@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.
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/dist/artifacts/index.d.ts +3 -0
- package/dist/artifacts/index.js +2 -0
- package/dist/artifacts/parsers.d.ts +5 -0
- package/dist/artifacts/parsers.js +12 -0
- package/dist/artifacts/types.d.ts +19 -0
- package/dist/artifacts/types.js +16 -0
- package/dist/capabilities/index.d.ts +3 -0
- package/dist/capabilities/index.js +2 -0
- package/dist/capabilities/parsers.d.ts +6 -0
- package/dist/capabilities/parsers.js +18 -0
- package/dist/capabilities/types.d.ts +96 -0
- package/dist/capabilities/types.js +20 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.js +2 -0
- package/dist/events/parsers.d.ts +6 -0
- package/dist/events/parsers.js +16 -0
- package/dist/events/types.d.ts +78 -0
- package/dist/events/types.js +21 -0
- package/dist/foundation/index.d.ts +4 -0
- package/dist/foundation/index.js +3 -0
- package/dist/foundation/ordering.d.ts +2 -0
- package/dist/foundation/ordering.js +15 -0
- package/dist/foundation/parsers.d.ts +39 -0
- package/dist/foundation/parsers.js +148 -0
- package/dist/foundation/types.d.ts +62 -0
- package/dist/foundation/types.js +39 -0
- package/dist/foundation/validation.d.ts +16 -0
- package/dist/foundation/validation.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/internal/parsers.d.ts +5 -0
- package/dist/internal/parsers.js +21 -0
- package/dist/jsonSchema/generated.d.ts +6667 -0
- package/dist/jsonSchema/generated.js +4150 -0
- package/dist/jsonSchema/index.d.ts +2 -0
- package/dist/jsonSchema/index.js +1 -0
- package/dist/public/artifacts.d.ts +2 -0
- package/dist/public/artifacts.js +1 -0
- package/dist/public/capabilities.d.ts +2 -0
- package/dist/public/capabilities.js +1 -0
- package/dist/public/events.d.ts +2 -0
- package/dist/public/events.js +1 -0
- package/dist/public/index.d.ts +8 -0
- package/dist/public/index.js +7 -0
- package/dist/public/requests.d.ts +2 -0
- package/dist/public/requests.js +1 -0
- package/dist/public/sessions.d.ts +2 -0
- package/dist/public/sessions.js +1 -0
- package/dist/public/turns.d.ts +2 -0
- package/dist/public/turns.js +1 -0
- package/dist/requests/index.d.ts +3 -0
- package/dist/requests/index.js +2 -0
- package/dist/requests/parsers.d.ts +9 -0
- package/dist/requests/parsers.js +134 -0
- package/dist/requests/types.d.ts +89 -0
- package/dist/requests/types.js +0 -0
- package/dist/sessions/index.d.ts +3 -0
- package/dist/sessions/index.js +2 -0
- package/dist/sessions/parsers.d.ts +10 -0
- package/dist/sessions/parsers.js +38 -0
- package/dist/sessions/types.d.ts +37 -0
- package/dist/sessions/types.js +0 -0
- package/dist/turns/index.d.ts +3 -0
- package/dist/turns/index.js +2 -0
- package/dist/turns/parsers.d.ts +11 -0
- package/dist/turns/parsers.js +41 -0
- package/dist/turns/types.d.ts +207 -0
- package/dist/turns/types.js +62 -0
- package/dist/zod/artifacts.d.ts +4 -0
- package/dist/zod/artifacts.js +28 -0
- package/dist/zod/capabilities.d.ts +180 -0
- package/dist/zod/capabilities.js +222 -0
- package/dist/zod/events.d.ts +357 -0
- package/dist/zod/events.js +190 -0
- package/dist/zod/foundation.d.ts +45 -0
- package/dist/zod/foundation.js +205 -0
- package/dist/zod/index.d.ts +9 -0
- package/dist/zod/index.js +118 -0
- package/dist/zod/requests.d.ts +123 -0
- package/dist/zod/requests.js +174 -0
- package/dist/zod/sessions.d.ts +65 -0
- package/dist/zod/sessions.js +124 -0
- package/dist/zod/turns.d.ts +219 -0
- package/dist/zod/turns.js +400 -0
- package/dist/zod/typeEquality.generated.d.ts +51 -0
- package/dist/zod/typeEquality.generated.js +0 -0
- package/package.json +95 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { AgentArtifactDescriptorSchema } from "./artifacts.js";
|
|
3
|
+
import {
|
|
4
|
+
AGENT_PROTOCOL_COLLECTION_MAX_LENGTH,
|
|
5
|
+
AGENT_PROTOCOL_EVENT_BYTES_LIMIT,
|
|
6
|
+
AGENT_PROTOCOL_SUMMARY_MAX_LENGTH,
|
|
7
|
+
AGENT_PROTOCOL_TEXT_MAX_LENGTH,
|
|
8
|
+
AGENT_PROTOCOL_VERSION,
|
|
9
|
+
agentProtocolSerializedJsonBytes
|
|
10
|
+
} from "../foundation/types.js";
|
|
11
|
+
import { AgentRequestPortableSchema, AgentRequestSchema } from "./requests.js";
|
|
12
|
+
import {
|
|
13
|
+
AgentContentStreamKindSchema,
|
|
14
|
+
AgentDiffSummarySchema,
|
|
15
|
+
AgentItemSnapshotSchema,
|
|
16
|
+
AgentPlanStepSchema,
|
|
17
|
+
AgentTurnCompletedPayloadPortableSchema,
|
|
18
|
+
AgentTurnCompletedPayloadSchema
|
|
19
|
+
} from "./turns.js";
|
|
20
|
+
import {
|
|
21
|
+
AgentArtifactIdSchema,
|
|
22
|
+
AgentCanonicalCodeSchema,
|
|
23
|
+
AgentCanonicalIdValueSchema,
|
|
24
|
+
AgentCanonicalNonBlankTextSchema,
|
|
25
|
+
AgentErrorContextSchema,
|
|
26
|
+
AgentErrorSchema,
|
|
27
|
+
AgentIsoDateTimeSchema,
|
|
28
|
+
AgentItemIdSchema,
|
|
29
|
+
AgentProviderRefsPortableSchema,
|
|
30
|
+
AgentProviderRefsSchema,
|
|
31
|
+
AgentRequestIdSchema,
|
|
32
|
+
AgentSessionIdSchema,
|
|
33
|
+
AgentTurnIdSchema
|
|
34
|
+
} from "./foundation.js";
|
|
35
|
+
const commonFields = {
|
|
36
|
+
protocolVersion: z.literal(AGENT_PROTOCOL_VERSION),
|
|
37
|
+
sessionId: AgentSessionIdSchema,
|
|
38
|
+
providerRefs: AgentProviderRefsPortableSchema.optional(),
|
|
39
|
+
occurredAt: AgentIsoDateTimeSchema
|
|
40
|
+
};
|
|
41
|
+
function turnEvent(type, payload) {
|
|
42
|
+
return z.object({
|
|
43
|
+
...commonFields,
|
|
44
|
+
type: z.literal(type),
|
|
45
|
+
turnId: AgentTurnIdSchema,
|
|
46
|
+
payload
|
|
47
|
+
}).strict().readonly();
|
|
48
|
+
}
|
|
49
|
+
function optionallyTurnScopedEvent(type, payload) {
|
|
50
|
+
return z.object({
|
|
51
|
+
...commonFields,
|
|
52
|
+
type: z.literal(type),
|
|
53
|
+
turnId: AgentTurnIdSchema.optional(),
|
|
54
|
+
payload
|
|
55
|
+
}).strict().readonly();
|
|
56
|
+
}
|
|
57
|
+
const TurnStateChangedPayloadSchema = z.object({
|
|
58
|
+
state: z.enum(["running", "waiting_for_request"]),
|
|
59
|
+
requestId: AgentRequestIdSchema.optional(),
|
|
60
|
+
message: z.string().max(AGENT_PROTOCOL_TEXT_MAX_LENGTH).optional()
|
|
61
|
+
}).strict().readonly();
|
|
62
|
+
const ProgressUpdatedPayloadSchema = z.object({
|
|
63
|
+
progressId: AgentCanonicalIdValueSchema,
|
|
64
|
+
kind: z.enum(["task", "hook", "tool", "unknown"]),
|
|
65
|
+
phase: z.enum(["started", "updated", "completed"]),
|
|
66
|
+
title: z.string().max(200).optional(),
|
|
67
|
+
message: z.string().max(AGENT_PROTOCOL_TEXT_MAX_LENGTH).optional(),
|
|
68
|
+
current: z.number().int().min(0).optional(),
|
|
69
|
+
total: z.number().int().min(0).optional()
|
|
70
|
+
}).strict().readonly();
|
|
71
|
+
const AgentEventPortableSchema = z.discriminatedUnion("type", [
|
|
72
|
+
turnEvent(
|
|
73
|
+
"turn.started",
|
|
74
|
+
z.object({ message: z.string().max(AGENT_PROTOCOL_TEXT_MAX_LENGTH).optional() }).strict().readonly()
|
|
75
|
+
),
|
|
76
|
+
turnEvent("turn.state_changed", TurnStateChangedPayloadSchema),
|
|
77
|
+
turnEvent("turn.completed", AgentTurnCompletedPayloadPortableSchema),
|
|
78
|
+
turnEvent("item.started", AgentItemSnapshotSchema),
|
|
79
|
+
turnEvent("item.updated", AgentItemSnapshotSchema),
|
|
80
|
+
turnEvent("item.completed", AgentItemSnapshotSchema),
|
|
81
|
+
turnEvent(
|
|
82
|
+
"content.delta",
|
|
83
|
+
z.object({
|
|
84
|
+
itemId: AgentItemIdSchema,
|
|
85
|
+
streamKind: AgentContentStreamKindSchema,
|
|
86
|
+
delta: z.string().max(AGENT_PROTOCOL_TEXT_MAX_LENGTH)
|
|
87
|
+
}).strict().readonly()
|
|
88
|
+
),
|
|
89
|
+
turnEvent(
|
|
90
|
+
"turn.plan.updated",
|
|
91
|
+
z.object({
|
|
92
|
+
explanation: z.string().max(AGENT_PROTOCOL_SUMMARY_MAX_LENGTH).optional(),
|
|
93
|
+
steps: z.array(AgentPlanStepSchema).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly()
|
|
94
|
+
}).strict().readonly()
|
|
95
|
+
),
|
|
96
|
+
turnEvent(
|
|
97
|
+
"turn.plan.proposed",
|
|
98
|
+
z.object({
|
|
99
|
+
artifactId: AgentArtifactIdSchema,
|
|
100
|
+
requestId: AgentRequestIdSchema
|
|
101
|
+
}).strict().readonly()
|
|
102
|
+
),
|
|
103
|
+
turnEvent("turn.diff.updated", AgentDiffSummarySchema),
|
|
104
|
+
turnEvent(
|
|
105
|
+
"request.opened",
|
|
106
|
+
z.object({ request: AgentRequestPortableSchema }).strict().readonly()
|
|
107
|
+
),
|
|
108
|
+
turnEvent("progress.updated", ProgressUpdatedPayloadSchema),
|
|
109
|
+
optionallyTurnScopedEvent(
|
|
110
|
+
"artifact.referenced",
|
|
111
|
+
z.object({ artifact: AgentArtifactDescriptorSchema }).strict().readonly()
|
|
112
|
+
),
|
|
113
|
+
optionallyTurnScopedEvent(
|
|
114
|
+
"runtime.warning",
|
|
115
|
+
z.object({
|
|
116
|
+
code: AgentCanonicalCodeSchema,
|
|
117
|
+
message: AgentCanonicalNonBlankTextSchema,
|
|
118
|
+
retryable: z.boolean().optional(),
|
|
119
|
+
context: AgentErrorContextSchema.optional()
|
|
120
|
+
}).strict().readonly()
|
|
121
|
+
),
|
|
122
|
+
optionallyTurnScopedEvent(
|
|
123
|
+
"runtime.error",
|
|
124
|
+
z.object({ error: AgentErrorSchema }).strict().readonly()
|
|
125
|
+
),
|
|
126
|
+
optionallyTurnScopedEvent(
|
|
127
|
+
"provider.diagnostic",
|
|
128
|
+
z.object({
|
|
129
|
+
code: AgentCanonicalCodeSchema,
|
|
130
|
+
message: AgentCanonicalNonBlankTextSchema,
|
|
131
|
+
context: AgentErrorContextSchema.optional()
|
|
132
|
+
}).strict().readonly()
|
|
133
|
+
)
|
|
134
|
+
]);
|
|
135
|
+
const AgentEventSchema = AgentEventPortableSchema.superRefine((event, context) => {
|
|
136
|
+
if (event.providerRefs !== void 0) {
|
|
137
|
+
const providerRefs = AgentProviderRefsSchema.safeParse(event.providerRefs);
|
|
138
|
+
if (!providerRefs.success) {
|
|
139
|
+
for (const issue of providerRefs.error.issues) {
|
|
140
|
+
context.addIssue({ ...issue, path: ["providerRefs", ...issue.path] });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (event.type === "turn.state_changed") {
|
|
145
|
+
const waiting = event.payload.state === "waiting_for_request";
|
|
146
|
+
if (waiting !== (event.payload.requestId !== void 0)) {
|
|
147
|
+
context.addIssue({
|
|
148
|
+
code: "custom",
|
|
149
|
+
path: ["payload", "requestId"],
|
|
150
|
+
message: "Only waiting_for_request state requires a requestId."
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (event.type === "turn.completed") {
|
|
155
|
+
const completed = AgentTurnCompletedPayloadSchema.safeParse(event.payload);
|
|
156
|
+
if (!completed.success) {
|
|
157
|
+
for (const issue of completed.error.issues) {
|
|
158
|
+
context.addIssue({ ...issue, path: ["payload", ...issue.path] });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (event.type === "request.opened") {
|
|
163
|
+
const request = AgentRequestSchema.safeParse(event.payload.request);
|
|
164
|
+
if (!request.success) {
|
|
165
|
+
for (const issue of request.error.issues) {
|
|
166
|
+
context.addIssue({
|
|
167
|
+
...issue,
|
|
168
|
+
path: ["payload", "request", ...issue.path]
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (event.type === "progress.updated" && event.payload.current !== void 0 && event.payload.total !== void 0 && event.payload.current > event.payload.total) {
|
|
174
|
+
context.addIssue({
|
|
175
|
+
code: "custom",
|
|
176
|
+
path: ["payload", "current"],
|
|
177
|
+
message: "Progress current cannot exceed total."
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
if (agentProtocolSerializedJsonBytes(event) > AGENT_PROTOCOL_EVENT_BYTES_LIMIT) {
|
|
181
|
+
context.addIssue({
|
|
182
|
+
code: "custom",
|
|
183
|
+
message: `Agent events cannot exceed ${AGENT_PROTOCOL_EVENT_BYTES_LIMIT} serialized bytes.`
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
export {
|
|
188
|
+
AgentEventPortableSchema,
|
|
189
|
+
AgentEventSchema
|
|
190
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { type AgentArtifactId, type AgentConfigurationRevisionId, type AgentError, type AgentInstanceId, type AgentIsoDateTime, type AgentItemId, type AgentJsonValue, type AgentProviderConversationId, type AgentProviderHistoryAnchor, type AgentProviderItemRef, type AgentProviderKey, type AgentProviderRefs, type AgentProviderRequestRef, type AgentProviderTurnRef, type AgentRequestFieldId, type AgentRequestId, type AgentSessionId, type AgentTurnId } from '../foundation/types.js';
|
|
3
|
+
export declare const AgentCanonicalIdValueSchema: z.ZodString;
|
|
4
|
+
export declare function createAgentCanonicalNonBlankStringSchema(maxLength: number): z.ZodString;
|
|
5
|
+
export declare const AgentCanonicalNonBlankTextSchema: z.ZodString;
|
|
6
|
+
export declare const AgentCanonicalCodeSchema: z.ZodString;
|
|
7
|
+
export declare const AgentInstanceIdSchema: z.ZodType<AgentInstanceId, unknown, z.core.$ZodTypeInternals<AgentInstanceId, unknown>>;
|
|
8
|
+
export declare const AgentSessionIdSchema: z.ZodType<AgentSessionId, unknown, z.core.$ZodTypeInternals<AgentSessionId, unknown>>;
|
|
9
|
+
export declare const AgentTurnIdSchema: z.ZodType<AgentTurnId, unknown, z.core.$ZodTypeInternals<AgentTurnId, unknown>>;
|
|
10
|
+
export declare const AgentItemIdSchema: z.ZodType<AgentItemId, unknown, z.core.$ZodTypeInternals<AgentItemId, unknown>>;
|
|
11
|
+
export declare const AgentRequestIdSchema: z.ZodType<AgentRequestId, unknown, z.core.$ZodTypeInternals<AgentRequestId, unknown>>;
|
|
12
|
+
export declare const AgentRequestFieldIdSchema: z.ZodType<AgentRequestFieldId, unknown, z.core.$ZodTypeInternals<AgentRequestFieldId, unknown>>;
|
|
13
|
+
export declare const AgentArtifactIdSchema: z.ZodType<AgentArtifactId, unknown, z.core.$ZodTypeInternals<AgentArtifactId, unknown>>;
|
|
14
|
+
export declare const AgentConfigurationRevisionIdSchema: z.ZodType<AgentConfigurationRevisionId, unknown, z.core.$ZodTypeInternals<AgentConfigurationRevisionId, unknown>>;
|
|
15
|
+
export declare const AgentProviderConversationIdSchema: z.ZodType<AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<AgentProviderConversationId, unknown>>;
|
|
16
|
+
export declare const AgentProviderHistoryAnchorSchema: z.ZodType<AgentProviderHistoryAnchor, unknown, z.core.$ZodTypeInternals<AgentProviderHistoryAnchor, unknown>>;
|
|
17
|
+
export declare const AgentProviderTurnRefSchema: z.ZodType<AgentProviderTurnRef, unknown, z.core.$ZodTypeInternals<AgentProviderTurnRef, unknown>>;
|
|
18
|
+
export declare const AgentProviderItemRefSchema: z.ZodType<AgentProviderItemRef, unknown, z.core.$ZodTypeInternals<AgentProviderItemRef, unknown>>;
|
|
19
|
+
export declare const AgentProviderRequestRefSchema: z.ZodType<AgentProviderRequestRef, unknown, z.core.$ZodTypeInternals<AgentProviderRequestRef, unknown>>;
|
|
20
|
+
export declare const AgentProviderKeySchema: z.ZodType<AgentProviderKey, unknown, z.core.$ZodTypeInternals<AgentProviderKey, unknown>>;
|
|
21
|
+
export declare const AgentIsoDateTimeSchema: z.ZodType<AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<AgentIsoDateTime, unknown>>;
|
|
22
|
+
export declare const AgentJsonObjectKeySchema: z.ZodString;
|
|
23
|
+
interface ProtocolInputPreflightOptions {
|
|
24
|
+
readonly maxDepth?: number;
|
|
25
|
+
readonly maxCollectionLength?: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function withAcyclicProtocolInput<Output>(schema: z.ZodType<Output>, options?: ProtocolInputPreflightOptions): z.ZodType<Output>;
|
|
28
|
+
export declare const AgentJsonValuePortableSchema: z.ZodType<AgentJsonValue>;
|
|
29
|
+
export declare const AgentJsonValueSchema: z.ZodType<AgentJsonValue>;
|
|
30
|
+
export declare const AgentProviderRefsPortableSchema: z.ZodReadonly<z.ZodObject<{
|
|
31
|
+
conversationId: z.ZodOptional<z.ZodType<AgentProviderConversationId, unknown, z.core.$ZodTypeInternals<AgentProviderConversationId, unknown>>>;
|
|
32
|
+
historyAnchor: z.ZodOptional<z.ZodType<AgentProviderHistoryAnchor, unknown, z.core.$ZodTypeInternals<AgentProviderHistoryAnchor, unknown>>>;
|
|
33
|
+
turnId: z.ZodOptional<z.ZodType<AgentProviderTurnRef, unknown, z.core.$ZodTypeInternals<AgentProviderTurnRef, unknown>>>;
|
|
34
|
+
itemId: z.ZodOptional<z.ZodType<AgentProviderItemRef, unknown, z.core.$ZodTypeInternals<AgentProviderItemRef, unknown>>>;
|
|
35
|
+
requestId: z.ZodOptional<z.ZodType<AgentProviderRequestRef, unknown, z.core.$ZodTypeInternals<AgentProviderRequestRef, unknown>>>;
|
|
36
|
+
}, z.core.$strict>>;
|
|
37
|
+
export declare const AgentProviderRefsSchema: z.ZodType<AgentProviderRefs>;
|
|
38
|
+
export declare const AgentErrorContextSchema: z.ZodReadonly<z.ZodObject<{
|
|
39
|
+
operation: z.ZodOptional<z.ZodString>;
|
|
40
|
+
component: z.ZodOptional<z.ZodString>;
|
|
41
|
+
status: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, z.core.$strict>>;
|
|
43
|
+
export declare const AgentErrorSchema: z.ZodType<AgentError>;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=foundation.d.ts.map
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import {
|
|
3
|
+
AGENT_PROTOCOL_CODE_MAX_LENGTH,
|
|
4
|
+
AGENT_PROTOCOL_COLLECTION_MAX_LENGTH,
|
|
5
|
+
AGENT_PROTOCOL_ID_MAX_LENGTH,
|
|
6
|
+
AGENT_PROTOCOL_JSON_BYTES_LIMIT,
|
|
7
|
+
AGENT_PROTOCOL_JSON_DEPTH_LIMIT,
|
|
8
|
+
AGENT_PROTOCOL_JSON_KEY_MAX_LENGTH,
|
|
9
|
+
AGENT_PROTOCOL_PROVIDER_KEY_MAX_LENGTH,
|
|
10
|
+
AGENT_PROTOCOL_PROVIDER_REFERENCE_MAX_LENGTH,
|
|
11
|
+
AGENT_PROTOCOL_TEXT_MAX_LENGTH,
|
|
12
|
+
agentProtocolSerializedJsonBytes
|
|
13
|
+
} from "../foundation/types.js";
|
|
14
|
+
const CANONICAL_OPAQUE_STRING_PATTERN = /^(?![\s\S]*[\u0000-\u001F\u007F-\u009F])\S(?:[\s\S]*\S)?$/u;
|
|
15
|
+
const CANONICAL_NON_BLANK_STRING_PATTERN = /^(?:\S|\S[\s\S]*\S)$/u;
|
|
16
|
+
function canonicalOpaqueStringSchema(maxLength, message) {
|
|
17
|
+
return z.string().min(1).max(maxLength).regex(CANONICAL_OPAQUE_STRING_PATTERN, message);
|
|
18
|
+
}
|
|
19
|
+
const AgentCanonicalIdValueSchema = canonicalOpaqueStringSchema(
|
|
20
|
+
AGENT_PROTOCOL_ID_MAX_LENGTH,
|
|
21
|
+
"Opaque IDs must be canonical and contain no control or surrounding whitespace."
|
|
22
|
+
);
|
|
23
|
+
function createAgentCanonicalNonBlankStringSchema(maxLength) {
|
|
24
|
+
return z.string().min(1).max(maxLength).regex(
|
|
25
|
+
CANONICAL_NON_BLANK_STRING_PATTERN,
|
|
26
|
+
"Canonical text must contain non-whitespace content and no surrounding whitespace."
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
const AgentCanonicalNonBlankTextSchema = createAgentCanonicalNonBlankStringSchema(AGENT_PROTOCOL_TEXT_MAX_LENGTH);
|
|
30
|
+
const AgentCanonicalCodeSchema = createAgentCanonicalNonBlankStringSchema(AGENT_PROTOCOL_CODE_MAX_LENGTH);
|
|
31
|
+
const ProviderReferenceSchema = canonicalOpaqueStringSchema(
|
|
32
|
+
AGENT_PROTOCOL_PROVIDER_REFERENCE_MAX_LENGTH,
|
|
33
|
+
"Provider references must be canonical and contain no control or surrounding whitespace."
|
|
34
|
+
);
|
|
35
|
+
function opaqueStringSchema(schema) {
|
|
36
|
+
return schema;
|
|
37
|
+
}
|
|
38
|
+
const AgentInstanceIdSchema = opaqueStringSchema(AgentCanonicalIdValueSchema);
|
|
39
|
+
const AgentSessionIdSchema = opaqueStringSchema(AgentCanonicalIdValueSchema);
|
|
40
|
+
const AgentTurnIdSchema = opaqueStringSchema(AgentCanonicalIdValueSchema);
|
|
41
|
+
const AgentItemIdSchema = opaqueStringSchema(AgentCanonicalIdValueSchema);
|
|
42
|
+
const AgentRequestIdSchema = opaqueStringSchema(AgentCanonicalIdValueSchema);
|
|
43
|
+
const AgentRequestFieldIdSchema = opaqueStringSchema(AgentCanonicalIdValueSchema);
|
|
44
|
+
const AgentArtifactIdSchema = opaqueStringSchema(AgentCanonicalIdValueSchema);
|
|
45
|
+
const AgentConfigurationRevisionIdSchema = opaqueStringSchema(AgentCanonicalIdValueSchema);
|
|
46
|
+
const AgentProviderConversationIdSchema = opaqueStringSchema(ProviderReferenceSchema);
|
|
47
|
+
const AgentProviderHistoryAnchorSchema = opaqueStringSchema(ProviderReferenceSchema);
|
|
48
|
+
const AgentProviderTurnRefSchema = opaqueStringSchema(ProviderReferenceSchema);
|
|
49
|
+
const AgentProviderItemRefSchema = opaqueStringSchema(ProviderReferenceSchema);
|
|
50
|
+
const AgentProviderRequestRefSchema = opaqueStringSchema(ProviderReferenceSchema);
|
|
51
|
+
const AgentProviderKeySchema = opaqueStringSchema(
|
|
52
|
+
z.string().min(1).max(AGENT_PROTOCOL_PROVIDER_KEY_MAX_LENGTH).regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/u)
|
|
53
|
+
);
|
|
54
|
+
const AgentIsoDateTimeSchema = opaqueStringSchema(
|
|
55
|
+
z.string().datetime({ offset: true })
|
|
56
|
+
);
|
|
57
|
+
const AGENT_JSON_OBJECT_KEY_PATTERN = /^(?!(?:__proto__|constructor|prototype)$)/u;
|
|
58
|
+
const AgentJsonObjectKeySchema = z.string().min(1).max(AGENT_PROTOCOL_JSON_KEY_MAX_LENGTH).regex(
|
|
59
|
+
AGENT_JSON_OBJECT_KEY_PATTERN,
|
|
60
|
+
"JSON object keys must not use prototype-sensitive names."
|
|
61
|
+
);
|
|
62
|
+
function passesProtocolInputPreflight(input, options) {
|
|
63
|
+
const activeObjects = /* @__PURE__ */ new WeakSet();
|
|
64
|
+
const pending = [{ operation: "enter", value: input, depth: 0 }];
|
|
65
|
+
while (pending.length > 0) {
|
|
66
|
+
const current = pending.pop();
|
|
67
|
+
if (!current) break;
|
|
68
|
+
if (current.operation === "leave") {
|
|
69
|
+
activeObjects.delete(current.value);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (options.maxDepth !== void 0 && current.depth > options.maxDepth) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (current.value === null || typeof current.value !== "object") continue;
|
|
76
|
+
if (activeObjects.has(current.value)) return false;
|
|
77
|
+
activeObjects.add(current.value);
|
|
78
|
+
pending.push({ operation: "leave", value: current.value });
|
|
79
|
+
if (Array.isArray(current.value) && options.maxCollectionLength !== void 0) {
|
|
80
|
+
let lengthDescriptor;
|
|
81
|
+
try {
|
|
82
|
+
lengthDescriptor = Object.getOwnPropertyDescriptor(current.value, "length");
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (!lengthDescriptor || !("value" in lengthDescriptor) || typeof lengthDescriptor.value !== "number" || lengthDescriptor.value > options.maxCollectionLength) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
let propertyKeys;
|
|
91
|
+
try {
|
|
92
|
+
propertyKeys = Reflect.ownKeys(current.value);
|
|
93
|
+
} catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
let collectionLength = 0;
|
|
97
|
+
for (const propertyKey of propertyKeys) {
|
|
98
|
+
if (typeof propertyKey === "string" && !AGENT_JSON_OBJECT_KEY_PATTERN.test(propertyKey)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
let descriptor;
|
|
102
|
+
try {
|
|
103
|
+
descriptor = Object.getOwnPropertyDescriptor(current.value, propertyKey);
|
|
104
|
+
} catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (!descriptor?.enumerable) continue;
|
|
108
|
+
if (!("value" in descriptor)) return false;
|
|
109
|
+
collectionLength += 1;
|
|
110
|
+
if (options.maxCollectionLength !== void 0 && collectionLength > options.maxCollectionLength) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
pending.push({
|
|
114
|
+
operation: "enter",
|
|
115
|
+
value: descriptor.value,
|
|
116
|
+
depth: current.depth + 1
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
function withAcyclicProtocolInput(schema, options = {}) {
|
|
123
|
+
return z.custom(
|
|
124
|
+
(input) => passesProtocolInputPreflight(input, options),
|
|
125
|
+
{
|
|
126
|
+
message: "Protocol inputs must be bounded, acyclic, and free of accessor-backed values."
|
|
127
|
+
}
|
|
128
|
+
).pipe(schema);
|
|
129
|
+
}
|
|
130
|
+
const AgentJsonValuePortableSchema = z.lazy(
|
|
131
|
+
() => z.union([
|
|
132
|
+
z.string().max(AGENT_PROTOCOL_JSON_BYTES_LIMIT),
|
|
133
|
+
z.number().finite(),
|
|
134
|
+
z.boolean(),
|
|
135
|
+
z.null(),
|
|
136
|
+
z.array(AgentJsonValuePortableSchema).max(AGENT_PROTOCOL_COLLECTION_MAX_LENGTH).readonly(),
|
|
137
|
+
z.record(
|
|
138
|
+
AgentJsonObjectKeySchema,
|
|
139
|
+
AgentJsonValuePortableSchema
|
|
140
|
+
).readonly()
|
|
141
|
+
])
|
|
142
|
+
);
|
|
143
|
+
function addJsonByteBoundsIssue(value, context) {
|
|
144
|
+
if (agentProtocolSerializedJsonBytes(value) > AGENT_PROTOCOL_JSON_BYTES_LIMIT) {
|
|
145
|
+
context.addIssue({
|
|
146
|
+
code: "custom",
|
|
147
|
+
message: `JSON values cannot exceed ${AGENT_PROTOCOL_JSON_BYTES_LIMIT} serialized bytes.`
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const AgentJsonValueSchema = withAcyclicProtocolInput(AgentJsonValuePortableSchema, {
|
|
152
|
+
maxDepth: AGENT_PROTOCOL_JSON_DEPTH_LIMIT,
|
|
153
|
+
maxCollectionLength: AGENT_PROTOCOL_COLLECTION_MAX_LENGTH
|
|
154
|
+
}).superRefine(addJsonByteBoundsIssue);
|
|
155
|
+
const AgentProviderRefsPortableSchema = z.object({
|
|
156
|
+
conversationId: AgentProviderConversationIdSchema.optional(),
|
|
157
|
+
historyAnchor: AgentProviderHistoryAnchorSchema.optional(),
|
|
158
|
+
turnId: AgentProviderTurnRefSchema.optional(),
|
|
159
|
+
itemId: AgentProviderItemRefSchema.optional(),
|
|
160
|
+
requestId: AgentProviderRequestRefSchema.optional()
|
|
161
|
+
}).strict().readonly();
|
|
162
|
+
const AgentProviderRefsSchema = AgentProviderRefsPortableSchema.refine(
|
|
163
|
+
(value) => Object.values(value).some((item) => item !== void 0),
|
|
164
|
+
{ message: "At least one provider reference is required." }
|
|
165
|
+
);
|
|
166
|
+
const AgentErrorContextSchema = z.object({
|
|
167
|
+
operation: createAgentCanonicalNonBlankStringSchema(160).optional(),
|
|
168
|
+
component: createAgentCanonicalNonBlankStringSchema(160).optional(),
|
|
169
|
+
status: createAgentCanonicalNonBlankStringSchema(160).optional()
|
|
170
|
+
}).strict().readonly();
|
|
171
|
+
const AgentErrorSchema = z.object({
|
|
172
|
+
code: AgentCanonicalCodeSchema,
|
|
173
|
+
message: AgentCanonicalNonBlankTextSchema,
|
|
174
|
+
retryable: z.boolean(),
|
|
175
|
+
context: AgentErrorContextSchema.optional()
|
|
176
|
+
}).strict().readonly();
|
|
177
|
+
export {
|
|
178
|
+
AgentArtifactIdSchema,
|
|
179
|
+
AgentCanonicalCodeSchema,
|
|
180
|
+
AgentCanonicalIdValueSchema,
|
|
181
|
+
AgentCanonicalNonBlankTextSchema,
|
|
182
|
+
AgentConfigurationRevisionIdSchema,
|
|
183
|
+
AgentErrorContextSchema,
|
|
184
|
+
AgentErrorSchema,
|
|
185
|
+
AgentInstanceIdSchema,
|
|
186
|
+
AgentIsoDateTimeSchema,
|
|
187
|
+
AgentItemIdSchema,
|
|
188
|
+
AgentJsonObjectKeySchema,
|
|
189
|
+
AgentJsonValuePortableSchema,
|
|
190
|
+
AgentJsonValueSchema,
|
|
191
|
+
AgentProviderConversationIdSchema,
|
|
192
|
+
AgentProviderHistoryAnchorSchema,
|
|
193
|
+
AgentProviderItemRefSchema,
|
|
194
|
+
AgentProviderKeySchema,
|
|
195
|
+
AgentProviderRefsPortableSchema,
|
|
196
|
+
AgentProviderRefsSchema,
|
|
197
|
+
AgentProviderRequestRefSchema,
|
|
198
|
+
AgentProviderTurnRefSchema,
|
|
199
|
+
AgentRequestFieldIdSchema,
|
|
200
|
+
AgentRequestIdSchema,
|
|
201
|
+
AgentSessionIdSchema,
|
|
202
|
+
AgentTurnIdSchema,
|
|
203
|
+
createAgentCanonicalNonBlankStringSchema,
|
|
204
|
+
withAcyclicProtocolInput
|
|
205
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { AgentArtifactIdSchema, AgentConfigurationRevisionIdSchema, AgentErrorContextSchema, AgentErrorSchema, AgentInstanceIdSchema, AgentIsoDateTimeSchema, AgentItemIdSchema, AgentJsonValueSchema, AgentProviderConversationIdSchema, AgentProviderHistoryAnchorSchema, AgentProviderItemRefSchema, AgentProviderKeySchema, AgentProviderRefsSchema, AgentProviderRequestRefSchema, AgentProviderTurnRefSchema, AgentRequestFieldIdSchema, AgentRequestIdSchema, AgentSessionIdSchema, AgentTurnIdSchema, } from './foundation.js';
|
|
2
|
+
export { AgentSessionBindingSchema, AgentSessionBranchSourceSchema, AgentSessionBranchInputSchema, AgentSessionConfigurationSchema, AgentSessionCreateInputSchema, AgentSessionOpenInputSchema, AgentSessionResumeInputSchema, } from './sessions.js';
|
|
3
|
+
export { AgentBrowserActionDetailsSchema, AgentCollaborationToolCallDetailsSchema, AgentCommandExecutionDetailsSchema, AgentComputerActionDetailsSchema, AgentContentStreamKindSchema, AgentDiffSummarySchema, AgentDynamicToolCallDetailsSchema, AgentFileChangeDetailsSchema, AgentFileChangeSchema, AgentImageViewDetailsSchema, AgentItemSnapshotSchema, AgentMcpToolCallDetailsSchema, AgentPlanStepSchema, AgentReviewDetailsSchema, AgentTurnCompletedPayloadSchema, AgentTurnInputContentCompositionSchema, AgentTurnInputContentSchema, AgentTurnInteractionModeSchema, AgentTurnInputPartSchema, AgentTurnInterruptionInputSchema, AgentTurnRunInputSchema, AgentWebSearchDetailsSchema, } from './turns.js';
|
|
4
|
+
export { AgentElicitationRequestSchema, AgentRequestResolutionSchema, AgentRequestSchema, } from './requests.js';
|
|
5
|
+
export { AgentCapabilitiesSchema } from './capabilities.js';
|
|
6
|
+
export { AgentArtifactDescriptorSchema } from './artifacts.js';
|
|
7
|
+
export { AgentEventSchema } from './events.js';
|
|
8
|
+
export type { AgentProtocolSchemaTypeAssertions } from './typeEquality.generated.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentArtifactIdSchema,
|
|
3
|
+
AgentConfigurationRevisionIdSchema,
|
|
4
|
+
AgentErrorContextSchema,
|
|
5
|
+
AgentErrorSchema,
|
|
6
|
+
AgentInstanceIdSchema,
|
|
7
|
+
AgentIsoDateTimeSchema,
|
|
8
|
+
AgentItemIdSchema,
|
|
9
|
+
AgentJsonValueSchema,
|
|
10
|
+
AgentProviderConversationIdSchema,
|
|
11
|
+
AgentProviderHistoryAnchorSchema,
|
|
12
|
+
AgentProviderItemRefSchema,
|
|
13
|
+
AgentProviderKeySchema,
|
|
14
|
+
AgentProviderRefsSchema,
|
|
15
|
+
AgentProviderRequestRefSchema,
|
|
16
|
+
AgentProviderTurnRefSchema,
|
|
17
|
+
AgentRequestFieldIdSchema,
|
|
18
|
+
AgentRequestIdSchema,
|
|
19
|
+
AgentSessionIdSchema,
|
|
20
|
+
AgentTurnIdSchema
|
|
21
|
+
} from "./foundation.js";
|
|
22
|
+
import {
|
|
23
|
+
AgentSessionBindingSchema,
|
|
24
|
+
AgentSessionBranchSourceSchema,
|
|
25
|
+
AgentSessionBranchInputSchema,
|
|
26
|
+
AgentSessionConfigurationSchema,
|
|
27
|
+
AgentSessionCreateInputSchema,
|
|
28
|
+
AgentSessionOpenInputSchema,
|
|
29
|
+
AgentSessionResumeInputSchema
|
|
30
|
+
} from "./sessions.js";
|
|
31
|
+
import {
|
|
32
|
+
AgentBrowserActionDetailsSchema,
|
|
33
|
+
AgentCollaborationToolCallDetailsSchema,
|
|
34
|
+
AgentCommandExecutionDetailsSchema,
|
|
35
|
+
AgentComputerActionDetailsSchema,
|
|
36
|
+
AgentContentStreamKindSchema,
|
|
37
|
+
AgentDiffSummarySchema,
|
|
38
|
+
AgentDynamicToolCallDetailsSchema,
|
|
39
|
+
AgentFileChangeDetailsSchema,
|
|
40
|
+
AgentFileChangeSchema,
|
|
41
|
+
AgentImageViewDetailsSchema,
|
|
42
|
+
AgentItemSnapshotSchema,
|
|
43
|
+
AgentMcpToolCallDetailsSchema,
|
|
44
|
+
AgentPlanStepSchema,
|
|
45
|
+
AgentReviewDetailsSchema,
|
|
46
|
+
AgentTurnCompletedPayloadSchema,
|
|
47
|
+
AgentTurnInputContentCompositionSchema,
|
|
48
|
+
AgentTurnInputContentSchema,
|
|
49
|
+
AgentTurnInteractionModeSchema,
|
|
50
|
+
AgentTurnInputPartSchema,
|
|
51
|
+
AgentTurnInterruptionInputSchema,
|
|
52
|
+
AgentTurnRunInputSchema,
|
|
53
|
+
AgentWebSearchDetailsSchema
|
|
54
|
+
} from "./turns.js";
|
|
55
|
+
import {
|
|
56
|
+
AgentElicitationRequestSchema,
|
|
57
|
+
AgentRequestResolutionSchema,
|
|
58
|
+
AgentRequestSchema
|
|
59
|
+
} from "./requests.js";
|
|
60
|
+
import { AgentCapabilitiesSchema } from "./capabilities.js";
|
|
61
|
+
import { AgentArtifactDescriptorSchema } from "./artifacts.js";
|
|
62
|
+
import { AgentEventSchema } from "./events.js";
|
|
63
|
+
export {
|
|
64
|
+
AgentArtifactDescriptorSchema,
|
|
65
|
+
AgentArtifactIdSchema,
|
|
66
|
+
AgentBrowserActionDetailsSchema,
|
|
67
|
+
AgentCapabilitiesSchema,
|
|
68
|
+
AgentCollaborationToolCallDetailsSchema,
|
|
69
|
+
AgentCommandExecutionDetailsSchema,
|
|
70
|
+
AgentComputerActionDetailsSchema,
|
|
71
|
+
AgentConfigurationRevisionIdSchema,
|
|
72
|
+
AgentContentStreamKindSchema,
|
|
73
|
+
AgentDiffSummarySchema,
|
|
74
|
+
AgentDynamicToolCallDetailsSchema,
|
|
75
|
+
AgentElicitationRequestSchema,
|
|
76
|
+
AgentErrorContextSchema,
|
|
77
|
+
AgentErrorSchema,
|
|
78
|
+
AgentEventSchema,
|
|
79
|
+
AgentFileChangeDetailsSchema,
|
|
80
|
+
AgentFileChangeSchema,
|
|
81
|
+
AgentImageViewDetailsSchema,
|
|
82
|
+
AgentInstanceIdSchema,
|
|
83
|
+
AgentIsoDateTimeSchema,
|
|
84
|
+
AgentItemIdSchema,
|
|
85
|
+
AgentItemSnapshotSchema,
|
|
86
|
+
AgentJsonValueSchema,
|
|
87
|
+
AgentMcpToolCallDetailsSchema,
|
|
88
|
+
AgentPlanStepSchema,
|
|
89
|
+
AgentProviderConversationIdSchema,
|
|
90
|
+
AgentProviderHistoryAnchorSchema,
|
|
91
|
+
AgentProviderItemRefSchema,
|
|
92
|
+
AgentProviderKeySchema,
|
|
93
|
+
AgentProviderRefsSchema,
|
|
94
|
+
AgentProviderRequestRefSchema,
|
|
95
|
+
AgentProviderTurnRefSchema,
|
|
96
|
+
AgentRequestFieldIdSchema,
|
|
97
|
+
AgentRequestIdSchema,
|
|
98
|
+
AgentRequestResolutionSchema,
|
|
99
|
+
AgentRequestSchema,
|
|
100
|
+
AgentReviewDetailsSchema,
|
|
101
|
+
AgentSessionBindingSchema,
|
|
102
|
+
AgentSessionBranchInputSchema,
|
|
103
|
+
AgentSessionBranchSourceSchema,
|
|
104
|
+
AgentSessionConfigurationSchema,
|
|
105
|
+
AgentSessionCreateInputSchema,
|
|
106
|
+
AgentSessionIdSchema,
|
|
107
|
+
AgentSessionOpenInputSchema,
|
|
108
|
+
AgentSessionResumeInputSchema,
|
|
109
|
+
AgentTurnCompletedPayloadSchema,
|
|
110
|
+
AgentTurnIdSchema,
|
|
111
|
+
AgentTurnInputContentCompositionSchema,
|
|
112
|
+
AgentTurnInputContentSchema,
|
|
113
|
+
AgentTurnInputPartSchema,
|
|
114
|
+
AgentTurnInteractionModeSchema,
|
|
115
|
+
AgentTurnInterruptionInputSchema,
|
|
116
|
+
AgentTurnRunInputSchema,
|
|
117
|
+
AgentWebSearchDetailsSchema
|
|
118
|
+
};
|