@agen-ai/agent-protocol 0.4.0 → 0.4.2
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.
- package/README.md +115 -18
- package/dist/capabilities/types.d.ts +6 -1
- package/dist/events/types.d.ts +9 -3
- package/dist/events/types.js +4 -1
- package/dist/foundation/types.d.ts +1 -1
- package/dist/foundation/types.js +1 -1
- package/dist/jsonSchema/generated.d.ts +11214 -7152
- package/dist/jsonSchema/generated.js +2835 -227
- package/dist/public/index.d.ts +1 -0
- package/dist/public/index.js +1 -0
- package/dist/public/sessionInteractions.d.ts +2 -0
- package/dist/public/sessionInteractions.js +1 -0
- package/dist/requests/elicitation.d.ts +4 -0
- package/dist/requests/elicitation.js +107 -0
- package/dist/requests/parsers.js +2 -100
- package/dist/requests/types.d.ts +17 -4
- package/dist/sessionInteractions/index.d.ts +3 -0
- package/dist/sessionInteractions/index.js +2 -0
- package/dist/sessionInteractions/parsers.d.ts +37 -0
- package/dist/sessionInteractions/parsers.js +201 -0
- package/dist/sessionInteractions/types.d.ts +162 -0
- package/dist/sessionInteractions/types.js +34 -0
- package/dist/zod/capabilities.d.ts +72 -6
- package/dist/zod/capabilities.js +32 -30
- package/dist/zod/collaboration.d.ts +2 -2
- package/dist/zod/events.d.ts +75 -42
- package/dist/zod/events.js +8 -0
- package/dist/zod/foundation.d.ts +1 -0
- package/dist/zod/foundation.js +15 -2
- package/dist/zod/index.d.ts +2 -1
- package/dist/zod/index.js +60 -0
- package/dist/zod/operations.d.ts +1 -1
- package/dist/zod/requests.d.ts +175 -32
- package/dist/zod/requests.js +33 -10
- package/dist/zod/sessionInteractions.d.ts +925 -0
- package/dist/zod/sessionInteractions.js +284 -0
- package/dist/zod/turns.d.ts +1 -1
- package/dist/zod/typeEquality.generated.d.ts +38 -4
- package/package.json +6 -2
package/dist/zod/requests.d.ts
CHANGED
|
@@ -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
|
+
once: "once";
|
|
8
|
+
workspace: "workspace";
|
|
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>>;
|
|
@@ -11,10 +38,10 @@ export declare const AgentApprovalRequestPortableSchema: z.ZodReadonly<z.ZodObje
|
|
|
11
38
|
artifactId: z.ZodType<import("../index.js").AgentArtifactId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentArtifactId, unknown>>;
|
|
12
39
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
13
40
|
kind: z.ZodEnum<{
|
|
14
|
-
other: "other";
|
|
15
|
-
file_change: "file_change";
|
|
16
41
|
tool: "tool";
|
|
17
42
|
command: "command";
|
|
43
|
+
file_change: "file_change";
|
|
44
|
+
other: "other";
|
|
18
45
|
}>;
|
|
19
46
|
title: z.ZodString;
|
|
20
47
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -28,25 +55,104 @@ export declare const AgentApprovalRequestPortableSchema: z.ZodReadonly<z.ZodObje
|
|
|
28
55
|
approved: "approved";
|
|
29
56
|
denied: "denied";
|
|
30
57
|
}>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
+
once: "once";
|
|
63
|
+
workspace: "workspace";
|
|
44
64
|
}>;
|
|
45
|
-
|
|
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>>;
|
|
49
88
|
export declare const AgentApprovalRequestSchema: z.ZodType<AgentApprovalRequest>;
|
|
89
|
+
export declare const AgentElicitationFieldSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
|
|
90
|
+
kind: z.ZodLiteral<"text">;
|
|
91
|
+
multiline: z.ZodBoolean;
|
|
92
|
+
maxLength: z.ZodNumber;
|
|
93
|
+
fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
|
|
94
|
+
label: z.ZodString;
|
|
95
|
+
description: z.ZodOptional<z.ZodString>;
|
|
96
|
+
required: z.ZodBoolean;
|
|
97
|
+
sensitivity: z.ZodEnum<{
|
|
98
|
+
ordinary: "ordinary";
|
|
99
|
+
sensitive: "sensitive";
|
|
100
|
+
}>;
|
|
101
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
102
|
+
kind: z.ZodLiteral<"single_select">;
|
|
103
|
+
options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
104
|
+
value: z.ZodIntersection<z.ZodString, z.ZodString>;
|
|
105
|
+
label: z.ZodString;
|
|
106
|
+
description: z.ZodOptional<z.ZodString>;
|
|
107
|
+
}, z.core.$strict>>>>;
|
|
108
|
+
allowOther: z.ZodBoolean;
|
|
109
|
+
fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
|
|
110
|
+
label: z.ZodString;
|
|
111
|
+
description: z.ZodOptional<z.ZodString>;
|
|
112
|
+
required: z.ZodBoolean;
|
|
113
|
+
sensitivity: z.ZodEnum<{
|
|
114
|
+
ordinary: "ordinary";
|
|
115
|
+
sensitive: "sensitive";
|
|
116
|
+
}>;
|
|
117
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
118
|
+
kind: z.ZodLiteral<"multi_select">;
|
|
119
|
+
options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
120
|
+
value: z.ZodIntersection<z.ZodString, z.ZodString>;
|
|
121
|
+
label: z.ZodString;
|
|
122
|
+
description: z.ZodOptional<z.ZodString>;
|
|
123
|
+
}, z.core.$strict>>>>;
|
|
124
|
+
allowOther: z.ZodBoolean;
|
|
125
|
+
maxSelections: z.ZodNumber;
|
|
126
|
+
fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
|
|
127
|
+
label: z.ZodString;
|
|
128
|
+
description: z.ZodOptional<z.ZodString>;
|
|
129
|
+
required: z.ZodBoolean;
|
|
130
|
+
sensitivity: z.ZodEnum<{
|
|
131
|
+
ordinary: "ordinary";
|
|
132
|
+
sensitive: "sensitive";
|
|
133
|
+
}>;
|
|
134
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
135
|
+
kind: z.ZodLiteral<"boolean">;
|
|
136
|
+
fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
|
|
137
|
+
label: z.ZodString;
|
|
138
|
+
description: z.ZodOptional<z.ZodString>;
|
|
139
|
+
required: z.ZodBoolean;
|
|
140
|
+
sensitivity: z.ZodEnum<{
|
|
141
|
+
ordinary: "ordinary";
|
|
142
|
+
sensitive: "sensitive";
|
|
143
|
+
}>;
|
|
144
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
145
|
+
kind: z.ZodLiteral<"confirmation">;
|
|
146
|
+
confirmLabel: z.ZodString;
|
|
147
|
+
fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
|
|
148
|
+
label: z.ZodString;
|
|
149
|
+
description: z.ZodOptional<z.ZodString>;
|
|
150
|
+
required: z.ZodBoolean;
|
|
151
|
+
sensitivity: z.ZodEnum<{
|
|
152
|
+
ordinary: "ordinary";
|
|
153
|
+
sensitive: "sensitive";
|
|
154
|
+
}>;
|
|
155
|
+
}, z.core.$strict>>], "kind">;
|
|
50
156
|
export declare const AgentElicitationRequestPortableSchema: z.ZodReadonly<z.ZodObject<{
|
|
51
157
|
requestKind: z.ZodLiteral<"elicitation">;
|
|
52
158
|
requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
|
|
@@ -120,6 +226,7 @@ export declare const AgentElicitationRequestPortableSchema: z.ZodReadonly<z.ZodO
|
|
|
120
226
|
}, z.core.$strict>>], "kind">>>;
|
|
121
227
|
expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
|
|
122
228
|
}, z.core.$strict>>;
|
|
229
|
+
export declare function refineAgentElicitationFields(fields: readonly z.output<typeof AgentElicitationFieldSchema>[], context: z.RefinementCtx): void;
|
|
123
230
|
export declare const AgentElicitationRequestSchema: z.ZodType<AgentElicitationRequest>;
|
|
124
231
|
export declare const AgentRequestPortableSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
|
|
125
232
|
requestKind: z.ZodLiteral<"approval">;
|
|
@@ -132,10 +239,10 @@ export declare const AgentRequestPortableSchema: z.ZodDiscriminatedUnion<[z.ZodR
|
|
|
132
239
|
artifactId: z.ZodType<import("../index.js").AgentArtifactId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentArtifactId, unknown>>;
|
|
133
240
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
134
241
|
kind: z.ZodEnum<{
|
|
135
|
-
other: "other";
|
|
136
|
-
file_change: "file_change";
|
|
137
242
|
tool: "tool";
|
|
138
243
|
command: "command";
|
|
244
|
+
file_change: "file_change";
|
|
245
|
+
other: "other";
|
|
139
246
|
}>;
|
|
140
247
|
title: z.ZodString;
|
|
141
248
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -149,21 +256,33 @@ export declare const AgentRequestPortableSchema: z.ZodDiscriminatedUnion<[z.ZodR
|
|
|
149
256
|
approved: "approved";
|
|
150
257
|
denied: "denied";
|
|
151
258
|
}>;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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";
|
|
259
|
+
consequence: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
|
|
260
|
+
kind: z.ZodLiteral<"scoped">;
|
|
261
|
+
persistence: z.ZodEnum<{
|
|
262
|
+
session: "session";
|
|
263
|
+
once: "once";
|
|
264
|
+
workspace: "workspace";
|
|
165
265
|
}>;
|
|
166
|
-
|
|
266
|
+
scope: z.ZodReadonly<z.ZodObject<{
|
|
267
|
+
kind: z.ZodEnum<{
|
|
268
|
+
exact_action: "exact_action";
|
|
269
|
+
command_pattern: "command_pattern";
|
|
270
|
+
domain: "domain";
|
|
271
|
+
tool: "tool";
|
|
272
|
+
server: "server";
|
|
273
|
+
all_edits: "all_edits";
|
|
274
|
+
}>;
|
|
275
|
+
}, z.core.$strict>>;
|
|
276
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
277
|
+
kind: z.ZodLiteral<"provider_managed_remembrance">;
|
|
278
|
+
duration: z.ZodReadonly<z.ZodObject<{
|
|
279
|
+
kind: z.ZodLiteral<"unknown">;
|
|
280
|
+
}, z.core.$strict>>;
|
|
281
|
+
applicability: z.ZodReadonly<z.ZodObject<{
|
|
282
|
+
kind: z.ZodLiteral<"unknown">;
|
|
283
|
+
}, z.core.$strict>>;
|
|
284
|
+
explanation: z.ZodString;
|
|
285
|
+
}, z.core.$strict>>], "kind">;
|
|
167
286
|
}, z.core.$strict>>>>;
|
|
168
287
|
expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
|
|
169
288
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
@@ -240,6 +359,29 @@ export declare const AgentRequestPortableSchema: z.ZodDiscriminatedUnion<[z.ZodR
|
|
|
240
359
|
expiresAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
|
|
241
360
|
}, z.core.$strict>>], "requestKind">;
|
|
242
361
|
export declare const AgentRequestSchema: z.ZodType<AgentRequest>;
|
|
362
|
+
export declare const AgentElicitationAnswerSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
|
|
363
|
+
fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
|
|
364
|
+
kind: z.ZodLiteral<"text">;
|
|
365
|
+
value: z.ZodString;
|
|
366
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
367
|
+
fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
|
|
368
|
+
kind: z.ZodLiteral<"single_select">;
|
|
369
|
+
value: z.ZodOptional<z.ZodIntersection<z.ZodString, z.ZodString>>;
|
|
370
|
+
other: z.ZodOptional<z.ZodString>;
|
|
371
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
372
|
+
fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
|
|
373
|
+
kind: z.ZodLiteral<"multi_select">;
|
|
374
|
+
values: z.ZodReadonly<z.ZodArray<z.ZodIntersection<z.ZodString, z.ZodString>>>;
|
|
375
|
+
other: z.ZodOptional<z.ZodString>;
|
|
376
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
377
|
+
fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
|
|
378
|
+
kind: z.ZodLiteral<"boolean">;
|
|
379
|
+
value: z.ZodBoolean;
|
|
380
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
381
|
+
fieldId: z.ZodType<import("../index.js").AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestFieldId, unknown>>;
|
|
382
|
+
kind: z.ZodLiteral<"confirmation">;
|
|
383
|
+
confirmed: z.ZodBoolean;
|
|
384
|
+
}, z.core.$strict>>], "kind">;
|
|
243
385
|
export declare const AgentApprovalResolutionSchema: z.ZodType<AgentApprovalResolution>;
|
|
244
386
|
export declare const AgentRequestResolutionPortableSchema: z.ZodUnion<readonly [z.ZodType<AgentApprovalResolution, unknown, z.core.$ZodTypeInternals<AgentApprovalResolution, unknown>>, z.ZodReadonly<z.ZodObject<{
|
|
245
387
|
requestKind: z.ZodLiteral<"elicitation">;
|
|
@@ -273,5 +415,6 @@ export declare const AgentRequestResolutionPortableSchema: z.ZodUnion<readonly [
|
|
|
273
415
|
requestId: z.ZodType<import("../index.js").AgentRequestId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentRequestId, unknown>>;
|
|
274
416
|
disposition: z.ZodLiteral<"canceled">;
|
|
275
417
|
}, z.core.$strict>>]>;
|
|
418
|
+
export declare function refineAgentElicitationAnswers(answers: readonly z.output<typeof AgentElicitationAnswerSchema>[], context: z.RefinementCtx): void;
|
|
276
419
|
export declare const AgentRequestResolutionSchema: z.ZodType<AgentRequestResolution>;
|
|
277
420
|
//# sourceMappingURL=requests.d.ts.map
|
package/dist/zod/requests.js
CHANGED
|
@@ -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
|
-
|
|
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"),
|
|
@@ -120,9 +132,9 @@ const AgentElicitationRequestPortableSchema = z.object({
|
|
|
120
132
|
fields: z.array(AgentElicitationFieldSchema).min(1).max(AGENT_ELICITATION_FIELDS_MAX_LENGTH).readonly(),
|
|
121
133
|
expiresAt: AgentIsoDateTimeSchema.optional()
|
|
122
134
|
}).strict().readonly();
|
|
123
|
-
|
|
135
|
+
function refineAgentElicitationFields(fields, context) {
|
|
124
136
|
const fieldIds = /* @__PURE__ */ new Set();
|
|
125
|
-
|
|
137
|
+
fields.forEach((field, fieldIndex) => {
|
|
126
138
|
if (fieldIds.has(field.fieldId)) {
|
|
127
139
|
context.addIssue({
|
|
128
140
|
code: "custom",
|
|
@@ -153,6 +165,9 @@ const AgentElicitationRequestSchema = AgentElicitationRequestPortableSchema.supe
|
|
|
153
165
|
});
|
|
154
166
|
}
|
|
155
167
|
});
|
|
168
|
+
}
|
|
169
|
+
const AgentElicitationRequestSchema = AgentElicitationRequestPortableSchema.superRefine((request, context) => {
|
|
170
|
+
refineAgentElicitationFields(request.fields, context);
|
|
156
171
|
});
|
|
157
172
|
const AgentRequestPortableSchema = z.discriminatedUnion("requestKind", [
|
|
158
173
|
AgentApprovalRequestPortableSchema,
|
|
@@ -226,11 +241,8 @@ const AgentRequestResolutionPortableSchema = z.union([
|
|
|
226
241
|
disposition: z.literal("canceled")
|
|
227
242
|
}).strict().readonly()
|
|
228
243
|
]);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
resolution.answers.forEach((answer, answerIndex) => {
|
|
244
|
+
function refineAgentElicitationAnswers(answers, context) {
|
|
245
|
+
answers.forEach((answer, answerIndex) => {
|
|
234
246
|
if (answer.kind === "multi_select" && new Set(answer.values).size !== answer.values.length) {
|
|
235
247
|
context.addIssue({
|
|
236
248
|
code: "custom",
|
|
@@ -246,15 +258,26 @@ const AgentRequestResolutionSchema = AgentRequestResolutionPortableSchema.superR
|
|
|
246
258
|
});
|
|
247
259
|
}
|
|
248
260
|
});
|
|
261
|
+
}
|
|
262
|
+
const AgentRequestResolutionSchema = AgentRequestResolutionPortableSchema.superRefine((resolution, context) => {
|
|
263
|
+
if (resolution.requestKind !== "elicitation" || resolution.disposition !== "answered") {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
refineAgentElicitationAnswers(resolution.answers, context);
|
|
249
267
|
});
|
|
250
268
|
export {
|
|
269
|
+
AgentApprovalConsequenceSchema,
|
|
251
270
|
AgentApprovalRequestPortableSchema,
|
|
252
271
|
AgentApprovalRequestSchema,
|
|
253
272
|
AgentApprovalResolutionSchema,
|
|
273
|
+
AgentElicitationAnswerSchema,
|
|
274
|
+
AgentElicitationFieldSchema,
|
|
254
275
|
AgentElicitationRequestPortableSchema,
|
|
255
276
|
AgentElicitationRequestSchema,
|
|
256
277
|
AgentRequestPortableSchema,
|
|
257
278
|
AgentRequestResolutionPortableSchema,
|
|
258
279
|
AgentRequestResolutionSchema,
|
|
259
|
-
AgentRequestSchema
|
|
280
|
+
AgentRequestSchema,
|
|
281
|
+
refineAgentElicitationAnswers,
|
|
282
|
+
refineAgentElicitationFields
|
|
260
283
|
};
|