@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.
- package/dist/_virtual/_rolldown/runtime.cjs +7 -13
- package/dist/chat_models.cjs +13 -13
- package/dist/chat_models.cjs.map +1 -1
- package/dist/chat_models.d.cts +25 -25
- package/dist/chat_models.d.cts.map +1 -1
- package/dist/chat_models.d.ts +25 -25
- package/dist/chat_models.d.ts.map +1 -1
- package/dist/chat_models.js +8 -8
- package/dist/chat_models.js.map +1 -1
- package/dist/index.cjs +5 -6
- package/dist/index.js +1 -2
- package/dist/output_parsers.cjs +2 -3
- package/dist/output_parsers.cjs.map +1 -1
- package/dist/output_parsers.js +1 -2
- 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 -1
- package/dist/tools/bash.cjs +3 -4
- package/dist/tools/bash.cjs.map +1 -1
- package/dist/tools/bash.js +1 -2
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/codeExecution.cjs +1 -2
- package/dist/tools/codeExecution.cjs.map +1 -1
- package/dist/tools/codeExecution.d.cts +2 -2
- package/dist/tools/codeExecution.d.cts.map +1 -1
- package/dist/tools/codeExecution.d.ts +2 -2
- package/dist/tools/codeExecution.d.ts.map +1 -1
- package/dist/tools/codeExecution.js +1 -1
- package/dist/tools/computer.cjs +3 -4
- package/dist/tools/computer.cjs.map +1 -1
- package/dist/tools/computer.js +1 -2
- package/dist/tools/computer.js.map +1 -1
- package/dist/tools/index.cjs +10 -11
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +1 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/mcpToolset.cjs +1 -2
- package/dist/tools/mcpToolset.cjs.map +1 -1
- package/dist/tools/mcpToolset.d.cts +2 -2
- package/dist/tools/mcpToolset.d.cts.map +1 -1
- package/dist/tools/mcpToolset.d.ts +2 -2
- package/dist/tools/mcpToolset.d.ts.map +1 -1
- package/dist/tools/mcpToolset.js +1 -1
- package/dist/tools/mcpToolset.js.map +1 -1
- package/dist/tools/memory.cjs +3 -4
- package/dist/tools/memory.cjs.map +1 -1
- package/dist/tools/memory.js +1 -2
- package/dist/tools/memory.js.map +1 -1
- package/dist/tools/textEditor.cjs +3 -4
- package/dist/tools/textEditor.cjs.map +1 -1
- package/dist/tools/textEditor.js +1 -2
- package/dist/tools/textEditor.js.map +1 -1
- package/dist/tools/toolSearch.cjs +1 -2
- package/dist/tools/toolSearch.cjs.map +1 -1
- package/dist/tools/toolSearch.d.cts +2 -2
- package/dist/tools/toolSearch.d.cts.map +1 -1
- package/dist/tools/toolSearch.d.ts +2 -2
- package/dist/tools/toolSearch.d.ts.map +1 -1
- package/dist/tools/toolSearch.js +1 -1
- package/dist/tools/types.cjs +2 -3
- package/dist/tools/types.cjs.map +1 -1
- package/dist/tools/types.d.cts +2 -2
- package/dist/tools/types.d.cts.map +1 -1
- package/dist/tools/types.d.ts +2 -2
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +1 -2
- package/dist/tools/types.js.map +1 -1
- package/dist/tools/webFetch.cjs +1 -2
- package/dist/tools/webFetch.cjs.map +1 -1
- package/dist/tools/webFetch.d.cts +2 -2
- package/dist/tools/webFetch.d.cts.map +1 -1
- package/dist/tools/webFetch.d.ts +2 -2
- package/dist/tools/webFetch.d.ts.map +1 -1
- package/dist/tools/webFetch.js +1 -1
- package/dist/tools/webSearch.cjs +1 -2
- package/dist/tools/webSearch.cjs.map +1 -1
- package/dist/tools/webSearch.d.cts +3 -3
- package/dist/tools/webSearch.d.cts.map +1 -1
- package/dist/tools/webSearch.d.ts +3 -3
- package/dist/tools/webSearch.d.ts.map +1 -1
- package/dist/tools/webSearch.js +1 -1
- package/dist/types.d.cts +24 -24
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +24 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/content.cjs +2 -3
- package/dist/utils/content.cjs.map +1 -1
- package/dist/utils/content.js +1 -2
- package/dist/utils/content.js.map +1 -1
- package/dist/utils/errors.cjs +3 -4
- package/dist/utils/errors.cjs.map +1 -1
- package/dist/utils/errors.js +2 -3
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/index.cjs +1 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/message_inputs.cjs +4 -5
- package/dist/utils/message_inputs.cjs.map +1 -1
- package/dist/utils/message_inputs.js +1 -2
- package/dist/utils/message_inputs.js.map +1 -1
- package/dist/utils/message_outputs.cjs +4 -5
- package/dist/utils/message_outputs.cjs.map +1 -1
- package/dist/utils/message_outputs.js +1 -2
- package/dist/utils/message_outputs.js.map +1 -1
- package/dist/utils/prompts.cjs +2 -3
- package/dist/utils/prompts.cjs.map +1 -1
- package/dist/utils/prompts.d.cts +2 -2
- package/dist/utils/prompts.d.cts.map +1 -1
- package/dist/utils/prompts.d.ts +2 -2
- 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 -3
- package/dist/utils/standard.cjs.map +1 -1
- package/dist/utils/standard.js +1 -2
- package/dist/utils/standard.js.map +1 -1
- package/dist/utils/tools.cjs +2 -3
- package/dist/utils/tools.cjs.map +1 -1
- package/dist/utils/tools.js +1 -2
- package/dist/utils/tools.js.map +1 -1
- package/package.json +3 -3
package/dist/utils/prompts.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
1
|
+
import Anthropic$1 from "@anthropic-ai/sdk";
|
|
2
2
|
import { BasePromptValue } from "@langchain/core/prompt_values";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/prompts.d.ts
|
|
@@ -38,7 +38,7 @@ import { BasePromptValue } from "@langchain/core/prompt_values";
|
|
|
38
38
|
* @param formattedPrompt
|
|
39
39
|
* @returns A partial Anthropic payload.
|
|
40
40
|
*/
|
|
41
|
-
declare function convertPromptToAnthropic(formattedPrompt: BasePromptValue): Anthropic.Messages.MessageCreateParams;
|
|
41
|
+
declare function convertPromptToAnthropic(formattedPrompt: BasePromptValue): Anthropic$1.Messages.MessageCreateParams;
|
|
42
42
|
//#endregion
|
|
43
43
|
export { convertPromptToAnthropic };
|
|
44
44
|
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","names":[],"sources":["../../src/utils/prompts.ts"],"mappings":";;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,wBAAA,CACd,eAAA,EAAiB,eAAA,GAChB,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","names":[],"sources":["../../src/utils/prompts.ts"],"mappings":";;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,wBAAA,CACd,eAAA,EAAiB,eAAA,GAChB,WAAA,CAAU,QAAA,CAAS,mBAAA"}
|
package/dist/utils/prompts.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { _convertMessagesToAnthropicPayload } from "./message_inputs.js";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/prompts.ts
|
|
4
3
|
/**
|
|
5
4
|
* Convert a formatted LangChain prompt (e.g. pulled from the hub) into
|
|
@@ -42,7 +41,7 @@ function convertPromptToAnthropic(formattedPrompt) {
|
|
|
42
41
|
if (anthropicBody.messages === void 0) anthropicBody.messages = [];
|
|
43
42
|
return anthropicBody;
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
//#endregion
|
|
47
45
|
export { convertPromptToAnthropic };
|
|
46
|
+
|
|
48
47
|
//# sourceMappingURL=prompts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","names":[],"sources":["../../src/utils/prompts.ts"],"sourcesContent":["import type { BasePromptValue } from \"@langchain/core/prompt_values\";\nimport Anthropic from \"@anthropic-ai/sdk\";\n\nimport { _convertMessagesToAnthropicPayload } from \"./message_inputs.js\";\n\n/**\n * Convert a formatted LangChain prompt (e.g. pulled from the hub) into\n * a format expected by Anthropic's JS SDK.\n *\n * Requires the \"@langchain/anthropic\" package to be installed in addition\n * to the Anthropic SDK.\n *\n * @example\n * ```ts\n * import { convertPromptToAnthropic } from \"langsmith/utils/hub/anthropic\";\n * import { pull } from \"langchain/hub\";\n *\n * import Anthropic from '@anthropic-ai/sdk';\n *\n * const prompt = await pull(\"jacob/joke-generator\");\n * const formattedPrompt = await prompt.invoke({\n * topic: \"cats\",\n * });\n *\n * const { system, messages } = convertPromptToAnthropic(formattedPrompt);\n *\n * const anthropicClient = new Anthropic({\n * apiKey: 'your_api_key',\n * });\n *\n * const anthropicResponse = await anthropicClient.messages.create({\n * model: \"claude-sonnet-4-5-20250929\",\n * max_tokens: 1024,\n * stream: false,\n * system,\n * messages,\n * });\n * ```\n * @param formattedPrompt\n * @returns A partial Anthropic payload.\n */\nexport function convertPromptToAnthropic(\n formattedPrompt: BasePromptValue\n): Anthropic.Messages.MessageCreateParams {\n const messages = formattedPrompt.toChatMessages();\n const anthropicBody = _convertMessagesToAnthropicPayload(messages);\n if (anthropicBody.messages === undefined) {\n anthropicBody.messages = [];\n }\n return anthropicBody;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"prompts.js","names":[],"sources":["../../src/utils/prompts.ts"],"sourcesContent":["import type { BasePromptValue } from \"@langchain/core/prompt_values\";\nimport Anthropic from \"@anthropic-ai/sdk\";\n\nimport { _convertMessagesToAnthropicPayload } from \"./message_inputs.js\";\n\n/**\n * Convert a formatted LangChain prompt (e.g. pulled from the hub) into\n * a format expected by Anthropic's JS SDK.\n *\n * Requires the \"@langchain/anthropic\" package to be installed in addition\n * to the Anthropic SDK.\n *\n * @example\n * ```ts\n * import { convertPromptToAnthropic } from \"langsmith/utils/hub/anthropic\";\n * import { pull } from \"langchain/hub\";\n *\n * import Anthropic from '@anthropic-ai/sdk';\n *\n * const prompt = await pull(\"jacob/joke-generator\");\n * const formattedPrompt = await prompt.invoke({\n * topic: \"cats\",\n * });\n *\n * const { system, messages } = convertPromptToAnthropic(formattedPrompt);\n *\n * const anthropicClient = new Anthropic({\n * apiKey: 'your_api_key',\n * });\n *\n * const anthropicResponse = await anthropicClient.messages.create({\n * model: \"claude-sonnet-4-5-20250929\",\n * max_tokens: 1024,\n * stream: false,\n * system,\n * messages,\n * });\n * ```\n * @param formattedPrompt\n * @returns A partial Anthropic payload.\n */\nexport function convertPromptToAnthropic(\n formattedPrompt: BasePromptValue\n): Anthropic.Messages.MessageCreateParams {\n const messages = formattedPrompt.toChatMessages();\n const anthropicBody = _convertMessagesToAnthropicPayload(messages);\n if (anthropicBody.messages === undefined) {\n anthropicBody.messages = [];\n }\n return anthropicBody;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,yBACd,iBACwC;CAExC,MAAM,gBAAgB,mCADL,gBAAgB,gBAAgB,CACiB;AAClE,KAAI,cAAc,aAAa,KAAA,EAC7B,eAAc,WAAW,EAAE;AAE7B,QAAO"}
|
package/dist/utils/standard.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const require_index = require(
|
|
2
|
-
|
|
1
|
+
const require_index = require("./index.cjs");
|
|
3
2
|
//#region src/utils/standard.ts
|
|
4
3
|
function _isStandardAnnotation(annotation) {
|
|
5
4
|
return typeof annotation === "object" && annotation !== null && "type" in annotation && annotation.type === "citation";
|
|
@@ -277,7 +276,7 @@ function _formatStandardContent(message) {
|
|
|
277
276
|
} else if (block.type === "non_standard" && isAnthropicMessage) result.push(block.value);
|
|
278
277
|
return result;
|
|
279
278
|
}
|
|
280
|
-
|
|
281
279
|
//#endregion
|
|
282
280
|
exports._formatStandardContent = _formatStandardContent;
|
|
281
|
+
|
|
283
282
|
//# sourceMappingURL=standard.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard.cjs","names":["iife"],"sources":["../../src/utils/standard.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport type {\n BaseMessage,\n ContentBlock,\n ResponseMetadata,\n} from \"@langchain/core/messages\";\nimport { iife } from \"./index.js\";\n\nfunction _isStandardAnnotation(\n annotation: unknown\n): annotation is ContentBlock.Citation {\n return (\n typeof annotation === \"object\" &&\n annotation !== null &&\n \"type\" in annotation &&\n annotation.type === \"citation\"\n );\n}\n\nfunction _formatStandardCitations(\n annotations: ContentBlock.Citation[]\n): Anthropic.Beta.BetaTextCitation[] {\n function* iterateAnnotations() {\n for (const annotation of annotations) {\n if (_isStandardAnnotation(annotation)) {\n if (annotation.source === \"char\") {\n yield {\n type: \"char_location\" as const,\n file_id: annotation.url ?? \"\",\n start_char_index: annotation.startIndex ?? 0,\n end_char_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"page\") {\n yield {\n type: \"page_location\" as const,\n file_id: annotation.url ?? \"\",\n start_page_number: annotation.startIndex ?? 0,\n end_page_number: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"block\") {\n yield {\n type: \"content_block_location\" as const,\n file_id: annotation.url ?? \"\",\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"url\") {\n yield {\n type: \"web_search_result_location\" as const,\n url: annotation.url ?? \"\",\n title: annotation.title ?? null,\n encrypted_index: String(annotation.startIndex ?? 0),\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"search\") {\n yield {\n type: \"search_result_location\" as const,\n title: annotation.title ?? null,\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n search_result_index: 0,\n source: annotation.source ?? \"\",\n cited_text: annotation.citedText ?? \"\",\n };\n }\n }\n }\n }\n return Array.from(iterateAnnotations());\n}\n\nfunction _formatBase64Data(data: string | Uint8Array): string {\n if (typeof data === \"string\") return data;\n else return _encodeUint8Array(data);\n}\n\nfunction _encodeUint8Array(data: Uint8Array): string {\n const output = [];\n for (let i = 0, { length } = data; i < length; i++) {\n output.push(String.fromCharCode(data[i]));\n }\n return btoa(output.join(\"\"));\n}\n\nfunction _normalizeMimeType(mimeType?: string | null): string {\n return (mimeType ?? \"\").split(\";\")[0].toLowerCase();\n}\n\nfunction _extractMetadataValue<T>(\n metadata: unknown,\n key: string\n): T | undefined {\n if (\n metadata !== undefined &&\n metadata !== null &&\n typeof metadata === \"object\" &&\n key in metadata\n ) {\n return (metadata as Record<string, unknown>)[key] as T;\n }\n return undefined;\n}\n\nfunction _applyDocumentMetadata(\n block: Anthropic.Beta.BetaRequestDocumentBlock,\n metadata: unknown\n): Anthropic.Beta.BetaRequestDocumentBlock {\n const cacheControl =\n _extractMetadataValue<Anthropic.Beta.BetaCacheControlEphemeral | null>(\n metadata,\n \"cache_control\"\n );\n if (cacheControl !== undefined) {\n block.cache_control = cacheControl;\n }\n const citations =\n _extractMetadataValue<Anthropic.Beta.BetaCitationsConfigParam | null>(\n metadata,\n \"citations\"\n );\n if (citations !== undefined) {\n block.citations = citations;\n }\n const context = _extractMetadataValue<string | null>(metadata, \"context\");\n if (context !== undefined) {\n block.context = context;\n }\n const title = _extractMetadataValue<string | null>(metadata, \"title\");\n if (title !== undefined) {\n block.title = title;\n }\n return block;\n}\n\nfunction _applyImageMetadata(\n block: Anthropic.Beta.BetaImageBlockParam,\n metadata: unknown\n): Anthropic.Beta.BetaImageBlockParam {\n const cacheControl =\n _extractMetadataValue<Anthropic.Beta.BetaCacheControlEphemeral | null>(\n metadata,\n \"cache_control\"\n );\n if (cacheControl !== undefined) {\n block.cache_control = cacheControl;\n }\n return block;\n}\n\nfunction _hasAllowedImageMimeType(\n mimeType: string\n): mimeType is \"image/jpeg\" | \"image/png\" | \"image/gif\" | \"image/webp\" {\n const ALLOWED_IMAGE_MIME_TYPES = new Set([\n \"image/jpeg\",\n \"image/png\",\n \"image/gif\",\n \"image/webp\",\n ]);\n return ALLOWED_IMAGE_MIME_TYPES.has(mimeType);\n}\n\nexport function _formatStandardContent(\n message: BaseMessage\n): Anthropic.Beta.BetaContentBlockParam[] {\n const result: Anthropic.Beta.BetaContentBlockParam[] = [];\n const responseMetadata = message.response_metadata as ResponseMetadata;\n const isAnthropicMessage =\n \"model_provider\" in responseMetadata &&\n responseMetadata?.model_provider === \"anthropic\";\n for (const block of message.contentBlocks) {\n if (block.type === \"text\") {\n if (block.annotations) {\n result.push({\n type: \"text\",\n text: block.text,\n citations: _formatStandardCitations(\n block.annotations as ContentBlock.Citation[]\n ),\n });\n } else {\n result.push({\n type: \"text\",\n text: block.text,\n });\n }\n } else if (block.type === \"tool_call\") {\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name,\n input: block.args,\n });\n } else if (block.type === \"tool_call_chunk\") {\n const input = iife(() => {\n if (typeof block.args !== \"string\") {\n return block.args;\n }\n try {\n return JSON.parse(block.args);\n } catch {\n return {};\n }\n });\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name ?? \"\",\n input,\n });\n } else if (block.type === \"reasoning\" && isAnthropicMessage) {\n result.push({\n type: \"thinking\",\n thinking: block.reasoning,\n signature: String(block.signature),\n });\n } else if (block.type === \"server_tool_call\" && isAnthropicMessage) {\n if (block.name === \"web_search\") {\n result.push({\n type: \"server_tool_use\",\n name: block.name,\n id: block.id ?? \"\",\n input: block.args,\n });\n } else if (block.name === \"code_execution\") {\n result.push({\n type: \"server_tool_use\",\n name: block.name,\n id: block.id ?? \"\",\n input: block.args,\n });\n }\n } else if (block.type === \"server_tool_call_result\" && isAnthropicMessage) {\n if (block.name === \"web_search\" && Array.isArray(block.output.urls)) {\n const content = block.output.urls.map((url) => ({\n type: \"web_search_result\" as const,\n title: \"\",\n encrypted_content: \"\",\n url,\n }));\n result.push({\n type: \"web_search_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n content,\n });\n } else if (block.name === \"code_execution\") {\n result.push({\n type: \"code_execution_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n content: block.output as any,\n });\n } else if (block.name === \"mcp_tool_result\") {\n result.push({\n type: \"mcp_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n content: block.output as any,\n });\n }\n } else if (block.type === \"audio\") {\n throw new Error(\"Anthropic does not support audio content blocks.\");\n } else if (block.type === \"file\") {\n const metadata = block.metadata;\n if (block.fileId) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"file\",\n file_id: block.fileId,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.url) {\n const mimeType = _normalizeMimeType(block.mimeType);\n if (mimeType === \"application/pdf\" || mimeType === \"\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n },\n metadata\n )\n );\n continue;\n }\n }\n if (block.data) {\n const mimeType = _normalizeMimeType(block.mimeType);\n if (mimeType === \"\" || mimeType === \"application/pdf\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: \"application/pdf\",\n },\n },\n metadata\n )\n );\n } else if (mimeType === \"text/plain\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"text\",\n data: _formatBase64Data(block.data),\n media_type: \"text/plain\",\n },\n },\n metadata\n )\n );\n } else {\n if (_hasAllowedImageMimeType(mimeType)) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: mimeType,\n },\n },\n ],\n },\n },\n metadata\n )\n );\n } else {\n throw new Error(\n `Unsupported file mime type for Anthropic base64 source: ${mimeType}`\n );\n }\n }\n continue;\n }\n throw new Error(\n \"File content block must include a fileId, url, or data property.\"\n );\n } else if (block.type === \"image\") {\n const metadata = block.metadata;\n if (block.fileId) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"file\",\n file_id: block.fileId,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.url) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.data) {\n const mimeType = _normalizeMimeType(block.mimeType) || \"image/png\";\n if (_hasAllowedImageMimeType(mimeType)) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: mimeType,\n },\n },\n metadata\n )\n );\n }\n continue;\n }\n throw new Error(\n \"Image content block must include a fileId, url, or data property.\"\n );\n } else if (block.type === \"video\") {\n // no-op\n } else if (block.type === \"text-plain\") {\n if (block.data) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"text\",\n data: _formatBase64Data(block.data),\n media_type: \"text/plain\",\n },\n },\n block.metadata\n )\n );\n }\n } else if (block.type === \"non_standard\" && isAnthropicMessage) {\n result.push(block.value as Anthropic.Beta.BetaContentBlockParam);\n }\n }\n return result;\n}\n"],"mappings":";;;AAQA,SAAS,sBACP,YACqC;AACrC,QACE,OAAO,eAAe,YACtB,eAAe,QACf,UAAU,cACV,WAAW,SAAS;;AAIxB,SAAS,yBACP,aACmC;CACnC,UAAU,qBAAqB;AAC7B,OAAK,MAAM,cAAc,YACvB,KAAI,sBAAsB,WAAW,EACnC;OAAI,WAAW,WAAW,OACxB,OAAM;IACJ,MAAM;IACN,S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;AACD;;AAEF,MAAI,MAAM,MAAM;GACd,MAAM,WAAW,mBAAmB,MAAM,SAAS,IAAI;AACvD,OAAI,yBAAyB,SAAS,CACpC,QAAO,KACL,oBACE;IACE,MAAM;IACN,QAAQ;KACN,MAAM;KACN,MAAM,kBAAkB,MAAM,KAAK;KACnC,YAAY;KACb;IACF,EACD,SACD,CACF;AAEH;;AAEF,QAAM,IAAI,MACR,oEACD;YACQ,MAAM,SAAS,SAAS,YAExB,MAAM,SAAS,cACxB;MAAI,MAAM,KACR,QAAO,KACL,uBACE;GACE,MAAM;GACN,QAAQ;IACN,MAAM;IACN,MAAM,kBAAkB,MAAM,KAAK;IACnC,YAAY;IACb;GACF,EACD,MAAM,SACP,CACF;YAEM,MAAM,SAAS,kBAAkB,mBAC1C,QAAO,KAAK,MAAM,MAA8C;AAGpE,QAAO"}
|
|
1
|
+
{"version":3,"file":"standard.cjs","names":["iife"],"sources":["../../src/utils/standard.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport type {\n BaseMessage,\n ContentBlock,\n ResponseMetadata,\n} from \"@langchain/core/messages\";\nimport { iife } from \"./index.js\";\n\nfunction _isStandardAnnotation(\n annotation: unknown\n): annotation is ContentBlock.Citation {\n return (\n typeof annotation === \"object\" &&\n annotation !== null &&\n \"type\" in annotation &&\n annotation.type === \"citation\"\n );\n}\n\nfunction _formatStandardCitations(\n annotations: ContentBlock.Citation[]\n): Anthropic.Beta.BetaTextCitation[] {\n function* iterateAnnotations() {\n for (const annotation of annotations) {\n if (_isStandardAnnotation(annotation)) {\n if (annotation.source === \"char\") {\n yield {\n type: \"char_location\" as const,\n file_id: annotation.url ?? \"\",\n start_char_index: annotation.startIndex ?? 0,\n end_char_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"page\") {\n yield {\n type: \"page_location\" as const,\n file_id: annotation.url ?? \"\",\n start_page_number: annotation.startIndex ?? 0,\n end_page_number: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"block\") {\n yield {\n type: \"content_block_location\" as const,\n file_id: annotation.url ?? \"\",\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"url\") {\n yield {\n type: \"web_search_result_location\" as const,\n url: annotation.url ?? \"\",\n title: annotation.title ?? null,\n encrypted_index: String(annotation.startIndex ?? 0),\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"search\") {\n yield {\n type: \"search_result_location\" as const,\n title: annotation.title ?? null,\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n search_result_index: 0,\n source: annotation.source ?? \"\",\n cited_text: annotation.citedText ?? \"\",\n };\n }\n }\n }\n }\n return Array.from(iterateAnnotations());\n}\n\nfunction _formatBase64Data(data: string | Uint8Array): string {\n if (typeof data === \"string\") return data;\n else return _encodeUint8Array(data);\n}\n\nfunction _encodeUint8Array(data: Uint8Array): string {\n const output = [];\n for (let i = 0, { length } = data; i < length; i++) {\n output.push(String.fromCharCode(data[i]));\n }\n return btoa(output.join(\"\"));\n}\n\nfunction _normalizeMimeType(mimeType?: string | null): string {\n return (mimeType ?? \"\").split(\";\")[0].toLowerCase();\n}\n\nfunction _extractMetadataValue<T>(\n metadata: unknown,\n key: string\n): T | undefined {\n if (\n metadata !== undefined &&\n metadata !== null &&\n typeof metadata === \"object\" &&\n key in metadata\n ) {\n return (metadata as Record<string, unknown>)[key] as T;\n }\n return undefined;\n}\n\nfunction _applyDocumentMetadata(\n block: Anthropic.Beta.BetaRequestDocumentBlock,\n metadata: unknown\n): Anthropic.Beta.BetaRequestDocumentBlock {\n const cacheControl =\n _extractMetadataValue<Anthropic.Beta.BetaCacheControlEphemeral | null>(\n metadata,\n \"cache_control\"\n );\n if (cacheControl !== undefined) {\n block.cache_control = cacheControl;\n }\n const citations =\n _extractMetadataValue<Anthropic.Beta.BetaCitationsConfigParam | null>(\n metadata,\n \"citations\"\n );\n if (citations !== undefined) {\n block.citations = citations;\n }\n const context = _extractMetadataValue<string | null>(metadata, \"context\");\n if (context !== undefined) {\n block.context = context;\n }\n const title = _extractMetadataValue<string | null>(metadata, \"title\");\n if (title !== undefined) {\n block.title = title;\n }\n return block;\n}\n\nfunction _applyImageMetadata(\n block: Anthropic.Beta.BetaImageBlockParam,\n metadata: unknown\n): Anthropic.Beta.BetaImageBlockParam {\n const cacheControl =\n _extractMetadataValue<Anthropic.Beta.BetaCacheControlEphemeral | null>(\n metadata,\n \"cache_control\"\n );\n if (cacheControl !== undefined) {\n block.cache_control = cacheControl;\n }\n return block;\n}\n\nfunction _hasAllowedImageMimeType(\n mimeType: string\n): mimeType is \"image/jpeg\" | \"image/png\" | \"image/gif\" | \"image/webp\" {\n const ALLOWED_IMAGE_MIME_TYPES = new Set([\n \"image/jpeg\",\n \"image/png\",\n \"image/gif\",\n \"image/webp\",\n ]);\n return ALLOWED_IMAGE_MIME_TYPES.has(mimeType);\n}\n\nexport function _formatStandardContent(\n message: BaseMessage\n): Anthropic.Beta.BetaContentBlockParam[] {\n const result: Anthropic.Beta.BetaContentBlockParam[] = [];\n const responseMetadata = message.response_metadata as ResponseMetadata;\n const isAnthropicMessage =\n \"model_provider\" in responseMetadata &&\n responseMetadata?.model_provider === \"anthropic\";\n for (const block of message.contentBlocks) {\n if (block.type === \"text\") {\n if (block.annotations) {\n result.push({\n type: \"text\",\n text: block.text,\n citations: _formatStandardCitations(\n block.annotations as ContentBlock.Citation[]\n ),\n });\n } else {\n result.push({\n type: \"text\",\n text: block.text,\n });\n }\n } else if (block.type === \"tool_call\") {\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name,\n input: block.args,\n });\n } else if (block.type === \"tool_call_chunk\") {\n const input = iife(() => {\n if (typeof block.args !== \"string\") {\n return block.args;\n }\n try {\n return JSON.parse(block.args);\n } catch {\n return {};\n }\n });\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name ?? \"\",\n input,\n });\n } else if (block.type === \"reasoning\" && isAnthropicMessage) {\n result.push({\n type: \"thinking\",\n thinking: block.reasoning,\n signature: String(block.signature),\n });\n } else if (block.type === \"server_tool_call\" && isAnthropicMessage) {\n if (block.name === \"web_search\") {\n result.push({\n type: \"server_tool_use\",\n name: block.name,\n id: block.id ?? \"\",\n input: block.args,\n });\n } else if (block.name === \"code_execution\") {\n result.push({\n type: \"server_tool_use\",\n name: block.name,\n id: block.id ?? \"\",\n input: block.args,\n });\n }\n } else if (block.type === \"server_tool_call_result\" && isAnthropicMessage) {\n if (block.name === \"web_search\" && Array.isArray(block.output.urls)) {\n const content = block.output.urls.map((url) => ({\n type: \"web_search_result\" as const,\n title: \"\",\n encrypted_content: \"\",\n url,\n }));\n result.push({\n type: \"web_search_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n content,\n });\n } else if (block.name === \"code_execution\") {\n result.push({\n type: \"code_execution_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n content: block.output as any,\n });\n } else if (block.name === \"mcp_tool_result\") {\n result.push({\n type: \"mcp_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n content: block.output as any,\n });\n }\n } else if (block.type === \"audio\") {\n throw new Error(\"Anthropic does not support audio content blocks.\");\n } else if (block.type === \"file\") {\n const metadata = block.metadata;\n if (block.fileId) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"file\",\n file_id: block.fileId,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.url) {\n const mimeType = _normalizeMimeType(block.mimeType);\n if (mimeType === \"application/pdf\" || mimeType === \"\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n },\n metadata\n )\n );\n continue;\n }\n }\n if (block.data) {\n const mimeType = _normalizeMimeType(block.mimeType);\n if (mimeType === \"\" || mimeType === \"application/pdf\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: \"application/pdf\",\n },\n },\n metadata\n )\n );\n } else if (mimeType === \"text/plain\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"text\",\n data: _formatBase64Data(block.data),\n media_type: \"text/plain\",\n },\n },\n metadata\n )\n );\n } else {\n if (_hasAllowedImageMimeType(mimeType)) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: mimeType,\n },\n },\n ],\n },\n },\n metadata\n )\n );\n } else {\n throw new Error(\n `Unsupported file mime type for Anthropic base64 source: ${mimeType}`\n );\n }\n }\n continue;\n }\n throw new Error(\n \"File content block must include a fileId, url, or data property.\"\n );\n } else if (block.type === \"image\") {\n const metadata = block.metadata;\n if (block.fileId) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"file\",\n file_id: block.fileId,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.url) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.data) {\n const mimeType = _normalizeMimeType(block.mimeType) || \"image/png\";\n if (_hasAllowedImageMimeType(mimeType)) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: mimeType,\n },\n },\n metadata\n )\n );\n }\n continue;\n }\n throw new Error(\n \"Image content block must include a fileId, url, or data property.\"\n );\n } else if (block.type === \"video\") {\n // no-op\n } else if (block.type === \"text-plain\") {\n if (block.data) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"text\",\n data: _formatBase64Data(block.data),\n media_type: \"text/plain\",\n },\n },\n block.metadata\n )\n );\n }\n } else if (block.type === \"non_standard\" && isAnthropicMessage) {\n result.push(block.value as Anthropic.Beta.BetaContentBlockParam);\n }\n }\n return result;\n}\n"],"mappings":";;AAQA,SAAS,sBACP,YACqC;AACrC,QACE,OAAO,eAAe,YACtB,eAAe,QACf,UAAU,cACV,WAAW,SAAS;;AAIxB,SAAS,yBACP,aACmC;CACnC,UAAU,qBAAqB;AAC7B,OAAK,MAAM,cAAc,YACvB,KAAI,sBAAsB,WAAW;OAC/B,WAAW,WAAW,OACxB,OAAM;IACJ,MAAM;IACN,SAAS,WAAW,OAAO;IAC3B,kBAAkB,WAAW,cAAc;IAC3C,gBAAgB,WAAW,YAAY;IACvC,gBAAgB,WAAW,SAAS;IACpC,gBAAgB;IAChB,YAAY,WAAW,aAAa;IACrC;YACQ,WAAW,WAAW,OAC/B,OAAM;IACJ,MAAM;IACN,SAAS,WAAW,OAAO;IAC3B,mBAAmB,WAAW,cAAc;IAC5C,iBAAiB,WAAW,YAAY;IACxC,gBAAgB,WAAW,SAAS;IACpC,gBAAgB;IAChB,YAAY,WAAW,aAAa;IACrC;YACQ,WAAW,WAAW,QAC/B,OAAM;IACJ,MAAM;IACN,SAAS,WAAW,OAAO;IAC3B,mBAAmB,WAAW,cAAc;IAC5C,iBAAiB,WAAW,YAAY;IACxC,gBAAgB,WAAW,SAAS;IACpC,gBAAgB;IAChB,YAAY,WAAW,aAAa;IACrC;YACQ,WAAW,WAAW,MAC/B,OAAM;IACJ,MAAM;IACN,KAAK,WAAW,OAAO;IACvB,OAAO,WAAW,SAAS;IAC3B,iBAAiB,OAAO,WAAW,cAAc,EAAE;IACnD,YAAY,WAAW,aAAa;IACrC;YACQ,WAAW,WAAW,SAC/B,OAAM;IACJ,MAAM;IACN,OAAO,W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;KACN,MAAM;KACN,SAAS,CACP;MACE,MAAM;MACN,QAAQ;OACN,MAAM;OACN,MAAM,kBAAkB,MAAM,KAAK;OACnC,YAAY;OACb;MACF,CACF;KACF;IACF,EACD,SACD,CACF;OAED,OAAM,IAAI,MACR,2DAA2D,WAC5D;AAGL;;AAEF,QAAM,IAAI,MACR,mEACD;YACQ,MAAM,SAAS,SAAS;EACjC,MAAM,WAAW,MAAM;AACvB,MAAI,MAAM,QAAQ;AAChB,UAAO,KACL,oBACE;IACE,MAAM;IACN,QAAQ;KACN,MAAM;KACN,SAAS,MAAM;KAChB;IACF,EACD,SACD,CACF;AACD;;AAEF,MAAI,MAAM,KAAK;AACb,UAAO,KACL,oBACE;IACE,MAAM;IACN,QAAQ;KACN,MAAM;KACN,KAAK,MAAM;KACZ;IACF,EACD,SACD,CACF;AACD;;AAEF,MAAI,MAAM,MAAM;GACd,MAAM,WAAW,mBAAmB,MAAM,SAAS,IAAI;AACvD,OAAI,yBAAyB,SAAS,CACpC,QAAO,KACL,oBACE;IACE,MAAM;IACN,QAAQ;KACN,MAAM;KACN,MAAM,kBAAkB,MAAM,KAAK;KACnC,YAAY;KACb;IACF,EACD,SACD,CACF;AAEH;;AAEF,QAAM,IAAI,MACR,oEACD;YACQ,MAAM,SAAS,SAAS,YAExB,MAAM,SAAS;MACpB,MAAM,KACR,QAAO,KACL,uBACE;GACE,MAAM;GACN,QAAQ;IACN,MAAM;IACN,MAAM,kBAAkB,MAAM,KAAK;IACnC,YAAY;IACb;GACF,EACD,MAAM,SACP,CACF;YAEM,MAAM,SAAS,kBAAkB,mBAC1C,QAAO,KAAK,MAAM,MAA8C;AAGpE,QAAO"}
|
package/dist/utils/standard.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { iife } from "./index.js";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/standard.ts
|
|
4
3
|
function _isStandardAnnotation(annotation) {
|
|
5
4
|
return typeof annotation === "object" && annotation !== null && "type" in annotation && annotation.type === "citation";
|
|
@@ -277,7 +276,7 @@ function _formatStandardContent(message) {
|
|
|
277
276
|
} else if (block.type === "non_standard" && isAnthropicMessage) result.push(block.value);
|
|
278
277
|
return result;
|
|
279
278
|
}
|
|
280
|
-
|
|
281
279
|
//#endregion
|
|
282
280
|
export { _formatStandardContent };
|
|
281
|
+
|
|
283
282
|
//# sourceMappingURL=standard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard.js","names":[],"sources":["../../src/utils/standard.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport type {\n BaseMessage,\n ContentBlock,\n ResponseMetadata,\n} from \"@langchain/core/messages\";\nimport { iife } from \"./index.js\";\n\nfunction _isStandardAnnotation(\n annotation: unknown\n): annotation is ContentBlock.Citation {\n return (\n typeof annotation === \"object\" &&\n annotation !== null &&\n \"type\" in annotation &&\n annotation.type === \"citation\"\n );\n}\n\nfunction _formatStandardCitations(\n annotations: ContentBlock.Citation[]\n): Anthropic.Beta.BetaTextCitation[] {\n function* iterateAnnotations() {\n for (const annotation of annotations) {\n if (_isStandardAnnotation(annotation)) {\n if (annotation.source === \"char\") {\n yield {\n type: \"char_location\" as const,\n file_id: annotation.url ?? \"\",\n start_char_index: annotation.startIndex ?? 0,\n end_char_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"page\") {\n yield {\n type: \"page_location\" as const,\n file_id: annotation.url ?? \"\",\n start_page_number: annotation.startIndex ?? 0,\n end_page_number: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"block\") {\n yield {\n type: \"content_block_location\" as const,\n file_id: annotation.url ?? \"\",\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"url\") {\n yield {\n type: \"web_search_result_location\" as const,\n url: annotation.url ?? \"\",\n title: annotation.title ?? null,\n encrypted_index: String(annotation.startIndex ?? 0),\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"search\") {\n yield {\n type: \"search_result_location\" as const,\n title: annotation.title ?? null,\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n search_result_index: 0,\n source: annotation.source ?? \"\",\n cited_text: annotation.citedText ?? \"\",\n };\n }\n }\n }\n }\n return Array.from(iterateAnnotations());\n}\n\nfunction _formatBase64Data(data: string | Uint8Array): string {\n if (typeof data === \"string\") return data;\n else return _encodeUint8Array(data);\n}\n\nfunction _encodeUint8Array(data: Uint8Array): string {\n const output = [];\n for (let i = 0, { length } = data; i < length; i++) {\n output.push(String.fromCharCode(data[i]));\n }\n return btoa(output.join(\"\"));\n}\n\nfunction _normalizeMimeType(mimeType?: string | null): string {\n return (mimeType ?? \"\").split(\";\")[0].toLowerCase();\n}\n\nfunction _extractMetadataValue<T>(\n metadata: unknown,\n key: string\n): T | undefined {\n if (\n metadata !== undefined &&\n metadata !== null &&\n typeof metadata === \"object\" &&\n key in metadata\n ) {\n return (metadata as Record<string, unknown>)[key] as T;\n }\n return undefined;\n}\n\nfunction _applyDocumentMetadata(\n block: Anthropic.Beta.BetaRequestDocumentBlock,\n metadata: unknown\n): Anthropic.Beta.BetaRequestDocumentBlock {\n const cacheControl =\n _extractMetadataValue<Anthropic.Beta.BetaCacheControlEphemeral | null>(\n metadata,\n \"cache_control\"\n );\n if (cacheControl !== undefined) {\n block.cache_control = cacheControl;\n }\n const citations =\n _extractMetadataValue<Anthropic.Beta.BetaCitationsConfigParam | null>(\n metadata,\n \"citations\"\n );\n if (citations !== undefined) {\n block.citations = citations;\n }\n const context = _extractMetadataValue<string | null>(metadata, \"context\");\n if (context !== undefined) {\n block.context = context;\n }\n const title = _extractMetadataValue<string | null>(metadata, \"title\");\n if (title !== undefined) {\n block.title = title;\n }\n return block;\n}\n\nfunction _applyImageMetadata(\n block: Anthropic.Beta.BetaImageBlockParam,\n metadata: unknown\n): Anthropic.Beta.BetaImageBlockParam {\n const cacheControl =\n _extractMetadataValue<Anthropic.Beta.BetaCacheControlEphemeral | null>(\n metadata,\n \"cache_control\"\n );\n if (cacheControl !== undefined) {\n block.cache_control = cacheControl;\n }\n return block;\n}\n\nfunction _hasAllowedImageMimeType(\n mimeType: string\n): mimeType is \"image/jpeg\" | \"image/png\" | \"image/gif\" | \"image/webp\" {\n const ALLOWED_IMAGE_MIME_TYPES = new Set([\n \"image/jpeg\",\n \"image/png\",\n \"image/gif\",\n \"image/webp\",\n ]);\n return ALLOWED_IMAGE_MIME_TYPES.has(mimeType);\n}\n\nexport function _formatStandardContent(\n message: BaseMessage\n): Anthropic.Beta.BetaContentBlockParam[] {\n const result: Anthropic.Beta.BetaContentBlockParam[] = [];\n const responseMetadata = message.response_metadata as ResponseMetadata;\n const isAnthropicMessage =\n \"model_provider\" in responseMetadata &&\n responseMetadata?.model_provider === \"anthropic\";\n for (const block of message.contentBlocks) {\n if (block.type === \"text\") {\n if (block.annotations) {\n result.push({\n type: \"text\",\n text: block.text,\n citations: _formatStandardCitations(\n block.annotations as ContentBlock.Citation[]\n ),\n });\n } else {\n result.push({\n type: \"text\",\n text: block.text,\n });\n }\n } else if (block.type === \"tool_call\") {\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name,\n input: block.args,\n });\n } else if (block.type === \"tool_call_chunk\") {\n const input = iife(() => {\n if (typeof block.args !== \"string\") {\n return block.args;\n }\n try {\n return JSON.parse(block.args);\n } catch {\n return {};\n }\n });\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name ?? \"\",\n input,\n });\n } else if (block.type === \"reasoning\" && isAnthropicMessage) {\n result.push({\n type: \"thinking\",\n thinking: block.reasoning,\n signature: String(block.signature),\n });\n } else if (block.type === \"server_tool_call\" && isAnthropicMessage) {\n if (block.name === \"web_search\") {\n result.push({\n type: \"server_tool_use\",\n name: block.name,\n id: block.id ?? \"\",\n input: block.args,\n });\n } else if (block.name === \"code_execution\") {\n result.push({\n type: \"server_tool_use\",\n name: block.name,\n id: block.id ?? \"\",\n input: block.args,\n });\n }\n } else if (block.type === \"server_tool_call_result\" && isAnthropicMessage) {\n if (block.name === \"web_search\" && Array.isArray(block.output.urls)) {\n const content = block.output.urls.map((url) => ({\n type: \"web_search_result\" as const,\n title: \"\",\n encrypted_content: \"\",\n url,\n }));\n result.push({\n type: \"web_search_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n content,\n });\n } else if (block.name === \"code_execution\") {\n result.push({\n type: \"code_execution_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n content: block.output as any,\n });\n } else if (block.name === \"mcp_tool_result\") {\n result.push({\n type: \"mcp_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n content: block.output as any,\n });\n }\n } else if (block.type === \"audio\") {\n throw new Error(\"Anthropic does not support audio content blocks.\");\n } else if (block.type === \"file\") {\n const metadata = block.metadata;\n if (block.fileId) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"file\",\n file_id: block.fileId,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.url) {\n const mimeType = _normalizeMimeType(block.mimeType);\n if (mimeType === \"application/pdf\" || mimeType === \"\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n },\n metadata\n )\n );\n continue;\n }\n }\n if (block.data) {\n const mimeType = _normalizeMimeType(block.mimeType);\n if (mimeType === \"\" || mimeType === \"application/pdf\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: \"application/pdf\",\n },\n },\n metadata\n )\n );\n } else if (mimeType === \"text/plain\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"text\",\n data: _formatBase64Data(block.data),\n media_type: \"text/plain\",\n },\n },\n metadata\n )\n );\n } else {\n if (_hasAllowedImageMimeType(mimeType)) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: mimeType,\n },\n },\n ],\n },\n },\n metadata\n )\n );\n } else {\n throw new Error(\n `Unsupported file mime type for Anthropic base64 source: ${mimeType}`\n );\n }\n }\n continue;\n }\n throw new Error(\n \"File content block must include a fileId, url, or data property.\"\n );\n } else if (block.type === \"image\") {\n const metadata = block.metadata;\n if (block.fileId) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"file\",\n file_id: block.fileId,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.url) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.data) {\n const mimeType = _normalizeMimeType(block.mimeType) || \"image/png\";\n if (_hasAllowedImageMimeType(mimeType)) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: mimeType,\n },\n },\n metadata\n )\n );\n }\n continue;\n }\n throw new Error(\n \"Image content block must include a fileId, url, or data property.\"\n );\n } else if (block.type === \"video\") {\n // no-op\n } else if (block.type === \"text-plain\") {\n if (block.data) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"text\",\n data: _formatBase64Data(block.data),\n media_type: \"text/plain\",\n },\n },\n block.metadata\n )\n );\n }\n } else if (block.type === \"non_standard\" && isAnthropicMessage) {\n result.push(block.value as Anthropic.Beta.BetaContentBlockParam);\n }\n }\n return result;\n}\n"],"mappings":";;;AAQA,SAAS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;AAChB,UAAO,KACL,oBACE;IACE,MAAM;IACN,QAAQ;KACN,MAAM;KACN,SAAS,MAAM;KAChB;IACF,EACD,SACD,CACF;AACD;;AAEF,MAAI,MAAM,KAAK;AACb,UAAO,KACL,oBACE;IACE,MAAM;IACN,QAAQ;KACN,MAAM;KACN,KAAK,MAAM;KACZ;IACF,EACD,SACD,CACF;AACD;;AAEF,MAAI,MAAM,MAAM;GACd,MAAM,WAAW,mBAAmB,MAAM,SAAS,IAAI;AACvD,OAAI,yBAAyB,SAAS,CACpC,QAAO,KACL,oBACE;IACE,MAAM;IACN,QAAQ;KACN,MAAM;KACN,MAAM,kBAAkB,MAAM,KAAK;KACnC,YAAY;KACb;IACF,EACD,SACD,CACF;AAEH;;AAEF,QAAM,IAAI,MACR,oEACD;YACQ,MAAM,SAAS,SAAS,YAExB,MAAM,SAAS,cACxB;MAAI,MAAM,KACR,QAAO,KACL,uBACE;GACE,MAAM;GACN,QAAQ;IACN,MAAM;IACN,MAAM,kBAAkB,MAAM,KAAK;IACnC,YAAY;IACb;GACF,EACD,MAAM,SACP,CACF;YAEM,MAAM,SAAS,kBAAkB,mBAC1C,QAAO,KAAK,MAAM,MAA8C;AAGpE,QAAO"}
|
|
1
|
+
{"version":3,"file":"standard.js","names":[],"sources":["../../src/utils/standard.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport type {\n BaseMessage,\n ContentBlock,\n ResponseMetadata,\n} from \"@langchain/core/messages\";\nimport { iife } from \"./index.js\";\n\nfunction _isStandardAnnotation(\n annotation: unknown\n): annotation is ContentBlock.Citation {\n return (\n typeof annotation === \"object\" &&\n annotation !== null &&\n \"type\" in annotation &&\n annotation.type === \"citation\"\n );\n}\n\nfunction _formatStandardCitations(\n annotations: ContentBlock.Citation[]\n): Anthropic.Beta.BetaTextCitation[] {\n function* iterateAnnotations() {\n for (const annotation of annotations) {\n if (_isStandardAnnotation(annotation)) {\n if (annotation.source === \"char\") {\n yield {\n type: \"char_location\" as const,\n file_id: annotation.url ?? \"\",\n start_char_index: annotation.startIndex ?? 0,\n end_char_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"page\") {\n yield {\n type: \"page_location\" as const,\n file_id: annotation.url ?? \"\",\n start_page_number: annotation.startIndex ?? 0,\n end_page_number: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"block\") {\n yield {\n type: \"content_block_location\" as const,\n file_id: annotation.url ?? \"\",\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"url\") {\n yield {\n type: \"web_search_result_location\" as const,\n url: annotation.url ?? \"\",\n title: annotation.title ?? null,\n encrypted_index: String(annotation.startIndex ?? 0),\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"search\") {\n yield {\n type: \"search_result_location\" as const,\n title: annotation.title ?? null,\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n search_result_index: 0,\n source: annotation.source ?? \"\",\n cited_text: annotation.citedText ?? \"\",\n };\n }\n }\n }\n }\n return Array.from(iterateAnnotations());\n}\n\nfunction _formatBase64Data(data: string | Uint8Array): string {\n if (typeof data === \"string\") return data;\n else return _encodeUint8Array(data);\n}\n\nfunction _encodeUint8Array(data: Uint8Array): string {\n const output = [];\n for (let i = 0, { length } = data; i < length; i++) {\n output.push(String.fromCharCode(data[i]));\n }\n return btoa(output.join(\"\"));\n}\n\nfunction _normalizeMimeType(mimeType?: string | null): string {\n return (mimeType ?? \"\").split(\";\")[0].toLowerCase();\n}\n\nfunction _extractMetadataValue<T>(\n metadata: unknown,\n key: string\n): T | undefined {\n if (\n metadata !== undefined &&\n metadata !== null &&\n typeof metadata === \"object\" &&\n key in metadata\n ) {\n return (metadata as Record<string, unknown>)[key] as T;\n }\n return undefined;\n}\n\nfunction _applyDocumentMetadata(\n block: Anthropic.Beta.BetaRequestDocumentBlock,\n metadata: unknown\n): Anthropic.Beta.BetaRequestDocumentBlock {\n const cacheControl =\n _extractMetadataValue<Anthropic.Beta.BetaCacheControlEphemeral | null>(\n metadata,\n \"cache_control\"\n );\n if (cacheControl !== undefined) {\n block.cache_control = cacheControl;\n }\n const citations =\n _extractMetadataValue<Anthropic.Beta.BetaCitationsConfigParam | null>(\n metadata,\n \"citations\"\n );\n if (citations !== undefined) {\n block.citations = citations;\n }\n const context = _extractMetadataValue<string | null>(metadata, \"context\");\n if (context !== undefined) {\n block.context = context;\n }\n const title = _extractMetadataValue<string | null>(metadata, \"title\");\n if (title !== undefined) {\n block.title = title;\n }\n return block;\n}\n\nfunction _applyImageMetadata(\n block: Anthropic.Beta.BetaImageBlockParam,\n metadata: unknown\n): Anthropic.Beta.BetaImageBlockParam {\n const cacheControl =\n _extractMetadataValue<Anthropic.Beta.BetaCacheControlEphemeral | null>(\n metadata,\n \"cache_control\"\n );\n if (cacheControl !== undefined) {\n block.cache_control = cacheControl;\n }\n return block;\n}\n\nfunction _hasAllowedImageMimeType(\n mimeType: string\n): mimeType is \"image/jpeg\" | \"image/png\" | \"image/gif\" | \"image/webp\" {\n const ALLOWED_IMAGE_MIME_TYPES = new Set([\n \"image/jpeg\",\n \"image/png\",\n \"image/gif\",\n \"image/webp\",\n ]);\n return ALLOWED_IMAGE_MIME_TYPES.has(mimeType);\n}\n\nexport function _formatStandardContent(\n message: BaseMessage\n): Anthropic.Beta.BetaContentBlockParam[] {\n const result: Anthropic.Beta.BetaContentBlockParam[] = [];\n const responseMetadata = message.response_metadata as ResponseMetadata;\n const isAnthropicMessage =\n \"model_provider\" in responseMetadata &&\n responseMetadata?.model_provider === \"anthropic\";\n for (const block of message.contentBlocks) {\n if (block.type === \"text\") {\n if (block.annotations) {\n result.push({\n type: \"text\",\n text: block.text,\n citations: _formatStandardCitations(\n block.annotations as ContentBlock.Citation[]\n ),\n });\n } else {\n result.push({\n type: \"text\",\n text: block.text,\n });\n }\n } else if (block.type === \"tool_call\") {\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name,\n input: block.args,\n });\n } else if (block.type === \"tool_call_chunk\") {\n const input = iife(() => {\n if (typeof block.args !== \"string\") {\n return block.args;\n }\n try {\n return JSON.parse(block.args);\n } catch {\n return {};\n }\n });\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name ?? \"\",\n input,\n });\n } else if (block.type === \"reasoning\" && isAnthropicMessage) {\n result.push({\n type: \"thinking\",\n thinking: block.reasoning,\n signature: String(block.signature),\n });\n } else if (block.type === \"server_tool_call\" && isAnthropicMessage) {\n if (block.name === \"web_search\") {\n result.push({\n type: \"server_tool_use\",\n name: block.name,\n id: block.id ?? \"\",\n input: block.args,\n });\n } else if (block.name === \"code_execution\") {\n result.push({\n type: \"server_tool_use\",\n name: block.name,\n id: block.id ?? \"\",\n input: block.args,\n });\n }\n } else if (block.type === \"server_tool_call_result\" && isAnthropicMessage) {\n if (block.name === \"web_search\" && Array.isArray(block.output.urls)) {\n const content = block.output.urls.map((url) => ({\n type: \"web_search_result\" as const,\n title: \"\",\n encrypted_content: \"\",\n url,\n }));\n result.push({\n type: \"web_search_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n content,\n });\n } else if (block.name === \"code_execution\") {\n result.push({\n type: \"code_execution_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n content: block.output as any,\n });\n } else if (block.name === \"mcp_tool_result\") {\n result.push({\n type: \"mcp_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n content: block.output as any,\n });\n }\n } else if (block.type === \"audio\") {\n throw new Error(\"Anthropic does not support audio content blocks.\");\n } else if (block.type === \"file\") {\n const metadata = block.metadata;\n if (block.fileId) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"file\",\n file_id: block.fileId,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.url) {\n const mimeType = _normalizeMimeType(block.mimeType);\n if (mimeType === \"application/pdf\" || mimeType === \"\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n },\n metadata\n )\n );\n continue;\n }\n }\n if (block.data) {\n const mimeType = _normalizeMimeType(block.mimeType);\n if (mimeType === \"\" || mimeType === \"application/pdf\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: \"application/pdf\",\n },\n },\n metadata\n )\n );\n } else if (mimeType === \"text/plain\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"text\",\n data: _formatBase64Data(block.data),\n media_type: \"text/plain\",\n },\n },\n metadata\n )\n );\n } else {\n if (_hasAllowedImageMimeType(mimeType)) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: mimeType,\n },\n },\n ],\n },\n },\n metadata\n )\n );\n } else {\n throw new Error(\n `Unsupported file mime type for Anthropic base64 source: ${mimeType}`\n );\n }\n }\n continue;\n }\n throw new Error(\n \"File content block must include a fileId, url, or data property.\"\n );\n } else if (block.type === \"image\") {\n const metadata = block.metadata;\n if (block.fileId) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"file\",\n file_id: block.fileId,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.url) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.data) {\n const mimeType = _normalizeMimeType(block.mimeType) || \"image/png\";\n if (_hasAllowedImageMimeType(mimeType)) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: mimeType,\n },\n },\n metadata\n )\n );\n }\n continue;\n }\n throw new Error(\n \"Image content block must include a fileId, url, or data property.\"\n );\n } else if (block.type === \"video\") {\n // no-op\n } else if (block.type === \"text-plain\") {\n if (block.data) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"text\",\n data: _formatBase64Data(block.data),\n media_type: \"text/plain\",\n },\n },\n block.metadata\n )\n );\n }\n } else if (block.type === \"non_standard\" && isAnthropicMessage) {\n result.push(block.value as Anthropic.Beta.BetaContentBlockParam);\n }\n }\n return result;\n}\n"],"mappings":";;AAQA,SAAS,sBACP,YACqC;AACrC,QACE,OAAO,eAAe,YACtB,eAAe,QACf,UAAU,cACV,WAAW,SAAS;;AAIxB,SAAS,yBACP,aACmC;CACnC,UAAU,qBAAqB;AAC7B,OAAK,MAAM,cAAc,YACvB,KAAI,sBAAsB,WAAW;OAC/B,WAAW,WAAW,OACxB,OAAM;IACJ,MAAM;IACN,SAAS,WAAW,OAAO;IAC3B,kBAAkB,WAAW,cAAc;IAC3C,gBAAgB,WAAW,YAAY;IACvC,gBAAgB,WAAW,SAAS;IACpC,gBAAgB;IAChB,YAAY,WAAW,aAAa;IACrC;YACQ,WAAW,WAAW,OAC/B,OAAM;IACJ,MAAM;IACN,SAAS,WAAW,OAAO;IAC3B,mBAAmB,WAAW,cAAc;IAC5C,iBAAiB,WAAW,YAAY;IACxC,gBAAgB,WAAW,SAAS;IACpC,gBAAgB;IAChB,YAAY,WAAW,aAAa;IACrC;YACQ,WAAW,WAAW,QAC/B,OAAM;IACJ,MAAM;IACN,SAAS,WAAW,OAAO;IAC3B,mBAAmB,WAAW,cAAc;IAC5C,iBAAiB,WAAW,YAAY;IACxC,gBAAgB,WAAW,SAAS;IACpC,gBAAgB;IAChB,YAAY,WAAW,aAAa;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C;AAGpE,QAAO"}
|
package/dist/utils/tools.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const require_runtime = require(
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let zod_v4 = require("zod/v4");
|
|
3
3
|
zod_v4 = require_runtime.__toESM(zod_v4);
|
|
4
|
-
|
|
5
4
|
//#region src/utils/tools.ts
|
|
6
5
|
function handleToolChoice(toolChoice) {
|
|
7
6
|
if (!toolChoice) return;
|
|
@@ -37,9 +36,9 @@ const ANTHROPIC_TOOL_BETAS = {
|
|
|
37
36
|
computer_20250124: "computer-use-2025-01-24",
|
|
38
37
|
mcp_toolset: "mcp-client-2025-11-20"
|
|
39
38
|
};
|
|
40
|
-
|
|
41
39
|
//#endregion
|
|
42
40
|
exports.ANTHROPIC_TOOL_BETAS = ANTHROPIC_TOOL_BETAS;
|
|
43
41
|
exports.AnthropicToolExtrasSchema = AnthropicToolExtrasSchema;
|
|
44
42
|
exports.handleToolChoice = handleToolChoice;
|
|
43
|
+
|
|
45
44
|
//# sourceMappingURL=tools.cjs.map
|
package/dist/utils/tools.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.cjs","names":["z"],"sources":["../../src/utils/tools.ts"],"sourcesContent":["import type { Anthropic } from \"@anthropic-ai/sdk\";\nimport * as z from \"zod/v4\";\nimport { AnthropicToolChoice } from \"../types.js\";\n\nexport function handleToolChoice(\n toolChoice?: AnthropicToolChoice\n):\n | Anthropic.Messages.ToolChoiceAuto\n | Anthropic.Messages.ToolChoiceAny\n | Anthropic.Messages.ToolChoiceTool\n | Anthropic.Messages.ToolChoiceNone\n | undefined {\n if (!toolChoice) {\n return undefined;\n } else if (toolChoice === \"any\") {\n return {\n type: \"any\",\n };\n } else if (toolChoice === \"auto\") {\n return {\n type: \"auto\",\n };\n } else if (toolChoice === \"none\") {\n return {\n type: \"none\",\n };\n } else if (typeof toolChoice === \"string\") {\n return {\n type: \"tool\",\n name: toolChoice,\n };\n } else {\n return toolChoice;\n }\n}\n\nexport const AnthropicToolExtrasSchema = z.object({\n cache_control: z\n .custom<Anthropic.Messages.CacheControlEphemeral>()\n .optional()\n .nullable(),\n defer_loading: z.boolean().optional(),\n input_examples: z.array(z.unknown()).optional(),\n allowed_callers: z.array(z.unknown()).optional(),\n});\n\n/**\n * Mapping of Anthropic tool types to their required beta feature flags.\n *\n * This constant defines which beta header is needed for specific tool types\n * when making requests to the Anthropic API. Beta features are experimental\n * capabilities that may change or be removed.\n */\nexport const ANTHROPIC_TOOL_BETAS: Record<string, string> = {\n tool_search_tool_regex_20251119: \"advanced-tool-use-2025-11-20\",\n tool_search_tool_bm25_20251119: \"advanced-tool-use-2025-11-20\",\n memory_20250818: \"context-management-2025-06-27\",\n web_fetch_20250910: \"web-fetch-2025-09-10\",\n code_execution_20250825: \"code-execution-2025-08-25\",\n computer_20251124: \"computer-use-2025-11-24\",\n computer_20250124: \"computer-use-2025-01-24\",\n mcp_toolset: \"mcp-client-2025-11-20\",\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools.cjs","names":["z"],"sources":["../../src/utils/tools.ts"],"sourcesContent":["import type { Anthropic } from \"@anthropic-ai/sdk\";\nimport * as z from \"zod/v4\";\nimport { AnthropicToolChoice } from \"../types.js\";\n\nexport function handleToolChoice(\n toolChoice?: AnthropicToolChoice\n):\n | Anthropic.Messages.ToolChoiceAuto\n | Anthropic.Messages.ToolChoiceAny\n | Anthropic.Messages.ToolChoiceTool\n | Anthropic.Messages.ToolChoiceNone\n | undefined {\n if (!toolChoice) {\n return undefined;\n } else if (toolChoice === \"any\") {\n return {\n type: \"any\",\n };\n } else if (toolChoice === \"auto\") {\n return {\n type: \"auto\",\n };\n } else if (toolChoice === \"none\") {\n return {\n type: \"none\",\n };\n } else if (typeof toolChoice === \"string\") {\n return {\n type: \"tool\",\n name: toolChoice,\n };\n } else {\n return toolChoice;\n }\n}\n\nexport const AnthropicToolExtrasSchema = z.object({\n cache_control: z\n .custom<Anthropic.Messages.CacheControlEphemeral>()\n .optional()\n .nullable(),\n defer_loading: z.boolean().optional(),\n input_examples: z.array(z.unknown()).optional(),\n allowed_callers: z.array(z.unknown()).optional(),\n});\n\n/**\n * Mapping of Anthropic tool types to their required beta feature flags.\n *\n * This constant defines which beta header is needed for specific tool types\n * when making requests to the Anthropic API. Beta features are experimental\n * capabilities that may change or be removed.\n */\nexport const ANTHROPIC_TOOL_BETAS: Record<string, string> = {\n tool_search_tool_regex_20251119: \"advanced-tool-use-2025-11-20\",\n tool_search_tool_bm25_20251119: \"advanced-tool-use-2025-11-20\",\n memory_20250818: \"context-management-2025-06-27\",\n web_fetch_20250910: \"web-fetch-2025-09-10\",\n code_execution_20250825: \"code-execution-2025-08-25\",\n computer_20251124: \"computer-use-2025-11-24\",\n computer_20250124: \"computer-use-2025-01-24\",\n mcp_toolset: \"mcp-client-2025-11-20\",\n};\n"],"mappings":";;;;AAIA,SAAgB,iBACd,YAMY;AACZ,KAAI,CAAC,WACH;UACS,eAAe,MACxB,QAAO,EACL,MAAM,OACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,QACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,QACP;UACQ,OAAO,eAAe,SAC/B,QAAO;EACL,MAAM;EACN,MAAM;EACP;KAED,QAAO;;AAIX,MAAa,4BAA4BA,OAAE,OAAO;CAChD,eAAeA,OACZ,QAAkD,CAClD,UAAU,CACV,UAAU;CACb,eAAeA,OAAE,SAAS,CAAC,UAAU;CACrC,gBAAgBA,OAAE,MAAMA,OAAE,SAAS,CAAC,CAAC,UAAU;CAC/C,iBAAiBA,OAAE,MAAMA,OAAE,SAAS,CAAC,CAAC,UAAU;CACjD,CAAC;;;;;;;;AASF,MAAa,uBAA+C;CAC1D,iCAAiC;CACjC,gCAAgC;CAChC,iBAAiB;CACjB,oBAAoB;CACpB,yBAAyB;CACzB,mBAAmB;CACnB,mBAAmB;CACnB,aAAa;CACd"}
|
package/dist/utils/tools.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as z$1 from "zod/v4";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/tools.ts
|
|
4
3
|
function handleToolChoice(toolChoice) {
|
|
5
4
|
if (!toolChoice) return;
|
|
@@ -35,7 +34,7 @@ const ANTHROPIC_TOOL_BETAS = {
|
|
|
35
34
|
computer_20250124: "computer-use-2025-01-24",
|
|
36
35
|
mcp_toolset: "mcp-client-2025-11-20"
|
|
37
36
|
};
|
|
38
|
-
|
|
39
37
|
//#endregion
|
|
40
38
|
export { ANTHROPIC_TOOL_BETAS, AnthropicToolExtrasSchema, handleToolChoice };
|
|
39
|
+
|
|
41
40
|
//# sourceMappingURL=tools.js.map
|
package/dist/utils/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","names":["z"],"sources":["../../src/utils/tools.ts"],"sourcesContent":["import type { Anthropic } from \"@anthropic-ai/sdk\";\nimport * as z from \"zod/v4\";\nimport { AnthropicToolChoice } from \"../types.js\";\n\nexport function handleToolChoice(\n toolChoice?: AnthropicToolChoice\n):\n | Anthropic.Messages.ToolChoiceAuto\n | Anthropic.Messages.ToolChoiceAny\n | Anthropic.Messages.ToolChoiceTool\n | Anthropic.Messages.ToolChoiceNone\n | undefined {\n if (!toolChoice) {\n return undefined;\n } else if (toolChoice === \"any\") {\n return {\n type: \"any\",\n };\n } else if (toolChoice === \"auto\") {\n return {\n type: \"auto\",\n };\n } else if (toolChoice === \"none\") {\n return {\n type: \"none\",\n };\n } else if (typeof toolChoice === \"string\") {\n return {\n type: \"tool\",\n name: toolChoice,\n };\n } else {\n return toolChoice;\n }\n}\n\nexport const AnthropicToolExtrasSchema = z.object({\n cache_control: z\n .custom<Anthropic.Messages.CacheControlEphemeral>()\n .optional()\n .nullable(),\n defer_loading: z.boolean().optional(),\n input_examples: z.array(z.unknown()).optional(),\n allowed_callers: z.array(z.unknown()).optional(),\n});\n\n/**\n * Mapping of Anthropic tool types to their required beta feature flags.\n *\n * This constant defines which beta header is needed for specific tool types\n * when making requests to the Anthropic API. Beta features are experimental\n * capabilities that may change or be removed.\n */\nexport const ANTHROPIC_TOOL_BETAS: Record<string, string> = {\n tool_search_tool_regex_20251119: \"advanced-tool-use-2025-11-20\",\n tool_search_tool_bm25_20251119: \"advanced-tool-use-2025-11-20\",\n memory_20250818: \"context-management-2025-06-27\",\n web_fetch_20250910: \"web-fetch-2025-09-10\",\n code_execution_20250825: \"code-execution-2025-08-25\",\n computer_20251124: \"computer-use-2025-11-24\",\n computer_20250124: \"computer-use-2025-01-24\",\n mcp_toolset: \"mcp-client-2025-11-20\",\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools.js","names":["z"],"sources":["../../src/utils/tools.ts"],"sourcesContent":["import type { Anthropic } from \"@anthropic-ai/sdk\";\nimport * as z from \"zod/v4\";\nimport { AnthropicToolChoice } from \"../types.js\";\n\nexport function handleToolChoice(\n toolChoice?: AnthropicToolChoice\n):\n | Anthropic.Messages.ToolChoiceAuto\n | Anthropic.Messages.ToolChoiceAny\n | Anthropic.Messages.ToolChoiceTool\n | Anthropic.Messages.ToolChoiceNone\n | undefined {\n if (!toolChoice) {\n return undefined;\n } else if (toolChoice === \"any\") {\n return {\n type: \"any\",\n };\n } else if (toolChoice === \"auto\") {\n return {\n type: \"auto\",\n };\n } else if (toolChoice === \"none\") {\n return {\n type: \"none\",\n };\n } else if (typeof toolChoice === \"string\") {\n return {\n type: \"tool\",\n name: toolChoice,\n };\n } else {\n return toolChoice;\n }\n}\n\nexport const AnthropicToolExtrasSchema = z.object({\n cache_control: z\n .custom<Anthropic.Messages.CacheControlEphemeral>()\n .optional()\n .nullable(),\n defer_loading: z.boolean().optional(),\n input_examples: z.array(z.unknown()).optional(),\n allowed_callers: z.array(z.unknown()).optional(),\n});\n\n/**\n * Mapping of Anthropic tool types to their required beta feature flags.\n *\n * This constant defines which beta header is needed for specific tool types\n * when making requests to the Anthropic API. Beta features are experimental\n * capabilities that may change or be removed.\n */\nexport const ANTHROPIC_TOOL_BETAS: Record<string, string> = {\n tool_search_tool_regex_20251119: \"advanced-tool-use-2025-11-20\",\n tool_search_tool_bm25_20251119: \"advanced-tool-use-2025-11-20\",\n memory_20250818: \"context-management-2025-06-27\",\n web_fetch_20250910: \"web-fetch-2025-09-10\",\n code_execution_20250825: \"code-execution-2025-08-25\",\n computer_20251124: \"computer-use-2025-11-24\",\n computer_20250124: \"computer-use-2025-01-24\",\n mcp_toolset: \"mcp-client-2025-11-20\",\n};\n"],"mappings":";;AAIA,SAAgB,iBACd,YAMY;AACZ,KAAI,CAAC,WACH;UACS,eAAe,MACxB,QAAO,EACL,MAAM,OACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,QACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,QACP;UACQ,OAAO,eAAe,SAC/B,QAAO;EACL,MAAM;EACN,MAAM;EACP;KAED,QAAO;;AAIX,MAAa,4BAA4BA,IAAE,OAAO;CAChD,eAAeA,IACZ,QAAkD,CAClD,UAAU,CACV,UAAU;CACb,eAAeA,IAAE,SAAS,CAAC,UAAU;CACrC,gBAAgBA,IAAE,MAAMA,IAAE,SAAS,CAAC,CAAC,UAAU;CAC/C,iBAAiBA,IAAE,MAAMA,IAAE,SAAS,CAAC,CAAC,UAAU;CACjD,CAAC;;;;;;;;AASF,MAAa,uBAA+C;CAC1D,iCAAiC;CACjC,gCAAgC;CAChC,iBAAiB;CACjB,oBAAoB;CACpB,yBAAyB;CACzB,mBAAmB;CACnB,mBAAmB;CACnB,aAAa;CACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/anthropic",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.24-dev-1773698445534",
|
|
4
4
|
"description": "Anthropic integrations for LangChain.js",
|
|
5
5
|
"author": "LangChain",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"zod": "^3.25.76 || ^4"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@langchain/core": "^1.1.
|
|
21
|
+
"@langchain/core": "^1.1.33-dev-1773698445534"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@anthropic-ai/vertex-sdk": "^0.14.4",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"typescript": "~5.8.3",
|
|
34
34
|
"uuid": "^13.0.0",
|
|
35
35
|
"vitest": "^3.2.4",
|
|
36
|
-
"@langchain/core": "^1.1.
|
|
36
|
+
"@langchain/core": "^1.1.33-dev-1773698445534",
|
|
37
37
|
"@langchain/standard-tests": "0.0.23",
|
|
38
38
|
"@langchain/eslint": "0.1.1",
|
|
39
39
|
"@langchain/tsconfig": "0.0.1"
|