{"version":3,"sources":["../../src/tools/think.ts"],"names":["ThinkSchema","z","object","thoughts","string","describe","ThinkTool","Tool","name","description","emitter","_inputSchema","_toolOutput","_extraInstructions","options","schema","toolOutput","extraInstructions","createEmitter","inputSchema","_run","input","_options","_context","output","StringToolOutput","Emitter","root","child","namespace","creator"],"mappings":";;;;;;;;AAUA,MAAMA,WAAAA,GAAcC,MAAEC,MAAAA,CAAO;AAC3BC,EAAAA,QAAAA,EAAUF,KAAAA,CAAEG,MAAAA,EAAM,CAAGC,QAAAA,CAAS,iDAAA;AAChC,CAAA,CAAA;AAUO,MAAMC,kBAAkBC,aAAAA,CAAAA;EAtB/B;;;EAuBSC,IAAAA,GAAO,OAAA;EACPC,WAAAA,GACL,kIAAA;AAEcC,EAAAA,OAAAA;AAENC,EAAAA,YAAAA;AACAC,EAAAA,WAAAA;AACAC,EAAAA,kBAAAA;EAEV,WAAA,CAAYC,OAAAA,GAA4B,EAAC,EAAG;AAC1C,IAAA,KAAA,CAAMA,OAAAA,CAAAA;AACN,IAAA,IAAA,CAAKH,YAAAA,GAAeG,QAAQC,MAAAA,IAAUf,WAAAA;AACtC,IAAA,IAAA,CAAKY,WAAAA,GAAcE,QAAQE,UAAAA,IAAc,IAAA;AACzC,IAAA,IAAA,CAAKH,kBAAAA,GAAqBC,QAAQG,iBAAAA,IAAqB,EAAA;AAEvD,IAAA,IAAI,KAAKJ,kBAAAA,EAAoB;AAC3B,MAAA,IAAA,CAAKJ,WAAAA,IAAe,CAAA,CAAA,EAAI,IAAA,CAAKI,kBAAkB,CAAA,CAAA;AACjD,IAAA;AAEA,IAAA,IAAA,CAAKH,OAAAA,GAAU,KAAKQ,aAAAA,EAAa;AACnC,EAAA;EAEAC,WAAAA,GAAyB;AACvB,IAAA,OAAO,IAAA,CAAKR,YAAAA;AACd,EAAA;EAEA,MAAMS,IAAAA,CACJC,KAAAA,EACAC,QAAAA,EACAC,QAAAA,EAC2B;AAC3B,IAAA,MAAMC,MAAAA,GACJ,OAAO,IAAA,CAAKZ,WAAAA,KAAgB,aAAa,IAAA,CAAKA,WAAAA,CAAYS,KAAAA,CAAAA,GAAS,IAAA,CAAKT,WAAAA;AAC1E,IAAA,OAAO,IAAIa,0BAAiBD,MAAAA,CAAAA;AAC9B,EAAA;EAEUN,aAAAA,GAA8B;AACtC,IAAA,OAAOQ,mBAAAA,CAAQC,KAAKC,KAAAA,CAAM;MACxBC,SAAAA,EAAW;AAAC,QAAA,MAAA;AAAQ,QAAA;;MACpBC,OAAAA,EAAS;KACX,CAAA;AACF,EAAA;AACF","file":"think.cjs","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { z, ZodSchema } from \"zod\";\nimport { Tool, StringToolOutput, BaseToolRunOptions, BaseToolOptions } from \"@/tools/base.js\";\nimport { RunContext } from \"@/context.js\";\nimport { Emitter } from \"@/emitter/emitter.js\";\n\nconst ThinkSchema = z.object({\n  thoughts: z.string().describe(\"Precisely describe what you are thinking about.\"),\n});\n\ntype ThinkInput = z.infer<typeof ThinkSchema>;\n\nexport interface ThinkToolOptions extends BaseToolOptions<StringToolOutput> {\n  extraInstructions?: string;\n  toolOutput?: string | ((input: ThinkInput) => string);\n  schema?: ZodSchema;\n}\n\nexport class ThinkTool extends Tool<StringToolOutput, ThinkToolOptions> {\n  public name = \"think\";\n  public description =\n    \"Use when you want to think through a problem, clarify your assumptions, or break down complex steps before acting or responding.\";\n\n  public readonly emitter: Emitter<any>;\n\n  protected _inputSchema: ZodSchema;\n  protected _toolOutput: string | ((input: ThinkInput) => string);\n  protected _extraInstructions: string;\n\n  constructor(options: ThinkToolOptions = {}) {\n    super(options);\n    this._inputSchema = options.schema ?? ThinkSchema;\n    this._toolOutput = options.toolOutput ?? \"OK\";\n    this._extraInstructions = options.extraInstructions ?? \"\";\n\n    if (this._extraInstructions) {\n      this.description += ` ${this._extraInstructions}`;\n    }\n\n    this.emitter = this.createEmitter();\n  }\n\n  inputSchema(): ZodSchema {\n    return this._inputSchema;\n  }\n\n  async _run(\n    input: ThinkInput,\n    _options: BaseToolRunOptions,\n    _context: RunContext<typeof this>,\n  ): Promise<StringToolOutput> {\n    const output =\n      typeof this._toolOutput === \"function\" ? this._toolOutput(input) : this._toolOutput;\n    return new StringToolOutput(output);\n  }\n\n  protected createEmitter(): Emitter<any> {\n    return Emitter.root.child({\n      namespace: [\"tool\", \"think\"],\n      creator: this,\n    });\n  }\n}\n"]}