@volcengine/ark-runtime 1.0.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/LICENSE.txt +202 -0
- package/README.md +104 -0
- package/dist/cjs/index.js +1717 -0
- package/dist/esm/client.d.ts +97 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/config.d.ts +46 -0
- package/dist/esm/config.d.ts.map +1 -0
- package/dist/esm/encryption/encrypt-chat.d.ts +24 -0
- package/dist/esm/encryption/encrypt-chat.d.ts.map +1 -0
- package/dist/esm/encryption/index.d.ts +4 -0
- package/dist/esm/encryption/index.d.ts.map +1 -0
- package/dist/esm/encryption/key-agreement.d.ts +73 -0
- package/dist/esm/encryption/key-agreement.d.ts.map +1 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.mjs +1476 -0
- package/dist/esm/rslib-runtime.mjs +37 -0
- package/dist/esm/types/bot.d.ts +109 -0
- package/dist/esm/types/bot.d.ts.map +1 -0
- package/dist/esm/types/chat-completion.d.ts +167 -0
- package/dist/esm/types/chat-completion.d.ts.map +1 -0
- package/dist/esm/types/common.d.ts +29 -0
- package/dist/esm/types/common.d.ts.map +1 -0
- package/dist/esm/types/content-generation.d.ts +118 -0
- package/dist/esm/types/content-generation.d.ts.map +1 -0
- package/dist/esm/types/context.d.ts +49 -0
- package/dist/esm/types/context.d.ts.map +1 -0
- package/dist/esm/types/embeddings.d.ts +44 -0
- package/dist/esm/types/embeddings.d.ts.map +1 -0
- package/dist/esm/types/error.d.ts +45 -0
- package/dist/esm/types/error.d.ts.map +1 -0
- package/dist/esm/types/file.d.ts +66 -0
- package/dist/esm/types/file.d.ts.map +1 -0
- package/dist/esm/types/http-request-error.d.ts +13 -0
- package/dist/esm/types/http-request-error.d.ts.map +1 -0
- package/dist/esm/types/images.d.ts +78 -0
- package/dist/esm/types/images.d.ts.map +1 -0
- package/dist/esm/types/index.d.ts +13 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/multimodal-embedding.d.ts +56 -0
- package/dist/esm/types/multimodal-embedding.d.ts.map +1 -0
- package/dist/esm/types/responses/enums.d.ts +38 -0
- package/dist/esm/types/responses/enums.d.ts.map +1 -0
- package/dist/esm/types/responses/helpers.d.ts +22 -0
- package/dist/esm/types/responses/helpers.d.ts.map +1 -0
- package/dist/esm/types/responses/index.d.ts +4 -0
- package/dist/esm/types/responses/index.d.ts.map +1 -0
- package/dist/esm/types/responses/types.d.ts +906 -0
- package/dist/esm/types/responses/types.d.ts.map +1 -0
- package/dist/esm/types/tokenization.d.ts +22 -0
- package/dist/esm/types/tokenization.d.ts.map +1 -0
- package/dist/esm/utils/breaker-provider.d.ts +9 -0
- package/dist/esm/utils/breaker-provider.d.ts.map +1 -0
- package/dist/esm/utils/breaker.d.ts +28 -0
- package/dist/esm/utils/breaker.d.ts.map +1 -0
- package/dist/esm/utils/normalize.d.ts +51 -0
- package/dist/esm/utils/normalize.d.ts.map +1 -0
- package/dist/esm/utils/request-builder.d.ts +15 -0
- package/dist/esm/utils/request-builder.d.ts.map +1 -0
- package/dist/esm/utils/request-id.d.ts +5 -0
- package/dist/esm/utils/request-id.d.ts.map +1 -0
- package/dist/esm/utils/retry.d.ts +11 -0
- package/dist/esm/utils/retry.d.ts.map +1 -0
- package/dist/esm/utils/sse-decoder.d.ts +23 -0
- package/dist/esm/utils/sse-decoder.d.ts.map +1 -0
- package/dist/esm/utils/stream-reader.d.ts +67 -0
- package/dist/esm/utils/stream-reader.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/example/README.md +118 -0
- package/example/batch-chat.ts +64 -0
- package/example/bot-chat.ts +66 -0
- package/example/chat-completion-function-call.ts +141 -0
- package/example/chat-completion-reasoning.ts +64 -0
- package/example/chat-completion-vision.ts +70 -0
- package/example/chat-completion.ts +62 -0
- package/example/content-generation.ts +70 -0
- package/example/context.ts +69 -0
- package/example/embeddings.ts +31 -0
- package/example/file-upload.ts +53 -0
- package/example/images.ts +74 -0
- package/example/list-input-items.ts +34 -0
- package/example/multimodal-embeddings.ts +36 -0
- package/example/responses/basic.ts +75 -0
- package/example/responses/doubao-app.ts +53 -0
- package/example/responses/mcp.ts +66 -0
- package/example/responses/streaming.ts +45 -0
- package/example/responses/video.ts +74 -0
- package/example/responses/web-search.ts +52 -0
- package/example/structured-outputs.ts +71 -0
- package/example/tokenization.ts +30 -0
- package/package.json +47 -0
- package/src/client.ts +1199 -0
- package/src/config.ts +68 -0
- package/src/encryption/encrypt-chat.ts +146 -0
- package/src/encryption/index.ts +21 -0
- package/src/encryption/key-agreement.ts +270 -0
- package/src/index.ts +10 -0
- package/src/types/ark.d.ts +9 -0
- package/src/types/bot.ts +127 -0
- package/src/types/chat-completion.ts +228 -0
- package/src/types/common.ts +37 -0
- package/src/types/content-generation.ts +135 -0
- package/src/types/context.ts +59 -0
- package/src/types/embeddings.ts +74 -0
- package/src/types/error.ts +93 -0
- package/src/types/file.ts +76 -0
- package/src/types/http-request-error.ts +34 -0
- package/src/types/images.ts +102 -0
- package/src/types/index.ts +12 -0
- package/src/types/multimodal-embedding.ts +67 -0
- package/src/types/responses/enums.ts +163 -0
- package/src/types/responses/helpers.ts +67 -0
- package/src/types/responses/index.ts +3 -0
- package/src/types/responses/types.ts +1335 -0
- package/src/types/tokenization.ts +24 -0
- package/src/utils/breaker-provider.ts +17 -0
- package/src/utils/breaker.ts +56 -0
- package/src/utils/normalize.ts +154 -0
- package/src/utils/request-builder.ts +51 -0
- package/src/utils/request-id.ts +17 -0
- package/src/utils/retry.ts +76 -0
- package/src/utils/sse-decoder.ts +140 -0
- package/src/utils/stream-reader.ts +270 -0
|
@@ -0,0 +1,1335 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EventType,
|
|
3
|
+
ItemType,
|
|
4
|
+
MessageRole,
|
|
5
|
+
ContentItemType,
|
|
6
|
+
ContentItemImageDetail,
|
|
7
|
+
ItemStatus,
|
|
8
|
+
ResponseStatus,
|
|
9
|
+
ThinkingType,
|
|
10
|
+
TextType,
|
|
11
|
+
ToolChoiceMode,
|
|
12
|
+
ToolType,
|
|
13
|
+
UserLocationType,
|
|
14
|
+
ObjectType,
|
|
15
|
+
ReasoningEffort,
|
|
16
|
+
IncludeType,
|
|
17
|
+
CacheType,
|
|
18
|
+
ChunkingStrategyType,
|
|
19
|
+
ActionType,
|
|
20
|
+
SourceType,
|
|
21
|
+
ApprovalMode,
|
|
22
|
+
AnnotationType,
|
|
23
|
+
ResponseImageProcessType,
|
|
24
|
+
ResponsesServiceTier,
|
|
25
|
+
ResponsesTruncation,
|
|
26
|
+
DoubaoAppBlockType,
|
|
27
|
+
ResponseDoubaoAppFeatureType,
|
|
28
|
+
} from "./enums";
|
|
29
|
+
|
|
30
|
+
// Re-export enums for convenience
|
|
31
|
+
export type {
|
|
32
|
+
EventType,
|
|
33
|
+
ItemType,
|
|
34
|
+
MessageRole,
|
|
35
|
+
ContentItemType,
|
|
36
|
+
ContentItemImageDetail,
|
|
37
|
+
ItemStatus,
|
|
38
|
+
ResponseStatus,
|
|
39
|
+
ThinkingType,
|
|
40
|
+
TextType,
|
|
41
|
+
ToolChoiceMode,
|
|
42
|
+
ToolType,
|
|
43
|
+
UserLocationType,
|
|
44
|
+
ObjectType,
|
|
45
|
+
ReasoningEffort,
|
|
46
|
+
IncludeType,
|
|
47
|
+
CacheType,
|
|
48
|
+
ChunkingStrategyType,
|
|
49
|
+
ActionType,
|
|
50
|
+
SourceType,
|
|
51
|
+
ApprovalMode,
|
|
52
|
+
AnnotationType,
|
|
53
|
+
ResponseImageProcessType,
|
|
54
|
+
ResponsesServiceTier,
|
|
55
|
+
ResponsesTruncation,
|
|
56
|
+
DoubaoAppBlockType,
|
|
57
|
+
ResponseDoubaoAppFeatureType,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
// Common / Shared types
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
|
|
64
|
+
export interface Usage {
|
|
65
|
+
prompt_tokens: number;
|
|
66
|
+
completion_tokens: number;
|
|
67
|
+
total_tokens: number;
|
|
68
|
+
prompt_tokens_details?: PromptTokensDetail;
|
|
69
|
+
completion_tokens_details?: CompletionTokensDetail;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface PromptTokensDetail {
|
|
73
|
+
cached_tokens?: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface CompletionTokensDetail {
|
|
77
|
+
reasoning_tokens?: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface Error {
|
|
81
|
+
code?: string;
|
|
82
|
+
message: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface IncompleteDetails {
|
|
86
|
+
reason?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Annotation / CoverImage
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
export interface CoverImage {
|
|
94
|
+
url?: string;
|
|
95
|
+
width?: number;
|
|
96
|
+
height?: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface Annotation {
|
|
100
|
+
type: AnnotationType;
|
|
101
|
+
title: string;
|
|
102
|
+
url: string;
|
|
103
|
+
logo_url?: string;
|
|
104
|
+
mobile_url?: string;
|
|
105
|
+
site_name?: string;
|
|
106
|
+
publish_time?: string;
|
|
107
|
+
cover_image?: CoverImage;
|
|
108
|
+
summary?: string;
|
|
109
|
+
freshness_info?: string;
|
|
110
|
+
doc_id?: string;
|
|
111
|
+
doc_name?: string;
|
|
112
|
+
chunk_id?: number;
|
|
113
|
+
chunk_attachment?: Record<string, unknown>[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
// Content Items
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
export interface TextTranslationOptions {
|
|
121
|
+
source_language: string;
|
|
122
|
+
target_language: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface ImagePixelLimit {
|
|
126
|
+
max_pixels?: number;
|
|
127
|
+
min_pixels?: number;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface ContentItemText {
|
|
131
|
+
type: ContentItemType;
|
|
132
|
+
text: string;
|
|
133
|
+
translation_options?: TextTranslationOptions;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface ContentItemImage {
|
|
137
|
+
type: ContentItemType;
|
|
138
|
+
detail?: ContentItemImageDetail;
|
|
139
|
+
image_url?: string;
|
|
140
|
+
file_id?: string;
|
|
141
|
+
image_pixel_limit?: ImagePixelLimit;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface ContentItemVideo {
|
|
145
|
+
type: ContentItemType;
|
|
146
|
+
video_url: string;
|
|
147
|
+
file_id?: string;
|
|
148
|
+
fps?: number;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface AudioChunkingStrategy {
|
|
152
|
+
type: ChunkingStrategyType;
|
|
153
|
+
prefix_padding_ms?: number;
|
|
154
|
+
silence_duration_ms?: number;
|
|
155
|
+
threshold?: number;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface ContentItemAudio {
|
|
159
|
+
type: ContentItemType;
|
|
160
|
+
chunking_strategy?: AudioChunkingStrategy;
|
|
161
|
+
audio_url: string;
|
|
162
|
+
file_id?: string;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface ContentItemFile {
|
|
166
|
+
type: ContentItemType;
|
|
167
|
+
file_data?: string;
|
|
168
|
+
file_id?: string;
|
|
169
|
+
file_url?: string;
|
|
170
|
+
filename?: string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface AudioChunk {
|
|
174
|
+
start_time?: number;
|
|
175
|
+
end_time?: number;
|
|
176
|
+
text?: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Discriminated union: `type` field selects variant */
|
|
180
|
+
export type ContentItem =
|
|
181
|
+
| ContentItemText
|
|
182
|
+
| ContentItemImage
|
|
183
|
+
| ContentItemVideo
|
|
184
|
+
| ContentItemAudio
|
|
185
|
+
| ContentItemFile;
|
|
186
|
+
|
|
187
|
+
/** MessageContent can be a simple string or an array of ContentItem */
|
|
188
|
+
export type MessageContent = string | ContentItem[];
|
|
189
|
+
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
// Output Content Items
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
|
|
194
|
+
export interface OutputContentItemText {
|
|
195
|
+
type: ContentItemType;
|
|
196
|
+
text: string;
|
|
197
|
+
annotations?: Annotation[];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export type OutputContentItem = OutputContentItemText;
|
|
201
|
+
|
|
202
|
+
// ---------------------------------------------------------------------------
|
|
203
|
+
// Reasoning Summary
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
|
|
206
|
+
export interface ReasoningSummaryPart {
|
|
207
|
+
type: string;
|
|
208
|
+
text: string;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// ---------------------------------------------------------------------------
|
|
212
|
+
// Transcription
|
|
213
|
+
// ---------------------------------------------------------------------------
|
|
214
|
+
|
|
215
|
+
export interface TranscriptionPart {
|
|
216
|
+
type: ContentItemType;
|
|
217
|
+
text: string;
|
|
218
|
+
chunks?: AudioChunk[];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ---------------------------------------------------------------------------
|
|
222
|
+
// Input Items (what the user sends)
|
|
223
|
+
// ---------------------------------------------------------------------------
|
|
224
|
+
|
|
225
|
+
export interface ItemEasyMessage {
|
|
226
|
+
type?: ItemType;
|
|
227
|
+
role: MessageRole;
|
|
228
|
+
content: MessageContent;
|
|
229
|
+
id?: string;
|
|
230
|
+
partial?: boolean;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface ItemInputMessage {
|
|
234
|
+
type?: ItemType;
|
|
235
|
+
role: MessageRole;
|
|
236
|
+
content: ContentItem[];
|
|
237
|
+
status?: ItemStatus;
|
|
238
|
+
id?: string;
|
|
239
|
+
partial?: boolean;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface ItemOutputMessage {
|
|
243
|
+
type?: ItemType;
|
|
244
|
+
role: MessageRole;
|
|
245
|
+
content: OutputContentItem[];
|
|
246
|
+
status?: ItemStatus;
|
|
247
|
+
id?: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface ItemFunctionToolCall {
|
|
251
|
+
arguments: string;
|
|
252
|
+
call_id: string;
|
|
253
|
+
name: string;
|
|
254
|
+
type: ItemType;
|
|
255
|
+
id?: string;
|
|
256
|
+
status?: ItemStatus;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface ItemFunctionToolCallOutput {
|
|
260
|
+
output: string;
|
|
261
|
+
call_id: string;
|
|
262
|
+
type: ItemType;
|
|
263
|
+
id?: string;
|
|
264
|
+
status?: ItemStatus;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface ItemReasoning {
|
|
268
|
+
id?: string;
|
|
269
|
+
type: ItemType;
|
|
270
|
+
summary?: ReasoningSummaryPart[];
|
|
271
|
+
status: ItemStatus;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export interface ItemTranscription {
|
|
275
|
+
id?: string;
|
|
276
|
+
type: ItemType;
|
|
277
|
+
transcription?: TranscriptionPart[];
|
|
278
|
+
status: ItemStatus;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface ItemReference {
|
|
282
|
+
id: string;
|
|
283
|
+
type?: ItemType;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// ---------------------------------------------------------------------------
|
|
287
|
+
// Web Search
|
|
288
|
+
// ---------------------------------------------------------------------------
|
|
289
|
+
|
|
290
|
+
export interface Action {
|
|
291
|
+
query: string;
|
|
292
|
+
type: ActionType;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface ItemFunctionWebSearch {
|
|
296
|
+
type: ItemType;
|
|
297
|
+
action?: Action;
|
|
298
|
+
status: ItemStatus;
|
|
299
|
+
id: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// ---------------------------------------------------------------------------
|
|
303
|
+
// Image Process
|
|
304
|
+
// ---------------------------------------------------------------------------
|
|
305
|
+
|
|
306
|
+
export interface ResponseImageProcessAction {
|
|
307
|
+
type: ResponseImageProcessType;
|
|
308
|
+
result_image_url?: string;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export interface ResponseImageProcessError {
|
|
312
|
+
message: string;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export interface ResponseImageProcessPointArgs {
|
|
316
|
+
image_index: number;
|
|
317
|
+
points: string;
|
|
318
|
+
draw_line: boolean;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export interface ResponseImageProcessGroundingArgs {
|
|
322
|
+
image_index: number;
|
|
323
|
+
bbox_str: string;
|
|
324
|
+
crop: boolean;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export interface ResponseImageProcessRotateArgs {
|
|
328
|
+
image_index: number;
|
|
329
|
+
degree: number;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export interface ResponseImageProcessZoomArgs {
|
|
333
|
+
image_index: number;
|
|
334
|
+
bbox_str: string;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export type ResponseImageProcessArgs =
|
|
338
|
+
| ResponseImageProcessPointArgs
|
|
339
|
+
| ResponseImageProcessGroundingArgs
|
|
340
|
+
| ResponseImageProcessRotateArgs
|
|
341
|
+
| ResponseImageProcessZoomArgs;
|
|
342
|
+
|
|
343
|
+
export interface ItemFunctionImageProcess {
|
|
344
|
+
type: ItemType;
|
|
345
|
+
action?: ResponseImageProcessAction;
|
|
346
|
+
arguments?: ResponseImageProcessArgs;
|
|
347
|
+
status: ItemStatus;
|
|
348
|
+
id: string;
|
|
349
|
+
error?: ResponseImageProcessError;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// ---------------------------------------------------------------------------
|
|
353
|
+
// Image Process Options (for tool config)
|
|
354
|
+
// ---------------------------------------------------------------------------
|
|
355
|
+
|
|
356
|
+
export interface ImageProcessPointOptions {
|
|
357
|
+
enabled?: boolean;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export interface ImageProcessGroundingOptions {
|
|
361
|
+
enabled?: boolean;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export interface ImageProcessZoomOptions {
|
|
365
|
+
enabled?: boolean;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export interface ImageProcessRotateOptions {
|
|
369
|
+
enabled?: boolean;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// ---------------------------------------------------------------------------
|
|
373
|
+
// MCP
|
|
374
|
+
// ---------------------------------------------------------------------------
|
|
375
|
+
|
|
376
|
+
export interface McpTool {
|
|
377
|
+
name: string;
|
|
378
|
+
description: string;
|
|
379
|
+
input_schema?: Record<string, unknown>;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export interface ItemFunctionMcpApprovalRequest {
|
|
383
|
+
type: ItemType;
|
|
384
|
+
server_label: string;
|
|
385
|
+
arguments: string;
|
|
386
|
+
name: string;
|
|
387
|
+
id?: string;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export interface ItemFunctionMcpApprovalResponse {
|
|
391
|
+
type: ItemType;
|
|
392
|
+
id?: string;
|
|
393
|
+
approve: boolean;
|
|
394
|
+
approval_request_id: string;
|
|
395
|
+
reason?: string;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export interface ItemFunctionMcpListTools {
|
|
399
|
+
type: ItemType;
|
|
400
|
+
server_label: string;
|
|
401
|
+
tools?: McpTool[];
|
|
402
|
+
id?: string;
|
|
403
|
+
error?: string;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export interface ItemFunctionMcpCall {
|
|
407
|
+
type: ItemType;
|
|
408
|
+
server_label: string;
|
|
409
|
+
approval_request_id?: string;
|
|
410
|
+
arguments: string;
|
|
411
|
+
error?: string;
|
|
412
|
+
name: string;
|
|
413
|
+
output?: string;
|
|
414
|
+
id?: string;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// ---------------------------------------------------------------------------
|
|
418
|
+
// Knowledge Search
|
|
419
|
+
// ---------------------------------------------------------------------------
|
|
420
|
+
|
|
421
|
+
export interface ItemFunctionKnowledgeSearch {
|
|
422
|
+
type: ItemType;
|
|
423
|
+
queries?: string[];
|
|
424
|
+
knowledge_resource_id: string;
|
|
425
|
+
status: ItemStatus;
|
|
426
|
+
id?: string;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// ---------------------------------------------------------------------------
|
|
430
|
+
// Doubao App
|
|
431
|
+
// ---------------------------------------------------------------------------
|
|
432
|
+
|
|
433
|
+
export interface DoubaoAppCallBlockOutputText {
|
|
434
|
+
id?: string;
|
|
435
|
+
type: DoubaoAppBlockType;
|
|
436
|
+
text: string;
|
|
437
|
+
status: ItemStatus;
|
|
438
|
+
parent_id?: string;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export interface DoubaoAppCallBlockReasoningText {
|
|
442
|
+
id?: string;
|
|
443
|
+
type: DoubaoAppBlockType;
|
|
444
|
+
text: string;
|
|
445
|
+
status: ItemStatus;
|
|
446
|
+
parent_id?: string;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export interface DoubaoAppSearchTextItem {
|
|
450
|
+
index?: number;
|
|
451
|
+
title?: string;
|
|
452
|
+
site_name?: string;
|
|
453
|
+
url?: string;
|
|
454
|
+
mobile_url?: string;
|
|
455
|
+
logo_url?: string;
|
|
456
|
+
cover_image?: CoverImage;
|
|
457
|
+
publish_time?: string;
|
|
458
|
+
freshness_info?: string;
|
|
459
|
+
summary?: string;
|
|
460
|
+
doc_id?: string;
|
|
461
|
+
doc_name?: string;
|
|
462
|
+
chunk_id?: number;
|
|
463
|
+
chunk_attachment?: Record<string, unknown>[];
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export interface DoubaoAppSearchResult {
|
|
467
|
+
type?: string;
|
|
468
|
+
search_result?: DoubaoAppSearchTextItem[];
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export interface DoubaoAppCallBlockSearch {
|
|
472
|
+
id?: string;
|
|
473
|
+
type: DoubaoAppBlockType;
|
|
474
|
+
status: ItemStatus;
|
|
475
|
+
parent_id?: string;
|
|
476
|
+
result?: DoubaoAppSearchResult;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export interface DoubaoAppCallBlockReasoningSearch {
|
|
480
|
+
id?: string;
|
|
481
|
+
type: DoubaoAppBlockType;
|
|
482
|
+
status: ItemStatus;
|
|
483
|
+
parent_id?: string;
|
|
484
|
+
result?: DoubaoAppSearchResult;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export type DoubaoAppCallBlock =
|
|
488
|
+
| DoubaoAppCallBlockOutputText
|
|
489
|
+
| DoubaoAppCallBlockReasoningText
|
|
490
|
+
| DoubaoAppCallBlockSearch
|
|
491
|
+
| DoubaoAppCallBlockReasoningSearch;
|
|
492
|
+
|
|
493
|
+
export interface ItemDoubaoAppCall {
|
|
494
|
+
id?: string;
|
|
495
|
+
type: ItemType;
|
|
496
|
+
feature?: string;
|
|
497
|
+
blocks?: DoubaoAppCallBlock[];
|
|
498
|
+
status: ItemStatus;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
export interface DoubaoAppFeature {
|
|
502
|
+
search?: ResponseDoubaoAppFeatureType;
|
|
503
|
+
summary?: ResponseDoubaoAppFeatureType;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// ---------------------------------------------------------------------------
|
|
507
|
+
// InputItem — discriminated union over `type`
|
|
508
|
+
// ---------------------------------------------------------------------------
|
|
509
|
+
|
|
510
|
+
export type InputItem =
|
|
511
|
+
| ItemEasyMessage
|
|
512
|
+
| ItemInputMessage
|
|
513
|
+
| ItemOutputMessage
|
|
514
|
+
| ItemFunctionToolCall
|
|
515
|
+
| ItemFunctionToolCallOutput
|
|
516
|
+
| ItemReasoning
|
|
517
|
+
| ItemReference
|
|
518
|
+
| ItemFunctionImageProcess
|
|
519
|
+
| ItemFunctionMcpApprovalRequest
|
|
520
|
+
| ItemFunctionMcpApprovalResponse
|
|
521
|
+
| ItemFunctionMcpListTools
|
|
522
|
+
| ItemFunctionMcpCall
|
|
523
|
+
| ItemFunctionWebSearch
|
|
524
|
+
| ItemFunctionKnowledgeSearch
|
|
525
|
+
| ItemDoubaoAppCall;
|
|
526
|
+
|
|
527
|
+
/** ResponsesInput can be a simple string or array of InputItem */
|
|
528
|
+
export type ResponsesInput = string | InputItem[];
|
|
529
|
+
|
|
530
|
+
// ---------------------------------------------------------------------------
|
|
531
|
+
// Output Items (what the model returns)
|
|
532
|
+
// ---------------------------------------------------------------------------
|
|
533
|
+
|
|
534
|
+
export type OutputItem =
|
|
535
|
+
| ItemOutputMessage
|
|
536
|
+
| ItemFunctionToolCall
|
|
537
|
+
| ItemReasoning
|
|
538
|
+
| ItemTranscription
|
|
539
|
+
| ItemFunctionWebSearch
|
|
540
|
+
| ItemFunctionImageProcess
|
|
541
|
+
| ItemFunctionMcpApprovalRequest
|
|
542
|
+
| ItemFunctionMcpListTools
|
|
543
|
+
| ItemFunctionMcpCall
|
|
544
|
+
| ItemFunctionKnowledgeSearch
|
|
545
|
+
| ItemDoubaoAppCall;
|
|
546
|
+
|
|
547
|
+
// ---------------------------------------------------------------------------
|
|
548
|
+
// Tools
|
|
549
|
+
// ---------------------------------------------------------------------------
|
|
550
|
+
|
|
551
|
+
export interface ToolFunction {
|
|
552
|
+
name: string;
|
|
553
|
+
strict?: boolean;
|
|
554
|
+
type: ToolType;
|
|
555
|
+
description?: string;
|
|
556
|
+
/** JSON schema describing the function parameters */
|
|
557
|
+
parameters?: Record<string, unknown>;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export interface UserLocation {
|
|
561
|
+
type: UserLocationType;
|
|
562
|
+
city?: string;
|
|
563
|
+
country?: string;
|
|
564
|
+
region?: string;
|
|
565
|
+
timezone?: string;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
export interface ToolWebSearch {
|
|
569
|
+
type: ToolType;
|
|
570
|
+
limit?: number;
|
|
571
|
+
user_location?: UserLocation;
|
|
572
|
+
sources?: SourceType[];
|
|
573
|
+
max_keyword?: number;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export interface ToolImageProcess {
|
|
577
|
+
type: ToolType;
|
|
578
|
+
point?: ImageProcessPointOptions;
|
|
579
|
+
grounding?: ImageProcessGroundingOptions;
|
|
580
|
+
zoom?: ImageProcessZoomOptions;
|
|
581
|
+
rotate?: ImageProcessRotateOptions;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export interface McpAllowedToolsFilter {
|
|
585
|
+
tool_names: string[];
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/** allowed_tools can be string[] (list) or {tool_names: string[]} (filter) */
|
|
589
|
+
export type McpAllowedTools = string[] | McpAllowedToolsFilter;
|
|
590
|
+
|
|
591
|
+
export interface McpToolApprovalFilterAlways {
|
|
592
|
+
tool_names?: string[];
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
export interface McpToolApprovalFilterNever {
|
|
596
|
+
tool_names?: string[];
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export interface McpToolApprovalFilter {
|
|
600
|
+
always?: McpToolApprovalFilterAlways;
|
|
601
|
+
never?: McpToolApprovalFilterNever;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/** require_approval can be a mode string ("always"|"never") or a filter object */
|
|
605
|
+
export type McpRequireApproval = ApprovalMode | McpToolApprovalFilter;
|
|
606
|
+
|
|
607
|
+
export interface ToolMcp {
|
|
608
|
+
type: ToolType;
|
|
609
|
+
server_label: string;
|
|
610
|
+
server_url: string;
|
|
611
|
+
allowed_tools?: McpAllowedTools;
|
|
612
|
+
headers?: Record<string, string>;
|
|
613
|
+
require_approval?: McpRequireApproval;
|
|
614
|
+
server_description?: string;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export interface ToolKnowledgeSearch {
|
|
618
|
+
type: ToolType;
|
|
619
|
+
knowledge_resource_id: string;
|
|
620
|
+
description?: string;
|
|
621
|
+
limit?: number;
|
|
622
|
+
dense_weight?: number;
|
|
623
|
+
doc_filter?: Record<string, unknown>;
|
|
624
|
+
ranking_options?: Record<string, unknown>;
|
|
625
|
+
max_keyword?: number;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
export interface ToolDoubaoApp {
|
|
629
|
+
type: ToolType;
|
|
630
|
+
feature?: DoubaoAppFeature;
|
|
631
|
+
user_location?: UserLocation;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
export type ResponsesTool =
|
|
635
|
+
| ToolFunction
|
|
636
|
+
| ToolWebSearch
|
|
637
|
+
| ToolImageProcess
|
|
638
|
+
| ToolMcp
|
|
639
|
+
| ToolKnowledgeSearch
|
|
640
|
+
| ToolDoubaoApp;
|
|
641
|
+
|
|
642
|
+
// ---------------------------------------------------------------------------
|
|
643
|
+
// Tool Choice
|
|
644
|
+
// ---------------------------------------------------------------------------
|
|
645
|
+
|
|
646
|
+
export interface FunctionToolChoice {
|
|
647
|
+
type: ToolType;
|
|
648
|
+
name: string;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
export interface McpToolChoice {
|
|
652
|
+
type: ToolType;
|
|
653
|
+
server_label: string;
|
|
654
|
+
name?: string;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
export interface WebSearchToolChoice {
|
|
658
|
+
type: ToolType;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
export interface KnowledgeSearchToolChoice {
|
|
662
|
+
type: ToolType;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/** tool_choice can be a mode string or a specific tool choice object */
|
|
666
|
+
export type ResponsesToolChoice =
|
|
667
|
+
| ToolChoiceMode
|
|
668
|
+
| FunctionToolChoice
|
|
669
|
+
| McpToolChoice
|
|
670
|
+
| WebSearchToolChoice
|
|
671
|
+
| KnowledgeSearchToolChoice;
|
|
672
|
+
|
|
673
|
+
// ---------------------------------------------------------------------------
|
|
674
|
+
// Thinking / Reasoning / Caching / Text
|
|
675
|
+
// ---------------------------------------------------------------------------
|
|
676
|
+
|
|
677
|
+
export interface ResponsesThinking {
|
|
678
|
+
type?: ThinkingType;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
export interface ResponsesReasoning {
|
|
682
|
+
effort: ReasoningEffort;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
export interface ResponsesCaching {
|
|
686
|
+
type?: CacheType;
|
|
687
|
+
prefix?: boolean;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
export interface TextFormat {
|
|
691
|
+
type: TextType;
|
|
692
|
+
schema?: Record<string, unknown>;
|
|
693
|
+
name?: string;
|
|
694
|
+
description?: string;
|
|
695
|
+
strict?: boolean;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
export interface ResponsesText {
|
|
699
|
+
format?: TextFormat;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// ---------------------------------------------------------------------------
|
|
703
|
+
// Context Management (matches Go contextmanagement package)
|
|
704
|
+
// ---------------------------------------------------------------------------
|
|
705
|
+
|
|
706
|
+
export interface ContextManagement {
|
|
707
|
+
truncation?: ResponsesTruncation;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
export interface ContextManagementResponse {
|
|
711
|
+
truncation?: ResponsesTruncation;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// ---------------------------------------------------------------------------
|
|
715
|
+
// ResponsesRequest — the main request body
|
|
716
|
+
// ---------------------------------------------------------------------------
|
|
717
|
+
|
|
718
|
+
export interface ResponsesRequest {
|
|
719
|
+
input?: ResponsesInput;
|
|
720
|
+
model: string;
|
|
721
|
+
max_output_tokens?: number;
|
|
722
|
+
previous_response_id?: string;
|
|
723
|
+
thinking?: ResponsesThinking;
|
|
724
|
+
service_tier?: ResponsesServiceTier;
|
|
725
|
+
store?: boolean;
|
|
726
|
+
stream?: boolean;
|
|
727
|
+
temperature?: number;
|
|
728
|
+
tools?: ResponsesTool[];
|
|
729
|
+
top_p?: number;
|
|
730
|
+
instructions?: string;
|
|
731
|
+
include?: IncludeType[];
|
|
732
|
+
caching?: ResponsesCaching;
|
|
733
|
+
text?: ResponsesText;
|
|
734
|
+
expire_at?: number;
|
|
735
|
+
tool_choice?: ResponsesToolChoice;
|
|
736
|
+
parallel_tool_calls?: boolean;
|
|
737
|
+
max_tool_calls?: number;
|
|
738
|
+
reasoning?: ResponsesReasoning;
|
|
739
|
+
context_management?: ContextManagement;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// ---------------------------------------------------------------------------
|
|
743
|
+
// ResponseObject — the main response
|
|
744
|
+
// ---------------------------------------------------------------------------
|
|
745
|
+
|
|
746
|
+
export interface ResponseObject {
|
|
747
|
+
created_at: number;
|
|
748
|
+
error?: Error;
|
|
749
|
+
id: string;
|
|
750
|
+
incomplete_details?: IncompleteDetails;
|
|
751
|
+
max_output_tokens?: number;
|
|
752
|
+
model: string;
|
|
753
|
+
object: ObjectType;
|
|
754
|
+
output: OutputItem[];
|
|
755
|
+
previous_response_id?: string;
|
|
756
|
+
thinking?: ResponsesThinking;
|
|
757
|
+
service_tier?: ResponsesServiceTier;
|
|
758
|
+
status: ResponseStatus;
|
|
759
|
+
temperature?: number;
|
|
760
|
+
tools?: ResponsesTool[];
|
|
761
|
+
top_p?: number;
|
|
762
|
+
usage?: Usage;
|
|
763
|
+
caching?: ResponsesCaching;
|
|
764
|
+
text?: ResponsesText;
|
|
765
|
+
instructions?: string;
|
|
766
|
+
store?: boolean;
|
|
767
|
+
expire_at?: number;
|
|
768
|
+
tool_choice?: ResponsesToolChoice;
|
|
769
|
+
parallel_tool_calls?: boolean;
|
|
770
|
+
max_tool_calls?: number;
|
|
771
|
+
reasoning?: ResponsesReasoning;
|
|
772
|
+
context_management?: ContextManagementResponse;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// ---------------------------------------------------------------------------
|
|
776
|
+
// Get / Delete / List requests
|
|
777
|
+
// ---------------------------------------------------------------------------
|
|
778
|
+
|
|
779
|
+
export interface GetResponseRequest {
|
|
780
|
+
include?: IncludeType[];
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export interface ListInputItemsRequest {
|
|
784
|
+
include?: IncludeType[];
|
|
785
|
+
limit?: number;
|
|
786
|
+
order?: "asc" | "desc";
|
|
787
|
+
after?: string;
|
|
788
|
+
before?: string;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
export interface ListInputItemsResponse {
|
|
792
|
+
object: ObjectType;
|
|
793
|
+
data: InputItem[];
|
|
794
|
+
first_id?: string;
|
|
795
|
+
last_id?: string;
|
|
796
|
+
has_more: boolean;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// ---------------------------------------------------------------------------
|
|
800
|
+
// Streaming Event types
|
|
801
|
+
// ---------------------------------------------------------------------------
|
|
802
|
+
|
|
803
|
+
export interface ResponseEvent {
|
|
804
|
+
type: EventType;
|
|
805
|
+
response: ResponseObject;
|
|
806
|
+
sequence_number: number;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
export interface ResponseInProgressEvent {
|
|
810
|
+
type: EventType;
|
|
811
|
+
response: ResponseObject;
|
|
812
|
+
sequence_number: number;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
export interface ResponseCompletedEvent {
|
|
816
|
+
type: EventType;
|
|
817
|
+
response: ResponseObject;
|
|
818
|
+
sequence_number: number;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
export interface ResponseFailedEvent {
|
|
822
|
+
type: EventType;
|
|
823
|
+
response: ResponseObject;
|
|
824
|
+
sequence_number: number;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
export interface ResponseIncompleteEvent {
|
|
828
|
+
type: EventType;
|
|
829
|
+
response: ResponseObject;
|
|
830
|
+
sequence_number: number;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
export interface ItemEvent {
|
|
834
|
+
type: EventType;
|
|
835
|
+
item: OutputItem;
|
|
836
|
+
output_index: number;
|
|
837
|
+
sequence_number: number;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
export interface ItemDoneEvent {
|
|
841
|
+
type: EventType;
|
|
842
|
+
item: OutputItem;
|
|
843
|
+
output_index: number;
|
|
844
|
+
sequence_number: number;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
export interface ContentPartEvent {
|
|
848
|
+
type: EventType;
|
|
849
|
+
part: OutputContentItem;
|
|
850
|
+
item_id: string;
|
|
851
|
+
output_index: number;
|
|
852
|
+
content_index: number;
|
|
853
|
+
sequence_number: number;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
export interface ContentPartDoneEvent {
|
|
857
|
+
type: EventType;
|
|
858
|
+
part: OutputContentItem;
|
|
859
|
+
item_id: string;
|
|
860
|
+
output_index: number;
|
|
861
|
+
content_index: number;
|
|
862
|
+
sequence_number: number;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
export interface OutputTextEvent {
|
|
866
|
+
type: EventType;
|
|
867
|
+
delta: string;
|
|
868
|
+
item_id: string;
|
|
869
|
+
output_index: number;
|
|
870
|
+
content_index: number;
|
|
871
|
+
sequence_number: number;
|
|
872
|
+
annotations?: Annotation[];
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
export interface OutputTextDoneEvent {
|
|
876
|
+
type: EventType;
|
|
877
|
+
text: string;
|
|
878
|
+
item_id: string;
|
|
879
|
+
output_index: number;
|
|
880
|
+
content_index: number;
|
|
881
|
+
sequence_number: number;
|
|
882
|
+
annotations?: Annotation[];
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
export interface ResponseAnnotationAddedEvent {
|
|
886
|
+
type: EventType;
|
|
887
|
+
annotation: Annotation;
|
|
888
|
+
item_id: string;
|
|
889
|
+
output_index: number;
|
|
890
|
+
content_index: number;
|
|
891
|
+
annotation_index: number;
|
|
892
|
+
sequence_number: number;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
export interface ReasoningSummaryPartEvent {
|
|
896
|
+
type: EventType;
|
|
897
|
+
part: ReasoningSummaryPart;
|
|
898
|
+
item_id: string;
|
|
899
|
+
output_index: number;
|
|
900
|
+
summary_index: number;
|
|
901
|
+
sequence_number: number;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
export interface ReasoningSummaryPartDoneEvent {
|
|
905
|
+
type: EventType;
|
|
906
|
+
part: ReasoningSummaryPart;
|
|
907
|
+
item_id: string;
|
|
908
|
+
output_index: number;
|
|
909
|
+
summary_index: number;
|
|
910
|
+
sequence_number: number;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
export interface ReasoningSummaryTextEvent {
|
|
914
|
+
type: EventType;
|
|
915
|
+
delta: string;
|
|
916
|
+
item_id: string;
|
|
917
|
+
output_index: number;
|
|
918
|
+
summary_index: number;
|
|
919
|
+
sequence_number: number;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
export interface ReasoningSummaryTextDoneEvent {
|
|
923
|
+
type: EventType;
|
|
924
|
+
text: string;
|
|
925
|
+
item_id: string;
|
|
926
|
+
output_index: number;
|
|
927
|
+
summary_index: number;
|
|
928
|
+
sequence_number: number;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
export interface FunctionCallArgumentsEvent {
|
|
932
|
+
type: EventType;
|
|
933
|
+
delta: string;
|
|
934
|
+
item_id: string;
|
|
935
|
+
output_index: number;
|
|
936
|
+
sequence_number: number;
|
|
937
|
+
call_id?: string;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
export interface FunctionCallArgumentsDoneEvent {
|
|
941
|
+
type: EventType;
|
|
942
|
+
arguments: string;
|
|
943
|
+
item_id: string;
|
|
944
|
+
output_index: number;
|
|
945
|
+
sequence_number: number;
|
|
946
|
+
call_id?: string;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
export interface TranscriptionPartEvent {
|
|
950
|
+
type: EventType;
|
|
951
|
+
part: TranscriptionPart;
|
|
952
|
+
item_id: string;
|
|
953
|
+
output_index: number;
|
|
954
|
+
content_index: number;
|
|
955
|
+
sequence_number: number;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
export interface TranscriptionPartDoneEvent {
|
|
959
|
+
type: EventType;
|
|
960
|
+
part: TranscriptionPart;
|
|
961
|
+
item_id: string;
|
|
962
|
+
output_index: number;
|
|
963
|
+
content_index: number;
|
|
964
|
+
sequence_number: number;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
export interface TranscriptionTextEvent {
|
|
968
|
+
type: EventType;
|
|
969
|
+
delta: string;
|
|
970
|
+
item_id: string;
|
|
971
|
+
output_index: number;
|
|
972
|
+
content_index: number;
|
|
973
|
+
sequence_number: number;
|
|
974
|
+
chunks?: AudioChunk[];
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
export interface TranscriptionTextDoneEvent {
|
|
978
|
+
type: EventType;
|
|
979
|
+
text: string;
|
|
980
|
+
item_id: string;
|
|
981
|
+
output_index: number;
|
|
982
|
+
content_index: number;
|
|
983
|
+
sequence_number: number;
|
|
984
|
+
chunks?: AudioChunk[];
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
export interface ErrorEvent {
|
|
988
|
+
type: EventType;
|
|
989
|
+
message: string;
|
|
990
|
+
code?: string;
|
|
991
|
+
sequence_number: number;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// ---------------------------------------------------------------------------
|
|
995
|
+
// Web Search Events
|
|
996
|
+
// ---------------------------------------------------------------------------
|
|
997
|
+
|
|
998
|
+
export interface ResponseWebSearchCallInProgressEvent {
|
|
999
|
+
type: EventType;
|
|
1000
|
+
item_id: string;
|
|
1001
|
+
output_index: number;
|
|
1002
|
+
sequence_number: number;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
export interface ResponseWebSearchCallSearchingEvent {
|
|
1006
|
+
type: EventType;
|
|
1007
|
+
item_id: string;
|
|
1008
|
+
output_index: number;
|
|
1009
|
+
sequence_number: number;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
export interface ResponseWebSearchCallCompletedEvent {
|
|
1013
|
+
type: EventType;
|
|
1014
|
+
item_id: string;
|
|
1015
|
+
output_index: number;
|
|
1016
|
+
sequence_number: number;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// ---------------------------------------------------------------------------
|
|
1020
|
+
// Image Process Events
|
|
1021
|
+
// ---------------------------------------------------------------------------
|
|
1022
|
+
|
|
1023
|
+
export interface ResponseImageProcessCallInProgressEvent {
|
|
1024
|
+
type: EventType;
|
|
1025
|
+
item_id: string;
|
|
1026
|
+
output_index: number;
|
|
1027
|
+
sequence_number: number;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
export interface ResponseImageProcessCallProcessingEvent {
|
|
1031
|
+
type: EventType;
|
|
1032
|
+
item_id: string;
|
|
1033
|
+
output_index: number;
|
|
1034
|
+
sequence_number: number;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
export interface ResponseImageProcessCallCompletedEvent {
|
|
1038
|
+
type: EventType;
|
|
1039
|
+
item_id: string;
|
|
1040
|
+
output_index: number;
|
|
1041
|
+
sequence_number: number;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
export interface ResponseImageProcessCallFailedEvent {
|
|
1045
|
+
type: EventType;
|
|
1046
|
+
item_id: string;
|
|
1047
|
+
output_index: number;
|
|
1048
|
+
sequence_number: number;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// ---------------------------------------------------------------------------
|
|
1052
|
+
// MCP Events
|
|
1053
|
+
// ---------------------------------------------------------------------------
|
|
1054
|
+
|
|
1055
|
+
export interface ResponseMcpListToolsInProgressEvent {
|
|
1056
|
+
type: EventType;
|
|
1057
|
+
item_id: string;
|
|
1058
|
+
output_index: number;
|
|
1059
|
+
sequence_number: number;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
export interface ResponseMcpListToolsCompletedEvent {
|
|
1063
|
+
type: EventType;
|
|
1064
|
+
item_id: string;
|
|
1065
|
+
output_index: number;
|
|
1066
|
+
sequence_number: number;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
export interface ResponseMcpCallInProgressEvent {
|
|
1070
|
+
type: EventType;
|
|
1071
|
+
item_id: string;
|
|
1072
|
+
output_index: number;
|
|
1073
|
+
sequence_number: number;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
export interface ResponseMcpCallArgumentsDeltaEvent {
|
|
1077
|
+
type: EventType;
|
|
1078
|
+
delta: string;
|
|
1079
|
+
item_id: string;
|
|
1080
|
+
output_index: number;
|
|
1081
|
+
sequence_number: number;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
export interface ResponseMcpCallArgumentsDoneEvent {
|
|
1085
|
+
type: EventType;
|
|
1086
|
+
arguments: string;
|
|
1087
|
+
item_id: string;
|
|
1088
|
+
output_index: number;
|
|
1089
|
+
sequence_number: number;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
export interface ResponseMcpCallCompletedEvent {
|
|
1093
|
+
type: EventType;
|
|
1094
|
+
item_id: string;
|
|
1095
|
+
output_index: number;
|
|
1096
|
+
sequence_number: number;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
export interface ResponseMcpCallFailedEvent {
|
|
1100
|
+
type: EventType;
|
|
1101
|
+
item_id: string;
|
|
1102
|
+
output_index: number;
|
|
1103
|
+
sequence_number: number;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
export interface ResponseMcpApprovalRequestEvent {
|
|
1107
|
+
type: EventType;
|
|
1108
|
+
item_id: string;
|
|
1109
|
+
output_index: number;
|
|
1110
|
+
sequence_number: number;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// ---------------------------------------------------------------------------
|
|
1114
|
+
// Knowledge Search Events
|
|
1115
|
+
// ---------------------------------------------------------------------------
|
|
1116
|
+
|
|
1117
|
+
export interface ResponseKnowledgeSearchCallInProgressEvent {
|
|
1118
|
+
type: EventType;
|
|
1119
|
+
item_id: string;
|
|
1120
|
+
output_index: number;
|
|
1121
|
+
sequence_number: number;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
export interface ResponseKnowledgeSearchCallSearchingEvent {
|
|
1125
|
+
type: EventType;
|
|
1126
|
+
item_id: string;
|
|
1127
|
+
output_index: number;
|
|
1128
|
+
sequence_number: number;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
export interface ResponseKnowledgeSearchCallCompletedEvent {
|
|
1132
|
+
type: EventType;
|
|
1133
|
+
item_id: string;
|
|
1134
|
+
output_index: number;
|
|
1135
|
+
sequence_number: number;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
export interface ResponseKnowledgeSearchCallFailedEvent {
|
|
1139
|
+
type: EventType;
|
|
1140
|
+
item_id: string;
|
|
1141
|
+
output_index: number;
|
|
1142
|
+
sequence_number: number;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
// ---------------------------------------------------------------------------
|
|
1146
|
+
// Doubao App Events
|
|
1147
|
+
// ---------------------------------------------------------------------------
|
|
1148
|
+
|
|
1149
|
+
export interface ResponseDoubaoAppCallInProgressEvent {
|
|
1150
|
+
type: EventType;
|
|
1151
|
+
item_id: string;
|
|
1152
|
+
output_index: number;
|
|
1153
|
+
sequence_number: number;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
export interface ResponseDoubaoAppCallFailedEvent {
|
|
1157
|
+
type: EventType;
|
|
1158
|
+
item_id: string;
|
|
1159
|
+
output_index: number;
|
|
1160
|
+
sequence_number: number;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
export interface ResponseDoubaoAppCallCompletedEvent {
|
|
1164
|
+
type: EventType;
|
|
1165
|
+
item_id: string;
|
|
1166
|
+
output_index: number;
|
|
1167
|
+
sequence_number: number;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
export interface ResponseDoubaoAppCallBlockAddedEvent {
|
|
1171
|
+
type: EventType;
|
|
1172
|
+
block: DoubaoAppCallBlock;
|
|
1173
|
+
item_id: string;
|
|
1174
|
+
output_index: number;
|
|
1175
|
+
sequence_number: number;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
export interface ResponseDoubaoAppCallBlockDoneEvent {
|
|
1179
|
+
type: EventType;
|
|
1180
|
+
block: DoubaoAppCallBlock;
|
|
1181
|
+
item_id: string;
|
|
1182
|
+
output_index: number;
|
|
1183
|
+
sequence_number: number;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
export interface ResponseDoubaoAppCallReasoningTextDeltaEvent {
|
|
1187
|
+
type: EventType;
|
|
1188
|
+
delta: string;
|
|
1189
|
+
item_id: string;
|
|
1190
|
+
output_index: number;
|
|
1191
|
+
block_index: number;
|
|
1192
|
+
sequence_number: number;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
export interface ResponseDoubaoAppCallReasoningTextDoneEvent {
|
|
1196
|
+
type: EventType;
|
|
1197
|
+
text: string;
|
|
1198
|
+
item_id: string;
|
|
1199
|
+
output_index: number;
|
|
1200
|
+
block_index: number;
|
|
1201
|
+
sequence_number: number;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
export interface ResponseDoubaoAppCallOutputTextDeltaEvent {
|
|
1205
|
+
type: EventType;
|
|
1206
|
+
delta: string;
|
|
1207
|
+
item_id: string;
|
|
1208
|
+
output_index: number;
|
|
1209
|
+
block_index: number;
|
|
1210
|
+
sequence_number: number;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
export interface ResponseDoubaoAppCallOutputTextDoneEvent {
|
|
1214
|
+
type: EventType;
|
|
1215
|
+
text: string;
|
|
1216
|
+
item_id: string;
|
|
1217
|
+
output_index: number;
|
|
1218
|
+
block_index: number;
|
|
1219
|
+
sequence_number: number;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
export interface ResponseDoubaoAppCallReasoningSearchInProgressEvent {
|
|
1223
|
+
type: EventType;
|
|
1224
|
+
item_id: string;
|
|
1225
|
+
output_index: number;
|
|
1226
|
+
block_index: number;
|
|
1227
|
+
sequence_number: number;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
export interface ResponseDoubaoAppCallReasoningSearchSearchingEvent {
|
|
1231
|
+
type: EventType;
|
|
1232
|
+
item_id: string;
|
|
1233
|
+
output_index: number;
|
|
1234
|
+
block_index: number;
|
|
1235
|
+
sequence_number: number;
|
|
1236
|
+
search_result?: DoubaoAppSearchTextItem[];
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
export interface ResponseDoubaoAppCallReasoningSearchCompletedEvent {
|
|
1240
|
+
type: EventType;
|
|
1241
|
+
item_id: string;
|
|
1242
|
+
output_index: number;
|
|
1243
|
+
block_index: number;
|
|
1244
|
+
sequence_number: number;
|
|
1245
|
+
search_result?: DoubaoAppSearchTextItem[];
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
export interface ResponseDoubaoAppCallSearchInProgressEvent {
|
|
1249
|
+
type: EventType;
|
|
1250
|
+
item_id: string;
|
|
1251
|
+
output_index: number;
|
|
1252
|
+
block_index: number;
|
|
1253
|
+
sequence_number: number;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
export interface ResponseDoubaoAppCallSearchSearchingEvent {
|
|
1257
|
+
type: EventType;
|
|
1258
|
+
item_id: string;
|
|
1259
|
+
output_index: number;
|
|
1260
|
+
block_index: number;
|
|
1261
|
+
sequence_number: number;
|
|
1262
|
+
search_result?: DoubaoAppSearchTextItem[];
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
export interface ResponseDoubaoAppCallSearchCompletedEvent {
|
|
1266
|
+
type: EventType;
|
|
1267
|
+
item_id: string;
|
|
1268
|
+
output_index: number;
|
|
1269
|
+
block_index: number;
|
|
1270
|
+
sequence_number: number;
|
|
1271
|
+
search_result?: DoubaoAppSearchTextItem[];
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
// ---------------------------------------------------------------------------
|
|
1275
|
+
// Event — the top-level streaming event (discriminated by `type`)
|
|
1276
|
+
// ---------------------------------------------------------------------------
|
|
1277
|
+
|
|
1278
|
+
export type Event =
|
|
1279
|
+
| ResponseEvent
|
|
1280
|
+
| ResponseInProgressEvent
|
|
1281
|
+
| ResponseCompletedEvent
|
|
1282
|
+
| ResponseFailedEvent
|
|
1283
|
+
| ResponseIncompleteEvent
|
|
1284
|
+
| ItemEvent
|
|
1285
|
+
| ItemDoneEvent
|
|
1286
|
+
| ContentPartEvent
|
|
1287
|
+
| ContentPartDoneEvent
|
|
1288
|
+
| OutputTextEvent
|
|
1289
|
+
| OutputTextDoneEvent
|
|
1290
|
+
| ResponseAnnotationAddedEvent
|
|
1291
|
+
| ReasoningSummaryPartEvent
|
|
1292
|
+
| ReasoningSummaryPartDoneEvent
|
|
1293
|
+
| ReasoningSummaryTextEvent
|
|
1294
|
+
| ReasoningSummaryTextDoneEvent
|
|
1295
|
+
| FunctionCallArgumentsEvent
|
|
1296
|
+
| FunctionCallArgumentsDoneEvent
|
|
1297
|
+
| TranscriptionPartEvent
|
|
1298
|
+
| TranscriptionPartDoneEvent
|
|
1299
|
+
| TranscriptionTextEvent
|
|
1300
|
+
| TranscriptionTextDoneEvent
|
|
1301
|
+
| ErrorEvent
|
|
1302
|
+
| ResponseWebSearchCallInProgressEvent
|
|
1303
|
+
| ResponseWebSearchCallSearchingEvent
|
|
1304
|
+
| ResponseWebSearchCallCompletedEvent
|
|
1305
|
+
| ResponseImageProcessCallInProgressEvent
|
|
1306
|
+
| ResponseImageProcessCallProcessingEvent
|
|
1307
|
+
| ResponseImageProcessCallCompletedEvent
|
|
1308
|
+
| ResponseImageProcessCallFailedEvent
|
|
1309
|
+
| ResponseMcpListToolsInProgressEvent
|
|
1310
|
+
| ResponseMcpListToolsCompletedEvent
|
|
1311
|
+
| ResponseMcpCallInProgressEvent
|
|
1312
|
+
| ResponseMcpCallArgumentsDeltaEvent
|
|
1313
|
+
| ResponseMcpCallArgumentsDoneEvent
|
|
1314
|
+
| ResponseMcpCallCompletedEvent
|
|
1315
|
+
| ResponseMcpCallFailedEvent
|
|
1316
|
+
| ResponseMcpApprovalRequestEvent
|
|
1317
|
+
| ResponseKnowledgeSearchCallInProgressEvent
|
|
1318
|
+
| ResponseKnowledgeSearchCallSearchingEvent
|
|
1319
|
+
| ResponseKnowledgeSearchCallCompletedEvent
|
|
1320
|
+
| ResponseKnowledgeSearchCallFailedEvent
|
|
1321
|
+
| ResponseDoubaoAppCallInProgressEvent
|
|
1322
|
+
| ResponseDoubaoAppCallFailedEvent
|
|
1323
|
+
| ResponseDoubaoAppCallCompletedEvent
|
|
1324
|
+
| ResponseDoubaoAppCallBlockAddedEvent
|
|
1325
|
+
| ResponseDoubaoAppCallBlockDoneEvent
|
|
1326
|
+
| ResponseDoubaoAppCallReasoningTextDeltaEvent
|
|
1327
|
+
| ResponseDoubaoAppCallReasoningTextDoneEvent
|
|
1328
|
+
| ResponseDoubaoAppCallOutputTextDeltaEvent
|
|
1329
|
+
| ResponseDoubaoAppCallOutputTextDoneEvent
|
|
1330
|
+
| ResponseDoubaoAppCallSearchInProgressEvent
|
|
1331
|
+
| ResponseDoubaoAppCallSearchSearchingEvent
|
|
1332
|
+
| ResponseDoubaoAppCallSearchCompletedEvent
|
|
1333
|
+
| ResponseDoubaoAppCallReasoningSearchInProgressEvent
|
|
1334
|
+
| ResponseDoubaoAppCallReasoningSearchSearchingEvent
|
|
1335
|
+
| ResponseDoubaoAppCallReasoningSearchCompletedEvent;
|