@ai-sdk/anthropic 3.0.0-beta.69 → 3.0.0-beta.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 +15 -0
- package/dist/index.js +86 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -51
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +7 -2
- package/dist/internal/index.d.ts +7 -2
- package/dist/internal/index.js +85 -50
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +86 -50
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.71
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1bd7d32: feat: tool-specific strict mode
|
|
8
|
+
- Updated dependencies [1bd7d32]
|
|
9
|
+
- @ai-sdk/provider-utils@4.0.0-beta.41
|
|
10
|
+
- @ai-sdk/provider@3.0.0-beta.23
|
|
11
|
+
|
|
12
|
+
## 3.0.0-beta.70
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- f13958c: chore(antropic): allow custom names for provider-defined tools
|
|
17
|
+
|
|
3
18
|
## 3.0.0-beta.69
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ 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 ? "3.0.0-beta.
|
|
34
|
+
var VERSION = true ? "3.0.0-beta.71" : "0.0.0-test";
|
|
35
35
|
|
|
36
36
|
// src/anthropic-messages-language-model.ts
|
|
37
37
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -856,7 +856,8 @@ async function prepareTools({
|
|
|
856
856
|
tools,
|
|
857
857
|
toolChoice,
|
|
858
858
|
disableParallelToolUse,
|
|
859
|
-
cacheControlValidator
|
|
859
|
+
cacheControlValidator,
|
|
860
|
+
supportsStructuredOutput
|
|
860
861
|
}) {
|
|
861
862
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
862
863
|
const toolWarnings = [];
|
|
@@ -877,7 +878,8 @@ async function prepareTools({
|
|
|
877
878
|
name: tool.name,
|
|
878
879
|
description: tool.description,
|
|
879
880
|
input_schema: tool.inputSchema,
|
|
880
|
-
cache_control: cacheControl
|
|
881
|
+
cache_control: cacheControl,
|
|
882
|
+
...supportsStructuredOutput === true && tool.strict != null ? { strict: tool.strict } : {}
|
|
881
883
|
});
|
|
882
884
|
break;
|
|
883
885
|
}
|
|
@@ -1237,7 +1239,8 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1237
1239
|
prompt,
|
|
1238
1240
|
sendReasoning,
|
|
1239
1241
|
warnings,
|
|
1240
|
-
cacheControlValidator
|
|
1242
|
+
cacheControlValidator,
|
|
1243
|
+
toolNameMapping
|
|
1241
1244
|
}) {
|
|
1242
1245
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1243
1246
|
const betas = /* @__PURE__ */ new Set();
|
|
@@ -1575,6 +1578,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1575
1578
|
}
|
|
1576
1579
|
case "tool-call": {
|
|
1577
1580
|
if (part.providerExecuted) {
|
|
1581
|
+
const providerToolName = toolNameMapping.toProviderToolName(
|
|
1582
|
+
part.toolName
|
|
1583
|
+
);
|
|
1578
1584
|
const isMcpToolUse = ((_h = (_g = part.providerOptions) == null ? void 0 : _g.anthropic) == null ? void 0 : _h.type) === "mcp-tool-use";
|
|
1579
1585
|
if (isMcpToolUse) {
|
|
1580
1586
|
mcpToolUseIds.add(part.toolCallId);
|
|
@@ -1596,7 +1602,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1596
1602
|
});
|
|
1597
1603
|
} else if (
|
|
1598
1604
|
// code execution 20250825:
|
|
1599
|
-
|
|
1605
|
+
providerToolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && typeof part.input.type === "string" && (part.input.type === "bash_code_execution" || part.input.type === "text_editor_code_execution")
|
|
1600
1606
|
) {
|
|
1601
1607
|
anthropicContent.push({
|
|
1602
1608
|
type: "server_tool_use",
|
|
@@ -1606,20 +1612,22 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1606
1612
|
input: part.input,
|
|
1607
1613
|
cache_control: cacheControl
|
|
1608
1614
|
});
|
|
1609
|
-
} else if (part.toolName === "code_execution" || // code execution 20250522
|
|
1610
|
-
part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
1611
|
-
anthropicContent.push({
|
|
1612
|
-
type: "server_tool_use",
|
|
1613
|
-
id: part.toolCallId,
|
|
1614
|
-
name: part.toolName,
|
|
1615
|
-
input: part.input,
|
|
1616
|
-
cache_control: cacheControl
|
|
1617
|
-
});
|
|
1618
1615
|
} else {
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1616
|
+
if (providerToolName === "code_execution" || // code execution 20250522
|
|
1617
|
+
providerToolName === "web_fetch" || providerToolName === "web_search") {
|
|
1618
|
+
anthropicContent.push({
|
|
1619
|
+
type: "server_tool_use",
|
|
1620
|
+
id: part.toolCallId,
|
|
1621
|
+
name: providerToolName,
|
|
1622
|
+
input: part.input,
|
|
1623
|
+
cache_control: cacheControl
|
|
1624
|
+
});
|
|
1625
|
+
} else {
|
|
1626
|
+
warnings.push({
|
|
1627
|
+
type: "other",
|
|
1628
|
+
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1623
1631
|
}
|
|
1624
1632
|
break;
|
|
1625
1633
|
}
|
|
@@ -1633,6 +1641,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1633
1641
|
break;
|
|
1634
1642
|
}
|
|
1635
1643
|
case "tool-result": {
|
|
1644
|
+
const providerToolName = toolNameMapping.toProviderToolName(
|
|
1645
|
+
part.toolName
|
|
1646
|
+
);
|
|
1636
1647
|
if (mcpToolUseIds.has(part.toolCallId)) {
|
|
1637
1648
|
const output = part.output;
|
|
1638
1649
|
if (output.type !== "json" && output.type !== "error-json") {
|
|
@@ -1649,7 +1660,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1649
1660
|
content: output.value,
|
|
1650
1661
|
cache_control: cacheControl
|
|
1651
1662
|
});
|
|
1652
|
-
} else if (
|
|
1663
|
+
} else if (providerToolName === "code_execution") {
|
|
1653
1664
|
const output = part.output;
|
|
1654
1665
|
if (output.type !== "json") {
|
|
1655
1666
|
warnings.push({
|
|
@@ -1702,7 +1713,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1702
1713
|
}
|
|
1703
1714
|
break;
|
|
1704
1715
|
}
|
|
1705
|
-
if (
|
|
1716
|
+
if (providerToolName === "web_fetch") {
|
|
1706
1717
|
const output = part.output;
|
|
1707
1718
|
if (output.type !== "json") {
|
|
1708
1719
|
warnings.push({
|
|
@@ -1737,7 +1748,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1737
1748
|
});
|
|
1738
1749
|
break;
|
|
1739
1750
|
}
|
|
1740
|
-
if (
|
|
1751
|
+
if (providerToolName === "web_search") {
|
|
1741
1752
|
const output = part.output;
|
|
1742
1753
|
if (output.type !== "json") {
|
|
1743
1754
|
warnings.push({
|
|
@@ -1974,11 +1985,30 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1974
1985
|
inputSchema: responseFormat.schema
|
|
1975
1986
|
} : void 0;
|
|
1976
1987
|
const cacheControlValidator = new CacheControlValidator();
|
|
1988
|
+
const toolNameMapping = (0, import_provider_utils11.createToolNameMapping)({
|
|
1989
|
+
tools,
|
|
1990
|
+
providerToolNames: {
|
|
1991
|
+
"anthropic.code_execution_20250522": "code_execution",
|
|
1992
|
+
"anthropic.code_execution_20250825": "code_execution",
|
|
1993
|
+
"anthropic.computer_20241022": "computer",
|
|
1994
|
+
"anthropic.computer_20250124": "computer",
|
|
1995
|
+
"anthropic.text_editor_20241022": "str_replace_editor",
|
|
1996
|
+
"anthropic.text_editor_20250124": "str_replace_editor",
|
|
1997
|
+
"anthropic.text_editor_20250429": "str_replace_based_edit_tool",
|
|
1998
|
+
"anthropic.text_editor_20250728": "str_replace_based_edit_tool",
|
|
1999
|
+
"anthropic.bash_20241022": "bash",
|
|
2000
|
+
"anthropic.bash_20250124": "bash",
|
|
2001
|
+
"anthropic.memory_20250818": "memory",
|
|
2002
|
+
"anthropic.web_search_20250305": "web_search",
|
|
2003
|
+
"anthropic.web_fetch_20250910": "web_fetch"
|
|
2004
|
+
}
|
|
2005
|
+
});
|
|
1977
2006
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
1978
2007
|
prompt,
|
|
1979
2008
|
sendReasoning: (_b = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _b : true,
|
|
1980
2009
|
warnings,
|
|
1981
|
-
cacheControlValidator
|
|
2010
|
+
cacheControlValidator,
|
|
2011
|
+
toolNameMapping
|
|
1982
2012
|
});
|
|
1983
2013
|
const isThinking = ((_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type) === "enabled";
|
|
1984
2014
|
const thinkingBudget = (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens;
|
|
@@ -2111,12 +2141,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2111
2141
|
tools: [...tools != null ? tools : [], jsonResponseTool],
|
|
2112
2142
|
toolChoice: { type: "required" },
|
|
2113
2143
|
disableParallelToolUse: true,
|
|
2114
|
-
cacheControlValidator
|
|
2144
|
+
cacheControlValidator,
|
|
2145
|
+
supportsStructuredOutput
|
|
2115
2146
|
} : {
|
|
2116
2147
|
tools: tools != null ? tools : [],
|
|
2117
2148
|
toolChoice,
|
|
2118
2149
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
2119
|
-
cacheControlValidator
|
|
2150
|
+
cacheControlValidator,
|
|
2151
|
+
supportsStructuredOutput
|
|
2120
2152
|
}
|
|
2121
2153
|
);
|
|
2122
2154
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -2130,7 +2162,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2130
2162
|
},
|
|
2131
2163
|
warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
|
|
2132
2164
|
betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas, ...userSuppliedBetas]),
|
|
2133
|
-
usesJsonResponseTool: jsonResponseTool != null
|
|
2165
|
+
usesJsonResponseTool: jsonResponseTool != null,
|
|
2166
|
+
toolNameMapping
|
|
2134
2167
|
};
|
|
2135
2168
|
}
|
|
2136
2169
|
async getHeaders({
|
|
@@ -2188,7 +2221,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2188
2221
|
}
|
|
2189
2222
|
async doGenerate(options) {
|
|
2190
2223
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2191
|
-
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
|
|
2224
|
+
const { args, warnings, betas, usesJsonResponseTool, toolNameMapping } = await this.getArgs({
|
|
2192
2225
|
...options,
|
|
2193
2226
|
stream: false,
|
|
2194
2227
|
userSuppliedBetas: await this.getBetasFromHeaders(options.headers)
|
|
@@ -2279,7 +2312,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2279
2312
|
content.push({
|
|
2280
2313
|
type: "tool-call",
|
|
2281
2314
|
toolCallId: part.id,
|
|
2282
|
-
toolName: "code_execution",
|
|
2315
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2283
2316
|
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
2284
2317
|
providerExecuted: true
|
|
2285
2318
|
});
|
|
@@ -2287,7 +2320,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2287
2320
|
content.push({
|
|
2288
2321
|
type: "tool-call",
|
|
2289
2322
|
toolCallId: part.id,
|
|
2290
|
-
toolName: part.name,
|
|
2323
|
+
toolName: toolNameMapping.toCustomToolName(part.name),
|
|
2291
2324
|
input: JSON.stringify(part.input),
|
|
2292
2325
|
providerExecuted: true
|
|
2293
2326
|
});
|
|
@@ -2329,7 +2362,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2329
2362
|
content.push({
|
|
2330
2363
|
type: "tool-result",
|
|
2331
2364
|
toolCallId: part.tool_use_id,
|
|
2332
|
-
toolName: "web_fetch",
|
|
2365
|
+
toolName: toolNameMapping.toCustomToolName("web_fetch"),
|
|
2333
2366
|
result: {
|
|
2334
2367
|
type: "web_fetch_result",
|
|
2335
2368
|
url: part.content.url,
|
|
@@ -2350,7 +2383,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2350
2383
|
content.push({
|
|
2351
2384
|
type: "tool-result",
|
|
2352
2385
|
toolCallId: part.tool_use_id,
|
|
2353
|
-
toolName: "web_fetch",
|
|
2386
|
+
toolName: toolNameMapping.toCustomToolName("web_fetch"),
|
|
2354
2387
|
isError: true,
|
|
2355
2388
|
result: {
|
|
2356
2389
|
type: "web_fetch_tool_result_error",
|
|
@@ -2365,7 +2398,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2365
2398
|
content.push({
|
|
2366
2399
|
type: "tool-result",
|
|
2367
2400
|
toolCallId: part.tool_use_id,
|
|
2368
|
-
toolName: "web_search",
|
|
2401
|
+
toolName: toolNameMapping.toCustomToolName("web_search"),
|
|
2369
2402
|
result: part.content.map((result) => {
|
|
2370
2403
|
var _a2;
|
|
2371
2404
|
return {
|
|
@@ -2395,7 +2428,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2395
2428
|
content.push({
|
|
2396
2429
|
type: "tool-result",
|
|
2397
2430
|
toolCallId: part.tool_use_id,
|
|
2398
|
-
toolName: "web_search",
|
|
2431
|
+
toolName: toolNameMapping.toCustomToolName("web_search"),
|
|
2399
2432
|
isError: true,
|
|
2400
2433
|
result: {
|
|
2401
2434
|
type: "web_search_tool_result_error",
|
|
@@ -2411,7 +2444,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2411
2444
|
content.push({
|
|
2412
2445
|
type: "tool-result",
|
|
2413
2446
|
toolCallId: part.tool_use_id,
|
|
2414
|
-
toolName: "code_execution",
|
|
2447
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2415
2448
|
result: {
|
|
2416
2449
|
type: part.content.type,
|
|
2417
2450
|
stdout: part.content.stdout,
|
|
@@ -2423,7 +2456,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2423
2456
|
content.push({
|
|
2424
2457
|
type: "tool-result",
|
|
2425
2458
|
toolCallId: part.tool_use_id,
|
|
2426
|
-
toolName: "code_execution",
|
|
2459
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2427
2460
|
isError: true,
|
|
2428
2461
|
result: {
|
|
2429
2462
|
type: "code_execution_tool_result_error",
|
|
@@ -2439,7 +2472,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2439
2472
|
content.push({
|
|
2440
2473
|
type: "tool-result",
|
|
2441
2474
|
toolCallId: part.tool_use_id,
|
|
2442
|
-
toolName: "code_execution",
|
|
2475
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2443
2476
|
result: part.content
|
|
2444
2477
|
});
|
|
2445
2478
|
break;
|
|
@@ -2490,7 +2523,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2490
2523
|
args: body,
|
|
2491
2524
|
warnings,
|
|
2492
2525
|
betas,
|
|
2493
|
-
usesJsonResponseTool
|
|
2526
|
+
usesJsonResponseTool,
|
|
2527
|
+
toolNameMapping
|
|
2494
2528
|
} = await this.getArgs({
|
|
2495
2529
|
...options,
|
|
2496
2530
|
stream: true,
|
|
@@ -2616,19 +2650,21 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2616
2650
|
// code execution 20250825 bash:
|
|
2617
2651
|
"bash_code_execution"
|
|
2618
2652
|
].includes(part.name)) {
|
|
2653
|
+
const providerToolName = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? "code_execution" : part.name;
|
|
2654
|
+
const customToolName = toolNameMapping.toCustomToolName(providerToolName);
|
|
2619
2655
|
contentBlocks[value.index] = {
|
|
2620
2656
|
type: "tool-call",
|
|
2621
2657
|
toolCallId: part.id,
|
|
2622
|
-
toolName:
|
|
2658
|
+
toolName: customToolName,
|
|
2623
2659
|
input: "",
|
|
2624
2660
|
providerExecuted: true,
|
|
2625
|
-
firstDelta: true
|
|
2661
|
+
firstDelta: true,
|
|
2662
|
+
providerToolName: part.name
|
|
2626
2663
|
};
|
|
2627
|
-
const mappedToolName = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? "code_execution" : part.name;
|
|
2628
2664
|
controller.enqueue({
|
|
2629
2665
|
type: "tool-input-start",
|
|
2630
2666
|
id: part.id,
|
|
2631
|
-
toolName:
|
|
2667
|
+
toolName: customToolName,
|
|
2632
2668
|
providerExecuted: true
|
|
2633
2669
|
});
|
|
2634
2670
|
}
|
|
@@ -2639,7 +2675,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2639
2675
|
controller.enqueue({
|
|
2640
2676
|
type: "tool-result",
|
|
2641
2677
|
toolCallId: part.tool_use_id,
|
|
2642
|
-
toolName: "web_fetch",
|
|
2678
|
+
toolName: toolNameMapping.toCustomToolName("web_fetch"),
|
|
2643
2679
|
result: {
|
|
2644
2680
|
type: "web_fetch_result",
|
|
2645
2681
|
url: part.content.url,
|
|
@@ -2660,7 +2696,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2660
2696
|
controller.enqueue({
|
|
2661
2697
|
type: "tool-result",
|
|
2662
2698
|
toolCallId: part.tool_use_id,
|
|
2663
|
-
toolName: "web_fetch",
|
|
2699
|
+
toolName: toolNameMapping.toCustomToolName("web_fetch"),
|
|
2664
2700
|
isError: true,
|
|
2665
2701
|
result: {
|
|
2666
2702
|
type: "web_fetch_tool_result_error",
|
|
@@ -2675,7 +2711,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2675
2711
|
controller.enqueue({
|
|
2676
2712
|
type: "tool-result",
|
|
2677
2713
|
toolCallId: part.tool_use_id,
|
|
2678
|
-
toolName: "web_search",
|
|
2714
|
+
toolName: toolNameMapping.toCustomToolName("web_search"),
|
|
2679
2715
|
result: part.content.map((result) => {
|
|
2680
2716
|
var _a3;
|
|
2681
2717
|
return {
|
|
@@ -2705,7 +2741,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2705
2741
|
controller.enqueue({
|
|
2706
2742
|
type: "tool-result",
|
|
2707
2743
|
toolCallId: part.tool_use_id,
|
|
2708
|
-
toolName: "web_search",
|
|
2744
|
+
toolName: toolNameMapping.toCustomToolName("web_search"),
|
|
2709
2745
|
isError: true,
|
|
2710
2746
|
result: {
|
|
2711
2747
|
type: "web_search_tool_result_error",
|
|
@@ -2721,7 +2757,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2721
2757
|
controller.enqueue({
|
|
2722
2758
|
type: "tool-result",
|
|
2723
2759
|
toolCallId: part.tool_use_id,
|
|
2724
|
-
toolName: "code_execution",
|
|
2760
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2725
2761
|
result: {
|
|
2726
2762
|
type: part.content.type,
|
|
2727
2763
|
stdout: part.content.stdout,
|
|
@@ -2733,7 +2769,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2733
2769
|
controller.enqueue({
|
|
2734
2770
|
type: "tool-result",
|
|
2735
2771
|
toolCallId: part.tool_use_id,
|
|
2736
|
-
toolName: "code_execution",
|
|
2772
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2737
2773
|
isError: true,
|
|
2738
2774
|
result: {
|
|
2739
2775
|
type: "code_execution_tool_result_error",
|
|
@@ -2749,7 +2785,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2749
2785
|
controller.enqueue({
|
|
2750
2786
|
type: "tool-result",
|
|
2751
2787
|
toolCallId: part.tool_use_id,
|
|
2752
|
-
toolName: "code_execution",
|
|
2788
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2753
2789
|
result: part.content
|
|
2754
2790
|
});
|
|
2755
2791
|
return;
|
|
@@ -2817,11 +2853,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2817
2853
|
type: "tool-input-end",
|
|
2818
2854
|
id: contentBlock.toolCallId
|
|
2819
2855
|
});
|
|
2820
|
-
const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
|
|
2821
2856
|
controller.enqueue({
|
|
2822
2857
|
type: "tool-call",
|
|
2823
2858
|
toolCallId: contentBlock.toolCallId,
|
|
2824
|
-
toolName,
|
|
2859
|
+
toolName: contentBlock.toolName,
|
|
2825
2860
|
input: contentBlock.input === "" ? "{}" : contentBlock.input,
|
|
2826
2861
|
providerExecuted: contentBlock.providerExecuted
|
|
2827
2862
|
});
|
|
@@ -2889,8 +2924,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2889
2924
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2890
2925
|
return;
|
|
2891
2926
|
}
|
|
2892
|
-
if (contentBlock.firstDelta && (contentBlock.
|
|
2893
|
-
delta = `{"type": "${contentBlock.
|
|
2927
|
+
if (contentBlock.firstDelta && (contentBlock.providerToolName === "bash_code_execution" || contentBlock.providerToolName === "text_editor_code_execution")) {
|
|
2928
|
+
delta = `{"type": "${contentBlock.providerToolName}",${delta.substring(1)}`;
|
|
2894
2929
|
}
|
|
2895
2930
|
controller.enqueue({
|
|
2896
2931
|
type: "tool-input-delta",
|