@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "3.0.128",
3
+ "version": "3.0.129",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -554,6 +554,7 @@ export type AnthropicSpeed = 'fast' | 'standard';
554
554
 
555
555
  export type AnthropicToolChoice =
556
556
  | { type: 'auto' | 'any'; disable_parallel_tool_use?: boolean }
557
+ | { type: 'none' }
557
558
  | { type: 'tool'; name: string; disable_parallel_tool_use?: boolean };
558
559
 
559
560
  export type AnthropicContainer = {
@@ -477,8 +477,12 @@ export async function prepareTools({
477
477
  betas,
478
478
  };
479
479
  case 'none':
480
- // Anthropic does not support 'none' tool choice, so we remove the tools:
481
- return { tools: undefined, toolChoice: undefined, toolWarnings, betas };
480
+ return {
481
+ tools: anthropicTools,
482
+ toolChoice: { type: 'none' },
483
+ toolWarnings,
484
+ betas,
485
+ };
482
486
  case 'tool':
483
487
  if (rejectsForcedToolUse) {
484
488
  toolWarnings.push({
@@ -1207,6 +1207,30 @@ export async function convertToAnthropicMessagesPrompt({
1207
1207
  ) {
1208
1208
  const output = part.output;
1209
1209
 
1210
+ if (
1211
+ output.type === 'error-json' ||
1212
+ (output.type === 'json' &&
1213
+ output.value != null &&
1214
+ typeof output.value === 'object' &&
1215
+ !Array.isArray(output.value) &&
1216
+ 'type' in output.value &&
1217
+ output.value.type === 'tool_search_tool_result_error')
1218
+ ) {
1219
+ anthropicContent.push({
1220
+ type: 'tool_search_tool_result',
1221
+ tool_use_id: part.toolCallId,
1222
+ content: {
1223
+ type: 'tool_search_tool_result_error',
1224
+ error_code:
1225
+ (await extractErrorValue(output.value)).errorCode ??
1226
+ 'unavailable',
1227
+ },
1228
+ cache_control: cacheControl,
1229
+ });
1230
+
1231
+ break;
1232
+ }
1233
+
1210
1234
  if (output.type !== 'json') {
1211
1235
  warnings.push({
1212
1236
  type: 'other',