@rubytech/create-realagent 1.0.865 → 1.0.867

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 (41) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/graph-search/dist/index.d.ts +51 -0
  3. package/payload/platform/lib/graph-search/dist/index.d.ts.map +1 -1
  4. package/payload/platform/lib/graph-search/dist/index.js +77 -7
  5. package/payload/platform/lib/graph-search/dist/index.js.map +1 -1
  6. package/payload/platform/lib/graph-search/src/__tests__/bm25-strong-bypass-threshold.test.ts +126 -0
  7. package/payload/platform/lib/graph-search/src/__tests__/vector-threshold.test.ts +170 -0
  8. package/payload/platform/lib/graph-search/src/index.ts +129 -9
  9. package/payload/platform/plugins/admin/skills/publish-site/SKILL.md +2 -0
  10. package/payload/platform/plugins/admin/skills/unzip-attachment/SKILL.md +2 -0
  11. package/payload/platform/templates/agents/admin/IDENTITY.md +2 -1
  12. package/payload/platform/templates/specialists/agents/content-producer.md +17 -3
  13. package/payload/platform/templates/specialists/agents/database-operator.md +1 -1
  14. package/payload/server/chunk-DHSBEMWW.js +11319 -0
  15. package/payload/server/chunk-FHNFKJZN.js +2143 -0
  16. package/payload/server/chunk-ND23BDBM.js +11312 -0
  17. package/payload/server/chunk-TOLLHW7W.js +1155 -0
  18. package/payload/server/chunk-UXLZ5Z3Y.js +667 -0
  19. package/payload/server/client-pool-2IUOSYDF.js +34 -0
  20. package/payload/server/cloudflare-task-tracker-OCFIVXEJ.js +20 -0
  21. package/payload/server/maxy-edge.js +5 -6
  22. package/payload/server/public/assets/{Checkbox-BySsatDO.js → Checkbox-B9hff9s8.js} +1 -1
  23. package/payload/server/public/assets/{admin-CCML_l4E.js → admin-Cpi6L_g7.js} +3 -3
  24. package/payload/server/public/assets/data-Da6iYRW1.js +1 -0
  25. package/payload/server/public/assets/graph-BHq-JYwV.js +1 -0
  26. package/payload/server/public/assets/{useAdminFetch-B3MO55eB.js → graph-labels-ChinGFwI.js} +1 -1
  27. package/payload/server/public/assets/{jsx-runtime-O5ef8xK8.css → jsx-runtime-CVA1ZrPS.css} +1 -1
  28. package/payload/server/public/assets/page-DqPf65sS.js +50 -0
  29. package/payload/server/public/assets/page-OVrxtgOZ.js +1 -0
  30. package/payload/server/public/assets/{public-DRrf63wm.js → public-CJN5KAiK.js} +1 -1
  31. package/payload/server/public/assets/{useVoiceRecorder-CR8gcELb.js → useVoiceRecorder-DyVx7e7a.js} +1 -1
  32. package/payload/server/public/data.html +5 -5
  33. package/payload/server/public/graph.html +6 -6
  34. package/payload/server/public/index.html +8 -8
  35. package/payload/server/public/public.html +5 -5
  36. package/payload/server/server.js +211 -165
  37. package/payload/server/public/assets/data-BuuqlV4L.js +0 -1
  38. package/payload/server/public/assets/graph-CtVITeok.js +0 -1
  39. package/payload/server/public/assets/page-Ddc_nKh8.js +0 -1
  40. package/payload/server/public/assets/page-IQBQoOdT.js +0 -50
  41. /package/payload/server/public/assets/{jsx-runtime-DnY0498s.js → jsx-runtime-nxP_2eNo.js} +0 -0
@@ -1,9 +1,19 @@
1
1
  import {
2
+ ACCOUNTS_DIR,
2
3
  ATTACHMENTS_ROOT,
4
+ CDP_PORT,
5
+ COMMERCIAL_MODE,
3
6
  Hono,
7
+ LOG_DIR,
8
+ MAXY_DIR,
4
9
  MAX_FILES_PER_MESSAGE,
5
10
  MAX_FILE_SIZE_BYTES,
11
+ PLATFORM_ROOT,
6
12
  SUPPORTED_MIME_TYPES,
13
+ TELEGRAM_ADMIN_WEBHOOK_SECRET_FILE,
14
+ TELEGRAM_WEBHOOK_SECRET_FILE,
15
+ USERS_FILE,
16
+ WEBSOCKIFY_PORT,
7
17
  assertSupportedMime,
8
18
  autoDeliverPremiumPlugins,
9
19
  browserViewerLog,
@@ -25,6 +35,8 @@ import {
25
35
  ensureLogDir,
26
36
  ensureVnc,
27
37
  findMissingPlugins,
38
+ getDefaultAccountId,
39
+ hasStubAccountDir,
28
40
  hashPassword,
29
41
  httpLog,
30
42
  invokeAgent,
@@ -37,13 +49,19 @@ import {
37
49
  load,
38
50
  logPath,
39
51
  pickComponentBytes,
52
+ preflushSliceOf,
40
53
  recordFailedAttempt,
41
54
  render,
42
55
  renderLoginPage,
43
56
  requireAdminSession,
57
+ resolveAccount,
58
+ resolveAgentConfig,
44
59
  resolveBrowserTransport,
45
60
  resolveClientIp,
61
+ resolveConversationLogPaths,
62
+ resolveDefaultAgentSlug,
46
63
  resolveEntitlement,
64
+ resolveUserAccounts,
47
65
  safeJson,
48
66
  sanitizeClientCorrId,
49
67
  serve,
@@ -56,6 +74,7 @@ import {
56
74
  streamLogPathFor,
57
75
  stripAttachmentMetaSuffix,
58
76
  tryCookieBridgeForConversation,
77
+ validateAgentSlug,
59
78
  validateFilePathInAccount,
60
79
  validateKey,
61
80
  validatePasswordStrength,
@@ -64,25 +83,14 @@ import {
64
83
  vncLog,
65
84
  waitForExit,
66
85
  writeChromiumWrapper
67
- } from "./chunk-2Q2S52GB.js";
86
+ } from "./chunk-DHSBEMWW.js";
68
87
  import {
69
- ACCOUNTS_DIR,
70
- CDP_PORT,
71
- COMMERCIAL_MODE,
72
- LOG_DIR,
73
- MAXY_DIR,
74
- PLATFORM_ROOT,
75
- TELEGRAM_ADMIN_WEBHOOK_SECRET_FILE,
76
- TELEGRAM_WEBHOOK_SECRET_FILE,
77
- USERS_FILE,
78
- WEBSOCKIFY_PORT,
79
88
  agentLogStream,
80
89
  clearSessionHistory,
81
90
  completeGrantSetup,
82
91
  getAccountIdForSession,
83
92
  getAgentNameForSession,
84
93
  getConversationIdForSession,
85
- getDefaultAccountId,
86
94
  getGrantForSession,
87
95
  getGroupSlugForSession,
88
96
  getRoleForSession,
@@ -90,26 +98,19 @@ import {
90
98
  getUserIdForSession,
91
99
  getUserNameForSession,
92
100
  getVisitorIdForSession,
93
- hasStubAccountDir,
94
101
  interruptClient,
95
102
  listAdminSessionsInProgress,
96
103
  preConversationLogStream,
97
- preflushStreamLogKey,
98
104
  registerGrantSession,
99
105
  registerResumedSession,
100
106
  registerSession,
101
- resolveAccount,
102
- resolveAgentConfig,
103
- resolveDefaultAgentSlug,
104
- resolveUserAccounts,
105
107
  setAgentSessionId,
106
108
  setConversationIdForSession,
107
109
  setGroupContextForSession,
108
110
  sigtermFlushStreamLogs,
109
111
  unregisterSession,
110
- validateAgentSlug,
111
112
  validateSession
112
- } from "./chunk-22LK7D5R.js";
113
+ } from "./chunk-TOLLHW7W.js";
113
114
  import {
114
115
  CLOUDFLARE_TASK_DIAGNOSTICS,
115
116
  appendCloudflareSteps,
@@ -117,13 +118,14 @@ import {
117
118
  openCloudflareTask,
118
119
  readTunnelState,
119
120
  resolveUnitGoneVerdict
120
- } from "./chunk-BY4LZDL4.js";
121
+ } from "./chunk-UXLZ5Z3Y.js";
121
122
  import {
122
123
  GREETING_DIRECTIVE,
123
124
  HAIKU_MODEL,
124
125
  backfillNullUserIdConversations,
125
126
  bindVisitorToGroup,
126
127
  checkGroupMembership,
128
+ createNewAdminConversation,
127
129
  deleteAgentProjection,
128
130
  deleteConversation,
129
131
  embed,
@@ -148,7 +150,7 @@ import {
148
150
  verifyAndGetConversationUpdatedAt,
149
151
  verifyConversationOwnership,
150
152
  writeAdminUserAndPerson
151
- } from "./chunk-7ADUQXTU.js";
153
+ } from "./chunk-FHNFKJZN.js";
152
154
  import {
153
155
  __commonJS,
154
156
  __toESM
@@ -651,8 +653,8 @@ var serveStatic = (options = { root: "" }) => {
651
653
  };
652
654
 
653
655
  // server/index.ts
654
- import { readFileSync as readFileSync18, existsSync as existsSync24, watchFile } from "fs";
655
- import { resolve as resolve21, join as join12, basename as basename4 } from "path";
656
+ import { readFileSync as readFileSync18, existsSync as existsSync23, watchFile } from "fs";
657
+ import { resolve as resolve21, join as join11, basename as basename4 } from "path";
656
658
  import { homedir as homedir3 } from "os";
657
659
 
658
660
  // app/lib/agent-slug-pattern.ts
@@ -7147,6 +7149,7 @@ var session_default2 = app10;
7147
7149
  // server/routes/admin/chat.ts
7148
7150
  import { resolve as resolve8 } from "path";
7149
7151
  import { appendFileSync as appendFileSync3 } from "fs";
7152
+ import { randomUUID as randomUUID6 } from "crypto";
7150
7153
 
7151
7154
  // app/lib/script-stream-tailer.ts
7152
7155
  import * as childProcess from "child_process";
@@ -7436,7 +7439,7 @@ var app11 = new Hono();
7436
7439
  app11.post("/cancel", requireAdminSession, async (c) => {
7437
7440
  const session_key = c.var.sessionKey;
7438
7441
  try {
7439
- const { interruptClient: interruptClient2 } = await import("./client-pool-3BCJTPPA.js");
7442
+ const { interruptClient: interruptClient2 } = await import("./client-pool-2IUOSYDF.js");
7440
7443
  await interruptClient2(session_key);
7441
7444
  return c.json({ ok: true });
7442
7445
  } catch (err) {
@@ -7593,17 +7596,29 @@ app11.post("/", requireAdminSession, async (c) => {
7593
7596
  if (!isSystemMessage) {
7594
7597
  gatewayResult = await processInbound(message, "web-admin");
7595
7598
  }
7596
- const encoder = new TextEncoder();
7597
- const sseConvId = getConversationIdForSession(session_key);
7598
- const sseLogStream = sseConvId ? agentLogStream("sse-events", account.accountDir, sseConvId) : preConversationLogStream("sse-events", account.accountDir);
7599
- const sk = sseConvId?.slice(0, 8) ?? session_key.slice(0, 8);
7600
- function resolveTeeStreamLogPath() {
7601
- const liveConvId = getConversationIdForSession(session_key);
7602
- const key = liveConvId ?? preflushStreamLogKey(session_key);
7603
- return resolve8(account.accountDir, "logs", `claude-agent-stream-${key}.log`);
7599
+ let conversationId = getConversationIdForSession(session_key);
7600
+ if (!conversationId) {
7601
+ const userId = getUserIdForSession(session_key);
7602
+ const userName = getUserNameForSession(session_key);
7603
+ const accountId = getAccountIdForSession(session_key);
7604
+ if (!userId || !accountId) {
7605
+ return chatReject(401, "Invalid or expired admin session", session_key);
7606
+ }
7607
+ const minted = randomUUID6();
7608
+ const created = await createNewAdminConversation(userId, accountId, session_key, userName, minted);
7609
+ if (!created) {
7610
+ return chatReject(500, "Failed to create conversation", session_key);
7611
+ }
7612
+ conversationId = created;
7613
+ setConversationIdForSession(session_key, conversationId);
7614
+ console.log(`[chat-route] new conversation conversationId=${conversationId} sessionKey=${session_key.slice(0, 12)}\u2026`);
7604
7615
  }
7616
+ const encoder = new TextEncoder();
7617
+ const sseLogStream = agentLogStream("sse-events", account.accountDir, conversationId);
7618
+ const sk = conversationId.slice(0, 8);
7619
+ const teeStreamLogPath = resolve8(account.accountDir, "logs", `claude-agent-stream-${conversationId}.log`);
7605
7620
  try {
7606
- appendFileSync3(resolveTeeStreamLogPath(), `[${(/* @__PURE__ */ new Date()).toISOString()}] [chat-route-version=task606-tee-path-resolve] sessionKey=${session_key.slice(0, 12)}\u2026
7621
+ appendFileSync3(teeStreamLogPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] [chat-route-version=task965-mint-at-entry] sessionKey=${session_key.slice(0, 12)}\u2026 conversationId=${conversationId}
7607
7622
  `);
7608
7623
  } catch {
7609
7624
  }
@@ -7612,7 +7627,7 @@ app11.post("/", requireAdminSession, async (c) => {
7612
7627
  incoming.on("close", () => {
7613
7628
  const tsClose = (/* @__PURE__ */ new Date()).toISOString();
7614
7629
  try {
7615
- appendFileSync3(resolveTeeStreamLogPath(), `[${tsClose}] [incoming-close] sessionKey=${session_key.slice(0, 12)}\u2026 complete=${incoming.complete}
7630
+ appendFileSync3(teeStreamLogPath, `[${tsClose}] [incoming-close] sessionKey=${session_key.slice(0, 12)}\u2026 complete=${incoming.complete}
7616
7631
  `);
7617
7632
  } catch {
7618
7633
  }
@@ -7620,7 +7635,7 @@ app11.post("/", requireAdminSession, async (c) => {
7620
7635
  console.error(`[${tsClose}] [incoming-close] DISCONNECT sessionKey=${session_key.slice(0, 12)}\u2026`);
7621
7636
  interruptClient(session_key).catch((err) => {
7622
7637
  try {
7623
- appendFileSync3(resolveTeeStreamLogPath(), `[${(/* @__PURE__ */ new Date()).toISOString()}] [incoming-close] interrupt-failed: ${err instanceof Error ? err.message : String(err)}
7638
+ appendFileSync3(teeStreamLogPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] [incoming-close] interrupt-failed: ${err instanceof Error ? err.message : String(err)}
7624
7639
  `);
7625
7640
  } catch {
7626
7641
  }
@@ -7629,7 +7644,7 @@ app11.post("/", requireAdminSession, async (c) => {
7629
7644
  });
7630
7645
  } else {
7631
7646
  try {
7632
- appendFileSync3(resolveTeeStreamLogPath(), `[${(/* @__PURE__ */ new Date()).toISOString()}] [incoming-close] UNAVAILABLE \u2014 c.env.incoming is not an EventEmitter
7647
+ appendFileSync3(teeStreamLogPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] [incoming-close] UNAVAILABLE \u2014 c.env.incoming is not an EventEmitter
7633
7648
  `);
7634
7649
  } catch {
7635
7650
  }
@@ -7641,7 +7656,7 @@ app11.post("/", requireAdminSession, async (c) => {
7641
7656
  } catch {
7642
7657
  }
7643
7658
  try {
7644
- appendFileSync3(resolveTeeStreamLogPath(), line);
7659
+ appendFileSync3(teeStreamLogPath, line);
7645
7660
  } catch {
7646
7661
  }
7647
7662
  return true;
@@ -7681,13 +7696,12 @@ app11.post("/", requireAdminSession, async (c) => {
7681
7696
  },
7682
7697
  async start(controller) {
7683
7698
  let controllerOpen = true;
7684
- const sseEntry = { controller, conversationId: sseConvId ?? null, sessionKey: session_key };
7699
+ const sseEntry = { controller, conversationId, sessionKey: session_key };
7685
7700
  try {
7686
7701
  const reqSignal = c.req.raw?.signal;
7687
7702
  if (reqSignal) {
7688
7703
  reqSignal.addEventListener("abort", () => {
7689
- const abortLogKey = sseConvId ?? preflushStreamLogKey(session_key);
7690
- const abortStreamLog = agentLogStream("claude-agent-stream", account.accountDir, abortLogKey);
7704
+ const abortStreamLog = agentLogStream("claude-agent-stream", account.accountDir, conversationId);
7691
7705
  const ts = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
7692
7706
  sseLog.write(`[${ts}] [${sk}] admin: ABORT [operator-cancel] interrupting pool client
7693
7707
  `);
@@ -7701,28 +7715,25 @@ app11.post("/", requireAdminSession, async (c) => {
7701
7715
  }
7702
7716
  try {
7703
7717
  registerAdminSSE(sseEntry);
7704
- if (sseConvId) {
7705
- const streamLogPath = resolve8(account.accountDir, "logs", `claude-agent-stream-${sseConvId}.log`);
7706
- tailer = startScriptStreamTailer({
7707
- path: streamLogPath,
7708
- onEvent: (event) => {
7709
- if (!controllerOpen) return;
7710
- const ts = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
7711
- sseLog.write(`[${ts}] [${sk}] admin: ${JSON.stringify(event)}
7718
+ tailer = startScriptStreamTailer({
7719
+ path: teeStreamLogPath,
7720
+ onEvent: (event) => {
7721
+ if (!controllerOpen) return;
7722
+ const ts = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
7723
+ sseLog.write(`[${ts}] [${sk}] admin: ${JSON.stringify(event)}
7712
7724
  `);
7713
- try {
7714
- controller.enqueue(encoder.encode(`data: ${JSON.stringify(event)}
7725
+ try {
7726
+ controller.enqueue(encoder.encode(`data: ${JSON.stringify(event)}
7715
7727
 
7716
7728
  `));
7717
- } catch {
7718
- controllerOpen = false;
7719
- }
7720
- },
7721
- onError: (err) => {
7722
- console.error(`[script-stream-tailer] ${streamLogPath}: ${err.message}`);
7729
+ } catch {
7730
+ controllerOpen = false;
7723
7731
  }
7724
- });
7725
- }
7732
+ },
7733
+ onError: (err) => {
7734
+ console.error(`[script-stream-tailer] ${teeStreamLogPath}: ${err.message}`);
7735
+ }
7736
+ });
7726
7737
  for await (const event of invokeAgent(
7727
7738
  { type: "admin", skipTopicCheck },
7728
7739
  message,
@@ -7831,42 +7842,8 @@ app12.post("/", requireAdminSession, async (c) => {
7831
7842
  var compact_default = app12;
7832
7843
 
7833
7844
  // server/routes/admin/logs.ts
7834
- import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as readFileSync11, statSync as statSync6 } from "fs";
7845
+ import { existsSync as existsSync12, readdirSync as readdirSync5, readFileSync as readFileSync11, statSync as statSync6 } from "fs";
7835
7846
  import { resolve as resolve9, basename as basename2 } from "path";
7836
-
7837
- // app/lib/logs-read-resolve.ts
7838
- import { existsSync as existsSync12 } from "fs";
7839
- import { join as join9 } from "path";
7840
- function resolveConversationLogPaths(fullFilename, preflushFilename, logDirs) {
7841
- const tried = [fullFilename, preflushFilename];
7842
- const hits = [];
7843
- const stalePreflushPaths = [];
7844
- for (const dir of logDirs) {
7845
- const fullPath = join9(dir, fullFilename);
7846
- if (existsSync12(fullPath)) {
7847
- hits.push({ path: fullPath, shape: "full", dir });
7848
- const preflushSibling = join9(dir, preflushFilename);
7849
- if (existsSync12(preflushSibling)) {
7850
- stalePreflushPaths.push(preflushSibling);
7851
- }
7852
- }
7853
- }
7854
- if (hits.length > 0) {
7855
- return { hits, stalePreflushPaths, tried };
7856
- }
7857
- for (const dir of logDirs) {
7858
- const preflushPath = join9(dir, preflushFilename);
7859
- if (existsSync12(preflushPath)) {
7860
- hits.push({ path: preflushPath, shape: "preflush", dir });
7861
- }
7862
- }
7863
- return { hits, stalePreflushPaths, tried };
7864
- }
7865
- function preflushSliceOf(id) {
7866
- return `preflush-${id.slice(0, 12)}`;
7867
- }
7868
-
7869
- // server/routes/admin/logs.ts
7870
7847
  var TAIL_BYTES = 8192;
7871
7848
  var app13 = new Hono();
7872
7849
  app13.get("/", async (c) => {
@@ -7958,7 +7935,7 @@ app13.get("/", async (c) => {
7958
7935
  }
7959
7936
  const MISSING_SENTINEL = ".task702-identifier-not-supplied.log";
7960
7937
  const fullFilename = conversationId ? `${prefix}-${conversationId}.log` : MISSING_SENTINEL;
7961
- const preflushFilename = sessionKey ? `${prefix}-${preflushSliceOf(sessionKey)}.log` : MISSING_SENTINEL;
7938
+ const preflushFilename = sessionKey && typeParam === "public" ? `${prefix}-${preflushSliceOf(sessionKey)}.log` : MISSING_SENTINEL;
7962
7939
  const { hits, stalePreflushPaths, tried } = resolveConversationLogPaths(
7963
7940
  fullFilename,
7964
7941
  preflushFilename,
@@ -8015,7 +7992,7 @@ app13.get("/", async (c) => {
8015
7992
  const seen = /* @__PURE__ */ new Set();
8016
7993
  const logs = {};
8017
7994
  for (const dir of logDirs) {
8018
- if (!existsSync13(dir)) continue;
7995
+ if (!existsSync12(dir)) continue;
8019
7996
  let files;
8020
7997
  try {
8021
7998
  files = readdirSync5(dir).filter((f) => f.endsWith(".log"));
@@ -8066,7 +8043,7 @@ var claude_info_default = app14;
8066
8043
 
8067
8044
  // server/routes/admin/attachment.ts
8068
8045
  import { readFile as readFile2, readdir } from "fs/promises";
8069
- import { existsSync as existsSync14 } from "fs";
8046
+ import { existsSync as existsSync13 } from "fs";
8070
8047
  import { resolve as resolve10 } from "path";
8071
8048
  var app15 = new Hono();
8072
8049
  app15.get("/:attachmentId", requireAdminSession, async (c) => {
@@ -8080,11 +8057,11 @@ app15.get("/:attachmentId", requireAdminSession, async (c) => {
8080
8057
  return new Response("Not found", { status: 404 });
8081
8058
  }
8082
8059
  const dir = resolve10(ATTACHMENTS_ROOT, accountId, attachmentId);
8083
- if (!existsSync14(dir)) {
8060
+ if (!existsSync13(dir)) {
8084
8061
  return new Response("Not found", { status: 404 });
8085
8062
  }
8086
8063
  const metaPath = resolve10(dir, `${attachmentId}.meta.json`);
8087
- if (!existsSync14(metaPath)) {
8064
+ if (!existsSync13(metaPath)) {
8088
8065
  return new Response("Not found", { status: 404 });
8089
8066
  }
8090
8067
  let meta;
@@ -8112,13 +8089,13 @@ var attachment_default = app15;
8112
8089
 
8113
8090
  // server/routes/admin/agents.ts
8114
8091
  import { resolve as resolve11 } from "path";
8115
- import { readdirSync as readdirSync6, readFileSync as readFileSync12, existsSync as existsSync15, rmSync } from "fs";
8092
+ import { readdirSync as readdirSync6, readFileSync as readFileSync12, existsSync as existsSync14, rmSync } from "fs";
8116
8093
  var app16 = new Hono();
8117
8094
  app16.get("/", (c) => {
8118
8095
  const account = resolveAccount();
8119
8096
  if (!account) return c.json({ agents: [] });
8120
8097
  const agentsDir = resolve11(account.accountDir, "agents");
8121
- if (!existsSync15(agentsDir)) return c.json({ agents: [] });
8098
+ if (!existsSync14(agentsDir)) return c.json({ agents: [] });
8122
8099
  const agents = [];
8123
8100
  try {
8124
8101
  const entries = readdirSync6(agentsDir, { withFileTypes: true });
@@ -8126,7 +8103,7 @@ app16.get("/", (c) => {
8126
8103
  if (!entry.isDirectory()) continue;
8127
8104
  if (entry.name === "admin") continue;
8128
8105
  const configPath2 = resolve11(agentsDir, entry.name, "config.json");
8129
- if (!existsSync15(configPath2)) continue;
8106
+ if (!existsSync14(configPath2)) continue;
8130
8107
  try {
8131
8108
  const config = JSON.parse(readFileSync12(configPath2, "utf-8"));
8132
8109
  agents.push({
@@ -8155,7 +8132,7 @@ app16.delete("/:slug", async (c) => {
8155
8132
  return c.json({ error: "Invalid agent slug" }, 400);
8156
8133
  }
8157
8134
  const agentDir = resolve11(account.accountDir, "agents", slug);
8158
- if (!existsSync15(agentDir)) {
8135
+ if (!existsSync14(agentDir)) {
8159
8136
  return c.json({ error: "Agent not found" }, 404);
8160
8137
  }
8161
8138
  try {
@@ -8185,7 +8162,7 @@ app16.post("/:slug/project", async (c) => {
8185
8162
  return c.json({ error: "Invalid agent slug" }, 400);
8186
8163
  }
8187
8164
  const agentDir = resolve11(account.accountDir, "agents", slug);
8188
- if (!existsSync15(agentDir)) {
8165
+ if (!existsSync14(agentDir)) {
8189
8166
  return c.json({ error: "Agent not found on disk" }, 404);
8190
8167
  }
8191
8168
  try {
@@ -8201,7 +8178,7 @@ var agents_default = app16;
8201
8178
  // server/routes/admin/sessions.ts
8202
8179
  import crypto2 from "crypto";
8203
8180
  import { resolve as resolvePath } from "path";
8204
- import { appendFileSync as appendFileSync4, existsSync as existsSync17 } from "fs";
8181
+ import { appendFileSync as appendFileSync4, existsSync as existsSync16 } from "fs";
8205
8182
 
8206
8183
  // app/lib/synthetic-marker.ts
8207
8184
  var CLOUDFLARE_MARKER_PREFIX = "Cloudflare setup completed (actionId: ";
@@ -8213,9 +8190,9 @@ function isSyntheticUserMarker(content) {
8213
8190
  }
8214
8191
 
8215
8192
  // app/lib/claude-agent/jsonl-replay.ts
8216
- import { existsSync as existsSync16, readFileSync as readFileSync13 } from "fs";
8193
+ import { existsSync as existsSync15, readFileSync as readFileSync13 } from "fs";
8217
8194
  function replayJsonl(jsonlPath) {
8218
- if (!existsSync16(jsonlPath)) {
8195
+ if (!existsSync15(jsonlPath)) {
8219
8196
  return { messages: [], jsonlMissing: true, malformedLines: 0 };
8220
8197
  }
8221
8198
  let raw;
@@ -8349,7 +8326,7 @@ function validateAndShapeAttachments(raws, conversationAccountId, conversationId
8349
8326
  let reason = null;
8350
8327
  if (!a.attachmentId || !a.filename || !a.mimeType || !a.storagePath) reason = "schema-fail";
8351
8328
  else if (a.accountId !== conversationAccountId) reason = "account-mismatch";
8352
- else if (!existsSync17(a.storagePath)) reason = "missing-file";
8329
+ else if (!existsSync16(a.storagePath)) reason = "missing-file";
8353
8330
  if (reason) {
8354
8331
  invalid++;
8355
8332
  try {
@@ -9125,12 +9102,12 @@ function isValidDomain(value) {
9125
9102
  }
9126
9103
 
9127
9104
  // app/lib/alias-domains.ts
9128
- import { existsSync as existsSync18, mkdirSync as mkdirSync6, readFileSync as readFileSync14, writeFileSync as writeFileSync7 } from "fs";
9105
+ import { existsSync as existsSync17, mkdirSync as mkdirSync6, readFileSync as readFileSync14, writeFileSync as writeFileSync7 } from "fs";
9129
9106
  import { dirname as dirname5 } from "path";
9130
9107
  import { resolve as resolve12 } from "path";
9131
9108
  var ALIAS_DOMAINS_PATH = resolve12(MAXY_DIR, "alias-domains.json");
9132
9109
  function readExisting() {
9133
- if (!existsSync18(ALIAS_DOMAINS_PATH)) return /* @__PURE__ */ new Set();
9110
+ if (!existsSync17(ALIAS_DOMAINS_PATH)) return /* @__PURE__ */ new Set();
9134
9111
  try {
9135
9112
  const parsed = JSON.parse(readFileSync14(ALIAS_DOMAINS_PATH, "utf-8"));
9136
9113
  if (!Array.isArray(parsed)) return /* @__PURE__ */ new Set();
@@ -9378,8 +9355,8 @@ app22.get("/tunnels", requireAdminSession, async (c) => {
9378
9355
  if (!correlationId) return err("session", "No active conversation for session \u2014 refresh chat.");
9379
9356
  streamLogPath = streamLogPathFor(accountId, correlationId).streamLogPath;
9380
9357
  const certPath = resolve13(homedir2(), brand.configDir, "cloudflared", "cert.pem");
9381
- const { existsSync: existsSync25 } = await import("fs");
9382
- if (!existsSync25(certPath)) {
9358
+ const { existsSync: existsSync24 } = await import("fs");
9359
+ if (!existsSync24(certPath)) {
9383
9360
  return err("cert", `Cloudflare origin certificate is not on disk yet (${certPath}). Complete the Cloudflare login first by submitting the form once \u2014 the OAuth flow writes cert.pem.`);
9384
9361
  }
9385
9362
  const result = await runFormSpawn({
@@ -9677,7 +9654,7 @@ var cloudflare_default = app22;
9677
9654
  import { createReadStream as createReadStream3 } from "fs";
9678
9655
  import { readdir as readdir2, readFile as readFile3, stat as stat3, mkdir as mkdir2, writeFile as writeFile3, unlink as unlink2 } from "fs/promises";
9679
9656
  import { realpathSync as realpathSync3 } from "fs";
9680
- import { basename as basename3, dirname as dirname6, join as join10, resolve as resolve15, sep as sep2 } from "path";
9657
+ import { basename as basename3, dirname as dirname6, join as join9, resolve as resolve15, sep as sep2 } from "path";
9681
9658
  import { Readable as Readable2 } from "stream";
9682
9659
 
9683
9660
  // app/lib/data-path.ts
@@ -10035,7 +10012,7 @@ async function cascadeDeleteDocument(params) {
10035
10012
  var UUID_RE4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
10036
10013
  async function readMeta(absDir, baseName) {
10037
10014
  try {
10038
- const raw = await readFile3(join10(absDir, `${baseName}.meta.json`), "utf8");
10015
+ const raw = await readFile3(join9(absDir, `${baseName}.meta.json`), "utf8");
10039
10016
  const parsed = JSON.parse(raw);
10040
10017
  if (typeof parsed?.filename === "string") {
10041
10018
  return { filename: parsed.filename, mimeType: typeof parsed.mimeType === "string" ? parsed.mimeType : void 0 };
@@ -10073,7 +10050,7 @@ async function readAccountNames() {
10073
10050
  }
10074
10051
  async function enrich(absolute, entry, accountNames) {
10075
10052
  if (entry.kind === "directory" && UUID_RE4.test(entry.name)) {
10076
- const meta = await readMeta(join10(absolute, entry.name), entry.name);
10053
+ const meta = await readMeta(join9(absolute, entry.name), entry.name);
10077
10054
  if (meta?.filename) {
10078
10055
  entry.displayName = meta.filename;
10079
10056
  entry.mimeType = meta.mimeType;
@@ -10132,7 +10109,7 @@ app23.get("/", requireAdminSession, async (c) => {
10132
10109
  continue;
10133
10110
  }
10134
10111
  try {
10135
- const entryPath = join10(absolute, name);
10112
+ const entryPath = join9(absolute, name);
10136
10113
  const s = await stat3(entryPath);
10137
10114
  entries.push({
10138
10115
  name,
@@ -10305,7 +10282,7 @@ app23.delete("/", requireAdminSession, async (c) => {
10305
10282
  }
10306
10283
  const dot = base.lastIndexOf(".");
10307
10284
  const stem = dot === -1 ? base : base.slice(0, dot);
10308
- const sidecarPath = UUID_RE4.test(stem) && base !== `${stem}.meta.json` ? join10(dirname6(absolute), `${stem}.meta.json`) : null;
10285
+ const sidecarPath = UUID_RE4.test(stem) && base !== `${stem}.meta.json` ? join9(dirname6(absolute), `${stem}.meta.json`) : null;
10309
10286
  await unlink2(absolute);
10310
10287
  if (sidecarPath) {
10311
10288
  try {
@@ -10460,7 +10437,16 @@ async function hybrid(session, embed2, params) {
10460
10437
  bm25Score: normalised[i] ?? 0,
10461
10438
  related: []
10462
10439
  }));
10463
- return { mode: "bm25", results: results2, embedError: msg, expandMs: 0 };
10440
+ return {
10441
+ mode: "bm25",
10442
+ results: results2,
10443
+ embedError: msg,
10444
+ expandMs: 0,
10445
+ rawMerged: results2.length,
10446
+ suppressed: 0,
10447
+ bm25Bypass: 0,
10448
+ threshold: null
10449
+ };
10464
10450
  }
10465
10451
  const labelToIndex = await discoverIndexes(session);
10466
10452
  const keywordFilter = buildKeywordFilter(keywords, keywordMatch);
@@ -10471,7 +10457,15 @@ async function hybrid(session, embed2, params) {
10471
10457
  if (labels && labels.length > 0) {
10472
10458
  indexesToQuery = labels.map((l) => labelToIndex.get(l)).filter((idx) => idx !== void 0);
10473
10459
  if (indexesToQuery.length === 0) {
10474
- return { mode: "hybrid", results: [], expandMs: 0 };
10460
+ return {
10461
+ mode: "hybrid",
10462
+ results: [],
10463
+ expandMs: 0,
10464
+ rawMerged: 0,
10465
+ suppressed: 0,
10466
+ bm25Bypass: 0,
10467
+ threshold: params.vectorThreshold ?? null
10468
+ };
10475
10469
  }
10476
10470
  } else {
10477
10471
  indexesToQuery = [...new Set(labelToIndex.values())];
@@ -10516,7 +10510,8 @@ async function hybrid(session, embed2, params) {
10516
10510
  labels: record.get("nodeLabels"),
10517
10511
  properties: plainProperties(node.properties),
10518
10512
  vectorScore: score,
10519
- bm25Score: 0
10513
+ bm25Score: 0,
10514
+ bm25Hit: false
10520
10515
  });
10521
10516
  }
10522
10517
  }
@@ -10566,6 +10561,7 @@ async function hybrid(session, embed2, params) {
10566
10561
  const existing = scoreMap.get(nodeId);
10567
10562
  if (existing) {
10568
10563
  existing.bm25Score = Math.max(existing.bm25Score, 1);
10564
+ existing.bm25Hit = true;
10569
10565
  } else {
10570
10566
  const node = record.get("node");
10571
10567
  scoreMap.set(nodeId, {
@@ -10573,15 +10569,33 @@ async function hybrid(session, embed2, params) {
10573
10569
  labels: record.get("nodeLabels"),
10574
10570
  properties: plainProperties(node.properties),
10575
10571
  vectorScore: 0,
10576
- bm25Score: 1
10572
+ bm25Score: 1,
10573
+ bm25Hit: true
10577
10574
  });
10578
10575
  }
10579
10576
  }
10580
10577
  }
10581
- const merged = [...scoreMap.values()].map((node) => ({
10578
+ const allMerged = [...scoreMap.values()].map((node) => ({
10582
10579
  ...node,
10583
10580
  combinedScore: VECTOR_WEIGHT * node.vectorScore + BM25_WEIGHT * node.bm25Score
10584
- })).sort((a, b) => b.combinedScore - a.combinedScore).slice(0, limit);
10581
+ }));
10582
+ const rawMerged = allMerged.length;
10583
+ const threshold = params.vectorThreshold;
10584
+ let kept = allMerged;
10585
+ let bm25Bypass = 0;
10586
+ if (threshold !== void 0) {
10587
+ kept = [];
10588
+ for (const node of allMerged) {
10589
+ if (node.vectorScore >= threshold) {
10590
+ kept.push(node);
10591
+ } else if (node.bm25Hit) {
10592
+ kept.push(node);
10593
+ bm25Bypass++;
10594
+ }
10595
+ }
10596
+ }
10597
+ const suppressed = rawMerged - kept.length;
10598
+ const merged = kept.sort((a, b) => b.combinedScore - a.combinedScore).slice(0, limit);
10585
10599
  const results = merged.map((node) => ({
10586
10600
  nodeId: node.nodeId,
10587
10601
  labels: node.labels,
@@ -10637,19 +10651,29 @@ async function hybrid(session, embed2, params) {
10637
10651
  }
10638
10652
  }
10639
10653
  }
10640
- return { mode: "hybrid", results, expandMs };
10654
+ return {
10655
+ mode: "hybrid",
10656
+ results,
10657
+ expandMs,
10658
+ rawMerged,
10659
+ suppressed,
10660
+ bm25Bypass,
10661
+ threshold: threshold ?? null
10662
+ };
10641
10663
  }
10642
10664
  function mergeBm25Hit(map, hit, normalisedScore) {
10643
10665
  const existing = map.get(hit.nodeId);
10644
10666
  if (existing) {
10645
10667
  existing.bm25Score = Math.max(existing.bm25Score, normalisedScore);
10668
+ existing.bm25Hit = true;
10646
10669
  } else {
10647
10670
  map.set(hit.nodeId, {
10648
10671
  nodeId: hit.nodeId,
10649
10672
  labels: hit.labels,
10650
10673
  properties: hit.properties,
10651
10674
  vectorScore: 0,
10652
- bm25Score: normalisedScore
10675
+ bm25Score: normalisedScore,
10676
+ bm25Hit: true
10653
10677
  });
10654
10678
  }
10655
10679
  }
@@ -10669,6 +10693,7 @@ function plainProperties(properties) {
10669
10693
  // server/routes/admin/graph-search.ts
10670
10694
  var DEFAULT_LIMIT = 20;
10671
10695
  var MAX_LIMIT = 2e3;
10696
+ var DEFAULT_VECTOR_THRESHOLD = 0.72;
10672
10697
  var MESSAGE_FAMILY_LABELS = ["Message", "UserMessage", "AssistantMessage", "WhatsAppMessage"];
10673
10698
  var CONVERSATION_PARENT_LABELS = /* @__PURE__ */ new Set(["AdminConversation", "PublicConversation"]);
10674
10699
  var app24 = new Hono();
@@ -10677,6 +10702,7 @@ app24.get("/", requireAdminSession, async (c) => {
10677
10702
  const q = (c.req.query("q") ?? "").trim();
10678
10703
  const rawLimit = c.req.query("limit");
10679
10704
  const rawLabels = c.req.query("labels");
10705
+ const rawThreshold = c.req.query("threshold");
10680
10706
  const accountId = getAccountIdForSession(sessionKey);
10681
10707
  if (!accountId) {
10682
10708
  console.error(`[graph-search] auth-rejected endpoint="/api/admin/graph-search" reason="no account for session"`);
@@ -10690,6 +10716,13 @@ app24.get("/", requireAdminSession, async (c) => {
10690
10716
  }
10691
10717
  const parsedLimit = rawLimit ? parseInt(rawLimit, 10) : DEFAULT_LIMIT;
10692
10718
  const limit = Number.isFinite(parsedLimit) && parsedLimit > 0 ? Math.min(parsedLimit, MAX_LIMIT) : DEFAULT_LIMIT;
10719
+ let vectorThreshold = DEFAULT_VECTOR_THRESHOLD;
10720
+ if (rawThreshold !== void 0) {
10721
+ const parsed = Number(rawThreshold);
10722
+ if (Number.isFinite(parsed) && parsed >= 0 && parsed <= 1) {
10723
+ vectorThreshold = parsed;
10724
+ }
10725
+ }
10693
10726
  const wantsBodyFulltext = !wildcard && labels.some((l) => CONVERSATION_PARENT_LABELS.has(l));
10694
10727
  const forwardedLabels = wildcard ? void 0 : wantsBodyFulltext ? Array.from(/* @__PURE__ */ new Set([...labels, ...MESSAGE_FAMILY_LABELS])) : labels;
10695
10728
  const started = Date.now();
@@ -10700,7 +10733,8 @@ app24.get("/", requireAdminSession, async (c) => {
10700
10733
  accountId,
10701
10734
  labels: forwardedLabels,
10702
10735
  limit,
10703
- degradeOnEmbedFailure: true
10736
+ degradeOnEmbedFailure: true,
10737
+ vectorThreshold
10704
10738
  });
10705
10739
  const total = Date.now() - started;
10706
10740
  if (res.embedError) {
@@ -10767,11 +10801,23 @@ app24.get("/", requireAdminSession, async (c) => {
10767
10801
  console.error(
10768
10802
  `[graph-search] query="${q}" labels=${labelsToken} expanded=${expandedFlag} limit=${limit} mode=${res.mode} raw-results=${res.results.length} resolved-results=${resolvedResults.length} expand-ms=${res.expandMs} total-ms=${total}`
10769
10803
  );
10804
+ console.error(
10805
+ `[graph-search] threshold=${res.threshold ?? "off"} raw-merged=${res.rawMerged} suppressed=${res.suppressed} rendered=${res.results.length} bm25-bypass=${res.bm25Bypass}`
10806
+ );
10770
10807
  return c.json({
10771
10808
  results: resolvedResults,
10772
10809
  mode: res.mode,
10773
10810
  embedError: res.embedError,
10774
- elapsedMs: total
10811
+ elapsedMs: total,
10812
+ // Task 967 — UI surfaces ("N suppressed — show all" affordance on
10813
+ // /graph and /data). `suppressed` is the count of rows the lib
10814
+ // dropped via the vector-cosine floor; `threshold` echoes the value
10815
+ // applied (null when no filter ran). `bm25Bypass` is operator-only
10816
+ // diagnostic — kept on the wire so the /data score panel can flag
10817
+ // "kept by literal-match carve-out" rows in a future iteration.
10818
+ suppressed: res.suppressed,
10819
+ bm25Bypass: res.bm25Bypass,
10820
+ threshold: res.threshold
10775
10821
  });
10776
10822
  } catch (err) {
10777
10823
  const elapsed = Date.now() - started;
@@ -11927,7 +11973,7 @@ var adherence_default = app31;
11927
11973
  import neo4j3 from "neo4j-driver";
11928
11974
  import { readFile as readFile4, readdir as readdir3, stat as stat4 } from "fs/promises";
11929
11975
  import { resolve as resolve16, relative as relative2, isAbsolute } from "path";
11930
- import { existsSync as existsSync19 } from "fs";
11976
+ import { existsSync as existsSync18 } from "fs";
11931
11977
  var LIMIT = 50;
11932
11978
  var TEXT_MIME_PREFIXES = ["text/", "application/json", "application/markdown"];
11933
11979
  var ADMIN_AGENT_FILES = ["IDENTITY.md", "SOUL.md", "KNOWLEDGE.md"];
@@ -12075,7 +12121,7 @@ async function fetchAgentTemplateRows(accountDir) {
12075
12121
  async function unionSpecialistFilenames(overrideDir, bundledDir) {
12076
12122
  const names = /* @__PURE__ */ new Set();
12077
12123
  for (const dir of [overrideDir, bundledDir]) {
12078
- if (!existsSync19(dir)) continue;
12124
+ if (!existsSync18(dir)) continue;
12079
12125
  try {
12080
12126
  const entries = await readdir3(dir);
12081
12127
  for (const entry of entries) {
@@ -12090,7 +12136,7 @@ async function unionSpecialistFilenames(overrideDir, bundledDir) {
12090
12136
  }
12091
12137
  async function readAgentTemplateRow(inp) {
12092
12138
  let chosenPath = null;
12093
- if (existsSync19(inp.overridePath)) {
12139
+ if (existsSync18(inp.overridePath)) {
12094
12140
  try {
12095
12141
  validateFilePathInAccount(inp.overridePath, inp.overrideRoot);
12096
12142
  chosenPath = inp.overridePath;
@@ -12101,7 +12147,7 @@ async function readAgentTemplateRow(inp) {
12101
12147
  );
12102
12148
  return null;
12103
12149
  }
12104
- } else if (existsSync19(inp.bundledPath)) {
12150
+ } else if (existsSync18(inp.bundledPath)) {
12105
12151
  if (!isWithin(inp.bundledPath, inp.bundledRoot)) {
12106
12152
  console.error(
12107
12153
  `[admin/sidebar-artefacts] agent-template-read-failed agent=${inp.displayName} kind=${inp.logName} error="bundled path outside PLATFORM_ROOT"`
@@ -12143,7 +12189,7 @@ var sidebar_artefacts_default = app32;
12143
12189
  // server/routes/admin/sidebar-artefact-save.ts
12144
12190
  import { mkdir as mkdir3, readdir as readdir4, stat as stat5, writeFile as writeFile4 } from "fs/promises";
12145
12191
  import { resolve as resolve17 } from "path";
12146
- import { existsSync as existsSync20 } from "fs";
12192
+ import { existsSync as existsSync19 } from "fs";
12147
12193
  var ADMIN_AGENT_FILES2 = /* @__PURE__ */ new Set(["IDENTITY.md", "SOUL.md", "KNOWLEDGE.md"]);
12148
12194
  var UUID_RE5 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
12149
12195
  var app33 = new Hono();
@@ -12207,7 +12253,7 @@ async function resolveSavePath(id, accountId, accountDir) {
12207
12253
  }
12208
12254
  if (UUID_RE5.test(id)) {
12209
12255
  const dir = resolve17(ATTACHMENTS_ROOT, accountId, id);
12210
- if (!existsSync20(dir)) {
12256
+ if (!existsSync19(dir)) {
12211
12257
  return { kind: "reject", status: 400, reason: "not-found" };
12212
12258
  }
12213
12259
  try {
@@ -12231,7 +12277,7 @@ var sidebar_artefact_save_default = app33;
12231
12277
 
12232
12278
  // server/routes/admin/sidebar-artefact-content.ts
12233
12279
  import { readFile as readFile5, readdir as readdir5 } from "fs/promises";
12234
- import { existsSync as existsSync21 } from "fs";
12280
+ import { existsSync as existsSync20 } from "fs";
12235
12281
  import { resolve as resolve18 } from "path";
12236
12282
  var UUID_RE6 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
12237
12283
  var app34 = new Hono();
@@ -12245,7 +12291,7 @@ app34.get("/", requireAdminSession, async (c) => {
12245
12291
  return new Response("Not found", { status: 404 });
12246
12292
  }
12247
12293
  const dir = resolve18(ATTACHMENTS_ROOT, accountId, id);
12248
- if (!existsSync21(dir)) {
12294
+ if (!existsSync20(dir)) {
12249
12295
  console.error(`[admin/sidebar-artefact-content] not-found id=${id.slice(0, 8)}`);
12250
12296
  return new Response("Not found", { status: 404 });
12251
12297
  }
@@ -12279,12 +12325,12 @@ app34.get("/", requireAdminSession, async (c) => {
12279
12325
  var sidebar_artefact_content_default = app34;
12280
12326
 
12281
12327
  // server/routes/admin/health.ts
12282
- import { existsSync as existsSync22, readFileSync as readFileSync16 } from "fs";
12283
- import { resolve as resolve19, join as join11 } from "path";
12328
+ import { existsSync as existsSync21, readFileSync as readFileSync16 } from "fs";
12329
+ import { resolve as resolve19, join as join10 } from "path";
12284
12330
  var PLATFORM_ROOT6 = process.env.MAXY_PLATFORM_ROOT ?? resolve19(process.cwd(), "..");
12285
12331
  var brandHostname = "maxy";
12286
- var brandJsonPath = join11(PLATFORM_ROOT6, "config", "brand.json");
12287
- if (existsSync22(brandJsonPath)) {
12332
+ var brandJsonPath = join10(PLATFORM_ROOT6, "config", "brand.json");
12333
+ if (existsSync21(brandJsonPath)) {
12288
12334
  try {
12289
12335
  const brand = JSON.parse(readFileSync16(brandJsonPath, "utf-8"));
12290
12336
  if (brand.hostname) brandHostname = brand.hostname;
@@ -12295,7 +12341,7 @@ var VERSION_FILE = resolve19(PLATFORM_ROOT6, `config/.${brandHostname}-version`)
12295
12341
  var PROCESS_STARTED_AT = (/* @__PURE__ */ new Date()).toISOString();
12296
12342
  var PROBE_TIMEOUT_MS = 1e3;
12297
12343
  function readVersion() {
12298
- if (!existsSync22(VERSION_FILE)) return "unknown";
12344
+ if (!existsSync21(VERSION_FILE)) return "unknown";
12299
12345
  return readFileSync16(VERSION_FILE, "utf-8").trim() || "unknown";
12300
12346
  }
12301
12347
  async function probeConversationDb() {
@@ -12377,7 +12423,7 @@ app36.route("/health-brand", health_default2);
12377
12423
  var admin_default = app36;
12378
12424
 
12379
12425
  // server/routes/sites.ts
12380
- import { existsSync as existsSync23, readFileSync as readFileSync17, realpathSync as realpathSync4, statSync as statSync7 } from "fs";
12426
+ import { existsSync as existsSync22, readFileSync as readFileSync17, realpathSync as realpathSync4, statSync as statSync7 } from "fs";
12381
12427
  import { resolve as resolve20 } from "path";
12382
12428
  var SAFE_SEG_RE = /^[a-z0-9_][a-z0-9_.-]{0,99}$/i;
12383
12429
  var MIME = {
@@ -12443,7 +12489,7 @@ app37.get("/:rel{.*}", (c) => {
12443
12489
  }
12444
12490
  let stat6;
12445
12491
  try {
12446
- stat6 = existsSync23(filePath) ? statSync7(filePath) : null;
12492
+ stat6 = existsSync22(filePath) ? statSync7(filePath) : null;
12447
12493
  } catch {
12448
12494
  stat6 = null;
12449
12495
  }
@@ -12462,7 +12508,7 @@ app37.get("/:rel{.*}", (c) => {
12462
12508
  console.error(`[sites] path-traversal-rejected path=${reqPath} reason=escape status=403`);
12463
12509
  return c.text("Forbidden", 403);
12464
12510
  }
12465
- if (!existsSync23(filePath)) {
12511
+ if (!existsSync22(filePath)) {
12466
12512
  console.error(`[sites] not-found path=${reqPath} status=404`);
12467
12513
  return c.text("Not found", 404);
12468
12514
  }
@@ -12613,12 +12659,12 @@ function clientFrom(c) {
12613
12659
  );
12614
12660
  }
12615
12661
  var PLATFORM_ROOT7 = process.env.MAXY_PLATFORM_ROOT || "";
12616
- var BRAND_JSON_PATH = PLATFORM_ROOT7 ? join12(PLATFORM_ROOT7, "config", "brand.json") : "";
12662
+ var BRAND_JSON_PATH = PLATFORM_ROOT7 ? join11(PLATFORM_ROOT7, "config", "brand.json") : "";
12617
12663
  var BRAND = { productName: "Maxy", hostname: "maxy", configDir: ".maxy", domain: "getmaxy.com" };
12618
- if (BRAND_JSON_PATH && !existsSync24(BRAND_JSON_PATH)) {
12664
+ if (BRAND_JSON_PATH && !existsSync23(BRAND_JSON_PATH)) {
12619
12665
  console.error(`[brand] WARNING: brand.json not found at ${BRAND_JSON_PATH} \u2014 using Maxy defaults`);
12620
12666
  }
12621
- if (BRAND_JSON_PATH && existsSync24(BRAND_JSON_PATH)) {
12667
+ if (BRAND_JSON_PATH && existsSync23(BRAND_JSON_PATH)) {
12622
12668
  try {
12623
12669
  const parsed = JSON.parse(readFileSync18(BRAND_JSON_PATH, "utf-8"));
12624
12670
  BRAND = { ...BRAND, ...parsed };
@@ -12639,10 +12685,10 @@ var brandLoginOpts = {
12639
12685
  bodyFont: BRAND.defaultFonts?.body,
12640
12686
  logoContainsName: !!BRAND.logoContainsName
12641
12687
  };
12642
- var ALIAS_DOMAINS_PATH2 = join12(homedir3(), BRAND.configDir, "alias-domains.json");
12688
+ var ALIAS_DOMAINS_PATH2 = join11(homedir3(), BRAND.configDir, "alias-domains.json");
12643
12689
  function loadAliasDomains() {
12644
12690
  try {
12645
- if (!existsSync24(ALIAS_DOMAINS_PATH2)) return null;
12691
+ if (!existsSync23(ALIAS_DOMAINS_PATH2)) return null;
12646
12692
  const parsed = JSON.parse(readFileSync18(ALIAS_DOMAINS_PATH2, "utf-8"));
12647
12693
  if (!Array.isArray(parsed)) {
12648
12694
  console.error("[alias-domains] malformed alias-domains.json \u2014 expected array");
@@ -13015,7 +13061,7 @@ app38.get("/agent-assets/:slug/:filename", (c) => {
13015
13061
  console.error(`[agent-assets] path-traversal-rejected slug=${slug} file=${filename}`);
13016
13062
  return c.text("Forbidden", 403);
13017
13063
  }
13018
- if (!existsSync24(filePath)) {
13064
+ if (!existsSync23(filePath)) {
13019
13065
  console.error(`[agent-assets] serve slug=${slug} file=${filename} status=404`);
13020
13066
  return c.text("Not found", 404);
13021
13067
  }
@@ -13045,7 +13091,7 @@ app38.get("/generated/:filename", (c) => {
13045
13091
  console.error(`[generated] serve file=${filename} status=403`);
13046
13092
  return c.text("Forbidden", 403);
13047
13093
  }
13048
- if (!existsSync24(filePath)) {
13094
+ if (!existsSync23(filePath)) {
13049
13095
  console.error(`[generated] serve file=${filename} status=404`);
13050
13096
  return c.text("Not found", 404);
13051
13097
  }
@@ -13062,7 +13108,7 @@ app38.route("/sites", sites_default);
13062
13108
  var htmlCache = /* @__PURE__ */ new Map();
13063
13109
  var brandLogoPath = "/brand/maxy-monochrome.png";
13064
13110
  var brandIconPath = "/brand/maxy-monochrome.png";
13065
- if (BRAND_JSON_PATH && existsSync24(BRAND_JSON_PATH)) {
13111
+ if (BRAND_JSON_PATH && existsSync23(BRAND_JSON_PATH)) {
13066
13112
  try {
13067
13113
  const fullBrand = JSON.parse(readFileSync18(BRAND_JSON_PATH, "utf-8"));
13068
13114
  if (fullBrand.assets?.logo) brandLogoPath = `/brand/${fullBrand.assets.logo}`;
@@ -13081,8 +13127,8 @@ var brandScript = `<script>window.__BRAND__=${JSON.stringify({
13081
13127
  function readInstalledVersion() {
13082
13128
  try {
13083
13129
  if (!PLATFORM_ROOT7) return "unknown";
13084
- const versionFile = join12(PLATFORM_ROOT7, "config", `.${BRAND.hostname}-version`);
13085
- if (!existsSync24(versionFile)) return "unknown";
13130
+ const versionFile = join11(PLATFORM_ROOT7, "config", `.${BRAND.hostname}-version`);
13131
+ if (!existsSync23(versionFile)) return "unknown";
13086
13132
  const content = readFileSync18(versionFile, "utf-8").trim();
13087
13133
  return content || "unknown";
13088
13134
  } catch {
@@ -13140,15 +13186,15 @@ ${clientErrorReporterScript}
13140
13186
  }
13141
13187
  var brandedHtmlCache = /* @__PURE__ */ new Map();
13142
13188
  function loadBrandingCache(agentSlug) {
13143
- const configDir2 = join12(homedir3(), BRAND.configDir);
13189
+ const configDir2 = join11(homedir3(), BRAND.configDir);
13144
13190
  try {
13145
- const accountJsonPath = join12(configDir2, "account.json");
13146
- if (!existsSync24(accountJsonPath)) return null;
13191
+ const accountJsonPath = join11(configDir2, "account.json");
13192
+ if (!existsSync23(accountJsonPath)) return null;
13147
13193
  const account = JSON.parse(readFileSync18(accountJsonPath, "utf-8"));
13148
13194
  const accountId = account.accountId;
13149
13195
  if (!accountId) return null;
13150
- const cachePath = join12(configDir2, "branding-cache", accountId, `${agentSlug}.json`);
13151
- if (!existsSync24(cachePath)) return null;
13196
+ const cachePath = join11(configDir2, "branding-cache", accountId, `${agentSlug}.json`);
13197
+ if (!existsSync23(cachePath)) return null;
13152
13198
  return JSON.parse(readFileSync18(cachePath, "utf-8"));
13153
13199
  } catch {
13154
13200
  return null;
@@ -13156,9 +13202,9 @@ function loadBrandingCache(agentSlug) {
13156
13202
  }
13157
13203
  function resolveDefaultSlug() {
13158
13204
  try {
13159
- const configDir2 = join12(homedir3(), BRAND.configDir);
13160
- const accountJsonPath = join12(configDir2, "account.json");
13161
- if (!existsSync24(accountJsonPath)) return null;
13205
+ const configDir2 = join11(homedir3(), BRAND.configDir);
13206
+ const accountJsonPath = join11(configDir2, "account.json");
13207
+ if (!existsSync23(accountJsonPath)) return null;
13162
13208
  const account = JSON.parse(readFileSync18(accountJsonPath, "utf-8"));
13163
13209
  return account.defaultAgent || null;
13164
13210
  } catch {
@@ -13338,7 +13384,7 @@ try {
13338
13384
  (async () => {
13339
13385
  try {
13340
13386
  let userId = "";
13341
- if (existsSync24(USERS_FILE)) {
13387
+ if (existsSync23(USERS_FILE)) {
13342
13388
  const users = JSON.parse(readFileSync18(USERS_FILE, "utf-8").trim() || "[]");
13343
13389
  userId = users[0]?.userId ?? "";
13344
13390
  }
@@ -13349,7 +13395,7 @@ try {
13349
13395
  })();
13350
13396
  (async () => {
13351
13397
  try {
13352
- if (!existsSync24(USERS_FILE)) return;
13398
+ if (!existsSync23(USERS_FILE)) return;
13353
13399
  const usersRaw = readFileSync18(USERS_FILE, "utf-8").trim();
13354
13400
  if (!usersRaw) return;
13355
13401
  const users = JSON.parse(usersRaw);
@@ -13401,7 +13447,7 @@ autoDeliverPremiumPlugins(bootEntitlement?.purchasedPlugins ?? void 0);
13401
13447
  (async () => {
13402
13448
  if (!bootAccount) return;
13403
13449
  try {
13404
- const { recoverRunningCloudflareTasks } = await import("./cloudflare-task-tracker-OOQCL5ZB.js");
13450
+ const { recoverRunningCloudflareTasks } = await import("./cloudflare-task-tracker-OCFIVXEJ.js");
13405
13451
  const result = await recoverRunningCloudflareTasks(
13406
13452
  bootAccount.accountId,
13407
13453
  configDirForWhatsApp,
@@ -13451,7 +13497,7 @@ if (bootAccountConfig?.whatsapp) {
13451
13497
  }
13452
13498
  init({
13453
13499
  configDir: configDirForWhatsApp,
13454
- platformRoot: resolve21(process.env.MAXY_PLATFORM_ROOT ?? join12(__dirname, "..")),
13500
+ platformRoot: resolve21(process.env.MAXY_PLATFORM_ROOT ?? join11(__dirname, "..")),
13455
13501
  accountConfig: bootAccountConfig,
13456
13502
  onMessage: async (msg) => {
13457
13503
  try {