@ai-sdk/anthropic 3.0.128 → 3.0.129
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 +7 -0
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -0
- package/dist/internal/index.d.ts +2 -0
- package/dist/internal/index.js +19 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +19 -2
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/anthropic-messages-api.ts +1 -0
- package/src/anthropic-prepare-tools.ts +6 -2
- package/src/convert-to-anthropic-messages-prompt.ts +24 -0
package/dist/internal/index.d.ts
CHANGED
package/dist/internal/index.js
CHANGED
|
@@ -1984,7 +1984,12 @@ async function prepareTools({
|
|
|
1984
1984
|
betas
|
|
1985
1985
|
};
|
|
1986
1986
|
case "none":
|
|
1987
|
-
return {
|
|
1987
|
+
return {
|
|
1988
|
+
tools: anthropicTools2,
|
|
1989
|
+
toolChoice: { type: "none" },
|
|
1990
|
+
toolWarnings,
|
|
1991
|
+
betas
|
|
1992
|
+
};
|
|
1988
1993
|
case "tool":
|
|
1989
1994
|
if (rejectsForcedToolUse) {
|
|
1990
1995
|
toolWarnings.push({
|
|
@@ -2433,7 +2438,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2433
2438
|
toolNameMapping,
|
|
2434
2439
|
toolsetNames = {}
|
|
2435
2440
|
}) {
|
|
2436
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2441
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
2437
2442
|
const betas = /* @__PURE__ */ new Set();
|
|
2438
2443
|
const blocks = groupIntoBlocks(prompt);
|
|
2439
2444
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
@@ -3245,6 +3250,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
3245
3250
|
}
|
|
3246
3251
|
if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
|
|
3247
3252
|
const output = part.output;
|
|
3253
|
+
if (output.type === "error-json" || output.type === "json" && output.value != null && typeof output.value === "object" && !Array.isArray(output.value) && "type" in output.value && output.value.type === "tool_search_tool_result_error") {
|
|
3254
|
+
anthropicContent.push({
|
|
3255
|
+
type: "tool_search_tool_result",
|
|
3256
|
+
tool_use_id: part.toolCallId,
|
|
3257
|
+
content: {
|
|
3258
|
+
type: "tool_search_tool_result_error",
|
|
3259
|
+
error_code: (_v = (await extractErrorValue(output.value)).errorCode) != null ? _v : "unavailable"
|
|
3260
|
+
},
|
|
3261
|
+
cache_control: cacheControl
|
|
3262
|
+
});
|
|
3263
|
+
break;
|
|
3264
|
+
}
|
|
3248
3265
|
if (output.type !== "json") {
|
|
3249
3266
|
warnings.push({
|
|
3250
3267
|
type: "other",
|