@langchain/anthropic 1.3.23 → 1.3.24-dev-1773698445534

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 (122) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +7 -13
  2. package/dist/chat_models.cjs +13 -13
  3. package/dist/chat_models.cjs.map +1 -1
  4. package/dist/chat_models.d.cts +25 -25
  5. package/dist/chat_models.d.cts.map +1 -1
  6. package/dist/chat_models.d.ts +25 -25
  7. package/dist/chat_models.d.ts.map +1 -1
  8. package/dist/chat_models.js +8 -8
  9. package/dist/chat_models.js.map +1 -1
  10. package/dist/index.cjs +5 -6
  11. package/dist/index.js +1 -2
  12. package/dist/output_parsers.cjs +2 -3
  13. package/dist/output_parsers.cjs.map +1 -1
  14. package/dist/output_parsers.js +1 -2
  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 -1
  19. package/dist/tools/bash.cjs +3 -4
  20. package/dist/tools/bash.cjs.map +1 -1
  21. package/dist/tools/bash.js +1 -2
  22. package/dist/tools/bash.js.map +1 -1
  23. package/dist/tools/codeExecution.cjs +1 -2
  24. package/dist/tools/codeExecution.cjs.map +1 -1
  25. package/dist/tools/codeExecution.d.cts +2 -2
  26. package/dist/tools/codeExecution.d.cts.map +1 -1
  27. package/dist/tools/codeExecution.d.ts +2 -2
  28. package/dist/tools/codeExecution.d.ts.map +1 -1
  29. package/dist/tools/codeExecution.js +1 -1
  30. package/dist/tools/computer.cjs +3 -4
  31. package/dist/tools/computer.cjs.map +1 -1
  32. package/dist/tools/computer.js +1 -2
  33. package/dist/tools/computer.js.map +1 -1
  34. package/dist/tools/index.cjs +10 -11
  35. package/dist/tools/index.cjs.map +1 -1
  36. package/dist/tools/index.js +1 -2
  37. package/dist/tools/index.js.map +1 -1
  38. package/dist/tools/mcpToolset.cjs +1 -2
  39. package/dist/tools/mcpToolset.cjs.map +1 -1
  40. package/dist/tools/mcpToolset.d.cts +2 -2
  41. package/dist/tools/mcpToolset.d.cts.map +1 -1
  42. package/dist/tools/mcpToolset.d.ts +2 -2
  43. package/dist/tools/mcpToolset.d.ts.map +1 -1
  44. package/dist/tools/mcpToolset.js +1 -1
  45. package/dist/tools/mcpToolset.js.map +1 -1
  46. package/dist/tools/memory.cjs +3 -4
  47. package/dist/tools/memory.cjs.map +1 -1
  48. package/dist/tools/memory.js +1 -2
  49. package/dist/tools/memory.js.map +1 -1
  50. package/dist/tools/textEditor.cjs +3 -4
  51. package/dist/tools/textEditor.cjs.map +1 -1
  52. package/dist/tools/textEditor.js +1 -2
  53. package/dist/tools/textEditor.js.map +1 -1
  54. package/dist/tools/toolSearch.cjs +1 -2
  55. package/dist/tools/toolSearch.cjs.map +1 -1
  56. package/dist/tools/toolSearch.d.cts +2 -2
  57. package/dist/tools/toolSearch.d.cts.map +1 -1
  58. package/dist/tools/toolSearch.d.ts +2 -2
  59. package/dist/tools/toolSearch.d.ts.map +1 -1
  60. package/dist/tools/toolSearch.js +1 -1
  61. package/dist/tools/types.cjs +2 -3
  62. package/dist/tools/types.cjs.map +1 -1
  63. package/dist/tools/types.d.cts +2 -2
  64. package/dist/tools/types.d.cts.map +1 -1
  65. package/dist/tools/types.d.ts +2 -2
  66. package/dist/tools/types.d.ts.map +1 -1
  67. package/dist/tools/types.js +1 -2
  68. package/dist/tools/types.js.map +1 -1
  69. package/dist/tools/webFetch.cjs +1 -2
  70. package/dist/tools/webFetch.cjs.map +1 -1
  71. package/dist/tools/webFetch.d.cts +2 -2
  72. package/dist/tools/webFetch.d.cts.map +1 -1
  73. package/dist/tools/webFetch.d.ts +2 -2
  74. package/dist/tools/webFetch.d.ts.map +1 -1
  75. package/dist/tools/webFetch.js +1 -1
  76. package/dist/tools/webSearch.cjs +1 -2
  77. package/dist/tools/webSearch.cjs.map +1 -1
  78. package/dist/tools/webSearch.d.cts +3 -3
  79. package/dist/tools/webSearch.d.cts.map +1 -1
  80. package/dist/tools/webSearch.d.ts +3 -3
  81. package/dist/tools/webSearch.d.ts.map +1 -1
  82. package/dist/tools/webSearch.js +1 -1
  83. package/dist/types.d.cts +24 -24
  84. package/dist/types.d.cts.map +1 -1
  85. package/dist/types.d.ts +24 -24
  86. package/dist/types.d.ts.map +1 -1
  87. package/dist/utils/content.cjs +2 -3
  88. package/dist/utils/content.cjs.map +1 -1
  89. package/dist/utils/content.js +1 -2
  90. package/dist/utils/content.js.map +1 -1
  91. package/dist/utils/errors.cjs +3 -4
  92. package/dist/utils/errors.cjs.map +1 -1
  93. package/dist/utils/errors.js +2 -3
  94. package/dist/utils/errors.js.map +1 -1
  95. package/dist/utils/index.cjs +1 -2
  96. package/dist/utils/index.cjs.map +1 -1
  97. package/dist/utils/index.js +1 -1
  98. package/dist/utils/message_inputs.cjs +4 -5
  99. package/dist/utils/message_inputs.cjs.map +1 -1
  100. package/dist/utils/message_inputs.js +1 -2
  101. package/dist/utils/message_inputs.js.map +1 -1
  102. package/dist/utils/message_outputs.cjs +4 -5
  103. package/dist/utils/message_outputs.cjs.map +1 -1
  104. package/dist/utils/message_outputs.js +1 -2
  105. package/dist/utils/message_outputs.js.map +1 -1
  106. package/dist/utils/prompts.cjs +2 -3
  107. package/dist/utils/prompts.cjs.map +1 -1
  108. package/dist/utils/prompts.d.cts +2 -2
  109. package/dist/utils/prompts.d.cts.map +1 -1
  110. package/dist/utils/prompts.d.ts +2 -2
  111. package/dist/utils/prompts.d.ts.map +1 -1
  112. package/dist/utils/prompts.js +1 -2
  113. package/dist/utils/prompts.js.map +1 -1
  114. package/dist/utils/standard.cjs +2 -3
  115. package/dist/utils/standard.cjs.map +1 -1
  116. package/dist/utils/standard.js +1 -2
  117. package/dist/utils/standard.js.map +1 -1
  118. package/dist/utils/tools.cjs +2 -3
  119. package/dist/utils/tools.cjs.map +1 -1
  120. package/dist/utils/tools.js +1 -2
  121. package/dist/utils/tools.js.map +1 -1
  122. package/package.json +3 -3
@@ -1 +1 @@
1
- {"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"}
1
+ {"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"}
@@ -1,4 +1,4 @@
1
- import Anthropic from "@anthropic-ai/sdk";
1
+ import Anthropic$1 from "@anthropic-ai/sdk";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/webFetch.d.ts
@@ -23,7 +23,7 @@ interface WebFetch20250910Options {
23
23
  /**
24
24
  * Create a cache control breakpoint at this content block.
25
25
  */
26
- cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;
26
+ cacheControl?: Anthropic$1.Beta.BetaCacheControlEphemeral;
27
27
  /**
28
28
  * Enable citations for fetched content. Unlike web search where citations
29
29
  * are always enabled, citations are optional for web fetch.
@@ -1 +1 @@
1
- {"version":3,"file":"webFetch.d.cts","names":[],"sources":["../../src/tools/webFetch.ts"],"mappings":";;;;;;AAMA;UAAiB,uBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAuEc;;;EAnEd,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA;EAoEpB;;;;EA/DV,SAAA;IACE,OAAA;EAAA;;;;;EAMF,gBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuDc,iBAAA,CACd,OAAA,GAAU,uBAAA,GACT,UAAA"}
1
+ {"version":3,"file":"webFetch.d.cts","names":[],"sources":["../../src/tools/webFetch.ts"],"mappings":";;;;;;AAMA;UAAiB,uBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAuEc;;;EAnEd,YAAA,GAAe,WAAA,CAAU,IAAA,CAAK,yBAAA;EAoEpB;;;;EA/DV,SAAA;IACE,OAAA;EAAA;;;;;EAMF,gBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuDc,iBAAA,CACd,OAAA,GAAU,uBAAA,GACT,UAAA"}
@@ -1,4 +1,4 @@
1
- import Anthropic from "@anthropic-ai/sdk";
1
+ import Anthropic$1 from "@anthropic-ai/sdk";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/webFetch.d.ts
@@ -23,7 +23,7 @@ interface WebFetch20250910Options {
23
23
  /**
24
24
  * Create a cache control breakpoint at this content block.
25
25
  */
26
- cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;
26
+ cacheControl?: Anthropic$1.Beta.BetaCacheControlEphemeral;
27
27
  /**
28
28
  * Enable citations for fetched content. Unlike web search where citations
29
29
  * are always enabled, citations are optional for web fetch.
@@ -1 +1 @@
1
- {"version":3,"file":"webFetch.d.ts","names":[],"sources":["../../src/tools/webFetch.ts"],"mappings":";;;;;;AAMA;UAAiB,uBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAuEc;;;EAnEd,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA;EAoEpB;;;;EA/DV,SAAA;IACE,OAAA;EAAA;;;;;EAMF,gBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuDc,iBAAA,CACd,OAAA,GAAU,uBAAA,GACT,UAAA"}
1
+ {"version":3,"file":"webFetch.d.ts","names":[],"sources":["../../src/tools/webFetch.ts"],"mappings":";;;;;;AAMA;UAAiB,uBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAuEc;;;EAnEd,YAAA,GAAe,WAAA,CAAU,IAAA,CAAK,yBAAA;EAoEpB;;;;EA/DV,SAAA;IACE,OAAA;EAAA;;;;;EAMF,gBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuDc,iBAAA,CACd,OAAA,GAAU,uBAAA,GACT,UAAA"}
@@ -63,7 +63,7 @@ function webFetch_20250910(options) {
63
63
  max_content_tokens: options?.maxContentTokens
64
64
  };
65
65
  }
66
-
67
66
  //#endregion
68
67
  export { webFetch_20250910 };
68
+
69
69
  //# sourceMappingURL=webFetch.js.map
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/tools/webSearch.ts
3
2
  /**
4
3
  * Creates a web search tool that gives Claude direct access to real-time web content,
@@ -51,7 +50,7 @@ function webSearch_20250305(options) {
51
50
  user_location: options?.userLocation
52
51
  };
53
52
  }
54
-
55
53
  //#endregion
56
54
  exports.webSearch_20250305 = webSearch_20250305;
55
+
57
56
  //# sourceMappingURL=webSearch.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.cjs","names":[],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web search tool.\n */\nexport interface WebSearch20250305Options {\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 included in results. Cannot be used\n * alongside `blocked_domains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never appear in results. Cannot be used\n * alongside `allowed_domains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Parameters for the user's location. Used to provide more relevant search\n * results.\n */\n userLocation?: Anthropic.Beta.BetaWebSearchTool20250305.UserLocation;\n /**\n * If true, tool will not be included in initial system prompt. Only loaded when\n * returned via tool_reference from tool search.\n */\n deferLoading?: boolean;\n /**\n * If true, tool will only return results from the allowed domains.\n */\n strict?: boolean;\n}\n\n/**\n * Creates a web search tool that gives Claude direct access to real-time web content,\n * allowing it to answer questions with up-to-date information beyond its knowledge cutoff.\n * Claude automatically cites sources from search results as part of its answer.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool | Anthropic Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search 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\n * const response = await model.invoke(\"What is the weather in NYC?\", {\n * tools: [tools.webSearch_20250305()],\n * });\n *\n * // With options\n * const responseWithOptions = await model.invoke(\"Latest news about AI?\", {\n * tools: [tools.webSearch_20250305({\n * maxUses: 5,\n * allowedDomains: [\"reuters.com\", \"bbc.com\"],\n * userLocation: {\n * type: \"approximate\",\n * city: \"San Francisco\",\n * region: \"California\",\n * country: \"US\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n * ```\n */\nexport function webSearch_20250305(\n options?: WebSearch20250305Options\n): ServerTool {\n return {\n type: \"web_search_20250305\",\n name: \"web_search\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n defer_loading: options?.deferLoading,\n strict: options?.strict,\n user_location: options?.userLocation,\n } satisfies Anthropic.Beta.BetaWebSearchTool20250305;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,mBACd,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,eAAe,SAAS;EACxB,QAAQ,SAAS;EACjB,eAAe,SAAS;EACzB"}
1
+ {"version":3,"file":"webSearch.cjs","names":[],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web search tool.\n */\nexport interface WebSearch20250305Options {\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 included in results. Cannot be used\n * alongside `blocked_domains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never appear in results. Cannot be used\n * alongside `allowed_domains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Parameters for the user's location. Used to provide more relevant search\n * results.\n */\n userLocation?: Anthropic.Beta.BetaWebSearchTool20250305.UserLocation;\n /**\n * If true, tool will not be included in initial system prompt. Only loaded when\n * returned via tool_reference from tool search.\n */\n deferLoading?: boolean;\n /**\n * If true, tool will only return results from the allowed domains.\n */\n strict?: boolean;\n}\n\n/**\n * Creates a web search tool that gives Claude direct access to real-time web content,\n * allowing it to answer questions with up-to-date information beyond its knowledge cutoff.\n * Claude automatically cites sources from search results as part of its answer.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool | Anthropic Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search 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\n * const response = await model.invoke(\"What is the weather in NYC?\", {\n * tools: [tools.webSearch_20250305()],\n * });\n *\n * // With options\n * const responseWithOptions = await model.invoke(\"Latest news about AI?\", {\n * tools: [tools.webSearch_20250305({\n * maxUses: 5,\n * allowedDomains: [\"reuters.com\", \"bbc.com\"],\n * userLocation: {\n * type: \"approximate\",\n * city: \"San Francisco\",\n * region: \"California\",\n * country: \"US\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n * ```\n */\nexport function webSearch_20250305(\n options?: WebSearch20250305Options\n): ServerTool {\n return {\n type: \"web_search_20250305\",\n name: \"web_search\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n defer_loading: options?.deferLoading,\n strict: options?.strict,\n user_location: options?.userLocation,\n } satisfies Anthropic.Beta.BetaWebSearchTool20250305;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,mBACd,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,eAAe,SAAS;EACxB,QAAQ,SAAS;EACjB,eAAe,SAAS;EACzB"}
@@ -1,4 +1,4 @@
1
- import Anthropic from "@anthropic-ai/sdk";
1
+ import Anthropic$1 from "@anthropic-ai/sdk";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/webSearch.d.ts
@@ -23,12 +23,12 @@ interface WebSearch20250305Options {
23
23
  /**
24
24
  * Create a cache control breakpoint at this content block.
25
25
  */
26
- cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;
26
+ cacheControl?: Anthropic$1.Beta.BetaCacheControlEphemeral;
27
27
  /**
28
28
  * Parameters for the user's location. Used to provide more relevant search
29
29
  * results.
30
30
  */
31
- userLocation?: Anthropic.Beta.BetaWebSearchTool20250305.UserLocation;
31
+ userLocation?: Anthropic$1.Beta.BetaWebSearchTool20250305.UserLocation;
32
32
  /**
33
33
  * If true, tool will not be included in initial system prompt. Only loaded when
34
34
  * returned via tool_reference from tool search.
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.d.cts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,wBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAcA;;;EAVA,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA;EAuDhB;;;;EAlDd,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA,CAA0B,YAAA;EAmDxD;;;;EA9CA,YAAA;;;;EAIA,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCc,kBAAA,CACd,OAAA,GAAU,wBAAA,GACT,UAAA"}
1
+ {"version":3,"file":"webSearch.d.cts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,wBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAcA;;;EAVA,YAAA,GAAe,WAAA,CAAU,IAAA,CAAK,yBAAA;EAuDhB;;;;EAlDd,YAAA,GAAe,WAAA,CAAU,IAAA,CAAK,yBAAA,CAA0B,YAAA;EAmDxD;;;;EA9CA,YAAA;;;;EAIA,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCc,kBAAA,CACd,OAAA,GAAU,wBAAA,GACT,UAAA"}
@@ -1,4 +1,4 @@
1
- import Anthropic from "@anthropic-ai/sdk";
1
+ import Anthropic$1 from "@anthropic-ai/sdk";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/webSearch.d.ts
@@ -23,12 +23,12 @@ interface WebSearch20250305Options {
23
23
  /**
24
24
  * Create a cache control breakpoint at this content block.
25
25
  */
26
- cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;
26
+ cacheControl?: Anthropic$1.Beta.BetaCacheControlEphemeral;
27
27
  /**
28
28
  * Parameters for the user's location. Used to provide more relevant search
29
29
  * results.
30
30
  */
31
- userLocation?: Anthropic.Beta.BetaWebSearchTool20250305.UserLocation;
31
+ userLocation?: Anthropic$1.Beta.BetaWebSearchTool20250305.UserLocation;
32
32
  /**
33
33
  * If true, tool will not be included in initial system prompt. Only loaded when
34
34
  * returned via tool_reference from tool search.
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.d.ts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,wBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAcA;;;EAVA,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA;EAuDhB;;;;EAlDd,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA,CAA0B,YAAA;EAmDxD;;;;EA9CA,YAAA;;;;EAIA,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCc,kBAAA,CACd,OAAA,GAAU,wBAAA,GACT,UAAA"}
1
+ {"version":3,"file":"webSearch.d.ts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,wBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAcA;;;EAVA,YAAA,GAAe,WAAA,CAAU,IAAA,CAAK,yBAAA;EAuDhB;;;;EAlDd,YAAA,GAAe,WAAA,CAAU,IAAA,CAAK,yBAAA,CAA0B,YAAA;EAmDxD;;;;EA9CA,YAAA;;;;EAIA,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCc,kBAAA,CACd,OAAA,GAAU,wBAAA,GACT,UAAA"}
@@ -50,7 +50,7 @@ function webSearch_20250305(options) {
50
50
  user_location: options?.userLocation
51
51
  };
52
52
  }
53
-
54
53
  //#endregion
55
54
  export { webSearch_20250305 };
55
+
56
56
  //# sourceMappingURL=webSearch.js.map
package/dist/types.d.cts CHANGED
@@ -1,34 +1,34 @@
1
- import Anthropic from "@anthropic-ai/sdk";
1
+ import Anthropic$1 from "@anthropic-ai/sdk";
2
2
  import { BindToolsInput } from "@langchain/core/language_models/chat_models";
3
3
 
4
4
  //#region src/types.d.ts
5
- type AnthropicMessageCreateParams = Anthropic.MessageCreateParamsNonStreaming;
6
- type AnthropicStreamingMessageCreateParams = Anthropic.MessageCreateParamsStreaming;
7
- type AnthropicThinkingConfigParam = Anthropic.ThinkingConfigParam;
8
- type AnthropicContextManagementConfigParam = Anthropic.Beta.BetaContextManagementConfig;
9
- type AnthropicMessageStreamEvent = Anthropic.MessageStreamEvent;
10
- type AnthropicRequestOptions = Anthropic.RequestOptions;
5
+ type AnthropicMessageCreateParams = Anthropic$1.MessageCreateParamsNonStreaming;
6
+ type AnthropicStreamingMessageCreateParams = Anthropic$1.MessageCreateParamsStreaming;
7
+ type AnthropicThinkingConfigParam = Anthropic$1.ThinkingConfigParam;
8
+ type AnthropicContextManagementConfigParam = Anthropic$1.Beta.BetaContextManagementConfig;
9
+ type AnthropicMessageStreamEvent = Anthropic$1.MessageStreamEvent;
10
+ type AnthropicRequestOptions = Anthropic$1.RequestOptions;
11
11
  type AnthropicToolChoice = {
12
12
  type: "tool";
13
13
  name: string;
14
14
  } | "any" | "auto" | "none" | string;
15
- type ChatAnthropicToolType = Anthropic.Messages.Tool | BindToolsInput;
16
- type ChatAnthropicOutputFormat = Anthropic.Messages.JSONOutputFormat;
17
- type AnthropicOutputConfig = Anthropic.Messages.OutputConfig;
18
- type AnthropicTextBlockParam = Anthropic.Messages.TextBlockParam;
19
- type AnthropicImageBlockParam = Anthropic.Messages.ImageBlockParam;
20
- type AnthropicToolUseBlockParam = Anthropic.Messages.ToolUseBlockParam;
21
- type AnthropicToolResultBlockParam = Anthropic.Messages.ToolResultBlockParam;
22
- type AnthropicDocumentBlockParam = Anthropic.Messages.DocumentBlockParam;
23
- type AnthropicThinkingBlockParam = Anthropic.Messages.ThinkingBlockParam;
24
- type AnthropicRedactedThinkingBlockParam = Anthropic.Messages.RedactedThinkingBlockParam;
25
- type AnthropicServerToolUseBlockParam = Anthropic.Messages.ServerToolUseBlockParam;
26
- type AnthropicWebSearchToolResultBlockParam = Anthropic.Messages.WebSearchToolResultBlockParam;
27
- type AnthropicWebSearchResultBlockParam = Anthropic.Messages.WebSearchResultBlockParam;
28
- type AnthropicSearchResultBlockParam = Anthropic.SearchResultBlockParam;
29
- type AnthropicContainerUploadBlockParam = Anthropic.Beta.BetaContainerUploadBlockParam;
30
- type AnthropicCompactionBlockParam = Anthropic.Beta.BetaCompactionBlockParam;
31
- type AnthropicMCPServerURLDefinition = Anthropic.Beta.Messages.BetaRequestMCPServerURLDefinition;
15
+ type ChatAnthropicToolType = Anthropic$1.Messages.Tool | BindToolsInput;
16
+ type ChatAnthropicOutputFormat = Anthropic$1.Messages.JSONOutputFormat;
17
+ type AnthropicOutputConfig = Anthropic$1.Messages.OutputConfig;
18
+ type AnthropicTextBlockParam = Anthropic$1.Messages.TextBlockParam;
19
+ type AnthropicImageBlockParam = Anthropic$1.Messages.ImageBlockParam;
20
+ type AnthropicToolUseBlockParam = Anthropic$1.Messages.ToolUseBlockParam;
21
+ type AnthropicToolResultBlockParam = Anthropic$1.Messages.ToolResultBlockParam;
22
+ type AnthropicDocumentBlockParam = Anthropic$1.Messages.DocumentBlockParam;
23
+ type AnthropicThinkingBlockParam = Anthropic$1.Messages.ThinkingBlockParam;
24
+ type AnthropicRedactedThinkingBlockParam = Anthropic$1.Messages.RedactedThinkingBlockParam;
25
+ type AnthropicServerToolUseBlockParam = Anthropic$1.Messages.ServerToolUseBlockParam;
26
+ type AnthropicWebSearchToolResultBlockParam = Anthropic$1.Messages.WebSearchToolResultBlockParam;
27
+ type AnthropicWebSearchResultBlockParam = Anthropic$1.Messages.WebSearchResultBlockParam;
28
+ type AnthropicSearchResultBlockParam = Anthropic$1.SearchResultBlockParam;
29
+ type AnthropicContainerUploadBlockParam = Anthropic$1.Beta.BetaContainerUploadBlockParam;
30
+ type AnthropicCompactionBlockParam = Anthropic$1.Beta.BetaCompactionBlockParam;
31
+ type AnthropicMCPServerURLDefinition = Anthropic$1.Beta.Messages.BetaRequestMCPServerURLDefinition;
32
32
  type ChatAnthropicContentBlock = AnthropicTextBlockParam | AnthropicImageBlockParam | AnthropicToolUseBlockParam | AnthropicToolResultBlockParam | AnthropicDocumentBlockParam | AnthropicThinkingBlockParam | AnthropicRedactedThinkingBlockParam | AnthropicServerToolUseBlockParam | AnthropicWebSearchToolResultBlockParam | AnthropicWebSearchResultBlockParam | AnthropicSearchResultBlockParam | AnthropicContainerUploadBlockParam | AnthropicCompactionBlockParam;
33
33
  /**
34
34
  * A type representing additional parameters that can be passed to the
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;;KAcY,4BAAA,GACV,SAAA,CAAU,+BAAA;AAAA,KACA,qCAAA,GACV,SAAA,CAAU,4BAAA;AAAA,KACA,4BAAA,GAA+B,SAAA,CAAU,mBAAA;AAAA,KACzC,qCAAA,GACV,SAAA,CAAU,IAAA,CAAK,2BAAA;AAAA,KACL,2BAAA,GAA8B,SAAA,CAAU,kBAAA;AAAA,KACxC,uBAAA,GAA0B,SAAA,CAAU,cAAA;AAAA,KACpC,mBAAA;EAEN,IAAA;EACA,IAAA;AAAA;AAAA,KAMM,qBAAA,GAAwB,SAAA,CAAU,QAAA,CAAS,IAAA,GAAO,cAAA;AAAA,KAClD,yBAAA,GAA4B,SAAA,CAAU,QAAA,CAAS,gBAAA;AAAA,KAC/C,qBAAA,GAAwB,SAAA,CAAU,QAAA,CAAS,YAAA;AAAA,KAE3C,uBAAA,GAA0B,SAAA,CAAU,QAAA,CAAS,cAAA;AAAA,KAC7C,wBAAA,GAA2B,SAAA,CAAU,QAAA,CAAS,eAAA;AAAA,KAC9C,0BAAA,GAA6B,SAAA,CAAU,QAAA,CAAS,iBA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ET,yBAAA,GAA4B,IAAA,CACtC,4BAAA,GAA+B,qCAAA,gBAG/B,MAAA"}
package/dist/types.d.ts CHANGED
@@ -1,34 +1,34 @@
1
- import Anthropic from "@anthropic-ai/sdk";
1
+ import Anthropic$1 from "@anthropic-ai/sdk";
2
2
  import { BindToolsInput } from "@langchain/core/language_models/chat_models";
3
3
 
4
4
  //#region src/types.d.ts
5
- type AnthropicMessageCreateParams = Anthropic.MessageCreateParamsNonStreaming;
6
- type AnthropicStreamingMessageCreateParams = Anthropic.MessageCreateParamsStreaming;
7
- type AnthropicThinkingConfigParam = Anthropic.ThinkingConfigParam;
8
- type AnthropicContextManagementConfigParam = Anthropic.Beta.BetaContextManagementConfig;
9
- type AnthropicMessageStreamEvent = Anthropic.MessageStreamEvent;
10
- type AnthropicRequestOptions = Anthropic.RequestOptions;
5
+ type AnthropicMessageCreateParams = Anthropic$1.MessageCreateParamsNonStreaming;
6
+ type AnthropicStreamingMessageCreateParams = Anthropic$1.MessageCreateParamsStreaming;
7
+ type AnthropicThinkingConfigParam = Anthropic$1.ThinkingConfigParam;
8
+ type AnthropicContextManagementConfigParam = Anthropic$1.Beta.BetaContextManagementConfig;
9
+ type AnthropicMessageStreamEvent = Anthropic$1.MessageStreamEvent;
10
+ type AnthropicRequestOptions = Anthropic$1.RequestOptions;
11
11
  type AnthropicToolChoice = {
12
12
  type: "tool";
13
13
  name: string;
14
14
  } | "any" | "auto" | "none" | string;
15
- type ChatAnthropicToolType = Anthropic.Messages.Tool | BindToolsInput;
16
- type ChatAnthropicOutputFormat = Anthropic.Messages.JSONOutputFormat;
17
- type AnthropicOutputConfig = Anthropic.Messages.OutputConfig;
18
- type AnthropicTextBlockParam = Anthropic.Messages.TextBlockParam;
19
- type AnthropicImageBlockParam = Anthropic.Messages.ImageBlockParam;
20
- type AnthropicToolUseBlockParam = Anthropic.Messages.ToolUseBlockParam;
21
- type AnthropicToolResultBlockParam = Anthropic.Messages.ToolResultBlockParam;
22
- type AnthropicDocumentBlockParam = Anthropic.Messages.DocumentBlockParam;
23
- type AnthropicThinkingBlockParam = Anthropic.Messages.ThinkingBlockParam;
24
- type AnthropicRedactedThinkingBlockParam = Anthropic.Messages.RedactedThinkingBlockParam;
25
- type AnthropicServerToolUseBlockParam = Anthropic.Messages.ServerToolUseBlockParam;
26
- type AnthropicWebSearchToolResultBlockParam = Anthropic.Messages.WebSearchToolResultBlockParam;
27
- type AnthropicWebSearchResultBlockParam = Anthropic.Messages.WebSearchResultBlockParam;
28
- type AnthropicSearchResultBlockParam = Anthropic.SearchResultBlockParam;
29
- type AnthropicContainerUploadBlockParam = Anthropic.Beta.BetaContainerUploadBlockParam;
30
- type AnthropicCompactionBlockParam = Anthropic.Beta.BetaCompactionBlockParam;
31
- type AnthropicMCPServerURLDefinition = Anthropic.Beta.Messages.BetaRequestMCPServerURLDefinition;
15
+ type ChatAnthropicToolType = Anthropic$1.Messages.Tool | BindToolsInput;
16
+ type ChatAnthropicOutputFormat = Anthropic$1.Messages.JSONOutputFormat;
17
+ type AnthropicOutputConfig = Anthropic$1.Messages.OutputConfig;
18
+ type AnthropicTextBlockParam = Anthropic$1.Messages.TextBlockParam;
19
+ type AnthropicImageBlockParam = Anthropic$1.Messages.ImageBlockParam;
20
+ type AnthropicToolUseBlockParam = Anthropic$1.Messages.ToolUseBlockParam;
21
+ type AnthropicToolResultBlockParam = Anthropic$1.Messages.ToolResultBlockParam;
22
+ type AnthropicDocumentBlockParam = Anthropic$1.Messages.DocumentBlockParam;
23
+ type AnthropicThinkingBlockParam = Anthropic$1.Messages.ThinkingBlockParam;
24
+ type AnthropicRedactedThinkingBlockParam = Anthropic$1.Messages.RedactedThinkingBlockParam;
25
+ type AnthropicServerToolUseBlockParam = Anthropic$1.Messages.ServerToolUseBlockParam;
26
+ type AnthropicWebSearchToolResultBlockParam = Anthropic$1.Messages.WebSearchToolResultBlockParam;
27
+ type AnthropicWebSearchResultBlockParam = Anthropic$1.Messages.WebSearchResultBlockParam;
28
+ type AnthropicSearchResultBlockParam = Anthropic$1.SearchResultBlockParam;
29
+ type AnthropicContainerUploadBlockParam = Anthropic$1.Beta.BetaContainerUploadBlockParam;
30
+ type AnthropicCompactionBlockParam = Anthropic$1.Beta.BetaCompactionBlockParam;
31
+ type AnthropicMCPServerURLDefinition = Anthropic$1.Beta.Messages.BetaRequestMCPServerURLDefinition;
32
32
  type ChatAnthropicContentBlock = AnthropicTextBlockParam | AnthropicImageBlockParam | AnthropicToolUseBlockParam | AnthropicToolResultBlockParam | AnthropicDocumentBlockParam | AnthropicThinkingBlockParam | AnthropicRedactedThinkingBlockParam | AnthropicServerToolUseBlockParam | AnthropicWebSearchToolResultBlockParam | AnthropicWebSearchResultBlockParam | AnthropicSearchResultBlockParam | AnthropicContainerUploadBlockParam | AnthropicCompactionBlockParam;
33
33
  /**
34
34
  * A type representing additional parameters that can be passed to the
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;KAcY,4BAAA,GACV,SAAA,CAAU,+BAAA;AAAA,KACA,qCAAA,GACV,SAAA,CAAU,4BAAA;AAAA,KACA,4BAAA,GAA+B,SAAA,CAAU,mBAAA;AAAA,KACzC,qCAAA,GACV,SAAA,CAAU,IAAA,CAAK,2BAAA;AAAA,KACL,2BAAA,GAA8B,SAAA,CAAU,kBAAA;AAAA,KACxC,uBAAA,GAA0B,SAAA,CAAU,cAAA;AAAA,KACpC,mBAAA;EAEN,IAAA;EACA,IAAA;AAAA;AAAA,KAMM,qBAAA,GAAwB,SAAA,CAAU,QAAA,CAAS,IAAA,GAAO,cAAA;AAAA,KAClD,yBAAA,GAA4B,SAAA,CAAU,QAAA,CAAS,gBAAA;AAAA,KAC/C,qBAAA,GAAwB,SAAA,CAAU,QAAA,CAAS,YAAA;AAAA,KAE3C,uBAAA,GAA0B,SAAA,CAAU,QAAA,CAAS,cAAA;AAAA,KAC7C,wBAAA,GAA2B,SAAA,CAAU,QAAA,CAAS,eAAA;AAAA,KAC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;;;AAzCJ;KAkHY,MAAA,GAAS,MAAA;AAAA,KAET,yBAAA,GAA4B,IAAA,CACtC,4BAAA,GAA+B,qCAAA,gBAG/B,MAAA"}
@@ -1,6 +1,5 @@
1
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
1
+ require("../_virtual/_rolldown/runtime.cjs");
2
2
  let _langchain_core_messages = require("@langchain/core/messages");
3
-
4
3
  //#region src/utils/content.ts
5
4
  function _isAnthropicThinkingBlock(block) {
6
5
  return typeof block === "object" && block !== null && "type" in block && block.type === "thinking";
@@ -144,7 +143,6 @@ const standardContentBlockConverter = {
144
143
  else throw new Error(`Unsupported file source type: ${block.source_type}`);
145
144
  }
146
145
  };
147
-
148
146
  //#endregion
149
147
  exports._isAnthropicCompactionBlock = _isAnthropicCompactionBlock;
150
148
  exports._isAnthropicImageBlockParam = _isAnthropicImageBlockParam;
@@ -152,4 +150,5 @@ exports._isAnthropicRedactedThinkingBlock = _isAnthropicRedactedThinkingBlock;
152
150
  exports._isAnthropicSearchResultBlock = _isAnthropicSearchResultBlock;
153
151
  exports._isAnthropicThinkingBlock = _isAnthropicThinkingBlock;
154
152
  exports.standardContentBlockConverter = standardContentBlockConverter;
153
+
155
154
  //# sourceMappingURL=content.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"content.cjs","names":[],"sources":["../../src/utils/content.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport {\n parseBase64DataUrl,\n type StandardContentBlockConverter,\n} from \"@langchain/core/messages\";\n\nexport function _isAnthropicThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.ThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"thinking\"\n );\n}\n\nexport function _isAnthropicRedactedThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.RedactedThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"redacted_thinking\"\n );\n}\n\nexport function _isAnthropicCompactionBlock(\n block: unknown\n): block is Anthropic.Beta.BetaCompactionBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"compaction\"\n );\n}\n\nexport function _isAnthropicSearchResultBlock(\n block: unknown\n): block is Anthropic.Beta.BetaSearchResultBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"search_result\"\n );\n}\n\nexport function _isAnthropicImageBlockParam(\n block: unknown\n): block is Anthropic.Messages.ImageBlockParam {\n if (typeof block !== \"object\" || block == null) {\n return false;\n }\n if (!(\"type\" in block) || block.type !== \"image\") {\n return false;\n }\n\n if (\n !(\"source\" in block) ||\n typeof block.source !== \"object\" ||\n block.source == null\n ) {\n return false;\n }\n\n if (!(\"type\" in block.source)) {\n return false;\n }\n\n if (block.source.type === \"base64\") {\n if (!(\"media_type\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.media_type !== \"string\") {\n return false;\n }\n\n if (!(\"data\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.data !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n if (block.source.type === \"url\") {\n if (!(\"url\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.url !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n return false;\n}\n\nexport const standardContentBlockConverter: StandardContentBlockConverter<{\n text: Anthropic.Messages.TextBlockParam;\n image: Anthropic.Messages.ImageBlockParam;\n file: Anthropic.Messages.DocumentBlockParam;\n}> = {\n providerName: \"anthropic\",\n\n fromStandardTextBlock(block): Anthropic.Messages.TextBlockParam {\n return {\n type: \"text\",\n text: block.text,\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.TextBlockParam;\n },\n\n fromStandardImageBlock(block): Anthropic.Messages.ImageBlockParam {\n if (block.source_type === \"url\") {\n const data = parseBase64DataUrl({\n dataUrl: block.url,\n asTypedArray: false,\n });\n if (data) {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: data.data,\n media_type: data.mime_type,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n return {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n }\n } else {\n if (block.source_type === \"base64\") {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n throw new Error(`Unsupported image source type: ${block.source_type}`);\n }\n }\n },\n\n fromStandardFileBlock(block): Anthropic.Messages.DocumentBlockParam {\n const mime_type = (block.mime_type ?? \"\").split(\";\")[0];\n\n if (block.source_type === \"url\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n }\n throw new Error(\n `Unsupported file mime type for file url source: ${block.mime_type}`\n );\n } else if (block.source_type === \"text\") {\n if (mime_type === \"text/plain\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"text\",\n data: block.text,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file text source: ${block.mime_type}`\n );\n }\n } else if (block.source_type === \"base64\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: \"application/pdf\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else if (\n [\"image/jpeg\", \"image/png\", \"image/gif\", \"image/webp\"].includes(\n mime_type\n )\n ) {\n return {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: mime_type as\n | \"image/jpeg\"\n | \"image/png\"\n | \"image/gif\"\n | \"image/webp\",\n },\n },\n ],\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file base64 source: ${block.mime_type}`\n );\n }\n } else {\n throw new Error(`Unsupported file source type: ${block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Q;IACN,MAAM;IACN,SAAS,CACP;KACE,MAAM;KACN,QAAQ;MACN,MAAM;MACN,MAAM,MAAM;MACZ,YAAY;MAKb;KACF,CACF;IACF;GACD,GAAI,oBAAoB,MAAM,YAAY,EAAE,IACxC,EAAE,eAAe,MAAM,SAAU,eAAe,GAChD,EAAE;GACN,GAAI,gBAAgB,MAAM,YAAY,EAAE,IACpC,EAAE,WAAW,MAAM,SAAU,WAAW,GACxC,EAAE;GACN,GAAI,cAAc,MAAM,YAAY,EAAE,IAClC,EAAE,SAAS,MAAM,SAAU,SAAS,GACpC,EAAE;GACN,GAAI,YAAY,MAAM,YAAY,EAAE,IAChC,EAAE,OAAO,MAAM,SAAU,OAAO,GAChC,EAAE;GACP;MAED,OAAM,IAAI,MACR,sDAAsD,MAAM,YAC7D;MAGH,OAAM,IAAI,MAAM,iCAAiC,MAAM,cAAc;;CAG1E"}
1
+ {"version":3,"file":"content.cjs","names":[],"sources":["../../src/utils/content.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport {\n parseBase64DataUrl,\n type StandardContentBlockConverter,\n} from \"@langchain/core/messages\";\n\nexport function _isAnthropicThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.ThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"thinking\"\n );\n}\n\nexport function _isAnthropicRedactedThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.RedactedThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"redacted_thinking\"\n );\n}\n\nexport function _isAnthropicCompactionBlock(\n block: unknown\n): block is Anthropic.Beta.BetaCompactionBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"compaction\"\n );\n}\n\nexport function _isAnthropicSearchResultBlock(\n block: unknown\n): block is Anthropic.Beta.BetaSearchResultBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"search_result\"\n );\n}\n\nexport function _isAnthropicImageBlockParam(\n block: unknown\n): block is Anthropic.Messages.ImageBlockParam {\n if (typeof block !== \"object\" || block == null) {\n return false;\n }\n if (!(\"type\" in block) || block.type !== \"image\") {\n return false;\n }\n\n if (\n !(\"source\" in block) ||\n typeof block.source !== \"object\" ||\n block.source == null\n ) {\n return false;\n }\n\n if (!(\"type\" in block.source)) {\n return false;\n }\n\n if (block.source.type === \"base64\") {\n if (!(\"media_type\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.media_type !== \"string\") {\n return false;\n }\n\n if (!(\"data\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.data !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n if (block.source.type === \"url\") {\n if (!(\"url\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.url !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n return false;\n}\n\nexport const standardContentBlockConverter: StandardContentBlockConverter<{\n text: Anthropic.Messages.TextBlockParam;\n image: Anthropic.Messages.ImageBlockParam;\n file: Anthropic.Messages.DocumentBlockParam;\n}> = {\n providerName: \"anthropic\",\n\n fromStandardTextBlock(block): Anthropic.Messages.TextBlockParam {\n return {\n type: \"text\",\n text: block.text,\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.TextBlockParam;\n },\n\n fromStandardImageBlock(block): Anthropic.Messages.ImageBlockParam {\n if (block.source_type === \"url\") {\n const data = parseBase64DataUrl({\n dataUrl: block.url,\n asTypedArray: false,\n });\n if (data) {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: data.data,\n media_type: data.mime_type,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n return {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n }\n } else {\n if (block.source_type === \"base64\") {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n throw new Error(`Unsupported image source type: ${block.source_type}`);\n }\n }\n },\n\n fromStandardFileBlock(block): Anthropic.Messages.DocumentBlockParam {\n const mime_type = (block.mime_type ?? \"\").split(\";\")[0];\n\n if (block.source_type === \"url\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n }\n throw new Error(\n `Unsupported file mime type for file url source: ${block.mime_type}`\n );\n } else if (block.source_type === \"text\") {\n if (mime_type === \"text/plain\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"text\",\n data: block.text,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file text source: ${block.mime_type}`\n );\n }\n } else if (block.source_type === \"base64\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: \"application/pdf\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else if (\n [\"image/jpeg\", \"image/png\", \"image/gif\", \"image/webp\"].includes(\n mime_type\n )\n ) {\n return {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: mime_type as\n | \"image/jpeg\"\n | \"image/png\"\n | \"image/gif\"\n | \"image/webp\",\n },\n },\n ],\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file base64 source: ${block.mime_type}`\n );\n }\n } else {\n throw new Error(`Unsupported file source type: ${block.source_type}`);\n }\n },\n};\n"],"mappings":";;;AAMA,SAAgB,0BACd,OACgD;AAChD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;;AAInB,SAAgB,kCACd,OACwD;AACxD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;;AAInB,SAAgB,4BACd,OACk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,MAAM,YAAY,EAAE,IACpC,EAAE,WAAW,MAAM,SAAU,WAAW,GACxC,EAAE;GACN,GAAI,cAAc,MAAM,YAAY,EAAE,IAClC,EAAE,SAAS,MAAM,SAAU,SAAS,GACpC,EAAE;GACN,GAAI,YAAY,MAAM,YAAY,EAAE,IAChC,EAAE,OAAO,MAAM,SAAU,OAAO,GAChC,EAAE;GACP;MAED,OAAM,IAAI,MACR,sDAAsD,MAAM,YAC7D;MAGH,OAAM,IAAI,MAAM,iCAAiC,MAAM,cAAc;;CAG1E"}
@@ -1,5 +1,4 @@
1
1
  import { parseBase64DataUrl } from "@langchain/core/messages";
2
-
3
2
  //#region src/utils/content.ts
4
3
  function _isAnthropicThinkingBlock(block) {
5
4
  return typeof block === "object" && block !== null && "type" in block && block.type === "thinking";
@@ -143,7 +142,7 @@ const standardContentBlockConverter = {
143
142
  else throw new Error(`Unsupported file source type: ${block.source_type}`);
144
143
  }
145
144
  };
146
-
147
145
  //#endregion
148
146
  export { _isAnthropicCompactionBlock, _isAnthropicImageBlockParam, _isAnthropicRedactedThinkingBlock, _isAnthropicSearchResultBlock, _isAnthropicThinkingBlock, standardContentBlockConverter };
147
+
149
148
  //# sourceMappingURL=content.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"content.js","names":[],"sources":["../../src/utils/content.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport {\n parseBase64DataUrl,\n type StandardContentBlockConverter,\n} from \"@langchain/core/messages\";\n\nexport function _isAnthropicThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.ThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"thinking\"\n );\n}\n\nexport function _isAnthropicRedactedThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.RedactedThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"redacted_thinking\"\n );\n}\n\nexport function _isAnthropicCompactionBlock(\n block: unknown\n): block is Anthropic.Beta.BetaCompactionBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"compaction\"\n );\n}\n\nexport function _isAnthropicSearchResultBlock(\n block: unknown\n): block is Anthropic.Beta.BetaSearchResultBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"search_result\"\n );\n}\n\nexport function _isAnthropicImageBlockParam(\n block: unknown\n): block is Anthropic.Messages.ImageBlockParam {\n if (typeof block !== \"object\" || block == null) {\n return false;\n }\n if (!(\"type\" in block) || block.type !== \"image\") {\n return false;\n }\n\n if (\n !(\"source\" in block) ||\n typeof block.source !== \"object\" ||\n block.source == null\n ) {\n return false;\n }\n\n if (!(\"type\" in block.source)) {\n return false;\n }\n\n if (block.source.type === \"base64\") {\n if (!(\"media_type\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.media_type !== \"string\") {\n return false;\n }\n\n if (!(\"data\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.data !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n if (block.source.type === \"url\") {\n if (!(\"url\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.url !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n return false;\n}\n\nexport const standardContentBlockConverter: StandardContentBlockConverter<{\n text: Anthropic.Messages.TextBlockParam;\n image: Anthropic.Messages.ImageBlockParam;\n file: Anthropic.Messages.DocumentBlockParam;\n}> = {\n providerName: \"anthropic\",\n\n fromStandardTextBlock(block): Anthropic.Messages.TextBlockParam {\n return {\n type: \"text\",\n text: block.text,\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.TextBlockParam;\n },\n\n fromStandardImageBlock(block): Anthropic.Messages.ImageBlockParam {\n if (block.source_type === \"url\") {\n const data = parseBase64DataUrl({\n dataUrl: block.url,\n asTypedArray: false,\n });\n if (data) {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: data.data,\n media_type: data.mime_type,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n return {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n }\n } else {\n if (block.source_type === \"base64\") {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n throw new Error(`Unsupported image source type: ${block.source_type}`);\n }\n }\n },\n\n fromStandardFileBlock(block): Anthropic.Messages.DocumentBlockParam {\n const mime_type = (block.mime_type ?? \"\").split(\";\")[0];\n\n if (block.source_type === \"url\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n }\n throw new Error(\n `Unsupported file mime type for file url source: ${block.mime_type}`\n );\n } else if (block.source_type === \"text\") {\n if (mime_type === \"text/plain\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"text\",\n data: block.text,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file text source: ${block.mime_type}`\n );\n }\n } else if (block.source_type === \"base64\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: \"application/pdf\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else if (\n [\"image/jpeg\", \"image/png\", \"image/gif\", \"image/webp\"].includes(\n mime_type\n )\n ) {\n return {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: mime_type as\n | \"image/jpeg\"\n | \"image/png\"\n | \"image/gif\"\n | \"image/webp\",\n },\n },\n ],\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file base64 source: ${block.mime_type}`\n );\n }\n } else {\n throw new Error(`Unsupported file source type: ${block.source_type}`);\n }\n },\n};\n"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,SAAS,CACP;KACE,MAAM;KACN,QAAQ;MACN,MAAM;MACN,MAAM,MAAM;MACZ,YAAY;MAKb;KACF,CACF;IACF;GACD,GAAI,oBAAoB,MAAM,YAAY,EAAE,IACxC,EAAE,eAAe,MAAM,SAAU,eAAe,GAChD,EAAE;GACN,GAAI,gBAAgB,MAAM,YAAY,EAAE,IACpC,EAAE,WAAW,MAAM,SAAU,WAAW,GACxC,EAAE;GACN,GAAI,cAAc,MAAM,YAAY,EAAE,IAClC,EAAE,SAAS,MAAM,SAAU,SAAS,GACpC,EAAE;GACN,GAAI,YAAY,MAAM,YAAY,EAAE,IAChC,EAAE,OAAO,MAAM,SAAU,OAAO,GAChC,EAAE;GACP;MAED,OAAM,IAAI,MACR,sDAAsD,MAAM,YAC7D;MAGH,OAAM,IAAI,MAAM,iCAAiC,MAAM,cAAc;;CAG1E"}
1
+ {"version":3,"file":"content.js","names":[],"sources":["../../src/utils/content.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport {\n parseBase64DataUrl,\n type StandardContentBlockConverter,\n} from \"@langchain/core/messages\";\n\nexport function _isAnthropicThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.ThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"thinking\"\n );\n}\n\nexport function _isAnthropicRedactedThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.RedactedThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"redacted_thinking\"\n );\n}\n\nexport function _isAnthropicCompactionBlock(\n block: unknown\n): block is Anthropic.Beta.BetaCompactionBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"compaction\"\n );\n}\n\nexport function _isAnthropicSearchResultBlock(\n block: unknown\n): block is Anthropic.Beta.BetaSearchResultBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"search_result\"\n );\n}\n\nexport function _isAnthropicImageBlockParam(\n block: unknown\n): block is Anthropic.Messages.ImageBlockParam {\n if (typeof block !== \"object\" || block == null) {\n return false;\n }\n if (!(\"type\" in block) || block.type !== \"image\") {\n return false;\n }\n\n if (\n !(\"source\" in block) ||\n typeof block.source !== \"object\" ||\n block.source == null\n ) {\n return false;\n }\n\n if (!(\"type\" in block.source)) {\n return false;\n }\n\n if (block.source.type === \"base64\") {\n if (!(\"media_type\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.media_type !== \"string\") {\n return false;\n }\n\n if (!(\"data\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.data !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n if (block.source.type === \"url\") {\n if (!(\"url\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.url !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n return false;\n}\n\nexport const standardContentBlockConverter: StandardContentBlockConverter<{\n text: Anthropic.Messages.TextBlockParam;\n image: Anthropic.Messages.ImageBlockParam;\n file: Anthropic.Messages.DocumentBlockParam;\n}> = {\n providerName: \"anthropic\",\n\n fromStandardTextBlock(block): Anthropic.Messages.TextBlockParam {\n return {\n type: \"text\",\n text: block.text,\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.TextBlockParam;\n },\n\n fromStandardImageBlock(block): Anthropic.Messages.ImageBlockParam {\n if (block.source_type === \"url\") {\n const data = parseBase64DataUrl({\n dataUrl: block.url,\n asTypedArray: false,\n });\n if (data) {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: data.data,\n media_type: data.mime_type,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n return {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n }\n } else {\n if (block.source_type === \"base64\") {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n throw new Error(`Unsupported image source type: ${block.source_type}`);\n }\n }\n },\n\n fromStandardFileBlock(block): Anthropic.Messages.DocumentBlockParam {\n const mime_type = (block.mime_type ?? \"\").split(\";\")[0];\n\n if (block.source_type === \"url\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n }\n throw new Error(\n `Unsupported file mime type for file url source: ${block.mime_type}`\n );\n } else if (block.source_type === \"text\") {\n if (mime_type === \"text/plain\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"text\",\n data: block.text,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file text source: ${block.mime_type}`\n );\n }\n } else if (block.source_type === \"base64\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: \"application/pdf\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else if (\n [\"image/jpeg\", \"image/png\", \"image/gif\", \"image/webp\"].includes(\n mime_type\n )\n ) {\n return {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: mime_type as\n | \"image/jpeg\"\n | \"image/png\"\n | \"image/gif\"\n | \"image/webp\",\n },\n },\n ],\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file base64 source: ${block.mime_type}`\n );\n }\n } else {\n throw new Error(`Unsupported file source type: ${block.source_type}`);\n }\n },\n};\n"],"mappings":";;AAMA,SAAgB,0BACd,OACgD;AAChD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;;AAInB,SAAgB,kCACd,OACwD;AACxD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;;AAInB,SAAgB,4BACd,OACkD;AAClD,QACE,OAAO,UA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W,MAAM,SAAU,WAAW,GACxC,EAAE;GACN,GAAI,cAAc,MAAM,YAAY,EAAE,IAClC,EAAE,SAAS,MAAM,SAAU,SAAS,GACpC,EAAE;GACN,GAAI,YAAY,MAAM,YAAY,EAAE,IAChC,EAAE,OAAO,MAAM,SAAU,OAAO,GAChC,EAAE;GACP;MAED,OAAM,IAAI,MACR,sDAAsD,MAAM,YAC7D;MAGH,OAAM,IAAI,MAAM,iCAAiC,MAAM,cAAc;;CAG1E"}
@@ -1,6 +1,5 @@
1
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
1
+ require("../_virtual/_rolldown/runtime.cjs");
2
2
  let _langchain_core_errors = require("@langchain/core/errors");
3
-
4
3
  //#region src/utils/errors.ts
5
4
  function addLangChainErrorFields(error, lc_error_code) {
6
5
  error.lc_error_code = lc_error_code;
@@ -9,7 +8,7 @@ function addLangChainErrorFields(error, lc_error_code) {
9
8
  }
10
9
  function wrapAnthropicClientError(e) {
11
10
  let error;
12
- if (e.status === 400 && typeof e.message === "string" && e.message.includes("prompt is too long")) error = _langchain_core_errors.ContextOverflowError.fromError(e);
11
+ if (e.status === 400 && typeof e.message === "string" && e.message.includes("prompt is too long")) error = addLangChainErrorFields(_langchain_core_errors.ContextOverflowError.fromError(e), "CONTEXT_OVERFLOW");
13
12
  else if (e.status === 400 && e.message.includes("tool")) error = addLangChainErrorFields(e, "INVALID_TOOL_RESULTS");
14
13
  else if (e.status === 401) error = addLangChainErrorFields(e, "MODEL_AUTHENTICATION");
15
14
  else if (e.status === 404) error = addLangChainErrorFields(e, "MODEL_NOT_FOUND");
@@ -17,7 +16,7 @@ function wrapAnthropicClientError(e) {
17
16
  else error = e;
18
17
  return error;
19
18
  }
20
-
21
19
  //#endregion
22
20
  exports.wrapAnthropicClientError = wrapAnthropicClientError;
21
+
23
22
  //# sourceMappingURL=errors.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":["ContextOverflowError"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-param-reassign */\n\nimport { ContextOverflowError } from \"@langchain/core/errors\";\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"CONTEXT_OVERFLOW\"\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapAnthropicClientError(e: any) {\n let error;\n if (\n e.status === 400 &&\n typeof e.message === \"string\" &&\n e.message.includes(\"prompt is too long\")\n ) {\n error = ContextOverflowError.fromError(e);\n } else if (e.status === 400 && e.message.includes(\"tool\")) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else if (e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";;;;AAiBA,SAAgB,wBACd,OACA,eACA;AACA,CAAC,MAAc,gBAAgB;AAC/B,OAAM,UAAU,GAAG,MAAM,QAAQ,sFAAsF,cAAc;AACrI,QAAO;;AAIT,SAAgB,yBAAyB,GAAQ;CAC/C,IAAI;AACJ,KACE,EAAE,WAAW,OACb,OAAO,EAAE,YAAY,YACrB,EAAE,QAAQ,SAAS,qBAAqB,CAExC,SAAQA,4CAAqB,UAAU,EAAE;UAChC,EAAE,WAAW,OAAO,EAAE,QAAQ,SAAS,OAAO,CACvD,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,kBAAkB;UAC5C,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,mBAAmB;KAEtD,SAAQ;AAEV,QAAO"}
1
+ {"version":3,"file":"errors.cjs","names":["ContextOverflowError"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-param-reassign */\n\nimport { ContextOverflowError } from \"@langchain/core/errors\";\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"CONTEXT_OVERFLOW\"\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapAnthropicClientError(e: any) {\n let error;\n if (\n e.status === 400 &&\n typeof e.message === \"string\" &&\n e.message.includes(\"prompt is too long\")\n ) {\n error = addLangChainErrorFields(\n ContextOverflowError.fromError(e),\n \"CONTEXT_OVERFLOW\"\n );\n } else if (e.status === 400 && e.message.includes(\"tool\")) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else if (e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";;;AAiBA,SAAgB,wBACd,OACA,eACA;AACC,OAAc,gBAAgB;AAC/B,OAAM,UAAU,GAAG,MAAM,QAAQ,sFAAsF,cAAc;AACrI,QAAO;;AAIT,SAAgB,yBAAyB,GAAQ;CAC/C,IAAI;AACJ,KACE,EAAE,WAAW,OACb,OAAO,EAAE,YAAY,YACrB,EAAE,QAAQ,SAAS,qBAAqB,CAExC,SAAQ,wBACNA,uBAAAA,qBAAqB,UAAU,EAAE,EACjC,mBACD;UACQ,EAAE,WAAW,OAAO,EAAE,QAAQ,SAAS,OAAO,CACvD,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,kBAAkB;UAC5C,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,mBAAmB;KAEtD,SAAQ;AAEV,QAAO"}
@@ -1,5 +1,4 @@
1
1
  import { ContextOverflowError } from "@langchain/core/errors";
2
-
3
2
  //#region src/utils/errors.ts
4
3
  function addLangChainErrorFields(error, lc_error_code) {
5
4
  error.lc_error_code = lc_error_code;
@@ -8,7 +7,7 @@ function addLangChainErrorFields(error, lc_error_code) {
8
7
  }
9
8
  function wrapAnthropicClientError(e) {
10
9
  let error;
11
- if (e.status === 400 && typeof e.message === "string" && e.message.includes("prompt is too long")) error = ContextOverflowError.fromError(e);
10
+ if (e.status === 400 && typeof e.message === "string" && e.message.includes("prompt is too long")) error = addLangChainErrorFields(ContextOverflowError.fromError(e), "CONTEXT_OVERFLOW");
12
11
  else if (e.status === 400 && e.message.includes("tool")) error = addLangChainErrorFields(e, "INVALID_TOOL_RESULTS");
13
12
  else if (e.status === 401) error = addLangChainErrorFields(e, "MODEL_AUTHENTICATION");
14
13
  else if (e.status === 404) error = addLangChainErrorFields(e, "MODEL_NOT_FOUND");
@@ -16,7 +15,7 @@ function wrapAnthropicClientError(e) {
16
15
  else error = e;
17
16
  return error;
18
17
  }
19
-
20
18
  //#endregion
21
19
  export { wrapAnthropicClientError };
20
+
22
21
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-param-reassign */\n\nimport { ContextOverflowError } from \"@langchain/core/errors\";\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"CONTEXT_OVERFLOW\"\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapAnthropicClientError(e: any) {\n let error;\n if (\n e.status === 400 &&\n typeof e.message === \"string\" &&\n e.message.includes(\"prompt is too long\")\n ) {\n error = ContextOverflowError.fromError(e);\n } else if (e.status === 400 && e.message.includes(\"tool\")) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else if (e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";;;AAiBA,SAAgB,wBACd,OACA,eACA;AACA,CAAC,MAAc,gBAAgB;AAC/B,OAAM,UAAU,GAAG,MAAM,QAAQ,sFAAsF,cAAc;AACrI,QAAO;;AAIT,SAAgB,yBAAyB,GAAQ;CAC/C,IAAI;AACJ,KACE,EAAE,WAAW,OACb,OAAO,EAAE,YAAY,YACrB,EAAE,QAAQ,SAAS,qBAAqB,CAExC,SAAQ,qBAAqB,UAAU,EAAE;UAChC,EAAE,WAAW,OAAO,EAAE,QAAQ,SAAS,OAAO,CACvD,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,kBAAkB;UAC5C,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,mBAAmB;KAEtD,SAAQ;AAEV,QAAO"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-param-reassign */\n\nimport { ContextOverflowError } from \"@langchain/core/errors\";\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"CONTEXT_OVERFLOW\"\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapAnthropicClientError(e: any) {\n let error;\n if (\n e.status === 400 &&\n typeof e.message === \"string\" &&\n e.message.includes(\"prompt is too long\")\n ) {\n error = addLangChainErrorFields(\n ContextOverflowError.fromError(e),\n \"CONTEXT_OVERFLOW\"\n );\n } else if (e.status === 400 && e.message.includes(\"tool\")) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else if (e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";;AAiBA,SAAgB,wBACd,OACA,eACA;AACC,OAAc,gBAAgB;AAC/B,OAAM,UAAU,GAAG,MAAM,QAAQ,sFAAsF,cAAc;AACrI,QAAO;;AAIT,SAAgB,yBAAyB,GAAQ;CAC/C,IAAI;AACJ,KACE,EAAE,WAAW,OACb,OAAO,EAAE,YAAY,YACrB,EAAE,QAAQ,SAAS,qBAAqB,CAExC,SAAQ,wBACN,qBAAqB,UAAU,EAAE,EACjC,mBACD;UACQ,EAAE,WAAW,OAAO,EAAE,QAAQ,SAAS,OAAO,CACvD,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,kBAAkB;UAC5C,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,mBAAmB;KAEtD,SAAQ;AAEV,QAAO"}
@@ -1,7 +1,6 @@
1
-
2
1
  //#region src/utils/index.ts
3
2
  const iife = (fn) => fn();
4
-
5
3
  //#endregion
6
4
  exports.iife = iife;
5
+
7
6
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["export const iife = <T>(fn: () => T) => fn();\n\nexport const safeParseJson = <T>(json: string): T | object => {\n try {\n return JSON.parse(json);\n } catch {\n return {};\n }\n};\n"],"mappings":";;AAAA,MAAa,QAAW,OAAgB,IAAI"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["export const iife = <T>(fn: () => T) => fn();\n\nexport const safeParseJson = <T>(json: string): T | object => {\n try {\n return JSON.parse(json);\n } catch {\n return {};\n }\n};\n"],"mappings":";AAAA,MAAa,QAAW,OAAgB,IAAI"}
@@ -1,6 +1,6 @@
1
1
  //#region src/utils/index.ts
2
2
  const iife = (fn) => fn();
3
-
4
3
  //#endregion
5
4
  export { iife };
5
+
6
6
  //# sourceMappingURL=index.js.map