UNPKG

@langchain/anthropic

Version:
1 lines 3.1 kB
{"version":3,"file":"codeExecution.d.ts","names":["Anthropic","ServerTool","CodeExecution20250825Options","Beta","BetaCacheControlEphemeral","codeExecution_20250825"],"sources":["../../src/tools/codeExecution.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n/**\n * Options for the code execution tool.\n */\nexport interface CodeExecution20250825Options {\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n}\n/**\n * Creates a code execution tool that allows Claude to run Bash commands and manipulate files\n * in a secure, sandboxed environment. Claude can analyze data, create visualizations,\n * perform calculations, and process files.\n *\n * When this tool is provided, Claude automatically gains access to:\n * - **Bash commands**: Execute shell commands for system operations\n * - **File operations**: Create, view, and edit files directly\n *\n * @note This tool requires the beta header `code-execution-2025-08-25` in API requests.\n *\n * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/code-execution-tool | Anthropic Code Execution Documentation}\n * @param options - Configuration options for the code execution tool\n * @returns A code execution tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - calculations and data analysis\n * const response = await model.invoke(\n * \"Calculate the mean and standard deviation of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\",\n * { tools: [tools.codeExecution_20250825()] }\n * );\n *\n * // File operations and visualization\n * const response2 = await model.invoke(\n * \"Create a matplotlib visualization of sales data and save it as chart.png\",\n * { tools: [tools.codeExecution_20250825()] }\n * );\n * ```\n *\n * @example Container reuse\n * ```typescript\n * // First request - creates a container\n * const response1 = await model.invoke(\n * \"Write a random number to /tmp/number.txt\",\n * { tools: [tools.codeExecution_20250825()] }\n * );\n *\n * // Extract container ID from response for reuse\n * const containerId = response1.response_metadata?.container?.id;\n *\n * // Second request - reuse container to access the file\n * const response2 = await model.invoke(\n * \"Read /tmp/number.txt and calculate its square\",\n * {\n * tools: [tools.codeExecution_20250825()],\n * // Pass container ID to reuse the same environment\n * }\n * );\n * ```\n */\nexport declare function codeExecution_20250825(options?: CodeExecution20250825Options): ServerTool;\n//# sourceMappingURL=codeExecution.d.ts.map"],"mappings":";;;;;;;AAKA;AA+DwBK,UA/DPH,4BAAAA,CA+DwCA;;;;iBA3DtCF,SAAAA,CAAUG,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2DVC,sBAAAA,WAAiCH,+BAA+BD"}