@302ai/media-studio-core 0.1.0-beta.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.
@@ -0,0 +1,375 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Creation provenance of a session: which kind of client provisioned it.
4
+ * The upstream database is backfilled with `web` as the default, so the
5
+ * field is always present on stored sessions.
6
+ */
7
+ export declare const SessionSourceSchema: z.ZodEnum<{
8
+ cli: "cli";
9
+ web: "web";
10
+ }>;
11
+ export type SessionSource = z.infer<typeof SessionSourceSchema>;
12
+ declare const SessionListItemSchema: z.ZodPipe<z.ZodObject<{
13
+ id: z.ZodOptional<z.ZodString>;
14
+ sessionId: z.ZodOptional<z.ZodString>;
15
+ session_id: z.ZodOptional<z.ZodString>;
16
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
+ titleCustomized: z.ZodOptional<z.ZodBoolean>;
18
+ title_customized: z.ZodOptional<z.ZodBoolean>;
19
+ lastActiveAt: z.ZodOptional<z.ZodString>;
20
+ last_active_at: z.ZodOptional<z.ZodString>;
21
+ pinnedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ pinned_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
23
+ createdAt: z.ZodOptional<z.ZodString>;
24
+ created_at: z.ZodOptional<z.ZodString>;
25
+ source: z.ZodOptional<z.ZodEnum<{
26
+ cli: "cli";
27
+ web: "web";
28
+ }>>;
29
+ status: z.ZodOptional<z.ZodObject<{
30
+ chat: z.ZodBoolean;
31
+ task: z.ZodBoolean;
32
+ }, z.core.$strip>>;
33
+ chatTasks: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodObject<{
34
+ id: z.ZodOptional<z.ZodString>;
35
+ chatTaskId: z.ZodOptional<z.ZodString>;
36
+ chat_task_id: z.ZodOptional<z.ZodString>;
37
+ parentChatTaskId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
38
+ parent_chat_task_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
39
+ resultChildChatTaskId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
40
+ result_child_chat_task_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
+ status: z.ZodEnum<{
42
+ cancelled: "cancelled";
43
+ completed: "completed";
44
+ failed: "failed";
45
+ pending: "pending";
46
+ processing: "processing";
47
+ running: "running";
48
+ }>;
49
+ }, z.core.$strip>, z.ZodTransform<{
50
+ id: string;
51
+ chatTaskId: string;
52
+ parentChatTaskId: string | null;
53
+ resultChildChatTaskId: string | null;
54
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
55
+ }, {
56
+ id?: string | undefined;
57
+ chatTaskId?: string | undefined;
58
+ chat_task_id?: string | undefined;
59
+ parentChatTaskId?: string | null | undefined;
60
+ parent_chat_task_id?: string | null | undefined;
61
+ resultChildChatTaskId?: string | null | undefined;
62
+ result_child_chat_task_id?: string | null | undefined;
63
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
64
+ }>>>>;
65
+ chat_tasks: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodObject<{
66
+ id: z.ZodOptional<z.ZodString>;
67
+ chatTaskId: z.ZodOptional<z.ZodString>;
68
+ chat_task_id: z.ZodOptional<z.ZodString>;
69
+ parentChatTaskId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
70
+ parent_chat_task_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
+ resultChildChatTaskId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ result_child_chat_task_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
73
+ status: z.ZodEnum<{
74
+ cancelled: "cancelled";
75
+ completed: "completed";
76
+ failed: "failed";
77
+ pending: "pending";
78
+ processing: "processing";
79
+ running: "running";
80
+ }>;
81
+ }, z.core.$strip>, z.ZodTransform<{
82
+ id: string;
83
+ chatTaskId: string;
84
+ parentChatTaskId: string | null;
85
+ resultChildChatTaskId: string | null;
86
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
87
+ }, {
88
+ id?: string | undefined;
89
+ chatTaskId?: string | undefined;
90
+ chat_task_id?: string | undefined;
91
+ parentChatTaskId?: string | null | undefined;
92
+ parent_chat_task_id?: string | null | undefined;
93
+ resultChildChatTaskId?: string | null | undefined;
94
+ result_child_chat_task_id?: string | null | undefined;
95
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
96
+ }>>>>;
97
+ ai302TaskCount: z.ZodOptional<z.ZodCatch<z.ZodNullable<z.ZodNumber>>>;
98
+ ai302_task_count: z.ZodOptional<z.ZodCatch<z.ZodNullable<z.ZodNumber>>>;
99
+ }, z.core.$strip>, z.ZodTransform<{
100
+ id: string;
101
+ sessionId: string;
102
+ note: string | null;
103
+ titleCustomized: boolean;
104
+ lastActiveAt: string;
105
+ pinnedAt: string | null;
106
+ createdAt: string;
107
+ source: "cli" | "web";
108
+ status: {
109
+ chat: boolean;
110
+ task: boolean;
111
+ };
112
+ chatTasks: {
113
+ id: string;
114
+ chatTaskId: string;
115
+ parentChatTaskId: string | null;
116
+ resultChildChatTaskId: string | null;
117
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
118
+ }[];
119
+ ai302TaskCount: number | null;
120
+ }, {
121
+ id?: string | undefined;
122
+ sessionId?: string | undefined;
123
+ session_id?: string | undefined;
124
+ note?: string | null | undefined;
125
+ titleCustomized?: boolean | undefined;
126
+ title_customized?: boolean | undefined;
127
+ lastActiveAt?: string | undefined;
128
+ last_active_at?: string | undefined;
129
+ pinnedAt?: string | null | undefined;
130
+ pinned_at?: string | null | undefined;
131
+ createdAt?: string | undefined;
132
+ created_at?: string | undefined;
133
+ source?: "cli" | "web" | undefined;
134
+ status?: {
135
+ chat: boolean;
136
+ task: boolean;
137
+ } | undefined;
138
+ chatTasks?: {
139
+ id: string;
140
+ chatTaskId: string;
141
+ parentChatTaskId: string | null;
142
+ resultChildChatTaskId: string | null;
143
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
144
+ }[] | undefined;
145
+ chat_tasks?: {
146
+ id: string;
147
+ chatTaskId: string;
148
+ parentChatTaskId: string | null;
149
+ resultChildChatTaskId: string | null;
150
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
151
+ }[] | undefined;
152
+ ai302TaskCount?: number | null | undefined;
153
+ ai302_task_count?: number | null | undefined;
154
+ }>>;
155
+ export type SessionListItem = z.infer<typeof SessionListItemSchema>;
156
+ export declare const ListSessionsQuerySchema: z.ZodObject<{
157
+ limit: z.ZodOptional<z.ZodNumber>;
158
+ offset: z.ZodOptional<z.ZodNumber>;
159
+ note: z.ZodOptional<z.ZodString>;
160
+ }, z.core.$strip>;
161
+ export type ListSessionsQuery = z.input<typeof ListSessionsQuerySchema>;
162
+ export declare const ListSessionsResponseSchema: z.ZodObject<{
163
+ success: z.ZodBoolean;
164
+ error: z.ZodOptional<z.ZodObject<{
165
+ message: z.ZodString;
166
+ code: z.ZodOptional<z.ZodString>;
167
+ }, z.core.$strip>>;
168
+ data: z.ZodArray<z.ZodPipe<z.ZodObject<{
169
+ id: z.ZodOptional<z.ZodString>;
170
+ sessionId: z.ZodOptional<z.ZodString>;
171
+ session_id: z.ZodOptional<z.ZodString>;
172
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
173
+ titleCustomized: z.ZodOptional<z.ZodBoolean>;
174
+ title_customized: z.ZodOptional<z.ZodBoolean>;
175
+ lastActiveAt: z.ZodOptional<z.ZodString>;
176
+ last_active_at: z.ZodOptional<z.ZodString>;
177
+ pinnedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
178
+ pinned_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
179
+ createdAt: z.ZodOptional<z.ZodString>;
180
+ created_at: z.ZodOptional<z.ZodString>;
181
+ source: z.ZodOptional<z.ZodEnum<{
182
+ cli: "cli";
183
+ web: "web";
184
+ }>>;
185
+ status: z.ZodOptional<z.ZodObject<{
186
+ chat: z.ZodBoolean;
187
+ task: z.ZodBoolean;
188
+ }, z.core.$strip>>;
189
+ chatTasks: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodObject<{
190
+ id: z.ZodOptional<z.ZodString>;
191
+ chatTaskId: z.ZodOptional<z.ZodString>;
192
+ chat_task_id: z.ZodOptional<z.ZodString>;
193
+ parentChatTaskId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
194
+ parent_chat_task_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
195
+ resultChildChatTaskId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
196
+ result_child_chat_task_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
197
+ status: z.ZodEnum<{
198
+ cancelled: "cancelled";
199
+ completed: "completed";
200
+ failed: "failed";
201
+ pending: "pending";
202
+ processing: "processing";
203
+ running: "running";
204
+ }>;
205
+ }, z.core.$strip>, z.ZodTransform<{
206
+ id: string;
207
+ chatTaskId: string;
208
+ parentChatTaskId: string | null;
209
+ resultChildChatTaskId: string | null;
210
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
211
+ }, {
212
+ id?: string | undefined;
213
+ chatTaskId?: string | undefined;
214
+ chat_task_id?: string | undefined;
215
+ parentChatTaskId?: string | null | undefined;
216
+ parent_chat_task_id?: string | null | undefined;
217
+ resultChildChatTaskId?: string | null | undefined;
218
+ result_child_chat_task_id?: string | null | undefined;
219
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
220
+ }>>>>;
221
+ chat_tasks: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodObject<{
222
+ id: z.ZodOptional<z.ZodString>;
223
+ chatTaskId: z.ZodOptional<z.ZodString>;
224
+ chat_task_id: z.ZodOptional<z.ZodString>;
225
+ parentChatTaskId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
226
+ parent_chat_task_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
227
+ resultChildChatTaskId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
228
+ result_child_chat_task_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
229
+ status: z.ZodEnum<{
230
+ cancelled: "cancelled";
231
+ completed: "completed";
232
+ failed: "failed";
233
+ pending: "pending";
234
+ processing: "processing";
235
+ running: "running";
236
+ }>;
237
+ }, z.core.$strip>, z.ZodTransform<{
238
+ id: string;
239
+ chatTaskId: string;
240
+ parentChatTaskId: string | null;
241
+ resultChildChatTaskId: string | null;
242
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
243
+ }, {
244
+ id?: string | undefined;
245
+ chatTaskId?: string | undefined;
246
+ chat_task_id?: string | undefined;
247
+ parentChatTaskId?: string | null | undefined;
248
+ parent_chat_task_id?: string | null | undefined;
249
+ resultChildChatTaskId?: string | null | undefined;
250
+ result_child_chat_task_id?: string | null | undefined;
251
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
252
+ }>>>>;
253
+ ai302TaskCount: z.ZodOptional<z.ZodCatch<z.ZodNullable<z.ZodNumber>>>;
254
+ ai302_task_count: z.ZodOptional<z.ZodCatch<z.ZodNullable<z.ZodNumber>>>;
255
+ }, z.core.$strip>, z.ZodTransform<{
256
+ id: string;
257
+ sessionId: string;
258
+ note: string | null;
259
+ titleCustomized: boolean;
260
+ lastActiveAt: string;
261
+ pinnedAt: string | null;
262
+ createdAt: string;
263
+ source: "cli" | "web";
264
+ status: {
265
+ chat: boolean;
266
+ task: boolean;
267
+ };
268
+ chatTasks: {
269
+ id: string;
270
+ chatTaskId: string;
271
+ parentChatTaskId: string | null;
272
+ resultChildChatTaskId: string | null;
273
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
274
+ }[];
275
+ ai302TaskCount: number | null;
276
+ }, {
277
+ id?: string | undefined;
278
+ sessionId?: string | undefined;
279
+ session_id?: string | undefined;
280
+ note?: string | null | undefined;
281
+ titleCustomized?: boolean | undefined;
282
+ title_customized?: boolean | undefined;
283
+ lastActiveAt?: string | undefined;
284
+ last_active_at?: string | undefined;
285
+ pinnedAt?: string | null | undefined;
286
+ pinned_at?: string | null | undefined;
287
+ createdAt?: string | undefined;
288
+ created_at?: string | undefined;
289
+ source?: "cli" | "web" | undefined;
290
+ status?: {
291
+ chat: boolean;
292
+ task: boolean;
293
+ } | undefined;
294
+ chatTasks?: {
295
+ id: string;
296
+ chatTaskId: string;
297
+ parentChatTaskId: string | null;
298
+ resultChildChatTaskId: string | null;
299
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
300
+ }[] | undefined;
301
+ chat_tasks?: {
302
+ id: string;
303
+ chatTaskId: string;
304
+ parentChatTaskId: string | null;
305
+ resultChildChatTaskId: string | null;
306
+ status: "cancelled" | "completed" | "failed" | "pending" | "processing" | "running";
307
+ }[] | undefined;
308
+ ai302TaskCount?: number | null | undefined;
309
+ ai302_task_count?: number | null | undefined;
310
+ }>>>;
311
+ }, z.core.$strip>;
312
+ export type ListSessionsResponse = z.infer<typeof ListSessionsResponseSchema>;
313
+ export declare const DeleteSessionResponseSchema: z.ZodObject<{
314
+ success: z.ZodBoolean;
315
+ error: z.ZodOptional<z.ZodObject<{
316
+ message: z.ZodString;
317
+ code: z.ZodOptional<z.ZodString>;
318
+ }, z.core.$strip>>;
319
+ }, z.core.$strip>;
320
+ export type DeleteSessionResponse = z.infer<typeof DeleteSessionResponseSchema>;
321
+ export declare const PrewarmSessionReadySchema: z.ZodPipe<z.ZodObject<{
322
+ session_id: z.ZodString;
323
+ note: z.ZodNullable<z.ZodString>;
324
+ title_customized: z.ZodBoolean;
325
+ is_new: z.ZodBoolean;
326
+ }, z.core.$strip>, z.ZodTransform<{
327
+ note: string | null;
328
+ sessionId: string;
329
+ titleCustomized: boolean;
330
+ isNew: boolean;
331
+ }, {
332
+ session_id: string;
333
+ note: string | null;
334
+ title_customized: boolean;
335
+ is_new: boolean;
336
+ }>>;
337
+ export type PrewarmSessionReady = z.infer<typeof PrewarmSessionReadySchema>;
338
+ export declare const PrewarmSandboxReadySchema: z.ZodObject<{
339
+ cli_installed: z.ZodBoolean;
340
+ cli_version: z.ZodString;
341
+ sdk_installed: z.ZodBoolean;
342
+ sdk_version: z.ZodString;
343
+ restarted: z.ZodBoolean;
344
+ elapsed_s: z.ZodNumber;
345
+ }, z.core.$strip>;
346
+ export declare const PrewarmSkillsReadySchema: z.ZodObject<{
347
+ total: z.ZodNumber;
348
+ elapsed_s: z.ZodNumber;
349
+ }, z.core.$strip>;
350
+ export declare const PrewarmDoneSchema: z.ZodObject<{
351
+ ok: z.ZodLiteral<true>;
352
+ prewarmed: z.ZodLiteral<true>;
353
+ total_elapsed_s: z.ZodNumber;
354
+ }, z.core.$strip>;
355
+ export declare const PrewarmErrorSchema: z.ZodObject<{
356
+ err_code: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
357
+ message: z.ZodString;
358
+ }, z.core.$strip>;
359
+ /**
360
+ * Terminal result of a session prewarm. The boundary is the `session_ready`
361
+ * event (the upstream commit point): once it has been observed the session
362
+ * exists in the upstream database, so later failures degrade to `fallback`
363
+ * instead of `failed`.
364
+ */
365
+ export type SessionPrewarmOutcome = {
366
+ status: "ready";
367
+ session: PrewarmSessionReady;
368
+ } | {
369
+ status: "fallback";
370
+ session: PrewarmSessionReady;
371
+ } | {
372
+ status: "failed";
373
+ };
374
+ export type SessionPrewarmStage = "creating" | "sandbox" | "skills" | "finishing";
375
+ export {};
@@ -0,0 +1,129 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Creation provenance of a session: which kind of client provisioned it.
4
+ * The upstream database is backfilled with `web` as the default, so the
5
+ * field is always present on stored sessions.
6
+ */
7
+ export const SessionSourceSchema = z.enum(["web", "cli"]);
8
+ const ApiResponseBaseSchema = z.object({
9
+ success: z.boolean(),
10
+ error: z
11
+ .object({
12
+ message: z.string(),
13
+ code: z.string().optional(),
14
+ })
15
+ .optional(),
16
+ });
17
+ const ChatTaskSummarySchema = z
18
+ .object({
19
+ id: z.string().optional(),
20
+ chatTaskId: z.string().optional(),
21
+ chat_task_id: z.string().optional(),
22
+ parentChatTaskId: z.string().nullable().optional(),
23
+ parent_chat_task_id: z.string().nullable().optional(),
24
+ resultChildChatTaskId: z.string().nullable().optional(),
25
+ result_child_chat_task_id: z.string().nullable().optional(),
26
+ status: z.enum([
27
+ "pending",
28
+ "running",
29
+ "processing",
30
+ "completed",
31
+ "failed",
32
+ "cancelled",
33
+ ]),
34
+ })
35
+ .transform((data) => {
36
+ const id = data.id ?? data.chatTaskId ?? data.chat_task_id ?? "";
37
+ return {
38
+ id,
39
+ chatTaskId: id,
40
+ parentChatTaskId: data.parentChatTaskId ?? data.parent_chat_task_id ?? null,
41
+ resultChildChatTaskId: data.resultChildChatTaskId ?? data.result_child_chat_task_id ?? null,
42
+ status: data.status,
43
+ };
44
+ });
45
+ const SessionListItemSchema = z
46
+ .object({
47
+ id: z.string().optional(),
48
+ sessionId: z.string().optional(),
49
+ session_id: z.string().optional(),
50
+ note: z.string().nullable().optional(),
51
+ titleCustomized: z.boolean().optional(),
52
+ title_customized: z.boolean().optional(),
53
+ lastActiveAt: z.string().optional(),
54
+ last_active_at: z.string().optional(),
55
+ pinnedAt: z.string().nullable().optional(),
56
+ pinned_at: z.string().nullable().optional(),
57
+ createdAt: z.string().optional(),
58
+ created_at: z.string().optional(),
59
+ source: SessionSourceSchema.optional(),
60
+ status: z
61
+ .object({
62
+ chat: z.boolean(),
63
+ task: z.boolean(),
64
+ })
65
+ .optional(),
66
+ chatTasks: z.array(ChatTaskSummarySchema).optional(),
67
+ chat_tasks: z.array(ChatTaskSummarySchema).optional(),
68
+ ai302TaskCount: z.number().nullable().catch(null).optional(),
69
+ ai302_task_count: z.number().nullable().catch(null).optional(),
70
+ })
71
+ .transform((data) => {
72
+ const id = data.id ?? data.sessionId ?? data.session_id ?? "";
73
+ return {
74
+ id,
75
+ sessionId: id,
76
+ note: data.note ?? null,
77
+ titleCustomized: data.titleCustomized ?? data.title_customized ?? false,
78
+ lastActiveAt: data.lastActiveAt ?? data.last_active_at ?? "",
79
+ pinnedAt: data.pinnedAt ?? data.pinned_at ?? null,
80
+ createdAt: data.createdAt ?? data.created_at ?? "",
81
+ source: data.source ?? "web",
82
+ status: data.status ?? { chat: true, task: true },
83
+ chatTasks: data.chatTasks ?? data.chat_tasks ?? [],
84
+ ai302TaskCount: data.ai302TaskCount ?? data.ai302_task_count ?? null,
85
+ };
86
+ });
87
+ export const ListSessionsQuerySchema = z.object({
88
+ limit: z.number().int().positive().optional(),
89
+ offset: z.number().int().nonnegative().optional(),
90
+ note: z.string().optional(),
91
+ });
92
+ export const ListSessionsResponseSchema = ApiResponseBaseSchema.extend({
93
+ data: z.array(SessionListItemSchema),
94
+ });
95
+ export const DeleteSessionResponseSchema = ApiResponseBaseSchema;
96
+ export const PrewarmSessionReadySchema = z
97
+ .object({
98
+ session_id: z.string(),
99
+ note: z.string().nullable(),
100
+ title_customized: z.boolean(),
101
+ is_new: z.boolean(),
102
+ })
103
+ .transform(({ session_id, title_customized, is_new, ...rest }) => ({
104
+ ...rest,
105
+ sessionId: session_id,
106
+ titleCustomized: title_customized,
107
+ isNew: is_new,
108
+ }));
109
+ export const PrewarmSandboxReadySchema = z.object({
110
+ cli_installed: z.boolean(),
111
+ cli_version: z.string(),
112
+ sdk_installed: z.boolean(),
113
+ sdk_version: z.string(),
114
+ restarted: z.boolean(),
115
+ elapsed_s: z.number(),
116
+ });
117
+ export const PrewarmSkillsReadySchema = z.object({
118
+ total: z.number().int().nonnegative(),
119
+ elapsed_s: z.number(),
120
+ });
121
+ export const PrewarmDoneSchema = z.object({
122
+ ok: z.literal(true),
123
+ prewarmed: z.literal(true),
124
+ total_elapsed_s: z.number(),
125
+ });
126
+ export const PrewarmErrorSchema = z.object({
127
+ err_code: z.union([z.number(), z.string()]),
128
+ message: z.string(),
129
+ });
@@ -0,0 +1,90 @@
1
+ import { z } from "zod";
2
+ /** Text part delta in streaming turn. */
3
+ export declare const TextDeltaEventSchema: z.ZodObject<{
4
+ type: z.ZodLiteral<"text-delta">;
5
+ delta: z.ZodString;
6
+ id: z.ZodOptional<z.ZodString>;
7
+ }, z.core.$strip>;
8
+ /** Reasoning / thinking part delta in streaming turn. */
9
+ export declare const ReasoningDeltaEventSchema: z.ZodObject<{
10
+ type: z.ZodLiteral<"reasoning-delta">;
11
+ delta: z.ZodString;
12
+ id: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strip>;
14
+ /** Tool invocation event emitted when assistant calls an external tool. */
15
+ export declare const ToolCallEventSchema: z.ZodObject<{
16
+ type: z.ZodLiteral<"tool-call">;
17
+ toolCallId: z.ZodString;
18
+ toolName: z.ZodString;
19
+ args: z.ZodOptional<z.ZodUnknown>;
20
+ }, z.core.$strip>;
21
+ /** Tool result response emitted after tool execution finishes. */
22
+ export declare const ToolResultEventSchema: z.ZodObject<{
23
+ type: z.ZodLiteral<"tool-result">;
24
+ toolCallId: z.ZodString;
25
+ result: z.ZodOptional<z.ZodUnknown>;
26
+ }, z.core.$strip>;
27
+ /** High-level media result event emitted when image/video generation completes. */
28
+ export declare const MediaResultEventSchema: z.ZodObject<{
29
+ type: z.ZodLiteral<"media-result">;
30
+ result: z.ZodObject<{
31
+ status: z.ZodOptional<z.ZodString>;
32
+ domain: z.ZodOptional<z.ZodString>;
33
+ operation: z.ZodOptional<z.ZodString>;
34
+ modelUsed: z.ZodOptional<z.ZodString>;
35
+ taskId: z.ZodOptional<z.ZodString>;
36
+ resultUrl: z.ZodOptional<z.ZodString>;
37
+ prompt: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>;
39
+ }, z.core.$strip>;
40
+ /** Terminal finish event indicating turn completion. */
41
+ export declare const FinishEventSchema: z.ZodObject<{
42
+ type: z.ZodLiteral<"finish">;
43
+ finishReason: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strip>;
45
+ /** Stream error event. Supports either error or message string. */
46
+ export declare const StreamErrorEventSchema: z.ZodObject<{
47
+ type: z.ZodLiteral<"error">;
48
+ error: z.ZodOptional<z.ZodString>;
49
+ message: z.ZodOptional<z.ZodString>;
50
+ chatTaskId: z.ZodOptional<z.ZodString>;
51
+ }, z.core.$strip>;
52
+ /** Discriminated union of all possible streaming events yielded by ChatStream. */
53
+ export declare const ChatStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
54
+ type: z.ZodLiteral<"text-delta">;
55
+ delta: z.ZodString;
56
+ id: z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strip>, z.ZodObject<{
58
+ type: z.ZodLiteral<"reasoning-delta">;
59
+ delta: z.ZodString;
60
+ id: z.ZodOptional<z.ZodString>;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ type: z.ZodLiteral<"tool-call">;
63
+ toolCallId: z.ZodString;
64
+ toolName: z.ZodString;
65
+ args: z.ZodOptional<z.ZodUnknown>;
66
+ }, z.core.$strip>, z.ZodObject<{
67
+ type: z.ZodLiteral<"tool-result">;
68
+ toolCallId: z.ZodString;
69
+ result: z.ZodOptional<z.ZodUnknown>;
70
+ }, z.core.$strip>, z.ZodObject<{
71
+ type: z.ZodLiteral<"media-result">;
72
+ result: z.ZodObject<{
73
+ status: z.ZodOptional<z.ZodString>;
74
+ domain: z.ZodOptional<z.ZodString>;
75
+ operation: z.ZodOptional<z.ZodString>;
76
+ modelUsed: z.ZodOptional<z.ZodString>;
77
+ taskId: z.ZodOptional<z.ZodString>;
78
+ resultUrl: z.ZodOptional<z.ZodString>;
79
+ prompt: z.ZodOptional<z.ZodString>;
80
+ }, z.core.$strip>;
81
+ }, z.core.$strip>, z.ZodObject<{
82
+ type: z.ZodLiteral<"finish">;
83
+ finishReason: z.ZodOptional<z.ZodString>;
84
+ }, z.core.$strip>, z.ZodObject<{
85
+ type: z.ZodLiteral<"error">;
86
+ error: z.ZodOptional<z.ZodString>;
87
+ message: z.ZodOptional<z.ZodString>;
88
+ chatTaskId: z.ZodOptional<z.ZodString>;
89
+ }, z.core.$strip>], "type">;
90
+ export type ChatStreamEvent = z.infer<typeof ChatStreamEventSchema>;
@@ -0,0 +1,54 @@
1
+ import { z } from "zod";
2
+ import { MediaResultSchema } from "../media/media-result.js";
3
+ /** Text part delta in streaming turn. */
4
+ export const TextDeltaEventSchema = z.object({
5
+ type: z.literal("text-delta"),
6
+ delta: z.string(),
7
+ id: z.string().optional(),
8
+ });
9
+ /** Reasoning / thinking part delta in streaming turn. */
10
+ export const ReasoningDeltaEventSchema = z.object({
11
+ type: z.literal("reasoning-delta"),
12
+ delta: z.string(),
13
+ id: z.string().optional(),
14
+ });
15
+ /** Tool invocation event emitted when assistant calls an external tool. */
16
+ export const ToolCallEventSchema = z.object({
17
+ type: z.literal("tool-call"),
18
+ toolCallId: z.string(),
19
+ toolName: z.string(),
20
+ args: z.unknown().optional(),
21
+ });
22
+ /** Tool result response emitted after tool execution finishes. */
23
+ export const ToolResultEventSchema = z.object({
24
+ type: z.literal("tool-result"),
25
+ toolCallId: z.string(),
26
+ result: z.unknown().optional(),
27
+ });
28
+ /** High-level media result event emitted when image/video generation completes. */
29
+ export const MediaResultEventSchema = z.object({
30
+ type: z.literal("media-result"),
31
+ result: MediaResultSchema,
32
+ });
33
+ /** Terminal finish event indicating turn completion. */
34
+ export const FinishEventSchema = z.object({
35
+ type: z.literal("finish"),
36
+ finishReason: z.string().optional(),
37
+ });
38
+ /** Stream error event. Supports either error or message string. */
39
+ export const StreamErrorEventSchema = z.object({
40
+ type: z.literal("error"),
41
+ error: z.string().optional(),
42
+ message: z.string().optional(),
43
+ chatTaskId: z.string().optional(),
44
+ });
45
+ /** Discriminated union of all possible streaming events yielded by ChatStream. */
46
+ export const ChatStreamEventSchema = z.discriminatedUnion("type", [
47
+ TextDeltaEventSchema,
48
+ ReasoningDeltaEventSchema,
49
+ ToolCallEventSchema,
50
+ ToolResultEventSchema,
51
+ MediaResultEventSchema,
52
+ FinishEventSchema,
53
+ StreamErrorEventSchema,
54
+ ]);