@anthropic-ai/sdk 0.104.1 → 0.105.0

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.
Files changed (98) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/client.d.mts +2 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs.map +1 -1
  8. package/internal/message-stream-utils.d.mts +10 -0
  9. package/internal/message-stream-utils.d.mts.map +1 -0
  10. package/internal/message-stream-utils.d.ts +10 -0
  11. package/internal/message-stream-utils.d.ts.map +1 -0
  12. package/internal/message-stream-utils.js +34 -0
  13. package/internal/message-stream-utils.js.map +1 -0
  14. package/internal/message-stream-utils.mjs +30 -0
  15. package/internal/message-stream-utils.mjs.map +1 -0
  16. package/lib/BetaMessageStream.d.mts.map +1 -1
  17. package/lib/BetaMessageStream.d.ts.map +1 -1
  18. package/lib/BetaMessageStream.js +36 -27
  19. package/lib/BetaMessageStream.js.map +1 -1
  20. package/lib/BetaMessageStream.mjs +36 -27
  21. package/lib/BetaMessageStream.mjs.map +1 -1
  22. package/lib/MessageStream.d.mts.map +1 -1
  23. package/lib/MessageStream.d.ts.map +1 -1
  24. package/lib/MessageStream.js +18 -22
  25. package/lib/MessageStream.js.map +1 -1
  26. package/lib/MessageStream.mjs +15 -19
  27. package/lib/MessageStream.mjs.map +1 -1
  28. package/lib/middleware.d.mts.map +1 -1
  29. package/lib/middleware.d.ts.map +1 -1
  30. package/lib/middleware.js +7 -1
  31. package/lib/middleware.js.map +1 -1
  32. package/lib/middleware.mjs +7 -1
  33. package/lib/middleware.mjs.map +1 -1
  34. package/package.json +1 -1
  35. package/resources/beta/beta.d.mts +4 -4
  36. package/resources/beta/beta.d.mts.map +1 -1
  37. package/resources/beta/beta.d.ts +4 -4
  38. package/resources/beta/beta.d.ts.map +1 -1
  39. package/resources/beta/beta.js.map +1 -1
  40. package/resources/beta/beta.mjs.map +1 -1
  41. package/resources/beta/index.d.mts +2 -2
  42. package/resources/beta/index.d.mts.map +1 -1
  43. package/resources/beta/index.d.ts +2 -2
  44. package/resources/beta/index.d.ts.map +1 -1
  45. package/resources/beta/index.js.map +1 -1
  46. package/resources/beta/index.mjs.map +1 -1
  47. package/resources/beta/messages/index.d.mts +1 -1
  48. package/resources/beta/messages/index.d.mts.map +1 -1
  49. package/resources/beta/messages/index.d.ts +1 -1
  50. package/resources/beta/messages/index.d.ts.map +1 -1
  51. package/resources/beta/messages/index.js.map +1 -1
  52. package/resources/beta/messages/index.mjs.map +1 -1
  53. package/resources/beta/messages/messages.d.mts +84 -44
  54. package/resources/beta/messages/messages.d.mts.map +1 -1
  55. package/resources/beta/messages/messages.d.ts +84 -44
  56. package/resources/beta/messages/messages.d.ts.map +1 -1
  57. package/resources/beta/messages/messages.js.map +1 -1
  58. package/resources/beta/messages/messages.mjs.map +1 -1
  59. package/resources/beta/webhooks.d.mts +11 -2
  60. package/resources/beta/webhooks.d.mts.map +1 -1
  61. package/resources/beta/webhooks.d.ts +11 -2
  62. package/resources/beta/webhooks.d.ts.map +1 -1
  63. package/resources/index.d.mts +1 -1
  64. package/resources/index.d.mts.map +1 -1
  65. package/resources/index.d.ts +1 -1
  66. package/resources/index.d.ts.map +1 -1
  67. package/resources/index.js.map +1 -1
  68. package/resources/index.mjs.map +1 -1
  69. package/resources/messages/index.d.mts +1 -1
  70. package/resources/messages/index.d.mts.map +1 -1
  71. package/resources/messages/index.d.ts +1 -1
  72. package/resources/messages/index.d.ts.map +1 -1
  73. package/resources/messages/index.js.map +1 -1
  74. package/resources/messages/index.mjs.map +1 -1
  75. package/resources/messages/messages.d.mts +47 -23
  76. package/resources/messages/messages.d.mts.map +1 -1
  77. package/resources/messages/messages.d.ts +47 -23
  78. package/resources/messages/messages.d.ts.map +1 -1
  79. package/resources/messages/messages.js.map +1 -1
  80. package/resources/messages/messages.mjs.map +1 -1
  81. package/src/client.ts +2 -0
  82. package/src/internal/message-stream-utils.ts +30 -0
  83. package/src/lib/BetaMessageStream.ts +37 -30
  84. package/src/lib/MessageStream.ts +15 -22
  85. package/src/lib/middleware.ts +7 -1
  86. package/src/resources/beta/beta.ts +6 -0
  87. package/src/resources/beta/index.ts +3 -0
  88. package/src/resources/beta/messages/index.ts +2 -0
  89. package/src/resources/beta/messages/messages.ts +141 -41
  90. package/src/resources/beta/webhooks.ts +16 -1
  91. package/src/resources/index.ts +1 -0
  92. package/src/resources/messages/index.ts +1 -0
  93. package/src/resources/messages/messages.ts +86 -24
  94. package/src/version.ts +1 -1
  95. package/version.d.mts +1 -1
  96. package/version.d.ts +1 -1
  97. package/version.js +1 -1
  98. package/version.mjs +1 -1
@@ -605,7 +605,9 @@ export interface CodeExecutionTool20250522 {
605
605
 
606
606
  type: 'code_execution_20250522';
607
607
 
608
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
608
+ allowed_callers?: Array<
609
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
610
+ >;
609
611
 
610
612
  /**
611
613
  * Create a cache control breakpoint at this content block.
@@ -634,7 +636,9 @@ export interface CodeExecutionTool20250825 {
634
636
 
635
637
  type: 'code_execution_20250825';
636
638
 
637
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
639
+ allowed_callers?: Array<
640
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
641
+ >;
638
642
 
639
643
  /**
640
644
  * Create a cache control breakpoint at this content block.
@@ -667,7 +671,43 @@ export interface CodeExecutionTool20260120 {
667
671
 
668
672
  type: 'code_execution_20260120';
669
673
 
670
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
674
+ allowed_callers?: Array<
675
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
676
+ >;
677
+
678
+ /**
679
+ * Create a cache control breakpoint at this content block.
680
+ */
681
+ cache_control?: CacheControlEphemeral | null;
682
+
683
+ /**
684
+ * If true, tool will not be included in initial system prompt. Only loaded when
685
+ * returned via tool_reference from tool search.
686
+ */
687
+ defer_loading?: boolean;
688
+
689
+ /**
690
+ * When true, guarantees schema validation on tool names and inputs
691
+ */
692
+ strict?: boolean;
693
+ }
694
+
695
+ /**
696
+ * Code execution tool with REPL state persistence.
697
+ */
698
+ export interface CodeExecutionTool20260521 {
699
+ /**
700
+ * Name of the tool.
701
+ *
702
+ * This is how the tool will be called by the model and in `tool_use` blocks.
703
+ */
704
+ name: 'code_execution';
705
+
706
+ type: 'code_execution_20260521';
707
+
708
+ allowed_callers?: Array<
709
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
710
+ >;
671
711
 
672
712
  /**
673
713
  * Create a cache control breakpoint at this content block.
@@ -940,7 +980,9 @@ export interface MemoryTool20250818 {
940
980
 
941
981
  type: 'memory_20250818';
942
982
 
943
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
983
+ allowed_callers?: Array<
984
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
985
+ >;
944
986
 
945
987
  /**
946
988
  * Create a cache control breakpoint at this content block.
@@ -1095,6 +1137,7 @@ export type MessageCountTokensTool =
1095
1137
  | CodeExecutionTool20250522
1096
1138
  | CodeExecutionTool20250825
1097
1139
  | CodeExecutionTool20260120
1140
+ | CodeExecutionTool20260521
1098
1141
  | MemoryTool20250818
1099
1142
  | ToolTextEditor20250124
1100
1143
  | ToolTextEditor20250429
@@ -1212,11 +1255,6 @@ export type Model =
1212
1255
  | 'claude-sonnet-4-5-20250929'
1213
1256
  | 'claude-opus-4-1'
1214
1257
  | 'claude-opus-4-1-20250805'
1215
- | 'claude-opus-4-0'
1216
- | 'claude-opus-4-20250514'
1217
- | 'claude-sonnet-4-0'
1218
- | 'claude-sonnet-4-20250514'
1219
- | 'claude-3-haiku-20240307'
1220
1258
  | (string & {});
1221
1259
 
1222
1260
  export interface OutputConfig {
@@ -1403,9 +1441,7 @@ export interface RedactedThinkingBlockParam {
1403
1441
  */
1404
1442
  export interface RefusalStopDetails {
1405
1443
  /**
1406
- * The policy category that triggered the refusal.
1407
- *
1408
- * `null` when the refusal doesn't map to a named category.
1444
+ * The policy category that triggered a refusal.
1409
1445
  */
1410
1446
  category: 'cyber' | 'bio' | 'frontier_llm' | 'reasoning_extraction' | null;
1411
1447
 
@@ -1781,7 +1817,9 @@ export interface Tool {
1781
1817
  */
1782
1818
  name: string;
1783
1819
 
1784
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
1820
+ allowed_callers?: Array<
1821
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
1822
+ >;
1785
1823
 
1786
1824
  /**
1787
1825
  * Create a cache control breakpoint at this content block.
@@ -1851,7 +1889,9 @@ export interface ToolBash20250124 {
1851
1889
 
1852
1890
  type: 'bash_20250124';
1853
1891
 
1854
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
1892
+ allowed_callers?: Array<
1893
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
1894
+ >;
1855
1895
 
1856
1896
  /**
1857
1897
  * Create a cache control breakpoint at this content block.
@@ -1988,7 +2028,9 @@ export interface ToolSearchToolBm25_20251119 {
1988
2028
 
1989
2029
  type: 'tool_search_tool_bm25_20251119' | 'tool_search_tool_bm25';
1990
2030
 
1991
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2031
+ allowed_callers?: Array<
2032
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
2033
+ >;
1992
2034
 
1993
2035
  /**
1994
2036
  * Create a cache control breakpoint at this content block.
@@ -2017,7 +2059,9 @@ export interface ToolSearchToolRegex20251119 {
2017
2059
 
2018
2060
  type: 'tool_search_tool_regex_20251119' | 'tool_search_tool_regex';
2019
2061
 
2020
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2062
+ allowed_callers?: Array<
2063
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
2064
+ >;
2021
2065
 
2022
2066
  /**
2023
2067
  * Create a cache control breakpoint at this content block.
@@ -2101,7 +2145,9 @@ export interface ToolTextEditor20250124 {
2101
2145
 
2102
2146
  type: 'text_editor_20250124';
2103
2147
 
2104
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2148
+ allowed_callers?: Array<
2149
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
2150
+ >;
2105
2151
 
2106
2152
  /**
2107
2153
  * Create a cache control breakpoint at this content block.
@@ -2132,7 +2178,9 @@ export interface ToolTextEditor20250429 {
2132
2178
 
2133
2179
  type: 'text_editor_20250429';
2134
2180
 
2135
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2181
+ allowed_callers?: Array<
2182
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
2183
+ >;
2136
2184
 
2137
2185
  /**
2138
2186
  * Create a cache control breakpoint at this content block.
@@ -2163,7 +2211,9 @@ export interface ToolTextEditor20250728 {
2163
2211
 
2164
2212
  type: 'text_editor_20250728';
2165
2213
 
2166
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2214
+ allowed_callers?: Array<
2215
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
2216
+ >;
2167
2217
 
2168
2218
  /**
2169
2219
  * Create a cache control breakpoint at this content block.
@@ -2200,6 +2250,7 @@ export type ToolUnion =
2200
2250
  | CodeExecutionTool20250522
2201
2251
  | CodeExecutionTool20250825
2202
2252
  | CodeExecutionTool20260120
2253
+ | CodeExecutionTool20260521
2203
2254
  | MemoryTool20250818
2204
2255
  | ToolTextEditor20250124
2205
2256
  | ToolTextEditor20250429
@@ -2379,7 +2430,9 @@ export interface WebFetchTool20250910 {
2379
2430
 
2380
2431
  type: 'web_fetch_20250910';
2381
2432
 
2382
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2433
+ allowed_callers?: Array<
2434
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
2435
+ >;
2383
2436
 
2384
2437
  /**
2385
2438
  * List of domains to allow fetching from
@@ -2435,7 +2488,9 @@ export interface WebFetchTool20260209 {
2435
2488
 
2436
2489
  type: 'web_fetch_20260209';
2437
2490
 
2438
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2491
+ allowed_callers?: Array<
2492
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
2493
+ >;
2439
2494
 
2440
2495
  /**
2441
2496
  * List of domains to allow fetching from
@@ -2494,7 +2549,9 @@ export interface WebFetchTool20260309 {
2494
2549
 
2495
2550
  type: 'web_fetch_20260309';
2496
2551
 
2497
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2552
+ allowed_callers?: Array<
2553
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
2554
+ >;
2498
2555
 
2499
2556
  /**
2500
2557
  * List of domains to allow fetching from
@@ -2635,7 +2692,9 @@ export interface WebSearchTool20250305 {
2635
2692
 
2636
2693
  type: 'web_search_20250305';
2637
2694
 
2638
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2695
+ allowed_callers?: Array<
2696
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
2697
+ >;
2639
2698
 
2640
2699
  /**
2641
2700
  * If provided, only these domains will be included in results. Cannot be used
@@ -2696,7 +2755,9 @@ export interface WebSearchTool20260209 {
2696
2755
 
2697
2756
  type: 'web_search_20260209';
2698
2757
 
2699
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2758
+ allowed_callers?: Array<
2759
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
2760
+ >;
2700
2761
 
2701
2762
  /**
2702
2763
  * If provided, only these domains will be included in results. Cannot be used
@@ -3356,6 +3417,7 @@ export declare namespace Messages {
3356
3417
  type CodeExecutionTool20250522 as CodeExecutionTool20250522,
3357
3418
  type CodeExecutionTool20250825 as CodeExecutionTool20250825,
3358
3419
  type CodeExecutionTool20260120 as CodeExecutionTool20260120,
3420
+ type CodeExecutionTool20260521 as CodeExecutionTool20260521,
3359
3421
  type CodeExecutionToolResultBlock as CodeExecutionToolResultBlock,
3360
3422
  type CodeExecutionToolResultBlockContent as CodeExecutionToolResultBlockContent,
3361
3423
  type CodeExecutionToolResultBlockParam as CodeExecutionToolResultBlockParam,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.104.1'; // x-release-please-version
1
+ export const VERSION = '0.105.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.104.1";
1
+ export declare const VERSION = "0.105.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.104.1";
1
+ export declare const VERSION = "0.105.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.104.1'; // x-release-please-version
4
+ exports.VERSION = '0.105.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.104.1'; // x-release-please-version
1
+ export const VERSION = '0.105.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map