@rubytech/create-maxy-code 0.1.311 → 0.1.313

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/graph-style/dist/index.d.ts +5 -2
  3. package/payload/platform/lib/graph-style/dist/index.d.ts.map +1 -1
  4. package/payload/platform/lib/graph-style/dist/index.js +65 -2
  5. package/payload/platform/lib/graph-style/dist/index.js.map +1 -1
  6. package/payload/platform/lib/graph-style/src/__tests__/parity.test.ts +218 -0
  7. package/payload/platform/lib/graph-style/src/index.ts +53 -2
  8. package/payload/platform/plugins/.claude-plugin/marketplace.json +5 -0
  9. package/payload/platform/plugins/admin/hooks/lib/maxy-mcp-plugins.txt +1 -0
  10. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +56 -4
  11. package/payload/platform/plugins/docs/references/admin-ui.md +21 -3
  12. package/payload/platform/plugins/docs/references/quickbooks.md +29 -0
  13. package/payload/platform/plugins/quickbooks/.claude-plugin/plugin.json +21 -0
  14. package/payload/platform/plugins/quickbooks/PLUGIN.md +91 -0
  15. package/payload/platform/plugins/quickbooks/lib/mcp-spawn-tee/index.js +159 -0
  16. package/payload/platform/plugins/quickbooks/lib/mcp-spawn-tee/package.json +3 -0
  17. package/payload/platform/plugins/quickbooks/mcp/dist/index.d.ts +2 -0
  18. package/payload/platform/plugins/quickbooks/mcp/dist/index.d.ts.map +1 -0
  19. package/payload/platform/plugins/quickbooks/mcp/dist/index.js +218 -0
  20. package/payload/platform/plugins/quickbooks/mcp/dist/index.js.map +1 -0
  21. package/payload/platform/plugins/quickbooks/mcp/dist/lib/oauth.d.ts +37 -0
  22. package/payload/platform/plugins/quickbooks/mcp/dist/lib/oauth.d.ts.map +1 -0
  23. package/payload/platform/plugins/quickbooks/mcp/dist/lib/oauth.js +75 -0
  24. package/payload/platform/plugins/quickbooks/mcp/dist/lib/oauth.js.map +1 -0
  25. package/payload/platform/plugins/quickbooks/mcp/dist/lib/qbo-client.d.ts +39 -0
  26. package/payload/platform/plugins/quickbooks/mcp/dist/lib/qbo-client.d.ts.map +1 -0
  27. package/payload/platform/plugins/quickbooks/mcp/dist/lib/qbo-client.js +178 -0
  28. package/payload/platform/plugins/quickbooks/mcp/dist/lib/qbo-client.js.map +1 -0
  29. package/payload/platform/plugins/quickbooks/mcp/dist/lib/secrets.d.ts +36 -0
  30. package/payload/platform/plugins/quickbooks/mcp/dist/lib/secrets.d.ts.map +1 -0
  31. package/payload/platform/plugins/quickbooks/mcp/dist/lib/secrets.js +107 -0
  32. package/payload/platform/plugins/quickbooks/mcp/dist/lib/secrets.js.map +1 -0
  33. package/payload/platform/plugins/quickbooks/mcp/package.json +19 -0
  34. package/payload/platform/plugins/quickbooks/skills/quickbooks/SKILL.md +37 -0
  35. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
  36. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +16 -0
  37. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
  38. package/payload/platform/services/claude-session-manager/dist/reseat-ledger.d.ts +10 -0
  39. package/payload/platform/services/claude-session-manager/dist/reseat-ledger.d.ts.map +1 -1
  40. package/payload/platform/services/claude-session-manager/dist/reseat-ledger.js +62 -53
  41. package/payload/platform/services/claude-session-manager/dist/reseat-ledger.js.map +1 -1
  42. package/payload/platform/services/claude-session-manager/dist/scope-record.d.ts.map +1 -1
  43. package/payload/platform/services/claude-session-manager/dist/scope-record.js +35 -53
  44. package/payload/platform/services/claude-session-manager/dist/scope-record.js.map +1 -1
  45. package/payload/platform/services/claude-session-manager/dist/sidecar-store.d.ts +45 -0
  46. package/payload/platform/services/claude-session-manager/dist/sidecar-store.d.ts.map +1 -0
  47. package/payload/platform/services/claude-session-manager/dist/sidecar-store.js +118 -0
  48. package/payload/platform/services/claude-session-manager/dist/sidecar-store.js.map +1 -0
  49. package/payload/server/{chunk-J6WDAWFJ.js → chunk-Q7EWROVN.js} +4 -0
  50. package/payload/server/maxy-edge.js +1 -1
  51. package/payload/server/public/assets/{AccessGate-ChFLk-rp.js → AccessGate-Byskkf47.js} +1 -1
  52. package/payload/server/public/assets/{AdminLoginScreens-DU6zgbk5.js → AdminLoginScreens-DgwQi3HN.js} +1 -1
  53. package/payload/server/public/assets/AdminShell-DQfL2c_L.js +1 -0
  54. package/payload/server/public/assets/{Checkbox-CQGLKMXu.js → Checkbox-C54JSreC.js} +1 -1
  55. package/payload/server/public/assets/OperatorConversations-DulQyF8c.js +1 -0
  56. package/payload/server/public/assets/{admin-COHPIWdb.js → admin-B25rkI9Q.js} +1 -1
  57. package/payload/server/public/assets/{audio-attachment-mime-DL06xo72.js → audio-attachment-mime-BlwrgPQa.js} +1 -1
  58. package/payload/server/public/assets/{brand-CN7uSSKl.css → brand-TWflEl22.css} +1 -1
  59. package/payload/server/public/assets/{browser-L7N4tAOl.js → browser-C9Z5dLlN.js} +1 -1
  60. package/payload/server/public/assets/chat-CGNWDmid.js +1 -0
  61. package/payload/server/public/assets/data-DCQDh0-Y.js +1 -0
  62. package/payload/server/public/assets/graph-labels-BBtL--_M.js +1 -0
  63. package/payload/server/public/assets/{graph-Cro3-mgY.js → graph-sMzOI71g.js} +2 -2
  64. package/payload/server/public/assets/operator-hI6kJi0I.js +1 -0
  65. package/payload/server/public/assets/page-DbsqlpuX.js +1 -0
  66. package/payload/server/public/assets/{public-CX148JKi.js → public-Cs5N4-Az.js} +1 -1
  67. package/payload/server/public/assets/{public-next-BCItsUbZ.js → public-next-DoGPYX6T.js} +1 -1
  68. package/payload/server/public/assets/{useSelectionMode-BHAAhkDg.js → useSelectionMode-Cs-vtuKI.js} +1 -1
  69. package/payload/server/public/browser.html +6 -6
  70. package/payload/server/public/chat.html +8 -8
  71. package/payload/server/public/data.html +5 -5
  72. package/payload/server/public/graph.html +8 -8
  73. package/payload/server/public/index.html +8 -8
  74. package/payload/server/public/operator.html +10 -10
  75. package/payload/server/public/public-next.html +9 -9
  76. package/payload/server/public/public.html +7 -7
  77. package/payload/server/server.js +1091 -594
  78. package/payload/server/public/assets/AdminShell-BJCYb1v5.js +0 -1
  79. package/payload/server/public/assets/OperatorConversations-CHEQTz20.js +0 -1
  80. package/payload/server/public/assets/chat-B_jYIH9a.js +0 -1
  81. package/payload/server/public/assets/data-BmSTKHR1.js +0 -1
  82. package/payload/server/public/assets/graph-labels-WQQn6JIJ.js +0 -1
  83. package/payload/server/public/assets/operator-B4I25isQ.js +0 -1
  84. package/payload/server/public/assets/page-B-6ZQ4JG.js +0 -1
  85. /package/payload/server/public/assets/{brand-MKGM8WZp.js → brand-CYjs10m-.js} +0 -0
@@ -25,6 +25,16 @@ export interface ReseatChainResult {
25
25
  * Cycle-guarded by a visited set and a hard depth cap.
26
26
  */
27
27
  export declare function resolveReseatChain(sessionsDir: string, sourceSessionId: string, jsonlExists: (sessionId: string) => boolean, maxDepth?: number): ReseatChainResult;
28
+ /**
29
+ * The inverse of resolveReseatChain. Given a fork id whose own JSONL does not
30
+ * exist yet (claude --fork-session flushes the copied history only at the
31
+ * fork's first turn), walk the ledger back to the nearest ancestor whose JSONL
32
+ * exists, so the resolver can serve that source transcript read-only until the
33
+ * fork materialises. Returns the source id, or null when forkSessionId is not a
34
+ * recorded fork or no ancestor has a JSONL. Cycle-guarded by a visited set and
35
+ * depth-capped, mirroring resolveReseatChain.
36
+ */
37
+ export declare function resolveBridgeSource(sessionsDir: string, forkSessionId: string, jsonlExists: (sessionId: string) => boolean, maxDepth?: number): string | null;
28
38
  export interface ReseatReconcileResult {
29
39
  scanned: number;
30
40
  stopped: number;
@@ -1 +1 @@
1
- {"version":3,"file":"reseat-ledger.d.ts","sourceRoot":"","sources":["../src/reseat-ledger.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAKxC,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa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AA;CACf;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,EAC3C,QAAQ,GAAE,MAA+B,GACxC,iBAAiB,CAwBnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,EAC3C,QAAQ,GAAE,MAA+B,GACxC,MAAM,GAAG,IAAI,CAiBf;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,EACtC,IAAI,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC9E,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,EAC3C,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,qBAAqB,CAAC,CAchC"}
@@ -11,75 +11,54 @@
11
11
  // The pid-file regex (^[0-9]+\.json$) and scope-record (\.scope\.json$) never
12
12
  // match <uuid>.reseated.json, so the three sidecars share the dir without
13
13
  // collision.
14
- import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
15
- import { join } from 'node:path';
16
- const RESEAT_FILE_RE = /\.reseated\.json$/;
14
+ //
15
+ // Task 902 the file mechanics (path, atomic write, scan, clear) live in the
16
+ // shared `sidecar-store` helper; this module owns the marker shape, the
17
+ // `[reseat-ledger]` log lines, and the chain/reconcile logic below.
18
+ import { createSidecarStore } from './sidecar-store.js';
17
19
  const RESEAT_CHAIN_MAX_DEPTH = 16;
20
+ const store = createSidecarStore({
21
+ suffix: '.reseated.json',
22
+ validate: (raw) => {
23
+ if (!raw || typeof raw !== 'object')
24
+ return null;
25
+ const r = raw;
26
+ if (typeof r.sourceSessionId === 'string' && typeof r.forkSessionId === 'string' && typeof r.at === 'number') {
27
+ return { sourceSessionId: r.sourceSessionId, forkSessionId: r.forkSessionId, at: r.at };
28
+ }
29
+ return null;
30
+ },
31
+ });
18
32
  export function reseatMarkerPath(sessionsDir, sourceSessionId) {
19
- return join(sessionsDir, `${sourceSessionId}.reseated.json`);
33
+ return store.pathFor(sessionsDir, sourceSessionId);
20
34
  }
21
35
  export function writeReseatMarker(sessionsDir, sourceSessionId, forkSessionId, at, logger) {
22
- mkdirSync(sessionsDir, { recursive: true });
23
- const path = reseatMarkerPath(sessionsDir, sourceSessionId);
24
- const tmp = `${path}.tmp.${process.pid}`;
25
- const body = JSON.stringify({ sourceSessionId, forkSessionId, at });
26
- try {
27
- writeFileSync(tmp, body, 'utf8');
28
- renameSync(tmp, path);
36
+ const res = store.write(sessionsDir, sourceSessionId, { sourceSessionId, forkSessionId, at });
37
+ if (res.ok) {
29
38
  logger(`[reseat-ledger] write source=${sourceSessionId.slice(0, 8)} fork=${forkSessionId.slice(0, 8)}`);
30
39
  }
31
- catch (err) {
32
- try {
33
- if (existsSync(tmp))
34
- unlinkSync(tmp);
35
- }
36
- catch { /* best-effort */ }
40
+ else {
41
+ const err = res.error;
37
42
  logger(`[reseat-ledger] write-failed source=${sourceSessionId.slice(0, 8)} err=${err instanceof Error ? err.message : String(err)}`);
38
43
  }
39
44
  }
40
45
  export function readReseatMarker(sessionsDir, sourceSessionId) {
41
- const path = reseatMarkerPath(sessionsDir, sourceSessionId);
42
- try {
43
- const raw = JSON.parse(readFileSync(path, 'utf8'));
44
- if (typeof raw.sourceSessionId === 'string' && typeof raw.forkSessionId === 'string' && typeof raw.at === 'number') {
45
- return { sourceSessionId: raw.sourceSessionId, forkSessionId: raw.forkSessionId, at: raw.at };
46
- }
47
- return null;
48
- }
49
- catch {
50
- return null;
51
- }
46
+ return store.read(sessionsDir, sourceSessionId);
52
47
  }
53
48
  export function readAllReseatMarkers(sessionsDir, logger) {
54
- let entries;
55
- try {
56
- entries = readdirSync(sessionsDir).filter((n) => RESEAT_FILE_RE.test(n));
57
- }
58
- catch {
59
- return [];
60
- }
61
- const out = [];
62
- for (const name of entries) {
63
- const id = name.replace(RESEAT_FILE_RE, '');
64
- const m = readReseatMarker(sessionsDir, id);
65
- if (m)
66
- out.push(m);
67
- else
68
- logger(`[reseat-ledger] skip-unreadable file=${name}`);
69
- }
70
- return out;
49
+ // A marker file that is unreadable OR fails the shape check is skipped and
50
+ // logged, matching the pre-902 readReseatMarker-returns-null behaviour.
51
+ return store.readAll(sessionsDir, (name) => logger(`[reseat-ledger] skip-unreadable file=${name}`));
71
52
  }
72
53
  export function clearReseatMarker(sessionsDir, sourceSessionId, logger) {
73
- const path = reseatMarkerPath(sessionsDir, sourceSessionId);
74
- try {
75
- if (existsSync(path)) {
76
- unlinkSync(path);
77
- logger(`[reseat-ledger] clear source=${sourceSessionId.slice(0, 8)}`);
78
- }
79
- }
80
- catch (err) {
54
+ const res = store.clear(sessionsDir, sourceSessionId);
55
+ if (!res.ok) {
56
+ const err = res.error;
81
57
  logger(`[reseat-ledger] clear-failed source=${sourceSessionId.slice(0, 8)} err=${err instanceof Error ? err.message : String(err)}`);
82
58
  }
59
+ else if (res.removed) {
60
+ logger(`[reseat-ledger] clear source=${sourceSessionId.slice(0, 8)}`);
61
+ }
83
62
  }
84
63
  /**
85
64
  * Follow source -> fork -> fork2 ... while a marker exists and the next fork's
@@ -114,6 +93,36 @@ export function resolveReseatChain(sessionsDir, sourceSessionId, jsonlExists, ma
114
93
  }
115
94
  return { target, hops, redirected, stale };
116
95
  }
96
+ /**
97
+ * The inverse of resolveReseatChain. Given a fork id whose own JSONL does not
98
+ * exist yet (claude --fork-session flushes the copied history only at the
99
+ * fork's first turn), walk the ledger back to the nearest ancestor whose JSONL
100
+ * exists, so the resolver can serve that source transcript read-only until the
101
+ * fork materialises. Returns the source id, or null when forkSessionId is not a
102
+ * recorded fork or no ancestor has a JSONL. Cycle-guarded by a visited set and
103
+ * depth-capped, mirroring resolveReseatChain.
104
+ */
105
+ export function resolveBridgeSource(sessionsDir, forkSessionId, jsonlExists, maxDepth = RESEAT_CHAIN_MAX_DEPTH) {
106
+ // Markers are keyed by source; build the fork -> source inverse once.
107
+ const sourceOf = new Map();
108
+ for (const m of readAllReseatMarkers(sessionsDir, () => { })) {
109
+ sourceOf.set(m.forkSessionId, m.sourceSessionId);
110
+ }
111
+ const visited = new Set([forkSessionId]);
112
+ let current = forkSessionId;
113
+ for (let depth = 0; depth < maxDepth; depth++) {
114
+ const source = sourceOf.get(current);
115
+ if (source === undefined)
116
+ return null; // not a recorded fork / end of chain
117
+ if (visited.has(source))
118
+ return null; // cycle guard
119
+ visited.add(source);
120
+ if (jsonlExists(source))
121
+ return source; // nearest ancestor with a JSONL
122
+ current = source;
123
+ }
124
+ return null;
125
+ }
117
126
  /**
118
127
  * Scan all markers; stop any source that is currently live and whose fork JSONL
119
128
  * still exists (the fork is the real continuation). If a marked source is live
@@ -1 +1 @@
1
- {"version":3,"file":"reseat-ledger.js","sourceRoot":"","sources":["../src/reseat-ledger.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,2EAA2E;AAC3E,wEAAwE;AACxE,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,kCAAkC;AAClC,EAAE;AACF,mFAAmF;AACnF,8EAA8E;AAC9E,0EAA0E;AAC1E,aAAa;AAEb,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACjH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,MAAM,cAAc,GAA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E,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;CACvB;AAID,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb,IAAI,CAaN;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAyBtF;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAU9F"}
1
+ {"version":3,"file":"scope-record.d.ts","sourceRoot":"","sources":["../src/scope-record.ts"],"names":[],"mappings":"AAoBA,KAAK,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;AAEpC,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;CACvB;AAeD,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb,IAAI,CAQN;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAMtF;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAQ9F"}
@@ -11,71 +11,53 @@
11
11
  // is the same dir boot-seed already scans for pid files; the pid-file name
12
12
  // regex (`^[0-9]+\.json$`) never matches a `<uuid>.scope.json`, so there is no
13
13
  // collision.
14
- import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
15
- import { join } from 'node:path';
16
- const SCOPE_FILE_RE = /\.scope\.json$/;
14
+ //
15
+ // Task 902 the file mechanics (path, atomic write, scan, clear) live in the
16
+ // shared `sidecar-store` helper; this module owns only the record shape and the
17
+ // `[scope-record]` log lines.
18
+ import { createSidecarStore } from './sidecar-store.js';
19
+ const store = createSidecarStore({
20
+ suffix: '.scope.json',
21
+ validate: (raw) => {
22
+ if (!raw || typeof raw !== 'object')
23
+ return null;
24
+ const sid = raw.sessionId;
25
+ const tok = raw.scopeUnitToken;
26
+ if (typeof sid === 'string' && sid.length > 0 && typeof tok === 'string' && tok.length > 0) {
27
+ return { sessionId: sid, scopeUnitToken: tok };
28
+ }
29
+ return null;
30
+ },
31
+ });
17
32
  export function scopeRecordPath(sessionsDir, sessionId) {
18
- return join(sessionsDir, `${sessionId}.scope.json`);
33
+ return store.pathFor(sessionsDir, sessionId);
19
34
  }
20
35
  export function writeScopeRecord(sessionsDir, sessionId, scopeUnitToken, logger) {
21
- mkdirSync(sessionsDir, { recursive: true });
22
- const path = scopeRecordPath(sessionsDir, sessionId);
23
- const tmp = `${path}.tmp.${process.pid}`;
24
- const body = JSON.stringify({ sessionId, scopeUnitToken });
25
- try {
26
- writeFileSync(tmp, body, 'utf8');
27
- renameSync(tmp, path);
36
+ const res = store.write(sessionsDir, sessionId, { sessionId, scopeUnitToken });
37
+ if (res.ok) {
28
38
  logger(`[scope-record] write sessionId=${sessionId.slice(0, 8)} unitToken=${scopeUnitToken}`);
29
39
  }
30
- catch (err) {
31
- try {
32
- if (existsSync(tmp))
33
- unlinkSync(tmp);
34
- }
35
- catch { /* best-effort */ }
40
+ else {
41
+ const err = res.error;
36
42
  logger(`[scope-record] write-failed sessionId=${sessionId.slice(0, 8)} err=${err instanceof Error ? err.message : String(err)}`);
37
43
  }
38
44
  }
39
45
  export function readAllScopeRecords(sessionsDir, logger) {
40
- let entries;
41
- try {
42
- entries = readdirSync(sessionsDir, { withFileTypes: true });
43
- }
44
- catch {
45
- return [];
46
- }
47
- const out = [];
48
- for (const entry of entries) {
49
- if (!entry.isFile() || !SCOPE_FILE_RE.test(entry.name))
50
- continue;
51
- let parsed;
52
- try {
53
- parsed = JSON.parse(readFileSync(join(sessionsDir, entry.name), 'utf8'));
54
- }
55
- catch {
56
- logger(`[scope-record] parse-failed file=${entry.name}`);
57
- continue;
58
- }
59
- if (!parsed || typeof parsed !== 'object')
60
- continue;
61
- const sid = parsed.sessionId;
62
- const tok = parsed.scopeUnitToken;
63
- if (typeof sid === 'string' && sid.length > 0 && typeof tok === 'string' && tok.length > 0) {
64
- out.push({ sessionId: sid, scopeUnitToken: tok });
65
- }
66
- }
67
- return out;
46
+ // Only JSON-unreadable files log; a parsed-but-wrong-shape file is skipped
47
+ // silently, matching the pre-902 inline scan.
48
+ return store.readAll(sessionsDir, (name, reason) => {
49
+ if (reason === 'unreadable')
50
+ logger(`[scope-record] parse-failed file=${name}`);
51
+ });
68
52
  }
69
53
  export function removeScopeRecord(sessionsDir, sessionId, logger) {
70
- const path = scopeRecordPath(sessionsDir, sessionId);
71
- try {
72
- if (existsSync(path)) {
73
- unlinkSync(path);
74
- logger(`[scope-record] remove sessionId=${sessionId.slice(0, 8)}`);
75
- }
76
- }
77
- catch (err) {
54
+ const res = store.clear(sessionsDir, sessionId);
55
+ if (!res.ok) {
56
+ const err = res.error;
78
57
  logger(`[scope-record] remove-failed sessionId=${sessionId.slice(0, 8)} err=${err instanceof Error ? err.message : String(err)}`);
79
58
  }
59
+ else if (res.removed) {
60
+ logger(`[scope-record] remove sessionId=${sessionId.slice(0, 8)}`);
61
+ }
80
62
  }
81
63
  //# sourceMappingURL=scope-record.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scope-record.js","sourceRoot":"","sources":["../src/scope-record.ts"],"names":[],"mappings":"AAAA,0CAA0C;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AC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAClI,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,WAAmB,EAAE,MAAc;IACrE,2EAA2E;IAC3E,8CAA8C;IAC9C,OAAO,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACjD,IAAI,MAAM,KAAK,YAAY;YAAE,MAAM,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;IACjF,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,WAAmB,EAAE,SAAiB,EAAE,MAAc;IACtF,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;IAC/C,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAA;QACrB,MAAM,CAAC,0CAA0C,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACnI,CAAC;SAAM,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QACvB,MAAM,CAAC,mCAAmC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;IACpE,CAAC;AACH,CAAC"}
@@ -0,0 +1,45 @@
1
+ /** Why `readAll` skipped a file that matched the suffix.
2
+ * `'unreadable'` — the file could not be read or did not parse as JSON.
3
+ * `'invalid'` — it parsed but failed the store's `validate`. */
4
+ export type SidecarSkipReason = 'unreadable' | 'invalid';
5
+ export type WriteResult = {
6
+ ok: true;
7
+ } | {
8
+ ok: false;
9
+ error: unknown;
10
+ };
11
+ export type ClearResult = {
12
+ ok: true;
13
+ removed: boolean;
14
+ } | {
15
+ ok: false;
16
+ error: unknown;
17
+ };
18
+ export interface SidecarStore<T> {
19
+ /** `<sessionsDir>/<id><suffix>`. */
20
+ pathFor(sessionsDir: string, id: string): string;
21
+ /** Atomic write of `record` as JSON (no indentation): create the dir, write a
22
+ * `<path>.tmp.<pid>` sibling, then rename it onto the canonical path. On
23
+ * failure the tmp file is removed best-effort and the caught error is
24
+ * returned rather than thrown — the caller owns the success/failure log. */
25
+ write(sessionsDir: string, id: string, record: T): WriteResult;
26
+ /** Read + parse + validate one record. Null when the file is absent,
27
+ * unreadable, not JSON, or fails `validate`. */
28
+ read(sessionsDir: string, id: string): T | null;
29
+ /** Every valid record in `sessionsDir`. Files not matching the suffix are
30
+ * ignored. A matching file that is unreadable/not-JSON fires
31
+ * `onSkip(name, 'unreadable')`; one that parses but fails `validate` fires
32
+ * `onSkip(name, 'invalid')`. A missing directory yields `[]`. */
33
+ readAll(sessionsDir: string, onSkip?: (fileName: string, reason: SidecarSkipReason) => void): T[];
34
+ /** `existsSync` + `unlink`. `{ ok: true, removed: false }` when the file was
35
+ * already absent; `{ ok: false, error }` when the unlink throws. */
36
+ clear(sessionsDir: string, id: string): ClearResult;
37
+ }
38
+ export declare function createSidecarStore<T>(config: {
39
+ /** Filename suffix including the dot(s), e.g. `'.scope.json'`. */
40
+ suffix: string;
41
+ /** Parse-validate one decoded JSON value into a record, or null if it does
42
+ * not match the store's shape. */
43
+ validate: (raw: unknown) => T | null;
44
+ }): SidecarStore<T>;
45
+ //# sourceMappingURL=sidecar-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidecar-store.d.ts","sourceRoot":"","sources":["../src/sidecar-store.ts"],"names":[],"mappings":"AAgBA;;oEAEoE;AACpE,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,SAAS,CAAA;AAExD,MAAM,MAAM,WAAW,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AACtE,MAAM,MAAM,WAAW,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAExF,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,oCAAoC;IACpC,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IAChD;;;iFAG6E;IAC7E,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,WAAW,CAAA;IAC9D;qDACiD;IACjD,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAA;IAC/C;;;sEAGkE;IAClE,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAAG,CAAC,EAAE,CAAA;IACjG;yEACqE;IACrE,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,CAAA;CACpD;AAMD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE;IAC5C,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAA;IACd;uCACmC;IACnC,QAAQ,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,CAAC,GAAG,IAAI,CAAA;CACrC,GAAG,YAAY,CAAC,CAAC,CAAC,CA8FlB"}
@@ -0,0 +1,118 @@
1
+ // Task 902 — the one per-session sidecar store that scope-record and
2
+ // reseat-ledger both build on. Each store keeps a `<sessionsDir>/<id><suffix>`
3
+ // JSON file and shares the same mechanics: a path builder, an atomic
4
+ // tmp-write + rename (best-effort tmp cleanup on failure), a suffix-matched
5
+ // directory scan, and an `existsSync` + `unlink` clear. Before this helper the
6
+ // two stores were near-verbatim copies that had already begun to drift in how
7
+ // they scanned the directory; collapsing them puts any future fix to
8
+ // partial-write handling or tmp-file cleanup in one place.
9
+ //
10
+ // The helper does NO logging. It returns results, and each store's thin
11
+ // wrapper owns its own log lines — the two stores log with different prefixes
12
+ // and different per-record detail, so unifying the messages here would change
13
+ // operator-greppable output. The wrappers keep their exact strings.
14
+ import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
15
+ import { join } from 'node:path';
16
+ function escapeRegExp(s) {
17
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
18
+ }
19
+ export function createSidecarStore(config) {
20
+ const { suffix, validate } = config;
21
+ const suffixRe = new RegExp(`${escapeRegExp(suffix)}$`);
22
+ function pathFor(sessionsDir, id) {
23
+ return join(sessionsDir, `${id}${suffix}`);
24
+ }
25
+ function write(sessionsDir, id, record) {
26
+ mkdirSync(sessionsDir, { recursive: true });
27
+ const path = pathFor(sessionsDir, id);
28
+ const tmp = `${path}.tmp.${process.pid}`;
29
+ try {
30
+ writeFileSync(tmp, JSON.stringify(record), 'utf8');
31
+ renameSync(tmp, path);
32
+ return { ok: true };
33
+ }
34
+ catch (error) {
35
+ try {
36
+ if (existsSync(tmp))
37
+ unlinkSync(tmp);
38
+ }
39
+ catch { /* best-effort */ }
40
+ return { ok: false, error };
41
+ }
42
+ }
43
+ function readFileAt(path) {
44
+ let raw;
45
+ try {
46
+ raw = readFileSync(path, 'utf8');
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ try {
52
+ return validate(JSON.parse(raw));
53
+ }
54
+ catch {
55
+ return null;
56
+ }
57
+ }
58
+ function read(sessionsDir, id) {
59
+ return readFileAt(pathFor(sessionsDir, id));
60
+ }
61
+ function readAll(sessionsDir, onSkip) {
62
+ let names;
63
+ try {
64
+ // `withFileTypes` + `isFile` so a sub-directory whose name happens to
65
+ // match the suffix is ignored before any read is attempted — never read
66
+ // as a record, never reported via onSkip.
67
+ names = readdirSync(sessionsDir, { withFileTypes: true })
68
+ .filter((entry) => entry.isFile())
69
+ .map((entry) => entry.name);
70
+ }
71
+ catch {
72
+ return [];
73
+ }
74
+ const out = [];
75
+ for (const name of names) {
76
+ if (!suffixRe.test(name))
77
+ continue;
78
+ const path = join(sessionsDir, name);
79
+ let raw;
80
+ try {
81
+ raw = readFileSync(path, 'utf8');
82
+ }
83
+ catch {
84
+ onSkip?.(name, 'unreadable');
85
+ continue;
86
+ }
87
+ let parsed;
88
+ try {
89
+ parsed = JSON.parse(raw);
90
+ }
91
+ catch {
92
+ onSkip?.(name, 'unreadable');
93
+ continue;
94
+ }
95
+ const record = validate(parsed);
96
+ if (record)
97
+ out.push(record);
98
+ else
99
+ onSkip?.(name, 'invalid');
100
+ }
101
+ return out;
102
+ }
103
+ function clear(sessionsDir, id) {
104
+ const path = pathFor(sessionsDir, id);
105
+ try {
106
+ if (existsSync(path)) {
107
+ unlinkSync(path);
108
+ return { ok: true, removed: true };
109
+ }
110
+ return { ok: true, removed: false };
111
+ }
112
+ catch (error) {
113
+ return { ok: false, error };
114
+ }
115
+ }
116
+ return { pathFor, write, read, readAll, clear };
117
+ }
118
+ //# sourceMappingURL=sidecar-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidecar-store.js","sourceRoot":"","sources":["../src/sidecar-store.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,+EAA+E;AAC/E,qEAAqE;AACrE,4EAA4E;AAC5E,+EAA+E;AAC/E,8EAA8E;AAC9E,qEAAqE;AACrE,2DAA2D;AAC3D,EAAE;AACF,wEAAwE;AACxE,8EAA8E;AAC9E,8EAA8E;AAC9E,oEAAoE;AACpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa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  "/api/health",
3551
3551
  "/api/group/",
3552
3552
  "/api/telegram/",
3553
+ // QuickBooks OAuth consent callback. Intuit redirects the operator's browser
3554
+ // here with no admin cookie; the route authenticates by validating the OAuth
3555
+ // `state` nonce, not the remote-auth gate (same model as /api/telegram/).
3556
+ "/api/quickbooks/",
3553
3557
  "/assets/",
3554
3558
  "/brand/",
3555
3559
  "/agent-assets/",
@@ -16,7 +16,7 @@ import {
16
16
  sanitizeClientCorrId,
17
17
  vncLog,
18
18
  websockifyLog
19
- } from "./chunk-J6WDAWFJ.js";
19
+ } from "./chunk-Q7EWROVN.js";
20
20
  import "./chunk-PFF6I7KP.js";
21
21
 
22
22
  // server/edge.ts
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{o as t,u as n}from"./brand-MKGM8WZp.js";import{r}from"./useSelectionMode-BHAAhkDg.js";var i=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar,audio/ogg,audio/opus,audio/mp4,audio/mpeg,audio/webm,audio/wav,.opus,.ogg,.m4a,.mp3,.wav,.webm`,a=new Set(i.split(`,`).filter(e=>!e.startsWith(`.`))),o=50*1024*1024,s=typeof window<`u`&&/^(localhost|127\.0\.0\.1|[a-z0-9-]+\.local)(:|$)/.test(window.location.hostname);function c(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function l(){let e=window.location.pathname;if(e.startsWith(`/g/`))return;let t=e.match(/^\/([a-z][a-z0-9-]{2,49})$/);return t?t[1]:void 0}function u(){let e=window.location.pathname.match(/^\/g\/([a-z0-9][a-z0-9-]{0,49})$/);return e?e[1]:void 0}var d=e(n(),1);function f(){let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(`loading`),[o,f]=(0,d.useState)(``),[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(null),x=(0,d.useMemo)(()=>l(),[]),S=(0,d.useMemo)(()=>u(),[]),[C,w]=(0,d.useState)(null),T=(0,d.useRef)(x||``),E=(0,d.useRef)(null),D=(0,d.useRef)(null),O=(0,d.useRef)(!1),k=(0,d.useRef)(null),[A,j]=(0,d.useState)(`request-link`),[M,N]=(0,d.useState)(null),P=(0,d.useRef)(null),F=(0,d.useRef)(null);(0,d.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(F.current=e)}catch{}},[]);let I=(0,d.useCallback)(e=>{E.current=e,t(e);try{sessionStorage.setItem(`maxy_session`,e)}catch{}a(`chat`)},[]),L=(0,d.useCallback)(()=>{E.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}t(null),a(`auth-required`),j(`request-link`)},[]),R=(0,d.useCallback)(async e=>{j(`verifying`);try{let t=T.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})});if(window.history.replaceState({},``,window.location.pathname),n.ok){let e=await n.json().catch(()=>({}));return e?.displayName&&N({displayName:e.displayName,contactValue:``,expiresAt:null,status:`active`}),!0}return j(`verify-failed`),!1}catch{return j(`verify-failed`),!1}},[]),z=(0,d.useCallback)(async()=>{if(E.current)return E.current;if(D.current)return D.current;let e=(async()=>{try{let e=F.current,n=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:c(),...x?{agent:x}:{},...S?{group_slug:S}:{},...e?{session_key:e}:{}})});if(!n.ok){let e=await n.json().catch(()=>({error:``}));return s&&console.error(`[session] POST /api/session failed: ${n.status} ${n.statusText}`,e),n.status===404?r(e.error||`Agent not found`):n.status===503&&r(e.error||`Service unavailable`),null}let i=await n.json();if(i.auth_required){i.agent_id&&(T.current=i.agent_id),f(i.displayName||``),i.agentImage&&m(i.agentImage),i.agentImageShape&&g(i.agentImageShape),i.showAgentName&&v(i.showAgentName),i.branding&&b(i.branding),a(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?await R(e)&&window.location.reload():j(`request-link`),null}E.current=i.session_key,t(i.session_key),i.displayName&&f(i.displayName),i.agentImage&&m(i.agentImage),i.agentImageShape&&g(i.agentImageShape),i.showAgentName&&v(i.showAgentName),i.branding&&b(i.branding),a(`chat`),i.resumed&&i.messages&&(O.current=!0,k.current=i.messages),i.group&&w({groupSlug:i.groupSlug,groupName:i.groupName,participants:i.participants??[]});try{sessionStorage.setItem(`maxy_session`,i.session_key)}catch{}return i.session_key}catch(e){return s&&console.error(`[session] fetch /api/session threw:`,e),r(`Unable to connect. Please check your connection and try again.`),null}finally{D.current=null}})();return D.current=e,e},[x,S,R]);return{sessionId:e,cacheKeyRef:E,sessionError:n,pageState:i,setPageState:a,agentDisplayName:o,agentImage:p,agentImageShape:h,showAgentName:_,agentSlug:x,branding:y,resolvedSlugRef:T,ensureSession:z,startNewSession:(0,d.useCallback)(async()=>{E.current=null,D.current=null,F.current=null,O.current=!1,k.current=null,t(null),r(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}await z()},[z]),enterChat:I,enterGate:L,resumedRef:O,resumeMessagesRef:k,gateState:A,setGateState:j,grantInfo:M,setGrantInfo:N,gateCacheKeyRef:P,groupContext:C,groupSlug:S}}var p=t();function m({gateState:e,setGateState:t,grantInfo:n,resolvedSlugRef:i}){let[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(null);async function f(e){e.preventDefault();let n=a.trim().toLowerCase();if(!n){u(`Enter the email you were invited on.`);return}c(!0),u(null);try{let e=await fetch(`/api/access/request-magic-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contactValue:n,agentSlug:i.current})});if(e.status===429){u((await e.json().catch(()=>({})))?.error||`Too many requests. Try again later.`);return}t(`request-sent`)}catch{u(`Could not reach the server. Check your connection and try again.`)}finally{c(!1)}}return(0,p.jsxs)(`div`,{className:`access-gate`,children:[e===`verifying`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Verifying your link…`}),(0,p.jsx)(`p`,{children:`This takes a moment.`})]}),e===`verify-failed`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`That link did not work`}),(0,p.jsx)(`p`,{children:`It may have expired, already been used, or been for a different agent. You can request a fresh one below.`}),(0,p.jsx)(r,{onClick:()=>{t(`request-link`),u(null)},children:`Request a new link`})]}),e===`request-link`&&(0,p.jsxs)(`form`,{className:`access-gate-form`,onSubmit:f,children:[(0,p.jsx)(`h2`,{children:n?.displayName?`Welcome back, ${n.displayName}`:`Sign in`}),(0,p.jsx)(`p`,{children:`Enter the email you were invited on and we will send you a fresh link.`}),(0,p.jsx)(`label`,{htmlFor:`access-email`,children:`Email`}),(0,p.jsx)(`input`,{id:`access-email`,type:`email`,inputMode:`email`,autoComplete:`email`,value:a,onChange:e=>o(e.target.value),disabled:s}),l&&(0,p.jsx)(`p`,{className:`access-gate-error`,children:l}),(0,p.jsx)(r,{type:`submit`,disabled:s||!a.trim(),children:s?`Sending…`:`Send me a link`})]}),e===`request-sent`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Check your email`}),(0,p.jsx)(`p`,{children:`If that address is on the invite list, a fresh link is on the way. It expires in 15 minutes.`}),(0,p.jsx)(r,{onClick:()=>{t(`request-link`),o(``),u(null)},children:`Try a different email`})]})]})}export{a,o as i,f as n,s as o,i as r,m as t};
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{o as t,u as n}from"./brand-CYjs10m-.js";import{r}from"./useSelectionMode-Cs-vtuKI.js";var i=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar,audio/ogg,audio/opus,audio/mp4,audio/mpeg,audio/webm,audio/wav,.opus,.ogg,.m4a,.mp3,.wav,.webm`,a=new Set(i.split(`,`).filter(e=>!e.startsWith(`.`))),o=50*1024*1024,s=typeof window<`u`&&/^(localhost|127\.0\.0\.1|[a-z0-9-]+\.local)(:|$)/.test(window.location.hostname);function c(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function l(){let e=window.location.pathname;if(e.startsWith(`/g/`))return;let t=e.match(/^\/([a-z][a-z0-9-]{2,49})$/);return t?t[1]:void 0}function u(){let e=window.location.pathname.match(/^\/g\/([a-z0-9][a-z0-9-]{0,49})$/);return e?e[1]:void 0}var d=e(n(),1);function f(){let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(`loading`),[o,f]=(0,d.useState)(``),[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(null),x=(0,d.useMemo)(()=>l(),[]),S=(0,d.useMemo)(()=>u(),[]),[C,w]=(0,d.useState)(null),T=(0,d.useRef)(x||``),E=(0,d.useRef)(null),D=(0,d.useRef)(null),O=(0,d.useRef)(!1),k=(0,d.useRef)(null),[A,j]=(0,d.useState)(`request-link`),[M,N]=(0,d.useState)(null),P=(0,d.useRef)(null),F=(0,d.useRef)(null);(0,d.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(F.current=e)}catch{}},[]);let I=(0,d.useCallback)(e=>{E.current=e,t(e);try{sessionStorage.setItem(`maxy_session`,e)}catch{}a(`chat`)},[]),L=(0,d.useCallback)(()=>{E.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}t(null),a(`auth-required`),j(`request-link`)},[]),R=(0,d.useCallback)(async e=>{j(`verifying`);try{let t=T.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})});if(window.history.replaceState({},``,window.location.pathname),n.ok){let e=await n.json().catch(()=>({}));return e?.displayName&&N({displayName:e.displayName,contactValue:``,expiresAt:null,status:`active`}),!0}return j(`verify-failed`),!1}catch{return j(`verify-failed`),!1}},[]),z=(0,d.useCallback)(async()=>{if(E.current)return E.current;if(D.current)return D.current;let e=(async()=>{try{let e=F.current,n=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:c(),...x?{agent:x}:{},...S?{group_slug:S}:{},...e?{session_key:e}:{}})});if(!n.ok){let e=await n.json().catch(()=>({error:``}));return s&&console.error(`[session] POST /api/session failed: ${n.status} ${n.statusText}`,e),n.status===404?r(e.error||`Agent not found`):n.status===503&&r(e.error||`Service unavailable`),null}let i=await n.json();if(i.auth_required){i.agent_id&&(T.current=i.agent_id),f(i.displayName||``),i.agentImage&&m(i.agentImage),i.agentImageShape&&g(i.agentImageShape),i.showAgentName&&v(i.showAgentName),i.branding&&b(i.branding),a(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?await R(e)&&window.location.reload():j(`request-link`),null}E.current=i.session_key,t(i.session_key),i.displayName&&f(i.displayName),i.agentImage&&m(i.agentImage),i.agentImageShape&&g(i.agentImageShape),i.showAgentName&&v(i.showAgentName),i.branding&&b(i.branding),a(`chat`),i.resumed&&i.messages&&(O.current=!0,k.current=i.messages),i.group&&w({groupSlug:i.groupSlug,groupName:i.groupName,participants:i.participants??[]});try{sessionStorage.setItem(`maxy_session`,i.session_key)}catch{}return i.session_key}catch(e){return s&&console.error(`[session] fetch /api/session threw:`,e),r(`Unable to connect. Please check your connection and try again.`),null}finally{D.current=null}})();return D.current=e,e},[x,S,R]);return{sessionId:e,cacheKeyRef:E,sessionError:n,pageState:i,setPageState:a,agentDisplayName:o,agentImage:p,agentImageShape:h,showAgentName:_,agentSlug:x,branding:y,resolvedSlugRef:T,ensureSession:z,startNewSession:(0,d.useCallback)(async()=>{E.current=null,D.current=null,F.current=null,O.current=!1,k.current=null,t(null),r(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}await z()},[z]),enterChat:I,enterGate:L,resumedRef:O,resumeMessagesRef:k,gateState:A,setGateState:j,grantInfo:M,setGrantInfo:N,gateCacheKeyRef:P,groupContext:C,groupSlug:S}}var p=t();function m({gateState:e,setGateState:t,grantInfo:n,resolvedSlugRef:i}){let[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(null);async function f(e){e.preventDefault();let n=a.trim().toLowerCase();if(!n){u(`Enter the email you were invited on.`);return}c(!0),u(null);try{let e=await fetch(`/api/access/request-magic-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contactValue:n,agentSlug:i.current})});if(e.status===429){u((await e.json().catch(()=>({})))?.error||`Too many requests. Try again later.`);return}t(`request-sent`)}catch{u(`Could not reach the server. Check your connection and try again.`)}finally{c(!1)}}return(0,p.jsxs)(`div`,{className:`access-gate`,children:[e===`verifying`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Verifying your link…`}),(0,p.jsx)(`p`,{children:`This takes a moment.`})]}),e===`verify-failed`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`That link did not work`}),(0,p.jsx)(`p`,{children:`It may have expired, already been used, or been for a different agent. You can request a fresh one below.`}),(0,p.jsx)(r,{onClick:()=>{t(`request-link`),u(null)},children:`Request a new link`})]}),e===`request-link`&&(0,p.jsxs)(`form`,{className:`access-gate-form`,onSubmit:f,children:[(0,p.jsx)(`h2`,{children:n?.displayName?`Welcome back, ${n.displayName}`:`Sign in`}),(0,p.jsx)(`p`,{children:`Enter the email you were invited on and we will send you a fresh link.`}),(0,p.jsx)(`label`,{htmlFor:`access-email`,children:`Email`}),(0,p.jsx)(`input`,{id:`access-email`,type:`email`,inputMode:`email`,autoComplete:`email`,value:a,onChange:e=>o(e.target.value),disabled:s}),l&&(0,p.jsx)(`p`,{className:`access-gate-error`,children:l}),(0,p.jsx)(r,{type:`submit`,disabled:s||!a.trim(),children:s?`Sending…`:`Send me a link`})]}),e===`request-sent`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Check your email`}),(0,p.jsx)(`p`,{children:`If that address is on the invite list, a fresh link is on the way. It expires in 15 minutes.`}),(0,p.jsx)(r,{onClick:()=>{t(`request-link`),o(``),u(null)},children:`Try a different email`})]})]})}export{a,o as i,f as n,s as o,i as r,m as t};