@ai-sdk/anthropic 2.0.69 → 2.0.71

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,17 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 2.0.71
4
+
5
+ ### Patch Changes
6
+
7
+ - b0a0821: feat (provider/anthropic): support passing metadata.user_id
8
+
9
+ ## 2.0.70
10
+
11
+ ### Patch Changes
12
+
13
+ - a9a7f73: feat(anthropic): support eagerInputStreaming option for fine-grained tool streaming
14
+
3
15
  ## 2.0.69
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -147,6 +147,9 @@ declare const anthropicProviderOptions: z.ZodObject<{
147
147
  type: z.ZodLiteral<"ephemeral">;
148
148
  ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
149
149
  }, z.core.$strip>>;
150
+ metadata: z.ZodOptional<z.ZodObject<{
151
+ userId: z.ZodOptional<z.ZodString>;
152
+ }, z.core.$strip>>;
150
153
  container: z.ZodOptional<z.ZodObject<{
151
154
  id: z.ZodOptional<z.ZodString>;
152
155
  skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
package/dist/index.d.ts CHANGED
@@ -147,6 +147,9 @@ declare const anthropicProviderOptions: z.ZodObject<{
147
147
  type: z.ZodLiteral<"ephemeral">;
148
148
  ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
149
149
  }, z.core.$strip>>;
150
+ metadata: z.ZodOptional<z.ZodObject<{
151
+ userId: z.ZodOptional<z.ZodString>;
152
+ }, z.core.$strip>>;
150
153
  container: z.ZodOptional<z.ZodObject<{
151
154
  id: z.ZodOptional<z.ZodString>;
152
155
  skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
package/dist/index.js CHANGED
@@ -18,20 +18,20 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  VERSION: () => VERSION,
24
24
  anthropic: () => anthropic,
25
25
  createAnthropic: () => createAnthropic
26
26
  });
27
- module.exports = __toCommonJS(src_exports);
27
+ module.exports = __toCommonJS(index_exports);
28
28
 
29
29
  // src/anthropic-provider.ts
30
30
  var import_provider4 = require("@ai-sdk/provider");
31
31
  var import_provider_utils20 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/version.ts
34
- var VERSION = true ? "2.0.69" : "0.0.0-test";
34
+ var VERSION = true ? "2.0.71" : "0.0.0-test";
35
35
 
36
36
  // src/anthropic-messages-language-model.ts
37
37
  var import_provider3 = require("@ai-sdk/provider");
@@ -673,6 +673,20 @@ var anthropicProviderOptions = import_v43.z.object({
673
673
  type: import_v43.z.literal("ephemeral"),
674
674
  ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
675
675
  }).optional(),
676
+ /**
677
+ * Metadata to include with the request.
678
+ *
679
+ * See https://platform.claude.com/docs/en/api/messages/create for details.
680
+ */
681
+ metadata: import_v43.z.object({
682
+ /**
683
+ * An external identifier for the user associated with the request.
684
+ *
685
+ * Should be a UUID, hash value, or other opaque identifier.
686
+ * Must not contain PII (name, email, phone number, etc.).
687
+ */
688
+ userId: import_v43.z.string().optional()
689
+ }).optional(),
676
690
  /**
677
691
  * Agent Skills configuration. Skills enable Claude to perform specialized tasks
678
692
  * like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
@@ -948,6 +962,7 @@ async function prepareTools({
948
962
  disableParallelToolUse,
949
963
  cacheControlValidator
950
964
  }) {
965
+ var _a;
951
966
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
952
967
  const toolWarnings = [];
953
968
  const betas = /* @__PURE__ */ new Set();
@@ -963,11 +978,14 @@ async function prepareTools({
963
978
  type: "tool definition",
964
979
  canCache: true
965
980
  });
981
+ const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
982
+ const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
966
983
  anthropicTools2.push({
967
984
  name: tool.name,
968
985
  description: tool.description,
969
986
  input_schema: tool.inputSchema,
970
- cache_control: cacheControl
987
+ cache_control: cacheControl,
988
+ ...eagerInputStreaming ? { eager_input_streaming: true } : {}
971
989
  });
972
990
  break;
973
991
  }
@@ -1947,7 +1965,7 @@ var AnthropicMessagesLanguageModel = class {
1947
1965
  toolChoice,
1948
1966
  providerOptions
1949
1967
  }) {
1950
- var _a, _b, _c, _d, _e, _f;
1968
+ var _a, _b, _c, _d, _e, _f, _g;
1951
1969
  const warnings = [];
1952
1970
  if (frequencyPenalty != null) {
1953
1971
  warnings.push({
@@ -2051,6 +2069,9 @@ var AnthropicMessagesLanguageModel = class {
2051
2069
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
2052
2070
  cache_control: anthropicOptions.cacheControl
2053
2071
  },
2072
+ ...((_e = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _e.userId) != null && {
2073
+ metadata: { user_id: anthropicOptions.metadata.userId }
2074
+ },
2054
2075
  // structured output:
2055
2076
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2056
2077
  output_format: {
@@ -2062,7 +2083,7 @@ var AnthropicMessagesLanguageModel = class {
2062
2083
  ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
2063
2084
  container: {
2064
2085
  id: anthropicOptions.container.id,
2065
- skills: (_e = anthropicOptions.container.skills) == null ? void 0 : _e.map((skill) => ({
2086
+ skills: (_f = anthropicOptions.container.skills) == null ? void 0 : _f.map((skill) => ({
2066
2087
  type: skill.type,
2067
2088
  skill_id: skill.skillId,
2068
2089
  version: skill.version
@@ -2225,7 +2246,7 @@ var AnthropicMessagesLanguageModel = class {
2225
2246
  ...betas,
2226
2247
  ...toolsBetas,
2227
2248
  ...userSuppliedBetas,
2228
- ...(_f = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _f : []
2249
+ ...(_g = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _g : []
2229
2250
  ]),
2230
2251
  usesJsonResponseTool: jsonResponseTool != null
2231
2252
  };