@langchain/openai 1.1.3 → 1.2.0-dev-1765431816670

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 (204) hide show
  1. package/README.md +583 -2
  2. package/dist/azure/chat_models/common.d.cts.map +1 -0
  3. package/dist/azure/chat_models/common.d.ts.map +1 -0
  4. package/dist/azure/chat_models/completions.d.cts.map +1 -0
  5. package/dist/azure/chat_models/completions.d.ts.map +1 -0
  6. package/dist/azure/chat_models/index.d.cts +1 -1
  7. package/dist/azure/chat_models/index.d.cts.map +1 -0
  8. package/dist/azure/chat_models/index.d.ts.map +1 -0
  9. package/dist/azure/chat_models/responses.d.cts.map +1 -0
  10. package/dist/azure/chat_models/responses.d.ts.map +1 -0
  11. package/dist/azure/embeddings.d.cts.map +1 -0
  12. package/dist/azure/embeddings.d.ts.map +1 -0
  13. package/dist/azure/llms.d.cts +0 -1
  14. package/dist/azure/llms.d.cts.map +1 -0
  15. package/dist/azure/llms.d.ts +0 -1
  16. package/dist/azure/llms.d.ts.map +1 -0
  17. package/dist/chat_models/base.cjs +5 -1
  18. package/dist/chat_models/base.cjs.map +1 -1
  19. package/dist/chat_models/base.d.cts +8 -22
  20. package/dist/chat_models/base.d.cts.map +1 -0
  21. package/dist/chat_models/base.d.ts +6 -20
  22. package/dist/chat_models/base.d.ts.map +1 -0
  23. package/dist/chat_models/base.js +6 -2
  24. package/dist/chat_models/base.js.map +1 -1
  25. package/dist/chat_models/completions.cjs.map +1 -1
  26. package/dist/chat_models/completions.d.cts +1 -3
  27. package/dist/chat_models/completions.d.cts.map +1 -0
  28. package/dist/chat_models/completions.d.ts +1 -3
  29. package/dist/chat_models/completions.d.ts.map +1 -0
  30. package/dist/chat_models/completions.js.map +1 -1
  31. package/dist/chat_models/index.d.cts +42 -4
  32. package/dist/chat_models/index.d.cts.map +1 -0
  33. package/dist/chat_models/index.d.ts +42 -4
  34. package/dist/chat_models/index.d.ts.map +1 -0
  35. package/dist/chat_models/responses.d.cts +2 -2
  36. package/dist/chat_models/responses.d.cts.map +1 -0
  37. package/dist/chat_models/responses.d.ts +2 -2
  38. package/dist/chat_models/responses.d.ts.map +1 -0
  39. package/dist/converters/completions.cjs +22 -12
  40. package/dist/converters/completions.cjs.map +1 -1
  41. package/dist/converters/completions.d.cts +0 -1
  42. package/dist/converters/completions.d.cts.map +1 -0
  43. package/dist/converters/completions.d.ts +0 -1
  44. package/dist/converters/completions.d.ts.map +1 -0
  45. package/dist/converters/completions.js +23 -13
  46. package/dist/converters/completions.js.map +1 -1
  47. package/dist/converters/responses.cjs +37 -4
  48. package/dist/converters/responses.cjs.map +1 -1
  49. package/dist/converters/responses.d.cts.map +1 -0
  50. package/dist/converters/responses.d.ts.map +1 -0
  51. package/dist/converters/responses.js +39 -6
  52. package/dist/converters/responses.js.map +1 -1
  53. package/dist/embeddings.d.cts +0 -1
  54. package/dist/embeddings.d.cts.map +1 -0
  55. package/dist/embeddings.d.ts +0 -1
  56. package/dist/embeddings.d.ts.map +1 -0
  57. package/dist/index.cjs +2 -1
  58. package/dist/index.d.cts +12 -2
  59. package/dist/index.d.ts +12 -3
  60. package/dist/index.js +2 -2
  61. package/dist/llms.d.cts +0 -1
  62. package/dist/llms.d.cts.map +1 -0
  63. package/dist/llms.d.ts +0 -1
  64. package/dist/llms.d.ts.map +1 -0
  65. package/dist/tools/applyPatch.cjs +116 -0
  66. package/dist/tools/applyPatch.cjs.map +1 -0
  67. package/dist/tools/applyPatch.d.cts +148 -0
  68. package/dist/tools/applyPatch.d.cts.map +1 -0
  69. package/dist/tools/applyPatch.d.ts +148 -0
  70. package/dist/tools/applyPatch.d.ts.map +1 -0
  71. package/dist/tools/applyPatch.js +115 -0
  72. package/dist/tools/applyPatch.js.map +1 -0
  73. package/dist/tools/codeInterpreter.cjs +95 -0
  74. package/dist/tools/codeInterpreter.cjs.map +1 -0
  75. package/dist/tools/codeInterpreter.d.cts +125 -0
  76. package/dist/tools/codeInterpreter.d.cts.map +1 -0
  77. package/dist/tools/codeInterpreter.d.ts +125 -0
  78. package/dist/tools/codeInterpreter.d.ts.map +1 -0
  79. package/dist/tools/codeInterpreter.js +94 -0
  80. package/dist/tools/codeInterpreter.js.map +1 -0
  81. package/dist/tools/computerUse.cjs +240 -0
  82. package/dist/tools/computerUse.cjs.map +1 -0
  83. package/dist/tools/computerUse.d.cts +234 -0
  84. package/dist/tools/computerUse.d.cts.map +1 -0
  85. package/dist/tools/computerUse.d.ts +234 -0
  86. package/dist/tools/computerUse.d.ts.map +1 -0
  87. package/dist/tools/computerUse.js +239 -0
  88. package/dist/tools/computerUse.js.map +1 -0
  89. package/dist/tools/custom.d.cts +1 -1
  90. package/dist/tools/custom.d.cts.map +1 -0
  91. package/dist/tools/custom.d.ts.map +1 -0
  92. package/dist/tools/dalle.d.cts +1 -2
  93. package/dist/tools/dalle.d.cts.map +1 -0
  94. package/dist/tools/dalle.d.ts +1 -2
  95. package/dist/tools/dalle.d.ts.map +1 -0
  96. package/dist/tools/fileSearch.cjs +137 -0
  97. package/dist/tools/fileSearch.cjs.map +1 -0
  98. package/dist/tools/fileSearch.d.cts +224 -0
  99. package/dist/tools/fileSearch.d.cts.map +1 -0
  100. package/dist/tools/fileSearch.d.ts +224 -0
  101. package/dist/tools/fileSearch.d.ts.map +1 -0
  102. package/dist/tools/fileSearch.js +136 -0
  103. package/dist/tools/fileSearch.js.map +1 -0
  104. package/dist/tools/imageGeneration.cjs +128 -0
  105. package/dist/tools/imageGeneration.cjs.map +1 -0
  106. package/dist/tools/imageGeneration.d.cts +199 -0
  107. package/dist/tools/imageGeneration.d.cts.map +1 -0
  108. package/dist/tools/imageGeneration.d.ts +199 -0
  109. package/dist/tools/imageGeneration.d.ts.map +1 -0
  110. package/dist/tools/imageGeneration.js +127 -0
  111. package/dist/tools/imageGeneration.js.map +1 -0
  112. package/dist/tools/index.cjs +26 -0
  113. package/dist/tools/index.cjs.map +1 -0
  114. package/dist/tools/index.d.cts +27 -0
  115. package/dist/tools/index.d.cts.map +1 -0
  116. package/dist/tools/index.d.ts +27 -1
  117. package/dist/tools/index.d.ts.map +1 -0
  118. package/dist/tools/index.js +26 -0
  119. package/dist/tools/index.js.map +1 -0
  120. package/dist/tools/localShell.cjs +145 -0
  121. package/dist/tools/localShell.cjs.map +1 -0
  122. package/dist/tools/localShell.d.cts +167 -0
  123. package/dist/tools/localShell.d.cts.map +1 -0
  124. package/dist/tools/localShell.d.ts +167 -0
  125. package/dist/tools/localShell.d.ts.map +1 -0
  126. package/dist/tools/localShell.js +144 -0
  127. package/dist/tools/localShell.js.map +1 -0
  128. package/dist/tools/mcp.cjs +53 -0
  129. package/dist/tools/mcp.cjs.map +1 -0
  130. package/dist/tools/mcp.d.cts +177 -0
  131. package/dist/tools/mcp.d.cts.map +1 -0
  132. package/dist/tools/mcp.d.ts +177 -0
  133. package/dist/tools/mcp.d.ts.map +1 -0
  134. package/dist/tools/mcp.js +52 -0
  135. package/dist/tools/mcp.js.map +1 -0
  136. package/dist/tools/shell.cjs +163 -0
  137. package/dist/tools/shell.cjs.map +1 -0
  138. package/dist/tools/shell.d.cts +221 -0
  139. package/dist/tools/shell.d.cts.map +1 -0
  140. package/dist/tools/shell.d.ts +221 -0
  141. package/dist/tools/shell.d.ts.map +1 -0
  142. package/dist/tools/shell.js +162 -0
  143. package/dist/tools/shell.js.map +1 -0
  144. package/dist/tools/webSearch.cjs +73 -0
  145. package/dist/tools/webSearch.cjs.map +1 -0
  146. package/dist/tools/webSearch.d.cts +130 -0
  147. package/dist/tools/webSearch.d.cts.map +1 -0
  148. package/dist/tools/webSearch.d.ts +130 -0
  149. package/dist/tools/webSearch.d.ts.map +1 -0
  150. package/dist/tools/webSearch.js +72 -0
  151. package/dist/tools/webSearch.js.map +1 -0
  152. package/dist/types.d.cts +2 -4
  153. package/dist/types.d.cts.map +1 -0
  154. package/dist/types.d.ts +1 -3
  155. package/dist/types.d.ts.map +1 -0
  156. package/dist/utils/azure.d.cts +1 -5
  157. package/dist/utils/azure.d.cts.map +1 -0
  158. package/dist/utils/azure.d.ts +1 -5
  159. package/dist/utils/azure.d.ts.map +1 -0
  160. package/dist/utils/client.d.cts.map +1 -0
  161. package/dist/utils/client.d.ts.map +1 -0
  162. package/dist/utils/misc.cjs +6 -0
  163. package/dist/utils/misc.cjs.map +1 -1
  164. package/dist/utils/misc.d.cts +1 -1
  165. package/dist/utils/misc.d.cts.map +1 -0
  166. package/dist/utils/misc.d.ts +1 -1
  167. package/dist/utils/misc.d.ts.map +1 -0
  168. package/dist/utils/misc.js +6 -1
  169. package/dist/utils/misc.js.map +1 -1
  170. package/dist/utils/prompts.d.cts +0 -1
  171. package/dist/utils/prompts.d.cts.map +1 -0
  172. package/dist/utils/prompts.d.ts +0 -1
  173. package/dist/utils/prompts.d.ts.map +1 -0
  174. package/dist/utils/tools.cjs +39 -1
  175. package/dist/utils/tools.cjs.map +1 -1
  176. package/dist/utils/tools.d.cts.map +1 -0
  177. package/dist/utils/tools.d.ts.map +1 -0
  178. package/dist/utils/tools.js +37 -2
  179. package/dist/utils/tools.js.map +1 -1
  180. package/package.json +8 -6
  181. package/dist/langchain-core/dist/callbacks/base.d.ts +0 -1
  182. package/dist/langchain-core/dist/callbacks/manager.d.ts +0 -2
  183. package/dist/langchain-core/dist/documents/transformers.d.ts +0 -2
  184. package/dist/langchain-core/dist/language_models/base.d.ts +0 -7
  185. package/dist/langchain-core/dist/language_models/chat_models.d.cts +0 -13
  186. package/dist/langchain-core/dist/language_models/chat_models.d.ts +0 -23
  187. package/dist/langchain-core/dist/messages/index.d.ts +0 -1
  188. package/dist/langchain-core/dist/messages/transformers.d.ts +0 -3
  189. package/dist/langchain-core/dist/runnables/base.d.ts +0 -7
  190. package/dist/langchain-core/dist/runnables/config.d.ts +0 -2
  191. package/dist/langchain-core/dist/runnables/graph.d.ts +0 -1
  192. package/dist/langchain-core/dist/runnables/types.d.ts +0 -2
  193. package/dist/langchain-core/dist/tools/index.d.ts +0 -8
  194. package/dist/langchain-core/dist/tools/types.d.ts +0 -7
  195. package/dist/langchain-core/dist/tracers/base.d.ts +0 -2
  196. package/dist/langchain-core/dist/tracers/event_stream.d.ts +0 -2
  197. package/dist/langchain-core/dist/tracers/log_stream.d.ts +0 -3
  198. package/dist/langchain-core/dist/types/_internal.d.cts +0 -11
  199. package/dist/langchain-core/dist/types/_internal.d.ts +0 -11
  200. package/dist/langchain-core/dist/utils/json_schema.d.ts +0 -1
  201. package/dist/langchain-core/dist/utils/stream.d.cts +0 -26
  202. package/dist/langchain-core/dist/utils/stream.d.ts +0 -26
  203. package/dist/langchain-core/dist/utils/types/index.d.ts +0 -1
  204. package/dist/langchain-core/dist/utils/types/zod.d.ts +0 -1
@@ -0,0 +1,116 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langchain/core/tools"));
3
+ const zod_v4 = require_rolldown_runtime.__toESM(require("zod/v4"));
4
+
5
+ //#region src/tools/applyPatch.ts
6
+ const ApplyPatchCreateFileOperationSchema = zod_v4.z.object({
7
+ type: zod_v4.z.literal("create_file"),
8
+ path: zod_v4.z.string(),
9
+ diff: zod_v4.z.string()
10
+ });
11
+ const ApplyPatchUpdateFileOperationSchema = zod_v4.z.object({
12
+ type: zod_v4.z.literal("update_file"),
13
+ path: zod_v4.z.string(),
14
+ diff: zod_v4.z.string()
15
+ });
16
+ const ApplyPatchDeleteFileOperationSchema = zod_v4.z.object({
17
+ type: zod_v4.z.literal("delete_file"),
18
+ path: zod_v4.z.string()
19
+ });
20
+ const ApplyPatchOperationSchema = zod_v4.z.discriminatedUnion("type", [
21
+ ApplyPatchCreateFileOperationSchema,
22
+ ApplyPatchUpdateFileOperationSchema,
23
+ ApplyPatchDeleteFileOperationSchema
24
+ ]);
25
+ const TOOL_NAME = "apply_patch";
26
+ /**
27
+ * Creates an Apply Patch tool that allows models to propose structured diffs
28
+ * that your integration applies. This enables iterative, multi-step code
29
+ * editing workflows.
30
+ *
31
+ * **Apply Patch** lets GPT-5.1 create, update, and delete files in your codebase
32
+ * using structured diffs. Instead of just suggesting edits, the model emits
33
+ * patch operations that your application applies and then reports back on.
34
+ *
35
+ * **When to use**:
36
+ * - **Multi-file refactors** – Rename symbols, extract helpers, or reorganize modules
37
+ * - **Bug fixes** – Have the model both diagnose issues and emit precise patches
38
+ * - **Tests & docs generation** – Create new test files, fixtures, and documentation
39
+ * - **Migrations & mechanical edits** – Apply repetitive, structured updates
40
+ *
41
+ * **How it works**:
42
+ * The tool operates in a continuous loop:
43
+ * 1. Model sends patch operations (`apply_patch_call` with operation type)
44
+ * 2. Your code applies the patch to your working directory or repo
45
+ * 3. You return success/failure status and optional output
46
+ * 4. Repeat until the task is complete
47
+ *
48
+ * **Security Warning**: Applying patches can modify files in your codebase.
49
+ * Always validate paths, implement backups, and consider sandboxing.
50
+ *
51
+ * @see {@link https://platform.openai.com/docs/guides/tools-apply-patch | OpenAI Apply Patch Documentation}
52
+ *
53
+ * @param options - Configuration options for the Apply Patch tool
54
+ * @returns An Apply Patch tool that can be passed to `bindTools`
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * import { ChatOpenAI, tools } from "@langchain/openai";
59
+ * import { applyDiff } from "@openai/agents";
60
+ * import * as fs from "fs/promises";
61
+ *
62
+ * const model = new ChatOpenAI({ model: "gpt-5.1" });
63
+ *
64
+ * // With execute callback for automatic patch handling
65
+ * const patchTool = tools.applyPatch({
66
+ * execute: async (operation) => {
67
+ * if (operation.type === "create_file") {
68
+ * const content = applyDiff("", operation.diff, "create");
69
+ * await fs.writeFile(operation.path, content);
70
+ * return `Created ${operation.path}`;
71
+ * }
72
+ * if (operation.type === "update_file") {
73
+ * const current = await fs.readFile(operation.path, "utf-8");
74
+ * const newContent = applyDiff(current, operation.diff);
75
+ * await fs.writeFile(operation.path, newContent);
76
+ * return `Updated ${operation.path}`;
77
+ * }
78
+ * if (operation.type === "delete_file") {
79
+ * await fs.unlink(operation.path);
80
+ * return `Deleted ${operation.path}`;
81
+ * }
82
+ * return "Unknown operation type";
83
+ * },
84
+ * });
85
+ *
86
+ * const llmWithPatch = model.bindTools([patchTool]);
87
+ * const response = await llmWithPatch.invoke(
88
+ * "Rename the fib() function to fibonacci() in lib/fib.py"
89
+ * );
90
+ * ```
91
+ *
92
+ * @remarks
93
+ * - Only available through the Responses API (not Chat Completions)
94
+ * - Designed for use with `gpt-5.1` model
95
+ * - Operations include: `create_file`, `update_file`, `delete_file`
96
+ * - Patches use V4A diff format for updates
97
+ * - Always validate paths to prevent directory traversal attacks
98
+ * - Consider backing up files before applying patches
99
+ * - Implement "all-or-nothing" semantics if atomicity is required
100
+ */
101
+ function applyPatch(options) {
102
+ const patchTool = (0, __langchain_core_tools.tool)(options.execute, {
103
+ name: TOOL_NAME,
104
+ description: "Apply structured diffs to create, update, or delete files in the codebase.",
105
+ schema: ApplyPatchOperationSchema
106
+ });
107
+ patchTool.extras = {
108
+ ...patchTool.extras ?? {},
109
+ providerToolDefinition: { type: "apply_patch" }
110
+ };
111
+ return patchTool;
112
+ }
113
+
114
+ //#endregion
115
+ exports.applyPatch = applyPatch;
116
+ //# sourceMappingURL=applyPatch.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyPatch.cjs","names":["z","options: ApplyPatchOptions"],"sources":["../../src/tools/applyPatch.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 operation types from OpenAI SDK for convenience.\n */\nexport type ApplyPatchCreateFileOperation =\n OpenAIClient.Responses.ResponseApplyPatchToolCall.CreateFile;\nexport type ApplyPatchUpdateFileOperation =\n OpenAIClient.Responses.ResponseApplyPatchToolCall.UpdateFile;\nexport type ApplyPatchDeleteFileOperation =\n OpenAIClient.Responses.ResponseApplyPatchToolCall.DeleteFile;\n\n/**\n * Union type of all apply patch operations from OpenAI SDK.\n */\nexport type ApplyPatchOperation = NonNullable<\n OpenAIClient.Responses.ResponseApplyPatchToolCall[\"operation\"]\n>;\n\n// Zod schemas for apply patch operations\nexport const ApplyPatchCreateFileOperationSchema = z.object({\n type: z.literal(\"create_file\"),\n path: z.string(),\n diff: z.string(),\n});\n\nexport const ApplyPatchUpdateFileOperationSchema = z.object({\n type: z.literal(\"update_file\"),\n path: z.string(),\n diff: z.string(),\n});\n\nexport const ApplyPatchDeleteFileOperationSchema = z.object({\n type: z.literal(\"delete_file\"),\n path: z.string(),\n});\n\n// Discriminated union schema for all apply patch operations\nexport const ApplyPatchOperationSchema = z.discriminatedUnion(\"type\", [\n ApplyPatchCreateFileOperationSchema,\n ApplyPatchUpdateFileOperationSchema,\n ApplyPatchDeleteFileOperationSchema,\n]);\n\n/**\n * Options for the Apply Patch tool.\n */\nexport interface ApplyPatchOptions {\n /**\n * Execute function that handles patch operations.\n * This function receives the operation input and should return a string\n * describing the result (success or failure message).\n *\n * The operation types are:\n * - `create_file`: Create a new file at the specified path with the diff content\n * - `update_file`: Modify an existing file using V4A diff format\n * - `delete_file`: Remove a file at the specified path\n *\n * @example\n * ```typescript\n * execute: async (operation) => {\n * if (operation.type === \"create_file\") {\n * const content = applyDiff(\"\", operation.diff, \"create\");\n * await fs.writeFile(operation.path, content);\n * return `Created ${operation.path}`;\n * }\n * if (operation.type === \"update_file\") {\n * const current = await fs.readFile(operation.path, \"utf-8\");\n * const newContent = applyDiff(current, operation.diff);\n * await fs.writeFile(operation.path, newContent);\n * return `Updated ${operation.path}`;\n * }\n * if (operation.type === \"delete_file\") {\n * await fs.unlink(operation.path);\n * return `Deleted ${operation.path}`;\n * }\n * return \"Unknown operation type\";\n * }\n * ```\n */\n execute: (operation: ApplyPatchOperation) => string | Promise<string>;\n}\n\n/**\n * OpenAI Apply Patch tool type for the Responses API.\n */\nexport type ApplyPatchTool = OpenAIClient.Responses.ApplyPatchTool;\n\nconst TOOL_NAME = \"apply_patch\";\n\n/**\n * Creates an Apply Patch tool that allows models to propose structured diffs\n * that your integration applies. This enables iterative, multi-step code\n * editing workflows.\n *\n * **Apply Patch** lets GPT-5.1 create, update, and delete files in your codebase\n * using structured diffs. Instead of just suggesting edits, the model emits\n * patch operations that your application applies and then reports back on.\n *\n * **When to use**:\n * - **Multi-file refactors** – Rename symbols, extract helpers, or reorganize modules\n * - **Bug fixes** – Have the model both diagnose issues and emit precise patches\n * - **Tests & docs generation** – Create new test files, fixtures, and documentation\n * - **Migrations & mechanical edits** – Apply repetitive, structured updates\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends patch operations (`apply_patch_call` with operation type)\n * 2. Your code applies the patch to your working directory or repo\n * 3. You return success/failure status and optional output\n * 4. Repeat until the task is complete\n *\n * **Security Warning**: Applying patches can modify files in your codebase.\n * Always validate paths, implement backups, and consider sandboxing.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-apply-patch | OpenAI Apply Patch Documentation}\n *\n * @param options - Configuration options for the Apply Patch tool\n * @returns An Apply Patch tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { applyDiff } from \"@openai/agents\";\n * import * as fs from \"fs/promises\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.1\" });\n *\n * // With execute callback for automatic patch handling\n * const patchTool = tools.applyPatch({\n * execute: async (operation) => {\n * if (operation.type === \"create_file\") {\n * const content = applyDiff(\"\", operation.diff, \"create\");\n * await fs.writeFile(operation.path, content);\n * return `Created ${operation.path}`;\n * }\n * if (operation.type === \"update_file\") {\n * const current = await fs.readFile(operation.path, \"utf-8\");\n * const newContent = applyDiff(current, operation.diff);\n * await fs.writeFile(operation.path, newContent);\n * return `Updated ${operation.path}`;\n * }\n * if (operation.type === \"delete_file\") {\n * await fs.unlink(operation.path);\n * return `Deleted ${operation.path}`;\n * }\n * return \"Unknown operation type\";\n * },\n * });\n *\n * const llmWithPatch = model.bindTools([patchTool]);\n * const response = await llmWithPatch.invoke(\n * \"Rename the fib() function to fibonacci() in lib/fib.py\"\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 * - Operations include: `create_file`, `update_file`, `delete_file`\n * - Patches use V4A diff format for updates\n * - Always validate paths to prevent directory traversal attacks\n * - Consider backing up files before applying patches\n * - Implement \"all-or-nothing\" semantics if atomicity is required\n */\nexport function applyPatch(options: ApplyPatchOptions) {\n const patchTool = tool(options.execute, {\n name: TOOL_NAME,\n description:\n \"Apply structured diffs to create, update, or delete files in the codebase.\",\n schema: ApplyPatchOperationSchema,\n });\n\n patchTool.extras = {\n ...(patchTool.extras ?? {}),\n providerToolDefinition: {\n type: \"apply_patch\",\n } satisfies ApplyPatchTool,\n };\n\n return patchTool as DynamicStructuredTool<\n typeof ApplyPatchOperationSchema,\n ApplyPatchOperation,\n unknown,\n string\n >;\n}\n"],"mappings":";;;;;AAsBA,MAAa,sCAAsCA,SAAE,OAAO;CAC1D,MAAMA,SAAE,QAAQ,cAAc;CAC9B,MAAMA,SAAE,QAAQ;CAChB,MAAMA,SAAE,QAAQ;AACjB,EAAC;AAEF,MAAa,sCAAsCA,SAAE,OAAO;CAC1D,MAAMA,SAAE,QAAQ,cAAc;CAC9B,MAAMA,SAAE,QAAQ;CAChB,MAAMA,SAAE,QAAQ;AACjB,EAAC;AAEF,MAAa,sCAAsCA,SAAE,OAAO;CAC1D,MAAMA,SAAE,QAAQ,cAAc;CAC9B,MAAMA,SAAE,QAAQ;AACjB,EAAC;AAGF,MAAa,4BAA4BA,SAAE,mBAAmB,QAAQ;CACpE;CACA;CACA;AACD,EAAC;AA8CF,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6ElB,SAAgB,WAAWC,SAA4B;CACrD,MAAM,6CAAiB,QAAQ,SAAS;EACtC,MAAM;EACN,aACE;EACF,QAAQ;CACT,EAAC;CAEF,UAAU,SAAS;EACjB,GAAI,UAAU,UAAU,CAAE;EAC1B,wBAAwB,EACtB,MAAM,cACP;CACF;AAED,QAAO;AAMR"}
@@ -0,0 +1,148 @@
1
+ import { OpenAI as OpenAI$1 } from "openai";
2
+ import { DynamicStructuredTool } from "@langchain/core/tools";
3
+ import { z } from "zod/v4";
4
+
5
+ //#region src/tools/applyPatch.d.ts
6
+
7
+ /**
8
+ * Re-export operation types from OpenAI SDK for convenience.
9
+ */
10
+ type ApplyPatchCreateFileOperation = OpenAI$1.Responses.ResponseApplyPatchToolCall.CreateFile;
11
+ type ApplyPatchUpdateFileOperation = OpenAI$1.Responses.ResponseApplyPatchToolCall.UpdateFile;
12
+ type ApplyPatchDeleteFileOperation = OpenAI$1.Responses.ResponseApplyPatchToolCall.DeleteFile;
13
+ /**
14
+ * Union type of all apply patch operations from OpenAI SDK.
15
+ */
16
+ type ApplyPatchOperation = NonNullable<OpenAI$1.Responses.ResponseApplyPatchToolCall["operation"]>;
17
+ /**
18
+ * Options for the Apply Patch tool.
19
+ */
20
+ interface ApplyPatchOptions {
21
+ /**
22
+ * Execute function that handles patch operations.
23
+ * This function receives the operation input and should return a string
24
+ * describing the result (success or failure message).
25
+ *
26
+ * The operation types are:
27
+ * - `create_file`: Create a new file at the specified path with the diff content
28
+ * - `update_file`: Modify an existing file using V4A diff format
29
+ * - `delete_file`: Remove a file at the specified path
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * execute: async (operation) => {
34
+ * if (operation.type === "create_file") {
35
+ * const content = applyDiff("", operation.diff, "create");
36
+ * await fs.writeFile(operation.path, content);
37
+ * return `Created ${operation.path}`;
38
+ * }
39
+ * if (operation.type === "update_file") {
40
+ * const current = await fs.readFile(operation.path, "utf-8");
41
+ * const newContent = applyDiff(current, operation.diff);
42
+ * await fs.writeFile(operation.path, newContent);
43
+ * return `Updated ${operation.path}`;
44
+ * }
45
+ * if (operation.type === "delete_file") {
46
+ * await fs.unlink(operation.path);
47
+ * return `Deleted ${operation.path}`;
48
+ * }
49
+ * return "Unknown operation type";
50
+ * }
51
+ * ```
52
+ */
53
+ execute: (operation: ApplyPatchOperation) => string | Promise<string>;
54
+ }
55
+ /**
56
+ * OpenAI Apply Patch tool type for the Responses API.
57
+ */
58
+ type ApplyPatchTool = OpenAI$1.Responses.ApplyPatchTool;
59
+ /**
60
+ * Creates an Apply Patch tool that allows models to propose structured diffs
61
+ * that your integration applies. This enables iterative, multi-step code
62
+ * editing workflows.
63
+ *
64
+ * **Apply Patch** lets GPT-5.1 create, update, and delete files in your codebase
65
+ * using structured diffs. Instead of just suggesting edits, the model emits
66
+ * patch operations that your application applies and then reports back on.
67
+ *
68
+ * **When to use**:
69
+ * - **Multi-file refactors** – Rename symbols, extract helpers, or reorganize modules
70
+ * - **Bug fixes** – Have the model both diagnose issues and emit precise patches
71
+ * - **Tests & docs generation** – Create new test files, fixtures, and documentation
72
+ * - **Migrations & mechanical edits** – Apply repetitive, structured updates
73
+ *
74
+ * **How it works**:
75
+ * The tool operates in a continuous loop:
76
+ * 1. Model sends patch operations (`apply_patch_call` with operation type)
77
+ * 2. Your code applies the patch to your working directory or repo
78
+ * 3. You return success/failure status and optional output
79
+ * 4. Repeat until the task is complete
80
+ *
81
+ * **Security Warning**: Applying patches can modify files in your codebase.
82
+ * Always validate paths, implement backups, and consider sandboxing.
83
+ *
84
+ * @see {@link https://platform.openai.com/docs/guides/tools-apply-patch | OpenAI Apply Patch Documentation}
85
+ *
86
+ * @param options - Configuration options for the Apply Patch tool
87
+ * @returns An Apply Patch tool that can be passed to `bindTools`
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * import { ChatOpenAI, tools } from "@langchain/openai";
92
+ * import { applyDiff } from "@openai/agents";
93
+ * import * as fs from "fs/promises";
94
+ *
95
+ * const model = new ChatOpenAI({ model: "gpt-5.1" });
96
+ *
97
+ * // With execute callback for automatic patch handling
98
+ * const patchTool = tools.applyPatch({
99
+ * execute: async (operation) => {
100
+ * if (operation.type === "create_file") {
101
+ * const content = applyDiff("", operation.diff, "create");
102
+ * await fs.writeFile(operation.path, content);
103
+ * return `Created ${operation.path}`;
104
+ * }
105
+ * if (operation.type === "update_file") {
106
+ * const current = await fs.readFile(operation.path, "utf-8");
107
+ * const newContent = applyDiff(current, operation.diff);
108
+ * await fs.writeFile(operation.path, newContent);
109
+ * return `Updated ${operation.path}`;
110
+ * }
111
+ * if (operation.type === "delete_file") {
112
+ * await fs.unlink(operation.path);
113
+ * return `Deleted ${operation.path}`;
114
+ * }
115
+ * return "Unknown operation type";
116
+ * },
117
+ * });
118
+ *
119
+ * const llmWithPatch = model.bindTools([patchTool]);
120
+ * const response = await llmWithPatch.invoke(
121
+ * "Rename the fib() function to fibonacci() in lib/fib.py"
122
+ * );
123
+ * ```
124
+ *
125
+ * @remarks
126
+ * - Only available through the Responses API (not Chat Completions)
127
+ * - Designed for use with `gpt-5.1` model
128
+ * - Operations include: `create_file`, `update_file`, `delete_file`
129
+ * - Patches use V4A diff format for updates
130
+ * - Always validate paths to prevent directory traversal attacks
131
+ * - Consider backing up files before applying patches
132
+ * - Implement "all-or-nothing" semantics if atomicity is required
133
+ */
134
+ declare function applyPatch(options: ApplyPatchOptions): DynamicStructuredTool<z.ZodDiscriminatedUnion<[z.ZodObject<{
135
+ type: z.ZodLiteral<"create_file">;
136
+ path: z.ZodString;
137
+ diff: z.ZodString;
138
+ }, z.core.$strip>, z.ZodObject<{
139
+ type: z.ZodLiteral<"update_file">;
140
+ path: z.ZodString;
141
+ diff: z.ZodString;
142
+ }, z.core.$strip>, z.ZodObject<{
143
+ type: z.ZodLiteral<"delete_file">;
144
+ path: z.ZodString;
145
+ }, z.core.$strip>]>, ApplyPatchOperation, unknown, string>;
146
+ //#endregion
147
+ export { ApplyPatchCreateFileOperation, ApplyPatchDeleteFileOperation, ApplyPatchOperation, ApplyPatchOptions, ApplyPatchTool, ApplyPatchUpdateFileOperation, applyPatch };
148
+ //# sourceMappingURL=applyPatch.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyPatch.d.cts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","ApplyPatchCreateFileOperation","Responses","ResponseApplyPatchToolCall","CreateFile","ApplyPatchUpdateFileOperation","UpdateFile","ApplyPatchDeleteFileOperation","DeleteFile","ApplyPatchOperation","NonNullable","ApplyPatchCreateFileOperationSchema","ZodLiteral","ZodString","core","$strip","ZodObject","ApplyPatchUpdateFileOperationSchema","ApplyPatchDeleteFileOperationSchema","ApplyPatchOperationSchema","ZodDiscriminatedUnion","ApplyPatchOptions","Promise","ApplyPatchTool","applyPatch"],"sources":["../../src/tools/applyPatch.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\n/**\n * Re-export operation types from OpenAI SDK for convenience.\n */\nexport type ApplyPatchCreateFileOperation = OpenAIClient.Responses.ResponseApplyPatchToolCall.CreateFile;\nexport type ApplyPatchUpdateFileOperation = OpenAIClient.Responses.ResponseApplyPatchToolCall.UpdateFile;\nexport type ApplyPatchDeleteFileOperation = OpenAIClient.Responses.ResponseApplyPatchToolCall.DeleteFile;\n/**\n * Union type of all apply patch operations from OpenAI SDK.\n */\nexport type ApplyPatchOperation = NonNullable<OpenAIClient.Responses.ResponseApplyPatchToolCall[\"operation\"]>;\nexport declare const ApplyPatchCreateFileOperationSchema: z.ZodObject<{\n type: z.ZodLiteral<\"create_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>;\nexport declare const ApplyPatchUpdateFileOperationSchema: z.ZodObject<{\n type: z.ZodLiteral<\"update_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>;\nexport declare const ApplyPatchDeleteFileOperationSchema: z.ZodObject<{\n type: z.ZodLiteral<\"delete_file\">;\n path: z.ZodString;\n}, z.core.$strip>;\nexport declare const ApplyPatchOperationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"create_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"update_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"delete_file\">;\n path: z.ZodString;\n}, z.core.$strip>]>;\n/**\n * Options for the Apply Patch tool.\n */\nexport interface ApplyPatchOptions {\n /**\n * Execute function that handles patch operations.\n * This function receives the operation input and should return a string\n * describing the result (success or failure message).\n *\n * The operation types are:\n * - `create_file`: Create a new file at the specified path with the diff content\n * - `update_file`: Modify an existing file using V4A diff format\n * - `delete_file`: Remove a file at the specified path\n *\n * @example\n * ```typescript\n * execute: async (operation) => {\n * if (operation.type === \"create_file\") {\n * const content = applyDiff(\"\", operation.diff, \"create\");\n * await fs.writeFile(operation.path, content);\n * return `Created ${operation.path}`;\n * }\n * if (operation.type === \"update_file\") {\n * const current = await fs.readFile(operation.path, \"utf-8\");\n * const newContent = applyDiff(current, operation.diff);\n * await fs.writeFile(operation.path, newContent);\n * return `Updated ${operation.path}`;\n * }\n * if (operation.type === \"delete_file\") {\n * await fs.unlink(operation.path);\n * return `Deleted ${operation.path}`;\n * }\n * return \"Unknown operation type\";\n * }\n * ```\n */\n execute: (operation: ApplyPatchOperation) => string | Promise<string>;\n}\n/**\n * OpenAI Apply Patch tool type for the Responses API.\n */\nexport type ApplyPatchTool = OpenAIClient.Responses.ApplyPatchTool;\n/**\n * Creates an Apply Patch tool that allows models to propose structured diffs\n * that your integration applies. This enables iterative, multi-step code\n * editing workflows.\n *\n * **Apply Patch** lets GPT-5.1 create, update, and delete files in your codebase\n * using structured diffs. Instead of just suggesting edits, the model emits\n * patch operations that your application applies and then reports back on.\n *\n * **When to use**:\n * - **Multi-file refactors** – Rename symbols, extract helpers, or reorganize modules\n * - **Bug fixes** – Have the model both diagnose issues and emit precise patches\n * - **Tests & docs generation** – Create new test files, fixtures, and documentation\n * - **Migrations & mechanical edits** – Apply repetitive, structured updates\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends patch operations (`apply_patch_call` with operation type)\n * 2. Your code applies the patch to your working directory or repo\n * 3. You return success/failure status and optional output\n * 4. Repeat until the task is complete\n *\n * **Security Warning**: Applying patches can modify files in your codebase.\n * Always validate paths, implement backups, and consider sandboxing.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-apply-patch | OpenAI Apply Patch Documentation}\n *\n * @param options - Configuration options for the Apply Patch tool\n * @returns An Apply Patch tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { applyDiff } from \"@openai/agents\";\n * import * as fs from \"fs/promises\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.1\" });\n *\n * // With execute callback for automatic patch handling\n * const patchTool = tools.applyPatch({\n * execute: async (operation) => {\n * if (operation.type === \"create_file\") {\n * const content = applyDiff(\"\", operation.diff, \"create\");\n * await fs.writeFile(operation.path, content);\n * return `Created ${operation.path}`;\n * }\n * if (operation.type === \"update_file\") {\n * const current = await fs.readFile(operation.path, \"utf-8\");\n * const newContent = applyDiff(current, operation.diff);\n * await fs.writeFile(operation.path, newContent);\n * return `Updated ${operation.path}`;\n * }\n * if (operation.type === \"delete_file\") {\n * await fs.unlink(operation.path);\n * return `Deleted ${operation.path}`;\n * }\n * return \"Unknown operation type\";\n * },\n * });\n *\n * const llmWithPatch = model.bindTools([patchTool]);\n * const response = await llmWithPatch.invoke(\n * \"Rename the fib() function to fibonacci() in lib/fib.py\"\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 * - Operations include: `create_file`, `update_file`, `delete_file`\n * - Patches use V4A diff format for updates\n * - Always validate paths to prevent directory traversal attacks\n * - Consider backing up files before applying patches\n * - Implement \"all-or-nothing\" semantics if atomicity is required\n */\nexport declare function applyPatch(options: ApplyPatchOptions): DynamicStructuredTool<z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"create_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"update_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"delete_file\">;\n path: z.ZodString;\n}, z.core.$strip>]>, ApplyPatchOperation, unknown, string>;\n//# sourceMappingURL=applyPatch.d.ts.map"],"mappings":";;;;;;;;AAMA;AACYQ,KADAJ,6BAAAA,GAAgCF,QAAAA,CAAaG,SAAAA,CAAUC,0BAAAA,CAA2BC,UACU;AAC5FG,KADAF,6BAAAA,GAAgCN,QAAAA,CAAaG,SAAAA,CAAUC,0BAAAA,CAA2BG,UACU;AAI5FG,KAJAF,6BAAAA,GAAgCR,QAAAA,CAAaG,SAAAA,CAAUC,0BAAAA,CAA2BK,UAIjD;AA8B7C;AAsCA;AA4EA;AAA4Ca,KAhJhCZ,mBAAAA,GAAsBC,WAgJUW,CAhJEtB,QAAAA,CAAaG,SAAAA,CAAUC,0BAgJzBkB,CAAAA,WAAAA,CAAAA,CAAAA;;;;UAlH3BA,iBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAiCQZ,iCAAiCa;;;;;KAK9CC,cAAAA,GAAiBxB,QAAAA,CAAaG,SAAAA,CAAUqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4E5BC,UAAAA,UAAoBH,oBAAoBrB,sBAAsBH,CAAAA,CAAEuB,uBAAuBvB,CAAAA,CAAEmB;QACvGnB,CAAAA,CAAEe;QACFf,CAAAA,CAAEgB;QACFhB,CAAAA,CAAEgB;GACThB,CAAAA,CAAEiB,IAAAA,CAAKC,SAASlB,CAAAA,CAAEmB;QACXnB,CAAAA,CAAEe;QACFf,CAAAA,CAAEgB;QACFhB,CAAAA,CAAEgB;GACThB,CAAAA,CAAEiB,IAAAA,CAAKC,SAASlB,CAAAA,CAAEmB;QACXnB,CAAAA,CAAEe;QACFf,CAAAA,CAAEgB;GACThB,CAAAA,CAAEiB,IAAAA,CAAKC,WAAWN"}
@@ -0,0 +1,148 @@
1
+ import { OpenAI as OpenAI$1 } from "openai";
2
+ import { DynamicStructuredTool } from "@langchain/core/tools";
3
+ import { z } from "zod/v4";
4
+
5
+ //#region src/tools/applyPatch.d.ts
6
+
7
+ /**
8
+ * Re-export operation types from OpenAI SDK for convenience.
9
+ */
10
+ type ApplyPatchCreateFileOperation = OpenAI$1.Responses.ResponseApplyPatchToolCall.CreateFile;
11
+ type ApplyPatchUpdateFileOperation = OpenAI$1.Responses.ResponseApplyPatchToolCall.UpdateFile;
12
+ type ApplyPatchDeleteFileOperation = OpenAI$1.Responses.ResponseApplyPatchToolCall.DeleteFile;
13
+ /**
14
+ * Union type of all apply patch operations from OpenAI SDK.
15
+ */
16
+ type ApplyPatchOperation = NonNullable<OpenAI$1.Responses.ResponseApplyPatchToolCall["operation"]>;
17
+ /**
18
+ * Options for the Apply Patch tool.
19
+ */
20
+ interface ApplyPatchOptions {
21
+ /**
22
+ * Execute function that handles patch operations.
23
+ * This function receives the operation input and should return a string
24
+ * describing the result (success or failure message).
25
+ *
26
+ * The operation types are:
27
+ * - `create_file`: Create a new file at the specified path with the diff content
28
+ * - `update_file`: Modify an existing file using V4A diff format
29
+ * - `delete_file`: Remove a file at the specified path
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * execute: async (operation) => {
34
+ * if (operation.type === "create_file") {
35
+ * const content = applyDiff("", operation.diff, "create");
36
+ * await fs.writeFile(operation.path, content);
37
+ * return `Created ${operation.path}`;
38
+ * }
39
+ * if (operation.type === "update_file") {
40
+ * const current = await fs.readFile(operation.path, "utf-8");
41
+ * const newContent = applyDiff(current, operation.diff);
42
+ * await fs.writeFile(operation.path, newContent);
43
+ * return `Updated ${operation.path}`;
44
+ * }
45
+ * if (operation.type === "delete_file") {
46
+ * await fs.unlink(operation.path);
47
+ * return `Deleted ${operation.path}`;
48
+ * }
49
+ * return "Unknown operation type";
50
+ * }
51
+ * ```
52
+ */
53
+ execute: (operation: ApplyPatchOperation) => string | Promise<string>;
54
+ }
55
+ /**
56
+ * OpenAI Apply Patch tool type for the Responses API.
57
+ */
58
+ type ApplyPatchTool = OpenAI$1.Responses.ApplyPatchTool;
59
+ /**
60
+ * Creates an Apply Patch tool that allows models to propose structured diffs
61
+ * that your integration applies. This enables iterative, multi-step code
62
+ * editing workflows.
63
+ *
64
+ * **Apply Patch** lets GPT-5.1 create, update, and delete files in your codebase
65
+ * using structured diffs. Instead of just suggesting edits, the model emits
66
+ * patch operations that your application applies and then reports back on.
67
+ *
68
+ * **When to use**:
69
+ * - **Multi-file refactors** – Rename symbols, extract helpers, or reorganize modules
70
+ * - **Bug fixes** – Have the model both diagnose issues and emit precise patches
71
+ * - **Tests & docs generation** – Create new test files, fixtures, and documentation
72
+ * - **Migrations & mechanical edits** – Apply repetitive, structured updates
73
+ *
74
+ * **How it works**:
75
+ * The tool operates in a continuous loop:
76
+ * 1. Model sends patch operations (`apply_patch_call` with operation type)
77
+ * 2. Your code applies the patch to your working directory or repo
78
+ * 3. You return success/failure status and optional output
79
+ * 4. Repeat until the task is complete
80
+ *
81
+ * **Security Warning**: Applying patches can modify files in your codebase.
82
+ * Always validate paths, implement backups, and consider sandboxing.
83
+ *
84
+ * @see {@link https://platform.openai.com/docs/guides/tools-apply-patch | OpenAI Apply Patch Documentation}
85
+ *
86
+ * @param options - Configuration options for the Apply Patch tool
87
+ * @returns An Apply Patch tool that can be passed to `bindTools`
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * import { ChatOpenAI, tools } from "@langchain/openai";
92
+ * import { applyDiff } from "@openai/agents";
93
+ * import * as fs from "fs/promises";
94
+ *
95
+ * const model = new ChatOpenAI({ model: "gpt-5.1" });
96
+ *
97
+ * // With execute callback for automatic patch handling
98
+ * const patchTool = tools.applyPatch({
99
+ * execute: async (operation) => {
100
+ * if (operation.type === "create_file") {
101
+ * const content = applyDiff("", operation.diff, "create");
102
+ * await fs.writeFile(operation.path, content);
103
+ * return `Created ${operation.path}`;
104
+ * }
105
+ * if (operation.type === "update_file") {
106
+ * const current = await fs.readFile(operation.path, "utf-8");
107
+ * const newContent = applyDiff(current, operation.diff);
108
+ * await fs.writeFile(operation.path, newContent);
109
+ * return `Updated ${operation.path}`;
110
+ * }
111
+ * if (operation.type === "delete_file") {
112
+ * await fs.unlink(operation.path);
113
+ * return `Deleted ${operation.path}`;
114
+ * }
115
+ * return "Unknown operation type";
116
+ * },
117
+ * });
118
+ *
119
+ * const llmWithPatch = model.bindTools([patchTool]);
120
+ * const response = await llmWithPatch.invoke(
121
+ * "Rename the fib() function to fibonacci() in lib/fib.py"
122
+ * );
123
+ * ```
124
+ *
125
+ * @remarks
126
+ * - Only available through the Responses API (not Chat Completions)
127
+ * - Designed for use with `gpt-5.1` model
128
+ * - Operations include: `create_file`, `update_file`, `delete_file`
129
+ * - Patches use V4A diff format for updates
130
+ * - Always validate paths to prevent directory traversal attacks
131
+ * - Consider backing up files before applying patches
132
+ * - Implement "all-or-nothing" semantics if atomicity is required
133
+ */
134
+ declare function applyPatch(options: ApplyPatchOptions): DynamicStructuredTool<z.ZodDiscriminatedUnion<[z.ZodObject<{
135
+ type: z.ZodLiteral<"create_file">;
136
+ path: z.ZodString;
137
+ diff: z.ZodString;
138
+ }, z.core.$strip>, z.ZodObject<{
139
+ type: z.ZodLiteral<"update_file">;
140
+ path: z.ZodString;
141
+ diff: z.ZodString;
142
+ }, z.core.$strip>, z.ZodObject<{
143
+ type: z.ZodLiteral<"delete_file">;
144
+ path: z.ZodString;
145
+ }, z.core.$strip>]>, ApplyPatchOperation, unknown, string>;
146
+ //#endregion
147
+ export { ApplyPatchCreateFileOperation, ApplyPatchDeleteFileOperation, ApplyPatchOperation, ApplyPatchOptions, ApplyPatchTool, ApplyPatchUpdateFileOperation, applyPatch };
148
+ //# sourceMappingURL=applyPatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyPatch.d.ts","names":["z","OpenAI","OpenAIClient","DynamicStructuredTool","ApplyPatchCreateFileOperation","Responses","ResponseApplyPatchToolCall","CreateFile","ApplyPatchUpdateFileOperation","UpdateFile","ApplyPatchDeleteFileOperation","DeleteFile","ApplyPatchOperation","NonNullable","ApplyPatchCreateFileOperationSchema","ZodLiteral","ZodString","core","$strip","ZodObject","ApplyPatchUpdateFileOperationSchema","ApplyPatchDeleteFileOperationSchema","ApplyPatchOperationSchema","ZodDiscriminatedUnion","ApplyPatchOptions","Promise","ApplyPatchTool","applyPatch"],"sources":["../../src/tools/applyPatch.d.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { type DynamicStructuredTool } from \"@langchain/core/tools\";\n/**\n * Re-export operation types from OpenAI SDK for convenience.\n */\nexport type ApplyPatchCreateFileOperation = OpenAIClient.Responses.ResponseApplyPatchToolCall.CreateFile;\nexport type ApplyPatchUpdateFileOperation = OpenAIClient.Responses.ResponseApplyPatchToolCall.UpdateFile;\nexport type ApplyPatchDeleteFileOperation = OpenAIClient.Responses.ResponseApplyPatchToolCall.DeleteFile;\n/**\n * Union type of all apply patch operations from OpenAI SDK.\n */\nexport type ApplyPatchOperation = NonNullable<OpenAIClient.Responses.ResponseApplyPatchToolCall[\"operation\"]>;\nexport declare const ApplyPatchCreateFileOperationSchema: z.ZodObject<{\n type: z.ZodLiteral<\"create_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>;\nexport declare const ApplyPatchUpdateFileOperationSchema: z.ZodObject<{\n type: z.ZodLiteral<\"update_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>;\nexport declare const ApplyPatchDeleteFileOperationSchema: z.ZodObject<{\n type: z.ZodLiteral<\"delete_file\">;\n path: z.ZodString;\n}, z.core.$strip>;\nexport declare const ApplyPatchOperationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"create_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"update_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"delete_file\">;\n path: z.ZodString;\n}, z.core.$strip>]>;\n/**\n * Options for the Apply Patch tool.\n */\nexport interface ApplyPatchOptions {\n /**\n * Execute function that handles patch operations.\n * This function receives the operation input and should return a string\n * describing the result (success or failure message).\n *\n * The operation types are:\n * - `create_file`: Create a new file at the specified path with the diff content\n * - `update_file`: Modify an existing file using V4A diff format\n * - `delete_file`: Remove a file at the specified path\n *\n * @example\n * ```typescript\n * execute: async (operation) => {\n * if (operation.type === \"create_file\") {\n * const content = applyDiff(\"\", operation.diff, \"create\");\n * await fs.writeFile(operation.path, content);\n * return `Created ${operation.path}`;\n * }\n * if (operation.type === \"update_file\") {\n * const current = await fs.readFile(operation.path, \"utf-8\");\n * const newContent = applyDiff(current, operation.diff);\n * await fs.writeFile(operation.path, newContent);\n * return `Updated ${operation.path}`;\n * }\n * if (operation.type === \"delete_file\") {\n * await fs.unlink(operation.path);\n * return `Deleted ${operation.path}`;\n * }\n * return \"Unknown operation type\";\n * }\n * ```\n */\n execute: (operation: ApplyPatchOperation) => string | Promise<string>;\n}\n/**\n * OpenAI Apply Patch tool type for the Responses API.\n */\nexport type ApplyPatchTool = OpenAIClient.Responses.ApplyPatchTool;\n/**\n * Creates an Apply Patch tool that allows models to propose structured diffs\n * that your integration applies. This enables iterative, multi-step code\n * editing workflows.\n *\n * **Apply Patch** lets GPT-5.1 create, update, and delete files in your codebase\n * using structured diffs. Instead of just suggesting edits, the model emits\n * patch operations that your application applies and then reports back on.\n *\n * **When to use**:\n * - **Multi-file refactors** – Rename symbols, extract helpers, or reorganize modules\n * - **Bug fixes** – Have the model both diagnose issues and emit precise patches\n * - **Tests & docs generation** – Create new test files, fixtures, and documentation\n * - **Migrations & mechanical edits** – Apply repetitive, structured updates\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends patch operations (`apply_patch_call` with operation type)\n * 2. Your code applies the patch to your working directory or repo\n * 3. You return success/failure status and optional output\n * 4. Repeat until the task is complete\n *\n * **Security Warning**: Applying patches can modify files in your codebase.\n * Always validate paths, implement backups, and consider sandboxing.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-apply-patch | OpenAI Apply Patch Documentation}\n *\n * @param options - Configuration options for the Apply Patch tool\n * @returns An Apply Patch tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { applyDiff } from \"@openai/agents\";\n * import * as fs from \"fs/promises\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.1\" });\n *\n * // With execute callback for automatic patch handling\n * const patchTool = tools.applyPatch({\n * execute: async (operation) => {\n * if (operation.type === \"create_file\") {\n * const content = applyDiff(\"\", operation.diff, \"create\");\n * await fs.writeFile(operation.path, content);\n * return `Created ${operation.path}`;\n * }\n * if (operation.type === \"update_file\") {\n * const current = await fs.readFile(operation.path, \"utf-8\");\n * const newContent = applyDiff(current, operation.diff);\n * await fs.writeFile(operation.path, newContent);\n * return `Updated ${operation.path}`;\n * }\n * if (operation.type === \"delete_file\") {\n * await fs.unlink(operation.path);\n * return `Deleted ${operation.path}`;\n * }\n * return \"Unknown operation type\";\n * },\n * });\n *\n * const llmWithPatch = model.bindTools([patchTool]);\n * const response = await llmWithPatch.invoke(\n * \"Rename the fib() function to fibonacci() in lib/fib.py\"\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 * - Operations include: `create_file`, `update_file`, `delete_file`\n * - Patches use V4A diff format for updates\n * - Always validate paths to prevent directory traversal attacks\n * - Consider backing up files before applying patches\n * - Implement \"all-or-nothing\" semantics if atomicity is required\n */\nexport declare function applyPatch(options: ApplyPatchOptions): DynamicStructuredTool<z.ZodDiscriminatedUnion<[z.ZodObject<{\n type: z.ZodLiteral<\"create_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"update_file\">;\n path: z.ZodString;\n diff: z.ZodString;\n}, z.core.$strip>, z.ZodObject<{\n type: z.ZodLiteral<\"delete_file\">;\n path: z.ZodString;\n}, z.core.$strip>]>, ApplyPatchOperation, unknown, string>;\n//# sourceMappingURL=applyPatch.d.ts.map"],"mappings":";;;;;;;;AAMA;AACYQ,KADAJ,6BAAAA,GAAgCF,QAAAA,CAAaG,SAAAA,CAAUC,0BAAAA,CAA2BC,UACAE;AAClFC,KADAF,6BAAAA,GAAgCN,QAAAA,CAAaG,SAAAA,CAAUC,0BAAAA,CAA2BG,UACAE;AAIlFC,KAJAF,6BAAAA,GAAgCR,QAAAA,CAAaG,SAAAA,CAAUC,0BAAAA,CAA2BK,UAIjD;AA8B7C;AAsCA;AA4EA;AAA4Ca,KAhJhCZ,mBAAAA,GAAsBC,WAgJUW,CAhJEtB,QAAAA,CAAaG,SAAAA,CAAUC,0BAgJzBkB,CAAAA,WAAAA,CAAAA,CAAAA;;;;UAlH3BA,iBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAiCQZ,iCAAiCa;;;;;KAK9CC,cAAAA,GAAiBxB,QAAAA,CAAaG,SAAAA,CAAUqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4E5BC,UAAAA,UAAoBH,oBAAoBrB,sBAAsBH,CAAAA,CAAEuB,uBAAuBvB,CAAAA,CAAEmB;QACvGnB,CAAAA,CAAEe;QACFf,CAAAA,CAAEgB;QACFhB,CAAAA,CAAEgB;GACThB,CAAAA,CAAEiB,IAAAA,CAAKC,SAASlB,CAAAA,CAAEmB;QACXnB,CAAAA,CAAEe;QACFf,CAAAA,CAAEgB;QACFhB,CAAAA,CAAEgB;GACThB,CAAAA,CAAEiB,IAAAA,CAAKC,SAASlB,CAAAA,CAAEmB;QACXnB,CAAAA,CAAEe;QACFf,CAAAA,CAAEgB;GACThB,CAAAA,CAAEiB,IAAAA,CAAKC,WAAWN"}
@@ -0,0 +1,115 @@
1
+ import { tool } from "@langchain/core/tools";
2
+ import { z } from "zod/v4";
3
+
4
+ //#region src/tools/applyPatch.ts
5
+ const ApplyPatchCreateFileOperationSchema = z.object({
6
+ type: z.literal("create_file"),
7
+ path: z.string(),
8
+ diff: z.string()
9
+ });
10
+ const ApplyPatchUpdateFileOperationSchema = z.object({
11
+ type: z.literal("update_file"),
12
+ path: z.string(),
13
+ diff: z.string()
14
+ });
15
+ const ApplyPatchDeleteFileOperationSchema = z.object({
16
+ type: z.literal("delete_file"),
17
+ path: z.string()
18
+ });
19
+ const ApplyPatchOperationSchema = z.discriminatedUnion("type", [
20
+ ApplyPatchCreateFileOperationSchema,
21
+ ApplyPatchUpdateFileOperationSchema,
22
+ ApplyPatchDeleteFileOperationSchema
23
+ ]);
24
+ const TOOL_NAME = "apply_patch";
25
+ /**
26
+ * Creates an Apply Patch tool that allows models to propose structured diffs
27
+ * that your integration applies. This enables iterative, multi-step code
28
+ * editing workflows.
29
+ *
30
+ * **Apply Patch** lets GPT-5.1 create, update, and delete files in your codebase
31
+ * using structured diffs. Instead of just suggesting edits, the model emits
32
+ * patch operations that your application applies and then reports back on.
33
+ *
34
+ * **When to use**:
35
+ * - **Multi-file refactors** – Rename symbols, extract helpers, or reorganize modules
36
+ * - **Bug fixes** – Have the model both diagnose issues and emit precise patches
37
+ * - **Tests & docs generation** – Create new test files, fixtures, and documentation
38
+ * - **Migrations & mechanical edits** – Apply repetitive, structured updates
39
+ *
40
+ * **How it works**:
41
+ * The tool operates in a continuous loop:
42
+ * 1. Model sends patch operations (`apply_patch_call` with operation type)
43
+ * 2. Your code applies the patch to your working directory or repo
44
+ * 3. You return success/failure status and optional output
45
+ * 4. Repeat until the task is complete
46
+ *
47
+ * **Security Warning**: Applying patches can modify files in your codebase.
48
+ * Always validate paths, implement backups, and consider sandboxing.
49
+ *
50
+ * @see {@link https://platform.openai.com/docs/guides/tools-apply-patch | OpenAI Apply Patch Documentation}
51
+ *
52
+ * @param options - Configuration options for the Apply Patch tool
53
+ * @returns An Apply Patch tool that can be passed to `bindTools`
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * import { ChatOpenAI, tools } from "@langchain/openai";
58
+ * import { applyDiff } from "@openai/agents";
59
+ * import * as fs from "fs/promises";
60
+ *
61
+ * const model = new ChatOpenAI({ model: "gpt-5.1" });
62
+ *
63
+ * // With execute callback for automatic patch handling
64
+ * const patchTool = tools.applyPatch({
65
+ * execute: async (operation) => {
66
+ * if (operation.type === "create_file") {
67
+ * const content = applyDiff("", operation.diff, "create");
68
+ * await fs.writeFile(operation.path, content);
69
+ * return `Created ${operation.path}`;
70
+ * }
71
+ * if (operation.type === "update_file") {
72
+ * const current = await fs.readFile(operation.path, "utf-8");
73
+ * const newContent = applyDiff(current, operation.diff);
74
+ * await fs.writeFile(operation.path, newContent);
75
+ * return `Updated ${operation.path}`;
76
+ * }
77
+ * if (operation.type === "delete_file") {
78
+ * await fs.unlink(operation.path);
79
+ * return `Deleted ${operation.path}`;
80
+ * }
81
+ * return "Unknown operation type";
82
+ * },
83
+ * });
84
+ *
85
+ * const llmWithPatch = model.bindTools([patchTool]);
86
+ * const response = await llmWithPatch.invoke(
87
+ * "Rename the fib() function to fibonacci() in lib/fib.py"
88
+ * );
89
+ * ```
90
+ *
91
+ * @remarks
92
+ * - Only available through the Responses API (not Chat Completions)
93
+ * - Designed for use with `gpt-5.1` model
94
+ * - Operations include: `create_file`, `update_file`, `delete_file`
95
+ * - Patches use V4A diff format for updates
96
+ * - Always validate paths to prevent directory traversal attacks
97
+ * - Consider backing up files before applying patches
98
+ * - Implement "all-or-nothing" semantics if atomicity is required
99
+ */
100
+ function applyPatch(options) {
101
+ const patchTool = tool(options.execute, {
102
+ name: TOOL_NAME,
103
+ description: "Apply structured diffs to create, update, or delete files in the codebase.",
104
+ schema: ApplyPatchOperationSchema
105
+ });
106
+ patchTool.extras = {
107
+ ...patchTool.extras ?? {},
108
+ providerToolDefinition: { type: "apply_patch" }
109
+ };
110
+ return patchTool;
111
+ }
112
+
113
+ //#endregion
114
+ export { applyPatch };
115
+ //# sourceMappingURL=applyPatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyPatch.js","names":["options: ApplyPatchOptions"],"sources":["../../src/tools/applyPatch.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 operation types from OpenAI SDK for convenience.\n */\nexport type ApplyPatchCreateFileOperation =\n OpenAIClient.Responses.ResponseApplyPatchToolCall.CreateFile;\nexport type ApplyPatchUpdateFileOperation =\n OpenAIClient.Responses.ResponseApplyPatchToolCall.UpdateFile;\nexport type ApplyPatchDeleteFileOperation =\n OpenAIClient.Responses.ResponseApplyPatchToolCall.DeleteFile;\n\n/**\n * Union type of all apply patch operations from OpenAI SDK.\n */\nexport type ApplyPatchOperation = NonNullable<\n OpenAIClient.Responses.ResponseApplyPatchToolCall[\"operation\"]\n>;\n\n// Zod schemas for apply patch operations\nexport const ApplyPatchCreateFileOperationSchema = z.object({\n type: z.literal(\"create_file\"),\n path: z.string(),\n diff: z.string(),\n});\n\nexport const ApplyPatchUpdateFileOperationSchema = z.object({\n type: z.literal(\"update_file\"),\n path: z.string(),\n diff: z.string(),\n});\n\nexport const ApplyPatchDeleteFileOperationSchema = z.object({\n type: z.literal(\"delete_file\"),\n path: z.string(),\n});\n\n// Discriminated union schema for all apply patch operations\nexport const ApplyPatchOperationSchema = z.discriminatedUnion(\"type\", [\n ApplyPatchCreateFileOperationSchema,\n ApplyPatchUpdateFileOperationSchema,\n ApplyPatchDeleteFileOperationSchema,\n]);\n\n/**\n * Options for the Apply Patch tool.\n */\nexport interface ApplyPatchOptions {\n /**\n * Execute function that handles patch operations.\n * This function receives the operation input and should return a string\n * describing the result (success or failure message).\n *\n * The operation types are:\n * - `create_file`: Create a new file at the specified path with the diff content\n * - `update_file`: Modify an existing file using V4A diff format\n * - `delete_file`: Remove a file at the specified path\n *\n * @example\n * ```typescript\n * execute: async (operation) => {\n * if (operation.type === \"create_file\") {\n * const content = applyDiff(\"\", operation.diff, \"create\");\n * await fs.writeFile(operation.path, content);\n * return `Created ${operation.path}`;\n * }\n * if (operation.type === \"update_file\") {\n * const current = await fs.readFile(operation.path, \"utf-8\");\n * const newContent = applyDiff(current, operation.diff);\n * await fs.writeFile(operation.path, newContent);\n * return `Updated ${operation.path}`;\n * }\n * if (operation.type === \"delete_file\") {\n * await fs.unlink(operation.path);\n * return `Deleted ${operation.path}`;\n * }\n * return \"Unknown operation type\";\n * }\n * ```\n */\n execute: (operation: ApplyPatchOperation) => string | Promise<string>;\n}\n\n/**\n * OpenAI Apply Patch tool type for the Responses API.\n */\nexport type ApplyPatchTool = OpenAIClient.Responses.ApplyPatchTool;\n\nconst TOOL_NAME = \"apply_patch\";\n\n/**\n * Creates an Apply Patch tool that allows models to propose structured diffs\n * that your integration applies. This enables iterative, multi-step code\n * editing workflows.\n *\n * **Apply Patch** lets GPT-5.1 create, update, and delete files in your codebase\n * using structured diffs. Instead of just suggesting edits, the model emits\n * patch operations that your application applies and then reports back on.\n *\n * **When to use**:\n * - **Multi-file refactors** – Rename symbols, extract helpers, or reorganize modules\n * - **Bug fixes** – Have the model both diagnose issues and emit precise patches\n * - **Tests & docs generation** – Create new test files, fixtures, and documentation\n * - **Migrations & mechanical edits** – Apply repetitive, structured updates\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends patch operations (`apply_patch_call` with operation type)\n * 2. Your code applies the patch to your working directory or repo\n * 3. You return success/failure status and optional output\n * 4. Repeat until the task is complete\n *\n * **Security Warning**: Applying patches can modify files in your codebase.\n * Always validate paths, implement backups, and consider sandboxing.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-apply-patch | OpenAI Apply Patch Documentation}\n *\n * @param options - Configuration options for the Apply Patch tool\n * @returns An Apply Patch tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { applyDiff } from \"@openai/agents\";\n * import * as fs from \"fs/promises\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-5.1\" });\n *\n * // With execute callback for automatic patch handling\n * const patchTool = tools.applyPatch({\n * execute: async (operation) => {\n * if (operation.type === \"create_file\") {\n * const content = applyDiff(\"\", operation.diff, \"create\");\n * await fs.writeFile(operation.path, content);\n * return `Created ${operation.path}`;\n * }\n * if (operation.type === \"update_file\") {\n * const current = await fs.readFile(operation.path, \"utf-8\");\n * const newContent = applyDiff(current, operation.diff);\n * await fs.writeFile(operation.path, newContent);\n * return `Updated ${operation.path}`;\n * }\n * if (operation.type === \"delete_file\") {\n * await fs.unlink(operation.path);\n * return `Deleted ${operation.path}`;\n * }\n * return \"Unknown operation type\";\n * },\n * });\n *\n * const llmWithPatch = model.bindTools([patchTool]);\n * const response = await llmWithPatch.invoke(\n * \"Rename the fib() function to fibonacci() in lib/fib.py\"\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 * - Operations include: `create_file`, `update_file`, `delete_file`\n * - Patches use V4A diff format for updates\n * - Always validate paths to prevent directory traversal attacks\n * - Consider backing up files before applying patches\n * - Implement \"all-or-nothing\" semantics if atomicity is required\n */\nexport function applyPatch(options: ApplyPatchOptions) {\n const patchTool = tool(options.execute, {\n name: TOOL_NAME,\n description:\n \"Apply structured diffs to create, update, or delete files in the codebase.\",\n schema: ApplyPatchOperationSchema,\n });\n\n patchTool.extras = {\n ...(patchTool.extras ?? {}),\n providerToolDefinition: {\n type: \"apply_patch\",\n } satisfies ApplyPatchTool,\n };\n\n return patchTool as DynamicStructuredTool<\n typeof ApplyPatchOperationSchema,\n ApplyPatchOperation,\n unknown,\n string\n >;\n}\n"],"mappings":";;;;AAsBA,MAAa,sCAAsC,EAAE,OAAO;CAC1D,MAAM,EAAE,QAAQ,cAAc;CAC9B,MAAM,EAAE,QAAQ;CAChB,MAAM,EAAE,QAAQ;AACjB,EAAC;AAEF,MAAa,sCAAsC,EAAE,OAAO;CAC1D,MAAM,EAAE,QAAQ,cAAc;CAC9B,MAAM,EAAE,QAAQ;CAChB,MAAM,EAAE,QAAQ;AACjB,EAAC;AAEF,MAAa,sCAAsC,EAAE,OAAO;CAC1D,MAAM,EAAE,QAAQ,cAAc;CAC9B,MAAM,EAAE,QAAQ;AACjB,EAAC;AAGF,MAAa,4BAA4B,EAAE,mBAAmB,QAAQ;CACpE;CACA;CACA;AACD,EAAC;AA8CF,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6ElB,SAAgB,WAAWA,SAA4B;CACrD,MAAM,YAAY,KAAK,QAAQ,SAAS;EACtC,MAAM;EACN,aACE;EACF,QAAQ;CACT,EAAC;CAEF,UAAU,SAAS;EACjB,GAAI,UAAU,UAAU,CAAE;EAC1B,wBAAwB,EACtB,MAAM,cACP;CACF;AAED,QAAO;AAMR"}