@agen-ai/agent-protocol 0.1.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.
Files changed (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +101 -0
  3. package/dist/artifacts/index.d.ts +3 -0
  4. package/dist/artifacts/index.js +2 -0
  5. package/dist/artifacts/parsers.d.ts +5 -0
  6. package/dist/artifacts/parsers.js +12 -0
  7. package/dist/artifacts/types.d.ts +19 -0
  8. package/dist/artifacts/types.js +16 -0
  9. package/dist/capabilities/index.d.ts +3 -0
  10. package/dist/capabilities/index.js +2 -0
  11. package/dist/capabilities/parsers.d.ts +6 -0
  12. package/dist/capabilities/parsers.js +18 -0
  13. package/dist/capabilities/types.d.ts +96 -0
  14. package/dist/capabilities/types.js +20 -0
  15. package/dist/events/index.d.ts +3 -0
  16. package/dist/events/index.js +2 -0
  17. package/dist/events/parsers.d.ts +6 -0
  18. package/dist/events/parsers.js +16 -0
  19. package/dist/events/types.d.ts +78 -0
  20. package/dist/events/types.js +21 -0
  21. package/dist/foundation/index.d.ts +4 -0
  22. package/dist/foundation/index.js +3 -0
  23. package/dist/foundation/ordering.d.ts +2 -0
  24. package/dist/foundation/ordering.js +15 -0
  25. package/dist/foundation/parsers.d.ts +39 -0
  26. package/dist/foundation/parsers.js +148 -0
  27. package/dist/foundation/types.d.ts +62 -0
  28. package/dist/foundation/types.js +39 -0
  29. package/dist/foundation/validation.d.ts +16 -0
  30. package/dist/foundation/validation.js +11 -0
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.js +1 -0
  33. package/dist/internal/parsers.d.ts +5 -0
  34. package/dist/internal/parsers.js +21 -0
  35. package/dist/jsonSchema/generated.d.ts +6667 -0
  36. package/dist/jsonSchema/generated.js +4150 -0
  37. package/dist/jsonSchema/index.d.ts +2 -0
  38. package/dist/jsonSchema/index.js +1 -0
  39. package/dist/public/artifacts.d.ts +2 -0
  40. package/dist/public/artifacts.js +1 -0
  41. package/dist/public/capabilities.d.ts +2 -0
  42. package/dist/public/capabilities.js +1 -0
  43. package/dist/public/events.d.ts +2 -0
  44. package/dist/public/events.js +1 -0
  45. package/dist/public/index.d.ts +8 -0
  46. package/dist/public/index.js +7 -0
  47. package/dist/public/requests.d.ts +2 -0
  48. package/dist/public/requests.js +1 -0
  49. package/dist/public/sessions.d.ts +2 -0
  50. package/dist/public/sessions.js +1 -0
  51. package/dist/public/turns.d.ts +2 -0
  52. package/dist/public/turns.js +1 -0
  53. package/dist/requests/index.d.ts +3 -0
  54. package/dist/requests/index.js +2 -0
  55. package/dist/requests/parsers.d.ts +9 -0
  56. package/dist/requests/parsers.js +134 -0
  57. package/dist/requests/types.d.ts +89 -0
  58. package/dist/requests/types.js +0 -0
  59. package/dist/sessions/index.d.ts +3 -0
  60. package/dist/sessions/index.js +2 -0
  61. package/dist/sessions/parsers.d.ts +10 -0
  62. package/dist/sessions/parsers.js +38 -0
  63. package/dist/sessions/types.d.ts +37 -0
  64. package/dist/sessions/types.js +0 -0
  65. package/dist/turns/index.d.ts +3 -0
  66. package/dist/turns/index.js +2 -0
  67. package/dist/turns/parsers.d.ts +11 -0
  68. package/dist/turns/parsers.js +41 -0
  69. package/dist/turns/types.d.ts +207 -0
  70. package/dist/turns/types.js +62 -0
  71. package/dist/zod/artifacts.d.ts +4 -0
  72. package/dist/zod/artifacts.js +28 -0
  73. package/dist/zod/capabilities.d.ts +180 -0
  74. package/dist/zod/capabilities.js +222 -0
  75. package/dist/zod/events.d.ts +357 -0
  76. package/dist/zod/events.js +190 -0
  77. package/dist/zod/foundation.d.ts +45 -0
  78. package/dist/zod/foundation.js +205 -0
  79. package/dist/zod/index.d.ts +9 -0
  80. package/dist/zod/index.js +118 -0
  81. package/dist/zod/requests.d.ts +123 -0
  82. package/dist/zod/requests.js +174 -0
  83. package/dist/zod/sessions.d.ts +65 -0
  84. package/dist/zod/sessions.js +124 -0
  85. package/dist/zod/turns.d.ts +219 -0
  86. package/dist/zod/turns.js +400 -0
  87. package/dist/zod/typeEquality.generated.d.ts +51 -0
  88. package/dist/zod/typeEquality.generated.js +0 -0
  89. package/package.json +95 -0
@@ -0,0 +1,123 @@
1
+ import { z } from 'zod/v4';
2
+ import type { AgentElicitationRequest, AgentRequest, AgentRequestResolution } from '../requests/types.js';
3
+ export declare const AgentElicitationRequestPortableSchema: z.ZodReadonly<z.ZodObject<{
4
+ requestKind: z.ZodLiteral<"elicitation">;
5
+ requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
6
+ prompt: z.ZodString;
7
+ fields: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
8
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
9
+ label: z.ZodString;
10
+ description: z.ZodOptional<z.ZodString>;
11
+ required: z.ZodBoolean;
12
+ kind: z.ZodLiteral<"text">;
13
+ multiline: z.ZodOptional<z.ZodBoolean>;
14
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
15
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
16
+ label: z.ZodString;
17
+ description: z.ZodOptional<z.ZodString>;
18
+ required: z.ZodBoolean;
19
+ kind: z.ZodLiteral<"choice">;
20
+ options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
21
+ value: z.ZodIntersection<z.ZodString, z.ZodString>;
22
+ label: z.ZodString;
23
+ description: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strict>>>>;
25
+ multiple: z.ZodBoolean;
26
+ allowOther: z.ZodBoolean;
27
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
28
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
29
+ label: z.ZodString;
30
+ description: z.ZodOptional<z.ZodString>;
31
+ required: z.ZodBoolean;
32
+ kind: z.ZodLiteral<"boolean">;
33
+ }, z.core.$strict>>], "kind">>>;
34
+ expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
35
+ }, z.core.$strict>>;
36
+ export declare const AgentElicitationRequestSchema: z.ZodType<AgentElicitationRequest>;
37
+ export declare const AgentRequestPortableSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
38
+ requestKind: z.ZodLiteral<"approval">;
39
+ requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
40
+ prompt: z.ZodString;
41
+ subject: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
42
+ kind: z.ZodLiteral<"plan">;
43
+ title: z.ZodString;
44
+ description: z.ZodOptional<z.ZodString>;
45
+ artifactId: z.ZodType<import("../index.js").AgentArtifactId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentArtifactId, unknown>>;
46
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
47
+ kind: z.ZodEnum<{
48
+ other: "other";
49
+ file_change: "file_change";
50
+ command: "command";
51
+ tool: "tool";
52
+ }>;
53
+ title: z.ZodString;
54
+ description: z.ZodOptional<z.ZodString>;
55
+ }, z.core.$strict>>], "kind">;
56
+ expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
57
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
58
+ requestKind: z.ZodLiteral<"elicitation">;
59
+ requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
60
+ prompt: z.ZodString;
61
+ fields: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
62
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
63
+ label: z.ZodString;
64
+ description: z.ZodOptional<z.ZodString>;
65
+ required: z.ZodBoolean;
66
+ kind: z.ZodLiteral<"text">;
67
+ multiline: z.ZodOptional<z.ZodBoolean>;
68
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
69
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
70
+ label: z.ZodString;
71
+ description: z.ZodOptional<z.ZodString>;
72
+ required: z.ZodBoolean;
73
+ kind: z.ZodLiteral<"choice">;
74
+ options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
75
+ value: z.ZodIntersection<z.ZodString, z.ZodString>;
76
+ label: z.ZodString;
77
+ description: z.ZodOptional<z.ZodString>;
78
+ }, z.core.$strict>>>>;
79
+ multiple: z.ZodBoolean;
80
+ allowOther: z.ZodBoolean;
81
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
82
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
83
+ label: z.ZodString;
84
+ description: z.ZodOptional<z.ZodString>;
85
+ required: z.ZodBoolean;
86
+ kind: z.ZodLiteral<"boolean">;
87
+ }, z.core.$strict>>], "kind">>>;
88
+ expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
89
+ }, z.core.$strict>>], "requestKind">;
90
+ export declare const AgentRequestSchema: z.ZodType<AgentRequest>;
91
+ export declare const AgentRequestResolutionPortableSchema: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
92
+ requestKind: z.ZodLiteral<"approval">;
93
+ requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
94
+ decision: z.ZodEnum<{
95
+ canceled: "canceled";
96
+ approved: "approved";
97
+ denied: "denied";
98
+ }>;
99
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
100
+ requestKind: z.ZodLiteral<"elicitation">;
101
+ requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
102
+ disposition: z.ZodLiteral<"answered">;
103
+ answers: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
104
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
105
+ kind: z.ZodLiteral<"text">;
106
+ value: z.ZodString;
107
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
108
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
109
+ kind: z.ZodLiteral<"choice">;
110
+ values: z.ZodReadonly<z.ZodArray<z.ZodIntersection<z.ZodString, z.ZodString>>>;
111
+ other: z.ZodOptional<z.ZodString>;
112
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
113
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
114
+ kind: z.ZodLiteral<"boolean">;
115
+ value: z.ZodBoolean;
116
+ }, z.core.$strict>>], "kind">>>;
117
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
118
+ requestKind: z.ZodLiteral<"elicitation">;
119
+ requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
120
+ disposition: z.ZodLiteral<"canceled">;
121
+ }, z.core.$strict>>]>;
122
+ export declare const AgentRequestResolutionSchema: z.ZodType<AgentRequestResolution>;
123
+ //# sourceMappingURL=requests.d.ts.map
@@ -0,0 +1,174 @@
1
+ import { z } from "zod/v4";
2
+ import {
3
+ AGENT_PROTOCOL_COLLECTION_MAX_LENGTH,
4
+ AGENT_PROTOCOL_SUMMARY_MAX_LENGTH,
5
+ AGENT_PROTOCOL_TEXT_MAX_LENGTH
6
+ } from "../foundation/types.js";
7
+ import {
8
+ AgentArtifactIdSchema,
9
+ AgentCanonicalIdValueSchema,
10
+ AgentIsoDateTimeSchema,
11
+ AgentRequestFieldIdSchema,
12
+ AgentRequestIdSchema
13
+ } from "./foundation.js";
14
+ const AgentApprovalRequestSchema = z.object({
15
+ requestKind: z.literal("approval"),
16
+ requestId: AgentRequestIdSchema,
17
+ prompt: z.string().min(1).max(AGENT_PROTOCOL_TEXT_MAX_LENGTH),
18
+ subject: z.discriminatedUnion("kind", [
19
+ z.object({
20
+ kind: z.literal("plan"),
21
+ title: z.string().min(1).max(200),
22
+ description: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional(),
23
+ artifactId: AgentArtifactIdSchema
24
+ }).strict().readonly(),
25
+ z.object({
26
+ kind: z.enum(["command", "file_change", "tool", "other"]),
27
+ title: z.string().min(1).max(200),
28
+ description: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional()
29
+ }).strict().readonly()
30
+ ]),
31
+ expiresAt: AgentIsoDateTimeSchema.optional()
32
+ }).strict().readonly();
33
+ const AgentRequestChoiceValueSchema = AgentCanonicalIdValueSchema.and(
34
+ z.string().max(160)
35
+ );
36
+ const AgentRequestChoiceSchema = z.object({
37
+ value: AgentRequestChoiceValueSchema,
38
+ label: z.string().min(1).max(200),
39
+ description: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional()
40
+ }).strict().readonly();
41
+ const AgentElicitationFieldSchema = z.discriminatedUnion("kind", [
42
+ z.object({
43
+ fieldId: AgentRequestFieldIdSchema,
44
+ label: z.string().min(1).max(200),
45
+ description: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional(),
46
+ required: z.boolean(),
47
+ kind: z.literal("text"),
48
+ multiline: z.boolean().optional()
49
+ }).strict().readonly(),
50
+ z.object({
51
+ fieldId: AgentRequestFieldIdSchema,
52
+ label: z.string().min(1).max(200),
53
+ description: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional(),
54
+ required: z.boolean(),
55
+ kind: z.literal("choice"),
56
+ options: z.array(AgentRequestChoiceSchema).min(1).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly(),
57
+ multiple: z.boolean(),
58
+ allowOther: z.boolean()
59
+ }).strict().readonly(),
60
+ z.object({
61
+ fieldId: AgentRequestFieldIdSchema,
62
+ label: z.string().min(1).max(200),
63
+ description: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional(),
64
+ required: z.boolean(),
65
+ kind: z.literal("boolean")
66
+ }).strict().readonly()
67
+ ]);
68
+ const AgentElicitationRequestPortableSchema = z.object({
69
+ requestKind: z.literal("elicitation"),
70
+ requestId: AgentRequestIdSchema,
71
+ prompt: z.string().min(1).max(AGENT_PROTOCOL_TEXT_MAX_LENGTH),
72
+ fields: z.array(AgentElicitationFieldSchema).min(1).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly(),
73
+ expiresAt: AgentIsoDateTimeSchema.optional()
74
+ }).strict().readonly();
75
+ const AgentElicitationRequestSchema = AgentElicitationRequestPortableSchema.superRefine((request, context) => {
76
+ const fieldIds = /* @__PURE__ */ new Set();
77
+ request.fields.forEach((field, fieldIndex) => {
78
+ if (fieldIds.has(field.fieldId)) {
79
+ context.addIssue({
80
+ code: "custom",
81
+ path: ["fields", fieldIndex, "fieldId"],
82
+ message: "Request field IDs must be unique."
83
+ });
84
+ }
85
+ fieldIds.add(field.fieldId);
86
+ if (field.kind !== "choice") return;
87
+ const optionValues = /* @__PURE__ */ new Set();
88
+ field.options.forEach((option, optionIndex) => {
89
+ if (optionValues.has(option.value)) {
90
+ context.addIssue({
91
+ code: "custom",
92
+ path: ["fields", fieldIndex, "options", optionIndex, "value"],
93
+ message: "Choice option values must be unique within a field."
94
+ });
95
+ }
96
+ optionValues.add(option.value);
97
+ });
98
+ });
99
+ });
100
+ const AgentRequestPortableSchema = z.discriminatedUnion("requestKind", [
101
+ AgentApprovalRequestSchema,
102
+ AgentElicitationRequestPortableSchema
103
+ ]);
104
+ const AgentRequestSchema = AgentRequestPortableSchema.superRefine((request, context) => {
105
+ if (request.requestKind !== "elicitation") return;
106
+ const parsed = AgentElicitationRequestSchema.safeParse(request);
107
+ if (parsed.success) return;
108
+ for (const issue of parsed.error.issues) {
109
+ context.addIssue({
110
+ code: "custom",
111
+ path: issue.path,
112
+ message: issue.message
113
+ });
114
+ }
115
+ });
116
+ const AgentElicitationFreeformAnswerSchema = z.string().max(AGENT_PROTOCOL_TEXT_MAX_LENGTH).regex(/\S/u, "Free-form answers must contain non-whitespace content.");
117
+ const AgentElicitationAnswerSchema = z.discriminatedUnion("kind", [
118
+ z.object({
119
+ fieldId: AgentRequestFieldIdSchema,
120
+ kind: z.literal("text"),
121
+ value: AgentElicitationFreeformAnswerSchema
122
+ }).strict().readonly(),
123
+ z.object({
124
+ fieldId: AgentRequestFieldIdSchema,
125
+ kind: z.literal("choice"),
126
+ values: z.array(AgentRequestChoiceValueSchema).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly(),
127
+ other: AgentElicitationFreeformAnswerSchema.optional()
128
+ }).strict().readonly(),
129
+ z.object({
130
+ fieldId: AgentRequestFieldIdSchema,
131
+ kind: z.literal("boolean"),
132
+ value: z.boolean()
133
+ }).strict().readonly()
134
+ ]);
135
+ const AgentRequestResolutionPortableSchema = z.union([
136
+ z.object({
137
+ requestKind: z.literal("approval"),
138
+ requestId: AgentRequestIdSchema,
139
+ decision: z.enum(["approved", "denied", "canceled"])
140
+ }).strict().readonly(),
141
+ z.object({
142
+ requestKind: z.literal("elicitation"),
143
+ requestId: AgentRequestIdSchema,
144
+ disposition: z.literal("answered"),
145
+ answers: z.array(AgentElicitationAnswerSchema).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly()
146
+ }).strict().readonly(),
147
+ z.object({
148
+ requestKind: z.literal("elicitation"),
149
+ requestId: AgentRequestIdSchema,
150
+ disposition: z.literal("canceled")
151
+ }).strict().readonly()
152
+ ]);
153
+ const AgentRequestResolutionSchema = AgentRequestResolutionPortableSchema.superRefine((resolution, context) => {
154
+ if (resolution.requestKind !== "elicitation" || resolution.disposition !== "answered") {
155
+ return;
156
+ }
157
+ resolution.answers.forEach((answer, answerIndex) => {
158
+ if (answer.kind === "choice" && new Set(answer.values).size !== answer.values.length) {
159
+ context.addIssue({
160
+ code: "custom",
161
+ path: ["answers", answerIndex, "values"],
162
+ message: "Choice answers cannot select the same option more than once."
163
+ });
164
+ }
165
+ });
166
+ });
167
+ export {
168
+ AgentElicitationRequestPortableSchema,
169
+ AgentElicitationRequestSchema,
170
+ AgentRequestPortableSchema,
171
+ AgentRequestResolutionPortableSchema,
172
+ AgentRequestResolutionSchema,
173
+ AgentRequestSchema
174
+ };
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod/v4';
2
+ import type { AgentSessionBinding, AgentSessionBranchSource, AgentSessionBranchInput, AgentSessionConfiguration, AgentSessionCreateInput, AgentSessionOpenInput, AgentSessionResumeInput } from '../sessions/types.js';
3
+ export declare const AgentSessionBindingSchema: z.ZodType<AgentSessionBinding>;
4
+ export declare const AgentSessionConfigurationPortableSchema: z.ZodReadonly<z.ZodObject<{
5
+ revision: z.ZodType<import("../index.js").AgentConfigurationRevisionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentConfigurationRevisionId, unknown>>;
6
+ values: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodType<import("../index.js").AgentJsonValue, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentJsonValue, unknown>>>>;
7
+ }, z.core.$strict>>;
8
+ export declare const AgentSessionConfigurationSchema: z.ZodType<AgentSessionConfiguration>;
9
+ export declare const AgentSessionCreateInputPortableSchema: z.ZodReadonly<z.ZodObject<{
10
+ operation: z.ZodLiteral<"create">;
11
+ sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
12
+ configuration: z.ZodReadonly<z.ZodObject<{
13
+ revision: z.ZodType<import("../index.js").AgentConfigurationRevisionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentConfigurationRevisionId, unknown>>;
14
+ values: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodType<import("../index.js").AgentJsonValue, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentJsonValue, unknown>>>>;
15
+ }, z.core.$strict>>;
16
+ }, z.core.$strict>>;
17
+ export declare const AgentSessionResumeInputPortableSchema: z.ZodReadonly<z.ZodObject<{
18
+ operation: z.ZodLiteral<"resume">;
19
+ sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
20
+ binding: z.ZodType<AgentSessionBinding, unknown, z.core.$ZodTypeInternals<AgentSessionBinding, unknown>>;
21
+ configuration: z.ZodReadonly<z.ZodObject<{
22
+ revision: z.ZodType<import("../index.js").AgentConfigurationRevisionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentConfigurationRevisionId, unknown>>;
23
+ values: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodType<import("../index.js").AgentJsonValue, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentJsonValue, unknown>>>>;
24
+ }, z.core.$strict>>;
25
+ }, z.core.$strict>>;
26
+ export declare const AgentSessionBranchSourceSchema: z.ZodType<AgentSessionBranchSource>;
27
+ export declare const AgentSessionBranchInputPortableSchema: z.ZodReadonly<z.ZodObject<{
28
+ operation: z.ZodLiteral<"branch">;
29
+ sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
30
+ source: z.ZodType<AgentSessionBranchSource, unknown, z.core.$ZodTypeInternals<AgentSessionBranchSource, unknown>>;
31
+ configuration: z.ZodReadonly<z.ZodObject<{
32
+ revision: z.ZodType<import("../index.js").AgentConfigurationRevisionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentConfigurationRevisionId, unknown>>;
33
+ values: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodType<import("../index.js").AgentJsonValue, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentJsonValue, unknown>>>>;
34
+ }, z.core.$strict>>;
35
+ }, z.core.$strict>>;
36
+ declare const AgentSessionOpenInputPortableSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
37
+ operation: z.ZodLiteral<"create">;
38
+ sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
39
+ configuration: z.ZodReadonly<z.ZodObject<{
40
+ revision: z.ZodType<import("../index.js").AgentConfigurationRevisionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentConfigurationRevisionId, unknown>>;
41
+ values: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodType<import("../index.js").AgentJsonValue, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentJsonValue, unknown>>>>;
42
+ }, z.core.$strict>>;
43
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
44
+ operation: z.ZodLiteral<"resume">;
45
+ sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
46
+ binding: z.ZodType<AgentSessionBinding, unknown, z.core.$ZodTypeInternals<AgentSessionBinding, unknown>>;
47
+ configuration: z.ZodReadonly<z.ZodObject<{
48
+ revision: z.ZodType<import("../index.js").AgentConfigurationRevisionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentConfigurationRevisionId, unknown>>;
49
+ values: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodType<import("../index.js").AgentJsonValue, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentJsonValue, unknown>>>>;
50
+ }, z.core.$strict>>;
51
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
52
+ operation: z.ZodLiteral<"branch">;
53
+ sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
54
+ source: z.ZodType<AgentSessionBranchSource, unknown, z.core.$ZodTypeInternals<AgentSessionBranchSource, unknown>>;
55
+ configuration: z.ZodReadonly<z.ZodObject<{
56
+ revision: z.ZodType<import("../index.js").AgentConfigurationRevisionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentConfigurationRevisionId, unknown>>;
57
+ values: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodType<import("../index.js").AgentJsonValue, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentJsonValue, unknown>>>>;
58
+ }, z.core.$strict>>;
59
+ }, z.core.$strict>>], "operation">;
60
+ export declare const AgentSessionCreateInputSchema: z.ZodType<AgentSessionCreateInput>;
61
+ export declare const AgentSessionResumeInputSchema: z.ZodType<AgentSessionResumeInput>;
62
+ export declare const AgentSessionBranchInputSchema: z.ZodType<AgentSessionBranchInput>;
63
+ export declare const AgentSessionOpenInputSchema: z.ZodType<AgentSessionOpenInput>;
64
+ export { AgentSessionOpenInputPortableSchema };
65
+ //# sourceMappingURL=sessions.d.ts.map
@@ -0,0 +1,124 @@
1
+ import { z } from "zod/v4";
2
+ import {
3
+ AGENT_PROTOCOL_COLLECTION_MAX_LENGTH,
4
+ AGENT_PROTOCOL_JSON_BYTES_LIMIT,
5
+ AGENT_PROTOCOL_JSON_DEPTH_LIMIT,
6
+ agentProtocolSerializedJsonBytes
7
+ } from "../foundation/types.js";
8
+ import {
9
+ AgentConfigurationRevisionIdSchema,
10
+ AgentJsonObjectKeySchema,
11
+ AgentJsonValuePortableSchema,
12
+ AgentProviderConversationIdSchema,
13
+ AgentProviderHistoryAnchorSchema,
14
+ AgentSessionIdSchema,
15
+ AgentTurnIdSchema,
16
+ withAcyclicProtocolInput
17
+ } from "./foundation.js";
18
+ const SESSION_CONFIGURATION_JSON_DEPTH_OFFSET = 2;
19
+ const SESSION_OPEN_JSON_DEPTH_OFFSET = 3;
20
+ const AgentSessionBindingSchema = z.object({
21
+ conversationId: AgentProviderConversationIdSchema,
22
+ historyAnchor: AgentProviderHistoryAnchorSchema.optional()
23
+ }).strict().readonly();
24
+ const AgentSessionConfigurationPortableSchema = z.object({
25
+ revision: AgentConfigurationRevisionIdSchema,
26
+ values: z.record(
27
+ AgentJsonObjectKeySchema,
28
+ AgentJsonValuePortableSchema
29
+ ).readonly()
30
+ }).strict().readonly();
31
+ const AgentSessionConfigurationSchema = withAcyclicProtocolInput(AgentSessionConfigurationPortableSchema, {
32
+ maxDepth: AGENT_PROTOCOL_JSON_DEPTH_LIMIT + SESSION_CONFIGURATION_JSON_DEPTH_OFFSET,
33
+ maxCollectionLength: AGENT_PROTOCOL_COLLECTION_MAX_LENGTH
34
+ }).superRefine((configuration, context) => {
35
+ if (Object.keys(configuration.values).length > AGENT_PROTOCOL_COLLECTION_MAX_LENGTH) {
36
+ context.addIssue({
37
+ code: "custom",
38
+ path: ["values"],
39
+ message: `Session configuration cannot exceed ${AGENT_PROTOCOL_COLLECTION_MAX_LENGTH} entries.`
40
+ });
41
+ }
42
+ if (agentProtocolSerializedJsonBytes(configuration.values) > AGENT_PROTOCOL_JSON_BYTES_LIMIT) {
43
+ context.addIssue({
44
+ code: "custom",
45
+ path: ["values"],
46
+ message: `Session configuration cannot exceed ${AGENT_PROTOCOL_JSON_BYTES_LIMIT} serialized bytes.`
47
+ });
48
+ }
49
+ });
50
+ const AgentSessionCreateInputPortableSchema = z.object({
51
+ operation: z.literal("create"),
52
+ sessionId: AgentSessionIdSchema,
53
+ configuration: AgentSessionConfigurationPortableSchema
54
+ }).strict().readonly();
55
+ const AgentSessionResumeInputPortableSchema = z.object({
56
+ operation: z.literal("resume"),
57
+ sessionId: AgentSessionIdSchema,
58
+ binding: AgentSessionBindingSchema,
59
+ configuration: AgentSessionConfigurationPortableSchema
60
+ }).strict().readonly();
61
+ const AgentSessionBranchSourceSchema = z.object({
62
+ sessionId: AgentSessionIdSchema,
63
+ binding: AgentSessionBindingSchema,
64
+ throughTurn: z.object({
65
+ turnId: AgentTurnIdSchema,
66
+ historyAnchor: AgentProviderHistoryAnchorSchema
67
+ }).strict().readonly()
68
+ }).strict().readonly();
69
+ const AgentSessionBranchInputPortableSchema = z.object({
70
+ operation: z.literal("branch"),
71
+ sessionId: AgentSessionIdSchema,
72
+ source: AgentSessionBranchSourceSchema,
73
+ configuration: AgentSessionConfigurationPortableSchema
74
+ }).strict().readonly();
75
+ const AgentSessionOpenInputPortableSchema = z.discriminatedUnion("operation", [
76
+ AgentSessionCreateInputPortableSchema,
77
+ AgentSessionResumeInputPortableSchema,
78
+ AgentSessionBranchInputPortableSchema
79
+ ]);
80
+ function validateSessionOpenInput(input, context) {
81
+ const parsed = AgentSessionConfigurationSchema.safeParse(input.configuration);
82
+ if (!parsed.success) {
83
+ for (const issue of parsed.error.issues) {
84
+ context.addIssue({ ...issue, path: ["configuration", ...issue.path] });
85
+ }
86
+ }
87
+ if (input.operation === "branch" && input.sessionId === input.source.sessionId) {
88
+ context.addIssue({
89
+ code: "custom",
90
+ path: ["sessionId"],
91
+ message: "Branch target sessionId must differ from its source sessionId."
92
+ });
93
+ }
94
+ }
95
+ const AgentSessionCreateInputSchema = withAcyclicProtocolInput(AgentSessionCreateInputPortableSchema, {
96
+ maxDepth: AGENT_PROTOCOL_JSON_DEPTH_LIMIT + SESSION_OPEN_JSON_DEPTH_OFFSET,
97
+ maxCollectionLength: AGENT_PROTOCOL_COLLECTION_MAX_LENGTH
98
+ }).superRefine(validateSessionOpenInput);
99
+ const AgentSessionResumeInputSchema = withAcyclicProtocolInput(AgentSessionResumeInputPortableSchema, {
100
+ maxDepth: AGENT_PROTOCOL_JSON_DEPTH_LIMIT + SESSION_OPEN_JSON_DEPTH_OFFSET,
101
+ maxCollectionLength: AGENT_PROTOCOL_COLLECTION_MAX_LENGTH
102
+ }).superRefine(validateSessionOpenInput);
103
+ const AgentSessionBranchInputSchema = withAcyclicProtocolInput(AgentSessionBranchInputPortableSchema, {
104
+ maxDepth: AGENT_PROTOCOL_JSON_DEPTH_LIMIT + SESSION_OPEN_JSON_DEPTH_OFFSET,
105
+ maxCollectionLength: AGENT_PROTOCOL_COLLECTION_MAX_LENGTH
106
+ }).superRefine(validateSessionOpenInput);
107
+ const AgentSessionOpenInputSchema = withAcyclicProtocolInput(AgentSessionOpenInputPortableSchema, {
108
+ maxDepth: AGENT_PROTOCOL_JSON_DEPTH_LIMIT + SESSION_OPEN_JSON_DEPTH_OFFSET,
109
+ maxCollectionLength: AGENT_PROTOCOL_COLLECTION_MAX_LENGTH
110
+ }).superRefine(validateSessionOpenInput);
111
+ export {
112
+ AgentSessionBindingSchema,
113
+ AgentSessionBranchInputPortableSchema,
114
+ AgentSessionBranchInputSchema,
115
+ AgentSessionBranchSourceSchema,
116
+ AgentSessionConfigurationPortableSchema,
117
+ AgentSessionConfigurationSchema,
118
+ AgentSessionCreateInputPortableSchema,
119
+ AgentSessionCreateInputSchema,
120
+ AgentSessionOpenInputPortableSchema,
121
+ AgentSessionOpenInputSchema,
122
+ AgentSessionResumeInputPortableSchema,
123
+ AgentSessionResumeInputSchema
124
+ };