@ai-sdk/anthropic 2.0.70 → 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,11 @@
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
+
3
9
  ## 2.0.70
4
10
 
5
11
  ### 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.70" : "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.
@@ -1951,7 +1965,7 @@ var AnthropicMessagesLanguageModel = class {
1951
1965
  toolChoice,
1952
1966
  providerOptions
1953
1967
  }) {
1954
- var _a, _b, _c, _d, _e, _f;
1968
+ var _a, _b, _c, _d, _e, _f, _g;
1955
1969
  const warnings = [];
1956
1970
  if (frequencyPenalty != null) {
1957
1971
  warnings.push({
@@ -2055,6 +2069,9 @@ var AnthropicMessagesLanguageModel = class {
2055
2069
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
2056
2070
  cache_control: anthropicOptions.cacheControl
2057
2071
  },
2072
+ ...((_e = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _e.userId) != null && {
2073
+ metadata: { user_id: anthropicOptions.metadata.userId }
2074
+ },
2058
2075
  // structured output:
2059
2076
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2060
2077
  output_format: {
@@ -2066,7 +2083,7 @@ var AnthropicMessagesLanguageModel = class {
2066
2083
  ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
2067
2084
  container: {
2068
2085
  id: anthropicOptions.container.id,
2069
- skills: (_e = anthropicOptions.container.skills) == null ? void 0 : _e.map((skill) => ({
2086
+ skills: (_f = anthropicOptions.container.skills) == null ? void 0 : _f.map((skill) => ({
2070
2087
  type: skill.type,
2071
2088
  skill_id: skill.skillId,
2072
2089
  version: skill.version
@@ -2229,7 +2246,7 @@ var AnthropicMessagesLanguageModel = class {
2229
2246
  ...betas,
2230
2247
  ...toolsBetas,
2231
2248
  ...userSuppliedBetas,
2232
- ...(_f = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _f : []
2249
+ ...(_g = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _g : []
2233
2250
  ]),
2234
2251
  usesJsonResponseTool: jsonResponseTool != null
2235
2252
  };