@langchain/anthropic 1.1.3 → 1.2.1

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.
@@ -1,3 +1,5 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const zod_v4 = require_rolldown_runtime.__toESM(require("zod/v4"));
1
3
 
2
4
  //#region src/utils/tools.ts
3
5
  function handleToolChoice(toolChoice) {
@@ -11,7 +13,25 @@ function handleToolChoice(toolChoice) {
11
13
  };
12
14
  else return toolChoice;
13
15
  }
16
+ const AnthropicToolExtrasSchema = zod_v4.object({
17
+ cache_control: zod_v4.custom().optional().nullable(),
18
+ defer_loading: zod_v4.boolean().optional(),
19
+ input_examples: zod_v4.array(zod_v4.unknown()).optional()
20
+ });
21
+ /**
22
+ * Mapping of Anthropic tool types to their required beta feature flags.
23
+ *
24
+ * This constant defines which beta header is needed for specific tool types
25
+ * when making requests to the Anthropic API. Beta features are experimental
26
+ * capabilities that may change or be removed.
27
+ */
28
+ const ANTHROPIC_TOOL_BETAS = {
29
+ tool_search_tool_regex_20251119: "advanced-tool-use-2025-11-20",
30
+ tool_search_tool_bm25_20251119: "advanced-tool-use-2025-11-20"
31
+ };
14
32
 
15
33
  //#endregion
34
+ exports.ANTHROPIC_TOOL_BETAS = ANTHROPIC_TOOL_BETAS;
35
+ exports.AnthropicToolExtrasSchema = AnthropicToolExtrasSchema;
16
36
  exports.handleToolChoice = handleToolChoice;
17
37
  //# sourceMappingURL=tools.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.cjs","names":["toolChoice?: AnthropicToolChoice"],"sources":["../../src/utils/tools.ts"],"sourcesContent":["import type { Anthropic } from \"@anthropic-ai/sdk\";\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"],"mappings":";;AAGA,SAAgB,iBACdA,YAMY;AACZ,KAAI,CAAC,WACH,QAAO;UACE,eAAe,MACxB,QAAO,EACL,MAAM,MACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,OAAO,eAAe,SAC/B,QAAO;EACL,MAAM;EACN,MAAM;CACP;KAED,QAAO;AAEV"}
1
+ {"version":3,"file":"tools.cjs","names":["toolChoice?: AnthropicToolChoice","z","ANTHROPIC_TOOL_BETAS: Record<string, string>"],"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});\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};\n"],"mappings":";;;;AAIA,SAAgB,iBACdA,YAMY;AACZ,KAAI,CAAC,WACH,QAAO;UACE,eAAe,MACxB,QAAO,EACL,MAAM,MACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,OAAO,eAAe,SAC/B,QAAO;EACL,MAAM;EACN,MAAM;CACP;KAED,QAAO;AAEV;AAED,MAAa,4BAA4BC,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;AAChD,EAAC;;;;;;;;AASF,MAAaC,uBAA+C;CAC1D,iCAAiC;CACjC,gCAAgC;AACjC"}
@@ -1,3 +1,5 @@
1
+ import * as z from "zod/v4";
2
+
1
3
  //#region src/utils/tools.ts
2
4
  function handleToolChoice(toolChoice) {
3
5
  if (!toolChoice) return void 0;
@@ -10,7 +12,23 @@ function handleToolChoice(toolChoice) {
10
12
  };
11
13
  else return toolChoice;
12
14
  }
15
+ const AnthropicToolExtrasSchema = z.object({
16
+ cache_control: z.custom().optional().nullable(),
17
+ defer_loading: z.boolean().optional(),
18
+ input_examples: z.array(z.unknown()).optional()
19
+ });
20
+ /**
21
+ * Mapping of Anthropic tool types to their required beta feature flags.
22
+ *
23
+ * This constant defines which beta header is needed for specific tool types
24
+ * when making requests to the Anthropic API. Beta features are experimental
25
+ * capabilities that may change or be removed.
26
+ */
27
+ const ANTHROPIC_TOOL_BETAS = {
28
+ tool_search_tool_regex_20251119: "advanced-tool-use-2025-11-20",
29
+ tool_search_tool_bm25_20251119: "advanced-tool-use-2025-11-20"
30
+ };
13
31
 
14
32
  //#endregion
15
- export { handleToolChoice };
33
+ export { ANTHROPIC_TOOL_BETAS, AnthropicToolExtrasSchema, handleToolChoice };
16
34
  //# sourceMappingURL=tools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","names":["toolChoice?: AnthropicToolChoice"],"sources":["../../src/utils/tools.ts"],"sourcesContent":["import type { Anthropic } from \"@anthropic-ai/sdk\";\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"],"mappings":";AAGA,SAAgB,iBACdA,YAMY;AACZ,KAAI,CAAC,WACH,QAAO;UACE,eAAe,MACxB,QAAO,EACL,MAAM,MACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,OAAO,eAAe,SAC/B,QAAO;EACL,MAAM;EACN,MAAM;CACP;KAED,QAAO;AAEV"}
1
+ {"version":3,"file":"tools.js","names":["toolChoice?: AnthropicToolChoice","ANTHROPIC_TOOL_BETAS: Record<string, string>"],"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});\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};\n"],"mappings":";;;AAIA,SAAgB,iBACdA,YAMY;AACZ,KAAI,CAAC,WACH,QAAO;UACE,eAAe,MACxB,QAAO,EACL,MAAM,MACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,OAAO,eAAe,SAC/B,QAAO;EACL,MAAM;EACN,MAAM;CACP;KAED,QAAO;AAEV;AAED,MAAa,4BAA4B,EAAE,OAAO;CAChD,eAAe,EACZ,QAAkD,CAClD,UAAU,CACV,UAAU;CACb,eAAe,EAAE,SAAS,CAAC,UAAU;CACrC,gBAAgB,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,UAAU;AAChD,EAAC;;;;;;;;AASF,MAAaC,uBAA+C;CAC1D,iCAAiC;CACjC,gCAAgC;AACjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/anthropic",
3
- "version": "1.1.3",
3
+ "version": "1.2.1",
4
4
  "description": "Anthropic integrations for LangChain.js",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -14,10 +14,11 @@
14
14
  },
15
15
  "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-anthropic/",
16
16
  "dependencies": {
17
- "@anthropic-ai/sdk": "^0.71.0"
17
+ "@anthropic-ai/sdk": "^0.71.0",
18
+ "zod": "^3.25.76 || ^4"
18
19
  },
19
20
  "peerDependencies": {
20
- "@langchain/core": "^1.0.0"
21
+ "@langchain/core": "1.1.2"
21
22
  },
22
23
  "devDependencies": {
23
24
  "@anthropic-ai/vertex-sdk": "^0.11.5",
@@ -32,10 +33,9 @@
32
33
  "typescript": "~5.8.3",
33
34
  "uuid": "^13.0.0",
34
35
  "vitest": "^3.2.4",
35
- "zod": "3.25.76",
36
- "@langchain/core": "1.1.0",
37
- "@langchain/standard-tests": "0.0.3",
38
- "@langchain/eslint": "0.1.1"
36
+ "@langchain/core": "1.1.2",
37
+ "@langchain/eslint": "0.1.1",
38
+ "@langchain/standard-tests": "0.0.5"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"