{"version":3,"file":"ai-model/prompt/planning/planning-response-example.mjs","sources":["../../../../../src/ai-model/prompt/planning/planning-response-example.ts"],"sourcesContent":["import type { SubGoalStatus } from '@/types';\n\ntype PlanningSubGoalExample = {\n  index: number;\n  status: Extract<SubGoalStatus, 'pending' | 'finished'>;\n  description: string;\n};\n\ntype PlanningResponseActionOutputExample = {\n  log?: string;\n  actionOutputExample: string | undefined;\n  complete?: never;\n};\n\ntype PlanningResponseCompleteExample = {\n  complete: {\n    success: boolean;\n    message: string;\n  };\n  log?: never;\n  actionOutputExample?: never;\n};\n\nexport type BuildPlanningResponseExampleInput = {\n  prefix?: string;\n  planning?: string;\n  updateSubGoals?: PlanningSubGoalExample[];\n  markSubGoalsDone?: number[];\n  memory?: string;\n} & (PlanningResponseActionOutputExample | PlanningResponseCompleteExample);\n\nexport const buildPlanningResponseExample = (\n  input: BuildPlanningResponseExampleInput,\n) => {\n  const sections = input.prefix ? [input.prefix] : [];\n\n  if (input.planning) {\n    sections.push(`<planning>${input.planning}</planning>`);\n  }\n\n  if (input.updateSubGoals?.length) {\n    const subGoals = input.updateSubGoals\n      .map(\n        ({ index, status, description }) =>\n          `  <sub-goal index=\"${index}\" status=\"${status}\">${description}</sub-goal>`,\n      )\n      .join('\\n');\n    sections.push(`<update-plan-content>\\n${subGoals}\\n</update-plan-content>`);\n  }\n\n  if (input.markSubGoalsDone?.length) {\n    const subGoals = input.markSubGoalsDone\n      .map((index) => `  <sub-goal index=\"${index}\" status=\"finished\" />`)\n      .join('\\n');\n    sections.push(`<mark-sub-goal-done>\\n${subGoals}\\n</mark-sub-goal-done>`);\n  }\n\n  if (input.memory) {\n    sections.push(`<memory>${input.memory}</memory>`);\n  }\n\n  if (input.complete) {\n    sections.push(\n      `<complete success=\"${input.complete.success}\">${input.complete.message}</complete>`,\n    );\n  } else {\n    if (!input.actionOutputExample) {\n      throw new Error(\n        'Cannot build planning response example without an action output example',\n      );\n    }\n    if (input.log) {\n      sections.push(`<log>${input.log}</log>`);\n    }\n    sections.push(input.actionOutputExample);\n  }\n\n  return sections.join('\\n');\n};\n"],"names":["buildPlanningResponseExample","input","sections","subGoals","index","status","description","Error"],"mappings":"AA+BO,MAAMA,+BAA+B,CAC1CC;IAEA,MAAMC,WAAWD,MAAM,MAAM,GAAG;QAACA,MAAM,MAAM;KAAC,GAAG,EAAE;IAEnD,IAAIA,MAAM,QAAQ,EAChBC,SAAS,IAAI,CAAC,CAAC,UAAU,EAAED,MAAM,QAAQ,CAAC,WAAW,CAAC;IAGxD,IAAIA,MAAM,cAAc,EAAE,QAAQ;QAChC,MAAME,WAAWF,MAAM,cAAc,CAClC,GAAG,CACF,CAAC,EAAEG,KAAK,EAAEC,MAAM,EAAEC,WAAW,EAAE,GAC7B,CAAC,mBAAmB,EAAEF,MAAM,UAAU,EAAEC,OAAO,EAAE,EAAEC,YAAY,WAAW,CAAC,EAE9E,IAAI,CAAC;QACRJ,SAAS,IAAI,CAAC,CAAC,uBAAuB,EAAEC,SAAS,wBAAwB,CAAC;IAC5E;IAEA,IAAIF,MAAM,gBAAgB,EAAE,QAAQ;QAClC,MAAME,WAAWF,MAAM,gBAAgB,CACpC,GAAG,CAAC,CAACG,QAAU,CAAC,mBAAmB,EAAEA,MAAM,sBAAsB,CAAC,EAClE,IAAI,CAAC;QACRF,SAAS,IAAI,CAAC,CAAC,sBAAsB,EAAEC,SAAS,uBAAuB,CAAC;IAC1E;IAEA,IAAIF,MAAM,MAAM,EACdC,SAAS,IAAI,CAAC,CAAC,QAAQ,EAAED,MAAM,MAAM,CAAC,SAAS,CAAC;IAGlD,IAAIA,MAAM,QAAQ,EAChBC,SAAS,IAAI,CACX,CAAC,mBAAmB,EAAED,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAEA,MAAM,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC;SAEjF;QACL,IAAI,CAACA,MAAM,mBAAmB,EAC5B,MAAM,IAAIM,MACR;QAGJ,IAAIN,MAAM,GAAG,EACXC,SAAS,IAAI,CAAC,CAAC,KAAK,EAAED,MAAM,GAAG,CAAC,MAAM,CAAC;QAEzCC,SAAS,IAAI,CAACD,MAAM,mBAAmB;IACzC;IAEA,OAAOC,SAAS,IAAI,CAAC;AACvB"}