@machinemetrics/agent-event-protocol 0.1.0 → 0.2.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/dist/core.d.ts CHANGED
@@ -1,119 +1,395 @@
1
- export { h as AbortedEvent, a as ActionResult, i as AgentEvent, b as AgentRequest, A as AssistantContentBlock, C as ContinuationEvent, D as DoneEvent, c as ErrorCode, g as ErrorEvent, E as EventStage, F as FinishReason, I as InputMessage, M as MetadataEvent, T as TextEvent, d as ThinkingEvent, e as ToolCallEvent, f as ToolResultEvent, U as UserContentBlock } from './types-CttB5bnC.js';
1
+ export { h as AbortedEvent, a as ActionResult, i as AgentEvent, b as AgentRequest, A as AssistantContentBlock, C as ContinuationEvent, D as DoneEvent, c as ErrorCode, g as ErrorEvent, E as EventStage, F as FinishReason, I as InputMessage, M as MetadataEvent, T as TextEvent, d as ThinkingEvent, e as ToolCallEvent, f as ToolResultEvent, U as UserContentBlock } from './types-HORFdRxd.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  /**
5
- * Zod schema for validating user content blocks.
6
- * Currently only supports text; extensible for multimodal.
5
+ * Zod schema for a user text block.
7
6
  */
8
- declare const UserContentBlockSchema: z.ZodObject<{
7
+ declare const UserTextBlockSchema: z.ZodObject<{
9
8
  type: z.ZodLiteral<"text">;
10
9
  text: z.ZodString;
11
- }, z.core.$strip>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ text: string;
12
+ type: "text";
13
+ }, {
14
+ text: string;
15
+ type: "text";
16
+ }>;
17
+ declare const MediaTypeSchema: z.ZodString;
18
+ /**
19
+ * Zod schema for a user attachment block: a file the user uploaded ahead of
20
+ * the message and now refers to by id. How the file reaches the model (an
21
+ * image, a document, extracted text, a tool) is the server's decision.
22
+ */
23
+ declare const UserAttachmentBlockSchema: z.ZodObject<{
24
+ type: z.ZodLiteral<"attachment">;
25
+ attachmentId: z.ZodString;
26
+ mimeType: z.ZodString;
27
+ name: z.ZodOptional<z.ZodString>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ type: "attachment";
30
+ attachmentId: string;
31
+ mimeType: string;
32
+ name?: string | undefined;
33
+ }, {
34
+ type: "attachment";
35
+ attachmentId: string;
36
+ mimeType: string;
37
+ name?: string | undefined;
38
+ }>;
39
+ /**
40
+ * Zod schema for validating user content blocks: text or an attachment.
41
+ */
42
+ declare const UserContentBlockSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
43
+ type: z.ZodLiteral<"text">;
44
+ text: z.ZodString;
45
+ }, "strip", z.ZodTypeAny, {
46
+ text: string;
47
+ type: "text";
48
+ }, {
49
+ text: string;
50
+ type: "text";
51
+ }>, z.ZodObject<{
52
+ type: z.ZodLiteral<"attachment">;
53
+ attachmentId: z.ZodString;
54
+ mimeType: z.ZodString;
55
+ name: z.ZodOptional<z.ZodString>;
56
+ }, "strip", z.ZodTypeAny, {
57
+ type: "attachment";
58
+ attachmentId: string;
59
+ mimeType: string;
60
+ name?: string | undefined;
61
+ }, {
62
+ type: "attachment";
63
+ attachmentId: string;
64
+ mimeType: string;
65
+ name?: string | undefined;
66
+ }>]>;
12
67
  /**
13
68
  * Zod schema for validating assistant content blocks.
14
69
  * Discriminated union supporting text, thinking, tool_use, and tool_result.
15
70
  */
16
- declare const AssistantContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
71
+ declare const AssistantContentBlockSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
17
72
  type: z.ZodLiteral<"text">;
18
73
  text: z.ZodString;
19
- }, z.core.$strip>, z.ZodObject<{
74
+ }, "strip", z.ZodTypeAny, {
75
+ text: string;
76
+ type: "text";
77
+ }, {
78
+ text: string;
79
+ type: "text";
80
+ }>, z.ZodObject<{
20
81
  type: z.ZodLiteral<"thinking">;
21
82
  text: z.ZodString;
22
- }, z.core.$strip>, z.ZodObject<{
83
+ }, "strip", z.ZodTypeAny, {
84
+ text: string;
85
+ type: "thinking";
86
+ }, {
87
+ text: string;
88
+ type: "thinking";
89
+ }>, z.ZodObject<{
23
90
  type: z.ZodLiteral<"tool_use">;
24
91
  toolCallId: z.ZodString;
25
92
  tool: z.ZodString;
26
93
  args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
27
- }, z.core.$strip>, z.ZodObject<{
94
+ }, "strip", z.ZodTypeAny, {
95
+ type: "tool_use";
96
+ toolCallId: string;
97
+ tool: string;
98
+ args: Record<string, unknown>;
99
+ }, {
100
+ type: "tool_use";
101
+ toolCallId: string;
102
+ tool: string;
103
+ args: Record<string, unknown>;
104
+ }>, z.ZodObject<{
28
105
  type: z.ZodLiteral<"tool_result">;
29
106
  toolCallId: z.ZodString;
30
107
  tool: z.ZodString;
31
- status: z.ZodEnum<{
32
- success: "success";
33
- error: "error";
34
- }>;
108
+ status: z.ZodEnum<["success", "error"]>;
35
109
  summary: z.ZodOptional<z.ZodString>;
36
- }, z.core.$strip>], "type">;
110
+ output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
111
+ }, "strip", z.ZodTypeAny, {
112
+ type: "tool_result";
113
+ status: "success" | "error";
114
+ toolCallId: string;
115
+ tool: string;
116
+ summary?: string | undefined;
117
+ output?: Record<string, unknown> | undefined;
118
+ }, {
119
+ type: "tool_result";
120
+ status: "success" | "error";
121
+ toolCallId: string;
122
+ tool: string;
123
+ summary?: string | undefined;
124
+ output?: Record<string, unknown> | undefined;
125
+ }>]>;
37
126
  /**
38
127
  * Zod schema for validating input messages.
39
128
  */
40
129
  declare const InputMessageSchema: z.ZodObject<{
41
- content: z.ZodArray<z.ZodObject<{
130
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
42
131
  type: z.ZodLiteral<"text">;
43
132
  text: z.ZodString;
44
- }, z.core.$strip>>;
45
- }, z.core.$strip>;
133
+ }, "strip", z.ZodTypeAny, {
134
+ text: string;
135
+ type: "text";
136
+ }, {
137
+ text: string;
138
+ type: "text";
139
+ }>, z.ZodObject<{
140
+ type: z.ZodLiteral<"attachment">;
141
+ attachmentId: z.ZodString;
142
+ mimeType: z.ZodString;
143
+ name: z.ZodOptional<z.ZodString>;
144
+ }, "strip", z.ZodTypeAny, {
145
+ type: "attachment";
146
+ attachmentId: string;
147
+ mimeType: string;
148
+ name?: string | undefined;
149
+ }, {
150
+ type: "attachment";
151
+ attachmentId: string;
152
+ mimeType: string;
153
+ name?: string | undefined;
154
+ }>]>, "many">;
155
+ }, "strip", z.ZodTypeAny, {
156
+ content: ({
157
+ text: string;
158
+ type: "text";
159
+ } | {
160
+ type: "attachment";
161
+ attachmentId: string;
162
+ mimeType: string;
163
+ name?: string | undefined;
164
+ })[];
165
+ }, {
166
+ content: ({
167
+ text: string;
168
+ type: "text";
169
+ } | {
170
+ type: "attachment";
171
+ attachmentId: string;
172
+ mimeType: string;
173
+ name?: string | undefined;
174
+ })[];
175
+ }>;
46
176
  /**
47
177
  * Zod schema for validating action results from continuation events.
48
178
  */
49
179
  declare const ActionResultSchema: z.ZodObject<{
50
180
  actionId: z.ZodString;
51
181
  kind: z.ZodString;
52
- status: z.ZodEnum<{
53
- success: "success";
54
- error: "error";
55
- }>;
182
+ status: z.ZodEnum<["success", "error"]>;
56
183
  data: z.ZodOptional<z.ZodUnknown>;
57
184
  error: z.ZodOptional<z.ZodString>;
58
- }, z.core.$strip>;
185
+ }, "strip", z.ZodTypeAny, {
186
+ status: "success" | "error";
187
+ actionId: string;
188
+ kind: string;
189
+ error?: string | undefined;
190
+ data?: unknown;
191
+ }, {
192
+ status: "success" | "error";
193
+ actionId: string;
194
+ kind: string;
195
+ error?: string | undefined;
196
+ data?: unknown;
197
+ }>;
59
198
  /**
60
199
  * Zod schema for validating agent request payloads.
61
200
  * Context object uses passthrough() to allow additional fields.
62
201
  */
63
202
  declare const AgentRequestSchema: z.ZodObject<{
64
203
  messages: z.ZodArray<z.ZodObject<{
65
- content: z.ZodArray<z.ZodObject<{
204
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
66
205
  type: z.ZodLiteral<"text">;
67
206
  text: z.ZodString;
68
- }, z.core.$strip>>;
69
- }, z.core.$strip>>;
207
+ }, "strip", z.ZodTypeAny, {
208
+ text: string;
209
+ type: "text";
210
+ }, {
211
+ text: string;
212
+ type: "text";
213
+ }>, z.ZodObject<{
214
+ type: z.ZodLiteral<"attachment">;
215
+ attachmentId: z.ZodString;
216
+ mimeType: z.ZodString;
217
+ name: z.ZodOptional<z.ZodString>;
218
+ }, "strip", z.ZodTypeAny, {
219
+ type: "attachment";
220
+ attachmentId: string;
221
+ mimeType: string;
222
+ name?: string | undefined;
223
+ }, {
224
+ type: "attachment";
225
+ attachmentId: string;
226
+ mimeType: string;
227
+ name?: string | undefined;
228
+ }>]>, "many">;
229
+ }, "strip", z.ZodTypeAny, {
230
+ content: ({
231
+ text: string;
232
+ type: "text";
233
+ } | {
234
+ type: "attachment";
235
+ attachmentId: string;
236
+ mimeType: string;
237
+ name?: string | undefined;
238
+ })[];
239
+ }, {
240
+ content: ({
241
+ text: string;
242
+ type: "text";
243
+ } | {
244
+ type: "attachment";
245
+ attachmentId: string;
246
+ mimeType: string;
247
+ name?: string | undefined;
248
+ })[];
249
+ }>, "many">;
70
250
  threadId: z.ZodOptional<z.ZodString>;
71
251
  context: z.ZodOptional<z.ZodObject<{
72
252
  actionResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
73
253
  actionId: z.ZodString;
74
254
  kind: z.ZodString;
75
- status: z.ZodEnum<{
76
- success: "success";
77
- error: "error";
78
- }>;
255
+ status: z.ZodEnum<["success", "error"]>;
256
+ data: z.ZodOptional<z.ZodUnknown>;
257
+ error: z.ZodOptional<z.ZodString>;
258
+ }, "strip", z.ZodTypeAny, {
259
+ status: "success" | "error";
260
+ actionId: string;
261
+ kind: string;
262
+ error?: string | undefined;
263
+ data?: unknown;
264
+ }, {
265
+ status: "success" | "error";
266
+ actionId: string;
267
+ kind: string;
268
+ error?: string | undefined;
269
+ data?: unknown;
270
+ }>, "many">>;
271
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
272
+ actionResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
273
+ actionId: z.ZodString;
274
+ kind: z.ZodString;
275
+ status: z.ZodEnum<["success", "error"]>;
276
+ data: z.ZodOptional<z.ZodUnknown>;
277
+ error: z.ZodOptional<z.ZodString>;
278
+ }, "strip", z.ZodTypeAny, {
279
+ status: "success" | "error";
280
+ actionId: string;
281
+ kind: string;
282
+ error?: string | undefined;
283
+ data?: unknown;
284
+ }, {
285
+ status: "success" | "error";
286
+ actionId: string;
287
+ kind: string;
288
+ error?: string | undefined;
289
+ data?: unknown;
290
+ }>, "many">>;
291
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
292
+ actionResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
293
+ actionId: z.ZodString;
294
+ kind: z.ZodString;
295
+ status: z.ZodEnum<["success", "error"]>;
296
+ data: z.ZodOptional<z.ZodUnknown>;
297
+ error: z.ZodOptional<z.ZodString>;
298
+ }, "strip", z.ZodTypeAny, {
299
+ status: "success" | "error";
300
+ actionId: string;
301
+ kind: string;
302
+ error?: string | undefined;
303
+ data?: unknown;
304
+ }, {
305
+ status: "success" | "error";
306
+ actionId: string;
307
+ kind: string;
308
+ error?: string | undefined;
309
+ data?: unknown;
310
+ }>, "many">>;
311
+ }, z.ZodTypeAny, "passthrough">>>;
312
+ }, "strip", z.ZodTypeAny, {
313
+ messages: {
314
+ content: ({
315
+ text: string;
316
+ type: "text";
317
+ } | {
318
+ type: "attachment";
319
+ attachmentId: string;
320
+ mimeType: string;
321
+ name?: string | undefined;
322
+ })[];
323
+ }[];
324
+ threadId?: string | undefined;
325
+ context?: z.objectOutputType<{
326
+ actionResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
327
+ actionId: z.ZodString;
328
+ kind: z.ZodString;
329
+ status: z.ZodEnum<["success", "error"]>;
79
330
  data: z.ZodOptional<z.ZodUnknown>;
80
331
  error: z.ZodOptional<z.ZodString>;
81
- }, z.core.$strip>>>;
82
- }, z.core.$loose>>;
83
- }, z.core.$strip>;
332
+ }, "strip", z.ZodTypeAny, {
333
+ status: "success" | "error";
334
+ actionId: string;
335
+ kind: string;
336
+ error?: string | undefined;
337
+ data?: unknown;
338
+ }, {
339
+ status: "success" | "error";
340
+ actionId: string;
341
+ kind: string;
342
+ error?: string | undefined;
343
+ data?: unknown;
344
+ }>, "many">>;
345
+ }, z.ZodTypeAny, "passthrough"> | undefined;
346
+ }, {
347
+ messages: {
348
+ content: ({
349
+ text: string;
350
+ type: "text";
351
+ } | {
352
+ type: "attachment";
353
+ attachmentId: string;
354
+ mimeType: string;
355
+ name?: string | undefined;
356
+ })[];
357
+ }[];
358
+ threadId?: string | undefined;
359
+ context?: z.objectInputType<{
360
+ actionResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
361
+ actionId: z.ZodString;
362
+ kind: z.ZodString;
363
+ status: z.ZodEnum<["success", "error"]>;
364
+ data: z.ZodOptional<z.ZodUnknown>;
365
+ error: z.ZodOptional<z.ZodString>;
366
+ }, "strip", z.ZodTypeAny, {
367
+ status: "success" | "error";
368
+ actionId: string;
369
+ kind: string;
370
+ error?: string | undefined;
371
+ data?: unknown;
372
+ }, {
373
+ status: "success" | "error";
374
+ actionId: string;
375
+ kind: string;
376
+ error?: string | undefined;
377
+ data?: unknown;
378
+ }>, "many">>;
379
+ }, z.ZodTypeAny, "passthrough"> | undefined;
380
+ }>;
84
381
  /**
85
382
  * Zod schema for event lifecycle stages.
86
383
  */
87
- declare const EventStageSchema: z.ZodEnum<{
88
- start: "start";
89
- delta: "delta";
90
- stop: "stop";
91
- }>;
384
+ declare const EventStageSchema: z.ZodEnum<["start", "delta", "stop"]>;
92
385
  /**
93
386
  * Zod schema for protocol error codes.
94
387
  */
95
- declare const ErrorCodeSchema: z.ZodEnum<{
96
- auth_failed: "auth_failed";
97
- thread_not_found: "thread_not_found";
98
- thread_access_denied: "thread_access_denied";
99
- invalid_message_format: "invalid_message_format";
100
- message_too_large: "message_too_large";
101
- rate_limit_exceeded: "rate_limit_exceeded";
102
- stream_timeout: "stream_timeout";
103
- agent_error: "agent_error";
104
- tool_error: "tool_error";
105
- internal_error: "internal_error";
106
- invalid_action_id: "invalid_action_id";
107
- }>;
388
+ declare const ErrorCodeSchema: z.ZodEnum<["auth_failed", "thread_not_found", "thread_access_denied", "invalid_message_format", "message_too_large", "rate_limit_exceeded", "stream_timeout", "stream_stalled", "agent_error", "tool_error", "internal_error", "invalid_action_id"]>;
108
389
  /**
109
390
  * Zod schema for stream finish reasons.
110
391
  */
111
- declare const FinishReasonSchema: z.ZodEnum<{
112
- error: "error";
113
- stop: "stop";
114
- length: "length";
115
- action_required: "action_required";
116
- }>;
392
+ declare const FinishReasonSchema: z.ZodEnum<["stop", "length", "error", "action_required"]>;
117
393
  /**
118
394
  * Zod schema for metadata events.
119
395
  * First event in every stream, provides identifiers.
@@ -124,7 +400,19 @@ declare const MetadataEventSchema: z.ZodObject<{
124
400
  threadId: z.ZodString;
125
401
  agentId: z.ZodString;
126
402
  timestamp: z.ZodString;
127
- }, z.core.$strip>;
403
+ }, "strip", z.ZodTypeAny, {
404
+ threadId: string;
405
+ event: "metadata";
406
+ requestId: string;
407
+ agentId: string;
408
+ timestamp: string;
409
+ }, {
410
+ threadId: string;
411
+ event: "metadata";
412
+ requestId: string;
413
+ agentId: string;
414
+ timestamp: string;
415
+ }>;
128
416
  /**
129
417
  * Zod schema for text streaming events.
130
418
  * Validates the stage lifecycle with appropriate optional fields per stage.
@@ -135,15 +423,31 @@ declare const TextEventSchema: z.ZodObject<{
135
423
  messageId: z.ZodString;
136
424
  blockId: z.ZodString;
137
425
  blockIndex: z.ZodOptional<z.ZodNumber>;
138
- stage: z.ZodEnum<{
139
- start: "start";
140
- delta: "delta";
141
- stop: "stop";
142
- }>;
426
+ stage: z.ZodEnum<["start", "delta", "stop"]>;
143
427
  delta: z.ZodOptional<z.ZodString>;
144
428
  deltaIndex: z.ZodOptional<z.ZodNumber>;
145
429
  timestamp: z.ZodString;
146
- }, z.core.$strip>;
430
+ }, "strip", z.ZodTypeAny, {
431
+ event: "text";
432
+ requestId: string;
433
+ timestamp: string;
434
+ messageId: string;
435
+ blockId: string;
436
+ stage: "start" | "delta" | "stop";
437
+ delta?: string | undefined;
438
+ blockIndex?: number | undefined;
439
+ deltaIndex?: number | undefined;
440
+ }, {
441
+ event: "text";
442
+ requestId: string;
443
+ timestamp: string;
444
+ messageId: string;
445
+ blockId: string;
446
+ stage: "start" | "delta" | "stop";
447
+ delta?: string | undefined;
448
+ blockIndex?: number | undefined;
449
+ deltaIndex?: number | undefined;
450
+ }>;
147
451
  /**
148
452
  * Zod schema for thinking/reasoning events.
149
453
  * Structure mirrors TextEventSchema.
@@ -154,15 +458,31 @@ declare const ThinkingEventSchema: z.ZodObject<{
154
458
  messageId: z.ZodString;
155
459
  blockId: z.ZodString;
156
460
  blockIndex: z.ZodOptional<z.ZodNumber>;
157
- stage: z.ZodEnum<{
158
- start: "start";
159
- delta: "delta";
160
- stop: "stop";
161
- }>;
461
+ stage: z.ZodEnum<["start", "delta", "stop"]>;
162
462
  delta: z.ZodOptional<z.ZodString>;
163
463
  deltaIndex: z.ZodOptional<z.ZodNumber>;
164
464
  timestamp: z.ZodString;
165
- }, z.core.$strip>;
465
+ }, "strip", z.ZodTypeAny, {
466
+ event: "thinking";
467
+ requestId: string;
468
+ timestamp: string;
469
+ messageId: string;
470
+ blockId: string;
471
+ stage: "start" | "delta" | "stop";
472
+ delta?: string | undefined;
473
+ blockIndex?: number | undefined;
474
+ deltaIndex?: number | undefined;
475
+ }, {
476
+ event: "thinking";
477
+ requestId: string;
478
+ timestamp: string;
479
+ messageId: string;
480
+ blockId: string;
481
+ stage: "start" | "delta" | "stop";
482
+ delta?: string | undefined;
483
+ blockIndex?: number | undefined;
484
+ deltaIndex?: number | undefined;
485
+ }>;
166
486
  /**
167
487
  * Zod schema for tool call events.
168
488
  * Args are optional (only present on stop stage).
@@ -173,18 +493,40 @@ declare const ToolCallEventSchema: z.ZodObject<{
173
493
  messageId: z.ZodString;
174
494
  blockId: z.ZodString;
175
495
  blockIndex: z.ZodOptional<z.ZodNumber>;
176
- stage: z.ZodEnum<{
177
- start: "start";
178
- delta: "delta";
179
- stop: "stop";
180
- }>;
496
+ stage: z.ZodEnum<["start", "delta", "stop"]>;
181
497
  toolCallId: z.ZodOptional<z.ZodString>;
182
498
  tool: z.ZodOptional<z.ZodString>;
183
499
  delta: z.ZodOptional<z.ZodString>;
184
500
  deltaIndex: z.ZodOptional<z.ZodNumber>;
185
501
  args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
186
502
  timestamp: z.ZodString;
187
- }, z.core.$strip>;
503
+ }, "strip", z.ZodTypeAny, {
504
+ event: "tool_call";
505
+ requestId: string;
506
+ timestamp: string;
507
+ messageId: string;
508
+ blockId: string;
509
+ stage: "start" | "delta" | "stop";
510
+ delta?: string | undefined;
511
+ toolCallId?: string | undefined;
512
+ tool?: string | undefined;
513
+ args?: Record<string, unknown> | undefined;
514
+ blockIndex?: number | undefined;
515
+ deltaIndex?: number | undefined;
516
+ }, {
517
+ event: "tool_call";
518
+ requestId: string;
519
+ timestamp: string;
520
+ messageId: string;
521
+ blockId: string;
522
+ stage: "start" | "delta" | "stop";
523
+ delta?: string | undefined;
524
+ toolCallId?: string | undefined;
525
+ tool?: string | undefined;
526
+ args?: Record<string, unknown> | undefined;
527
+ blockIndex?: number | undefined;
528
+ deltaIndex?: number | undefined;
529
+ }>;
188
530
  /**
189
531
  * Zod schema for tool result events.
190
532
  * Status and summary only present on stop stage.
@@ -195,20 +537,40 @@ declare const ToolResultEventSchema: z.ZodObject<{
195
537
  messageId: z.ZodString;
196
538
  blockId: z.ZodString;
197
539
  blockIndex: z.ZodOptional<z.ZodNumber>;
198
- stage: z.ZodEnum<{
199
- start: "start";
200
- delta: "delta";
201
- stop: "stop";
202
- }>;
540
+ stage: z.ZodEnum<["start", "delta", "stop"]>;
203
541
  toolCallId: z.ZodOptional<z.ZodString>;
204
542
  tool: z.ZodOptional<z.ZodString>;
205
- status: z.ZodOptional<z.ZodEnum<{
206
- success: "success";
207
- error: "error";
208
- }>>;
543
+ status: z.ZodOptional<z.ZodEnum<["success", "error"]>>;
209
544
  summary: z.ZodOptional<z.ZodString>;
545
+ output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
210
546
  timestamp: z.ZodString;
211
- }, z.core.$strip>;
547
+ }, "strip", z.ZodTypeAny, {
548
+ event: "tool_result";
549
+ requestId: string;
550
+ timestamp: string;
551
+ messageId: string;
552
+ blockId: string;
553
+ stage: "start" | "delta" | "stop";
554
+ status?: "success" | "error" | undefined;
555
+ toolCallId?: string | undefined;
556
+ tool?: string | undefined;
557
+ summary?: string | undefined;
558
+ output?: Record<string, unknown> | undefined;
559
+ blockIndex?: number | undefined;
560
+ }, {
561
+ event: "tool_result";
562
+ requestId: string;
563
+ timestamp: string;
564
+ messageId: string;
565
+ blockId: string;
566
+ stage: "start" | "delta" | "stop";
567
+ status?: "success" | "error" | undefined;
568
+ toolCallId?: string | undefined;
569
+ tool?: string | undefined;
570
+ summary?: string | undefined;
571
+ output?: Record<string, unknown> | undefined;
572
+ blockIndex?: number | undefined;
573
+ }>;
212
574
  /**
213
575
  * Zod schema for done events.
214
576
  * Terminal event with complete content array.
@@ -218,40 +580,137 @@ declare const DoneEventSchema: z.ZodObject<{
218
580
  requestId: z.ZodString;
219
581
  messageId: z.ZodString;
220
582
  threadId: z.ZodString;
221
- content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
583
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
222
584
  type: z.ZodLiteral<"text">;
223
585
  text: z.ZodString;
224
- }, z.core.$strip>, z.ZodObject<{
586
+ }, "strip", z.ZodTypeAny, {
587
+ text: string;
588
+ type: "text";
589
+ }, {
590
+ text: string;
591
+ type: "text";
592
+ }>, z.ZodObject<{
225
593
  type: z.ZodLiteral<"thinking">;
226
594
  text: z.ZodString;
227
- }, z.core.$strip>, z.ZodObject<{
595
+ }, "strip", z.ZodTypeAny, {
596
+ text: string;
597
+ type: "thinking";
598
+ }, {
599
+ text: string;
600
+ type: "thinking";
601
+ }>, z.ZodObject<{
228
602
  type: z.ZodLiteral<"tool_use">;
229
603
  toolCallId: z.ZodString;
230
604
  tool: z.ZodString;
231
605
  args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
232
- }, z.core.$strip>, z.ZodObject<{
606
+ }, "strip", z.ZodTypeAny, {
607
+ type: "tool_use";
608
+ toolCallId: string;
609
+ tool: string;
610
+ args: Record<string, unknown>;
611
+ }, {
612
+ type: "tool_use";
613
+ toolCallId: string;
614
+ tool: string;
615
+ args: Record<string, unknown>;
616
+ }>, z.ZodObject<{
233
617
  type: z.ZodLiteral<"tool_result">;
234
618
  toolCallId: z.ZodString;
235
619
  tool: z.ZodString;
236
- status: z.ZodEnum<{
237
- success: "success";
238
- error: "error";
239
- }>;
620
+ status: z.ZodEnum<["success", "error"]>;
240
621
  summary: z.ZodOptional<z.ZodString>;
241
- }, z.core.$strip>], "type">>;
622
+ output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
623
+ }, "strip", z.ZodTypeAny, {
624
+ type: "tool_result";
625
+ status: "success" | "error";
626
+ toolCallId: string;
627
+ tool: string;
628
+ summary?: string | undefined;
629
+ output?: Record<string, unknown> | undefined;
630
+ }, {
631
+ type: "tool_result";
632
+ status: "success" | "error";
633
+ toolCallId: string;
634
+ tool: string;
635
+ summary?: string | undefined;
636
+ output?: Record<string, unknown> | undefined;
637
+ }>]>, "many">;
242
638
  usage: z.ZodOptional<z.ZodObject<{
243
639
  promptTokens: z.ZodNumber;
244
640
  completionTokens: z.ZodNumber;
245
- }, z.core.$strip>>;
246
- finishReason: z.ZodEnum<{
247
- error: "error";
248
- stop: "stop";
249
- length: "length";
250
- action_required: "action_required";
251
- }>;
641
+ }, "strip", z.ZodTypeAny, {
642
+ promptTokens: number;
643
+ completionTokens: number;
644
+ }, {
645
+ promptTokens: number;
646
+ completionTokens: number;
647
+ }>>;
648
+ finishReason: z.ZodEnum<["stop", "length", "error", "action_required"]>;
252
649
  traceId: z.ZodOptional<z.ZodString>;
253
650
  timestamp: z.ZodString;
254
- }, z.core.$strip>;
651
+ }, "strip", z.ZodTypeAny, {
652
+ content: ({
653
+ text: string;
654
+ type: "text";
655
+ } | {
656
+ text: string;
657
+ type: "thinking";
658
+ } | {
659
+ type: "tool_use";
660
+ toolCallId: string;
661
+ tool: string;
662
+ args: Record<string, unknown>;
663
+ } | {
664
+ type: "tool_result";
665
+ status: "success" | "error";
666
+ toolCallId: string;
667
+ tool: string;
668
+ summary?: string | undefined;
669
+ output?: Record<string, unknown> | undefined;
670
+ })[];
671
+ threadId: string;
672
+ event: "done";
673
+ requestId: string;
674
+ timestamp: string;
675
+ messageId: string;
676
+ finishReason: "error" | "stop" | "length" | "action_required";
677
+ usage?: {
678
+ promptTokens: number;
679
+ completionTokens: number;
680
+ } | undefined;
681
+ traceId?: string | undefined;
682
+ }, {
683
+ content: ({
684
+ text: string;
685
+ type: "text";
686
+ } | {
687
+ text: string;
688
+ type: "thinking";
689
+ } | {
690
+ type: "tool_use";
691
+ toolCallId: string;
692
+ tool: string;
693
+ args: Record<string, unknown>;
694
+ } | {
695
+ type: "tool_result";
696
+ status: "success" | "error";
697
+ toolCallId: string;
698
+ tool: string;
699
+ summary?: string | undefined;
700
+ output?: Record<string, unknown> | undefined;
701
+ })[];
702
+ threadId: string;
703
+ event: "done";
704
+ requestId: string;
705
+ timestamp: string;
706
+ messageId: string;
707
+ finishReason: "error" | "stop" | "length" | "action_required";
708
+ usage?: {
709
+ promptTokens: number;
710
+ completionTokens: number;
711
+ } | undefined;
712
+ traceId?: string | undefined;
713
+ }>;
255
714
  /**
256
715
  * Zod schema for error events.
257
716
  * Terminal event with error details and retry guidance.
@@ -260,22 +719,24 @@ declare const ErrorEventSchema: z.ZodObject<{
260
719
  event: z.ZodLiteral<"error">;
261
720
  requestId: z.ZodString;
262
721
  message: z.ZodString;
263
- code: z.ZodOptional<z.ZodEnum<{
264
- auth_failed: "auth_failed";
265
- thread_not_found: "thread_not_found";
266
- thread_access_denied: "thread_access_denied";
267
- invalid_message_format: "invalid_message_format";
268
- message_too_large: "message_too_large";
269
- rate_limit_exceeded: "rate_limit_exceeded";
270
- stream_timeout: "stream_timeout";
271
- agent_error: "agent_error";
272
- tool_error: "tool_error";
273
- internal_error: "internal_error";
274
- invalid_action_id: "invalid_action_id";
275
- }>>;
722
+ code: z.ZodOptional<z.ZodEnum<["auth_failed", "thread_not_found", "thread_access_denied", "invalid_message_format", "message_too_large", "rate_limit_exceeded", "stream_timeout", "stream_stalled", "agent_error", "tool_error", "internal_error", "invalid_action_id"]>>;
276
723
  retryable: z.ZodOptional<z.ZodBoolean>;
277
724
  timestamp: z.ZodString;
278
- }, z.core.$strip>;
725
+ }, "strip", z.ZodTypeAny, {
726
+ message: string;
727
+ event: "error";
728
+ requestId: string;
729
+ timestamp: string;
730
+ code?: "auth_failed" | "thread_not_found" | "thread_access_denied" | "invalid_message_format" | "message_too_large" | "rate_limit_exceeded" | "stream_timeout" | "stream_stalled" | "agent_error" | "tool_error" | "internal_error" | "invalid_action_id" | undefined;
731
+ retryable?: boolean | undefined;
732
+ }, {
733
+ message: string;
734
+ event: "error";
735
+ requestId: string;
736
+ timestamp: string;
737
+ code?: "auth_failed" | "thread_not_found" | "thread_access_denied" | "invalid_message_format" | "message_too_large" | "rate_limit_exceeded" | "stream_timeout" | "stream_stalled" | "agent_error" | "tool_error" | "internal_error" | "invalid_action_id" | undefined;
738
+ retryable?: boolean | undefined;
739
+ }>;
279
740
  /**
280
741
  * Zod schema for aborted events.
281
742
  * Terminal event acknowledging client cancellation.
@@ -285,7 +746,17 @@ declare const AbortedEventSchema: z.ZodObject<{
285
746
  requestId: z.ZodString;
286
747
  messageId: z.ZodOptional<z.ZodString>;
287
748
  timestamp: z.ZodString;
288
- }, z.core.$strip>;
749
+ }, "strip", z.ZodTypeAny, {
750
+ event: "aborted";
751
+ requestId: string;
752
+ timestamp: string;
753
+ messageId?: string | undefined;
754
+ }, {
755
+ event: "aborted";
756
+ requestId: string;
757
+ timestamp: string;
758
+ messageId?: string | undefined;
759
+ }>;
289
760
  /**
290
761
  * Zod schema for continuation events.
291
762
  * Signals client action required before stream can continue.
@@ -297,151 +768,374 @@ declare const ContinuationEventSchema: z.ZodObject<{
297
768
  kind: z.ZodString;
298
769
  payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
299
770
  timestamp: z.ZodString;
300
- }, z.core.$strip>;
771
+ }, "strip", z.ZodTypeAny, {
772
+ actionId: string;
773
+ kind: string;
774
+ event: "continuation";
775
+ requestId: string;
776
+ timestamp: string;
777
+ payload: Record<string, unknown>;
778
+ }, {
779
+ actionId: string;
780
+ kind: string;
781
+ event: "continuation";
782
+ requestId: string;
783
+ timestamp: string;
784
+ payload: Record<string, unknown>;
785
+ }>;
301
786
  /**
302
787
  * Zod schema for all protocol events.
303
788
  * Discriminated union on the `event` field for efficient parsing.
304
789
  */
305
- declare const AgentEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
790
+ declare const AgentEventSchema: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
306
791
  event: z.ZodLiteral<"metadata">;
307
792
  requestId: z.ZodString;
308
793
  threadId: z.ZodString;
309
794
  agentId: z.ZodString;
310
795
  timestamp: z.ZodString;
311
- }, z.core.$strip>, z.ZodObject<{
796
+ }, "strip", z.ZodTypeAny, {
797
+ threadId: string;
798
+ event: "metadata";
799
+ requestId: string;
800
+ agentId: string;
801
+ timestamp: string;
802
+ }, {
803
+ threadId: string;
804
+ event: "metadata";
805
+ requestId: string;
806
+ agentId: string;
807
+ timestamp: string;
808
+ }>, z.ZodObject<{
312
809
  event: z.ZodLiteral<"text">;
313
810
  requestId: z.ZodString;
314
811
  messageId: z.ZodString;
315
812
  blockId: z.ZodString;
316
813
  blockIndex: z.ZodOptional<z.ZodNumber>;
317
- stage: z.ZodEnum<{
318
- start: "start";
319
- delta: "delta";
320
- stop: "stop";
321
- }>;
814
+ stage: z.ZodEnum<["start", "delta", "stop"]>;
322
815
  delta: z.ZodOptional<z.ZodString>;
323
816
  deltaIndex: z.ZodOptional<z.ZodNumber>;
324
817
  timestamp: z.ZodString;
325
- }, z.core.$strip>, z.ZodObject<{
818
+ }, "strip", z.ZodTypeAny, {
819
+ event: "text";
820
+ requestId: string;
821
+ timestamp: string;
822
+ messageId: string;
823
+ blockId: string;
824
+ stage: "start" | "delta" | "stop";
825
+ delta?: string | undefined;
826
+ blockIndex?: number | undefined;
827
+ deltaIndex?: number | undefined;
828
+ }, {
829
+ event: "text";
830
+ requestId: string;
831
+ timestamp: string;
832
+ messageId: string;
833
+ blockId: string;
834
+ stage: "start" | "delta" | "stop";
835
+ delta?: string | undefined;
836
+ blockIndex?: number | undefined;
837
+ deltaIndex?: number | undefined;
838
+ }>, z.ZodObject<{
326
839
  event: z.ZodLiteral<"thinking">;
327
840
  requestId: z.ZodString;
328
841
  messageId: z.ZodString;
329
842
  blockId: z.ZodString;
330
843
  blockIndex: z.ZodOptional<z.ZodNumber>;
331
- stage: z.ZodEnum<{
332
- start: "start";
333
- delta: "delta";
334
- stop: "stop";
335
- }>;
844
+ stage: z.ZodEnum<["start", "delta", "stop"]>;
336
845
  delta: z.ZodOptional<z.ZodString>;
337
846
  deltaIndex: z.ZodOptional<z.ZodNumber>;
338
847
  timestamp: z.ZodString;
339
- }, z.core.$strip>, z.ZodObject<{
848
+ }, "strip", z.ZodTypeAny, {
849
+ event: "thinking";
850
+ requestId: string;
851
+ timestamp: string;
852
+ messageId: string;
853
+ blockId: string;
854
+ stage: "start" | "delta" | "stop";
855
+ delta?: string | undefined;
856
+ blockIndex?: number | undefined;
857
+ deltaIndex?: number | undefined;
858
+ }, {
859
+ event: "thinking";
860
+ requestId: string;
861
+ timestamp: string;
862
+ messageId: string;
863
+ blockId: string;
864
+ stage: "start" | "delta" | "stop";
865
+ delta?: string | undefined;
866
+ blockIndex?: number | undefined;
867
+ deltaIndex?: number | undefined;
868
+ }>, z.ZodObject<{
340
869
  event: z.ZodLiteral<"tool_call">;
341
870
  requestId: z.ZodString;
342
871
  messageId: z.ZodString;
343
872
  blockId: z.ZodString;
344
873
  blockIndex: z.ZodOptional<z.ZodNumber>;
345
- stage: z.ZodEnum<{
346
- start: "start";
347
- delta: "delta";
348
- stop: "stop";
349
- }>;
874
+ stage: z.ZodEnum<["start", "delta", "stop"]>;
350
875
  toolCallId: z.ZodOptional<z.ZodString>;
351
876
  tool: z.ZodOptional<z.ZodString>;
352
877
  delta: z.ZodOptional<z.ZodString>;
353
878
  deltaIndex: z.ZodOptional<z.ZodNumber>;
354
879
  args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
355
880
  timestamp: z.ZodString;
356
- }, z.core.$strip>, z.ZodObject<{
881
+ }, "strip", z.ZodTypeAny, {
882
+ event: "tool_call";
883
+ requestId: string;
884
+ timestamp: string;
885
+ messageId: string;
886
+ blockId: string;
887
+ stage: "start" | "delta" | "stop";
888
+ delta?: string | undefined;
889
+ toolCallId?: string | undefined;
890
+ tool?: string | undefined;
891
+ args?: Record<string, unknown> | undefined;
892
+ blockIndex?: number | undefined;
893
+ deltaIndex?: number | undefined;
894
+ }, {
895
+ event: "tool_call";
896
+ requestId: string;
897
+ timestamp: string;
898
+ messageId: string;
899
+ blockId: string;
900
+ stage: "start" | "delta" | "stop";
901
+ delta?: string | undefined;
902
+ toolCallId?: string | undefined;
903
+ tool?: string | undefined;
904
+ args?: Record<string, unknown> | undefined;
905
+ blockIndex?: number | undefined;
906
+ deltaIndex?: number | undefined;
907
+ }>, z.ZodObject<{
357
908
  event: z.ZodLiteral<"tool_result">;
358
909
  requestId: z.ZodString;
359
910
  messageId: z.ZodString;
360
911
  blockId: z.ZodString;
361
912
  blockIndex: z.ZodOptional<z.ZodNumber>;
362
- stage: z.ZodEnum<{
363
- start: "start";
364
- delta: "delta";
365
- stop: "stop";
366
- }>;
913
+ stage: z.ZodEnum<["start", "delta", "stop"]>;
367
914
  toolCallId: z.ZodOptional<z.ZodString>;
368
915
  tool: z.ZodOptional<z.ZodString>;
369
- status: z.ZodOptional<z.ZodEnum<{
370
- success: "success";
371
- error: "error";
372
- }>>;
916
+ status: z.ZodOptional<z.ZodEnum<["success", "error"]>>;
373
917
  summary: z.ZodOptional<z.ZodString>;
918
+ output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
374
919
  timestamp: z.ZodString;
375
- }, z.core.$strip>, z.ZodObject<{
920
+ }, "strip", z.ZodTypeAny, {
921
+ event: "tool_result";
922
+ requestId: string;
923
+ timestamp: string;
924
+ messageId: string;
925
+ blockId: string;
926
+ stage: "start" | "delta" | "stop";
927
+ status?: "success" | "error" | undefined;
928
+ toolCallId?: string | undefined;
929
+ tool?: string | undefined;
930
+ summary?: string | undefined;
931
+ output?: Record<string, unknown> | undefined;
932
+ blockIndex?: number | undefined;
933
+ }, {
934
+ event: "tool_result";
935
+ requestId: string;
936
+ timestamp: string;
937
+ messageId: string;
938
+ blockId: string;
939
+ stage: "start" | "delta" | "stop";
940
+ status?: "success" | "error" | undefined;
941
+ toolCallId?: string | undefined;
942
+ tool?: string | undefined;
943
+ summary?: string | undefined;
944
+ output?: Record<string, unknown> | undefined;
945
+ blockIndex?: number | undefined;
946
+ }>, z.ZodObject<{
376
947
  event: z.ZodLiteral<"done">;
377
948
  requestId: z.ZodString;
378
949
  messageId: z.ZodString;
379
950
  threadId: z.ZodString;
380
- content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
951
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
381
952
  type: z.ZodLiteral<"text">;
382
953
  text: z.ZodString;
383
- }, z.core.$strip>, z.ZodObject<{
954
+ }, "strip", z.ZodTypeAny, {
955
+ text: string;
956
+ type: "text";
957
+ }, {
958
+ text: string;
959
+ type: "text";
960
+ }>, z.ZodObject<{
384
961
  type: z.ZodLiteral<"thinking">;
385
962
  text: z.ZodString;
386
- }, z.core.$strip>, z.ZodObject<{
963
+ }, "strip", z.ZodTypeAny, {
964
+ text: string;
965
+ type: "thinking";
966
+ }, {
967
+ text: string;
968
+ type: "thinking";
969
+ }>, z.ZodObject<{
387
970
  type: z.ZodLiteral<"tool_use">;
388
971
  toolCallId: z.ZodString;
389
972
  tool: z.ZodString;
390
973
  args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
391
- }, z.core.$strip>, z.ZodObject<{
974
+ }, "strip", z.ZodTypeAny, {
975
+ type: "tool_use";
976
+ toolCallId: string;
977
+ tool: string;
978
+ args: Record<string, unknown>;
979
+ }, {
980
+ type: "tool_use";
981
+ toolCallId: string;
982
+ tool: string;
983
+ args: Record<string, unknown>;
984
+ }>, z.ZodObject<{
392
985
  type: z.ZodLiteral<"tool_result">;
393
986
  toolCallId: z.ZodString;
394
987
  tool: z.ZodString;
395
- status: z.ZodEnum<{
396
- success: "success";
397
- error: "error";
398
- }>;
988
+ status: z.ZodEnum<["success", "error"]>;
399
989
  summary: z.ZodOptional<z.ZodString>;
400
- }, z.core.$strip>], "type">>;
990
+ output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
991
+ }, "strip", z.ZodTypeAny, {
992
+ type: "tool_result";
993
+ status: "success" | "error";
994
+ toolCallId: string;
995
+ tool: string;
996
+ summary?: string | undefined;
997
+ output?: Record<string, unknown> | undefined;
998
+ }, {
999
+ type: "tool_result";
1000
+ status: "success" | "error";
1001
+ toolCallId: string;
1002
+ tool: string;
1003
+ summary?: string | undefined;
1004
+ output?: Record<string, unknown> | undefined;
1005
+ }>]>, "many">;
401
1006
  usage: z.ZodOptional<z.ZodObject<{
402
1007
  promptTokens: z.ZodNumber;
403
1008
  completionTokens: z.ZodNumber;
404
- }, z.core.$strip>>;
405
- finishReason: z.ZodEnum<{
406
- error: "error";
407
- stop: "stop";
408
- length: "length";
409
- action_required: "action_required";
410
- }>;
1009
+ }, "strip", z.ZodTypeAny, {
1010
+ promptTokens: number;
1011
+ completionTokens: number;
1012
+ }, {
1013
+ promptTokens: number;
1014
+ completionTokens: number;
1015
+ }>>;
1016
+ finishReason: z.ZodEnum<["stop", "length", "error", "action_required"]>;
411
1017
  traceId: z.ZodOptional<z.ZodString>;
412
1018
  timestamp: z.ZodString;
413
- }, z.core.$strip>, z.ZodObject<{
1019
+ }, "strip", z.ZodTypeAny, {
1020
+ content: ({
1021
+ text: string;
1022
+ type: "text";
1023
+ } | {
1024
+ text: string;
1025
+ type: "thinking";
1026
+ } | {
1027
+ type: "tool_use";
1028
+ toolCallId: string;
1029
+ tool: string;
1030
+ args: Record<string, unknown>;
1031
+ } | {
1032
+ type: "tool_result";
1033
+ status: "success" | "error";
1034
+ toolCallId: string;
1035
+ tool: string;
1036
+ summary?: string | undefined;
1037
+ output?: Record<string, unknown> | undefined;
1038
+ })[];
1039
+ threadId: string;
1040
+ event: "done";
1041
+ requestId: string;
1042
+ timestamp: string;
1043
+ messageId: string;
1044
+ finishReason: "error" | "stop" | "length" | "action_required";
1045
+ usage?: {
1046
+ promptTokens: number;
1047
+ completionTokens: number;
1048
+ } | undefined;
1049
+ traceId?: string | undefined;
1050
+ }, {
1051
+ content: ({
1052
+ text: string;
1053
+ type: "text";
1054
+ } | {
1055
+ text: string;
1056
+ type: "thinking";
1057
+ } | {
1058
+ type: "tool_use";
1059
+ toolCallId: string;
1060
+ tool: string;
1061
+ args: Record<string, unknown>;
1062
+ } | {
1063
+ type: "tool_result";
1064
+ status: "success" | "error";
1065
+ toolCallId: string;
1066
+ tool: string;
1067
+ summary?: string | undefined;
1068
+ output?: Record<string, unknown> | undefined;
1069
+ })[];
1070
+ threadId: string;
1071
+ event: "done";
1072
+ requestId: string;
1073
+ timestamp: string;
1074
+ messageId: string;
1075
+ finishReason: "error" | "stop" | "length" | "action_required";
1076
+ usage?: {
1077
+ promptTokens: number;
1078
+ completionTokens: number;
1079
+ } | undefined;
1080
+ traceId?: string | undefined;
1081
+ }>, z.ZodObject<{
414
1082
  event: z.ZodLiteral<"error">;
415
1083
  requestId: z.ZodString;
416
1084
  message: z.ZodString;
417
- code: z.ZodOptional<z.ZodEnum<{
418
- auth_failed: "auth_failed";
419
- thread_not_found: "thread_not_found";
420
- thread_access_denied: "thread_access_denied";
421
- invalid_message_format: "invalid_message_format";
422
- message_too_large: "message_too_large";
423
- rate_limit_exceeded: "rate_limit_exceeded";
424
- stream_timeout: "stream_timeout";
425
- agent_error: "agent_error";
426
- tool_error: "tool_error";
427
- internal_error: "internal_error";
428
- invalid_action_id: "invalid_action_id";
429
- }>>;
1085
+ code: z.ZodOptional<z.ZodEnum<["auth_failed", "thread_not_found", "thread_access_denied", "invalid_message_format", "message_too_large", "rate_limit_exceeded", "stream_timeout", "stream_stalled", "agent_error", "tool_error", "internal_error", "invalid_action_id"]>>;
430
1086
  retryable: z.ZodOptional<z.ZodBoolean>;
431
1087
  timestamp: z.ZodString;
432
- }, z.core.$strip>, z.ZodObject<{
1088
+ }, "strip", z.ZodTypeAny, {
1089
+ message: string;
1090
+ event: "error";
1091
+ requestId: string;
1092
+ timestamp: string;
1093
+ code?: "auth_failed" | "thread_not_found" | "thread_access_denied" | "invalid_message_format" | "message_too_large" | "rate_limit_exceeded" | "stream_timeout" | "stream_stalled" | "agent_error" | "tool_error" | "internal_error" | "invalid_action_id" | undefined;
1094
+ retryable?: boolean | undefined;
1095
+ }, {
1096
+ message: string;
1097
+ event: "error";
1098
+ requestId: string;
1099
+ timestamp: string;
1100
+ code?: "auth_failed" | "thread_not_found" | "thread_access_denied" | "invalid_message_format" | "message_too_large" | "rate_limit_exceeded" | "stream_timeout" | "stream_stalled" | "agent_error" | "tool_error" | "internal_error" | "invalid_action_id" | undefined;
1101
+ retryable?: boolean | undefined;
1102
+ }>, z.ZodObject<{
433
1103
  event: z.ZodLiteral<"aborted">;
434
1104
  requestId: z.ZodString;
435
1105
  messageId: z.ZodOptional<z.ZodString>;
436
1106
  timestamp: z.ZodString;
437
- }, z.core.$strip>, z.ZodObject<{
1107
+ }, "strip", z.ZodTypeAny, {
1108
+ event: "aborted";
1109
+ requestId: string;
1110
+ timestamp: string;
1111
+ messageId?: string | undefined;
1112
+ }, {
1113
+ event: "aborted";
1114
+ requestId: string;
1115
+ timestamp: string;
1116
+ messageId?: string | undefined;
1117
+ }>, z.ZodObject<{
438
1118
  event: z.ZodLiteral<"continuation">;
439
1119
  requestId: z.ZodString;
440
1120
  actionId: z.ZodString;
441
1121
  kind: z.ZodString;
442
1122
  payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
443
1123
  timestamp: z.ZodString;
444
- }, z.core.$strip>], "event">;
1124
+ }, "strip", z.ZodTypeAny, {
1125
+ actionId: string;
1126
+ kind: string;
1127
+ event: "continuation";
1128
+ requestId: string;
1129
+ timestamp: string;
1130
+ payload: Record<string, unknown>;
1131
+ }, {
1132
+ actionId: string;
1133
+ kind: string;
1134
+ event: "continuation";
1135
+ requestId: string;
1136
+ timestamp: string;
1137
+ payload: Record<string, unknown>;
1138
+ }>]>;
445
1139
 
446
1140
  /**
447
1141
  * Current protocol version.
@@ -460,4 +1154,4 @@ declare const EVENT_TYPES: readonly ["metadata", "text", "thinking", "tool_call"
460
1154
  */
461
1155
  type EventType = (typeof EVENT_TYPES)[number];
462
1156
 
463
- export { AbortedEventSchema, ActionResultSchema, AgentEventSchema, AgentRequestSchema, AssistantContentBlockSchema, ContinuationEventSchema, DoneEventSchema, EVENT_TYPES, ErrorCodeSchema, ErrorEventSchema, EventStageSchema, type EventType, FinishReasonSchema, InputMessageSchema, MetadataEventSchema, PROTOCOL_VERSION, TextEventSchema, ThinkingEventSchema, ToolCallEventSchema, ToolResultEventSchema, UserContentBlockSchema };
1157
+ export { AbortedEventSchema, ActionResultSchema, AgentEventSchema, AgentRequestSchema, AssistantContentBlockSchema, ContinuationEventSchema, DoneEventSchema, EVENT_TYPES, ErrorCodeSchema, ErrorEventSchema, EventStageSchema, type EventType, FinishReasonSchema, InputMessageSchema, MediaTypeSchema, MetadataEventSchema, PROTOCOL_VERSION, TextEventSchema, ThinkingEventSchema, ToolCallEventSchema, ToolResultEventSchema, UserAttachmentBlockSchema, UserContentBlockSchema, UserTextBlockSchema };