{"version":3,"file":"webFetch.cjs","names":[],"sources":["../../src/tools/webFetch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web fetch tool.\n */\nexport interface WebFetch20250910Options {\n  /**\n   * Maximum number of times the tool can be used in the API request.\n   */\n  maxUses?: number;\n  /**\n   * If provided, only these domains will be fetched. Cannot be used\n   * alongside `blockedDomains`.\n   */\n  allowedDomains?: string[];\n  /**\n   * If provided, these domains will never be fetched. Cannot be used\n   * alongside `allowedDomains`.\n   */\n  blockedDomains?: string[];\n  /**\n   * Create a cache control breakpoint at this content block.\n   */\n  cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n  /**\n   * Enable citations for fetched content. Unlike web search where citations\n   * are always enabled, citations are optional for web fetch.\n   */\n  citations?: {\n    enabled: boolean;\n  };\n  /**\n   * Maximum content length in tokens. If the fetched content exceeds this limit,\n   * it will be truncated. This helps control token usage when fetching large documents.\n   */\n  maxContentTokens?: number;\n}\n\n/**\n * Creates a web fetch tool that allows Claude to retrieve full content from specified\n * web pages and PDF documents. Claude can only fetch URLs that have been explicitly\n * provided by the user or that come from previous web search or web fetch results.\n *\n * @warning Enabling the web fetch tool in environments where Claude processes untrusted\n * input alongside sensitive data poses data exfiltration risks. We recommend only using\n * this tool in trusted environments or when handling non-sensitive data.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}\n * @param options - Configuration options for the web fetch tool\n * @returns A web fetch tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n *   model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - fetch content from a URL\n * const response = await model.invoke(\n *   \"Please analyze the content at https://example.com/article\",\n *   { tools: [tools.webFetch_20250910()] }\n * );\n *\n * // With options\n * const responseWithOptions = await model.invoke(\n *   \"Summarize this research paper: https://arxiv.org/abs/2024.12345\",\n *   {\n *     tools: [tools.webFetch_20250910({\n *       maxUses: 5,\n *       allowedDomains: [\"arxiv.org\", \"example.com\"],\n *       citations: { enabled: true },\n *       maxContentTokens: 50000,\n *     })],\n *   }\n * );\n *\n * // Combined with web search for comprehensive information gathering\n * const combinedResponse = await model.invoke(\n *   \"Find recent articles about quantum computing and analyze the most relevant one\",\n *   {\n *     tools: [\n *       tools.webSearch_20250305({ maxUses: 3 }),\n *       tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),\n *     ],\n *   }\n * );\n * ```\n */\nexport function webFetch_20250910(\n  options?: WebFetch20250910Options\n): ServerTool {\n  return {\n    type: \"web_fetch_20250910\",\n    name: \"web_fetch\",\n    max_uses: options?.maxUses,\n    allowed_domains: options?.allowedDomains,\n    blocked_domains: options?.blockedDomains,\n    cache_control: options?.cacheControl,\n    citations: options?.citations,\n    max_content_tokens: options?.maxContentTokens,\n  } satisfies Anthropic.Beta.BetaWebFetchTool20250910;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,SAAgB,kBACd,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,WAAW,SAAS;EACpB,oBAAoB,SAAS;EAC9B"}