@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,199 @@
1
+ import { z } from "zod/v4";
2
+
3
+ //#region src/tools/types.ts
4
+ /**
5
+ * Memory tool command types as defined by Anthropic's memory tool API.
6
+ * @beta
7
+ * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool
8
+ */
9
+ const Memory20250818ViewCommandSchema = z.object({
10
+ command: z.literal("view"),
11
+ path: z.string()
12
+ });
13
+ const Memory20250818CreateCommandSchema = z.object({
14
+ command: z.literal("create"),
15
+ path: z.string(),
16
+ file_text: z.string()
17
+ });
18
+ const Memory20250818StrReplaceCommandSchema = z.object({
19
+ command: z.literal("str_replace"),
20
+ path: z.string(),
21
+ old_str: z.string(),
22
+ new_str: z.string()
23
+ });
24
+ const Memory20250818InsertCommandSchema = z.object({
25
+ command: z.literal("insert"),
26
+ path: z.string(),
27
+ insert_line: z.number(),
28
+ insert_text: z.string()
29
+ });
30
+ const Memory20250818DeleteCommandSchema = z.object({
31
+ command: z.literal("delete"),
32
+ path: z.string()
33
+ });
34
+ const Memory20250818RenameCommandSchema = z.object({
35
+ command: z.literal("rename"),
36
+ old_path: z.string(),
37
+ new_path: z.string()
38
+ });
39
+ const Memory20250818CommandSchema = z.discriminatedUnion("command", [
40
+ Memory20250818ViewCommandSchema,
41
+ Memory20250818CreateCommandSchema,
42
+ Memory20250818StrReplaceCommandSchema,
43
+ Memory20250818InsertCommandSchema,
44
+ Memory20250818DeleteCommandSchema,
45
+ Memory20250818RenameCommandSchema
46
+ ]);
47
+ /**
48
+ * Text editor tool command types for Claude 4.x models.
49
+ * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool
50
+ */
51
+ const TextEditor20250728ViewCommandSchema = z.object({
52
+ command: z.literal("view"),
53
+ path: z.string(),
54
+ view_range: z.tuple([z.number(), z.number()]).optional()
55
+ });
56
+ const TextEditor20250728StrReplaceCommandSchema = z.object({
57
+ command: z.literal("str_replace"),
58
+ path: z.string(),
59
+ old_str: z.string(),
60
+ new_str: z.string()
61
+ });
62
+ const TextEditor20250728CreateCommandSchema = z.object({
63
+ command: z.literal("create"),
64
+ path: z.string(),
65
+ file_text: z.string()
66
+ });
67
+ const TextEditor20250728InsertCommandSchema = z.object({
68
+ command: z.literal("insert"),
69
+ path: z.string(),
70
+ insert_line: z.number(),
71
+ new_str: z.string()
72
+ });
73
+ const TextEditor20250728CommandSchema = z.discriminatedUnion("command", [
74
+ TextEditor20250728ViewCommandSchema,
75
+ TextEditor20250728StrReplaceCommandSchema,
76
+ TextEditor20250728CreateCommandSchema,
77
+ TextEditor20250728InsertCommandSchema
78
+ ]);
79
+ const coordinateSchema = z.tuple([z.number(), z.number()]);
80
+ const ComputerScreenshotActionSchema = z.object({ action: z.literal("screenshot") });
81
+ const ComputerLeftClickActionSchema = z.object({
82
+ action: z.literal("left_click"),
83
+ coordinate: coordinateSchema
84
+ });
85
+ const ComputerRightClickActionSchema = z.object({
86
+ action: z.literal("right_click"),
87
+ coordinate: coordinateSchema
88
+ });
89
+ const ComputerMiddleClickActionSchema = z.object({
90
+ action: z.literal("middle_click"),
91
+ coordinate: coordinateSchema
92
+ });
93
+ const ComputerDoubleClickActionSchema = z.object({
94
+ action: z.literal("double_click"),
95
+ coordinate: coordinateSchema
96
+ });
97
+ const ComputerTripleClickActionSchema = z.object({
98
+ action: z.literal("triple_click"),
99
+ coordinate: coordinateSchema
100
+ });
101
+ const ComputerLeftClickDragActionSchema = z.object({
102
+ action: z.literal("left_click_drag"),
103
+ start_coordinate: coordinateSchema,
104
+ end_coordinate: coordinateSchema
105
+ });
106
+ const ComputerLeftMouseDownActionSchema = z.object({
107
+ action: z.literal("left_mouse_down"),
108
+ coordinate: coordinateSchema
109
+ });
110
+ const ComputerLeftMouseUpActionSchema = z.object({
111
+ action: z.literal("left_mouse_up"),
112
+ coordinate: coordinateSchema
113
+ });
114
+ const ComputerScrollActionSchema = z.object({
115
+ action: z.literal("scroll"),
116
+ coordinate: coordinateSchema,
117
+ scroll_direction: z.enum([
118
+ "up",
119
+ "down",
120
+ "left",
121
+ "right"
122
+ ]),
123
+ scroll_amount: z.number()
124
+ });
125
+ const ComputerTypeActionSchema = z.object({
126
+ action: z.literal("type"),
127
+ text: z.string()
128
+ });
129
+ const ComputerKeyActionSchema = z.object({
130
+ action: z.literal("key"),
131
+ key: z.string()
132
+ });
133
+ const ComputerMouseMoveActionSchema = z.object({
134
+ action: z.literal("mouse_move"),
135
+ coordinate: coordinateSchema
136
+ });
137
+ const ComputerHoldKeyActionSchema = z.object({
138
+ action: z.literal("hold_key"),
139
+ key: z.string()
140
+ });
141
+ const ComputerWaitActionSchema = z.object({
142
+ action: z.literal("wait"),
143
+ duration: z.number().optional()
144
+ });
145
+ const ComputerZoomActionSchema = z.object({
146
+ action: z.literal("zoom"),
147
+ region: z.tuple([
148
+ z.number(),
149
+ z.number(),
150
+ z.number(),
151
+ z.number()
152
+ ])
153
+ });
154
+ const Computer20250124ActionSchema = z.discriminatedUnion("action", [
155
+ ComputerScreenshotActionSchema,
156
+ ComputerLeftClickActionSchema,
157
+ ComputerRightClickActionSchema,
158
+ ComputerMiddleClickActionSchema,
159
+ ComputerDoubleClickActionSchema,
160
+ ComputerTripleClickActionSchema,
161
+ ComputerLeftClickDragActionSchema,
162
+ ComputerLeftMouseDownActionSchema,
163
+ ComputerLeftMouseUpActionSchema,
164
+ ComputerScrollActionSchema,
165
+ ComputerTypeActionSchema,
166
+ ComputerKeyActionSchema,
167
+ ComputerMouseMoveActionSchema,
168
+ ComputerHoldKeyActionSchema,
169
+ ComputerWaitActionSchema
170
+ ]);
171
+ const Computer20251124ActionSchema = z.discriminatedUnion("action", [
172
+ ComputerScreenshotActionSchema,
173
+ ComputerLeftClickActionSchema,
174
+ ComputerRightClickActionSchema,
175
+ ComputerMiddleClickActionSchema,
176
+ ComputerDoubleClickActionSchema,
177
+ ComputerTripleClickActionSchema,
178
+ ComputerLeftClickDragActionSchema,
179
+ ComputerLeftMouseDownActionSchema,
180
+ ComputerLeftMouseUpActionSchema,
181
+ ComputerScrollActionSchema,
182
+ ComputerTypeActionSchema,
183
+ ComputerKeyActionSchema,
184
+ ComputerMouseMoveActionSchema,
185
+ ComputerHoldKeyActionSchema,
186
+ ComputerWaitActionSchema,
187
+ ComputerZoomActionSchema
188
+ ]);
189
+ /**
190
+ * Bash tool command types for Claude 4 models and Claude 3.7.
191
+ * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/bash-tool
192
+ */
193
+ const Bash20250124ExecuteCommandSchema = z.object({ command: z.string().describe("The bash command to run") });
194
+ const Bash20250124RestartCommandSchema = z.object({ restart: z.literal(true).describe("Set to true to restart the bash session") });
195
+ const Bash20250124CommandSchema = z.union([Bash20250124ExecuteCommandSchema, Bash20250124RestartCommandSchema]);
196
+
197
+ //#endregion
198
+ export { Bash20250124CommandSchema, Computer20250124ActionSchema, Computer20251124ActionSchema, Memory20250818CommandSchema, TextEditor20250728CommandSchema };
199
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/tools/types.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { z } from \"zod/v4\";\n\n/**\n * Memory tool command types as defined by Anthropic's memory tool API.\n * @beta\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool\n */\n\n// Zod schemas for memory commands\nexport const Memory20250818ViewCommandSchema = z.object({\n command: z.literal(\"view\"),\n path: z.string(),\n});\n\nexport const Memory20250818CreateCommandSchema = z.object({\n command: z.literal(\"create\"),\n path: z.string(),\n file_text: z.string(),\n});\n\nexport const Memory20250818StrReplaceCommandSchema = z.object({\n command: z.literal(\"str_replace\"),\n path: z.string(),\n old_str: z.string(),\n new_str: z.string(),\n});\n\nexport const Memory20250818InsertCommandSchema = z.object({\n command: z.literal(\"insert\"),\n path: z.string(),\n insert_line: z.number(),\n insert_text: z.string(),\n});\n\nexport const Memory20250818DeleteCommandSchema = z.object({\n command: z.literal(\"delete\"),\n path: z.string(),\n});\n\nexport const Memory20250818RenameCommandSchema = z.object({\n command: z.literal(\"rename\"),\n old_path: z.string(),\n new_path: z.string(),\n});\n\n// Discriminated union schema for all memory commands\nexport const Memory20250818CommandSchema = z.discriminatedUnion(\"command\", [\n Memory20250818ViewCommandSchema,\n Memory20250818CreateCommandSchema,\n Memory20250818StrReplaceCommandSchema,\n Memory20250818InsertCommandSchema,\n Memory20250818DeleteCommandSchema,\n Memory20250818RenameCommandSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type Memory20250818ViewCommand = z.infer<\n typeof Memory20250818ViewCommandSchema\n>;\nexport type Memory20250818CreateCommand = z.infer<\n typeof Memory20250818CreateCommandSchema\n>;\nexport type Memory20250818StrReplaceCommand = z.infer<\n typeof Memory20250818StrReplaceCommandSchema\n>;\nexport type Memory20250818InsertCommand = z.infer<\n typeof Memory20250818InsertCommandSchema\n>;\nexport type Memory20250818DeleteCommand = z.infer<\n typeof Memory20250818DeleteCommandSchema\n>;\nexport type Memory20250818RenameCommand = z.infer<\n typeof Memory20250818RenameCommandSchema\n>;\n\nexport type Memory20250818Command = z.infer<typeof Memory20250818CommandSchema>;\n\n/**\n * Options for creating a memory tool.\n */\nexport interface MemoryTool20250818Options {\n /**\n * Optional execute function that handles memory command execution.\n * In LangChain, this is typically handled separately when processing tool calls,\n * but this option is provided for compatibility with the AI SDK pattern.\n * Note: This option is currently unused but reserved for future use.\n */\n execute: (action: Memory20250818Command) => Promise<string> | string;\n}\n\n/**\n * Memory tool type definition.\n */\nexport type MemoryTool20250818 = Anthropic.Beta.BetaMemoryTool20250818;\n\n/**\n * Text editor tool command types for Claude 4.x models.\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool\n */\n\n// Zod schemas for text editor commands\nexport const TextEditor20250728ViewCommandSchema = z.object({\n command: z.literal(\"view\"),\n path: z.string(),\n view_range: z.tuple([z.number(), z.number()]).optional(),\n});\n\nexport const TextEditor20250728StrReplaceCommandSchema = z.object({\n command: z.literal(\"str_replace\"),\n path: z.string(),\n old_str: z.string(),\n new_str: z.string(),\n});\n\nexport const TextEditor20250728CreateCommandSchema = z.object({\n command: z.literal(\"create\"),\n path: z.string(),\n file_text: z.string(),\n});\n\nexport const TextEditor20250728InsertCommandSchema = z.object({\n command: z.literal(\"insert\"),\n path: z.string(),\n insert_line: z.number(),\n new_str: z.string(),\n});\n\n// Discriminated union schema for all text editor commands\nexport const TextEditor20250728CommandSchema = z.discriminatedUnion(\"command\", [\n TextEditor20250728ViewCommandSchema,\n TextEditor20250728StrReplaceCommandSchema,\n TextEditor20250728CreateCommandSchema,\n TextEditor20250728InsertCommandSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type TextEditor20250728ViewCommand = z.infer<\n typeof TextEditor20250728ViewCommandSchema\n>;\nexport type TextEditor20250728StrReplaceCommand = z.infer<\n typeof TextEditor20250728StrReplaceCommandSchema\n>;\nexport type TextEditor20250728CreateCommand = z.infer<\n typeof TextEditor20250728CreateCommandSchema\n>;\nexport type TextEditor20250728InsertCommand = z.infer<\n typeof TextEditor20250728InsertCommandSchema\n>;\nexport type TextEditor20250728Command = z.infer<\n typeof TextEditor20250728CommandSchema\n>;\n\n/**\n * Computer use tool action types for Claude Opus 4.5.\n * Includes zoom action which is not available in earlier versions.\n * @see https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool\n */\nexport type Computer20251124Action =\n | Computer20250124Action\n | ComputerZoomAction;\n\n/**\n * Computer use tool action types for Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4, Opus 4, and Sonnet 3.7 versions.\n * @see https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool\n */\nexport type Computer20250124Action =\n | ComputerScreenshotAction\n | ComputerLeftClickAction\n | ComputerRightClickAction\n | ComputerMiddleClickAction\n | ComputerDoubleClickAction\n | ComputerTripleClickAction\n | ComputerLeftClickDragAction\n | ComputerLeftMouseDownAction\n | ComputerLeftMouseUpAction\n | ComputerScrollAction\n | ComputerTypeAction\n | ComputerKeyAction\n | ComputerMouseMoveAction\n | ComputerHoldKeyAction\n | ComputerWaitAction;\n\n// Zod schemas for computer actions\nconst coordinateSchema = z.tuple([z.number(), z.number()]);\n\nexport const ComputerScreenshotActionSchema = z.object({\n action: z.literal(\"screenshot\"),\n});\n\nexport const ComputerLeftClickActionSchema = z.object({\n action: z.literal(\"left_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerRightClickActionSchema = z.object({\n action: z.literal(\"right_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerMiddleClickActionSchema = z.object({\n action: z.literal(\"middle_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerDoubleClickActionSchema = z.object({\n action: z.literal(\"double_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerTripleClickActionSchema = z.object({\n action: z.literal(\"triple_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerLeftClickDragActionSchema = z.object({\n action: z.literal(\"left_click_drag\"),\n start_coordinate: coordinateSchema,\n end_coordinate: coordinateSchema,\n});\n\nexport const ComputerLeftMouseDownActionSchema = z.object({\n action: z.literal(\"left_mouse_down\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerLeftMouseUpActionSchema = z.object({\n action: z.literal(\"left_mouse_up\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerScrollActionSchema = z.object({\n action: z.literal(\"scroll\"),\n coordinate: coordinateSchema,\n scroll_direction: z.enum([\"up\", \"down\", \"left\", \"right\"]),\n scroll_amount: z.number(),\n});\n\nexport const ComputerTypeActionSchema = z.object({\n action: z.literal(\"type\"),\n text: z.string(),\n});\n\nexport const ComputerKeyActionSchema = z.object({\n action: z.literal(\"key\"),\n key: z.string(),\n});\n\nexport const ComputerMouseMoveActionSchema = z.object({\n action: z.literal(\"mouse_move\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerHoldKeyActionSchema = z.object({\n action: z.literal(\"hold_key\"),\n key: z.string(),\n});\n\nexport const ComputerWaitActionSchema = z.object({\n action: z.literal(\"wait\"),\n duration: z.number().optional(),\n});\n\nexport const ComputerZoomActionSchema = z.object({\n action: z.literal(\"zoom\"),\n region: z.tuple([z.number(), z.number(), z.number(), z.number()]),\n});\n\n// Discriminated union schemas\nexport const Computer20250124ActionSchema = z.discriminatedUnion(\"action\", [\n ComputerScreenshotActionSchema,\n ComputerLeftClickActionSchema,\n ComputerRightClickActionSchema,\n ComputerMiddleClickActionSchema,\n ComputerDoubleClickActionSchema,\n ComputerTripleClickActionSchema,\n ComputerLeftClickDragActionSchema,\n ComputerLeftMouseDownActionSchema,\n ComputerLeftMouseUpActionSchema,\n ComputerScrollActionSchema,\n ComputerTypeActionSchema,\n ComputerKeyActionSchema,\n ComputerMouseMoveActionSchema,\n ComputerHoldKeyActionSchema,\n ComputerWaitActionSchema,\n]);\n\nexport const Computer20251124ActionSchema = z.discriminatedUnion(\"action\", [\n ComputerScreenshotActionSchema,\n ComputerLeftClickActionSchema,\n ComputerRightClickActionSchema,\n ComputerMiddleClickActionSchema,\n ComputerDoubleClickActionSchema,\n ComputerTripleClickActionSchema,\n ComputerLeftClickDragActionSchema,\n ComputerLeftMouseDownActionSchema,\n ComputerLeftMouseUpActionSchema,\n ComputerScrollActionSchema,\n ComputerTypeActionSchema,\n ComputerKeyActionSchema,\n ComputerMouseMoveActionSchema,\n ComputerHoldKeyActionSchema,\n ComputerWaitActionSchema,\n ComputerZoomActionSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type ComputerScreenshotAction = z.infer<\n typeof ComputerScreenshotActionSchema\n>;\n\nexport type ComputerLeftClickAction = z.infer<\n typeof ComputerLeftClickActionSchema\n>;\n\nexport type ComputerRightClickAction = z.infer<\n typeof ComputerRightClickActionSchema\n>;\n\nexport type ComputerMiddleClickAction = z.infer<\n typeof ComputerMiddleClickActionSchema\n>;\n\nexport type ComputerDoubleClickAction = z.infer<\n typeof ComputerDoubleClickActionSchema\n>;\n\nexport type ComputerTripleClickAction = z.infer<\n typeof ComputerTripleClickActionSchema\n>;\n\nexport type ComputerLeftClickDragAction = z.infer<\n typeof ComputerLeftClickDragActionSchema\n>;\n\nexport type ComputerLeftMouseDownAction = z.infer<\n typeof ComputerLeftMouseDownActionSchema\n>;\n\nexport type ComputerLeftMouseUpAction = z.infer<\n typeof ComputerLeftMouseUpActionSchema\n>;\n\nexport type ComputerScrollAction = z.infer<typeof ComputerScrollActionSchema>;\n\nexport type ComputerTypeAction = z.infer<typeof ComputerTypeActionSchema>;\n\nexport type ComputerKeyAction = z.infer<typeof ComputerKeyActionSchema>;\n\nexport type ComputerMouseMoveAction = z.infer<\n typeof ComputerMouseMoveActionSchema\n>;\n\nexport type ComputerHoldKeyAction = z.infer<typeof ComputerHoldKeyActionSchema>;\n\nexport type ComputerWaitAction = z.infer<typeof ComputerWaitActionSchema>;\n\nexport type ComputerZoomAction = z.infer<typeof ComputerZoomActionSchema>;\n\n/**\n * Bash tool command types for Claude 4 models and Claude 3.7.\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/bash-tool\n */\n\n// Zod schemas for bash commands\nexport const Bash20250124ExecuteCommandSchema = z.object({\n command: z.string().describe(\"The bash command to run\"),\n});\n\nexport const Bash20250124RestartCommandSchema = z.object({\n restart: z.literal(true).describe(\"Set to true to restart the bash session\"),\n});\n\n// Union schema for all bash commands\nexport const Bash20250124CommandSchema = z.union([\n Bash20250124ExecuteCommandSchema,\n Bash20250124RestartCommandSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type Bash20250124ExecuteCommand = z.infer<\n typeof Bash20250124ExecuteCommandSchema\n>;\nexport type Bash20250124RestartCommand = z.infer<\n typeof Bash20250124RestartCommandSchema\n>;\nexport type Bash20250124Command = z.infer<typeof Bash20250124CommandSchema>;\n"],"mappings":"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"}
@@ -0,0 +1,70 @@
1
+
2
+ //#region src/tools/webFetch.ts
3
+ /**
4
+ * Creates a web fetch tool that allows Claude to retrieve full content from specified
5
+ * web pages and PDF documents. Claude can only fetch URLs that have been explicitly
6
+ * provided by the user or that come from previous web search or web fetch results.
7
+ *
8
+ * @warning Enabling the web fetch tool in environments where Claude processes untrusted
9
+ * input alongside sensitive data poses data exfiltration risks. We recommend only using
10
+ * this tool in trusted environments or when handling non-sensitive data.
11
+ *
12
+ * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}
13
+ * @param options - Configuration options for the web fetch tool
14
+ * @returns A web fetch tool definition to be passed to the Anthropic API
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
19
+ *
20
+ * const model = new ChatAnthropic({
21
+ * model: "claude-sonnet-4-5-20250929",
22
+ * });
23
+ *
24
+ * // Basic usage - fetch content from a URL
25
+ * const response = await model.invoke(
26
+ * "Please analyze the content at https://example.com/article",
27
+ * { tools: [tools.webFetch_20250910()] }
28
+ * );
29
+ *
30
+ * // With options
31
+ * const responseWithOptions = await model.invoke(
32
+ * "Summarize this research paper: https://arxiv.org/abs/2024.12345",
33
+ * {
34
+ * tools: [tools.webFetch_20250910({
35
+ * maxUses: 5,
36
+ * allowedDomains: ["arxiv.org", "example.com"],
37
+ * citations: { enabled: true },
38
+ * maxContentTokens: 50000,
39
+ * })],
40
+ * }
41
+ * );
42
+ *
43
+ * // Combined with web search for comprehensive information gathering
44
+ * const combinedResponse = await model.invoke(
45
+ * "Find recent articles about quantum computing and analyze the most relevant one",
46
+ * {
47
+ * tools: [
48
+ * tools.webSearch_20250305({ maxUses: 3 }),
49
+ * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),
50
+ * ],
51
+ * }
52
+ * );
53
+ * ```
54
+ */
55
+ function webFetch_20250910(options) {
56
+ return {
57
+ type: "web_fetch_20250910",
58
+ name: "web_fetch",
59
+ max_uses: options?.maxUses,
60
+ allowed_domains: options?.allowedDomains,
61
+ blocked_domains: options?.blockedDomains,
62
+ cache_control: options?.cacheControl,
63
+ citations: options?.citations,
64
+ max_content_tokens: options?.maxContentTokens
65
+ };
66
+ }
67
+
68
+ //#endregion
69
+ exports.webFetch_20250910 = webFetch_20250910;
70
+ //# sourceMappingURL=webFetch.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webFetch.cjs","names":["options?: WebFetch20250910Options"],"sources":["../../src/tools/webFetch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web fetch tool.\n */\nexport interface WebFetch20250910Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be fetched. Cannot be used\n * alongside `blockedDomains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never be fetched. Cannot be used\n * alongside `allowedDomains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Enable citations for fetched content. Unlike web search where citations\n * are always enabled, citations are optional for web fetch.\n */\n citations?: {\n enabled: boolean;\n };\n /**\n * Maximum content length in tokens. If the fetched content exceeds this limit,\n * it will be truncated. This helps control token usage when fetching large documents.\n */\n maxContentTokens?: number;\n}\n\n/**\n * Creates a web fetch tool that allows Claude to retrieve full content from specified\n * web pages and PDF documents. Claude can only fetch URLs that have been explicitly\n * provided by the user or that come from previous web search or web fetch results.\n *\n * @warning Enabling the web fetch tool in environments where Claude processes untrusted\n * input alongside sensitive data poses data exfiltration risks. We recommend only using\n * this tool in trusted environments or when handling non-sensitive data.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}\n * @param options - Configuration options for the web fetch tool\n * @returns A web fetch tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - fetch content from a URL\n * const response = await model.invoke(\n * \"Please analyze the content at https://example.com/article\",\n * { tools: [tools.webFetch_20250910()] }\n * );\n *\n * // With options\n * const responseWithOptions = await model.invoke(\n * \"Summarize this research paper: https://arxiv.org/abs/2024.12345\",\n * {\n * tools: [tools.webFetch_20250910({\n * maxUses: 5,\n * allowedDomains: [\"arxiv.org\", \"example.com\"],\n * citations: { enabled: true },\n * maxContentTokens: 50000,\n * })],\n * }\n * );\n *\n * // Combined with web search for comprehensive information gathering\n * const combinedResponse = await model.invoke(\n * \"Find recent articles about quantum computing and analyze the most relevant one\",\n * {\n * tools: [\n * tools.webSearch_20250305({ maxUses: 3 }),\n * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),\n * ],\n * }\n * );\n * ```\n */\nexport function webFetch_20250910(\n options?: WebFetch20250910Options\n): ServerTool {\n return {\n type: \"web_fetch_20250910\",\n name: \"web_fetch\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n citations: options?.citations,\n max_content_tokens: options?.maxContentTokens,\n } satisfies Anthropic.Beta.BetaWebFetchTool20250910;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,SAAgB,kBACdA,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,WAAW,SAAS;EACpB,oBAAoB,SAAS;CAC9B;AACF"}
@@ -0,0 +1,96 @@
1
+ import Anthropic from "@anthropic-ai/sdk";
2
+ import { ServerTool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/webFetch.d.ts
5
+
6
+ /**
7
+ * Options for the web fetch tool.
8
+ */
9
+ interface WebFetch20250910Options {
10
+ /**
11
+ * Maximum number of times the tool can be used in the API request.
12
+ */
13
+ maxUses?: number;
14
+ /**
15
+ * If provided, only these domains will be fetched. Cannot be used
16
+ * alongside `blockedDomains`.
17
+ */
18
+ allowedDomains?: string[];
19
+ /**
20
+ * If provided, these domains will never be fetched. Cannot be used
21
+ * alongside `allowedDomains`.
22
+ */
23
+ blockedDomains?: string[];
24
+ /**
25
+ * Create a cache control breakpoint at this content block.
26
+ */
27
+ cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;
28
+ /**
29
+ * Enable citations for fetched content. Unlike web search where citations
30
+ * are always enabled, citations are optional for web fetch.
31
+ */
32
+ citations?: {
33
+ enabled: boolean;
34
+ };
35
+ /**
36
+ * Maximum content length in tokens. If the fetched content exceeds this limit,
37
+ * it will be truncated. This helps control token usage when fetching large documents.
38
+ */
39
+ maxContentTokens?: number;
40
+ }
41
+ /**
42
+ * Creates a web fetch tool that allows Claude to retrieve full content from specified
43
+ * web pages and PDF documents. Claude can only fetch URLs that have been explicitly
44
+ * provided by the user or that come from previous web search or web fetch results.
45
+ *
46
+ * @warning Enabling the web fetch tool in environments where Claude processes untrusted
47
+ * input alongside sensitive data poses data exfiltration risks. We recommend only using
48
+ * this tool in trusted environments or when handling non-sensitive data.
49
+ *
50
+ * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}
51
+ * @param options - Configuration options for the web fetch tool
52
+ * @returns A web fetch tool definition to be passed to the Anthropic API
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
57
+ *
58
+ * const model = new ChatAnthropic({
59
+ * model: "claude-sonnet-4-5-20250929",
60
+ * });
61
+ *
62
+ * // Basic usage - fetch content from a URL
63
+ * const response = await model.invoke(
64
+ * "Please analyze the content at https://example.com/article",
65
+ * { tools: [tools.webFetch_20250910()] }
66
+ * );
67
+ *
68
+ * // With options
69
+ * const responseWithOptions = await model.invoke(
70
+ * "Summarize this research paper: https://arxiv.org/abs/2024.12345",
71
+ * {
72
+ * tools: [tools.webFetch_20250910({
73
+ * maxUses: 5,
74
+ * allowedDomains: ["arxiv.org", "example.com"],
75
+ * citations: { enabled: true },
76
+ * maxContentTokens: 50000,
77
+ * })],
78
+ * }
79
+ * );
80
+ *
81
+ * // Combined with web search for comprehensive information gathering
82
+ * const combinedResponse = await model.invoke(
83
+ * "Find recent articles about quantum computing and analyze the most relevant one",
84
+ * {
85
+ * tools: [
86
+ * tools.webSearch_20250305({ maxUses: 3 }),
87
+ * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),
88
+ * ],
89
+ * }
90
+ * );
91
+ * ```
92
+ */
93
+ declare function webFetch_20250910(options?: WebFetch20250910Options): ServerTool;
94
+ //#endregion
95
+ export { WebFetch20250910Options, webFetch_20250910 };
96
+ //# sourceMappingURL=webFetch.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webFetch.d.cts","names":["Anthropic","ServerTool","WebFetch20250910Options","Beta","BetaCacheControlEphemeral","webFetch_20250910"],"sources":["../../src/tools/webFetch.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n/**\n * Options for the web fetch tool.\n */\nexport interface WebFetch20250910Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be fetched. Cannot be used\n * alongside `blockedDomains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never be fetched. Cannot be used\n * alongside `allowedDomains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Enable citations for fetched content. Unlike web search where citations\n * are always enabled, citations are optional for web fetch.\n */\n citations?: {\n enabled: boolean;\n };\n /**\n * Maximum content length in tokens. If the fetched content exceeds this limit,\n * it will be truncated. This helps control token usage when fetching large documents.\n */\n maxContentTokens?: number;\n}\n/**\n * Creates a web fetch tool that allows Claude to retrieve full content from specified\n * web pages and PDF documents. Claude can only fetch URLs that have been explicitly\n * provided by the user or that come from previous web search or web fetch results.\n *\n * @warning Enabling the web fetch tool in environments where Claude processes untrusted\n * input alongside sensitive data poses data exfiltration risks. We recommend only using\n * this tool in trusted environments or when handling non-sensitive data.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}\n * @param options - Configuration options for the web fetch tool\n * @returns A web fetch tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - fetch content from a URL\n * const response = await model.invoke(\n * \"Please analyze the content at https://example.com/article\",\n * { tools: [tools.webFetch_20250910()] }\n * );\n *\n * // With options\n * const responseWithOptions = await model.invoke(\n * \"Summarize this research paper: https://arxiv.org/abs/2024.12345\",\n * {\n * tools: [tools.webFetch_20250910({\n * maxUses: 5,\n * allowedDomains: [\"arxiv.org\", \"example.com\"],\n * citations: { enabled: true },\n * maxContentTokens: 50000,\n * })],\n * }\n * );\n *\n * // Combined with web search for comprehensive information gathering\n * const combinedResponse = await model.invoke(\n * \"Find recent articles about quantum computing and analyze the most relevant one\",\n * {\n * tools: [\n * tools.webSearch_20250305({ maxUses: 3 }),\n * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),\n * ],\n * }\n * );\n * ```\n */\nexport declare function webFetch_20250910(options?: WebFetch20250910Options): ServerTool;\n//# sourceMappingURL=webFetch.d.ts.map"],"mappings":";;;;;;;AAKA;AAoFwBK,UApFPH,uBAAAA,CAoFmCA;;;;;;;;;;;;;;;;;;iBAlEjCF,SAAAA,CAAUG,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkEVC,iBAAAA,WAA4BH,0BAA0BD"}
@@ -0,0 +1,96 @@
1
+ import Anthropic from "@anthropic-ai/sdk";
2
+ import { ServerTool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/webFetch.d.ts
5
+
6
+ /**
7
+ * Options for the web fetch tool.
8
+ */
9
+ interface WebFetch20250910Options {
10
+ /**
11
+ * Maximum number of times the tool can be used in the API request.
12
+ */
13
+ maxUses?: number;
14
+ /**
15
+ * If provided, only these domains will be fetched. Cannot be used
16
+ * alongside `blockedDomains`.
17
+ */
18
+ allowedDomains?: string[];
19
+ /**
20
+ * If provided, these domains will never be fetched. Cannot be used
21
+ * alongside `allowedDomains`.
22
+ */
23
+ blockedDomains?: string[];
24
+ /**
25
+ * Create a cache control breakpoint at this content block.
26
+ */
27
+ cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;
28
+ /**
29
+ * Enable citations for fetched content. Unlike web search where citations
30
+ * are always enabled, citations are optional for web fetch.
31
+ */
32
+ citations?: {
33
+ enabled: boolean;
34
+ };
35
+ /**
36
+ * Maximum content length in tokens. If the fetched content exceeds this limit,
37
+ * it will be truncated. This helps control token usage when fetching large documents.
38
+ */
39
+ maxContentTokens?: number;
40
+ }
41
+ /**
42
+ * Creates a web fetch tool that allows Claude to retrieve full content from specified
43
+ * web pages and PDF documents. Claude can only fetch URLs that have been explicitly
44
+ * provided by the user or that come from previous web search or web fetch results.
45
+ *
46
+ * @warning Enabling the web fetch tool in environments where Claude processes untrusted
47
+ * input alongside sensitive data poses data exfiltration risks. We recommend only using
48
+ * this tool in trusted environments or when handling non-sensitive data.
49
+ *
50
+ * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}
51
+ * @param options - Configuration options for the web fetch tool
52
+ * @returns A web fetch tool definition to be passed to the Anthropic API
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
57
+ *
58
+ * const model = new ChatAnthropic({
59
+ * model: "claude-sonnet-4-5-20250929",
60
+ * });
61
+ *
62
+ * // Basic usage - fetch content from a URL
63
+ * const response = await model.invoke(
64
+ * "Please analyze the content at https://example.com/article",
65
+ * { tools: [tools.webFetch_20250910()] }
66
+ * );
67
+ *
68
+ * // With options
69
+ * const responseWithOptions = await model.invoke(
70
+ * "Summarize this research paper: https://arxiv.org/abs/2024.12345",
71
+ * {
72
+ * tools: [tools.webFetch_20250910({
73
+ * maxUses: 5,
74
+ * allowedDomains: ["arxiv.org", "example.com"],
75
+ * citations: { enabled: true },
76
+ * maxContentTokens: 50000,
77
+ * })],
78
+ * }
79
+ * );
80
+ *
81
+ * // Combined with web search for comprehensive information gathering
82
+ * const combinedResponse = await model.invoke(
83
+ * "Find recent articles about quantum computing and analyze the most relevant one",
84
+ * {
85
+ * tools: [
86
+ * tools.webSearch_20250305({ maxUses: 3 }),
87
+ * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),
88
+ * ],
89
+ * }
90
+ * );
91
+ * ```
92
+ */
93
+ declare function webFetch_20250910(options?: WebFetch20250910Options): ServerTool;
94
+ //#endregion
95
+ export { WebFetch20250910Options, webFetch_20250910 };
96
+ //# sourceMappingURL=webFetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webFetch.d.ts","names":["Anthropic","ServerTool","WebFetch20250910Options","Beta","BetaCacheControlEphemeral","webFetch_20250910"],"sources":["../../src/tools/webFetch.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n/**\n * Options for the web fetch tool.\n */\nexport interface WebFetch20250910Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be fetched. Cannot be used\n * alongside `blockedDomains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never be fetched. Cannot be used\n * alongside `allowedDomains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Enable citations for fetched content. Unlike web search where citations\n * are always enabled, citations are optional for web fetch.\n */\n citations?: {\n enabled: boolean;\n };\n /**\n * Maximum content length in tokens. If the fetched content exceeds this limit,\n * it will be truncated. This helps control token usage when fetching large documents.\n */\n maxContentTokens?: number;\n}\n/**\n * Creates a web fetch tool that allows Claude to retrieve full content from specified\n * web pages and PDF documents. Claude can only fetch URLs that have been explicitly\n * provided by the user or that come from previous web search or web fetch results.\n *\n * @warning Enabling the web fetch tool in environments where Claude processes untrusted\n * input alongside sensitive data poses data exfiltration risks. We recommend only using\n * this tool in trusted environments or when handling non-sensitive data.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}\n * @param options - Configuration options for the web fetch tool\n * @returns A web fetch tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - fetch content from a URL\n * const response = await model.invoke(\n * \"Please analyze the content at https://example.com/article\",\n * { tools: [tools.webFetch_20250910()] }\n * );\n *\n * // With options\n * const responseWithOptions = await model.invoke(\n * \"Summarize this research paper: https://arxiv.org/abs/2024.12345\",\n * {\n * tools: [tools.webFetch_20250910({\n * maxUses: 5,\n * allowedDomains: [\"arxiv.org\", \"example.com\"],\n * citations: { enabled: true },\n * maxContentTokens: 50000,\n * })],\n * }\n * );\n *\n * // Combined with web search for comprehensive information gathering\n * const combinedResponse = await model.invoke(\n * \"Find recent articles about quantum computing and analyze the most relevant one\",\n * {\n * tools: [\n * tools.webSearch_20250305({ maxUses: 3 }),\n * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),\n * ],\n * }\n * );\n * ```\n */\nexport declare function webFetch_20250910(options?: WebFetch20250910Options): ServerTool;\n//# sourceMappingURL=webFetch.d.ts.map"],"mappings":";;;;;;;AAKA;AAoFwBK,UApFPH,uBAAAA,CAoFmCA;;;;;;;;;;;;;;;;;;iBAlEjCF,SAAAA,CAAUG,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkEVC,iBAAAA,WAA4BH,0BAA0BD"}
@@ -0,0 +1,69 @@
1
+ //#region src/tools/webFetch.ts
2
+ /**
3
+ * Creates a web fetch tool that allows Claude to retrieve full content from specified
4
+ * web pages and PDF documents. Claude can only fetch URLs that have been explicitly
5
+ * provided by the user or that come from previous web search or web fetch results.
6
+ *
7
+ * @warning Enabling the web fetch tool in environments where Claude processes untrusted
8
+ * input alongside sensitive data poses data exfiltration risks. We recommend only using
9
+ * this tool in trusted environments or when handling non-sensitive data.
10
+ *
11
+ * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}
12
+ * @param options - Configuration options for the web fetch tool
13
+ * @returns A web fetch tool definition to be passed to the Anthropic API
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
18
+ *
19
+ * const model = new ChatAnthropic({
20
+ * model: "claude-sonnet-4-5-20250929",
21
+ * });
22
+ *
23
+ * // Basic usage - fetch content from a URL
24
+ * const response = await model.invoke(
25
+ * "Please analyze the content at https://example.com/article",
26
+ * { tools: [tools.webFetch_20250910()] }
27
+ * );
28
+ *
29
+ * // With options
30
+ * const responseWithOptions = await model.invoke(
31
+ * "Summarize this research paper: https://arxiv.org/abs/2024.12345",
32
+ * {
33
+ * tools: [tools.webFetch_20250910({
34
+ * maxUses: 5,
35
+ * allowedDomains: ["arxiv.org", "example.com"],
36
+ * citations: { enabled: true },
37
+ * maxContentTokens: 50000,
38
+ * })],
39
+ * }
40
+ * );
41
+ *
42
+ * // Combined with web search for comprehensive information gathering
43
+ * const combinedResponse = await model.invoke(
44
+ * "Find recent articles about quantum computing and analyze the most relevant one",
45
+ * {
46
+ * tools: [
47
+ * tools.webSearch_20250305({ maxUses: 3 }),
48
+ * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),
49
+ * ],
50
+ * }
51
+ * );
52
+ * ```
53
+ */
54
+ function webFetch_20250910(options) {
55
+ return {
56
+ type: "web_fetch_20250910",
57
+ name: "web_fetch",
58
+ max_uses: options?.maxUses,
59
+ allowed_domains: options?.allowedDomains,
60
+ blocked_domains: options?.blockedDomains,
61
+ cache_control: options?.cacheControl,
62
+ citations: options?.citations,
63
+ max_content_tokens: options?.maxContentTokens
64
+ };
65
+ }
66
+
67
+ //#endregion
68
+ export { webFetch_20250910 };
69
+ //# sourceMappingURL=webFetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webFetch.js","names":["options?: WebFetch20250910Options"],"sources":["../../src/tools/webFetch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web fetch tool.\n */\nexport interface WebFetch20250910Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be fetched. Cannot be used\n * alongside `blockedDomains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never be fetched. Cannot be used\n * alongside `allowedDomains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Enable citations for fetched content. Unlike web search where citations\n * are always enabled, citations are optional for web fetch.\n */\n citations?: {\n enabled: boolean;\n };\n /**\n * Maximum content length in tokens. If the fetched content exceeds this limit,\n * it will be truncated. This helps control token usage when fetching large documents.\n */\n maxContentTokens?: number;\n}\n\n/**\n * Creates a web fetch tool that allows Claude to retrieve full content from specified\n * web pages and PDF documents. Claude can only fetch URLs that have been explicitly\n * provided by the user or that come from previous web search or web fetch results.\n *\n * @warning Enabling the web fetch tool in environments where Claude processes untrusted\n * input alongside sensitive data poses data exfiltration risks. We recommend only using\n * this tool in trusted environments or when handling non-sensitive data.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}\n * @param options - Configuration options for the web fetch tool\n * @returns A web fetch tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - fetch content from a URL\n * const response = await model.invoke(\n * \"Please analyze the content at https://example.com/article\",\n * { tools: [tools.webFetch_20250910()] }\n * );\n *\n * // With options\n * const responseWithOptions = await model.invoke(\n * \"Summarize this research paper: https://arxiv.org/abs/2024.12345\",\n * {\n * tools: [tools.webFetch_20250910({\n * maxUses: 5,\n * allowedDomains: [\"arxiv.org\", \"example.com\"],\n * citations: { enabled: true },\n * maxContentTokens: 50000,\n * })],\n * }\n * );\n *\n * // Combined with web search for comprehensive information gathering\n * const combinedResponse = await model.invoke(\n * \"Find recent articles about quantum computing and analyze the most relevant one\",\n * {\n * tools: [\n * tools.webSearch_20250305({ maxUses: 3 }),\n * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),\n * ],\n * }\n * );\n * ```\n */\nexport function webFetch_20250910(\n options?: WebFetch20250910Options\n): ServerTool {\n return {\n type: \"web_fetch_20250910\",\n name: \"web_fetch\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n citations: options?.citations,\n max_content_tokens: options?.maxContentTokens,\n } satisfies Anthropic.Beta.BetaWebFetchTool20250910;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,SAAgB,kBACdA,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,WAAW,SAAS;EACpB,oBAAoB,SAAS;CAC9B;AACF"}
@@ -0,0 +1,57 @@
1
+
2
+ //#region src/tools/webSearch.ts
3
+ /**
4
+ * Creates a web search tool that gives Claude direct access to real-time web content,
5
+ * allowing it to answer questions with up-to-date information beyond its knowledge cutoff.
6
+ * Claude automatically cites sources from search results as part of its answer.
7
+ *
8
+ * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool | Anthropic Web Search Documentation}
9
+ * @param options - Configuration options for the web search tool
10
+ * @returns A web search tool definition to be passed to the Anthropic API
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
15
+ *
16
+ * const model = new ChatAnthropic({
17
+ * model: "claude-sonnet-4-5-20250929",
18
+ * });
19
+ *
20
+ * // Basic usage
21
+ * const response = await model.invoke("What is the weather in NYC?", {
22
+ * tools: [tools.webSearch_20250305()],
23
+ * });
24
+ *
25
+ * // With options
26
+ * const responseWithOptions = await model.invoke("Latest news about AI?", {
27
+ * tools: [tools.webSearch_20250305({
28
+ * maxUses: 5,
29
+ * allowedDomains: ["reuters.com", "bbc.com"],
30
+ * userLocation: {
31
+ * type: "approximate",
32
+ * city: "San Francisco",
33
+ * region: "California",
34
+ * country: "US",
35
+ * timezone: "America/Los_Angeles",
36
+ * },
37
+ * })],
38
+ * });
39
+ * ```
40
+ */
41
+ function webSearch_20250305(options) {
42
+ return {
43
+ type: "web_search_20250305",
44
+ name: "web_search",
45
+ max_uses: options?.maxUses,
46
+ allowed_domains: options?.allowedDomains,
47
+ blocked_domains: options?.blockedDomains,
48
+ cache_control: options?.cacheControl,
49
+ defer_loading: options?.deferLoading,
50
+ strict: options?.strict,
51
+ user_location: options?.userLocation
52
+ };
53
+ }
54
+
55
+ //#endregion
56
+ exports.webSearch_20250305 = webSearch_20250305;
57
+ //# sourceMappingURL=webSearch.cjs.map