@langchain/openai 1.2.13 → 1.3.0-dev-1773709997654

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/dist/azure/chat_models/common.cjs +2 -3
  2. package/dist/azure/chat_models/common.cjs.map +1 -1
  3. package/dist/azure/chat_models/common.d.ts +0 -1
  4. package/dist/azure/chat_models/common.d.ts.map +1 -1
  5. package/dist/azure/chat_models/common.js +1 -2
  6. package/dist/azure/chat_models/common.js.map +1 -1
  7. package/dist/azure/chat_models/completions.cjs +3 -4
  8. package/dist/azure/chat_models/completions.cjs.map +1 -1
  9. package/dist/azure/chat_models/completions.js +1 -2
  10. package/dist/azure/chat_models/completions.js.map +1 -1
  11. package/dist/azure/chat_models/index.cjs +5 -6
  12. package/dist/azure/chat_models/index.cjs.map +1 -1
  13. package/dist/azure/chat_models/index.js +1 -2
  14. package/dist/azure/chat_models/index.js.map +1 -1
  15. package/dist/azure/chat_models/responses.cjs +3 -4
  16. package/dist/azure/chat_models/responses.cjs.map +1 -1
  17. package/dist/azure/chat_models/responses.js +1 -2
  18. package/dist/azure/chat_models/responses.js.map +1 -1
  19. package/dist/azure/embeddings.cjs +4 -5
  20. package/dist/azure/embeddings.cjs.map +1 -1
  21. package/dist/azure/embeddings.d.cts +2 -2
  22. package/dist/azure/embeddings.d.cts.map +1 -1
  23. package/dist/azure/embeddings.d.ts +2 -2
  24. package/dist/azure/embeddings.d.ts.map +1 -1
  25. package/dist/azure/embeddings.js +1 -2
  26. package/dist/azure/embeddings.js.map +1 -1
  27. package/dist/azure/llms.cjs +3 -4
  28. package/dist/azure/llms.cjs.map +1 -1
  29. package/dist/azure/llms.js +1 -2
  30. package/dist/azure/llms.js.map +1 -1
  31. package/dist/chat_models/base.cjs +15 -10
  32. package/dist/chat_models/base.cjs.map +1 -1
  33. package/dist/chat_models/base.d.cts +20 -20
  34. package/dist/chat_models/base.d.cts.map +1 -1
  35. package/dist/chat_models/base.d.ts +20 -20
  36. package/dist/chat_models/base.d.ts.map +1 -1
  37. package/dist/chat_models/base.js +11 -6
  38. package/dist/chat_models/base.js.map +1 -1
  39. package/dist/chat_models/completions.cjs +6 -7
  40. package/dist/chat_models/completions.cjs.map +1 -1
  41. package/dist/chat_models/completions.d.cts +6 -6
  42. package/dist/chat_models/completions.d.cts.map +1 -1
  43. package/dist/chat_models/completions.d.ts +6 -6
  44. package/dist/chat_models/completions.d.ts.map +1 -1
  45. package/dist/chat_models/completions.js +1 -2
  46. package/dist/chat_models/completions.js.map +1 -1
  47. package/dist/chat_models/index.cjs +6 -7
  48. package/dist/chat_models/index.cjs.map +1 -1
  49. package/dist/chat_models/index.js +1 -2
  50. package/dist/chat_models/index.js.map +1 -1
  51. package/dist/chat_models/profiles.cjs +1 -2
  52. package/dist/chat_models/profiles.cjs.map +1 -1
  53. package/dist/chat_models/profiles.js +1 -1
  54. package/dist/chat_models/responses.cjs +17 -14
  55. package/dist/chat_models/responses.cjs.map +1 -1
  56. package/dist/chat_models/responses.d.cts +8 -8
  57. package/dist/chat_models/responses.d.cts.map +1 -1
  58. package/dist/chat_models/responses.d.ts +8 -8
  59. package/dist/chat_models/responses.d.ts.map +1 -1
  60. package/dist/chat_models/responses.js +13 -10
  61. package/dist/chat_models/responses.js.map +1 -1
  62. package/dist/converters/completions.cjs +3 -4
  63. package/dist/converters/completions.cjs.map +1 -1
  64. package/dist/converters/completions.d.cts +8 -8
  65. package/dist/converters/completions.d.cts.map +1 -1
  66. package/dist/converters/completions.d.ts +8 -8
  67. package/dist/converters/completions.d.ts.map +1 -1
  68. package/dist/converters/completions.js +1 -2
  69. package/dist/converters/completions.js.map +1 -1
  70. package/dist/converters/index.cjs +2 -2
  71. package/dist/converters/index.js +3 -4
  72. package/dist/converters/responses.cjs +15 -11
  73. package/dist/converters/responses.cjs.map +1 -1
  74. package/dist/converters/responses.d.cts +8 -8
  75. package/dist/converters/responses.d.cts.map +1 -1
  76. package/dist/converters/responses.d.ts +8 -8
  77. package/dist/converters/responses.d.ts.map +1 -1
  78. package/dist/converters/responses.js +12 -8
  79. package/dist/converters/responses.js.map +1 -1
  80. package/dist/embeddings.cjs +3 -4
  81. package/dist/embeddings.cjs.map +1 -1
  82. package/dist/embeddings.d.cts +4 -4
  83. package/dist/embeddings.d.cts.map +1 -1
  84. package/dist/embeddings.d.ts +4 -4
  85. package/dist/embeddings.d.ts.map +1 -1
  86. package/dist/embeddings.js +3 -4
  87. package/dist/embeddings.js.map +1 -1
  88. package/dist/index.cjs +33 -34
  89. package/dist/index.d.cts +2 -1
  90. package/dist/index.d.ts +2 -2
  91. package/dist/index.js +1 -2
  92. package/dist/llms.cjs +4 -5
  93. package/dist/llms.cjs.map +1 -1
  94. package/dist/llms.d.cts +7 -7
  95. package/dist/llms.d.cts.map +1 -1
  96. package/dist/llms.d.ts +7 -7
  97. package/dist/llms.d.ts.map +1 -1
  98. package/dist/llms.js +4 -5
  99. package/dist/llms.js.map +1 -1
  100. package/dist/tools/applyPatch.cjs +1 -2
  101. package/dist/tools/applyPatch.cjs.map +1 -1
  102. package/dist/tools/applyPatch.d.cts +6 -6
  103. package/dist/tools/applyPatch.d.cts.map +1 -1
  104. package/dist/tools/applyPatch.d.ts +6 -6
  105. package/dist/tools/applyPatch.d.ts.map +1 -1
  106. package/dist/tools/applyPatch.js +1 -2
  107. package/dist/tools/applyPatch.js.map +1 -1
  108. package/dist/tools/codeInterpreter.cjs +1 -2
  109. package/dist/tools/codeInterpreter.cjs.map +1 -1
  110. package/dist/tools/codeInterpreter.d.cts +2 -2
  111. package/dist/tools/codeInterpreter.d.cts.map +1 -1
  112. package/dist/tools/codeInterpreter.d.ts +2 -2
  113. package/dist/tools/codeInterpreter.d.ts.map +1 -1
  114. package/dist/tools/codeInterpreter.js +1 -1
  115. package/dist/tools/computerUse.cjs +1 -2
  116. package/dist/tools/computerUse.cjs.map +1 -1
  117. package/dist/tools/computerUse.d.cts +12 -12
  118. package/dist/tools/computerUse.d.cts.map +1 -1
  119. package/dist/tools/computerUse.d.ts +12 -12
  120. package/dist/tools/computerUse.d.ts.map +1 -1
  121. package/dist/tools/computerUse.js +1 -2
  122. package/dist/tools/computerUse.js.map +1 -1
  123. package/dist/tools/custom.cjs +1 -2
  124. package/dist/tools/custom.cjs.map +1 -1
  125. package/dist/tools/custom.d.cts +2 -2
  126. package/dist/tools/custom.d.cts.map +1 -1
  127. package/dist/tools/custom.d.ts +2 -2
  128. package/dist/tools/custom.d.ts.map +1 -1
  129. package/dist/tools/custom.js +1 -2
  130. package/dist/tools/custom.js.map +1 -1
  131. package/dist/tools/dalle.cjs +1 -2
  132. package/dist/tools/dalle.cjs.map +1 -1
  133. package/dist/tools/dalle.d.cts +3 -3
  134. package/dist/tools/dalle.d.cts.map +1 -1
  135. package/dist/tools/dalle.d.ts +3 -3
  136. package/dist/tools/dalle.d.ts.map +1 -1
  137. package/dist/tools/dalle.js +3 -4
  138. package/dist/tools/dalle.js.map +1 -1
  139. package/dist/tools/fileSearch.cjs +1 -2
  140. package/dist/tools/fileSearch.cjs.map +1 -1
  141. package/dist/tools/fileSearch.d.cts +2 -2
  142. package/dist/tools/fileSearch.d.cts.map +1 -1
  143. package/dist/tools/fileSearch.d.ts +2 -2
  144. package/dist/tools/fileSearch.d.ts.map +1 -1
  145. package/dist/tools/fileSearch.js +1 -1
  146. package/dist/tools/fileSearch.js.map +1 -1
  147. package/dist/tools/imageGeneration.cjs +1 -2
  148. package/dist/tools/imageGeneration.cjs.map +1 -1
  149. package/dist/tools/imageGeneration.d.cts +2 -2
  150. package/dist/tools/imageGeneration.d.cts.map +1 -1
  151. package/dist/tools/imageGeneration.d.ts +2 -2
  152. package/dist/tools/imageGeneration.d.ts.map +1 -1
  153. package/dist/tools/imageGeneration.js +1 -1
  154. package/dist/tools/imageGeneration.js.map +1 -1
  155. package/dist/tools/index.cjs +14 -13
  156. package/dist/tools/index.cjs.map +1 -1
  157. package/dist/tools/index.d.cts +2 -0
  158. package/dist/tools/index.d.cts.map +1 -1
  159. package/dist/tools/index.d.ts +2 -0
  160. package/dist/tools/index.d.ts.map +1 -1
  161. package/dist/tools/index.js +5 -4
  162. package/dist/tools/index.js.map +1 -1
  163. package/dist/tools/localShell.cjs +1 -2
  164. package/dist/tools/localShell.cjs.map +1 -1
  165. package/dist/tools/localShell.d.cts +4 -4
  166. package/dist/tools/localShell.d.cts.map +1 -1
  167. package/dist/tools/localShell.d.ts +4 -4
  168. package/dist/tools/localShell.d.ts.map +1 -1
  169. package/dist/tools/localShell.js +1 -2
  170. package/dist/tools/localShell.js.map +1 -1
  171. package/dist/tools/mcp.cjs +1 -2
  172. package/dist/tools/mcp.cjs.map +1 -1
  173. package/dist/tools/mcp.d.cts +2 -2
  174. package/dist/tools/mcp.d.cts.map +1 -1
  175. package/dist/tools/mcp.d.ts +2 -2
  176. package/dist/tools/mcp.d.ts.map +1 -1
  177. package/dist/tools/mcp.js +1 -1
  178. package/dist/tools/mcp.js.map +1 -1
  179. package/dist/tools/shell.cjs +1 -2
  180. package/dist/tools/shell.cjs.map +1 -1
  181. package/dist/tools/shell.d.cts +5 -5
  182. package/dist/tools/shell.d.cts.map +1 -1
  183. package/dist/tools/shell.d.ts +5 -5
  184. package/dist/tools/shell.d.ts.map +1 -1
  185. package/dist/tools/shell.js +1 -2
  186. package/dist/tools/shell.js.map +1 -1
  187. package/dist/tools/toolSearch.cjs +67 -0
  188. package/dist/tools/toolSearch.cjs.map +1 -0
  189. package/dist/tools/toolSearch.d.cts +79 -0
  190. package/dist/tools/toolSearch.d.cts.map +1 -0
  191. package/dist/tools/toolSearch.d.ts +79 -0
  192. package/dist/tools/toolSearch.d.ts.map +1 -0
  193. package/dist/tools/toolSearch.js +67 -0
  194. package/dist/tools/toolSearch.js.map +1 -0
  195. package/dist/tools/webSearch.cjs +1 -2
  196. package/dist/tools/webSearch.cjs.map +1 -1
  197. package/dist/tools/webSearch.d.cts +2 -2
  198. package/dist/tools/webSearch.d.cts.map +1 -1
  199. package/dist/tools/webSearch.d.ts +2 -2
  200. package/dist/tools/webSearch.d.ts.map +1 -1
  201. package/dist/tools/webSearch.js +1 -1
  202. package/dist/tools/webSearch.js.map +1 -1
  203. package/dist/types.d.cts +10 -10
  204. package/dist/types.d.cts.map +1 -1
  205. package/dist/types.d.ts +10 -10
  206. package/dist/types.d.ts.map +1 -1
  207. package/dist/utils/azure.cjs +2 -3
  208. package/dist/utils/azure.cjs.map +1 -1
  209. package/dist/utils/azure.js +1 -2
  210. package/dist/utils/azure.js.map +1 -1
  211. package/dist/utils/client.cjs +2 -3
  212. package/dist/utils/client.cjs.map +1 -1
  213. package/dist/utils/client.js +1 -2
  214. package/dist/utils/client.js.map +1 -1
  215. package/dist/utils/errors.cjs +1 -2
  216. package/dist/utils/errors.cjs.map +1 -1
  217. package/dist/utils/errors.js +1 -1
  218. package/dist/utils/errors.js.map +1 -1
  219. package/dist/utils/misc.cjs +1 -2
  220. package/dist/utils/misc.cjs.map +1 -1
  221. package/dist/utils/misc.d.cts +2 -2
  222. package/dist/utils/misc.d.cts.map +1 -1
  223. package/dist/utils/misc.d.ts +2 -2
  224. package/dist/utils/misc.d.ts.map +1 -1
  225. package/dist/utils/misc.js +1 -2
  226. package/dist/utils/misc.js.map +1 -1
  227. package/dist/utils/output.cjs +1 -2
  228. package/dist/utils/output.cjs.map +1 -1
  229. package/dist/utils/output.js +1 -2
  230. package/dist/utils/output.js.map +1 -1
  231. package/dist/utils/prompts.cjs +2 -3
  232. package/dist/utils/prompts.cjs.map +1 -1
  233. package/dist/utils/prompts.d.cts +2 -2
  234. package/dist/utils/prompts.d.cts.map +1 -1
  235. package/dist/utils/prompts.d.ts +2 -2
  236. package/dist/utils/prompts.d.ts.map +1 -1
  237. package/dist/utils/prompts.js +1 -2
  238. package/dist/utils/prompts.js.map +1 -1
  239. package/dist/utils/tools.cjs +3 -4
  240. package/dist/utils/tools.cjs.map +1 -1
  241. package/dist/utils/tools.d.cts +5 -5
  242. package/dist/utils/tools.d.cts.map +1 -1
  243. package/dist/utils/tools.d.ts +5 -6
  244. package/dist/utils/tools.d.ts.map +1 -1
  245. package/dist/utils/tools.js +3 -4
  246. package/dist/utils/tools.js.map +1 -1
  247. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"shell.cjs","names":["z"],"sources":["../../src/tools/shell.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { tool, type DynamicStructuredTool } from \"@langchain/core/tools\";\n\n/**\n * Re-export action type from OpenAI SDK for convenience.\n * The action contains command details like commands array, timeout, and max output length.\n */\nexport type ShellAction =\n OpenAIClient.Responses.ResponseFunctionShellToolCall.Action;\n\n// Zod schema for shell action\nexport const ShellActionSchema = z.object({\n commands: z.array(z.string()).describe(\"Array of shell commands to execute\"),\n timeout_ms: z\n .number()\n .optional()\n .describe(\"Optional timeout in milliseconds for the commands\"),\n max_output_length: z\n .number()\n .optional()\n .describe(\n \"Optional maximum number of characters to return from each command\"\n ),\n});\n\n/**\n * Result of a single shell command execution.\n * Contains stdout, stderr, and the outcome (exit code or timeout).\n */\nexport type ShellCommandOutput =\n OpenAIClient.Responses.ResponseFunctionShellCallOutputContent;\n\n/**\n * Outcome type for shell command execution - either exit with code or timeout.\n */\nexport type ShellCallOutcome = ShellCommandOutput[\"outcome\"];\n\n/**\n * Result of executing shell commands.\n * Contains an array of outputs (one per command) and the max_output_length parameter.\n */\nexport interface ShellResult {\n /**\n * Array of command outputs. Each entry corresponds to a command from the action.\n * The order should match the order of commands in the action.\n */\n output: ShellCommandOutput[];\n /**\n * The max_output_length from the action, which must be passed back to the API.\n * If not provided in the action, can be omitted.\n */\n maxOutputLength?: number | null;\n}\n\n/**\n * Options for the Shell tool.\n */\nexport interface ShellOptions {\n /**\n * Execute function that handles shell command execution.\n * This function receives the action input containing the commands and limits,\n * and should return a ShellResult with stdout, stderr, and outcome for each command.\n *\n * @example\n * ```typescript\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * }\n * ```\n */\n execute: (action: ShellAction) => ShellResult | Promise<ShellResult>;\n}\n\n/**\n * OpenAI Shell tool type for the Responses API.\n */\nexport type ShellTool = OpenAIClient.Responses.FunctionShellTool;\n\nconst TOOL_NAME = \"shell\";\n\n/**\n * Creates a Shell tool that allows models to run shell commands through your integration.\n *\n * The shell tool allows the model to interact with your local computer through a controlled\n * command-line interface. The model proposes shell commands; your integration executes them\n * and returns the outputs. This creates a simple plan-execute loop that lets models inspect\n * the system, run utilities, and gather data until they can finish the task.\n *\n * **Important**: The shell tool is available through the Responses API for use with `GPT-5.1`.\n * It is not available on other models, or via the Chat Completions API.\n *\n * **When to use**:\n * - **Automating filesystem or process diagnostics** – For example, \"find the largest PDF\n * under ~/Documents\" or \"show running gunicorn processes.\"\n * - **Extending the model's capabilities** – Using built-in UNIX utilities, python runtime\n * and other CLIs in your environment.\n * - **Running multi-step build and test flows** – Chaining commands like `pip install` and `pytest`.\n * - **Complex agentic coding workflows** – Using other tools like `apply_patch` to complete\n * workflows that involve complex file operations.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends shell commands (`shell_call` with `commands` array)\n * 2. Your code executes the commands (can be concurrent)\n * 3. You return stdout, stderr, and outcome for each command\n * 4. Repeat until the task is complete\n *\n * **Security Warning**: Running arbitrary shell commands can be dangerous.\n * Always sandbox execution or add strict allow/deny-lists before forwarding\n * a command to the system shell.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-shell | OpenAI Shell Documentation}\n * @see {@link https://github.com/openai/codex | Codex CLI} for reference implementation.\n *\n * @param options - Configuration for the Shell tool\n * @returns A Shell tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { exec } from \"child_process/promises\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.1\" });\n *\n * // With execute callback for automatic command handling\n * const shellTool = tools.shell({\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * },\n * });\n *\n * const llmWithShell = model.bindTools([shellTool]);\n * const response = await llmWithShell.invoke(\n * \"Find the largest PDF file in ~/Documents\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Full shell loop example\n * async function shellLoop(model, task) {\n * let response = await model.invoke(task, {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n *\n * while (true) {\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"shell_call\"\n * );\n *\n * if (!shellCall) break;\n *\n * // Execute commands (with proper sandboxing!)\n * const result = await executeCommands(shellCall.action);\n *\n * // Send output back to model\n * response = await model.invoke([\n * response,\n * {\n * type: \"shell_call_output\",\n * call_id: shellCall.call_id,\n * output: result.output,\n * max_output_length: result.maxOutputLength,\n * },\n * ], {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n * }\n *\n * return response;\n * }\n * ```\n *\n * @remarks\n * - Only available through the Responses API (not Chat Completions)\n * - Designed for use with `gpt-5.1` model\n * - Commands are provided as an array of strings that can be executed concurrently\n * - Action includes: `commands`, `timeout_ms`, `max_output_length`\n * - Always sandbox or validate commands before execution\n * - The `timeout_ms` from the model is only a hint—enforce your own limits\n * - If `max_output_length` exists in the action, always pass it back in the output\n * - Many CLI tools return non-zero exit codes for warnings; still capture stdout/stderr\n */\nexport function shell(options: ShellOptions) {\n // Wrapper that converts ShellResult to string for LangChain tool compatibility\n const executeWrapper = async (action: ShellAction): Promise<string> => {\n const result = await options.execute(action);\n // Return a JSON string representation for the tool result\n return JSON.stringify({\n output: result.output,\n max_output_length: result.maxOutputLength,\n });\n };\n\n const shellTool = tool(executeWrapper, {\n name: TOOL_NAME,\n description:\n \"Execute shell commands in a managed environment. Commands can be run concurrently.\",\n schema: ShellActionSchema,\n });\n\n shellTool.extras = {\n ...(shellTool.extras ?? {}),\n providerToolDefinition: {\n type: \"shell\",\n } satisfies ShellTool,\n };\n\n return shellTool as DynamicStructuredTool<\n typeof ShellActionSchema,\n ShellAction,\n unknown,\n string\n >;\n}\n"],"mappings":";;;;AAYA,MAAa,oBAAoBA,SAAE,OAAO;CACxC,UAAUA,SAAE,MAAMA,SAAE,QAAQ,CAAC,CAAC,SAAS,qCAAqC;CAC5E,YAAYA,SACT,QAAQ,CACR,UAAU,CACV,SAAS,oDAAoD;CAChE,mBAAmBA,SAChB,QAAQ,CACR,UAAU,CACV,SACC,oEACD;CACJ,CAAC;AAiFF,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmIlB,SAAgB,MAAM,SAAuB;CAE3C,MAAM,iBAAiB,OAAO,WAAyC;EACrE,MAAM,SAAS,MAAM,QAAQ,QAAQ,OAAO;AAE5C,SAAO,KAAK,UAAU;GACpB,QAAQ,OAAO;GACf,mBAAmB,OAAO;GAC3B,CAAC;;CAGJ,MAAM,4CAAiB,gBAAgB;EACrC,MAAM;EACN,aACE;EACF,QAAQ;EACT,CAAC;AAEF,WAAU,SAAS;EACjB,GAAI,UAAU,UAAU,EAAE;EAC1B,wBAAwB,EACtB,MAAM,SACP;EACF;AAED,QAAO"}
1
+ {"version":3,"file":"shell.cjs","names":["z"],"sources":["../../src/tools/shell.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { tool, type DynamicStructuredTool } from \"@langchain/core/tools\";\n\n/**\n * Re-export action type from OpenAI SDK for convenience.\n * The action contains command details like commands array, timeout, and max output length.\n */\nexport type ShellAction =\n OpenAIClient.Responses.ResponseFunctionShellToolCall.Action;\n\n// Zod schema for shell action\nexport const ShellActionSchema = z.object({\n commands: z.array(z.string()).describe(\"Array of shell commands to execute\"),\n timeout_ms: z\n .number()\n .optional()\n .describe(\"Optional timeout in milliseconds for the commands\"),\n max_output_length: z\n .number()\n .optional()\n .describe(\n \"Optional maximum number of characters to return from each command\"\n ),\n});\n\n/**\n * Result of a single shell command execution.\n * Contains stdout, stderr, and the outcome (exit code or timeout).\n */\nexport type ShellCommandOutput =\n OpenAIClient.Responses.ResponseFunctionShellCallOutputContent;\n\n/**\n * Outcome type for shell command execution - either exit with code or timeout.\n */\nexport type ShellCallOutcome = ShellCommandOutput[\"outcome\"];\n\n/**\n * Result of executing shell commands.\n * Contains an array of outputs (one per command) and the max_output_length parameter.\n */\nexport interface ShellResult {\n /**\n * Array of command outputs. Each entry corresponds to a command from the action.\n * The order should match the order of commands in the action.\n */\n output: ShellCommandOutput[];\n /**\n * The max_output_length from the action, which must be passed back to the API.\n * If not provided in the action, can be omitted.\n */\n maxOutputLength?: number | null;\n}\n\n/**\n * Options for the Shell tool.\n */\nexport interface ShellOptions {\n /**\n * Execute function that handles shell command execution.\n * This function receives the action input containing the commands and limits,\n * and should return a ShellResult with stdout, stderr, and outcome for each command.\n *\n * @example\n * ```typescript\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * }\n * ```\n */\n execute: (action: ShellAction) => ShellResult | Promise<ShellResult>;\n}\n\n/**\n * OpenAI Shell tool type for the Responses API.\n */\nexport type ShellTool = OpenAIClient.Responses.FunctionShellTool;\n\nconst TOOL_NAME = \"shell\";\n\n/**\n * Creates a Shell tool that allows models to run shell commands through your integration.\n *\n * The shell tool allows the model to interact with your local computer through a controlled\n * command-line interface. The model proposes shell commands; your integration executes them\n * and returns the outputs. This creates a simple plan-execute loop that lets models inspect\n * the system, run utilities, and gather data until they can finish the task.\n *\n * **Important**: The shell tool is available through the Responses API for use with `GPT-5.1`.\n * It is not available on other models, or via the Chat Completions API.\n *\n * **When to use**:\n * - **Automating filesystem or process diagnostics** – For example, \"find the largest PDF\n * under ~/Documents\" or \"show running gunicorn processes.\"\n * - **Extending the model's capabilities** – Using built-in UNIX utilities, python runtime\n * and other CLIs in your environment.\n * - **Running multi-step build and test flows** – Chaining commands like `pip install` and `pytest`.\n * - **Complex agentic coding workflows** – Using other tools like `apply_patch` to complete\n * workflows that involve complex file operations.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends shell commands (`shell_call` with `commands` array)\n * 2. Your code executes the commands (can be concurrent)\n * 3. You return stdout, stderr, and outcome for each command\n * 4. Repeat until the task is complete\n *\n * **Security Warning**: Running arbitrary shell commands can be dangerous.\n * Always sandbox execution or add strict allow/deny-lists before forwarding\n * a command to the system shell.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-shell | OpenAI Shell Documentation}\n * @see {@link https://github.com/openai/codex | Codex CLI} for reference implementation.\n *\n * @param options - Configuration for the Shell tool\n * @returns A Shell tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { exec } from \"child_process/promises\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.1\" });\n *\n * // With execute callback for automatic command handling\n * const shellTool = tools.shell({\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * },\n * });\n *\n * const llmWithShell = model.bindTools([shellTool]);\n * const response = await llmWithShell.invoke(\n * \"Find the largest PDF file in ~/Documents\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Full shell loop example\n * async function shellLoop(model, task) {\n * let response = await model.invoke(task, {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n *\n * while (true) {\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"shell_call\"\n * );\n *\n * if (!shellCall) break;\n *\n * // Execute commands (with proper sandboxing!)\n * const result = await executeCommands(shellCall.action);\n *\n * // Send output back to model\n * response = await model.invoke([\n * response,\n * {\n * type: \"shell_call_output\",\n * call_id: shellCall.call_id,\n * output: result.output,\n * max_output_length: result.maxOutputLength,\n * },\n * ], {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n * }\n *\n * return response;\n * }\n * ```\n *\n * @remarks\n * - Only available through the Responses API (not Chat Completions)\n * - Designed for use with `gpt-5.1` model\n * - Commands are provided as an array of strings that can be executed concurrently\n * - Action includes: `commands`, `timeout_ms`, `max_output_length`\n * - Always sandbox or validate commands before execution\n * - The `timeout_ms` from the model is only a hint—enforce your own limits\n * - If `max_output_length` exists in the action, always pass it back in the output\n * - Many CLI tools return non-zero exit codes for warnings; still capture stdout/stderr\n */\nexport function shell(options: ShellOptions) {\n // Wrapper that converts ShellResult to string for LangChain tool compatibility\n const executeWrapper = async (action: ShellAction): Promise<string> => {\n const result = await options.execute(action);\n // Return a JSON string representation for the tool result\n return JSON.stringify({\n output: result.output,\n max_output_length: result.maxOutputLength,\n });\n };\n\n const shellTool = tool(executeWrapper, {\n name: TOOL_NAME,\n description:\n \"Execute shell commands in a managed environment. Commands can be run concurrently.\",\n schema: ShellActionSchema,\n });\n\n shellTool.extras = {\n ...(shellTool.extras ?? {}),\n providerToolDefinition: {\n type: \"shell\",\n } satisfies ShellTool,\n };\n\n return shellTool as DynamicStructuredTool<\n typeof ShellActionSchema,\n ShellAction,\n unknown,\n string\n >;\n}\n"],"mappings":";;;AAYA,MAAa,oBAAoBA,OAAAA,EAAE,OAAO;CACxC,UAAUA,OAAAA,EAAE,MAAMA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS,qCAAqC;CAC5E,YAAYA,OAAAA,EACT,QAAQ,CACR,UAAU,CACV,SAAS,oDAAoD;CAChE,mBAAmBA,OAAAA,EAChB,QAAQ,CACR,UAAU,CACV,SACC,oEACD;CACJ,CAAC;AAiFF,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmIlB,SAAgB,MAAM,SAAuB;CAE3C,MAAM,iBAAiB,OAAO,WAAyC;EACrE,MAAM,SAAS,MAAM,QAAQ,QAAQ,OAAO;AAE5C,SAAO,KAAK,UAAU;GACpB,QAAQ,OAAO;GACf,mBAAmB,OAAO;GAC3B,CAAC;;CAGJ,MAAM,aAAA,GAAA,sBAAA,MAAiB,gBAAgB;EACrC,MAAM;EACN,aACE;EACF,QAAQ;EACT,CAAC;AAEF,WAAU,SAAS;EACjB,GAAI,UAAU,UAAU,EAAE;EAC1B,wBAAwB,EACtB,MAAM,SACP;EACF;AAED,QAAO"}
@@ -1,4 +1,4 @@
1
- import { OpenAI as OpenAI$1 } from "openai";
1
+ import { OpenAI } from "openai";
2
2
  import { DynamicStructuredTool } from "@langchain/core/tools";
3
3
  import { z } from "zod/v4";
4
4
 
@@ -7,12 +7,12 @@ import { z } from "zod/v4";
7
7
  * Re-export action type from OpenAI SDK for convenience.
8
8
  * The action contains command details like commands array, timeout, and max output length.
9
9
  */
10
- type ShellAction = OpenAI$1.Responses.ResponseFunctionShellToolCall.Action;
10
+ type ShellAction = OpenAI.Responses.ResponseFunctionShellToolCall.Action;
11
11
  /**
12
12
  * Result of a single shell command execution.
13
13
  * Contains stdout, stderr, and the outcome (exit code or timeout).
14
14
  */
15
- type ShellCommandOutput = OpenAI$1.Responses.ResponseFunctionShellCallOutputContent;
15
+ type ShellCommandOutput = OpenAI.Responses.ResponseFunctionShellCallOutputContent;
16
16
  /**
17
17
  * Outcome type for shell command execution - either exit with code or timeout.
18
18
  */
@@ -80,7 +80,7 @@ interface ShellOptions {
80
80
  /**
81
81
  * OpenAI Shell tool type for the Responses API.
82
82
  */
83
- type ShellTool = OpenAI$1.Responses.FunctionShellTool;
83
+ type ShellTool = OpenAI.Responses.FunctionShellTool;
84
84
  /**
85
85
  * Creates a Shell tool that allows models to run shell commands through your integration.
86
86
  *
@@ -214,7 +214,7 @@ declare function shell(options: ShellOptions): DynamicStructuredTool<z.ZodObject
214
214
  commands: z.ZodArray<z.ZodString>;
215
215
  timeout_ms: z.ZodOptional<z.ZodNumber>;
216
216
  max_output_length: z.ZodOptional<z.ZodNumber>;
217
- }, z.core.$strip>, OpenAI$1.Responses.ResponseFunctionShellToolCall.Action, unknown, string, unknown, string>;
217
+ }, z.core.$strip>, OpenAI.Responses.ResponseFunctionShellToolCall.Action, unknown, string, unknown, string>;
218
218
  //#endregion
219
219
  export { ShellAction, ShellCallOutcome, ShellCommandOutput, ShellOptions, ShellResult, ShellTool, shell };
220
220
  //# sourceMappingURL=shell.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.cts","names":[],"sources":["../../src/tools/shell.ts"],"mappings":";;;;;;;AAQA;;KAAY,WAAA,GACV,QAAA,CAAa,SAAA,CAAU,6BAAA,CAA8B,MAAA;;;AAqBvD;;KAAY,kBAAA,GACV,QAAA,CAAa,SAAA,CAAU,sCAAA;;;;KAKb,gBAAA,GAAmB,kBAAA;;;AAA/B;;UAMiB,WAAA;EANc;;AAM/B;;EAKE,MAAA,EAAQ,kBAAA;EAAkB;;;;EAK1B,eAAA;AAAA;AAMF;;;AAAA,UAAiB,YAAA;EAuCmB;;;;;;;;;;;;;AAMpC;;;;;;;;;AAqIA;;;;;;;;;;;;;;;;EA3IE,OAAA,GAAU,MAAA,EAAQ,WAAA,KAAgB,WAAA,GAAc,OAAA,CAAQ,WAAA;AAAA;;;;KAM9C,SAAA,GAAY,QAAA,CAAa,SAAA,CAAU,iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqI/B,KAAA,CAAM,OAAA,EAAS,YAAA,GAAY,qBAAA,CAAA,CAAA,CAAA,SAAA"}
1
+ {"version":3,"file":"shell.d.cts","names":[],"sources":["../../src/tools/shell.ts"],"mappings":";;;;;;;AAQA;;KAAY,WAAA,GACV,MAAA,CAAa,SAAA,CAAU,6BAAA,CAA8B,MAAA;;;AAqBvD;;KAAY,kBAAA,GACV,MAAA,CAAa,SAAA,CAAU,sCAAA;;;;KAKb,gBAAA,GAAmB,kBAAA;;;AAA/B;;UAMiB,WAAA;EANc;;AAM/B;;EAKE,MAAA,EAAQ,kBAAA;EAAkB;;;;EAK1B,eAAA;AAAA;AAMF;;;AAAA,UAAiB,YAAA;EAuCmB;;;;;;;;;;;;;AAMpC;;;;;;;;;AAqIA;;;;;;;;;;;;;;;;EA3IE,OAAA,GAAU,MAAA,EAAQ,WAAA,KAAgB,WAAA,GAAc,OAAA,CAAQ,WAAA;AAAA;;;;KAM9C,SAAA,GAAY,MAAA,CAAa,SAAA,CAAU,iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqI/B,KAAA,CAAM,OAAA,EAAS,YAAA,GAAY,qBAAA,CAAA,CAAA,CAAA,SAAA"}
@@ -1,4 +1,4 @@
1
- import { OpenAI as OpenAI$1 } from "openai";
1
+ import { OpenAI } from "openai";
2
2
  import { DynamicStructuredTool } from "@langchain/core/tools";
3
3
  import { z } from "zod/v4";
4
4
 
@@ -7,12 +7,12 @@ import { z } from "zod/v4";
7
7
  * Re-export action type from OpenAI SDK for convenience.
8
8
  * The action contains command details like commands array, timeout, and max output length.
9
9
  */
10
- type ShellAction = OpenAI$1.Responses.ResponseFunctionShellToolCall.Action;
10
+ type ShellAction = OpenAI.Responses.ResponseFunctionShellToolCall.Action;
11
11
  /**
12
12
  * Result of a single shell command execution.
13
13
  * Contains stdout, stderr, and the outcome (exit code or timeout).
14
14
  */
15
- type ShellCommandOutput = OpenAI$1.Responses.ResponseFunctionShellCallOutputContent;
15
+ type ShellCommandOutput = OpenAI.Responses.ResponseFunctionShellCallOutputContent;
16
16
  /**
17
17
  * Outcome type for shell command execution - either exit with code or timeout.
18
18
  */
@@ -80,7 +80,7 @@ interface ShellOptions {
80
80
  /**
81
81
  * OpenAI Shell tool type for the Responses API.
82
82
  */
83
- type ShellTool = OpenAI$1.Responses.FunctionShellTool;
83
+ type ShellTool = OpenAI.Responses.FunctionShellTool;
84
84
  /**
85
85
  * Creates a Shell tool that allows models to run shell commands through your integration.
86
86
  *
@@ -214,7 +214,7 @@ declare function shell(options: ShellOptions): DynamicStructuredTool<z.ZodObject
214
214
  commands: z.ZodArray<z.ZodString>;
215
215
  timeout_ms: z.ZodOptional<z.ZodNumber>;
216
216
  max_output_length: z.ZodOptional<z.ZodNumber>;
217
- }, z.core.$strip>, OpenAI$1.Responses.ResponseFunctionShellToolCall.Action, unknown, string, unknown, string>;
217
+ }, z.core.$strip>, OpenAI.Responses.ResponseFunctionShellToolCall.Action, unknown, string, unknown, string>;
218
218
  //#endregion
219
219
  export { ShellAction, ShellCallOutcome, ShellCommandOutput, ShellOptions, ShellResult, ShellTool, shell };
220
220
  //# sourceMappingURL=shell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.ts","names":[],"sources":["../../src/tools/shell.ts"],"mappings":";;;;;;;AAQA;;KAAY,WAAA,GACV,QAAA,CAAa,SAAA,CAAU,6BAAA,CAA8B,MAAA;;;AAqBvD;;KAAY,kBAAA,GACV,QAAA,CAAa,SAAA,CAAU,sCAAA;;;;KAKb,gBAAA,GAAmB,kBAAA;;;AAA/B;;UAMiB,WAAA;EANc;;AAM/B;;EAKE,MAAA,EAAQ,kBAAA;EAAkB;;;;EAK1B,eAAA;AAAA;AAMF;;;AAAA,UAAiB,YAAA;EAuCmB;;;;;;;;;;;;;AAMpC;;;;;;;;;AAqIA;;;;;;;;;;;;;;;;EA3IE,OAAA,GAAU,MAAA,EAAQ,WAAA,KAAgB,WAAA,GAAc,OAAA,CAAQ,WAAA;AAAA;;;;KAM9C,SAAA,GAAY,QAAA,CAAa,SAAA,CAAU,iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqI/B,KAAA,CAAM,OAAA,EAAS,YAAA,GAAY,qBAAA,CAAA,CAAA,CAAA,SAAA"}
1
+ {"version":3,"file":"shell.d.ts","names":[],"sources":["../../src/tools/shell.ts"],"mappings":";;;;;;;AAQA;;KAAY,WAAA,GACV,MAAA,CAAa,SAAA,CAAU,6BAAA,CAA8B,MAAA;;;AAqBvD;;KAAY,kBAAA,GACV,MAAA,CAAa,SAAA,CAAU,sCAAA;;;;KAKb,gBAAA,GAAmB,kBAAA;;;AAA/B;;UAMiB,WAAA;EANc;;AAM/B;;EAKE,MAAA,EAAQ,kBAAA;EAAkB;;;;EAK1B,eAAA;AAAA;AAMF;;;AAAA,UAAiB,YAAA;EAuCmB;;;;;;;;;;;;;AAMpC;;;;;;;;;AAqIA;;;;;;;;;;;;;;;;EA3IE,OAAA,GAAU,MAAA,EAAQ,WAAA,KAAgB,WAAA,GAAc,OAAA,CAAQ,WAAA;AAAA;;;;KAM9C,SAAA,GAAY,MAAA,CAAa,SAAA,CAAU,iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqI/B,KAAA,CAAM,OAAA,EAAS,YAAA,GAAY,qBAAA,CAAA,CAAA,CAAA,SAAA"}
@@ -1,6 +1,5 @@
1
1
  import { tool } from "@langchain/core/tools";
2
2
  import { z } from "zod/v4";
3
-
4
3
  //#region src/tools/shell.ts
5
4
  const ShellActionSchema = z.object({
6
5
  commands: z.array(z.string()).describe("Array of shell commands to execute"),
@@ -156,7 +155,7 @@ function shell(options) {
156
155
  };
157
156
  return shellTool;
158
157
  }
159
-
160
158
  //#endregion
161
159
  export { shell };
160
+
162
161
  //# sourceMappingURL=shell.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.js","names":[],"sources":["../../src/tools/shell.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { tool, type DynamicStructuredTool } from \"@langchain/core/tools\";\n\n/**\n * Re-export action type from OpenAI SDK for convenience.\n * The action contains command details like commands array, timeout, and max output length.\n */\nexport type ShellAction =\n OpenAIClient.Responses.ResponseFunctionShellToolCall.Action;\n\n// Zod schema for shell action\nexport const ShellActionSchema = z.object({\n commands: z.array(z.string()).describe(\"Array of shell commands to execute\"),\n timeout_ms: z\n .number()\n .optional()\n .describe(\"Optional timeout in milliseconds for the commands\"),\n max_output_length: z\n .number()\n .optional()\n .describe(\n \"Optional maximum number of characters to return from each command\"\n ),\n});\n\n/**\n * Result of a single shell command execution.\n * Contains stdout, stderr, and the outcome (exit code or timeout).\n */\nexport type ShellCommandOutput =\n OpenAIClient.Responses.ResponseFunctionShellCallOutputContent;\n\n/**\n * Outcome type for shell command execution - either exit with code or timeout.\n */\nexport type ShellCallOutcome = ShellCommandOutput[\"outcome\"];\n\n/**\n * Result of executing shell commands.\n * Contains an array of outputs (one per command) and the max_output_length parameter.\n */\nexport interface ShellResult {\n /**\n * Array of command outputs. Each entry corresponds to a command from the action.\n * The order should match the order of commands in the action.\n */\n output: ShellCommandOutput[];\n /**\n * The max_output_length from the action, which must be passed back to the API.\n * If not provided in the action, can be omitted.\n */\n maxOutputLength?: number | null;\n}\n\n/**\n * Options for the Shell tool.\n */\nexport interface ShellOptions {\n /**\n * Execute function that handles shell command execution.\n * This function receives the action input containing the commands and limits,\n * and should return a ShellResult with stdout, stderr, and outcome for each command.\n *\n * @example\n * ```typescript\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * }\n * ```\n */\n execute: (action: ShellAction) => ShellResult | Promise<ShellResult>;\n}\n\n/**\n * OpenAI Shell tool type for the Responses API.\n */\nexport type ShellTool = OpenAIClient.Responses.FunctionShellTool;\n\nconst TOOL_NAME = \"shell\";\n\n/**\n * Creates a Shell tool that allows models to run shell commands through your integration.\n *\n * The shell tool allows the model to interact with your local computer through a controlled\n * command-line interface. The model proposes shell commands; your integration executes them\n * and returns the outputs. This creates a simple plan-execute loop that lets models inspect\n * the system, run utilities, and gather data until they can finish the task.\n *\n * **Important**: The shell tool is available through the Responses API for use with `GPT-5.1`.\n * It is not available on other models, or via the Chat Completions API.\n *\n * **When to use**:\n * - **Automating filesystem or process diagnostics** – For example, \"find the largest PDF\n * under ~/Documents\" or \"show running gunicorn processes.\"\n * - **Extending the model's capabilities** – Using built-in UNIX utilities, python runtime\n * and other CLIs in your environment.\n * - **Running multi-step build and test flows** – Chaining commands like `pip install` and `pytest`.\n * - **Complex agentic coding workflows** – Using other tools like `apply_patch` to complete\n * workflows that involve complex file operations.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends shell commands (`shell_call` with `commands` array)\n * 2. Your code executes the commands (can be concurrent)\n * 3. You return stdout, stderr, and outcome for each command\n * 4. Repeat until the task is complete\n *\n * **Security Warning**: Running arbitrary shell commands can be dangerous.\n * Always sandbox execution or add strict allow/deny-lists before forwarding\n * a command to the system shell.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-shell | OpenAI Shell Documentation}\n * @see {@link https://github.com/openai/codex | Codex CLI} for reference implementation.\n *\n * @param options - Configuration for the Shell tool\n * @returns A Shell tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { exec } from \"child_process/promises\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.1\" });\n *\n * // With execute callback for automatic command handling\n * const shellTool = tools.shell({\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * },\n * });\n *\n * const llmWithShell = model.bindTools([shellTool]);\n * const response = await llmWithShell.invoke(\n * \"Find the largest PDF file in ~/Documents\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Full shell loop example\n * async function shellLoop(model, task) {\n * let response = await model.invoke(task, {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n *\n * while (true) {\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"shell_call\"\n * );\n *\n * if (!shellCall) break;\n *\n * // Execute commands (with proper sandboxing!)\n * const result = await executeCommands(shellCall.action);\n *\n * // Send output back to model\n * response = await model.invoke([\n * response,\n * {\n * type: \"shell_call_output\",\n * call_id: shellCall.call_id,\n * output: result.output,\n * max_output_length: result.maxOutputLength,\n * },\n * ], {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n * }\n *\n * return response;\n * }\n * ```\n *\n * @remarks\n * - Only available through the Responses API (not Chat Completions)\n * - Designed for use with `gpt-5.1` model\n * - Commands are provided as an array of strings that can be executed concurrently\n * - Action includes: `commands`, `timeout_ms`, `max_output_length`\n * - Always sandbox or validate commands before execution\n * - The `timeout_ms` from the model is only a hint—enforce your own limits\n * - If `max_output_length` exists in the action, always pass it back in the output\n * - Many CLI tools return non-zero exit codes for warnings; still capture stdout/stderr\n */\nexport function shell(options: ShellOptions) {\n // Wrapper that converts ShellResult to string for LangChain tool compatibility\n const executeWrapper = async (action: ShellAction): Promise<string> => {\n const result = await options.execute(action);\n // Return a JSON string representation for the tool result\n return JSON.stringify({\n output: result.output,\n max_output_length: result.maxOutputLength,\n });\n };\n\n const shellTool = tool(executeWrapper, {\n name: TOOL_NAME,\n description:\n \"Execute shell commands in a managed environment. Commands can be run concurrently.\",\n schema: ShellActionSchema,\n });\n\n shellTool.extras = {\n ...(shellTool.extras ?? {}),\n providerToolDefinition: {\n type: \"shell\",\n } satisfies ShellTool,\n };\n\n return shellTool as DynamicStructuredTool<\n typeof ShellActionSchema,\n ShellAction,\n unknown,\n string\n >;\n}\n"],"mappings":";;;;AAYA,MAAa,oBAAoB,EAAE,OAAO;CACxC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS,qCAAqC;CAC5E,YAAY,EACT,QAAQ,CACR,UAAU,CACV,SAAS,oDAAoD;CAChE,mBAAmB,EAChB,QAAQ,CACR,UAAU,CACV,SACC,oEACD;CACJ,CAAC;AAiFF,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmIlB,SAAgB,MAAM,SAAuB;CAE3C,MAAM,iBAAiB,OAAO,WAAyC;EACrE,MAAM,SAAS,MAAM,QAAQ,QAAQ,OAAO;AAE5C,SAAO,KAAK,UAAU;GACpB,QAAQ,OAAO;GACf,mBAAmB,OAAO;GAC3B,CAAC;;CAGJ,MAAM,YAAY,KAAK,gBAAgB;EACrC,MAAM;EACN,aACE;EACF,QAAQ;EACT,CAAC;AAEF,WAAU,SAAS;EACjB,GAAI,UAAU,UAAU,EAAE;EAC1B,wBAAwB,EACtB,MAAM,SACP;EACF;AAED,QAAO"}
1
+ {"version":3,"file":"shell.js","names":[],"sources":["../../src/tools/shell.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { tool, type DynamicStructuredTool } from \"@langchain/core/tools\";\n\n/**\n * Re-export action type from OpenAI SDK for convenience.\n * The action contains command details like commands array, timeout, and max output length.\n */\nexport type ShellAction =\n OpenAIClient.Responses.ResponseFunctionShellToolCall.Action;\n\n// Zod schema for shell action\nexport const ShellActionSchema = z.object({\n commands: z.array(z.string()).describe(\"Array of shell commands to execute\"),\n timeout_ms: z\n .number()\n .optional()\n .describe(\"Optional timeout in milliseconds for the commands\"),\n max_output_length: z\n .number()\n .optional()\n .describe(\n \"Optional maximum number of characters to return from each command\"\n ),\n});\n\n/**\n * Result of a single shell command execution.\n * Contains stdout, stderr, and the outcome (exit code or timeout).\n */\nexport type ShellCommandOutput =\n OpenAIClient.Responses.ResponseFunctionShellCallOutputContent;\n\n/**\n * Outcome type for shell command execution - either exit with code or timeout.\n */\nexport type ShellCallOutcome = ShellCommandOutput[\"outcome\"];\n\n/**\n * Result of executing shell commands.\n * Contains an array of outputs (one per command) and the max_output_length parameter.\n */\nexport interface ShellResult {\n /**\n * Array of command outputs. Each entry corresponds to a command from the action.\n * The order should match the order of commands in the action.\n */\n output: ShellCommandOutput[];\n /**\n * The max_output_length from the action, which must be passed back to the API.\n * If not provided in the action, can be omitted.\n */\n maxOutputLength?: number | null;\n}\n\n/**\n * Options for the Shell tool.\n */\nexport interface ShellOptions {\n /**\n * Execute function that handles shell command execution.\n * This function receives the action input containing the commands and limits,\n * and should return a ShellResult with stdout, stderr, and outcome for each command.\n *\n * @example\n * ```typescript\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * }\n * ```\n */\n execute: (action: ShellAction) => ShellResult | Promise<ShellResult>;\n}\n\n/**\n * OpenAI Shell tool type for the Responses API.\n */\nexport type ShellTool = OpenAIClient.Responses.FunctionShellTool;\n\nconst TOOL_NAME = \"shell\";\n\n/**\n * Creates a Shell tool that allows models to run shell commands through your integration.\n *\n * The shell tool allows the model to interact with your local computer through a controlled\n * command-line interface. The model proposes shell commands; your integration executes them\n * and returns the outputs. This creates a simple plan-execute loop that lets models inspect\n * the system, run utilities, and gather data until they can finish the task.\n *\n * **Important**: The shell tool is available through the Responses API for use with `GPT-5.1`.\n * It is not available on other models, or via the Chat Completions API.\n *\n * **When to use**:\n * - **Automating filesystem or process diagnostics** – For example, \"find the largest PDF\n * under ~/Documents\" or \"show running gunicorn processes.\"\n * - **Extending the model's capabilities** – Using built-in UNIX utilities, python runtime\n * and other CLIs in your environment.\n * - **Running multi-step build and test flows** – Chaining commands like `pip install` and `pytest`.\n * - **Complex agentic coding workflows** – Using other tools like `apply_patch` to complete\n * workflows that involve complex file operations.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends shell commands (`shell_call` with `commands` array)\n * 2. Your code executes the commands (can be concurrent)\n * 3. You return stdout, stderr, and outcome for each command\n * 4. Repeat until the task is complete\n *\n * **Security Warning**: Running arbitrary shell commands can be dangerous.\n * Always sandbox execution or add strict allow/deny-lists before forwarding\n * a command to the system shell.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-shell | OpenAI Shell Documentation}\n * @see {@link https://github.com/openai/codex | Codex CLI} for reference implementation.\n *\n * @param options - Configuration for the Shell tool\n * @returns A Shell tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { exec } from \"child_process/promises\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.1\" });\n *\n * // With execute callback for automatic command handling\n * const shellTool = tools.shell({\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * },\n * });\n *\n * const llmWithShell = model.bindTools([shellTool]);\n * const response = await llmWithShell.invoke(\n * \"Find the largest PDF file in ~/Documents\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Full shell loop example\n * async function shellLoop(model, task) {\n * let response = await model.invoke(task, {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n *\n * while (true) {\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"shell_call\"\n * );\n *\n * if (!shellCall) break;\n *\n * // Execute commands (with proper sandboxing!)\n * const result = await executeCommands(shellCall.action);\n *\n * // Send output back to model\n * response = await model.invoke([\n * response,\n * {\n * type: \"shell_call_output\",\n * call_id: shellCall.call_id,\n * output: result.output,\n * max_output_length: result.maxOutputLength,\n * },\n * ], {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n * }\n *\n * return response;\n * }\n * ```\n *\n * @remarks\n * - Only available through the Responses API (not Chat Completions)\n * - Designed for use with `gpt-5.1` model\n * - Commands are provided as an array of strings that can be executed concurrently\n * - Action includes: `commands`, `timeout_ms`, `max_output_length`\n * - Always sandbox or validate commands before execution\n * - The `timeout_ms` from the model is only a hint—enforce your own limits\n * - If `max_output_length` exists in the action, always pass it back in the output\n * - Many CLI tools return non-zero exit codes for warnings; still capture stdout/stderr\n */\nexport function shell(options: ShellOptions) {\n // Wrapper that converts ShellResult to string for LangChain tool compatibility\n const executeWrapper = async (action: ShellAction): Promise<string> => {\n const result = await options.execute(action);\n // Return a JSON string representation for the tool result\n return JSON.stringify({\n output: result.output,\n max_output_length: result.maxOutputLength,\n });\n };\n\n const shellTool = tool(executeWrapper, {\n name: TOOL_NAME,\n description:\n \"Execute shell commands in a managed environment. Commands can be run concurrently.\",\n schema: ShellActionSchema,\n });\n\n shellTool.extras = {\n ...(shellTool.extras ?? {}),\n providerToolDefinition: {\n type: \"shell\",\n } satisfies ShellTool,\n };\n\n return shellTool as DynamicStructuredTool<\n typeof ShellActionSchema,\n ShellAction,\n unknown,\n string\n >;\n}\n"],"mappings":";;;AAYA,MAAa,oBAAoB,EAAE,OAAO;CACxC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS,qCAAqC;CAC5E,YAAY,EACT,QAAQ,CACR,UAAU,CACV,SAAS,oDAAoD;CAChE,mBAAmB,EAChB,QAAQ,CACR,UAAU,CACV,SACC,oEACD;CACJ,CAAC;AAiFF,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmIlB,SAAgB,MAAM,SAAuB;CAE3C,MAAM,iBAAiB,OAAO,WAAyC;EACrE,MAAM,SAAS,MAAM,QAAQ,QAAQ,OAAO;AAE5C,SAAO,KAAK,UAAU;GACpB,QAAQ,OAAO;GACf,mBAAmB,OAAO;GAC3B,CAAC;;CAGJ,MAAM,YAAY,KAAK,gBAAgB;EACrC,MAAM;EACN,aACE;EACF,QAAQ;EACT,CAAC;AAEF,WAAU,SAAS;EACjB,GAAI,UAAU,UAAU,EAAE;EAC1B,wBAAwB,EACtB,MAAM,SACP;EACF;AAED,QAAO"}
@@ -0,0 +1,67 @@
1
+ //#region src/tools/toolSearch.ts
2
+ /**
3
+ * Creates a tool search tool that enables OpenAI models to dynamically discover
4
+ * and load tools on-demand from a large pool, rather than requiring all tool
5
+ * definitions to be sent in every request.
6
+ *
7
+ * Tool search works with tools that have `defer_loading: true` set (either
8
+ * directly in the tool definition or via `extras: { defer_loading: true }` on
9
+ * LangChain tools). When the model needs a deferred tool, it issues a tool
10
+ * search call, discovers matching tools, and then makes the actual function call.
11
+ *
12
+ * @see {@link https://platform.openai.com/docs/guides/tools-tool-search | OpenAI Tool Search Documentation}
13
+ * @param options - Configuration options for the tool search tool
14
+ * @returns A tool search tool definition to be passed to the OpenAI Responses API
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { ChatOpenAI, tools } from "@langchain/openai";
19
+ * import { tool } from "@langchain/core/tools";
20
+ * import { z } from "zod";
21
+ *
22
+ * const model = new ChatOpenAI({ model: "gpt-5.3" });
23
+ *
24
+ * const getWeather = tool(
25
+ * async (input) => `Weather in ${input.location}: sunny, 72°F`,
26
+ * {
27
+ * name: "get_weather",
28
+ * description: "Get the current weather for a location",
29
+ * schema: z.object({ location: z.string() }),
30
+ * extras: { defer_loading: true },
31
+ * }
32
+ * );
33
+ *
34
+ * // Server-executed tool search (default)
35
+ * const response = await model.invoke("What is the weather in SF?", {
36
+ * tools: [tools.toolSearch(), getWeather],
37
+ * });
38
+ *
39
+ * // Client-executed tool search
40
+ * const clientResponse = await model.invoke("What is the weather in SF?", {
41
+ * tools: [
42
+ * tools.toolSearch({
43
+ * execution: "client",
44
+ * description: "Search for available tools",
45
+ * parameters: {
46
+ * type: "object",
47
+ * properties: { goal: { type: "string" } },
48
+ * required: ["goal"],
49
+ * },
50
+ * }),
51
+ * getWeather,
52
+ * ],
53
+ * });
54
+ * ```
55
+ */
56
+ function toolSearch(options) {
57
+ return {
58
+ type: "tool_search",
59
+ ...options?.execution ? { execution: options.execution } : {},
60
+ ...options?.description ? { description: options.description } : {},
61
+ ...options?.parameters !== void 0 ? { parameters: options.parameters } : {}
62
+ };
63
+ }
64
+ //#endregion
65
+ exports.toolSearch = toolSearch;
66
+
67
+ //# sourceMappingURL=toolSearch.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolSearch.cjs","names":[],"sources":["../../src/tools/toolSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\nexport interface ToolSearchOptions {\n /**\n * Whether tool search is executed by the server or by the client.\n * - `\"server\"` (default): OpenAI's servers handle the search internally.\n * - `\"client\"`: The client provides results via agent middleware.\n */\n execution?: \"server\" | \"client\";\n /**\n * Description shown to the model for a client-executed tool search tool.\n */\n description?: string;\n /**\n * Parameter schema for a client-executed tool search tool.\n */\n parameters?: unknown;\n}\n\nexport type ToolSearchTool = OpenAIClient.Responses.ToolSearchTool;\n\n/**\n * Creates a tool search tool that enables OpenAI models to dynamically discover\n * and load tools on-demand from a large pool, rather than requiring all tool\n * definitions to be sent in every request.\n *\n * Tool search works with tools that have `defer_loading: true` set (either\n * directly in the tool definition or via `extras: { defer_loading: true }` on\n * LangChain tools). When the model needs a deferred tool, it issues a tool\n * search call, discovers matching tools, and then makes the actual function call.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-tool-search | OpenAI Tool Search Documentation}\n * @param options - Configuration options for the tool search tool\n * @returns A tool search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.3\" });\n *\n * const getWeather = tool(\n * async (input) => `Weather in ${input.location}: sunny, 72°F`,\n * {\n * name: \"get_weather\",\n * description: \"Get the current weather for a location\",\n * schema: z.object({ location: z.string() }),\n * extras: { defer_loading: true },\n * }\n * );\n *\n * // Server-executed tool search (default)\n * const response = await model.invoke(\"What is the weather in SF?\", {\n * tools: [tools.toolSearch(), getWeather],\n * });\n *\n * // Client-executed tool search\n * const clientResponse = await model.invoke(\"What is the weather in SF?\", {\n * tools: [\n * tools.toolSearch({\n * execution: \"client\",\n * description: \"Search for available tools\",\n * parameters: {\n * type: \"object\",\n * properties: { goal: { type: \"string\" } },\n * required: [\"goal\"],\n * },\n * }),\n * getWeather,\n * ],\n * });\n * ```\n */\nexport function toolSearch(options?: ToolSearchOptions): ServerTool {\n return {\n type: \"tool_search\",\n ...(options?.execution ? { execution: options.execution } : {}),\n ...(options?.description ? { description: options.description } : {}),\n ...(options?.parameters !== undefined\n ? { parameters: options.parameters }\n : {}),\n } satisfies ToolSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,SAAgB,WAAW,SAAyC;AAClE,QAAO;EACL,MAAM;EACN,GAAI,SAAS,YAAY,EAAE,WAAW,QAAQ,WAAW,GAAG,EAAE;EAC9D,GAAI,SAAS,cAAc,EAAE,aAAa,QAAQ,aAAa,GAAG,EAAE;EACpE,GAAI,SAAS,eAAe,KAAA,IACxB,EAAE,YAAY,QAAQ,YAAY,GAClC,EAAE;EACP"}
@@ -0,0 +1,79 @@
1
+ import { OpenAI } from "openai";
2
+ import { ServerTool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/toolSearch.d.ts
5
+ interface ToolSearchOptions {
6
+ /**
7
+ * Whether tool search is executed by the server or by the client.
8
+ * - `"server"` (default): OpenAI's servers handle the search internally.
9
+ * - `"client"`: The client provides results via agent middleware.
10
+ */
11
+ execution?: "server" | "client";
12
+ /**
13
+ * Description shown to the model for a client-executed tool search tool.
14
+ */
15
+ description?: string;
16
+ /**
17
+ * Parameter schema for a client-executed tool search tool.
18
+ */
19
+ parameters?: unknown;
20
+ }
21
+ type ToolSearchTool = OpenAI.Responses.ToolSearchTool;
22
+ /**
23
+ * Creates a tool search tool that enables OpenAI models to dynamically discover
24
+ * and load tools on-demand from a large pool, rather than requiring all tool
25
+ * definitions to be sent in every request.
26
+ *
27
+ * Tool search works with tools that have `defer_loading: true` set (either
28
+ * directly in the tool definition or via `extras: { defer_loading: true }` on
29
+ * LangChain tools). When the model needs a deferred tool, it issues a tool
30
+ * search call, discovers matching tools, and then makes the actual function call.
31
+ *
32
+ * @see {@link https://platform.openai.com/docs/guides/tools-tool-search | OpenAI Tool Search Documentation}
33
+ * @param options - Configuration options for the tool search tool
34
+ * @returns A tool search tool definition to be passed to the OpenAI Responses API
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * import { ChatOpenAI, tools } from "@langchain/openai";
39
+ * import { tool } from "@langchain/core/tools";
40
+ * import { z } from "zod";
41
+ *
42
+ * const model = new ChatOpenAI({ model: "gpt-5.3" });
43
+ *
44
+ * const getWeather = tool(
45
+ * async (input) => `Weather in ${input.location}: sunny, 72°F`,
46
+ * {
47
+ * name: "get_weather",
48
+ * description: "Get the current weather for a location",
49
+ * schema: z.object({ location: z.string() }),
50
+ * extras: { defer_loading: true },
51
+ * }
52
+ * );
53
+ *
54
+ * // Server-executed tool search (default)
55
+ * const response = await model.invoke("What is the weather in SF?", {
56
+ * tools: [tools.toolSearch(), getWeather],
57
+ * });
58
+ *
59
+ * // Client-executed tool search
60
+ * const clientResponse = await model.invoke("What is the weather in SF?", {
61
+ * tools: [
62
+ * tools.toolSearch({
63
+ * execution: "client",
64
+ * description: "Search for available tools",
65
+ * parameters: {
66
+ * type: "object",
67
+ * properties: { goal: { type: "string" } },
68
+ * required: ["goal"],
69
+ * },
70
+ * }),
71
+ * getWeather,
72
+ * ],
73
+ * });
74
+ * ```
75
+ */
76
+ declare function toolSearch(options?: ToolSearchOptions): ServerTool;
77
+ //#endregion
78
+ export { ToolSearchOptions, ToolSearchTool, toolSearch };
79
+ //# sourceMappingURL=toolSearch.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolSearch.d.cts","names":[],"sources":["../../src/tools/toolSearch.ts"],"mappings":";;;;UAGiB,iBAAA;;AAAjB;;;;EAME,SAAA;EAIA;;;EAAA,WAAA;EAOU;;;EAHV,UAAA;AAAA;AAAA,KAGU,cAAA,GAAiB,MAAA,CAAa,SAAA,CAAU,cAAA;;;;AAwDpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,UAAA,CAAW,OAAA,GAAU,iBAAA,GAAoB,UAAA"}
@@ -0,0 +1,79 @@
1
+ import { OpenAI } from "openai";
2
+ import { ServerTool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/toolSearch.d.ts
5
+ interface ToolSearchOptions {
6
+ /**
7
+ * Whether tool search is executed by the server or by the client.
8
+ * - `"server"` (default): OpenAI's servers handle the search internally.
9
+ * - `"client"`: The client provides results via agent middleware.
10
+ */
11
+ execution?: "server" | "client";
12
+ /**
13
+ * Description shown to the model for a client-executed tool search tool.
14
+ */
15
+ description?: string;
16
+ /**
17
+ * Parameter schema for a client-executed tool search tool.
18
+ */
19
+ parameters?: unknown;
20
+ }
21
+ type ToolSearchTool = OpenAI.Responses.ToolSearchTool;
22
+ /**
23
+ * Creates a tool search tool that enables OpenAI models to dynamically discover
24
+ * and load tools on-demand from a large pool, rather than requiring all tool
25
+ * definitions to be sent in every request.
26
+ *
27
+ * Tool search works with tools that have `defer_loading: true` set (either
28
+ * directly in the tool definition or via `extras: { defer_loading: true }` on
29
+ * LangChain tools). When the model needs a deferred tool, it issues a tool
30
+ * search call, discovers matching tools, and then makes the actual function call.
31
+ *
32
+ * @see {@link https://platform.openai.com/docs/guides/tools-tool-search | OpenAI Tool Search Documentation}
33
+ * @param options - Configuration options for the tool search tool
34
+ * @returns A tool search tool definition to be passed to the OpenAI Responses API
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * import { ChatOpenAI, tools } from "@langchain/openai";
39
+ * import { tool } from "@langchain/core/tools";
40
+ * import { z } from "zod";
41
+ *
42
+ * const model = new ChatOpenAI({ model: "gpt-5.3" });
43
+ *
44
+ * const getWeather = tool(
45
+ * async (input) => `Weather in ${input.location}: sunny, 72°F`,
46
+ * {
47
+ * name: "get_weather",
48
+ * description: "Get the current weather for a location",
49
+ * schema: z.object({ location: z.string() }),
50
+ * extras: { defer_loading: true },
51
+ * }
52
+ * );
53
+ *
54
+ * // Server-executed tool search (default)
55
+ * const response = await model.invoke("What is the weather in SF?", {
56
+ * tools: [tools.toolSearch(), getWeather],
57
+ * });
58
+ *
59
+ * // Client-executed tool search
60
+ * const clientResponse = await model.invoke("What is the weather in SF?", {
61
+ * tools: [
62
+ * tools.toolSearch({
63
+ * execution: "client",
64
+ * description: "Search for available tools",
65
+ * parameters: {
66
+ * type: "object",
67
+ * properties: { goal: { type: "string" } },
68
+ * required: ["goal"],
69
+ * },
70
+ * }),
71
+ * getWeather,
72
+ * ],
73
+ * });
74
+ * ```
75
+ */
76
+ declare function toolSearch(options?: ToolSearchOptions): ServerTool;
77
+ //#endregion
78
+ export { ToolSearchOptions, ToolSearchTool, toolSearch };
79
+ //# sourceMappingURL=toolSearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolSearch.d.ts","names":[],"sources":["../../src/tools/toolSearch.ts"],"mappings":";;;;UAGiB,iBAAA;;AAAjB;;;;EAME,SAAA;EAIA;;;EAAA,WAAA;EAOU;;;EAHV,UAAA;AAAA;AAAA,KAGU,cAAA,GAAiB,MAAA,CAAa,SAAA,CAAU,cAAA;;;;AAwDpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,UAAA,CAAW,OAAA,GAAU,iBAAA,GAAoB,UAAA"}
@@ -0,0 +1,67 @@
1
+ //#region src/tools/toolSearch.ts
2
+ /**
3
+ * Creates a tool search tool that enables OpenAI models to dynamically discover
4
+ * and load tools on-demand from a large pool, rather than requiring all tool
5
+ * definitions to be sent in every request.
6
+ *
7
+ * Tool search works with tools that have `defer_loading: true` set (either
8
+ * directly in the tool definition or via `extras: { defer_loading: true }` on
9
+ * LangChain tools). When the model needs a deferred tool, it issues a tool
10
+ * search call, discovers matching tools, and then makes the actual function call.
11
+ *
12
+ * @see {@link https://platform.openai.com/docs/guides/tools-tool-search | OpenAI Tool Search Documentation}
13
+ * @param options - Configuration options for the tool search tool
14
+ * @returns A tool search tool definition to be passed to the OpenAI Responses API
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { ChatOpenAI, tools } from "@langchain/openai";
19
+ * import { tool } from "@langchain/core/tools";
20
+ * import { z } from "zod";
21
+ *
22
+ * const model = new ChatOpenAI({ model: "gpt-5.3" });
23
+ *
24
+ * const getWeather = tool(
25
+ * async (input) => `Weather in ${input.location}: sunny, 72°F`,
26
+ * {
27
+ * name: "get_weather",
28
+ * description: "Get the current weather for a location",
29
+ * schema: z.object({ location: z.string() }),
30
+ * extras: { defer_loading: true },
31
+ * }
32
+ * );
33
+ *
34
+ * // Server-executed tool search (default)
35
+ * const response = await model.invoke("What is the weather in SF?", {
36
+ * tools: [tools.toolSearch(), getWeather],
37
+ * });
38
+ *
39
+ * // Client-executed tool search
40
+ * const clientResponse = await model.invoke("What is the weather in SF?", {
41
+ * tools: [
42
+ * tools.toolSearch({
43
+ * execution: "client",
44
+ * description: "Search for available tools",
45
+ * parameters: {
46
+ * type: "object",
47
+ * properties: { goal: { type: "string" } },
48
+ * required: ["goal"],
49
+ * },
50
+ * }),
51
+ * getWeather,
52
+ * ],
53
+ * });
54
+ * ```
55
+ */
56
+ function toolSearch(options) {
57
+ return {
58
+ type: "tool_search",
59
+ ...options?.execution ? { execution: options.execution } : {},
60
+ ...options?.description ? { description: options.description } : {},
61
+ ...options?.parameters !== void 0 ? { parameters: options.parameters } : {}
62
+ };
63
+ }
64
+ //#endregion
65
+ export { toolSearch };
66
+
67
+ //# sourceMappingURL=toolSearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolSearch.js","names":[],"sources":["../../src/tools/toolSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\nexport interface ToolSearchOptions {\n /**\n * Whether tool search is executed by the server or by the client.\n * - `\"server\"` (default): OpenAI's servers handle the search internally.\n * - `\"client\"`: The client provides results via agent middleware.\n */\n execution?: \"server\" | \"client\";\n /**\n * Description shown to the model for a client-executed tool search tool.\n */\n description?: string;\n /**\n * Parameter schema for a client-executed tool search tool.\n */\n parameters?: unknown;\n}\n\nexport type ToolSearchTool = OpenAIClient.Responses.ToolSearchTool;\n\n/**\n * Creates a tool search tool that enables OpenAI models to dynamically discover\n * and load tools on-demand from a large pool, rather than requiring all tool\n * definitions to be sent in every request.\n *\n * Tool search works with tools that have `defer_loading: true` set (either\n * directly in the tool definition or via `extras: { defer_loading: true }` on\n * LangChain tools). When the model needs a deferred tool, it issues a tool\n * search call, discovers matching tools, and then makes the actual function call.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-tool-search | OpenAI Tool Search Documentation}\n * @param options - Configuration options for the tool search tool\n * @returns A tool search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.3\" });\n *\n * const getWeather = tool(\n * async (input) => `Weather in ${input.location}: sunny, 72°F`,\n * {\n * name: \"get_weather\",\n * description: \"Get the current weather for a location\",\n * schema: z.object({ location: z.string() }),\n * extras: { defer_loading: true },\n * }\n * );\n *\n * // Server-executed tool search (default)\n * const response = await model.invoke(\"What is the weather in SF?\", {\n * tools: [tools.toolSearch(), getWeather],\n * });\n *\n * // Client-executed tool search\n * const clientResponse = await model.invoke(\"What is the weather in SF?\", {\n * tools: [\n * tools.toolSearch({\n * execution: \"client\",\n * description: \"Search for available tools\",\n * parameters: {\n * type: \"object\",\n * properties: { goal: { type: \"string\" } },\n * required: [\"goal\"],\n * },\n * }),\n * getWeather,\n * ],\n * });\n * ```\n */\nexport function toolSearch(options?: ToolSearchOptions): ServerTool {\n return {\n type: \"tool_search\",\n ...(options?.execution ? { execution: options.execution } : {}),\n ...(options?.description ? { description: options.description } : {}),\n ...(options?.parameters !== undefined\n ? { parameters: options.parameters }\n : {}),\n } satisfies ToolSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,SAAgB,WAAW,SAAyC;AAClE,QAAO;EACL,MAAM;EACN,GAAI,SAAS,YAAY,EAAE,WAAW,QAAQ,WAAW,GAAG,EAAE;EAC9D,GAAI,SAAS,cAAc,EAAE,aAAa,QAAQ,aAAa,GAAG,EAAE;EACpE,GAAI,SAAS,eAAe,KAAA,IACxB,EAAE,YAAY,QAAQ,YAAY,GAClC,EAAE;EACP"}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/tools/webSearch.ts
3
2
  /**
4
3
  * Creates a web search tool that allows OpenAI models to search the web
@@ -67,7 +66,7 @@ function webSearch(options) {
67
66
  search_context_size: options?.search_context_size
68
67
  };
69
68
  }
70
-
71
69
  //#endregion
72
70
  exports.webSearch = webSearch;
71
+
73
72
  //# sourceMappingURL=webSearch.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.cjs","names":[],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * User location configuration for geographic search refinement.\n */\nexport interface WebSearchUserLocation {\n /**\n * The type of location. Currently only \"approximate\" is supported.\n */\n type: \"approximate\";\n /**\n * Two-letter ISO country code (e.g., \"US\", \"GB\").\n * @see https://en.wikipedia.org/wiki/ISO_3166-1\n */\n country?: string;\n /**\n * City name (e.g., \"San Francisco\", \"London\").\n */\n city?: string;\n /**\n * Region or state name (e.g., \"California\", \"London\").\n */\n region?: string;\n /**\n * IANA timezone (e.g., \"America/Los_Angeles\", \"Europe/London\").\n * @see https://timeapi.io/documentation/iana-timezones\n */\n timezone?: string;\n}\n\n/**\n * Domain filtering configuration for web search.\n */\nexport interface WebSearchFilters {\n /**\n * Allow-list of up to 100 domains to limit search results.\n * Omit the HTTP/HTTPS prefix (e.g., \"openai.com\" instead of \"https://openai.com/\").\n * Includes subdomains automatically.\n */\n allowedDomains?: string[];\n}\n\n/**\n * Options for the OpenAI web search tool.\n */\nexport interface WebSearchOptions {\n /**\n * Domain filtering configuration.\n * Limit results to a specific set of up to 100 domains.\n */\n filters?: WebSearchFilters;\n /**\n * Approximate user location for geographic search refinement.\n * Not supported for deep research models.\n */\n userLocation?: WebSearchUserLocation;\n /**\n * High level guidance for the amount of context window space to use for the\n * search. One of `low`, `medium`, or `high`. `medium` is the default.\n */\n search_context_size?: \"low\" | \"medium\" | \"high\";\n}\n\n/**\n * OpenAI web search tool type for the Responses API.\n */\nexport type WebSearchTool = OpenAIClient.Responses.WebSearchTool;\n\n/**\n * Creates a web search tool that allows OpenAI models to search the web\n * for up-to-date information before generating a response.\n *\n * Web search supports three main types:\n * 1. **Non-reasoning web search**: Quick lookups where the model passes queries\n * directly to the search tool.\n * 2. **Agentic search with reasoning models**: The model actively manages the\n * search process, analyzing results and deciding whether to keep searching.\n * 3. **Deep research**: Extended investigations using models like `o3-deep-research`\n * or `gpt-5` with high reasoning effort.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-web-search | OpenAI Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What was a positive news story from today?\", {\n * tools: [tools.webSearch()],\n * });\n *\n * // With domain filtering\n * const filteredResponse = await model.invoke(\"Latest AI research news\", {\n * tools: [tools.webSearch({\n * filters: {\n * allowedDomains: [\"arxiv.org\", \"nature.com\", \"science.org\"],\n * },\n * })],\n * });\n *\n * // With user location for geographic relevance\n * const localResponse = await model.invoke(\"What are the best restaurants near me?\", {\n * tools: [tools.webSearch({\n * userLocation: {\n * type: \"approximate\",\n * country: \"US\",\n * city: \"San Francisco\",\n * region: \"California\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n *\n * // Cache-only mode (no live internet access)\n * const cachedResponse = await model.invoke(\"Find information about OpenAI\", {\n * tools: [tools.webSearch({\n * externalWebAccess: false,\n * })],\n * });\n * ```\n */\nexport function webSearch(options?: WebSearchOptions): ServerTool {\n return {\n type: \"web_search\",\n filters: options?.filters?.allowedDomains\n ? { allowed_domains: options.filters.allowedDomains }\n : undefined,\n user_location: options?.userLocation,\n search_context_size: options?.search_context_size,\n } satisfies WebSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgIA,SAAgB,UAAU,SAAwC;AAChE,QAAO;EACL,MAAM;EACN,SAAS,SAAS,SAAS,iBACvB,EAAE,iBAAiB,QAAQ,QAAQ,gBAAgB,GACnD;EACJ,eAAe,SAAS;EACxB,qBAAqB,SAAS;EAC/B"}
1
+ {"version":3,"file":"webSearch.cjs","names":[],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * User location configuration for geographic search refinement.\n */\nexport interface WebSearchUserLocation {\n /**\n * The type of location. Currently only \"approximate\" is supported.\n */\n type: \"approximate\";\n /**\n * Two-letter ISO country code (e.g., \"US\", \"GB\").\n * @see https://en.wikipedia.org/wiki/ISO_3166-1\n */\n country?: string;\n /**\n * City name (e.g., \"San Francisco\", \"London\").\n */\n city?: string;\n /**\n * Region or state name (e.g., \"California\", \"London\").\n */\n region?: string;\n /**\n * IANA timezone (e.g., \"America/Los_Angeles\", \"Europe/London\").\n * @see https://timeapi.io/documentation/iana-timezones\n */\n timezone?: string;\n}\n\n/**\n * Domain filtering configuration for web search.\n */\nexport interface WebSearchFilters {\n /**\n * Allow-list of up to 100 domains to limit search results.\n * Omit the HTTP/HTTPS prefix (e.g., \"openai.com\" instead of \"https://openai.com/\").\n * Includes subdomains automatically.\n */\n allowedDomains?: string[];\n}\n\n/**\n * Options for the OpenAI web search tool.\n */\nexport interface WebSearchOptions {\n /**\n * Domain filtering configuration.\n * Limit results to a specific set of up to 100 domains.\n */\n filters?: WebSearchFilters;\n /**\n * Approximate user location for geographic search refinement.\n * Not supported for deep research models.\n */\n userLocation?: WebSearchUserLocation;\n /**\n * High level guidance for the amount of context window space to use for the\n * search. One of `low`, `medium`, or `high`. `medium` is the default.\n */\n search_context_size?: \"low\" | \"medium\" | \"high\";\n}\n\n/**\n * OpenAI web search tool type for the Responses API.\n */\nexport type WebSearchTool = OpenAIClient.Responses.WebSearchTool;\n\n/**\n * Creates a web search tool that allows OpenAI models to search the web\n * for up-to-date information before generating a response.\n *\n * Web search supports three main types:\n * 1. **Non-reasoning web search**: Quick lookups where the model passes queries\n * directly to the search tool.\n * 2. **Agentic search with reasoning models**: The model actively manages the\n * search process, analyzing results and deciding whether to keep searching.\n * 3. **Deep research**: Extended investigations using models like `o3-deep-research`\n * or `gpt-5` with high reasoning effort.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-web-search | OpenAI Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What was a positive news story from today?\", {\n * tools: [tools.webSearch()],\n * });\n *\n * // With domain filtering\n * const filteredResponse = await model.invoke(\"Latest AI research news\", {\n * tools: [tools.webSearch({\n * filters: {\n * allowedDomains: [\"arxiv.org\", \"nature.com\", \"science.org\"],\n * },\n * })],\n * });\n *\n * // With user location for geographic relevance\n * const localResponse = await model.invoke(\"What are the best restaurants near me?\", {\n * tools: [tools.webSearch({\n * userLocation: {\n * type: \"approximate\",\n * country: \"US\",\n * city: \"San Francisco\",\n * region: \"California\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n *\n * // Cache-only mode (no live internet access)\n * const cachedResponse = await model.invoke(\"Find information about OpenAI\", {\n * tools: [tools.webSearch({\n * externalWebAccess: false,\n * })],\n * });\n * ```\n */\nexport function webSearch(options?: WebSearchOptions): ServerTool {\n return {\n type: \"web_search\",\n filters: options?.filters?.allowedDomains\n ? { allowed_domains: options.filters.allowedDomains }\n : undefined,\n user_location: options?.userLocation,\n search_context_size: options?.search_context_size,\n } satisfies WebSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgIA,SAAgB,UAAU,SAAwC;AAChE,QAAO;EACL,MAAM;EACN,SAAS,SAAS,SAAS,iBACvB,EAAE,iBAAiB,QAAQ,QAAQ,gBAAgB,GACnD,KAAA;EACJ,eAAe,SAAS;EACxB,qBAAqB,SAAS;EAC/B"}
@@ -1,4 +1,4 @@
1
- import { OpenAI as OpenAI$1 } from "openai";
1
+ import { OpenAI } from "openai";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/webSearch.d.ts
@@ -63,7 +63,7 @@ interface WebSearchOptions {
63
63
  /**
64
64
  * OpenAI web search tool type for the Responses API.
65
65
  */
66
- type WebSearchTool = OpenAI$1.Responses.WebSearchTool;
66
+ type WebSearchTool = OpenAI.Responses.WebSearchTool;
67
67
  /**
68
68
  * Creates a web search tool that allows OpenAI models to search the web
69
69
  * for up-to-date information before generating a response.
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.d.cts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,qBAAA;;;;EAIf,IAAA;EASA;;;;EAJA,OAAA;EAmBe;;;EAff,IAAA;EAqBc;AAMhB;;EAvBE,MAAA;EAiCoC;;;;EA5BpC,QAAA;AAAA;;;AAuCF;UAjCiB,gBAAA;;;;;;EAMf,cAAA;AAAA;AAwFF;;;AAAA,UAlFiB,gBAAA;EAkFmB;;;;EA7ElC,OAAA,GAAU,gBAAA;;;;;EAKV,YAAA,GAAe,qBAAA;;;;;EAKf,mBAAA;AAAA;;;;KAMU,aAAA,GAAgB,QAAA,CAAa,SAAA,CAAU,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DnC,SAAA,CAAU,OAAA,GAAU,gBAAA,GAAmB,UAAA"}
1
+ {"version":3,"file":"webSearch.d.cts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,qBAAA;;;;EAIf,IAAA;EASA;;;;EAJA,OAAA;EAmBe;;;EAff,IAAA;EAqBc;AAMhB;;EAvBE,MAAA;EAiCoC;;;;EA5BpC,QAAA;AAAA;;;AAuCF;UAjCiB,gBAAA;;;;;;EAMf,cAAA;AAAA;AAwFF;;;AAAA,UAlFiB,gBAAA;EAkFmB;;;;EA7ElC,OAAA,GAAU,gBAAA;;;;;EAKV,YAAA,GAAe,qBAAA;;;;;EAKf,mBAAA;AAAA;;;;KAMU,aAAA,GAAgB,MAAA,CAAa,SAAA,CAAU,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DnC,SAAA,CAAU,OAAA,GAAU,gBAAA,GAAmB,UAAA"}
@@ -1,4 +1,4 @@
1
- import { OpenAI as OpenAI$1 } from "openai";
1
+ import { OpenAI } from "openai";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/webSearch.d.ts
@@ -63,7 +63,7 @@ interface WebSearchOptions {
63
63
  /**
64
64
  * OpenAI web search tool type for the Responses API.
65
65
  */
66
- type WebSearchTool = OpenAI$1.Responses.WebSearchTool;
66
+ type WebSearchTool = OpenAI.Responses.WebSearchTool;
67
67
  /**
68
68
  * Creates a web search tool that allows OpenAI models to search the web
69
69
  * for up-to-date information before generating a response.
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.d.ts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,qBAAA;;;;EAIf,IAAA;EASA;;;;EAJA,OAAA;EAmBe;;;EAff,IAAA;EAqBc;AAMhB;;EAvBE,MAAA;EAiCoC;;;;EA5BpC,QAAA;AAAA;;;AAuCF;UAjCiB,gBAAA;;;;;;EAMf,cAAA;AAAA;AAwFF;;;AAAA,UAlFiB,gBAAA;EAkFmB;;;;EA7ElC,OAAA,GAAU,gBAAA;;;;;EAKV,YAAA,GAAe,qBAAA;;;;;EAKf,mBAAA;AAAA;;;;KAMU,aAAA,GAAgB,QAAA,CAAa,SAAA,CAAU,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DnC,SAAA,CAAU,OAAA,GAAU,gBAAA,GAAmB,UAAA"}
1
+ {"version":3,"file":"webSearch.d.ts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,qBAAA;;;;EAIf,IAAA;EASA;;;;EAJA,OAAA;EAmBe;;;EAff,IAAA;EAqBc;AAMhB;;EAvBE,MAAA;EAiCoC;;;;EA5BpC,QAAA;AAAA;;;AAuCF;UAjCiB,gBAAA;;;;;;EAMf,cAAA;AAAA;AAwFF;;;AAAA,UAlFiB,gBAAA;EAkFmB;;;;EA7ElC,OAAA,GAAU,gBAAA;;;;;EAKV,YAAA,GAAe,qBAAA;;;;;EAKf,mBAAA;AAAA;;;;KAMU,aAAA,GAAgB,MAAA,CAAa,SAAA,CAAU,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DnC,SAAA,CAAU,OAAA,GAAU,gBAAA,GAAmB,UAAA"}
@@ -66,7 +66,7 @@ function webSearch(options) {
66
66
  search_context_size: options?.search_context_size
67
67
  };
68
68
  }
69
-
70
69
  //#endregion
71
70
  export { webSearch };
71
+
72
72
  //# sourceMappingURL=webSearch.js.map