@anthropic-ai/sdk 0.38.0 → 0.40.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 (101) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/_shims/index.d.ts +2 -0
  3. package/_shims/index.js +5 -1
  4. package/_shims/index.mjs +5 -1
  5. package/core.d.ts +12 -1
  6. package/core.d.ts.map +1 -1
  7. package/core.js +10 -7
  8. package/core.js.map +1 -1
  9. package/core.mjs +11 -8
  10. package/core.mjs.map +1 -1
  11. package/index.d.mts +2 -2
  12. package/index.d.ts +2 -2
  13. package/index.d.ts.map +1 -1
  14. package/index.js +4 -9
  15. package/index.js.map +1 -1
  16. package/index.mjs +4 -9
  17. package/index.mjs.map +1 -1
  18. package/package.json +8 -29
  19. package/resources/beta/beta.d.ts +2 -2
  20. package/resources/beta/beta.d.ts.map +1 -1
  21. package/resources/beta/beta.js.map +1 -1
  22. package/resources/beta/beta.mjs.map +1 -1
  23. package/resources/beta/index.d.ts +1 -1
  24. package/resources/beta/index.d.ts.map +1 -1
  25. package/resources/beta/index.js.map +1 -1
  26. package/resources/beta/index.mjs.map +1 -1
  27. package/resources/beta/messages/batches.d.ts +1 -1
  28. package/resources/beta/messages/batches.d.ts.map +1 -1
  29. package/resources/beta/messages/batches.js +1 -0
  30. package/resources/beta/messages/batches.js.map +1 -1
  31. package/resources/beta/messages/batches.mjs +1 -0
  32. package/resources/beta/messages/batches.mjs.map +1 -1
  33. package/resources/beta/messages/index.d.ts +1 -1
  34. package/resources/beta/messages/index.d.ts.map +1 -1
  35. package/resources/beta/messages/index.js.map +1 -1
  36. package/resources/beta/messages/index.mjs.map +1 -1
  37. package/resources/beta/messages/messages.d.ts +16 -8
  38. package/resources/beta/messages/messages.d.ts.map +1 -1
  39. package/resources/beta/messages/messages.js.map +1 -1
  40. package/resources/beta/messages/messages.mjs.map +1 -1
  41. package/resources/beta/messages.d.ts +2 -0
  42. package/resources/beta/messages.d.ts.map +1 -0
  43. package/resources/beta/messages.js +19 -0
  44. package/resources/beta/messages.js.map +1 -0
  45. package/resources/beta/messages.mjs +3 -0
  46. package/resources/beta/messages.mjs.map +1 -0
  47. package/resources/beta.d.ts +2 -0
  48. package/resources/beta.d.ts.map +1 -0
  49. package/resources/beta.js +19 -0
  50. package/resources/beta.js.map +1 -0
  51. package/resources/beta.mjs +3 -0
  52. package/resources/beta.mjs.map +1 -0
  53. package/resources/index.d.ts +1 -1
  54. package/resources/index.d.ts.map +1 -1
  55. package/resources/index.js.map +1 -1
  56. package/resources/index.mjs.map +1 -1
  57. package/resources/messages/batches.d.ts.map +1 -1
  58. package/resources/messages/batches.js.map +1 -1
  59. package/resources/messages/batches.mjs.map +1 -1
  60. package/resources/messages/index.d.ts +1 -1
  61. package/resources/messages/index.d.ts.map +1 -1
  62. package/resources/messages/index.js.map +1 -1
  63. package/resources/messages/index.mjs.map +1 -1
  64. package/resources/messages/messages.d.ts +23 -15
  65. package/resources/messages/messages.d.ts.map +1 -1
  66. package/resources/messages/messages.js.map +1 -1
  67. package/resources/messages/messages.mjs.map +1 -1
  68. package/resources/messages.d.ts +2 -0
  69. package/resources/messages.d.ts.map +1 -0
  70. package/resources/messages.js +19 -0
  71. package/resources/messages.js.map +1 -0
  72. package/resources/messages.mjs +3 -0
  73. package/resources/messages.mjs.map +1 -0
  74. package/resources.d.ts +2 -0
  75. package/resources.d.ts.map +1 -0
  76. package/resources.js +18 -0
  77. package/resources.js.map +1 -0
  78. package/resources.mjs +2 -0
  79. package/resources.mjs.map +1 -0
  80. package/src/_shims/index.d.ts +2 -0
  81. package/src/_shims/index.js +5 -1
  82. package/src/_shims/index.mjs +5 -1
  83. package/src/core.ts +27 -8
  84. package/src/index.ts +17 -18
  85. package/src/resources/beta/beta.ts +6 -0
  86. package/src/resources/beta/index.ts +3 -0
  87. package/src/resources/beta/messages/batches.ts +6 -2
  88. package/src/resources/beta/messages/index.ts +3 -0
  89. package/src/resources/beta/messages/messages.ts +27 -7
  90. package/src/resources/beta/messages.ts +3 -0
  91. package/src/resources/beta.ts +3 -0
  92. package/src/resources/index.ts +10 -7
  93. package/src/resources/messages/batches.ts +4 -1
  94. package/src/resources/messages/index.ts +10 -7
  95. package/src/resources/messages/messages.ts +48 -28
  96. package/src/resources/messages.ts +3 -0
  97. package/src/resources.ts +1 -0
  98. package/src/version.ts +1 -1
  99. package/version.d.ts +1 -1
  100. package/version.js +1 -1
  101. package/version.mjs +1 -1
@@ -37,29 +37,23 @@ export {
37
37
  type CitationsConfigParam,
38
38
  type CitationsDelta,
39
39
  type ContentBlock,
40
- type ContentBlockDeltaEvent,
41
40
  type ContentBlockParam,
42
41
  type ContentBlockSource,
43
42
  type ContentBlockSourceContent,
44
- type ContentBlockStartEvent,
45
- type ContentBlockStopEvent,
46
43
  type DocumentBlockParam,
47
44
  type ImageBlockParam,
48
45
  type InputJsonDelta,
49
46
  type InputJSONDelta,
50
47
  type Message,
51
48
  type MessageCountTokensTool,
52
- type MessageDeltaEvent,
53
49
  type MessageDeltaUsage,
54
50
  type MessageParam,
55
- type MessageStartEvent,
56
- type MessageStopEvent,
57
- type MessageStreamEvent,
58
51
  type MessageStreamParams,
59
52
  type MessageTokensCount,
60
53
  type Metadata,
61
54
  type Model,
62
55
  type PlainTextSource,
56
+ type RawContentBlockDelta,
63
57
  type RawContentBlockDeltaEvent,
64
58
  type RawContentBlockStartEvent,
65
59
  type RawContentBlockStopEvent,
@@ -70,6 +64,7 @@ export {
70
64
  type RedactedThinkingBlock,
71
65
  type RedactedThinkingBlockParam,
72
66
  type SignatureDelta,
67
+ type StopReason,
73
68
  type TextBlock,
74
69
  type TextBlockParam,
75
70
  type TextCitation,
@@ -86,6 +81,7 @@ export {
86
81
  type ToolChoice,
87
82
  type ToolChoiceAny,
88
83
  type ToolChoiceAuto,
84
+ type ToolChoiceNone,
89
85
  type ToolChoiceTool,
90
86
  type ToolResultBlockParam,
91
87
  type ToolTextEditor20250124,
@@ -95,6 +91,13 @@ export {
95
91
  type URLImageSource,
96
92
  type URLPDFSource,
97
93
  type Usage,
94
+ type MessageStreamEvent,
95
+ type MessageStartEvent,
96
+ type MessageDeltaEvent,
97
+ type MessageStopEvent,
98
+ type ContentBlockStartEvent,
99
+ type ContentBlockDeltaEvent,
100
+ type ContentBlockStopEvent,
98
101
  type MessageCreateParams,
99
102
  type MessageCreateParamsNonStreaming,
100
103
  type MessageCreateParamsStreaming,
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { APIResource } from "../../resource.js";
4
4
  import { isRequestOptions } from "../../core.js";
5
+ import { APIPromise } from "../../core.js";
5
6
  import * as Core from "../../core.js";
6
7
  import * as Shared from "../shared.js";
7
8
  import * as MessagesAPI from "./messages.js";
@@ -119,7 +120,9 @@ export class Batches extends APIResource {
119
120
  },
120
121
  __binaryResponse: true,
121
122
  })
122
- ._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller));
123
+ ._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller)) as APIPromise<
124
+ JSONLDecoder<MessageBatchIndividualResponse>
125
+ >;
123
126
  }
124
127
  }
125
128
 
@@ -29,27 +29,21 @@ export {
29
29
  type CitationsConfigParam,
30
30
  type CitationsDelta,
31
31
  type ContentBlock,
32
- type ContentBlockDeltaEvent,
33
32
  type ContentBlockParam,
34
33
  type ContentBlockSource,
35
34
  type ContentBlockSourceContent,
36
- type ContentBlockStartEvent,
37
- type ContentBlockStopEvent,
38
35
  type DocumentBlockParam,
39
36
  type ImageBlockParam,
40
37
  type InputJSONDelta,
41
38
  type Message,
42
39
  type MessageCountTokensTool,
43
- type MessageDeltaEvent,
44
40
  type MessageDeltaUsage,
45
41
  type MessageParam,
46
- type MessageStartEvent,
47
- type MessageStopEvent,
48
- type MessageStreamEvent,
49
42
  type MessageTokensCount,
50
43
  type Metadata,
51
44
  type Model,
52
45
  type PlainTextSource,
46
+ type RawContentBlockDelta,
53
47
  type RawContentBlockDeltaEvent,
54
48
  type RawContentBlockStartEvent,
55
49
  type RawContentBlockStopEvent,
@@ -60,6 +54,7 @@ export {
60
54
  type RedactedThinkingBlock,
61
55
  type RedactedThinkingBlockParam,
62
56
  type SignatureDelta,
57
+ type StopReason,
63
58
  type TextBlock,
64
59
  type TextBlockParam,
65
60
  type TextCitation,
@@ -76,6 +71,7 @@ export {
76
71
  type ToolChoice,
77
72
  type ToolChoiceAny,
78
73
  type ToolChoiceAuto,
74
+ type ToolChoiceNone,
79
75
  type ToolChoiceTool,
80
76
  type ToolResultBlockParam,
81
77
  type ToolTextEditor20250124,
@@ -85,6 +81,13 @@ export {
85
81
  type URLImageSource,
86
82
  type URLPDFSource,
87
83
  type Usage,
84
+ type MessageStreamEvent,
85
+ type MessageStartEvent,
86
+ type MessageDeltaEvent,
87
+ type MessageStopEvent,
88
+ type ContentBlockStartEvent,
89
+ type ContentBlockDeltaEvent,
90
+ type ContentBlockStopEvent,
88
91
  type MessageCreateParams,
89
92
  type MessageCreateParamsBase,
90
93
  type MessageCreateParamsNonStreaming,
@@ -207,8 +207,6 @@ export interface CitationsDelta {
207
207
 
208
208
  export type ContentBlock = TextBlock | ToolUseBlock | ThinkingBlock | RedactedThinkingBlock;
209
209
 
210
- export type ContentBlockDeltaEvent = RawContentBlockDeltaEvent;
211
-
212
210
  export type ContentBlockParam =
213
211
  | TextBlockParam
214
212
  | ImageBlockParam
@@ -226,10 +224,6 @@ export interface ContentBlockSource {
226
224
 
227
225
  export type ContentBlockSourceContent = TextBlockParam | ImageBlockParam;
228
226
 
229
- export type ContentBlockStartEvent = RawContentBlockStartEvent;
230
-
231
- export type ContentBlockStopEvent = RawContentBlockStopEvent;
232
-
233
227
  export interface DocumentBlockParam {
234
228
  source: Base64PDFSource | PlainTextSource | ContentBlockSource | URLPDFSource;
235
229
 
@@ -331,7 +325,7 @@ export interface Message {
331
325
  * In non-streaming mode this value is always non-null. In streaming mode, it is
332
326
  * null in the `message_start` event and non-null otherwise.
333
327
  */
334
- stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | null;
328
+ stop_reason: StopReason | null;
335
329
 
336
330
  /**
337
331
  * Which custom stop sequence was generated, if any.
@@ -370,8 +364,6 @@ export interface Message {
370
364
 
371
365
  export type MessageCountTokensTool = Tool | ToolBash20250124 | ToolTextEditor20250124;
372
366
 
373
- export type MessageDeltaEvent = RawMessageDeltaEvent;
374
-
375
367
  export interface MessageDeltaUsage {
376
368
  /**
377
369
  * The cumulative number of output tokens which were used.
@@ -385,12 +377,6 @@ export interface MessageParam {
385
377
  role: 'user' | 'assistant';
386
378
  }
387
379
 
388
- export type MessageStartEvent = RawMessageStartEvent;
389
-
390
- export type MessageStopEvent = RawMessageStopEvent;
391
-
392
- export type MessageStreamEvent = RawMessageStreamEvent;
393
-
394
380
  export interface MessageTokensCount {
395
381
  /**
396
382
  * The total number of tokens across the provided list of messages, system prompt,
@@ -452,8 +438,15 @@ export interface PlainTextSource {
452
438
  type: 'text';
453
439
  }
454
440
 
441
+ export type RawContentBlockDelta =
442
+ | TextDelta
443
+ | InputJSONDelta
444
+ | CitationsDelta
445
+ | ThinkingDelta
446
+ | SignatureDelta;
447
+
455
448
  export interface RawContentBlockDeltaEvent {
456
- delta: TextDelta | InputJSONDelta | CitationsDelta | ThinkingDelta | SignatureDelta;
449
+ delta: RawContentBlockDelta;
457
450
 
458
451
  index: number;
459
452
 
@@ -501,7 +494,7 @@ export interface RawMessageDeltaEvent {
501
494
 
502
495
  export namespace RawMessageDeltaEvent {
503
496
  export interface Delta {
504
- stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | null;
497
+ stop_reason: MessagesAPI.StopReason | null;
505
498
 
506
499
  stop_sequence: string | null;
507
500
  }
@@ -543,6 +536,8 @@ export interface SignatureDelta {
543
536
  type: 'signature_delta';
544
537
  }
545
538
 
539
+ export type StopReason = 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use';
540
+
546
541
  export interface TextBlock {
547
542
  /**
548
543
  * Citations supporting the text block.
@@ -677,6 +672,7 @@ export namespace Tool {
677
672
  type: 'object';
678
673
 
679
674
  properties?: unknown | null;
675
+
680
676
  [k: string]: unknown;
681
677
  }
682
678
  }
@@ -696,9 +692,9 @@ export interface ToolBash20250124 {
696
692
 
697
693
  /**
698
694
  * How the model should use the provided tools. The model can use a specific tool,
699
- * any available tool, or decide by itself.
695
+ * any available tool, decide by itself, or not use tools at all.
700
696
  */
701
- export type ToolChoice = ToolChoiceAuto | ToolChoiceAny | ToolChoiceTool;
697
+ export type ToolChoice = ToolChoiceAuto | ToolChoiceAny | ToolChoiceTool | ToolChoiceNone;
702
698
 
703
699
  /**
704
700
  * The model will use any available tools.
@@ -730,6 +726,13 @@ export interface ToolChoiceAuto {
730
726
  disable_parallel_tool_use?: boolean;
731
727
  }
732
728
 
729
+ /**
730
+ * The model will not be allowed to use tools.
731
+ */
732
+ export interface ToolChoiceNone {
733
+ type: 'none';
734
+ }
735
+
733
736
  /**
734
737
  * The model will use the specified tool with `tool_choice.name`.
735
738
  */
@@ -833,6 +836,20 @@ export interface Usage {
833
836
  output_tokens: number;
834
837
  }
835
838
 
839
+ export type MessageStreamEvent = RawMessageStreamEvent;
840
+
841
+ export type MessageStartEvent = RawMessageStartEvent;
842
+
843
+ export type MessageDeltaEvent = RawMessageDeltaEvent;
844
+
845
+ export type MessageStopEvent = RawMessageStopEvent;
846
+
847
+ export type ContentBlockStartEvent = RawContentBlockStartEvent;
848
+
849
+ export type ContentBlockDeltaEvent = RawContentBlockDeltaEvent;
850
+
851
+ export type ContentBlockStopEvent = RawContentBlockStopEvent;
852
+
836
853
  export type MessageCreateParams = MessageCreateParamsNonStreaming | MessageCreateParamsStreaming;
837
854
 
838
855
  export interface MessageCreateParamsBase {
@@ -1006,7 +1023,7 @@ export interface MessageCreateParamsBase {
1006
1023
 
1007
1024
  /**
1008
1025
  * How the model should use the provided tools. The model can use a specific tool,
1009
- * any available tool, or decide by itself.
1026
+ * any available tool, decide by itself, or not use tools at all.
1010
1027
  */
1011
1028
  tool_choice?: ToolChoice;
1012
1029
 
@@ -1277,7 +1294,7 @@ export interface MessageCountTokensParams {
1277
1294
 
1278
1295
  /**
1279
1296
  * How the model should use the provided tools. The model can use a specific tool,
1280
- * any available tool, or decide by itself.
1297
+ * any available tool, decide by itself, or not use tools at all.
1281
1298
  */
1282
1299
  tool_choice?: ToolChoice;
1283
1300
 
@@ -1372,28 +1389,22 @@ export declare namespace Messages {
1372
1389
  type CitationsConfigParam as CitationsConfigParam,
1373
1390
  type CitationsDelta as CitationsDelta,
1374
1391
  type ContentBlock as ContentBlock,
1375
- type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
1376
1392
  type ContentBlockParam as ContentBlockParam,
1377
1393
  type ContentBlockSource as ContentBlockSource,
1378
1394
  type ContentBlockSourceContent as ContentBlockSourceContent,
1379
- type ContentBlockStartEvent as ContentBlockStartEvent,
1380
- type ContentBlockStopEvent as ContentBlockStopEvent,
1381
1395
  type DocumentBlockParam as DocumentBlockParam,
1382
1396
  type ImageBlockParam as ImageBlockParam,
1383
1397
  type InputJsonDelta as InputJsonDelta,
1384
1398
  type InputJSONDelta as InputJSONDelta,
1385
1399
  type Message as Message,
1386
1400
  type MessageCountTokensTool as MessageCountTokensTool,
1387
- type MessageDeltaEvent as MessageDeltaEvent,
1388
1401
  type MessageDeltaUsage as MessageDeltaUsage,
1389
1402
  type MessageParam as MessageParam,
1390
- type MessageStartEvent as MessageStartEvent,
1391
- type MessageStopEvent as MessageStopEvent,
1392
- type MessageStreamEvent as MessageStreamEvent,
1393
1403
  type MessageTokensCount as MessageTokensCount,
1394
1404
  type Metadata as Metadata,
1395
1405
  type Model as Model,
1396
1406
  type PlainTextSource as PlainTextSource,
1407
+ type RawContentBlockDelta as RawContentBlockDelta,
1397
1408
  type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent,
1398
1409
  type RawContentBlockStartEvent as RawContentBlockStartEvent,
1399
1410
  type RawContentBlockStopEvent as RawContentBlockStopEvent,
@@ -1404,6 +1415,7 @@ export declare namespace Messages {
1404
1415
  type RedactedThinkingBlock as RedactedThinkingBlock,
1405
1416
  type RedactedThinkingBlockParam as RedactedThinkingBlockParam,
1406
1417
  type SignatureDelta as SignatureDelta,
1418
+ type StopReason as StopReason,
1407
1419
  type TextBlock as TextBlock,
1408
1420
  type TextBlockParam as TextBlockParam,
1409
1421
  type TextCitation as TextCitation,
@@ -1420,6 +1432,7 @@ export declare namespace Messages {
1420
1432
  type ToolChoice as ToolChoice,
1421
1433
  type ToolChoiceAny as ToolChoiceAny,
1422
1434
  type ToolChoiceAuto as ToolChoiceAuto,
1435
+ type ToolChoiceNone as ToolChoiceNone,
1423
1436
  type ToolChoiceTool as ToolChoiceTool,
1424
1437
  type ToolResultBlockParam as ToolResultBlockParam,
1425
1438
  type ToolTextEditor20250124 as ToolTextEditor20250124,
@@ -1429,6 +1442,13 @@ export declare namespace Messages {
1429
1442
  type URLImageSource as URLImageSource,
1430
1443
  type URLPDFSource as URLPDFSource,
1431
1444
  type Usage as Usage,
1445
+ type MessageStreamEvent as MessageStreamEvent,
1446
+ type MessageStartEvent as MessageStartEvent,
1447
+ type MessageDeltaEvent as MessageDeltaEvent,
1448
+ type MessageStopEvent as MessageStopEvent,
1449
+ type ContentBlockStartEvent as ContentBlockStartEvent,
1450
+ type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
1451
+ type ContentBlockStopEvent as ContentBlockStopEvent,
1432
1452
  type MessageCreateParams as MessageCreateParams,
1433
1453
  type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
1434
1454
  type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from "./messages/index.js";
@@ -0,0 +1 @@
1
+ export * from "./resources/index.js";
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.38.0'; // x-release-please-version
1
+ export const VERSION = '0.40.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.38.0";
1
+ export declare const VERSION = "0.40.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.38.0'; // x-release-please-version
4
+ exports.VERSION = '0.40.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.38.0'; // x-release-please-version
1
+ export const VERSION = '0.40.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map