{"version":3,"sources":["../../../../../src/agents/react/runners/deep-think/runner.ts"],"names":["DeepThinkRunner","DefaultRunner","defaultTemplates","system","DeepThinkReActAgentSystemPrompt","assistant","DeepThinkReActAgentAssistantPrompt","user","DeepThinkReActAgentUserPrompt","schemaError","DeepThinkReActAgentSchemaErrorPrompt","toolNotFoundError","DeepThinkReActAgentToolNotFoundPrompt","toolError","DeepThinkReActAgentToolErrorPrompt","toolInputError","DeepThinkReActAgentToolInputErrorPrompt","userEmpty","ReActAgentUserEmptyPrompt","toolNoResultError","ReActAgentToolNoResultsPrompt","register","input","options","run","emitter","on","update","meta","memory","key","add","UserMessage","value","success","createdAt","Date","isBlocking","createParser","tools","parser","fork","nodes","silentNodes","thought","prefix","next","isStart","field","ZodParserField","z","string","min","dummy_thought_end","isDummy","transform","_","tool_name","tool_input","isEnd","tool_output","final_answer","enumerable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAMA,wBAAwBC,wBAAAA,CAAAA;AAAAA,EAAAA;;;AACnC,EAAA,IACWC,gBAAAA,GAAmB;AAC5B,IAAA,OAAO;MACLC,MAAAA,EAAQC,6CAAAA;MACRC,SAAAA,EAAWC,gDAAAA;MACXC,IAAAA,EAAMC,2CAAAA;MACNC,WAAAA,EAAaC,kDAAAA;MACbC,iBAAAA,EAAmBC,mDAAAA;MACnBC,SAAAA,EAAWC,gDAAAA;MACXC,cAAAA,EAAgBC,qDAAAA;;MAEhBC,SAAAA,EAAWC,qCAAAA;MACXC,iBAAAA,EAAmBC;AACrB,KAAA;AACF,EAAA;EAEA;AACE,IAAA,IAAA,CAAKC,QAAAA,EAAQ;AACf;EAEA,WAAA,CACEC,KAAAA,EACAC,SACAC,GAAAA,EACA;AACA,IAAA,KAAA,CAAMF,KAAAA,EAAOC,SAASC,GAAAA,CAAAA;AAEtBA,IAAAA,GAAAA,CAAIC,OAAAA,CAAQC,GACV,QAAA,EACA,OAAO,EAAEC,MAAAA,EAAQC,IAAAA,EAAMC,QAAM,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ACxD,WAAA;UACAC,SAAAA,EAAW;AAAE,YAAA,GAAGf,KAAAA,CAAMe,SAAAA;YAAWZ,MAAAA,EAAQ;AAAa,WAAA;UACtDa,UAAAA,EAAY;AACV,YAAA,GAAGhB,KAAAA,CAAMgB,UAAAA;YACTb,MAAAA,EAAQ,aAAA;YACRc,KAAAA,EAAO,IAAA;AACPb,YAAAA,IAAAA,EAAM;AACR,WAAA;UACAc,WAAAA,EAAa;AAAE,YAAA,GAAGlB,KAAAA,CAAMe,SAAAA;YAAWZ,MAAAA,EAAQ;AAAe,WAAA;UAC1DgB,YAAAA,EAAc;AAAE,YAAA,GAAGnB,KAAAA,CAAMmB,YAAAA;YAAchB,MAAAA,EAAQ;AAAY;AAC7D;OACF,CAAA;AACF,KAAA;AACF,EAAA;AACF;;;IAjFWiB,UAAAA,EAAY","file":"runner.cjs","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { AnyTool } from \"@/tools/base.js\";\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport {\n  DeepThinkReActAgentAssistantPrompt,\n  DeepThinkReActAgentSchemaErrorPrompt,\n  DeepThinkReActAgentSystemPrompt,\n  DeepThinkReActAgentToolErrorPrompt,\n  DeepThinkReActAgentToolInputErrorPrompt,\n  DeepThinkReActAgentToolNotFoundPrompt,\n  DeepThinkReActAgentUserPrompt,\n} from \"@/agents/react/runners/deep-think/prompts.js\";\nimport {\n  ReActAgentToolNoResultsPrompt,\n  ReActAgentUserEmptyPrompt,\n} from \"@/agents/react/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\nimport { ZodParserField } from \"@/parsers/field.js\";\nimport { z } from \"zod\";\nimport { ReActAgentInput, ReActAgent } from \"@/agents/react/agent.js\";\nimport { ReActAgentRunOptions } from \"@/agents/react/types.js\";\nimport { GetRunContext } from \"@/context.js\";\nimport { UserMessage } from \"@/backend/message.js\";\n\nexport class DeepThinkRunner extends DefaultRunner {\n  @Cache({ enumerable: false })\n  public get defaultTemplates() {\n    return {\n      system: DeepThinkReActAgentSystemPrompt,\n      assistant: DeepThinkReActAgentAssistantPrompt,\n      user: DeepThinkReActAgentUserPrompt,\n      schemaError: DeepThinkReActAgentSchemaErrorPrompt,\n      toolNotFoundError: DeepThinkReActAgentToolNotFoundPrompt,\n      toolError: DeepThinkReActAgentToolErrorPrompt,\n      toolInputError: DeepThinkReActAgentToolInputErrorPrompt,\n      // Note: These are from ReAct\n      userEmpty: ReActAgentUserEmptyPrompt,\n      toolNoResultError: ReActAgentToolNoResultsPrompt,\n    };\n  }\n\n  static {\n    this.register();\n  }\n\n  constructor(\n    input: ReActAgentInput,\n    options: ReActAgentRunOptions,\n    run: GetRunContext<ReActAgent>,\n  ) {\n    super(input, options, run);\n\n    run.emitter.on(\n      \"update\",\n      async ({ update, meta, memory }) => {\n        if (update.key === \"tool_output\") {\n          await memory.add(\n            new UserMessage(update.value, { success: meta.success, createdAt: new Date() }),\n          );\n        }\n      },\n      {\n        isBlocking: true,\n      },\n    );\n  }\n\n  protected createParser(tools: AnyTool[]) {\n    const { parser } = super.createParser(tools);\n\n    return {\n      parser: parser.fork((nodes, options) => ({\n        options: {\n          ...options,\n          // @ts-expect-error\n          silentNodes: [...(options?.silentNodes ?? []), \"dummy_thought_end\"],\n        },\n        nodes: {\n          ...nodes,\n          thought: {\n            ...nodes.thought,\n            prefix: \"<think>\",\n            // @ts-expect-error\n            next: [\"dummy_thought_end\"] as const,\n            isStart: true,\n            field: new ZodParserField(z.string().min(1)),\n          },\n          dummy_thought_end: {\n            prefix: \"</think>\",\n            isDummy: true,\n            next: [\"tool_name\", \"final_answer\"],\n            field: new ZodParserField(z.string().transform((_) => \"\")),\n          },\n          tool_name: { ...nodes.tool_name, prefix: \"Tool Name:\" },\n          tool_input: {\n            ...nodes.tool_input,\n            prefix: \"Tool Input:\",\n            isEnd: true,\n            next: [],\n          },\n          tool_output: { ...nodes.tool_name, prefix: \"Tool Output:\" },\n          final_answer: { ...nodes.final_answer, prefix: \"Response:\" },\n        },\n      })),\n    } as const;\n  }\n}\n"]}