@anthropic-ai/sdk 0.36.3 → 0.38.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.
- package/CHANGELOG.md +44 -0
- package/README.md +30 -3
- package/core.d.ts +1 -0
- package/core.d.ts.map +1 -1
- package/core.js +33 -6
- package/core.js.map +1 -1
- package/core.mjs +33 -6
- package/core.mjs.map +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/index.mjs.map +1 -1
- package/internal/decoders/line.d.ts +3 -2
- package/internal/decoders/line.d.ts.map +1 -1
- package/internal/decoders/line.js +97 -35
- package/internal/decoders/line.js.map +1 -1
- package/internal/decoders/line.mjs +95 -34
- package/internal/decoders/line.mjs.map +1 -1
- package/lib/BetaMessageStream.d.ts +2 -0
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +24 -0
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +24 -0
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/MessageStream.d.ts +2 -0
- package/lib/MessageStream.d.ts.map +1 -1
- package/lib/MessageStream.js +24 -0
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +24 -0
- package/lib/MessageStream.mjs.map +1 -1
- package/package.json +29 -8
- package/pagination.d.ts +1 -0
- package/pagination.d.ts.map +1 -1
- package/pagination.js +6 -0
- package/pagination.js.map +1 -1
- package/pagination.mjs +6 -0
- package/pagination.mjs.map +1 -1
- package/resources/beta/beta.d.ts +3 -3
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/index.d.ts +1 -1
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/messages/batches.d.ts +18 -0
- package/resources/beta/messages/batches.d.ts.map +1 -1
- package/resources/beta/messages/batches.js +3 -0
- package/resources/beta/messages/batches.js.map +1 -1
- package/resources/beta/messages/batches.mjs +3 -0
- package/resources/beta/messages/batches.mjs.map +1 -1
- package/resources/beta/messages/index.d.ts +1 -1
- package/resources/beta/messages/index.d.ts.map +1 -1
- package/resources/beta/messages/index.js.map +1 -1
- package/resources/beta/messages/index.mjs.map +1 -1
- package/resources/beta/messages/messages.d.ts +163 -22
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +5 -1
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +5 -1
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/messages/batches.d.ts +18 -0
- package/resources/messages/batches.d.ts.map +1 -1
- package/resources/messages/batches.js +15 -0
- package/resources/messages/batches.js.map +1 -1
- package/resources/messages/batches.mjs +15 -0
- package/resources/messages/batches.mjs.map +1 -1
- package/resources/messages/index.d.ts +1 -1
- package/resources/messages/index.d.ts.map +1 -1
- package/resources/messages/index.js.map +1 -1
- package/resources/messages/index.mjs.map +1 -1
- package/resources/messages/messages.d.ts +144 -23
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +5 -1
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +5 -1
- package/resources/messages/messages.mjs.map +1 -1
- package/src/core.ts +39 -6
- package/src/index.ts +32 -0
- package/src/internal/decoders/line.ts +100 -38
- package/src/lib/BetaMessageStream.ts +26 -0
- package/src/lib/MessageStream.ts +26 -0
- package/src/pagination.ts +8 -0
- package/src/resources/beta/beta.ts +34 -1
- package/src/resources/beta/index.ts +15 -0
- package/src/resources/beta/messages/batches.ts +18 -0
- package/src/resources/beta/messages/index.ts +15 -0
- package/src/resources/beta/messages/messages.ts +236 -25
- package/src/resources/index.ts +16 -0
- package/src/resources/messages/batches.ts +18 -0
- package/src/resources/messages/index.ts +16 -0
- package/src/resources/messages/messages.ts +202 -27
- package/src/streaming.ts +1 -43
- package/src/version.ts +1 -1
- package/streaming.d.ts +0 -2
- package/streaming.d.ts.map +1 -1
- package/streaming.js +2 -38
- package/streaming.js.map +1 -1
- package/streaming.mjs +1 -36
- package/streaming.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -13,52 +13,58 @@ export class LineDecoder {
|
|
|
13
13
|
static NEWLINE_CHARS = new Set(['\n', '\r']);
|
|
14
14
|
static NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
15
15
|
|
|
16
|
-
buffer:
|
|
17
|
-
|
|
16
|
+
buffer: Uint8Array;
|
|
17
|
+
#carriageReturnIndex: number | null;
|
|
18
18
|
textDecoder: any; // TextDecoder found in browsers; not typed to avoid pulling in either "dom" or "node" types.
|
|
19
19
|
|
|
20
20
|
constructor() {
|
|
21
|
-
this.buffer =
|
|
22
|
-
this
|
|
21
|
+
this.buffer = new Uint8Array();
|
|
22
|
+
this.#carriageReturnIndex = null;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
decode(chunk: Bytes): string[] {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (this.trailingCR) {
|
|
29
|
-
text = '\r' + text;
|
|
30
|
-
this.trailingCR = false;
|
|
31
|
-
}
|
|
32
|
-
if (text.endsWith('\r')) {
|
|
33
|
-
this.trailingCR = true;
|
|
34
|
-
text = text.slice(0, -1);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!text) {
|
|
26
|
+
if (chunk == null) {
|
|
38
27
|
return [];
|
|
39
28
|
}
|
|
40
29
|
|
|
41
|
-
const
|
|
42
|
-
|
|
30
|
+
const binaryChunk =
|
|
31
|
+
chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
|
|
32
|
+
: typeof chunk === 'string' ? new TextEncoder().encode(chunk)
|
|
33
|
+
: chunk;
|
|
34
|
+
|
|
35
|
+
let newData = new Uint8Array(this.buffer.length + binaryChunk.length);
|
|
36
|
+
newData.set(this.buffer);
|
|
37
|
+
newData.set(binaryChunk, this.buffer.length);
|
|
38
|
+
this.buffer = newData;
|
|
39
|
+
|
|
40
|
+
const lines: string[] = [];
|
|
41
|
+
let patternIndex;
|
|
42
|
+
while ((patternIndex = findNewlineIndex(this.buffer, this.#carriageReturnIndex)) != null) {
|
|
43
|
+
if (patternIndex.carriage && this.#carriageReturnIndex == null) {
|
|
44
|
+
// skip until we either get a corresponding `\n`, a new `\r` or nothing
|
|
45
|
+
this.#carriageReturnIndex = patternIndex.index;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
// we got double \r or \rtext\n
|
|
50
|
+
if (
|
|
51
|
+
this.#carriageReturnIndex != null &&
|
|
52
|
+
(patternIndex.index !== this.#carriageReturnIndex + 1 || patternIndex.carriage)
|
|
53
|
+
) {
|
|
54
|
+
lines.push(this.decodeText(this.buffer.slice(0, this.#carriageReturnIndex - 1)));
|
|
55
|
+
this.buffer = this.buffer.slice(this.#carriageReturnIndex);
|
|
56
|
+
this.#carriageReturnIndex = null;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
60
|
+
const endIndex =
|
|
61
|
+
this.#carriageReturnIndex !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
|
|
54
62
|
|
|
55
|
-
|
|
56
|
-
lines
|
|
57
|
-
this.buffer = [];
|
|
58
|
-
}
|
|
63
|
+
const line = this.decodeText(this.buffer.slice(0, endIndex));
|
|
64
|
+
lines.push(line);
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
this
|
|
66
|
+
this.buffer = this.buffer.slice(patternIndex.index);
|
|
67
|
+
this.#carriageReturnIndex = null;
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
return lines;
|
|
@@ -102,13 +108,69 @@ export class LineDecoder {
|
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
flush(): string[] {
|
|
105
|
-
if (!this.buffer.length
|
|
111
|
+
if (!this.buffer.length) {
|
|
106
112
|
return [];
|
|
107
113
|
}
|
|
114
|
+
return this.decode('\n');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
108
117
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
118
|
+
/**
|
|
119
|
+
* This function searches the buffer for the end patterns, (\r or \n)
|
|
120
|
+
* and returns an object with the index preceding the matched newline and the
|
|
121
|
+
* index after the newline char. `null` is returned if no new line is found.
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* findNewLineIndex('abc\ndef') -> { preceding: 2, index: 3 }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
function findNewlineIndex(
|
|
128
|
+
buffer: Uint8Array,
|
|
129
|
+
startIndex: number | null,
|
|
130
|
+
): { preceding: number; index: number; carriage: boolean } | null {
|
|
131
|
+
const newline = 0x0a; // \n
|
|
132
|
+
const carriage = 0x0d; // \r
|
|
133
|
+
|
|
134
|
+
for (let i = startIndex ?? 0; i < buffer.length; i++) {
|
|
135
|
+
if (buffer[i] === newline) {
|
|
136
|
+
return { preceding: i, index: i + 1, carriage: false };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (buffer[i] === carriage) {
|
|
140
|
+
return { preceding: i, index: i + 1, carriage: true };
|
|
141
|
+
}
|
|
113
142
|
}
|
|
143
|
+
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function findDoubleNewlineIndex(buffer: Uint8Array): number {
|
|
148
|
+
// This function searches the buffer for the end patterns (\r\r, \n\n, \r\n\r\n)
|
|
149
|
+
// and returns the index right after the first occurrence of any pattern,
|
|
150
|
+
// or -1 if none of the patterns are found.
|
|
151
|
+
const newline = 0x0a; // \n
|
|
152
|
+
const carriage = 0x0d; // \r
|
|
153
|
+
|
|
154
|
+
for (let i = 0; i < buffer.length - 1; i++) {
|
|
155
|
+
if (buffer[i] === newline && buffer[i + 1] === newline) {
|
|
156
|
+
// \n\n
|
|
157
|
+
return i + 2;
|
|
158
|
+
}
|
|
159
|
+
if (buffer[i] === carriage && buffer[i + 1] === carriage) {
|
|
160
|
+
// \r\r
|
|
161
|
+
return i + 2;
|
|
162
|
+
}
|
|
163
|
+
if (
|
|
164
|
+
buffer[i] === carriage &&
|
|
165
|
+
buffer[i + 1] === newline &&
|
|
166
|
+
i + 3 < buffer.length &&
|
|
167
|
+
buffer[i + 2] === carriage &&
|
|
168
|
+
buffer[i + 3] === newline
|
|
169
|
+
) {
|
|
170
|
+
// \r\n\r\n
|
|
171
|
+
return i + 4;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return -1;
|
|
114
176
|
}
|
|
@@ -21,6 +21,8 @@ export interface MessageStreamEvents {
|
|
|
21
21
|
text: (textDelta: string, textSnapshot: string) => void;
|
|
22
22
|
citation: (citation: BetaTextCitation, citationsSnapshot: BetaTextCitation[]) => void;
|
|
23
23
|
inputJson: (partialJson: string, jsonSnapshot: unknown) => void;
|
|
24
|
+
thinking: (thinkingDelta: string, thinkingSnapshot: string) => void;
|
|
25
|
+
signature: (signature: string) => void;
|
|
24
26
|
message: (message: BetaMessage) => void;
|
|
25
27
|
contentBlock: (content: BetaContentBlock) => void;
|
|
26
28
|
finalMessage: (message: BetaMessage) => void;
|
|
@@ -434,6 +436,18 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
|
|
|
434
436
|
}
|
|
435
437
|
break;
|
|
436
438
|
}
|
|
439
|
+
case 'thinking_delta': {
|
|
440
|
+
if (content.type === 'thinking') {
|
|
441
|
+
this._emit('thinking', event.delta.thinking, content.thinking);
|
|
442
|
+
}
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
case 'signature_delta': {
|
|
446
|
+
if (content.type === 'thinking') {
|
|
447
|
+
this._emit('signature', content.signature);
|
|
448
|
+
}
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
437
451
|
default:
|
|
438
452
|
checkNever(event.delta);
|
|
439
453
|
}
|
|
@@ -557,6 +571,18 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
|
|
|
557
571
|
}
|
|
558
572
|
break;
|
|
559
573
|
}
|
|
574
|
+
case 'thinking_delta': {
|
|
575
|
+
if (snapshotContent?.type === 'thinking') {
|
|
576
|
+
snapshotContent.thinking += event.delta.thinking;
|
|
577
|
+
}
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
case 'signature_delta': {
|
|
581
|
+
if (snapshotContent?.type === 'thinking') {
|
|
582
|
+
snapshotContent.signature = event.delta.signature;
|
|
583
|
+
}
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
560
586
|
default:
|
|
561
587
|
checkNever(event.delta);
|
|
562
588
|
}
|
package/src/lib/MessageStream.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface MessageStreamEvents {
|
|
|
21
21
|
text: (textDelta: string, textSnapshot: string) => void;
|
|
22
22
|
citation: (citation: TextCitation, citationsSnapshot: TextCitation[]) => void;
|
|
23
23
|
inputJson: (partialJson: string, jsonSnapshot: unknown) => void;
|
|
24
|
+
thinking: (thinkingDelta: string, thinkingSnapshot: string) => void;
|
|
25
|
+
signature: (signature: string) => void;
|
|
24
26
|
message: (message: Message) => void;
|
|
25
27
|
contentBlock: (content: ContentBlock) => void;
|
|
26
28
|
finalMessage: (message: Message) => void;
|
|
@@ -434,6 +436,18 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
|
|
|
434
436
|
}
|
|
435
437
|
break;
|
|
436
438
|
}
|
|
439
|
+
case 'thinking_delta': {
|
|
440
|
+
if (content.type === 'thinking') {
|
|
441
|
+
this._emit('thinking', event.delta.thinking, content.thinking);
|
|
442
|
+
}
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
case 'signature_delta': {
|
|
446
|
+
if (content.type === 'thinking') {
|
|
447
|
+
this._emit('signature', content.signature);
|
|
448
|
+
}
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
437
451
|
default:
|
|
438
452
|
checkNever(event.delta);
|
|
439
453
|
}
|
|
@@ -557,6 +571,18 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
|
|
|
557
571
|
}
|
|
558
572
|
break;
|
|
559
573
|
}
|
|
574
|
+
case 'thinking_delta': {
|
|
575
|
+
if (snapshotContent?.type === 'thinking') {
|
|
576
|
+
snapshotContent.thinking += event.delta.thinking;
|
|
577
|
+
}
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
case 'signature_delta': {
|
|
581
|
+
if (snapshotContent?.type === 'thinking') {
|
|
582
|
+
snapshotContent.signature = event.delta.signature;
|
|
583
|
+
}
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
560
586
|
default:
|
|
561
587
|
checkNever(event.delta);
|
|
562
588
|
}
|
package/src/pagination.ts
CHANGED
|
@@ -45,6 +45,14 @@ export class Page<Item> extends AbstractPage<Item> implements PageResponse<Item>
|
|
|
45
45
|
return this.data ?? [];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
override hasNextPage(): boolean {
|
|
49
|
+
if (this.has_more === false) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return super.hasNextPage();
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
// @deprecated Please use `nextPageInfo()` instead
|
|
49
57
|
nextPageParams(): Partial<PageParams> | null {
|
|
50
58
|
const info = this.nextPageInfo();
|
|
@@ -5,6 +5,7 @@ import * as ModelsAPI from "./models.js";
|
|
|
5
5
|
import { BetaModelInfo, BetaModelInfosPage, ModelListParams, Models } from "./models.js";
|
|
6
6
|
import * as MessagesAPI from "./messages/messages.js";
|
|
7
7
|
import {
|
|
8
|
+
BetaBase64ImageSource,
|
|
8
9
|
BetaBase64PDFBlock,
|
|
9
10
|
BetaBase64PDFSource,
|
|
10
11
|
BetaCacheControlEphemeral,
|
|
@@ -35,23 +36,37 @@ import {
|
|
|
35
36
|
BetaRawMessageStartEvent,
|
|
36
37
|
BetaRawMessageStopEvent,
|
|
37
38
|
BetaRawMessageStreamEvent,
|
|
39
|
+
BetaRedactedThinkingBlock,
|
|
40
|
+
BetaRedactedThinkingBlockParam,
|
|
41
|
+
BetaSignatureDelta,
|
|
38
42
|
BetaTextBlock,
|
|
39
43
|
BetaTextBlockParam,
|
|
40
44
|
BetaTextCitation,
|
|
41
45
|
BetaTextCitationParam,
|
|
42
46
|
BetaTextDelta,
|
|
47
|
+
BetaThinkingBlock,
|
|
48
|
+
BetaThinkingBlockParam,
|
|
49
|
+
BetaThinkingConfigDisabled,
|
|
50
|
+
BetaThinkingConfigEnabled,
|
|
51
|
+
BetaThinkingConfigParam,
|
|
52
|
+
BetaThinkingDelta,
|
|
43
53
|
BetaTool,
|
|
44
54
|
BetaToolBash20241022,
|
|
55
|
+
BetaToolBash20250124,
|
|
45
56
|
BetaToolChoice,
|
|
46
57
|
BetaToolChoiceAny,
|
|
47
58
|
BetaToolChoiceAuto,
|
|
48
59
|
BetaToolChoiceTool,
|
|
49
60
|
BetaToolComputerUse20241022,
|
|
61
|
+
BetaToolComputerUse20250124,
|
|
50
62
|
BetaToolResultBlockParam,
|
|
51
63
|
BetaToolTextEditor20241022,
|
|
64
|
+
BetaToolTextEditor20250124,
|
|
52
65
|
BetaToolUnion,
|
|
53
66
|
BetaToolUseBlock,
|
|
54
67
|
BetaToolUseBlockParam,
|
|
68
|
+
BetaURLImageSource,
|
|
69
|
+
BetaURLPDFSource,
|
|
55
70
|
BetaUsage,
|
|
56
71
|
MessageCountTokensParams,
|
|
57
72
|
MessageCreateParams,
|
|
@@ -70,8 +85,11 @@ export type AnthropicBeta =
|
|
|
70
85
|
| 'message-batches-2024-09-24'
|
|
71
86
|
| 'prompt-caching-2024-07-31'
|
|
72
87
|
| 'computer-use-2024-10-22'
|
|
88
|
+
| 'computer-use-2025-01-24'
|
|
73
89
|
| 'pdfs-2024-09-25'
|
|
74
|
-
| 'token-counting-2024-11-01'
|
|
90
|
+
| 'token-counting-2024-11-01'
|
|
91
|
+
| 'token-efficient-tools-2025-02-19'
|
|
92
|
+
| 'output-128k-2025-02-19';
|
|
75
93
|
|
|
76
94
|
export interface BetaAPIError {
|
|
77
95
|
message: string;
|
|
@@ -173,6 +191,7 @@ export declare namespace Beta {
|
|
|
173
191
|
|
|
174
192
|
export {
|
|
175
193
|
Messages as Messages,
|
|
194
|
+
type BetaBase64ImageSource as BetaBase64ImageSource,
|
|
176
195
|
type BetaBase64PDFBlock as BetaBase64PDFBlock,
|
|
177
196
|
type BetaBase64PDFSource as BetaBase64PDFSource,
|
|
178
197
|
type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
|
|
@@ -203,23 +222,37 @@ export declare namespace Beta {
|
|
|
203
222
|
type BetaRawMessageStartEvent as BetaRawMessageStartEvent,
|
|
204
223
|
type BetaRawMessageStopEvent as BetaRawMessageStopEvent,
|
|
205
224
|
type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
|
|
225
|
+
type BetaRedactedThinkingBlock as BetaRedactedThinkingBlock,
|
|
226
|
+
type BetaRedactedThinkingBlockParam as BetaRedactedThinkingBlockParam,
|
|
227
|
+
type BetaSignatureDelta as BetaSignatureDelta,
|
|
206
228
|
type BetaTextBlock as BetaTextBlock,
|
|
207
229
|
type BetaTextBlockParam as BetaTextBlockParam,
|
|
208
230
|
type BetaTextCitation as BetaTextCitation,
|
|
209
231
|
type BetaTextCitationParam as BetaTextCitationParam,
|
|
210
232
|
type BetaTextDelta as BetaTextDelta,
|
|
233
|
+
type BetaThinkingBlock as BetaThinkingBlock,
|
|
234
|
+
type BetaThinkingBlockParam as BetaThinkingBlockParam,
|
|
235
|
+
type BetaThinkingConfigDisabled as BetaThinkingConfigDisabled,
|
|
236
|
+
type BetaThinkingConfigEnabled as BetaThinkingConfigEnabled,
|
|
237
|
+
type BetaThinkingConfigParam as BetaThinkingConfigParam,
|
|
238
|
+
type BetaThinkingDelta as BetaThinkingDelta,
|
|
211
239
|
type BetaTool as BetaTool,
|
|
212
240
|
type BetaToolBash20241022 as BetaToolBash20241022,
|
|
241
|
+
type BetaToolBash20250124 as BetaToolBash20250124,
|
|
213
242
|
type BetaToolChoice as BetaToolChoice,
|
|
214
243
|
type BetaToolChoiceAny as BetaToolChoiceAny,
|
|
215
244
|
type BetaToolChoiceAuto as BetaToolChoiceAuto,
|
|
216
245
|
type BetaToolChoiceTool as BetaToolChoiceTool,
|
|
217
246
|
type BetaToolComputerUse20241022 as BetaToolComputerUse20241022,
|
|
247
|
+
type BetaToolComputerUse20250124 as BetaToolComputerUse20250124,
|
|
218
248
|
type BetaToolResultBlockParam as BetaToolResultBlockParam,
|
|
219
249
|
type BetaToolTextEditor20241022 as BetaToolTextEditor20241022,
|
|
250
|
+
type BetaToolTextEditor20250124 as BetaToolTextEditor20250124,
|
|
220
251
|
type BetaToolUnion as BetaToolUnion,
|
|
221
252
|
type BetaToolUseBlock as BetaToolUseBlock,
|
|
222
253
|
type BetaToolUseBlockParam as BetaToolUseBlockParam,
|
|
254
|
+
type BetaURLImageSource as BetaURLImageSource,
|
|
255
|
+
type BetaURLPDFSource as BetaURLPDFSource,
|
|
223
256
|
type BetaUsage as BetaUsage,
|
|
224
257
|
type MessageCreateParams as MessageCreateParams,
|
|
225
258
|
type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
|
|
@@ -18,6 +18,7 @@ export {
|
|
|
18
18
|
export { BetaModelInfosPage, Models, type BetaModelInfo, type ModelListParams } from "./models.js";
|
|
19
19
|
export {
|
|
20
20
|
Messages,
|
|
21
|
+
type BetaBase64ImageSource,
|
|
21
22
|
type BetaBase64PDFBlock,
|
|
22
23
|
type BetaBase64PDFSource,
|
|
23
24
|
type BetaCacheControlEphemeral,
|
|
@@ -48,23 +49,37 @@ export {
|
|
|
48
49
|
type BetaRawMessageStartEvent,
|
|
49
50
|
type BetaRawMessageStopEvent,
|
|
50
51
|
type BetaRawMessageStreamEvent,
|
|
52
|
+
type BetaRedactedThinkingBlock,
|
|
53
|
+
type BetaRedactedThinkingBlockParam,
|
|
54
|
+
type BetaSignatureDelta,
|
|
51
55
|
type BetaTextBlock,
|
|
52
56
|
type BetaTextBlockParam,
|
|
53
57
|
type BetaTextCitation,
|
|
54
58
|
type BetaTextCitationParam,
|
|
55
59
|
type BetaTextDelta,
|
|
60
|
+
type BetaThinkingBlock,
|
|
61
|
+
type BetaThinkingBlockParam,
|
|
62
|
+
type BetaThinkingConfigDisabled,
|
|
63
|
+
type BetaThinkingConfigEnabled,
|
|
64
|
+
type BetaThinkingConfigParam,
|
|
65
|
+
type BetaThinkingDelta,
|
|
56
66
|
type BetaTool,
|
|
57
67
|
type BetaToolBash20241022,
|
|
68
|
+
type BetaToolBash20250124,
|
|
58
69
|
type BetaToolChoice,
|
|
59
70
|
type BetaToolChoiceAny,
|
|
60
71
|
type BetaToolChoiceAuto,
|
|
61
72
|
type BetaToolChoiceTool,
|
|
62
73
|
type BetaToolComputerUse20241022,
|
|
74
|
+
type BetaToolComputerUse20250124,
|
|
63
75
|
type BetaToolResultBlockParam,
|
|
64
76
|
type BetaToolTextEditor20241022,
|
|
77
|
+
type BetaToolTextEditor20250124,
|
|
65
78
|
type BetaToolUnion,
|
|
66
79
|
type BetaToolUseBlock,
|
|
67
80
|
type BetaToolUseBlockParam,
|
|
81
|
+
type BetaURLImageSource,
|
|
82
|
+
type BetaURLPDFSource,
|
|
68
83
|
type BetaUsage,
|
|
69
84
|
type MessageCreateParams,
|
|
70
85
|
type MessageCreateParamsNonStreaming,
|
|
@@ -16,6 +16,9 @@ export class Batches extends APIResource {
|
|
|
16
16
|
* The Message Batches API can be used to process multiple Messages API requests at
|
|
17
17
|
* once. Once a Message Batch is created, it begins processing immediately. Batches
|
|
18
18
|
* can take up to 24 hours to complete.
|
|
19
|
+
*
|
|
20
|
+
* Learn more about the Message Batches API in our
|
|
21
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
19
22
|
*/
|
|
20
23
|
create(params: BatchCreateParams, options?: Core.RequestOptions): Core.APIPromise<BetaMessageBatch> {
|
|
21
24
|
const { betas, ...body } = params;
|
|
@@ -33,6 +36,9 @@ export class Batches extends APIResource {
|
|
|
33
36
|
* This endpoint is idempotent and can be used to poll for Message Batch
|
|
34
37
|
* completion. To access the results of a Message Batch, make a request to the
|
|
35
38
|
* `results_url` field in the response.
|
|
39
|
+
*
|
|
40
|
+
* Learn more about the Message Batches API in our
|
|
41
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
36
42
|
*/
|
|
37
43
|
retrieve(
|
|
38
44
|
messageBatchId: string,
|
|
@@ -61,6 +67,9 @@ export class Batches extends APIResource {
|
|
|
61
67
|
/**
|
|
62
68
|
* List all Message Batches within a Workspace. Most recently created batches are
|
|
63
69
|
* returned first.
|
|
70
|
+
*
|
|
71
|
+
* Learn more about the Message Batches API in our
|
|
72
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
64
73
|
*/
|
|
65
74
|
list(
|
|
66
75
|
params?: BatchListParams,
|
|
@@ -90,6 +99,9 @@ export class Batches extends APIResource {
|
|
|
90
99
|
*
|
|
91
100
|
* Message Batches can only be deleted once they've finished processing. If you'd
|
|
92
101
|
* like to delete an in-progress batch, you must first cancel it.
|
|
102
|
+
*
|
|
103
|
+
* Learn more about the Message Batches API in our
|
|
104
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
93
105
|
*/
|
|
94
106
|
delete(
|
|
95
107
|
messageBatchId: string,
|
|
@@ -125,6 +137,9 @@ export class Batches extends APIResource {
|
|
|
125
137
|
* which requests were canceled, check the individual results within the batch.
|
|
126
138
|
* Note that cancellation may not result in any canceled requests if they were
|
|
127
139
|
* non-interruptible.
|
|
140
|
+
*
|
|
141
|
+
* Learn more about the Message Batches API in our
|
|
142
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
128
143
|
*/
|
|
129
144
|
cancel(
|
|
130
145
|
messageBatchId: string,
|
|
@@ -156,6 +171,9 @@ export class Batches extends APIResource {
|
|
|
156
171
|
* Each line in the file is a JSON object containing the result of a single request
|
|
157
172
|
* in the Message Batch. Results are not guaranteed to be in the same order as
|
|
158
173
|
* requests. Use the `custom_id` field to match results to requests.
|
|
174
|
+
*
|
|
175
|
+
* Learn more about the Message Batches API in our
|
|
176
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
159
177
|
*/
|
|
160
178
|
async results(
|
|
161
179
|
messageBatchId: string,
|
|
@@ -21,6 +21,7 @@ export {
|
|
|
21
21
|
} from "./batches.js";
|
|
22
22
|
export {
|
|
23
23
|
Messages,
|
|
24
|
+
type BetaBase64ImageSource,
|
|
24
25
|
type BetaBase64PDFBlock,
|
|
25
26
|
type BetaBase64PDFSource,
|
|
26
27
|
type BetaCacheControlEphemeral,
|
|
@@ -51,23 +52,37 @@ export {
|
|
|
51
52
|
type BetaRawMessageStartEvent,
|
|
52
53
|
type BetaRawMessageStopEvent,
|
|
53
54
|
type BetaRawMessageStreamEvent,
|
|
55
|
+
type BetaRedactedThinkingBlock,
|
|
56
|
+
type BetaRedactedThinkingBlockParam,
|
|
57
|
+
type BetaSignatureDelta,
|
|
54
58
|
type BetaTextBlock,
|
|
55
59
|
type BetaTextBlockParam,
|
|
56
60
|
type BetaTextCitation,
|
|
57
61
|
type BetaTextCitationParam,
|
|
58
62
|
type BetaTextDelta,
|
|
63
|
+
type BetaThinkingBlock,
|
|
64
|
+
type BetaThinkingBlockParam,
|
|
65
|
+
type BetaThinkingConfigDisabled,
|
|
66
|
+
type BetaThinkingConfigEnabled,
|
|
67
|
+
type BetaThinkingConfigParam,
|
|
68
|
+
type BetaThinkingDelta,
|
|
59
69
|
type BetaTool,
|
|
60
70
|
type BetaToolBash20241022,
|
|
71
|
+
type BetaToolBash20250124,
|
|
61
72
|
type BetaToolChoice,
|
|
62
73
|
type BetaToolChoiceAny,
|
|
63
74
|
type BetaToolChoiceAuto,
|
|
64
75
|
type BetaToolChoiceTool,
|
|
65
76
|
type BetaToolComputerUse20241022,
|
|
77
|
+
type BetaToolComputerUse20250124,
|
|
66
78
|
type BetaToolResultBlockParam,
|
|
67
79
|
type BetaToolTextEditor20241022,
|
|
80
|
+
type BetaToolTextEditor20250124,
|
|
68
81
|
type BetaToolUnion,
|
|
69
82
|
type BetaToolUseBlock,
|
|
70
83
|
type BetaToolUseBlockParam,
|
|
84
|
+
type BetaURLImageSource,
|
|
85
|
+
type BetaURLPDFSource,
|
|
71
86
|
type BetaUsage,
|
|
72
87
|
type MessageCreateParams,
|
|
73
88
|
type MessageCreateParamsNonStreaming,
|