@agen-ai/agent-protocol 0.3.1 → 0.4.1

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 (50) hide show
  1. package/README.md +114 -13
  2. package/dist/capabilities/types.d.ts +6 -1
  3. package/dist/events/types.d.ts +12 -4
  4. package/dist/events/types.js +1 -0
  5. package/dist/failures/index.d.ts +3 -0
  6. package/dist/failures/index.js +2 -0
  7. package/dist/failures/parsers.d.ts +5 -0
  8. package/dist/failures/parsers.js +12 -0
  9. package/dist/failures/types.d.ts +41 -0
  10. package/dist/failures/types.js +21 -0
  11. package/dist/foundation/parsers.d.ts +2 -3
  12. package/dist/foundation/parsers.js +1 -7
  13. package/dist/foundation/types.d.ts +2 -12
  14. package/dist/foundation/types.js +1 -1
  15. package/dist/jsonSchema/generated.d.ts +5519 -3498
  16. package/dist/jsonSchema/generated.js +4038 -2645
  17. package/dist/public/index.d.ts +2 -0
  18. package/dist/public/index.js +2 -0
  19. package/dist/public/sessionInteractions.d.ts +2 -0
  20. package/dist/public/sessionInteractions.js +1 -0
  21. package/dist/requests/types.d.ts +17 -4
  22. package/dist/sessionInteractions/index.d.ts +3 -0
  23. package/dist/sessionInteractions/index.js +2 -0
  24. package/dist/sessionInteractions/parsers.d.ts +10 -0
  25. package/dist/sessionInteractions/parsers.js +48 -0
  26. package/dist/sessionInteractions/types.d.ts +50 -0
  27. package/dist/sessionInteractions/types.js +18 -0
  28. package/dist/zod/accountQuota.d.ts +8 -0
  29. package/dist/zod/accountQuota.js +7 -5
  30. package/dist/zod/capabilities.d.ts +75 -9
  31. package/dist/zod/capabilities.js +32 -30
  32. package/dist/zod/collaboration.js +1 -1
  33. package/dist/zod/events.d.ts +68 -45
  34. package/dist/zod/events.js +17 -3
  35. package/dist/zod/failures.d.ts +23 -0
  36. package/dist/zod/failures.js +76 -0
  37. package/dist/zod/foundation.d.ts +2 -7
  38. package/dist/zod/foundation.js +15 -15
  39. package/dist/zod/index.d.ts +4 -2
  40. package/dist/zod/index.js +28 -2
  41. package/dist/zod/operations.d.ts +4 -4
  42. package/dist/zod/operations.js +1 -1
  43. package/dist/zod/requests.d.ts +79 -28
  44. package/dist/zod/requests.js +15 -2
  45. package/dist/zod/resources.js +1 -1
  46. package/dist/zod/sessionInteractions.d.ts +55 -0
  47. package/dist/zod/sessionInteractions.js +114 -0
  48. package/dist/zod/turns.js +1 -1
  49. package/dist/zod/typeEquality.generated.d.ts +36 -8
  50. package/package.json +6 -2
@@ -1,6 +1,8 @@
1
1
  export * from '../foundation/index.js';
2
+ export * from '../failures/index.js';
2
3
  export * from '../accountQuota/index.js';
3
4
  export * from '../sessions/index.js';
5
+ export * from '../sessionInteractions/index.js';
4
6
  export * from '../turns/index.js';
5
7
  export * from '../requests/index.js';
6
8
  export * from '../operations/index.js';
@@ -1,6 +1,8 @@
1
1
  export * from "../foundation/index.js";
2
+ export * from "../failures/index.js";
2
3
  export * from "../accountQuota/index.js";
3
4
  export * from "../sessions/index.js";
5
+ export * from "../sessionInteractions/index.js";
4
6
  export * from "../turns/index.js";
5
7
  export * from "../requests/index.js";
6
8
  export * from "../operations/index.js";
@@ -0,0 +1,2 @@
1
+ export * from '../sessionInteractions/index.js';
2
+ //# sourceMappingURL=sessionInteractions.d.ts.map
@@ -0,0 +1 @@
1
+ export * from "../sessionInteractions/index.js";
@@ -22,15 +22,28 @@ export type AgentApprovalSubject = (AgentApprovalSubjectBase & Readonly<{
22
22
  kind: 'command' | 'file_change' | 'tool' | 'other';
23
23
  itemId: AgentItemId;
24
24
  }>);
25
+ export type AgentApprovalConsequence = Readonly<{
26
+ kind: 'scoped';
27
+ persistence: AgentApprovalPersistence;
28
+ scope: Readonly<{
29
+ kind: AgentApprovalScopeKind;
30
+ }>;
31
+ }> | Readonly<{
32
+ kind: 'provider_managed_remembrance';
33
+ duration: Readonly<{
34
+ kind: 'unknown';
35
+ }>;
36
+ applicability: Readonly<{
37
+ kind: 'unknown';
38
+ }>;
39
+ explanation: string;
40
+ }>;
25
41
  export interface AgentApprovalOption {
26
42
  readonly optionId: AgentApprovalOptionId;
27
43
  readonly label: string;
28
44
  readonly description?: string;
29
45
  readonly decision: 'approved' | 'denied';
30
- readonly persistence: AgentApprovalPersistence;
31
- readonly scope: Readonly<{
32
- kind: AgentApprovalScopeKind;
33
- }>;
46
+ readonly consequence: AgentApprovalConsequence;
34
47
  }
35
48
  export interface AgentApprovalRequest {
36
49
  readonly requestKind: 'approval';
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './parsers.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from "./types.js";
2
+ export * from "./parsers.js";
@@ -0,0 +1,10 @@
1
+ import { type AgentProtocolParseResult } from '../foundation/index.js';
2
+ import type { AgentSessionDecisionChoiceId, AgentSessionDecisionRequest, AgentSessionDecisionResponse } from './types.js';
3
+ export declare function parseAgentSessionDecisionChoiceId(input: unknown): AgentSessionDecisionChoiceId;
4
+ export declare function safeParseAgentSessionDecisionChoiceId(input: unknown): AgentProtocolParseResult<AgentSessionDecisionChoiceId>;
5
+ export declare function parseAgentSessionDecisionRequest(input: unknown): AgentSessionDecisionRequest;
6
+ export declare function safeParseAgentSessionDecisionRequest(input: unknown): AgentProtocolParseResult<AgentSessionDecisionRequest>;
7
+ export declare function parseAgentSessionDecisionResponse(input: unknown): AgentSessionDecisionResponse;
8
+ export declare function safeParseAgentSessionDecisionResponse(input: unknown): AgentProtocolParseResult<AgentSessionDecisionResponse>;
9
+ export declare function parseAgentSessionDecisionResponseFor(request: AgentSessionDecisionRequest, input: unknown): AgentSessionDecisionResponse;
10
+ //# sourceMappingURL=parsers.d.ts.map
@@ -0,0 +1,48 @@
1
+ import {
2
+ AgentProtocolValidationError
3
+ } from "../foundation/index.js";
4
+ import { parseWithSchema, safeParseWithSchema } from "../internal/parsers.js";
5
+ import {
6
+ AgentSessionDecisionChoiceIdSchema,
7
+ AgentSessionDecisionRequestSchema,
8
+ AgentSessionDecisionResponseSchema
9
+ } from "../zod/sessionInteractions.js";
10
+ function parseAgentSessionDecisionChoiceId(input) {
11
+ return parseWithSchema(AgentSessionDecisionChoiceIdSchema, input);
12
+ }
13
+ function safeParseAgentSessionDecisionChoiceId(input) {
14
+ return safeParseWithSchema(AgentSessionDecisionChoiceIdSchema, input);
15
+ }
16
+ function parseAgentSessionDecisionRequest(input) {
17
+ return parseWithSchema(AgentSessionDecisionRequestSchema, input);
18
+ }
19
+ function safeParseAgentSessionDecisionRequest(input) {
20
+ return safeParseWithSchema(AgentSessionDecisionRequestSchema, input);
21
+ }
22
+ function parseAgentSessionDecisionResponse(input) {
23
+ return parseWithSchema(AgentSessionDecisionResponseSchema, input);
24
+ }
25
+ function safeParseAgentSessionDecisionResponse(input) {
26
+ return safeParseWithSchema(AgentSessionDecisionResponseSchema, input);
27
+ }
28
+ function parseAgentSessionDecisionResponseFor(request, input) {
29
+ const parsedRequest = parseAgentSessionDecisionRequest(request);
30
+ const response = parseAgentSessionDecisionResponse(input);
31
+ if (!parsedRequest.choices.some((choice) => choice.choiceId === response.choiceId)) {
32
+ throw new AgentProtocolValidationError([{
33
+ code: "custom",
34
+ path: ["choiceId"],
35
+ message: "The response must select a choice offered by this session decision."
36
+ }]);
37
+ }
38
+ return response;
39
+ }
40
+ export {
41
+ parseAgentSessionDecisionChoiceId,
42
+ parseAgentSessionDecisionRequest,
43
+ parseAgentSessionDecisionResponse,
44
+ parseAgentSessionDecisionResponseFor,
45
+ safeParseAgentSessionDecisionChoiceId,
46
+ safeParseAgentSessionDecisionRequest,
47
+ safeParseAgentSessionDecisionResponse
48
+ };
@@ -0,0 +1,50 @@
1
+ import type { AgentIsoDateTime, AgentRequestId, AgentSessionId } from '../foundation/index.js';
2
+ declare const agentSessionDecisionChoiceIdBrand: unique symbol;
3
+ export type AgentSessionDecisionChoiceId = string & {
4
+ readonly [agentSessionDecisionChoiceIdBrand]: 'AgentSessionDecisionChoiceId';
5
+ };
6
+ export interface AgentSessionWorkspaceTarget {
7
+ readonly kind: 'workspace';
8
+ readonly path: string;
9
+ }
10
+ export type AgentSessionDecisionConsequence = Readonly<{
11
+ kind: 'grant';
12
+ scope: 'workspace';
13
+ persistence: Readonly<{
14
+ kind: 'provider_managed';
15
+ duration: 'persistent';
16
+ mayAffectOtherSessions: true;
17
+ }>;
18
+ }> | Readonly<{
19
+ kind: 'decline';
20
+ configuration: 'remains_gated';
21
+ }>;
22
+ export interface AgentSessionDecisionChoice {
23
+ readonly choiceId: AgentSessionDecisionChoiceId;
24
+ readonly label: string;
25
+ readonly description: string;
26
+ readonly consequence: AgentSessionDecisionConsequence;
27
+ }
28
+ export interface AgentSessionDecisionRequest {
29
+ readonly kind: 'decision';
30
+ readonly requestId: AgentRequestId;
31
+ readonly sessionId: AgentSessionId;
32
+ readonly title: string;
33
+ readonly description?: string;
34
+ readonly target: AgentSessionWorkspaceTarget;
35
+ readonly expiresAt: AgentIsoDateTime;
36
+ readonly choices: readonly [AgentSessionDecisionChoice, ...AgentSessionDecisionChoice[]];
37
+ }
38
+ export interface AgentSessionDecisionResponse {
39
+ readonly choiceId: AgentSessionDecisionChoiceId;
40
+ }
41
+ export declare const AGENT_SESSION_DECISION_REQUEST_BYTES_LIMIT = 65536;
42
+ export declare const AGENT_SESSION_DECISION_RESPONSE_BYTES_LIMIT = 1024;
43
+ export declare const AGENT_SESSION_DECISION_CHOICES_MAX_LENGTH = 16;
44
+ export declare const AGENT_SESSION_DECISION_CHOICE_ID_BYTES_LIMIT = 128;
45
+ export declare const AGENT_SESSION_DECISION_TITLE_MAX_LENGTH = 120;
46
+ export declare const AGENT_SESSION_DECISION_DESCRIPTION_MAX_LENGTH = 4000;
47
+ export declare const AGENT_SESSION_DECISION_CHOICE_DESCRIPTION_MAX_LENGTH = 1000;
48
+ export declare const AGENT_SESSION_DECISION_WORKSPACE_PATH_BYTES_LIMIT = 4096;
49
+ export {};
50
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,18 @@
1
+ const AGENT_SESSION_DECISION_REQUEST_BYTES_LIMIT = 65536;
2
+ const AGENT_SESSION_DECISION_RESPONSE_BYTES_LIMIT = 1024;
3
+ const AGENT_SESSION_DECISION_CHOICES_MAX_LENGTH = 16;
4
+ const AGENT_SESSION_DECISION_CHOICE_ID_BYTES_LIMIT = 128;
5
+ const AGENT_SESSION_DECISION_TITLE_MAX_LENGTH = 120;
6
+ const AGENT_SESSION_DECISION_DESCRIPTION_MAX_LENGTH = 4e3;
7
+ const AGENT_SESSION_DECISION_CHOICE_DESCRIPTION_MAX_LENGTH = 1e3;
8
+ const AGENT_SESSION_DECISION_WORKSPACE_PATH_BYTES_LIMIT = 4096;
9
+ export {
10
+ AGENT_SESSION_DECISION_CHOICES_MAX_LENGTH,
11
+ AGENT_SESSION_DECISION_CHOICE_DESCRIPTION_MAX_LENGTH,
12
+ AGENT_SESSION_DECISION_CHOICE_ID_BYTES_LIMIT,
13
+ AGENT_SESSION_DECISION_DESCRIPTION_MAX_LENGTH,
14
+ AGENT_SESSION_DECISION_REQUEST_BYTES_LIMIT,
15
+ AGENT_SESSION_DECISION_RESPONSE_BYTES_LIMIT,
16
+ AGENT_SESSION_DECISION_TITLE_MAX_LENGTH,
17
+ AGENT_SESSION_DECISION_WORKSPACE_PATH_BYTES_LIMIT
18
+ };
@@ -58,6 +58,14 @@ export declare const AgentAccountQuotaMeasurementSchema: z.ZodDiscriminatedUnion
58
58
  remainingMinorUnits: z.ZodOptional<z.ZodNumber>;
59
59
  usedPercent: z.ZodOptional<z.ZodNumber>;
60
60
  }, z.core.$strict>>], "kind">;
61
+ export declare const AgentAccountQuotaResetSchema: z.ZodReadonly<z.ZodObject<{
62
+ at: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
63
+ precision: z.ZodEnum<{
64
+ reported: "reported";
65
+ estimated: "estimated";
66
+ }>;
67
+ observedAt: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
68
+ }, z.core.$strict>>;
61
69
  export declare const AgentAccountQuotaWindowPortableSchema: z.ZodReadonly<z.ZodObject<{
62
70
  poolId: z.ZodString;
63
71
  windowId: z.ZodString;
@@ -61,6 +61,11 @@ const AgentAccountQuotaMeasurementSchema = z.discriminatedUnion("kind", [
61
61
  usedPercent: NonnegativeQuantitySchema.optional()
62
62
  }).strict().readonly()
63
63
  ]);
64
+ const AgentAccountQuotaResetSchema = z.object({
65
+ at: AgentIsoDateTimeSchema,
66
+ precision: z.enum(["reported", "estimated"]),
67
+ observedAt: AgentIsoDateTimeSchema
68
+ }).strict().readonly();
64
69
  const AgentAccountQuotaWindowPortableSchema = z.object({
65
70
  poolId: AgentCanonicalIdValueSchema,
66
71
  windowId: AgentCanonicalIdValueSchema,
@@ -71,11 +76,7 @@ const AgentAccountQuotaWindowPortableSchema = z.object({
71
76
  measurement: AgentAccountQuotaMeasurementSchema,
72
77
  observedAt: AgentIsoDateTimeSchema,
73
78
  startsAt: AgentIsoDateTimeSchema.optional(),
74
- reset: z.object({
75
- at: AgentIsoDateTimeSchema,
76
- precision: z.enum(["reported", "estimated"]),
77
- observedAt: AgentIsoDateTimeSchema
78
- }).strict().readonly().optional()
79
+ reset: AgentAccountQuotaResetSchema.optional()
79
80
  }).strict().readonly();
80
81
  function validateWindow(window, context, prefix = []) {
81
82
  if (window.applicability.kind === "models" && new Set(window.applicability.modelIds).size !== window.applicability.modelIds.length) {
@@ -148,6 +149,7 @@ export {
148
149
  AgentAccountQuotaApplicabilitySchema,
149
150
  AgentAccountQuotaMeasurementSchema,
150
151
  AgentAccountQuotaPeriodSchema,
152
+ AgentAccountQuotaResetSchema,
151
153
  AgentAccountQuotaSnapshotPortableSchema,
152
154
  AgentAccountQuotaSnapshotSchema,
153
155
  AgentAccountQuotaWindowPortableSchema,
@@ -1,14 +1,28 @@
1
1
  import { z } from 'zod/v4';
2
2
  import { type AgentCapabilities } from '../capabilities/types.js';
3
- export declare const AgentApprovalCapabilitySchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
3
+ export declare const AgentApprovalCapabilitySchema: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
4
4
  kind: z.ZodLiteral<"unsupported">;
5
5
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
6
6
  kind: z.ZodLiteral<"supported">;
7
- modes: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
7
+ modes: z.ZodReadonly<z.ZodTuple<[z.ZodReadonly<z.ZodObject<{
8
8
  persistence: z.ZodEnum<{
9
9
  session: "session";
10
+ workspace: "workspace";
10
11
  once: "once";
12
+ }>;
13
+ scopeKinds: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
14
+ exact_action: "exact_action";
15
+ command_pattern: "command_pattern";
16
+ domain: "domain";
17
+ tool: "tool";
18
+ server: "server";
19
+ all_edits: "all_edits";
20
+ }>>>;
21
+ }, z.core.$strict>>], z.ZodReadonly<z.ZodObject<{
22
+ persistence: z.ZodEnum<{
23
+ session: "session";
11
24
  workspace: "workspace";
25
+ once: "once";
12
26
  }>;
13
27
  scopeKinds: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
14
28
  exact_action: "exact_action";
@@ -19,7 +33,26 @@ export declare const AgentApprovalCapabilitySchema: z.ZodDiscriminatedUnion<[z.Z
19
33
  all_edits: "all_edits";
20
34
  }>>>;
21
35
  }, z.core.$strict>>>>;
22
- }, z.core.$strict>>], "kind">;
36
+ providerManagedRemembrance: z.ZodLiteral<false>;
37
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
38
+ kind: z.ZodLiteral<"supported">;
39
+ modes: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
40
+ persistence: z.ZodEnum<{
41
+ session: "session";
42
+ workspace: "workspace";
43
+ once: "once";
44
+ }>;
45
+ scopeKinds: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
46
+ exact_action: "exact_action";
47
+ command_pattern: "command_pattern";
48
+ domain: "domain";
49
+ tool: "tool";
50
+ server: "server";
51
+ all_edits: "all_edits";
52
+ }>>>;
53
+ }, z.core.$strict>>>>;
54
+ providerManagedRemembrance: z.ZodLiteral<true>;
55
+ }, z.core.$strict>>]>;
23
56
  export declare const AgentImageInputCapabilitySchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
24
57
  kind: z.ZodLiteral<"unsupported">;
25
58
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
@@ -106,7 +139,7 @@ export declare const AgentOperationInputCapabilitySchema: z.ZodReadonly<z.ZodObj
106
139
  }, z.core.$strict>>], "kind">;
107
140
  }, z.core.$strict>>;
108
141
  export declare const AgentCapabilitiesPortableSchema: z.ZodReadonly<z.ZodObject<{
109
- protocolVersion: z.ZodLiteral<9>;
142
+ protocolVersion: z.ZodLiteral<11>;
110
143
  providerKey: z.ZodType<import("../index.js").AgentProviderKey, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderKey, unknown>>;
111
144
  sessions: z.ZodReadonly<z.ZodObject<{
112
145
  create: z.ZodLiteral<true>;
@@ -174,15 +207,47 @@ export declare const AgentCapabilitiesPortableSchema: z.ZodReadonly<z.ZodObject<
174
207
  }, z.core.$strict>>], "kind">;
175
208
  }, z.core.$strict>>;
176
209
  requests: z.ZodReadonly<z.ZodObject<{
177
- approval: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
210
+ approval: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
178
211
  kind: z.ZodLiteral<"unsupported">;
179
212
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
180
213
  kind: z.ZodLiteral<"supported">;
181
- modes: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
214
+ modes: z.ZodReadonly<z.ZodTuple<[z.ZodReadonly<z.ZodObject<{
215
+ persistence: z.ZodEnum<{
216
+ session: "session";
217
+ workspace: "workspace";
218
+ once: "once";
219
+ }>;
220
+ scopeKinds: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
221
+ exact_action: "exact_action";
222
+ command_pattern: "command_pattern";
223
+ domain: "domain";
224
+ tool: "tool";
225
+ server: "server";
226
+ all_edits: "all_edits";
227
+ }>>>;
228
+ }, z.core.$strict>>], z.ZodReadonly<z.ZodObject<{
182
229
  persistence: z.ZodEnum<{
183
230
  session: "session";
231
+ workspace: "workspace";
184
232
  once: "once";
233
+ }>;
234
+ scopeKinds: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
235
+ exact_action: "exact_action";
236
+ command_pattern: "command_pattern";
237
+ domain: "domain";
238
+ tool: "tool";
239
+ server: "server";
240
+ all_edits: "all_edits";
241
+ }>>>;
242
+ }, z.core.$strict>>>>;
243
+ providerManagedRemembrance: z.ZodLiteral<false>;
244
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
245
+ kind: z.ZodLiteral<"supported">;
246
+ modes: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
247
+ persistence: z.ZodEnum<{
248
+ session: "session";
185
249
  workspace: "workspace";
250
+ once: "once";
186
251
  }>;
187
252
  scopeKinds: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
188
253
  exact_action: "exact_action";
@@ -193,7 +258,8 @@ export declare const AgentCapabilitiesPortableSchema: z.ZodReadonly<z.ZodObject<
193
258
  all_edits: "all_edits";
194
259
  }>>>;
195
260
  }, z.core.$strict>>>>;
196
- }, z.core.$strict>>], "kind">;
261
+ providerManagedRemembrance: z.ZodLiteral<true>;
262
+ }, z.core.$strict>>]>;
197
263
  elicitation: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
198
264
  kind: z.ZodLiteral<"unsupported">;
199
265
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
@@ -234,10 +300,10 @@ export declare const AgentCapabilitiesPortableSchema: z.ZodReadonly<z.ZodObject<
234
300
  kind: z.ZodLiteral<"supported">;
235
301
  triggers: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
236
302
  unknown: "unknown";
237
- automatic: "automatic";
238
- manual: "manual";
239
303
  context_limit: "context_limit";
240
304
  recovery: "recovery";
305
+ automatic: "automatic";
306
+ manual: "manual";
241
307
  }>>>;
242
308
  sameSessionContinuation: z.ZodBoolean;
243
309
  }, z.core.$strict>>], "kind">;
@@ -80,39 +80,41 @@ const PositiveSafeIntegerSchema = z.number().int().positive().max(Number.MAX_SAF
80
80
  function boundedPositiveSafeInteger(maximum) {
81
81
  return z.number().int().positive().max(maximum);
82
82
  }
83
- const AgentApprovalCapabilitySchema = z.discriminatedUnion("kind", [
83
+ const AgentApprovalCapabilityModeSchema = z.object({
84
+ persistence: z.enum(AGENT_APPROVAL_PERSISTENCES),
85
+ scopeKinds: z.array(z.enum(AGENT_APPROVAL_SCOPE_KINDS)).min(1).max(AGENT_APPROVAL_SCOPE_KINDS.length).meta({ uniqueItems: true }).readonly()
86
+ }).strict().readonly();
87
+ const AgentApprovalCapabilitySchema = z.union([
84
88
  z.object({ kind: z.literal("unsupported") }).strict().readonly(),
85
89
  z.object({
86
90
  kind: z.literal("supported"),
87
- modes: z.array(
88
- z.object({
89
- persistence: z.enum(AGENT_APPROVAL_PERSISTENCES),
90
- scopeKinds: z.array(z.enum(AGENT_APPROVAL_SCOPE_KINDS)).min(1).max(AGENT_APPROVAL_SCOPE_KINDS.length).meta({ uniqueItems: true }).readonly()
91
- }).strict().readonly()
92
- ).min(1).max(AGENT_APPROVAL_PERSISTENCES.length).readonly()
93
- }).strict().superRefine((capability, context) => {
94
- addCanonicalListIssues(
95
- {
96
- values: capability.modes.map((mode) => mode.persistence),
97
- canonicalOrder: AGENT_APPROVAL_PERSISTENCES,
98
- path: ["modes"],
99
- label: "Approval persistence modes"
100
- },
101
- context
102
- );
103
- capability.modes.forEach((mode, index) => {
104
- addCanonicalListIssues(
105
- {
106
- values: mode.scopeKinds,
107
- canonicalOrder: AGENT_APPROVAL_SCOPE_KINDS,
108
- path: ["modes", index, "scopeKinds"],
109
- label: "Approval scope kinds"
110
- },
111
- context
112
- );
113
- });
114
- }).readonly()
115
- ]);
91
+ modes: z.tuple([AgentApprovalCapabilityModeSchema]).rest(AgentApprovalCapabilityModeSchema).refine((modes) => modes.length <= AGENT_APPROVAL_PERSISTENCES.length, {
92
+ message: "Approval modes must contain at most three precise persistences."
93
+ }).meta({ minItems: 1, maxItems: AGENT_APPROVAL_PERSISTENCES.length }).readonly(),
94
+ providerManagedRemembrance: z.literal(false)
95
+ }).strict().readonly(),
96
+ z.object({
97
+ kind: z.literal("supported"),
98
+ modes: z.array(AgentApprovalCapabilityModeSchema).max(AGENT_APPROVAL_PERSISTENCES.length).readonly(),
99
+ providerManagedRemembrance: z.literal(true)
100
+ }).strict().readonly()
101
+ ]).superRefine((capability, context) => {
102
+ if (capability.kind === "unsupported") return;
103
+ addCanonicalListIssues({
104
+ values: capability.modes.map((mode) => mode.persistence),
105
+ canonicalOrder: AGENT_APPROVAL_PERSISTENCES,
106
+ path: ["modes"],
107
+ label: "Approval persistence modes"
108
+ }, context);
109
+ capability.modes.forEach((mode, index) => {
110
+ addCanonicalListIssues({
111
+ values: mode.scopeKinds,
112
+ canonicalOrder: AGENT_APPROVAL_SCOPE_KINDS,
113
+ path: ["modes", index, "scopeKinds"],
114
+ label: "Approval scope kinds"
115
+ }, context);
116
+ });
117
+ });
116
118
  const AgentContextUsageCapabilitySchema = z.discriminatedUnion("kind", [
117
119
  z.object({ kind: z.literal("unsupported") }).strict().readonly(),
118
120
  z.object({
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod/v4";
2
+ import { AgentErrorSchema } from "./failures.js";
2
3
  import { compareStringsByUnicodeCodePoint } from "../foundation/ordering.js";
3
4
  import {
4
5
  AGENT_COLLABORATION_OBJECTIVE_MAX_LENGTH,
@@ -13,7 +14,6 @@ import {
13
14
  import {
14
15
  AgentArtifactIdSchema,
15
16
  AgentCollaborationIdSchema,
16
- AgentErrorSchema,
17
17
  AgentGeneratedResourceIdSchema,
18
18
  AgentIsoDateTimeSchema,
19
19
  createAgentCanonicalNonBlankStringSchema