@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.
- package/CHANGELOG.md +9 -0
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +11 -7
- package/dist/chat_models.cjs +68 -78
- package/dist/chat_models.cjs.map +1 -1
- package/dist/chat_models.d.cts +0 -1
- package/dist/chat_models.d.cts.map +1 -1
- package/dist/chat_models.d.ts +0 -1
- package/dist/chat_models.d.ts.map +1 -1
- package/dist/chat_models.js +40 -50
- package/dist/chat_models.js.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/output_parsers.cjs +9 -11
- package/dist/output_parsers.cjs.map +1 -1
- package/dist/output_parsers.js +2 -4
- package/dist/output_parsers.js.map +1 -1
- package/dist/profiles.cjs +1 -2
- package/dist/profiles.cjs.map +1 -1
- package/dist/profiles.js +1 -2
- package/dist/profiles.js.map +1 -1
- package/dist/tools/bash.cjs +3 -3
- package/dist/tools/bash.cjs.map +1 -1
- package/dist/tools/bash.d.cts +7 -7
- package/dist/tools/bash.d.cts.map +1 -1
- package/dist/tools/bash.d.ts +7 -7
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/codeExecution.cjs.map +1 -1
- package/dist/tools/codeExecution.d.cts +0 -1
- package/dist/tools/codeExecution.d.cts.map +1 -1
- package/dist/tools/codeExecution.d.ts +0 -1
- package/dist/tools/codeExecution.d.ts.map +1 -1
- package/dist/tools/codeExecution.js.map +1 -1
- package/dist/tools/computer.cjs +4 -4
- package/dist/tools/computer.cjs.map +1 -1
- package/dist/tools/computer.d.cts +101 -101
- package/dist/tools/computer.d.cts.map +1 -1
- package/dist/tools/computer.d.ts +101 -101
- package/dist/tools/computer.d.ts.map +1 -1
- package/dist/tools/computer.js.map +1 -1
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/mcpToolset.cjs.map +1 -1
- package/dist/tools/mcpToolset.d.cts +0 -1
- package/dist/tools/mcpToolset.d.cts.map +1 -1
- package/dist/tools/mcpToolset.d.ts +0 -1
- package/dist/tools/mcpToolset.d.ts.map +1 -1
- package/dist/tools/mcpToolset.js.map +1 -1
- package/dist/tools/memory.cjs +3 -3
- package/dist/tools/memory.cjs.map +1 -1
- package/dist/tools/memory.d.cts +25 -26
- package/dist/tools/memory.d.cts.map +1 -1
- package/dist/tools/memory.d.ts +25 -26
- package/dist/tools/memory.d.ts.map +1 -1
- package/dist/tools/memory.js.map +1 -1
- package/dist/tools/textEditor.cjs +3 -3
- package/dist/tools/textEditor.cjs.map +1 -1
- package/dist/tools/textEditor.d.cts +21 -21
- package/dist/tools/textEditor.d.cts.map +1 -1
- package/dist/tools/textEditor.d.ts +21 -21
- package/dist/tools/textEditor.d.ts.map +1 -1
- package/dist/tools/textEditor.js.map +1 -1
- package/dist/tools/toolSearch.cjs.map +1 -1
- package/dist/tools/toolSearch.d.cts +0 -1
- package/dist/tools/toolSearch.d.cts.map +1 -1
- package/dist/tools/toolSearch.d.ts +0 -1
- package/dist/tools/toolSearch.d.ts.map +1 -1
- package/dist/tools/toolSearch.js.map +1 -1
- package/dist/tools/types.cjs +2 -2
- package/dist/tools/types.cjs.map +1 -1
- package/dist/tools/types.d.cts +0 -1
- package/dist/tools/types.d.cts.map +1 -1
- package/dist/tools/types.d.ts +0 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/tools/webFetch.cjs.map +1 -1
- package/dist/tools/webFetch.d.cts +0 -1
- package/dist/tools/webFetch.d.cts.map +1 -1
- package/dist/tools/webFetch.d.ts +0 -1
- package/dist/tools/webFetch.d.ts.map +1 -1
- package/dist/tools/webFetch.js.map +1 -1
- package/dist/tools/webSearch.cjs.map +1 -1
- package/dist/tools/webSearch.d.cts +0 -1
- package/dist/tools/webSearch.d.cts.map +1 -1
- package/dist/tools/webSearch.d.ts +0 -1
- package/dist/tools/webSearch.d.ts.map +1 -1
- package/dist/tools/webSearch.js.map +1 -1
- package/dist/types.d.cts +0 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/content.cjs +3 -3
- package/dist/utils/content.cjs.map +1 -1
- package/dist/utils/content.js.map +1 -1
- package/dist/utils/errors.cjs +4 -1
- package/dist/utils/errors.cjs.map +1 -1
- package/dist/utils/errors.js +4 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/message_inputs.cjs +79 -100
- package/dist/utils/message_inputs.cjs.map +1 -1
- package/dist/utils/message_inputs.js +73 -94
- package/dist/utils/message_inputs.js.map +1 -1
- package/dist/utils/message_outputs.cjs +28 -32
- package/dist/utils/message_outputs.cjs.map +1 -1
- package/dist/utils/message_outputs.js +13 -17
- package/dist/utils/message_outputs.js.map +1 -1
- package/dist/utils/prompts.cjs +1 -2
- package/dist/utils/prompts.cjs.map +1 -1
- package/dist/utils/prompts.d.cts +0 -1
- package/dist/utils/prompts.d.cts.map +1 -1
- package/dist/utils/prompts.d.ts +0 -1
- package/dist/utils/prompts.d.ts.map +1 -1
- package/dist/utils/prompts.js +1 -2
- package/dist/utils/prompts.js.map +1 -1
- package/dist/utils/standard.cjs +2 -4
- package/dist/utils/standard.cjs.map +1 -1
- package/dist/utils/standard.js +2 -4
- package/dist/utils/standard.js.map +1 -1
- package/dist/utils/tools.cjs +4 -3
- package/dist/utils/tools.cjs.map +1 -1
- package/dist/utils/tools.js +1 -1
- package/dist/utils/tools.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computer.js","names":[
|
|
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"}
|
package/dist/tools/index.cjs.map
CHANGED
|
@@ -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;
|
|
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":[
|
|
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":[
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/tools/index.ts"],"mappings":";;;;;;;;;;;;cA6Ba,KAAA"}
|
package/dist/tools/index.js.map
CHANGED
|
@@ -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;
|
|
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":[
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpToolset.d.cts","names":[
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpToolset.d.ts","names":[
|
|
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":[
|
|
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"}
|
package/dist/tools/memory.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
2
|
const require_types = require('./types.cjs');
|
|
3
|
-
|
|
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,
|
|
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":["
|
|
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"}
|
package/dist/tools/memory.d.cts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { MemoryTool20250818Options } from "./types.cjs";
|
|
2
|
-
import * as
|
|
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<
|
|
42
|
-
command:
|
|
43
|
-
path:
|
|
44
|
-
}, zod_v4_core0.$strip>,
|
|
45
|
-
command:
|
|
46
|
-
path:
|
|
47
|
-
file_text:
|
|
48
|
-
}, zod_v4_core0.$strip>,
|
|
49
|
-
command:
|
|
50
|
-
path:
|
|
51
|
-
old_str:
|
|
52
|
-
new_str:
|
|
53
|
-
}, zod_v4_core0.$strip>,
|
|
54
|
-
command:
|
|
55
|
-
path:
|
|
56
|
-
insert_line:
|
|
57
|
-
insert_text:
|
|
58
|
-
}, zod_v4_core0.$strip>,
|
|
59
|
-
command:
|
|
60
|
-
path:
|
|
61
|
-
}, zod_v4_core0.$strip>,
|
|
62
|
-
command:
|
|
63
|
-
old_path:
|
|
64
|
-
new_path:
|
|
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":[
|
|
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"}
|
package/dist/tools/memory.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { MemoryTool20250818Options } from "./types.js";
|
|
2
2
|
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
3
|
-
import * as
|
|
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<
|
|
42
|
-
command:
|
|
43
|
-
path:
|
|
44
|
-
}, zod_v4_core0.$strip>,
|
|
45
|
-
command:
|
|
46
|
-
path:
|
|
47
|
-
file_text:
|
|
48
|
-
}, zod_v4_core0.$strip>,
|
|
49
|
-
command:
|
|
50
|
-
path:
|
|
51
|
-
old_str:
|
|
52
|
-
new_str:
|
|
53
|
-
}, zod_v4_core0.$strip>,
|
|
54
|
-
command:
|
|
55
|
-
path:
|
|
56
|
-
insert_line:
|
|
57
|
-
insert_text:
|
|
58
|
-
}, zod_v4_core0.$strip>,
|
|
59
|
-
command:
|
|
60
|
-
path:
|
|
61
|
-
}, zod_v4_core0.$strip>,
|
|
62
|
-
command:
|
|
63
|
-
old_path:
|
|
64
|
-
new_path:
|
|
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":[
|
|
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"}
|
package/dist/tools/memory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","names":[
|
|
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
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
2
|
const require_types = require('./types.cjs');
|
|
3
|
-
|
|
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,
|
|
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":["
|
|
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
|
|
3
|
-
import * as
|
|
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<
|
|
76
|
-
command:
|
|
77
|
-
path:
|
|
78
|
-
view_range:
|
|
79
|
-
},
|
|
80
|
-
command:
|
|
81
|
-
path:
|
|
82
|
-
old_str:
|
|
83
|
-
new_str:
|
|
84
|
-
},
|
|
85
|
-
command:
|
|
86
|
-
path:
|
|
87
|
-
file_text:
|
|
88
|
-
},
|
|
89
|
-
command:
|
|
90
|
-
path:
|
|
91
|
-
insert_line:
|
|
92
|
-
new_str:
|
|
93
|
-
},
|
|
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":[
|
|
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"}
|