@rubytech/create-maxy-code 0.1.4 → 0.1.5

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.
@@ -1,4 +1,5 @@
1
1
  import {
2
+ ACCOUNTS_DIR,
2
3
  BIN_DIR,
3
4
  BRAND_NAME,
4
5
  CDP_PORT,
@@ -8,6 +9,7 @@ import {
8
9
  Hono,
9
10
  LOG_DIR,
10
11
  MAXY_DIR,
12
+ PLATFORM_ROOT,
11
13
  RFB_PORT,
12
14
  TELEGRAM_ADMIN_WEBHOOK_SECRET_FILE,
13
15
  TELEGRAM_WEBHOOK_SECRET_FILE,
@@ -15,6 +17,8 @@ import {
15
17
  VNC_DISPLAY,
16
18
  WEBSOCKIFY_PORT,
17
19
  agentLogStream,
20
+ appendStreamLogLine,
21
+ autoDeliverPremiumPlugins,
18
22
  browserViewerLog,
19
23
  canAccessAdmin,
20
24
  checkRateLimit,
@@ -24,21 +28,23 @@ import {
24
28
  compactSession,
25
29
  completeGrantSetup,
26
30
  createRemoteSession,
31
+ emitMissingOnResolve,
27
32
  findMissingPlugins,
28
33
  fingerprintSessionKey,
29
34
  getAccountIdForSession,
30
35
  getAgentNameForSession,
36
+ getBundleMtimeIso,
31
37
  getConversationIdForSession,
32
38
  getDefaultAccountId,
33
39
  getGrantForSession,
34
40
  getGroupSlugForSession,
35
41
  getRoleForSession,
42
+ getSessionKeyByConversationId,
36
43
  getSessionMessages,
37
44
  getStreamLogHandle,
38
45
  getUserIdForSession,
39
46
  getUserNameForSession,
40
47
  getVisitorIdForSession,
41
- hasStubAccountDir,
42
48
  hashPassword,
43
49
  httpLog,
44
50
  invokeAgent,
@@ -47,7 +53,7 @@ import {
47
53
  isRemoteAuthConfigured,
48
54
  launchAction,
49
55
  listAdminSessionsInProgress,
50
- mintAdminSessionToken,
56
+ reconcileEnabledPlugins,
51
57
  recordFailedAttempt,
52
58
  registerGrantSession,
53
59
  registerResumedSession,
@@ -69,6 +75,7 @@ import {
69
75
  setWantsPriorConversation,
70
76
  sigtermFlushStreamLogs,
71
77
  streamLogPathFor,
78
+ stripAttachmentMetaSuffix,
72
79
  tryCookieBridgeForConversation,
73
80
  unregisterSession,
74
81
  validateAgentSlug,
@@ -77,8 +84,9 @@ import {
77
84
  verifyPassword,
78
85
  verifyRemotePassword,
79
86
  vncLog,
80
- waitForExit
81
- } from "./chunk-6YL26HQW.js";
87
+ waitForExit,
88
+ walkPremiumBundles
89
+ } from "./chunk-IDKWGLM5.js";
82
90
  import {
83
91
  CLOUDFLARE_TASK_DIAGNOSTICS,
84
92
  appendCloudflareSteps,
@@ -642,8 +650,8 @@ var serveStatic = (options = { root: "" }) => {
642
650
  };
643
651
 
644
652
  // server/index.ts
645
- import { readFileSync as readFileSync23, existsSync as existsSync26, watchFile } from "fs";
646
- import { resolve as resolve26, join as join14, basename as basename5 } from "path";
653
+ import { readFileSync as readFileSync22, existsSync as existsSync25, watchFile } from "fs";
654
+ import { resolve as resolve25, join as join13, basename as basename5 } from "path";
647
655
  import { homedir as homedir5 } from "os";
648
656
 
649
657
  // app/lib/agent-slug-pattern.ts
@@ -1625,7 +1633,7 @@ var credsSaveQueue = Promise.resolve();
1625
1633
  async function drainCredsSaveQueue(timeoutMs = 5e3) {
1626
1634
  console.error(`${TAG3} draining credential save queue\u2026`);
1627
1635
  const timer2 = new Promise(
1628
- (resolve27) => setTimeout(() => resolve27("timeout"), timeoutMs)
1636
+ (resolve26) => setTimeout(() => resolve26("timeout"), timeoutMs)
1629
1637
  );
1630
1638
  const result = await Promise.race([
1631
1639
  credsSaveQueue.then(() => "drained"),
@@ -1753,11 +1761,11 @@ async function createWaSocket(opts) {
1753
1761
  return sock;
1754
1762
  }
1755
1763
  async function waitForConnection(sock) {
1756
- return new Promise((resolve27, reject) => {
1764
+ return new Promise((resolve26, reject) => {
1757
1765
  const handler = (update) => {
1758
1766
  if (update.connection === "open") {
1759
1767
  sock.ev.off("connection.update", handler);
1760
- resolve27();
1768
+ resolve26();
1761
1769
  }
1762
1770
  if (update.connection === "close") {
1763
1771
  sock.ev.off("connection.update", handler);
@@ -1871,14 +1879,14 @@ ${inspected}`;
1871
1879
  return inspect2(err, INSPECT_OPTS2);
1872
1880
  }
1873
1881
  function withTimeout(label, promise, timeoutMs) {
1874
- return new Promise((resolve27, reject) => {
1882
+ return new Promise((resolve26, reject) => {
1875
1883
  const timer2 = setTimeout(() => {
1876
1884
  reject(new Error(`${label} timed out after ${timeoutMs}ms`));
1877
1885
  }, timeoutMs);
1878
1886
  promise.then(
1879
1887
  (value) => {
1880
1888
  clearTimeout(timer2);
1881
- resolve27(value);
1889
+ resolve26(value);
1882
1890
  },
1883
1891
  (err) => {
1884
1892
  clearTimeout(timer2);
@@ -2413,8 +2421,8 @@ async function persistWhatsAppMessage(input) {
2413
2421
  const { givenName, familyName } = splitName(input.pushName);
2414
2422
  const prev = sessionWriteLocks.get(input.cacheKey);
2415
2423
  let release;
2416
- const mine = new Promise((resolve27) => {
2417
- release = resolve27;
2424
+ const mine = new Promise((resolve26) => {
2425
+ release = resolve26;
2418
2426
  });
2419
2427
  const chained = (prev ?? Promise.resolve()).then(() => mine);
2420
2428
  sessionWriteLocks.set(input.cacheKey, chained);
@@ -2598,11 +2606,6 @@ async function ensureWhatsAppConversation(input) {
2598
2606
  }
2599
2607
  }
2600
2608
 
2601
- // app/lib/claude-agent/account.ts
2602
- var ACCOUNTS_DIR = "";
2603
- var PLATFORM_ROOT = "";
2604
- var resolveAccount2 = (..._args) => null;
2605
-
2606
2609
  // ../lib/account-enumeration/src/index.ts
2607
2610
  import { readdirSync, readFileSync as readFileSync4 } from "fs";
2608
2611
  import { resolve as resolve3 } from "path";
@@ -3456,11 +3459,11 @@ async function connectWithReconnect(conn) {
3456
3459
  console.error(
3457
3460
  `${TAG13} reconnecting account=${conn.accountId} in ${delay}ms (attempt ${decision.nextAttempts}/${maxAttempts})`
3458
3461
  );
3459
- await new Promise((resolve27) => {
3460
- const timer2 = setTimeout(resolve27, delay);
3462
+ await new Promise((resolve26) => {
3463
+ const timer2 = setTimeout(resolve26, delay);
3461
3464
  conn.abortController.signal.addEventListener("abort", () => {
3462
3465
  clearTimeout(timer2);
3463
- resolve27();
3466
+ resolve26();
3464
3467
  }, { once: true });
3465
3468
  });
3466
3469
  }
@@ -3468,16 +3471,16 @@ async function connectWithReconnect(conn) {
3468
3471
  }
3469
3472
  }
3470
3473
  function waitForDisconnectEvent(conn) {
3471
- return new Promise((resolve27) => {
3474
+ return new Promise((resolve26) => {
3472
3475
  if (!conn.sock) {
3473
- resolve27();
3476
+ resolve26();
3474
3477
  return;
3475
3478
  }
3476
3479
  const sock = conn.sock;
3477
3480
  const handler = (update) => {
3478
3481
  if (update.connection === "close") {
3479
3482
  sock.ev.off("connection.update", handler);
3480
- resolve27();
3483
+ resolve26();
3481
3484
  }
3482
3485
  };
3483
3486
  sock.ev.on("connection.update", handler);
@@ -3739,8 +3742,8 @@ async function handleInboundMessage(conn, msg) {
3739
3742
  const conversationKey = isGroup ? remoteJid : senderPhone;
3740
3743
  const debounceKey = `${conn.accountId}:${conversationKey}:${senderPhone}`;
3741
3744
  let resolvePending;
3742
- const sttPending = new Promise((resolve27) => {
3743
- resolvePending = resolve27;
3745
+ const sttPending = new Promise((resolve26) => {
3746
+ resolvePending = resolve26;
3744
3747
  });
3745
3748
  if (conn.debouncer) conn.debouncer.registerPending(debounceKey, sttPending);
3746
3749
  try {
@@ -4157,20 +4160,20 @@ async function probeApiKey() {
4157
4160
  return result.status;
4158
4161
  }
4159
4162
  function checkPort(port2, timeoutMs = 500) {
4160
- return new Promise((resolve27) => {
4163
+ return new Promise((resolve26) => {
4161
4164
  const socket = createConnection2(port2, "127.0.0.1");
4162
4165
  socket.setTimeout(timeoutMs);
4163
4166
  socket.once("connect", () => {
4164
4167
  socket.destroy();
4165
- resolve27(true);
4168
+ resolve26(true);
4166
4169
  });
4167
4170
  socket.once("error", () => {
4168
4171
  socket.destroy();
4169
- resolve27(false);
4172
+ resolve26(false);
4170
4173
  });
4171
4174
  socket.once("timeout", () => {
4172
4175
  socket.destroy();
4173
- resolve27(false);
4176
+ resolve26(false);
4174
4177
  });
4175
4178
  });
4176
4179
  }
@@ -6697,8 +6700,8 @@ async function startLogin(opts) {
6697
6700
  resetActiveLogin(accountId);
6698
6701
  let resolveQr = null;
6699
6702
  let rejectQr = null;
6700
- const qrPromise = new Promise((resolve27, reject) => {
6701
- resolveQr = resolve27;
6703
+ const qrPromise = new Promise((resolve26, reject) => {
6704
+ resolveQr = resolve26;
6702
6705
  rejectQr = reject;
6703
6706
  });
6704
6707
  const qrTimer = setTimeout(
@@ -7659,17 +7662,6 @@ app8.post("/set-pin", async (c) => {
7659
7662
  if (existingUsers !== null && existingUsers.length > 0) {
7660
7663
  return c.json({ error: "PIN is already configured." }, 409);
7661
7664
  }
7662
- const stubCheck = hasStubAccountDir();
7663
- if (stubCheck.stub) {
7664
- console.error(
7665
- `[onboarding] set-pin REFUSED reason=stub-account-dirs dirs=${stubCheck.dirs.join(",")}`
7666
- );
7667
- return c.json({
7668
- error: `Onboarding refused: data/accounts/ contains ${stubCheck.dirs.length} directory/ies without account.json (${stubCheck.dirs.join(", ")}). Resolve the stub before setting up.`,
7669
- code: "STUB_ACCOUNT_DIR",
7670
- dirs: stubCheck.dirs
7671
- }, 409);
7672
- }
7673
7665
  let body;
7674
7666
  try {
7675
7667
  body = await c.req.json();
@@ -7996,6 +7988,7 @@ var client_error_default = app9;
7996
7988
  import { readFileSync as readFileSync14, readdirSync as readdirSync4, statSync as statSync4, writeFileSync as writeFileSync10, existsSync as existsSync12 } from "fs";
7997
7989
  import { join as join9 } from "path";
7998
7990
  import { createHash as createHash2 } from "crypto";
7991
+ import { randomUUID as randomUUID7 } from "crypto";
7999
7992
  var deprecationLogged = /* @__PURE__ */ new Set();
8000
7993
  function hashPin2(pin) {
8001
7994
  return createHash2("sha256").update(pin).digest("hex");
@@ -8071,7 +8064,7 @@ async function resolveUserIdentity(accountId, userId) {
8071
8064
  async function createAdminSession(accountId, thinkingView, userId, userName, role, avatar) {
8072
8065
  const account = resolveAccount();
8073
8066
  const effectiveThinkingView = thinkingView ?? account?.config.thinkingView ?? "default";
8074
- const signedSessionToken = userId ? mintAdminSessionToken({ accountId, userId }) : crypto.randomUUID();
8067
+ const signedSessionToken = randomUUID7();
8075
8068
  const cacheKey = fingerprintSessionKey(signedSessionToken);
8076
8069
  registerSession(cacheKey, "admin", accountId, void 0, userId, userName, role);
8077
8070
  if (userId) setWantsPriorConversation(cacheKey);
@@ -8373,9 +8366,6 @@ app13.post("/", requireAdminSession, async (c) => {
8373
8366
  });
8374
8367
  var new_session_submit_default = app13;
8375
8368
 
8376
- // app/lib/claude-agent/stream-log-writer.ts
8377
- var appendStreamLogLine = (..._args) => null;
8378
-
8379
8369
  // server/routes/admin/failure-report.ts
8380
8370
  var SESSION_KEY_RE = /^sk_[0-9a-f]{16}$/i;
8381
8371
  var UUID_RE4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -8544,12 +8534,6 @@ function resolveSessionLogPaths(filename, logDirs) {
8544
8534
  return { hits, tried };
8545
8535
  }
8546
8536
 
8547
- // app/lib/claude-agent/session-store.ts
8548
- var getSessionKeyByConversationId = (..._args) => null;
8549
-
8550
- // app/lib/claude-agent/logging.ts
8551
- var emitMissingOnResolve = (..._args) => null;
8552
-
8553
8537
  // server/routes/admin/logs.ts
8554
8538
  var TAIL_BYTES = 8192;
8555
8539
  var app17 = new Hono();
@@ -8859,9 +8843,6 @@ import crypto2 from "crypto";
8859
8843
  import { resolve as resolvePath } from "path";
8860
8844
  import { existsSync as existsSync17 } from "fs";
8861
8845
 
8862
- // app/lib/claude-agent/summary-helpers.ts
8863
- var stripAttachmentMetaSuffix = (..._args) => null;
8864
-
8865
8846
  // app/lib/synthetic-marker.ts
8866
8847
  var CLOUDFLARE_MARKER_PREFIX = "Cloudflare setup completed (actionId: ";
8867
8848
  var COMPONENT_DONE_PREFIX = '{"_componentDone"';
@@ -10081,9 +10062,6 @@ var CLOUDFLARE_SETUP_FORM_SCHEMA = {
10081
10062
  secretFields: ["password", "session_key", "messageId"]
10082
10063
  };
10083
10064
 
10084
- // app/lib/claude-agent/spawn-env.ts
10085
- var getBundleMtimeIso = (..._args) => null;
10086
-
10087
10065
  // server/routes/admin/cloudflare.ts
10088
10066
  var SETUP_TIMEOUT_MS = 10 * 60 * 1e3;
10089
10067
  var DOMAINS_TIMEOUT_MS = 40 * 1e3;
@@ -10336,8 +10314,8 @@ app27.get("/tunnels", requireAdminSession, async (c) => {
10336
10314
  if (!correlationId) return err("session", "No active conversation for session \u2014 refresh chat.");
10337
10315
  streamLogPath = streamLogPathFor(accountId, correlationId).streamLogPath;
10338
10316
  const certPath = resolve16(homedir4(), brand.configDir, "cloudflared", "cert.pem");
10339
- const { existsSync: existsSync27 } = await import("fs");
10340
- if (!existsSync27(certPath)) {
10317
+ const { existsSync: existsSync26 } = await import("fs");
10318
+ if (!existsSync26(certPath)) {
10341
10319
  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.`);
10342
10320
  }
10343
10321
  const result = await runFormSpawn({
@@ -10477,7 +10455,7 @@ app27.post("/setup", requireAdminSession, async (c) => {
10477
10455
  } catch (e) {
10478
10456
  log(`retry-decision lookup-failed reason="${e instanceof Error ? e.message : String(e)}" branch=proceed`);
10479
10457
  }
10480
- const account = resolveAccount2();
10458
+ const account = resolveAccount();
10481
10459
  if (!account) {
10482
10460
  return err("script", "No account on disk for this device \u2014 re-run installer.");
10483
10461
  }
@@ -13660,152 +13638,10 @@ function startGraphHealthTimer() {
13660
13638
  if (typeof timer.unref === "function") timer.unref();
13661
13639
  }
13662
13640
 
13663
- // app/lib/claude-agent/plugin-manifest.ts
13664
- import { resolve as resolve24, join as join13 } from "path";
13665
- import {
13666
- readFileSync as readFileSync21,
13667
- writeFileSync as writeFileSync12,
13668
- readdirSync as readdirSync7,
13669
- existsSync as existsSync24,
13670
- statSync as statSync8,
13671
- cpSync
13672
- } from "fs";
13673
- function readBundleSubPlugins(bundlePath) {
13674
- if (!existsSync24(bundlePath)) return [];
13675
- let raw;
13676
- try {
13677
- raw = readFileSync21(bundlePath, "utf-8");
13678
- } catch {
13679
- return [];
13680
- }
13681
- const fm = raw.match(/^---\n([\s\S]*?)\n---/);
13682
- if (!fm) return [];
13683
- const subs = [];
13684
- let inPlugins = false;
13685
- for (const line of fm[1].split("\n")) {
13686
- if (/^plugins:/.test(line)) {
13687
- inPlugins = true;
13688
- continue;
13689
- }
13690
- if (inPlugins) {
13691
- const m = line.match(/^\s+- (.+)/);
13692
- if (m) subs.push(m[1].trim());
13693
- else break;
13694
- }
13695
- }
13696
- return subs;
13697
- }
13698
- function walkPremiumBundles() {
13699
- if (BRAND_NAME === "maxy") return [];
13700
- const stagingRoot = resolve24(PLATFORM_ROOT, "../premium-plugins");
13701
- if (!existsSync24(stagingRoot)) return [];
13702
- let entries;
13703
- try {
13704
- entries = readdirSync7(stagingRoot);
13705
- } catch {
13706
- return [];
13707
- }
13708
- const result = [];
13709
- for (const bundle of entries) {
13710
- const bundleDir = resolve24(stagingRoot, bundle);
13711
- try {
13712
- if (!statSync8(bundleDir).isDirectory()) continue;
13713
- } catch {
13714
- continue;
13715
- }
13716
- const declared = readBundleSubPlugins(join13(bundleDir, "BUNDLE.md"));
13717
- result.push({ bundle, subs: declared.length > 0 ? declared : [bundle] });
13718
- }
13719
- return result;
13720
- }
13721
- function autoDeliverPremiumPlugins() {
13722
- const TAG20 = "[premium-auto-deliver]";
13723
- const bundles = walkPremiumBundles();
13724
- if (bundles.length === 0) return;
13725
- const stagingRoot = resolve24(PLATFORM_ROOT, "../premium-plugins");
13726
- const pluginsDir = resolve24(PLATFORM_ROOT, "plugins");
13727
- for (const { bundle, subs } of bundles) {
13728
- const stagingDir = resolve24(stagingRoot, bundle);
13729
- const bundlePath = join13(stagingDir, "BUNDLE.md");
13730
- const isBundle = existsSync24(bundlePath);
13731
- if (isBundle) {
13732
- let delivered = 0;
13733
- let skipped = 0;
13734
- for (const sub of subs) {
13735
- const target = resolve24(pluginsDir, sub);
13736
- if (existsSync24(resolve24(target, "PLUGIN.md"))) {
13737
- skipped++;
13738
- continue;
13739
- }
13740
- const source = resolve24(stagingDir, "plugins", sub);
13741
- if (!existsSync24(source)) {
13742
- console.log(`${TAG20} ${bundle}/${sub}: source missing in staging, skipping`);
13743
- continue;
13744
- }
13745
- try {
13746
- cpSync(source, target, { recursive: true });
13747
- delivered++;
13748
- } catch (err) {
13749
- console.log(`${TAG20} ${bundle}/${sub}: copy failed: ${err instanceof Error ? err.message : String(err)}`);
13750
- }
13751
- }
13752
- console.log(`${TAG20} ${bundle} (bundle): ${delivered} delivered, ${skipped} already present`);
13753
- } else {
13754
- const target = resolve24(pluginsDir, bundle);
13755
- if (existsSync24(resolve24(target, "PLUGIN.md"))) {
13756
- console.log(`${TAG20} ${bundle}: already present, skipping`);
13757
- } else {
13758
- try {
13759
- cpSync(stagingDir, target, { recursive: true });
13760
- console.log(`${TAG20} ${bundle} (standalone): delivered`);
13761
- } catch (err) {
13762
- console.log(`${TAG20} ${bundle}: copy failed: ${err instanceof Error ? err.message : String(err)}`);
13763
- }
13764
- }
13765
- }
13766
- }
13767
- }
13768
- function reconcileEnabledPlugins(accountDir, config) {
13769
- const TAG20 = "[premium-auto-deliver]";
13770
- if (!accountDir || !config) return;
13771
- const bundles = walkPremiumBundles();
13772
- const pluginsDir = resolve24(PLATFORM_ROOT, "plugins");
13773
- const bundleNames = [];
13774
- const allSubs = [];
13775
- for (const { bundle, subs } of bundles) {
13776
- bundleNames.push(bundle);
13777
- for (const sub of subs) {
13778
- if (!existsSync24(resolve24(pluginsDir, sub, "PLUGIN.md"))) continue;
13779
- allSubs.push(sub);
13780
- }
13781
- }
13782
- const current = Array.isArray(config.enabledPlugins) ? config.enabledPlugins : [];
13783
- const currentSet = new Set(current);
13784
- const added = [];
13785
- for (const sub of allSubs) {
13786
- if (currentSet.has(sub)) continue;
13787
- currentSet.add(sub);
13788
- added.push(sub);
13789
- }
13790
- console.log(`${TAG20} brand=${BRAND_NAME} bundles=[${bundleNames.join(",")}] subs=[${allSubs.join(",")}] stamped=${added.length}`);
13791
- if (added.length === 0) return;
13792
- const merged = [...currentSet];
13793
- const configPath2 = resolve24(accountDir, "account.json");
13794
- try {
13795
- const raw = readFileSync21(configPath2, "utf-8");
13796
- const parsed = JSON.parse(raw);
13797
- parsed.enabledPlugins = merged;
13798
- writeFileSync12(configPath2, JSON.stringify(parsed, null, 2) + "\n");
13799
- config.enabledPlugins = merged;
13800
- } catch (err) {
13801
- console.error(`${TAG20} enabled-stamp write failed: ${err instanceof Error ? err.message : String(err)}`);
13802
- }
13803
- }
13804
-
13805
13641
  // ../lib/entitlement/src/index.ts
13806
13642
  import { createPublicKey, createHash as createHash3, verify as cryptoVerify } from "crypto";
13807
- import { existsSync as existsSync25, readFileSync as readFileSync22, statSync as statSync9 } from "fs";
13808
- import { resolve as resolve25 } from "path";
13643
+ import { existsSync as existsSync24, readFileSync as readFileSync21, statSync as statSync8 } from "fs";
13644
+ import { resolve as resolve24 } from "path";
13809
13645
 
13810
13646
  // ../lib/entitlement/src/canonicalize.ts
13811
13647
  function canonicalize(value) {
@@ -13840,7 +13676,7 @@ var PUBKEY_SHA256 = "8eee6bcb33545fd13b16d3199a5735ca5db5062834c7b49dfe4f23801d9
13840
13676
  var GRACE_DAYS = 7;
13841
13677
  var GRACE_MS = GRACE_DAYS * 24 * 60 * 60 * 1e3;
13842
13678
  function pubkeyPath(brand) {
13843
- return resolve25(brand.platformRoot, "lib", "entitlement", "rubytech-pubkey.pem");
13679
+ return resolve24(brand.platformRoot, "lib", "entitlement", "rubytech-pubkey.pem");
13844
13680
  }
13845
13681
  var memo = null;
13846
13682
  function memoKey(mtimeMs, account) {
@@ -13852,11 +13688,11 @@ function resolveEntitlement(brand, account) {
13852
13688
  if (brand.commercialMode !== true) {
13853
13689
  return logResolved(implicitTrust(account), null);
13854
13690
  }
13855
- const entitlementPath = resolve25(brand.configDir, "entitlement.json");
13856
- if (!existsSync25(entitlementPath)) {
13691
+ const entitlementPath = resolve24(brand.configDir, "entitlement.json");
13692
+ if (!existsSync24(entitlementPath)) {
13857
13693
  return logResolved(anonymousFallback("missing"), { reason: "missing" });
13858
13694
  }
13859
- const stat7 = statSync9(entitlementPath);
13695
+ const stat7 = statSync8(entitlementPath);
13860
13696
  const key = memoKey(stat7.mtimeMs, account);
13861
13697
  if (memo && memo.key === key) {
13862
13698
  return memo.result;
@@ -13868,7 +13704,7 @@ function resolveEntitlement(brand, account) {
13868
13704
  function verifyAndResolve(brand, entitlementPath, account) {
13869
13705
  let pubkeyPem;
13870
13706
  try {
13871
- pubkeyPem = readFileSync22(pubkeyPath(brand), "utf-8");
13707
+ pubkeyPem = readFileSync21(pubkeyPath(brand), "utf-8");
13872
13708
  } catch (err) {
13873
13709
  return logResolved(anonymousFallback("pubkey-missing"), {
13874
13710
  reason: "pubkey-missing"
@@ -13882,7 +13718,7 @@ function verifyAndResolve(brand, entitlementPath, account) {
13882
13718
  }
13883
13719
  let envelope;
13884
13720
  try {
13885
- envelope = JSON.parse(readFileSync22(entitlementPath, "utf-8"));
13721
+ envelope = JSON.parse(readFileSync21(entitlementPath, "utf-8"));
13886
13722
  } catch {
13887
13723
  return logResolved(anonymousFallback("malformed"), { reason: "malformed" });
13888
13724
  }
@@ -14043,14 +13879,14 @@ function clientFrom(c) {
14043
13879
  );
14044
13880
  }
14045
13881
  var PLATFORM_ROOT9 = process.env.MAXY_PLATFORM_ROOT || "";
14046
- var BRAND_JSON_PATH = PLATFORM_ROOT9 ? join14(PLATFORM_ROOT9, "config", "brand.json") : "";
13882
+ var BRAND_JSON_PATH = PLATFORM_ROOT9 ? join13(PLATFORM_ROOT9, "config", "brand.json") : "";
14047
13883
  var BRAND = { productName: "Maxy", hostname: "maxy", configDir: ".maxy", domain: "getmaxy.com" };
14048
- if (BRAND_JSON_PATH && !existsSync26(BRAND_JSON_PATH)) {
13884
+ if (BRAND_JSON_PATH && !existsSync25(BRAND_JSON_PATH)) {
14049
13885
  console.error(`[brand] WARNING: brand.json not found at ${BRAND_JSON_PATH} \u2014 using Maxy defaults`);
14050
13886
  }
14051
- if (BRAND_JSON_PATH && existsSync26(BRAND_JSON_PATH)) {
13887
+ if (BRAND_JSON_PATH && existsSync25(BRAND_JSON_PATH)) {
14052
13888
  try {
14053
- const parsed = JSON.parse(readFileSync23(BRAND_JSON_PATH, "utf-8"));
13889
+ const parsed = JSON.parse(readFileSync22(BRAND_JSON_PATH, "utf-8"));
14054
13890
  BRAND = { ...BRAND, ...parsed };
14055
13891
  } catch (err) {
14056
13892
  console.error(`[brand] Failed to parse brand.json: ${err.message}`);
@@ -14069,11 +13905,11 @@ var brandLoginOpts = {
14069
13905
  bodyFont: BRAND.defaultFonts?.body,
14070
13906
  logoContainsName: !!BRAND.logoContainsName
14071
13907
  };
14072
- var ALIAS_DOMAINS_PATH2 = join14(homedir5(), BRAND.configDir, "alias-domains.json");
13908
+ var ALIAS_DOMAINS_PATH2 = join13(homedir5(), BRAND.configDir, "alias-domains.json");
14073
13909
  function loadAliasDomains() {
14074
13910
  try {
14075
- if (!existsSync26(ALIAS_DOMAINS_PATH2)) return null;
14076
- const parsed = JSON.parse(readFileSync23(ALIAS_DOMAINS_PATH2, "utf-8"));
13911
+ if (!existsSync25(ALIAS_DOMAINS_PATH2)) return null;
13912
+ const parsed = JSON.parse(readFileSync22(ALIAS_DOMAINS_PATH2, "utf-8"));
14077
13913
  if (!Array.isArray(parsed)) {
14078
13914
  console.error("[alias-domains] malformed alias-domains.json \u2014 expected array");
14079
13915
  return null;
@@ -14447,20 +14283,20 @@ app42.get("/agent-assets/:slug/:filename", (c) => {
14447
14283
  console.error(`[agent-assets] no-account slug=${slug} file=${filename}`);
14448
14284
  return c.text("Not found", 404);
14449
14285
  }
14450
- const filePath = resolve26(account.accountDir, "agents", slug, "assets", filename);
14451
- const expectedDir = resolve26(account.accountDir, "agents", slug, "assets");
14286
+ const filePath = resolve25(account.accountDir, "agents", slug, "assets", filename);
14287
+ const expectedDir = resolve25(account.accountDir, "agents", slug, "assets");
14452
14288
  if (!filePath.startsWith(expectedDir + "/")) {
14453
14289
  console.error(`[agent-assets] path-traversal-rejected slug=${slug} file=${filename}`);
14454
14290
  return c.text("Forbidden", 403);
14455
14291
  }
14456
- if (!existsSync26(filePath)) {
14292
+ if (!existsSync25(filePath)) {
14457
14293
  console.error(`[agent-assets] serve slug=${slug} file=${filename} status=404`);
14458
14294
  return c.text("Not found", 404);
14459
14295
  }
14460
14296
  const ext = "." + filename.split(".").pop()?.toLowerCase();
14461
14297
  const contentType = IMAGE_MIME[ext] || "application/octet-stream";
14462
14298
  console.log(`[agent-assets] serve slug=${slug} file=${filename} status=200`);
14463
- const body = readFileSync23(filePath);
14299
+ const body = readFileSync22(filePath);
14464
14300
  return c.body(body, 200, {
14465
14301
  "Content-Type": contentType,
14466
14302
  "Cache-Control": "public, max-age=3600"
@@ -14477,20 +14313,20 @@ app42.get("/generated/:filename", (c) => {
14477
14313
  console.error(`[generated] serve file=${filename} status=404`);
14478
14314
  return c.text("Not found", 404);
14479
14315
  }
14480
- const filePath = resolve26(account.accountDir, "generated", filename);
14481
- const expectedDir = resolve26(account.accountDir, "generated");
14316
+ const filePath = resolve25(account.accountDir, "generated", filename);
14317
+ const expectedDir = resolve25(account.accountDir, "generated");
14482
14318
  if (!filePath.startsWith(expectedDir + "/")) {
14483
14319
  console.error(`[generated] serve file=${filename} status=403`);
14484
14320
  return c.text("Forbidden", 403);
14485
14321
  }
14486
- if (!existsSync26(filePath)) {
14322
+ if (!existsSync25(filePath)) {
14487
14323
  console.error(`[generated] serve file=${filename} status=404`);
14488
14324
  return c.text("Not found", 404);
14489
14325
  }
14490
14326
  const ext = "." + filename.split(".").pop()?.toLowerCase();
14491
14327
  const contentType = IMAGE_MIME[ext] || "application/octet-stream";
14492
14328
  console.log(`[generated] serve file=${filename} status=200`);
14493
- const body = readFileSync23(filePath);
14329
+ const body = readFileSync22(filePath);
14494
14330
  return c.body(body, 200, {
14495
14331
  "Content-Type": contentType,
14496
14332
  "Cache-Control": "public, max-age=86400"
@@ -14500,9 +14336,9 @@ app42.route("/sites", sites_default);
14500
14336
  var htmlCache = /* @__PURE__ */ new Map();
14501
14337
  var brandLogoPath = "/brand/maxy-monochrome.png";
14502
14338
  var brandIconPath = "/brand/maxy-monochrome.png";
14503
- if (BRAND_JSON_PATH && existsSync26(BRAND_JSON_PATH)) {
14339
+ if (BRAND_JSON_PATH && existsSync25(BRAND_JSON_PATH)) {
14504
14340
  try {
14505
- const fullBrand = JSON.parse(readFileSync23(BRAND_JSON_PATH, "utf-8"));
14341
+ const fullBrand = JSON.parse(readFileSync22(BRAND_JSON_PATH, "utf-8"));
14506
14342
  if (fullBrand.assets?.logo) brandLogoPath = `/brand/${fullBrand.assets.logo}`;
14507
14343
  brandIconPath = fullBrand.assets?.icon ? `/brand/${fullBrand.assets.icon}` : brandLogoPath;
14508
14344
  } catch {
@@ -14519,9 +14355,9 @@ var brandScript = `<script>window.__BRAND__=${JSON.stringify({
14519
14355
  function readInstalledVersion() {
14520
14356
  try {
14521
14357
  if (!PLATFORM_ROOT9) return "unknown";
14522
- const versionFile = join14(PLATFORM_ROOT9, "config", `.${BRAND.hostname}-version`);
14523
- if (!existsSync26(versionFile)) return "unknown";
14524
- const content = readFileSync23(versionFile, "utf-8").trim();
14358
+ const versionFile = join13(PLATFORM_ROOT9, "config", `.${BRAND.hostname}-version`);
14359
+ if (!existsSync25(versionFile)) return "unknown";
14360
+ const content = readFileSync22(versionFile, "utf-8").trim();
14525
14361
  return content || "unknown";
14526
14362
  } catch {
14527
14363
  return "unknown";
@@ -14562,7 +14398,7 @@ var clientErrorReporterScript = `<script>
14562
14398
  function cachedHtml(file) {
14563
14399
  let html = htmlCache.get(file);
14564
14400
  if (!html) {
14565
- html = readFileSync23(resolve26(process.cwd(), "public", file), "utf-8");
14401
+ html = readFileSync22(resolve25(process.cwd(), "public", file), "utf-8");
14566
14402
  const productNameEsc = escapeHtml(BRAND.productName);
14567
14403
  html = html.replace(/<title>([^<]*)<\/title>/, (_match, inner) => `<title>${escapeHtml(inner).replace(/Maxy/g, productNameEsc)}</title>`);
14568
14404
  html = html.replace('href="/favicon.ico"', `href="${escapeHtml(brandFaviconPath)}"`);
@@ -14578,26 +14414,26 @@ ${clientErrorReporterScript}
14578
14414
  }
14579
14415
  var brandedHtmlCache = /* @__PURE__ */ new Map();
14580
14416
  function loadBrandingCache(agentSlug) {
14581
- const configDir2 = join14(homedir5(), BRAND.configDir);
14417
+ const configDir2 = join13(homedir5(), BRAND.configDir);
14582
14418
  try {
14583
- const accountJsonPath = join14(configDir2, "account.json");
14584
- if (!existsSync26(accountJsonPath)) return null;
14585
- const account = JSON.parse(readFileSync23(accountJsonPath, "utf-8"));
14419
+ const accountJsonPath = join13(configDir2, "account.json");
14420
+ if (!existsSync25(accountJsonPath)) return null;
14421
+ const account = JSON.parse(readFileSync22(accountJsonPath, "utf-8"));
14586
14422
  const accountId = account.accountId;
14587
14423
  if (!accountId) return null;
14588
- const cachePath = join14(configDir2, "branding-cache", accountId, `${agentSlug}.json`);
14589
- if (!existsSync26(cachePath)) return null;
14590
- return JSON.parse(readFileSync23(cachePath, "utf-8"));
14424
+ const cachePath = join13(configDir2, "branding-cache", accountId, `${agentSlug}.json`);
14425
+ if (!existsSync25(cachePath)) return null;
14426
+ return JSON.parse(readFileSync22(cachePath, "utf-8"));
14591
14427
  } catch {
14592
14428
  return null;
14593
14429
  }
14594
14430
  }
14595
14431
  function resolveDefaultSlug() {
14596
14432
  try {
14597
- const configDir2 = join14(homedir5(), BRAND.configDir);
14598
- const accountJsonPath = join14(configDir2, "account.json");
14599
- if (!existsSync26(accountJsonPath)) return null;
14600
- const account = JSON.parse(readFileSync23(accountJsonPath, "utf-8"));
14433
+ const configDir2 = join13(homedir5(), BRAND.configDir);
14434
+ const accountJsonPath = join13(configDir2, "account.json");
14435
+ if (!existsSync25(accountJsonPath)) return null;
14436
+ const account = JSON.parse(readFileSync22(accountJsonPath, "utf-8"));
14601
14437
  return account.defaultAgent || null;
14602
14438
  } catch {
14603
14439
  return null;
@@ -14670,7 +14506,7 @@ app42.use("/vnc-popout.html", logViewerFetch);
14670
14506
  app42.get("/vnc-popout.html", (c) => {
14671
14507
  let html = htmlCache.get("vnc-popout.html");
14672
14508
  if (!html) {
14673
- html = readFileSync23(resolve26(process.cwd(), "public", "vnc-popout.html"), "utf-8");
14509
+ html = readFileSync22(resolve25(process.cwd(), "public", "vnc-popout.html"), "utf-8");
14674
14510
  const name = escapeHtml(BRAND.productName);
14675
14511
  html = html.replace("<title>Browser \u2014 Maxy</title>", `<title>${name}</title>`);
14676
14512
  html = html.replace("</head>", ` ${brandScript}
@@ -14780,8 +14616,8 @@ try {
14780
14616
  }
14781
14617
  (async () => {
14782
14618
  try {
14783
- if (!existsSync26(USERS_FILE)) return;
14784
- const usersRaw = readFileSync23(USERS_FILE, "utf-8").trim();
14619
+ if (!existsSync25(USERS_FILE)) return;
14620
+ const usersRaw = readFileSync22(USERS_FILE, "utf-8").trim();
14785
14621
  if (!usersRaw) return;
14786
14622
  const users = JSON.parse(usersRaw);
14787
14623
  const userId = users[0]?.userId;
@@ -14907,7 +14743,7 @@ if (bootAccountConfig?.whatsapp) {
14907
14743
  }
14908
14744
  init({
14909
14745
  configDir: configDirForWhatsApp,
14910
- platformRoot: resolve26(process.env.MAXY_PLATFORM_ROOT ?? join14(__dirname, "..")),
14746
+ platformRoot: resolve25(process.env.MAXY_PLATFORM_ROOT ?? join13(__dirname, "..")),
14911
14747
  accountConfig: bootAccountConfig,
14912
14748
  onMessage: async (msg) => {
14913
14749
  try {