@rubytech/create-maxy-code 0.1.475 → 0.1.476

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 (80) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/storage-broker/dist/cf-exec.d.ts.map +1 -1
  3. package/payload/platform/lib/storage-broker/dist/cf-exec.js +3 -2
  4. package/payload/platform/lib/storage-broker/dist/cf-exec.js.map +1 -1
  5. package/payload/platform/lib/storage-broker/src/cf-exec.ts +3 -2
  6. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +3 -3
  7. package/payload/platform/plugins/cloudflare/skills/calendar-site/template/schema.sql +13 -3
  8. package/payload/platform/plugins/docs/references/calendar-booking.md +2 -2
  9. package/payload/platform/plugins/scheduling/PLUGIN.md +2 -2
  10. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-reconcile.test.js +158 -23
  11. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-reconcile.test.js.map +1 -1
  12. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-schema-migration.test.d.ts +2 -0
  13. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-schema-migration.test.d.ts.map +1 -0
  14. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-schema-migration.test.js +200 -0
  15. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-schema-migration.test.js.map +1 -0
  16. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-sync-provision.test.d.ts +2 -0
  17. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-sync-provision.test.d.ts.map +1 -0
  18. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-sync-provision.test.js +309 -0
  19. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-sync-provision.test.js.map +1 -0
  20. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/d1-command.test.js +219 -19
  21. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/d1-command.test.js.map +1 -1
  22. package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.d.ts +94 -11
  23. package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.d.ts.map +1 -1
  24. package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.js +106 -22
  25. package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.js.map +1 -1
  26. package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-sync-provision.d.ts +109 -0
  27. package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-sync-provision.d.ts.map +1 -0
  28. package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-sync-provision.js +213 -0
  29. package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-sync-provision.js.map +1 -0
  30. package/payload/platform/plugins/scheduling/mcp/dist/lib/d1-command.d.ts +80 -8
  31. package/payload/platform/plugins/scheduling/mcp/dist/lib/d1-command.d.ts.map +1 -1
  32. package/payload/platform/plugins/scheduling/mcp/dist/lib/d1-command.js +202 -8
  33. package/payload/platform/plugins/scheduling/mcp/dist/lib/d1-command.js.map +1 -1
  34. package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.d.ts +6 -4
  35. package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.d.ts.map +1 -1
  36. package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.js +334 -142
  37. package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.js.map +1 -1
  38. package/payload/server/{chunk-Y6V45R6M.js → chunk-LBCMFD4O.js} +173 -29
  39. package/payload/server/maxy-edge.js +1 -1
  40. package/payload/server/public/activity.html +6 -6
  41. package/payload/server/public/assets/{AdminLoginScreens-B44KbEuC.js → AdminLoginScreens-DximwPlS.js} +1 -1
  42. package/payload/server/public/assets/{AdminShell-BjxV2qkb.js → AdminShell-BehbH-Oa.js} +1 -1
  43. package/payload/server/public/assets/{Checkbox-DSeZNGNA.js → Checkbox-DM-eHqOS.js} +1 -1
  44. package/payload/server/public/assets/activity-hDwUeQd6.js +1 -0
  45. package/payload/server/public/assets/{admin-B4LpTCur.js → admin-CAkDnGdk.js} +1 -1
  46. package/payload/server/public/assets/{browser-CEFvaWwI.js → browser-DXl8hOoi.js} +1 -1
  47. package/payload/server/public/assets/{calendar-B3zo6V34.js → calendar-DP6hn4-6.js} +1 -1
  48. package/payload/server/public/assets/chat-DhOfVGYM.js +1 -0
  49. package/payload/server/public/assets/chevron-left-DYNBoLii.js +1 -0
  50. package/payload/server/public/assets/data-bq8fTo_s.js +1 -0
  51. package/payload/server/public/assets/{graph-RaOrnSf2.js → graph-CHcYoEJ5.js} +1 -1
  52. package/payload/server/public/assets/{graph-labels-GlTEIYJj.js → graph-labels-CZykslZM.js} +1 -1
  53. package/payload/server/public/assets/{maximize-2-CHDa8p5h.js → maximize-2-31AZEcMS.js} +1 -1
  54. package/payload/server/public/assets/{operator-DtqHY4jV.js → operator-BGGpdsO_.js} +1 -1
  55. package/payload/server/public/assets/{page-CkhFj8GQ.js → page-BloC6ygA.js} +1 -1
  56. package/payload/server/public/assets/{page-DxnWgPtd.js → page-DOeiiqbR.js} +1 -1
  57. package/payload/server/public/assets/{public-D5TUfQ3I.js → public-CGgO6IZv.js} +1 -1
  58. package/payload/server/public/assets/{rotate-ccw-BJjVAQQY.js → rotate-ccw-BlAi6iFg.js} +1 -1
  59. package/payload/server/public/assets/{tasks-CM9pYYG1.js → tasks-C1giFRRL.js} +1 -1
  60. package/payload/server/public/assets/{time-entry-format-C5RYEYjM.js → time-entry-format-CiUUQdq7.js} +1 -1
  61. package/payload/server/public/assets/{triangle-alert-DLfIsuo_.js → triangle-alert-CVqKuLoa.js} +1 -1
  62. package/payload/server/public/assets/{useCopyFeedback-7yKeiAzV.js → useCopyFeedback-ksyUe_g1.js} +1 -1
  63. package/payload/server/public/assets/{useSelectionMode-CWlh6AEq.js → useSelectionMode-BPrBkdTd.js} +1 -1
  64. package/payload/server/public/assets/{useSubAccountSwitcher-B2n9QPVI.css → useSubAccountSwitcher-K4kYeN6i.css} +1 -1
  65. package/payload/server/public/assets/{useVoiceRecorder-j3ZArZ2H.js → useVoiceRecorder-CTXP8oTW.js} +1 -1
  66. package/payload/server/public/browser.html +5 -5
  67. package/payload/server/public/calendar.html +6 -6
  68. package/payload/server/public/chat.html +12 -12
  69. package/payload/server/public/data.html +11 -11
  70. package/payload/server/public/graph.html +11 -11
  71. package/payload/server/public/index.html +14 -14
  72. package/payload/server/public/operator.html +14 -14
  73. package/payload/server/public/public.html +12 -12
  74. package/payload/server/public/tasks.html +5 -5
  75. package/payload/server/server.js +188 -132
  76. package/payload/server/public/assets/activity-Mz1BhgB1.js +0 -1
  77. package/payload/server/public/assets/chat-5tJdo9i_.js +0 -1
  78. package/payload/server/public/assets/chevron-left-BJllrPBj.js +0 -1
  79. package/payload/server/public/assets/data-Du79EgR-.js +0 -1
  80. /package/payload/server/public/assets/{useSubAccountSwitcher-CBlKgwms.js → useSubAccountSwitcher-DzgzTRRn.js} +0 -0
@@ -28,6 +28,7 @@ import {
28
28
  VNC_DISPLAY,
29
29
  WEBSOCKIFY_PORT,
30
30
  accessPasswordCollides,
31
+ armedCount,
31
32
  autoDeliverPremiumPlugins,
32
33
  canAccessAdmin,
33
34
  checkRateLimit,
@@ -71,6 +72,7 @@ import {
71
72
  isValidAccountId,
72
73
  linkConversationTranscript,
73
74
  listAdminSessions,
75
+ listLoops,
74
76
  listValidAccounts,
75
77
  loadAdminUserName,
76
78
  loadPersonNameByElementId,
@@ -81,6 +83,7 @@ import {
81
83
  projectAgent,
82
84
  reconcileEnabledPluginsForAccounts,
83
85
  recordFailedAttempt,
86
+ registerLoop,
84
87
  registerSession,
85
88
  renameConversation,
86
89
  renderLoginPage,
@@ -112,7 +115,7 @@ import {
112
115
  vncLog,
113
116
  walkPremiumBundles,
114
117
  writeAdminUserAndPerson
115
- } from "./chunk-Y6V45R6M.js";
118
+ } from "./chunk-LBCMFD4O.js";
116
119
  import {
117
120
  D1_MAX_SQL_STATEMENT_BYTES,
118
121
  D1_QUERY_MAX_BODY_BYTES,
@@ -2391,12 +2394,12 @@ function startAuthHealthHeartbeat(intervalMs = 5 * 60 * 1e3) {
2391
2394
  ticking = false;
2392
2395
  }
2393
2396
  };
2394
- void tick();
2395
- const handle = setInterval(() => {
2396
- void tick();
2397
- }, intervalMs);
2398
- if (typeof handle.unref === "function") handle.unref();
2399
- return () => clearInterval(handle);
2397
+ return registerLoop({
2398
+ name: "auth-health",
2399
+ intervalMs,
2400
+ firstRunDelayMs: 0,
2401
+ run: tick
2402
+ });
2400
2403
  }
2401
2404
  async function ensureAuth() {
2402
2405
  const health = assessAuthHealth();
@@ -2809,12 +2812,12 @@ function createBaileysLogger(bindings = {}, authDir) {
2809
2812
  var credsSaveQueue = Promise.resolve();
2810
2813
  async function drainCredsSaveQueue(timeoutMs = 5e3) {
2811
2814
  console.error(`${TAG6} draining credential save queue\u2026`);
2812
- const timer2 = new Promise(
2815
+ const timer = new Promise(
2813
2816
  (resolve37) => setTimeout(() => resolve37("timeout"), timeoutMs)
2814
2817
  );
2815
2818
  const result = await Promise.race([
2816
2819
  credsSaveQueue.then(() => "drained"),
2817
- timer2
2820
+ timer
2818
2821
  ]);
2819
2822
  if (result === "timeout") {
2820
2823
  console.error(`${TAG6} credential save queue drain timed out after ${timeoutMs}ms`);
@@ -3100,19 +3103,19 @@ function isTimeoutError(err) {
3100
3103
  }
3101
3104
  function withTimeout(label, promise, timeoutMs) {
3102
3105
  return new Promise((resolve37, reject) => {
3103
- const timer2 = setTimeout(() => {
3106
+ const timer = setTimeout(() => {
3104
3107
  const err = new Error(`${label} timed out after ${timeoutMs}ms`);
3105
3108
  err.__maxyTimeout = true;
3106
3109
  reject(err);
3107
3110
  }, timeoutMs);
3108
- timer2.unref?.();
3111
+ timer.unref?.();
3109
3112
  promise.then(
3110
3113
  (value) => {
3111
- clearTimeout(timer2);
3114
+ clearTimeout(timer);
3112
3115
  resolve37(value);
3113
3116
  },
3114
3117
  (err) => {
3115
- clearTimeout(timer2);
3118
+ clearTimeout(timer);
3116
3119
  reject(err);
3117
3120
  }
3118
3121
  );
@@ -5197,10 +5200,10 @@ function createInboundDebouncer(opts) {
5197
5200
  flushKey(key).catch(onError);
5198
5201
  }, debounceMs);
5199
5202
  } else {
5200
- const timer2 = setTimeout(() => {
5203
+ const timer = setTimeout(() => {
5201
5204
  flushKey(key).catch(onError);
5202
5205
  }, debounceMs);
5203
- pending.set(key, { entries: [msg], timer: timer2 });
5206
+ pending.set(key, { entries: [msg], timer });
5204
5207
  }
5205
5208
  }
5206
5209
  function registerPending(key, promise) {
@@ -5855,9 +5858,9 @@ async function connectWithReconnect(conn) {
5855
5858
  `${TAG17} reconnecting account=${conn.accountId} in ${delay}ms (attempt ${decision.nextAttempts}/${maxAttempts})`
5856
5859
  );
5857
5860
  await new Promise((resolve37) => {
5858
- const timer2 = setTimeout(resolve37, delay);
5861
+ const timer = setTimeout(resolve37, delay);
5859
5862
  conn.abortController.signal.addEventListener("abort", () => {
5860
- clearTimeout(timer2);
5863
+ clearTimeout(timer);
5861
5864
  resolve37();
5862
5865
  }, { once: true });
5863
5866
  });
@@ -10445,9 +10448,9 @@ function isModelGated(turns) {
10445
10448
  return turns.some((t) => t.kind === "agent-error" && t.code === "model_unavailable");
10446
10449
  }
10447
10450
  function renderOrSuppressChannelInbound(u, ts, out, queuedPendingSuppress) {
10448
- const armed = queuedPendingSuppress.get(u.text) ?? 0;
10449
- if (armed > 0) {
10450
- queuedPendingSuppress.set(u.text, armed - 1);
10451
+ const armed2 = queuedPendingSuppress.get(u.text) ?? 0;
10452
+ if (armed2 > 0) {
10453
+ queuedPendingSuppress.set(u.text, armed2 - 1);
10451
10454
  } else {
10452
10455
  out.push(operatorInboundTurn(u, ts));
10453
10456
  }
@@ -10656,8 +10659,8 @@ function pickActivity(entries, grown, nowMs, concurrencyWindowMs) {
10656
10659
 
10657
10660
  // server/routes/stream-lifecycle.ts
10658
10661
  var GAUGE_INTERVAL_MS = 6e4;
10659
- function isArmed(timer2) {
10660
- return timer2._destroyed !== true;
10662
+ function isArmed(timer) {
10663
+ return timer._destroyed !== true;
10661
10664
  }
10662
10665
  var Registration = class {
10663
10666
  constructor(connId, channel, startedAt) {
@@ -10667,9 +10670,9 @@ var Registration = class {
10667
10670
  }
10668
10671
  timers = [];
10669
10672
  closed = false;
10670
- arm(timer2) {
10671
- this.timers.push(timer2);
10672
- return timer2;
10673
+ arm(timer) {
10674
+ this.timers.push(timer);
10675
+ return timer;
10673
10676
  }
10674
10677
  teardown(reason) {
10675
10678
  if (this.closed) return false;
@@ -10703,11 +10706,11 @@ function emitGauge() {
10703
10706
  counts[reg.channel]++;
10704
10707
  oldestMs = Math.max(oldestMs, now - reg.startedAt);
10705
10708
  }
10706
- const armed = counts.reader + counts.store;
10709
+ const armed2 = counts.reader + counts.store;
10707
10710
  console.log(
10708
- `[wa-stream] op=gauge armed=${armed} reader=${counts.reader} store=${counts.store} oldestSec=${Math.floor(oldestMs / 1e3)} stale=${stale}`
10711
+ `[wa-stream] op=gauge armed=${armed2} reader=${counts.reader} store=${counts.store} oldestSec=${Math.floor(oldestMs / 1e3)} stale=${stale}`
10709
10712
  );
10710
- if (armed === 0) stopGauge();
10713
+ if (armed2 === 0) stopGauge();
10711
10714
  }
10712
10715
  function startGauge() {
10713
10716
  if (gaugeTimer) return;
@@ -20701,18 +20704,18 @@ async function probeConversationDb() {
20701
20704
  } catch (err) {
20702
20705
  return { state: "error", reason: err instanceof Error ? err.message : String(err) };
20703
20706
  }
20704
- let timer2;
20707
+ let timer;
20705
20708
  try {
20706
20709
  const probe = session.run("RETURN 1");
20707
20710
  const timeout = new Promise((_, reject) => {
20708
- timer2 = setTimeout(() => reject(new Error("timeout")), PROBE_TIMEOUT_MS);
20711
+ timer = setTimeout(() => reject(new Error("timeout")), PROBE_TIMEOUT_MS);
20709
20712
  });
20710
20713
  await Promise.race([probe, timeout]);
20711
20714
  return { state: "ok" };
20712
20715
  } catch (err) {
20713
20716
  return { state: "error", reason: err instanceof Error ? err.message : String(err) };
20714
20717
  } finally {
20715
- if (timer2) clearTimeout(timer2);
20718
+ if (timer) clearTimeout(timer);
20716
20719
  session.close().catch(() => {
20717
20720
  });
20718
20721
  }
@@ -22383,10 +22386,20 @@ app52.get("/", requireAdminSession, async (c) => {
22383
22386
  if (name) names[a.accountId] = name;
22384
22387
  })
22385
22388
  );
22389
+ const loopRows = listLoops();
22390
+ const armed2 = armedCount();
22391
+ const byState = loopRows.reduce((acc, r) => {
22392
+ acc[r.state] = (acc[r.state] ?? 0) + 1;
22393
+ return acc;
22394
+ }, {});
22395
+ console.log(
22396
+ `${TAG42} op=loops req=${req} armed=${armed2} rendered=${loopRows.length} ` + Object.entries(byState).map(([s, n]) => `${s}=${n}`).join(" ")
22397
+ );
22386
22398
  return c.json({
22387
22399
  rows,
22388
22400
  census,
22389
22401
  censusAgeMs,
22402
+ loops: { armed: armed2, rows: loopRows },
22390
22403
  accounts: {
22391
22404
  onDisk,
22392
22405
  valid: valid.length,
@@ -23801,14 +23814,12 @@ function startTimeEntryCensus(openSession, opts = {}) {
23801
23814
  }
23802
23815
  }
23803
23816
  };
23804
- void tick();
23805
- const id = setInterval(() => {
23806
- void tick();
23807
- }, intervalMs);
23808
- if (typeof id.unref === "function") {
23809
- id.unref();
23810
- }
23811
- return () => clearInterval(id);
23817
+ return registerLoop({
23818
+ name: "timeentry-census",
23819
+ intervalMs,
23820
+ firstRunDelayMs: 0,
23821
+ run: tick
23822
+ });
23812
23823
  }
23813
23824
 
23814
23825
  // app/lib/ledger-census.ts
@@ -23962,15 +23973,12 @@ function startLedgerCensus(openSession, opts = {}) {
23962
23973
  }
23963
23974
  }
23964
23975
  };
23965
- void tick();
23966
- const id = setInterval(() => {
23967
- void tick();
23968
- }, intervalMs);
23969
- if (typeof id.unref === "function") {
23970
- ;
23971
- id.unref();
23972
- }
23973
- return () => clearInterval(id);
23976
+ return registerLoop({
23977
+ name: "ledger-census",
23978
+ intervalMs,
23979
+ firstRunDelayMs: 0,
23980
+ run: tick
23981
+ });
23974
23982
  }
23975
23983
 
23976
23984
  // app/lib/conversation-audit.ts
@@ -24022,7 +24030,7 @@ function renderLabelTop(rows) {
24022
24030
  return `${labels}:${c}`;
24023
24031
  }).join(",");
24024
24032
  }
24025
- var timer = null;
24033
+ var armed = false;
24026
24034
  async function runGraphHealthTick() {
24027
24035
  const session = getSession();
24028
24036
  try {
@@ -24117,16 +24125,16 @@ async function verifyUserProfileConstraint() {
24117
24125
  }
24118
24126
  }
24119
24127
  function startGraphHealthTimer() {
24120
- if (timer) return;
24128
+ if (armed) return;
24121
24129
  verifyUserProfileConstraint().catch(() => {
24122
24130
  });
24123
- runGraphHealthTick().catch(() => {
24131
+ registerLoop({
24132
+ name: "graph-health",
24133
+ intervalMs: HOUR_MS,
24134
+ firstRunDelayMs: 0,
24135
+ run: () => runGraphHealthTick()
24124
24136
  });
24125
- timer = setInterval(() => {
24126
- runGraphHealthTick().catch(() => {
24127
- });
24128
- }, HOUR_MS);
24129
- if (typeof timer.unref === "function") timer.unref();
24137
+ armed = true;
24130
24138
  }
24131
24139
 
24132
24140
  // app/lib/file-watcher.ts
@@ -25446,13 +25454,13 @@ var WebchatGateway = class _WebchatGateway {
25446
25454
  * response, preserving the pre-756 POST→single-blob browser contract. */
25447
25455
  awaitReply(key, timeoutMs) {
25448
25456
  return new Promise((resolve37) => {
25449
- const timer2 = setTimeout(() => {
25457
+ const timer = setTimeout(() => {
25450
25458
  this.replyAwaiters.delete(key);
25451
25459
  resolve37({ timeout: true });
25452
25460
  }, timeoutMs);
25453
- if (timer2.unref) timer2.unref();
25461
+ if (timer.unref) timer.unref();
25454
25462
  this.replyAwaiters.set(key, (r) => {
25455
- clearTimeout(timer2);
25463
+ clearTimeout(timer);
25456
25464
  this.replyAwaiters.delete(key);
25457
25465
  resolve37(r);
25458
25466
  });
@@ -25467,16 +25475,16 @@ var WebchatGateway = class _WebchatGateway {
25467
25475
  const k = _WebchatGateway.promptKey(p.key, p.requestId);
25468
25476
  return new Promise((resolve37) => {
25469
25477
  this.pendingPrompts.get(k)?.resolve({ timeout: true });
25470
- const timer2 = setTimeout(() => {
25478
+ const timer = setTimeout(() => {
25471
25479
  this.pendingPrompts.delete(k);
25472
25480
  resolve37({ timeout: true });
25473
25481
  }, timeoutMs);
25474
- if (timer2.unref) timer2.unref();
25482
+ if (timer.unref) timer.unref();
25475
25483
  this.pendingPrompts.set(k, {
25476
25484
  ...p,
25477
25485
  at: Date.now(),
25478
25486
  resolve: (r) => {
25479
- clearTimeout(timer2);
25487
+ clearTimeout(timer);
25480
25488
  this.pendingPrompts.delete(k);
25481
25489
  resolve37(r);
25482
25490
  }
@@ -27569,8 +27577,12 @@ function runDuplicateSenderAudit() {
27569
27577
  console.error(`[whatsapp-native] op=duplicate-sender-audit-error error=${err instanceof Error ? err.message : String(err)}`);
27570
27578
  }
27571
27579
  }
27572
- setTimeout(runDuplicateSenderAudit, 0).unref();
27573
- setInterval(runDuplicateSenderAudit, 15 * 6e4).unref();
27580
+ registerLoop({
27581
+ name: "whatsapp-duplicate-sender-audit",
27582
+ intervalMs: 15 * 6e4,
27583
+ firstRunDelayMs: 0,
27584
+ run: runDuplicateSenderAudit
27585
+ });
27574
27586
  var webchatGateway = new WebchatGateway({
27575
27587
  fetchStandingRules: fetchAccountStandingRules,
27576
27588
  gatewayUrl: webchatGatewayUrl(),
@@ -28512,10 +28524,13 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
28512
28524
  console.error(`[calendar-reconcile] spawn-failed err="${err.message}"`);
28513
28525
  }
28514
28526
  };
28515
- const firstRun = setTimeout(runReconcile, 15e3);
28516
- firstRun.unref();
28517
- const loop = setInterval(runReconcile, RECONCILE_INTERVAL_MS);
28518
- loop.unref();
28527
+ registerLoop({
28528
+ name: "calendar-reconcile",
28529
+ intervalMs: RECONCILE_INTERVAL_MS,
28530
+ firstRunDelayMs: 15e3,
28531
+ detached: true,
28532
+ run: runReconcile
28533
+ });
28519
28534
  }
28520
28535
  {
28521
28536
  const outlookPlatformRoot = process.env.MAXY_PLATFORM_ROOT ?? join42(__dirname, "..");
@@ -28534,10 +28549,13 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
28534
28549
  console.error(`[outlook-complete] spawn-failed err="${err.message}"`);
28535
28550
  }
28536
28551
  };
28537
- const outlookFirst = setTimeout(runOutlookComplete, 18e3);
28538
- outlookFirst.unref();
28539
- const outlookLoop = setInterval(runOutlookComplete, OUTLOOK_COMPLETE_INTERVAL_MS);
28540
- outlookLoop.unref();
28552
+ registerLoop({
28553
+ name: "outlook-devicecode-complete",
28554
+ intervalMs: OUTLOOK_COMPLETE_INTERVAL_MS,
28555
+ firstRunDelayMs: 18e3,
28556
+ detached: true,
28557
+ run: runOutlookComplete
28558
+ });
28541
28559
  }
28542
28560
  {
28543
28561
  const auditRoot = process.env.MAXY_PLATFORM_ROOT ?? join42(__dirname, "..");
@@ -28562,10 +28580,12 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
28562
28580
  console.error(`[outlook-mcp] devicecode-stranded-audit error="${err.message}"`);
28563
28581
  }
28564
28582
  };
28565
- const strandedFirst = setTimeout(runStrandedAudit, 25e3);
28566
- strandedFirst.unref();
28567
- const strandedLoop = setInterval(runStrandedAudit, STRANDED_AUDIT_INTERVAL_MS);
28568
- strandedLoop.unref();
28583
+ registerLoop({
28584
+ name: "outlook-stranded-audit",
28585
+ intervalMs: STRANDED_AUDIT_INTERVAL_MS,
28586
+ firstRunDelayMs: 25e3,
28587
+ run: runStrandedAudit
28588
+ });
28569
28589
  }
28570
28590
  {
28571
28591
  const googleRoot = process.env.MAXY_PLATFORM_ROOT ?? join42(__dirname, "..");
@@ -28578,10 +28598,12 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
28578
28598
  console.error(`[google-oauth] op=pending-audit-error error="${err.message}"`);
28579
28599
  }
28580
28600
  };
28581
- const googlePendingFirst = setTimeout(runGooglePendingAuditSafe, 27e3);
28582
- googlePendingFirst.unref();
28583
- const googlePendingLoop = setInterval(runGooglePendingAuditSafe, GOOGLE_PENDING_AUDIT_INTERVAL_MS);
28584
- googlePendingLoop.unref();
28601
+ registerLoop({
28602
+ name: "google-pending-audit",
28603
+ intervalMs: GOOGLE_PENDING_AUDIT_INTERVAL_MS,
28604
+ firstRunDelayMs: 27e3,
28605
+ run: runGooglePendingAuditSafe
28606
+ });
28585
28607
  const googleAuditScript = resolve36(googleRoot, "plugins/google/mcp/dist/scripts/account-audit.js");
28586
28608
  const GOOGLE_ACCOUNT_AUDIT_INTERVAL_MS = 36e5;
28587
28609
  const runGoogleAccountAudit = () => {
@@ -28600,32 +28622,37 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
28600
28622
  console.error(`[google-account-audit] op=spawn-failed error="${err.message}"`);
28601
28623
  }
28602
28624
  };
28603
- const googleAuditFirst = setTimeout(runGoogleAccountAudit, 45e3);
28604
- googleAuditFirst.unref();
28605
- const googleAuditLoop = setInterval(runGoogleAccountAudit, GOOGLE_ACCOUNT_AUDIT_INTERVAL_MS);
28606
- googleAuditLoop.unref();
28625
+ registerLoop({
28626
+ name: "google-account-audit",
28627
+ intervalMs: GOOGLE_ACCOUNT_AUDIT_INTERVAL_MS,
28628
+ firstRunDelayMs: 45e3,
28629
+ detached: true,
28630
+ run: runGoogleAccountAudit
28631
+ });
28607
28632
  }
28608
28633
  {
28609
28634
  const auditPlatformRoot = process.env.MAXY_PLATFORM_ROOT ?? join42(__dirname, "..");
28610
28635
  const STORAGE_AUDIT_INTERVAL_MS = 3e5;
28611
- const runStorageAuditSafe = () => {
28612
- runStorageAudit(auditPlatformRoot).catch(
28613
- (err) => console.error(`[storage-audit] error="${err.message}"`)
28614
- );
28615
- };
28616
- const auditFirst = setTimeout(runStorageAuditSafe, 2e4);
28617
- auditFirst.unref();
28618
- const auditLoop = setInterval(runStorageAuditSafe, STORAGE_AUDIT_INTERVAL_MS);
28619
- auditLoop.unref();
28620
- const runPagesAuditSafe = () => {
28621
- runPagesAudit(auditPlatformRoot).catch(
28622
- (err) => console.error(`[pages-audit] error="${err.message}"`)
28623
- );
28624
- };
28625
- const pagesAuditFirst = setTimeout(runPagesAuditSafe, 35e3);
28626
- pagesAuditFirst.unref();
28627
- const pagesAuditLoop = setInterval(runPagesAuditSafe, STORAGE_AUDIT_INTERVAL_MS);
28628
- pagesAuditLoop.unref();
28636
+ const runStorageAuditSafe = () => runStorageAudit(auditPlatformRoot).catch((err) => {
28637
+ console.error(`[storage-audit] error="${err.message}"`);
28638
+ throw err;
28639
+ });
28640
+ registerLoop({
28641
+ name: "storage-audit",
28642
+ intervalMs: STORAGE_AUDIT_INTERVAL_MS,
28643
+ firstRunDelayMs: 2e4,
28644
+ run: runStorageAuditSafe
28645
+ });
28646
+ const runPagesAuditSafe = () => runPagesAudit(auditPlatformRoot).catch((err) => {
28647
+ console.error(`[pages-audit] error="${err.message}"`);
28648
+ throw err;
28649
+ });
28650
+ registerLoop({
28651
+ name: "pages-audit",
28652
+ intervalMs: STORAGE_AUDIT_INTERVAL_MS,
28653
+ firstRunDelayMs: 35e3,
28654
+ run: runPagesAuditSafe
28655
+ });
28629
28656
  }
28630
28657
  {
28631
28658
  const publishPlatformRoot = process.env.MAXY_PLATFORM_ROOT ?? join42(__dirname, "..");
@@ -28689,10 +28716,13 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
28689
28716
  spawnPublish(account);
28690
28717
  auditSnapshotAge(account);
28691
28718
  };
28692
- const firstPublish = setTimeout(publishTick, 2e4);
28693
- firstPublish.unref();
28694
- const publishLoop = setInterval(publishTick, PUBLISH_INTERVAL_MS);
28695
- publishLoop.unref();
28719
+ registerLoop({
28720
+ name: "calendar-availability-publish",
28721
+ intervalMs: PUBLISH_INTERVAL_MS,
28722
+ firstRunDelayMs: 2e4,
28723
+ detached: true,
28724
+ run: publishTick
28725
+ });
28696
28726
  }
28697
28727
  startTimeEntryCensus(() => getSession());
28698
28728
  startLedgerCensus(() => getSession());
@@ -28714,10 +28744,13 @@ startLedgerCensus(() => getSession());
28714
28744
  console.error(`[connector-audit] spawn-failed err="${err.message}"`);
28715
28745
  }
28716
28746
  };
28717
- const firstAudit = setTimeout(runConnectorAudit, 3e4);
28718
- firstAudit.unref();
28719
- const auditLoop = setInterval(runConnectorAudit, CONNECTOR_AUDIT_INTERVAL_MS);
28720
- auditLoop.unref();
28747
+ registerLoop({
28748
+ name: "connector-audit",
28749
+ intervalMs: CONNECTOR_AUDIT_INTERVAL_MS,
28750
+ firstRunDelayMs: 3e4,
28751
+ detached: true,
28752
+ run: runConnectorAudit
28753
+ });
28721
28754
  }
28722
28755
  {
28723
28756
  const census = pwaCensus({
@@ -28740,15 +28773,19 @@ startAuthHealthHeartbeat();
28740
28773
  loopHist.enable();
28741
28774
  const LOG_THRESHOLD_MS = 1e3;
28742
28775
  const WINDOW_MS2 = 3e4;
28743
- const lagTimer = setInterval(() => {
28744
- const maxMs = loopHist.max / 1e6;
28745
- const p99Ms = loopHist.percentile(99) / 1e6;
28746
- loopHist.reset();
28747
- if (maxMs >= LOG_THRESHOLD_MS) {
28748
- console.error(`[event-loop] lag p99=${Math.round(p99Ms)} max=${Math.round(maxMs)} window=${WINDOW_MS2 / 1e3}s`);
28776
+ registerLoop({
28777
+ name: "event-loop-lag",
28778
+ intervalMs: WINDOW_MS2,
28779
+ run: () => {
28780
+ const maxMs = loopHist.max / 1e6;
28781
+ const p99Ms = loopHist.percentile(99) / 1e6;
28782
+ loopHist.reset();
28783
+ if (maxMs >= LOG_THRESHOLD_MS) {
28784
+ console.error(`[event-loop] lag p99=${Math.round(p99Ms)} max=${Math.round(maxMs)} window=${WINDOW_MS2 / 1e3}s`);
28785
+ }
28786
+ return `p99 ${Math.round(p99Ms)}ms, max ${Math.round(maxMs)}ms`;
28749
28787
  }
28750
- }, WINDOW_MS2);
28751
- lagTimer.unref();
28788
+ });
28752
28789
  }
28753
28790
  var SUBAPP_MANIFEST = [
28754
28791
  { prefix: "/api/health", file: "server/routes/health.ts", subapp: health_default },
@@ -28840,11 +28877,14 @@ async function runAdminUserReconcileTick() {
28840
28877
  console.error(`[adminuser-self-heal] rejected: ${err instanceof Error ? err.message : String(err)}`);
28841
28878
  }
28842
28879
  }
28843
- void runAdminUserReconcileTick();
28844
- var adminUserReconcileTimer = setInterval(() => {
28845
- void runAdminUserReconcileTick();
28846
- }, ADMINUSER_RECONCILE_INTERVAL_MS);
28847
- if (typeof adminUserReconcileTimer.unref === "function") adminUserReconcileTimer.unref();
28880
+ registerLoop({
28881
+ name: "adminuser-reconcile",
28882
+ intervalMs: ADMINUSER_RECONCILE_INTERVAL_MS,
28883
+ firstRunDelayMs: 0,
28884
+ // Returned, not void-called: the registry awaits it, so the recorded
28885
+ // duration and outcome describe the tick rather than the call that started it.
28886
+ run: () => runAdminUserReconcileTick()
28887
+ });
28848
28888
  var INGEST_AUDIT_INTERVAL_MS = 15 * 60 * 1e3;
28849
28889
  var runIngestAuditTick = () => {
28850
28890
  try {
@@ -28853,9 +28893,12 @@ var runIngestAuditTick = () => {
28853
28893
  console.error(`[wa-ingest-audit] rejected: ${err instanceof Error ? err.message : String(err)}`);
28854
28894
  }
28855
28895
  };
28856
- runIngestAuditTick();
28857
- var ingestAuditTimer = setInterval(runIngestAuditTick, INGEST_AUDIT_INTERVAL_MS);
28858
- if (typeof ingestAuditTimer.unref === "function") ingestAuditTimer.unref();
28896
+ registerLoop({
28897
+ name: "wa-ingest-audit",
28898
+ intervalMs: INGEST_AUDIT_INTERVAL_MS,
28899
+ firstRunDelayMs: 0,
28900
+ run: runIngestAuditTick
28901
+ });
28859
28902
  var USERS_RECONCILE_INTERVAL_MS = 60 * 60 * 1e3;
28860
28903
  function countUsersRows() {
28861
28904
  if (!existsSync38(USERS_FILE)) return 0;
@@ -28882,9 +28925,12 @@ function runUsersReconcileTick() {
28882
28925
  console.error(`[users-reconcile] op=error detail=${err instanceof Error ? err.message : String(err)}`);
28883
28926
  }
28884
28927
  }
28885
- runUsersReconcileTick();
28886
- var usersReconcileTimer = setInterval(runUsersReconcileTick, USERS_RECONCILE_INTERVAL_MS);
28887
- if (typeof usersReconcileTimer.unref === "function") usersReconcileTimer.unref();
28928
+ registerLoop({
28929
+ name: "users-reconcile",
28930
+ intervalMs: USERS_RECONCILE_INTERVAL_MS,
28931
+ firstRunDelayMs: 0,
28932
+ run: runUsersReconcileTick
28933
+ });
28888
28934
  startGraphHealthTimer();
28889
28935
  void migrateUploads().catch((err) => console.error(`[uploads-migrate] failed err="${err instanceof Error ? err.message : String(err)}"`)).finally(() => {
28890
28936
  void startFileWatcher().catch((err) => {
@@ -28893,9 +28939,19 @@ void migrateUploads().catch((err) => console.error(`[uploads-migrate] failed err
28893
28939
  });
28894
28940
  void sweepStaleUploadTemps().catch((err) => console.error(`[data-upload] op=sweep-failed err="${err instanceof Error ? err.message : String(err)}"`));
28895
28941
  var CHUNK_IDLE_TTL_MS = 30 * 60 * 1e3;
28896
- setInterval(() => {
28897
- void evictStaleChunkUploads(CHUNK_IDLE_TTL_MS).catch((err) => console.error(`[data-upload] op=evict-failed err="${err instanceof Error ? err.message : String(err)}"`));
28898
- }, 10 * 60 * 1e3).unref();
28942
+ registerLoop({
28943
+ name: "upload-chunk-evict",
28944
+ intervalMs: 10 * 60 * 1e3,
28945
+ // The domain-tagged line is kept and the rejection rethrown: existing
28946
+ // `[data-upload]` greps keep working AND the registry records the failure,
28947
+ // rather than swallowing it and reporting the run as healthy.
28948
+ run: () => evictStaleChunkUploads(CHUNK_IDLE_TTL_MS).then((evicted) => `evicted ${evicted}`).catch((err) => {
28949
+ console.error(
28950
+ `[data-upload] op=evict-failed err="${err instanceof Error ? err.message : String(err)}"`
28951
+ );
28952
+ throw err;
28953
+ })
28954
+ });
28899
28955
  void migrateAdminWebchatSidecars().catch((err) => console.error(`[sidecar-backfill] failed err="${err instanceof Error ? err.message : String(err)}"`));
28900
28956
  try {
28901
28957
  const accounts = enumerateValidAccountIds(getAccountsDirFromEnv());
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-TPjIAO9U.js";import{D as t,S as n,T as r,_ as i,d as a,g as o,r as s,w as c}from"./useSubAccountSwitcher-CBlKgwms.js";import{t as l,y as u}from"./AdminShell-BjxV2qkb.js";import"./useSelectionMode-CWlh6AEq.js";import{t as d}from"./triangle-alert-DLfIsuo_.js";var f=i(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),p=i(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),m=r(),h=e(t(),1),g=n(),_=`maxy-admin-session-key`;function v(e){switch(e.costUnavailable){case`metering-failed`:return`Cost could not be calculated: ${e.meteringError??`the transcript could not be read`}`;case`model-not-priced`:return`No published price for this model, so cost cannot be estimated.`;case`no-transcript`:return`This session has no transcript yet, so there is nothing to cost.`;default:return}}var y=[{key:`accountId`,label:`Account`,numeric:!1,help:`The business this session belongs to. "untagged" means the session records no account.`},{key:`title`,label:`Session`,numeric:!1,help:`The conversation name, or its short id when it has none yet.`},{key:`model`,label:`Model`,numeric:!1,help:`The model that answered the most recent turn.`},{key:`status`,label:`Status`,numeric:!1,help:`What the process is doing right now.`},{key:`ageMs`,label:`Age`,numeric:!0,help:`How long ago this conversation started.`},{key:`lastMessageAt`,label:`Last activity`,numeric:!0,help:`The clock time of the most recent message, in your timezone. A date appears once it is not today.`},{key:`turnCount`,label:`Turns`,numeric:!0,help:`Messages exchanged. A trailing + means the count is a minimum — the conversation is too long to count exactly.`},{key:`rssKb`,label:`RAM`,numeric:!0,help:`Memory held by this session and all its helper processes together.`},{key:`cpuPct`,label:`CPU (avg)`,numeric:!0,help:`AVERAGE share of one processor core over the last census interval, up to 60 seconds. It is not a reading of this instant, so a session that answered a turn a minute ago still shows a high figure while sitting quiet now. Can exceed 100% because a session runs many processes at once.`},{key:`usedTokens`,label:`Tokens`,numeric:!0,help:`Size of the conversation the model currently reads back on every turn.`},{key:`costGbp`,label:`Cost`,numeric:!0,help:`Estimated spend on this conversation so far, at published prices for its model.`}],b=[`lastMessageAt`,`turnCount`,`rssKb`,`cpuPct`];function x(e,t){let n=t?.[e];return n&&n.trim()!==``?n:e.slice(0,8)}var S=`—`;function C(e){if(e===null||!Number.isFinite(e)||e<0)return S;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function w(e){return e===null||!Number.isFinite(e)?S:`${(e/1024/1024).toFixed(1)} GB`}function T(e,t){if(!e)return S;let n=Date.parse(e);if(!Number.isFinite(n))return S;let r=new Date(n),i=new Date(t),a=`${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`;return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()?a:`${r.getDate()} ${r.toLocaleString(`en-GB`,{month:`short`})} ${a}`}function E(e){return e===null||!Number.isFinite(e)?S:`${e.toFixed(1)}%`}function D(e){return e===null||!Number.isFinite(e)?S:e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function O(e){return e===null||!Number.isFinite(e)?S:`£${e.toFixed(2)}`}function k(e,t,n,r){let i=e[n],a=t[n];if(i===null&&a===null)return 0;if(i===null)return 1;if(a===null)return-1;if(n===`lastMessageAt`){let e=Date.parse(String(i)),t=Date.parse(String(a));return!Number.isFinite(e)&&!Number.isFinite(t)?0:Number.isFinite(e)?Number.isFinite(t)?(e-t)*r:-1:1}return typeof i==`number`&&typeof a==`number`?(i-a)*r:String(i).localeCompare(String(a))*r}function A({adminFetch:e}){let[t,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(null),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(`cpuPct`),[m,_]=(0,h.useState)(-1),A=(0,h.useRef)(!1),j=(0,h.useCallback)(async()=>{if(!A.current){A.current=!0;try{let t=await e(`/api/admin/activity`);if(t.status===403){i(`This view is available to the house account only.`),c(!0);return}if(!t.ok){i(`The session manager did not answer (status ${t.status}).`),c(!0);return}n(await t.json()),i(null)}catch(e){i(e instanceof Error?e.message:String(e))}finally{c(!0),A.current=!1}}},[e]);(0,h.useEffect)(()=>{j();let e=setInterval(()=>void j(),15e3);return()=>clearInterval(e)},[j]);let M=(0,h.useMemo)(()=>t?[...t.rows].sort((e,t)=>k(e,t,l,m)):[],[t,l,m]),N=e=>{e===l?_(e=>e===1?-1:1):(u(e),_(-1))};if(!s)return(0,g.jsxs)(`div`,{className:`activity-loading`,children:[(0,g.jsx)(a,{size:18,className:`spin`}),` Loading…`]});if(r)return(0,g.jsx)(`div`,{className:`activity-empty`,children:r});if(!t)return(0,g.jsx)(`div`,{className:`activity-empty`,children:`No response.`});let{accounts:P,census:F,censusAgeMs:I}=t,L=Date.now(),R=P.onDisk!==null&&P.onDisk>P.valid;return(0,g.jsxs)(`div`,{className:`activity-body`,children:[(0,g.jsxs)(`div`,{className:`activity-head`,children:[(0,g.jsxs)(`span`,{className:`activity-title`,children:[(0,g.jsx)(o,{size:16}),` Live sessions`]}),(0,g.jsxs)(`span`,{className:`activity-meta`,children:[M.length,` live · `,P.valid,` accounts`,P.untaggedCount>0?` · ${P.untaggedCount} untagged`:``]})]}),(0,g.jsx)(`div`,{className:`activity-census`,children:F===null?`No census collected yet, so memory and CPU are unavailable.`:`Memory and CPU measured ${C(I)} ago, averaged over the minute before that · ${F.cpuNull} of ${F.live} without a CPU reading`}),R&&(0,g.jsxs)(`div`,{className:`activity-warning`,children:[(0,g.jsx)(d,{size:14}),` `,P.onDisk,` account folders on disk but only`,` `,P.valid,` are readable. Sessions belonging to the rest cannot be attributed.`]}),M.length===0?(0,g.jsx)(`div`,{className:`activity-empty`,children:`No sessions are running.`}):(0,g.jsx)(`div`,{className:`activity-scroll`,children:(0,g.jsxs)(`table`,{className:`activity-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsx)(`tr`,{children:y.map(e=>(0,g.jsx)(`th`,{className:e.numeric?`activity-th activity-num`:`activity-th`,title:e.help,children:(0,g.jsxs)(`button`,{type:`button`,className:`activity-sort`,onClick:()=>N(e.key),children:[e.label,l===e.key&&(m===1?(0,g.jsx)(p,{size:11}):(0,g.jsx)(f,{size:11}))]})},e.key))})}),(0,g.jsx)(`tbody`,{children:M.map(e=>(0,g.jsxs)(`tr`,{className:`activity-row`,children:[(0,g.jsx)(`td`,{className:`activity-td`,title:e.accountId??void 0,children:e.accountId===null?(0,g.jsx)(`span`,{className:`activity-untagged`,title:`This session records no account, so it cannot be attributed to a business.`,children:`untagged`}):x(e.accountId,P.names)}),(0,g.jsx)(`td`,{className:`activity-td`,children:e.title??e.sessionId.slice(0,8)}),(0,g.jsx)(`td`,{className:`activity-td`,children:e.model??S}),(0,g.jsx)(`td`,{className:`activity-td`,children:e.status??S}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:C(e.ageMs)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:T(e.lastMessageAt,L)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:e.turnCount===null?S:`${e.turnCount}${e.turnCountCapped?`+`:``}`}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.rssKb)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:E(e.cpuPct)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:D(e.usedTokens)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,title:v(e),children:O(e.costGbp)})]},e.sessionId))})]})}),M.length>0&&(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[b.map(e=>{let t=y.find(t=>t.key===e);return(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:t.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:t.help})]},e)}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:S}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Not measured. It does not mean zero — hover the cell for the reason where one exists.`})]})]})]})}function j({cacheKey:e}){let{adminFetch:t}=c({initialCacheKey:e,surface:`activity`});return(0,g.jsx)(A,{adminFetch:t})}function M(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)(!1),[i,o]=(0,h.useState)(void 0),[c,d]=(0,h.useState)(null),[f,p]=(0,h.useState)(null),[m,v]=(0,h.useState)(null),[y,b]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(_)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(_)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&d(e.sessionId??null),p(e.role??null),v(e.userName===void 0?null:e.userName),b(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let x=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(_)}catch{}window.location.href=`/`},[]),[S,C]=(0,h.useState)(!1),w=(0,h.useCallback)(async()=>{C(!0);try{let e=await u();if(e){try{sessionStorage.removeItem(_)}catch{}window.location.href=`/`}return e}finally{C(!1)}},[]);return n?e?(0,g.jsx)(s,{cacheKey:e,surface:`activity`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=activity`);try{sessionStorage.removeItem(_)}catch{}window.location.href=`/`},children:(0,g.jsx)(l,{cacheKey:e,businessName:i,sessionId:c,onLogout:x,onDisconnect:w,disconnecting:S,userName:m,userAvatar:y,role:f,children:(0,g.jsx)(j,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`activity-page`,children:(0,g.jsxs)(`div`,{className:`activity-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`activity-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(`div`,{className:`activity-page`,children:(0,g.jsxs)(`div`,{className:`activity-loading`,children:[(0,g.jsx)(a,{size:18,className:`spin`}),` Loading…`]})})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(M,{}));
@@ -1 +0,0 @@
1
- import{S as e,T as t}from"./useSubAccountSwitcher-CBlKgwms.js";import"./useVoiceRecorder-j3ZArZ2H.js";import"./AdminShell-BjxV2qkb.js";import{n}from"./page-DxnWgPtd.js";import"./useCopyFeedback-7yKeiAzV.js";import"./useSelectionMode-CWlh6AEq.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +0,0 @@
1
- import{_ as e}from"./useSubAccountSwitcher-CBlKgwms.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};
@@ -1 +0,0 @@
1
- import{S as e,T as t}from"./useSubAccountSwitcher-CBlKgwms.js";import"./useVoiceRecorder-j3ZArZ2H.js";import{t as n}from"./page-CkhFj8GQ.js";import"./useSelectionMode-CWlh6AEq.js";import"./graph-labels-GlTEIYJj.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));