@ai-sdk/anthropic 4.0.37 → 4.0.39

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,18 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.39
4
+
5
+ ### Patch Changes
6
+
7
+ - 4579b08: Preserve Anthropic server-tool caller metadata in multi-turn conversations.
8
+
9
+ ## 4.0.38
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [7fbfc6d]
14
+ - @ai-sdk/provider-utils@5.0.27
15
+
3
16
  ## 4.0.37
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -148,6 +148,19 @@ var anthropicStopDetailsSchema = z3.object({
148
148
  explanation: z3.string().nullish(),
149
149
  recommended_model: z3.string().nullish()
150
150
  });
151
+ var anthropicToolCallCallerSchema = z3.union([
152
+ z3.object({
153
+ type: z3.literal("code_execution_20250825"),
154
+ tool_id: z3.string()
155
+ }),
156
+ z3.object({
157
+ type: z3.literal("code_execution_20260120"),
158
+ tool_id: z3.string()
159
+ }),
160
+ z3.object({
161
+ type: z3.literal("direct")
162
+ })
163
+ ]);
151
164
  var anthropicResponseSchema = lazySchema3(
152
165
  () => zodSchema3(
153
166
  z3.object({
@@ -206,34 +219,14 @@ var anthropicResponseSchema = lazySchema3(
206
219
  name: z3.string(),
207
220
  input: z3.unknown(),
208
221
  // Programmatic tool calling: caller info when triggered from code execution
209
- caller: z3.union([
210
- z3.object({
211
- type: z3.literal("code_execution_20250825"),
212
- tool_id: z3.string()
213
- }),
214
- z3.object({
215
- type: z3.literal("code_execution_20260120"),
216
- tool_id: z3.string()
217
- }),
218
- z3.object({
219
- type: z3.literal("direct")
220
- })
221
- ]).optional()
222
+ caller: anthropicToolCallCallerSchema.optional()
222
223
  }),
223
224
  z3.object({
224
225
  type: z3.literal("server_tool_use"),
225
226
  id: z3.string(),
226
227
  name: z3.string(),
227
228
  input: z3.record(z3.string(), z3.unknown()).nullish(),
228
- caller: z3.union([
229
- z3.object({
230
- type: z3.literal("code_execution_20260120"),
231
- tool_id: z3.string()
232
- }),
233
- z3.object({
234
- type: z3.literal("direct")
235
- })
236
- ]).optional()
229
+ caller: anthropicToolCallCallerSchema.optional()
237
230
  }),
238
231
  z3.object({
239
232
  type: z3.literal("mcp_tool_use"),
@@ -256,6 +249,7 @@ var anthropicResponseSchema = lazySchema3(
256
249
  z3.object({
257
250
  type: z3.literal("web_fetch_tool_result"),
258
251
  tool_use_id: z3.string(),
252
+ caller: anthropicToolCallCallerSchema.optional(),
259
253
  content: z3.union([
260
254
  z3.object({
261
255
  type: z3.literal("web_fetch_result"),
@@ -288,6 +282,7 @@ var anthropicResponseSchema = lazySchema3(
288
282
  z3.object({
289
283
  type: z3.literal("web_search_tool_result"),
290
284
  tool_use_id: z3.string(),
285
+ caller: anthropicToolCallCallerSchema.optional(),
291
286
  content: z3.union([
292
287
  z3.array(
293
288
  z3.object({
@@ -526,19 +521,7 @@ var anthropicChunkSchema = lazySchema3(
526
521
  id: z3.string(),
527
522
  name: z3.string(),
528
523
  input: z3.unknown(),
529
- caller: z3.union([
530
- z3.object({
531
- type: z3.literal("code_execution_20250825"),
532
- tool_id: z3.string()
533
- }),
534
- z3.object({
535
- type: z3.literal("code_execution_20260120"),
536
- tool_id: z3.string()
537
- }),
538
- z3.object({
539
- type: z3.literal("direct")
540
- })
541
- ]).optional()
524
+ caller: anthropicToolCallCallerSchema.optional()
542
525
  })
543
526
  ])
544
527
  ).nullish(),
@@ -568,19 +551,7 @@ var anthropicChunkSchema = lazySchema3(
568
551
  // Programmatic tool calling: input may be present directly for deferred tool calls
569
552
  input: z3.record(z3.string(), z3.unknown()).optional(),
570
553
  // Programmatic tool calling: caller info when triggered from code execution
571
- caller: z3.union([
572
- z3.object({
573
- type: z3.literal("code_execution_20250825"),
574
- tool_id: z3.string()
575
- }),
576
- z3.object({
577
- type: z3.literal("code_execution_20260120"),
578
- tool_id: z3.string()
579
- }),
580
- z3.object({
581
- type: z3.literal("direct")
582
- })
583
- ]).optional()
554
+ caller: anthropicToolCallCallerSchema.optional()
584
555
  }),
585
556
  z3.object({
586
557
  type: z3.literal("redacted_thinking"),
@@ -595,15 +566,7 @@ var anthropicChunkSchema = lazySchema3(
595
566
  id: z3.string(),
596
567
  name: z3.string(),
597
568
  input: z3.record(z3.string(), z3.unknown()).nullish(),
598
- caller: z3.union([
599
- z3.object({
600
- type: z3.literal("code_execution_20260120"),
601
- tool_id: z3.string()
602
- }),
603
- z3.object({
604
- type: z3.literal("direct")
605
- })
606
- ]).optional()
569
+ caller: anthropicToolCallCallerSchema.optional()
607
570
  }),
608
571
  z3.object({
609
572
  type: z3.literal("mcp_tool_use"),
@@ -626,6 +589,7 @@ var anthropicChunkSchema = lazySchema3(
626
589
  z3.object({
627
590
  type: z3.literal("web_fetch_tool_result"),
628
591
  tool_use_id: z3.string(),
592
+ caller: anthropicToolCallCallerSchema.optional(),
629
593
  content: z3.union([
630
594
  z3.object({
631
595
  type: z3.literal("web_fetch_result"),
@@ -658,6 +622,7 @@ var anthropicChunkSchema = lazySchema3(
658
622
  z3.object({
659
623
  type: z3.literal("web_search_tool_result"),
660
624
  tool_use_id: z3.string(),
625
+ caller: anthropicToolCallCallerSchema.optional(),
661
626
  content: z3.union([
662
627
  z3.array(
663
628
  z3.object({
@@ -2455,7 +2420,7 @@ async function convertToAnthropicPrompt({
2455
2420
  cacheControlValidator,
2456
2421
  toolNameMapping
2457
2422
  }) {
2458
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
2423
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2459
2424
  const betas = /* @__PURE__ */ new Set();
2460
2425
  const blocks = groupIntoBlocks(prompt);
2461
2426
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -2949,6 +2914,7 @@ async function convertToAnthropicPrompt({
2949
2914
  break;
2950
2915
  }
2951
2916
  case "tool-call": {
2917
+ const caller = getAnthropicCaller(part.providerOptions);
2952
2918
  if (part.providerExecuted) {
2953
2919
  const providerToolName = toolNameMapping.toProviderToolName(
2954
2920
  part.toolName
@@ -2983,6 +2949,7 @@ async function convertToAnthropicPrompt({
2983
2949
  name: codeExecutionType,
2984
2950
  // map back to subtool name
2985
2951
  input: inputWithoutType,
2952
+ ...caller && { caller },
2986
2953
  cache_control: cacheControl
2987
2954
  });
2988
2955
  } else if (
@@ -2996,6 +2963,7 @@ async function convertToAnthropicPrompt({
2996
2963
  id: part.toolCallId,
2997
2964
  name: "code_execution",
2998
2965
  input: inputWithoutType,
2966
+ ...caller && { caller },
2999
2967
  cache_control: cacheControl
3000
2968
  });
3001
2969
  } else {
@@ -3006,6 +2974,7 @@ async function convertToAnthropicPrompt({
3006
2974
  id: part.toolCallId,
3007
2975
  name: providerToolName,
3008
2976
  input: part.input,
2977
+ ...caller && { caller },
3009
2978
  cache_control: cacheControl
3010
2979
  });
3011
2980
  } else if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
@@ -3014,6 +2983,7 @@ async function convertToAnthropicPrompt({
3014
2983
  id: part.toolCallId,
3015
2984
  name: providerToolName,
3016
2985
  input: part.input,
2986
+ ...caller && { caller },
3017
2987
  cache_control: cacheControl
3018
2988
  });
3019
2989
  } else if (providerToolName === "advisor") {
@@ -3022,6 +2992,7 @@ async function convertToAnthropicPrompt({
3022
2992
  id: part.toolCallId,
3023
2993
  name: "advisor",
3024
2994
  input: {},
2995
+ ...caller && { caller },
3025
2996
  cache_control: cacheControl
3026
2997
  });
3027
2998
  } else {
@@ -3033,11 +3004,6 @@ async function convertToAnthropicPrompt({
3033
3004
  }
3034
3005
  break;
3035
3006
  }
3036
- const callerOptions = (_p = part.providerOptions) == null ? void 0 : _p.anthropic;
3037
- const caller = (callerOptions == null ? void 0 : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
3038
- type: callerOptions.caller.type,
3039
- tool_id: callerOptions.caller.toolId
3040
- } : callerOptions.caller.type === "direct" ? { type: "direct" } : void 0 : void 0;
3041
3007
  anthropicContent.push({
3042
3008
  type: "tool_use",
3043
3009
  id: part.toolCallId,
@@ -3052,6 +3018,7 @@ async function convertToAnthropicPrompt({
3052
3018
  const providerToolName = toolNameMapping.toProviderToolName(
3053
3019
  part.toolName
3054
3020
  );
3021
+ const caller = getAnthropicCaller(part.providerOptions);
3055
3022
  if (mcpToolUseIds.has(part.toolCallId)) {
3056
3023
  const output = part.output;
3057
3024
  if (output.type !== "json" && output.type !== "error-json") {
@@ -3086,7 +3053,7 @@ async function convertToAnthropicPrompt({
3086
3053
  tool_use_id: part.toolCallId,
3087
3054
  content: {
3088
3055
  type: "code_execution_tool_result_error",
3089
- error_code: (_q = errorInfo.errorCode) != null ? _q : "unknown"
3056
+ error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
3090
3057
  },
3091
3058
  cache_control: cacheControl
3092
3059
  });
@@ -3097,7 +3064,7 @@ async function convertToAnthropicPrompt({
3097
3064
  cache_control: cacheControl,
3098
3065
  content: {
3099
3066
  type: "bash_code_execution_tool_result_error",
3100
- error_code: (_r = errorInfo.errorCode) != null ? _r : "unknown"
3067
+ error_code: (_q = errorInfo.errorCode) != null ? _q : "unknown"
3101
3068
  }
3102
3069
  });
3103
3070
  }
@@ -3130,7 +3097,7 @@ async function convertToAnthropicPrompt({
3130
3097
  stdout: codeExecutionOutput.stdout,
3131
3098
  stderr: codeExecutionOutput.stderr,
3132
3099
  return_code: codeExecutionOutput.return_code,
3133
- content: (_s = codeExecutionOutput.content) != null ? _s : []
3100
+ content: (_r = codeExecutionOutput.content) != null ? _r : []
3134
3101
  },
3135
3102
  cache_control: cacheControl
3136
3103
  });
@@ -3148,7 +3115,7 @@ async function convertToAnthropicPrompt({
3148
3115
  encrypted_stdout: codeExecutionOutput.encrypted_stdout,
3149
3116
  stderr: codeExecutionOutput.stderr,
3150
3117
  return_code: codeExecutionOutput.return_code,
3151
- content: (_t = codeExecutionOutput.content) != null ? _t : []
3118
+ content: (_s = codeExecutionOutput.content) != null ? _s : []
3152
3119
  },
3153
3120
  cache_control: cacheControl
3154
3121
  });
@@ -3167,7 +3134,7 @@ async function convertToAnthropicPrompt({
3167
3134
  stdout: codeExecutionOutput.stdout,
3168
3135
  stderr: codeExecutionOutput.stderr,
3169
3136
  return_code: codeExecutionOutput.return_code,
3170
- content: (_u = codeExecutionOutput.content) != null ? _u : []
3137
+ content: (_t = codeExecutionOutput.content) != null ? _t : []
3171
3138
  },
3172
3139
  cache_control: cacheControl
3173
3140
  });
@@ -3205,8 +3172,9 @@ async function convertToAnthropicPrompt({
3205
3172
  tool_use_id: part.toolCallId,
3206
3173
  content: {
3207
3174
  type: "web_fetch_tool_result_error",
3208
- error_code: (_v = extractErrorValue(output.value).errorCode) != null ? _v : "unavailable"
3175
+ error_code: (_u = extractErrorValue(output.value).errorCode) != null ? _u : "unavailable"
3209
3176
  },
3177
+ ...caller && { caller },
3210
3178
  cache_control: cacheControl
3211
3179
  });
3212
3180
  break;
@@ -3240,6 +3208,7 @@ async function convertToAnthropicPrompt({
3240
3208
  }
3241
3209
  }
3242
3210
  },
3211
+ ...caller && { caller },
3243
3212
  cache_control: cacheControl
3244
3213
  });
3245
3214
  break;
@@ -3252,8 +3221,9 @@ async function convertToAnthropicPrompt({
3252
3221
  tool_use_id: part.toolCallId,
3253
3222
  content: {
3254
3223
  type: "web_search_tool_result_error",
3255
- error_code: (_w = extractErrorValue(output.value).errorCode) != null ? _w : "unavailable"
3224
+ error_code: (_v = extractErrorValue(output.value).errorCode) != null ? _v : "unavailable"
3256
3225
  },
3226
+ ...caller && { caller },
3257
3227
  cache_control: cacheControl
3258
3228
  });
3259
3229
  break;
@@ -3279,6 +3249,7 @@ async function convertToAnthropicPrompt({
3279
3249
  encrypted_content: result.encryptedContent,
3280
3250
  type: result.type
3281
3251
  })),
3252
+ ...caller && { caller },
3282
3253
  cache_control: cacheControl
3283
3254
  });
3284
3255
  break;
@@ -3456,6 +3427,17 @@ function moveToolUseBlocksToEnd(content) {
3456
3427
  flushSegment();
3457
3428
  return result;
3458
3429
  }
3430
+ function getAnthropicCaller(providerOptions) {
3431
+ var _a;
3432
+ const caller = (_a = providerOptions == null ? void 0 : providerOptions.anthropic) == null ? void 0 : _a.caller;
3433
+ if (((caller == null ? void 0 : caller.type) === "code_execution_20250825" || (caller == null ? void 0 : caller.type) === "code_execution_20260120") && caller.toolId) {
3434
+ return {
3435
+ type: caller.type,
3436
+ tool_id: caller.toolId
3437
+ };
3438
+ }
3439
+ return (caller == null ? void 0 : caller.type) === "direct" ? { type: "direct" } : void 0;
3440
+ }
3459
3441
  function toAnthropicToolInput(input) {
3460
3442
  return typeof input === "object" && input !== null && !Array.isArray(input) ? input : { rawInvalidInput: input };
3461
3443
  }
@@ -3673,6 +3655,16 @@ function createCitationSource(citation, citationDocuments, generateId3) {
3673
3655
  }
3674
3656
  };
3675
3657
  }
3658
+ function getAnthropicCallerInfo(caller) {
3659
+ return caller == null ? void 0 : {
3660
+ type: caller.type,
3661
+ toolId: "tool_id" in caller ? caller.tool_id : void 0
3662
+ };
3663
+ }
3664
+ function getAnthropicCallerMetadata(caller) {
3665
+ const callerInfo = getAnthropicCallerInfo(caller);
3666
+ return callerInfo == null ? {} : { providerMetadata: { anthropic: { caller: callerInfo } } };
3667
+ }
3676
3668
  var AnthropicLanguageModel = class _AnthropicLanguageModel {
3677
3669
  constructor(modelId, config) {
3678
3670
  this.specificationVersion = "v4";
@@ -4353,23 +4345,12 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4353
4345
  text: JSON.stringify(part.input)
4354
4346
  });
4355
4347
  } else {
4356
- const caller = part.caller;
4357
- const callerInfo = caller ? {
4358
- type: caller.type,
4359
- toolId: "tool_id" in caller ? caller.tool_id : void 0
4360
- } : void 0;
4361
4348
  content.push({
4362
4349
  type: "tool-call",
4363
4350
  toolCallId: part.id,
4364
4351
  toolName: part.name,
4365
4352
  input: JSON.stringify(part.input),
4366
- ...callerInfo && {
4367
- providerMetadata: {
4368
- anthropic: {
4369
- caller: callerInfo
4370
- }
4371
- }
4372
- }
4353
+ ...getAnthropicCallerMetadata(part.caller)
4373
4354
  });
4374
4355
  }
4375
4356
  break;
@@ -4387,7 +4368,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4387
4368
  // implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
4388
4369
  // tool was not explicitly provided. We therefore bypass the general validation by marking the
4389
4370
  // tool as dynamic.
4390
- ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
4371
+ ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
4372
+ ...getAnthropicCallerMetadata(part.caller)
4391
4373
  });
4392
4374
  } else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
4393
4375
  const inputToSerialize = part.name === "code_execution" && part.input != null && typeof part.input === "object" && "code" in part.input && !("type" in part.input) ? { type: "programmatic-tool-call", ...part.input } : part.input;
@@ -4401,7 +4383,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4401
4383
  // implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
4402
4384
  // tool was not explicitly provided. We therefore bypass the general validation by marking the
4403
4385
  // tool as dynamic.
4404
- ...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {}
4386
+ ...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {},
4387
+ ...getAnthropicCallerMetadata(part.caller)
4405
4388
  });
4406
4389
  } else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
4407
4390
  serverToolCalls[part.id] = part.name;
@@ -4410,7 +4393,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4410
4393
  toolCallId: part.id,
4411
4394
  toolName: toolNameMapping.toCustomToolName(part.name),
4412
4395
  input: JSON.stringify(part.input),
4413
- providerExecuted: true
4396
+ providerExecuted: true,
4397
+ ...getAnthropicCallerMetadata(part.caller)
4414
4398
  });
4415
4399
  } else if (part.name === "advisor") {
4416
4400
  content.push({
@@ -4418,7 +4402,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4418
4402
  toolCallId: part.id,
4419
4403
  toolName: toolNameMapping.toCustomToolName("advisor"),
4420
4404
  input: JSON.stringify(part.input),
4421
- providerExecuted: true
4405
+ providerExecuted: true,
4406
+ ...getAnthropicCallerMetadata(part.caller)
4422
4407
  });
4423
4408
  }
4424
4409
  break;
@@ -4477,7 +4462,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4477
4462
  data: part.content.content.source.data
4478
4463
  }
4479
4464
  }
4480
- }
4465
+ },
4466
+ ...getAnthropicCallerMetadata(part.caller)
4481
4467
  });
4482
4468
  } else if (part.content.type === "web_fetch_tool_result_error") {
4483
4469
  content.push({
@@ -4488,7 +4474,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4488
4474
  result: {
4489
4475
  type: "web_fetch_tool_result_error",
4490
4476
  errorCode: part.content.error_code
4491
- }
4477
+ },
4478
+ ...getAnthropicCallerMetadata(part.caller)
4492
4479
  });
4493
4480
  }
4494
4481
  break;
@@ -4508,7 +4495,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4508
4495
  encryptedContent: result.encrypted_content,
4509
4496
  type: result.type
4510
4497
  };
4511
- })
4498
+ }),
4499
+ ...getAnthropicCallerMetadata(part.caller)
4512
4500
  });
4513
4501
  for (const result of part.content) {
4514
4502
  content.push({
@@ -4533,7 +4521,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4533
4521
  result: {
4534
4522
  type: "web_search_tool_result_error",
4535
4523
  errorCode: part.content.error_code
4536
- }
4524
+ },
4525
+ ...getAnthropicCallerMetadata(part.caller)
4537
4526
  });
4538
4527
  }
4539
4528
  break;
@@ -4897,11 +4886,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4897
4886
  id: String(value.index)
4898
4887
  });
4899
4888
  } else {
4900
- const caller = part.caller;
4901
- const callerInfo = caller ? {
4902
- type: caller.type,
4903
- toolId: "tool_id" in caller ? caller.tool_id : void 0
4904
- } : void 0;
4889
+ const callerInfo = getAnthropicCallerInfo(part.caller);
4905
4890
  const hasNonEmptyInput = part.input && Object.keys(part.input).length > 0;
4906
4891
  const initialInput = hasNonEmptyInput ? JSON.stringify(part.input) : "";
4907
4892
  contentBlocks[value.index] = {
@@ -4921,6 +4906,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4921
4906
  return;
4922
4907
  }
4923
4908
  case "server_tool_use": {
4909
+ const callerInfo = getAnthropicCallerInfo(part.caller);
4924
4910
  if ([
4925
4911
  "web_fetch",
4926
4912
  "web_search",
@@ -4948,7 +4934,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4948
4934
  ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
4949
4935
  firstDelta: finalInput.length === 0,
4950
4936
  providerToolName,
4951
- providerToolInputType
4937
+ providerToolInputType,
4938
+ ...callerInfo && { caller: callerInfo }
4952
4939
  };
4953
4940
  controller.enqueue({
4954
4941
  type: "tool-input-start",
@@ -4973,7 +4960,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4973
4960
  input: "",
4974
4961
  providerExecuted: true,
4975
4962
  firstDelta: true,
4976
- providerToolName: part.name
4963
+ providerToolName: part.name,
4964
+ ...callerInfo && { caller: callerInfo }
4977
4965
  };
4978
4966
  controller.enqueue({
4979
4967
  type: "tool-input-start",
@@ -4990,7 +4978,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4990
4978
  input: "{}",
4991
4979
  providerExecuted: true,
4992
4980
  firstDelta: true,
4993
- providerToolName: part.name
4981
+ providerToolName: part.name,
4982
+ ...callerInfo && { caller: callerInfo }
4994
4983
  };
4995
4984
  controller.enqueue({
4996
4985
  type: "tool-input-start",
@@ -5025,7 +5014,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
5025
5014
  data: part.content.content.source.data
5026
5015
  }
5027
5016
  }
5028
- }
5017
+ },
5018
+ ...getAnthropicCallerMetadata(part.caller)
5029
5019
  });
5030
5020
  } else if (part.content.type === "web_fetch_tool_result_error") {
5031
5021
  controller.enqueue({
@@ -5036,7 +5026,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
5036
5026
  result: {
5037
5027
  type: "web_fetch_tool_result_error",
5038
5028
  errorCode: part.content.error_code
5039
- }
5029
+ },
5030
+ ...getAnthropicCallerMetadata(part.caller)
5040
5031
  });
5041
5032
  }
5042
5033
  return;
@@ -5056,7 +5047,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
5056
5047
  encryptedContent: result.encrypted_content,
5057
5048
  type: result.type
5058
5049
  };
5059
- })
5050
+ }),
5051
+ ...getAnthropicCallerMetadata(part.caller)
5060
5052
  });
5061
5053
  for (const result of part.content) {
5062
5054
  controller.enqueue({
@@ -5081,7 +5073,8 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
5081
5073
  result: {
5082
5074
  type: "web_search_tool_result_error",
5083
5075
  errorCode: part.content.error_code
5084
- }
5076
+ },
5077
+ ...getAnthropicCallerMetadata(part.caller)
5085
5078
  });
5086
5079
  }
5087
5080
  return;
@@ -5486,11 +5479,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
5486
5479
  for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
5487
5480
  const part = value.message.content[contentIndex];
5488
5481
  if (part.type === "tool_use") {
5489
- const caller = part.caller;
5490
- const callerInfo = caller ? {
5491
- type: caller.type,
5492
- toolId: "tool_id" in caller ? caller.tool_id : void 0
5493
- } : void 0;
5482
+ const callerInfo = getAnthropicCallerInfo(part.caller);
5494
5483
  controller.enqueue({
5495
5484
  type: "tool-input-start",
5496
5485
  id: part.id,
@@ -7142,7 +7131,7 @@ var AnthropicSkills = class {
7142
7131
  };
7143
7132
 
7144
7133
  // src/version.ts
7145
- var VERSION = true ? "4.0.37" : "0.0.0-test";
7134
+ var VERSION = true ? "4.0.39" : "0.0.0-test";
7146
7135
 
7147
7136
  // src/anthropic-provider.ts
7148
7137
  var ANTHROPIC_API_URL = "https://api.anthropic.com";