@langchain/anthropic 1.3.25 → 1.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @langchain/anthropic
2
2
 
3
+ ## 1.3.26
4
+
5
+ ### Patch Changes
6
+
7
+ - [#10519](https://github.com/langchain-ai/langchainjs/pull/10519) [`cd86fea`](https://github.com/langchain-ai/langchainjs/commit/cd86fea8de2130d0df60805baada81958d47c747) Thanks [@baptistejamin](https://github.com/baptistejamin)! - fix: implement tool choice required on anthropic
8
+
9
+ - Updated dependencies [[`589ab9b`](https://github.com/langchain-ai/langchainjs/commit/589ab9be391a5d6c104f34877fc1b3e2a32fa449)]:
10
+ - @langchain/core@1.1.38
11
+
3
12
  ## 1.3.25
4
13
 
5
14
  ### Patch Changes
@@ -648,7 +648,7 @@ var ChatAnthropicMessages = class extends _langchain_core_language_models_chat_m
648
648
  model: modelOrFields
649
649
  } : modelOrFields ?? {};
650
650
  super(fields ?? {});
651
- this._addVersion("@langchain/anthropic", "1.3.25");
651
+ this._addVersion("@langchain/anthropic", "1.3.26");
652
652
  this.anthropicApiKey = fields?.apiKey ?? fields?.anthropicApiKey ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("ANTHROPIC_API_KEY");
653
653
  if (!this.anthropicApiKey && !fields?.createClient) throw new Error("Anthropic API key not found");
654
654
  this.clientOptions = fields?.clientOptions ?? {};
@@ -647,7 +647,7 @@ var ChatAnthropicMessages = class extends BaseChatModel {
647
647
  model: modelOrFields
648
648
  } : modelOrFields ?? {};
649
649
  super(fields ?? {});
650
- this._addVersion("@langchain/anthropic", "1.3.25");
650
+ this._addVersion("@langchain/anthropic", "1.3.26");
651
651
  this.anthropicApiKey = fields?.apiKey ?? fields?.anthropicApiKey ?? getEnvironmentVariable("ANTHROPIC_API_KEY");
652
652
  if (!this.anthropicApiKey && !fields?.createClient) throw new Error("Anthropic API key not found");
653
653
  this.clientOptions = fields?.clientOptions ?? {};
@@ -4,7 +4,7 @@ zod_v4 = require_runtime.__toESM(zod_v4);
4
4
  //#region src/utils/tools.ts
5
5
  function handleToolChoice(toolChoice) {
6
6
  if (!toolChoice) return;
7
- else if (toolChoice === "any") return { type: "any" };
7
+ else if (toolChoice === "any" || toolChoice === "required") return { type: "any" };
8
8
  else if (toolChoice === "auto") return { type: "auto" };
9
9
  else if (toolChoice === "none") return { type: "none" };
10
10
  else if (typeof toolChoice === "string") return {
@@ -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":";;;;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"}
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\" || toolChoice === \"required\") {\n // \"required\" is OpenAI-style, map to Anthropic's \"any\" which forces tool use\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,SAAS,eAAe,WAEhD,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"}
@@ -2,7 +2,7 @@ import * as z$1 from "zod/v4";
2
2
  //#region src/utils/tools.ts
3
3
  function handleToolChoice(toolChoice) {
4
4
  if (!toolChoice) return;
5
- else if (toolChoice === "any") return { type: "any" };
5
+ else if (toolChoice === "any" || toolChoice === "required") return { type: "any" };
6
6
  else if (toolChoice === "auto") return { type: "auto" };
7
7
  else if (toolChoice === "none") return { type: "none" };
8
8
  else if (typeof toolChoice === "string") return {
@@ -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":";;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"}
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\" || toolChoice === \"required\") {\n // \"required\" is OpenAI-style, map to Anthropic's \"any\" which forces tool use\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,SAAS,eAAe,WAEhD,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.25",
3
+ "version": "1.3.26",
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.34"
21
+ "@langchain/core": "^1.1.38"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@anthropic-ai/vertex-sdk": "^0.14.4",
@@ -33,10 +33,10 @@
33
33
  "typescript": "~5.8.3",
34
34
  "uuid": "^13.0.0",
35
35
  "vitest": "^3.2.4",
36
- "@langchain/core": "^1.1.34",
36
+ "@langchain/core": "^1.1.38",
37
+ "@langchain/eslint": "0.1.1",
37
38
  "@langchain/standard-tests": "0.0.23",
38
- "@langchain/tsconfig": "0.0.1",
39
- "@langchain/eslint": "0.1.1"
39
+ "@langchain/tsconfig": "0.0.1"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"