@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
@@ -163,16 +163,16 @@ declare const AgentOperationDescriptorPortableSchema: z.ZodReadonly<z.ZodObject<
163
163
  }>;
164
164
  }, z.core.$strict>>], "fieldKind">>>;
165
165
  confirmation: z.ZodEnum<{
166
- required: "required";
167
166
  none: "none";
167
+ required: "required";
168
168
  }>;
169
169
  idempotency: z.ZodEnum<{
170
170
  required: "required";
171
171
  not_required: "not_required";
172
172
  }>;
173
173
  resultKind: z.ZodEnum<{
174
- resource: "resource";
175
174
  none: "none";
175
+ resource: "resource";
176
176
  canonical_output: "canonical_output";
177
177
  artifact: "artifact";
178
178
  }>;
@@ -277,16 +277,16 @@ export declare const AgentOperationCatalogPortableSchema: z.ZodReadonly<z.ZodObj
277
277
  }>;
278
278
  }, z.core.$strict>>], "fieldKind">>>;
279
279
  confirmation: z.ZodEnum<{
280
- required: "required";
281
280
  none: "none";
281
+ required: "required";
282
282
  }>;
283
283
  idempotency: z.ZodEnum<{
284
284
  required: "required";
285
285
  not_required: "not_required";
286
286
  }>;
287
287
  resultKind: z.ZodEnum<{
288
- resource: "resource";
289
288
  none: "none";
289
+ resource: "resource";
290
290
  canonical_output: "canonical_output";
291
291
  artifact: "artifact";
292
292
  }>;
@@ -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_OPERATION_CATALOG_MAX_LENGTH,
@@ -19,7 +20,6 @@ import {
19
20
  import {
20
21
  AgentArtifactIdSchema,
21
22
  AgentCanonicalIdValueSchema,
22
- AgentErrorSchema,
23
23
  AgentGeneratedResourceIdSchema,
24
24
  AgentOperationIdSchema,
25
25
  AgentOperationInvocationIdSchema,
@@ -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,
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod/v4";
2
+ import { AgentErrorSchema } from "./failures.js";
2
3
  import { AGENT_ARTIFACT_BYTE_SIZE_MAX } from "../artifacts/types.js";
3
4
  import {
4
5
  AGENT_GENERATED_RESOURCE_DISPLAY_NAME_MAX_LENGTH,
@@ -9,7 +10,6 @@ import {
9
10
  import {
10
11
  AgentArtifactIdSchema,
11
12
  AgentCollaborationIdSchema,
12
- AgentErrorSchema,
13
13
  AgentGeneratedResourceIdSchema,
14
14
  AgentIsoDateTimeSchema,
15
15
  AgentOperationInvocationIdSchema,
@@ -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
+ };
package/dist/zod/turns.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod/v4";
2
+ import { AgentErrorSchema } from "./failures.js";
2
3
  import {
3
4
  AGENT_PROTOCOL_COLLECTION_MAX_LENGTH,
4
5
  AGENT_PROTOCOL_SUMMARY_MAX_LENGTH,
@@ -21,7 +22,6 @@ import {
21
22
  } from "../turns/types.js";
22
23
  import {
23
24
  AgentCanonicalIdValueSchema,
24
- AgentErrorSchema,
25
25
  AgentEnvironmentIdSchema,
26
26
  AgentEffectiveContentIdSchema,
27
27
  AgentIsoDateTimeSchema,
@@ -1,7 +1,7 @@
1
1
  import type { z } from 'zod/v4';
2
- import type { AgentAccountQuotaSnapshot, AgentAccountQuotaWindow } from '../accountQuota/types.js';
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';
@@ -9,17 +9,19 @@ import type { AgentEffectiveContentCatalog, AgentEffectiveContentDescriptor } fr
9
9
  import type { AgentEnvironmentCapability, AgentEnvironmentInvalidation, AgentEnvironmentSnapshot } from '../environment/types.js';
10
10
  import type { AgentEvent } from '../events/types.js';
11
11
  import type { AgentExtensionCatalog, AgentExtensionDescriptor } from '../extensions/types.js';
12
- import type { AgentError, AgentJsonValue, AgentProviderRefs } from '../foundation/types.js';
12
+ import type { AgentError, AgentErrorContext, AgentFailureCategory, AgentFailureQuotaReference, AgentRecoveryHint } from '../failures/types.js';
13
+ import type { AgentJsonValue, AgentProviderRefs } from '../foundation/types.js';
13
14
  import type { AgentIntegrationCatalog, AgentIntegrationDescriptor, AgentMcpIntegrationDescriptor } from '../integrations/types.js';
14
15
  import type { AgentManagedContentCatalog, AgentManagedContentDescriptor } from '../managedContent/types.js';
15
16
  import type { AgentOperationCatalog, AgentOperationDescriptor, AgentOperationInvocation, AgentOperationResult } from '../operations/types.js';
16
- import type { AgentRequest, AgentRequestResolution } from '../requests/types.js';
17
+ import type { AgentApprovalConsequence, AgentRequest, AgentRequestResolution } from '../requests/types.js';
17
18
  import type { AgentGeneratedResourceDescriptor } from '../resources/types.js';
19
+ import type { AgentSessionDecisionChoice, AgentSessionDecisionConsequence, AgentSessionDecisionRequest, AgentSessionDecisionResponse, AgentSessionWorkspaceTarget } from '../sessionInteractions/types.js';
18
20
  import type { AgentSessionBinding, AgentSessionConfiguration, AgentSessionOpenInput } from '../sessions/types.js';
19
21
  import type { AgentContentReferenceInputPart, AgentItemSnapshot, AgentTurnInputContent, AgentTurnInterruptionInput, AgentTurnRunInput } from '../turns/types.js';
20
- import { AgentAccountQuotaSnapshotSchema, AgentAccountQuotaWindowSchema } from './accountQuota.js';
22
+ import { AgentAccountQuotaResetSchema, AgentAccountQuotaSnapshotSchema, AgentAccountQuotaWindowSchema } from './accountQuota.js';
21
23
  import { AgentArtifactDescriptorSchema } from './artifacts.js';
22
- import { AgentCapabilitiesSchema } from './capabilities.js';
24
+ import { AgentApprovalCapabilitySchema, AgentCapabilitiesSchema } from './capabilities.js';
23
25
  import { AgentCollaborationControlInputSchema, AgentCollaborationNodeSchema, AgentCollaborationSpawnInputSchema } from './collaboration.js';
24
26
  import { AgentCommandCatalogSchema, AgentCommandDescriptorSchema } from './commands.js';
25
27
  import { AgentConfigurationCatalogSchema, AgentConfigurationSelectionInputSchema } from './configuration.js';
@@ -27,17 +29,29 @@ import { AgentEffectiveContentCatalogSchema, AgentEffectiveContentDescriptorSche
27
29
  import { AgentEnvironmentCapabilitySchema, AgentEnvironmentInvalidationSchema, AgentEnvironmentSnapshotSchema } from './environment.js';
28
30
  import { AgentEventSchema } from './events.js';
29
31
  import { AgentExtensionCatalogSchema, AgentExtensionDescriptorSchema } from './extensions.js';
30
- import { AgentErrorSchema, AgentJsonValueSchema, AgentProviderRefsSchema } from './foundation.js';
32
+ import { AgentErrorContextSchema, AgentErrorSchema, AgentFailureCategorySchema, AgentFailureQuotaReferenceSchema, AgentRecoveryHintSchema } from './failures.js';
33
+ import { AgentJsonValueSchema, AgentProviderRefsSchema } from './foundation.js';
31
34
  import { AgentIntegrationCatalogSchema, AgentIntegrationDescriptorSchema, AgentMcpIntegrationDescriptorSchema } from './integrations.js';
32
35
  import { AgentManagedContentCatalogSchema, AgentManagedContentDescriptorSchema } from './managedContent.js';
33
36
  import { AgentOperationCatalogSchema, AgentOperationDescriptorSchema, AgentOperationInvocationSchema, AgentOperationResultSchema } from './operations.js';
34
- import { AgentRequestResolutionSchema, AgentRequestSchema } from './requests.js';
37
+ import { AgentApprovalConsequenceSchema, AgentRequestResolutionSchema, AgentRequestSchema } from './requests.js';
35
38
  import { AgentGeneratedResourceDescriptorSchema } from './resources.js';
39
+ import { AgentSessionDecisionChoiceSchema, AgentSessionDecisionConsequenceSchema, AgentSessionDecisionRequestSchema, AgentSessionDecisionResponseSchema, AgentSessionWorkspaceTargetSchema } from './sessionInteractions.js';
36
40
  import { AgentSessionBindingSchema, AgentSessionConfigurationSchema, AgentSessionOpenInputSchema } from './sessions.js';
37
41
  import { AgentContentReferenceInputPartSchema, AgentItemSnapshotSchema, AgentTurnInputContentSchema, AgentTurnInterruptionInputSchema, AgentTurnRunInputSchema } from './turns.js';
38
42
  type Extends<Left, Right> = [Left] extends [Right] ? true : false;
39
43
  type Assert<Value extends true> = Value;
40
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>>>,
41
55
  Assert<Extends<z.output<typeof AgentEffectiveContentCatalogSchema>, AgentEffectiveContentCatalog>>,
42
56
  Assert<Extends<AgentEffectiveContentCatalog, z.output<typeof AgentEffectiveContentCatalogSchema>>>,
43
57
  Assert<Extends<z.output<typeof AgentEffectiveContentDescriptorSchema>, AgentEffectiveContentDescriptor>>,
@@ -62,12 +76,22 @@ export type AgentProtocolSchemaTypeAssertions = readonly [
62
76
  Assert<Extends<AgentAccountQuotaSnapshot, z.output<typeof AgentAccountQuotaSnapshotSchema>>>,
63
77
  Assert<Extends<z.output<typeof AgentAccountQuotaWindowSchema>, AgentAccountQuotaWindow>>,
64
78
  Assert<Extends<AgentAccountQuotaWindow, z.output<typeof AgentAccountQuotaWindowSchema>>>,
79
+ Assert<Extends<z.output<typeof AgentAccountQuotaResetSchema>, AgentAccountQuotaReset>>,
80
+ Assert<Extends<AgentAccountQuotaReset, z.output<typeof AgentAccountQuotaResetSchema>>>,
65
81
  Assert<Extends<z.output<typeof AgentJsonValueSchema>, AgentJsonValue>>,
66
82
  Assert<Extends<AgentJsonValue, z.output<typeof AgentJsonValueSchema>>>,
67
83
  Assert<Extends<z.output<typeof AgentProviderRefsSchema>, AgentProviderRefs>>,
68
84
  Assert<Extends<AgentProviderRefs, z.output<typeof AgentProviderRefsSchema>>>,
69
85
  Assert<Extends<z.output<typeof AgentErrorSchema>, AgentError>>,
70
86
  Assert<Extends<AgentError, z.output<typeof AgentErrorSchema>>>,
87
+ Assert<Extends<z.output<typeof AgentErrorContextSchema>, AgentErrorContext>>,
88
+ Assert<Extends<AgentErrorContext, z.output<typeof AgentErrorContextSchema>>>,
89
+ Assert<Extends<z.output<typeof AgentFailureCategorySchema>, AgentFailureCategory>>,
90
+ Assert<Extends<AgentFailureCategory, z.output<typeof AgentFailureCategorySchema>>>,
91
+ Assert<Extends<z.output<typeof AgentFailureQuotaReferenceSchema>, AgentFailureQuotaReference>>,
92
+ Assert<Extends<AgentFailureQuotaReference, z.output<typeof AgentFailureQuotaReferenceSchema>>>,
93
+ Assert<Extends<z.output<typeof AgentRecoveryHintSchema>, AgentRecoveryHint>>,
94
+ Assert<Extends<AgentRecoveryHint, z.output<typeof AgentRecoveryHintSchema>>>,
71
95
  Assert<Extends<z.output<typeof AgentSessionBindingSchema>, AgentSessionBinding>>,
72
96
  Assert<Extends<AgentSessionBinding, z.output<typeof AgentSessionBindingSchema>>>,
73
97
  Assert<Extends<z.output<typeof AgentSessionConfigurationSchema>, AgentSessionConfiguration>>,
@@ -82,6 +106,10 @@ export type AgentProtocolSchemaTypeAssertions = readonly [
82
106
  Assert<Extends<AgentTurnInterruptionInput, z.output<typeof AgentTurnInterruptionInputSchema>>>,
83
107
  Assert<Extends<z.output<typeof AgentItemSnapshotSchema>, AgentItemSnapshot>>,
84
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>>>,
85
113
  Assert<Extends<z.output<typeof AgentRequestSchema>, AgentRequest>>,
86
114
  Assert<Extends<AgentRequest, z.output<typeof AgentRequestSchema>>>,
87
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.3.1",
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.3.1"
107
+ "@agen-ai/validation": "^0.4.1"
104
108
  },
105
109
  "devDependencies": {
106
110
  "ajv": "8.17.1",