@langchain/openai 1.2.1 → 1.2.3-dev-1768440391024

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 (42) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/azure/chat_models/completions.cjs.map +1 -1
  3. package/dist/azure/chat_models/completions.js.map +1 -1
  4. package/dist/azure/chat_models/index.cjs.map +1 -1
  5. package/dist/azure/chat_models/index.js.map +1 -1
  6. package/dist/azure/chat_models/responses.cjs.map +1 -1
  7. package/dist/azure/chat_models/responses.js.map +1 -1
  8. package/dist/chat_models/base.cjs.map +1 -1
  9. package/dist/chat_models/base.d.cts +2 -2
  10. package/dist/chat_models/base.d.cts.map +1 -1
  11. package/dist/chat_models/base.d.ts +2 -2
  12. package/dist/chat_models/base.d.ts.map +1 -1
  13. package/dist/chat_models/base.js.map +1 -1
  14. package/dist/chat_models/completions.cjs.map +1 -1
  15. package/dist/chat_models/completions.js.map +1 -1
  16. package/dist/chat_models/index.cjs.map +1 -1
  17. package/dist/chat_models/index.js.map +1 -1
  18. package/dist/chat_models/responses.cjs.map +1 -1
  19. package/dist/chat_models/responses.js.map +1 -1
  20. package/dist/converters/responses.cjs +39 -18
  21. package/dist/converters/responses.cjs.map +1 -1
  22. package/dist/converters/responses.js +39 -18
  23. package/dist/converters/responses.js.map +1 -1
  24. package/dist/tools/applyPatch.d.cts +1 -1
  25. package/dist/tools/applyPatch.d.cts.map +1 -1
  26. package/dist/tools/applyPatch.d.ts +1 -1
  27. package/dist/tools/applyPatch.d.ts.map +1 -1
  28. package/dist/tools/computerUse.d.cts +1 -1
  29. package/dist/tools/computerUse.d.cts.map +1 -1
  30. package/dist/tools/computerUse.d.ts +1 -1
  31. package/dist/tools/computerUse.d.ts.map +1 -1
  32. package/dist/tools/localShell.d.cts +1 -1
  33. package/dist/tools/localShell.d.cts.map +1 -1
  34. package/dist/tools/localShell.d.ts +1 -1
  35. package/dist/tools/localShell.d.ts.map +1 -1
  36. package/dist/tools/shell.d.cts +1 -1
  37. package/dist/tools/shell.d.cts.map +1 -1
  38. package/dist/tools/shell.d.ts +1 -1
  39. package/dist/tools/shell.d.ts.map +1 -1
  40. package/dist/utils/output.cjs.map +1 -1
  41. package/dist/utils/output.js.map +1 -1
  42. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"computerUse.d.ts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","ToolRuntime","ToolMessage","ComputerUseEnvironment","ComputerUseClickAction","Responses","ResponseComputerToolCall","Click","ComputerUseDoubleClickAction","DoubleClick","ComputerUseDragAction","Drag","ComputerUseKeypressAction","Keypress","ComputerUseMoveAction","Move","ComputerUseScreenshotAction","Screenshot","ComputerUseScrollAction","Scroll","ComputerUseTypeAction","Type","ComputerUseWaitAction","Wait","ComputerUseAction","ComputerUseScreenshotActionSchema","ZodLiteral","core","$strip","ZodObject","ComputerUseClickActionSchema","ZodNumber","ZodEnum","ZodDefault","ComputerUseDoubleClickActionSchema","ComputerUseDragActionSchema","ZodArray","ComputerUseKeypressActionSchema","ZodString","ComputerUseMoveActionSchema","ComputerUseScrollActionSchema","ComputerUseTypeActionSchema","ComputerUseWaitActionSchema","ZodOptional","ComputerUseActionSchema","ZodDiscriminatedUnion","ComputerUseScreenshotActionType","infer","ComputerUseClickActionType","ComputerUseDoubleClickActionType","ComputerUseDragActionType","ComputerUseKeypressActionType","ComputerUseMoveActionType","ComputerUseScrollActionType","ComputerUseTypeActionType","ComputerUseWaitActionType","ComputerUseInput","ComputerUseReturnType","Promise","ComputerUseOptions","ComputerUseTool","ComputerTool","computerUse"],"sources":["../../src/tools/computerUse.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\nimport { type ToolRuntime } from \"@langchain/core/tools\";\nimport { ToolMessage } from \"@langchain/core/messages\";\n/**\n * The type of computer environment to control.\n */\nexport type ComputerUseEnvironment = \"browser\" | \"mac\" | \"windows\" | \"linux\" | \"ubuntu\";\n/**\n * Re-export action types from OpenAI SDK for convenience.\n */\nexport type ComputerUseClickAction = OpenAIClient.Responses.ResponseComputerToolCall.Click;\nexport type ComputerUseDoubleClickAction = OpenAIClient.Responses.ResponseComputerToolCall.DoubleClick;\nexport type ComputerUseDragAction = OpenAIClient.Responses.ResponseComputerToolCall.Drag;\nexport type ComputerUseKeypressAction = OpenAIClient.Responses.ResponseComputerToolCall.Keypress;\nexport type ComputerUseMoveAction = OpenAIClient.Responses.ResponseComputerToolCall.Move;\nexport type ComputerUseScreenshotAction = OpenAIClient.Responses.ResponseComputerToolCall.Screenshot;\nexport type ComputerUseScrollAction = OpenAIClient.Responses.ResponseComputerToolCall.Scroll;\nexport type ComputerUseTypeAction = OpenAIClient.Responses.ResponseComputerToolCall.Type;\nexport type ComputerUseWaitAction = OpenAIClient.Responses.ResponseComputerToolCall.Wait;\n/**\n * Union type of all computer use actions from OpenAI SDK.\n */\nexport type ComputerUseAction = OpenAIClient.Responses.ResponseComputerToolCall[\"action\"];\ndeclare const ComputerUseScreenshotActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"screenshot\">;\n}, z.core.$strip>;\ndeclare const ComputerUseClickActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n}, z.core.$strip>;\ndeclare const ComputerUseDoubleClickActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"double_click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n}, z.core.$strip>;\ndeclare const ComputerUseDragActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"drag\">;\n path: z.ZodArray<z.ZodObject<{\n x: z.ZodNumber;\n y: z.ZodNumber;\n }, z.core.$strip>>;\n}, z.core.$strip>;\ndeclare const ComputerUseKeypressActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"keypress\">;\n keys: z.ZodArray<z.ZodString>;\n}, z.core.$strip>;\ndeclare const ComputerUseMoveActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"move\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n}, z.core.$strip>;\ndeclare const ComputerUseScrollActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"scroll\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n scroll_x: z.ZodNumber;\n scroll_y: z.ZodNumber;\n}, z.core.$strip>;\ndeclare const ComputerUseTypeActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"type\">;\n text: z.ZodString;\n}, z.core.$strip>;\ndeclare const ComputerUseWaitActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"wait\">;\n duration: z.ZodOptional<z.ZodNumber>;\n}, z.core.$strip>;\nexport declare const ComputerUseActionSchema: z.ZodObject<{\n action: z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"screenshot\">;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"double_click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"drag\">;\n path: z.ZodArray<z.ZodObject<{\n x: z.ZodNumber;\n y: z.ZodNumber;\n }, z.core.$strip>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"keypress\">;\n keys: z.ZodArray<z.ZodString>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"move\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"scroll\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n scroll_x: z.ZodNumber;\n scroll_y: z.ZodNumber;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"type\">;\n text: z.ZodString;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"wait\">;\n duration: z.ZodOptional<z.ZodNumber>;\n }, z.core.$strip>]>;\n}, z.core.$strip>;\nexport type ComputerUseScreenshotActionType = z.infer<typeof ComputerUseScreenshotActionSchema>;\nexport type ComputerUseClickActionType = z.infer<typeof ComputerUseClickActionSchema>;\nexport type ComputerUseDoubleClickActionType = z.infer<typeof ComputerUseDoubleClickActionSchema>;\nexport type ComputerUseDragActionType = z.infer<typeof ComputerUseDragActionSchema>;\nexport type ComputerUseKeypressActionType = z.infer<typeof ComputerUseKeypressActionSchema>;\nexport type ComputerUseMoveActionType = z.infer<typeof ComputerUseMoveActionSchema>;\nexport type ComputerUseScrollActionType = z.infer<typeof ComputerUseScrollActionSchema>;\nexport type ComputerUseTypeActionType = z.infer<typeof ComputerUseTypeActionSchema>;\nexport type ComputerUseWaitActionType = z.infer<typeof ComputerUseWaitActionSchema>;\n/**\n * Input structure for the Computer Use tool.\n * The action is wrapped in an `action` property.\n */\nexport interface ComputerUseInput {\n action: ComputerUseAction;\n}\nexport type ComputerUseReturnType = string | Promise<string> | ToolMessage<any> | Promise<ToolMessage<any>>;\n/**\n * Options for the Computer Use tool.\n */\nexport interface ComputerUseOptions {\n /**\n * The width of the computer display in pixels.\n */\n displayWidth: number;\n /**\n * The height of the computer display in pixels.\n */\n displayHeight: number;\n /**\n * The type of computer environment to control.\n * - `browser`: Browser automation (recommended for most use cases)\n * - `mac`: macOS environment\n * - `windows`: Windows environment\n * - `linux`: Linux environment\n * - `ubuntu`: Ubuntu environment\n */\n environment: ComputerUseEnvironment;\n /**\n * Execute function that handles computer action execution.\n * This function receives the action input and should return a base64-encoded\n * screenshot of the result.\n */\n execute: (action: ComputerUseAction, runtime: ToolRuntime<any, any>) => ComputerUseReturnType;\n}\n/**\n * OpenAI Computer Use tool type for the Responses API.\n */\nexport type ComputerUseTool = OpenAIClient.Responses.ComputerTool;\n/**\n * Creates a Computer Use tool that allows models to control computer interfaces\n * and perform tasks by simulating mouse clicks, keyboard input, scrolling, and more.\n *\n * **Computer Use** is a practical application of OpenAI's Computer-Using Agent (CUA)\n * model (`computer-use-preview`), which combines vision capabilities with advanced\n * reasoning to simulate controlling computer interfaces.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends computer actions (click, type, scroll, etc.)\n * 2. Your code executes these actions in a controlled environment\n * 3. You capture a screenshot of the result\n * 4. Send the screenshot back to the model\n * 5. Repeat until the task is complete\n *\n * **Important**: Computer use is in beta and requires careful consideration:\n * - Use in sandboxed environments only\n * - Do not use for high-stakes or authenticated tasks\n * - Always implement human-in-the-loop for important decisions\n * - Handle safety checks appropriately\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-computer-use | OpenAI Computer Use Documentation}\n *\n * @param options - Configuration options for the Computer Use tool\n * @returns A Computer Use tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"computer-use-preview\" });\n *\n * // With execute callback for automatic action handling\n * const computer = tools.computerUse({\n * displayWidth: 1024,\n * displayHeight: 768,\n * environment: \"browser\",\n * execute: async (action) => {\n * if (action.type === \"screenshot\") {\n * return captureScreenshot();\n * }\n * if (action.type === \"click\") {\n * await page.mouse.click(action.x, action.y, { button: action.button });\n * return captureScreenshot();\n * }\n * if (action.type === \"type\") {\n * await page.keyboard.type(action.text);\n * return captureScreenshot();\n * }\n * // Handle other actions...\n * return captureScreenshot();\n * },\n * });\n *\n * const llmWithComputer = model.bindTools([computer]);\n * const response = await llmWithComputer.invoke(\n * \"Check the latest news on bing.com\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Without execute callback (manual action handling)\n * const computer = tools.computerUse({\n * displayWidth: 1024,\n * displayHeight: 768,\n * environment: \"browser\",\n * });\n *\n * const response = await model.invoke(\"Check the news\", {\n * tools: [computer],\n * });\n *\n * // Access the computer call from the response\n * const computerCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"computer_call\"\n * );\n * if (computerCall) {\n * console.log(\"Action to execute:\", computerCall.action);\n * // Execute the action manually, then send back a screenshot\n * }\n * ```\n *\n * @example\n * ```typescript\n * // For macOS desktop automation with Docker\n * const computer = tools.computerUse({\n * displayWidth: 1920,\n * displayHeight: 1080,\n * environment: \"mac\",\n * execute: async (action) => {\n * if (action.type === \"click\") {\n * await dockerExec(\n * `DISPLAY=:99 xdotool mousemove ${action.x} ${action.y} click 1`,\n * containerName\n * );\n * }\n * // Capture screenshot from container\n * return await getDockerScreenshot(containerName);\n * },\n * });\n * ```\n *\n * @remarks\n * - Only available through the Responses API (not Chat Completions)\n * - Requires `computer-use-preview` model\n * - Actions include: click, double_click, drag, keypress, move, screenshot, scroll, type, wait\n * - Safety checks may be returned that require acknowledgment before proceeding\n * - Use `truncation: \"auto\"` parameter when making requests\n * - Recommended to use with `reasoning.summary` for debugging\n */\nexport declare function computerUse(options: ComputerUseOptions): DynamicStructuredTool<z.ZodObject<{\n action: z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"screenshot\">;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"double_click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"drag\">;\n path: z.ZodArray<z.ZodObject<{\n x: z.ZodNumber;\n y: z.ZodNumber;\n }, z.core.$strip>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"keypress\">;\n keys: z.ZodArray<z.ZodString>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"move\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"scroll\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n scroll_x: z.ZodNumber;\n scroll_y: z.ZodNumber;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"type\">;\n text: z.ZodString;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"wait\">;\n duration: z.ZodOptional<z.ZodNumber>;\n }, z.core.$strip>]>;\n}, z.core.$strip>, ComputerUseInput, unknown, ComputerUseReturnType>;\nexport {};\n//# sourceMappingURL=computerUse.d.ts.map"],"mappings":";;;;;;;;AAQA;AAIA;AACYW,KALAL,sBAAAA,GAK4B,SAAA,GAAGJ,KAAAA,GAAaM,SAAAA,GAAUC,OAAAA,GAAAA,QAAAA;AAClE;AACA;AACA;AACYU,KALAZ,sBAAAA,GAAyBL,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBC,KAKpBD;AACrDY,KALAV,4BAAAA,GAA+BT,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBG,WAKC;AAChFW,KALAV,qBAAAA,GAAwBX,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBK,IAKAU;AACxEC,KALAV,yBAAAA,GAA4Bb,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBO,QAKA;AAI5EW,KARAV,qBAAAA,GAAwBf,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBS,IAQL;AA4H9DyC,KAnILxC,2BAAAA,GAA8BjB,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBW,UAoI7D;AAEjBwC,KArIAvC,uBAAAA,GAA0BnB,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBa,MAqIrD;AAAYuC,KApIjCtC,qBAAAA,GAAwBrB,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBe,IAoIvCqC;AAAkBxD,KAnInDoB,qBAAAA,GAAwBvB,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBiB,IAmIrBrB;;;AAA0B;AAIxEyD,KAnILnC,iBAAAA,GAAoBzB,QAAAA,CAAaM,SAAAA,CAAUC,wBAmIpB,CAAA,QAAA,CAAA;;;;;UAPlBkD,gBAAAA;UACLhC;;KAEAiC,qBAAAA,YAAiCC,kBAAkBxD,mBAAmBwD,QAAQxD;;;;UAIzEyD,kBAAAA;;;;;;;;;;;;;;;;;eAiBAxD;;;;;;oBAMKqB,4BAA4BvB,0BAA0BwD;;;;;KAKhEG,eAAAA,GAAkB7D,QAAAA,CAAaM,SAAAA,CAAUwD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiH7BC,WAAAA,UAAqBH,qBAAqB3D,sBAAsBH,CAAAA,CAAEgC;UAC9EhC,CAAAA,CAAEgD,uBAAuBhD,CAAAA,CAAEgC;UACzBhC,CAAAA,CAAE6B;KACT7B,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;OACL7B,CAAAA,CAAEkC;OACFlC,CAAAA,CAAEkC;YACGlC,CAAAA,CAAEoC,WAAWpC,CAAAA,CAAEmC;;;;;;;KAOxBnC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;OACL7B,CAAAA,CAAEkC;OACFlC,CAAAA,CAAEkC;YACGlC,CAAAA,CAAEoC,WAAWpC,CAAAA,CAAEmC;;;;;;;KAOxBnC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;UACF7B,CAAAA,CAAEuC,SAASvC,CAAAA,CAAEgC;SACZhC,CAAAA,CAAEkC;SACFlC,CAAAA,CAAEkC;OACNlC,CAAAA,CAAE8B,IAAAA,CAAKC;KACX/B,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;UACF7B,CAAAA,CAAEuC,SAASvC,CAAAA,CAAEyC;KACpBzC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;OACL7B,CAAAA,CAAEkC;OACFlC,CAAAA,CAAEkC;KACNlC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;OACL7B,CAAAA,CAAEkC;OACFlC,CAAAA,CAAEkC;cACKlC,CAAAA,CAAEkC;cACFlC,CAAAA,CAAEkC;KACblC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;UACF7B,CAAAA,CAAEyC;KACTzC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;cACE7B,CAAAA,CAAE8C,YAAY9C,CAAAA,CAAEkC;KAC3BlC,CAAAA,CAAE8B,IAAAA,CAAKC;GACX/B,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS4B,2BAA2BC"}
1
+ {"version":3,"file":"computerUse.d.ts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","ToolRuntime","ToolMessage","ComputerUseEnvironment","ComputerUseClickAction","Responses","ResponseComputerToolCall","Click","ComputerUseDoubleClickAction","DoubleClick","ComputerUseDragAction","Drag","ComputerUseKeypressAction","Keypress","ComputerUseMoveAction","Move","ComputerUseScreenshotAction","Screenshot","ComputerUseScrollAction","Scroll","ComputerUseTypeAction","Type","ComputerUseWaitAction","Wait","ComputerUseAction","ComputerUseScreenshotActionSchema","ZodLiteral","core","$strip","ZodObject","ComputerUseClickActionSchema","ZodNumber","ZodEnum","ZodDefault","ComputerUseDoubleClickActionSchema","ComputerUseDragActionSchema","ZodArray","ComputerUseKeypressActionSchema","ZodString","ComputerUseMoveActionSchema","ComputerUseScrollActionSchema","ComputerUseTypeActionSchema","ComputerUseWaitActionSchema","ZodOptional","ComputerUseActionSchema","ZodDiscriminatedUnion","ComputerUseScreenshotActionType","infer","ComputerUseClickActionType","ComputerUseDoubleClickActionType","ComputerUseDragActionType","ComputerUseKeypressActionType","ComputerUseMoveActionType","ComputerUseScrollActionType","ComputerUseTypeActionType","ComputerUseWaitActionType","ComputerUseInput","ComputerUseReturnType","Promise","ComputerUseOptions","ComputerUseTool","ComputerTool","computerUse"],"sources":["../../src/tools/computerUse.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\nimport { type ToolRuntime } from \"@langchain/core/tools\";\nimport { ToolMessage } from \"@langchain/core/messages\";\n/**\n * The type of computer environment to control.\n */\nexport type ComputerUseEnvironment = \"browser\" | \"mac\" | \"windows\" | \"linux\" | \"ubuntu\";\n/**\n * Re-export action types from OpenAI SDK for convenience.\n */\nexport type ComputerUseClickAction = OpenAIClient.Responses.ResponseComputerToolCall.Click;\nexport type ComputerUseDoubleClickAction = OpenAIClient.Responses.ResponseComputerToolCall.DoubleClick;\nexport type ComputerUseDragAction = OpenAIClient.Responses.ResponseComputerToolCall.Drag;\nexport type ComputerUseKeypressAction = OpenAIClient.Responses.ResponseComputerToolCall.Keypress;\nexport type ComputerUseMoveAction = OpenAIClient.Responses.ResponseComputerToolCall.Move;\nexport type ComputerUseScreenshotAction = OpenAIClient.Responses.ResponseComputerToolCall.Screenshot;\nexport type ComputerUseScrollAction = OpenAIClient.Responses.ResponseComputerToolCall.Scroll;\nexport type ComputerUseTypeAction = OpenAIClient.Responses.ResponseComputerToolCall.Type;\nexport type ComputerUseWaitAction = OpenAIClient.Responses.ResponseComputerToolCall.Wait;\n/**\n * Union type of all computer use actions from OpenAI SDK.\n */\nexport type ComputerUseAction = OpenAIClient.Responses.ResponseComputerToolCall[\"action\"];\ndeclare const ComputerUseScreenshotActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"screenshot\">;\n}, z.core.$strip>;\ndeclare const ComputerUseClickActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n}, z.core.$strip>;\ndeclare const ComputerUseDoubleClickActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"double_click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n}, z.core.$strip>;\ndeclare const ComputerUseDragActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"drag\">;\n path: z.ZodArray<z.ZodObject<{\n x: z.ZodNumber;\n y: z.ZodNumber;\n }, z.core.$strip>>;\n}, z.core.$strip>;\ndeclare const ComputerUseKeypressActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"keypress\">;\n keys: z.ZodArray<z.ZodString>;\n}, z.core.$strip>;\ndeclare const ComputerUseMoveActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"move\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n}, z.core.$strip>;\ndeclare const ComputerUseScrollActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"scroll\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n scroll_x: z.ZodNumber;\n scroll_y: z.ZodNumber;\n}, z.core.$strip>;\ndeclare const ComputerUseTypeActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"type\">;\n text: z.ZodString;\n}, z.core.$strip>;\ndeclare const ComputerUseWaitActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"wait\">;\n duration: z.ZodOptional<z.ZodNumber>;\n}, z.core.$strip>;\nexport declare const ComputerUseActionSchema: z.ZodObject<{\n action: z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"screenshot\">;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"double_click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"drag\">;\n path: z.ZodArray<z.ZodObject<{\n x: z.ZodNumber;\n y: z.ZodNumber;\n }, z.core.$strip>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"keypress\">;\n keys: z.ZodArray<z.ZodString>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"move\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"scroll\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n scroll_x: z.ZodNumber;\n scroll_y: z.ZodNumber;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"type\">;\n text: z.ZodString;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"wait\">;\n duration: z.ZodOptional<z.ZodNumber>;\n }, z.core.$strip>]>;\n}, z.core.$strip>;\nexport type ComputerUseScreenshotActionType = z.infer<typeof ComputerUseScreenshotActionSchema>;\nexport type ComputerUseClickActionType = z.infer<typeof ComputerUseClickActionSchema>;\nexport type ComputerUseDoubleClickActionType = z.infer<typeof ComputerUseDoubleClickActionSchema>;\nexport type ComputerUseDragActionType = z.infer<typeof ComputerUseDragActionSchema>;\nexport type ComputerUseKeypressActionType = z.infer<typeof ComputerUseKeypressActionSchema>;\nexport type ComputerUseMoveActionType = z.infer<typeof ComputerUseMoveActionSchema>;\nexport type ComputerUseScrollActionType = z.infer<typeof ComputerUseScrollActionSchema>;\nexport type ComputerUseTypeActionType = z.infer<typeof ComputerUseTypeActionSchema>;\nexport type ComputerUseWaitActionType = z.infer<typeof ComputerUseWaitActionSchema>;\n/**\n * Input structure for the Computer Use tool.\n * The action is wrapped in an `action` property.\n */\nexport interface ComputerUseInput {\n action: ComputerUseAction;\n}\nexport type ComputerUseReturnType = string | Promise<string> | ToolMessage<any> | Promise<ToolMessage<any>>;\n/**\n * Options for the Computer Use tool.\n */\nexport interface ComputerUseOptions {\n /**\n * The width of the computer display in pixels.\n */\n displayWidth: number;\n /**\n * The height of the computer display in pixels.\n */\n displayHeight: number;\n /**\n * The type of computer environment to control.\n * - `browser`: Browser automation (recommended for most use cases)\n * - `mac`: macOS environment\n * - `windows`: Windows environment\n * - `linux`: Linux environment\n * - `ubuntu`: Ubuntu environment\n */\n environment: ComputerUseEnvironment;\n /**\n * Execute function that handles computer action execution.\n * This function receives the action input and should return a base64-encoded\n * screenshot of the result.\n */\n execute: (action: ComputerUseAction, runtime: ToolRuntime<any, any>) => ComputerUseReturnType;\n}\n/**\n * OpenAI Computer Use tool type for the Responses API.\n */\nexport type ComputerUseTool = OpenAIClient.Responses.ComputerTool;\n/**\n * Creates a Computer Use tool that allows models to control computer interfaces\n * and perform tasks by simulating mouse clicks, keyboard input, scrolling, and more.\n *\n * **Computer Use** is a practical application of OpenAI's Computer-Using Agent (CUA)\n * model (`computer-use-preview`), which combines vision capabilities with advanced\n * reasoning to simulate controlling computer interfaces.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends computer actions (click, type, scroll, etc.)\n * 2. Your code executes these actions in a controlled environment\n * 3. You capture a screenshot of the result\n * 4. Send the screenshot back to the model\n * 5. Repeat until the task is complete\n *\n * **Important**: Computer use is in beta and requires careful consideration:\n * - Use in sandboxed environments only\n * - Do not use for high-stakes or authenticated tasks\n * - Always implement human-in-the-loop for important decisions\n * - Handle safety checks appropriately\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-computer-use | OpenAI Computer Use Documentation}\n *\n * @param options - Configuration options for the Computer Use tool\n * @returns A Computer Use tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"computer-use-preview\" });\n *\n * // With execute callback for automatic action handling\n * const computer = tools.computerUse({\n * displayWidth: 1024,\n * displayHeight: 768,\n * environment: \"browser\",\n * execute: async (action) => {\n * if (action.type === \"screenshot\") {\n * return captureScreenshot();\n * }\n * if (action.type === \"click\") {\n * await page.mouse.click(action.x, action.y, { button: action.button });\n * return captureScreenshot();\n * }\n * if (action.type === \"type\") {\n * await page.keyboard.type(action.text);\n * return captureScreenshot();\n * }\n * // Handle other actions...\n * return captureScreenshot();\n * },\n * });\n *\n * const llmWithComputer = model.bindTools([computer]);\n * const response = await llmWithComputer.invoke(\n * \"Check the latest news on bing.com\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Without execute callback (manual action handling)\n * const computer = tools.computerUse({\n * displayWidth: 1024,\n * displayHeight: 768,\n * environment: \"browser\",\n * });\n *\n * const response = await model.invoke(\"Check the news\", {\n * tools: [computer],\n * });\n *\n * // Access the computer call from the response\n * const computerCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"computer_call\"\n * );\n * if (computerCall) {\n * console.log(\"Action to execute:\", computerCall.action);\n * // Execute the action manually, then send back a screenshot\n * }\n * ```\n *\n * @example\n * ```typescript\n * // For macOS desktop automation with Docker\n * const computer = tools.computerUse({\n * displayWidth: 1920,\n * displayHeight: 1080,\n * environment: \"mac\",\n * execute: async (action) => {\n * if (action.type === \"click\") {\n * await dockerExec(\n * `DISPLAY=:99 xdotool mousemove ${action.x} ${action.y} click 1`,\n * containerName\n * );\n * }\n * // Capture screenshot from container\n * return await getDockerScreenshot(containerName);\n * },\n * });\n * ```\n *\n * @remarks\n * - Only available through the Responses API (not Chat Completions)\n * - Requires `computer-use-preview` model\n * - Actions include: click, double_click, drag, keypress, move, screenshot, scroll, type, wait\n * - Safety checks may be returned that require acknowledgment before proceeding\n * - Use `truncation: \"auto\"` parameter when making requests\n * - Recommended to use with `reasoning.summary` for debugging\n */\nexport declare function computerUse(options: ComputerUseOptions): DynamicStructuredTool<z.ZodObject<{\n action: z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"screenshot\">;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"double_click\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n button: z.ZodDefault<z.ZodEnum<{\n back: \"back\";\n forward: \"forward\";\n left: \"left\";\n right: \"right\";\n wheel: \"wheel\";\n }>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"drag\">;\n path: z.ZodArray<z.ZodObject<{\n x: z.ZodNumber;\n y: z.ZodNumber;\n }, z.core.$strip>>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"keypress\">;\n keys: z.ZodArray<z.ZodString>;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"move\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"scroll\">;\n x: z.ZodNumber;\n y: z.ZodNumber;\n scroll_x: z.ZodNumber;\n scroll_y: z.ZodNumber;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"type\">;\n text: z.ZodString;\n }, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"wait\">;\n duration: z.ZodOptional<z.ZodNumber>;\n }, z.core.$strip>]>;\n}, z.core.$strip>, ComputerUseInput, unknown, ComputerUseReturnType, string>;\nexport {};\n//# sourceMappingURL=computerUse.d.ts.map"],"mappings":";;;;;;;;AAQA;AAIA;AACYW,KALAL,sBAAAA,GAK4B,SAAA,GAAGJ,KAAAA,GAAaM,SAAAA,GAAUC,OAAAA,GAAAA,QAAAA;AAClE;AACA;AACA;AACYU,KALAZ,sBAAAA,GAAyBL,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBC,KAKpBD;AACrDY,KALAV,4BAAAA,GAA+BT,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBG,WAKC;AAChFW,KALAV,qBAAAA,GAAwBX,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBK,IAKAU;AACxEC,KALAV,yBAAAA,GAA4Bb,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBO,QAKA;AAI5EW,KARAV,qBAAAA,GAAwBf,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBS,IAQL;AA4H9DyC,KAnILxC,2BAAAA,GAA8BjB,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBW,UAoI7D;AAEjBwC,KArIAvC,uBAAAA,GAA0BnB,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBa,MAqIrD;AAAYuC,KApIjCtC,qBAAAA,GAAwBrB,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBe,IAoIvCqC;AAAkBxD,KAnInDoB,qBAAAA,GAAwBvB,QAAAA,CAAaM,SAAAA,CAAUC,wBAAAA,CAAyBiB,IAmIrBrB;;;AAA0B;AAIxEyD,KAnILnC,iBAAAA,GAAoBzB,QAAAA,CAAaM,SAAAA,CAAUC,wBAmIpB,CAAA,QAAA,CAAA;;;;;UAPlBkD,gBAAAA;UACLhC;;KAEAiC,qBAAAA,YAAiCC,kBAAkBxD,mBAAmBwD,QAAQxD;;;;UAIzEyD,kBAAAA;;;;;;;;;;;;;;;;;eAiBAxD;;;;;;oBAMKqB,4BAA4BvB,0BAA0BwD;;;;;KAKhEG,eAAAA,GAAkB7D,QAAAA,CAAaM,SAAAA,CAAUwD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiH7BC,WAAAA,UAAqBH,qBAAqB3D,sBAAsBH,CAAAA,CAAEgC;UAC9EhC,CAAAA,CAAEgD,uBAAuBhD,CAAAA,CAAEgC;UACzBhC,CAAAA,CAAE6B;KACT7B,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;OACL7B,CAAAA,CAAEkC;OACFlC,CAAAA,CAAEkC;YACGlC,CAAAA,CAAEoC,WAAWpC,CAAAA,CAAEmC;;;;;;;KAOxBnC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;OACL7B,CAAAA,CAAEkC;OACFlC,CAAAA,CAAEkC;YACGlC,CAAAA,CAAEoC,WAAWpC,CAAAA,CAAEmC;;;;;;;KAOxBnC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;UACF7B,CAAAA,CAAEuC,SAASvC,CAAAA,CAAEgC;SACZhC,CAAAA,CAAEkC;SACFlC,CAAAA,CAAEkC;OACNlC,CAAAA,CAAE8B,IAAAA,CAAKC;KACX/B,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;UACF7B,CAAAA,CAAEuC,SAASvC,CAAAA,CAAEyC;KACpBzC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;OACL7B,CAAAA,CAAEkC;OACFlC,CAAAA,CAAEkC;KACNlC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;OACL7B,CAAAA,CAAEkC;OACFlC,CAAAA,CAAEkC;cACKlC,CAAAA,CAAEkC;cACFlC,CAAAA,CAAEkC;KACblC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;UACF7B,CAAAA,CAAEyC;KACTzC,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS/B,CAAAA,CAAEgC;UACXhC,CAAAA,CAAE6B;cACE7B,CAAAA,CAAE8C,YAAY9C,CAAAA,CAAEkC;KAC3BlC,CAAAA,CAAE8B,IAAAA,CAAKC;GACX/B,CAAAA,CAAE8B,IAAAA,CAAKC,SAAS4B,2BAA2BC"}
@@ -161,7 +161,7 @@ declare function localShell(options: LocalShellOptions): DynamicStructuredTool<z
161
161
  working_directory: z.ZodOptional<z.ZodString>;
162
162
  timeout_ms: z.ZodOptional<z.ZodNumber>;
163
163
  user: z.ZodOptional<z.ZodString>;
164
- }, z.core.$strip>]>, OpenAI$1.Responses.ResponseOutputItem.LocalShellCall.Action, unknown, string>;
164
+ }, z.core.$strip>]>, OpenAI$1.Responses.ResponseOutputItem.LocalShellCall.Action, unknown, string, string>;
165
165
  //#endregion
166
166
  export { LocalShellAction, LocalShellOptions, LocalShellTool, localShell };
167
167
  //# sourceMappingURL=localShell.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localShell.d.cts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","LocalShellAction","Responses","ResponseOutputItem","LocalShellCall","Action","LocalShellExecActionSchema","ZodLiteral","ZodString","ZodArray","ZodRecord","ZodOptional","ZodNumber","core","$strip","ZodObject","LocalShellActionSchema","ZodDiscriminatedUnion","LocalShellOptions","Promise","LocalShellTool","Tool","LocalShell","localShell"],"sources":["../../src/tools/localShell.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\n/**\n * Re-export action type from OpenAI SDK for convenience.\n * The action contains command details like argv tokens, environment variables,\n * working directory, timeout, and user.\n */\nexport type LocalShellAction = OpenAIClient.Responses.ResponseOutputItem.LocalShellCall.Action;\nexport declare const LocalShellExecActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>;\nexport declare const LocalShellActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>]>;\n/**\n * Options for the Local Shell tool.\n */\nexport interface LocalShellOptions {\n /**\n * Optional execute function that handles shell command execution.\n * This function receives the action input and should return the command output\n * (stdout + stderr combined).\n *\n * If not provided, you'll need to handle action execution manually by\n * checking `local_shell_call` outputs in the response.\n *\n * @example\n * ```typescript\n * execute: async (action) => {\n * const result = await exec(action.command.join(' '), {\n * cwd: action.working_directory,\n * env: { ...process.env, ...action.env },\n * timeout: action.timeout_ms,\n * });\n * return result.stdout + result.stderr;\n * }\n * ```\n */\n execute: (action: LocalShellAction) => string | Promise<string>;\n}\n/**\n * OpenAI Local Shell tool type for the Responses API.\n */\nexport type LocalShellTool = OpenAIClient.Responses.Tool.LocalShell;\n/**\n * Creates a Local Shell tool that allows models to run shell commands locally\n * on a machine you provide. Commands are executed inside your own runtime—\n * the API only returns the instructions, but does not execute them on OpenAI infrastructure.\n *\n * **Important**: The local shell tool is designed to work with\n * [Codex CLI](https://github.com/openai/codex) and the `codex-mini-latest` model.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends shell commands (`local_shell_call` with `exec` action)\n * 2. Your code executes the command locally\n * 3. You return the output back to the model\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-local-shell | OpenAI Local Shell Documentation}\n *\n * @param options - Optional configuration for the Local Shell tool\n * @returns A Local 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\";\n * import { promisify } from \"util\";\n *\n * const execAsync = promisify(exec);\n * const model = new ChatOpenAI({ model: \"codex-mini-latest\" });\n *\n * // With execute callback for automatic command handling\n * const shell = tools.localShell({\n * execute: async (action) => {\n * const { command, env, working_directory, timeout_ms } = action;\n * const result = await execAsync(command.join(' '), {\n * cwd: working_directory ?? process.cwd(),\n * env: { ...process.env, ...env },\n * timeout: timeout_ms ?? undefined,\n * });\n * return result.stdout + result.stderr;\n * },\n * });\n *\n * const llmWithShell = model.bindTools([shell]);\n * const response = await llmWithShell.invoke(\n * \"List files in the current directory\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Without execute callback (manual handling)\n * const shell = tools.localShell();\n *\n * const response = await model.invoke(\"List files\", {\n * tools: [shell],\n * });\n *\n * // Access the shell call from the response\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"local_shell_call\"\n * );\n * if (shellCall) {\n * console.log(\"Command to execute:\", shellCall.action.command);\n * // Execute the command manually, then send back the output\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.localShell()],\n * });\n *\n * while (true) {\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"local_shell_call\"\n * );\n *\n * if (!shellCall) break;\n *\n * // Execute command (with proper sandboxing!)\n * const output = await executeCommand(shellCall.action);\n *\n * // Send output back to model\n * response = await model.invoke([\n * response,\n * {\n * type: \"local_shell_call_output\",\n * id: shellCall.call_id,\n * output: output,\n * },\n * ], {\n * tools: [tools.localShell()],\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 `codex-mini-latest` model\n * - Commands are provided as argv tokens in `action.command`\n * - Action includes: `command`, `env`, `working_directory`, `timeout_ms`, `user`\n * - Always sandbox or validate commands before execution\n * - The `timeout_ms` from the model is only a hint—enforce your own limits\n */\nexport declare function localShell(options: LocalShellOptions): DynamicStructuredTool<z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>]>, OpenAIClient.Responses.ResponseOutputItem.LocalShellCall.Action, unknown, string>;\n//# sourceMappingURL=localShell.d.ts.map"],"mappings":";;;;;;;;AAQA;AAoBA;AA0BA;AAmHwB0B,KAjKZtB,gBAAAA,GAAmBF,QAAAA,CAAaG,SAAAA,CAAUC,kBAAAA,CAAmBC,cAAAA,CAAeC,MAiKtD;;;;AAAmD,UA7IpEa,iBAAAA,CA6IoE;;;;;;;;;;;;;;;;;;;;;oBAxH/DjB,8BAA8BkB;;;;;KAKxCC,cAAAA,GAAiBrB,QAAAA,CAAaG,SAAAA,CAAUmB,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmHjCC,UAAAA,UAAoBL,oBAAoBlB,sBAAsBH,CAAAA,CAAEoB,uBAAuBpB,CAAAA,CAAEkB;QACvGlB,CAAAA,CAAEU;WACCV,CAAAA,CAAEY,SAASZ,CAAAA,CAAEW;OACjBX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEa,UAAUb,CAAAA,CAAEW,WAAWX,CAAAA,CAAEW;qBAC3BX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEW;cACvBX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEe;QACtBf,CAAAA,CAAEc,YAAYd,CAAAA,CAAEW;GACvBX,CAAAA,CAAEgB,IAAAA,CAAKC,WAAWf,QAAAA,CAAaG,SAAAA,CAAUC,kBAAAA,CAAmBC,cAAAA,CAAeC"}
1
+ {"version":3,"file":"localShell.d.cts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","LocalShellAction","Responses","ResponseOutputItem","LocalShellCall","Action","LocalShellExecActionSchema","ZodLiteral","ZodString","ZodArray","ZodRecord","ZodOptional","ZodNumber","core","$strip","ZodObject","LocalShellActionSchema","ZodDiscriminatedUnion","LocalShellOptions","Promise","LocalShellTool","Tool","LocalShell","localShell"],"sources":["../../src/tools/localShell.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\n/**\n * Re-export action type from OpenAI SDK for convenience.\n * The action contains command details like argv tokens, environment variables,\n * working directory, timeout, and user.\n */\nexport type LocalShellAction = OpenAIClient.Responses.ResponseOutputItem.LocalShellCall.Action;\nexport declare const LocalShellExecActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>;\nexport declare const LocalShellActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>]>;\n/**\n * Options for the Local Shell tool.\n */\nexport interface LocalShellOptions {\n /**\n * Optional execute function that handles shell command execution.\n * This function receives the action input and should return the command output\n * (stdout + stderr combined).\n *\n * If not provided, you'll need to handle action execution manually by\n * checking `local_shell_call` outputs in the response.\n *\n * @example\n * ```typescript\n * execute: async (action) => {\n * const result = await exec(action.command.join(' '), {\n * cwd: action.working_directory,\n * env: { ...process.env, ...action.env },\n * timeout: action.timeout_ms,\n * });\n * return result.stdout + result.stderr;\n * }\n * ```\n */\n execute: (action: LocalShellAction) => string | Promise<string>;\n}\n/**\n * OpenAI Local Shell tool type for the Responses API.\n */\nexport type LocalShellTool = OpenAIClient.Responses.Tool.LocalShell;\n/**\n * Creates a Local Shell tool that allows models to run shell commands locally\n * on a machine you provide. Commands are executed inside your own runtime—\n * the API only returns the instructions, but does not execute them on OpenAI infrastructure.\n *\n * **Important**: The local shell tool is designed to work with\n * [Codex CLI](https://github.com/openai/codex) and the `codex-mini-latest` model.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends shell commands (`local_shell_call` with `exec` action)\n * 2. Your code executes the command locally\n * 3. You return the output back to the model\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-local-shell | OpenAI Local Shell Documentation}\n *\n * @param options - Optional configuration for the Local Shell tool\n * @returns A Local 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\";\n * import { promisify } from \"util\";\n *\n * const execAsync = promisify(exec);\n * const model = new ChatOpenAI({ model: \"codex-mini-latest\" });\n *\n * // With execute callback for automatic command handling\n * const shell = tools.localShell({\n * execute: async (action) => {\n * const { command, env, working_directory, timeout_ms } = action;\n * const result = await execAsync(command.join(' '), {\n * cwd: working_directory ?? process.cwd(),\n * env: { ...process.env, ...env },\n * timeout: timeout_ms ?? undefined,\n * });\n * return result.stdout + result.stderr;\n * },\n * });\n *\n * const llmWithShell = model.bindTools([shell]);\n * const response = await llmWithShell.invoke(\n * \"List files in the current directory\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Without execute callback (manual handling)\n * const shell = tools.localShell();\n *\n * const response = await model.invoke(\"List files\", {\n * tools: [shell],\n * });\n *\n * // Access the shell call from the response\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"local_shell_call\"\n * );\n * if (shellCall) {\n * console.log(\"Command to execute:\", shellCall.action.command);\n * // Execute the command manually, then send back the output\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.localShell()],\n * });\n *\n * while (true) {\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"local_shell_call\"\n * );\n *\n * if (!shellCall) break;\n *\n * // Execute command (with proper sandboxing!)\n * const output = await executeCommand(shellCall.action);\n *\n * // Send output back to model\n * response = await model.invoke([\n * response,\n * {\n * type: \"local_shell_call_output\",\n * id: shellCall.call_id,\n * output: output,\n * },\n * ], {\n * tools: [tools.localShell()],\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 `codex-mini-latest` model\n * - Commands are provided as argv tokens in `action.command`\n * - Action includes: `command`, `env`, `working_directory`, `timeout_ms`, `user`\n * - Always sandbox or validate commands before execution\n * - The `timeout_ms` from the model is only a hint—enforce your own limits\n */\nexport declare function localShell(options: LocalShellOptions): DynamicStructuredTool<z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>]>, OpenAIClient.Responses.ResponseOutputItem.LocalShellCall.Action, unknown, string, string>;\n//# sourceMappingURL=localShell.d.ts.map"],"mappings":";;;;;;;;AAQA;AAoBA;AA0BA;AAmHwB0B,KAjKZtB,gBAAAA,GAAmBF,QAAAA,CAAaG,SAAAA,CAAUC,kBAAAA,CAAmBC,cAAAA,CAAeC,MAiKtD;;;;AAAmD,UA7IpEa,iBAAAA,CA6IoE;;;;;;;;;;;;;;;;;;;;;oBAxH/DjB,8BAA8BkB;;;;;KAKxCC,cAAAA,GAAiBrB,QAAAA,CAAaG,SAAAA,CAAUmB,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmHjCC,UAAAA,UAAoBL,oBAAoBlB,sBAAsBH,CAAAA,CAAEoB,uBAAuBpB,CAAAA,CAAEkB;QACvGlB,CAAAA,CAAEU;WACCV,CAAAA,CAAEY,SAASZ,CAAAA,CAAEW;OACjBX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEa,UAAUb,CAAAA,CAAEW,WAAWX,CAAAA,CAAEW;qBAC3BX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEW;cACvBX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEe;QACtBf,CAAAA,CAAEc,YAAYd,CAAAA,CAAEW;GACvBX,CAAAA,CAAEgB,IAAAA,CAAKC,WAAWf,QAAAA,CAAaG,SAAAA,CAAUC,kBAAAA,CAAmBC,cAAAA,CAAeC"}
@@ -161,7 +161,7 @@ declare function localShell(options: LocalShellOptions): DynamicStructuredTool<z
161
161
  working_directory: z.ZodOptional<z.ZodString>;
162
162
  timeout_ms: z.ZodOptional<z.ZodNumber>;
163
163
  user: z.ZodOptional<z.ZodString>;
164
- }, z.core.$strip>]>, OpenAI$1.Responses.ResponseOutputItem.LocalShellCall.Action, unknown, string>;
164
+ }, z.core.$strip>]>, OpenAI$1.Responses.ResponseOutputItem.LocalShellCall.Action, unknown, string, string>;
165
165
  //#endregion
166
166
  export { LocalShellAction, LocalShellOptions, LocalShellTool, localShell };
167
167
  //# sourceMappingURL=localShell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localShell.d.ts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","LocalShellAction","Responses","ResponseOutputItem","LocalShellCall","Action","LocalShellExecActionSchema","ZodLiteral","ZodString","ZodArray","ZodRecord","ZodOptional","ZodNumber","core","$strip","ZodObject","LocalShellActionSchema","ZodDiscriminatedUnion","LocalShellOptions","Promise","LocalShellTool","Tool","LocalShell","localShell"],"sources":["../../src/tools/localShell.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\n/**\n * Re-export action type from OpenAI SDK for convenience.\n * The action contains command details like argv tokens, environment variables,\n * working directory, timeout, and user.\n */\nexport type LocalShellAction = OpenAIClient.Responses.ResponseOutputItem.LocalShellCall.Action;\nexport declare const LocalShellExecActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>;\nexport declare const LocalShellActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>]>;\n/**\n * Options for the Local Shell tool.\n */\nexport interface LocalShellOptions {\n /**\n * Optional execute function that handles shell command execution.\n * This function receives the action input and should return the command output\n * (stdout + stderr combined).\n *\n * If not provided, you'll need to handle action execution manually by\n * checking `local_shell_call` outputs in the response.\n *\n * @example\n * ```typescript\n * execute: async (action) => {\n * const result = await exec(action.command.join(' '), {\n * cwd: action.working_directory,\n * env: { ...process.env, ...action.env },\n * timeout: action.timeout_ms,\n * });\n * return result.stdout + result.stderr;\n * }\n * ```\n */\n execute: (action: LocalShellAction) => string | Promise<string>;\n}\n/**\n * OpenAI Local Shell tool type for the Responses API.\n */\nexport type LocalShellTool = OpenAIClient.Responses.Tool.LocalShell;\n/**\n * Creates a Local Shell tool that allows models to run shell commands locally\n * on a machine you provide. Commands are executed inside your own runtime—\n * the API only returns the instructions, but does not execute them on OpenAI infrastructure.\n *\n * **Important**: The local shell tool is designed to work with\n * [Codex CLI](https://github.com/openai/codex) and the `codex-mini-latest` model.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends shell commands (`local_shell_call` with `exec` action)\n * 2. Your code executes the command locally\n * 3. You return the output back to the model\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-local-shell | OpenAI Local Shell Documentation}\n *\n * @param options - Optional configuration for the Local Shell tool\n * @returns A Local 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\";\n * import { promisify } from \"util\";\n *\n * const execAsync = promisify(exec);\n * const model = new ChatOpenAI({ model: \"codex-mini-latest\" });\n *\n * // With execute callback for automatic command handling\n * const shell = tools.localShell({\n * execute: async (action) => {\n * const { command, env, working_directory, timeout_ms } = action;\n * const result = await execAsync(command.join(' '), {\n * cwd: working_directory ?? process.cwd(),\n * env: { ...process.env, ...env },\n * timeout: timeout_ms ?? undefined,\n * });\n * return result.stdout + result.stderr;\n * },\n * });\n *\n * const llmWithShell = model.bindTools([shell]);\n * const response = await llmWithShell.invoke(\n * \"List files in the current directory\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Without execute callback (manual handling)\n * const shell = tools.localShell();\n *\n * const response = await model.invoke(\"List files\", {\n * tools: [shell],\n * });\n *\n * // Access the shell call from the response\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"local_shell_call\"\n * );\n * if (shellCall) {\n * console.log(\"Command to execute:\", shellCall.action.command);\n * // Execute the command manually, then send back the output\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.localShell()],\n * });\n *\n * while (true) {\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"local_shell_call\"\n * );\n *\n * if (!shellCall) break;\n *\n * // Execute command (with proper sandboxing!)\n * const output = await executeCommand(shellCall.action);\n *\n * // Send output back to model\n * response = await model.invoke([\n * response,\n * {\n * type: \"local_shell_call_output\",\n * id: shellCall.call_id,\n * output: output,\n * },\n * ], {\n * tools: [tools.localShell()],\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 `codex-mini-latest` model\n * - Commands are provided as argv tokens in `action.command`\n * - Action includes: `command`, `env`, `working_directory`, `timeout_ms`, `user`\n * - Always sandbox or validate commands before execution\n * - The `timeout_ms` from the model is only a hint—enforce your own limits\n */\nexport declare function localShell(options: LocalShellOptions): DynamicStructuredTool<z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>]>, OpenAIClient.Responses.ResponseOutputItem.LocalShellCall.Action, unknown, string>;\n//# sourceMappingURL=localShell.d.ts.map"],"mappings":";;;;;;;;AAQA;AAoBA;AA0BA;AAmHwB0B,KAjKZtB,gBAAAA,GAAmBF,QAAAA,CAAaG,SAAAA,CAAUC,kBAAAA,CAAmBC,cAAAA,CAAeC,MAiKtD;;;;AAAmD,UA7IpEa,iBAAAA,CA6IoE;;;;;;;;;;;;;;;;;;;;;oBAxH/DjB,8BAA8BkB;;;;;KAKxCC,cAAAA,GAAiBrB,QAAAA,CAAaG,SAAAA,CAAUmB,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmHjCC,UAAAA,UAAoBL,oBAAoBlB,sBAAsBH,CAAAA,CAAEoB,uBAAuBpB,CAAAA,CAAEkB;QACvGlB,CAAAA,CAAEU;WACCV,CAAAA,CAAEY,SAASZ,CAAAA,CAAEW;OACjBX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEa,UAAUb,CAAAA,CAAEW,WAAWX,CAAAA,CAAEW;qBAC3BX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEW;cACvBX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEe;QACtBf,CAAAA,CAAEc,YAAYd,CAAAA,CAAEW;GACvBX,CAAAA,CAAEgB,IAAAA,CAAKC,WAAWf,QAAAA,CAAaG,SAAAA,CAAUC,kBAAAA,CAAmBC,cAAAA,CAAeC"}
1
+ {"version":3,"file":"localShell.d.ts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","LocalShellAction","Responses","ResponseOutputItem","LocalShellCall","Action","LocalShellExecActionSchema","ZodLiteral","ZodString","ZodArray","ZodRecord","ZodOptional","ZodNumber","core","$strip","ZodObject","LocalShellActionSchema","ZodDiscriminatedUnion","LocalShellOptions","Promise","LocalShellTool","Tool","LocalShell","localShell"],"sources":["../../src/tools/localShell.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\n/**\n * Re-export action type from OpenAI SDK for convenience.\n * The action contains command details like argv tokens, environment variables,\n * working directory, timeout, and user.\n */\nexport type LocalShellAction = OpenAIClient.Responses.ResponseOutputItem.LocalShellCall.Action;\nexport declare const LocalShellExecActionSchema: z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>;\nexport declare const LocalShellActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>]>;\n/**\n * Options for the Local Shell tool.\n */\nexport interface LocalShellOptions {\n /**\n * Optional execute function that handles shell command execution.\n * This function receives the action input and should return the command output\n * (stdout + stderr combined).\n *\n * If not provided, you'll need to handle action execution manually by\n * checking `local_shell_call` outputs in the response.\n *\n * @example\n * ```typescript\n * execute: async (action) => {\n * const result = await exec(action.command.join(' '), {\n * cwd: action.working_directory,\n * env: { ...process.env, ...action.env },\n * timeout: action.timeout_ms,\n * });\n * return result.stdout + result.stderr;\n * }\n * ```\n */\n execute: (action: LocalShellAction) => string | Promise<string>;\n}\n/**\n * OpenAI Local Shell tool type for the Responses API.\n */\nexport type LocalShellTool = OpenAIClient.Responses.Tool.LocalShell;\n/**\n * Creates a Local Shell tool that allows models to run shell commands locally\n * on a machine you provide. Commands are executed inside your own runtime—\n * the API only returns the instructions, but does not execute them on OpenAI infrastructure.\n *\n * **Important**: The local shell tool is designed to work with\n * [Codex CLI](https://github.com/openai/codex) and the `codex-mini-latest` model.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends shell commands (`local_shell_call` with `exec` action)\n * 2. Your code executes the command locally\n * 3. You return the output back to the model\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-local-shell | OpenAI Local Shell Documentation}\n *\n * @param options - Optional configuration for the Local Shell tool\n * @returns A Local 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\";\n * import { promisify } from \"util\";\n *\n * const execAsync = promisify(exec);\n * const model = new ChatOpenAI({ model: \"codex-mini-latest\" });\n *\n * // With execute callback for automatic command handling\n * const shell = tools.localShell({\n * execute: async (action) => {\n * const { command, env, working_directory, timeout_ms } = action;\n * const result = await execAsync(command.join(' '), {\n * cwd: working_directory ?? process.cwd(),\n * env: { ...process.env, ...env },\n * timeout: timeout_ms ?? undefined,\n * });\n * return result.stdout + result.stderr;\n * },\n * });\n *\n * const llmWithShell = model.bindTools([shell]);\n * const response = await llmWithShell.invoke(\n * \"List files in the current directory\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Without execute callback (manual handling)\n * const shell = tools.localShell();\n *\n * const response = await model.invoke(\"List files\", {\n * tools: [shell],\n * });\n *\n * // Access the shell call from the response\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"local_shell_call\"\n * );\n * if (shellCall) {\n * console.log(\"Command to execute:\", shellCall.action.command);\n * // Execute the command manually, then send back the output\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.localShell()],\n * });\n *\n * while (true) {\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"local_shell_call\"\n * );\n *\n * if (!shellCall) break;\n *\n * // Execute command (with proper sandboxing!)\n * const output = await executeCommand(shellCall.action);\n *\n * // Send output back to model\n * response = await model.invoke([\n * response,\n * {\n * type: \"local_shell_call_output\",\n * id: shellCall.call_id,\n * output: output,\n * },\n * ], {\n * tools: [tools.localShell()],\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 `codex-mini-latest` model\n * - Commands are provided as argv tokens in `action.command`\n * - Action includes: `command`, `env`, `working_directory`, `timeout_ms`, `user`\n * - Always sandbox or validate commands before execution\n * - The `timeout_ms` from the model is only a hint—enforce your own limits\n */\nexport declare function localShell(options: LocalShellOptions): DynamicStructuredTool<z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"exec\">;\n command: z.ZodArray<z.ZodString>;\n env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;\n working_directory: z.ZodOptional<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n user: z.ZodOptional<z.ZodString>;\n}, z.core.$strip>]>, OpenAIClient.Responses.ResponseOutputItem.LocalShellCall.Action, unknown, string, string>;\n//# sourceMappingURL=localShell.d.ts.map"],"mappings":";;;;;;;;AAQA;AAoBA;AA0BA;AAmHwB0B,KAjKZtB,gBAAAA,GAAmBF,QAAAA,CAAaG,SAAAA,CAAUC,kBAAAA,CAAmBC,cAAAA,CAAeC,MAiKtD;;;;AAAmD,UA7IpEa,iBAAAA,CA6IoE;;;;;;;;;;;;;;;;;;;;;oBAxH/DjB,8BAA8BkB;;;;;KAKxCC,cAAAA,GAAiBrB,QAAAA,CAAaG,SAAAA,CAAUmB,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmHjCC,UAAAA,UAAoBL,oBAAoBlB,sBAAsBH,CAAAA,CAAEoB,uBAAuBpB,CAAAA,CAAEkB;QACvGlB,CAAAA,CAAEU;WACCV,CAAAA,CAAEY,SAASZ,CAAAA,CAAEW;OACjBX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEa,UAAUb,CAAAA,CAAEW,WAAWX,CAAAA,CAAEW;qBAC3BX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEW;cACvBX,CAAAA,CAAEc,YAAYd,CAAAA,CAAEe;QACtBf,CAAAA,CAAEc,YAAYd,CAAAA,CAAEW;GACvBX,CAAAA,CAAEgB,IAAAA,CAAKC,WAAWf,QAAAA,CAAaG,SAAAA,CAAUC,kBAAAA,CAAmBC,cAAAA,CAAeC"}
@@ -215,7 +215,7 @@ declare function shell(options: ShellOptions): DynamicStructuredTool<z.ZodObject
215
215
  commands: z.ZodArray<z.ZodString>;
216
216
  timeout_ms: z.ZodOptional<z.ZodNumber>;
217
217
  max_output_length: z.ZodOptional<z.ZodNumber>;
218
- }, z.core.$strip>, OpenAI$1.Responses.ResponseFunctionShellToolCall.Action, unknown, string>;
218
+ }, z.core.$strip>, OpenAI$1.Responses.ResponseFunctionShellToolCall.Action, unknown, string, string>;
219
219
  //#endregion
220
220
  export { ShellAction, ShellCallOutcome, ShellCommandOutput, ShellOptions, ShellResult, ShellTool, shell };
221
221
  //# sourceMappingURL=shell.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.cts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","ShellAction","Responses","ResponseFunctionShellToolCall","Action","ShellActionSchema","ZodString","ZodArray","ZodNumber","ZodOptional","core","$strip","ZodObject","ShellCommandOutput","ResponseFunctionShellCallOutputContent","ShellCallOutcome","ShellResult","ShellOptions","Promise","ShellTool","FunctionShellTool","shell"],"sources":["../../src/tools/shell.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\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 = OpenAIClient.Responses.ResponseFunctionShellToolCall.Action;\nexport declare const ShellActionSchema: z.ZodObject<{\n commands: z.ZodArray<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n max_output_length: z.ZodOptional<z.ZodNumber>;\n}, z.core.$strip>;\n/**\n * Result of a single shell command execution.\n * Contains stdout, stderr, and the outcome (exit code or timeout).\n */\nexport type ShellCommandOutput = OpenAIClient.Responses.ResponseFunctionShellCallOutputContent;\n/**\n * Outcome type for shell command execution - either exit with code or timeout.\n */\nexport type ShellCallOutcome = ShellCommandOutput[\"outcome\"];\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 * 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 * OpenAI Shell tool type for the Responses API.\n */\nexport type ShellTool = OpenAIClient.Responses.FunctionShellTool;\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 declare function shell(options: ShellOptions): DynamicStructuredTool<z.ZodObject<{\n commands: z.ZodArray<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n max_output_length: z.ZodOptional<z.ZodNumber>;\n}, z.core.$strip>, OpenAIClient.Responses.ResponseFunctionShellToolCall.Action, unknown, string>;\n//# sourceMappingURL=shell.d.ts.map"],"mappings":";;;;;;;;AAOA;AAUA;AAIYkB,KAdAd,WAAAA,GAAcF,QAAAA,CAAaG,SAAAA,CAAUC,6BAAAA,CAA8BC,MAc9B;;AA2DU;AAK3D;AAkIA;AAAuCa,KAtM3BJ,kBAAAA,GAAqBd,QAAAA,CAAaG,SAAAA,CAAUY,sCAsMjBG;;;;AAErBR,KApMNM,gBAAAA,GAAmBF,kBAoMbJ,CAAAA,SAAAA,CAAAA;;;;;AAECV,UAjMFiB,WAAAA,CAiMyBb;EAJYH;AAAqB;;;UAxL/Da;;;;;;;;;;UAUKI,YAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAuCKhB,gBAAgBe,cAAcE,QAAQF;;;;;KAKhDG,SAAAA,GAAYpB,QAAAA,CAAaG,SAAAA,CAAUkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkIvBC,KAAAA,UAAeJ,eAAejB,sBAAsBH,CAAAA,CAAEe;YAChEf,CAAAA,CAAEU,SAASV,CAAAA,CAAES;cACXT,CAAAA,CAAEY,YAAYZ,CAAAA,CAAEW;qBACTX,CAAAA,CAAEY,YAAYZ,CAAAA,CAAEW;GACpCX,CAAAA,CAAEa,IAAAA,CAAKC,SAASZ,QAAAA,CAAaG,SAAAA,CAAUC,6BAAAA,CAA8BC"}
1
+ {"version":3,"file":"shell.d.cts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","ShellAction","Responses","ResponseFunctionShellToolCall","Action","ShellActionSchema","ZodString","ZodArray","ZodNumber","ZodOptional","core","$strip","ZodObject","ShellCommandOutput","ResponseFunctionShellCallOutputContent","ShellCallOutcome","ShellResult","ShellOptions","Promise","ShellTool","FunctionShellTool","shell"],"sources":["../../src/tools/shell.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\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 = OpenAIClient.Responses.ResponseFunctionShellToolCall.Action;\nexport declare const ShellActionSchema: z.ZodObject<{\n commands: z.ZodArray<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n max_output_length: z.ZodOptional<z.ZodNumber>;\n}, z.core.$strip>;\n/**\n * Result of a single shell command execution.\n * Contains stdout, stderr, and the outcome (exit code or timeout).\n */\nexport type ShellCommandOutput = OpenAIClient.Responses.ResponseFunctionShellCallOutputContent;\n/**\n * Outcome type for shell command execution - either exit with code or timeout.\n */\nexport type ShellCallOutcome = ShellCommandOutput[\"outcome\"];\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 * 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 * OpenAI Shell tool type for the Responses API.\n */\nexport type ShellTool = OpenAIClient.Responses.FunctionShellTool;\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 declare function shell(options: ShellOptions): DynamicStructuredTool<z.ZodObject<{\n commands: z.ZodArray<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n max_output_length: z.ZodOptional<z.ZodNumber>;\n}, z.core.$strip>, OpenAIClient.Responses.ResponseFunctionShellToolCall.Action, unknown, string, string>;\n//# sourceMappingURL=shell.d.ts.map"],"mappings":";;;;;;;;AAOA;AAUA;AAIYkB,KAdAd,WAAAA,GAAcF,QAAAA,CAAaG,SAAAA,CAAUC,6BAAAA,CAA8BC,MAc9B;;AA2DU;AAK3D;AAkIA;AAAuCa,KAtM3BJ,kBAAAA,GAAqBd,QAAAA,CAAaG,SAAAA,CAAUY,sCAsMjBG;;;;AAErBR,KApMNM,gBAAAA,GAAmBF,kBAoMbJ,CAAAA,SAAAA,CAAAA;;;;;AAECV,UAjMFiB,WAAAA,CAiMyBb;EAJYH;AAAqB;;;UAxL/Da;;;;;;;;;;UAUKI,YAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAuCKhB,gBAAgBe,cAAcE,QAAQF;;;;;KAKhDG,SAAAA,GAAYpB,QAAAA,CAAaG,SAAAA,CAAUkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkIvBC,KAAAA,UAAeJ,eAAejB,sBAAsBH,CAAAA,CAAEe;YAChEf,CAAAA,CAAEU,SAASV,CAAAA,CAAES;cACXT,CAAAA,CAAEY,YAAYZ,CAAAA,CAAEW;qBACTX,CAAAA,CAAEY,YAAYZ,CAAAA,CAAEW;GACpCX,CAAAA,CAAEa,IAAAA,CAAKC,SAASZ,QAAAA,CAAaG,SAAAA,CAAUC,6BAAAA,CAA8BC"}
@@ -215,7 +215,7 @@ declare function shell(options: ShellOptions): DynamicStructuredTool<z.ZodObject
215
215
  commands: z.ZodArray<z.ZodString>;
216
216
  timeout_ms: z.ZodOptional<z.ZodNumber>;
217
217
  max_output_length: z.ZodOptional<z.ZodNumber>;
218
- }, z.core.$strip>, OpenAI$1.Responses.ResponseFunctionShellToolCall.Action, unknown, string>;
218
+ }, z.core.$strip>, OpenAI$1.Responses.ResponseFunctionShellToolCall.Action, unknown, string, string>;
219
219
  //#endregion
220
220
  export { ShellAction, ShellCallOutcome, ShellCommandOutput, ShellOptions, ShellResult, ShellTool, shell };
221
221
  //# sourceMappingURL=shell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.ts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","ShellAction","Responses","ResponseFunctionShellToolCall","Action","ShellActionSchema","ZodString","ZodArray","ZodNumber","ZodOptional","core","$strip","ZodObject","ShellCommandOutput","ResponseFunctionShellCallOutputContent","ShellCallOutcome","ShellResult","ShellOptions","Promise","ShellTool","FunctionShellTool","shell"],"sources":["../../src/tools/shell.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\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 = OpenAIClient.Responses.ResponseFunctionShellToolCall.Action;\nexport declare const ShellActionSchema: z.ZodObject<{\n commands: z.ZodArray<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n max_output_length: z.ZodOptional<z.ZodNumber>;\n}, z.core.$strip>;\n/**\n * Result of a single shell command execution.\n * Contains stdout, stderr, and the outcome (exit code or timeout).\n */\nexport type ShellCommandOutput = OpenAIClient.Responses.ResponseFunctionShellCallOutputContent;\n/**\n * Outcome type for shell command execution - either exit with code or timeout.\n */\nexport type ShellCallOutcome = ShellCommandOutput[\"outcome\"];\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 * 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 * OpenAI Shell tool type for the Responses API.\n */\nexport type ShellTool = OpenAIClient.Responses.FunctionShellTool;\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 declare function shell(options: ShellOptions): DynamicStructuredTool<z.ZodObject<{\n commands: z.ZodArray<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n max_output_length: z.ZodOptional<z.ZodNumber>;\n}, z.core.$strip>, OpenAIClient.Responses.ResponseFunctionShellToolCall.Action, unknown, string>;\n//# sourceMappingURL=shell.d.ts.map"],"mappings":";;;;;;;;AAOA;AAUA;AAIYkB,KAdAd,WAAAA,GAAcF,QAAAA,CAAaG,SAAAA,CAAUC,6BAAAA,CAA8BC,MAc9B;;AA2DU;AAK3D;AAkIA;AAAuCa,KAtM3BJ,kBAAAA,GAAqBd,QAAAA,CAAaG,SAAAA,CAAUY,sCAsMjBG;;;;AAErBR,KApMNM,gBAAAA,GAAmBF,kBAoMbJ,CAAAA,SAAAA,CAAAA;;;;;AAECV,UAjMFiB,WAAAA,CAiMyBb;EAJYH;AAAqB;;;UAxL/Da;;;;;;;;;;UAUKI,YAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAuCKhB,gBAAgBe,cAAcE,QAAQF;;;;;KAKhDG,SAAAA,GAAYpB,QAAAA,CAAaG,SAAAA,CAAUkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkIvBC,KAAAA,UAAeJ,eAAejB,sBAAsBH,CAAAA,CAAEe;YAChEf,CAAAA,CAAEU,SAASV,CAAAA,CAAES;cACXT,CAAAA,CAAEY,YAAYZ,CAAAA,CAAEW;qBACTX,CAAAA,CAAEY,YAAYZ,CAAAA,CAAEW;GACpCX,CAAAA,CAAEa,IAAAA,CAAKC,SAASZ,QAAAA,CAAaG,SAAAA,CAAUC,6BAAAA,CAA8BC"}
1
+ {"version":3,"file":"shell.d.ts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","ShellAction","Responses","ResponseFunctionShellToolCall","Action","ShellActionSchema","ZodString","ZodArray","ZodNumber","ZodOptional","core","$strip","ZodObject","ShellCommandOutput","ResponseFunctionShellCallOutputContent","ShellCallOutcome","ShellResult","ShellOptions","Promise","ShellTool","FunctionShellTool","shell"],"sources":["../../src/tools/shell.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\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 = OpenAIClient.Responses.ResponseFunctionShellToolCall.Action;\nexport declare const ShellActionSchema: z.ZodObject<{\n commands: z.ZodArray<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n max_output_length: z.ZodOptional<z.ZodNumber>;\n}, z.core.$strip>;\n/**\n * Result of a single shell command execution.\n * Contains stdout, stderr, and the outcome (exit code or timeout).\n */\nexport type ShellCommandOutput = OpenAIClient.Responses.ResponseFunctionShellCallOutputContent;\n/**\n * Outcome type for shell command execution - either exit with code or timeout.\n */\nexport type ShellCallOutcome = ShellCommandOutput[\"outcome\"];\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 * 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 * OpenAI Shell tool type for the Responses API.\n */\nexport type ShellTool = OpenAIClient.Responses.FunctionShellTool;\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 declare function shell(options: ShellOptions): DynamicStructuredTool<z.ZodObject<{\n commands: z.ZodArray<z.ZodString>;\n timeout_ms: z.ZodOptional<z.ZodNumber>;\n max_output_length: z.ZodOptional<z.ZodNumber>;\n}, z.core.$strip>, OpenAIClient.Responses.ResponseFunctionShellToolCall.Action, unknown, string, string>;\n//# sourceMappingURL=shell.d.ts.map"],"mappings":";;;;;;;;AAOA;AAUA;AAIYkB,KAdAd,WAAAA,GAAcF,QAAAA,CAAaG,SAAAA,CAAUC,6BAAAA,CAA8BC,MAc9B;;AA2DU;AAK3D;AAkIA;AAAuCa,KAtM3BJ,kBAAAA,GAAqBd,QAAAA,CAAaG,SAAAA,CAAUY,sCAsMjBG;;;;AAErBR,KApMNM,gBAAAA,GAAmBF,kBAoMbJ,CAAAA,SAAAA,CAAAA;;;;;AAECV,UAjMFiB,WAAAA,CAiMyBb;EAJYH;AAAqB;;;UAxL/Da;;;;;;;;;;UAUKI,YAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAuCKhB,gBAAgBe,cAAcE,QAAQF;;;;;KAKhDG,SAAAA,GAAYpB,QAAAA,CAAaG,SAAAA,CAAUkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkIvBC,KAAAA,UAAeJ,eAAejB,sBAAsBH,CAAAA,CAAEe;YAChEf,CAAAA,CAAEU,SAASV,CAAAA,CAAES;cACXT,CAAAA,CAAEY,YAAYZ,CAAAA,CAAEW;qBACTX,CAAAA,CAAEY,YAAYZ,CAAAA,CAAEW;GACpCX,CAAAA,CAAEa,IAAAA,CAAKC,SAASZ,QAAAA,CAAaG,SAAAA,CAAUC,6BAAAA,CAA8BC"}
@@ -1 +1 @@
1
- {"version":3,"file":"output.cjs","names":["model: string","method: unknown","response_format: ResponseFormatJSONSchema","parser: (content: string) => ParsedT","zodSchema: InteropZodType","name: string","props: Omit<ResponseFormatJSONSchema.JSONSchema, \"schema\" | \"strict\" | \"name\">","content: string","messages: unknown"],"sources":["../../src/utils/output.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport {\n InteropZodType,\n isZodSchemaV3,\n isZodSchemaV4,\n} from \"@langchain/core/utils/types\";\nimport { parse as parseV4 } from \"zod/v4/core\";\nimport { ResponseFormatJSONSchema } from \"openai/resources\";\nimport { zodResponseFormat } from \"openai/helpers/zod\";\nimport { ContentBlock, UsageMetadata } from \"@langchain/core/messages\";\nimport { toJsonSchema } from \"@langchain/core/utils/json_schema\";\n\nconst SUPPORTED_METHODS = [\n \"jsonSchema\",\n \"functionCalling\",\n \"jsonMode\",\n] as const;\ntype SupportedMethod = (typeof SUPPORTED_METHODS)[number];\n\n/**\n * Get the structured output method for a given model. By default, it uses\n * `jsonSchema` if the model supports it, otherwise it uses `functionCalling`.\n *\n * @throws if the method is invalid, e.g. is not a string or invalid method is provided.\n * @param model - The model name.\n * @param config - The structured output method options.\n * @returns The structured output method.\n */\nexport function getStructuredOutputMethod(\n model: string,\n method: unknown\n): SupportedMethod {\n /**\n * If a method is provided, validate it.\n */\n if (\n typeof method !== \"undefined\" &&\n !SUPPORTED_METHODS.includes(method as SupportedMethod)\n ) {\n throw new Error(\n `Invalid method: ${method}. Supported methods are: ${SUPPORTED_METHODS.join(\n \", \"\n )}`\n );\n }\n\n const hasSupportForJsonSchema =\n !model.startsWith(\"gpt-3\") &&\n !model.startsWith(\"gpt-4-\") &&\n model !== \"gpt-4\";\n\n /**\n * If the model supports JSON Schema, use it by default.\n */\n if (hasSupportForJsonSchema && !method) {\n return \"jsonSchema\";\n }\n\n if (!hasSupportForJsonSchema && method === \"jsonSchema\") {\n throw new Error(\n `JSON Schema is not supported for model \"${model}\". Please use a different method, e.g. \"functionCalling\" or \"jsonMode\".`\n );\n }\n\n /**\n * If the model does not support JSON Schema, use function calling by default.\n */\n return (method as SupportedMethod) ?? \"functionCalling\";\n}\n\n// inlined from openai/lib/parser.ts\nfunction makeParseableResponseFormat<ParsedT>(\n response_format: ResponseFormatJSONSchema,\n parser: (content: string) => ParsedT\n) {\n const obj = { ...response_format };\n\n Object.defineProperties(obj, {\n $brand: {\n value: \"auto-parseable-response-format\",\n enumerable: false,\n },\n $parseRaw: {\n value: parser,\n enumerable: false,\n },\n });\n\n return obj;\n}\n\nexport function interopZodResponseFormat(\n zodSchema: InteropZodType,\n name: string,\n props: Omit<ResponseFormatJSONSchema.JSONSchema, \"schema\" | \"strict\" | \"name\">\n) {\n if (isZodSchemaV3(zodSchema)) {\n return zodResponseFormat(zodSchema, name, props);\n }\n if (isZodSchemaV4(zodSchema)) {\n return makeParseableResponseFormat(\n {\n type: \"json_schema\",\n json_schema: {\n ...props,\n name,\n strict: true,\n schema: toJsonSchema(zodSchema, {\n cycles: \"ref\", // equivalent to nameStrategy: 'duplicate-ref'\n reused: \"ref\", // equivalent to $refStrategy: 'extract-to-root'\n override(ctx) {\n ctx.jsonSchema.title = name; // equivalent to `name` property\n // TODO: implement `nullableStrategy` patch-fix (zod doesn't support openApi3 json schema target)\n // TODO: implement `openaiStrictMode` patch-fix (where optional properties without `nullable` are not supported)\n },\n /// property equivalents from native `zodResponseFormat` fn\n // openaiStrictMode: true,\n // name,\n // nameStrategy: 'duplicate-ref',\n // $refStrategy: 'extract-to-root',\n // nullableStrategy: 'property',\n }),\n },\n },\n (content) => parseV4(zodSchema, JSON.parse(content))\n );\n }\n throw new Error(\"Unsupported schema response format\");\n}\n\n/**\n * Handle multi modal response content.\n *\n * @param content The content of the message.\n * @param messages The messages of the response.\n * @returns The new content of the message.\n */\nexport function handleMultiModalOutput(\n content: string,\n messages: unknown\n): ContentBlock[] | string {\n /**\n * Handle OpenRouter image responses\n * @see https://openrouter.ai/docs/features/multimodal/image-generation#api-usage\n */\n if (\n messages &&\n typeof messages === \"object\" &&\n \"images\" in messages &&\n Array.isArray(messages.images)\n ) {\n const images = messages.images\n .filter((image) => typeof image?.image_url?.url === \"string\")\n .map(\n (image) =>\n ({\n type: \"image\",\n url: image.image_url.url as string,\n } as const)\n );\n return [{ type: \"text\", text: content }, ...images];\n }\n\n return content;\n}\n\n// TODO: make this a converter\nexport function _convertOpenAIResponsesUsageToLangChainUsage(\n usage?: OpenAIClient.Responses.ResponseUsage\n): UsageMetadata {\n const inputTokenDetails = {\n ...(usage?.input_tokens_details?.cached_tokens != null && {\n cache_read: usage?.input_tokens_details?.cached_tokens,\n }),\n };\n const outputTokenDetails = {\n ...(usage?.output_tokens_details?.reasoning_tokens != null && {\n reasoning: usage?.output_tokens_details?.reasoning_tokens,\n }),\n };\n return {\n input_tokens: usage?.input_tokens ?? 0,\n output_tokens: usage?.output_tokens ?? 0,\n total_tokens: usage?.total_tokens ?? 0,\n input_token_details: inputTokenDetails,\n output_token_details: outputTokenDetails,\n };\n}\n"],"mappings":";;;;;;;AAYA,MAAM,oBAAoB;CACxB;CACA;CACA;AACD;;;;;;;;;;AAYD,SAAgB,0BACdA,OACAC,QACiB;;;;AAIjB,KACE,OAAO,WAAW,eAClB,CAAC,kBAAkB,SAAS,OAA0B,CAEtD,OAAM,IAAI,MACR,CAAC,gBAAgB,EAAE,OAAO,yBAAyB,EAAE,kBAAkB,KACrE,KACD,EAAE;CAIP,MAAM,0BACJ,CAAC,MAAM,WAAW,QAAQ,IAC1B,CAAC,MAAM,WAAW,SAAS,IAC3B,UAAU;;;;AAKZ,KAAI,2BAA2B,CAAC,OAC9B,QAAO;AAGT,KAAI,CAAC,2BAA2B,WAAW,aACzC,OAAM,IAAI,MACR,CAAC,wCAAwC,EAAE,MAAM,uEAAuE,CAAC;;;;AAO7H,QAAQ,UAA8B;AACvC;AAGD,SAAS,4BACPC,iBACAC,QACA;CACA,MAAM,MAAM,EAAE,GAAG,gBAAiB;CAElC,OAAO,iBAAiB,KAAK;EAC3B,QAAQ;GACN,OAAO;GACP,YAAY;EACb;EACD,WAAW;GACT,OAAO;GACP,YAAY;EACb;CACF,EAAC;AAEF,QAAO;AACR;AAED,SAAgB,yBACdC,WACAC,MACAC,OACA;AACA,qDAAkB,UAAU,CAC1B,kDAAyB,WAAW,MAAM,MAAM;AAElD,qDAAkB,UAAU,CAC1B,QAAO,4BACL;EACE,MAAM;EACN,aAAa;GACX,GAAG;GACH;GACA,QAAQ;GACR,6DAAqB,WAAW;IAC9B,QAAQ;IACR,QAAQ;IACR,SAAS,KAAK;KACZ,IAAI,WAAW,QAAQ;IAGxB;GAOF,EAAC;EACH;CACF,GACD,CAAC,mCAAoB,WAAW,KAAK,MAAM,QAAQ,CAAC,CACrD;AAEH,OAAM,IAAI,MAAM;AACjB;;;;;;;;AASD,SAAgB,uBACdC,SACAC,UACyB;;;;;AAKzB,KACE,YACA,OAAO,aAAa,YACpB,YAAY,YACZ,MAAM,QAAQ,SAAS,OAAO,EAC9B;EACA,MAAM,SAAS,SAAS,OACrB,OAAO,CAAC,UAAU,OAAO,OAAO,WAAW,QAAQ,SAAS,CAC5D,IACC,CAAC,WACE;GACC,MAAM;GACN,KAAK,MAAM,UAAU;EACtB,GACJ;AACH,SAAO,CAAC;GAAE,MAAM;GAAQ,MAAM;EAAS,GAAE,GAAG,MAAO;CACpD;AAED,QAAO;AACR"}
1
+ {"version":3,"file":"output.cjs","names":["model: string","method: unknown","response_format: ResponseFormatJSONSchema","parser: (content: string) => ParsedT","zodSchema: InteropZodType","name: string","props: Omit<ResponseFormatJSONSchema.JSONSchema, \"schema\" | \"strict\" | \"name\">","content: string","messages: unknown"],"sources":["../../src/utils/output.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport {\n InteropZodType,\n isZodSchemaV3,\n isZodSchemaV4,\n} from \"@langchain/core/utils/types\";\nimport { parse as parseV4 } from \"zod/v4/core\";\nimport { ResponseFormatJSONSchema } from \"openai/resources\";\nimport { zodResponseFormat } from \"openai/helpers/zod\";\nimport { ContentBlock, UsageMetadata } from \"@langchain/core/messages\";\nimport { toJsonSchema } from \"@langchain/core/utils/json_schema\";\n\nconst SUPPORTED_METHODS = [\n \"jsonSchema\",\n \"functionCalling\",\n \"jsonMode\",\n] as const;\ntype SupportedMethod = (typeof SUPPORTED_METHODS)[number];\n\n/**\n * Get the structured output method for a given model. By default, it uses\n * `jsonSchema` if the model supports it, otherwise it uses `functionCalling`.\n *\n * @throws if the method is invalid, e.g. is not a string or invalid method is provided.\n * @param model - The model name.\n * @param config - The structured output method options.\n * @returns The structured output method.\n */\nexport function getStructuredOutputMethod(\n model: string,\n method: unknown\n): SupportedMethod {\n /**\n * If a method is provided, validate it.\n */\n if (\n typeof method !== \"undefined\" &&\n !SUPPORTED_METHODS.includes(method as SupportedMethod)\n ) {\n throw new Error(\n `Invalid method: ${method}. Supported methods are: ${SUPPORTED_METHODS.join(\n \", \"\n )}`\n );\n }\n\n const hasSupportForJsonSchema =\n !model.startsWith(\"gpt-3\") &&\n !model.startsWith(\"gpt-4-\") &&\n model !== \"gpt-4\";\n\n /**\n * If the model supports JSON Schema, use it by default.\n */\n if (hasSupportForJsonSchema && !method) {\n return \"jsonSchema\";\n }\n\n if (!hasSupportForJsonSchema && method === \"jsonSchema\") {\n throw new Error(\n `JSON Schema is not supported for model \"${model}\". Please use a different method, e.g. \"functionCalling\" or \"jsonMode\".`\n );\n }\n\n /**\n * If the model does not support JSON Schema, use function calling by default.\n */\n return (method as SupportedMethod) ?? \"functionCalling\";\n}\n\n// inlined from openai/lib/parser.ts\nfunction makeParseableResponseFormat<ParsedT>(\n response_format: ResponseFormatJSONSchema,\n parser: (content: string) => ParsedT\n) {\n const obj = { ...response_format };\n\n Object.defineProperties(obj, {\n $brand: {\n value: \"auto-parseable-response-format\",\n enumerable: false,\n },\n $parseRaw: {\n value: parser,\n enumerable: false,\n },\n });\n\n return obj;\n}\n\nexport function interopZodResponseFormat(\n zodSchema: InteropZodType,\n name: string,\n props: Omit<ResponseFormatJSONSchema.JSONSchema, \"schema\" | \"strict\" | \"name\">\n) {\n if (isZodSchemaV3(zodSchema)) {\n return zodResponseFormat(zodSchema, name, props);\n }\n if (isZodSchemaV4(zodSchema)) {\n return makeParseableResponseFormat(\n {\n type: \"json_schema\",\n json_schema: {\n ...props,\n name,\n strict: true,\n schema: toJsonSchema(zodSchema, {\n cycles: \"ref\", // equivalent to nameStrategy: 'duplicate-ref'\n reused: \"ref\", // equivalent to $refStrategy: 'extract-to-root'\n override(ctx) {\n ctx.jsonSchema.title = name; // equivalent to `name` property\n // TODO: implement `nullableStrategy` patch-fix (zod doesn't support openApi3 json schema target)\n // TODO: implement `openaiStrictMode` patch-fix (where optional properties without `nullable` are not supported)\n },\n /// property equivalents from native `zodResponseFormat` fn\n // openaiStrictMode: true,\n // name,\n // nameStrategy: 'duplicate-ref',\n // $refStrategy: 'extract-to-root',\n // nullableStrategy: 'property',\n }),\n },\n },\n (content) => parseV4(zodSchema, JSON.parse(content))\n );\n }\n throw new Error(\"Unsupported schema response format\");\n}\n\n/**\n * Handle multi modal response content.\n *\n * @param content The content of the message.\n * @param messages The messages of the response.\n * @returns The new content of the message.\n */\nexport function handleMultiModalOutput(\n content: string,\n messages: unknown\n): ContentBlock[] | string {\n /**\n * Handle OpenRouter image responses\n * @see https://openrouter.ai/docs/features/multimodal/image-generation#api-usage\n */\n if (\n messages &&\n typeof messages === \"object\" &&\n \"images\" in messages &&\n Array.isArray(messages.images)\n ) {\n const images = messages.images\n .filter((image) => typeof image?.image_url?.url === \"string\")\n .map(\n (image) =>\n ({\n type: \"image\",\n url: image.image_url.url as string,\n }) as const\n );\n return [{ type: \"text\", text: content }, ...images];\n }\n\n return content;\n}\n\n// TODO: make this a converter\nexport function _convertOpenAIResponsesUsageToLangChainUsage(\n usage?: OpenAIClient.Responses.ResponseUsage\n): UsageMetadata {\n const inputTokenDetails = {\n ...(usage?.input_tokens_details?.cached_tokens != null && {\n cache_read: usage?.input_tokens_details?.cached_tokens,\n }),\n };\n const outputTokenDetails = {\n ...(usage?.output_tokens_details?.reasoning_tokens != null && {\n reasoning: usage?.output_tokens_details?.reasoning_tokens,\n }),\n };\n return {\n input_tokens: usage?.input_tokens ?? 0,\n output_tokens: usage?.output_tokens ?? 0,\n total_tokens: usage?.total_tokens ?? 0,\n input_token_details: inputTokenDetails,\n output_token_details: outputTokenDetails,\n };\n}\n"],"mappings":";;;;;;;AAYA,MAAM,oBAAoB;CACxB;CACA;CACA;AACD;;;;;;;;;;AAYD,SAAgB,0BACdA,OACAC,QACiB;;;;AAIjB,KACE,OAAO,WAAW,eAClB,CAAC,kBAAkB,SAAS,OAA0B,CAEtD,OAAM,IAAI,MACR,CAAC,gBAAgB,EAAE,OAAO,yBAAyB,EAAE,kBAAkB,KACrE,KACD,EAAE;CAIP,MAAM,0BACJ,CAAC,MAAM,WAAW,QAAQ,IAC1B,CAAC,MAAM,WAAW,SAAS,IAC3B,UAAU;;;;AAKZ,KAAI,2BAA2B,CAAC,OAC9B,QAAO;AAGT,KAAI,CAAC,2BAA2B,WAAW,aACzC,OAAM,IAAI,MACR,CAAC,wCAAwC,EAAE,MAAM,uEAAuE,CAAC;;;;AAO7H,QAAQ,UAA8B;AACvC;AAGD,SAAS,4BACPC,iBACAC,QACA;CACA,MAAM,MAAM,EAAE,GAAG,gBAAiB;CAElC,OAAO,iBAAiB,KAAK;EAC3B,QAAQ;GACN,OAAO;GACP,YAAY;EACb;EACD,WAAW;GACT,OAAO;GACP,YAAY;EACb;CACF,EAAC;AAEF,QAAO;AACR;AAED,SAAgB,yBACdC,WACAC,MACAC,OACA;AACA,qDAAkB,UAAU,CAC1B,kDAAyB,WAAW,MAAM,MAAM;AAElD,qDAAkB,UAAU,CAC1B,QAAO,4BACL;EACE,MAAM;EACN,aAAa;GACX,GAAG;GACH;GACA,QAAQ;GACR,6DAAqB,WAAW;IAC9B,QAAQ;IACR,QAAQ;IACR,SAAS,KAAK;KACZ,IAAI,WAAW,QAAQ;IAGxB;GAOF,EAAC;EACH;CACF,GACD,CAAC,mCAAoB,WAAW,KAAK,MAAM,QAAQ,CAAC,CACrD;AAEH,OAAM,IAAI,MAAM;AACjB;;;;;;;;AASD,SAAgB,uBACdC,SACAC,UACyB;;;;;AAKzB,KACE,YACA,OAAO,aAAa,YACpB,YAAY,YACZ,MAAM,QAAQ,SAAS,OAAO,EAC9B;EACA,MAAM,SAAS,SAAS,OACrB,OAAO,CAAC,UAAU,OAAO,OAAO,WAAW,QAAQ,SAAS,CAC5D,IACC,CAAC,WACE;GACC,MAAM;GACN,KAAK,MAAM,UAAU;EACtB,GACJ;AACH,SAAO,CAAC;GAAE,MAAM;GAAQ,MAAM;EAAS,GAAE,GAAG,MAAO;CACpD;AAED,QAAO;AACR"}
@@ -1 +1 @@
1
- {"version":3,"file":"output.js","names":["model: string","method: unknown","response_format: ResponseFormatJSONSchema","parser: (content: string) => ParsedT","zodSchema: InteropZodType","name: string","props: Omit<ResponseFormatJSONSchema.JSONSchema, \"schema\" | \"strict\" | \"name\">","parseV4","content: string","messages: unknown"],"sources":["../../src/utils/output.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport {\n InteropZodType,\n isZodSchemaV3,\n isZodSchemaV4,\n} from \"@langchain/core/utils/types\";\nimport { parse as parseV4 } from \"zod/v4/core\";\nimport { ResponseFormatJSONSchema } from \"openai/resources\";\nimport { zodResponseFormat } from \"openai/helpers/zod\";\nimport { ContentBlock, UsageMetadata } from \"@langchain/core/messages\";\nimport { toJsonSchema } from \"@langchain/core/utils/json_schema\";\n\nconst SUPPORTED_METHODS = [\n \"jsonSchema\",\n \"functionCalling\",\n \"jsonMode\",\n] as const;\ntype SupportedMethod = (typeof SUPPORTED_METHODS)[number];\n\n/**\n * Get the structured output method for a given model. By default, it uses\n * `jsonSchema` if the model supports it, otherwise it uses `functionCalling`.\n *\n * @throws if the method is invalid, e.g. is not a string or invalid method is provided.\n * @param model - The model name.\n * @param config - The structured output method options.\n * @returns The structured output method.\n */\nexport function getStructuredOutputMethod(\n model: string,\n method: unknown\n): SupportedMethod {\n /**\n * If a method is provided, validate it.\n */\n if (\n typeof method !== \"undefined\" &&\n !SUPPORTED_METHODS.includes(method as SupportedMethod)\n ) {\n throw new Error(\n `Invalid method: ${method}. Supported methods are: ${SUPPORTED_METHODS.join(\n \", \"\n )}`\n );\n }\n\n const hasSupportForJsonSchema =\n !model.startsWith(\"gpt-3\") &&\n !model.startsWith(\"gpt-4-\") &&\n model !== \"gpt-4\";\n\n /**\n * If the model supports JSON Schema, use it by default.\n */\n if (hasSupportForJsonSchema && !method) {\n return \"jsonSchema\";\n }\n\n if (!hasSupportForJsonSchema && method === \"jsonSchema\") {\n throw new Error(\n `JSON Schema is not supported for model \"${model}\". Please use a different method, e.g. \"functionCalling\" or \"jsonMode\".`\n );\n }\n\n /**\n * If the model does not support JSON Schema, use function calling by default.\n */\n return (method as SupportedMethod) ?? \"functionCalling\";\n}\n\n// inlined from openai/lib/parser.ts\nfunction makeParseableResponseFormat<ParsedT>(\n response_format: ResponseFormatJSONSchema,\n parser: (content: string) => ParsedT\n) {\n const obj = { ...response_format };\n\n Object.defineProperties(obj, {\n $brand: {\n value: \"auto-parseable-response-format\",\n enumerable: false,\n },\n $parseRaw: {\n value: parser,\n enumerable: false,\n },\n });\n\n return obj;\n}\n\nexport function interopZodResponseFormat(\n zodSchema: InteropZodType,\n name: string,\n props: Omit<ResponseFormatJSONSchema.JSONSchema, \"schema\" | \"strict\" | \"name\">\n) {\n if (isZodSchemaV3(zodSchema)) {\n return zodResponseFormat(zodSchema, name, props);\n }\n if (isZodSchemaV4(zodSchema)) {\n return makeParseableResponseFormat(\n {\n type: \"json_schema\",\n json_schema: {\n ...props,\n name,\n strict: true,\n schema: toJsonSchema(zodSchema, {\n cycles: \"ref\", // equivalent to nameStrategy: 'duplicate-ref'\n reused: \"ref\", // equivalent to $refStrategy: 'extract-to-root'\n override(ctx) {\n ctx.jsonSchema.title = name; // equivalent to `name` property\n // TODO: implement `nullableStrategy` patch-fix (zod doesn't support openApi3 json schema target)\n // TODO: implement `openaiStrictMode` patch-fix (where optional properties without `nullable` are not supported)\n },\n /// property equivalents from native `zodResponseFormat` fn\n // openaiStrictMode: true,\n // name,\n // nameStrategy: 'duplicate-ref',\n // $refStrategy: 'extract-to-root',\n // nullableStrategy: 'property',\n }),\n },\n },\n (content) => parseV4(zodSchema, JSON.parse(content))\n );\n }\n throw new Error(\"Unsupported schema response format\");\n}\n\n/**\n * Handle multi modal response content.\n *\n * @param content The content of the message.\n * @param messages The messages of the response.\n * @returns The new content of the message.\n */\nexport function handleMultiModalOutput(\n content: string,\n messages: unknown\n): ContentBlock[] | string {\n /**\n * Handle OpenRouter image responses\n * @see https://openrouter.ai/docs/features/multimodal/image-generation#api-usage\n */\n if (\n messages &&\n typeof messages === \"object\" &&\n \"images\" in messages &&\n Array.isArray(messages.images)\n ) {\n const images = messages.images\n .filter((image) => typeof image?.image_url?.url === \"string\")\n .map(\n (image) =>\n ({\n type: \"image\",\n url: image.image_url.url as string,\n } as const)\n );\n return [{ type: \"text\", text: content }, ...images];\n }\n\n return content;\n}\n\n// TODO: make this a converter\nexport function _convertOpenAIResponsesUsageToLangChainUsage(\n usage?: OpenAIClient.Responses.ResponseUsage\n): UsageMetadata {\n const inputTokenDetails = {\n ...(usage?.input_tokens_details?.cached_tokens != null && {\n cache_read: usage?.input_tokens_details?.cached_tokens,\n }),\n };\n const outputTokenDetails = {\n ...(usage?.output_tokens_details?.reasoning_tokens != null && {\n reasoning: usage?.output_tokens_details?.reasoning_tokens,\n }),\n };\n return {\n input_tokens: usage?.input_tokens ?? 0,\n output_tokens: usage?.output_tokens ?? 0,\n total_tokens: usage?.total_tokens ?? 0,\n input_token_details: inputTokenDetails,\n output_token_details: outputTokenDetails,\n };\n}\n"],"mappings":";;;;;;AAYA,MAAM,oBAAoB;CACxB;CACA;CACA;AACD;;;;;;;;;;AAYD,SAAgB,0BACdA,OACAC,QACiB;;;;AAIjB,KACE,OAAO,WAAW,eAClB,CAAC,kBAAkB,SAAS,OAA0B,CAEtD,OAAM,IAAI,MACR,CAAC,gBAAgB,EAAE,OAAO,yBAAyB,EAAE,kBAAkB,KACrE,KACD,EAAE;CAIP,MAAM,0BACJ,CAAC,MAAM,WAAW,QAAQ,IAC1B,CAAC,MAAM,WAAW,SAAS,IAC3B,UAAU;;;;AAKZ,KAAI,2BAA2B,CAAC,OAC9B,QAAO;AAGT,KAAI,CAAC,2BAA2B,WAAW,aACzC,OAAM,IAAI,MACR,CAAC,wCAAwC,EAAE,MAAM,uEAAuE,CAAC;;;;AAO7H,QAAQ,UAA8B;AACvC;AAGD,SAAS,4BACPC,iBACAC,QACA;CACA,MAAM,MAAM,EAAE,GAAG,gBAAiB;CAElC,OAAO,iBAAiB,KAAK;EAC3B,QAAQ;GACN,OAAO;GACP,YAAY;EACb;EACD,WAAW;GACT,OAAO;GACP,YAAY;EACb;CACF,EAAC;AAEF,QAAO;AACR;AAED,SAAgB,yBACdC,WACAC,MACAC,OACA;AACA,KAAI,cAAc,UAAU,CAC1B,QAAO,kBAAkB,WAAW,MAAM,MAAM;AAElD,KAAI,cAAc,UAAU,CAC1B,QAAO,4BACL;EACE,MAAM;EACN,aAAa;GACX,GAAG;GACH;GACA,QAAQ;GACR,QAAQ,aAAa,WAAW;IAC9B,QAAQ;IACR,QAAQ;IACR,SAAS,KAAK;KACZ,IAAI,WAAW,QAAQ;IAGxB;GAOF,EAAC;EACH;CACF,GACD,CAAC,YAAYC,MAAQ,WAAW,KAAK,MAAM,QAAQ,CAAC,CACrD;AAEH,OAAM,IAAI,MAAM;AACjB;;;;;;;;AASD,SAAgB,uBACdC,SACAC,UACyB;;;;;AAKzB,KACE,YACA,OAAO,aAAa,YACpB,YAAY,YACZ,MAAM,QAAQ,SAAS,OAAO,EAC9B;EACA,MAAM,SAAS,SAAS,OACrB,OAAO,CAAC,UAAU,OAAO,OAAO,WAAW,QAAQ,SAAS,CAC5D,IACC,CAAC,WACE;GACC,MAAM;GACN,KAAK,MAAM,UAAU;EACtB,GACJ;AACH,SAAO,CAAC;GAAE,MAAM;GAAQ,MAAM;EAAS,GAAE,GAAG,MAAO;CACpD;AAED,QAAO;AACR"}
1
+ {"version":3,"file":"output.js","names":["model: string","method: unknown","response_format: ResponseFormatJSONSchema","parser: (content: string) => ParsedT","zodSchema: InteropZodType","name: string","props: Omit<ResponseFormatJSONSchema.JSONSchema, \"schema\" | \"strict\" | \"name\">","parseV4","content: string","messages: unknown"],"sources":["../../src/utils/output.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport {\n InteropZodType,\n isZodSchemaV3,\n isZodSchemaV4,\n} from \"@langchain/core/utils/types\";\nimport { parse as parseV4 } from \"zod/v4/core\";\nimport { ResponseFormatJSONSchema } from \"openai/resources\";\nimport { zodResponseFormat } from \"openai/helpers/zod\";\nimport { ContentBlock, UsageMetadata } from \"@langchain/core/messages\";\nimport { toJsonSchema } from \"@langchain/core/utils/json_schema\";\n\nconst SUPPORTED_METHODS = [\n \"jsonSchema\",\n \"functionCalling\",\n \"jsonMode\",\n] as const;\ntype SupportedMethod = (typeof SUPPORTED_METHODS)[number];\n\n/**\n * Get the structured output method for a given model. By default, it uses\n * `jsonSchema` if the model supports it, otherwise it uses `functionCalling`.\n *\n * @throws if the method is invalid, e.g. is not a string or invalid method is provided.\n * @param model - The model name.\n * @param config - The structured output method options.\n * @returns The structured output method.\n */\nexport function getStructuredOutputMethod(\n model: string,\n method: unknown\n): SupportedMethod {\n /**\n * If a method is provided, validate it.\n */\n if (\n typeof method !== \"undefined\" &&\n !SUPPORTED_METHODS.includes(method as SupportedMethod)\n ) {\n throw new Error(\n `Invalid method: ${method}. Supported methods are: ${SUPPORTED_METHODS.join(\n \", \"\n )}`\n );\n }\n\n const hasSupportForJsonSchema =\n !model.startsWith(\"gpt-3\") &&\n !model.startsWith(\"gpt-4-\") &&\n model !== \"gpt-4\";\n\n /**\n * If the model supports JSON Schema, use it by default.\n */\n if (hasSupportForJsonSchema && !method) {\n return \"jsonSchema\";\n }\n\n if (!hasSupportForJsonSchema && method === \"jsonSchema\") {\n throw new Error(\n `JSON Schema is not supported for model \"${model}\". Please use a different method, e.g. \"functionCalling\" or \"jsonMode\".`\n );\n }\n\n /**\n * If the model does not support JSON Schema, use function calling by default.\n */\n return (method as SupportedMethod) ?? \"functionCalling\";\n}\n\n// inlined from openai/lib/parser.ts\nfunction makeParseableResponseFormat<ParsedT>(\n response_format: ResponseFormatJSONSchema,\n parser: (content: string) => ParsedT\n) {\n const obj = { ...response_format };\n\n Object.defineProperties(obj, {\n $brand: {\n value: \"auto-parseable-response-format\",\n enumerable: false,\n },\n $parseRaw: {\n value: parser,\n enumerable: false,\n },\n });\n\n return obj;\n}\n\nexport function interopZodResponseFormat(\n zodSchema: InteropZodType,\n name: string,\n props: Omit<ResponseFormatJSONSchema.JSONSchema, \"schema\" | \"strict\" | \"name\">\n) {\n if (isZodSchemaV3(zodSchema)) {\n return zodResponseFormat(zodSchema, name, props);\n }\n if (isZodSchemaV4(zodSchema)) {\n return makeParseableResponseFormat(\n {\n type: \"json_schema\",\n json_schema: {\n ...props,\n name,\n strict: true,\n schema: toJsonSchema(zodSchema, {\n cycles: \"ref\", // equivalent to nameStrategy: 'duplicate-ref'\n reused: \"ref\", // equivalent to $refStrategy: 'extract-to-root'\n override(ctx) {\n ctx.jsonSchema.title = name; // equivalent to `name` property\n // TODO: implement `nullableStrategy` patch-fix (zod doesn't support openApi3 json schema target)\n // TODO: implement `openaiStrictMode` patch-fix (where optional properties without `nullable` are not supported)\n },\n /// property equivalents from native `zodResponseFormat` fn\n // openaiStrictMode: true,\n // name,\n // nameStrategy: 'duplicate-ref',\n // $refStrategy: 'extract-to-root',\n // nullableStrategy: 'property',\n }),\n },\n },\n (content) => parseV4(zodSchema, JSON.parse(content))\n );\n }\n throw new Error(\"Unsupported schema response format\");\n}\n\n/**\n * Handle multi modal response content.\n *\n * @param content The content of the message.\n * @param messages The messages of the response.\n * @returns The new content of the message.\n */\nexport function handleMultiModalOutput(\n content: string,\n messages: unknown\n): ContentBlock[] | string {\n /**\n * Handle OpenRouter image responses\n * @see https://openrouter.ai/docs/features/multimodal/image-generation#api-usage\n */\n if (\n messages &&\n typeof messages === \"object\" &&\n \"images\" in messages &&\n Array.isArray(messages.images)\n ) {\n const images = messages.images\n .filter((image) => typeof image?.image_url?.url === \"string\")\n .map(\n (image) =>\n ({\n type: \"image\",\n url: image.image_url.url as string,\n }) as const\n );\n return [{ type: \"text\", text: content }, ...images];\n }\n\n return content;\n}\n\n// TODO: make this a converter\nexport function _convertOpenAIResponsesUsageToLangChainUsage(\n usage?: OpenAIClient.Responses.ResponseUsage\n): UsageMetadata {\n const inputTokenDetails = {\n ...(usage?.input_tokens_details?.cached_tokens != null && {\n cache_read: usage?.input_tokens_details?.cached_tokens,\n }),\n };\n const outputTokenDetails = {\n ...(usage?.output_tokens_details?.reasoning_tokens != null && {\n reasoning: usage?.output_tokens_details?.reasoning_tokens,\n }),\n };\n return {\n input_tokens: usage?.input_tokens ?? 0,\n output_tokens: usage?.output_tokens ?? 0,\n total_tokens: usage?.total_tokens ?? 0,\n input_token_details: inputTokenDetails,\n output_token_details: outputTokenDetails,\n };\n}\n"],"mappings":";;;;;;AAYA,MAAM,oBAAoB;CACxB;CACA;CACA;AACD;;;;;;;;;;AAYD,SAAgB,0BACdA,OACAC,QACiB;;;;AAIjB,KACE,OAAO,WAAW,eAClB,CAAC,kBAAkB,SAAS,OAA0B,CAEtD,OAAM,IAAI,MACR,CAAC,gBAAgB,EAAE,OAAO,yBAAyB,EAAE,kBAAkB,KACrE,KACD,EAAE;CAIP,MAAM,0BACJ,CAAC,MAAM,WAAW,QAAQ,IAC1B,CAAC,MAAM,WAAW,SAAS,IAC3B,UAAU;;;;AAKZ,KAAI,2BAA2B,CAAC,OAC9B,QAAO;AAGT,KAAI,CAAC,2BAA2B,WAAW,aACzC,OAAM,IAAI,MACR,CAAC,wCAAwC,EAAE,MAAM,uEAAuE,CAAC;;;;AAO7H,QAAQ,UAA8B;AACvC;AAGD,SAAS,4BACPC,iBACAC,QACA;CACA,MAAM,MAAM,EAAE,GAAG,gBAAiB;CAElC,OAAO,iBAAiB,KAAK;EAC3B,QAAQ;GACN,OAAO;GACP,YAAY;EACb;EACD,WAAW;GACT,OAAO;GACP,YAAY;EACb;CACF,EAAC;AAEF,QAAO;AACR;AAED,SAAgB,yBACdC,WACAC,MACAC,OACA;AACA,KAAI,cAAc,UAAU,CAC1B,QAAO,kBAAkB,WAAW,MAAM,MAAM;AAElD,KAAI,cAAc,UAAU,CAC1B,QAAO,4BACL;EACE,MAAM;EACN,aAAa;GACX,GAAG;GACH;GACA,QAAQ;GACR,QAAQ,aAAa,WAAW;IAC9B,QAAQ;IACR,QAAQ;IACR,SAAS,KAAK;KACZ,IAAI,WAAW,QAAQ;IAGxB;GAOF,EAAC;EACH;CACF,GACD,CAAC,YAAYC,MAAQ,WAAW,KAAK,MAAM,QAAQ,CAAC,CACrD;AAEH,OAAM,IAAI,MAAM;AACjB;;;;;;;;AASD,SAAgB,uBACdC,SACAC,UACyB;;;;;AAKzB,KACE,YACA,OAAO,aAAa,YACpB,YAAY,YACZ,MAAM,QAAQ,SAAS,OAAO,EAC9B;EACA,MAAM,SAAS,SAAS,OACrB,OAAO,CAAC,UAAU,OAAO,OAAO,WAAW,QAAQ,SAAS,CAC5D,IACC,CAAC,WACE;GACC,MAAM;GACN,KAAK,MAAM,UAAU;EACtB,GACJ;AACH,SAAO,CAAC;GAAE,MAAM;GAAQ,MAAM;EAAS,GAAE,GAAG,MAAO;CACpD;AAED,QAAO;AACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/openai",
3
- "version": "1.2.1",
3
+ "version": "1.2.3-dev-1768440391024",
4
4
  "description": "OpenAI integrations for LangChain.js",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -30,15 +30,15 @@
30
30
  "dotenv": "^17.2.1",
31
31
  "dpdm": "^3.14.0",
32
32
  "eslint": "^9.34.0",
33
- "prettier": "^2.8.3",
33
+ "prettier": "^3.5.0",
34
34
  "rimraf": "^5.0.1",
35
35
  "typescript": "~5.8.3",
36
36
  "uuid": "^11.1.0",
37
37
  "vitest": "^3.2.4",
38
38
  "zod-to-json-schema": "^3.24.6",
39
- "@langchain/core": "1.1.9",
39
+ "@langchain/core": "1.1.15",
40
40
  "@langchain/eslint": "0.1.1",
41
- "@langchain/standard-tests": "0.0.12",
41
+ "@langchain/standard-tests": "0.0.18",
42
42
  "@langchain/tsconfig": "0.0.1"
43
43
  },
44
44
  "publishConfig": {