@rubytech/create-maxy-code 0.1.583 → 0.1.584

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 (65) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/telegram-reach/dist/index.d.ts +6 -0
  3. package/payload/platform/lib/telegram-reach/dist/index.d.ts.map +1 -1
  4. package/payload/platform/lib/telegram-reach/dist/index.js +38 -3
  5. package/payload/platform/lib/telegram-reach/dist/index.js.map +1 -1
  6. package/payload/platform/lib/telegram-reach/src/__tests__/telegram-reach.test.ts +54 -2
  7. package/payload/platform/lib/telegram-reach/src/index.ts +38 -4
  8. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +5 -1
  9. package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +6 -0
  10. package/payload/platform/plugins/docs/references/telegram-guide.md +4 -0
  11. package/payload/platform/plugins/telegram/.claude-plugin/plugin.json +1 -1
  12. package/payload/platform/plugins/telegram/PLUGIN.md +3 -7
  13. package/payload/platform/plugins/telegram/mcp/dist/__tests__/api-census.test.js +25 -11
  14. package/payload/platform/plugins/telegram/mcp/dist/__tests__/api-census.test.js.map +1 -1
  15. package/payload/platform/plugins/telegram/mcp/dist/__tests__/api-guard.test.js +41 -5
  16. package/payload/platform/plugins/telegram/mcp/dist/__tests__/api-guard.test.js.map +1 -1
  17. package/payload/platform/plugins/telegram/mcp/dist/__tests__/api-methods.test.js +9 -3
  18. package/payload/platform/plugins/telegram/mcp/dist/__tests__/api-methods.test.js.map +1 -1
  19. package/payload/platform/plugins/telegram/mcp/dist/__tests__/card-business.test.js +14 -3
  20. package/payload/platform/plugins/telegram/mcp/dist/__tests__/card-business.test.js.map +1 -1
  21. package/payload/platform/plugins/telegram/mcp/dist/__tests__/reach-tool.test.js +20 -7
  22. package/payload/platform/plugins/telegram/mcp/dist/__tests__/reach-tool.test.js.map +1 -1
  23. package/payload/platform/plugins/telegram/mcp/dist/__tests__/schemas.test.js +2 -31
  24. package/payload/platform/plugins/telegram/mcp/dist/__tests__/schemas.test.js.map +1 -1
  25. package/payload/platform/plugins/telegram/mcp/dist/index.js +2 -10
  26. package/payload/platform/plugins/telegram/mcp/dist/index.js.map +1 -1
  27. package/payload/platform/plugins/telegram/mcp/dist/lib/account-write.d.ts +10 -3
  28. package/payload/platform/plugins/telegram/mcp/dist/lib/account-write.d.ts.map +1 -1
  29. package/payload/platform/plugins/telegram/mcp/dist/lib/account-write.js +29 -16
  30. package/payload/platform/plugins/telegram/mcp/dist/lib/account-write.js.map +1 -1
  31. package/payload/platform/plugins/telegram/mcp/dist/lib/api-census.d.ts +11 -1
  32. package/payload/platform/plugins/telegram/mcp/dist/lib/api-census.d.ts.map +1 -1
  33. package/payload/platform/plugins/telegram/mcp/dist/lib/api-census.js +18 -4
  34. package/payload/platform/plugins/telegram/mcp/dist/lib/api-census.js.map +1 -1
  35. package/payload/platform/plugins/telegram/mcp/dist/lib/api-guard.d.ts +11 -1
  36. package/payload/platform/plugins/telegram/mcp/dist/lib/api-guard.d.ts.map +1 -1
  37. package/payload/platform/plugins/telegram/mcp/dist/lib/api-guard.js +34 -2
  38. package/payload/platform/plugins/telegram/mcp/dist/lib/api-guard.js.map +1 -1
  39. package/payload/platform/plugins/telegram/mcp/dist/lib/api-methods.d.ts +0 -3
  40. package/payload/platform/plugins/telegram/mcp/dist/lib/api-methods.d.ts.map +1 -1
  41. package/payload/platform/plugins/telegram/mcp/dist/lib/api-methods.js +0 -1
  42. package/payload/platform/plugins/telegram/mcp/dist/lib/api-methods.js.map +1 -1
  43. package/payload/platform/plugins/telegram/mcp/dist/lib/business-window-store.d.ts +7 -4
  44. package/payload/platform/plugins/telegram/mcp/dist/lib/business-window-store.d.ts.map +1 -1
  45. package/payload/platform/plugins/telegram/mcp/dist/lib/business-window-store.js +15 -6
  46. package/payload/platform/plugins/telegram/mcp/dist/lib/business-window-store.js.map +1 -1
  47. package/payload/platform/plugins/telegram/mcp/dist/lib/chat-send-policy.d.ts +3 -2
  48. package/payload/platform/plugins/telegram/mcp/dist/lib/chat-send-policy.d.ts.map +1 -1
  49. package/payload/platform/plugins/telegram/mcp/dist/lib/chat-send-policy.js +3 -2
  50. package/payload/platform/plugins/telegram/mcp/dist/lib/chat-send-policy.js.map +1 -1
  51. package/payload/platform/plugins/telegram/mcp/dist/tools/api.js +8 -0
  52. package/payload/platform/plugins/telegram/mcp/dist/tools/api.js.map +1 -1
  53. package/payload/platform/plugins/telegram/mcp/dist/tools/reach.d.ts.map +1 -1
  54. package/payload/platform/plugins/telegram/mcp/dist/tools/reach.js +6 -1
  55. package/payload/platform/plugins/telegram/mcp/dist/tools/reach.js.map +1 -1
  56. package/payload/platform/plugins/telegram/mcp/dist/tools/schemas.d.ts +0 -70
  57. package/payload/platform/plugins/telegram/mcp/dist/tools/schemas.d.ts.map +1 -1
  58. package/payload/platform/plugins/telegram/mcp/dist/tools/schemas.js +0 -105
  59. package/payload/platform/plugins/telegram/mcp/dist/tools/schemas.js.map +1 -1
  60. package/payload/platform/plugins/telegram/skills/build/SKILL.md +12 -35
  61. package/payload/platform/plugins/telegram/skills/build/references/methods.md +3 -13
  62. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
  63. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +0 -1
  64. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
  65. package/payload/server/server.js +281 -291
@@ -314,7 +314,9 @@ var require_dist2 = __commonJS({
314
314
  exports.channelKeyToFileStem = channelKeyToFileStem3;
315
315
  exports.fileStemToChannelKey = fileStemToChannelKey3;
316
316
  exports.collectTelegramReach = collectTelegramReach2;
317
+ exports.telegramStoreRoot = telegramStoreRoot2;
317
318
  var node_fs_1 = __require("fs");
319
+ var node_os_1 = __require("os");
318
320
  var node_path_1 = __require("path");
319
321
  function isStorableChannelKey3(channelKey) {
320
322
  return /^-?\d+:-?\d+$/.test(channelKey) || /^-?\d+:biz:-?\d+$/.test(channelKey);
@@ -442,6 +444,22 @@ var require_dist2 = __commonJS({
442
444
  });
443
445
  return { bots, storeRows };
444
446
  }
447
+ function configDirName2(platformRoot5) {
448
+ const brandPath = (0, node_path_1.join)(platformRoot5, "config", "brand.json");
449
+ if ((0, node_fs_1.existsSync)(brandPath)) {
450
+ try {
451
+ const parsed = JSON.parse((0, node_fs_1.readFileSync)(brandPath, "utf8"));
452
+ if (typeof parsed.configDir === "string")
453
+ return parsed.configDir;
454
+ } catch {
455
+ }
456
+ }
457
+ return ".maxy";
458
+ }
459
+ function telegramStoreRoot2(platformRoot5) {
460
+ const brandDir = process.env.MAXY_DIR_OVERRIDE ?? (0, node_path_1.resolve)((0, node_os_1.homedir)(), configDirName2(platformRoot5));
461
+ return (0, node_path_1.join)(brandDir, "data", "telegram-messages");
462
+ }
445
463
  }
446
464
  });
447
465
 
@@ -3122,11 +3140,11 @@ var require_dist9 = __commonJS({
3122
3140
  });
3123
3141
 
3124
3142
  // server/index.ts
3125
- import { readFileSync as readFileSync62, existsSync as existsSync61, watchFile, readdirSync as readdirSync37, statSync as statSync33 } from "fs";
3143
+ import { readFileSync as readFileSync62, existsSync as existsSync62, watchFile, readdirSync as readdirSync37, statSync as statSync33 } from "fs";
3126
3144
  import { spawn as spawn3 } from "child_process";
3127
3145
  import { createHash as createHash8 } from "crypto";
3128
3146
  import { resolve as resolve55, join as join75, basename as basename19 } from "path";
3129
- import { homedir as homedir6 } from "os";
3147
+ import { homedir as homedir5 } from "os";
3130
3148
 
3131
3149
  // server/lib/route-cache-watchers.ts
3132
3150
  import { watch } from "fs";
@@ -3251,23 +3269,11 @@ function onInvalidate(fn) {
3251
3269
  var import_dist2 = __toESM(require_dist2(), 1);
3252
3270
  var import_dist3 = __toESM(require_dist2(), 1);
3253
3271
  import { existsSync, mkdirSync, readFileSync, appendFileSync, readdirSync, statSync } from "fs";
3254
- import { homedir } from "os";
3255
3272
  import { dirname, join, resolve } from "path";
3256
- function configDirName() {
3257
- const platformRoot5 = process.env.MAXY_PLATFORM_ROOT ?? resolve(process.cwd(), "..");
3258
- const brandPath = join(platformRoot5, "config", "brand.json");
3259
- if (existsSync(brandPath)) {
3260
- try {
3261
- return JSON.parse(readFileSync(brandPath, "utf-8")).configDir ?? ".maxy";
3262
- } catch {
3263
- }
3264
- }
3265
- return ".maxy";
3266
- }
3267
3273
  function isUpdateRecord(r) {
3268
3274
  return r.kind === "update";
3269
3275
  }
3270
- var STORE_ROOT2 = () => join(process.env.MAXY_DIR_OVERRIDE ?? resolve(homedir(), configDirName()), "data", "telegram-messages");
3276
+ var STORE_ROOT2 = () => (0, import_dist2.telegramStoreRoot)(process.env.MAXY_PLATFORM_ROOT ?? resolve(process.cwd(), ".."));
3271
3277
  function conversationFile(accountId, channelKey) {
3272
3278
  return join(STORE_ROOT2(), accountId, `${(0, import_dist2.channelKeyToFileStem)(channelKey)}.jsonl`);
3273
3279
  }
@@ -6315,7 +6321,7 @@ async function scanAiTitleIncremental(path, size, prior) {
6315
6321
 
6316
6322
  // ../services/claude-session-manager/src/jsonl-path.ts
6317
6323
  import { existsSync as existsSync4, readdirSync as readdirSync3 } from "fs";
6318
- import { homedir as homedir2 } from "os";
6324
+ import { homedir } from "os";
6319
6325
  import { join as join9 } from "path";
6320
6326
  function findExistingJsonlForSessionId(claudeConfigDir2, sessionId) {
6321
6327
  const projectsRoot = join9(claudeConfigDir2, "projects");
@@ -7776,6 +7782,60 @@ function parseInline(text) {
7776
7782
  return parts;
7777
7783
  }
7778
7784
 
7785
+ // app/lib/telegram/outbound/chunk-text.ts
7786
+ var TELEGRAM_TEXT_LIMIT = 4096;
7787
+ function fenceRanges(text) {
7788
+ const ranges = [];
7789
+ let open3 = -1;
7790
+ let pos = 0;
7791
+ for (const line of text.split("\n")) {
7792
+ if (FENCE.test(line)) {
7793
+ if (open3 === -1) open3 = pos;
7794
+ else {
7795
+ ranges.push([open3, pos + line.length]);
7796
+ open3 = -1;
7797
+ }
7798
+ }
7799
+ pos += line.length + 1;
7800
+ }
7801
+ if (open3 !== -1) ranges.push([open3, text.length]);
7802
+ return ranges;
7803
+ }
7804
+ function surrogateSafe(text, end) {
7805
+ const code = text.charCodeAt(end - 1);
7806
+ return code >= 55296 && code <= 56319 ? end - 1 : end;
7807
+ }
7808
+ function cutPoint(text, start, limit, fences) {
7809
+ const end = start + limit;
7810
+ const insideFence = (cut) => fences.some(([o, c]) => c - o <= limit && o < cut && cut < c);
7811
+ for (const [needle, width] of [
7812
+ ["\n\n", 2],
7813
+ ["\n", 1],
7814
+ [" ", 1]
7815
+ ]) {
7816
+ let idx = text.lastIndexOf(needle, end - width);
7817
+ while (idx > start) {
7818
+ const cut = idx + width;
7819
+ if (!insideFence(cut)) return cut;
7820
+ idx = text.lastIndexOf(needle, idx - 1);
7821
+ }
7822
+ }
7823
+ return surrogateSafe(text, end);
7824
+ }
7825
+ function chunkForTelegram(text, limit = TELEGRAM_TEXT_LIMIT) {
7826
+ if (text.length <= limit) return [text];
7827
+ const fences = fenceRanges(text);
7828
+ const chunks = [];
7829
+ let start = 0;
7830
+ while (text.length - start > limit) {
7831
+ const cut = cutPoint(text, start, limit, fences);
7832
+ chunks.push(text.slice(start, cut));
7833
+ start = cut;
7834
+ }
7835
+ chunks.push(text.slice(start));
7836
+ return chunks;
7837
+ }
7838
+
7779
7839
  // app/lib/telegram/outbound/outbound-census.ts
7780
7840
  var WINDOW_MS = 60 * 60 * 1e3;
7781
7841
  var records = [];
@@ -7829,30 +7889,31 @@ async function sendTelegramText(botToken, chatId, text, messageThreadId, busines
7829
7889
  console.error(
7830
7890
  `${TAG11} op=error botId=${botId} chatId=${chatId} stage=rich description="${richError}"`
7831
7891
  );
7832
- console.error(`${TAG11} op=fallback botId=${botId} chatId=${chatId} reason="${richError}"`);
7833
- try {
7834
- const data = await post(botToken, "sendMessage", {
7835
- chat_id: chatId,
7836
- text,
7837
- ...thread,
7838
- ...businessConnectionId ? { business_connection_id: businessConnectionId } : {}
7839
- });
7840
- if (data.ok) {
7841
- noteTelegramOutbound("fallback", Date.now());
7842
- return { ok: true };
7892
+ const chunks = chunkForTelegram(text);
7893
+ console.error(
7894
+ `${TAG11} op=fallback botId=${botId} chatId=${chatId} chunks=${chunks.length} reason="${richError}"`
7895
+ );
7896
+ for (let i = 0; i < chunks.length; i += 1) {
7897
+ let error = "";
7898
+ try {
7899
+ const data = await post(botToken, "sendMessage", {
7900
+ chat_id: chatId,
7901
+ text: chunks[i],
7902
+ ...thread,
7903
+ ...businessConnectionId ? { business_connection_id: businessConnectionId } : {}
7904
+ });
7905
+ if (data.ok) continue;
7906
+ error = data.description ?? "send failed";
7907
+ } catch (e) {
7908
+ error = e instanceof Error ? e.message : String(e);
7843
7909
  }
7844
- const error = data.description ?? "send failed";
7845
7910
  console.error(
7846
- `${TAG11} op=error botId=${botId} chatId=${chatId} stage=plain description="${error}"`
7847
- );
7848
- return { ok: false, error };
7849
- } catch (e) {
7850
- const error = e instanceof Error ? e.message : String(e);
7851
- console.error(
7852
- `${TAG11} op=error botId=${botId} chatId=${chatId} stage=plain description="${error}"`
7911
+ `${TAG11} op=error botId=${botId} chatId=${chatId} stage=plain chunk=${i + 1}/${chunks.length} description="${error}"`
7853
7912
  );
7854
7913
  return { ok: false, error };
7855
7914
  }
7915
+ noteTelegramOutbound("fallback", Date.now());
7916
+ return { ok: true };
7856
7917
  }
7857
7918
 
7858
7919
  // app/lib/telegram/outbound/send-chat-action.ts
@@ -15207,6 +15268,7 @@ function runTelegramStoreCensus() {
15207
15268
 
15208
15269
  // app/lib/telegram/reach-census.ts
15209
15270
  var import_dist4 = __toESM(require_dist2(), 1);
15271
+ import { existsSync as existsSync19 } from "fs";
15210
15272
  import { join as join27 } from "path";
15211
15273
  function collectTelegramReachCensus(accounts) {
15212
15274
  const out = {
@@ -15231,8 +15293,9 @@ function collectTelegramReachCensus(accounts) {
15231
15293
  }
15232
15294
  function runTelegramReachCensus(accounts) {
15233
15295
  const c = collectTelegramReachCensus(accounts);
15296
+ const root = STORE_ROOT2();
15234
15297
  console.error(
15235
- `[telegram-reach-census] accounts=${c.accounts} bots=${c.bots} chatsKnown=${c.chatsKnown} botsWithNoChats=${c.botsWithNoChats}`
15298
+ `[telegram-reach-census] accounts=${c.accounts} bots=${c.bots} chatsKnown=${c.chatsKnown} botsWithNoChats=${c.botsWithNoChats} storeRoot=${root} exists=${existsSync19(root)}`
15236
15299
  );
15237
15300
  return c;
15238
15301
  }
@@ -15247,10 +15310,6 @@ function noteCheckoutArrived(botId, queryId, now) {
15247
15310
  arrived += 1;
15248
15311
  outstanding.set(queryId, { botId, arrivedAt: now });
15249
15312
  }
15250
- function noteCheckoutAnswered(queryId) {
15251
- if (!outstanding.delete(queryId)) return;
15252
- answered += 1;
15253
- }
15254
15313
  function readTelegramCheckoutCensus(now) {
15255
15314
  let oldestUnansweredMs = 0;
15256
15315
  for (const o of outstanding.values()) {
@@ -15355,7 +15414,7 @@ function readWaOperatorTurns() {
15355
15414
  }
15356
15415
 
15357
15416
  // server/routes/session-reader.ts
15358
- import { readFileSync as readFileSync22, watch as watch4, statSync as statSync15, existsSync as existsSync19, readdirSync as readdirSync14, realpathSync as realpathSync5 } from "fs";
15417
+ import { readFileSync as readFileSync22, watch as watch4, statSync as statSync15, existsSync as existsSync20, readdirSync as readdirSync14, realpathSync as realpathSync5 } from "fs";
15359
15418
  import { isAbsolute as isAbsolute2, join as join29, relative as relative3, resolve as resolve21, sep as sep5 } from "path";
15360
15419
 
15361
15420
  // server/routes/admin/manager-client.ts
@@ -15572,7 +15631,7 @@ data: ${JSON.stringify(turn)}
15572
15631
  const sessionKey = c.req.query("session_key") ?? "";
15573
15632
  const subagentsDir = resolve21(join29(projectDir, sessionId, "subagents"));
15574
15633
  console.log(
15575
- `[webchat-activity] op=watch-subagents key=${sessionKey} dir=${subagentsDir} exists=${existsSync19(subagentsDir)}`
15634
+ `[webchat-activity] op=watch-subagents key=${sessionKey} dir=${subagentsDir} exists=${existsSync20(subagentsDir)}`
15576
15635
  );
15577
15636
  const actx = makeActivityCtx({
15578
15637
  subagentsDir,
@@ -15779,7 +15838,7 @@ app7.get("/directives", requireAdminSession, (c) => {
15779
15838
  const sessionId = c.req.query("sessionId") ?? "";
15780
15839
  if (!SESSION_ID_RE2.test(sessionId)) return c.json({ error: "bad session reference" }, 400);
15781
15840
  const dir = directiveStoreDir(sessionId);
15782
- if (!dir || !existsSync19(dir)) return c.json({ entries: [] });
15841
+ if (!dir || !existsSync20(dir)) return c.json({ entries: [] });
15783
15842
  let names;
15784
15843
  try {
15785
15844
  names = readdirSync14(dir).filter((n) => DIRECTIVE_NAME_RE.test(n));
@@ -16675,7 +16734,7 @@ var public_reader_default = app9;
16675
16734
  // server/routes/webchat.ts
16676
16735
  import { basename as basename11, dirname as dirname11 } from "path";
16677
16736
  import { join as join34 } from "path";
16678
- import { existsSync as existsSync22, readdirSync as readdirSync18, readFileSync as readFileSync27, renameSync as renameSync4, statSync as statSync18, writeFileSync as writeFileSync11 } from "fs";
16737
+ import { existsSync as existsSync23, readdirSync as readdirSync18, readFileSync as readFileSync27, renameSync as renameSync4, statSync as statSync18, writeFileSync as writeFileSync11 } from "fs";
16679
16738
 
16680
16739
  // server/canonical-webchat-override.ts
16681
16740
  import { readFileSync as readFileSync25, writeFileSync as writeFileSync9, renameSync as renameSync2 } from "fs";
@@ -16787,7 +16846,7 @@ function isNewSessionEffortLevel(value) {
16787
16846
  }
16788
16847
 
16789
16848
  // ../services/claude-session-manager/src/sidecar-store.ts
16790
- import { existsSync as existsSync21, mkdirSync as mkdirSync4, readdirSync as readdirSync17, readFileSync as readFileSync26, renameSync as renameSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync10 } from "fs";
16849
+ import { existsSync as existsSync22, mkdirSync as mkdirSync4, readdirSync as readdirSync17, readFileSync as readFileSync26, renameSync as renameSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync10 } from "fs";
16791
16850
  import { join as join33 } from "path";
16792
16851
  function escapeRegExp(s) {
16793
16852
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -16808,7 +16867,7 @@ function createSidecarStore(config) {
16808
16867
  return { ok: true };
16809
16868
  } catch (error) {
16810
16869
  try {
16811
- if (existsSync21(tmp)) unlinkSync2(tmp);
16870
+ if (existsSync22(tmp)) unlinkSync2(tmp);
16812
16871
  } catch {
16813
16872
  }
16814
16873
  return { ok: false, error };
@@ -16864,7 +16923,7 @@ function createSidecarStore(config) {
16864
16923
  function clear(sessionsDir, id) {
16865
16924
  const path = pathFor(sessionsDir, id);
16866
16925
  try {
16867
- if (existsSync21(path)) {
16926
+ if (existsSync22(path)) {
16868
16927
  unlinkSync2(path);
16869
16928
  return { ok: true, removed: true };
16870
16929
  }
@@ -16960,7 +17019,7 @@ function locateSidecar(sessionId) {
16960
17019
  }
16961
17020
  for (const slug of slugs) {
16962
17021
  const metaPath = join34(projectsRoot, slug, `${sessionId}.meta.json`);
16963
- if (existsSync22(metaPath)) return readSidecarMeta(metaPath);
17022
+ if (existsSync23(metaPath)) return readSidecarMeta(metaPath);
16964
17023
  }
16965
17024
  return null;
16966
17025
  }
@@ -17553,10 +17612,10 @@ ${note}` : note;
17553
17612
  import { resolve as resolve24 } from "path";
17554
17613
 
17555
17614
  // app/lib/claude-agent/specialist-roster.ts
17556
- import { existsSync as existsSync23, readFileSync as readFileSync28, readdirSync as readdirSync19 } from "fs";
17615
+ import { existsSync as existsSync24, readFileSync as readFileSync28, readdirSync as readdirSync19 } from "fs";
17557
17616
  import { join as join35 } from "path";
17558
17617
  function listSpecialistCardNames(specialistsDir) {
17559
- if (!existsSync23(specialistsDir)) return [];
17618
+ if (!existsSync24(specialistsDir)) return [];
17560
17619
  return readdirSync19(specialistsDir).filter((f) => f.endsWith(".md")).map((f) => f.slice(0, -3)).sort();
17561
17620
  }
17562
17621
  function field(fm, name) {
@@ -17569,7 +17628,7 @@ function field(fm, name) {
17569
17628
  return value || null;
17570
17629
  }
17571
17630
  function readSpecialistRoster(specialistsDir) {
17572
- if (!existsSync23(specialistsDir)) return { specialists: [], skipped: [] };
17631
+ if (!existsSync24(specialistsDir)) return { specialists: [], skipped: [] };
17573
17632
  const entries2 = readdirSync19(specialistsDir);
17574
17633
  const specialists = [];
17575
17634
  const skipped = [];
@@ -17693,13 +17752,13 @@ function r2n(value) {
17693
17752
  var webchat_greeting_default = app10;
17694
17753
 
17695
17754
  // server/routes/telegram.ts
17696
- import { homedir as homedir3 } from "os";
17755
+ import { homedir as homedir2 } from "os";
17697
17756
  import { resolve as resolve25, join as join40 } from "path";
17698
- import { existsSync as existsSync27, readFileSync as readFileSync32 } from "fs";
17757
+ import { existsSync as existsSync28, readFileSync as readFileSync32 } from "fs";
17699
17758
 
17700
17759
  // ../lib/telegram-managed-bot/src/index.ts
17701
17760
  import { randomBytes } from "crypto";
17702
- import { existsSync as existsSync24, readFileSync as readFileSync29, writeFileSync as writeFileSync12, mkdirSync as mkdirSync5 } from "fs";
17761
+ import { existsSync as existsSync25, readFileSync as readFileSync29, writeFileSync as writeFileSync12, mkdirSync as mkdirSync5 } from "fs";
17703
17762
  import { dirname as dirname12, join as join36 } from "path";
17704
17763
  var TELEGRAM_API = "https://api.telegram.org";
17705
17764
  var TELEGRAM_ALLOWED_UPDATES = [
@@ -17768,7 +17827,7 @@ async function setTelegramWebhook(botToken, webhookUrl, secretFilePath, fetchImp
17768
17827
  }
17769
17828
  function writeTelegramBotEntry(accountDir, entry2) {
17770
17829
  const configPath3 = join36(accountDir, "account.json");
17771
- if (!existsSync24(configPath3)) {
17830
+ if (!existsSync25(configPath3)) {
17772
17831
  return { ok: false, error: `account.json not found at ${configPath3}` };
17773
17832
  }
17774
17833
  let config;
@@ -18966,25 +19025,6 @@ async function answerTelegramCallback(botToken, callbackQueryId, text) {
18966
19025
  }
18967
19026
  }
18968
19027
 
18969
- // app/lib/telegram/outbound/answer-precheckout.ts
18970
- async function answerTelegramPreCheckout(botToken, preCheckoutQueryId, ok2, errorMessage) {
18971
- try {
18972
- const res = await fetch(`https://api.telegram.org/bot${botToken}/answerPreCheckoutQuery`, {
18973
- method: "POST",
18974
- headers: { "Content-Type": "application/json" },
18975
- body: JSON.stringify({
18976
- pre_checkout_query_id: preCheckoutQueryId,
18977
- ok: ok2,
18978
- ...ok2 ? {} : { error_message: errorMessage ?? "This payment cannot be completed." }
18979
- })
18980
- });
18981
- const data = await res.json();
18982
- return data.ok ? { ok: true } : { ok: false, error: data.description ?? "answer failed" };
18983
- } catch (e) {
18984
- return { ok: false, error: e instanceof Error ? e.message : String(e) };
18985
- }
18986
- }
18987
-
18988
19028
  // app/lib/telegram/inbound/notify-gate.ts
18989
19029
  function decideTelegramNotify(input) {
18990
19030
  if (input.messageId === null) return { emit: false, reason: "no-id" };
@@ -19599,7 +19639,7 @@ async function handleDispatchMedia(p) {
19599
19639
  }
19600
19640
 
19601
19641
  // app/lib/telegram/live-location.ts
19602
- import { existsSync as existsSync25, mkdirSync as mkdirSync6, readFileSync as readFileSync30, readdirSync as readdirSync20, statSync as statSync19, writeFileSync as writeFileSync13 } from "fs";
19642
+ import { existsSync as existsSync26, mkdirSync as mkdirSync6, readFileSync as readFileSync30, readdirSync as readdirSync20, statSync as statSync19, writeFileSync as writeFileSync13 } from "fs";
19603
19643
  import { join as join38 } from "path";
19604
19644
  var TAG32 = "[telegram-inbound]";
19605
19645
  var LIVE_LOCATION_FILE = "telegram-live-location.json";
@@ -19613,7 +19653,7 @@ function isRecord(v) {
19613
19653
  return typeof r.lat === "number" && Number.isFinite(r.lat) && typeof r.lon === "number" && Number.isFinite(r.lon) && typeof r.at === "number" && Number.isFinite(r.at) && typeof r.botId === "string" && typeof r.livePeriodS === "number" && Number.isFinite(r.livePeriodS);
19614
19654
  }
19615
19655
  function readAll(path) {
19616
- if (!existsSync25(path)) return {};
19656
+ if (!existsSync26(path)) return {};
19617
19657
  try {
19618
19658
  const parsed = JSON.parse(readFileSync30(path, "utf-8"));
19619
19659
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
@@ -19683,7 +19723,7 @@ function liveLocationCensusLine(accountsRoot, now) {
19683
19723
  try {
19684
19724
  for (const entry2 of readdirSync20(accountsRoot)) {
19685
19725
  const path = join38(accountsRoot, entry2, LIVE_LOCATION_FILE);
19686
- if (!existsSync25(path) || !statSync19(path).isFile()) continue;
19726
+ if (!existsSync26(path) || !statSync19(path).isFile()) continue;
19687
19727
  for (const rec of Object.values(readAll(path))) {
19688
19728
  records3 += 1;
19689
19729
  if (isExpired(rec, now)) expired += 1;
@@ -19702,7 +19742,7 @@ function liveLocationCensusLine(accountsRoot, now) {
19702
19742
  }
19703
19743
 
19704
19744
  // app/lib/telegram/business-connection.ts
19705
- import { existsSync as existsSync26, mkdirSync as mkdirSync7, readFileSync as readFileSync31, writeFileSync as writeFileSync14 } from "fs";
19745
+ import { existsSync as existsSync27, mkdirSync as mkdirSync7, readFileSync as readFileSync31, writeFileSync as writeFileSync14 } from "fs";
19706
19746
  import { join as join39 } from "path";
19707
19747
  var TAG33 = "[telegram-inbound]";
19708
19748
  var BUSINESS_CONNECTION_FILE = "telegram-business-connection.json";
@@ -19715,7 +19755,7 @@ function isRecord2(v) {
19715
19755
  return typeof r.id === "string" && r.id.length > 0 && typeof r.isEnabled === "boolean";
19716
19756
  }
19717
19757
  function readAll2(path) {
19718
- if (!existsSync26(path)) return {};
19758
+ if (!existsSync27(path)) return {};
19719
19759
  try {
19720
19760
  const parsed = JSON.parse(readFileSync31(path, "utf-8"));
19721
19761
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
@@ -19836,10 +19876,10 @@ function entryActive(entry2, accountDir, botId, noteSpecialist) {
19836
19876
  function logValue2(v) {
19837
19877
  return v.replace(/[\r\n]+/g, " ");
19838
19878
  }
19839
- function configDirName2() {
19879
+ function configDirName() {
19840
19880
  const platformRoot5 = process.env.MAXY_PLATFORM_ROOT ?? resolve25(process.cwd(), "..");
19841
19881
  const brandPath = join40(platformRoot5, "config", "brand.json");
19842
- if (existsSync27(brandPath)) {
19882
+ if (existsSync28(brandPath)) {
19843
19883
  try {
19844
19884
  return JSON.parse(readFileSync32(brandPath, "utf-8")).configDir ?? ".maxy";
19845
19885
  } catch {
@@ -19848,7 +19888,7 @@ function configDirName2() {
19848
19888
  return ".maxy";
19849
19889
  }
19850
19890
  function telegramSecretsDir() {
19851
- return resolve25(homedir3(), configDirName2(), "telegram-secrets");
19891
+ return resolve25(homedir2(), configDirName(), "telegram-secrets");
19852
19892
  }
19853
19893
  function secretPath(botId) {
19854
19894
  return resolve25(telegramSecretsDir(), botId);
@@ -19947,7 +19987,7 @@ app11.post("/", async (c) => {
19947
19987
  const agentSlug = entryAgentSlug(entry2);
19948
19988
  console.error(`${TAG34} op=entry botId=${botId} accountId=${accountId} role=${entry2.role} agent=${agentSlug}`);
19949
19989
  const sp = secretPath(botId);
19950
- if (!existsSync27(sp)) {
19990
+ if (!existsSync28(sp)) {
19951
19991
  console.error(`${TAG34} op=secret botId=${botId} result=missing-file`);
19952
19992
  return c.json({ ok: false }, 401);
19953
19993
  }
@@ -20250,69 +20290,19 @@ app11.post("/", async (c) => {
20250
20290
  return c.json({ ok: true }, 200);
20251
20291
  }
20252
20292
  if (decision.kind === "checkout") {
20253
- const cKey = telegramChannelKey(botId, decision.senderId);
20254
20293
  if (decision.query === "pre-checkout") {
20255
20294
  console.error(
20256
20295
  `${TAG34} op=precheckout-received botId=${botId} queryId=${decision.queryId} payload=${logValue2(decision.payload)} amount=${decision.amount ?? "none"} currency=${decision.currency ?? "none"}`
20257
20296
  );
20258
20297
  noteCheckoutArrived(botId, decision.queryId, Date.now());
20259
- const answerStartedAt = Date.now();
20260
- const answered4 = decision.allowed ? await answerTelegramPreCheckout(entry2.token, decision.queryId, true) : await answerTelegramPreCheckout(
20261
- entry2.token,
20262
- decision.queryId,
20263
- false,
20264
- "This account cannot complete a payment here."
20265
- );
20266
- if (answered4.ok) noteCheckoutAnswered(decision.queryId);
20267
- console.error(
20268
- `${TAG34} op=precheckout-answered botId=${botId} queryId=${decision.queryId} ms=${Date.now() - answerStartedAt} ok=${answered4.ok} outcome=${!answered4.ok ? "error" : decision.allowed ? "accepted" : "refused"}${answered4.error ? ` error=${logValue2(answered4.error)}` : ""}`
20269
- );
20270
20298
  } else {
20271
20299
  console.error(
20272
20300
  `${TAG34} op=shipping-received botId=${botId} queryId=${decision.queryId} payload=${logValue2(decision.payload)}`
20273
20301
  );
20274
20302
  }
20275
20303
  console.error(
20276
- `${TAG34} op=checkout-authorised botId=${botId} senderId=${decision.senderId} allowed=${decision.allowed} reason=${decision.reason}`
20304
+ `${TAG34} op=checkout-ignored botId=${botId} senderId=${decision.senderId} queryId=${decision.queryId} query=${decision.query} allowed=${decision.allowed} reason=payments-removed`
20277
20305
  );
20278
- if (!decision.allowed) return c.json({ ok: true }, 200);
20279
- const cScope = entry2.role === "admin" ? "admin" : "public";
20280
- const cSession = telegramAdminSessionId(accountId, decision.senderId, botId);
20281
- const cAt = (/* @__PURE__ */ new Date()).toISOString();
20282
- const cBody = decision.query === "pre-checkout" ? `[pre-checkout approved: ${decision.amount ?? 0} ${decision.currency ?? "unknown"}, payload=${decision.payload}]` : `[shipping query: payload=${decision.payload}, queryId=${decision.queryId} \u2014 answer with telegram-invoice answerShipping]`;
20283
- appendMessage2(accountId, {
20284
- messageId: `telegram:${accountId}:${cKey}:checkout:${decision.queryId}`,
20285
- sessionId: cSession,
20286
- dateSent: cAt,
20287
- body: cBody,
20288
- fromMe: false,
20289
- senderId: decision.senderId,
20290
- senderName: decision.senderDisplay,
20291
- chatId: String(decision.chatId),
20292
- channelKey: cKey,
20293
- scope: cScope,
20294
- origin: "inbound",
20295
- createdAt: cAt
20296
- });
20297
- const cActive = entryActive(entry2, accountDir, botId);
20298
- console.error(`${TAG34} op=agent botId=${botId} slug=${agentSlug} active=${cActive}`);
20299
- raiseChannelTurn({
20300
- accountId,
20301
- accountDir,
20302
- botId,
20303
- botToken: entry2.token,
20304
- role: entry2.role,
20305
- agentSlug,
20306
- specialist: entry2.role === "specialist" ? entry2.specialist : null,
20307
- active: cActive,
20308
- senderId: decision.senderId,
20309
- senderDisplay: decision.senderDisplay,
20310
- chatId: decision.chatId,
20311
- text: cBody,
20312
- channelKey: cKey,
20313
- scope: cScope,
20314
- sessionId: cSession
20315
- });
20316
20306
  return c.json({ ok: true }, 200);
20317
20307
  }
20318
20308
  if (decision.kind === "subscription") {
@@ -20928,7 +20918,7 @@ function mountTelegramRoutes(app81, telegramRoutes) {
20928
20918
 
20929
20919
  // server/routes/quickbooks.ts
20930
20920
  import { join as join41 } from "path";
20931
- import { existsSync as existsSync28, readFileSync as readFileSync33, writeFileSync as writeFileSync15, mkdirSync as mkdirSync8, rmSync as rmSync4, renameSync as renameSync5 } from "fs";
20921
+ import { existsSync as existsSync29, readFileSync as readFileSync33, writeFileSync as writeFileSync15, mkdirSync as mkdirSync8, rmSync as rmSync4, renameSync as renameSync5 } from "fs";
20932
20922
  var TAG35 = "[quickbooks]";
20933
20923
  var INTUIT_TOKEN_URL = "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer";
20934
20924
  var STATE_RE = /^[A-Za-z0-9_-]+$/;
@@ -20941,7 +20931,7 @@ function storePath(accountDir) {
20941
20931
  async function completeConsent(args) {
20942
20932
  const { accountDir, code, realmId } = args;
20943
20933
  const state = args.state;
20944
- if (!state || !STATE_RE.test(state) || !existsSync28(pendingPath(accountDir, state))) {
20934
+ if (!state || !STATE_RE.test(state) || !existsSync29(pendingPath(accountDir, state))) {
20945
20935
  console.error(`${TAG35} op=callback state=${state ?? ""} stateValid=false realmId=${realmId ?? ""}`);
20946
20936
  return { ok: false, status: 400, message: "Invalid or unknown authorization state.", stateValid: false };
20947
20937
  }
@@ -20968,7 +20958,7 @@ async function completeConsent(args) {
20968
20958
  if (!code || !realmId) {
20969
20959
  return { ok: false, status: 400, message: "Missing code or realmId in the callback.", stateValid: true };
20970
20960
  }
20971
- if (!existsSync28(storePath(accountDir))) {
20961
+ if (!existsSync29(storePath(accountDir))) {
20972
20962
  return { ok: false, status: 500, message: "No QuickBooks credentials are stored for this account.", stateValid: true };
20973
20963
  }
20974
20964
  const store2 = JSON.parse(readFileSync33(storePath(accountDir), "utf-8"));
@@ -21036,7 +21026,7 @@ var quickbooks_default = app12;
21036
21026
 
21037
21027
  // server/routes/onboarding.ts
21038
21028
  import { spawn, spawnSync as spawnSync2, execFileSync as execFileSync4 } from "child_process";
21039
- import { openSync as openSync8, closeSync as closeSync8, appendFileSync as appendFileSync3, writeFileSync as writeFileSync17, writeSync, existsSync as existsSync30, readFileSync as readFileSync35, unlinkSync as unlinkSync3 } from "fs";
21029
+ import { openSync as openSync8, closeSync as closeSync8, appendFileSync as appendFileSync3, writeFileSync as writeFileSync17, writeSync, existsSync as existsSync31, readFileSync as readFileSync35, unlinkSync as unlinkSync3 } from "fs";
21040
21030
  import { createHash as createHash4, randomUUID as randomUUID4 } from "crypto";
21041
21031
 
21042
21032
  // app/lib/claude-spawn-env.ts
@@ -21176,7 +21166,7 @@ function readHostCredsBlob(service) {
21176
21166
  }
21177
21167
 
21178
21168
  // ../lib/admins-write/src/index.ts
21179
- import { existsSync as existsSync29, readFileSync as readFileSync34, writeFileSync as writeFileSync16, renameSync as renameSync6, mkdirSync as mkdirSync9, readdirSync as readdirSync21, statSync as statSync20, appendFileSync as appendFileSync2 } from "fs";
21169
+ import { existsSync as existsSync30, readFileSync as readFileSync34, writeFileSync as writeFileSync16, renameSync as renameSync6, mkdirSync as mkdirSync9, readdirSync as readdirSync21, statSync as statSync20, appendFileSync as appendFileSync2 } from "fs";
21180
21170
  import { dirname as dirname13, join as join42 } from "path";
21181
21171
  function id8(value) {
21182
21172
  return value.slice(0, 8);
@@ -21218,7 +21208,7 @@ function writeAdminEntry(input) {
21218
21208
  const result = { usersJsonResult: "noop", accountJsonResult: "noop" };
21219
21209
  try {
21220
21210
  let users = [];
21221
- if (existsSync29(input.usersFile)) {
21211
+ if (existsSync30(input.usersFile)) {
21222
21212
  const raw = readFileSync34(input.usersFile, "utf-8").trim();
21223
21213
  if (raw) {
21224
21214
  const parsed = JSON.parse(raw);
@@ -21262,7 +21252,7 @@ function writeAdminEntry(input) {
21262
21252
  }
21263
21253
  try {
21264
21254
  const accountJsonPath = join42(input.accountDir, "account.json");
21265
- if (!existsSync29(accountJsonPath)) {
21255
+ if (!existsSync30(accountJsonPath)) {
21266
21256
  throw new Error(`account.json not found at ${accountJsonPath}`);
21267
21257
  }
21268
21258
  const config = JSON.parse(readFileSync34(accountJsonPath, "utf-8"));
@@ -21285,7 +21275,7 @@ function writeAdminEntry(input) {
21285
21275
  function computeAdminStoreDivergence(input) {
21286
21276
  const result = { divergences: 0, accountWithoutUsers: [], usersWithoutAccount: [], errors: [] };
21287
21277
  const usersUserIds = /* @__PURE__ */ new Set();
21288
- if (existsSync29(input.usersFile)) {
21278
+ if (existsSync30(input.usersFile)) {
21289
21279
  try {
21290
21280
  const raw = readFileSync34(input.usersFile, "utf-8").trim();
21291
21281
  if (raw) {
@@ -21299,7 +21289,7 @@ function computeAdminStoreDivergence(input) {
21299
21289
  }
21300
21290
  }
21301
21291
  const accountUserIds = /* @__PURE__ */ new Set();
21302
- if (existsSync29(input.accountsDir)) {
21292
+ if (existsSync30(input.accountsDir)) {
21303
21293
  let entries2;
21304
21294
  try {
21305
21295
  entries2 = readdirSync21(input.accountsDir);
@@ -21316,7 +21306,7 @@ function computeAdminStoreDivergence(input) {
21316
21306
  continue;
21317
21307
  }
21318
21308
  const accountJsonPath = join42(accountDir, "account.json");
21319
- if (!existsSync29(accountJsonPath)) continue;
21309
+ if (!existsSync30(accountJsonPath)) continue;
21320
21310
  let admins = [];
21321
21311
  try {
21322
21312
  const config = JSON.parse(readFileSync34(accountJsonPath, "utf-8"));
@@ -21367,7 +21357,7 @@ function hashPin2(pin) {
21367
21357
  return createHash4("sha256").update(pin).digest("hex");
21368
21358
  }
21369
21359
  function readUsersFile2() {
21370
- if (!existsSync30(USERS_FILE)) return null;
21360
+ if (!existsSync31(USERS_FILE)) return null;
21371
21361
  const raw = readFileSync35(USERS_FILE, "utf-8").trim();
21372
21362
  if (!raw) return [];
21373
21363
  return JSON.parse(raw);
@@ -21459,7 +21449,7 @@ app13.post("/claude-auth", async (c) => {
21459
21449
  } catch (err) {
21460
21450
  logoutError = err instanceof Error ? err.message : String(err);
21461
21451
  }
21462
- const credentialsPresent = existsSync30(CLAUDE_CREDENTIALS_FILE);
21452
+ const credentialsPresent = existsSync31(CLAUDE_CREDENTIALS_FILE);
21463
21453
  const ranMs = Date.now() - start;
21464
21454
  console.log(`[onboarding] op=claude-logout credentialsPresent=${credentialsPresent} ranMs=${ranMs} logoutError=${logoutError ? JSON.stringify(logoutError.slice(0, 120)) : "none"}`);
21465
21455
  return c.json({ logged_out: !credentialsPresent });
@@ -21617,7 +21607,7 @@ app13.post("/set-pin", async (c) => {
21617
21607
  console.log(`[set-pin] wrote users.json + account.json admins: userId=${userId.slice(0, 8)}\u2026 role=owner`);
21618
21608
  if (process.platform === "linux") {
21619
21609
  let installOwner = null;
21620
- if (existsSync30(INSTALL_OWNER_FILE)) {
21610
+ if (existsSync31(INSTALL_OWNER_FILE)) {
21621
21611
  try {
21622
21612
  const raw = readFileSync35(INSTALL_OWNER_FILE, "utf-8").trim();
21623
21613
  if (raw.length > 0) installOwner = raw;
@@ -21765,7 +21755,7 @@ app13.put("/set-pin", requireAdminSession, async (c) => {
21765
21755
  console.log(`[set-pin] changed PIN in place: userId=${sessionUserId.slice(0, 8)}\u2026`);
21766
21756
  if (process.platform === "linux") {
21767
21757
  let installOwner = null;
21768
- if (existsSync30(INSTALL_OWNER_FILE)) {
21758
+ if (existsSync31(INSTALL_OWNER_FILE)) {
21769
21759
  try {
21770
21760
  const raw = readFileSync35(INSTALL_OWNER_FILE, "utf-8").trim();
21771
21761
  if (raw.length > 0) installOwner = raw;
@@ -22224,7 +22214,7 @@ app14.post("/probe", async (c) => {
22224
22214
  var field_default = app14;
22225
22215
 
22226
22216
  // server/routes/client-error.ts
22227
- import { appendFileSync as appendFileSync4, existsSync as existsSync31, renameSync as renameSync8, statSync as statSync21 } from "fs";
22217
+ import { appendFileSync as appendFileSync4, existsSync as existsSync32, renameSync as renameSync8, statSync as statSync21 } from "fs";
22228
22218
  import { join as join44 } from "path";
22229
22219
  var CLIENT_ERRORS_LOG = join44(LOG_DIR, "client-errors.log");
22230
22220
  var MAX_LOG_SIZE = 10 * 1024 * 1024;
@@ -22283,7 +22273,7 @@ function stackHead(stack) {
22283
22273
  }
22284
22274
  function rotateIfNeeded() {
22285
22275
  try {
22286
- if (!existsSync31(CLIENT_ERRORS_LOG)) return;
22276
+ if (!existsSync32(CLIENT_ERRORS_LOG)) return;
22287
22277
  const stats = statSync21(CLIENT_ERRORS_LOG);
22288
22278
  if (stats.size < MAX_LOG_SIZE) return;
22289
22279
  renameSync8(CLIENT_ERRORS_LOG, CLIENT_ERRORS_LOG + ".1");
@@ -22632,18 +22622,18 @@ app17.get("/", requireAdminSession, async (c) => {
22632
22622
  var accounts_default = app17;
22633
22623
 
22634
22624
  // server/routes/admin/logs.ts
22635
- import { existsSync as existsSync33, readdirSync as readdirSync22, readFileSync as readFileSync36, statSync as statSync22 } from "fs";
22625
+ import { existsSync as existsSync34, readdirSync as readdirSync22, readFileSync as readFileSync36, statSync as statSync22 } from "fs";
22636
22626
  import { resolve as resolve26, basename as basename13 } from "path";
22637
22627
 
22638
22628
  // app/lib/logs-read-resolve.ts
22639
- import { existsSync as existsSync32 } from "fs";
22629
+ import { existsSync as existsSync33 } from "fs";
22640
22630
  import { join as join45 } from "path";
22641
22631
  function resolveSessionLogPaths(filename, logDirs) {
22642
22632
  const tried = [filename];
22643
22633
  const hits = [];
22644
22634
  for (const dir of logDirs) {
22645
22635
  const fullPath = join45(dir, filename);
22646
- if (existsSync32(fullPath)) {
22636
+ if (existsSync33(fullPath)) {
22647
22637
  hits.push({ path: fullPath, dir });
22648
22638
  }
22649
22639
  }
@@ -22768,7 +22758,7 @@ app18.get("/", async (c) => {
22768
22758
  const seen = /* @__PURE__ */ new Set();
22769
22759
  const logs = {};
22770
22760
  for (const dir of logDirs) {
22771
- if (!existsSync33(dir)) continue;
22761
+ if (!existsSync34(dir)) continue;
22772
22762
  let files;
22773
22763
  try {
22774
22764
  files = readdirSync22(dir).filter((f) => f.endsWith(".log"));
@@ -22825,7 +22815,7 @@ var claude_info_default = app19;
22825
22815
 
22826
22816
  // server/routes/admin/attachment.ts
22827
22817
  import { readFile as readFile7, readdir as readdir2 } from "fs/promises";
22828
- import { existsSync as existsSync34 } from "fs";
22818
+ import { existsSync as existsSync35 } from "fs";
22829
22819
  import { resolve as resolve27 } from "path";
22830
22820
  var app20 = new Hono();
22831
22821
  var ATTACHMENT_ID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
@@ -22848,12 +22838,12 @@ app20.get("/:attachmentId", requireAdminSession, async (c) => {
22848
22838
  }
22849
22839
  let accountId = pinnedAccountId;
22850
22840
  let dir = uploadsDirFor(accountId, attachmentId);
22851
- let found = existsSync34(dir);
22841
+ let found = existsSync35(dir);
22852
22842
  if (!found) {
22853
22843
  for (const candidate of listValidAccounts()) {
22854
22844
  if (candidate.accountId === pinnedAccountId) continue;
22855
22845
  const candidateDir = uploadsDirFor(candidate.accountId, attachmentId);
22856
- if (existsSync34(candidateDir)) {
22846
+ if (existsSync35(candidateDir)) {
22857
22847
  accountId = candidate.accountId;
22858
22848
  dir = candidateDir;
22859
22849
  found = true;
@@ -22868,7 +22858,7 @@ app20.get("/:attachmentId", requireAdminSession, async (c) => {
22868
22858
  return new Response("Not found", { status: 404 });
22869
22859
  }
22870
22860
  const metaPath = resolve27(dir, `${attachmentId}.meta.json`);
22871
- if (!existsSync34(metaPath)) {
22861
+ if (!existsSync35(metaPath)) {
22872
22862
  return new Response("Not found", { status: 404 });
22873
22863
  }
22874
22864
  let meta;
@@ -22902,7 +22892,7 @@ var attachment_default = app20;
22902
22892
 
22903
22893
  // server/routes/admin/session-upload.ts
22904
22894
  import { readFile as readFile8 } from "fs/promises";
22905
- import { existsSync as existsSync35, statSync as statSync23 } from "fs";
22895
+ import { existsSync as existsSync36, statSync as statSync23 } from "fs";
22906
22896
  var app21 = new Hono();
22907
22897
  app21.get("/", requireAdminSession, async (c) => {
22908
22898
  const cacheKey = c.var.cacheKey;
@@ -22923,7 +22913,7 @@ app21.get("/", requireAdminSession, async (c) => {
22923
22913
  return c.json({ error: "Not found" }, 404);
22924
22914
  }
22925
22915
  const resolution = resolveClaudeUploadsPath(`${sessionId}/${file}`);
22926
- if (!resolution.ok || !existsSync35(resolution.absolute) || !statSync23(resolution.absolute).isFile()) {
22916
+ if (!resolution.ok || !existsSync36(resolution.absolute) || !statSync23(resolution.absolute).isFile()) {
22927
22917
  console.log(`[session-upload] op=miss session=${short2} file=${file} status=404 reason=absent`);
22928
22918
  return c.json({ error: "Not found" }, 404);
22929
22919
  }
@@ -22945,11 +22935,11 @@ var session_upload_default = app21;
22945
22935
 
22946
22936
  // server/routes/admin/agents.ts
22947
22937
  import { resolve as resolve28 } from "path";
22948
- import { readdirSync as readdirSync24, readFileSync as readFileSync38, existsSync as existsSync37, rmSync as rmSync5, renameSync as renameSync9, mkdirSync as mkdirSync10, writeFileSync as writeFileSync18, chmodSync } from "fs";
22938
+ import { readdirSync as readdirSync24, readFileSync as readFileSync38, existsSync as existsSync38, rmSync as rmSync5, renameSync as renameSync9, mkdirSync as mkdirSync10, writeFileSync as writeFileSync18, chmodSync } from "fs";
22949
22939
  import { execFileSync as execFileSync6 } from "child_process";
22950
22940
 
22951
22941
  // ../services/claude-session-manager/src/tool-surface.ts
22952
- import { readFileSync as readFileSync37, readdirSync as readdirSync23, statSync as statSync24, existsSync as existsSync36 } from "fs";
22942
+ import { readFileSync as readFileSync37, readdirSync as readdirSync23, statSync as statSync24, existsSync as existsSync37 } from "fs";
22953
22943
  import { createHash as createHash5 } from "crypto";
22954
22944
  import { join as join46 } from "path";
22955
22945
 
@@ -23195,7 +23185,7 @@ function parseMcpBlock(frontmatter, pluginDir) {
23195
23185
  function loadToolSurface(pluginsRoots) {
23196
23186
  const roots = Array.isArray(pluginsRoots) ? pluginsRoots : [pluginsRoots];
23197
23187
  for (const r of roots) {
23198
- if (!existsSync36(r)) throw new ToolSurfaceError("plugins-root-missing", r);
23188
+ if (!existsSync37(r)) throw new ToolSurfaceError("plugins-root-missing", r);
23199
23189
  }
23200
23190
  const admin = /* @__PURE__ */ new Set();
23201
23191
  const pub = /* @__PURE__ */ new Set();
@@ -23211,7 +23201,7 @@ function loadToolSurface(pluginsRoots) {
23211
23201
  return;
23212
23202
  }
23213
23203
  const manifestPath = join46(pluginDir, "PLUGIN.md");
23214
- if (!existsSync36(manifestPath)) return;
23204
+ if (!existsSync37(manifestPath)) return;
23215
23205
  const raw = readFileSync37(manifestPath, "utf-8");
23216
23206
  const frontmatter = extractFrontmatter(raw, plugin);
23217
23207
  const tools = parseToolsBlock(frontmatter, plugin);
@@ -23392,7 +23382,7 @@ function agentRiskClass(tools, riskByTool) {
23392
23382
  // server/routes/admin/agents.ts
23393
23383
  var SLUG_UNSAFE = (s) => s.includes("/") || s.includes("..") || s.includes("\\");
23394
23384
  function subdirs(dir) {
23395
- if (!existsSync37(dir)) return [];
23385
+ if (!existsSync38(dir)) return [];
23396
23386
  try {
23397
23387
  return readdirSync24(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
23398
23388
  } catch {
@@ -23413,7 +23403,7 @@ var SPECIALISTS_DIR = ["specialists", "agents"];
23413
23403
  var QUARANTINE_DIR = ["specialists", "agents-disabled"];
23414
23404
  var DISABLED_STORE = "agents-disabled.json";
23415
23405
  function loadRiskSurface() {
23416
- const roots = [resolve28(PLATFORM_ROOT, "plugins"), resolve28(PLATFORM_ROOT, "..", "premium-plugins")].filter((r) => existsSync37(r));
23406
+ const roots = [resolve28(PLATFORM_ROOT, "plugins"), resolve28(PLATFORM_ROOT, "..", "premium-plugins")].filter((r) => existsSync38(r));
23417
23407
  try {
23418
23408
  return { riskByTool: loadToolSurface(roots).riskByTool, failed: null };
23419
23409
  } catch (err) {
@@ -23425,7 +23415,7 @@ function loadRiskSurface() {
23425
23415
  }
23426
23416
  function readDisabledStoreStrict(accountDir) {
23427
23417
  const p = resolve28(accountDir, DISABLED_STORE);
23428
- if (!existsSync37(p)) return /* @__PURE__ */ new Set();
23418
+ if (!existsSync38(p)) return /* @__PURE__ */ new Set();
23429
23419
  const parsed = JSON.parse(readFileSync38(p, "utf-8"));
23430
23420
  if (!Array.isArray(parsed.disabled)) throw new Error("disabled is not an array");
23431
23421
  return new Set(parsed.disabled.filter((x) => typeof x === "string"));
@@ -23444,7 +23434,7 @@ function authoredAgentFiles(accountDir) {
23444
23434
  const byName = /* @__PURE__ */ new Map();
23445
23435
  for (const plugin of subdirs(pluginsDir)) {
23446
23436
  const dir = resolve28(pluginsDir, plugin, "agents");
23447
- if (!existsSync37(dir)) continue;
23437
+ if (!existsSync38(dir)) continue;
23448
23438
  try {
23449
23439
  for (const entry2 of readdirSync24(dir)) {
23450
23440
  if (!entry2.endsWith(".md")) continue;
@@ -23518,7 +23508,7 @@ function listShipped(accountDir, riskByTool, disabled, riskSurfaceFailed, author
23518
23508
  const dirs = shippedSourceDirs(accountDir);
23519
23509
  const names = /* @__PURE__ */ new Set();
23520
23510
  for (const dir of dirs) {
23521
- if (!existsSync37(dir)) continue;
23511
+ if (!existsSync38(dir)) continue;
23522
23512
  try {
23523
23513
  for (const entry2 of readdirSync24(dir)) if (entry2.endsWith(".md")) names.add(entry2);
23524
23514
  } catch (err) {
@@ -23530,7 +23520,7 @@ function listShipped(accountDir, riskByTool, disabled, riskSurfaceFailed, author
23530
23520
  let deduped = 0;
23531
23521
  let divergent = 0;
23532
23522
  for (const filename of [...names].sort()) {
23533
- const source = dirs.find((d) => existsSync37(resolve28(d, filename)));
23523
+ const source = dirs.find((d) => existsSync38(resolve28(d, filename)));
23534
23524
  if (!source) continue;
23535
23525
  const authoredPaths = source === dirs[0] || source === dirs[1] ? authoredFiles.get(filename) : void 0;
23536
23526
  if (authoredPaths) {
@@ -23607,7 +23597,7 @@ function listSpecialists(accountDir, riskByTool, riskSurfaceFailed) {
23607
23597
  let specialistsSkipped = 0;
23608
23598
  for (const plugin of subdirs(pluginsDir).sort()) {
23609
23599
  const agentsDirP = resolve28(pluginsDir, plugin, "agents");
23610
- if (!existsSync37(agentsDirP)) continue;
23600
+ if (!existsSync38(agentsDirP)) continue;
23611
23601
  let entries2;
23612
23602
  try {
23613
23603
  entries2 = readdirSync24(agentsDirP, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
@@ -23649,7 +23639,7 @@ function listSpecialists(accountDir, riskByTool, riskSurfaceFailed) {
23649
23639
  // have the surface claim an agent is stopped while it is still being
23650
23640
  // spawned. Absence from the live dir alone is also not the test: a
23651
23641
  // specialist that was never activated was never switched off either.
23652
- disabled: existsSync37(resolve28(accountDir, ...QUARANTINE_DIR, entry2.name)) && !existsSync37(resolve28(accountDir, ...SPECIALISTS_DIR, entry2.name))
23642
+ disabled: existsSync38(resolve28(accountDir, ...QUARANTINE_DIR, entry2.name)) && !existsSync38(resolve28(accountDir, ...SPECIALISTS_DIR, entry2.name))
23653
23643
  });
23654
23644
  } catch {
23655
23645
  specialistsSkipped++;
@@ -23677,14 +23667,14 @@ app22.get("/", requireAdminSession, (c) => {
23677
23667
  const agents = [];
23678
23668
  let skipped = 0;
23679
23669
  const agentsDir = resolve28(account.accountDir, "agents");
23680
- if (existsSync37(agentsDir)) {
23670
+ if (existsSync38(agentsDir)) {
23681
23671
  try {
23682
23672
  const entries2 = readdirSync24(agentsDir, { withFileTypes: true });
23683
23673
  for (const entry2 of entries2.sort((a, b) => a.name.localeCompare(b.name))) {
23684
23674
  if (!entry2.isDirectory()) continue;
23685
23675
  if (entry2.name === "admin") continue;
23686
23676
  const configPath3 = resolve28(agentsDir, entry2.name, "config.json");
23687
- if (!existsSync37(configPath3)) continue;
23677
+ if (!existsSync38(configPath3)) continue;
23688
23678
  try {
23689
23679
  const config = JSON.parse(readFileSync38(configPath3, "utf-8"));
23690
23680
  agents.push({
@@ -23766,7 +23756,7 @@ app22.get("/:slug", requireAdminSession, (c) => {
23766
23756
  if (SLUG_UNSAFE(slug)) return c.json({ error: "Invalid agent slug" }, 400);
23767
23757
  if (c.req.query("origin") === "shipped") {
23768
23758
  const dirs = shippedSourceDirs(account.accountDir);
23769
- const source = dirs.find((d) => existsSync37(resolve28(d, `${slug}.md`)));
23759
+ const source = dirs.find((d) => existsSync38(resolve28(d, `${slug}.md`)));
23770
23760
  if (!source) return c.json({ error: "Agent not found" }, 404);
23771
23761
  const { fm, body } = splitFrontmatter(readFileSync38(resolve28(source, `${slug}.md`), "utf-8"));
23772
23762
  const { riskByTool, failed: failed2 } = loadRiskSurface();
@@ -23799,7 +23789,7 @@ app22.get("/:slug", requireAdminSession, (c) => {
23799
23789
  if (pluginParam) {
23800
23790
  if (SLUG_UNSAFE(pluginParam)) return c.json({ error: "Invalid plugin" }, 400);
23801
23791
  const file = resolve28(account.accountDir, "plugins", pluginParam, "agents", `${slug}.md`);
23802
- if (!existsSync37(file)) return c.json({ error: "Agent not found" }, 404);
23792
+ if (!existsSync38(file)) return c.json({ error: "Agent not found" }, 404);
23803
23793
  const { fm, body } = splitFrontmatter(readFileSync38(file, "utf-8"));
23804
23794
  const skills = subdirs(resolve28(account.accountDir, "plugins", pluginParam, "skills"));
23805
23795
  const { riskByTool, failed: failed2 } = loadRiskSurface();
@@ -23830,7 +23820,7 @@ app22.get("/:slug", requireAdminSession, (c) => {
23830
23820
  }
23831
23821
  const agentDir = resolve28(account.accountDir, "agents", slug);
23832
23822
  const configPath3 = resolve28(agentDir, "config.json");
23833
- if (!existsSync37(configPath3)) return c.json({ error: "Agent not found" }, 404);
23823
+ if (!existsSync38(configPath3)) return c.json({ error: "Agent not found" }, 404);
23834
23824
  let config;
23835
23825
  try {
23836
23826
  config = JSON.parse(readFileSync38(configPath3, "utf-8"));
@@ -23843,7 +23833,7 @@ app22.get("/:slug", requireAdminSession, (c) => {
23843
23833
  for (const { file, key: key2 } of OWNED_DOCS) {
23844
23834
  const p = resolve28(agentDir, file);
23845
23835
  try {
23846
- if (existsSync37(p)) {
23836
+ if (existsSync38(p)) {
23847
23837
  docs[key2] = readFileSync38(p, "utf-8");
23848
23838
  present[key2] = true;
23849
23839
  } else {
@@ -23904,7 +23894,7 @@ function reconcileRoutingProse(accountDir, accountId, op, slug) {
23904
23894
  }
23905
23895
  function reconcileAuthoredRoutingLine(accountDir, accountId, op, source) {
23906
23896
  const agentsMd = resolve28(accountDir, "agents", "admin", "AGENTS.md");
23907
- if (!existsSync37(agentsMd) || !existsSync37(source)) return false;
23897
+ if (!existsSync38(agentsMd) || !existsSync38(source)) return false;
23908
23898
  try {
23909
23899
  const { fm } = splitFrontmatter(readFileSync38(source, "utf-8"));
23910
23900
  if (!fm.name) return false;
@@ -23933,7 +23923,7 @@ app22.post("/:slug/disable", async (c) => {
23933
23923
  console.error(`[admin/agents] op=disable accountId=${resolved.accountId.slice(0, 8)} slug=${slug} origin=not-authored eligible=false outcome=refused reason=not-user-created`);
23934
23924
  return c.json({ error: "Only an agent you created can be switched off here. A shipped agent is stopped by suspending the routines that dispatch it." }, 404);
23935
23925
  }
23936
- if (!existsSync37(live)) {
23926
+ if (!existsSync38(live)) {
23937
23927
  console.error(`[admin/agents] op=disable accountId=${resolved.accountId.slice(0, 8)} slug=${slug} origin=specialist eligible=true outcome=refused reason=not-dispatchable`);
23938
23928
  return c.json({ error: "This agent is not in the dispatchable set, so there is nothing to switch off." }, 409);
23939
23929
  }
@@ -23962,7 +23952,7 @@ app22.post("/:slug/enable", async (c) => {
23962
23952
  let restored = false;
23963
23953
  try {
23964
23954
  if (authored) {
23965
- if (!existsSync37(quarantined)) {
23955
+ if (!existsSync38(quarantined)) {
23966
23956
  console.error(`[admin/agents] op=enable accountId=${resolved.accountId.slice(0, 8)} slug=${slug} origin=specialist eligible=true outcome=refused reason=not-disabled`);
23967
23957
  return c.json({ error: "This agent is not disabled" }, 404);
23968
23958
  }
@@ -23971,11 +23961,11 @@ app22.post("/:slug/enable", async (c) => {
23971
23961
  restored = true;
23972
23962
  } else {
23973
23963
  const disabled = readDisabledStoreStrict(resolved.accountDir);
23974
- if (!existsSync37(quarantined) && !disabled.has(filename)) {
23964
+ if (!existsSync38(quarantined) && !disabled.has(filename)) {
23975
23965
  console.error(`[admin/agents] op=enable accountId=${resolved.accountId.slice(0, 8)} slug=${slug} origin=shipped eligible=true outcome=refused reason=not-disabled`);
23976
23966
  return c.json({ error: "This agent is not disabled" }, 404);
23977
23967
  }
23978
- if (existsSync37(quarantined)) {
23968
+ if (existsSync38(quarantined)) {
23979
23969
  mkdirSync10(resolve28(resolved.accountDir, ...SPECIALISTS_DIR), { recursive: true });
23980
23970
  renameSync9(quarantined, live);
23981
23971
  restored = true;
@@ -24018,7 +24008,7 @@ app22.delete("/:slug", async (c) => {
24018
24008
  return c.json({ error: "Not authorized for this account" }, 403);
24019
24009
  }
24020
24010
  const agentDir = resolve28(account.accountDir, "agents", slug);
24021
- if (!existsSync37(agentDir)) {
24011
+ if (!existsSync38(agentDir)) {
24022
24012
  return c.json({ error: "Agent not found" }, 404);
24023
24013
  }
24024
24014
  try {
@@ -24061,7 +24051,7 @@ app22.post("/:slug/project", async (c) => {
24061
24051
  return c.json({ error: "Not authorized for this account" }, 403);
24062
24052
  }
24063
24053
  const agentDir = resolve28(account.accountDir, "agents", slug);
24064
- if (!existsSync37(agentDir)) {
24054
+ if (!existsSync38(agentDir)) {
24065
24055
  console.error(`[admin/agents] op=project rejected reason=agent-not-on-disk accountId=${account.accountId.slice(0, 8)} slug=${slug} probed=${agentDir}`);
24066
24056
  return c.json({ error: "Agent not found on disk" }, 404);
24067
24057
  }
@@ -24080,7 +24070,7 @@ var agents_default = app22;
24080
24070
  // server/routes/admin/sessions.ts
24081
24071
  import crypto2 from "crypto";
24082
24072
  import { resolve as resolvePath } from "path";
24083
- import { existsSync as existsSync38, mkdirSync as mkdirSync11, createWriteStream } from "fs";
24073
+ import { existsSync as existsSync39, mkdirSync as mkdirSync11, createWriteStream } from "fs";
24084
24074
 
24085
24075
  // ../lib/admin-conversation-purge/src/index.ts
24086
24076
  async function purgeAdminConversationJsonls(args) {
@@ -24218,7 +24208,7 @@ var replayJsonl = (..._args) => null;
24218
24208
  var resolveJsonlPath = (..._args) => null;
24219
24209
 
24220
24210
  // server/routes/admin/sessions.ts
24221
- import { homedir as homedir4 } from "os";
24211
+ import { homedir as homedir3 } from "os";
24222
24212
 
24223
24213
  // app/lib/claude-agent/component-attachment.ts
24224
24214
  var pickComponentBytes = (..._args) => null;
@@ -24240,7 +24230,7 @@ function validateAndShapeAttachments(raws, conversationAccountId, sessionId, mes
24240
24230
  let reason = null;
24241
24231
  if (!a.attachmentId || !a.filename || !a.mimeType || !a.storagePath) reason = "schema-fail";
24242
24232
  else if (a.accountId !== conversationAccountId) reason = "account-mismatch";
24243
- else if (!existsSync38(a.storagePath)) reason = "missing-file";
24233
+ else if (!existsSync39(a.storagePath)) reason = "missing-file";
24244
24234
  if (reason) {
24245
24235
  invalid++;
24246
24236
  try {
@@ -24533,7 +24523,7 @@ app23.post("/:id/resume", async (c) => {
24533
24523
  return c.json({ error: "Failed to load conversation messages" }, 500);
24534
24524
  }
24535
24525
  if (persistedAgentSessionId) {
24536
- const jsonlPath = resolveJsonlPath(homedir4(), resolvePath(ACCOUNTS_DIR, accountId), persistedAgentSessionId);
24526
+ const jsonlPath = resolveJsonlPath(homedir3(), resolvePath(ACCOUNTS_DIR, accountId), persistedAgentSessionId);
24537
24527
  const replay = replayJsonl(jsonlPath);
24538
24528
  jsonlMissing = replay.jsonlMissing;
24539
24529
  jsonlMalformedLines = replay.malformedLines;
@@ -24766,7 +24756,7 @@ app23.put("/:id/label", requireAdminSession, async (c) => {
24766
24756
  var sessions_default = app23;
24767
24757
 
24768
24758
  // app/lib/claude-agent/spawn-context.ts
24769
- import { existsSync as existsSync39, readFileSync as readFileSync39, readdirSync as readdirSync25, statSync as statSync25 } from "fs";
24759
+ import { existsSync as existsSync40, readFileSync as readFileSync39, readdirSync as readdirSync25, statSync as statSync25 } from "fs";
24770
24760
  import { dirname as dirname15, resolve as resolve29, join as join47 } from "path";
24771
24761
  async function resolveOwnerProfileBlock(accountId, userId) {
24772
24762
  if (!userId) return { ok: false, reason: "missing-user-id" };
@@ -24813,7 +24803,7 @@ function extractPluginToolDescriptions(pluginDir) {
24813
24803
  ];
24814
24804
  let raw = null;
24815
24805
  for (const path of candidates) {
24816
- if (!existsSync39(path)) continue;
24806
+ if (!existsSync40(path)) continue;
24817
24807
  try {
24818
24808
  raw = readFileSync39(path, "utf-8");
24819
24809
  break;
@@ -24865,7 +24855,7 @@ function parseSkillPathsFromFrontmatter(fm) {
24865
24855
  function listPluginDirs(accountPluginsDir) {
24866
24856
  const out = /* @__PURE__ */ new Map();
24867
24857
  const platformPlugins = resolve29(PLATFORM_ROOT, "plugins");
24868
- if (existsSync39(platformPlugins)) {
24858
+ if (existsSync40(platformPlugins)) {
24869
24859
  for (const name of readdirSync25(platformPlugins)) {
24870
24860
  const dir = join47(platformPlugins, name);
24871
24861
  try {
@@ -24875,10 +24865,10 @@ function listPluginDirs(accountPluginsDir) {
24875
24865
  }
24876
24866
  }
24877
24867
  const premiumRoot = resolve29(dirname15(PLATFORM_ROOT), "premium-plugins");
24878
- if (existsSync39(premiumRoot)) {
24868
+ if (existsSync40(premiumRoot)) {
24879
24869
  for (const bundle of readdirSync25(premiumRoot)) {
24880
24870
  const bundlePlugins = join47(premiumRoot, bundle, "plugins");
24881
- if (!existsSync39(bundlePlugins)) continue;
24871
+ if (!existsSync40(bundlePlugins)) continue;
24882
24872
  try {
24883
24873
  for (const name of readdirSync25(bundlePlugins)) {
24884
24874
  const dir = join47(bundlePlugins, name);
@@ -24891,7 +24881,7 @@ function listPluginDirs(accountPluginsDir) {
24891
24881
  }
24892
24882
  }
24893
24883
  }
24894
- if (accountPluginsDir && existsSync39(accountPluginsDir)) {
24884
+ if (accountPluginsDir && existsSync40(accountPluginsDir)) {
24895
24885
  try {
24896
24886
  for (const name of readdirSync25(accountPluginsDir)) {
24897
24887
  if (out.has(name)) continue;
@@ -24910,7 +24900,7 @@ function accountPluginsDirFor(accountId) {
24910
24900
  return resolve29(PLATFORM_ROOT, "..", "data/accounts", accountId, "plugins");
24911
24901
  }
24912
24902
  function listAccountPluginNames(accountPluginsDir) {
24913
- if (!existsSync39(accountPluginsDir)) return [];
24903
+ if (!existsSync40(accountPluginsDir)) return [];
24914
24904
  try {
24915
24905
  return readdirSync25(accountPluginsDir).filter((name) => {
24916
24906
  try {
@@ -24925,7 +24915,7 @@ function listAccountPluginNames(accountPluginsDir) {
24925
24915
  }
24926
24916
  function readEnabledPlugins(accountId) {
24927
24917
  const accountFile = resolve29(PLATFORM_ROOT, "..", "data/accounts", accountId, "account.json");
24928
- if (!existsSync39(accountFile)) return /* @__PURE__ */ new Set();
24918
+ if (!existsSync40(accountFile)) return /* @__PURE__ */ new Set();
24929
24919
  try {
24930
24920
  const parsed = JSON.parse(readFileSync39(accountFile, "utf-8"));
24931
24921
  return new Set(
@@ -24936,7 +24926,7 @@ function readEnabledPlugins(accountId) {
24936
24926
  }
24937
24927
  }
24938
24928
  function readFrontmatter(path) {
24939
- if (!existsSync39(path)) return null;
24929
+ if (!existsSync40(path)) return null;
24940
24930
  let raw;
24941
24931
  try {
24942
24932
  raw = readFileSync39(path, "utf-8");
@@ -24974,7 +24964,7 @@ ${fm}
24974
24964
  `plugin-manifest-tool-coverage plugin=${name} tools=${tools.length} with-desc=${withDesc}`
24975
24965
  );
24976
24966
  if (toolNames.length > 0 && descMap.size === 0) {
24977
- const hasSource = existsSync39(join47(dir, "mcp/dist/index.js")) || existsSync39(join47(dir, "mcp/src/index.ts"));
24967
+ const hasSource = existsSync40(join47(dir, "mcp/dist/index.js")) || existsSync40(join47(dir, "mcp/src/index.ts"));
24978
24968
  if (hasSource) {
24979
24969
  console.warn(
24980
24970
  `[spawn-context] WARN plugin=${name} mcp source present but tool-description regex matched zero entries \u2014 SDK upgrade may have changed the registration shape`
@@ -25001,7 +24991,7 @@ ${skillFm}
25001
24991
  }
25002
24992
  function computeSpecialistDomains(accountId) {
25003
24993
  const specialistsDir = resolve29(PLATFORM_ROOT, "..", "data/accounts", accountId, "specialists", "agents");
25004
- if (!existsSync39(specialistsDir)) return [];
24994
+ if (!existsSync40(specialistsDir)) return [];
25005
24995
  let entries2;
25006
24996
  try {
25007
24997
  entries2 = readdirSync25(specialistsDir);
@@ -25047,7 +25037,7 @@ ${fm}
25047
25037
  }
25048
25038
  function computeDormantPlugins(accountId) {
25049
25039
  const accountFile = resolve29(PLATFORM_ROOT, "..", "data/accounts", accountId, "account.json");
25050
- if (!existsSync39(accountFile)) return [];
25040
+ if (!existsSync40(accountFile)) return [];
25051
25041
  let enabled;
25052
25042
  try {
25053
25043
  const raw = readFileSync39(accountFile, "utf-8");
@@ -25062,7 +25052,7 @@ function computeDormantPlugins(accountId) {
25062
25052
  return [];
25063
25053
  }
25064
25054
  const pluginsDir = resolve29(PLATFORM_ROOT, "plugins");
25065
- if (!existsSync39(pluginsDir)) return [];
25055
+ if (!existsSync40(pluginsDir)) return [];
25066
25056
  let entries2;
25067
25057
  try {
25068
25058
  entries2 = readdirSync25(pluginsDir);
@@ -25073,7 +25063,7 @@ function computeDormantPlugins(accountId) {
25073
25063
  for (const name of entries2) {
25074
25064
  if (enabled.has(name)) continue;
25075
25065
  const manifestPath = resolve29(pluginsDir, name, "PLUGIN.md");
25076
- if (!existsSync39(manifestPath)) continue;
25066
+ if (!existsSync40(manifestPath)) continue;
25077
25067
  let manifest;
25078
25068
  try {
25079
25069
  manifest = readFileSync39(manifestPath, "utf-8");
@@ -25090,11 +25080,11 @@ function computeDormantPlugins(accountId) {
25090
25080
  }
25091
25081
 
25092
25082
  // server/routes/admin/claude-sessions.ts
25093
- import { existsSync as existsSync40, readFileSync as readFileSync40 } from "fs";
25083
+ import { existsSync as existsSync41, readFileSync as readFileSync40 } from "fs";
25094
25084
  import { resolve as resolve30 } from "path";
25095
25085
  function readTunnelState(brandConfigDir) {
25096
25086
  const statePath = `${process.env.HOME ?? ""}/${brandConfigDir}/cloudflared/tunnel.state`;
25097
- if (!existsSync40(statePath)) return null;
25087
+ if (!existsSync41(statePath)) return null;
25098
25088
  try {
25099
25089
  const parsed = JSON.parse(readFileSync40(statePath, "utf-8"));
25100
25090
  const tunnelId = typeof parsed.tunnelId === "string" ? parsed.tunnelId : null;
@@ -25553,7 +25543,7 @@ app27.get("/", requireAdminSession, async (c) => {
25553
25543
  var events_default = app27;
25554
25544
 
25555
25545
  // server/routes/admin/files.ts
25556
- import { createReadStream as createReadStream2, createWriteStream as createWriteStream2, existsSync as existsSync41 } from "fs";
25546
+ import { createReadStream as createReadStream2, createWriteStream as createWriteStream2, existsSync as existsSync42 } from "fs";
25557
25547
  import { readdir as readdir4, readFile as readFile10, stat as stat6, mkdir as mkdir2, unlink as unlink3, rename as rename3, rmdir } from "fs/promises";
25558
25548
  import { realpathSync as realpathSync7 } from "fs";
25559
25549
  import { randomUUID as randomUUID6 } from "crypto";
@@ -27100,7 +27090,7 @@ app28.post("/upload", requireAdminSession, async (c) => {
27100
27090
  });
27101
27091
  await unlink3(tmpPath).catch(() => {
27102
27092
  });
27103
- const tempRemoved = !existsSync41(tmpPath);
27093
+ const tempRemoved = !existsSync42(tmpPath);
27104
27094
  console.error(`[data-upload] op=cleanup uid=${uid} tempRemoved=${tempRemoved}`);
27105
27095
  };
27106
27096
  const reader = body.getReader();
@@ -27174,7 +27164,7 @@ async function discardChunkUpload(uploadId, state) {
27174
27164
  });
27175
27165
  await unlink3(state.tmpPath).catch(() => {
27176
27166
  });
27177
- const tempRemoved = !existsSync41(state.tmpPath);
27167
+ const tempRemoved = !existsSync42(state.tmpPath);
27178
27168
  console.error(`[data-upload] op=cleanup uid=${uploadId} tempRemoved=${tempRemoved}`);
27179
27169
  }
27180
27170
  async function writeChunkBody(body, out, alreadyReceived, ceiling) {
@@ -29805,7 +29795,7 @@ var graph_default_view_default = app34;
29805
29795
  // server/routes/admin/sidebar-artefacts.ts
29806
29796
  import { readdir as readdir5, stat as stat7 } from "fs/promises";
29807
29797
  import { resolve as resolve34, relative as relative7, isAbsolute as isAbsolute4, sep as sep10, basename as basename16 } from "path";
29808
- import { existsSync as existsSync42 } from "fs";
29798
+ import { existsSync as existsSync43 } from "fs";
29809
29799
  var LIMIT = 50;
29810
29800
  var ADMIN_AGENT_FILES = ["IDENTITY.md", "SOUL.md", "KNOWLEDGE.md"];
29811
29801
  function toDataRootRelPath(absPath) {
@@ -29917,7 +29907,7 @@ async function fetchAgentTemplateRows(accountDir) {
29917
29907
  async function unionSpecialistFilenames(overrideDir, bundledDir) {
29918
29908
  const names = /* @__PURE__ */ new Set();
29919
29909
  for (const dir of [overrideDir, bundledDir]) {
29920
- if (!existsSync42(dir)) continue;
29910
+ if (!existsSync43(dir)) continue;
29921
29911
  try {
29922
29912
  const entries2 = await readdir5(dir);
29923
29913
  for (const entry2 of entries2) {
@@ -29932,7 +29922,7 @@ async function unionSpecialistFilenames(overrideDir, bundledDir) {
29932
29922
  }
29933
29923
  async function readAgentTemplateRow(inp) {
29934
29924
  let chosenPath = null;
29935
- if (existsSync42(inp.overridePath)) {
29925
+ if (existsSync43(inp.overridePath)) {
29936
29926
  try {
29937
29927
  validateFilePathInAccount(inp.overridePath, inp.overrideRoot);
29938
29928
  chosenPath = inp.overridePath;
@@ -29943,7 +29933,7 @@ async function readAgentTemplateRow(inp) {
29943
29933
  );
29944
29934
  return null;
29945
29935
  }
29946
- } else if (existsSync42(inp.bundledPath)) {
29936
+ } else if (existsSync43(inp.bundledPath)) {
29947
29937
  if (!isWithin(inp.bundledPath, inp.bundledRoot)) {
29948
29938
  console.error(
29949
29939
  `[admin/sidebar-artefacts] agent-template-read-failed agent=${inp.displayName} kind=${inp.logName} error="bundled path outside PLATFORM_ROOT"`
@@ -30738,12 +30728,12 @@ app43.get("/", async (c) => {
30738
30728
  var system_stats_default = app43;
30739
30729
 
30740
30730
  // server/routes/admin/health.ts
30741
- import { existsSync as existsSync43, readFileSync as readFileSync43 } from "fs";
30731
+ import { existsSync as existsSync44, readFileSync as readFileSync43 } from "fs";
30742
30732
  import { resolve as resolve37, join as join55 } from "path";
30743
30733
  var PLATFORM_ROOT4 = process.env.MAXY_PLATFORM_ROOT ?? resolve37(process.cwd(), "..");
30744
30734
  var brandHostname = "maxy";
30745
30735
  var brandJsonPath = join55(PLATFORM_ROOT4, "config", "brand.json");
30746
- if (existsSync43(brandJsonPath)) {
30736
+ if (existsSync44(brandJsonPath)) {
30747
30737
  try {
30748
30738
  const brand = JSON.parse(readFileSync43(brandJsonPath, "utf-8"));
30749
30739
  if (brand.hostname) brandHostname = brand.hostname;
@@ -30754,7 +30744,7 @@ var VERSION_FILE = resolve37(PLATFORM_ROOT4, `config/.${brandHostname}-version`)
30754
30744
  var PROCESS_STARTED_AT = (/* @__PURE__ */ new Date()).toISOString();
30755
30745
  var PROBE_TIMEOUT_MS = 1e3;
30756
30746
  function readVersion() {
30757
- if (!existsSync43(VERSION_FILE)) return "unknown";
30747
+ if (!existsSync44(VERSION_FILE)) return "unknown";
30758
30748
  return readFileSync43(VERSION_FILE, "utf-8").trim() || "unknown";
30759
30749
  }
30760
30750
  async function probeConversationDb() {
@@ -30810,7 +30800,7 @@ import { randomUUID as randomUUID9 } from "crypto";
30810
30800
 
30811
30801
  // ../lib/account-ingest-token/src/index.ts
30812
30802
  import { randomBytes as randomBytes2, timingSafeEqual as timingSafeEqual2 } from "crypto";
30813
- import { existsSync as existsSync44, readdirSync as readdirSync27, readFileSync as readFileSync44, writeFileSync as writeFileSync20 } from "fs";
30803
+ import { existsSync as existsSync45, readdirSync as readdirSync27, readFileSync as readFileSync44, writeFileSync as writeFileSync20 } from "fs";
30814
30804
  import { resolve as resolve38 } from "path";
30815
30805
  var UUID_RE4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
30816
30806
  var INGEST_TOKEN_FIELD = "ingestToken";
@@ -30820,7 +30810,7 @@ function configPath2(accountsDir, accountId) {
30820
30810
  }
30821
30811
  function readConfig2(accountsDir, accountId) {
30822
30812
  const path = configPath2(accountsDir, accountId);
30823
- if (!existsSync44(path)) return null;
30813
+ if (!existsSync45(path)) return null;
30824
30814
  try {
30825
30815
  const parsed = JSON.parse(readFileSync44(path, "utf-8"));
30826
30816
  return parsed !== null && typeof parsed === "object" ? parsed : null;
@@ -30833,7 +30823,7 @@ function readIngestToken(accountsDir, accountId) {
30833
30823
  return typeof value === "string" && TOKEN_RE.test(value) ? value : null;
30834
30824
  }
30835
30825
  function listAccountIdsOnDisk(accountsDir) {
30836
- if (!existsSync44(accountsDir)) return [];
30826
+ if (!existsSync45(accountsDir)) return [];
30837
30827
  let entries2;
30838
30828
  try {
30839
30829
  entries2 = readdirSync27(accountsDir);
@@ -30841,7 +30831,7 @@ function listAccountIdsOnDisk(accountsDir) {
30841
30831
  return [];
30842
30832
  }
30843
30833
  return entries2.filter(
30844
- (name) => UUID_RE4.test(name) && existsSync44(resolve38(accountsDir, name, "account.json"))
30834
+ (name) => UUID_RE4.test(name) && existsSync45(resolve38(accountsDir, name, "account.json"))
30845
30835
  );
30846
30836
  }
30847
30837
  function resolveAccountIdByIngestToken(accountsDir, token) {
@@ -31673,7 +31663,7 @@ app51.delete("/tabs/:id", requireAdminSession, async (c) => {
31673
31663
  var browser_default = app51;
31674
31664
 
31675
31665
  // server/routes/admin/calendar.ts
31676
- import { existsSync as existsSync45 } from "fs";
31666
+ import { existsSync as existsSync46 } from "fs";
31677
31667
  import { randomUUID as randomUUID10 } from "crypto";
31678
31668
  import { join as join57 } from "path";
31679
31669
 
@@ -32343,7 +32333,7 @@ app52.get("/booking-link", requireAdminSession, (c) => {
32343
32333
  }
32344
32334
  const id83 = account.accountId.slice(0, 8);
32345
32335
  try {
32346
- if (!existsSync45(join57(account.accountDir, AVAILABILITY_FILENAME))) {
32336
+ if (!existsSync46(join57(account.accountDir, AVAILABILITY_FILENAME))) {
32347
32337
  console.log(`[calendar] op=booking-link accountId=${id83} bookingDomain=none source=availability-config`);
32348
32338
  return c.json({ bookingDomain: null });
32349
32339
  }
@@ -32362,7 +32352,7 @@ app52.get("/booking-link", requireAdminSession, (c) => {
32362
32352
  var calendar_default = app52;
32363
32353
 
32364
32354
  // server/routes/admin/data-portal.ts
32365
- import { existsSync as existsSync46, readFileSync as readFileSync46 } from "fs";
32355
+ import { existsSync as existsSync47, readFileSync as readFileSync46 } from "fs";
32366
32356
  import { join as join58 } from "path";
32367
32357
  var app53 = new Hono();
32368
32358
  var PORTAL_FILENAME = "data-portal.json";
@@ -32375,7 +32365,7 @@ app53.get("/portal-link", requireAdminSession, (c) => {
32375
32365
  const id83 = account.accountId.slice(0, 8);
32376
32366
  try {
32377
32367
  const path = join58(account.accountDir, PORTAL_FILENAME);
32378
- if (!existsSync46(path)) {
32368
+ if (!existsSync47(path)) {
32379
32369
  console.log(`[data-portal] op=portal-link accountId=${id83} portalDomain=none source=data-portal-config`);
32380
32370
  return c.json({ portalDomain: null });
32381
32371
  }
@@ -32392,7 +32382,7 @@ app53.get("/portal-link", requireAdminSession, (c) => {
32392
32382
  var data_portal_default = app53;
32393
32383
 
32394
32384
  // server/routes/admin/dispatch-planner.ts
32395
- import { existsSync as existsSync47, readFileSync as readFileSync47 } from "fs";
32385
+ import { existsSync as existsSync48, readFileSync as readFileSync47 } from "fs";
32396
32386
  import { join as join59 } from "path";
32397
32387
  var app54 = new Hono();
32398
32388
  var PORTAL_FILENAME2 = "data-portal.json";
@@ -32407,10 +32397,10 @@ app54.get("/planner-link", requireAdminSession, (c) => {
32407
32397
  const id83 = account.accountId.slice(0, 8);
32408
32398
  try {
32409
32399
  const portalPath = join59(account.accountDir, PORTAL_FILENAME2);
32410
- const dispatchConfigured = existsSync47(join59(account.accountDir, "dispatch", "config.json"));
32411
- if (!existsSync47(portalPath) || !dispatchConfigured) {
32400
+ const dispatchConfigured = existsSync48(join59(account.accountDir, "dispatch", "config.json"));
32401
+ if (!existsSync48(portalPath) || !dispatchConfigured) {
32412
32402
  console.log(
32413
- `[dispatch-planner] op=planner-link accountId=${id83} plannerUrl=none portal=${existsSync47(portalPath)} dispatch=${dispatchConfigured}`
32403
+ `[dispatch-planner] op=planner-link accountId=${id83} plannerUrl=none portal=${existsSync48(portalPath)} dispatch=${dispatchConfigured}`
32414
32404
  );
32415
32405
  return c.json({ plannerUrl: null });
32416
32406
  }
@@ -33437,7 +33427,7 @@ app55.delete("/:eventId", requireAdminSession, async (c) => {
33437
33427
  var routines_default = app55;
33438
33428
 
33439
33429
  // server/routes/admin/skills.ts
33440
- import { existsSync as existsSync48, readdirSync as readdirSync28, readFileSync as readFileSync50, rmSync as rmSync6 } from "fs";
33430
+ import { existsSync as existsSync49, readdirSync as readdirSync28, readFileSync as readFileSync50, rmSync as rmSync6 } from "fs";
33441
33431
  import { resolve as resolve41 } from "path";
33442
33432
  var app56 = new Hono();
33443
33433
  var NAME_RE = /^[a-z0-9][a-z0-9-]*$/;
@@ -33461,7 +33451,7 @@ function stripQuotes(s) {
33461
33451
  return s;
33462
33452
  }
33463
33453
  function subdirs2(dir) {
33464
- if (!existsSync48(dir)) return [];
33454
+ if (!existsSync49(dir)) return [];
33465
33455
  try {
33466
33456
  return readdirSync28(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
33467
33457
  } catch {
@@ -33484,11 +33474,11 @@ app56.get("/", requireAdminSession, async (c) => {
33484
33474
  const skillsDir = resolve41(pluginsDir, plugin, "skills");
33485
33475
  for (const skill of subdirs2(skillsDir)) {
33486
33476
  const skillMd = resolve41(skillsDir, skill, "SKILL.md");
33487
- if (!existsSync48(skillMd)) continue;
33477
+ if (!existsSync49(skillMd)) continue;
33488
33478
  try {
33489
33479
  const { frontmatter } = splitSkillMd(readFileSync50(skillMd, "utf-8"));
33490
33480
  const refsDir = resolve41(skillsDir, skill, "references");
33491
- const refCount = existsSync48(refsDir) ? readdirSync28(refsDir, { withFileTypes: true }).filter((e) => e.isFile()).length : 0;
33481
+ const refCount = existsSync49(refsDir) ? readdirSync28(refsDir, { withFileTypes: true }).filter((e) => e.isFile()).length : 0;
33492
33482
  skills.push({ plugin, skill, description: frontmatter.description, refCount });
33493
33483
  } catch (err) {
33494
33484
  console.error(`[admin:skills] op=list-skip plugin=${plugin} skill=${skill} reason="${err instanceof Error ? err.message : String(err)}"`);
@@ -33512,13 +33502,13 @@ app56.get("/:plugin/:skill", requireAdminSession, async (c) => {
33512
33502
  }
33513
33503
  const skillDir = resolve41(acct.accountDir, "plugins", plugin, "skills", skill);
33514
33504
  const skillMd = resolve41(skillDir, "SKILL.md");
33515
- const found = existsSync48(skillMd);
33505
+ const found = existsSync49(skillMd);
33516
33506
  console.log(`[admin:skills] op=get plugin=${plugin} skill=${skill} found=${found}`);
33517
33507
  if (!found) return c.json({ error: "Skill not found" }, 404);
33518
33508
  try {
33519
33509
  const { frontmatter, body } = splitSkillMd(readFileSync50(skillMd, "utf-8"));
33520
33510
  const refsDir = resolve41(skillDir, "references");
33521
- const references = existsSync48(refsDir) ? readdirSync28(refsDir, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name).sort() : [];
33511
+ const references = existsSync49(refsDir) ? readdirSync28(refsDir, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name).sort() : [];
33522
33512
  return c.json({ skill: { plugin, skill, frontmatter, body, references } });
33523
33513
  } catch (err) {
33524
33514
  const message = err instanceof Error ? err.message : String(err);
@@ -33538,7 +33528,7 @@ app56.delete("/:plugin/:skill", requireAdminSession, async (c) => {
33538
33528
  const pluginDir = resolve41(acct.accountDir, "plugins", plugin);
33539
33529
  const skillsDir = resolve41(pluginDir, "skills");
33540
33530
  const skillDir = resolve41(skillsDir, skill);
33541
- if (!existsSync48(resolve41(skillDir, "SKILL.md"))) {
33531
+ if (!existsSync49(resolve41(skillDir, "SKILL.md"))) {
33542
33532
  console.error(`[admin:skills] op=delete outcome=rejected reason=not-found plugin=${plugin} skill=${skill}`);
33543
33533
  return c.json({ error: "Skill not found" }, 404);
33544
33534
  }
@@ -33546,7 +33536,7 @@ app56.delete("/:plugin/:skill", requireAdminSession, async (c) => {
33546
33536
  rmSync6(skillDir, { recursive: true, force: true });
33547
33537
  const pluginDirRemoved = subdirs2(skillsDir).length === 0;
33548
33538
  if (pluginDirRemoved) rmSync6(pluginDir, { recursive: true, force: true });
33549
- const skillDirGone = !existsSync48(skillDir);
33539
+ const skillDirGone = !existsSync49(skillDir);
33550
33540
  if (!skillDirGone) {
33551
33541
  console.error(`[admin:skills] op=delete plugin=${plugin} skill=${skill} outcome=rejected reason=rm-incomplete skillDirGone=false`);
33552
33542
  return c.json({ error: "Delete did not remove the skill directory" }, 503);
@@ -34150,7 +34140,7 @@ app62.post("/", requireAdminSession, async (c) => {
34150
34140
  var task_delete_default = app62;
34151
34141
 
34152
34142
  // app/lib/admin-roster.ts
34153
- import { existsSync as existsSync49, readdirSync as readdirSync29, readFileSync as readFileSync51 } from "fs";
34143
+ import { existsSync as existsSync50, readdirSync as readdirSync29, readFileSync as readFileSync51 } from "fs";
34154
34144
  import { resolve as resolve42 } from "path";
34155
34145
  function readHouseAdminUserIds(accountsDir = ACCOUNTS_DIR) {
34156
34146
  let entries2;
@@ -34161,7 +34151,7 @@ function readHouseAdminUserIds(accountsDir = ACCOUNTS_DIR) {
34161
34151
  }
34162
34152
  for (const entry2 of entries2) {
34163
34153
  const cfgPath = resolve42(accountsDir, entry2, "account.json");
34164
- if (!existsSync49(cfgPath)) continue;
34154
+ if (!existsSync50(cfgPath)) continue;
34165
34155
  try {
34166
34156
  const cfg = JSON.parse(readFileSync51(cfgPath, "utf-8"));
34167
34157
  if (cfg.role !== "house") continue;
@@ -35005,7 +34995,7 @@ app72.route("/request-magic-link", request_magic_link_default);
35005
34995
  var access_default = app72;
35006
34996
 
35007
34997
  // server/routes/sites.ts
35008
- import { existsSync as existsSync50, readFileSync as readFileSync52, realpathSync as realpathSync8, statSync as statSync27 } from "fs";
34998
+ import { existsSync as existsSync51, readFileSync as readFileSync52, realpathSync as realpathSync8, statSync as statSync27 } from "fs";
35009
34999
  import { resolve as resolve45 } from "path";
35010
35000
  var SAFE_SEG_RE = /^[a-z0-9_][a-z0-9_.-]{0,99}$/i;
35011
35001
  var MIME = {
@@ -35071,7 +35061,7 @@ app73.get("/:rel{.*}", (c) => {
35071
35061
  }
35072
35062
  let stat11;
35073
35063
  try {
35074
- stat11 = existsSync50(filePath) ? statSync27(filePath) : null;
35064
+ stat11 = existsSync51(filePath) ? statSync27(filePath) : null;
35075
35065
  } catch {
35076
35066
  stat11 = null;
35077
35067
  }
@@ -35090,7 +35080,7 @@ app73.get("/:rel{.*}", (c) => {
35090
35080
  console.error(`[sites] path-traversal-rejected path=${reqPath} reason=escape status=403`);
35091
35081
  return c.text("Forbidden", 403);
35092
35082
  }
35093
- if (!existsSync50(filePath)) {
35083
+ if (!existsSync51(filePath)) {
35094
35084
  console.error(`[sites] not-found path=${reqPath} status=404`);
35095
35085
  return c.text("Not found", 404);
35096
35086
  }
@@ -35221,7 +35211,7 @@ var VISITOR_COOKIE_NAME = "mxy_v";
35221
35211
  var VISITOR_COOKIE_MAX_AGE_SECONDS = Math.floor(DEFAULT_TTL_MS / 1e3);
35222
35212
 
35223
35213
  // app/lib/brand-config.ts
35224
- import { existsSync as existsSync51, readFileSync as readFileSync54 } from "fs";
35214
+ import { existsSync as existsSync52, readFileSync as readFileSync54 } from "fs";
35225
35215
  import { join as join61 } from "path";
35226
35216
  var cached2 = null;
35227
35217
  var cachedAttempted = false;
@@ -35231,7 +35221,7 @@ function readBrandConfig() {
35231
35221
  const platformRoot5 = process.env.MAXY_PLATFORM_ROOT;
35232
35222
  if (!platformRoot5) return null;
35233
35223
  const brandPath = join61(platformRoot5, "config", "brand.json");
35234
- if (!existsSync51(brandPath)) return null;
35224
+ if (!existsSync52(brandPath)) return null;
35235
35225
  try {
35236
35226
  cached2 = JSON.parse(readFileSync54(brandPath, "utf-8"));
35237
35227
  return cached2;
@@ -35731,7 +35721,7 @@ var visitor_event_default = app76;
35731
35721
 
35732
35722
  // server/routes/session.ts
35733
35723
  import { resolve as resolve46 } from "path";
35734
- import { existsSync as existsSync52, writeFileSync as writeFileSync22, mkdirSync as mkdirSync13 } from "fs";
35724
+ import { existsSync as existsSync53, writeFileSync as writeFileSync22, mkdirSync as mkdirSync13 } from "fs";
35735
35725
  var UUID_RE5 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
35736
35726
  function writeBrandingCache(accountId, agentSlug, branding) {
35737
35727
  try {
@@ -35819,7 +35809,7 @@ app77.post("/", async (c) => {
35819
35809
  let agentConfig = null;
35820
35810
  if (account) {
35821
35811
  const agentDir = resolve46(account.accountDir, "agents", agentSlug);
35822
- if (!existsSync52(agentDir) || !existsSync52(resolve46(agentDir, "config.json"))) {
35812
+ if (!existsSync53(agentDir) || !existsSync53(resolve46(agentDir, "config.json"))) {
35823
35813
  return c.json({ error: "Agent not found" }, 404);
35824
35814
  }
35825
35815
  agentConfig = resolveAgentConfig(account.accountDir, agentSlug);
@@ -36904,7 +36894,7 @@ function startGraphHealthTimer() {
36904
36894
  }
36905
36895
 
36906
36896
  // app/lib/shared-folder-census.ts
36907
- import { existsSync as existsSync53, statSync as statSync29, readdirSync as readdirSync32 } from "fs";
36897
+ import { existsSync as existsSync54, statSync as statSync29, readdirSync as readdirSync32 } from "fs";
36908
36898
  import { join as join65 } from "path";
36909
36899
  var import_dist15 = __toESM(require_dist(), 1);
36910
36900
  var TAG64 = "[shared-census]";
@@ -36925,7 +36915,7 @@ function countFiles(dir) {
36925
36915
  }
36926
36916
  function runSharedFolderCensus(dataRoot = DATA_ROOT) {
36927
36917
  const root = (0, import_dist15.sharedRoot)(dataRoot);
36928
- const exists = existsSync53(root);
36918
+ const exists = existsSync54(root);
36929
36919
  let isDir = false;
36930
36920
  if (exists) {
36931
36921
  try {
@@ -36950,7 +36940,7 @@ function startSharedFolderCensus() {
36950
36940
 
36951
36941
  // app/lib/cred-refresh-census.ts
36952
36942
  import { readdirSync as readdirSync33, readFileSync as readFileSync57 } from "fs";
36953
- import { homedir as homedir5 } from "os";
36943
+ import { homedir as homedir4 } from "os";
36954
36944
  import { join as join66 } from "path";
36955
36945
  var TAG65 = "[claude-auth]";
36956
36946
  function refreshTokenLength(raw) {
@@ -36991,7 +36981,7 @@ function censusResult(rows) {
36991
36981
  if (rows.length === 0) return "no-brands-found";
36992
36982
  return rows.some(isBlank) ? "blank-tokens" : "ok";
36993
36983
  }
36994
- function runCredRefreshCensus(home = homedir5()) {
36984
+ function runCredRefreshCensus(home = homedir4()) {
36995
36985
  const rows = surveyBrandCredentials(home);
36996
36986
  const blank = rows.filter(isBlank).length;
36997
36987
  const detail = rows.map((r) => `${r.brand}:${r.refreshTokenLen === null ? "unreadable" : r.refreshTokenLen}`).join(",");
@@ -37237,7 +37227,7 @@ async function migrateUploads(opts = {}) {
37237
37227
 
37238
37228
  // app/lib/migrate-admin-webchat-sidecars.ts
37239
37229
  import { readdir as readdir7, readFile as readFile13, rename as rename5, writeFile as writeFile4, unlink as unlink4 } from "fs/promises";
37240
- import { existsSync as existsSync54 } from "fs";
37230
+ import { existsSync as existsSync55 } from "fs";
37241
37231
  import { join as join67 } from "path";
37242
37232
  var ADMIN_ROLE2 = "admin";
37243
37233
  var WEBCHAT_CHANNEL2 = "webchat";
@@ -37267,7 +37257,7 @@ async function writeRaw(path, obj) {
37267
37257
  await rename5(tmp, path);
37268
37258
  } catch (err) {
37269
37259
  try {
37270
- if (existsSync54(tmp)) await unlink4(tmp);
37260
+ if (existsSync55(tmp)) await unlink4(tmp);
37271
37261
  } catch {
37272
37262
  }
37273
37263
  throw err;
@@ -37390,7 +37380,7 @@ async function migrateAdminWebchatSidecars(opts = {}) {
37390
37380
 
37391
37381
  // app/lib/migrate-sidecar-account-ids.ts
37392
37382
  import { readdir as readdir8, readFile as readFile14, rename as rename6, writeFile as writeFile5, unlink as unlink5 } from "fs/promises";
37393
- import { existsSync as existsSync55 } from "fs";
37383
+ import { existsSync as existsSync56 } from "fs";
37394
37384
  import { join as join68 } from "path";
37395
37385
  var SESSION_META_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.meta\.json$/i;
37396
37386
  function projectSlugForCwd(cwd) {
@@ -37417,7 +37407,7 @@ async function writeRaw2(path, obj) {
37417
37407
  await rename6(tmp, path);
37418
37408
  } catch (err) {
37419
37409
  try {
37420
- if (existsSync55(tmp)) await unlink5(tmp);
37410
+ if (existsSync56(tmp)) await unlink5(tmp);
37421
37411
  } catch {
37422
37412
  }
37423
37413
  throw err;
@@ -39089,7 +39079,7 @@ function createWebchatChannelRoutes(deps) {
39089
39079
  }
39090
39080
 
39091
39081
  // app/lib/webchat/gateway/resolve-turn-answer.ts
39092
- import { existsSync as existsSync56, openSync as openSync9, readSync as readSync8, closeSync as closeSync9, readdirSync as readdirSync34 } from "fs";
39082
+ import { existsSync as existsSync57, openSync as openSync9, readSync as readSync8, closeSync as closeSync9, readdirSync as readdirSync34 } from "fs";
39093
39083
  import { join as join69 } from "path";
39094
39084
 
39095
39085
  // app/lib/channel-delivery/outbound-guard.ts
@@ -39151,7 +39141,7 @@ function resolveTurnAnswer(p) {
39151
39141
  return segmentText(guardOutbound(p.senderId, parts.join("\n\n"))).join("\n\n");
39152
39142
  }
39153
39143
  function findJsonl(projectsRoot, sessionId) {
39154
- if (!existsSync56(projectsRoot)) return null;
39144
+ if (!existsSync57(projectsRoot)) return null;
39155
39145
  let slugs;
39156
39146
  try {
39157
39147
  slugs = readdirSync34(projectsRoot, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
@@ -39160,7 +39150,7 @@ function findJsonl(projectsRoot, sessionId) {
39160
39150
  }
39161
39151
  for (const slug of slugs) {
39162
39152
  const live = join69(projectsRoot, slug, `${sessionId}.jsonl`);
39163
- if (existsSync56(live)) return live;
39153
+ if (existsSync57(live)) return live;
39164
39154
  }
39165
39155
  return null;
39166
39156
  }
@@ -42194,7 +42184,7 @@ function businessConnectionCensusLine(c) {
42194
42184
  }
42195
42185
 
42196
42186
  // app/lib/telegram/business-window-census.ts
42197
- import { readdirSync as readdirSync36, existsSync as existsSync57 } from "fs";
42187
+ import { readdirSync as readdirSync36, existsSync as existsSync58 } from "fs";
42198
42188
  import { join as join72 } from "path";
42199
42189
  var BUSINESS_WINDOW_CENSUS_TAG = "[telegram-audit]";
42200
42190
  var EXPIRING_SOON_S = 3600;
@@ -42224,7 +42214,7 @@ function readBusinessChatClocks(accountIds) {
42224
42214
  const out = [];
42225
42215
  for (const accountId of accountIds) {
42226
42216
  const dir = join72(STORE_ROOT2(), accountId);
42227
- if (!existsSync57(dir)) continue;
42217
+ if (!existsSync58(dir)) continue;
42228
42218
  let names;
42229
42219
  try {
42230
42220
  names = readdirSync36(dir);
@@ -42285,7 +42275,7 @@ async function getTelegramBusinessConnection(botToken, connectionId, opts = {})
42285
42275
  }
42286
42276
 
42287
42277
  // server/telegram-migrate.ts
42288
- import { readFileSync as readFileSync58, writeFileSync as writeFileSync23, existsSync as existsSync58, renameSync as renameSync11, mkdirSync as mkdirSync14 } from "fs";
42278
+ import { readFileSync as readFileSync58, writeFileSync as writeFileSync23, existsSync as existsSync59, renameSync as renameSync11, mkdirSync as mkdirSync14 } from "fs";
42289
42279
  import { dirname as dirname19, join as join73 } from "path";
42290
42280
  function migrateTelegramTwoSlot(input) {
42291
42281
  const out = [];
@@ -42346,7 +42336,7 @@ function migrateTelegramTwoSlot(input) {
42346
42336
  return out;
42347
42337
  }
42348
42338
  function moveSecret(from, to) {
42349
- if (!existsSync58(from)) return;
42339
+ if (!existsSync59(from)) return;
42350
42340
  mkdirSync14(dirname19(to), { recursive: true, mode: 448 });
42351
42341
  renameSync11(from, to);
42352
42342
  }
@@ -42432,12 +42422,12 @@ function backfillMisfiledRecords(params) {
42432
42422
  }
42433
42423
 
42434
42424
  // server/lib/booking-site-accounts.ts
42435
- import { existsSync as existsSync59, readFileSync as readFileSync60 } from "fs";
42425
+ import { existsSync as existsSync60, readFileSync as readFileSync60 } from "fs";
42436
42426
  import { resolve as resolve53 } from "path";
42437
42427
  function listBookingSiteAccounts(accounts) {
42438
42428
  return accounts.filter((a) => {
42439
42429
  const availPath = resolve53(a.accountDir, "calendar-availability.json");
42440
- if (!existsSync59(availPath)) return false;
42430
+ if (!existsSync60(availPath)) return false;
42441
42431
  try {
42442
42432
  const cfg = JSON.parse(readFileSync60(availPath, "utf-8"));
42443
42433
  return typeof cfg.bookingDbName === "string" && cfg.bookingDbName.length > 0;
@@ -42477,7 +42467,7 @@ function broadcastAdminShutdown(reason) {
42477
42467
 
42478
42468
  // ../lib/entitlement/src/index.ts
42479
42469
  import { createPublicKey, createHash as createHash7, verify as cryptoVerify } from "crypto";
42480
- import { existsSync as existsSync60, readFileSync as readFileSync61, statSync as statSync32 } from "fs";
42470
+ import { existsSync as existsSync61, readFileSync as readFileSync61, statSync as statSync32 } from "fs";
42481
42471
  import { resolve as resolve54 } from "path";
42482
42472
 
42483
42473
  // ../lib/entitlement/src/canonicalize.ts
@@ -42526,7 +42516,7 @@ function resolveEntitlement(brand, account) {
42526
42516
  return logResolved(implicitTrust(account), null);
42527
42517
  }
42528
42518
  const entitlementPath = resolve54(brand.configDir, "entitlement.json");
42529
- if (!existsSync60(entitlementPath)) {
42519
+ if (!existsSync61(entitlementPath)) {
42530
42520
  return logResolved(anonymousFallback("missing"), { reason: "missing" });
42531
42521
  }
42532
42522
  const stat11 = statSync32(entitlementPath);
@@ -42719,10 +42709,10 @@ installMediaDownloadGuard();
42719
42709
  var PLATFORM_ROOT6 = process.env.MAXY_PLATFORM_ROOT || "";
42720
42710
  var BRAND_JSON_PATH = PLATFORM_ROOT6 ? join75(PLATFORM_ROOT6, "config", "brand.json") : "";
42721
42711
  var BRAND = { productName: "Maxy", hostname: "maxy", configDir: ".maxy", marketingUrl: "https://getmaxy.com" };
42722
- if (BRAND_JSON_PATH && !existsSync61(BRAND_JSON_PATH)) {
42712
+ if (BRAND_JSON_PATH && !existsSync62(BRAND_JSON_PATH)) {
42723
42713
  console.error(`[brand] WARNING: brand.json not found at ${BRAND_JSON_PATH} \u2014 using Maxy defaults`);
42724
42714
  }
42725
- if (BRAND_JSON_PATH && existsSync61(BRAND_JSON_PATH)) {
42715
+ if (BRAND_JSON_PATH && existsSync62(BRAND_JSON_PATH)) {
42726
42716
  try {
42727
42717
  const parsed = JSON.parse(readFileSync62(BRAND_JSON_PATH, "utf-8"));
42728
42718
  BRAND = { ...BRAND, ...parsed };
@@ -42756,10 +42746,10 @@ var brandLoginOpts = {
42756
42746
  appleTouchIconPath: brandAppIcon512Path,
42757
42747
  themeColor: BRAND.defaultColors?.primary
42758
42748
  };
42759
- var ALIAS_DOMAINS_PATH = join75(homedir6(), BRAND.configDir, "alias-domains.json");
42749
+ var ALIAS_DOMAINS_PATH = join75(homedir5(), BRAND.configDir, "alias-domains.json");
42760
42750
  function loadAliasDomains() {
42761
42751
  try {
42762
- if (!existsSync61(ALIAS_DOMAINS_PATH)) return null;
42752
+ if (!existsSync62(ALIAS_DOMAINS_PATH)) return null;
42763
42753
  const parsed = JSON.parse(readFileSync62(ALIAS_DOMAINS_PATH, "utf-8"));
42764
42754
  if (!Array.isArray(parsed)) {
42765
42755
  console.error("[alias-domains] malformed alias-domains.json \u2014 expected array");
@@ -43791,7 +43781,7 @@ app80.get("/agent-assets/:slug/:filename", (c) => {
43791
43781
  console.error(`[agent-assets] path-traversal-rejected slug=${slug} file=${filename}`);
43792
43782
  return c.text("Forbidden", 403);
43793
43783
  }
43794
- if (!existsSync61(filePath)) {
43784
+ if (!existsSync62(filePath)) {
43795
43785
  console.error(`[agent-assets] serve slug=${slug} file=${filename} status=404`);
43796
43786
  return c.text("Not found", 404);
43797
43787
  }
@@ -43821,7 +43811,7 @@ app80.get("/generated/:filename", (c) => {
43821
43811
  console.error(`[generated] serve file=${filename} status=403`);
43822
43812
  return c.text("Forbidden", 403);
43823
43813
  }
43824
- if (!existsSync61(filePath)) {
43814
+ if (!existsSync62(filePath)) {
43825
43815
  console.error(`[generated] serve file=${filename} status=404`);
43826
43816
  return c.text("Not found", 404);
43827
43817
  }
@@ -43841,7 +43831,7 @@ app80.route("/v", visitor_consent_default);
43841
43831
  var htmlCache = /* @__PURE__ */ new Map();
43842
43832
  var brandLogoPath = "/brand/maxy-monochrome.png";
43843
43833
  var brandIconPath = "/brand/maxy-monochrome.png";
43844
- if (BRAND_JSON_PATH && existsSync61(BRAND_JSON_PATH)) {
43834
+ if (BRAND_JSON_PATH && existsSync62(BRAND_JSON_PATH)) {
43845
43835
  try {
43846
43836
  const fullBrand = JSON.parse(readFileSync62(BRAND_JSON_PATH, "utf-8"));
43847
43837
  if (fullBrand.assets?.logo) brandLogoPath = `/brand/${fullBrand.assets.logo}`;
@@ -43870,7 +43860,7 @@ var brandScript = `<script>window.__BRAND__=${JSON.stringify({
43870
43860
  var brandThemeColor = BRAND.defaultColors?.primary ?? "#000000";
43871
43861
  var brandBackgroundColor = BRAND.defaultColors?.background ?? "#ffffff";
43872
43862
  var brandAppIconsExist = [brandAppIcon192Path, brandAppIcon512Path, brandMaskableIconPath].every(
43873
- (p) => existsSync61(resolve55(process.cwd(), "public", p.replace(/^\//, "")))
43863
+ (p) => existsSync62(resolve55(process.cwd(), "public", p.replace(/^\//, "")))
43874
43864
  );
43875
43865
  var SW_SOURCE = (() => {
43876
43866
  try {
@@ -43883,7 +43873,7 @@ function readInstalledVersion() {
43883
43873
  try {
43884
43874
  if (!PLATFORM_ROOT6) return "unknown";
43885
43875
  const versionFile = join75(PLATFORM_ROOT6, "config", `.${BRAND.hostname}-version`);
43886
- if (!existsSync61(versionFile)) return "unknown";
43876
+ if (!existsSync62(versionFile)) return "unknown";
43887
43877
  const content = readFileSync62(versionFile, "utf-8").trim();
43888
43878
  return content || "unknown";
43889
43879
  } catch {
@@ -43912,13 +43902,13 @@ ${clientErrorReporterScript}
43912
43902
  return html;
43913
43903
  }
43914
43904
  function loadBrandingCache(agentSlug) {
43915
- const configDir = join75(homedir6(), BRAND.configDir);
43905
+ const configDir = join75(homedir5(), BRAND.configDir);
43916
43906
  try {
43917
43907
  const verdict = resolvePublicAddressFromDisk(agentSlug);
43918
43908
  const accountId = verdict.kind === "served" ? verdict.owner.accountId : getDefaultAccountId();
43919
43909
  if (!accountId) return null;
43920
43910
  const cachePath = join75(configDir, "branding-cache", accountId, `${agentSlug}.json`);
43921
- if (!existsSync61(cachePath)) return null;
43911
+ if (!existsSync62(cachePath)) return null;
43922
43912
  return JSON.parse(readFileSync62(cachePath, "utf-8"));
43923
43913
  } catch {
43924
43914
  return null;
@@ -44171,7 +44161,7 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
44171
44161
  const reconcilePlatformRoot = process.env.MAXY_PLATFORM_ROOT ?? join75(__dirname, "..");
44172
44162
  const reconcileScript = resolve55(reconcilePlatformRoot, "plugins/scheduling/mcp/dist/scripts/reconcile-bookings.js");
44173
44163
  const runReconcile = (ctx) => {
44174
- if (!existsSync61(reconcileScript)) return;
44164
+ if (!existsSync62(reconcileScript)) return;
44175
44165
  try {
44176
44166
  const child = spawn3(process.execPath, [reconcileScript], {
44177
44167
  env: { ...process.env, PLATFORM_ROOT: reconcilePlatformRoot },
@@ -44217,7 +44207,7 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
44217
44207
  firstRunDelayMs: 3e4,
44218
44208
  detached: true,
44219
44209
  run: (ctx) => {
44220
- if (!existsSync61(dreamSweepScript)) return;
44210
+ if (!existsSync62(dreamSweepScript)) return;
44221
44211
  try {
44222
44212
  const child = spawn3(process.execPath, [dreamSweepScript], {
44223
44213
  env: { ...process.env, PLATFORM_ROOT: dreamPlatformRoot },
@@ -44237,7 +44227,7 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
44237
44227
  const outlookScript = resolve55(outlookPlatformRoot, "plugins/outlook/mcp/dist/scripts/complete-registration.js");
44238
44228
  const OUTLOOK_COMPLETE_INTERVAL_MS = 3e4;
44239
44229
  const runOutlookComplete = (ctx) => {
44240
- if (!existsSync61(outlookScript)) return;
44230
+ if (!existsSync62(outlookScript)) return;
44241
44231
  try {
44242
44232
  const child = spawn3(process.execPath, [outlookScript], {
44243
44233
  env: { ...process.env, PLATFORM_ROOT: outlookPlatformRoot },
@@ -44266,12 +44256,12 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
44266
44256
  const STRANDED_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
44267
44257
  const runStrandedAudit = () => {
44268
44258
  try {
44269
- if (!existsSync61(strandedAccountsDir)) return;
44259
+ if (!existsSync62(strandedAccountsDir)) return;
44270
44260
  const now = Date.now();
44271
44261
  for (const name of readdirSync37(strandedAccountsDir)) {
44272
44262
  if (!STRANDED_UUID_RE.test(name)) continue;
44273
44263
  const pendingPath2 = resolve55(strandedAccountsDir, name, "secrets/outlook/pending-devicecode.enc");
44274
- if (!existsSync61(pendingPath2)) continue;
44264
+ if (!existsSync62(pendingPath2)) continue;
44275
44265
  const ageMs2 = now - statSync33(pendingPath2).mtimeMs;
44276
44266
  if (ageMs2 > STRANDED_AGE_MS) {
44277
44267
  console.error(`[outlook-mcp] devicecode-stranded account=${name} ageSec=${Math.floor(ageMs2 / 1e3)}`);
@@ -44308,7 +44298,7 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
44308
44298
  const googleAuditScript = resolve55(googleRoot, "plugins/google/mcp/dist/scripts/account-audit.js");
44309
44299
  const GOOGLE_ACCOUNT_AUDIT_INTERVAL_MS = 36e5;
44310
44300
  const runGoogleAccountAudit = (ctx) => {
44311
- if (!existsSync61(googleAuditScript)) return;
44301
+ if (!existsSync62(googleAuditScript)) return;
44312
44302
  try {
44313
44303
  const child = spawn3(process.execPath, [googleAuditScript], {
44314
44304
  env: { ...process.env, PLATFORM_ROOT: googleRoot },
@@ -44381,8 +44371,8 @@ registerLoop({
44381
44371
  accounts: listValidAccounts().map((a) => ({ accountId: a.accountId, accountDir: a.accountDir })),
44382
44372
  secretPathFor: secretPath,
44383
44373
  legacySecretPathFor: (botType, accountId) => resolve55(
44384
- homedir6(),
44385
- configDirName2(),
44374
+ homedir5(),
44375
+ configDirName(),
44386
44376
  `${botType === "admin" ? ".telegram-admin-webhook-secret" : ".telegram-webhook-secret"}.${accountId}`
44387
44377
  ),
44388
44378
  // Counted here and nowhere else: the session-key re-key strands these and no
@@ -44417,7 +44407,7 @@ registerLoop({
44417
44407
  }
44418
44408
  const lines = buildTelegramAuditLines({
44419
44409
  accounts,
44420
- secretFileExists: (botId) => existsSync61(secretPath(botId)),
44410
+ secretFileExists: (botId) => existsSync62(secretPath(botId)),
44421
44411
  agentActive: isActiveAgentSlug,
44422
44412
  // Task 2619 — the card set a specialist binding is reconciled against.
44423
44413
  specialistCards: (accountDir) => listSpecialistCardNames(join75(accountDir, "specialists", "agents")),
@@ -44770,7 +44760,7 @@ registerLoop({
44770
44760
  }
44771
44761
  };
44772
44762
  const spawnPublish = (account, ctx) => {
44773
- if (!existsSync61(publishScript)) return;
44763
+ if (!existsSync62(publishScript)) return;
44774
44764
  try {
44775
44765
  const child = spawn3(process.execPath, [publishScript], {
44776
44766
  env: {
@@ -44792,7 +44782,7 @@ registerLoop({
44792
44782
  const availPath = resolve55(account.accountDir, "calendar-availability.json");
44793
44783
  let hasBookingSite = false;
44794
44784
  try {
44795
- if (existsSync61(availPath)) {
44785
+ if (existsSync62(availPath)) {
44796
44786
  const cfg = JSON.parse(readFileSync62(availPath, "utf-8"));
44797
44787
  hasBookingSite = typeof cfg.bookingDbName === "string" && cfg.bookingDbName.length > 0;
44798
44788
  }
@@ -44801,7 +44791,7 @@ registerLoop({
44801
44791
  if (!hasBookingSite) return;
44802
44792
  const statePath = resolve55(account.accountDir, "state", "booking-availability", "last-publish.json");
44803
44793
  let lastSuccessAt = null;
44804
- if (existsSync61(statePath)) {
44794
+ if (existsSync62(statePath)) {
44805
44795
  try {
44806
44796
  const rec = JSON.parse(readFileSync62(statePath, "utf-8"));
44807
44797
  lastSuccessAt = rec.lastSuccessAt ?? null;
@@ -44843,7 +44833,7 @@ startDispatchTgCensus(() => getSession());
44843
44833
  const auditLogDir = process.env.LOG_DIR ?? LOG_DIR;
44844
44834
  const CONNECTOR_AUDIT_INTERVAL_MS = 3e5;
44845
44835
  const runConnectorAudit = (ctx) => {
44846
- if (!existsSync61(auditScript)) return;
44836
+ if (!existsSync62(auditScript)) return;
44847
44837
  try {
44848
44838
  const child = spawn3(process.execPath, [auditScript], {
44849
44839
  env: { ...process.env, PLATFORM_ROOT: auditPlatformRoot, LOG_DIR: auditLogDir },
@@ -44965,7 +44955,7 @@ try {
44965
44955
  var ADMINUSER_RECONCILE_INTERVAL_MS = 60 * 60 * 1e3;
44966
44956
  async function runAdminUserReconcileTick() {
44967
44957
  try {
44968
- if (!existsSync61(USERS_FILE)) {
44958
+ if (!existsSync62(USERS_FILE)) {
44969
44959
  console.error("[adminuser-self-heal] skip reason=no-users-file");
44970
44960
  return;
44971
44961
  }
@@ -45052,7 +45042,7 @@ var runIngestAuditTick = () => {
45052
45042
  agentExists: (accountId, slug) => {
45053
45043
  if (!house) return false;
45054
45044
  const dir = isHouseAccountKey(house.accountId, accountId) ? house.accountDir : join75(ACCOUNTS_DIR, accountId);
45055
- return existsSync61(join75(dir, "agents", slug, "config.json"));
45045
+ return existsSync62(join75(dir, "agents", slug, "config.json"));
45056
45046
  }
45057
45047
  });
45058
45048
  } catch (err) {
@@ -45101,7 +45091,7 @@ registerLoop({
45101
45091
  houseAccountId: () => resolveAccount()?.accountId ?? null,
45102
45092
  activeSlugs: () => listValidAccounts().map((a) => {
45103
45093
  const agentsRoot = join75(a.accountDir, "agents");
45104
- if (!existsSync61(agentsRoot)) return { accountId: a.accountId, slugs: [] };
45094
+ if (!existsSync62(agentsRoot)) return { accountId: a.accountId, slugs: [] };
45105
45095
  const slugs = readdirSync37(agentsRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).filter((slug) => isActiveAgentSlug(a.accountDir, slug));
45106
45096
  return { accountId: a.accountId, slugs };
45107
45097
  })
@@ -45115,7 +45105,7 @@ registerLoop({
45115
45105
  });
45116
45106
  var USERS_RECONCILE_INTERVAL_MS = 60 * 60 * 1e3;
45117
45107
  function countUsersRows() {
45118
- if (!existsSync61(USERS_FILE)) return 0;
45108
+ if (!existsSync62(USERS_FILE)) return 0;
45119
45109
  const raw = readFileSync62(USERS_FILE, "utf-8").trim();
45120
45110
  if (!raw) return 0;
45121
45111
  const users = JSON.parse(raw);