@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.
- package/CHANGELOG.md +15 -0
- package/dist/index.js +97 -108
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -108
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +96 -107
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +96 -107
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/anthropic-messages-api.ts +26 -67
- package/src/anthropic-messages-language-model.ts +39 -32
- package/src/convert-to-anthropic-messages-prompt.ts +36 -20
package/dist/internal/index.mjs
CHANGED
|
@@ -50,6 +50,19 @@ var anthropicStopDetailsSchema = z2.object({
|
|
|
50
50
|
explanation: z2.string().nullish(),
|
|
51
51
|
recommended_model: z2.string().nullish()
|
|
52
52
|
});
|
|
53
|
+
var anthropicToolCallCallerSchema = z2.union([
|
|
54
|
+
z2.object({
|
|
55
|
+
type: z2.literal("code_execution_20250825"),
|
|
56
|
+
tool_id: z2.string()
|
|
57
|
+
}),
|
|
58
|
+
z2.object({
|
|
59
|
+
type: z2.literal("code_execution_20260120"),
|
|
60
|
+
tool_id: z2.string()
|
|
61
|
+
}),
|
|
62
|
+
z2.object({
|
|
63
|
+
type: z2.literal("direct")
|
|
64
|
+
})
|
|
65
|
+
]);
|
|
53
66
|
var anthropicMessagesResponseSchema = lazySchema2(
|
|
54
67
|
() => zodSchema2(
|
|
55
68
|
z2.object({
|
|
@@ -108,34 +121,14 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
108
121
|
name: z2.string(),
|
|
109
122
|
input: z2.unknown(),
|
|
110
123
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
111
|
-
caller:
|
|
112
|
-
z2.object({
|
|
113
|
-
type: z2.literal("code_execution_20250825"),
|
|
114
|
-
tool_id: z2.string()
|
|
115
|
-
}),
|
|
116
|
-
z2.object({
|
|
117
|
-
type: z2.literal("code_execution_20260120"),
|
|
118
|
-
tool_id: z2.string()
|
|
119
|
-
}),
|
|
120
|
-
z2.object({
|
|
121
|
-
type: z2.literal("direct")
|
|
122
|
-
})
|
|
123
|
-
]).optional()
|
|
124
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
124
125
|
}),
|
|
125
126
|
z2.object({
|
|
126
127
|
type: z2.literal("server_tool_use"),
|
|
127
128
|
id: z2.string(),
|
|
128
129
|
name: z2.string(),
|
|
129
130
|
input: z2.record(z2.string(), z2.unknown()).nullish(),
|
|
130
|
-
caller:
|
|
131
|
-
z2.object({
|
|
132
|
-
type: z2.literal("code_execution_20260120"),
|
|
133
|
-
tool_id: z2.string()
|
|
134
|
-
}),
|
|
135
|
-
z2.object({
|
|
136
|
-
type: z2.literal("direct")
|
|
137
|
-
})
|
|
138
|
-
]).optional()
|
|
131
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
139
132
|
}),
|
|
140
133
|
z2.object({
|
|
141
134
|
type: z2.literal("mcp_tool_use"),
|
|
@@ -158,6 +151,7 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
158
151
|
z2.object({
|
|
159
152
|
type: z2.literal("web_fetch_tool_result"),
|
|
160
153
|
tool_use_id: z2.string(),
|
|
154
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
161
155
|
content: z2.union([
|
|
162
156
|
z2.object({
|
|
163
157
|
type: z2.literal("web_fetch_result"),
|
|
@@ -190,6 +184,7 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
190
184
|
z2.object({
|
|
191
185
|
type: z2.literal("web_search_tool_result"),
|
|
192
186
|
tool_use_id: z2.string(),
|
|
187
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
193
188
|
content: z2.union([
|
|
194
189
|
z2.array(
|
|
195
190
|
z2.object({
|
|
@@ -426,19 +421,7 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
426
421
|
id: z2.string(),
|
|
427
422
|
name: z2.string(),
|
|
428
423
|
input: z2.unknown(),
|
|
429
|
-
caller:
|
|
430
|
-
z2.object({
|
|
431
|
-
type: z2.literal("code_execution_20250825"),
|
|
432
|
-
tool_id: z2.string()
|
|
433
|
-
}),
|
|
434
|
-
z2.object({
|
|
435
|
-
type: z2.literal("code_execution_20260120"),
|
|
436
|
-
tool_id: z2.string()
|
|
437
|
-
}),
|
|
438
|
-
z2.object({
|
|
439
|
-
type: z2.literal("direct")
|
|
440
|
-
})
|
|
441
|
-
]).optional()
|
|
424
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
442
425
|
})
|
|
443
426
|
])
|
|
444
427
|
).nullish(),
|
|
@@ -468,19 +451,7 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
468
451
|
// Programmatic tool calling: input may be present directly for deferred tool calls
|
|
469
452
|
input: z2.record(z2.string(), z2.unknown()).optional(),
|
|
470
453
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
471
|
-
caller:
|
|
472
|
-
z2.object({
|
|
473
|
-
type: z2.literal("code_execution_20250825"),
|
|
474
|
-
tool_id: z2.string()
|
|
475
|
-
}),
|
|
476
|
-
z2.object({
|
|
477
|
-
type: z2.literal("code_execution_20260120"),
|
|
478
|
-
tool_id: z2.string()
|
|
479
|
-
}),
|
|
480
|
-
z2.object({
|
|
481
|
-
type: z2.literal("direct")
|
|
482
|
-
})
|
|
483
|
-
]).optional()
|
|
454
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
484
455
|
}),
|
|
485
456
|
z2.object({
|
|
486
457
|
type: z2.literal("redacted_thinking"),
|
|
@@ -495,15 +466,7 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
495
466
|
id: z2.string(),
|
|
496
467
|
name: z2.string(),
|
|
497
468
|
input: z2.record(z2.string(), z2.unknown()).nullish(),
|
|
498
|
-
caller:
|
|
499
|
-
z2.object({
|
|
500
|
-
type: z2.literal("code_execution_20260120"),
|
|
501
|
-
tool_id: z2.string()
|
|
502
|
-
}),
|
|
503
|
-
z2.object({
|
|
504
|
-
type: z2.literal("direct")
|
|
505
|
-
})
|
|
506
|
-
]).optional()
|
|
469
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
507
470
|
}),
|
|
508
471
|
z2.object({
|
|
509
472
|
type: z2.literal("mcp_tool_use"),
|
|
@@ -526,6 +489,7 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
526
489
|
z2.object({
|
|
527
490
|
type: z2.literal("web_fetch_tool_result"),
|
|
528
491
|
tool_use_id: z2.string(),
|
|
492
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
529
493
|
content: z2.union([
|
|
530
494
|
z2.object({
|
|
531
495
|
type: z2.literal("web_fetch_result"),
|
|
@@ -558,6 +522,7 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
558
522
|
z2.object({
|
|
559
523
|
type: z2.literal("web_search_tool_result"),
|
|
560
524
|
tool_use_id: z2.string(),
|
|
525
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
561
526
|
content: z2.union([
|
|
562
527
|
z2.array(
|
|
563
528
|
z2.object({
|
|
@@ -2290,7 +2255,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2290
2255
|
cacheControlValidator,
|
|
2291
2256
|
toolNameMapping
|
|
2292
2257
|
}) {
|
|
2293
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u
|
|
2258
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2294
2259
|
const betas = /* @__PURE__ */ new Set();
|
|
2295
2260
|
const blocks = groupIntoBlocks(prompt);
|
|
2296
2261
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
@@ -2695,6 +2660,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2695
2660
|
break;
|
|
2696
2661
|
}
|
|
2697
2662
|
case "tool-call": {
|
|
2663
|
+
const caller = getAnthropicCaller(part.providerOptions);
|
|
2698
2664
|
if (part.providerExecuted) {
|
|
2699
2665
|
const providerToolName = toolNameMapping.toProviderToolName(
|
|
2700
2666
|
part.toolName
|
|
@@ -2729,6 +2695,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2729
2695
|
name: subtoolName,
|
|
2730
2696
|
// map back to subtool name
|
|
2731
2697
|
input,
|
|
2698
|
+
...caller && { caller },
|
|
2732
2699
|
cache_control: cacheControl
|
|
2733
2700
|
});
|
|
2734
2701
|
} else if (
|
|
@@ -2742,6 +2709,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2742
2709
|
id: part.toolCallId,
|
|
2743
2710
|
name: "code_execution",
|
|
2744
2711
|
input: inputWithoutType,
|
|
2712
|
+
...caller && { caller },
|
|
2745
2713
|
cache_control: cacheControl
|
|
2746
2714
|
});
|
|
2747
2715
|
} else {
|
|
@@ -2752,6 +2720,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2752
2720
|
id: part.toolCallId,
|
|
2753
2721
|
name: providerToolName,
|
|
2754
2722
|
input: part.input,
|
|
2723
|
+
...caller && { caller },
|
|
2755
2724
|
cache_control: cacheControl
|
|
2756
2725
|
});
|
|
2757
2726
|
} else if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
|
|
@@ -2760,6 +2729,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2760
2729
|
id: part.toolCallId,
|
|
2761
2730
|
name: providerToolName,
|
|
2762
2731
|
input: part.input,
|
|
2732
|
+
...caller && { caller },
|
|
2763
2733
|
cache_control: cacheControl
|
|
2764
2734
|
});
|
|
2765
2735
|
} else if (providerToolName === "advisor") {
|
|
@@ -2768,6 +2738,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2768
2738
|
id: part.toolCallId,
|
|
2769
2739
|
name: "advisor",
|
|
2770
2740
|
input: {},
|
|
2741
|
+
...caller && { caller },
|
|
2771
2742
|
cache_control: cacheControl
|
|
2772
2743
|
});
|
|
2773
2744
|
} else {
|
|
@@ -2779,11 +2750,6 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2779
2750
|
}
|
|
2780
2751
|
break;
|
|
2781
2752
|
}
|
|
2782
|
-
const callerOptions = (_o = part.providerOptions) == null ? void 0 : _o.anthropic;
|
|
2783
|
-
const caller = (callerOptions == null ? void 0 : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
|
|
2784
|
-
type: callerOptions.caller.type,
|
|
2785
|
-
tool_id: callerOptions.caller.toolId
|
|
2786
|
-
} : callerOptions.caller.type === "direct" ? { type: "direct" } : void 0 : void 0;
|
|
2787
2753
|
anthropicContent.push({
|
|
2788
2754
|
type: "tool_use",
|
|
2789
2755
|
id: part.toolCallId,
|
|
@@ -2798,6 +2764,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2798
2764
|
const providerToolName = toolNameMapping.toProviderToolName(
|
|
2799
2765
|
part.toolName
|
|
2800
2766
|
);
|
|
2767
|
+
const caller = getAnthropicCaller(part.providerOptions);
|
|
2801
2768
|
if (mcpToolUseIds.has(part.toolCallId)) {
|
|
2802
2769
|
const output = part.output;
|
|
2803
2770
|
if (output.type !== "json" && output.type !== "error-json") {
|
|
@@ -2832,7 +2799,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2832
2799
|
tool_use_id: part.toolCallId,
|
|
2833
2800
|
content: {
|
|
2834
2801
|
type: "code_execution_tool_result_error",
|
|
2835
|
-
error_code: (
|
|
2802
|
+
error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
|
|
2836
2803
|
},
|
|
2837
2804
|
cache_control: cacheControl
|
|
2838
2805
|
});
|
|
@@ -2843,7 +2810,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2843
2810
|
cache_control: cacheControl,
|
|
2844
2811
|
content: {
|
|
2845
2812
|
type: "bash_code_execution_tool_result_error",
|
|
2846
|
-
error_code: (
|
|
2813
|
+
error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
|
|
2847
2814
|
}
|
|
2848
2815
|
});
|
|
2849
2816
|
}
|
|
@@ -2876,7 +2843,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2876
2843
|
stdout: codeExecutionOutput.stdout,
|
|
2877
2844
|
stderr: codeExecutionOutput.stderr,
|
|
2878
2845
|
return_code: codeExecutionOutput.return_code,
|
|
2879
|
-
content: (
|
|
2846
|
+
content: (_q = codeExecutionOutput.content) != null ? _q : []
|
|
2880
2847
|
},
|
|
2881
2848
|
cache_control: cacheControl
|
|
2882
2849
|
});
|
|
@@ -2894,7 +2861,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2894
2861
|
encrypted_stdout: codeExecutionOutput.encrypted_stdout,
|
|
2895
2862
|
stderr: codeExecutionOutput.stderr,
|
|
2896
2863
|
return_code: codeExecutionOutput.return_code,
|
|
2897
|
-
content: (
|
|
2864
|
+
content: (_r = codeExecutionOutput.content) != null ? _r : []
|
|
2898
2865
|
},
|
|
2899
2866
|
cache_control: cacheControl
|
|
2900
2867
|
});
|
|
@@ -2913,7 +2880,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2913
2880
|
stdout: codeExecutionOutput.stdout,
|
|
2914
2881
|
stderr: codeExecutionOutput.stderr,
|
|
2915
2882
|
return_code: codeExecutionOutput.return_code,
|
|
2916
|
-
content: (
|
|
2883
|
+
content: (_s = codeExecutionOutput.content) != null ? _s : []
|
|
2917
2884
|
},
|
|
2918
2885
|
cache_control: cacheControl
|
|
2919
2886
|
});
|
|
@@ -2951,8 +2918,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2951
2918
|
tool_use_id: part.toolCallId,
|
|
2952
2919
|
content: {
|
|
2953
2920
|
type: "web_fetch_tool_result_error",
|
|
2954
|
-
error_code: (
|
|
2921
|
+
error_code: (_t = (await extractErrorValue(output.value)).errorCode) != null ? _t : "unavailable"
|
|
2955
2922
|
},
|
|
2923
|
+
...caller && { caller },
|
|
2956
2924
|
cache_control: cacheControl
|
|
2957
2925
|
});
|
|
2958
2926
|
break;
|
|
@@ -2986,6 +2954,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2986
2954
|
}
|
|
2987
2955
|
}
|
|
2988
2956
|
},
|
|
2957
|
+
...caller && { caller },
|
|
2989
2958
|
cache_control: cacheControl
|
|
2990
2959
|
});
|
|
2991
2960
|
break;
|
|
@@ -2998,8 +2967,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2998
2967
|
tool_use_id: part.toolCallId,
|
|
2999
2968
|
content: {
|
|
3000
2969
|
type: "web_search_tool_result_error",
|
|
3001
|
-
error_code: (
|
|
2970
|
+
error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
|
|
3002
2971
|
},
|
|
2972
|
+
...caller && { caller },
|
|
3003
2973
|
cache_control: cacheControl
|
|
3004
2974
|
});
|
|
3005
2975
|
break;
|
|
@@ -3025,6 +2995,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
3025
2995
|
encrypted_content: result.encryptedContent,
|
|
3026
2996
|
type: result.type
|
|
3027
2997
|
})),
|
|
2998
|
+
...caller && { caller },
|
|
3028
2999
|
cache_control: cacheControl
|
|
3029
3000
|
});
|
|
3030
3001
|
break;
|
|
@@ -3196,6 +3167,17 @@ function moveToolUseBlocksToEnd(content) {
|
|
|
3196
3167
|
flushSegment();
|
|
3197
3168
|
return result;
|
|
3198
3169
|
}
|
|
3170
|
+
function getAnthropicCaller(providerOptions) {
|
|
3171
|
+
var _a;
|
|
3172
|
+
const caller = (_a = providerOptions == null ? void 0 : providerOptions.anthropic) == null ? void 0 : _a.caller;
|
|
3173
|
+
if (((caller == null ? void 0 : caller.type) === "code_execution_20250825" || (caller == null ? void 0 : caller.type) === "code_execution_20260120") && caller.toolId) {
|
|
3174
|
+
return {
|
|
3175
|
+
type: caller.type,
|
|
3176
|
+
tool_id: caller.toolId
|
|
3177
|
+
};
|
|
3178
|
+
}
|
|
3179
|
+
return (caller == null ? void 0 : caller.type) === "direct" ? { type: "direct" } : void 0;
|
|
3180
|
+
}
|
|
3199
3181
|
|
|
3200
3182
|
// src/map-anthropic-stop-reason.ts
|
|
3201
3183
|
function mapAnthropicStopReason({
|
|
@@ -3412,6 +3394,16 @@ function createCitationSource(citation, citationDocuments, generateId2) {
|
|
|
3412
3394
|
}
|
|
3413
3395
|
};
|
|
3414
3396
|
}
|
|
3397
|
+
function getAnthropicCallerInfo(caller) {
|
|
3398
|
+
return caller == null ? void 0 : {
|
|
3399
|
+
type: caller.type,
|
|
3400
|
+
toolId: "tool_id" in caller ? caller.tool_id : void 0
|
|
3401
|
+
};
|
|
3402
|
+
}
|
|
3403
|
+
function getAnthropicCallerMetadata(caller) {
|
|
3404
|
+
const callerInfo = getAnthropicCallerInfo(caller);
|
|
3405
|
+
return callerInfo == null ? {} : { providerMetadata: { anthropic: { caller: callerInfo } } };
|
|
3406
|
+
}
|
|
3415
3407
|
var AnthropicMessagesLanguageModel = class {
|
|
3416
3408
|
constructor(modelId, config) {
|
|
3417
3409
|
this.specificationVersion = "v3";
|
|
@@ -4060,23 +4052,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4060
4052
|
text: JSON.stringify(part.input)
|
|
4061
4053
|
});
|
|
4062
4054
|
} else {
|
|
4063
|
-
const caller = part.caller;
|
|
4064
|
-
const callerInfo = caller ? {
|
|
4065
|
-
type: caller.type,
|
|
4066
|
-
toolId: "tool_id" in caller ? caller.tool_id : void 0
|
|
4067
|
-
} : void 0;
|
|
4068
4055
|
content.push({
|
|
4069
4056
|
type: "tool-call",
|
|
4070
4057
|
toolCallId: part.id,
|
|
4071
4058
|
toolName: part.name,
|
|
4072
4059
|
input: JSON.stringify(part.input),
|
|
4073
|
-
...
|
|
4074
|
-
providerMetadata: {
|
|
4075
|
-
anthropic: {
|
|
4076
|
-
caller: callerInfo
|
|
4077
|
-
}
|
|
4078
|
-
}
|
|
4079
|
-
}
|
|
4060
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4080
4061
|
});
|
|
4081
4062
|
}
|
|
4082
4063
|
break;
|
|
@@ -4094,7 +4075,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4094
4075
|
// implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
|
|
4095
4076
|
// tool was not explicitly provided. We therefore bypass the general validation by marking the
|
|
4096
4077
|
// tool as dynamic.
|
|
4097
|
-
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
|
|
4078
|
+
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
4079
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4098
4080
|
});
|
|
4099
4081
|
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
4100
4082
|
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;
|
|
@@ -4108,7 +4090,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4108
4090
|
// implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
|
|
4109
4091
|
// tool was not explicitly provided. We therefore bypass the general validation by marking the
|
|
4110
4092
|
// tool as dynamic.
|
|
4111
|
-
...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {}
|
|
4093
|
+
...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {},
|
|
4094
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4112
4095
|
});
|
|
4113
4096
|
} else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
|
|
4114
4097
|
serverToolCalls[part.id] = part.name;
|
|
@@ -4117,7 +4100,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4117
4100
|
toolCallId: part.id,
|
|
4118
4101
|
toolName: toolNameMapping.toCustomToolName(part.name),
|
|
4119
4102
|
input: JSON.stringify(part.input),
|
|
4120
|
-
providerExecuted: true
|
|
4103
|
+
providerExecuted: true,
|
|
4104
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4121
4105
|
});
|
|
4122
4106
|
} else if (part.name === "advisor") {
|
|
4123
4107
|
content.push({
|
|
@@ -4125,7 +4109,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4125
4109
|
toolCallId: part.id,
|
|
4126
4110
|
toolName: toolNameMapping.toCustomToolName("advisor"),
|
|
4127
4111
|
input: JSON.stringify(part.input),
|
|
4128
|
-
providerExecuted: true
|
|
4112
|
+
providerExecuted: true,
|
|
4113
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4129
4114
|
});
|
|
4130
4115
|
}
|
|
4131
4116
|
break;
|
|
@@ -4184,7 +4169,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4184
4169
|
data: part.content.content.source.data
|
|
4185
4170
|
}
|
|
4186
4171
|
}
|
|
4187
|
-
}
|
|
4172
|
+
},
|
|
4173
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4188
4174
|
});
|
|
4189
4175
|
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
4190
4176
|
content.push({
|
|
@@ -4195,7 +4181,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4195
4181
|
result: {
|
|
4196
4182
|
type: "web_fetch_tool_result_error",
|
|
4197
4183
|
errorCode: part.content.error_code
|
|
4198
|
-
}
|
|
4184
|
+
},
|
|
4185
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4199
4186
|
});
|
|
4200
4187
|
}
|
|
4201
4188
|
break;
|
|
@@ -4215,7 +4202,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4215
4202
|
encryptedContent: result.encrypted_content,
|
|
4216
4203
|
type: result.type
|
|
4217
4204
|
};
|
|
4218
|
-
})
|
|
4205
|
+
}),
|
|
4206
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4219
4207
|
});
|
|
4220
4208
|
for (const result of part.content) {
|
|
4221
4209
|
content.push({
|
|
@@ -4240,7 +4228,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4240
4228
|
result: {
|
|
4241
4229
|
type: "web_search_tool_result_error",
|
|
4242
4230
|
errorCode: part.content.error_code
|
|
4243
|
-
}
|
|
4231
|
+
},
|
|
4232
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4244
4233
|
});
|
|
4245
4234
|
}
|
|
4246
4235
|
break;
|
|
@@ -4601,11 +4590,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4601
4590
|
id: String(value.index)
|
|
4602
4591
|
});
|
|
4603
4592
|
} else {
|
|
4604
|
-
const
|
|
4605
|
-
const callerInfo = caller ? {
|
|
4606
|
-
type: caller.type,
|
|
4607
|
-
toolId: "tool_id" in caller ? caller.tool_id : void 0
|
|
4608
|
-
} : void 0;
|
|
4593
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
4609
4594
|
const hasNonEmptyInput = part.input && Object.keys(part.input).length > 0;
|
|
4610
4595
|
const initialInput = hasNonEmptyInput ? JSON.stringify(part.input) : "";
|
|
4611
4596
|
contentBlocks[value.index] = {
|
|
@@ -4625,6 +4610,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4625
4610
|
return;
|
|
4626
4611
|
}
|
|
4627
4612
|
case "server_tool_use": {
|
|
4613
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
4628
4614
|
if ([
|
|
4629
4615
|
"web_fetch",
|
|
4630
4616
|
"web_search",
|
|
@@ -4652,7 +4638,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4652
4638
|
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
4653
4639
|
firstDelta: finalInput.length === 0,
|
|
4654
4640
|
providerToolName,
|
|
4655
|
-
providerToolInputType
|
|
4641
|
+
providerToolInputType,
|
|
4642
|
+
...callerInfo && { caller: callerInfo }
|
|
4656
4643
|
};
|
|
4657
4644
|
controller.enqueue({
|
|
4658
4645
|
type: "tool-input-start",
|
|
@@ -4677,7 +4664,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4677
4664
|
input: "",
|
|
4678
4665
|
providerExecuted: true,
|
|
4679
4666
|
firstDelta: true,
|
|
4680
|
-
providerToolName: part.name
|
|
4667
|
+
providerToolName: part.name,
|
|
4668
|
+
...callerInfo && { caller: callerInfo }
|
|
4681
4669
|
};
|
|
4682
4670
|
controller.enqueue({
|
|
4683
4671
|
type: "tool-input-start",
|
|
@@ -4694,7 +4682,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4694
4682
|
input: "{}",
|
|
4695
4683
|
providerExecuted: true,
|
|
4696
4684
|
firstDelta: true,
|
|
4697
|
-
providerToolName: part.name
|
|
4685
|
+
providerToolName: part.name,
|
|
4686
|
+
...callerInfo && { caller: callerInfo }
|
|
4698
4687
|
};
|
|
4699
4688
|
controller.enqueue({
|
|
4700
4689
|
type: "tool-input-start",
|
|
@@ -4729,7 +4718,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4729
4718
|
data: part.content.content.source.data
|
|
4730
4719
|
}
|
|
4731
4720
|
}
|
|
4732
|
-
}
|
|
4721
|
+
},
|
|
4722
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4733
4723
|
});
|
|
4734
4724
|
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
4735
4725
|
controller.enqueue({
|
|
@@ -4740,7 +4730,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4740
4730
|
result: {
|
|
4741
4731
|
type: "web_fetch_tool_result_error",
|
|
4742
4732
|
errorCode: part.content.error_code
|
|
4743
|
-
}
|
|
4733
|
+
},
|
|
4734
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4744
4735
|
});
|
|
4745
4736
|
}
|
|
4746
4737
|
return;
|
|
@@ -4760,7 +4751,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4760
4751
|
encryptedContent: result.encrypted_content,
|
|
4761
4752
|
type: result.type
|
|
4762
4753
|
};
|
|
4763
|
-
})
|
|
4754
|
+
}),
|
|
4755
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4764
4756
|
});
|
|
4765
4757
|
for (const result of part.content) {
|
|
4766
4758
|
controller.enqueue({
|
|
@@ -4785,7 +4777,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4785
4777
|
result: {
|
|
4786
4778
|
type: "web_search_tool_result_error",
|
|
4787
4779
|
errorCode: part.content.error_code
|
|
4788
|
-
}
|
|
4780
|
+
},
|
|
4781
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
4789
4782
|
});
|
|
4790
4783
|
}
|
|
4791
4784
|
return;
|
|
@@ -5185,11 +5178,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5185
5178
|
for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
|
|
5186
5179
|
const part = value.message.content[contentIndex];
|
|
5187
5180
|
if (part.type === "tool_use") {
|
|
5188
|
-
const
|
|
5189
|
-
const callerInfo = caller ? {
|
|
5190
|
-
type: caller.type,
|
|
5191
|
-
toolId: "tool_id" in caller ? caller.tool_id : void 0
|
|
5192
|
-
} : void 0;
|
|
5181
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
5193
5182
|
controller.enqueue({
|
|
5194
5183
|
type: "tool-input-start",
|
|
5195
5184
|
id: part.id,
|