sidekick-shared 0.19.0 → 0.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -2
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +46 -3
- package/dist/modelContext.d.ts +3 -0
- package/dist/modelContext.js +5 -1
- package/dist/modelInfo.d.ts +8 -0
- package/dist/modelInfo.js +29 -16
- package/dist/schemas/accountStatus.d.ts +30 -0
- package/dist/schemas/accountStatus.js +27 -0
- package/dist/schemas/assistantTurn.d.ts +123 -0
- package/dist/schemas/assistantTurn.js +67 -0
- package/dist/schemas/index.d.ts +25 -0
- package/dist/schemas/index.js +52 -0
- package/dist/schemas/quota.d.ts +499 -0
- package/dist/schemas/quota.js +109 -0
- package/dist/schemas/quotaHistory.d.ts +49 -0
- package/dist/schemas/quotaHistory.js +42 -0
- package/dist/schemas/sessionEvent.d.ts +11 -0
- package/dist/schemas/sessionEvent.js +30 -0
- package/dist/turns/assistantTurn.d.ts +69 -0
- package/dist/turns/assistantTurn.js +314 -0
- package/package.json +6 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Schemas entry (`sidekick-shared/schemas`).
|
|
4
|
+
*
|
|
5
|
+
* Pure zod runtime validation for the data shapes that cross process/IPC
|
|
6
|
+
* boundaries: session events, quota state, quota history, account status,
|
|
7
|
+
* and assistant turn projections. No node:fs / node:path — safe to bundle
|
|
8
|
+
* for browser runtimes, and lean enough that importing it does not drag in
|
|
9
|
+
* the rest of the library.
|
|
10
|
+
*
|
|
11
|
+
* The mirrored TypeScript interfaces are re-exported as types so this
|
|
12
|
+
* subpath is self-sufficient for boundary-validation modules.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.assistantTurnToolRefSchema = exports.assistantTurnToolGroupStepSchema = exports.assistantTurnSubagentStatusSchema = exports.assistantTurnSubagentSchema = exports.assistantTurnProjectionSchema = exports.assistantTurnProcessStepSchema = exports.assistantTurnProcessSchema = exports.assistantTurnNarrationStepSchema = exports.assistantTurnEventTypeSchema = exports.assistantTurnEventSchema = exports.activeAccountStatusSchema = exports.activeProviderAccountStatusSchema = exports.quotaHistoryDailyBucketSchema = exports.quotaHistorySampleSchema = exports.quotaHistoryRuntimeProviderSchema = exports.providerQuotaMapSchema = exports.codexProviderQuotaStateSchema = exports.claudeProviderQuotaStateSchema = exports.providerQuotaStateSchema = exports.runtimeQuotaProviderSchema = exports.quotaFailureDescriptorSchema = exports.peakHoursStateSchema = exports.quotaSourceSchema = exports.quotaProviderIdSchema = exports.quotaFailureKindSchema = exports.quotaStateSchema = exports.quotaWindowSchema = exports.extractSessionEvents = exports.permissionModeSchema = exports.sessionEventSchema = exports.sessionMessageSchema = exports.messageUsageSchema = void 0;
|
|
16
|
+
var sessionEvent_1 = require("./sessionEvent");
|
|
17
|
+
Object.defineProperty(exports, "messageUsageSchema", { enumerable: true, get: function () { return sessionEvent_1.messageUsageSchema; } });
|
|
18
|
+
Object.defineProperty(exports, "sessionMessageSchema", { enumerable: true, get: function () { return sessionEvent_1.sessionMessageSchema; } });
|
|
19
|
+
Object.defineProperty(exports, "sessionEventSchema", { enumerable: true, get: function () { return sessionEvent_1.sessionEventSchema; } });
|
|
20
|
+
Object.defineProperty(exports, "permissionModeSchema", { enumerable: true, get: function () { return sessionEvent_1.permissionModeSchema; } });
|
|
21
|
+
Object.defineProperty(exports, "extractSessionEvents", { enumerable: true, get: function () { return sessionEvent_1.extractSessionEvents; } });
|
|
22
|
+
var quota_1 = require("./quota");
|
|
23
|
+
Object.defineProperty(exports, "quotaWindowSchema", { enumerable: true, get: function () { return quota_1.quotaWindowSchema; } });
|
|
24
|
+
Object.defineProperty(exports, "quotaStateSchema", { enumerable: true, get: function () { return quota_1.quotaStateSchema; } });
|
|
25
|
+
Object.defineProperty(exports, "quotaFailureKindSchema", { enumerable: true, get: function () { return quota_1.quotaFailureKindSchema; } });
|
|
26
|
+
Object.defineProperty(exports, "quotaProviderIdSchema", { enumerable: true, get: function () { return quota_1.quotaProviderIdSchema; } });
|
|
27
|
+
Object.defineProperty(exports, "quotaSourceSchema", { enumerable: true, get: function () { return quota_1.quotaSourceSchema; } });
|
|
28
|
+
Object.defineProperty(exports, "peakHoursStateSchema", { enumerable: true, get: function () { return quota_1.peakHoursStateSchema; } });
|
|
29
|
+
Object.defineProperty(exports, "quotaFailureDescriptorSchema", { enumerable: true, get: function () { return quota_1.quotaFailureDescriptorSchema; } });
|
|
30
|
+
Object.defineProperty(exports, "runtimeQuotaProviderSchema", { enumerable: true, get: function () { return quota_1.runtimeQuotaProviderSchema; } });
|
|
31
|
+
Object.defineProperty(exports, "providerQuotaStateSchema", { enumerable: true, get: function () { return quota_1.providerQuotaStateSchema; } });
|
|
32
|
+
Object.defineProperty(exports, "claudeProviderQuotaStateSchema", { enumerable: true, get: function () { return quota_1.claudeProviderQuotaStateSchema; } });
|
|
33
|
+
Object.defineProperty(exports, "codexProviderQuotaStateSchema", { enumerable: true, get: function () { return quota_1.codexProviderQuotaStateSchema; } });
|
|
34
|
+
Object.defineProperty(exports, "providerQuotaMapSchema", { enumerable: true, get: function () { return quota_1.providerQuotaMapSchema; } });
|
|
35
|
+
var quotaHistory_1 = require("./quotaHistory");
|
|
36
|
+
Object.defineProperty(exports, "quotaHistoryRuntimeProviderSchema", { enumerable: true, get: function () { return quotaHistory_1.quotaHistoryRuntimeProviderSchema; } });
|
|
37
|
+
Object.defineProperty(exports, "quotaHistorySampleSchema", { enumerable: true, get: function () { return quotaHistory_1.quotaHistorySampleSchema; } });
|
|
38
|
+
Object.defineProperty(exports, "quotaHistoryDailyBucketSchema", { enumerable: true, get: function () { return quotaHistory_1.quotaHistoryDailyBucketSchema; } });
|
|
39
|
+
var accountStatus_1 = require("./accountStatus");
|
|
40
|
+
Object.defineProperty(exports, "activeProviderAccountStatusSchema", { enumerable: true, get: function () { return accountStatus_1.activeProviderAccountStatusSchema; } });
|
|
41
|
+
Object.defineProperty(exports, "activeAccountStatusSchema", { enumerable: true, get: function () { return accountStatus_1.activeAccountStatusSchema; } });
|
|
42
|
+
var assistantTurn_1 = require("./assistantTurn");
|
|
43
|
+
Object.defineProperty(exports, "assistantTurnEventSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnEventSchema; } });
|
|
44
|
+
Object.defineProperty(exports, "assistantTurnEventTypeSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnEventTypeSchema; } });
|
|
45
|
+
Object.defineProperty(exports, "assistantTurnNarrationStepSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnNarrationStepSchema; } });
|
|
46
|
+
Object.defineProperty(exports, "assistantTurnProcessSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnProcessSchema; } });
|
|
47
|
+
Object.defineProperty(exports, "assistantTurnProcessStepSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnProcessStepSchema; } });
|
|
48
|
+
Object.defineProperty(exports, "assistantTurnProjectionSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnProjectionSchema; } });
|
|
49
|
+
Object.defineProperty(exports, "assistantTurnSubagentSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnSubagentSchema; } });
|
|
50
|
+
Object.defineProperty(exports, "assistantTurnSubagentStatusSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnSubagentStatusSchema; } });
|
|
51
|
+
Object.defineProperty(exports, "assistantTurnToolGroupStepSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnToolGroupStepSchema; } });
|
|
52
|
+
Object.defineProperty(exports, "assistantTurnToolRefSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnToolRefSchema; } });
|
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for runtime validation of quota state.
|
|
3
|
+
*
|
|
4
|
+
* These schemas mirror the TypeScript interfaces in `quota.ts`,
|
|
5
|
+
* `peakHours.ts`, `quotaPresentation.ts`, and `providerQuota.ts` (keep in
|
|
6
|
+
* sync when those change). They let consumers validate quota payloads at
|
|
7
|
+
* process/IPC boundaries without hand-mirroring the interfaces.
|
|
8
|
+
*
|
|
9
|
+
* @module schemas/quota
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
export declare const quotaWindowSchema: z.ZodObject<{
|
|
13
|
+
utilization: z.ZodNumber;
|
|
14
|
+
resetsAt: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const quotaFailureKindSchema: z.ZodEnum<{
|
|
17
|
+
unknown: "unknown";
|
|
18
|
+
rate_limit: "rate_limit";
|
|
19
|
+
auth: "auth";
|
|
20
|
+
network: "network";
|
|
21
|
+
server: "server";
|
|
22
|
+
}>;
|
|
23
|
+
export declare const quotaProviderIdSchema: z.ZodEnum<{
|
|
24
|
+
"claude-code": "claude-code";
|
|
25
|
+
codex: "codex";
|
|
26
|
+
}>;
|
|
27
|
+
export declare const quotaSourceSchema: z.ZodEnum<{
|
|
28
|
+
session: "session";
|
|
29
|
+
api: "api";
|
|
30
|
+
cache: "cache";
|
|
31
|
+
}>;
|
|
32
|
+
export declare const quotaStateSchema: z.ZodObject<{
|
|
33
|
+
fiveHour: z.ZodObject<{
|
|
34
|
+
utilization: z.ZodNumber;
|
|
35
|
+
resetsAt: z.ZodString;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
sevenDay: z.ZodObject<{
|
|
38
|
+
utilization: z.ZodNumber;
|
|
39
|
+
resetsAt: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
available: z.ZodBoolean;
|
|
42
|
+
error: z.ZodOptional<z.ZodString>;
|
|
43
|
+
failureKind: z.ZodOptional<z.ZodEnum<{
|
|
44
|
+
unknown: "unknown";
|
|
45
|
+
rate_limit: "rate_limit";
|
|
46
|
+
auth: "auth";
|
|
47
|
+
network: "network";
|
|
48
|
+
server: "server";
|
|
49
|
+
}>>;
|
|
50
|
+
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
projectedFiveHour: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
projectedSevenDay: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
providerId: z.ZodOptional<z.ZodEnum<{
|
|
55
|
+
"claude-code": "claude-code";
|
|
56
|
+
codex: "codex";
|
|
57
|
+
}>>;
|
|
58
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
59
|
+
session: "session";
|
|
60
|
+
api: "api";
|
|
61
|
+
cache: "cache";
|
|
62
|
+
}>>;
|
|
63
|
+
capturedAt: z.ZodOptional<z.ZodString>;
|
|
64
|
+
stale: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
+
fiveHourLabel: z.ZodOptional<z.ZodString>;
|
|
66
|
+
sevenDayLabel: z.ZodOptional<z.ZodString>;
|
|
67
|
+
limitId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
limitName: z.ZodOptional<z.ZodString>;
|
|
69
|
+
credits: z.ZodOptional<z.ZodUnknown>;
|
|
70
|
+
planType: z.ZodOptional<z.ZodString>;
|
|
71
|
+
rateLimitReachedType: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
export declare const peakHoursStateSchema: z.ZodObject<{
|
|
74
|
+
status: z.ZodEnum<{
|
|
75
|
+
unknown: "unknown";
|
|
76
|
+
peak: "peak";
|
|
77
|
+
off_peak: "off_peak";
|
|
78
|
+
}>;
|
|
79
|
+
isPeak: z.ZodBoolean;
|
|
80
|
+
sessionLimitSpeed: z.ZodEnum<{
|
|
81
|
+
unknown: "unknown";
|
|
82
|
+
normal: "normal";
|
|
83
|
+
faster: "faster";
|
|
84
|
+
}>;
|
|
85
|
+
label: z.ZodString;
|
|
86
|
+
peakHoursDescription: z.ZodString;
|
|
87
|
+
nextChange: z.ZodNullable<z.ZodString>;
|
|
88
|
+
minutesUntilChange: z.ZodNullable<z.ZodNumber>;
|
|
89
|
+
note: z.ZodString;
|
|
90
|
+
updatedAt: z.ZodString;
|
|
91
|
+
unavailable: z.ZodBoolean;
|
|
92
|
+
notApplicable: z.ZodOptional<z.ZodBoolean>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
export declare const quotaFailureDescriptorSchema: z.ZodObject<{
|
|
95
|
+
severity: z.ZodEnum<{
|
|
96
|
+
error: "error";
|
|
97
|
+
info: "info";
|
|
98
|
+
warning: "warning";
|
|
99
|
+
}>;
|
|
100
|
+
title: z.ZodString;
|
|
101
|
+
message: z.ZodString;
|
|
102
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
103
|
+
alertKey: z.ZodString;
|
|
104
|
+
isRetryable: z.ZodBoolean;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
export declare const runtimeQuotaProviderSchema: z.ZodEnum<{
|
|
107
|
+
codex: "codex";
|
|
108
|
+
claude: "claude";
|
|
109
|
+
}>;
|
|
110
|
+
export declare const providerQuotaStateSchema: z.ZodObject<{
|
|
111
|
+
fiveHour: z.ZodObject<{
|
|
112
|
+
utilization: z.ZodNumber;
|
|
113
|
+
resetsAt: z.ZodString;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
sevenDay: z.ZodObject<{
|
|
116
|
+
utilization: z.ZodNumber;
|
|
117
|
+
resetsAt: z.ZodString;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
available: z.ZodBoolean;
|
|
120
|
+
error: z.ZodOptional<z.ZodString>;
|
|
121
|
+
failureKind: z.ZodOptional<z.ZodEnum<{
|
|
122
|
+
unknown: "unknown";
|
|
123
|
+
rate_limit: "rate_limit";
|
|
124
|
+
auth: "auth";
|
|
125
|
+
network: "network";
|
|
126
|
+
server: "server";
|
|
127
|
+
}>>;
|
|
128
|
+
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
129
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
projectedFiveHour: z.ZodOptional<z.ZodNumber>;
|
|
131
|
+
projectedSevenDay: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
providerId: z.ZodOptional<z.ZodEnum<{
|
|
133
|
+
"claude-code": "claude-code";
|
|
134
|
+
codex: "codex";
|
|
135
|
+
}>>;
|
|
136
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
137
|
+
session: "session";
|
|
138
|
+
api: "api";
|
|
139
|
+
cache: "cache";
|
|
140
|
+
}>>;
|
|
141
|
+
capturedAt: z.ZodOptional<z.ZodString>;
|
|
142
|
+
stale: z.ZodOptional<z.ZodBoolean>;
|
|
143
|
+
fiveHourLabel: z.ZodOptional<z.ZodString>;
|
|
144
|
+
sevenDayLabel: z.ZodOptional<z.ZodString>;
|
|
145
|
+
limitId: z.ZodOptional<z.ZodString>;
|
|
146
|
+
limitName: z.ZodOptional<z.ZodString>;
|
|
147
|
+
credits: z.ZodOptional<z.ZodUnknown>;
|
|
148
|
+
planType: z.ZodOptional<z.ZodString>;
|
|
149
|
+
rateLimitReachedType: z.ZodOptional<z.ZodString>;
|
|
150
|
+
accountLabel: z.ZodOptional<z.ZodString>;
|
|
151
|
+
accountDetail: z.ZodOptional<z.ZodString>;
|
|
152
|
+
peakHours: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
153
|
+
status: z.ZodEnum<{
|
|
154
|
+
unknown: "unknown";
|
|
155
|
+
peak: "peak";
|
|
156
|
+
off_peak: "off_peak";
|
|
157
|
+
}>;
|
|
158
|
+
isPeak: z.ZodBoolean;
|
|
159
|
+
sessionLimitSpeed: z.ZodEnum<{
|
|
160
|
+
unknown: "unknown";
|
|
161
|
+
normal: "normal";
|
|
162
|
+
faster: "faster";
|
|
163
|
+
}>;
|
|
164
|
+
label: z.ZodString;
|
|
165
|
+
peakHoursDescription: z.ZodString;
|
|
166
|
+
nextChange: z.ZodNullable<z.ZodString>;
|
|
167
|
+
minutesUntilChange: z.ZodNullable<z.ZodNumber>;
|
|
168
|
+
note: z.ZodString;
|
|
169
|
+
updatedAt: z.ZodString;
|
|
170
|
+
unavailable: z.ZodBoolean;
|
|
171
|
+
notApplicable: z.ZodOptional<z.ZodBoolean>;
|
|
172
|
+
}, z.core.$strip>>>;
|
|
173
|
+
failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
174
|
+
severity: z.ZodEnum<{
|
|
175
|
+
error: "error";
|
|
176
|
+
info: "info";
|
|
177
|
+
warning: "warning";
|
|
178
|
+
}>;
|
|
179
|
+
title: z.ZodString;
|
|
180
|
+
message: z.ZodString;
|
|
181
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
182
|
+
alertKey: z.ZodString;
|
|
183
|
+
isRetryable: z.ZodBoolean;
|
|
184
|
+
}, z.core.$strip>>>;
|
|
185
|
+
runtimeProvider: z.ZodEnum<{
|
|
186
|
+
codex: "codex";
|
|
187
|
+
claude: "claude";
|
|
188
|
+
}>;
|
|
189
|
+
}, z.core.$strip>;
|
|
190
|
+
export declare const claudeProviderQuotaStateSchema: z.ZodObject<{
|
|
191
|
+
fiveHour: z.ZodObject<{
|
|
192
|
+
utilization: z.ZodNumber;
|
|
193
|
+
resetsAt: z.ZodString;
|
|
194
|
+
}, z.core.$strip>;
|
|
195
|
+
sevenDay: z.ZodObject<{
|
|
196
|
+
utilization: z.ZodNumber;
|
|
197
|
+
resetsAt: z.ZodString;
|
|
198
|
+
}, z.core.$strip>;
|
|
199
|
+
available: z.ZodBoolean;
|
|
200
|
+
error: z.ZodOptional<z.ZodString>;
|
|
201
|
+
failureKind: z.ZodOptional<z.ZodEnum<{
|
|
202
|
+
unknown: "unknown";
|
|
203
|
+
rate_limit: "rate_limit";
|
|
204
|
+
auth: "auth";
|
|
205
|
+
network: "network";
|
|
206
|
+
server: "server";
|
|
207
|
+
}>>;
|
|
208
|
+
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
209
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
210
|
+
projectedFiveHour: z.ZodOptional<z.ZodNumber>;
|
|
211
|
+
projectedSevenDay: z.ZodOptional<z.ZodNumber>;
|
|
212
|
+
providerId: z.ZodOptional<z.ZodEnum<{
|
|
213
|
+
"claude-code": "claude-code";
|
|
214
|
+
codex: "codex";
|
|
215
|
+
}>>;
|
|
216
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
217
|
+
session: "session";
|
|
218
|
+
api: "api";
|
|
219
|
+
cache: "cache";
|
|
220
|
+
}>>;
|
|
221
|
+
capturedAt: z.ZodOptional<z.ZodString>;
|
|
222
|
+
stale: z.ZodOptional<z.ZodBoolean>;
|
|
223
|
+
fiveHourLabel: z.ZodOptional<z.ZodString>;
|
|
224
|
+
sevenDayLabel: z.ZodOptional<z.ZodString>;
|
|
225
|
+
limitId: z.ZodOptional<z.ZodString>;
|
|
226
|
+
limitName: z.ZodOptional<z.ZodString>;
|
|
227
|
+
credits: z.ZodOptional<z.ZodUnknown>;
|
|
228
|
+
planType: z.ZodOptional<z.ZodString>;
|
|
229
|
+
rateLimitReachedType: z.ZodOptional<z.ZodString>;
|
|
230
|
+
accountLabel: z.ZodOptional<z.ZodString>;
|
|
231
|
+
accountDetail: z.ZodOptional<z.ZodString>;
|
|
232
|
+
peakHours: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
233
|
+
status: z.ZodEnum<{
|
|
234
|
+
unknown: "unknown";
|
|
235
|
+
peak: "peak";
|
|
236
|
+
off_peak: "off_peak";
|
|
237
|
+
}>;
|
|
238
|
+
isPeak: z.ZodBoolean;
|
|
239
|
+
sessionLimitSpeed: z.ZodEnum<{
|
|
240
|
+
unknown: "unknown";
|
|
241
|
+
normal: "normal";
|
|
242
|
+
faster: "faster";
|
|
243
|
+
}>;
|
|
244
|
+
label: z.ZodString;
|
|
245
|
+
peakHoursDescription: z.ZodString;
|
|
246
|
+
nextChange: z.ZodNullable<z.ZodString>;
|
|
247
|
+
minutesUntilChange: z.ZodNullable<z.ZodNumber>;
|
|
248
|
+
note: z.ZodString;
|
|
249
|
+
updatedAt: z.ZodString;
|
|
250
|
+
unavailable: z.ZodBoolean;
|
|
251
|
+
notApplicable: z.ZodOptional<z.ZodBoolean>;
|
|
252
|
+
}, z.core.$strip>>>;
|
|
253
|
+
failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
254
|
+
severity: z.ZodEnum<{
|
|
255
|
+
error: "error";
|
|
256
|
+
info: "info";
|
|
257
|
+
warning: "warning";
|
|
258
|
+
}>;
|
|
259
|
+
title: z.ZodString;
|
|
260
|
+
message: z.ZodString;
|
|
261
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
262
|
+
alertKey: z.ZodString;
|
|
263
|
+
isRetryable: z.ZodBoolean;
|
|
264
|
+
}, z.core.$strip>>>;
|
|
265
|
+
runtimeProvider: z.ZodLiteral<"claude">;
|
|
266
|
+
}, z.core.$strip>;
|
|
267
|
+
export declare const codexProviderQuotaStateSchema: z.ZodObject<{
|
|
268
|
+
fiveHour: z.ZodObject<{
|
|
269
|
+
utilization: z.ZodNumber;
|
|
270
|
+
resetsAt: z.ZodString;
|
|
271
|
+
}, z.core.$strip>;
|
|
272
|
+
sevenDay: z.ZodObject<{
|
|
273
|
+
utilization: z.ZodNumber;
|
|
274
|
+
resetsAt: z.ZodString;
|
|
275
|
+
}, z.core.$strip>;
|
|
276
|
+
available: z.ZodBoolean;
|
|
277
|
+
error: z.ZodOptional<z.ZodString>;
|
|
278
|
+
failureKind: z.ZodOptional<z.ZodEnum<{
|
|
279
|
+
unknown: "unknown";
|
|
280
|
+
rate_limit: "rate_limit";
|
|
281
|
+
auth: "auth";
|
|
282
|
+
network: "network";
|
|
283
|
+
server: "server";
|
|
284
|
+
}>>;
|
|
285
|
+
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
286
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
287
|
+
projectedFiveHour: z.ZodOptional<z.ZodNumber>;
|
|
288
|
+
projectedSevenDay: z.ZodOptional<z.ZodNumber>;
|
|
289
|
+
providerId: z.ZodOptional<z.ZodEnum<{
|
|
290
|
+
"claude-code": "claude-code";
|
|
291
|
+
codex: "codex";
|
|
292
|
+
}>>;
|
|
293
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
294
|
+
session: "session";
|
|
295
|
+
api: "api";
|
|
296
|
+
cache: "cache";
|
|
297
|
+
}>>;
|
|
298
|
+
capturedAt: z.ZodOptional<z.ZodString>;
|
|
299
|
+
stale: z.ZodOptional<z.ZodBoolean>;
|
|
300
|
+
fiveHourLabel: z.ZodOptional<z.ZodString>;
|
|
301
|
+
sevenDayLabel: z.ZodOptional<z.ZodString>;
|
|
302
|
+
limitId: z.ZodOptional<z.ZodString>;
|
|
303
|
+
limitName: z.ZodOptional<z.ZodString>;
|
|
304
|
+
credits: z.ZodOptional<z.ZodUnknown>;
|
|
305
|
+
planType: z.ZodOptional<z.ZodString>;
|
|
306
|
+
rateLimitReachedType: z.ZodOptional<z.ZodString>;
|
|
307
|
+
accountLabel: z.ZodOptional<z.ZodString>;
|
|
308
|
+
accountDetail: z.ZodOptional<z.ZodString>;
|
|
309
|
+
peakHours: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
310
|
+
status: z.ZodEnum<{
|
|
311
|
+
unknown: "unknown";
|
|
312
|
+
peak: "peak";
|
|
313
|
+
off_peak: "off_peak";
|
|
314
|
+
}>;
|
|
315
|
+
isPeak: z.ZodBoolean;
|
|
316
|
+
sessionLimitSpeed: z.ZodEnum<{
|
|
317
|
+
unknown: "unknown";
|
|
318
|
+
normal: "normal";
|
|
319
|
+
faster: "faster";
|
|
320
|
+
}>;
|
|
321
|
+
label: z.ZodString;
|
|
322
|
+
peakHoursDescription: z.ZodString;
|
|
323
|
+
nextChange: z.ZodNullable<z.ZodString>;
|
|
324
|
+
minutesUntilChange: z.ZodNullable<z.ZodNumber>;
|
|
325
|
+
note: z.ZodString;
|
|
326
|
+
updatedAt: z.ZodString;
|
|
327
|
+
unavailable: z.ZodBoolean;
|
|
328
|
+
notApplicable: z.ZodOptional<z.ZodBoolean>;
|
|
329
|
+
}, z.core.$strip>>>;
|
|
330
|
+
failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
331
|
+
severity: z.ZodEnum<{
|
|
332
|
+
error: "error";
|
|
333
|
+
info: "info";
|
|
334
|
+
warning: "warning";
|
|
335
|
+
}>;
|
|
336
|
+
title: z.ZodString;
|
|
337
|
+
message: z.ZodString;
|
|
338
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
339
|
+
alertKey: z.ZodString;
|
|
340
|
+
isRetryable: z.ZodBoolean;
|
|
341
|
+
}, z.core.$strip>>>;
|
|
342
|
+
runtimeProvider: z.ZodLiteral<"codex">;
|
|
343
|
+
}, z.core.$strip>;
|
|
344
|
+
export declare const providerQuotaMapSchema: z.ZodObject<{
|
|
345
|
+
claude: z.ZodOptional<z.ZodObject<{
|
|
346
|
+
fiveHour: z.ZodObject<{
|
|
347
|
+
utilization: z.ZodNumber;
|
|
348
|
+
resetsAt: z.ZodString;
|
|
349
|
+
}, z.core.$strip>;
|
|
350
|
+
sevenDay: z.ZodObject<{
|
|
351
|
+
utilization: z.ZodNumber;
|
|
352
|
+
resetsAt: z.ZodString;
|
|
353
|
+
}, z.core.$strip>;
|
|
354
|
+
available: z.ZodBoolean;
|
|
355
|
+
error: z.ZodOptional<z.ZodString>;
|
|
356
|
+
failureKind: z.ZodOptional<z.ZodEnum<{
|
|
357
|
+
unknown: "unknown";
|
|
358
|
+
rate_limit: "rate_limit";
|
|
359
|
+
auth: "auth";
|
|
360
|
+
network: "network";
|
|
361
|
+
server: "server";
|
|
362
|
+
}>>;
|
|
363
|
+
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
364
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
365
|
+
projectedFiveHour: z.ZodOptional<z.ZodNumber>;
|
|
366
|
+
projectedSevenDay: z.ZodOptional<z.ZodNumber>;
|
|
367
|
+
providerId: z.ZodOptional<z.ZodEnum<{
|
|
368
|
+
"claude-code": "claude-code";
|
|
369
|
+
codex: "codex";
|
|
370
|
+
}>>;
|
|
371
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
372
|
+
session: "session";
|
|
373
|
+
api: "api";
|
|
374
|
+
cache: "cache";
|
|
375
|
+
}>>;
|
|
376
|
+
capturedAt: z.ZodOptional<z.ZodString>;
|
|
377
|
+
stale: z.ZodOptional<z.ZodBoolean>;
|
|
378
|
+
fiveHourLabel: z.ZodOptional<z.ZodString>;
|
|
379
|
+
sevenDayLabel: z.ZodOptional<z.ZodString>;
|
|
380
|
+
limitId: z.ZodOptional<z.ZodString>;
|
|
381
|
+
limitName: z.ZodOptional<z.ZodString>;
|
|
382
|
+
credits: z.ZodOptional<z.ZodUnknown>;
|
|
383
|
+
planType: z.ZodOptional<z.ZodString>;
|
|
384
|
+
rateLimitReachedType: z.ZodOptional<z.ZodString>;
|
|
385
|
+
accountLabel: z.ZodOptional<z.ZodString>;
|
|
386
|
+
accountDetail: z.ZodOptional<z.ZodString>;
|
|
387
|
+
peakHours: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
388
|
+
status: z.ZodEnum<{
|
|
389
|
+
unknown: "unknown";
|
|
390
|
+
peak: "peak";
|
|
391
|
+
off_peak: "off_peak";
|
|
392
|
+
}>;
|
|
393
|
+
isPeak: z.ZodBoolean;
|
|
394
|
+
sessionLimitSpeed: z.ZodEnum<{
|
|
395
|
+
unknown: "unknown";
|
|
396
|
+
normal: "normal";
|
|
397
|
+
faster: "faster";
|
|
398
|
+
}>;
|
|
399
|
+
label: z.ZodString;
|
|
400
|
+
peakHoursDescription: z.ZodString;
|
|
401
|
+
nextChange: z.ZodNullable<z.ZodString>;
|
|
402
|
+
minutesUntilChange: z.ZodNullable<z.ZodNumber>;
|
|
403
|
+
note: z.ZodString;
|
|
404
|
+
updatedAt: z.ZodString;
|
|
405
|
+
unavailable: z.ZodBoolean;
|
|
406
|
+
notApplicable: z.ZodOptional<z.ZodBoolean>;
|
|
407
|
+
}, z.core.$strip>>>;
|
|
408
|
+
failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
409
|
+
severity: z.ZodEnum<{
|
|
410
|
+
error: "error";
|
|
411
|
+
info: "info";
|
|
412
|
+
warning: "warning";
|
|
413
|
+
}>;
|
|
414
|
+
title: z.ZodString;
|
|
415
|
+
message: z.ZodString;
|
|
416
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
417
|
+
alertKey: z.ZodString;
|
|
418
|
+
isRetryable: z.ZodBoolean;
|
|
419
|
+
}, z.core.$strip>>>;
|
|
420
|
+
runtimeProvider: z.ZodLiteral<"claude">;
|
|
421
|
+
}, z.core.$strip>>;
|
|
422
|
+
codex: z.ZodOptional<z.ZodObject<{
|
|
423
|
+
fiveHour: z.ZodObject<{
|
|
424
|
+
utilization: z.ZodNumber;
|
|
425
|
+
resetsAt: z.ZodString;
|
|
426
|
+
}, z.core.$strip>;
|
|
427
|
+
sevenDay: z.ZodObject<{
|
|
428
|
+
utilization: z.ZodNumber;
|
|
429
|
+
resetsAt: z.ZodString;
|
|
430
|
+
}, z.core.$strip>;
|
|
431
|
+
available: z.ZodBoolean;
|
|
432
|
+
error: z.ZodOptional<z.ZodString>;
|
|
433
|
+
failureKind: z.ZodOptional<z.ZodEnum<{
|
|
434
|
+
unknown: "unknown";
|
|
435
|
+
rate_limit: "rate_limit";
|
|
436
|
+
auth: "auth";
|
|
437
|
+
network: "network";
|
|
438
|
+
server: "server";
|
|
439
|
+
}>>;
|
|
440
|
+
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
441
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
442
|
+
projectedFiveHour: z.ZodOptional<z.ZodNumber>;
|
|
443
|
+
projectedSevenDay: z.ZodOptional<z.ZodNumber>;
|
|
444
|
+
providerId: z.ZodOptional<z.ZodEnum<{
|
|
445
|
+
"claude-code": "claude-code";
|
|
446
|
+
codex: "codex";
|
|
447
|
+
}>>;
|
|
448
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
449
|
+
session: "session";
|
|
450
|
+
api: "api";
|
|
451
|
+
cache: "cache";
|
|
452
|
+
}>>;
|
|
453
|
+
capturedAt: z.ZodOptional<z.ZodString>;
|
|
454
|
+
stale: z.ZodOptional<z.ZodBoolean>;
|
|
455
|
+
fiveHourLabel: z.ZodOptional<z.ZodString>;
|
|
456
|
+
sevenDayLabel: z.ZodOptional<z.ZodString>;
|
|
457
|
+
limitId: z.ZodOptional<z.ZodString>;
|
|
458
|
+
limitName: z.ZodOptional<z.ZodString>;
|
|
459
|
+
credits: z.ZodOptional<z.ZodUnknown>;
|
|
460
|
+
planType: z.ZodOptional<z.ZodString>;
|
|
461
|
+
rateLimitReachedType: z.ZodOptional<z.ZodString>;
|
|
462
|
+
accountLabel: z.ZodOptional<z.ZodString>;
|
|
463
|
+
accountDetail: z.ZodOptional<z.ZodString>;
|
|
464
|
+
peakHours: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
465
|
+
status: z.ZodEnum<{
|
|
466
|
+
unknown: "unknown";
|
|
467
|
+
peak: "peak";
|
|
468
|
+
off_peak: "off_peak";
|
|
469
|
+
}>;
|
|
470
|
+
isPeak: z.ZodBoolean;
|
|
471
|
+
sessionLimitSpeed: z.ZodEnum<{
|
|
472
|
+
unknown: "unknown";
|
|
473
|
+
normal: "normal";
|
|
474
|
+
faster: "faster";
|
|
475
|
+
}>;
|
|
476
|
+
label: z.ZodString;
|
|
477
|
+
peakHoursDescription: z.ZodString;
|
|
478
|
+
nextChange: z.ZodNullable<z.ZodString>;
|
|
479
|
+
minutesUntilChange: z.ZodNullable<z.ZodNumber>;
|
|
480
|
+
note: z.ZodString;
|
|
481
|
+
updatedAt: z.ZodString;
|
|
482
|
+
unavailable: z.ZodBoolean;
|
|
483
|
+
notApplicable: z.ZodOptional<z.ZodBoolean>;
|
|
484
|
+
}, z.core.$strip>>>;
|
|
485
|
+
failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
486
|
+
severity: z.ZodEnum<{
|
|
487
|
+
error: "error";
|
|
488
|
+
info: "info";
|
|
489
|
+
warning: "warning";
|
|
490
|
+
}>;
|
|
491
|
+
title: z.ZodString;
|
|
492
|
+
message: z.ZodString;
|
|
493
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
494
|
+
alertKey: z.ZodString;
|
|
495
|
+
isRetryable: z.ZodBoolean;
|
|
496
|
+
}, z.core.$strip>>>;
|
|
497
|
+
runtimeProvider: z.ZodLiteral<"codex">;
|
|
498
|
+
}, z.core.$strip>>;
|
|
499
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Zod schemas for runtime validation of quota state.
|
|
4
|
+
*
|
|
5
|
+
* These schemas mirror the TypeScript interfaces in `quota.ts`,
|
|
6
|
+
* `peakHours.ts`, `quotaPresentation.ts`, and `providerQuota.ts` (keep in
|
|
7
|
+
* sync when those change). They let consumers validate quota payloads at
|
|
8
|
+
* process/IPC boundaries without hand-mirroring the interfaces.
|
|
9
|
+
*
|
|
10
|
+
* @module schemas/quota
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.providerQuotaMapSchema = exports.codexProviderQuotaStateSchema = exports.claudeProviderQuotaStateSchema = exports.providerQuotaStateSchema = exports.runtimeQuotaProviderSchema = exports.quotaFailureDescriptorSchema = exports.peakHoursStateSchema = exports.quotaStateSchema = exports.quotaSourceSchema = exports.quotaProviderIdSchema = exports.quotaFailureKindSchema = exports.quotaWindowSchema = void 0;
|
|
14
|
+
const zod_1 = require("zod");
|
|
15
|
+
// ── QuotaWindow ──
|
|
16
|
+
exports.quotaWindowSchema = zod_1.z.object({
|
|
17
|
+
utilization: zod_1.z.number(),
|
|
18
|
+
resetsAt: zod_1.z.string(),
|
|
19
|
+
});
|
|
20
|
+
// ── QuotaState ──
|
|
21
|
+
exports.quotaFailureKindSchema = zod_1.z.enum([
|
|
22
|
+
'auth',
|
|
23
|
+
'network',
|
|
24
|
+
'rate_limit',
|
|
25
|
+
'server',
|
|
26
|
+
'unknown',
|
|
27
|
+
]);
|
|
28
|
+
exports.quotaProviderIdSchema = zod_1.z.enum([
|
|
29
|
+
'claude-code',
|
|
30
|
+
'codex',
|
|
31
|
+
]);
|
|
32
|
+
exports.quotaSourceSchema = zod_1.z.enum([
|
|
33
|
+
'api',
|
|
34
|
+
'session',
|
|
35
|
+
'cache',
|
|
36
|
+
]);
|
|
37
|
+
exports.quotaStateSchema = zod_1.z.object({
|
|
38
|
+
fiveHour: exports.quotaWindowSchema,
|
|
39
|
+
sevenDay: exports.quotaWindowSchema,
|
|
40
|
+
available: zod_1.z.boolean(),
|
|
41
|
+
error: zod_1.z.string().optional(),
|
|
42
|
+
failureKind: exports.quotaFailureKindSchema.optional(),
|
|
43
|
+
httpStatus: zod_1.z.number().optional(),
|
|
44
|
+
retryAfterMs: zod_1.z.number().optional(),
|
|
45
|
+
projectedFiveHour: zod_1.z.number().optional(),
|
|
46
|
+
projectedSevenDay: zod_1.z.number().optional(),
|
|
47
|
+
providerId: exports.quotaProviderIdSchema.optional(),
|
|
48
|
+
source: exports.quotaSourceSchema.optional(),
|
|
49
|
+
capturedAt: zod_1.z.string().optional(),
|
|
50
|
+
stale: zod_1.z.boolean().optional(),
|
|
51
|
+
fiveHourLabel: zod_1.z.string().optional(),
|
|
52
|
+
sevenDayLabel: zod_1.z.string().optional(),
|
|
53
|
+
limitId: zod_1.z.string().optional(),
|
|
54
|
+
limitName: zod_1.z.string().optional(),
|
|
55
|
+
credits: zod_1.z.unknown().optional(),
|
|
56
|
+
planType: zod_1.z.string().optional(),
|
|
57
|
+
rateLimitReachedType: zod_1.z.string().optional(),
|
|
58
|
+
});
|
|
59
|
+
// ── PeakHoursState ──
|
|
60
|
+
exports.peakHoursStateSchema = zod_1.z.object({
|
|
61
|
+
status: zod_1.z.enum(['peak', 'off_peak', 'unknown']),
|
|
62
|
+
isPeak: zod_1.z.boolean(),
|
|
63
|
+
sessionLimitSpeed: zod_1.z.enum(['normal', 'faster', 'unknown']),
|
|
64
|
+
label: zod_1.z.string(),
|
|
65
|
+
peakHoursDescription: zod_1.z.string(),
|
|
66
|
+
nextChange: zod_1.z.string().nullable(),
|
|
67
|
+
minutesUntilChange: zod_1.z.number().nullable(),
|
|
68
|
+
note: zod_1.z.string(),
|
|
69
|
+
updatedAt: zod_1.z.string(),
|
|
70
|
+
unavailable: zod_1.z.boolean(),
|
|
71
|
+
notApplicable: zod_1.z.boolean().optional(),
|
|
72
|
+
});
|
|
73
|
+
// ── QuotaFailureDescriptor ──
|
|
74
|
+
exports.quotaFailureDescriptorSchema = zod_1.z.object({
|
|
75
|
+
severity: zod_1.z.enum(['info', 'warning', 'error']),
|
|
76
|
+
title: zod_1.z.string(),
|
|
77
|
+
message: zod_1.z.string(),
|
|
78
|
+
detail: zod_1.z.string().optional(),
|
|
79
|
+
alertKey: zod_1.z.string(),
|
|
80
|
+
isRetryable: zod_1.z.boolean(),
|
|
81
|
+
});
|
|
82
|
+
// ── ProviderQuotaState / ProviderQuotaMap ──
|
|
83
|
+
exports.runtimeQuotaProviderSchema = zod_1.z.enum([
|
|
84
|
+
'claude',
|
|
85
|
+
'codex',
|
|
86
|
+
]);
|
|
87
|
+
/** Fields ProviderQuotaState adds on top of QuotaState, minus the provider tag. */
|
|
88
|
+
const providerQuotaExtensionShape = {
|
|
89
|
+
accountLabel: zod_1.z.string().optional(),
|
|
90
|
+
accountDetail: zod_1.z.string().optional(),
|
|
91
|
+
peakHours: exports.peakHoursStateSchema.nullable().optional(),
|
|
92
|
+
failure: exports.quotaFailureDescriptorSchema.nullable().optional(),
|
|
93
|
+
};
|
|
94
|
+
exports.providerQuotaStateSchema = exports.quotaStateSchema.extend({
|
|
95
|
+
runtimeProvider: exports.runtimeQuotaProviderSchema,
|
|
96
|
+
...providerQuotaExtensionShape,
|
|
97
|
+
});
|
|
98
|
+
exports.claudeProviderQuotaStateSchema = exports.quotaStateSchema.extend({
|
|
99
|
+
runtimeProvider: zod_1.z.literal('claude'),
|
|
100
|
+
...providerQuotaExtensionShape,
|
|
101
|
+
});
|
|
102
|
+
exports.codexProviderQuotaStateSchema = exports.quotaStateSchema.extend({
|
|
103
|
+
runtimeProvider: zod_1.z.literal('codex'),
|
|
104
|
+
...providerQuotaExtensionShape,
|
|
105
|
+
});
|
|
106
|
+
exports.providerQuotaMapSchema = zod_1.z.object({
|
|
107
|
+
claude: exports.claudeProviderQuotaStateSchema.optional(),
|
|
108
|
+
codex: exports.codexProviderQuotaStateSchema.optional(),
|
|
109
|
+
});
|