@agen-ai/agent-protocol 0.2.4 → 0.2.5

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.
@@ -0,0 +1,265 @@
1
+ import { z } from 'zod/v4';
2
+ import { type AgentAccountQuotaSnapshot, type AgentAccountQuotaWindow } from '../accountQuota/types.js';
3
+ export declare const AgentAccountQuotaApplicabilitySchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
4
+ kind: z.ZodLiteral<"account">;
5
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
6
+ kind: z.ZodLiteral<"product">;
7
+ productId: z.ZodString;
8
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
9
+ kind: z.ZodLiteral<"models">;
10
+ modelIds: z.ZodReadonly<z.ZodArray<z.ZodString>>;
11
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
12
+ kind: z.ZodLiteral<"unknown">;
13
+ }, z.core.$strict>>], "kind">;
14
+ export declare const AgentAccountQuotaPeriodSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
15
+ kind: z.ZodLiteral<"rolling">;
16
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
17
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
18
+ kind: z.ZodLiteral<"fixed">;
19
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
20
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
21
+ kind: z.ZodLiteral<"unknown">;
22
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
23
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
24
+ kind: z.ZodLiteral<"calendar">;
25
+ unit: z.ZodEnum<{
26
+ day: "day";
27
+ week: "week";
28
+ month: "month";
29
+ year: "year";
30
+ }>;
31
+ timeZone: z.ZodString;
32
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
33
+ kind: z.ZodLiteral<"billing_cycle">;
34
+ unit: z.ZodEnum<{
35
+ unknown: "unknown";
36
+ month: "month";
37
+ year: "year";
38
+ }>;
39
+ }, z.core.$strict>>], "kind">;
40
+ export declare const AgentAccountQuotaMeasurementSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
41
+ kind: z.ZodLiteral<"unknown">;
42
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
43
+ kind: z.ZodLiteral<"percentage">;
44
+ usedPercent: z.ZodNumber;
45
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
46
+ kind: z.ZodLiteral<"quantity">;
47
+ unit: z.ZodString;
48
+ used: z.ZodOptional<z.ZodNumber>;
49
+ limit: z.ZodOptional<z.ZodNumber>;
50
+ remaining: z.ZodOptional<z.ZodNumber>;
51
+ usedPercent: z.ZodOptional<z.ZodNumber>;
52
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
53
+ kind: z.ZodLiteral<"money">;
54
+ currency: z.ZodString;
55
+ scale: z.ZodNumber;
56
+ usedMinorUnits: z.ZodOptional<z.ZodNumber>;
57
+ limitMinorUnits: z.ZodOptional<z.ZodNumber>;
58
+ remainingMinorUnits: z.ZodOptional<z.ZodNumber>;
59
+ usedPercent: z.ZodOptional<z.ZodNumber>;
60
+ }, z.core.$strict>>], "kind">;
61
+ export declare const AgentAccountQuotaWindowPortableSchema: z.ZodReadonly<z.ZodObject<{
62
+ poolId: z.ZodString;
63
+ windowId: z.ZodString;
64
+ label: z.ZodString;
65
+ allowanceKind: z.ZodEnum<{
66
+ unknown: "unknown";
67
+ included: "included";
68
+ extra: "extra";
69
+ reserve: "reserve";
70
+ }>;
71
+ applicability: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
72
+ kind: z.ZodLiteral<"account">;
73
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
74
+ kind: z.ZodLiteral<"product">;
75
+ productId: z.ZodString;
76
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
77
+ kind: z.ZodLiteral<"models">;
78
+ modelIds: z.ZodReadonly<z.ZodArray<z.ZodString>>;
79
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
80
+ kind: z.ZodLiteral<"unknown">;
81
+ }, z.core.$strict>>], "kind">;
82
+ period: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
83
+ kind: z.ZodLiteral<"rolling">;
84
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
85
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
86
+ kind: z.ZodLiteral<"fixed">;
87
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
88
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
89
+ kind: z.ZodLiteral<"unknown">;
90
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
91
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
92
+ kind: z.ZodLiteral<"calendar">;
93
+ unit: z.ZodEnum<{
94
+ day: "day";
95
+ week: "week";
96
+ month: "month";
97
+ year: "year";
98
+ }>;
99
+ timeZone: z.ZodString;
100
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
101
+ kind: z.ZodLiteral<"billing_cycle">;
102
+ unit: z.ZodEnum<{
103
+ unknown: "unknown";
104
+ month: "month";
105
+ year: "year";
106
+ }>;
107
+ }, z.core.$strict>>], "kind">;
108
+ measurement: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
109
+ kind: z.ZodLiteral<"unknown">;
110
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
111
+ kind: z.ZodLiteral<"percentage">;
112
+ usedPercent: z.ZodNumber;
113
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
114
+ kind: z.ZodLiteral<"quantity">;
115
+ unit: z.ZodString;
116
+ used: z.ZodOptional<z.ZodNumber>;
117
+ limit: z.ZodOptional<z.ZodNumber>;
118
+ remaining: z.ZodOptional<z.ZodNumber>;
119
+ usedPercent: z.ZodOptional<z.ZodNumber>;
120
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
121
+ kind: z.ZodLiteral<"money">;
122
+ currency: z.ZodString;
123
+ scale: z.ZodNumber;
124
+ usedMinorUnits: z.ZodOptional<z.ZodNumber>;
125
+ limitMinorUnits: z.ZodOptional<z.ZodNumber>;
126
+ remainingMinorUnits: z.ZodOptional<z.ZodNumber>;
127
+ usedPercent: z.ZodOptional<z.ZodNumber>;
128
+ }, z.core.$strict>>], "kind">;
129
+ observedAt: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
130
+ startsAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
131
+ reset: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
132
+ at: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
133
+ precision: z.ZodEnum<{
134
+ reported: "reported";
135
+ estimated: "estimated";
136
+ }>;
137
+ observedAt: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
138
+ }, z.core.$strict>>>;
139
+ }, z.core.$strict>>;
140
+ export declare const AgentAccountQuotaWindowSchema: z.ZodType<AgentAccountQuotaWindow>;
141
+ export declare const AgentAccountQuotaSnapshotPortableSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
142
+ state: z.ZodLiteral<"available">;
143
+ completeness: z.ZodEnum<{
144
+ complete: "complete";
145
+ partial: "partial";
146
+ }>;
147
+ accountLabel: z.ZodOptional<z.ZodString>;
148
+ planLabel: z.ZodOptional<z.ZodString>;
149
+ windows: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
150
+ poolId: z.ZodString;
151
+ windowId: z.ZodString;
152
+ label: z.ZodString;
153
+ allowanceKind: z.ZodEnum<{
154
+ unknown: "unknown";
155
+ included: "included";
156
+ extra: "extra";
157
+ reserve: "reserve";
158
+ }>;
159
+ applicability: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
160
+ kind: z.ZodLiteral<"account">;
161
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
162
+ kind: z.ZodLiteral<"product">;
163
+ productId: z.ZodString;
164
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
165
+ kind: z.ZodLiteral<"models">;
166
+ modelIds: z.ZodReadonly<z.ZodArray<z.ZodString>>;
167
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
168
+ kind: z.ZodLiteral<"unknown">;
169
+ }, z.core.$strict>>], "kind">;
170
+ period: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
171
+ kind: z.ZodLiteral<"rolling">;
172
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
173
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
174
+ kind: z.ZodLiteral<"fixed">;
175
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
176
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
177
+ kind: z.ZodLiteral<"unknown">;
178
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
179
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
180
+ kind: z.ZodLiteral<"calendar">;
181
+ unit: z.ZodEnum<{
182
+ day: "day";
183
+ week: "week";
184
+ month: "month";
185
+ year: "year";
186
+ }>;
187
+ timeZone: z.ZodString;
188
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
189
+ kind: z.ZodLiteral<"billing_cycle">;
190
+ unit: z.ZodEnum<{
191
+ unknown: "unknown";
192
+ month: "month";
193
+ year: "year";
194
+ }>;
195
+ }, z.core.$strict>>], "kind">;
196
+ measurement: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
197
+ kind: z.ZodLiteral<"unknown">;
198
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
199
+ kind: z.ZodLiteral<"percentage">;
200
+ usedPercent: z.ZodNumber;
201
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
202
+ kind: z.ZodLiteral<"quantity">;
203
+ unit: z.ZodString;
204
+ used: z.ZodOptional<z.ZodNumber>;
205
+ limit: z.ZodOptional<z.ZodNumber>;
206
+ remaining: z.ZodOptional<z.ZodNumber>;
207
+ usedPercent: z.ZodOptional<z.ZodNumber>;
208
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
209
+ kind: z.ZodLiteral<"money">;
210
+ currency: z.ZodString;
211
+ scale: z.ZodNumber;
212
+ usedMinorUnits: z.ZodOptional<z.ZodNumber>;
213
+ limitMinorUnits: z.ZodOptional<z.ZodNumber>;
214
+ remainingMinorUnits: z.ZodOptional<z.ZodNumber>;
215
+ usedPercent: z.ZodOptional<z.ZodNumber>;
216
+ }, z.core.$strict>>], "kind">;
217
+ observedAt: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
218
+ startsAt: z.ZodOptional<z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>>;
219
+ reset: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
220
+ at: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
221
+ precision: z.ZodEnum<{
222
+ reported: "reported";
223
+ estimated: "estimated";
224
+ }>;
225
+ observedAt: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
226
+ }, z.core.$strict>>>;
227
+ }, z.core.$strict>>>>;
228
+ allowance: z.ZodReadonly<z.ZodObject<{
229
+ included: z.ZodEnum<{
230
+ unknown: "unknown";
231
+ allowed: "allowed";
232
+ exhausted: "exhausted";
233
+ }>;
234
+ extra: z.ZodEnum<{
235
+ unknown: "unknown";
236
+ allowed: "allowed";
237
+ unavailable: "unavailable";
238
+ }>;
239
+ reserve: z.ZodEnum<{
240
+ unknown: "unknown";
241
+ allowed: "allowed";
242
+ unavailable: "unavailable";
243
+ }>;
244
+ }, z.core.$strict>>;
245
+ schemaVersion: z.ZodLiteral<1>;
246
+ sourceId: z.ZodString;
247
+ observedAt: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
248
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
249
+ state: z.ZodLiteral<"authentication_required">;
250
+ schemaVersion: z.ZodLiteral<1>;
251
+ sourceId: z.ZodString;
252
+ observedAt: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
253
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
254
+ state: z.ZodLiteral<"inapplicable">;
255
+ schemaVersion: z.ZodLiteral<1>;
256
+ sourceId: z.ZodString;
257
+ observedAt: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
258
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
259
+ state: z.ZodLiteral<"temporarily_unavailable">;
260
+ schemaVersion: z.ZodLiteral<1>;
261
+ sourceId: z.ZodString;
262
+ observedAt: z.ZodType<import("../index.js").AgentIsoDateTime, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIsoDateTime, unknown>>;
263
+ }, z.core.$strict>>], "state">;
264
+ export declare const AgentAccountQuotaSnapshotSchema: z.ZodType<AgentAccountQuotaSnapshot>;
265
+ //# sourceMappingURL=accountQuota.d.ts.map
@@ -0,0 +1,155 @@
1
+ import { z } from "zod/v4";
2
+ import {
3
+ AGENT_ACCOUNT_QUOTA_MAX_BYTES,
4
+ AGENT_ACCOUNT_QUOTA_MAX_LABEL_LENGTH,
5
+ AGENT_ACCOUNT_QUOTA_MAX_SCOPE_IDS,
6
+ AGENT_ACCOUNT_QUOTA_MAX_WINDOWS,
7
+ AGENT_ACCOUNT_QUOTA_SCHEMA_VERSION
8
+ } from "../accountQuota/types.js";
9
+ import { agentProtocolSerializedJsonBytes } from "../foundation/types.js";
10
+ import {
11
+ AgentCanonicalIdValueSchema,
12
+ AgentIsoDateTimeSchema,
13
+ createAgentCanonicalOpaqueStringSchema,
14
+ withAcyclicProtocolInput
15
+ } from "./foundation.js";
16
+ const LabelSchema = createAgentCanonicalOpaqueStringSchema(
17
+ AGENT_ACCOUNT_QUOTA_MAX_LABEL_LENGTH,
18
+ "Quota labels must be canonical and contain no control characters."
19
+ );
20
+ const NonnegativeQuantitySchema = z.number().finite().min(0).max(Number.MAX_SAFE_INTEGER);
21
+ const MinorUnitsSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
22
+ const DurationSchema = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
23
+ const AgentAccountQuotaApplicabilitySchema = z.discriminatedUnion("kind", [
24
+ z.object({ kind: z.literal("account") }).strict().readonly(),
25
+ z.object({ kind: z.literal("product"), productId: AgentCanonicalIdValueSchema }).strict().readonly(),
26
+ z.object({
27
+ kind: z.literal("models"),
28
+ modelIds: z.array(AgentCanonicalIdValueSchema).min(1).max(AGENT_ACCOUNT_QUOTA_MAX_SCOPE_IDS).readonly()
29
+ }).strict().readonly(),
30
+ z.object({ kind: z.literal("unknown") }).strict().readonly()
31
+ ]);
32
+ const AgentAccountQuotaPeriodSchema = z.discriminatedUnion("kind", [
33
+ z.object({ kind: z.literal("rolling"), durationSeconds: DurationSchema.optional() }).strict().readonly(),
34
+ z.object({ kind: z.literal("fixed"), durationSeconds: DurationSchema.optional() }).strict().readonly(),
35
+ z.object({ kind: z.literal("unknown"), durationSeconds: DurationSchema.optional() }).strict().readonly(),
36
+ z.object({
37
+ kind: z.literal("calendar"),
38
+ unit: z.enum(["day", "week", "month", "year"]),
39
+ timeZone: LabelSchema
40
+ }).strict().readonly(),
41
+ z.object({ kind: z.literal("billing_cycle"), unit: z.enum(["month", "year", "unknown"]) }).strict().readonly()
42
+ ]);
43
+ const AgentAccountQuotaMeasurementSchema = z.discriminatedUnion("kind", [
44
+ z.object({ kind: z.literal("unknown") }).strict().readonly(),
45
+ z.object({ kind: z.literal("percentage"), usedPercent: NonnegativeQuantitySchema }).strict().readonly(),
46
+ z.object({
47
+ kind: z.literal("quantity"),
48
+ unit: LabelSchema,
49
+ used: NonnegativeQuantitySchema.optional(),
50
+ limit: NonnegativeQuantitySchema.optional(),
51
+ remaining: NonnegativeQuantitySchema.optional(),
52
+ usedPercent: NonnegativeQuantitySchema.optional()
53
+ }).strict().readonly(),
54
+ z.object({
55
+ kind: z.literal("money"),
56
+ currency: z.string().regex(/^[A-Z]{3}$/u),
57
+ scale: z.number().int().min(0).max(9),
58
+ usedMinorUnits: MinorUnitsSchema.optional(),
59
+ limitMinorUnits: MinorUnitsSchema.optional(),
60
+ remainingMinorUnits: MinorUnitsSchema.optional(),
61
+ usedPercent: NonnegativeQuantitySchema.optional()
62
+ }).strict().readonly()
63
+ ]);
64
+ const AgentAccountQuotaWindowPortableSchema = z.object({
65
+ poolId: AgentCanonicalIdValueSchema,
66
+ windowId: AgentCanonicalIdValueSchema,
67
+ label: LabelSchema,
68
+ allowanceKind: z.enum(["included", "extra", "reserve", "unknown"]),
69
+ applicability: AgentAccountQuotaApplicabilitySchema,
70
+ period: AgentAccountQuotaPeriodSchema,
71
+ measurement: AgentAccountQuotaMeasurementSchema,
72
+ observedAt: AgentIsoDateTimeSchema,
73
+ startsAt: AgentIsoDateTimeSchema.optional(),
74
+ reset: z.object({
75
+ at: AgentIsoDateTimeSchema,
76
+ precision: z.enum(["reported", "estimated"]),
77
+ observedAt: AgentIsoDateTimeSchema
78
+ }).strict().readonly().optional()
79
+ }).strict().readonly();
80
+ function validateWindow(window, context, prefix = []) {
81
+ if (window.applicability.kind === "models" && new Set(window.applicability.modelIds).size !== window.applicability.modelIds.length) {
82
+ context.addIssue({ code: "custom", path: [...prefix, "applicability", "modelIds"], message: "Model applicability IDs must be unique." });
83
+ }
84
+ const measurement = window.measurement;
85
+ if (measurement.kind === "quantity" && measurement.used === void 0 && measurement.limit === void 0 && measurement.remaining === void 0) {
86
+ context.addIssue({ code: "custom", path: [...prefix, "measurement"], message: "A quantity measurement requires a reported quantity." });
87
+ }
88
+ if (measurement.kind === "money" && measurement.usedMinorUnits === void 0 && measurement.limitMinorUnits === void 0 && measurement.remainingMinorUnits === void 0) {
89
+ context.addIssue({ code: "custom", path: [...prefix, "measurement"], message: "A money measurement requires a reported exact amount." });
90
+ }
91
+ if (window.startsAt && window.reset && Date.parse(window.startsAt) >= Date.parse(window.reset.at)) {
92
+ context.addIssue({ code: "custom", path: [...prefix, "reset", "at"], message: "A period reset must follow its start." });
93
+ }
94
+ if (window.reset && Date.parse(window.reset.observedAt) > Date.parse(window.observedAt)) {
95
+ context.addIssue({ code: "custom", path: [...prefix, "reset", "observedAt"], message: "Reset evidence cannot be newer than the window observation." });
96
+ }
97
+ }
98
+ const AgentAccountQuotaWindowSchema = withAcyclicProtocolInput(AgentAccountQuotaWindowPortableSchema, {
99
+ maxDepth: 6,
100
+ maxCollectionLength: AGENT_ACCOUNT_QUOTA_MAX_SCOPE_IDS
101
+ }).superRefine(validateWindow);
102
+ const snapshotBase = {
103
+ schemaVersion: z.literal(AGENT_ACCOUNT_QUOTA_SCHEMA_VERSION),
104
+ sourceId: AgentCanonicalIdValueSchema,
105
+ observedAt: AgentIsoDateTimeSchema
106
+ };
107
+ const AgentAccountQuotaSnapshotPortableSchema = z.discriminatedUnion("state", [
108
+ z.object({
109
+ ...snapshotBase,
110
+ state: z.literal("available"),
111
+ completeness: z.enum(["complete", "partial"]),
112
+ accountLabel: LabelSchema.optional(),
113
+ planLabel: LabelSchema.optional(),
114
+ windows: z.array(AgentAccountQuotaWindowPortableSchema).max(AGENT_ACCOUNT_QUOTA_MAX_WINDOWS).readonly(),
115
+ allowance: z.object({
116
+ included: z.enum(["allowed", "exhausted", "unknown"]),
117
+ extra: z.enum(["allowed", "unavailable", "unknown"]),
118
+ reserve: z.enum(["allowed", "unavailable", "unknown"])
119
+ }).strict().readonly()
120
+ }).strict().readonly(),
121
+ z.object({ ...snapshotBase, state: z.literal("authentication_required") }).strict().readonly(),
122
+ z.object({ ...snapshotBase, state: z.literal("inapplicable") }).strict().readonly(),
123
+ z.object({ ...snapshotBase, state: z.literal("temporarily_unavailable") }).strict().readonly()
124
+ ]);
125
+ const AgentAccountQuotaSnapshotSchema = withAcyclicProtocolInput(AgentAccountQuotaSnapshotPortableSchema, {
126
+ maxDepth: 8,
127
+ maxCollectionLength: AGENT_ACCOUNT_QUOTA_MAX_WINDOWS
128
+ }).superRefine((snapshot, context) => {
129
+ if (agentProtocolSerializedJsonBytes(snapshot) > AGENT_ACCOUNT_QUOTA_MAX_BYTES) {
130
+ context.addIssue({ code: "custom", message: "Account quota snapshot exceeds its serialized byte limit." });
131
+ }
132
+ if (snapshot.state !== "available") return;
133
+ const identities = /* @__PURE__ */ new Map();
134
+ snapshot.windows.forEach((window, index) => {
135
+ const windows = identities.get(window.poolId) ?? /* @__PURE__ */ new Set();
136
+ if (windows.has(window.windowId)) {
137
+ context.addIssue({ code: "custom", path: ["windows", index, "windowId"], message: "Window IDs must be unique within each pool." });
138
+ }
139
+ windows.add(window.windowId);
140
+ identities.set(window.poolId, windows);
141
+ validateWindow(window, context, ["windows", index]);
142
+ if (Date.parse(window.observedAt) > Date.parse(snapshot.observedAt)) {
143
+ context.addIssue({ code: "custom", path: ["windows", index, "observedAt"], message: "Window evidence cannot be newer than its snapshot." });
144
+ }
145
+ });
146
+ });
147
+ export {
148
+ AgentAccountQuotaApplicabilitySchema,
149
+ AgentAccountQuotaMeasurementSchema,
150
+ AgentAccountQuotaPeriodSchema,
151
+ AgentAccountQuotaSnapshotPortableSchema,
152
+ AgentAccountQuotaSnapshotSchema,
153
+ AgentAccountQuotaWindowPortableSchema,
154
+ AgentAccountQuotaWindowSchema
155
+ };
@@ -531,10 +531,10 @@ export declare const AgentEventPortableSchema: z.ZodDiscriminatedUnion<[z.ZodRea
531
531
  archive: "archive";
532
532
  }>;
533
533
  status: z.ZodEnum<{
534
+ unavailable: "unavailable";
535
+ available: "available";
534
536
  pending: "pending";
535
537
  expired: "expired";
536
- available: "available";
537
- unavailable: "unavailable";
538
538
  }>;
539
539
  displayName: z.ZodString;
540
540
  producer: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
2
  import { type AgentArtifactId, type AgentApprovalOptionId, type AgentCollaborationId, type AgentConfigurationRevisionId, type AgentError, type AgentInstanceId, type AgentIntegrationId, type AgentIntegrationResourceId, type AgentIntegrationServerId, type AgentIntegrationToolId, type AgentIsoDateTime, type AgentItemId, type AgentJsonValue, type AgentManagedContentId, type AgentOperationId, type AgentOperationInvocationId, type AgentProviderConversationId, type AgentProviderHistoryAnchor, type AgentProviderItemRef, type AgentProviderKey, type AgentProviderRefs, type AgentProviderRequestRef, type AgentProviderTurnRef, type AgentRequestFieldId, type AgentRequestId, type AgentSessionId, type AgentGeneratedResourceId, type AgentTurnId } from '../foundation/types.js';
3
+ export declare function createAgentCanonicalOpaqueStringSchema(maxLength: number, message: string): z.ZodString;
3
4
  export declare const AgentCanonicalIdValueSchema: z.ZodString;
4
5
  export declare function createAgentCanonicalNonBlankStringSchema(maxLength: number): z.ZodString;
5
6
  export declare const AgentCanonicalNonBlankTextSchema: z.ZodString;
@@ -13,10 +13,10 @@ import {
13
13
  } from "../foundation/types.js";
14
14
  const CANONICAL_OPAQUE_STRING_PATTERN = /^(?![\s\S]*[\u0000-\u001F\u007F-\u009F])\S(?:[\s\S]*\S)?$/u;
15
15
  const CANONICAL_NON_BLANK_STRING_PATTERN = /^(?:\S|\S[\s\S]*\S)$/u;
16
- function canonicalOpaqueStringSchema(maxLength, message) {
16
+ function createAgentCanonicalOpaqueStringSchema(maxLength, message) {
17
17
  return z.string().min(1).max(maxLength).regex(CANONICAL_OPAQUE_STRING_PATTERN, message);
18
18
  }
19
- const AgentCanonicalIdValueSchema = canonicalOpaqueStringSchema(
19
+ const AgentCanonicalIdValueSchema = createAgentCanonicalOpaqueStringSchema(
20
20
  AGENT_PROTOCOL_ID_MAX_LENGTH,
21
21
  "Opaque IDs must be canonical and contain no control or surrounding whitespace."
22
22
  );
@@ -28,7 +28,7 @@ function createAgentCanonicalNonBlankStringSchema(maxLength) {
28
28
  }
29
29
  const AgentCanonicalNonBlankTextSchema = createAgentCanonicalNonBlankStringSchema(AGENT_PROTOCOL_TEXT_MAX_LENGTH);
30
30
  const AgentCanonicalCodeSchema = createAgentCanonicalNonBlankStringSchema(AGENT_PROTOCOL_CODE_MAX_LENGTH);
31
- const ProviderReferenceSchema = canonicalOpaqueStringSchema(
31
+ const ProviderReferenceSchema = createAgentCanonicalOpaqueStringSchema(
32
32
  AGENT_PROTOCOL_PROVIDER_REFERENCE_MAX_LENGTH,
33
33
  "Provider references must be canonical and contain no control or surrounding whitespace."
34
34
  );
@@ -221,5 +221,6 @@ export {
221
221
  AgentSessionIdSchema,
222
222
  AgentTurnIdSchema,
223
223
  createAgentCanonicalNonBlankStringSchema,
224
+ createAgentCanonicalOpaqueStringSchema,
224
225
  withAcyclicProtocolInput
225
226
  };
@@ -12,4 +12,5 @@ export { AgentApprovalCapabilitySchema, AgentCapabilitiesSchema, } from './capab
12
12
  export { AgentArtifactDescriptorSchema } from './artifacts.js';
13
13
  export { AgentContextUsageSchema, AgentEventSchema } from './events.js';
14
14
  export type { AgentProtocolSchemaTypeAssertions } from './typeEquality.generated.js';
15
+ export * from './accountQuota.js';
15
16
  //# sourceMappingURL=index.d.ts.map
package/dist/zod/index.js CHANGED
@@ -103,6 +103,7 @@ import {
103
103
  } from "./capabilities.js";
104
104
  import { AgentArtifactDescriptorSchema } from "./artifacts.js";
105
105
  import { AgentContextUsageSchema, AgentEventSchema } from "./events.js";
106
+ export * from "./accountQuota.js";
106
107
  export {
107
108
  AgentApprovalCapabilitySchema,
108
109
  AgentApprovalOptionIdSchema,
@@ -6,19 +6,19 @@ declare const AgentIntegrationDescriptorPortableSchema: z.ZodReadonly<z.ZodObjec
6
6
  kind: z.ZodLiteral<"mcp">;
7
7
  name: z.ZodString;
8
8
  status: z.ZodEnum<{
9
+ unavailable: "unavailable";
9
10
  starting: "starting";
10
11
  ready: "ready";
11
12
  degraded: "degraded";
12
- unavailable: "unavailable";
13
13
  }>;
14
14
  servers: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
15
15
  serverId: z.ZodType<import("../index.js").AgentIntegrationServerId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIntegrationServerId, unknown>>;
16
16
  name: z.ZodString;
17
17
  status: z.ZodEnum<{
18
+ unavailable: "unavailable";
18
19
  starting: "starting";
19
20
  ready: "ready";
20
21
  degraded: "degraded";
21
- unavailable: "unavailable";
22
22
  }>;
23
23
  tools: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
24
24
  toolId: z.ZodType<import("../index.js").AgentIntegrationToolId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIntegrationToolId, unknown>>;
@@ -43,19 +43,19 @@ export declare const AgentIntegrationCatalogPortableSchema: z.ZodReadonly<z.ZodO
43
43
  kind: z.ZodLiteral<"mcp">;
44
44
  name: z.ZodString;
45
45
  status: z.ZodEnum<{
46
+ unavailable: "unavailable";
46
47
  starting: "starting";
47
48
  ready: "ready";
48
49
  degraded: "degraded";
49
- unavailable: "unavailable";
50
50
  }>;
51
51
  servers: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
52
52
  serverId: z.ZodType<import("../index.js").AgentIntegrationServerId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIntegrationServerId, unknown>>;
53
53
  name: z.ZodString;
54
54
  status: z.ZodEnum<{
55
+ unavailable: "unavailable";
55
56
  starting: "starting";
56
57
  ready: "ready";
57
58
  degraded: "degraded";
58
- unavailable: "unavailable";
59
59
  }>;
60
60
  tools: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
61
61
  toolId: z.ZodType<import("../index.js").AgentIntegrationToolId, unknown, z.core.$ZodTypeInternals<import("../index.js").AgentIntegrationToolId, unknown>>;
@@ -8,10 +8,10 @@ export declare const AgentGeneratedResourceDescriptorPortableSchema: z.ZodReadon
8
8
  archive: "archive";
9
9
  }>;
10
10
  status: z.ZodEnum<{
11
+ unavailable: "unavailable";
12
+ available: "available";
11
13
  pending: "pending";
12
14
  expired: "expired";
13
- available: "available";
14
- unavailable: "unavailable";
15
15
  }>;
16
16
  displayName: z.ZodString;
17
17
  producer: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
@@ -1,4 +1,5 @@
1
1
  import type { z } from 'zod/v4';
2
+ import type { AgentAccountQuotaSnapshot, AgentAccountQuotaWindow } from '../accountQuota/types.js';
2
3
  import type { AgentArtifactDescriptor } from '../artifacts/types.js';
3
4
  import type { AgentCapabilities } from '../capabilities/types.js';
4
5
  import type { AgentCollaborationControlInput, AgentCollaborationNode, AgentCollaborationSpawnInput } from '../collaboration/types.js';
@@ -12,6 +13,7 @@ import type { AgentRequest, AgentRequestResolution } from '../requests/types.js'
12
13
  import type { AgentGeneratedResourceDescriptor } from '../resources/types.js';
13
14
  import type { AgentSessionBinding, AgentSessionConfiguration, AgentSessionOpenInput } from '../sessions/types.js';
14
15
  import type { AgentItemSnapshot, AgentTurnInputContent, AgentTurnInterruptionInput, AgentTurnRunInput } from '../turns/types.js';
16
+ import { AgentAccountQuotaSnapshotSchema, AgentAccountQuotaWindowSchema } from './accountQuota.js';
15
17
  import { AgentArtifactDescriptorSchema } from './artifacts.js';
16
18
  import { AgentCapabilitiesSchema } from './capabilities.js';
17
19
  import { AgentCollaborationControlInputSchema, AgentCollaborationNodeSchema, AgentCollaborationSpawnInputSchema } from './collaboration.js';
@@ -28,6 +30,10 @@ import { AgentItemSnapshotSchema, AgentTurnInputContentSchema, AgentTurnInterrup
28
30
  type Extends<Left, Right> = [Left] extends [Right] ? true : false;
29
31
  type Assert<Value extends true> = Value;
30
32
  export type AgentProtocolSchemaTypeAssertions = readonly [
33
+ Assert<Extends<z.output<typeof AgentAccountQuotaSnapshotSchema>, AgentAccountQuotaSnapshot>>,
34
+ Assert<Extends<AgentAccountQuotaSnapshot, z.output<typeof AgentAccountQuotaSnapshotSchema>>>,
35
+ Assert<Extends<z.output<typeof AgentAccountQuotaWindowSchema>, AgentAccountQuotaWindow>>,
36
+ Assert<Extends<AgentAccountQuotaWindow, z.output<typeof AgentAccountQuotaWindowSchema>>>,
31
37
  Assert<Extends<z.output<typeof AgentJsonValueSchema>, AgentJsonValue>>,
32
38
  Assert<Extends<AgentJsonValue, z.output<typeof AgentJsonValueSchema>>>,
33
39
  Assert<Extends<z.output<typeof AgentProviderRefsSchema>, AgentProviderRefs>>,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agen-ai/agent-protocol",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "private": false,
5
5
  "description": "Provider-neutral sessions, turns, requests, capabilities, artifacts, and events for coding-agent runtimes.",
6
6
  "type": "module",
@@ -76,11 +76,15 @@
76
76
  "types": "./dist/jsonSchema/index.d.ts",
77
77
  "import": "./dist/jsonSchema/index.js"
78
78
  },
79
- "./package.json": "./package.json"
79
+ "./package.json": "./package.json",
80
+ "./account-quota": {
81
+ "types": "./dist/public/accountQuota.d.ts",
82
+ "import": "./dist/public/accountQuota.js"
83
+ }
80
84
  },
81
85
  "dependencies": {
82
86
  "zod": "4.4.3",
83
- "@agen-ai/validation": "^0.2.4"
87
+ "@agen-ai/validation": "^0.2.5"
84
88
  },
85
89
  "devDependencies": {
86
90
  "ajv": "8.17.1",