@ai-sdk/anthropic 3.0.110 → 3.0.112

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.
@@ -60,6 +60,19 @@ var anthropicStopDetailsSchema = import_v42.z.object({
60
60
  explanation: import_v42.z.string().nullish(),
61
61
  recommended_model: import_v42.z.string().nullish()
62
62
  });
63
+ var anthropicToolCallCallerSchema = import_v42.z.union([
64
+ import_v42.z.object({
65
+ type: import_v42.z.literal("code_execution_20250825"),
66
+ tool_id: import_v42.z.string()
67
+ }),
68
+ import_v42.z.object({
69
+ type: import_v42.z.literal("code_execution_20260120"),
70
+ tool_id: import_v42.z.string()
71
+ }),
72
+ import_v42.z.object({
73
+ type: import_v42.z.literal("direct")
74
+ })
75
+ ]);
63
76
  var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
64
77
  () => (0, import_provider_utils2.zodSchema)(
65
78
  import_v42.z.object({
@@ -118,34 +131,14 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
118
131
  name: import_v42.z.string(),
119
132
  input: import_v42.z.unknown(),
120
133
  // Programmatic tool calling: caller info when triggered from code execution
121
- caller: import_v42.z.union([
122
- import_v42.z.object({
123
- type: import_v42.z.literal("code_execution_20250825"),
124
- tool_id: import_v42.z.string()
125
- }),
126
- import_v42.z.object({
127
- type: import_v42.z.literal("code_execution_20260120"),
128
- tool_id: import_v42.z.string()
129
- }),
130
- import_v42.z.object({
131
- type: import_v42.z.literal("direct")
132
- })
133
- ]).optional()
134
+ caller: anthropicToolCallCallerSchema.optional()
134
135
  }),
135
136
  import_v42.z.object({
136
137
  type: import_v42.z.literal("server_tool_use"),
137
138
  id: import_v42.z.string(),
138
139
  name: import_v42.z.string(),
139
140
  input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish(),
140
- caller: import_v42.z.union([
141
- import_v42.z.object({
142
- type: import_v42.z.literal("code_execution_20260120"),
143
- tool_id: import_v42.z.string()
144
- }),
145
- import_v42.z.object({
146
- type: import_v42.z.literal("direct")
147
- })
148
- ]).optional()
141
+ caller: anthropicToolCallCallerSchema.optional()
149
142
  }),
150
143
  import_v42.z.object({
151
144
  type: import_v42.z.literal("mcp_tool_use"),
@@ -168,6 +161,7 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
168
161
  import_v42.z.object({
169
162
  type: import_v42.z.literal("web_fetch_tool_result"),
170
163
  tool_use_id: import_v42.z.string(),
164
+ caller: anthropicToolCallCallerSchema.optional(),
171
165
  content: import_v42.z.union([
172
166
  import_v42.z.object({
173
167
  type: import_v42.z.literal("web_fetch_result"),
@@ -200,6 +194,7 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
200
194
  import_v42.z.object({
201
195
  type: import_v42.z.literal("web_search_tool_result"),
202
196
  tool_use_id: import_v42.z.string(),
197
+ caller: anthropicToolCallCallerSchema.optional(),
203
198
  content: import_v42.z.union([
204
199
  import_v42.z.array(
205
200
  import_v42.z.object({
@@ -436,19 +431,7 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
436
431
  id: import_v42.z.string(),
437
432
  name: import_v42.z.string(),
438
433
  input: import_v42.z.unknown(),
439
- caller: import_v42.z.union([
440
- import_v42.z.object({
441
- type: import_v42.z.literal("code_execution_20250825"),
442
- tool_id: import_v42.z.string()
443
- }),
444
- import_v42.z.object({
445
- type: import_v42.z.literal("code_execution_20260120"),
446
- tool_id: import_v42.z.string()
447
- }),
448
- import_v42.z.object({
449
- type: import_v42.z.literal("direct")
450
- })
451
- ]).optional()
434
+ caller: anthropicToolCallCallerSchema.optional()
452
435
  })
453
436
  ])
454
437
  ).nullish(),
@@ -478,19 +461,7 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
478
461
  // Programmatic tool calling: input may be present directly for deferred tool calls
479
462
  input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).optional(),
480
463
  // Programmatic tool calling: caller info when triggered from code execution
481
- caller: import_v42.z.union([
482
- import_v42.z.object({
483
- type: import_v42.z.literal("code_execution_20250825"),
484
- tool_id: import_v42.z.string()
485
- }),
486
- import_v42.z.object({
487
- type: import_v42.z.literal("code_execution_20260120"),
488
- tool_id: import_v42.z.string()
489
- }),
490
- import_v42.z.object({
491
- type: import_v42.z.literal("direct")
492
- })
493
- ]).optional()
464
+ caller: anthropicToolCallCallerSchema.optional()
494
465
  }),
495
466
  import_v42.z.object({
496
467
  type: import_v42.z.literal("redacted_thinking"),
@@ -505,15 +476,7 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
505
476
  id: import_v42.z.string(),
506
477
  name: import_v42.z.string(),
507
478
  input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish(),
508
- caller: import_v42.z.union([
509
- import_v42.z.object({
510
- type: import_v42.z.literal("code_execution_20260120"),
511
- tool_id: import_v42.z.string()
512
- }),
513
- import_v42.z.object({
514
- type: import_v42.z.literal("direct")
515
- })
516
- ]).optional()
479
+ caller: anthropicToolCallCallerSchema.optional()
517
480
  }),
518
481
  import_v42.z.object({
519
482
  type: import_v42.z.literal("mcp_tool_use"),
@@ -536,6 +499,7 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
536
499
  import_v42.z.object({
537
500
  type: import_v42.z.literal("web_fetch_tool_result"),
538
501
  tool_use_id: import_v42.z.string(),
502
+ caller: anthropicToolCallCallerSchema.optional(),
539
503
  content: import_v42.z.union([
540
504
  import_v42.z.object({
541
505
  type: import_v42.z.literal("web_fetch_result"),
@@ -568,6 +532,7 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
568
532
  import_v42.z.object({
569
533
  type: import_v42.z.literal("web_search_tool_result"),
570
534
  tool_use_id: import_v42.z.string(),
535
+ caller: anthropicToolCallCallerSchema.optional(),
571
536
  content: import_v42.z.union([
572
537
  import_v42.z.array(
573
538
  import_v42.z.object({
@@ -2248,7 +2213,7 @@ async function convertToAnthropicMessagesPrompt({
2248
2213
  cacheControlValidator,
2249
2214
  toolNameMapping
2250
2215
  }) {
2251
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2216
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2252
2217
  const betas = /* @__PURE__ */ new Set();
2253
2218
  const blocks = groupIntoBlocks(prompt);
2254
2219
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -2653,6 +2618,7 @@ async function convertToAnthropicMessagesPrompt({
2653
2618
  break;
2654
2619
  }
2655
2620
  case "tool-call": {
2621
+ const caller = getAnthropicCaller(part.providerOptions);
2656
2622
  if (part.providerExecuted) {
2657
2623
  const providerToolName = toolNameMapping.toProviderToolName(
2658
2624
  part.toolName
@@ -2687,6 +2653,7 @@ async function convertToAnthropicMessagesPrompt({
2687
2653
  name: subtoolName,
2688
2654
  // map back to subtool name
2689
2655
  input,
2656
+ ...caller && { caller },
2690
2657
  cache_control: cacheControl
2691
2658
  });
2692
2659
  } else if (
@@ -2700,6 +2667,7 @@ async function convertToAnthropicMessagesPrompt({
2700
2667
  id: part.toolCallId,
2701
2668
  name: "code_execution",
2702
2669
  input: inputWithoutType,
2670
+ ...caller && { caller },
2703
2671
  cache_control: cacheControl
2704
2672
  });
2705
2673
  } else {
@@ -2710,6 +2678,7 @@ async function convertToAnthropicMessagesPrompt({
2710
2678
  id: part.toolCallId,
2711
2679
  name: providerToolName,
2712
2680
  input: part.input,
2681
+ ...caller && { caller },
2713
2682
  cache_control: cacheControl
2714
2683
  });
2715
2684
  } else if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
@@ -2718,6 +2687,7 @@ async function convertToAnthropicMessagesPrompt({
2718
2687
  id: part.toolCallId,
2719
2688
  name: providerToolName,
2720
2689
  input: part.input,
2690
+ ...caller && { caller },
2721
2691
  cache_control: cacheControl
2722
2692
  });
2723
2693
  } else if (providerToolName === "advisor") {
@@ -2726,6 +2696,7 @@ async function convertToAnthropicMessagesPrompt({
2726
2696
  id: part.toolCallId,
2727
2697
  name: "advisor",
2728
2698
  input: {},
2699
+ ...caller && { caller },
2729
2700
  cache_control: cacheControl
2730
2701
  });
2731
2702
  } else {
@@ -2737,11 +2708,6 @@ async function convertToAnthropicMessagesPrompt({
2737
2708
  }
2738
2709
  break;
2739
2710
  }
2740
- const callerOptions = (_o = part.providerOptions) == null ? void 0 : _o.anthropic;
2741
- const caller = (callerOptions == null ? void 0 : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
2742
- type: callerOptions.caller.type,
2743
- tool_id: callerOptions.caller.toolId
2744
- } : callerOptions.caller.type === "direct" ? { type: "direct" } : void 0 : void 0;
2745
2711
  anthropicContent.push({
2746
2712
  type: "tool_use",
2747
2713
  id: part.toolCallId,
@@ -2756,6 +2722,7 @@ async function convertToAnthropicMessagesPrompt({
2756
2722
  const providerToolName = toolNameMapping.toProviderToolName(
2757
2723
  part.toolName
2758
2724
  );
2725
+ const caller = getAnthropicCaller(part.providerOptions);
2759
2726
  if (mcpToolUseIds.has(part.toolCallId)) {
2760
2727
  const output = part.output;
2761
2728
  if (output.type !== "json" && output.type !== "error-json") {
@@ -2790,7 +2757,7 @@ async function convertToAnthropicMessagesPrompt({
2790
2757
  tool_use_id: part.toolCallId,
2791
2758
  content: {
2792
2759
  type: "code_execution_tool_result_error",
2793
- error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
2760
+ error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
2794
2761
  },
2795
2762
  cache_control: cacheControl
2796
2763
  });
@@ -2801,7 +2768,7 @@ async function convertToAnthropicMessagesPrompt({
2801
2768
  cache_control: cacheControl,
2802
2769
  content: {
2803
2770
  type: "bash_code_execution_tool_result_error",
2804
- error_code: (_q = errorInfo.errorCode) != null ? _q : "unknown"
2771
+ error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
2805
2772
  }
2806
2773
  });
2807
2774
  }
@@ -2834,7 +2801,7 @@ async function convertToAnthropicMessagesPrompt({
2834
2801
  stdout: codeExecutionOutput.stdout,
2835
2802
  stderr: codeExecutionOutput.stderr,
2836
2803
  return_code: codeExecutionOutput.return_code,
2837
- content: (_r = codeExecutionOutput.content) != null ? _r : []
2804
+ content: (_q = codeExecutionOutput.content) != null ? _q : []
2838
2805
  },
2839
2806
  cache_control: cacheControl
2840
2807
  });
@@ -2852,7 +2819,7 @@ async function convertToAnthropicMessagesPrompt({
2852
2819
  encrypted_stdout: codeExecutionOutput.encrypted_stdout,
2853
2820
  stderr: codeExecutionOutput.stderr,
2854
2821
  return_code: codeExecutionOutput.return_code,
2855
- content: (_s = codeExecutionOutput.content) != null ? _s : []
2822
+ content: (_r = codeExecutionOutput.content) != null ? _r : []
2856
2823
  },
2857
2824
  cache_control: cacheControl
2858
2825
  });
@@ -2871,7 +2838,7 @@ async function convertToAnthropicMessagesPrompt({
2871
2838
  stdout: codeExecutionOutput.stdout,
2872
2839
  stderr: codeExecutionOutput.stderr,
2873
2840
  return_code: codeExecutionOutput.return_code,
2874
- content: (_t = codeExecutionOutput.content) != null ? _t : []
2841
+ content: (_s = codeExecutionOutput.content) != null ? _s : []
2875
2842
  },
2876
2843
  cache_control: cacheControl
2877
2844
  });
@@ -2909,8 +2876,9 @@ async function convertToAnthropicMessagesPrompt({
2909
2876
  tool_use_id: part.toolCallId,
2910
2877
  content: {
2911
2878
  type: "web_fetch_tool_result_error",
2912
- error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
2879
+ error_code: (_t = (await extractErrorValue(output.value)).errorCode) != null ? _t : "unavailable"
2913
2880
  },
2881
+ ...caller && { caller },
2914
2882
  cache_control: cacheControl
2915
2883
  });
2916
2884
  break;
@@ -2944,6 +2912,7 @@ async function convertToAnthropicMessagesPrompt({
2944
2912
  }
2945
2913
  }
2946
2914
  },
2915
+ ...caller && { caller },
2947
2916
  cache_control: cacheControl
2948
2917
  });
2949
2918
  break;
@@ -2956,8 +2925,9 @@ async function convertToAnthropicMessagesPrompt({
2956
2925
  tool_use_id: part.toolCallId,
2957
2926
  content: {
2958
2927
  type: "web_search_tool_result_error",
2959
- error_code: (_v = (await extractErrorValue(output.value)).errorCode) != null ? _v : "unavailable"
2928
+ error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
2960
2929
  },
2930
+ ...caller && { caller },
2961
2931
  cache_control: cacheControl
2962
2932
  });
2963
2933
  break;
@@ -2983,6 +2953,7 @@ async function convertToAnthropicMessagesPrompt({
2983
2953
  encrypted_content: result.encryptedContent,
2984
2954
  type: result.type
2985
2955
  })),
2956
+ ...caller && { caller },
2986
2957
  cache_control: cacheControl
2987
2958
  });
2988
2959
  break;
@@ -3154,6 +3125,17 @@ function moveToolUseBlocksToEnd(content) {
3154
3125
  flushSegment();
3155
3126
  return result;
3156
3127
  }
3128
+ function getAnthropicCaller(providerOptions) {
3129
+ var _a;
3130
+ const caller = (_a = providerOptions == null ? void 0 : providerOptions.anthropic) == null ? void 0 : _a.caller;
3131
+ if (((caller == null ? void 0 : caller.type) === "code_execution_20250825" || (caller == null ? void 0 : caller.type) === "code_execution_20260120") && caller.toolId) {
3132
+ return {
3133
+ type: caller.type,
3134
+ tool_id: caller.toolId
3135
+ };
3136
+ }
3137
+ return (caller == null ? void 0 : caller.type) === "direct" ? { type: "direct" } : void 0;
3138
+ }
3157
3139
 
3158
3140
  // src/map-anthropic-stop-reason.ts
3159
3141
  function mapAnthropicStopReason({
@@ -3370,6 +3352,16 @@ function createCitationSource(citation, citationDocuments, generateId2) {
3370
3352
  }
3371
3353
  };
3372
3354
  }
3355
+ function getAnthropicCallerInfo(caller) {
3356
+ return caller == null ? void 0 : {
3357
+ type: caller.type,
3358
+ toolId: "tool_id" in caller ? caller.tool_id : void 0
3359
+ };
3360
+ }
3361
+ function getAnthropicCallerMetadata(caller) {
3362
+ const callerInfo = getAnthropicCallerInfo(caller);
3363
+ return callerInfo == null ? {} : { providerMetadata: { anthropic: { caller: callerInfo } } };
3364
+ }
3373
3365
  var AnthropicMessagesLanguageModel = class {
3374
3366
  constructor(modelId, config) {
3375
3367
  this.specificationVersion = "v3";
@@ -4018,23 +4010,12 @@ var AnthropicMessagesLanguageModel = class {
4018
4010
  text: JSON.stringify(part.input)
4019
4011
  });
4020
4012
  } else {
4021
- const caller = part.caller;
4022
- const callerInfo = caller ? {
4023
- type: caller.type,
4024
- toolId: "tool_id" in caller ? caller.tool_id : void 0
4025
- } : void 0;
4026
4013
  content.push({
4027
4014
  type: "tool-call",
4028
4015
  toolCallId: part.id,
4029
4016
  toolName: part.name,
4030
4017
  input: JSON.stringify(part.input),
4031
- ...callerInfo && {
4032
- providerMetadata: {
4033
- anthropic: {
4034
- caller: callerInfo
4035
- }
4036
- }
4037
- }
4018
+ ...getAnthropicCallerMetadata(part.caller)
4038
4019
  });
4039
4020
  }
4040
4021
  break;
@@ -4052,7 +4033,8 @@ var AnthropicMessagesLanguageModel = class {
4052
4033
  // implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
4053
4034
  // tool was not explicitly provided. We therefore bypass the general validation by marking the
4054
4035
  // tool as dynamic.
4055
- ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
4036
+ ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
4037
+ ...getAnthropicCallerMetadata(part.caller)
4056
4038
  });
4057
4039
  } else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
4058
4040
  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;
@@ -4066,7 +4048,8 @@ var AnthropicMessagesLanguageModel = class {
4066
4048
  // implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
4067
4049
  // tool was not explicitly provided. We therefore bypass the general validation by marking the
4068
4050
  // tool as dynamic.
4069
- ...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {}
4051
+ ...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {},
4052
+ ...getAnthropicCallerMetadata(part.caller)
4070
4053
  });
4071
4054
  } else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
4072
4055
  serverToolCalls[part.id] = part.name;
@@ -4075,7 +4058,8 @@ var AnthropicMessagesLanguageModel = class {
4075
4058
  toolCallId: part.id,
4076
4059
  toolName: toolNameMapping.toCustomToolName(part.name),
4077
4060
  input: JSON.stringify(part.input),
4078
- providerExecuted: true
4061
+ providerExecuted: true,
4062
+ ...getAnthropicCallerMetadata(part.caller)
4079
4063
  });
4080
4064
  } else if (part.name === "advisor") {
4081
4065
  content.push({
@@ -4083,7 +4067,8 @@ var AnthropicMessagesLanguageModel = class {
4083
4067
  toolCallId: part.id,
4084
4068
  toolName: toolNameMapping.toCustomToolName("advisor"),
4085
4069
  input: JSON.stringify(part.input),
4086
- providerExecuted: true
4070
+ providerExecuted: true,
4071
+ ...getAnthropicCallerMetadata(part.caller)
4087
4072
  });
4088
4073
  }
4089
4074
  break;
@@ -4142,7 +4127,8 @@ var AnthropicMessagesLanguageModel = class {
4142
4127
  data: part.content.content.source.data
4143
4128
  }
4144
4129
  }
4145
- }
4130
+ },
4131
+ ...getAnthropicCallerMetadata(part.caller)
4146
4132
  });
4147
4133
  } else if (part.content.type === "web_fetch_tool_result_error") {
4148
4134
  content.push({
@@ -4153,7 +4139,8 @@ var AnthropicMessagesLanguageModel = class {
4153
4139
  result: {
4154
4140
  type: "web_fetch_tool_result_error",
4155
4141
  errorCode: part.content.error_code
4156
- }
4142
+ },
4143
+ ...getAnthropicCallerMetadata(part.caller)
4157
4144
  });
4158
4145
  }
4159
4146
  break;
@@ -4173,7 +4160,8 @@ var AnthropicMessagesLanguageModel = class {
4173
4160
  encryptedContent: result.encrypted_content,
4174
4161
  type: result.type
4175
4162
  };
4176
- })
4163
+ }),
4164
+ ...getAnthropicCallerMetadata(part.caller)
4177
4165
  });
4178
4166
  for (const result of part.content) {
4179
4167
  content.push({
@@ -4198,7 +4186,8 @@ var AnthropicMessagesLanguageModel = class {
4198
4186
  result: {
4199
4187
  type: "web_search_tool_result_error",
4200
4188
  errorCode: part.content.error_code
4201
- }
4189
+ },
4190
+ ...getAnthropicCallerMetadata(part.caller)
4202
4191
  });
4203
4192
  }
4204
4193
  break;
@@ -4559,11 +4548,7 @@ var AnthropicMessagesLanguageModel = class {
4559
4548
  id: String(value.index)
4560
4549
  });
4561
4550
  } else {
4562
- const caller = part.caller;
4563
- const callerInfo = caller ? {
4564
- type: caller.type,
4565
- toolId: "tool_id" in caller ? caller.tool_id : void 0
4566
- } : void 0;
4551
+ const callerInfo = getAnthropicCallerInfo(part.caller);
4567
4552
  const hasNonEmptyInput = part.input && Object.keys(part.input).length > 0;
4568
4553
  const initialInput = hasNonEmptyInput ? JSON.stringify(part.input) : "";
4569
4554
  contentBlocks[value.index] = {
@@ -4583,6 +4568,7 @@ var AnthropicMessagesLanguageModel = class {
4583
4568
  return;
4584
4569
  }
4585
4570
  case "server_tool_use": {
4571
+ const callerInfo = getAnthropicCallerInfo(part.caller);
4586
4572
  if ([
4587
4573
  "web_fetch",
4588
4574
  "web_search",
@@ -4610,7 +4596,8 @@ var AnthropicMessagesLanguageModel = class {
4610
4596
  ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
4611
4597
  firstDelta: finalInput.length === 0,
4612
4598
  providerToolName,
4613
- providerToolInputType
4599
+ providerToolInputType,
4600
+ ...callerInfo && { caller: callerInfo }
4614
4601
  };
4615
4602
  controller.enqueue({
4616
4603
  type: "tool-input-start",
@@ -4635,7 +4622,8 @@ var AnthropicMessagesLanguageModel = class {
4635
4622
  input: "",
4636
4623
  providerExecuted: true,
4637
4624
  firstDelta: true,
4638
- providerToolName: part.name
4625
+ providerToolName: part.name,
4626
+ ...callerInfo && { caller: callerInfo }
4639
4627
  };
4640
4628
  controller.enqueue({
4641
4629
  type: "tool-input-start",
@@ -4652,7 +4640,8 @@ var AnthropicMessagesLanguageModel = class {
4652
4640
  input: "{}",
4653
4641
  providerExecuted: true,
4654
4642
  firstDelta: true,
4655
- providerToolName: part.name
4643
+ providerToolName: part.name,
4644
+ ...callerInfo && { caller: callerInfo }
4656
4645
  };
4657
4646
  controller.enqueue({
4658
4647
  type: "tool-input-start",
@@ -4687,7 +4676,8 @@ var AnthropicMessagesLanguageModel = class {
4687
4676
  data: part.content.content.source.data
4688
4677
  }
4689
4678
  }
4690
- }
4679
+ },
4680
+ ...getAnthropicCallerMetadata(part.caller)
4691
4681
  });
4692
4682
  } else if (part.content.type === "web_fetch_tool_result_error") {
4693
4683
  controller.enqueue({
@@ -4698,7 +4688,8 @@ var AnthropicMessagesLanguageModel = class {
4698
4688
  result: {
4699
4689
  type: "web_fetch_tool_result_error",
4700
4690
  errorCode: part.content.error_code
4701
- }
4691
+ },
4692
+ ...getAnthropicCallerMetadata(part.caller)
4702
4693
  });
4703
4694
  }
4704
4695
  return;
@@ -4718,7 +4709,8 @@ var AnthropicMessagesLanguageModel = class {
4718
4709
  encryptedContent: result.encrypted_content,
4719
4710
  type: result.type
4720
4711
  };
4721
- })
4712
+ }),
4713
+ ...getAnthropicCallerMetadata(part.caller)
4722
4714
  });
4723
4715
  for (const result of part.content) {
4724
4716
  controller.enqueue({
@@ -4743,7 +4735,8 @@ var AnthropicMessagesLanguageModel = class {
4743
4735
  result: {
4744
4736
  type: "web_search_tool_result_error",
4745
4737
  errorCode: part.content.error_code
4746
- }
4738
+ },
4739
+ ...getAnthropicCallerMetadata(part.caller)
4747
4740
  });
4748
4741
  }
4749
4742
  return;
@@ -5143,11 +5136,7 @@ var AnthropicMessagesLanguageModel = class {
5143
5136
  for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
5144
5137
  const part = value.message.content[contentIndex];
5145
5138
  if (part.type === "tool_use") {
5146
- const caller = part.caller;
5147
- const callerInfo = caller ? {
5148
- type: caller.type,
5149
- toolId: "tool_id" in caller ? caller.tool_id : void 0
5150
- } : void 0;
5139
+ const callerInfo = getAnthropicCallerInfo(part.caller);
5151
5140
  controller.enqueue({
5152
5141
  type: "tool-input-start",
5153
5142
  id: part.id,