@agen-ai/agent-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.
@@ -1,9 +1,13 @@
1
1
  import { type AgentProtocolParseResult } from '../foundation/index.js';
2
- import type { AgentRequest, AgentRequestResolution } from './types.js';
2
+ import type { AgentApprovalRequest, AgentApprovalResolution, AgentRequest, AgentRequestResolution } from './types.js';
3
3
  export declare function parseAgentRequest(input: unknown): AgentRequest;
4
+ export declare function parseAgentApprovalRequest(input: unknown): AgentApprovalRequest;
5
+ export declare function safeParseAgentApprovalRequest(input: unknown): AgentProtocolParseResult<AgentApprovalRequest>;
4
6
  export declare function safeParseAgentRequest(input: unknown): AgentProtocolParseResult<AgentRequest>;
5
7
  export declare function parseAgentRequestResolution(input: unknown): AgentRequestResolution;
6
8
  export declare function safeParseAgentRequestResolution(input: unknown): AgentProtocolParseResult<AgentRequestResolution>;
9
+ export declare function parseAgentApprovalResolution(input: unknown): AgentApprovalResolution;
10
+ export declare function safeParseAgentApprovalResolution(input: unknown): AgentProtocolParseResult<AgentApprovalResolution>;
7
11
  export declare function safeParseAgentRequestResolutionFor(requestInput: unknown, resolutionInput: unknown): AgentProtocolParseResult<AgentRequestResolution>;
8
12
  export declare function parseAgentRequestResolutionFor(requestInput: unknown, resolutionInput: unknown): AgentRequestResolution;
9
13
  //# sourceMappingURL=parsers.d.ts.map
@@ -3,12 +3,20 @@ import {
3
3
  } from "../foundation/index.js";
4
4
  import { parseWithSchema, safeParseWithSchema } from "../internal/parsers.js";
5
5
  import {
6
+ AgentApprovalRequestSchema,
7
+ AgentApprovalResolutionSchema,
6
8
  AgentRequestResolutionSchema,
7
9
  AgentRequestSchema
8
10
  } from "../zod/requests.js";
9
11
  function parseAgentRequest(input) {
10
12
  return parseWithSchema(AgentRequestSchema, input);
11
13
  }
14
+ function parseAgentApprovalRequest(input) {
15
+ return parseWithSchema(AgentApprovalRequestSchema, input);
16
+ }
17
+ function safeParseAgentApprovalRequest(input) {
18
+ return safeParseWithSchema(AgentApprovalRequestSchema, input);
19
+ }
12
20
  function safeParseAgentRequest(input) {
13
21
  return safeParseWithSchema(AgentRequestSchema, input);
14
22
  }
@@ -18,6 +26,12 @@ function parseAgentRequestResolution(input) {
18
26
  function safeParseAgentRequestResolution(input) {
19
27
  return safeParseWithSchema(AgentRequestResolutionSchema, input);
20
28
  }
29
+ function parseAgentApprovalResolution(input) {
30
+ return parseWithSchema(AgentApprovalResolutionSchema, input);
31
+ }
32
+ function safeParseAgentApprovalResolution(input) {
33
+ return safeParseWithSchema(AgentApprovalResolutionSchema, input);
34
+ }
21
35
  function issue(path, message) {
22
36
  return { code: "custom", path, message };
23
37
  }
@@ -77,6 +91,14 @@ function resolutionIssues(request, resolution) {
77
91
  "Resolution requestId must match the opened request."
78
92
  ));
79
93
  }
94
+ if (request.requestKind === "approval" && resolution.requestKind === "approval" && resolution.disposition === "selected" && !request.options.some(
95
+ (option) => option.optionId === resolution.optionId
96
+ )) {
97
+ issues.push(issue(
98
+ ["optionId"],
99
+ "Approval resolution must select an option declared by the request."
100
+ ));
101
+ }
80
102
  if (request.requestKind !== "elicitation" || resolution.requestKind !== "elicitation" || resolution.disposition !== "answered") {
81
103
  return issues;
82
104
  }
@@ -125,9 +147,13 @@ function parseAgentRequestResolutionFor(requestInput, resolutionInput) {
125
147
  throw new AgentProtocolValidationError(parsed.issues);
126
148
  }
127
149
  export {
150
+ parseAgentApprovalRequest,
151
+ parseAgentApprovalResolution,
128
152
  parseAgentRequest,
129
153
  parseAgentRequestResolution,
130
154
  parseAgentRequestResolutionFor,
155
+ safeParseAgentApprovalRequest,
156
+ safeParseAgentApprovalResolution,
131
157
  safeParseAgentRequest,
132
158
  safeParseAgentRequestResolution,
133
159
  safeParseAgentRequestResolutionFor
@@ -1,4 +1,11 @@
1
- import type { AgentArtifactId, AgentIsoDateTime, AgentRequestFieldId, AgentRequestId } from '../foundation/index.js';
1
+ import type { AgentApprovalOptionId, AgentArtifactId, AgentIsoDateTime, AgentItemId, AgentRequestFieldId, AgentRequestId } from '../foundation/index.js';
2
+ export declare const AGENT_APPROVAL_PERSISTENCES: readonly ["once", "session", "workspace"];
3
+ export declare const AGENT_APPROVAL_SCOPE_KINDS: readonly ["exact_action", "command_pattern", "domain", "tool", "server", "all_edits"];
4
+ export declare const AGENT_APPROVAL_OPTIONS_MAX_LENGTH = 16;
5
+ export declare const AGENT_APPROVAL_LABEL_MAX_LENGTH = 120;
6
+ export declare const AGENT_APPROVAL_DESCRIPTION_MAX_LENGTH = 1000;
7
+ export type AgentApprovalPersistence = (typeof AGENT_APPROVAL_PERSISTENCES)[number];
8
+ export type AgentApprovalScopeKind = (typeof AGENT_APPROVAL_SCOPE_KINDS)[number];
2
9
  interface AgentApprovalSubjectBase {
3
10
  readonly title: string;
4
11
  readonly description?: string;
@@ -8,13 +15,24 @@ export type AgentApprovalSubject = (AgentApprovalSubjectBase & Readonly<{
8
15
  artifactId: AgentArtifactId;
9
16
  }>) | (AgentApprovalSubjectBase & Readonly<{
10
17
  kind: 'command' | 'file_change' | 'tool' | 'other';
11
- artifactId?: never;
18
+ itemId: AgentItemId;
12
19
  }>);
20
+ export interface AgentApprovalOption {
21
+ readonly optionId: AgentApprovalOptionId;
22
+ readonly label: string;
23
+ readonly description?: string;
24
+ readonly decision: 'approved' | 'denied';
25
+ readonly persistence: AgentApprovalPersistence;
26
+ readonly scope: Readonly<{
27
+ kind: AgentApprovalScopeKind;
28
+ }>;
29
+ }
13
30
  export interface AgentApprovalRequest {
14
31
  readonly requestKind: 'approval';
15
32
  readonly requestId: AgentRequestId;
16
33
  readonly prompt: string;
17
34
  readonly subject: AgentApprovalSubject;
35
+ readonly options: readonly AgentApprovalOption[];
18
36
  readonly expiresAt?: AgentIsoDateTime;
19
37
  }
20
38
  export interface AgentRequestChoice {
@@ -50,11 +68,16 @@ export interface AgentElicitationRequest {
50
68
  readonly expiresAt?: AgentIsoDateTime;
51
69
  }
52
70
  export type AgentRequest = AgentApprovalRequest | AgentElicitationRequest;
53
- export interface AgentApprovalResolution {
54
- readonly requestKind: 'approval';
55
- readonly requestId: AgentRequestId;
56
- readonly decision: 'approved' | 'denied' | 'canceled';
57
- }
71
+ export type AgentApprovalResolution = Readonly<{
72
+ requestKind: 'approval';
73
+ requestId: AgentRequestId;
74
+ disposition: 'selected';
75
+ optionId: AgentApprovalOptionId;
76
+ }> | Readonly<{
77
+ requestKind: 'approval';
78
+ requestId: AgentRequestId;
79
+ disposition: 'canceled';
80
+ }>;
58
81
  export interface AgentTextElicitationAnswer {
59
82
  readonly fieldId: AgentRequestFieldId;
60
83
  readonly kind: 'text';
@@ -0,0 +1,23 @@
1
+ const AGENT_APPROVAL_PERSISTENCES = [
2
+ "once",
3
+ "session",
4
+ "workspace"
5
+ ];
6
+ const AGENT_APPROVAL_SCOPE_KINDS = [
7
+ "exact_action",
8
+ "command_pattern",
9
+ "domain",
10
+ "tool",
11
+ "server",
12
+ "all_edits"
13
+ ];
14
+ const AGENT_APPROVAL_OPTIONS_MAX_LENGTH = 16;
15
+ const AGENT_APPROVAL_LABEL_MAX_LENGTH = 120;
16
+ const AGENT_APPROVAL_DESCRIPTION_MAX_LENGTH = 1e3;
17
+ export {
18
+ AGENT_APPROVAL_DESCRIPTION_MAX_LENGTH,
19
+ AGENT_APPROVAL_LABEL_MAX_LENGTH,
20
+ AGENT_APPROVAL_OPTIONS_MAX_LENGTH,
21
+ AGENT_APPROVAL_PERSISTENCES,
22
+ AGENT_APPROVAL_SCOPE_KINDS
23
+ };
@@ -54,6 +54,36 @@ export declare const AGENT_CONTENT_STREAM_KINDS: readonly ["assistant_text", "re
54
54
  export type AgentContentStreamKind = (typeof AGENT_CONTENT_STREAM_KINDS)[number];
55
55
  export type AgentTurnState = 'running' | 'waiting_for_request';
56
56
  export type AgentTurnOutcome = 'completed' | 'failed' | 'canceled' | 'expired';
57
+ export declare const AGENT_CONTEXT_MEASUREMENT_SCOPES: readonly ["session", "materialization"];
58
+ export declare const AGENT_CONTEXT_CUMULATIVE_USAGE_FIELDS: readonly ["inputTokens", "outputTokens", "cachedReadTokens", "cacheCreationTokens", "reasoningTokens", "modelCalls", "turns"];
59
+ export declare const AGENT_CONTEXT_COMPACTION_STATES: readonly ["idle", "approaching", "in_progress"];
60
+ export declare const AGENT_CONTEXT_COMPACTION_TRIGGERS: readonly ["automatic", "manual", "context_limit", "recovery", "unknown"];
61
+ export declare const AGENT_CONTEXT_COMPACTION_SUMMARY_PREVIEW_MAX_LENGTH = 500;
62
+ export declare const AGENT_CONTEXT_COMPACTION_DURATION_MAX_MILLISECONDS = 3600000;
63
+ export type AgentContextMeasurementScope = (typeof AGENT_CONTEXT_MEASUREMENT_SCOPES)[number];
64
+ export type AgentContextCumulativeUsageField = (typeof AGENT_CONTEXT_CUMULATIVE_USAGE_FIELDS)[number];
65
+ export type AgentContextCompactionState = (typeof AGENT_CONTEXT_COMPACTION_STATES)[number];
66
+ export type AgentContextCompactionTrigger = (typeof AGENT_CONTEXT_COMPACTION_TRIGGERS)[number];
67
+ export interface AgentContextCumulativeUsage {
68
+ readonly inputTokens?: number;
69
+ readonly outputTokens?: number;
70
+ readonly cachedReadTokens?: number;
71
+ readonly cacheCreationTokens?: number;
72
+ readonly reasoningTokens?: number;
73
+ readonly modelCalls?: number;
74
+ readonly turns?: number;
75
+ }
76
+ export interface AgentContextCompactionPressure {
77
+ readonly state: AgentContextCompactionState;
78
+ readonly thresholdTokens?: number;
79
+ }
80
+ export interface AgentContextUsage {
81
+ readonly measurementScope: AgentContextMeasurementScope;
82
+ readonly usedTokens: number;
83
+ readonly maxTokens: number;
84
+ readonly cumulative?: AgentContextCumulativeUsage;
85
+ readonly compaction?: AgentContextCompactionPressure;
86
+ }
57
87
  export interface AgentItemSnapshotBase {
58
88
  readonly itemId: AgentItemId;
59
89
  readonly status: AgentItemStatus;
@@ -74,6 +104,14 @@ export interface AgentPlanItemSnapshot extends AgentItemSnapshotBase {
74
104
  }
75
105
  export interface AgentContextCompactionItemSnapshot extends AgentItemSnapshotBase {
76
106
  readonly itemKind: 'context_compaction';
107
+ readonly details: AgentContextCompactionDetails;
108
+ }
109
+ export interface AgentContextCompactionDetails {
110
+ readonly trigger: AgentContextCompactionTrigger;
111
+ readonly beforeTokens?: number;
112
+ readonly afterTokens?: number;
113
+ readonly durationMs?: number;
114
+ readonly summaryPreview?: string;
77
115
  }
78
116
  export interface AgentUnknownItemSnapshot extends AgentItemSnapshotBase {
79
117
  readonly itemKind: 'unknown';
@@ -44,6 +44,33 @@ const AGENT_CONTENT_STREAM_KINDS = [
44
44
  "file_change_output",
45
45
  "unknown"
46
46
  ];
47
+ const AGENT_CONTEXT_MEASUREMENT_SCOPES = [
48
+ "session",
49
+ "materialization"
50
+ ];
51
+ const AGENT_CONTEXT_CUMULATIVE_USAGE_FIELDS = [
52
+ "inputTokens",
53
+ "outputTokens",
54
+ "cachedReadTokens",
55
+ "cacheCreationTokens",
56
+ "reasoningTokens",
57
+ "modelCalls",
58
+ "turns"
59
+ ];
60
+ const AGENT_CONTEXT_COMPACTION_STATES = [
61
+ "idle",
62
+ "approaching",
63
+ "in_progress"
64
+ ];
65
+ const AGENT_CONTEXT_COMPACTION_TRIGGERS = [
66
+ "automatic",
67
+ "manual",
68
+ "context_limit",
69
+ "recovery",
70
+ "unknown"
71
+ ];
72
+ const AGENT_CONTEXT_COMPACTION_SUMMARY_PREVIEW_MAX_LENGTH = 500;
73
+ const AGENT_CONTEXT_COMPACTION_DURATION_MAX_MILLISECONDS = 36e5;
47
74
  const AGENT_FILE_CHANGE_KINDS = [
48
75
  "created",
49
76
  "modified",
@@ -53,6 +80,12 @@ const AGENT_FILE_CHANGE_KINDS = [
53
80
  ];
54
81
  export {
55
82
  AGENT_CONTENT_STREAM_KINDS,
83
+ AGENT_CONTEXT_COMPACTION_DURATION_MAX_MILLISECONDS,
84
+ AGENT_CONTEXT_COMPACTION_STATES,
85
+ AGENT_CONTEXT_COMPACTION_SUMMARY_PREVIEW_MAX_LENGTH,
86
+ AGENT_CONTEXT_COMPACTION_TRIGGERS,
87
+ AGENT_CONTEXT_CUMULATIVE_USAGE_FIELDS,
88
+ AGENT_CONTEXT_MEASUREMENT_SCOPES,
56
89
  AGENT_FILE_CHANGE_KINDS,
57
90
  AGENT_IMAGE_INPUT_MEDIA_TYPES,
58
91
  AGENT_IMAGE_INPUT_SOURCE_KINDS,
@@ -1,5 +1,25 @@
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<{
4
+ kind: z.ZodLiteral<"unsupported">;
5
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
6
+ kind: z.ZodLiteral<"supported">;
7
+ modes: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
8
+ persistence: z.ZodEnum<{
9
+ session: "session";
10
+ once: "once";
11
+ workspace: "workspace";
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>>>>;
22
+ }, z.core.$strict>>], "kind">;
3
23
  export declare const AgentImageInputCapabilitySchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
4
24
  kind: z.ZodLiteral<"unsupported">;
5
25
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
@@ -48,7 +68,7 @@ export declare const AgentOperationInputCapabilitySchema: z.ZodReadonly<z.ZodObj
48
68
  }, z.core.$strict>>], "kind">;
49
69
  }, z.core.$strict>>;
50
70
  export declare const AgentCapabilitiesPortableSchema: z.ZodReadonly<z.ZodObject<{
51
- protocolVersion: z.ZodLiteral<6>;
71
+ protocolVersion: z.ZodLiteral<7>;
52
72
  providerKey: z.ZodType<import("../index.js").AgentProviderKey, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentProviderKey, unknown>>;
53
73
  sessions: z.ZodReadonly<z.ZodObject<{
54
74
  create: z.ZodLiteral<true>;
@@ -97,7 +117,26 @@ export declare const AgentCapabilitiesPortableSchema: z.ZodReadonly<z.ZodObject<
97
117
  }, z.core.$strict>>], "kind">;
98
118
  }, z.core.$strict>>;
99
119
  requests: z.ZodReadonly<z.ZodObject<{
100
- approval: z.ZodBoolean;
120
+ approval: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
121
+ kind: z.ZodLiteral<"unsupported">;
122
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
123
+ kind: z.ZodLiteral<"supported">;
124
+ modes: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
125
+ persistence: z.ZodEnum<{
126
+ session: "session";
127
+ once: "once";
128
+ workspace: "workspace";
129
+ }>;
130
+ scopeKinds: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
131
+ exact_action: "exact_action";
132
+ command_pattern: "command_pattern";
133
+ domain: "domain";
134
+ tool: "tool";
135
+ server: "server";
136
+ all_edits: "all_edits";
137
+ }>>>;
138
+ }, z.core.$strict>>>>;
139
+ }, z.core.$strict>>], "kind">;
101
140
  elicitation: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
102
141
  kind: z.ZodLiteral<"unsupported">;
103
142
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
@@ -106,6 +145,39 @@ export declare const AgentCapabilitiesPortableSchema: z.ZodReadonly<z.ZodObject<
106
145
  kind: z.ZodLiteral<"structured">;
107
146
  }, z.core.$strict>>], "kind">;
108
147
  }, z.core.$strict>>;
148
+ context: z.ZodReadonly<z.ZodObject<{
149
+ usage: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
150
+ kind: z.ZodLiteral<"unsupported">;
151
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
152
+ kind: z.ZodLiteral<"supported">;
153
+ measurementScopes: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
154
+ session: "session";
155
+ materialization: "materialization";
156
+ }>>>;
157
+ cumulativeFields: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
158
+ inputTokens: "inputTokens";
159
+ outputTokens: "outputTokens";
160
+ cachedReadTokens: "cachedReadTokens";
161
+ cacheCreationTokens: "cacheCreationTokens";
162
+ reasoningTokens: "reasoningTokens";
163
+ modelCalls: "modelCalls";
164
+ turns: "turns";
165
+ }>>>;
166
+ }, z.core.$strict>>], "kind">;
167
+ compaction: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
168
+ kind: z.ZodLiteral<"unsupported">;
169
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
170
+ kind: z.ZodLiteral<"supported">;
171
+ triggers: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
172
+ unknown: "unknown";
173
+ automatic: "automatic";
174
+ manual: "manual";
175
+ context_limit: "context_limit";
176
+ recovery: "recovery";
177
+ }>>>;
178
+ sameSessionContinuation: z.ZodBoolean;
179
+ }, z.core.$strict>>], "kind">;
180
+ }, z.core.$strict>>;
109
181
  input: z.ZodReadonly<z.ZodObject<{
110
182
  text: z.ZodLiteral<true>;
111
183
  images: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
@@ -9,6 +9,13 @@ import {
9
9
  AGENT_FILE_CHANGE_MODES
10
10
  } from "../capabilities/types.js";
11
11
  import {
12
+ AGENT_APPROVAL_PERSISTENCES,
13
+ AGENT_APPROVAL_SCOPE_KINDS
14
+ } from "../requests/types.js";
15
+ import {
16
+ AGENT_CONTEXT_COMPACTION_TRIGGERS,
17
+ AGENT_CONTEXT_CUMULATIVE_USAGE_FIELDS,
18
+ AGENT_CONTEXT_MEASUREMENT_SCOPES,
12
19
  AGENT_IMAGE_INPUT_MEDIA_TYPES,
13
20
  AGENT_IMAGE_INPUT_SOURCE_KINDS,
14
21
  AGENT_TURN_INTERACTION_MODES
@@ -39,6 +46,34 @@ function addCanonicalListIssues(input, context) {
39
46
  });
40
47
  }
41
48
  const PositiveSafeIntegerSchema = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
49
+ const AgentApprovalCapabilitySchema = z.discriminatedUnion("kind", [
50
+ z.object({ kind: z.literal("unsupported") }).strict().readonly(),
51
+ z.object({
52
+ kind: z.literal("supported"),
53
+ modes: z.array(
54
+ z.object({
55
+ persistence: z.enum(AGENT_APPROVAL_PERSISTENCES),
56
+ scopeKinds: z.array(z.enum(AGENT_APPROVAL_SCOPE_KINDS)).min(1).max(AGENT_APPROVAL_SCOPE_KINDS.length).meta({ uniqueItems: true }).readonly()
57
+ }).strict().readonly()
58
+ ).min(1).max(AGENT_APPROVAL_PERSISTENCES.length).readonly()
59
+ }).strict().readonly()
60
+ ]);
61
+ const AgentContextUsageCapabilitySchema = z.discriminatedUnion("kind", [
62
+ z.object({ kind: z.literal("unsupported") }).strict().readonly(),
63
+ z.object({
64
+ kind: z.literal("supported"),
65
+ measurementScopes: z.array(z.enum(AGENT_CONTEXT_MEASUREMENT_SCOPES)).min(1).max(AGENT_CONTEXT_MEASUREMENT_SCOPES.length).meta({ uniqueItems: true }).readonly(),
66
+ cumulativeFields: z.array(z.enum(AGENT_CONTEXT_CUMULATIVE_USAGE_FIELDS)).max(AGENT_CONTEXT_CUMULATIVE_USAGE_FIELDS.length).meta({ uniqueItems: true }).readonly()
67
+ }).strict().readonly()
68
+ ]);
69
+ const AgentContextCompactionCapabilitySchema = z.discriminatedUnion("kind", [
70
+ z.object({ kind: z.literal("unsupported") }).strict().readonly(),
71
+ z.object({
72
+ kind: z.literal("supported"),
73
+ triggers: z.array(z.enum(AGENT_CONTEXT_COMPACTION_TRIGGERS)).min(1).max(AGENT_CONTEXT_COMPACTION_TRIGGERS.length).meta({ uniqueItems: true }).readonly(),
74
+ sameSessionContinuation: z.boolean()
75
+ }).strict().readonly()
76
+ ]);
42
77
  const AgentImageInputCapabilitySchema = z.discriminatedUnion("kind", [
43
78
  z.object({ kind: z.literal("unsupported") }).strict().readonly(),
44
79
  z.object({
@@ -121,13 +156,17 @@ const AgentCapabilitiesPortableSchema = z.object({
121
156
  ])
122
157
  }).strict().readonly(),
123
158
  requests: z.object({
124
- approval: z.boolean(),
159
+ approval: AgentApprovalCapabilitySchema,
125
160
  elicitation: z.discriminatedUnion("kind", [
126
161
  z.object({ kind: z.literal("unsupported") }).strict().readonly(),
127
162
  z.object({ kind: z.literal("text") }).strict().readonly(),
128
163
  z.object({ kind: z.literal("structured") }).strict().readonly()
129
164
  ])
130
165
  }).strict().readonly(),
166
+ context: z.object({
167
+ usage: AgentContextUsageCapabilitySchema,
168
+ compaction: AgentContextCompactionCapabilitySchema
169
+ }).strict().readonly(),
131
170
  input: AgentOperationInputCapabilitySchema,
132
171
  output: z.object({
133
172
  streaming: z.boolean(),
@@ -172,6 +211,61 @@ const AgentCapabilitiesSchema = AgentCapabilitiesPortableSchema.superRefine((cap
172
211
  },
173
212
  context
174
213
  );
214
+ if (capabilities.requests.approval.kind === "supported") {
215
+ addCanonicalListIssues(
216
+ {
217
+ values: capabilities.requests.approval.modes.map(
218
+ (mode) => mode.persistence
219
+ ),
220
+ canonicalOrder: AGENT_APPROVAL_PERSISTENCES,
221
+ path: ["requests", "approval", "modes"],
222
+ label: "Approval persistence modes"
223
+ },
224
+ context
225
+ );
226
+ capabilities.requests.approval.modes.forEach((mode, index) => {
227
+ addCanonicalListIssues(
228
+ {
229
+ values: mode.scopeKinds,
230
+ canonicalOrder: AGENT_APPROVAL_SCOPE_KINDS,
231
+ path: ["requests", "approval", "modes", index, "scopeKinds"],
232
+ label: "Approval scope kinds"
233
+ },
234
+ context
235
+ );
236
+ });
237
+ }
238
+ if (capabilities.context.usage.kind === "supported") {
239
+ addCanonicalListIssues(
240
+ {
241
+ values: capabilities.context.usage.measurementScopes,
242
+ canonicalOrder: AGENT_CONTEXT_MEASUREMENT_SCOPES,
243
+ path: ["context", "usage", "measurementScopes"],
244
+ label: "Context measurement scopes"
245
+ },
246
+ context
247
+ );
248
+ addCanonicalListIssues(
249
+ {
250
+ values: capabilities.context.usage.cumulativeFields,
251
+ canonicalOrder: AGENT_CONTEXT_CUMULATIVE_USAGE_FIELDS,
252
+ path: ["context", "usage", "cumulativeFields"],
253
+ label: "Context cumulative usage fields"
254
+ },
255
+ context
256
+ );
257
+ }
258
+ if (capabilities.context.compaction.kind === "supported") {
259
+ addCanonicalListIssues(
260
+ {
261
+ values: capabilities.context.compaction.triggers,
262
+ canonicalOrder: AGENT_CONTEXT_COMPACTION_TRIGGERS,
263
+ path: ["context", "compaction", "triggers"],
264
+ label: "Context compaction triggers"
265
+ },
266
+ context
267
+ );
268
+ }
175
269
  addCanonicalListIssues(
176
270
  {
177
271
  values: capabilities.output.artifactKinds,
@@ -215,6 +309,7 @@ const AgentCapabilitiesSchema = AgentCapabilitiesPortableSchema.superRefine((cap
215
309
  }
216
310
  });
217
311
  export {
312
+ AgentApprovalCapabilitySchema,
218
313
  AgentCapabilitiesPortableSchema,
219
314
  AgentCapabilitiesSchema,
220
315
  AgentImageInputCapabilitySchema,