@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.
- package/CHANGELOG.md +24 -0
- package/client.d.mts +2 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +2 -2
- package/client.d.ts.map +1 -1
- package/client.js.map +1 -1
- package/client.mjs.map +1 -1
- package/internal/message-stream-utils.d.mts +10 -0
- package/internal/message-stream-utils.d.mts.map +1 -0
- package/internal/message-stream-utils.d.ts +10 -0
- package/internal/message-stream-utils.d.ts.map +1 -0
- package/internal/message-stream-utils.js +34 -0
- package/internal/message-stream-utils.js.map +1 -0
- package/internal/message-stream-utils.mjs +30 -0
- package/internal/message-stream-utils.mjs.map +1 -0
- package/lib/BetaMessageStream.d.mts.map +1 -1
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +36 -27
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +36 -27
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/MessageStream.d.mts.map +1 -1
- package/lib/MessageStream.d.ts.map +1 -1
- package/lib/MessageStream.js +18 -22
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +15 -19
- package/lib/MessageStream.mjs.map +1 -1
- package/lib/middleware.d.mts.map +1 -1
- package/lib/middleware.d.ts.map +1 -1
- package/lib/middleware.js +7 -1
- package/lib/middleware.js.map +1 -1
- package/lib/middleware.mjs +7 -1
- package/lib/middleware.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/beta.d.mts +4 -4
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +4 -4
- 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.mts +2 -2
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +2 -2
- 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/index.d.mts +1 -1
- package/resources/beta/messages/index.d.mts.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.mts +84 -44
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +84 -44
- 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/webhooks.d.mts +11 -2
- package/resources/beta/webhooks.d.mts.map +1 -1
- package/resources/beta/webhooks.d.ts +11 -2
- package/resources/beta/webhooks.d.ts.map +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.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/index.d.mts +1 -1
- package/resources/messages/index.d.mts.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.mts +47 -23
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +47 -23
- 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/src/client.ts +2 -0
- package/src/internal/message-stream-utils.ts +30 -0
- package/src/lib/BetaMessageStream.ts +37 -30
- package/src/lib/MessageStream.ts +15 -22
- package/src/lib/middleware.ts +7 -1
- package/src/resources/beta/beta.ts +6 -0
- package/src/resources/beta/index.ts +3 -0
- package/src/resources/beta/messages/index.ts +2 -0
- package/src/resources/beta/messages/messages.ts +141 -41
- package/src/resources/beta/webhooks.ts +16 -1
- package/src/resources/index.ts +1 -0
- package/src/resources/messages/index.ts +1 -0
- package/src/resources/messages/messages.ts +86 -24
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/lib/MessageStream.ts
CHANGED
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
type ServerToolUseBlock,
|
|
15
15
|
} from '../resources/messages';
|
|
16
16
|
import { Stream } from '../streaming';
|
|
17
|
-
import { partialParse } from '../_vendor/partial-json-parser/parser';
|
|
18
17
|
import { RequestOptions } from '../internal/request-options';
|
|
19
18
|
import type { Logger } from '../client';
|
|
20
19
|
import { maybeParseMessage, type ParsedMessage } from './parser';
|
|
20
|
+
import { JSON_BUF_PROPERTY, withLazyInput } from '../internal/message-stream-utils';
|
|
21
21
|
|
|
22
22
|
export interface MessageStreamEvents<ParsedT = null> {
|
|
23
23
|
connect: () => void;
|
|
@@ -40,8 +40,6 @@ type MessageStreamEventListeners<ParsedT, Event extends keyof MessageStreamEvent
|
|
|
40
40
|
once?: boolean;
|
|
41
41
|
}[];
|
|
42
42
|
|
|
43
|
-
const JSON_BUF_PROPERTY = '__json_buf';
|
|
44
|
-
|
|
45
43
|
export type TracksToolInput = ToolUseBlock | ServerToolUseBlock;
|
|
46
44
|
|
|
47
45
|
function tracksToolInput(content: ContentBlock): content is TracksToolInput {
|
|
@@ -470,7 +468,7 @@ export class MessageStream<ParsedT = null> implements AsyncIterable<MessageStrea
|
|
|
470
468
|
break;
|
|
471
469
|
}
|
|
472
470
|
case 'input_json_delta': {
|
|
473
|
-
if (tracksToolInput(content) &&
|
|
471
|
+
if (tracksToolInput(content) && this.#listeners.inputJson?.length) {
|
|
474
472
|
this._emit('inputJson', event.delta.partial_json, content.input);
|
|
475
473
|
}
|
|
476
474
|
break;
|
|
@@ -626,23 +624,8 @@ export class MessageStream<ParsedT = null> implements AsyncIterable<MessageStrea
|
|
|
626
624
|
}
|
|
627
625
|
case 'input_json_delta': {
|
|
628
626
|
if (snapshotContent && tracksToolInput(snapshotContent)) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
// non-enumerable property on the snapshot
|
|
632
|
-
let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
|
|
633
|
-
jsonBuf += event.delta.partial_json;
|
|
634
|
-
|
|
635
|
-
const newContent = { ...snapshotContent };
|
|
636
|
-
Object.defineProperty(newContent, JSON_BUF_PROPERTY, {
|
|
637
|
-
value: jsonBuf,
|
|
638
|
-
enumerable: false,
|
|
639
|
-
writable: true,
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
if (jsonBuf) {
|
|
643
|
-
newContent.input = partialParse(jsonBuf);
|
|
644
|
-
}
|
|
645
|
-
snapshot.content[event.index] = newContent;
|
|
627
|
+
const jsonBuf = ((snapshotContent as any)[JSON_BUF_PROPERTY] || '') + event.delta.partial_json;
|
|
628
|
+
snapshot.content[event.index] = withLazyInput(snapshotContent, jsonBuf);
|
|
646
629
|
}
|
|
647
630
|
break;
|
|
648
631
|
}
|
|
@@ -670,8 +653,18 @@ export class MessageStream<ParsedT = null> implements AsyncIterable<MessageStrea
|
|
|
670
653
|
|
|
671
654
|
return snapshot;
|
|
672
655
|
}
|
|
673
|
-
case 'content_block_stop':
|
|
656
|
+
case 'content_block_stop': {
|
|
657
|
+
const snapshotContent = snapshot.content.at(event.index);
|
|
658
|
+
if (snapshotContent && tracksToolInput(snapshotContent) && JSON_BUF_PROPERTY in snapshotContent) {
|
|
659
|
+
Object.defineProperty(snapshotContent, 'input', {
|
|
660
|
+
value: snapshotContent.input,
|
|
661
|
+
enumerable: true,
|
|
662
|
+
configurable: true,
|
|
663
|
+
writable: true,
|
|
664
|
+
});
|
|
665
|
+
}
|
|
674
666
|
return snapshot;
|
|
667
|
+
}
|
|
675
668
|
}
|
|
676
669
|
}
|
|
677
670
|
|
package/src/lib/middleware.ts
CHANGED
|
@@ -265,6 +265,7 @@ export function betaRefusalFallbackMiddleware(
|
|
|
265
265
|
// against an untyped body that carried no `model` field.
|
|
266
266
|
from: { model: requestedModel ?? message.model },
|
|
267
267
|
to: { model: entry.model },
|
|
268
|
+
trigger: { type: 'refusal', category: message.stop_details?.category ?? null },
|
|
268
269
|
});
|
|
269
270
|
requestedModel = entry.model;
|
|
270
271
|
res = await next({
|
|
@@ -435,7 +436,12 @@ async function* splicedEvents(
|
|
|
435
436
|
yield emit<BetaRawContentBlockStartEvent>('content_block_start', {
|
|
436
437
|
type: 'content_block_start',
|
|
437
438
|
index: fbIndex,
|
|
438
|
-
content_block: {
|
|
439
|
+
content_block: {
|
|
440
|
+
type: 'fallback',
|
|
441
|
+
from: { model: fromModel },
|
|
442
|
+
to: { model },
|
|
443
|
+
trigger: { type: 'refusal', category: refusalDetails?.category ?? null },
|
|
444
|
+
},
|
|
439
445
|
});
|
|
440
446
|
yield emit<BetaRawContentBlockStopEvent>('content_block_stop', {
|
|
441
447
|
type: 'content_block_stop',
|
|
@@ -134,6 +134,7 @@ import {
|
|
|
134
134
|
BetaWebhookSessionThreadCreatedEventData,
|
|
135
135
|
BetaWebhookSessionThreadIdledEventData,
|
|
136
136
|
BetaWebhookSessionThreadTerminatedEventData,
|
|
137
|
+
BetaWebhookSessionUpdatedEventData,
|
|
137
138
|
BetaWebhookVaultArchivedEventData,
|
|
138
139
|
BetaWebhookVaultCreatedEventData,
|
|
139
140
|
BetaWebhookVaultCredentialArchivedEventData,
|
|
@@ -284,6 +285,7 @@ import {
|
|
|
284
285
|
BetaCodeExecutionTool20250522,
|
|
285
286
|
BetaCodeExecutionTool20250825,
|
|
286
287
|
BetaCodeExecutionTool20260120,
|
|
288
|
+
BetaCodeExecutionTool20260521,
|
|
287
289
|
BetaCodeExecutionToolResultBlock,
|
|
288
290
|
BetaCodeExecutionToolResultBlockContent,
|
|
289
291
|
BetaCodeExecutionToolResultBlockParam,
|
|
@@ -319,6 +321,7 @@ import {
|
|
|
319
321
|
BetaFallbackInfoParam,
|
|
320
322
|
BetaFallbackMessageIterationUsage,
|
|
321
323
|
BetaFallbackParam,
|
|
324
|
+
BetaFallbackRefusalTrigger,
|
|
322
325
|
BetaFileDocumentSource,
|
|
323
326
|
BetaFileImageSource,
|
|
324
327
|
BetaImageBlockParam,
|
|
@@ -732,6 +735,7 @@ export declare namespace Beta {
|
|
|
732
735
|
type BetaCodeExecutionTool20250522 as BetaCodeExecutionTool20250522,
|
|
733
736
|
type BetaCodeExecutionTool20250825 as BetaCodeExecutionTool20250825,
|
|
734
737
|
type BetaCodeExecutionTool20260120 as BetaCodeExecutionTool20260120,
|
|
738
|
+
type BetaCodeExecutionTool20260521 as BetaCodeExecutionTool20260521,
|
|
735
739
|
type BetaCodeExecutionToolResultBlock as BetaCodeExecutionToolResultBlock,
|
|
736
740
|
type BetaCodeExecutionToolResultBlockContent as BetaCodeExecutionToolResultBlockContent,
|
|
737
741
|
type BetaCodeExecutionToolResultBlockParam as BetaCodeExecutionToolResultBlockParam,
|
|
@@ -767,6 +771,7 @@ export declare namespace Beta {
|
|
|
767
771
|
type BetaFallbackInfoParam as BetaFallbackInfoParam,
|
|
768
772
|
type BetaFallbackMessageIterationUsage as BetaFallbackMessageIterationUsage,
|
|
769
773
|
type BetaFallbackParam as BetaFallbackParam,
|
|
774
|
+
type BetaFallbackRefusalTrigger as BetaFallbackRefusalTrigger,
|
|
770
775
|
type BetaFileDocumentSource as BetaFileDocumentSource,
|
|
771
776
|
type BetaFileImageSource as BetaFileImageSource,
|
|
772
777
|
type BetaImageBlockParam as BetaImageBlockParam,
|
|
@@ -1151,6 +1156,7 @@ export declare namespace Beta {
|
|
|
1151
1156
|
type BetaWebhookSessionThreadCreatedEventData as BetaWebhookSessionThreadCreatedEventData,
|
|
1152
1157
|
type BetaWebhookSessionThreadIdledEventData as BetaWebhookSessionThreadIdledEventData,
|
|
1153
1158
|
type BetaWebhookSessionThreadTerminatedEventData as BetaWebhookSessionThreadTerminatedEventData,
|
|
1159
|
+
type BetaWebhookSessionUpdatedEventData as BetaWebhookSessionUpdatedEventData,
|
|
1154
1160
|
type BetaWebhookVaultArchivedEventData as BetaWebhookVaultArchivedEventData,
|
|
1155
1161
|
type BetaWebhookVaultCreatedEventData as BetaWebhookVaultCreatedEventData,
|
|
1156
1162
|
type BetaWebhookVaultCredentialArchivedEventData as BetaWebhookVaultCredentialArchivedEventData,
|
|
@@ -235,6 +235,7 @@ export {
|
|
|
235
235
|
type BetaCodeExecutionTool20250522,
|
|
236
236
|
type BetaCodeExecutionTool20250825,
|
|
237
237
|
type BetaCodeExecutionTool20260120,
|
|
238
|
+
type BetaCodeExecutionTool20260521,
|
|
238
239
|
type BetaCodeExecutionToolResultBlock,
|
|
239
240
|
type BetaCodeExecutionToolResultBlockContent,
|
|
240
241
|
type BetaCodeExecutionToolResultBlockParam,
|
|
@@ -270,6 +271,7 @@ export {
|
|
|
270
271
|
type BetaFallbackInfoParam,
|
|
271
272
|
type BetaFallbackMessageIterationUsage,
|
|
272
273
|
type BetaFallbackParam,
|
|
274
|
+
type BetaFallbackRefusalTrigger,
|
|
273
275
|
type BetaFileDocumentSource,
|
|
274
276
|
type BetaFileImageSource,
|
|
275
277
|
type BetaImageBlockParam,
|
|
@@ -514,6 +516,7 @@ export {
|
|
|
514
516
|
type BetaWebhookSessionThreadCreatedEventData,
|
|
515
517
|
type BetaWebhookSessionThreadIdledEventData,
|
|
516
518
|
type BetaWebhookSessionThreadTerminatedEventData,
|
|
519
|
+
type BetaWebhookSessionUpdatedEventData,
|
|
517
520
|
type BetaWebhookVaultArchivedEventData,
|
|
518
521
|
type BetaWebhookVaultCreatedEventData,
|
|
519
522
|
type BetaWebhookVaultCredentialArchivedEventData,
|
|
@@ -74,6 +74,7 @@ export {
|
|
|
74
74
|
type BetaCodeExecutionTool20250522,
|
|
75
75
|
type BetaCodeExecutionTool20250825,
|
|
76
76
|
type BetaCodeExecutionTool20260120,
|
|
77
|
+
type BetaCodeExecutionTool20260521,
|
|
77
78
|
type BetaCodeExecutionToolResultBlock,
|
|
78
79
|
type BetaCodeExecutionToolResultBlockContent,
|
|
79
80
|
type BetaCodeExecutionToolResultBlockParam,
|
|
@@ -109,6 +110,7 @@ export {
|
|
|
109
110
|
type BetaFallbackInfoParam,
|
|
110
111
|
type BetaFallbackMessageIterationUsage,
|
|
111
112
|
type BetaFallbackParam,
|
|
113
|
+
type BetaFallbackRefusalTrigger,
|
|
112
114
|
type BetaFileDocumentSource,
|
|
113
115
|
type BetaFileImageSource,
|
|
114
116
|
type BetaImageBlockParam,
|
|
@@ -382,7 +382,9 @@ export interface BetaAdvisorTool20260301 {
|
|
|
382
382
|
|
|
383
383
|
type: 'advisor_20260301';
|
|
384
384
|
|
|
385
|
-
allowed_callers?: Array<
|
|
385
|
+
allowed_callers?: Array<
|
|
386
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
387
|
+
>;
|
|
386
388
|
|
|
387
389
|
/**
|
|
388
390
|
* Create a cache control breakpoint at this content block.
|
|
@@ -1024,7 +1026,9 @@ export interface BetaCodeExecutionTool20250522 {
|
|
|
1024
1026
|
|
|
1025
1027
|
type: 'code_execution_20250522';
|
|
1026
1028
|
|
|
1027
|
-
allowed_callers?: Array<
|
|
1029
|
+
allowed_callers?: Array<
|
|
1030
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
1031
|
+
>;
|
|
1028
1032
|
|
|
1029
1033
|
/**
|
|
1030
1034
|
* Create a cache control breakpoint at this content block.
|
|
@@ -1053,7 +1057,9 @@ export interface BetaCodeExecutionTool20250825 {
|
|
|
1053
1057
|
|
|
1054
1058
|
type: 'code_execution_20250825';
|
|
1055
1059
|
|
|
1056
|
-
allowed_callers?: Array<
|
|
1060
|
+
allowed_callers?: Array<
|
|
1061
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
1062
|
+
>;
|
|
1057
1063
|
|
|
1058
1064
|
/**
|
|
1059
1065
|
* Create a cache control breakpoint at this content block.
|
|
@@ -1086,7 +1092,43 @@ export interface BetaCodeExecutionTool20260120 {
|
|
|
1086
1092
|
|
|
1087
1093
|
type: 'code_execution_20260120';
|
|
1088
1094
|
|
|
1089
|
-
allowed_callers?: Array<
|
|
1095
|
+
allowed_callers?: Array<
|
|
1096
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
1097
|
+
>;
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* Create a cache control breakpoint at this content block.
|
|
1101
|
+
*/
|
|
1102
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* If true, tool will not be included in initial system prompt. Only loaded when
|
|
1106
|
+
* returned via tool_reference from tool search.
|
|
1107
|
+
*/
|
|
1108
|
+
defer_loading?: boolean;
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* When true, guarantees schema validation on tool names and inputs
|
|
1112
|
+
*/
|
|
1113
|
+
strict?: boolean;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Code execution tool with REPL state persistence.
|
|
1118
|
+
*/
|
|
1119
|
+
export interface BetaCodeExecutionTool20260521 {
|
|
1120
|
+
/**
|
|
1121
|
+
* Name of the tool.
|
|
1122
|
+
*
|
|
1123
|
+
* This is how the tool will be called by the model and in `tool_use` blocks.
|
|
1124
|
+
*/
|
|
1125
|
+
name: 'code_execution';
|
|
1126
|
+
|
|
1127
|
+
type: 'code_execution_20260521';
|
|
1128
|
+
|
|
1129
|
+
allowed_callers?: Array<
|
|
1130
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
1131
|
+
>;
|
|
1090
1132
|
|
|
1091
1133
|
/**
|
|
1092
1134
|
* Create a cache control breakpoint at this content block.
|
|
@@ -1515,10 +1557,10 @@ export interface BetaEncryptedCodeExecutionResultBlockParam {
|
|
|
1515
1557
|
* Marks the point in `content` where one model's output gives way to the next.
|
|
1516
1558
|
*
|
|
1517
1559
|
* One block appears per hop where a preceding model actually ran this turn and
|
|
1518
|
-
* declined. A turn
|
|
1519
|
-
* carries no block — the signal for whether a fallback model served the
|
|
1520
|
-
* is the presence of a `fallback_message` entry in `usage.iterations`,
|
|
1521
|
-
* block.
|
|
1560
|
+
* declined. A turn where no preceding model ran and declined has no such boundary
|
|
1561
|
+
* and carries no block — the signal for whether a fallback model served the
|
|
1562
|
+
* response is the presence of a `fallback_message` entry in `usage.iterations`,
|
|
1563
|
+
* not this block.
|
|
1522
1564
|
*
|
|
1523
1565
|
* The block is treated like a server-tool content block for streaming: it arrives
|
|
1524
1566
|
* via the standard `content_block_start` / `content_block_stop` pair and carries
|
|
@@ -1539,25 +1581,27 @@ export interface BetaFallbackBlock {
|
|
|
1539
1581
|
*/
|
|
1540
1582
|
to: BetaFallbackInfo;
|
|
1541
1583
|
|
|
1584
|
+
/**
|
|
1585
|
+
* What caused the `from` model to hand over at this hop.
|
|
1586
|
+
*/
|
|
1587
|
+
trigger: BetaFallbackRefusalTrigger;
|
|
1588
|
+
|
|
1542
1589
|
type: 'fallback';
|
|
1543
1590
|
}
|
|
1544
1591
|
|
|
1545
1592
|
/**
|
|
1546
1593
|
* A `fallback` block echoed back from a prior response.
|
|
1547
1594
|
*
|
|
1548
|
-
* Accepted in `messages[].content` and
|
|
1549
|
-
*
|
|
1550
|
-
* stripped before the sticky-routing cache key is computed.
|
|
1595
|
+
* Accepted in `messages[].content` and not rendered into the prompt; not validated
|
|
1596
|
+
* against the request's `fallbacks` chain or top-level `model`.
|
|
1551
1597
|
*
|
|
1552
|
-
*
|
|
1553
|
-
* position
|
|
1554
|
-
*
|
|
1555
|
-
*
|
|
1556
|
-
*
|
|
1557
|
-
*
|
|
1558
|
-
*
|
|
1559
|
-
* rejected; between non-thinking blocks the block's placement has no verification
|
|
1560
|
-
* effect.
|
|
1598
|
+
* Echo the assistant turn back verbatim, including this block in its original
|
|
1599
|
+
* position. The block marks the boundary between content produced before and after
|
|
1600
|
+
* a fallback hop, and the server relies on that boundary to validate the turn:
|
|
1601
|
+
* when thinking runs flank the boundary, omitting the block merges them into one
|
|
1602
|
+
* span the server cannot validate (the request is rejected), and moving it into
|
|
1603
|
+
* the middle of a single run is likewise rejected; between non-thinking blocks the
|
|
1604
|
+
* block's placement has no validation effect.
|
|
1561
1605
|
*/
|
|
1562
1606
|
export interface BetaFallbackBlockParam {
|
|
1563
1607
|
/**
|
|
@@ -1571,6 +1615,12 @@ export interface BetaFallbackBlockParam {
|
|
|
1571
1615
|
to: BetaFallbackInfoParam;
|
|
1572
1616
|
|
|
1573
1617
|
type: 'fallback';
|
|
1618
|
+
|
|
1619
|
+
/**
|
|
1620
|
+
* The response block's `trigger`, echoed verbatim. Accepted and ignored by the
|
|
1621
|
+
* server; any object or `null` is allowed.
|
|
1622
|
+
*/
|
|
1623
|
+
trigger?: unknown;
|
|
1574
1624
|
}
|
|
1575
1625
|
|
|
1576
1626
|
/**
|
|
@@ -1675,6 +1725,18 @@ export interface BetaFallbackParam {
|
|
|
1675
1725
|
[k: string]: unknown;
|
|
1676
1726
|
}
|
|
1677
1727
|
|
|
1728
|
+
/**
|
|
1729
|
+
* The `from` model declined for policy reasons.
|
|
1730
|
+
*/
|
|
1731
|
+
export interface BetaFallbackRefusalTrigger {
|
|
1732
|
+
/**
|
|
1733
|
+
* The policy category that triggered a refusal.
|
|
1734
|
+
*/
|
|
1735
|
+
category: 'cyber' | 'bio' | 'frontier_llm' | 'reasoning_extraction' | null;
|
|
1736
|
+
|
|
1737
|
+
type: 'refusal';
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1678
1740
|
export interface BetaFileDocumentSource {
|
|
1679
1741
|
file_id: string;
|
|
1680
1742
|
|
|
@@ -1848,7 +1910,9 @@ export interface BetaMemoryTool20250818 {
|
|
|
1848
1910
|
|
|
1849
1911
|
type: 'memory_20250818';
|
|
1850
1912
|
|
|
1851
|
-
allowed_callers?: Array<
|
|
1913
|
+
allowed_callers?: Array<
|
|
1914
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
1915
|
+
>;
|
|
1852
1916
|
|
|
1853
1917
|
/**
|
|
1854
1918
|
* Create a cache control breakpoint at this content block.
|
|
@@ -2438,9 +2502,7 @@ export interface BetaRedactedThinkingBlockParam {
|
|
|
2438
2502
|
*/
|
|
2439
2503
|
export interface BetaRefusalStopDetails {
|
|
2440
2504
|
/**
|
|
2441
|
-
* The policy category that triggered
|
|
2442
|
-
*
|
|
2443
|
-
* `null` when the refusal doesn't map to a named category.
|
|
2505
|
+
* The policy category that triggered a refusal.
|
|
2444
2506
|
*/
|
|
2445
2507
|
category: 'cyber' | 'bio' | 'frontier_llm' | 'reasoning_extraction' | null;
|
|
2446
2508
|
|
|
@@ -3019,7 +3081,9 @@ export interface BetaTool {
|
|
|
3019
3081
|
*/
|
|
3020
3082
|
name: string;
|
|
3021
3083
|
|
|
3022
|
-
allowed_callers?: Array<
|
|
3084
|
+
allowed_callers?: Array<
|
|
3085
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3086
|
+
>;
|
|
3023
3087
|
|
|
3024
3088
|
/**
|
|
3025
3089
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3089,7 +3153,9 @@ export interface BetaToolBash20241022 {
|
|
|
3089
3153
|
|
|
3090
3154
|
type: 'bash_20241022';
|
|
3091
3155
|
|
|
3092
|
-
allowed_callers?: Array<
|
|
3156
|
+
allowed_callers?: Array<
|
|
3157
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3158
|
+
>;
|
|
3093
3159
|
|
|
3094
3160
|
/**
|
|
3095
3161
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3120,7 +3186,9 @@ export interface BetaToolBash20250124 {
|
|
|
3120
3186
|
|
|
3121
3187
|
type: 'bash_20250124';
|
|
3122
3188
|
|
|
3123
|
-
allowed_callers?: Array<
|
|
3189
|
+
allowed_callers?: Array<
|
|
3190
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3191
|
+
>;
|
|
3124
3192
|
|
|
3125
3193
|
/**
|
|
3126
3194
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3224,7 +3292,9 @@ export interface BetaToolComputerUse20241022 {
|
|
|
3224
3292
|
|
|
3225
3293
|
type: 'computer_20241022';
|
|
3226
3294
|
|
|
3227
|
-
allowed_callers?: Array<
|
|
3295
|
+
allowed_callers?: Array<
|
|
3296
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3297
|
+
>;
|
|
3228
3298
|
|
|
3229
3299
|
/**
|
|
3230
3300
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3270,7 +3340,9 @@ export interface BetaToolComputerUse20250124 {
|
|
|
3270
3340
|
|
|
3271
3341
|
type: 'computer_20250124';
|
|
3272
3342
|
|
|
3273
|
-
allowed_callers?: Array<
|
|
3343
|
+
allowed_callers?: Array<
|
|
3344
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3345
|
+
>;
|
|
3274
3346
|
|
|
3275
3347
|
/**
|
|
3276
3348
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3316,7 +3388,9 @@ export interface BetaToolComputerUse20251124 {
|
|
|
3316
3388
|
|
|
3317
3389
|
type: 'computer_20251124';
|
|
3318
3390
|
|
|
3319
|
-
allowed_callers?: Array<
|
|
3391
|
+
allowed_callers?: Array<
|
|
3392
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3393
|
+
>;
|
|
3320
3394
|
|
|
3321
3395
|
/**
|
|
3322
3396
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3400,7 +3474,9 @@ export interface BetaToolSearchToolBm25_20251119 {
|
|
|
3400
3474
|
|
|
3401
3475
|
type: 'tool_search_tool_bm25_20251119' | 'tool_search_tool_bm25';
|
|
3402
3476
|
|
|
3403
|
-
allowed_callers?: Array<
|
|
3477
|
+
allowed_callers?: Array<
|
|
3478
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3479
|
+
>;
|
|
3404
3480
|
|
|
3405
3481
|
/**
|
|
3406
3482
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3429,7 +3505,9 @@ export interface BetaToolSearchToolRegex20251119 {
|
|
|
3429
3505
|
|
|
3430
3506
|
type: 'tool_search_tool_regex_20251119' | 'tool_search_tool_regex';
|
|
3431
3507
|
|
|
3432
|
-
allowed_callers?: Array<
|
|
3508
|
+
allowed_callers?: Array<
|
|
3509
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3510
|
+
>;
|
|
3433
3511
|
|
|
3434
3512
|
/**
|
|
3435
3513
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3509,7 +3587,9 @@ export interface BetaToolTextEditor20241022 {
|
|
|
3509
3587
|
|
|
3510
3588
|
type: 'text_editor_20241022';
|
|
3511
3589
|
|
|
3512
|
-
allowed_callers?: Array<
|
|
3590
|
+
allowed_callers?: Array<
|
|
3591
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3592
|
+
>;
|
|
3513
3593
|
|
|
3514
3594
|
/**
|
|
3515
3595
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3540,7 +3620,9 @@ export interface BetaToolTextEditor20250124 {
|
|
|
3540
3620
|
|
|
3541
3621
|
type: 'text_editor_20250124';
|
|
3542
3622
|
|
|
3543
|
-
allowed_callers?: Array<
|
|
3623
|
+
allowed_callers?: Array<
|
|
3624
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3625
|
+
>;
|
|
3544
3626
|
|
|
3545
3627
|
/**
|
|
3546
3628
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3571,7 +3653,9 @@ export interface BetaToolTextEditor20250429 {
|
|
|
3571
3653
|
|
|
3572
3654
|
type: 'text_editor_20250429';
|
|
3573
3655
|
|
|
3574
|
-
allowed_callers?: Array<
|
|
3656
|
+
allowed_callers?: Array<
|
|
3657
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3658
|
+
>;
|
|
3575
3659
|
|
|
3576
3660
|
/**
|
|
3577
3661
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3602,7 +3686,9 @@ export interface BetaToolTextEditor20250728 {
|
|
|
3602
3686
|
|
|
3603
3687
|
type: 'text_editor_20250728';
|
|
3604
3688
|
|
|
3605
|
-
allowed_callers?: Array<
|
|
3689
|
+
allowed_callers?: Array<
|
|
3690
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3691
|
+
>;
|
|
3606
3692
|
|
|
3607
3693
|
/**
|
|
3608
3694
|
* Create a cache control breakpoint at this content block.
|
|
@@ -3640,6 +3726,7 @@ export type BetaToolUnion =
|
|
|
3640
3726
|
| BetaCodeExecutionTool20250522
|
|
3641
3727
|
| BetaCodeExecutionTool20250825
|
|
3642
3728
|
| BetaCodeExecutionTool20260120
|
|
3729
|
+
| BetaCodeExecutionTool20260521
|
|
3643
3730
|
| BetaToolComputerUse20241022
|
|
3644
3731
|
| BetaMemoryTool20250818
|
|
3645
3732
|
| BetaToolComputerUse20250124
|
|
@@ -3854,7 +3941,9 @@ export interface BetaWebFetchTool20250910 {
|
|
|
3854
3941
|
|
|
3855
3942
|
type: 'web_fetch_20250910';
|
|
3856
3943
|
|
|
3857
|
-
allowed_callers?: Array<
|
|
3944
|
+
allowed_callers?: Array<
|
|
3945
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
3946
|
+
>;
|
|
3858
3947
|
|
|
3859
3948
|
/**
|
|
3860
3949
|
* List of domains to allow fetching from
|
|
@@ -3910,7 +3999,9 @@ export interface BetaWebFetchTool20260209 {
|
|
|
3910
3999
|
|
|
3911
4000
|
type: 'web_fetch_20260209';
|
|
3912
4001
|
|
|
3913
|
-
allowed_callers?: Array<
|
|
4002
|
+
allowed_callers?: Array<
|
|
4003
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
4004
|
+
>;
|
|
3914
4005
|
|
|
3915
4006
|
/**
|
|
3916
4007
|
* List of domains to allow fetching from
|
|
@@ -3969,7 +4060,9 @@ export interface BetaWebFetchTool20260309 {
|
|
|
3969
4060
|
|
|
3970
4061
|
type: 'web_fetch_20260309';
|
|
3971
4062
|
|
|
3972
|
-
allowed_callers?: Array<
|
|
4063
|
+
allowed_callers?: Array<
|
|
4064
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
4065
|
+
>;
|
|
3973
4066
|
|
|
3974
4067
|
/**
|
|
3975
4068
|
* List of domains to allow fetching from
|
|
@@ -4110,7 +4203,9 @@ export interface BetaWebSearchTool20250305 {
|
|
|
4110
4203
|
|
|
4111
4204
|
type: 'web_search_20250305';
|
|
4112
4205
|
|
|
4113
|
-
allowed_callers?: Array<
|
|
4206
|
+
allowed_callers?: Array<
|
|
4207
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
4208
|
+
>;
|
|
4114
4209
|
|
|
4115
4210
|
/**
|
|
4116
4211
|
* If provided, only these domains will be included in results. Cannot be used
|
|
@@ -4162,7 +4257,9 @@ export interface BetaWebSearchTool20260209 {
|
|
|
4162
4257
|
|
|
4163
4258
|
type: 'web_search_20260209';
|
|
4164
4259
|
|
|
4165
|
-
allowed_callers?: Array<
|
|
4260
|
+
allowed_callers?: Array<
|
|
4261
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
|
|
4262
|
+
>;
|
|
4166
4263
|
|
|
4167
4264
|
/**
|
|
4168
4265
|
* If provided, only these domains will be included in results. Cannot be used
|
|
@@ -4879,6 +4976,7 @@ export interface MessageCountTokensParams {
|
|
|
4879
4976
|
| BetaCodeExecutionTool20250522
|
|
4880
4977
|
| BetaCodeExecutionTool20250825
|
|
4881
4978
|
| BetaCodeExecutionTool20260120
|
|
4979
|
+
| BetaCodeExecutionTool20260521
|
|
4882
4980
|
| BetaToolComputerUse20241022
|
|
4883
4981
|
| BetaMemoryTool20250818
|
|
4884
4982
|
| BetaToolComputerUse20250124
|
|
@@ -4967,6 +5065,7 @@ export declare namespace Messages {
|
|
|
4967
5065
|
type BetaCodeExecutionTool20250522 as BetaCodeExecutionTool20250522,
|
|
4968
5066
|
type BetaCodeExecutionTool20250825 as BetaCodeExecutionTool20250825,
|
|
4969
5067
|
type BetaCodeExecutionTool20260120 as BetaCodeExecutionTool20260120,
|
|
5068
|
+
type BetaCodeExecutionTool20260521 as BetaCodeExecutionTool20260521,
|
|
4970
5069
|
type BetaCodeExecutionToolResultBlock as BetaCodeExecutionToolResultBlock,
|
|
4971
5070
|
type BetaCodeExecutionToolResultBlockContent as BetaCodeExecutionToolResultBlockContent,
|
|
4972
5071
|
type BetaCodeExecutionToolResultBlockParam as BetaCodeExecutionToolResultBlockParam,
|
|
@@ -5002,6 +5101,7 @@ export declare namespace Messages {
|
|
|
5002
5101
|
type BetaFallbackInfoParam as BetaFallbackInfoParam,
|
|
5003
5102
|
type BetaFallbackMessageIterationUsage as BetaFallbackMessageIterationUsage,
|
|
5004
5103
|
type BetaFallbackParam as BetaFallbackParam,
|
|
5104
|
+
type BetaFallbackRefusalTrigger as BetaFallbackRefusalTrigger,
|
|
5005
5105
|
type BetaFileDocumentSource as BetaFileDocumentSource,
|
|
5006
5106
|
type BetaFileImageSource as BetaFileImageSource,
|
|
5007
5107
|
type BetaImageBlockParam as BetaImageBlockParam,
|
|
@@ -59,7 +59,8 @@ export type BetaWebhookEventData =
|
|
|
59
59
|
| BetaWebhookVaultCredentialCreatedEventData
|
|
60
60
|
| BetaWebhookVaultCredentialArchivedEventData
|
|
61
61
|
| BetaWebhookVaultCredentialDeletedEventData
|
|
62
|
-
| BetaWebhookVaultCredentialRefreshFailedEventData
|
|
62
|
+
| BetaWebhookVaultCredentialRefreshFailedEventData
|
|
63
|
+
| BetaWebhookSessionUpdatedEventData;
|
|
63
64
|
|
|
64
65
|
export interface BetaWebhookSessionArchivedEventData {
|
|
65
66
|
/**
|
|
@@ -271,6 +272,19 @@ export interface BetaWebhookSessionThreadTerminatedEventData {
|
|
|
271
272
|
workspace_id: string;
|
|
272
273
|
}
|
|
273
274
|
|
|
275
|
+
export interface BetaWebhookSessionUpdatedEventData {
|
|
276
|
+
/**
|
|
277
|
+
* ID of the session that triggered the event.
|
|
278
|
+
*/
|
|
279
|
+
id: string;
|
|
280
|
+
|
|
281
|
+
organization_id: string;
|
|
282
|
+
|
|
283
|
+
type: 'session.updated';
|
|
284
|
+
|
|
285
|
+
workspace_id: string;
|
|
286
|
+
}
|
|
287
|
+
|
|
274
288
|
export interface BetaWebhookVaultArchivedEventData {
|
|
275
289
|
/**
|
|
276
290
|
* ID of the vault that triggered the event.
|
|
@@ -420,6 +434,7 @@ export declare namespace Webhooks {
|
|
|
420
434
|
type BetaWebhookSessionThreadCreatedEventData as BetaWebhookSessionThreadCreatedEventData,
|
|
421
435
|
type BetaWebhookSessionThreadIdledEventData as BetaWebhookSessionThreadIdledEventData,
|
|
422
436
|
type BetaWebhookSessionThreadTerminatedEventData as BetaWebhookSessionThreadTerminatedEventData,
|
|
437
|
+
type BetaWebhookSessionUpdatedEventData as BetaWebhookSessionUpdatedEventData,
|
|
423
438
|
type BetaWebhookVaultArchivedEventData as BetaWebhookVaultArchivedEventData,
|
|
424
439
|
type BetaWebhookVaultCreatedEventData as BetaWebhookVaultCreatedEventData,
|
|
425
440
|
type BetaWebhookVaultCredentialArchivedEventData as BetaWebhookVaultCredentialArchivedEventData,
|
package/src/resources/index.ts
CHANGED
|
@@ -58,6 +58,7 @@ export {
|
|
|
58
58
|
type CodeExecutionTool20250522,
|
|
59
59
|
type CodeExecutionTool20250825,
|
|
60
60
|
type CodeExecutionTool20260120,
|
|
61
|
+
type CodeExecutionTool20260521,
|
|
61
62
|
type CodeExecutionToolResultBlock,
|
|
62
63
|
type CodeExecutionToolResultBlockContent,
|
|
63
64
|
type CodeExecutionToolResultBlockParam,
|
|
@@ -50,6 +50,7 @@ export {
|
|
|
50
50
|
type CodeExecutionTool20250522,
|
|
51
51
|
type CodeExecutionTool20250825,
|
|
52
52
|
type CodeExecutionTool20260120,
|
|
53
|
+
type CodeExecutionTool20260521,
|
|
53
54
|
type CodeExecutionToolResultBlock,
|
|
54
55
|
type CodeExecutionToolResultBlockContent,
|
|
55
56
|
type CodeExecutionToolResultBlockParam,
|