@cremini/skillpack 1.2.5 → 1.2.7

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/cli.js CHANGED
@@ -329,6 +329,20 @@ var init_commands = __esm({
329
329
  }
330
330
  });
331
331
 
332
+ // src/runtime/adapters/types.ts
333
+ var types_exports = {};
334
+ __export(types_exports, {
335
+ isMessageSender: () => isMessageSender
336
+ });
337
+ function isMessageSender(adapter) {
338
+ return typeof adapter.sendMessage === "function";
339
+ }
340
+ var init_types = __esm({
341
+ "src/runtime/adapters/types.ts"() {
342
+ "use strict";
343
+ }
344
+ });
345
+
332
346
  // src/runtime/adapters/markdown.ts
333
347
  function unwrapMarkdownSourceBlocks(text) {
334
348
  return text.replace(
@@ -449,7 +463,7 @@ var telegram_exports = {};
449
463
  __export(telegram_exports, {
450
464
  TelegramAdapter: () => TelegramAdapter
451
465
  });
452
- import fs12 from "fs";
466
+ import fs13 from "fs";
453
467
  import TelegramBot from "node-telegram-bot-api";
454
468
  var MAX_MESSAGE_LENGTH, ACK_REACTION, TelegramAdapter;
455
469
  var init_telegram = __esm({
@@ -469,12 +483,14 @@ var init_telegram = __esm({
469
483
  agent = null;
470
484
  options;
471
485
  rootDir = "";
486
+ ipcBroadcaster = null;
472
487
  constructor(options) {
473
488
  this.options = options;
474
489
  }
475
490
  async start(ctx) {
476
491
  this.agent = ctx.agent;
477
492
  this.rootDir = ctx.rootDir;
493
+ this.ipcBroadcaster = ctx.ipcBroadcaster ?? null;
478
494
  this.bot = new TelegramBot(this.options.token, { polling: true });
479
495
  this.bot.on("message", (msg) => {
480
496
  this.handleTelegramMessage(msg).catch((err) => {
@@ -516,6 +532,15 @@ var init_telegram = __esm({
516
532
  const messageId = msg.message_id;
517
533
  const text = (msg.text || msg.caption || "").trim();
518
534
  const channelId = `telegram-${chatId}`;
535
+ this.ipcBroadcaster?.broadcastInbound(
536
+ channelId,
537
+ "telegram",
538
+ {
539
+ id: String(msg.from?.id || ""),
540
+ username: msg.from?.username || msg.from?.first_name || ""
541
+ },
542
+ text
543
+ );
519
544
  const attachments = await this.extractAttachments(msg, channelId);
520
545
  if (!text && attachments.length === 0) return;
521
546
  await this.tryAckReaction(chatId, messageId);
@@ -545,6 +570,7 @@ var init_telegram = __esm({
545
570
  });
546
571
  break;
547
572
  }
573
+ this.ipcBroadcaster?.broadcastAgentEvent(channelId, event);
548
574
  };
549
575
  try {
550
576
  const userText = text || "(User sent an attachment)";
@@ -755,7 +781,7 @@ var init_telegram = __esm({
755
781
  async sendFileSafe(chatId, filePath, caption) {
756
782
  if (!this.bot) return;
757
783
  try {
758
- if (!fs12.existsSync(filePath)) {
784
+ if (!fs13.existsSync(filePath)) {
759
785
  console.error(`[Telegram] File not found for sending: ${filePath}`);
760
786
  return;
761
787
  }
@@ -775,8 +801,8 @@ var slack_exports = {};
775
801
  __export(slack_exports, {
776
802
  SlackAdapter: () => SlackAdapter
777
803
  });
778
- import fs13 from "fs";
779
- import path12 from "path";
804
+ import fs14 from "fs";
805
+ import path13 from "path";
780
806
  import { App, LogLevel } from "@slack/bolt";
781
807
  var INLINE_COMMANDS, SLASH_COMMANDS, MAX_MESSAGE_LENGTH2, ACK_REACTION2, PROCESSING_MESSAGE, SlackAdapter;
782
808
  var init_slack = __esm({
@@ -807,12 +833,14 @@ var init_slack = __esm({
807
833
  botUserId = null;
808
834
  lastThreadByChannel = /* @__PURE__ */ new Map();
809
835
  rootDir = "";
836
+ ipcBroadcaster = null;
810
837
  constructor(options) {
811
838
  this.options = options;
812
839
  }
813
840
  async start(ctx) {
814
841
  this.agent = ctx.agent;
815
842
  this.rootDir = ctx.rootDir;
843
+ this.ipcBroadcaster = ctx.ipcBroadcaster ?? null;
816
844
  this.app = new App({
817
845
  token: this.options.botToken,
818
846
  appToken: this.options.appToken,
@@ -898,6 +926,15 @@ var init_slack = __esm({
898
926
  const teamId = this.getTeamId(body, context);
899
927
  const channelId = `slack-dm-${teamId}-${event.channel}`;
900
928
  const route = { channel: event.channel };
929
+ this.ipcBroadcaster?.broadcastInbound(
930
+ channelId,
931
+ "slack",
932
+ {
933
+ id: String(event.user || ""),
934
+ username: String(event.user || "")
935
+ },
936
+ text
937
+ );
901
938
  const attachments = await this.extractSlackFiles(event, channelId, client);
902
939
  if (!text && attachments.length === 0) return;
903
940
  await this.tryAckReaction(client, event);
@@ -928,6 +965,15 @@ var init_slack = __esm({
928
965
  threadTs
929
966
  );
930
967
  const text = this.stripBotMention(event.text || "").trim();
968
+ this.ipcBroadcaster?.broadcastInbound(
969
+ channelId,
970
+ "slack",
971
+ {
972
+ id: String(event.user || ""),
973
+ username: String(event.user || "")
974
+ },
975
+ text
976
+ );
931
977
  const attachments = await this.extractSlackFiles(event, channelId, client);
932
978
  if (!text && attachments.length === 0) {
933
979
  await this.sendSafe(
@@ -987,6 +1033,7 @@ var init_slack = __esm({
987
1033
  caption: event.caption
988
1034
  });
989
1035
  }
1036
+ this.ipcBroadcaster?.broadcastAgentEvent(channelId, event);
990
1037
  };
991
1038
  try {
992
1039
  const result = await this.agent.handleMessage(
@@ -1390,12 +1437,12 @@ var init_slack = __esm({
1390
1437
  */
1391
1438
  async sendFileSafe(client, route, filePath, caption) {
1392
1439
  try {
1393
- if (!fs13.existsSync(filePath)) {
1440
+ if (!fs14.existsSync(filePath)) {
1394
1441
  console.error(`[Slack] File not found for sending: ${filePath}`);
1395
1442
  return;
1396
1443
  }
1397
- const filename = path12.basename(filePath);
1398
- const fileContent = fs13.readFileSync(filePath);
1444
+ const filename = path13.basename(filePath);
1445
+ const fileContent = fs14.readFileSync(filePath);
1399
1446
  await client.files.uploadV2({
1400
1447
  channel_id: route.channel,
1401
1448
  thread_ts: route.threadTs,
@@ -1412,20 +1459,6 @@ var init_slack = __esm({
1412
1459
  }
1413
1460
  });
1414
1461
 
1415
- // src/runtime/adapters/types.ts
1416
- var types_exports = {};
1417
- __export(types_exports, {
1418
- isMessageSender: () => isMessageSender
1419
- });
1420
- function isMessageSender(adapter) {
1421
- return typeof adapter.sendMessage === "function";
1422
- }
1423
- var init_types = __esm({
1424
- "src/runtime/adapters/types.ts"() {
1425
- "use strict";
1426
- }
1427
- });
1428
-
1429
1462
  // src/runtime/adapters/scheduler.ts
1430
1463
  var scheduler_exports = {};
1431
1464
  __export(scheduler_exports, {
@@ -2436,15 +2469,15 @@ async function interactiveCreate(workDir) {
2436
2469
  }
2437
2470
 
2438
2471
  // src/commands/run.ts
2439
- import path14 from "path";
2440
- import fs15 from "fs";
2472
+ import path15 from "path";
2473
+ import fs16 from "fs";
2441
2474
  import inquirer2 from "inquirer";
2442
2475
  import chalk4 from "chalk";
2443
2476
 
2444
2477
  // src/runtime/server.ts
2445
2478
  import express from "express";
2446
- import path13 from "path";
2447
- import fs14 from "fs";
2479
+ import path14 from "path";
2480
+ import fs15 from "fs";
2448
2481
  import { fileURLToPath as fileURLToPath2 } from "url";
2449
2482
  import { createServer } from "http";
2450
2483
  import { exec } from "child_process";
@@ -2467,2734 +2500,128 @@ import {
2467
2500
  // src/runtime/tools/send-file-tool.ts
2468
2501
  import fs7 from "fs";
2469
2502
  import path7 from "path";
2470
-
2471
- // node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
2472
- var value_exports = {};
2473
- __export(value_exports, {
2474
- HasPropertyKey: () => HasPropertyKey,
2475
- IsArray: () => IsArray,
2476
- IsAsyncIterator: () => IsAsyncIterator,
2477
- IsBigInt: () => IsBigInt,
2478
- IsBoolean: () => IsBoolean,
2479
- IsDate: () => IsDate,
2480
- IsFunction: () => IsFunction,
2481
- IsIterator: () => IsIterator,
2482
- IsNull: () => IsNull,
2483
- IsNumber: () => IsNumber,
2484
- IsObject: () => IsObject,
2485
- IsRegExp: () => IsRegExp,
2486
- IsString: () => IsString,
2487
- IsSymbol: () => IsSymbol,
2488
- IsUint8Array: () => IsUint8Array,
2489
- IsUndefined: () => IsUndefined
2503
+ import { Type } from "@sinclair/typebox";
2504
+ var SendFileParams = Type.Object({
2505
+ filePath: Type.String({
2506
+ description: "Absolute path to the file to send to the user. The file must exist and be readable."
2507
+ }),
2508
+ caption: Type.Optional(
2509
+ Type.String({
2510
+ description: "Optional caption or description to accompany the file."
2511
+ })
2512
+ )
2490
2513
  });
2491
- function HasPropertyKey(value, key) {
2492
- return key in value;
2493
- }
2494
- function IsAsyncIterator(value) {
2495
- return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
2496
- }
2497
- function IsArray(value) {
2498
- return Array.isArray(value);
2499
- }
2500
- function IsBigInt(value) {
2501
- return typeof value === "bigint";
2502
- }
2503
- function IsBoolean(value) {
2504
- return typeof value === "boolean";
2505
- }
2506
- function IsDate(value) {
2507
- return value instanceof globalThis.Date;
2508
- }
2509
- function IsFunction(value) {
2510
- return typeof value === "function";
2511
- }
2512
- function IsIterator(value) {
2513
- return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.iterator in value;
2514
- }
2515
- function IsNull(value) {
2516
- return value === null;
2517
- }
2518
- function IsNumber(value) {
2519
- return typeof value === "number";
2520
- }
2521
- function IsObject(value) {
2522
- return typeof value === "object" && value !== null;
2523
- }
2524
- function IsRegExp(value) {
2525
- return value instanceof globalThis.RegExp;
2526
- }
2527
- function IsString(value) {
2528
- return typeof value === "string";
2529
- }
2530
- function IsSymbol(value) {
2531
- return typeof value === "symbol";
2532
- }
2533
- function IsUint8Array(value) {
2534
- return value instanceof globalThis.Uint8Array;
2535
- }
2536
- function IsUndefined(value) {
2537
- return value === void 0;
2538
- }
2539
-
2540
- // node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
2541
- function ArrayType(value) {
2542
- return value.map((value2) => Visit(value2));
2543
- }
2544
- function DateType(value) {
2545
- return new Date(value.getTime());
2546
- }
2547
- function Uint8ArrayType(value) {
2548
- return new Uint8Array(value);
2549
- }
2550
- function RegExpType(value) {
2551
- return new RegExp(value.source, value.flags);
2552
- }
2553
- function ObjectType(value) {
2554
- const result = {};
2555
- for (const key of Object.getOwnPropertyNames(value)) {
2556
- result[key] = Visit(value[key]);
2557
- }
2558
- for (const key of Object.getOwnPropertySymbols(value)) {
2559
- result[key] = Visit(value[key]);
2560
- }
2561
- return result;
2562
- }
2563
- function Visit(value) {
2564
- return IsArray(value) ? ArrayType(value) : IsDate(value) ? DateType(value) : IsUint8Array(value) ? Uint8ArrayType(value) : IsRegExp(value) ? RegExpType(value) : IsObject(value) ? ObjectType(value) : value;
2565
- }
2566
- function Clone(value) {
2567
- return Visit(value);
2568
- }
2569
-
2570
- // node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
2571
- function CloneType(schema, options) {
2572
- return options === void 0 ? Clone(schema) : Clone({ ...options, ...schema });
2573
- }
2574
-
2575
- // node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
2576
- function IsObject2(value) {
2577
- return value !== null && typeof value === "object";
2578
- }
2579
- function IsArray2(value) {
2580
- return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
2581
- }
2582
- function IsUndefined2(value) {
2583
- return value === void 0;
2584
- }
2585
- function IsNumber2(value) {
2586
- return typeof value === "number";
2587
- }
2588
-
2589
- // node_modules/@sinclair/typebox/build/esm/system/policy.mjs
2590
- var TypeSystemPolicy;
2591
- (function(TypeSystemPolicy2) {
2592
- TypeSystemPolicy2.InstanceMode = "default";
2593
- TypeSystemPolicy2.ExactOptionalPropertyTypes = false;
2594
- TypeSystemPolicy2.AllowArrayObject = false;
2595
- TypeSystemPolicy2.AllowNaN = false;
2596
- TypeSystemPolicy2.AllowNullVoid = false;
2597
- function IsExactOptionalProperty(value, key) {
2598
- return TypeSystemPolicy2.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
2599
- }
2600
- TypeSystemPolicy2.IsExactOptionalProperty = IsExactOptionalProperty;
2601
- function IsObjectLike(value) {
2602
- const isObject = IsObject2(value);
2603
- return TypeSystemPolicy2.AllowArrayObject ? isObject : isObject && !IsArray2(value);
2604
- }
2605
- TypeSystemPolicy2.IsObjectLike = IsObjectLike;
2606
- function IsRecordLike(value) {
2607
- return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
2608
- }
2609
- TypeSystemPolicy2.IsRecordLike = IsRecordLike;
2610
- function IsNumberLike(value) {
2611
- return TypeSystemPolicy2.AllowNaN ? IsNumber2(value) : Number.isFinite(value);
2612
- }
2613
- TypeSystemPolicy2.IsNumberLike = IsNumberLike;
2614
- function IsVoidLike(value) {
2615
- const isUndefined = IsUndefined2(value);
2616
- return TypeSystemPolicy2.AllowNullVoid ? isUndefined || value === null : isUndefined;
2617
- }
2618
- TypeSystemPolicy2.IsVoidLike = IsVoidLike;
2619
- })(TypeSystemPolicy || (TypeSystemPolicy = {}));
2620
-
2621
- // node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
2622
- function ImmutableArray(value) {
2623
- return globalThis.Object.freeze(value).map((value2) => Immutable(value2));
2624
- }
2625
- function ImmutableDate(value) {
2626
- return value;
2627
- }
2628
- function ImmutableUint8Array(value) {
2629
- return value;
2630
- }
2631
- function ImmutableRegExp(value) {
2632
- return value;
2633
- }
2634
- function ImmutableObject(value) {
2635
- const result = {};
2636
- for (const key of Object.getOwnPropertyNames(value)) {
2637
- result[key] = Immutable(value[key]);
2638
- }
2639
- for (const key of Object.getOwnPropertySymbols(value)) {
2640
- result[key] = Immutable(value[key]);
2641
- }
2642
- return globalThis.Object.freeze(result);
2643
- }
2644
- function Immutable(value) {
2645
- return IsArray(value) ? ImmutableArray(value) : IsDate(value) ? ImmutableDate(value) : IsUint8Array(value) ? ImmutableUint8Array(value) : IsRegExp(value) ? ImmutableRegExp(value) : IsObject(value) ? ImmutableObject(value) : value;
2646
- }
2647
-
2648
- // node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
2649
- function CreateType(schema, options) {
2650
- const result = options !== void 0 ? { ...options, ...schema } : schema;
2651
- switch (TypeSystemPolicy.InstanceMode) {
2652
- case "freeze":
2653
- return Immutable(result);
2654
- case "clone":
2655
- return Clone(result);
2656
- default:
2657
- return result;
2658
- }
2659
- }
2660
-
2661
- // node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
2662
- var TypeBoxError = class extends Error {
2663
- constructor(message) {
2664
- super(message);
2665
- }
2514
+ var MIME_BY_EXT = {
2515
+ ".png": "image/png",
2516
+ ".jpg": "image/jpeg",
2517
+ ".jpeg": "image/jpeg",
2518
+ ".gif": "image/gif",
2519
+ ".webp": "image/webp",
2520
+ ".svg": "image/svg+xml",
2521
+ ".pdf": "application/pdf",
2522
+ ".csv": "text/csv",
2523
+ ".json": "application/json",
2524
+ ".txt": "text/plain",
2525
+ ".md": "text/markdown",
2526
+ ".html": "text/html",
2527
+ ".xml": "application/xml",
2528
+ ".zip": "application/zip",
2529
+ ".mp3": "audio/mpeg",
2530
+ ".mp4": "video/mp4",
2531
+ ".wav": "audio/wav",
2532
+ ".ogg": "audio/ogg"
2666
2533
  };
2667
-
2668
- // node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
2669
- var TransformKind = /* @__PURE__ */ Symbol.for("TypeBox.Transform");
2670
- var ReadonlyKind = /* @__PURE__ */ Symbol.for("TypeBox.Readonly");
2671
- var OptionalKind = /* @__PURE__ */ Symbol.for("TypeBox.Optional");
2672
- var Hint = /* @__PURE__ */ Symbol.for("TypeBox.Hint");
2673
- var Kind = /* @__PURE__ */ Symbol.for("TypeBox.Kind");
2674
-
2675
- // node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
2676
- function IsReadonly(value) {
2677
- return IsObject(value) && value[ReadonlyKind] === "Readonly";
2678
- }
2679
- function IsOptional(value) {
2680
- return IsObject(value) && value[OptionalKind] === "Optional";
2681
- }
2682
- function IsAny(value) {
2683
- return IsKindOf(value, "Any");
2684
- }
2685
- function IsArgument(value) {
2686
- return IsKindOf(value, "Argument");
2687
- }
2688
- function IsArray3(value) {
2689
- return IsKindOf(value, "Array");
2690
- }
2691
- function IsAsyncIterator2(value) {
2692
- return IsKindOf(value, "AsyncIterator");
2693
- }
2694
- function IsBigInt2(value) {
2695
- return IsKindOf(value, "BigInt");
2696
- }
2697
- function IsBoolean2(value) {
2698
- return IsKindOf(value, "Boolean");
2699
- }
2700
- function IsComputed(value) {
2701
- return IsKindOf(value, "Computed");
2702
- }
2703
- function IsConstructor(value) {
2704
- return IsKindOf(value, "Constructor");
2705
- }
2706
- function IsDate2(value) {
2707
- return IsKindOf(value, "Date");
2708
- }
2709
- function IsFunction2(value) {
2710
- return IsKindOf(value, "Function");
2711
- }
2712
- function IsInteger(value) {
2713
- return IsKindOf(value, "Integer");
2714
- }
2715
- function IsIntersect(value) {
2716
- return IsKindOf(value, "Intersect");
2717
- }
2718
- function IsIterator2(value) {
2719
- return IsKindOf(value, "Iterator");
2720
- }
2721
- function IsKindOf(value, kind) {
2722
- return IsObject(value) && Kind in value && value[Kind] === kind;
2723
- }
2724
- function IsLiteralValue(value) {
2725
- return IsBoolean(value) || IsNumber(value) || IsString(value);
2726
- }
2727
- function IsLiteral(value) {
2728
- return IsKindOf(value, "Literal");
2729
- }
2730
- function IsMappedKey(value) {
2731
- return IsKindOf(value, "MappedKey");
2732
- }
2733
- function IsMappedResult(value) {
2734
- return IsKindOf(value, "MappedResult");
2735
- }
2736
- function IsNever(value) {
2737
- return IsKindOf(value, "Never");
2738
- }
2739
- function IsNot(value) {
2740
- return IsKindOf(value, "Not");
2741
- }
2742
- function IsNull2(value) {
2743
- return IsKindOf(value, "Null");
2744
- }
2745
- function IsNumber3(value) {
2746
- return IsKindOf(value, "Number");
2747
- }
2748
- function IsObject3(value) {
2749
- return IsKindOf(value, "Object");
2750
- }
2751
- function IsPromise(value) {
2752
- return IsKindOf(value, "Promise");
2753
- }
2754
- function IsRecord(value) {
2755
- return IsKindOf(value, "Record");
2756
- }
2757
- function IsRef(value) {
2758
- return IsKindOf(value, "Ref");
2759
- }
2760
- function IsRegExp2(value) {
2761
- return IsKindOf(value, "RegExp");
2762
- }
2763
- function IsString2(value) {
2764
- return IsKindOf(value, "String");
2765
- }
2766
- function IsSymbol2(value) {
2767
- return IsKindOf(value, "Symbol");
2768
- }
2769
- function IsTemplateLiteral(value) {
2770
- return IsKindOf(value, "TemplateLiteral");
2771
- }
2772
- function IsThis(value) {
2773
- return IsKindOf(value, "This");
2774
- }
2775
- function IsTransform(value) {
2776
- return IsObject(value) && TransformKind in value;
2777
- }
2778
- function IsTuple(value) {
2779
- return IsKindOf(value, "Tuple");
2780
- }
2781
- function IsUndefined3(value) {
2782
- return IsKindOf(value, "Undefined");
2783
- }
2784
- function IsUnion(value) {
2785
- return IsKindOf(value, "Union");
2786
- }
2787
- function IsUint8Array2(value) {
2788
- return IsKindOf(value, "Uint8Array");
2789
- }
2790
- function IsUnknown(value) {
2791
- return IsKindOf(value, "Unknown");
2792
- }
2793
- function IsUnsafe(value) {
2794
- return IsKindOf(value, "Unsafe");
2795
- }
2796
- function IsVoid(value) {
2797
- return IsKindOf(value, "Void");
2798
- }
2799
- function IsKind(value) {
2800
- return IsObject(value) && Kind in value && IsString(value[Kind]);
2534
+ function detectMimeType(filePath) {
2535
+ const ext = path7.extname(filePath).toLowerCase();
2536
+ return MIME_BY_EXT[ext];
2801
2537
  }
2802
- function IsSchema(value) {
2803
- 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);
2538
+ function createSendFileTool(fileOutputCallbackRef) {
2539
+ return {
2540
+ name: "send_file",
2541
+ label: "Send File",
2542
+ description: "Send a file to the user via the current chat channel (Telegram, Slack, or Web). IMPORTANT: Do NOT proactively send files. Only use this tool when the user EXPLICITLY asks you to send, share, or deliver a file (e.g. '\u628A\u6587\u4EF6\u53D1\u7ED9\u6211', 'send me the file', 'share the result'). Never send intermediate/temporary files. When the user asks, send only the specific file(s) the user requested, not all generated files.",
2543
+ promptSnippet: "send_file: Send a file to the user ONLY when they explicitly request it. Never send files proactively or automatically.",
2544
+ parameters: SendFileParams,
2545
+ async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
2546
+ const { filePath, caption } = params;
2547
+ if (!fs7.existsSync(filePath)) {
2548
+ return {
2549
+ content: [{ type: "text", text: `Error: File not found: ${filePath}` }],
2550
+ details: void 0
2551
+ };
2552
+ }
2553
+ const stats = fs7.statSync(filePath);
2554
+ if (!stats.isFile()) {
2555
+ return {
2556
+ content: [
2557
+ { type: "text", text: `Error: Path is not a file: ${filePath}` }
2558
+ ],
2559
+ details: void 0
2560
+ };
2561
+ }
2562
+ const filename = path7.basename(filePath);
2563
+ const mimeType = detectMimeType(filePath);
2564
+ const callback = fileOutputCallbackRef.current;
2565
+ if (callback) {
2566
+ callback({
2567
+ type: "file_output",
2568
+ filePath,
2569
+ filename,
2570
+ mimeType,
2571
+ caption
2572
+ });
2573
+ }
2574
+ const sizeKB = (stats.size / 1024).toFixed(1);
2575
+ return {
2576
+ content: [
2577
+ {
2578
+ type: "text",
2579
+ text: `File "${filename}" (${sizeKB}KB) has been sent to the user.`
2580
+ }
2581
+ ],
2582
+ details: void 0
2583
+ };
2584
+ }
2585
+ };
2804
2586
  }
2805
2587
 
2806
- // node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
2807
- var type_exports = {};
2808
- __export(type_exports, {
2809
- IsAny: () => IsAny2,
2810
- IsArgument: () => IsArgument2,
2811
- IsArray: () => IsArray4,
2812
- IsAsyncIterator: () => IsAsyncIterator3,
2813
- IsBigInt: () => IsBigInt3,
2814
- IsBoolean: () => IsBoolean3,
2815
- IsComputed: () => IsComputed2,
2816
- IsConstructor: () => IsConstructor2,
2817
- IsDate: () => IsDate3,
2818
- IsFunction: () => IsFunction3,
2819
- IsImport: () => IsImport,
2820
- IsInteger: () => IsInteger2,
2821
- IsIntersect: () => IsIntersect2,
2822
- IsIterator: () => IsIterator3,
2823
- IsKind: () => IsKind2,
2824
- IsKindOf: () => IsKindOf2,
2825
- IsLiteral: () => IsLiteral2,
2826
- IsLiteralBoolean: () => IsLiteralBoolean,
2827
- IsLiteralNumber: () => IsLiteralNumber,
2828
- IsLiteralString: () => IsLiteralString,
2829
- IsLiteralValue: () => IsLiteralValue2,
2830
- IsMappedKey: () => IsMappedKey2,
2831
- IsMappedResult: () => IsMappedResult2,
2832
- IsNever: () => IsNever2,
2833
- IsNot: () => IsNot2,
2834
- IsNull: () => IsNull3,
2835
- IsNumber: () => IsNumber4,
2836
- IsObject: () => IsObject4,
2837
- IsOptional: () => IsOptional2,
2838
- IsPromise: () => IsPromise2,
2839
- IsProperties: () => IsProperties,
2840
- IsReadonly: () => IsReadonly2,
2841
- IsRecord: () => IsRecord2,
2842
- IsRecursive: () => IsRecursive,
2843
- IsRef: () => IsRef2,
2844
- IsRegExp: () => IsRegExp3,
2845
- IsSchema: () => IsSchema2,
2846
- IsString: () => IsString3,
2847
- IsSymbol: () => IsSymbol3,
2848
- IsTemplateLiteral: () => IsTemplateLiteral2,
2849
- IsThis: () => IsThis2,
2850
- IsTransform: () => IsTransform2,
2851
- IsTuple: () => IsTuple2,
2852
- IsUint8Array: () => IsUint8Array3,
2853
- IsUndefined: () => IsUndefined4,
2854
- IsUnion: () => IsUnion2,
2855
- IsUnionLiteral: () => IsUnionLiteral,
2856
- IsUnknown: () => IsUnknown2,
2857
- IsUnsafe: () => IsUnsafe2,
2858
- IsVoid: () => IsVoid2,
2859
- TypeGuardUnknownTypeError: () => TypeGuardUnknownTypeError
2588
+ // src/runtime/tools/manage-schedule-tool.ts
2589
+ import { Type as Type2 } from "@sinclair/typebox";
2590
+ var ManageScheduleParams = Type2.Object({
2591
+ action: Type2.Union(
2592
+ [
2593
+ Type2.Literal("add"),
2594
+ Type2.Literal("list"),
2595
+ Type2.Literal("remove"),
2596
+ Type2.Literal("trigger"),
2597
+ Type2.Literal("enable"),
2598
+ Type2.Literal("disable")
2599
+ ],
2600
+ { description: "The action to perform." }
2601
+ ),
2602
+ name: Type2.Optional(
2603
+ Type2.String({
2604
+ description: "Unique name for the scheduled task. Required for add/remove/trigger/enable/disable."
2605
+ })
2606
+ ),
2607
+ cron: Type2.Optional(
2608
+ Type2.String({
2609
+ description: "Cron expression (5 fields: minute hour day month weekday). Required for add."
2610
+ })
2611
+ ),
2612
+ prompt: Type2.Optional(
2613
+ Type2.String({
2614
+ description: "The work prompt to execute when the task triggers. Required for add. Describe only what to do each run; do not repeat timing, cron, or 'every N minutes' instructions here."
2615
+ })
2616
+ ),
2617
+ timezone: Type2.Optional(
2618
+ Type2.String({
2619
+ description: "Optional timezone for the cron schedule, e.g. 'Asia/Shanghai', 'America/New_York'."
2620
+ })
2621
+ )
2860
2622
  });
2861
- var TypeGuardUnknownTypeError = class extends TypeBoxError {
2862
- };
2863
- var KnownTypes = [
2864
- "Argument",
2865
- "Any",
2866
- "Array",
2867
- "AsyncIterator",
2868
- "BigInt",
2869
- "Boolean",
2870
- "Computed",
2871
- "Constructor",
2872
- "Date",
2873
- "Enum",
2874
- "Function",
2875
- "Integer",
2876
- "Intersect",
2877
- "Iterator",
2878
- "Literal",
2879
- "MappedKey",
2880
- "MappedResult",
2881
- "Not",
2882
- "Null",
2883
- "Number",
2884
- "Object",
2885
- "Promise",
2886
- "Record",
2887
- "Ref",
2888
- "RegExp",
2889
- "String",
2890
- "Symbol",
2891
- "TemplateLiteral",
2892
- "This",
2893
- "Tuple",
2894
- "Undefined",
2895
- "Union",
2896
- "Uint8Array",
2897
- "Unknown",
2898
- "Void"
2899
- ];
2900
- function IsPattern(value) {
2901
- try {
2902
- new RegExp(value);
2903
- return true;
2904
- } catch {
2905
- return false;
2906
- }
2907
- }
2908
- function IsControlCharacterFree(value) {
2909
- if (!IsString(value))
2910
- return false;
2911
- for (let i = 0; i < value.length; i++) {
2912
- const code = value.charCodeAt(i);
2913
- if (code >= 7 && code <= 13 || code === 27 || code === 127) {
2914
- return false;
2915
- }
2916
- }
2917
- return true;
2918
- }
2919
- function IsAdditionalProperties(value) {
2920
- return IsOptionalBoolean(value) || IsSchema2(value);
2921
- }
2922
- function IsOptionalBigInt(value) {
2923
- return IsUndefined(value) || IsBigInt(value);
2924
- }
2925
- function IsOptionalNumber(value) {
2926
- return IsUndefined(value) || IsNumber(value);
2927
- }
2928
- function IsOptionalBoolean(value) {
2929
- return IsUndefined(value) || IsBoolean(value);
2930
- }
2931
- function IsOptionalString(value) {
2932
- return IsUndefined(value) || IsString(value);
2933
- }
2934
- function IsOptionalPattern(value) {
2935
- return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value) && IsPattern(value);
2936
- }
2937
- function IsOptionalFormat(value) {
2938
- return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value);
2939
- }
2940
- function IsOptionalSchema(value) {
2941
- return IsUndefined(value) || IsSchema2(value);
2942
- }
2943
- function IsReadonly2(value) {
2944
- return IsObject(value) && value[ReadonlyKind] === "Readonly";
2945
- }
2946
- function IsOptional2(value) {
2947
- return IsObject(value) && value[OptionalKind] === "Optional";
2948
- }
2949
- function IsAny2(value) {
2950
- return IsKindOf2(value, "Any") && IsOptionalString(value.$id);
2951
- }
2952
- function IsArgument2(value) {
2953
- return IsKindOf2(value, "Argument") && IsNumber(value.index);
2954
- }
2955
- function IsArray4(value) {
2956
- 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);
2957
- }
2958
- function IsAsyncIterator3(value) {
2959
- return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
2960
- }
2961
- function IsBigInt3(value) {
2962
- 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);
2963
- }
2964
- function IsBoolean3(value) {
2965
- return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
2966
- }
2967
- function IsComputed2(value) {
2968
- return IsKindOf2(value, "Computed") && IsString(value.target) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema));
2969
- }
2970
- function IsConstructor2(value) {
2971
- return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
2972
- }
2973
- function IsDate3(value) {
2974
- 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);
2975
- }
2976
- function IsFunction3(value) {
2977
- return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
2978
- }
2979
- function IsImport(value) {
2980
- return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
2981
- }
2982
- function IsInteger2(value) {
2983
- 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);
2984
- }
2985
- function IsProperties(value) {
2986
- return IsObject(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema2(schema));
2987
- }
2988
- function IsIntersect2(value) {
2989
- 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);
2990
- }
2991
- function IsIterator3(value) {
2992
- return IsKindOf2(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
2993
- }
2994
- function IsKindOf2(value, kind) {
2995
- return IsObject(value) && Kind in value && value[Kind] === kind;
2996
- }
2997
- function IsLiteralString(value) {
2998
- return IsLiteral2(value) && IsString(value.const);
2999
- }
3000
- function IsLiteralNumber(value) {
3001
- return IsLiteral2(value) && IsNumber(value.const);
3002
- }
3003
- function IsLiteralBoolean(value) {
3004
- return IsLiteral2(value) && IsBoolean(value.const);
3005
- }
3006
- function IsLiteral2(value) {
3007
- return IsKindOf2(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue2(value.const);
3008
- }
3009
- function IsLiteralValue2(value) {
3010
- return IsBoolean(value) || IsNumber(value) || IsString(value);
3011
- }
3012
- function IsMappedKey2(value) {
3013
- return IsKindOf2(value, "MappedKey") && IsArray(value.keys) && value.keys.every((key) => IsNumber(key) || IsString(key));
3014
- }
3015
- function IsMappedResult2(value) {
3016
- return IsKindOf2(value, "MappedResult") && IsProperties(value.properties);
3017
- }
3018
- function IsNever2(value) {
3019
- return IsKindOf2(value, "Never") && IsObject(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
3020
- }
3021
- function IsNot2(value) {
3022
- return IsKindOf2(value, "Not") && IsSchema2(value.not);
3023
- }
3024
- function IsNull3(value) {
3025
- return IsKindOf2(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
3026
- }
3027
- function IsNumber4(value) {
3028
- 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);
3029
- }
3030
- function IsObject4(value) {
3031
- return IsKindOf2(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
3032
- }
3033
- function IsPromise2(value) {
3034
- return IsKindOf2(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema2(value.item);
3035
- }
3036
- function IsRecord2(value) {
3037
- return IsKindOf2(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject(value.patternProperties) && ((schema) => {
3038
- const keys = Object.getOwnPropertyNames(schema.patternProperties);
3039
- return keys.length === 1 && IsPattern(keys[0]) && IsObject(schema.patternProperties) && IsSchema2(schema.patternProperties[keys[0]]);
3040
- })(value);
3041
- }
3042
- function IsRecursive(value) {
3043
- return IsObject(value) && Hint in value && value[Hint] === "Recursive";
3044
- }
3045
- function IsRef2(value) {
3046
- return IsKindOf2(value, "Ref") && IsOptionalString(value.$id) && IsString(value.$ref);
3047
- }
3048
- function IsRegExp3(value) {
3049
- return IsKindOf2(value, "RegExp") && IsOptionalString(value.$id) && IsString(value.source) && IsString(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
3050
- }
3051
- function IsString3(value) {
3052
- return IsKindOf2(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
3053
- }
3054
- function IsSymbol3(value) {
3055
- return IsKindOf2(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
3056
- }
3057
- function IsTemplateLiteral2(value) {
3058
- return IsKindOf2(value, "TemplateLiteral") && value.type === "string" && IsString(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
3059
- }
3060
- function IsThis2(value) {
3061
- return IsKindOf2(value, "This") && IsOptionalString(value.$id) && IsString(value.$ref);
3062
- }
3063
- function IsTransform2(value) {
3064
- return IsObject(value) && TransformKind in value;
3065
- }
3066
- function IsTuple2(value) {
3067
- return IsKindOf2(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber(value.minItems) && IsNumber(value.maxItems) && value.minItems === value.maxItems && // empty
3068
- (IsUndefined(value.items) && IsUndefined(value.additionalItems) && value.minItems === 0 || IsArray(value.items) && value.items.every((schema) => IsSchema2(schema)));
3069
- }
3070
- function IsUndefined4(value) {
3071
- return IsKindOf2(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
3072
- }
3073
- function IsUnionLiteral(value) {
3074
- return IsUnion2(value) && value.anyOf.every((schema) => IsLiteralString(schema) || IsLiteralNumber(schema));
3075
- }
3076
- function IsUnion2(value) {
3077
- return IsKindOf2(value, "Union") && IsOptionalString(value.$id) && IsObject(value) && IsArray(value.anyOf) && value.anyOf.every((schema) => IsSchema2(schema));
3078
- }
3079
- function IsUint8Array3(value) {
3080
- return IsKindOf2(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
3081
- }
3082
- function IsUnknown2(value) {
3083
- return IsKindOf2(value, "Unknown") && IsOptionalString(value.$id);
3084
- }
3085
- function IsUnsafe2(value) {
3086
- return IsKindOf2(value, "Unsafe");
3087
- }
3088
- function IsVoid2(value) {
3089
- return IsKindOf2(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
3090
- }
3091
- function IsKind2(value) {
3092
- return IsObject(value) && Kind in value && IsString(value[Kind]) && !KnownTypes.includes(value[Kind]);
3093
- }
3094
- function IsSchema2(value) {
3095
- 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));
3096
- }
3097
-
3098
- // node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.mjs
3099
- var PatternBoolean = "(true|false)";
3100
- var PatternNumber = "(0|[1-9][0-9]*)";
3101
- var PatternString = "(.*)";
3102
- var PatternNever = "(?!.*)";
3103
- var PatternBooleanExact = `^${PatternBoolean}$`;
3104
- var PatternNumberExact = `^${PatternNumber}$`;
3105
- var PatternStringExact = `^${PatternString}$`;
3106
- var PatternNeverExact = `^${PatternNever}$`;
3107
-
3108
- // node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
3109
- function SetIncludes(T, S) {
3110
- return T.includes(S);
3111
- }
3112
- function SetDistinct(T) {
3113
- return [...new Set(T)];
3114
- }
3115
- function SetIntersect(T, S) {
3116
- return T.filter((L) => S.includes(L));
3117
- }
3118
- function SetIntersectManyResolve(T, Init) {
3119
- return T.reduce((Acc, L) => {
3120
- return SetIntersect(Acc, L);
3121
- }, Init);
3122
- }
3123
- function SetIntersectMany(T) {
3124
- return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
3125
- }
3126
- function SetUnionMany(T) {
3127
- const Acc = [];
3128
- for (const L of T)
3129
- Acc.push(...L);
3130
- return Acc;
3131
- }
3132
-
3133
- // node_modules/@sinclair/typebox/build/esm/type/any/any.mjs
3134
- function Any(options) {
3135
- return CreateType({ [Kind]: "Any" }, options);
3136
- }
3137
-
3138
- // node_modules/@sinclair/typebox/build/esm/type/array/array.mjs
3139
- function Array2(items, options) {
3140
- return CreateType({ [Kind]: "Array", type: "array", items }, options);
3141
- }
3142
-
3143
- // node_modules/@sinclair/typebox/build/esm/type/argument/argument.mjs
3144
- function Argument(index) {
3145
- return CreateType({ [Kind]: "Argument", index });
3146
- }
3147
-
3148
- // node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.mjs
3149
- function AsyncIterator(items, options) {
3150
- return CreateType({ [Kind]: "AsyncIterator", type: "AsyncIterator", items }, options);
3151
- }
3152
-
3153
- // node_modules/@sinclair/typebox/build/esm/type/computed/computed.mjs
3154
- function Computed(target, parameters, options) {
3155
- return CreateType({ [Kind]: "Computed", target, parameters }, options);
3156
- }
3157
-
3158
- // node_modules/@sinclair/typebox/build/esm/type/discard/discard.mjs
3159
- function DiscardKey(value, key) {
3160
- const { [key]: _, ...rest } = value;
3161
- return rest;
3162
- }
3163
- function Discard(value, keys) {
3164
- return keys.reduce((acc, key) => DiscardKey(acc, key), value);
3165
- }
3166
-
3167
- // node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
3168
- function Never(options) {
3169
- return CreateType({ [Kind]: "Never", not: {} }, options);
3170
- }
3171
-
3172
- // node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.mjs
3173
- function MappedResult(properties) {
3174
- return CreateType({
3175
- [Kind]: "MappedResult",
3176
- properties
3177
- });
3178
- }
3179
-
3180
- // node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.mjs
3181
- function Constructor(parameters, returns, options) {
3182
- return CreateType({ [Kind]: "Constructor", type: "Constructor", parameters, returns }, options);
3183
- }
3184
-
3185
- // node_modules/@sinclair/typebox/build/esm/type/function/function.mjs
3186
- function Function(parameters, returns, options) {
3187
- return CreateType({ [Kind]: "Function", type: "Function", parameters, returns }, options);
3188
- }
3189
-
3190
- // node_modules/@sinclair/typebox/build/esm/type/union/union-create.mjs
3191
- function UnionCreate(T, options) {
3192
- return CreateType({ [Kind]: "Union", anyOf: T }, options);
3193
- }
3194
-
3195
- // node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.mjs
3196
- function IsUnionOptional(types) {
3197
- return types.some((type) => IsOptional(type));
3198
- }
3199
- function RemoveOptionalFromRest(types) {
3200
- return types.map((left) => IsOptional(left) ? RemoveOptionalFromType(left) : left);
3201
- }
3202
- function RemoveOptionalFromType(T) {
3203
- return Discard(T, [OptionalKind]);
3204
- }
3205
- function ResolveUnion(types, options) {
3206
- const isOptional = IsUnionOptional(types);
3207
- return isOptional ? Optional(UnionCreate(RemoveOptionalFromRest(types), options)) : UnionCreate(RemoveOptionalFromRest(types), options);
3208
- }
3209
- function UnionEvaluated(T, options) {
3210
- return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
3211
- }
3212
-
3213
- // node_modules/@sinclair/typebox/build/esm/type/union/union.mjs
3214
- function Union(types, options) {
3215
- return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
3216
- }
3217
-
3218
- // node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.mjs
3219
- var TemplateLiteralParserError = class extends TypeBoxError {
3220
- };
3221
- function Unescape(pattern) {
3222
- return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
3223
- }
3224
- function IsNonEscaped(pattern, index, char) {
3225
- return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
3226
- }
3227
- function IsOpenParen(pattern, index) {
3228
- return IsNonEscaped(pattern, index, "(");
3229
- }
3230
- function IsCloseParen(pattern, index) {
3231
- return IsNonEscaped(pattern, index, ")");
3232
- }
3233
- function IsSeparator(pattern, index) {
3234
- return IsNonEscaped(pattern, index, "|");
3235
- }
3236
- function IsGroup(pattern) {
3237
- if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
3238
- return false;
3239
- let count = 0;
3240
- for (let index = 0; index < pattern.length; index++) {
3241
- if (IsOpenParen(pattern, index))
3242
- count += 1;
3243
- if (IsCloseParen(pattern, index))
3244
- count -= 1;
3245
- if (count === 0 && index !== pattern.length - 1)
3246
- return false;
3247
- }
3248
- return true;
3249
- }
3250
- function InGroup(pattern) {
3251
- return pattern.slice(1, pattern.length - 1);
3252
- }
3253
- function IsPrecedenceOr(pattern) {
3254
- let count = 0;
3255
- for (let index = 0; index < pattern.length; index++) {
3256
- if (IsOpenParen(pattern, index))
3257
- count += 1;
3258
- if (IsCloseParen(pattern, index))
3259
- count -= 1;
3260
- if (IsSeparator(pattern, index) && count === 0)
3261
- return true;
3262
- }
3263
- return false;
3264
- }
3265
- function IsPrecedenceAnd(pattern) {
3266
- for (let index = 0; index < pattern.length; index++) {
3267
- if (IsOpenParen(pattern, index))
3268
- return true;
3269
- }
3270
- return false;
3271
- }
3272
- function Or(pattern) {
3273
- let [count, start] = [0, 0];
3274
- const expressions = [];
3275
- for (let index = 0; index < pattern.length; index++) {
3276
- if (IsOpenParen(pattern, index))
3277
- count += 1;
3278
- if (IsCloseParen(pattern, index))
3279
- count -= 1;
3280
- if (IsSeparator(pattern, index) && count === 0) {
3281
- const range2 = pattern.slice(start, index);
3282
- if (range2.length > 0)
3283
- expressions.push(TemplateLiteralParse(range2));
3284
- start = index + 1;
3285
- }
3286
- }
3287
- const range = pattern.slice(start);
3288
- if (range.length > 0)
3289
- expressions.push(TemplateLiteralParse(range));
3290
- if (expressions.length === 0)
3291
- return { type: "const", const: "" };
3292
- if (expressions.length === 1)
3293
- return expressions[0];
3294
- return { type: "or", expr: expressions };
3295
- }
3296
- function And(pattern) {
3297
- function Group(value, index) {
3298
- if (!IsOpenParen(value, index))
3299
- throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
3300
- let count = 0;
3301
- for (let scan = index; scan < value.length; scan++) {
3302
- if (IsOpenParen(value, scan))
3303
- count += 1;
3304
- if (IsCloseParen(value, scan))
3305
- count -= 1;
3306
- if (count === 0)
3307
- return [index, scan];
3308
- }
3309
- throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
3310
- }
3311
- function Range(pattern2, index) {
3312
- for (let scan = index; scan < pattern2.length; scan++) {
3313
- if (IsOpenParen(pattern2, scan))
3314
- return [index, scan];
3315
- }
3316
- return [index, pattern2.length];
3317
- }
3318
- const expressions = [];
3319
- for (let index = 0; index < pattern.length; index++) {
3320
- if (IsOpenParen(pattern, index)) {
3321
- const [start, end] = Group(pattern, index);
3322
- const range = pattern.slice(start, end + 1);
3323
- expressions.push(TemplateLiteralParse(range));
3324
- index = end;
3325
- } else {
3326
- const [start, end] = Range(pattern, index);
3327
- const range = pattern.slice(start, end);
3328
- if (range.length > 0)
3329
- expressions.push(TemplateLiteralParse(range));
3330
- index = end - 1;
3331
- }
3332
- }
3333
- return expressions.length === 0 ? { type: "const", const: "" } : expressions.length === 1 ? expressions[0] : { type: "and", expr: expressions };
3334
- }
3335
- function TemplateLiteralParse(pattern) {
3336
- return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : { type: "const", const: Unescape(pattern) };
3337
- }
3338
- function TemplateLiteralParseExact(pattern) {
3339
- return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
3340
- }
3341
-
3342
- // node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.mjs
3343
- var TemplateLiteralFiniteError = class extends TypeBoxError {
3344
- };
3345
- function IsNumberExpression(expression) {
3346
- 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]*";
3347
- }
3348
- function IsBooleanExpression(expression) {
3349
- 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";
3350
- }
3351
- function IsStringExpression(expression) {
3352
- return expression.type === "const" && expression.const === ".*";
3353
- }
3354
- function IsTemplateLiteralExpressionFinite(expression) {
3355
- 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 : (() => {
3356
- throw new TemplateLiteralFiniteError(`Unknown expression type`);
3357
- })();
3358
- }
3359
- function IsTemplateLiteralFinite(schema) {
3360
- const expression = TemplateLiteralParseExact(schema.pattern);
3361
- return IsTemplateLiteralExpressionFinite(expression);
3362
- }
3363
-
3364
- // node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.mjs
3365
- var TemplateLiteralGenerateError = class extends TypeBoxError {
3366
- };
3367
- function* GenerateReduce(buffer) {
3368
- if (buffer.length === 1)
3369
- return yield* buffer[0];
3370
- for (const left of buffer[0]) {
3371
- for (const right of GenerateReduce(buffer.slice(1))) {
3372
- yield `${left}${right}`;
3373
- }
3374
- }
3375
- }
3376
- function* GenerateAnd(expression) {
3377
- return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
3378
- }
3379
- function* GenerateOr(expression) {
3380
- for (const expr of expression.expr)
3381
- yield* TemplateLiteralExpressionGenerate(expr);
3382
- }
3383
- function* GenerateConst(expression) {
3384
- return yield expression.const;
3385
- }
3386
- function* TemplateLiteralExpressionGenerate(expression) {
3387
- return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
3388
- throw new TemplateLiteralGenerateError("Unknown expression");
3389
- })();
3390
- }
3391
- function TemplateLiteralGenerate(schema) {
3392
- const expression = TemplateLiteralParseExact(schema.pattern);
3393
- return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
3394
- }
3395
-
3396
- // node_modules/@sinclair/typebox/build/esm/type/literal/literal.mjs
3397
- function Literal(value, options) {
3398
- return CreateType({
3399
- [Kind]: "Literal",
3400
- const: value,
3401
- type: typeof value
3402
- }, options);
3403
- }
3404
-
3405
- // node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.mjs
3406
- function Boolean2(options) {
3407
- return CreateType({ [Kind]: "Boolean", type: "boolean" }, options);
3408
- }
3409
-
3410
- // node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.mjs
3411
- function BigInt(options) {
3412
- return CreateType({ [Kind]: "BigInt", type: "bigint" }, options);
3413
- }
3414
-
3415
- // node_modules/@sinclair/typebox/build/esm/type/number/number.mjs
3416
- function Number2(options) {
3417
- return CreateType({ [Kind]: "Number", type: "number" }, options);
3418
- }
3419
-
3420
- // node_modules/@sinclair/typebox/build/esm/type/string/string.mjs
3421
- function String2(options) {
3422
- return CreateType({ [Kind]: "String", type: "string" }, options);
3423
- }
3424
-
3425
- // node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.mjs
3426
- function* FromUnion(syntax) {
3427
- const trim = syntax.trim().replace(/"|'/g, "");
3428
- return trim === "boolean" ? yield Boolean2() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String2() : yield (() => {
3429
- const literals = trim.split("|").map((literal) => Literal(literal.trim()));
3430
- return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
3431
- })();
3432
- }
3433
- function* FromTerminal(syntax) {
3434
- if (syntax[1] !== "{") {
3435
- const L = Literal("$");
3436
- const R = FromSyntax(syntax.slice(1));
3437
- return yield* [L, ...R];
3438
- }
3439
- for (let i = 2; i < syntax.length; i++) {
3440
- if (syntax[i] === "}") {
3441
- const L = FromUnion(syntax.slice(2, i));
3442
- const R = FromSyntax(syntax.slice(i + 1));
3443
- return yield* [...L, ...R];
3444
- }
3445
- }
3446
- yield Literal(syntax);
3447
- }
3448
- function* FromSyntax(syntax) {
3449
- for (let i = 0; i < syntax.length; i++) {
3450
- if (syntax[i] === "$") {
3451
- const L = Literal(syntax.slice(0, i));
3452
- const R = FromTerminal(syntax.slice(i));
3453
- return yield* [L, ...R];
3454
- }
3455
- }
3456
- yield Literal(syntax);
3457
- }
3458
- function TemplateLiteralSyntax(syntax) {
3459
- return [...FromSyntax(syntax)];
3460
- }
3461
-
3462
- // node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.mjs
3463
- var TemplateLiteralPatternError = class extends TypeBoxError {
3464
- };
3465
- function Escape(value) {
3466
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3467
- }
3468
- function Visit2(schema, acc) {
3469
- 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}` : (() => {
3470
- throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
3471
- })();
3472
- }
3473
- function TemplateLiteralPattern(kinds) {
3474
- return `^${kinds.map((schema) => Visit2(schema, "")).join("")}$`;
3475
- }
3476
-
3477
- // node_modules/@sinclair/typebox/build/esm/type/template-literal/union.mjs
3478
- function TemplateLiteralToUnion(schema) {
3479
- const R = TemplateLiteralGenerate(schema);
3480
- const L = R.map((S) => Literal(S));
3481
- return UnionEvaluated(L);
3482
- }
3483
-
3484
- // node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.mjs
3485
- function TemplateLiteral(unresolved, options) {
3486
- const pattern = IsString(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
3487
- return CreateType({ [Kind]: "TemplateLiteral", type: "string", pattern }, options);
3488
- }
3489
-
3490
- // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.mjs
3491
- function FromTemplateLiteral(templateLiteral) {
3492
- const keys = TemplateLiteralGenerate(templateLiteral);
3493
- return keys.map((key) => key.toString());
3494
- }
3495
- function FromUnion2(types) {
3496
- const result = [];
3497
- for (const type of types)
3498
- result.push(...IndexPropertyKeys(type));
3499
- return result;
3500
- }
3501
- function FromLiteral(literalValue) {
3502
- return [literalValue.toString()];
3503
- }
3504
- function IndexPropertyKeys(type) {
3505
- return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] : IsInteger(type) ? ["[number]"] : [])];
3506
- }
3507
-
3508
- // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.mjs
3509
- function FromProperties(type, properties, options) {
3510
- const result = {};
3511
- for (const K2 of Object.getOwnPropertyNames(properties)) {
3512
- result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
3513
- }
3514
- return result;
3515
- }
3516
- function FromMappedResult(type, mappedResult, options) {
3517
- return FromProperties(type, mappedResult.properties, options);
3518
- }
3519
- function IndexFromMappedResult(type, mappedResult, options) {
3520
- const properties = FromMappedResult(type, mappedResult, options);
3521
- return MappedResult(properties);
3522
- }
3523
-
3524
- // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.mjs
3525
- function FromRest(types, key) {
3526
- return types.map((type) => IndexFromPropertyKey(type, key));
3527
- }
3528
- function FromIntersectRest(types) {
3529
- return types.filter((type) => !IsNever(type));
3530
- }
3531
- function FromIntersect(types, key) {
3532
- return IntersectEvaluated(FromIntersectRest(FromRest(types, key)));
3533
- }
3534
- function FromUnionRest(types) {
3535
- return types.some((L) => IsNever(L)) ? [] : types;
3536
- }
3537
- function FromUnion3(types, key) {
3538
- return UnionEvaluated(FromUnionRest(FromRest(types, key)));
3539
- }
3540
- function FromTuple(types, key) {
3541
- return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
3542
- }
3543
- function FromArray(type, key) {
3544
- return key === "[number]" ? type : Never();
3545
- }
3546
- function FromProperty(properties, propertyKey) {
3547
- return propertyKey in properties ? properties[propertyKey] : Never();
3548
- }
3549
- function IndexFromPropertyKey(type, propertyKey) {
3550
- 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();
3551
- }
3552
- function IndexFromPropertyKeys(type, propertyKeys) {
3553
- return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
3554
- }
3555
- function FromSchema(type, propertyKeys) {
3556
- return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
3557
- }
3558
- function Index(type, key, options) {
3559
- if (IsRef(type) || IsRef(key)) {
3560
- const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
3561
- if (!IsSchema(type) || !IsSchema(key))
3562
- throw new TypeBoxError(error);
3563
- return Computed("Index", [type, key]);
3564
- }
3565
- if (IsMappedResult(key))
3566
- return IndexFromMappedResult(type, key, options);
3567
- if (IsMappedKey(key))
3568
- return IndexFromMappedKey(type, key, options);
3569
- return CreateType(IsSchema(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
3570
- }
3571
-
3572
- // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.mjs
3573
- function MappedIndexPropertyKey(type, key, options) {
3574
- return { [key]: Index(type, [key], Clone(options)) };
3575
- }
3576
- function MappedIndexPropertyKeys(type, propertyKeys, options) {
3577
- return propertyKeys.reduce((result, left) => {
3578
- return { ...result, ...MappedIndexPropertyKey(type, left, options) };
3579
- }, {});
3580
- }
3581
- function MappedIndexProperties(type, mappedKey, options) {
3582
- return MappedIndexPropertyKeys(type, mappedKey.keys, options);
3583
- }
3584
- function IndexFromMappedKey(type, mappedKey, options) {
3585
- const properties = MappedIndexProperties(type, mappedKey, options);
3586
- return MappedResult(properties);
3587
- }
3588
-
3589
- // node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.mjs
3590
- function Iterator(items, options) {
3591
- return CreateType({ [Kind]: "Iterator", type: "Iterator", items }, options);
3592
- }
3593
-
3594
- // node_modules/@sinclair/typebox/build/esm/type/object/object.mjs
3595
- function RequiredArray(properties) {
3596
- return globalThis.Object.keys(properties).filter((key) => !IsOptional(properties[key]));
3597
- }
3598
- function _Object(properties, options) {
3599
- const required = RequiredArray(properties);
3600
- const schema = required.length > 0 ? { [Kind]: "Object", type: "object", required, properties } : { [Kind]: "Object", type: "object", properties };
3601
- return CreateType(schema, options);
3602
- }
3603
- var Object2 = _Object;
3604
-
3605
- // node_modules/@sinclair/typebox/build/esm/type/promise/promise.mjs
3606
- function Promise2(item, options) {
3607
- return CreateType({ [Kind]: "Promise", type: "Promise", item }, options);
3608
- }
3609
-
3610
- // node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.mjs
3611
- function RemoveReadonly(schema) {
3612
- return CreateType(Discard(schema, [ReadonlyKind]));
3613
- }
3614
- function AddReadonly(schema) {
3615
- return CreateType({ ...schema, [ReadonlyKind]: "Readonly" });
3616
- }
3617
- function ReadonlyWithFlag(schema, F) {
3618
- return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
3619
- }
3620
- function Readonly(schema, enable) {
3621
- const F = enable ?? true;
3622
- return IsMappedResult(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
3623
- }
3624
-
3625
- // node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.mjs
3626
- function FromProperties2(K, F) {
3627
- const Acc = {};
3628
- for (const K2 of globalThis.Object.getOwnPropertyNames(K))
3629
- Acc[K2] = Readonly(K[K2], F);
3630
- return Acc;
3631
- }
3632
- function FromMappedResult2(R, F) {
3633
- return FromProperties2(R.properties, F);
3634
- }
3635
- function ReadonlyFromMappedResult(R, F) {
3636
- const P = FromMappedResult2(R, F);
3637
- return MappedResult(P);
3638
- }
3639
-
3640
- // node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.mjs
3641
- function Tuple(types, options) {
3642
- 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);
3643
- }
3644
-
3645
- // node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs
3646
- function FromMappedResult3(K, P) {
3647
- return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
3648
- }
3649
- function MappedKeyToKnownMappedResultProperties(K) {
3650
- return { [K]: Literal(K) };
3651
- }
3652
- function MappedKeyToUnknownMappedResultProperties(P) {
3653
- const Acc = {};
3654
- for (const L of P)
3655
- Acc[L] = Literal(L);
3656
- return Acc;
3657
- }
3658
- function MappedKeyToMappedResultProperties(K, P) {
3659
- return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
3660
- }
3661
- function FromMappedKey(K, P) {
3662
- const R = MappedKeyToMappedResultProperties(K, P);
3663
- return FromMappedResult3(K, R);
3664
- }
3665
- function FromRest2(K, T) {
3666
- return T.map((L) => FromSchemaType(K, L));
3667
- }
3668
- function FromProperties3(K, T) {
3669
- const Acc = {};
3670
- for (const K2 of globalThis.Object.getOwnPropertyNames(T))
3671
- Acc[K2] = FromSchemaType(K, T[K2]);
3672
- return Acc;
3673
- }
3674
- function FromSchemaType(K, T) {
3675
- const options = { ...T };
3676
- return (
3677
- // unevaluated modifier types
3678
- IsOptional(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : (
3679
- // unevaluated mapped types
3680
- IsMappedResult(T) ? FromMappedResult3(K, T.properties) : IsMappedKey(T) ? FromMappedKey(K, T.keys) : (
3681
- // unevaluated types
3682
- 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
3683
- )
3684
- )
3685
- );
3686
- }
3687
- function MappedFunctionReturnType(K, T) {
3688
- const Acc = {};
3689
- for (const L of K)
3690
- Acc[L] = FromSchemaType(L, T);
3691
- return Acc;
3692
- }
3693
- function Mapped(key, map, options) {
3694
- const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
3695
- const RT = map({ [Kind]: "MappedKey", keys: K });
3696
- const R = MappedFunctionReturnType(K, RT);
3697
- return Object2(R, options);
3698
- }
3699
-
3700
- // node_modules/@sinclair/typebox/build/esm/type/optional/optional.mjs
3701
- function RemoveOptional(schema) {
3702
- return CreateType(Discard(schema, [OptionalKind]));
3703
- }
3704
- function AddOptional(schema) {
3705
- return CreateType({ ...schema, [OptionalKind]: "Optional" });
3706
- }
3707
- function OptionalWithFlag(schema, F) {
3708
- return F === false ? RemoveOptional(schema) : AddOptional(schema);
3709
- }
3710
- function Optional(schema, enable) {
3711
- const F = enable ?? true;
3712
- return IsMappedResult(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
3713
- }
3714
-
3715
- // node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.mjs
3716
- function FromProperties4(P, F) {
3717
- const Acc = {};
3718
- for (const K2 of globalThis.Object.getOwnPropertyNames(P))
3719
- Acc[K2] = Optional(P[K2], F);
3720
- return Acc;
3721
- }
3722
- function FromMappedResult4(R, F) {
3723
- return FromProperties4(R.properties, F);
3724
- }
3725
- function OptionalFromMappedResult(R, F) {
3726
- const P = FromMappedResult4(R, F);
3727
- return MappedResult(P);
3728
- }
3729
-
3730
- // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.mjs
3731
- function IntersectCreate(T, options = {}) {
3732
- const allObjects = T.every((schema) => IsObject3(schema));
3733
- const clonedUnevaluatedProperties = IsSchema(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
3734
- return CreateType(options.unevaluatedProperties === false || IsSchema(options.unevaluatedProperties) || allObjects ? { ...clonedUnevaluatedProperties, [Kind]: "Intersect", type: "object", allOf: T } : { ...clonedUnevaluatedProperties, [Kind]: "Intersect", allOf: T }, options);
3735
- }
3736
-
3737
- // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.mjs
3738
- function IsIntersectOptional(types) {
3739
- return types.every((left) => IsOptional(left));
3740
- }
3741
- function RemoveOptionalFromType2(type) {
3742
- return Discard(type, [OptionalKind]);
3743
- }
3744
- function RemoveOptionalFromRest2(types) {
3745
- return types.map((left) => IsOptional(left) ? RemoveOptionalFromType2(left) : left);
3746
- }
3747
- function ResolveIntersect(types, options) {
3748
- return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest2(types), options)) : IntersectCreate(RemoveOptionalFromRest2(types), options);
3749
- }
3750
- function IntersectEvaluated(types, options = {}) {
3751
- if (types.length === 1)
3752
- return CreateType(types[0], options);
3753
- if (types.length === 0)
3754
- return Never(options);
3755
- if (types.some((schema) => IsTransform(schema)))
3756
- throw new Error("Cannot intersect transform types");
3757
- return ResolveIntersect(types, options);
3758
- }
3759
-
3760
- // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.mjs
3761
- function Intersect(types, options) {
3762
- if (types.length === 1)
3763
- return CreateType(types[0], options);
3764
- if (types.length === 0)
3765
- return Never(options);
3766
- if (types.some((schema) => IsTransform(schema)))
3767
- throw new Error("Cannot intersect transform types");
3768
- return IntersectCreate(types, options);
3769
- }
3770
-
3771
- // node_modules/@sinclair/typebox/build/esm/type/ref/ref.mjs
3772
- function Ref(...args) {
3773
- const [$ref, options] = typeof args[0] === "string" ? [args[0], args[1]] : [args[0].$id, args[1]];
3774
- if (typeof $ref !== "string")
3775
- throw new TypeBoxError("Ref: $ref must be a string");
3776
- return CreateType({ [Kind]: "Ref", $ref }, options);
3777
- }
3778
-
3779
- // node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.mjs
3780
- function FromComputed(target, parameters) {
3781
- return Computed("Awaited", [Computed(target, parameters)]);
3782
- }
3783
- function FromRef($ref) {
3784
- return Computed("Awaited", [Ref($ref)]);
3785
- }
3786
- function FromIntersect2(types) {
3787
- return Intersect(FromRest3(types));
3788
- }
3789
- function FromUnion4(types) {
3790
- return Union(FromRest3(types));
3791
- }
3792
- function FromPromise(type) {
3793
- return Awaited(type);
3794
- }
3795
- function FromRest3(types) {
3796
- return types.map((type) => Awaited(type));
3797
- }
3798
- function Awaited(type, options) {
3799
- 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);
3800
- }
3801
-
3802
- // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
3803
- function FromRest4(types) {
3804
- const result = [];
3805
- for (const L of types)
3806
- result.push(KeyOfPropertyKeys(L));
3807
- return result;
3808
- }
3809
- function FromIntersect3(types) {
3810
- const propertyKeysArray = FromRest4(types);
3811
- const propertyKeys = SetUnionMany(propertyKeysArray);
3812
- return propertyKeys;
3813
- }
3814
- function FromUnion5(types) {
3815
- const propertyKeysArray = FromRest4(types);
3816
- const propertyKeys = SetIntersectMany(propertyKeysArray);
3817
- return propertyKeys;
3818
- }
3819
- function FromTuple2(types) {
3820
- return types.map((_, indexer) => indexer.toString());
3821
- }
3822
- function FromArray2(_) {
3823
- return ["[number]"];
3824
- }
3825
- function FromProperties5(T) {
3826
- return globalThis.Object.getOwnPropertyNames(T);
3827
- }
3828
- function FromPatternProperties(patternProperties) {
3829
- if (!includePatternProperties)
3830
- return [];
3831
- const patternPropertyKeys = globalThis.Object.getOwnPropertyNames(patternProperties);
3832
- return patternPropertyKeys.map((key) => {
3833
- return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
3834
- });
3835
- }
3836
- function KeyOfPropertyKeys(type) {
3837
- 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) : [];
3838
- }
3839
- var includePatternProperties = false;
3840
-
3841
- // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.mjs
3842
- function FromComputed2(target, parameters) {
3843
- return Computed("KeyOf", [Computed(target, parameters)]);
3844
- }
3845
- function FromRef2($ref) {
3846
- return Computed("KeyOf", [Ref($ref)]);
3847
- }
3848
- function KeyOfFromType(type, options) {
3849
- const propertyKeys = KeyOfPropertyKeys(type);
3850
- const propertyKeyTypes = KeyOfPropertyKeysToRest(propertyKeys);
3851
- const result = UnionEvaluated(propertyKeyTypes);
3852
- return CreateType(result, options);
3853
- }
3854
- function KeyOfPropertyKeysToRest(propertyKeys) {
3855
- return propertyKeys.map((L) => L === "[number]" ? Number2() : Literal(L));
3856
- }
3857
- function KeyOf(type, options) {
3858
- return IsComputed(type) ? FromComputed2(type.target, type.parameters) : IsRef(type) ? FromRef2(type.$ref) : IsMappedResult(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
3859
- }
3860
-
3861
- // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.mjs
3862
- function FromProperties6(properties, options) {
3863
- const result = {};
3864
- for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
3865
- result[K2] = KeyOf(properties[K2], Clone(options));
3866
- return result;
3867
- }
3868
- function FromMappedResult5(mappedResult, options) {
3869
- return FromProperties6(mappedResult.properties, options);
3870
- }
3871
- function KeyOfFromMappedResult(mappedResult, options) {
3872
- const properties = FromMappedResult5(mappedResult, options);
3873
- return MappedResult(properties);
3874
- }
3875
-
3876
- // node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs
3877
- function CompositeKeys(T) {
3878
- const Acc = [];
3879
- for (const L of T)
3880
- Acc.push(...KeyOfPropertyKeys(L));
3881
- return SetDistinct(Acc);
3882
- }
3883
- function FilterNever(T) {
3884
- return T.filter((L) => !IsNever(L));
3885
- }
3886
- function CompositeProperty(T, K) {
3887
- const Acc = [];
3888
- for (const L of T)
3889
- Acc.push(...IndexFromPropertyKeys(L, [K]));
3890
- return FilterNever(Acc);
3891
- }
3892
- function CompositeProperties(T, K) {
3893
- const Acc = {};
3894
- for (const L of K) {
3895
- Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
3896
- }
3897
- return Acc;
3898
- }
3899
- function Composite(T, options) {
3900
- const K = CompositeKeys(T);
3901
- const P = CompositeProperties(T, K);
3902
- const R = Object2(P, options);
3903
- return R;
3904
- }
3905
-
3906
- // node_modules/@sinclair/typebox/build/esm/type/date/date.mjs
3907
- function Date2(options) {
3908
- return CreateType({ [Kind]: "Date", type: "Date" }, options);
3909
- }
3910
-
3911
- // node_modules/@sinclair/typebox/build/esm/type/null/null.mjs
3912
- function Null(options) {
3913
- return CreateType({ [Kind]: "Null", type: "null" }, options);
3914
- }
3915
-
3916
- // node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.mjs
3917
- function Symbol2(options) {
3918
- return CreateType({ [Kind]: "Symbol", type: "symbol" }, options);
3919
- }
3920
-
3921
- // node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.mjs
3922
- function Undefined(options) {
3923
- return CreateType({ [Kind]: "Undefined", type: "undefined" }, options);
3924
- }
3925
-
3926
- // node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.mjs
3927
- function Uint8Array2(options) {
3928
- return CreateType({ [Kind]: "Uint8Array", type: "Uint8Array" }, options);
3929
- }
3930
-
3931
- // node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.mjs
3932
- function Unknown(options) {
3933
- return CreateType({ [Kind]: "Unknown" }, options);
3934
- }
3935
-
3936
- // node_modules/@sinclair/typebox/build/esm/type/const/const.mjs
3937
- function FromArray3(T) {
3938
- return T.map((L) => FromValue(L, false));
3939
- }
3940
- function FromProperties7(value) {
3941
- const Acc = {};
3942
- for (const K of globalThis.Object.getOwnPropertyNames(value))
3943
- Acc[K] = Readonly(FromValue(value[K], false));
3944
- return Acc;
3945
- }
3946
- function ConditionalReadonly(T, root) {
3947
- return root === true ? T : Readonly(T);
3948
- }
3949
- function FromValue(value, root) {
3950
- 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({});
3951
- }
3952
- function Const(T, options) {
3953
- return CreateType(FromValue(T, true), options);
3954
- }
3955
-
3956
- // node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.mjs
3957
- function ConstructorParameters(schema, options) {
3958
- return IsConstructor(schema) ? Tuple(schema.parameters, options) : Never(options);
3959
- }
3960
-
3961
- // node_modules/@sinclair/typebox/build/esm/type/enum/enum.mjs
3962
- function Enum(item, options) {
3963
- if (IsUndefined(item))
3964
- throw new Error("Enum undefined or empty");
3965
- const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
3966
- const values2 = [...new Set(values1)];
3967
- const anyOf = values2.map((value) => Literal(value));
3968
- return Union(anyOf, { ...options, [Hint]: "Enum" });
3969
- }
3970
-
3971
- // node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.mjs
3972
- var ExtendsResolverError = class extends TypeBoxError {
3973
- };
3974
- var ExtendsResult;
3975
- (function(ExtendsResult2) {
3976
- ExtendsResult2[ExtendsResult2["Union"] = 0] = "Union";
3977
- ExtendsResult2[ExtendsResult2["True"] = 1] = "True";
3978
- ExtendsResult2[ExtendsResult2["False"] = 2] = "False";
3979
- })(ExtendsResult || (ExtendsResult = {}));
3980
- function IntoBooleanResult(result) {
3981
- return result === ExtendsResult.False ? result : ExtendsResult.True;
3982
- }
3983
- function Throw(message) {
3984
- throw new ExtendsResolverError(message);
3985
- }
3986
- function IsStructuralRight(right) {
3987
- return type_exports.IsNever(right) || type_exports.IsIntersect(right) || type_exports.IsUnion(right) || type_exports.IsUnknown(right) || type_exports.IsAny(right);
3988
- }
3989
- function StructuralRight(left, right) {
3990
- 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");
3991
- }
3992
- function FromAnyRight(left, right) {
3993
- return ExtendsResult.True;
3994
- }
3995
- function FromAny(left, right) {
3996
- 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;
3997
- }
3998
- function FromArrayRight(left, right) {
3999
- return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
4000
- }
4001
- function FromArray4(left, right) {
4002
- 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));
4003
- }
4004
- function FromAsyncIterator(left, right) {
4005
- return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
4006
- }
4007
- function FromBigInt(left, right) {
4008
- 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;
4009
- }
4010
- function FromBooleanRight(left, right) {
4011
- return type_exports.IsLiteralBoolean(left) ? ExtendsResult.True : type_exports.IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
4012
- }
4013
- function FromBoolean(left, right) {
4014
- 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;
4015
- }
4016
- function FromConstructor(left, right) {
4017
- 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));
4018
- }
4019
- function FromDate(left, right) {
4020
- 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;
4021
- }
4022
- function FromFunction(left, right) {
4023
- 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));
4024
- }
4025
- function FromIntegerRight(left, right) {
4026
- return type_exports.IsLiteral(left) && value_exports.IsNumber(left.const) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
4027
- }
4028
- function FromInteger(left, right) {
4029
- 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;
4030
- }
4031
- function FromIntersectRight(left, right) {
4032
- return right.allOf.every((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
4033
- }
4034
- function FromIntersect4(left, right) {
4035
- return left.allOf.some((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
4036
- }
4037
- function FromIterator(left, right) {
4038
- return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
4039
- }
4040
- function FromLiteral2(left, right) {
4041
- 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;
4042
- }
4043
- function FromNeverRight(left, right) {
4044
- return ExtendsResult.False;
4045
- }
4046
- function FromNever(left, right) {
4047
- return ExtendsResult.True;
4048
- }
4049
- function UnwrapTNot(schema) {
4050
- let [current, depth] = [schema, 0];
4051
- while (true) {
4052
- if (!type_exports.IsNot(current))
4053
- break;
4054
- current = current.not;
4055
- depth += 1;
4056
- }
4057
- return depth % 2 === 0 ? current : Unknown();
4058
- }
4059
- function FromNot(left, right) {
4060
- return type_exports.IsNot(left) ? Visit3(UnwrapTNot(left), right) : type_exports.IsNot(right) ? Visit3(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
4061
- }
4062
- function FromNull(left, right) {
4063
- 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;
4064
- }
4065
- function FromNumberRight(left, right) {
4066
- return type_exports.IsLiteralNumber(left) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
4067
- }
4068
- function FromNumber(left, right) {
4069
- 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;
4070
- }
4071
- function IsObjectPropertyCount(schema, count) {
4072
- return Object.getOwnPropertyNames(schema.properties).length === count;
4073
- }
4074
- function IsObjectStringLike(schema) {
4075
- return IsObjectArrayLike(schema);
4076
- }
4077
- function IsObjectSymbolLike(schema) {
4078
- 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]));
4079
- }
4080
- function IsObjectNumberLike(schema) {
4081
- return IsObjectPropertyCount(schema, 0);
4082
- }
4083
- function IsObjectBooleanLike(schema) {
4084
- return IsObjectPropertyCount(schema, 0);
4085
- }
4086
- function IsObjectBigIntLike(schema) {
4087
- return IsObjectPropertyCount(schema, 0);
4088
- }
4089
- function IsObjectDateLike(schema) {
4090
- return IsObjectPropertyCount(schema, 0);
4091
- }
4092
- function IsObjectUint8ArrayLike(schema) {
4093
- return IsObjectArrayLike(schema);
4094
- }
4095
- function IsObjectFunctionLike(schema) {
4096
- const length = Number2();
4097
- return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
4098
- }
4099
- function IsObjectConstructorLike(schema) {
4100
- return IsObjectPropertyCount(schema, 0);
4101
- }
4102
- function IsObjectArrayLike(schema) {
4103
- const length = Number2();
4104
- return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
4105
- }
4106
- function IsObjectPromiseLike(schema) {
4107
- const then = Function([Any()], Any());
4108
- return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit3(schema.properties["then"], then)) === ExtendsResult.True;
4109
- }
4110
- function Property(left, right) {
4111
- return Visit3(left, right) === ExtendsResult.False ? ExtendsResult.False : type_exports.IsOptional(left) && !type_exports.IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
4112
- }
4113
- function FromObjectRight(left, right) {
4114
- 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)) ? (() => {
4115
- return right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False;
4116
- })() : type_exports.IsRecord(left) && type_exports.IsNumber(RecordKey(left)) ? (() => {
4117
- return IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False;
4118
- })() : ExtendsResult.False;
4119
- }
4120
- function FromObject(left, right) {
4121
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : !type_exports.IsObject(right) ? ExtendsResult.False : (() => {
4122
- for (const key of Object.getOwnPropertyNames(right.properties)) {
4123
- if (!(key in left.properties) && !type_exports.IsOptional(right.properties[key])) {
4124
- return ExtendsResult.False;
4125
- }
4126
- if (type_exports.IsOptional(right.properties[key])) {
4127
- return ExtendsResult.True;
4128
- }
4129
- if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) {
4130
- return ExtendsResult.False;
4131
- }
4132
- }
4133
- return ExtendsResult.True;
4134
- })();
4135
- }
4136
- function FromPromise2(left, right) {
4137
- 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));
4138
- }
4139
- function RecordKey(schema) {
4140
- return PatternNumberExact in schema.patternProperties ? Number2() : PatternStringExact in schema.patternProperties ? String2() : Throw("Unknown record key pattern");
4141
- }
4142
- function RecordValue(schema) {
4143
- return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
4144
- }
4145
- function FromRecordRight(left, right) {
4146
- const [Key, Value] = [RecordKey(right), RecordValue(right)];
4147
- 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) ? (() => {
4148
- for (const key of Object.getOwnPropertyNames(left.properties)) {
4149
- if (Property(Value, left.properties[key]) === ExtendsResult.False) {
4150
- return ExtendsResult.False;
4151
- }
4152
- }
4153
- return ExtendsResult.True;
4154
- })() : ExtendsResult.False;
4155
- }
4156
- function FromRecord(left, right) {
4157
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsRecord(right) ? ExtendsResult.False : Visit3(RecordValue(left), RecordValue(right));
4158
- }
4159
- function FromRegExp(left, right) {
4160
- const L = type_exports.IsRegExp(left) ? String2() : left;
4161
- const R = type_exports.IsRegExp(right) ? String2() : right;
4162
- return Visit3(L, R);
4163
- }
4164
- function FromStringRight(left, right) {
4165
- return type_exports.IsLiteral(left) && value_exports.IsString(left.const) ? ExtendsResult.True : type_exports.IsString(left) ? ExtendsResult.True : ExtendsResult.False;
4166
- }
4167
- function FromString(left, right) {
4168
- 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;
4169
- }
4170
- function FromSymbol(left, right) {
4171
- 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;
4172
- }
4173
- function FromTemplateLiteral2(left, right) {
4174
- return type_exports.IsTemplateLiteral(left) ? Visit3(TemplateLiteralToUnion(left), right) : type_exports.IsTemplateLiteral(right) ? Visit3(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
4175
- }
4176
- function IsArrayOfTuple(left, right) {
4177
- return type_exports.IsArray(right) && left.items !== void 0 && left.items.every((schema) => Visit3(schema, right.items) === ExtendsResult.True);
4178
- }
4179
- function FromTupleRight(left, right) {
4180
- return type_exports.IsNever(left) ? ExtendsResult.True : type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
4181
- }
4182
- function FromTuple3(left, right) {
4183
- 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;
4184
- }
4185
- function FromUint8Array(left, right) {
4186
- 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;
4187
- }
4188
- function FromUndefined(left, right) {
4189
- 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;
4190
- }
4191
- function FromUnionRight(left, right) {
4192
- return right.anyOf.some((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
4193
- }
4194
- function FromUnion6(left, right) {
4195
- return left.anyOf.every((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
4196
- }
4197
- function FromUnknownRight(left, right) {
4198
- return ExtendsResult.True;
4199
- }
4200
- function FromUnknown(left, right) {
4201
- 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;
4202
- }
4203
- function FromVoidRight(left, right) {
4204
- return type_exports.IsUndefined(left) ? ExtendsResult.True : type_exports.IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
4205
- }
4206
- function FromVoid(left, right) {
4207
- 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;
4208
- }
4209
- function Visit3(left, right) {
4210
- return (
4211
- // resolvable
4212
- 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) : (
4213
- // standard
4214
- 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]}'`)
4215
- )
4216
- );
4217
- }
4218
- function ExtendsCheck(left, right) {
4219
- return Visit3(left, right);
4220
- }
4221
-
4222
- // node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.mjs
4223
- function FromProperties8(P, Right, True, False, options) {
4224
- const Acc = {};
4225
- for (const K2 of globalThis.Object.getOwnPropertyNames(P))
4226
- Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
4227
- return Acc;
4228
- }
4229
- function FromMappedResult6(Left, Right, True, False, options) {
4230
- return FromProperties8(Left.properties, Right, True, False, options);
4231
- }
4232
- function ExtendsFromMappedResult(Left, Right, True, False, options) {
4233
- const P = FromMappedResult6(Left, Right, True, False, options);
4234
- return MappedResult(P);
4235
- }
4236
-
4237
- // node_modules/@sinclair/typebox/build/esm/type/extends/extends.mjs
4238
- function ExtendsResolve(left, right, trueType, falseType) {
4239
- const R = ExtendsCheck(left, right);
4240
- return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
4241
- }
4242
- function Extends(L, R, T, F, options) {
4243
- 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);
4244
- }
4245
-
4246
- // node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.mjs
4247
- function FromPropertyKey(K, U, L, R, options) {
4248
- return {
4249
- [K]: Extends(Literal(K), U, L, R, Clone(options))
4250
- };
4251
- }
4252
- function FromPropertyKeys(K, U, L, R, options) {
4253
- return K.reduce((Acc, LK) => {
4254
- return { ...Acc, ...FromPropertyKey(LK, U, L, R, options) };
4255
- }, {});
4256
- }
4257
- function FromMappedKey2(K, U, L, R, options) {
4258
- return FromPropertyKeys(K.keys, U, L, R, options);
4259
- }
4260
- function ExtendsFromMappedKey(T, U, L, R, options) {
4261
- const P = FromMappedKey2(T, U, L, R, options);
4262
- return MappedResult(P);
4263
- }
4264
-
4265
- // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.mjs
4266
- function ExcludeFromTemplateLiteral(L, R) {
4267
- return Exclude(TemplateLiteralToUnion(L), R);
4268
- }
4269
-
4270
- // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.mjs
4271
- function ExcludeRest(L, R) {
4272
- const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
4273
- return excluded.length === 1 ? excluded[0] : Union(excluded);
4274
- }
4275
- function Exclude(L, R, options = {}) {
4276
- if (IsTemplateLiteral(L))
4277
- return CreateType(ExcludeFromTemplateLiteral(L, R), options);
4278
- if (IsMappedResult(L))
4279
- return CreateType(ExcludeFromMappedResult(L, R), options);
4280
- return CreateType(IsUnion(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
4281
- }
4282
-
4283
- // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.mjs
4284
- function FromProperties9(P, U) {
4285
- const Acc = {};
4286
- for (const K2 of globalThis.Object.getOwnPropertyNames(P))
4287
- Acc[K2] = Exclude(P[K2], U);
4288
- return Acc;
4289
- }
4290
- function FromMappedResult7(R, T) {
4291
- return FromProperties9(R.properties, T);
4292
- }
4293
- function ExcludeFromMappedResult(R, T) {
4294
- const P = FromMappedResult7(R, T);
4295
- return MappedResult(P);
4296
- }
4297
-
4298
- // node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.mjs
4299
- function ExtractFromTemplateLiteral(L, R) {
4300
- return Extract(TemplateLiteralToUnion(L), R);
4301
- }
4302
-
4303
- // node_modules/@sinclair/typebox/build/esm/type/extract/extract.mjs
4304
- function ExtractRest(L, R) {
4305
- const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
4306
- return extracted.length === 1 ? extracted[0] : Union(extracted);
4307
- }
4308
- function Extract(L, R, options) {
4309
- if (IsTemplateLiteral(L))
4310
- return CreateType(ExtractFromTemplateLiteral(L, R), options);
4311
- if (IsMappedResult(L))
4312
- return CreateType(ExtractFromMappedResult(L, R), options);
4313
- return CreateType(IsUnion(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
4314
- }
4315
-
4316
- // node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.mjs
4317
- function FromProperties10(P, T) {
4318
- const Acc = {};
4319
- for (const K2 of globalThis.Object.getOwnPropertyNames(P))
4320
- Acc[K2] = Extract(P[K2], T);
4321
- return Acc;
4322
- }
4323
- function FromMappedResult8(R, T) {
4324
- return FromProperties10(R.properties, T);
4325
- }
4326
- function ExtractFromMappedResult(R, T) {
4327
- const P = FromMappedResult8(R, T);
4328
- return MappedResult(P);
4329
- }
4330
-
4331
- // node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.mjs
4332
- function InstanceType(schema, options) {
4333
- return IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options);
4334
- }
4335
-
4336
- // node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.mjs
4337
- function ReadonlyOptional(schema) {
4338
- return Readonly(Optional(schema));
4339
- }
4340
-
4341
- // node_modules/@sinclair/typebox/build/esm/type/record/record.mjs
4342
- function RecordCreateFromPattern(pattern, T, options) {
4343
- return CreateType({ [Kind]: "Record", type: "object", patternProperties: { [pattern]: T } }, options);
4344
- }
4345
- function RecordCreateFromKeys(K, T, options) {
4346
- const result = {};
4347
- for (const K2 of K)
4348
- result[K2] = T;
4349
- return Object2(result, { ...options, [Hint]: "Record" });
4350
- }
4351
- function FromTemplateLiteralKey(K, T, options) {
4352
- return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
4353
- }
4354
- function FromUnionKey(key, type, options) {
4355
- return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
4356
- }
4357
- function FromLiteralKey(key, type, options) {
4358
- return RecordCreateFromKeys([key.toString()], type, options);
4359
- }
4360
- function FromRegExpKey(key, type, options) {
4361
- return RecordCreateFromPattern(key.source, type, options);
4362
- }
4363
- function FromStringKey(key, type, options) {
4364
- const pattern = IsUndefined(key.pattern) ? PatternStringExact : key.pattern;
4365
- return RecordCreateFromPattern(pattern, type, options);
4366
- }
4367
- function FromAnyKey(_, type, options) {
4368
- return RecordCreateFromPattern(PatternStringExact, type, options);
4369
- }
4370
- function FromNeverKey(_key, type, options) {
4371
- return RecordCreateFromPattern(PatternNeverExact, type, options);
4372
- }
4373
- function FromBooleanKey(_key, type, options) {
4374
- return Object2({ true: type, false: type }, options);
4375
- }
4376
- function FromIntegerKey(_key, type, options) {
4377
- return RecordCreateFromPattern(PatternNumberExact, type, options);
4378
- }
4379
- function FromNumberKey(_, type, options) {
4380
- return RecordCreateFromPattern(PatternNumberExact, type, options);
4381
- }
4382
- function Record(key, type, options = {}) {
4383
- 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);
4384
- }
4385
- function RecordPattern(record) {
4386
- return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
4387
- }
4388
- function RecordKey2(type) {
4389
- const pattern = RecordPattern(type);
4390
- return pattern === PatternStringExact ? String2() : pattern === PatternNumberExact ? Number2() : String2({ pattern });
4391
- }
4392
- function RecordValue2(type) {
4393
- return type.patternProperties[RecordPattern(type)];
4394
- }
4395
-
4396
- // node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs
4397
- function FromConstructor2(args, type) {
4398
- type.parameters = FromTypes(args, type.parameters);
4399
- type.returns = FromType(args, type.returns);
4400
- return type;
4401
- }
4402
- function FromFunction2(args, type) {
4403
- type.parameters = FromTypes(args, type.parameters);
4404
- type.returns = FromType(args, type.returns);
4405
- return type;
4406
- }
4407
- function FromIntersect5(args, type) {
4408
- type.allOf = FromTypes(args, type.allOf);
4409
- return type;
4410
- }
4411
- function FromUnion7(args, type) {
4412
- type.anyOf = FromTypes(args, type.anyOf);
4413
- return type;
4414
- }
4415
- function FromTuple4(args, type) {
4416
- if (IsUndefined(type.items))
4417
- return type;
4418
- type.items = FromTypes(args, type.items);
4419
- return type;
4420
- }
4421
- function FromArray5(args, type) {
4422
- type.items = FromType(args, type.items);
4423
- return type;
4424
- }
4425
- function FromAsyncIterator2(args, type) {
4426
- type.items = FromType(args, type.items);
4427
- return type;
4428
- }
4429
- function FromIterator2(args, type) {
4430
- type.items = FromType(args, type.items);
4431
- return type;
4432
- }
4433
- function FromPromise3(args, type) {
4434
- type.item = FromType(args, type.item);
4435
- return type;
4436
- }
4437
- function FromObject2(args, type) {
4438
- const mappedProperties = FromProperties11(args, type.properties);
4439
- return { ...type, ...Object2(mappedProperties) };
4440
- }
4441
- function FromRecord2(args, type) {
4442
- const mappedKey = FromType(args, RecordKey2(type));
4443
- const mappedValue = FromType(args, RecordValue2(type));
4444
- const result = Record(mappedKey, mappedValue);
4445
- return { ...type, ...result };
4446
- }
4447
- function FromArgument(args, argument) {
4448
- return argument.index in args ? args[argument.index] : Unknown();
4449
- }
4450
- function FromProperty2(args, type) {
4451
- const isReadonly = IsReadonly(type);
4452
- const isOptional = IsOptional(type);
4453
- const mapped = FromType(args, type);
4454
- return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
4455
- }
4456
- function FromProperties11(args, properties) {
4457
- return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
4458
- return { ...result, [key]: FromProperty2(args, properties[key]) };
4459
- }, {});
4460
- }
4461
- function FromTypes(args, types) {
4462
- return types.map((type) => FromType(args, type));
4463
- }
4464
- function FromType(args, type) {
4465
- 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;
4466
- }
4467
- function Instantiate(type, args) {
4468
- return FromType(args, CloneType(type));
4469
- }
4470
-
4471
- // node_modules/@sinclair/typebox/build/esm/type/integer/integer.mjs
4472
- function Integer(options) {
4473
- return CreateType({ [Kind]: "Integer", type: "integer" }, options);
4474
- }
4475
-
4476
- // node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs
4477
- function MappedIntrinsicPropertyKey(K, M, options) {
4478
- return {
4479
- [K]: Intrinsic(Literal(K), M, Clone(options))
4480
- };
4481
- }
4482
- function MappedIntrinsicPropertyKeys(K, M, options) {
4483
- const result = K.reduce((Acc, L) => {
4484
- return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
4485
- }, {});
4486
- return result;
4487
- }
4488
- function MappedIntrinsicProperties(T, M, options) {
4489
- return MappedIntrinsicPropertyKeys(T["keys"], M, options);
4490
- }
4491
- function IntrinsicFromMappedKey(T, M, options) {
4492
- const P = MappedIntrinsicProperties(T, M, options);
4493
- return MappedResult(P);
4494
- }
4495
-
4496
- // node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.mjs
4497
- function ApplyUncapitalize(value) {
4498
- const [first, rest] = [value.slice(0, 1), value.slice(1)];
4499
- return [first.toLowerCase(), rest].join("");
4500
- }
4501
- function ApplyCapitalize(value) {
4502
- const [first, rest] = [value.slice(0, 1), value.slice(1)];
4503
- return [first.toUpperCase(), rest].join("");
4504
- }
4505
- function ApplyUppercase(value) {
4506
- return value.toUpperCase();
4507
- }
4508
- function ApplyLowercase(value) {
4509
- return value.toLowerCase();
4510
- }
4511
- function FromTemplateLiteral3(schema, mode, options) {
4512
- const expression = TemplateLiteralParseExact(schema.pattern);
4513
- const finite = IsTemplateLiteralExpressionFinite(expression);
4514
- if (!finite)
4515
- return { ...schema, pattern: FromLiteralValue(schema.pattern, mode) };
4516
- const strings = [...TemplateLiteralExpressionGenerate(expression)];
4517
- const literals = strings.map((value) => Literal(value));
4518
- const mapped = FromRest5(literals, mode);
4519
- const union = Union(mapped);
4520
- return TemplateLiteral([union], options);
4521
- }
4522
- function FromLiteralValue(value, mode) {
4523
- return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
4524
- }
4525
- function FromRest5(T, M) {
4526
- return T.map((L) => Intrinsic(L, M));
4527
- }
4528
- function Intrinsic(schema, mode, options = {}) {
4529
- return (
4530
- // Intrinsic-Mapped-Inference
4531
- IsMappedKey(schema) ? IntrinsicFromMappedKey(schema, mode, options) : (
4532
- // Standard-Inference
4533
- IsTemplateLiteral(schema) ? FromTemplateLiteral3(schema, mode, options) : IsUnion(schema) ? Union(FromRest5(schema.anyOf, mode), options) : IsLiteral(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : (
4534
- // Default Type
4535
- CreateType(schema, options)
4536
- )
4537
- )
4538
- );
4539
- }
4540
-
4541
- // node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.mjs
4542
- function Capitalize(T, options = {}) {
4543
- return Intrinsic(T, "Capitalize", options);
4544
- }
4545
-
4546
- // node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.mjs
4547
- function Lowercase(T, options = {}) {
4548
- return Intrinsic(T, "Lowercase", options);
4549
- }
4550
-
4551
- // node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.mjs
4552
- function Uncapitalize(T, options = {}) {
4553
- return Intrinsic(T, "Uncapitalize", options);
4554
- }
4555
-
4556
- // node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.mjs
4557
- function Uppercase(T, options = {}) {
4558
- return Intrinsic(T, "Uppercase", options);
4559
- }
4560
-
4561
- // node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.mjs
4562
- function FromProperties12(properties, propertyKeys, options) {
4563
- const result = {};
4564
- for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
4565
- result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
4566
- return result;
4567
- }
4568
- function FromMappedResult9(mappedResult, propertyKeys, options) {
4569
- return FromProperties12(mappedResult.properties, propertyKeys, options);
4570
- }
4571
- function OmitFromMappedResult(mappedResult, propertyKeys, options) {
4572
- const properties = FromMappedResult9(mappedResult, propertyKeys, options);
4573
- return MappedResult(properties);
4574
- }
4575
-
4576
- // node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs
4577
- function FromIntersect6(types, propertyKeys) {
4578
- return types.map((type) => OmitResolve(type, propertyKeys));
4579
- }
4580
- function FromUnion8(types, propertyKeys) {
4581
- return types.map((type) => OmitResolve(type, propertyKeys));
4582
- }
4583
- function FromProperty3(properties, key) {
4584
- const { [key]: _, ...R } = properties;
4585
- return R;
4586
- }
4587
- function FromProperties13(properties, propertyKeys) {
4588
- return propertyKeys.reduce((T, K2) => FromProperty3(T, K2), properties);
4589
- }
4590
- function FromObject3(type, propertyKeys, properties) {
4591
- const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
4592
- const mappedProperties = FromProperties13(properties, propertyKeys);
4593
- return Object2(mappedProperties, options);
4594
- }
4595
- function UnionFromPropertyKeys(propertyKeys) {
4596
- const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
4597
- return Union(result);
4598
- }
4599
- function OmitResolve(type, propertyKeys) {
4600
- return IsIntersect(type) ? Intersect(FromIntersect6(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion8(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject3(type, propertyKeys, type.properties) : Object2({});
4601
- }
4602
- function Omit(type, key, options) {
4603
- const typeKey = IsArray(key) ? UnionFromPropertyKeys(key) : key;
4604
- const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
4605
- const isTypeRef = IsRef(type);
4606
- const isKeyRef = IsRef(key);
4607
- 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 });
4608
- }
4609
-
4610
- // node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.mjs
4611
- function FromPropertyKey2(type, key, options) {
4612
- return { [key]: Omit(type, [key], Clone(options)) };
4613
- }
4614
- function FromPropertyKeys2(type, propertyKeys, options) {
4615
- return propertyKeys.reduce((Acc, LK) => {
4616
- return { ...Acc, ...FromPropertyKey2(type, LK, options) };
4617
- }, {});
4618
- }
4619
- function FromMappedKey3(type, mappedKey, options) {
4620
- return FromPropertyKeys2(type, mappedKey.keys, options);
4621
- }
4622
- function OmitFromMappedKey(type, mappedKey, options) {
4623
- const properties = FromMappedKey3(type, mappedKey, options);
4624
- return MappedResult(properties);
4625
- }
4626
-
4627
- // node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.mjs
4628
- function FromProperties14(properties, propertyKeys, options) {
4629
- const result = {};
4630
- for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
4631
- result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
4632
- return result;
4633
- }
4634
- function FromMappedResult10(mappedResult, propertyKeys, options) {
4635
- return FromProperties14(mappedResult.properties, propertyKeys, options);
4636
- }
4637
- function PickFromMappedResult(mappedResult, propertyKeys, options) {
4638
- const properties = FromMappedResult10(mappedResult, propertyKeys, options);
4639
- return MappedResult(properties);
4640
- }
4641
-
4642
- // node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs
4643
- function FromIntersect7(types, propertyKeys) {
4644
- return types.map((type) => PickResolve(type, propertyKeys));
4645
- }
4646
- function FromUnion9(types, propertyKeys) {
4647
- return types.map((type) => PickResolve(type, propertyKeys));
4648
- }
4649
- function FromProperties15(properties, propertyKeys) {
4650
- const result = {};
4651
- for (const K2 of propertyKeys)
4652
- if (K2 in properties)
4653
- result[K2] = properties[K2];
4654
- return result;
4655
- }
4656
- function FromObject4(Type2, keys, properties) {
4657
- const options = Discard(Type2, [TransformKind, "$id", "required", "properties"]);
4658
- const mappedProperties = FromProperties15(properties, keys);
4659
- return Object2(mappedProperties, options);
4660
- }
4661
- function UnionFromPropertyKeys2(propertyKeys) {
4662
- const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
4663
- return Union(result);
4664
- }
4665
- function PickResolve(type, propertyKeys) {
4666
- return IsIntersect(type) ? Intersect(FromIntersect7(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion9(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject4(type, propertyKeys, type.properties) : Object2({});
4667
- }
4668
- function Pick(type, key, options) {
4669
- const typeKey = IsArray(key) ? UnionFromPropertyKeys2(key) : key;
4670
- const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
4671
- const isTypeRef = IsRef(type);
4672
- const isKeyRef = IsRef(key);
4673
- 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 });
4674
- }
4675
-
4676
- // node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.mjs
4677
- function FromPropertyKey3(type, key, options) {
4678
- return {
4679
- [key]: Pick(type, [key], Clone(options))
4680
- };
4681
- }
4682
- function FromPropertyKeys3(type, propertyKeys, options) {
4683
- return propertyKeys.reduce((result, leftKey) => {
4684
- return { ...result, ...FromPropertyKey3(type, leftKey, options) };
4685
- }, {});
4686
- }
4687
- function FromMappedKey4(type, mappedKey, options) {
4688
- return FromPropertyKeys3(type, mappedKey.keys, options);
4689
- }
4690
- function PickFromMappedKey(type, mappedKey, options) {
4691
- const properties = FromMappedKey4(type, mappedKey, options);
4692
- return MappedResult(properties);
4693
- }
4694
-
4695
- // node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs
4696
- function FromComputed3(target, parameters) {
4697
- return Computed("Partial", [Computed(target, parameters)]);
4698
- }
4699
- function FromRef3($ref) {
4700
- return Computed("Partial", [Ref($ref)]);
4701
- }
4702
- function FromProperties16(properties) {
4703
- const partialProperties = {};
4704
- for (const K of globalThis.Object.getOwnPropertyNames(properties))
4705
- partialProperties[K] = Optional(properties[K]);
4706
- return partialProperties;
4707
- }
4708
- function FromObject5(type, properties) {
4709
- const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
4710
- const mappedProperties = FromProperties16(properties);
4711
- return Object2(mappedProperties, options);
4712
- }
4713
- function FromRest6(types) {
4714
- return types.map((type) => PartialResolve(type));
4715
- }
4716
- function PartialResolve(type) {
4717
- return (
4718
- // Mappable
4719
- 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) : (
4720
- // Intrinsic
4721
- 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 : (
4722
- // Passthrough
4723
- Object2({})
4724
- )
4725
- )
4726
- );
4727
- }
4728
- function Partial(type, options) {
4729
- if (IsMappedResult(type)) {
4730
- return PartialFromMappedResult(type, options);
4731
- } else {
4732
- return CreateType({ ...PartialResolve(type), ...options });
4733
- }
4734
- }
4735
-
4736
- // node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.mjs
4737
- function FromProperties17(K, options) {
4738
- const Acc = {};
4739
- for (const K2 of globalThis.Object.getOwnPropertyNames(K))
4740
- Acc[K2] = Partial(K[K2], Clone(options));
4741
- return Acc;
4742
- }
4743
- function FromMappedResult11(R, options) {
4744
- return FromProperties17(R.properties, options);
4745
- }
4746
- function PartialFromMappedResult(R, options) {
4747
- const P = FromMappedResult11(R, options);
4748
- return MappedResult(P);
4749
- }
4750
-
4751
- // node_modules/@sinclair/typebox/build/esm/type/required/required.mjs
4752
- function FromComputed4(target, parameters) {
4753
- return Computed("Required", [Computed(target, parameters)]);
4754
- }
4755
- function FromRef4($ref) {
4756
- return Computed("Required", [Ref($ref)]);
4757
- }
4758
- function FromProperties18(properties) {
4759
- const requiredProperties = {};
4760
- for (const K of globalThis.Object.getOwnPropertyNames(properties))
4761
- requiredProperties[K] = Discard(properties[K], [OptionalKind]);
4762
- return requiredProperties;
4763
- }
4764
- function FromObject6(type, properties) {
4765
- const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
4766
- const mappedProperties = FromProperties18(properties);
4767
- return Object2(mappedProperties, options);
4768
- }
4769
- function FromRest7(types) {
4770
- return types.map((type) => RequiredResolve(type));
4771
- }
4772
- function RequiredResolve(type) {
4773
- return (
4774
- // Mappable
4775
- 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) : (
4776
- // Intrinsic
4777
- 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 : (
4778
- // Passthrough
4779
- Object2({})
4780
- )
4781
- )
4782
- );
4783
- }
4784
- function Required(type, options) {
4785
- if (IsMappedResult(type)) {
4786
- return RequiredFromMappedResult(type, options);
4787
- } else {
4788
- return CreateType({ ...RequiredResolve(type), ...options });
4789
- }
4790
- }
4791
-
4792
- // node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.mjs
4793
- function FromProperties19(P, options) {
4794
- const Acc = {};
4795
- for (const K2 of globalThis.Object.getOwnPropertyNames(P))
4796
- Acc[K2] = Required(P[K2], options);
4797
- return Acc;
4798
- }
4799
- function FromMappedResult12(R, options) {
4800
- return FromProperties19(R.properties, options);
4801
- }
4802
- function RequiredFromMappedResult(R, options) {
4803
- const P = FromMappedResult12(R, options);
4804
- return MappedResult(P);
4805
- }
4806
-
4807
- // node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs
4808
- function DereferenceParameters(moduleProperties, types) {
4809
- return types.map((type) => {
4810
- return IsRef(type) ? Dereference(moduleProperties, type.$ref) : FromType2(moduleProperties, type);
4811
- });
4812
- }
4813
- function Dereference(moduleProperties, ref) {
4814
- return ref in moduleProperties ? IsRef(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType2(moduleProperties, moduleProperties[ref]) : Never();
4815
- }
4816
- function FromAwaited(parameters) {
4817
- return Awaited(parameters[0]);
4818
- }
4819
- function FromIndex(parameters) {
4820
- return Index(parameters[0], parameters[1]);
4821
- }
4822
- function FromKeyOf(parameters) {
4823
- return KeyOf(parameters[0]);
4824
- }
4825
- function FromPartial(parameters) {
4826
- return Partial(parameters[0]);
4827
- }
4828
- function FromOmit(parameters) {
4829
- return Omit(parameters[0], parameters[1]);
4830
- }
4831
- function FromPick(parameters) {
4832
- return Pick(parameters[0], parameters[1]);
4833
- }
4834
- function FromRequired(parameters) {
4835
- return Required(parameters[0]);
4836
- }
4837
- function FromComputed5(moduleProperties, target, parameters) {
4838
- const dereferenced = DereferenceParameters(moduleProperties, parameters);
4839
- 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();
4840
- }
4841
- function FromArray6(moduleProperties, type) {
4842
- return Array2(FromType2(moduleProperties, type));
4843
- }
4844
- function FromAsyncIterator3(moduleProperties, type) {
4845
- return AsyncIterator(FromType2(moduleProperties, type));
4846
- }
4847
- function FromConstructor3(moduleProperties, parameters, instanceType) {
4848
- return Constructor(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, instanceType));
4849
- }
4850
- function FromFunction3(moduleProperties, parameters, returnType) {
4851
- return Function(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, returnType));
4852
- }
4853
- function FromIntersect8(moduleProperties, types) {
4854
- return Intersect(FromTypes2(moduleProperties, types));
4855
- }
4856
- function FromIterator3(moduleProperties, type) {
4857
- return Iterator(FromType2(moduleProperties, type));
4858
- }
4859
- function FromObject7(moduleProperties, properties) {
4860
- return Object2(globalThis.Object.keys(properties).reduce((result, key) => {
4861
- return { ...result, [key]: FromType2(moduleProperties, properties[key]) };
4862
- }, {}));
4863
- }
4864
- function FromRecord3(moduleProperties, type) {
4865
- const [value, pattern] = [FromType2(moduleProperties, RecordValue2(type)), RecordPattern(type)];
4866
- const result = CloneType(type);
4867
- result.patternProperties[pattern] = value;
4868
- return result;
4869
- }
4870
- function FromTransform(moduleProperties, transform) {
4871
- return IsRef(transform) ? { ...Dereference(moduleProperties, transform.$ref), [TransformKind]: transform[TransformKind] } : transform;
4872
- }
4873
- function FromTuple5(moduleProperties, types) {
4874
- return Tuple(FromTypes2(moduleProperties, types));
4875
- }
4876
- function FromUnion10(moduleProperties, types) {
4877
- return Union(FromTypes2(moduleProperties, types));
4878
- }
4879
- function FromTypes2(moduleProperties, types) {
4880
- return types.map((type) => FromType2(moduleProperties, type));
4881
- }
4882
- function FromType2(moduleProperties, type) {
4883
- return (
4884
- // Modifiers
4885
- IsOptional(type) ? CreateType(FromType2(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType2(moduleProperties, Discard(type, [ReadonlyKind])), type) : (
4886
- // Transform
4887
- IsTransform(type) ? CreateType(FromTransform(moduleProperties, type), type) : (
4888
- // Types
4889
- 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
4890
- )
4891
- )
4892
- );
4893
- }
4894
- function ComputeType(moduleProperties, key) {
4895
- return key in moduleProperties ? FromType2(moduleProperties, moduleProperties[key]) : Never();
4896
- }
4897
- function ComputeModuleProperties(moduleProperties) {
4898
- return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
4899
- return { ...result, [key]: ComputeType(moduleProperties, key) };
4900
- }, {});
4901
- }
4902
-
4903
- // node_modules/@sinclair/typebox/build/esm/type/module/module.mjs
4904
- var TModule = class {
4905
- constructor($defs) {
4906
- const computed = ComputeModuleProperties($defs);
4907
- const identified = this.WithIdentifiers(computed);
4908
- this.$defs = identified;
4909
- }
4910
- /** `[Json]` Imports a Type by Key. */
4911
- Import(key, options) {
4912
- const $defs = { ...this.$defs, [key]: CreateType(this.$defs[key], options) };
4913
- return CreateType({ [Kind]: "Import", $defs, $ref: key });
4914
- }
4915
- // prettier-ignore
4916
- WithIdentifiers($defs) {
4917
- return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
4918
- return { ...result, [key]: { ...$defs[key], $id: key } };
4919
- }, {});
4920
- }
4921
- };
4922
- function Module(properties) {
4923
- return new TModule(properties);
4924
- }
4925
-
4926
- // node_modules/@sinclair/typebox/build/esm/type/not/not.mjs
4927
- function Not(type, options) {
4928
- return CreateType({ [Kind]: "Not", not: type }, options);
4929
- }
4930
-
4931
- // node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.mjs
4932
- function Parameters(schema, options) {
4933
- return IsFunction2(schema) ? Tuple(schema.parameters, options) : Never();
4934
- }
4935
-
4936
- // node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.mjs
4937
- var Ordinal = 0;
4938
- function Recursive(callback, options = {}) {
4939
- if (IsUndefined(options.$id))
4940
- options.$id = `T${Ordinal++}`;
4941
- const thisType = CloneType(callback({ [Kind]: "This", $ref: `${options.$id}` }));
4942
- thisType.$id = options.$id;
4943
- return CreateType({ [Hint]: "Recursive", ...thisType }, options);
4944
- }
4945
-
4946
- // node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.mjs
4947
- function RegExp2(unresolved, options) {
4948
- const expr = IsString(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
4949
- return CreateType({ [Kind]: "RegExp", type: "RegExp", source: expr.source, flags: expr.flags }, options);
4950
- }
4951
-
4952
- // node_modules/@sinclair/typebox/build/esm/type/rest/rest.mjs
4953
- function RestResolve(T) {
4954
- return IsIntersect(T) ? T.allOf : IsUnion(T) ? T.anyOf : IsTuple(T) ? T.items ?? [] : [];
4955
- }
4956
- function Rest(T) {
4957
- return RestResolve(T);
4958
- }
4959
-
4960
- // node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.mjs
4961
- function ReturnType(schema, options) {
4962
- return IsFunction2(schema) ? CreateType(schema.returns, options) : Never(options);
4963
- }
4964
-
4965
- // node_modules/@sinclair/typebox/build/esm/type/transform/transform.mjs
4966
- var TransformDecodeBuilder = class {
4967
- constructor(schema) {
4968
- this.schema = schema;
4969
- }
4970
- Decode(decode) {
4971
- return new TransformEncodeBuilder(this.schema, decode);
4972
- }
4973
- };
4974
- var TransformEncodeBuilder = class {
4975
- constructor(schema, decode) {
4976
- this.schema = schema;
4977
- this.decode = decode;
4978
- }
4979
- EncodeTransform(encode, schema) {
4980
- const Encode = (value) => schema[TransformKind].Encode(encode(value));
4981
- const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
4982
- const Codec = { Encode, Decode };
4983
- return { ...schema, [TransformKind]: Codec };
4984
- }
4985
- EncodeSchema(encode, schema) {
4986
- const Codec = { Decode: this.decode, Encode: encode };
4987
- return { ...schema, [TransformKind]: Codec };
4988
- }
4989
- Encode(encode) {
4990
- return IsTransform(this.schema) ? this.EncodeTransform(encode, this.schema) : this.EncodeSchema(encode, this.schema);
4991
- }
4992
- };
4993
- function Transform(schema) {
4994
- return new TransformDecodeBuilder(schema);
4995
- }
4996
-
4997
- // node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.mjs
4998
- function Unsafe(options = {}) {
4999
- return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
5000
- }
5001
-
5002
- // node_modules/@sinclair/typebox/build/esm/type/void/void.mjs
5003
- function Void(options) {
5004
- return CreateType({ [Kind]: "Void", type: "void" }, options);
5005
- }
5006
-
5007
- // node_modules/@sinclair/typebox/build/esm/type/type/type.mjs
5008
- var type_exports2 = {};
5009
- __export(type_exports2, {
5010
- Any: () => Any,
5011
- Argument: () => Argument,
5012
- Array: () => Array2,
5013
- AsyncIterator: () => AsyncIterator,
5014
- Awaited: () => Awaited,
5015
- BigInt: () => BigInt,
5016
- Boolean: () => Boolean2,
5017
- Capitalize: () => Capitalize,
5018
- Composite: () => Composite,
5019
- Const: () => Const,
5020
- Constructor: () => Constructor,
5021
- ConstructorParameters: () => ConstructorParameters,
5022
- Date: () => Date2,
5023
- Enum: () => Enum,
5024
- Exclude: () => Exclude,
5025
- Extends: () => Extends,
5026
- Extract: () => Extract,
5027
- Function: () => Function,
5028
- Index: () => Index,
5029
- InstanceType: () => InstanceType,
5030
- Instantiate: () => Instantiate,
5031
- Integer: () => Integer,
5032
- Intersect: () => Intersect,
5033
- Iterator: () => Iterator,
5034
- KeyOf: () => KeyOf,
5035
- Literal: () => Literal,
5036
- Lowercase: () => Lowercase,
5037
- Mapped: () => Mapped,
5038
- Module: () => Module,
5039
- Never: () => Never,
5040
- Not: () => Not,
5041
- Null: () => Null,
5042
- Number: () => Number2,
5043
- Object: () => Object2,
5044
- Omit: () => Omit,
5045
- Optional: () => Optional,
5046
- Parameters: () => Parameters,
5047
- Partial: () => Partial,
5048
- Pick: () => Pick,
5049
- Promise: () => Promise2,
5050
- Readonly: () => Readonly,
5051
- ReadonlyOptional: () => ReadonlyOptional,
5052
- Record: () => Record,
5053
- Recursive: () => Recursive,
5054
- Ref: () => Ref,
5055
- RegExp: () => RegExp2,
5056
- Required: () => Required,
5057
- Rest: () => Rest,
5058
- ReturnType: () => ReturnType,
5059
- String: () => String2,
5060
- Symbol: () => Symbol2,
5061
- TemplateLiteral: () => TemplateLiteral,
5062
- Transform: () => Transform,
5063
- Tuple: () => Tuple,
5064
- Uint8Array: () => Uint8Array2,
5065
- Uncapitalize: () => Uncapitalize,
5066
- Undefined: () => Undefined,
5067
- Union: () => Union,
5068
- Unknown: () => Unknown,
5069
- Unsafe: () => Unsafe,
5070
- Uppercase: () => Uppercase,
5071
- Void: () => Void
5072
- });
5073
-
5074
- // node_modules/@sinclair/typebox/build/esm/type/type/index.mjs
5075
- var Type = type_exports2;
5076
-
5077
- // src/runtime/tools/send-file-tool.ts
5078
- var SendFileParams = Type.Object({
5079
- filePath: Type.String({
5080
- description: "Absolute path to the file to send to the user. The file must exist and be readable."
5081
- }),
5082
- caption: Type.Optional(
5083
- Type.String({
5084
- description: "Optional caption or description to accompany the file."
5085
- })
5086
- )
5087
- });
5088
- var MIME_BY_EXT = {
5089
- ".png": "image/png",
5090
- ".jpg": "image/jpeg",
5091
- ".jpeg": "image/jpeg",
5092
- ".gif": "image/gif",
5093
- ".webp": "image/webp",
5094
- ".svg": "image/svg+xml",
5095
- ".pdf": "application/pdf",
5096
- ".csv": "text/csv",
5097
- ".json": "application/json",
5098
- ".txt": "text/plain",
5099
- ".md": "text/markdown",
5100
- ".html": "text/html",
5101
- ".xml": "application/xml",
5102
- ".zip": "application/zip",
5103
- ".mp3": "audio/mpeg",
5104
- ".mp4": "video/mp4",
5105
- ".wav": "audio/wav",
5106
- ".ogg": "audio/ogg"
5107
- };
5108
- function detectMimeType(filePath) {
5109
- const ext = path7.extname(filePath).toLowerCase();
5110
- return MIME_BY_EXT[ext];
5111
- }
5112
- function createSendFileTool(fileOutputCallbackRef) {
5113
- return {
5114
- name: "send_file",
5115
- label: "Send File",
5116
- description: "Send a file to the user via the current chat channel (Telegram, Slack, or Web). IMPORTANT: Do NOT proactively send files. Only use this tool when the user EXPLICITLY asks you to send, share, or deliver a file (e.g. '\u628A\u6587\u4EF6\u53D1\u7ED9\u6211', 'send me the file', 'share the result'). Never send intermediate/temporary files. When the user asks, send only the specific file(s) the user requested, not all generated files.",
5117
- promptSnippet: "send_file: Send a file to the user ONLY when they explicitly request it. Never send files proactively or automatically.",
5118
- parameters: SendFileParams,
5119
- async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
5120
- const { filePath, caption } = params;
5121
- if (!fs7.existsSync(filePath)) {
5122
- return {
5123
- content: [{ type: "text", text: `Error: File not found: ${filePath}` }],
5124
- details: void 0
5125
- };
5126
- }
5127
- const stats = fs7.statSync(filePath);
5128
- if (!stats.isFile()) {
5129
- return {
5130
- content: [
5131
- { type: "text", text: `Error: Path is not a file: ${filePath}` }
5132
- ],
5133
- details: void 0
5134
- };
5135
- }
5136
- const filename = path7.basename(filePath);
5137
- const mimeType = detectMimeType(filePath);
5138
- const callback = fileOutputCallbackRef.current;
5139
- if (callback) {
5140
- callback({
5141
- type: "file_output",
5142
- filePath,
5143
- filename,
5144
- mimeType,
5145
- caption
5146
- });
5147
- }
5148
- const sizeKB = (stats.size / 1024).toFixed(1);
5149
- return {
5150
- content: [
5151
- {
5152
- type: "text",
5153
- text: `File "${filename}" (${sizeKB}KB) has been sent to the user.`
5154
- }
5155
- ],
5156
- details: void 0
5157
- };
5158
- }
5159
- };
5160
- }
5161
-
5162
- // src/runtime/tools/manage-schedule-tool.ts
5163
- var ManageScheduleParams = Type.Object({
5164
- action: Type.Union(
5165
- [
5166
- Type.Literal("add"),
5167
- Type.Literal("list"),
5168
- Type.Literal("remove"),
5169
- Type.Literal("trigger"),
5170
- Type.Literal("enable"),
5171
- Type.Literal("disable")
5172
- ],
5173
- { description: "The action to perform." }
5174
- ),
5175
- name: Type.Optional(
5176
- Type.String({
5177
- description: "Unique name for the scheduled task. Required for add/remove/trigger/enable/disable."
5178
- })
5179
- ),
5180
- cron: Type.Optional(
5181
- Type.String({
5182
- description: "Cron expression (5 fields: minute hour day month weekday). Required for add."
5183
- })
5184
- ),
5185
- prompt: Type.Optional(
5186
- Type.String({
5187
- description: "The work prompt to execute when the task triggers. Required for add. Describe only what to do each run; do not repeat timing, cron, or 'every N minutes' instructions here."
5188
- })
5189
- ),
5190
- timezone: Type.Optional(
5191
- Type.String({
5192
- description: "Optional timezone for the cron schedule, e.g. 'Asia/Shanghai', 'America/New_York'."
5193
- })
5194
- )
5195
- });
5196
- function textResult(text) {
5197
- return { content: [{ type: "text", text }], details: void 0 };
2623
+ function textResult(text) {
2624
+ return { content: [{ type: "text", text }], details: void 0 };
5198
2625
  }
5199
2626
  function createManageScheduleTool(schedulerRef, adapter, channelId) {
5200
2627
  return {
@@ -5861,6 +3288,9 @@ ${text}`;
5861
3288
  /** Reserved: restore a historical session */
5862
3289
  async restoreSession(_sessionId) {
5863
3290
  }
3291
+ getActiveChannelIds() {
3292
+ return Array.from(this.channels.keys());
3293
+ }
5864
3294
  };
5865
3295
 
5866
3296
  // src/runtime/adapters/web.ts
@@ -5896,9 +3326,11 @@ var WebAdapter = class {
5896
3326
  name = "web";
5897
3327
  wss = null;
5898
3328
  agent = null;
3329
+ ipcBroadcaster = null;
5899
3330
  async start(ctx) {
5900
3331
  const { agent, server, app, rootDir, lifecycle } = ctx;
5901
3332
  this.agent = agent;
3333
+ this.ipcBroadcaster = ctx.ipcBroadcaster ?? null;
5902
3334
  const currentConf = configManager.getConfig();
5903
3335
  let apiKey = currentConf.apiKey || "";
5904
3336
  let currentProvider = currentConf.provider || "openai";
@@ -6174,6 +3606,7 @@ var WebAdapter = class {
6174
3606
  }
6175
3607
  const onEvent = (event) => {
6176
3608
  sendWsEvent(ws, event);
3609
+ this.ipcBroadcaster?.broadcastAgentEvent(channelId, event);
6177
3610
  };
6178
3611
  const result = await agent.handleMessage("web", channelId, text, onEvent);
6179
3612
  if (result.errorMessage) {
@@ -6191,6 +3624,378 @@ var WebAdapter = class {
6191
3624
  }
6192
3625
  };
6193
3626
 
3627
+ // src/runtime/adapters/ipc.ts
3628
+ init_config();
3629
+
3630
+ // src/runtime/services/conversation.ts
3631
+ import fs11 from "fs";
3632
+ import path11 from "path";
3633
+ import {
3634
+ parseSessionEntries
3635
+ } from "@mariozechner/pi-coding-agent";
3636
+ var ConversationService = class {
3637
+ constructor(rootDir) {
3638
+ this.rootDir = rootDir;
3639
+ }
3640
+ /**
3641
+ * Scan data/sessions and return conversation summaries sorted by recency.
3642
+ */
3643
+ listConversations(activeChannels) {
3644
+ const sessionsDir = path11.resolve(this.rootDir, "data", "sessions");
3645
+ const channelIds = new Set(activeChannels);
3646
+ if (fs11.existsSync(sessionsDir)) {
3647
+ for (const entry of fs11.readdirSync(sessionsDir)) {
3648
+ const channelDir = path11.join(sessionsDir, entry);
3649
+ try {
3650
+ if (fs11.statSync(channelDir).isDirectory()) {
3651
+ channelIds.add(entry);
3652
+ }
3653
+ } catch {
3654
+ }
3655
+ }
3656
+ }
3657
+ const results = [];
3658
+ for (const channelId of channelIds) {
3659
+ const channelDir = path11.join(sessionsDir, channelId);
3660
+ const sessionFile = this.findLatestSessionFile(channelDir);
3661
+ let messageCount = 0;
3662
+ let lastMessageAt = "";
3663
+ let lastMessagePreview = "";
3664
+ if (sessionFile) {
3665
+ const entries = this.loadEntries(sessionFile);
3666
+ const messages = entries.filter(
3667
+ (entry) => entry.type === "message"
3668
+ );
3669
+ messageCount = messages.length;
3670
+ const lastMessage = messages[messages.length - 1];
3671
+ if (lastMessage) {
3672
+ lastMessageAt = lastMessage.timestamp;
3673
+ lastMessagePreview = this.extractTextPreview(lastMessage, 100);
3674
+ }
3675
+ }
3676
+ results.push({
3677
+ channelId,
3678
+ platform: this.detectPlatform(channelId),
3679
+ sessionFile,
3680
+ messageCount,
3681
+ lastMessageAt,
3682
+ lastMessagePreview
3683
+ });
3684
+ }
3685
+ return results.sort((a, b) => {
3686
+ const recency = (b.lastMessageAt || "").localeCompare(a.lastMessageAt || "");
3687
+ if (recency !== 0) return recency;
3688
+ return a.channelId.localeCompare(b.channelId);
3689
+ });
3690
+ }
3691
+ /**
3692
+ * Load latest messages for a channel in a simplified format.
3693
+ */
3694
+ getMessages(channelId, limit = 100) {
3695
+ const channelDir = path11.resolve(
3696
+ this.rootDir,
3697
+ "data",
3698
+ "sessions",
3699
+ channelId
3700
+ );
3701
+ const sessionFile = this.findLatestSessionFile(channelDir);
3702
+ if (!sessionFile) return [];
3703
+ const safeLimit = Number.isFinite(limit) ? Math.max(0, Math.floor(limit)) : 100;
3704
+ if (safeLimit === 0) return [];
3705
+ const entries = this.loadEntries(sessionFile);
3706
+ const messages = [];
3707
+ for (const entry of entries) {
3708
+ if (entry.type !== "message") continue;
3709
+ const role = entry.message?.role;
3710
+ if (role !== "user" && role !== "assistant") continue;
3711
+ const text = this.extractText(entry.message);
3712
+ if (!text) continue;
3713
+ const toolCalls = role === "assistant" ? this.extractToolCallSummaries(entry.message) : void 0;
3714
+ messages.push({
3715
+ id: entry.id,
3716
+ role,
3717
+ text,
3718
+ timestamp: entry.timestamp,
3719
+ toolCalls
3720
+ });
3721
+ }
3722
+ return messages.slice(-safeLimit);
3723
+ }
3724
+ findLatestSessionFile(channelDir) {
3725
+ if (!fs11.existsSync(channelDir)) return null;
3726
+ let stats;
3727
+ try {
3728
+ stats = fs11.statSync(channelDir);
3729
+ } catch {
3730
+ return null;
3731
+ }
3732
+ if (!stats.isDirectory()) return null;
3733
+ const files = fs11.readdirSync(channelDir).filter((file) => file.endsWith(".jsonl")).sort((a, b) => b.localeCompare(a));
3734
+ return files[0] ? path11.join(channelDir, files[0]) : null;
3735
+ }
3736
+ loadEntries(filePath) {
3737
+ try {
3738
+ const content = fs11.readFileSync(filePath, "utf-8");
3739
+ const fileEntries = parseSessionEntries(content);
3740
+ return fileEntries.filter((entry) => entry.type !== "session");
3741
+ } catch (err) {
3742
+ console.warn(`[ConversationService] Failed to load ${filePath}:`, err);
3743
+ return [];
3744
+ }
3745
+ }
3746
+ extractText(message) {
3747
+ if (!message?.content) return "";
3748
+ if (typeof message.content === "string") return message.content.trim();
3749
+ if (!Array.isArray(message.content)) return "";
3750
+ return message.content.filter((item) => item?.type === "text").map((item) => typeof item?.text === "string" ? item.text : "").join("").trim();
3751
+ }
3752
+ extractTextPreview(entry, maxLen) {
3753
+ const text = this.extractText(entry.message);
3754
+ return text.length > maxLen ? `${text.slice(0, maxLen)}\u2026` : text;
3755
+ }
3756
+ extractToolCallSummaries(message) {
3757
+ if (!Array.isArray(message?.content)) return void 0;
3758
+ const toolCalls = message.content.filter((item) => item?.type === "toolCall").map((item) => ({
3759
+ name: typeof item?.name === "string" && item.name ? item.name : "unknown",
3760
+ isError: false
3761
+ }));
3762
+ return toolCalls.length > 0 ? toolCalls : void 0;
3763
+ }
3764
+ detectPlatform(channelId) {
3765
+ if (channelId.startsWith("telegram-")) return "telegram";
3766
+ if (channelId.startsWith("slack-")) return "slack";
3767
+ if (channelId.startsWith("scheduler-")) return "scheduler";
3768
+ return "web";
3769
+ }
3770
+ };
3771
+
3772
+ // src/runtime/adapters/ipc.ts
3773
+ init_types();
3774
+ var IpcAdapter = class {
3775
+ name = "ipc";
3776
+ agent = null;
3777
+ rootDir = "";
3778
+ adapterMap = null;
3779
+ conversationService = null;
3780
+ createdChannels = /* @__PURE__ */ new Set();
3781
+ messageListener;
3782
+ started = false;
3783
+ async start(ctx) {
3784
+ if (typeof process.send !== "function") {
3785
+ return;
3786
+ }
3787
+ this.agent = ctx.agent;
3788
+ this.rootDir = ctx.rootDir;
3789
+ this.adapterMap = ctx.adapterMap ?? null;
3790
+ this.conversationService = new ConversationService(ctx.rootDir);
3791
+ this.messageListener = (message) => {
3792
+ if (!this.isIpcRequest(message)) return;
3793
+ void this.handleRequest(message);
3794
+ };
3795
+ process.on("message", this.messageListener);
3796
+ this.started = true;
3797
+ console.log("[IpcAdapter] Started");
3798
+ }
3799
+ async stop() {
3800
+ if (this.messageListener) {
3801
+ process.off("message", this.messageListener);
3802
+ this.messageListener = void 0;
3803
+ }
3804
+ if (this.started) {
3805
+ console.log("[IpcAdapter] Stopped");
3806
+ }
3807
+ this.started = false;
3808
+ }
3809
+ notifyReady(port) {
3810
+ this.sendIpc({
3811
+ type: "ready",
3812
+ port
3813
+ });
3814
+ }
3815
+ broadcastInbound(channelId, platform, sender, text) {
3816
+ this.sendIpc({
3817
+ type: "inbound_message",
3818
+ channelId,
3819
+ platform,
3820
+ sender,
3821
+ text,
3822
+ timestamp: Date.now()
3823
+ });
3824
+ }
3825
+ broadcastAgentEvent(channelId, event) {
3826
+ this.sendIpc({
3827
+ type: "agent_event",
3828
+ channelId,
3829
+ event
3830
+ });
3831
+ }
3832
+ isIpcRequest(message) {
3833
+ if (!message || typeof message !== "object") return false;
3834
+ const maybe = message;
3835
+ return typeof maybe.id === "string" && typeof maybe.type === "string";
3836
+ }
3837
+ async handleRequest(request) {
3838
+ if (!this.agent || !this.conversationService) {
3839
+ this.replyError(request.id, "IPC adapter is not ready yet");
3840
+ return;
3841
+ }
3842
+ try {
3843
+ switch (request.type) {
3844
+ case "get_conversations": {
3845
+ const activeChannels = new Set(this.agent.getActiveChannelIds());
3846
+ for (const channelId of this.createdChannels) {
3847
+ activeChannels.add(channelId);
3848
+ }
3849
+ const conversations = this.conversationService.listConversations(activeChannels);
3850
+ this.reply(request.id, conversations);
3851
+ return;
3852
+ }
3853
+ case "create_conversation": {
3854
+ const channelId = `web-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
3855
+ this.createdChannels.add(channelId);
3856
+ this.reply(request.id, { channelId });
3857
+ return;
3858
+ }
3859
+ case "get_messages": {
3860
+ if (!request.channelId || typeof request.channelId !== "string") {
3861
+ this.replyError(request.id, "channelId is required");
3862
+ return;
3863
+ }
3864
+ const messages = this.conversationService.getMessages(
3865
+ request.channelId,
3866
+ request.limit ?? 100
3867
+ );
3868
+ this.reply(request.id, messages);
3869
+ return;
3870
+ }
3871
+ case "send_message": {
3872
+ if (!request.channelId || typeof request.channelId !== "string") {
3873
+ this.replyError(request.id, "channelId is required");
3874
+ return;
3875
+ }
3876
+ if (typeof request.text !== "string") {
3877
+ this.replyError(request.id, "text is required");
3878
+ return;
3879
+ }
3880
+ const platform = this.detectPlatform(request.channelId);
3881
+ this.createdChannels.add(request.channelId);
3882
+ let fullText = "";
3883
+ const result = await this.agent.handleMessage(
3884
+ platform,
3885
+ request.channelId,
3886
+ request.text,
3887
+ (event) => {
3888
+ if (event.type === "text_delta") {
3889
+ fullText += event.delta;
3890
+ }
3891
+ this.broadcastAgentEvent(request.channelId, event);
3892
+ }
3893
+ );
3894
+ if (fullText.trim() && platform !== "web" && platform !== "scheduler") {
3895
+ const adapter = this.adapterMap?.get(platform);
3896
+ if (adapter && isMessageSender(adapter)) {
3897
+ await adapter.sendMessage(request.channelId, fullText);
3898
+ }
3899
+ }
3900
+ this.reply(request.id, {
3901
+ ...result,
3902
+ text: fullText
3903
+ });
3904
+ return;
3905
+ }
3906
+ case "command": {
3907
+ if (!request.channelId || typeof request.channelId !== "string") {
3908
+ this.replyError(request.id, "channelId is required");
3909
+ return;
3910
+ }
3911
+ const result = await this.agent.handleCommand(request.command, request.channelId);
3912
+ this.reply(request.id, result);
3913
+ return;
3914
+ }
3915
+ case "get_config": {
3916
+ this.reply(request.id, configManager.getConfig());
3917
+ return;
3918
+ }
3919
+ case "update_config": {
3920
+ configManager.save(this.rootDir, request.updates || {});
3921
+ const updated = configManager.getConfig();
3922
+ const provider = updated.provider || "openai";
3923
+ this.agent.updateAuth(provider, updated.apiKey);
3924
+ this.reply(request.id, updated);
3925
+ return;
3926
+ }
3927
+ case "get_status": {
3928
+ this.reply(request.id, {
3929
+ status: "running",
3930
+ pid: process.pid
3931
+ });
3932
+ return;
3933
+ }
3934
+ case "get_scheduled_jobs": {
3935
+ const scheduler = this.getSchedulerAdapter();
3936
+ this.reply(request.id, scheduler ? scheduler.listJobs() : []);
3937
+ return;
3938
+ }
3939
+ case "add_scheduled_job": {
3940
+ const scheduler = this.getSchedulerAdapter();
3941
+ if (!scheduler) {
3942
+ this.replyError(request.id, "Scheduler adapter is not available");
3943
+ return;
3944
+ }
3945
+ const result = scheduler.addJob(request.job);
3946
+ if (!result.success) {
3947
+ this.replyError(request.id, result.message);
3948
+ return;
3949
+ }
3950
+ this.reply(request.id, result);
3951
+ return;
3952
+ }
3953
+ case "remove_scheduled_job": {
3954
+ const scheduler = this.getSchedulerAdapter();
3955
+ if (!scheduler) {
3956
+ this.replyError(request.id, "Scheduler adapter is not available");
3957
+ return;
3958
+ }
3959
+ const result = scheduler.removeJob(request.name);
3960
+ if (!result.success) {
3961
+ this.replyError(request.id, result.message);
3962
+ return;
3963
+ }
3964
+ this.reply(request.id, result);
3965
+ return;
3966
+ }
3967
+ }
3968
+ } catch (err) {
3969
+ this.replyError(
3970
+ request.id,
3971
+ err instanceof Error ? err.message : String(err)
3972
+ );
3973
+ }
3974
+ }
3975
+ getSchedulerAdapter() {
3976
+ const adapter = this.adapterMap?.get("scheduler");
3977
+ if (!adapter) return null;
3978
+ return adapter;
3979
+ }
3980
+ detectPlatform(channelId) {
3981
+ if (channelId.startsWith("telegram-")) return "telegram";
3982
+ if (channelId.startsWith("slack-")) return "slack";
3983
+ if (channelId.startsWith("scheduler-")) return "scheduler";
3984
+ return "web";
3985
+ }
3986
+ sendIpc(payload) {
3987
+ if (typeof process.send === "function") {
3988
+ process.send(payload);
3989
+ }
3990
+ }
3991
+ reply(id, data) {
3992
+ this.sendIpc({ id, type: "result", data });
3993
+ }
3994
+ replyError(id, message) {
3995
+ this.sendIpc({ id, type: "error", message });
3996
+ }
3997
+ };
3998
+
6194
3999
  // src/runtime/server.ts
6195
4000
  init_config();
6196
4001
 
@@ -6267,28 +4072,28 @@ var Lifecycle = class {
6267
4072
 
6268
4073
  // src/runtime/registry.ts
6269
4074
  import crypto from "crypto";
6270
- import fs11 from "fs";
4075
+ import fs12 from "fs";
6271
4076
  import os from "os";
6272
- import path11 from "path";
6273
- var SKILLPACK_HOME = path11.join(os.homedir(), ".skillpack");
6274
- var LEGACY_REGISTRY_FILE = path11.join(SKILLPACK_HOME, "registry.json");
6275
- var REGISTRY_DIR = path11.join(SKILLPACK_HOME, "registry.d");
4077
+ import path12 from "path";
4078
+ var SKILLPACK_HOME = path12.join(os.homedir(), ".skillpack");
4079
+ var LEGACY_REGISTRY_FILE = path12.join(SKILLPACK_HOME, "registry.json");
4080
+ var REGISTRY_DIR = path12.join(SKILLPACK_HOME, "registry.d");
6276
4081
  var migrationChecked = false;
6277
4082
  function ensureHomeDir() {
6278
- if (!fs11.existsSync(SKILLPACK_HOME)) {
6279
- fs11.mkdirSync(SKILLPACK_HOME, { recursive: true });
4083
+ if (!fs12.existsSync(SKILLPACK_HOME)) {
4084
+ fs12.mkdirSync(SKILLPACK_HOME, { recursive: true });
6280
4085
  }
6281
4086
  }
6282
4087
  function ensureRegistryDir() {
6283
4088
  ensureHomeDir();
6284
- if (!fs11.existsSync(REGISTRY_DIR)) {
6285
- fs11.mkdirSync(REGISTRY_DIR, { recursive: true });
4089
+ if (!fs12.existsSync(REGISTRY_DIR)) {
4090
+ fs12.mkdirSync(REGISTRY_DIR, { recursive: true });
6286
4091
  }
6287
4092
  }
6288
4093
  function canonicalizeDir(dir) {
6289
- const resolved = path11.resolve(dir);
4094
+ const resolved = path12.resolve(dir);
6290
4095
  try {
6291
- return fs11.realpathSync(resolved);
4096
+ return fs12.realpathSync(resolved);
6292
4097
  } catch {
6293
4098
  return resolved;
6294
4099
  }
@@ -6297,7 +4102,7 @@ function hashDir(dir) {
6297
4102
  return crypto.createHash("md5").update(canonicalizeDir(dir)).digest("hex");
6298
4103
  }
6299
4104
  function getEntryPathForCanonicalDir(dir) {
6300
- return path11.join(REGISTRY_DIR, `${hashDir(dir)}.json`);
4105
+ return path12.join(REGISTRY_DIR, `${hashDir(dir)}.json`);
6301
4106
  }
6302
4107
  function getEntryPath(dir) {
6303
4108
  ensureRegistryReady();
@@ -6305,11 +4110,11 @@ function getEntryPath(dir) {
6305
4110
  }
6306
4111
  function listEntryFiles() {
6307
4112
  ensureRegistryReady();
6308
- return fs11.readdirSync(REGISTRY_DIR).filter((file) => file.endsWith(".json")).sort().map((file) => path11.join(REGISTRY_DIR, file));
4113
+ return fs12.readdirSync(REGISTRY_DIR).filter((file) => file.endsWith(".json")).sort().map((file) => path12.join(REGISTRY_DIR, file));
6309
4114
  }
6310
4115
  function readEntryFile(filePath) {
6311
4116
  try {
6312
- const raw = fs11.readFileSync(filePath, "utf-8");
4117
+ const raw = fs12.readFileSync(filePath, "utf-8");
6313
4118
  const data = JSON.parse(raw);
6314
4119
  if (typeof data?.dir !== "string" || typeof data?.name !== "string" || typeof data?.version !== "string" || typeof data?.port !== "number" || typeof data?.pid !== "number" && data?.pid !== null || data?.status !== "running" && data?.status !== "stopped") {
6315
4120
  return null;
@@ -6342,8 +4147,8 @@ function writeEntryFile(entry) {
6342
4147
  };
6343
4148
  const entryPath = getEntryPathForCanonicalDir(normalized.dir);
6344
4149
  const tmpPath = createTmpPath(entryPath);
6345
- fs11.writeFileSync(tmpPath, JSON.stringify(normalized, null, 2), "utf-8");
6346
- fs11.renameSync(tmpPath, entryPath);
4150
+ fs12.writeFileSync(tmpPath, JSON.stringify(normalized, null, 2), "utf-8");
4151
+ fs12.renameSync(tmpPath, entryPath);
6347
4152
  }
6348
4153
  function migrateLegacyRegistryIfNeeded() {
6349
4154
  if (migrationChecked) {
@@ -6351,14 +4156,14 @@ function migrateLegacyRegistryIfNeeded() {
6351
4156
  }
6352
4157
  migrationChecked = true;
6353
4158
  ensureRegistryDir();
6354
- if (!fs11.existsSync(LEGACY_REGISTRY_FILE)) {
4159
+ if (!fs12.existsSync(LEGACY_REGISTRY_FILE)) {
6355
4160
  return;
6356
4161
  }
6357
4162
  if (listEntryFiles().length > 0) {
6358
4163
  return;
6359
4164
  }
6360
4165
  try {
6361
- const raw = fs11.readFileSync(LEGACY_REGISTRY_FILE, "utf-8");
4166
+ const raw = fs12.readFileSync(LEGACY_REGISTRY_FILE, "utf-8");
6362
4167
  const data = JSON.parse(raw);
6363
4168
  const packs = Array.isArray(data?.packs) ? data.packs : [];
6364
4169
  for (const pack of packs) {
@@ -6371,7 +4176,7 @@ function migrateLegacyRegistryIfNeeded() {
6371
4176
  } catch {
6372
4177
  }
6373
4178
  }
6374
- fs11.renameSync(LEGACY_REGISTRY_FILE, `${LEGACY_REGISTRY_FILE}.legacy`);
4179
+ fs12.renameSync(LEGACY_REGISTRY_FILE, `${LEGACY_REGISTRY_FILE}.legacy`);
6375
4180
  } catch (err) {
6376
4181
  console.warn(" [Registry] Failed to migrate legacy registry.json:", err);
6377
4182
  }
@@ -6424,7 +4229,7 @@ function deregister(dir, pid) {
6424
4229
  }
6425
4230
 
6426
4231
  // src/runtime/server.ts
6427
- var __dirname = path13.dirname(fileURLToPath2(import.meta.url));
4232
+ var __dirname = path14.dirname(fileURLToPath2(import.meta.url));
6428
4233
  async function startServer(options) {
6429
4234
  const {
6430
4235
  rootDir,
@@ -6440,8 +4245,8 @@ async function startServer(options) {
6440
4245
  const baseUrl = dataConfig.baseUrl?.trim() || void 0;
6441
4246
  const modelId = dataConfig.modelId?.trim() || (SUPPORTED_PROVIDERS[provider]?.defaultModelId ?? SUPPORTED_PROVIDERS.openai.defaultModelId);
6442
4247
  const apiProtocol = dataConfig.apiProtocol;
6443
- const packageRoot = path13.resolve(__dirname, "..");
6444
- const webDir = fs14.existsSync(path13.join(rootDir, "web")) ? path13.join(rootDir, "web") : path13.join(packageRoot, "web");
4248
+ const packageRoot = path14.resolve(__dirname, "..");
4249
+ const webDir = fs15.existsSync(path14.join(rootDir, "web")) ? path14.join(rootDir, "web") : path14.join(packageRoot, "web");
6445
4250
  const app = express();
6446
4251
  app.use(express.json());
6447
4252
  app.use(express.static(webDir));
@@ -6470,8 +4275,31 @@ async function startServer(options) {
6470
4275
  });
6471
4276
  const adapters = [];
6472
4277
  const adapterMap = /* @__PURE__ */ new Map();
4278
+ const hasIpcChannel = typeof process.send === "function";
4279
+ const ipcAdapter = new IpcAdapter();
4280
+ if (hasIpcChannel) {
4281
+ await ipcAdapter.start({
4282
+ agent,
4283
+ server,
4284
+ app,
4285
+ rootDir,
4286
+ lifecycle,
4287
+ adapterMap
4288
+ });
4289
+ adapters.push(ipcAdapter);
4290
+ adapterMap.set(ipcAdapter.name, ipcAdapter);
4291
+ }
4292
+ const ipcBroadcaster = hasIpcChannel ? ipcAdapter : void 0;
6473
4293
  const webAdapter = new WebAdapter();
6474
- await webAdapter.start({ agent, server, app, rootDir, lifecycle, adapterMap });
4294
+ await webAdapter.start({
4295
+ agent,
4296
+ server,
4297
+ app,
4298
+ rootDir,
4299
+ lifecycle,
4300
+ adapterMap,
4301
+ ipcBroadcaster
4302
+ });
6475
4303
  adapters.push(webAdapter);
6476
4304
  adapterMap.set(webAdapter.name, webAdapter);
6477
4305
  if (dataConfig.adapters?.telegram?.token) {
@@ -6480,7 +4308,15 @@ async function startServer(options) {
6480
4308
  const telegramAdapter = new TelegramAdapter2({
6481
4309
  token: dataConfig.adapters.telegram.token
6482
4310
  });
6483
- await telegramAdapter.start({ agent, server, app, rootDir, lifecycle });
4311
+ await telegramAdapter.start({
4312
+ agent,
4313
+ server,
4314
+ app,
4315
+ rootDir,
4316
+ lifecycle,
4317
+ adapterMap,
4318
+ ipcBroadcaster
4319
+ });
6484
4320
  adapters.push(telegramAdapter);
6485
4321
  adapterMap.set(telegramAdapter.name, telegramAdapter);
6486
4322
  } catch (err) {
@@ -6500,7 +4336,15 @@ async function startServer(options) {
6500
4336
  botToken: slackConfig.botToken,
6501
4337
  appToken: slackConfig.appToken
6502
4338
  });
6503
- await slackAdapter.start({ agent, server, app, rootDir, lifecycle });
4339
+ await slackAdapter.start({
4340
+ agent,
4341
+ server,
4342
+ app,
4343
+ rootDir,
4344
+ lifecycle,
4345
+ adapterMap,
4346
+ ipcBroadcaster
4347
+ });
6504
4348
  adapters.push(slackAdapter);
6505
4349
  adapterMap.set(slackAdapter.name, slackAdapter);
6506
4350
  } catch (err) {
@@ -6563,6 +4407,9 @@ async function startServer(options) {
6563
4407
  } catch (err) {
6564
4408
  console.warn(" [Registry] Could not register pack:", err);
6565
4409
  }
4410
+ if (hasIpcChannel) {
4411
+ ipcAdapter.notifyReady(typeof actualPort === "number" ? actualPort : port);
4412
+ }
6566
4413
  if (!daemonRun) {
6567
4414
  const cmd = process.platform === "darwin" ? `open ${url}` : process.platform === "win32" ? `start ${url}` : `xdg-open ${url}`;
6568
4415
  exec(cmd, (err) => {
@@ -6610,23 +4457,23 @@ function findMissingSkills(workDir, config) {
6610
4457
  });
6611
4458
  }
6612
4459
  function copyStartTemplates2(workDir) {
6613
- const templateDir = path14.resolve(
4460
+ const templateDir = path15.resolve(
6614
4461
  new URL("../templates", import.meta.url).pathname
6615
4462
  );
6616
4463
  for (const file of ["start.sh", "start.bat"]) {
6617
- const src = path14.join(templateDir, file);
6618
- const dest = path14.join(workDir, file);
6619
- if (fs15.existsSync(src)) {
6620
- fs15.copyFileSync(src, dest);
4464
+ const src = path15.join(templateDir, file);
4465
+ const dest = path15.join(workDir, file);
4466
+ if (fs16.existsSync(src)) {
4467
+ fs16.copyFileSync(src, dest);
6621
4468
  if (file === "start.sh") {
6622
- fs15.chmodSync(dest, 493);
4469
+ fs16.chmodSync(dest, 493);
6623
4470
  }
6624
4471
  }
6625
4472
  }
6626
4473
  }
6627
4474
  async function runCommand(directory) {
6628
- const workDir = directory ? path14.resolve(directory) : process.cwd();
6629
- fs15.mkdirSync(workDir, { recursive: true });
4475
+ const workDir = directory ? path15.resolve(directory) : process.cwd();
4476
+ fs16.mkdirSync(workDir, { recursive: true });
6630
4477
  if (!configExists(workDir)) {
6631
4478
  console.log(chalk4.blue("\n No skillpack.json found. Let's set one up.\n"));
6632
4479
  const { name, description } = await inquirer2.prompt([
@@ -6671,11 +4518,14 @@ async function runCommand(directory) {
6671
4518
  }
6672
4519
 
6673
4520
  // src/cli.ts
6674
- import fs16 from "fs";
4521
+ import fs17 from "fs";
4522
+ import path16 from "path";
4523
+ import { fileURLToPath as fileURLToPath3 } from "url";
6675
4524
  var packageJson = JSON.parse(
6676
- fs16.readFileSync(new URL("../package.json", import.meta.url), "utf-8")
4525
+ fs17.readFileSync(new URL("../package.json", import.meta.url), "utf-8")
6677
4526
  );
6678
4527
  var program = new Command();
4528
+ var cliFilePath = path16.resolve(fileURLToPath3(import.meta.url));
6679
4529
  program.name("skillpack").description("Assemble, package, and run Agent Skills packs").version(packageJson.version);
6680
4530
  program.command("create [directory]").description("Create a skills pack interactively").option("--config <path-or-url>", "Initialize from a local or remote skillpack.json").action(async (directory, options) => {
6681
4531
  await createCommand(directory, options);
@@ -6693,4 +4543,12 @@ program.command("zip").description("Package the current pack as a zip file (skil
6693
4543
  process.exit(1);
6694
4544
  }
6695
4545
  });
6696
- program.parse();
4546
+ function normalizeUserArgs(argv) {
4547
+ if (argv.length === 0) return argv;
4548
+ const firstArg = argv[0];
4549
+ if (firstArg && path16.resolve(firstArg) === cliFilePath) {
4550
+ return argv.slice(1);
4551
+ }
4552
+ return argv;
4553
+ }
4554
+ program.parse(normalizeUserArgs(process.argv.slice(2)), { from: "user" });