@ai-sdk/anthropic 3.0.20 → 3.0.21
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 +6 -0
- package/dist/index.js +58 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -26
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +57 -25
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +57 -25
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/__fixtures__/anthropic-tool-search-deferred-bm25.2.json +65 -0
- package/src/__fixtures__/anthropic-tool-search-deferred-bm25.chunks.txt +115 -0
- package/src/__fixtures__/anthropic-tool-search-deferred-regex.2.json +69 -0
- package/src/__fixtures__/anthropic-tool-search-deferred-regex.chunks.txt +119 -0
- package/src/anthropic-messages-language-model.test.ts +198 -0
- package/src/anthropic-messages-language-model.ts +38 -5
- package/src/tool/tool-search-bm25_20251119.ts +1 -0
- package/src/tool/tool-search-regex_20251119.ts +1 -0
|
@@ -987,8 +987,25 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
987
987
|
|
|
988
988
|
// tool search tool results:
|
|
989
989
|
case 'tool_search_tool_result': {
|
|
990
|
-
|
|
991
|
-
|
|
990
|
+
let providerToolName = serverToolCalls[part.tool_use_id];
|
|
991
|
+
|
|
992
|
+
if (providerToolName == null) {
|
|
993
|
+
const bm25CustomName = toolNameMapping.toCustomToolName(
|
|
994
|
+
'tool_search_tool_bm25',
|
|
995
|
+
);
|
|
996
|
+
const regexCustomName = toolNameMapping.toCustomToolName(
|
|
997
|
+
'tool_search_tool_regex',
|
|
998
|
+
);
|
|
999
|
+
|
|
1000
|
+
if (bm25CustomName !== 'tool_search_tool_bm25') {
|
|
1001
|
+
providerToolName = 'tool_search_tool_bm25';
|
|
1002
|
+
} else if (regexCustomName !== 'tool_search_tool_regex') {
|
|
1003
|
+
providerToolName = 'tool_search_tool_regex';
|
|
1004
|
+
} else {
|
|
1005
|
+
providerToolName = 'tool_search_tool_regex';
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
992
1009
|
if (part.content.type === 'tool_search_tool_search_result') {
|
|
993
1010
|
content.push({
|
|
994
1011
|
type: 'tool-result',
|
|
@@ -1480,9 +1497,25 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
1480
1497
|
|
|
1481
1498
|
// tool search tool results:
|
|
1482
1499
|
case 'tool_search_tool_result': {
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1500
|
+
let providerToolName = serverToolCalls[part.tool_use_id];
|
|
1501
|
+
|
|
1502
|
+
if (providerToolName == null) {
|
|
1503
|
+
const bm25CustomName = toolNameMapping.toCustomToolName(
|
|
1504
|
+
'tool_search_tool_bm25',
|
|
1505
|
+
);
|
|
1506
|
+
const regexCustomName = toolNameMapping.toCustomToolName(
|
|
1507
|
+
'tool_search_tool_regex',
|
|
1508
|
+
);
|
|
1509
|
+
|
|
1510
|
+
if (bm25CustomName !== 'tool_search_tool_bm25') {
|
|
1511
|
+
providerToolName = 'tool_search_tool_bm25';
|
|
1512
|
+
} else if (regexCustomName !== 'tool_search_tool_regex') {
|
|
1513
|
+
providerToolName = 'tool_search_tool_regex';
|
|
1514
|
+
} else {
|
|
1515
|
+
providerToolName = 'tool_search_tool_regex';
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1486
1519
|
if (part.content.type === 'tool_search_tool_search_result') {
|
|
1487
1520
|
controller.enqueue({
|
|
1488
1521
|
type: 'tool-result',
|
|
@@ -76,6 +76,7 @@ const factory = createProviderToolFactoryWithOutputSchema<
|
|
|
76
76
|
id: 'anthropic.tool_search_regex_20251119',
|
|
77
77
|
inputSchema: toolSearchRegex_20251119InputSchema,
|
|
78
78
|
outputSchema: toolSearchRegex_20251119OutputSchema,
|
|
79
|
+
supportsDeferredResults: true,
|
|
79
80
|
});
|
|
80
81
|
|
|
81
82
|
/**
|