{"version":3,"sources":["../../../../src/agents/experimental/replan/prompts.ts"],"names":["createRePlanOutputSchema","tools","toolSchemas","Promise","all","map","tool","name","description","input","z","object","passthrough","inputSchema","getInputJsonSchema","zodSchemaToJsonSchema","WeakMap","shape","definition","information","record","string","describe","lookback","plan","array","title","decision","research","boolean","computation","nextStep","discriminatedUnion","type","literal","message","hasAtLeast","calls","json","toJsonSchema","override","_def","def","typeName","ZodFirstPartyTypeKind","ZodObject","schema","get","delete","ignoreOverride","RePlanSystemPrompt","PromptTemplate","template","RePlanAssistantPrompt","results"],"mappings":";;;;;;;;;;AAuBA,eAAsBA,yBAA4CC,KAAU,EAAA;AAC1E,EAAA,MAAMC,cAAc,MAAMC,OAAAA,CAAQC,IAChCH,KAAMI,CAAAA,GAAAA,CAAI,OAAOC,IAAU,MAAA;AACzBC,IAAAA,IAAAA,EAAMD,IAAKC,CAAAA,IAAAA;AACXC,IAAAA,WAAAA,EAAaF,IAAKE,CAAAA,WAAAA;AAClBC,IAAAA,KAAAA,EAAOC,KAAEC,CAAAA,MAAAA,CAAO,EAAC,EAAGC,WAAW,EAAA;IAC/BC,WAAa,EAAA,MAAMP,KAAKQ,kBAAkB;AAC5C,GAAA,CAAA,CAAA,CAAA;AAEF,EAAA,MAAMC,wBAAwB,IAAIC,OAAAA,CAChCd,WAAYG,CAAAA,GAAAA,CAAI,CAACC,IAAS,KAAA;AAACA,IAAAA,IAAAA,CAAKG,KAAMQ,CAAAA,KAAAA;IAAOX,IAAKO,CAAAA;GAAY,CAAA,CAAA;AAGhE,EAAMK,MAAAA,UAAAA,GAAaR,MAAEC,MAAO,CAAA;AAC1BQ,IAAAA,WAAAA,EAAaT,MACVU,MAAOV,CAAAA,KAAAA,CAAEW,QAAM,CAAA,CACfC,SACC,mQAAA,CAAA;AAEJC,IAAAA,QAAAA,EAAUb,KACPW,CAAAA,MAAAA,EACAC,CAAAA,QAAAA,CACC,yMAAA,CAAA;IAEJE,IAAMd,EAAAA,KAAAA,CACHe,KACC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AA,CACCc,SAAS,sCAAA;UAEd;AACL,KAAA;GACH,CAAA;AAEA,EAAO,OAAA;AACLJ,IAAAA,UAAAA;AACAoB,IAAAA,IAAAA,EAAMC,wBAAarB,UAAY,EAAA;AAC7BsB,MAAAA,QAAAA,0BAAWC,IAAAA,KAAAA;AACT,QAAA,MAAMC,GAAMD,GAAAA,IAAAA;AACZ,QAAIC,IAAAA,GAAAA,CAAIC,QAAaC,KAAAA,yBAAAA,CAAsBC,SAAW,EAAA;AACpD,UAAM5B,MAAAA,KAAAA,GAAQyB,IAAIzB,KAAK,EAAA;AACvB,UAAM6B,MAAAA,MAAAA,GAAS/B,qBAAsBgC,CAAAA,GAAAA,CAAI9B,KAAAA,CAAAA;AACzC,UAAA,IAAI6B,MAAQ,EAAA;AACV/B,YAAAA,qBAAAA,CAAsBiC,OAAO/B,KAAAA,CAAAA;AAC7B,YAAO6B,OAAAA,MAAAA;AACT;AACF;AACA,QAAOG,OAAAA,8BAAAA;OAVC,EAAA,UAAA;KAYZ;AACF,GAAA;AACF;AA/FsBjD,MAAAA,CAAAA,wBAAAA,EAAAA,0BAAAA,CAAAA;AAqGTkD,MAAAA,kBAAAA,GAAqB,IAAIC,2BAAe,CAAA;AACnDL,EAAAA,MAAAA,EAAQpC,MAAEC,MAAO,CAAA;AACfmC,IAAAA,MAAAA,EAAQpC,MAAEW,MAAM;GAClB,CAAA;EACA+B,QAAU,EAAA,CAAA;;;;;;;AAOZ,CAAA;AAEaC,MAAAA,qBAAAA,GAAwB,IAAIF,2BAAe,CAAA;AACtDL,EAAAA,MAAAA,EAAQpC,MAAEC,MAAO,CAAA;AAAE2C,IAAAA,OAAAA,EAAS5C,MAAEW,MAAM;GAAG,CAAA;EACvC+B,QAAU,EAAA,CAAA,WAAA;AACZ,CAAA","file":"prompts.cjs","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { z, ZodFirstPartyTypeKind, ZodObjectDef, ZodTypeDef } from \"zod\";\nimport { PromptTemplate } from \"@/template.js\";\nimport { AnyTool } from \"@/tools/base.js\";\nimport { hasAtLeast, map } from \"remeda\";\nimport { toJsonSchema } from \"@/internals/helpers/schema.js\";\nimport { ignoreOverride, JsonSchema7Type } from \"zod-to-json-schema\";\n\nexport async function createRePlanOutputSchema<T extends AnyTool>(tools: T[]) {\n  const toolSchemas = await Promise.all(\n    tools.map(async (tool) => ({\n      name: tool.name,\n      description: tool.description,\n      input: z.object({}).passthrough(),\n      inputSchema: await tool.getInputJsonSchema(),\n    })),\n  );\n  const zodSchemaToJsonSchema = new WeakMap(\n    toolSchemas.map((tool) => [tool.input.shape, tool.inputSchema]),\n  );\n\n  const definition = z.object({\n    information: z\n      .record(z.string())\n      .describe(\n        \"Summary of the factual information that was collected so far. Eg. 'height of the Eiffel tower': '300m'. Only information that was provided by tools or the user in this very conversation is allowed to be included here. Other information must not be included.\",\n      ),\n    lookback: z\n      .string()\n      .describe(\n        \"A full summary of what has happened so far, focusing on what the assistant tried, what went well and what failed. This repeats in every message, but always concerns the full history up to that point.\",\n      ),\n    plan: z\n      .array(\n        z.object({\n          title: z\n            .string()\n            .describe(\"Title of this step, shortly describing what needs to be done.\"),\n          decision: z.string().describe(\"Assistant's decision of how to tackle this step.\"),\n          research: z\n            .boolean()\n            .describe(\"Does this step involve looking up factual information through tools?\"),\n          computation: z\n            .boolean()\n            .describe(\"Does this step involve calculating or computing information through tools?\"),\n        }),\n      )\n      .describe(\n        \"Detailed step-by-step plan of what steps will the assistant take from start to finish to fulfill the user's request. Includes concrete facts and numbers wherever possible. This repeats in every message, but always contains all the future steps from this point on.\",\n      ),\n    nextStep: z.discriminatedUnion(\"type\", [\n      z\n        .object({\n          type: z.literal(\"message\"),\n          message: z\n            .string()\n            .describe(\n              \"Message with the response, that is sent back to the user. Always include a bit of info on how you arrived at the answer. Be friendly and helpful.\",\n            ),\n        })\n        .describe(\"Message the user -- either to give the answer, or to ask for more information.\"),\n      ...(hasAtLeast(toolSchemas, 1)\n        ? [\n            z\n              .object({\n                type: z.literal(\"tool\"),\n                calls: z.array(\n                  z.discriminatedUnion(\n                    \"name\",\n                    map(toolSchemas, (tool) =>\n                      z\n                        .object({\n                          name: z.literal(tool.name),\n                          input: tool.input,\n                        })\n                        .describe(tool.description),\n                    ),\n                  ),\n                ),\n              })\n              .describe(\"Obtain more information using tools.\"),\n          ]\n        : []),\n    ]),\n  });\n\n  return {\n    definition,\n    json: toJsonSchema(definition, {\n      override: (_def: ZodTypeDef) => {\n        const def = _def as ZodObjectDef;\n        if (def.typeName === ZodFirstPartyTypeKind.ZodObject) {\n          const shape = def.shape();\n          const schema = zodSchemaToJsonSchema.get(shape) as JsonSchema7Type;\n          if (schema) {\n            zodSchemaToJsonSchema.delete(shape);\n            return schema;\n          }\n        }\n        return ignoreOverride;\n      },\n    }),\n  };\n}\n\nexport type RePlanState = z.output<\n  Awaited<ReturnType<typeof createRePlanOutputSchema>>[\"definition\"]\n>;\n\nexport const RePlanSystemPrompt = new PromptTemplate({\n  schema: z.object({\n    schema: z.string(),\n  }),\n  template: `The assistant is created by IBM and refers to itself as Bee. It's named after the IBM logo.\n\nThe assistant is very intelligent and helpful. It always thinks ahead, and uses smart approaches to solve the user's problems. The assistant is an expert-level user of the provided tools, and can utilize them to their maximum potential.\n\nThe assistant is forbidden from using factual information that was not provided by the user or tools in this very conversation. All information about places, people, events, etc. is unknown to the assistant, and the assistant must use tools to obtain it.\n\nOutput Schema: {{schema}}`,\n});\n\nexport const RePlanAssistantPrompt = new PromptTemplate({\n  schema: z.object({ results: z.string() }),\n  template: `{{results}}`,\n});\n"]}