@agen-ai/agent-protocol 0.4.2 → 0.4.4

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.
Files changed (52) hide show
  1. package/README.md +151 -21
  2. package/dist/capabilities/types.d.ts +3 -1
  3. package/dist/events/types.d.ts +1 -1
  4. package/dist/foundation/types.d.ts +2 -1
  5. package/dist/foundation/types.js +1 -1
  6. package/dist/jsonSchema/generated.d.ts +13637 -9890
  7. package/dist/jsonSchema/generated.js +3025 -644
  8. package/dist/public/index.d.ts +1 -0
  9. package/dist/public/index.js +1 -0
  10. package/dist/public/structuredOutput.d.ts +2 -0
  11. package/dist/public/structuredOutput.js +1 -0
  12. package/dist/sessions/types.d.ts +2 -0
  13. package/dist/structuredOutput/boundedJson.d.ts +13 -0
  14. package/dist/structuredOutput/boundedJson.js +143 -0
  15. package/dist/structuredOutput/constants.d.ts +24 -0
  16. package/dist/structuredOutput/constants.js +57 -0
  17. package/dist/structuredOutput/definition.d.ts +9 -0
  18. package/dist/structuredOutput/definition.js +15 -0
  19. package/dist/structuredOutput/index.d.ts +9 -0
  20. package/dist/structuredOutput/index.js +12 -0
  21. package/dist/structuredOutput/issues.d.ts +8 -0
  22. package/dist/structuredOutput/issues.js +76 -0
  23. package/dist/structuredOutput/parsers.d.ts +10 -0
  24. package/dist/structuredOutput/parsers.js +74 -0
  25. package/dist/structuredOutput/schemaAdmission.d.ts +9 -0
  26. package/dist/structuredOutput/schemaAdmission.js +247 -0
  27. package/dist/structuredOutput/types.d.ts +75 -0
  28. package/dist/structuredOutput/types.js +0 -0
  29. package/dist/structuredOutput/values.d.ts +5 -0
  30. package/dist/structuredOutput/values.js +89 -0
  31. package/dist/turns/types.d.ts +18 -5
  32. package/dist/zod/capabilities.d.ts +3 -2
  33. package/dist/zod/capabilities.js +2 -0
  34. package/dist/zod/events.d.ts +24 -33
  35. package/dist/zod/events.js +94 -94
  36. package/dist/zod/foundation.d.ts +1 -0
  37. package/dist/zod/foundation.js +3 -0
  38. package/dist/zod/index.d.ts +2 -0
  39. package/dist/zod/index.js +25 -1
  40. package/dist/zod/operations.d.ts +2 -2
  41. package/dist/zod/outputDefinition.d.ts +4 -0
  42. package/dist/zod/outputDefinition.js +22 -0
  43. package/dist/zod/outputSchema.d.ts +4 -0
  44. package/dist/zod/outputSchema.js +177 -0
  45. package/dist/zod/sessions.d.ts +14 -0
  46. package/dist/zod/sessions.js +26 -3
  47. package/dist/zod/structuredOutput.d.ts +14 -0
  48. package/dist/zod/structuredOutput.js +209 -0
  49. package/dist/zod/turns.d.ts +19 -5
  50. package/dist/zod/turns.js +63 -24
  51. package/dist/zod/typeEquality.generated.d.ts +16 -2
  52. package/package.json +6 -2
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
2
  import { type AgentEvent } from '../events/types.js';
3
- import { type AgentContextUsage } from '../turns/types.js';
3
+ import { type AgentContextUsage, type AgentTurnCompletedPayload } from '../turns/types.js';
4
4
  export declare const AgentContextUsagePortableSchema: z.ZodReadonly<z.ZodObject<{
5
5
  measurementScope: z.ZodEnum<{
6
6
  session: "session";
@@ -33,7 +33,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
33
33
  payload: z.ZodReadonly<z.ZodObject<{
34
34
  message: z.ZodOptional<z.ZodString>;
35
35
  }, z.core.$strict>>;
36
- protocolVersion: z.ZodLiteral<12>;
36
+ protocolVersion: z.ZodLiteral<13>;
37
37
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
38
38
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
39
39
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -54,7 +54,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
54
54
  requestId: z.ZodOptional<z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>>;
55
55
  message: z.ZodOptional<z.ZodString>;
56
56
  }, z.core.$strict>>;
57
- protocolVersion: z.ZodLiteral<12>;
57
+ protocolVersion: z.ZodLiteral<13>;
58
58
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
59
59
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
60
60
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -67,17 +67,8 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
67
67
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
68
68
  type: z.ZodLiteral<"turn.completed">;
69
69
  turnId: z.ZodType<import("../index.js").AgentTurnId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentTurnId, unknown>>;
70
- payload: z.ZodReadonly<z.ZodObject<{
71
- outcome: z.ZodEnum<{
72
- canceled: "canceled";
73
- completed: "completed";
74
- failed: "failed";
75
- expired: "expired";
76
- }>;
77
- reason: z.ZodOptional<z.ZodString>;
78
- error: z.ZodOptional<z.ZodType<import("../index.js").AgentError, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentError, unknown>>>;
79
- }, z.core.$strict>>;
80
- protocolVersion: z.ZodLiteral<12>;
70
+ payload: z.ZodType<AgentTurnCompletedPayload, unknown, z.core.$ZodTypeInternals<AgentTurnCompletedPayload, unknown>>;
71
+ protocolVersion: z.ZodLiteral<13>;
81
72
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
82
73
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
83
74
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -91,7 +82,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
91
82
  type: z.ZodLiteral<"item.started">;
92
83
  turnId: z.ZodType<import("../index.js").AgentTurnId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentTurnId, unknown>>;
93
84
  payload: z.ZodType<import("../index.js").AgentItemSnapshot, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentItemSnapshot, unknown>>;
94
- protocolVersion: z.ZodLiteral<12>;
85
+ protocolVersion: z.ZodLiteral<13>;
95
86
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
96
87
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
97
88
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -105,7 +96,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
105
96
  type: z.ZodLiteral<"item.updated">;
106
97
  turnId: z.ZodType<import("../index.js").AgentTurnId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentTurnId, unknown>>;
107
98
  payload: z.ZodType<import("../index.js").AgentItemSnapshot, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentItemSnapshot, unknown>>;
108
- protocolVersion: z.ZodLiteral<12>;
99
+ protocolVersion: z.ZodLiteral<13>;
109
100
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
110
101
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
111
102
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -119,7 +110,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
119
110
  type: z.ZodLiteral<"item.completed">;
120
111
  turnId: z.ZodType<import("../index.js").AgentTurnId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentTurnId, unknown>>;
121
112
  payload: z.ZodType<import("../index.js").AgentItemSnapshot, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentItemSnapshot, unknown>>;
122
- protocolVersion: z.ZodLiteral<12>;
113
+ protocolVersion: z.ZodLiteral<13>;
123
114
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
124
115
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
125
116
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -145,7 +136,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
145
136
  }>;
146
137
  delta: z.ZodString;
147
138
  }, z.core.$strict>>;
148
- protocolVersion: z.ZodLiteral<12>;
139
+ protocolVersion: z.ZodLiteral<13>;
149
140
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
150
141
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
151
142
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -162,7 +153,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
162
153
  explanation: z.ZodOptional<z.ZodString>;
163
154
  steps: z.ZodReadonly<z.ZodArray<z.ZodType<import("../index.js").AgentPlanStep, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentPlanStep, unknown>>>>;
164
155
  }, z.core.$strict>>;
165
- protocolVersion: z.ZodLiteral<12>;
156
+ protocolVersion: z.ZodLiteral<13>;
166
157
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
167
158
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
168
159
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -179,7 +170,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
179
170
  artifactId: z.ZodType<import("../index.js").AgentArtifactId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentArtifactId, unknown>>;
180
171
  requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
181
172
  }, z.core.$strict>>;
182
- protocolVersion: z.ZodLiteral<12>;
173
+ protocolVersion: z.ZodLiteral<13>;
183
174
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
184
175
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
185
176
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -193,7 +184,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
193
184
  type: z.ZodLiteral<"turn.diff.updated">;
194
185
  turnId: z.ZodType<import("../index.js").AgentTurnId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentTurnId, unknown>>;
195
186
  payload: z.ZodType<import("../index.js").AgentDiffSummary, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentDiffSummary, unknown>>;
196
- protocolVersion: z.ZodLiteral<12>;
187
+ protocolVersion: z.ZodLiteral<13>;
197
188
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
198
189
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
199
190
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -338,7 +329,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
338
329
  expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
339
330
  }, z.core.$strict>>], "requestKind">;
340
331
  }, z.core.$strict>>;
341
- protocolVersion: z.ZodLiteral<12>;
332
+ protocolVersion: z.ZodLiteral<13>;
342
333
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
343
334
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
344
335
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -359,7 +350,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
359
350
  withdrawn: "withdrawn";
360
351
  }>;
361
352
  }, z.core.$strict>>;
362
- protocolVersion: z.ZodLiteral<12>;
353
+ protocolVersion: z.ZodLiteral<13>;
363
354
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
364
355
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
365
356
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -390,7 +381,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
390
381
  current: z.ZodOptional<z.ZodNumber>;
391
382
  total: z.ZodOptional<z.ZodNumber>;
392
383
  }, z.core.$strict>>;
393
- protocolVersion: z.ZodLiteral<12>;
384
+ protocolVersion: z.ZodLiteral<13>;
394
385
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
395
386
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
396
387
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -428,7 +419,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
428
419
  thresholdTokens: z.ZodOptional<z.ZodNumber>;
429
420
  }, z.core.$strict>>>;
430
421
  }, z.core.$strict>>;
431
- protocolVersion: z.ZodLiteral<12>;
422
+ protocolVersion: z.ZodLiteral<13>;
432
423
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
433
424
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
434
425
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -444,7 +435,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
444
435
  payload: z.ZodReadonly<z.ZodObject<{
445
436
  artifact: z.ZodType<import("../index.js").AgentArtifactDescriptor, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentArtifactDescriptor, unknown>>;
446
437
  }, z.core.$strict>>;
447
- protocolVersion: z.ZodLiteral<12>;
438
+ protocolVersion: z.ZodLiteral<13>;
448
439
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
449
440
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
450
441
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -473,7 +464,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
473
464
  error: z.ZodOptional<z.ZodType<import("../index.js").AgentError, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentError, unknown>>>;
474
465
  }, z.core.$strict>>;
475
466
  }, z.core.$strict>>;
476
- protocolVersion: z.ZodLiteral<12>;
467
+ protocolVersion: z.ZodLiteral<13>;
477
468
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
478
469
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
479
470
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -542,7 +533,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
542
533
  resourceIds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodType<import("../index.js").AgentGeneratedResourceId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentGeneratedResourceId, unknown>>>>>;
543
534
  }, z.core.$strict>>;
544
535
  }, z.core.$strict>>;
545
- protocolVersion: z.ZodLiteral<12>;
536
+ protocolVersion: z.ZodLiteral<13>;
546
537
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
547
538
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
548
539
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -596,7 +587,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
596
587
  error: z.ZodOptional<z.ZodType<import("../index.js").AgentError, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentError, unknown>>>;
597
588
  }, z.core.$strict>>;
598
589
  }, z.core.$strict>>;
599
- protocolVersion: z.ZodLiteral<12>;
590
+ protocolVersion: z.ZodLiteral<13>;
600
591
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
601
592
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
602
593
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -616,7 +607,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
616
607
  maxAttempts: z.ZodOptional<z.ZodNumber>;
617
608
  delayMs: z.ZodOptional<z.ZodNumber>;
618
609
  }, z.core.$strict>>;
619
- protocolVersion: z.ZodLiteral<12>;
610
+ protocolVersion: z.ZodLiteral<13>;
620
611
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
621
612
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
622
613
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -634,7 +625,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
634
625
  message: z.ZodString;
635
626
  context: z.ZodOptional<z.ZodType<import("../index.js").AgentErrorContext, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentErrorContext, unknown>>>;
636
627
  }, z.core.$strict>>;
637
- protocolVersion: z.ZodLiteral<12>;
628
+ protocolVersion: z.ZodLiteral<13>;
638
629
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
639
630
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
640
631
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -650,7 +641,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
650
641
  payload: z.ZodReadonly<z.ZodObject<{
651
642
  error: z.ZodType<import("../index.js").AgentError, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentError, unknown>>;
652
643
  }, z.core.$strict>>;
653
- protocolVersion: z.ZodLiteral<12>;
644
+ protocolVersion: z.ZodLiteral<13>;
654
645
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
655
646
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
656
647
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -668,7 +659,7 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
668
659
  message: z.ZodString;
669
660
  context: z.ZodOptional<z.ZodType<import("../index.js").AgentErrorContext, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentErrorContext, unknown>>>;
670
661
  }, z.core.$strict>>;
671
- protocolVersion: z.ZodLiteral<12>;
662
+ protocolVersion: z.ZodLiteral<13>;
672
663
  sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
673
664
  providerRefs: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
674
665
  conversationId: z.ZodOptional<z.ZodType<import("../index.js").AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderConversationId, unknown>>>;
@@ -37,7 +37,8 @@ import {
37
37
  AgentProviderRefsSchema,
38
38
  AgentRequestIdSchema,
39
39
  AgentSessionIdSchema,
40
- AgentTurnIdSchema
40
+ AgentTurnIdSchema,
41
+ withAcyclicProtocolInput
41
42
  } from "./foundation.js";
42
43
  const commonFields = {
43
44
  protocolVersion: z.literal(AGENT_PROTOCOL_VERSION),
@@ -129,91 +130,98 @@ const AgentContextUsageSchema = AgentContextUsagePortableSchema.superRefine((usa
129
130
  });
130
131
  }
131
132
  });
132
- const AgentEventPortableSchema = z.discriminatedUnion("type", [
133
- turnEvent(
134
- "turn.started",
135
- z.object({ message: z.string().max(AGENT_PROTOCOL_TEXT_MAX_LENGTH).optional() }).strict().readonly()
136
- ),
137
- turnEvent("turn.state_changed", TurnStateChangedPayloadSchema),
138
- turnEvent("turn.completed", AgentTurnCompletedPayloadPortableSchema),
139
- turnEvent("item.started", AgentItemSnapshotSchema),
140
- turnEvent("item.updated", AgentItemSnapshotSchema),
141
- turnEvent("item.completed", AgentItemSnapshotSchema),
142
- turnEvent(
143
- "content.delta",
144
- z.object({
145
- itemId: AgentItemIdSchema,
146
- streamKind: AgentContentStreamKindSchema,
147
- delta: z.string().max(AGENT_PROTOCOL_TEXT_MAX_LENGTH)
148
- }).strict().readonly()
149
- ),
150
- turnEvent(
151
- "turn.plan.updated",
152
- z.object({
153
- explanation: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional(),
154
- steps: z.array(AgentPlanStepSchema).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly()
155
- }).strict().readonly()
156
- ),
157
- turnEvent(
158
- "turn.plan.proposed",
159
- z.object({
160
- artifactId: AgentArtifactIdSchema,
161
- requestId: AgentRequestIdSchema
162
- }).strict().readonly()
163
- ),
164
- turnEvent("turn.diff.updated", AgentDiffSummarySchema),
165
- turnEvent(
166
- "request.opened",
167
- z.object({ request: AgentRequestPortableSchema }).strict().readonly()
168
- ),
169
- turnEvent(
170
- "request.unavailable",
171
- z.object({
172
- requestId: AgentRequestIdSchema,
173
- reason: z.enum(AGENT_REQUEST_UNAVAILABLE_REASONS)
174
- }).strict().readonly()
175
- ),
176
- turnEvent("progress.updated", ProgressUpdatedPayloadSchema),
177
- turnEvent("context.usage.updated", AgentContextUsagePortableSchema),
178
- optionallyTurnScopedEvent(
179
- "artifact.referenced",
180
- z.object({ artifact: AgentArtifactDescriptorSchema }).strict().readonly()
181
- ),
182
- optionallyTurnScopedEvent(
183
- "operation.updated",
184
- z.object({ result: AgentOperationResultPortableSchema }).strict().readonly()
185
- ),
186
- optionallyTurnScopedEvent(
187
- "collaboration.updated",
188
- z.object({ node: AgentCollaborationNodePortableSchema }).strict().readonly()
189
- ),
190
- optionallyTurnScopedEvent(
191
- "resource.updated",
192
- z.object({ resource: AgentGeneratedResourceDescriptorPortableSchema }).strict().readonly()
193
- ),
194
- turnEvent("runtime.retrying", RuntimeRetryingPayloadSchema),
195
- optionallyTurnScopedEvent(
196
- "runtime.warning",
197
- z.object({
198
- code: AgentCanonicalCodeSchema,
199
- message: AgentCanonicalNonBlankTextSchema,
200
- context: AgentErrorContextSchema.optional()
201
- }).strict().readonly()
202
- ),
203
- optionallyTurnScopedEvent(
204
- "runtime.error",
205
- z.object({ error: AgentErrorSchema }).strict().readonly()
206
- ),
207
- optionallyTurnScopedEvent(
208
- "provider.diagnostic",
209
- z.object({
210
- code: AgentCanonicalCodeSchema,
211
- message: AgentCanonicalNonBlankTextSchema,
212
- context: AgentErrorContextSchema.optional()
213
- }).strict().readonly()
214
- )
215
- ]);
216
- const AgentEventSchema = AgentEventPortableSchema.superRefine((event, context) => {
133
+ function createEventSchema(completedPayload) {
134
+ return z.discriminatedUnion("type", [
135
+ turnEvent(
136
+ "turn.started",
137
+ z.object({ message: z.string().max(AGENT_PROTOCOL_TEXT_MAX_LENGTH).optional() }).strict().readonly()
138
+ ),
139
+ turnEvent("turn.state_changed", TurnStateChangedPayloadSchema),
140
+ turnEvent("turn.completed", completedPayload),
141
+ turnEvent("item.started", AgentItemSnapshotSchema),
142
+ turnEvent("item.updated", AgentItemSnapshotSchema),
143
+ turnEvent("item.completed", AgentItemSnapshotSchema),
144
+ turnEvent(
145
+ "content.delta",
146
+ z.object({
147
+ itemId: AgentItemIdSchema,
148
+ streamKind: AgentContentStreamKindSchema,
149
+ delta: z.string().max(AGENT_PROTOCOL_TEXT_MAX_LENGTH)
150
+ }).strict().readonly()
151
+ ),
152
+ turnEvent(
153
+ "turn.plan.updated",
154
+ z.object({
155
+ explanation: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional(),
156
+ steps: z.array(AgentPlanStepSchema).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly()
157
+ }).strict().readonly()
158
+ ),
159
+ turnEvent(
160
+ "turn.plan.proposed",
161
+ z.object({
162
+ artifactId: AgentArtifactIdSchema,
163
+ requestId: AgentRequestIdSchema
164
+ }).strict().readonly()
165
+ ),
166
+ turnEvent("turn.diff.updated", AgentDiffSummarySchema),
167
+ turnEvent(
168
+ "request.opened",
169
+ z.object({ request: AgentRequestPortableSchema }).strict().readonly()
170
+ ),
171
+ turnEvent(
172
+ "request.unavailable",
173
+ z.object({
174
+ requestId: AgentRequestIdSchema,
175
+ reason: z.enum(AGENT_REQUEST_UNAVAILABLE_REASONS)
176
+ }).strict().readonly()
177
+ ),
178
+ turnEvent("progress.updated", ProgressUpdatedPayloadSchema),
179
+ turnEvent("context.usage.updated", AgentContextUsagePortableSchema),
180
+ optionallyTurnScopedEvent(
181
+ "artifact.referenced",
182
+ z.object({ artifact: AgentArtifactDescriptorSchema }).strict().readonly()
183
+ ),
184
+ optionallyTurnScopedEvent(
185
+ "operation.updated",
186
+ z.object({ result: AgentOperationResultPortableSchema }).strict().readonly()
187
+ ),
188
+ optionallyTurnScopedEvent(
189
+ "collaboration.updated",
190
+ z.object({ node: AgentCollaborationNodePortableSchema }).strict().readonly()
191
+ ),
192
+ optionallyTurnScopedEvent(
193
+ "resource.updated",
194
+ z.object({ resource: AgentGeneratedResourceDescriptorPortableSchema }).strict().readonly()
195
+ ),
196
+ turnEvent("runtime.retrying", RuntimeRetryingPayloadSchema),
197
+ optionallyTurnScopedEvent(
198
+ "runtime.warning",
199
+ z.object({
200
+ code: AgentCanonicalCodeSchema,
201
+ message: AgentCanonicalNonBlankTextSchema,
202
+ context: AgentErrorContextSchema.optional()
203
+ }).strict().readonly()
204
+ ),
205
+ optionallyTurnScopedEvent(
206
+ "runtime.error",
207
+ z.object({ error: AgentErrorSchema }).strict().readonly()
208
+ ),
209
+ optionallyTurnScopedEvent(
210
+ "provider.diagnostic",
211
+ z.object({
212
+ code: AgentCanonicalCodeSchema,
213
+ message: AgentCanonicalNonBlankTextSchema,
214
+ context: AgentErrorContextSchema.optional()
215
+ }).strict().readonly()
216
+ )
217
+ ]);
218
+ }
219
+ const AgentEventPortableSchema = createEventSchema(AgentTurnCompletedPayloadPortableSchema);
220
+ const AgentEventSchema = withAcyclicProtocolInput(createEventSchema(AgentTurnCompletedPayloadSchema), {
221
+ maxDepth: 32,
222
+ maxNodes: AGENT_PROTOCOL_EVENT_BYTES_LIMIT,
223
+ maxCollectionLength: AGENT_PROTOCOL_COLLECTION_MAX_LENGTH
224
+ }).superRefine((event, context) => {
217
225
  if (event.providerRefs !== void 0) {
218
226
  const providerRefs = AgentProviderRefsSchema.safeParse(event.providerRefs);
219
227
  if (!providerRefs.success) {
@@ -232,14 +240,6 @@ const AgentEventSchema = AgentEventPortableSchema.superRefine((event, context) =
232
240
  });
233
241
  }
234
242
  }
235
- if (event.type === "turn.completed") {
236
- const completed = AgentTurnCompletedPayloadSchema.safeParse(event.payload);
237
- if (!completed.success) {
238
- for (const issue of completed.error.issues) {
239
- context.addIssue({ ...issue, path: ["payload", ...issue.path] });
240
- }
241
- }
242
- }
243
243
  if (event.type === "request.opened") {
244
244
  const request = AgentRequestSchema.safeParse(event.payload.request);
245
245
  if (!request.success) {
@@ -37,6 +37,7 @@ export declare const AgentIsoDateTimeSchema: z.ZodType<AgentIsoDateTime, unknown
37
37
  export declare const AgentJsonObjectKeySchema: z.ZodString;
38
38
  interface ProtocolInputPreflightOptions {
39
39
  readonly maxDepth?: number;
40
+ readonly maxNodes?: number;
40
41
  readonly maxCollectionLength?: number;
41
42
  readonly requireJsonData?: boolean;
42
43
  }
@@ -76,6 +76,7 @@ const AgentJsonObjectKeySchema = z.string().min(1).max(AGENT_PROTOCOL_JSON_KEY_M
76
76
  function passesProtocolInputPreflight(input, options) {
77
77
  const activeObjects = /* @__PURE__ */ new WeakSet();
78
78
  const pending = [{ operation: "enter", value: input, depth: 0 }];
79
+ let nodes = 0;
79
80
  while (pending.length > 0) {
80
81
  const current = pending.pop();
81
82
  if (!current) break;
@@ -83,6 +84,8 @@ function passesProtocolInputPreflight(input, options) {
83
84
  activeObjects.delete(current.value);
84
85
  continue;
85
86
  }
87
+ nodes += 1;
88
+ if (options.maxNodes !== void 0 && nodes > options.maxNodes) return false;
86
89
  if (options.maxDepth !== void 0 && current.depth > options.maxDepth) {
87
90
  return false;
88
91
  }
@@ -18,6 +18,8 @@ export * from './accountQuota.js';
18
18
  export * from './environmentFacts.js';
19
19
  export * from './effectiveContent.js';
20
20
  export * from './commands.js';
21
+ export { zodOutput } from './outputDefinition.js';
21
22
  export * from './extensions.js';
22
23
  export * from './environment.js';
24
+ export { AgentOutputSchemaPortableSchema, AgentOutputSchemaSchema, AgentStructuredOutputCapabilityPortableSchema, AgentStructuredOutputCapabilitySchema, AgentStructuredOutputRequestPortableSchema, AgentStructuredOutputRequestSchema, AgentStructuredOutputResultPortableSchema, AgentStructuredOutputResultSchema, AgentStructuredOutputNonJsonResultPortableSchema, AgentStructuredOutputNonJsonResultSchema, } from './structuredOutput.js';
23
25
  //# sourceMappingURL=index.d.ts.map
package/dist/zod/index.js CHANGED
@@ -150,8 +150,21 @@ export * from "./accountQuota.js";
150
150
  export * from "./environmentFacts.js";
151
151
  export * from "./effectiveContent.js";
152
152
  export * from "./commands.js";
153
+ import { zodOutput } from "./outputDefinition.js";
153
154
  export * from "./extensions.js";
154
155
  export * from "./environment.js";
156
+ import {
157
+ AgentOutputSchemaPortableSchema,
158
+ AgentOutputSchemaSchema,
159
+ AgentStructuredOutputCapabilityPortableSchema,
160
+ AgentStructuredOutputCapabilitySchema,
161
+ AgentStructuredOutputRequestPortableSchema,
162
+ AgentStructuredOutputRequestSchema,
163
+ AgentStructuredOutputResultPortableSchema,
164
+ AgentStructuredOutputResultSchema,
165
+ AgentStructuredOutputNonJsonResultPortableSchema,
166
+ AgentStructuredOutputNonJsonResultSchema
167
+ } from "./structuredOutput.js";
155
168
  export {
156
169
  AgentApprovalCapabilitySchema,
157
170
  AgentApprovalConsequenceSchema,
@@ -219,6 +232,8 @@ export {
219
232
  AgentOperationInvocationIdSchema,
220
233
  AgentOperationInvocationSchema,
221
234
  AgentOperationResultSchema,
235
+ AgentOutputSchemaPortableSchema,
236
+ AgentOutputSchemaSchema,
222
237
  AgentPlanStepSchema,
223
238
  AgentProviderConversationIdSchema,
224
239
  AgentProviderHistoryAnchorSchema,
@@ -269,6 +284,14 @@ export {
269
284
  AgentSessionResponseSchema,
270
285
  AgentSessionResumeInputSchema,
271
286
  AgentSessionWorkspaceTargetSchema,
287
+ AgentStructuredOutputCapabilityPortableSchema,
288
+ AgentStructuredOutputCapabilitySchema,
289
+ AgentStructuredOutputNonJsonResultPortableSchema,
290
+ AgentStructuredOutputNonJsonResultSchema,
291
+ AgentStructuredOutputRequestPortableSchema,
292
+ AgentStructuredOutputRequestSchema,
293
+ AgentStructuredOutputResultPortableSchema,
294
+ AgentStructuredOutputResultSchema,
272
295
  AgentTurnCompletedPayloadSchema,
273
296
  AgentTurnIdSchema,
274
297
  AgentTurnInputContentCompositionSchema,
@@ -277,5 +300,6 @@ export {
277
300
  AgentTurnInteractionModeSchema,
278
301
  AgentTurnInterruptionInputSchema,
279
302
  AgentTurnRunInputSchema,
280
- AgentWebSearchDetailsSchema
303
+ AgentWebSearchDetailsSchema,
304
+ zodOutput
281
305
  };
@@ -80,9 +80,9 @@ declare const AgentOperationDescriptorPortableSchema: z.ZodReadonly<z.ZodObject<
80
80
  title: z.ZodString;
81
81
  description: z.ZodOptional<z.ZodString>;
82
82
  context: z.ZodEnum<{
83
+ turn: "turn";
83
84
  session: "session";
84
85
  workspace: "workspace";
85
- turn: "turn";
86
86
  collaboration: "collaboration";
87
87
  resource: "resource";
88
88
  }>;
@@ -194,9 +194,9 @@ export declare const AgentOperationCatalogPortableSchema: z.ZodReadonly<z.ZodObj
194
194
  title: z.ZodString;
195
195
  description: z.ZodOptional<z.ZodString>;
196
196
  context: z.ZodEnum<{
197
+ turn: "turn";
197
198
  session: "session";
198
199
  workspace: "workspace";
199
- turn: "turn";
200
200
  collaboration: "collaboration";
201
201
  resource: "resource";
202
202
  }>;
@@ -0,0 +1,4 @@
1
+ import * as core from 'zod/v4/core';
2
+ import { type AgentOutputDefinition } from '../structuredOutput/definition.js';
3
+ export declare function zodOutput<S extends core.$ZodType>(schema: S): AgentOutputDefinition<core.output<S>>;
4
+ //# sourceMappingURL=outputDefinition.d.ts.map
@@ -0,0 +1,22 @@
1
+ import { normalizeValidationIssues } from "@agen-ai/validation";
2
+ import * as core from "zod/v4/core";
3
+ import { createAgentOutputDefinition } from "../structuredOutput/definition.js";
4
+ import { StructuredOutputIssues } from "../structuredOutput/issues.js";
5
+ import { emitZodOutputSchema } from "./outputSchema.js";
6
+ function zodOutput(schema) {
7
+ return createAgentOutputDefinition(emitZodOutputSchema(schema), (value) => {
8
+ const parsed = core.safeParse(schema, value);
9
+ if (parsed.success) return { success: true, data: parsed.data };
10
+ const bounded = new StructuredOutputIssues();
11
+ for (const issue of parsed.error.issues) {
12
+ if (bounded.full) break;
13
+ for (const normalized of normalizeValidationIssues([issue], value)) {
14
+ bounded.add(normalized.code, normalized.message, normalized.path);
15
+ }
16
+ }
17
+ return { success: false, issues: bounded.issues };
18
+ });
19
+ }
20
+ export {
21
+ zodOutput
22
+ };
@@ -0,0 +1,4 @@
1
+ import * as core from 'zod/v4/core';
2
+ import type { AgentOutputSchema } from '../structuredOutput/types.js';
3
+ export declare function emitZodOutputSchema(root: core.$ZodType): AgentOutputSchema;
4
+ //# sourceMappingURL=outputSchema.d.ts.map