@rubytech/create-maxy-code 0.1.100 → 0.1.101

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.
@@ -598,9 +598,9 @@ var serveStatic = (options = { root: "" }) => {
598
598
  };
599
599
 
600
600
  // server/index.ts
601
- import { readFileSync as readFileSync20, existsSync as existsSync22, watchFile } from "fs";
602
- import { resolve as resolve23, join as join13, basename as basename5 } from "path";
603
- import { homedir as homedir4 } from "os";
601
+ import { readFileSync as readFileSync21, existsSync as existsSync23, watchFile } from "fs";
602
+ import { resolve as resolve23, join as join14, basename as basename5 } from "path";
603
+ import { homedir as homedir5 } from "os";
604
604
  import { monitorEventLoopDelay } from "perf_hooks";
605
605
 
606
606
  // app/lib/agent-slug-pattern.ts
@@ -7056,12 +7056,53 @@ app10.get("/", (c) => {
7056
7056
  });
7057
7057
  var claude_info_default = app10;
7058
7058
 
7059
+ // server/routes/admin/claude-capabilities.ts
7060
+ import { existsSync as existsSync11, readFileSync as readFileSync12 } from "fs";
7061
+ import { dirname as dirname2, join as join10 } from "path";
7062
+ import { homedir as homedir2 } from "os";
7063
+ var app11 = new Hono();
7064
+ function resolveClaudeJsonPath() {
7065
+ const configDir2 = process.env.CLAUDE_CONFIG_DIR ?? join10(homedir2(), ".claude");
7066
+ return join10(dirname2(configDir2), ".claude.json");
7067
+ }
7068
+ function readSeatTier(path2) {
7069
+ if (!existsSync11(path2)) return null;
7070
+ let raw;
7071
+ try {
7072
+ raw = readFileSync12(path2, "utf8");
7073
+ } catch {
7074
+ return null;
7075
+ }
7076
+ let parsed;
7077
+ try {
7078
+ parsed = JSON.parse(raw);
7079
+ } catch {
7080
+ return null;
7081
+ }
7082
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
7083
+ const oauth = parsed.oauthAccount;
7084
+ if (!oauth || typeof oauth !== "object" || Array.isArray(oauth)) return null;
7085
+ const seatTier = oauth.seatTier;
7086
+ if (typeof seatTier !== "string") return null;
7087
+ return seatTier;
7088
+ }
7089
+ app11.get("/", (c) => {
7090
+ const path2 = resolveClaudeJsonPath();
7091
+ const seatTier = readSeatTier(path2);
7092
+ const body = {
7093
+ seatTier,
7094
+ autoModeAvailable: typeof seatTier === "string" && seatTier.length > 0
7095
+ };
7096
+ return c.json(body);
7097
+ });
7098
+ var claude_capabilities_default = app11;
7099
+
7059
7100
  // server/routes/admin/attachment.ts
7060
7101
  import { readFile as readFile3, readdir } from "fs/promises";
7061
- import { existsSync as existsSync11 } from "fs";
7102
+ import { existsSync as existsSync12 } from "fs";
7062
7103
  import { resolve as resolve9 } from "path";
7063
- var app11 = new Hono();
7064
- app11.get("/:attachmentId", requireAdminSession, async (c) => {
7104
+ var app12 = new Hono();
7105
+ app12.get("/:attachmentId", requireAdminSession, async (c) => {
7065
7106
  const attachmentId = c.req.param("attachmentId");
7066
7107
  const cacheKey = c.var.cacheKey;
7067
7108
  const accountId = getAccountIdForSession(cacheKey);
@@ -7072,11 +7113,11 @@ app11.get("/:attachmentId", requireAdminSession, async (c) => {
7072
7113
  return new Response("Not found", { status: 404 });
7073
7114
  }
7074
7115
  const dir = resolve9(ATTACHMENTS_ROOT, accountId, attachmentId);
7075
- if (!existsSync11(dir)) {
7116
+ if (!existsSync12(dir)) {
7076
7117
  return new Response("Not found", { status: 404 });
7077
7118
  }
7078
7119
  const metaPath = resolve9(dir, `${attachmentId}.meta.json`);
7079
- if (!existsSync11(metaPath)) {
7120
+ if (!existsSync12(metaPath)) {
7080
7121
  return new Response("Not found", { status: 404 });
7081
7122
  }
7082
7123
  let meta;
@@ -7100,17 +7141,17 @@ app11.get("/:attachmentId", requireAdminSession, async (c) => {
7100
7141
  }
7101
7142
  });
7102
7143
  });
7103
- var attachment_default = app11;
7144
+ var attachment_default = app12;
7104
7145
 
7105
7146
  // server/routes/admin/agents.ts
7106
7147
  import { resolve as resolve10 } from "path";
7107
- import { readdirSync as readdirSync6, readFileSync as readFileSync12, existsSync as existsSync12, rmSync } from "fs";
7108
- var app12 = new Hono();
7109
- app12.get("/", (c) => {
7148
+ import { readdirSync as readdirSync6, readFileSync as readFileSync13, existsSync as existsSync13, rmSync } from "fs";
7149
+ var app13 = new Hono();
7150
+ app13.get("/", (c) => {
7110
7151
  const account = resolveAccount();
7111
7152
  if (!account) return c.json({ agents: [] });
7112
7153
  const agentsDir = resolve10(account.accountDir, "agents");
7113
- if (!existsSync12(agentsDir)) return c.json({ agents: [] });
7154
+ if (!existsSync13(agentsDir)) return c.json({ agents: [] });
7114
7155
  const agents = [];
7115
7156
  try {
7116
7157
  const entries = readdirSync6(agentsDir, { withFileTypes: true });
@@ -7118,9 +7159,9 @@ app12.get("/", (c) => {
7118
7159
  if (!entry.isDirectory()) continue;
7119
7160
  if (entry.name === "admin") continue;
7120
7161
  const configPath2 = resolve10(agentsDir, entry.name, "config.json");
7121
- if (!existsSync12(configPath2)) continue;
7162
+ if (!existsSync13(configPath2)) continue;
7122
7163
  try {
7123
- const config = JSON.parse(readFileSync12(configPath2, "utf-8"));
7164
+ const config = JSON.parse(readFileSync13(configPath2, "utf-8"));
7124
7165
  agents.push({
7125
7166
  slug: entry.name,
7126
7167
  displayName: config.displayName ?? entry.name,
@@ -7136,7 +7177,7 @@ app12.get("/", (c) => {
7136
7177
  }
7137
7178
  return c.json({ agents });
7138
7179
  });
7139
- app12.delete("/:slug", async (c) => {
7180
+ app13.delete("/:slug", async (c) => {
7140
7181
  const slug = c.req.param("slug");
7141
7182
  const account = resolveAccount();
7142
7183
  if (!account) return c.json({ error: "No account resolved" }, 400);
@@ -7147,7 +7188,7 @@ app12.delete("/:slug", async (c) => {
7147
7188
  return c.json({ error: "Invalid agent slug" }, 400);
7148
7189
  }
7149
7190
  const agentDir = resolve10(account.accountDir, "agents", slug);
7150
- if (!existsSync12(agentDir)) {
7191
+ if (!existsSync13(agentDir)) {
7151
7192
  return c.json({ error: "Agent not found" }, 404);
7152
7193
  }
7153
7194
  try {
@@ -7166,7 +7207,7 @@ app12.delete("/:slug", async (c) => {
7166
7207
  return c.json({ error: "Failed to delete agent" }, 500);
7167
7208
  }
7168
7209
  });
7169
- app12.post("/:slug/project", async (c) => {
7210
+ app13.post("/:slug/project", async (c) => {
7170
7211
  const slug = c.req.param("slug");
7171
7212
  const account = resolveAccount();
7172
7213
  if (!account) return c.json({ error: "No account resolved" }, 400);
@@ -7177,7 +7218,7 @@ app12.post("/:slug/project", async (c) => {
7177
7218
  return c.json({ error: "Invalid agent slug" }, 400);
7178
7219
  }
7179
7220
  const agentDir = resolve10(account.accountDir, "agents", slug);
7180
- if (!existsSync12(agentDir)) {
7221
+ if (!existsSync13(agentDir)) {
7181
7222
  return c.json({ error: "Agent not found on disk" }, 404);
7182
7223
  }
7183
7224
  try {
@@ -7188,12 +7229,12 @@ app12.post("/:slug/project", async (c) => {
7188
7229
  return c.json({ error: `Projection failed: ${msg}` }, 500);
7189
7230
  }
7190
7231
  });
7191
- var agents_default = app12;
7232
+ var agents_default = app13;
7192
7233
 
7193
7234
  // server/routes/admin/sessions.ts
7194
7235
  import crypto from "crypto";
7195
7236
  import { resolve as resolvePath } from "path";
7196
- import { existsSync as existsSync13, mkdirSync as mkdirSync3, createWriteStream } from "fs";
7237
+ import { existsSync as existsSync14, mkdirSync as mkdirSync3, createWriteStream } from "fs";
7197
7238
 
7198
7239
  // ../lib/admin-conversation-purge/src/index.ts
7199
7240
  async function purgeAdminConversationJsonls(args) {
@@ -7331,7 +7372,7 @@ var replayJsonl = (..._args) => null;
7331
7372
  var resolveJsonlPath = (..._args) => null;
7332
7373
 
7333
7374
  // server/routes/admin/sessions.ts
7334
- import { homedir as homedir2 } from "os";
7375
+ import { homedir as homedir3 } from "os";
7335
7376
 
7336
7377
  // app/lib/claude-agent/component-attachment.ts
7337
7378
  var pickComponentBytes = (..._args) => null;
@@ -7371,7 +7412,7 @@ function validateAndShapeAttachments(raws, conversationAccountId, conversationId
7371
7412
  let reason = null;
7372
7413
  if (!a.attachmentId || !a.filename || !a.mimeType || !a.storagePath) reason = "schema-fail";
7373
7414
  else if (a.accountId !== conversationAccountId) reason = "account-mismatch";
7374
- else if (!existsSync13(a.storagePath)) reason = "missing-file";
7415
+ else if (!existsSync14(a.storagePath)) reason = "missing-file";
7375
7416
  if (reason) {
7376
7417
  invalid++;
7377
7418
  try {
@@ -7478,8 +7519,8 @@ function formatAge(updatedAtStr) {
7478
7519
  return "unknown";
7479
7520
  }
7480
7521
  }
7481
- var app13 = new Hono();
7482
- app13.get("/", requireAdminSession, async (c) => {
7522
+ var app14 = new Hono();
7523
+ app14.get("/", requireAdminSession, async (c) => {
7483
7524
  const cacheKey = c.var.cacheKey;
7484
7525
  const accountId = getAccountIdForSession(cacheKey);
7485
7526
  if (!accountId) return c.json({ error: "Account not found for session" }, 401);
@@ -7509,7 +7550,7 @@ app13.get("/", requireAdminSession, async (c) => {
7509
7550
  return c.json({ error: "Failed to fetch sessions" }, 500);
7510
7551
  }
7511
7552
  });
7512
- app13.post("/new", requireAdminSession, async (c) => {
7553
+ app14.post("/new", requireAdminSession, async (c) => {
7513
7554
  const oldCacheKey = c.var.cacheKey;
7514
7555
  console.log(`[admin-chat] new-conversation outcome=ingress cacheKey=${oldCacheKey.slice(0, 8)}`);
7515
7556
  const accountId = getAccountIdForSession(oldCacheKey);
@@ -7526,7 +7567,7 @@ app13.post("/new", requireAdminSession, async (c) => {
7526
7567
  console.log(`[admin-chat] new-conversation outcome=ok oldKey=${oldCacheKey.slice(0, 8)} newKey=${newCacheKey.slice(0, 8)}`);
7527
7568
  return c.json({ session_key: newSignedSessionToken, conversationId: null });
7528
7569
  });
7529
- app13.post("/switch", requireAdminSession, async (c) => {
7570
+ app14.post("/switch", requireAdminSession, async (c) => {
7530
7571
  const cacheKey = c.var.cacheKey;
7531
7572
  const accountId = getAccountIdForSession(cacheKey);
7532
7573
  const userId = getUserIdForSession(cacheKey);
@@ -7554,7 +7595,7 @@ app13.post("/switch", requireAdminSession, async (c) => {
7554
7595
  console.log(`[session-switch] from=${cacheKey.slice(0, 8)} to=${targetCacheKey.slice(0, 8)} targetConvId=${targetConversationId?.slice(0, 8) ?? "none"} accountId=${accountId.slice(0, 8)}`);
7555
7596
  return c.json({ session_key: targetSignedSessionToken, conversationId: targetConversationId });
7556
7597
  });
7557
- app13.delete("/:id", requireAdminSession, async (c) => {
7598
+ app14.delete("/:id", requireAdminSession, async (c) => {
7558
7599
  const conversationId = c.req.param("id");
7559
7600
  const cacheKey = c.var.cacheKey;
7560
7601
  const accountId = getAccountIdForSession(cacheKey);
@@ -7600,7 +7641,7 @@ app13.delete("/:id", requireAdminSession, async (c) => {
7600
7641
  500
7601
7642
  );
7602
7643
  });
7603
- app13.post("/:id/resume", async (c) => {
7644
+ app14.post("/:id/resume", async (c) => {
7604
7645
  const conversationId = c.req.param("id");
7605
7646
  const t0 = Date.now();
7606
7647
  const signedSessionToken = c.req.query("session_key") ?? "";
@@ -7665,7 +7706,7 @@ app13.post("/:id/resume", async (c) => {
7665
7706
  return c.json({ error: "Failed to load conversation messages" }, 500);
7666
7707
  }
7667
7708
  if (persistedAgentSessionId) {
7668
- const jsonlPath = resolveJsonlPath(homedir2(), resolvePath(ACCOUNTS_DIR, accountId), persistedAgentSessionId);
7709
+ const jsonlPath = resolveJsonlPath(homedir3(), resolvePath(ACCOUNTS_DIR, accountId), persistedAgentSessionId);
7669
7710
  const replay = replayJsonl(jsonlPath);
7670
7711
  jsonlMissing = replay.jsonlMissing;
7671
7712
  jsonlMalformedLines = replay.malformedLines;
@@ -7873,7 +7914,7 @@ app13.post("/:id/resume", async (c) => {
7873
7914
  }
7874
7915
  });
7875
7916
  });
7876
- app13.put("/:id/label", requireAdminSession, async (c) => {
7917
+ app14.put("/:id/label", requireAdminSession, async (c) => {
7877
7918
  const conversationId = c.req.param("id");
7878
7919
  const cacheKey = c.var.cacheKey;
7879
7920
  let body;
@@ -7899,11 +7940,11 @@ app13.put("/:id/label", requireAdminSession, async (c) => {
7899
7940
  return c.json({ error: "Failed to rename session" }, 500);
7900
7941
  }
7901
7942
  });
7902
- var sessions_default = app13;
7943
+ var sessions_default = app14;
7903
7944
 
7904
7945
  // app/lib/claude-agent/spawn-context.ts
7905
- import { existsSync as existsSync14, readFileSync as readFileSync13, readdirSync as readdirSync7, statSync as statSync6 } from "fs";
7906
- import { dirname as dirname2, resolve as resolve11, join as join10 } from "path";
7946
+ import { existsSync as existsSync15, readFileSync as readFileSync14, readdirSync as readdirSync7, statSync as statSync6 } from "fs";
7947
+ import { dirname as dirname3, resolve as resolve11, join as join11 } from "path";
7907
7948
  async function resolveOwnerProfileBlock(accountId, userId) {
7908
7949
  if (!userId) return { ok: false, reason: "missing-user-id" };
7909
7950
  try {
@@ -7932,14 +7973,14 @@ function frontmatterField(manifest, field) {
7932
7973
  function extractPluginToolDescriptions(pluginDir) {
7933
7974
  const out = /* @__PURE__ */ new Map();
7934
7975
  const candidates = [
7935
- join10(pluginDir, "mcp/dist/index.js"),
7936
- join10(pluginDir, "mcp/src/index.ts")
7976
+ join11(pluginDir, "mcp/dist/index.js"),
7977
+ join11(pluginDir, "mcp/src/index.ts")
7937
7978
  ];
7938
7979
  let raw = null;
7939
7980
  for (const path2 of candidates) {
7940
- if (!existsSync14(path2)) continue;
7981
+ if (!existsSync15(path2)) continue;
7941
7982
  try {
7942
- raw = readFileSync13(path2, "utf-8");
7983
+ raw = readFileSync14(path2, "utf-8");
7943
7984
  break;
7944
7985
  } catch {
7945
7986
  }
@@ -7989,23 +8030,23 @@ function parseSkillPathsFromFrontmatter(fm) {
7989
8030
  function listPluginDirs() {
7990
8031
  const out = /* @__PURE__ */ new Map();
7991
8032
  const platformPlugins = resolve11(PLATFORM_ROOT, "plugins");
7992
- if (existsSync14(platformPlugins)) {
8033
+ if (existsSync15(platformPlugins)) {
7993
8034
  for (const name of readdirSync7(platformPlugins)) {
7994
- const dir = join10(platformPlugins, name);
8035
+ const dir = join11(platformPlugins, name);
7995
8036
  try {
7996
8037
  if (statSync6(dir).isDirectory()) out.set(name, dir);
7997
8038
  } catch {
7998
8039
  }
7999
8040
  }
8000
8041
  }
8001
- const premiumRoot = resolve11(dirname2(PLATFORM_ROOT), "premium-plugins");
8002
- if (existsSync14(premiumRoot)) {
8042
+ const premiumRoot = resolve11(dirname3(PLATFORM_ROOT), "premium-plugins");
8043
+ if (existsSync15(premiumRoot)) {
8003
8044
  for (const bundle of readdirSync7(premiumRoot)) {
8004
- const bundlePlugins = join10(premiumRoot, bundle, "plugins");
8005
- if (!existsSync14(bundlePlugins)) continue;
8045
+ const bundlePlugins = join11(premiumRoot, bundle, "plugins");
8046
+ if (!existsSync15(bundlePlugins)) continue;
8006
8047
  try {
8007
8048
  for (const name of readdirSync7(bundlePlugins)) {
8008
- const dir = join10(bundlePlugins, name);
8049
+ const dir = join11(bundlePlugins, name);
8009
8050
  try {
8010
8051
  if (statSync6(dir).isDirectory()) out.set(name, dir);
8011
8052
  } catch {
@@ -8019,9 +8060,9 @@ function listPluginDirs() {
8019
8060
  }
8020
8061
  function readEnabledPlugins(accountId) {
8021
8062
  const accountFile = resolve11(PLATFORM_ROOT, "..", "data/accounts", accountId, "account.json");
8022
- if (!existsSync14(accountFile)) return /* @__PURE__ */ new Set();
8063
+ if (!existsSync15(accountFile)) return /* @__PURE__ */ new Set();
8023
8064
  try {
8024
- const parsed = JSON.parse(readFileSync13(accountFile, "utf-8"));
8065
+ const parsed = JSON.parse(readFileSync14(accountFile, "utf-8"));
8025
8066
  return new Set(
8026
8067
  Array.isArray(parsed.enabledPlugins) ? parsed.enabledPlugins.filter((p) => typeof p === "string") : []
8027
8068
  );
@@ -8030,10 +8071,10 @@ function readEnabledPlugins(accountId) {
8030
8071
  }
8031
8072
  }
8032
8073
  function readFrontmatter(path2) {
8033
- if (!existsSync14(path2)) return null;
8074
+ if (!existsSync15(path2)) return null;
8034
8075
  let raw;
8035
8076
  try {
8036
- raw = readFileSync13(path2, "utf-8");
8077
+ raw = readFileSync14(path2, "utf-8");
8037
8078
  } catch {
8038
8079
  return null;
8039
8080
  }
@@ -8048,7 +8089,7 @@ function computeActivePlugins(accountId) {
8048
8089
  for (const name of Array.from(enabled).sort()) {
8049
8090
  const dir = pluginDirs.get(name);
8050
8091
  if (!dir) continue;
8051
- const fm = readFrontmatter(join10(dir, "PLUGIN.md"));
8092
+ const fm = readFrontmatter(join11(dir, "PLUGIN.md"));
8052
8093
  if (!fm) continue;
8053
8094
  const description = frontmatterField(`---
8054
8095
  ${fm}
@@ -8065,7 +8106,7 @@ ${fm}
8065
8106
  `plugin-manifest-tool-coverage plugin=${name} tools=${tools.length} with-desc=${withDesc}`
8066
8107
  );
8067
8108
  if (toolNames.length > 0 && descMap.size === 0) {
8068
- const hasSource = existsSync14(join10(dir, "mcp/dist/index.js")) || existsSync14(join10(dir, "mcp/src/index.ts"));
8109
+ const hasSource = existsSync15(join11(dir, "mcp/dist/index.js")) || existsSync15(join11(dir, "mcp/src/index.ts"));
8069
8110
  if (hasSource) {
8070
8111
  console.warn(
8071
8112
  `[spawn-context] WARN plugin=${name} mcp source present but tool-description regex matched zero entries \u2014 SDK upgrade may have changed the registration shape`
@@ -8075,7 +8116,7 @@ ${fm}
8075
8116
  const skillPaths = parseSkillPathsFromFrontmatter(fm);
8076
8117
  const skills = [];
8077
8118
  for (const relPath2 of skillPaths) {
8078
- const skillPath = join10(dir, relPath2);
8119
+ const skillPath = join11(dir, relPath2);
8079
8120
  const skillFm = readFrontmatter(skillPath);
8080
8121
  if (!skillFm) continue;
8081
8122
  const skillName = frontmatterField(`---
@@ -8092,7 +8133,7 @@ ${skillFm}
8092
8133
  }
8093
8134
  function computeSpecialistDomains(accountId) {
8094
8135
  const specialistsDir = resolve11(PLATFORM_ROOT, "..", "data/accounts", accountId, "specialists", "agents");
8095
- if (!existsSync14(specialistsDir)) return [];
8136
+ if (!existsSync15(specialistsDir)) return [];
8096
8137
  let entries;
8097
8138
  try {
8098
8139
  entries = readdirSync7(specialistsDir);
@@ -8119,7 +8160,7 @@ function computeSpecialistDomains(accountId) {
8119
8160
  const out = [];
8120
8161
  for (const file of entries.sort()) {
8121
8162
  if (!file.endsWith(".md")) continue;
8122
- const fm = readFrontmatter(join10(specialistsDir, file));
8163
+ const fm = readFrontmatter(join11(specialistsDir, file));
8123
8164
  if (!fm) continue;
8124
8165
  const wrapped = `---
8125
8166
  ${fm}
@@ -8138,10 +8179,10 @@ ${fm}
8138
8179
  }
8139
8180
  function computeDormantPlugins(accountId) {
8140
8181
  const accountFile = resolve11(PLATFORM_ROOT, "..", "data/accounts", accountId, "account.json");
8141
- if (!existsSync14(accountFile)) return [];
8182
+ if (!existsSync15(accountFile)) return [];
8142
8183
  let enabled;
8143
8184
  try {
8144
- const raw = readFileSync13(accountFile, "utf-8");
8185
+ const raw = readFileSync14(accountFile, "utf-8");
8145
8186
  const parsed = JSON.parse(raw);
8146
8187
  enabled = new Set(
8147
8188
  Array.isArray(parsed.enabledPlugins) ? parsed.enabledPlugins.filter((p) => typeof p === "string") : []
@@ -8153,7 +8194,7 @@ function computeDormantPlugins(accountId) {
8153
8194
  return [];
8154
8195
  }
8155
8196
  const pluginsDir = resolve11(PLATFORM_ROOT, "plugins");
8156
- if (!existsSync14(pluginsDir)) return [];
8197
+ if (!existsSync15(pluginsDir)) return [];
8157
8198
  let entries;
8158
8199
  try {
8159
8200
  entries = readdirSync7(pluginsDir);
@@ -8164,10 +8205,10 @@ function computeDormantPlugins(accountId) {
8164
8205
  for (const name of entries) {
8165
8206
  if (enabled.has(name)) continue;
8166
8207
  const manifestPath = resolve11(pluginsDir, name, "PLUGIN.md");
8167
- if (!existsSync14(manifestPath)) continue;
8208
+ if (!existsSync15(manifestPath)) continue;
8168
8209
  let manifest;
8169
8210
  try {
8170
- manifest = readFileSync13(manifestPath, "utf-8");
8211
+ manifest = readFileSync14(manifestPath, "utf-8");
8171
8212
  } catch {
8172
8213
  continue;
8173
8214
  }
@@ -8180,13 +8221,13 @@ function computeDormantPlugins(accountId) {
8180
8221
  }
8181
8222
 
8182
8223
  // server/routes/admin/claude-sessions.ts
8183
- import { readFileSync as readFileSync14 } from "fs";
8224
+ import { readFileSync as readFileSync15 } from "fs";
8184
8225
  import { resolve as resolve12 } from "path";
8185
8226
  function resolveTunnelUrl() {
8186
8227
  const platformRoot = process.env.MAXY_PLATFORM_ROOT ?? process.env.PLATFORM_ROOT ?? resolve12(process.cwd(), "..");
8187
8228
  let brand;
8188
8229
  try {
8189
- brand = JSON.parse(readFileSync14(resolve12(platformRoot, "config", "brand.json"), "utf-8"));
8230
+ brand = JSON.parse(readFileSync15(resolve12(platformRoot, "config", "brand.json"), "utf-8"));
8190
8231
  } catch {
8191
8232
  return null;
8192
8233
  }
@@ -8202,7 +8243,7 @@ function managerBase2() {
8202
8243
  const port2 = requirePortEnv("CLAUDE_SESSION_MANAGER_PORT", { tag: "claude-session-manager:wrapper" });
8203
8244
  return `http://127.0.0.1:${port2}`;
8204
8245
  }
8205
- var app14 = new Hono();
8246
+ var app15 = new Hono();
8206
8247
  var UUID_PATTERN = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
8207
8248
  async function performSpawnWithInitialMessage(args) {
8208
8249
  const ownerStart = Date.now();
@@ -8284,8 +8325,8 @@ var requireAdminSessionUnlessLoopbackSpawn = async (c, next) => {
8284
8325
  }
8285
8326
  return requireAdminSession(c, next);
8286
8327
  };
8287
- app14.use("*", requireAdminSessionUnlessLoopbackSpawn);
8288
- app14.post("/", async (c) => {
8328
+ app15.use("*", requireAdminSessionUnlessLoopbackSpawn);
8329
+ app15.post("/", async (c) => {
8289
8330
  const routeStart = Date.now();
8290
8331
  const cacheKey = c.get("cacheKey") ?? "";
8291
8332
  let body = {};
@@ -8348,7 +8389,7 @@ app14.post("/", async (c) => {
8348
8389
  console.log(`${TAG18} route-done surface=${authSurface} status=${response.status} route-ms=${Date.now() - routeStart}`);
8349
8390
  return response;
8350
8391
  });
8351
- app14.get("/events", async (c) => {
8392
+ app15.get("/events", async (c) => {
8352
8393
  const upstream = await fetch(`${managerBase2()}/events`, {
8353
8394
  headers: { accept: "text/event-stream" }
8354
8395
  }).catch((err) => {
@@ -8366,7 +8407,7 @@ app14.get("/events", async (c) => {
8366
8407
  }
8367
8408
  });
8368
8409
  });
8369
- app14.get("/", async (c) => {
8410
+ app15.get("/", async (c) => {
8370
8411
  const cacheKey = c.get("cacheKey") ?? "";
8371
8412
  const senderId = getAccountIdForSession(cacheKey) ?? "";
8372
8413
  if (!senderId) return c.json({ error: "admin-account-not-resolved" }, 500);
@@ -8379,7 +8420,7 @@ app14.get("/", async (c) => {
8379
8420
  if (!upstream) return c.json({ error: "manager-unreachable" }, 503);
8380
8421
  return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
8381
8422
  });
8382
- app14.post("/resume", async (c) => {
8423
+ app15.post("/resume", async (c) => {
8383
8424
  const cacheKey = c.get("cacheKey") ?? "";
8384
8425
  const senderId = getAccountIdForSession(cacheKey) ?? "";
8385
8426
  if (!senderId) return c.json({ error: "admin-account-not-resolved" }, 500);
@@ -8441,7 +8482,7 @@ app14.post("/resume", async (c) => {
8441
8482
  );
8442
8483
  return new Response(bodyText, { status: upstream.status, headers: upstream.headers });
8443
8484
  });
8444
- app14.post("/:sessionId/stop", async (c) => {
8485
+ app15.post("/:sessionId/stop", async (c) => {
8445
8486
  const sessionId = c.req.param("sessionId");
8446
8487
  const upstream = await fetch(
8447
8488
  `${managerBase2()}/${encodeURIComponent(sessionId)}/stop`,
@@ -8453,7 +8494,7 @@ app14.post("/:sessionId/stop", async (c) => {
8453
8494
  if (!upstream) return c.json({ error: "manager-unreachable" }, 503);
8454
8495
  return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
8455
8496
  });
8456
- app14.post("/:sessionId/rename", async (c) => {
8497
+ app15.post("/:sessionId/rename", async (c) => {
8457
8498
  const sessionId = c.req.param("sessionId");
8458
8499
  const body = await c.req.text();
8459
8500
  const upstream = await fetch(
@@ -8470,7 +8511,7 @@ app14.post("/:sessionId/rename", async (c) => {
8470
8511
  if (!upstream) return c.json({ error: "manager-unreachable" }, 503);
8471
8512
  return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
8472
8513
  });
8473
- app14.delete("/:sessionId", async (c) => {
8514
+ app15.delete("/:sessionId", async (c) => {
8474
8515
  const sessionId = c.req.param("sessionId");
8475
8516
  const cacheKey = c.get("cacheKey") ?? "";
8476
8517
  const accountId = getAccountIdForSession(cacheKey) ?? "";
@@ -8533,7 +8574,7 @@ app14.delete("/:sessionId", async (c) => {
8533
8574
  500
8534
8575
  );
8535
8576
  });
8536
- app14.post("/:sessionId/archive", async (c) => {
8577
+ app15.post("/:sessionId/archive", async (c) => {
8537
8578
  const sessionId = c.req.param("sessionId");
8538
8579
  const body = await c.req.text();
8539
8580
  const upstream = await fetch(
@@ -8550,19 +8591,7 @@ app14.post("/:sessionId/archive", async (c) => {
8550
8591
  if (!upstream) return c.json({ error: "manager-unreachable" }, 503);
8551
8592
  return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
8552
8593
  });
8553
- app14.post("/:sessionId/promote", async (c) => {
8554
- const sessionId = c.req.param("sessionId");
8555
- const upstream = await fetch(
8556
- `${managerBase2()}/${encodeURIComponent(sessionId)}/promote`,
8557
- { method: "POST" }
8558
- ).catch((err) => {
8559
- console.error(`${TAG18} fetch-failed op=promote message=${err instanceof Error ? err.message : String(err)}`);
8560
- return null;
8561
- });
8562
- if (!upstream) return c.json({ error: "manager-unreachable" }, 503);
8563
- return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
8564
- });
8565
- app14.get("/:sessionId/meta", async (c) => {
8594
+ app15.get("/:sessionId/meta", async (c) => {
8566
8595
  const sessionId = c.req.param("sessionId");
8567
8596
  const upstream = await fetch(
8568
8597
  `${managerBase2()}/${encodeURIComponent(sessionId)}/meta`
@@ -8573,7 +8602,7 @@ app14.get("/:sessionId/meta", async (c) => {
8573
8602
  if (!upstream) return c.json({ error: "manager-unreachable" }, 503);
8574
8603
  return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
8575
8604
  });
8576
- app14.post("/:sessionId/input", async (c) => {
8605
+ app15.post("/:sessionId/input", async (c) => {
8577
8606
  const sessionId = c.req.param("sessionId");
8578
8607
  const rawBody = await c.req.text();
8579
8608
  const upstream = await fetch(
@@ -8590,7 +8619,7 @@ app14.post("/:sessionId/input", async (c) => {
8590
8619
  if (!upstream) return c.json({ error: "manager-unreachable" }, 503);
8591
8620
  return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
8592
8621
  });
8593
- app14.get("/:sessionId/log", async (c) => {
8622
+ app15.get("/:sessionId/log", async (c) => {
8594
8623
  const sessionId = c.req.param("sessionId");
8595
8624
  const search = new URLSearchParams();
8596
8625
  if (c.req.query("follow") === "1") search.set("follow", "1");
@@ -8605,18 +8634,18 @@ app14.get("/:sessionId/log", async (c) => {
8605
8634
  if (!upstream) return c.json({ error: "manager-unreachable" }, 503);
8606
8635
  return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
8607
8636
  });
8608
- var claude_sessions_default = app14;
8637
+ var claude_sessions_default = app15;
8609
8638
 
8610
8639
  // server/routes/admin/log-ingest.ts
8611
8640
  var TAG19 = "[log-ingest]";
8612
8641
  var TAG_PATTERN = /^[A-Za-z0-9_:-]{1,32}$/;
8613
8642
  var LEVELS = /* @__PURE__ */ new Set(["debug", "info", "warn", "error"]);
8614
8643
  var MAX_LINE_BYTES = 4096;
8615
- var app15 = new Hono();
8644
+ var app16 = new Hono();
8616
8645
  function isLoopbackAddr(addr) {
8617
8646
  return addr === "127.0.0.1" || addr === "::1" || addr === "::ffff:127.0.0.1";
8618
8647
  }
8619
- app15.post("/", async (c) => {
8648
+ app16.post("/", async (c) => {
8620
8649
  const remoteAddr = c.env?.incoming?.socket?.remoteAddress ?? "";
8621
8650
  if (!isLoopbackAddr(remoteAddr)) {
8622
8651
  console.error(`${TAG19} reject reason=non-loopback remoteAddr=${remoteAddr}`);
@@ -8659,11 +8688,11 @@ app15.post("/", async (c) => {
8659
8688
  else console.log(formatted);
8660
8689
  return c.json({ ok: true }, 200);
8661
8690
  });
8662
- var log_ingest_default = app15;
8691
+ var log_ingest_default = app16;
8663
8692
 
8664
8693
  // server/routes/admin/browser.ts
8665
- var app16 = new Hono();
8666
- app16.post("/launch", async (c) => {
8694
+ var app17 = new Hono();
8695
+ app17.post("/launch", async (c) => {
8667
8696
  try {
8668
8697
  const transport = resolveBrowserTransport(c.req.raw, c.env?.incoming?.socket?.remoteAddress);
8669
8698
  if (transport === "vnc") {
@@ -8685,7 +8714,7 @@ app16.post("/launch", async (c) => {
8685
8714
  );
8686
8715
  }
8687
8716
  });
8688
- var browser_default = app16;
8717
+ var browser_default = app17;
8689
8718
 
8690
8719
  // server/routes/admin/browser-iframe.ts
8691
8720
  var ALLOWED_EVENTS = /* @__PURE__ */ new Set([
@@ -8702,8 +8731,8 @@ function asString(v, max = 500) {
8702
8731
  function asNumber(v) {
8703
8732
  return typeof v === "number" && Number.isFinite(v) ? v : void 0;
8704
8733
  }
8705
- var app17 = new Hono();
8706
- app17.post("/event", async (c) => {
8734
+ var app18 = new Hono();
8735
+ app18.post("/event", async (c) => {
8707
8736
  let body = {};
8708
8737
  try {
8709
8738
  body = await c.req.json();
@@ -8724,7 +8753,7 @@ app17.post("/event", async (c) => {
8724
8753
  });
8725
8754
  return c.body(null, 204);
8726
8755
  });
8727
- var browser_iframe_default = app17;
8756
+ var browser_iframe_default = app18;
8728
8757
 
8729
8758
  // app/lib/cdp-client.ts
8730
8759
  var CDP_HOST = "127.0.0.1";
@@ -8767,8 +8796,8 @@ async function cdpNavigateNewTab(url, opts = {}) {
8767
8796
  }
8768
8797
 
8769
8798
  // server/routes/admin/device-browser.ts
8770
- var app18 = new Hono();
8771
- app18.post("/navigate", async (c) => {
8799
+ var app19 = new Hono();
8800
+ app19.post("/navigate", async (c) => {
8772
8801
  const TAG22 = "[device-url:click]";
8773
8802
  let body;
8774
8803
  try {
@@ -8855,7 +8884,7 @@ app18.post("/navigate", async (c) => {
8855
8884
  targetId: outcome.targetId
8856
8885
  });
8857
8886
  });
8858
- var device_browser_default = app18;
8887
+ var device_browser_default = app19;
8859
8888
 
8860
8889
  // server/routes/admin/events.ts
8861
8890
  var ALLOWED_EVENTS2 = /* @__PURE__ */ new Set([
@@ -8864,8 +8893,8 @@ var ALLOWED_EVENTS2 = /* @__PURE__ */ new Set([
8864
8893
  "device-url:vnc-surface-shown",
8865
8894
  "device-url:malformed"
8866
8895
  ]);
8867
- var app19 = new Hono();
8868
- app19.post("/", async (c) => {
8896
+ var app20 = new Hono();
8897
+ app20.post("/", async (c) => {
8869
8898
  const TAG22 = "[admin:events]";
8870
8899
  let body;
8871
8900
  try {
@@ -8896,12 +8925,12 @@ app19.post("/", async (c) => {
8896
8925
  console.error(`[${event}] ${formatted}`);
8897
8926
  return c.json({ ok: true });
8898
8927
  });
8899
- var events_default = app19;
8928
+ var events_default = app20;
8900
8929
 
8901
8930
  // server/routes/admin/cloudflare.ts
8902
- import { homedir as homedir3 } from "os";
8931
+ import { homedir as homedir4 } from "os";
8903
8932
  import { resolve as resolve14 } from "path";
8904
- import { readFileSync as readFileSync16 } from "fs";
8933
+ import { readFileSync as readFileSync17 } from "fs";
8905
8934
 
8906
8935
  // app/lib/dns-label.ts
8907
8936
  var VALID_LABEL = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
@@ -8917,14 +8946,14 @@ function isValidDomain(value) {
8917
8946
  }
8918
8947
 
8919
8948
  // app/lib/alias-domains.ts
8920
- import { existsSync as existsSync15, mkdirSync as mkdirSync4, readFileSync as readFileSync15, writeFileSync as writeFileSync7 } from "fs";
8921
- import { dirname as dirname3 } from "path";
8949
+ import { existsSync as existsSync16, mkdirSync as mkdirSync4, readFileSync as readFileSync16, writeFileSync as writeFileSync7 } from "fs";
8950
+ import { dirname as dirname4 } from "path";
8922
8951
  import { resolve as resolve13 } from "path";
8923
8952
  var ALIAS_DOMAINS_PATH = resolve13(MAXY_DIR, "alias-domains.json");
8924
8953
  function readExisting() {
8925
- if (!existsSync15(ALIAS_DOMAINS_PATH)) return /* @__PURE__ */ new Set();
8954
+ if (!existsSync16(ALIAS_DOMAINS_PATH)) return /* @__PURE__ */ new Set();
8926
8955
  try {
8927
- const parsed = JSON.parse(readFileSync15(ALIAS_DOMAINS_PATH, "utf-8"));
8956
+ const parsed = JSON.parse(readFileSync16(ALIAS_DOMAINS_PATH, "utf-8"));
8928
8957
  if (!Array.isArray(parsed)) return /* @__PURE__ */ new Set();
8929
8958
  return new Set(parsed.filter((h) => typeof h === "string"));
8930
8959
  } catch {
@@ -8935,14 +8964,14 @@ function addAliasDomain(hostname2) {
8935
8964
  const existing = readExisting();
8936
8965
  if (existing.has(hostname2)) return;
8937
8966
  existing.add(hostname2);
8938
- mkdirSync4(dirname3(ALIAS_DOMAINS_PATH), { recursive: true });
8967
+ mkdirSync4(dirname4(ALIAS_DOMAINS_PATH), { recursive: true });
8939
8968
  writeFileSync7(ALIAS_DOMAINS_PATH, JSON.stringify([...existing], null, 2) + "\n", "utf-8");
8940
8969
  }
8941
8970
 
8942
8971
  // app/lib/script-stream-tailer.ts
8943
8972
  import * as childProcess from "child_process";
8944
8973
  import { appendFileSync as appendFileSync2, createReadStream as createReadStream2, mkdirSync as mkdirSync5, statSync as statSync7 } from "fs";
8945
- import { dirname as dirname4 } from "path";
8974
+ import { dirname as dirname5 } from "path";
8946
8975
  import { StringDecoder } from "string_decoder";
8947
8976
  var SCRIPT_STREAM_RE = /^\[([^\]]+)\] \[script:([a-z][a-z0-9-]*)((?::[a-z0-9:_-]+)?)\] (.*)$/;
8948
8977
  function parseLine(line) {
@@ -9051,7 +9080,7 @@ function writeRouteMilestone(streamLogPath, scope, line) {
9051
9080
  }
9052
9081
  const ts = (/* @__PURE__ */ new Date()).toISOString();
9053
9082
  try {
9054
- mkdirSync5(dirname4(streamLogPath), { recursive: true });
9083
+ mkdirSync5(dirname5(streamLogPath), { recursive: true });
9055
9084
  appendFileSync2(streamLogPath, `[${ts}] [script:${scope}] ${line}
9056
9085
  `);
9057
9086
  } catch (err) {
@@ -9252,7 +9281,7 @@ function loadBrandInfo() {
9252
9281
  const platformRoot = process.env.MAXY_PLATFORM_ROOT ?? resolve14(process.cwd(), "..");
9253
9282
  const brandPath = resolve14(platformRoot, "config", "brand.json");
9254
9283
  try {
9255
- const parsed = JSON.parse(readFileSync16(brandPath, "utf-8"));
9284
+ const parsed = JSON.parse(readFileSync17(brandPath, "utf-8"));
9256
9285
  const hostname2 = typeof parsed.hostname === "string" && parsed.hostname ? parsed.hostname : "maxy";
9257
9286
  const configDir2 = typeof parsed.configDir === "string" && parsed.configDir ? parsed.configDir : ".maxy";
9258
9287
  return { hostname: hostname2, configDir: configDir2 };
@@ -9315,7 +9344,7 @@ function validateBody(body) {
9315
9344
  }
9316
9345
  return null;
9317
9346
  }
9318
- var app20 = new Hono();
9347
+ var app21 = new Hono();
9319
9348
  function fieldFromReason(reason) {
9320
9349
  switch (reason) {
9321
9350
  case "not-signed-in":
@@ -9336,7 +9365,7 @@ function fieldFromReason(reason) {
9336
9365
  return "script";
9337
9366
  }
9338
9367
  }
9339
- app20.get("/domains", requireAdminSession, async (c) => {
9368
+ app21.get("/domains", requireAdminSession, async (c) => {
9340
9369
  const started = Date.now();
9341
9370
  const cacheKey = c.var.cacheKey;
9342
9371
  let correlationId;
@@ -9380,7 +9409,7 @@ app20.get("/domains", requireAdminSession, async (c) => {
9380
9409
  streamLogPath = cloudflareStreamLogPath(accountId, correlationId);
9381
9410
  log(`phase=stream-log-resolved path=${streamLogPath}`);
9382
9411
  const brand = loadBrandInfo();
9383
- const scriptPath = resolve14(homedir3(), "list-cf-domains.sh");
9412
+ const scriptPath = resolve14(homedir4(), "list-cf-domains.sh");
9384
9413
  const result = await runFormSpawn({
9385
9414
  scriptPath,
9386
9415
  args: [brand.hostname],
@@ -9432,7 +9461,7 @@ ${result.stderr}` : ""}`;
9432
9461
  return c.json(success, 200);
9433
9462
  });
9434
9463
  var TUNNELS_TIMEOUT_MS = 30 * 1e3;
9435
- app20.get("/tunnels", requireAdminSession, async (c) => {
9464
+ app21.get("/tunnels", requireAdminSession, async (c) => {
9436
9465
  const started = Date.now();
9437
9466
  const cacheKey = c.var.cacheKey;
9438
9467
  let correlationId;
@@ -9471,9 +9500,9 @@ app20.get("/tunnels", requireAdminSession, async (c) => {
9471
9500
  if (!accountId) return err("session", "No account bound to session \u2014 refresh chat.");
9472
9501
  if (!correlationId) return err("session", "No active conversation for session \u2014 refresh chat.");
9473
9502
  streamLogPath = cloudflareStreamLogPath(accountId, correlationId);
9474
- const certPath = resolve14(homedir3(), brand.configDir, "cloudflared", "cert.pem");
9475
- const { existsSync: existsSync23 } = await import("fs");
9476
- if (!existsSync23(certPath)) {
9503
+ const certPath = resolve14(homedir4(), brand.configDir, "cloudflared", "cert.pem");
9504
+ const { existsSync: existsSync24 } = await import("fs");
9505
+ if (!existsSync24(certPath)) {
9477
9506
  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.`);
9478
9507
  }
9479
9508
  const result = await runFormSpawn({
@@ -9529,7 +9558,7 @@ ${result.stderr}` : ""}`;
9529
9558
  const success = { ok: true, tunnels, defaultName, correlationId, streamLogPath };
9530
9559
  return c.json(success, 200);
9531
9560
  });
9532
- app20.post("/setup", requireAdminSession, async (c) => {
9561
+ app21.post("/setup", requireAdminSession, async (c) => {
9533
9562
  const started = Date.now();
9534
9563
  const cacheKey = c.var.cacheKey;
9535
9564
  let correlationId;
@@ -9787,13 +9816,13 @@ actionId: ${actionId}`,
9787
9816
  };
9788
9817
  return ok(success);
9789
9818
  });
9790
- var cloudflare_default = app20;
9819
+ var cloudflare_default = app21;
9791
9820
 
9792
9821
  // server/routes/admin/files.ts
9793
9822
  import { createReadStream as createReadStream3 } from "fs";
9794
9823
  import { readdir as readdir2, readFile as readFile4, stat as stat4, mkdir as mkdir3, writeFile as writeFile4, unlink as unlink2 } from "fs/promises";
9795
9824
  import { realpathSync as realpathSync4 } from "fs";
9796
- import { basename as basename4, dirname as dirname5, join as join11, resolve as resolve16, sep as sep3 } from "path";
9825
+ import { basename as basename4, dirname as dirname6, join as join12, resolve as resolve16, sep as sep3 } from "path";
9797
9826
  import { Readable as Readable2 } from "stream";
9798
9827
 
9799
9828
  // app/lib/data-path.ts
@@ -10150,7 +10179,7 @@ async function cascadeDeleteDocument(params) {
10150
10179
  var UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
10151
10180
  async function readMeta(absDir, baseName) {
10152
10181
  try {
10153
- const raw = await readFile4(join11(absDir, `${baseName}.meta.json`), "utf8");
10182
+ const raw = await readFile4(join12(absDir, `${baseName}.meta.json`), "utf8");
10154
10183
  const parsed = JSON.parse(raw);
10155
10184
  if (typeof parsed?.filename === "string") {
10156
10185
  return { filename: parsed.filename, mimeType: typeof parsed.mimeType === "string" ? parsed.mimeType : void 0 };
@@ -10188,7 +10217,7 @@ async function readAccountNames() {
10188
10217
  }
10189
10218
  async function enrich(absolute, entry, accountNames) {
10190
10219
  if (entry.kind === "directory" && UUID_RE3.test(entry.name)) {
10191
- const meta = await readMeta(join11(absolute, entry.name), entry.name);
10220
+ const meta = await readMeta(join12(absolute, entry.name), entry.name);
10192
10221
  if (meta?.filename) {
10193
10222
  entry.displayName = meta.filename;
10194
10223
  entry.mimeType = meta.mimeType;
@@ -10219,8 +10248,8 @@ function buildDisplayPath(relPath2, accountNames) {
10219
10248
  return dn ? { name: seg, displayName: dn } : { name: seg };
10220
10249
  });
10221
10250
  }
10222
- var app21 = new Hono();
10223
- app21.get("/", requireAdminSession, async (c) => {
10251
+ var app22 = new Hono();
10252
+ app22.get("/", requireAdminSession, async (c) => {
10224
10253
  const cacheKey = c.var.cacheKey;
10225
10254
  if (!getAccountIdForSession(cacheKey)) {
10226
10255
  console.error(`[data] auth-rejected endpoint="/api/admin/files" reason="no account for session"`);
@@ -10247,7 +10276,7 @@ app21.get("/", requireAdminSession, async (c) => {
10247
10276
  continue;
10248
10277
  }
10249
10278
  try {
10250
- const entryPath = join11(absolute, name);
10279
+ const entryPath = join12(absolute, name);
10251
10280
  const s = await stat4(entryPath);
10252
10281
  entries.push({
10253
10282
  name,
@@ -10281,7 +10310,7 @@ app21.get("/", requireAdminSession, async (c) => {
10281
10310
  return c.json({ error: message }, 500);
10282
10311
  }
10283
10312
  });
10284
- app21.get("/download", requireAdminSession, async (c) => {
10313
+ app22.get("/download", requireAdminSession, async (c) => {
10285
10314
  const cacheKey = c.var.cacheKey;
10286
10315
  if (!getAccountIdForSession(cacheKey)) {
10287
10316
  console.error(`[data] auth-rejected endpoint="/api/admin/files/download" reason="no account for session"`);
@@ -10329,7 +10358,7 @@ app21.get("/download", requireAdminSession, async (c) => {
10329
10358
  return c.json({ error: message }, 500);
10330
10359
  }
10331
10360
  });
10332
- app21.post("/upload", requireAdminSession, async (c) => {
10361
+ app22.post("/upload", requireAdminSession, async (c) => {
10333
10362
  const cacheKey = c.var.cacheKey;
10334
10363
  const accountId = getAccountIdForSession(cacheKey);
10335
10364
  if (!accountId) {
@@ -10387,7 +10416,7 @@ app21.post("/upload", requireAdminSession, async (c) => {
10387
10416
  mimeType: file.type
10388
10417
  });
10389
10418
  });
10390
- app21.delete("/", requireAdminSession, async (c) => {
10419
+ app22.delete("/", requireAdminSession, async (c) => {
10391
10420
  const cacheKey = c.var.cacheKey;
10392
10421
  const accountId = getAccountIdForSession(cacheKey);
10393
10422
  if (!accountId) {
@@ -10420,7 +10449,7 @@ app21.delete("/", requireAdminSession, async (c) => {
10420
10449
  }
10421
10450
  const dot = base.lastIndexOf(".");
10422
10451
  const stem = dot === -1 ? base : base.slice(0, dot);
10423
- const sidecarPath = UUID_RE3.test(stem) && base !== `${stem}.meta.json` ? join11(dirname5(absolute), `${stem}.meta.json`) : null;
10452
+ const sidecarPath = UUID_RE3.test(stem) && base !== `${stem}.meta.json` ? join12(dirname6(absolute), `${stem}.meta.json`) : null;
10424
10453
  await unlink2(absolute);
10425
10454
  if (sidecarPath) {
10426
10455
  try {
@@ -10454,7 +10483,7 @@ app21.delete("/", requireAdminSession, async (c) => {
10454
10483
  return c.json({ error: message }, 500);
10455
10484
  }
10456
10485
  });
10457
- var files_default = app21;
10486
+ var files_default = app22;
10458
10487
 
10459
10488
  // ../lib/graph-search/src/index.ts
10460
10489
  var import_dist = __toESM(require_dist());
@@ -10834,8 +10863,8 @@ var MAX_LIMIT = 2e3;
10834
10863
  var DEFAULT_VECTOR_THRESHOLD = 0.82;
10835
10864
  var MESSAGE_FAMILY_LABELS = ["Message", "UserMessage", "AssistantMessage", "WhatsAppMessage"];
10836
10865
  var CONVERSATION_PARENT_LABELS = /* @__PURE__ */ new Set(["AdminConversation", "PublicConversation"]);
10837
- var app22 = new Hono();
10838
- app22.get("/", requireAdminSession, async (c) => {
10866
+ var app23 = new Hono();
10867
+ app23.get("/", requireAdminSession, async (c) => {
10839
10868
  const cacheKey = c.var.cacheKey;
10840
10869
  const q = (c.req.query("q") ?? "").trim();
10841
10870
  const rawLimit = c.req.query("limit");
@@ -10966,7 +10995,7 @@ app22.get("/", requireAdminSession, async (c) => {
10966
10995
  await session.close();
10967
10996
  }
10968
10997
  });
10969
- var graph_search_default = app22;
10998
+ var graph_search_default = app23;
10970
10999
 
10971
11000
  // server/routes/admin/graph-subgraph.ts
10972
11001
  import neo4j from "neo4j-driver";
@@ -11120,8 +11149,8 @@ var STRIPPED_PROPERTIES = /* @__PURE__ */ new Set([
11120
11149
  "otpCode",
11121
11150
  "cacheKey"
11122
11151
  ]);
11123
- var app23 = new Hono();
11124
- app23.get("/", requireAdminSession, async (c) => {
11152
+ var app24 = new Hono();
11153
+ app24.get("/", requireAdminSession, async (c) => {
11125
11154
  const cacheKey = c.var.cacheKey;
11126
11155
  const accountId = getAccountIdForSession(cacheKey);
11127
11156
  if (!accountId) {
@@ -11704,12 +11733,12 @@ function pruneNode(node, warnedClasses, conversationWarnings) {
11704
11733
  }
11705
11734
  return trashed ? { id: node.id, labels, properties, trashed: true } : { id: node.id, labels, properties };
11706
11735
  }
11707
- var graph_subgraph_default = app23;
11736
+ var graph_subgraph_default = app24;
11708
11737
 
11709
11738
  // server/routes/admin/graph-delete.ts
11710
11739
  var ALLOWED_BY = ["graph-page", "graph-drag-trash", "graph-side-panel-trash"];
11711
- var app24 = new Hono();
11712
- app24.post("/", requireAdminSession, async (c) => {
11740
+ var app25 = new Hono();
11741
+ app25.post("/", requireAdminSession, async (c) => {
11713
11742
  const cacheKey = c.var.cacheKey;
11714
11743
  const accountId = getAccountIdForSession(cacheKey);
11715
11744
  if (!accountId) {
@@ -11872,11 +11901,11 @@ app24.post("/", requireAdminSession, async (c) => {
11872
11901
  }
11873
11902
  }
11874
11903
  });
11875
- var graph_delete_default = app24;
11904
+ var graph_delete_default = app25;
11876
11905
 
11877
11906
  // server/routes/admin/graph-restore.ts
11878
- var app25 = new Hono();
11879
- app25.post("/", requireAdminSession, async (c) => {
11907
+ var app26 = new Hono();
11908
+ app26.post("/", requireAdminSession, async (c) => {
11880
11909
  const cacheKey = c.var.cacheKey;
11881
11910
  const accountId = getAccountIdForSession(cacheKey);
11882
11911
  if (!accountId) {
@@ -11940,11 +11969,11 @@ app25.post("/", requireAdminSession, async (c) => {
11940
11969
  }
11941
11970
  }
11942
11971
  });
11943
- var graph_restore_default = app25;
11972
+ var graph_restore_default = app26;
11944
11973
 
11945
11974
  // server/routes/admin/graph-labels-in-graph.ts
11946
- var app26 = new Hono();
11947
- app26.get("/", requireAdminSession, async (c) => {
11975
+ var app27 = new Hono();
11976
+ app27.get("/", requireAdminSession, async (c) => {
11948
11977
  const cacheKey = c.var.cacheKey;
11949
11978
  const accountId = getAccountIdForSession(cacheKey);
11950
11979
  if (!accountId) {
@@ -12010,11 +12039,11 @@ var LABELS_IN_GRAPH_CYPHER = `
12010
12039
  sum(halfEdges) AS relDegree
12011
12040
  RETURN label, nodeCount, relDegree
12012
12041
  `;
12013
- var graph_labels_in_graph_default = app26;
12042
+ var graph_labels_in_graph_default = app27;
12014
12043
 
12015
12044
  // server/routes/admin/graph-default-view.ts
12016
- var app27 = new Hono();
12017
- app27.get("/", requireAdminSession, async (c) => {
12045
+ var app28 = new Hono();
12046
+ app28.get("/", requireAdminSession, async (c) => {
12018
12047
  const cacheKey = c.var.cacheKey;
12019
12048
  const accountId = getAccountIdForSession(cacheKey);
12020
12049
  const userId = getUserIdForSession(cacheKey);
@@ -12052,7 +12081,7 @@ app27.get("/", requireAdminSession, async (c) => {
12052
12081
  }
12053
12082
  }
12054
12083
  });
12055
- app27.put("/", requireAdminSession, async (c) => {
12084
+ app28.put("/", requireAdminSession, async (c) => {
12056
12085
  const cacheKey = c.var.cacheKey;
12057
12086
  const accountId = getAccountIdForSession(cacheKey);
12058
12087
  const userId = getUserIdForSession(cacheKey);
@@ -12141,13 +12170,13 @@ var WRITE_CYPHER = `
12141
12170
  p.updatedAt = $updatedAt
12142
12171
  RETURN p.labels AS labels
12143
12172
  `;
12144
- var graph_default_view_default = app27;
12173
+ var graph_default_view_default = app28;
12145
12174
 
12146
12175
  // server/routes/admin/session-defaults.ts
12147
- var app28 = new Hono();
12176
+ var app29 = new Hono();
12148
12177
  var MODE_OPTIONS = ["default", "acceptEdits", "plan", "auto", "bypassPermissions"];
12149
12178
  var MODEL_OPTIONS = ["claude-opus-4-7", "claude-sonnet-4-6", "claude-haiku-4-5"];
12150
- app28.get("/", requireAdminSession, async (c) => {
12179
+ app29.get("/", requireAdminSession, async (c) => {
12151
12180
  const cacheKey = c.var.cacheKey;
12152
12181
  const accountId = getAccountIdForSession(cacheKey);
12153
12182
  const userId = getUserIdForSession(cacheKey);
@@ -12185,7 +12214,7 @@ app28.get("/", requireAdminSession, async (c) => {
12185
12214
  }
12186
12215
  }
12187
12216
  });
12188
- app28.put("/", requireAdminSession, async (c) => {
12217
+ app29.put("/", requireAdminSession, async (c) => {
12189
12218
  const cacheKey = c.var.cacheKey;
12190
12219
  const accountId = getAccountIdForSession(cacheKey);
12191
12220
  const userId = getUserIdForSession(cacheKey);
@@ -12269,11 +12298,11 @@ var WRITE_CYPHER2 = `
12269
12298
  p.updatedAt = $updatedAt
12270
12299
  RETURN p.permissionMode AS permissionMode
12271
12300
  `;
12272
- var session_defaults_default = app28;
12301
+ var session_defaults_default = app29;
12273
12302
 
12274
12303
  // server/routes/admin/file-attach.ts
12275
- var app29 = new Hono();
12276
- app29.post("/", async (c) => {
12304
+ var app30 = new Hono();
12305
+ app30.post("/", async (c) => {
12277
12306
  try {
12278
12307
  const body = await c.req.json();
12279
12308
  const { filePath, accountId } = body;
@@ -12296,18 +12325,18 @@ app29.post("/", async (c) => {
12296
12325
  return c.json({ error: message }, 500);
12297
12326
  }
12298
12327
  });
12299
- var file_attach_default = app29;
12328
+ var file_attach_default = app30;
12300
12329
 
12301
12330
  // server/routes/admin/sidebar-artefacts.ts
12302
12331
  import neo4j2 from "neo4j-driver";
12303
12332
  import { readFile as readFile5, readdir as readdir3, stat as stat5 } from "fs/promises";
12304
12333
  import { resolve as resolve17, relative as relative2, isAbsolute } from "path";
12305
- import { existsSync as existsSync16 } from "fs";
12334
+ import { existsSync as existsSync17 } from "fs";
12306
12335
  var LIMIT = 50;
12307
12336
  var TEXT_MIME_PREFIXES = ["text/", "application/json", "application/markdown"];
12308
12337
  var ADMIN_AGENT_FILES = ["IDENTITY.md", "SOUL.md", "KNOWLEDGE.md"];
12309
- var app30 = new Hono();
12310
- app30.get("/", requireAdminSession, async (c) => {
12338
+ var app31 = new Hono();
12339
+ app31.get("/", requireAdminSession, async (c) => {
12311
12340
  const cacheKey = c.var.cacheKey;
12312
12341
  const accountId = getAccountIdForSession(cacheKey);
12313
12342
  if (!accountId) {
@@ -12450,7 +12479,7 @@ async function fetchAgentTemplateRows(accountDir) {
12450
12479
  async function unionSpecialistFilenames(overrideDir, bundledDir) {
12451
12480
  const names = /* @__PURE__ */ new Set();
12452
12481
  for (const dir of [overrideDir, bundledDir]) {
12453
- if (!existsSync16(dir)) continue;
12482
+ if (!existsSync17(dir)) continue;
12454
12483
  try {
12455
12484
  const entries = await readdir3(dir);
12456
12485
  for (const entry of entries) {
@@ -12465,7 +12494,7 @@ async function unionSpecialistFilenames(overrideDir, bundledDir) {
12465
12494
  }
12466
12495
  async function readAgentTemplateRow(inp) {
12467
12496
  let chosenPath = null;
12468
- if (existsSync16(inp.overridePath)) {
12497
+ if (existsSync17(inp.overridePath)) {
12469
12498
  try {
12470
12499
  validateFilePathInAccount(inp.overridePath, inp.overrideRoot);
12471
12500
  chosenPath = inp.overridePath;
@@ -12476,7 +12505,7 @@ async function readAgentTemplateRow(inp) {
12476
12505
  );
12477
12506
  return null;
12478
12507
  }
12479
- } else if (existsSync16(inp.bundledPath)) {
12508
+ } else if (existsSync17(inp.bundledPath)) {
12480
12509
  if (!isWithin(inp.bundledPath, inp.bundledRoot)) {
12481
12510
  console.error(
12482
12511
  `[admin/sidebar-artefacts] agent-template-read-failed agent=${inp.displayName} kind=${inp.logName} error="bundled path outside PLATFORM_ROOT"`
@@ -12513,16 +12542,16 @@ function isWithin(target, root) {
12513
12542
  const rel = relative2(root, target);
12514
12543
  return !rel.startsWith("..") && !isAbsolute(rel);
12515
12544
  }
12516
- var sidebar_artefacts_default = app30;
12545
+ var sidebar_artefacts_default = app31;
12517
12546
 
12518
12547
  // server/routes/admin/sidebar-artefact-save.ts
12519
12548
  import { mkdir as mkdir4, readdir as readdir4, stat as stat6, writeFile as writeFile5 } from "fs/promises";
12520
12549
  import { resolve as resolve18 } from "path";
12521
- import { existsSync as existsSync17 } from "fs";
12550
+ import { existsSync as existsSync18 } from "fs";
12522
12551
  var ADMIN_AGENT_FILES2 = /* @__PURE__ */ new Set(["IDENTITY.md", "SOUL.md", "KNOWLEDGE.md"]);
12523
12552
  var UUID_RE4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
12524
- var app31 = new Hono();
12525
- app31.post("/", requireAdminSession, async (c) => {
12553
+ var app32 = new Hono();
12554
+ app32.post("/", requireAdminSession, async (c) => {
12526
12555
  const cacheKey = c.var.cacheKey;
12527
12556
  const accountId = getAccountIdForSession(cacheKey);
12528
12557
  if (!accountId) return c.json({ error: "Account not found for session" }, 401);
@@ -12586,7 +12615,7 @@ async function resolveSavePath(id, accountId, accountDir) {
12586
12615
  }
12587
12616
  if (UUID_RE4.test(id)) {
12588
12617
  const dir = resolve18(ATTACHMENTS_ROOT, accountId, id);
12589
- if (!existsSync17(dir)) {
12618
+ if (!existsSync18(dir)) {
12590
12619
  const attShort = id.slice(0, 8);
12591
12620
  if (isHealPending(accountId, id)) {
12592
12621
  console.error(`[admin/sidebar-artefact-save] heal-race attachmentId=${attShort} outcome=503-retry source=heal-pending`);
@@ -12634,15 +12663,15 @@ async function resolveSavePath(id, accountId, accountDir) {
12634
12663
  function relPath(absPath, root) {
12635
12664
  return absPath.startsWith(root) ? absPath.slice(root.length + 1) : absPath;
12636
12665
  }
12637
- var sidebar_artefact_save_default = app31;
12666
+ var sidebar_artefact_save_default = app32;
12638
12667
 
12639
12668
  // server/routes/admin/sidebar-artefact-content.ts
12640
12669
  import { readFile as readFile6, readdir as readdir5 } from "fs/promises";
12641
- import { existsSync as existsSync18 } from "fs";
12670
+ import { existsSync as existsSync19 } from "fs";
12642
12671
  import { resolve as resolve19 } from "path";
12643
12672
  var UUID_RE5 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
12644
- var app32 = new Hono();
12645
- app32.get("/", requireAdminSession, async (c) => {
12673
+ var app33 = new Hono();
12674
+ app33.get("/", requireAdminSession, async (c) => {
12646
12675
  const cacheKey = c.var.cacheKey;
12647
12676
  const accountId = getAccountIdForSession(cacheKey);
12648
12677
  if (!accountId) return new Response("Unauthorized", { status: 401 });
@@ -12652,7 +12681,7 @@ app32.get("/", requireAdminSession, async (c) => {
12652
12681
  return new Response("Not found", { status: 404 });
12653
12682
  }
12654
12683
  const dir = resolve19(ATTACHMENTS_ROOT, accountId, id);
12655
- if (!existsSync18(dir)) {
12684
+ if (!existsSync19(dir)) {
12656
12685
  console.error(`[admin/sidebar-artefact-content] not-found id=${id.slice(0, 8)}`);
12657
12686
  return new Response("Not found", { status: 404 });
12658
12687
  }
@@ -12683,17 +12712,17 @@ app32.get("/", requireAdminSession, async (c) => {
12683
12712
  }
12684
12713
  });
12685
12714
  });
12686
- var sidebar_artefact_content_default = app32;
12715
+ var sidebar_artefact_content_default = app33;
12687
12716
 
12688
12717
  // server/routes/admin/health.ts
12689
- import { existsSync as existsSync19, readFileSync as readFileSync17 } from "fs";
12690
- import { resolve as resolve20, join as join12 } from "path";
12718
+ import { existsSync as existsSync20, readFileSync as readFileSync18 } from "fs";
12719
+ import { resolve as resolve20, join as join13 } from "path";
12691
12720
  var PLATFORM_ROOT6 = process.env.MAXY_PLATFORM_ROOT ?? resolve20(process.cwd(), "..");
12692
12721
  var brandHostname = "maxy";
12693
- var brandJsonPath = join12(PLATFORM_ROOT6, "config", "brand.json");
12694
- if (existsSync19(brandJsonPath)) {
12722
+ var brandJsonPath = join13(PLATFORM_ROOT6, "config", "brand.json");
12723
+ if (existsSync20(brandJsonPath)) {
12695
12724
  try {
12696
- const brand = JSON.parse(readFileSync17(brandJsonPath, "utf-8"));
12725
+ const brand = JSON.parse(readFileSync18(brandJsonPath, "utf-8"));
12697
12726
  if (brand.hostname) brandHostname = brand.hostname;
12698
12727
  } catch {
12699
12728
  }
@@ -12702,8 +12731,8 @@ var VERSION_FILE = resolve20(PLATFORM_ROOT6, `config/.${brandHostname}-version`)
12702
12731
  var PROCESS_STARTED_AT = (/* @__PURE__ */ new Date()).toISOString();
12703
12732
  var PROBE_TIMEOUT_MS = 1e3;
12704
12733
  function readVersion() {
12705
- if (!existsSync19(VERSION_FILE)) return "unknown";
12706
- return readFileSync17(VERSION_FILE, "utf-8").trim() || "unknown";
12734
+ if (!existsSync20(VERSION_FILE)) return "unknown";
12735
+ return readFileSync18(VERSION_FILE, "utf-8").trim() || "unknown";
12707
12736
  }
12708
12737
  async function probeConversationDb() {
12709
12738
  let session;
@@ -12728,8 +12757,8 @@ async function probeConversationDb() {
12728
12757
  });
12729
12758
  }
12730
12759
  }
12731
- var app33 = new Hono();
12732
- app33.get("/", async (c) => {
12760
+ var app34 = new Hono();
12761
+ app34.get("/", async (c) => {
12733
12762
  const version = readVersion();
12734
12763
  const probe = await probeConversationDb();
12735
12764
  const uptimeMs = Date.now() - new Date(PROCESS_STARTED_AT).getTime();
@@ -12751,7 +12780,7 @@ app33.get("/", async (c) => {
12751
12780
  uptimeMs
12752
12781
  });
12753
12782
  });
12754
- var health_default2 = app33;
12783
+ var health_default2 = app34;
12755
12784
 
12756
12785
  // server/routes/admin/linkedin-ingest.ts
12757
12786
  var TAG20 = "[linkedin-ingest-route]";
@@ -12847,8 +12876,8 @@ function buildInitialMessage(env) {
12847
12876
  }
12848
12877
  return header;
12849
12878
  }
12850
- var app34 = new Hono();
12851
- app34.post("/", requireAdminSession, async (c) => {
12879
+ var app35 = new Hono();
12880
+ app35.post("/", requireAdminSession, async (c) => {
12852
12881
  let body;
12853
12882
  try {
12854
12883
  body = await c.req.json();
@@ -12898,43 +12927,44 @@ app34.post("/", requireAdminSession, async (c) => {
12898
12927
  );
12899
12928
  return c.json({ ok: true, dispatchId: envelope.dispatchId, taskId: claudeSessionId }, 202);
12900
12929
  });
12901
- var linkedin_ingest_default = app34;
12930
+ var linkedin_ingest_default = app35;
12902
12931
 
12903
12932
  // server/routes/admin/index.ts
12904
- var app35 = new Hono();
12905
- app35.route("/session", session_default);
12906
- app35.route("/new-session-failure", new_session_failure_default);
12907
- app35.route("/new-session-submit", new_session_submit_default);
12908
- app35.route("/logs", logs_default);
12909
- app35.route("/claude-info", claude_info_default);
12910
- app35.route("/attachment", attachment_default);
12911
- app35.route("/agents", agents_default);
12912
- app35.route("/sessions", sessions_default);
12913
- app35.route("/claude-sessions", claude_sessions_default);
12914
- app35.route("/log-ingest", log_ingest_default);
12915
- app35.route("/browser", browser_default);
12916
- app35.route("/browser-iframe", browser_iframe_default);
12917
- app35.route("/device-browser", device_browser_default);
12918
- app35.route("/events", events_default);
12919
- app35.route("/cloudflare", cloudflare_default);
12920
- app35.route("/files", files_default);
12921
- app35.route("/graph-search", graph_search_default);
12922
- app35.route("/graph-subgraph", graph_subgraph_default);
12923
- app35.route("/graph-delete", graph_delete_default);
12924
- app35.route("/graph-restore", graph_restore_default);
12925
- app35.route("/graph-labels-in-graph", graph_labels_in_graph_default);
12926
- app35.route("/graph-default-view", graph_default_view_default);
12927
- app35.route("/session-defaults", session_defaults_default);
12928
- app35.route("/file-attach", file_attach_default);
12929
- app35.route("/sidebar-artefacts", sidebar_artefacts_default);
12930
- app35.route("/sidebar-artefact-save", sidebar_artefact_save_default);
12931
- app35.route("/sidebar-artefact-content", sidebar_artefact_content_default);
12932
- app35.route("/health-brand", health_default2);
12933
- app35.route("/linkedin-ingest", linkedin_ingest_default);
12934
- var admin_default = app35;
12933
+ var app36 = new Hono();
12934
+ app36.route("/session", session_default);
12935
+ app36.route("/new-session-failure", new_session_failure_default);
12936
+ app36.route("/new-session-submit", new_session_submit_default);
12937
+ app36.route("/logs", logs_default);
12938
+ app36.route("/claude-info", claude_info_default);
12939
+ app36.route("/claude-capabilities", claude_capabilities_default);
12940
+ app36.route("/attachment", attachment_default);
12941
+ app36.route("/agents", agents_default);
12942
+ app36.route("/sessions", sessions_default);
12943
+ app36.route("/claude-sessions", claude_sessions_default);
12944
+ app36.route("/log-ingest", log_ingest_default);
12945
+ app36.route("/browser", browser_default);
12946
+ app36.route("/browser-iframe", browser_iframe_default);
12947
+ app36.route("/device-browser", device_browser_default);
12948
+ app36.route("/events", events_default);
12949
+ app36.route("/cloudflare", cloudflare_default);
12950
+ app36.route("/files", files_default);
12951
+ app36.route("/graph-search", graph_search_default);
12952
+ app36.route("/graph-subgraph", graph_subgraph_default);
12953
+ app36.route("/graph-delete", graph_delete_default);
12954
+ app36.route("/graph-restore", graph_restore_default);
12955
+ app36.route("/graph-labels-in-graph", graph_labels_in_graph_default);
12956
+ app36.route("/graph-default-view", graph_default_view_default);
12957
+ app36.route("/session-defaults", session_defaults_default);
12958
+ app36.route("/file-attach", file_attach_default);
12959
+ app36.route("/sidebar-artefacts", sidebar_artefacts_default);
12960
+ app36.route("/sidebar-artefact-save", sidebar_artefact_save_default);
12961
+ app36.route("/sidebar-artefact-content", sidebar_artefact_content_default);
12962
+ app36.route("/health-brand", health_default2);
12963
+ app36.route("/linkedin-ingest", linkedin_ingest_default);
12964
+ var admin_default = app36;
12935
12965
 
12936
12966
  // server/routes/sites.ts
12937
- import { existsSync as existsSync20, readFileSync as readFileSync18, realpathSync as realpathSync5, statSync as statSync9 } from "fs";
12967
+ import { existsSync as existsSync21, readFileSync as readFileSync19, realpathSync as realpathSync5, statSync as statSync9 } from "fs";
12938
12968
  import { resolve as resolve21 } from "path";
12939
12969
  var SAFE_SEG_RE = /^[a-z0-9_][a-z0-9_.-]{0,99}$/i;
12940
12970
  var MIME = {
@@ -12966,8 +12996,8 @@ function getExt(p) {
12966
12996
  if (idx < p.lastIndexOf("/")) return "";
12967
12997
  return p.slice(idx).toLowerCase();
12968
12998
  }
12969
- var app36 = new Hono();
12970
- app36.get("/:rel{.*}", (c) => {
12999
+ var app37 = new Hono();
13000
+ app37.get("/:rel{.*}", (c) => {
12971
13001
  const reqPath = c.req.path;
12972
13002
  const rawRel = c.req.param("rel") ?? "";
12973
13003
  const trimmed = rawRel.replace(/^\/+/, "").replace(/\/+$/, "");
@@ -13000,7 +13030,7 @@ app36.get("/:rel{.*}", (c) => {
13000
13030
  }
13001
13031
  let stat7;
13002
13032
  try {
13003
- stat7 = existsSync20(filePath) ? statSync9(filePath) : null;
13033
+ stat7 = existsSync21(filePath) ? statSync9(filePath) : null;
13004
13034
  } catch {
13005
13035
  stat7 = null;
13006
13036
  }
@@ -13019,7 +13049,7 @@ app36.get("/:rel{.*}", (c) => {
13019
13049
  console.error(`[sites] path-traversal-rejected path=${reqPath} reason=escape status=403`);
13020
13050
  return c.text("Forbidden", 403);
13021
13051
  }
13022
- if (!existsSync20(filePath)) {
13052
+ if (!existsSync21(filePath)) {
13023
13053
  console.error(`[sites] not-found path=${reqPath} status=404`);
13024
13054
  return c.text("Not found", 404);
13025
13055
  }
@@ -13038,7 +13068,7 @@ app36.get("/:rel{.*}", (c) => {
13038
13068
  }
13039
13069
  let body;
13040
13070
  try {
13041
- body = readFileSync18(realPath);
13071
+ body = readFileSync19(realPath);
13042
13072
  } catch (err) {
13043
13073
  const code = err?.code;
13044
13074
  if (code === "EISDIR") {
@@ -13070,7 +13100,7 @@ app36.get("/:rel{.*}", (c) => {
13070
13100
  "X-Content-Type-Options": "nosniff"
13071
13101
  });
13072
13102
  });
13073
- var sites_default = app36;
13103
+ var sites_default = app37;
13074
13104
 
13075
13105
  // app/lib/graph-health.ts
13076
13106
  var HOUR_MS = 60 * 60 * 1e3;
@@ -13184,7 +13214,7 @@ function startReaper2() {
13184
13214
 
13185
13215
  // ../lib/entitlement/src/index.ts
13186
13216
  import { createPublicKey, createHash as createHash3, verify as cryptoVerify } from "crypto";
13187
- import { existsSync as existsSync21, readFileSync as readFileSync19, statSync as statSync10 } from "fs";
13217
+ import { existsSync as existsSync22, readFileSync as readFileSync20, statSync as statSync10 } from "fs";
13188
13218
  import { resolve as resolve22 } from "path";
13189
13219
 
13190
13220
  // ../lib/entitlement/src/canonicalize.ts
@@ -13233,7 +13263,7 @@ function resolveEntitlement(brand, account) {
13233
13263
  return logResolved(implicitTrust(account), null);
13234
13264
  }
13235
13265
  const entitlementPath = resolve22(brand.configDir, "entitlement.json");
13236
- if (!existsSync21(entitlementPath)) {
13266
+ if (!existsSync22(entitlementPath)) {
13237
13267
  return logResolved(anonymousFallback("missing"), { reason: "missing" });
13238
13268
  }
13239
13269
  const stat7 = statSync10(entitlementPath);
@@ -13248,7 +13278,7 @@ function resolveEntitlement(brand, account) {
13248
13278
  function verifyAndResolve(brand, entitlementPath, account) {
13249
13279
  let pubkeyPem;
13250
13280
  try {
13251
- pubkeyPem = readFileSync19(pubkeyPath(brand), "utf-8");
13281
+ pubkeyPem = readFileSync20(pubkeyPath(brand), "utf-8");
13252
13282
  } catch (err) {
13253
13283
  return logResolved(anonymousFallback("pubkey-missing"), {
13254
13284
  reason: "pubkey-missing"
@@ -13262,7 +13292,7 @@ function verifyAndResolve(brand, entitlementPath, account) {
13262
13292
  }
13263
13293
  let envelope;
13264
13294
  try {
13265
- envelope = JSON.parse(readFileSync19(entitlementPath, "utf-8"));
13295
+ envelope = JSON.parse(readFileSync20(entitlementPath, "utf-8"));
13266
13296
  } catch {
13267
13297
  return logResolved(anonymousFallback("malformed"), { reason: "malformed" });
13268
13298
  }
@@ -13423,14 +13453,14 @@ function clientFrom(c) {
13423
13453
  );
13424
13454
  }
13425
13455
  var PLATFORM_ROOT7 = process.env.MAXY_PLATFORM_ROOT || "";
13426
- var BRAND_JSON_PATH = PLATFORM_ROOT7 ? join13(PLATFORM_ROOT7, "config", "brand.json") : "";
13456
+ var BRAND_JSON_PATH = PLATFORM_ROOT7 ? join14(PLATFORM_ROOT7, "config", "brand.json") : "";
13427
13457
  var BRAND = { productName: "Maxy", hostname: "maxy", configDir: ".maxy", marketingUrl: "https://getmaxy.com" };
13428
- if (BRAND_JSON_PATH && !existsSync22(BRAND_JSON_PATH)) {
13458
+ if (BRAND_JSON_PATH && !existsSync23(BRAND_JSON_PATH)) {
13429
13459
  console.error(`[brand] WARNING: brand.json not found at ${BRAND_JSON_PATH} \u2014 using Maxy defaults`);
13430
13460
  }
13431
- if (BRAND_JSON_PATH && existsSync22(BRAND_JSON_PATH)) {
13461
+ if (BRAND_JSON_PATH && existsSync23(BRAND_JSON_PATH)) {
13432
13462
  try {
13433
- const parsed = JSON.parse(readFileSync20(BRAND_JSON_PATH, "utf-8"));
13463
+ const parsed = JSON.parse(readFileSync21(BRAND_JSON_PATH, "utf-8"));
13434
13464
  BRAND = { ...BRAND, ...parsed };
13435
13465
  } catch (err) {
13436
13466
  console.error(`[brand] Failed to parse brand.json: ${err.message}`);
@@ -13449,11 +13479,11 @@ var brandLoginOpts = {
13449
13479
  bodyFont: BRAND.defaultFonts?.body,
13450
13480
  logoContainsName: !!BRAND.logoContainsName
13451
13481
  };
13452
- var ALIAS_DOMAINS_PATH2 = join13(homedir4(), BRAND.configDir, "alias-domains.json");
13482
+ var ALIAS_DOMAINS_PATH2 = join14(homedir5(), BRAND.configDir, "alias-domains.json");
13453
13483
  function loadAliasDomains() {
13454
13484
  try {
13455
- if (!existsSync22(ALIAS_DOMAINS_PATH2)) return null;
13456
- const parsed = JSON.parse(readFileSync20(ALIAS_DOMAINS_PATH2, "utf-8"));
13485
+ if (!existsSync23(ALIAS_DOMAINS_PATH2)) return null;
13486
+ const parsed = JSON.parse(readFileSync21(ALIAS_DOMAINS_PATH2, "utf-8"));
13457
13487
  if (!Array.isArray(parsed)) {
13458
13488
  console.error("[alias-domains] malformed alias-domains.json \u2014 expected array");
13459
13489
  return null;
@@ -13477,9 +13507,9 @@ watchFile(ALIAS_DOMAINS_PATH2, { interval: 2e3 }, () => {
13477
13507
  function isPublicHost(host) {
13478
13508
  return host.startsWith("public.") || aliasDomains.has(host);
13479
13509
  }
13480
- var app37 = new Hono();
13481
- app37.use("*", clientIpMiddleware);
13482
- app37.use("*", async (c, next) => {
13510
+ var app38 = new Hono();
13511
+ app38.use("*", clientIpMiddleware);
13512
+ app38.use("*", async (c, next) => {
13483
13513
  await next();
13484
13514
  c.header("X-Content-Type-Options", "nosniff");
13485
13515
  c.header("Referrer-Policy", "strict-origin-when-cross-origin");
@@ -13489,7 +13519,7 @@ app37.use("*", async (c, next) => {
13489
13519
  );
13490
13520
  });
13491
13521
  var HTTP_LOG_PATHS = /* @__PURE__ */ new Set(["/vnc-viewer.html", "/vnc-popout.html"]);
13492
- app37.use("*", async (c, next) => {
13522
+ app38.use("*", async (c, next) => {
13493
13523
  if (!HTTP_LOG_PATHS.has(c.req.path)) {
13494
13524
  await next();
13495
13525
  return;
@@ -13522,7 +13552,7 @@ var PUBLIC_ALLOWED_PREFIXES = [
13522
13552
  "/sites/"
13523
13553
  ];
13524
13554
  var PUBLIC_ALLOWED_EXACT = ["/favicon.ico"];
13525
- app37.use("*", async (c, next) => {
13555
+ app38.use("*", async (c, next) => {
13526
13556
  const host = (c.req.header("host") ?? "").split(":")[0];
13527
13557
  if (!isPublicHost(host)) {
13528
13558
  await next();
@@ -13562,7 +13592,7 @@ function resolveRemoteAuthOpts() {
13562
13592
  return brandLoginOpts;
13563
13593
  }
13564
13594
  var MAX_LOGIN_BODY = 8 * 1024;
13565
- app37.post("/__remote-auth/login", async (c) => {
13595
+ app38.post("/__remote-auth/login", async (c) => {
13566
13596
  const client = clientFrom(c);
13567
13597
  const clientIp = client.ip || "unknown";
13568
13598
  if (!requestIsTlsTerminated(c)) {
@@ -13607,7 +13637,7 @@ app37.post("/__remote-auth/login", async (c) => {
13607
13637
  }
13608
13638
  });
13609
13639
  });
13610
- app37.get("/__remote-auth/logout", (c) => {
13640
+ app38.get("/__remote-auth/logout", (c) => {
13611
13641
  const client = clientFrom(c);
13612
13642
  const clientIp = client.ip || "unknown";
13613
13643
  console.error(`[remote-auth] logout ip=${clientIp}`);
@@ -13620,7 +13650,7 @@ app37.get("/__remote-auth/logout", (c) => {
13620
13650
  }
13621
13651
  });
13622
13652
  });
13623
- app37.post("/__remote-auth/change-password", async (c) => {
13653
+ app38.post("/__remote-auth/change-password", async (c) => {
13624
13654
  const client = clientFrom(c);
13625
13655
  const clientIp = client.ip || "unknown";
13626
13656
  const rateLimited = checkRateLimit(client);
@@ -13671,13 +13701,13 @@ app37.post("/__remote-auth/change-password", async (c) => {
13671
13701
  return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(), mode: "change", changeError: "Failed to save password", redirect }), 200);
13672
13702
  }
13673
13703
  });
13674
- app37.get("/__remote-auth/setup", (c) => {
13704
+ app38.get("/__remote-auth/setup", (c) => {
13675
13705
  if (isRemoteAuthConfigured()) {
13676
13706
  return c.redirect("/");
13677
13707
  }
13678
13708
  return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(), mode: "setup" }), 200);
13679
13709
  });
13680
- app37.post("/__remote-auth/set-initial-password", async (c) => {
13710
+ app38.post("/__remote-auth/set-initial-password", async (c) => {
13681
13711
  if (isRemoteAuthConfigured()) {
13682
13712
  return c.redirect("/");
13683
13713
  }
@@ -13715,10 +13745,10 @@ app37.post("/__remote-auth/set-initial-password", async (c) => {
13715
13745
  return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(), mode: "setup", setupError: "Failed to save password. Please try again." }), 200);
13716
13746
  }
13717
13747
  });
13718
- app37.get("/api/remote-auth/status", (c) => {
13748
+ app38.get("/api/remote-auth/status", (c) => {
13719
13749
  return c.json({ configured: isRemoteAuthConfigured() });
13720
13750
  });
13721
- app37.post("/api/remote-auth/set-password", async (c) => {
13751
+ app38.post("/api/remote-auth/set-password", async (c) => {
13722
13752
  let body;
13723
13753
  try {
13724
13754
  body = await c.req.json();
@@ -13749,9 +13779,9 @@ app37.post("/api/remote-auth/set-password", async (c) => {
13749
13779
  return c.json({ error: "Failed to save password" }, 500);
13750
13780
  }
13751
13781
  });
13752
- app37.route("/api/_client-error", client_error_default);
13782
+ app38.route("/api/_client-error", client_error_default);
13753
13783
  console.log("[client-error-route] mounted");
13754
- app37.use("*", async (c, next) => {
13784
+ app38.use("*", async (c, next) => {
13755
13785
  const host = (c.req.header("host") ?? "").split(":")[0];
13756
13786
  const path2 = c.req.path;
13757
13787
  if (path2 === "/favicon.ico" || path2.startsWith("/assets/") || path2.startsWith("/brand/")) {
@@ -13791,11 +13821,11 @@ app37.use("*", async (c, next) => {
13791
13821
  console.error(`[remote-auth] login required ip=${clientIp} path=${path2} ${disambig}`);
13792
13822
  return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(), redirect: path2 }), 200);
13793
13823
  });
13794
- app37.route("/api/health", health_default);
13795
- app37.route("/api/chat", chat_default);
13796
- app37.route("/api/whatsapp", whatsapp_default);
13797
- app37.route("/api/onboarding", onboarding_default);
13798
- app37.route("/api/admin", admin_default);
13824
+ app38.route("/api/health", health_default);
13825
+ app38.route("/api/chat", chat_default);
13826
+ app38.route("/api/whatsapp", whatsapp_default);
13827
+ app38.route("/api/onboarding", onboarding_default);
13828
+ app38.route("/api/admin", admin_default);
13799
13829
  var SAFE_SLUG_RE = /^[a-z][a-z0-9-]{2,49}$/;
13800
13830
  var SAFE_FILENAME_RE = /^[a-z0-9_][a-z0-9_.-]{0,99}$/i;
13801
13831
  var IMAGE_MIME = {
@@ -13807,7 +13837,7 @@ var IMAGE_MIME = {
13807
13837
  ".svg": "image/svg+xml",
13808
13838
  ".ico": "image/x-icon"
13809
13839
  };
13810
- app37.get("/agent-assets/:slug/:filename", (c) => {
13840
+ app38.get("/agent-assets/:slug/:filename", (c) => {
13811
13841
  const slug = c.req.param("slug");
13812
13842
  const filename = c.req.param("filename");
13813
13843
  if (!SAFE_SLUG_RE.test(slug)) {
@@ -13829,20 +13859,20 @@ app37.get("/agent-assets/:slug/:filename", (c) => {
13829
13859
  console.error(`[agent-assets] path-traversal-rejected slug=${slug} file=${filename}`);
13830
13860
  return c.text("Forbidden", 403);
13831
13861
  }
13832
- if (!existsSync22(filePath)) {
13862
+ if (!existsSync23(filePath)) {
13833
13863
  console.error(`[agent-assets] serve slug=${slug} file=${filename} status=404`);
13834
13864
  return c.text("Not found", 404);
13835
13865
  }
13836
13866
  const ext = "." + filename.split(".").pop()?.toLowerCase();
13837
13867
  const contentType = IMAGE_MIME[ext] || "application/octet-stream";
13838
13868
  console.log(`[agent-assets] serve slug=${slug} file=${filename} status=200`);
13839
- const body = readFileSync20(filePath);
13869
+ const body = readFileSync21(filePath);
13840
13870
  return c.body(body, 200, {
13841
13871
  "Content-Type": contentType,
13842
13872
  "Cache-Control": "public, max-age=3600"
13843
13873
  });
13844
13874
  });
13845
- app37.get("/generated/:filename", (c) => {
13875
+ app38.get("/generated/:filename", (c) => {
13846
13876
  const filename = c.req.param("filename");
13847
13877
  if (!SAFE_FILENAME_RE.test(filename) || filename.includes("..")) {
13848
13878
  console.error(`[generated] serve file=${filename} status=403`);
@@ -13859,26 +13889,26 @@ app37.get("/generated/:filename", (c) => {
13859
13889
  console.error(`[generated] serve file=${filename} status=403`);
13860
13890
  return c.text("Forbidden", 403);
13861
13891
  }
13862
- if (!existsSync22(filePath)) {
13892
+ if (!existsSync23(filePath)) {
13863
13893
  console.error(`[generated] serve file=${filename} status=404`);
13864
13894
  return c.text("Not found", 404);
13865
13895
  }
13866
13896
  const ext = "." + filename.split(".").pop()?.toLowerCase();
13867
13897
  const contentType = IMAGE_MIME[ext] || "application/octet-stream";
13868
13898
  console.log(`[generated] serve file=${filename} status=200`);
13869
- const body = readFileSync20(filePath);
13899
+ const body = readFileSync21(filePath);
13870
13900
  return c.body(body, 200, {
13871
13901
  "Content-Type": contentType,
13872
13902
  "Cache-Control": "public, max-age=86400"
13873
13903
  });
13874
13904
  });
13875
- app37.route("/sites", sites_default);
13905
+ app38.route("/sites", sites_default);
13876
13906
  var htmlCache = /* @__PURE__ */ new Map();
13877
13907
  var brandLogoPath = "/brand/maxy-monochrome.png";
13878
13908
  var brandIconPath = "/brand/maxy-monochrome.png";
13879
- if (BRAND_JSON_PATH && existsSync22(BRAND_JSON_PATH)) {
13909
+ if (BRAND_JSON_PATH && existsSync23(BRAND_JSON_PATH)) {
13880
13910
  try {
13881
- const fullBrand = JSON.parse(readFileSync20(BRAND_JSON_PATH, "utf-8"));
13911
+ const fullBrand = JSON.parse(readFileSync21(BRAND_JSON_PATH, "utf-8"));
13882
13912
  if (fullBrand.assets?.logo) brandLogoPath = `/brand/${fullBrand.assets.logo}`;
13883
13913
  brandIconPath = fullBrand.assets?.icon ? `/brand/${fullBrand.assets.icon}` : brandLogoPath;
13884
13914
  } catch {
@@ -13895,9 +13925,9 @@ var brandScript = `<script>window.__BRAND__=${JSON.stringify({
13895
13925
  function readInstalledVersion() {
13896
13926
  try {
13897
13927
  if (!PLATFORM_ROOT7) return "unknown";
13898
- const versionFile = join13(PLATFORM_ROOT7, "config", `.${BRAND.hostname}-version`);
13899
- if (!existsSync22(versionFile)) return "unknown";
13900
- const content = readFileSync20(versionFile, "utf-8").trim();
13928
+ const versionFile = join14(PLATFORM_ROOT7, "config", `.${BRAND.hostname}-version`);
13929
+ if (!existsSync23(versionFile)) return "unknown";
13930
+ const content = readFileSync21(versionFile, "utf-8").trim();
13901
13931
  return content || "unknown";
13902
13932
  } catch {
13903
13933
  return "unknown";
@@ -13938,7 +13968,7 @@ var clientErrorReporterScript = `<script>
13938
13968
  function cachedHtml(file) {
13939
13969
  let html = htmlCache.get(file);
13940
13970
  if (!html) {
13941
- html = readFileSync20(resolve23(process.cwd(), "public", file), "utf-8");
13971
+ html = readFileSync21(resolve23(process.cwd(), "public", file), "utf-8");
13942
13972
  const productNameEsc = escapeHtml(BRAND.productName);
13943
13973
  html = html.replace(/<title>([^<]*)<\/title>/, (_match, inner) => `<title>${escapeHtml(inner).replace(/Maxy/g, productNameEsc)}</title>`);
13944
13974
  html = html.replace('href="/favicon.ico"', `href="${escapeHtml(brandFaviconPath)}"`);
@@ -13954,26 +13984,26 @@ ${clientErrorReporterScript}
13954
13984
  }
13955
13985
  var brandedHtmlCache = /* @__PURE__ */ new Map();
13956
13986
  function loadBrandingCache(agentSlug) {
13957
- const configDir2 = join13(homedir4(), BRAND.configDir);
13987
+ const configDir2 = join14(homedir5(), BRAND.configDir);
13958
13988
  try {
13959
- const accountJsonPath = join13(configDir2, "account.json");
13960
- if (!existsSync22(accountJsonPath)) return null;
13961
- const account = JSON.parse(readFileSync20(accountJsonPath, "utf-8"));
13989
+ const accountJsonPath = join14(configDir2, "account.json");
13990
+ if (!existsSync23(accountJsonPath)) return null;
13991
+ const account = JSON.parse(readFileSync21(accountJsonPath, "utf-8"));
13962
13992
  const accountId = account.accountId;
13963
13993
  if (!accountId) return null;
13964
- const cachePath = join13(configDir2, "branding-cache", accountId, `${agentSlug}.json`);
13965
- if (!existsSync22(cachePath)) return null;
13966
- return JSON.parse(readFileSync20(cachePath, "utf-8"));
13994
+ const cachePath = join14(configDir2, "branding-cache", accountId, `${agentSlug}.json`);
13995
+ if (!existsSync23(cachePath)) return null;
13996
+ return JSON.parse(readFileSync21(cachePath, "utf-8"));
13967
13997
  } catch {
13968
13998
  return null;
13969
13999
  }
13970
14000
  }
13971
14001
  function resolveDefaultSlug() {
13972
14002
  try {
13973
- const configDir2 = join13(homedir4(), BRAND.configDir);
13974
- const accountJsonPath = join13(configDir2, "account.json");
13975
- if (!existsSync22(accountJsonPath)) return null;
13976
- const account = JSON.parse(readFileSync20(accountJsonPath, "utf-8"));
14003
+ const configDir2 = join14(homedir5(), BRAND.configDir);
14004
+ const accountJsonPath = join14(configDir2, "account.json");
14005
+ if (!existsSync23(accountJsonPath)) return null;
14006
+ const account = JSON.parse(readFileSync21(accountJsonPath, "utf-8"));
13977
14007
  return account.defaultAgent || null;
13978
14008
  } catch {
13979
14009
  return null;
@@ -14009,7 +14039,7 @@ function brandedPublicHtml(agentSlug) {
14009
14039
  function escapeHtml(s) {
14010
14040
  return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
14011
14041
  }
14012
- app37.get("/", (c) => {
14042
+ app38.get("/", (c) => {
14013
14043
  const host = (c.req.header("host") ?? "").split(":")[0];
14014
14044
  if (isPublicHost(host)) {
14015
14045
  const defaultSlug = resolveDefaultSlug();
@@ -14017,12 +14047,12 @@ app37.get("/", (c) => {
14017
14047
  }
14018
14048
  return c.html(cachedHtml("index.html"));
14019
14049
  });
14020
- app37.get("/public", (c) => {
14050
+ app38.get("/public", (c) => {
14021
14051
  const host = (c.req.header("host") ?? "").split(":")[0];
14022
14052
  if (isPublicHost(host)) return c.text("Not found", 404);
14023
14053
  return c.html(cachedHtml("public.html"));
14024
14054
  });
14025
- app37.get("/chat", (c) => {
14055
+ app38.get("/chat", (c) => {
14026
14056
  const host = (c.req.header("host") ?? "").split(":")[0];
14027
14057
  if (isPublicHost(host)) return c.text("Not found", 404);
14028
14058
  return c.html(cachedHtml("public.html"));
@@ -14041,12 +14071,12 @@ async function logViewerFetch(c, next) {
14041
14071
  duration_ms: Date.now() - start
14042
14072
  });
14043
14073
  }
14044
- app37.use("/vnc-viewer.html", logViewerFetch);
14045
- app37.use("/vnc-popout.html", logViewerFetch);
14046
- app37.get("/vnc-popout.html", (c) => {
14074
+ app38.use("/vnc-viewer.html", logViewerFetch);
14075
+ app38.use("/vnc-popout.html", logViewerFetch);
14076
+ app38.get("/vnc-popout.html", (c) => {
14047
14077
  let html = htmlCache.get("vnc-popout.html");
14048
14078
  if (!html) {
14049
- html = readFileSync20(resolve23(process.cwd(), "public", "vnc-popout.html"), "utf-8");
14079
+ html = readFileSync21(resolve23(process.cwd(), "public", "vnc-popout.html"), "utf-8");
14050
14080
  const name = escapeHtml(BRAND.productName);
14051
14081
  html = html.replace("<title>Browser \u2014 Maxy</title>", `<title>${name}</title>`);
14052
14082
  html = html.replace("</head>", ` ${brandScript}
@@ -14056,7 +14086,7 @@ app37.get("/vnc-popout.html", (c) => {
14056
14086
  }
14057
14087
  return c.html(html);
14058
14088
  });
14059
- app37.post("/api/vnc/client-event", async (c) => {
14089
+ app38.post("/api/vnc/client-event", async (c) => {
14060
14090
  let body;
14061
14091
  try {
14062
14092
  body = await c.req.json();
@@ -14077,25 +14107,25 @@ app37.post("/api/vnc/client-event", async (c) => {
14077
14107
  });
14078
14108
  return c.json({ ok: true });
14079
14109
  });
14080
- app37.get("/g/:slug", (c) => {
14110
+ app38.get("/g/:slug", (c) => {
14081
14111
  return c.html(brandedPublicHtml());
14082
14112
  });
14083
- app37.get("/graph", (c) => {
14113
+ app38.get("/graph", (c) => {
14084
14114
  const host = (c.req.header("host") ?? "").split(":")[0];
14085
14115
  if (isPublicHost(host)) return c.text("Not found", 404);
14086
14116
  return c.html(cachedHtml("graph.html"));
14087
14117
  });
14088
- app37.get("/sessions", (c) => {
14118
+ app38.get("/sessions", (c) => {
14089
14119
  const host = (c.req.header("host") ?? "").split(":")[0];
14090
14120
  if (isPublicHost(host)) return c.text("Not found", 404);
14091
14121
  return c.html(cachedHtml("sessions.html"));
14092
14122
  });
14093
- app37.get("/data", (c) => {
14123
+ app38.get("/data", (c) => {
14094
14124
  const host = (c.req.header("host") ?? "").split(":")[0];
14095
14125
  if (isPublicHost(host)) return c.text("Not found", 404);
14096
14126
  return c.html(cachedHtml("data.html"));
14097
14127
  });
14098
- app37.get("/:slug", async (c, next) => {
14128
+ app38.get("/:slug", async (c, next) => {
14099
14129
  const slug = c.req.param("slug");
14100
14130
  if (AGENT_SLUG_PATTERN.test(`/${slug}`)) {
14101
14131
  const branding = loadBrandingCache(slug);
@@ -14105,15 +14135,15 @@ app37.get("/:slug", async (c, next) => {
14105
14135
  await next();
14106
14136
  });
14107
14137
  if (brandFaviconPath !== "/favicon.ico") {
14108
- app37.get("/favicon.ico", (c) => {
14138
+ app38.get("/favicon.ico", (c) => {
14109
14139
  c.header("Cache-Control", "public, max-age=300");
14110
14140
  return c.redirect(brandFaviconPath, 302);
14111
14141
  });
14112
14142
  }
14113
- app37.use("/*", serveStatic({ root: "./public" }));
14143
+ app38.use("/*", serveStatic({ root: "./public" }));
14114
14144
  var port = requirePortEnv("MAXY_UI_INTERNAL_PORT", { tag: "ui-server" });
14115
14145
  var hostname = process.env.HOSTNAME ?? "127.0.0.1";
14116
- var httpServer = serve({ fetch: app37.fetch, port, hostname });
14146
+ var httpServer = serve({ fetch: app38.fetch, port, hostname });
14117
14147
  console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
14118
14148
  {
14119
14149
  const loopHist = monitorEventLoopDelay({ resolution: 50 });
@@ -14145,7 +14175,7 @@ for (const m of SUBAPP_MANIFEST) {
14145
14175
  }
14146
14176
  try {
14147
14177
  const registered = [];
14148
- for (const r of app37.routes ?? []) {
14178
+ for (const r of app38.routes ?? []) {
14149
14179
  if (typeof r.path !== "string" || r.path.includes(":") || r.path.includes("*")) continue;
14150
14180
  if (AGENT_SLUG_PATTERN.test(r.path)) {
14151
14181
  registered.push({ method: (r.method ?? "ALL").toUpperCase(), path: r.path });
@@ -14167,8 +14197,8 @@ try {
14167
14197
  }
14168
14198
  (async () => {
14169
14199
  try {
14170
- if (!existsSync22(USERS_FILE)) return;
14171
- const usersRaw = readFileSync20(USERS_FILE, "utf-8").trim();
14200
+ if (!existsSync23(USERS_FILE)) return;
14201
+ const usersRaw = readFileSync21(USERS_FILE, "utf-8").trim();
14172
14202
  if (!usersRaw) return;
14173
14203
  const users = JSON.parse(usersRaw);
14174
14204
  const userId = users[0]?.userId;
@@ -14279,7 +14309,7 @@ if (bootAccountConfig?.whatsapp) {
14279
14309
  }
14280
14310
  init({
14281
14311
  configDir: configDirForWhatsApp,
14282
- platformRoot: resolve23(process.env.MAXY_PLATFORM_ROOT ?? join13(__dirname, "..")),
14312
+ platformRoot: resolve23(process.env.MAXY_PLATFORM_ROOT ?? join14(__dirname, "..")),
14283
14313
  accountConfig: bootAccountConfig,
14284
14314
  onMessage: async (msg) => {
14285
14315
  if (process.env.WHATSAPP_PTY_BRIDGE_ENABLED === "true" && msg.text && !msg.isOwnerMirror) {