@13rac1/openclaw-plugin-claude-code 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3878 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
8
+ var value_exports = {};
9
+ __export(value_exports, {
10
+ HasPropertyKey: () => HasPropertyKey,
11
+ IsArray: () => IsArray,
12
+ IsAsyncIterator: () => IsAsyncIterator,
13
+ IsBigInt: () => IsBigInt,
14
+ IsBoolean: () => IsBoolean,
15
+ IsDate: () => IsDate,
16
+ IsFunction: () => IsFunction,
17
+ IsIterator: () => IsIterator,
18
+ IsNull: () => IsNull,
19
+ IsNumber: () => IsNumber,
20
+ IsObject: () => IsObject,
21
+ IsRegExp: () => IsRegExp,
22
+ IsString: () => IsString,
23
+ IsSymbol: () => IsSymbol,
24
+ IsUint8Array: () => IsUint8Array,
25
+ IsUndefined: () => IsUndefined
26
+ });
27
+ function HasPropertyKey(value, key) {
28
+ return key in value;
29
+ }
30
+ function IsAsyncIterator(value) {
31
+ return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
32
+ }
33
+ function IsArray(value) {
34
+ return Array.isArray(value);
35
+ }
36
+ function IsBigInt(value) {
37
+ return typeof value === "bigint";
38
+ }
39
+ function IsBoolean(value) {
40
+ return typeof value === "boolean";
41
+ }
42
+ function IsDate(value) {
43
+ return value instanceof globalThis.Date;
44
+ }
45
+ function IsFunction(value) {
46
+ return typeof value === "function";
47
+ }
48
+ function IsIterator(value) {
49
+ return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.iterator in value;
50
+ }
51
+ function IsNull(value) {
52
+ return value === null;
53
+ }
54
+ function IsNumber(value) {
55
+ return typeof value === "number";
56
+ }
57
+ function IsObject(value) {
58
+ return typeof value === "object" && value !== null;
59
+ }
60
+ function IsRegExp(value) {
61
+ return value instanceof globalThis.RegExp;
62
+ }
63
+ function IsString(value) {
64
+ return typeof value === "string";
65
+ }
66
+ function IsSymbol(value) {
67
+ return typeof value === "symbol";
68
+ }
69
+ function IsUint8Array(value) {
70
+ return value instanceof globalThis.Uint8Array;
71
+ }
72
+ function IsUndefined(value) {
73
+ return value === void 0;
74
+ }
75
+
76
+ // node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
77
+ function ArrayType(value) {
78
+ return value.map((value2) => Visit(value2));
79
+ }
80
+ function DateType(value) {
81
+ return new Date(value.getTime());
82
+ }
83
+ function Uint8ArrayType(value) {
84
+ return new Uint8Array(value);
85
+ }
86
+ function RegExpType(value) {
87
+ return new RegExp(value.source, value.flags);
88
+ }
89
+ function ObjectType(value) {
90
+ const result = {};
91
+ for (const key of Object.getOwnPropertyNames(value)) {
92
+ result[key] = Visit(value[key]);
93
+ }
94
+ for (const key of Object.getOwnPropertySymbols(value)) {
95
+ result[key] = Visit(value[key]);
96
+ }
97
+ return result;
98
+ }
99
+ function Visit(value) {
100
+ return IsArray(value) ? ArrayType(value) : IsDate(value) ? DateType(value) : IsUint8Array(value) ? Uint8ArrayType(value) : IsRegExp(value) ? RegExpType(value) : IsObject(value) ? ObjectType(value) : value;
101
+ }
102
+ function Clone(value) {
103
+ return Visit(value);
104
+ }
105
+
106
+ // node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
107
+ function CloneType(schema, options) {
108
+ return options === void 0 ? Clone(schema) : Clone({ ...options, ...schema });
109
+ }
110
+
111
+ // node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
112
+ function IsObject2(value) {
113
+ return value !== null && typeof value === "object";
114
+ }
115
+ function IsArray2(value) {
116
+ return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
117
+ }
118
+ function IsUndefined2(value) {
119
+ return value === void 0;
120
+ }
121
+ function IsNumber2(value) {
122
+ return typeof value === "number";
123
+ }
124
+
125
+ // node_modules/@sinclair/typebox/build/esm/system/policy.mjs
126
+ var TypeSystemPolicy;
127
+ (function(TypeSystemPolicy2) {
128
+ TypeSystemPolicy2.InstanceMode = "default";
129
+ TypeSystemPolicy2.ExactOptionalPropertyTypes = false;
130
+ TypeSystemPolicy2.AllowArrayObject = false;
131
+ TypeSystemPolicy2.AllowNaN = false;
132
+ TypeSystemPolicy2.AllowNullVoid = false;
133
+ function IsExactOptionalProperty(value, key) {
134
+ return TypeSystemPolicy2.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
135
+ }
136
+ TypeSystemPolicy2.IsExactOptionalProperty = IsExactOptionalProperty;
137
+ function IsObjectLike(value) {
138
+ const isObject = IsObject2(value);
139
+ return TypeSystemPolicy2.AllowArrayObject ? isObject : isObject && !IsArray2(value);
140
+ }
141
+ TypeSystemPolicy2.IsObjectLike = IsObjectLike;
142
+ function IsRecordLike(value) {
143
+ return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
144
+ }
145
+ TypeSystemPolicy2.IsRecordLike = IsRecordLike;
146
+ function IsNumberLike(value) {
147
+ return TypeSystemPolicy2.AllowNaN ? IsNumber2(value) : Number.isFinite(value);
148
+ }
149
+ TypeSystemPolicy2.IsNumberLike = IsNumberLike;
150
+ function IsVoidLike(value) {
151
+ const isUndefined = IsUndefined2(value);
152
+ return TypeSystemPolicy2.AllowNullVoid ? isUndefined || value === null : isUndefined;
153
+ }
154
+ TypeSystemPolicy2.IsVoidLike = IsVoidLike;
155
+ })(TypeSystemPolicy || (TypeSystemPolicy = {}));
156
+
157
+ // node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
158
+ function ImmutableArray(value) {
159
+ return globalThis.Object.freeze(value).map((value2) => Immutable(value2));
160
+ }
161
+ function ImmutableDate(value) {
162
+ return value;
163
+ }
164
+ function ImmutableUint8Array(value) {
165
+ return value;
166
+ }
167
+ function ImmutableRegExp(value) {
168
+ return value;
169
+ }
170
+ function ImmutableObject(value) {
171
+ const result = {};
172
+ for (const key of Object.getOwnPropertyNames(value)) {
173
+ result[key] = Immutable(value[key]);
174
+ }
175
+ for (const key of Object.getOwnPropertySymbols(value)) {
176
+ result[key] = Immutable(value[key]);
177
+ }
178
+ return globalThis.Object.freeze(result);
179
+ }
180
+ function Immutable(value) {
181
+ return IsArray(value) ? ImmutableArray(value) : IsDate(value) ? ImmutableDate(value) : IsUint8Array(value) ? ImmutableUint8Array(value) : IsRegExp(value) ? ImmutableRegExp(value) : IsObject(value) ? ImmutableObject(value) : value;
182
+ }
183
+
184
+ // node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
185
+ function CreateType(schema, options) {
186
+ const result = options !== void 0 ? { ...options, ...schema } : schema;
187
+ switch (TypeSystemPolicy.InstanceMode) {
188
+ case "freeze":
189
+ return Immutable(result);
190
+ case "clone":
191
+ return Clone(result);
192
+ default:
193
+ return result;
194
+ }
195
+ }
196
+
197
+ // node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
198
+ var TypeBoxError = class extends Error {
199
+ constructor(message) {
200
+ super(message);
201
+ }
202
+ };
203
+
204
+ // node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
205
+ var TransformKind = /* @__PURE__ */ Symbol.for("TypeBox.Transform");
206
+ var ReadonlyKind = /* @__PURE__ */ Symbol.for("TypeBox.Readonly");
207
+ var OptionalKind = /* @__PURE__ */ Symbol.for("TypeBox.Optional");
208
+ var Hint = /* @__PURE__ */ Symbol.for("TypeBox.Hint");
209
+ var Kind = /* @__PURE__ */ Symbol.for("TypeBox.Kind");
210
+
211
+ // node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
212
+ function IsReadonly(value) {
213
+ return IsObject(value) && value[ReadonlyKind] === "Readonly";
214
+ }
215
+ function IsOptional(value) {
216
+ return IsObject(value) && value[OptionalKind] === "Optional";
217
+ }
218
+ function IsAny(value) {
219
+ return IsKindOf(value, "Any");
220
+ }
221
+ function IsArgument(value) {
222
+ return IsKindOf(value, "Argument");
223
+ }
224
+ function IsArray3(value) {
225
+ return IsKindOf(value, "Array");
226
+ }
227
+ function IsAsyncIterator2(value) {
228
+ return IsKindOf(value, "AsyncIterator");
229
+ }
230
+ function IsBigInt2(value) {
231
+ return IsKindOf(value, "BigInt");
232
+ }
233
+ function IsBoolean2(value) {
234
+ return IsKindOf(value, "Boolean");
235
+ }
236
+ function IsComputed(value) {
237
+ return IsKindOf(value, "Computed");
238
+ }
239
+ function IsConstructor(value) {
240
+ return IsKindOf(value, "Constructor");
241
+ }
242
+ function IsDate2(value) {
243
+ return IsKindOf(value, "Date");
244
+ }
245
+ function IsFunction2(value) {
246
+ return IsKindOf(value, "Function");
247
+ }
248
+ function IsInteger(value) {
249
+ return IsKindOf(value, "Integer");
250
+ }
251
+ function IsIntersect(value) {
252
+ return IsKindOf(value, "Intersect");
253
+ }
254
+ function IsIterator2(value) {
255
+ return IsKindOf(value, "Iterator");
256
+ }
257
+ function IsKindOf(value, kind) {
258
+ return IsObject(value) && Kind in value && value[Kind] === kind;
259
+ }
260
+ function IsLiteralValue(value) {
261
+ return IsBoolean(value) || IsNumber(value) || IsString(value);
262
+ }
263
+ function IsLiteral(value) {
264
+ return IsKindOf(value, "Literal");
265
+ }
266
+ function IsMappedKey(value) {
267
+ return IsKindOf(value, "MappedKey");
268
+ }
269
+ function IsMappedResult(value) {
270
+ return IsKindOf(value, "MappedResult");
271
+ }
272
+ function IsNever(value) {
273
+ return IsKindOf(value, "Never");
274
+ }
275
+ function IsNot(value) {
276
+ return IsKindOf(value, "Not");
277
+ }
278
+ function IsNull2(value) {
279
+ return IsKindOf(value, "Null");
280
+ }
281
+ function IsNumber3(value) {
282
+ return IsKindOf(value, "Number");
283
+ }
284
+ function IsObject3(value) {
285
+ return IsKindOf(value, "Object");
286
+ }
287
+ function IsPromise(value) {
288
+ return IsKindOf(value, "Promise");
289
+ }
290
+ function IsRecord(value) {
291
+ return IsKindOf(value, "Record");
292
+ }
293
+ function IsRef(value) {
294
+ return IsKindOf(value, "Ref");
295
+ }
296
+ function IsRegExp2(value) {
297
+ return IsKindOf(value, "RegExp");
298
+ }
299
+ function IsString2(value) {
300
+ return IsKindOf(value, "String");
301
+ }
302
+ function IsSymbol2(value) {
303
+ return IsKindOf(value, "Symbol");
304
+ }
305
+ function IsTemplateLiteral(value) {
306
+ return IsKindOf(value, "TemplateLiteral");
307
+ }
308
+ function IsThis(value) {
309
+ return IsKindOf(value, "This");
310
+ }
311
+ function IsTransform(value) {
312
+ return IsObject(value) && TransformKind in value;
313
+ }
314
+ function IsTuple(value) {
315
+ return IsKindOf(value, "Tuple");
316
+ }
317
+ function IsUndefined3(value) {
318
+ return IsKindOf(value, "Undefined");
319
+ }
320
+ function IsUnion(value) {
321
+ return IsKindOf(value, "Union");
322
+ }
323
+ function IsUint8Array2(value) {
324
+ return IsKindOf(value, "Uint8Array");
325
+ }
326
+ function IsUnknown(value) {
327
+ return IsKindOf(value, "Unknown");
328
+ }
329
+ function IsUnsafe(value) {
330
+ return IsKindOf(value, "Unsafe");
331
+ }
332
+ function IsVoid(value) {
333
+ return IsKindOf(value, "Void");
334
+ }
335
+ function IsKind(value) {
336
+ return IsObject(value) && Kind in value && IsString(value[Kind]);
337
+ }
338
+ function IsSchema(value) {
339
+ return IsAny(value) || IsArgument(value) || IsArray3(value) || IsBoolean2(value) || IsBigInt2(value) || IsAsyncIterator2(value) || IsComputed(value) || IsConstructor(value) || IsDate2(value) || IsFunction2(value) || IsInteger(value) || IsIntersect(value) || IsIterator2(value) || IsLiteral(value) || IsMappedKey(value) || IsMappedResult(value) || IsNever(value) || IsNot(value) || IsNull2(value) || IsNumber3(value) || IsObject3(value) || IsPromise(value) || IsRecord(value) || IsRef(value) || IsRegExp2(value) || IsString2(value) || IsSymbol2(value) || IsTemplateLiteral(value) || IsThis(value) || IsTuple(value) || IsUndefined3(value) || IsUnion(value) || IsUint8Array2(value) || IsUnknown(value) || IsUnsafe(value) || IsVoid(value) || IsKind(value);
340
+ }
341
+
342
+ // node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
343
+ var type_exports = {};
344
+ __export(type_exports, {
345
+ IsAny: () => IsAny2,
346
+ IsArgument: () => IsArgument2,
347
+ IsArray: () => IsArray4,
348
+ IsAsyncIterator: () => IsAsyncIterator3,
349
+ IsBigInt: () => IsBigInt3,
350
+ IsBoolean: () => IsBoolean3,
351
+ IsComputed: () => IsComputed2,
352
+ IsConstructor: () => IsConstructor2,
353
+ IsDate: () => IsDate3,
354
+ IsFunction: () => IsFunction3,
355
+ IsImport: () => IsImport,
356
+ IsInteger: () => IsInteger2,
357
+ IsIntersect: () => IsIntersect2,
358
+ IsIterator: () => IsIterator3,
359
+ IsKind: () => IsKind2,
360
+ IsKindOf: () => IsKindOf2,
361
+ IsLiteral: () => IsLiteral2,
362
+ IsLiteralBoolean: () => IsLiteralBoolean,
363
+ IsLiteralNumber: () => IsLiteralNumber,
364
+ IsLiteralString: () => IsLiteralString,
365
+ IsLiteralValue: () => IsLiteralValue2,
366
+ IsMappedKey: () => IsMappedKey2,
367
+ IsMappedResult: () => IsMappedResult2,
368
+ IsNever: () => IsNever2,
369
+ IsNot: () => IsNot2,
370
+ IsNull: () => IsNull3,
371
+ IsNumber: () => IsNumber4,
372
+ IsObject: () => IsObject4,
373
+ IsOptional: () => IsOptional2,
374
+ IsPromise: () => IsPromise2,
375
+ IsProperties: () => IsProperties,
376
+ IsReadonly: () => IsReadonly2,
377
+ IsRecord: () => IsRecord2,
378
+ IsRecursive: () => IsRecursive,
379
+ IsRef: () => IsRef2,
380
+ IsRegExp: () => IsRegExp3,
381
+ IsSchema: () => IsSchema2,
382
+ IsString: () => IsString3,
383
+ IsSymbol: () => IsSymbol3,
384
+ IsTemplateLiteral: () => IsTemplateLiteral2,
385
+ IsThis: () => IsThis2,
386
+ IsTransform: () => IsTransform2,
387
+ IsTuple: () => IsTuple2,
388
+ IsUint8Array: () => IsUint8Array3,
389
+ IsUndefined: () => IsUndefined4,
390
+ IsUnion: () => IsUnion2,
391
+ IsUnionLiteral: () => IsUnionLiteral,
392
+ IsUnknown: () => IsUnknown2,
393
+ IsUnsafe: () => IsUnsafe2,
394
+ IsVoid: () => IsVoid2,
395
+ TypeGuardUnknownTypeError: () => TypeGuardUnknownTypeError
396
+ });
397
+ var TypeGuardUnknownTypeError = class extends TypeBoxError {
398
+ };
399
+ var KnownTypes = [
400
+ "Argument",
401
+ "Any",
402
+ "Array",
403
+ "AsyncIterator",
404
+ "BigInt",
405
+ "Boolean",
406
+ "Computed",
407
+ "Constructor",
408
+ "Date",
409
+ "Enum",
410
+ "Function",
411
+ "Integer",
412
+ "Intersect",
413
+ "Iterator",
414
+ "Literal",
415
+ "MappedKey",
416
+ "MappedResult",
417
+ "Not",
418
+ "Null",
419
+ "Number",
420
+ "Object",
421
+ "Promise",
422
+ "Record",
423
+ "Ref",
424
+ "RegExp",
425
+ "String",
426
+ "Symbol",
427
+ "TemplateLiteral",
428
+ "This",
429
+ "Tuple",
430
+ "Undefined",
431
+ "Union",
432
+ "Uint8Array",
433
+ "Unknown",
434
+ "Void"
435
+ ];
436
+ function IsPattern(value) {
437
+ try {
438
+ new RegExp(value);
439
+ return true;
440
+ } catch {
441
+ return false;
442
+ }
443
+ }
444
+ function IsControlCharacterFree(value) {
445
+ if (!IsString(value))
446
+ return false;
447
+ for (let i = 0; i < value.length; i++) {
448
+ const code = value.charCodeAt(i);
449
+ if (code >= 7 && code <= 13 || code === 27 || code === 127) {
450
+ return false;
451
+ }
452
+ }
453
+ return true;
454
+ }
455
+ function IsAdditionalProperties(value) {
456
+ return IsOptionalBoolean(value) || IsSchema2(value);
457
+ }
458
+ function IsOptionalBigInt(value) {
459
+ return IsUndefined(value) || IsBigInt(value);
460
+ }
461
+ function IsOptionalNumber(value) {
462
+ return IsUndefined(value) || IsNumber(value);
463
+ }
464
+ function IsOptionalBoolean(value) {
465
+ return IsUndefined(value) || IsBoolean(value);
466
+ }
467
+ function IsOptionalString(value) {
468
+ return IsUndefined(value) || IsString(value);
469
+ }
470
+ function IsOptionalPattern(value) {
471
+ return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value) && IsPattern(value);
472
+ }
473
+ function IsOptionalFormat(value) {
474
+ return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value);
475
+ }
476
+ function IsOptionalSchema(value) {
477
+ return IsUndefined(value) || IsSchema2(value);
478
+ }
479
+ function IsReadonly2(value) {
480
+ return IsObject(value) && value[ReadonlyKind] === "Readonly";
481
+ }
482
+ function IsOptional2(value) {
483
+ return IsObject(value) && value[OptionalKind] === "Optional";
484
+ }
485
+ function IsAny2(value) {
486
+ return IsKindOf2(value, "Any") && IsOptionalString(value.$id);
487
+ }
488
+ function IsArgument2(value) {
489
+ return IsKindOf2(value, "Argument") && IsNumber(value.index);
490
+ }
491
+ function IsArray4(value) {
492
+ return IsKindOf2(value, "Array") && value.type === "array" && IsOptionalString(value.$id) && IsSchema2(value.items) && IsOptionalNumber(value.minItems) && IsOptionalNumber(value.maxItems) && IsOptionalBoolean(value.uniqueItems) && IsOptionalSchema(value.contains) && IsOptionalNumber(value.minContains) && IsOptionalNumber(value.maxContains);
493
+ }
494
+ function IsAsyncIterator3(value) {
495
+ return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
496
+ }
497
+ function IsBigInt3(value) {
498
+ return IsKindOf2(value, "BigInt") && value.type === "bigint" && IsOptionalString(value.$id) && IsOptionalBigInt(value.exclusiveMaximum) && IsOptionalBigInt(value.exclusiveMinimum) && IsOptionalBigInt(value.maximum) && IsOptionalBigInt(value.minimum) && IsOptionalBigInt(value.multipleOf);
499
+ }
500
+ function IsBoolean3(value) {
501
+ return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
502
+ }
503
+ function IsComputed2(value) {
504
+ return IsKindOf2(value, "Computed") && IsString(value.target) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema));
505
+ }
506
+ function IsConstructor2(value) {
507
+ return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
508
+ }
509
+ function IsDate3(value) {
510
+ return IsKindOf2(value, "Date") && value.type === "Date" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximumTimestamp) && IsOptionalNumber(value.exclusiveMinimumTimestamp) && IsOptionalNumber(value.maximumTimestamp) && IsOptionalNumber(value.minimumTimestamp) && IsOptionalNumber(value.multipleOfTimestamp);
511
+ }
512
+ function IsFunction3(value) {
513
+ return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
514
+ }
515
+ function IsImport(value) {
516
+ return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
517
+ }
518
+ function IsInteger2(value) {
519
+ return IsKindOf2(value, "Integer") && value.type === "integer" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
520
+ }
521
+ function IsProperties(value) {
522
+ return IsObject(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema2(schema));
523
+ }
524
+ function IsIntersect2(value) {
525
+ return IsKindOf2(value, "Intersect") && (IsString(value.type) && value.type !== "object" ? false : true) && IsArray(value.allOf) && value.allOf.every((schema) => IsSchema2(schema) && !IsTransform2(schema)) && IsOptionalString(value.type) && (IsOptionalBoolean(value.unevaluatedProperties) || IsOptionalSchema(value.unevaluatedProperties)) && IsOptionalString(value.$id);
526
+ }
527
+ function IsIterator3(value) {
528
+ return IsKindOf2(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
529
+ }
530
+ function IsKindOf2(value, kind) {
531
+ return IsObject(value) && Kind in value && value[Kind] === kind;
532
+ }
533
+ function IsLiteralString(value) {
534
+ return IsLiteral2(value) && IsString(value.const);
535
+ }
536
+ function IsLiteralNumber(value) {
537
+ return IsLiteral2(value) && IsNumber(value.const);
538
+ }
539
+ function IsLiteralBoolean(value) {
540
+ return IsLiteral2(value) && IsBoolean(value.const);
541
+ }
542
+ function IsLiteral2(value) {
543
+ return IsKindOf2(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue2(value.const);
544
+ }
545
+ function IsLiteralValue2(value) {
546
+ return IsBoolean(value) || IsNumber(value) || IsString(value);
547
+ }
548
+ function IsMappedKey2(value) {
549
+ return IsKindOf2(value, "MappedKey") && IsArray(value.keys) && value.keys.every((key) => IsNumber(key) || IsString(key));
550
+ }
551
+ function IsMappedResult2(value) {
552
+ return IsKindOf2(value, "MappedResult") && IsProperties(value.properties);
553
+ }
554
+ function IsNever2(value) {
555
+ return IsKindOf2(value, "Never") && IsObject(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
556
+ }
557
+ function IsNot2(value) {
558
+ return IsKindOf2(value, "Not") && IsSchema2(value.not);
559
+ }
560
+ function IsNull3(value) {
561
+ return IsKindOf2(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
562
+ }
563
+ function IsNumber4(value) {
564
+ return IsKindOf2(value, "Number") && value.type === "number" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
565
+ }
566
+ function IsObject4(value) {
567
+ return IsKindOf2(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
568
+ }
569
+ function IsPromise2(value) {
570
+ return IsKindOf2(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema2(value.item);
571
+ }
572
+ function IsRecord2(value) {
573
+ return IsKindOf2(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject(value.patternProperties) && ((schema) => {
574
+ const keys = Object.getOwnPropertyNames(schema.patternProperties);
575
+ return keys.length === 1 && IsPattern(keys[0]) && IsObject(schema.patternProperties) && IsSchema2(schema.patternProperties[keys[0]]);
576
+ })(value);
577
+ }
578
+ function IsRecursive(value) {
579
+ return IsObject(value) && Hint in value && value[Hint] === "Recursive";
580
+ }
581
+ function IsRef2(value) {
582
+ return IsKindOf2(value, "Ref") && IsOptionalString(value.$id) && IsString(value.$ref);
583
+ }
584
+ function IsRegExp3(value) {
585
+ return IsKindOf2(value, "RegExp") && IsOptionalString(value.$id) && IsString(value.source) && IsString(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
586
+ }
587
+ function IsString3(value) {
588
+ return IsKindOf2(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
589
+ }
590
+ function IsSymbol3(value) {
591
+ return IsKindOf2(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
592
+ }
593
+ function IsTemplateLiteral2(value) {
594
+ return IsKindOf2(value, "TemplateLiteral") && value.type === "string" && IsString(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
595
+ }
596
+ function IsThis2(value) {
597
+ return IsKindOf2(value, "This") && IsOptionalString(value.$id) && IsString(value.$ref);
598
+ }
599
+ function IsTransform2(value) {
600
+ return IsObject(value) && TransformKind in value;
601
+ }
602
+ function IsTuple2(value) {
603
+ return IsKindOf2(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber(value.minItems) && IsNumber(value.maxItems) && value.minItems === value.maxItems && // empty
604
+ (IsUndefined(value.items) && IsUndefined(value.additionalItems) && value.minItems === 0 || IsArray(value.items) && value.items.every((schema) => IsSchema2(schema)));
605
+ }
606
+ function IsUndefined4(value) {
607
+ return IsKindOf2(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
608
+ }
609
+ function IsUnionLiteral(value) {
610
+ return IsUnion2(value) && value.anyOf.every((schema) => IsLiteralString(schema) || IsLiteralNumber(schema));
611
+ }
612
+ function IsUnion2(value) {
613
+ return IsKindOf2(value, "Union") && IsOptionalString(value.$id) && IsObject(value) && IsArray(value.anyOf) && value.anyOf.every((schema) => IsSchema2(schema));
614
+ }
615
+ function IsUint8Array3(value) {
616
+ return IsKindOf2(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
617
+ }
618
+ function IsUnknown2(value) {
619
+ return IsKindOf2(value, "Unknown") && IsOptionalString(value.$id);
620
+ }
621
+ function IsUnsafe2(value) {
622
+ return IsKindOf2(value, "Unsafe");
623
+ }
624
+ function IsVoid2(value) {
625
+ return IsKindOf2(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
626
+ }
627
+ function IsKind2(value) {
628
+ return IsObject(value) && Kind in value && IsString(value[Kind]) && !KnownTypes.includes(value[Kind]);
629
+ }
630
+ function IsSchema2(value) {
631
+ return IsObject(value) && (IsAny2(value) || IsArgument2(value) || IsArray4(value) || IsBoolean3(value) || IsBigInt3(value) || IsAsyncIterator3(value) || IsComputed2(value) || IsConstructor2(value) || IsDate3(value) || IsFunction3(value) || IsInteger2(value) || IsIntersect2(value) || IsIterator3(value) || IsLiteral2(value) || IsMappedKey2(value) || IsMappedResult2(value) || IsNever2(value) || IsNot2(value) || IsNull3(value) || IsNumber4(value) || IsObject4(value) || IsPromise2(value) || IsRecord2(value) || IsRef2(value) || IsRegExp3(value) || IsString3(value) || IsSymbol3(value) || IsTemplateLiteral2(value) || IsThis2(value) || IsTuple2(value) || IsUndefined4(value) || IsUnion2(value) || IsUint8Array3(value) || IsUnknown2(value) || IsUnsafe2(value) || IsVoid2(value) || IsKind2(value));
632
+ }
633
+
634
+ // node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.mjs
635
+ var PatternBoolean = "(true|false)";
636
+ var PatternNumber = "(0|[1-9][0-9]*)";
637
+ var PatternString = "(.*)";
638
+ var PatternNever = "(?!.*)";
639
+ var PatternBooleanExact = `^${PatternBoolean}$`;
640
+ var PatternNumberExact = `^${PatternNumber}$`;
641
+ var PatternStringExact = `^${PatternString}$`;
642
+ var PatternNeverExact = `^${PatternNever}$`;
643
+
644
+ // node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
645
+ function SetIncludes(T, S) {
646
+ return T.includes(S);
647
+ }
648
+ function SetDistinct(T) {
649
+ return [...new Set(T)];
650
+ }
651
+ function SetIntersect(T, S) {
652
+ return T.filter((L) => S.includes(L));
653
+ }
654
+ function SetIntersectManyResolve(T, Init) {
655
+ return T.reduce((Acc, L) => {
656
+ return SetIntersect(Acc, L);
657
+ }, Init);
658
+ }
659
+ function SetIntersectMany(T) {
660
+ return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
661
+ }
662
+ function SetUnionMany(T) {
663
+ const Acc = [];
664
+ for (const L of T)
665
+ Acc.push(...L);
666
+ return Acc;
667
+ }
668
+
669
+ // node_modules/@sinclair/typebox/build/esm/type/any/any.mjs
670
+ function Any(options) {
671
+ return CreateType({ [Kind]: "Any" }, options);
672
+ }
673
+
674
+ // node_modules/@sinclair/typebox/build/esm/type/array/array.mjs
675
+ function Array2(items, options) {
676
+ return CreateType({ [Kind]: "Array", type: "array", items }, options);
677
+ }
678
+
679
+ // node_modules/@sinclair/typebox/build/esm/type/argument/argument.mjs
680
+ function Argument(index) {
681
+ return CreateType({ [Kind]: "Argument", index });
682
+ }
683
+
684
+ // node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.mjs
685
+ function AsyncIterator(items, options) {
686
+ return CreateType({ [Kind]: "AsyncIterator", type: "AsyncIterator", items }, options);
687
+ }
688
+
689
+ // node_modules/@sinclair/typebox/build/esm/type/computed/computed.mjs
690
+ function Computed(target, parameters, options) {
691
+ return CreateType({ [Kind]: "Computed", target, parameters }, options);
692
+ }
693
+
694
+ // node_modules/@sinclair/typebox/build/esm/type/discard/discard.mjs
695
+ function DiscardKey(value, key) {
696
+ const { [key]: _, ...rest } = value;
697
+ return rest;
698
+ }
699
+ function Discard(value, keys) {
700
+ return keys.reduce((acc, key) => DiscardKey(acc, key), value);
701
+ }
702
+
703
+ // node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
704
+ function Never(options) {
705
+ return CreateType({ [Kind]: "Never", not: {} }, options);
706
+ }
707
+
708
+ // node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.mjs
709
+ function MappedResult(properties) {
710
+ return CreateType({
711
+ [Kind]: "MappedResult",
712
+ properties
713
+ });
714
+ }
715
+
716
+ // node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.mjs
717
+ function Constructor(parameters, returns, options) {
718
+ return CreateType({ [Kind]: "Constructor", type: "Constructor", parameters, returns }, options);
719
+ }
720
+
721
+ // node_modules/@sinclair/typebox/build/esm/type/function/function.mjs
722
+ function Function(parameters, returns, options) {
723
+ return CreateType({ [Kind]: "Function", type: "Function", parameters, returns }, options);
724
+ }
725
+
726
+ // node_modules/@sinclair/typebox/build/esm/type/union/union-create.mjs
727
+ function UnionCreate(T, options) {
728
+ return CreateType({ [Kind]: "Union", anyOf: T }, options);
729
+ }
730
+
731
+ // node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.mjs
732
+ function IsUnionOptional(types) {
733
+ return types.some((type) => IsOptional(type));
734
+ }
735
+ function RemoveOptionalFromRest(types) {
736
+ return types.map((left) => IsOptional(left) ? RemoveOptionalFromType(left) : left);
737
+ }
738
+ function RemoveOptionalFromType(T) {
739
+ return Discard(T, [OptionalKind]);
740
+ }
741
+ function ResolveUnion(types, options) {
742
+ const isOptional = IsUnionOptional(types);
743
+ return isOptional ? Optional(UnionCreate(RemoveOptionalFromRest(types), options)) : UnionCreate(RemoveOptionalFromRest(types), options);
744
+ }
745
+ function UnionEvaluated(T, options) {
746
+ return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
747
+ }
748
+
749
+ // node_modules/@sinclair/typebox/build/esm/type/union/union.mjs
750
+ function Union(types, options) {
751
+ return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
752
+ }
753
+
754
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.mjs
755
+ var TemplateLiteralParserError = class extends TypeBoxError {
756
+ };
757
+ function Unescape(pattern) {
758
+ return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
759
+ }
760
+ function IsNonEscaped(pattern, index, char) {
761
+ return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
762
+ }
763
+ function IsOpenParen(pattern, index) {
764
+ return IsNonEscaped(pattern, index, "(");
765
+ }
766
+ function IsCloseParen(pattern, index) {
767
+ return IsNonEscaped(pattern, index, ")");
768
+ }
769
+ function IsSeparator(pattern, index) {
770
+ return IsNonEscaped(pattern, index, "|");
771
+ }
772
+ function IsGroup(pattern) {
773
+ if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
774
+ return false;
775
+ let count = 0;
776
+ for (let index = 0; index < pattern.length; index++) {
777
+ if (IsOpenParen(pattern, index))
778
+ count += 1;
779
+ if (IsCloseParen(pattern, index))
780
+ count -= 1;
781
+ if (count === 0 && index !== pattern.length - 1)
782
+ return false;
783
+ }
784
+ return true;
785
+ }
786
+ function InGroup(pattern) {
787
+ return pattern.slice(1, pattern.length - 1);
788
+ }
789
+ function IsPrecedenceOr(pattern) {
790
+ let count = 0;
791
+ for (let index = 0; index < pattern.length; index++) {
792
+ if (IsOpenParen(pattern, index))
793
+ count += 1;
794
+ if (IsCloseParen(pattern, index))
795
+ count -= 1;
796
+ if (IsSeparator(pattern, index) && count === 0)
797
+ return true;
798
+ }
799
+ return false;
800
+ }
801
+ function IsPrecedenceAnd(pattern) {
802
+ for (let index = 0; index < pattern.length; index++) {
803
+ if (IsOpenParen(pattern, index))
804
+ return true;
805
+ }
806
+ return false;
807
+ }
808
+ function Or(pattern) {
809
+ let [count, start] = [0, 0];
810
+ const expressions = [];
811
+ for (let index = 0; index < pattern.length; index++) {
812
+ if (IsOpenParen(pattern, index))
813
+ count += 1;
814
+ if (IsCloseParen(pattern, index))
815
+ count -= 1;
816
+ if (IsSeparator(pattern, index) && count === 0) {
817
+ const range2 = pattern.slice(start, index);
818
+ if (range2.length > 0)
819
+ expressions.push(TemplateLiteralParse(range2));
820
+ start = index + 1;
821
+ }
822
+ }
823
+ const range = pattern.slice(start);
824
+ if (range.length > 0)
825
+ expressions.push(TemplateLiteralParse(range));
826
+ if (expressions.length === 0)
827
+ return { type: "const", const: "" };
828
+ if (expressions.length === 1)
829
+ return expressions[0];
830
+ return { type: "or", expr: expressions };
831
+ }
832
+ function And(pattern) {
833
+ function Group(value, index) {
834
+ if (!IsOpenParen(value, index))
835
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
836
+ let count = 0;
837
+ for (let scan = index; scan < value.length; scan++) {
838
+ if (IsOpenParen(value, scan))
839
+ count += 1;
840
+ if (IsCloseParen(value, scan))
841
+ count -= 1;
842
+ if (count === 0)
843
+ return [index, scan];
844
+ }
845
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
846
+ }
847
+ function Range(pattern2, index) {
848
+ for (let scan = index; scan < pattern2.length; scan++) {
849
+ if (IsOpenParen(pattern2, scan))
850
+ return [index, scan];
851
+ }
852
+ return [index, pattern2.length];
853
+ }
854
+ const expressions = [];
855
+ for (let index = 0; index < pattern.length; index++) {
856
+ if (IsOpenParen(pattern, index)) {
857
+ const [start, end] = Group(pattern, index);
858
+ const range = pattern.slice(start, end + 1);
859
+ expressions.push(TemplateLiteralParse(range));
860
+ index = end;
861
+ } else {
862
+ const [start, end] = Range(pattern, index);
863
+ const range = pattern.slice(start, end);
864
+ if (range.length > 0)
865
+ expressions.push(TemplateLiteralParse(range));
866
+ index = end - 1;
867
+ }
868
+ }
869
+ return expressions.length === 0 ? { type: "const", const: "" } : expressions.length === 1 ? expressions[0] : { type: "and", expr: expressions };
870
+ }
871
+ function TemplateLiteralParse(pattern) {
872
+ return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : { type: "const", const: Unescape(pattern) };
873
+ }
874
+ function TemplateLiteralParseExact(pattern) {
875
+ return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
876
+ }
877
+
878
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.mjs
879
+ var TemplateLiteralFiniteError = class extends TypeBoxError {
880
+ };
881
+ function IsNumberExpression(expression) {
882
+ return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "0" && expression.expr[1].type === "const" && expression.expr[1].const === "[1-9][0-9]*";
883
+ }
884
+ function IsBooleanExpression(expression) {
885
+ return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "true" && expression.expr[1].type === "const" && expression.expr[1].const === "false";
886
+ }
887
+ function IsStringExpression(expression) {
888
+ return expression.type === "const" && expression.const === ".*";
889
+ }
890
+ function IsTemplateLiteralExpressionFinite(expression) {
891
+ return IsNumberExpression(expression) || IsStringExpression(expression) ? false : IsBooleanExpression(expression) ? true : expression.type === "and" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "or" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "const" ? true : (() => {
892
+ throw new TemplateLiteralFiniteError(`Unknown expression type`);
893
+ })();
894
+ }
895
+ function IsTemplateLiteralFinite(schema) {
896
+ const expression = TemplateLiteralParseExact(schema.pattern);
897
+ return IsTemplateLiteralExpressionFinite(expression);
898
+ }
899
+
900
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.mjs
901
+ var TemplateLiteralGenerateError = class extends TypeBoxError {
902
+ };
903
+ function* GenerateReduce(buffer) {
904
+ if (buffer.length === 1)
905
+ return yield* buffer[0];
906
+ for (const left of buffer[0]) {
907
+ for (const right of GenerateReduce(buffer.slice(1))) {
908
+ yield `${left}${right}`;
909
+ }
910
+ }
911
+ }
912
+ function* GenerateAnd(expression) {
913
+ return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
914
+ }
915
+ function* GenerateOr(expression) {
916
+ for (const expr of expression.expr)
917
+ yield* TemplateLiteralExpressionGenerate(expr);
918
+ }
919
+ function* GenerateConst(expression) {
920
+ return yield expression.const;
921
+ }
922
+ function* TemplateLiteralExpressionGenerate(expression) {
923
+ return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
924
+ throw new TemplateLiteralGenerateError("Unknown expression");
925
+ })();
926
+ }
927
+ function TemplateLiteralGenerate(schema) {
928
+ const expression = TemplateLiteralParseExact(schema.pattern);
929
+ return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
930
+ }
931
+
932
+ // node_modules/@sinclair/typebox/build/esm/type/literal/literal.mjs
933
+ function Literal(value, options) {
934
+ return CreateType({
935
+ [Kind]: "Literal",
936
+ const: value,
937
+ type: typeof value
938
+ }, options);
939
+ }
940
+
941
+ // node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.mjs
942
+ function Boolean2(options) {
943
+ return CreateType({ [Kind]: "Boolean", type: "boolean" }, options);
944
+ }
945
+
946
+ // node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.mjs
947
+ function BigInt(options) {
948
+ return CreateType({ [Kind]: "BigInt", type: "bigint" }, options);
949
+ }
950
+
951
+ // node_modules/@sinclair/typebox/build/esm/type/number/number.mjs
952
+ function Number2(options) {
953
+ return CreateType({ [Kind]: "Number", type: "number" }, options);
954
+ }
955
+
956
+ // node_modules/@sinclair/typebox/build/esm/type/string/string.mjs
957
+ function String2(options) {
958
+ return CreateType({ [Kind]: "String", type: "string" }, options);
959
+ }
960
+
961
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.mjs
962
+ function* FromUnion(syntax) {
963
+ const trim = syntax.trim().replace(/"|'/g, "");
964
+ return trim === "boolean" ? yield Boolean2() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String2() : yield (() => {
965
+ const literals = trim.split("|").map((literal) => Literal(literal.trim()));
966
+ return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
967
+ })();
968
+ }
969
+ function* FromTerminal(syntax) {
970
+ if (syntax[1] !== "{") {
971
+ const L = Literal("$");
972
+ const R = FromSyntax(syntax.slice(1));
973
+ return yield* [L, ...R];
974
+ }
975
+ for (let i = 2; i < syntax.length; i++) {
976
+ if (syntax[i] === "}") {
977
+ const L = FromUnion(syntax.slice(2, i));
978
+ const R = FromSyntax(syntax.slice(i + 1));
979
+ return yield* [...L, ...R];
980
+ }
981
+ }
982
+ yield Literal(syntax);
983
+ }
984
+ function* FromSyntax(syntax) {
985
+ for (let i = 0; i < syntax.length; i++) {
986
+ if (syntax[i] === "$") {
987
+ const L = Literal(syntax.slice(0, i));
988
+ const R = FromTerminal(syntax.slice(i));
989
+ return yield* [L, ...R];
990
+ }
991
+ }
992
+ yield Literal(syntax);
993
+ }
994
+ function TemplateLiteralSyntax(syntax) {
995
+ return [...FromSyntax(syntax)];
996
+ }
997
+
998
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.mjs
999
+ var TemplateLiteralPatternError = class extends TypeBoxError {
1000
+ };
1001
+ function Escape(value) {
1002
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1003
+ }
1004
+ function Visit2(schema, acc) {
1005
+ return IsTemplateLiteral(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) : IsUnion(schema) ? `(${schema.anyOf.map((schema2) => Visit2(schema2, acc)).join("|")})` : IsNumber3(schema) ? `${acc}${PatternNumber}` : IsInteger(schema) ? `${acc}${PatternNumber}` : IsBigInt2(schema) ? `${acc}${PatternNumber}` : IsString2(schema) ? `${acc}${PatternString}` : IsLiteral(schema) ? `${acc}${Escape(schema.const.toString())}` : IsBoolean2(schema) ? `${acc}${PatternBoolean}` : (() => {
1006
+ throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
1007
+ })();
1008
+ }
1009
+ function TemplateLiteralPattern(kinds) {
1010
+ return `^${kinds.map((schema) => Visit2(schema, "")).join("")}$`;
1011
+ }
1012
+
1013
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/union.mjs
1014
+ function TemplateLiteralToUnion(schema) {
1015
+ const R = TemplateLiteralGenerate(schema);
1016
+ const L = R.map((S) => Literal(S));
1017
+ return UnionEvaluated(L);
1018
+ }
1019
+
1020
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.mjs
1021
+ function TemplateLiteral(unresolved, options) {
1022
+ const pattern = IsString(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
1023
+ return CreateType({ [Kind]: "TemplateLiteral", type: "string", pattern }, options);
1024
+ }
1025
+
1026
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.mjs
1027
+ function FromTemplateLiteral(templateLiteral) {
1028
+ const keys = TemplateLiteralGenerate(templateLiteral);
1029
+ return keys.map((key) => key.toString());
1030
+ }
1031
+ function FromUnion2(types) {
1032
+ const result = [];
1033
+ for (const type of types)
1034
+ result.push(...IndexPropertyKeys(type));
1035
+ return result;
1036
+ }
1037
+ function FromLiteral(literalValue) {
1038
+ return [literalValue.toString()];
1039
+ }
1040
+ function IndexPropertyKeys(type) {
1041
+ return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] : IsInteger(type) ? ["[number]"] : [])];
1042
+ }
1043
+
1044
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.mjs
1045
+ function FromProperties(type, properties, options) {
1046
+ const result = {};
1047
+ for (const K2 of Object.getOwnPropertyNames(properties)) {
1048
+ result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
1049
+ }
1050
+ return result;
1051
+ }
1052
+ function FromMappedResult(type, mappedResult, options) {
1053
+ return FromProperties(type, mappedResult.properties, options);
1054
+ }
1055
+ function IndexFromMappedResult(type, mappedResult, options) {
1056
+ const properties = FromMappedResult(type, mappedResult, options);
1057
+ return MappedResult(properties);
1058
+ }
1059
+
1060
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.mjs
1061
+ function FromRest(types, key) {
1062
+ return types.map((type) => IndexFromPropertyKey(type, key));
1063
+ }
1064
+ function FromIntersectRest(types) {
1065
+ return types.filter((type) => !IsNever(type));
1066
+ }
1067
+ function FromIntersect(types, key) {
1068
+ return IntersectEvaluated(FromIntersectRest(FromRest(types, key)));
1069
+ }
1070
+ function FromUnionRest(types) {
1071
+ return types.some((L) => IsNever(L)) ? [] : types;
1072
+ }
1073
+ function FromUnion3(types, key) {
1074
+ return UnionEvaluated(FromUnionRest(FromRest(types, key)));
1075
+ }
1076
+ function FromTuple(types, key) {
1077
+ return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
1078
+ }
1079
+ function FromArray(type, key) {
1080
+ return key === "[number]" ? type : Never();
1081
+ }
1082
+ function FromProperty(properties, propertyKey) {
1083
+ return propertyKey in properties ? properties[propertyKey] : Never();
1084
+ }
1085
+ function IndexFromPropertyKey(type, propertyKey) {
1086
+ return IsIntersect(type) ? FromIntersect(type.allOf, propertyKey) : IsUnion(type) ? FromUnion3(type.anyOf, propertyKey) : IsTuple(type) ? FromTuple(type.items ?? [], propertyKey) : IsArray3(type) ? FromArray(type.items, propertyKey) : IsObject3(type) ? FromProperty(type.properties, propertyKey) : Never();
1087
+ }
1088
+ function IndexFromPropertyKeys(type, propertyKeys) {
1089
+ return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
1090
+ }
1091
+ function FromSchema(type, propertyKeys) {
1092
+ return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
1093
+ }
1094
+ function Index(type, key, options) {
1095
+ if (IsRef(type) || IsRef(key)) {
1096
+ const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
1097
+ if (!IsSchema(type) || !IsSchema(key))
1098
+ throw new TypeBoxError(error);
1099
+ return Computed("Index", [type, key]);
1100
+ }
1101
+ if (IsMappedResult(key))
1102
+ return IndexFromMappedResult(type, key, options);
1103
+ if (IsMappedKey(key))
1104
+ return IndexFromMappedKey(type, key, options);
1105
+ return CreateType(IsSchema(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
1106
+ }
1107
+
1108
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.mjs
1109
+ function MappedIndexPropertyKey(type, key, options) {
1110
+ return { [key]: Index(type, [key], Clone(options)) };
1111
+ }
1112
+ function MappedIndexPropertyKeys(type, propertyKeys, options) {
1113
+ return propertyKeys.reduce((result, left) => {
1114
+ return { ...result, ...MappedIndexPropertyKey(type, left, options) };
1115
+ }, {});
1116
+ }
1117
+ function MappedIndexProperties(type, mappedKey, options) {
1118
+ return MappedIndexPropertyKeys(type, mappedKey.keys, options);
1119
+ }
1120
+ function IndexFromMappedKey(type, mappedKey, options) {
1121
+ const properties = MappedIndexProperties(type, mappedKey, options);
1122
+ return MappedResult(properties);
1123
+ }
1124
+
1125
+ // node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.mjs
1126
+ function Iterator(items, options) {
1127
+ return CreateType({ [Kind]: "Iterator", type: "Iterator", items }, options);
1128
+ }
1129
+
1130
+ // node_modules/@sinclair/typebox/build/esm/type/object/object.mjs
1131
+ function RequiredArray(properties) {
1132
+ return globalThis.Object.keys(properties).filter((key) => !IsOptional(properties[key]));
1133
+ }
1134
+ function _Object(properties, options) {
1135
+ const required = RequiredArray(properties);
1136
+ const schema = required.length > 0 ? { [Kind]: "Object", type: "object", required, properties } : { [Kind]: "Object", type: "object", properties };
1137
+ return CreateType(schema, options);
1138
+ }
1139
+ var Object2 = _Object;
1140
+
1141
+ // node_modules/@sinclair/typebox/build/esm/type/promise/promise.mjs
1142
+ function Promise2(item, options) {
1143
+ return CreateType({ [Kind]: "Promise", type: "Promise", item }, options);
1144
+ }
1145
+
1146
+ // node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.mjs
1147
+ function RemoveReadonly(schema) {
1148
+ return CreateType(Discard(schema, [ReadonlyKind]));
1149
+ }
1150
+ function AddReadonly(schema) {
1151
+ return CreateType({ ...schema, [ReadonlyKind]: "Readonly" });
1152
+ }
1153
+ function ReadonlyWithFlag(schema, F) {
1154
+ return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
1155
+ }
1156
+ function Readonly(schema, enable) {
1157
+ const F = enable ?? true;
1158
+ return IsMappedResult(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
1159
+ }
1160
+
1161
+ // node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.mjs
1162
+ function FromProperties2(K, F) {
1163
+ const Acc = {};
1164
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K))
1165
+ Acc[K2] = Readonly(K[K2], F);
1166
+ return Acc;
1167
+ }
1168
+ function FromMappedResult2(R, F) {
1169
+ return FromProperties2(R.properties, F);
1170
+ }
1171
+ function ReadonlyFromMappedResult(R, F) {
1172
+ const P = FromMappedResult2(R, F);
1173
+ return MappedResult(P);
1174
+ }
1175
+
1176
+ // node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.mjs
1177
+ function Tuple(types, options) {
1178
+ return CreateType(types.length > 0 ? { [Kind]: "Tuple", type: "array", items: types, additionalItems: false, minItems: types.length, maxItems: types.length } : { [Kind]: "Tuple", type: "array", minItems: types.length, maxItems: types.length }, options);
1179
+ }
1180
+
1181
+ // node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs
1182
+ function FromMappedResult3(K, P) {
1183
+ return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
1184
+ }
1185
+ function MappedKeyToKnownMappedResultProperties(K) {
1186
+ return { [K]: Literal(K) };
1187
+ }
1188
+ function MappedKeyToUnknownMappedResultProperties(P) {
1189
+ const Acc = {};
1190
+ for (const L of P)
1191
+ Acc[L] = Literal(L);
1192
+ return Acc;
1193
+ }
1194
+ function MappedKeyToMappedResultProperties(K, P) {
1195
+ return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
1196
+ }
1197
+ function FromMappedKey(K, P) {
1198
+ const R = MappedKeyToMappedResultProperties(K, P);
1199
+ return FromMappedResult3(K, R);
1200
+ }
1201
+ function FromRest2(K, T) {
1202
+ return T.map((L) => FromSchemaType(K, L));
1203
+ }
1204
+ function FromProperties3(K, T) {
1205
+ const Acc = {};
1206
+ for (const K2 of globalThis.Object.getOwnPropertyNames(T))
1207
+ Acc[K2] = FromSchemaType(K, T[K2]);
1208
+ return Acc;
1209
+ }
1210
+ function FromSchemaType(K, T) {
1211
+ const options = { ...T };
1212
+ return (
1213
+ // unevaluated modifier types
1214
+ IsOptional(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : (
1215
+ // unevaluated mapped types
1216
+ IsMappedResult(T) ? FromMappedResult3(K, T.properties) : IsMappedKey(T) ? FromMappedKey(K, T.keys) : (
1217
+ // unevaluated types
1218
+ IsConstructor(T) ? Constructor(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsFunction2(T) ? Function(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsAsyncIterator2(T) ? AsyncIterator(FromSchemaType(K, T.items), options) : IsIterator2(T) ? Iterator(FromSchemaType(K, T.items), options) : IsIntersect(T) ? Intersect(FromRest2(K, T.allOf), options) : IsUnion(T) ? Union(FromRest2(K, T.anyOf), options) : IsTuple(T) ? Tuple(FromRest2(K, T.items ?? []), options) : IsObject3(T) ? Object2(FromProperties3(K, T.properties), options) : IsArray3(T) ? Array2(FromSchemaType(K, T.items), options) : IsPromise(T) ? Promise2(FromSchemaType(K, T.item), options) : T
1219
+ )
1220
+ )
1221
+ );
1222
+ }
1223
+ function MappedFunctionReturnType(K, T) {
1224
+ const Acc = {};
1225
+ for (const L of K)
1226
+ Acc[L] = FromSchemaType(L, T);
1227
+ return Acc;
1228
+ }
1229
+ function Mapped(key, map, options) {
1230
+ const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
1231
+ const RT = map({ [Kind]: "MappedKey", keys: K });
1232
+ const R = MappedFunctionReturnType(K, RT);
1233
+ return Object2(R, options);
1234
+ }
1235
+
1236
+ // node_modules/@sinclair/typebox/build/esm/type/optional/optional.mjs
1237
+ function RemoveOptional(schema) {
1238
+ return CreateType(Discard(schema, [OptionalKind]));
1239
+ }
1240
+ function AddOptional(schema) {
1241
+ return CreateType({ ...schema, [OptionalKind]: "Optional" });
1242
+ }
1243
+ function OptionalWithFlag(schema, F) {
1244
+ return F === false ? RemoveOptional(schema) : AddOptional(schema);
1245
+ }
1246
+ function Optional(schema, enable) {
1247
+ const F = enable ?? true;
1248
+ return IsMappedResult(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
1249
+ }
1250
+
1251
+ // node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.mjs
1252
+ function FromProperties4(P, F) {
1253
+ const Acc = {};
1254
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
1255
+ Acc[K2] = Optional(P[K2], F);
1256
+ return Acc;
1257
+ }
1258
+ function FromMappedResult4(R, F) {
1259
+ return FromProperties4(R.properties, F);
1260
+ }
1261
+ function OptionalFromMappedResult(R, F) {
1262
+ const P = FromMappedResult4(R, F);
1263
+ return MappedResult(P);
1264
+ }
1265
+
1266
+ // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.mjs
1267
+ function IntersectCreate(T, options = {}) {
1268
+ const allObjects = T.every((schema) => IsObject3(schema));
1269
+ const clonedUnevaluatedProperties = IsSchema(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
1270
+ return CreateType(options.unevaluatedProperties === false || IsSchema(options.unevaluatedProperties) || allObjects ? { ...clonedUnevaluatedProperties, [Kind]: "Intersect", type: "object", allOf: T } : { ...clonedUnevaluatedProperties, [Kind]: "Intersect", allOf: T }, options);
1271
+ }
1272
+
1273
+ // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.mjs
1274
+ function IsIntersectOptional(types) {
1275
+ return types.every((left) => IsOptional(left));
1276
+ }
1277
+ function RemoveOptionalFromType2(type) {
1278
+ return Discard(type, [OptionalKind]);
1279
+ }
1280
+ function RemoveOptionalFromRest2(types) {
1281
+ return types.map((left) => IsOptional(left) ? RemoveOptionalFromType2(left) : left);
1282
+ }
1283
+ function ResolveIntersect(types, options) {
1284
+ return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest2(types), options)) : IntersectCreate(RemoveOptionalFromRest2(types), options);
1285
+ }
1286
+ function IntersectEvaluated(types, options = {}) {
1287
+ if (types.length === 1)
1288
+ return CreateType(types[0], options);
1289
+ if (types.length === 0)
1290
+ return Never(options);
1291
+ if (types.some((schema) => IsTransform(schema)))
1292
+ throw new Error("Cannot intersect transform types");
1293
+ return ResolveIntersect(types, options);
1294
+ }
1295
+
1296
+ // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.mjs
1297
+ function Intersect(types, options) {
1298
+ if (types.length === 1)
1299
+ return CreateType(types[0], options);
1300
+ if (types.length === 0)
1301
+ return Never(options);
1302
+ if (types.some((schema) => IsTransform(schema)))
1303
+ throw new Error("Cannot intersect transform types");
1304
+ return IntersectCreate(types, options);
1305
+ }
1306
+
1307
+ // node_modules/@sinclair/typebox/build/esm/type/ref/ref.mjs
1308
+ function Ref(...args) {
1309
+ const [$ref, options] = typeof args[0] === "string" ? [args[0], args[1]] : [args[0].$id, args[1]];
1310
+ if (typeof $ref !== "string")
1311
+ throw new TypeBoxError("Ref: $ref must be a string");
1312
+ return CreateType({ [Kind]: "Ref", $ref }, options);
1313
+ }
1314
+
1315
+ // node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.mjs
1316
+ function FromComputed(target, parameters) {
1317
+ return Computed("Awaited", [Computed(target, parameters)]);
1318
+ }
1319
+ function FromRef($ref) {
1320
+ return Computed("Awaited", [Ref($ref)]);
1321
+ }
1322
+ function FromIntersect2(types) {
1323
+ return Intersect(FromRest3(types));
1324
+ }
1325
+ function FromUnion4(types) {
1326
+ return Union(FromRest3(types));
1327
+ }
1328
+ function FromPromise(type) {
1329
+ return Awaited(type);
1330
+ }
1331
+ function FromRest3(types) {
1332
+ return types.map((type) => Awaited(type));
1333
+ }
1334
+ function Awaited(type, options) {
1335
+ return CreateType(IsComputed(type) ? FromComputed(type.target, type.parameters) : IsIntersect(type) ? FromIntersect2(type.allOf) : IsUnion(type) ? FromUnion4(type.anyOf) : IsPromise(type) ? FromPromise(type.item) : IsRef(type) ? FromRef(type.$ref) : type, options);
1336
+ }
1337
+
1338
+ // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
1339
+ function FromRest4(types) {
1340
+ const result = [];
1341
+ for (const L of types)
1342
+ result.push(KeyOfPropertyKeys(L));
1343
+ return result;
1344
+ }
1345
+ function FromIntersect3(types) {
1346
+ const propertyKeysArray = FromRest4(types);
1347
+ const propertyKeys = SetUnionMany(propertyKeysArray);
1348
+ return propertyKeys;
1349
+ }
1350
+ function FromUnion5(types) {
1351
+ const propertyKeysArray = FromRest4(types);
1352
+ const propertyKeys = SetIntersectMany(propertyKeysArray);
1353
+ return propertyKeys;
1354
+ }
1355
+ function FromTuple2(types) {
1356
+ return types.map((_, indexer) => indexer.toString());
1357
+ }
1358
+ function FromArray2(_) {
1359
+ return ["[number]"];
1360
+ }
1361
+ function FromProperties5(T) {
1362
+ return globalThis.Object.getOwnPropertyNames(T);
1363
+ }
1364
+ function FromPatternProperties(patternProperties) {
1365
+ if (!includePatternProperties)
1366
+ return [];
1367
+ const patternPropertyKeys = globalThis.Object.getOwnPropertyNames(patternProperties);
1368
+ return patternPropertyKeys.map((key) => {
1369
+ return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
1370
+ });
1371
+ }
1372
+ function KeyOfPropertyKeys(type) {
1373
+ return IsIntersect(type) ? FromIntersect3(type.allOf) : IsUnion(type) ? FromUnion5(type.anyOf) : IsTuple(type) ? FromTuple2(type.items ?? []) : IsArray3(type) ? FromArray2(type.items) : IsObject3(type) ? FromProperties5(type.properties) : IsRecord(type) ? FromPatternProperties(type.patternProperties) : [];
1374
+ }
1375
+ var includePatternProperties = false;
1376
+
1377
+ // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.mjs
1378
+ function FromComputed2(target, parameters) {
1379
+ return Computed("KeyOf", [Computed(target, parameters)]);
1380
+ }
1381
+ function FromRef2($ref) {
1382
+ return Computed("KeyOf", [Ref($ref)]);
1383
+ }
1384
+ function KeyOfFromType(type, options) {
1385
+ const propertyKeys = KeyOfPropertyKeys(type);
1386
+ const propertyKeyTypes = KeyOfPropertyKeysToRest(propertyKeys);
1387
+ const result = UnionEvaluated(propertyKeyTypes);
1388
+ return CreateType(result, options);
1389
+ }
1390
+ function KeyOfPropertyKeysToRest(propertyKeys) {
1391
+ return propertyKeys.map((L) => L === "[number]" ? Number2() : Literal(L));
1392
+ }
1393
+ function KeyOf(type, options) {
1394
+ return IsComputed(type) ? FromComputed2(type.target, type.parameters) : IsRef(type) ? FromRef2(type.$ref) : IsMappedResult(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
1395
+ }
1396
+
1397
+ // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.mjs
1398
+ function FromProperties6(properties, options) {
1399
+ const result = {};
1400
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
1401
+ result[K2] = KeyOf(properties[K2], Clone(options));
1402
+ return result;
1403
+ }
1404
+ function FromMappedResult5(mappedResult, options) {
1405
+ return FromProperties6(mappedResult.properties, options);
1406
+ }
1407
+ function KeyOfFromMappedResult(mappedResult, options) {
1408
+ const properties = FromMappedResult5(mappedResult, options);
1409
+ return MappedResult(properties);
1410
+ }
1411
+
1412
+ // node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs
1413
+ function CompositeKeys(T) {
1414
+ const Acc = [];
1415
+ for (const L of T)
1416
+ Acc.push(...KeyOfPropertyKeys(L));
1417
+ return SetDistinct(Acc);
1418
+ }
1419
+ function FilterNever(T) {
1420
+ return T.filter((L) => !IsNever(L));
1421
+ }
1422
+ function CompositeProperty(T, K) {
1423
+ const Acc = [];
1424
+ for (const L of T)
1425
+ Acc.push(...IndexFromPropertyKeys(L, [K]));
1426
+ return FilterNever(Acc);
1427
+ }
1428
+ function CompositeProperties(T, K) {
1429
+ const Acc = {};
1430
+ for (const L of K) {
1431
+ Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
1432
+ }
1433
+ return Acc;
1434
+ }
1435
+ function Composite(T, options) {
1436
+ const K = CompositeKeys(T);
1437
+ const P = CompositeProperties(T, K);
1438
+ const R = Object2(P, options);
1439
+ return R;
1440
+ }
1441
+
1442
+ // node_modules/@sinclair/typebox/build/esm/type/date/date.mjs
1443
+ function Date2(options) {
1444
+ return CreateType({ [Kind]: "Date", type: "Date" }, options);
1445
+ }
1446
+
1447
+ // node_modules/@sinclair/typebox/build/esm/type/null/null.mjs
1448
+ function Null(options) {
1449
+ return CreateType({ [Kind]: "Null", type: "null" }, options);
1450
+ }
1451
+
1452
+ // node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.mjs
1453
+ function Symbol2(options) {
1454
+ return CreateType({ [Kind]: "Symbol", type: "symbol" }, options);
1455
+ }
1456
+
1457
+ // node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.mjs
1458
+ function Undefined(options) {
1459
+ return CreateType({ [Kind]: "Undefined", type: "undefined" }, options);
1460
+ }
1461
+
1462
+ // node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.mjs
1463
+ function Uint8Array2(options) {
1464
+ return CreateType({ [Kind]: "Uint8Array", type: "Uint8Array" }, options);
1465
+ }
1466
+
1467
+ // node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.mjs
1468
+ function Unknown(options) {
1469
+ return CreateType({ [Kind]: "Unknown" }, options);
1470
+ }
1471
+
1472
+ // node_modules/@sinclair/typebox/build/esm/type/const/const.mjs
1473
+ function FromArray3(T) {
1474
+ return T.map((L) => FromValue(L, false));
1475
+ }
1476
+ function FromProperties7(value) {
1477
+ const Acc = {};
1478
+ for (const K of globalThis.Object.getOwnPropertyNames(value))
1479
+ Acc[K] = Readonly(FromValue(value[K], false));
1480
+ return Acc;
1481
+ }
1482
+ function ConditionalReadonly(T, root) {
1483
+ return root === true ? T : Readonly(T);
1484
+ }
1485
+ function FromValue(value, root) {
1486
+ return IsAsyncIterator(value) ? ConditionalReadonly(Any(), root) : IsIterator(value) ? ConditionalReadonly(Any(), root) : IsArray(value) ? Readonly(Tuple(FromArray3(value))) : IsUint8Array(value) ? Uint8Array2() : IsDate(value) ? Date2() : IsObject(value) ? ConditionalReadonly(Object2(FromProperties7(value)), root) : IsFunction(value) ? ConditionalReadonly(Function([], Unknown()), root) : IsUndefined(value) ? Undefined() : IsNull(value) ? Null() : IsSymbol(value) ? Symbol2() : IsBigInt(value) ? BigInt() : IsNumber(value) ? Literal(value) : IsBoolean(value) ? Literal(value) : IsString(value) ? Literal(value) : Object2({});
1487
+ }
1488
+ function Const(T, options) {
1489
+ return CreateType(FromValue(T, true), options);
1490
+ }
1491
+
1492
+ // node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.mjs
1493
+ function ConstructorParameters(schema, options) {
1494
+ return IsConstructor(schema) ? Tuple(schema.parameters, options) : Never(options);
1495
+ }
1496
+
1497
+ // node_modules/@sinclair/typebox/build/esm/type/enum/enum.mjs
1498
+ function Enum(item, options) {
1499
+ if (IsUndefined(item))
1500
+ throw new Error("Enum undefined or empty");
1501
+ const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
1502
+ const values2 = [...new Set(values1)];
1503
+ const anyOf = values2.map((value) => Literal(value));
1504
+ return Union(anyOf, { ...options, [Hint]: "Enum" });
1505
+ }
1506
+
1507
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.mjs
1508
+ var ExtendsResolverError = class extends TypeBoxError {
1509
+ };
1510
+ var ExtendsResult;
1511
+ (function(ExtendsResult2) {
1512
+ ExtendsResult2[ExtendsResult2["Union"] = 0] = "Union";
1513
+ ExtendsResult2[ExtendsResult2["True"] = 1] = "True";
1514
+ ExtendsResult2[ExtendsResult2["False"] = 2] = "False";
1515
+ })(ExtendsResult || (ExtendsResult = {}));
1516
+ function IntoBooleanResult(result) {
1517
+ return result === ExtendsResult.False ? result : ExtendsResult.True;
1518
+ }
1519
+ function Throw(message) {
1520
+ throw new ExtendsResolverError(message);
1521
+ }
1522
+ function IsStructuralRight(right) {
1523
+ return type_exports.IsNever(right) || type_exports.IsIntersect(right) || type_exports.IsUnion(right) || type_exports.IsUnknown(right) || type_exports.IsAny(right);
1524
+ }
1525
+ function StructuralRight(left, right) {
1526
+ return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : Throw("StructuralRight");
1527
+ }
1528
+ function FromAnyRight(left, right) {
1529
+ return ExtendsResult.True;
1530
+ }
1531
+ function FromAny(left, right) {
1532
+ return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) && right.anyOf.some((schema) => type_exports.IsAny(schema) || type_exports.IsUnknown(schema)) ? ExtendsResult.True : type_exports.IsUnion(right) ? ExtendsResult.Union : type_exports.IsUnknown(right) ? ExtendsResult.True : type_exports.IsAny(right) ? ExtendsResult.True : ExtendsResult.Union;
1533
+ }
1534
+ function FromArrayRight(left, right) {
1535
+ return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
1536
+ }
1537
+ function FromArray4(left, right) {
1538
+ return type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsArray(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
1539
+ }
1540
+ function FromAsyncIterator(left, right) {
1541
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
1542
+ }
1543
+ function FromBigInt(left, right) {
1544
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBigInt(right) ? ExtendsResult.True : ExtendsResult.False;
1545
+ }
1546
+ function FromBooleanRight(left, right) {
1547
+ return type_exports.IsLiteralBoolean(left) ? ExtendsResult.True : type_exports.IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
1548
+ }
1549
+ function FromBoolean(left, right) {
1550
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBoolean(right) ? ExtendsResult.True : ExtendsResult.False;
1551
+ }
1552
+ function FromConstructor(left, right) {
1553
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsConstructor(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit3(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
1554
+ }
1555
+ function FromDate(left, right) {
1556
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsDate(right) ? ExtendsResult.True : ExtendsResult.False;
1557
+ }
1558
+ function FromFunction(left, right) {
1559
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsFunction(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit3(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
1560
+ }
1561
+ function FromIntegerRight(left, right) {
1562
+ return type_exports.IsLiteral(left) && value_exports.IsNumber(left.const) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
1563
+ }
1564
+ function FromInteger(left, right) {
1565
+ return type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : ExtendsResult.False;
1566
+ }
1567
+ function FromIntersectRight(left, right) {
1568
+ return right.allOf.every((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1569
+ }
1570
+ function FromIntersect4(left, right) {
1571
+ return left.allOf.some((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1572
+ }
1573
+ function FromIterator(left, right) {
1574
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
1575
+ }
1576
+ function FromLiteral2(left, right) {
1577
+ return type_exports.IsLiteral(right) && right.const === left.const ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? FromStringRight(left, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : ExtendsResult.False;
1578
+ }
1579
+ function FromNeverRight(left, right) {
1580
+ return ExtendsResult.False;
1581
+ }
1582
+ function FromNever(left, right) {
1583
+ return ExtendsResult.True;
1584
+ }
1585
+ function UnwrapTNot(schema) {
1586
+ let [current, depth] = [schema, 0];
1587
+ while (true) {
1588
+ if (!type_exports.IsNot(current))
1589
+ break;
1590
+ current = current.not;
1591
+ depth += 1;
1592
+ }
1593
+ return depth % 2 === 0 ? current : Unknown();
1594
+ }
1595
+ function FromNot(left, right) {
1596
+ return type_exports.IsNot(left) ? Visit3(UnwrapTNot(left), right) : type_exports.IsNot(right) ? Visit3(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
1597
+ }
1598
+ function FromNull(left, right) {
1599
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsNull(right) ? ExtendsResult.True : ExtendsResult.False;
1600
+ }
1601
+ function FromNumberRight(left, right) {
1602
+ return type_exports.IsLiteralNumber(left) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
1603
+ }
1604
+ function FromNumber(left, right) {
1605
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : ExtendsResult.False;
1606
+ }
1607
+ function IsObjectPropertyCount(schema, count) {
1608
+ return Object.getOwnPropertyNames(schema.properties).length === count;
1609
+ }
1610
+ function IsObjectStringLike(schema) {
1611
+ return IsObjectArrayLike(schema);
1612
+ }
1613
+ function IsObjectSymbolLike(schema) {
1614
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "description" in schema.properties && type_exports.IsUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && (type_exports.IsString(schema.properties.description.anyOf[0]) && type_exports.IsUndefined(schema.properties.description.anyOf[1]) || type_exports.IsString(schema.properties.description.anyOf[1]) && type_exports.IsUndefined(schema.properties.description.anyOf[0]));
1615
+ }
1616
+ function IsObjectNumberLike(schema) {
1617
+ return IsObjectPropertyCount(schema, 0);
1618
+ }
1619
+ function IsObjectBooleanLike(schema) {
1620
+ return IsObjectPropertyCount(schema, 0);
1621
+ }
1622
+ function IsObjectBigIntLike(schema) {
1623
+ return IsObjectPropertyCount(schema, 0);
1624
+ }
1625
+ function IsObjectDateLike(schema) {
1626
+ return IsObjectPropertyCount(schema, 0);
1627
+ }
1628
+ function IsObjectUint8ArrayLike(schema) {
1629
+ return IsObjectArrayLike(schema);
1630
+ }
1631
+ function IsObjectFunctionLike(schema) {
1632
+ const length = Number2();
1633
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
1634
+ }
1635
+ function IsObjectConstructorLike(schema) {
1636
+ return IsObjectPropertyCount(schema, 0);
1637
+ }
1638
+ function IsObjectArrayLike(schema) {
1639
+ const length = Number2();
1640
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
1641
+ }
1642
+ function IsObjectPromiseLike(schema) {
1643
+ const then = Function([Any()], Any());
1644
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit3(schema.properties["then"], then)) === ExtendsResult.True;
1645
+ }
1646
+ function Property(left, right) {
1647
+ return Visit3(left, right) === ExtendsResult.False ? ExtendsResult.False : type_exports.IsOptional(left) && !type_exports.IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
1648
+ }
1649
+ function FromObjectRight(left, right) {
1650
+ return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) || type_exports.IsLiteralString(left) && IsObjectStringLike(right) || type_exports.IsLiteralNumber(left) && IsObjectNumberLike(right) || type_exports.IsLiteralBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsBigInt(left) && IsObjectBigIntLike(right) || type_exports.IsString(left) && IsObjectStringLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsNumber(left) && IsObjectNumberLike(right) || type_exports.IsInteger(left) && IsObjectNumberLike(right) || type_exports.IsBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsUint8Array(left) && IsObjectUint8ArrayLike(right) || type_exports.IsDate(left) && IsObjectDateLike(right) || type_exports.IsConstructor(left) && IsObjectConstructorLike(right) || type_exports.IsFunction(left) && IsObjectFunctionLike(right) ? ExtendsResult.True : type_exports.IsRecord(left) && type_exports.IsString(RecordKey(left)) ? (() => {
1651
+ return right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False;
1652
+ })() : type_exports.IsRecord(left) && type_exports.IsNumber(RecordKey(left)) ? (() => {
1653
+ return IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False;
1654
+ })() : ExtendsResult.False;
1655
+ }
1656
+ function FromObject(left, right) {
1657
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : !type_exports.IsObject(right) ? ExtendsResult.False : (() => {
1658
+ for (const key of Object.getOwnPropertyNames(right.properties)) {
1659
+ if (!(key in left.properties) && !type_exports.IsOptional(right.properties[key])) {
1660
+ return ExtendsResult.False;
1661
+ }
1662
+ if (type_exports.IsOptional(right.properties[key])) {
1663
+ return ExtendsResult.True;
1664
+ }
1665
+ if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) {
1666
+ return ExtendsResult.False;
1667
+ }
1668
+ }
1669
+ return ExtendsResult.True;
1670
+ })();
1671
+ }
1672
+ function FromPromise2(left, right) {
1673
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True : !type_exports.IsPromise(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.item, right.item));
1674
+ }
1675
+ function RecordKey(schema) {
1676
+ return PatternNumberExact in schema.patternProperties ? Number2() : PatternStringExact in schema.patternProperties ? String2() : Throw("Unknown record key pattern");
1677
+ }
1678
+ function RecordValue(schema) {
1679
+ return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
1680
+ }
1681
+ function FromRecordRight(left, right) {
1682
+ const [Key, Value] = [RecordKey(right), RecordValue(right)];
1683
+ return type_exports.IsLiteralString(left) && type_exports.IsNumber(Key) && IntoBooleanResult(Visit3(left, Value)) === ExtendsResult.True ? ExtendsResult.True : type_exports.IsUint8Array(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsString(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsArray(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsObject(left) ? (() => {
1684
+ for (const key of Object.getOwnPropertyNames(left.properties)) {
1685
+ if (Property(Value, left.properties[key]) === ExtendsResult.False) {
1686
+ return ExtendsResult.False;
1687
+ }
1688
+ }
1689
+ return ExtendsResult.True;
1690
+ })() : ExtendsResult.False;
1691
+ }
1692
+ function FromRecord(left, right) {
1693
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsRecord(right) ? ExtendsResult.False : Visit3(RecordValue(left), RecordValue(right));
1694
+ }
1695
+ function FromRegExp(left, right) {
1696
+ const L = type_exports.IsRegExp(left) ? String2() : left;
1697
+ const R = type_exports.IsRegExp(right) ? String2() : right;
1698
+ return Visit3(L, R);
1699
+ }
1700
+ function FromStringRight(left, right) {
1701
+ return type_exports.IsLiteral(left) && value_exports.IsString(left.const) ? ExtendsResult.True : type_exports.IsString(left) ? ExtendsResult.True : ExtendsResult.False;
1702
+ }
1703
+ function FromString(left, right) {
1704
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? ExtendsResult.True : ExtendsResult.False;
1705
+ }
1706
+ function FromSymbol(left, right) {
1707
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsSymbol(right) ? ExtendsResult.True : ExtendsResult.False;
1708
+ }
1709
+ function FromTemplateLiteral2(left, right) {
1710
+ return type_exports.IsTemplateLiteral(left) ? Visit3(TemplateLiteralToUnion(left), right) : type_exports.IsTemplateLiteral(right) ? Visit3(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
1711
+ }
1712
+ function IsArrayOfTuple(left, right) {
1713
+ return type_exports.IsArray(right) && left.items !== void 0 && left.items.every((schema) => Visit3(schema, right.items) === ExtendsResult.True);
1714
+ }
1715
+ function FromTupleRight(left, right) {
1716
+ return type_exports.IsNever(left) ? ExtendsResult.True : type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
1717
+ }
1718
+ function FromTuple3(left, right) {
1719
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : type_exports.IsArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True : !type_exports.IsTuple(right) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) || !value_exports.IsUndefined(left.items) && value_exports.IsUndefined(right.items) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) ? ExtendsResult.True : left.items.every((schema, index) => Visit3(schema, right.items[index]) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1720
+ }
1721
+ function FromUint8Array(left, right) {
1722
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsUint8Array(right) ? ExtendsResult.True : ExtendsResult.False;
1723
+ }
1724
+ function FromUndefined(left, right) {
1725
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsVoid(right) ? FromVoidRight(left, right) : type_exports.IsUndefined(right) ? ExtendsResult.True : ExtendsResult.False;
1726
+ }
1727
+ function FromUnionRight(left, right) {
1728
+ return right.anyOf.some((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1729
+ }
1730
+ function FromUnion6(left, right) {
1731
+ return left.anyOf.every((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1732
+ }
1733
+ function FromUnknownRight(left, right) {
1734
+ return ExtendsResult.True;
1735
+ }
1736
+ function FromUnknown(left, right) {
1737
+ return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsString(right) ? FromStringRight(left, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : type_exports.IsArray(right) ? FromArrayRight(left, right) : type_exports.IsTuple(right) ? FromTupleRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsUnknown(right) ? ExtendsResult.True : ExtendsResult.False;
1738
+ }
1739
+ function FromVoidRight(left, right) {
1740
+ return type_exports.IsUndefined(left) ? ExtendsResult.True : type_exports.IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
1741
+ }
1742
+ function FromVoid(left, right) {
1743
+ return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsVoid(right) ? ExtendsResult.True : ExtendsResult.False;
1744
+ }
1745
+ function Visit3(left, right) {
1746
+ return (
1747
+ // resolvable
1748
+ type_exports.IsTemplateLiteral(left) || type_exports.IsTemplateLiteral(right) ? FromTemplateLiteral2(left, right) : type_exports.IsRegExp(left) || type_exports.IsRegExp(right) ? FromRegExp(left, right) : type_exports.IsNot(left) || type_exports.IsNot(right) ? FromNot(left, right) : (
1749
+ // standard
1750
+ type_exports.IsAny(left) ? FromAny(left, right) : type_exports.IsArray(left) ? FromArray4(left, right) : type_exports.IsBigInt(left) ? FromBigInt(left, right) : type_exports.IsBoolean(left) ? FromBoolean(left, right) : type_exports.IsAsyncIterator(left) ? FromAsyncIterator(left, right) : type_exports.IsConstructor(left) ? FromConstructor(left, right) : type_exports.IsDate(left) ? FromDate(left, right) : type_exports.IsFunction(left) ? FromFunction(left, right) : type_exports.IsInteger(left) ? FromInteger(left, right) : type_exports.IsIntersect(left) ? FromIntersect4(left, right) : type_exports.IsIterator(left) ? FromIterator(left, right) : type_exports.IsLiteral(left) ? FromLiteral2(left, right) : type_exports.IsNever(left) ? FromNever(left, right) : type_exports.IsNull(left) ? FromNull(left, right) : type_exports.IsNumber(left) ? FromNumber(left, right) : type_exports.IsObject(left) ? FromObject(left, right) : type_exports.IsRecord(left) ? FromRecord(left, right) : type_exports.IsString(left) ? FromString(left, right) : type_exports.IsSymbol(left) ? FromSymbol(left, right) : type_exports.IsTuple(left) ? FromTuple3(left, right) : type_exports.IsPromise(left) ? FromPromise2(left, right) : type_exports.IsUint8Array(left) ? FromUint8Array(left, right) : type_exports.IsUndefined(left) ? FromUndefined(left, right) : type_exports.IsUnion(left) ? FromUnion6(left, right) : type_exports.IsUnknown(left) ? FromUnknown(left, right) : type_exports.IsVoid(left) ? FromVoid(left, right) : Throw(`Unknown left type operand '${left[Kind]}'`)
1751
+ )
1752
+ );
1753
+ }
1754
+ function ExtendsCheck(left, right) {
1755
+ return Visit3(left, right);
1756
+ }
1757
+
1758
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.mjs
1759
+ function FromProperties8(P, Right, True, False, options) {
1760
+ const Acc = {};
1761
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
1762
+ Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
1763
+ return Acc;
1764
+ }
1765
+ function FromMappedResult6(Left, Right, True, False, options) {
1766
+ return FromProperties8(Left.properties, Right, True, False, options);
1767
+ }
1768
+ function ExtendsFromMappedResult(Left, Right, True, False, options) {
1769
+ const P = FromMappedResult6(Left, Right, True, False, options);
1770
+ return MappedResult(P);
1771
+ }
1772
+
1773
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends.mjs
1774
+ function ExtendsResolve(left, right, trueType, falseType) {
1775
+ const R = ExtendsCheck(left, right);
1776
+ return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
1777
+ }
1778
+ function Extends(L, R, T, F, options) {
1779
+ return IsMappedResult(L) ? ExtendsFromMappedResult(L, R, T, F, options) : IsMappedKey(L) ? CreateType(ExtendsFromMappedKey(L, R, T, F, options)) : CreateType(ExtendsResolve(L, R, T, F), options);
1780
+ }
1781
+
1782
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.mjs
1783
+ function FromPropertyKey(K, U, L, R, options) {
1784
+ return {
1785
+ [K]: Extends(Literal(K), U, L, R, Clone(options))
1786
+ };
1787
+ }
1788
+ function FromPropertyKeys(K, U, L, R, options) {
1789
+ return K.reduce((Acc, LK) => {
1790
+ return { ...Acc, ...FromPropertyKey(LK, U, L, R, options) };
1791
+ }, {});
1792
+ }
1793
+ function FromMappedKey2(K, U, L, R, options) {
1794
+ return FromPropertyKeys(K.keys, U, L, R, options);
1795
+ }
1796
+ function ExtendsFromMappedKey(T, U, L, R, options) {
1797
+ const P = FromMappedKey2(T, U, L, R, options);
1798
+ return MappedResult(P);
1799
+ }
1800
+
1801
+ // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.mjs
1802
+ function ExcludeFromTemplateLiteral(L, R) {
1803
+ return Exclude(TemplateLiteralToUnion(L), R);
1804
+ }
1805
+
1806
+ // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.mjs
1807
+ function ExcludeRest(L, R) {
1808
+ const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
1809
+ return excluded.length === 1 ? excluded[0] : Union(excluded);
1810
+ }
1811
+ function Exclude(L, R, options = {}) {
1812
+ if (IsTemplateLiteral(L))
1813
+ return CreateType(ExcludeFromTemplateLiteral(L, R), options);
1814
+ if (IsMappedResult(L))
1815
+ return CreateType(ExcludeFromMappedResult(L, R), options);
1816
+ return CreateType(IsUnion(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
1817
+ }
1818
+
1819
+ // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.mjs
1820
+ function FromProperties9(P, U) {
1821
+ const Acc = {};
1822
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
1823
+ Acc[K2] = Exclude(P[K2], U);
1824
+ return Acc;
1825
+ }
1826
+ function FromMappedResult7(R, T) {
1827
+ return FromProperties9(R.properties, T);
1828
+ }
1829
+ function ExcludeFromMappedResult(R, T) {
1830
+ const P = FromMappedResult7(R, T);
1831
+ return MappedResult(P);
1832
+ }
1833
+
1834
+ // node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.mjs
1835
+ function ExtractFromTemplateLiteral(L, R) {
1836
+ return Extract(TemplateLiteralToUnion(L), R);
1837
+ }
1838
+
1839
+ // node_modules/@sinclair/typebox/build/esm/type/extract/extract.mjs
1840
+ function ExtractRest(L, R) {
1841
+ const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
1842
+ return extracted.length === 1 ? extracted[0] : Union(extracted);
1843
+ }
1844
+ function Extract(L, R, options) {
1845
+ if (IsTemplateLiteral(L))
1846
+ return CreateType(ExtractFromTemplateLiteral(L, R), options);
1847
+ if (IsMappedResult(L))
1848
+ return CreateType(ExtractFromMappedResult(L, R), options);
1849
+ return CreateType(IsUnion(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
1850
+ }
1851
+
1852
+ // node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.mjs
1853
+ function FromProperties10(P, T) {
1854
+ const Acc = {};
1855
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
1856
+ Acc[K2] = Extract(P[K2], T);
1857
+ return Acc;
1858
+ }
1859
+ function FromMappedResult8(R, T) {
1860
+ return FromProperties10(R.properties, T);
1861
+ }
1862
+ function ExtractFromMappedResult(R, T) {
1863
+ const P = FromMappedResult8(R, T);
1864
+ return MappedResult(P);
1865
+ }
1866
+
1867
+ // node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.mjs
1868
+ function InstanceType(schema, options) {
1869
+ return IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options);
1870
+ }
1871
+
1872
+ // node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.mjs
1873
+ function ReadonlyOptional(schema) {
1874
+ return Readonly(Optional(schema));
1875
+ }
1876
+
1877
+ // node_modules/@sinclair/typebox/build/esm/type/record/record.mjs
1878
+ function RecordCreateFromPattern(pattern, T, options) {
1879
+ return CreateType({ [Kind]: "Record", type: "object", patternProperties: { [pattern]: T } }, options);
1880
+ }
1881
+ function RecordCreateFromKeys(K, T, options) {
1882
+ const result = {};
1883
+ for (const K2 of K)
1884
+ result[K2] = T;
1885
+ return Object2(result, { ...options, [Hint]: "Record" });
1886
+ }
1887
+ function FromTemplateLiteralKey(K, T, options) {
1888
+ return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
1889
+ }
1890
+ function FromUnionKey(key, type, options) {
1891
+ return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
1892
+ }
1893
+ function FromLiteralKey(key, type, options) {
1894
+ return RecordCreateFromKeys([key.toString()], type, options);
1895
+ }
1896
+ function FromRegExpKey(key, type, options) {
1897
+ return RecordCreateFromPattern(key.source, type, options);
1898
+ }
1899
+ function FromStringKey(key, type, options) {
1900
+ const pattern = IsUndefined(key.pattern) ? PatternStringExact : key.pattern;
1901
+ return RecordCreateFromPattern(pattern, type, options);
1902
+ }
1903
+ function FromAnyKey(_, type, options) {
1904
+ return RecordCreateFromPattern(PatternStringExact, type, options);
1905
+ }
1906
+ function FromNeverKey(_key, type, options) {
1907
+ return RecordCreateFromPattern(PatternNeverExact, type, options);
1908
+ }
1909
+ function FromBooleanKey(_key, type, options) {
1910
+ return Object2({ true: type, false: type }, options);
1911
+ }
1912
+ function FromIntegerKey(_key, type, options) {
1913
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
1914
+ }
1915
+ function FromNumberKey(_, type, options) {
1916
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
1917
+ }
1918
+ function Record(key, type, options = {}) {
1919
+ return IsUnion(key) ? FromUnionKey(key.anyOf, type, options) : IsTemplateLiteral(key) ? FromTemplateLiteralKey(key, type, options) : IsLiteral(key) ? FromLiteralKey(key.const, type, options) : IsBoolean2(key) ? FromBooleanKey(key, type, options) : IsInteger(key) ? FromIntegerKey(key, type, options) : IsNumber3(key) ? FromNumberKey(key, type, options) : IsRegExp2(key) ? FromRegExpKey(key, type, options) : IsString2(key) ? FromStringKey(key, type, options) : IsAny(key) ? FromAnyKey(key, type, options) : IsNever(key) ? FromNeverKey(key, type, options) : Never(options);
1920
+ }
1921
+ function RecordPattern(record) {
1922
+ return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
1923
+ }
1924
+ function RecordKey2(type) {
1925
+ const pattern = RecordPattern(type);
1926
+ return pattern === PatternStringExact ? String2() : pattern === PatternNumberExact ? Number2() : String2({ pattern });
1927
+ }
1928
+ function RecordValue2(type) {
1929
+ return type.patternProperties[RecordPattern(type)];
1930
+ }
1931
+
1932
+ // node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs
1933
+ function FromConstructor2(args, type) {
1934
+ type.parameters = FromTypes(args, type.parameters);
1935
+ type.returns = FromType(args, type.returns);
1936
+ return type;
1937
+ }
1938
+ function FromFunction2(args, type) {
1939
+ type.parameters = FromTypes(args, type.parameters);
1940
+ type.returns = FromType(args, type.returns);
1941
+ return type;
1942
+ }
1943
+ function FromIntersect5(args, type) {
1944
+ type.allOf = FromTypes(args, type.allOf);
1945
+ return type;
1946
+ }
1947
+ function FromUnion7(args, type) {
1948
+ type.anyOf = FromTypes(args, type.anyOf);
1949
+ return type;
1950
+ }
1951
+ function FromTuple4(args, type) {
1952
+ if (IsUndefined(type.items))
1953
+ return type;
1954
+ type.items = FromTypes(args, type.items);
1955
+ return type;
1956
+ }
1957
+ function FromArray5(args, type) {
1958
+ type.items = FromType(args, type.items);
1959
+ return type;
1960
+ }
1961
+ function FromAsyncIterator2(args, type) {
1962
+ type.items = FromType(args, type.items);
1963
+ return type;
1964
+ }
1965
+ function FromIterator2(args, type) {
1966
+ type.items = FromType(args, type.items);
1967
+ return type;
1968
+ }
1969
+ function FromPromise3(args, type) {
1970
+ type.item = FromType(args, type.item);
1971
+ return type;
1972
+ }
1973
+ function FromObject2(args, type) {
1974
+ const mappedProperties = FromProperties11(args, type.properties);
1975
+ return { ...type, ...Object2(mappedProperties) };
1976
+ }
1977
+ function FromRecord2(args, type) {
1978
+ const mappedKey = FromType(args, RecordKey2(type));
1979
+ const mappedValue = FromType(args, RecordValue2(type));
1980
+ const result = Record(mappedKey, mappedValue);
1981
+ return { ...type, ...result };
1982
+ }
1983
+ function FromArgument(args, argument) {
1984
+ return argument.index in args ? args[argument.index] : Unknown();
1985
+ }
1986
+ function FromProperty2(args, type) {
1987
+ const isReadonly = IsReadonly(type);
1988
+ const isOptional = IsOptional(type);
1989
+ const mapped = FromType(args, type);
1990
+ return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
1991
+ }
1992
+ function FromProperties11(args, properties) {
1993
+ return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
1994
+ return { ...result, [key]: FromProperty2(args, properties[key]) };
1995
+ }, {});
1996
+ }
1997
+ function FromTypes(args, types) {
1998
+ return types.map((type) => FromType(args, type));
1999
+ }
2000
+ function FromType(args, type) {
2001
+ return IsConstructor(type) ? FromConstructor2(args, type) : IsFunction2(type) ? FromFunction2(args, type) : IsIntersect(type) ? FromIntersect5(args, type) : IsUnion(type) ? FromUnion7(args, type) : IsTuple(type) ? FromTuple4(args, type) : IsArray3(type) ? FromArray5(args, type) : IsAsyncIterator2(type) ? FromAsyncIterator2(args, type) : IsIterator2(type) ? FromIterator2(args, type) : IsPromise(type) ? FromPromise3(args, type) : IsObject3(type) ? FromObject2(args, type) : IsRecord(type) ? FromRecord2(args, type) : IsArgument(type) ? FromArgument(args, type) : type;
2002
+ }
2003
+ function Instantiate(type, args) {
2004
+ return FromType(args, CloneType(type));
2005
+ }
2006
+
2007
+ // node_modules/@sinclair/typebox/build/esm/type/integer/integer.mjs
2008
+ function Integer(options) {
2009
+ return CreateType({ [Kind]: "Integer", type: "integer" }, options);
2010
+ }
2011
+
2012
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs
2013
+ function MappedIntrinsicPropertyKey(K, M, options) {
2014
+ return {
2015
+ [K]: Intrinsic(Literal(K), M, Clone(options))
2016
+ };
2017
+ }
2018
+ function MappedIntrinsicPropertyKeys(K, M, options) {
2019
+ const result = K.reduce((Acc, L) => {
2020
+ return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
2021
+ }, {});
2022
+ return result;
2023
+ }
2024
+ function MappedIntrinsicProperties(T, M, options) {
2025
+ return MappedIntrinsicPropertyKeys(T["keys"], M, options);
2026
+ }
2027
+ function IntrinsicFromMappedKey(T, M, options) {
2028
+ const P = MappedIntrinsicProperties(T, M, options);
2029
+ return MappedResult(P);
2030
+ }
2031
+
2032
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.mjs
2033
+ function ApplyUncapitalize(value) {
2034
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
2035
+ return [first.toLowerCase(), rest].join("");
2036
+ }
2037
+ function ApplyCapitalize(value) {
2038
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
2039
+ return [first.toUpperCase(), rest].join("");
2040
+ }
2041
+ function ApplyUppercase(value) {
2042
+ return value.toUpperCase();
2043
+ }
2044
+ function ApplyLowercase(value) {
2045
+ return value.toLowerCase();
2046
+ }
2047
+ function FromTemplateLiteral3(schema, mode, options) {
2048
+ const expression = TemplateLiteralParseExact(schema.pattern);
2049
+ const finite = IsTemplateLiteralExpressionFinite(expression);
2050
+ if (!finite)
2051
+ return { ...schema, pattern: FromLiteralValue(schema.pattern, mode) };
2052
+ const strings = [...TemplateLiteralExpressionGenerate(expression)];
2053
+ const literals = strings.map((value) => Literal(value));
2054
+ const mapped = FromRest5(literals, mode);
2055
+ const union = Union(mapped);
2056
+ return TemplateLiteral([union], options);
2057
+ }
2058
+ function FromLiteralValue(value, mode) {
2059
+ return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
2060
+ }
2061
+ function FromRest5(T, M) {
2062
+ return T.map((L) => Intrinsic(L, M));
2063
+ }
2064
+ function Intrinsic(schema, mode, options = {}) {
2065
+ return (
2066
+ // Intrinsic-Mapped-Inference
2067
+ IsMappedKey(schema) ? IntrinsicFromMappedKey(schema, mode, options) : (
2068
+ // Standard-Inference
2069
+ IsTemplateLiteral(schema) ? FromTemplateLiteral3(schema, mode, options) : IsUnion(schema) ? Union(FromRest5(schema.anyOf, mode), options) : IsLiteral(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : (
2070
+ // Default Type
2071
+ CreateType(schema, options)
2072
+ )
2073
+ )
2074
+ );
2075
+ }
2076
+
2077
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.mjs
2078
+ function Capitalize(T, options = {}) {
2079
+ return Intrinsic(T, "Capitalize", options);
2080
+ }
2081
+
2082
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.mjs
2083
+ function Lowercase(T, options = {}) {
2084
+ return Intrinsic(T, "Lowercase", options);
2085
+ }
2086
+
2087
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.mjs
2088
+ function Uncapitalize(T, options = {}) {
2089
+ return Intrinsic(T, "Uncapitalize", options);
2090
+ }
2091
+
2092
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.mjs
2093
+ function Uppercase(T, options = {}) {
2094
+ return Intrinsic(T, "Uppercase", options);
2095
+ }
2096
+
2097
+ // node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.mjs
2098
+ function FromProperties12(properties, propertyKeys, options) {
2099
+ const result = {};
2100
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
2101
+ result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
2102
+ return result;
2103
+ }
2104
+ function FromMappedResult9(mappedResult, propertyKeys, options) {
2105
+ return FromProperties12(mappedResult.properties, propertyKeys, options);
2106
+ }
2107
+ function OmitFromMappedResult(mappedResult, propertyKeys, options) {
2108
+ const properties = FromMappedResult9(mappedResult, propertyKeys, options);
2109
+ return MappedResult(properties);
2110
+ }
2111
+
2112
+ // node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs
2113
+ function FromIntersect6(types, propertyKeys) {
2114
+ return types.map((type) => OmitResolve(type, propertyKeys));
2115
+ }
2116
+ function FromUnion8(types, propertyKeys) {
2117
+ return types.map((type) => OmitResolve(type, propertyKeys));
2118
+ }
2119
+ function FromProperty3(properties, key) {
2120
+ const { [key]: _, ...R } = properties;
2121
+ return R;
2122
+ }
2123
+ function FromProperties13(properties, propertyKeys) {
2124
+ return propertyKeys.reduce((T, K2) => FromProperty3(T, K2), properties);
2125
+ }
2126
+ function FromObject3(type, propertyKeys, properties) {
2127
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
2128
+ const mappedProperties = FromProperties13(properties, propertyKeys);
2129
+ return Object2(mappedProperties, options);
2130
+ }
2131
+ function UnionFromPropertyKeys(propertyKeys) {
2132
+ const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
2133
+ return Union(result);
2134
+ }
2135
+ function OmitResolve(type, propertyKeys) {
2136
+ return IsIntersect(type) ? Intersect(FromIntersect6(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion8(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject3(type, propertyKeys, type.properties) : Object2({});
2137
+ }
2138
+ function Omit(type, key, options) {
2139
+ const typeKey = IsArray(key) ? UnionFromPropertyKeys(key) : key;
2140
+ const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
2141
+ const isTypeRef = IsRef(type);
2142
+ const isKeyRef = IsRef(key);
2143
+ return IsMappedResult(type) ? OmitFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? OmitFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Omit", [type, typeKey], options) : CreateType({ ...OmitResolve(type, propertyKeys), ...options });
2144
+ }
2145
+
2146
+ // node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.mjs
2147
+ function FromPropertyKey2(type, key, options) {
2148
+ return { [key]: Omit(type, [key], Clone(options)) };
2149
+ }
2150
+ function FromPropertyKeys2(type, propertyKeys, options) {
2151
+ return propertyKeys.reduce((Acc, LK) => {
2152
+ return { ...Acc, ...FromPropertyKey2(type, LK, options) };
2153
+ }, {});
2154
+ }
2155
+ function FromMappedKey3(type, mappedKey, options) {
2156
+ return FromPropertyKeys2(type, mappedKey.keys, options);
2157
+ }
2158
+ function OmitFromMappedKey(type, mappedKey, options) {
2159
+ const properties = FromMappedKey3(type, mappedKey, options);
2160
+ return MappedResult(properties);
2161
+ }
2162
+
2163
+ // node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.mjs
2164
+ function FromProperties14(properties, propertyKeys, options) {
2165
+ const result = {};
2166
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
2167
+ result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
2168
+ return result;
2169
+ }
2170
+ function FromMappedResult10(mappedResult, propertyKeys, options) {
2171
+ return FromProperties14(mappedResult.properties, propertyKeys, options);
2172
+ }
2173
+ function PickFromMappedResult(mappedResult, propertyKeys, options) {
2174
+ const properties = FromMappedResult10(mappedResult, propertyKeys, options);
2175
+ return MappedResult(properties);
2176
+ }
2177
+
2178
+ // node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs
2179
+ function FromIntersect7(types, propertyKeys) {
2180
+ return types.map((type) => PickResolve(type, propertyKeys));
2181
+ }
2182
+ function FromUnion9(types, propertyKeys) {
2183
+ return types.map((type) => PickResolve(type, propertyKeys));
2184
+ }
2185
+ function FromProperties15(properties, propertyKeys) {
2186
+ const result = {};
2187
+ for (const K2 of propertyKeys)
2188
+ if (K2 in properties)
2189
+ result[K2] = properties[K2];
2190
+ return result;
2191
+ }
2192
+ function FromObject4(Type2, keys, properties) {
2193
+ const options = Discard(Type2, [TransformKind, "$id", "required", "properties"]);
2194
+ const mappedProperties = FromProperties15(properties, keys);
2195
+ return Object2(mappedProperties, options);
2196
+ }
2197
+ function UnionFromPropertyKeys2(propertyKeys) {
2198
+ const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
2199
+ return Union(result);
2200
+ }
2201
+ function PickResolve(type, propertyKeys) {
2202
+ return IsIntersect(type) ? Intersect(FromIntersect7(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion9(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject4(type, propertyKeys, type.properties) : Object2({});
2203
+ }
2204
+ function Pick(type, key, options) {
2205
+ const typeKey = IsArray(key) ? UnionFromPropertyKeys2(key) : key;
2206
+ const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
2207
+ const isTypeRef = IsRef(type);
2208
+ const isKeyRef = IsRef(key);
2209
+ return IsMappedResult(type) ? PickFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? PickFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Pick", [type, typeKey], options) : CreateType({ ...PickResolve(type, propertyKeys), ...options });
2210
+ }
2211
+
2212
+ // node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.mjs
2213
+ function FromPropertyKey3(type, key, options) {
2214
+ return {
2215
+ [key]: Pick(type, [key], Clone(options))
2216
+ };
2217
+ }
2218
+ function FromPropertyKeys3(type, propertyKeys, options) {
2219
+ return propertyKeys.reduce((result, leftKey) => {
2220
+ return { ...result, ...FromPropertyKey3(type, leftKey, options) };
2221
+ }, {});
2222
+ }
2223
+ function FromMappedKey4(type, mappedKey, options) {
2224
+ return FromPropertyKeys3(type, mappedKey.keys, options);
2225
+ }
2226
+ function PickFromMappedKey(type, mappedKey, options) {
2227
+ const properties = FromMappedKey4(type, mappedKey, options);
2228
+ return MappedResult(properties);
2229
+ }
2230
+
2231
+ // node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs
2232
+ function FromComputed3(target, parameters) {
2233
+ return Computed("Partial", [Computed(target, parameters)]);
2234
+ }
2235
+ function FromRef3($ref) {
2236
+ return Computed("Partial", [Ref($ref)]);
2237
+ }
2238
+ function FromProperties16(properties) {
2239
+ const partialProperties = {};
2240
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
2241
+ partialProperties[K] = Optional(properties[K]);
2242
+ return partialProperties;
2243
+ }
2244
+ function FromObject5(type, properties) {
2245
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
2246
+ const mappedProperties = FromProperties16(properties);
2247
+ return Object2(mappedProperties, options);
2248
+ }
2249
+ function FromRest6(types) {
2250
+ return types.map((type) => PartialResolve(type));
2251
+ }
2252
+ function PartialResolve(type) {
2253
+ return (
2254
+ // Mappable
2255
+ IsComputed(type) ? FromComputed3(type.target, type.parameters) : IsRef(type) ? FromRef3(type.$ref) : IsIntersect(type) ? Intersect(FromRest6(type.allOf)) : IsUnion(type) ? Union(FromRest6(type.anyOf)) : IsObject3(type) ? FromObject5(type, type.properties) : (
2256
+ // Intrinsic
2257
+ IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : (
2258
+ // Passthrough
2259
+ Object2({})
2260
+ )
2261
+ )
2262
+ );
2263
+ }
2264
+ function Partial(type, options) {
2265
+ if (IsMappedResult(type)) {
2266
+ return PartialFromMappedResult(type, options);
2267
+ } else {
2268
+ return CreateType({ ...PartialResolve(type), ...options });
2269
+ }
2270
+ }
2271
+
2272
+ // node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.mjs
2273
+ function FromProperties17(K, options) {
2274
+ const Acc = {};
2275
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K))
2276
+ Acc[K2] = Partial(K[K2], Clone(options));
2277
+ return Acc;
2278
+ }
2279
+ function FromMappedResult11(R, options) {
2280
+ return FromProperties17(R.properties, options);
2281
+ }
2282
+ function PartialFromMappedResult(R, options) {
2283
+ const P = FromMappedResult11(R, options);
2284
+ return MappedResult(P);
2285
+ }
2286
+
2287
+ // node_modules/@sinclair/typebox/build/esm/type/required/required.mjs
2288
+ function FromComputed4(target, parameters) {
2289
+ return Computed("Required", [Computed(target, parameters)]);
2290
+ }
2291
+ function FromRef4($ref) {
2292
+ return Computed("Required", [Ref($ref)]);
2293
+ }
2294
+ function FromProperties18(properties) {
2295
+ const requiredProperties = {};
2296
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
2297
+ requiredProperties[K] = Discard(properties[K], [OptionalKind]);
2298
+ return requiredProperties;
2299
+ }
2300
+ function FromObject6(type, properties) {
2301
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
2302
+ const mappedProperties = FromProperties18(properties);
2303
+ return Object2(mappedProperties, options);
2304
+ }
2305
+ function FromRest7(types) {
2306
+ return types.map((type) => RequiredResolve(type));
2307
+ }
2308
+ function RequiredResolve(type) {
2309
+ return (
2310
+ // Mappable
2311
+ IsComputed(type) ? FromComputed4(type.target, type.parameters) : IsRef(type) ? FromRef4(type.$ref) : IsIntersect(type) ? Intersect(FromRest7(type.allOf)) : IsUnion(type) ? Union(FromRest7(type.anyOf)) : IsObject3(type) ? FromObject6(type, type.properties) : (
2312
+ // Intrinsic
2313
+ IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : (
2314
+ // Passthrough
2315
+ Object2({})
2316
+ )
2317
+ )
2318
+ );
2319
+ }
2320
+ function Required(type, options) {
2321
+ if (IsMappedResult(type)) {
2322
+ return RequiredFromMappedResult(type, options);
2323
+ } else {
2324
+ return CreateType({ ...RequiredResolve(type), ...options });
2325
+ }
2326
+ }
2327
+
2328
+ // node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.mjs
2329
+ function FromProperties19(P, options) {
2330
+ const Acc = {};
2331
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
2332
+ Acc[K2] = Required(P[K2], options);
2333
+ return Acc;
2334
+ }
2335
+ function FromMappedResult12(R, options) {
2336
+ return FromProperties19(R.properties, options);
2337
+ }
2338
+ function RequiredFromMappedResult(R, options) {
2339
+ const P = FromMappedResult12(R, options);
2340
+ return MappedResult(P);
2341
+ }
2342
+
2343
+ // node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs
2344
+ function DereferenceParameters(moduleProperties, types) {
2345
+ return types.map((type) => {
2346
+ return IsRef(type) ? Dereference(moduleProperties, type.$ref) : FromType2(moduleProperties, type);
2347
+ });
2348
+ }
2349
+ function Dereference(moduleProperties, ref) {
2350
+ return ref in moduleProperties ? IsRef(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType2(moduleProperties, moduleProperties[ref]) : Never();
2351
+ }
2352
+ function FromAwaited(parameters) {
2353
+ return Awaited(parameters[0]);
2354
+ }
2355
+ function FromIndex(parameters) {
2356
+ return Index(parameters[0], parameters[1]);
2357
+ }
2358
+ function FromKeyOf(parameters) {
2359
+ return KeyOf(parameters[0]);
2360
+ }
2361
+ function FromPartial(parameters) {
2362
+ return Partial(parameters[0]);
2363
+ }
2364
+ function FromOmit(parameters) {
2365
+ return Omit(parameters[0], parameters[1]);
2366
+ }
2367
+ function FromPick(parameters) {
2368
+ return Pick(parameters[0], parameters[1]);
2369
+ }
2370
+ function FromRequired(parameters) {
2371
+ return Required(parameters[0]);
2372
+ }
2373
+ function FromComputed5(moduleProperties, target, parameters) {
2374
+ const dereferenced = DereferenceParameters(moduleProperties, parameters);
2375
+ return target === "Awaited" ? FromAwaited(dereferenced) : target === "Index" ? FromIndex(dereferenced) : target === "KeyOf" ? FromKeyOf(dereferenced) : target === "Partial" ? FromPartial(dereferenced) : target === "Omit" ? FromOmit(dereferenced) : target === "Pick" ? FromPick(dereferenced) : target === "Required" ? FromRequired(dereferenced) : Never();
2376
+ }
2377
+ function FromArray6(moduleProperties, type) {
2378
+ return Array2(FromType2(moduleProperties, type));
2379
+ }
2380
+ function FromAsyncIterator3(moduleProperties, type) {
2381
+ return AsyncIterator(FromType2(moduleProperties, type));
2382
+ }
2383
+ function FromConstructor3(moduleProperties, parameters, instanceType) {
2384
+ return Constructor(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, instanceType));
2385
+ }
2386
+ function FromFunction3(moduleProperties, parameters, returnType) {
2387
+ return Function(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, returnType));
2388
+ }
2389
+ function FromIntersect8(moduleProperties, types) {
2390
+ return Intersect(FromTypes2(moduleProperties, types));
2391
+ }
2392
+ function FromIterator3(moduleProperties, type) {
2393
+ return Iterator(FromType2(moduleProperties, type));
2394
+ }
2395
+ function FromObject7(moduleProperties, properties) {
2396
+ return Object2(globalThis.Object.keys(properties).reduce((result, key) => {
2397
+ return { ...result, [key]: FromType2(moduleProperties, properties[key]) };
2398
+ }, {}));
2399
+ }
2400
+ function FromRecord3(moduleProperties, type) {
2401
+ const [value, pattern] = [FromType2(moduleProperties, RecordValue2(type)), RecordPattern(type)];
2402
+ const result = CloneType(type);
2403
+ result.patternProperties[pattern] = value;
2404
+ return result;
2405
+ }
2406
+ function FromTransform(moduleProperties, transform) {
2407
+ return IsRef(transform) ? { ...Dereference(moduleProperties, transform.$ref), [TransformKind]: transform[TransformKind] } : transform;
2408
+ }
2409
+ function FromTuple5(moduleProperties, types) {
2410
+ return Tuple(FromTypes2(moduleProperties, types));
2411
+ }
2412
+ function FromUnion10(moduleProperties, types) {
2413
+ return Union(FromTypes2(moduleProperties, types));
2414
+ }
2415
+ function FromTypes2(moduleProperties, types) {
2416
+ return types.map((type) => FromType2(moduleProperties, type));
2417
+ }
2418
+ function FromType2(moduleProperties, type) {
2419
+ return (
2420
+ // Modifiers
2421
+ IsOptional(type) ? CreateType(FromType2(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType2(moduleProperties, Discard(type, [ReadonlyKind])), type) : (
2422
+ // Transform
2423
+ IsTransform(type) ? CreateType(FromTransform(moduleProperties, type), type) : (
2424
+ // Types
2425
+ IsArray3(type) ? CreateType(FromArray6(moduleProperties, type.items), type) : IsAsyncIterator2(type) ? CreateType(FromAsyncIterator3(moduleProperties, type.items), type) : IsComputed(type) ? CreateType(FromComputed5(moduleProperties, type.target, type.parameters)) : IsConstructor(type) ? CreateType(FromConstructor3(moduleProperties, type.parameters, type.returns), type) : IsFunction2(type) ? CreateType(FromFunction3(moduleProperties, type.parameters, type.returns), type) : IsIntersect(type) ? CreateType(FromIntersect8(moduleProperties, type.allOf), type) : IsIterator2(type) ? CreateType(FromIterator3(moduleProperties, type.items), type) : IsObject3(type) ? CreateType(FromObject7(moduleProperties, type.properties), type) : IsRecord(type) ? CreateType(FromRecord3(moduleProperties, type)) : IsTuple(type) ? CreateType(FromTuple5(moduleProperties, type.items || []), type) : IsUnion(type) ? CreateType(FromUnion10(moduleProperties, type.anyOf), type) : type
2426
+ )
2427
+ )
2428
+ );
2429
+ }
2430
+ function ComputeType(moduleProperties, key) {
2431
+ return key in moduleProperties ? FromType2(moduleProperties, moduleProperties[key]) : Never();
2432
+ }
2433
+ function ComputeModuleProperties(moduleProperties) {
2434
+ return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
2435
+ return { ...result, [key]: ComputeType(moduleProperties, key) };
2436
+ }, {});
2437
+ }
2438
+
2439
+ // node_modules/@sinclair/typebox/build/esm/type/module/module.mjs
2440
+ var TModule = class {
2441
+ constructor($defs) {
2442
+ const computed = ComputeModuleProperties($defs);
2443
+ const identified = this.WithIdentifiers(computed);
2444
+ this.$defs = identified;
2445
+ }
2446
+ /** `[Json]` Imports a Type by Key. */
2447
+ Import(key, options) {
2448
+ const $defs = { ...this.$defs, [key]: CreateType(this.$defs[key], options) };
2449
+ return CreateType({ [Kind]: "Import", $defs, $ref: key });
2450
+ }
2451
+ // prettier-ignore
2452
+ WithIdentifiers($defs) {
2453
+ return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
2454
+ return { ...result, [key]: { ...$defs[key], $id: key } };
2455
+ }, {});
2456
+ }
2457
+ };
2458
+ function Module(properties) {
2459
+ return new TModule(properties);
2460
+ }
2461
+
2462
+ // node_modules/@sinclair/typebox/build/esm/type/not/not.mjs
2463
+ function Not(type, options) {
2464
+ return CreateType({ [Kind]: "Not", not: type }, options);
2465
+ }
2466
+
2467
+ // node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.mjs
2468
+ function Parameters(schema, options) {
2469
+ return IsFunction2(schema) ? Tuple(schema.parameters, options) : Never();
2470
+ }
2471
+
2472
+ // node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.mjs
2473
+ var Ordinal = 0;
2474
+ function Recursive(callback, options = {}) {
2475
+ if (IsUndefined(options.$id))
2476
+ options.$id = `T${Ordinal++}`;
2477
+ const thisType = CloneType(callback({ [Kind]: "This", $ref: `${options.$id}` }));
2478
+ thisType.$id = options.$id;
2479
+ return CreateType({ [Hint]: "Recursive", ...thisType }, options);
2480
+ }
2481
+
2482
+ // node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.mjs
2483
+ function RegExp2(unresolved, options) {
2484
+ const expr = IsString(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
2485
+ return CreateType({ [Kind]: "RegExp", type: "RegExp", source: expr.source, flags: expr.flags }, options);
2486
+ }
2487
+
2488
+ // node_modules/@sinclair/typebox/build/esm/type/rest/rest.mjs
2489
+ function RestResolve(T) {
2490
+ return IsIntersect(T) ? T.allOf : IsUnion(T) ? T.anyOf : IsTuple(T) ? T.items ?? [] : [];
2491
+ }
2492
+ function Rest(T) {
2493
+ return RestResolve(T);
2494
+ }
2495
+
2496
+ // node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.mjs
2497
+ function ReturnType(schema, options) {
2498
+ return IsFunction2(schema) ? CreateType(schema.returns, options) : Never(options);
2499
+ }
2500
+
2501
+ // node_modules/@sinclair/typebox/build/esm/type/transform/transform.mjs
2502
+ var TransformDecodeBuilder = class {
2503
+ constructor(schema) {
2504
+ this.schema = schema;
2505
+ }
2506
+ Decode(decode) {
2507
+ return new TransformEncodeBuilder(this.schema, decode);
2508
+ }
2509
+ };
2510
+ var TransformEncodeBuilder = class {
2511
+ constructor(schema, decode) {
2512
+ this.schema = schema;
2513
+ this.decode = decode;
2514
+ }
2515
+ EncodeTransform(encode, schema) {
2516
+ const Encode = (value) => schema[TransformKind].Encode(encode(value));
2517
+ const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
2518
+ const Codec = { Encode, Decode };
2519
+ return { ...schema, [TransformKind]: Codec };
2520
+ }
2521
+ EncodeSchema(encode, schema) {
2522
+ const Codec = { Decode: this.decode, Encode: encode };
2523
+ return { ...schema, [TransformKind]: Codec };
2524
+ }
2525
+ Encode(encode) {
2526
+ return IsTransform(this.schema) ? this.EncodeTransform(encode, this.schema) : this.EncodeSchema(encode, this.schema);
2527
+ }
2528
+ };
2529
+ function Transform(schema) {
2530
+ return new TransformDecodeBuilder(schema);
2531
+ }
2532
+
2533
+ // node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.mjs
2534
+ function Unsafe(options = {}) {
2535
+ return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
2536
+ }
2537
+
2538
+ // node_modules/@sinclair/typebox/build/esm/type/void/void.mjs
2539
+ function Void(options) {
2540
+ return CreateType({ [Kind]: "Void", type: "void" }, options);
2541
+ }
2542
+
2543
+ // node_modules/@sinclair/typebox/build/esm/type/type/type.mjs
2544
+ var type_exports2 = {};
2545
+ __export(type_exports2, {
2546
+ Any: () => Any,
2547
+ Argument: () => Argument,
2548
+ Array: () => Array2,
2549
+ AsyncIterator: () => AsyncIterator,
2550
+ Awaited: () => Awaited,
2551
+ BigInt: () => BigInt,
2552
+ Boolean: () => Boolean2,
2553
+ Capitalize: () => Capitalize,
2554
+ Composite: () => Composite,
2555
+ Const: () => Const,
2556
+ Constructor: () => Constructor,
2557
+ ConstructorParameters: () => ConstructorParameters,
2558
+ Date: () => Date2,
2559
+ Enum: () => Enum,
2560
+ Exclude: () => Exclude,
2561
+ Extends: () => Extends,
2562
+ Extract: () => Extract,
2563
+ Function: () => Function,
2564
+ Index: () => Index,
2565
+ InstanceType: () => InstanceType,
2566
+ Instantiate: () => Instantiate,
2567
+ Integer: () => Integer,
2568
+ Intersect: () => Intersect,
2569
+ Iterator: () => Iterator,
2570
+ KeyOf: () => KeyOf,
2571
+ Literal: () => Literal,
2572
+ Lowercase: () => Lowercase,
2573
+ Mapped: () => Mapped,
2574
+ Module: () => Module,
2575
+ Never: () => Never,
2576
+ Not: () => Not,
2577
+ Null: () => Null,
2578
+ Number: () => Number2,
2579
+ Object: () => Object2,
2580
+ Omit: () => Omit,
2581
+ Optional: () => Optional,
2582
+ Parameters: () => Parameters,
2583
+ Partial: () => Partial,
2584
+ Pick: () => Pick,
2585
+ Promise: () => Promise2,
2586
+ Readonly: () => Readonly,
2587
+ ReadonlyOptional: () => ReadonlyOptional,
2588
+ Record: () => Record,
2589
+ Recursive: () => Recursive,
2590
+ Ref: () => Ref,
2591
+ RegExp: () => RegExp2,
2592
+ Required: () => Required,
2593
+ Rest: () => Rest,
2594
+ ReturnType: () => ReturnType,
2595
+ String: () => String2,
2596
+ Symbol: () => Symbol2,
2597
+ TemplateLiteral: () => TemplateLiteral,
2598
+ Transform: () => Transform,
2599
+ Tuple: () => Tuple,
2600
+ Uint8Array: () => Uint8Array2,
2601
+ Uncapitalize: () => Uncapitalize,
2602
+ Undefined: () => Undefined,
2603
+ Union: () => Union,
2604
+ Unknown: () => Unknown,
2605
+ Unsafe: () => Unsafe,
2606
+ Uppercase: () => Uppercase,
2607
+ Void: () => Void
2608
+ });
2609
+
2610
+ // node_modules/@sinclair/typebox/build/esm/type/type/index.mjs
2611
+ var Type = type_exports2;
2612
+
2613
+ // src/claude-code.ts
2614
+ import * as fs2 from "node:fs/promises";
2615
+ import * as path2 from "node:path";
2616
+ import { homedir as homedir2 } from "node:os";
2617
+
2618
+ // src/session-manager.ts
2619
+ import * as fs from "node:fs/promises";
2620
+ import * as path from "node:path";
2621
+ import { homedir } from "node:os";
2622
+ import { randomUUID } from "node:crypto";
2623
+ var SessionManager = class {
2624
+ config;
2625
+ constructor(config) {
2626
+ this.config = {
2627
+ ...config,
2628
+ sessionsDir: this.expandPath(config.sessionsDir),
2629
+ workspacesDir: this.expandPath(config.workspacesDir)
2630
+ };
2631
+ }
2632
+ expandPath(p) {
2633
+ if (p.startsWith("~")) {
2634
+ return path.join(homedir(), p.slice(1));
2635
+ }
2636
+ return p;
2637
+ }
2638
+ sessionDir(sessionKey) {
2639
+ return path.join(this.config.sessionsDir, sessionKey);
2640
+ }
2641
+ sessionFile(sessionKey) {
2642
+ return path.join(this.sessionDir(sessionKey), "session.json");
2643
+ }
2644
+ claudeDir(sessionKey) {
2645
+ return path.join(this.sessionDir(sessionKey), ".claude");
2646
+ }
2647
+ jobsDir(sessionKey) {
2648
+ return path.join(this.sessionDir(sessionKey), "jobs");
2649
+ }
2650
+ jobFile(sessionKey, jobId) {
2651
+ return path.join(this.jobsDir(sessionKey), `${jobId}.json`);
2652
+ }
2653
+ jobOutputFile(sessionKey, jobId) {
2654
+ return path.join(this.jobsDir(sessionKey), `${jobId}.log`);
2655
+ }
2656
+ workspaceDir(sessionKey) {
2657
+ return path.join(this.config.workspacesDir, sessionKey);
2658
+ }
2659
+ async getSession(sessionKey) {
2660
+ const sessionPath = this.sessionFile(sessionKey);
2661
+ try {
2662
+ const data = await fs.readFile(sessionPath, "utf-8");
2663
+ return JSON.parse(data);
2664
+ } catch (err) {
2665
+ if (err.code === "ENOENT") {
2666
+ return null;
2667
+ }
2668
+ throw err;
2669
+ }
2670
+ }
2671
+ async createSession(sessionKey) {
2672
+ const sessionPath = this.sessionDir(sessionKey);
2673
+ const claudePath = this.claudeDir(sessionKey);
2674
+ const workspacePath = this.workspaceDir(sessionKey);
2675
+ await fs.mkdir(sessionPath, { recursive: true });
2676
+ await fs.mkdir(claudePath, { recursive: true });
2677
+ await fs.mkdir(workspacePath, { recursive: true });
2678
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2679
+ const session = {
2680
+ sessionKey,
2681
+ claudeSessionId: null,
2682
+ createdAt: now,
2683
+ lastActivity: now,
2684
+ messageCount: 0,
2685
+ activeJobId: null
2686
+ };
2687
+ await fs.writeFile(this.sessionFile(sessionKey), JSON.stringify(session, null, 2));
2688
+ return session;
2689
+ }
2690
+ async getOrCreateSession(sessionKey) {
2691
+ const existing = await this.getSession(sessionKey);
2692
+ if (existing) {
2693
+ return existing;
2694
+ }
2695
+ return this.createSession(sessionKey);
2696
+ }
2697
+ async updateSession(sessionKey, claudeSessionId) {
2698
+ const session = await this.getSession(sessionKey);
2699
+ if (!session) {
2700
+ throw new Error(`Session not found: ${sessionKey}`);
2701
+ }
2702
+ session.claudeSessionId = claudeSessionId;
2703
+ session.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
2704
+ session.messageCount += 1;
2705
+ await fs.writeFile(this.sessionFile(sessionKey), JSON.stringify(session, null, 2));
2706
+ return session;
2707
+ }
2708
+ async deleteSession(sessionKey) {
2709
+ const sessionPath = this.sessionDir(sessionKey);
2710
+ const workspacePath = this.workspaceDir(sessionKey);
2711
+ try {
2712
+ await fs.rm(sessionPath, { recursive: true, force: true });
2713
+ } catch {
2714
+ }
2715
+ try {
2716
+ await fs.rm(workspacePath, { recursive: true, force: true });
2717
+ } catch {
2718
+ }
2719
+ }
2720
+ async listSessions() {
2721
+ const sessions = [];
2722
+ try {
2723
+ const entries = await fs.readdir(this.config.sessionsDir, { withFileTypes: true });
2724
+ for (const entry of entries) {
2725
+ if (!entry.isDirectory()) continue;
2726
+ const session = await this.getSession(entry.name);
2727
+ if (session) {
2728
+ sessions.push(session);
2729
+ }
2730
+ }
2731
+ } catch (err) {
2732
+ if (err.code !== "ENOENT") {
2733
+ throw err;
2734
+ }
2735
+ }
2736
+ return sessions;
2737
+ }
2738
+ async cleanupIdleSessions() {
2739
+ const sessions = await this.listSessions();
2740
+ const cutoff = Date.now() - this.config.idleTimeout * 1e3;
2741
+ const deleted = [];
2742
+ for (const session of sessions) {
2743
+ const lastActivity = new Date(session.lastActivity).getTime();
2744
+ if (lastActivity < cutoff) {
2745
+ await this.deleteSession(session.sessionKey);
2746
+ deleted.push(session.sessionKey);
2747
+ }
2748
+ }
2749
+ return deleted;
2750
+ }
2751
+ // ============ Job Management ============
2752
+ /**
2753
+ * Create a new job for a session.
2754
+ */
2755
+ async createJob(sessionKey, params) {
2756
+ const jobId = randomUUID();
2757
+ const jobDir = this.jobsDir(sessionKey);
2758
+ await fs.mkdir(jobDir, { recursive: true });
2759
+ const outputFile = this.jobOutputFile(sessionKey, jobId);
2760
+ const job = {
2761
+ jobId,
2762
+ sessionKey,
2763
+ containerName: params.containerName,
2764
+ status: "pending",
2765
+ prompt: params.prompt,
2766
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2767
+ startedAt: null,
2768
+ completedAt: null,
2769
+ exitCode: null,
2770
+ errorType: null,
2771
+ errorMessage: null,
2772
+ outputFile,
2773
+ outputSize: 0,
2774
+ outputTruncated: false,
2775
+ metrics: null
2776
+ };
2777
+ await fs.writeFile(this.jobFile(sessionKey, jobId), JSON.stringify(job, null, 2));
2778
+ await fs.writeFile(outputFile, "");
2779
+ return job;
2780
+ }
2781
+ /**
2782
+ * Get a job by ID.
2783
+ */
2784
+ async getJob(sessionKey, jobId) {
2785
+ try {
2786
+ const data = await fs.readFile(this.jobFile(sessionKey, jobId), "utf-8");
2787
+ return JSON.parse(data);
2788
+ } catch (err) {
2789
+ if (err.code === "ENOENT") {
2790
+ return null;
2791
+ }
2792
+ throw err;
2793
+ }
2794
+ }
2795
+ /**
2796
+ * Update a job with partial fields.
2797
+ */
2798
+ async updateJob(sessionKey, jobId, updates) {
2799
+ const job = await this.getJob(sessionKey, jobId);
2800
+ if (!job) {
2801
+ throw new Error(`Job not found: ${jobId}`);
2802
+ }
2803
+ const updated = { ...job, ...updates };
2804
+ await fs.writeFile(this.jobFile(sessionKey, jobId), JSON.stringify(updated, null, 2));
2805
+ return updated;
2806
+ }
2807
+ /**
2808
+ * Get the active job for a session.
2809
+ */
2810
+ async getActiveJob(sessionKey) {
2811
+ const session = await this.getSession(sessionKey);
2812
+ if (!session?.activeJobId) {
2813
+ return null;
2814
+ }
2815
+ return this.getJob(sessionKey, session.activeJobId);
2816
+ }
2817
+ /**
2818
+ * Set the active job ID for a session.
2819
+ */
2820
+ async setActiveJob(sessionKey, jobId) {
2821
+ const session = await this.getSession(sessionKey);
2822
+ if (!session) {
2823
+ throw new Error(`Session not found: ${sessionKey}`);
2824
+ }
2825
+ session.activeJobId = jobId;
2826
+ session.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
2827
+ await fs.writeFile(this.sessionFile(sessionKey), JSON.stringify(session, null, 2));
2828
+ }
2829
+ /**
2830
+ * List all jobs for a session.
2831
+ */
2832
+ async listJobs(sessionKey) {
2833
+ const jobs = [];
2834
+ const jobDir = this.jobsDir(sessionKey);
2835
+ try {
2836
+ const entries = await fs.readdir(jobDir);
2837
+ for (const entry of entries) {
2838
+ if (!entry.endsWith(".json")) continue;
2839
+ const jobId = entry.slice(0, -5);
2840
+ const job = await this.getJob(sessionKey, jobId);
2841
+ if (job) {
2842
+ jobs.push(job);
2843
+ }
2844
+ }
2845
+ } catch (err) {
2846
+ if (err.code !== "ENOENT") {
2847
+ throw err;
2848
+ }
2849
+ }
2850
+ return jobs;
2851
+ }
2852
+ /**
2853
+ * Read job output with offset and limit support.
2854
+ */
2855
+ async readJobOutput(sessionKey, jobId, opts) {
2856
+ const job = await this.getJob(sessionKey, jobId);
2857
+ if (!job) {
2858
+ throw new Error(`Job not found: ${jobId}`);
2859
+ }
2860
+ const offset = opts?.offset ?? 0;
2861
+ const limit = opts?.limit ?? 65536;
2862
+ try {
2863
+ const stat2 = await fs.stat(job.outputFile);
2864
+ const totalSize = stat2.size;
2865
+ if (offset >= totalSize) {
2866
+ return { content: "", size: 0, totalSize, hasMore: false };
2867
+ }
2868
+ const handle = await fs.open(job.outputFile, "r");
2869
+ try {
2870
+ const buffer = Buffer.alloc(Math.min(limit, totalSize - offset));
2871
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, offset);
2872
+ return {
2873
+ content: buffer.toString("utf-8", 0, bytesRead),
2874
+ size: bytesRead,
2875
+ totalSize,
2876
+ hasMore: offset + bytesRead < totalSize
2877
+ };
2878
+ } finally {
2879
+ await handle.close();
2880
+ }
2881
+ } catch (err) {
2882
+ if (err.code === "ENOENT") {
2883
+ return { content: "", size: 0, totalSize: 0, hasMore: false };
2884
+ }
2885
+ throw err;
2886
+ }
2887
+ }
2888
+ /**
2889
+ * Append content to job output file.
2890
+ */
2891
+ async appendJobOutput(sessionKey, jobId, content) {
2892
+ const job = await this.getJob(sessionKey, jobId);
2893
+ if (!job) {
2894
+ throw new Error(`Job not found: ${jobId}`);
2895
+ }
2896
+ await fs.appendFile(job.outputFile, content);
2897
+ const stat2 = await fs.stat(job.outputFile);
2898
+ await this.updateJob(sessionKey, jobId, { outputSize: stat2.size });
2899
+ }
2900
+ };
2901
+
2902
+ // src/podman-runner.ts
2903
+ import { spawn } from "node:child_process";
2904
+ function isClaudeCodeOutput(value) {
2905
+ return typeof value === "object" && value !== null;
2906
+ }
2907
+ function isPodmanStatsOutput(value) {
2908
+ return typeof value === "object" && value !== null;
2909
+ }
2910
+ function isPodmanInspectOutput(value) {
2911
+ return typeof value === "object" && value !== null;
2912
+ }
2913
+ function isPodmanPsOutput(value) {
2914
+ return typeof value === "object" && value !== null;
2915
+ }
2916
+ var PodmanRunner = class {
2917
+ config;
2918
+ constructor(config) {
2919
+ this.config = config;
2920
+ }
2921
+ async runClaudeCode(params) {
2922
+ const containerName = `claude-${params.sessionKey.replace(/[^a-zA-Z0-9-]/g, "-")}`;
2923
+ await this.killContainer(params.sessionKey);
2924
+ const args = this.buildArgs(params, containerName);
2925
+ return this.execute(args, containerName);
2926
+ }
2927
+ buildArgs(params, containerName) {
2928
+ const resumeFlag = params.resumeSessionId ? `--resume '${params.resumeSessionId}'` : "";
2929
+ const escapedPrompt = params.prompt.replace(/'/g, "'\\''");
2930
+ const claudeCmd = `claude --print --dangerously-skip-permissions ${resumeFlag} -p '${escapedPrompt}' < /dev/null 2>&1`;
2931
+ const args = [
2932
+ "run",
2933
+ "--rm",
2934
+ "--name",
2935
+ containerName,
2936
+ "--network",
2937
+ this.config.network,
2938
+ "--cap-drop",
2939
+ "ALL"
2940
+ ];
2941
+ if (this.config.apparmorProfile) {
2942
+ args.push("--security-opt", `apparmor=${this.config.apparmorProfile}`);
2943
+ }
2944
+ args.push(
2945
+ "--memory",
2946
+ this.config.memory,
2947
+ "--cpus",
2948
+ this.config.cpus,
2949
+ "--pids-limit",
2950
+ "100",
2951
+ "--tmpfs",
2952
+ "/tmp:rw,noexec,nosuid,size=64m",
2953
+ // :U flag handles UID mapping for permissions
2954
+ "-v",
2955
+ `${params.claudeDir}:/home/claude/.claude:U`,
2956
+ "-v",
2957
+ `${params.workspaceDir}:/workspace:U`
2958
+ );
2959
+ if (params.apiKey) {
2960
+ args.push("-e", `ANTHROPIC_API_KEY=${params.apiKey}`);
2961
+ }
2962
+ args.push("-w", "/workspace", "--entrypoint", "/bin/bash", this.config.image, "-c", claudeCmd);
2963
+ return args;
2964
+ }
2965
+ execute(args, containerName) {
2966
+ return new Promise((resolve, reject) => {
2967
+ const startTime = Date.now();
2968
+ const proc = spawn(this.config.runtime, args, {
2969
+ stdio: ["ignore", "pipe", "pipe"]
2970
+ });
2971
+ let stdout = "";
2972
+ let stderr = "";
2973
+ let killed = false;
2974
+ let killReason = null;
2975
+ let lastActivity = Date.now();
2976
+ let hadOutput = false;
2977
+ let totalOutputSize = 0;
2978
+ let outputTruncated = false;
2979
+ const maxSize = this.config.maxOutputSize;
2980
+ let lastMetrics;
2981
+ const cleanup = () => {
2982
+ clearTimeout(startupTimeoutId);
2983
+ clearInterval(idleCheckInterval);
2984
+ clearInterval(metricsInterval);
2985
+ };
2986
+ const killProcess = (reason) => {
2987
+ if (killed) return;
2988
+ killed = true;
2989
+ killReason = reason;
2990
+ cleanup();
2991
+ proc.kill("SIGTERM");
2992
+ setTimeout(() => {
2993
+ if (!proc.killed) {
2994
+ proc.kill("SIGKILL");
2995
+ }
2996
+ }, 5e3);
2997
+ };
2998
+ const startupTimeoutId = setTimeout(() => {
2999
+ if (!hadOutput) {
3000
+ killProcess("startup_timeout");
3001
+ }
3002
+ }, this.config.startupTimeout * 1e3);
3003
+ const idleCheckInterval = setInterval(() => {
3004
+ if (!hadOutput) return;
3005
+ const idleSeconds = (Date.now() - lastActivity) / 1e3;
3006
+ if (idleSeconds > this.config.idleTimeout) {
3007
+ killProcess("idle_timeout");
3008
+ }
3009
+ }, 5e3);
3010
+ const metricsInterval = setInterval(() => {
3011
+ if (!hadOutput) return;
3012
+ void this.getContainerStats(containerName).then((metrics) => {
3013
+ if (metrics) {
3014
+ lastMetrics = metrics;
3015
+ }
3016
+ });
3017
+ }, 1e4);
3018
+ const onOutput = () => {
3019
+ if (!hadOutput) {
3020
+ hadOutput = true;
3021
+ clearTimeout(startupTimeoutId);
3022
+ }
3023
+ lastActivity = Date.now();
3024
+ };
3025
+ proc.stdout.on("data", (data) => {
3026
+ onOutput();
3027
+ const dataStr = data.toString();
3028
+ if (maxSize > 0 && totalOutputSize + dataStr.length > maxSize) {
3029
+ if (!outputTruncated) {
3030
+ const remaining = maxSize - totalOutputSize;
3031
+ stdout += dataStr.slice(0, remaining);
3032
+ outputTruncated = true;
3033
+ }
3034
+ totalOutputSize += dataStr.length;
3035
+ } else {
3036
+ stdout += dataStr;
3037
+ totalOutputSize += dataStr.length;
3038
+ }
3039
+ });
3040
+ proc.stderr.on("data", (data) => {
3041
+ onOutput();
3042
+ const dataStr = data.toString();
3043
+ if (maxSize > 0 && totalOutputSize + dataStr.length > maxSize) {
3044
+ if (!outputTruncated) {
3045
+ const remaining = maxSize - totalOutputSize;
3046
+ stderr += dataStr.slice(0, remaining);
3047
+ outputTruncated = true;
3048
+ }
3049
+ totalOutputSize += dataStr.length;
3050
+ } else {
3051
+ stderr += dataStr;
3052
+ totalOutputSize += dataStr.length;
3053
+ }
3054
+ });
3055
+ proc.on("error", (err) => {
3056
+ cleanup();
3057
+ const elapsed = (Date.now() - startTime) / 1e3;
3058
+ reject(
3059
+ Object.assign(new Error(`Failed to spawn ${this.config.runtime}: ${err.message}`), {
3060
+ errorType: "spawn_failed",
3061
+ elapsedSeconds: elapsed
3062
+ })
3063
+ );
3064
+ });
3065
+ proc.on("close", (code, signal) => {
3066
+ cleanup();
3067
+ const elapsed = (Date.now() - startTime) / 1e3;
3068
+ if (killed && killReason) {
3069
+ const message = killReason === "startup_timeout" ? `Container startup timeout (no output for ${String(this.config.startupTimeout)}s)` : `Container idle timeout (no output for ${String(this.config.idleTimeout)}s) after ${elapsed.toFixed(1)}s total`;
3070
+ reject(
3071
+ Object.assign(new Error(message), {
3072
+ errorType: killReason,
3073
+ elapsedSeconds: elapsed
3074
+ })
3075
+ );
3076
+ return;
3077
+ }
3078
+ if (signal === "SIGKILL" || code === 137) {
3079
+ reject(
3080
+ Object.assign(
3081
+ new Error(
3082
+ `Container killed (OOM or resource limit) after ${elapsed.toFixed(1)}s: ${stderr || stdout}`
3083
+ ),
3084
+ { errorType: "oom", elapsedSeconds: elapsed }
3085
+ )
3086
+ );
3087
+ return;
3088
+ }
3089
+ if (code !== 0) {
3090
+ reject(
3091
+ Object.assign(
3092
+ new Error(
3093
+ `Container failed (exit ${String(code)}) after ${elapsed.toFixed(1)}s: ${stderr || stdout}`
3094
+ ),
3095
+ { errorType: "crash", elapsedSeconds: elapsed }
3096
+ )
3097
+ );
3098
+ return;
3099
+ }
3100
+ const result = this.parseOutput(stdout, code);
3101
+ result.elapsedSeconds = elapsed;
3102
+ if (outputTruncated) {
3103
+ result.outputTruncated = true;
3104
+ result.originalSize = totalOutputSize;
3105
+ }
3106
+ if (lastMetrics) {
3107
+ result.metrics = lastMetrics;
3108
+ }
3109
+ resolve(result);
3110
+ });
3111
+ });
3112
+ }
3113
+ parseOutput(output, exitCode) {
3114
+ try {
3115
+ const lines = output.trim().split("\n");
3116
+ for (let i = lines.length - 1; i >= 0; i--) {
3117
+ const line = lines[i].trim();
3118
+ if (line.startsWith("{") && line.endsWith("}")) {
3119
+ const parsed = JSON.parse(line);
3120
+ if (isClaudeCodeOutput(parsed)) {
3121
+ return {
3122
+ content: parsed.result ?? parsed.content ?? parsed.message ?? output,
3123
+ sessionId: parsed.session_id ?? parsed.sessionId ?? null,
3124
+ exitCode
3125
+ };
3126
+ }
3127
+ }
3128
+ }
3129
+ } catch {
3130
+ }
3131
+ return {
3132
+ content: output.trim(),
3133
+ sessionId: null,
3134
+ exitCode
3135
+ };
3136
+ }
3137
+ async checkImage() {
3138
+ return new Promise((resolve) => {
3139
+ const proc = spawn(this.config.runtime, ["image", "exists", this.config.image], {
3140
+ stdio: "ignore"
3141
+ });
3142
+ proc.on("error", () => resolve(false));
3143
+ proc.on("close", (code) => resolve(code === 0));
3144
+ });
3145
+ }
3146
+ async killContainer(sessionKey) {
3147
+ const containerName = `claude-${sessionKey.replace(/[^a-zA-Z0-9-]/g, "-")}`;
3148
+ await new Promise((resolve) => {
3149
+ const proc = spawn(this.config.runtime, ["kill", containerName], {
3150
+ stdio: "ignore"
3151
+ });
3152
+ proc.on("error", () => resolve());
3153
+ proc.on("close", () => resolve());
3154
+ });
3155
+ await new Promise((resolve) => {
3156
+ const proc = spawn(this.config.runtime, ["rm", "-f", containerName], {
3157
+ stdio: "ignore"
3158
+ });
3159
+ proc.on("error", () => resolve());
3160
+ proc.on("close", () => resolve());
3161
+ });
3162
+ }
3163
+ async verifyContainerRunning(containerName, retries = 3) {
3164
+ for (let i = 0; i < retries; i++) {
3165
+ await new Promise((r) => setTimeout(r, 500));
3166
+ const exists = await new Promise((resolve) => {
3167
+ const proc = spawn(this.config.runtime, ["container", "exists", containerName], {
3168
+ stdio: "ignore"
3169
+ });
3170
+ proc.on("close", (code) => resolve(code === 0));
3171
+ proc.on("error", () => resolve(false));
3172
+ });
3173
+ if (exists) return true;
3174
+ }
3175
+ return false;
3176
+ }
3177
+ /**
3178
+ * Get resource metrics for a running container.
3179
+ * Returns undefined if container is not running or stats unavailable.
3180
+ */
3181
+ getContainerStats(containerName) {
3182
+ return new Promise((resolve) => {
3183
+ const proc = spawn(
3184
+ this.config.runtime,
3185
+ ["stats", "--no-stream", "--format", "json", containerName],
3186
+ { stdio: ["ignore", "pipe", "ignore"] }
3187
+ );
3188
+ let stdout = "";
3189
+ let timeoutId = null;
3190
+ proc.stdout.on("data", (data) => {
3191
+ stdout += data.toString();
3192
+ });
3193
+ proc.on("error", () => resolve(void 0));
3194
+ proc.on("close", (code) => {
3195
+ if (timeoutId) clearTimeout(timeoutId);
3196
+ if (code !== 0) {
3197
+ resolve(void 0);
3198
+ return;
3199
+ }
3200
+ try {
3201
+ const stats = JSON.parse(stdout);
3202
+ const statArray = Array.isArray(stats) ? stats : [stats];
3203
+ const stat2 = statArray[0];
3204
+ if (!isPodmanStatsOutput(stat2)) {
3205
+ resolve(void 0);
3206
+ return;
3207
+ }
3208
+ const memUsage = this.parseMemoryString(stat2.MemUsage ?? stat2.mem_usage);
3209
+ const memLimit = this.parseMemoryString(stat2.MemLimit ?? stat2.mem_limit);
3210
+ resolve({
3211
+ memoryUsageMB: memUsage,
3212
+ memoryLimitMB: memLimit,
3213
+ memoryPercent: stat2.MemPerc ? parseFloat(String(stat2.MemPerc).replace("%", "")) : void 0,
3214
+ cpuPercent: stat2.CPUPerc ? parseFloat(String(stat2.CPUPerc).replace("%", "")) : void 0
3215
+ });
3216
+ } catch {
3217
+ resolve(void 0);
3218
+ }
3219
+ });
3220
+ timeoutId = setTimeout(() => {
3221
+ proc.kill();
3222
+ resolve(void 0);
3223
+ }, 5e3);
3224
+ });
3225
+ }
3226
+ /**
3227
+ * Parse memory string like "123.4MiB" or "1.2GiB" to MB
3228
+ */
3229
+ parseMemoryString(memStr) {
3230
+ if (!memStr) return void 0;
3231
+ const parts = memStr.split("/");
3232
+ const valueStr = parts[0].trim();
3233
+ const match = /^([\d.]+)\s*(B|KB|KiB|MB|MiB|GB|GiB)/i.exec(valueStr);
3234
+ if (!match) return void 0;
3235
+ const value = parseFloat(match[1]);
3236
+ const unit = match[2].toLowerCase();
3237
+ switch (unit) {
3238
+ case "b":
3239
+ return value / (1024 * 1024);
3240
+ case "kb":
3241
+ case "kib":
3242
+ return value / 1024;
3243
+ case "mb":
3244
+ case "mib":
3245
+ return value;
3246
+ case "gb":
3247
+ case "gib":
3248
+ return value * 1024;
3249
+ default:
3250
+ return void 0;
3251
+ }
3252
+ }
3253
+ /**
3254
+ * Start a container in detached mode. Returns immediately with container ID.
3255
+ */
3256
+ async startDetached(params) {
3257
+ const containerName = `claude-${params.sessionKey.replace(/[^a-zA-Z0-9-]/g, "-")}`;
3258
+ await this.killContainer(params.sessionKey);
3259
+ const resumeFlag = params.resumeSessionId ? `--resume '${params.resumeSessionId}'` : "";
3260
+ const escapedPrompt = params.prompt.replace(/'/g, "'\\''");
3261
+ const claudeCmd = `claude --print --dangerously-skip-permissions ${resumeFlag} -p '${escapedPrompt}' < /dev/null 2>&1`;
3262
+ const args = [
3263
+ "run",
3264
+ "--detach",
3265
+ "--name",
3266
+ containerName,
3267
+ "--network",
3268
+ this.config.network,
3269
+ "--cap-drop",
3270
+ "ALL"
3271
+ ];
3272
+ if (this.config.apparmorProfile) {
3273
+ args.push("--security-opt", `apparmor=${this.config.apparmorProfile}`);
3274
+ }
3275
+ args.push(
3276
+ "--memory",
3277
+ this.config.memory,
3278
+ "--cpus",
3279
+ this.config.cpus,
3280
+ "--pids-limit",
3281
+ "100",
3282
+ "--tmpfs",
3283
+ "/tmp:rw,noexec,nosuid,size=64m",
3284
+ "-v",
3285
+ `${params.claudeDir}:/home/claude/.claude:U`,
3286
+ "-v",
3287
+ `${params.workspaceDir}:/workspace:U`
3288
+ );
3289
+ if (params.apiKey) {
3290
+ args.push("-e", `ANTHROPIC_API_KEY=${params.apiKey}`);
3291
+ }
3292
+ args.push("-w", "/workspace", "--entrypoint", "/bin/bash", this.config.image, "-c", claudeCmd);
3293
+ return new Promise((resolve, reject) => {
3294
+ const proc = spawn(this.config.runtime, args, {
3295
+ stdio: ["ignore", "pipe", "pipe"]
3296
+ });
3297
+ let stdout = "";
3298
+ let stderr = "";
3299
+ proc.stdout.on("data", (data) => {
3300
+ stdout += data.toString();
3301
+ });
3302
+ proc.stderr.on("data", (data) => {
3303
+ stderr += data.toString();
3304
+ });
3305
+ proc.on("error", (err) => {
3306
+ reject(new Error(`Failed to spawn ${this.config.runtime}: ${err.message}`));
3307
+ });
3308
+ proc.on("close", (code) => {
3309
+ if (code !== 0) {
3310
+ reject(new Error(`Failed to start container: ${stderr || stdout}`));
3311
+ return;
3312
+ }
3313
+ const containerId = stdout.trim();
3314
+ resolve({ containerName, containerId });
3315
+ });
3316
+ });
3317
+ }
3318
+ /**
3319
+ * Get the status of a container by name.
3320
+ */
3321
+ async getContainerStatus(containerName) {
3322
+ return new Promise((resolve) => {
3323
+ const proc = spawn(this.config.runtime, ["inspect", "--format", "json", containerName], {
3324
+ stdio: ["ignore", "pipe", "ignore"]
3325
+ });
3326
+ let stdout = "";
3327
+ proc.stdout.on("data", (data) => {
3328
+ stdout += data.toString();
3329
+ });
3330
+ proc.on("error", () => resolve(null));
3331
+ proc.on("close", (code) => {
3332
+ if (code !== 0) {
3333
+ resolve(null);
3334
+ return;
3335
+ }
3336
+ try {
3337
+ const parsed = JSON.parse(stdout);
3338
+ const inspectArray = Array.isArray(parsed) ? parsed : [parsed];
3339
+ const inspect = inspectArray[0];
3340
+ if (!isPodmanInspectOutput(inspect) || !inspect.State) {
3341
+ resolve(null);
3342
+ return;
3343
+ }
3344
+ const state = inspect.State;
3345
+ resolve({
3346
+ running: state.Running ?? false,
3347
+ exitCode: state.ExitCode ?? null,
3348
+ startedAt: state.StartedAt ?? null,
3349
+ finishedAt: state.FinishedAt ?? null
3350
+ });
3351
+ } catch {
3352
+ resolve(null);
3353
+ }
3354
+ });
3355
+ });
3356
+ }
3357
+ /**
3358
+ * Get logs from a container.
3359
+ */
3360
+ async getContainerLogs(containerName, opts) {
3361
+ return new Promise((resolve) => {
3362
+ const args = ["logs"];
3363
+ if (opts?.since) {
3364
+ args.push("--since", opts.since);
3365
+ }
3366
+ if (opts?.tail !== void 0) {
3367
+ args.push("--tail", String(opts.tail));
3368
+ }
3369
+ args.push(containerName);
3370
+ const proc = spawn(this.config.runtime, args, {
3371
+ stdio: ["ignore", "pipe", "pipe"]
3372
+ });
3373
+ let output = "";
3374
+ proc.stdout.on("data", (data) => {
3375
+ output += data.toString();
3376
+ });
3377
+ proc.stderr.on("data", (data) => {
3378
+ output += data.toString();
3379
+ });
3380
+ proc.on("error", () => resolve(null));
3381
+ proc.on("close", (code) => {
3382
+ if (code !== 0) {
3383
+ resolve(null);
3384
+ return;
3385
+ }
3386
+ resolve(output);
3387
+ });
3388
+ });
3389
+ }
3390
+ /**
3391
+ * List all containers matching a name prefix.
3392
+ */
3393
+ async listContainersByPrefix(prefix) {
3394
+ return new Promise((resolve) => {
3395
+ const proc = spawn(
3396
+ this.config.runtime,
3397
+ ["ps", "-a", "--filter", `name=^${prefix}`, "--format", "json"],
3398
+ { stdio: ["ignore", "pipe", "ignore"] }
3399
+ );
3400
+ let stdout = "";
3401
+ proc.stdout.on("data", (data) => {
3402
+ stdout += data.toString();
3403
+ });
3404
+ proc.on("error", () => resolve([]));
3405
+ proc.on("close", (code) => {
3406
+ if (code !== 0) {
3407
+ resolve([]);
3408
+ return;
3409
+ }
3410
+ try {
3411
+ const lines = stdout.trim().split("\n").filter(Boolean);
3412
+ const containers = [];
3413
+ for (const line of lines) {
3414
+ const parsed = JSON.parse(line);
3415
+ if (!isPodmanPsOutput(parsed)) continue;
3416
+ const name = Array.isArray(parsed.Names) ? parsed.Names[0] : parsed.Names;
3417
+ if (!name) continue;
3418
+ const running = parsed.State === "running" || typeof parsed.Status === "string" && parsed.Status.startsWith("Up");
3419
+ containers.push({
3420
+ name,
3421
+ running,
3422
+ createdAt: parsed.Created ?? parsed.CreatedAt ?? ""
3423
+ });
3424
+ }
3425
+ resolve(containers);
3426
+ } catch {
3427
+ resolve([]);
3428
+ }
3429
+ });
3430
+ });
3431
+ }
3432
+ /**
3433
+ * Generate container name from session key.
3434
+ */
3435
+ containerNameFromSessionKey(sessionKey) {
3436
+ return `claude-${sessionKey.replace(/[^a-zA-Z0-9-]/g, "-")}`;
3437
+ }
3438
+ /**
3439
+ * Extract session key from container name.
3440
+ */
3441
+ sessionKeyFromContainerName(containerName) {
3442
+ if (!containerName.startsWith("claude-")) {
3443
+ return null;
3444
+ }
3445
+ return containerName.slice(7);
3446
+ }
3447
+ };
3448
+
3449
+ // src/claude-code.ts
3450
+ var DEFAULT_CONFIG = {
3451
+ image: "ghcr.io/13rac1/openclaw-claude-code:latest",
3452
+ runtime: "podman",
3453
+ startupTimeout: 30,
3454
+ // Container must produce output within 30s
3455
+ idleTimeout: 120,
3456
+ // Container silent for 120s = hung
3457
+ memory: "512m",
3458
+ cpus: "1.0",
3459
+ network: "bridge",
3460
+ // Needs network for Anthropic API access
3461
+ sessionsDir: "~/.openclaw/claude-sessions",
3462
+ workspacesDir: "~/.openclaw/workspaces",
3463
+ sessionIdleTimeout: 3600,
3464
+ // Clean up sessions after 1hr idle
3465
+ apparmorProfile: "",
3466
+ // Disabled by default
3467
+ maxOutputSize: 10 * 1024 * 1024
3468
+ // 10MB default
3469
+ };
3470
+ function formatDuration(ms) {
3471
+ const seconds = Math.floor(ms / 1e3);
3472
+ const minutes = Math.floor(seconds / 60);
3473
+ const hours = Math.floor(minutes / 60);
3474
+ const days = Math.floor(hours / 24);
3475
+ if (days > 0) {
3476
+ return `${String(days)}d ${String(hours % 24)}h`;
3477
+ }
3478
+ if (hours > 0) {
3479
+ return `${String(hours)}h ${String(minutes % 60)}m`;
3480
+ }
3481
+ if (minutes > 0) {
3482
+ return `${String(minutes)}m ${String(seconds % 60)}s`;
3483
+ }
3484
+ return `${String(seconds)}s`;
3485
+ }
3486
+ function register(api) {
3487
+ const pluginConfig = api.config;
3488
+ const config = {
3489
+ ...DEFAULT_CONFIG,
3490
+ ...pluginConfig
3491
+ };
3492
+ const sessionManager = new SessionManager({
3493
+ sessionsDir: config.sessionsDir,
3494
+ workspacesDir: config.workspacesDir,
3495
+ idleTimeout: config.sessionIdleTimeout
3496
+ });
3497
+ const podmanRunner = new PodmanRunner({
3498
+ runtime: config.runtime,
3499
+ image: config.image,
3500
+ startupTimeout: config.startupTimeout,
3501
+ idleTimeout: config.idleTimeout,
3502
+ memory: config.memory,
3503
+ cpus: config.cpus,
3504
+ network: config.network,
3505
+ apparmorProfile: config.apparmorProfile,
3506
+ maxOutputSize: config.maxOutputSize
3507
+ });
3508
+ async function getAuth() {
3509
+ const hostCredsPath = path2.join(homedir2(), ".claude", ".credentials.json");
3510
+ let hasCredsFile = false;
3511
+ try {
3512
+ await fs2.access(hostCredsPath);
3513
+ hasCredsFile = true;
3514
+ } catch {
3515
+ }
3516
+ const apiKey = hasCredsFile ? void 0 : process.env.ANTHROPIC_API_KEY;
3517
+ if (!apiKey && !hasCredsFile) {
3518
+ throw new Error(
3519
+ "No authentication available. Set ANTHROPIC_API_KEY or have ~/.claude/.credentials.json"
3520
+ );
3521
+ }
3522
+ return { apiKey, hasCredsFile };
3523
+ }
3524
+ async function copyCredentials(claudeDir) {
3525
+ const hostCredsPath = path2.join(homedir2(), ".claude", ".credentials.json");
3526
+ const sessionCredsPath = path2.join(claudeDir, ".credentials.json");
3527
+ try {
3528
+ await fs2.mkdir(claudeDir, { recursive: true });
3529
+ await fs2.copyFile(hostCredsPath, sessionCredsPath);
3530
+ } catch (err) {
3531
+ const message = err instanceof Error ? err.message : String(err);
3532
+ throw new Error(`Failed to copy credentials file: ${message}`);
3533
+ }
3534
+ }
3535
+ api.registerTool({
3536
+ name: "claude_code_start",
3537
+ description: "Start a Claude Code task in the background. Returns a job ID immediately. Use claude_code_status to check progress and claude_code_output to read results.",
3538
+ parameters: Type.Object({
3539
+ prompt: Type.String({ description: "The prompt or task to send to Claude Code" }),
3540
+ session_id: Type.Optional(
3541
+ Type.String({ description: "Optional session ID to continue a previous session" })
3542
+ )
3543
+ }),
3544
+ async execute(id, params) {
3545
+ const prompt = params.prompt;
3546
+ if (!prompt) {
3547
+ throw new Error("prompt parameter is required");
3548
+ }
3549
+ const sessionKey = params.session_id ?? `session-${id}`;
3550
+ const { apiKey, hasCredsFile } = await getAuth();
3551
+ const imageExists = await podmanRunner.checkImage();
3552
+ if (!imageExists) {
3553
+ throw new Error(
3554
+ `Container image not found: ${config.image}. Build it with: podman build -t ${config.image} .`
3555
+ );
3556
+ }
3557
+ const session = await sessionManager.getOrCreateSession(sessionKey);
3558
+ const activeJob = await sessionManager.getActiveJob(sessionKey);
3559
+ if (activeJob && (activeJob.status === "pending" || activeJob.status === "running")) {
3560
+ throw new Error(
3561
+ `Session already has an active job: ${activeJob.jobId} (status: ${activeJob.status})`
3562
+ );
3563
+ }
3564
+ const claudeDir = `${config.sessionsDir.replace("~", process.env.HOME ?? "")}/${sessionKey}/.claude`;
3565
+ const workspaceDir = sessionManager.workspaceDir(sessionKey);
3566
+ if (hasCredsFile) {
3567
+ await copyCredentials(claudeDir);
3568
+ }
3569
+ const containerName = podmanRunner.containerNameFromSessionKey(sessionKey);
3570
+ const job = await sessionManager.createJob(sessionKey, { prompt, containerName });
3571
+ try {
3572
+ await podmanRunner.startDetached({
3573
+ sessionKey,
3574
+ prompt,
3575
+ claudeDir,
3576
+ workspaceDir,
3577
+ resumeSessionId: session.claudeSessionId ?? void 0,
3578
+ apiKey
3579
+ });
3580
+ await sessionManager.updateJob(sessionKey, job.jobId, {
3581
+ status: "running",
3582
+ startedAt: (/* @__PURE__ */ new Date()).toISOString()
3583
+ });
3584
+ await sessionManager.setActiveJob(sessionKey, job.jobId);
3585
+ return {
3586
+ content: [
3587
+ {
3588
+ type: "text",
3589
+ text: JSON.stringify(
3590
+ {
3591
+ jobId: job.jobId,
3592
+ sessionKey,
3593
+ status: "running",
3594
+ message: "Job started. Use claude_code_status to check progress."
3595
+ },
3596
+ null,
3597
+ 2
3598
+ )
3599
+ }
3600
+ ]
3601
+ };
3602
+ } catch (err) {
3603
+ const message = err instanceof Error ? err.message : String(err);
3604
+ await sessionManager.updateJob(sessionKey, job.jobId, {
3605
+ status: "failed",
3606
+ completedAt: (/* @__PURE__ */ new Date()).toISOString(),
3607
+ errorMessage: message
3608
+ });
3609
+ throw err;
3610
+ }
3611
+ }
3612
+ });
3613
+ api.registerTool({
3614
+ name: "claude_code_status",
3615
+ description: "Check the status of a Claude Code job. Returns status, elapsed time, output size, and metrics.",
3616
+ parameters: Type.Object({
3617
+ job_id: Type.String({ description: "The job ID to check" }),
3618
+ session_id: Type.Optional(
3619
+ Type.String({ description: "Session ID (if job was started with one)" })
3620
+ )
3621
+ }),
3622
+ async execute(id, params) {
3623
+ const jobId = params.job_id;
3624
+ if (!jobId) {
3625
+ throw new Error("job_id parameter is required");
3626
+ }
3627
+ let sessionKey = params.session_id;
3628
+ let job = sessionKey ? await sessionManager.getJob(sessionKey, jobId) : null;
3629
+ if (!job) {
3630
+ const sessions = await sessionManager.listSessions();
3631
+ for (const session of sessions) {
3632
+ job = await sessionManager.getJob(session.sessionKey, jobId);
3633
+ if (job) {
3634
+ sessionKey = session.sessionKey;
3635
+ break;
3636
+ }
3637
+ }
3638
+ }
3639
+ if (!job || !sessionKey) {
3640
+ throw new Error(`Job not found: ${jobId}`);
3641
+ }
3642
+ if (job.status === "running") {
3643
+ const containerStatus = await podmanRunner.getContainerStatus(job.containerName);
3644
+ if (containerStatus && !containerStatus.running) {
3645
+ const logs = await podmanRunner.getContainerLogs(job.containerName);
3646
+ if (logs) {
3647
+ await sessionManager.appendJobOutput(sessionKey, jobId, logs);
3648
+ }
3649
+ const status = containerStatus.exitCode === 0 ? "completed" : "failed";
3650
+ job = await sessionManager.updateJob(sessionKey, jobId, {
3651
+ status,
3652
+ completedAt: containerStatus.finishedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3653
+ exitCode: containerStatus.exitCode,
3654
+ errorType: containerStatus.exitCode === 137 ? "oom" : containerStatus.exitCode !== 0 ? "crash" : null
3655
+ });
3656
+ await sessionManager.setActiveJob(sessionKey, null);
3657
+ await podmanRunner.killContainer(sessionKey);
3658
+ } else if (containerStatus) {
3659
+ const logs = await podmanRunner.getContainerLogs(job.containerName);
3660
+ if (logs) {
3661
+ await sessionManager.appendJobOutput(sessionKey, jobId, logs);
3662
+ }
3663
+ const metrics = await podmanRunner.getContainerStats(job.containerName);
3664
+ if (metrics) {
3665
+ await sessionManager.updateJob(sessionKey, jobId, { metrics });
3666
+ job.metrics = metrics;
3667
+ }
3668
+ }
3669
+ }
3670
+ const startTime = job.startedAt ? new Date(job.startedAt).getTime() : new Date(job.createdAt).getTime();
3671
+ const endTime = job.completedAt ? new Date(job.completedAt).getTime() : Date.now();
3672
+ const elapsedSeconds = (endTime - startTime) / 1e3;
3673
+ const outputResult = await sessionManager.readJobOutput(sessionKey, jobId, {
3674
+ offset: 0,
3675
+ limit: 0
3676
+ });
3677
+ const response = {
3678
+ jobId: job.jobId,
3679
+ sessionKey,
3680
+ status: job.status,
3681
+ elapsedSeconds: Math.round(elapsedSeconds * 10) / 10,
3682
+ outputSize: outputResult.totalSize,
3683
+ exitCode: job.exitCode,
3684
+ error: job.errorMessage,
3685
+ metrics: job.metrics
3686
+ };
3687
+ return {
3688
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }]
3689
+ };
3690
+ }
3691
+ });
3692
+ api.registerTool({
3693
+ name: "claude_code_output",
3694
+ description: "Read output from a Claude Code job. Supports reading partial output while job is running.",
3695
+ parameters: Type.Object({
3696
+ job_id: Type.String({ description: "The job ID" }),
3697
+ session_id: Type.Optional(Type.String({ description: "Session ID" })),
3698
+ offset: Type.Optional(
3699
+ Type.Number({ description: "Byte offset to start reading from (default: 0)" })
3700
+ ),
3701
+ limit: Type.Optional(Type.Number({ description: "Maximum bytes to read (default: 64KB)" }))
3702
+ }),
3703
+ async execute(id, params) {
3704
+ const jobId = params.job_id;
3705
+ if (!jobId) {
3706
+ throw new Error("job_id parameter is required");
3707
+ }
3708
+ let sessionKey = params.session_id;
3709
+ let job = sessionKey ? await sessionManager.getJob(sessionKey, jobId) : null;
3710
+ if (!job) {
3711
+ const sessions = await sessionManager.listSessions();
3712
+ for (const session of sessions) {
3713
+ job = await sessionManager.getJob(session.sessionKey, jobId);
3714
+ if (job) {
3715
+ sessionKey = session.sessionKey;
3716
+ break;
3717
+ }
3718
+ }
3719
+ }
3720
+ if (!job || !sessionKey) {
3721
+ throw new Error(`Job not found: ${jobId}`);
3722
+ }
3723
+ if (job.status === "running") {
3724
+ const logs = await podmanRunner.getContainerLogs(job.containerName);
3725
+ if (logs) {
3726
+ await sessionManager.appendJobOutput(sessionKey, jobId, logs);
3727
+ }
3728
+ }
3729
+ const offset = params.offset ?? 0;
3730
+ const limit = params.limit ?? 65536;
3731
+ const result = await sessionManager.readJobOutput(sessionKey, jobId, { offset, limit });
3732
+ const header = `[job: ${jobId}] [status: ${job.status}] [bytes ${String(offset)}-${String(offset + result.size)} of ${String(result.totalSize)}]${result.hasMore ? " [more available]" : ""}`;
3733
+ return {
3734
+ content: [{ type: "text", text: `${header}
3735
+
3736
+ ${result.content}` }]
3737
+ };
3738
+ }
3739
+ });
3740
+ api.registerTool({
3741
+ name: "claude_code_cancel",
3742
+ description: "Cancel a running Claude Code job.",
3743
+ parameters: Type.Object({
3744
+ job_id: Type.String({ description: "The job ID to cancel" }),
3745
+ session_id: Type.Optional(Type.String({ description: "Session ID" }))
3746
+ }),
3747
+ async execute(id, params) {
3748
+ const jobId = params.job_id;
3749
+ if (!jobId) {
3750
+ throw new Error("job_id parameter is required");
3751
+ }
3752
+ let sessionKey = params.session_id;
3753
+ let job = sessionKey ? await sessionManager.getJob(sessionKey, jobId) : null;
3754
+ if (!job) {
3755
+ const sessions = await sessionManager.listSessions();
3756
+ for (const session of sessions) {
3757
+ job = await sessionManager.getJob(session.sessionKey, jobId);
3758
+ if (job) {
3759
+ sessionKey = session.sessionKey;
3760
+ break;
3761
+ }
3762
+ }
3763
+ }
3764
+ if (!job || !sessionKey) {
3765
+ throw new Error(`Job not found: ${jobId}`);
3766
+ }
3767
+ if (job.status !== "running" && job.status !== "pending") {
3768
+ return {
3769
+ content: [
3770
+ { type: "text", text: `Job ${jobId} is already ${job.status}, cannot cancel.` }
3771
+ ]
3772
+ };
3773
+ }
3774
+ await podmanRunner.killContainer(sessionKey);
3775
+ await sessionManager.updateJob(sessionKey, jobId, {
3776
+ status: "cancelled",
3777
+ completedAt: (/* @__PURE__ */ new Date()).toISOString()
3778
+ });
3779
+ await sessionManager.setActiveJob(sessionKey, null);
3780
+ return {
3781
+ content: [{ type: "text", text: `Job ${jobId} cancelled.` }]
3782
+ };
3783
+ }
3784
+ });
3785
+ api.registerTool({
3786
+ name: "claude_code_cleanup",
3787
+ description: "Clean up idle Claude Code sessions. Removes sessions that have been inactive longer than the configured timeout.",
3788
+ parameters: Type.Object({}),
3789
+ async execute() {
3790
+ const deleted = await sessionManager.cleanupIdleSessions();
3791
+ const text = deleted.length === 0 ? "No idle sessions to clean up." : `Cleaned up ${String(deleted.length)} idle session(s): ${deleted.join(", ")}`;
3792
+ return {
3793
+ content: [{ type: "text", text }]
3794
+ };
3795
+ }
3796
+ });
3797
+ api.registerTool({
3798
+ name: "claude_code_sessions",
3799
+ description: "List all active Claude Code sessions with their age, message count, and active jobs. Useful for understanding which sessions exist before resuming or cleaning up.",
3800
+ parameters: Type.Object({}),
3801
+ async execute() {
3802
+ const sessions = await sessionManager.listSessions();
3803
+ if (sessions.length === 0) {
3804
+ return {
3805
+ content: [{ type: "text", text: "No active sessions." }]
3806
+ };
3807
+ }
3808
+ const now = Date.now();
3809
+ const lines = await Promise.all(
3810
+ sessions.map(async (session) => {
3811
+ const ageMs = now - new Date(session.createdAt).getTime();
3812
+ const ageFormatted = formatDuration(ageMs);
3813
+ const lastActiveMs = now - new Date(session.lastActivity).getTime();
3814
+ const lastActiveFormatted = formatDuration(lastActiveMs);
3815
+ const parts = [
3816
+ `Session: ${session.sessionKey}`,
3817
+ ` Age: ${ageFormatted}`,
3818
+ ` Last Active: ${lastActiveFormatted} ago`,
3819
+ ` Messages: ${String(session.messageCount)}`
3820
+ ];
3821
+ if (session.activeJobId) {
3822
+ const activeJob = await sessionManager.getJob(session.sessionKey, session.activeJobId);
3823
+ if (activeJob) {
3824
+ parts.push(` Active Job: ${activeJob.jobId} (${activeJob.status})`);
3825
+ }
3826
+ }
3827
+ if (session.claudeSessionId) {
3828
+ parts.push(` Claude Session: ${session.claudeSessionId}`);
3829
+ }
3830
+ return parts.join("\n");
3831
+ })
3832
+ );
3833
+ const text = `Found ${String(sessions.length)} session(s):
3834
+
3835
+ ${lines.join("\n\n")}`;
3836
+ return {
3837
+ content: [{ type: "text", text }]
3838
+ };
3839
+ }
3840
+ });
3841
+ void recoverOrphanedJobs(sessionManager, podmanRunner);
3842
+ }
3843
+ async function recoverOrphanedJobs(sessionManager, podmanRunner) {
3844
+ try {
3845
+ const containers = await podmanRunner.listContainersByPrefix("claude-");
3846
+ for (const container of containers) {
3847
+ const sessionKey = podmanRunner.sessionKeyFromContainerName(container.name);
3848
+ if (!sessionKey) continue;
3849
+ const activeJob = await sessionManager.getActiveJob(sessionKey);
3850
+ if (activeJob?.containerName === container.name) {
3851
+ if (!container.running) {
3852
+ const status = await podmanRunner.getContainerStatus(container.name);
3853
+ const logs = await podmanRunner.getContainerLogs(container.name);
3854
+ if (logs) {
3855
+ await sessionManager.appendJobOutput(sessionKey, activeJob.jobId, logs);
3856
+ }
3857
+ await sessionManager.updateJob(sessionKey, activeJob.jobId, {
3858
+ status: status?.exitCode === 0 ? "completed" : "failed",
3859
+ completedAt: status?.finishedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3860
+ exitCode: status?.exitCode ?? null,
3861
+ errorType: status?.exitCode === 137 ? "oom" : status?.exitCode !== 0 ? "crash" : null
3862
+ });
3863
+ await sessionManager.setActiveJob(sessionKey, null);
3864
+ await podmanRunner.killContainer(sessionKey);
3865
+ }
3866
+ } else {
3867
+ await podmanRunner.killContainer(sessionKey);
3868
+ }
3869
+ }
3870
+ } catch {
3871
+ }
3872
+ }
3873
+ export {
3874
+ PodmanRunner,
3875
+ SessionManager,
3876
+ register as default,
3877
+ formatDuration
3878
+ };