@langchain/openai 1.5.5 → 1.5.6

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 (228) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/azure/chat_models/common.cjs.map +1 -1
  3. package/dist/azure/chat_models/common.d.cts +1 -1
  4. package/dist/azure/chat_models/common.d.cts.map +1 -1
  5. package/dist/azure/chat_models/common.d.ts +1 -1
  6. package/dist/azure/chat_models/common.d.ts.map +1 -1
  7. package/dist/azure/chat_models/common.js.map +1 -1
  8. package/dist/azure/chat_models/completions.cjs.map +1 -1
  9. package/dist/azure/chat_models/completions.d.cts +0 -1
  10. package/dist/azure/chat_models/completions.d.cts.map +1 -1
  11. package/dist/azure/chat_models/completions.d.ts +0 -1
  12. package/dist/azure/chat_models/completions.d.ts.map +1 -1
  13. package/dist/azure/chat_models/completions.js.map +1 -1
  14. package/dist/azure/chat_models/index.cjs.map +1 -1
  15. package/dist/azure/chat_models/index.d.cts +1 -2
  16. package/dist/azure/chat_models/index.d.cts.map +1 -1
  17. package/dist/azure/chat_models/index.d.ts +0 -1
  18. package/dist/azure/chat_models/index.d.ts.map +1 -1
  19. package/dist/azure/chat_models/index.js.map +1 -1
  20. package/dist/azure/chat_models/responses.cjs.map +1 -1
  21. package/dist/azure/chat_models/responses.d.cts +0 -1
  22. package/dist/azure/chat_models/responses.d.cts.map +1 -1
  23. package/dist/azure/chat_models/responses.d.ts +0 -1
  24. package/dist/azure/chat_models/responses.d.ts.map +1 -1
  25. package/dist/azure/chat_models/responses.js.map +1 -1
  26. package/dist/azure/embeddings.cjs.map +1 -1
  27. package/dist/azure/embeddings.d.cts +2 -2
  28. package/dist/azure/embeddings.d.cts.map +1 -1
  29. package/dist/azure/embeddings.d.ts +2 -2
  30. package/dist/azure/embeddings.d.ts.map +1 -1
  31. package/dist/azure/embeddings.js.map +1 -1
  32. package/dist/azure/llms.cjs.map +1 -1
  33. package/dist/azure/llms.d.cts +0 -1
  34. package/dist/azure/llms.d.cts.map +1 -1
  35. package/dist/azure/llms.d.ts +0 -1
  36. package/dist/azure/llms.d.ts.map +1 -1
  37. package/dist/azure/llms.js.map +1 -1
  38. package/dist/chat_models/base.cjs +37 -3
  39. package/dist/chat_models/base.cjs.map +1 -1
  40. package/dist/chat_models/base.d.cts +6 -7
  41. package/dist/chat_models/base.d.cts.map +1 -1
  42. package/dist/chat_models/base.d.ts +5 -6
  43. package/dist/chat_models/base.d.ts.map +1 -1
  44. package/dist/chat_models/base.js +37 -3
  45. package/dist/chat_models/base.js.map +1 -1
  46. package/dist/chat_models/completions.cjs.map +1 -1
  47. package/dist/chat_models/completions.d.cts +0 -1
  48. package/dist/chat_models/completions.d.cts.map +1 -1
  49. package/dist/chat_models/completions.d.ts +0 -1
  50. package/dist/chat_models/completions.d.ts.map +1 -1
  51. package/dist/chat_models/completions.js.map +1 -1
  52. package/dist/chat_models/index.cjs.map +1 -1
  53. package/dist/chat_models/index.d.cts +14 -17
  54. package/dist/chat_models/index.d.cts.map +1 -1
  55. package/dist/chat_models/index.d.ts +14 -17
  56. package/dist/chat_models/index.d.ts.map +1 -1
  57. package/dist/chat_models/index.js.map +1 -1
  58. package/dist/chat_models/profiles.cjs.map +1 -1
  59. package/dist/chat_models/profiles.js.map +1 -1
  60. package/dist/chat_models/responses.cjs.map +1 -1
  61. package/dist/chat_models/responses.d.cts +0 -1
  62. package/dist/chat_models/responses.d.cts.map +1 -1
  63. package/dist/chat_models/responses.d.ts +0 -1
  64. package/dist/chat_models/responses.d.ts.map +1 -1
  65. package/dist/chat_models/responses.js.map +1 -1
  66. package/dist/converters/completions.cjs.map +1 -1
  67. package/dist/converters/completions.d.cts +0 -1
  68. package/dist/converters/completions.d.cts.map +1 -1
  69. package/dist/converters/completions.d.ts +0 -1
  70. package/dist/converters/completions.d.ts.map +1 -1
  71. package/dist/converters/completions.js.map +1 -1
  72. package/dist/converters/index.cjs +14 -2
  73. package/dist/converters/index.d.cts +2 -1
  74. package/dist/converters/index.d.ts +2 -1
  75. package/dist/converters/index.js +3 -3
  76. package/dist/converters/responses.cjs.map +1 -1
  77. package/dist/converters/responses.d.cts +0 -1
  78. package/dist/converters/responses.d.cts.map +1 -1
  79. package/dist/converters/responses.d.ts +0 -1
  80. package/dist/converters/responses.d.ts.map +1 -1
  81. package/dist/converters/responses.js.map +1 -1
  82. package/dist/embeddings.cjs.map +1 -1
  83. package/dist/embeddings.d.cts +2 -2
  84. package/dist/embeddings.d.cts.map +1 -1
  85. package/dist/embeddings.d.ts +2 -2
  86. package/dist/embeddings.d.ts.map +1 -1
  87. package/dist/embeddings.js.map +1 -1
  88. package/dist/index.d.cts +2 -1
  89. package/dist/index.d.ts +2 -1
  90. package/dist/llms.cjs +1 -1
  91. package/dist/llms.cjs.map +1 -1
  92. package/dist/llms.d.cts +1 -2
  93. package/dist/llms.d.cts.map +1 -1
  94. package/dist/llms.d.ts +1 -2
  95. package/dist/llms.d.ts.map +1 -1
  96. package/dist/llms.js +1 -1
  97. package/dist/llms.js.map +1 -1
  98. package/dist/tools/applyPatch.cjs +4 -0
  99. package/dist/tools/applyPatch.cjs.map +1 -1
  100. package/dist/tools/applyPatch.d.cts +1 -2
  101. package/dist/tools/applyPatch.d.cts.map +1 -1
  102. package/dist/tools/applyPatch.d.ts +1 -2
  103. package/dist/tools/applyPatch.d.ts.map +1 -1
  104. package/dist/tools/applyPatch.js +1 -1
  105. package/dist/tools/applyPatch.js.map +1 -1
  106. package/dist/tools/codeInterpreter.cjs.map +1 -1
  107. package/dist/tools/codeInterpreter.d.cts +0 -1
  108. package/dist/tools/codeInterpreter.d.cts.map +1 -1
  109. package/dist/tools/codeInterpreter.d.ts +0 -1
  110. package/dist/tools/codeInterpreter.d.ts.map +1 -1
  111. package/dist/tools/codeInterpreter.js.map +1 -1
  112. package/dist/tools/computerUse.cjs +1 -0
  113. package/dist/tools/computerUse.cjs.map +1 -1
  114. package/dist/tools/computerUse.d.cts +1 -2
  115. package/dist/tools/computerUse.d.cts.map +1 -1
  116. package/dist/tools/computerUse.d.ts +1 -2
  117. package/dist/tools/computerUse.d.ts.map +1 -1
  118. package/dist/tools/computerUse.js +1 -1
  119. package/dist/tools/computerUse.js.map +1 -1
  120. package/dist/tools/custom.cjs.map +1 -1
  121. package/dist/tools/custom.d.cts +1 -2
  122. package/dist/tools/custom.d.cts.map +1 -1
  123. package/dist/tools/custom.d.ts +1 -2
  124. package/dist/tools/custom.d.ts.map +1 -1
  125. package/dist/tools/custom.js.map +1 -1
  126. package/dist/tools/dalle.cjs.map +1 -1
  127. package/dist/tools/dalle.d.cts +0 -1
  128. package/dist/tools/dalle.d.cts.map +1 -1
  129. package/dist/tools/dalle.d.ts +0 -1
  130. package/dist/tools/dalle.d.ts.map +1 -1
  131. package/dist/tools/dalle.js.map +1 -1
  132. package/dist/tools/fileSearch.cjs.map +1 -1
  133. package/dist/tools/fileSearch.d.cts +0 -1
  134. package/dist/tools/fileSearch.d.cts.map +1 -1
  135. package/dist/tools/fileSearch.d.ts +0 -1
  136. package/dist/tools/fileSearch.d.ts.map +1 -1
  137. package/dist/tools/fileSearch.js.map +1 -1
  138. package/dist/tools/imageGeneration.cjs.map +1 -1
  139. package/dist/tools/imageGeneration.d.cts +0 -1
  140. package/dist/tools/imageGeneration.d.cts.map +1 -1
  141. package/dist/tools/imageGeneration.d.ts +0 -1
  142. package/dist/tools/imageGeneration.d.ts.map +1 -1
  143. package/dist/tools/imageGeneration.js.map +1 -1
  144. package/dist/tools/index.cjs +2 -1
  145. package/dist/tools/index.cjs.map +1 -1
  146. package/dist/tools/index.d.cts +1 -2
  147. package/dist/tools/index.d.cts.map +1 -1
  148. package/dist/tools/index.d.ts +1 -2
  149. package/dist/tools/index.d.ts.map +1 -1
  150. package/dist/tools/index.js +2 -2
  151. package/dist/tools/index.js.map +1 -1
  152. package/dist/tools/localShell.cjs +2 -0
  153. package/dist/tools/localShell.cjs.map +1 -1
  154. package/dist/tools/localShell.d.cts +1 -2
  155. package/dist/tools/localShell.d.cts.map +1 -1
  156. package/dist/tools/localShell.d.ts +1 -2
  157. package/dist/tools/localShell.d.ts.map +1 -1
  158. package/dist/tools/localShell.js +1 -1
  159. package/dist/tools/localShell.js.map +1 -1
  160. package/dist/tools/mcp.cjs.map +1 -1
  161. package/dist/tools/mcp.d.cts +0 -1
  162. package/dist/tools/mcp.d.cts.map +1 -1
  163. package/dist/tools/mcp.d.ts +0 -1
  164. package/dist/tools/mcp.d.ts.map +1 -1
  165. package/dist/tools/mcp.js.map +1 -1
  166. package/dist/tools/shell.cjs +1 -0
  167. package/dist/tools/shell.cjs.map +1 -1
  168. package/dist/tools/shell.d.cts +1 -2
  169. package/dist/tools/shell.d.cts.map +1 -1
  170. package/dist/tools/shell.d.ts +1 -2
  171. package/dist/tools/shell.d.ts.map +1 -1
  172. package/dist/tools/shell.js +1 -1
  173. package/dist/tools/shell.js.map +1 -1
  174. package/dist/tools/toolSearch.cjs.map +1 -1
  175. package/dist/tools/toolSearch.d.cts +0 -1
  176. package/dist/tools/toolSearch.d.cts.map +1 -1
  177. package/dist/tools/toolSearch.d.ts +0 -1
  178. package/dist/tools/toolSearch.d.ts.map +1 -1
  179. package/dist/tools/toolSearch.js.map +1 -1
  180. package/dist/tools/webSearch.cjs.map +1 -1
  181. package/dist/tools/webSearch.d.cts +1 -2
  182. package/dist/tools/webSearch.d.cts.map +1 -1
  183. package/dist/tools/webSearch.d.ts +1 -2
  184. package/dist/tools/webSearch.d.ts.map +1 -1
  185. package/dist/tools/webSearch.js.map +1 -1
  186. package/dist/types.d.cts +0 -1
  187. package/dist/types.d.cts.map +1 -1
  188. package/dist/types.d.ts +0 -1
  189. package/dist/types.d.ts.map +1 -1
  190. package/dist/utils/azure.cjs.map +1 -1
  191. package/dist/utils/azure.d.cts.map +1 -1
  192. package/dist/utils/azure.d.ts.map +1 -1
  193. package/dist/utils/azure.js.map +1 -1
  194. package/dist/utils/client.cjs.map +1 -1
  195. package/dist/utils/client.d.cts.map +1 -1
  196. package/dist/utils/client.d.ts.map +1 -1
  197. package/dist/utils/client.js.map +1 -1
  198. package/dist/utils/errors.cjs.map +1 -1
  199. package/dist/utils/errors.js.map +1 -1
  200. package/dist/utils/misc.cjs +2 -0
  201. package/dist/utils/misc.cjs.map +1 -1
  202. package/dist/utils/misc.d.cts +0 -1
  203. package/dist/utils/misc.d.cts.map +1 -1
  204. package/dist/utils/misc.d.ts +0 -1
  205. package/dist/utils/misc.d.ts.map +1 -1
  206. package/dist/utils/misc.js +1 -1
  207. package/dist/utils/misc.js.map +1 -1
  208. package/dist/utils/output.cjs.map +1 -1
  209. package/dist/utils/output.js.map +1 -1
  210. package/dist/utils/prompts.cjs.map +1 -1
  211. package/dist/utils/prompts.d.cts +0 -1
  212. package/dist/utils/prompts.d.cts.map +1 -1
  213. package/dist/utils/prompts.d.ts +0 -1
  214. package/dist/utils/prompts.d.ts.map +1 -1
  215. package/dist/utils/prompts.js.map +1 -1
  216. package/dist/utils/responses_stream_events.cjs.map +1 -1
  217. package/dist/utils/responses_stream_events.d.cts +0 -1
  218. package/dist/utils/responses_stream_events.d.cts.map +1 -1
  219. package/dist/utils/responses_stream_events.d.ts +0 -1
  220. package/dist/utils/responses_stream_events.d.ts.map +1 -1
  221. package/dist/utils/responses_stream_events.js.map +1 -1
  222. package/dist/utils/tools.cjs.map +1 -1
  223. package/dist/utils/tools.d.cts +2 -0
  224. package/dist/utils/tools.d.cts.map +1 -1
  225. package/dist/utils/tools.d.ts +2 -0
  226. package/dist/utils/tools.d.ts.map +1 -1
  227. package/dist/utils/tools.js.map +1 -1
  228. package/package.json +6 -6
@@ -1,7 +1,6 @@
1
1
  import { OpenAI } from "openai";
2
2
  import { DynamicStructuredTool } from "@langchain/core/tools";
3
3
  import { z } from "zod/v4";
4
-
5
4
  //#region src/tools/shell.d.ts
6
5
  /**
7
6
  * Re-export action type from OpenAI SDK for convenience.
@@ -217,5 +216,5 @@ type ShellTool = OpenAI.Responses.FunctionShellTool;
217
216
  */
218
217
  declare function shell(options: ShellOptions): DynamicStructuredTool<typeof ShellActionSchema, ShellAction, unknown, string>;
219
218
  //#endregion
220
- export { ShellAction, ShellCallOutcome, ShellCommandOutput, ShellOptions, ShellResult, ShellTool, shell };
219
+ export { ShellAction, ShellActionSchema, ShellCallOutcome, ShellCommandOutput, ShellOptions, ShellResult, ShellTool, shell };
221
220
  //# sourceMappingURL=shell.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.cts","names":[],"sources":["../../src/tools/shell.ts"],"mappings":";;;;;;;AAQA;;KAAY,WAAA,GACV,MAAA,CAAa,SAAA,CAAU,6BAAA,CAA8B,MAAA;AAAA,cAG1C,iBAAA,EAAiB,CAAA,CAAA,SAAA;;;;;;;AAA9B;;KAkBY,kBAAA,GACV,MAAA,CAAa,SAAA,CAAU,sCAAA;;;;KAKb,gBAAA,GAAmB,kBAAA;;;;;UAMd,WAAA;EA9Ba;;;;EAmC5B,MAAA,EAAQ,kBAAA;;;;;EAKR,eAAA;AAAA;;;;UAMe,YAAA;;;;;;;;;AA5BjB;;;;;;;;;AAMA;;;;;AAMA;;;;;;;;;AAgBA;;;;;;;EAuCE,OAAA,GAAU,MAAA,EAAQ,WAAA,KAAgB,WAAA,GAAc,OAAA,CAAQ,WAAA;AAAA;;;;KAM9C,SAAA,GAAY,MAAA,CAAa,SAAA,CAAU,iBAAA;;;;;AAA/C;;;;;;;;;AAqIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,KAAA,CAAM,OAAA,EAAS,YAAA,GAyBT,qBAAA,QACX,iBAAA,EACP,WAAA"}
1
+ {"version":3,"file":"shell.d.cts","names":[],"sources":["../../src/tools/shell.ts"],"mappings":";;;;;;;;KAQY,cACV,OAAa,UAAU,8BAA8B;cAG1C,mBAAiB,EAAA;;;;GAY5B,EAAA,KAAA;;;;;KAMU,qBACV,OAAa,UAAU;;;;KAKb,mBAAmB;;;;;UAMd;;;;;EAKf,QAAQ;;;;;EAKR;;;;;UAMe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuCf,UAAU,QAAQ,gBAAgB,cAAc,QAAQ;;;;;KAM9C,YAAY,OAAa,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqI/B,MAAM,SAAS,eAyBT,6BACX,mBACP"}
@@ -1,7 +1,6 @@
1
1
  import { OpenAI } from "openai";
2
2
  import { DynamicStructuredTool } from "@langchain/core/tools";
3
3
  import { z } from "zod/v4";
4
-
5
4
  //#region src/tools/shell.d.ts
6
5
  /**
7
6
  * Re-export action type from OpenAI SDK for convenience.
@@ -217,5 +216,5 @@ type ShellTool = OpenAI.Responses.FunctionShellTool;
217
216
  */
218
217
  declare function shell(options: ShellOptions): DynamicStructuredTool<typeof ShellActionSchema, ShellAction, unknown, string>;
219
218
  //#endregion
220
- export { ShellAction, ShellCallOutcome, ShellCommandOutput, ShellOptions, ShellResult, ShellTool, shell };
219
+ export { ShellAction, ShellActionSchema, ShellCallOutcome, ShellCommandOutput, ShellOptions, ShellResult, ShellTool, shell };
221
220
  //# sourceMappingURL=shell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.ts","names":[],"sources":["../../src/tools/shell.ts"],"mappings":";;;;;;;AAQA;;KAAY,WAAA,GACV,MAAA,CAAa,SAAA,CAAU,6BAAA,CAA8B,MAAA;AAAA,cAG1C,iBAAA,EAAiB,CAAA,CAAA,SAAA;;;;;;;AAA9B;;KAkBY,kBAAA,GACV,MAAA,CAAa,SAAA,CAAU,sCAAA;;;;KAKb,gBAAA,GAAmB,kBAAA;;;;;UAMd,WAAA;EA9Ba;;;;EAmC5B,MAAA,EAAQ,kBAAA;;;;;EAKR,eAAA;AAAA;;;;UAMe,YAAA;;;;;;;;;AA5BjB;;;;;;;;;AAMA;;;;;AAMA;;;;;;;;;AAgBA;;;;;;;EAuCE,OAAA,GAAU,MAAA,EAAQ,WAAA,KAAgB,WAAA,GAAc,OAAA,CAAQ,WAAA;AAAA;;;;KAM9C,SAAA,GAAY,MAAA,CAAa,SAAA,CAAU,iBAAA;;;;;AAA/C;;;;;;;;;AAqIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,KAAA,CAAM,OAAA,EAAS,YAAA,GAyBT,qBAAA,QACX,iBAAA,EACP,WAAA"}
1
+ {"version":3,"file":"shell.d.ts","names":[],"sources":["../../src/tools/shell.ts"],"mappings":";;;;;;;;KAQY,cACV,OAAa,UAAU,8BAA8B;cAG1C,mBAAiB,EAAA;;;;GAY5B,EAAA,KAAA;;;;;KAMU,qBACV,OAAa,UAAU;;;;KAKb,mBAAmB;;;;;UAMd;;;;;EAKf,QAAQ;;;;;EAKR;;;;;UAMe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuCf,UAAU,QAAQ,gBAAgB,cAAc,QAAQ;;;;;KAM9C,YAAY,OAAa,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqI/B,MAAM,SAAS,eAyBT,6BACX,mBACP"}
@@ -156,6 +156,6 @@ function shell(options) {
156
156
  return shellTool;
157
157
  }
158
158
  //#endregion
159
- export { shell };
159
+ export { ShellActionSchema, shell };
160
160
 
161
161
  //# sourceMappingURL=shell.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.js","names":[],"sources":["../../src/tools/shell.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { tool, type DynamicStructuredTool } from \"@langchain/core/tools\";\n\n/**\n * Re-export action type from OpenAI SDK for convenience.\n * The action contains command details like commands array, timeout, and max output length.\n */\nexport type ShellAction =\n OpenAIClient.Responses.ResponseFunctionShellToolCall.Action;\n\n// Zod schema for shell action\nexport const ShellActionSchema = z.object({\n commands: z.array(z.string()).describe(\"Array of shell commands to execute\"),\n timeout_ms: z\n .number()\n .optional()\n .describe(\"Optional timeout in milliseconds for the commands\"),\n max_output_length: z\n .number()\n .optional()\n .describe(\n \"Optional maximum number of characters to return from each command\"\n ),\n});\n\n/**\n * Result of a single shell command execution.\n * Contains stdout, stderr, and the outcome (exit code or timeout).\n */\nexport type ShellCommandOutput =\n OpenAIClient.Responses.ResponseFunctionShellCallOutputContent;\n\n/**\n * Outcome type for shell command execution - either exit with code or timeout.\n */\nexport type ShellCallOutcome = ShellCommandOutput[\"outcome\"];\n\n/**\n * Result of executing shell commands.\n * Contains an array of outputs (one per command) and the max_output_length parameter.\n */\nexport interface ShellResult {\n /**\n * Array of command outputs. Each entry corresponds to a command from the action.\n * The order should match the order of commands in the action.\n */\n output: ShellCommandOutput[];\n /**\n * The max_output_length from the action, which must be passed back to the API.\n * If not provided in the action, can be omitted.\n */\n maxOutputLength?: number | null;\n}\n\n/**\n * Options for the Shell tool.\n */\nexport interface ShellOptions {\n /**\n * Execute function that handles shell command execution.\n * This function receives the action input containing the commands and limits,\n * and should return a ShellResult with stdout, stderr, and outcome for each command.\n *\n * @example\n * ```typescript\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * }\n * ```\n */\n execute: (action: ShellAction) => ShellResult | Promise<ShellResult>;\n}\n\n/**\n * OpenAI Shell tool type for the Responses API.\n */\nexport type ShellTool = OpenAIClient.Responses.FunctionShellTool;\n\nconst TOOL_NAME = \"shell\";\n\n/**\n * Creates a Shell tool that allows models to run shell commands through your integration.\n *\n * The shell tool allows the model to interact with your local computer through a controlled\n * command-line interface. The model proposes shell commands; your integration executes them\n * and returns the outputs. This creates a simple plan-execute loop that lets models inspect\n * the system, run utilities, and gather data until they can finish the task.\n *\n * **Important**: The shell tool is available through the Responses API for use with `GPT-5.1`.\n * It is not available on other models, or via the Chat Completions API.\n *\n * **When to use**:\n * - **Automating filesystem or process diagnostics** – For example, \"find the largest PDF\n * under ~/Documents\" or \"show running gunicorn processes.\"\n * - **Extending the model's capabilities** – Using built-in UNIX utilities, python runtime\n * and other CLIs in your environment.\n * - **Running multi-step build and test flows** – Chaining commands like `pip install` and `pytest`.\n * - **Complex agentic coding workflows** – Using other tools like `apply_patch` to complete\n * workflows that involve complex file operations.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends shell commands (`shell_call` with `commands` array)\n * 2. Your code executes the commands (can be concurrent)\n * 3. You return stdout, stderr, and outcome for each command\n * 4. Repeat until the task is complete\n *\n * **Security Warning**: Running arbitrary shell commands can be dangerous.\n * Always sandbox execution or add strict allow/deny-lists before forwarding\n * a command to the system shell.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-shell | OpenAI Shell Documentation}\n * @see {@link https://github.com/openai/codex | Codex CLI} for reference implementation.\n *\n * @param options - Configuration for the Shell tool\n * @returns A Shell tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { exec } from \"child_process/promises\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.1\" });\n *\n * // With execute callback for automatic command handling\n * const shellTool = tools.shell({\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * },\n * });\n *\n * const llmWithShell = model.bindTools([shellTool]);\n * const response = await llmWithShell.invoke(\n * \"Find the largest PDF file in ~/Documents\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Full shell loop example\n * async function shellLoop(model, task) {\n * let response = await model.invoke(task, {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n *\n * while (true) {\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"shell_call\"\n * );\n *\n * if (!shellCall) break;\n *\n * // Execute commands (with proper sandboxing!)\n * const result = await executeCommands(shellCall.action);\n *\n * // Send output back to model\n * response = await model.invoke([\n * response,\n * {\n * type: \"shell_call_output\",\n * call_id: shellCall.call_id,\n * output: result.output,\n * max_output_length: result.maxOutputLength,\n * },\n * ], {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n * }\n *\n * return response;\n * }\n * ```\n *\n * @remarks\n * - Only available through the Responses API (not Chat Completions)\n * - Designed for use with `gpt-5.1` model\n * - Commands are provided as an array of strings that can be executed concurrently\n * - Action includes: `commands`, `timeout_ms`, `max_output_length`\n * - Always sandbox or validate commands before execution\n * - The `timeout_ms` from the model is only a hint—enforce your own limits\n * - If `max_output_length` exists in the action, always pass it back in the output\n * - Many CLI tools return non-zero exit codes for warnings; still capture stdout/stderr\n */\nexport function shell(options: ShellOptions) {\n // Wrapper that converts ShellResult to string for LangChain tool compatibility\n const executeWrapper = async (action: ShellAction): Promise<string> => {\n const result = await options.execute(action);\n // Return a JSON string representation for the tool result\n return JSON.stringify({\n output: result.output,\n max_output_length: result.maxOutputLength,\n });\n };\n\n const shellTool = tool(executeWrapper, {\n name: TOOL_NAME,\n description:\n \"Execute shell commands in a managed environment. Commands can be run concurrently.\",\n schema: ShellActionSchema,\n });\n\n shellTool.extras = {\n ...(shellTool.extras ?? {}),\n providerToolDefinition: {\n type: \"shell\",\n } satisfies ShellTool,\n };\n\n return shellTool as DynamicStructuredTool<\n typeof ShellActionSchema,\n ShellAction,\n unknown,\n string\n >;\n}\n"],"mappings":";;;AAYA,MAAa,oBAAoB,EAAE,OAAO;CACxC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS,qCAAqC;CAC5E,YAAY,EACT,QAAQ,CACR,UAAU,CACV,SAAS,oDAAoD;CAChE,mBAAmB,EAChB,QAAQ,CACR,UAAU,CACV,SACC,oEACD;CACJ,CAAC;AAiFF,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmIlB,SAAgB,MAAM,SAAuB;CAE3C,MAAM,iBAAiB,OAAO,WAAyC;EACrE,MAAM,SAAS,MAAM,QAAQ,QAAQ,OAAO;AAE5C,SAAO,KAAK,UAAU;GACpB,QAAQ,OAAO;GACf,mBAAmB,OAAO;GAC3B,CAAC;;CAGJ,MAAM,YAAY,KAAK,gBAAgB;EACrC,MAAM;EACN,aACE;EACF,QAAQ;EACT,CAAC;AAEF,WAAU,SAAS;EACjB,GAAI,UAAU,UAAU,EAAE;EAC1B,wBAAwB,EACtB,MAAM,SACP;EACF;AAED,QAAO"}
1
+ {"version":3,"file":"shell.js","names":[],"sources":["../../src/tools/shell.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { tool, type DynamicStructuredTool } from \"@langchain/core/tools\";\n\n/**\n * Re-export action type from OpenAI SDK for convenience.\n * The action contains command details like commands array, timeout, and max output length.\n */\nexport type ShellAction =\n OpenAIClient.Responses.ResponseFunctionShellToolCall.Action;\n\n// Zod schema for shell action\nexport const ShellActionSchema = z.object({\n commands: z.array(z.string()).describe(\"Array of shell commands to execute\"),\n timeout_ms: z\n .number()\n .optional()\n .describe(\"Optional timeout in milliseconds for the commands\"),\n max_output_length: z\n .number()\n .optional()\n .describe(\n \"Optional maximum number of characters to return from each command\"\n ),\n});\n\n/**\n * Result of a single shell command execution.\n * Contains stdout, stderr, and the outcome (exit code or timeout).\n */\nexport type ShellCommandOutput =\n OpenAIClient.Responses.ResponseFunctionShellCallOutputContent;\n\n/**\n * Outcome type for shell command execution - either exit with code or timeout.\n */\nexport type ShellCallOutcome = ShellCommandOutput[\"outcome\"];\n\n/**\n * Result of executing shell commands.\n * Contains an array of outputs (one per command) and the max_output_length parameter.\n */\nexport interface ShellResult {\n /**\n * Array of command outputs. Each entry corresponds to a command from the action.\n * The order should match the order of commands in the action.\n */\n output: ShellCommandOutput[];\n /**\n * The max_output_length from the action, which must be passed back to the API.\n * If not provided in the action, can be omitted.\n */\n maxOutputLength?: number | null;\n}\n\n/**\n * Options for the Shell tool.\n */\nexport interface ShellOptions {\n /**\n * Execute function that handles shell command execution.\n * This function receives the action input containing the commands and limits,\n * and should return a ShellResult with stdout, stderr, and outcome for each command.\n *\n * @example\n * ```typescript\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * }\n * ```\n */\n execute: (action: ShellAction) => ShellResult | Promise<ShellResult>;\n}\n\n/**\n * OpenAI Shell tool type for the Responses API.\n */\nexport type ShellTool = OpenAIClient.Responses.FunctionShellTool;\n\nconst TOOL_NAME = \"shell\";\n\n/**\n * Creates a Shell tool that allows models to run shell commands through your integration.\n *\n * The shell tool allows the model to interact with your local computer through a controlled\n * command-line interface. The model proposes shell commands; your integration executes them\n * and returns the outputs. This creates a simple plan-execute loop that lets models inspect\n * the system, run utilities, and gather data until they can finish the task.\n *\n * **Important**: The shell tool is available through the Responses API for use with `GPT-5.1`.\n * It is not available on other models, or via the Chat Completions API.\n *\n * **When to use**:\n * - **Automating filesystem or process diagnostics** – For example, \"find the largest PDF\n * under ~/Documents\" or \"show running gunicorn processes.\"\n * - **Extending the model's capabilities** – Using built-in UNIX utilities, python runtime\n * and other CLIs in your environment.\n * - **Running multi-step build and test flows** – Chaining commands like `pip install` and `pytest`.\n * - **Complex agentic coding workflows** – Using other tools like `apply_patch` to complete\n * workflows that involve complex file operations.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends shell commands (`shell_call` with `commands` array)\n * 2. Your code executes the commands (can be concurrent)\n * 3. You return stdout, stderr, and outcome for each command\n * 4. Repeat until the task is complete\n *\n * **Security Warning**: Running arbitrary shell commands can be dangerous.\n * Always sandbox execution or add strict allow/deny-lists before forwarding\n * a command to the system shell.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-shell | OpenAI Shell Documentation}\n * @see {@link https://github.com/openai/codex | Codex CLI} for reference implementation.\n *\n * @param options - Configuration for the Shell tool\n * @returns A Shell tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { exec } from \"child_process/promises\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.1\" });\n *\n * // With execute callback for automatic command handling\n * const shellTool = tools.shell({\n * execute: async (action) => {\n * const outputs = await Promise.all(\n * action.commands.map(async (cmd) => {\n * try {\n * const { stdout, stderr } = await exec(cmd, {\n * timeout: action.timeout_ms ?? undefined,\n * });\n * return {\n * stdout,\n * stderr,\n * outcome: { type: \"exit\" as const, exit_code: 0 },\n * };\n * } catch (error) {\n * const timedOut = error.killed && error.signal === \"SIGTERM\";\n * return {\n * stdout: error.stdout ?? \"\",\n * stderr: error.stderr ?? String(error),\n * outcome: timedOut\n * ? { type: \"timeout\" as const }\n * : { type: \"exit\" as const, exit_code: error.code ?? 1 },\n * };\n * }\n * })\n * );\n * return {\n * output: outputs,\n * maxOutputLength: action.max_output_length,\n * };\n * },\n * });\n *\n * const llmWithShell = model.bindTools([shellTool]);\n * const response = await llmWithShell.invoke(\n * \"Find the largest PDF file in ~/Documents\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Full shell loop example\n * async function shellLoop(model, task) {\n * let response = await model.invoke(task, {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n *\n * while (true) {\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"shell_call\"\n * );\n *\n * if (!shellCall) break;\n *\n * // Execute commands (with proper sandboxing!)\n * const result = await executeCommands(shellCall.action);\n *\n * // Send output back to model\n * response = await model.invoke([\n * response,\n * {\n * type: \"shell_call_output\",\n * call_id: shellCall.call_id,\n * output: result.output,\n * max_output_length: result.maxOutputLength,\n * },\n * ], {\n * tools: [tools.shell({ execute: myExecutor })],\n * });\n * }\n *\n * return response;\n * }\n * ```\n *\n * @remarks\n * - Only available through the Responses API (not Chat Completions)\n * - Designed for use with `gpt-5.1` model\n * - Commands are provided as an array of strings that can be executed concurrently\n * - Action includes: `commands`, `timeout_ms`, `max_output_length`\n * - Always sandbox or validate commands before execution\n * - The `timeout_ms` from the model is only a hint—enforce your own limits\n * - If `max_output_length` exists in the action, always pass it back in the output\n * - Many CLI tools return non-zero exit codes for warnings; still capture stdout/stderr\n */\nexport function shell(options: ShellOptions) {\n // Wrapper that converts ShellResult to string for LangChain tool compatibility\n const executeWrapper = async (action: ShellAction): Promise<string> => {\n const result = await options.execute(action);\n // Return a JSON string representation for the tool result\n return JSON.stringify({\n output: result.output,\n max_output_length: result.maxOutputLength,\n });\n };\n\n const shellTool = tool(executeWrapper, {\n name: TOOL_NAME,\n description:\n \"Execute shell commands in a managed environment. Commands can be run concurrently.\",\n schema: ShellActionSchema,\n });\n\n shellTool.extras = {\n ...(shellTool.extras ?? {}),\n providerToolDefinition: {\n type: \"shell\",\n } satisfies ShellTool,\n };\n\n return shellTool as DynamicStructuredTool<\n typeof ShellActionSchema,\n ShellAction,\n unknown,\n string\n >;\n}\n"],"mappings":";;;AAYA,MAAa,oBAAoB,EAAE,OAAO;CACxC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,oCAAoC;CAC3E,YAAY,EACT,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,mDAAmD;CAC/D,mBAAmB,EAChB,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,mEACF;AACJ,CAAC;AAiFD,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmIlB,SAAgB,MAAM,SAAuB;CAE3C,MAAM,iBAAiB,OAAO,WAAyC;EACrE,MAAM,SAAS,MAAM,QAAQ,QAAQ,MAAM;EAE3C,OAAO,KAAK,UAAU;GACpB,QAAQ,OAAO;GACf,mBAAmB,OAAO;EAC5B,CAAC;CACH;CAEA,MAAM,YAAY,KAAK,gBAAgB;EACrC,MAAM;EACN,aACE;EACF,QAAQ;CACV,CAAC;CAED,UAAU,SAAS;EACjB,GAAI,UAAU,UAAU,CAAC;EACzB,wBAAwB,EACtB,MAAM,QACR;CACF;CAEA,OAAO;AAMT"}
@@ -1 +1 @@
1
- {"version":3,"file":"toolSearch.cjs","names":[],"sources":["../../src/tools/toolSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\nexport interface ToolSearchOptions {\n /**\n * Whether tool search is executed by the server or by the client.\n * - `\"server\"` (default): OpenAI's servers handle the search internally.\n * - `\"client\"`: The client provides results via agent middleware.\n */\n execution?: \"server\" | \"client\";\n /**\n * Description shown to the model for a client-executed tool search tool.\n */\n description?: string;\n /**\n * Parameter schema for a client-executed tool search tool.\n */\n parameters?: unknown;\n}\n\nexport type ToolSearchTool = OpenAIClient.Responses.ToolSearchTool;\n\n/**\n * Creates a tool search tool that enables OpenAI models to dynamically discover\n * and load tools on-demand from a large pool, rather than requiring all tool\n * definitions to be sent in every request.\n *\n * Tool search works with tools that have `defer_loading: true` set (either\n * directly in the tool definition or via `extras: { defer_loading: true }` on\n * LangChain tools). When the model needs a deferred tool, it issues a tool\n * search call, discovers matching tools, and then makes the actual function call.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-tool-search | OpenAI Tool Search Documentation}\n * @param options - Configuration options for the tool search tool\n * @returns A tool search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.3\" });\n *\n * const getWeather = tool(\n * async (input) => `Weather in ${input.location}: sunny, 72°F`,\n * {\n * name: \"get_weather\",\n * description: \"Get the current weather for a location\",\n * schema: z.object({ location: z.string() }),\n * extras: { defer_loading: true },\n * }\n * );\n *\n * // Server-executed tool search (default)\n * const response = await model.invoke(\"What is the weather in SF?\", {\n * tools: [tools.toolSearch(), getWeather],\n * });\n *\n * // Client-executed tool search\n * const clientResponse = await model.invoke(\"What is the weather in SF?\", {\n * tools: [\n * tools.toolSearch({\n * execution: \"client\",\n * description: \"Search for available tools\",\n * parameters: {\n * type: \"object\",\n * properties: { goal: { type: \"string\" } },\n * required: [\"goal\"],\n * },\n * }),\n * getWeather,\n * ],\n * });\n * ```\n */\nexport function toolSearch(options?: ToolSearchOptions): ServerTool {\n return {\n type: \"tool_search\",\n ...(options?.execution ? { execution: options.execution } : {}),\n ...(options?.description ? { description: options.description } : {}),\n ...(options?.parameters !== undefined\n ? { parameters: options.parameters }\n : {}),\n } satisfies ToolSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,SAAgB,WAAW,SAAyC;AAClE,QAAO;EACL,MAAM;EACN,GAAI,SAAS,YAAY,EAAE,WAAW,QAAQ,WAAW,GAAG,EAAE;EAC9D,GAAI,SAAS,cAAc,EAAE,aAAa,QAAQ,aAAa,GAAG,EAAE;EACpE,GAAI,SAAS,eAAe,KAAA,IACxB,EAAE,YAAY,QAAQ,YAAY,GAClC,EAAE;EACP"}
1
+ {"version":3,"file":"toolSearch.cjs","names":[],"sources":["../../src/tools/toolSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\nexport interface ToolSearchOptions {\n /**\n * Whether tool search is executed by the server or by the client.\n * - `\"server\"` (default): OpenAI's servers handle the search internally.\n * - `\"client\"`: The client provides results via agent middleware.\n */\n execution?: \"server\" | \"client\";\n /**\n * Description shown to the model for a client-executed tool search tool.\n */\n description?: string;\n /**\n * Parameter schema for a client-executed tool search tool.\n */\n parameters?: unknown;\n}\n\nexport type ToolSearchTool = OpenAIClient.Responses.ToolSearchTool;\n\n/**\n * Creates a tool search tool that enables OpenAI models to dynamically discover\n * and load tools on-demand from a large pool, rather than requiring all tool\n * definitions to be sent in every request.\n *\n * Tool search works with tools that have `defer_loading: true` set (either\n * directly in the tool definition or via `extras: { defer_loading: true }` on\n * LangChain tools). When the model needs a deferred tool, it issues a tool\n * search call, discovers matching tools, and then makes the actual function call.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-tool-search | OpenAI Tool Search Documentation}\n * @param options - Configuration options for the tool search tool\n * @returns A tool search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.3\" });\n *\n * const getWeather = tool(\n * async (input) => `Weather in ${input.location}: sunny, 72°F`,\n * {\n * name: \"get_weather\",\n * description: \"Get the current weather for a location\",\n * schema: z.object({ location: z.string() }),\n * extras: { defer_loading: true },\n * }\n * );\n *\n * // Server-executed tool search (default)\n * const response = await model.invoke(\"What is the weather in SF?\", {\n * tools: [tools.toolSearch(), getWeather],\n * });\n *\n * // Client-executed tool search\n * const clientResponse = await model.invoke(\"What is the weather in SF?\", {\n * tools: [\n * tools.toolSearch({\n * execution: \"client\",\n * description: \"Search for available tools\",\n * parameters: {\n * type: \"object\",\n * properties: { goal: { type: \"string\" } },\n * required: [\"goal\"],\n * },\n * }),\n * getWeather,\n * ],\n * });\n * ```\n */\nexport function toolSearch(options?: ToolSearchOptions): ServerTool {\n return {\n type: \"tool_search\",\n ...(options?.execution ? { execution: options.execution } : {}),\n ...(options?.description ? { description: options.description } : {}),\n ...(options?.parameters !== undefined\n ? { parameters: options.parameters }\n : {}),\n } satisfies ToolSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,SAAgB,WAAW,SAAyC;CAClE,OAAO;EACL,MAAM;EACN,GAAI,SAAS,YAAY,EAAE,WAAW,QAAQ,UAAU,IAAI,CAAC;EAC7D,GAAI,SAAS,cAAc,EAAE,aAAa,QAAQ,YAAY,IAAI,CAAC;EACnE,GAAI,SAAS,eAAe,KAAA,IACxB,EAAE,YAAY,QAAQ,WAAW,IACjC,CAAC;CACP;AACF"}
@@ -1,6 +1,5 @@
1
1
  import { OpenAI } from "openai";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
-
4
3
  //#region src/tools/toolSearch.d.ts
5
4
  interface ToolSearchOptions {
6
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"toolSearch.d.cts","names":[],"sources":["../../src/tools/toolSearch.ts"],"mappings":";;;;UAGiB,iBAAA;;AAAjB;;;;EAME,SAAA;EAIA;;;EAAA,WAAA;EAOU;;;EAHV,UAAA;AAAA;AAAA,KAGU,cAAA,GAAiB,MAAA,CAAa,SAAA,CAAU,cAAA;;;;AAwDpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,UAAA,CAAW,OAAA,GAAU,iBAAA,GAAoB,UAAA"}
1
+ {"version":3,"file":"toolSearch.d.cts","names":[],"sources":["../../src/tools/toolSearch.ts"],"mappings":";;;UAGiB;;;;;;EAMf;;;;EAIA;;;;EAIA;;KAGU,iBAAiB,OAAa,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwDpC,WAAW,UAAU,oBAAoB"}
@@ -1,6 +1,5 @@
1
1
  import { OpenAI } from "openai";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
-
4
3
  //#region src/tools/toolSearch.d.ts
5
4
  interface ToolSearchOptions {
6
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"toolSearch.d.ts","names":[],"sources":["../../src/tools/toolSearch.ts"],"mappings":";;;;UAGiB,iBAAA;;AAAjB;;;;EAME,SAAA;EAIA;;;EAAA,WAAA;EAOU;;;EAHV,UAAA;AAAA;AAAA,KAGU,cAAA,GAAiB,MAAA,CAAa,SAAA,CAAU,cAAA;;;;AAwDpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,UAAA,CAAW,OAAA,GAAU,iBAAA,GAAoB,UAAA"}
1
+ {"version":3,"file":"toolSearch.d.ts","names":[],"sources":["../../src/tools/toolSearch.ts"],"mappings":";;;UAGiB;;;;;;EAMf;;;;EAIA;;;;EAIA;;KAGU,iBAAiB,OAAa,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwDpC,WAAW,UAAU,oBAAoB"}
@@ -1 +1 @@
1
- {"version":3,"file":"toolSearch.js","names":[],"sources":["../../src/tools/toolSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\nexport interface ToolSearchOptions {\n /**\n * Whether tool search is executed by the server or by the client.\n * - `\"server\"` (default): OpenAI's servers handle the search internally.\n * - `\"client\"`: The client provides results via agent middleware.\n */\n execution?: \"server\" | \"client\";\n /**\n * Description shown to the model for a client-executed tool search tool.\n */\n description?: string;\n /**\n * Parameter schema for a client-executed tool search tool.\n */\n parameters?: unknown;\n}\n\nexport type ToolSearchTool = OpenAIClient.Responses.ToolSearchTool;\n\n/**\n * Creates a tool search tool that enables OpenAI models to dynamically discover\n * and load tools on-demand from a large pool, rather than requiring all tool\n * definitions to be sent in every request.\n *\n * Tool search works with tools that have `defer_loading: true` set (either\n * directly in the tool definition or via `extras: { defer_loading: true }` on\n * LangChain tools). When the model needs a deferred tool, it issues a tool\n * search call, discovers matching tools, and then makes the actual function call.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-tool-search | OpenAI Tool Search Documentation}\n * @param options - Configuration options for the tool search tool\n * @returns A tool search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.3\" });\n *\n * const getWeather = tool(\n * async (input) => `Weather in ${input.location}: sunny, 72°F`,\n * {\n * name: \"get_weather\",\n * description: \"Get the current weather for a location\",\n * schema: z.object({ location: z.string() }),\n * extras: { defer_loading: true },\n * }\n * );\n *\n * // Server-executed tool search (default)\n * const response = await model.invoke(\"What is the weather in SF?\", {\n * tools: [tools.toolSearch(), getWeather],\n * });\n *\n * // Client-executed tool search\n * const clientResponse = await model.invoke(\"What is the weather in SF?\", {\n * tools: [\n * tools.toolSearch({\n * execution: \"client\",\n * description: \"Search for available tools\",\n * parameters: {\n * type: \"object\",\n * properties: { goal: { type: \"string\" } },\n * required: [\"goal\"],\n * },\n * }),\n * getWeather,\n * ],\n * });\n * ```\n */\nexport function toolSearch(options?: ToolSearchOptions): ServerTool {\n return {\n type: \"tool_search\",\n ...(options?.execution ? { execution: options.execution } : {}),\n ...(options?.description ? { description: options.description } : {}),\n ...(options?.parameters !== undefined\n ? { parameters: options.parameters }\n : {}),\n } satisfies ToolSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,SAAgB,WAAW,SAAyC;AAClE,QAAO;EACL,MAAM;EACN,GAAI,SAAS,YAAY,EAAE,WAAW,QAAQ,WAAW,GAAG,EAAE;EAC9D,GAAI,SAAS,cAAc,EAAE,aAAa,QAAQ,aAAa,GAAG,EAAE;EACpE,GAAI,SAAS,eAAe,KAAA,IACxB,EAAE,YAAY,QAAQ,YAAY,GAClC,EAAE;EACP"}
1
+ {"version":3,"file":"toolSearch.js","names":[],"sources":["../../src/tools/toolSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\nexport interface ToolSearchOptions {\n /**\n * Whether tool search is executed by the server or by the client.\n * - `\"server\"` (default): OpenAI's servers handle the search internally.\n * - `\"client\"`: The client provides results via agent middleware.\n */\n execution?: \"server\" | \"client\";\n /**\n * Description shown to the model for a client-executed tool search tool.\n */\n description?: string;\n /**\n * Parameter schema for a client-executed tool search tool.\n */\n parameters?: unknown;\n}\n\nexport type ToolSearchTool = OpenAIClient.Responses.ToolSearchTool;\n\n/**\n * Creates a tool search tool that enables OpenAI models to dynamically discover\n * and load tools on-demand from a large pool, rather than requiring all tool\n * definitions to be sent in every request.\n *\n * Tool search works with tools that have `defer_loading: true` set (either\n * directly in the tool definition or via `extras: { defer_loading: true }` on\n * LangChain tools). When the model needs a deferred tool, it issues a tool\n * search call, discovers matching tools, and then makes the actual function call.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-tool-search | OpenAI Tool Search Documentation}\n * @param options - Configuration options for the tool search tool\n * @returns A tool search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.3\" });\n *\n * const getWeather = tool(\n * async (input) => `Weather in ${input.location}: sunny, 72°F`,\n * {\n * name: \"get_weather\",\n * description: \"Get the current weather for a location\",\n * schema: z.object({ location: z.string() }),\n * extras: { defer_loading: true },\n * }\n * );\n *\n * // Server-executed tool search (default)\n * const response = await model.invoke(\"What is the weather in SF?\", {\n * tools: [tools.toolSearch(), getWeather],\n * });\n *\n * // Client-executed tool search\n * const clientResponse = await model.invoke(\"What is the weather in SF?\", {\n * tools: [\n * tools.toolSearch({\n * execution: \"client\",\n * description: \"Search for available tools\",\n * parameters: {\n * type: \"object\",\n * properties: { goal: { type: \"string\" } },\n * required: [\"goal\"],\n * },\n * }),\n * getWeather,\n * ],\n * });\n * ```\n */\nexport function toolSearch(options?: ToolSearchOptions): ServerTool {\n return {\n type: \"tool_search\",\n ...(options?.execution ? { execution: options.execution } : {}),\n ...(options?.description ? { description: options.description } : {}),\n ...(options?.parameters !== undefined\n ? { parameters: options.parameters }\n : {}),\n } satisfies ToolSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,SAAgB,WAAW,SAAyC;CAClE,OAAO;EACL,MAAM;EACN,GAAI,SAAS,YAAY,EAAE,WAAW,QAAQ,UAAU,IAAI,CAAC;EAC7D,GAAI,SAAS,cAAc,EAAE,aAAa,QAAQ,YAAY,IAAI,CAAC;EACnE,GAAI,SAAS,eAAe,KAAA,IACxB,EAAE,YAAY,QAAQ,WAAW,IACjC,CAAC;CACP;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.cjs","names":[],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * User location configuration for geographic search refinement.\n */\nexport interface WebSearchUserLocation {\n /**\n * The type of location. Currently only \"approximate\" is supported.\n */\n type: \"approximate\";\n /**\n * Two-letter ISO country code (e.g., \"US\", \"GB\").\n * @see https://en.wikipedia.org/wiki/ISO_3166-1\n */\n country?: string;\n /**\n * City name (e.g., \"San Francisco\", \"London\").\n */\n city?: string;\n /**\n * Region or state name (e.g., \"California\", \"London\").\n */\n region?: string;\n /**\n * IANA timezone (e.g., \"America/Los_Angeles\", \"Europe/London\").\n * @see https://timeapi.io/documentation/iana-timezones\n */\n timezone?: string;\n}\n\n/**\n * Domain filtering configuration for web search.\n */\nexport interface WebSearchFilters {\n /**\n * Allow-list of up to 100 domains to limit search results.\n * Omit the HTTP/HTTPS prefix (e.g., \"openai.com\" instead of \"https://openai.com/\").\n * Includes subdomains automatically.\n */\n allowedDomains?: string[];\n}\n\n/**\n * Options for the OpenAI web search tool.\n */\nexport interface WebSearchOptions {\n /**\n * Domain filtering configuration.\n * Limit results to a specific set of up to 100 domains.\n */\n filters?: WebSearchFilters;\n /**\n * Approximate user location for geographic search refinement.\n * Not supported for deep research models.\n */\n userLocation?: WebSearchUserLocation;\n /**\n * High level guidance for the amount of context window space to use for the\n * search. One of `low`, `medium`, or `high`. `medium` is the default.\n */\n search_context_size?: \"low\" | \"medium\" | \"high\";\n}\n\n/**\n * OpenAI web search tool type for the Responses API.\n */\nexport type WebSearchTool = OpenAIClient.Responses.WebSearchTool;\n\n/**\n * Creates a web search tool that allows OpenAI models to search the web\n * for up-to-date information before generating a response.\n *\n * Web search supports three main types:\n * 1. **Non-reasoning web search**: Quick lookups where the model passes queries\n * directly to the search tool.\n * 2. **Agentic search with reasoning models**: The model actively manages the\n * search process, analyzing results and deciding whether to keep searching.\n * 3. **Deep research**: Extended investigations using models like `o3-deep-research`\n * or `gpt-5` with high reasoning effort.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-web-search | OpenAI Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What was a positive news story from today?\", {\n * tools: [tools.webSearch()],\n * });\n *\n * // With domain filtering\n * const filteredResponse = await model.invoke(\"Latest AI research news\", {\n * tools: [tools.webSearch({\n * filters: {\n * allowedDomains: [\"arxiv.org\", \"nature.com\", \"science.org\"],\n * },\n * })],\n * });\n *\n * // With user location for geographic relevance\n * const localResponse = await model.invoke(\"What are the best restaurants near me?\", {\n * tools: [tools.webSearch({\n * userLocation: {\n * type: \"approximate\",\n * country: \"US\",\n * city: \"San Francisco\",\n * region: \"California\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n *\n * // Cache-only mode (no live internet access)\n * const cachedResponse = await model.invoke(\"Find information about OpenAI\", {\n * tools: [tools.webSearch({\n * externalWebAccess: false,\n * })],\n * });\n * ```\n */\nexport function webSearch(options?: WebSearchOptions): ServerTool {\n return {\n type: \"web_search\",\n filters: options?.filters?.allowedDomains\n ? { allowed_domains: options.filters.allowedDomains }\n : undefined,\n user_location: options?.userLocation,\n search_context_size: options?.search_context_size,\n } satisfies WebSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgIA,SAAgB,UAAU,SAAwC;AAChE,QAAO;EACL,MAAM;EACN,SAAS,SAAS,SAAS,iBACvB,EAAE,iBAAiB,QAAQ,QAAQ,gBAAgB,GACnD,KAAA;EACJ,eAAe,SAAS;EACxB,qBAAqB,SAAS;EAC/B"}
1
+ {"version":3,"file":"webSearch.cjs","names":[],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * User location configuration for geographic search refinement.\n */\nexport interface WebSearchUserLocation {\n /**\n * The type of location. Currently only \"approximate\" is supported.\n */\n type: \"approximate\";\n /**\n * Two-letter ISO country code (e.g., \"US\", \"GB\").\n * @see https://en.wikipedia.org/wiki/ISO_3166-1\n */\n country?: string;\n /**\n * City name (e.g., \"San Francisco\", \"London\").\n */\n city?: string;\n /**\n * Region or state name (e.g., \"California\", \"London\").\n */\n region?: string;\n /**\n * IANA timezone (e.g., \"America/Los_Angeles\", \"Europe/London\").\n * @see https://timeapi.io/documentation/iana-timezones\n */\n timezone?: string;\n}\n\n/**\n * Domain filtering configuration for web search.\n */\nexport interface WebSearchFilters {\n /**\n * Allow-list of up to 100 domains to limit search results.\n * Omit the HTTP/HTTPS prefix (e.g., \"openai.com\" instead of \"https://openai.com/\").\n * Includes subdomains automatically.\n */\n allowedDomains?: string[];\n}\n\n/**\n * Options for the OpenAI web search tool.\n */\nexport interface WebSearchOptions {\n /**\n * Domain filtering configuration.\n * Limit results to a specific set of up to 100 domains.\n */\n filters?: WebSearchFilters;\n /**\n * Approximate user location for geographic search refinement.\n * Not supported for deep research models.\n */\n userLocation?: WebSearchUserLocation;\n /**\n * High level guidance for the amount of context window space to use for the\n * search. One of `low`, `medium`, or `high`. `medium` is the default.\n */\n search_context_size?: \"low\" | \"medium\" | \"high\";\n}\n\n/**\n * OpenAI web search tool type for the Responses API.\n */\nexport type WebSearchTool = OpenAIClient.Responses.WebSearchTool;\n\n/**\n * Creates a web search tool that allows OpenAI models to search the web\n * for up-to-date information before generating a response.\n *\n * Web search supports three main types:\n * 1. **Non-reasoning web search**: Quick lookups where the model passes queries\n * directly to the search tool.\n * 2. **Agentic search with reasoning models**: The model actively manages the\n * search process, analyzing results and deciding whether to keep searching.\n * 3. **Deep research**: Extended investigations using models like `o3-deep-research`\n * or `gpt-5` with high reasoning effort.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-web-search | OpenAI Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What was a positive news story from today?\", {\n * tools: [tools.webSearch()],\n * });\n *\n * // With domain filtering\n * const filteredResponse = await model.invoke(\"Latest AI research news\", {\n * tools: [tools.webSearch({\n * filters: {\n * allowedDomains: [\"arxiv.org\", \"nature.com\", \"science.org\"],\n * },\n * })],\n * });\n *\n * // With user location for geographic relevance\n * const localResponse = await model.invoke(\"What are the best restaurants near me?\", {\n * tools: [tools.webSearch({\n * userLocation: {\n * type: \"approximate\",\n * country: \"US\",\n * city: \"San Francisco\",\n * region: \"California\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n *\n * // Cache-only mode (no live internet access)\n * const cachedResponse = await model.invoke(\"Find information about OpenAI\", {\n * tools: [tools.webSearch({\n * externalWebAccess: false,\n * })],\n * });\n * ```\n */\nexport function webSearch(options?: WebSearchOptions): ServerTool {\n return {\n type: \"web_search\",\n filters: options?.filters?.allowedDomains\n ? { allowed_domains: options.filters.allowedDomains }\n : undefined,\n user_location: options?.userLocation,\n search_context_size: options?.search_context_size,\n } satisfies WebSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgIA,SAAgB,UAAU,SAAwC;CAChE,OAAO;EACL,MAAM;EACN,SAAS,SAAS,SAAS,iBACvB,EAAE,iBAAiB,QAAQ,QAAQ,eAAe,IAClD,KAAA;EACJ,eAAe,SAAS;EACxB,qBAAqB,SAAS;CAChC;AACF"}
@@ -1,6 +1,5 @@
1
1
  import { OpenAI } from "openai";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
-
4
3
  //#region src/tools/webSearch.d.ts
5
4
  /**
6
5
  * User location configuration for geographic search refinement.
@@ -125,5 +124,5 @@ type WebSearchTool = OpenAI.Responses.WebSearchTool;
125
124
  */
126
125
  declare function webSearch(options?: WebSearchOptions): ServerTool;
127
126
  //#endregion
128
- export { WebSearchFilters, WebSearchOptions, WebSearchTool, webSearch };
127
+ export { WebSearchFilters, WebSearchOptions, WebSearchTool, WebSearchUserLocation, webSearch };
129
128
  //# sourceMappingURL=webSearch.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.d.cts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,qBAAA;;;;EAIf,IAAA;EASA;;;;EAJA,OAAA;EAmBe;;;EAff,IAAA;EAqBc;AAMhB;;EAvBE,MAAA;EAiCoC;;;;EA5BpC,QAAA;AAAA;;;AAuCF;UAjCiB,gBAAA;;;;;;EAMf,cAAA;AAAA;AAwFF;;;AAAA,UAlFiB,gBAAA;EAkFmB;;;;EA7ElC,OAAA,GAAU,gBAAA;;;;;EAKV,YAAA,GAAe,qBAAA;;;;;EAKf,mBAAA;AAAA;;;;KAMU,aAAA,GAAgB,MAAA,CAAa,SAAA,CAAU,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DnC,SAAA,CAAU,OAAA,GAAU,gBAAA,GAAmB,UAAA"}
1
+ {"version":3,"file":"webSearch.d.cts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;UAMiB;;;;EAIf;;;;;EAKA;;;;EAIA;;;;EAIA;;;;;EAKA;;;;;UAMe;;;;;;EAMf;;;;;UAMe;;;;;EAKf,UAAU;;;;;EAKV,eAAe;;;;;EAKf;;;;;KAMU,gBAAgB,OAAa,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DnC,UAAU,UAAU,mBAAmB"}
@@ -1,6 +1,5 @@
1
1
  import { OpenAI } from "openai";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
-
4
3
  //#region src/tools/webSearch.d.ts
5
4
  /**
6
5
  * User location configuration for geographic search refinement.
@@ -125,5 +124,5 @@ type WebSearchTool = OpenAI.Responses.WebSearchTool;
125
124
  */
126
125
  declare function webSearch(options?: WebSearchOptions): ServerTool;
127
126
  //#endregion
128
- export { WebSearchFilters, WebSearchOptions, WebSearchTool, webSearch };
127
+ export { WebSearchFilters, WebSearchOptions, WebSearchTool, WebSearchUserLocation, webSearch };
129
128
  //# sourceMappingURL=webSearch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.d.ts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,qBAAA;;;;EAIf,IAAA;EASA;;;;EAJA,OAAA;EAmBe;;;EAff,IAAA;EAqBc;AAMhB;;EAvBE,MAAA;EAiCoC;;;;EA5BpC,QAAA;AAAA;;;AAuCF;UAjCiB,gBAAA;;;;;;EAMf,cAAA;AAAA;AAwFF;;;AAAA,UAlFiB,gBAAA;EAkFmB;;;;EA7ElC,OAAA,GAAU,gBAAA;;;;;EAKV,YAAA,GAAe,qBAAA;;;;;EAKf,mBAAA;AAAA;;;;KAMU,aAAA,GAAgB,MAAA,CAAa,SAAA,CAAU,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DnC,SAAA,CAAU,OAAA,GAAU,gBAAA,GAAmB,UAAA"}
1
+ {"version":3,"file":"webSearch.d.ts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;UAMiB;;;;EAIf;;;;;EAKA;;;;EAIA;;;;EAIA;;;;;EAKA;;;;;UAMe;;;;;;EAMf;;;;;UAMe;;;;;EAKf,UAAU;;;;;EAKV,eAAe;;;;;EAKf;;;;;KAMU,gBAAgB,OAAa,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DnC,UAAU,UAAU,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.js","names":[],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * User location configuration for geographic search refinement.\n */\nexport interface WebSearchUserLocation {\n /**\n * The type of location. Currently only \"approximate\" is supported.\n */\n type: \"approximate\";\n /**\n * Two-letter ISO country code (e.g., \"US\", \"GB\").\n * @see https://en.wikipedia.org/wiki/ISO_3166-1\n */\n country?: string;\n /**\n * City name (e.g., \"San Francisco\", \"London\").\n */\n city?: string;\n /**\n * Region or state name (e.g., \"California\", \"London\").\n */\n region?: string;\n /**\n * IANA timezone (e.g., \"America/Los_Angeles\", \"Europe/London\").\n * @see https://timeapi.io/documentation/iana-timezones\n */\n timezone?: string;\n}\n\n/**\n * Domain filtering configuration for web search.\n */\nexport interface WebSearchFilters {\n /**\n * Allow-list of up to 100 domains to limit search results.\n * Omit the HTTP/HTTPS prefix (e.g., \"openai.com\" instead of \"https://openai.com/\").\n * Includes subdomains automatically.\n */\n allowedDomains?: string[];\n}\n\n/**\n * Options for the OpenAI web search tool.\n */\nexport interface WebSearchOptions {\n /**\n * Domain filtering configuration.\n * Limit results to a specific set of up to 100 domains.\n */\n filters?: WebSearchFilters;\n /**\n * Approximate user location for geographic search refinement.\n * Not supported for deep research models.\n */\n userLocation?: WebSearchUserLocation;\n /**\n * High level guidance for the amount of context window space to use for the\n * search. One of `low`, `medium`, or `high`. `medium` is the default.\n */\n search_context_size?: \"low\" | \"medium\" | \"high\";\n}\n\n/**\n * OpenAI web search tool type for the Responses API.\n */\nexport type WebSearchTool = OpenAIClient.Responses.WebSearchTool;\n\n/**\n * Creates a web search tool that allows OpenAI models to search the web\n * for up-to-date information before generating a response.\n *\n * Web search supports three main types:\n * 1. **Non-reasoning web search**: Quick lookups where the model passes queries\n * directly to the search tool.\n * 2. **Agentic search with reasoning models**: The model actively manages the\n * search process, analyzing results and deciding whether to keep searching.\n * 3. **Deep research**: Extended investigations using models like `o3-deep-research`\n * or `gpt-5` with high reasoning effort.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-web-search | OpenAI Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What was a positive news story from today?\", {\n * tools: [tools.webSearch()],\n * });\n *\n * // With domain filtering\n * const filteredResponse = await model.invoke(\"Latest AI research news\", {\n * tools: [tools.webSearch({\n * filters: {\n * allowedDomains: [\"arxiv.org\", \"nature.com\", \"science.org\"],\n * },\n * })],\n * });\n *\n * // With user location for geographic relevance\n * const localResponse = await model.invoke(\"What are the best restaurants near me?\", {\n * tools: [tools.webSearch({\n * userLocation: {\n * type: \"approximate\",\n * country: \"US\",\n * city: \"San Francisco\",\n * region: \"California\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n *\n * // Cache-only mode (no live internet access)\n * const cachedResponse = await model.invoke(\"Find information about OpenAI\", {\n * tools: [tools.webSearch({\n * externalWebAccess: false,\n * })],\n * });\n * ```\n */\nexport function webSearch(options?: WebSearchOptions): ServerTool {\n return {\n type: \"web_search\",\n filters: options?.filters?.allowedDomains\n ? { allowed_domains: options.filters.allowedDomains }\n : undefined,\n user_location: options?.userLocation,\n search_context_size: options?.search_context_size,\n } satisfies WebSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgIA,SAAgB,UAAU,SAAwC;AAChE,QAAO;EACL,MAAM;EACN,SAAS,SAAS,SAAS,iBACvB,EAAE,iBAAiB,QAAQ,QAAQ,gBAAgB,GACnD,KAAA;EACJ,eAAe,SAAS;EACxB,qBAAqB,SAAS;EAC/B"}
1
+ {"version":3,"file":"webSearch.js","names":[],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * User location configuration for geographic search refinement.\n */\nexport interface WebSearchUserLocation {\n /**\n * The type of location. Currently only \"approximate\" is supported.\n */\n type: \"approximate\";\n /**\n * Two-letter ISO country code (e.g., \"US\", \"GB\").\n * @see https://en.wikipedia.org/wiki/ISO_3166-1\n */\n country?: string;\n /**\n * City name (e.g., \"San Francisco\", \"London\").\n */\n city?: string;\n /**\n * Region or state name (e.g., \"California\", \"London\").\n */\n region?: string;\n /**\n * IANA timezone (e.g., \"America/Los_Angeles\", \"Europe/London\").\n * @see https://timeapi.io/documentation/iana-timezones\n */\n timezone?: string;\n}\n\n/**\n * Domain filtering configuration for web search.\n */\nexport interface WebSearchFilters {\n /**\n * Allow-list of up to 100 domains to limit search results.\n * Omit the HTTP/HTTPS prefix (e.g., \"openai.com\" instead of \"https://openai.com/\").\n * Includes subdomains automatically.\n */\n allowedDomains?: string[];\n}\n\n/**\n * Options for the OpenAI web search tool.\n */\nexport interface WebSearchOptions {\n /**\n * Domain filtering configuration.\n * Limit results to a specific set of up to 100 domains.\n */\n filters?: WebSearchFilters;\n /**\n * Approximate user location for geographic search refinement.\n * Not supported for deep research models.\n */\n userLocation?: WebSearchUserLocation;\n /**\n * High level guidance for the amount of context window space to use for the\n * search. One of `low`, `medium`, or `high`. `medium` is the default.\n */\n search_context_size?: \"low\" | \"medium\" | \"high\";\n}\n\n/**\n * OpenAI web search tool type for the Responses API.\n */\nexport type WebSearchTool = OpenAIClient.Responses.WebSearchTool;\n\n/**\n * Creates a web search tool that allows OpenAI models to search the web\n * for up-to-date information before generating a response.\n *\n * Web search supports three main types:\n * 1. **Non-reasoning web search**: Quick lookups where the model passes queries\n * directly to the search tool.\n * 2. **Agentic search with reasoning models**: The model actively manages the\n * search process, analyzing results and deciding whether to keep searching.\n * 3. **Deep research**: Extended investigations using models like `o3-deep-research`\n * or `gpt-5` with high reasoning effort.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-web-search | OpenAI Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What was a positive news story from today?\", {\n * tools: [tools.webSearch()],\n * });\n *\n * // With domain filtering\n * const filteredResponse = await model.invoke(\"Latest AI research news\", {\n * tools: [tools.webSearch({\n * filters: {\n * allowedDomains: [\"arxiv.org\", \"nature.com\", \"science.org\"],\n * },\n * })],\n * });\n *\n * // With user location for geographic relevance\n * const localResponse = await model.invoke(\"What are the best restaurants near me?\", {\n * tools: [tools.webSearch({\n * userLocation: {\n * type: \"approximate\",\n * country: \"US\",\n * city: \"San Francisco\",\n * region: \"California\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n *\n * // Cache-only mode (no live internet access)\n * const cachedResponse = await model.invoke(\"Find information about OpenAI\", {\n * tools: [tools.webSearch({\n * externalWebAccess: false,\n * })],\n * });\n * ```\n */\nexport function webSearch(options?: WebSearchOptions): ServerTool {\n return {\n type: \"web_search\",\n filters: options?.filters?.allowedDomains\n ? { allowed_domains: options.filters.allowedDomains }\n : undefined,\n user_location: options?.userLocation,\n search_context_size: options?.search_context_size,\n } satisfies WebSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgIA,SAAgB,UAAU,SAAwC;CAChE,OAAO;EACL,MAAM;EACN,SAAS,SAAS,SAAS,iBACvB,EAAE,iBAAiB,QAAQ,QAAQ,eAAe,IAClD,KAAA;EACJ,eAAe,SAAS;EACxB,qBAAqB,SAAS;CAChC;AACF"}
package/dist/types.d.cts CHANGED
@@ -3,7 +3,6 @@ import { BaseLanguageModelCallOptions } from "@langchain/core/language_models/ba
3
3
  import { InteropZodObject } from "@langchain/core/utils/types";
4
4
  import { ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatText, ResponseFormatTextGrammar, ResponseFormatTextPython } from "openai/resources/shared";
5
5
  import { TiktokenModel } from "js-tiktoken/lite";
6
-
7
6
  //#region src/types.d.ts
8
7
  /**
9
8
  * @see https://platform.openai.com/docs/models
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;AAoBA;;KAAY,iBAAA,GACR,MAAA,CAAa,SAAA,aACH,WAAA;AAAA,KAEF,oBAAA;AAAA,KACA,yBAAA;AAAA,KAEA,YAAA,GAAe,aAAA;AAAA,kBAEF,eAAA;EAPA;EASvB,WAAA;EAPU;;;;EAaV,SAAA;EAZU;;;;;EAmBV,mBAAA;EAjBsB;EAoBtB,IAAA;EApByB;EAuBzB,gBAAA;EArBuB;EAwBvB,eAAA;;EAGA,CAAA;EAyBO;EAtBP,SAAA,GAAY,MAAA;EAiDG;EA9Cf,IAAA;EAwDY;EArDZ,SAAA;EAqDgC;;;;EA/ChC,WAAA;EArBA;;;;;EA4BA,SAAA;EAbA;EAgBA,KAAA,EAAO,iBAAA;EAHP;;;;EAUA,WAAA,GAAc,MAAA;EAMd;;;;EAAA,IAAA;EAmBA;EAjBA,aAAA;EAsBA;;;EAjBA,OAAA;EAoBU;;;;;EAbV,YAAA,GAAe,YAAA;EAekB;;;;EAVjC,MAAA,GAAS,YAAA;EAcC;;;EATV,SAAA,GAAY,oBAAA;AAAA;AAAA,KAGF,wBAAA,GAA2B,MAAA,CAAa,cAAA;AAAA,UAEnC,iBAAA,SAA0B,4BAAA;EAUE;;;EAN3C,OAAA,GAAU,wBAAA;AAAA;AAcZ;;;AAAA,kBARyB,WAAA,SAAoB,eAAA;EAgDxB;EA9CnB,MAAA;EAqDQ;EAlDR,SAAA;AAAA;AAAA,UAGe,eAAA,SAAwB,eAAA;EAAA;;;;EAKvC,QAAA;EAMA;;;;EAAA,WAAA;EASA;EANA,cAAA,GAAiB,MAAA,CAAa,IAAA,CAAK,0BAAA;EA0BnC;;;;EApBA,oBAAA;EA2BA;;;;EArBA,yBAAA;EA6BY;;;;;;;;;;;;EAfZ,UAAA,GAAa,KAAA,CAAM,MAAA,CAAa,IAAA,CAAK,sBAAA;EA4CN;;;;;EArC/B,KAAA,GAAQ,MAAA,CAAa,IAAA,CAAK,wBAAA;EA8D1B;;;;;;EAtDA,SAAA,GAAY,MAAA,CAAa,SAAA;EA6FW;;AAGtC;;;;EAxFE,UAAA;EAyFyB;;;;EAnFzB,YAAA,GAAe,MAAA,CAAa,SAAA,CAAU,oBAAA;EAsFxB;AACf;;;;EAhFC,cAAA;EAsFkB;;;EAjFlB,oBAAA,GAAuB,yBAAA;AAAA;AAAA,UAGR,gBAAA;EA0EyB;;;EAtExC,qBAAA;EA0EkB;;;EArElB,iBAAA;EA2EgD;;AAOlD;;;;EA1EE,0BAAA;EAoFE;;;;;;EA5EF,4BAAA;EAmEuB;;;;;;;EA1DvB,sCAAA;EAmEgE;;AAIlE;;;;;;EA7DE,uCAAA;EAkEE;;;;;EA3DF,mBAAA;EA0DE;;;;AAGJ;EAtDE,mBAAA;;;;;EAMA,oBAAA,SAA6B,OAAA;AAAA;AAAA,UAGd,oBAAA,SACP,eAAA,EAAiB,gBAAA;EACzB,gBAAA;EACA,cAAA;EACA,cAAA;AAAA;AAAA,KAGG,kCAAA,GAAqC,IAAA,CACxC,wBAAA;EAGA,WAAA,EAAa,IAAA,CAAK,wBAAA;;;;;IAMhB,MAAA,EAAQ,MAAA,gBAAsB,gBAAA;EAAA;AAAA;;;;KAOtB,0BAAA,GAA6B,IAAA,CACvC,MAAA,CAAa,SAAA,CAAU,qBAAA;;;;;;EAQvB,OAAA,EAAS,KAAA,CACP,MAAA,CAAa,SAAA,CAAU,qBAAA,CAAsB,OAAA;IAAY,KAAA;EAAA;AAAA;AAAA,KAIjD,wBAAA,GACR,kBAAA,GACA,wBAAA,GACA,yBAAA,GACA,wBAAA,GACA,kCAAA;AAAA,KAEQ,2BAAA,GACR,kBAAA,GACA,wBAAA,GACA,wBAAA"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;KAoBY,oBACR,OAAa,sBACH;KAEF;KACA;KAEA,eAAe;kBAEF;;EAEvB;;;;;EAMA;;;;;;EAOA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA,YAAY;;EAGZ;;EAGA;;;;;EAMA;;;;;;EAOA;;EAGA,OAAO;;;;;EAOP,cAAc;;;;;EAMd;;EAEA;;;;EAKA;;;;;;EAOA,eAAe;;;;;EAKf,SAAS;;;;EAKT,YAAY;;KAGF,2BAA2B,OAAa;UAEnC,0BAA0B;;;;EAIzC,UAAU;;;;;kBAMa,oBAAoB;;EAE3C;;EAGA;;UAGe,wBAAwB;;;;;EAKvC;;;;;EAMA;;EAGA,iBAAiB,OAAa,KAAK;;;;;EAMnC;;;;;EAMA;;;;;;;;;;;;;EAcA,aAAa,MAAM,OAAa,KAAK;;;;;;EAOrC,QAAQ,OAAa,KAAK;;;;;;;EAQ1B,YAAY,OAAa;;;;;;;EAQzB;;;;;EAMA,eAAe,OAAa,UAAU;;;;;;EAOtC;;;;EAKA,uBAAuB;;UAGR;;;;EAIf;;;;EAKA;;;;;;;EAQA;;;;;;;EAQA;;;;;;;;EASA;;;;;;;;;EAUA;;;;;;EAOA;;;;;;EAOA;;;;;EAMA,6BAA6B;;UAGd,6BACP,iBAAiB;EACzB;EACA;EACA;;KAGG,qCAAqC,KACxC;EAGA,aAAa,KAAK;;;;;IAMhB,QAAQ,sBAAsB;;;;;;KAOtB,6BAA6B,KACvC,OAAa,UAAU;;;;;;EAQvB,SAAS,MACP,OAAa,UAAU,sBAAsB;IAAY;;;KAIjD,2BACR,qBACA,2BACA,4BACA,2BACA;KAEQ,8BACR,qBACA,2BACA"}
package/dist/types.d.ts CHANGED
@@ -3,7 +3,6 @@ import { InteropZodObject } from "@langchain/core/utils/types";
3
3
  import { BaseLanguageModelCallOptions } from "@langchain/core/language_models/base";
4
4
  import { ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatText, ResponseFormatTextGrammar, ResponseFormatTextPython } from "openai/resources/shared";
5
5
  import { TiktokenModel } from "js-tiktoken/lite";
6
-
7
6
  //#region src/types.d.ts
8
7
  /**
9
8
  * @see https://platform.openai.com/docs/models
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;AAoBA;;KAAY,iBAAA,GACR,MAAA,CAAa,SAAA,aACH,WAAA;AAAA,KAEF,oBAAA;AAAA,KACA,yBAAA;AAAA,KAEA,YAAA,GAAe,aAAA;AAAA,kBAEF,eAAA;EAPA;EASvB,WAAA;EAPU;;;;EAaV,SAAA;EAZU;;;;;EAmBV,mBAAA;EAjBsB;EAoBtB,IAAA;EApByB;EAuBzB,gBAAA;EArBuB;EAwBvB,eAAA;;EAGA,CAAA;EAyBO;EAtBP,SAAA,GAAY,MAAA;EAiDG;EA9Cf,IAAA;EAwDY;EArDZ,SAAA;EAqDgC;;;;EA/ChC,WAAA;EArBA;;;;;EA4BA,SAAA;EAbA;EAgBA,KAAA,EAAO,iBAAA;EAHP;;;;EAUA,WAAA,GAAc,MAAA;EAMd;;;;EAAA,IAAA;EAmBA;EAjBA,aAAA;EAsBA;;;EAjBA,OAAA;EAoBU;;;;;EAbV,YAAA,GAAe,YAAA;EAekB;;;;EAVjC,MAAA,GAAS,YAAA;EAcC;;;EATV,SAAA,GAAY,oBAAA;AAAA;AAAA,KAGF,wBAAA,GAA2B,MAAA,CAAa,cAAA;AAAA,UAEnC,iBAAA,SAA0B,4BAAA;EAUE;;;EAN3C,OAAA,GAAU,wBAAA;AAAA;AAcZ;;;AAAA,kBARyB,WAAA,SAAoB,eAAA;EAgDxB;EA9CnB,MAAA;EAqDQ;EAlDR,SAAA;AAAA;AAAA,UAGe,eAAA,SAAwB,eAAA;EAAA;;;;EAKvC,QAAA;EAMA;;;;EAAA,WAAA;EASA;EANA,cAAA,GAAiB,MAAA,CAAa,IAAA,CAAK,0BAAA;EA0BnC;;;;EApBA,oBAAA;EA2BA;;;;EArBA,yBAAA;EA6BY;;;;;;;;;;;;EAfZ,UAAA,GAAa,KAAA,CAAM,MAAA,CAAa,IAAA,CAAK,sBAAA;EA4CN;;;;;EArC/B,KAAA,GAAQ,MAAA,CAAa,IAAA,CAAK,wBAAA;EA8D1B;;;;;;EAtDA,SAAA,GAAY,MAAA,CAAa,SAAA;EA6FW;;AAGtC;;;;EAxFE,UAAA;EAyFyB;;;;EAnFzB,YAAA,GAAe,MAAA,CAAa,SAAA,CAAU,oBAAA;EAsFxB;AACf;;;;EAhFC,cAAA;EAsFkB;;;EAjFlB,oBAAA,GAAuB,yBAAA;AAAA;AAAA,UAGR,gBAAA;EA0EyB;;;EAtExC,qBAAA;EA0EkB;;;EArElB,iBAAA;EA2EgD;;AAOlD;;;;EA1EE,0BAAA;EAoFE;;;;;;EA5EF,4BAAA;EAmEuB;;;;;;;EA1DvB,sCAAA;EAmEgE;;AAIlE;;;;;;EA7DE,uCAAA;EAkEE;;;;;EA3DF,mBAAA;EA0DE;;;;AAGJ;EAtDE,mBAAA;;;;;EAMA,oBAAA,SAA6B,OAAA;AAAA;AAAA,UAGd,oBAAA,SACP,eAAA,EAAiB,gBAAA;EACzB,gBAAA;EACA,cAAA;EACA,cAAA;AAAA;AAAA,KAGG,kCAAA,GAAqC,IAAA,CACxC,wBAAA;EAGA,WAAA,EAAa,IAAA,CAAK,wBAAA;;;;;IAMhB,MAAA,EAAQ,MAAA,gBAAsB,gBAAA;EAAA;AAAA;;;;KAOtB,0BAAA,GAA6B,IAAA,CACvC,MAAA,CAAa,SAAA,CAAU,qBAAA;;;;;;EAQvB,OAAA,EAAS,KAAA,CACP,MAAA,CAAa,SAAA,CAAU,qBAAA,CAAsB,OAAA;IAAY,KAAA;EAAA;AAAA;AAAA,KAIjD,wBAAA,GACR,kBAAA,GACA,wBAAA,GACA,yBAAA,GACA,wBAAA,GACA,kCAAA;AAAA,KAEQ,2BAAA,GACR,kBAAA,GACA,wBAAA,GACA,wBAAA"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;KAoBY,oBACR,OAAa,sBACH;KAEF;KACA;KAEA,eAAe;kBAEF;;EAEvB;;;;;EAMA;;;;;;EAOA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA,YAAY;;EAGZ;;EAGA;;;;;EAMA;;;;;;EAOA;;EAGA,OAAO;;;;;EAOP,cAAc;;;;;EAMd;;EAEA;;;;EAKA;;;;;;EAOA,eAAe;;;;;EAKf,SAAS;;;;EAKT,YAAY;;KAGF,2BAA2B,OAAa;UAEnC,0BAA0B;;;;EAIzC,UAAU;;;;;kBAMa,oBAAoB;;EAE3C;;EAGA;;UAGe,wBAAwB;;;;;EAKvC;;;;;EAMA;;EAGA,iBAAiB,OAAa,KAAK;;;;;EAMnC;;;;;EAMA;;;;;;;;;;;;;EAcA,aAAa,MAAM,OAAa,KAAK;;;;;;EAOrC,QAAQ,OAAa,KAAK;;;;;;;EAQ1B,YAAY,OAAa;;;;;;;EAQzB;;;;;EAMA,eAAe,OAAa,UAAU;;;;;;EAOtC;;;;EAKA,uBAAuB;;UAGR;;;;EAIf;;;;EAKA;;;;;;;EAQA;;;;;;;EAQA;;;;;;;;EASA;;;;;;;;;EAUA;;;;;;EAOA;;;;;;EAOA;;;;;EAMA,6BAA6B;;UAGd,6BACP,iBAAiB;EACzB;EACA;EACA;;KAGG,qCAAqC,KACxC;EAGA,aAAa,KAAK;;;;;IAMhB,QAAQ,sBAAsB;;;;;;KAOtB,6BAA6B,KACvC,OAAa,UAAU;;;;;;EAQvB,SAAS,MACP,OAAa,UAAU,sBAAsB;IAAY;;;KAIjD,2BACR,qBACA,2BACA,4BACA,2BACA;KAEQ,8BACR,qBACA,2BACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"azure.cjs","names":["iife"],"sources":["../../src/utils/azure.ts"],"sourcesContent":["import { getEnv } from \"@langchain/core/utils/env\";\nimport { iife } from \"./misc.js\";\n\nexport interface OpenAIEndpointConfig {\n azureOpenAIApiDeploymentName?: string;\n azureOpenAIApiInstanceName?: string;\n azureOpenAIApiKey?: string;\n azureADTokenProvider?: () => Promise<string>;\n azureOpenAIBasePath?: string;\n baseURL?: string | null;\n azureOpenAIEndpoint?: string;\n}\n\n/**\n * This function generates an endpoint URL for (Azure) OpenAI\n * based on the configuration parameters provided.\n *\n * @param {OpenAIEndpointConfig} config - The configuration object for the (Azure) endpoint.\n *\n * @property {string} config.azureOpenAIApiDeploymentName - The deployment name of Azure OpenAI.\n * @property {string} config.azureOpenAIApiInstanceName - The instance name of Azure OpenAI, e.g. `example-resource`.\n * @property {string} config.azureOpenAIApiKey - The API Key for Azure OpenAI.\n * @property {string} config.azureOpenAIBasePath - The base path for Azure OpenAI, e.g. `https://example-resource.azure.openai.com/openai/deployments/`.\n * @property {string} config.baseURL - Some other custom base path URL.\n * @property {string} config.azureOpenAIEndpoint - The endpoint for the Azure OpenAI instance, e.g. `https://example-resource.azure.openai.com/`.\n *\n * The function operates as follows:\n * - If both `azureOpenAIBasePath` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`).\n * - If both `azureOpenAIEndpoint` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`).\n * - If `azureOpenAIApiKey` is provided, it checks for `azureOpenAIApiInstanceName` and `azureOpenAIApiDeploymentName` and throws an error if any of these is missing. If both are provided, it generates an URL incorporating these parameters.\n * - If none of the above conditions are met, return any custom `baseURL`.\n * - The function returns the generated URL as a string, or undefined if no custom paths are specified.\n *\n * @throws Will throw an error if the necessary parameters for generating the URL are missing.\n *\n * @returns {string | undefined} The generated (Azure) OpenAI endpoint URL.\n */\nexport function getEndpoint(config: OpenAIEndpointConfig) {\n const {\n azureOpenAIApiDeploymentName,\n azureOpenAIApiInstanceName,\n azureOpenAIApiKey,\n azureOpenAIBasePath,\n baseURL,\n azureADTokenProvider,\n azureOpenAIEndpoint,\n } = config;\n\n if (\n (azureOpenAIApiKey || azureADTokenProvider) &&\n azureOpenAIBasePath &&\n azureOpenAIApiDeploymentName\n ) {\n return `${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`;\n }\n if (\n (azureOpenAIApiKey || azureADTokenProvider) &&\n azureOpenAIEndpoint &&\n azureOpenAIApiDeploymentName\n ) {\n return `${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`;\n }\n\n if (azureOpenAIApiKey || azureADTokenProvider) {\n if (!azureOpenAIApiInstanceName) {\n throw new Error(\n \"azureOpenAIApiInstanceName is required when using azureOpenAIApiKey\"\n );\n }\n if (!azureOpenAIApiDeploymentName) {\n throw new Error(\n \"azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey\"\n );\n }\n return `https://${azureOpenAIApiInstanceName}.openai.azure.com/openai/deployments/${azureOpenAIApiDeploymentName}`;\n }\n\n return baseURL;\n}\n\ntype HeaderValue = string | undefined | null;\nexport type HeadersLike =\n | Headers\n | readonly HeaderValue[][]\n | Record<string, HeaderValue | readonly HeaderValue[]>\n | undefined\n | null\n // NullableHeaders\n | { values: Headers; [key: string]: unknown };\n\nexport function isHeaders(headers: unknown): headers is Headers {\n return (\n typeof Headers !== \"undefined\" &&\n headers !== null &&\n typeof headers === \"object\" &&\n Object.prototype.toString.call(headers) === \"[object Headers]\"\n );\n}\n\n/**\n * Normalizes various header formats into a consistent Record format.\n *\n * This function accepts headers in multiple formats and converts them to a\n * Record<string, HeaderValue | readonly HeaderValue[]> for consistent handling.\n *\n * @param headers - The headers to normalize. Can be:\n * - A Headers instance\n * - An array of [key, value] pairs\n * - A plain object with string keys\n * - A NullableHeaders-like object with a 'values' property containing Headers\n * - null or undefined\n * @returns A normalized Record containing the header key-value pairs\n *\n * @example\n * ```ts\n * // With Headers instance\n * const headers1 = new Headers([['content-type', 'application/json']]);\n * const normalized1 = normalizeHeaders(headers1);\n *\n * // With plain object\n * const headers2 = { 'content-type': 'application/json' };\n * const normalized2 = normalizeHeaders(headers2);\n *\n * // With array of pairs\n * const headers3 = [['content-type', 'application/json']];\n * const normalized3 = normalizeHeaders(headers3);\n * ```\n */\nexport function normalizeHeaders(\n headers: HeadersLike\n): Record<string, HeaderValue | readonly HeaderValue[]> {\n const output = iife(() => {\n // If headers is a Headers instance\n if (isHeaders(headers)) {\n return headers;\n }\n // If headers is an array of [key, value] pairs\n else if (Array.isArray(headers)) {\n return new Headers(headers);\n }\n // If headers is a NullableHeaders-like object (has 'values' property that is a Headers)\n else if (\n typeof headers === \"object\" &&\n headers !== null &&\n \"values\" in headers &&\n isHeaders(headers.values)\n ) {\n return headers.values;\n }\n // If headers is a plain object\n else if (typeof headers === \"object\" && headers !== null) {\n const entries: [string, string][] = Object.entries(headers)\n .filter(([, v]) => typeof v === \"string\")\n .map(([k, v]) => [k, v as string]);\n return new Headers(entries);\n }\n return new Headers();\n });\n\n return Object.fromEntries(output.entries());\n}\n\nexport function getFormattedEnv() {\n let env = getEnv();\n if (env === \"node\" || env === \"deno\") {\n env = `(${env}/${process.version}; ${process.platform}; ${process.arch})`;\n }\n return env;\n}\n\n// Note: ideally version would be imported from package.json, but there's\n// currently no good way to do that for all supported environments (Node, Deno, Browser).\nexport function getHeadersWithUserAgent(\n headers: HeadersLike,\n isAzure = false,\n version = \"1.0.0\"\n): Record<string, string> {\n const normalizedHeaders = normalizeHeaders(headers);\n const env = getFormattedEnv();\n const library = `langchainjs${isAzure ? \"-azure\" : \"\"}-openai`;\n return {\n ...normalizedHeaders,\n \"User-Agent\": normalizedHeaders[\"User-Agent\"]\n ? `${library}/${version} (${env})${normalizedHeaders[\"User-Agent\"]}`\n : `${library}/${version} (${env})`,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,YAAY,QAA8B;CACxD,MAAM,EACJ,8BACA,4BACA,mBACA,qBACA,SACA,sBACA,wBACE;AAEJ,MACG,qBAAqB,yBACtB,uBACA,6BAEA,QAAO,GAAG,oBAAoB,GAAG;AAEnC,MACG,qBAAqB,yBACtB,uBACA,6BAEA,QAAO,GAAG,oBAAoB,sBAAsB;AAGtD,KAAI,qBAAqB,sBAAsB;AAC7C,MAAI,CAAC,2BACH,OAAM,IAAI,MACR,sEACD;AAEH,MAAI,CAAC,6BACH,OAAM,IAAI,MACR,oFACD;AAEH,SAAO,WAAW,2BAA2B,uCAAuC;;AAGtF,QAAO;;AAaT,SAAgB,UAAU,SAAsC;AAC9D,QACE,OAAO,YAAY,eACnB,YAAY,QACZ,OAAO,YAAY,YACnB,OAAO,UAAU,SAAS,KAAK,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiChD,SAAgB,iBACd,SACsD;CACtD,MAAM,SAASA,aAAAA,WAAW;AAExB,MAAI,UAAU,QAAQ,CACpB,QAAO;WAGA,MAAM,QAAQ,QAAQ,CAC7B,QAAO,IAAI,QAAQ,QAAQ;WAI3B,OAAO,YAAY,YACnB,YAAY,QACZ,YAAY,WACZ,UAAU,QAAQ,OAAO,CAEzB,QAAO,QAAQ;WAGR,OAAO,YAAY,YAAY,YAAY,MAAM;GACxD,MAAM,UAA8B,OAAO,QAAQ,QAAQ,CACxD,QAAQ,GAAG,OAAO,OAAO,MAAM,SAAS,CACxC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,EAAY,CAAC;AACpC,UAAO,IAAI,QAAQ,QAAQ;;AAE7B,SAAO,IAAI,SAAS;GACpB;AAEF,QAAO,OAAO,YAAY,OAAO,SAAS,CAAC;;AAG7C,SAAgB,kBAAkB;CAChC,IAAI,OAAA,GAAA,0BAAA,SAAc;AAClB,KAAI,QAAQ,UAAU,QAAQ,OAC5B,OAAM,IAAI,IAAI,GAAG,QAAQ,QAAQ,IAAI,QAAQ,SAAS,IAAI,QAAQ,KAAK;AAEzE,QAAO;;AAKT,SAAgB,wBACd,SACA,UAAU,OACV,UAAU,SACc;CACxB,MAAM,oBAAoB,iBAAiB,QAAQ;CACnD,MAAM,MAAM,iBAAiB;CAC7B,MAAM,UAAU,cAAc,UAAU,WAAW,GAAG;AACtD,QAAO;EACL,GAAG;EACH,cAAc,kBAAkB,gBAC5B,GAAG,QAAQ,GAAG,QAAQ,IAAI,IAAI,GAAG,kBAAkB,kBACnD,GAAG,QAAQ,GAAG,QAAQ,IAAI,IAAI;EACnC"}
1
+ {"version":3,"file":"azure.cjs","names":["iife"],"sources":["../../src/utils/azure.ts"],"sourcesContent":["import { getEnv } from \"@langchain/core/utils/env\";\nimport { iife } from \"./misc.js\";\n\nexport interface OpenAIEndpointConfig {\n azureOpenAIApiDeploymentName?: string;\n azureOpenAIApiInstanceName?: string;\n azureOpenAIApiKey?: string;\n azureADTokenProvider?: () => Promise<string>;\n azureOpenAIBasePath?: string;\n baseURL?: string | null;\n azureOpenAIEndpoint?: string;\n}\n\n/**\n * This function generates an endpoint URL for (Azure) OpenAI\n * based on the configuration parameters provided.\n *\n * @param {OpenAIEndpointConfig} config - The configuration object for the (Azure) endpoint.\n *\n * @property {string} config.azureOpenAIApiDeploymentName - The deployment name of Azure OpenAI.\n * @property {string} config.azureOpenAIApiInstanceName - The instance name of Azure OpenAI, e.g. `example-resource`.\n * @property {string} config.azureOpenAIApiKey - The API Key for Azure OpenAI.\n * @property {string} config.azureOpenAIBasePath - The base path for Azure OpenAI, e.g. `https://example-resource.azure.openai.com/openai/deployments/`.\n * @property {string} config.baseURL - Some other custom base path URL.\n * @property {string} config.azureOpenAIEndpoint - The endpoint for the Azure OpenAI instance, e.g. `https://example-resource.azure.openai.com/`.\n *\n * The function operates as follows:\n * - If both `azureOpenAIBasePath` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`).\n * - If both `azureOpenAIEndpoint` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`).\n * - If `azureOpenAIApiKey` is provided, it checks for `azureOpenAIApiInstanceName` and `azureOpenAIApiDeploymentName` and throws an error if any of these is missing. If both are provided, it generates an URL incorporating these parameters.\n * - If none of the above conditions are met, return any custom `baseURL`.\n * - The function returns the generated URL as a string, or undefined if no custom paths are specified.\n *\n * @throws Will throw an error if the necessary parameters for generating the URL are missing.\n *\n * @returns {string | undefined} The generated (Azure) OpenAI endpoint URL.\n */\nexport function getEndpoint(config: OpenAIEndpointConfig) {\n const {\n azureOpenAIApiDeploymentName,\n azureOpenAIApiInstanceName,\n azureOpenAIApiKey,\n azureOpenAIBasePath,\n baseURL,\n azureADTokenProvider,\n azureOpenAIEndpoint,\n } = config;\n\n if (\n (azureOpenAIApiKey || azureADTokenProvider) &&\n azureOpenAIBasePath &&\n azureOpenAIApiDeploymentName\n ) {\n return `${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`;\n }\n if (\n (azureOpenAIApiKey || azureADTokenProvider) &&\n azureOpenAIEndpoint &&\n azureOpenAIApiDeploymentName\n ) {\n return `${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`;\n }\n\n if (azureOpenAIApiKey || azureADTokenProvider) {\n if (!azureOpenAIApiInstanceName) {\n throw new Error(\n \"azureOpenAIApiInstanceName is required when using azureOpenAIApiKey\"\n );\n }\n if (!azureOpenAIApiDeploymentName) {\n throw new Error(\n \"azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey\"\n );\n }\n return `https://${azureOpenAIApiInstanceName}.openai.azure.com/openai/deployments/${azureOpenAIApiDeploymentName}`;\n }\n\n return baseURL;\n}\n\ntype HeaderValue = string | undefined | null;\nexport type HeadersLike =\n | Headers\n | readonly HeaderValue[][]\n | Record<string, HeaderValue | readonly HeaderValue[]>\n | undefined\n | null\n // NullableHeaders\n | { values: Headers; [key: string]: unknown };\n\nexport function isHeaders(headers: unknown): headers is Headers {\n return (\n typeof Headers !== \"undefined\" &&\n headers !== null &&\n typeof headers === \"object\" &&\n Object.prototype.toString.call(headers) === \"[object Headers]\"\n );\n}\n\n/**\n * Normalizes various header formats into a consistent Record format.\n *\n * This function accepts headers in multiple formats and converts them to a\n * Record<string, HeaderValue | readonly HeaderValue[]> for consistent handling.\n *\n * @param headers - The headers to normalize. Can be:\n * - A Headers instance\n * - An array of [key, value] pairs\n * - A plain object with string keys\n * - A NullableHeaders-like object with a 'values' property containing Headers\n * - null or undefined\n * @returns A normalized Record containing the header key-value pairs\n *\n * @example\n * ```ts\n * // With Headers instance\n * const headers1 = new Headers([['content-type', 'application/json']]);\n * const normalized1 = normalizeHeaders(headers1);\n *\n * // With plain object\n * const headers2 = { 'content-type': 'application/json' };\n * const normalized2 = normalizeHeaders(headers2);\n *\n * // With array of pairs\n * const headers3 = [['content-type', 'application/json']];\n * const normalized3 = normalizeHeaders(headers3);\n * ```\n */\nexport function normalizeHeaders(\n headers: HeadersLike\n): Record<string, HeaderValue | readonly HeaderValue[]> {\n const output = iife(() => {\n // If headers is a Headers instance\n if (isHeaders(headers)) {\n return headers;\n }\n // If headers is an array of [key, value] pairs\n else if (Array.isArray(headers)) {\n return new Headers(headers);\n }\n // If headers is a NullableHeaders-like object (has 'values' property that is a Headers)\n else if (\n typeof headers === \"object\" &&\n headers !== null &&\n \"values\" in headers &&\n isHeaders(headers.values)\n ) {\n return headers.values;\n }\n // If headers is a plain object\n else if (typeof headers === \"object\" && headers !== null) {\n const entries: [string, string][] = Object.entries(headers)\n .filter(([, v]) => typeof v === \"string\")\n .map(([k, v]) => [k, v as string]);\n return new Headers(entries);\n }\n return new Headers();\n });\n\n return Object.fromEntries(output.entries());\n}\n\nexport function getFormattedEnv() {\n let env = getEnv();\n if (env === \"node\" || env === \"deno\") {\n env = `(${env}/${process.version}; ${process.platform}; ${process.arch})`;\n }\n return env;\n}\n\n// Note: ideally version would be imported from package.json, but there's\n// currently no good way to do that for all supported environments (Node, Deno, Browser).\nexport function getHeadersWithUserAgent(\n headers: HeadersLike,\n isAzure = false,\n version = \"1.0.0\"\n): Record<string, string> {\n const normalizedHeaders = normalizeHeaders(headers);\n const env = getFormattedEnv();\n const library = `langchainjs${isAzure ? \"-azure\" : \"\"}-openai`;\n return {\n ...normalizedHeaders,\n \"User-Agent\": normalizedHeaders[\"User-Agent\"]\n ? `${library}/${version} (${env})${normalizedHeaders[\"User-Agent\"]}`\n : `${library}/${version} (${env})`,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,YAAY,QAA8B;CACxD,MAAM,EACJ,8BACA,4BACA,mBACA,qBACA,SACA,sBACA,wBACE;CAEJ,KACG,qBAAqB,yBACtB,uBACA,8BAEA,OAAO,GAAG,oBAAoB,GAAG;CAEnC,KACG,qBAAqB,yBACtB,uBACA,8BAEA,OAAO,GAAG,oBAAoB,sBAAsB;CAGtD,IAAI,qBAAqB,sBAAsB;EAC7C,IAAI,CAAC,4BACH,MAAM,IAAI,MACR,qEACF;EAEF,IAAI,CAAC,8BACH,MAAM,IAAI,MACR,mFACF;EAEF,OAAO,WAAW,2BAA2B,uCAAuC;CACtF;CAEA,OAAO;AACT;AAYA,SAAgB,UAAU,SAAsC;CAC9D,OACE,OAAO,YAAY,eACnB,YAAY,QACZ,OAAO,YAAY,YACnB,OAAO,UAAU,SAAS,KAAK,OAAO,MAAM;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,SAAgB,iBACd,SACsD;CACtD,MAAM,SAASA,aAAAA,WAAW;EAExB,IAAI,UAAU,OAAO,GACnB,OAAO;OAGJ,IAAI,MAAM,QAAQ,OAAO,GAC5B,OAAO,IAAI,QAAQ,OAAO;OAGvB,IACH,OAAO,YAAY,YACnB,YAAY,QACZ,YAAY,WACZ,UAAU,QAAQ,MAAM,GAExB,OAAO,QAAQ;OAGZ,IAAI,OAAO,YAAY,YAAY,YAAY,MAAM;GACxD,MAAM,UAA8B,OAAO,QAAQ,OAAO,CAAC,CACxD,QAAQ,GAAG,OAAO,OAAO,MAAM,QAAQ,CAAC,CACxC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,CAAW,CAAC;GACnC,OAAO,IAAI,QAAQ,OAAO;EAC5B;EACA,OAAO,IAAI,QAAQ;CACrB,CAAC;CAED,OAAO,OAAO,YAAY,OAAO,QAAQ,CAAC;AAC5C;AAEA,SAAgB,kBAAkB;CAChC,IAAI,OAAA,GAAA,0BAAA,OAAA,CAAa;CACjB,IAAI,QAAQ,UAAU,QAAQ,QAC5B,MAAM,IAAI,IAAI,GAAG,QAAQ,QAAQ,IAAI,QAAQ,SAAS,IAAI,QAAQ,KAAK;CAEzE,OAAO;AACT;AAIA,SAAgB,wBACd,SACA,UAAU,OACV,UAAU,SACc;CACxB,MAAM,oBAAoB,iBAAiB,OAAO;CAClD,MAAM,MAAM,gBAAgB;CAC5B,MAAM,UAAU,cAAc,UAAU,WAAW,GAAG;CACtD,OAAO;EACL,GAAG;EACH,cAAc,kBAAkB,gBAC5B,GAAG,QAAQ,GAAG,QAAQ,IAAI,IAAI,GAAG,kBAAkB,kBACnD,GAAG,QAAQ,GAAG,QAAQ,IAAI,IAAI;CACpC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"azure.d.cts","names":[],"sources":["../../src/utils/azure.ts"],"mappings":";UAGiB,oBAAA;EACf,4BAAA;EACA,0BAAA;EACA,iBAAA;EACA,oBAAA,SAA6B,OAAA;EAC7B,mBAAA;EACA,OAAA;EACA,mBAAA;AAAA;;;;;;;AA2BF;;;;;AAyCC;;;;;AAGD;;;;;;;;iBA5CgB,WAAA,CAAY,MAAA,EAAQ,oBAAA;AAAA,KA2C/B,WAAA;AAAA,KACO,WAAA,GACR,OAAA,YACS,WAAA,OACT,MAAA,SAAe,WAAA,YAAuB,WAAA;EAIpC,MAAA,EAAQ,OAAA;EAAA,CAAU,GAAA;AAAA;AAAA,iBAER,SAAA,CAAU,OAAA,YAAmB,OAAA,IAAW,OAAA;;;;;;;AAAxD;;;;;;;;;AAsCA;;;;;;;;;;;;;;iBAAgB,gBAAA,CACd,OAAA,EAAS,WAAA,GACR,MAAA,SAAe,WAAA,YAAuB,WAAA;AAAA,iBAgCzB,eAAA,CAAA;AAAA,iBAUA,uBAAA,CACd,OAAA,EAAS,WAAA,EACT,OAAA,YACA,OAAA,YACC,MAAA"}
1
+ {"version":3,"file":"azure.d.cts","names":[],"sources":["../../src/utils/azure.ts"],"mappings":";UAGiB;EACf;EACA;EACA;EACA,6BAA6B;EAC7B;EACA;EACA;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2Bc,YAAY,QAAQ;KA2C/B;KACO,cACR,mBACS,kBACT,eAAe,uBAAuB;EAIpC,QAAQ;GAAU;;iBAER,UAAU,mBAAmB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCxC,iBACd,SAAS,cACR,eAAe,uBAAuB;iBAgCzB;iBAUA,wBACd,SAAS,aACT,mBACA,mBACC"}
@@ -1 +1 @@
1
- {"version":3,"file":"azure.d.ts","names":[],"sources":["../../src/utils/azure.ts"],"mappings":";UAGiB,oBAAA;EACf,4BAAA;EACA,0BAAA;EACA,iBAAA;EACA,oBAAA,SAA6B,OAAA;EAC7B,mBAAA;EACA,OAAA;EACA,mBAAA;AAAA;;;;;;;AA2BF;;;;;AAyCC;;;;;AAGD;;;;;;;;iBA5CgB,WAAA,CAAY,MAAA,EAAQ,oBAAA;AAAA,KA2C/B,WAAA;AAAA,KACO,WAAA,GACR,OAAA,YACS,WAAA,OACT,MAAA,SAAe,WAAA,YAAuB,WAAA;EAIpC,MAAA,EAAQ,OAAA;EAAA,CAAU,GAAA;AAAA;AAAA,iBAER,SAAA,CAAU,OAAA,YAAmB,OAAA,IAAW,OAAA;;;;;;;AAAxD;;;;;;;;;AAsCA;;;;;;;;;;;;;;iBAAgB,gBAAA,CACd,OAAA,EAAS,WAAA,GACR,MAAA,SAAe,WAAA,YAAuB,WAAA;AAAA,iBAgCzB,eAAA,CAAA;AAAA,iBAUA,uBAAA,CACd,OAAA,EAAS,WAAA,EACT,OAAA,YACA,OAAA,YACC,MAAA"}
1
+ {"version":3,"file":"azure.d.ts","names":[],"sources":["../../src/utils/azure.ts"],"mappings":";UAGiB;EACf;EACA;EACA;EACA,6BAA6B;EAC7B;EACA;EACA;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2Bc,YAAY,QAAQ;KA2C/B;KACO,cACR,mBACS,kBACT,eAAe,uBAAuB;EAIpC,QAAQ;GAAU;;iBAER,UAAU,mBAAmB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCxC,iBACd,SAAS,cACR,eAAe,uBAAuB;iBAgCzB;iBAUA,wBACd,SAAS,aACT,mBACA,mBACC"}
@@ -1 +1 @@
1
- {"version":3,"file":"azure.js","names":[],"sources":["../../src/utils/azure.ts"],"sourcesContent":["import { getEnv } from \"@langchain/core/utils/env\";\nimport { iife } from \"./misc.js\";\n\nexport interface OpenAIEndpointConfig {\n azureOpenAIApiDeploymentName?: string;\n azureOpenAIApiInstanceName?: string;\n azureOpenAIApiKey?: string;\n azureADTokenProvider?: () => Promise<string>;\n azureOpenAIBasePath?: string;\n baseURL?: string | null;\n azureOpenAIEndpoint?: string;\n}\n\n/**\n * This function generates an endpoint URL for (Azure) OpenAI\n * based on the configuration parameters provided.\n *\n * @param {OpenAIEndpointConfig} config - The configuration object for the (Azure) endpoint.\n *\n * @property {string} config.azureOpenAIApiDeploymentName - The deployment name of Azure OpenAI.\n * @property {string} config.azureOpenAIApiInstanceName - The instance name of Azure OpenAI, e.g. `example-resource`.\n * @property {string} config.azureOpenAIApiKey - The API Key for Azure OpenAI.\n * @property {string} config.azureOpenAIBasePath - The base path for Azure OpenAI, e.g. `https://example-resource.azure.openai.com/openai/deployments/`.\n * @property {string} config.baseURL - Some other custom base path URL.\n * @property {string} config.azureOpenAIEndpoint - The endpoint for the Azure OpenAI instance, e.g. `https://example-resource.azure.openai.com/`.\n *\n * The function operates as follows:\n * - If both `azureOpenAIBasePath` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`).\n * - If both `azureOpenAIEndpoint` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`).\n * - If `azureOpenAIApiKey` is provided, it checks for `azureOpenAIApiInstanceName` and `azureOpenAIApiDeploymentName` and throws an error if any of these is missing. If both are provided, it generates an URL incorporating these parameters.\n * - If none of the above conditions are met, return any custom `baseURL`.\n * - The function returns the generated URL as a string, or undefined if no custom paths are specified.\n *\n * @throws Will throw an error if the necessary parameters for generating the URL are missing.\n *\n * @returns {string | undefined} The generated (Azure) OpenAI endpoint URL.\n */\nexport function getEndpoint(config: OpenAIEndpointConfig) {\n const {\n azureOpenAIApiDeploymentName,\n azureOpenAIApiInstanceName,\n azureOpenAIApiKey,\n azureOpenAIBasePath,\n baseURL,\n azureADTokenProvider,\n azureOpenAIEndpoint,\n } = config;\n\n if (\n (azureOpenAIApiKey || azureADTokenProvider) &&\n azureOpenAIBasePath &&\n azureOpenAIApiDeploymentName\n ) {\n return `${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`;\n }\n if (\n (azureOpenAIApiKey || azureADTokenProvider) &&\n azureOpenAIEndpoint &&\n azureOpenAIApiDeploymentName\n ) {\n return `${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`;\n }\n\n if (azureOpenAIApiKey || azureADTokenProvider) {\n if (!azureOpenAIApiInstanceName) {\n throw new Error(\n \"azureOpenAIApiInstanceName is required when using azureOpenAIApiKey\"\n );\n }\n if (!azureOpenAIApiDeploymentName) {\n throw new Error(\n \"azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey\"\n );\n }\n return `https://${azureOpenAIApiInstanceName}.openai.azure.com/openai/deployments/${azureOpenAIApiDeploymentName}`;\n }\n\n return baseURL;\n}\n\ntype HeaderValue = string | undefined | null;\nexport type HeadersLike =\n | Headers\n | readonly HeaderValue[][]\n | Record<string, HeaderValue | readonly HeaderValue[]>\n | undefined\n | null\n // NullableHeaders\n | { values: Headers; [key: string]: unknown };\n\nexport function isHeaders(headers: unknown): headers is Headers {\n return (\n typeof Headers !== \"undefined\" &&\n headers !== null &&\n typeof headers === \"object\" &&\n Object.prototype.toString.call(headers) === \"[object Headers]\"\n );\n}\n\n/**\n * Normalizes various header formats into a consistent Record format.\n *\n * This function accepts headers in multiple formats and converts them to a\n * Record<string, HeaderValue | readonly HeaderValue[]> for consistent handling.\n *\n * @param headers - The headers to normalize. Can be:\n * - A Headers instance\n * - An array of [key, value] pairs\n * - A plain object with string keys\n * - A NullableHeaders-like object with a 'values' property containing Headers\n * - null or undefined\n * @returns A normalized Record containing the header key-value pairs\n *\n * @example\n * ```ts\n * // With Headers instance\n * const headers1 = new Headers([['content-type', 'application/json']]);\n * const normalized1 = normalizeHeaders(headers1);\n *\n * // With plain object\n * const headers2 = { 'content-type': 'application/json' };\n * const normalized2 = normalizeHeaders(headers2);\n *\n * // With array of pairs\n * const headers3 = [['content-type', 'application/json']];\n * const normalized3 = normalizeHeaders(headers3);\n * ```\n */\nexport function normalizeHeaders(\n headers: HeadersLike\n): Record<string, HeaderValue | readonly HeaderValue[]> {\n const output = iife(() => {\n // If headers is a Headers instance\n if (isHeaders(headers)) {\n return headers;\n }\n // If headers is an array of [key, value] pairs\n else if (Array.isArray(headers)) {\n return new Headers(headers);\n }\n // If headers is a NullableHeaders-like object (has 'values' property that is a Headers)\n else if (\n typeof headers === \"object\" &&\n headers !== null &&\n \"values\" in headers &&\n isHeaders(headers.values)\n ) {\n return headers.values;\n }\n // If headers is a plain object\n else if (typeof headers === \"object\" && headers !== null) {\n const entries: [string, string][] = Object.entries(headers)\n .filter(([, v]) => typeof v === \"string\")\n .map(([k, v]) => [k, v as string]);\n return new Headers(entries);\n }\n return new Headers();\n });\n\n return Object.fromEntries(output.entries());\n}\n\nexport function getFormattedEnv() {\n let env = getEnv();\n if (env === \"node\" || env === \"deno\") {\n env = `(${env}/${process.version}; ${process.platform}; ${process.arch})`;\n }\n return env;\n}\n\n// Note: ideally version would be imported from package.json, but there's\n// currently no good way to do that for all supported environments (Node, Deno, Browser).\nexport function getHeadersWithUserAgent(\n headers: HeadersLike,\n isAzure = false,\n version = \"1.0.0\"\n): Record<string, string> {\n const normalizedHeaders = normalizeHeaders(headers);\n const env = getFormattedEnv();\n const library = `langchainjs${isAzure ? \"-azure\" : \"\"}-openai`;\n return {\n ...normalizedHeaders,\n \"User-Agent\": normalizedHeaders[\"User-Agent\"]\n ? `${library}/${version} (${env})${normalizedHeaders[\"User-Agent\"]}`\n : `${library}/${version} (${env})`,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,YAAY,QAA8B;CACxD,MAAM,EACJ,8BACA,4BACA,mBACA,qBACA,SACA,sBACA,wBACE;AAEJ,MACG,qBAAqB,yBACtB,uBACA,6BAEA,QAAO,GAAG,oBAAoB,GAAG;AAEnC,MACG,qBAAqB,yBACtB,uBACA,6BAEA,QAAO,GAAG,oBAAoB,sBAAsB;AAGtD,KAAI,qBAAqB,sBAAsB;AAC7C,MAAI,CAAC,2BACH,OAAM,IAAI,MACR,sEACD;AAEH,MAAI,CAAC,6BACH,OAAM,IAAI,MACR,oFACD;AAEH,SAAO,WAAW,2BAA2B,uCAAuC;;AAGtF,QAAO;;AAaT,SAAgB,UAAU,SAAsC;AAC9D,QACE,OAAO,YAAY,eACnB,YAAY,QACZ,OAAO,YAAY,YACnB,OAAO,UAAU,SAAS,KAAK,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiChD,SAAgB,iBACd,SACsD;CACtD,MAAM,SAAS,WAAW;AAExB,MAAI,UAAU,QAAQ,CACpB,QAAO;WAGA,MAAM,QAAQ,QAAQ,CAC7B,QAAO,IAAI,QAAQ,QAAQ;WAI3B,OAAO,YAAY,YACnB,YAAY,QACZ,YAAY,WACZ,UAAU,QAAQ,OAAO,CAEzB,QAAO,QAAQ;WAGR,OAAO,YAAY,YAAY,YAAY,MAAM;GACxD,MAAM,UAA8B,OAAO,QAAQ,QAAQ,CACxD,QAAQ,GAAG,OAAO,OAAO,MAAM,SAAS,CACxC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,EAAY,CAAC;AACpC,UAAO,IAAI,QAAQ,QAAQ;;AAE7B,SAAO,IAAI,SAAS;GACpB;AAEF,QAAO,OAAO,YAAY,OAAO,SAAS,CAAC;;AAG7C,SAAgB,kBAAkB;CAChC,IAAI,MAAM,QAAQ;AAClB,KAAI,QAAQ,UAAU,QAAQ,OAC5B,OAAM,IAAI,IAAI,GAAG,QAAQ,QAAQ,IAAI,QAAQ,SAAS,IAAI,QAAQ,KAAK;AAEzE,QAAO;;AAKT,SAAgB,wBACd,SACA,UAAU,OACV,UAAU,SACc;CACxB,MAAM,oBAAoB,iBAAiB,QAAQ;CACnD,MAAM,MAAM,iBAAiB;CAC7B,MAAM,UAAU,cAAc,UAAU,WAAW,GAAG;AACtD,QAAO;EACL,GAAG;EACH,cAAc,kBAAkB,gBAC5B,GAAG,QAAQ,GAAG,QAAQ,IAAI,IAAI,GAAG,kBAAkB,kBACnD,GAAG,QAAQ,GAAG,QAAQ,IAAI,IAAI;EACnC"}
1
+ {"version":3,"file":"azure.js","names":[],"sources":["../../src/utils/azure.ts"],"sourcesContent":["import { getEnv } from \"@langchain/core/utils/env\";\nimport { iife } from \"./misc.js\";\n\nexport interface OpenAIEndpointConfig {\n azureOpenAIApiDeploymentName?: string;\n azureOpenAIApiInstanceName?: string;\n azureOpenAIApiKey?: string;\n azureADTokenProvider?: () => Promise<string>;\n azureOpenAIBasePath?: string;\n baseURL?: string | null;\n azureOpenAIEndpoint?: string;\n}\n\n/**\n * This function generates an endpoint URL for (Azure) OpenAI\n * based on the configuration parameters provided.\n *\n * @param {OpenAIEndpointConfig} config - The configuration object for the (Azure) endpoint.\n *\n * @property {string} config.azureOpenAIApiDeploymentName - The deployment name of Azure OpenAI.\n * @property {string} config.azureOpenAIApiInstanceName - The instance name of Azure OpenAI, e.g. `example-resource`.\n * @property {string} config.azureOpenAIApiKey - The API Key for Azure OpenAI.\n * @property {string} config.azureOpenAIBasePath - The base path for Azure OpenAI, e.g. `https://example-resource.azure.openai.com/openai/deployments/`.\n * @property {string} config.baseURL - Some other custom base path URL.\n * @property {string} config.azureOpenAIEndpoint - The endpoint for the Azure OpenAI instance, e.g. `https://example-resource.azure.openai.com/`.\n *\n * The function operates as follows:\n * - If both `azureOpenAIBasePath` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`).\n * - If both `azureOpenAIEndpoint` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`).\n * - If `azureOpenAIApiKey` is provided, it checks for `azureOpenAIApiInstanceName` and `azureOpenAIApiDeploymentName` and throws an error if any of these is missing. If both are provided, it generates an URL incorporating these parameters.\n * - If none of the above conditions are met, return any custom `baseURL`.\n * - The function returns the generated URL as a string, or undefined if no custom paths are specified.\n *\n * @throws Will throw an error if the necessary parameters for generating the URL are missing.\n *\n * @returns {string | undefined} The generated (Azure) OpenAI endpoint URL.\n */\nexport function getEndpoint(config: OpenAIEndpointConfig) {\n const {\n azureOpenAIApiDeploymentName,\n azureOpenAIApiInstanceName,\n azureOpenAIApiKey,\n azureOpenAIBasePath,\n baseURL,\n azureADTokenProvider,\n azureOpenAIEndpoint,\n } = config;\n\n if (\n (azureOpenAIApiKey || azureADTokenProvider) &&\n azureOpenAIBasePath &&\n azureOpenAIApiDeploymentName\n ) {\n return `${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`;\n }\n if (\n (azureOpenAIApiKey || azureADTokenProvider) &&\n azureOpenAIEndpoint &&\n azureOpenAIApiDeploymentName\n ) {\n return `${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`;\n }\n\n if (azureOpenAIApiKey || azureADTokenProvider) {\n if (!azureOpenAIApiInstanceName) {\n throw new Error(\n \"azureOpenAIApiInstanceName is required when using azureOpenAIApiKey\"\n );\n }\n if (!azureOpenAIApiDeploymentName) {\n throw new Error(\n \"azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey\"\n );\n }\n return `https://${azureOpenAIApiInstanceName}.openai.azure.com/openai/deployments/${azureOpenAIApiDeploymentName}`;\n }\n\n return baseURL;\n}\n\ntype HeaderValue = string | undefined | null;\nexport type HeadersLike =\n | Headers\n | readonly HeaderValue[][]\n | Record<string, HeaderValue | readonly HeaderValue[]>\n | undefined\n | null\n // NullableHeaders\n | { values: Headers; [key: string]: unknown };\n\nexport function isHeaders(headers: unknown): headers is Headers {\n return (\n typeof Headers !== \"undefined\" &&\n headers !== null &&\n typeof headers === \"object\" &&\n Object.prototype.toString.call(headers) === \"[object Headers]\"\n );\n}\n\n/**\n * Normalizes various header formats into a consistent Record format.\n *\n * This function accepts headers in multiple formats and converts them to a\n * Record<string, HeaderValue | readonly HeaderValue[]> for consistent handling.\n *\n * @param headers - The headers to normalize. Can be:\n * - A Headers instance\n * - An array of [key, value] pairs\n * - A plain object with string keys\n * - A NullableHeaders-like object with a 'values' property containing Headers\n * - null or undefined\n * @returns A normalized Record containing the header key-value pairs\n *\n * @example\n * ```ts\n * // With Headers instance\n * const headers1 = new Headers([['content-type', 'application/json']]);\n * const normalized1 = normalizeHeaders(headers1);\n *\n * // With plain object\n * const headers2 = { 'content-type': 'application/json' };\n * const normalized2 = normalizeHeaders(headers2);\n *\n * // With array of pairs\n * const headers3 = [['content-type', 'application/json']];\n * const normalized3 = normalizeHeaders(headers3);\n * ```\n */\nexport function normalizeHeaders(\n headers: HeadersLike\n): Record<string, HeaderValue | readonly HeaderValue[]> {\n const output = iife(() => {\n // If headers is a Headers instance\n if (isHeaders(headers)) {\n return headers;\n }\n // If headers is an array of [key, value] pairs\n else if (Array.isArray(headers)) {\n return new Headers(headers);\n }\n // If headers is a NullableHeaders-like object (has 'values' property that is a Headers)\n else if (\n typeof headers === \"object\" &&\n headers !== null &&\n \"values\" in headers &&\n isHeaders(headers.values)\n ) {\n return headers.values;\n }\n // If headers is a plain object\n else if (typeof headers === \"object\" && headers !== null) {\n const entries: [string, string][] = Object.entries(headers)\n .filter(([, v]) => typeof v === \"string\")\n .map(([k, v]) => [k, v as string]);\n return new Headers(entries);\n }\n return new Headers();\n });\n\n return Object.fromEntries(output.entries());\n}\n\nexport function getFormattedEnv() {\n let env = getEnv();\n if (env === \"node\" || env === \"deno\") {\n env = `(${env}/${process.version}; ${process.platform}; ${process.arch})`;\n }\n return env;\n}\n\n// Note: ideally version would be imported from package.json, but there's\n// currently no good way to do that for all supported environments (Node, Deno, Browser).\nexport function getHeadersWithUserAgent(\n headers: HeadersLike,\n isAzure = false,\n version = \"1.0.0\"\n): Record<string, string> {\n const normalizedHeaders = normalizeHeaders(headers);\n const env = getFormattedEnv();\n const library = `langchainjs${isAzure ? \"-azure\" : \"\"}-openai`;\n return {\n ...normalizedHeaders,\n \"User-Agent\": normalizedHeaders[\"User-Agent\"]\n ? `${library}/${version} (${env})${normalizedHeaders[\"User-Agent\"]}`\n : `${library}/${version} (${env})`,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,YAAY,QAA8B;CACxD,MAAM,EACJ,8BACA,4BACA,mBACA,qBACA,SACA,sBACA,wBACE;CAEJ,KACG,qBAAqB,yBACtB,uBACA,8BAEA,OAAO,GAAG,oBAAoB,GAAG;CAEnC,KACG,qBAAqB,yBACtB,uBACA,8BAEA,OAAO,GAAG,oBAAoB,sBAAsB;CAGtD,IAAI,qBAAqB,sBAAsB;EAC7C,IAAI,CAAC,4BACH,MAAM,IAAI,MACR,qEACF;EAEF,IAAI,CAAC,8BACH,MAAM,IAAI,MACR,mFACF;EAEF,OAAO,WAAW,2BAA2B,uCAAuC;CACtF;CAEA,OAAO;AACT;AAYA,SAAgB,UAAU,SAAsC;CAC9D,OACE,OAAO,YAAY,eACnB,YAAY,QACZ,OAAO,YAAY,YACnB,OAAO,UAAU,SAAS,KAAK,OAAO,MAAM;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,SAAgB,iBACd,SACsD;CACtD,MAAM,SAAS,WAAW;EAExB,IAAI,UAAU,OAAO,GACnB,OAAO;OAGJ,IAAI,MAAM,QAAQ,OAAO,GAC5B,OAAO,IAAI,QAAQ,OAAO;OAGvB,IACH,OAAO,YAAY,YACnB,YAAY,QACZ,YAAY,WACZ,UAAU,QAAQ,MAAM,GAExB,OAAO,QAAQ;OAGZ,IAAI,OAAO,YAAY,YAAY,YAAY,MAAM;GACxD,MAAM,UAA8B,OAAO,QAAQ,OAAO,CAAC,CACxD,QAAQ,GAAG,OAAO,OAAO,MAAM,QAAQ,CAAC,CACxC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,CAAW,CAAC;GACnC,OAAO,IAAI,QAAQ,OAAO;EAC5B;EACA,OAAO,IAAI,QAAQ;CACrB,CAAC;CAED,OAAO,OAAO,YAAY,OAAO,QAAQ,CAAC;AAC5C;AAEA,SAAgB,kBAAkB;CAChC,IAAI,MAAM,OAAO;CACjB,IAAI,QAAQ,UAAU,QAAQ,QAC5B,MAAM,IAAI,IAAI,GAAG,QAAQ,QAAQ,IAAI,QAAQ,SAAS,IAAI,QAAQ,KAAK;CAEzE,OAAO;AACT;AAIA,SAAgB,wBACd,SACA,UAAU,OACV,UAAU,SACc;CACxB,MAAM,oBAAoB,iBAAiB,OAAO;CAClD,MAAM,MAAM,gBAAgB;CAC5B,MAAM,UAAU,cAAc,UAAU,WAAW,GAAG;CACtD,OAAO;EACL,GAAG;EACH,cAAc,kBAAkB,gBAC5B,GAAG,QAAQ,GAAG,QAAQ,IAAI,IAAI,GAAG,kBAAkB,kBACnD,GAAG,QAAQ,GAAG,QAAQ,IAAI,IAAI;CACpC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"client.cjs","names":["APIConnectionTimeoutError","APIUserAbortError","ContextOverflowError","addLangChainErrorFields"],"sources":["../../src/utils/client.ts"],"sourcesContent":["import { APIConnectionTimeoutError, APIUserAbortError } from \"openai\";\nimport { ContextOverflowError } from \"@langchain/core/errors\";\nimport { addLangChainErrorFields } from \"./errors.js\";\n\nfunction _isOpenAIContextOverflowError(e: object): boolean {\n const errorStr = String(e);\n if (errorStr.includes(\"context_length_exceeded\")) {\n return true;\n }\n if (\n \"message\" in e &&\n typeof e.message === \"string\" &&\n (e.message.includes(\"Input tokens exceed the configured limit\") ||\n e.message.includes(\"exceeds the context window\") ||\n e.message.includes(\"maximum context length\"))\n ) {\n return true;\n }\n return false;\n}\n\nexport function wrapOpenAIClientError(e: unknown) {\n if (!e || typeof e !== \"object\") {\n return e;\n }\n\n let error;\n if (\n e.constructor.name === APIConnectionTimeoutError.name &&\n \"message\" in e &&\n typeof e.message === \"string\"\n ) {\n error = new Error(e.message);\n error.name = \"TimeoutError\";\n } else if (\n e.constructor.name === APIUserAbortError.name &&\n \"message\" in e &&\n typeof e.message === \"string\"\n ) {\n error = new Error(e.message);\n error.name = \"AbortError\";\n } else if (_isOpenAIContextOverflowError(e)) {\n error = ContextOverflowError.fromError(e as Error);\n } else if (\n \"status\" in e &&\n e.status === 400 &&\n \"message\" in e &&\n typeof e.message === \"string\" &&\n e.message.includes(\"tool_calls\")\n ) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (\"status\" in e && e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (\"status\" in e && e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else if (\"status\" in e && e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";;;;AAIA,SAAS,8BAA8B,GAAoB;AAEzD,KADiB,OAAO,EACZ,CAAC,SAAS,0BAA0B,CAC9C,QAAO;AAET,KACE,aAAa,KACb,OAAO,EAAE,YAAY,aACpB,EAAE,QAAQ,SAAS,2CAA2C,IAC7D,EAAE,QAAQ,SAAS,6BAA6B,IAChD,EAAE,QAAQ,SAAS,yBAAyB,EAE9C,QAAO;AAET,QAAO;;AAGT,SAAgB,sBAAsB,GAAY;AAChD,KAAI,CAAC,KAAK,OAAO,MAAM,SACrB,QAAO;CAGT,IAAI;AACJ,KACE,EAAE,YAAY,SAASA,OAAAA,0BAA0B,QACjD,aAAa,KACb,OAAO,EAAE,YAAY,UACrB;AACA,UAAQ,IAAI,MAAM,EAAE,QAAQ;AAC5B,QAAM,OAAO;YAEb,EAAE,YAAY,SAASC,OAAAA,kBAAkB,QACzC,aAAa,KACb,OAAO,EAAE,YAAY,UACrB;AACA,UAAQ,IAAI,MAAM,EAAE,QAAQ;AAC5B,QAAM,OAAO;YACJ,8BAA8B,EAAE,CACzC,SAAQC,uBAAAA,qBAAqB,UAAU,EAAW;UAElD,YAAY,KACZ,EAAE,WAAW,OACb,aAAa,KACb,OAAO,EAAE,YAAY,YACrB,EAAE,QAAQ,SAAS,aAAa,CAEhC,SAAQC,eAAAA,wBAAwB,GAAG,uBAAuB;UACjD,YAAY,KAAK,EAAE,WAAW,IACvC,SAAQA,eAAAA,wBAAwB,GAAG,uBAAuB;UACjD,YAAY,KAAK,EAAE,WAAW,IACvC,SAAQA,eAAAA,wBAAwB,GAAG,mBAAmB;UAC7C,YAAY,KAAK,EAAE,WAAW,IACvC,SAAQA,eAAAA,wBAAwB,GAAG,kBAAkB;KAErD,SAAQ;AAEV,QAAO"}
1
+ {"version":3,"file":"client.cjs","names":["APIConnectionTimeoutError","APIUserAbortError","ContextOverflowError","addLangChainErrorFields"],"sources":["../../src/utils/client.ts"],"sourcesContent":["import { APIConnectionTimeoutError, APIUserAbortError } from \"openai\";\nimport { ContextOverflowError } from \"@langchain/core/errors\";\nimport { addLangChainErrorFields } from \"./errors.js\";\n\nfunction _isOpenAIContextOverflowError(e: object): boolean {\n const errorStr = String(e);\n if (errorStr.includes(\"context_length_exceeded\")) {\n return true;\n }\n if (\n \"message\" in e &&\n typeof e.message === \"string\" &&\n (e.message.includes(\"Input tokens exceed the configured limit\") ||\n e.message.includes(\"exceeds the context window\") ||\n e.message.includes(\"maximum context length\"))\n ) {\n return true;\n }\n return false;\n}\n\nexport function wrapOpenAIClientError(e: unknown) {\n if (!e || typeof e !== \"object\") {\n return e;\n }\n\n let error;\n if (\n e.constructor.name === APIConnectionTimeoutError.name &&\n \"message\" in e &&\n typeof e.message === \"string\"\n ) {\n error = new Error(e.message);\n error.name = \"TimeoutError\";\n } else if (\n e.constructor.name === APIUserAbortError.name &&\n \"message\" in e &&\n typeof e.message === \"string\"\n ) {\n error = new Error(e.message);\n error.name = \"AbortError\";\n } else if (_isOpenAIContextOverflowError(e)) {\n error = ContextOverflowError.fromError(e as Error);\n } else if (\n \"status\" in e &&\n e.status === 400 &&\n \"message\" in e &&\n typeof e.message === \"string\" &&\n e.message.includes(\"tool_calls\")\n ) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (\"status\" in e && e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (\"status\" in e && e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else if (\"status\" in e && e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";;;;AAIA,SAAS,8BAA8B,GAAoB;CAEzD,IADiB,OAAO,CACb,CAAC,CAAC,SAAS,yBAAyB,GAC7C,OAAO;CAET,IACE,aAAa,KACb,OAAO,EAAE,YAAY,aACpB,EAAE,QAAQ,SAAS,0CAA0C,KAC5D,EAAE,QAAQ,SAAS,4BAA4B,KAC/C,EAAE,QAAQ,SAAS,wBAAwB,IAE7C,OAAO;CAET,OAAO;AACT;AAEA,SAAgB,sBAAsB,GAAY;CAChD,IAAI,CAAC,KAAK,OAAO,MAAM,UACrB,OAAO;CAGT,IAAI;CACJ,IACE,EAAE,YAAY,SAASA,OAAAA,0BAA0B,QACjD,aAAa,KACb,OAAO,EAAE,YAAY,UACrB;EACA,QAAQ,IAAI,MAAM,EAAE,OAAO;EAC3B,MAAM,OAAO;CACf,OAAO,IACL,EAAE,YAAY,SAASC,OAAAA,kBAAkB,QACzC,aAAa,KACb,OAAO,EAAE,YAAY,UACrB;EACA,QAAQ,IAAI,MAAM,EAAE,OAAO;EAC3B,MAAM,OAAO;CACf,OAAO,IAAI,8BAA8B,CAAC,GACxC,QAAQC,uBAAAA,qBAAqB,UAAU,CAAU;MAC5C,IACL,YAAY,KACZ,EAAE,WAAW,OACb,aAAa,KACb,OAAO,EAAE,YAAY,YACrB,EAAE,QAAQ,SAAS,YAAY,GAE/B,QAAQC,eAAAA,wBAAwB,GAAG,sBAAsB;MACpD,IAAI,YAAY,KAAK,EAAE,WAAW,KACvC,QAAQA,eAAAA,wBAAwB,GAAG,sBAAsB;MACpD,IAAI,YAAY,KAAK,EAAE,WAAW,KACvC,QAAQA,eAAAA,wBAAwB,GAAG,kBAAkB;MAChD,IAAI,YAAY,KAAK,EAAE,WAAW,KACvC,QAAQA,eAAAA,wBAAwB,GAAG,iBAAiB;MAEpD,QAAQ;CAEV,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.cts","names":[],"sources":["../../src/utils/client.ts"],"mappings":";iBAqBgB,qBAAA,CAAsB,CAAA"}
1
+ {"version":3,"file":"client.d.cts","names":[],"sources":["../../src/utils/client.ts"],"mappings":";iBAqBgB,sBAAsB"}
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","names":[],"sources":["../../src/utils/client.ts"],"mappings":";iBAqBgB,qBAAA,CAAsB,CAAA"}
1
+ {"version":3,"file":"client.d.ts","names":[],"sources":["../../src/utils/client.ts"],"mappings":";iBAqBgB,sBAAsB"}
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":[],"sources":["../../src/utils/client.ts"],"sourcesContent":["import { APIConnectionTimeoutError, APIUserAbortError } from \"openai\";\nimport { ContextOverflowError } from \"@langchain/core/errors\";\nimport { addLangChainErrorFields } from \"./errors.js\";\n\nfunction _isOpenAIContextOverflowError(e: object): boolean {\n const errorStr = String(e);\n if (errorStr.includes(\"context_length_exceeded\")) {\n return true;\n }\n if (\n \"message\" in e &&\n typeof e.message === \"string\" &&\n (e.message.includes(\"Input tokens exceed the configured limit\") ||\n e.message.includes(\"exceeds the context window\") ||\n e.message.includes(\"maximum context length\"))\n ) {\n return true;\n }\n return false;\n}\n\nexport function wrapOpenAIClientError(e: unknown) {\n if (!e || typeof e !== \"object\") {\n return e;\n }\n\n let error;\n if (\n e.constructor.name === APIConnectionTimeoutError.name &&\n \"message\" in e &&\n typeof e.message === \"string\"\n ) {\n error = new Error(e.message);\n error.name = \"TimeoutError\";\n } else if (\n e.constructor.name === APIUserAbortError.name &&\n \"message\" in e &&\n typeof e.message === \"string\"\n ) {\n error = new Error(e.message);\n error.name = \"AbortError\";\n } else if (_isOpenAIContextOverflowError(e)) {\n error = ContextOverflowError.fromError(e as Error);\n } else if (\n \"status\" in e &&\n e.status === 400 &&\n \"message\" in e &&\n typeof e.message === \"string\" &&\n e.message.includes(\"tool_calls\")\n ) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (\"status\" in e && e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (\"status\" in e && e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else if (\"status\" in e && e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";;;;AAIA,SAAS,8BAA8B,GAAoB;AAEzD,KADiB,OAAO,EACZ,CAAC,SAAS,0BAA0B,CAC9C,QAAO;AAET,KACE,aAAa,KACb,OAAO,EAAE,YAAY,aACpB,EAAE,QAAQ,SAAS,2CAA2C,IAC7D,EAAE,QAAQ,SAAS,6BAA6B,IAChD,EAAE,QAAQ,SAAS,yBAAyB,EAE9C,QAAO;AAET,QAAO;;AAGT,SAAgB,sBAAsB,GAAY;AAChD,KAAI,CAAC,KAAK,OAAO,MAAM,SACrB,QAAO;CAGT,IAAI;AACJ,KACE,EAAE,YAAY,SAAS,0BAA0B,QACjD,aAAa,KACb,OAAO,EAAE,YAAY,UACrB;AACA,UAAQ,IAAI,MAAM,EAAE,QAAQ;AAC5B,QAAM,OAAO;YAEb,EAAE,YAAY,SAAS,kBAAkB,QACzC,aAAa,KACb,OAAO,EAAE,YAAY,UACrB;AACA,UAAQ,IAAI,MAAM,EAAE,QAAQ;AAC5B,QAAM,OAAO;YACJ,8BAA8B,EAAE,CACzC,SAAQ,qBAAqB,UAAU,EAAW;UAElD,YAAY,KACZ,EAAE,WAAW,OACb,aAAa,KACb,OAAO,EAAE,YAAY,YACrB,EAAE,QAAQ,SAAS,aAAa,CAEhC,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,YAAY,KAAK,EAAE,WAAW,IACvC,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,YAAY,KAAK,EAAE,WAAW,IACvC,SAAQ,wBAAwB,GAAG,mBAAmB;UAC7C,YAAY,KAAK,EAAE,WAAW,IACvC,SAAQ,wBAAwB,GAAG,kBAAkB;KAErD,SAAQ;AAEV,QAAO"}
1
+ {"version":3,"file":"client.js","names":[],"sources":["../../src/utils/client.ts"],"sourcesContent":["import { APIConnectionTimeoutError, APIUserAbortError } from \"openai\";\nimport { ContextOverflowError } from \"@langchain/core/errors\";\nimport { addLangChainErrorFields } from \"./errors.js\";\n\nfunction _isOpenAIContextOverflowError(e: object): boolean {\n const errorStr = String(e);\n if (errorStr.includes(\"context_length_exceeded\")) {\n return true;\n }\n if (\n \"message\" in e &&\n typeof e.message === \"string\" &&\n (e.message.includes(\"Input tokens exceed the configured limit\") ||\n e.message.includes(\"exceeds the context window\") ||\n e.message.includes(\"maximum context length\"))\n ) {\n return true;\n }\n return false;\n}\n\nexport function wrapOpenAIClientError(e: unknown) {\n if (!e || typeof e !== \"object\") {\n return e;\n }\n\n let error;\n if (\n e.constructor.name === APIConnectionTimeoutError.name &&\n \"message\" in e &&\n typeof e.message === \"string\"\n ) {\n error = new Error(e.message);\n error.name = \"TimeoutError\";\n } else if (\n e.constructor.name === APIUserAbortError.name &&\n \"message\" in e &&\n typeof e.message === \"string\"\n ) {\n error = new Error(e.message);\n error.name = \"AbortError\";\n } else if (_isOpenAIContextOverflowError(e)) {\n error = ContextOverflowError.fromError(e as Error);\n } else if (\n \"status\" in e &&\n e.status === 400 &&\n \"message\" in e &&\n typeof e.message === \"string\" &&\n e.message.includes(\"tool_calls\")\n ) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (\"status\" in e && e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (\"status\" in e && e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else if (\"status\" in e && e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";;;;AAIA,SAAS,8BAA8B,GAAoB;CAEzD,IADiB,OAAO,CACb,CAAC,CAAC,SAAS,yBAAyB,GAC7C,OAAO;CAET,IACE,aAAa,KACb,OAAO,EAAE,YAAY,aACpB,EAAE,QAAQ,SAAS,0CAA0C,KAC5D,EAAE,QAAQ,SAAS,4BAA4B,KAC/C,EAAE,QAAQ,SAAS,wBAAwB,IAE7C,OAAO;CAET,OAAO;AACT;AAEA,SAAgB,sBAAsB,GAAY;CAChD,IAAI,CAAC,KAAK,OAAO,MAAM,UACrB,OAAO;CAGT,IAAI;CACJ,IACE,EAAE,YAAY,SAAS,0BAA0B,QACjD,aAAa,KACb,OAAO,EAAE,YAAY,UACrB;EACA,QAAQ,IAAI,MAAM,EAAE,OAAO;EAC3B,MAAM,OAAO;CACf,OAAO,IACL,EAAE,YAAY,SAAS,kBAAkB,QACzC,aAAa,KACb,OAAO,EAAE,YAAY,UACrB;EACA,QAAQ,IAAI,MAAM,EAAE,OAAO;EAC3B,MAAM,OAAO;CACf,OAAO,IAAI,8BAA8B,CAAC,GACxC,QAAQ,qBAAqB,UAAU,CAAU;MAC5C,IACL,YAAY,KACZ,EAAE,WAAW,OACb,aAAa,KACb,OAAO,EAAE,YAAY,YACrB,EAAE,QAAQ,SAAS,YAAY,GAE/B,QAAQ,wBAAwB,GAAG,sBAAsB;MACpD,IAAI,YAAY,KAAK,EAAE,WAAW,KACvC,QAAQ,wBAAwB,GAAG,sBAAsB;MACpD,IAAI,YAAY,KAAK,EAAE,WAAW,KACvC,QAAQ,wBAAwB,GAAG,kBAAkB;MAChD,IAAI,YAAY,KAAK,EAAE,WAAW,KACvC,QAAQ,wBAAwB,GAAG,iBAAiB;MAEpD,QAAQ;CAEV,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* oxlint-disable @typescript-eslint/no-explicit-any */\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"CONTEXT_OVERFLOW\"\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n"],"mappings":";AAcA,SAAgB,wBACd,OACA,eACA;AACC,OAAc,gBAAgB;AAC/B,OAAM,UAAU,GAAG,MAAM,QAAQ,sFAAsF,cAAc;AACrI,QAAO"}
1
+ {"version":3,"file":"errors.cjs","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* oxlint-disable @typescript-eslint/no-explicit-any */\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"CONTEXT_OVERFLOW\"\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n"],"mappings":";AAcA,SAAgB,wBACd,OACA,eACA;CACA,MAAe,gBAAgB;CAC/B,MAAM,UAAU,GAAG,MAAM,QAAQ,sFAAsF,cAAc;CACrI,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* oxlint-disable @typescript-eslint/no-explicit-any */\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"CONTEXT_OVERFLOW\"\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n"],"mappings":";AAcA,SAAgB,wBACd,OACA,eACA;AACC,OAAc,gBAAgB;AAC/B,OAAM,UAAU,GAAG,MAAM,QAAQ,sFAAsF,cAAc;AACrI,QAAO"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* oxlint-disable @typescript-eslint/no-explicit-any */\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"CONTEXT_OVERFLOW\"\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n"],"mappings":";AAcA,SAAgB,wBACd,OACA,eACA;CACA,MAAe,gBAAgB;CAC/B,MAAM,UAAU,GAAG,MAAM,QAAQ,sFAAsF,cAAc;CACrI,OAAO;AACT"}
@@ -45,7 +45,9 @@ function _modelPrefersResponsesAPI(model) {
45
45
  return false;
46
46
  }
47
47
  //#endregion
48
+ exports.LC_AUTOGENERATED_FILENAME = LC_AUTOGENERATED_FILENAME;
48
49
  exports._modelPrefersResponsesAPI = _modelPrefersResponsesAPI;
50
+ exports.extractGenericMessageCustomRole = extractGenericMessageCustomRole;
49
51
  exports.getFilenameFromMetadata = getFilenameFromMetadata;
50
52
  exports.getRequiredFilenameFromMetadata = getRequiredFilenameFromMetadata;
51
53
  exports.iife = iife;
@@ -1 +1 @@
1
- {"version":3,"file":"misc.cjs","names":["ChatMessage"],"sources":["../../src/utils/misc.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport {\n BaseMessage,\n ChatMessage,\n ContentBlock,\n Data,\n} from \"@langchain/core/messages\";\n\nexport const iife = <T>(fn: () => T) => fn();\n\nexport function isReasoningModel(model?: string) {\n if (!model) return false;\n if (/^o\\d/.test(model ?? \"\")) return true;\n if (model.startsWith(\"gpt-5\") && !model.startsWith(\"gpt-5-chat\")) return true;\n return false;\n}\n\nexport function extractGenericMessageCustomRole(message: ChatMessage) {\n if (\n message.role !== \"system\" &&\n message.role !== \"developer\" &&\n message.role !== \"assistant\" &&\n message.role !== \"user\" &&\n message.role !== \"function\" &&\n message.role !== \"tool\"\n ) {\n console.warn(`Unknown message role: ${message.role}`);\n }\n\n return message.role as OpenAIClient.ChatCompletionRole;\n}\n\nexport function getFilenameFromMetadata(\n block:\n | ContentBlock.Multimodal.File\n | ContentBlock.Multimodal.Video\n | Data.StandardFileBlock\n): string | undefined {\n return (block.metadata?.filename ??\n block.metadata?.name ??\n block.metadata?.title) as string;\n}\n\nexport const LC_AUTOGENERATED_FILENAME = \"LC_AUTOGENERATED\";\n\nexport function getRequiredFilenameFromMetadata(\n block:\n | ContentBlock.Multimodal.File\n | ContentBlock.Multimodal.Video\n | Data.StandardFileBlock\n): string {\n const filename = (block.metadata?.filename ??\n block.metadata?.name ??\n block.metadata?.title) as string;\n\n if (!filename) {\n console.warn(\n \"OpenAI may require a filename for file uploads. Specify a filename \" +\n \"in the content block metadata, e.g.: { type: 'file', mimeType: \" +\n \"'...', data: '...', metadata: { filename: 'my-file.pdf' } }. \" +\n \"Using placeholder filename 'LC_AUTOGENERATED'.\"\n );\n return LC_AUTOGENERATED_FILENAME;\n }\n\n return filename;\n}\nexport function messageToOpenAIRole(\n message: BaseMessage\n): OpenAIClient.ChatCompletionRole {\n const type = message._getType();\n switch (type) {\n case \"system\":\n return \"system\";\n case \"ai\":\n return \"assistant\";\n case \"human\":\n return \"user\";\n case \"function\":\n return \"function\";\n case \"tool\":\n return \"tool\";\n case \"generic\": {\n if (!ChatMessage.isInstance(message))\n throw new Error(\"Invalid generic chat message\");\n return extractGenericMessageCustomRole(message);\n }\n default:\n throw new Error(`Unknown message type: ${type}`);\n }\n}\n\nexport function _modelPrefersResponsesAPI(model: string): boolean {\n if (model.includes(\"gpt-5.2-pro\")) return true;\n if (model.includes(\"gpt-5.4-pro\")) return true;\n if (model.includes(\"gpt-5.5-pro\")) return true;\n // Codex models are Responses API only\n if (model.includes(\"codex\")) return true;\n return false;\n}\n"],"mappings":";;AAQA,MAAa,QAAW,OAAgB,IAAI;AAE5C,SAAgB,iBAAiB,OAAgB;AAC/C,KAAI,CAAC,MAAO,QAAO;AACnB,KAAI,OAAO,KAAK,SAAS,GAAG,CAAE,QAAO;AACrC,KAAI,MAAM,WAAW,QAAQ,IAAI,CAAC,MAAM,WAAW,aAAa,CAAE,QAAO;AACzE,QAAO;;AAGT,SAAgB,gCAAgC,SAAsB;AACpE,KACE,QAAQ,SAAS,YACjB,QAAQ,SAAS,eACjB,QAAQ,SAAS,eACjB,QAAQ,SAAS,UACjB,QAAQ,SAAS,cACjB,QAAQ,SAAS,OAEjB,SAAQ,KAAK,yBAAyB,QAAQ,OAAO;AAGvD,QAAO,QAAQ;;AAGjB,SAAgB,wBACd,OAIoB;AACpB,QAAQ,MAAM,UAAU,YACtB,MAAM,UAAU,QAChB,MAAM,UAAU;;AAGpB,MAAa,4BAA4B;AAEzC,SAAgB,gCACd,OAIQ;CACR,MAAM,WAAY,MAAM,UAAU,YAChC,MAAM,UAAU,QAChB,MAAM,UAAU;AAElB,KAAI,CAAC,UAAU;AACb,UAAQ,KACN,gPAID;AACD,SAAO;;AAGT,QAAO;;AAET,SAAgB,oBACd,SACiC;CACjC,MAAM,OAAO,QAAQ,UAAU;AAC/B,SAAQ,MAAR;EACE,KAAK,SACH,QAAO;EACT,KAAK,KACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,WACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK;AACH,OAAI,CAACA,yBAAAA,YAAY,WAAW,QAAQ,CAClC,OAAM,IAAI,MAAM,+BAA+B;AACjD,UAAO,gCAAgC,QAAQ;EAEjD,QACE,OAAM,IAAI,MAAM,yBAAyB,OAAO;;;AAItD,SAAgB,0BAA0B,OAAwB;AAChE,KAAI,MAAM,SAAS,cAAc,CAAE,QAAO;AAC1C,KAAI,MAAM,SAAS,cAAc,CAAE,QAAO;AAC1C,KAAI,MAAM,SAAS,cAAc,CAAE,QAAO;AAE1C,KAAI,MAAM,SAAS,QAAQ,CAAE,QAAO;AACpC,QAAO"}
1
+ {"version":3,"file":"misc.cjs","names":["ChatMessage"],"sources":["../../src/utils/misc.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport {\n BaseMessage,\n ChatMessage,\n ContentBlock,\n Data,\n} from \"@langchain/core/messages\";\n\nexport const iife = <T>(fn: () => T) => fn();\n\nexport function isReasoningModel(model?: string) {\n if (!model) return false;\n if (/^o\\d/.test(model ?? \"\")) return true;\n if (model.startsWith(\"gpt-5\") && !model.startsWith(\"gpt-5-chat\")) return true;\n return false;\n}\n\nexport function extractGenericMessageCustomRole(message: ChatMessage) {\n if (\n message.role !== \"system\" &&\n message.role !== \"developer\" &&\n message.role !== \"assistant\" &&\n message.role !== \"user\" &&\n message.role !== \"function\" &&\n message.role !== \"tool\"\n ) {\n console.warn(`Unknown message role: ${message.role}`);\n }\n\n return message.role as OpenAIClient.ChatCompletionRole;\n}\n\nexport function getFilenameFromMetadata(\n block:\n | ContentBlock.Multimodal.File\n | ContentBlock.Multimodal.Video\n | Data.StandardFileBlock\n): string | undefined {\n return (block.metadata?.filename ??\n block.metadata?.name ??\n block.metadata?.title) as string;\n}\n\nexport const LC_AUTOGENERATED_FILENAME = \"LC_AUTOGENERATED\";\n\nexport function getRequiredFilenameFromMetadata(\n block:\n | ContentBlock.Multimodal.File\n | ContentBlock.Multimodal.Video\n | Data.StandardFileBlock\n): string {\n const filename = (block.metadata?.filename ??\n block.metadata?.name ??\n block.metadata?.title) as string;\n\n if (!filename) {\n console.warn(\n \"OpenAI may require a filename for file uploads. Specify a filename \" +\n \"in the content block metadata, e.g.: { type: 'file', mimeType: \" +\n \"'...', data: '...', metadata: { filename: 'my-file.pdf' } }. \" +\n \"Using placeholder filename 'LC_AUTOGENERATED'.\"\n );\n return LC_AUTOGENERATED_FILENAME;\n }\n\n return filename;\n}\nexport function messageToOpenAIRole(\n message: BaseMessage\n): OpenAIClient.ChatCompletionRole {\n const type = message._getType();\n switch (type) {\n case \"system\":\n return \"system\";\n case \"ai\":\n return \"assistant\";\n case \"human\":\n return \"user\";\n case \"function\":\n return \"function\";\n case \"tool\":\n return \"tool\";\n case \"generic\": {\n if (!ChatMessage.isInstance(message))\n throw new Error(\"Invalid generic chat message\");\n return extractGenericMessageCustomRole(message);\n }\n default:\n throw new Error(`Unknown message type: ${type}`);\n }\n}\n\nexport function _modelPrefersResponsesAPI(model: string): boolean {\n if (model.includes(\"gpt-5.2-pro\")) return true;\n if (model.includes(\"gpt-5.4-pro\")) return true;\n if (model.includes(\"gpt-5.5-pro\")) return true;\n // Codex models are Responses API only\n if (model.includes(\"codex\")) return true;\n return false;\n}\n"],"mappings":";;AAQA,MAAa,QAAW,OAAgB,GAAG;AAE3C,SAAgB,iBAAiB,OAAgB;CAC/C,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI,OAAO,KAAK,SAAS,EAAE,GAAG,OAAO;CACrC,IAAI,MAAM,WAAW,OAAO,KAAK,CAAC,MAAM,WAAW,YAAY,GAAG,OAAO;CACzE,OAAO;AACT;AAEA,SAAgB,gCAAgC,SAAsB;CACpE,IACE,QAAQ,SAAS,YACjB,QAAQ,SAAS,eACjB,QAAQ,SAAS,eACjB,QAAQ,SAAS,UACjB,QAAQ,SAAS,cACjB,QAAQ,SAAS,QAEjB,QAAQ,KAAK,yBAAyB,QAAQ,MAAM;CAGtD,OAAO,QAAQ;AACjB;AAEA,SAAgB,wBACd,OAIoB;CACpB,OAAQ,MAAM,UAAU,YACtB,MAAM,UAAU,QAChB,MAAM,UAAU;AACpB;AAEA,MAAa,4BAA4B;AAEzC,SAAgB,gCACd,OAIQ;CACR,MAAM,WAAY,MAAM,UAAU,YAChC,MAAM,UAAU,QAChB,MAAM,UAAU;CAElB,IAAI,CAAC,UAAU;EACb,QAAQ,KACN,+OAIF;EACA,OAAO;CACT;CAEA,OAAO;AACT;AACA,SAAgB,oBACd,SACiC;CACjC,MAAM,OAAO,QAAQ,SAAS;CAC9B,QAAQ,MAAR;EACE,KAAK,UACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,KAAK,SACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK;GACH,IAAI,CAACA,yBAAAA,YAAY,WAAW,OAAO,GACjC,MAAM,IAAI,MAAM,8BAA8B;GAChD,OAAO,gCAAgC,OAAO;EAEhD,SACE,MAAM,IAAI,MAAM,yBAAyB,MAAM;CACnD;AACF;AAEA,SAAgB,0BAA0B,OAAwB;CAChE,IAAI,MAAM,SAAS,aAAa,GAAG,OAAO;CAC1C,IAAI,MAAM,SAAS,aAAa,GAAG,OAAO;CAC1C,IAAI,MAAM,SAAS,aAAa,GAAG,OAAO;CAE1C,IAAI,MAAM,SAAS,OAAO,GAAG,OAAO;CACpC,OAAO;AACT"}
@@ -1,6 +1,5 @@
1
1
  import { OpenAI } from "openai";
2
2
  import { BaseMessage, ContentBlock } from "@langchain/core/messages";
3
-
4
3
  //#region src/utils/misc.d.ts
5
4
  declare function messageToOpenAIRole(message: BaseMessage): OpenAI.ChatCompletionRole;
6
5
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"misc.d.cts","names":[],"sources":["../../src/utils/misc.ts"],"mappings":";;;;iBAmEgB,mBAAA,CACd,OAAA,EAAS,WAAA,GACR,MAAA,CAAa,kBAAA"}
1
+ {"version":3,"file":"misc.d.cts","names":[],"sources":["../../src/utils/misc.ts"],"mappings":";;;iBAmEgB,oBACd,SAAS,cACR,OAAa"}
@@ -1,6 +1,5 @@
1
1
  import { OpenAI } from "openai";
2
2
  import { BaseMessage, ChatMessage, ContentBlock } from "@langchain/core/messages";
3
-
4
3
  //#region src/utils/misc.d.ts
5
4
  declare function messageToOpenAIRole(message: BaseMessage): OpenAI.ChatCompletionRole;
6
5
  //#endregion