@ai-sdk/anthropic 3.0.47 → 3.0.48
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.d.mts +138 -1
- package/dist/index.d.ts +138 -1
- package/dist/index.js +262 -124
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +266 -124
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +141 -1
- package/dist/internal/index.d.ts +141 -1
- package/dist/internal/index.js +255 -117
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +265 -123
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +10 -9
- package/package.json +1 -1
- package/src/anthropic-messages-api.ts +23 -1
- package/src/anthropic-messages-language-model.ts +7 -2
- package/src/anthropic-prepare-tools.ts +10 -1
- package/src/anthropic-tools.ts +15 -0
- package/src/convert-to-anthropic-messages-prompt.ts +6 -2
- package/src/tool/code-execution_20260120.ts +277 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -219,7 +219,7 @@ type AnthropicLanguageModelOptions = z.infer<typeof anthropicLanguageModelOption
|
|
|
219
219
|
|
|
220
220
|
interface AnthropicToolOptions {
|
|
221
221
|
deferLoading?: boolean;
|
|
222
|
-
allowedCallers?: Array<'code_execution_20250825'>;
|
|
222
|
+
allowedCallers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
declare const anthropicTools: {
|
|
@@ -409,6 +409,143 @@ declare const anthropicTools: {
|
|
|
409
409
|
old_lines: number | null;
|
|
410
410
|
old_start: number | null;
|
|
411
411
|
}>;
|
|
412
|
+
/**
|
|
413
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
414
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
415
|
+
* the API conversation.
|
|
416
|
+
*
|
|
417
|
+
* The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
|
|
418
|
+
* including writing code, in a secure, sandboxed environment.
|
|
419
|
+
*
|
|
420
|
+
* This is the recommended version. Does not require a beta header.
|
|
421
|
+
*
|
|
422
|
+
* Supported models: Claude Opus 4.6, Sonnet 4.6, Sonnet 4.5, Opus 4.5
|
|
423
|
+
*/
|
|
424
|
+
codeExecution_20260120: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
|
|
425
|
+
type: "programmatic-tool-call";
|
|
426
|
+
code: string;
|
|
427
|
+
} | {
|
|
428
|
+
type: "bash_code_execution";
|
|
429
|
+
command: string;
|
|
430
|
+
} | {
|
|
431
|
+
type: "text_editor_code_execution";
|
|
432
|
+
command: "view";
|
|
433
|
+
path: string;
|
|
434
|
+
} | {
|
|
435
|
+
type: "text_editor_code_execution";
|
|
436
|
+
command: "create";
|
|
437
|
+
path: string;
|
|
438
|
+
file_text?: string | null;
|
|
439
|
+
} | {
|
|
440
|
+
type: "text_editor_code_execution";
|
|
441
|
+
command: "str_replace";
|
|
442
|
+
path: string;
|
|
443
|
+
old_str: string;
|
|
444
|
+
new_str: string;
|
|
445
|
+
}, {
|
|
446
|
+
type: "code_execution_result";
|
|
447
|
+
stdout: string;
|
|
448
|
+
stderr: string;
|
|
449
|
+
return_code: number;
|
|
450
|
+
content: Array<{
|
|
451
|
+
type: "code_execution_output";
|
|
452
|
+
file_id: string;
|
|
453
|
+
}>;
|
|
454
|
+
} | {
|
|
455
|
+
type: "bash_code_execution_result";
|
|
456
|
+
content: Array<{
|
|
457
|
+
type: "bash_code_execution_output";
|
|
458
|
+
file_id: string;
|
|
459
|
+
}>;
|
|
460
|
+
stdout: string;
|
|
461
|
+
stderr: string;
|
|
462
|
+
return_code: number;
|
|
463
|
+
} | {
|
|
464
|
+
type: "bash_code_execution_tool_result_error";
|
|
465
|
+
error_code: string;
|
|
466
|
+
} | {
|
|
467
|
+
type: "text_editor_code_execution_tool_result_error";
|
|
468
|
+
error_code: string;
|
|
469
|
+
} | {
|
|
470
|
+
type: "text_editor_code_execution_view_result";
|
|
471
|
+
content: string;
|
|
472
|
+
file_type: string;
|
|
473
|
+
num_lines: number | null;
|
|
474
|
+
start_line: number | null;
|
|
475
|
+
total_lines: number | null;
|
|
476
|
+
} | {
|
|
477
|
+
type: "text_editor_code_execution_create_result";
|
|
478
|
+
is_file_update: boolean;
|
|
479
|
+
} | {
|
|
480
|
+
type: "text_editor_code_execution_str_replace_result";
|
|
481
|
+
lines: string[] | null;
|
|
482
|
+
new_lines: number | null;
|
|
483
|
+
new_start: number | null;
|
|
484
|
+
old_lines: number | null;
|
|
485
|
+
old_start: number | null;
|
|
486
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
487
|
+
type: "programmatic-tool-call";
|
|
488
|
+
code: string;
|
|
489
|
+
} | {
|
|
490
|
+
type: "bash_code_execution";
|
|
491
|
+
command: string;
|
|
492
|
+
} | {
|
|
493
|
+
type: "text_editor_code_execution";
|
|
494
|
+
command: "view";
|
|
495
|
+
path: string;
|
|
496
|
+
} | {
|
|
497
|
+
type: "text_editor_code_execution";
|
|
498
|
+
command: "create";
|
|
499
|
+
path: string;
|
|
500
|
+
file_text?: string | null;
|
|
501
|
+
} | {
|
|
502
|
+
type: "text_editor_code_execution";
|
|
503
|
+
command: "str_replace";
|
|
504
|
+
path: string;
|
|
505
|
+
old_str: string;
|
|
506
|
+
new_str: string;
|
|
507
|
+
}, {
|
|
508
|
+
type: "code_execution_result";
|
|
509
|
+
stdout: string;
|
|
510
|
+
stderr: string;
|
|
511
|
+
return_code: number;
|
|
512
|
+
content: Array<{
|
|
513
|
+
type: "code_execution_output";
|
|
514
|
+
file_id: string;
|
|
515
|
+
}>;
|
|
516
|
+
} | {
|
|
517
|
+
type: "bash_code_execution_result";
|
|
518
|
+
content: Array<{
|
|
519
|
+
type: "bash_code_execution_output";
|
|
520
|
+
file_id: string;
|
|
521
|
+
}>;
|
|
522
|
+
stdout: string;
|
|
523
|
+
stderr: string;
|
|
524
|
+
return_code: number;
|
|
525
|
+
} | {
|
|
526
|
+
type: "bash_code_execution_tool_result_error";
|
|
527
|
+
error_code: string;
|
|
528
|
+
} | {
|
|
529
|
+
type: "text_editor_code_execution_tool_result_error";
|
|
530
|
+
error_code: string;
|
|
531
|
+
} | {
|
|
532
|
+
type: "text_editor_code_execution_view_result";
|
|
533
|
+
content: string;
|
|
534
|
+
file_type: string;
|
|
535
|
+
num_lines: number | null;
|
|
536
|
+
start_line: number | null;
|
|
537
|
+
total_lines: number | null;
|
|
538
|
+
} | {
|
|
539
|
+
type: "text_editor_code_execution_create_result";
|
|
540
|
+
is_file_update: boolean;
|
|
541
|
+
} | {
|
|
542
|
+
type: "text_editor_code_execution_str_replace_result";
|
|
543
|
+
lines: string[] | null;
|
|
544
|
+
new_lines: number | null;
|
|
545
|
+
new_start: number | null;
|
|
546
|
+
old_lines: number | null;
|
|
547
|
+
old_start: number | null;
|
|
548
|
+
}>;
|
|
412
549
|
/**
|
|
413
550
|
* Claude can interact with computer environments through the computer use tool, which
|
|
414
551
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
package/dist/index.d.ts
CHANGED
|
@@ -219,7 +219,7 @@ type AnthropicLanguageModelOptions = z.infer<typeof anthropicLanguageModelOption
|
|
|
219
219
|
|
|
220
220
|
interface AnthropicToolOptions {
|
|
221
221
|
deferLoading?: boolean;
|
|
222
|
-
allowedCallers?: Array<'code_execution_20250825'>;
|
|
222
|
+
allowedCallers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
declare const anthropicTools: {
|
|
@@ -409,6 +409,143 @@ declare const anthropicTools: {
|
|
|
409
409
|
old_lines: number | null;
|
|
410
410
|
old_start: number | null;
|
|
411
411
|
}>;
|
|
412
|
+
/**
|
|
413
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
414
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
415
|
+
* the API conversation.
|
|
416
|
+
*
|
|
417
|
+
* The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
|
|
418
|
+
* including writing code, in a secure, sandboxed environment.
|
|
419
|
+
*
|
|
420
|
+
* This is the recommended version. Does not require a beta header.
|
|
421
|
+
*
|
|
422
|
+
* Supported models: Claude Opus 4.6, Sonnet 4.6, Sonnet 4.5, Opus 4.5
|
|
423
|
+
*/
|
|
424
|
+
codeExecution_20260120: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
|
|
425
|
+
type: "programmatic-tool-call";
|
|
426
|
+
code: string;
|
|
427
|
+
} | {
|
|
428
|
+
type: "bash_code_execution";
|
|
429
|
+
command: string;
|
|
430
|
+
} | {
|
|
431
|
+
type: "text_editor_code_execution";
|
|
432
|
+
command: "view";
|
|
433
|
+
path: string;
|
|
434
|
+
} | {
|
|
435
|
+
type: "text_editor_code_execution";
|
|
436
|
+
command: "create";
|
|
437
|
+
path: string;
|
|
438
|
+
file_text?: string | null;
|
|
439
|
+
} | {
|
|
440
|
+
type: "text_editor_code_execution";
|
|
441
|
+
command: "str_replace";
|
|
442
|
+
path: string;
|
|
443
|
+
old_str: string;
|
|
444
|
+
new_str: string;
|
|
445
|
+
}, {
|
|
446
|
+
type: "code_execution_result";
|
|
447
|
+
stdout: string;
|
|
448
|
+
stderr: string;
|
|
449
|
+
return_code: number;
|
|
450
|
+
content: Array<{
|
|
451
|
+
type: "code_execution_output";
|
|
452
|
+
file_id: string;
|
|
453
|
+
}>;
|
|
454
|
+
} | {
|
|
455
|
+
type: "bash_code_execution_result";
|
|
456
|
+
content: Array<{
|
|
457
|
+
type: "bash_code_execution_output";
|
|
458
|
+
file_id: string;
|
|
459
|
+
}>;
|
|
460
|
+
stdout: string;
|
|
461
|
+
stderr: string;
|
|
462
|
+
return_code: number;
|
|
463
|
+
} | {
|
|
464
|
+
type: "bash_code_execution_tool_result_error";
|
|
465
|
+
error_code: string;
|
|
466
|
+
} | {
|
|
467
|
+
type: "text_editor_code_execution_tool_result_error";
|
|
468
|
+
error_code: string;
|
|
469
|
+
} | {
|
|
470
|
+
type: "text_editor_code_execution_view_result";
|
|
471
|
+
content: string;
|
|
472
|
+
file_type: string;
|
|
473
|
+
num_lines: number | null;
|
|
474
|
+
start_line: number | null;
|
|
475
|
+
total_lines: number | null;
|
|
476
|
+
} | {
|
|
477
|
+
type: "text_editor_code_execution_create_result";
|
|
478
|
+
is_file_update: boolean;
|
|
479
|
+
} | {
|
|
480
|
+
type: "text_editor_code_execution_str_replace_result";
|
|
481
|
+
lines: string[] | null;
|
|
482
|
+
new_lines: number | null;
|
|
483
|
+
new_start: number | null;
|
|
484
|
+
old_lines: number | null;
|
|
485
|
+
old_start: number | null;
|
|
486
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
487
|
+
type: "programmatic-tool-call";
|
|
488
|
+
code: string;
|
|
489
|
+
} | {
|
|
490
|
+
type: "bash_code_execution";
|
|
491
|
+
command: string;
|
|
492
|
+
} | {
|
|
493
|
+
type: "text_editor_code_execution";
|
|
494
|
+
command: "view";
|
|
495
|
+
path: string;
|
|
496
|
+
} | {
|
|
497
|
+
type: "text_editor_code_execution";
|
|
498
|
+
command: "create";
|
|
499
|
+
path: string;
|
|
500
|
+
file_text?: string | null;
|
|
501
|
+
} | {
|
|
502
|
+
type: "text_editor_code_execution";
|
|
503
|
+
command: "str_replace";
|
|
504
|
+
path: string;
|
|
505
|
+
old_str: string;
|
|
506
|
+
new_str: string;
|
|
507
|
+
}, {
|
|
508
|
+
type: "code_execution_result";
|
|
509
|
+
stdout: string;
|
|
510
|
+
stderr: string;
|
|
511
|
+
return_code: number;
|
|
512
|
+
content: Array<{
|
|
513
|
+
type: "code_execution_output";
|
|
514
|
+
file_id: string;
|
|
515
|
+
}>;
|
|
516
|
+
} | {
|
|
517
|
+
type: "bash_code_execution_result";
|
|
518
|
+
content: Array<{
|
|
519
|
+
type: "bash_code_execution_output";
|
|
520
|
+
file_id: string;
|
|
521
|
+
}>;
|
|
522
|
+
stdout: string;
|
|
523
|
+
stderr: string;
|
|
524
|
+
return_code: number;
|
|
525
|
+
} | {
|
|
526
|
+
type: "bash_code_execution_tool_result_error";
|
|
527
|
+
error_code: string;
|
|
528
|
+
} | {
|
|
529
|
+
type: "text_editor_code_execution_tool_result_error";
|
|
530
|
+
error_code: string;
|
|
531
|
+
} | {
|
|
532
|
+
type: "text_editor_code_execution_view_result";
|
|
533
|
+
content: string;
|
|
534
|
+
file_type: string;
|
|
535
|
+
num_lines: number | null;
|
|
536
|
+
start_line: number | null;
|
|
537
|
+
total_lines: number | null;
|
|
538
|
+
} | {
|
|
539
|
+
type: "text_editor_code_execution_create_result";
|
|
540
|
+
is_file_update: boolean;
|
|
541
|
+
} | {
|
|
542
|
+
type: "text_editor_code_execution_str_replace_result";
|
|
543
|
+
lines: string[] | null;
|
|
544
|
+
new_lines: number | null;
|
|
545
|
+
new_start: number | null;
|
|
546
|
+
old_lines: number | null;
|
|
547
|
+
old_start: number | null;
|
|
548
|
+
}>;
|
|
412
549
|
/**
|
|
413
550
|
* Claude can interact with computer environments through the computer use tool, which
|
|
414
551
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|