switchroom 0.13.65 → 0.14.1

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.
Files changed (30) hide show
  1. package/dist/agent-scheduler/index.js +80 -80
  2. package/dist/auth-broker/index.js +96 -81
  3. package/dist/cli/drive-write-pretool.mjs +10 -10
  4. package/dist/cli/notion-write-pretool.mjs +82 -82
  5. package/dist/cli/skill-validate-pretool.mjs +72 -72
  6. package/dist/cli/switchroom.js +1883 -1479
  7. package/dist/host-control/main.js +149 -149
  8. package/dist/vault/approvals/kernel-server.js +82 -82
  9. package/dist/vault/broker/server.js +83 -83
  10. package/package.json +1 -1
  11. package/profiles/_shared/telegram-style.md.hbs +1 -1
  12. package/telegram-plugin/auth-snapshot-format.ts +47 -1
  13. package/telegram-plugin/dist/bridge/bridge.js +112 -112
  14. package/telegram-plugin/dist/gateway/gateway.js +1226 -696
  15. package/telegram-plugin/dist/server.js +160 -160
  16. package/telegram-plugin/gateway/boot-card.ts +100 -0
  17. package/telegram-plugin/gateway/config-snapshot.ts +274 -0
  18. package/telegram-plugin/gateway/gateway.ts +256 -36
  19. package/telegram-plugin/operator-events.ts +2 -10
  20. package/telegram-plugin/quota-watch.ts +276 -0
  21. package/telegram-plugin/tests/auth-snapshot-format.test.ts +133 -1
  22. package/telegram-plugin/tests/boot-card-render.test.ts +93 -0
  23. package/telegram-plugin/tests/config-snapshot.test.ts +409 -0
  24. package/telegram-plugin/tests/operator-events.test.ts +12 -6
  25. package/telegram-plugin/tests/quota-watch.test.ts +366 -0
  26. package/telegram-plugin/tests/tool-activity-summary.test.ts +66 -0
  27. package/telegram-plugin/tests/turn-flush-safety.test.ts +48 -0
  28. package/telegram-plugin/tool-activity-summary.ts +137 -0
  29. package/telegram-plugin/turn-flush-safety.ts +47 -0
  30. package/telegram-plugin/uat/assertions.ts +4 -4
@@ -66,7 +66,7 @@ var __export = (target, all) => {
66
66
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
67
67
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
68
68
 
69
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/filter.js
69
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/filter.js
70
70
  var require_filter = __commonJS((exports) => {
71
71
  Object.defineProperty(exports, "__esModule", { value: true });
72
72
  exports.matchFilter = matchFilter;
@@ -430,7 +430,7 @@ var require_filter = __commonJS((exports) => {
430
430
  };
431
431
  });
432
432
 
433
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/context.js
433
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/context.js
434
434
  var require_context = __commonJS((exports) => {
435
435
  Object.defineProperty(exports, "__esModule", { value: true });
436
436
  exports.Context = undefined;
@@ -1457,7 +1457,7 @@ var require_context = __commonJS((exports) => {
1457
1457
  }
1458
1458
  });
1459
1459
 
1460
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/composer.js
1460
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/composer.js
1461
1461
  var require_composer = __commonJS((exports) => {
1462
1462
  Object.defineProperty(exports, "__esModule", { value: true });
1463
1463
  exports.Composer = exports.BotError = undefined;
@@ -1619,7 +1619,7 @@ var require_composer = __commonJS((exports) => {
1619
1619
  exports.Composer = Composer;
1620
1620
  });
1621
1621
 
1622
- // ../../switchroom-sec-1417/node_modules/.bun/ms@2.1.3/node_modules/ms/index.js
1622
+ // ../node_modules/.bun/ms@2.1.3/node_modules/ms/index.js
1623
1623
  var require_ms = __commonJS((exports, module) => {
1624
1624
  var s = 1000;
1625
1625
  var m = s * 60;
@@ -1729,7 +1729,7 @@ var require_ms = __commonJS((exports, module) => {
1729
1729
  }
1730
1730
  });
1731
1731
 
1732
- // ../../switchroom-sec-1417/node_modules/.bun/debug@4.4.3/node_modules/debug/src/common.js
1732
+ // ../node_modules/.bun/debug@4.4.3/node_modules/debug/src/common.js
1733
1733
  var require_common = __commonJS((exports, module) => {
1734
1734
  function setup(env) {
1735
1735
  createDebug.debug = createDebug;
@@ -1904,7 +1904,7 @@ var require_common = __commonJS((exports, module) => {
1904
1904
  module.exports = setup;
1905
1905
  });
1906
1906
 
1907
- // ../../switchroom-sec-1417/node_modules/.bun/debug@4.4.3/node_modules/debug/src/browser.js
1907
+ // ../node_modules/.bun/debug@4.4.3/node_modules/debug/src/browser.js
1908
1908
  var require_browser = __commonJS((exports, module) => {
1909
1909
  exports.formatArgs = formatArgs;
1910
1910
  exports.save = save;
@@ -2064,7 +2064,7 @@ var require_browser = __commonJS((exports, module) => {
2064
2064
  };
2065
2065
  });
2066
2066
 
2067
- // ../../switchroom-sec-1417/node_modules/.bun/has-flag@4.0.0/node_modules/has-flag/index.js
2067
+ // ../node_modules/.bun/has-flag@4.0.0/node_modules/has-flag/index.js
2068
2068
  var require_has_flag = __commonJS((exports, module) => {
2069
2069
  module.exports = (flag, argv = process.argv) => {
2070
2070
  const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
@@ -2074,7 +2074,7 @@ var require_has_flag = __commonJS((exports, module) => {
2074
2074
  };
2075
2075
  });
2076
2076
 
2077
- // ../../switchroom-sec-1417/node_modules/.bun/supports-color@7.2.0/node_modules/supports-color/index.js
2077
+ // ../node_modules/.bun/supports-color@7.2.0/node_modules/supports-color/index.js
2078
2078
  var require_supports_color = __commonJS((exports, module) => {
2079
2079
  var os = __require("os");
2080
2080
  var tty = __require("tty");
@@ -2173,7 +2173,7 @@ var require_supports_color = __commonJS((exports, module) => {
2173
2173
  };
2174
2174
  });
2175
2175
 
2176
- // ../../switchroom-sec-1417/node_modules/.bun/debug@4.4.3/node_modules/debug/src/node.js
2176
+ // ../node_modules/.bun/debug@4.4.3/node_modules/debug/src/node.js
2177
2177
  var require_node = __commonJS((exports, module) => {
2178
2178
  var tty = __require("tty");
2179
2179
  var util = __require("util");
@@ -2344,7 +2344,7 @@ var require_node = __commonJS((exports, module) => {
2344
2344
  };
2345
2345
  });
2346
2346
 
2347
- // ../../switchroom-sec-1417/node_modules/.bun/debug@4.4.3/node_modules/debug/src/index.js
2347
+ // ../node_modules/.bun/debug@4.4.3/node_modules/debug/src/index.js
2348
2348
  var require_src = __commonJS((exports, module) => {
2349
2349
  if (typeof process === "undefined" || process.type === "renderer" || false || process.__nwjs) {
2350
2350
  module.exports = require_browser();
@@ -2353,7 +2353,7 @@ var require_src = __commonJS((exports, module) => {
2353
2353
  }
2354
2354
  });
2355
2355
 
2356
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/platform.node.js
2356
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/platform.node.js
2357
2357
  var require_platform_node = __commonJS((exports) => {
2358
2358
  Object.defineProperty(exports, "__esModule", { value: true });
2359
2359
  exports.defaultAdapter = exports.itrToStream = exports.debug = undefined;
@@ -2393,7 +2393,7 @@ var require_platform_node = __commonJS((exports) => {
2393
2393
  exports.defaultAdapter = "express";
2394
2394
  });
2395
2395
 
2396
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/core/error.js
2396
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/core/error.js
2397
2397
  var require_error = __commonJS((exports) => {
2398
2398
  Object.defineProperty(exports, "__esModule", { value: true });
2399
2399
  exports.HttpError = exports.GrammyError = undefined;
@@ -2449,10 +2449,10 @@ var require_error = __commonJS((exports) => {
2449
2449
  }
2450
2450
  });
2451
2451
 
2452
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+types@3.26.0/node_modules/@grammyjs/types/mod.js
2452
+ // ../node_modules/.bun/@grammyjs+types@3.26.0/node_modules/@grammyjs/types/mod.js
2453
2453
  var exports_mod = {};
2454
2454
 
2455
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/types.node.js
2455
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/types.node.js
2456
2456
  var require_types_node = __commonJS((exports) => {
2457
2457
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
2458
2458
  if (k2 === undefined)
@@ -2543,7 +2543,7 @@ var require_types_node = __commonJS((exports) => {
2543
2543
  }
2544
2544
  });
2545
2545
 
2546
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/types.js
2546
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/types.js
2547
2547
  var require_types = __commonJS((exports) => {
2548
2548
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
2549
2549
  if (k2 === undefined)
@@ -2569,7 +2569,7 @@ var require_types = __commonJS((exports) => {
2569
2569
  __exportStar(require_types_node(), exports);
2570
2570
  });
2571
2571
 
2572
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/core/payload.js
2572
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/core/payload.js
2573
2573
  var require_payload = __commonJS((exports) => {
2574
2574
  Object.defineProperty(exports, "__esModule", { value: true });
2575
2575
  exports.requiresFormDataUpload = requiresFormDataUpload;
@@ -2709,7 +2709,7 @@ content-type:application/octet-stream\r
2709
2709
  }
2710
2710
  });
2711
2711
 
2712
- // ../../switchroom-sec-1417/node_modules/.bun/event-target-shim@5.0.1/node_modules/event-target-shim/dist/event-target-shim.js
2712
+ // ../node_modules/.bun/event-target-shim@5.0.1/node_modules/event-target-shim/dist/event-target-shim.js
2713
2713
  var require_event_target_shim = __commonJS((exports, module) => {
2714
2714
  Object.defineProperty(exports, "__esModule", { value: true });
2715
2715
  var privateData = new WeakMap;
@@ -3149,7 +3149,7 @@ var require_event_target_shim = __commonJS((exports, module) => {
3149
3149
  module.exports.defineEventAttribute = defineEventAttribute;
3150
3150
  });
3151
3151
 
3152
- // ../../switchroom-sec-1417/node_modules/.bun/abort-controller@3.0.0/node_modules/abort-controller/dist/abort-controller.js
3152
+ // ../node_modules/.bun/abort-controller@3.0.0/node_modules/abort-controller/dist/abort-controller.js
3153
3153
  var require_abort_controller = __commonJS((exports, module) => {
3154
3154
  Object.defineProperty(exports, "__esModule", { value: true });
3155
3155
  var eventTargetShim = require_event_target_shim();
@@ -3229,7 +3229,7 @@ var require_abort_controller = __commonJS((exports, module) => {
3229
3229
  module.exports.AbortSignal = AbortSignal2;
3230
3230
  });
3231
3231
 
3232
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/shim.node.js
3232
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/shim.node.js
3233
3233
  var require_shim_node = __commonJS((exports) => {
3234
3234
  Object.defineProperty(exports, "__esModule", { value: true });
3235
3235
  exports.fetch = exports.AbortController = undefined;
@@ -3243,7 +3243,7 @@ var require_shim_node = __commonJS((exports) => {
3243
3243
  } });
3244
3244
  });
3245
3245
 
3246
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/core/client.js
3246
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/core/client.js
3247
3247
  var require_client = __commonJS((exports) => {
3248
3248
  Object.defineProperty(exports, "__esModule", { value: true });
3249
3249
  exports.createRawApi = createRawApi;
@@ -3423,7 +3423,7 @@ If you want to prevent such mistakes in the future, consider using TypeScript. h
3423
3423
  var shim_node_js_1 = require_shim_node();
3424
3424
  });
3425
3425
 
3426
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/core/api.js
3426
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/core/api.js
3427
3427
  var require_api = __commonJS((exports) => {
3428
3428
  Object.defineProperty(exports, "__esModule", { value: true });
3429
3429
  exports.Api = undefined;
@@ -4041,7 +4041,7 @@ var require_api = __commonJS((exports) => {
4041
4041
  exports.Api = Api;
4042
4042
  });
4043
4043
 
4044
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/bot.js
4044
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/bot.js
4045
4045
  var require_bot = __commonJS((exports) => {
4046
4046
  Object.defineProperty(exports, "__esModule", { value: true });
4047
4047
  exports.Bot = exports.BotError = exports.DEFAULT_UPDATE_TYPES = undefined;
@@ -4370,7 +4370,7 @@ On the other hand, if you actually know what you're doing and you do need to ins
4370
4370
  var shim_node_js_1 = require_shim_node();
4371
4371
  });
4372
4372
 
4373
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/constants.js
4373
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/constants.js
4374
4374
  var require_constants = __commonJS((exports) => {
4375
4375
  Object.defineProperty(exports, "__esModule", { value: true });
4376
4376
  exports.API_CONSTANTS = undefined;
@@ -4406,7 +4406,7 @@ var require_constants = __commonJS((exports) => {
4406
4406
  Object.freeze(exports.API_CONSTANTS);
4407
4407
  });
4408
4408
 
4409
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/inline_query.js
4409
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/inline_query.js
4410
4410
  var require_inline_query = __commonJS((exports) => {
4411
4411
  Object.defineProperty(exports, "__esModule", { value: true });
4412
4412
  exports.InlineQueryResultBuilder = undefined;
@@ -4604,7 +4604,7 @@ var require_inline_query = __commonJS((exports) => {
4604
4604
  };
4605
4605
  });
4606
4606
 
4607
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/input_media.js
4607
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/input_media.js
4608
4608
  var require_input_media = __commonJS((exports) => {
4609
4609
  Object.defineProperty(exports, "__esModule", { value: true });
4610
4610
  exports.InputMediaBuilder = undefined;
@@ -4627,7 +4627,7 @@ var require_input_media = __commonJS((exports) => {
4627
4627
  };
4628
4628
  });
4629
4629
 
4630
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/keyboard.js
4630
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/keyboard.js
4631
4631
  var require_keyboard = __commonJS((exports) => {
4632
4632
  Object.defineProperty(exports, "__esModule", { value: true });
4633
4633
  exports.InlineKeyboard = exports.Keyboard = undefined;
@@ -4985,7 +4985,7 @@ var require_keyboard = __commonJS((exports) => {
4985
4985
  }
4986
4986
  });
4987
4987
 
4988
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/session.js
4988
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/session.js
4989
4989
  var require_session = __commonJS((exports) => {
4990
4990
  Object.defineProperty(exports, "__esModule", { value: true });
4991
4991
  exports.MemorySessionStorage = undefined;
@@ -5285,7 +5285,7 @@ var require_session = __commonJS((exports) => {
5285
5285
  }
5286
5286
  });
5287
5287
 
5288
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/frameworks.js
5288
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/frameworks.js
5289
5289
  var require_frameworks = __commonJS((exports) => {
5290
5290
  Object.defineProperty(exports, "__esModule", { value: true });
5291
5291
  exports.adapters = undefined;
@@ -5653,7 +5653,7 @@ var require_frameworks = __commonJS((exports) => {
5653
5653
  };
5654
5654
  });
5655
5655
 
5656
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/webhook.js
5656
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/convenience/webhook.js
5657
5657
  var require_webhook = __commonJS((exports) => {
5658
5658
  Object.defineProperty(exports, "__esModule", { value: true });
5659
5659
  exports.webhookCallback = webhookCallback;
@@ -5747,7 +5747,7 @@ var require_webhook = __commonJS((exports) => {
5747
5747
  }
5748
5748
  });
5749
5749
 
5750
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/mod.js
5750
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/mod.js
5751
5751
  var require_mod = __commonJS((exports) => {
5752
5752
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
5753
5753
  if (k2 === undefined)
@@ -5813,7 +5813,7 @@ var require_mod = __commonJS((exports) => {
5813
5813
  } });
5814
5814
  });
5815
5815
 
5816
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/platform.node.js
5816
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/platform.node.js
5817
5817
  var require_platform_node2 = __commonJS((exports) => {
5818
5818
  Object.defineProperty(exports, "__esModule", { value: true });
5819
5819
  exports.parentThread = exports.createThread = undefined;
@@ -5844,7 +5844,7 @@ var require_platform_node2 = __commonJS((exports) => {
5844
5844
  exports.parentThread = parentThread;
5845
5845
  });
5846
5846
 
5847
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/distribute.js
5847
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/distribute.js
5848
5848
  var require_distribute = __commonJS((exports) => {
5849
5849
  Object.defineProperty(exports, "__esModule", { value: true });
5850
5850
  exports.distribute = undefined;
@@ -5889,7 +5889,7 @@ var require_distribute = __commonJS((exports) => {
5889
5889
  exports.distribute = distribute;
5890
5890
  });
5891
5891
 
5892
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/queue.js
5892
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/queue.js
5893
5893
  var require_queue = __commonJS((exports) => {
5894
5894
  Object.defineProperty(exports, "__esModule", { value: true });
5895
5895
  exports.DecayingDeque = undefined;
@@ -6033,7 +6033,7 @@ var require_queue = __commonJS((exports) => {
6033
6033
  exports.DecayingDeque = DecayingDeque;
6034
6034
  });
6035
6035
 
6036
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/sink.js
6036
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/sink.js
6037
6037
  var require_sink = __commonJS((exports) => {
6038
6038
  Object.defineProperty(exports, "__esModule", { value: true });
6039
6039
  exports.createConcurrentSink = exports.createBatchSink = exports.createSequentialSink = undefined;
@@ -6078,7 +6078,7 @@ var require_sink = __commonJS((exports) => {
6078
6078
  exports.createConcurrentSink = createConcurrentSink;
6079
6079
  });
6080
6080
 
6081
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/node-shim.js
6081
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/node-shim.js
6082
6082
  var require_node_shim = __commonJS((exports) => {
6083
6083
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
6084
6084
  if (k2 === undefined)
@@ -6104,7 +6104,7 @@ var require_node_shim = __commonJS((exports) => {
6104
6104
  __exportStar(require_abort_controller(), exports);
6105
6105
  });
6106
6106
 
6107
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/source.js
6107
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/source.js
6108
6108
  var require_source = __commonJS((exports) => {
6109
6109
  Object.defineProperty(exports, "__esModule", { value: true });
6110
6110
  exports.createSource = undefined;
@@ -6184,7 +6184,7 @@ var require_source = __commonJS((exports) => {
6184
6184
  var node_shim_js_1 = require_node_shim();
6185
6185
  });
6186
6186
 
6187
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/runner.js
6187
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/runner.js
6188
6188
  var require_runner = __commonJS((exports) => {
6189
6189
  Object.defineProperty(exports, "__esModule", { value: true });
6190
6190
  exports.createRunner = exports.createUpdateFetcher = exports.run = undefined;
@@ -6336,7 +6336,7 @@ var require_runner = __commonJS((exports) => {
6336
6336
  }
6337
6337
  });
6338
6338
 
6339
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/sequentialize.js
6339
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/sequentialize.js
6340
6340
  var require_sequentialize = __commonJS((exports) => {
6341
6341
  Object.defineProperty(exports, "__esModule", { value: true });
6342
6342
  exports.sequentialize = undefined;
@@ -6379,7 +6379,7 @@ var require_sequentialize = __commonJS((exports) => {
6379
6379
  exports.sequentialize = sequentialize;
6380
6380
  });
6381
6381
 
6382
- // ../../switchroom-sec-1417/node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/mod.js
6382
+ // ../node_modules/.bun/grammy@1.42.0/node_modules/grammy/out/mod.js
6383
6383
  var require_mod2 = __commonJS((exports) => {
6384
6384
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
6385
6385
  if (k2 === undefined)
@@ -6445,7 +6445,7 @@ var require_mod2 = __commonJS((exports) => {
6445
6445
  } });
6446
6446
  });
6447
6447
 
6448
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/deps.node.js
6448
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/deps.node.js
6449
6449
  var require_deps_node = __commonJS((exports) => {
6450
6450
  Object.defineProperty(exports, "__esModule", { value: true });
6451
6451
  exports.BotError = exports.Bot = undefined;
@@ -6458,7 +6458,7 @@ var require_deps_node = __commonJS((exports) => {
6458
6458
  } });
6459
6459
  });
6460
6460
 
6461
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/worker.js
6461
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/worker.js
6462
6462
  var require_worker = __commonJS((exports) => {
6463
6463
  Object.defineProperty(exports, "__esModule", { value: true });
6464
6464
  exports.BotWorker = undefined;
@@ -6500,7 +6500,7 @@ var require_worker = __commonJS((exports) => {
6500
6500
  exports.BotWorker = BotWorker;
6501
6501
  });
6502
6502
 
6503
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/mod.js
6503
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/mod.js
6504
6504
  var require_mod3 = __commonJS((exports) => {
6505
6505
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
6506
6506
  if (k2 === undefined)
@@ -6532,7 +6532,7 @@ var require_mod3 = __commonJS((exports) => {
6532
6532
  __exportStar(require_worker(), exports);
6533
6533
  });
6534
6534
 
6535
- // ../../switchroom-sec-1417/node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/mod.js
6535
+ // ../node_modules/.bun/@grammyjs+runner@2.0.3+c6be0243b1bbec89/node_modules/@grammyjs/runner/out/mod.js
6536
6536
  var require_mod4 = __commonJS((exports) => {
6537
6537
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
6538
6538
  if (k2 === undefined)
@@ -6564,7 +6564,7 @@ var require_mod4 = __commonJS((exports) => {
6564
6564
  __exportStar(require_worker(), exports);
6565
6565
  });
6566
6566
 
6567
- // ../../switchroom-sec-1417/node_modules/.bun/@xterm+headless@6.0.0/node_modules/@xterm/headless/lib-headless/xterm-headless.js
6567
+ // ../node_modules/.bun/@xterm+headless@6.0.0/node_modules/@xterm/headless/lib-headless/xterm-headless.js
6568
6568
  var require_xterm_headless = __commonJS((exports2) => {
6569
6569
  (() => {
6570
6570
  var e = { 5639: (e2, t2, s2) => {
@@ -12119,7 +12119,7 @@ ${i3.join(`
12119
12119
  })();
12120
12120
  });
12121
12121
 
12122
- // ../../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/util.js
12122
+ // ../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/util.js
12123
12123
  var util, objectUtil, ZodParsedType, getParsedType = (data) => {
12124
12124
  const t = typeof data;
12125
12125
  switch (t) {
@@ -12250,7 +12250,7 @@ var init_util = __esm(() => {
12250
12250
  ]);
12251
12251
  });
12252
12252
 
12253
- // ../../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/ZodError.js
12253
+ // ../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/ZodError.js
12254
12254
  var ZodIssueCode, quotelessJson = (obj) => {
12255
12255
  const json = JSON.stringify(obj, null, 2);
12256
12256
  return json.replace(/"([^"]+)":/g, "$1:");
@@ -12371,7 +12371,7 @@ var init_ZodError = __esm(() => {
12371
12371
  };
12372
12372
  });
12373
12373
 
12374
- // ../../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/locales/en.js
12374
+ // ../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/locales/en.js
12375
12375
  var errorMap = (issue, _ctx) => {
12376
12376
  let message;
12377
12377
  switch (issue.code) {
@@ -12478,7 +12478,7 @@ var init_en = __esm(() => {
12478
12478
  en_default = errorMap;
12479
12479
  });
12480
12480
 
12481
- // ../../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/errors.js
12481
+ // ../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/errors.js
12482
12482
  function setErrorMap(map) {
12483
12483
  overrideErrorMap = map;
12484
12484
  }
@@ -12491,7 +12491,7 @@ var init_errors = __esm(() => {
12491
12491
  overrideErrorMap = en_default;
12492
12492
  });
12493
12493
 
12494
- // ../../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
12494
+ // ../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
12495
12495
  function addIssueToContext(ctx, issueData) {
12496
12496
  const overrideMap = getErrorMap();
12497
12497
  const issue = makeIssue({
@@ -12596,10 +12596,10 @@ var init_parseUtil = __esm(() => {
12596
12596
  });
12597
12597
  });
12598
12598
 
12599
- // ../../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/typeAliases.js
12599
+ // ../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/typeAliases.js
12600
12600
  var init_typeAliases = () => {};
12601
12601
 
12602
- // ../../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
12602
+ // ../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
12603
12603
  var errorUtil;
12604
12604
  var init_errorUtil = __esm(() => {
12605
12605
  (function(errorUtil2) {
@@ -12608,7 +12608,7 @@ var init_errorUtil = __esm(() => {
12608
12608
  })(errorUtil || (errorUtil = {}));
12609
12609
  });
12610
12610
 
12611
- // ../../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/types.js
12611
+ // ../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/types.js
12612
12612
  class ParseInputLazyPath {
12613
12613
  constructor(parent, value, path, key) {
12614
12614
  this._cachedPath = [];
@@ -15959,7 +15959,7 @@ var init_types = __esm(() => {
15959
15959
  NEVER = INVALID;
15960
15960
  });
15961
15961
 
15962
- // ../../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
15962
+ // ../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
15963
15963
  var exports_external = {};
15964
15964
  __export(exports_external, {
15965
15965
  void: () => voidType,
@@ -16079,7 +16079,7 @@ var init_external = __esm(() => {
16079
16079
  init_ZodError();
16080
16080
  });
16081
16081
 
16082
- // ../../switchroom-sec-1417/node_modules/.bun/zod@3.25.76/node_modules/zod/index.js
16082
+ // ../node_modules/.bun/zod@3.25.76/node_modules/zod/index.js
16083
16083
  var init_zod = __esm(() => {
16084
16084
  init_external();
16085
16085
  init_external();
@@ -16642,7 +16642,7 @@ var init_client = __esm(() => {
16642
16642
  };
16643
16643
  });
16644
16644
 
16645
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/identity.js
16645
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/identity.js
16646
16646
  var require_identity = __commonJS((exports2) => {
16647
16647
  var ALIAS = Symbol.for("yaml.alias");
16648
16648
  var DOC = Symbol.for("yaml.document");
@@ -16696,7 +16696,7 @@ var require_identity = __commonJS((exports2) => {
16696
16696
  exports2.isSeq = isSeq;
16697
16697
  });
16698
16698
 
16699
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/visit.js
16699
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/visit.js
16700
16700
  var require_visit = __commonJS((exports2) => {
16701
16701
  var identity = require_identity();
16702
16702
  var BREAK = Symbol("break visit");
@@ -16851,7 +16851,7 @@ var require_visit = __commonJS((exports2) => {
16851
16851
  exports2.visitAsync = visitAsync;
16852
16852
  });
16853
16853
 
16854
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/directives.js
16854
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/directives.js
16855
16855
  var require_directives = __commonJS((exports2) => {
16856
16856
  var identity = require_identity();
16857
16857
  var visit = require_visit();
@@ -17003,7 +17003,7 @@ var require_directives = __commonJS((exports2) => {
17003
17003
  exports2.Directives = Directives;
17004
17004
  });
17005
17005
 
17006
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/anchors.js
17006
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/anchors.js
17007
17007
  var require_anchors = __commonJS((exports2) => {
17008
17008
  var identity = require_identity();
17009
17009
  var visit = require_visit();
@@ -17065,7 +17065,7 @@ var require_anchors = __commonJS((exports2) => {
17065
17065
  exports2.findNewAnchor = findNewAnchor;
17066
17066
  });
17067
17067
 
17068
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/applyReviver.js
17068
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/applyReviver.js
17069
17069
  var require_applyReviver = __commonJS((exports2) => {
17070
17070
  function applyReviver(reviver, obj, key, val) {
17071
17071
  if (val && typeof val === "object") {
@@ -17112,7 +17112,7 @@ var require_applyReviver = __commonJS((exports2) => {
17112
17112
  exports2.applyReviver = applyReviver;
17113
17113
  });
17114
17114
 
17115
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/toJS.js
17115
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/toJS.js
17116
17116
  var require_toJS = __commonJS((exports2) => {
17117
17117
  var identity = require_identity();
17118
17118
  function toJS(value, arg, ctx) {
@@ -17139,7 +17139,7 @@ var require_toJS = __commonJS((exports2) => {
17139
17139
  exports2.toJS = toJS;
17140
17140
  });
17141
17141
 
17142
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Node.js
17142
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Node.js
17143
17143
  var require_Node = __commonJS((exports2) => {
17144
17144
  var applyReviver = require_applyReviver();
17145
17145
  var identity = require_identity();
@@ -17176,7 +17176,7 @@ var require_Node = __commonJS((exports2) => {
17176
17176
  exports2.NodeBase = NodeBase;
17177
17177
  });
17178
17178
 
17179
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Alias.js
17179
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Alias.js
17180
17180
  var require_Alias = __commonJS((exports2) => {
17181
17181
  var anchors = require_anchors();
17182
17182
  var visit = require_visit();
@@ -17284,7 +17284,7 @@ var require_Alias = __commonJS((exports2) => {
17284
17284
  exports2.Alias = Alias;
17285
17285
  });
17286
17286
 
17287
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Scalar.js
17287
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Scalar.js
17288
17288
  var require_Scalar = __commonJS((exports2) => {
17289
17289
  var identity = require_identity();
17290
17290
  var Node = require_Node();
@@ -17312,7 +17312,7 @@ var require_Scalar = __commonJS((exports2) => {
17312
17312
  exports2.isScalarValue = isScalarValue;
17313
17313
  });
17314
17314
 
17315
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/createNode.js
17315
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/createNode.js
17316
17316
  var require_createNode = __commonJS((exports2) => {
17317
17317
  var Alias = require_Alias();
17318
17318
  var identity = require_identity();
@@ -17384,7 +17384,7 @@ var require_createNode = __commonJS((exports2) => {
17384
17384
  exports2.createNode = createNode;
17385
17385
  });
17386
17386
 
17387
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Collection.js
17387
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Collection.js
17388
17388
  var require_Collection = __commonJS((exports2) => {
17389
17389
  var createNode = require_createNode();
17390
17390
  var identity = require_identity();
@@ -17499,7 +17499,7 @@ var require_Collection = __commonJS((exports2) => {
17499
17499
  exports2.isEmptyPath = isEmptyPath;
17500
17500
  });
17501
17501
 
17502
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyComment.js
17502
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyComment.js
17503
17503
  var require_stringifyComment = __commonJS((exports2) => {
17504
17504
  var stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, "#");
17505
17505
  function indentComment(comment, indent) {
@@ -17516,7 +17516,7 @@ var require_stringifyComment = __commonJS((exports2) => {
17516
17516
  exports2.stringifyComment = stringifyComment;
17517
17517
  });
17518
17518
 
17519
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/foldFlowLines.js
17519
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/foldFlowLines.js
17520
17520
  var require_foldFlowLines = __commonJS((exports2) => {
17521
17521
  var FOLD_FLOW = "flow";
17522
17522
  var FOLD_BLOCK = "block";
@@ -17653,7 +17653,7 @@ ${indent}${text.slice(fold + 1, end2)}`;
17653
17653
  exports2.foldFlowLines = foldFlowLines;
17654
17654
  });
17655
17655
 
17656
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyString.js
17656
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyString.js
17657
17657
  var require_stringifyString = __commonJS((exports2) => {
17658
17658
  var Scalar = require_Scalar();
17659
17659
  var foldFlowLines = require_foldFlowLines();
@@ -17951,7 +17951,7 @@ ${indent}`);
17951
17951
  exports2.stringifyString = stringifyString;
17952
17952
  });
17953
17953
 
17954
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringify.js
17954
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringify.js
17955
17955
  var require_stringify = __commonJS((exports2) => {
17956
17956
  var anchors = require_anchors();
17957
17957
  var identity = require_identity();
@@ -18072,7 +18072,7 @@ ${ctx.indent}${str}`;
18072
18072
  exports2.stringify = stringify;
18073
18073
  });
18074
18074
 
18075
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyPair.js
18075
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyPair.js
18076
18076
  var require_stringifyPair = __commonJS((exports2) => {
18077
18077
  var identity = require_identity();
18078
18078
  var Scalar = require_Scalar();
@@ -18208,7 +18208,7 @@ ${ctx.indent}`;
18208
18208
  exports2.stringifyPair = stringifyPair;
18209
18209
  });
18210
18210
 
18211
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/log.js
18211
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/log.js
18212
18212
  var require_log = __commonJS((exports2) => {
18213
18213
  var node_process = __require("process");
18214
18214
  function debug(logLevel, ...messages) {
@@ -18227,7 +18227,7 @@ var require_log = __commonJS((exports2) => {
18227
18227
  exports2.warn = warn;
18228
18228
  });
18229
18229
 
18230
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/merge.js
18230
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/merge.js
18231
18231
  var require_merge = __commonJS((exports2) => {
18232
18232
  var identity = require_identity();
18233
18233
  var Scalar = require_Scalar();
@@ -18281,7 +18281,7 @@ var require_merge = __commonJS((exports2) => {
18281
18281
  exports2.merge = merge;
18282
18282
  });
18283
18283
 
18284
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/addPairToJSMap.js
18284
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/addPairToJSMap.js
18285
18285
  var require_addPairToJSMap = __commonJS((exports2) => {
18286
18286
  var log = require_log();
18287
18287
  var merge = require_merge();
@@ -18342,7 +18342,7 @@ var require_addPairToJSMap = __commonJS((exports2) => {
18342
18342
  exports2.addPairToJSMap = addPairToJSMap;
18343
18343
  });
18344
18344
 
18345
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Pair.js
18345
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Pair.js
18346
18346
  var require_Pair = __commonJS((exports2) => {
18347
18347
  var createNode = require_createNode();
18348
18348
  var stringifyPair = require_stringifyPair();
@@ -18380,7 +18380,7 @@ var require_Pair = __commonJS((exports2) => {
18380
18380
  exports2.createPair = createPair;
18381
18381
  });
18382
18382
 
18383
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyCollection.js
18383
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyCollection.js
18384
18384
  var require_stringifyCollection = __commonJS((exports2) => {
18385
18385
  var identity = require_identity();
18386
18386
  var stringify = require_stringify();
@@ -18532,7 +18532,7 @@ ${indent}${end}`;
18532
18532
  exports2.stringifyCollection = stringifyCollection;
18533
18533
  });
18534
18534
 
18535
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/YAMLMap.js
18535
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/YAMLMap.js
18536
18536
  var require_YAMLMap = __commonJS((exports2) => {
18537
18537
  var stringifyCollection = require_stringifyCollection();
18538
18538
  var addPairToJSMap = require_addPairToJSMap();
@@ -18659,7 +18659,7 @@ var require_YAMLMap = __commonJS((exports2) => {
18659
18659
  exports2.findPair = findPair;
18660
18660
  });
18661
18661
 
18662
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/map.js
18662
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/map.js
18663
18663
  var require_map = __commonJS((exports2) => {
18664
18664
  var identity = require_identity();
18665
18665
  var YAMLMap = require_YAMLMap();
@@ -18678,7 +18678,7 @@ var require_map = __commonJS((exports2) => {
18678
18678
  exports2.map = map;
18679
18679
  });
18680
18680
 
18681
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/YAMLSeq.js
18681
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/YAMLSeq.js
18682
18682
  var require_YAMLSeq = __commonJS((exports2) => {
18683
18683
  var createNode = require_createNode();
18684
18684
  var stringifyCollection = require_stringifyCollection();
@@ -18771,7 +18771,7 @@ var require_YAMLSeq = __commonJS((exports2) => {
18771
18771
  exports2.YAMLSeq = YAMLSeq;
18772
18772
  });
18773
18773
 
18774
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/seq.js
18774
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/seq.js
18775
18775
  var require_seq = __commonJS((exports2) => {
18776
18776
  var identity = require_identity();
18777
18777
  var YAMLSeq = require_YAMLSeq();
@@ -18790,7 +18790,7 @@ var require_seq = __commonJS((exports2) => {
18790
18790
  exports2.seq = seq;
18791
18791
  });
18792
18792
 
18793
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/string.js
18793
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/string.js
18794
18794
  var require_string = __commonJS((exports2) => {
18795
18795
  var stringifyString = require_stringifyString();
18796
18796
  var string = {
@@ -18806,7 +18806,7 @@ var require_string = __commonJS((exports2) => {
18806
18806
  exports2.string = string;
18807
18807
  });
18808
18808
 
18809
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/null.js
18809
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/null.js
18810
18810
  var require_null = __commonJS((exports2) => {
18811
18811
  var Scalar = require_Scalar();
18812
18812
  var nullTag = {
@@ -18821,7 +18821,7 @@ var require_null = __commonJS((exports2) => {
18821
18821
  exports2.nullTag = nullTag;
18822
18822
  });
18823
18823
 
18824
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/bool.js
18824
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/bool.js
18825
18825
  var require_bool = __commonJS((exports2) => {
18826
18826
  var Scalar = require_Scalar();
18827
18827
  var boolTag = {
@@ -18842,7 +18842,7 @@ var require_bool = __commonJS((exports2) => {
18842
18842
  exports2.boolTag = boolTag;
18843
18843
  });
18844
18844
 
18845
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyNumber.js
18845
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyNumber.js
18846
18846
  var require_stringifyNumber = __commonJS((exports2) => {
18847
18847
  function stringifyNumber({ format, minFractionDigits, tag, value }) {
18848
18848
  if (typeof value === "bigint")
@@ -18866,7 +18866,7 @@ var require_stringifyNumber = __commonJS((exports2) => {
18866
18866
  exports2.stringifyNumber = stringifyNumber;
18867
18867
  });
18868
18868
 
18869
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/float.js
18869
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/float.js
18870
18870
  var require_float = __commonJS((exports2) => {
18871
18871
  var Scalar = require_Scalar();
18872
18872
  var stringifyNumber = require_stringifyNumber();
@@ -18909,7 +18909,7 @@ var require_float = __commonJS((exports2) => {
18909
18909
  exports2.floatNaN = floatNaN;
18910
18910
  });
18911
18911
 
18912
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/int.js
18912
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/int.js
18913
18913
  var require_int = __commonJS((exports2) => {
18914
18914
  var stringifyNumber = require_stringifyNumber();
18915
18915
  var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
@@ -18951,7 +18951,7 @@ var require_int = __commonJS((exports2) => {
18951
18951
  exports2.intOct = intOct;
18952
18952
  });
18953
18953
 
18954
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/schema.js
18954
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/schema.js
18955
18955
  var require_schema = __commonJS((exports2) => {
18956
18956
  var map = require_map();
18957
18957
  var _null = require_null();
@@ -18976,7 +18976,7 @@ var require_schema = __commonJS((exports2) => {
18976
18976
  exports2.schema = schema;
18977
18977
  });
18978
18978
 
18979
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/json/schema.js
18979
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/json/schema.js
18980
18980
  var require_schema2 = __commonJS((exports2) => {
18981
18981
  var Scalar = require_Scalar();
18982
18982
  var map = require_map();
@@ -19040,7 +19040,7 @@ var require_schema2 = __commonJS((exports2) => {
19040
19040
  exports2.schema = schema;
19041
19041
  });
19042
19042
 
19043
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/binary.js
19043
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/binary.js
19044
19044
  var require_binary = __commonJS((exports2) => {
19045
19045
  var node_buffer = __require("buffer");
19046
19046
  var Scalar = require_Scalar();
@@ -19095,7 +19095,7 @@ var require_binary = __commonJS((exports2) => {
19095
19095
  exports2.binary = binary;
19096
19096
  });
19097
19097
 
19098
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/pairs.js
19098
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/pairs.js
19099
19099
  var require_pairs = __commonJS((exports2) => {
19100
19100
  var identity = require_identity();
19101
19101
  var Pair = require_Pair();
@@ -19170,7 +19170,7 @@ ${cn.comment}` : item.comment;
19170
19170
  exports2.resolvePairs = resolvePairs;
19171
19171
  });
19172
19172
 
19173
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/omap.js
19173
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/omap.js
19174
19174
  var require_omap = __commonJS((exports2) => {
19175
19175
  var identity = require_identity();
19176
19176
  var toJS = require_toJS();
@@ -19242,7 +19242,7 @@ var require_omap = __commonJS((exports2) => {
19242
19242
  exports2.omap = omap;
19243
19243
  });
19244
19244
 
19245
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/bool.js
19245
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/bool.js
19246
19246
  var require_bool2 = __commonJS((exports2) => {
19247
19247
  var Scalar = require_Scalar();
19248
19248
  function boolStringify({ value, source }, ctx) {
@@ -19271,7 +19271,7 @@ var require_bool2 = __commonJS((exports2) => {
19271
19271
  exports2.trueTag = trueTag;
19272
19272
  });
19273
19273
 
19274
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/float.js
19274
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/float.js
19275
19275
  var require_float2 = __commonJS((exports2) => {
19276
19276
  var Scalar = require_Scalar();
19277
19277
  var stringifyNumber = require_stringifyNumber();
@@ -19317,7 +19317,7 @@ var require_float2 = __commonJS((exports2) => {
19317
19317
  exports2.floatNaN = floatNaN;
19318
19318
  });
19319
19319
 
19320
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/int.js
19320
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/int.js
19321
19321
  var require_int2 = __commonJS((exports2) => {
19322
19322
  var stringifyNumber = require_stringifyNumber();
19323
19323
  var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
@@ -19393,7 +19393,7 @@ var require_int2 = __commonJS((exports2) => {
19393
19393
  exports2.intOct = intOct;
19394
19394
  });
19395
19395
 
19396
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/set.js
19396
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/set.js
19397
19397
  var require_set = __commonJS((exports2) => {
19398
19398
  var identity = require_identity();
19399
19399
  var Pair = require_Pair();
@@ -19476,7 +19476,7 @@ var require_set = __commonJS((exports2) => {
19476
19476
  exports2.set = set;
19477
19477
  });
19478
19478
 
19479
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js
19479
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js
19480
19480
  var require_timestamp = __commonJS((exports2) => {
19481
19481
  var stringifyNumber = require_stringifyNumber();
19482
19482
  function parseSexagesimal(str, asBigInt) {
@@ -19558,7 +19558,7 @@ var require_timestamp = __commonJS((exports2) => {
19558
19558
  exports2.timestamp = timestamp;
19559
19559
  });
19560
19560
 
19561
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/schema.js
19561
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/schema.js
19562
19562
  var require_schema3 = __commonJS((exports2) => {
19563
19563
  var map = require_map();
19564
19564
  var _null = require_null();
@@ -19599,7 +19599,7 @@ var require_schema3 = __commonJS((exports2) => {
19599
19599
  exports2.schema = schema;
19600
19600
  });
19601
19601
 
19602
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/tags.js
19602
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/tags.js
19603
19603
  var require_tags = __commonJS((exports2) => {
19604
19604
  var map = require_map();
19605
19605
  var _null = require_null();
@@ -19690,7 +19690,7 @@ var require_tags = __commonJS((exports2) => {
19690
19690
  exports2.getTags = getTags;
19691
19691
  });
19692
19692
 
19693
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/Schema.js
19693
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/Schema.js
19694
19694
  var require_Schema = __commonJS((exports2) => {
19695
19695
  var identity = require_identity();
19696
19696
  var map = require_map();
@@ -19720,7 +19720,7 @@ var require_Schema = __commonJS((exports2) => {
19720
19720
  exports2.Schema = Schema;
19721
19721
  });
19722
19722
 
19723
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyDocument.js
19723
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyDocument.js
19724
19724
  var require_stringifyDocument = __commonJS((exports2) => {
19725
19725
  var identity = require_identity();
19726
19726
  var stringify = require_stringify();
@@ -19800,7 +19800,7 @@ var require_stringifyDocument = __commonJS((exports2) => {
19800
19800
  exports2.stringifyDocument = stringifyDocument;
19801
19801
  });
19802
19802
 
19803
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/Document.js
19803
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/Document.js
19804
19804
  var require_Document = __commonJS((exports2) => {
19805
19805
  var Alias = require_Alias();
19806
19806
  var Collection = require_Collection();
@@ -20035,7 +20035,7 @@ var require_Document = __commonJS((exports2) => {
20035
20035
  exports2.Document = Document;
20036
20036
  });
20037
20037
 
20038
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/errors.js
20038
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/errors.js
20039
20039
  var require_errors = __commonJS((exports2) => {
20040
20040
  class YAMLError extends Error {
20041
20041
  constructor(name, pos, code, message) {
@@ -20100,7 +20100,7 @@ ${pointer}
20100
20100
  exports2.prettifyError = prettifyError;
20101
20101
  });
20102
20102
 
20103
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-props.js
20103
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-props.js
20104
20104
  var require_resolve_props = __commonJS((exports2) => {
20105
20105
  function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) {
20106
20106
  let spaceBefore = false;
@@ -20230,7 +20230,7 @@ var require_resolve_props = __commonJS((exports2) => {
20230
20230
  exports2.resolveProps = resolveProps;
20231
20231
  });
20232
20232
 
20233
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-contains-newline.js
20233
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-contains-newline.js
20234
20234
  var require_util_contains_newline = __commonJS((exports2) => {
20235
20235
  function containsNewline(key) {
20236
20236
  if (!key)
@@ -20270,7 +20270,7 @@ var require_util_contains_newline = __commonJS((exports2) => {
20270
20270
  exports2.containsNewline = containsNewline;
20271
20271
  });
20272
20272
 
20273
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-flow-indent-check.js
20273
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-flow-indent-check.js
20274
20274
  var require_util_flow_indent_check = __commonJS((exports2) => {
20275
20275
  var utilContainsNewline = require_util_contains_newline();
20276
20276
  function flowIndentCheck(indent, fc, onError) {
@@ -20285,7 +20285,7 @@ var require_util_flow_indent_check = __commonJS((exports2) => {
20285
20285
  exports2.flowIndentCheck = flowIndentCheck;
20286
20286
  });
20287
20287
 
20288
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-map-includes.js
20288
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-map-includes.js
20289
20289
  var require_util_map_includes = __commonJS((exports2) => {
20290
20290
  var identity = require_identity();
20291
20291
  function mapIncludes(ctx, items, search) {
@@ -20298,7 +20298,7 @@ var require_util_map_includes = __commonJS((exports2) => {
20298
20298
  exports2.mapIncludes = mapIncludes;
20299
20299
  });
20300
20300
 
20301
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-map.js
20301
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-map.js
20302
20302
  var require_resolve_block_map = __commonJS((exports2) => {
20303
20303
  var Pair = require_Pair();
20304
20304
  var YAMLMap = require_YAMLMap();
@@ -20405,7 +20405,7 @@ var require_resolve_block_map = __commonJS((exports2) => {
20405
20405
  exports2.resolveBlockMap = resolveBlockMap;
20406
20406
  });
20407
20407
 
20408
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-seq.js
20408
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-seq.js
20409
20409
  var require_resolve_block_seq = __commonJS((exports2) => {
20410
20410
  var YAMLSeq = require_YAMLSeq();
20411
20411
  var resolveProps = require_resolve_props();
@@ -20453,7 +20453,7 @@ var require_resolve_block_seq = __commonJS((exports2) => {
20453
20453
  exports2.resolveBlockSeq = resolveBlockSeq;
20454
20454
  });
20455
20455
 
20456
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-end.js
20456
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-end.js
20457
20457
  var require_resolve_end = __commonJS((exports2) => {
20458
20458
  function resolveEnd(end, offset, reqSpace, onError) {
20459
20459
  let comment = "";
@@ -20493,7 +20493,7 @@ var require_resolve_end = __commonJS((exports2) => {
20493
20493
  exports2.resolveEnd = resolveEnd;
20494
20494
  });
20495
20495
 
20496
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-flow-collection.js
20496
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-flow-collection.js
20497
20497
  var require_resolve_flow_collection = __commonJS((exports2) => {
20498
20498
  var identity = require_identity();
20499
20499
  var Pair = require_Pair();
@@ -20684,7 +20684,7 @@ var require_resolve_flow_collection = __commonJS((exports2) => {
20684
20684
  exports2.resolveFlowCollection = resolveFlowCollection;
20685
20685
  });
20686
20686
 
20687
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-collection.js
20687
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-collection.js
20688
20688
  var require_compose_collection = __commonJS((exports2) => {
20689
20689
  var identity = require_identity();
20690
20690
  var Scalar = require_Scalar();
@@ -20746,7 +20746,7 @@ var require_compose_collection = __commonJS((exports2) => {
20746
20746
  exports2.composeCollection = composeCollection;
20747
20747
  });
20748
20748
 
20749
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-scalar.js
20749
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-scalar.js
20750
20750
  var require_resolve_block_scalar = __commonJS((exports2) => {
20751
20751
  var Scalar = require_Scalar();
20752
20752
  function resolveBlockScalar(ctx, scalar, onError) {
@@ -20939,7 +20939,7 @@ var require_resolve_block_scalar = __commonJS((exports2) => {
20939
20939
  exports2.resolveBlockScalar = resolveBlockScalar;
20940
20940
  });
20941
20941
 
20942
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-flow-scalar.js
20942
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-flow-scalar.js
20943
20943
  var require_resolve_flow_scalar = __commonJS((exports2) => {
20944
20944
  var Scalar = require_Scalar();
20945
20945
  var resolveEnd = require_resolve_end();
@@ -21155,7 +21155,7 @@ var require_resolve_flow_scalar = __commonJS((exports2) => {
21155
21155
  exports2.resolveFlowScalar = resolveFlowScalar;
21156
21156
  });
21157
21157
 
21158
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-scalar.js
21158
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-scalar.js
21159
21159
  var require_compose_scalar = __commonJS((exports2) => {
21160
21160
  var identity = require_identity();
21161
21161
  var Scalar = require_Scalar();
@@ -21233,7 +21233,7 @@ var require_compose_scalar = __commonJS((exports2) => {
21233
21233
  exports2.composeScalar = composeScalar;
21234
21234
  });
21235
21235
 
21236
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-empty-scalar-position.js
21236
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-empty-scalar-position.js
21237
21237
  var require_util_empty_scalar_position = __commonJS((exports2) => {
21238
21238
  function emptyScalarPosition(offset, before, pos) {
21239
21239
  if (before) {
@@ -21260,7 +21260,7 @@ var require_util_empty_scalar_position = __commonJS((exports2) => {
21260
21260
  exports2.emptyScalarPosition = emptyScalarPosition;
21261
21261
  });
21262
21262
 
21263
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-node.js
21263
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-node.js
21264
21264
  var require_compose_node = __commonJS((exports2) => {
21265
21265
  var Alias = require_Alias();
21266
21266
  var identity = require_identity();
@@ -21363,7 +21363,7 @@ var require_compose_node = __commonJS((exports2) => {
21363
21363
  exports2.composeNode = composeNode;
21364
21364
  });
21365
21365
 
21366
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-doc.js
21366
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-doc.js
21367
21367
  var require_compose_doc = __commonJS((exports2) => {
21368
21368
  var Document = require_Document();
21369
21369
  var composeNode = require_compose_node();
@@ -21403,7 +21403,7 @@ var require_compose_doc = __commonJS((exports2) => {
21403
21403
  exports2.composeDoc = composeDoc;
21404
21404
  });
21405
21405
 
21406
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/composer.js
21406
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/composer.js
21407
21407
  var require_composer2 = __commonJS((exports2) => {
21408
21408
  var node_process = __require("process");
21409
21409
  var directives = require_directives();
@@ -21592,7 +21592,7 @@ ${end.comment}` : end.comment;
21592
21592
  exports2.Composer = Composer;
21593
21593
  });
21594
21594
 
21595
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-scalar.js
21595
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-scalar.js
21596
21596
  var require_cst_scalar = __commonJS((exports2) => {
21597
21597
  var resolveBlockScalar = require_resolve_block_scalar();
21598
21598
  var resolveFlowScalar = require_resolve_flow_scalar();
@@ -21782,7 +21782,7 @@ var require_cst_scalar = __commonJS((exports2) => {
21782
21782
  exports2.setScalarValue = setScalarValue;
21783
21783
  });
21784
21784
 
21785
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-stringify.js
21785
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-stringify.js
21786
21786
  var require_cst_stringify = __commonJS((exports2) => {
21787
21787
  var stringify = (cst) => ("type" in cst) ? stringifyToken(cst) : stringifyItem(cst);
21788
21788
  function stringifyToken(token) {
@@ -21840,7 +21840,7 @@ var require_cst_stringify = __commonJS((exports2) => {
21840
21840
  exports2.stringify = stringify;
21841
21841
  });
21842
21842
 
21843
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-visit.js
21843
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-visit.js
21844
21844
  var require_cst_visit = __commonJS((exports2) => {
21845
21845
  var BREAK = Symbol("break visit");
21846
21846
  var SKIP = Symbol("skip children");
@@ -21899,7 +21899,7 @@ var require_cst_visit = __commonJS((exports2) => {
21899
21899
  exports2.visit = visit;
21900
21900
  });
21901
21901
 
21902
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst.js
21902
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst.js
21903
21903
  var require_cst = __commonJS((exports2) => {
21904
21904
  var cstScalar = require_cst_scalar();
21905
21905
  var cstStringify = require_cst_stringify();
@@ -22000,7 +22000,7 @@ var require_cst = __commonJS((exports2) => {
22000
22000
  exports2.tokenType = tokenType;
22001
22001
  });
22002
22002
 
22003
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/lexer.js
22003
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/lexer.js
22004
22004
  var require_lexer = __commonJS((exports2) => {
22005
22005
  var cst = require_cst();
22006
22006
  function isEmpty2(ch) {
@@ -22586,7 +22586,7 @@ var require_lexer = __commonJS((exports2) => {
22586
22586
  exports2.Lexer = Lexer;
22587
22587
  });
22588
22588
 
22589
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/line-counter.js
22589
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/line-counter.js
22590
22590
  var require_line_counter = __commonJS((exports2) => {
22591
22591
  class LineCounter {
22592
22592
  constructor() {
@@ -22614,7 +22614,7 @@ var require_line_counter = __commonJS((exports2) => {
22614
22614
  exports2.LineCounter = LineCounter;
22615
22615
  });
22616
22616
 
22617
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/parser.js
22617
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/parser.js
22618
22618
  var require_parser = __commonJS((exports2) => {
22619
22619
  var node_process = __require("process");
22620
22620
  var cst = require_cst();
@@ -23463,7 +23463,7 @@ var require_parser = __commonJS((exports2) => {
23463
23463
  exports2.Parser = Parser;
23464
23464
  });
23465
23465
 
23466
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/public-api.js
23466
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/public-api.js
23467
23467
  var require_public_api = __commonJS((exports2) => {
23468
23468
  var composer = require_composer2();
23469
23469
  var Document = require_Document();
@@ -23557,7 +23557,7 @@ var require_public_api = __commonJS((exports2) => {
23557
23557
  exports2.stringify = stringify;
23558
23558
  });
23559
23559
 
23560
- // ../../switchroom-sec-1417/node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/index.js
23560
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/index.js
23561
23561
  var composer, Document, Schema, errors2, Alias, identity, Pair, Scalar, YAMLMap, YAMLSeq, cst, lexer, lineCounter, parser, publicApi, visit, $Composer, $Document, $Schema, $YAMLError, $YAMLParseError, $YAMLWarning, $Alias, $isAlias, $isCollection, $isDocument, $isMap, $isNode, $isPair, $isScalar, $isSeq, $Pair, $Scalar, $YAMLMap, $YAMLSeq, $Lexer, $LineCounter, $Parser, $parse, $parseAllDocuments, $parseDocument, $stringify, $visit, $visitAsync;
23562
23562
  var init_dist = __esm(() => {
23563
23563
  composer = require_composer2();
@@ -25849,7 +25849,7 @@ function deriveSlug(inputs, existing) {
25849
25849
  return `${base}_${n}`;
25850
25850
  }
25851
25851
 
25852
- // ../../switchroom-sec-1417/node_modules/.bun/boundary@2.0.0/node_modules/boundary/lib/index.js
25852
+ // ../node_modules/.bun/boundary@2.0.0/node_modules/boundary/lib/index.js
25853
25853
  var require_lib = __commonJS((exports2) => {
25854
25854
  Object.defineProperty(exports2, "__esModule", { value: true });
25855
25855
  exports2.binarySearch = exports2.upperBound = exports2.lowerBound = exports2.compare = undefined;
@@ -25896,7 +25896,7 @@ var require_lib = __commonJS((exports2) => {
25896
25896
  exports2.binarySearch = binarySearch;
25897
25897
  });
25898
25898
 
25899
- // ../../switchroom-sec-1417/node_modules/.bun/structured-source@4.0.0/node_modules/structured-source/lib/structured-source.js
25899
+ // ../node_modules/.bun/structured-source@4.0.0/node_modules/structured-source/lib/structured-source.js
25900
25900
  var require_structured_source = __commonJS((exports2) => {
25901
25901
  Object.defineProperty(exports2, "__esModule", { value: true });
25902
25902
  exports2.StructuredSource = undefined;
@@ -25951,13 +25951,13 @@ var require_structured_source = __commonJS((exports2) => {
25951
25951
  }
25952
25952
  exports2.StructuredSource = StructuredSource;
25953
25953
  });
25954
- // ../../switchroom-sec-1417/node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/SecretLintSourceCodeImpl.js
25954
+ // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/SecretLintSourceCodeImpl.js
25955
25955
  var import_structured_source;
25956
25956
  var init_SecretLintSourceCodeImpl = __esm(() => {
25957
25957
  import_structured_source = __toESM(require_structured_source(), 1);
25958
25958
  });
25959
25959
 
25960
- // ../../switchroom-sec-1417/node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/helper/promise-event-emitter.js
25960
+ // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/helper/promise-event-emitter.js
25961
25961
  class EventEmitter {
25962
25962
  #listeners = new Map;
25963
25963
  on(type, listener) {
@@ -25996,9 +25996,9 @@ class EventEmitter {
25996
25996
  return Array.from(this.#listeners.get(type) ?? []);
25997
25997
  }
25998
25998
  }
25999
- // ../../switchroom-sec-1417/node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/RuleContext.js
25999
+ // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/RuleContext.js
26000
26000
  var init_RuleContext = () => {};
26001
- // ../../switchroom-sec-1417/node_modules/.bun/@secretlint+profiler@12.2.0/node_modules/@secretlint/profiler/module/index.js
26001
+ // ../node_modules/.bun/@secretlint+profiler@12.2.0/node_modules/@secretlint/profiler/module/index.js
26002
26002
  class SecretLintProfiler {
26003
26003
  perf;
26004
26004
  entries = [];
@@ -26055,7 +26055,7 @@ class SecretLintProfiler {
26055
26055
  }
26056
26056
  }
26057
26057
 
26058
- // ../../switchroom-sec-1417/node_modules/.bun/@secretlint+profiler@12.2.0/node_modules/@secretlint/profiler/module/node.js
26058
+ // ../node_modules/.bun/@secretlint+profiler@12.2.0/node_modules/@secretlint/profiler/module/node.js
26059
26059
  import perf_hooks from "node:perf_hooks";
26060
26060
 
26061
26061
  class NullPerformanceObserver {
@@ -26070,19 +26070,19 @@ var init_node = __esm(() => {
26070
26070
  });
26071
26071
  });
26072
26072
 
26073
- // ../../switchroom-sec-1417/node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/RunningEvents.js
26073
+ // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/RunningEvents.js
26074
26074
  var init_RunningEvents = __esm(() => {
26075
26075
  init_node();
26076
26076
  });
26077
26077
 
26078
- // ../../switchroom-sec-1417/node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/RulePresetContext.js
26078
+ // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/RulePresetContext.js
26079
26079
  var init_RulePresetContext = __esm(() => {
26080
26080
  init_RuleContext();
26081
26081
  });
26082
- // ../../switchroom-sec-1417/node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/messages/index.js
26082
+ // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/messages/index.js
26083
26083
  var init_messages = () => {};
26084
26084
 
26085
- // ../../switchroom-sec-1417/node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/index.js
26085
+ // ../node_modules/.bun/@secretlint+core@12.2.0/node_modules/@secretlint/core/module/index.js
26086
26086
  var import_debug, debug;
26087
26087
  var init_module = __esm(() => {
26088
26088
  init_SecretLintSourceCodeImpl();
@@ -26095,7 +26095,7 @@ var init_module = __esm(() => {
26095
26095
  debug = import_debug.default("@secretlint/core");
26096
26096
  });
26097
26097
 
26098
- // ../../switchroom-sec-1417/node_modules/.bun/@secretlint+secretlint-rule-preset-recommend@12.2.0/node_modules/@secretlint/secretlint-rule-preset-recommend/module/index.js
26098
+ // ../node_modules/.bun/@secretlint+secretlint-rule-preset-recommend@12.2.0/node_modules/@secretlint/secretlint-rule-preset-recommend/module/index.js
26099
26099
  function requireLodash_uniq() {
26100
26100
  if (hasRequiredLodash_uniq)
26101
26101
  return lodash_uniq;
@@ -28823,6 +28823,115 @@ var init_boot_issue_cache = __esm(() => {
28823
28823
  EMPTY_CACHE = { schema: 1, probes: {} };
28824
28824
  });
28825
28825
 
28826
+ // gateway/config-snapshot.ts
28827
+ import { createHash as createHash2 } from "crypto";
28828
+ import { existsSync as existsSync26, readFileSync as readFileSync25, writeFileSync as writeFileSync15, mkdirSync as mkdirSync13, renameSync as renameSync10 } from "fs";
28829
+ import { dirname as dirname10 } from "path";
28830
+ function hashStringArray(items) {
28831
+ if (!items || items.length === 0)
28832
+ return null;
28833
+ const sorted = [...items].sort();
28834
+ const raw = createHash2("sha256").update(sorted.join("\x00")).digest("hex");
28835
+ return raw.slice(0, 12);
28836
+ }
28837
+ function normalizeModel(model) {
28838
+ if (!model || model.trim().length === 0)
28839
+ return null;
28840
+ return model.trim().toLowerCase();
28841
+ }
28842
+ function captureConfigSnapshot(input) {
28843
+ return {
28844
+ schema: 1,
28845
+ capturedAtMs: (input.now ?? Date.now)(),
28846
+ model: normalizeModel(input.model),
28847
+ toolsHash: hashStringArray(input.toolsAllow ?? null),
28848
+ skillsHash: hashStringArray(input.skills ?? null),
28849
+ memoryBackend: input.memoryCollection?.trim() || null
28850
+ };
28851
+ }
28852
+ function diffSnapshots(current, previous) {
28853
+ if (previous === null)
28854
+ return [];
28855
+ const changes = [];
28856
+ if (current.model !== previous.model) {
28857
+ changes.push({ field: "model", from: previous.model, to: current.model });
28858
+ }
28859
+ if (current.toolsHash !== previous.toolsHash) {
28860
+ changes.push({ field: "tools", from: previous.toolsHash, to: current.toolsHash });
28861
+ }
28862
+ if (current.skillsHash !== previous.skillsHash) {
28863
+ changes.push({ field: "skills", from: previous.skillsHash, to: current.skillsHash });
28864
+ }
28865
+ if (current.memoryBackend !== previous.memoryBackend) {
28866
+ changes.push({
28867
+ field: "memoryBackend",
28868
+ from: previous.memoryBackend,
28869
+ to: current.memoryBackend
28870
+ });
28871
+ }
28872
+ return changes;
28873
+ }
28874
+ function renderConfigChangeDim(dim) {
28875
+ switch (dim.field) {
28876
+ case "model": {
28877
+ const from = escapeHtml8(dim.from ?? "(default)");
28878
+ const to = escapeHtml8(dim.to ?? "(default)");
28879
+ return `\u2699\ufe0f <b>Config</b> model: ${from} \u2192 ${to}`;
28880
+ }
28881
+ case "memoryBackend": {
28882
+ const from = escapeHtml8(dim.from ?? "(default)");
28883
+ const to = escapeHtml8(dim.to ?? "(default)");
28884
+ return `\u2699\ufe0f <b>Config</b> memory backend: ${from} \u2192 ${to}`;
28885
+ }
28886
+ case "tools":
28887
+ return `\u2699\ufe0f <b>Config</b> tools allowlist changed \u2014 run /status for details`;
28888
+ case "skills":
28889
+ return `\u2699\ufe0f <b>Config</b> skills changed \u2014 run /status for details`;
28890
+ }
28891
+ }
28892
+ function loadSnapshot(path, now = Date.now) {
28893
+ if (!existsSync26(path))
28894
+ return null;
28895
+ let raw;
28896
+ try {
28897
+ raw = readFileSync25(path, "utf-8");
28898
+ } catch {
28899
+ return null;
28900
+ }
28901
+ let parsed;
28902
+ try {
28903
+ parsed = JSON.parse(raw);
28904
+ } catch {
28905
+ try {
28906
+ renameSync10(path, `${path}.corrupt-${now()}`);
28907
+ } catch {}
28908
+ return null;
28909
+ }
28910
+ const obj = parsed;
28911
+ if (!obj || obj.schema !== 1)
28912
+ return null;
28913
+ if (typeof obj.capturedAtMs !== "number" || !("model" in obj) || !("toolsHash" in obj) || !("skillsHash" in obj) || !("memoryBackend" in obj)) {
28914
+ return null;
28915
+ }
28916
+ return {
28917
+ schema: 1,
28918
+ capturedAtMs: obj.capturedAtMs,
28919
+ model: obj.model ?? null,
28920
+ toolsHash: obj.toolsHash ?? null,
28921
+ skillsHash: obj.skillsHash ?? null,
28922
+ memoryBackend: obj.memoryBackend ?? null
28923
+ };
28924
+ }
28925
+ function persistSnapshot(path, snapshot) {
28926
+ try {
28927
+ mkdirSync13(dirname10(path), { recursive: true });
28928
+ const tmp = `${path}.tmp`;
28929
+ writeFileSync15(tmp, JSON.stringify(snapshot), { mode: 384 });
28930
+ renameSync10(tmp, path);
28931
+ } catch {}
28932
+ }
28933
+ var init_config_snapshot = () => {};
28934
+
28826
28935
  // gateway/boot-card.ts
28827
28936
  var exports_boot_card = {};
28828
28937
  __export(exports_boot_card, {
@@ -28899,6 +29008,12 @@ function renderBootCard(opts) {
28899
29008
  }
28900
29009
  }
28901
29010
  const accountRows = opts.accounts ? renderAuthLine(opts.accounts, agentName3, (opts.now ?? new Date).getTime()) : [];
29011
+ const configChangeRows = [];
29012
+ if (opts.configChanges && opts.configChanges.length > 0) {
29013
+ for (const dim of opts.configChanges) {
29014
+ configChangeRows.push(renderConfigChangeDim(dim));
29015
+ }
29016
+ }
28902
29017
  const sections = [ack];
28903
29018
  if (degradedRows.length > 0)
28904
29019
  sections.push("", ...degradedRows);
@@ -28908,6 +29023,9 @@ function renderBootCard(opts) {
28908
29023
  sections.push("", ...opts.updateOutcomeLine.split(`
28909
29024
  `));
28910
29025
  }
29026
+ if (configChangeRows.length > 0) {
29027
+ sections.push("", ...configChangeRows);
29028
+ }
28911
29029
  if (sections.length === 1)
28912
29030
  return ack;
28913
29031
  return sections.join(`
@@ -29011,6 +29129,38 @@ async function startBootCard(chatId, threadId, bot, opts, ackMessageId, log) {
29011
29129
  applyAndSave(opts.bootIssueCachePath, cache, diff);
29012
29130
  } catch (diffErr) {
29013
29131
  logger2(`telegram gateway: boot-card: issue-dedup diff failed: ${diffErr?.message ?? String(diffErr)}
29132
+ `);
29133
+ }
29134
+ }
29135
+ let configChanges = [];
29136
+ if (opts.configSnapshotPath) {
29137
+ try {
29138
+ const agentSlug = opts.agentSlug ?? opts.agentName;
29139
+ const agentName3 = process.env.SWITCHROOM_AGENT_NAME ?? agentSlug;
29140
+ let currentCfg;
29141
+ try {
29142
+ const loaded = loadConfig();
29143
+ const rawAgent = loaded.agents?.[agentName3] ?? {};
29144
+ const resolved = resolveAgentConfig(loaded.defaults, loaded.profiles, rawAgent);
29145
+ currentCfg = captureConfigSnapshot({
29146
+ agentName: agentName3,
29147
+ model: resolved.model,
29148
+ toolsAllow: resolved.tools?.allow,
29149
+ skills: resolved.skills,
29150
+ memoryCollection: resolved.memory?.collection
29151
+ });
29152
+ } catch {}
29153
+ if (currentCfg != null) {
29154
+ const previousSnapshot = loadSnapshot(opts.configSnapshotPath);
29155
+ configChanges = diffSnapshots(currentCfg, previousSnapshot);
29156
+ persistSnapshot(opts.configSnapshotPath, currentCfg);
29157
+ if (configChanges.length > 0) {
29158
+ logger2(`telegram gateway: boot-card: config-snapshot diff detected ${configChanges.length} change(s): ${configChanges.map((d) => d.field).join(", ")}
29159
+ `);
29160
+ }
29161
+ }
29162
+ } catch (snapErr) {
29163
+ logger2(`telegram gateway: boot-card: config-snapshot diff failed: ${snapErr?.message ?? String(snapErr)}
29014
29164
  `);
29015
29165
  }
29016
29166
  }
@@ -29024,7 +29174,8 @@ async function startBootCard(chatId, threadId, bot, opts, ackMessageId, log) {
29024
29174
  ...accountRows ? { accounts: accountRows } : {},
29025
29175
  ...resolvedRows.length > 0 ? { resolvedRows } : {},
29026
29176
  ...snoozeRows.length > 0 ? { snoozeRows } : {},
29027
- ...opts.updateOutcomeLine ? { updateOutcomeLine: opts.updateOutcomeLine } : {}
29177
+ ...opts.updateOutcomeLine ? { updateOutcomeLine: opts.updateOutcomeLine } : {},
29178
+ ...configChanges.length > 0 ? { configChanges } : {}
29028
29179
  });
29029
29180
  if (currentText !== ackText) {
29030
29181
  try {
@@ -29066,7 +29217,8 @@ async function startBootCard(chatId, threadId, bot, opts, ackMessageId, log) {
29066
29217
  ...accountRows ? { accounts: accountRows } : {},
29067
29218
  ...resolvedRows.length > 0 ? { resolvedRows } : {},
29068
29219
  ...snoozeRows.length > 0 ? { snoozeRows } : {},
29069
- ...opts.updateOutcomeLine ? { updateOutcomeLine: opts.updateOutcomeLine } : {}
29220
+ ...opts.updateOutcomeLine ? { updateOutcomeLine: opts.updateOutcomeLine } : {},
29221
+ ...configChanges.length > 0 ? { configChanges } : {}
29070
29222
  });
29071
29223
  if (updatedText === currentText)
29072
29224
  continue;
@@ -29108,7 +29260,9 @@ var SETTLE_WINDOW_MS = 6000, DOT, PROBE_LABELS, PROBE_KEYS, REASON_EMOJI, REASON
29108
29260
  var init_boot_card = __esm(() => {
29109
29261
  init_boot_probes();
29110
29262
  init_boot_issue_cache();
29263
+ init_config_snapshot();
29111
29264
  init_loader();
29265
+ init_merge();
29112
29266
  DOT = {
29113
29267
  ok: "\uD83D\uDFE2",
29114
29268
  degraded: "\uD83D\uDFE1",
@@ -29150,17 +29304,357 @@ var init_boot_card = __esm(() => {
29150
29304
  };
29151
29305
  });
29152
29306
 
29307
+ // auth-snapshot-format.ts
29308
+ var exports_auth_snapshot_format = {};
29309
+ __export(exports_auth_snapshot_format, {
29310
+ reviveLastQuota: () => reviveLastQuota,
29311
+ renderFallbackAnnouncement: () => renderFallbackAnnouncement2,
29312
+ renderAuthSnapshotFormat2: () => renderAuthSnapshotFormat22,
29313
+ recommendation: () => recommendation2,
29314
+ formatRelative: () => formatRelative2,
29315
+ formatAbsolute: () => formatAbsolute2,
29316
+ fmtPct: () => fmtPct2,
29317
+ classifyHealth: () => classifyHealth2,
29318
+ buildSnapshotsFromState: () => buildSnapshotsFromState2,
29319
+ buildSnapshotsFromCachedState: () => buildSnapshotsFromCachedState,
29320
+ buildSnapshotKeyboard: () => buildSnapshotKeyboard2,
29321
+ bindingWindow: () => bindingWindow3,
29322
+ THROTTLING_THRESHOLD_PCT: () => THROTTLING_THRESHOLD_PCT2
29323
+ });
29324
+ function classifyHealth2(snap) {
29325
+ if (!snap.quota)
29326
+ return "unknown";
29327
+ const q = snap.quota;
29328
+ const max = Math.max(q.fiveHourUtilizationPct, q.sevenDayUtilizationPct);
29329
+ if (max >= 99.5)
29330
+ return "blocked";
29331
+ if (max >= THROTTLING_THRESHOLD_PCT2)
29332
+ return "throttling";
29333
+ return "healthy";
29334
+ }
29335
+ function bindingWindow3(q) {
29336
+ if (q.representativeClaim === "seven_day")
29337
+ return "7d";
29338
+ if (q.representativeClaim === "five_hour")
29339
+ return "5h";
29340
+ return q.sevenDayUtilizationPct >= q.fiveHourUtilizationPct ? "7d" : "5h";
29341
+ }
29342
+ function formatRelative2(target, now = new Date) {
29343
+ if (!target)
29344
+ return "\u2014";
29345
+ const deltaMs = target.getTime() - now.getTime();
29346
+ if (deltaMs <= 0)
29347
+ return "now";
29348
+ const totalMin = Math.round(deltaMs / 60000);
29349
+ if (totalMin < 60)
29350
+ return `${totalMin}m`;
29351
+ const h = Math.floor(totalMin / 60);
29352
+ const m = totalMin % 60;
29353
+ if (h < 24)
29354
+ return m > 0 ? `${h}h ${m}m` : `${h}h`;
29355
+ const d = Math.floor(h / 24);
29356
+ const rh = h % 24;
29357
+ return rh > 0 ? `${d}d ${rh}h` : `${d}d`;
29358
+ }
29359
+ function formatAbsolute2(target, tz = "UTC") {
29360
+ if (!target)
29361
+ return "\u2014";
29362
+ return target.toLocaleString("en-US", {
29363
+ timeZone: tz,
29364
+ weekday: "short",
29365
+ hour: "numeric",
29366
+ minute: "2-digit",
29367
+ hour12: true
29368
+ });
29369
+ }
29370
+ function fmtPct2(pct) {
29371
+ return `${Math.round(pct)}%`;
29372
+ }
29373
+ function groupHeader2(health, count) {
29374
+ const emoji = HEALTH_EMOJI2[health];
29375
+ const title = HEALTH_TITLE2[health];
29376
+ return `${emoji} <b>${title}</b> (${count})`;
29377
+ }
29378
+ function renderAccountRow2(snap, opts) {
29379
+ const now = opts.now ?? new Date;
29380
+ const tz = opts.tz ?? "UTC";
29381
+ const lines = [];
29382
+ const marker = snap.isActive ? "\u25cf " : "";
29383
+ if (!snap.quota) {
29384
+ lines.push(`${marker}<code>${escapeHtml12(snap.label)}</code> <i>quota probe failed</i>`);
29385
+ if (snap.quotaError) {
29386
+ lines.push(` <i>${escapeHtml12(snap.quotaError)}</i>`);
29387
+ }
29388
+ return lines;
29389
+ }
29390
+ const q = snap.quota;
29391
+ const fiveStr = fmtPct2(q.fiveHourUtilizationPct);
29392
+ const sevenStr = fmtPct2(q.sevenDayUtilizationPct);
29393
+ lines.push(`${marker}<code>${escapeHtml12(snap.label)}</code> ${fiveStr} / ${sevenStr}`);
29394
+ const health = classifyHealth2(snap);
29395
+ if (health === "blocked") {
29396
+ const win = bindingWindow3(q);
29397
+ const reset2 = win === "5h" ? q.fiveHourResetAt : q.sevenDayResetAt;
29398
+ const winLabel = win === "5h" ? "5-hour" : "7-day";
29399
+ lines.push(` <i>back ${formatAbsolute2(reset2, tz)} (in ${formatRelative2(reset2, now)}, ${winLabel} cap)</i>`);
29400
+ return lines;
29401
+ }
29402
+ const fiveResetIn = q.fiveHourResetAt ? q.fiveHourResetAt.getTime() - now.getTime() : Infinity;
29403
+ const sevenResetIn = q.sevenDayResetAt ? q.sevenDayResetAt.getTime() - now.getTime() : Infinity;
29404
+ const fiveFirst = fiveResetIn <= sevenResetIn;
29405
+ const fiveSeg = q.fiveHourResetAt ? `5h refills ${formatAbsolute2(q.fiveHourResetAt, tz)} (in ${formatRelative2(q.fiveHourResetAt, now)})` : "5h refills \u2014";
29406
+ const sevenSeg = q.sevenDayResetAt ? `7d resets ${formatAbsolute2(q.sevenDayResetAt, tz)} (in ${formatRelative2(q.sevenDayResetAt, now)})` : "7d resets \u2014";
29407
+ lines.push(` <i>${fiveFirst ? fiveSeg : sevenSeg} \u00b7 ${fiveFirst ? sevenSeg : fiveSeg}</i>`);
29408
+ return lines;
29409
+ }
29410
+ function renderAuthSnapshotFormat22(snapshots, opts = {}) {
29411
+ const now = opts.now ?? new Date;
29412
+ const lines = [];
29413
+ lines.push("\uD83D\uDD0B <b>Auth \u2014 fleet status</b>");
29414
+ const order = ["blocked", "throttling", "healthy", "unknown"];
29415
+ const grouped = new Map;
29416
+ for (const s of snapshots) {
29417
+ const h = classifyHealth2(s);
29418
+ if (!grouped.has(h))
29419
+ grouped.set(h, []);
29420
+ grouped.get(h).push(s);
29421
+ }
29422
+ for (const arr of grouped.values()) {
29423
+ arr.sort((a, b) => Number(b.isActive) - Number(a.isActive));
29424
+ }
29425
+ for (const h of order) {
29426
+ const arr = grouped.get(h);
29427
+ if (!arr || arr.length === 0)
29428
+ continue;
29429
+ lines.push("");
29430
+ lines.push(groupHeader2(h, arr.length));
29431
+ for (const s of arr) {
29432
+ for (const ln of renderAccountRow2(s, opts))
29433
+ lines.push(ln);
29434
+ }
29435
+ }
29436
+ lines.push("");
29437
+ lines.push("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
29438
+ lines.push(`<i>${recommendation2(snapshots, now)}</i>`);
29439
+ if (opts.liveProbedAtMs != null) {
29440
+ const ageSec = Math.max(0, Math.round((Date.now() - opts.liveProbedAtMs) / 1000));
29441
+ const ageStr = ageSec < 60 ? `${ageSec}s ago` : `${Math.round(ageSec / 60)}m ago`;
29442
+ lines.push(`<i>Live \u00b7 refreshed ${ageStr}</i>`);
29443
+ } else {
29444
+ lines.push("<i>Live</i>");
29445
+ }
29446
+ return lines.join(`
29447
+ `);
29448
+ }
29449
+ function recommendation2(snapshots, now = new Date) {
29450
+ const active = snapshots.find((s) => s.isActive);
29451
+ if (!active)
29452
+ return "No active account set.";
29453
+ const activeHealth = classifyHealth2(active);
29454
+ const others = snapshots.filter((s) => !s.isActive);
29455
+ const healthyAlt = others.find((s) => classifyHealth2(s) === "healthy");
29456
+ if (activeHealth === "healthy") {
29457
+ return `Recommendation: stay on ${active.label}.`;
29458
+ }
29459
+ if (activeHealth === "throttling") {
29460
+ if (healthyAlt) {
29461
+ return `Recommendation: active ${active.label} is throttling. Switch to ${healthyAlt.label} for headroom.`;
29462
+ }
29463
+ return `Recommendation: active ${active.label} is throttling; no healthy alternative \u2014 wait for refill.`;
29464
+ }
29465
+ if (activeHealth === "blocked") {
29466
+ if (healthyAlt) {
29467
+ return `Recommendation: active ${active.label} is BLOCKED \u2014 switch to ${healthyAlt.label} now.`;
29468
+ }
29469
+ const earliestRecovery = pickEarliestRecovery2(snapshots, now);
29470
+ if (earliestRecovery) {
29471
+ return `All accounts blocked. Earliest recovery: ${earliestRecovery.label} in ${formatRelative2(earliestRecovery.at, now)}.`;
29472
+ }
29473
+ return `All accounts blocked. Run /auth add to attach another subscription.`;
29474
+ }
29475
+ return `Active ${active.label}: quota probe failed; broker last_seen unknown.`;
29476
+ }
29477
+ function pickEarliestRecovery2(snapshots, now) {
29478
+ let best = null;
29479
+ for (const s of snapshots) {
29480
+ if (!s.quota)
29481
+ continue;
29482
+ const win = bindingWindow3(s.quota);
29483
+ const at = win === "5h" ? s.quota.fiveHourResetAt : s.quota.sevenDayResetAt;
29484
+ if (!at || at.getTime() <= now.getTime())
29485
+ continue;
29486
+ if (!best || at.getTime() < best.at.getTime()) {
29487
+ best = { label: s.label, at };
29488
+ }
29489
+ }
29490
+ return best;
29491
+ }
29492
+ function renderFallbackAnnouncement2(input) {
29493
+ const now = input.now ?? new Date;
29494
+ const tz = input.tz ?? "UTC";
29495
+ const lines = [];
29496
+ const limitWord = input.oldQuota ? limitWordFor2(input.oldQuota) : "quota";
29497
+ const headerLimit = limitWord === "quota" ? "quota cap" : `${limitWord} limit`;
29498
+ if (!input.newLabel) {
29499
+ lines.push(`\uD83D\uDD34 <b>All accounts blocked \u00b7 ${headerLimit} on ${escapeHtml12(input.oldLabel)}</b>`);
29500
+ lines.push("");
29501
+ lines.push(`Triggered by: agent <b>${escapeHtml12(input.triggerAgent)}</b>`);
29502
+ if (input.oldQuota) {
29503
+ const recovery = recoveryAtFor2(input.oldQuota);
29504
+ if (recovery) {
29505
+ lines.push(`${escapeHtml12(input.oldLabel)} recovers ${formatAbsolute2(recovery, tz)} ` + `(in ${formatRelative2(recovery, now)})`);
29506
+ }
29507
+ }
29508
+ lines.push("");
29509
+ lines.push(`Run <code>/auth add &lt;label&gt;</code> to attach another subscription, ` + `or <code>/auth refresh</code> to re-probe.`);
29510
+ return lines.join(`
29511
+ `);
29512
+ }
29513
+ lines.push(`\u2713 <b>Switched fleet \u00b7 ${headerLimit} on ${escapeHtml12(input.oldLabel)}</b>`);
29514
+ lines.push("");
29515
+ lines.push(`<code>${escapeHtml12(input.oldLabel)}</code> \u2192 <code>${escapeHtml12(input.newLabel)}</code>`);
29516
+ lines.push(`Triggered by: agent <b>${escapeHtml12(input.triggerAgent)}</b>`);
29517
+ lines.push("");
29518
+ if (input.oldQuota) {
29519
+ const recovery = recoveryAtFor2(input.oldQuota);
29520
+ if (recovery) {
29521
+ lines.push(`<code>${escapeHtml12(input.oldLabel)}</code> recovers ` + `${formatAbsolute2(recovery, tz)} (in ${formatRelative2(recovery, now)})`);
29522
+ }
29523
+ }
29524
+ if (input.newQuota) {
29525
+ const fiveStr = fmtPct2(input.newQuota.fiveHourUtilizationPct);
29526
+ const sevenStr = fmtPct2(input.newQuota.sevenDayUtilizationPct);
29527
+ const hasHeadroom = input.newQuota.fiveHourUtilizationPct < THROTTLING_THRESHOLD_PCT2 && input.newQuota.sevenDayUtilizationPct < THROTTLING_THRESHOLD_PCT2;
29528
+ const headroomStr = hasHeadroom ? "<i>(plenty of headroom)</i>" : "<i>(near limit \u2014 watch this)</i>";
29529
+ lines.push(`<code>${escapeHtml12(input.newLabel)}</code> now: ${fiveStr} of 5h \u00b7 ${sevenStr} of 7d ${headroomStr}`);
29530
+ } else {
29531
+ lines.push(`<i>(quota probe for new account is pending \u2014 will reflect on next /auth)</i>`);
29532
+ }
29533
+ return lines.join(`
29534
+ `);
29535
+ }
29536
+ function limitWordFor2(q) {
29537
+ if (q.representativeClaim === "seven_day" && q.sevenDayUtilizationPct >= 99)
29538
+ return "7-day";
29539
+ if (q.representativeClaim === "five_hour" && q.fiveHourUtilizationPct >= 99)
29540
+ return "5-hour";
29541
+ if (q.sevenDayUtilizationPct >= 99)
29542
+ return "7-day";
29543
+ if (q.fiveHourUtilizationPct >= 99)
29544
+ return "5-hour";
29545
+ return q.sevenDayUtilizationPct >= q.fiveHourUtilizationPct ? "7-day" : "5-hour";
29546
+ }
29547
+ function recoveryAtFor2(q) {
29548
+ const word = limitWordFor2(q);
29549
+ if (word === "7-day")
29550
+ return q.sevenDayResetAt;
29551
+ if (word === "5-hour")
29552
+ return q.fiveHourResetAt;
29553
+ if (!q.fiveHourResetAt)
29554
+ return q.sevenDayResetAt;
29555
+ if (!q.sevenDayResetAt)
29556
+ return q.fiveHourResetAt;
29557
+ return q.fiveHourResetAt.getTime() < q.sevenDayResetAt.getTime() ? q.fiveHourResetAt : q.sevenDayResetAt;
29558
+ }
29559
+ function buildSnapshotKeyboard2(snapshots, opts = {}) {
29560
+ const max = opts.maxSwitchButtons ?? 3;
29561
+ const rows = [];
29562
+ const switchTargets = snapshots.filter((s) => !s.isActive).sort((a, b) => switchPriority2(a) - switchPriority2(b)).filter((s) => classifyHealth2(s) !== "blocked" && classifyHealth2(s) !== "unknown").slice(0, max);
29563
+ for (const t of switchTargets) {
29564
+ rows.push([
29565
+ {
29566
+ text: `Switch fleet \u2192 ${t.label}`,
29567
+ callbackData: `auth:use:${t.label}`
29568
+ }
29569
+ ]);
29570
+ }
29571
+ rows.push([
29572
+ { text: "\u21bb Refresh", callbackData: "auth:refresh" },
29573
+ { text: "/usage", insertText: "/usage" },
29574
+ { text: "+ Add", insertText: "/auth add " }
29575
+ ]);
29576
+ return rows;
29577
+ }
29578
+ function switchPriority2(s) {
29579
+ const h = classifyHealth2(s);
29580
+ if (h === "healthy")
29581
+ return 0;
29582
+ if (h === "throttling")
29583
+ return 1;
29584
+ if (h === "unknown")
29585
+ return 2;
29586
+ return 3;
29587
+ }
29588
+ function escapeHtml12(s) {
29589
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
29590
+ }
29591
+ function buildSnapshotsFromState2(state4, quotas) {
29592
+ const out = [];
29593
+ for (let i = 0;i < state4.accounts.length; i++) {
29594
+ const acc = state4.accounts[i];
29595
+ const q = quotas[i];
29596
+ out.push({
29597
+ label: acc.label,
29598
+ isActive: acc.label === state4.active,
29599
+ quota: q && q.ok ? q.data : null,
29600
+ quotaError: q && !q.ok ? q.reason : undefined,
29601
+ expiresAtMs: acc.expiresAt
29602
+ });
29603
+ }
29604
+ return out;
29605
+ }
29606
+ function reviveLastQuota(snap) {
29607
+ if (!snap)
29608
+ return null;
29609
+ return {
29610
+ fiveHourUtilizationPct: snap.fiveHourUtilizationPct,
29611
+ sevenDayUtilizationPct: snap.sevenDayUtilizationPct,
29612
+ fiveHourResetAt: snap.fiveHourResetAt ? new Date(snap.fiveHourResetAt) : null,
29613
+ sevenDayResetAt: snap.sevenDayResetAt ? new Date(snap.sevenDayResetAt) : null,
29614
+ representativeClaim: snap.representativeClaim,
29615
+ overageStatus: snap.overageStatus,
29616
+ overageDisabledReason: snap.overageDisabledReason
29617
+ };
29618
+ }
29619
+ function buildSnapshotsFromCachedState(state4) {
29620
+ return state4.accounts.map((acc) => {
29621
+ const lq = acc.last_quota ?? null;
29622
+ return {
29623
+ label: acc.label,
29624
+ isActive: acc.label === state4.active,
29625
+ quota: reviveLastQuota(lq),
29626
+ quotaError: lq ? undefined : "no cached quota (no probe since broker start)",
29627
+ expiresAtMs: acc.expiresAt
29628
+ };
29629
+ });
29630
+ }
29631
+ var THROTTLING_THRESHOLD_PCT2 = 80, HEALTH_EMOJI2, HEALTH_TITLE2;
29632
+ var init_auth_snapshot_format = __esm(() => {
29633
+ HEALTH_EMOJI2 = {
29634
+ healthy: "\uD83D\uDFE2",
29635
+ throttling: "\uD83D\uDFE1",
29636
+ blocked: "\uD83D\uDD34",
29637
+ unknown: "\u26aa"
29638
+ };
29639
+ HEALTH_TITLE2 = {
29640
+ healthy: "HEALTHY",
29641
+ throttling: "THROTTLING",
29642
+ blocked: "BLOCKED",
29643
+ unknown: "UNKNOWN"
29644
+ };
29645
+ });
29646
+
29153
29647
  // ../src/vault/flock.ts
29154
29648
  var init_flock = () => {};
29155
29649
 
29156
29650
  // ../src/vault/vault.ts
29157
29651
  import { randomBytes as randomBytes5, scryptSync, createCipheriv, createDecipheriv } from "node:crypto";
29158
29652
  import {
29159
- readFileSync as readFileSync31,
29160
- writeFileSync as writeFileSync19,
29161
- existsSync as existsSync32,
29162
- renameSync as renameSync11,
29163
- mkdirSync as mkdirSync18,
29653
+ readFileSync as readFileSync33,
29654
+ writeFileSync as writeFileSync21,
29655
+ existsSync as existsSync34,
29656
+ renameSync as renameSync12,
29657
+ mkdirSync as mkdirSync20,
29164
29658
  unlinkSync as unlinkSync12,
29165
29659
  lstatSync,
29166
29660
  realpathSync
@@ -29196,12 +29690,12 @@ function normalizeSecrets(raw) {
29196
29690
  return out;
29197
29691
  }
29198
29692
  function openVault(passphrase, vaultPath) {
29199
- if (!existsSync32(vaultPath)) {
29693
+ if (!existsSync34(vaultPath)) {
29200
29694
  throw new VaultError(`Vault file not found: ${vaultPath}`);
29201
29695
  }
29202
29696
  let vaultFile;
29203
29697
  try {
29204
- vaultFile = JSON.parse(readFileSync31(vaultPath, "utf8"));
29698
+ vaultFile = JSON.parse(readFileSync33(vaultPath, "utf8"));
29205
29699
  } catch {
29206
29700
  throw new VaultError(`Failed to read vault file: ${vaultPath}`);
29207
29701
  }
@@ -29248,14 +29742,14 @@ var init_vault = __esm(() => {
29248
29742
  import {
29249
29743
  chmodSync as chmodSync4,
29250
29744
  closeSync as closeSync7,
29251
- mkdirSync as mkdirSync19,
29745
+ mkdirSync as mkdirSync21,
29252
29746
  mkdtempSync as mkdtempSync2,
29253
29747
  openSync as openSync7,
29254
29748
  rmSync as rmSync3,
29255
29749
  statSync as statSync11,
29256
29750
  writeSync as writeSync2
29257
29751
  } from "node:fs";
29258
- import { join as join31 } from "node:path";
29752
+ import { join as join32 } from "node:path";
29259
29753
  import { tmpdir } from "node:os";
29260
29754
  import { constants as fsConstants } from "node:fs";
29261
29755
  function isVaultReference(value) {
@@ -29307,11 +29801,11 @@ function materializationRoot() {
29307
29801
  return cachedRoot;
29308
29802
  const xdg = process.env.XDG_RUNTIME_DIR;
29309
29803
  if (xdg) {
29310
- const base = join31(xdg, "switchroom", "vault");
29311
- mkdirSync19(base, { recursive: true, mode: 448 });
29312
- cachedRoot = mkdtempSync2(join31(base, "run-"));
29804
+ const base = join32(xdg, "switchroom", "vault");
29805
+ mkdirSync21(base, { recursive: true, mode: 448 });
29806
+ cachedRoot = mkdtempSync2(join32(base, "run-"));
29313
29807
  } else {
29314
- cachedRoot = mkdtempSync2(join31(tmpdir(), "switchroom-vault-"));
29808
+ cachedRoot = mkdtempSync2(join32(tmpdir(), "switchroom-vault-"));
29315
29809
  }
29316
29810
  chmodSync4(cachedRoot, 448);
29317
29811
  return cachedRoot;
@@ -29326,13 +29820,13 @@ function writeFileExclusive(filePath, content) {
29326
29820
  }
29327
29821
  }
29328
29822
  function materializeFilesEntry(key, files) {
29329
- const dir = join31(materializationRoot(), key);
29823
+ const dir = join32(materializationRoot(), key);
29330
29824
  if (materializedDirs.has(dir)) {
29331
29825
  try {
29332
29826
  rmSync3(dir, { recursive: true, force: true });
29333
29827
  } catch {}
29334
29828
  }
29335
- mkdirSync19(dir, { recursive: true, mode: 448 });
29829
+ mkdirSync21(dir, { recursive: true, mode: 448 });
29336
29830
  chmodSync4(dir, 448);
29337
29831
  const st = statSync11(dir);
29338
29832
  if (typeof process.getuid === "function" && st.uid !== process.getuid()) {
@@ -29342,7 +29836,7 @@ function materializeFilesEntry(key, files) {
29342
29836
  if (filename.includes("/") || filename.includes("\\") || filename === ".." || filename === "." || filename.includes("\x00")) {
29343
29837
  throw new Error(`Refusing to materialize vault file with unsafe name: ${filename}`);
29344
29838
  }
29345
- const filePath = join31(dir, filename);
29839
+ const filePath = join32(dir, filename);
29346
29840
  const content = encoding === "base64" ? Buffer.from(value, "base64") : value;
29347
29841
  writeFileExclusive(filePath, content);
29348
29842
  }
@@ -29475,7 +29969,7 @@ __export(exports_materialize_bot_token, {
29475
29969
  materializeBotToken: () => materializeBotToken,
29476
29970
  BotTokenMaterializeError: () => BotTokenMaterializeError
29477
29971
  });
29478
- import { existsSync as existsSync33 } from "node:fs";
29972
+ import { existsSync as existsSync35 } from "node:fs";
29479
29973
  function pickConfiguredToken(config, agentName3) {
29480
29974
  if (agentName3) {
29481
29975
  const agent = config.agents?.[agentName3];
@@ -29489,7 +29983,7 @@ function tryDirectVaultRead(ref, config, passphrase) {
29489
29983
  if (!passphrase)
29490
29984
  return null;
29491
29985
  const vaultPath = resolvePath(config.vault?.path ?? "~/.switchroom/vault.enc");
29492
- if (!existsSync33(vaultPath))
29986
+ if (!existsSync35(vaultPath))
29493
29987
  return null;
29494
29988
  try {
29495
29989
  const secrets = openVault(passphrase, vaultPath);
@@ -29607,7 +30101,7 @@ function truncateDiffForCard(unifiedDiff, maxLines = 50, maxChars = 3000) {
29607
30101
  }
29608
30102
  return out === unifiedDiff ? out : out + sentinel;
29609
30103
  }
29610
- function escapeHtml11(s) {
30104
+ function escapeHtml13(s) {
29611
30105
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
29612
30106
  }
29613
30107
  function clipReason(reason) {
@@ -29618,10 +30112,10 @@ function clipReason(reason) {
29618
30112
  function buildConfigApprovalCardBody(args) {
29619
30113
  const safeReason = clipReason(args.reason);
29620
30114
  const render = (diff) => `\uD83D\uDEE0 <b>Config edit proposed</b>
29621
- ` + `Agent: <code>${escapeHtml11(args.agentName)}</code>
29622
- ` + `Reason: ${escapeHtml11(safeReason)}
30115
+ ` + `Agent: <code>${escapeHtml13(args.agentName)}</code>
30116
+ ` + `Reason: ${escapeHtml13(safeReason)}
29623
30117
 
29624
- ` + `<pre>${escapeHtml11(diff)}</pre>`;
30118
+ ` + `<pre>${escapeHtml13(diff)}</pre>`;
29625
30119
  return truncateRawToFit({
29626
30120
  raw: args.unifiedDiff,
29627
30121
  render,
@@ -29728,8 +30222,8 @@ async function handleRequestConfigFinalize(_client, msg, deps) {
29728
30222
  }
29729
30223
  pending.delete(msg.requestId);
29730
30224
  const body = msg.outcome === "applied" ? `\u2705 <b>Applied</b>${msg.detail ? `
29731
- ${escapeHtml11(msg.detail)}` : ""}` : `\u26a0\ufe0f <b>Reconcile failed; rolled back</b>${msg.detail ? `
29732
- ${escapeHtml11(msg.detail)}` : ""}`;
30225
+ ${escapeHtml13(msg.detail)}` : ""}` : `\u26a0\ufe0f <b>Reconcile failed; rolled back</b>${msg.detail ? `
30226
+ ${escapeHtml13(msg.detail)}` : ""}`;
29733
30227
  try {
29734
30228
  await deps.editCard({
29735
30229
  chatId: entry.chatId,
@@ -29794,7 +30288,7 @@ __export(exports_tmux, {
29794
30288
  captureAgentPane: () => captureAgentPane
29795
30289
  });
29796
30290
  import { execFileSync as execFileSync4 } from "node:child_process";
29797
- import { mkdirSync as mkdirSync20, readdirSync as readdirSync6, statSync as statSync12, unlinkSync as unlinkSync13, writeFileSync as writeFileSync20 } from "node:fs";
30291
+ import { mkdirSync as mkdirSync22, readdirSync as readdirSync6, statSync as statSync12, unlinkSync as unlinkSync13, writeFileSync as writeFileSync22 } from "node:fs";
29798
30292
  import { resolve as resolve7 } from "node:path";
29799
30293
  function captureAgentPane(opts) {
29800
30294
  const { agentName: agentName3, agentDir, reason } = opts;
@@ -29806,7 +30300,7 @@ function captureAgentPane(opts) {
29806
30300
  const reasonSlug = sanitizeReason(reason);
29807
30301
  const outPath = resolve7(outDir, `${ts}-${reasonSlug}.txt`);
29808
30302
  try {
29809
- mkdirSync20(outDir, { recursive: true, mode: 493 });
30303
+ mkdirSync22(outDir, { recursive: true, mode: 493 });
29810
30304
  } catch (err) {
29811
30305
  const msg = `mkdir crash-reports failed: ${err.message}`;
29812
30306
  console.error(`[tmux-capture] ${agentName3}: ${msg}`);
@@ -29840,7 +30334,7 @@ function captureAgentPane(opts) {
29840
30334
  ` + `
29841
30335
  `;
29842
30336
  try {
29843
- writeFileSync20(outPath, Buffer.concat([Buffer.from(header, "utf8"), body]), {
30337
+ writeFileSync22(outPath, Buffer.concat([Buffer.from(header, "utf8"), body]), {
29844
30338
  mode: 420
29845
30339
  });
29846
30340
  } catch (err) {
@@ -29999,17 +30493,17 @@ function registerApprovalsCommands(bot, opts) {
29999
30493
  return;
30000
30494
  }
30001
30495
  if (decisions.length === 0) {
30002
- await ctx.reply(agentFilter ? `No active approvals for <code>${escapeHtml12(agentFilter)}</code>.` : "No active approvals.", { parse_mode: "HTML" });
30496
+ await ctx.reply(agentFilter ? `No active approvals for <code>${escapeHtml14(agentFilter)}</code>.` : "No active approvals.", { parse_mode: "HTML" });
30003
30497
  return;
30004
30498
  }
30005
30499
  const byAgent = new Map;
30006
30500
  for (const d of decisions)
30007
30501
  byAgent.set(d.agent_unit, (byAgent.get(d.agent_unit) ?? 0) + 1);
30008
- const summary = Array.from(byAgent.entries()).map(([a, n]) => `\u2022 <b>${escapeHtml12(a)}</b>: ${n}`).join(`
30502
+ const summary = Array.from(byAgent.entries()).map(([a, n]) => `\u2022 <b>${escapeHtml14(a)}</b>: ${n}`).join(`
30009
30503
  `);
30010
30504
  const detail = decisions.slice(0, 20).map((d) => {
30011
30505
  const ttl = d.ttl_expires_at === null ? "always" : `until ${new Date(d.ttl_expires_at).toISOString().slice(0, 16).replace("T", " ")}`;
30012
- return `<code>${escapeHtml12(d.id.slice(0, 8))}</code> ` + `${escapeHtml12(d.agent_unit)} \u2192 ` + `<code>${escapeHtml12(d.scope)}</code> ` + `(${escapeHtml12(d.action)}, ${ttl}) ` + `\u00b7 /approvals revoke ${escapeHtml12(d.id)}`;
30506
+ return `<code>${escapeHtml14(d.id.slice(0, 8))}</code> ` + `${escapeHtml14(d.agent_unit)} \u2192 ` + `<code>${escapeHtml14(d.scope)}</code> ` + `(${escapeHtml14(d.action)}, ${ttl}) ` + `\u00b7 /approvals revoke ${escapeHtml14(d.id)}`;
30013
30507
  }).join(`
30014
30508
  `);
30015
30509
  await ctx.reply(`<b>Active approvals</b>
@@ -30035,332 +30529,19 @@ ${detail}`, {
30035
30529
  await ctx.reply("Approval kernel unreachable.");
30036
30530
  return;
30037
30531
  }
30038
- await ctx.reply(ok ? `Revoked <code>${escapeHtml12(id)}</code>.` : `No such active decision <code>${escapeHtml12(id)}</code>.`, { parse_mode: "HTML" });
30532
+ await ctx.reply(ok ? `Revoked <code>${escapeHtml14(id)}</code>.` : `No such active decision <code>${escapeHtml14(id)}</code>.`, { parse_mode: "HTML" });
30039
30533
  return;
30040
30534
  }
30041
- await ctx.reply(`Unknown subcommand <code>${escapeHtml12(sub)}</code>. ` + `Use <code>/approvals list</code> or <code>/approvals revoke &lt;id&gt;</code>. ` + `(<code>add</code> and <code>stats</code> are coming in a follow-up.)`, { parse_mode: "HTML" });
30535
+ await ctx.reply(`Unknown subcommand <code>${escapeHtml14(sub)}</code>. ` + `Use <code>/approvals list</code> or <code>/approvals revoke &lt;id&gt;</code>. ` + `(<code>add</code> and <code>stats</code> are coming in a follow-up.)`, { parse_mode: "HTML" });
30042
30536
  });
30043
30537
  }
30044
- function escapeHtml12(s) {
30538
+ function escapeHtml14(s) {
30045
30539
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
30046
30540
  }
30047
30541
  var init_approvals_commands = __esm(() => {
30048
30542
  init_client3();
30049
30543
  });
30050
30544
 
30051
- // auth-snapshot-format.ts
30052
- var exports_auth_snapshot_format = {};
30053
- __export(exports_auth_snapshot_format, {
30054
- renderFallbackAnnouncement: () => renderFallbackAnnouncement2,
30055
- renderAuthSnapshotFormat2: () => renderAuthSnapshotFormat22,
30056
- recommendation: () => recommendation2,
30057
- formatRelative: () => formatRelative2,
30058
- formatAbsolute: () => formatAbsolute2,
30059
- fmtPct: () => fmtPct2,
30060
- classifyHealth: () => classifyHealth2,
30061
- buildSnapshotsFromState: () => buildSnapshotsFromState2,
30062
- buildSnapshotKeyboard: () => buildSnapshotKeyboard2,
30063
- bindingWindow: () => bindingWindow2,
30064
- THROTTLING_THRESHOLD_PCT: () => THROTTLING_THRESHOLD_PCT2
30065
- });
30066
- function classifyHealth2(snap) {
30067
- if (!snap.quota)
30068
- return "unknown";
30069
- const q = snap.quota;
30070
- const max = Math.max(q.fiveHourUtilizationPct, q.sevenDayUtilizationPct);
30071
- if (max >= 99.5)
30072
- return "blocked";
30073
- if (max >= THROTTLING_THRESHOLD_PCT2)
30074
- return "throttling";
30075
- return "healthy";
30076
- }
30077
- function bindingWindow2(q) {
30078
- if (q.representativeClaim === "seven_day")
30079
- return "7d";
30080
- if (q.representativeClaim === "five_hour")
30081
- return "5h";
30082
- return q.sevenDayUtilizationPct >= q.fiveHourUtilizationPct ? "7d" : "5h";
30083
- }
30084
- function formatRelative2(target, now = new Date) {
30085
- if (!target)
30086
- return "\u2014";
30087
- const deltaMs = target.getTime() - now.getTime();
30088
- if (deltaMs <= 0)
30089
- return "now";
30090
- const totalMin = Math.round(deltaMs / 60000);
30091
- if (totalMin < 60)
30092
- return `${totalMin}m`;
30093
- const h = Math.floor(totalMin / 60);
30094
- const m = totalMin % 60;
30095
- if (h < 24)
30096
- return m > 0 ? `${h}h ${m}m` : `${h}h`;
30097
- const d = Math.floor(h / 24);
30098
- const rh = h % 24;
30099
- return rh > 0 ? `${d}d ${rh}h` : `${d}d`;
30100
- }
30101
- function formatAbsolute2(target, tz = "UTC") {
30102
- if (!target)
30103
- return "\u2014";
30104
- return target.toLocaleString("en-US", {
30105
- timeZone: tz,
30106
- weekday: "short",
30107
- hour: "numeric",
30108
- minute: "2-digit",
30109
- hour12: true
30110
- });
30111
- }
30112
- function fmtPct2(pct) {
30113
- return `${Math.round(pct)}%`;
30114
- }
30115
- function groupHeader2(health, count) {
30116
- const emoji = HEALTH_EMOJI2[health];
30117
- const title = HEALTH_TITLE2[health];
30118
- return `${emoji} <b>${title}</b> (${count})`;
30119
- }
30120
- function renderAccountRow2(snap, opts) {
30121
- const now = opts.now ?? new Date;
30122
- const tz = opts.tz ?? "UTC";
30123
- const lines = [];
30124
- const marker = snap.isActive ? "\u25cf " : "";
30125
- if (!snap.quota) {
30126
- lines.push(`${marker}<code>${escapeHtml13(snap.label)}</code> <i>quota probe failed</i>`);
30127
- if (snap.quotaError) {
30128
- lines.push(` <i>${escapeHtml13(snap.quotaError)}</i>`);
30129
- }
30130
- return lines;
30131
- }
30132
- const q = snap.quota;
30133
- const fiveStr = fmtPct2(q.fiveHourUtilizationPct);
30134
- const sevenStr = fmtPct2(q.sevenDayUtilizationPct);
30135
- lines.push(`${marker}<code>${escapeHtml13(snap.label)}</code> ${fiveStr} / ${sevenStr}`);
30136
- const health = classifyHealth2(snap);
30137
- if (health === "blocked") {
30138
- const win = bindingWindow2(q);
30139
- const reset2 = win === "5h" ? q.fiveHourResetAt : q.sevenDayResetAt;
30140
- const winLabel = win === "5h" ? "5-hour" : "7-day";
30141
- lines.push(` <i>back ${formatAbsolute2(reset2, tz)} (in ${formatRelative2(reset2, now)}, ${winLabel} cap)</i>`);
30142
- return lines;
30143
- }
30144
- const fiveResetIn = q.fiveHourResetAt ? q.fiveHourResetAt.getTime() - now.getTime() : Infinity;
30145
- const sevenResetIn = q.sevenDayResetAt ? q.sevenDayResetAt.getTime() - now.getTime() : Infinity;
30146
- const fiveFirst = fiveResetIn <= sevenResetIn;
30147
- const fiveSeg = q.fiveHourResetAt ? `5h refills ${formatAbsolute2(q.fiveHourResetAt, tz)} (in ${formatRelative2(q.fiveHourResetAt, now)})` : "5h refills \u2014";
30148
- const sevenSeg = q.sevenDayResetAt ? `7d resets ${formatAbsolute2(q.sevenDayResetAt, tz)} (in ${formatRelative2(q.sevenDayResetAt, now)})` : "7d resets \u2014";
30149
- lines.push(` <i>${fiveFirst ? fiveSeg : sevenSeg} \u00b7 ${fiveFirst ? sevenSeg : fiveSeg}</i>`);
30150
- return lines;
30151
- }
30152
- function renderAuthSnapshotFormat22(snapshots, opts = {}) {
30153
- const now = opts.now ?? new Date;
30154
- const lines = [];
30155
- lines.push("\uD83D\uDD0B <b>Auth \u2014 fleet status</b>");
30156
- const order = ["blocked", "throttling", "healthy", "unknown"];
30157
- const grouped = new Map;
30158
- for (const s of snapshots) {
30159
- const h = classifyHealth2(s);
30160
- if (!grouped.has(h))
30161
- grouped.set(h, []);
30162
- grouped.get(h).push(s);
30163
- }
30164
- for (const arr of grouped.values()) {
30165
- arr.sort((a, b) => Number(b.isActive) - Number(a.isActive));
30166
- }
30167
- for (const h of order) {
30168
- const arr = grouped.get(h);
30169
- if (!arr || arr.length === 0)
30170
- continue;
30171
- lines.push("");
30172
- lines.push(groupHeader2(h, arr.length));
30173
- for (const s of arr) {
30174
- for (const ln of renderAccountRow2(s, opts))
30175
- lines.push(ln);
30176
- }
30177
- }
30178
- lines.push("");
30179
- lines.push("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
30180
- lines.push(`<i>${recommendation2(snapshots, now)}</i>`);
30181
- if (opts.liveProbedAtMs != null) {
30182
- const ageSec = Math.max(0, Math.round((Date.now() - opts.liveProbedAtMs) / 1000));
30183
- const ageStr = ageSec < 60 ? `${ageSec}s ago` : `${Math.round(ageSec / 60)}m ago`;
30184
- lines.push(`<i>Live \u00b7 refreshed ${ageStr}</i>`);
30185
- } else {
30186
- lines.push("<i>Live</i>");
30187
- }
30188
- return lines.join(`
30189
- `);
30190
- }
30191
- function recommendation2(snapshots, now = new Date) {
30192
- const active = snapshots.find((s) => s.isActive);
30193
- if (!active)
30194
- return "No active account set.";
30195
- const activeHealth = classifyHealth2(active);
30196
- const others = snapshots.filter((s) => !s.isActive);
30197
- const healthyAlt = others.find((s) => classifyHealth2(s) === "healthy");
30198
- if (activeHealth === "healthy") {
30199
- return `Recommendation: stay on ${active.label}.`;
30200
- }
30201
- if (activeHealth === "throttling") {
30202
- if (healthyAlt) {
30203
- return `Recommendation: active ${active.label} is throttling. Switch to ${healthyAlt.label} for headroom.`;
30204
- }
30205
- return `Recommendation: active ${active.label} is throttling; no healthy alternative \u2014 wait for refill.`;
30206
- }
30207
- if (activeHealth === "blocked") {
30208
- if (healthyAlt) {
30209
- return `Recommendation: active ${active.label} is BLOCKED \u2014 switch to ${healthyAlt.label} now.`;
30210
- }
30211
- const earliestRecovery = pickEarliestRecovery2(snapshots, now);
30212
- if (earliestRecovery) {
30213
- return `All accounts blocked. Earliest recovery: ${earliestRecovery.label} in ${formatRelative2(earliestRecovery.at, now)}.`;
30214
- }
30215
- return `All accounts blocked. Run /auth add to attach another subscription.`;
30216
- }
30217
- return `Active ${active.label}: quota probe failed; broker last_seen unknown.`;
30218
- }
30219
- function pickEarliestRecovery2(snapshots, now) {
30220
- let best = null;
30221
- for (const s of snapshots) {
30222
- if (!s.quota)
30223
- continue;
30224
- const win = bindingWindow2(s.quota);
30225
- const at = win === "5h" ? s.quota.fiveHourResetAt : s.quota.sevenDayResetAt;
30226
- if (!at || at.getTime() <= now.getTime())
30227
- continue;
30228
- if (!best || at.getTime() < best.at.getTime()) {
30229
- best = { label: s.label, at };
30230
- }
30231
- }
30232
- return best;
30233
- }
30234
- function renderFallbackAnnouncement2(input) {
30235
- const now = input.now ?? new Date;
30236
- const tz = input.tz ?? "UTC";
30237
- const lines = [];
30238
- const limitWord = input.oldQuota ? limitWordFor2(input.oldQuota) : "quota";
30239
- const headerLimit = limitWord === "quota" ? "quota cap" : `${limitWord} limit`;
30240
- if (!input.newLabel) {
30241
- lines.push(`\uD83D\uDD34 <b>All accounts blocked \u00b7 ${headerLimit} on ${escapeHtml13(input.oldLabel)}</b>`);
30242
- lines.push("");
30243
- lines.push(`Triggered by: agent <b>${escapeHtml13(input.triggerAgent)}</b>`);
30244
- if (input.oldQuota) {
30245
- const recovery = recoveryAtFor2(input.oldQuota);
30246
- if (recovery) {
30247
- lines.push(`${escapeHtml13(input.oldLabel)} recovers ${formatAbsolute2(recovery, tz)} ` + `(in ${formatRelative2(recovery, now)})`);
30248
- }
30249
- }
30250
- lines.push("");
30251
- lines.push(`Run <code>/auth add &lt;label&gt;</code> to attach another subscription, ` + `or <code>/auth refresh</code> to re-probe.`);
30252
- return lines.join(`
30253
- `);
30254
- }
30255
- lines.push(`\u2713 <b>Switched fleet \u00b7 ${headerLimit} on ${escapeHtml13(input.oldLabel)}</b>`);
30256
- lines.push("");
30257
- lines.push(`<code>${escapeHtml13(input.oldLabel)}</code> \u2192 <code>${escapeHtml13(input.newLabel)}</code>`);
30258
- lines.push(`Triggered by: agent <b>${escapeHtml13(input.triggerAgent)}</b>`);
30259
- lines.push("");
30260
- if (input.oldQuota) {
30261
- const recovery = recoveryAtFor2(input.oldQuota);
30262
- if (recovery) {
30263
- lines.push(`<code>${escapeHtml13(input.oldLabel)}</code> recovers ` + `${formatAbsolute2(recovery, tz)} (in ${formatRelative2(recovery, now)})`);
30264
- }
30265
- }
30266
- if (input.newQuota) {
30267
- const fiveStr = fmtPct2(input.newQuota.fiveHourUtilizationPct);
30268
- const sevenStr = fmtPct2(input.newQuota.sevenDayUtilizationPct);
30269
- const hasHeadroom = input.newQuota.fiveHourUtilizationPct < THROTTLING_THRESHOLD_PCT2 && input.newQuota.sevenDayUtilizationPct < THROTTLING_THRESHOLD_PCT2;
30270
- const headroomStr = hasHeadroom ? "<i>(plenty of headroom)</i>" : "<i>(near limit \u2014 watch this)</i>";
30271
- lines.push(`<code>${escapeHtml13(input.newLabel)}</code> now: ${fiveStr} of 5h \u00b7 ${sevenStr} of 7d ${headroomStr}`);
30272
- } else {
30273
- lines.push(`<i>(quota probe for new account is pending \u2014 will reflect on next /auth)</i>`);
30274
- }
30275
- return lines.join(`
30276
- `);
30277
- }
30278
- function limitWordFor2(q) {
30279
- if (q.representativeClaim === "seven_day" && q.sevenDayUtilizationPct >= 99)
30280
- return "7-day";
30281
- if (q.representativeClaim === "five_hour" && q.fiveHourUtilizationPct >= 99)
30282
- return "5-hour";
30283
- if (q.sevenDayUtilizationPct >= 99)
30284
- return "7-day";
30285
- if (q.fiveHourUtilizationPct >= 99)
30286
- return "5-hour";
30287
- return q.sevenDayUtilizationPct >= q.fiveHourUtilizationPct ? "7-day" : "5-hour";
30288
- }
30289
- function recoveryAtFor2(q) {
30290
- const word = limitWordFor2(q);
30291
- if (word === "7-day")
30292
- return q.sevenDayResetAt;
30293
- if (word === "5-hour")
30294
- return q.fiveHourResetAt;
30295
- if (!q.fiveHourResetAt)
30296
- return q.sevenDayResetAt;
30297
- if (!q.sevenDayResetAt)
30298
- return q.fiveHourResetAt;
30299
- return q.fiveHourResetAt.getTime() < q.sevenDayResetAt.getTime() ? q.fiveHourResetAt : q.sevenDayResetAt;
30300
- }
30301
- function buildSnapshotKeyboard2(snapshots, opts = {}) {
30302
- const max = opts.maxSwitchButtons ?? 3;
30303
- const rows = [];
30304
- const switchTargets = snapshots.filter((s) => !s.isActive).sort((a, b) => switchPriority2(a) - switchPriority2(b)).filter((s) => classifyHealth2(s) !== "blocked" && classifyHealth2(s) !== "unknown").slice(0, max);
30305
- for (const t of switchTargets) {
30306
- rows.push([
30307
- {
30308
- text: `Switch fleet \u2192 ${t.label}`,
30309
- callbackData: `auth:use:${t.label}`
30310
- }
30311
- ]);
30312
- }
30313
- rows.push([
30314
- { text: "\u21bb Refresh", callbackData: "auth:refresh" },
30315
- { text: "/usage", insertText: "/usage" },
30316
- { text: "+ Add", insertText: "/auth add " }
30317
- ]);
30318
- return rows;
30319
- }
30320
- function switchPriority2(s) {
30321
- const h = classifyHealth2(s);
30322
- if (h === "healthy")
30323
- return 0;
30324
- if (h === "throttling")
30325
- return 1;
30326
- if (h === "unknown")
30327
- return 2;
30328
- return 3;
30329
- }
30330
- function escapeHtml13(s) {
30331
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
30332
- }
30333
- function buildSnapshotsFromState2(state4, quotas) {
30334
- const out = [];
30335
- for (let i = 0;i < state4.accounts.length; i++) {
30336
- const acc = state4.accounts[i];
30337
- const q = quotas[i];
30338
- out.push({
30339
- label: acc.label,
30340
- isActive: acc.label === state4.active,
30341
- quota: q && q.ok ? q.data : null,
30342
- quotaError: q && !q.ok ? q.reason : undefined,
30343
- expiresAtMs: acc.expiresAt
30344
- });
30345
- }
30346
- return out;
30347
- }
30348
- var THROTTLING_THRESHOLD_PCT2 = 80, HEALTH_EMOJI2, HEALTH_TITLE2;
30349
- var init_auth_snapshot_format = __esm(() => {
30350
- HEALTH_EMOJI2 = {
30351
- healthy: "\uD83D\uDFE2",
30352
- throttling: "\uD83D\uDFE1",
30353
- blocked: "\uD83D\uDD34",
30354
- unknown: "\u26aa"
30355
- };
30356
- HEALTH_TITLE2 = {
30357
- healthy: "HEALTHY",
30358
- throttling: "THROTTLING",
30359
- blocked: "BLOCKED",
30360
- unknown: "UNKNOWN"
30361
- };
30362
- });
30363
-
30364
30545
  // gateway/approval-card.ts
30365
30546
  function parseApprovalCallback(data) {
30366
30547
  if (!data.startsWith("apv:"))
@@ -30495,23 +30676,23 @@ var import_runner2 = __toESM(require_mod3(), 1);
30495
30676
  import { randomBytes as randomBytes6 } from "crypto";
30496
30677
  import { execFileSync as execFileSync5, execSync as execSync2, spawn as spawn2 } from "child_process";
30497
30678
  import {
30498
- readFileSync as readFileSync32,
30499
- writeFileSync as writeFileSync21,
30500
- mkdirSync as mkdirSync21,
30679
+ readFileSync as readFileSync34,
30680
+ writeFileSync as writeFileSync23,
30681
+ mkdirSync as mkdirSync23,
30501
30682
  readdirSync as readdirSync7,
30502
30683
  rmSync as rmSync4,
30503
30684
  statSync as statSync13,
30504
- renameSync as renameSync12,
30685
+ renameSync as renameSync13,
30505
30686
  realpathSync as realpathSync2,
30506
30687
  chmodSync as chmodSync5,
30507
30688
  openSync as openSync8,
30508
30689
  closeSync as closeSync8,
30509
- existsSync as existsSync34,
30690
+ existsSync as existsSync36,
30510
30691
  unlinkSync as unlinkSync14,
30511
30692
  appendFileSync as appendFileSync3
30512
30693
  } from "fs";
30513
30694
  import { homedir as homedir12 } from "os";
30514
- import { join as join32, extname, sep as sep3, basename as basename7 } from "path";
30695
+ import { join as join33, extname, sep as sep3, basename as basename7 } from "path";
30515
30696
 
30516
30697
  // plugin-logger.ts
30517
30698
  import { appendFileSync, mkdirSync, renameSync, statSync, existsSync } from "fs";
@@ -31685,6 +31866,111 @@ function registerAndRender(state, toolName) {
31685
31866
  return null;
31686
31867
  return formatSummary(state);
31687
31868
  }
31869
+ function baseName(p) {
31870
+ if (typeof p !== "string" || p.length === 0)
31871
+ return null;
31872
+ const parts = p.split("/").filter(Boolean);
31873
+ return parts.length > 0 ? parts[parts.length - 1] : p;
31874
+ }
31875
+ function hostName(u) {
31876
+ if (typeof u !== "string" || u.length === 0)
31877
+ return null;
31878
+ try {
31879
+ return new URL(u).hostname.replace(/^www\./, "");
31880
+ } catch {
31881
+ return u.replace(/^https?:\/\//, "").split("/")[0] || null;
31882
+ }
31883
+ }
31884
+ function clip(s, n) {
31885
+ if (typeof s !== "string")
31886
+ return null;
31887
+ const t = s.trim();
31888
+ if (t.length === 0)
31889
+ return null;
31890
+ return t.length > n ? t.slice(0, n - 1) + "\u2026" : t;
31891
+ }
31892
+ function describeToolUse(toolName, input) {
31893
+ if (!toolName)
31894
+ return null;
31895
+ const inp = input ?? {};
31896
+ const mcpMatch = /^mcp__(.+?)__(.+)$/.exec(toolName);
31897
+ if (mcpMatch) {
31898
+ const server = mcpMatch[1].toLowerCase();
31899
+ const tool = mcpMatch[2].toLowerCase();
31900
+ if (server === "switchroom-telegram")
31901
+ return null;
31902
+ if (server === "hindsight") {
31903
+ if (tool === "recall" || tool === "reflect")
31904
+ return "Searching memory";
31905
+ if (tool === "retain" || tool === "update_memory" || tool === "sync_retain")
31906
+ return "Saving to memory";
31907
+ return "Working with memory";
31908
+ }
31909
+ if (server === "google-workspace" || server === "claude_ai_google_calendar") {
31910
+ return "Checking your calendar";
31911
+ }
31912
+ if (server === "claude_ai_gmail")
31913
+ return "Checking your email";
31914
+ if (server === "claude_ai_google_drive")
31915
+ return "Looking through your files";
31916
+ if (server === "notion" || server === "claude_ai_notion") {
31917
+ return "Checking your notes";
31918
+ }
31919
+ const desc = clip(inp.description, 60) ?? clip(inp.query, 50) ?? clip(inp.title, 50);
31920
+ if (desc)
31921
+ return desc;
31922
+ return "Using " + tool.replace(/[-_]+/g, " ");
31923
+ }
31924
+ switch (toolName) {
31925
+ case "Bash": {
31926
+ return clip(inp.description, 70) ?? "Running a command";
31927
+ }
31928
+ case "BashOutput":
31929
+ case "KillShell":
31930
+ return "Managing a background command";
31931
+ case "Read": {
31932
+ const f = baseName(inp.file_path);
31933
+ return f ? `Reading ${f}` : "Reading a file";
31934
+ }
31935
+ case "Edit":
31936
+ case "MultiEdit":
31937
+ case "NotebookEdit": {
31938
+ const f = baseName(inp.file_path) ?? baseName(inp.notebook_path);
31939
+ return f ? `Editing ${f}` : "Editing a file";
31940
+ }
31941
+ case "Write": {
31942
+ const f = baseName(inp.file_path);
31943
+ return f ? `Writing ${f}` : "Writing a file";
31944
+ }
31945
+ case "Grep":
31946
+ case "Glob": {
31947
+ const p = clip(inp.pattern, 40);
31948
+ return p ? `Searching for ${p}` : "Searching files";
31949
+ }
31950
+ case "WebFetch": {
31951
+ const h = hostName(inp.url);
31952
+ return h ? `Reading ${h}` : "Reading a web page";
31953
+ }
31954
+ case "WebSearch": {
31955
+ const q = clip(inp.query, 50);
31956
+ return q ? `Searching the web for ${q}` : "Searching the web";
31957
+ }
31958
+ case "Task":
31959
+ case "Agent": {
31960
+ const d = clip(inp.description, 60);
31961
+ return d ? `Delegating: ${d}` : "Delegating to a sub-agent";
31962
+ }
31963
+ case "TodoWrite":
31964
+ case "TaskCreate":
31965
+ case "TaskUpdate":
31966
+ case "TaskList":
31967
+ return "Updating the plan";
31968
+ case "ToolSearch":
31969
+ return "Finding the right tool";
31970
+ default:
31971
+ return "Working\u2026";
31972
+ }
31973
+ }
31688
31974
 
31689
31975
  // tool-labels.ts
31690
31976
  var MAX_LABEL_CHARS = 60;
@@ -33123,7 +33409,7 @@ function clear(key) {
33123
33409
  state.delete(key);
33124
33410
  }
33125
33411
 
33126
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
33412
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
33127
33413
  import { dirname as dirname2, posix, sep as sep2 } from "path";
33128
33414
  function createModulerModifier() {
33129
33415
  const getModuleFromFileName = createGetModuleFromFilename();
@@ -33159,7 +33445,7 @@ function normalizeWindowsPath(path) {
33159
33445
  return path.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
33160
33446
  }
33161
33447
 
33162
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/featureFlagUtils.mjs
33448
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/featureFlagUtils.mjs
33163
33449
  var normalizeFlagsResponse = (flagsResponse) => {
33164
33450
  if ("flags" in flagsResponse) {
33165
33451
  const featureFlags = getFlagValuesFromFlags(flagsResponse.flags);
@@ -33230,7 +33516,7 @@ var parsePayload = (response) => {
33230
33516
  }
33231
33517
  };
33232
33518
 
33233
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/gzip.mjs
33519
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/gzip.mjs
33234
33520
  function isGzipSupported() {
33235
33521
  return "CompressionStream" in globalThis;
33236
33522
  }
@@ -33250,7 +33536,7 @@ async function gzipCompress(input, isDebug = true) {
33250
33536
  }
33251
33537
  }
33252
33538
 
33253
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
33539
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
33254
33540
  /*! For license information please see uuidv7.mjs.LICENSE.txt */
33255
33541
  var DIGITS = "0123456789abcdef";
33256
33542
 
@@ -33428,7 +33714,7 @@ var defaultGenerator;
33428
33714
  var uuidv7 = () => uuidv7obj().toString();
33429
33715
  var uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator)).generate();
33430
33716
 
33431
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/types.mjs
33717
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/types.mjs
33432
33718
  var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedProperty) {
33433
33719
  PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
33434
33720
  PostHogPersistedProperty["DistinctId"] = "distinct_id";
@@ -33461,7 +33747,7 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
33461
33747
  return PostHogPersistedProperty;
33462
33748
  }({});
33463
33749
 
33464
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/bot-detection.mjs
33750
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/bot-detection.mjs
33465
33751
  var DEFAULT_BLOCKED_UA_STRS = [
33466
33752
  "amazonbot",
33467
33753
  "amazonproductbot",
@@ -33550,7 +33836,7 @@ var isBlockedUA = function(ua, customBlockedUserAgents = []) {
33550
33836
  return uaLower.indexOf(blockedUaLower) !== -1;
33551
33837
  });
33552
33838
  };
33553
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/type-utils.mjs
33839
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/type-utils.mjs
33554
33840
  var nativeIsArray = Array.isArray;
33555
33841
  var ObjProto = Object.prototype;
33556
33842
  var type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
@@ -33587,7 +33873,7 @@ function isInstanceOf(candidate, base) {
33587
33873
  }
33588
33874
  }
33589
33875
 
33590
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/number-utils.mjs
33876
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/number-utils.mjs
33591
33877
  function clampToRange(value, min, max, logger, fallbackValue) {
33592
33878
  if (min > max) {
33593
33879
  logger.warn("min cannot be greater than max.");
@@ -33607,7 +33893,7 @@ function clampToRange(value, min, max, logger, fallbackValue) {
33607
33893
  return clampToRange(fallbackValue || max, min, max, logger);
33608
33894
  }
33609
33895
 
33610
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
33896
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
33611
33897
  var ONE_DAY_IN_MS = 86400000;
33612
33898
 
33613
33899
  class BucketedRateLimiter {
@@ -33651,7 +33937,7 @@ class BucketedRateLimiter {
33651
33937
  this._buckets = {};
33652
33938
  }
33653
33939
  }
33654
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/promise-queue.mjs
33940
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/promise-queue.mjs
33655
33941
  class PromiseQueue {
33656
33942
  add(promise) {
33657
33943
  const promiseUUID = uuidv7();
@@ -33677,7 +33963,7 @@ class PromiseQueue {
33677
33963
  this.promiseByIds = {};
33678
33964
  }
33679
33965
  }
33680
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/logger.mjs
33966
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/logger.mjs
33681
33967
  function createConsole(consoleLike = console) {
33682
33968
  const lockedMethods = {
33683
33969
  log: consoleLike.log.bind(consoleLike),
@@ -33715,7 +34001,7 @@ var passThrough = (fn) => fn();
33715
34001
  function createLogger(prefix, maybeCall = passThrough) {
33716
34002
  return _createLogger(prefix, maybeCall, createConsole());
33717
34003
  }
33718
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
34004
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
33719
34005
  var MOBILE = "Mobile";
33720
34006
  var IOS = "iOS";
33721
34007
  var ANDROID = "Android";
@@ -33972,7 +34258,7 @@ var osMatchers = [
33972
34258
  ]
33973
34259
  ];
33974
34260
 
33975
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/index.mjs
34261
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/utils/index.mjs
33976
34262
  var STRING_FORMAT = "utf8";
33977
34263
  function assert(truthyValue, message) {
33978
34264
  if (!truthyValue || typeof truthyValue != "string" || isEmpty(truthyValue))
@@ -34020,7 +34306,7 @@ function allSettled(promises) {
34020
34306
  reason
34021
34307
  }))));
34022
34308
  }
34023
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/eventemitter.mjs
34309
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/eventemitter.mjs
34024
34310
  class SimpleEventEmitter {
34025
34311
  constructor() {
34026
34312
  this.events = {};
@@ -34042,7 +34328,7 @@ class SimpleEventEmitter {
34042
34328
  }
34043
34329
  }
34044
34330
 
34045
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
34331
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
34046
34332
  class PostHogFetchHttpError extends Error {
34047
34333
  constructor(response, reqByteLength) {
34048
34334
  super("HTTP error while fetching PostHog: status=" + response.status + ", reqByteLength=" + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.name = "PostHogFetchHttpError";
@@ -34757,7 +35043,7 @@ class PostHogCoreStateless {
34757
35043
  return this.shutdownPromise;
34758
35044
  }
34759
35045
  }
34760
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/index.mjs
35046
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/index.mjs
34761
35047
  var exports_error_tracking = {};
34762
35048
  __export(exports_error_tracking, {
34763
35049
  winjsStackLineParser: () => winjsStackLineParser,
@@ -34781,7 +35067,7 @@ __export(exports_error_tracking, {
34781
35067
  DOMExceptionCoercer: () => DOMExceptionCoercer
34782
35068
  });
34783
35069
 
34784
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
35070
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
34785
35071
  var parsedStackResults;
34786
35072
  var lastKeysCount;
34787
35073
  var cachedFilenameChunkIds;
@@ -34820,7 +35106,7 @@ function getFilenameToChunkIdMap(stackParser) {
34820
35106
  return cachedFilenameChunkIds;
34821
35107
  }
34822
35108
 
34823
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
35109
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
34824
35110
  var MAX_CAUSE_RECURSION = 4;
34825
35111
 
34826
35112
  class ErrorPropertiesBuilder {
@@ -34942,7 +35228,7 @@ class ErrorPropertiesBuilder {
34942
35228
  return context;
34943
35229
  }
34944
35230
  }
34945
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
35231
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
34946
35232
  var UNKNOWN_FUNCTION = "?";
34947
35233
  function createFrame(platform, filename, func, lineno, colno) {
34948
35234
  const frame = {
@@ -34958,7 +35244,7 @@ function createFrame(platform, filename, func, lineno, colno) {
34958
35244
  return frame;
34959
35245
  }
34960
35246
 
34961
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
35247
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
34962
35248
  var extractSafariExtensionDetails = (func, filename) => {
34963
35249
  const isSafariExtension = func.indexOf("safari-extension") !== -1;
34964
35250
  const isSafariWebExtension = func.indexOf("safari-web-extension") !== -1;
@@ -34971,7 +35257,7 @@ var extractSafariExtensionDetails = (func, filename) => {
34971
35257
  ];
34972
35258
  };
34973
35259
 
34974
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
35260
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
34975
35261
  var chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
34976
35262
  var chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
34977
35263
  var chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
@@ -34997,7 +35283,7 @@ var chromeStackLineParser = (line, platform) => {
34997
35283
  }
34998
35284
  };
34999
35285
 
35000
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
35286
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
35001
35287
  var geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
35002
35288
  var geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
35003
35289
  var geckoStackLineParser = (line, platform) => {
@@ -35020,14 +35306,14 @@ var geckoStackLineParser = (line, platform) => {
35020
35306
  }
35021
35307
  };
35022
35308
 
35023
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/winjs.mjs
35309
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/winjs.mjs
35024
35310
  var winjsRegex = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
35025
35311
  var winjsStackLineParser = (line, platform) => {
35026
35312
  const parts = winjsRegex.exec(line);
35027
35313
  return parts ? createFrame(platform, parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined) : undefined;
35028
35314
  };
35029
35315
 
35030
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/opera.mjs
35316
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/opera.mjs
35031
35317
  var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
35032
35318
  var opera10StackLineParser = (line, platform) => {
35033
35319
  const parts = opera10Regex.exec(line);
@@ -35039,7 +35325,7 @@ var opera11StackLineParser = (line, platform) => {
35039
35325
  return parts ? createFrame(platform, parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined;
35040
35326
  };
35041
35327
 
35042
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
35328
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
35043
35329
  var FILENAME_MATCH = /^\s*[-]{4,}$/;
35044
35330
  var FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
35045
35331
  var nodeStackLineParser = (line, platform) => {
@@ -35108,7 +35394,7 @@ function _parseIntOrUndefined(input) {
35108
35394
  return parseInt(input || "", 10) || undefined;
35109
35395
  }
35110
35396
 
35111
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
35397
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
35112
35398
  var WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
35113
35399
  var STACKTRACE_FRAME_LIMIT = 50;
35114
35400
  function reverseAndStripFrames(stack) {
@@ -35153,7 +35439,7 @@ function createStackParser(platform, ...parsers) {
35153
35439
  return reverseAndStripFrames(frames);
35154
35440
  };
35155
35441
  }
35156
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/dom-exception-coercer.mjs
35442
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/dom-exception-coercer.mjs
35157
35443
  class DOMExceptionCoercer {
35158
35444
  match(err) {
35159
35445
  return this.isDOMException(err) || this.isDOMError(err);
@@ -35183,7 +35469,7 @@ class DOMExceptionCoercer {
35183
35469
  return isBuiltin(err, "DOMError");
35184
35470
  }
35185
35471
  }
35186
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
35472
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
35187
35473
  class ErrorCoercer {
35188
35474
  match(err) {
35189
35475
  return isPlainError(err);
@@ -35210,7 +35496,7 @@ class ErrorCoercer {
35210
35496
  return err.stacktrace || err.stack || undefined;
35211
35497
  }
35212
35498
  }
35213
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/error-event-coercer.mjs
35499
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/error-event-coercer.mjs
35214
35500
  class ErrorEventCoercer {
35215
35501
  constructor() {}
35216
35502
  match(err) {
@@ -35228,7 +35514,7 @@ class ErrorEventCoercer {
35228
35514
  return exceptionLike;
35229
35515
  }
35230
35516
  }
35231
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
35517
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
35232
35518
  var ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
35233
35519
 
35234
35520
  class StringCoercer {
@@ -35258,7 +35544,7 @@ class StringCoercer {
35258
35544
  ];
35259
35545
  }
35260
35546
  }
35261
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/types.mjs
35547
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/types.mjs
35262
35548
  var severityLevels = [
35263
35549
  "fatal",
35264
35550
  "error",
@@ -35268,7 +35554,7 @@ var severityLevels = [
35268
35554
  "debug"
35269
35555
  ];
35270
35556
 
35271
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
35557
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
35272
35558
  function extractExceptionKeysForMessage(err, maxLength = 40) {
35273
35559
  const keys = Object.keys(err);
35274
35560
  keys.sort();
@@ -35285,7 +35571,7 @@ function extractExceptionKeysForMessage(err, maxLength = 40) {
35285
35571
  return "";
35286
35572
  }
35287
35573
 
35288
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
35574
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
35289
35575
  class ObjectCoercer {
35290
35576
  match(candidate) {
35291
35577
  return typeof candidate == "object" && candidate !== null;
@@ -35338,7 +35624,7 @@ class ObjectCoercer {
35338
35624
  }
35339
35625
  }
35340
35626
  }
35341
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
35627
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
35342
35628
  class EventCoercer {
35343
35629
  match(err) {
35344
35630
  return isEvent(err);
@@ -35353,7 +35639,7 @@ class EventCoercer {
35353
35639
  };
35354
35640
  }
35355
35641
  }
35356
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
35642
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
35357
35643
  class PrimitiveCoercer {
35358
35644
  match(candidate) {
35359
35645
  return isPrimitive(candidate);
@@ -35367,7 +35653,7 @@ class PrimitiveCoercer {
35367
35653
  };
35368
35654
  }
35369
35655
  }
35370
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/promise-rejection-event.mjs
35656
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/coercers/promise-rejection-event.mjs
35371
35657
  class PromiseRejectionEventCoercer {
35372
35658
  match(err) {
35373
35659
  return isBuiltin(err, "PromiseRejectionEvent") || this.isCustomEventWrappingRejection(err);
@@ -35403,7 +35689,7 @@ class PromiseRejectionEventCoercer {
35403
35689
  return error;
35404
35690
  }
35405
35691
  }
35406
- // ../../switchroom-sec-1417/node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/utils.mjs
35692
+ // ../node_modules/.bun/@posthog+core@1.25.2/node_modules/@posthog/core/dist/error-tracking/utils.mjs
35407
35693
  class ReduceableCache {
35408
35694
  constructor(_maxSize) {
35409
35695
  this._maxSize = _maxSize;
@@ -35428,7 +35714,7 @@ class ReduceableCache {
35428
35714
  }
35429
35715
  }
35430
35716
  }
35431
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
35717
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
35432
35718
  import { createReadStream } from "node:fs";
35433
35719
  import { createInterface } from "node:readline";
35434
35720
  var LRU_FILE_CONTENTS_CACHE = new exports_error_tracking.ReduceableCache(25);
@@ -35646,7 +35932,7 @@ function snipLine(line, colno) {
35646
35932
  return newLine;
35647
35933
  }
35648
35934
 
35649
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
35935
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
35650
35936
  function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
35651
35937
  let calledFatalError = false;
35652
35938
  return Object.assign((error) => {
@@ -35678,7 +35964,7 @@ function addUnhandledRejectionListener(captureFn) {
35678
35964
  }));
35679
35965
  }
35680
35966
 
35681
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
35967
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
35682
35968
  var SHUTDOWN_TIMEOUT = 2000;
35683
35969
 
35684
35970
  class ErrorTracking {
@@ -35747,10 +36033,10 @@ class ErrorTracking {
35747
36033
  }
35748
36034
  }
35749
36035
 
35750
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/version.mjs
36036
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/version.mjs
35751
36037
  var version = "5.29.2";
35752
36038
 
35753
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/types.mjs
36039
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/types.mjs
35754
36040
  var FeatureFlagError2 = {
35755
36041
  ERRORS_WHILE_COMPUTING: "errors_while_computing_flags",
35756
36042
  FLAG_MISSING: "flag_missing",
@@ -35758,7 +36044,7 @@ var FeatureFlagError2 = {
35758
36044
  UNKNOWN_ERROR: "unknown_error"
35759
36045
  };
35760
36046
 
35761
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
36047
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
35762
36048
  async function hashSHA1(text) {
35763
36049
  const subtle = globalThis.crypto?.subtle;
35764
36050
  if (!subtle)
@@ -35768,7 +36054,7 @@ async function hashSHA1(text) {
35768
36054
  return hashArray.map((byte) => byte.toString(16).padStart(2, "0")).join("");
35769
36055
  }
35770
36056
 
35771
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
36057
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
35772
36058
  var SIXTY_SECONDS = 60000;
35773
36059
  var LONG_SCALE = 1152921504606847000;
35774
36060
  var NULL_VALUES_ALLOWED_OPERATORS = [
@@ -36642,7 +36928,7 @@ function relativeDateParseForFeatureFlagMatching(value) {
36642
36928
  }
36643
36929
  }
36644
36930
 
36645
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/storage-memory.mjs
36931
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/storage-memory.mjs
36646
36932
  class PostHogMemoryStorage {
36647
36933
  getProperty(key) {
36648
36934
  return this._memoryStorage[key];
@@ -36655,7 +36941,7 @@ class PostHogMemoryStorage {
36655
36941
  }
36656
36942
  }
36657
36943
 
36658
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/client.mjs
36944
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/client.mjs
36659
36945
  var MINIMUM_POLLING_INTERVAL = 100;
36660
36946
  var THIRTY_SECONDS = 30000;
36661
36947
  var MAX_CACHE_SIZE = 50000;
@@ -37443,7 +37729,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
37443
37729
  }
37444
37730
  }
37445
37731
 
37446
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/context/context.mjs
37732
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/context/context.mjs
37447
37733
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
37448
37734
 
37449
37735
  class PostHogContext {
@@ -37474,7 +37760,7 @@ class PostHogContext {
37474
37760
  }
37475
37761
  }
37476
37762
 
37477
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
37763
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
37478
37764
  var NAME = "posthog-node";
37479
37765
  function createEventProcessor(_posthog, { organization, projectId, prefix, severityAllowList = [
37480
37766
  "error"
@@ -37542,7 +37828,7 @@ class PostHogSentryIntegration {
37542
37828
  };
37543
37829
  }
37544
37830
  }
37545
- // ../../switchroom-sec-1417/node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/entrypoints/index.node.mjs
37831
+ // ../node_modules/.bun/posthog-node@5.29.2/node_modules/posthog-node/dist/entrypoints/index.node.mjs
37546
37832
  ErrorTracking.errorPropertiesBuilder = new exports_error_tracking.ErrorPropertiesBuilder([
37547
37833
  new exports_error_tracking.EventCoercer,
37548
37834
  new exports_error_tracking.ErrorCoercer,
@@ -38415,6 +38701,7 @@ function isSilentFlushMarker(text) {
38415
38701
  }
38416
38702
  return SILENT_MARKERS.has(trimmed.toUpperCase());
38417
38703
  }
38704
+ var TRIVIAL_CONFIRMATIONS = new Set(["SENT", "DONE", "OK", "OKAY", "ACK"]);
38418
38705
 
38419
38706
  // answer-stream.ts
38420
38707
  var MIN_INITIAL_CHARS = 50;
@@ -40383,15 +40670,11 @@ function renderOperatorEvent(ev) {
40383
40670
  text: [
40384
40671
  `\uD83D\uDCB3 <b>Credit balance too low</b> for <b>${agent}</b>.`,
40385
40672
  detail ? `<i>${detail}</i>` : "",
40386
- `Swap to another account slot or add a new one.`
40673
+ `Use <code>/auth use &lt;label&gt;</code> to switch account slot or <code>/auth add</code> to add one.`
40387
40674
  ].filter(Boolean).join(`
40388
40675
  `),
40389
40676
  keyboard: {
40390
40677
  inline_keyboard: [
40391
- [
40392
- { text: "\uD83D\uDD04 Swap slot", callback_data: `op:swap-slot:${encodeURIComponent(ev.agent)}` },
40393
- { text: "\u2795 Add slot", callback_data: `op:add-slot:${encodeURIComponent(ev.agent)}` }
40394
- ],
40395
40678
  [{ text: "\u23f3 Wait", callback_data: `op:dismiss:${encodeURIComponent(ev.agent)}` }]
40396
40679
  ]
40397
40680
  }
@@ -40401,15 +40684,11 @@ function renderOperatorEvent(ev) {
40401
40684
  text: [
40402
40685
  `\u26a0\ufe0f <b>Quota exhausted</b> for <b>${agent}</b>.`,
40403
40686
  detail ? `<i>${detail}</i>` : "",
40404
- `All account slots are at the usage limit. Switchroom will auto-fallback when another slot is available.`
40687
+ `All account slots are at the usage limit. Switchroom will auto-fallback when another slot is available. Use <code>/auth use &lt;label&gt;</code> to switch manually.`
40405
40688
  ].filter(Boolean).join(`
40406
40689
  `),
40407
40690
  keyboard: {
40408
40691
  inline_keyboard: [
40409
- [
40410
- { text: "\uD83D\uDD04 Swap slot", callback_data: `op:swap-slot:${encodeURIComponent(ev.agent)}` },
40411
- { text: "\u2795 Add slot", callback_data: `op:add-slot:${encodeURIComponent(ev.agent)}` }
40412
- ],
40413
40692
  [{ text: "\u23f3 Wait", callback_data: `op:dismiss:${encodeURIComponent(ev.agent)}` }]
40414
40693
  ]
40415
40694
  }
@@ -41707,6 +41986,27 @@ function isSilentFlushMarker2(text) {
41707
41986
  }
41708
41987
  return SILENT_MARKERS2.has(trimmed.toUpperCase());
41709
41988
  }
41989
+ var TRIVIAL_CONFIRMATIONS2 = new Set(["SENT", "DONE", "OK", "OKAY", "ACK"]);
41990
+ function isTrivialConfirmationLine(line) {
41991
+ let t = line.trim();
41992
+ if (t.length === 0 || t.length > 8)
41993
+ return false;
41994
+ if (/\W$/.test(t))
41995
+ t = t.slice(0, -1);
41996
+ return TRIVIAL_CONFIRMATIONS2.has(t.toUpperCase());
41997
+ }
41998
+ function isCompositeSilentNoise(text) {
41999
+ if (typeof text !== "string")
42000
+ return false;
42001
+ const lines = text.split(`
42002
+ `).map((l) => l.trim()).filter((l) => l.length > 0);
42003
+ if (lines.length === 0)
42004
+ return false;
42005
+ const hasMarker = lines.some((l) => isSilentFlushMarker2(l));
42006
+ if (!hasMarker)
42007
+ return false;
42008
+ return lines.every((l) => isSilentFlushMarker2(l) || isTrivialConfirmationLine(l));
42009
+ }
41710
42010
  function decideTurnFlush(input) {
41711
42011
  const flushEnabled = input.flushEnabled !== false;
41712
42012
  if (!flushEnabled)
@@ -41721,6 +42021,8 @@ function decideTurnFlush(input) {
41721
42021
  return { kind: "skip", reason: "empty-text" };
41722
42022
  if (isSilentFlushMarker2(joined))
41723
42023
  return { kind: "skip", reason: "silent-marker" };
42024
+ if (isCompositeSilentNoise(joined))
42025
+ return { kind: "skip", reason: "silent-marker" };
41724
42026
  return { kind: "flush", text: joined };
41725
42027
  }
41726
42028
  function isTurnFlushSafetyEnabled(env = process.env) {
@@ -48624,7 +48926,7 @@ function determineRestartReason(opts) {
48624
48926
  init_boot_card();
48625
48927
 
48626
48928
  // gateway/update-announce.ts
48627
- import { existsSync as existsSync26, mkdirSync as mkdirSync13, openSync as openSync3, closeSync as closeSync3, readFileSync as readFileSync25 } from "node:fs";
48929
+ import { existsSync as existsSync27, mkdirSync as mkdirSync14, openSync as openSync3, closeSync as closeSync3, readFileSync as readFileSync26 } from "node:fs";
48628
48930
  import { join as join24 } from "node:path";
48629
48931
  import { homedir as homedir10 } from "node:os";
48630
48932
 
@@ -48738,8 +49040,8 @@ function readAndFilter(raw, filters, limit) {
48738
49040
  var DEFAULT_LOOKBACK_MS = 10 * 60 * 1000;
48739
49041
  function readLastTerminalUpdateAudit(opts = {}) {
48740
49042
  const path = opts.auditLogPath ?? defaultAuditLogPath();
48741
- const exists = opts.exists ?? existsSync26;
48742
- const readFile = opts.readFile ?? ((p) => readFileSync25(p, "utf-8"));
49043
+ const exists = opts.exists ?? existsSync27;
49044
+ const readFile = opts.readFile ?? ((p) => readFileSync26(p, "utf-8"));
48743
49045
  if (!exists(path))
48744
49046
  return null;
48745
49047
  let raw;
@@ -48803,7 +49105,7 @@ function claimUpdateAnnouncement(requestId, opts = {}) {
48803
49105
  const stateDir = opts.stateDir ?? process.env.TELEGRAM_STATE_DIR ?? join24(homedir10(), ".switchroom");
48804
49106
  const dir = join24(stateDir, "update-announced");
48805
49107
  try {
48806
- mkdirSync13(dir, { recursive: true });
49108
+ mkdirSync14(dir, { recursive: true });
48807
49109
  } catch {
48808
49110
  return false;
48809
49111
  }
@@ -48827,7 +49129,7 @@ function maybeRenderUpdateAnnouncement(opts = {}) {
48827
49129
  }
48828
49130
 
48829
49131
  // issues-card.ts
48830
- import { readFileSync as readFileSync26, writeFileSync as writeFileSync15 } from "node:fs";
49132
+ import { readFileSync as readFileSync27, writeFileSync as writeFileSync16 } from "node:fs";
48831
49133
  var SEVERITY_EMOJI = {
48832
49134
  info: "\u2139\ufe0f",
48833
49135
  warn: "\u26a0\ufe0f",
@@ -48919,7 +49221,7 @@ function extractRetryAfterSecs(err) {
48919
49221
  var COOLDOWN_JITTER_MS = 500;
48920
49222
  function readPersistedMessageId(path, log) {
48921
49223
  try {
48922
- const raw = readFileSync26(path, "utf8");
49224
+ const raw = readFileSync27(path, "utf8");
48923
49225
  const parsed = JSON.parse(raw);
48924
49226
  const v = parsed.messageId;
48925
49227
  if (typeof v === "number" && Number.isInteger(v) && v > 0)
@@ -48935,7 +49237,7 @@ function readPersistedMessageId(path, log) {
48935
49237
  }
48936
49238
  function writePersistedMessageId(path, messageId, log) {
48937
49239
  try {
48938
- writeFileSync15(path, JSON.stringify({ messageId }) + `
49240
+ writeFileSync16(path, JSON.stringify({ messageId }) + `
48939
49241
  `, { mode: 384 });
48940
49242
  } catch (err) {
48941
49243
  log(`issues-card: persist write failed (${err.message})`);
@@ -49028,21 +49330,21 @@ function createIssuesCardHandle(opts) {
49028
49330
  }
49029
49331
 
49030
49332
  // issues-watcher.ts
49031
- import { existsSync as existsSync28, statSync as statSync8 } from "node:fs";
49333
+ import { existsSync as existsSync29, statSync as statSync8 } from "node:fs";
49032
49334
  import { join as join26 } from "node:path";
49033
49335
 
49034
49336
  // ../src/issues/store.ts
49035
49337
  import {
49036
49338
  closeSync as closeSync4,
49037
- existsSync as existsSync27,
49038
- mkdirSync as mkdirSync14,
49339
+ existsSync as existsSync28,
49340
+ mkdirSync as mkdirSync15,
49039
49341
  openSync as openSync4,
49040
49342
  readdirSync as readdirSync5,
49041
- readFileSync as readFileSync27,
49042
- renameSync as renameSync10,
49343
+ readFileSync as readFileSync28,
49344
+ renameSync as renameSync11,
49043
49345
  statSync as statSync7,
49044
49346
  unlinkSync as unlinkSync10,
49045
- writeFileSync as writeFileSync16,
49347
+ writeFileSync as writeFileSync17,
49046
49348
  writeSync
49047
49349
  } from "node:fs";
49048
49350
  import { join as join25 } from "node:path";
@@ -49062,11 +49364,11 @@ var ISSUES_FILE = "issues.jsonl";
49062
49364
  var ISSUES_LOCK = "issues.lock";
49063
49365
  function readAll(stateDir) {
49064
49366
  const path = join25(stateDir, ISSUES_FILE);
49065
- if (!existsSync27(path))
49367
+ if (!existsSync28(path))
49066
49368
  return [];
49067
49369
  let raw;
49068
49370
  try {
49069
- raw = readFileSync27(path, "utf-8");
49371
+ raw = readFileSync28(path, "utf-8");
49070
49372
  } catch {
49071
49373
  return [];
49072
49374
  }
@@ -49098,7 +49400,7 @@ function list(stateDir, opts = {}) {
49098
49400
  });
49099
49401
  }
49100
49402
  function resolve6(stateDir, fingerprint, nowFn = Date.now) {
49101
- if (!existsSync27(join25(stateDir, ISSUES_FILE)))
49403
+ if (!existsSync28(join25(stateDir, ISSUES_FILE)))
49102
49404
  return 0;
49103
49405
  return withLock(stateDir, () => {
49104
49406
  const all = readAll(stateDir);
@@ -49122,8 +49424,8 @@ function writeAll(stateDir, events) {
49122
49424
  const body = events.length === 0 ? "" : events.map((e) => JSON.stringify(e)).join(`
49123
49425
  `) + `
49124
49426
  `;
49125
- writeFileSync16(tmp, body, "utf-8");
49126
- renameSync10(tmp, path);
49427
+ writeFileSync17(tmp, body, "utf-8");
49428
+ renameSync11(tmp, path);
49127
49429
  }
49128
49430
  var ORPHAN_TMP_TTL_MS = 60000;
49129
49431
  var TMP_PREFIX = `${ISSUES_FILE}.tmp-`;
@@ -49185,7 +49487,7 @@ function withLock(stateDir, fn) {
49185
49487
  function tryStealStaleLock(lockPath) {
49186
49488
  let pidStr;
49187
49489
  try {
49188
- pidStr = readFileSync27(lockPath, "utf-8").trim();
49490
+ pidStr = readFileSync28(lockPath, "utf-8").trim();
49189
49491
  } catch {
49190
49492
  return true;
49191
49493
  }
@@ -49283,7 +49585,7 @@ function startIssuesWatcher(opts) {
49283
49585
  };
49284
49586
  }
49285
49587
  function defaultSignatureProvider(path) {
49286
- if (!existsSync28(path))
49588
+ if (!existsSync29(path))
49287
49589
  return null;
49288
49590
  try {
49289
49591
  const stat = statSync8(path);
@@ -49523,7 +49825,7 @@ function skillBasenameFromPath2(input) {
49523
49825
  }
49524
49826
 
49525
49827
  // credits-watch.ts
49526
- import { readFileSync as readFileSync28, writeFileSync as writeFileSync17, existsSync as existsSync29, mkdirSync as mkdirSync15 } from "fs";
49828
+ import { readFileSync as readFileSync29, writeFileSync as writeFileSync18, existsSync as existsSync30, mkdirSync as mkdirSync16 } from "fs";
49527
49829
  import { join as join27 } from "path";
49528
49830
  var STATE_FILE = "credits-watch.json";
49529
49831
  var FATAL_REASONS = new Set([
@@ -49537,11 +49839,11 @@ function emptyCreditState() {
49537
49839
  }
49538
49840
  function readClaudeJsonOverage(claudeConfigDir) {
49539
49841
  const path = join27(claudeConfigDir, ".claude.json");
49540
- if (!existsSync29(path))
49842
+ if (!existsSync30(path))
49541
49843
  return null;
49542
49844
  let raw;
49543
49845
  try {
49544
- raw = readFileSync28(path, "utf-8");
49846
+ raw = readFileSync29(path, "utf-8");
49545
49847
  } catch {
49546
49848
  return null;
49547
49849
  }
@@ -49622,10 +49924,10 @@ function escapeHtml10(s) {
49622
49924
  }
49623
49925
  function loadCreditState(stateDir) {
49624
49926
  const path = join27(stateDir, STATE_FILE);
49625
- if (!existsSync29(path))
49927
+ if (!existsSync30(path))
49626
49928
  return emptyCreditState();
49627
49929
  try {
49628
- const raw = readFileSync28(path, "utf-8");
49930
+ const raw = readFileSync29(path, "utf-8");
49629
49931
  const parsed = JSON.parse(raw);
49630
49932
  if (parsed && typeof parsed === "object" && (parsed.lastNotifiedReason === null || typeof parsed.lastNotifiedReason === "string") && typeof parsed.lastNotifiedAt === "number" && Number.isFinite(parsed.lastNotifiedAt)) {
49631
49933
  return {
@@ -49637,36 +49939,161 @@ function loadCreditState(stateDir) {
49637
49939
  return emptyCreditState();
49638
49940
  }
49639
49941
  function saveCreditState(stateDir, state4) {
49640
- mkdirSync15(stateDir, { recursive: true });
49942
+ mkdirSync16(stateDir, { recursive: true });
49641
49943
  const path = join27(stateDir, STATE_FILE);
49642
- writeFileSync17(path, JSON.stringify(state4, null, 2) + `
49944
+ writeFileSync18(path, JSON.stringify(state4, null, 2) + `
49643
49945
  `, { mode: 384 });
49644
49946
  }
49645
49947
 
49948
+ // quota-watch.ts
49949
+ import { readFileSync as readFileSync30, writeFileSync as writeFileSync19, existsSync as existsSync31, mkdirSync as mkdirSync17 } from "fs";
49950
+ import { join as join28 } from "path";
49951
+ var STATE_FILE2 = "quota-watch.json";
49952
+ function emptyQuotaWatchState() {
49953
+ return {};
49954
+ }
49955
+ function emptyAccountState() {
49956
+ return { lastNotifiedHealth: null, lastNotifiedAt: 0 };
49957
+ }
49958
+ function evaluateQuotaWatchAccount(args) {
49959
+ const { agentName: agentName3, snap, prev, now } = args;
49960
+ const label = snap.label;
49961
+ const currentHealth = classifyHealth(snap);
49962
+ if (currentHealth === "unknown" || currentHealth === "blocked") {
49963
+ return { kind: "skip", accountLabel: label, reason: `${currentHealth}-not-our-domain` };
49964
+ }
49965
+ const prevHealth = prev.lastNotifiedHealth ?? "healthy";
49966
+ if (currentHealth === prevHealth) {
49967
+ return { kind: "skip", accountLabel: label, reason: "steady-state" };
49968
+ }
49969
+ if (currentHealth === "throttling" && prevHealth === "healthy") {
49970
+ const newState = {
49971
+ lastNotifiedHealth: "throttling",
49972
+ lastNotifiedAt: now
49973
+ };
49974
+ return {
49975
+ kind: "notify",
49976
+ accountLabel: label,
49977
+ message: buildThrottlingMessage(agentName3, snap),
49978
+ newAccountState: newState,
49979
+ transition: "entered-throttling"
49980
+ };
49981
+ }
49982
+ if (currentHealth === "healthy" && prevHealth === "throttling") {
49983
+ const newState = {
49984
+ lastNotifiedHealth: "healthy",
49985
+ lastNotifiedAt: now
49986
+ };
49987
+ return {
49988
+ kind: "notify",
49989
+ accountLabel: label,
49990
+ message: buildRecoveryMessage(agentName3, snap),
49991
+ newAccountState: newState,
49992
+ transition: "recovered-to-healthy"
49993
+ };
49994
+ }
49995
+ return { kind: "skip", accountLabel: label, reason: "no-matching-transition" };
49996
+ }
49997
+ function buildThrottlingMessage(agentName3, snap) {
49998
+ const q = snap.quota;
49999
+ const fiveStr = fmtPct(q.fiveHourUtilizationPct);
50000
+ const sevenStr = fmtPct(q.sevenDayUtilizationPct);
50001
+ const max = Math.max(q.fiveHourUtilizationPct, q.sevenDayUtilizationPct);
50002
+ const win = max === q.fiveHourUtilizationPct ? "5h" : "7d";
50003
+ const winLabel = win === "5h" ? "5-hour" : "7-day";
50004
+ const resetAt = win === "5h" ? q.fiveHourResetAt : q.sevenDayResetAt;
50005
+ const resetStr = resetAt ? ` \u00b7 refills in ${formatRelative(resetAt, new Date)}` : "";
50006
+ const activeNote = snap.isActive ? "" : `
50007
+ This is a non-active account. Consider <code>/auth use ${escapeHtml11(snap.label)}</code> to switch, or keep it as a fallback reserve.`;
50008
+ const altNote = snap.isActive ? `
50009
+ Consider <code>/auth use &lt;other-account&gt;</code> if you have a healthier account, or wait for the ${winLabel} window to refill${resetStr}.` : "";
50010
+ return [
50011
+ `\uD83D\uDFE1 <b>Quota approaching limit</b> \u2014 <code>${escapeHtml11(snap.label)}</code>`,
50012
+ ``,
50013
+ `${fiveStr} of 5h \u00b7 ${sevenStr} of 7d`,
50014
+ `Binding window: ${winLabel}${resetStr}`,
50015
+ `${activeNote}${altNote}`,
50016
+ ``,
50017
+ `<i>Threshold: ${THROTTLING_THRESHOLD_PCT}% on either window. Source: broker quota cache.</i>`,
50018
+ `<i>Run /auth for full fleet status or /usage for the active account.</i>`
50019
+ ].join(`
50020
+ `).replace(/\n\n\n+/g, `
50021
+
50022
+ `).trim();
50023
+ }
50024
+ function buildRecoveryMessage(agentName3, snap) {
50025
+ const q = snap.quota;
50026
+ const utilLine = q ? `Current: ${fmtPct(q.fiveHourUtilizationPct)} of 5h \u00b7 ${fmtPct(q.sevenDayUtilizationPct)} of 7d` : "Current quota data unavailable.";
50027
+ return [
50028
+ `\uD83D\uDFE2 <b>Quota back in healthy range</b> \u2014 <code>${escapeHtml11(snap.label)}</code>`,
50029
+ ``,
50030
+ utilLine,
50031
+ ``,
50032
+ `<i>Below ${THROTTLING_THRESHOLD_PCT}% on both windows.</i>`
50033
+ ].join(`
50034
+ `);
50035
+ }
50036
+ function escapeHtml11(s) {
50037
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
50038
+ }
50039
+ function loadQuotaWatchState(stateDir) {
50040
+ const path = join28(stateDir, STATE_FILE2);
50041
+ if (!existsSync31(path))
50042
+ return emptyQuotaWatchState();
50043
+ try {
50044
+ const raw = readFileSync30(path, "utf-8");
50045
+ const parsed = JSON.parse(raw);
50046
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
50047
+ return emptyQuotaWatchState();
50048
+ }
50049
+ const result = {};
50050
+ for (const [key, val] of Object.entries(parsed)) {
50051
+ if (val && typeof val === "object" && !Array.isArray(val) && (val.lastNotifiedHealth === null || val.lastNotifiedHealth === "healthy" || val.lastNotifiedHealth === "throttling") && typeof val.lastNotifiedAt === "number" && Number.isFinite(val.lastNotifiedAt)) {
50052
+ result[key] = val;
50053
+ }
50054
+ }
50055
+ return result;
50056
+ } catch {
50057
+ return emptyQuotaWatchState();
50058
+ }
50059
+ }
50060
+ function saveQuotaWatchState(stateDir, state4) {
50061
+ mkdirSync17(stateDir, { recursive: true });
50062
+ const path = join28(stateDir, STATE_FILE2);
50063
+ writeFileSync19(path, JSON.stringify(state4, null, 2) + `
50064
+ `, { mode: 384 });
50065
+ }
50066
+ function patchQuotaWatchState(current, accountLabel, accountState) {
50067
+ return { ...current, [accountLabel]: accountState };
50068
+ }
50069
+
50070
+ // gateway/gateway.ts
50071
+ init_auth_snapshot_format();
50072
+
49646
50073
  // gateway/turn-active-marker.ts
49647
50074
  import {
49648
50075
  closeSync as closeSync5,
49649
- existsSync as existsSync30,
49650
- mkdirSync as mkdirSync16,
50076
+ existsSync as existsSync32,
50077
+ mkdirSync as mkdirSync18,
49651
50078
  openSync as openSync5,
49652
- readFileSync as readFileSync29,
50079
+ readFileSync as readFileSync31,
49653
50080
  statSync as statSync9,
49654
50081
  unlinkSync as unlinkSync11,
49655
50082
  utimesSync as utimesSync2,
49656
- writeFileSync as writeFileSync18
50083
+ writeFileSync as writeFileSync20
49657
50084
  } from "node:fs";
49658
- import { join as join28 } from "node:path";
50085
+ import { join as join29 } from "node:path";
49659
50086
  var TURN_ACTIVE_MARKER_FILE2 = "turn-active.json";
49660
50087
  function writeTurnActiveMarker(stateDir, marker) {
49661
50088
  try {
49662
- mkdirSync16(stateDir, { recursive: true });
49663
- writeFileSync18(join28(stateDir, TURN_ACTIVE_MARKER_FILE2), JSON.stringify(marker, null, 2) + `
50089
+ mkdirSync18(stateDir, { recursive: true });
50090
+ writeFileSync20(join29(stateDir, TURN_ACTIVE_MARKER_FILE2), JSON.stringify(marker, null, 2) + `
49664
50091
  `, { mode: 384 });
49665
50092
  } catch {}
49666
50093
  }
49667
50094
  function touchTurnActiveMarker2(stateDir) {
49668
- const path = join28(stateDir, TURN_ACTIVE_MARKER_FILE2);
49669
- if (!existsSync30(path))
50095
+ const path = join29(stateDir, TURN_ACTIVE_MARKER_FILE2);
50096
+ if (!existsSync32(path))
49670
50097
  return;
49671
50098
  const now = new Date;
49672
50099
  try {
@@ -49680,12 +50107,12 @@ function touchTurnActiveMarker2(stateDir) {
49680
50107
  }
49681
50108
  function removeTurnActiveMarker(stateDir) {
49682
50109
  try {
49683
- unlinkSync11(join28(stateDir, TURN_ACTIVE_MARKER_FILE2));
50110
+ unlinkSync11(join29(stateDir, TURN_ACTIVE_MARKER_FILE2));
49684
50111
  } catch {}
49685
50112
  }
49686
50113
  function sweepStaleTurnActiveMarker(stateDir, opts) {
49687
- const path = join28(stateDir, TURN_ACTIVE_MARKER_FILE2);
49688
- if (!existsSync30(path))
50114
+ const path = join29(stateDir, TURN_ACTIVE_MARKER_FILE2);
50115
+ if (!existsSync32(path))
49689
50116
  return false;
49690
50117
  const now = opts.now ?? Date.now();
49691
50118
  try {
@@ -49697,7 +50124,7 @@ function sweepStaleTurnActiveMarker(stateDir, opts) {
49697
50124
  return false;
49698
50125
  let payload = null;
49699
50126
  try {
49700
- payload = readFileSync29(path, "utf8");
50127
+ payload = readFileSync31(path, "utf8");
49701
50128
  } catch {}
49702
50129
  unlinkSync11(path);
49703
50130
  if (opts.onRemove) {
@@ -49716,10 +50143,10 @@ function sweepStaleTurnActiveMarker(stateDir, opts) {
49716
50143
  }
49717
50144
 
49718
50145
  // ../src/build-info.ts
49719
- var VERSION = "0.13.65";
49720
- var COMMIT_SHA = "51894764";
49721
- var COMMIT_DATE = "2026-05-28T05:00:08Z";
49722
- var LATEST_PR = 1950;
50146
+ var VERSION = "0.14.1";
50147
+ var COMMIT_SHA = "e51a8794";
50148
+ var COMMIT_DATE = "2026-05-28T07:24:12Z";
50149
+ var LATEST_PR = 1956;
49723
50150
  var COMMITS_AHEAD_OF_TAG = 0;
49724
50151
 
49725
50152
  // gateway/boot-version.ts
@@ -49793,11 +50220,11 @@ init_peercred();
49793
50220
  import * as net4 from "node:net";
49794
50221
  import * as fs2 from "node:fs";
49795
50222
  import { homedir as homedir11 } from "node:os";
49796
- import { join as join29 } from "node:path";
50223
+ import { join as join30 } from "node:path";
49797
50224
  var DEFAULT_TIMEOUT_MS4 = 2000;
49798
50225
  var UNLOCK_TIMEOUT_MS = 30000;
49799
- var LEGACY_SOCKET_PATH2 = join29(homedir11(), ".switchroom", "vault-broker.sock");
49800
- var OPERATOR_SOCKET_PATH2 = join29(homedir11(), ".switchroom", "broker-operator", "sock");
50226
+ var LEGACY_SOCKET_PATH2 = join30(homedir11(), ".switchroom", "vault-broker.sock");
50227
+ var OPERATOR_SOCKET_PATH2 = join30(homedir11(), ".switchroom", "broker-operator", "sock");
49801
50228
  function defaultBrokerSocketPath2() {
49802
50229
  if (fs2.existsSync(OPERATOR_SOCKET_PATH2))
49803
50230
  return OPERATOR_SOCKET_PATH2;
@@ -50019,8 +50446,8 @@ function resolveVaultApprovalPosture(broker) {
50019
50446
  }
50020
50447
 
50021
50448
  // registry/turns-schema.ts
50022
- import { chmodSync as chmodSync3, mkdirSync as mkdirSync17 } from "fs";
50023
- import { join as join30 } from "path";
50449
+ import { chmodSync as chmodSync3, mkdirSync as mkdirSync19 } from "fs";
50450
+ import { join as join31 } from "path";
50024
50451
  var DatabaseClass2 = null;
50025
50452
  function loadDatabaseClass2() {
50026
50453
  if (DatabaseClass2 != null)
@@ -50079,9 +50506,9 @@ function applySchema(db2) {
50079
50506
  }
50080
50507
  function openTurnsDb(agentDir) {
50081
50508
  const Database = loadDatabaseClass2();
50082
- const dir = join30(agentDir, "telegram");
50083
- mkdirSync17(dir, { recursive: true, mode: 448 });
50084
- const path = join30(dir, "registry.db");
50509
+ const dir = join31(agentDir, "telegram");
50510
+ mkdirSync19(dir, { recursive: true, mode: 448 });
50511
+ const path = join31(dir, "registry.db");
50085
50512
  const db2 = new Database(path, { create: true });
50086
50513
  applySchema(db2);
50087
50514
  try {
@@ -50222,11 +50649,11 @@ installGlobalErrorHandlers();
50222
50649
  process.on("beforeExit", () => {
50223
50650
  shutdownAnalytics();
50224
50651
  });
50225
- var STATE_DIR = process.env.TELEGRAM_STATE_DIR ?? join32(homedir12(), ".claude", "channels", "telegram");
50226
- var ACCESS_FILE = join32(STATE_DIR, "access.json");
50227
- var APPROVED_DIR = join32(STATE_DIR, "approved");
50228
- var ENV_FILE = join32(STATE_DIR, ".env");
50229
- var INBOX_DIR = join32(STATE_DIR, "inbox");
50652
+ var STATE_DIR = process.env.TELEGRAM_STATE_DIR ?? join33(homedir12(), ".claude", "channels", "telegram");
50653
+ var ACCESS_FILE = join33(STATE_DIR, "access.json");
50654
+ var APPROVED_DIR = join33(STATE_DIR, "approved");
50655
+ var ENV_FILE = join33(STATE_DIR, ".env");
50656
+ var INBOX_DIR = join33(STATE_DIR, "inbox");
50230
50657
  function triggerSelfRestart(targetAgent, reason, delayMs = 300) {
50231
50658
  const isDocker = process.env.SWITCHROOM_RUNTIME === "docker";
50232
50659
  const selfAgent = process.env.SWITCHROOM_AGENT_NAME;
@@ -50291,7 +50718,7 @@ function formatBootVersion() {
50291
50718
  }
50292
50719
  try {
50293
50720
  chmodSync5(ENV_FILE, 384);
50294
- for (const line of readFileSync32(ENV_FILE, "utf8").split(`
50721
+ for (const line of readFileSync34(ENV_FILE, "utf8").split(`
50295
50722
  `)) {
50296
50723
  const m = line.match(/^(\w+)=(.*)$/);
50297
50724
  if (m && process.env[m[1]] === undefined)
@@ -50344,7 +50771,7 @@ installTgPostLogger(bot);
50344
50771
  var _rawSendMessageDraft = bot.api.raw.sendMessageDraft;
50345
50772
  var GRAMMY_VERSION = (() => {
50346
50773
  try {
50347
- const raw = readFileSync32(new URL("../../node_modules/grammy/package.json", import.meta.url), "utf8");
50774
+ const raw = readFileSync34(new URL("../../node_modules/grammy/package.json", import.meta.url), "utf8");
50348
50775
  return JSON.parse(raw).version ?? "unknown";
50349
50776
  } catch {
50350
50777
  return "unknown";
@@ -50417,7 +50844,7 @@ function assertSendable(f) {
50417
50844
  } catch {
50418
50845
  throw new Error(`refusing to send file \u2014 cannot resolve real path: ${f}`);
50419
50846
  }
50420
- const inbox = join32(stateReal, "inbox");
50847
+ const inbox = join33(stateReal, "inbox");
50421
50848
  if (real.startsWith(stateReal + sep3) && !real.startsWith(inbox + sep3)) {
50422
50849
  throw new Error(`refusing to send channel state: ${f}`);
50423
50850
  }
@@ -50436,7 +50863,7 @@ function assertSendable(f) {
50436
50863
  }
50437
50864
  function readAccessFile() {
50438
50865
  try {
50439
- const raw = readFileSync32(ACCESS_FILE, "utf8");
50866
+ const raw = readFileSync34(ACCESS_FILE, "utf8");
50440
50867
  const parsed = JSON.parse(raw);
50441
50868
  const allowFrom = validateStringArray("allowFrom", parsed.allowFrom ?? []);
50442
50869
  const groups = {};
@@ -50470,7 +50897,7 @@ function readAccessFile() {
50470
50897
  if (err.code === "ENOENT")
50471
50898
  return defaultAccess();
50472
50899
  try {
50473
- renameSync12(ACCESS_FILE, `${ACCESS_FILE}.corrupt-${Date.now()}`);
50900
+ renameSync13(ACCESS_FILE, `${ACCESS_FILE}.corrupt-${Date.now()}`);
50474
50901
  } catch {}
50475
50902
  process.stderr.write(`telegram gateway: access.json is corrupt, moved aside. Starting fresh.
50476
50903
  `);
@@ -50501,11 +50928,11 @@ function assertAllowedChat(chat_id) {
50501
50928
  function saveAccess(a) {
50502
50929
  if (STATIC)
50503
50930
  return;
50504
- mkdirSync21(STATE_DIR, { recursive: true, mode: 448 });
50931
+ mkdirSync23(STATE_DIR, { recursive: true, mode: 448 });
50505
50932
  const tmp = ACCESS_FILE + ".tmp";
50506
- writeFileSync21(tmp, JSON.stringify(a, null, 2) + `
50933
+ writeFileSync23(tmp, JSON.stringify(a, null, 2) + `
50507
50934
  `, { mode: 384 });
50508
- renameSync12(tmp, ACCESS_FILE);
50935
+ renameSync13(tmp, ACCESS_FILE);
50509
50936
  }
50510
50937
  function pruneExpired(a) {
50511
50938
  const now = Date.now();
@@ -50523,7 +50950,7 @@ var HISTORY_ENABLED = HISTORY_ACCESS.historyEnabled !== false;
50523
50950
  if (HISTORY_ENABLED) {
50524
50951
  try {
50525
50952
  initHistory(STATE_DIR, HISTORY_ACCESS.historyRetentionDays ?? 30);
50526
- process.stderr.write(`telegram gateway: history capture enabled at ${join32(STATE_DIR, "history.db")}
50953
+ process.stderr.write(`telegram gateway: history capture enabled at ${join33(STATE_DIR, "history.db")}
50527
50954
  `);
50528
50955
  } catch (err) {
50529
50956
  process.stderr.write(`telegram gateway: history init failed (${err.message}) \u2014 capture disabled
@@ -50540,10 +50967,10 @@ try {
50540
50967
  process.stderr.write(`telegram gateway: turn-registry boot-reaper stamped ${reaped} orphaned turn(s) as ended_via='restart'
50541
50968
  `);
50542
50969
  } else {
50543
- process.stderr.write(`telegram gateway: turn-registry initialized at ${join32(agentDir, "telegram", "registry.db")}
50970
+ process.stderr.write(`telegram gateway: turn-registry initialized at ${join33(agentDir, "telegram", "registry.db")}
50544
50971
  `);
50545
50972
  }
50546
- const pendingEnvPath = join32(agentDir, ".pending-turn.env");
50973
+ const pendingEnvPath = join33(agentDir, ".pending-turn.env");
50547
50974
  try {
50548
50975
  const pending2 = findMostRecentInterruptedTurn(turnsDb);
50549
50976
  if (pending2 != null) {
@@ -50557,13 +50984,13 @@ try {
50557
50984
  `SWITCHROOM_PENDING_STARTED_AT=${pending2.started_at}`
50558
50985
  ];
50559
50986
  const pendingEnvTmp = `${pendingEnvPath}.tmp-${process.pid}`;
50560
- writeFileSync21(pendingEnvTmp, lines.join(`
50987
+ writeFileSync23(pendingEnvTmp, lines.join(`
50561
50988
  `) + `
50562
50989
  `, { mode: 384 });
50563
- renameSync12(pendingEnvTmp, pendingEnvPath);
50990
+ renameSync13(pendingEnvTmp, pendingEnvPath);
50564
50991
  process.stderr.write(`telegram gateway: pending-turn env written to ${pendingEnvPath} turnKey=${pending2.turn_key} endedVia=${pending2.ended_via ?? "open"}
50565
50992
  `);
50566
- } else if (existsSync34(pendingEnvPath)) {
50993
+ } else if (existsSync36(pendingEnvPath)) {
50567
50994
  rmSync4(pendingEnvPath, { force: true });
50568
50995
  process.stderr.write(`telegram gateway: pending-turn env cleared (clean previous shutdown)
50569
50996
  `);
@@ -50617,7 +51044,7 @@ function checkApprovals() {
50617
51044
  return;
50618
51045
  }
50619
51046
  for (const senderId of files) {
50620
- const file = join32(APPROVED_DIR, senderId);
51047
+ const file = join33(APPROVED_DIR, senderId);
50621
51048
  bot.api.sendMessage(senderId, "Paired! Say hi to Claude.").then(() => rmSync4(file, { force: true }), (err) => {
50622
51049
  process.stderr.write(`telegram gateway: failed to send approval confirm: ${err}
50623
51050
  `);
@@ -51501,11 +51928,11 @@ var unpinProgressCardForChat = null;
51501
51928
  var getPinnedProgressCardMessageId = null;
51502
51929
  var completeProgressCardTurn = null;
51503
51930
  var subagentWatcher = null;
51504
- var SOCKET_PATH = process.env.SWITCHROOM_GATEWAY_SOCKET ?? join32(STATE_DIR, "gateway.sock");
51505
- mkdirSync21(STATE_DIR, { recursive: true, mode: 448 });
51506
- var GATEWAY_PID_PATH = process.env.SWITCHROOM_GATEWAY_PID_FILE ?? join32(STATE_DIR, "gateway.pid.json");
51507
- var GATEWAY_SESSION_MARKER_PATH = process.env.SWITCHROOM_GATEWAY_SESSION_MARKER ?? join32(STATE_DIR, "gateway-session.json");
51508
- var GATEWAY_CLEAN_SHUTDOWN_MARKER_PATH = process.env.SWITCHROOM_GATEWAY_CLEAN_SHUTDOWN_MARKER ?? join32(STATE_DIR, "clean-shutdown.json");
51931
+ var SOCKET_PATH = process.env.SWITCHROOM_GATEWAY_SOCKET ?? join33(STATE_DIR, "gateway.sock");
51932
+ mkdirSync23(STATE_DIR, { recursive: true, mode: 448 });
51933
+ var GATEWAY_PID_PATH = process.env.SWITCHROOM_GATEWAY_PID_FILE ?? join33(STATE_DIR, "gateway.pid.json");
51934
+ var GATEWAY_SESSION_MARKER_PATH = process.env.SWITCHROOM_GATEWAY_SESSION_MARKER ?? join33(STATE_DIR, "gateway-session.json");
51935
+ var GATEWAY_CLEAN_SHUTDOWN_MARKER_PATH = process.env.SWITCHROOM_GATEWAY_CLEAN_SHUTDOWN_MARKER ?? join33(STATE_DIR, "clean-shutdown.json");
51509
51936
  var GATEWAY_STARTED_AT_MS = Date.now();
51510
51937
  var BOOT_CARD_ENABLED = process.env.SWITCHROOM_BOOT_CARD !== "false";
51511
51938
  var activeBootCard = null;
@@ -51534,7 +51961,7 @@ function ensureIssuesCard(chatId, threadId) {
51534
51961
  bot: botApi,
51535
51962
  log: (msg) => process.stderr.write(`telegram gateway: ${msg}
51536
51963
  `),
51537
- persistPath: join32(stateDir, "issues-card.json")
51964
+ persistPath: join33(stateDir, "issues-card.json")
51538
51965
  });
51539
51966
  activeIssuesWatcher = startIssuesWatcher({
51540
51967
  stateDir,
@@ -51703,13 +52130,13 @@ startTimer2({
51703
52130
  }
51704
52131
  });
51705
52132
  var inboundSpool = STATIC ? undefined : createInboundSpool({
51706
- path: join32(STATE_DIR, "inbound-spool.jsonl"),
52133
+ path: join33(STATE_DIR, "inbound-spool.jsonl"),
51707
52134
  fs: {
51708
52135
  appendFileSync: (p, d) => appendFileSync3(p, d),
51709
- readFileSync: (p) => readFileSync32(p, "utf8"),
51710
- writeFileSync: (p, d) => writeFileSync21(p, d),
51711
- renameSync: (a, b) => renameSync12(a, b),
51712
- existsSync: (p) => existsSync34(p),
52136
+ readFileSync: (p) => readFileSync34(p, "utf8"),
52137
+ writeFileSync: (p, d) => writeFileSync23(p, d),
52138
+ renameSync: (a, b) => renameSync13(a, b),
52139
+ existsSync: (p) => existsSync36(p),
51713
52140
  statSizeSync: (p) => statSync13(p).size
51714
52141
  }
51715
52142
  });
@@ -51822,11 +52249,12 @@ var ipcServer = createIpcServer({
51822
52249
  return;
51823
52250
  }
51824
52251
  })();
52252
+ const resolvedAgentDirForCard = agentDir ?? (process.env.TELEGRAM_STATE_DIR ? __require("path").dirname(process.env.TELEGRAM_STATE_DIR) : "/tmp");
51825
52253
  startBootCard(chatId, threadId, botApiForCard, {
51826
52254
  agentName: agentDisplayName,
51827
52255
  agentSlug,
51828
52256
  version: formatBootVersion(),
51829
- agentDir: agentDir ?? (process.env.TELEGRAM_STATE_DIR ? __require("path").dirname(process.env.TELEGRAM_STATE_DIR) : "/tmp"),
52257
+ agentDir: resolvedAgentDirForCard,
51830
52258
  gatewayInfo: { pid: process.pid, startedAtMs: GATEWAY_STARTED_AT_MS },
51831
52259
  restartReason: reason,
51832
52260
  restartAgeMs: markerAgeMs,
@@ -51835,6 +52263,7 @@ var ipcServer = createIpcServer({
51835
52263
  probeQuotaViaBroker: (t) => probeQuotaForBootCard(agentSlug, t),
51836
52264
  tmuxSupervisor: process.env.SWITCHROOM_TMUX_SUPERVISOR === "1",
51837
52265
  dockerMode: process.env.SWITCHROOM_RUNTIME === "docker",
52266
+ configSnapshotPath: join33(resolvedAgentDirForCard, ".config-snapshot.json"),
51838
52267
  ...updateOutcomeLine ? { updateOutcomeLine } : {}
51839
52268
  }, ackMsgId).then((handle) => {
51840
52269
  activeBootCard = handle;
@@ -53199,11 +53628,11 @@ async function executeSendGif(rawArgs) {
53199
53628
  };
53200
53629
  }
53201
53630
  async function publishToTelegraph(text, shortName, authorName) {
53202
- const accountPath = join32(STATE_DIR, "telegraph-account.json");
53631
+ const accountPath = join33(STATE_DIR, "telegraph-account.json");
53203
53632
  let account = null;
53204
53633
  try {
53205
- if (existsSync34(accountPath)) {
53206
- const raw = readFileSync32(accountPath, "utf-8");
53634
+ if (existsSync36(accountPath)) {
53635
+ const raw = readFileSync34(accountPath, "utf-8");
53207
53636
  const parsed = JSON.parse(raw);
53208
53637
  if (parsed.shortName && parsed.accessToken) {
53209
53638
  account = parsed;
@@ -53222,8 +53651,8 @@ async function publishToTelegraph(text, shortName, authorName) {
53222
53651
  }
53223
53652
  account = created.value;
53224
53653
  try {
53225
- mkdirSync21(STATE_DIR, { recursive: true, mode: 448 });
53226
- writeFileSync21(accountPath, JSON.stringify(account, null, 2), { mode: 384 });
53654
+ mkdirSync23(STATE_DIR, { recursive: true, mode: 448 });
53655
+ writeFileSync23(accountPath, JSON.stringify(account, null, 2), { mode: 384 });
53227
53656
  } catch (err) {
53228
53657
  process.stderr.write(`telegram gateway: telegraph cache write failed: ${err.message}
53229
53658
  `);
@@ -53465,9 +53894,9 @@ async function executeDownloadAttachment(args) {
53465
53894
  fileUniqueId: file.file_unique_id,
53466
53895
  now: Date.now()
53467
53896
  });
53468
- mkdirSync21(INBOX_DIR, { recursive: true, mode: 448 });
53897
+ mkdirSync23(INBOX_DIR, { recursive: true, mode: 448 });
53469
53898
  assertInsideInbox(INBOX_DIR, dlPath);
53470
- writeFileSync21(dlPath, buf, { mode: 384 });
53899
+ writeFileSync23(dlPath, buf, { mode: 384 });
53471
53900
  return { content: [{ type: "text", text: dlPath }] };
53472
53901
  }
53473
53902
  async function executeEditMessage(args) {
@@ -53694,7 +54123,7 @@ async function drainActivitySummary(turn) {
53694
54123
  const target = turn.activityPendingRender;
53695
54124
  if (target == null)
53696
54125
  break;
53697
- const html = `<i>${target}</i>`;
54126
+ const html = `<i>${escapeHtmlForTg(target)}</i>`;
53698
54127
  const chat = turn.sessionChatId;
53699
54128
  const thread = turn.sessionThreadId;
53700
54129
  const useDraft = turn.isDm && thread == null && sendMessageDraftFn != null;
@@ -53863,8 +54292,8 @@ function handleSessionEvent(ev) {
53863
54292
  clearActivitySummary(turn);
53864
54293
  }
53865
54294
  }
53866
- if (!DRAFT_MIRROR_ENABLED && !turn.replyCalled && !isTelegramSurfaceTool(name)) {
53867
- const rendered = registerAndRender(turn.toolActivity, name);
54295
+ if (!turn.replyCalled && !isTelegramSurfaceTool(name)) {
54296
+ const rendered = DRAFT_MIRROR_ENABLED ? describeToolUse(name, ev.input) : registerAndRender(turn.toolActivity, name);
53868
54297
  if (rendered != null) {
53869
54298
  turn.activityPendingRender = rendered;
53870
54299
  if (turn.activityInFlight == null) {
@@ -53891,7 +54320,7 @@ function handleSessionEvent(ev) {
53891
54320
  chatId: turn.sessionChatId,
53892
54321
  isPrivateChat: turn.isDm,
53893
54322
  threadId: turn.sessionThreadId,
53894
- ...DRAFT_MIRROR_ENABLED ? { sendMessageDraft: sendMessageDraftFn } : ANSWER_STREAM_VISIBLE_ENABLED ? { minInitialChars: 1 } : { sendMessageDraft: sendMessageDraftFn },
54323
+ ...ANSWER_STREAM_VISIBLE_ENABLED ? { minInitialChars: 1 } : { sendMessageDraft: sendMessageDraftFn },
53895
54324
  sendMessage: async (chatId, text, params) => {
53896
54325
  const tid = params?.message_thread_id;
53897
54326
  const silent = params?.purpose !== "materialize";
@@ -55239,14 +55668,14 @@ function restartMarkerPath() {
55239
55668
  const agentDir = resolveAgentDirFromEnv();
55240
55669
  if (!agentDir)
55241
55670
  return null;
55242
- return join32(agentDir, "restart-pending.json");
55671
+ return join33(agentDir, "restart-pending.json");
55243
55672
  }
55244
55673
  function writeRestartMarker(marker) {
55245
55674
  const p = restartMarkerPath();
55246
55675
  if (!p)
55247
55676
  return;
55248
55677
  try {
55249
- writeFileSync21(p, JSON.stringify(marker));
55678
+ writeFileSync23(p, JSON.stringify(marker));
55250
55679
  lastPlannedRestartAt = Date.now();
55251
55680
  process.stderr.write(`telegram gateway: restart-marker: write chat_id=${marker.chat_id} thread_id=${marker.thread_id ?? "-"} ack=${marker.ack_message_id ?? "-"} path=${p}
55252
55681
  `);
@@ -55265,7 +55694,7 @@ function readRestartMarker() {
55265
55694
  if (!p)
55266
55695
  return null;
55267
55696
  try {
55268
- return JSON.parse(readFileSync32(p, "utf8"));
55697
+ return JSON.parse(readFileSync34(p, "utf8"));
55269
55698
  } catch {
55270
55699
  return null;
55271
55700
  }
@@ -55363,7 +55792,7 @@ var _dockerReachable;
55363
55792
  function isDockerReachable() {
55364
55793
  if (_dockerReachable !== undefined)
55365
55794
  return _dockerReachable;
55366
- if (!existsSync34("/var/run/docker.sock")) {
55795
+ if (!existsSync36("/var/run/docker.sock")) {
55367
55796
  _dockerReachable = false;
55368
55797
  return _dockerReachable;
55369
55798
  }
@@ -55380,12 +55809,12 @@ function _resetDockerReachableCache() {
55380
55809
  }
55381
55810
  function spawnSwitchroomDetached(args, onFailure) {
55382
55811
  const fullArgs = SWITCHROOM_CONFIG ? ["--config", SWITCHROOM_CONFIG, ...args] : args;
55383
- const logPath = join32(STATE_DIR, "detached-spawn.log");
55812
+ const logPath = join33(STATE_DIR, "detached-spawn.log");
55384
55813
  let outFd = null;
55385
55814
  try {
55386
- mkdirSync21(STATE_DIR, { recursive: true });
55815
+ mkdirSync23(STATE_DIR, { recursive: true });
55387
55816
  outFd = openSync8(logPath, "a");
55388
- writeFileSync21(logPath, `
55817
+ writeFileSync23(logPath, `
55389
55818
  [${new Date().toISOString()}] spawn ${SWITCHROOM_CLI} ${fullArgs.join(" ")}
55390
55819
  `, { flag: "a" });
55391
55820
  } catch {}
@@ -55411,7 +55840,7 @@ function spawnSwitchroomDetached(args, onFailure) {
55411
55840
  return;
55412
55841
  let tail = "";
55413
55842
  try {
55414
- const full = readFileSync32(logPath, "utf8");
55843
+ const full = readFileSync34(logPath, "utf8");
55415
55844
  tail = full.split(`
55416
55845
  `).slice(-30).join(`
55417
55846
  `).trim();
@@ -55753,10 +56182,10 @@ bot.use(async (ctx, next) => {
55753
56182
  });
55754
56183
  function readRecentDenialsForAgent(agentName3, windowMs, limit) {
55755
56184
  try {
55756
- const auditPath = join32(homedir12(), ".switchroom", "vault-audit.log");
55757
- if (!existsSync34(auditPath))
56185
+ const auditPath = join33(homedir12(), ".switchroom", "vault-audit.log");
56186
+ if (!existsSync36(auditPath))
55758
56187
  return [];
55759
- const raw = readFileSync32(auditPath, "utf8");
56188
+ const raw = readFileSync34(auditPath, "utf8");
55760
56189
  return recentDenialsFromAuditLog(raw, { agentName: agentName3, windowMs, limit });
55761
56190
  } catch {
55762
56191
  return [];
@@ -55807,7 +56236,7 @@ async function buildAgentMetadata(agentName3) {
55807
56236
  try {
55808
56237
  const agentDir = resolveAgentDirFromEnv();
55809
56238
  if (agentDir) {
55810
- const raw = readFileSync32(join32(agentDir, ".claude", ".claude.json"), "utf8");
56239
+ const raw = readFileSync34(join33(agentDir, ".claude", ".claude.json"), "utf8");
55811
56240
  claudeJson = JSON.parse(raw);
55812
56241
  }
55813
56242
  } catch {}
@@ -56021,9 +56450,9 @@ bot.command("restart", async (ctx) => {
56021
56450
  function flushAgentHandoff(agentDir) {
56022
56451
  let removed = 0;
56023
56452
  for (const fname of [".handoff.md", ".handoff-topic"]) {
56024
- const p = join32(agentDir, fname);
56453
+ const p = join33(agentDir, fname);
56025
56454
  try {
56026
- if (existsSync34(p)) {
56455
+ if (existsSync36(p)) {
56027
56456
  unlinkSync14(p);
56028
56457
  removed++;
56029
56458
  }
@@ -56079,7 +56508,7 @@ async function handleNewOrResetCommand(ctx, kind) {
56079
56508
  writeRestartMarker({ chat_id: chatId, thread_id: threadId ?? null, ack_message_id: ackId, ts: Date.now() });
56080
56509
  if (agentDir != null) {
56081
56510
  try {
56082
- writeFileSync21(join32(agentDir, ".force-fresh-session"), `${kind} at ${new Date().toISOString()}
56511
+ writeFileSync23(join33(agentDir, ".force-fresh-session"), `${kind} at ${new Date().toISOString()}
56083
56512
  `, "utf8");
56084
56513
  } catch (err) {
56085
56514
  process.stderr.write(`telegram gateway: failed to write force-fresh marker: ${err}
@@ -56438,16 +56867,16 @@ bot.command("interrupt", async (ctx) => {
56438
56867
  await runSwitchroomCommand(ctx, ["agent", "interrupt", name], `interrupt ${name}`);
56439
56868
  });
56440
56869
  var lockoutOps = {
56441
- readFileSync: (p, enc) => readFileSync32(p, enc),
56442
- writeFileSync: (p, data, opts) => writeFileSync21(p, data, opts),
56443
- existsSync: (p) => existsSync34(p),
56444
- mkdirSync: (p, opts) => mkdirSync21(p, opts),
56445
- joinPath: (...parts) => join32(...parts)
56870
+ readFileSync: (p, enc) => readFileSync34(p, enc),
56871
+ writeFileSync: (p, data, opts) => writeFileSync23(p, data, opts),
56872
+ existsSync: (p) => existsSync36(p),
56873
+ mkdirSync: (p, opts) => mkdirSync23(p, opts),
56874
+ joinPath: (...parts) => join33(...parts)
56446
56875
  };
56447
56876
  var FLEET_FALLBACK_DEDUP_MS = 30000;
56448
56877
  function isAuthBrokerSocketReachable() {
56449
56878
  try {
56450
- return existsSync34(resolveAuthBrokerSocketPath2());
56879
+ return existsSync36(resolveAuthBrokerSocketPath2());
56451
56880
  } catch {
56452
56881
  return false;
56453
56882
  }
@@ -56508,7 +56937,7 @@ async function runCreditWatch() {
56508
56937
  if (!agentDir)
56509
56938
  return;
56510
56939
  const agentName3 = getMyAgentName();
56511
- const claudeConfigDir = join32(agentDir, ".claude");
56940
+ const claudeConfigDir = join33(agentDir, ".claude");
56512
56941
  const stateDir = STATE_DIR;
56513
56942
  const reason = readClaudeJsonOverage(claudeConfigDir);
56514
56943
  const prev = loadCreditState(stateDir);
@@ -56535,6 +56964,99 @@ async function runCreditWatch() {
56535
56964
  `);
56536
56965
  }
56537
56966
  }
56967
+ async function runQuotaWatch() {
56968
+ const agentName3 = getMyAgentName();
56969
+ const stateDir = STATE_DIR;
56970
+ const brokerClient = await getAuthBrokerClient(agentName3);
56971
+ if (!brokerClient) {
56972
+ process.stderr.write(`telegram gateway: quota-watch: broker client unavailable \u2014 skipping
56973
+ `);
56974
+ return;
56975
+ }
56976
+ let listStateData;
56977
+ try {
56978
+ listStateData = await brokerClient.listState();
56979
+ } catch (err) {
56980
+ process.stderr.write(`telegram gateway: quota-watch: listState failed: ${err}
56981
+ `);
56982
+ return;
56983
+ }
56984
+ if (!listStateData.accounts || listStateData.accounts.length === 0) {
56985
+ return;
56986
+ }
56987
+ const snapshots = buildSnapshotsFromCachedState(listStateData);
56988
+ let watchState = loadQuotaWatchState(stateDir);
56989
+ const now = Date.now();
56990
+ const access = loadAccess();
56991
+ const pendingTransitions = [];
56992
+ const labelToSnapIndex = new Map(snapshots.map((s, i) => [s.label, i]));
56993
+ for (const snap of snapshots) {
56994
+ const prev = watchState[snap.label] ?? emptyAccountState();
56995
+ const decision = evaluateQuotaWatchAccount({ agentName: agentName3, snap, prev, now });
56996
+ if (decision.kind !== "skip") {
56997
+ pendingTransitions.push({
56998
+ accountLabel: snap.label,
56999
+ snapIndex: labelToSnapIndex.get(snap.label) ?? -1,
57000
+ decision
57001
+ });
57002
+ }
57003
+ }
57004
+ if (pendingTransitions.length === 0) {
57005
+ return;
57006
+ }
57007
+ const crossingLabels = pendingTransitions.map((t) => t.accountLabel);
57008
+ let freshProbeMap = new Map;
57009
+ try {
57010
+ const probeData = await brokerClient.probeQuota(crossingLabels, 8000);
57011
+ for (const entry of probeData.results) {
57012
+ freshProbeMap.set(entry.label, entry.result);
57013
+ }
57014
+ } catch (err) {
57015
+ process.stderr.write(`telegram gateway: quota-watch: probe for crossing accounts failed: ${err}
57016
+ `);
57017
+ }
57018
+ let mutatedState = watchState;
57019
+ const notifications = [];
57020
+ for (const { accountLabel, snapIndex, decision } of pendingTransitions) {
57021
+ const freshResult = freshProbeMap.get(accountLabel);
57022
+ let enrichedDecision = decision;
57023
+ if (decision.kind !== "notify")
57024
+ continue;
57025
+ if (freshResult && freshResult.ok && snapIndex >= 0) {
57026
+ const enrichedSnap = { ...snapshots[snapIndex], quota: freshResult.data };
57027
+ const prev = watchState[accountLabel] ?? emptyAccountState();
57028
+ const re = evaluateQuotaWatchAccount({ agentName: agentName3, snap: enrichedSnap, prev, now });
57029
+ if (re.kind === "notify" && re.transition === decision.transition) {
57030
+ enrichedDecision = re;
57031
+ } else if (re.kind === "skip") {
57032
+ continue;
57033
+ }
57034
+ }
57035
+ if (enrichedDecision.kind !== "notify")
57036
+ continue;
57037
+ notifications.push({ message: enrichedDecision.message, accountLabel });
57038
+ mutatedState = patchQuotaWatchState(mutatedState, accountLabel, enrichedDecision.newAccountState);
57039
+ }
57040
+ if (notifications.length === 0) {
57041
+ return;
57042
+ }
57043
+ for (const { message, accountLabel } of notifications) {
57044
+ for (const chat_id of access.allowFrom) {
57045
+ await swallowingApiCall(() => bot.api.sendMessage(chat_id, message, {
57046
+ parse_mode: "HTML",
57047
+ link_preview_options: { is_disabled: true }
57048
+ }), { chat_id, verb: "quota-watch.notify" });
57049
+ }
57050
+ process.stderr.write(`telegram gateway: quota-watch: notified transition for account=${accountLabel}
57051
+ `);
57052
+ }
57053
+ try {
57054
+ saveQuotaWatchState(stateDir, mutatedState);
57055
+ } catch (err) {
57056
+ process.stderr.write(`telegram gateway: quota-watch state persist failed: ${err}
57057
+ `);
57058
+ }
57059
+ }
56538
57060
  bot.command("auth", async (ctx) => {
56539
57061
  const authSenderId = String(ctx.from?.id ?? "");
56540
57062
  const authOperatorPrivate = ctx.chat?.type === "private" && loadAccess().allowFrom.includes(authSenderId);
@@ -56718,10 +57240,10 @@ async function handleVaultRecentDenialCallback(ctx, data) {
56718
57240
  return;
56719
57241
  }
56720
57242
  const { token, id } = result;
56721
- const tokenPath = join32(homedir12(), ".switchroom", "agents", agentName3, ".vault-token");
57243
+ const tokenPath = join33(homedir12(), ".switchroom", "agents", agentName3, ".vault-token");
56722
57244
  try {
56723
- mkdirSync21(join32(homedir12(), ".switchroom", "agents", agentName3), { recursive: true });
56724
- writeFileSync21(tokenPath, token, { mode: 384 });
57245
+ mkdirSync23(join33(homedir12(), ".switchroom", "agents", agentName3), { recursive: true });
57246
+ writeFileSync23(tokenPath, token, { mode: 384 });
56725
57247
  } catch (err) {
56726
57248
  await switchroomReply(ctx, `<b>Grant created (${escapeHtmlForTg(id)}) but token write failed:</b> ${escapeHtmlForTg(String(err))}
56727
57249
  <i>Recover with: <code>switchroom vault grant ${escapeHtmlForTg(agentName3)} --keys ${escapeHtmlForTg(keyName)} --duration 30d</code> on the host.</i>`, { html: true });
@@ -56797,10 +57319,10 @@ async function performVaultAccessApproval(ctx, pending2, stageId, senderId, atte
56797
57319
  return;
56798
57320
  }
56799
57321
  const { token, id } = result;
56800
- const tokenPath = join32(homedir12(), ".switchroom", "agents", pending2.agent, ".vault-token");
57322
+ const tokenPath = join33(homedir12(), ".switchroom", "agents", pending2.agent, ".vault-token");
56801
57323
  try {
56802
- mkdirSync21(join32(homedir12(), ".switchroom", "agents", pending2.agent), { recursive: true });
56803
- writeFileSync21(tokenPath, token, { mode: 384 });
57324
+ mkdirSync23(join33(homedir12(), ".switchroom", "agents", pending2.agent), { recursive: true });
57325
+ writeFileSync23(tokenPath, token, { mode: 384 });
56804
57326
  } catch (err) {
56805
57327
  await switchroomReply(ctx, `<b>Grant created (${escapeHtmlForTg(id)}) but token write failed:</b> ${escapeHtmlForTg(String(err))}
56806
57328
  <i>Recover with: <code>switchroom vault grant ${escapeHtmlForTg(pending2.agent)} --keys ${escapeHtmlForTg(pending2.key)} --duration ${Math.round(pending2.ttl_seconds / 86400)}d</code> on the host.</i>`, { html: true });
@@ -57275,10 +57797,10 @@ async function executeGrantWizard(ctx, chatId, state4) {
57275
57797
  return;
57276
57798
  }
57277
57799
  const { token, id } = result;
57278
- const tokenPath = join32(homedir12(), ".switchroom", "agents", state4.agent, ".vault-token");
57800
+ const tokenPath = join33(homedir12(), ".switchroom", "agents", state4.agent, ".vault-token");
57279
57801
  try {
57280
- mkdirSync21(join32(homedir12(), ".switchroom", "agents", state4.agent), { recursive: true });
57281
- writeFileSync21(tokenPath, token, { mode: 384 });
57802
+ mkdirSync23(join33(homedir12(), ".switchroom", "agents", state4.agent), { recursive: true });
57803
+ writeFileSync23(tokenPath, token, { mode: 384 });
57282
57804
  } catch (err) {
57283
57805
  await switchroomReply(ctx, `<b>Grant created but token write failed:</b> ${escapeHtmlForTg(String(err))}`, { html: true });
57284
57806
  return;
@@ -57626,15 +58148,6 @@ async function handleOperatorEventCallback(ctx, data) {
57626
58148
  }
57627
58149
  return;
57628
58150
  }
57629
- case "swap-slot":
57630
- case "add-slot": {
57631
- await ctx.answerCallbackQuery({ text: "Phase 4c will wire this" }).catch(() => {});
57632
- const cmd = action === "swap-slot" ? `auth use ${agent} <slot-name>` : `auth add ${agent}`;
57633
- await ctx.reply(`Phase 4c will wire ${action} buttons. Until then, run in terminal: <code>switchroom ${cmd}</code>`, {
57634
- parse_mode: "HTML"
57635
- });
57636
- return;
57637
- }
57638
58151
  default: {
57639
58152
  await ctx.answerCallbackQuery({ text: `Unknown action: ${action}` }).catch(() => {});
57640
58153
  return;
@@ -57718,8 +58231,8 @@ async function handleAuthDashboardCallback(ctx) {
57718
58231
  return hit?.result ?? { ok: false, reason: "broker returned no result for account" };
57719
58232
  });
57720
58233
  const tz = process.env.SWITCHROOM_TIMEZONE ?? process.env.TZ ?? "UTC";
57721
- const { renderAuthSnapshotFormat2: renderAuthSnapshotFormat23, buildSnapshotsFromState: buildSnapshotsFromState3, buildSnapshotKeyboard: buildSnapshotKeyboard3 } = await Promise.resolve().then(() => (init_auth_snapshot_format(), exports_auth_snapshot_format));
57722
- const snapshots = buildSnapshotsFromState3(state4, quotas);
58234
+ const { renderAuthSnapshotFormat2: renderAuthSnapshotFormat23, buildSnapshotsFromState: buildSnapshotsFromState4, buildSnapshotKeyboard: buildSnapshotKeyboard3 } = await Promise.resolve().then(() => (init_auth_snapshot_format(), exports_auth_snapshot_format));
58235
+ const snapshots = buildSnapshotsFromState4(state4, quotas);
57723
58236
  const text = renderAuthSnapshotFormat23(snapshots, {
57724
58237
  tz,
57725
58238
  now: new Date,
@@ -58114,9 +58627,9 @@ bot.command("usage", async (ctx) => {
58114
58627
  const hit = probeResp.results.find((r) => r.label === a.label);
58115
58628
  return hit?.result ?? { ok: false, reason: "broker returned no result for account" };
58116
58629
  });
58117
- const { renderAuthSnapshotFormat2: renderAuthSnapshotFormat23, buildSnapshotsFromState: buildSnapshotsFromState3 } = await Promise.resolve().then(() => (init_auth_snapshot_format(), exports_auth_snapshot_format));
58630
+ const { renderAuthSnapshotFormat2: renderAuthSnapshotFormat23, buildSnapshotsFromState: buildSnapshotsFromState4 } = await Promise.resolve().then(() => (init_auth_snapshot_format(), exports_auth_snapshot_format));
58118
58631
  const tz = process.env.SWITCHROOM_TIMEZONE ?? process.env.TZ ?? "UTC";
58119
- const snapshots = buildSnapshotsFromState3(state4, quotas);
58632
+ const snapshots = buildSnapshotsFromState4(state4, quotas);
58120
58633
  const text = renderAuthSnapshotFormat23(snapshots, {
58121
58634
  tz,
58122
58635
  now: new Date,
@@ -58135,7 +58648,7 @@ bot.command("usage", async (ctx) => {
58135
58648
  await switchroomReply(ctx, "<b>/usage:</b> cannot resolve agent dir.", { html: true });
58136
58649
  return;
58137
58650
  }
58138
- const result = await fetchQuota2({ claudeConfigDir: join32(agentDir, ".claude") });
58651
+ const result = await fetchQuota2({ claudeConfigDir: join33(agentDir, ".claude") });
58139
58652
  if (!result.ok) {
58140
58653
  await switchroomReply(ctx, `<b>/usage:</b> ${escapeHtmlForTg(result.reason)}`, { html: true });
58141
58654
  return;
@@ -58638,9 +59151,9 @@ bot.on("message:photo", async (ctx) => {
58638
59151
  fileUniqueId: best.file_unique_id,
58639
59152
  now: Date.now()
58640
59153
  });
58641
- mkdirSync21(INBOX_DIR, { recursive: true, mode: 448 });
59154
+ mkdirSync23(INBOX_DIR, { recursive: true, mode: 448 });
58642
59155
  assertInsideInbox(INBOX_DIR, dlPath);
58643
- writeFileSync21(dlPath, buf, { mode: 384 });
59156
+ writeFileSync23(dlPath, buf, { mode: 384 });
58644
59157
  return dlPath;
58645
59158
  } catch (err) {
58646
59159
  const msg = err instanceof Error ? err.message : "unknown error";
@@ -58680,8 +59193,8 @@ async function maybeTranscribeVoice(fileId, mimeType, language) {
58680
59193
  let apiKey = null;
58681
59194
  try {
58682
59195
  const path = __require("path").join(__require("os").homedir(), ".switchroom", "openai-api-key");
58683
- if (existsSync34(path)) {
58684
- apiKey = readFileSync32(path, "utf-8").trim();
59196
+ if (existsSync36(path)) {
59197
+ apiKey = readFileSync34(path, "utf-8").trim();
58685
59198
  }
58686
59199
  } catch (err) {
58687
59200
  process.stderr.write(`telegram gateway: voice-in: failed to read api key: ${err.message}
@@ -59537,11 +60050,12 @@ var didOneTimeSetup = false;
59537
60050
  return;
59538
60051
  }
59539
60052
  })();
60053
+ const resolvedAgentDirForBootCard = agentDir ?? join33(homedir12(), ".switchroom", "agents", agentSlug);
59540
60054
  const handle = await startBootCard(chatId, threadId, botApiForCard, {
59541
60055
  agentName: agentDisplayName,
59542
60056
  agentSlug,
59543
60057
  version: formatBootVersion(),
59544
- agentDir: agentDir ?? join32(homedir12(), ".switchroom", "agents", agentSlug),
60058
+ agentDir: resolvedAgentDirForBootCard,
59545
60059
  gatewayInfo: { pid: process.pid, startedAtMs: GATEWAY_STARTED_AT_MS },
59546
60060
  restartReason: reason,
59547
60061
  restartAgeMs: markerAgeMs,
@@ -59550,6 +60064,7 @@ var didOneTimeSetup = false;
59550
60064
  probeQuotaViaBroker: (t) => probeQuotaForBootCard(agentSlug, t),
59551
60065
  tmuxSupervisor: process.env.SWITCHROOM_TMUX_SUPERVISOR === "1",
59552
60066
  dockerMode: process.env.SWITCHROOM_RUNTIME === "docker",
60067
+ configSnapshotPath: join33(resolvedAgentDirForBootCard, ".config-snapshot.json"),
59553
60068
  ...updateOutcomeLine ? { updateOutcomeLine } : {}
59554
60069
  }, ackMsgId);
59555
60070
  activeBootCard = handle;
@@ -59589,6 +60104,21 @@ var didOneTimeSetup = false;
59589
60104
  });
59590
60105
  }, CREDIT_WATCH_POLL_MS).unref();
59591
60106
  }
60107
+ const QUOTA_WATCH_POLL_MS = Number(process.env.SWITCHROOM_QUOTA_WATCH_POLL_MS ?? 900000);
60108
+ if (QUOTA_WATCH_POLL_MS > 0) {
60109
+ setTimeout(() => {
60110
+ runQuotaWatch().catch((err) => {
60111
+ process.stderr.write(`telegram gateway: quota-watch initial run failed: ${err}
60112
+ `);
60113
+ });
60114
+ }, 30000);
60115
+ setInterval(() => {
60116
+ runQuotaWatch().catch((err) => {
60117
+ process.stderr.write(`telegram gateway: quota-watch scheduled run failed: ${err}
60118
+ `);
60119
+ });
60120
+ }, QUOTA_WATCH_POLL_MS).unref();
60121
+ }
59592
60122
  const RESTART_WATCHDOG_POLL_MS = Number(process.env.SWITCHROOM_RESTART_WATCHDOG_POLL_MS ?? 30000);
59593
60123
  const watchdogAgentName = process.env.SWITCHROOM_AGENT_NAME;
59594
60124
  const watchdogDockerMode = process.env.SWITCHROOM_RUNTIME === "docker";