@langchain/anthropic 1.2.3 → 1.3.0-dev-1765432861398

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 (112) hide show
  1. package/README.md +620 -3
  2. package/dist/chat_models.cjs +8 -5
  3. package/dist/chat_models.cjs.map +1 -1
  4. package/dist/chat_models.d.cts +13 -16
  5. package/dist/chat_models.d.cts.map +1 -0
  6. package/dist/chat_models.d.ts +13 -16
  7. package/dist/chat_models.d.ts.map +1 -0
  8. package/dist/chat_models.js +7 -4
  9. package/dist/chat_models.js.map +1 -1
  10. package/dist/index.cjs +3 -1
  11. package/dist/index.d.cts +12 -2
  12. package/dist/index.d.ts +12 -2
  13. package/dist/index.js +2 -1
  14. package/dist/tools/bash.cjs +95 -0
  15. package/dist/tools/bash.cjs.map +1 -0
  16. package/dist/tools/bash.d.cts +99 -0
  17. package/dist/tools/bash.d.cts.map +1 -0
  18. package/dist/tools/bash.d.ts +99 -0
  19. package/dist/tools/bash.d.ts.map +1 -0
  20. package/dist/tools/bash.js +94 -0
  21. package/dist/tools/bash.js.map +1 -0
  22. package/dist/tools/codeExecution.cjs +70 -0
  23. package/dist/tools/codeExecution.cjs.map +1 -0
  24. package/dist/tools/codeExecution.d.cts +75 -0
  25. package/dist/tools/codeExecution.d.cts.map +1 -0
  26. package/dist/tools/codeExecution.d.ts +75 -0
  27. package/dist/tools/codeExecution.d.ts.map +1 -0
  28. package/dist/tools/codeExecution.js +69 -0
  29. package/dist/tools/codeExecution.js.map +1 -0
  30. package/dist/tools/computer.cjs +161 -0
  31. package/dist/tools/computer.cjs.map +1 -0
  32. package/dist/tools/computer.d.cts +289 -0
  33. package/dist/tools/computer.d.cts.map +1 -0
  34. package/dist/tools/computer.d.ts +289 -0
  35. package/dist/tools/computer.d.ts.map +1 -0
  36. package/dist/tools/computer.js +159 -0
  37. package/dist/tools/computer.js.map +1 -0
  38. package/dist/tools/index.cjs +28 -0
  39. package/dist/tools/index.cjs.map +1 -0
  40. package/dist/tools/index.d.cts +28 -0
  41. package/dist/tools/index.d.cts.map +1 -0
  42. package/dist/tools/index.d.ts +28 -0
  43. package/dist/tools/index.d.ts.map +1 -0
  44. package/dist/tools/index.js +28 -0
  45. package/dist/tools/index.js.map +1 -0
  46. package/dist/tools/mcpToolset.cjs +111 -0
  47. package/dist/tools/mcpToolset.cjs.map +1 -0
  48. package/dist/tools/mcpToolset.d.cts +141 -0
  49. package/dist/tools/mcpToolset.d.cts.map +1 -0
  50. package/dist/tools/mcpToolset.d.ts +141 -0
  51. package/dist/tools/mcpToolset.d.ts.map +1 -0
  52. package/dist/tools/mcpToolset.js +110 -0
  53. package/dist/tools/mcpToolset.js.map +1 -0
  54. package/dist/tools/memory.cjs +56 -0
  55. package/dist/tools/memory.cjs.map +1 -0
  56. package/dist/tools/memory.d.cts +92 -0
  57. package/dist/tools/memory.d.cts.map +1 -0
  58. package/dist/tools/memory.d.ts +92 -0
  59. package/dist/tools/memory.d.ts.map +1 -0
  60. package/dist/tools/memory.js +55 -0
  61. package/dist/tools/memory.js.map +1 -0
  62. package/dist/tools/textEditor.cjs +79 -0
  63. package/dist/tools/textEditor.cjs.map +1 -0
  64. package/dist/tools/textEditor.d.cts +114 -0
  65. package/dist/tools/textEditor.d.cts.map +1 -0
  66. package/dist/tools/textEditor.d.ts +114 -0
  67. package/dist/tools/textEditor.d.ts.map +1 -0
  68. package/dist/tools/textEditor.js +78 -0
  69. package/dist/tools/textEditor.js.map +1 -0
  70. package/dist/tools/toolSearch.cjs +110 -0
  71. package/dist/tools/toolSearch.cjs.map +1 -0
  72. package/dist/tools/toolSearch.d.cts +108 -0
  73. package/dist/tools/toolSearch.d.cts.map +1 -0
  74. package/dist/tools/toolSearch.d.ts +108 -0
  75. package/dist/tools/toolSearch.d.ts.map +1 -0
  76. package/dist/tools/toolSearch.js +108 -0
  77. package/dist/tools/toolSearch.js.map +1 -0
  78. package/dist/tools/types.cjs +204 -0
  79. package/dist/tools/types.cjs.map +1 -0
  80. package/dist/tools/types.d.cts +366 -0
  81. package/dist/tools/types.d.cts.map +1 -0
  82. package/dist/tools/types.d.ts +366 -0
  83. package/dist/tools/types.d.ts.map +1 -0
  84. package/dist/tools/types.js +199 -0
  85. package/dist/tools/types.js.map +1 -0
  86. package/dist/tools/webFetch.cjs +70 -0
  87. package/dist/tools/webFetch.cjs.map +1 -0
  88. package/dist/tools/webFetch.d.cts +96 -0
  89. package/dist/tools/webFetch.d.cts.map +1 -0
  90. package/dist/tools/webFetch.d.ts +96 -0
  91. package/dist/tools/webFetch.d.ts.map +1 -0
  92. package/dist/tools/webFetch.js +69 -0
  93. package/dist/tools/webFetch.js.map +1 -0
  94. package/dist/tools/webSearch.cjs +57 -0
  95. package/dist/tools/webSearch.cjs.map +1 -0
  96. package/dist/tools/webSearch.d.cts +84 -0
  97. package/dist/tools/webSearch.d.cts.map +1 -0
  98. package/dist/tools/webSearch.d.ts +84 -0
  99. package/dist/tools/webSearch.d.ts.map +1 -0
  100. package/dist/tools/webSearch.js +56 -0
  101. package/dist/tools/webSearch.js.map +1 -0
  102. package/dist/types.d.cts +2 -3
  103. package/dist/types.d.cts.map +1 -0
  104. package/dist/types.d.ts +2 -3
  105. package/dist/types.d.ts.map +1 -0
  106. package/dist/utils/prompts.d.cts.map +1 -0
  107. package/dist/utils/prompts.d.ts.map +1 -0
  108. package/dist/utils/tools.cjs +9 -2
  109. package/dist/utils/tools.cjs.map +1 -1
  110. package/dist/utils/tools.js +13 -6
  111. package/dist/utils/tools.js.map +1 -1
  112. package/package.json +8 -7
@@ -0,0 +1,92 @@
1
+ import { MemoryTool20250818Options } from "./types.cjs";
2
+ import * as zod0 from "zod";
3
+ import * as zod_v4_core0 from "zod/v4/core";
4
+ import { DynamicStructuredTool } from "@langchain/core/tools";
5
+
6
+ //#region src/tools/memory.d.ts
7
+
8
+ /**
9
+ * Creates an Anthropic memory tool that can be used with ChatAnthropic.
10
+ *
11
+ * The memory tool enables Claude to store and retrieve information across conversations
12
+ * through a memory file directory. Claude can create, read, update, and delete files that
13
+ * persist between sessions, allowing it to build knowledge over time without keeping
14
+ * everything in the context window.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { ChatAnthropic, memory_20250818 } from "@langchain/anthropic";
19
+ *
20
+ * const llm = new ChatAnthropic({
21
+ * model: "claude-sonnet-4-5-20250929"
22
+ * });
23
+ *
24
+ * const memory = memory_20250818({
25
+ * execute: async (args) => {
26
+ * // handle memory command execution
27
+ * // ...
28
+ * },
29
+ * });
30
+ * const llmWithMemory = llm.bindTools([memory]);
31
+ *
32
+ * const response = await llmWithMemory.invoke("Remember that I like Python");
33
+ * ```
34
+ *
35
+ * @param options - Optional configuration for the memory tool (currently unused)
36
+ * @param options.execute - Optional execute function that handles memory command execution.
37
+ * @returns The memory tool object that can be passed to `bindTools`
38
+ *
39
+ * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool
40
+ */
41
+ declare function memory_20250818(options?: MemoryTool20250818Options): DynamicStructuredTool<zod0.ZodDiscriminatedUnion<[zod0.ZodObject<{
42
+ command: zod0.ZodLiteral<"view">;
43
+ path: zod0.ZodString;
44
+ }, zod_v4_core0.$strip>, zod0.ZodObject<{
45
+ command: zod0.ZodLiteral<"create">;
46
+ path: zod0.ZodString;
47
+ file_text: zod0.ZodString;
48
+ }, zod_v4_core0.$strip>, zod0.ZodObject<{
49
+ command: zod0.ZodLiteral<"str_replace">;
50
+ path: zod0.ZodString;
51
+ old_str: zod0.ZodString;
52
+ new_str: zod0.ZodString;
53
+ }, zod_v4_core0.$strip>, zod0.ZodObject<{
54
+ command: zod0.ZodLiteral<"insert">;
55
+ path: zod0.ZodString;
56
+ insert_line: zod0.ZodNumber;
57
+ insert_text: zod0.ZodString;
58
+ }, zod_v4_core0.$strip>, zod0.ZodObject<{
59
+ command: zod0.ZodLiteral<"delete">;
60
+ path: zod0.ZodString;
61
+ }, zod_v4_core0.$strip>, zod0.ZodObject<{
62
+ command: zod0.ZodLiteral<"rename">;
63
+ old_path: zod0.ZodString;
64
+ new_path: zod0.ZodString;
65
+ }, zod_v4_core0.$strip>], "command">, {
66
+ command: "view";
67
+ path: string;
68
+ } | {
69
+ command: "create";
70
+ path: string;
71
+ file_text: string;
72
+ } | {
73
+ command: "str_replace";
74
+ path: string;
75
+ old_str: string;
76
+ new_str: string;
77
+ } | {
78
+ command: "insert";
79
+ path: string;
80
+ insert_line: number;
81
+ insert_text: string;
82
+ } | {
83
+ command: "delete";
84
+ path: string;
85
+ } | {
86
+ command: "rename";
87
+ old_path: string;
88
+ new_path: string;
89
+ }, unknown, string | Promise<string>>;
90
+ //#endregion
91
+ export { memory_20250818 };
92
+ //# sourceMappingURL=memory.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.cts","names":["zod_v4_core0","DynamicStructuredTool","MemoryTool20250818Options","memory_20250818","zod0","ZodLiteral","ZodString","$strip","ZodObject","ZodNumber","ZodDiscriminatedUnion","Promise"],"sources":["../../src/tools/memory.d.ts"],"sourcesContent":["import type { DynamicStructuredTool } from \"@langchain/core/tools\";\nimport { type MemoryTool20250818Options } from \"./types.js\";\n/**\n * Creates an Anthropic memory tool that can be used with ChatAnthropic.\n *\n * The memory tool enables Claude to store and retrieve information across conversations\n * through a memory file directory. Claude can create, read, update, and delete files that\n * persist between sessions, allowing it to build knowledge over time without keeping\n * everything in the context window.\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, memory_20250818 } from \"@langchain/anthropic\";\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\"\n * });\n *\n * const memory = memory_20250818({\n * execute: async (args) => {\n * // handle memory command execution\n * // ...\n * },\n * });\n * const llmWithMemory = llm.bindTools([memory]);\n *\n * const response = await llmWithMemory.invoke(\"Remember that I like Python\");\n * ```\n *\n * @param options - Optional configuration for the memory tool (currently unused)\n * @param options.execute - Optional execute function that handles memory command execution.\n * @returns The memory tool object that can be passed to `bindTools`\n *\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool\n */\nexport declare function memory_20250818(options?: MemoryTool20250818Options): DynamicStructuredTool<import(\"zod\").ZodDiscriminatedUnion<[import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"view\">;\n path: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"create\">;\n path: import(\"zod\").ZodString;\n file_text: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"str_replace\">;\n path: import(\"zod\").ZodString;\n old_str: import(\"zod\").ZodString;\n new_str: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"insert\">;\n path: import(\"zod\").ZodString;\n insert_line: import(\"zod\").ZodNumber;\n insert_text: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"delete\">;\n path: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"rename\">;\n old_path: import(\"zod\").ZodString;\n new_path: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>], \"command\">, {\n command: \"view\";\n path: string;\n} | {\n command: \"create\";\n path: string;\n file_text: string;\n} | {\n command: \"str_replace\";\n path: string;\n old_str: string;\n new_str: string;\n} | {\n command: \"insert\";\n path: string;\n insert_line: number;\n insert_text: string;\n} | {\n command: \"delete\";\n path: string;\n} | {\n command: \"rename\";\n old_path: string;\n new_path: string;\n}, unknown, string | Promise<string>>;\n//# sourceMappingURL=memory.d.ts.map"],"mappings":";;;;;;;;;;;AAmCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuB4BM,iBAvBJH,eAAAA,CAuBIG,OAAAA,CAAAA,EAvBsBJ,yBAuBtBI,CAAAA,EAvBkDL,qBAuBlDK,CAH6BF,IAAAA,CApByDM,qBAuBtFJ,CAAAA,CApBGF,IAAAA,CAHwHI,SAuB3HF,CAAAA;EAASN,OAAAA,EAvBsCI,IAAAA,CAChDC,UAuBFE,CAAAA,MAAAA,CAAAA;EAAMH,IAJiBI,EAnBXJ,IAAAA,CACbE,SAkBwBE;CAASJ,EAlBxBJ,YAAAA,CACRO,MAAAA,CAHyFG,EAOnFN,IAAAA,CAJiBI,SAHkEE,CAAAA;EAgD7FC,OAAAA,EAhD2IP,IAAAA,CAIrIC,UA4CNM,CAAAA,QAAAA,CAAAA;EAhDyDV,IAAAA,EAIzCG,IAAAA,CACbE,SALsDL;EAAqB,SAAA,EAKlEG,IAAAA,CACJE,SANsE;GAM7DN,YAAAA,CACbO,MAAAA,GAKMH,IAAAA,CALiBI;WAJSJ,IAAAA,CAK9BC;QAAUD,IAAAA,CACbE;WAASF,IAAAA,CACNE;WAASF,IAAAA,CACTE;GAASN,YAAAA,CACXO,MAAAA,GAKMH,IAAAA,CALiBI;WALSJ,IAAAA,CAM9BC;QAAUD,IAAAA,CACbE;eAASF,IAAAA,CACFK;eAASL,IAAAA,CACTE;GAASN,YAAAA,CACfO,MAAAA,GAGMH,IAAAA,CAHiBI;WALSJ,IAAAA,CAM9BC;QAAUD,IAAAA,CACbE;GAASN,YAAAA,CACRO,MAAAA,GAIMH,IAAAA,CAJiBI;WAHSJ,IAAAA,CAI9BC;YAAUD,IAAAA,CACTE;YAASF,IAAAA,CACTE;GAASN,YAAAA,CACZO,MAAAA;;;;;;;;;;;;;;;;;;;;;;;;qBAwBJI"}
@@ -0,0 +1,92 @@
1
+ import { MemoryTool20250818Options } from "./types.js";
2
+ import { DynamicStructuredTool } from "@langchain/core/tools";
3
+ import * as zod0 from "zod";
4
+ import * as zod_v4_core0 from "zod/v4/core";
5
+
6
+ //#region src/tools/memory.d.ts
7
+
8
+ /**
9
+ * Creates an Anthropic memory tool that can be used with ChatAnthropic.
10
+ *
11
+ * The memory tool enables Claude to store and retrieve information across conversations
12
+ * through a memory file directory. Claude can create, read, update, and delete files that
13
+ * persist between sessions, allowing it to build knowledge over time without keeping
14
+ * everything in the context window.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { ChatAnthropic, memory_20250818 } from "@langchain/anthropic";
19
+ *
20
+ * const llm = new ChatAnthropic({
21
+ * model: "claude-sonnet-4-5-20250929"
22
+ * });
23
+ *
24
+ * const memory = memory_20250818({
25
+ * execute: async (args) => {
26
+ * // handle memory command execution
27
+ * // ...
28
+ * },
29
+ * });
30
+ * const llmWithMemory = llm.bindTools([memory]);
31
+ *
32
+ * const response = await llmWithMemory.invoke("Remember that I like Python");
33
+ * ```
34
+ *
35
+ * @param options - Optional configuration for the memory tool (currently unused)
36
+ * @param options.execute - Optional execute function that handles memory command execution.
37
+ * @returns The memory tool object that can be passed to `bindTools`
38
+ *
39
+ * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool
40
+ */
41
+ declare function memory_20250818(options?: MemoryTool20250818Options): DynamicStructuredTool<zod0.ZodDiscriminatedUnion<[zod0.ZodObject<{
42
+ command: zod0.ZodLiteral<"view">;
43
+ path: zod0.ZodString;
44
+ }, zod_v4_core0.$strip>, zod0.ZodObject<{
45
+ command: zod0.ZodLiteral<"create">;
46
+ path: zod0.ZodString;
47
+ file_text: zod0.ZodString;
48
+ }, zod_v4_core0.$strip>, zod0.ZodObject<{
49
+ command: zod0.ZodLiteral<"str_replace">;
50
+ path: zod0.ZodString;
51
+ old_str: zod0.ZodString;
52
+ new_str: zod0.ZodString;
53
+ }, zod_v4_core0.$strip>, zod0.ZodObject<{
54
+ command: zod0.ZodLiteral<"insert">;
55
+ path: zod0.ZodString;
56
+ insert_line: zod0.ZodNumber;
57
+ insert_text: zod0.ZodString;
58
+ }, zod_v4_core0.$strip>, zod0.ZodObject<{
59
+ command: zod0.ZodLiteral<"delete">;
60
+ path: zod0.ZodString;
61
+ }, zod_v4_core0.$strip>, zod0.ZodObject<{
62
+ command: zod0.ZodLiteral<"rename">;
63
+ old_path: zod0.ZodString;
64
+ new_path: zod0.ZodString;
65
+ }, zod_v4_core0.$strip>], "command">, {
66
+ command: "view";
67
+ path: string;
68
+ } | {
69
+ command: "create";
70
+ path: string;
71
+ file_text: string;
72
+ } | {
73
+ command: "str_replace";
74
+ path: string;
75
+ old_str: string;
76
+ new_str: string;
77
+ } | {
78
+ command: "insert";
79
+ path: string;
80
+ insert_line: number;
81
+ insert_text: string;
82
+ } | {
83
+ command: "delete";
84
+ path: string;
85
+ } | {
86
+ command: "rename";
87
+ old_path: string;
88
+ new_path: string;
89
+ }, unknown, string | Promise<string>>;
90
+ //#endregion
91
+ export { memory_20250818 };
92
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","names":["zod_v4_core0","DynamicStructuredTool","MemoryTool20250818Options","memory_20250818","zod0","ZodLiteral","ZodString","$strip","ZodObject","ZodNumber","ZodDiscriminatedUnion","Promise"],"sources":["../../src/tools/memory.d.ts"],"sourcesContent":["import type { DynamicStructuredTool } from \"@langchain/core/tools\";\nimport { type MemoryTool20250818Options } from \"./types.js\";\n/**\n * Creates an Anthropic memory tool that can be used with ChatAnthropic.\n *\n * The memory tool enables Claude to store and retrieve information across conversations\n * through a memory file directory. Claude can create, read, update, and delete files that\n * persist between sessions, allowing it to build knowledge over time without keeping\n * everything in the context window.\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, memory_20250818 } from \"@langchain/anthropic\";\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\"\n * });\n *\n * const memory = memory_20250818({\n * execute: async (args) => {\n * // handle memory command execution\n * // ...\n * },\n * });\n * const llmWithMemory = llm.bindTools([memory]);\n *\n * const response = await llmWithMemory.invoke(\"Remember that I like Python\");\n * ```\n *\n * @param options - Optional configuration for the memory tool (currently unused)\n * @param options.execute - Optional execute function that handles memory command execution.\n * @returns The memory tool object that can be passed to `bindTools`\n *\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool\n */\nexport declare function memory_20250818(options?: MemoryTool20250818Options): DynamicStructuredTool<import(\"zod\").ZodDiscriminatedUnion<[import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"view\">;\n path: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"create\">;\n path: import(\"zod\").ZodString;\n file_text: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"str_replace\">;\n path: import(\"zod\").ZodString;\n old_str: import(\"zod\").ZodString;\n new_str: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"insert\">;\n path: import(\"zod\").ZodString;\n insert_line: import(\"zod\").ZodNumber;\n insert_text: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"delete\">;\n path: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"rename\">;\n old_path: import(\"zod\").ZodString;\n new_path: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>], \"command\">, {\n command: \"view\";\n path: string;\n} | {\n command: \"create\";\n path: string;\n file_text: string;\n} | {\n command: \"str_replace\";\n path: string;\n old_str: string;\n new_str: string;\n} | {\n command: \"insert\";\n path: string;\n insert_line: number;\n insert_text: string;\n} | {\n command: \"delete\";\n path: string;\n} | {\n command: \"rename\";\n old_path: string;\n new_path: string;\n}, unknown, string | Promise<string>>;\n//# sourceMappingURL=memory.d.ts.map"],"mappings":";;;;;;;;;;;AAmCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuB4BM,iBAvBJH,eAAAA,CAuBIG,OAAAA,CAAAA,EAvBsBJ,yBAuBtBI,CAAAA,EAvBkDL,qBAuBlDK,CAH6BF,IAAAA,CApByDM,qBAuBtFJ,CAAAA,CApBGF,IAAAA,CAHwHI,SAuB3HF,CAAAA;EAASN,OAAAA,EAvBsCI,IAAAA,CAChDC,UAuBFE,CAAAA,MAAAA,CAAAA;EAAMH,IAJiBI,EAnBXJ,IAAAA,CACbE,SAkBwBE;CAASJ,EAlBxBJ,YAAAA,CACRO,MAAAA,CAHyFG,EAOnFN,IAAAA,CAJiBI,SAHkEE,CAAAA;EAgD7FC,OAAAA,EAhD2IP,IAAAA,CAIrIC,UA4CNM,CAAAA,QAAAA,CAAAA;EAhDyDV,IAAAA,EAIzCG,IAAAA,CACbE,SALsDL;EAAqB,SAAA,EAKlEG,IAAAA,CACJE,SANsE;GAM7DN,YAAAA,CACbO,MAAAA,GAKMH,IAAAA,CALiBI;WAJSJ,IAAAA,CAK9BC;QAAUD,IAAAA,CACbE;WAASF,IAAAA,CACNE;WAASF,IAAAA,CACTE;GAASN,YAAAA,CACXO,MAAAA,GAKMH,IAAAA,CALiBI;WALSJ,IAAAA,CAM9BC;QAAUD,IAAAA,CACbE;eAASF,IAAAA,CACFK;eAASL,IAAAA,CACTE;GAASN,YAAAA,CACfO,MAAAA,GAGMH,IAAAA,CAHiBI;WALSJ,IAAAA,CAM9BC;QAAUD,IAAAA,CACbE;GAASN,YAAAA,CACRO,MAAAA,GAIMH,IAAAA,CAJiBI;WAHSJ,IAAAA,CAI9BC;YAAUD,IAAAA,CACTE;YAASF,IAAAA,CACTE;GAASN,YAAAA,CACZO,MAAAA;;;;;;;;;;;;;;;;;;;;;;;;qBAwBJI"}
@@ -0,0 +1,55 @@
1
+ import { Memory20250818CommandSchema } from "./types.js";
2
+ import { tool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/memory.ts
5
+ /**
6
+ * Creates an Anthropic memory tool that can be used with ChatAnthropic.
7
+ *
8
+ * The memory tool enables Claude to store and retrieve information across conversations
9
+ * through a memory file directory. Claude can create, read, update, and delete files that
10
+ * persist between sessions, allowing it to build knowledge over time without keeping
11
+ * everything in the context window.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { ChatAnthropic, memory_20250818 } from "@langchain/anthropic";
16
+ *
17
+ * const llm = new ChatAnthropic({
18
+ * model: "claude-sonnet-4-5-20250929"
19
+ * });
20
+ *
21
+ * const memory = memory_20250818({
22
+ * execute: async (args) => {
23
+ * // handle memory command execution
24
+ * // ...
25
+ * },
26
+ * });
27
+ * const llmWithMemory = llm.bindTools([memory]);
28
+ *
29
+ * const response = await llmWithMemory.invoke("Remember that I like Python");
30
+ * ```
31
+ *
32
+ * @param options - Optional configuration for the memory tool (currently unused)
33
+ * @param options.execute - Optional execute function that handles memory command execution.
34
+ * @returns The memory tool object that can be passed to `bindTools`
35
+ *
36
+ * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool
37
+ */
38
+ function memory_20250818(options) {
39
+ const memoryTool = tool(options?.execute, {
40
+ name: "memory",
41
+ schema: Memory20250818CommandSchema
42
+ });
43
+ memoryTool.extras = {
44
+ ...memoryTool.extras ?? {},
45
+ providerToolDefinition: {
46
+ type: "memory_20250818",
47
+ name: "memory"
48
+ }
49
+ };
50
+ return memoryTool;
51
+ }
52
+
53
+ //#endregion
54
+ export { memory_20250818 };
55
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","names":["options?: MemoryTool20250818Options"],"sources":["../../src/tools/memory.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { tool } from \"@langchain/core/tools\";\nimport type { DynamicStructuredTool, ToolRuntime } from \"@langchain/core/tools\";\n\nimport {\n Memory20250818CommandSchema,\n type MemoryTool20250818Options,\n type Memory20250818Command,\n} from \"./types.js\";\n\n/**\n * Creates an Anthropic memory tool that can be used with ChatAnthropic.\n *\n * The memory tool enables Claude to store and retrieve information across conversations\n * through a memory file directory. Claude can create, read, update, and delete files that\n * persist between sessions, allowing it to build knowledge over time without keeping\n * everything in the context window.\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, memory_20250818 } from \"@langchain/anthropic\";\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\"\n * });\n *\n * const memory = memory_20250818({\n * execute: async (args) => {\n * // handle memory command execution\n * // ...\n * },\n * });\n * const llmWithMemory = llm.bindTools([memory]);\n *\n * const response = await llmWithMemory.invoke(\"Remember that I like Python\");\n * ```\n *\n * @param options - Optional configuration for the memory tool (currently unused)\n * @param options.execute - Optional execute function that handles memory command execution.\n * @returns The memory tool object that can be passed to `bindTools`\n *\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool\n */\nexport function memory_20250818(options?: MemoryTool20250818Options) {\n const memoryTool = tool(\n options?.execute as (\n input: unknown,\n runtime: ToolRuntime<unknown, unknown>\n ) => string | Promise<string>,\n {\n name: \"memory\",\n schema: Memory20250818CommandSchema,\n }\n );\n\n memoryTool.extras = {\n ...(memoryTool.extras ?? {}),\n providerToolDefinition: {\n type: \"memory_20250818\",\n name: \"memory\",\n } satisfies Anthropic.Beta.BetaMemoryTool20250818,\n };\n\n return memoryTool as DynamicStructuredTool<\n typeof Memory20250818CommandSchema,\n Memory20250818Command,\n unknown,\n string | Promise<string>\n >;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,gBAAgBA,SAAqC;CACnE,MAAM,aAAa,KACjB,SAAS,SAIT;EACE,MAAM;EACN,QAAQ;CACT,EACF;CAED,WAAW,SAAS;EAClB,GAAI,WAAW,UAAU,CAAE;EAC3B,wBAAwB;GACtB,MAAM;GACN,MAAM;EACP;CACF;AAED,QAAO;AAMR"}
@@ -0,0 +1,79 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_types = require('./types.cjs');
3
+ const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langchain/core/tools"));
4
+
5
+ //#region src/tools/textEditor.ts
6
+ /**
7
+ * Creates an Anthropic text editor tool for Claude 4.x models that can view and modify text files.
8
+ *
9
+ * The text editor tool enables Claude to view and modify text files, helping debug, fix,
10
+ * and improve code or other text documents. Claude can directly interact with files,
11
+ * providing hands-on assistance rather than just suggesting changes.
12
+ *
13
+ * Available commands:
14
+ * - `view`: Examine file contents or list directory contents
15
+ * - `str_replace`: Replace specific text in a file
16
+ * - `create`: Create a new file with specified content
17
+ * - `insert`: Insert text at a specific line number
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
22
+ * import * as fs from "fs";
23
+ *
24
+ * const llm = new ChatAnthropic({
25
+ * model: "claude-sonnet-4-5-20250929",
26
+ * });
27
+ *
28
+ * const textEditor = tools.textEditor_20250728({
29
+ * execute: async (args) => {
30
+ * if (args.command === "view") {
31
+ * const content = fs.readFileSync(args.path, "utf-8");
32
+ * return content.split("\n").map((line, i) => `${i + 1}: ${line}`).join("\n");
33
+ * }
34
+ * if (args.command === "str_replace") {
35
+ * let content = fs.readFileSync(args.path, "utf-8");
36
+ * content = content.replace(args.old_str!, args.new_str!);
37
+ * fs.writeFileSync(args.path, content);
38
+ * return "Successfully replaced text.";
39
+ * }
40
+ * // Handle other commands...
41
+ * return "Command executed";
42
+ * },
43
+ * maxCharacters: 10000,
44
+ * });
45
+ *
46
+ * const llmWithEditor = llm.bindTools([textEditor]);
47
+ * const response = await llmWithEditor.invoke(
48
+ * "There's a syntax error in my primes.py file. Can you help me fix it?"
49
+ * );
50
+ * ```
51
+ *
52
+ * @param options - Configuration options for the text editor tool
53
+ * @param options.execute - Function that handles text editor command execution
54
+ * @param options.maxCharacters - Maximum characters to return when viewing files
55
+ * @returns The text editor tool object that can be passed to `bindTools`
56
+ *
57
+ * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool
58
+ */
59
+ function textEditor_20250728(options) {
60
+ const name = "str_replace_based_edit_tool";
61
+ const textEditorTool = (0, __langchain_core_tools.tool)(options?.execute, {
62
+ name,
63
+ description: "A tool for editing text files",
64
+ schema: require_types.TextEditor20250728CommandSchema
65
+ });
66
+ textEditorTool.extras = {
67
+ ...textEditorTool.extras ?? {},
68
+ providerToolDefinition: {
69
+ type: "text_editor_20250728",
70
+ name,
71
+ ...options?.maxCharacters !== void 0 && { max_characters: options.maxCharacters }
72
+ }
73
+ };
74
+ return textEditorTool;
75
+ }
76
+
77
+ //#endregion
78
+ exports.textEditor_20250728 = textEditor_20250728;
79
+ //# sourceMappingURL=textEditor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textEditor.cjs","names":["options?: TextEditor20250728Options","TextEditor20250728CommandSchema"],"sources":["../../src/tools/textEditor.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { tool } from \"@langchain/core/tools\";\nimport type { DynamicStructuredTool, ToolRuntime } from \"@langchain/core/tools\";\n\nimport {\n TextEditor20250728CommandSchema,\n type TextEditor20250728Command,\n} from \"./types.js\";\n\n/**\n * Options for the text editor tool (Claude 4.x version).\n */\nexport interface TextEditor20250728Options {\n /**\n * Optional execute function that handles text editor command execution.\n * This function receives the command input and should return the result.\n */\n execute?: (args: TextEditor20250728Command) => string | Promise<string>;\n /**\n * Optional maximum characters to return when viewing files.\n * If the file content exceeds this limit, it will be truncated.\n */\n maxCharacters?: number;\n}\n\n/**\n * Creates an Anthropic text editor tool for Claude 4.x models that can view and modify text files.\n *\n * The text editor tool enables Claude to view and modify text files, helping debug, fix,\n * and improve code or other text documents. Claude can directly interact with files,\n * providing hands-on assistance rather than just suggesting changes.\n *\n * Available commands:\n * - `view`: Examine file contents or list directory contents\n * - `str_replace`: Replace specific text in a file\n * - `create`: Create a new file with specified content\n * - `insert`: Insert text at a specific line number\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n * import * as fs from \"fs\";\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * const textEditor = tools.textEditor_20250728({\n * execute: async (args) => {\n * if (args.command === \"view\") {\n * const content = fs.readFileSync(args.path, \"utf-8\");\n * return content.split(\"\\n\").map((line, i) => `${i + 1}: ${line}`).join(\"\\n\");\n * }\n * if (args.command === \"str_replace\") {\n * let content = fs.readFileSync(args.path, \"utf-8\");\n * content = content.replace(args.old_str!, args.new_str!);\n * fs.writeFileSync(args.path, content);\n * return \"Successfully replaced text.\";\n * }\n * // Handle other commands...\n * return \"Command executed\";\n * },\n * maxCharacters: 10000,\n * });\n *\n * const llmWithEditor = llm.bindTools([textEditor]);\n * const response = await llmWithEditor.invoke(\n * \"There's a syntax error in my primes.py file. Can you help me fix it?\"\n * );\n * ```\n *\n * @param options - Configuration options for the text editor tool\n * @param options.execute - Function that handles text editor command execution\n * @param options.maxCharacters - Maximum characters to return when viewing files\n * @returns The text editor tool object that can be passed to `bindTools`\n *\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool\n */\nexport function textEditor_20250728(options?: TextEditor20250728Options) {\n const name = \"str_replace_based_edit_tool\";\n const textEditorTool = tool(\n options?.execute as (\n input: unknown,\n runtime: ToolRuntime<unknown, unknown>\n ) => string | Promise<string>,\n {\n name,\n description: \"A tool for editing text files\",\n schema: TextEditor20250728CommandSchema,\n }\n );\n\n textEditorTool.extras = {\n ...(textEditorTool.extras ?? {}),\n providerToolDefinition: {\n type: \"text_editor_20250728\",\n name,\n ...(options?.maxCharacters !== undefined && {\n max_characters: options.maxCharacters,\n }),\n } satisfies Anthropic.Beta.Messages.BetaToolTextEditor20250728,\n };\n\n return textEditorTool as DynamicStructuredTool<\n typeof TextEditor20250728CommandSchema,\n TextEditor20250728Command,\n unknown,\n string | Promise<string>\n >;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,SAAgB,oBAAoBA,SAAqC;CACvE,MAAM,OAAO;CACb,MAAM,kDACJ,SAAS,SAIT;EACE;EACA,aAAa;EACb,QAAQC;CACT,EACF;CAED,eAAe,SAAS;EACtB,GAAI,eAAe,UAAU,CAAE;EAC/B,wBAAwB;GACtB,MAAM;GACN;GACA,GAAI,SAAS,kBAAkB,UAAa,EAC1C,gBAAgB,QAAQ,cACzB;EACF;CACF;AAED,QAAO;AAMR"}
@@ -0,0 +1,114 @@
1
+ import { TextEditor20250728Command } from "./types.cjs";
2
+ import * as zod24 from "zod";
3
+ import * as zod_v4_core5 from "zod/v4/core";
4
+ import { DynamicStructuredTool } from "@langchain/core/tools";
5
+
6
+ //#region src/tools/textEditor.d.ts
7
+ /**
8
+ * Options for the text editor tool (Claude 4.x version).
9
+ */
10
+ interface TextEditor20250728Options {
11
+ /**
12
+ * Optional execute function that handles text editor command execution.
13
+ * This function receives the command input and should return the result.
14
+ */
15
+ execute?: (args: TextEditor20250728Command) => string | Promise<string>;
16
+ /**
17
+ * Optional maximum characters to return when viewing files.
18
+ * If the file content exceeds this limit, it will be truncated.
19
+ */
20
+ maxCharacters?: number;
21
+ }
22
+ /**
23
+ * Creates an Anthropic text editor tool for Claude 4.x models that can view and modify text files.
24
+ *
25
+ * The text editor tool enables Claude to view and modify text files, helping debug, fix,
26
+ * and improve code or other text documents. Claude can directly interact with files,
27
+ * providing hands-on assistance rather than just suggesting changes.
28
+ *
29
+ * Available commands:
30
+ * - `view`: Examine file contents or list directory contents
31
+ * - `str_replace`: Replace specific text in a file
32
+ * - `create`: Create a new file with specified content
33
+ * - `insert`: Insert text at a specific line number
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
38
+ * import * as fs from "fs";
39
+ *
40
+ * const llm = new ChatAnthropic({
41
+ * model: "claude-sonnet-4-5-20250929",
42
+ * });
43
+ *
44
+ * const textEditor = tools.textEditor_20250728({
45
+ * execute: async (args) => {
46
+ * if (args.command === "view") {
47
+ * const content = fs.readFileSync(args.path, "utf-8");
48
+ * return content.split("\n").map((line, i) => `${i + 1}: ${line}`).join("\n");
49
+ * }
50
+ * if (args.command === "str_replace") {
51
+ * let content = fs.readFileSync(args.path, "utf-8");
52
+ * content = content.replace(args.old_str!, args.new_str!);
53
+ * fs.writeFileSync(args.path, content);
54
+ * return "Successfully replaced text.";
55
+ * }
56
+ * // Handle other commands...
57
+ * return "Command executed";
58
+ * },
59
+ * maxCharacters: 10000,
60
+ * });
61
+ *
62
+ * const llmWithEditor = llm.bindTools([textEditor]);
63
+ * const response = await llmWithEditor.invoke(
64
+ * "There's a syntax error in my primes.py file. Can you help me fix it?"
65
+ * );
66
+ * ```
67
+ *
68
+ * @param options - Configuration options for the text editor tool
69
+ * @param options.execute - Function that handles text editor command execution
70
+ * @param options.maxCharacters - Maximum characters to return when viewing files
71
+ * @returns The text editor tool object that can be passed to `bindTools`
72
+ *
73
+ * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool
74
+ */
75
+ declare function textEditor_20250728(options?: TextEditor20250728Options): DynamicStructuredTool<zod24.ZodDiscriminatedUnion<[zod24.ZodObject<{
76
+ command: zod24.ZodLiteral<"view">;
77
+ path: zod24.ZodString;
78
+ view_range: zod24.ZodOptional<zod24.ZodTuple<[zod24.ZodNumber, zod24.ZodNumber], null>>;
79
+ }, zod_v4_core5.$strip>, zod24.ZodObject<{
80
+ command: zod24.ZodLiteral<"str_replace">;
81
+ path: zod24.ZodString;
82
+ old_str: zod24.ZodString;
83
+ new_str: zod24.ZodString;
84
+ }, zod_v4_core5.$strip>, zod24.ZodObject<{
85
+ command: zod24.ZodLiteral<"create">;
86
+ path: zod24.ZodString;
87
+ file_text: zod24.ZodString;
88
+ }, zod_v4_core5.$strip>, zod24.ZodObject<{
89
+ command: zod24.ZodLiteral<"insert">;
90
+ path: zod24.ZodString;
91
+ insert_line: zod24.ZodNumber;
92
+ new_str: zod24.ZodString;
93
+ }, zod_v4_core5.$strip>], "command">, {
94
+ command: "view";
95
+ path: string;
96
+ view_range?: [number, number] | undefined;
97
+ } | {
98
+ command: "str_replace";
99
+ path: string;
100
+ old_str: string;
101
+ new_str: string;
102
+ } | {
103
+ command: "create";
104
+ path: string;
105
+ file_text: string;
106
+ } | {
107
+ command: "insert";
108
+ path: string;
109
+ insert_line: number;
110
+ new_str: string;
111
+ }, unknown, string | Promise<string>>;
112
+ //#endregion
113
+ export { TextEditor20250728Options, textEditor_20250728 };
114
+ //# sourceMappingURL=textEditor.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textEditor.d.cts","names":["zod_v4_core5","DynamicStructuredTool","TextEditor20250728Command","TextEditor20250728Options","Promise","textEditor_20250728","zod24","ZodLiteral","ZodString","ZodNumber","ZodTuple","ZodOptional","$strip","ZodObject","ZodDiscriminatedUnion"],"sources":["../../src/tools/textEditor.d.ts"],"sourcesContent":["import type { DynamicStructuredTool } from \"@langchain/core/tools\";\nimport { type TextEditor20250728Command } from \"./types.js\";\n/**\n * Options for the text editor tool (Claude 4.x version).\n */\nexport interface TextEditor20250728Options {\n /**\n * Optional execute function that handles text editor command execution.\n * This function receives the command input and should return the result.\n */\n execute?: (args: TextEditor20250728Command) => string | Promise<string>;\n /**\n * Optional maximum characters to return when viewing files.\n * If the file content exceeds this limit, it will be truncated.\n */\n maxCharacters?: number;\n}\n/**\n * Creates an Anthropic text editor tool for Claude 4.x models that can view and modify text files.\n *\n * The text editor tool enables Claude to view and modify text files, helping debug, fix,\n * and improve code or other text documents. Claude can directly interact with files,\n * providing hands-on assistance rather than just suggesting changes.\n *\n * Available commands:\n * - `view`: Examine file contents or list directory contents\n * - `str_replace`: Replace specific text in a file\n * - `create`: Create a new file with specified content\n * - `insert`: Insert text at a specific line number\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n * import * as fs from \"fs\";\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * const textEditor = tools.textEditor_20250728({\n * execute: async (args) => {\n * if (args.command === \"view\") {\n * const content = fs.readFileSync(args.path, \"utf-8\");\n * return content.split(\"\\n\").map((line, i) => `${i + 1}: ${line}`).join(\"\\n\");\n * }\n * if (args.command === \"str_replace\") {\n * let content = fs.readFileSync(args.path, \"utf-8\");\n * content = content.replace(args.old_str!, args.new_str!);\n * fs.writeFileSync(args.path, content);\n * return \"Successfully replaced text.\";\n * }\n * // Handle other commands...\n * return \"Command executed\";\n * },\n * maxCharacters: 10000,\n * });\n *\n * const llmWithEditor = llm.bindTools([textEditor]);\n * const response = await llmWithEditor.invoke(\n * \"There's a syntax error in my primes.py file. Can you help me fix it?\"\n * );\n * ```\n *\n * @param options - Configuration options for the text editor tool\n * @param options.execute - Function that handles text editor command execution\n * @param options.maxCharacters - Maximum characters to return when viewing files\n * @returns The text editor tool object that can be passed to `bindTools`\n *\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool\n */\nexport declare function textEditor_20250728(options?: TextEditor20250728Options): DynamicStructuredTool<import(\"zod\").ZodDiscriminatedUnion<[import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"view\">;\n path: import(\"zod\").ZodString;\n view_range: import(\"zod\").ZodOptional<import(\"zod\").ZodTuple<[import(\"zod\").ZodNumber, import(\"zod\").ZodNumber], null>>;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"str_replace\">;\n path: import(\"zod\").ZodString;\n old_str: import(\"zod\").ZodString;\n new_str: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"create\">;\n path: import(\"zod\").ZodString;\n file_text: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"insert\">;\n path: import(\"zod\").ZodString;\n insert_line: import(\"zod\").ZodNumber;\n new_str: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>], \"command\">, {\n command: \"view\";\n path: string;\n view_range?: [number, number] | undefined;\n} | {\n command: \"str_replace\";\n path: string;\n old_str: string;\n new_str: string;\n} | {\n command: \"create\";\n path: string;\n file_text: string;\n} | {\n command: \"insert\";\n path: string;\n insert_line: number;\n new_str: string;\n}, unknown, string | Promise<string>>;\n//# sourceMappingURL=textEditor.d.ts.map"],"mappings":";;;;;;;;;UAKiBG,yBAAAA;EAAAA;AAiEjB;;;EACqCG,OACbE,CAAAA,EAAAA,CAAAA,IAAAA,EA9DHN,yBA8DGM,EAAAA,GAAAA,MAAAA,GA9DoCJ,OA8DpCI,CAAAA,MAAAA,CAAAA;EAASF;;;;EACQN,aAChBY,CAAAA,EAAAA,MAAAA;;;;;;;;;;;;;;;;;;;;;;AAJ8E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAA/EP,mBAAAA,WAA8BF,4BAA4BF,sBAazBK,KAAAA,CAb6DQ,uBAIvFR,KAAAA,CAJ4HO;WAA5EP,KAAAA,CACpDC;QAAUD,KAAAA,CACbE;cACwCF,KAAAA,CAAlCK,YAAoFL,KAAAA,CAA1DI,UADvBJ,KAAAA,CAC+CG,SAAAA,EAASH,KAAAA,CAAgBG,SAAAA;GAAhET,YAAAA,CAChBY,MAAAA,GAKMN,KAAAA,CALiBO;WAJoHP,KAAAA,CAKzIC;QAAUD,KAAAA,CACbE;WAASF,KAAAA,CACNE;WAASF,KAAAA,CACTE;GAASR,YAAAA,CACXY,MAAAA,GAIMN,KAAAA,CAJiBO;WALSP,KAAAA,CAM9BC;QAAUD,KAAAA,CACbE;aAASF,KAAAA,CACJE;GAASR,YAAAA,CACbY,MAAAA,GAKMN,KAAAA,CALiBO;WAJSP,KAAAA,CAK9BC;QAAUD,KAAAA,CACbE;eAASF,KAAAA,CACFG;WAASH,KAAAA,CACbE;GAASR,YAAAA,CACXY,MAAAA;;;;;;;;;;;;;;;;;;qBAkBJR"}
@@ -0,0 +1,114 @@
1
+ import { TextEditor20250728Command } from "./types.js";
2
+ import { DynamicStructuredTool } from "@langchain/core/tools";
3
+ import * as zod24 from "zod";
4
+ import * as zod_v4_core5 from "zod/v4/core";
5
+
6
+ //#region src/tools/textEditor.d.ts
7
+ /**
8
+ * Options for the text editor tool (Claude 4.x version).
9
+ */
10
+ interface TextEditor20250728Options {
11
+ /**
12
+ * Optional execute function that handles text editor command execution.
13
+ * This function receives the command input and should return the result.
14
+ */
15
+ execute?: (args: TextEditor20250728Command) => string | Promise<string>;
16
+ /**
17
+ * Optional maximum characters to return when viewing files.
18
+ * If the file content exceeds this limit, it will be truncated.
19
+ */
20
+ maxCharacters?: number;
21
+ }
22
+ /**
23
+ * Creates an Anthropic text editor tool for Claude 4.x models that can view and modify text files.
24
+ *
25
+ * The text editor tool enables Claude to view and modify text files, helping debug, fix,
26
+ * and improve code or other text documents. Claude can directly interact with files,
27
+ * providing hands-on assistance rather than just suggesting changes.
28
+ *
29
+ * Available commands:
30
+ * - `view`: Examine file contents or list directory contents
31
+ * - `str_replace`: Replace specific text in a file
32
+ * - `create`: Create a new file with specified content
33
+ * - `insert`: Insert text at a specific line number
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
38
+ * import * as fs from "fs";
39
+ *
40
+ * const llm = new ChatAnthropic({
41
+ * model: "claude-sonnet-4-5-20250929",
42
+ * });
43
+ *
44
+ * const textEditor = tools.textEditor_20250728({
45
+ * execute: async (args) => {
46
+ * if (args.command === "view") {
47
+ * const content = fs.readFileSync(args.path, "utf-8");
48
+ * return content.split("\n").map((line, i) => `${i + 1}: ${line}`).join("\n");
49
+ * }
50
+ * if (args.command === "str_replace") {
51
+ * let content = fs.readFileSync(args.path, "utf-8");
52
+ * content = content.replace(args.old_str!, args.new_str!);
53
+ * fs.writeFileSync(args.path, content);
54
+ * return "Successfully replaced text.";
55
+ * }
56
+ * // Handle other commands...
57
+ * return "Command executed";
58
+ * },
59
+ * maxCharacters: 10000,
60
+ * });
61
+ *
62
+ * const llmWithEditor = llm.bindTools([textEditor]);
63
+ * const response = await llmWithEditor.invoke(
64
+ * "There's a syntax error in my primes.py file. Can you help me fix it?"
65
+ * );
66
+ * ```
67
+ *
68
+ * @param options - Configuration options for the text editor tool
69
+ * @param options.execute - Function that handles text editor command execution
70
+ * @param options.maxCharacters - Maximum characters to return when viewing files
71
+ * @returns The text editor tool object that can be passed to `bindTools`
72
+ *
73
+ * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool
74
+ */
75
+ declare function textEditor_20250728(options?: TextEditor20250728Options): DynamicStructuredTool<zod24.ZodDiscriminatedUnion<[zod24.ZodObject<{
76
+ command: zod24.ZodLiteral<"view">;
77
+ path: zod24.ZodString;
78
+ view_range: zod24.ZodOptional<zod24.ZodTuple<[zod24.ZodNumber, zod24.ZodNumber], null>>;
79
+ }, zod_v4_core5.$strip>, zod24.ZodObject<{
80
+ command: zod24.ZodLiteral<"str_replace">;
81
+ path: zod24.ZodString;
82
+ old_str: zod24.ZodString;
83
+ new_str: zod24.ZodString;
84
+ }, zod_v4_core5.$strip>, zod24.ZodObject<{
85
+ command: zod24.ZodLiteral<"create">;
86
+ path: zod24.ZodString;
87
+ file_text: zod24.ZodString;
88
+ }, zod_v4_core5.$strip>, zod24.ZodObject<{
89
+ command: zod24.ZodLiteral<"insert">;
90
+ path: zod24.ZodString;
91
+ insert_line: zod24.ZodNumber;
92
+ new_str: zod24.ZodString;
93
+ }, zod_v4_core5.$strip>], "command">, {
94
+ command: "view";
95
+ path: string;
96
+ view_range?: [number, number] | undefined;
97
+ } | {
98
+ command: "str_replace";
99
+ path: string;
100
+ old_str: string;
101
+ new_str: string;
102
+ } | {
103
+ command: "create";
104
+ path: string;
105
+ file_text: string;
106
+ } | {
107
+ command: "insert";
108
+ path: string;
109
+ insert_line: number;
110
+ new_str: string;
111
+ }, unknown, string | Promise<string>>;
112
+ //#endregion
113
+ export { TextEditor20250728Options, textEditor_20250728 };
114
+ //# sourceMappingURL=textEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textEditor.d.ts","names":["zod_v4_core5","DynamicStructuredTool","TextEditor20250728Command","TextEditor20250728Options","Promise","textEditor_20250728","zod24","ZodLiteral","ZodString","ZodNumber","ZodTuple","ZodOptional","$strip","ZodObject","ZodDiscriminatedUnion"],"sources":["../../src/tools/textEditor.d.ts"],"sourcesContent":["import type { DynamicStructuredTool } from \"@langchain/core/tools\";\nimport { type TextEditor20250728Command } from \"./types.js\";\n/**\n * Options for the text editor tool (Claude 4.x version).\n */\nexport interface TextEditor20250728Options {\n /**\n * Optional execute function that handles text editor command execution.\n * This function receives the command input and should return the result.\n */\n execute?: (args: TextEditor20250728Command) => string | Promise<string>;\n /**\n * Optional maximum characters to return when viewing files.\n * If the file content exceeds this limit, it will be truncated.\n */\n maxCharacters?: number;\n}\n/**\n * Creates an Anthropic text editor tool for Claude 4.x models that can view and modify text files.\n *\n * The text editor tool enables Claude to view and modify text files, helping debug, fix,\n * and improve code or other text documents. Claude can directly interact with files,\n * providing hands-on assistance rather than just suggesting changes.\n *\n * Available commands:\n * - `view`: Examine file contents or list directory contents\n * - `str_replace`: Replace specific text in a file\n * - `create`: Create a new file with specified content\n * - `insert`: Insert text at a specific line number\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n * import * as fs from \"fs\";\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * const textEditor = tools.textEditor_20250728({\n * execute: async (args) => {\n * if (args.command === \"view\") {\n * const content = fs.readFileSync(args.path, \"utf-8\");\n * return content.split(\"\\n\").map((line, i) => `${i + 1}: ${line}`).join(\"\\n\");\n * }\n * if (args.command === \"str_replace\") {\n * let content = fs.readFileSync(args.path, \"utf-8\");\n * content = content.replace(args.old_str!, args.new_str!);\n * fs.writeFileSync(args.path, content);\n * return \"Successfully replaced text.\";\n * }\n * // Handle other commands...\n * return \"Command executed\";\n * },\n * maxCharacters: 10000,\n * });\n *\n * const llmWithEditor = llm.bindTools([textEditor]);\n * const response = await llmWithEditor.invoke(\n * \"There's a syntax error in my primes.py file. Can you help me fix it?\"\n * );\n * ```\n *\n * @param options - Configuration options for the text editor tool\n * @param options.execute - Function that handles text editor command execution\n * @param options.maxCharacters - Maximum characters to return when viewing files\n * @returns The text editor tool object that can be passed to `bindTools`\n *\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool\n */\nexport declare function textEditor_20250728(options?: TextEditor20250728Options): DynamicStructuredTool<import(\"zod\").ZodDiscriminatedUnion<[import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"view\">;\n path: import(\"zod\").ZodString;\n view_range: import(\"zod\").ZodOptional<import(\"zod\").ZodTuple<[import(\"zod\").ZodNumber, import(\"zod\").ZodNumber], null>>;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"str_replace\">;\n path: import(\"zod\").ZodString;\n old_str: import(\"zod\").ZodString;\n new_str: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"create\">;\n path: import(\"zod\").ZodString;\n file_text: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>, import(\"zod\").ZodObject<{\n command: import(\"zod\").ZodLiteral<\"insert\">;\n path: import(\"zod\").ZodString;\n insert_line: import(\"zod\").ZodNumber;\n new_str: import(\"zod\").ZodString;\n}, import(\"zod/v4/core\").$strip>], \"command\">, {\n command: \"view\";\n path: string;\n view_range?: [number, number] | undefined;\n} | {\n command: \"str_replace\";\n path: string;\n old_str: string;\n new_str: string;\n} | {\n command: \"create\";\n path: string;\n file_text: string;\n} | {\n command: \"insert\";\n path: string;\n insert_line: number;\n new_str: string;\n}, unknown, string | Promise<string>>;\n//# sourceMappingURL=textEditor.d.ts.map"],"mappings":";;;;;;;;;UAKiBG,yBAAAA;EAAAA;AAiEjB;;;EACqCG,OACbE,CAAAA,EAAAA,CAAAA,IAAAA,EA9DHN,yBA8DGM,EAAAA,GAAAA,MAAAA,GA9DoCJ,OA8DpCI,CAAAA,MAAAA,CAAAA;EAASF;;;;EACQN,aAChBY,CAAAA,EAAAA,MAAAA;;;;;;;;;;;;;;;;;;;;;;AAJ8E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAA/EP,mBAAAA,WAA8BF,4BAA4BF,sBAazBK,KAAAA,CAb6DQ,uBAIvFR,KAAAA,CAJ4HO;WAA5EP,KAAAA,CACpDC;QAAUD,KAAAA,CACbE;cACwCF,KAAAA,CAAlCK,YAAoFL,KAAAA,CAA1DI,UADvBJ,KAAAA,CAC+CG,SAAAA,EAASH,KAAAA,CAAgBG,SAAAA;GAAhET,YAAAA,CAChBY,MAAAA,GAKMN,KAAAA,CALiBO;WAJoHP,KAAAA,CAKzIC;QAAUD,KAAAA,CACbE;WAASF,KAAAA,CACNE;WAASF,KAAAA,CACTE;GAASR,YAAAA,CACXY,MAAAA,GAIMN,KAAAA,CAJiBO;WALSP,KAAAA,CAM9BC;QAAUD,KAAAA,CACbE;aAASF,KAAAA,CACJE;GAASR,YAAAA,CACbY,MAAAA,GAKMN,KAAAA,CALiBO;WAJSP,KAAAA,CAK9BC;QAAUD,KAAAA,CACbE;eAASF,KAAAA,CACFG;WAASH,KAAAA,CACbE;GAASR,YAAAA,CACXY,MAAAA;;;;;;;;;;;;;;;;;;qBAkBJR"}