@agen-ai/agent-protocol 0.2.2 → 0.2.4

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 (91) hide show
  1. package/README.md +22 -12
  2. package/dist/capabilities/types.d.ts +64 -18
  3. package/dist/capabilities/types.js +0 -6
  4. package/dist/collaboration/index.d.ts +3 -0
  5. package/dist/collaboration/index.js +2 -0
  6. package/dist/collaboration/parsers.d.ts +9 -0
  7. package/dist/collaboration/parsers.js +32 -0
  8. package/dist/collaboration/types.d.ts +88 -0
  9. package/dist/collaboration/types.js +64 -0
  10. package/dist/configuration/index.d.ts +3 -0
  11. package/dist/configuration/index.js +2 -0
  12. package/dist/configuration/parsers.d.ts +9 -0
  13. package/dist/configuration/parsers.js +98 -0
  14. package/dist/configuration/types.d.ts +72 -0
  15. package/dist/configuration/types.js +27 -0
  16. package/dist/events/types.d.ts +15 -3
  17. package/dist/events/types.js +3 -0
  18. package/dist/foundation/parsers.d.ts +19 -1
  19. package/dist/foundation/parsers.js +70 -0
  20. package/dist/foundation/types.d.ts +10 -1
  21. package/dist/foundation/types.js +1 -1
  22. package/dist/integrations/index.d.ts +3 -0
  23. package/dist/integrations/index.js +2 -0
  24. package/dist/integrations/parsers.d.ts +7 -0
  25. package/dist/integrations/parsers.js +23 -0
  26. package/dist/integrations/types.d.ts +43 -0
  27. package/dist/integrations/types.js +23 -0
  28. package/dist/jsonSchema/generated.d.ts +9686 -3515
  29. package/dist/jsonSchema/generated.js +5341 -1391
  30. package/dist/managedContent/index.d.ts +3 -0
  31. package/dist/managedContent/index.js +2 -0
  32. package/dist/managedContent/parsers.d.ts +7 -0
  33. package/dist/managedContent/parsers.js +23 -0
  34. package/dist/managedContent/types.d.ts +39 -0
  35. package/dist/managedContent/types.js +21 -0
  36. package/dist/operations/index.d.ts +3 -0
  37. package/dist/operations/index.js +2 -0
  38. package/dist/operations/parsers.d.ts +15 -0
  39. package/dist/operations/parsers.js +181 -0
  40. package/dist/operations/types.d.ts +112 -0
  41. package/dist/operations/types.js +67 -0
  42. package/dist/public/collaboration.d.ts +2 -0
  43. package/dist/public/collaboration.js +1 -0
  44. package/dist/public/configuration.d.ts +2 -0
  45. package/dist/public/configuration.js +1 -0
  46. package/dist/public/index.d.ts +6 -0
  47. package/dist/public/index.js +6 -0
  48. package/dist/public/integrations.d.ts +2 -0
  49. package/dist/public/integrations.js +1 -0
  50. package/dist/public/managedContent.d.ts +2 -0
  51. package/dist/public/managedContent.js +1 -0
  52. package/dist/public/operations.d.ts +2 -0
  53. package/dist/public/operations.js +1 -0
  54. package/dist/public/resources.d.ts +2 -0
  55. package/dist/public/resources.js +1 -0
  56. package/dist/requests/parsers.js +40 -11
  57. package/dist/requests/types.d.ts +35 -8
  58. package/dist/requests/types.js +15 -1
  59. package/dist/resources/index.d.ts +3 -0
  60. package/dist/resources/index.js +2 -0
  61. package/dist/resources/parsers.d.ts +5 -0
  62. package/dist/resources/parsers.js +12 -0
  63. package/dist/resources/types.d.ts +39 -0
  64. package/dist/resources/types.js +19 -0
  65. package/dist/sessions/types.d.ts +15 -4
  66. package/dist/zod/capabilities.d.ts +103 -15
  67. package/dist/zod/capabilities.js +196 -31
  68. package/dist/zod/collaboration.d.ts +60 -0
  69. package/dist/zod/collaboration.js +155 -0
  70. package/dist/zod/configuration.d.ts +177 -0
  71. package/dist/zod/configuration.js +157 -0
  72. package/dist/zod/events.d.ts +214 -22
  73. package/dist/zod/events.js +15 -0
  74. package/dist/zod/foundation.d.ts +10 -1
  75. package/dist/zod/foundation.js +18 -0
  76. package/dist/zod/index.d.ts +7 -1
  77. package/dist/zod/index.js +62 -0
  78. package/dist/zod/integrations.d.ts +76 -0
  79. package/dist/zod/integrations.js +92 -0
  80. package/dist/zod/managedContent.d.ts +9 -0
  81. package/dist/zod/managedContent.js +70 -0
  82. package/dist/zod/operations.d.ts +339 -0
  83. package/dist/zod/operations.js +229 -0
  84. package/dist/zod/requests.d.ts +100 -11
  85. package/dist/zod/requests.js +66 -26
  86. package/dist/zod/resources.d.ts +43 -0
  87. package/dist/zod/resources.js +82 -0
  88. package/dist/zod/sessions.d.ts +168 -21
  89. package/dist/zod/sessions.js +54 -42
  90. package/dist/zod/typeEquality.generated.d.ts +40 -0
  91. package/package.json +26 -2
@@ -0,0 +1,229 @@
1
+ import { z } from "zod/v4";
2
+ import { compareStringsByUnicodeCodePoint } from "../foundation/ordering.js";
3
+ import {
4
+ AGENT_OPERATION_CATALOG_MAX_LENGTH,
5
+ AGENT_OPERATION_CONTEXTS,
6
+ AGENT_OPERATION_DESCRIPTION_MAX_LENGTH,
7
+ AGENT_OPERATION_EXECUTION_MODES,
8
+ AGENT_OPERATION_FIELDS_MAX_LENGTH,
9
+ AGENT_OPERATION_IDEMPOTENCY_REQUIREMENTS,
10
+ AGENT_OPERATION_KINDS,
11
+ AGENT_OPERATION_OPTIONS_MAX_LENGTH,
12
+ AGENT_OPERATION_OUTPUT_TEXT_MAX_LENGTH,
13
+ AGENT_OPERATION_RESULT_KINDS,
14
+ AGENT_OPERATION_RESULT_REFERENCES_MAX_LENGTH,
15
+ AGENT_OPERATION_TEXT_VALUE_MAX_LENGTH,
16
+ AGENT_OPERATION_TIMINGS,
17
+ AGENT_OPERATION_TITLE_MAX_LENGTH
18
+ } from "../operations/types.js";
19
+ import {
20
+ AgentArtifactIdSchema,
21
+ AgentCanonicalIdValueSchema,
22
+ AgentErrorSchema,
23
+ AgentGeneratedResourceIdSchema,
24
+ AgentOperationIdSchema,
25
+ AgentOperationInvocationIdSchema,
26
+ AgentRequestFieldIdSchema,
27
+ createAgentCanonicalNonBlankStringSchema
28
+ } from "./foundation.js";
29
+ const PositiveSafeIntegerSchema = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
30
+ const CanonicalTitleSchema = createAgentCanonicalNonBlankStringSchema(
31
+ AGENT_OPERATION_TITLE_MAX_LENGTH
32
+ );
33
+ const CanonicalDescriptionSchema = createAgentCanonicalNonBlankStringSchema(
34
+ AGENT_OPERATION_DESCRIPTION_MAX_LENGTH
35
+ );
36
+ const AgentOperationSelectOptionSchema = z.object({
37
+ optionId: AgentCanonicalIdValueSchema,
38
+ label: CanonicalTitleSchema,
39
+ description: CanonicalDescriptionSchema.optional()
40
+ }).strict().readonly();
41
+ const fieldBase = {
42
+ fieldId: AgentRequestFieldIdSchema,
43
+ label: CanonicalTitleSchema,
44
+ description: CanonicalDescriptionSchema.optional(),
45
+ required: z.boolean(),
46
+ sensitivity: z.enum(["ordinary", "sensitive"])
47
+ };
48
+ const SelectOptionsSchema = z.array(AgentOperationSelectOptionSchema).min(1).max(AGENT_OPERATION_OPTIONS_MAX_LENGTH).readonly();
49
+ const AgentOperationFieldSchema = z.discriminatedUnion("fieldKind", [
50
+ z.object({
51
+ ...fieldBase,
52
+ fieldKind: z.literal("text"),
53
+ multiline: z.boolean(),
54
+ maxLength: z.number().int().positive().max(AGENT_OPERATION_TEXT_VALUE_MAX_LENGTH)
55
+ }).strict().readonly(),
56
+ z.object({ ...fieldBase, fieldKind: z.literal("boolean") }).strict().readonly(),
57
+ z.object({
58
+ ...fieldBase,
59
+ fieldKind: z.literal("single_select"),
60
+ options: SelectOptionsSchema
61
+ }).strict().readonly(),
62
+ z.object({
63
+ ...fieldBase,
64
+ fieldKind: z.literal("multi_select"),
65
+ options: SelectOptionsSchema,
66
+ maxSelections: z.number().int().positive().max(AGENT_OPERATION_OPTIONS_MAX_LENGTH)
67
+ }).strict().readonly(),
68
+ z.object({
69
+ ...fieldBase,
70
+ fieldKind: z.literal("integer"),
71
+ minimum: z.number().int().min(Number.MIN_SAFE_INTEGER).max(Number.MAX_SAFE_INTEGER),
72
+ maximum: z.number().int().min(Number.MIN_SAFE_INTEGER).max(Number.MAX_SAFE_INTEGER)
73
+ }).strict().readonly()
74
+ ]);
75
+ const AgentOperationDescriptorPortableSchema = z.object({
76
+ operationId: AgentOperationIdSchema,
77
+ revision: PositiveSafeIntegerSchema,
78
+ kind: z.enum(AGENT_OPERATION_KINDS),
79
+ title: CanonicalTitleSchema,
80
+ description: CanonicalDescriptionSchema.optional(),
81
+ context: z.enum(AGENT_OPERATION_CONTEXTS),
82
+ timing: z.enum(AGENT_OPERATION_TIMINGS),
83
+ executionMode: z.enum(AGENT_OPERATION_EXECUTION_MODES),
84
+ fields: z.array(AgentOperationFieldSchema).max(AGENT_OPERATION_FIELDS_MAX_LENGTH).readonly(),
85
+ confirmation: z.enum(["none", "required"]),
86
+ idempotency: z.enum(AGENT_OPERATION_IDEMPOTENCY_REQUIREMENTS),
87
+ resultKind: z.enum(AGENT_OPERATION_RESULT_KINDS)
88
+ }).strict().readonly();
89
+ function addFieldIssues(fields, context) {
90
+ const fieldIds = /* @__PURE__ */ new Set();
91
+ fields.forEach((field, fieldIndex) => {
92
+ if (fieldIds.has(field.fieldId)) {
93
+ context.addIssue({ code: "custom", path: ["fields", fieldIndex, "fieldId"], message: "Operation field IDs must be unique." });
94
+ }
95
+ if (fieldIndex > 0 && compareStringsByUnicodeCodePoint(
96
+ fields[fieldIndex - 1].fieldId,
97
+ field.fieldId
98
+ ) >= 0) {
99
+ context.addIssue({ code: "custom", path: ["fields", fieldIndex, "fieldId"], message: "Operation fields must use canonical fieldId order." });
100
+ }
101
+ fieldIds.add(field.fieldId);
102
+ if (field.fieldKind === "integer" && field.minimum > field.maximum) {
103
+ context.addIssue({ code: "custom", path: ["fields", fieldIndex, "minimum"], message: "Integer field minimum cannot exceed maximum." });
104
+ }
105
+ if (field.fieldKind !== "single_select" && field.fieldKind !== "multi_select") return;
106
+ const optionIds = /* @__PURE__ */ new Set();
107
+ field.options.forEach((option, optionIndex) => {
108
+ if (optionIds.has(option.optionId)) {
109
+ context.addIssue({ code: "custom", path: ["fields", fieldIndex, "options", optionIndex, "optionId"], message: "Operation option IDs must be unique within a field." });
110
+ }
111
+ if (optionIndex > 0 && compareStringsByUnicodeCodePoint(
112
+ field.options[optionIndex - 1].optionId,
113
+ option.optionId
114
+ ) >= 0) {
115
+ context.addIssue({ code: "custom", path: ["fields", fieldIndex, "options", optionIndex, "optionId"], message: "Operation options must use canonical optionId order." });
116
+ }
117
+ optionIds.add(option.optionId);
118
+ });
119
+ if (field.fieldKind === "multi_select" && field.maxSelections > field.options.length) {
120
+ context.addIssue({ code: "custom", path: ["fields", fieldIndex, "maxSelections"], message: "Maximum selections cannot exceed available options." });
121
+ }
122
+ });
123
+ }
124
+ const AgentOperationDescriptorSchema = AgentOperationDescriptorPortableSchema.superRefine((descriptor, context) => {
125
+ addFieldIssues(descriptor.fields, context);
126
+ });
127
+ const AgentOperationCatalogPortableSchema = z.object({
128
+ revision: PositiveSafeIntegerSchema,
129
+ operations: z.array(AgentOperationDescriptorPortableSchema).max(AGENT_OPERATION_CATALOG_MAX_LENGTH).readonly()
130
+ }).strict().readonly();
131
+ const AgentOperationCatalogSchema = AgentOperationCatalogPortableSchema.superRefine((catalog, context) => {
132
+ let previous = "";
133
+ const operationIds = /* @__PURE__ */ new Set();
134
+ catalog.operations.forEach((operation, operationIndex) => {
135
+ const parsed = AgentOperationDescriptorSchema.safeParse(operation);
136
+ if (!parsed.success) {
137
+ for (const issue of parsed.error.issues) {
138
+ context.addIssue({ code: "custom", path: ["operations", operationIndex, ...issue.path], message: issue.message });
139
+ }
140
+ }
141
+ if (operationIds.has(operation.operationId)) {
142
+ context.addIssue({ code: "custom", path: ["operations", operationIndex, "operationId"], message: "Operation IDs must be unique within a catalog." });
143
+ }
144
+ if (operationIndex > 0 && compareStringsByUnicodeCodePoint(previous, operation.operationId) >= 0) {
145
+ context.addIssue({ code: "custom", path: ["operations", operationIndex, "operationId"], message: "Operations must be ordered by operationId." });
146
+ }
147
+ operationIds.add(operation.operationId);
148
+ previous = operation.operationId;
149
+ });
150
+ });
151
+ const AgentOperationFieldValueSchema = z.discriminatedUnion("fieldKind", [
152
+ z.object({ fieldId: AgentRequestFieldIdSchema, fieldKind: z.literal("text"), value: z.string().max(AGENT_OPERATION_TEXT_VALUE_MAX_LENGTH) }).strict().readonly(),
153
+ z.object({ fieldId: AgentRequestFieldIdSchema, fieldKind: z.literal("boolean"), value: z.boolean() }).strict().readonly(),
154
+ z.object({ fieldId: AgentRequestFieldIdSchema, fieldKind: z.literal("single_select"), optionId: AgentCanonicalIdValueSchema }).strict().readonly(),
155
+ z.object({ fieldId: AgentRequestFieldIdSchema, fieldKind: z.literal("multi_select"), optionIds: z.array(AgentCanonicalIdValueSchema).min(1).max(AGENT_OPERATION_OPTIONS_MAX_LENGTH).readonly() }).strict().readonly(),
156
+ z.object({ fieldId: AgentRequestFieldIdSchema, fieldKind: z.literal("integer"), value: z.number().int().min(Number.MIN_SAFE_INTEGER).max(Number.MAX_SAFE_INTEGER) }).strict().readonly()
157
+ ]);
158
+ const AgentOperationInvocationPortableSchema = z.object({
159
+ invocationId: AgentOperationInvocationIdSchema,
160
+ operationId: AgentOperationIdSchema,
161
+ expectedRevision: PositiveSafeIntegerSchema,
162
+ values: z.array(AgentOperationFieldValueSchema).max(AGENT_OPERATION_FIELDS_MAX_LENGTH).readonly()
163
+ }).strict().readonly();
164
+ const AgentOperationInvocationSchema = AgentOperationInvocationPortableSchema.superRefine((invocation, context) => {
165
+ const fieldIds = /* @__PURE__ */ new Set();
166
+ invocation.values.forEach((value, valueIndex) => {
167
+ if (fieldIds.has(value.fieldId)) {
168
+ context.addIssue({ code: "custom", path: ["values", valueIndex, "fieldId"], message: "Each operation field may be supplied once." });
169
+ }
170
+ if (valueIndex > 0 && compareStringsByUnicodeCodePoint(
171
+ invocation.values[valueIndex - 1].fieldId,
172
+ value.fieldId
173
+ ) >= 0) {
174
+ context.addIssue({ code: "custom", path: ["values", valueIndex, "fieldId"], message: "Operation values must use canonical fieldId order." });
175
+ }
176
+ fieldIds.add(value.fieldId);
177
+ if (value.fieldKind === "multi_select" && new Set(value.optionIds).size !== value.optionIds.length) {
178
+ context.addIssue({ code: "custom", path: ["values", valueIndex, "optionIds"], message: "Multi-select operation values must be unique." });
179
+ }
180
+ if (value.fieldKind === "multi_select" && value.optionIds.some(
181
+ (optionId, optionIndex) => optionIndex > 0 && compareStringsByUnicodeCodePoint(
182
+ value.optionIds[optionIndex - 1],
183
+ optionId
184
+ ) >= 0
185
+ )) {
186
+ context.addIssue({ code: "custom", path: ["values", valueIndex, "optionIds"], message: "Multi-select operation values must use canonical optionId order." });
187
+ }
188
+ });
189
+ });
190
+ const AgentOperationResultPortableSchema = z.object({
191
+ invocationId: AgentOperationInvocationIdSchema,
192
+ status: z.enum(["accepted", "completed", "failed", "canceled", "waiting_for_request"]),
193
+ artifactIds: z.array(AgentArtifactIdSchema).min(1).max(AGENT_OPERATION_RESULT_REFERENCES_MAX_LENGTH).readonly().optional(),
194
+ resourceIds: z.array(AgentGeneratedResourceIdSchema).min(1).max(AGENT_OPERATION_RESULT_REFERENCES_MAX_LENGTH).readonly().optional(),
195
+ outputText: createAgentCanonicalNonBlankStringSchema(AGENT_OPERATION_OUTPUT_TEXT_MAX_LENGTH).optional(),
196
+ error: AgentErrorSchema.optional()
197
+ }).strict().readonly();
198
+ const AgentOperationResultSchema = AgentOperationResultPortableSchema.superRefine((result, context) => {
199
+ if (result.status === "failed" !== (result.error !== void 0)) {
200
+ context.addIssue({ code: "custom", path: ["error"], message: "Only failed operation results must include an error." });
201
+ }
202
+ if (result.status !== "completed" && (result.artifactIds !== void 0 || result.resourceIds !== void 0 || result.outputText !== void 0)) {
203
+ context.addIssue({ code: "custom", path: [], message: "Only completed operation results may expose result values." });
204
+ }
205
+ for (const [field, values] of [["artifactIds", result.artifactIds], ["resourceIds", result.resourceIds]]) {
206
+ if (values !== void 0 && new Set(values).size !== values.length) {
207
+ context.addIssue({ code: "custom", path: [field], message: `${field} must be unique.` });
208
+ }
209
+ if (values !== void 0 && values.some(
210
+ (value, valueIndex) => valueIndex > 0 && compareStringsByUnicodeCodePoint(
211
+ values[valueIndex - 1],
212
+ value
213
+ ) >= 0
214
+ )) {
215
+ context.addIssue({ code: "custom", path: [field], message: `${field} must use canonical ID order.` });
216
+ }
217
+ }
218
+ });
219
+ export {
220
+ AgentOperationCatalogPortableSchema,
221
+ AgentOperationCatalogSchema,
222
+ AgentOperationDescriptorPortableSchema,
223
+ AgentOperationDescriptorSchema,
224
+ AgentOperationFieldSchema,
225
+ AgentOperationInvocationPortableSchema,
226
+ AgentOperationInvocationSchema,
227
+ AgentOperationResultPortableSchema,
228
+ AgentOperationResultSchema
229
+ };
@@ -52,31 +52,71 @@ export declare const AgentElicitationRequestPortableSchema: z.ZodReadonly<z.ZodO
52
52
  requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
53
53
  prompt: z.ZodString;
54
54
  fields: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
55
+ kind: z.ZodLiteral<"text">;
56
+ multiline: z.ZodBoolean;
57
+ maxLength: z.ZodNumber;
55
58
  fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
56
59
  label: z.ZodString;
57
60
  description: z.ZodOptional<z.ZodString>;
58
61
  required: z.ZodBoolean;
59
- kind: z.ZodLiteral<"text">;
60
- multiline: z.ZodOptional<z.ZodBoolean>;
62
+ sensitivity: z.ZodEnum<{
63
+ ordinary: "ordinary";
64
+ sensitive: "sensitive";
65
+ }>;
61
66
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
67
+ kind: z.ZodLiteral<"single_select">;
68
+ options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
69
+ value: z.ZodIntersection<z.ZodString, z.ZodString>;
70
+ label: z.ZodString;
71
+ description: z.ZodOptional<z.ZodString>;
72
+ }, z.core.$strict>>>>;
73
+ allowOther: z.ZodBoolean;
62
74
  fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
63
75
  label: z.ZodString;
64
76
  description: z.ZodOptional<z.ZodString>;
65
77
  required: z.ZodBoolean;
66
- kind: z.ZodLiteral<"choice">;
78
+ sensitivity: z.ZodEnum<{
79
+ ordinary: "ordinary";
80
+ sensitive: "sensitive";
81
+ }>;
82
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
83
+ kind: z.ZodLiteral<"multi_select">;
67
84
  options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
68
85
  value: z.ZodIntersection<z.ZodString, z.ZodString>;
69
86
  label: z.ZodString;
70
87
  description: z.ZodOptional<z.ZodString>;
71
88
  }, z.core.$strict>>>>;
72
- multiple: z.ZodBoolean;
73
89
  allowOther: z.ZodBoolean;
74
- }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
90
+ maxSelections: z.ZodNumber;
75
91
  fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
76
92
  label: z.ZodString;
77
93
  description: z.ZodOptional<z.ZodString>;
78
94
  required: z.ZodBoolean;
95
+ sensitivity: z.ZodEnum<{
96
+ ordinary: "ordinary";
97
+ sensitive: "sensitive";
98
+ }>;
99
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
79
100
  kind: z.ZodLiteral<"boolean">;
101
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
102
+ label: z.ZodString;
103
+ description: z.ZodOptional<z.ZodString>;
104
+ required: z.ZodBoolean;
105
+ sensitivity: z.ZodEnum<{
106
+ ordinary: "ordinary";
107
+ sensitive: "sensitive";
108
+ }>;
109
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
110
+ kind: z.ZodLiteral<"confirmation">;
111
+ confirmLabel: z.ZodString;
112
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
113
+ label: z.ZodString;
114
+ description: z.ZodOptional<z.ZodString>;
115
+ required: z.ZodBoolean;
116
+ sensitivity: z.ZodEnum<{
117
+ ordinary: "ordinary";
118
+ sensitive: "sensitive";
119
+ }>;
80
120
  }, z.core.$strict>>], "kind">>>;
81
121
  expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
82
122
  }, z.core.$strict>>;
@@ -131,31 +171,71 @@ export declare const AgentRequestPortableSchema: z.ZodDiscriminatedUnion<[z.ZodR
131
171
  requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
132
172
  prompt: z.ZodString;
133
173
  fields: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
174
+ kind: z.ZodLiteral<"text">;
175
+ multiline: z.ZodBoolean;
176
+ maxLength: z.ZodNumber;
134
177
  fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
135
178
  label: z.ZodString;
136
179
  description: z.ZodOptional<z.ZodString>;
137
180
  required: z.ZodBoolean;
138
- kind: z.ZodLiteral<"text">;
139
- multiline: z.ZodOptional<z.ZodBoolean>;
181
+ sensitivity: z.ZodEnum<{
182
+ ordinary: "ordinary";
183
+ sensitive: "sensitive";
184
+ }>;
140
185
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
186
+ kind: z.ZodLiteral<"single_select">;
187
+ options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
188
+ value: z.ZodIntersection<z.ZodString, z.ZodString>;
189
+ label: z.ZodString;
190
+ description: z.ZodOptional<z.ZodString>;
191
+ }, z.core.$strict>>>>;
192
+ allowOther: z.ZodBoolean;
141
193
  fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
142
194
  label: z.ZodString;
143
195
  description: z.ZodOptional<z.ZodString>;
144
196
  required: z.ZodBoolean;
145
- kind: z.ZodLiteral<"choice">;
197
+ sensitivity: z.ZodEnum<{
198
+ ordinary: "ordinary";
199
+ sensitive: "sensitive";
200
+ }>;
201
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
202
+ kind: z.ZodLiteral<"multi_select">;
146
203
  options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
147
204
  value: z.ZodIntersection<z.ZodString, z.ZodString>;
148
205
  label: z.ZodString;
149
206
  description: z.ZodOptional<z.ZodString>;
150
207
  }, z.core.$strict>>>>;
151
- multiple: z.ZodBoolean;
152
208
  allowOther: z.ZodBoolean;
153
- }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
209
+ maxSelections: z.ZodNumber;
154
210
  fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
155
211
  label: z.ZodString;
156
212
  description: z.ZodOptional<z.ZodString>;
157
213
  required: z.ZodBoolean;
214
+ sensitivity: z.ZodEnum<{
215
+ ordinary: "ordinary";
216
+ sensitive: "sensitive";
217
+ }>;
218
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
158
219
  kind: z.ZodLiteral<"boolean">;
220
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
221
+ label: z.ZodString;
222
+ description: z.ZodOptional<z.ZodString>;
223
+ required: z.ZodBoolean;
224
+ sensitivity: z.ZodEnum<{
225
+ ordinary: "ordinary";
226
+ sensitive: "sensitive";
227
+ }>;
228
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
229
+ kind: z.ZodLiteral<"confirmation">;
230
+ confirmLabel: z.ZodString;
231
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
232
+ label: z.ZodString;
233
+ description: z.ZodOptional<z.ZodString>;
234
+ required: z.ZodBoolean;
235
+ sensitivity: z.ZodEnum<{
236
+ ordinary: "ordinary";
237
+ sensitive: "sensitive";
238
+ }>;
159
239
  }, z.core.$strict>>], "kind">>>;
160
240
  expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
161
241
  }, z.core.$strict>>], "requestKind">;
@@ -171,13 +251,22 @@ export declare const AgentRequestResolutionPortableSchema: z.ZodUnion<readonly [
171
251
  value: z.ZodString;
172
252
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
173
253
  fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
174
- kind: z.ZodLiteral<"choice">;
254
+ kind: z.ZodLiteral<"single_select">;
255
+ value: z.ZodOptional<z.ZodIntersection<z.ZodString, z.ZodString>>;
256
+ other: z.ZodOptional<z.ZodString>;
257
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
258
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
259
+ kind: z.ZodLiteral<"multi_select">;
175
260
  values: z.ZodReadonly<z.ZodArray<z.ZodIntersection<z.ZodString, z.ZodString>>>;
176
261
  other: z.ZodOptional<z.ZodString>;
177
262
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
178
263
  fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
179
264
  kind: z.ZodLiteral<"boolean">;
180
265
  value: z.ZodBoolean;
266
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
267
+ fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
268
+ kind: z.ZodLiteral<"confirmation">;
269
+ confirmed: z.ZodBoolean;
181
270
  }, z.core.$strict>>], "kind">>>;
182
271
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
183
272
  requestKind: z.ZodLiteral<"elicitation">;
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod/v4";
2
2
  import {
3
- AGENT_PROTOCOL_COLLECTION_MAX_LENGTH,
4
3
  AGENT_PROTOCOL_SUMMARY_MAX_LENGTH,
5
4
  AGENT_PROTOCOL_TEXT_MAX_LENGTH
6
5
  } from "../foundation/types.js";
@@ -9,7 +8,10 @@ import {
9
8
  AGENT_APPROVAL_LABEL_MAX_LENGTH,
10
9
  AGENT_APPROVAL_OPTIONS_MAX_LENGTH,
11
10
  AGENT_APPROVAL_PERSISTENCES,
12
- AGENT_APPROVAL_SCOPE_KINDS
11
+ AGENT_APPROVAL_SCOPE_KINDS,
12
+ AGENT_ELICITATION_FIELDS_MAX_LENGTH,
13
+ AGENT_ELICITATION_OPTIONS_MAX_LENGTH,
14
+ AGENT_ELICITATION_TEXT_VALUE_MAX_LENGTH
13
15
  } from "../requests/types.js";
14
16
  import {
15
17
  AgentApprovalOptionIdSchema,
@@ -73,38 +75,49 @@ const AgentRequestChoiceSchema = z.object({
73
75
  label: z.string().min(1).max(200),
74
76
  description: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional()
75
77
  }).strict().readonly();
78
+ const AgentElicitationFieldBase = {
79
+ fieldId: AgentRequestFieldIdSchema,
80
+ label: z.string().min(1).max(200),
81
+ description: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional(),
82
+ required: z.boolean(),
83
+ sensitivity: z.enum(["ordinary", "sensitive"])
84
+ };
85
+ const AgentElicitationOptionsSchema = z.array(AgentRequestChoiceSchema).min(1).max(AGENT_ELICITATION_OPTIONS_MAX_LENGTH).readonly();
76
86
  const AgentElicitationFieldSchema = z.discriminatedUnion("kind", [
77
87
  z.object({
78
- fieldId: AgentRequestFieldIdSchema,
79
- label: z.string().min(1).max(200),
80
- description: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional(),
81
- required: z.boolean(),
88
+ ...AgentElicitationFieldBase,
82
89
  kind: z.literal("text"),
83
- multiline: z.boolean().optional()
90
+ multiline: z.boolean(),
91
+ maxLength: z.number().int().positive().max(AGENT_ELICITATION_TEXT_VALUE_MAX_LENGTH)
84
92
  }).strict().readonly(),
85
93
  z.object({
86
- fieldId: AgentRequestFieldIdSchema,
87
- label: z.string().min(1).max(200),
88
- description: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional(),
89
- required: z.boolean(),
90
- kind: z.literal("choice"),
91
- options: z.array(AgentRequestChoiceSchema).min(1).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly(),
92
- multiple: z.boolean(),
94
+ ...AgentElicitationFieldBase,
95
+ kind: z.literal("single_select"),
96
+ options: AgentElicitationOptionsSchema,
93
97
  allowOther: z.boolean()
94
98
  }).strict().readonly(),
95
99
  z.object({
96
- fieldId: AgentRequestFieldIdSchema,
97
- label: z.string().min(1).max(200),
98
- description: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional(),
99
- required: z.boolean(),
100
+ ...AgentElicitationFieldBase,
101
+ kind: z.literal("multi_select"),
102
+ options: AgentElicitationOptionsSchema,
103
+ allowOther: z.boolean(),
104
+ maxSelections: z.number().int().positive().max(AGENT_ELICITATION_OPTIONS_MAX_LENGTH)
105
+ }).strict().readonly(),
106
+ z.object({
107
+ ...AgentElicitationFieldBase,
100
108
  kind: z.literal("boolean")
109
+ }).strict().readonly(),
110
+ z.object({
111
+ ...AgentElicitationFieldBase,
112
+ kind: z.literal("confirmation"),
113
+ confirmLabel: z.string().min(1).max(200)
101
114
  }).strict().readonly()
102
115
  ]);
103
116
  const AgentElicitationRequestPortableSchema = z.object({
104
117
  requestKind: z.literal("elicitation"),
105
118
  requestId: AgentRequestIdSchema,
106
119
  prompt: z.string().min(1).max(AGENT_PROTOCOL_TEXT_MAX_LENGTH),
107
- fields: z.array(AgentElicitationFieldSchema).min(1).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly(),
120
+ fields: z.array(AgentElicitationFieldSchema).min(1).max(AGENT_ELICITATION_FIELDS_MAX_LENGTH).readonly(),
108
121
  expiresAt: AgentIsoDateTimeSchema.optional()
109
122
  }).strict().readonly();
110
123
  const AgentElicitationRequestSchema = AgentElicitationRequestPortableSchema.superRefine((request, context) => {
@@ -118,7 +131,9 @@ const AgentElicitationRequestSchema = AgentElicitationRequestPortableSchema.supe
118
131
  });
119
132
  }
120
133
  fieldIds.add(field.fieldId);
121
- if (field.kind !== "choice") return;
134
+ if (field.kind !== "single_select" && field.kind !== "multi_select") {
135
+ return;
136
+ }
122
137
  const optionValues = /* @__PURE__ */ new Set();
123
138
  field.options.forEach((option, optionIndex) => {
124
139
  if (optionValues.has(option.value)) {
@@ -130,6 +145,13 @@ const AgentElicitationRequestSchema = AgentElicitationRequestPortableSchema.supe
130
145
  }
131
146
  optionValues.add(option.value);
132
147
  });
148
+ if (field.kind === "multi_select" && field.maxSelections > field.options.length + (field.allowOther ? 1 : 0)) {
149
+ context.addIssue({
150
+ code: "custom",
151
+ path: ["fields", fieldIndex, "maxSelections"],
152
+ message: "Maximum selections cannot exceed the available choices."
153
+ });
154
+ }
133
155
  });
134
156
  });
135
157
  const AgentRequestPortableSchema = z.discriminatedUnion("requestKind", [
@@ -147,7 +169,7 @@ const AgentRequestSchema = AgentRequestPortableSchema.superRefine((request, cont
147
169
  });
148
170
  }
149
171
  });
150
- const AgentElicitationFreeformAnswerSchema = z.string().max(AGENT_PROTOCOL_TEXT_MAX_LENGTH).regex(/\S/u, "Free-form answers must contain non-whitespace content.");
172
+ const AgentElicitationFreeformAnswerSchema = z.string().max(AGENT_ELICITATION_TEXT_VALUE_MAX_LENGTH).regex(/\S/u, "Free-form answers must contain non-whitespace content.");
151
173
  const AgentElicitationAnswerSchema = z.discriminatedUnion("kind", [
152
174
  z.object({
153
175
  fieldId: AgentRequestFieldIdSchema,
@@ -156,14 +178,25 @@ const AgentElicitationAnswerSchema = z.discriminatedUnion("kind", [
156
178
  }).strict().readonly(),
157
179
  z.object({
158
180
  fieldId: AgentRequestFieldIdSchema,
159
- kind: z.literal("choice"),
160
- values: z.array(AgentRequestChoiceValueSchema).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly(),
181
+ kind: z.literal("single_select"),
182
+ value: AgentRequestChoiceValueSchema.optional(),
183
+ other: AgentElicitationFreeformAnswerSchema.optional()
184
+ }).strict().readonly(),
185
+ z.object({
186
+ fieldId: AgentRequestFieldIdSchema,
187
+ kind: z.literal("multi_select"),
188
+ values: z.array(AgentRequestChoiceValueSchema).max(AGENT_ELICITATION_OPTIONS_MAX_LENGTH).readonly(),
161
189
  other: AgentElicitationFreeformAnswerSchema.optional()
162
190
  }).strict().readonly(),
163
191
  z.object({
164
192
  fieldId: AgentRequestFieldIdSchema,
165
193
  kind: z.literal("boolean"),
166
194
  value: z.boolean()
195
+ }).strict().readonly(),
196
+ z.object({
197
+ fieldId: AgentRequestFieldIdSchema,
198
+ kind: z.literal("confirmation"),
199
+ confirmed: z.boolean()
167
200
  }).strict().readonly()
168
201
  ]);
169
202
  const AgentApprovalResolutionSchema = z.discriminatedUnion("disposition", [
@@ -185,7 +218,7 @@ const AgentRequestResolutionPortableSchema = z.union([
185
218
  requestKind: z.literal("elicitation"),
186
219
  requestId: AgentRequestIdSchema,
187
220
  disposition: z.literal("answered"),
188
- answers: z.array(AgentElicitationAnswerSchema).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly()
221
+ answers: z.array(AgentElicitationAnswerSchema).max(AGENT_ELICITATION_FIELDS_MAX_LENGTH).readonly()
189
222
  }).strict().readonly(),
190
223
  z.object({
191
224
  requestKind: z.literal("elicitation"),
@@ -198,11 +231,18 @@ const AgentRequestResolutionSchema = AgentRequestResolutionPortableSchema.superR
198
231
  return;
199
232
  }
200
233
  resolution.answers.forEach((answer, answerIndex) => {
201
- if (answer.kind === "choice" && new Set(answer.values).size !== answer.values.length) {
234
+ if (answer.kind === "multi_select" && new Set(answer.values).size !== answer.values.length) {
202
235
  context.addIssue({
203
236
  code: "custom",
204
237
  path: ["answers", answerIndex, "values"],
205
- message: "Choice answers cannot select the same option more than once."
238
+ message: "Multi-select answers cannot select the same option more than once."
239
+ });
240
+ }
241
+ if (answer.kind === "single_select" && answer.value === void 0 === (answer.other === void 0)) {
242
+ context.addIssue({
243
+ code: "custom",
244
+ path: ["answers", answerIndex],
245
+ message: "Single-select answers require exactly one declared or custom choice."
206
246
  });
207
247
  }
208
248
  });
@@ -0,0 +1,43 @@
1
+ import { z } from 'zod/v4';
2
+ import { type AgentGeneratedResourceDescriptor } from '../resources/types.js';
3
+ export declare const AgentGeneratedResourceDescriptorPortableSchema: z.ZodReadonly<z.ZodObject<{
4
+ resourceId: z.ZodType<import("../index.js").AgentGeneratedResourceId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentGeneratedResourceId, unknown>>;
5
+ kind: z.ZodEnum<{
6
+ image: "image";
7
+ document: "document";
8
+ archive: "archive";
9
+ }>;
10
+ status: z.ZodEnum<{
11
+ pending: "pending";
12
+ expired: "expired";
13
+ available: "available";
14
+ unavailable: "unavailable";
15
+ }>;
16
+ displayName: z.ZodString;
17
+ producer: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
18
+ kind: z.ZodLiteral<"session">;
19
+ sessionId: z.ZodType<import("../index.js").AgentSessionId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentSessionId, unknown>>;
20
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
21
+ kind: z.ZodLiteral<"turn">;
22
+ turnId: z.ZodType<import("../index.js").AgentTurnId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentTurnId, unknown>>;
23
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
24
+ kind: z.ZodLiteral<"operation">;
25
+ invocationId: z.ZodType<import("../index.js").AgentOperationInvocationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentOperationInvocationId, unknown>>;
26
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
27
+ kind: z.ZodLiteral<"collaboration">;
28
+ collaborationId: z.ZodType<import("../index.js").AgentCollaborationId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentCollaborationId, unknown>>;
29
+ }, z.core.$strict>>], "kind">;
30
+ summary: z.ZodOptional<z.ZodString>;
31
+ mediaType: z.ZodOptional<z.ZodString>;
32
+ byteSize: z.ZodOptional<z.ZodNumber>;
33
+ sha256: z.ZodOptional<z.ZodString>;
34
+ widthPixels: z.ZodOptional<z.ZodNumber>;
35
+ heightPixels: z.ZodOptional<z.ZodNumber>;
36
+ pageCount: z.ZodOptional<z.ZodNumber>;
37
+ artifactId: z.ZodOptional<z.ZodType<import("../index.js").AgentArtifactId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentArtifactId, unknown>>>;
38
+ createdAt: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
39
+ expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
40
+ error: z.ZodOptional<z.ZodType<import("../index.js").AgentError, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentError, unknown>>>;
41
+ }, z.core.$strict>>;
42
+ export declare const AgentGeneratedResourceDescriptorSchema: z.ZodType<AgentGeneratedResourceDescriptor>;
43
+ //# sourceMappingURL=resources.d.ts.map