@anthropic-ai/sdk 0.39.0 → 0.40.1
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 +58 -0
- package/_shims/index.d.ts +2 -0
- package/_shims/index.js +5 -1
- package/_shims/index.mjs +5 -1
- package/core.d.ts +12 -1
- package/core.d.ts.map +1 -1
- package/core.js +10 -7
- package/core.js.map +1 -1
- package/core.mjs +11 -8
- 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 +4 -9
- package/index.js.map +1 -1
- package/index.mjs +4 -9
- package/index.mjs.map +1 -1
- package/package.json +8 -29
- package/resources/beta/beta.d.ts +2 -2
- 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 +1 -1
- package/resources/beta/messages/batches.d.ts.map +1 -1
- package/resources/beta/messages/batches.js +1 -0
- package/resources/beta/messages/batches.js.map +1 -1
- package/resources/beta/messages/batches.mjs +1 -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 +6 -4
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/beta/messages.d.ts +2 -0
- package/resources/beta/messages.d.ts.map +1 -0
- package/resources/beta/messages.js +19 -0
- package/resources/beta/messages.js.map +1 -0
- package/resources/beta/messages.mjs +3 -0
- package/resources/beta/messages.mjs.map +1 -0
- package/resources/beta.d.ts +2 -0
- package/resources/beta.d.ts.map +1 -0
- package/resources/beta.js +19 -0
- package/resources/beta.js.map +1 -0
- package/resources/beta.mjs +3 -0
- package/resources/beta.mjs.map +1 -0
- 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.map +1 -1
- package/resources/messages/batches.js.map +1 -1
- 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 +13 -11
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs.map +1 -1
- package/resources/messages.d.ts +2 -0
- package/resources/messages.d.ts.map +1 -0
- package/resources/messages.js +19 -0
- package/resources/messages.js.map +1 -0
- package/resources/messages.mjs +3 -0
- package/resources/messages.mjs.map +1 -0
- package/resources.d.ts +2 -0
- package/resources.d.ts.map +1 -0
- package/resources.js +18 -0
- package/resources.js.map +1 -0
- package/resources.mjs +2 -0
- package/resources.mjs.map +1 -0
- package/src/_shims/index.d.ts +2 -0
- package/src/_shims/index.js +5 -1
- package/src/_shims/index.mjs +5 -1
- package/src/core.ts +27 -8
- package/src/index.ts +15 -18
- package/src/resources/beta/beta.ts +4 -0
- package/src/resources/beta/index.ts +2 -0
- package/src/resources/beta/messages/batches.ts +6 -2
- package/src/resources/beta/messages/index.ts +2 -0
- package/src/resources/beta/messages/messages.ts +15 -3
- package/src/resources/beta/messages.ts +3 -0
- package/src/resources/beta.ts +3 -0
- package/src/resources/index.ts +9 -7
- package/src/resources/messages/batches.ts +4 -1
- package/src/resources/messages/index.ts +9 -7
- package/src/resources/messages/messages.ts +36 -24
- package/src/resources/messages.ts +3 -0
- package/src/resources.ts +1 -0
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/_shims/index.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
const shims = require('./registry');
|
|
5
5
|
const auto = require('@anthropic-ai/sdk/_shims/auto/runtime');
|
|
6
|
-
|
|
6
|
+
exports.init = () => {
|
|
7
|
+
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
|
|
8
|
+
};
|
|
7
9
|
for (const property of Object.keys(shims)) {
|
|
8
10
|
Object.defineProperty(exports, property, {
|
|
9
11
|
get() {
|
|
@@ -11,3 +13,5 @@ for (const property of Object.keys(shims)) {
|
|
|
11
13
|
},
|
|
12
14
|
});
|
|
13
15
|
}
|
|
16
|
+
|
|
17
|
+
exports.init();
|
package/src/_shims/index.mjs
CHANGED
|
@@ -3,5 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as shims from './registry.mjs';
|
|
5
5
|
import * as auto from "./auto/runtime.mjs";
|
|
6
|
-
|
|
6
|
+
export const init = () => {
|
|
7
|
+
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
|
|
8
|
+
};
|
|
7
9
|
export * from './registry.mjs';
|
|
10
|
+
|
|
11
|
+
init();
|
package/src/core.ts
CHANGED
|
@@ -17,7 +17,12 @@ import {
|
|
|
17
17
|
type RequestInit,
|
|
18
18
|
type Response,
|
|
19
19
|
type HeadersInit,
|
|
20
|
+
init,
|
|
20
21
|
} from "./_shims/index.js";
|
|
22
|
+
|
|
23
|
+
// try running side effects outside of _shims/index to workaround https://github.com/vercel/next.js/issues/76881
|
|
24
|
+
init();
|
|
25
|
+
|
|
21
26
|
export { type Response };
|
|
22
27
|
import { BlobLike, isBlobLike, isMultipartBody } from "./uploads.js";
|
|
23
28
|
export {
|
|
@@ -29,6 +34,20 @@ export {
|
|
|
29
34
|
|
|
30
35
|
export type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
31
36
|
|
|
37
|
+
/**
|
|
38
|
+
* An alias to the builtin `Array` type so we can
|
|
39
|
+
* easily alias it in import statements if there are name clashes.
|
|
40
|
+
*/
|
|
41
|
+
type _Array<T> = Array<T>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* An alias to the builtin `Record` type so we can
|
|
45
|
+
* easily alias it in import statements if there are name clashes.
|
|
46
|
+
*/
|
|
47
|
+
type _Record<K extends keyof any, T> = Record<K, T>;
|
|
48
|
+
|
|
49
|
+
export type { _Array as Array, _Record as Record };
|
|
50
|
+
|
|
32
51
|
type PromiseOrValue<T> = T | Promise<T>;
|
|
33
52
|
|
|
34
53
|
type APIResponseProps = {
|
|
@@ -62,8 +81,8 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<WithReq
|
|
|
62
81
|
}
|
|
63
82
|
|
|
64
83
|
const contentType = response.headers.get('content-type');
|
|
65
|
-
const
|
|
66
|
-
|
|
84
|
+
const mediaType = contentType?.split(';')[0]?.trim();
|
|
85
|
+
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
67
86
|
if (isJSON) {
|
|
68
87
|
const json = await response.json();
|
|
69
88
|
|
|
@@ -311,10 +330,10 @@ export abstract class APIClient {
|
|
|
311
330
|
}
|
|
312
331
|
|
|
313
332
|
buildRequest<Req>(
|
|
314
|
-
|
|
333
|
+
inputOptions: FinalRequestOptions<Req>,
|
|
315
334
|
{ retryCount = 0 }: { retryCount?: number } = {},
|
|
316
335
|
): { req: RequestInit; url: string; timeout: number } {
|
|
317
|
-
options = { ...
|
|
336
|
+
const options = { ...inputOptions };
|
|
318
337
|
const { method, path, query, headers: headers = {} } = options;
|
|
319
338
|
|
|
320
339
|
const body =
|
|
@@ -342,8 +361,8 @@ export abstract class APIClient {
|
|
|
342
361
|
}
|
|
343
362
|
|
|
344
363
|
if (this.idempotencyHeader && method !== 'get') {
|
|
345
|
-
if (!
|
|
346
|
-
headers[this.idempotencyHeader] =
|
|
364
|
+
if (!inputOptions.idempotencyKey) inputOptions.idempotencyKey = this.defaultIdempotencyKey();
|
|
365
|
+
headers[this.idempotencyHeader] = inputOptions.idempotencyKey;
|
|
347
366
|
}
|
|
348
367
|
|
|
349
368
|
const reqHeaders = this.buildHeaders({ options, headers, contentLength, retryCount });
|
|
@@ -400,7 +419,7 @@ export abstract class APIClient {
|
|
|
400
419
|
getHeader(headers, 'x-stainless-timeout') === undefined &&
|
|
401
420
|
options.timeout
|
|
402
421
|
) {
|
|
403
|
-
reqHeaders['x-stainless-timeout'] = String(options.timeout);
|
|
422
|
+
reqHeaders['x-stainless-timeout'] = String(Math.trunc(options.timeout / 1000));
|
|
404
423
|
}
|
|
405
424
|
|
|
406
425
|
this.validateHeaders(reqHeaders, headers);
|
|
@@ -441,7 +460,7 @@ export abstract class APIClient {
|
|
|
441
460
|
!headers ? {}
|
|
442
461
|
: Symbol.iterator in headers ?
|
|
443
462
|
Object.fromEntries(Array.from(headers as Iterable<string[]>).map((header) => [...header]))
|
|
444
|
-
: { ...headers }
|
|
463
|
+
: { ...(headers as any as Record<string, string>) }
|
|
445
464
|
);
|
|
446
465
|
}
|
|
447
466
|
|
package/src/index.ts
CHANGED
|
@@ -70,6 +70,7 @@ import {
|
|
|
70
70
|
Metadata,
|
|
71
71
|
Model,
|
|
72
72
|
PlainTextSource,
|
|
73
|
+
RawContentBlockDelta,
|
|
73
74
|
RawContentBlockDeltaEvent,
|
|
74
75
|
RawContentBlockStartEvent,
|
|
75
76
|
RawContentBlockStopEvent,
|
|
@@ -80,6 +81,7 @@ import {
|
|
|
80
81
|
RedactedThinkingBlock,
|
|
81
82
|
RedactedThinkingBlockParam,
|
|
82
83
|
SignatureDelta,
|
|
84
|
+
StopReason,
|
|
83
85
|
TextBlock,
|
|
84
86
|
TextBlockParam,
|
|
85
87
|
TextCitation,
|
|
@@ -279,17 +281,10 @@ export class Anthropic extends Core.APIClient {
|
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return apiKeyAuth;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (bearerAuth != null && !Core.isEmptyObj(bearerAuth)) {
|
|
290
|
-
return bearerAuth;
|
|
291
|
-
}
|
|
292
|
-
return {};
|
|
284
|
+
return {
|
|
285
|
+
...this.apiKeyAuth(opts),
|
|
286
|
+
...this.bearerAuth(opts),
|
|
287
|
+
};
|
|
293
288
|
}
|
|
294
289
|
|
|
295
290
|
protected apiKeyAuth(opts: Core.FinalRequestOptions): Core.Headers {
|
|
@@ -362,27 +357,21 @@ export declare namespace Anthropic {
|
|
|
362
357
|
type CitationsConfigParam as CitationsConfigParam,
|
|
363
358
|
type CitationsDelta as CitationsDelta,
|
|
364
359
|
type ContentBlock as ContentBlock,
|
|
365
|
-
type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
|
|
366
360
|
type ContentBlockParam as ContentBlockParam,
|
|
367
361
|
type ContentBlockSource as ContentBlockSource,
|
|
368
362
|
type ContentBlockSourceContent as ContentBlockSourceContent,
|
|
369
|
-
type ContentBlockStartEvent as ContentBlockStartEvent,
|
|
370
|
-
type ContentBlockStopEvent as ContentBlockStopEvent,
|
|
371
363
|
type DocumentBlockParam as DocumentBlockParam,
|
|
372
364
|
type ImageBlockParam as ImageBlockParam,
|
|
373
365
|
type InputJSONDelta as InputJSONDelta,
|
|
374
366
|
type Message as Message,
|
|
375
367
|
type MessageCountTokensTool as MessageCountTokensTool,
|
|
376
|
-
type MessageDeltaEvent as MessageDeltaEvent,
|
|
377
368
|
type MessageDeltaUsage as MessageDeltaUsage,
|
|
378
369
|
type MessageParam as MessageParam,
|
|
379
|
-
type MessageStartEvent as MessageStartEvent,
|
|
380
|
-
type MessageStopEvent as MessageStopEvent,
|
|
381
|
-
type MessageStreamEvent as MessageStreamEvent,
|
|
382
370
|
type MessageTokensCount as MessageTokensCount,
|
|
383
371
|
type Metadata as Metadata,
|
|
384
372
|
type Model as Model,
|
|
385
373
|
type PlainTextSource as PlainTextSource,
|
|
374
|
+
type RawContentBlockDelta as RawContentBlockDelta,
|
|
386
375
|
type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent,
|
|
387
376
|
type RawContentBlockStartEvent as RawContentBlockStartEvent,
|
|
388
377
|
type RawContentBlockStopEvent as RawContentBlockStopEvent,
|
|
@@ -393,6 +382,7 @@ export declare namespace Anthropic {
|
|
|
393
382
|
type RedactedThinkingBlock as RedactedThinkingBlock,
|
|
394
383
|
type RedactedThinkingBlockParam as RedactedThinkingBlockParam,
|
|
395
384
|
type SignatureDelta as SignatureDelta,
|
|
385
|
+
type StopReason as StopReason,
|
|
396
386
|
type TextBlock as TextBlock,
|
|
397
387
|
type TextBlockParam as TextBlockParam,
|
|
398
388
|
type TextCitation as TextCitation,
|
|
@@ -419,6 +409,13 @@ export declare namespace Anthropic {
|
|
|
419
409
|
type URLImageSource as URLImageSource,
|
|
420
410
|
type URLPDFSource as URLPDFSource,
|
|
421
411
|
type Usage as Usage,
|
|
412
|
+
type MessageStreamEvent as MessageStreamEvent,
|
|
413
|
+
type MessageStartEvent as MessageStartEvent,
|
|
414
|
+
type MessageDeltaEvent as MessageDeltaEvent,
|
|
415
|
+
type MessageStopEvent as MessageStopEvent,
|
|
416
|
+
type ContentBlockStartEvent as ContentBlockStartEvent,
|
|
417
|
+
type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
|
|
418
|
+
type ContentBlockStopEvent as ContentBlockStopEvent,
|
|
422
419
|
type MessageCreateParams as MessageCreateParams,
|
|
423
420
|
type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
|
|
424
421
|
type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
BetaMessageTokensCount,
|
|
30
30
|
BetaMetadata,
|
|
31
31
|
BetaPlainTextSource,
|
|
32
|
+
BetaRawContentBlockDelta,
|
|
32
33
|
BetaRawContentBlockDeltaEvent,
|
|
33
34
|
BetaRawContentBlockStartEvent,
|
|
34
35
|
BetaRawContentBlockStopEvent,
|
|
@@ -39,6 +40,7 @@ import {
|
|
|
39
40
|
BetaRedactedThinkingBlock,
|
|
40
41
|
BetaRedactedThinkingBlockParam,
|
|
41
42
|
BetaSignatureDelta,
|
|
43
|
+
BetaStopReason,
|
|
42
44
|
BetaTextBlock,
|
|
43
45
|
BetaTextBlockParam,
|
|
44
46
|
BetaTextCitation,
|
|
@@ -216,6 +218,7 @@ export declare namespace Beta {
|
|
|
216
218
|
type BetaMessageTokensCount as BetaMessageTokensCount,
|
|
217
219
|
type BetaMetadata as BetaMetadata,
|
|
218
220
|
type BetaPlainTextSource as BetaPlainTextSource,
|
|
221
|
+
type BetaRawContentBlockDelta as BetaRawContentBlockDelta,
|
|
219
222
|
type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
|
|
220
223
|
type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent,
|
|
221
224
|
type BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent,
|
|
@@ -226,6 +229,7 @@ export declare namespace Beta {
|
|
|
226
229
|
type BetaRedactedThinkingBlock as BetaRedactedThinkingBlock,
|
|
227
230
|
type BetaRedactedThinkingBlockParam as BetaRedactedThinkingBlockParam,
|
|
228
231
|
type BetaSignatureDelta as BetaSignatureDelta,
|
|
232
|
+
type BetaStopReason as BetaStopReason,
|
|
229
233
|
type BetaTextBlock as BetaTextBlock,
|
|
230
234
|
type BetaTextBlockParam as BetaTextBlockParam,
|
|
231
235
|
type BetaTextCitation as BetaTextCitation,
|
|
@@ -42,6 +42,7 @@ export {
|
|
|
42
42
|
type BetaMessageTokensCount,
|
|
43
43
|
type BetaMetadata,
|
|
44
44
|
type BetaPlainTextSource,
|
|
45
|
+
type BetaRawContentBlockDelta,
|
|
45
46
|
type BetaRawContentBlockDeltaEvent,
|
|
46
47
|
type BetaRawContentBlockStartEvent,
|
|
47
48
|
type BetaRawContentBlockStopEvent,
|
|
@@ -52,6 +53,7 @@ export {
|
|
|
52
53
|
type BetaRedactedThinkingBlock,
|
|
53
54
|
type BetaRedactedThinkingBlockParam,
|
|
54
55
|
type BetaSignatureDelta,
|
|
56
|
+
type BetaStopReason,
|
|
55
57
|
type BetaTextBlock,
|
|
56
58
|
type BetaTextBlockParam,
|
|
57
59
|
type BetaTextCitation,
|
|
@@ -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 BetaAPI from "../beta.js";
|
|
7
8
|
import * as BetaMessagesAPI from "./messages.js";
|
|
@@ -177,7 +178,7 @@ export class Batches extends APIResource {
|
|
|
177
178
|
*/
|
|
178
179
|
async results(
|
|
179
180
|
messageBatchId: string,
|
|
180
|
-
params
|
|
181
|
+
params: BatchResultsParams | undefined,
|
|
181
182
|
options?: Core.RequestOptions,
|
|
182
183
|
): Promise<JSONLDecoder<BetaMessageBatchIndividualResponse>>;
|
|
183
184
|
async results(
|
|
@@ -209,9 +210,12 @@ export class Batches extends APIResource {
|
|
|
209
210
|
Accept: 'application/binary',
|
|
210
211
|
...options?.headers,
|
|
211
212
|
},
|
|
213
|
+
stream: true,
|
|
212
214
|
__binaryResponse: true,
|
|
213
215
|
})
|
|
214
|
-
._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller))
|
|
216
|
+
._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller)) as APIPromise<
|
|
217
|
+
JSONLDecoder<BetaMessageBatchIndividualResponse>
|
|
218
|
+
>;
|
|
215
219
|
}
|
|
216
220
|
}
|
|
217
221
|
|
|
@@ -45,6 +45,7 @@ export {
|
|
|
45
45
|
type BetaMessageTokensCount,
|
|
46
46
|
type BetaMetadata,
|
|
47
47
|
type BetaPlainTextSource,
|
|
48
|
+
type BetaRawContentBlockDelta,
|
|
48
49
|
type BetaRawContentBlockDeltaEvent,
|
|
49
50
|
type BetaRawContentBlockStartEvent,
|
|
50
51
|
type BetaRawContentBlockStopEvent,
|
|
@@ -55,6 +56,7 @@ export {
|
|
|
55
56
|
type BetaRedactedThinkingBlock,
|
|
56
57
|
type BetaRedactedThinkingBlockParam,
|
|
57
58
|
type BetaSignatureDelta,
|
|
59
|
+
type BetaStopReason,
|
|
58
60
|
type BetaTextBlock,
|
|
59
61
|
type BetaTextBlockParam,
|
|
60
62
|
type BetaTextCitation,
|
|
@@ -362,7 +362,7 @@ export interface BetaMessage {
|
|
|
362
362
|
* In non-streaming mode this value is always non-null. In streaming mode, it is
|
|
363
363
|
* null in the `message_start` event and non-null otherwise.
|
|
364
364
|
*/
|
|
365
|
-
stop_reason:
|
|
365
|
+
stop_reason: BetaStopReason | null;
|
|
366
366
|
|
|
367
367
|
/**
|
|
368
368
|
* Which custom stop sequence was generated, if any.
|
|
@@ -439,8 +439,15 @@ export interface BetaPlainTextSource {
|
|
|
439
439
|
type: 'text';
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
+
export type BetaRawContentBlockDelta =
|
|
443
|
+
| BetaTextDelta
|
|
444
|
+
| BetaInputJSONDelta
|
|
445
|
+
| BetaCitationsDelta
|
|
446
|
+
| BetaThinkingDelta
|
|
447
|
+
| BetaSignatureDelta;
|
|
448
|
+
|
|
442
449
|
export interface BetaRawContentBlockDeltaEvent {
|
|
443
|
-
delta:
|
|
450
|
+
delta: BetaRawContentBlockDelta;
|
|
444
451
|
|
|
445
452
|
index: number;
|
|
446
453
|
|
|
@@ -488,7 +495,7 @@ export interface BetaRawMessageDeltaEvent {
|
|
|
488
495
|
|
|
489
496
|
export namespace BetaRawMessageDeltaEvent {
|
|
490
497
|
export interface Delta {
|
|
491
|
-
stop_reason:
|
|
498
|
+
stop_reason: MessagesMessagesAPI.BetaStopReason | null;
|
|
492
499
|
|
|
493
500
|
stop_sequence: string | null;
|
|
494
501
|
}
|
|
@@ -530,6 +537,8 @@ export interface BetaSignatureDelta {
|
|
|
530
537
|
type: 'signature_delta';
|
|
531
538
|
}
|
|
532
539
|
|
|
540
|
+
export type BetaStopReason = 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use';
|
|
541
|
+
|
|
533
542
|
export interface BetaTextBlock {
|
|
534
543
|
/**
|
|
535
544
|
* Citations supporting the text block.
|
|
@@ -669,6 +678,7 @@ export namespace BetaTool {
|
|
|
669
678
|
type: 'object';
|
|
670
679
|
|
|
671
680
|
properties?: unknown | null;
|
|
681
|
+
|
|
672
682
|
[k: string]: unknown;
|
|
673
683
|
}
|
|
674
684
|
}
|
|
@@ -1471,6 +1481,7 @@ export declare namespace Messages {
|
|
|
1471
1481
|
type BetaMessageTokensCount as BetaMessageTokensCount,
|
|
1472
1482
|
type BetaMetadata as BetaMetadata,
|
|
1473
1483
|
type BetaPlainTextSource as BetaPlainTextSource,
|
|
1484
|
+
type BetaRawContentBlockDelta as BetaRawContentBlockDelta,
|
|
1474
1485
|
type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
|
|
1475
1486
|
type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent,
|
|
1476
1487
|
type BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent,
|
|
@@ -1481,6 +1492,7 @@ export declare namespace Messages {
|
|
|
1481
1492
|
type BetaRedactedThinkingBlock as BetaRedactedThinkingBlock,
|
|
1482
1493
|
type BetaRedactedThinkingBlockParam as BetaRedactedThinkingBlockParam,
|
|
1483
1494
|
type BetaSignatureDelta as BetaSignatureDelta,
|
|
1495
|
+
type BetaStopReason as BetaStopReason,
|
|
1484
1496
|
type BetaTextBlock as BetaTextBlock,
|
|
1485
1497
|
type BetaTextBlockParam as BetaTextBlockParam,
|
|
1486
1498
|
type BetaTextCitation as BetaTextCitation,
|
package/src/resources/index.ts
CHANGED
|
@@ -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,
|
|
@@ -96,6 +91,13 @@ export {
|
|
|
96
91
|
type URLImageSource,
|
|
97
92
|
type URLPDFSource,
|
|
98
93
|
type Usage,
|
|
94
|
+
type MessageStreamEvent,
|
|
95
|
+
type MessageStartEvent,
|
|
96
|
+
type MessageDeltaEvent,
|
|
97
|
+
type MessageStopEvent,
|
|
98
|
+
type ContentBlockStartEvent,
|
|
99
|
+
type ContentBlockDeltaEvent,
|
|
100
|
+
type ContentBlockStopEvent,
|
|
99
101
|
type MessageCreateParams,
|
|
100
102
|
type MessageCreateParamsNonStreaming,
|
|
101
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,
|
|
@@ -86,6 +81,13 @@ export {
|
|
|
86
81
|
type URLImageSource,
|
|
87
82
|
type URLPDFSource,
|
|
88
83
|
type Usage,
|
|
84
|
+
type MessageStreamEvent,
|
|
85
|
+
type MessageStartEvent,
|
|
86
|
+
type MessageDeltaEvent,
|
|
87
|
+
type MessageStopEvent,
|
|
88
|
+
type ContentBlockStartEvent,
|
|
89
|
+
type ContentBlockDeltaEvent,
|
|
90
|
+
type ContentBlockStopEvent,
|
|
89
91
|
type MessageCreateParams,
|
|
90
92
|
type MessageCreateParamsBase,
|
|
91
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:
|
|
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:
|
|
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:
|
|
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
|
}
|
|
@@ -840,6 +836,20 @@ export interface Usage {
|
|
|
840
836
|
output_tokens: number;
|
|
841
837
|
}
|
|
842
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
|
+
|
|
843
853
|
export type MessageCreateParams = MessageCreateParamsNonStreaming | MessageCreateParamsStreaming;
|
|
844
854
|
|
|
845
855
|
export interface MessageCreateParamsBase {
|
|
@@ -1379,28 +1389,22 @@ export declare namespace Messages {
|
|
|
1379
1389
|
type CitationsConfigParam as CitationsConfigParam,
|
|
1380
1390
|
type CitationsDelta as CitationsDelta,
|
|
1381
1391
|
type ContentBlock as ContentBlock,
|
|
1382
|
-
type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
|
|
1383
1392
|
type ContentBlockParam as ContentBlockParam,
|
|
1384
1393
|
type ContentBlockSource as ContentBlockSource,
|
|
1385
1394
|
type ContentBlockSourceContent as ContentBlockSourceContent,
|
|
1386
|
-
type ContentBlockStartEvent as ContentBlockStartEvent,
|
|
1387
|
-
type ContentBlockStopEvent as ContentBlockStopEvent,
|
|
1388
1395
|
type DocumentBlockParam as DocumentBlockParam,
|
|
1389
1396
|
type ImageBlockParam as ImageBlockParam,
|
|
1390
1397
|
type InputJsonDelta as InputJsonDelta,
|
|
1391
1398
|
type InputJSONDelta as InputJSONDelta,
|
|
1392
1399
|
type Message as Message,
|
|
1393
1400
|
type MessageCountTokensTool as MessageCountTokensTool,
|
|
1394
|
-
type MessageDeltaEvent as MessageDeltaEvent,
|
|
1395
1401
|
type MessageDeltaUsage as MessageDeltaUsage,
|
|
1396
1402
|
type MessageParam as MessageParam,
|
|
1397
|
-
type MessageStartEvent as MessageStartEvent,
|
|
1398
|
-
type MessageStopEvent as MessageStopEvent,
|
|
1399
|
-
type MessageStreamEvent as MessageStreamEvent,
|
|
1400
1403
|
type MessageTokensCount as MessageTokensCount,
|
|
1401
1404
|
type Metadata as Metadata,
|
|
1402
1405
|
type Model as Model,
|
|
1403
1406
|
type PlainTextSource as PlainTextSource,
|
|
1407
|
+
type RawContentBlockDelta as RawContentBlockDelta,
|
|
1404
1408
|
type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent,
|
|
1405
1409
|
type RawContentBlockStartEvent as RawContentBlockStartEvent,
|
|
1406
1410
|
type RawContentBlockStopEvent as RawContentBlockStopEvent,
|
|
@@ -1411,6 +1415,7 @@ export declare namespace Messages {
|
|
|
1411
1415
|
type RedactedThinkingBlock as RedactedThinkingBlock,
|
|
1412
1416
|
type RedactedThinkingBlockParam as RedactedThinkingBlockParam,
|
|
1413
1417
|
type SignatureDelta as SignatureDelta,
|
|
1418
|
+
type StopReason as StopReason,
|
|
1414
1419
|
type TextBlock as TextBlock,
|
|
1415
1420
|
type TextBlockParam as TextBlockParam,
|
|
1416
1421
|
type TextCitation as TextCitation,
|
|
@@ -1437,6 +1442,13 @@ export declare namespace Messages {
|
|
|
1437
1442
|
type URLImageSource as URLImageSource,
|
|
1438
1443
|
type URLPDFSource as URLPDFSource,
|
|
1439
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,
|
|
1440
1452
|
type MessageCreateParams as MessageCreateParams,
|
|
1441
1453
|
type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
|
|
1442
1454
|
type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
|
package/src/resources.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./resources/index.js";
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.40.1'; // x-release-please-version
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.40.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|