@rubytech/create-maxy 1.0.770 → 1.0.772

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.
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/admin-CaXX8wc3.js"></script>
8
+ <script type="module" crossorigin src="/assets/admin-CFttroHB.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DeNudFNA.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-qlgyTAkD.js">
@@ -47,7 +47,7 @@ import {
47
47
  vncLog,
48
48
  waitForExit,
49
49
  writeChromiumWrapper
50
- } from "./chunk-IO2WQEY4.js";
50
+ } from "./chunk-57S5JC7G.js";
51
51
  import {
52
52
  ACCOUNTS_DIR,
53
53
  GREETING_DIRECTIVE,
@@ -87,6 +87,7 @@ import {
87
87
  interruptClient,
88
88
  listAdminSessions,
89
89
  listAdminSessionsInProgress,
90
+ loadAdminUserName,
90
91
  loadOnboardingStep,
91
92
  preConversationLogStream,
92
93
  preflushStreamLogKey,
@@ -107,7 +108,7 @@ import {
107
108
  validateSession,
108
109
  verifyAndGetConversationUpdatedAt,
109
110
  verifyConversationOwnership
110
- } from "./chunk-TKYZ7AEB.js";
111
+ } from "./chunk-XHFMXKXI.js";
111
112
 
112
113
  // ../lib/graph-trash/dist/index.js
113
114
  var require_dist = __commonJS({
@@ -7444,11 +7445,17 @@ app8.post("/set-pin", async (c) => {
7444
7445
  return c.json({ error: "PIN must be at least 4 characters." }, 400);
7445
7446
  }
7446
7447
  const hash = hashPin(body.pin);
7447
- const userId = randomUUID7();
7448
- mkdirSync6(dirname5(USERS_FILE), { recursive: true });
7449
- writeFileSync7(USERS_FILE, JSON.stringify([{ userId, name: "Owner", pin: hash }]), { mode: 384 });
7450
- console.log(`[set-pin] created users.json: userId=${userId.slice(0, 8)}\u2026 hash=${hash.slice(0, 8)}\u2026`);
7451
7448
  const account = resolveAccount();
7449
+ const existingOwnerUserId = account?.config.admins?.find((a) => a.role === "owner")?.userId;
7450
+ const userId = existingOwnerUserId ?? randomUUID7();
7451
+ if (existingOwnerUserId) {
7452
+ console.log(`[set-pin] reusing existing owner userId=${userId.slice(0, 8)}\u2026 (change-PIN preserves identity)`);
7453
+ } else {
7454
+ console.log(`[set-pin] minted new userId=${userId.slice(0, 8)}\u2026 (first-time install)`);
7455
+ }
7456
+ mkdirSync6(dirname5(USERS_FILE), { recursive: true });
7457
+ writeFileSync7(USERS_FILE, JSON.stringify([{ userId, pin: hash }]), { mode: 384 });
7458
+ console.log(`[set-pin] wrote users.json: userId=${userId.slice(0, 8)}\u2026 hash=${hash.slice(0, 8)}\u2026`);
7452
7459
  if (account) {
7453
7460
  try {
7454
7461
  const config = JSON.parse(readFileSync10(`${account.accountDir}/account.json`, "utf-8"));
@@ -7706,8 +7713,9 @@ app9.post("/", async (c) => {
7706
7713
  var client_error_default = app9;
7707
7714
 
7708
7715
  // server/routes/admin/session.ts
7709
- import { readFileSync as readFileSync11, existsSync as existsSync13 } from "fs";
7716
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, existsSync as existsSync13 } from "fs";
7710
7717
  import { createHash as createHash2 } from "crypto";
7718
+ var deprecationLogged = /* @__PURE__ */ new Set();
7711
7719
  function hashPin2(pin) {
7712
7720
  return createHash2("sha256").update(pin).digest("hex");
7713
7721
  }
@@ -7717,6 +7725,33 @@ function readUsersFile2() {
7717
7725
  if (!raw) return [];
7718
7726
  return JSON.parse(raw);
7719
7727
  }
7728
+ function stripLegacyNameField(users) {
7729
+ const dirty = users.some((u) => "name" in u && u.name !== void 0);
7730
+ if (!dirty) return;
7731
+ for (const u of users) {
7732
+ if ("name" in u && u.name !== void 0) {
7733
+ if (!deprecationLogged.has(u.userId)) {
7734
+ console.log(`[admin-identity] users-json-name-field-deprecated userId=${u.userId.slice(0, 8)}`);
7735
+ deprecationLogged.add(u.userId);
7736
+ }
7737
+ delete u.name;
7738
+ }
7739
+ }
7740
+ try {
7741
+ writeFileSync8(USERS_FILE, JSON.stringify(users), { mode: 384 });
7742
+ } catch (err) {
7743
+ console.error(`[admin-identity] users-json strip failed: ${err instanceof Error ? err.message : String(err)}`);
7744
+ }
7745
+ }
7746
+ async function resolveUserName(accountId, userId) {
7747
+ const result = await loadAdminUserName(accountId, userId);
7748
+ if (result.source === "neo4j") {
7749
+ console.log(`[admin-identity] userName-source=neo4j userId=${userId.slice(0, 8)} givenName=${result.givenName} familyName=${result.familyName ?? "null"} joined=${result.joined}`);
7750
+ return result.joined;
7751
+ }
7752
+ console.log(`[admin-identity] userName-source=fallback reason=${result.reason} userId=${userId.slice(0, 8)} accountId=${accountId.slice(0, 8)}`);
7753
+ return result.reason === "neo4j-unreachable" ? "Owner" : void 0;
7754
+ }
7720
7755
  async function createAdminSession(accountId, thinkingView, userId, userName, role) {
7721
7756
  const account = resolveAccount();
7722
7757
  const effectiveThinkingView = thinkingView ?? account?.config.thinkingView ?? "default";
@@ -7776,11 +7811,20 @@ app10.get("/", async (c) => {
7776
7811
  }
7777
7812
  const role = getRoleForSession(sessionKey);
7778
7813
  console.log(`[admin-session] role=${role ?? "null"} sessionKey=${sessionKey.slice(0, 8)} phase=restore`);
7814
+ const restoredUserId = getUserIdForSession(sessionKey);
7815
+ let restoredUserName = getUserNameForSession(sessionKey);
7816
+ if (restoredUserId) {
7817
+ const resolved = await resolveUserName(accountId, restoredUserId);
7818
+ restoredUserName = resolved;
7819
+ if (resolved !== void 0) {
7820
+ registerSession(sessionKey, "admin", accountId, void 0, restoredUserId, resolved, role ?? void 0);
7821
+ }
7822
+ }
7779
7823
  return c.json({
7780
7824
  session_key: sessionKey,
7781
7825
  agent_id: "admin",
7782
- userId: getUserIdForSession(sessionKey),
7783
- userName: getUserNameForSession(sessionKey),
7826
+ userId: restoredUserId,
7827
+ userName: restoredUserName,
7784
7828
  role: role ?? null,
7785
7829
  thinkingView,
7786
7830
  onboardingComplete,
@@ -7812,7 +7856,8 @@ app10.post("/", async (c) => {
7812
7856
  console.log(`[session] PIN auth failed: no matching user`);
7813
7857
  return c.json({ error: "Invalid PIN" }, 401);
7814
7858
  }
7815
- const { userId, name: userName } = matchedUser;
7859
+ stripLegacyNameField(users);
7860
+ const { userId } = matchedUser;
7816
7861
  const accounts = resolveUserAccounts(userId);
7817
7862
  if (accounts.length === 0) {
7818
7863
  console.log(`[session] user has no accounts: userId=${userId}`);
@@ -7831,13 +7876,14 @@ app10.post("/", async (c) => {
7831
7876
  return { accountId: a.accountId, businessName, role: a.role };
7832
7877
  })
7833
7878
  );
7834
- return c.json({ accounts: accountList, userId, userName });
7879
+ return c.json({ accounts: accountList, userId });
7835
7880
  }
7836
7881
  const selected = body.accountId ? accounts.find((a) => a.accountId === body.accountId) : accounts[0];
7837
7882
  if (!selected) {
7838
7883
  console.log(`[session] account selection invalid: userId=${userId} requested=${body.accountId}`);
7839
7884
  return c.json({ error: "Invalid account selection." }, 403);
7840
7885
  }
7886
+ const userName = await resolveUserName(selected.accountId, userId);
7841
7887
  const payload = await createAdminSession(selected.accountId, selected.config.thinkingView, userId, userName, selected.role);
7842
7888
  return c.json(payload);
7843
7889
  });
@@ -8135,7 +8181,7 @@ var app11 = new Hono();
8135
8181
  app11.post("/cancel", requireAdminSession, async (c) => {
8136
8182
  const session_key = c.var.sessionKey;
8137
8183
  try {
8138
- const { interruptClient: interruptClient2 } = await import("./client-pool-CX2MFW75.js");
8184
+ const { interruptClient: interruptClient2 } = await import("./client-pool-J4ZHJ6Z3.js");
8139
8185
  await interruptClient2(session_key);
8140
8186
  return c.json({ ok: true });
8141
8187
  } catch (err) {
@@ -9340,7 +9386,7 @@ function isValidDomain(value) {
9340
9386
  }
9341
9387
 
9342
9388
  // app/lib/alias-domains.ts
9343
- import { existsSync as existsSync18, mkdirSync as mkdirSync8, readFileSync as readFileSync14, writeFileSync as writeFileSync8 } from "fs";
9389
+ import { existsSync as existsSync18, mkdirSync as mkdirSync8, readFileSync as readFileSync14, writeFileSync as writeFileSync9 } from "fs";
9344
9390
  import { dirname as dirname7 } from "path";
9345
9391
  import { resolve as resolve16 } from "path";
9346
9392
  var ALIAS_DOMAINS_PATH = resolve16(MAXY_DIR, "alias-domains.json");
@@ -9359,7 +9405,7 @@ function addAliasDomain(hostname2) {
9359
9405
  if (existing.has(hostname2)) return;
9360
9406
  existing.add(hostname2);
9361
9407
  mkdirSync8(dirname7(ALIAS_DOMAINS_PATH), { recursive: true });
9362
- writeFileSync8(ALIAS_DOMAINS_PATH, JSON.stringify([...existing], null, 2) + "\n", "utf-8");
9408
+ writeFileSync9(ALIAS_DOMAINS_PATH, JSON.stringify([...existing], null, 2) + "\n", "utf-8");
9363
9409
  }
9364
9410
 
9365
9411
  // server/routes/admin/cloudflare.ts