@langchain/anthropic 1.3.16 → 1.3.18-dev-1771365493298

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 (126) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +11 -7
  3. package/dist/chat_models.cjs +68 -78
  4. package/dist/chat_models.cjs.map +1 -1
  5. package/dist/chat_models.d.cts +0 -1
  6. package/dist/chat_models.d.cts.map +1 -1
  7. package/dist/chat_models.d.ts +0 -1
  8. package/dist/chat_models.d.ts.map +1 -1
  9. package/dist/chat_models.js +40 -50
  10. package/dist/chat_models.js.map +1 -1
  11. package/dist/index.cjs +1 -0
  12. package/dist/output_parsers.cjs +9 -11
  13. package/dist/output_parsers.cjs.map +1 -1
  14. package/dist/output_parsers.js +2 -4
  15. package/dist/output_parsers.js.map +1 -1
  16. package/dist/profiles.cjs +1 -2
  17. package/dist/profiles.cjs.map +1 -1
  18. package/dist/profiles.js +1 -2
  19. package/dist/profiles.js.map +1 -1
  20. package/dist/tools/bash.cjs +3 -3
  21. package/dist/tools/bash.cjs.map +1 -1
  22. package/dist/tools/bash.d.cts +7 -7
  23. package/dist/tools/bash.d.cts.map +1 -1
  24. package/dist/tools/bash.d.ts +7 -7
  25. package/dist/tools/bash.d.ts.map +1 -1
  26. package/dist/tools/bash.js.map +1 -1
  27. package/dist/tools/codeExecution.cjs.map +1 -1
  28. package/dist/tools/codeExecution.d.cts +0 -1
  29. package/dist/tools/codeExecution.d.cts.map +1 -1
  30. package/dist/tools/codeExecution.d.ts +0 -1
  31. package/dist/tools/codeExecution.d.ts.map +1 -1
  32. package/dist/tools/codeExecution.js.map +1 -1
  33. package/dist/tools/computer.cjs +4 -4
  34. package/dist/tools/computer.cjs.map +1 -1
  35. package/dist/tools/computer.d.cts +101 -101
  36. package/dist/tools/computer.d.cts.map +1 -1
  37. package/dist/tools/computer.d.ts +101 -101
  38. package/dist/tools/computer.d.ts.map +1 -1
  39. package/dist/tools/computer.js.map +1 -1
  40. package/dist/tools/index.cjs.map +1 -1
  41. package/dist/tools/index.d.cts.map +1 -1
  42. package/dist/tools/index.d.ts.map +1 -1
  43. package/dist/tools/index.js.map +1 -1
  44. package/dist/tools/mcpToolset.cjs.map +1 -1
  45. package/dist/tools/mcpToolset.d.cts +0 -1
  46. package/dist/tools/mcpToolset.d.cts.map +1 -1
  47. package/dist/tools/mcpToolset.d.ts +0 -1
  48. package/dist/tools/mcpToolset.d.ts.map +1 -1
  49. package/dist/tools/mcpToolset.js.map +1 -1
  50. package/dist/tools/memory.cjs +3 -3
  51. package/dist/tools/memory.cjs.map +1 -1
  52. package/dist/tools/memory.d.cts +25 -26
  53. package/dist/tools/memory.d.cts.map +1 -1
  54. package/dist/tools/memory.d.ts +25 -26
  55. package/dist/tools/memory.d.ts.map +1 -1
  56. package/dist/tools/memory.js.map +1 -1
  57. package/dist/tools/textEditor.cjs +3 -3
  58. package/dist/tools/textEditor.cjs.map +1 -1
  59. package/dist/tools/textEditor.d.cts +21 -21
  60. package/dist/tools/textEditor.d.cts.map +1 -1
  61. package/dist/tools/textEditor.d.ts +21 -21
  62. package/dist/tools/textEditor.d.ts.map +1 -1
  63. package/dist/tools/textEditor.js.map +1 -1
  64. package/dist/tools/toolSearch.cjs.map +1 -1
  65. package/dist/tools/toolSearch.d.cts +0 -1
  66. package/dist/tools/toolSearch.d.cts.map +1 -1
  67. package/dist/tools/toolSearch.d.ts +0 -1
  68. package/dist/tools/toolSearch.d.ts.map +1 -1
  69. package/dist/tools/toolSearch.js.map +1 -1
  70. package/dist/tools/types.cjs +2 -2
  71. package/dist/tools/types.cjs.map +1 -1
  72. package/dist/tools/types.d.cts +0 -1
  73. package/dist/tools/types.d.cts.map +1 -1
  74. package/dist/tools/types.d.ts +0 -1
  75. package/dist/tools/types.d.ts.map +1 -1
  76. package/dist/tools/types.js.map +1 -1
  77. package/dist/tools/webFetch.cjs.map +1 -1
  78. package/dist/tools/webFetch.d.cts +0 -1
  79. package/dist/tools/webFetch.d.cts.map +1 -1
  80. package/dist/tools/webFetch.d.ts +0 -1
  81. package/dist/tools/webFetch.d.ts.map +1 -1
  82. package/dist/tools/webFetch.js.map +1 -1
  83. package/dist/tools/webSearch.cjs.map +1 -1
  84. package/dist/tools/webSearch.d.cts +0 -1
  85. package/dist/tools/webSearch.d.cts.map +1 -1
  86. package/dist/tools/webSearch.d.ts +0 -1
  87. package/dist/tools/webSearch.d.ts.map +1 -1
  88. package/dist/tools/webSearch.js.map +1 -1
  89. package/dist/types.d.cts +0 -1
  90. package/dist/types.d.cts.map +1 -1
  91. package/dist/types.d.ts +0 -1
  92. package/dist/types.d.ts.map +1 -1
  93. package/dist/utils/content.cjs +3 -3
  94. package/dist/utils/content.cjs.map +1 -1
  95. package/dist/utils/content.js.map +1 -1
  96. package/dist/utils/errors.cjs +4 -1
  97. package/dist/utils/errors.cjs.map +1 -1
  98. package/dist/utils/errors.js +4 -1
  99. package/dist/utils/errors.js.map +1 -1
  100. package/dist/utils/index.cjs.map +1 -1
  101. package/dist/utils/index.js.map +1 -1
  102. package/dist/utils/message_inputs.cjs +79 -100
  103. package/dist/utils/message_inputs.cjs.map +1 -1
  104. package/dist/utils/message_inputs.js +73 -94
  105. package/dist/utils/message_inputs.js.map +1 -1
  106. package/dist/utils/message_outputs.cjs +28 -32
  107. package/dist/utils/message_outputs.cjs.map +1 -1
  108. package/dist/utils/message_outputs.js +13 -17
  109. package/dist/utils/message_outputs.js.map +1 -1
  110. package/dist/utils/prompts.cjs +1 -2
  111. package/dist/utils/prompts.cjs.map +1 -1
  112. package/dist/utils/prompts.d.cts +0 -1
  113. package/dist/utils/prompts.d.cts.map +1 -1
  114. package/dist/utils/prompts.d.ts +0 -1
  115. package/dist/utils/prompts.d.ts.map +1 -1
  116. package/dist/utils/prompts.js +1 -2
  117. package/dist/utils/prompts.js.map +1 -1
  118. package/dist/utils/standard.cjs +2 -4
  119. package/dist/utils/standard.cjs.map +1 -1
  120. package/dist/utils/standard.js +2 -4
  121. package/dist/utils/standard.js.map +1 -1
  122. package/dist/utils/tools.cjs +4 -3
  123. package/dist/utils/tools.cjs.map +1 -1
  124. package/dist/utils/tools.js +1 -1
  125. package/dist/utils/tools.js.map +1 -1
  126. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"computer.js","names":["options: Computer20251124Options","options: Computer20250124Options"],"sources":["../../src/tools/computer.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport Anthropic from \"@anthropic-ai/sdk\";\nimport { tool } from \"@langchain/core/tools\";\nimport { ToolMessage } from \"@langchain/core/messages\";\nimport type { DynamicStructuredTool, ToolRuntime } from \"@langchain/core/tools\";\n\nimport type {\n Computer20251124Action,\n Computer20250124Action,\n} from \"./types.js\";\nimport {\n Computer20251124ActionSchema,\n Computer20250124ActionSchema,\n} from \"./types.js\";\n\nconst TOOL_NAME = \"computer\";\n\nexport type ComputerUseReturnType =\n | string\n | Promise<string>\n | ToolMessage<any>\n | Promise<ToolMessage<any>>;\n\n/**\n * Options for the computer use tool (Claude Opus 4.5 only version).\n *\n * @template TState - The type of the state schema (when used with `ReactAgent`)\n * @template TContext - The type of the context schema (when used with `ReactAgent`)\n */\nexport interface Computer20251124Options<TState = any, TContext = any> {\n /**\n * The width of the display in pixels.\n */\n displayWidthPx: number;\n /**\n * The height of the display in pixels.\n */\n displayHeightPx: number;\n /**\n * Optional display number for X11 environments.\n */\n displayNumber?: number;\n /**\n * Enable zoom action for detailed screen region inspection.\n * When enabled, Claude can zoom into specific screen regions.\n * @default false\n */\n enableZoom?: boolean;\n /**\n * Optional execute function that handles computer action execution.\n * This function receives the action input and should return the result\n * (typically a base64-encoded screenshot or action confirmation).\n */\n execute?: (\n args: Computer20251124Action,\n runtime: ToolRuntime<TState, TContext>\n ) => ComputerUseReturnType;\n}\n\n/**\n * Creates an Anthropic computer use tool for Claude Opus 4.5 that provides\n * screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * The computer use tool enables Claude to interact with desktop environments through:\n * - **Screenshot capture**: See what's currently displayed on screen\n * - **Mouse control**: Click, drag, and move the cursor\n * - **Keyboard input**: Type text and use keyboard shortcuts\n * - **Zoom**: View specific screen regions at full resolution (when enabled)\n *\n * @warning Computer use is a beta feature with unique risks. Use a dedicated virtual machine\n * or container with minimal privileges. Avoid giving access to sensitive data.\n *\n * @see {@link https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool | Anthropic Computer Use Documentation}\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-opus-4-5-20251101\",\n * clientOptions: {\n * defaultHeaders: {\n * \"anthropic-beta\": \"computer-use-2025-11-24\",\n * },\n * },\n * });\n *\n * const computer = tools.computer_20251124({\n * displayWidthPx: 1024,\n * displayHeightPx: 768,\n * displayNumber: 1,\n * enableZoom: true,\n * execute: async (action) => {\n * if (action.action === \"screenshot\") {\n * // Capture and return base64-encoded screenshot\n * return captureScreenshot();\n * }\n * if (action.action === \"left_click\") {\n * // Click at the specified coordinates\n * await click(action.coordinate[0], action.coordinate[1]);\n * return captureScreenshot();\n * }\n * // Handle other actions...\n * },\n * });\n *\n * const llmWithComputer = llm.bindTools([computer]);\n * const response = await llmWithComputer.invoke(\n * \"Save a picture of a cat to my desktop.\"\n * );\n * ```\n *\n * @param options - Configuration options for the computer use tool\n * @returns The computer use tool object that can be passed to `bindTools`\n */\nexport function computer_20251124(options: Computer20251124Options) {\n const name = TOOL_NAME;\n const computerTool = tool(\n options.execute as (\n input: unknown,\n runtime: ToolRuntime<unknown, unknown>\n ) => ComputerUseReturnType,\n {\n name,\n schema: Computer20251124ActionSchema,\n }\n );\n\n computerTool.extras = {\n ...(computerTool.extras ?? {}),\n providerToolDefinition: {\n type: \"computer_20251124\",\n name,\n display_width_px: options.displayWidthPx,\n display_height_px: options.displayHeightPx,\n ...(options.displayNumber !== undefined && {\n display_number: options.displayNumber,\n }),\n ...(options.enableZoom !== undefined && {\n enable_zoom: options.enableZoom,\n }),\n } satisfies Anthropic.Beta.BetaToolComputerUse20251124,\n };\n\n return computerTool as DynamicStructuredTool<\n typeof Computer20251124ActionSchema,\n Computer20251124Action,\n any,\n ToolMessage<any>\n >;\n}\n\n/**\n * Options for the computer use tool.\n *\n * Supported models: Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4, Opus 4, and Sonnet 3.7 versions.\n */\nexport interface Computer20250124Options<TState = any, TContext = any> {\n /**\n * The width of the display in pixels.\n */\n displayWidthPx: number;\n /**\n * The height of the display in pixels.\n */\n displayHeightPx: number;\n /**\n * Optional display number for X11 environments.\n */\n displayNumber?: number;\n /**\n * Optional execute function that handles computer action execution.\n * This function receives the action input and should return the result\n * (typically a base64-encoded screenshot or action confirmation).\n */\n execute?: (\n args: Computer20250124Action,\n runtime: ToolRuntime<TState, TContext>\n ) => ComputerUseReturnType;\n}\n\n/**\n * Creates an Anthropic computer use tool that provides screenshot capabilities and mouse/keyboard control\n * for autonomous desktop interaction.\n *\n * Supported models: Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4, Opus 4, and Sonnet 3.7 versions.\n *\n * The computer use tool enables Claude to interact with desktop environments through:\n * - **Screenshot capture**: See what's currently displayed on screen\n * - **Mouse control**: Click, drag, and move the cursor\n * - **Keyboard input**: Type text and use keyboard shortcuts\n *\n * @warning Computer use is a beta feature with unique risks. Use a dedicated virtual machine\n * or container with minimal privileges. Avoid giving access to sensitive data.\n *\n * @see {@link https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool | Anthropic Computer Use Documentation}\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * clientOptions: {\n * defaultHeaders: {\n * \"anthropic-beta\": \"computer-use-2025-01-24\",\n * },\n * },\n * });\n *\n * const computer = tools.computer_20250124({\n * displayWidthPx: 1024,\n * displayHeightPx: 768,\n * displayNumber: 1,\n * execute: async (action) => {\n * if (action.action === \"screenshot\") {\n * // Capture and return base64-encoded screenshot\n * return captureScreenshot();\n * }\n * if (action.action === \"left_click\") {\n * // Click at the specified coordinates\n * await click(action.coordinate[0], action.coordinate[1]);\n * return captureScreenshot();\n * }\n * // Handle other actions...\n * },\n * });\n *\n * const llmWithComputer = llm.bindTools([computer]);\n * const response = await llmWithComputer.invoke(\n * \"Save a picture of a cat to my desktop.\"\n * );\n * ```\n *\n * @param options - Configuration options for the computer use tool\n * @returns The computer use tool object that can be passed to `bindTools`\n */\nexport function computer_20250124(options: Computer20250124Options) {\n const name = TOOL_NAME;\n const computerTool = tool(\n options.execute as (\n input: unknown,\n runtime: ToolRuntime<unknown, unknown>\n ) => ComputerUseReturnType,\n {\n name,\n description: \"A tool for interacting with the computer\",\n schema: Computer20250124ActionSchema,\n }\n );\n\n computerTool.extras = {\n ...(computerTool.extras ?? {}),\n providerToolDefinition: {\n type: \"computer_20250124\",\n name,\n display_width_px: options.displayWidthPx,\n display_height_px: options.displayHeightPx,\n ...(options.displayNumber !== undefined && {\n display_number: options.displayNumber,\n }),\n } satisfies Anthropic.Beta.BetaToolComputerUse20250124,\n };\n\n return computerTool as DynamicStructuredTool<\n typeof Computer20250124ActionSchema,\n Computer20250124Action,\n any,\n ComputerUseReturnType\n >;\n}\n"],"mappings":";;;;AAeA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGlB,SAAgB,kBAAkBA,SAAkC;CAClE,MAAM,OAAO;CACb,MAAM,eAAe,KACnB,QAAQ,SAIR;EACE;EACA,QAAQ;CACT,EACF;CAED,aAAa,SAAS;EACpB,GAAI,aAAa,UAAU,CAAE;EAC7B,wBAAwB;GACtB,MAAM;GACN;GACA,kBAAkB,QAAQ;GAC1B,mBAAmB,QAAQ;GAC3B,GAAI,QAAQ,kBAAkB,UAAa,EACzC,gBAAgB,QAAQ,cACzB;GACD,GAAI,QAAQ,eAAe,UAAa,EACtC,aAAa,QAAQ,WACtB;EACF;CACF;AAED,QAAO;AAMR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFD,SAAgB,kBAAkBC,SAAkC;CAClE,MAAM,OAAO;CACb,MAAM,eAAe,KACnB,QAAQ,SAIR;EACE;EACA,aAAa;EACb,QAAQ;CACT,EACF;CAED,aAAa,SAAS;EACpB,GAAI,aAAa,UAAU,CAAE;EAC7B,wBAAwB;GACtB,MAAM;GACN;GACA,kBAAkB,QAAQ;GAC1B,mBAAmB,QAAQ;GAC3B,GAAI,QAAQ,kBAAkB,UAAa,EACzC,gBAAgB,QAAQ,cACzB;EACF;CACF;AAED,QAAO;AAMR"}
1
+ {"version":3,"file":"computer.js","names":[],"sources":["../../src/tools/computer.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport Anthropic from \"@anthropic-ai/sdk\";\nimport { tool } from \"@langchain/core/tools\";\nimport { ToolMessage } from \"@langchain/core/messages\";\nimport type { DynamicStructuredTool, ToolRuntime } from \"@langchain/core/tools\";\n\nimport type {\n Computer20251124Action,\n Computer20250124Action,\n} from \"./types.js\";\nimport {\n Computer20251124ActionSchema,\n Computer20250124ActionSchema,\n} from \"./types.js\";\n\nconst TOOL_NAME = \"computer\";\n\nexport type ComputerUseReturnType =\n | string\n | Promise<string>\n | ToolMessage<any>\n | Promise<ToolMessage<any>>;\n\n/**\n * Options for the computer use tool (Claude Opus 4.5 only version).\n *\n * @template TState - The type of the state schema (when used with `ReactAgent`)\n * @template TContext - The type of the context schema (when used with `ReactAgent`)\n */\nexport interface Computer20251124Options<TState = any, TContext = any> {\n /**\n * The width of the display in pixels.\n */\n displayWidthPx: number;\n /**\n * The height of the display in pixels.\n */\n displayHeightPx: number;\n /**\n * Optional display number for X11 environments.\n */\n displayNumber?: number;\n /**\n * Enable zoom action for detailed screen region inspection.\n * When enabled, Claude can zoom into specific screen regions.\n * @default false\n */\n enableZoom?: boolean;\n /**\n * Optional execute function that handles computer action execution.\n * This function receives the action input and should return the result\n * (typically a base64-encoded screenshot or action confirmation).\n */\n execute?: (\n args: Computer20251124Action,\n runtime: ToolRuntime<TState, TContext>\n ) => ComputerUseReturnType;\n}\n\n/**\n * Creates an Anthropic computer use tool for Claude Opus 4.5 that provides\n * screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * The computer use tool enables Claude to interact with desktop environments through:\n * - **Screenshot capture**: See what's currently displayed on screen\n * - **Mouse control**: Click, drag, and move the cursor\n * - **Keyboard input**: Type text and use keyboard shortcuts\n * - **Zoom**: View specific screen regions at full resolution (when enabled)\n *\n * @warning Computer use is a beta feature with unique risks. Use a dedicated virtual machine\n * or container with minimal privileges. Avoid giving access to sensitive data.\n *\n * @see {@link https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool | Anthropic Computer Use Documentation}\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-opus-4-5-20251101\",\n * clientOptions: {\n * defaultHeaders: {\n * \"anthropic-beta\": \"computer-use-2025-11-24\",\n * },\n * },\n * });\n *\n * const computer = tools.computer_20251124({\n * displayWidthPx: 1024,\n * displayHeightPx: 768,\n * displayNumber: 1,\n * enableZoom: true,\n * execute: async (action) => {\n * if (action.action === \"screenshot\") {\n * // Capture and return base64-encoded screenshot\n * return captureScreenshot();\n * }\n * if (action.action === \"left_click\") {\n * // Click at the specified coordinates\n * await click(action.coordinate[0], action.coordinate[1]);\n * return captureScreenshot();\n * }\n * // Handle other actions...\n * },\n * });\n *\n * const llmWithComputer = llm.bindTools([computer]);\n * const response = await llmWithComputer.invoke(\n * \"Save a picture of a cat to my desktop.\"\n * );\n * ```\n *\n * @param options - Configuration options for the computer use tool\n * @returns The computer use tool object that can be passed to `bindTools`\n */\nexport function computer_20251124(options: Computer20251124Options) {\n const name = TOOL_NAME;\n const computerTool = tool(\n options.execute as (\n input: unknown,\n runtime: ToolRuntime<unknown, unknown>\n ) => ComputerUseReturnType,\n {\n name,\n schema: Computer20251124ActionSchema,\n }\n );\n\n computerTool.extras = {\n ...(computerTool.extras ?? {}),\n providerToolDefinition: {\n type: \"computer_20251124\",\n name,\n display_width_px: options.displayWidthPx,\n display_height_px: options.displayHeightPx,\n ...(options.displayNumber !== undefined && {\n display_number: options.displayNumber,\n }),\n ...(options.enableZoom !== undefined && {\n enable_zoom: options.enableZoom,\n }),\n } satisfies Anthropic.Beta.BetaToolComputerUse20251124,\n };\n\n return computerTool as DynamicStructuredTool<\n typeof Computer20251124ActionSchema,\n Computer20251124Action,\n any,\n ToolMessage<any>\n >;\n}\n\n/**\n * Options for the computer use tool.\n *\n * Supported models: Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4, Opus 4, and Sonnet 3.7 versions.\n */\nexport interface Computer20250124Options<TState = any, TContext = any> {\n /**\n * The width of the display in pixels.\n */\n displayWidthPx: number;\n /**\n * The height of the display in pixels.\n */\n displayHeightPx: number;\n /**\n * Optional display number for X11 environments.\n */\n displayNumber?: number;\n /**\n * Optional execute function that handles computer action execution.\n * This function receives the action input and should return the result\n * (typically a base64-encoded screenshot or action confirmation).\n */\n execute?: (\n args: Computer20250124Action,\n runtime: ToolRuntime<TState, TContext>\n ) => ComputerUseReturnType;\n}\n\n/**\n * Creates an Anthropic computer use tool that provides screenshot capabilities and mouse/keyboard control\n * for autonomous desktop interaction.\n *\n * Supported models: Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4, Opus 4, and Sonnet 3.7 versions.\n *\n * The computer use tool enables Claude to interact with desktop environments through:\n * - **Screenshot capture**: See what's currently displayed on screen\n * - **Mouse control**: Click, drag, and move the cursor\n * - **Keyboard input**: Type text and use keyboard shortcuts\n *\n * @warning Computer use is a beta feature with unique risks. Use a dedicated virtual machine\n * or container with minimal privileges. Avoid giving access to sensitive data.\n *\n * @see {@link https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool | Anthropic Computer Use Documentation}\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * clientOptions: {\n * defaultHeaders: {\n * \"anthropic-beta\": \"computer-use-2025-01-24\",\n * },\n * },\n * });\n *\n * const computer = tools.computer_20250124({\n * displayWidthPx: 1024,\n * displayHeightPx: 768,\n * displayNumber: 1,\n * execute: async (action) => {\n * if (action.action === \"screenshot\") {\n * // Capture and return base64-encoded screenshot\n * return captureScreenshot();\n * }\n * if (action.action === \"left_click\") {\n * // Click at the specified coordinates\n * await click(action.coordinate[0], action.coordinate[1]);\n * return captureScreenshot();\n * }\n * // Handle other actions...\n * },\n * });\n *\n * const llmWithComputer = llm.bindTools([computer]);\n * const response = await llmWithComputer.invoke(\n * \"Save a picture of a cat to my desktop.\"\n * );\n * ```\n *\n * @param options - Configuration options for the computer use tool\n * @returns The computer use tool object that can be passed to `bindTools`\n */\nexport function computer_20250124(options: Computer20250124Options) {\n const name = TOOL_NAME;\n const computerTool = tool(\n options.execute as (\n input: unknown,\n runtime: ToolRuntime<unknown, unknown>\n ) => ComputerUseReturnType,\n {\n name,\n description: \"A tool for interacting with the computer\",\n schema: Computer20250124ActionSchema,\n }\n );\n\n computerTool.extras = {\n ...(computerTool.extras ?? {}),\n providerToolDefinition: {\n type: \"computer_20250124\",\n name,\n display_width_px: options.displayWidthPx,\n display_height_px: options.displayHeightPx,\n ...(options.displayNumber !== undefined && {\n display_number: options.displayNumber,\n }),\n } satisfies Anthropic.Beta.BetaToolComputerUse20250124,\n };\n\n return computerTool as DynamicStructuredTool<\n typeof Computer20250124ActionSchema,\n Computer20250124Action,\n any,\n ComputerUseReturnType\n >;\n}\n"],"mappings":";;;;AAeA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGlB,SAAgB,kBAAkB,SAAkC;CAClE,MAAM,OAAO;CACb,MAAM,eAAe,KACnB,QAAQ,SAIR;EACE;EACA,QAAQ;EACT,CACF;AAED,cAAa,SAAS;EACpB,GAAI,aAAa,UAAU,EAAE;EAC7B,wBAAwB;GACtB,MAAM;GACN;GACA,kBAAkB,QAAQ;GAC1B,mBAAmB,QAAQ;GAC3B,GAAI,QAAQ,kBAAkB,UAAa,EACzC,gBAAgB,QAAQ,eACzB;GACD,GAAI,QAAQ,eAAe,UAAa,EACtC,aAAa,QAAQ,YACtB;GACF;EACF;AAED,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FT,SAAgB,kBAAkB,SAAkC;CAClE,MAAM,OAAO;CACb,MAAM,eAAe,KACnB,QAAQ,SAIR;EACE;EACA,aAAa;EACb,QAAQ;EACT,CACF;AAED,cAAa,SAAS;EACpB,GAAI,aAAa,UAAU,EAAE;EAC7B,wBAAwB;GACtB,MAAM;GACN;GACA,kBAAkB,QAAQ;GAC1B,mBAAmB,QAAQ;GAC3B,GAAI,QAAQ,kBAAkB,UAAa,EACzC,gBAAgB,QAAQ,eACzB;GACF;EACF;AAED,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { memory_20250818 } from \"./memory.js\";\nimport {\n webSearch_20250305,\n type WebSearch20250305Options,\n} from \"./webSearch.js\";\nimport { webFetch_20250910, type WebFetch20250910Options } from \"./webFetch.js\";\nimport {\n toolSearchRegex_20251119,\n toolSearchBM25_20251119,\n type ToolSearchOptions,\n} from \"./toolSearch.js\";\nimport {\n textEditor_20250728,\n type TextEditor20250728Options,\n} from \"./textEditor.js\";\nimport {\n computer_20251124,\n computer_20250124,\n type Computer20251124Options,\n type Computer20250124Options,\n type ComputerUseReturnType,\n} from \"./computer.js\";\nimport {\n codeExecution_20250825,\n type CodeExecution20250825Options,\n} from \"./codeExecution.js\";\nimport { bash_20250124, type Bash20250124Options } from \"./bash.js\";\nimport { mcpToolset_20251120, type MCPToolsetOptions } from \"./mcpToolset.js\";\n\nexport const tools = {\n memory_20250818,\n webSearch_20250305,\n webFetch_20250910,\n toolSearchRegex_20251119,\n toolSearchBM25_20251119,\n textEditor_20250728,\n computer_20251124,\n computer_20250124,\n codeExecution_20250825,\n bash_20250124,\n mcpToolset_20251120,\n};\n\nexport type {\n MCPToolsetOptions,\n Bash20250124Options,\n Computer20251124Options,\n Computer20250124Options,\n ComputerUseReturnType,\n CodeExecution20250825Options,\n TextEditor20250728Options,\n ToolSearchOptions,\n WebFetch20250910Options,\n WebSearch20250305Options,\n};\n\nexport type * from \"./types.js\";\n"],"mappings":";;;;;;;;;;;AA6BA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { memory_20250818 } from \"./memory.js\";\nimport {\n webSearch_20250305,\n type WebSearch20250305Options,\n} from \"./webSearch.js\";\nimport { webFetch_20250910, type WebFetch20250910Options } from \"./webFetch.js\";\nimport {\n toolSearchRegex_20251119,\n toolSearchBM25_20251119,\n type ToolSearchOptions,\n} from \"./toolSearch.js\";\nimport {\n textEditor_20250728,\n type TextEditor20250728Options,\n} from \"./textEditor.js\";\nimport {\n computer_20251124,\n computer_20250124,\n type Computer20251124Options,\n type Computer20250124Options,\n type ComputerUseReturnType,\n} from \"./computer.js\";\nimport {\n codeExecution_20250825,\n type CodeExecution20250825Options,\n} from \"./codeExecution.js\";\nimport { bash_20250124, type Bash20250124Options } from \"./bash.js\";\nimport { mcpToolset_20251120, type MCPToolsetOptions } from \"./mcpToolset.js\";\n\nexport const tools = {\n memory_20250818,\n webSearch_20250305,\n webFetch_20250910,\n toolSearchRegex_20251119,\n toolSearchBM25_20251119,\n textEditor_20250728,\n computer_20251124,\n computer_20250124,\n codeExecution_20250825,\n bash_20250124,\n mcpToolset_20251120,\n};\n\nexport type {\n MCPToolsetOptions,\n Bash20250124Options,\n Computer20251124Options,\n Computer20250124Options,\n ComputerUseReturnType,\n CodeExecution20250825Options,\n TextEditor20250728Options,\n ToolSearchOptions,\n WebFetch20250910Options,\n WebSearch20250305Options,\n};\n\nexport type * from \"./types.js\";\n"],"mappings":";;;;;;;;;;;AA6BA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":["memory_20250818","webSearch_20250305","WebSearch20250305Options","webFetch_20250910","WebFetch20250910Options","toolSearchRegex_20251119","toolSearchBM25_20251119","ToolSearchOptions","textEditor_20250728","TextEditor20250728Options","computer_20251124","computer_20250124","Computer20251124Options","Computer20250124Options","ComputerUseReturnType","codeExecution_20250825","CodeExecution20250825Options","bash_20250124","Bash20250124Options","mcpToolset_20251120","MCPToolsetOptions","tools"],"sources":["../../src/tools/index.d.ts"],"sourcesContent":["import { memory_20250818 } from \"./memory.js\";\nimport { webSearch_20250305, type WebSearch20250305Options } from \"./webSearch.js\";\nimport { webFetch_20250910, type WebFetch20250910Options } from \"./webFetch.js\";\nimport { toolSearchRegex_20251119, toolSearchBM25_20251119, type ToolSearchOptions } from \"./toolSearch.js\";\nimport { textEditor_20250728, type TextEditor20250728Options } from \"./textEditor.js\";\nimport { computer_20251124, computer_20250124, type Computer20251124Options, type Computer20250124Options, type ComputerUseReturnType } from \"./computer.js\";\nimport { codeExecution_20250825, type CodeExecution20250825Options } from \"./codeExecution.js\";\nimport { bash_20250124, type Bash20250124Options } from \"./bash.js\";\nimport { mcpToolset_20251120, type MCPToolsetOptions } from \"./mcpToolset.js\";\nexport declare const tools: {\n memory_20250818: typeof memory_20250818;\n webSearch_20250305: typeof webSearch_20250305;\n webFetch_20250910: typeof webFetch_20250910;\n toolSearchRegex_20251119: typeof toolSearchRegex_20251119;\n toolSearchBM25_20251119: typeof toolSearchBM25_20251119;\n textEditor_20250728: typeof textEditor_20250728;\n computer_20251124: typeof computer_20251124;\n computer_20250124: typeof computer_20250124;\n codeExecution_20250825: typeof codeExecution_20250825;\n bash_20250124: typeof bash_20250124;\n mcpToolset_20251120: typeof mcpToolset_20251120;\n};\nexport type { MCPToolsetOptions, Bash20250124Options, Computer20251124Options, Computer20250124Options, ComputerUseReturnType, CodeExecution20250825Options, TextEditor20250728Options, ToolSearchOptions, WebFetch20250910Options, WebSearch20250305Options, };\nexport type * from \"./types.js\";\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;;;;;;cASqBqB;0BACOrB;6BACGC;EAFVoB,iBAYpB,EAAA,OAT6BlB,iBAS7B;EAX2BH,wBAAAA,EAAAA,OAGSK,wBAHTL;EACGC,uBAAAA,EAAAA,OAGKK,uBAHLL;EACDE,mBAAAA,EAAAA,OAGEK,mBAHFL;EACOE,iBAAAA,EAAAA,OAGPK,iBAHOL;EACDC,iBAAAA,EAAAA,OAGNK,iBAHML;EACJE,sBAAAA,EAAAA,OAGGO,sBAHHP;EACFE,aAAAA,EAAAA,OAGJO,aAHIP;EACAC,mBAAAA,EAAAA,OAGEQ,mBAHFR;CACKI"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/tools/index.ts"],"mappings":";;;;;;;;;;;;cA6Ba,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["memory_20250818","webSearch_20250305","WebSearch20250305Options","webFetch_20250910","WebFetch20250910Options","toolSearchRegex_20251119","toolSearchBM25_20251119","ToolSearchOptions","textEditor_20250728","TextEditor20250728Options","computer_20251124","computer_20250124","Computer20251124Options","Computer20250124Options","ComputerUseReturnType","codeExecution_20250825","CodeExecution20250825Options","bash_20250124","Bash20250124Options","mcpToolset_20251120","MCPToolsetOptions","tools"],"sources":["../../src/tools/index.d.ts"],"sourcesContent":["import { memory_20250818 } from \"./memory.js\";\nimport { webSearch_20250305, type WebSearch20250305Options } from \"./webSearch.js\";\nimport { webFetch_20250910, type WebFetch20250910Options } from \"./webFetch.js\";\nimport { toolSearchRegex_20251119, toolSearchBM25_20251119, type ToolSearchOptions } from \"./toolSearch.js\";\nimport { textEditor_20250728, type TextEditor20250728Options } from \"./textEditor.js\";\nimport { computer_20251124, computer_20250124, type Computer20251124Options, type Computer20250124Options, type ComputerUseReturnType } from \"./computer.js\";\nimport { codeExecution_20250825, type CodeExecution20250825Options } from \"./codeExecution.js\";\nimport { bash_20250124, type Bash20250124Options } from \"./bash.js\";\nimport { mcpToolset_20251120, type MCPToolsetOptions } from \"./mcpToolset.js\";\nexport declare const tools: {\n memory_20250818: typeof memory_20250818;\n webSearch_20250305: typeof webSearch_20250305;\n webFetch_20250910: typeof webFetch_20250910;\n toolSearchRegex_20251119: typeof toolSearchRegex_20251119;\n toolSearchBM25_20251119: typeof toolSearchBM25_20251119;\n textEditor_20250728: typeof textEditor_20250728;\n computer_20251124: typeof computer_20251124;\n computer_20250124: typeof computer_20250124;\n codeExecution_20250825: typeof codeExecution_20250825;\n bash_20250124: typeof bash_20250124;\n mcpToolset_20251120: typeof mcpToolset_20251120;\n};\nexport type { MCPToolsetOptions, Bash20250124Options, Computer20251124Options, Computer20250124Options, ComputerUseReturnType, CodeExecution20250825Options, TextEditor20250728Options, ToolSearchOptions, WebFetch20250910Options, WebSearch20250305Options, };\nexport type * from \"./types.js\";\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;;;;;;cASqBqB;0BACOrB;6BACGC;EAFVoB,iBAYpB,EAAA,OAT6BlB,iBAS7B;EAX2BH,wBAAAA,EAAAA,OAGSK,wBAHTL;EACGC,uBAAAA,EAAAA,OAGKK,uBAHLL;EACDE,mBAAAA,EAAAA,OAGEK,mBAHFL;EACOE,iBAAAA,EAAAA,OAGPK,iBAHOL;EACDC,iBAAAA,EAAAA,OAGNK,iBAHML;EACJE,sBAAAA,EAAAA,OAGGO,sBAHHP;EACFE,aAAAA,EAAAA,OAGJO,aAHIP;EACAC,mBAAAA,EAAAA,OAGEQ,mBAHFR;CACKI"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/tools/index.ts"],"mappings":";;;;;;;;;;;;cA6Ba,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { memory_20250818 } from \"./memory.js\";\nimport {\n webSearch_20250305,\n type WebSearch20250305Options,\n} from \"./webSearch.js\";\nimport { webFetch_20250910, type WebFetch20250910Options } from \"./webFetch.js\";\nimport {\n toolSearchRegex_20251119,\n toolSearchBM25_20251119,\n type ToolSearchOptions,\n} from \"./toolSearch.js\";\nimport {\n textEditor_20250728,\n type TextEditor20250728Options,\n} from \"./textEditor.js\";\nimport {\n computer_20251124,\n computer_20250124,\n type Computer20251124Options,\n type Computer20250124Options,\n type ComputerUseReturnType,\n} from \"./computer.js\";\nimport {\n codeExecution_20250825,\n type CodeExecution20250825Options,\n} from \"./codeExecution.js\";\nimport { bash_20250124, type Bash20250124Options } from \"./bash.js\";\nimport { mcpToolset_20251120, type MCPToolsetOptions } from \"./mcpToolset.js\";\n\nexport const tools = {\n memory_20250818,\n webSearch_20250305,\n webFetch_20250910,\n toolSearchRegex_20251119,\n toolSearchBM25_20251119,\n textEditor_20250728,\n computer_20251124,\n computer_20250124,\n codeExecution_20250825,\n bash_20250124,\n mcpToolset_20251120,\n};\n\nexport type {\n MCPToolsetOptions,\n Bash20250124Options,\n Computer20251124Options,\n Computer20250124Options,\n ComputerUseReturnType,\n CodeExecution20250825Options,\n TextEditor20250728Options,\n ToolSearchOptions,\n WebFetch20250910Options,\n WebSearch20250305Options,\n};\n\nexport type * from \"./types.js\";\n"],"mappings":";;;;;;;;;;;AA6BA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { memory_20250818 } from \"./memory.js\";\nimport {\n webSearch_20250305,\n type WebSearch20250305Options,\n} from \"./webSearch.js\";\nimport { webFetch_20250910, type WebFetch20250910Options } from \"./webFetch.js\";\nimport {\n toolSearchRegex_20251119,\n toolSearchBM25_20251119,\n type ToolSearchOptions,\n} from \"./toolSearch.js\";\nimport {\n textEditor_20250728,\n type TextEditor20250728Options,\n} from \"./textEditor.js\";\nimport {\n computer_20251124,\n computer_20250124,\n type Computer20251124Options,\n type Computer20250124Options,\n type ComputerUseReturnType,\n} from \"./computer.js\";\nimport {\n codeExecution_20250825,\n type CodeExecution20250825Options,\n} from \"./codeExecution.js\";\nimport { bash_20250124, type Bash20250124Options } from \"./bash.js\";\nimport { mcpToolset_20251120, type MCPToolsetOptions } from \"./mcpToolset.js\";\n\nexport const tools = {\n memory_20250818,\n webSearch_20250305,\n webFetch_20250910,\n toolSearchRegex_20251119,\n toolSearchBM25_20251119,\n textEditor_20250728,\n computer_20251124,\n computer_20250124,\n codeExecution_20250825,\n bash_20250124,\n mcpToolset_20251120,\n};\n\nexport type {\n MCPToolsetOptions,\n Bash20250124Options,\n Computer20251124Options,\n Computer20250124Options,\n ComputerUseReturnType,\n CodeExecution20250825Options,\n TextEditor20250728Options,\n ToolSearchOptions,\n WebFetch20250910Options,\n WebSearch20250305Options,\n};\n\nexport type * from \"./types.js\";\n"],"mappings":";;;;;;;;;;;AA6BA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"mcpToolset.cjs","names":["options: MCPToolsetOptions"],"sources":["../../src/tools/mcpToolset.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Configuration for a single tool in the MCP toolset.\n */\nexport interface MCPToolConfig {\n /**\n * Whether this tool is enabled.\n * @default true\n */\n enabled?: boolean;\n /**\n * If true, tool description is not sent to the model initially.\n * Used with Tool Search Tool for on-demand loading.\n * @default false\n */\n deferLoading?: boolean;\n}\n\n/**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\nexport type MCPToolConfigs = Record<string, MCPToolConfig>;\n\n/**\n * Options for creating an MCP toolset.\n */\nexport interface MCPToolsetOptions {\n /**\n * Must match a server name defined in the `mcp_servers` array in call options.\n */\n serverName: string;\n /**\n * Default configuration applied to all tools in this toolset.\n * Individual tool configs will override these defaults.\n */\n defaultConfig?: MCPToolConfig;\n /**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\n configs?: MCPToolConfigs;\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n}\n\n/**\n * Creates an MCP toolset that connects to a remote MCP server to access its tools.\n * This enables Claude to use tools from MCP servers without implementing a separate MCP client.\n *\n * @note This tool requires the beta header `mcp-client-2025-11-20` in API requests.\n * The header is automatically added when using this tool.\n *\n * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector | Anthropic MCP Connector Documentation}\n * @param options - Configuration options for the MCP toolset\n * @returns An MCP toolset definition to be passed to the Anthropic API tools array\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 - enable all tools from an MCP server\n * const response = await model.invoke(\"What tools do you have available?\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example-server.modelcontextprotocol.io/sse\",\n * name: \"example-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({ serverName: \"example-mcp\" }),\n * ],\n * });\n *\n * // Allowlist pattern - enable only specific tools\n * const responseAllowlist = await model.invoke(\"Search for events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * defaultConfig: { enabled: false },\n * configs: {\n * search_events: { enabled: true },\n * create_event: { enabled: true },\n * },\n * }),\n * ],\n * });\n *\n * // Denylist pattern - disable specific tools\n * const responseDenylist = await model.invoke(\"List my events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * configs: {\n * delete_all_events: { enabled: false },\n * share_calendar_publicly: { enabled: false },\n * },\n * }),\n * ],\n * });\n *\n * // With deferred loading for use with Tool Search Tool\n * const responseDeferred = await model.invoke(\"Search for tools\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example.com/sse\",\n * name: \"example-mcp\",\n * }],\n * tools: [\n * tools.toolSearchRegex_20251119(),\n * tools.mcpToolset_20251120({\n * serverName: \"example-mcp\",\n * defaultConfig: { deferLoading: true },\n * }),\n * ],\n * });\n * ```\n */\nexport function mcpToolset_20251120(options: MCPToolsetOptions): ServerTool {\n const defaultConfig =\n options.defaultConfig?.enabled !== undefined ||\n options.defaultConfig?.deferLoading !== undefined\n ? {\n enabled: options.defaultConfig?.enabled,\n defer_loading: options.defaultConfig?.deferLoading,\n }\n : undefined;\n\n const configs = options.configs\n ? Object.fromEntries(\n Object.entries(options.configs).map(([toolName, config]) => [\n toolName,\n {\n enabled: config.enabled,\n defer_loading: config.deferLoading,\n },\n ])\n )\n : undefined;\n\n return {\n type: \"mcp_toolset\",\n mcp_server_name: options.serverName,\n default_config: defaultConfig,\n configs,\n cache_control: options.cacheControl,\n } satisfies Anthropic.Beta.BetaMCPToolset;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,SAAgB,oBAAoBA,SAAwC;CAC1E,MAAM,gBACJ,QAAQ,eAAe,YAAY,UACnC,QAAQ,eAAe,iBAAiB,SACpC;EACE,SAAS,QAAQ,eAAe;EAChC,eAAe,QAAQ,eAAe;CACvC,IACD;CAEN,MAAM,UAAU,QAAQ,UACpB,OAAO,YACL,OAAO,QAAQ,QAAQ,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,OAAO,KAAK,CAC1D,UACA;EACE,SAAS,OAAO;EAChB,eAAe,OAAO;CACvB,CACF,EAAC,CACH,GACD;AAEJ,QAAO;EACL,MAAM;EACN,iBAAiB,QAAQ;EACzB,gBAAgB;EAChB;EACA,eAAe,QAAQ;CACxB;AACF"}
1
+ {"version":3,"file":"mcpToolset.cjs","names":[],"sources":["../../src/tools/mcpToolset.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Configuration for a single tool in the MCP toolset.\n */\nexport interface MCPToolConfig {\n /**\n * Whether this tool is enabled.\n * @default true\n */\n enabled?: boolean;\n /**\n * If true, tool description is not sent to the model initially.\n * Used with Tool Search Tool for on-demand loading.\n * @default false\n */\n deferLoading?: boolean;\n}\n\n/**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\nexport type MCPToolConfigs = Record<string, MCPToolConfig>;\n\n/**\n * Options for creating an MCP toolset.\n */\nexport interface MCPToolsetOptions {\n /**\n * Must match a server name defined in the `mcp_servers` array in call options.\n */\n serverName: string;\n /**\n * Default configuration applied to all tools in this toolset.\n * Individual tool configs will override these defaults.\n */\n defaultConfig?: MCPToolConfig;\n /**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\n configs?: MCPToolConfigs;\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n}\n\n/**\n * Creates an MCP toolset that connects to a remote MCP server to access its tools.\n * This enables Claude to use tools from MCP servers without implementing a separate MCP client.\n *\n * @note This tool requires the beta header `mcp-client-2025-11-20` in API requests.\n * The header is automatically added when using this tool.\n *\n * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector | Anthropic MCP Connector Documentation}\n * @param options - Configuration options for the MCP toolset\n * @returns An MCP toolset definition to be passed to the Anthropic API tools array\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 - enable all tools from an MCP server\n * const response = await model.invoke(\"What tools do you have available?\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example-server.modelcontextprotocol.io/sse\",\n * name: \"example-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({ serverName: \"example-mcp\" }),\n * ],\n * });\n *\n * // Allowlist pattern - enable only specific tools\n * const responseAllowlist = await model.invoke(\"Search for events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * defaultConfig: { enabled: false },\n * configs: {\n * search_events: { enabled: true },\n * create_event: { enabled: true },\n * },\n * }),\n * ],\n * });\n *\n * // Denylist pattern - disable specific tools\n * const responseDenylist = await model.invoke(\"List my events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * configs: {\n * delete_all_events: { enabled: false },\n * share_calendar_publicly: { enabled: false },\n * },\n * }),\n * ],\n * });\n *\n * // With deferred loading for use with Tool Search Tool\n * const responseDeferred = await model.invoke(\"Search for tools\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example.com/sse\",\n * name: \"example-mcp\",\n * }],\n * tools: [\n * tools.toolSearchRegex_20251119(),\n * tools.mcpToolset_20251120({\n * serverName: \"example-mcp\",\n * defaultConfig: { deferLoading: true },\n * }),\n * ],\n * });\n * ```\n */\nexport function mcpToolset_20251120(options: MCPToolsetOptions): ServerTool {\n const defaultConfig =\n options.defaultConfig?.enabled !== undefined ||\n options.defaultConfig?.deferLoading !== undefined\n ? {\n enabled: options.defaultConfig?.enabled,\n defer_loading: options.defaultConfig?.deferLoading,\n }\n : undefined;\n\n const configs = options.configs\n ? Object.fromEntries(\n Object.entries(options.configs).map(([toolName, config]) => [\n toolName,\n {\n enabled: config.enabled,\n defer_loading: config.deferLoading,\n },\n ])\n )\n : undefined;\n\n return {\n type: \"mcp_toolset\",\n mcp_server_name: options.serverName,\n default_config: defaultConfig,\n configs,\n cache_control: options.cacheControl,\n } satisfies Anthropic.Beta.BetaMCPToolset;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,SAAgB,oBAAoB,SAAwC;CAC1E,MAAM,gBACJ,QAAQ,eAAe,YAAY,UACnC,QAAQ,eAAe,iBAAiB,SACpC;EACE,SAAS,QAAQ,eAAe;EAChC,eAAe,QAAQ,eAAe;EACvC,GACD;CAEN,MAAM,UAAU,QAAQ,UACpB,OAAO,YACL,OAAO,QAAQ,QAAQ,QAAQ,CAAC,KAAK,CAAC,UAAU,YAAY,CAC1D,UACA;EACE,SAAS,OAAO;EAChB,eAAe,OAAO;EACvB,CACF,CAAC,CACH,GACD;AAEJ,QAAO;EACL,MAAM;EACN,iBAAiB,QAAQ;EACzB,gBAAgB;EAChB;EACA,eAAe,QAAQ;EACxB"}
@@ -2,7 +2,6 @@ import Anthropic from "@anthropic-ai/sdk";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/mcpToolset.d.ts
5
-
6
5
  /**
7
6
  * Configuration for a single tool in the MCP toolset.
8
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mcpToolset.d.cts","names":["Anthropic","ServerTool","MCPToolConfig","MCPToolConfigs","Record","MCPToolsetOptions","Beta","BetaCacheControlEphemeral","mcpToolset_20251120"],"sources":["../../src/tools/mcpToolset.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n/**\n * Configuration for a single tool in the MCP toolset.\n */\nexport interface MCPToolConfig {\n /**\n * Whether this tool is enabled.\n * @default true\n */\n enabled?: boolean;\n /**\n * If true, tool description is not sent to the model initially.\n * Used with Tool Search Tool for on-demand loading.\n * @default false\n */\n deferLoading?: boolean;\n}\n/**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\nexport type MCPToolConfigs = Record<string, MCPToolConfig>;\n/**\n * Options for creating an MCP toolset.\n */\nexport interface MCPToolsetOptions {\n /**\n * Must match a server name defined in the `mcp_servers` array in call options.\n */\n serverName: string;\n /**\n * Default configuration applied to all tools in this toolset.\n * Individual tool configs will override these defaults.\n */\n defaultConfig?: MCPToolConfig;\n /**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\n configs?: MCPToolConfigs;\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n}\n/**\n * Creates an MCP toolset that connects to a remote MCP server to access its tools.\n * This enables Claude to use tools from MCP servers without implementing a separate MCP client.\n *\n * @note This tool requires the beta header `mcp-client-2025-11-20` in API requests.\n * The header is automatically added when using this tool.\n *\n * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector | Anthropic MCP Connector Documentation}\n * @param options - Configuration options for the MCP toolset\n * @returns An MCP toolset definition to be passed to the Anthropic API tools array\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 - enable all tools from an MCP server\n * const response = await model.invoke(\"What tools do you have available?\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example-server.modelcontextprotocol.io/sse\",\n * name: \"example-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({ serverName: \"example-mcp\" }),\n * ],\n * });\n *\n * // Allowlist pattern - enable only specific tools\n * const responseAllowlist = await model.invoke(\"Search for events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * defaultConfig: { enabled: false },\n * configs: {\n * search_events: { enabled: true },\n * create_event: { enabled: true },\n * },\n * }),\n * ],\n * });\n *\n * // Denylist pattern - disable specific tools\n * const responseDenylist = await model.invoke(\"List my events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * configs: {\n * delete_all_events: { enabled: false },\n * share_calendar_publicly: { enabled: false },\n * },\n * }),\n * ],\n * });\n *\n * // With deferred loading for use with Tool Search Tool\n * const responseDeferred = await model.invoke(\"Search for tools\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example.com/sse\",\n * name: \"example-mcp\",\n * }],\n * tools: [\n * tools.toolSearchRegex_20251119(),\n * tools.mcpToolset_20251120({\n * serverName: \"example-mcp\",\n * defaultConfig: { deferLoading: true },\n * }),\n * ],\n * });\n * ```\n */\nexport declare function mcpToolset_20251120(options: MCPToolsetOptions): ServerTool;\n//# sourceMappingURL=mcpToolset.d.ts.map"],"mappings":";;;;;;;AAKA;AAiBYG,UAjBKD,aAAAA,CAiBS;EAITG;;;;EAkB0C,OAAA,CAAA,EAAA,OAAA;EA0FnCG;;;;;;;;;;;KAhHZL,cAAAA,GAAiBC,eAAeF;;;;UAI3BG,iBAAAA;;;;;;;;;kBASGH;;;;;YAKNC;;;;iBAIKH,SAAAA,CAAUM,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0FVC,mBAAAA,UAA6BH,oBAAoBJ"}
1
+ {"version":3,"file":"mcpToolset.d.cts","names":[],"sources":["../../src/tools/mcpToolset.ts"],"mappings":";;;;;;AAMA;UAAiB,aAAA;;;;AAkBjB;EAbE,OAAA;;;;AAkBF;;EAZE,YAAA;AAAA;;;;;KAOU,cAAA,GAAiB,MAAA,SAAe,aAAA;;;;UAK3B,iBAAA;EAkBf;;;EAdA,UAAA;EAcuD;;AA2FzD;;EApGE,aAAA,GAAgB,aAAA;EAoGyD;;;;EA/FzE,OAAA,GAAU,cAAA;EA+F+D;;;EA3FzE,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2FhB,mBAAA,CAAoB,OAAA,EAAS,iBAAA,GAAoB,UAAA"}
@@ -2,7 +2,6 @@ import Anthropic from "@anthropic-ai/sdk";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/mcpToolset.d.ts
5
-
6
5
  /**
7
6
  * Configuration for a single tool in the MCP toolset.
8
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mcpToolset.d.ts","names":["Anthropic","ServerTool","MCPToolConfig","MCPToolConfigs","Record","MCPToolsetOptions","Beta","BetaCacheControlEphemeral","mcpToolset_20251120"],"sources":["../../src/tools/mcpToolset.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n/**\n * Configuration for a single tool in the MCP toolset.\n */\nexport interface MCPToolConfig {\n /**\n * Whether this tool is enabled.\n * @default true\n */\n enabled?: boolean;\n /**\n * If true, tool description is not sent to the model initially.\n * Used with Tool Search Tool for on-demand loading.\n * @default false\n */\n deferLoading?: boolean;\n}\n/**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\nexport type MCPToolConfigs = Record<string, MCPToolConfig>;\n/**\n * Options for creating an MCP toolset.\n */\nexport interface MCPToolsetOptions {\n /**\n * Must match a server name defined in the `mcp_servers` array in call options.\n */\n serverName: string;\n /**\n * Default configuration applied to all tools in this toolset.\n * Individual tool configs will override these defaults.\n */\n defaultConfig?: MCPToolConfig;\n /**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\n configs?: MCPToolConfigs;\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n}\n/**\n * Creates an MCP toolset that connects to a remote MCP server to access its tools.\n * This enables Claude to use tools from MCP servers without implementing a separate MCP client.\n *\n * @note This tool requires the beta header `mcp-client-2025-11-20` in API requests.\n * The header is automatically added when using this tool.\n *\n * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector | Anthropic MCP Connector Documentation}\n * @param options - Configuration options for the MCP toolset\n * @returns An MCP toolset definition to be passed to the Anthropic API tools array\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 - enable all tools from an MCP server\n * const response = await model.invoke(\"What tools do you have available?\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example-server.modelcontextprotocol.io/sse\",\n * name: \"example-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({ serverName: \"example-mcp\" }),\n * ],\n * });\n *\n * // Allowlist pattern - enable only specific tools\n * const responseAllowlist = await model.invoke(\"Search for events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * defaultConfig: { enabled: false },\n * configs: {\n * search_events: { enabled: true },\n * create_event: { enabled: true },\n * },\n * }),\n * ],\n * });\n *\n * // Denylist pattern - disable specific tools\n * const responseDenylist = await model.invoke(\"List my events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * configs: {\n * delete_all_events: { enabled: false },\n * share_calendar_publicly: { enabled: false },\n * },\n * }),\n * ],\n * });\n *\n * // With deferred loading for use with Tool Search Tool\n * const responseDeferred = await model.invoke(\"Search for tools\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example.com/sse\",\n * name: \"example-mcp\",\n * }],\n * tools: [\n * tools.toolSearchRegex_20251119(),\n * tools.mcpToolset_20251120({\n * serverName: \"example-mcp\",\n * defaultConfig: { deferLoading: true },\n * }),\n * ],\n * });\n * ```\n */\nexport declare function mcpToolset_20251120(options: MCPToolsetOptions): ServerTool;\n//# sourceMappingURL=mcpToolset.d.ts.map"],"mappings":";;;;;;;AAKA;AAiBYG,UAjBKD,aAAAA,CAiBS;EAITG;;;;EAkB0C,OAAA,CAAA,EAAA,OAAA;EA0FnCG;;;;;;;;;;;KAhHZL,cAAAA,GAAiBC,eAAeF;;;;UAI3BG,iBAAAA;;;;;;;;;kBASGH;;;;;YAKNC;;;;iBAIKH,SAAAA,CAAUM,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0FVC,mBAAAA,UAA6BH,oBAAoBJ"}
1
+ {"version":3,"file":"mcpToolset.d.ts","names":[],"sources":["../../src/tools/mcpToolset.ts"],"mappings":";;;;;;AAMA;UAAiB,aAAA;;;;AAkBjB;EAbE,OAAA;;;;AAkBF;;EAZE,YAAA;AAAA;;;;;KAOU,cAAA,GAAiB,MAAA,SAAe,aAAA;;;;UAK3B,iBAAA;EAkBf;;;EAdA,UAAA;EAcuD;;AA2FzD;;EApGE,aAAA,GAAgB,aAAA;EAoGyD;;;;EA/FzE,OAAA,GAAU,cAAA;EA+F+D;;;EA3FzE,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2FhB,mBAAA,CAAoB,OAAA,EAAS,iBAAA,GAAoB,UAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"mcpToolset.js","names":["options: MCPToolsetOptions"],"sources":["../../src/tools/mcpToolset.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Configuration for a single tool in the MCP toolset.\n */\nexport interface MCPToolConfig {\n /**\n * Whether this tool is enabled.\n * @default true\n */\n enabled?: boolean;\n /**\n * If true, tool description is not sent to the model initially.\n * Used with Tool Search Tool for on-demand loading.\n * @default false\n */\n deferLoading?: boolean;\n}\n\n/**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\nexport type MCPToolConfigs = Record<string, MCPToolConfig>;\n\n/**\n * Options for creating an MCP toolset.\n */\nexport interface MCPToolsetOptions {\n /**\n * Must match a server name defined in the `mcp_servers` array in call options.\n */\n serverName: string;\n /**\n * Default configuration applied to all tools in this toolset.\n * Individual tool configs will override these defaults.\n */\n defaultConfig?: MCPToolConfig;\n /**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\n configs?: MCPToolConfigs;\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n}\n\n/**\n * Creates an MCP toolset that connects to a remote MCP server to access its tools.\n * This enables Claude to use tools from MCP servers without implementing a separate MCP client.\n *\n * @note This tool requires the beta header `mcp-client-2025-11-20` in API requests.\n * The header is automatically added when using this tool.\n *\n * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector | Anthropic MCP Connector Documentation}\n * @param options - Configuration options for the MCP toolset\n * @returns An MCP toolset definition to be passed to the Anthropic API tools array\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 - enable all tools from an MCP server\n * const response = await model.invoke(\"What tools do you have available?\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example-server.modelcontextprotocol.io/sse\",\n * name: \"example-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({ serverName: \"example-mcp\" }),\n * ],\n * });\n *\n * // Allowlist pattern - enable only specific tools\n * const responseAllowlist = await model.invoke(\"Search for events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * defaultConfig: { enabled: false },\n * configs: {\n * search_events: { enabled: true },\n * create_event: { enabled: true },\n * },\n * }),\n * ],\n * });\n *\n * // Denylist pattern - disable specific tools\n * const responseDenylist = await model.invoke(\"List my events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * configs: {\n * delete_all_events: { enabled: false },\n * share_calendar_publicly: { enabled: false },\n * },\n * }),\n * ],\n * });\n *\n * // With deferred loading for use with Tool Search Tool\n * const responseDeferred = await model.invoke(\"Search for tools\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example.com/sse\",\n * name: \"example-mcp\",\n * }],\n * tools: [\n * tools.toolSearchRegex_20251119(),\n * tools.mcpToolset_20251120({\n * serverName: \"example-mcp\",\n * defaultConfig: { deferLoading: true },\n * }),\n * ],\n * });\n * ```\n */\nexport function mcpToolset_20251120(options: MCPToolsetOptions): ServerTool {\n const defaultConfig =\n options.defaultConfig?.enabled !== undefined ||\n options.defaultConfig?.deferLoading !== undefined\n ? {\n enabled: options.defaultConfig?.enabled,\n defer_loading: options.defaultConfig?.deferLoading,\n }\n : undefined;\n\n const configs = options.configs\n ? Object.fromEntries(\n Object.entries(options.configs).map(([toolName, config]) => [\n toolName,\n {\n enabled: config.enabled,\n defer_loading: config.deferLoading,\n },\n ])\n )\n : undefined;\n\n return {\n type: \"mcp_toolset\",\n mcp_server_name: options.serverName,\n default_config: defaultConfig,\n configs,\n cache_control: options.cacheControl,\n } satisfies Anthropic.Beta.BetaMCPToolset;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,SAAgB,oBAAoBA,SAAwC;CAC1E,MAAM,gBACJ,QAAQ,eAAe,YAAY,UACnC,QAAQ,eAAe,iBAAiB,SACpC;EACE,SAAS,QAAQ,eAAe;EAChC,eAAe,QAAQ,eAAe;CACvC,IACD;CAEN,MAAM,UAAU,QAAQ,UACpB,OAAO,YACL,OAAO,QAAQ,QAAQ,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,OAAO,KAAK,CAC1D,UACA;EACE,SAAS,OAAO;EAChB,eAAe,OAAO;CACvB,CACF,EAAC,CACH,GACD;AAEJ,QAAO;EACL,MAAM;EACN,iBAAiB,QAAQ;EACzB,gBAAgB;EAChB;EACA,eAAe,QAAQ;CACxB;AACF"}
1
+ {"version":3,"file":"mcpToolset.js","names":[],"sources":["../../src/tools/mcpToolset.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Configuration for a single tool in the MCP toolset.\n */\nexport interface MCPToolConfig {\n /**\n * Whether this tool is enabled.\n * @default true\n */\n enabled?: boolean;\n /**\n * If true, tool description is not sent to the model initially.\n * Used with Tool Search Tool for on-demand loading.\n * @default false\n */\n deferLoading?: boolean;\n}\n\n/**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\nexport type MCPToolConfigs = Record<string, MCPToolConfig>;\n\n/**\n * Options for creating an MCP toolset.\n */\nexport interface MCPToolsetOptions {\n /**\n * Must match a server name defined in the `mcp_servers` array in call options.\n */\n serverName: string;\n /**\n * Default configuration applied to all tools in this toolset.\n * Individual tool configs will override these defaults.\n */\n defaultConfig?: MCPToolConfig;\n /**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\n configs?: MCPToolConfigs;\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n}\n\n/**\n * Creates an MCP toolset that connects to a remote MCP server to access its tools.\n * This enables Claude to use tools from MCP servers without implementing a separate MCP client.\n *\n * @note This tool requires the beta header `mcp-client-2025-11-20` in API requests.\n * The header is automatically added when using this tool.\n *\n * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector | Anthropic MCP Connector Documentation}\n * @param options - Configuration options for the MCP toolset\n * @returns An MCP toolset definition to be passed to the Anthropic API tools array\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 - enable all tools from an MCP server\n * const response = await model.invoke(\"What tools do you have available?\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example-server.modelcontextprotocol.io/sse\",\n * name: \"example-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({ serverName: \"example-mcp\" }),\n * ],\n * });\n *\n * // Allowlist pattern - enable only specific tools\n * const responseAllowlist = await model.invoke(\"Search for events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * defaultConfig: { enabled: false },\n * configs: {\n * search_events: { enabled: true },\n * create_event: { enabled: true },\n * },\n * }),\n * ],\n * });\n *\n * // Denylist pattern - disable specific tools\n * const responseDenylist = await model.invoke(\"List my events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * configs: {\n * delete_all_events: { enabled: false },\n * share_calendar_publicly: { enabled: false },\n * },\n * }),\n * ],\n * });\n *\n * // With deferred loading for use with Tool Search Tool\n * const responseDeferred = await model.invoke(\"Search for tools\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example.com/sse\",\n * name: \"example-mcp\",\n * }],\n * tools: [\n * tools.toolSearchRegex_20251119(),\n * tools.mcpToolset_20251120({\n * serverName: \"example-mcp\",\n * defaultConfig: { deferLoading: true },\n * }),\n * ],\n * });\n * ```\n */\nexport function mcpToolset_20251120(options: MCPToolsetOptions): ServerTool {\n const defaultConfig =\n options.defaultConfig?.enabled !== undefined ||\n options.defaultConfig?.deferLoading !== undefined\n ? {\n enabled: options.defaultConfig?.enabled,\n defer_loading: options.defaultConfig?.deferLoading,\n }\n : undefined;\n\n const configs = options.configs\n ? Object.fromEntries(\n Object.entries(options.configs).map(([toolName, config]) => [\n toolName,\n {\n enabled: config.enabled,\n defer_loading: config.deferLoading,\n },\n ])\n )\n : undefined;\n\n return {\n type: \"mcp_toolset\",\n mcp_server_name: options.serverName,\n default_config: defaultConfig,\n configs,\n cache_control: options.cacheControl,\n } satisfies Anthropic.Beta.BetaMCPToolset;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,SAAgB,oBAAoB,SAAwC;CAC1E,MAAM,gBACJ,QAAQ,eAAe,YAAY,UACnC,QAAQ,eAAe,iBAAiB,SACpC;EACE,SAAS,QAAQ,eAAe;EAChC,eAAe,QAAQ,eAAe;EACvC,GACD;CAEN,MAAM,UAAU,QAAQ,UACpB,OAAO,YACL,OAAO,QAAQ,QAAQ,QAAQ,CAAC,KAAK,CAAC,UAAU,YAAY,CAC1D,UACA;EACE,SAAS,OAAO;EAChB,eAAe,OAAO;EACvB,CACF,CAAC,CACH,GACD;AAEJ,QAAO;EACL,MAAM;EACN,iBAAiB,QAAQ;EACzB,gBAAgB;EAChB;EACA,eAAe,QAAQ;EACxB"}
@@ -1,6 +1,6 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  const require_types = require('./types.cjs');
3
- const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langchain/core/tools"));
3
+ let _langchain_core_tools = require("@langchain/core/tools");
4
4
 
5
5
  //#region src/tools/memory.ts
6
6
  /**
@@ -37,7 +37,7 @@ const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langch
37
37
  * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool
38
38
  */
39
39
  function memory_20250818(options) {
40
- const memoryTool = (0, __langchain_core_tools.tool)(options?.execute, {
40
+ const memoryTool = (0, _langchain_core_tools.tool)(options?.execute, {
41
41
  name: "memory",
42
42
  schema: require_types.Memory20250818CommandSchema
43
43
  });
@@ -1 +1 @@
1
- {"version":3,"file":"memory.cjs","names":["options?: MemoryTool20250818Options","Memory20250818CommandSchema"],"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,8CACJ,SAAS,SAIT;EACE,MAAM;EACN,QAAQC;CACT,EACF;CAED,WAAW,SAAS;EAClB,GAAI,WAAW,UAAU,CAAE;EAC3B,wBAAwB;GACtB,MAAM;GACN,MAAM;EACP;CACF;AAED,QAAO;AAMR"}
1
+ {"version":3,"file":"memory.cjs","names":["Memory20250818CommandSchema"],"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,gBAAgB,SAAqC;CACnE,MAAM,6CACJ,SAAS,SAIT;EACE,MAAM;EACN,QAAQA;EACT,CACF;AAED,YAAW,SAAS;EAClB,GAAI,WAAW,UAAU,EAAE;EAC3B,wBAAwB;GACtB,MAAM;GACN,MAAM;GACP;EACF;AAED,QAAO"}
@@ -1,10 +1,9 @@
1
1
  import { MemoryTool20250818Options } from "./types.cjs";
2
- import * as zod0 from "zod";
2
+ import * as zod from "zod";
3
3
  import * as zod_v4_core0 from "zod/v4/core";
4
4
  import { DynamicStructuredTool } from "@langchain/core/tools";
5
5
 
6
6
  //#region src/tools/memory.d.ts
7
-
8
7
  /**
9
8
  * Creates an Anthropic memory tool that can be used with ChatAnthropic.
10
9
  *
@@ -38,30 +37,30 @@ import { DynamicStructuredTool } from "@langchain/core/tools";
38
37
  *
39
38
  * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool
40
39
  */
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;
40
+ declare function memory_20250818(options?: MemoryTool20250818Options): DynamicStructuredTool<zod.ZodDiscriminatedUnion<[zod.ZodObject<{
41
+ command: zod.ZodLiteral<"view">;
42
+ path: zod.ZodString;
43
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
44
+ command: zod.ZodLiteral<"create">;
45
+ path: zod.ZodString;
46
+ file_text: zod.ZodString;
47
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
48
+ command: zod.ZodLiteral<"str_replace">;
49
+ path: zod.ZodString;
50
+ old_str: zod.ZodString;
51
+ new_str: zod.ZodString;
52
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
53
+ command: zod.ZodLiteral<"insert">;
54
+ path: zod.ZodString;
55
+ insert_line: zod.ZodNumber;
56
+ insert_text: zod.ZodString;
57
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
58
+ command: zod.ZodLiteral<"delete">;
59
+ path: zod.ZodString;
60
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
61
+ command: zod.ZodLiteral<"rename">;
62
+ old_path: zod.ZodString;
63
+ new_path: zod.ZodString;
65
64
  }, zod_v4_core0.$strip>], "command">, {
66
65
  command: "view";
67
66
  path: string;
@@ -1 +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>, 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"}
1
+ {"version":3,"file":"memory.d.cts","names":[],"sources":["../../src/tools/memory.ts"],"mappings":";;;;;;;;;;AA2CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,eAAA,CAAgB,OAAA,GAAU,yBAAA,GAAyB,qBAAA,KAAA,qBAAA,MAAA,SAAA;WAAA,GAAA,CAAA,UAAA;;;WAAA,GAAA,CAAA,UAAA"}
@@ -1,10 +1,9 @@
1
1
  import { MemoryTool20250818Options } from "./types.js";
2
2
  import { DynamicStructuredTool } from "@langchain/core/tools";
3
- import * as zod0 from "zod";
3
+ import * as zod from "zod";
4
4
  import * as zod_v4_core0 from "zod/v4/core";
5
5
 
6
6
  //#region src/tools/memory.d.ts
7
-
8
7
  /**
9
8
  * Creates an Anthropic memory tool that can be used with ChatAnthropic.
10
9
  *
@@ -38,30 +37,30 @@ import * as zod_v4_core0 from "zod/v4/core";
38
37
  *
39
38
  * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool
40
39
  */
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;
40
+ declare function memory_20250818(options?: MemoryTool20250818Options): DynamicStructuredTool<zod.ZodDiscriminatedUnion<[zod.ZodObject<{
41
+ command: zod.ZodLiteral<"view">;
42
+ path: zod.ZodString;
43
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
44
+ command: zod.ZodLiteral<"create">;
45
+ path: zod.ZodString;
46
+ file_text: zod.ZodString;
47
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
48
+ command: zod.ZodLiteral<"str_replace">;
49
+ path: zod.ZodString;
50
+ old_str: zod.ZodString;
51
+ new_str: zod.ZodString;
52
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
53
+ command: zod.ZodLiteral<"insert">;
54
+ path: zod.ZodString;
55
+ insert_line: zod.ZodNumber;
56
+ insert_text: zod.ZodString;
57
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
58
+ command: zod.ZodLiteral<"delete">;
59
+ path: zod.ZodString;
60
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
61
+ command: zod.ZodLiteral<"rename">;
62
+ old_path: zod.ZodString;
63
+ new_path: zod.ZodString;
65
64
  }, zod_v4_core0.$strip>], "command">, {
66
65
  command: "view";
67
66
  path: string;
@@ -1 +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>, 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"}
1
+ {"version":3,"file":"memory.d.ts","names":[],"sources":["../../src/tools/memory.ts"],"mappings":";;;;;;;;;;AA2CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,eAAA,CAAgB,OAAA,GAAU,yBAAA,GAAyB,qBAAA,KAAA,qBAAA,MAAA,SAAA;WAAA,GAAA,CAAA,UAAA;;;WAAA,GAAA,CAAA,UAAA"}
@@ -1 +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"}
1
+ {"version":3,"file":"memory.js","names":[],"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,gBAAgB,SAAqC;CACnE,MAAM,aAAa,KACjB,SAAS,SAIT;EACE,MAAM;EACN,QAAQ;EACT,CACF;AAED,YAAW,SAAS;EAClB,GAAI,WAAW,UAAU,EAAE;EAC3B,wBAAwB;GACtB,MAAM;GACN,MAAM;GACP;EACF;AAED,QAAO"}
@@ -1,6 +1,6 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  const require_types = require('./types.cjs');
3
- const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langchain/core/tools"));
3
+ let _langchain_core_tools = require("@langchain/core/tools");
4
4
 
5
5
  //#region src/tools/textEditor.ts
6
6
  /**
@@ -58,7 +58,7 @@ const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langch
58
58
  */
59
59
  function textEditor_20250728(options) {
60
60
  const name = "str_replace_based_edit_tool";
61
- const textEditorTool = (0, __langchain_core_tools.tool)(options?.execute, {
61
+ const textEditorTool = (0, _langchain_core_tools.tool)(options?.execute, {
62
62
  name,
63
63
  description: "A tool for editing text files",
64
64
  schema: require_types.TextEditor20250728CommandSchema
@@ -1 +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"}
1
+ {"version":3,"file":"textEditor.cjs","names":["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,oBAAoB,SAAqC;CACvE,MAAM,OAAO;CACb,MAAM,iDACJ,SAAS,SAIT;EACE;EACA,aAAa;EACb,QAAQA;EACT,CACF;AAED,gBAAe,SAAS;EACtB,GAAI,eAAe,UAAU,EAAE;EAC/B,wBAAwB;GACtB,MAAM;GACN;GACA,GAAI,SAAS,kBAAkB,UAAa,EAC1C,gBAAgB,QAAQ,eACzB;GACF;EACF;AAED,QAAO"}
@@ -1,6 +1,6 @@
1
1
  import { TextEditor20250728Command } from "./types.cjs";
2
- import * as zod24 from "zod";
3
- import * as zod_v4_core5 from "zod/v4/core";
2
+ import * as zod from "zod";
3
+ import * as zod_v4_core0 from "zod/v4/core";
4
4
  import { DynamicStructuredTool } from "@langchain/core/tools";
5
5
 
6
6
  //#region src/tools/textEditor.d.ts
@@ -72,25 +72,25 @@ interface TextEditor20250728Options {
72
72
  *
73
73
  * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool
74
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">, {
75
+ declare function textEditor_20250728(options?: TextEditor20250728Options): DynamicStructuredTool<zod.ZodDiscriminatedUnion<[zod.ZodObject<{
76
+ command: zod.ZodLiteral<"view">;
77
+ path: zod.ZodString;
78
+ view_range: zod.ZodOptional<zod.ZodTuple<[zod.ZodNumber, zod.ZodNumber], null>>;
79
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
80
+ command: zod.ZodLiteral<"str_replace">;
81
+ path: zod.ZodString;
82
+ old_str: zod.ZodString;
83
+ new_str: zod.ZodString;
84
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
85
+ command: zod.ZodLiteral<"create">;
86
+ path: zod.ZodString;
87
+ file_text: zod.ZodString;
88
+ }, zod_v4_core0.$strip>, zod.ZodObject<{
89
+ command: zod.ZodLiteral<"insert">;
90
+ path: zod.ZodString;
91
+ insert_line: zod.ZodNumber;
92
+ new_str: zod.ZodString;
93
+ }, zod_v4_core0.$strip>], "command">, {
94
94
  command: "view";
95
95
  path: string;
96
96
  view_range?: [number, number] | undefined;
@@ -1 +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>, 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"}
1
+ {"version":3,"file":"textEditor.d.cts","names":[],"sources":["../../src/tools/textEditor.ts"],"mappings":";;;;;;;;;UAYiB,yBAAA;EAAA;;;;EAKf,OAAA,IAAW,IAAA,EAAM,yBAAA,cAAuC,OAAA;EAAvC;;;;EAKjB,aAAA;AAAA;AAwDF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iBAAgB,mBAAA,CAAoB,OAAA,GAAU,yBAAA,GAAyB,qBAAA,KAAA,qBAAA,MAAA,SAAA;WAAA,GAAA,CAAA,UAAA;;;;WAAA,GAAA,CAAA,UAAA"}