@agen-ai/agent-protocol 0.4.0 → 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.
@@ -38,6 +38,7 @@ export declare const AgentJsonObjectKeySchema: z.ZodString;
38
38
  interface ProtocolInputPreflightOptions {
39
39
  readonly maxDepth?: number;
40
40
  readonly maxCollectionLength?: number;
41
+ readonly requireJsonData?: boolean;
41
42
  }
42
43
  export declare function withAcyclicProtocolInput<Output>(schema: z.ZodType<Output>, options?: ProtocolInputPreflightOptions): z.ZodType<Output>;
43
44
  export declare const AgentJsonValuePortableSchema: z.ZodType<AgentJsonValue>;
@@ -86,7 +86,10 @@ function passesProtocolInputPreflight(input, options) {
86
86
  if (options.maxDepth !== void 0 && current.depth > options.maxDepth) {
87
87
  return false;
88
88
  }
89
- if (current.value === null || typeof current.value !== "object") continue;
89
+ if (current.value === null || typeof current.value !== "object") {
90
+ if (options.requireJsonData && current.value !== null && typeof current.value !== "string" && typeof current.value !== "boolean" && !(typeof current.value === "number" && Number.isFinite(current.value))) return false;
91
+ continue;
92
+ }
90
93
  if (activeObjects.has(current.value)) return false;
91
94
  activeObjects.add(current.value);
92
95
  pending.push({ operation: "leave", value: current.value });
@@ -103,12 +106,17 @@ function passesProtocolInputPreflight(input, options) {
103
106
  }
104
107
  let propertyKeys;
105
108
  try {
109
+ if (options.requireJsonData) {
110
+ const prototype = Object.getPrototypeOf(current.value);
111
+ if (prototype !== (Array.isArray(current.value) ? Array.prototype : Object.prototype) && prototype !== null) return false;
112
+ }
106
113
  propertyKeys = Reflect.ownKeys(current.value);
107
114
  } catch {
108
115
  return false;
109
116
  }
110
117
  let collectionLength = 0;
111
118
  for (const propertyKey of propertyKeys) {
119
+ if (options.requireJsonData && typeof propertyKey !== "string") return false;
112
120
  if (typeof propertyKey === "string" && !AGENT_JSON_OBJECT_KEY_PATTERN.test(propertyKey)) {
113
121
  return false;
114
122
  }
@@ -118,7 +126,12 @@ function passesProtocolInputPreflight(input, options) {
118
126
  } catch {
119
127
  return false;
120
128
  }
121
- if (!descriptor?.enumerable) continue;
129
+ if (options.requireJsonData && (!descriptor || !("value" in descriptor))) return false;
130
+ if (!descriptor?.enumerable) {
131
+ if (options.requireJsonData && !(Array.isArray(current.value) && propertyKey === "length")) return false;
132
+ continue;
133
+ }
134
+ if (options.requireJsonData && Array.isArray(current.value) && (typeof propertyKey !== "string" || !/^(?:0|[1-9][0-9]*)$/u.test(propertyKey))) return false;
122
135
  if (!("value" in descriptor)) return false;
123
136
  collectionLength += 1;
124
137
  if (options.maxCollectionLength !== void 0 && collectionLength > options.maxCollectionLength) {
@@ -1,8 +1,9 @@
1
1
  export { AgentApprovalOptionIdSchema, AgentArtifactIdSchema, AgentCollaborationIdSchema, AgentConfigurationRevisionIdSchema, AgentInstanceIdSchema, AgentIntegrationIdSchema, AgentIntegrationResourceIdSchema, AgentIntegrationServerIdSchema, AgentIntegrationToolIdSchema, AgentIsoDateTimeSchema, AgentItemIdSchema, AgentJsonValueSchema, AgentManagedContentIdSchema, AgentEnvironmentIdSchema, AgentEffectiveContentIdSchema, AgentCommandIdSchema, AgentExtensionIdSchema, AgentOperationIdSchema, AgentOperationInvocationIdSchema, AgentProviderConversationIdSchema, AgentProviderHistoryAnchorSchema, AgentProviderItemRefSchema, AgentProviderKeySchema, AgentProviderRefsSchema, AgentProviderRequestRefSchema, AgentProviderTurnRefSchema, AgentRequestFieldIdSchema, AgentRequestIdSchema, AgentSessionIdSchema, AgentGeneratedResourceIdSchema, AgentTurnIdSchema, } from './foundation.js';
2
2
  export { AgentErrorContextSchema, AgentErrorSchema, AgentFailureCategorySchema, AgentFailureQuotaReferenceSchema, AgentRecoveryHintSchema, } from './failures.js';
3
3
  export { AgentSessionBindingSchema, AgentSessionBranchSourceSchema, AgentSessionBranchInputSchema, AgentSessionConfigurationSchema, AgentSessionCreateInputSchema, AgentSessionOpenInputSchema, AgentSessionResumeInputSchema, } from './sessions.js';
4
+ export { AgentSessionDecisionChoiceIdSchema, AgentSessionWorkspaceTargetSchema, AgentSessionDecisionConsequenceSchema, AgentSessionDecisionChoiceSchema, AgentSessionDecisionRequestPortableSchema, AgentSessionDecisionRequestSchema, AgentSessionDecisionResponseSchema, } from './sessionInteractions.js';
4
5
  export { AgentBrowserActionDetailsSchema, AgentCollaborationToolCallDetailsSchema, AgentCommandExecutionDetailsSchema, AgentComputerActionDetailsSchema, AgentContentStreamKindSchema, AgentContextCompactionDetailsSchema, AgentDiffSummarySchema, AgentDynamicToolCallDetailsSchema, AgentFileChangeDetailsSchema, AgentFileChangeSchema, AgentImageViewDetailsSchema, AgentItemSnapshotSchema, AgentMcpToolCallDetailsSchema, AgentPlanStepSchema, AgentReviewDetailsSchema, AgentTurnCompletedPayloadSchema, AgentTurnInputContentCompositionSchema, AgentTurnInputContentSchema, AgentTurnInteractionModeSchema, AgentTurnInputPartSchema, AgentContentReferenceInputPartSchema, AgentTurnInterruptionInputSchema, AgentTurnRunInputSchema, AgentWebSearchDetailsSchema, } from './turns.js';
5
- export { AgentApprovalRequestSchema, AgentApprovalResolutionSchema, AgentElicitationRequestSchema, AgentRequestResolutionSchema, AgentRequestSchema, } from './requests.js';
6
+ export { AgentApprovalConsequenceSchema, AgentApprovalRequestSchema, AgentApprovalResolutionSchema, AgentElicitationRequestSchema, AgentRequestResolutionSchema, AgentRequestSchema, } from './requests.js';
6
7
  export { AgentOperationCatalogSchema, AgentOperationDescriptorSchema, AgentOperationFieldSchema, AgentOperationInvocationSchema, AgentOperationResultSchema, } from './operations.js';
7
8
  export { AgentManagedContentCatalogSchema, AgentManagedContentDescriptorSchema, } from './managedContent.js';
8
9
  export { AgentConfigurationCatalogSchema, AgentConfigurationFieldPortableSchema, AgentConfigurationSelectionInputSchema, AgentConfigurationValueSchema, } from './configuration.js';
package/dist/zod/index.js CHANGED
@@ -47,6 +47,15 @@ import {
47
47
  AgentSessionOpenInputSchema,
48
48
  AgentSessionResumeInputSchema
49
49
  } from "./sessions.js";
50
+ import {
51
+ AgentSessionDecisionChoiceIdSchema,
52
+ AgentSessionWorkspaceTargetSchema,
53
+ AgentSessionDecisionConsequenceSchema,
54
+ AgentSessionDecisionChoiceSchema,
55
+ AgentSessionDecisionRequestPortableSchema,
56
+ AgentSessionDecisionRequestSchema,
57
+ AgentSessionDecisionResponseSchema
58
+ } from "./sessionInteractions.js";
50
59
  import {
51
60
  AgentBrowserActionDetailsSchema,
52
61
  AgentCollaborationToolCallDetailsSchema,
@@ -74,6 +83,7 @@ import {
74
83
  AgentWebSearchDetailsSchema
75
84
  } from "./turns.js";
76
85
  import {
86
+ AgentApprovalConsequenceSchema,
77
87
  AgentApprovalRequestSchema,
78
88
  AgentApprovalResolutionSchema,
79
89
  AgentElicitationRequestSchema,
@@ -123,6 +133,7 @@ export * from "./extensions.js";
123
133
  export * from "./environment.js";
124
134
  export {
125
135
  AgentApprovalCapabilitySchema,
136
+ AgentApprovalConsequenceSchema,
126
137
  AgentApprovalOptionIdSchema,
127
138
  AgentApprovalRequestSchema,
128
139
  AgentApprovalResolutionSchema,
@@ -206,9 +217,16 @@ export {
206
217
  AgentSessionBranchSourceSchema,
207
218
  AgentSessionConfigurationSchema,
208
219
  AgentSessionCreateInputSchema,
220
+ AgentSessionDecisionChoiceIdSchema,
221
+ AgentSessionDecisionChoiceSchema,
222
+ AgentSessionDecisionConsequenceSchema,
223
+ AgentSessionDecisionRequestPortableSchema,
224
+ AgentSessionDecisionRequestSchema,
225
+ AgentSessionDecisionResponseSchema,
209
226
  AgentSessionIdSchema,
210
227
  AgentSessionOpenInputSchema,
211
228
  AgentSessionResumeInputSchema,
229
+ AgentSessionWorkspaceTargetSchema,
212
230
  AgentTurnCompletedPayloadSchema,
213
231
  AgentTurnIdSchema,
214
232
  AgentTurnInputContentCompositionSchema,
@@ -1,5 +1,32 @@
1
1
  import { z } from 'zod/v4';
2
2
  import type { AgentApprovalRequest, AgentApprovalResolution, AgentElicitationRequest, AgentRequest, AgentRequestResolution } from '../requests/types.js';
3
+ export declare const AgentApprovalConsequenceSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
4
+ kind: z.ZodLiteral<"scoped">;
5
+ persistence: z.ZodEnum<{
6
+ session: "session";
7
+ workspace: "workspace";
8
+ once: "once";
9
+ }>;
10
+ scope: z.ZodReadonly<z.ZodObject<{
11
+ kind: z.ZodEnum<{
12
+ exact_action: "exact_action";
13
+ command_pattern: "command_pattern";
14
+ domain: "domain";
15
+ tool: "tool";
16
+ server: "server";
17
+ all_edits: "all_edits";
18
+ }>;
19
+ }, z.core.$strict>>;
20
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
21
+ kind: z.ZodLiteral<"provider_managed_remembrance">;
22
+ duration: z.ZodReadonly<z.ZodObject<{
23
+ kind: z.ZodLiteral<"unknown">;
24
+ }, z.core.$strict>>;
25
+ applicability: z.ZodReadonly<z.ZodObject<{
26
+ kind: z.ZodLiteral<"unknown">;
27
+ }, z.core.$strict>>;
28
+ explanation: z.ZodString;
29
+ }, z.core.$strict>>], "kind">;
3
30
  export declare const AgentApprovalRequestPortableSchema: z.ZodReadonly<z.ZodObject<{
4
31
  requestKind: z.ZodLiteral<"approval">;
5
32
  requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
@@ -28,21 +55,33 @@ export declare const AgentApprovalRequestPortableSchema: z.ZodReadonly<z.ZodObje
28
55
  approved: "approved";
29
56
  denied: "denied";
30
57
  }>;
31
- persistence: z.ZodEnum<{
32
- session: "session";
33
- once: "once";
34
- workspace: "workspace";
35
- }>;
36
- scope: z.ZodReadonly<z.ZodObject<{
37
- kind: z.ZodEnum<{
38
- exact_action: "exact_action";
39
- command_pattern: "command_pattern";
40
- domain: "domain";
41
- tool: "tool";
42
- server: "server";
43
- all_edits: "all_edits";
58
+ consequence: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
59
+ kind: z.ZodLiteral<"scoped">;
60
+ persistence: z.ZodEnum<{
61
+ session: "session";
62
+ workspace: "workspace";
63
+ once: "once";
44
64
  }>;
45
- }, z.core.$strict>>;
65
+ scope: z.ZodReadonly<z.ZodObject<{
66
+ kind: z.ZodEnum<{
67
+ exact_action: "exact_action";
68
+ command_pattern: "command_pattern";
69
+ domain: "domain";
70
+ tool: "tool";
71
+ server: "server";
72
+ all_edits: "all_edits";
73
+ }>;
74
+ }, z.core.$strict>>;
75
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
76
+ kind: z.ZodLiteral<"provider_managed_remembrance">;
77
+ duration: z.ZodReadonly<z.ZodObject<{
78
+ kind: z.ZodLiteral<"unknown">;
79
+ }, z.core.$strict>>;
80
+ applicability: z.ZodReadonly<z.ZodObject<{
81
+ kind: z.ZodLiteral<"unknown">;
82
+ }, z.core.$strict>>;
83
+ explanation: z.ZodString;
84
+ }, z.core.$strict>>], "kind">;
46
85
  }, z.core.$strict>>>>;
47
86
  expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
48
87
  }, z.core.$strict>>;
@@ -149,21 +188,33 @@ export declare const AgentRequestPortableSchema: z.ZodDiscriminatedUnion<[z.ZodR
149
188
  approved: "approved";
150
189
  denied: "denied";
151
190
  }>;
152
- persistence: z.ZodEnum<{
153
- session: "session";
154
- once: "once";
155
- workspace: "workspace";
156
- }>;
157
- scope: z.ZodReadonly<z.ZodObject<{
158
- kind: z.ZodEnum<{
159
- exact_action: "exact_action";
160
- command_pattern: "command_pattern";
161
- domain: "domain";
162
- tool: "tool";
163
- server: "server";
164
- all_edits: "all_edits";
191
+ consequence: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
192
+ kind: z.ZodLiteral<"scoped">;
193
+ persistence: z.ZodEnum<{
194
+ session: "session";
195
+ workspace: "workspace";
196
+ once: "once";
165
197
  }>;
166
- }, z.core.$strict>>;
198
+ scope: z.ZodReadonly<z.ZodObject<{
199
+ kind: z.ZodEnum<{
200
+ exact_action: "exact_action";
201
+ command_pattern: "command_pattern";
202
+ domain: "domain";
203
+ tool: "tool";
204
+ server: "server";
205
+ all_edits: "all_edits";
206
+ }>;
207
+ }, z.core.$strict>>;
208
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
209
+ kind: z.ZodLiteral<"provider_managed_remembrance">;
210
+ duration: z.ZodReadonly<z.ZodObject<{
211
+ kind: z.ZodLiteral<"unknown">;
212
+ }, z.core.$strict>>;
213
+ applicability: z.ZodReadonly<z.ZodObject<{
214
+ kind: z.ZodLiteral<"unknown">;
215
+ }, z.core.$strict>>;
216
+ explanation: z.ZodString;
217
+ }, z.core.$strict>>], "kind">;
167
218
  }, z.core.$strict>>>>;
168
219
  expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
169
220
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
@@ -25,13 +25,25 @@ import {
25
25
  const AgentApprovalLabelSchema = z.string().min(1).max(AGENT_APPROVAL_LABEL_MAX_LENGTH).regex(/^(?:\S|\S[\s\S]*\S)$/u);
26
26
  const AgentApprovalDescriptionSchema = z.string().min(1).max(AGENT_APPROVAL_DESCRIPTION_MAX_LENGTH).regex(/^(?:\S|\S[\s\S]*\S)$/u);
27
27
  const AgentApprovalPromptSchema = z.string().min(1).max(AGENT_PROTOCOL_TEXT_MAX_LENGTH).regex(/^(?:\S|\S[\s\S]*\S)$/u);
28
+ const AgentApprovalConsequenceSchema = z.discriminatedUnion("kind", [
29
+ z.object({
30
+ kind: z.literal("scoped"),
31
+ persistence: z.enum(AGENT_APPROVAL_PERSISTENCES),
32
+ scope: z.object({ kind: z.enum(AGENT_APPROVAL_SCOPE_KINDS) }).strict().readonly()
33
+ }).strict().readonly(),
34
+ z.object({
35
+ kind: z.literal("provider_managed_remembrance"),
36
+ duration: z.object({ kind: z.literal("unknown") }).strict().readonly(),
37
+ applicability: z.object({ kind: z.literal("unknown") }).strict().readonly(),
38
+ explanation: AgentApprovalDescriptionSchema
39
+ }).strict().readonly()
40
+ ]);
28
41
  const AgentApprovalOptionSchema = z.object({
29
42
  optionId: AgentApprovalOptionIdSchema,
30
43
  label: AgentApprovalLabelSchema,
31
44
  description: AgentApprovalDescriptionSchema.optional(),
32
45
  decision: z.enum(["approved", "denied"]),
33
- persistence: z.enum(AGENT_APPROVAL_PERSISTENCES),
34
- scope: z.object({ kind: z.enum(AGENT_APPROVAL_SCOPE_KINDS) }).strict().readonly()
46
+ consequence: AgentApprovalConsequenceSchema
35
47
  }).strict().readonly();
36
48
  const AgentApprovalRequestPortableSchema = z.object({
37
49
  requestKind: z.literal("approval"),
@@ -248,6 +260,7 @@ const AgentRequestResolutionSchema = AgentRequestResolutionPortableSchema.superR
248
260
  });
249
261
  });
250
262
  export {
263
+ AgentApprovalConsequenceSchema,
251
264
  AgentApprovalRequestPortableSchema,
252
265
  AgentApprovalRequestSchema,
253
266
  AgentApprovalResolutionSchema,
@@ -0,0 +1,55 @@
1
+ import { z } from 'zod/v4';
2
+ import { type AgentSessionDecisionChoiceId, type AgentSessionDecisionRequest, type AgentSessionDecisionResponse } from '../sessionInteractions/types.js';
3
+ export declare const AgentSessionDecisionChoiceIdSchema: z.ZodType<AgentSessionDecisionChoiceId>;
4
+ export declare const AgentSessionWorkspaceTargetSchema: z.ZodReadonly<z.ZodObject<{
5
+ kind: z.ZodLiteral<"workspace">;
6
+ path: z.ZodString;
7
+ }, z.core.$strict>>;
8
+ export declare const AgentSessionDecisionConsequenceSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
9
+ kind: z.ZodLiteral<"grant">;
10
+ scope: z.ZodLiteral<"workspace">;
11
+ persistence: z.ZodReadonly<z.ZodObject<{
12
+ kind: z.ZodLiteral<"provider_managed">;
13
+ duration: z.ZodLiteral<"persistent">;
14
+ mayAffectOtherSessions: z.ZodLiteral<true>;
15
+ }, z.core.$strict>>;
16
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
17
+ kind: z.ZodLiteral<"decline">;
18
+ configuration: z.ZodLiteral<"remains_gated">;
19
+ }, z.core.$strict>>], "kind">;
20
+ export declare const AgentSessionDecisionChoiceSchema: z.ZodReadonly<z.ZodObject<{
21
+ choiceId: z.ZodType<AgentSessionDecisionChoiceId, unknown, z.core.$ZodTypeInternals<AgentSessionDecisionChoiceId, unknown>>;
22
+ label: z.ZodString;
23
+ description: z.ZodString;
24
+ consequence: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
25
+ kind: z.ZodLiteral<"grant">;
26
+ scope: z.ZodLiteral<"workspace">;
27
+ persistence: z.ZodReadonly<z.ZodObject<{
28
+ kind: z.ZodLiteral<"provider_managed">;
29
+ duration: z.ZodLiteral<"persistent">;
30
+ mayAffectOtherSessions: z.ZodLiteral<true>;
31
+ }, z.core.$strict>>;
32
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
33
+ kind: z.ZodLiteral<"decline">;
34
+ configuration: z.ZodLiteral<"remains_gated">;
35
+ }, z.core.$strict>>], "kind">;
36
+ }, z.core.$strict>>;
37
+ export declare const AgentSessionDecisionRequestPortableSchema: z.ZodReadonly<z.ZodObject<{
38
+ kind: z.ZodLiteral<"decision">;
39
+ requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
40
+ sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
41
+ title: z.ZodString;
42
+ description: z.ZodOptional<z.ZodString>;
43
+ target: z.ZodReadonly<z.ZodObject<{
44
+ kind: z.ZodLiteral<"workspace">;
45
+ path: z.ZodString;
46
+ }, z.core.$strict>>;
47
+ expiresAt: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
48
+ choices: z.ZodType<readonly [import("../index.js").AgentSessionDecisionChoice, ...import("../index.js").AgentSessionDecisionChoice[]], unknown, z.core.$ZodTypeInternals<readonly [import("../index.js").AgentSessionDecisionChoice, ...import("../index.js").AgentSessionDecisionChoice[]], unknown>>;
49
+ }, z.core.$strict>>;
50
+ export declare const AgentSessionDecisionRequestSchema: z.ZodType<AgentSessionDecisionRequest>;
51
+ export declare const AgentSessionDecisionResponsePortableSchema: z.ZodReadonly<z.ZodObject<{
52
+ choiceId: z.ZodType<AgentSessionDecisionChoiceId, unknown, z.core.$ZodTypeInternals<AgentSessionDecisionChoiceId, unknown>>;
53
+ }, z.core.$strict>>;
54
+ export declare const AgentSessionDecisionResponseSchema: z.ZodType<AgentSessionDecisionResponse>;
55
+ //# sourceMappingURL=sessionInteractions.d.ts.map
@@ -0,0 +1,114 @@
1
+ import { z } from "zod/v4";
2
+ import {
3
+ AGENT_PROTOCOL_JSON_DEPTH_LIMIT,
4
+ agentProtocolSerializedJsonBytes
5
+ } from "../foundation/types.js";
6
+ import {
7
+ AGENT_SESSION_DECISION_CHOICE_DESCRIPTION_MAX_LENGTH,
8
+ AGENT_SESSION_DECISION_CHOICE_ID_BYTES_LIMIT,
9
+ AGENT_SESSION_DECISION_CHOICES_MAX_LENGTH,
10
+ AGENT_SESSION_DECISION_DESCRIPTION_MAX_LENGTH,
11
+ AGENT_SESSION_DECISION_REQUEST_BYTES_LIMIT,
12
+ AGENT_SESSION_DECISION_RESPONSE_BYTES_LIMIT,
13
+ AGENT_SESSION_DECISION_TITLE_MAX_LENGTH,
14
+ AGENT_SESSION_DECISION_WORKSPACE_PATH_BYTES_LIMIT
15
+ } from "../sessionInteractions/types.js";
16
+ import {
17
+ AgentIsoDateTimeSchema,
18
+ AgentRequestIdSchema,
19
+ AgentSessionIdSchema,
20
+ createAgentCanonicalNonBlankStringSchema,
21
+ createAgentCanonicalOpaqueStringSchema,
22
+ withAcyclicProtocolInput
23
+ } from "./foundation.js";
24
+ const encoder = new TextEncoder();
25
+ const SingleLineTextSchema = createAgentCanonicalNonBlankStringSchema(
26
+ AGENT_SESSION_DECISION_TITLE_MAX_LENGTH
27
+ ).regex(/^[^\u0000-\u001F\u007F-\u009F]*$/u);
28
+ function descriptionSchema(maxLength) {
29
+ return createAgentCanonicalNonBlankStringSchema(maxLength).regex(/^[^\u0000-\u0009\u000B-\u001F\u007F-\u009F]*$/u);
30
+ }
31
+ const AgentSessionDecisionChoiceIdSchema = createAgentCanonicalOpaqueStringSchema(
32
+ AGENT_SESSION_DECISION_CHOICE_ID_BYTES_LIMIT,
33
+ "Session decision choice IDs must be canonical and contain no control characters."
34
+ ).refine(
35
+ (value) => encoder.encode(value).byteLength <= AGENT_SESSION_DECISION_CHOICE_ID_BYTES_LIMIT,
36
+ "Session decision choice ID exceeds its UTF-8 byte limit."
37
+ );
38
+ const AgentSessionWorkspaceTargetSchema = z.object({
39
+ kind: z.literal("workspace"),
40
+ path: createAgentCanonicalNonBlankStringSchema(AGENT_SESSION_DECISION_WORKSPACE_PATH_BYTES_LIMIT).regex(/^[^\p{Cc}\p{Cf}]*$/u).refine(
41
+ (value) => encoder.encode(value).byteLength <= AGENT_SESSION_DECISION_WORKSPACE_PATH_BYTES_LIMIT,
42
+ "Workspace target path exceeds its UTF-8 byte limit."
43
+ )
44
+ }).strict().readonly();
45
+ const AgentSessionDecisionConsequenceSchema = z.discriminatedUnion("kind", [
46
+ z.object({
47
+ kind: z.literal("grant"),
48
+ scope: z.literal("workspace"),
49
+ persistence: z.object({
50
+ kind: z.literal("provider_managed"),
51
+ duration: z.literal("persistent"),
52
+ mayAffectOtherSessions: z.literal(true)
53
+ }).strict().readonly()
54
+ }).strict().readonly(),
55
+ z.object({
56
+ kind: z.literal("decline"),
57
+ configuration: z.literal("remains_gated")
58
+ }).strict().readonly()
59
+ ]);
60
+ const AgentSessionDecisionChoiceSchema = z.object({
61
+ choiceId: AgentSessionDecisionChoiceIdSchema,
62
+ label: SingleLineTextSchema,
63
+ description: descriptionSchema(AGENT_SESSION_DECISION_CHOICE_DESCRIPTION_MAX_LENGTH),
64
+ consequence: AgentSessionDecisionConsequenceSchema
65
+ }).strict().readonly();
66
+ const ChoicesSchema = z.array(AgentSessionDecisionChoiceSchema).min(1).max(AGENT_SESSION_DECISION_CHOICES_MAX_LENGTH).readonly();
67
+ const AgentSessionDecisionRequestPortableSchema = z.object({
68
+ kind: z.literal("decision"),
69
+ requestId: AgentRequestIdSchema,
70
+ sessionId: AgentSessionIdSchema,
71
+ title: SingleLineTextSchema,
72
+ description: descriptionSchema(AGENT_SESSION_DECISION_DESCRIPTION_MAX_LENGTH).optional(),
73
+ target: AgentSessionWorkspaceTargetSchema,
74
+ expiresAt: AgentIsoDateTimeSchema,
75
+ choices: ChoicesSchema
76
+ }).strict().readonly();
77
+ const inputBounds = {
78
+ maxDepth: AGENT_PROTOCOL_JSON_DEPTH_LIMIT,
79
+ maxCollectionLength: AGENT_SESSION_DECISION_CHOICES_MAX_LENGTH,
80
+ requireJsonData: true
81
+ };
82
+ const AgentSessionDecisionRequestSchema = withAcyclicProtocolInput(AgentSessionDecisionRequestPortableSchema, inputBounds).superRefine((request, context) => {
83
+ if (agentProtocolSerializedJsonBytes(request) > AGENT_SESSION_DECISION_REQUEST_BYTES_LIMIT) {
84
+ context.addIssue({ code: "custom", message: "Session decision exceeds its serialized UTF-8 byte limit." });
85
+ }
86
+ const seen = /* @__PURE__ */ new Set();
87
+ request.choices.forEach((choice, index) => {
88
+ if (seen.has(choice.choiceId)) {
89
+ context.addIssue({
90
+ code: "custom",
91
+ path: ["choices", index, "choiceId"],
92
+ message: "Session decision choices must have unique IDs."
93
+ });
94
+ }
95
+ seen.add(choice.choiceId);
96
+ });
97
+ });
98
+ const AgentSessionDecisionResponsePortableSchema = z.object({
99
+ choiceId: AgentSessionDecisionChoiceIdSchema
100
+ }).strict().readonly();
101
+ const AgentSessionDecisionResponseSchema = withAcyclicProtocolInput(AgentSessionDecisionResponsePortableSchema, inputBounds).refine(
102
+ (response) => agentProtocolSerializedJsonBytes(response) <= AGENT_SESSION_DECISION_RESPONSE_BYTES_LIMIT,
103
+ "Session decision response exceeds its serialized UTF-8 byte limit."
104
+ );
105
+ export {
106
+ AgentSessionDecisionChoiceIdSchema,
107
+ AgentSessionDecisionChoiceSchema,
108
+ AgentSessionDecisionConsequenceSchema,
109
+ AgentSessionDecisionRequestPortableSchema,
110
+ AgentSessionDecisionRequestSchema,
111
+ AgentSessionDecisionResponsePortableSchema,
112
+ AgentSessionDecisionResponseSchema,
113
+ AgentSessionWorkspaceTargetSchema
114
+ };
@@ -1,7 +1,7 @@
1
1
  import type { z } from 'zod/v4';
2
2
  import type { AgentAccountQuotaReset, AgentAccountQuotaSnapshot, AgentAccountQuotaWindow } from '../accountQuota/types.js';
3
3
  import type { AgentArtifactDescriptor } from '../artifacts/types.js';
4
- import type { AgentCapabilities } from '../capabilities/types.js';
4
+ import type { AgentApprovalCapability, AgentCapabilities } from '../capabilities/types.js';
5
5
  import type { AgentCollaborationControlInput, AgentCollaborationNode, AgentCollaborationSpawnInput } from '../collaboration/types.js';
6
6
  import type { AgentCommandCatalog, AgentCommandDescriptor } from '../commands/types.js';
7
7
  import type { AgentConfigurationCatalog, AgentConfigurationSelectionInput } from '../configuration/types.js';
@@ -14,13 +14,14 @@ import type { AgentJsonValue, AgentProviderRefs } from '../foundation/types.js';
14
14
  import type { AgentIntegrationCatalog, AgentIntegrationDescriptor, AgentMcpIntegrationDescriptor } from '../integrations/types.js';
15
15
  import type { AgentManagedContentCatalog, AgentManagedContentDescriptor } from '../managedContent/types.js';
16
16
  import type { AgentOperationCatalog, AgentOperationDescriptor, AgentOperationInvocation, AgentOperationResult } from '../operations/types.js';
17
- import type { AgentRequest, AgentRequestResolution } from '../requests/types.js';
17
+ import type { AgentApprovalConsequence, AgentRequest, AgentRequestResolution } from '../requests/types.js';
18
18
  import type { AgentGeneratedResourceDescriptor } from '../resources/types.js';
19
+ import type { AgentSessionDecisionChoice, AgentSessionDecisionConsequence, AgentSessionDecisionRequest, AgentSessionDecisionResponse, AgentSessionWorkspaceTarget } from '../sessionInteractions/types.js';
19
20
  import type { AgentSessionBinding, AgentSessionConfiguration, AgentSessionOpenInput } from '../sessions/types.js';
20
21
  import type { AgentContentReferenceInputPart, AgentItemSnapshot, AgentTurnInputContent, AgentTurnInterruptionInput, AgentTurnRunInput } from '../turns/types.js';
21
22
  import { AgentAccountQuotaResetSchema, AgentAccountQuotaSnapshotSchema, AgentAccountQuotaWindowSchema } from './accountQuota.js';
22
23
  import { AgentArtifactDescriptorSchema } from './artifacts.js';
23
- import { AgentCapabilitiesSchema } from './capabilities.js';
24
+ import { AgentApprovalCapabilitySchema, AgentCapabilitiesSchema } from './capabilities.js';
24
25
  import { AgentCollaborationControlInputSchema, AgentCollaborationNodeSchema, AgentCollaborationSpawnInputSchema } from './collaboration.js';
25
26
  import { AgentCommandCatalogSchema, AgentCommandDescriptorSchema } from './commands.js';
26
27
  import { AgentConfigurationCatalogSchema, AgentConfigurationSelectionInputSchema } from './configuration.js';
@@ -33,13 +34,24 @@ import { AgentJsonValueSchema, AgentProviderRefsSchema } from './foundation.js';
33
34
  import { AgentIntegrationCatalogSchema, AgentIntegrationDescriptorSchema, AgentMcpIntegrationDescriptorSchema } from './integrations.js';
34
35
  import { AgentManagedContentCatalogSchema, AgentManagedContentDescriptorSchema } from './managedContent.js';
35
36
  import { AgentOperationCatalogSchema, AgentOperationDescriptorSchema, AgentOperationInvocationSchema, AgentOperationResultSchema } from './operations.js';
36
- import { AgentRequestResolutionSchema, AgentRequestSchema } from './requests.js';
37
+ import { AgentApprovalConsequenceSchema, AgentRequestResolutionSchema, AgentRequestSchema } from './requests.js';
37
38
  import { AgentGeneratedResourceDescriptorSchema } from './resources.js';
39
+ import { AgentSessionDecisionChoiceSchema, AgentSessionDecisionConsequenceSchema, AgentSessionDecisionRequestSchema, AgentSessionDecisionResponseSchema, AgentSessionWorkspaceTargetSchema } from './sessionInteractions.js';
38
40
  import { AgentSessionBindingSchema, AgentSessionConfigurationSchema, AgentSessionOpenInputSchema } from './sessions.js';
39
41
  import { AgentContentReferenceInputPartSchema, AgentItemSnapshotSchema, AgentTurnInputContentSchema, AgentTurnInterruptionInputSchema, AgentTurnRunInputSchema } from './turns.js';
40
42
  type Extends<Left, Right> = [Left] extends [Right] ? true : false;
41
43
  type Assert<Value extends true> = Value;
42
44
  export type AgentProtocolSchemaTypeAssertions = readonly [
45
+ Assert<Extends<z.output<typeof AgentSessionWorkspaceTargetSchema>, AgentSessionWorkspaceTarget>>,
46
+ Assert<Extends<AgentSessionWorkspaceTarget, z.output<typeof AgentSessionWorkspaceTargetSchema>>>,
47
+ Assert<Extends<z.output<typeof AgentSessionDecisionConsequenceSchema>, AgentSessionDecisionConsequence>>,
48
+ Assert<Extends<AgentSessionDecisionConsequence, z.output<typeof AgentSessionDecisionConsequenceSchema>>>,
49
+ Assert<Extends<z.output<typeof AgentSessionDecisionChoiceSchema>, AgentSessionDecisionChoice>>,
50
+ Assert<Extends<AgentSessionDecisionChoice, z.output<typeof AgentSessionDecisionChoiceSchema>>>,
51
+ Assert<Extends<z.output<typeof AgentSessionDecisionRequestSchema>, AgentSessionDecisionRequest>>,
52
+ Assert<Extends<AgentSessionDecisionRequest, z.output<typeof AgentSessionDecisionRequestSchema>>>,
53
+ Assert<Extends<z.output<typeof AgentSessionDecisionResponseSchema>, AgentSessionDecisionResponse>>,
54
+ Assert<Extends<AgentSessionDecisionResponse, z.output<typeof AgentSessionDecisionResponseSchema>>>,
43
55
  Assert<Extends<z.output<typeof AgentEffectiveContentCatalogSchema>, AgentEffectiveContentCatalog>>,
44
56
  Assert<Extends<AgentEffectiveContentCatalog, z.output<typeof AgentEffectiveContentCatalogSchema>>>,
45
57
  Assert<Extends<z.output<typeof AgentEffectiveContentDescriptorSchema>, AgentEffectiveContentDescriptor>>,
@@ -94,6 +106,10 @@ export type AgentProtocolSchemaTypeAssertions = readonly [
94
106
  Assert<Extends<AgentTurnInterruptionInput, z.output<typeof AgentTurnInterruptionInputSchema>>>,
95
107
  Assert<Extends<z.output<typeof AgentItemSnapshotSchema>, AgentItemSnapshot>>,
96
108
  Assert<Extends<AgentItemSnapshot, z.output<typeof AgentItemSnapshotSchema>>>,
109
+ Assert<Extends<z.output<typeof AgentApprovalConsequenceSchema>, AgentApprovalConsequence>>,
110
+ Assert<Extends<AgentApprovalConsequence, z.output<typeof AgentApprovalConsequenceSchema>>>,
111
+ Assert<Extends<z.output<typeof AgentApprovalCapabilitySchema>, AgentApprovalCapability>>,
112
+ Assert<Extends<AgentApprovalCapability, z.output<typeof AgentApprovalCapabilitySchema>>>,
97
113
  Assert<Extends<z.output<typeof AgentRequestSchema>, AgentRequest>>,
98
114
  Assert<Extends<AgentRequest, z.output<typeof AgentRequestSchema>>>,
99
115
  Assert<Extends<z.output<typeof AgentRequestResolutionSchema>, AgentRequestResolution>>,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agen-ai/agent-protocol",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "private": false,
5
5
  "description": "Provider-neutral sessions, turns, requests, capabilities, artifacts, and events for coding-agent runtimes.",
6
6
  "type": "module",
@@ -24,6 +24,10 @@
24
24
  "types": "./dist/public/sessions.d.ts",
25
25
  "import": "./dist/public/sessions.js"
26
26
  },
27
+ "./session-interactions": {
28
+ "types": "./dist/public/sessionInteractions.d.ts",
29
+ "import": "./dist/public/sessionInteractions.js"
30
+ },
27
31
  "./turns": {
28
32
  "types": "./dist/public/turns.d.ts",
29
33
  "import": "./dist/public/turns.js"
@@ -100,7 +104,7 @@
100
104
  },
101
105
  "dependencies": {
102
106
  "zod": "4.4.3",
103
- "@agen-ai/validation": "^0.4.0"
107
+ "@agen-ai/validation": "^0.4.1"
104
108
  },
105
109
  "devDependencies": {
106
110
  "ajv": "8.17.1",