@ai-sdk/anthropic 3.0.0-beta.31 → 3.0.0-beta.33

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/index.mjs CHANGED
@@ -5,12 +5,13 @@ import {
5
5
  import {
6
6
  generateId as generateId2,
7
7
  loadApiKey,
8
+ loadOptionalSetting,
8
9
  withoutTrailingSlash,
9
10
  withUserAgentSuffix
10
11
  } from "@ai-sdk/provider-utils";
11
12
 
12
13
  // src/version.ts
13
- var VERSION = true ? "3.0.0-beta.31" : "0.0.0-test";
14
+ var VERSION = true ? "3.0.0-beta.33" : "0.0.0-test";
14
15
 
15
16
  // src/anthropic-messages-language-model.ts
16
17
  import {
@@ -256,7 +257,18 @@ var anthropicMessagesResponseSchema = lazySchema2(
256
257
  output_tokens: z2.number(),
257
258
  cache_creation_input_tokens: z2.number().nullish(),
258
259
  cache_read_input_tokens: z2.number().nullish()
259
- })
260
+ }),
261
+ container: z2.object({
262
+ expires_at: z2.string(),
263
+ id: z2.string(),
264
+ skills: z2.array(
265
+ z2.object({
266
+ type: z2.union([z2.literal("anthropic"), z2.literal("custom")]),
267
+ skill_id: z2.string(),
268
+ version: z2.string()
269
+ })
270
+ ).nullish()
271
+ }).nullish()
260
272
  })
261
273
  )
262
274
  );
@@ -504,7 +516,21 @@ var anthropicMessagesChunkSchema = lazySchema2(
504
516
  type: z2.literal("message_delta"),
505
517
  delta: z2.object({
506
518
  stop_reason: z2.string().nullish(),
507
- stop_sequence: z2.string().nullish()
519
+ stop_sequence: z2.string().nullish(),
520
+ container: z2.object({
521
+ expires_at: z2.string(),
522
+ id: z2.string(),
523
+ skills: z2.array(
524
+ z2.object({
525
+ type: z2.union([
526
+ z2.literal("anthropic"),
527
+ z2.literal("custom")
528
+ ]),
529
+ skill_id: z2.string(),
530
+ version: z2.string()
531
+ })
532
+ ).nullish()
533
+ }).nullish()
508
534
  }),
509
535
  usage: z2.looseObject({
510
536
  output_tokens: z2.number(),
@@ -2085,7 +2111,7 @@ var AnthropicMessagesLanguageModel = class {
2085
2111
  });
2086
2112
  }
2087
2113
  async doGenerate(options) {
2088
- var _a, _b, _c, _d, _e, _f;
2114
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2089
2115
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
2090
2116
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2091
2117
  const {
@@ -2368,7 +2394,16 @@ var AnthropicMessagesLanguageModel = class {
2368
2394
  anthropic: {
2369
2395
  usage: response.usage,
2370
2396
  cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
2371
- stopSequence: (_f = response.stop_sequence) != null ? _f : null
2397
+ stopSequence: (_f = response.stop_sequence) != null ? _f : null,
2398
+ container: response.container ? {
2399
+ expiresAt: response.container.expires_at,
2400
+ id: response.container.id,
2401
+ skills: (_h = (_g = response.container.skills) == null ? void 0 : _g.map((skill) => ({
2402
+ type: skill.type,
2403
+ skillId: skill.skill_id,
2404
+ version: skill.version
2405
+ }))) != null ? _h : null
2406
+ } : null
2372
2407
  }
2373
2408
  }
2374
2409
  };
@@ -2399,6 +2434,7 @@ var AnthropicMessagesLanguageModel = class {
2399
2434
  let rawUsage = void 0;
2400
2435
  let cacheCreationInputTokens = null;
2401
2436
  let stopSequence = null;
2437
+ let container = null;
2402
2438
  let blockType = void 0;
2403
2439
  const generateId3 = this.generateId;
2404
2440
  return {
@@ -2408,7 +2444,7 @@ var AnthropicMessagesLanguageModel = class {
2408
2444
  controller.enqueue({ type: "stream-start", warnings });
2409
2445
  },
2410
2446
  transform(chunk, controller) {
2411
- var _a, _b, _c, _d, _e, _f, _g, _h;
2447
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2412
2448
  if (options.includeRawChunks) {
2413
2449
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2414
2450
  }
@@ -2817,6 +2853,15 @@ var AnthropicMessagesLanguageModel = class {
2817
2853
  isJsonResponseFromTool: usesJsonResponseTool
2818
2854
  });
2819
2855
  stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
2856
+ container = value.delta.container != null ? {
2857
+ expiresAt: value.delta.container.expires_at,
2858
+ id: value.delta.container.id,
2859
+ skills: (_j = (_i = value.delta.container.skills) == null ? void 0 : _i.map((skill) => ({
2860
+ type: skill.type,
2861
+ skillId: skill.skill_id,
2862
+ version: skill.version
2863
+ }))) != null ? _j : null
2864
+ } : null;
2820
2865
  rawUsage = {
2821
2866
  ...rawUsage,
2822
2867
  ...value.usage
@@ -2832,7 +2877,8 @@ var AnthropicMessagesLanguageModel = class {
2832
2877
  anthropic: {
2833
2878
  usage: rawUsage != null ? rawUsage : null,
2834
2879
  cacheCreationInputTokens,
2835
- stopSequence
2880
+ stopSequence,
2881
+ container
2836
2882
  }
2837
2883
  }
2838
2884
  });
@@ -3268,7 +3314,12 @@ var anthropicTools = {
3268
3314
  // src/anthropic-provider.ts
3269
3315
  function createAnthropic(options = {}) {
3270
3316
  var _a;
3271
- const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
3317
+ const baseURL = (_a = withoutTrailingSlash(
3318
+ loadOptionalSetting({
3319
+ settingValue: options.baseURL,
3320
+ environmentVariableName: "ANTHROPIC_BASE_URL"
3321
+ })
3322
+ )) != null ? _a : "https://api.anthropic.com/v1";
3272
3323
  const getHeaders = () => withUserAgentSuffix(
3273
3324
  {
3274
3325
  "anthropic-version": "2023-06-01",