opencode-auth-load-balancer 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -7
- package/dist/fetch.d.ts +12 -1
- package/dist/index.js +1631 -845
- package/dist/notify.d.ts +8 -0
- package/dist/pending/coordinator.d.ts +135 -0
- package/dist/pending/lease.d.ts +3 -0
- package/dist/pending/recovery.d.ts +16 -0
- package/dist/pending/store.d.ts +12 -0
- package/dist/pending/types.d.ts +23 -0
- package/dist/pool/lock.d.ts +1 -2
- package/dist/pool/paths.d.ts +11 -0
- package/dist/providers/anthropic/constants.d.ts +46 -6
- package/dist/providers/anthropic/version.d.ts +29 -0
- package/dist/providers/types.d.ts +13 -0
- package/dist/providers/usage-http.d.ts +7 -6
- package/dist/session.d.ts +2 -0
- package/dist/status.d.ts +3 -0
- package/dist/types.d.ts +3 -0
- package/dist/usage-refresh.d.ts +1 -0
- package/package.json +10 -10
- package/tui/auth-load-balancer-tui.logic.ts +9 -1
- package/tui/auth-load-balancer-tui.view.tsx +31 -10
package/dist/index.js
CHANGED
|
@@ -1,506 +1,510 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __returnValue = (v) => v;
|
|
3
|
+
function __exportSetter(name, newValue) {
|
|
4
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
5
|
+
}
|
|
2
6
|
var __export = (target, all) => {
|
|
3
7
|
for (var name in all)
|
|
4
8
|
__defProp(target, name, {
|
|
5
9
|
get: all[name],
|
|
6
10
|
enumerable: true,
|
|
7
11
|
configurable: true,
|
|
8
|
-
set: (
|
|
12
|
+
set: __exportSetter.bind(all, name)
|
|
9
13
|
});
|
|
10
14
|
};
|
|
11
15
|
|
|
12
16
|
// node_modules/zod/v4/classic/external.js
|
|
13
17
|
var exports_external = {};
|
|
14
18
|
__export(exports_external, {
|
|
15
|
-
|
|
16
|
-
void: () => _void2,
|
|
17
|
-
uuidv7: () => uuidv7,
|
|
18
|
-
uuidv6: () => uuidv6,
|
|
19
|
-
uuidv4: () => uuidv4,
|
|
20
|
-
uuid: () => uuid2,
|
|
21
|
-
util: () => exports_util,
|
|
22
|
-
url: () => url,
|
|
23
|
-
uppercase: () => _uppercase,
|
|
24
|
-
unknown: () => unknown,
|
|
25
|
-
union: () => union,
|
|
26
|
-
undefined: () => _undefined3,
|
|
27
|
-
ulid: () => ulid2,
|
|
28
|
-
uint64: () => uint64,
|
|
29
|
-
uint32: () => uint32,
|
|
30
|
-
tuple: () => tuple,
|
|
31
|
-
trim: () => _trim,
|
|
32
|
-
treeifyError: () => treeifyError,
|
|
33
|
-
transform: () => transform,
|
|
34
|
-
toUpperCase: () => _toUpperCase,
|
|
35
|
-
toLowerCase: () => _toLowerCase,
|
|
36
|
-
toJSONSchema: () => toJSONSchema,
|
|
37
|
-
templateLiteral: () => templateLiteral,
|
|
38
|
-
symbol: () => symbol,
|
|
39
|
-
superRefine: () => superRefine,
|
|
40
|
-
success: () => success,
|
|
41
|
-
stringbool: () => stringbool,
|
|
42
|
-
stringFormat: () => stringFormat,
|
|
43
|
-
string: () => string2,
|
|
44
|
-
strictObject: () => strictObject,
|
|
45
|
-
startsWith: () => _startsWith,
|
|
46
|
-
size: () => _size,
|
|
47
|
-
setErrorMap: () => setErrorMap,
|
|
48
|
-
set: () => set,
|
|
49
|
-
safeParseAsync: () => safeParseAsync2,
|
|
50
|
-
safeParse: () => safeParse2,
|
|
51
|
-
safeEncodeAsync: () => safeEncodeAsync2,
|
|
52
|
-
safeEncode: () => safeEncode2,
|
|
53
|
-
safeDecodeAsync: () => safeDecodeAsync2,
|
|
54
|
-
safeDecode: () => safeDecode2,
|
|
55
|
-
registry: () => registry,
|
|
56
|
-
regexes: () => exports_regexes,
|
|
57
|
-
regex: () => _regex,
|
|
58
|
-
refine: () => refine,
|
|
59
|
-
record: () => record,
|
|
60
|
-
readonly: () => readonly,
|
|
61
|
-
property: () => _property,
|
|
62
|
-
promise: () => promise,
|
|
63
|
-
prettifyError: () => prettifyError,
|
|
64
|
-
preprocess: () => preprocess,
|
|
65
|
-
prefault: () => prefault,
|
|
66
|
-
positive: () => _positive,
|
|
67
|
-
pipe: () => pipe,
|
|
68
|
-
partialRecord: () => partialRecord,
|
|
69
|
-
parseAsync: () => parseAsync2,
|
|
70
|
-
parse: () => parse3,
|
|
71
|
-
overwrite: () => _overwrite,
|
|
72
|
-
optional: () => optional,
|
|
73
|
-
object: () => object,
|
|
74
|
-
number: () => number2,
|
|
75
|
-
nullish: () => nullish2,
|
|
76
|
-
nullable: () => nullable,
|
|
77
|
-
null: () => _null3,
|
|
78
|
-
normalize: () => _normalize,
|
|
79
|
-
nonpositive: () => _nonpositive,
|
|
80
|
-
nonoptional: () => nonoptional,
|
|
81
|
-
nonnegative: () => _nonnegative,
|
|
82
|
-
never: () => never,
|
|
83
|
-
negative: () => _negative,
|
|
84
|
-
nativeEnum: () => nativeEnum,
|
|
85
|
-
nanoid: () => nanoid2,
|
|
86
|
-
nan: () => nan,
|
|
87
|
-
multipleOf: () => _multipleOf,
|
|
88
|
-
minSize: () => _minSize,
|
|
89
|
-
minLength: () => _minLength,
|
|
90
|
-
mime: () => _mime,
|
|
91
|
-
maxSize: () => _maxSize,
|
|
92
|
-
maxLength: () => _maxLength,
|
|
93
|
-
map: () => map,
|
|
94
|
-
lte: () => _lte,
|
|
95
|
-
lt: () => _lt,
|
|
96
|
-
lowercase: () => _lowercase,
|
|
97
|
-
looseObject: () => looseObject,
|
|
98
|
-
locales: () => exports_locales,
|
|
99
|
-
literal: () => literal,
|
|
100
|
-
length: () => _length,
|
|
101
|
-
lazy: () => lazy,
|
|
102
|
-
ksuid: () => ksuid2,
|
|
103
|
-
keyof: () => keyof,
|
|
104
|
-
jwt: () => jwt,
|
|
105
|
-
json: () => json,
|
|
106
|
-
iso: () => exports_iso,
|
|
107
|
-
ipv6: () => ipv62,
|
|
108
|
-
ipv4: () => ipv42,
|
|
109
|
-
intersection: () => intersection,
|
|
110
|
-
int64: () => int64,
|
|
111
|
-
int32: () => int32,
|
|
112
|
-
int: () => int,
|
|
113
|
-
instanceof: () => _instanceof,
|
|
114
|
-
includes: () => _includes,
|
|
115
|
-
httpUrl: () => httpUrl,
|
|
116
|
-
hostname: () => hostname2,
|
|
117
|
-
hex: () => hex2,
|
|
118
|
-
hash: () => hash,
|
|
119
|
-
guid: () => guid2,
|
|
120
|
-
gte: () => _gte,
|
|
121
|
-
gt: () => _gt,
|
|
122
|
-
globalRegistry: () => globalRegistry,
|
|
123
|
-
getErrorMap: () => getErrorMap,
|
|
124
|
-
function: () => _function,
|
|
125
|
-
formatError: () => formatError,
|
|
126
|
-
float64: () => float64,
|
|
127
|
-
float32: () => float32,
|
|
128
|
-
flattenError: () => flattenError,
|
|
129
|
-
file: () => file,
|
|
130
|
-
enum: () => _enum2,
|
|
131
|
-
endsWith: () => _endsWith,
|
|
132
|
-
encodeAsync: () => encodeAsync2,
|
|
133
|
-
encode: () => encode2,
|
|
134
|
-
emoji: () => emoji2,
|
|
135
|
-
email: () => email2,
|
|
136
|
-
e164: () => e1642,
|
|
137
|
-
discriminatedUnion: () => discriminatedUnion,
|
|
138
|
-
decodeAsync: () => decodeAsync2,
|
|
139
|
-
decode: () => decode2,
|
|
140
|
-
date: () => date3,
|
|
141
|
-
custom: () => custom,
|
|
142
|
-
cuid2: () => cuid22,
|
|
143
|
-
cuid: () => cuid3,
|
|
144
|
-
core: () => exports_core2,
|
|
145
|
-
config: () => config,
|
|
146
|
-
coerce: () => exports_coerce,
|
|
147
|
-
codec: () => codec,
|
|
148
|
-
clone: () => clone,
|
|
149
|
-
cidrv6: () => cidrv62,
|
|
150
|
-
cidrv4: () => cidrv42,
|
|
151
|
-
check: () => check,
|
|
152
|
-
catch: () => _catch2,
|
|
153
|
-
boolean: () => boolean2,
|
|
154
|
-
bigint: () => bigint2,
|
|
155
|
-
base64url: () => base64url2,
|
|
156
|
-
base64: () => base642,
|
|
157
|
-
array: () => array,
|
|
158
|
-
any: () => any,
|
|
159
|
-
_function: () => _function,
|
|
160
|
-
_default: () => _default2,
|
|
161
|
-
_ZodString: () => _ZodString,
|
|
162
|
-
ZodXID: () => ZodXID,
|
|
163
|
-
ZodVoid: () => ZodVoid,
|
|
164
|
-
ZodUnknown: () => ZodUnknown,
|
|
165
|
-
ZodUnion: () => ZodUnion,
|
|
166
|
-
ZodUndefined: () => ZodUndefined,
|
|
167
|
-
ZodUUID: () => ZodUUID,
|
|
168
|
-
ZodURL: () => ZodURL,
|
|
169
|
-
ZodULID: () => ZodULID,
|
|
170
|
-
ZodType: () => ZodType,
|
|
171
|
-
ZodTuple: () => ZodTuple,
|
|
172
|
-
ZodTransform: () => ZodTransform,
|
|
173
|
-
ZodTemplateLiteral: () => ZodTemplateLiteral,
|
|
174
|
-
ZodSymbol: () => ZodSymbol,
|
|
175
|
-
ZodSuccess: () => ZodSuccess,
|
|
176
|
-
ZodStringFormat: () => ZodStringFormat,
|
|
177
|
-
ZodString: () => ZodString,
|
|
178
|
-
ZodSet: () => ZodSet,
|
|
179
|
-
ZodRecord: () => ZodRecord,
|
|
180
|
-
ZodRealError: () => ZodRealError,
|
|
181
|
-
ZodReadonly: () => ZodReadonly,
|
|
182
|
-
ZodPromise: () => ZodPromise,
|
|
183
|
-
ZodPrefault: () => ZodPrefault,
|
|
184
|
-
ZodPipe: () => ZodPipe,
|
|
185
|
-
ZodOptional: () => ZodOptional,
|
|
186
|
-
ZodObject: () => ZodObject,
|
|
187
|
-
ZodNumberFormat: () => ZodNumberFormat,
|
|
188
|
-
ZodNumber: () => ZodNumber,
|
|
189
|
-
ZodNullable: () => ZodNullable,
|
|
190
|
-
ZodNull: () => ZodNull,
|
|
191
|
-
ZodNonOptional: () => ZodNonOptional,
|
|
192
|
-
ZodNever: () => ZodNever,
|
|
193
|
-
ZodNanoID: () => ZodNanoID,
|
|
194
|
-
ZodNaN: () => ZodNaN,
|
|
195
|
-
ZodMap: () => ZodMap,
|
|
196
|
-
ZodLiteral: () => ZodLiteral,
|
|
197
|
-
ZodLazy: () => ZodLazy,
|
|
198
|
-
ZodKSUID: () => ZodKSUID,
|
|
199
|
-
ZodJWT: () => ZodJWT,
|
|
200
|
-
ZodIssueCode: () => ZodIssueCode,
|
|
201
|
-
ZodIntersection: () => ZodIntersection,
|
|
202
|
-
ZodISOTime: () => ZodISOTime,
|
|
203
|
-
ZodISODuration: () => ZodISODuration,
|
|
204
|
-
ZodISODateTime: () => ZodISODateTime,
|
|
205
|
-
ZodISODate: () => ZodISODate,
|
|
206
|
-
ZodIPv6: () => ZodIPv6,
|
|
207
|
-
ZodIPv4: () => ZodIPv4,
|
|
208
|
-
ZodGUID: () => ZodGUID,
|
|
209
|
-
ZodFunction: () => ZodFunction,
|
|
210
|
-
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
|
|
211
|
-
ZodFile: () => ZodFile,
|
|
212
|
-
ZodError: () => ZodError,
|
|
213
|
-
ZodEnum: () => ZodEnum,
|
|
214
|
-
ZodEmoji: () => ZodEmoji,
|
|
215
|
-
ZodEmail: () => ZodEmail,
|
|
216
|
-
ZodE164: () => ZodE164,
|
|
217
|
-
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
|
|
218
|
-
ZodDefault: () => ZodDefault,
|
|
219
|
-
ZodDate: () => ZodDate,
|
|
220
|
-
ZodCustomStringFormat: () => ZodCustomStringFormat,
|
|
221
|
-
ZodCustom: () => ZodCustom,
|
|
222
|
-
ZodCodec: () => ZodCodec,
|
|
223
|
-
ZodCatch: () => ZodCatch,
|
|
224
|
-
ZodCUID2: () => ZodCUID2,
|
|
225
|
-
ZodCUID: () => ZodCUID,
|
|
226
|
-
ZodCIDRv6: () => ZodCIDRv6,
|
|
227
|
-
ZodCIDRv4: () => ZodCIDRv4,
|
|
228
|
-
ZodBoolean: () => ZodBoolean,
|
|
229
|
-
ZodBigIntFormat: () => ZodBigIntFormat,
|
|
230
|
-
ZodBigInt: () => ZodBigInt,
|
|
231
|
-
ZodBase64URL: () => ZodBase64URL,
|
|
232
|
-
ZodBase64: () => ZodBase64,
|
|
233
|
-
ZodArray: () => ZodArray,
|
|
234
|
-
ZodAny: () => ZodAny,
|
|
235
|
-
TimePrecision: () => TimePrecision,
|
|
236
|
-
NEVER: () => NEVER,
|
|
237
|
-
$output: () => $output,
|
|
19
|
+
$brand: () => $brand,
|
|
238
20
|
$input: () => $input,
|
|
239
|
-
$brand: () => $brand
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
// node_modules/zod/v4/core/index.js
|
|
243
|
-
var exports_core2 = {};
|
|
244
|
-
__export(exports_core2, {
|
|
245
|
-
version: () => version,
|
|
246
|
-
util: () => exports_util,
|
|
247
|
-
treeifyError: () => treeifyError,
|
|
248
|
-
toJSONSchema: () => toJSONSchema,
|
|
249
|
-
toDotPath: () => toDotPath,
|
|
250
|
-
safeParseAsync: () => safeParseAsync,
|
|
251
|
-
safeParse: () => safeParse,
|
|
252
|
-
safeEncodeAsync: () => safeEncodeAsync,
|
|
253
|
-
safeEncode: () => safeEncode,
|
|
254
|
-
safeDecodeAsync: () => safeDecodeAsync,
|
|
255
|
-
safeDecode: () => safeDecode,
|
|
256
|
-
registry: () => registry,
|
|
257
|
-
regexes: () => exports_regexes,
|
|
258
|
-
prettifyError: () => prettifyError,
|
|
259
|
-
parseAsync: () => parseAsync,
|
|
260
|
-
parse: () => parse,
|
|
261
|
-
locales: () => exports_locales,
|
|
262
|
-
isValidJWT: () => isValidJWT,
|
|
263
|
-
isValidBase64URL: () => isValidBase64URL,
|
|
264
|
-
isValidBase64: () => isValidBase64,
|
|
265
|
-
globalRegistry: () => globalRegistry,
|
|
266
|
-
globalConfig: () => globalConfig,
|
|
267
|
-
formatError: () => formatError,
|
|
268
|
-
flattenError: () => flattenError,
|
|
269
|
-
encodeAsync: () => encodeAsync,
|
|
270
|
-
encode: () => encode,
|
|
271
|
-
decodeAsync: () => decodeAsync,
|
|
272
|
-
decode: () => decode,
|
|
273
|
-
config: () => config,
|
|
274
|
-
clone: () => clone,
|
|
275
|
-
_xid: () => _xid,
|
|
276
|
-
_void: () => _void,
|
|
277
|
-
_uuidv7: () => _uuidv7,
|
|
278
|
-
_uuidv6: () => _uuidv6,
|
|
279
|
-
_uuidv4: () => _uuidv4,
|
|
280
|
-
_uuid: () => _uuid,
|
|
281
|
-
_url: () => _url,
|
|
282
|
-
_uppercase: () => _uppercase,
|
|
283
|
-
_unknown: () => _unknown,
|
|
284
|
-
_union: () => _union,
|
|
285
|
-
_undefined: () => _undefined2,
|
|
286
|
-
_ulid: () => _ulid,
|
|
287
|
-
_uint64: () => _uint64,
|
|
288
|
-
_uint32: () => _uint32,
|
|
289
|
-
_tuple: () => _tuple,
|
|
290
|
-
_trim: () => _trim,
|
|
291
|
-
_transform: () => _transform,
|
|
292
|
-
_toUpperCase: () => _toUpperCase,
|
|
293
|
-
_toLowerCase: () => _toLowerCase,
|
|
294
|
-
_templateLiteral: () => _templateLiteral,
|
|
295
|
-
_symbol: () => _symbol,
|
|
296
|
-
_superRefine: () => _superRefine,
|
|
297
|
-
_success: () => _success,
|
|
298
|
-
_stringbool: () => _stringbool,
|
|
299
|
-
_stringFormat: () => _stringFormat,
|
|
300
|
-
_string: () => _string,
|
|
301
|
-
_startsWith: () => _startsWith,
|
|
302
|
-
_size: () => _size,
|
|
303
|
-
_set: () => _set,
|
|
304
|
-
_safeParseAsync: () => _safeParseAsync,
|
|
305
|
-
_safeParse: () => _safeParse,
|
|
306
|
-
_safeEncodeAsync: () => _safeEncodeAsync,
|
|
307
|
-
_safeEncode: () => _safeEncode,
|
|
308
|
-
_safeDecodeAsync: () => _safeDecodeAsync,
|
|
309
|
-
_safeDecode: () => _safeDecode,
|
|
310
|
-
_regex: () => _regex,
|
|
311
|
-
_refine: () => _refine,
|
|
312
|
-
_record: () => _record,
|
|
313
|
-
_readonly: () => _readonly,
|
|
314
|
-
_property: () => _property,
|
|
315
|
-
_promise: () => _promise,
|
|
316
|
-
_positive: () => _positive,
|
|
317
|
-
_pipe: () => _pipe,
|
|
318
|
-
_parseAsync: () => _parseAsync,
|
|
319
|
-
_parse: () => _parse,
|
|
320
|
-
_overwrite: () => _overwrite,
|
|
321
|
-
_optional: () => _optional,
|
|
322
|
-
_number: () => _number,
|
|
323
|
-
_nullable: () => _nullable,
|
|
324
|
-
_null: () => _null2,
|
|
325
|
-
_normalize: () => _normalize,
|
|
326
|
-
_nonpositive: () => _nonpositive,
|
|
327
|
-
_nonoptional: () => _nonoptional,
|
|
328
|
-
_nonnegative: () => _nonnegative,
|
|
329
|
-
_never: () => _never,
|
|
330
|
-
_negative: () => _negative,
|
|
331
|
-
_nativeEnum: () => _nativeEnum,
|
|
332
|
-
_nanoid: () => _nanoid,
|
|
333
|
-
_nan: () => _nan,
|
|
334
|
-
_multipleOf: () => _multipleOf,
|
|
335
|
-
_minSize: () => _minSize,
|
|
336
|
-
_minLength: () => _minLength,
|
|
337
|
-
_min: () => _gte,
|
|
338
|
-
_mime: () => _mime,
|
|
339
|
-
_maxSize: () => _maxSize,
|
|
340
|
-
_maxLength: () => _maxLength,
|
|
341
|
-
_max: () => _lte,
|
|
342
|
-
_map: () => _map,
|
|
343
|
-
_lte: () => _lte,
|
|
344
|
-
_lt: () => _lt,
|
|
345
|
-
_lowercase: () => _lowercase,
|
|
346
|
-
_literal: () => _literal,
|
|
347
|
-
_length: () => _length,
|
|
348
|
-
_lazy: () => _lazy,
|
|
349
|
-
_ksuid: () => _ksuid,
|
|
350
|
-
_jwt: () => _jwt,
|
|
351
|
-
_isoTime: () => _isoTime,
|
|
352
|
-
_isoDuration: () => _isoDuration,
|
|
353
|
-
_isoDateTime: () => _isoDateTime,
|
|
354
|
-
_isoDate: () => _isoDate,
|
|
355
|
-
_ipv6: () => _ipv6,
|
|
356
|
-
_ipv4: () => _ipv4,
|
|
357
|
-
_intersection: () => _intersection,
|
|
358
|
-
_int64: () => _int64,
|
|
359
|
-
_int32: () => _int32,
|
|
360
|
-
_int: () => _int,
|
|
361
|
-
_includes: () => _includes,
|
|
362
|
-
_guid: () => _guid,
|
|
363
|
-
_gte: () => _gte,
|
|
364
|
-
_gt: () => _gt,
|
|
365
|
-
_float64: () => _float64,
|
|
366
|
-
_float32: () => _float32,
|
|
367
|
-
_file: () => _file,
|
|
368
|
-
_enum: () => _enum,
|
|
369
|
-
_endsWith: () => _endsWith,
|
|
370
|
-
_encodeAsync: () => _encodeAsync,
|
|
371
|
-
_encode: () => _encode,
|
|
372
|
-
_emoji: () => _emoji2,
|
|
373
|
-
_email: () => _email,
|
|
374
|
-
_e164: () => _e164,
|
|
375
|
-
_discriminatedUnion: () => _discriminatedUnion,
|
|
376
|
-
_default: () => _default,
|
|
377
|
-
_decodeAsync: () => _decodeAsync,
|
|
378
|
-
_decode: () => _decode,
|
|
379
|
-
_date: () => _date,
|
|
380
|
-
_custom: () => _custom,
|
|
381
|
-
_cuid2: () => _cuid2,
|
|
382
|
-
_cuid: () => _cuid,
|
|
383
|
-
_coercedString: () => _coercedString,
|
|
384
|
-
_coercedNumber: () => _coercedNumber,
|
|
385
|
-
_coercedDate: () => _coercedDate,
|
|
386
|
-
_coercedBoolean: () => _coercedBoolean,
|
|
387
|
-
_coercedBigint: () => _coercedBigint,
|
|
388
|
-
_cidrv6: () => _cidrv6,
|
|
389
|
-
_cidrv4: () => _cidrv4,
|
|
390
|
-
_check: () => _check,
|
|
391
|
-
_catch: () => _catch,
|
|
392
|
-
_boolean: () => _boolean,
|
|
393
|
-
_bigint: () => _bigint,
|
|
394
|
-
_base64url: () => _base64url,
|
|
395
|
-
_base64: () => _base64,
|
|
396
|
-
_array: () => _array,
|
|
397
|
-
_any: () => _any,
|
|
398
|
-
TimePrecision: () => TimePrecision,
|
|
399
|
-
NEVER: () => NEVER,
|
|
400
|
-
JSONSchemaGenerator: () => JSONSchemaGenerator,
|
|
401
|
-
JSONSchema: () => exports_json_schema,
|
|
402
|
-
Doc: () => Doc,
|
|
403
21
|
$output: () => $output,
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
22
|
+
NEVER: () => NEVER,
|
|
23
|
+
TimePrecision: () => TimePrecision,
|
|
24
|
+
ZodAny: () => ZodAny,
|
|
25
|
+
ZodArray: () => ZodArray,
|
|
26
|
+
ZodBase64: () => ZodBase64,
|
|
27
|
+
ZodBase64URL: () => ZodBase64URL,
|
|
28
|
+
ZodBigInt: () => ZodBigInt,
|
|
29
|
+
ZodBigIntFormat: () => ZodBigIntFormat,
|
|
30
|
+
ZodBoolean: () => ZodBoolean,
|
|
31
|
+
ZodCIDRv4: () => ZodCIDRv4,
|
|
32
|
+
ZodCIDRv6: () => ZodCIDRv6,
|
|
33
|
+
ZodCUID: () => ZodCUID,
|
|
34
|
+
ZodCUID2: () => ZodCUID2,
|
|
35
|
+
ZodCatch: () => ZodCatch,
|
|
36
|
+
ZodCodec: () => ZodCodec,
|
|
37
|
+
ZodCustom: () => ZodCustom,
|
|
38
|
+
ZodCustomStringFormat: () => ZodCustomStringFormat,
|
|
39
|
+
ZodDate: () => ZodDate,
|
|
40
|
+
ZodDefault: () => ZodDefault,
|
|
41
|
+
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
|
|
42
|
+
ZodE164: () => ZodE164,
|
|
43
|
+
ZodEmail: () => ZodEmail,
|
|
44
|
+
ZodEmoji: () => ZodEmoji,
|
|
45
|
+
ZodEnum: () => ZodEnum,
|
|
46
|
+
ZodError: () => ZodError,
|
|
47
|
+
ZodFile: () => ZodFile,
|
|
48
|
+
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
|
|
49
|
+
ZodFunction: () => ZodFunction,
|
|
50
|
+
ZodGUID: () => ZodGUID,
|
|
51
|
+
ZodIPv4: () => ZodIPv4,
|
|
52
|
+
ZodIPv6: () => ZodIPv6,
|
|
53
|
+
ZodISODate: () => ZodISODate,
|
|
54
|
+
ZodISODateTime: () => ZodISODateTime,
|
|
55
|
+
ZodISODuration: () => ZodISODuration,
|
|
56
|
+
ZodISOTime: () => ZodISOTime,
|
|
57
|
+
ZodIntersection: () => ZodIntersection,
|
|
58
|
+
ZodIssueCode: () => ZodIssueCode,
|
|
59
|
+
ZodJWT: () => ZodJWT,
|
|
60
|
+
ZodKSUID: () => ZodKSUID,
|
|
61
|
+
ZodLazy: () => ZodLazy,
|
|
62
|
+
ZodLiteral: () => ZodLiteral,
|
|
63
|
+
ZodMap: () => ZodMap,
|
|
64
|
+
ZodNaN: () => ZodNaN,
|
|
65
|
+
ZodNanoID: () => ZodNanoID,
|
|
66
|
+
ZodNever: () => ZodNever,
|
|
67
|
+
ZodNonOptional: () => ZodNonOptional,
|
|
68
|
+
ZodNull: () => ZodNull,
|
|
69
|
+
ZodNullable: () => ZodNullable,
|
|
70
|
+
ZodNumber: () => ZodNumber,
|
|
71
|
+
ZodNumberFormat: () => ZodNumberFormat,
|
|
72
|
+
ZodObject: () => ZodObject,
|
|
73
|
+
ZodOptional: () => ZodOptional,
|
|
74
|
+
ZodPipe: () => ZodPipe,
|
|
75
|
+
ZodPrefault: () => ZodPrefault,
|
|
76
|
+
ZodPromise: () => ZodPromise,
|
|
77
|
+
ZodReadonly: () => ZodReadonly,
|
|
78
|
+
ZodRealError: () => ZodRealError,
|
|
79
|
+
ZodRecord: () => ZodRecord,
|
|
80
|
+
ZodSet: () => ZodSet,
|
|
81
|
+
ZodString: () => ZodString,
|
|
82
|
+
ZodStringFormat: () => ZodStringFormat,
|
|
83
|
+
ZodSuccess: () => ZodSuccess,
|
|
84
|
+
ZodSymbol: () => ZodSymbol,
|
|
85
|
+
ZodTemplateLiteral: () => ZodTemplateLiteral,
|
|
86
|
+
ZodTransform: () => ZodTransform,
|
|
87
|
+
ZodTuple: () => ZodTuple,
|
|
88
|
+
ZodType: () => ZodType,
|
|
89
|
+
ZodULID: () => ZodULID,
|
|
90
|
+
ZodURL: () => ZodURL,
|
|
91
|
+
ZodUUID: () => ZodUUID,
|
|
92
|
+
ZodUndefined: () => ZodUndefined,
|
|
93
|
+
ZodUnion: () => ZodUnion,
|
|
94
|
+
ZodUnknown: () => ZodUnknown,
|
|
95
|
+
ZodVoid: () => ZodVoid,
|
|
96
|
+
ZodXID: () => ZodXID,
|
|
97
|
+
_ZodString: () => _ZodString,
|
|
98
|
+
_default: () => _default2,
|
|
99
|
+
_function: () => _function,
|
|
100
|
+
any: () => any,
|
|
101
|
+
array: () => array,
|
|
102
|
+
base64: () => base642,
|
|
103
|
+
base64url: () => base64url2,
|
|
104
|
+
bigint: () => bigint2,
|
|
105
|
+
boolean: () => boolean2,
|
|
106
|
+
catch: () => _catch2,
|
|
107
|
+
check: () => check,
|
|
108
|
+
cidrv4: () => cidrv42,
|
|
109
|
+
cidrv6: () => cidrv62,
|
|
110
|
+
clone: () => clone,
|
|
111
|
+
codec: () => codec,
|
|
112
|
+
coerce: () => exports_coerce,
|
|
113
|
+
config: () => config,
|
|
114
|
+
core: () => exports_core2,
|
|
115
|
+
cuid: () => cuid3,
|
|
116
|
+
cuid2: () => cuid22,
|
|
117
|
+
custom: () => custom,
|
|
118
|
+
date: () => date3,
|
|
119
|
+
decode: () => decode2,
|
|
120
|
+
decodeAsync: () => decodeAsync2,
|
|
121
|
+
discriminatedUnion: () => discriminatedUnion,
|
|
122
|
+
e164: () => e1642,
|
|
123
|
+
email: () => email2,
|
|
124
|
+
emoji: () => emoji2,
|
|
125
|
+
encode: () => encode2,
|
|
126
|
+
encodeAsync: () => encodeAsync2,
|
|
127
|
+
endsWith: () => _endsWith,
|
|
128
|
+
enum: () => _enum2,
|
|
129
|
+
file: () => file,
|
|
130
|
+
flattenError: () => flattenError,
|
|
131
|
+
float32: () => float32,
|
|
132
|
+
float64: () => float64,
|
|
133
|
+
formatError: () => formatError,
|
|
134
|
+
function: () => _function,
|
|
135
|
+
getErrorMap: () => getErrorMap,
|
|
136
|
+
globalRegistry: () => globalRegistry,
|
|
137
|
+
gt: () => _gt,
|
|
138
|
+
gte: () => _gte,
|
|
139
|
+
guid: () => guid2,
|
|
140
|
+
hash: () => hash,
|
|
141
|
+
hex: () => hex2,
|
|
142
|
+
hostname: () => hostname2,
|
|
143
|
+
httpUrl: () => httpUrl,
|
|
144
|
+
includes: () => _includes,
|
|
145
|
+
instanceof: () => _instanceof,
|
|
146
|
+
int: () => int,
|
|
147
|
+
int32: () => int32,
|
|
148
|
+
int64: () => int64,
|
|
149
|
+
intersection: () => intersection,
|
|
150
|
+
ipv4: () => ipv42,
|
|
151
|
+
ipv6: () => ipv62,
|
|
152
|
+
iso: () => exports_iso,
|
|
153
|
+
json: () => json,
|
|
154
|
+
jwt: () => jwt,
|
|
155
|
+
keyof: () => keyof,
|
|
156
|
+
ksuid: () => ksuid2,
|
|
157
|
+
lazy: () => lazy,
|
|
158
|
+
length: () => _length,
|
|
159
|
+
literal: () => literal,
|
|
160
|
+
locales: () => exports_locales,
|
|
161
|
+
looseObject: () => looseObject,
|
|
162
|
+
lowercase: () => _lowercase,
|
|
163
|
+
lt: () => _lt,
|
|
164
|
+
lte: () => _lte,
|
|
165
|
+
map: () => map,
|
|
166
|
+
maxLength: () => _maxLength,
|
|
167
|
+
maxSize: () => _maxSize,
|
|
168
|
+
mime: () => _mime,
|
|
169
|
+
minLength: () => _minLength,
|
|
170
|
+
minSize: () => _minSize,
|
|
171
|
+
multipleOf: () => _multipleOf,
|
|
172
|
+
nan: () => nan,
|
|
173
|
+
nanoid: () => nanoid2,
|
|
174
|
+
nativeEnum: () => nativeEnum,
|
|
175
|
+
negative: () => _negative,
|
|
176
|
+
never: () => never,
|
|
177
|
+
nonnegative: () => _nonnegative,
|
|
178
|
+
nonoptional: () => nonoptional,
|
|
179
|
+
nonpositive: () => _nonpositive,
|
|
180
|
+
normalize: () => _normalize,
|
|
181
|
+
null: () => _null3,
|
|
182
|
+
nullable: () => nullable,
|
|
183
|
+
nullish: () => nullish2,
|
|
184
|
+
number: () => number2,
|
|
185
|
+
object: () => object,
|
|
186
|
+
optional: () => optional,
|
|
187
|
+
overwrite: () => _overwrite,
|
|
188
|
+
parse: () => parse3,
|
|
189
|
+
parseAsync: () => parseAsync2,
|
|
190
|
+
partialRecord: () => partialRecord,
|
|
191
|
+
pipe: () => pipe,
|
|
192
|
+
positive: () => _positive,
|
|
193
|
+
prefault: () => prefault,
|
|
194
|
+
preprocess: () => preprocess,
|
|
195
|
+
prettifyError: () => prettifyError,
|
|
196
|
+
promise: () => promise,
|
|
197
|
+
property: () => _property,
|
|
198
|
+
readonly: () => readonly,
|
|
199
|
+
record: () => record,
|
|
200
|
+
refine: () => refine,
|
|
201
|
+
regex: () => _regex,
|
|
202
|
+
regexes: () => exports_regexes,
|
|
203
|
+
registry: () => registry,
|
|
204
|
+
safeDecode: () => safeDecode2,
|
|
205
|
+
safeDecodeAsync: () => safeDecodeAsync2,
|
|
206
|
+
safeEncode: () => safeEncode2,
|
|
207
|
+
safeEncodeAsync: () => safeEncodeAsync2,
|
|
208
|
+
safeParse: () => safeParse2,
|
|
209
|
+
safeParseAsync: () => safeParseAsync2,
|
|
210
|
+
set: () => set,
|
|
211
|
+
setErrorMap: () => setErrorMap,
|
|
212
|
+
size: () => _size,
|
|
213
|
+
startsWith: () => _startsWith,
|
|
214
|
+
strictObject: () => strictObject,
|
|
215
|
+
string: () => string2,
|
|
216
|
+
stringFormat: () => stringFormat,
|
|
217
|
+
stringbool: () => stringbool,
|
|
218
|
+
success: () => success,
|
|
219
|
+
superRefine: () => superRefine,
|
|
220
|
+
symbol: () => symbol,
|
|
221
|
+
templateLiteral: () => templateLiteral,
|
|
222
|
+
toJSONSchema: () => toJSONSchema,
|
|
223
|
+
toLowerCase: () => _toLowerCase,
|
|
224
|
+
toUpperCase: () => _toUpperCase,
|
|
225
|
+
transform: () => transform,
|
|
226
|
+
treeifyError: () => treeifyError,
|
|
227
|
+
trim: () => _trim,
|
|
228
|
+
tuple: () => tuple,
|
|
229
|
+
uint32: () => uint32,
|
|
230
|
+
uint64: () => uint64,
|
|
231
|
+
ulid: () => ulid2,
|
|
232
|
+
undefined: () => _undefined3,
|
|
233
|
+
union: () => union,
|
|
234
|
+
unknown: () => unknown,
|
|
235
|
+
uppercase: () => _uppercase,
|
|
236
|
+
url: () => url,
|
|
237
|
+
util: () => exports_util,
|
|
238
|
+
uuid: () => uuid2,
|
|
239
|
+
uuidv4: () => uuidv4,
|
|
240
|
+
uuidv6: () => uuidv6,
|
|
241
|
+
uuidv7: () => uuidv7,
|
|
242
|
+
void: () => _void2,
|
|
243
|
+
xid: () => xid2
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// node_modules/zod/v4/core/index.js
|
|
247
|
+
var exports_core2 = {};
|
|
248
|
+
__export(exports_core2, {
|
|
249
|
+
$ZodAny: () => $ZodAny,
|
|
502
250
|
$ZodArray: () => $ZodArray,
|
|
503
|
-
$
|
|
251
|
+
$ZodAsyncError: () => $ZodAsyncError,
|
|
252
|
+
$ZodBase64: () => $ZodBase64,
|
|
253
|
+
$ZodBase64URL: () => $ZodBase64URL,
|
|
254
|
+
$ZodBigInt: () => $ZodBigInt,
|
|
255
|
+
$ZodBigIntFormat: () => $ZodBigIntFormat,
|
|
256
|
+
$ZodBoolean: () => $ZodBoolean,
|
|
257
|
+
$ZodCIDRv4: () => $ZodCIDRv4,
|
|
258
|
+
$ZodCIDRv6: () => $ZodCIDRv6,
|
|
259
|
+
$ZodCUID: () => $ZodCUID,
|
|
260
|
+
$ZodCUID2: () => $ZodCUID2,
|
|
261
|
+
$ZodCatch: () => $ZodCatch,
|
|
262
|
+
$ZodCheck: () => $ZodCheck,
|
|
263
|
+
$ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
|
|
264
|
+
$ZodCheckEndsWith: () => $ZodCheckEndsWith,
|
|
265
|
+
$ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
|
|
266
|
+
$ZodCheckIncludes: () => $ZodCheckIncludes,
|
|
267
|
+
$ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
|
|
268
|
+
$ZodCheckLessThan: () => $ZodCheckLessThan,
|
|
269
|
+
$ZodCheckLowerCase: () => $ZodCheckLowerCase,
|
|
270
|
+
$ZodCheckMaxLength: () => $ZodCheckMaxLength,
|
|
271
|
+
$ZodCheckMaxSize: () => $ZodCheckMaxSize,
|
|
272
|
+
$ZodCheckMimeType: () => $ZodCheckMimeType,
|
|
273
|
+
$ZodCheckMinLength: () => $ZodCheckMinLength,
|
|
274
|
+
$ZodCheckMinSize: () => $ZodCheckMinSize,
|
|
275
|
+
$ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
|
|
276
|
+
$ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
|
|
277
|
+
$ZodCheckOverwrite: () => $ZodCheckOverwrite,
|
|
278
|
+
$ZodCheckProperty: () => $ZodCheckProperty,
|
|
279
|
+
$ZodCheckRegex: () => $ZodCheckRegex,
|
|
280
|
+
$ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
|
|
281
|
+
$ZodCheckStartsWith: () => $ZodCheckStartsWith,
|
|
282
|
+
$ZodCheckStringFormat: () => $ZodCheckStringFormat,
|
|
283
|
+
$ZodCheckUpperCase: () => $ZodCheckUpperCase,
|
|
284
|
+
$ZodCodec: () => $ZodCodec,
|
|
285
|
+
$ZodCustom: () => $ZodCustom,
|
|
286
|
+
$ZodCustomStringFormat: () => $ZodCustomStringFormat,
|
|
287
|
+
$ZodDate: () => $ZodDate,
|
|
288
|
+
$ZodDefault: () => $ZodDefault,
|
|
289
|
+
$ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
|
|
290
|
+
$ZodE164: () => $ZodE164,
|
|
291
|
+
$ZodEmail: () => $ZodEmail,
|
|
292
|
+
$ZodEmoji: () => $ZodEmoji,
|
|
293
|
+
$ZodEncodeError: () => $ZodEncodeError,
|
|
294
|
+
$ZodEnum: () => $ZodEnum,
|
|
295
|
+
$ZodError: () => $ZodError,
|
|
296
|
+
$ZodFile: () => $ZodFile,
|
|
297
|
+
$ZodFunction: () => $ZodFunction,
|
|
298
|
+
$ZodGUID: () => $ZodGUID,
|
|
299
|
+
$ZodIPv4: () => $ZodIPv4,
|
|
300
|
+
$ZodIPv6: () => $ZodIPv6,
|
|
301
|
+
$ZodISODate: () => $ZodISODate,
|
|
302
|
+
$ZodISODateTime: () => $ZodISODateTime,
|
|
303
|
+
$ZodISODuration: () => $ZodISODuration,
|
|
304
|
+
$ZodISOTime: () => $ZodISOTime,
|
|
305
|
+
$ZodIntersection: () => $ZodIntersection,
|
|
306
|
+
$ZodJWT: () => $ZodJWT,
|
|
307
|
+
$ZodKSUID: () => $ZodKSUID,
|
|
308
|
+
$ZodLazy: () => $ZodLazy,
|
|
309
|
+
$ZodLiteral: () => $ZodLiteral,
|
|
310
|
+
$ZodMap: () => $ZodMap,
|
|
311
|
+
$ZodNaN: () => $ZodNaN,
|
|
312
|
+
$ZodNanoID: () => $ZodNanoID,
|
|
313
|
+
$ZodNever: () => $ZodNever,
|
|
314
|
+
$ZodNonOptional: () => $ZodNonOptional,
|
|
315
|
+
$ZodNull: () => $ZodNull,
|
|
316
|
+
$ZodNullable: () => $ZodNullable,
|
|
317
|
+
$ZodNumber: () => $ZodNumber,
|
|
318
|
+
$ZodNumberFormat: () => $ZodNumberFormat,
|
|
319
|
+
$ZodObject: () => $ZodObject,
|
|
320
|
+
$ZodObjectJIT: () => $ZodObjectJIT,
|
|
321
|
+
$ZodOptional: () => $ZodOptional,
|
|
322
|
+
$ZodPipe: () => $ZodPipe,
|
|
323
|
+
$ZodPrefault: () => $ZodPrefault,
|
|
324
|
+
$ZodPromise: () => $ZodPromise,
|
|
325
|
+
$ZodReadonly: () => $ZodReadonly,
|
|
326
|
+
$ZodRealError: () => $ZodRealError,
|
|
327
|
+
$ZodRecord: () => $ZodRecord,
|
|
328
|
+
$ZodRegistry: () => $ZodRegistry,
|
|
329
|
+
$ZodSet: () => $ZodSet,
|
|
330
|
+
$ZodString: () => $ZodString,
|
|
331
|
+
$ZodStringFormat: () => $ZodStringFormat,
|
|
332
|
+
$ZodSuccess: () => $ZodSuccess,
|
|
333
|
+
$ZodSymbol: () => $ZodSymbol,
|
|
334
|
+
$ZodTemplateLiteral: () => $ZodTemplateLiteral,
|
|
335
|
+
$ZodTransform: () => $ZodTransform,
|
|
336
|
+
$ZodTuple: () => $ZodTuple,
|
|
337
|
+
$ZodType: () => $ZodType,
|
|
338
|
+
$ZodULID: () => $ZodULID,
|
|
339
|
+
$ZodURL: () => $ZodURL,
|
|
340
|
+
$ZodUUID: () => $ZodUUID,
|
|
341
|
+
$ZodUndefined: () => $ZodUndefined,
|
|
342
|
+
$ZodUnion: () => $ZodUnion,
|
|
343
|
+
$ZodUnknown: () => $ZodUnknown,
|
|
344
|
+
$ZodVoid: () => $ZodVoid,
|
|
345
|
+
$ZodXID: () => $ZodXID,
|
|
346
|
+
$brand: () => $brand,
|
|
347
|
+
$constructor: () => $constructor,
|
|
348
|
+
$input: () => $input,
|
|
349
|
+
$output: () => $output,
|
|
350
|
+
Doc: () => Doc,
|
|
351
|
+
JSONSchema: () => exports_json_schema,
|
|
352
|
+
JSONSchemaGenerator: () => JSONSchemaGenerator,
|
|
353
|
+
NEVER: () => NEVER,
|
|
354
|
+
TimePrecision: () => TimePrecision,
|
|
355
|
+
_any: () => _any,
|
|
356
|
+
_array: () => _array,
|
|
357
|
+
_base64: () => _base64,
|
|
358
|
+
_base64url: () => _base64url,
|
|
359
|
+
_bigint: () => _bigint,
|
|
360
|
+
_boolean: () => _boolean,
|
|
361
|
+
_catch: () => _catch,
|
|
362
|
+
_check: () => _check,
|
|
363
|
+
_cidrv4: () => _cidrv4,
|
|
364
|
+
_cidrv6: () => _cidrv6,
|
|
365
|
+
_coercedBigint: () => _coercedBigint,
|
|
366
|
+
_coercedBoolean: () => _coercedBoolean,
|
|
367
|
+
_coercedDate: () => _coercedDate,
|
|
368
|
+
_coercedNumber: () => _coercedNumber,
|
|
369
|
+
_coercedString: () => _coercedString,
|
|
370
|
+
_cuid: () => _cuid,
|
|
371
|
+
_cuid2: () => _cuid2,
|
|
372
|
+
_custom: () => _custom,
|
|
373
|
+
_date: () => _date,
|
|
374
|
+
_decode: () => _decode,
|
|
375
|
+
_decodeAsync: () => _decodeAsync,
|
|
376
|
+
_default: () => _default,
|
|
377
|
+
_discriminatedUnion: () => _discriminatedUnion,
|
|
378
|
+
_e164: () => _e164,
|
|
379
|
+
_email: () => _email,
|
|
380
|
+
_emoji: () => _emoji2,
|
|
381
|
+
_encode: () => _encode,
|
|
382
|
+
_encodeAsync: () => _encodeAsync,
|
|
383
|
+
_endsWith: () => _endsWith,
|
|
384
|
+
_enum: () => _enum,
|
|
385
|
+
_file: () => _file,
|
|
386
|
+
_float32: () => _float32,
|
|
387
|
+
_float64: () => _float64,
|
|
388
|
+
_gt: () => _gt,
|
|
389
|
+
_gte: () => _gte,
|
|
390
|
+
_guid: () => _guid,
|
|
391
|
+
_includes: () => _includes,
|
|
392
|
+
_int: () => _int,
|
|
393
|
+
_int32: () => _int32,
|
|
394
|
+
_int64: () => _int64,
|
|
395
|
+
_intersection: () => _intersection,
|
|
396
|
+
_ipv4: () => _ipv4,
|
|
397
|
+
_ipv6: () => _ipv6,
|
|
398
|
+
_isoDate: () => _isoDate,
|
|
399
|
+
_isoDateTime: () => _isoDateTime,
|
|
400
|
+
_isoDuration: () => _isoDuration,
|
|
401
|
+
_isoTime: () => _isoTime,
|
|
402
|
+
_jwt: () => _jwt,
|
|
403
|
+
_ksuid: () => _ksuid,
|
|
404
|
+
_lazy: () => _lazy,
|
|
405
|
+
_length: () => _length,
|
|
406
|
+
_literal: () => _literal,
|
|
407
|
+
_lowercase: () => _lowercase,
|
|
408
|
+
_lt: () => _lt,
|
|
409
|
+
_lte: () => _lte,
|
|
410
|
+
_map: () => _map,
|
|
411
|
+
_max: () => _lte,
|
|
412
|
+
_maxLength: () => _maxLength,
|
|
413
|
+
_maxSize: () => _maxSize,
|
|
414
|
+
_mime: () => _mime,
|
|
415
|
+
_min: () => _gte,
|
|
416
|
+
_minLength: () => _minLength,
|
|
417
|
+
_minSize: () => _minSize,
|
|
418
|
+
_multipleOf: () => _multipleOf,
|
|
419
|
+
_nan: () => _nan,
|
|
420
|
+
_nanoid: () => _nanoid,
|
|
421
|
+
_nativeEnum: () => _nativeEnum,
|
|
422
|
+
_negative: () => _negative,
|
|
423
|
+
_never: () => _never,
|
|
424
|
+
_nonnegative: () => _nonnegative,
|
|
425
|
+
_nonoptional: () => _nonoptional,
|
|
426
|
+
_nonpositive: () => _nonpositive,
|
|
427
|
+
_normalize: () => _normalize,
|
|
428
|
+
_null: () => _null2,
|
|
429
|
+
_nullable: () => _nullable,
|
|
430
|
+
_number: () => _number,
|
|
431
|
+
_optional: () => _optional,
|
|
432
|
+
_overwrite: () => _overwrite,
|
|
433
|
+
_parse: () => _parse,
|
|
434
|
+
_parseAsync: () => _parseAsync,
|
|
435
|
+
_pipe: () => _pipe,
|
|
436
|
+
_positive: () => _positive,
|
|
437
|
+
_promise: () => _promise,
|
|
438
|
+
_property: () => _property,
|
|
439
|
+
_readonly: () => _readonly,
|
|
440
|
+
_record: () => _record,
|
|
441
|
+
_refine: () => _refine,
|
|
442
|
+
_regex: () => _regex,
|
|
443
|
+
_safeDecode: () => _safeDecode,
|
|
444
|
+
_safeDecodeAsync: () => _safeDecodeAsync,
|
|
445
|
+
_safeEncode: () => _safeEncode,
|
|
446
|
+
_safeEncodeAsync: () => _safeEncodeAsync,
|
|
447
|
+
_safeParse: () => _safeParse,
|
|
448
|
+
_safeParseAsync: () => _safeParseAsync,
|
|
449
|
+
_set: () => _set,
|
|
450
|
+
_size: () => _size,
|
|
451
|
+
_startsWith: () => _startsWith,
|
|
452
|
+
_string: () => _string,
|
|
453
|
+
_stringFormat: () => _stringFormat,
|
|
454
|
+
_stringbool: () => _stringbool,
|
|
455
|
+
_success: () => _success,
|
|
456
|
+
_superRefine: () => _superRefine,
|
|
457
|
+
_symbol: () => _symbol,
|
|
458
|
+
_templateLiteral: () => _templateLiteral,
|
|
459
|
+
_toLowerCase: () => _toLowerCase,
|
|
460
|
+
_toUpperCase: () => _toUpperCase,
|
|
461
|
+
_transform: () => _transform,
|
|
462
|
+
_trim: () => _trim,
|
|
463
|
+
_tuple: () => _tuple,
|
|
464
|
+
_uint32: () => _uint32,
|
|
465
|
+
_uint64: () => _uint64,
|
|
466
|
+
_ulid: () => _ulid,
|
|
467
|
+
_undefined: () => _undefined2,
|
|
468
|
+
_union: () => _union,
|
|
469
|
+
_unknown: () => _unknown,
|
|
470
|
+
_uppercase: () => _uppercase,
|
|
471
|
+
_url: () => _url,
|
|
472
|
+
_uuid: () => _uuid,
|
|
473
|
+
_uuidv4: () => _uuidv4,
|
|
474
|
+
_uuidv6: () => _uuidv6,
|
|
475
|
+
_uuidv7: () => _uuidv7,
|
|
476
|
+
_void: () => _void,
|
|
477
|
+
_xid: () => _xid,
|
|
478
|
+
clone: () => clone,
|
|
479
|
+
config: () => config,
|
|
480
|
+
decode: () => decode,
|
|
481
|
+
decodeAsync: () => decodeAsync,
|
|
482
|
+
encode: () => encode,
|
|
483
|
+
encodeAsync: () => encodeAsync,
|
|
484
|
+
flattenError: () => flattenError,
|
|
485
|
+
formatError: () => formatError,
|
|
486
|
+
globalConfig: () => globalConfig,
|
|
487
|
+
globalRegistry: () => globalRegistry,
|
|
488
|
+
isValidBase64: () => isValidBase64,
|
|
489
|
+
isValidBase64URL: () => isValidBase64URL,
|
|
490
|
+
isValidJWT: () => isValidJWT,
|
|
491
|
+
locales: () => exports_locales,
|
|
492
|
+
parse: () => parse,
|
|
493
|
+
parseAsync: () => parseAsync,
|
|
494
|
+
prettifyError: () => prettifyError,
|
|
495
|
+
regexes: () => exports_regexes,
|
|
496
|
+
registry: () => registry,
|
|
497
|
+
safeDecode: () => safeDecode,
|
|
498
|
+
safeDecodeAsync: () => safeDecodeAsync,
|
|
499
|
+
safeEncode: () => safeEncode,
|
|
500
|
+
safeEncodeAsync: () => safeEncodeAsync,
|
|
501
|
+
safeParse: () => safeParse,
|
|
502
|
+
safeParseAsync: () => safeParseAsync,
|
|
503
|
+
toDotPath: () => toDotPath,
|
|
504
|
+
toJSONSchema: () => toJSONSchema,
|
|
505
|
+
treeifyError: () => treeifyError,
|
|
506
|
+
util: () => exports_util,
|
|
507
|
+
version: () => version
|
|
504
508
|
});
|
|
505
509
|
|
|
506
510
|
// node_modules/zod/v4/core/core.js
|
|
@@ -554,85 +558,85 @@ var $brand = Symbol("zod_brand");
|
|
|
554
558
|
|
|
555
559
|
class $ZodAsyncError extends Error {
|
|
556
560
|
constructor() {
|
|
557
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
class $ZodEncodeError extends Error {
|
|
562
|
-
constructor(name) {
|
|
563
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
564
|
-
this.name = "ZodEncodeError";
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
var globalConfig = {};
|
|
568
|
-
function config(newConfig) {
|
|
569
|
-
if (newConfig)
|
|
570
|
-
Object.assign(globalConfig, newConfig);
|
|
571
|
-
return globalConfig;
|
|
572
|
-
}
|
|
573
|
-
// node_modules/zod/v4/core/util.js
|
|
574
|
-
var exports_util = {};
|
|
575
|
-
__export(exports_util, {
|
|
576
|
-
|
|
577
|
-
uint8ArrayToHex: () => uint8ArrayToHex,
|
|
578
|
-
uint8ArrayToBase64url: () => uint8ArrayToBase64url,
|
|
579
|
-
uint8ArrayToBase64: () => uint8ArrayToBase64,
|
|
580
|
-
stringifyPrimitive: () => stringifyPrimitive,
|
|
581
|
-
shallowClone: () => shallowClone,
|
|
582
|
-
safeExtend: () => safeExtend,
|
|
583
|
-
required: () => required,
|
|
584
|
-
randomString: () => randomString,
|
|
585
|
-
propertyKeyTypes: () => propertyKeyTypes,
|
|
586
|
-
promiseAllObject: () => promiseAllObject,
|
|
587
|
-
primitiveTypes: () => primitiveTypes,
|
|
588
|
-
prefixIssues: () => prefixIssues,
|
|
589
|
-
pick: () => pick,
|
|
590
|
-
partial: () => partial,
|
|
591
|
-
optionalKeys: () => optionalKeys,
|
|
592
|
-
omit: () => omit,
|
|
593
|
-
objectClone: () => objectClone,
|
|
594
|
-
numKeys: () => numKeys,
|
|
595
|
-
nullish: () => nullish,
|
|
596
|
-
normalizeParams: () => normalizeParams,
|
|
597
|
-
mergeDefs: () => mergeDefs,
|
|
598
|
-
merge: () => merge,
|
|
599
|
-
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
600
|
-
joinValues: () => joinValues,
|
|
601
|
-
issue: () => issue,
|
|
602
|
-
isPlainObject: () => isPlainObject,
|
|
603
|
-
isObject: () => isObject,
|
|
604
|
-
hexToUint8Array: () => hexToUint8Array,
|
|
605
|
-
getSizableOrigin: () => getSizableOrigin,
|
|
606
|
-
getParsedType: () => getParsedType,
|
|
607
|
-
getLengthableOrigin: () => getLengthableOrigin,
|
|
608
|
-
getEnumValues: () => getEnumValues,
|
|
609
|
-
getElementAtPath: () => getElementAtPath,
|
|
610
|
-
floatSafeRemainder: () => floatSafeRemainder,
|
|
611
|
-
finalizeIssue: () => finalizeIssue,
|
|
612
|
-
extend: () => extend,
|
|
613
|
-
escapeRegex: () => escapeRegex,
|
|
614
|
-
esc: () => esc,
|
|
615
|
-
defineLazy: () => defineLazy,
|
|
616
|
-
createTransparentProxy: () => createTransparentProxy,
|
|
617
|
-
cloneDef: () => cloneDef,
|
|
618
|
-
clone: () => clone,
|
|
619
|
-
cleanRegex: () => cleanRegex,
|
|
620
|
-
cleanEnum: () => cleanEnum,
|
|
621
|
-
captureStackTrace: () => captureStackTrace,
|
|
622
|
-
cached: () => cached,
|
|
623
|
-
base64urlToUint8Array: () => base64urlToUint8Array,
|
|
624
|
-
base64ToUint8Array: () => base64ToUint8Array,
|
|
625
|
-
assignProp: () => assignProp,
|
|
626
|
-
assertNotEqual: () => assertNotEqual,
|
|
627
|
-
assertNever: () => assertNever,
|
|
628
|
-
assertIs: () => assertIs,
|
|
629
|
-
assertEqual: () => assertEqual,
|
|
630
|
-
assert: () => assert,
|
|
631
|
-
allowsEval: () => allowsEval,
|
|
632
|
-
aborted: () => aborted,
|
|
633
|
-
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
|
|
561
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
class $ZodEncodeError extends Error {
|
|
566
|
+
constructor(name) {
|
|
567
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
568
|
+
this.name = "ZodEncodeError";
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
var globalConfig = {};
|
|
572
|
+
function config(newConfig) {
|
|
573
|
+
if (newConfig)
|
|
574
|
+
Object.assign(globalConfig, newConfig);
|
|
575
|
+
return globalConfig;
|
|
576
|
+
}
|
|
577
|
+
// node_modules/zod/v4/core/util.js
|
|
578
|
+
var exports_util = {};
|
|
579
|
+
__export(exports_util, {
|
|
580
|
+
BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
|
|
634
581
|
Class: () => Class,
|
|
635
|
-
|
|
582
|
+
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
|
|
583
|
+
aborted: () => aborted,
|
|
584
|
+
allowsEval: () => allowsEval,
|
|
585
|
+
assert: () => assert,
|
|
586
|
+
assertEqual: () => assertEqual,
|
|
587
|
+
assertIs: () => assertIs,
|
|
588
|
+
assertNever: () => assertNever,
|
|
589
|
+
assertNotEqual: () => assertNotEqual,
|
|
590
|
+
assignProp: () => assignProp,
|
|
591
|
+
base64ToUint8Array: () => base64ToUint8Array,
|
|
592
|
+
base64urlToUint8Array: () => base64urlToUint8Array,
|
|
593
|
+
cached: () => cached,
|
|
594
|
+
captureStackTrace: () => captureStackTrace,
|
|
595
|
+
cleanEnum: () => cleanEnum,
|
|
596
|
+
cleanRegex: () => cleanRegex,
|
|
597
|
+
clone: () => clone,
|
|
598
|
+
cloneDef: () => cloneDef,
|
|
599
|
+
createTransparentProxy: () => createTransparentProxy,
|
|
600
|
+
defineLazy: () => defineLazy,
|
|
601
|
+
esc: () => esc,
|
|
602
|
+
escapeRegex: () => escapeRegex,
|
|
603
|
+
extend: () => extend,
|
|
604
|
+
finalizeIssue: () => finalizeIssue,
|
|
605
|
+
floatSafeRemainder: () => floatSafeRemainder,
|
|
606
|
+
getElementAtPath: () => getElementAtPath,
|
|
607
|
+
getEnumValues: () => getEnumValues,
|
|
608
|
+
getLengthableOrigin: () => getLengthableOrigin,
|
|
609
|
+
getParsedType: () => getParsedType,
|
|
610
|
+
getSizableOrigin: () => getSizableOrigin,
|
|
611
|
+
hexToUint8Array: () => hexToUint8Array,
|
|
612
|
+
isObject: () => isObject,
|
|
613
|
+
isPlainObject: () => isPlainObject,
|
|
614
|
+
issue: () => issue,
|
|
615
|
+
joinValues: () => joinValues,
|
|
616
|
+
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
617
|
+
merge: () => merge,
|
|
618
|
+
mergeDefs: () => mergeDefs,
|
|
619
|
+
normalizeParams: () => normalizeParams,
|
|
620
|
+
nullish: () => nullish,
|
|
621
|
+
numKeys: () => numKeys,
|
|
622
|
+
objectClone: () => objectClone,
|
|
623
|
+
omit: () => omit,
|
|
624
|
+
optionalKeys: () => optionalKeys,
|
|
625
|
+
partial: () => partial,
|
|
626
|
+
pick: () => pick,
|
|
627
|
+
prefixIssues: () => prefixIssues,
|
|
628
|
+
primitiveTypes: () => primitiveTypes,
|
|
629
|
+
promiseAllObject: () => promiseAllObject,
|
|
630
|
+
propertyKeyTypes: () => propertyKeyTypes,
|
|
631
|
+
randomString: () => randomString,
|
|
632
|
+
required: () => required,
|
|
633
|
+
safeExtend: () => safeExtend,
|
|
634
|
+
shallowClone: () => shallowClone,
|
|
635
|
+
stringifyPrimitive: () => stringifyPrimitive,
|
|
636
|
+
uint8ArrayToBase64: () => uint8ArrayToBase64,
|
|
637
|
+
uint8ArrayToBase64url: () => uint8ArrayToBase64url,
|
|
638
|
+
uint8ArrayToHex: () => uint8ArrayToHex,
|
|
639
|
+
unwrapMessage: () => unwrapMessage
|
|
636
640
|
});
|
|
637
641
|
function assertEqual(val) {
|
|
638
642
|
return val;
|
|
@@ -1432,63 +1436,63 @@ var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
|
|
|
1432
1436
|
// node_modules/zod/v4/core/regexes.js
|
|
1433
1437
|
var exports_regexes = {};
|
|
1434
1438
|
__export(exports_regexes, {
|
|
1435
|
-
|
|
1436
|
-
uuid7: () => uuid7,
|
|
1437
|
-
uuid6: () => uuid6,
|
|
1438
|
-
uuid4: () => uuid4,
|
|
1439
|
-
uuid: () => uuid,
|
|
1440
|
-
uppercase: () => uppercase,
|
|
1441
|
-
unicodeEmail: () => unicodeEmail,
|
|
1442
|
-
undefined: () => _undefined,
|
|
1443
|
-
ulid: () => ulid,
|
|
1444
|
-
time: () => time,
|
|
1445
|
-
string: () => string,
|
|
1446
|
-
sha512_hex: () => sha512_hex,
|
|
1447
|
-
sha512_base64url: () => sha512_base64url,
|
|
1448
|
-
sha512_base64: () => sha512_base64,
|
|
1449
|
-
sha384_hex: () => sha384_hex,
|
|
1450
|
-
sha384_base64url: () => sha384_base64url,
|
|
1451
|
-
sha384_base64: () => sha384_base64,
|
|
1452
|
-
sha256_hex: () => sha256_hex,
|
|
1453
|
-
sha256_base64url: () => sha256_base64url,
|
|
1454
|
-
sha256_base64: () => sha256_base64,
|
|
1455
|
-
sha1_hex: () => sha1_hex,
|
|
1456
|
-
sha1_base64url: () => sha1_base64url,
|
|
1457
|
-
sha1_base64: () => sha1_base64,
|
|
1458
|
-
rfc5322Email: () => rfc5322Email,
|
|
1459
|
-
number: () => number,
|
|
1460
|
-
null: () => _null,
|
|
1461
|
-
nanoid: () => nanoid,
|
|
1462
|
-
md5_hex: () => md5_hex,
|
|
1463
|
-
md5_base64url: () => md5_base64url,
|
|
1464
|
-
md5_base64: () => md5_base64,
|
|
1465
|
-
lowercase: () => lowercase,
|
|
1466
|
-
ksuid: () => ksuid,
|
|
1467
|
-
ipv6: () => ipv6,
|
|
1468
|
-
ipv4: () => ipv4,
|
|
1469
|
-
integer: () => integer,
|
|
1470
|
-
idnEmail: () => idnEmail,
|
|
1471
|
-
html5Email: () => html5Email,
|
|
1472
|
-
hostname: () => hostname,
|
|
1473
|
-
hex: () => hex,
|
|
1474
|
-
guid: () => guid,
|
|
1475
|
-
extendedDuration: () => extendedDuration,
|
|
1476
|
-
emoji: () => emoji,
|
|
1477
|
-
email: () => email,
|
|
1478
|
-
e164: () => e164,
|
|
1479
|
-
duration: () => duration,
|
|
1480
|
-
domain: () => domain,
|
|
1481
|
-
datetime: () => datetime,
|
|
1482
|
-
date: () => date,
|
|
1483
|
-
cuid2: () => cuid2,
|
|
1484
|
-
cuid: () => cuid,
|
|
1485
|
-
cidrv6: () => cidrv6,
|
|
1486
|
-
cidrv4: () => cidrv4,
|
|
1487
|
-
browserEmail: () => browserEmail,
|
|
1488
|
-
boolean: () => boolean,
|
|
1489
|
-
bigint: () => bigint,
|
|
1439
|
+
base64: () => base64,
|
|
1490
1440
|
base64url: () => base64url,
|
|
1491
|
-
|
|
1441
|
+
bigint: () => bigint,
|
|
1442
|
+
boolean: () => boolean,
|
|
1443
|
+
browserEmail: () => browserEmail,
|
|
1444
|
+
cidrv4: () => cidrv4,
|
|
1445
|
+
cidrv6: () => cidrv6,
|
|
1446
|
+
cuid: () => cuid,
|
|
1447
|
+
cuid2: () => cuid2,
|
|
1448
|
+
date: () => date,
|
|
1449
|
+
datetime: () => datetime,
|
|
1450
|
+
domain: () => domain,
|
|
1451
|
+
duration: () => duration,
|
|
1452
|
+
e164: () => e164,
|
|
1453
|
+
email: () => email,
|
|
1454
|
+
emoji: () => emoji,
|
|
1455
|
+
extendedDuration: () => extendedDuration,
|
|
1456
|
+
guid: () => guid,
|
|
1457
|
+
hex: () => hex,
|
|
1458
|
+
hostname: () => hostname,
|
|
1459
|
+
html5Email: () => html5Email,
|
|
1460
|
+
idnEmail: () => idnEmail,
|
|
1461
|
+
integer: () => integer,
|
|
1462
|
+
ipv4: () => ipv4,
|
|
1463
|
+
ipv6: () => ipv6,
|
|
1464
|
+
ksuid: () => ksuid,
|
|
1465
|
+
lowercase: () => lowercase,
|
|
1466
|
+
md5_base64: () => md5_base64,
|
|
1467
|
+
md5_base64url: () => md5_base64url,
|
|
1468
|
+
md5_hex: () => md5_hex,
|
|
1469
|
+
nanoid: () => nanoid,
|
|
1470
|
+
null: () => _null,
|
|
1471
|
+
number: () => number,
|
|
1472
|
+
rfc5322Email: () => rfc5322Email,
|
|
1473
|
+
sha1_base64: () => sha1_base64,
|
|
1474
|
+
sha1_base64url: () => sha1_base64url,
|
|
1475
|
+
sha1_hex: () => sha1_hex,
|
|
1476
|
+
sha256_base64: () => sha256_base64,
|
|
1477
|
+
sha256_base64url: () => sha256_base64url,
|
|
1478
|
+
sha256_hex: () => sha256_hex,
|
|
1479
|
+
sha384_base64: () => sha384_base64,
|
|
1480
|
+
sha384_base64url: () => sha384_base64url,
|
|
1481
|
+
sha384_hex: () => sha384_hex,
|
|
1482
|
+
sha512_base64: () => sha512_base64,
|
|
1483
|
+
sha512_base64url: () => sha512_base64url,
|
|
1484
|
+
sha512_hex: () => sha512_hex,
|
|
1485
|
+
string: () => string,
|
|
1486
|
+
time: () => time,
|
|
1487
|
+
ulid: () => ulid,
|
|
1488
|
+
undefined: () => _undefined,
|
|
1489
|
+
unicodeEmail: () => unicodeEmail,
|
|
1490
|
+
uppercase: () => uppercase,
|
|
1491
|
+
uuid: () => uuid,
|
|
1492
|
+
uuid4: () => uuid4,
|
|
1493
|
+
uuid6: () => uuid6,
|
|
1494
|
+
uuid7: () => uuid7,
|
|
1495
|
+
xid: () => xid
|
|
1492
1496
|
});
|
|
1493
1497
|
var cuid = /^[cC][^\s-]{8,}$/;
|
|
1494
1498
|
var cuid2 = /^[0-9a-z]+$/;
|
|
@@ -3993,52 +3997,52 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
3993
3997
|
// node_modules/zod/v4/locales/index.js
|
|
3994
3998
|
var exports_locales = {};
|
|
3995
3999
|
__export(exports_locales, {
|
|
3996
|
-
|
|
3997
|
-
zhCN: () => zh_CN_default,
|
|
3998
|
-
yo: () => yo_default,
|
|
3999
|
-
vi: () => vi_default,
|
|
4000
|
-
ur: () => ur_default,
|
|
4001
|
-
uk: () => uk_default,
|
|
4002
|
-
ua: () => ua_default,
|
|
4003
|
-
tr: () => tr_default,
|
|
4004
|
-
th: () => th_default,
|
|
4005
|
-
ta: () => ta_default,
|
|
4006
|
-
sv: () => sv_default,
|
|
4007
|
-
sl: () => sl_default,
|
|
4008
|
-
ru: () => ru_default,
|
|
4009
|
-
pt: () => pt_default,
|
|
4010
|
-
ps: () => ps_default,
|
|
4011
|
-
pl: () => pl_default,
|
|
4012
|
-
ota: () => ota_default,
|
|
4013
|
-
no: () => no_default,
|
|
4014
|
-
nl: () => nl_default,
|
|
4015
|
-
ms: () => ms_default,
|
|
4016
|
-
mk: () => mk_default,
|
|
4017
|
-
lt: () => lt_default,
|
|
4018
|
-
ko: () => ko_default,
|
|
4019
|
-
km: () => km_default,
|
|
4020
|
-
kh: () => kh_default,
|
|
4021
|
-
ka: () => ka_default,
|
|
4022
|
-
ja: () => ja_default,
|
|
4023
|
-
it: () => it_default,
|
|
4024
|
-
is: () => is_default,
|
|
4025
|
-
id: () => id_default,
|
|
4026
|
-
hu: () => hu_default,
|
|
4027
|
-
he: () => he_default,
|
|
4028
|
-
frCA: () => fr_CA_default,
|
|
4029
|
-
fr: () => fr_default,
|
|
4030
|
-
fi: () => fi_default,
|
|
4031
|
-
fa: () => fa_default,
|
|
4032
|
-
es: () => es_default,
|
|
4033
|
-
eo: () => eo_default,
|
|
4034
|
-
en: () => en_default,
|
|
4035
|
-
de: () => de_default,
|
|
4036
|
-
da: () => da_default,
|
|
4037
|
-
cs: () => cs_default,
|
|
4038
|
-
ca: () => ca_default,
|
|
4039
|
-
be: () => be_default,
|
|
4000
|
+
ar: () => ar_default,
|
|
4040
4001
|
az: () => az_default,
|
|
4041
|
-
|
|
4002
|
+
be: () => be_default,
|
|
4003
|
+
ca: () => ca_default,
|
|
4004
|
+
cs: () => cs_default,
|
|
4005
|
+
da: () => da_default,
|
|
4006
|
+
de: () => de_default,
|
|
4007
|
+
en: () => en_default,
|
|
4008
|
+
eo: () => eo_default,
|
|
4009
|
+
es: () => es_default,
|
|
4010
|
+
fa: () => fa_default,
|
|
4011
|
+
fi: () => fi_default,
|
|
4012
|
+
fr: () => fr_default,
|
|
4013
|
+
frCA: () => fr_CA_default,
|
|
4014
|
+
he: () => he_default,
|
|
4015
|
+
hu: () => hu_default,
|
|
4016
|
+
id: () => id_default,
|
|
4017
|
+
is: () => is_default,
|
|
4018
|
+
it: () => it_default,
|
|
4019
|
+
ja: () => ja_default,
|
|
4020
|
+
ka: () => ka_default,
|
|
4021
|
+
kh: () => kh_default,
|
|
4022
|
+
km: () => km_default,
|
|
4023
|
+
ko: () => ko_default,
|
|
4024
|
+
lt: () => lt_default,
|
|
4025
|
+
mk: () => mk_default,
|
|
4026
|
+
ms: () => ms_default,
|
|
4027
|
+
nl: () => nl_default,
|
|
4028
|
+
no: () => no_default,
|
|
4029
|
+
ota: () => ota_default,
|
|
4030
|
+
pl: () => pl_default,
|
|
4031
|
+
ps: () => ps_default,
|
|
4032
|
+
pt: () => pt_default,
|
|
4033
|
+
ru: () => ru_default,
|
|
4034
|
+
sl: () => sl_default,
|
|
4035
|
+
sv: () => sv_default,
|
|
4036
|
+
ta: () => ta_default,
|
|
4037
|
+
th: () => th_default,
|
|
4038
|
+
tr: () => tr_default,
|
|
4039
|
+
ua: () => ua_default,
|
|
4040
|
+
uk: () => uk_default,
|
|
4041
|
+
ur: () => ur_default,
|
|
4042
|
+
vi: () => vi_default,
|
|
4043
|
+
yo: () => yo_default,
|
|
4044
|
+
zhCN: () => zh_CN_default,
|
|
4045
|
+
zhTW: () => zh_TW_default
|
|
4042
4046
|
});
|
|
4043
4047
|
|
|
4044
4048
|
// node_modules/zod/v4/locales/ar.js
|
|
@@ -10740,7 +10744,7 @@ class JSONSchemaGenerator {
|
|
|
10740
10744
|
if (val === undefined) {
|
|
10741
10745
|
if (this.unrepresentable === "throw") {
|
|
10742
10746
|
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
10743
|
-
}
|
|
10747
|
+
}
|
|
10744
10748
|
} else if (typeof val === "bigint") {
|
|
10745
10749
|
if (this.unrepresentable === "throw") {
|
|
10746
10750
|
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
@@ -11211,14 +11215,14 @@ var exports_json_schema = {};
|
|
|
11211
11215
|
// node_modules/zod/v4/classic/iso.js
|
|
11212
11216
|
var exports_iso = {};
|
|
11213
11217
|
__export(exports_iso, {
|
|
11214
|
-
|
|
11215
|
-
duration: () => duration2,
|
|
11216
|
-
datetime: () => datetime2,
|
|
11217
|
-
date: () => date2,
|
|
11218
|
-
ZodISOTime: () => ZodISOTime,
|
|
11219
|
-
ZodISODuration: () => ZodISODuration,
|
|
11218
|
+
ZodISODate: () => ZodISODate,
|
|
11220
11219
|
ZodISODateTime: () => ZodISODateTime,
|
|
11221
|
-
|
|
11220
|
+
ZodISODuration: () => ZodISODuration,
|
|
11221
|
+
ZodISOTime: () => ZodISOTime,
|
|
11222
|
+
date: () => date2,
|
|
11223
|
+
datetime: () => datetime2,
|
|
11224
|
+
duration: () => duration2,
|
|
11225
|
+
time: () => time2
|
|
11222
11226
|
});
|
|
11223
11227
|
var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
11224
11228
|
$ZodISODateTime.init(inst, def);
|
|
@@ -12300,11 +12304,11 @@ var ZodFirstPartyTypeKind;
|
|
|
12300
12304
|
// node_modules/zod/v4/classic/coerce.js
|
|
12301
12305
|
var exports_coerce = {};
|
|
12302
12306
|
__export(exports_coerce, {
|
|
12303
|
-
|
|
12304
|
-
number: () => number3,
|
|
12305
|
-
date: () => date4,
|
|
12307
|
+
bigint: () => bigint3,
|
|
12306
12308
|
boolean: () => boolean3,
|
|
12307
|
-
|
|
12309
|
+
date: () => date4,
|
|
12310
|
+
number: () => number3,
|
|
12311
|
+
string: () => string3
|
|
12308
12312
|
});
|
|
12309
12313
|
function string3(params) {
|
|
12310
12314
|
return _coercedString(ZodString, params);
|
|
@@ -12548,6 +12552,8 @@ function resolveDataDir(env, home) {
|
|
|
12548
12552
|
return join2(home, ".local", "share", "opencode");
|
|
12549
12553
|
}
|
|
12550
12554
|
var cachedPool = null;
|
|
12555
|
+
var cachedPending = null;
|
|
12556
|
+
var cachedVersion = null;
|
|
12551
12557
|
function poolFilePath() {
|
|
12552
12558
|
const override = process.env.OPENCODE_AUTH_LB_DIR;
|
|
12553
12559
|
const xdg = process.env.XDG_DATA_HOME;
|
|
@@ -12558,6 +12564,24 @@ function poolFilePath() {
|
|
|
12558
12564
|
cachedPool = { override, xdg, path };
|
|
12559
12565
|
return path;
|
|
12560
12566
|
}
|
|
12567
|
+
function pendingFilePath() {
|
|
12568
|
+
const override = process.env.OPENCODE_AUTH_LB_DIR;
|
|
12569
|
+
const xdg = process.env.XDG_DATA_HOME;
|
|
12570
|
+
if (cachedPending && cachedPending.override === override && cachedPending.xdg === xdg)
|
|
12571
|
+
return cachedPending.path;
|
|
12572
|
+
const path = join2(resolveDataDir({ override, xdgDataHome: xdg }, homedir()), "auth-load-balancer-pending.json");
|
|
12573
|
+
cachedPending = { override, xdg, path };
|
|
12574
|
+
return path;
|
|
12575
|
+
}
|
|
12576
|
+
function versionCacheFilePath() {
|
|
12577
|
+
const override = process.env.OPENCODE_AUTH_LB_DIR;
|
|
12578
|
+
const xdg = process.env.XDG_DATA_HOME;
|
|
12579
|
+
if (cachedVersion && cachedVersion.override === override && cachedVersion.xdg === xdg)
|
|
12580
|
+
return cachedVersion.path;
|
|
12581
|
+
const path = join2(resolveDataDir({ override, xdgDataHome: xdg }, homedir()), "auth-load-balancer-cc-version.json");
|
|
12582
|
+
cachedVersion = { override, xdg, path };
|
|
12583
|
+
return path;
|
|
12584
|
+
}
|
|
12561
12585
|
|
|
12562
12586
|
// src/pool/store.ts
|
|
12563
12587
|
function emptyPool() {
|
|
@@ -12635,6 +12659,10 @@ function normalizeAccounts(rows) {
|
|
|
12635
12659
|
}
|
|
12636
12660
|
if (!Number.isFinite(row.cooldownUntil))
|
|
12637
12661
|
row.cooldownUntil = 0;
|
|
12662
|
+
if (row.cooldownKind !== undefined && row.cooldownKind !== "quota" && row.cooldownKind !== "auth" && row.cooldownKind !== "transient")
|
|
12663
|
+
delete row.cooldownKind;
|
|
12664
|
+
if (row.cooldownUntil <= 0)
|
|
12665
|
+
delete row.cooldownKind;
|
|
12638
12666
|
if (row.modelCooldownsUntil !== undefined) {
|
|
12639
12667
|
if (!isPlainObject2(row.modelCooldownsUntil)) {
|
|
12640
12668
|
delete row.modelCooldownsUntil;
|
|
@@ -12846,6 +12874,156 @@ async function bootstrapFromOpencodeAuth(providerID, getAuth) {
|
|
|
12846
12874
|
});
|
|
12847
12875
|
}
|
|
12848
12876
|
|
|
12877
|
+
// src/scheduler/score-core.ts
|
|
12878
|
+
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
12879
|
+
var WEEK_MS = 7 * DAY_MS;
|
|
12880
|
+
var HOUR_MS = 60 * 60 * 1000;
|
|
12881
|
+
var HOURLY_WINDOW_MS = 5 * HOUR_MS;
|
|
12882
|
+
var RESET_CUSHION_DAYS = 0.25;
|
|
12883
|
+
var SCORE_DEFAULTS = {
|
|
12884
|
+
hourlyInfluence: 0.5,
|
|
12885
|
+
minResetMs: 5 * 60 * 1000,
|
|
12886
|
+
weekWindowMs: WEEK_MS,
|
|
12887
|
+
exhaustedAt: 0.999,
|
|
12888
|
+
migrateAt: 0.95,
|
|
12889
|
+
weeklyDrainTarget: 0.98
|
|
12890
|
+
};
|
|
12891
|
+
function readEnvNumber(env, key, dflt) {
|
|
12892
|
+
const raw = env[key];
|
|
12893
|
+
if (raw === undefined || raw.trim() === "")
|
|
12894
|
+
return dflt;
|
|
12895
|
+
const n = Number(raw);
|
|
12896
|
+
return Number.isFinite(n) ? n : dflt;
|
|
12897
|
+
}
|
|
12898
|
+
function loadScoreConfig(env = process.env) {
|
|
12899
|
+
const num = (key, dflt) => readEnvNumber(env, key, dflt);
|
|
12900
|
+
return {
|
|
12901
|
+
hourlyInfluence: num("OPENCODE_AUTH_LB_HOURLY_INFLUENCE", SCORE_DEFAULTS.hourlyInfluence),
|
|
12902
|
+
minResetMs: num("OPENCODE_AUTH_LB_MIN_RESET_MS", SCORE_DEFAULTS.minResetMs),
|
|
12903
|
+
weekWindowMs: num("OPENCODE_AUTH_LB_WEEK_WINDOW_MS", SCORE_DEFAULTS.weekWindowMs),
|
|
12904
|
+
exhaustedAt: num("OPENCODE_AUTH_LB_EXHAUSTED_AT", SCORE_DEFAULTS.exhaustedAt),
|
|
12905
|
+
migrateAt: num("OPENCODE_AUTH_LB_MIGRATE_AT", SCORE_DEFAULTS.migrateAt),
|
|
12906
|
+
weeklyDrainTarget: num("OPENCODE_AUTH_LB_WEEKLY_DRAIN_TARGET", SCORE_DEFAULTS.weeklyDrainTarget)
|
|
12907
|
+
};
|
|
12908
|
+
}
|
|
12909
|
+
function clamp012(n) {
|
|
12910
|
+
if (!Number.isFinite(n))
|
|
12911
|
+
return 0;
|
|
12912
|
+
return Math.min(1, Math.max(0, n));
|
|
12913
|
+
}
|
|
12914
|
+
function isWindowExpired(window, now) {
|
|
12915
|
+
return window.resetAt > 0 && window.resetAt <= now;
|
|
12916
|
+
}
|
|
12917
|
+
function utilOf(window, now) {
|
|
12918
|
+
if (!window || isWindowExpired(window, now))
|
|
12919
|
+
return 0;
|
|
12920
|
+
return clamp012(window.utilization);
|
|
12921
|
+
}
|
|
12922
|
+
function displayUtil(window, now) {
|
|
12923
|
+
if (!window)
|
|
12924
|
+
return null;
|
|
12925
|
+
return isWindowExpired(window, now) ? 0 : clamp012(window.utilization);
|
|
12926
|
+
}
|
|
12927
|
+
function maxUtil(account, now) {
|
|
12928
|
+
return Math.max(utilOf(account.usage.hourly, now), utilOf(account.usage.weekly, now));
|
|
12929
|
+
}
|
|
12930
|
+
function isExhausted(account, cfg, now) {
|
|
12931
|
+
return maxUtil(account, now) >= cfg.exhaustedAt;
|
|
12932
|
+
}
|
|
12933
|
+
function isAvailable(account, cfg, now) {
|
|
12934
|
+
if (account.disabledReason)
|
|
12935
|
+
return false;
|
|
12936
|
+
if (account.cooldownUntil > now)
|
|
12937
|
+
return false;
|
|
12938
|
+
if (isExhausted(account, cfg, now))
|
|
12939
|
+
return false;
|
|
12940
|
+
return true;
|
|
12941
|
+
}
|
|
12942
|
+
function weeklyUrgency(account, cfg, now) {
|
|
12943
|
+
const weekly = account.usage.weekly;
|
|
12944
|
+
const drainable = Math.max(0, cfg.weeklyDrainTarget - utilOf(weekly, now));
|
|
12945
|
+
if (drainable === 0)
|
|
12946
|
+
return 0;
|
|
12947
|
+
const resetAt = weekly?.resetAt ?? 0;
|
|
12948
|
+
const ms = resetAt > now ? resetAt - now : weekly ? resetAt === 0 ? cfg.minResetMs : WEEK_MS - (now - resetAt) % WEEK_MS : cfg.weekWindowMs;
|
|
12949
|
+
const days = Math.max(ms, cfg.minResetMs) / DAY_MS + RESET_CUSHION_DAYS;
|
|
12950
|
+
return drainable / (days * days);
|
|
12951
|
+
}
|
|
12952
|
+
function scoreAccount(account, cfg, now) {
|
|
12953
|
+
const urgency = weeklyUrgency(account, cfg, now);
|
|
12954
|
+
if (urgency === 0)
|
|
12955
|
+
return 0;
|
|
12956
|
+
const hourly = account.usage.hourly;
|
|
12957
|
+
if (!hourly)
|
|
12958
|
+
return urgency;
|
|
12959
|
+
const hourlyUtil = utilOf(hourly, now);
|
|
12960
|
+
if (hourlyUtil === 0)
|
|
12961
|
+
return urgency;
|
|
12962
|
+
const resetAt = hourly.resetAt;
|
|
12963
|
+
const msToReset = resetAt > now ? resetAt - now : HOURLY_WINDOW_MS;
|
|
12964
|
+
const resetFactor = clamp012(msToReset / HOURLY_WINDOW_MS);
|
|
12965
|
+
const pressure = hourlyUtil * resetFactor;
|
|
12966
|
+
return urgency * (1 - cfg.hourlyInfluence * pressure);
|
|
12967
|
+
}
|
|
12968
|
+
function compareRanked(x, y) {
|
|
12969
|
+
if (x.available !== y.available)
|
|
12970
|
+
return x.available ? -1 : 1;
|
|
12971
|
+
if (x.available)
|
|
12972
|
+
return y.score - x.score;
|
|
12973
|
+
return x.weeklyUtil - y.weeklyUtil;
|
|
12974
|
+
}
|
|
12975
|
+
|
|
12976
|
+
// src/pending/recovery.ts
|
|
12977
|
+
function exhaustedWindows(account, cfg, now) {
|
|
12978
|
+
const windows = [];
|
|
12979
|
+
const hourly = account.usage.hourly;
|
|
12980
|
+
const weekly = account.usage.weekly;
|
|
12981
|
+
if (hourly && utilOf(hourly, now) >= cfg.exhaustedAt)
|
|
12982
|
+
windows.push(hourly);
|
|
12983
|
+
if (weekly && utilOf(weekly, now) >= cfg.exhaustedAt)
|
|
12984
|
+
windows.push(weekly);
|
|
12985
|
+
return windows;
|
|
12986
|
+
}
|
|
12987
|
+
function classifyProviderRecovery(accounts, providerID, cfg, now, pollMs) {
|
|
12988
|
+
let hasQuotaCandidate = false;
|
|
12989
|
+
let hasUnknownReset = false;
|
|
12990
|
+
const knownAccountRecoveries = [];
|
|
12991
|
+
for (const account of accounts) {
|
|
12992
|
+
if (account.providerID !== providerID || account.disabledReason)
|
|
12993
|
+
continue;
|
|
12994
|
+
const windows = exhaustedWindows(account, cfg, now);
|
|
12995
|
+
const cooldownActive = account.cooldownUntil > now;
|
|
12996
|
+
if (!cooldownActive && windows.length === 0)
|
|
12997
|
+
return { state: "available" };
|
|
12998
|
+
if (cooldownActive && (account.cooldownKind === "auth" || account.cooldownKind === "transient"))
|
|
12999
|
+
continue;
|
|
13000
|
+
if (cooldownActive && account.cooldownKind === undefined && !windows.length)
|
|
13001
|
+
continue;
|
|
13002
|
+
hasQuotaCandidate = true;
|
|
13003
|
+
const constraints = [];
|
|
13004
|
+
let accountHasUnknownReset = false;
|
|
13005
|
+
for (const window of windows) {
|
|
13006
|
+
if (window.resetAt > now)
|
|
13007
|
+
constraints.push(window.resetAt);
|
|
13008
|
+
else
|
|
13009
|
+
accountHasUnknownReset = true;
|
|
13010
|
+
}
|
|
13011
|
+
if (cooldownActive)
|
|
13012
|
+
constraints.push(account.cooldownUntil);
|
|
13013
|
+
if (accountHasUnknownReset) {
|
|
13014
|
+
hasUnknownReset = true;
|
|
13015
|
+
continue;
|
|
13016
|
+
}
|
|
13017
|
+
knownAccountRecoveries.push(Math.max(...constraints));
|
|
13018
|
+
}
|
|
13019
|
+
if (!hasQuotaCandidate)
|
|
13020
|
+
return { state: "unusable" };
|
|
13021
|
+
const resumeAt = knownAccountRecoveries.length ? Math.min(...knownAccountRecoveries) : null;
|
|
13022
|
+
const pollAt = hasUnknownReset ? now + Math.max(0, pollMs) : Number.POSITIVE_INFINITY;
|
|
13023
|
+
const nextCheckAt = Math.min(resumeAt ?? Number.POSITIVE_INFINITY, pollAt);
|
|
13024
|
+
return { state: "quota-blocked", nextCheckAt, resumeAt };
|
|
13025
|
+
}
|
|
13026
|
+
|
|
12849
13027
|
// src/providers/anthropic/constants.ts
|
|
12850
13028
|
var PROVIDER_ID = "anthropic";
|
|
12851
13029
|
var CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
@@ -12880,10 +13058,12 @@ var OPENCODE_IDENTITY_PREFIX = "You are OpenCode";
|
|
|
12880
13058
|
var CLAUDE_CODE_IDENTITY = "You are a Claude agent, built on Anthropic's Claude Agent SDK.";
|
|
12881
13059
|
var CCH_SALT = "59cf53e54c78";
|
|
12882
13060
|
var CCH_POSITIONS = [4, 7, 20];
|
|
12883
|
-
var CLAUDE_CODE_VERSION = "2.1.87";
|
|
12884
13061
|
var CLAUDE_CODE_ENTRYPOINT = "sdk-cli";
|
|
12885
|
-
var
|
|
12886
|
-
var
|
|
13062
|
+
var FALLBACK_CLAUDE_CODE_VERSION = "2.1.258";
|
|
13063
|
+
var CLAUDE_CODE_VERSION_ENV = "OPENCODE_AUTH_LB_ANTHROPIC_CLAUDE_CODE_VERSION";
|
|
13064
|
+
var CLAUDE_CODE_REGISTRY_URL = "https://registry.npmjs.org/-/package/@anthropic-ai%2Fclaude-code/dist-tags";
|
|
13065
|
+
var CLAUDE_CODE_VERSION_TTL_MS = 24 * 60 * 60 * 1000;
|
|
13066
|
+
var REGISTRY_HTTP_TIMEOUT_MS = 1e4;
|
|
12887
13067
|
var PARAGRAPH_REMOVAL_ANCHORS = [
|
|
12888
13068
|
"github.com/anomalyco/opencode",
|
|
12889
13069
|
"opencode.ai/docs"
|
|
@@ -13033,112 +13213,13 @@ async function ensureAccessToken(adapter, account, now) {
|
|
|
13033
13213
|
const existing = inflight.get(account.id);
|
|
13034
13214
|
if (existing)
|
|
13035
13215
|
return settleRefresh(adapter, account, existing);
|
|
13036
|
-
const job = runRefresh(adapter, account, now);
|
|
13037
|
-
inflight.set(account.id, job);
|
|
13038
|
-
try {
|
|
13039
|
-
return await settleRefresh(adapter, account, job);
|
|
13040
|
-
} finally {
|
|
13041
|
-
inflight.delete(account.id);
|
|
13042
|
-
}
|
|
13043
|
-
}
|
|
13044
|
-
|
|
13045
|
-
// src/scheduler/score-core.ts
|
|
13046
|
-
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
13047
|
-
var WEEK_MS = 7 * DAY_MS;
|
|
13048
|
-
var HOUR_MS = 60 * 60 * 1000;
|
|
13049
|
-
var HOURLY_WINDOW_MS = 5 * HOUR_MS;
|
|
13050
|
-
var RESET_CUSHION_DAYS = 0.25;
|
|
13051
|
-
var SCORE_DEFAULTS = {
|
|
13052
|
-
hourlyInfluence: 0.5,
|
|
13053
|
-
minResetMs: 5 * 60 * 1000,
|
|
13054
|
-
weekWindowMs: WEEK_MS,
|
|
13055
|
-
exhaustedAt: 0.999,
|
|
13056
|
-
migrateAt: 0.95,
|
|
13057
|
-
weeklyDrainTarget: 0.98
|
|
13058
|
-
};
|
|
13059
|
-
function readEnvNumber(env, key, dflt) {
|
|
13060
|
-
const raw = env[key];
|
|
13061
|
-
if (raw === undefined || raw.trim() === "")
|
|
13062
|
-
return dflt;
|
|
13063
|
-
const n = Number(raw);
|
|
13064
|
-
return Number.isFinite(n) ? n : dflt;
|
|
13065
|
-
}
|
|
13066
|
-
function loadScoreConfig(env = process.env) {
|
|
13067
|
-
const num = (key, dflt) => readEnvNumber(env, key, dflt);
|
|
13068
|
-
return {
|
|
13069
|
-
hourlyInfluence: num("OPENCODE_AUTH_LB_HOURLY_INFLUENCE", SCORE_DEFAULTS.hourlyInfluence),
|
|
13070
|
-
minResetMs: num("OPENCODE_AUTH_LB_MIN_RESET_MS", SCORE_DEFAULTS.minResetMs),
|
|
13071
|
-
weekWindowMs: num("OPENCODE_AUTH_LB_WEEK_WINDOW_MS", SCORE_DEFAULTS.weekWindowMs),
|
|
13072
|
-
exhaustedAt: num("OPENCODE_AUTH_LB_EXHAUSTED_AT", SCORE_DEFAULTS.exhaustedAt),
|
|
13073
|
-
migrateAt: num("OPENCODE_AUTH_LB_MIGRATE_AT", SCORE_DEFAULTS.migrateAt),
|
|
13074
|
-
weeklyDrainTarget: num("OPENCODE_AUTH_LB_WEEKLY_DRAIN_TARGET", SCORE_DEFAULTS.weeklyDrainTarget)
|
|
13075
|
-
};
|
|
13076
|
-
}
|
|
13077
|
-
function clamp012(n) {
|
|
13078
|
-
if (!Number.isFinite(n))
|
|
13079
|
-
return 0;
|
|
13080
|
-
return Math.min(1, Math.max(0, n));
|
|
13081
|
-
}
|
|
13082
|
-
function isWindowExpired(window, now) {
|
|
13083
|
-
return window.resetAt > 0 && window.resetAt <= now;
|
|
13084
|
-
}
|
|
13085
|
-
function utilOf(window, now) {
|
|
13086
|
-
if (!window || isWindowExpired(window, now))
|
|
13087
|
-
return 0;
|
|
13088
|
-
return clamp012(window.utilization);
|
|
13089
|
-
}
|
|
13090
|
-
function displayUtil(window, now) {
|
|
13091
|
-
if (!window)
|
|
13092
|
-
return null;
|
|
13093
|
-
return isWindowExpired(window, now) ? 0 : clamp012(window.utilization);
|
|
13094
|
-
}
|
|
13095
|
-
function maxUtil(account, now) {
|
|
13096
|
-
return Math.max(utilOf(account.usage.hourly, now), utilOf(account.usage.weekly, now));
|
|
13097
|
-
}
|
|
13098
|
-
function isExhausted(account, cfg, now) {
|
|
13099
|
-
return maxUtil(account, now) >= cfg.exhaustedAt;
|
|
13100
|
-
}
|
|
13101
|
-
function isAvailable(account, cfg, now) {
|
|
13102
|
-
if (account.disabledReason)
|
|
13103
|
-
return false;
|
|
13104
|
-
if (account.cooldownUntil > now)
|
|
13105
|
-
return false;
|
|
13106
|
-
if (isExhausted(account, cfg, now))
|
|
13107
|
-
return false;
|
|
13108
|
-
return true;
|
|
13109
|
-
}
|
|
13110
|
-
function weeklyUrgency(account, cfg, now) {
|
|
13111
|
-
const weekly = account.usage.weekly;
|
|
13112
|
-
const drainable = Math.max(0, cfg.weeklyDrainTarget - utilOf(weekly, now));
|
|
13113
|
-
if (drainable === 0)
|
|
13114
|
-
return 0;
|
|
13115
|
-
const resetAt = weekly?.resetAt ?? 0;
|
|
13116
|
-
const ms = resetAt > now ? resetAt - now : weekly ? resetAt === 0 ? cfg.minResetMs : WEEK_MS - (now - resetAt) % WEEK_MS : cfg.weekWindowMs;
|
|
13117
|
-
const days = Math.max(ms, cfg.minResetMs) / DAY_MS + RESET_CUSHION_DAYS;
|
|
13118
|
-
return drainable / (days * days);
|
|
13119
|
-
}
|
|
13120
|
-
function scoreAccount(account, cfg, now) {
|
|
13121
|
-
const urgency = weeklyUrgency(account, cfg, now);
|
|
13122
|
-
if (urgency === 0)
|
|
13123
|
-
return 0;
|
|
13124
|
-
const hourly = account.usage.hourly;
|
|
13125
|
-
if (!hourly)
|
|
13126
|
-
return urgency;
|
|
13127
|
-
const hourlyUtil = utilOf(hourly, now);
|
|
13128
|
-
if (hourlyUtil === 0)
|
|
13129
|
-
return urgency;
|
|
13130
|
-
const resetAt = hourly.resetAt;
|
|
13131
|
-
const msToReset = resetAt > now ? resetAt - now : HOURLY_WINDOW_MS;
|
|
13132
|
-
const resetFactor = clamp012(msToReset / HOURLY_WINDOW_MS);
|
|
13133
|
-
const pressure = hourlyUtil * resetFactor;
|
|
13134
|
-
return urgency * (1 - cfg.hourlyInfluence * pressure);
|
|
13135
|
-
}
|
|
13136
|
-
function compareRanked(x, y) {
|
|
13137
|
-
if (x.available !== y.available)
|
|
13138
|
-
return x.available ? -1 : 1;
|
|
13139
|
-
if (x.available)
|
|
13140
|
-
return y.score - x.score;
|
|
13141
|
-
return x.weeklyUtil - y.weeklyUtil;
|
|
13216
|
+
const job = runRefresh(adapter, account, now);
|
|
13217
|
+
inflight.set(account.id, job);
|
|
13218
|
+
try {
|
|
13219
|
+
return await settleRefresh(adapter, account, job);
|
|
13220
|
+
} finally {
|
|
13221
|
+
inflight.delete(account.id);
|
|
13222
|
+
}
|
|
13142
13223
|
}
|
|
13143
13224
|
|
|
13144
13225
|
// src/scheduler/config.ts
|
|
@@ -13267,6 +13348,7 @@ function selectForSession(pool, providerID, sessionKey, now, cfg = DEFAULT_CONFI
|
|
|
13267
13348
|
// src/session.ts
|
|
13268
13349
|
import { createHash } from "node:crypto";
|
|
13269
13350
|
var SESSION_HEADER = "x-allb-session";
|
|
13351
|
+
var MESSAGE_HEADER = "x-allb-message";
|
|
13270
13352
|
function firstUserFromList(list) {
|
|
13271
13353
|
if (!Array.isArray(list))
|
|
13272
13354
|
return null;
|
|
@@ -13611,6 +13693,101 @@ async function refresh(refreshToken) {
|
|
|
13611
13693
|
|
|
13612
13694
|
// src/providers/anthropic/cch.ts
|
|
13613
13695
|
import { createHash as createHash2 } from "node:crypto";
|
|
13696
|
+
|
|
13697
|
+
// src/providers/anthropic/version.ts
|
|
13698
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
13699
|
+
|
|
13700
|
+
// src/providers/usage-http.ts
|
|
13701
|
+
async function fetchJson(url2, headers, timeoutMs) {
|
|
13702
|
+
let response;
|
|
13703
|
+
try {
|
|
13704
|
+
response = await fetch(url2, {
|
|
13705
|
+
headers,
|
|
13706
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
13707
|
+
});
|
|
13708
|
+
} catch {
|
|
13709
|
+
return null;
|
|
13710
|
+
}
|
|
13711
|
+
if (!response.ok) {
|
|
13712
|
+
await response.body?.cancel().catch(ignore);
|
|
13713
|
+
return null;
|
|
13714
|
+
}
|
|
13715
|
+
return await response.json().catch(() => null);
|
|
13716
|
+
}
|
|
13717
|
+
|
|
13718
|
+
// src/providers/anthropic/version.ts
|
|
13719
|
+
var VERSION_RE = /^\d+\.\d+\.\d+$/;
|
|
13720
|
+
function compareVersions2(a, b) {
|
|
13721
|
+
const left = a.split(".");
|
|
13722
|
+
const right = b.split(".");
|
|
13723
|
+
for (let i = 0;i < 3; i++) {
|
|
13724
|
+
const delta = Number(left[i]) - Number(right[i]);
|
|
13725
|
+
if (delta !== 0)
|
|
13726
|
+
return delta;
|
|
13727
|
+
}
|
|
13728
|
+
return 0;
|
|
13729
|
+
}
|
|
13730
|
+
var current = FALLBACK_CLAUDE_CODE_VERSION;
|
|
13731
|
+
function adopt(candidate) {
|
|
13732
|
+
const trimmed = candidate.trim();
|
|
13733
|
+
if (!VERSION_RE.test(trimmed))
|
|
13734
|
+
return;
|
|
13735
|
+
if (compareVersions2(trimmed, current) <= 0)
|
|
13736
|
+
return;
|
|
13737
|
+
current = trimmed;
|
|
13738
|
+
}
|
|
13739
|
+
function envOverride() {
|
|
13740
|
+
const raw = process.env[CLAUDE_CODE_VERSION_ENV]?.trim();
|
|
13741
|
+
return raw && VERSION_RE.test(raw) ? raw : undefined;
|
|
13742
|
+
}
|
|
13743
|
+
function claudeCodeVersion() {
|
|
13744
|
+
return envOverride() ?? current;
|
|
13745
|
+
}
|
|
13746
|
+
function userAgent() {
|
|
13747
|
+
return `claude-cli/${claudeCodeVersion()} (external, cli)`;
|
|
13748
|
+
}
|
|
13749
|
+
function usageUserAgent() {
|
|
13750
|
+
return `claude-code/${claudeCodeVersion()}`;
|
|
13751
|
+
}
|
|
13752
|
+
async function readCache() {
|
|
13753
|
+
let text;
|
|
13754
|
+
try {
|
|
13755
|
+
text = await readFile3(versionCacheFilePath(), "utf8");
|
|
13756
|
+
} catch {
|
|
13757
|
+
return null;
|
|
13758
|
+
}
|
|
13759
|
+
try {
|
|
13760
|
+
const parsed = JSON.parse(text);
|
|
13761
|
+
if (!isPlainObject2(parsed))
|
|
13762
|
+
return null;
|
|
13763
|
+
const { version: version2, fetchedAt } = parsed;
|
|
13764
|
+
if (typeof version2 !== "string" || !Number.isFinite(fetchedAt))
|
|
13765
|
+
return null;
|
|
13766
|
+
return { version: version2, fetchedAt };
|
|
13767
|
+
} catch {
|
|
13768
|
+
return null;
|
|
13769
|
+
}
|
|
13770
|
+
}
|
|
13771
|
+
async function refreshClaudeCodeVersion(now) {
|
|
13772
|
+
const tags = await fetchJson(CLAUDE_CODE_REGISTRY_URL, { accept: "application/json" }, REGISTRY_HTTP_TIMEOUT_MS);
|
|
13773
|
+
if (!isPlainObject2(tags) || typeof tags.latest !== "string")
|
|
13774
|
+
return;
|
|
13775
|
+
adopt(tags.latest);
|
|
13776
|
+
await writeJsonAtomic(versionCacheFilePath(), JSON.stringify({ version: current, fetchedAt: now })).catch(ignore);
|
|
13777
|
+
}
|
|
13778
|
+
async function primeClaudeCodeVersion(now) {
|
|
13779
|
+
if (envOverride())
|
|
13780
|
+
return;
|
|
13781
|
+
const cached2 = await readCache();
|
|
13782
|
+
if (cached2) {
|
|
13783
|
+
adopt(cached2.version);
|
|
13784
|
+
if (now - cached2.fetchedAt < CLAUDE_CODE_VERSION_TTL_MS)
|
|
13785
|
+
return;
|
|
13786
|
+
}
|
|
13787
|
+
refreshClaudeCodeVersion(now).catch(ignore);
|
|
13788
|
+
}
|
|
13789
|
+
|
|
13790
|
+
// src/providers/anthropic/cch.ts
|
|
13614
13791
|
function messageText({ content }) {
|
|
13615
13792
|
if (typeof content === "string")
|
|
13616
13793
|
return content;
|
|
@@ -13625,7 +13802,7 @@ function messageText({ content }) {
|
|
|
13625
13802
|
function computeCCH(messageText2) {
|
|
13626
13803
|
return createHash2("sha256").update(messageText2).digest("hex").slice(0, 5);
|
|
13627
13804
|
}
|
|
13628
|
-
function computeVersionSuffix(text, version2 =
|
|
13805
|
+
function computeVersionSuffix(text, version2 = claudeCodeVersion()) {
|
|
13629
13806
|
const chars = CCH_POSITIONS.map((index) => text[index] || "0").join("");
|
|
13630
13807
|
return createHash2("sha256").update(`${CCH_SALT}${chars}${version2}`).digest("hex").slice(0, 3);
|
|
13631
13808
|
}
|
|
@@ -13642,13 +13819,14 @@ function buildBillingHeaderValue(messages, entrypoint) {
|
|
|
13642
13819
|
if (!userMsg)
|
|
13643
13820
|
return null;
|
|
13644
13821
|
const text = messageText(userMsg);
|
|
13645
|
-
const
|
|
13822
|
+
const version2 = claudeCodeVersion();
|
|
13823
|
+
const key = `${version2}\x00${entrypoint}\x00${text}`;
|
|
13646
13824
|
const hit = cachedHeader.get(key);
|
|
13647
13825
|
if (hit !== undefined)
|
|
13648
13826
|
return hit;
|
|
13649
|
-
const suffix = computeVersionSuffix(text);
|
|
13827
|
+
const suffix = computeVersionSuffix(text, version2);
|
|
13650
13828
|
const cch = computeCCH(text);
|
|
13651
|
-
const value = "x-anthropic-billing-header: " + `cc_version=${
|
|
13829
|
+
const value = "x-anthropic-billing-header: " + `cc_version=${version2}.${suffix}; ` + `cc_entrypoint=${entrypoint}; ` + `cch=${cch};`;
|
|
13652
13830
|
setBounded(cachedHeader, key, value, CACHED_HEADER_MAX);
|
|
13653
13831
|
return value;
|
|
13654
13832
|
}
|
|
@@ -13676,7 +13854,7 @@ function mergeBetaHeaders(headers) {
|
|
|
13676
13854
|
function setOAuthHeaders(headers, accessToken) {
|
|
13677
13855
|
headers.set("authorization", `Bearer ${accessToken}`);
|
|
13678
13856
|
headers.set("anthropic-beta", mergeBetaHeaders(headers));
|
|
13679
|
-
headers.set("user-agent",
|
|
13857
|
+
headers.set("user-agent", userAgent());
|
|
13680
13858
|
headers.delete("x-api-key");
|
|
13681
13859
|
}
|
|
13682
13860
|
function prefixToolNames(parsed) {
|
|
@@ -13900,24 +14078,6 @@ function endpointWindowFrom(w, utilOf2, divisor, resetOf) {
|
|
|
13900
14078
|
return { utilization: clamp01(util / divisor), resetAt: resetOf(w) };
|
|
13901
14079
|
}
|
|
13902
14080
|
|
|
13903
|
-
// src/providers/usage-http.ts
|
|
13904
|
-
async function fetchUsageJson(url2, headers, timeoutMs) {
|
|
13905
|
-
let response;
|
|
13906
|
-
try {
|
|
13907
|
-
response = await fetch(url2, {
|
|
13908
|
-
headers,
|
|
13909
|
-
signal: AbortSignal.timeout(timeoutMs)
|
|
13910
|
-
});
|
|
13911
|
-
} catch {
|
|
13912
|
-
return null;
|
|
13913
|
-
}
|
|
13914
|
-
if (!response.ok) {
|
|
13915
|
-
await response.body?.cancel().catch(ignore);
|
|
13916
|
-
return null;
|
|
13917
|
-
}
|
|
13918
|
-
return await response.json().catch(() => null);
|
|
13919
|
-
}
|
|
13920
|
-
|
|
13921
14081
|
// src/providers/anthropic/usage.ts
|
|
13922
14082
|
var HEADER_SPEC = {
|
|
13923
14083
|
hourlyUtil: "anthropic-ratelimit-unified-5h-utilization",
|
|
@@ -13950,10 +14110,10 @@ function endpointWindow(w) {
|
|
|
13950
14110
|
return endpointWindowFrom(w, (win) => win.utilization, 100, (win) => parseResetAt(win.resets_at));
|
|
13951
14111
|
}
|
|
13952
14112
|
async function fetchUsage(account, now) {
|
|
13953
|
-
const json2 = await
|
|
14113
|
+
const json2 = await fetchJson(USAGE_URL, {
|
|
13954
14114
|
authorization: `Bearer ${account.access}`,
|
|
13955
14115
|
"anthropic-beta": "oauth-2025-04-20",
|
|
13956
|
-
"user-agent":
|
|
14116
|
+
"user-agent": usageUserAgent(),
|
|
13957
14117
|
"content-type": "application/json"
|
|
13958
14118
|
}, USAGE_HTTP_TIMEOUT_MS);
|
|
13959
14119
|
if (!json2)
|
|
@@ -13982,6 +14142,7 @@ var anthropicAdapter = {
|
|
|
13982
14142
|
parseUsageHeaders,
|
|
13983
14143
|
fetchUsage,
|
|
13984
14144
|
classifyError: classifyHttpStatus,
|
|
14145
|
+
prime: primeClaudeCodeVersion,
|
|
13985
14146
|
requestModelTier,
|
|
13986
14147
|
planModelFallback: downgradeModel,
|
|
13987
14148
|
planReactiveFallback
|
|
@@ -13997,10 +14158,10 @@ var REDIRECT_URI = "http://localhost:1455/auth/callback";
|
|
|
13997
14158
|
var OAUTH_SCOPES2 = ["openid", "profile", "email", "offline_access"];
|
|
13998
14159
|
var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
|
|
13999
14160
|
var USAGE_URL2 = "https://chatgpt.com/backend-api/wham/usage";
|
|
14000
|
-
var
|
|
14161
|
+
var USAGE_USER_AGENT = "codex-cli";
|
|
14001
14162
|
var ORIGINATOR = "opencode";
|
|
14002
14163
|
var OPENAI_BETA = "responses=experimental";
|
|
14003
|
-
var
|
|
14164
|
+
var USER_AGENT = `opencode/0.2.0 (${platform()} ${release()}; ${arch()})`;
|
|
14004
14165
|
var SESSION_ID = crypto.randomUUID();
|
|
14005
14166
|
|
|
14006
14167
|
// src/providers/openai/jwt.ts
|
|
@@ -14119,7 +14280,7 @@ function applyAuth(headers, account) {
|
|
|
14119
14280
|
headers.set("chatgpt-account-id", accountId);
|
|
14120
14281
|
headers.set("openai-beta", OPENAI_BETA);
|
|
14121
14282
|
headers.set("originator", ORIGINATOR);
|
|
14122
|
-
headers.set("user-agent",
|
|
14283
|
+
headers.set("user-agent", USER_AGENT);
|
|
14123
14284
|
headers.set("session-id", SESSION_ID);
|
|
14124
14285
|
}
|
|
14125
14286
|
function rewriteUrl2(input) {
|
|
@@ -14207,13 +14368,13 @@ function endpointWindow2(w) {
|
|
|
14207
14368
|
async function fetchUsage2(account, now) {
|
|
14208
14369
|
const headers = {
|
|
14209
14370
|
authorization: `Bearer ${account.access}`,
|
|
14210
|
-
"user-agent":
|
|
14371
|
+
"user-agent": USAGE_USER_AGENT,
|
|
14211
14372
|
accept: "application/json"
|
|
14212
14373
|
};
|
|
14213
14374
|
const accountId = resolveAccountId(account);
|
|
14214
14375
|
if (accountId)
|
|
14215
14376
|
headers["chatgpt-account-id"] = accountId;
|
|
14216
|
-
const json2 = await
|
|
14377
|
+
const json2 = await fetchJson(USAGE_URL2, headers, USAGE_HTTP_TIMEOUT_MS);
|
|
14217
14378
|
const rateLimit = json2?.rate_limit;
|
|
14218
14379
|
if (!isPlainObject2(rateLimit))
|
|
14219
14380
|
return null;
|
|
@@ -14256,7 +14417,7 @@ function adapterFor(adapters, providerID) {
|
|
|
14256
14417
|
}
|
|
14257
14418
|
|
|
14258
14419
|
// src/usage-refresh.ts
|
|
14259
|
-
var
|
|
14420
|
+
var USAGE_REFRESH_TTL_MS = 5 * 60 * 1000;
|
|
14260
14421
|
var MAX_TRANSIENT_COOLDOWN_MS = 5 * 60 * 1000;
|
|
14261
14422
|
var lastPoll = new Map;
|
|
14262
14423
|
async function refreshUsage(adapters, now, poolSnapshot) {
|
|
@@ -14267,12 +14428,12 @@ async function refreshUsage(adapters, now, poolSnapshot) {
|
|
|
14267
14428
|
aliveIds?.add(account.id);
|
|
14268
14429
|
if (account.disabledReason)
|
|
14269
14430
|
continue;
|
|
14270
|
-
if (account.usage.capturedAt !== 0 && now - account.usage.capturedAt <=
|
|
14431
|
+
if (account.usage.capturedAt !== 0 && now - account.usage.capturedAt <= USAGE_REFRESH_TTL_MS)
|
|
14271
14432
|
continue;
|
|
14272
14433
|
const adapter = adapterFor(adapters, account.providerID);
|
|
14273
14434
|
if (!adapter)
|
|
14274
14435
|
continue;
|
|
14275
|
-
if ((lastPoll.get(account.id) ?? 0) > now -
|
|
14436
|
+
if ((lastPoll.get(account.id) ?? 0) > now - USAGE_REFRESH_TTL_MS)
|
|
14276
14437
|
continue;
|
|
14277
14438
|
lastPoll.set(account.id, now);
|
|
14278
14439
|
stale ??= [];
|
|
@@ -14299,8 +14460,10 @@ async function refreshUsage(adapters, now, poolSnapshot) {
|
|
|
14299
14460
|
weekly: snapshot.weekly === null ? stored.usage.weekly : preserveWeeklyAnchor(snapshot.weekly, stored.usage.weekly, now),
|
|
14300
14461
|
capturedAt: snapshot.weekly === null ? stored.usage.capturedAt : now
|
|
14301
14462
|
};
|
|
14302
|
-
if (snapshot.weekly !== null && stored.cooldownUntil > now + MAX_TRANSIENT_COOLDOWN_MS && !isExhausted(stored, scoreCfg, now))
|
|
14463
|
+
if (snapshot.weekly !== null && stored.cooldownUntil > now + MAX_TRANSIENT_COOLDOWN_MS && !isExhausted(stored, scoreCfg, now)) {
|
|
14303
14464
|
stored.cooldownUntil = 0;
|
|
14465
|
+
delete stored.cooldownKind;
|
|
14466
|
+
}
|
|
14304
14467
|
}
|
|
14305
14468
|
});
|
|
14306
14469
|
}
|
|
@@ -14359,15 +14522,17 @@ function cooldownUntilFrom(res, fallbackMs, now) {
|
|
|
14359
14522
|
}
|
|
14360
14523
|
return until;
|
|
14361
14524
|
}
|
|
14362
|
-
async function applyCooldown(accountId, fallbackMs) {
|
|
14525
|
+
async function applyCooldown(accountId, fallbackMs, kind) {
|
|
14363
14526
|
const until = cooldownUntilFrom(null, fallbackMs, Date.now());
|
|
14364
14527
|
await bestEffort("cooldown", () => mutatePool((pool) => {
|
|
14365
14528
|
const account = findAccount(pool, accountId);
|
|
14366
|
-
if (account)
|
|
14367
|
-
account.cooldownUntil =
|
|
14529
|
+
if (account && until >= account.cooldownUntil) {
|
|
14530
|
+
account.cooldownUntil = until;
|
|
14531
|
+
account.cooldownKind = kind;
|
|
14532
|
+
}
|
|
14368
14533
|
}));
|
|
14369
14534
|
}
|
|
14370
|
-
async function recordRotation(adapter, accountId, res, fallbackMs, now) {
|
|
14535
|
+
async function recordRotation(adapter, accountId, res, fallbackMs, now, kind) {
|
|
14371
14536
|
const partial2 = adapter.parseUsageHeaders(res.headers);
|
|
14372
14537
|
const until = cooldownUntilFrom(res, fallbackMs, now);
|
|
14373
14538
|
await bestEffort("rotation", () => mutatePool((pool) => {
|
|
@@ -14376,7 +14541,10 @@ async function recordRotation(adapter, accountId, res, fallbackMs, now) {
|
|
|
14376
14541
|
return;
|
|
14377
14542
|
if (partial2)
|
|
14378
14543
|
applyUsagePartial(account, partial2, now);
|
|
14379
|
-
|
|
14544
|
+
if (until >= account.cooldownUntil) {
|
|
14545
|
+
account.cooldownUntil = until;
|
|
14546
|
+
account.cooldownKind = kind;
|
|
14547
|
+
}
|
|
14380
14548
|
}));
|
|
14381
14549
|
}
|
|
14382
14550
|
async function recordModelCooldown(accountId, tier, until, partial2, now) {
|
|
@@ -14396,8 +14564,10 @@ async function recordSuccess(adapter, accountId, partial2, sessionKey, now, cfg,
|
|
|
14396
14564
|
if (account) {
|
|
14397
14565
|
if (partial2)
|
|
14398
14566
|
applyUsagePartial(account, partial2, now);
|
|
14399
|
-
if (partial2 && account.cooldownUntil > now + ACCOUNT_COOLDOWN_MS && !isExhausted(account, cfg, now))
|
|
14567
|
+
if (partial2 && account.cooldownUntil > now + ACCOUNT_COOLDOWN_MS && !isExhausted(account, cfg, now)) {
|
|
14400
14568
|
account.cooldownUntil = 0;
|
|
14569
|
+
delete account.cooldownKind;
|
|
14570
|
+
}
|
|
14401
14571
|
pool.lastSelected[adapter.id] = accountId;
|
|
14402
14572
|
}
|
|
14403
14573
|
if (sessionKey) {
|
|
@@ -14438,15 +14608,24 @@ function soonestCooldownUntil(accounts, now, accountIds) {
|
|
|
14438
14608
|
}
|
|
14439
14609
|
return Number.isFinite(soonest) ? soonest : null;
|
|
14440
14610
|
}
|
|
14441
|
-
function createLoadBalancedFetch(adapter, hooks = {}, models = []) {
|
|
14611
|
+
function createLoadBalancedFetch(adapter, hooks = {}, models = [], pending) {
|
|
14442
14612
|
const cfg = loadConfig();
|
|
14443
14613
|
return async (input, init) => {
|
|
14444
14614
|
const bodyStr = typeof init?.body === "string" ? init.body : undefined;
|
|
14445
14615
|
const baseHeaders = mergeHeaders(input, init);
|
|
14616
|
+
const sessionID = baseHeaders.get(SESSION_HEADER);
|
|
14617
|
+
const messageID = baseHeaders.get(MESSAGE_HEADER);
|
|
14618
|
+
const pendingRef = pending && sessionID && messageID ? {
|
|
14619
|
+
workspace: pending.workspace,
|
|
14620
|
+
providerID: adapter.id,
|
|
14621
|
+
sessionID,
|
|
14622
|
+
messageID
|
|
14623
|
+
} : null;
|
|
14446
14624
|
const signal = init?.signal ?? (input instanceof Request ? input.signal : undefined);
|
|
14447
14625
|
const baseKey = deriveSessionKey(baseHeaders, bodyStr);
|
|
14448
14626
|
const sessionKey = baseKey ? `${adapter.id}:${baseKey}` : null;
|
|
14449
14627
|
baseHeaders.delete(SESSION_HEADER);
|
|
14628
|
+
baseHeaders.delete(MESSAGE_HEADER);
|
|
14450
14629
|
const tried = new Set;
|
|
14451
14630
|
let waitableCooldownIds = null;
|
|
14452
14631
|
let lastError = null;
|
|
@@ -14481,10 +14660,26 @@ function createLoadBalancedFetch(adapter, hooks = {}, models = []) {
|
|
|
14481
14660
|
usageSeeded = true;
|
|
14482
14661
|
refreshAllUsageInBackground(now, pool).catch(ignore);
|
|
14483
14662
|
}
|
|
14663
|
+
if (pendingRef && pending) {
|
|
14664
|
+
const recovery = classifyProviderRecovery(pool.accounts, adapter.id, cfg, now, USAGE_REFRESH_TTL_MS);
|
|
14665
|
+
if (recovery.state === "quota-blocked") {
|
|
14666
|
+
const result = await pending.waitForCapacity(pendingRef, recovery, signal);
|
|
14667
|
+
if (result === "unusable") {
|
|
14668
|
+
await pending.complete(pendingRef).catch(ignore);
|
|
14669
|
+
return noUsableAccountResponse(adapter.id);
|
|
14670
|
+
}
|
|
14671
|
+
tried.clear();
|
|
14672
|
+
waitableCooldownIds?.clear();
|
|
14673
|
+
continue;
|
|
14674
|
+
}
|
|
14675
|
+
}
|
|
14484
14676
|
const selection = selectForSession(pool, adapter.id, sessionKey, now, cfg, tried, requestBytes);
|
|
14485
14677
|
if (!selection) {
|
|
14486
|
-
if (tried.size === 0)
|
|
14678
|
+
if (tried.size === 0) {
|
|
14679
|
+
if (pendingRef && pending)
|
|
14680
|
+
await pending.complete(pendingRef).catch(ignore);
|
|
14487
14681
|
return noUsableAccountResponse(adapter.id);
|
|
14682
|
+
}
|
|
14488
14683
|
if (pendingTierFallback !== null) {
|
|
14489
14684
|
const adopted = pendingTierFallback;
|
|
14490
14685
|
pendingTierFallback = null;
|
|
@@ -14558,7 +14753,7 @@ function createLoadBalancedFetch(adapter, hooks = {}, models = []) {
|
|
|
14558
14753
|
}
|
|
14559
14754
|
}
|
|
14560
14755
|
const ms = cls === "auth" ? AUTH_COOLDOWN_MS : ACCOUNT_COOLDOWN_MS;
|
|
14561
|
-
await recordRotation(adapter, account.id, res, ms, Date.now());
|
|
14756
|
+
await recordRotation(adapter, account.id, res, ms, Date.now(), cls === "auth" ? "auth" : "quota");
|
|
14562
14757
|
if (cls === "account") {
|
|
14563
14758
|
waitableCooldownIds ??= new Set;
|
|
14564
14759
|
waitableCooldownIds.add(account.id);
|
|
@@ -14576,19 +14771,26 @@ function createLoadBalancedFetch(adapter, hooks = {}, models = []) {
|
|
|
14576
14771
|
hooks.onModelFallback?.(adapter.id, account, fallbackInfo.fromModel, fallbackInfo.toModel, fallbackInfo.fromTier);
|
|
14577
14772
|
hooks.onUse?.(adapter.id, account);
|
|
14578
14773
|
await recordSuccess(adapter, account.id, partial2, sessionKey, successNow, cfg, fallbackInfo);
|
|
14774
|
+
if (pendingRef && pending)
|
|
14775
|
+
await pending.complete(pendingRef).catch(ignore);
|
|
14579
14776
|
return adapter.transformResponse(res);
|
|
14580
14777
|
} catch (error45) {
|
|
14581
14778
|
lastError = error45;
|
|
14582
14779
|
const aborted2 = signal?.aborted === true || error45 instanceof Error && error45.name === "AbortError";
|
|
14583
|
-
if (aborted2)
|
|
14780
|
+
if (aborted2) {
|
|
14781
|
+
if (pendingRef && pending)
|
|
14782
|
+
await pending.abort(pendingRef).catch(ignore);
|
|
14584
14783
|
throw error45;
|
|
14784
|
+
}
|
|
14585
14785
|
if (!account.disabledReason)
|
|
14586
|
-
await applyCooldown(account.id, AUTH_COOLDOWN_MS);
|
|
14786
|
+
await applyCooldown(account.id, AUTH_COOLDOWN_MS, "transient");
|
|
14587
14787
|
if (DEBUG)
|
|
14588
14788
|
log(`!! ${account.label} threw: ${error45 instanceof Error ? error45.message : String(error45)}`);
|
|
14589
14789
|
continue;
|
|
14590
14790
|
}
|
|
14591
14791
|
}
|
|
14792
|
+
if (pendingRef && pending)
|
|
14793
|
+
await pending.complete(pendingRef).catch(ignore);
|
|
14592
14794
|
throw lastError ?? new Error(`${adapter.id}: no usable account in the load-balancer pool`);
|
|
14593
14795
|
};
|
|
14594
14796
|
}
|
|
@@ -14607,7 +14809,7 @@ function byProviderId(a, b) {
|
|
|
14607
14809
|
function isExpired(window, now) {
|
|
14608
14810
|
return !!window && window.resetAt > 0 && window.resetAt <= now;
|
|
14609
14811
|
}
|
|
14610
|
-
function toStatus(account, now,
|
|
14812
|
+
function toStatus(account, now, current2, available, rank) {
|
|
14611
14813
|
const weekly = account.usage.weekly;
|
|
14612
14814
|
const weeklyExpired = isExpired(weekly, now);
|
|
14613
14815
|
return {
|
|
@@ -14620,7 +14822,7 @@ function toStatus(account, now, current, available, rank) {
|
|
|
14620
14822
|
cooldownUntil: account.cooldownUntil,
|
|
14621
14823
|
modelCooldownsUntil: account.modelCooldownsUntil ?? {},
|
|
14622
14824
|
disabledReason: account.disabledReason,
|
|
14623
|
-
current,
|
|
14825
|
+
current: current2,
|
|
14624
14826
|
rank
|
|
14625
14827
|
};
|
|
14626
14828
|
}
|
|
@@ -14695,13 +14897,40 @@ function stateOf(a, now) {
|
|
|
14695
14897
|
function providerName(providerID) {
|
|
14696
14898
|
return PROVIDER_NAMES[providerID] ?? providerID;
|
|
14697
14899
|
}
|
|
14900
|
+
function renderPendingStatus(turns, now = Date.now()) {
|
|
14901
|
+
if (turns.length === 0)
|
|
14902
|
+
return "";
|
|
14903
|
+
const grouped = new Map;
|
|
14904
|
+
for (const turn of turns) {
|
|
14905
|
+
let group = grouped.get(turn.providerID);
|
|
14906
|
+
if (!group) {
|
|
14907
|
+
group = { sessions: new Set, resumeAt: [], nextCheckAt: [] };
|
|
14908
|
+
grouped.set(turn.providerID, group);
|
|
14909
|
+
}
|
|
14910
|
+
group.sessions.add(turn.sessionID);
|
|
14911
|
+
if (turn.resumeAt !== null)
|
|
14912
|
+
group.resumeAt.push(turn.resumeAt);
|
|
14913
|
+
group.nextCheckAt.push(turn.nextCheckAt);
|
|
14914
|
+
}
|
|
14915
|
+
const groups = [...grouped.entries()].sort(([a], [b]) => compareAscii(a, b));
|
|
14916
|
+
const width = groups.reduce((max, [providerID]) => Math.max(max, displayWidth(providerName(providerID))), 0);
|
|
14917
|
+
const pendingTime = (at) => at <= now ? "now" : relTime(at, now);
|
|
14918
|
+
const lines = ["Pending turns"];
|
|
14919
|
+
for (const [providerID, group] of groups) {
|
|
14920
|
+
const count = group.sessions.size;
|
|
14921
|
+
const timing = group.resumeAt.length ? `nearest recovery ${pendingTime(Math.min(...group.resumeAt))}` : `checking again ${pendingTime(Math.min(...group.nextCheckAt))}`;
|
|
14922
|
+
lines.push(` ${padDisplayEnd(providerName(providerID), width)} ${count} session${count === 1 ? "" : "s"} · ${timing}`);
|
|
14923
|
+
}
|
|
14924
|
+
return lines.join(`
|
|
14925
|
+
`);
|
|
14926
|
+
}
|
|
14698
14927
|
function renderStatus(providers, now = Date.now()) {
|
|
14699
14928
|
if (providers.length === 0)
|
|
14700
14929
|
return "auth-load-balancer: no accounts registered.";
|
|
14701
14930
|
const lines = [];
|
|
14702
14931
|
for (const p of providers) {
|
|
14703
|
-
const
|
|
14704
|
-
lines.push(`${providerName(p.providerID)} — in use: ${
|
|
14932
|
+
const current2 = p.accounts.find((a) => a.current);
|
|
14933
|
+
lines.push(`${providerName(p.providerID)} — in use: ${current2 ? current2.label : "(none yet)"}`);
|
|
14705
14934
|
const width = p.accounts.reduce((w, a) => Math.max(w, displayWidth(a.label)), 16);
|
|
14706
14935
|
lines.push(` # ${"account".padEnd(width + 3)}weekly 5h resets state`);
|
|
14707
14936
|
for (const a of p.accounts) {
|
|
@@ -14759,6 +14988,538 @@ async function notifyModelFallback(client, providerID, account, fromModel, toMod
|
|
|
14759
14988
|
duration: 6000
|
|
14760
14989
|
});
|
|
14761
14990
|
}
|
|
14991
|
+
function pendingDate(at) {
|
|
14992
|
+
const date5 = new Date(at);
|
|
14993
|
+
const months = [
|
|
14994
|
+
"Jan",
|
|
14995
|
+
"Feb",
|
|
14996
|
+
"Mar",
|
|
14997
|
+
"Apr",
|
|
14998
|
+
"May",
|
|
14999
|
+
"Jun",
|
|
15000
|
+
"Jul",
|
|
15001
|
+
"Aug",
|
|
15002
|
+
"Sep",
|
|
15003
|
+
"Oct",
|
|
15004
|
+
"Nov",
|
|
15005
|
+
"Dec"
|
|
15006
|
+
];
|
|
15007
|
+
const month = months[date5.getMonth()] ?? "";
|
|
15008
|
+
const hour = String(date5.getHours()).padStart(2, "0");
|
|
15009
|
+
const minute = String(date5.getMinutes()).padStart(2, "0");
|
|
15010
|
+
return `${month} ${date5.getDate()}, ${hour}:${minute}`;
|
|
15011
|
+
}
|
|
15012
|
+
async function notifyPending(client, providerID, recovery, now = Date.now()) {
|
|
15013
|
+
const provider = providerName(providerID);
|
|
15014
|
+
const message = recovery.resumeAt === null ? `${provider} usage exhausted — checking again in ${Math.max(1, Math.round((recovery.nextCheckAt - now) / 60000))}m (Esc to cancel)` : `${provider} usage exhausted — pending until ${pendingDate(recovery.resumeAt)} (Esc to cancel)`;
|
|
15015
|
+
await postToast(client, {
|
|
15016
|
+
title: `${provider} request pending`,
|
|
15017
|
+
message,
|
|
15018
|
+
variant: "warning",
|
|
15019
|
+
duration: 8000
|
|
15020
|
+
});
|
|
15021
|
+
}
|
|
15022
|
+
async function notifyPendingResumed(client, providerID) {
|
|
15023
|
+
const provider = providerName(providerID);
|
|
15024
|
+
await postToast(client, {
|
|
15025
|
+
title: `${provider} request resumed`,
|
|
15026
|
+
message: `${provider} usage recovered — resuming request`,
|
|
15027
|
+
variant: "success",
|
|
15028
|
+
duration: 5000
|
|
15029
|
+
});
|
|
15030
|
+
}
|
|
15031
|
+
async function notifyPendingRestored(client, providerID, count) {
|
|
15032
|
+
const provider = providerName(providerID);
|
|
15033
|
+
await postToast(client, {
|
|
15034
|
+
title: `${provider} pending restored`,
|
|
15035
|
+
message: `Restored ${count} pending ${provider} session${count === 1 ? "" : "s"}`,
|
|
15036
|
+
variant: "info",
|
|
15037
|
+
duration: 6000
|
|
15038
|
+
});
|
|
15039
|
+
}
|
|
15040
|
+
var restoreErrorsToasted = new Map;
|
|
15041
|
+
async function notifyPendingRestoreError(client, providerID, messageID) {
|
|
15042
|
+
const key = `${providerID}:${messageID}`;
|
|
15043
|
+
if (restoreErrorsToasted.has(key))
|
|
15044
|
+
return;
|
|
15045
|
+
setBounded(restoreErrorsToasted, key, true, 256);
|
|
15046
|
+
const provider = providerName(providerID);
|
|
15047
|
+
await postToast(client, {
|
|
15048
|
+
title: `${provider} pending restore`,
|
|
15049
|
+
message: `Could not restore a pending ${provider} request yet — retrying automatically`,
|
|
15050
|
+
variant: "error",
|
|
15051
|
+
duration: 8000
|
|
15052
|
+
});
|
|
15053
|
+
}
|
|
15054
|
+
|
|
15055
|
+
// src/pending/lease.ts
|
|
15056
|
+
var DEFAULT_PENDING_LEASE = {
|
|
15057
|
+
staleMs: 30000,
|
|
15058
|
+
timeoutMs: 0,
|
|
15059
|
+
retryMs: 25,
|
|
15060
|
+
heartbeatMs: 5000
|
|
15061
|
+
};
|
|
15062
|
+
function pendingLeasePath(key) {
|
|
15063
|
+
return `${pendingFilePath()}.${key}.lease`;
|
|
15064
|
+
}
|
|
15065
|
+
function acquirePendingLease(key, options = DEFAULT_PENDING_LEASE) {
|
|
15066
|
+
return acquireLock(pendingLeasePath(key), options);
|
|
15067
|
+
}
|
|
15068
|
+
|
|
15069
|
+
// src/pending/store.ts
|
|
15070
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
15071
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
15072
|
+
var PENDING_WRITE_LOCK = {
|
|
15073
|
+
staleMs: 30000,
|
|
15074
|
+
timeoutMs: 30000,
|
|
15075
|
+
retryMs: 25,
|
|
15076
|
+
heartbeatMs: 5000
|
|
15077
|
+
};
|
|
15078
|
+
function emptyPending() {
|
|
15079
|
+
return { version: 1, turns: [] };
|
|
15080
|
+
}
|
|
15081
|
+
|
|
15082
|
+
class PendingReadError extends Error {
|
|
15083
|
+
path;
|
|
15084
|
+
reason;
|
|
15085
|
+
constructor(path, reason) {
|
|
15086
|
+
super(`Failed to read pending-turn file: ${path}`);
|
|
15087
|
+
this.path = path;
|
|
15088
|
+
this.reason = reason;
|
|
15089
|
+
this.name = "PendingReadError";
|
|
15090
|
+
}
|
|
15091
|
+
}
|
|
15092
|
+
function pendingKey(ref) {
|
|
15093
|
+
return createHash3("sha256").update(JSON.stringify([
|
|
15094
|
+
ref.workspace,
|
|
15095
|
+
ref.providerID,
|
|
15096
|
+
ref.sessionID,
|
|
15097
|
+
ref.messageID
|
|
15098
|
+
])).digest("hex");
|
|
15099
|
+
}
|
|
15100
|
+
function finiteNonNegative(value) {
|
|
15101
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
15102
|
+
}
|
|
15103
|
+
function normalizeTurn(value) {
|
|
15104
|
+
if (!isPlainObject2(value))
|
|
15105
|
+
return null;
|
|
15106
|
+
const row = value;
|
|
15107
|
+
if (typeof row.workspace !== "string" || typeof row.providerID !== "string" || typeof row.sessionID !== "string" || typeof row.messageID !== "string" || !finiteNonNegative(row.createdAt) || !finiteNonNegative(row.updatedAt) || !finiteNonNegative(row.nextCheckAt) || row.resumeAt !== null && !finiteNonNegative(row.resumeAt))
|
|
15108
|
+
return null;
|
|
15109
|
+
const ref = {
|
|
15110
|
+
workspace: row.workspace,
|
|
15111
|
+
providerID: row.providerID,
|
|
15112
|
+
sessionID: row.sessionID,
|
|
15113
|
+
messageID: row.messageID
|
|
15114
|
+
};
|
|
15115
|
+
return {
|
|
15116
|
+
...ref,
|
|
15117
|
+
key: pendingKey(ref),
|
|
15118
|
+
createdAt: row.createdAt,
|
|
15119
|
+
updatedAt: row.updatedAt,
|
|
15120
|
+
nextCheckAt: row.nextCheckAt,
|
|
15121
|
+
resumeAt: row.resumeAt
|
|
15122
|
+
};
|
|
15123
|
+
}
|
|
15124
|
+
async function readRaw2() {
|
|
15125
|
+
let text;
|
|
15126
|
+
try {
|
|
15127
|
+
text = await readFile4(pendingFilePath(), "utf8");
|
|
15128
|
+
} catch (error45) {
|
|
15129
|
+
if (error45.code === "ENOENT")
|
|
15130
|
+
return emptyPending();
|
|
15131
|
+
throw new PendingReadError(pendingFilePath(), error45);
|
|
15132
|
+
}
|
|
15133
|
+
try {
|
|
15134
|
+
const parsed = JSON.parse(text);
|
|
15135
|
+
if (!isPlainObject2(parsed) || parsed.version !== 1 || !Array.isArray(parsed.turns))
|
|
15136
|
+
return emptyPending();
|
|
15137
|
+
const turns = [];
|
|
15138
|
+
const positions = new Map;
|
|
15139
|
+
for (const value of parsed.turns) {
|
|
15140
|
+
const turn = normalizeTurn(value);
|
|
15141
|
+
if (!turn)
|
|
15142
|
+
continue;
|
|
15143
|
+
const position = positions.get(turn.key);
|
|
15144
|
+
if (position === undefined) {
|
|
15145
|
+
positions.set(turn.key, turns.length);
|
|
15146
|
+
turns.push(turn);
|
|
15147
|
+
continue;
|
|
15148
|
+
}
|
|
15149
|
+
const existing = turns[position];
|
|
15150
|
+
if (!existing)
|
|
15151
|
+
continue;
|
|
15152
|
+
const createdAt = Math.min(existing.createdAt, turn.createdAt);
|
|
15153
|
+
if (turn.updatedAt > existing.updatedAt)
|
|
15154
|
+
turns[position] = { ...turn, createdAt };
|
|
15155
|
+
else
|
|
15156
|
+
existing.createdAt = createdAt;
|
|
15157
|
+
}
|
|
15158
|
+
return { version: 1, turns };
|
|
15159
|
+
} catch {
|
|
15160
|
+
return emptyPending();
|
|
15161
|
+
}
|
|
15162
|
+
}
|
|
15163
|
+
async function writeRaw2(file2) {
|
|
15164
|
+
await writeJsonAtomic(pendingFilePath(), JSON.stringify(file2, null, 2));
|
|
15165
|
+
}
|
|
15166
|
+
var chain2 = Promise.resolve();
|
|
15167
|
+
function withProcessLock(fn) {
|
|
15168
|
+
const run = chain2.then(fn, fn);
|
|
15169
|
+
chain2 = run.then(ignore, ignore);
|
|
15170
|
+
return run;
|
|
15171
|
+
}
|
|
15172
|
+
function pendingLockDir() {
|
|
15173
|
+
return `${pendingFilePath()}.lock`;
|
|
15174
|
+
}
|
|
15175
|
+
async function readPending() {
|
|
15176
|
+
return withProcessLock(readRaw2);
|
|
15177
|
+
}
|
|
15178
|
+
async function mutatePending(fn) {
|
|
15179
|
+
return withProcessLock(() => withLock(pendingLockDir(), PENDING_WRITE_LOCK, async () => {
|
|
15180
|
+
const file2 = await readRaw2();
|
|
15181
|
+
const result = await fn(file2);
|
|
15182
|
+
await writeRaw2(file2);
|
|
15183
|
+
return result;
|
|
15184
|
+
}));
|
|
15185
|
+
}
|
|
15186
|
+
async function upsertPending(ref, schedule) {
|
|
15187
|
+
return mutatePending((file2) => {
|
|
15188
|
+
const key = pendingKey(ref);
|
|
15189
|
+
const existing = file2.turns.find((turn2) => turn2.key === key);
|
|
15190
|
+
const turn = {
|
|
15191
|
+
...ref,
|
|
15192
|
+
key,
|
|
15193
|
+
createdAt: existing?.createdAt ?? schedule.now,
|
|
15194
|
+
updatedAt: schedule.now,
|
|
15195
|
+
nextCheckAt: schedule.nextCheckAt,
|
|
15196
|
+
resumeAt: schedule.resumeAt
|
|
15197
|
+
};
|
|
15198
|
+
if (existing)
|
|
15199
|
+
Object.assign(existing, turn);
|
|
15200
|
+
else
|
|
15201
|
+
file2.turns.push(turn);
|
|
15202
|
+
return existing ?? turn;
|
|
15203
|
+
});
|
|
15204
|
+
}
|
|
15205
|
+
async function removePending(refOrKey) {
|
|
15206
|
+
const key = typeof refOrKey === "string" ? refOrKey : pendingKey(refOrKey);
|
|
15207
|
+
return mutatePending((file2) => {
|
|
15208
|
+
const before = file2.turns.length;
|
|
15209
|
+
file2.turns = file2.turns.filter((turn) => turn.key !== key);
|
|
15210
|
+
return file2.turns.length !== before;
|
|
15211
|
+
});
|
|
15212
|
+
}
|
|
15213
|
+
async function removePendingSession(workspace, sessionID) {
|
|
15214
|
+
return mutatePending((file2) => {
|
|
15215
|
+
const before = file2.turns.length;
|
|
15216
|
+
file2.turns = file2.turns.filter((turn) => turn.workspace !== workspace || turn.sessionID !== sessionID);
|
|
15217
|
+
return before - file2.turns.length;
|
|
15218
|
+
});
|
|
15219
|
+
}
|
|
15220
|
+
async function listPendingForWorkspace(workspace, providerID) {
|
|
15221
|
+
const file2 = await readPending();
|
|
15222
|
+
return file2.turns.filter((turn) => turn.workspace === workspace && (providerID === undefined || turn.providerID === providerID));
|
|
15223
|
+
}
|
|
15224
|
+
|
|
15225
|
+
// src/pending/coordinator.ts
|
|
15226
|
+
var disposedError = () => new Error("OpenCode plugin disposed");
|
|
15227
|
+
|
|
15228
|
+
class PendingCoordinator {
|
|
15229
|
+
workspace;
|
|
15230
|
+
providerID;
|
|
15231
|
+
adapter;
|
|
15232
|
+
config;
|
|
15233
|
+
dependencies;
|
|
15234
|
+
leases = new Map;
|
|
15235
|
+
acquiring = new Map;
|
|
15236
|
+
active = new Map;
|
|
15237
|
+
restoring = new Map;
|
|
15238
|
+
pendingToasts = new Map;
|
|
15239
|
+
disposing = false;
|
|
15240
|
+
constructor(options) {
|
|
15241
|
+
this.workspace = options.workspace;
|
|
15242
|
+
this.providerID = options.adapter.id;
|
|
15243
|
+
this.adapter = options.adapter;
|
|
15244
|
+
this.config = options.config;
|
|
15245
|
+
this.dependencies = {
|
|
15246
|
+
now: Date.now,
|
|
15247
|
+
sleep: sleepAbortable,
|
|
15248
|
+
readPool,
|
|
15249
|
+
refreshUsage: refreshUsageInBackground.bind(null, this.adapter),
|
|
15250
|
+
upsert: upsertPending,
|
|
15251
|
+
remove: removePending,
|
|
15252
|
+
acquireLease: acquirePendingLease,
|
|
15253
|
+
list: listPendingForWorkspace,
|
|
15254
|
+
removeSession: removePendingSession,
|
|
15255
|
+
onPending: ignore,
|
|
15256
|
+
onResumed: ignore,
|
|
15257
|
+
onRestored: ignore,
|
|
15258
|
+
onRestoreError: ignore,
|
|
15259
|
+
...options.dependencies
|
|
15260
|
+
};
|
|
15261
|
+
}
|
|
15262
|
+
async ensureLease(key) {
|
|
15263
|
+
if (this.leases.has(key))
|
|
15264
|
+
return;
|
|
15265
|
+
let acquisition = this.acquiring.get(key);
|
|
15266
|
+
if (!acquisition) {
|
|
15267
|
+
acquisition = this.dependencies.acquireLease(key);
|
|
15268
|
+
this.acquiring.set(key, acquisition);
|
|
15269
|
+
}
|
|
15270
|
+
try {
|
|
15271
|
+
const handle = await acquisition;
|
|
15272
|
+
this.leases.set(key, handle);
|
|
15273
|
+
} finally {
|
|
15274
|
+
this.acquiring.delete(key);
|
|
15275
|
+
}
|
|
15276
|
+
}
|
|
15277
|
+
async releaseLease(key) {
|
|
15278
|
+
const handle = this.leases.get(key);
|
|
15279
|
+
if (!handle)
|
|
15280
|
+
return;
|
|
15281
|
+
this.leases.delete(key);
|
|
15282
|
+
await handle.release();
|
|
15283
|
+
}
|
|
15284
|
+
async notifyPending(ref, recovery) {
|
|
15285
|
+
const key = pendingKey(ref);
|
|
15286
|
+
const signature = recovery.resumeAt?.toString() ?? "unknown";
|
|
15287
|
+
if (this.pendingToasts.get(key) === signature)
|
|
15288
|
+
return;
|
|
15289
|
+
this.pendingToasts.set(key, signature);
|
|
15290
|
+
await Promise.resolve(this.dependencies.onPending(ref, recovery)).catch(ignore);
|
|
15291
|
+
}
|
|
15292
|
+
async clear(ref) {
|
|
15293
|
+
const key = pendingKey(ref);
|
|
15294
|
+
try {
|
|
15295
|
+
await this.dependencies.remove(ref);
|
|
15296
|
+
this.pendingToasts.delete(key);
|
|
15297
|
+
} finally {
|
|
15298
|
+
await this.releaseLease(key);
|
|
15299
|
+
}
|
|
15300
|
+
}
|
|
15301
|
+
async waitForCapacity(ref, initial, outerSignal) {
|
|
15302
|
+
const key = pendingKey(ref);
|
|
15303
|
+
if (this.disposing)
|
|
15304
|
+
throw disposedError();
|
|
15305
|
+
await this.ensureLease(key);
|
|
15306
|
+
try {
|
|
15307
|
+
await this.dependencies.upsert(ref, {
|
|
15308
|
+
now: this.dependencies.now(),
|
|
15309
|
+
nextCheckAt: initial.nextCheckAt,
|
|
15310
|
+
resumeAt: initial.resumeAt
|
|
15311
|
+
});
|
|
15312
|
+
} catch (error45) {
|
|
15313
|
+
await this.releaseLease(key);
|
|
15314
|
+
throw error45;
|
|
15315
|
+
}
|
|
15316
|
+
if (this.disposing) {
|
|
15317
|
+
await this.releaseLease(key);
|
|
15318
|
+
throw disposedError();
|
|
15319
|
+
}
|
|
15320
|
+
const controller = new AbortController;
|
|
15321
|
+
const forwardAbort = () => controller.abort(outerSignal?.reason);
|
|
15322
|
+
if (outerSignal?.aborted)
|
|
15323
|
+
forwardAbort();
|
|
15324
|
+
else
|
|
15325
|
+
outerSignal?.addEventListener("abort", forwardAbort, { once: true });
|
|
15326
|
+
this.active.set(controller, ref);
|
|
15327
|
+
let recovery = initial;
|
|
15328
|
+
await this.notifyPending(ref, recovery);
|
|
15329
|
+
try {
|
|
15330
|
+
for (;; ) {
|
|
15331
|
+
await this.dependencies.sleep(Math.max(0, recovery.nextCheckAt - this.dependencies.now()), controller.signal);
|
|
15332
|
+
const now = this.dependencies.now();
|
|
15333
|
+
await this.dependencies.refreshUsage(now).catch(ignore);
|
|
15334
|
+
let next;
|
|
15335
|
+
try {
|
|
15336
|
+
const pool = await this.dependencies.readPool();
|
|
15337
|
+
next = classifyProviderRecovery(pool.accounts, this.providerID, this.config, now, USAGE_REFRESH_TTL_MS);
|
|
15338
|
+
} catch {
|
|
15339
|
+
next = {
|
|
15340
|
+
state: "quota-blocked",
|
|
15341
|
+
nextCheckAt: now + USAGE_REFRESH_TTL_MS,
|
|
15342
|
+
resumeAt: recovery.resumeAt
|
|
15343
|
+
};
|
|
15344
|
+
}
|
|
15345
|
+
if (next.state === "available") {
|
|
15346
|
+
await Promise.resolve(this.dependencies.onResumed(ref)).catch(ignore);
|
|
15347
|
+
return "available";
|
|
15348
|
+
}
|
|
15349
|
+
if (next.state === "unusable") {
|
|
15350
|
+
await this.clear(ref);
|
|
15351
|
+
return "unusable";
|
|
15352
|
+
}
|
|
15353
|
+
recovery = next;
|
|
15354
|
+
await this.dependencies.upsert(ref, {
|
|
15355
|
+
now,
|
|
15356
|
+
nextCheckAt: recovery.nextCheckAt,
|
|
15357
|
+
resumeAt: recovery.resumeAt
|
|
15358
|
+
}).catch(ignore);
|
|
15359
|
+
await this.notifyPending(ref, recovery);
|
|
15360
|
+
}
|
|
15361
|
+
} catch (error45) {
|
|
15362
|
+
if (controller.signal.aborted) {
|
|
15363
|
+
if (this.disposing)
|
|
15364
|
+
await this.releaseLease(key);
|
|
15365
|
+
else
|
|
15366
|
+
await this.clear(ref);
|
|
15367
|
+
} else {
|
|
15368
|
+
await this.releaseLease(key);
|
|
15369
|
+
}
|
|
15370
|
+
throw error45;
|
|
15371
|
+
} finally {
|
|
15372
|
+
outerSignal?.removeEventListener("abort", forwardAbort);
|
|
15373
|
+
this.active.delete(controller);
|
|
15374
|
+
}
|
|
15375
|
+
}
|
|
15376
|
+
async complete(ref) {
|
|
15377
|
+
const key = pendingKey(ref);
|
|
15378
|
+
if (!this.leases.has(key) && !this.pendingToasts.has(key))
|
|
15379
|
+
return;
|
|
15380
|
+
await this.clear(ref);
|
|
15381
|
+
}
|
|
15382
|
+
async abort(ref) {
|
|
15383
|
+
const key = pendingKey(ref);
|
|
15384
|
+
if (!this.leases.has(key) && !this.pendingToasts.has(key))
|
|
15385
|
+
return;
|
|
15386
|
+
if (this.disposing) {
|
|
15387
|
+
this.pendingToasts.delete(key);
|
|
15388
|
+
await this.releaseLease(key);
|
|
15389
|
+
return;
|
|
15390
|
+
}
|
|
15391
|
+
await this.clear(ref);
|
|
15392
|
+
}
|
|
15393
|
+
async restoreOnce(turn, client) {
|
|
15394
|
+
const message = await client.session.message({
|
|
15395
|
+
path: { id: turn.sessionID, messageID: turn.messageID },
|
|
15396
|
+
query: { directory: this.workspace }
|
|
15397
|
+
});
|
|
15398
|
+
if (message.response?.status === 404) {
|
|
15399
|
+
await this.clear(turn);
|
|
15400
|
+
return;
|
|
15401
|
+
}
|
|
15402
|
+
if (message.error !== undefined)
|
|
15403
|
+
throw new Error(`Failed to read pending message ${turn.messageID}`);
|
|
15404
|
+
const info = message.data?.info;
|
|
15405
|
+
if (!info || info.role !== "user" || info.id !== turn.messageID || info.sessionID !== turn.sessionID || info.model.providerID !== turn.providerID) {
|
|
15406
|
+
await this.clear(turn);
|
|
15407
|
+
return;
|
|
15408
|
+
}
|
|
15409
|
+
const history = await client.session.messages({
|
|
15410
|
+
path: { id: turn.sessionID },
|
|
15411
|
+
query: { directory: this.workspace }
|
|
15412
|
+
});
|
|
15413
|
+
if (history.response?.status === 404) {
|
|
15414
|
+
await this.clear(turn);
|
|
15415
|
+
return;
|
|
15416
|
+
}
|
|
15417
|
+
if (history.error !== undefined || !history.data)
|
|
15418
|
+
throw new Error(`Failed to read pending session ${turn.sessionID}`);
|
|
15419
|
+
const completed = history.data.some((entry) => entry.info.role === "assistant" && entry.info.parentID === turn.messageID && typeof entry.info.finish === "string" && entry.info.finish.length > 0 && entry.info.error === undefined);
|
|
15420
|
+
if (completed) {
|
|
15421
|
+
await this.clear(turn);
|
|
15422
|
+
return;
|
|
15423
|
+
}
|
|
15424
|
+
const prompt = await client.session.prompt({
|
|
15425
|
+
path: { id: turn.sessionID },
|
|
15426
|
+
query: { directory: this.workspace },
|
|
15427
|
+
body: {
|
|
15428
|
+
messageID: info.id,
|
|
15429
|
+
model: info.model,
|
|
15430
|
+
agent: info.agent,
|
|
15431
|
+
...info.system === undefined ? {} : { system: info.system },
|
|
15432
|
+
...info.tools === undefined ? {} : { tools: info.tools },
|
|
15433
|
+
parts: []
|
|
15434
|
+
}
|
|
15435
|
+
});
|
|
15436
|
+
if (prompt.response?.status === 404) {
|
|
15437
|
+
await this.clear(turn);
|
|
15438
|
+
return;
|
|
15439
|
+
}
|
|
15440
|
+
if (prompt.error !== undefined)
|
|
15441
|
+
throw new Error(`Failed to restore pending message ${turn.messageID}`);
|
|
15442
|
+
}
|
|
15443
|
+
async restoreWithRetry(original, client) {
|
|
15444
|
+
const controller = new AbortController;
|
|
15445
|
+
this.active.set(controller, original);
|
|
15446
|
+
let backoffMs = 1000;
|
|
15447
|
+
try {
|
|
15448
|
+
for (;; ) {
|
|
15449
|
+
if (this.disposing)
|
|
15450
|
+
return;
|
|
15451
|
+
try {
|
|
15452
|
+
const current2 = (await this.dependencies.list(this.workspace, this.providerID)).find((turn) => turn.key === original.key);
|
|
15453
|
+
if (!current2)
|
|
15454
|
+
return;
|
|
15455
|
+
await this.ensureLease(current2.key);
|
|
15456
|
+
try {
|
|
15457
|
+
await this.restoreOnce(current2, client);
|
|
15458
|
+
return;
|
|
15459
|
+
} finally {
|
|
15460
|
+
await this.releaseLease(current2.key);
|
|
15461
|
+
}
|
|
15462
|
+
} catch (error45) {
|
|
15463
|
+
if (this.disposing || controller.signal.aborted)
|
|
15464
|
+
return;
|
|
15465
|
+
await Promise.resolve(this.dependencies.onRestoreError(original, error45)).catch(ignore);
|
|
15466
|
+
try {
|
|
15467
|
+
await this.dependencies.sleep(backoffMs, controller.signal);
|
|
15468
|
+
} catch (sleepError) {
|
|
15469
|
+
if (this.disposing || controller.signal.aborted)
|
|
15470
|
+
return;
|
|
15471
|
+
throw sleepError;
|
|
15472
|
+
}
|
|
15473
|
+
backoffMs = Math.min(backoffMs * 2, 60000);
|
|
15474
|
+
}
|
|
15475
|
+
}
|
|
15476
|
+
} finally {
|
|
15477
|
+
this.active.delete(controller);
|
|
15478
|
+
}
|
|
15479
|
+
}
|
|
15480
|
+
async restore(client) {
|
|
15481
|
+
if (this.disposing)
|
|
15482
|
+
return;
|
|
15483
|
+
const turns = (await this.dependencies.list(this.workspace, this.providerID)).filter((turn) => turn.workspace === this.workspace && turn.providerID === this.providerID);
|
|
15484
|
+
if (turns.length === 0)
|
|
15485
|
+
return;
|
|
15486
|
+
await Promise.resolve(this.dependencies.onRestored(turns.length)).catch(ignore);
|
|
15487
|
+
const tasks = turns.map((turn) => {
|
|
15488
|
+
const existing = this.restoring.get(turn.key);
|
|
15489
|
+
if (existing)
|
|
15490
|
+
return existing;
|
|
15491
|
+
const task = this.restoreWithRetry(turn, client);
|
|
15492
|
+
this.restoring.set(turn.key, task);
|
|
15493
|
+
task.finally(() => {
|
|
15494
|
+
if (this.restoring.get(turn.key) === task)
|
|
15495
|
+
this.restoring.delete(turn.key);
|
|
15496
|
+
}).catch(ignore);
|
|
15497
|
+
return task;
|
|
15498
|
+
});
|
|
15499
|
+
await Promise.allSettled(tasks);
|
|
15500
|
+
}
|
|
15501
|
+
async removeSession(sessionID) {
|
|
15502
|
+
const turns = (await this.dependencies.list(this.workspace)).filter((turn) => turn.sessionID === sessionID);
|
|
15503
|
+
for (const [controller, ref] of this.active) {
|
|
15504
|
+
if (ref.sessionID === sessionID)
|
|
15505
|
+
controller.abort();
|
|
15506
|
+
}
|
|
15507
|
+
const removed = await this.dependencies.removeSession(this.workspace, sessionID);
|
|
15508
|
+
await Promise.allSettled(turns.map(async (turn) => {
|
|
15509
|
+
this.pendingToasts.delete(turn.key);
|
|
15510
|
+
await this.releaseLease(turn.key);
|
|
15511
|
+
}));
|
|
15512
|
+
return removed;
|
|
15513
|
+
}
|
|
15514
|
+
async dispose() {
|
|
15515
|
+
if (this.disposing)
|
|
15516
|
+
return;
|
|
15517
|
+
this.disposing = true;
|
|
15518
|
+
for (const controller of this.active.keys())
|
|
15519
|
+
controller.abort(disposedError());
|
|
15520
|
+
await Promise.allSettled([...this.leases.keys()].map((key) => this.releaseLease(key)));
|
|
15521
|
+
}
|
|
15522
|
+
}
|
|
14762
15523
|
|
|
14763
15524
|
// src/prime.ts
|
|
14764
15525
|
async function primeInUse(providerID, now) {
|
|
@@ -14790,13 +15551,14 @@ function zeroOutCost(provider) {
|
|
|
14790
15551
|
};
|
|
14791
15552
|
}
|
|
14792
15553
|
}
|
|
14793
|
-
function buildAuthHook(adapter, client) {
|
|
15554
|
+
function buildAuthHook(adapter, client, pending) {
|
|
14794
15555
|
const label = PROVIDER_LABELS[adapter.id] ?? adapter.id;
|
|
14795
15556
|
return {
|
|
14796
15557
|
provider: adapter.id,
|
|
14797
15558
|
async loader(getAuth, provider) {
|
|
14798
15559
|
await bootstrapFromOpencodeAuth(adapter.id, getAuth);
|
|
14799
15560
|
zeroOutCost(provider);
|
|
15561
|
+
await adapter.prime?.(Date.now()).catch(ignore);
|
|
14800
15562
|
refreshUsageInBackground(adapter, Date.now()).then(() => primeInUse(adapter.id, Date.now())).catch(ignore);
|
|
14801
15563
|
return {
|
|
14802
15564
|
apiKey: "",
|
|
@@ -14807,7 +15569,7 @@ function buildAuthHook(adapter, client) {
|
|
|
14807
15569
|
onModelFallback: (providerID, account, fromModel, toModel, fromTier) => {
|
|
14808
15570
|
notifyModelFallback(client, providerID, account, fromModel, toModel, fromTier);
|
|
14809
15571
|
}
|
|
14810
|
-
}, Object.keys(provider.models))
|
|
15572
|
+
}, Object.keys(provider.models), pending)
|
|
14811
15573
|
};
|
|
14812
15574
|
},
|
|
14813
15575
|
methods: [
|
|
@@ -14842,21 +15604,41 @@ function buildAuthHook(adapter, client) {
|
|
|
14842
15604
|
function createProviderPlugin(adapter) {
|
|
14843
15605
|
return async (input) => {
|
|
14844
15606
|
const client = input.client;
|
|
15607
|
+
const pending = new PendingCoordinator({
|
|
15608
|
+
workspace: input.worktree || input.directory,
|
|
15609
|
+
adapter,
|
|
15610
|
+
config: loadConfig(),
|
|
15611
|
+
dependencies: {
|
|
15612
|
+
onPending: (_ref, recovery) => notifyPending(client, adapter.id, recovery),
|
|
15613
|
+
onResumed: () => notifyPendingResumed(client, adapter.id),
|
|
15614
|
+
onRestored: (count) => notifyPendingRestored(client, adapter.id, count),
|
|
15615
|
+
onRestoreError: (ref) => notifyPendingRestoreError(client, adapter.id, ref.messageID)
|
|
15616
|
+
}
|
|
15617
|
+
});
|
|
15618
|
+
pending.restore(input.client).catch(ignore);
|
|
14845
15619
|
return {
|
|
14846
|
-
auth: buildAuthHook(adapter, client),
|
|
15620
|
+
auth: buildAuthHook(adapter, client, pending),
|
|
14847
15621
|
"chat.headers": async (hook, output) => {
|
|
14848
15622
|
if (hook.model.providerID !== adapter.id)
|
|
14849
15623
|
return;
|
|
14850
|
-
if (hook.sessionID)
|
|
15624
|
+
if (hook.sessionID) {
|
|
14851
15625
|
output.headers[SESSION_HEADER] = hook.sessionID;
|
|
14852
|
-
|
|
15626
|
+
output.headers[MESSAGE_HEADER] = hook.message.id;
|
|
15627
|
+
}
|
|
15628
|
+
},
|
|
15629
|
+
event: async ({ event }) => {
|
|
15630
|
+
if (event.type !== "session.deleted")
|
|
15631
|
+
return;
|
|
15632
|
+
await pending.removeSession(event.properties.info.id);
|
|
15633
|
+
},
|
|
15634
|
+
dispose: () => pending.dispose()
|
|
14853
15635
|
};
|
|
14854
15636
|
};
|
|
14855
15637
|
}
|
|
14856
15638
|
var AnthropicLoadBalancerPlugin = createProviderPlugin(anthropicAdapter);
|
|
14857
15639
|
var OpenAILoadBalancerPlugin = createProviderPlugin(openaiAdapter);
|
|
14858
15640
|
var lbResult = (output) => ({ title: "Auth Load Balancer", output });
|
|
14859
|
-
var AuthLoadBalancerStatusPlugin = async () => ({
|
|
15641
|
+
var AuthLoadBalancerStatusPlugin = async (input) => ({
|
|
14860
15642
|
tool: {
|
|
14861
15643
|
auth_lb_status: tool({
|
|
14862
15644
|
description: "Show the auth load-balancer pool: the in-use account per provider, each account's weekly and 5h usage, cooldowns, and the ranked next-candidate accounts. Refreshes stale usage from the provider usage endpoints (throttled) before rendering.",
|
|
@@ -14866,7 +15648,11 @@ var AuthLoadBalancerStatusPlugin = async () => ({
|
|
|
14866
15648
|
const pool = await readPool();
|
|
14867
15649
|
await refreshAllUsageInBackground(now, pool).catch(ignore);
|
|
14868
15650
|
const renderedAt = Date.now();
|
|
14869
|
-
|
|
15651
|
+
const status = renderStatus(await readStatus(renderedAt), renderedAt);
|
|
15652
|
+
const pending = renderPendingStatus(await listPendingForWorkspace(input.worktree || input.directory), renderedAt);
|
|
15653
|
+
return lbResult(pending ? `${status}
|
|
15654
|
+
|
|
15655
|
+
${pending}` : status);
|
|
14870
15656
|
}
|
|
14871
15657
|
}),
|
|
14872
15658
|
auth_lb_rename: tool({
|
|
@@ -14923,7 +15709,7 @@ var AuthLoadBalancerStatusPlugin = async () => ({
|
|
|
14923
15709
|
}
|
|
14924
15710
|
});
|
|
14925
15711
|
export {
|
|
14926
|
-
|
|
15712
|
+
AnthropicLoadBalancerPlugin,
|
|
14927
15713
|
AuthLoadBalancerStatusPlugin,
|
|
14928
|
-
|
|
15714
|
+
OpenAILoadBalancerPlugin
|
|
14929
15715
|
};
|