@agen-ai/agent-protocol 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +57 -13
  2. package/dist/accountQuota/index.d.ts +3 -0
  3. package/dist/accountQuota/index.js +2 -0
  4. package/dist/accountQuota/parsers.d.ts +7 -0
  5. package/dist/accountQuota/parsers.js +20 -0
  6. package/dist/accountQuota/types.d.ts +89 -0
  7. package/dist/accountQuota/types.js +12 -0
  8. package/dist/capabilities/contentReferenceText.d.ts +13 -0
  9. package/dist/capabilities/contentReferenceText.js +25 -0
  10. package/dist/capabilities/index.d.ts +1 -0
  11. package/dist/capabilities/index.js +1 -0
  12. package/dist/capabilities/types.d.ts +19 -1
  13. package/dist/capabilities/types.js +6 -0
  14. package/dist/commands/index.d.ts +3 -0
  15. package/dist/commands/index.js +2 -0
  16. package/dist/commands/parsers.d.ts +7 -0
  17. package/dist/commands/parsers.js +23 -0
  18. package/dist/commands/types.d.ts +26 -0
  19. package/dist/commands/types.js +10 -0
  20. package/dist/effectiveContent/index.d.ts +3 -0
  21. package/dist/effectiveContent/index.js +2 -0
  22. package/dist/effectiveContent/parsers.d.ts +7 -0
  23. package/dist/effectiveContent/parsers.js +23 -0
  24. package/dist/effectiveContent/types.d.ts +35 -0
  25. package/dist/effectiveContent/types.js +19 -0
  26. package/dist/environment/facts.d.ts +28 -0
  27. package/dist/environment/facts.js +39 -0
  28. package/dist/environment/index.d.ts +4 -0
  29. package/dist/environment/index.js +3 -0
  30. package/dist/environment/parsers.d.ts +17 -0
  31. package/dist/environment/parsers.js +68 -0
  32. package/dist/environment/types.d.ts +61 -0
  33. package/dist/environment/types.js +26 -0
  34. package/dist/events/types.d.ts +1 -1
  35. package/dist/extensions/index.d.ts +3 -0
  36. package/dist/extensions/index.js +2 -0
  37. package/dist/extensions/parsers.d.ts +7 -0
  38. package/dist/extensions/parsers.js +23 -0
  39. package/dist/extensions/types.d.ts +73 -0
  40. package/dist/extensions/types.js +30 -0
  41. package/dist/foundation/parsers.d.ts +9 -1
  42. package/dist/foundation/parsers.js +24 -0
  43. package/dist/foundation/types.d.ts +5 -1
  44. package/dist/foundation/types.js +1 -1
  45. package/dist/integrations/types.d.ts +22 -4
  46. package/dist/integrations/types.js +6 -2
  47. package/dist/jsonSchema/generated.d.ts +9893 -5474
  48. package/dist/jsonSchema/generated.js +3097 -154
  49. package/dist/public/accountQuota.d.ts +2 -0
  50. package/dist/public/accountQuota.js +1 -0
  51. package/dist/public/commands.d.ts +2 -0
  52. package/dist/public/commands.js +1 -0
  53. package/dist/public/effectiveContent.d.ts +2 -0
  54. package/dist/public/effectiveContent.js +1 -0
  55. package/dist/public/environment.d.ts +2 -0
  56. package/dist/public/environment.js +1 -0
  57. package/dist/public/extensions.d.ts +2 -0
  58. package/dist/public/extensions.js +1 -0
  59. package/dist/public/index.d.ts +5 -0
  60. package/dist/public/index.js +5 -0
  61. package/dist/turns/parsers.d.ts +3 -1
  62. package/dist/turns/parsers.js +9 -0
  63. package/dist/turns/types.d.ts +13 -2
  64. package/dist/turns/types.js +4 -0
  65. package/dist/zod/accountQuota.d.ts +265 -0
  66. package/dist/zod/accountQuota.js +155 -0
  67. package/dist/zod/capabilities.d.ts +79 -1
  68. package/dist/zod/capabilities.js +21 -5
  69. package/dist/zod/commands.d.ts +35 -0
  70. package/dist/zod/commands.js +114 -0
  71. package/dist/zod/effectiveContent.d.ts +72 -0
  72. package/dist/zod/effectiveContent.js +157 -0
  73. package/dist/zod/environment.d.ts +531 -0
  74. package/dist/zod/environment.js +336 -0
  75. package/dist/zod/environmentFacts.d.ts +10 -0
  76. package/dist/zod/environmentFacts.js +40 -0
  77. package/dist/zod/events.d.ts +23 -23
  78. package/dist/zod/extensions.d.ts +161 -0
  79. package/dist/zod/extensions.js +194 -0
  80. package/dist/zod/foundation.d.ts +6 -1
  81. package/dist/zod/foundation.js +12 -3
  82. package/dist/zod/index.d.ts +10 -4
  83. package/dist/zod/index.js +22 -2
  84. package/dist/zod/integrations.d.ts +54 -9
  85. package/dist/zod/integrations.js +49 -6
  86. package/dist/zod/resources.d.ts +2 -2
  87. package/dist/zod/turns.d.ts +33 -0
  88. package/dist/zod/turns.js +34 -1
  89. package/dist/zod/typeEquality.generated.d.ts +40 -4
  90. package/package.json +23 -3
@@ -0,0 +1,2 @@
1
+ export * from '../accountQuota/index.js';
2
+ //# sourceMappingURL=accountQuota.d.ts.map
@@ -0,0 +1 @@
1
+ export * from "../accountQuota/index.js";
@@ -0,0 +1,2 @@
1
+ export * from '../commands/index.js';
2
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ export * from "../commands/index.js";
@@ -0,0 +1,2 @@
1
+ export * from '../effectiveContent/index.js';
2
+ //# sourceMappingURL=effectiveContent.d.ts.map
@@ -0,0 +1 @@
1
+ export * from "../effectiveContent/index.js";
@@ -0,0 +1,2 @@
1
+ export * from '../environment/index.js';
2
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ export * from "../environment/index.js";
@@ -0,0 +1,2 @@
1
+ export * from '../extensions/index.js';
2
+ //# sourceMappingURL=extensions.d.ts.map
@@ -0,0 +1 @@
1
+ export * from "../extensions/index.js";
@@ -1,9 +1,14 @@
1
1
  export * from '../foundation/index.js';
2
+ export * from '../accountQuota/index.js';
2
3
  export * from '../sessions/index.js';
3
4
  export * from '../turns/index.js';
4
5
  export * from '../requests/index.js';
5
6
  export * from '../operations/index.js';
6
7
  export * from '../managedContent/index.js';
8
+ export * from '../effectiveContent/index.js';
9
+ export * from '../commands/index.js';
10
+ export * from '../extensions/index.js';
11
+ export * from '../environment/index.js';
7
12
  export * from '../configuration/index.js';
8
13
  export * from '../integrations/index.js';
9
14
  export * from '../collaboration/index.js';
@@ -1,9 +1,14 @@
1
1
  export * from "../foundation/index.js";
2
+ export * from "../accountQuota/index.js";
2
3
  export * from "../sessions/index.js";
3
4
  export * from "../turns/index.js";
4
5
  export * from "../requests/index.js";
5
6
  export * from "../operations/index.js";
6
7
  export * from "../managedContent/index.js";
8
+ export * from "../effectiveContent/index.js";
9
+ export * from "../commands/index.js";
10
+ export * from "../extensions/index.js";
11
+ export * from "../environment/index.js";
7
12
  export * from "../configuration/index.js";
8
13
  export * from "../integrations/index.js";
9
14
  export * from "../collaboration/index.js";
@@ -1,5 +1,5 @@
1
1
  import type { AgentProtocolParseResult } from '../foundation/index.js';
2
- import type { AgentItemSnapshot, AgentTurnInputContent, AgentTurnInterruptionInput, AgentTurnRunInput } from './types.js';
2
+ import type { AgentItemSnapshot, AgentContentReferenceInputPart, AgentTurnInputContent, AgentTurnInterruptionInput, AgentTurnRunInput } from './types.js';
3
3
  export declare function parseAgentTurnInputContent(input: unknown): AgentTurnInputContent;
4
4
  export declare function safeParseAgentTurnInputContent(input: unknown): AgentProtocolParseResult<AgentTurnInputContent>;
5
5
  export declare function parseAgentTurnRunInput(input: unknown): AgentTurnRunInput;
@@ -8,4 +8,6 @@ export declare function parseAgentTurnInterruptionInput(input: unknown): AgentTu
8
8
  export declare function safeParseAgentTurnInterruptionInput(input: unknown): AgentProtocolParseResult<AgentTurnInterruptionInput>;
9
9
  export declare function parseAgentItemSnapshot(input: unknown): AgentItemSnapshot;
10
10
  export declare function safeParseAgentItemSnapshot(input: unknown): AgentProtocolParseResult<AgentItemSnapshot>;
11
+ export declare function parseAgentContentReferenceInputPart(input: unknown): AgentContentReferenceInputPart;
12
+ export declare function safeParseAgentContentReferenceInputPart(input: unknown): AgentProtocolParseResult<AgentContentReferenceInputPart>;
11
13
  //# sourceMappingURL=parsers.d.ts.map
@@ -1,6 +1,7 @@
1
1
  import { parseWithSchema, safeParseWithSchema } from "../internal/parsers.js";
2
2
  import {
3
3
  AgentItemSnapshotSchema,
4
+ AgentContentReferenceInputPartSchema,
4
5
  AgentTurnInputContentSchema,
5
6
  AgentTurnInterruptionInputSchema,
6
7
  AgentTurnRunInputSchema
@@ -29,11 +30,19 @@ function parseAgentItemSnapshot(input) {
29
30
  function safeParseAgentItemSnapshot(input) {
30
31
  return safeParseWithSchema(AgentItemSnapshotSchema, input);
31
32
  }
33
+ function parseAgentContentReferenceInputPart(input) {
34
+ return parseWithSchema(AgentContentReferenceInputPartSchema, input);
35
+ }
36
+ function safeParseAgentContentReferenceInputPart(input) {
37
+ return safeParseWithSchema(AgentContentReferenceInputPartSchema, input);
38
+ }
32
39
  export {
40
+ parseAgentContentReferenceInputPart,
33
41
  parseAgentItemSnapshot,
34
42
  parseAgentTurnInputContent,
35
43
  parseAgentTurnInterruptionInput,
36
44
  parseAgentTurnRunInput,
45
+ safeParseAgentContentReferenceInputPart,
37
46
  safeParseAgentItemSnapshot,
38
47
  safeParseAgentTurnInputContent,
39
48
  safeParseAgentTurnInterruptionInput,
@@ -1,4 +1,4 @@
1
- import type { AgentError, AgentIsoDateTime, AgentItemId, AgentTurnId } from '../foundation/index.js';
1
+ import type { AgentError, AgentEnvironmentId, AgentEffectiveContentId, AgentIsoDateTime, AgentItemId, AgentTurnId } from '../foundation/index.js';
2
2
  export interface AgentTextInputPart {
3
3
  readonly type: 'text';
4
4
  readonly text: string;
@@ -28,7 +28,18 @@ export interface AgentImageInputPart {
28
28
  readonly type: 'image';
29
29
  readonly source: AgentImageInputSource;
30
30
  }
31
- export type AgentTurnInputPart = AgentTextInputPart | AgentImageInputPart;
31
+ export declare const AGENT_CONTENT_REFERENCES_MAX_LENGTH = 16;
32
+ export declare const AGENT_CONTENT_REFERENCE_ARGUMENT_BYTES_LIMIT = 4096;
33
+ export interface AgentContentReferenceInputPart {
34
+ readonly type: 'content_reference';
35
+ readonly environmentId: AgentEnvironmentId;
36
+ readonly environmentRevision: number;
37
+ readonly contentCatalogRevision: number;
38
+ readonly contentId: AgentEffectiveContentId;
39
+ readonly contentRevision: number;
40
+ readonly arguments?: string | undefined;
41
+ }
42
+ export type AgentTurnInputPart = AgentTextInputPart | AgentImageInputPart | AgentContentReferenceInputPart;
32
43
  export declare const AGENT_TURN_INTERACTION_MODES: readonly ["default", "plan"];
33
44
  export type AgentTurnInteractionMode = (typeof AGENT_TURN_INTERACTION_MODES)[number];
34
45
  export interface AgentTurnInputContent {
@@ -8,6 +8,8 @@ const AGENT_IMAGE_INPUT_SOURCE_KINDS = [
8
8
  "base64",
9
9
  "local_file"
10
10
  ];
11
+ const AGENT_CONTENT_REFERENCES_MAX_LENGTH = 16;
12
+ const AGENT_CONTENT_REFERENCE_ARGUMENT_BYTES_LIMIT = 4096;
11
13
  const AGENT_TURN_INTERACTION_MODES = ["default", "plan"];
12
14
  const AGENT_ITEM_KINDS = [
13
15
  "user_message",
@@ -79,6 +81,8 @@ const AGENT_FILE_CHANGE_KINDS = [
79
81
  "unknown"
80
82
  ];
81
83
  export {
84
+ AGENT_CONTENT_REFERENCES_MAX_LENGTH,
85
+ AGENT_CONTENT_REFERENCE_ARGUMENT_BYTES_LIMIT,
82
86
  AGENT_CONTENT_STREAM_KINDS,
83
87
  AGENT_CONTEXT_COMPACTION_DURATION_MAX_MILLISECONDS,
84
88
  AGENT_CONTEXT_COMPACTION_STATES,
@@ -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
+ };