@bunny-agent/runner-cli 0.9.30 → 0.9.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.mjs CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, { get: all[name], enumerable: true });
6
+ };
2
7
 
3
8
  // src/cli.ts
4
9
  import { resolve as resolve3 } from "node:path";
@@ -2508,181 +2513,2888 @@ function buildSecretAwareTools(cwd, secrets) {
2508
2513
  return tools;
2509
2514
  }
2510
2515
 
2511
- // ../../packages/runner-pi/dist/pi-runner.js
2512
- var LOG_PREFIX2 = "[bunny-agent:pi]";
2513
- function parseModelSpec(model) {
2514
- const trimmed = model.trim();
2515
- const separator = trimmed.indexOf(":");
2516
- if (separator <= 0 || separator === trimmed.length - 1) {
2517
- throw new Error(`Invalid pi model "${model}". Expected format "<provider>:<model>", for example "google:gemini-2.5-pro".`);
2516
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
2517
+ var value_exports = {};
2518
+ __export(value_exports, {
2519
+ HasPropertyKey: () => HasPropertyKey,
2520
+ IsArray: () => IsArray,
2521
+ IsAsyncIterator: () => IsAsyncIterator,
2522
+ IsBigInt: () => IsBigInt,
2523
+ IsBoolean: () => IsBoolean,
2524
+ IsDate: () => IsDate,
2525
+ IsFunction: () => IsFunction,
2526
+ IsIterator: () => IsIterator,
2527
+ IsNull: () => IsNull,
2528
+ IsNumber: () => IsNumber,
2529
+ IsObject: () => IsObject,
2530
+ IsRegExp: () => IsRegExp,
2531
+ IsString: () => IsString,
2532
+ IsSymbol: () => IsSymbol,
2533
+ IsUint8Array: () => IsUint8Array,
2534
+ IsUndefined: () => IsUndefined
2535
+ });
2536
+ function HasPropertyKey(value, key) {
2537
+ return key in value;
2538
+ }
2539
+ function IsAsyncIterator(value) {
2540
+ return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
2541
+ }
2542
+ function IsArray(value) {
2543
+ return Array.isArray(value);
2544
+ }
2545
+ function IsBigInt(value) {
2546
+ return typeof value === "bigint";
2547
+ }
2548
+ function IsBoolean(value) {
2549
+ return typeof value === "boolean";
2550
+ }
2551
+ function IsDate(value) {
2552
+ return value instanceof globalThis.Date;
2553
+ }
2554
+ function IsFunction(value) {
2555
+ return typeof value === "function";
2556
+ }
2557
+ function IsIterator(value) {
2558
+ return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.iterator in value;
2559
+ }
2560
+ function IsNull(value) {
2561
+ return value === null;
2562
+ }
2563
+ function IsNumber(value) {
2564
+ return typeof value === "number";
2565
+ }
2566
+ function IsObject(value) {
2567
+ return typeof value === "object" && value !== null;
2568
+ }
2569
+ function IsRegExp(value) {
2570
+ return value instanceof globalThis.RegExp;
2571
+ }
2572
+ function IsString(value) {
2573
+ return typeof value === "string";
2574
+ }
2575
+ function IsSymbol(value) {
2576
+ return typeof value === "symbol";
2577
+ }
2578
+ function IsUint8Array(value) {
2579
+ return value instanceof globalThis.Uint8Array;
2580
+ }
2581
+ function IsUndefined(value) {
2582
+ return value === void 0;
2583
+ }
2584
+
2585
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
2586
+ function ArrayType(value) {
2587
+ return value.map((value2) => Visit(value2));
2588
+ }
2589
+ function DateType(value) {
2590
+ return new Date(value.getTime());
2591
+ }
2592
+ function Uint8ArrayType(value) {
2593
+ return new Uint8Array(value);
2594
+ }
2595
+ function RegExpType(value) {
2596
+ return new RegExp(value.source, value.flags);
2597
+ }
2598
+ function ObjectType(value) {
2599
+ const result = {};
2600
+ for (const key of Object.getOwnPropertyNames(value)) {
2601
+ result[key] = Visit(value[key]);
2518
2602
  }
2519
- return {
2520
- provider: trimmed.slice(0, separator),
2521
- modelName: trimmed.slice(separator + 1)
2522
- };
2603
+ for (const key of Object.getOwnPropertySymbols(value)) {
2604
+ result[key] = Visit(value[key]);
2605
+ }
2606
+ return result;
2523
2607
  }
2524
- function resolveImageModelName(chatProvider, env) {
2525
- const spec = env?.IMAGE_GENERATION_MODEL;
2526
- if (!spec)
2527
- return void 0;
2528
- try {
2529
- const { provider, modelName } = parseModelSpec(spec);
2530
- return provider === chatProvider ? modelName : void 0;
2531
- } catch {
2532
- return void 0;
2608
+ function Visit(value) {
2609
+ return IsArray(value) ? ArrayType(value) : IsDate(value) ? DateType(value) : IsUint8Array(value) ? Uint8ArrayType(value) : IsRegExp(value) ? RegExpType(value) : IsObject(value) ? ObjectType(value) : value;
2610
+ }
2611
+ function Clone(value) {
2612
+ return Visit(value);
2613
+ }
2614
+
2615
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
2616
+ function CloneType(schema, options) {
2617
+ return options === void 0 ? Clone(schema) : Clone({ ...options, ...schema });
2618
+ }
2619
+
2620
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
2621
+ function IsObject2(value) {
2622
+ return value !== null && typeof value === "object";
2623
+ }
2624
+ function IsArray2(value) {
2625
+ return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
2626
+ }
2627
+ function IsUndefined2(value) {
2628
+ return value === void 0;
2629
+ }
2630
+ function IsNumber2(value) {
2631
+ return typeof value === "number";
2632
+ }
2633
+
2634
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/system/policy.mjs
2635
+ var TypeSystemPolicy;
2636
+ (function(TypeSystemPolicy2) {
2637
+ TypeSystemPolicy2.InstanceMode = "default";
2638
+ TypeSystemPolicy2.ExactOptionalPropertyTypes = false;
2639
+ TypeSystemPolicy2.AllowArrayObject = false;
2640
+ TypeSystemPolicy2.AllowNaN = false;
2641
+ TypeSystemPolicy2.AllowNullVoid = false;
2642
+ function IsExactOptionalProperty(value, key) {
2643
+ return TypeSystemPolicy2.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
2644
+ }
2645
+ TypeSystemPolicy2.IsExactOptionalProperty = IsExactOptionalProperty;
2646
+ function IsObjectLike(value) {
2647
+ const isObject = IsObject2(value);
2648
+ return TypeSystemPolicy2.AllowArrayObject ? isObject : isObject && !IsArray2(value);
2649
+ }
2650
+ TypeSystemPolicy2.IsObjectLike = IsObjectLike;
2651
+ function IsRecordLike(value) {
2652
+ return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
2653
+ }
2654
+ TypeSystemPolicy2.IsRecordLike = IsRecordLike;
2655
+ function IsNumberLike(value) {
2656
+ return TypeSystemPolicy2.AllowNaN ? IsNumber2(value) : Number.isFinite(value);
2533
2657
  }
2658
+ TypeSystemPolicy2.IsNumberLike = IsNumberLike;
2659
+ function IsVoidLike(value) {
2660
+ const isUndefined = IsUndefined2(value);
2661
+ return TypeSystemPolicy2.AllowNullVoid ? isUndefined || value === null : isUndefined;
2662
+ }
2663
+ TypeSystemPolicy2.IsVoidLike = IsVoidLike;
2664
+ })(TypeSystemPolicy || (TypeSystemPolicy = {}));
2665
+
2666
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
2667
+ function ImmutableArray(value) {
2668
+ return globalThis.Object.freeze(value).map((value2) => Immutable(value2));
2534
2669
  }
2535
- function getEnvValue(optionsEnv, name) {
2536
- return optionsEnv?.[name] ?? process.env[name];
2670
+ function ImmutableDate(value) {
2671
+ return value;
2537
2672
  }
2538
- function applyModelOverrides(model, provider, optionsEnv) {
2539
- if (model == null)
2540
- return;
2541
- const openAiBaseUrl = getEnvValue(optionsEnv, "OPENAI_BASE_URL");
2542
- const geminiBaseUrl = getEnvValue(optionsEnv, "GEMINI_BASE_URL");
2543
- const anthropicBaseUrl = getEnvValue(optionsEnv, "ANTHROPIC_BASE_URL");
2544
- if (provider === "openai" && openAiBaseUrl) {
2545
- model.baseUrl = openAiBaseUrl;
2546
- } else if (provider === "google" && geminiBaseUrl) {
2547
- model.baseUrl = geminiBaseUrl;
2548
- } else if (provider === "anthropic" && anthropicBaseUrl) {
2549
- model.baseUrl = anthropicBaseUrl;
2673
+ function ImmutableUint8Array(value) {
2674
+ return value;
2675
+ }
2676
+ function ImmutableRegExp(value) {
2677
+ return value;
2678
+ }
2679
+ function ImmutableObject(value) {
2680
+ const result = {};
2681
+ for (const key of Object.getOwnPropertyNames(value)) {
2682
+ result[key] = Immutable(value[key]);
2550
2683
  }
2684
+ for (const key of Object.getOwnPropertySymbols(value)) {
2685
+ result[key] = Immutable(value[key]);
2686
+ }
2687
+ return globalThis.Object.freeze(result);
2551
2688
  }
2552
- function getErrorFromAgentEndMessages(messages) {
2553
- for (let i = messages.length - 1; i >= 0; i--) {
2554
- const m = messages[i];
2555
- if (m.role === "assistant" && m.errorMessage) {
2556
- return m.errorMessage;
2557
- }
2689
+ function Immutable(value) {
2690
+ return IsArray(value) ? ImmutableArray(value) : IsDate(value) ? ImmutableDate(value) : IsUint8Array(value) ? ImmutableUint8Array(value) : IsRegExp(value) ? ImmutableRegExp(value) : IsObject(value) ? ImmutableObject(value) : value;
2691
+ }
2692
+
2693
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
2694
+ function CreateType(schema, options) {
2695
+ const result = options !== void 0 ? { ...options, ...schema } : schema;
2696
+ switch (TypeSystemPolicy.InstanceMode) {
2697
+ case "freeze":
2698
+ return Immutable(result);
2699
+ case "clone":
2700
+ return Clone(result);
2701
+ default:
2702
+ return result;
2558
2703
  }
2559
- return void 0;
2560
2704
  }
2561
- function traceRawMessage(debugCwd, data, reset = false, optionsEnv) {
2562
- const debugVal = getEnvValue(optionsEnv, "DEBUG");
2563
- const enabled = debugVal === "true" || debugVal === "1";
2564
- if (!enabled)
2565
- return;
2705
+
2706
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
2707
+ var TypeBoxError = class extends Error {
2708
+ constructor(message) {
2709
+ super(message);
2710
+ }
2711
+ };
2712
+
2713
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
2714
+ var TransformKind = /* @__PURE__ */ Symbol.for("TypeBox.Transform");
2715
+ var ReadonlyKind = /* @__PURE__ */ Symbol.for("TypeBox.Readonly");
2716
+ var OptionalKind = /* @__PURE__ */ Symbol.for("TypeBox.Optional");
2717
+ var Hint = /* @__PURE__ */ Symbol.for("TypeBox.Hint");
2718
+ var Kind = /* @__PURE__ */ Symbol.for("TypeBox.Kind");
2719
+
2720
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
2721
+ function IsReadonly(value) {
2722
+ return IsObject(value) && value[ReadonlyKind] === "Readonly";
2723
+ }
2724
+ function IsOptional(value) {
2725
+ return IsObject(value) && value[OptionalKind] === "Optional";
2726
+ }
2727
+ function IsAny(value) {
2728
+ return IsKindOf(value, "Any");
2729
+ }
2730
+ function IsArgument(value) {
2731
+ return IsKindOf(value, "Argument");
2732
+ }
2733
+ function IsArray3(value) {
2734
+ return IsKindOf(value, "Array");
2735
+ }
2736
+ function IsAsyncIterator2(value) {
2737
+ return IsKindOf(value, "AsyncIterator");
2738
+ }
2739
+ function IsBigInt2(value) {
2740
+ return IsKindOf(value, "BigInt");
2741
+ }
2742
+ function IsBoolean2(value) {
2743
+ return IsKindOf(value, "Boolean");
2744
+ }
2745
+ function IsComputed(value) {
2746
+ return IsKindOf(value, "Computed");
2747
+ }
2748
+ function IsConstructor(value) {
2749
+ return IsKindOf(value, "Constructor");
2750
+ }
2751
+ function IsDate2(value) {
2752
+ return IsKindOf(value, "Date");
2753
+ }
2754
+ function IsFunction2(value) {
2755
+ return IsKindOf(value, "Function");
2756
+ }
2757
+ function IsInteger(value) {
2758
+ return IsKindOf(value, "Integer");
2759
+ }
2760
+ function IsIntersect(value) {
2761
+ return IsKindOf(value, "Intersect");
2762
+ }
2763
+ function IsIterator2(value) {
2764
+ return IsKindOf(value, "Iterator");
2765
+ }
2766
+ function IsKindOf(value, kind) {
2767
+ return IsObject(value) && Kind in value && value[Kind] === kind;
2768
+ }
2769
+ function IsLiteralValue(value) {
2770
+ return IsBoolean(value) || IsNumber(value) || IsString(value);
2771
+ }
2772
+ function IsLiteral(value) {
2773
+ return IsKindOf(value, "Literal");
2774
+ }
2775
+ function IsMappedKey(value) {
2776
+ return IsKindOf(value, "MappedKey");
2777
+ }
2778
+ function IsMappedResult(value) {
2779
+ return IsKindOf(value, "MappedResult");
2780
+ }
2781
+ function IsNever(value) {
2782
+ return IsKindOf(value, "Never");
2783
+ }
2784
+ function IsNot(value) {
2785
+ return IsKindOf(value, "Not");
2786
+ }
2787
+ function IsNull2(value) {
2788
+ return IsKindOf(value, "Null");
2789
+ }
2790
+ function IsNumber3(value) {
2791
+ return IsKindOf(value, "Number");
2792
+ }
2793
+ function IsObject3(value) {
2794
+ return IsKindOf(value, "Object");
2795
+ }
2796
+ function IsPromise(value) {
2797
+ return IsKindOf(value, "Promise");
2798
+ }
2799
+ function IsRecord(value) {
2800
+ return IsKindOf(value, "Record");
2801
+ }
2802
+ function IsRef(value) {
2803
+ return IsKindOf(value, "Ref");
2804
+ }
2805
+ function IsRegExp2(value) {
2806
+ return IsKindOf(value, "RegExp");
2807
+ }
2808
+ function IsString2(value) {
2809
+ return IsKindOf(value, "String");
2810
+ }
2811
+ function IsSymbol2(value) {
2812
+ return IsKindOf(value, "Symbol");
2813
+ }
2814
+ function IsTemplateLiteral(value) {
2815
+ return IsKindOf(value, "TemplateLiteral");
2816
+ }
2817
+ function IsThis(value) {
2818
+ return IsKindOf(value, "This");
2819
+ }
2820
+ function IsTransform(value) {
2821
+ return IsObject(value) && TransformKind in value;
2822
+ }
2823
+ function IsTuple(value) {
2824
+ return IsKindOf(value, "Tuple");
2825
+ }
2826
+ function IsUndefined3(value) {
2827
+ return IsKindOf(value, "Undefined");
2828
+ }
2829
+ function IsUnion(value) {
2830
+ return IsKindOf(value, "Union");
2831
+ }
2832
+ function IsUint8Array2(value) {
2833
+ return IsKindOf(value, "Uint8Array");
2834
+ }
2835
+ function IsUnknown(value) {
2836
+ return IsKindOf(value, "Unknown");
2837
+ }
2838
+ function IsUnsafe(value) {
2839
+ return IsKindOf(value, "Unsafe");
2840
+ }
2841
+ function IsVoid(value) {
2842
+ return IsKindOf(value, "Void");
2843
+ }
2844
+ function IsKind(value) {
2845
+ return IsObject(value) && Kind in value && IsString(value[Kind]);
2846
+ }
2847
+ function IsSchema(value) {
2848
+ 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);
2849
+ }
2850
+
2851
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
2852
+ var type_exports = {};
2853
+ __export(type_exports, {
2854
+ IsAny: () => IsAny2,
2855
+ IsArgument: () => IsArgument2,
2856
+ IsArray: () => IsArray4,
2857
+ IsAsyncIterator: () => IsAsyncIterator3,
2858
+ IsBigInt: () => IsBigInt3,
2859
+ IsBoolean: () => IsBoolean3,
2860
+ IsComputed: () => IsComputed2,
2861
+ IsConstructor: () => IsConstructor2,
2862
+ IsDate: () => IsDate3,
2863
+ IsFunction: () => IsFunction3,
2864
+ IsImport: () => IsImport,
2865
+ IsInteger: () => IsInteger2,
2866
+ IsIntersect: () => IsIntersect2,
2867
+ IsIterator: () => IsIterator3,
2868
+ IsKind: () => IsKind2,
2869
+ IsKindOf: () => IsKindOf2,
2870
+ IsLiteral: () => IsLiteral2,
2871
+ IsLiteralBoolean: () => IsLiteralBoolean,
2872
+ IsLiteralNumber: () => IsLiteralNumber,
2873
+ IsLiteralString: () => IsLiteralString,
2874
+ IsLiteralValue: () => IsLiteralValue2,
2875
+ IsMappedKey: () => IsMappedKey2,
2876
+ IsMappedResult: () => IsMappedResult2,
2877
+ IsNever: () => IsNever2,
2878
+ IsNot: () => IsNot2,
2879
+ IsNull: () => IsNull3,
2880
+ IsNumber: () => IsNumber4,
2881
+ IsObject: () => IsObject4,
2882
+ IsOptional: () => IsOptional2,
2883
+ IsPromise: () => IsPromise2,
2884
+ IsProperties: () => IsProperties,
2885
+ IsReadonly: () => IsReadonly2,
2886
+ IsRecord: () => IsRecord2,
2887
+ IsRecursive: () => IsRecursive,
2888
+ IsRef: () => IsRef2,
2889
+ IsRegExp: () => IsRegExp3,
2890
+ IsSchema: () => IsSchema2,
2891
+ IsString: () => IsString3,
2892
+ IsSymbol: () => IsSymbol3,
2893
+ IsTemplateLiteral: () => IsTemplateLiteral2,
2894
+ IsThis: () => IsThis2,
2895
+ IsTransform: () => IsTransform2,
2896
+ IsTuple: () => IsTuple2,
2897
+ IsUint8Array: () => IsUint8Array3,
2898
+ IsUndefined: () => IsUndefined4,
2899
+ IsUnion: () => IsUnion2,
2900
+ IsUnionLiteral: () => IsUnionLiteral,
2901
+ IsUnknown: () => IsUnknown2,
2902
+ IsUnsafe: () => IsUnsafe2,
2903
+ IsVoid: () => IsVoid2,
2904
+ TypeGuardUnknownTypeError: () => TypeGuardUnknownTypeError
2905
+ });
2906
+ var TypeGuardUnknownTypeError = class extends TypeBoxError {
2907
+ };
2908
+ var KnownTypes = [
2909
+ "Argument",
2910
+ "Any",
2911
+ "Array",
2912
+ "AsyncIterator",
2913
+ "BigInt",
2914
+ "Boolean",
2915
+ "Computed",
2916
+ "Constructor",
2917
+ "Date",
2918
+ "Enum",
2919
+ "Function",
2920
+ "Integer",
2921
+ "Intersect",
2922
+ "Iterator",
2923
+ "Literal",
2924
+ "MappedKey",
2925
+ "MappedResult",
2926
+ "Not",
2927
+ "Null",
2928
+ "Number",
2929
+ "Object",
2930
+ "Promise",
2931
+ "Record",
2932
+ "Ref",
2933
+ "RegExp",
2934
+ "String",
2935
+ "Symbol",
2936
+ "TemplateLiteral",
2937
+ "This",
2938
+ "Tuple",
2939
+ "Undefined",
2940
+ "Union",
2941
+ "Uint8Array",
2942
+ "Unknown",
2943
+ "Void"
2944
+ ];
2945
+ function IsPattern(value) {
2566
2946
  try {
2567
- const file = join8(debugCwd, "pi-message-stream-debug.json");
2568
- if (reset && existsSync5(file))
2569
- unlinkSync3(file);
2570
- const type = data !== null && typeof data === "object" ? data.type : void 0;
2571
- let payload = data;
2572
- try {
2573
- payload = data !== void 0 ? JSON.parse(JSON.stringify(data)) : void 0;
2574
- } catch {
2575
- payload = "[non-serializable]";
2576
- }
2577
- const entry = { _t: (/* @__PURE__ */ new Date()).toISOString(), type, payload };
2578
- appendFileSync2(file, JSON.stringify(entry, null, 2) + ",\n");
2947
+ new RegExp(value);
2948
+ return true;
2579
2949
  } catch {
2950
+ return false;
2580
2951
  }
2581
2952
  }
2582
- function createPiRunner(options = {}) {
2583
- const modelSpec = options.model;
2584
- if (modelSpec == null || modelSpec.trim() === "") {
2585
- throw new Error("Pi runner: model is required. Pass a model in the form <provider>:<model>, e.g. openai:gpt-4o or google:gemini-2.5-flash.");
2586
- }
2587
- const { provider, modelName } = parseModelSpec(modelSpec.trim());
2588
- const cwd = options.cwd || process.cwd();
2589
- const apiKeyEnvKey = `${provider.toUpperCase().replace(/-/g, "_")}_API_KEY`;
2590
- const inlineApiKey = typeof options.env?.[apiKeyEnvKey] === "string" && options.env[apiKeyEnvKey].length > 0 ? options.env[apiKeyEnvKey] : void 0;
2591
- const modelRegistry = ModelRegistry.inMemory(AuthStorage.create());
2592
- const defaultModel = getModel(provider, modelName);
2593
- let model = defaultModel ?? modelRegistry.find(provider, modelName);
2594
- if (model == null) {
2595
- const baseUrlEnvKey = `${provider.toUpperCase().replace(/-/g, "_")}_BASE_URL`;
2596
- const baseUrl = getEnvValue(options.env, baseUrlEnvKey) ?? getEnvValue(options.env, "OPENAI_BASE_URL");
2597
- if (!baseUrl) {
2598
- throw new Error(`Pi runner: model "${modelSpec}" not found in built-in catalog. Set ${baseUrlEnvKey} (or OPENAI_BASE_URL) to auto-register it.`);
2599
- }
2600
- modelRegistry.registerProvider(provider, {
2601
- baseUrl,
2602
- apiKey: inlineApiKey ?? apiKeyEnvKey,
2603
- api: "openai-completions",
2604
- models: [
2605
- {
2606
- id: modelName,
2607
- name: modelName,
2608
- reasoning: false,
2609
- input: ["text", "image"],
2610
- cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
2611
- contextWindow: 128e3,
2612
- maxTokens: 8192
2613
- }
2614
- ]
2615
- });
2616
- const registered = modelRegistry.find(provider, modelName);
2617
- if (!registered) {
2618
- throw new Error(`Pi runner: failed to resolve model "${modelSpec}" after registration.`);
2953
+ function IsControlCharacterFree(value) {
2954
+ if (!IsString(value))
2955
+ return false;
2956
+ for (let i = 0; i < value.length; i++) {
2957
+ const code = value.charCodeAt(i);
2958
+ if (code >= 7 && code <= 13 || code === 27 || code === 127) {
2959
+ return false;
2619
2960
  }
2620
- model = registered;
2621
2961
  }
2622
- applyModelOverrides(model, provider, options.env);
2623
- const imageModelName = resolveImageModelName(provider, options.env);
2624
- return {
2625
- async *run(userInput) {
2626
- if (inlineApiKey !== void 0) {
2627
- modelRegistry.authStorage.setRuntimeApiKey(provider, inlineApiKey);
2628
- }
2629
- try {
2630
- const resume = options.sessionId?.trim();
2631
- const sessionManager = await (async () => {
2632
- if (resume !== void 0 && resume !== "") {
2633
- if (resume.includes("/")) {
2634
- return SessionManager2.open(resume);
2635
- }
2636
- const sessionPath2 = resolveSessionPathById(cwd, resume);
2637
- console.error(`${LOG_PREFIX2} resume: id=${resume} path=${sessionPath2 ?? "(not found)"}`);
2638
- if (sessionPath2) {
2639
- if (isSessionFileTooLarge(sessionPath2)) {
2640
- const context = extractSessionContext(sessionPath2);
2641
- console.error(`${LOG_PREFIX2} session file too large, starting fresh${context ? " (with context)" : ""}`);
2642
- const newMgr = SessionManager2.create(cwd);
2643
- if (context) {
2644
- const firstId = newMgr.getEntries()[0]?.id ?? "";
2645
- newMgr.appendCompaction(context, firstId, 0);
2646
- }
2647
- return newMgr;
2648
- }
2649
- return SessionManager2.open(sessionPath2);
2650
- }
2651
- return SessionManager2.create(cwd);
2652
- }
2653
- return SessionManager2.create(cwd);
2654
- })();
2655
- const resourceLoader = options.skillPaths ? new BunnyAgentResourceLoader({
2656
- cwd,
2657
- skillPaths: options.skillPaths,
2658
- appendSystemPrompt: options.systemPrompt
2659
- }) : void 0;
2660
- if (options.skillPaths && options.skillPaths.length > 0) {
2661
- console.error(`${LOG_PREFIX2} runner: cwd=${cwd} skillPaths=${JSON.stringify(options.skillPaths)}`);
2662
- }
2663
- if (resourceLoader) {
2664
- await resourceLoader.reload();
2665
- }
2666
- const customTools = options.env && Object.keys(options.env).length > 0 ? buildSecretAwareTools(cwd, options.env) : [];
2667
- if (imageModelName) {
2668
- const apiKey = await modelRegistry.authStorage.getApiKey(provider) ?? "";
2669
- customTools.push(buildImageGenerateTool(cwd, imageModelName, model.baseUrl, apiKey), buildImageEditTool(cwd, imageModelName, model.baseUrl, apiKey));
2670
- }
2671
- const { session } = await createAgentSession({
2672
- cwd,
2673
- model,
2674
- sessionManager,
2675
- modelRegistry,
2676
- resourceLoader,
2677
- customTools
2678
- });
2679
- const eventQueue = [];
2680
- let isComplete = false;
2681
- let aborted = false;
2682
- let wakeConsumer = null;
2683
- const notify = () => {
2684
- wakeConsumer?.();
2685
- wakeConsumer = null;
2962
+ return true;
2963
+ }
2964
+ function IsAdditionalProperties(value) {
2965
+ return IsOptionalBoolean(value) || IsSchema2(value);
2966
+ }
2967
+ function IsOptionalBigInt(value) {
2968
+ return IsUndefined(value) || IsBigInt(value);
2969
+ }
2970
+ function IsOptionalNumber(value) {
2971
+ return IsUndefined(value) || IsNumber(value);
2972
+ }
2973
+ function IsOptionalBoolean(value) {
2974
+ return IsUndefined(value) || IsBoolean(value);
2975
+ }
2976
+ function IsOptionalString(value) {
2977
+ return IsUndefined(value) || IsString(value);
2978
+ }
2979
+ function IsOptionalPattern(value) {
2980
+ return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value) && IsPattern(value);
2981
+ }
2982
+ function IsOptionalFormat(value) {
2983
+ return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value);
2984
+ }
2985
+ function IsOptionalSchema(value) {
2986
+ return IsUndefined(value) || IsSchema2(value);
2987
+ }
2988
+ function IsReadonly2(value) {
2989
+ return IsObject(value) && value[ReadonlyKind] === "Readonly";
2990
+ }
2991
+ function IsOptional2(value) {
2992
+ return IsObject(value) && value[OptionalKind] === "Optional";
2993
+ }
2994
+ function IsAny2(value) {
2995
+ return IsKindOf2(value, "Any") && IsOptionalString(value.$id);
2996
+ }
2997
+ function IsArgument2(value) {
2998
+ return IsKindOf2(value, "Argument") && IsNumber(value.index);
2999
+ }
3000
+ function IsArray4(value) {
3001
+ 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);
3002
+ }
3003
+ function IsAsyncIterator3(value) {
3004
+ return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
3005
+ }
3006
+ function IsBigInt3(value) {
3007
+ 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);
3008
+ }
3009
+ function IsBoolean3(value) {
3010
+ return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
3011
+ }
3012
+ function IsComputed2(value) {
3013
+ return IsKindOf2(value, "Computed") && IsString(value.target) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema));
3014
+ }
3015
+ function IsConstructor2(value) {
3016
+ return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
3017
+ }
3018
+ function IsDate3(value) {
3019
+ 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);
3020
+ }
3021
+ function IsFunction3(value) {
3022
+ return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
3023
+ }
3024
+ function IsImport(value) {
3025
+ return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
3026
+ }
3027
+ function IsInteger2(value) {
3028
+ 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);
3029
+ }
3030
+ function IsProperties(value) {
3031
+ return IsObject(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema2(schema));
3032
+ }
3033
+ function IsIntersect2(value) {
3034
+ 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);
3035
+ }
3036
+ function IsIterator3(value) {
3037
+ return IsKindOf2(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
3038
+ }
3039
+ function IsKindOf2(value, kind) {
3040
+ return IsObject(value) && Kind in value && value[Kind] === kind;
3041
+ }
3042
+ function IsLiteralString(value) {
3043
+ return IsLiteral2(value) && IsString(value.const);
3044
+ }
3045
+ function IsLiteralNumber(value) {
3046
+ return IsLiteral2(value) && IsNumber(value.const);
3047
+ }
3048
+ function IsLiteralBoolean(value) {
3049
+ return IsLiteral2(value) && IsBoolean(value.const);
3050
+ }
3051
+ function IsLiteral2(value) {
3052
+ return IsKindOf2(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue2(value.const);
3053
+ }
3054
+ function IsLiteralValue2(value) {
3055
+ return IsBoolean(value) || IsNumber(value) || IsString(value);
3056
+ }
3057
+ function IsMappedKey2(value) {
3058
+ return IsKindOf2(value, "MappedKey") && IsArray(value.keys) && value.keys.every((key) => IsNumber(key) || IsString(key));
3059
+ }
3060
+ function IsMappedResult2(value) {
3061
+ return IsKindOf2(value, "MappedResult") && IsProperties(value.properties);
3062
+ }
3063
+ function IsNever2(value) {
3064
+ return IsKindOf2(value, "Never") && IsObject(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
3065
+ }
3066
+ function IsNot2(value) {
3067
+ return IsKindOf2(value, "Not") && IsSchema2(value.not);
3068
+ }
3069
+ function IsNull3(value) {
3070
+ return IsKindOf2(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
3071
+ }
3072
+ function IsNumber4(value) {
3073
+ 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);
3074
+ }
3075
+ function IsObject4(value) {
3076
+ return IsKindOf2(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
3077
+ }
3078
+ function IsPromise2(value) {
3079
+ return IsKindOf2(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema2(value.item);
3080
+ }
3081
+ function IsRecord2(value) {
3082
+ return IsKindOf2(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject(value.patternProperties) && ((schema) => {
3083
+ const keys = Object.getOwnPropertyNames(schema.patternProperties);
3084
+ return keys.length === 1 && IsPattern(keys[0]) && IsObject(schema.patternProperties) && IsSchema2(schema.patternProperties[keys[0]]);
3085
+ })(value);
3086
+ }
3087
+ function IsRecursive(value) {
3088
+ return IsObject(value) && Hint in value && value[Hint] === "Recursive";
3089
+ }
3090
+ function IsRef2(value) {
3091
+ return IsKindOf2(value, "Ref") && IsOptionalString(value.$id) && IsString(value.$ref);
3092
+ }
3093
+ function IsRegExp3(value) {
3094
+ return IsKindOf2(value, "RegExp") && IsOptionalString(value.$id) && IsString(value.source) && IsString(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
3095
+ }
3096
+ function IsString3(value) {
3097
+ return IsKindOf2(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
3098
+ }
3099
+ function IsSymbol3(value) {
3100
+ return IsKindOf2(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
3101
+ }
3102
+ function IsTemplateLiteral2(value) {
3103
+ return IsKindOf2(value, "TemplateLiteral") && value.type === "string" && IsString(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
3104
+ }
3105
+ function IsThis2(value) {
3106
+ return IsKindOf2(value, "This") && IsOptionalString(value.$id) && IsString(value.$ref);
3107
+ }
3108
+ function IsTransform2(value) {
3109
+ return IsObject(value) && TransformKind in value;
3110
+ }
3111
+ function IsTuple2(value) {
3112
+ return IsKindOf2(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber(value.minItems) && IsNumber(value.maxItems) && value.minItems === value.maxItems && // empty
3113
+ (IsUndefined(value.items) && IsUndefined(value.additionalItems) && value.minItems === 0 || IsArray(value.items) && value.items.every((schema) => IsSchema2(schema)));
3114
+ }
3115
+ function IsUndefined4(value) {
3116
+ return IsKindOf2(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
3117
+ }
3118
+ function IsUnionLiteral(value) {
3119
+ return IsUnion2(value) && value.anyOf.every((schema) => IsLiteralString(schema) || IsLiteralNumber(schema));
3120
+ }
3121
+ function IsUnion2(value) {
3122
+ return IsKindOf2(value, "Union") && IsOptionalString(value.$id) && IsObject(value) && IsArray(value.anyOf) && value.anyOf.every((schema) => IsSchema2(schema));
3123
+ }
3124
+ function IsUint8Array3(value) {
3125
+ return IsKindOf2(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
3126
+ }
3127
+ function IsUnknown2(value) {
3128
+ return IsKindOf2(value, "Unknown") && IsOptionalString(value.$id);
3129
+ }
3130
+ function IsUnsafe2(value) {
3131
+ return IsKindOf2(value, "Unsafe");
3132
+ }
3133
+ function IsVoid2(value) {
3134
+ return IsKindOf2(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
3135
+ }
3136
+ function IsKind2(value) {
3137
+ return IsObject(value) && Kind in value && IsString(value[Kind]) && !KnownTypes.includes(value[Kind]);
3138
+ }
3139
+ function IsSchema2(value) {
3140
+ 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));
3141
+ }
3142
+
3143
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.mjs
3144
+ var PatternBoolean = "(true|false)";
3145
+ var PatternNumber = "(0|[1-9][0-9]*)";
3146
+ var PatternString = "(.*)";
3147
+ var PatternNever = "(?!.*)";
3148
+ var PatternBooleanExact = `^${PatternBoolean}$`;
3149
+ var PatternNumberExact = `^${PatternNumber}$`;
3150
+ var PatternStringExact = `^${PatternString}$`;
3151
+ var PatternNeverExact = `^${PatternNever}$`;
3152
+
3153
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
3154
+ function SetIncludes(T, S) {
3155
+ return T.includes(S);
3156
+ }
3157
+ function SetDistinct(T) {
3158
+ return [...new Set(T)];
3159
+ }
3160
+ function SetIntersect(T, S) {
3161
+ return T.filter((L) => S.includes(L));
3162
+ }
3163
+ function SetIntersectManyResolve(T, Init) {
3164
+ return T.reduce((Acc, L) => {
3165
+ return SetIntersect(Acc, L);
3166
+ }, Init);
3167
+ }
3168
+ function SetIntersectMany(T) {
3169
+ return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
3170
+ }
3171
+ function SetUnionMany(T) {
3172
+ const Acc = [];
3173
+ for (const L of T)
3174
+ Acc.push(...L);
3175
+ return Acc;
3176
+ }
3177
+
3178
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/any/any.mjs
3179
+ function Any(options) {
3180
+ return CreateType({ [Kind]: "Any" }, options);
3181
+ }
3182
+
3183
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/array/array.mjs
3184
+ function Array2(items, options) {
3185
+ return CreateType({ [Kind]: "Array", type: "array", items }, options);
3186
+ }
3187
+
3188
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/argument/argument.mjs
3189
+ function Argument(index) {
3190
+ return CreateType({ [Kind]: "Argument", index });
3191
+ }
3192
+
3193
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.mjs
3194
+ function AsyncIterator(items, options) {
3195
+ return CreateType({ [Kind]: "AsyncIterator", type: "AsyncIterator", items }, options);
3196
+ }
3197
+
3198
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/computed/computed.mjs
3199
+ function Computed(target, parameters, options) {
3200
+ return CreateType({ [Kind]: "Computed", target, parameters }, options);
3201
+ }
3202
+
3203
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/discard/discard.mjs
3204
+ function DiscardKey(value, key) {
3205
+ const { [key]: _, ...rest } = value;
3206
+ return rest;
3207
+ }
3208
+ function Discard(value, keys) {
3209
+ return keys.reduce((acc, key) => DiscardKey(acc, key), value);
3210
+ }
3211
+
3212
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
3213
+ function Never(options) {
3214
+ return CreateType({ [Kind]: "Never", not: {} }, options);
3215
+ }
3216
+
3217
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.mjs
3218
+ function MappedResult(properties) {
3219
+ return CreateType({
3220
+ [Kind]: "MappedResult",
3221
+ properties
3222
+ });
3223
+ }
3224
+
3225
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.mjs
3226
+ function Constructor(parameters, returns, options) {
3227
+ return CreateType({ [Kind]: "Constructor", type: "Constructor", parameters, returns }, options);
3228
+ }
3229
+
3230
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/function/function.mjs
3231
+ function Function(parameters, returns, options) {
3232
+ return CreateType({ [Kind]: "Function", type: "Function", parameters, returns }, options);
3233
+ }
3234
+
3235
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/union/union-create.mjs
3236
+ function UnionCreate(T, options) {
3237
+ return CreateType({ [Kind]: "Union", anyOf: T }, options);
3238
+ }
3239
+
3240
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.mjs
3241
+ function IsUnionOptional(types) {
3242
+ return types.some((type) => IsOptional(type));
3243
+ }
3244
+ function RemoveOptionalFromRest(types) {
3245
+ return types.map((left) => IsOptional(left) ? RemoveOptionalFromType(left) : left);
3246
+ }
3247
+ function RemoveOptionalFromType(T) {
3248
+ return Discard(T, [OptionalKind]);
3249
+ }
3250
+ function ResolveUnion(types, options) {
3251
+ const isOptional = IsUnionOptional(types);
3252
+ return isOptional ? Optional(UnionCreate(RemoveOptionalFromRest(types), options)) : UnionCreate(RemoveOptionalFromRest(types), options);
3253
+ }
3254
+ function UnionEvaluated(T, options) {
3255
+ return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
3256
+ }
3257
+
3258
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/union/union.mjs
3259
+ function Union(types, options) {
3260
+ return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
3261
+ }
3262
+
3263
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.mjs
3264
+ var TemplateLiteralParserError = class extends TypeBoxError {
3265
+ };
3266
+ function Unescape(pattern) {
3267
+ return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
3268
+ }
3269
+ function IsNonEscaped(pattern, index, char) {
3270
+ return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
3271
+ }
3272
+ function IsOpenParen(pattern, index) {
3273
+ return IsNonEscaped(pattern, index, "(");
3274
+ }
3275
+ function IsCloseParen(pattern, index) {
3276
+ return IsNonEscaped(pattern, index, ")");
3277
+ }
3278
+ function IsSeparator(pattern, index) {
3279
+ return IsNonEscaped(pattern, index, "|");
3280
+ }
3281
+ function IsGroup(pattern) {
3282
+ if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
3283
+ return false;
3284
+ let count = 0;
3285
+ for (let index = 0; index < pattern.length; index++) {
3286
+ if (IsOpenParen(pattern, index))
3287
+ count += 1;
3288
+ if (IsCloseParen(pattern, index))
3289
+ count -= 1;
3290
+ if (count === 0 && index !== pattern.length - 1)
3291
+ return false;
3292
+ }
3293
+ return true;
3294
+ }
3295
+ function InGroup(pattern) {
3296
+ return pattern.slice(1, pattern.length - 1);
3297
+ }
3298
+ function IsPrecedenceOr(pattern) {
3299
+ let count = 0;
3300
+ for (let index = 0; index < pattern.length; index++) {
3301
+ if (IsOpenParen(pattern, index))
3302
+ count += 1;
3303
+ if (IsCloseParen(pattern, index))
3304
+ count -= 1;
3305
+ if (IsSeparator(pattern, index) && count === 0)
3306
+ return true;
3307
+ }
3308
+ return false;
3309
+ }
3310
+ function IsPrecedenceAnd(pattern) {
3311
+ for (let index = 0; index < pattern.length; index++) {
3312
+ if (IsOpenParen(pattern, index))
3313
+ return true;
3314
+ }
3315
+ return false;
3316
+ }
3317
+ function Or(pattern) {
3318
+ let [count, start] = [0, 0];
3319
+ const expressions = [];
3320
+ for (let index = 0; index < pattern.length; index++) {
3321
+ if (IsOpenParen(pattern, index))
3322
+ count += 1;
3323
+ if (IsCloseParen(pattern, index))
3324
+ count -= 1;
3325
+ if (IsSeparator(pattern, index) && count === 0) {
3326
+ const range2 = pattern.slice(start, index);
3327
+ if (range2.length > 0)
3328
+ expressions.push(TemplateLiteralParse(range2));
3329
+ start = index + 1;
3330
+ }
3331
+ }
3332
+ const range = pattern.slice(start);
3333
+ if (range.length > 0)
3334
+ expressions.push(TemplateLiteralParse(range));
3335
+ if (expressions.length === 0)
3336
+ return { type: "const", const: "" };
3337
+ if (expressions.length === 1)
3338
+ return expressions[0];
3339
+ return { type: "or", expr: expressions };
3340
+ }
3341
+ function And(pattern) {
3342
+ function Group(value, index) {
3343
+ if (!IsOpenParen(value, index))
3344
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
3345
+ let count = 0;
3346
+ for (let scan = index; scan < value.length; scan++) {
3347
+ if (IsOpenParen(value, scan))
3348
+ count += 1;
3349
+ if (IsCloseParen(value, scan))
3350
+ count -= 1;
3351
+ if (count === 0)
3352
+ return [index, scan];
3353
+ }
3354
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
3355
+ }
3356
+ function Range(pattern2, index) {
3357
+ for (let scan = index; scan < pattern2.length; scan++) {
3358
+ if (IsOpenParen(pattern2, scan))
3359
+ return [index, scan];
3360
+ }
3361
+ return [index, pattern2.length];
3362
+ }
3363
+ const expressions = [];
3364
+ for (let index = 0; index < pattern.length; index++) {
3365
+ if (IsOpenParen(pattern, index)) {
3366
+ const [start, end] = Group(pattern, index);
3367
+ const range = pattern.slice(start, end + 1);
3368
+ expressions.push(TemplateLiteralParse(range));
3369
+ index = end;
3370
+ } else {
3371
+ const [start, end] = Range(pattern, index);
3372
+ const range = pattern.slice(start, end);
3373
+ if (range.length > 0)
3374
+ expressions.push(TemplateLiteralParse(range));
3375
+ index = end - 1;
3376
+ }
3377
+ }
3378
+ return expressions.length === 0 ? { type: "const", const: "" } : expressions.length === 1 ? expressions[0] : { type: "and", expr: expressions };
3379
+ }
3380
+ function TemplateLiteralParse(pattern) {
3381
+ return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : { type: "const", const: Unescape(pattern) };
3382
+ }
3383
+ function TemplateLiteralParseExact(pattern) {
3384
+ return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
3385
+ }
3386
+
3387
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.mjs
3388
+ var TemplateLiteralFiniteError = class extends TypeBoxError {
3389
+ };
3390
+ function IsNumberExpression(expression) {
3391
+ 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]*";
3392
+ }
3393
+ function IsBooleanExpression(expression) {
3394
+ 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";
3395
+ }
3396
+ function IsStringExpression(expression) {
3397
+ return expression.type === "const" && expression.const === ".*";
3398
+ }
3399
+ function IsTemplateLiteralExpressionFinite(expression) {
3400
+ 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 : (() => {
3401
+ throw new TemplateLiteralFiniteError(`Unknown expression type`);
3402
+ })();
3403
+ }
3404
+ function IsTemplateLiteralFinite(schema) {
3405
+ const expression = TemplateLiteralParseExact(schema.pattern);
3406
+ return IsTemplateLiteralExpressionFinite(expression);
3407
+ }
3408
+
3409
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.mjs
3410
+ var TemplateLiteralGenerateError = class extends TypeBoxError {
3411
+ };
3412
+ function* GenerateReduce(buffer) {
3413
+ if (buffer.length === 1)
3414
+ return yield* buffer[0];
3415
+ for (const left of buffer[0]) {
3416
+ for (const right of GenerateReduce(buffer.slice(1))) {
3417
+ yield `${left}${right}`;
3418
+ }
3419
+ }
3420
+ }
3421
+ function* GenerateAnd(expression) {
3422
+ return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
3423
+ }
3424
+ function* GenerateOr(expression) {
3425
+ for (const expr of expression.expr)
3426
+ yield* TemplateLiteralExpressionGenerate(expr);
3427
+ }
3428
+ function* GenerateConst(expression) {
3429
+ return yield expression.const;
3430
+ }
3431
+ function* TemplateLiteralExpressionGenerate(expression) {
3432
+ return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
3433
+ throw new TemplateLiteralGenerateError("Unknown expression");
3434
+ })();
3435
+ }
3436
+ function TemplateLiteralGenerate(schema) {
3437
+ const expression = TemplateLiteralParseExact(schema.pattern);
3438
+ return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
3439
+ }
3440
+
3441
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/literal/literal.mjs
3442
+ function Literal(value, options) {
3443
+ return CreateType({
3444
+ [Kind]: "Literal",
3445
+ const: value,
3446
+ type: typeof value
3447
+ }, options);
3448
+ }
3449
+
3450
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.mjs
3451
+ function Boolean2(options) {
3452
+ return CreateType({ [Kind]: "Boolean", type: "boolean" }, options);
3453
+ }
3454
+
3455
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.mjs
3456
+ function BigInt(options) {
3457
+ return CreateType({ [Kind]: "BigInt", type: "bigint" }, options);
3458
+ }
3459
+
3460
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/number/number.mjs
3461
+ function Number2(options) {
3462
+ return CreateType({ [Kind]: "Number", type: "number" }, options);
3463
+ }
3464
+
3465
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/string/string.mjs
3466
+ function String2(options) {
3467
+ return CreateType({ [Kind]: "String", type: "string" }, options);
3468
+ }
3469
+
3470
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.mjs
3471
+ function* FromUnion(syntax) {
3472
+ const trim = syntax.trim().replace(/"|'/g, "");
3473
+ return trim === "boolean" ? yield Boolean2() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String2() : yield (() => {
3474
+ const literals = trim.split("|").map((literal) => Literal(literal.trim()));
3475
+ return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
3476
+ })();
3477
+ }
3478
+ function* FromTerminal(syntax) {
3479
+ if (syntax[1] !== "{") {
3480
+ const L = Literal("$");
3481
+ const R = FromSyntax(syntax.slice(1));
3482
+ return yield* [L, ...R];
3483
+ }
3484
+ for (let i = 2; i < syntax.length; i++) {
3485
+ if (syntax[i] === "}") {
3486
+ const L = FromUnion(syntax.slice(2, i));
3487
+ const R = FromSyntax(syntax.slice(i + 1));
3488
+ return yield* [...L, ...R];
3489
+ }
3490
+ }
3491
+ yield Literal(syntax);
3492
+ }
3493
+ function* FromSyntax(syntax) {
3494
+ for (let i = 0; i < syntax.length; i++) {
3495
+ if (syntax[i] === "$") {
3496
+ const L = Literal(syntax.slice(0, i));
3497
+ const R = FromTerminal(syntax.slice(i));
3498
+ return yield* [L, ...R];
3499
+ }
3500
+ }
3501
+ yield Literal(syntax);
3502
+ }
3503
+ function TemplateLiteralSyntax(syntax) {
3504
+ return [...FromSyntax(syntax)];
3505
+ }
3506
+
3507
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.mjs
3508
+ var TemplateLiteralPatternError = class extends TypeBoxError {
3509
+ };
3510
+ function Escape(value) {
3511
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3512
+ }
3513
+ function Visit2(schema, acc) {
3514
+ 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}` : (() => {
3515
+ throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
3516
+ })();
3517
+ }
3518
+ function TemplateLiteralPattern(kinds) {
3519
+ return `^${kinds.map((schema) => Visit2(schema, "")).join("")}$`;
3520
+ }
3521
+
3522
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/union.mjs
3523
+ function TemplateLiteralToUnion(schema) {
3524
+ const R = TemplateLiteralGenerate(schema);
3525
+ const L = R.map((S) => Literal(S));
3526
+ return UnionEvaluated(L);
3527
+ }
3528
+
3529
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.mjs
3530
+ function TemplateLiteral(unresolved, options) {
3531
+ const pattern = IsString(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
3532
+ return CreateType({ [Kind]: "TemplateLiteral", type: "string", pattern }, options);
3533
+ }
3534
+
3535
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.mjs
3536
+ function FromTemplateLiteral(templateLiteral) {
3537
+ const keys = TemplateLiteralGenerate(templateLiteral);
3538
+ return keys.map((key) => key.toString());
3539
+ }
3540
+ function FromUnion2(types) {
3541
+ const result = [];
3542
+ for (const type of types)
3543
+ result.push(...IndexPropertyKeys(type));
3544
+ return result;
3545
+ }
3546
+ function FromLiteral(literalValue) {
3547
+ return [literalValue.toString()];
3548
+ }
3549
+ function IndexPropertyKeys(type) {
3550
+ return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] : IsInteger(type) ? ["[number]"] : [])];
3551
+ }
3552
+
3553
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.mjs
3554
+ function FromProperties(type, properties, options) {
3555
+ const result = {};
3556
+ for (const K2 of Object.getOwnPropertyNames(properties)) {
3557
+ result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
3558
+ }
3559
+ return result;
3560
+ }
3561
+ function FromMappedResult(type, mappedResult, options) {
3562
+ return FromProperties(type, mappedResult.properties, options);
3563
+ }
3564
+ function IndexFromMappedResult(type, mappedResult, options) {
3565
+ const properties = FromMappedResult(type, mappedResult, options);
3566
+ return MappedResult(properties);
3567
+ }
3568
+
3569
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.mjs
3570
+ function FromRest(types, key) {
3571
+ return types.map((type) => IndexFromPropertyKey(type, key));
3572
+ }
3573
+ function FromIntersectRest(types) {
3574
+ return types.filter((type) => !IsNever(type));
3575
+ }
3576
+ function FromIntersect(types, key) {
3577
+ return IntersectEvaluated(FromIntersectRest(FromRest(types, key)));
3578
+ }
3579
+ function FromUnionRest(types) {
3580
+ return types.some((L) => IsNever(L)) ? [] : types;
3581
+ }
3582
+ function FromUnion3(types, key) {
3583
+ return UnionEvaluated(FromUnionRest(FromRest(types, key)));
3584
+ }
3585
+ function FromTuple(types, key) {
3586
+ return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
3587
+ }
3588
+ function FromArray(type, key) {
3589
+ return key === "[number]" ? type : Never();
3590
+ }
3591
+ function FromProperty(properties, propertyKey) {
3592
+ return propertyKey in properties ? properties[propertyKey] : Never();
3593
+ }
3594
+ function IndexFromPropertyKey(type, propertyKey) {
3595
+ 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();
3596
+ }
3597
+ function IndexFromPropertyKeys(type, propertyKeys) {
3598
+ return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
3599
+ }
3600
+ function FromSchema(type, propertyKeys) {
3601
+ return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
3602
+ }
3603
+ function Index(type, key, options) {
3604
+ if (IsRef(type) || IsRef(key)) {
3605
+ const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
3606
+ if (!IsSchema(type) || !IsSchema(key))
3607
+ throw new TypeBoxError(error);
3608
+ return Computed("Index", [type, key]);
3609
+ }
3610
+ if (IsMappedResult(key))
3611
+ return IndexFromMappedResult(type, key, options);
3612
+ if (IsMappedKey(key))
3613
+ return IndexFromMappedKey(type, key, options);
3614
+ return CreateType(IsSchema(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
3615
+ }
3616
+
3617
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.mjs
3618
+ function MappedIndexPropertyKey(type, key, options) {
3619
+ return { [key]: Index(type, [key], Clone(options)) };
3620
+ }
3621
+ function MappedIndexPropertyKeys(type, propertyKeys, options) {
3622
+ return propertyKeys.reduce((result, left) => {
3623
+ return { ...result, ...MappedIndexPropertyKey(type, left, options) };
3624
+ }, {});
3625
+ }
3626
+ function MappedIndexProperties(type, mappedKey, options) {
3627
+ return MappedIndexPropertyKeys(type, mappedKey.keys, options);
3628
+ }
3629
+ function IndexFromMappedKey(type, mappedKey, options) {
3630
+ const properties = MappedIndexProperties(type, mappedKey, options);
3631
+ return MappedResult(properties);
3632
+ }
3633
+
3634
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.mjs
3635
+ function Iterator(items, options) {
3636
+ return CreateType({ [Kind]: "Iterator", type: "Iterator", items }, options);
3637
+ }
3638
+
3639
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/object/object.mjs
3640
+ function RequiredArray(properties) {
3641
+ return globalThis.Object.keys(properties).filter((key) => !IsOptional(properties[key]));
3642
+ }
3643
+ function _Object(properties, options) {
3644
+ const required = RequiredArray(properties);
3645
+ const schema = required.length > 0 ? { [Kind]: "Object", type: "object", required, properties } : { [Kind]: "Object", type: "object", properties };
3646
+ return CreateType(schema, options);
3647
+ }
3648
+ var Object2 = _Object;
3649
+
3650
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/promise/promise.mjs
3651
+ function Promise2(item, options) {
3652
+ return CreateType({ [Kind]: "Promise", type: "Promise", item }, options);
3653
+ }
3654
+
3655
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.mjs
3656
+ function RemoveReadonly(schema) {
3657
+ return CreateType(Discard(schema, [ReadonlyKind]));
3658
+ }
3659
+ function AddReadonly(schema) {
3660
+ return CreateType({ ...schema, [ReadonlyKind]: "Readonly" });
3661
+ }
3662
+ function ReadonlyWithFlag(schema, F) {
3663
+ return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
3664
+ }
3665
+ function Readonly(schema, enable) {
3666
+ const F = enable ?? true;
3667
+ return IsMappedResult(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
3668
+ }
3669
+
3670
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.mjs
3671
+ function FromProperties2(K, F) {
3672
+ const Acc = {};
3673
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K))
3674
+ Acc[K2] = Readonly(K[K2], F);
3675
+ return Acc;
3676
+ }
3677
+ function FromMappedResult2(R, F) {
3678
+ return FromProperties2(R.properties, F);
3679
+ }
3680
+ function ReadonlyFromMappedResult(R, F) {
3681
+ const P = FromMappedResult2(R, F);
3682
+ return MappedResult(P);
3683
+ }
3684
+
3685
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.mjs
3686
+ function Tuple(types, options) {
3687
+ 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);
3688
+ }
3689
+
3690
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs
3691
+ function FromMappedResult3(K, P) {
3692
+ return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
3693
+ }
3694
+ function MappedKeyToKnownMappedResultProperties(K) {
3695
+ return { [K]: Literal(K) };
3696
+ }
3697
+ function MappedKeyToUnknownMappedResultProperties(P) {
3698
+ const Acc = {};
3699
+ for (const L of P)
3700
+ Acc[L] = Literal(L);
3701
+ return Acc;
3702
+ }
3703
+ function MappedKeyToMappedResultProperties(K, P) {
3704
+ return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
3705
+ }
3706
+ function FromMappedKey(K, P) {
3707
+ const R = MappedKeyToMappedResultProperties(K, P);
3708
+ return FromMappedResult3(K, R);
3709
+ }
3710
+ function FromRest2(K, T) {
3711
+ return T.map((L) => FromSchemaType(K, L));
3712
+ }
3713
+ function FromProperties3(K, T) {
3714
+ const Acc = {};
3715
+ for (const K2 of globalThis.Object.getOwnPropertyNames(T))
3716
+ Acc[K2] = FromSchemaType(K, T[K2]);
3717
+ return Acc;
3718
+ }
3719
+ function FromSchemaType(K, T) {
3720
+ const options = { ...T };
3721
+ return (
3722
+ // unevaluated modifier types
3723
+ IsOptional(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : (
3724
+ // unevaluated mapped types
3725
+ IsMappedResult(T) ? FromMappedResult3(K, T.properties) : IsMappedKey(T) ? FromMappedKey(K, T.keys) : (
3726
+ // unevaluated types
3727
+ 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
3728
+ )
3729
+ )
3730
+ );
3731
+ }
3732
+ function MappedFunctionReturnType(K, T) {
3733
+ const Acc = {};
3734
+ for (const L of K)
3735
+ Acc[L] = FromSchemaType(L, T);
3736
+ return Acc;
3737
+ }
3738
+ function Mapped(key, map, options) {
3739
+ const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
3740
+ const RT = map({ [Kind]: "MappedKey", keys: K });
3741
+ const R = MappedFunctionReturnType(K, RT);
3742
+ return Object2(R, options);
3743
+ }
3744
+
3745
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/optional/optional.mjs
3746
+ function RemoveOptional(schema) {
3747
+ return CreateType(Discard(schema, [OptionalKind]));
3748
+ }
3749
+ function AddOptional(schema) {
3750
+ return CreateType({ ...schema, [OptionalKind]: "Optional" });
3751
+ }
3752
+ function OptionalWithFlag(schema, F) {
3753
+ return F === false ? RemoveOptional(schema) : AddOptional(schema);
3754
+ }
3755
+ function Optional(schema, enable) {
3756
+ const F = enable ?? true;
3757
+ return IsMappedResult(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
3758
+ }
3759
+
3760
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.mjs
3761
+ function FromProperties4(P, F) {
3762
+ const Acc = {};
3763
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
3764
+ Acc[K2] = Optional(P[K2], F);
3765
+ return Acc;
3766
+ }
3767
+ function FromMappedResult4(R, F) {
3768
+ return FromProperties4(R.properties, F);
3769
+ }
3770
+ function OptionalFromMappedResult(R, F) {
3771
+ const P = FromMappedResult4(R, F);
3772
+ return MappedResult(P);
3773
+ }
3774
+
3775
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.mjs
3776
+ function IntersectCreate(T, options = {}) {
3777
+ const allObjects = T.every((schema) => IsObject3(schema));
3778
+ const clonedUnevaluatedProperties = IsSchema(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
3779
+ return CreateType(options.unevaluatedProperties === false || IsSchema(options.unevaluatedProperties) || allObjects ? { ...clonedUnevaluatedProperties, [Kind]: "Intersect", type: "object", allOf: T } : { ...clonedUnevaluatedProperties, [Kind]: "Intersect", allOf: T }, options);
3780
+ }
3781
+
3782
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.mjs
3783
+ function IsIntersectOptional(types) {
3784
+ return types.every((left) => IsOptional(left));
3785
+ }
3786
+ function RemoveOptionalFromType2(type) {
3787
+ return Discard(type, [OptionalKind]);
3788
+ }
3789
+ function RemoveOptionalFromRest2(types) {
3790
+ return types.map((left) => IsOptional(left) ? RemoveOptionalFromType2(left) : left);
3791
+ }
3792
+ function ResolveIntersect(types, options) {
3793
+ return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest2(types), options)) : IntersectCreate(RemoveOptionalFromRest2(types), options);
3794
+ }
3795
+ function IntersectEvaluated(types, options = {}) {
3796
+ if (types.length === 1)
3797
+ return CreateType(types[0], options);
3798
+ if (types.length === 0)
3799
+ return Never(options);
3800
+ if (types.some((schema) => IsTransform(schema)))
3801
+ throw new Error("Cannot intersect transform types");
3802
+ return ResolveIntersect(types, options);
3803
+ }
3804
+
3805
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.mjs
3806
+ function Intersect(types, options) {
3807
+ if (types.length === 1)
3808
+ return CreateType(types[0], options);
3809
+ if (types.length === 0)
3810
+ return Never(options);
3811
+ if (types.some((schema) => IsTransform(schema)))
3812
+ throw new Error("Cannot intersect transform types");
3813
+ return IntersectCreate(types, options);
3814
+ }
3815
+
3816
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/ref/ref.mjs
3817
+ function Ref(...args) {
3818
+ const [$ref, options] = typeof args[0] === "string" ? [args[0], args[1]] : [args[0].$id, args[1]];
3819
+ if (typeof $ref !== "string")
3820
+ throw new TypeBoxError("Ref: $ref must be a string");
3821
+ return CreateType({ [Kind]: "Ref", $ref }, options);
3822
+ }
3823
+
3824
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.mjs
3825
+ function FromComputed(target, parameters) {
3826
+ return Computed("Awaited", [Computed(target, parameters)]);
3827
+ }
3828
+ function FromRef($ref) {
3829
+ return Computed("Awaited", [Ref($ref)]);
3830
+ }
3831
+ function FromIntersect2(types) {
3832
+ return Intersect(FromRest3(types));
3833
+ }
3834
+ function FromUnion4(types) {
3835
+ return Union(FromRest3(types));
3836
+ }
3837
+ function FromPromise(type) {
3838
+ return Awaited(type);
3839
+ }
3840
+ function FromRest3(types) {
3841
+ return types.map((type) => Awaited(type));
3842
+ }
3843
+ function Awaited(type, options) {
3844
+ 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);
3845
+ }
3846
+
3847
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
3848
+ function FromRest4(types) {
3849
+ const result = [];
3850
+ for (const L of types)
3851
+ result.push(KeyOfPropertyKeys(L));
3852
+ return result;
3853
+ }
3854
+ function FromIntersect3(types) {
3855
+ const propertyKeysArray = FromRest4(types);
3856
+ const propertyKeys = SetUnionMany(propertyKeysArray);
3857
+ return propertyKeys;
3858
+ }
3859
+ function FromUnion5(types) {
3860
+ const propertyKeysArray = FromRest4(types);
3861
+ const propertyKeys = SetIntersectMany(propertyKeysArray);
3862
+ return propertyKeys;
3863
+ }
3864
+ function FromTuple2(types) {
3865
+ return types.map((_, indexer) => indexer.toString());
3866
+ }
3867
+ function FromArray2(_) {
3868
+ return ["[number]"];
3869
+ }
3870
+ function FromProperties5(T) {
3871
+ return globalThis.Object.getOwnPropertyNames(T);
3872
+ }
3873
+ function FromPatternProperties(patternProperties) {
3874
+ if (!includePatternProperties)
3875
+ return [];
3876
+ const patternPropertyKeys = globalThis.Object.getOwnPropertyNames(patternProperties);
3877
+ return patternPropertyKeys.map((key) => {
3878
+ return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
3879
+ });
3880
+ }
3881
+ function KeyOfPropertyKeys(type) {
3882
+ 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) : [];
3883
+ }
3884
+ var includePatternProperties = false;
3885
+
3886
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.mjs
3887
+ function FromComputed2(target, parameters) {
3888
+ return Computed("KeyOf", [Computed(target, parameters)]);
3889
+ }
3890
+ function FromRef2($ref) {
3891
+ return Computed("KeyOf", [Ref($ref)]);
3892
+ }
3893
+ function KeyOfFromType(type, options) {
3894
+ const propertyKeys = KeyOfPropertyKeys(type);
3895
+ const propertyKeyTypes = KeyOfPropertyKeysToRest(propertyKeys);
3896
+ const result = UnionEvaluated(propertyKeyTypes);
3897
+ return CreateType(result, options);
3898
+ }
3899
+ function KeyOfPropertyKeysToRest(propertyKeys) {
3900
+ return propertyKeys.map((L) => L === "[number]" ? Number2() : Literal(L));
3901
+ }
3902
+ function KeyOf(type, options) {
3903
+ return IsComputed(type) ? FromComputed2(type.target, type.parameters) : IsRef(type) ? FromRef2(type.$ref) : IsMappedResult(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
3904
+ }
3905
+
3906
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.mjs
3907
+ function FromProperties6(properties, options) {
3908
+ const result = {};
3909
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
3910
+ result[K2] = KeyOf(properties[K2], Clone(options));
3911
+ return result;
3912
+ }
3913
+ function FromMappedResult5(mappedResult, options) {
3914
+ return FromProperties6(mappedResult.properties, options);
3915
+ }
3916
+ function KeyOfFromMappedResult(mappedResult, options) {
3917
+ const properties = FromMappedResult5(mappedResult, options);
3918
+ return MappedResult(properties);
3919
+ }
3920
+
3921
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs
3922
+ function CompositeKeys(T) {
3923
+ const Acc = [];
3924
+ for (const L of T)
3925
+ Acc.push(...KeyOfPropertyKeys(L));
3926
+ return SetDistinct(Acc);
3927
+ }
3928
+ function FilterNever(T) {
3929
+ return T.filter((L) => !IsNever(L));
3930
+ }
3931
+ function CompositeProperty(T, K) {
3932
+ const Acc = [];
3933
+ for (const L of T)
3934
+ Acc.push(...IndexFromPropertyKeys(L, [K]));
3935
+ return FilterNever(Acc);
3936
+ }
3937
+ function CompositeProperties(T, K) {
3938
+ const Acc = {};
3939
+ for (const L of K) {
3940
+ Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
3941
+ }
3942
+ return Acc;
3943
+ }
3944
+ function Composite(T, options) {
3945
+ const K = CompositeKeys(T);
3946
+ const P = CompositeProperties(T, K);
3947
+ const R = Object2(P, options);
3948
+ return R;
3949
+ }
3950
+
3951
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/date/date.mjs
3952
+ function Date2(options) {
3953
+ return CreateType({ [Kind]: "Date", type: "Date" }, options);
3954
+ }
3955
+
3956
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/null/null.mjs
3957
+ function Null(options) {
3958
+ return CreateType({ [Kind]: "Null", type: "null" }, options);
3959
+ }
3960
+
3961
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.mjs
3962
+ function Symbol2(options) {
3963
+ return CreateType({ [Kind]: "Symbol", type: "symbol" }, options);
3964
+ }
3965
+
3966
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.mjs
3967
+ function Undefined(options) {
3968
+ return CreateType({ [Kind]: "Undefined", type: "undefined" }, options);
3969
+ }
3970
+
3971
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.mjs
3972
+ function Uint8Array2(options) {
3973
+ return CreateType({ [Kind]: "Uint8Array", type: "Uint8Array" }, options);
3974
+ }
3975
+
3976
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.mjs
3977
+ function Unknown(options) {
3978
+ return CreateType({ [Kind]: "Unknown" }, options);
3979
+ }
3980
+
3981
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/const/const.mjs
3982
+ function FromArray3(T) {
3983
+ return T.map((L) => FromValue(L, false));
3984
+ }
3985
+ function FromProperties7(value) {
3986
+ const Acc = {};
3987
+ for (const K of globalThis.Object.getOwnPropertyNames(value))
3988
+ Acc[K] = Readonly(FromValue(value[K], false));
3989
+ return Acc;
3990
+ }
3991
+ function ConditionalReadonly(T, root) {
3992
+ return root === true ? T : Readonly(T);
3993
+ }
3994
+ function FromValue(value, root) {
3995
+ 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({});
3996
+ }
3997
+ function Const(T, options) {
3998
+ return CreateType(FromValue(T, true), options);
3999
+ }
4000
+
4001
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.mjs
4002
+ function ConstructorParameters(schema, options) {
4003
+ return IsConstructor(schema) ? Tuple(schema.parameters, options) : Never(options);
4004
+ }
4005
+
4006
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/enum/enum.mjs
4007
+ function Enum(item, options) {
4008
+ if (IsUndefined(item))
4009
+ throw new Error("Enum undefined or empty");
4010
+ const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
4011
+ const values2 = [...new Set(values1)];
4012
+ const anyOf = values2.map((value) => Literal(value));
4013
+ return Union(anyOf, { ...options, [Hint]: "Enum" });
4014
+ }
4015
+
4016
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.mjs
4017
+ var ExtendsResolverError = class extends TypeBoxError {
4018
+ };
4019
+ var ExtendsResult;
4020
+ (function(ExtendsResult2) {
4021
+ ExtendsResult2[ExtendsResult2["Union"] = 0] = "Union";
4022
+ ExtendsResult2[ExtendsResult2["True"] = 1] = "True";
4023
+ ExtendsResult2[ExtendsResult2["False"] = 2] = "False";
4024
+ })(ExtendsResult || (ExtendsResult = {}));
4025
+ function IntoBooleanResult(result) {
4026
+ return result === ExtendsResult.False ? result : ExtendsResult.True;
4027
+ }
4028
+ function Throw(message) {
4029
+ throw new ExtendsResolverError(message);
4030
+ }
4031
+ function IsStructuralRight(right) {
4032
+ return type_exports.IsNever(right) || type_exports.IsIntersect(right) || type_exports.IsUnion(right) || type_exports.IsUnknown(right) || type_exports.IsAny(right);
4033
+ }
4034
+ function StructuralRight(left, right) {
4035
+ 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");
4036
+ }
4037
+ function FromAnyRight(left, right) {
4038
+ return ExtendsResult.True;
4039
+ }
4040
+ function FromAny(left, right) {
4041
+ 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;
4042
+ }
4043
+ function FromArrayRight(left, right) {
4044
+ return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
4045
+ }
4046
+ function FromArray4(left, right) {
4047
+ 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));
4048
+ }
4049
+ function FromAsyncIterator(left, right) {
4050
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
4051
+ }
4052
+ function FromBigInt(left, right) {
4053
+ 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;
4054
+ }
4055
+ function FromBooleanRight(left, right) {
4056
+ return type_exports.IsLiteralBoolean(left) ? ExtendsResult.True : type_exports.IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
4057
+ }
4058
+ function FromBoolean(left, right) {
4059
+ 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;
4060
+ }
4061
+ function FromConstructor(left, right) {
4062
+ 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));
4063
+ }
4064
+ function FromDate(left, right) {
4065
+ 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;
4066
+ }
4067
+ function FromFunction(left, right) {
4068
+ 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));
4069
+ }
4070
+ function FromIntegerRight(left, right) {
4071
+ return type_exports.IsLiteral(left) && value_exports.IsNumber(left.const) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
4072
+ }
4073
+ function FromInteger(left, right) {
4074
+ 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;
4075
+ }
4076
+ function FromIntersectRight(left, right) {
4077
+ return right.allOf.every((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
4078
+ }
4079
+ function FromIntersect4(left, right) {
4080
+ return left.allOf.some((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
4081
+ }
4082
+ function FromIterator(left, right) {
4083
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
4084
+ }
4085
+ function FromLiteral2(left, right) {
4086
+ 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;
4087
+ }
4088
+ function FromNeverRight(left, right) {
4089
+ return ExtendsResult.False;
4090
+ }
4091
+ function FromNever(left, right) {
4092
+ return ExtendsResult.True;
4093
+ }
4094
+ function UnwrapTNot(schema) {
4095
+ let [current, depth] = [schema, 0];
4096
+ while (true) {
4097
+ if (!type_exports.IsNot(current))
4098
+ break;
4099
+ current = current.not;
4100
+ depth += 1;
4101
+ }
4102
+ return depth % 2 === 0 ? current : Unknown();
4103
+ }
4104
+ function FromNot(left, right) {
4105
+ return type_exports.IsNot(left) ? Visit3(UnwrapTNot(left), right) : type_exports.IsNot(right) ? Visit3(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
4106
+ }
4107
+ function FromNull(left, right) {
4108
+ 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;
4109
+ }
4110
+ function FromNumberRight(left, right) {
4111
+ return type_exports.IsLiteralNumber(left) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
4112
+ }
4113
+ function FromNumber(left, right) {
4114
+ 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;
4115
+ }
4116
+ function IsObjectPropertyCount(schema, count) {
4117
+ return Object.getOwnPropertyNames(schema.properties).length === count;
4118
+ }
4119
+ function IsObjectStringLike(schema) {
4120
+ return IsObjectArrayLike(schema);
4121
+ }
4122
+ function IsObjectSymbolLike(schema) {
4123
+ 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]));
4124
+ }
4125
+ function IsObjectNumberLike(schema) {
4126
+ return IsObjectPropertyCount(schema, 0);
4127
+ }
4128
+ function IsObjectBooleanLike(schema) {
4129
+ return IsObjectPropertyCount(schema, 0);
4130
+ }
4131
+ function IsObjectBigIntLike(schema) {
4132
+ return IsObjectPropertyCount(schema, 0);
4133
+ }
4134
+ function IsObjectDateLike(schema) {
4135
+ return IsObjectPropertyCount(schema, 0);
4136
+ }
4137
+ function IsObjectUint8ArrayLike(schema) {
4138
+ return IsObjectArrayLike(schema);
4139
+ }
4140
+ function IsObjectFunctionLike(schema) {
4141
+ const length = Number2();
4142
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
4143
+ }
4144
+ function IsObjectConstructorLike(schema) {
4145
+ return IsObjectPropertyCount(schema, 0);
4146
+ }
4147
+ function IsObjectArrayLike(schema) {
4148
+ const length = Number2();
4149
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
4150
+ }
4151
+ function IsObjectPromiseLike(schema) {
4152
+ const then = Function([Any()], Any());
4153
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit3(schema.properties["then"], then)) === ExtendsResult.True;
4154
+ }
4155
+ function Property(left, right) {
4156
+ return Visit3(left, right) === ExtendsResult.False ? ExtendsResult.False : type_exports.IsOptional(left) && !type_exports.IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
4157
+ }
4158
+ function FromObjectRight(left, right) {
4159
+ 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)) ? (() => {
4160
+ return right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False;
4161
+ })() : type_exports.IsRecord(left) && type_exports.IsNumber(RecordKey(left)) ? (() => {
4162
+ return IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False;
4163
+ })() : ExtendsResult.False;
4164
+ }
4165
+ function FromObject(left, right) {
4166
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : !type_exports.IsObject(right) ? ExtendsResult.False : (() => {
4167
+ for (const key of Object.getOwnPropertyNames(right.properties)) {
4168
+ if (!(key in left.properties) && !type_exports.IsOptional(right.properties[key])) {
4169
+ return ExtendsResult.False;
4170
+ }
4171
+ if (type_exports.IsOptional(right.properties[key])) {
4172
+ return ExtendsResult.True;
4173
+ }
4174
+ if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) {
4175
+ return ExtendsResult.False;
4176
+ }
4177
+ }
4178
+ return ExtendsResult.True;
4179
+ })();
4180
+ }
4181
+ function FromPromise2(left, right) {
4182
+ 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));
4183
+ }
4184
+ function RecordKey(schema) {
4185
+ return PatternNumberExact in schema.patternProperties ? Number2() : PatternStringExact in schema.patternProperties ? String2() : Throw("Unknown record key pattern");
4186
+ }
4187
+ function RecordValue(schema) {
4188
+ return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
4189
+ }
4190
+ function FromRecordRight(left, right) {
4191
+ const [Key, Value] = [RecordKey(right), RecordValue(right)];
4192
+ 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) ? (() => {
4193
+ for (const key of Object.getOwnPropertyNames(left.properties)) {
4194
+ if (Property(Value, left.properties[key]) === ExtendsResult.False) {
4195
+ return ExtendsResult.False;
4196
+ }
4197
+ }
4198
+ return ExtendsResult.True;
4199
+ })() : ExtendsResult.False;
4200
+ }
4201
+ function FromRecord(left, right) {
4202
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsRecord(right) ? ExtendsResult.False : Visit3(RecordValue(left), RecordValue(right));
4203
+ }
4204
+ function FromRegExp(left, right) {
4205
+ const L = type_exports.IsRegExp(left) ? String2() : left;
4206
+ const R = type_exports.IsRegExp(right) ? String2() : right;
4207
+ return Visit3(L, R);
4208
+ }
4209
+ function FromStringRight(left, right) {
4210
+ return type_exports.IsLiteral(left) && value_exports.IsString(left.const) ? ExtendsResult.True : type_exports.IsString(left) ? ExtendsResult.True : ExtendsResult.False;
4211
+ }
4212
+ function FromString(left, right) {
4213
+ 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;
4214
+ }
4215
+ function FromSymbol(left, right) {
4216
+ 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;
4217
+ }
4218
+ function FromTemplateLiteral2(left, right) {
4219
+ return type_exports.IsTemplateLiteral(left) ? Visit3(TemplateLiteralToUnion(left), right) : type_exports.IsTemplateLiteral(right) ? Visit3(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
4220
+ }
4221
+ function IsArrayOfTuple(left, right) {
4222
+ return type_exports.IsArray(right) && left.items !== void 0 && left.items.every((schema) => Visit3(schema, right.items) === ExtendsResult.True);
4223
+ }
4224
+ function FromTupleRight(left, right) {
4225
+ return type_exports.IsNever(left) ? ExtendsResult.True : type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
4226
+ }
4227
+ function FromTuple3(left, right) {
4228
+ 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;
4229
+ }
4230
+ function FromUint8Array(left, right) {
4231
+ 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;
4232
+ }
4233
+ function FromUndefined(left, right) {
4234
+ 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;
4235
+ }
4236
+ function FromUnionRight(left, right) {
4237
+ return right.anyOf.some((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
4238
+ }
4239
+ function FromUnion6(left, right) {
4240
+ return left.anyOf.every((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
4241
+ }
4242
+ function FromUnknownRight(left, right) {
4243
+ return ExtendsResult.True;
4244
+ }
4245
+ function FromUnknown(left, right) {
4246
+ 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;
4247
+ }
4248
+ function FromVoidRight(left, right) {
4249
+ return type_exports.IsUndefined(left) ? ExtendsResult.True : type_exports.IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
4250
+ }
4251
+ function FromVoid(left, right) {
4252
+ 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;
4253
+ }
4254
+ function Visit3(left, right) {
4255
+ return (
4256
+ // resolvable
4257
+ 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) : (
4258
+ // standard
4259
+ 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]}'`)
4260
+ )
4261
+ );
4262
+ }
4263
+ function ExtendsCheck(left, right) {
4264
+ return Visit3(left, right);
4265
+ }
4266
+
4267
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.mjs
4268
+ function FromProperties8(P, Right, True, False, options) {
4269
+ const Acc = {};
4270
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
4271
+ Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
4272
+ return Acc;
4273
+ }
4274
+ function FromMappedResult6(Left, Right, True, False, options) {
4275
+ return FromProperties8(Left.properties, Right, True, False, options);
4276
+ }
4277
+ function ExtendsFromMappedResult(Left, Right, True, False, options) {
4278
+ const P = FromMappedResult6(Left, Right, True, False, options);
4279
+ return MappedResult(P);
4280
+ }
4281
+
4282
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extends/extends.mjs
4283
+ function ExtendsResolve(left, right, trueType, falseType) {
4284
+ const R = ExtendsCheck(left, right);
4285
+ return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
4286
+ }
4287
+ function Extends(L, R, T, F, options) {
4288
+ 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);
4289
+ }
4290
+
4291
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.mjs
4292
+ function FromPropertyKey(K, U, L, R, options) {
4293
+ return {
4294
+ [K]: Extends(Literal(K), U, L, R, Clone(options))
4295
+ };
4296
+ }
4297
+ function FromPropertyKeys(K, U, L, R, options) {
4298
+ return K.reduce((Acc, LK) => {
4299
+ return { ...Acc, ...FromPropertyKey(LK, U, L, R, options) };
4300
+ }, {});
4301
+ }
4302
+ function FromMappedKey2(K, U, L, R, options) {
4303
+ return FromPropertyKeys(K.keys, U, L, R, options);
4304
+ }
4305
+ function ExtendsFromMappedKey(T, U, L, R, options) {
4306
+ const P = FromMappedKey2(T, U, L, R, options);
4307
+ return MappedResult(P);
4308
+ }
4309
+
4310
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.mjs
4311
+ function ExcludeFromTemplateLiteral(L, R) {
4312
+ return Exclude(TemplateLiteralToUnion(L), R);
4313
+ }
4314
+
4315
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.mjs
4316
+ function ExcludeRest(L, R) {
4317
+ const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
4318
+ return excluded.length === 1 ? excluded[0] : Union(excluded);
4319
+ }
4320
+ function Exclude(L, R, options = {}) {
4321
+ if (IsTemplateLiteral(L))
4322
+ return CreateType(ExcludeFromTemplateLiteral(L, R), options);
4323
+ if (IsMappedResult(L))
4324
+ return CreateType(ExcludeFromMappedResult(L, R), options);
4325
+ return CreateType(IsUnion(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
4326
+ }
4327
+
4328
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.mjs
4329
+ function FromProperties9(P, U) {
4330
+ const Acc = {};
4331
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
4332
+ Acc[K2] = Exclude(P[K2], U);
4333
+ return Acc;
4334
+ }
4335
+ function FromMappedResult7(R, T) {
4336
+ return FromProperties9(R.properties, T);
4337
+ }
4338
+ function ExcludeFromMappedResult(R, T) {
4339
+ const P = FromMappedResult7(R, T);
4340
+ return MappedResult(P);
4341
+ }
4342
+
4343
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.mjs
4344
+ function ExtractFromTemplateLiteral(L, R) {
4345
+ return Extract(TemplateLiteralToUnion(L), R);
4346
+ }
4347
+
4348
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extract/extract.mjs
4349
+ function ExtractRest(L, R) {
4350
+ const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
4351
+ return extracted.length === 1 ? extracted[0] : Union(extracted);
4352
+ }
4353
+ function Extract(L, R, options) {
4354
+ if (IsTemplateLiteral(L))
4355
+ return CreateType(ExtractFromTemplateLiteral(L, R), options);
4356
+ if (IsMappedResult(L))
4357
+ return CreateType(ExtractFromMappedResult(L, R), options);
4358
+ return CreateType(IsUnion(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
4359
+ }
4360
+
4361
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.mjs
4362
+ function FromProperties10(P, T) {
4363
+ const Acc = {};
4364
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
4365
+ Acc[K2] = Extract(P[K2], T);
4366
+ return Acc;
4367
+ }
4368
+ function FromMappedResult8(R, T) {
4369
+ return FromProperties10(R.properties, T);
4370
+ }
4371
+ function ExtractFromMappedResult(R, T) {
4372
+ const P = FromMappedResult8(R, T);
4373
+ return MappedResult(P);
4374
+ }
4375
+
4376
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.mjs
4377
+ function InstanceType(schema, options) {
4378
+ return IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options);
4379
+ }
4380
+
4381
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.mjs
4382
+ function ReadonlyOptional(schema) {
4383
+ return Readonly(Optional(schema));
4384
+ }
4385
+
4386
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/record/record.mjs
4387
+ function RecordCreateFromPattern(pattern, T, options) {
4388
+ return CreateType({ [Kind]: "Record", type: "object", patternProperties: { [pattern]: T } }, options);
4389
+ }
4390
+ function RecordCreateFromKeys(K, T, options) {
4391
+ const result = {};
4392
+ for (const K2 of K)
4393
+ result[K2] = T;
4394
+ return Object2(result, { ...options, [Hint]: "Record" });
4395
+ }
4396
+ function FromTemplateLiteralKey(K, T, options) {
4397
+ return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
4398
+ }
4399
+ function FromUnionKey(key, type, options) {
4400
+ return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
4401
+ }
4402
+ function FromLiteralKey(key, type, options) {
4403
+ return RecordCreateFromKeys([key.toString()], type, options);
4404
+ }
4405
+ function FromRegExpKey(key, type, options) {
4406
+ return RecordCreateFromPattern(key.source, type, options);
4407
+ }
4408
+ function FromStringKey(key, type, options) {
4409
+ const pattern = IsUndefined(key.pattern) ? PatternStringExact : key.pattern;
4410
+ return RecordCreateFromPattern(pattern, type, options);
4411
+ }
4412
+ function FromAnyKey(_, type, options) {
4413
+ return RecordCreateFromPattern(PatternStringExact, type, options);
4414
+ }
4415
+ function FromNeverKey(_key, type, options) {
4416
+ return RecordCreateFromPattern(PatternNeverExact, type, options);
4417
+ }
4418
+ function FromBooleanKey(_key, type, options) {
4419
+ return Object2({ true: type, false: type }, options);
4420
+ }
4421
+ function FromIntegerKey(_key, type, options) {
4422
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
4423
+ }
4424
+ function FromNumberKey(_, type, options) {
4425
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
4426
+ }
4427
+ function Record(key, type, options = {}) {
4428
+ 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);
4429
+ }
4430
+ function RecordPattern(record) {
4431
+ return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
4432
+ }
4433
+ function RecordKey2(type) {
4434
+ const pattern = RecordPattern(type);
4435
+ return pattern === PatternStringExact ? String2() : pattern === PatternNumberExact ? Number2() : String2({ pattern });
4436
+ }
4437
+ function RecordValue2(type) {
4438
+ return type.patternProperties[RecordPattern(type)];
4439
+ }
4440
+
4441
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs
4442
+ function FromConstructor2(args, type) {
4443
+ type.parameters = FromTypes(args, type.parameters);
4444
+ type.returns = FromType(args, type.returns);
4445
+ return type;
4446
+ }
4447
+ function FromFunction2(args, type) {
4448
+ type.parameters = FromTypes(args, type.parameters);
4449
+ type.returns = FromType(args, type.returns);
4450
+ return type;
4451
+ }
4452
+ function FromIntersect5(args, type) {
4453
+ type.allOf = FromTypes(args, type.allOf);
4454
+ return type;
4455
+ }
4456
+ function FromUnion7(args, type) {
4457
+ type.anyOf = FromTypes(args, type.anyOf);
4458
+ return type;
4459
+ }
4460
+ function FromTuple4(args, type) {
4461
+ if (IsUndefined(type.items))
4462
+ return type;
4463
+ type.items = FromTypes(args, type.items);
4464
+ return type;
4465
+ }
4466
+ function FromArray5(args, type) {
4467
+ type.items = FromType(args, type.items);
4468
+ return type;
4469
+ }
4470
+ function FromAsyncIterator2(args, type) {
4471
+ type.items = FromType(args, type.items);
4472
+ return type;
4473
+ }
4474
+ function FromIterator2(args, type) {
4475
+ type.items = FromType(args, type.items);
4476
+ return type;
4477
+ }
4478
+ function FromPromise3(args, type) {
4479
+ type.item = FromType(args, type.item);
4480
+ return type;
4481
+ }
4482
+ function FromObject2(args, type) {
4483
+ const mappedProperties = FromProperties11(args, type.properties);
4484
+ return { ...type, ...Object2(mappedProperties) };
4485
+ }
4486
+ function FromRecord2(args, type) {
4487
+ const mappedKey = FromType(args, RecordKey2(type));
4488
+ const mappedValue = FromType(args, RecordValue2(type));
4489
+ const result = Record(mappedKey, mappedValue);
4490
+ return { ...type, ...result };
4491
+ }
4492
+ function FromArgument(args, argument) {
4493
+ return argument.index in args ? args[argument.index] : Unknown();
4494
+ }
4495
+ function FromProperty2(args, type) {
4496
+ const isReadonly = IsReadonly(type);
4497
+ const isOptional = IsOptional(type);
4498
+ const mapped = FromType(args, type);
4499
+ return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
4500
+ }
4501
+ function FromProperties11(args, properties) {
4502
+ return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
4503
+ return { ...result, [key]: FromProperty2(args, properties[key]) };
4504
+ }, {});
4505
+ }
4506
+ function FromTypes(args, types) {
4507
+ return types.map((type) => FromType(args, type));
4508
+ }
4509
+ function FromType(args, type) {
4510
+ 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;
4511
+ }
4512
+ function Instantiate(type, args) {
4513
+ return FromType(args, CloneType(type));
4514
+ }
4515
+
4516
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/integer/integer.mjs
4517
+ function Integer(options) {
4518
+ return CreateType({ [Kind]: "Integer", type: "integer" }, options);
4519
+ }
4520
+
4521
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs
4522
+ function MappedIntrinsicPropertyKey(K, M, options) {
4523
+ return {
4524
+ [K]: Intrinsic(Literal(K), M, Clone(options))
4525
+ };
4526
+ }
4527
+ function MappedIntrinsicPropertyKeys(K, M, options) {
4528
+ const result = K.reduce((Acc, L) => {
4529
+ return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
4530
+ }, {});
4531
+ return result;
4532
+ }
4533
+ function MappedIntrinsicProperties(T, M, options) {
4534
+ return MappedIntrinsicPropertyKeys(T["keys"], M, options);
4535
+ }
4536
+ function IntrinsicFromMappedKey(T, M, options) {
4537
+ const P = MappedIntrinsicProperties(T, M, options);
4538
+ return MappedResult(P);
4539
+ }
4540
+
4541
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.mjs
4542
+ function ApplyUncapitalize(value) {
4543
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
4544
+ return [first.toLowerCase(), rest].join("");
4545
+ }
4546
+ function ApplyCapitalize(value) {
4547
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
4548
+ return [first.toUpperCase(), rest].join("");
4549
+ }
4550
+ function ApplyUppercase(value) {
4551
+ return value.toUpperCase();
4552
+ }
4553
+ function ApplyLowercase(value) {
4554
+ return value.toLowerCase();
4555
+ }
4556
+ function FromTemplateLiteral3(schema, mode, options) {
4557
+ const expression = TemplateLiteralParseExact(schema.pattern);
4558
+ const finite = IsTemplateLiteralExpressionFinite(expression);
4559
+ if (!finite)
4560
+ return { ...schema, pattern: FromLiteralValue(schema.pattern, mode) };
4561
+ const strings = [...TemplateLiteralExpressionGenerate(expression)];
4562
+ const literals = strings.map((value) => Literal(value));
4563
+ const mapped = FromRest5(literals, mode);
4564
+ const union = Union(mapped);
4565
+ return TemplateLiteral([union], options);
4566
+ }
4567
+ function FromLiteralValue(value, mode) {
4568
+ return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
4569
+ }
4570
+ function FromRest5(T, M) {
4571
+ return T.map((L) => Intrinsic(L, M));
4572
+ }
4573
+ function Intrinsic(schema, mode, options = {}) {
4574
+ return (
4575
+ // Intrinsic-Mapped-Inference
4576
+ IsMappedKey(schema) ? IntrinsicFromMappedKey(schema, mode, options) : (
4577
+ // Standard-Inference
4578
+ IsTemplateLiteral(schema) ? FromTemplateLiteral3(schema, mode, options) : IsUnion(schema) ? Union(FromRest5(schema.anyOf, mode), options) : IsLiteral(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : (
4579
+ // Default Type
4580
+ CreateType(schema, options)
4581
+ )
4582
+ )
4583
+ );
4584
+ }
4585
+
4586
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.mjs
4587
+ function Capitalize(T, options = {}) {
4588
+ return Intrinsic(T, "Capitalize", options);
4589
+ }
4590
+
4591
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.mjs
4592
+ function Lowercase(T, options = {}) {
4593
+ return Intrinsic(T, "Lowercase", options);
4594
+ }
4595
+
4596
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.mjs
4597
+ function Uncapitalize(T, options = {}) {
4598
+ return Intrinsic(T, "Uncapitalize", options);
4599
+ }
4600
+
4601
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.mjs
4602
+ function Uppercase(T, options = {}) {
4603
+ return Intrinsic(T, "Uppercase", options);
4604
+ }
4605
+
4606
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.mjs
4607
+ function FromProperties12(properties, propertyKeys, options) {
4608
+ const result = {};
4609
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
4610
+ result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
4611
+ return result;
4612
+ }
4613
+ function FromMappedResult9(mappedResult, propertyKeys, options) {
4614
+ return FromProperties12(mappedResult.properties, propertyKeys, options);
4615
+ }
4616
+ function OmitFromMappedResult(mappedResult, propertyKeys, options) {
4617
+ const properties = FromMappedResult9(mappedResult, propertyKeys, options);
4618
+ return MappedResult(properties);
4619
+ }
4620
+
4621
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs
4622
+ function FromIntersect6(types, propertyKeys) {
4623
+ return types.map((type) => OmitResolve(type, propertyKeys));
4624
+ }
4625
+ function FromUnion8(types, propertyKeys) {
4626
+ return types.map((type) => OmitResolve(type, propertyKeys));
4627
+ }
4628
+ function FromProperty3(properties, key) {
4629
+ const { [key]: _, ...R } = properties;
4630
+ return R;
4631
+ }
4632
+ function FromProperties13(properties, propertyKeys) {
4633
+ return propertyKeys.reduce((T, K2) => FromProperty3(T, K2), properties);
4634
+ }
4635
+ function FromObject3(type, propertyKeys, properties) {
4636
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
4637
+ const mappedProperties = FromProperties13(properties, propertyKeys);
4638
+ return Object2(mappedProperties, options);
4639
+ }
4640
+ function UnionFromPropertyKeys(propertyKeys) {
4641
+ const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
4642
+ return Union(result);
4643
+ }
4644
+ function OmitResolve(type, propertyKeys) {
4645
+ return IsIntersect(type) ? Intersect(FromIntersect6(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion8(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject3(type, propertyKeys, type.properties) : Object2({});
4646
+ }
4647
+ function Omit(type, key, options) {
4648
+ const typeKey = IsArray(key) ? UnionFromPropertyKeys(key) : key;
4649
+ const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
4650
+ const isTypeRef = IsRef(type);
4651
+ const isKeyRef = IsRef(key);
4652
+ 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 });
4653
+ }
4654
+
4655
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.mjs
4656
+ function FromPropertyKey2(type, key, options) {
4657
+ return { [key]: Omit(type, [key], Clone(options)) };
4658
+ }
4659
+ function FromPropertyKeys2(type, propertyKeys, options) {
4660
+ return propertyKeys.reduce((Acc, LK) => {
4661
+ return { ...Acc, ...FromPropertyKey2(type, LK, options) };
4662
+ }, {});
4663
+ }
4664
+ function FromMappedKey3(type, mappedKey, options) {
4665
+ return FromPropertyKeys2(type, mappedKey.keys, options);
4666
+ }
4667
+ function OmitFromMappedKey(type, mappedKey, options) {
4668
+ const properties = FromMappedKey3(type, mappedKey, options);
4669
+ return MappedResult(properties);
4670
+ }
4671
+
4672
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.mjs
4673
+ function FromProperties14(properties, propertyKeys, options) {
4674
+ const result = {};
4675
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
4676
+ result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
4677
+ return result;
4678
+ }
4679
+ function FromMappedResult10(mappedResult, propertyKeys, options) {
4680
+ return FromProperties14(mappedResult.properties, propertyKeys, options);
4681
+ }
4682
+ function PickFromMappedResult(mappedResult, propertyKeys, options) {
4683
+ const properties = FromMappedResult10(mappedResult, propertyKeys, options);
4684
+ return MappedResult(properties);
4685
+ }
4686
+
4687
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs
4688
+ function FromIntersect7(types, propertyKeys) {
4689
+ return types.map((type) => PickResolve(type, propertyKeys));
4690
+ }
4691
+ function FromUnion9(types, propertyKeys) {
4692
+ return types.map((type) => PickResolve(type, propertyKeys));
4693
+ }
4694
+ function FromProperties15(properties, propertyKeys) {
4695
+ const result = {};
4696
+ for (const K2 of propertyKeys)
4697
+ if (K2 in properties)
4698
+ result[K2] = properties[K2];
4699
+ return result;
4700
+ }
4701
+ function FromObject4(Type2, keys, properties) {
4702
+ const options = Discard(Type2, [TransformKind, "$id", "required", "properties"]);
4703
+ const mappedProperties = FromProperties15(properties, keys);
4704
+ return Object2(mappedProperties, options);
4705
+ }
4706
+ function UnionFromPropertyKeys2(propertyKeys) {
4707
+ const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
4708
+ return Union(result);
4709
+ }
4710
+ function PickResolve(type, propertyKeys) {
4711
+ return IsIntersect(type) ? Intersect(FromIntersect7(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion9(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject4(type, propertyKeys, type.properties) : Object2({});
4712
+ }
4713
+ function Pick(type, key, options) {
4714
+ const typeKey = IsArray(key) ? UnionFromPropertyKeys2(key) : key;
4715
+ const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
4716
+ const isTypeRef = IsRef(type);
4717
+ const isKeyRef = IsRef(key);
4718
+ 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 });
4719
+ }
4720
+
4721
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.mjs
4722
+ function FromPropertyKey3(type, key, options) {
4723
+ return {
4724
+ [key]: Pick(type, [key], Clone(options))
4725
+ };
4726
+ }
4727
+ function FromPropertyKeys3(type, propertyKeys, options) {
4728
+ return propertyKeys.reduce((result, leftKey) => {
4729
+ return { ...result, ...FromPropertyKey3(type, leftKey, options) };
4730
+ }, {});
4731
+ }
4732
+ function FromMappedKey4(type, mappedKey, options) {
4733
+ return FromPropertyKeys3(type, mappedKey.keys, options);
4734
+ }
4735
+ function PickFromMappedKey(type, mappedKey, options) {
4736
+ const properties = FromMappedKey4(type, mappedKey, options);
4737
+ return MappedResult(properties);
4738
+ }
4739
+
4740
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs
4741
+ function FromComputed3(target, parameters) {
4742
+ return Computed("Partial", [Computed(target, parameters)]);
4743
+ }
4744
+ function FromRef3($ref) {
4745
+ return Computed("Partial", [Ref($ref)]);
4746
+ }
4747
+ function FromProperties16(properties) {
4748
+ const partialProperties = {};
4749
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
4750
+ partialProperties[K] = Optional(properties[K]);
4751
+ return partialProperties;
4752
+ }
4753
+ function FromObject5(type, properties) {
4754
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
4755
+ const mappedProperties = FromProperties16(properties);
4756
+ return Object2(mappedProperties, options);
4757
+ }
4758
+ function FromRest6(types) {
4759
+ return types.map((type) => PartialResolve(type));
4760
+ }
4761
+ function PartialResolve(type) {
4762
+ return (
4763
+ // Mappable
4764
+ 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) : (
4765
+ // Intrinsic
4766
+ 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 : (
4767
+ // Passthrough
4768
+ Object2({})
4769
+ )
4770
+ )
4771
+ );
4772
+ }
4773
+ function Partial(type, options) {
4774
+ if (IsMappedResult(type)) {
4775
+ return PartialFromMappedResult(type, options);
4776
+ } else {
4777
+ return CreateType({ ...PartialResolve(type), ...options });
4778
+ }
4779
+ }
4780
+
4781
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.mjs
4782
+ function FromProperties17(K, options) {
4783
+ const Acc = {};
4784
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K))
4785
+ Acc[K2] = Partial(K[K2], Clone(options));
4786
+ return Acc;
4787
+ }
4788
+ function FromMappedResult11(R, options) {
4789
+ return FromProperties17(R.properties, options);
4790
+ }
4791
+ function PartialFromMappedResult(R, options) {
4792
+ const P = FromMappedResult11(R, options);
4793
+ return MappedResult(P);
4794
+ }
4795
+
4796
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/required/required.mjs
4797
+ function FromComputed4(target, parameters) {
4798
+ return Computed("Required", [Computed(target, parameters)]);
4799
+ }
4800
+ function FromRef4($ref) {
4801
+ return Computed("Required", [Ref($ref)]);
4802
+ }
4803
+ function FromProperties18(properties) {
4804
+ const requiredProperties = {};
4805
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
4806
+ requiredProperties[K] = Discard(properties[K], [OptionalKind]);
4807
+ return requiredProperties;
4808
+ }
4809
+ function FromObject6(type, properties) {
4810
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
4811
+ const mappedProperties = FromProperties18(properties);
4812
+ return Object2(mappedProperties, options);
4813
+ }
4814
+ function FromRest7(types) {
4815
+ return types.map((type) => RequiredResolve(type));
4816
+ }
4817
+ function RequiredResolve(type) {
4818
+ return (
4819
+ // Mappable
4820
+ 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) : (
4821
+ // Intrinsic
4822
+ 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 : (
4823
+ // Passthrough
4824
+ Object2({})
4825
+ )
4826
+ )
4827
+ );
4828
+ }
4829
+ function Required(type, options) {
4830
+ if (IsMappedResult(type)) {
4831
+ return RequiredFromMappedResult(type, options);
4832
+ } else {
4833
+ return CreateType({ ...RequiredResolve(type), ...options });
4834
+ }
4835
+ }
4836
+
4837
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.mjs
4838
+ function FromProperties19(P, options) {
4839
+ const Acc = {};
4840
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
4841
+ Acc[K2] = Required(P[K2], options);
4842
+ return Acc;
4843
+ }
4844
+ function FromMappedResult12(R, options) {
4845
+ return FromProperties19(R.properties, options);
4846
+ }
4847
+ function RequiredFromMappedResult(R, options) {
4848
+ const P = FromMappedResult12(R, options);
4849
+ return MappedResult(P);
4850
+ }
4851
+
4852
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs
4853
+ function DereferenceParameters(moduleProperties, types) {
4854
+ return types.map((type) => {
4855
+ return IsRef(type) ? Dereference(moduleProperties, type.$ref) : FromType2(moduleProperties, type);
4856
+ });
4857
+ }
4858
+ function Dereference(moduleProperties, ref) {
4859
+ return ref in moduleProperties ? IsRef(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType2(moduleProperties, moduleProperties[ref]) : Never();
4860
+ }
4861
+ function FromAwaited(parameters) {
4862
+ return Awaited(parameters[0]);
4863
+ }
4864
+ function FromIndex(parameters) {
4865
+ return Index(parameters[0], parameters[1]);
4866
+ }
4867
+ function FromKeyOf(parameters) {
4868
+ return KeyOf(parameters[0]);
4869
+ }
4870
+ function FromPartial(parameters) {
4871
+ return Partial(parameters[0]);
4872
+ }
4873
+ function FromOmit(parameters) {
4874
+ return Omit(parameters[0], parameters[1]);
4875
+ }
4876
+ function FromPick(parameters) {
4877
+ return Pick(parameters[0], parameters[1]);
4878
+ }
4879
+ function FromRequired(parameters) {
4880
+ return Required(parameters[0]);
4881
+ }
4882
+ function FromComputed5(moduleProperties, target, parameters) {
4883
+ const dereferenced = DereferenceParameters(moduleProperties, parameters);
4884
+ 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();
4885
+ }
4886
+ function FromArray6(moduleProperties, type) {
4887
+ return Array2(FromType2(moduleProperties, type));
4888
+ }
4889
+ function FromAsyncIterator3(moduleProperties, type) {
4890
+ return AsyncIterator(FromType2(moduleProperties, type));
4891
+ }
4892
+ function FromConstructor3(moduleProperties, parameters, instanceType) {
4893
+ return Constructor(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, instanceType));
4894
+ }
4895
+ function FromFunction3(moduleProperties, parameters, returnType) {
4896
+ return Function(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, returnType));
4897
+ }
4898
+ function FromIntersect8(moduleProperties, types) {
4899
+ return Intersect(FromTypes2(moduleProperties, types));
4900
+ }
4901
+ function FromIterator3(moduleProperties, type) {
4902
+ return Iterator(FromType2(moduleProperties, type));
4903
+ }
4904
+ function FromObject7(moduleProperties, properties) {
4905
+ return Object2(globalThis.Object.keys(properties).reduce((result, key) => {
4906
+ return { ...result, [key]: FromType2(moduleProperties, properties[key]) };
4907
+ }, {}));
4908
+ }
4909
+ function FromRecord3(moduleProperties, type) {
4910
+ const [value, pattern] = [FromType2(moduleProperties, RecordValue2(type)), RecordPattern(type)];
4911
+ const result = CloneType(type);
4912
+ result.patternProperties[pattern] = value;
4913
+ return result;
4914
+ }
4915
+ function FromTransform(moduleProperties, transform) {
4916
+ return IsRef(transform) ? { ...Dereference(moduleProperties, transform.$ref), [TransformKind]: transform[TransformKind] } : transform;
4917
+ }
4918
+ function FromTuple5(moduleProperties, types) {
4919
+ return Tuple(FromTypes2(moduleProperties, types));
4920
+ }
4921
+ function FromUnion10(moduleProperties, types) {
4922
+ return Union(FromTypes2(moduleProperties, types));
4923
+ }
4924
+ function FromTypes2(moduleProperties, types) {
4925
+ return types.map((type) => FromType2(moduleProperties, type));
4926
+ }
4927
+ function FromType2(moduleProperties, type) {
4928
+ return (
4929
+ // Modifiers
4930
+ IsOptional(type) ? CreateType(FromType2(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType2(moduleProperties, Discard(type, [ReadonlyKind])), type) : (
4931
+ // Transform
4932
+ IsTransform(type) ? CreateType(FromTransform(moduleProperties, type), type) : (
4933
+ // Types
4934
+ 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
4935
+ )
4936
+ )
4937
+ );
4938
+ }
4939
+ function ComputeType(moduleProperties, key) {
4940
+ return key in moduleProperties ? FromType2(moduleProperties, moduleProperties[key]) : Never();
4941
+ }
4942
+ function ComputeModuleProperties(moduleProperties) {
4943
+ return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
4944
+ return { ...result, [key]: ComputeType(moduleProperties, key) };
4945
+ }, {});
4946
+ }
4947
+
4948
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/module/module.mjs
4949
+ var TModule = class {
4950
+ constructor($defs) {
4951
+ const computed = ComputeModuleProperties($defs);
4952
+ const identified = this.WithIdentifiers(computed);
4953
+ this.$defs = identified;
4954
+ }
4955
+ /** `[Json]` Imports a Type by Key. */
4956
+ Import(key, options) {
4957
+ const $defs = { ...this.$defs, [key]: CreateType(this.$defs[key], options) };
4958
+ return CreateType({ [Kind]: "Import", $defs, $ref: key });
4959
+ }
4960
+ // prettier-ignore
4961
+ WithIdentifiers($defs) {
4962
+ return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
4963
+ return { ...result, [key]: { ...$defs[key], $id: key } };
4964
+ }, {});
4965
+ }
4966
+ };
4967
+ function Module(properties) {
4968
+ return new TModule(properties);
4969
+ }
4970
+
4971
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/not/not.mjs
4972
+ function Not(type, options) {
4973
+ return CreateType({ [Kind]: "Not", not: type }, options);
4974
+ }
4975
+
4976
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.mjs
4977
+ function Parameters(schema, options) {
4978
+ return IsFunction2(schema) ? Tuple(schema.parameters, options) : Never();
4979
+ }
4980
+
4981
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.mjs
4982
+ var Ordinal = 0;
4983
+ function Recursive(callback, options = {}) {
4984
+ if (IsUndefined(options.$id))
4985
+ options.$id = `T${Ordinal++}`;
4986
+ const thisType = CloneType(callback({ [Kind]: "This", $ref: `${options.$id}` }));
4987
+ thisType.$id = options.$id;
4988
+ return CreateType({ [Hint]: "Recursive", ...thisType }, options);
4989
+ }
4990
+
4991
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.mjs
4992
+ function RegExp2(unresolved, options) {
4993
+ const expr = IsString(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
4994
+ return CreateType({ [Kind]: "RegExp", type: "RegExp", source: expr.source, flags: expr.flags }, options);
4995
+ }
4996
+
4997
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/rest/rest.mjs
4998
+ function RestResolve(T) {
4999
+ return IsIntersect(T) ? T.allOf : IsUnion(T) ? T.anyOf : IsTuple(T) ? T.items ?? [] : [];
5000
+ }
5001
+ function Rest(T) {
5002
+ return RestResolve(T);
5003
+ }
5004
+
5005
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.mjs
5006
+ function ReturnType(schema, options) {
5007
+ return IsFunction2(schema) ? CreateType(schema.returns, options) : Never(options);
5008
+ }
5009
+
5010
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/transform/transform.mjs
5011
+ var TransformDecodeBuilder = class {
5012
+ constructor(schema) {
5013
+ this.schema = schema;
5014
+ }
5015
+ Decode(decode) {
5016
+ return new TransformEncodeBuilder(this.schema, decode);
5017
+ }
5018
+ };
5019
+ var TransformEncodeBuilder = class {
5020
+ constructor(schema, decode) {
5021
+ this.schema = schema;
5022
+ this.decode = decode;
5023
+ }
5024
+ EncodeTransform(encode, schema) {
5025
+ const Encode = (value) => schema[TransformKind].Encode(encode(value));
5026
+ const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
5027
+ const Codec = { Encode, Decode };
5028
+ return { ...schema, [TransformKind]: Codec };
5029
+ }
5030
+ EncodeSchema(encode, schema) {
5031
+ const Codec = { Decode: this.decode, Encode: encode };
5032
+ return { ...schema, [TransformKind]: Codec };
5033
+ }
5034
+ Encode(encode) {
5035
+ return IsTransform(this.schema) ? this.EncodeTransform(encode, this.schema) : this.EncodeSchema(encode, this.schema);
5036
+ }
5037
+ };
5038
+ function Transform(schema) {
5039
+ return new TransformDecodeBuilder(schema);
5040
+ }
5041
+
5042
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.mjs
5043
+ function Unsafe(options = {}) {
5044
+ return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
5045
+ }
5046
+
5047
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/void/void.mjs
5048
+ function Void(options) {
5049
+ return CreateType({ [Kind]: "Void", type: "void" }, options);
5050
+ }
5051
+
5052
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/type/type.mjs
5053
+ var type_exports2 = {};
5054
+ __export(type_exports2, {
5055
+ Any: () => Any,
5056
+ Argument: () => Argument,
5057
+ Array: () => Array2,
5058
+ AsyncIterator: () => AsyncIterator,
5059
+ Awaited: () => Awaited,
5060
+ BigInt: () => BigInt,
5061
+ Boolean: () => Boolean2,
5062
+ Capitalize: () => Capitalize,
5063
+ Composite: () => Composite,
5064
+ Const: () => Const,
5065
+ Constructor: () => Constructor,
5066
+ ConstructorParameters: () => ConstructorParameters,
5067
+ Date: () => Date2,
5068
+ Enum: () => Enum,
5069
+ Exclude: () => Exclude,
5070
+ Extends: () => Extends,
5071
+ Extract: () => Extract,
5072
+ Function: () => Function,
5073
+ Index: () => Index,
5074
+ InstanceType: () => InstanceType,
5075
+ Instantiate: () => Instantiate,
5076
+ Integer: () => Integer,
5077
+ Intersect: () => Intersect,
5078
+ Iterator: () => Iterator,
5079
+ KeyOf: () => KeyOf,
5080
+ Literal: () => Literal,
5081
+ Lowercase: () => Lowercase,
5082
+ Mapped: () => Mapped,
5083
+ Module: () => Module,
5084
+ Never: () => Never,
5085
+ Not: () => Not,
5086
+ Null: () => Null,
5087
+ Number: () => Number2,
5088
+ Object: () => Object2,
5089
+ Omit: () => Omit,
5090
+ Optional: () => Optional,
5091
+ Parameters: () => Parameters,
5092
+ Partial: () => Partial,
5093
+ Pick: () => Pick,
5094
+ Promise: () => Promise2,
5095
+ Readonly: () => Readonly,
5096
+ ReadonlyOptional: () => ReadonlyOptional,
5097
+ Record: () => Record,
5098
+ Recursive: () => Recursive,
5099
+ Ref: () => Ref,
5100
+ RegExp: () => RegExp2,
5101
+ Required: () => Required,
5102
+ Rest: () => Rest,
5103
+ ReturnType: () => ReturnType,
5104
+ String: () => String2,
5105
+ Symbol: () => Symbol2,
5106
+ TemplateLiteral: () => TemplateLiteral,
5107
+ Transform: () => Transform,
5108
+ Tuple: () => Tuple,
5109
+ Uint8Array: () => Uint8Array2,
5110
+ Uncapitalize: () => Uncapitalize,
5111
+ Undefined: () => Undefined,
5112
+ Union: () => Union,
5113
+ Unknown: () => Unknown,
5114
+ Unsafe: () => Unsafe,
5115
+ Uppercase: () => Uppercase,
5116
+ Void: () => Void
5117
+ });
5118
+
5119
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/type/index.mjs
5120
+ var Type = type_exports2;
5121
+
5122
+ // ../../packages/runner-pi/dist/tool-refs.js
5123
+ var LOG_PREFIX2 = "[bunny-agent:pi-tool-ref]";
5124
+ function buildToolDefinitionsFromRefs(tools) {
5125
+ return tools.map((spec) => buildOne(spec));
5126
+ }
5127
+ function buildOne(spec) {
5128
+ const parameters = Type.Unsafe(spec.inputSchema);
5129
+ return {
5130
+ name: spec.name,
5131
+ label: spec.name,
5132
+ description: spec.description,
5133
+ parameters,
5134
+ async execute(_toolCallId, params, signal) {
5135
+ let response;
5136
+ try {
5137
+ response = await executeToolRef(spec, params, signal);
5138
+ } catch (error) {
5139
+ const message = error instanceof Error ? error.message : String(error);
5140
+ return transportErrorResult(spec.name, message);
5141
+ }
5142
+ if (response.status < 200 || response.status >= 300) {
5143
+ return statusErrorResult(spec.name, response.status, response.body);
5144
+ }
5145
+ return okResult(response.body);
5146
+ }
5147
+ };
5148
+ }
5149
+ async function executeToolRef(spec, params, signal) {
5150
+ switch (spec.runtime.type) {
5151
+ case "http":
5152
+ return sendDirectHttpRequest(spec.runtime, params, signal);
5153
+ case "module":
5154
+ return executeModuleTool(spec.runtime, params, signal);
5155
+ }
5156
+ }
5157
+ async function sendDirectHttpRequest(runtime, params, signal) {
5158
+ const response = await fetch(runtime.url, {
5159
+ method: "POST",
5160
+ signal,
5161
+ headers: {
5162
+ "Content-Type": "application/json",
5163
+ ...runtime.headers ?? {}
5164
+ },
5165
+ body: JSON.stringify(params)
5166
+ });
5167
+ const body = await response.text();
5168
+ return { status: response.status, body };
5169
+ }
5170
+ async function executeModuleTool(runtime, params, signal) {
5171
+ const mod = await import(runtime.module);
5172
+ const exportName = runtime.exportName ?? "execute";
5173
+ const fn = mod[exportName];
5174
+ if (typeof fn !== "function") {
5175
+ return {
5176
+ status: 500,
5177
+ body: `module tool export "${exportName}" is not a function`
5178
+ };
5179
+ }
5180
+ const result = await fn(params, { signal });
5181
+ return { status: 200, body: serializeResult(result) };
5182
+ }
5183
+ function okResult(text) {
5184
+ return {
5185
+ content: [{ type: "text", text }],
5186
+ details: void 0
5187
+ };
5188
+ }
5189
+ function statusErrorResult(toolName, status, body) {
5190
+ return {
5191
+ content: [
5192
+ {
5193
+ type: "text",
5194
+ text: `${LOG_PREFIX2} tool "${toolName}" failed (status ${status}): ${body}`
5195
+ }
5196
+ ],
5197
+ details: void 0
5198
+ };
5199
+ }
5200
+ function transportErrorResult(toolName, message) {
5201
+ return {
5202
+ content: [
5203
+ {
5204
+ type: "text",
5205
+ text: `${LOG_PREFIX2} tool "${toolName}" transport error: ${message}`
5206
+ }
5207
+ ],
5208
+ details: void 0
5209
+ };
5210
+ }
5211
+ function serializeResult(result) {
5212
+ if (typeof result === "string")
5213
+ return result;
5214
+ return JSON.stringify(result);
5215
+ }
5216
+
5217
+ // ../../packages/runner-pi/dist/pi-runner.js
5218
+ var LOG_PREFIX3 = "[bunny-agent:pi]";
5219
+ function parseModelSpec(model) {
5220
+ const trimmed = model.trim();
5221
+ const separator = trimmed.indexOf(":");
5222
+ if (separator <= 0 || separator === trimmed.length - 1) {
5223
+ throw new Error(`Invalid pi model "${model}". Expected format "<provider>:<model>", for example "google:gemini-2.5-pro".`);
5224
+ }
5225
+ return {
5226
+ provider: trimmed.slice(0, separator),
5227
+ modelName: trimmed.slice(separator + 1)
5228
+ };
5229
+ }
5230
+ function resolveImageModelName(chatProvider, env) {
5231
+ const spec = env?.IMAGE_GENERATION_MODEL;
5232
+ if (!spec)
5233
+ return void 0;
5234
+ try {
5235
+ const { provider, modelName } = parseModelSpec(spec);
5236
+ return provider === chatProvider ? modelName : void 0;
5237
+ } catch {
5238
+ return void 0;
5239
+ }
5240
+ }
5241
+ function getEnvValue(optionsEnv, name) {
5242
+ return optionsEnv?.[name] ?? process.env[name];
5243
+ }
5244
+ function applyModelOverrides(model, provider, optionsEnv) {
5245
+ if (model == null)
5246
+ return;
5247
+ const openAiBaseUrl = getEnvValue(optionsEnv, "OPENAI_BASE_URL");
5248
+ const geminiBaseUrl = getEnvValue(optionsEnv, "GEMINI_BASE_URL");
5249
+ const anthropicBaseUrl = getEnvValue(optionsEnv, "ANTHROPIC_BASE_URL");
5250
+ if (provider === "openai" && openAiBaseUrl) {
5251
+ model.baseUrl = openAiBaseUrl;
5252
+ } else if (provider === "google" && geminiBaseUrl) {
5253
+ model.baseUrl = geminiBaseUrl;
5254
+ } else if (provider === "anthropic" && anthropicBaseUrl) {
5255
+ model.baseUrl = anthropicBaseUrl;
5256
+ }
5257
+ }
5258
+ function getErrorFromAgentEndMessages(messages) {
5259
+ for (let i = messages.length - 1; i >= 0; i--) {
5260
+ const m = messages[i];
5261
+ if (m.role === "assistant" && m.errorMessage) {
5262
+ return m.errorMessage;
5263
+ }
5264
+ }
5265
+ return void 0;
5266
+ }
5267
+ function traceRawMessage(debugCwd, data, reset = false, optionsEnv) {
5268
+ const debugVal = getEnvValue(optionsEnv, "DEBUG");
5269
+ const enabled = debugVal === "true" || debugVal === "1";
5270
+ if (!enabled)
5271
+ return;
5272
+ try {
5273
+ const file = join8(debugCwd, "pi-message-stream-debug.json");
5274
+ if (reset && existsSync5(file))
5275
+ unlinkSync3(file);
5276
+ const type = data !== null && typeof data === "object" ? data.type : void 0;
5277
+ let payload = data;
5278
+ try {
5279
+ payload = data !== void 0 ? JSON.parse(JSON.stringify(data)) : void 0;
5280
+ } catch {
5281
+ payload = "[non-serializable]";
5282
+ }
5283
+ const entry = { _t: (/* @__PURE__ */ new Date()).toISOString(), type, payload };
5284
+ appendFileSync2(file, JSON.stringify(entry, null, 2) + ",\n");
5285
+ } catch {
5286
+ }
5287
+ }
5288
+ function createPiRunner(options = {}) {
5289
+ const modelSpec = options.model;
5290
+ if (modelSpec == null || modelSpec.trim() === "") {
5291
+ throw new Error("Pi runner: model is required. Pass a model in the form <provider>:<model>, e.g. openai:gpt-4o or google:gemini-2.5-flash.");
5292
+ }
5293
+ const { provider, modelName } = parseModelSpec(modelSpec.trim());
5294
+ const cwd = options.cwd || process.cwd();
5295
+ const apiKeyEnvKey = `${provider.toUpperCase().replace(/-/g, "_")}_API_KEY`;
5296
+ const inlineApiKey = typeof options.env?.[apiKeyEnvKey] === "string" && options.env[apiKeyEnvKey].length > 0 ? options.env[apiKeyEnvKey] : void 0;
5297
+ const modelRegistry = ModelRegistry.inMemory(AuthStorage.create());
5298
+ const defaultModel = getModel(provider, modelName);
5299
+ let model = defaultModel ?? modelRegistry.find(provider, modelName);
5300
+ if (model == null) {
5301
+ const baseUrlEnvKey = `${provider.toUpperCase().replace(/-/g, "_")}_BASE_URL`;
5302
+ const baseUrl = getEnvValue(options.env, baseUrlEnvKey) ?? getEnvValue(options.env, "OPENAI_BASE_URL");
5303
+ if (!baseUrl) {
5304
+ throw new Error(`Pi runner: model "${modelSpec}" not found in built-in catalog. Set ${baseUrlEnvKey} (or OPENAI_BASE_URL) to auto-register it.`);
5305
+ }
5306
+ modelRegistry.registerProvider(provider, {
5307
+ baseUrl,
5308
+ apiKey: inlineApiKey ?? apiKeyEnvKey,
5309
+ api: "openai-completions",
5310
+ models: [
5311
+ {
5312
+ id: modelName,
5313
+ name: modelName,
5314
+ reasoning: false,
5315
+ input: ["text", "image"],
5316
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
5317
+ contextWindow: 128e3,
5318
+ maxTokens: 8192
5319
+ }
5320
+ ]
5321
+ });
5322
+ const registered = modelRegistry.find(provider, modelName);
5323
+ if (!registered) {
5324
+ throw new Error(`Pi runner: failed to resolve model "${modelSpec}" after registration.`);
5325
+ }
5326
+ model = registered;
5327
+ }
5328
+ applyModelOverrides(model, provider, options.env);
5329
+ const imageModelName = resolveImageModelName(provider, options.env);
5330
+ return {
5331
+ async *run(userInput) {
5332
+ if (inlineApiKey !== void 0) {
5333
+ modelRegistry.authStorage.setRuntimeApiKey(provider, inlineApiKey);
5334
+ }
5335
+ try {
5336
+ const resume = options.sessionId?.trim();
5337
+ const sessionManager = await (async () => {
5338
+ if (resume !== void 0 && resume !== "") {
5339
+ if (resume.includes("/")) {
5340
+ return SessionManager2.open(resume);
5341
+ }
5342
+ const sessionPath2 = resolveSessionPathById(cwd, resume);
5343
+ console.error(`${LOG_PREFIX3} resume: id=${resume} path=${sessionPath2 ?? "(not found)"}`);
5344
+ if (sessionPath2) {
5345
+ if (isSessionFileTooLarge(sessionPath2)) {
5346
+ const context = extractSessionContext(sessionPath2);
5347
+ console.error(`${LOG_PREFIX3} session file too large, starting fresh${context ? " (with context)" : ""}`);
5348
+ const newMgr = SessionManager2.create(cwd);
5349
+ if (context) {
5350
+ const firstId = newMgr.getEntries()[0]?.id ?? "";
5351
+ newMgr.appendCompaction(context, firstId, 0);
5352
+ }
5353
+ return newMgr;
5354
+ }
5355
+ return SessionManager2.open(sessionPath2);
5356
+ }
5357
+ return SessionManager2.create(cwd);
5358
+ }
5359
+ return SessionManager2.create(cwd);
5360
+ })();
5361
+ const resourceLoader = options.skillPaths ? new BunnyAgentResourceLoader({
5362
+ cwd,
5363
+ skillPaths: options.skillPaths,
5364
+ appendSystemPrompt: options.systemPrompt
5365
+ }) : void 0;
5366
+ if (options.skillPaths && options.skillPaths.length > 0) {
5367
+ console.error(`${LOG_PREFIX3} runner: cwd=${cwd} skillPaths=${JSON.stringify(options.skillPaths)}`);
5368
+ }
5369
+ if (resourceLoader) {
5370
+ await resourceLoader.reload();
5371
+ }
5372
+ const customTools = options.env && Object.keys(options.env).length > 0 ? buildSecretAwareTools(cwd, options.env) : [];
5373
+ if (imageModelName) {
5374
+ const apiKey = await modelRegistry.authStorage.getApiKey(provider) ?? "";
5375
+ customTools.push(buildImageGenerateTool(cwd, imageModelName, model.baseUrl, apiKey), buildImageEditTool(cwd, imageModelName, model.baseUrl, apiKey));
5376
+ }
5377
+ if (options.customTools && options.customTools.length > 0) {
5378
+ customTools.push(...options.customTools);
5379
+ }
5380
+ if (options.toolRefs && options.toolRefs.length > 0) {
5381
+ customTools.push(...buildToolDefinitionsFromRefs(options.toolRefs));
5382
+ }
5383
+ const { session } = await createAgentSession({
5384
+ cwd,
5385
+ model,
5386
+ sessionManager,
5387
+ modelRegistry,
5388
+ resourceLoader,
5389
+ customTools
5390
+ });
5391
+ const eventQueue = [];
5392
+ let isComplete = false;
5393
+ let aborted = false;
5394
+ let wakeConsumer = null;
5395
+ const notify = () => {
5396
+ wakeConsumer?.();
5397
+ wakeConsumer = null;
2686
5398
  };
2687
5399
  const unsubscribe = session.subscribe((e) => {
2688
5400
  eventQueue.push(e);
@@ -2865,13 +5577,15 @@ function dispatchRunner(runner, base, cwd, options) {
2865
5577
  env: base.env,
2866
5578
  abortController: base.abortController
2867
5579
  }).run(options.userInput);
2868
- case "pi":
5580
+ case "pi": {
2869
5581
  return createPiRunner({
2870
5582
  ...base,
2871
5583
  cwd,
2872
5584
  sessionId: base.resume,
2873
- skillPaths: options.skillPaths ?? discoverSkillPaths(cwd)
5585
+ skillPaths: options.skillPaths ?? discoverSkillPaths(cwd),
5586
+ toolRefs: options.toolRefs
2874
5587
  }).run(options.userInput);
5588
+ }
2875
5589
  case "opencode":
2876
5590
  return createOpenCodeRunner({
2877
5591
  model: options.model,
@@ -2929,6 +5643,27 @@ async function runAgent(options) {
2929
5643
  config({ path: resolve3(process.cwd(), ".env") });
2930
5644
  config({ path: resolve3(process.cwd(), "../.env") });
2931
5645
  config({ path: resolve3(process.cwd(), "../../.env") });
5646
+ function takeToolRefsFromEnv() {
5647
+ const raw = process.env.BUNNY_AGENT_TOOL_REFS_JSON;
5648
+ if (!raw) return null;
5649
+ delete process.env.BUNNY_AGENT_TOOL_REFS_JSON;
5650
+ try {
5651
+ const parsed = JSON.parse(raw);
5652
+ if (!Array.isArray(parsed.tools)) {
5653
+ console.error(
5654
+ "[bunny-agent] BUNNY_AGENT_TOOL_REFS_JSON missing tools array; ignoring."
5655
+ );
5656
+ return null;
5657
+ }
5658
+ return parsed.tools;
5659
+ } catch (err) {
5660
+ const message = err instanceof Error ? err.message : String(err);
5661
+ console.error(
5662
+ `[bunny-agent] Failed to parse BUNNY_AGENT_TOOL_REFS_JSON: ${message}`
5663
+ );
5664
+ return null;
5665
+ }
5666
+ }
2932
5667
  function getSubcommand() {
2933
5668
  for (let i = 2; i < process.argv.length; i++) {
2934
5669
  const a = process.argv[i];
@@ -3141,6 +5876,7 @@ async function main() {
3141
5876
  case "run": {
3142
5877
  const args = parseRunArgs();
3143
5878
  process.chdir(args.cwd);
5879
+ const toolRefs = takeToolRefsFromEnv();
3144
5880
  await runAgent({
3145
5881
  runner: args.runner,
3146
5882
  model: args.model,
@@ -3150,7 +5886,8 @@ async function main() {
3150
5886
  allowedTools: args.allowedTools,
3151
5887
  skillPaths: args.skillPaths,
3152
5888
  resume: args.resume,
3153
- yolo: args.yolo
5889
+ yolo: args.yolo,
5890
+ ...toolRefs ? { toolRefs } : {}
3154
5891
  });
3155
5892
  break;
3156
5893
  }