@rubytech/create-maxy-code 0.1.477 → 0.1.478
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.
- package/package.json +1 -1
- package/payload/platform/docs/superpowers/plans/2026-07-20-task-1704-data-portal-standing-audit.md +673 -0
- package/payload/platform/docs/superpowers/specs/2026-07-20-task-1704-data-portal-standing-audit-design.md +177 -0
- package/payload/platform/docs/superpowers/specs/2026-07-20-task-1820-cpu-triage-admin-tools-design.md +97 -0
- package/payload/platform/lib/storage-broker/dist/__tests__/audit.test.js +44 -0
- package/payload/platform/lib/storage-broker/dist/__tests__/audit.test.js.map +1 -1
- package/payload/platform/lib/storage-broker/dist/audit.d.ts +56 -0
- package/payload/platform/lib/storage-broker/dist/audit.d.ts.map +1 -1
- package/payload/platform/lib/storage-broker/dist/audit.js +34 -0
- package/payload/platform/lib/storage-broker/dist/audit.js.map +1 -1
- package/payload/platform/lib/storage-broker/src/__tests__/audit.test.ts +70 -1
- package/payload/platform/lib/storage-broker/src/audit.ts +111 -0
- package/payload/platform/plugins/admin/.claude-plugin/plugin.json +1 -1
- package/payload/platform/plugins/admin/PLUGIN.md +7 -1
- package/payload/platform/plugins/admin/mcp/dist/index.js +72 -0
- package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/admin/mcp/dist/tools/cpu-triage.d.ts +94 -0
- package/payload/platform/plugins/admin/mcp/dist/tools/cpu-triage.d.ts.map +1 -0
- package/payload/platform/plugins/admin/mcp/dist/tools/cpu-triage.js +229 -0
- package/payload/platform/plugins/admin/mcp/dist/tools/cpu-triage.js.map +1 -0
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +2 -2
- package/payload/platform/plugins/docs/references/admin-ui.md +1 -1
- package/payload/platform/plugins/email/PLUGIN.md +2 -1
- package/payload/platform/plugins/email/mcp/dist/__tests__/confirm-sent-copy.test.d.ts +2 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/confirm-sent-copy.test.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/confirm-sent-copy.test.js +92 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/confirm-sent-copy.test.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/email-draft-send.test.js +112 -12
- package/payload/platform/plugins/email/mcp/dist/__tests__/email-draft-send.test.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/__tests__/email-send-sent-copy.test.d.ts +2 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/email-send-sent-copy.test.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/email-send-sent-copy.test.js +54 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/email-send-sent-copy.test.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/imap-drafts.test.js +170 -1
- package/payload/platform/plugins/email/mcp/dist/__tests__/imap-drafts.test.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-copy-note.test.d.ts +2 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-copy-note.test.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-copy-note.test.js +86 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-copy-note.test.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-copy-sweep.test.d.ts +2 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-copy-sweep.test.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-copy-sweep.test.js +164 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-copy-sweep.test.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-ledger.test.d.ts +2 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-ledger.test.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-ledger.test.js +82 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/sent-ledger.test.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/lib/imap.d.ts +95 -0
- package/payload/platform/plugins/email/mcp/dist/lib/imap.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/imap.js +223 -0
- package/payload/platform/plugins/email/mcp/dist/lib/imap.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/sent-copy-note.d.ts +18 -0
- package/payload/platform/plugins/email/mcp/dist/lib/sent-copy-note.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/lib/sent-copy-note.js +59 -0
- package/payload/platform/plugins/email/mcp/dist/lib/sent-copy-note.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/lib/sent-copy-sweep.d.ts +48 -0
- package/payload/platform/plugins/email/mcp/dist/lib/sent-copy-sweep.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/lib/sent-copy-sweep.js +79 -0
- package/payload/platform/plugins/email/mcp/dist/lib/sent-copy-sweep.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/lib/sent-ledger.d.ts +44 -0
- package/payload/platform/plugins/email/mcp/dist/lib/sent-ledger.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/lib/sent-ledger.js +63 -0
- package/payload/platform/plugins/email/mcp/dist/lib/sent-ledger.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/scripts/sent-copy-sweep.d.ts +2 -0
- package/payload/platform/plugins/email/mcp/dist/scripts/sent-copy-sweep.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/scripts/sent-copy-sweep.js +55 -0
- package/payload/platform/plugins/email/mcp/dist/scripts/sent-copy-sweep.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/tools/email-draft-send.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-draft-send.js +64 -13
- package/payload/platform/plugins/email/mcp/dist/tools/email-draft-send.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-reply.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-reply.js +11 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-reply.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-send.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-send.js +16 -3
- package/payload/platform/plugins/email/mcp/dist/tools/email-send.js.map +1 -1
- package/payload/platform/plugins/email/references/email-reference.md +36 -0
- package/payload/platform/plugins/scheduling/mcp/dist/__tests__/sent-sweep-throttle.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/__tests__/sent-sweep-throttle.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/__tests__/sent-sweep-throttle.test.js +18 -0
- package/payload/platform/plugins/scheduling/mcp/dist/__tests__/sent-sweep-throttle.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/sent-sweep-throttle.d.ts +13 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/sent-sweep-throttle.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/sent-sweep-throttle.js +10 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/sent-sweep-throttle.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/check-due-events.js +53 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/check-due-events.js.map +1 -1
- package/payload/platform/scripts/cpu-triage-run.sh +117 -0
- package/payload/platform/scripts/cpu-triage.sh +23 -4
- package/payload/platform/services/claude-session-manager/dist/activity-range.d.ts +40 -0
- package/payload/platform/services/claude-session-manager/dist/activity-range.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/activity-range.js +68 -0
- package/payload/platform/services/claude-session-manager/dist/activity-range.js.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/activity-rows.d.ts +40 -8
- package/payload/platform/services/claude-session-manager/dist/activity-rows.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/activity-rows.js +74 -7
- package/payload/platform/services/claude-session-manager/dist/activity-rows.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +2 -0
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +9 -0
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/server/{chunk-56WJMBQQ.js → chunk-3XLLTG6R.js} +14 -0
- package/payload/server/{chunk-JECAP3Z2.js → chunk-XGNRSM57.js} +3 -0
- package/payload/server/maxy-edge.js +1 -1
- package/payload/server/public/activity.html +6 -6
- package/payload/server/public/assets/{AdminLoginScreens-mEKP4pDi.js → AdminLoginScreens-DR5eLF-a.js} +1 -1
- package/payload/server/public/assets/AdminShell-D9zaUxPd.js +2 -0
- package/payload/server/public/assets/{Checkbox-CN4uQ80w.js → Checkbox-DcbbAIe5.js} +1 -1
- package/payload/server/public/assets/activity-C9P5NjEZ.js +1 -0
- package/payload/server/public/assets/{admin-BVhgfgs1.js → admin-D2KLZnQW.js} +1 -1
- package/payload/server/public/assets/{browser-D-HMmHcM.js → browser-CDWqEiCD.js} +1 -1
- package/payload/server/public/assets/{calendar-tGWvFyFn.js → calendar-BG7fOpbB.js} +1 -1
- package/payload/server/public/assets/chat-RyH-WYQC.js +1 -0
- package/payload/server/public/assets/chevron-left-DmXCr6nB.js +1 -0
- package/payload/server/public/assets/data-BaY_LkLR.js +1 -0
- package/payload/server/public/assets/{graph-zEw610xK.js → graph-DRloNic4.js} +1 -1
- package/payload/server/public/assets/{graph-labels-qnBleOE6.js → graph-labels-DD-GqS4v.js} +1 -1
- package/payload/server/public/assets/{maximize-2-BlTjXT_Y.js → maximize-2-CzDaBugs.js} +1 -1
- package/payload/server/public/assets/{operator-C7oIw2PG.js → operator-BZeeyait.js} +1 -1
- package/payload/server/public/assets/{page-DL6Zsdvk.js → page-B0obcg3b.js} +1 -1
- package/payload/server/public/assets/{page-CTP7OFZa.js → page-ef-6rRPL.js} +1 -1
- package/payload/server/public/assets/{public-r1A9dqR_.js → public-9D3MMOkC.js} +1 -1
- package/payload/server/public/assets/{rotate-ccw-CzkkKx4-.js → rotate-ccw-DXEKUhXP.js} +1 -1
- package/payload/server/public/assets/tasks-BB0L7e5a.js +1 -0
- package/payload/server/public/assets/{time-entry-format-j669DgXj.js → time-entry-format-CsYAjplS.js} +1 -1
- package/payload/server/public/assets/{triangle-alert-BPgCgIef.js → triangle-alert-0lSBIUg-.js} +1 -1
- package/payload/server/public/assets/{useCopyFeedback-BmLa2aes.js → useCopyFeedback-jTBQ2h0V.js} +1 -1
- package/payload/server/public/assets/{useSelectionMode-DnnM7A8-.js → useSelectionMode-BooArySZ.js} +1 -1
- package/payload/server/public/assets/useSubAccountSwitcher-D9knHOKq.css +1 -0
- package/payload/server/public/assets/{useVoiceRecorder-u2dwZfen.js → useVoiceRecorder-PUT8q_sm.js} +1 -1
- package/payload/server/public/browser.html +5 -5
- package/payload/server/public/calendar.html +6 -6
- package/payload/server/public/chat.html +12 -12
- package/payload/server/public/data.html +11 -11
- package/payload/server/public/graph.html +11 -11
- package/payload/server/public/index.html +14 -14
- package/payload/server/public/operator.html +14 -14
- package/payload/server/public/public.html +12 -12
- package/payload/server/public/tasks.html +5 -5
- package/payload/server/server.js +153 -18
- package/payload/server/{src-JYPKMWJR.js → src-XQ63FPRE.js} +3 -1
- package/payload/server/public/assets/AdminShell-BwSaZ88d.js +0 -2
- package/payload/server/public/assets/activity-CIQ8ozNZ.js +0 -1
- package/payload/server/public/assets/chat-DkttVxAz.js +0 -1
- package/payload/server/public/assets/chevron-left-CZ4ez9G5.js +0 -1
- package/payload/server/public/assets/data-P-mcmnNi.js +0 -1
- package/payload/server/public/assets/tasks-fIJwYFWG.js +0 -1
- package/payload/server/public/assets/useSubAccountSwitcher-C_E8h07P.css +0 -1
- /package/payload/server/public/assets/{useSubAccountSwitcher-CFa6ZAT1.js → useSubAccountSwitcher-BZnzc5C3.js} +0 -0
package/payload/server/server.js
CHANGED
|
@@ -117,7 +117,7 @@ import {
|
|
|
117
117
|
vncLog,
|
|
118
118
|
walkPremiumBundles,
|
|
119
119
|
writeAdminUserAndPerson
|
|
120
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-XGNRSM57.js";
|
|
121
121
|
import {
|
|
122
122
|
D1_MAX_SQL_STATEMENT_BYTES,
|
|
123
123
|
D1_QUERY_MAX_BODY_BYTES,
|
|
@@ -129,10 +129,11 @@ import {
|
|
|
129
129
|
listResources,
|
|
130
130
|
makeHouseCfExec,
|
|
131
131
|
makeHousePagesExec,
|
|
132
|
+
reconcileDataPortal,
|
|
132
133
|
registerResource,
|
|
133
134
|
resolveOwner,
|
|
134
135
|
tooLargeMessage
|
|
135
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-3XLLTG6R.js";
|
|
136
137
|
import {
|
|
137
138
|
__commonJS,
|
|
138
139
|
__toESM
|
|
@@ -9637,7 +9638,7 @@ app3.post("/r2/object/delete", envelopeBodyLimit("write"), async (c) => {
|
|
|
9637
9638
|
});
|
|
9638
9639
|
var storage_broker_default = app3;
|
|
9639
9640
|
async function runStorageAudit(root) {
|
|
9640
|
-
const { reconcileStorage } = await import("./src-
|
|
9641
|
+
const { reconcileStorage } = await import("./src-XQ63FPRE.js");
|
|
9641
9642
|
const cf = await makeHouseCfExec(root);
|
|
9642
9643
|
const accountsDir = resolve11(root, "..", "data", "accounts");
|
|
9643
9644
|
const strays = (await reconcileStorage({
|
|
@@ -9677,26 +9678,108 @@ async function runStorageAudit(root) {
|
|
|
9677
9678
|
);
|
|
9678
9679
|
}
|
|
9679
9680
|
async function runPagesAudit(root) {
|
|
9680
|
-
const { reconcilePages } = await import("./src-
|
|
9681
|
-
const
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9681
|
+
const { reconcilePages } = await import("./src-XQ63FPRE.js");
|
|
9682
|
+
const cf = await makeHousePagesExec(root);
|
|
9683
|
+
const r = await reconcilePages({
|
|
9684
|
+
cfProjects: async () => (await cf.pagesProjectList()).map((p) => p.name),
|
|
9685
|
+
// Its own session per invocation, same rule as runStorageAudit above and
|
|
9686
|
+
// for the same reason. This previously held one session opened in the
|
|
9687
|
+
// enclosing scope, which was safe only because reconcilePages issues
|
|
9688
|
+
// exactly one registry query — a property of the library, not of this
|
|
9689
|
+
// caller. A second read added there would have reproduced 1813 here
|
|
9690
|
+
// verbatim. The old shape also held that session open across
|
|
9691
|
+
// makeHousePagesExec's network I/O, which is a pooled connection parked
|
|
9692
|
+
// for the length of a Cloudflare round trip.
|
|
9693
|
+
registeredProjects: async () => {
|
|
9694
|
+
const session = getSession();
|
|
9695
|
+
try {
|
|
9687
9696
|
const res = await session.run(
|
|
9688
9697
|
"MATCH (r:StorageResource {kind: $kind}) RETURN r.name AS name",
|
|
9689
9698
|
{ kind: "pages" }
|
|
9690
9699
|
);
|
|
9691
9700
|
return res.records.map((rec) => rec.get("name"));
|
|
9701
|
+
} finally {
|
|
9702
|
+
await session.close();
|
|
9692
9703
|
}
|
|
9693
|
-
}
|
|
9704
|
+
}
|
|
9705
|
+
});
|
|
9706
|
+
console.error(
|
|
9707
|
+
`[pages-audit] projects=${r.projects} registered=${r.registered} orphan=${r.orphans.length} phantom=${r.phantoms.length}` + r.orphans.map((n) => ` orphan:${n}`).join("") + r.phantoms.map((n) => ` phantom:${n}`).join("")
|
|
9708
|
+
);
|
|
9709
|
+
}
|
|
9710
|
+
function parseManifestRows(raw) {
|
|
9711
|
+
const envelope = Array.isArray(raw) ? raw[0] : null;
|
|
9712
|
+
const results = envelope?.results;
|
|
9713
|
+
if (!Array.isArray(results)) {
|
|
9714
|
+
throw new Error(`unexpected d1 payload: envelope carries no results array`);
|
|
9715
|
+
}
|
|
9716
|
+
return results.map((r, i) => {
|
|
9717
|
+
const row = r;
|
|
9718
|
+
const bad = ["objectKey", "ingested", "uploadedAt"].find(
|
|
9719
|
+
(f) => f === "ingested" ? typeof row[f] !== "number" : typeof row[f] !== "string"
|
|
9720
|
+
);
|
|
9721
|
+
if (bad) throw new Error(`unexpected d1 row: index=${i} field=${bad} type=${typeof row[bad]}`);
|
|
9722
|
+
return { objectKey: row.objectKey, ingested: row.ingested, uploadedAt: row.uploadedAt };
|
|
9723
|
+
});
|
|
9724
|
+
}
|
|
9725
|
+
function auditErrorText(message) {
|
|
9726
|
+
return message.split("\n")[0].replaceAll('"', "'").slice(0, 160);
|
|
9727
|
+
}
|
|
9728
|
+
function discoverPortalAccounts(accountsDir) {
|
|
9729
|
+
if (!existsSync9(accountsDir)) return [];
|
|
9730
|
+
const found = [];
|
|
9731
|
+
for (const accountId of readdirSync8(accountsDir)) {
|
|
9732
|
+
const configPath2 = join13(accountsDir, accountId, "data-portal.json");
|
|
9733
|
+
if (!existsSync9(configPath2)) continue;
|
|
9734
|
+
try {
|
|
9735
|
+
const cfg = JSON.parse(readFileSync15(configPath2, "utf-8"));
|
|
9736
|
+
if (typeof cfg.portalDbName === "string" && cfg.portalDbName.length > 0 && typeof cfg.bucketName === "string" && cfg.bucketName.length > 0) {
|
|
9737
|
+
found.push({ accountId, portalDbName: cfg.portalDbName, bucketName: cfg.bucketName });
|
|
9738
|
+
}
|
|
9739
|
+
} catch {
|
|
9740
|
+
}
|
|
9741
|
+
}
|
|
9742
|
+
return found;
|
|
9743
|
+
}
|
|
9744
|
+
async function runDataPortalAudit(root) {
|
|
9745
|
+
const portals = discoverPortalAccounts(resolve11(root, "..", "data", "accounts"));
|
|
9746
|
+
if (portals.length === 0) return "portals=0 degraded=0";
|
|
9747
|
+
const cf = await makeHouseCfExec(root);
|
|
9748
|
+
let degraded = 0;
|
|
9749
|
+
for (const portal of portals) {
|
|
9750
|
+
let rows = null;
|
|
9751
|
+
let d1Error = null;
|
|
9752
|
+
try {
|
|
9753
|
+
rows = parseManifestRows(
|
|
9754
|
+
await cf.d1Query(
|
|
9755
|
+
portal.portalDbName,
|
|
9756
|
+
"SELECT objectKey, ingested, uploadedAt FROM manifest"
|
|
9757
|
+
)
|
|
9758
|
+
);
|
|
9759
|
+
} catch (err) {
|
|
9760
|
+
d1Error = err.message;
|
|
9761
|
+
}
|
|
9762
|
+
let objects = null;
|
|
9763
|
+
let r2Error = null;
|
|
9764
|
+
try {
|
|
9765
|
+
objects = await cf.r2ObjectList(portal.bucketName);
|
|
9766
|
+
} catch (err) {
|
|
9767
|
+
r2Error = err.message;
|
|
9768
|
+
}
|
|
9769
|
+
const nowMs = Date.now();
|
|
9770
|
+
const reconciled = rows !== null && objects !== null ? reconcileDataPortal(objects, rows, nowMs) : null;
|
|
9771
|
+
const ageHrs = rows === null ? null : reconcileDataPortal([], rows, nowMs).oldestUningestedHrs;
|
|
9772
|
+
const degradation = [d1Error !== null ? "d1" : null, r2Error !== null ? "r2" : null].filter(Boolean).join("+");
|
|
9773
|
+
if (degradation) degraded += 1;
|
|
9774
|
+
const reasons = [
|
|
9775
|
+
d1Error !== null ? `d1:${auditErrorText(d1Error)}` : null,
|
|
9776
|
+
r2Error !== null ? `r2:${auditErrorText(r2Error)}` : null
|
|
9777
|
+
].filter(Boolean).join(" | ");
|
|
9694
9778
|
console.error(
|
|
9695
|
-
`[
|
|
9779
|
+
`[data-portal-audit] account=${portal.accountId} objects=${objects?.length ?? "na"} rows=${rows?.length ?? "na"} orphanObjects=${reconciled?.orphanObjects.length ?? "na"} phantomRows=${reconciled?.phantomRows.length ?? "na"} oldestUningestedHrs=${ageHrs?.toFixed(1) ?? "na"}` + (degradation ? ` degraded=${degradation} err="${reasons}"` : "")
|
|
9696
9780
|
);
|
|
9697
|
-
} finally {
|
|
9698
|
-
await session.close();
|
|
9699
9781
|
}
|
|
9782
|
+
return `portals=${portals.length} degraded=${degraded}`;
|
|
9700
9783
|
}
|
|
9701
9784
|
|
|
9702
9785
|
// server/google-pending-audit.ts
|
|
@@ -22016,16 +22099,32 @@ app47.get("/", requireAdminSession, async (c) => {
|
|
|
22016
22099
|
WHERE te.endedAt IS NULL
|
|
22017
22100
|
WITH t, te ORDER BY te.startedAt
|
|
22018
22101
|
WITH t, head(collect(te)) AS openTe
|
|
22102
|
+
// OPTIONAL is load-bearing. Unassigned is the common state, so a plain
|
|
22103
|
+
// MATCH would silently drop most of the list with nothing looking wrong.
|
|
22104
|
+
OPTIONAL MATCH (t)-[:ASSIGNED_TO]->(a:AdminUser)
|
|
22105
|
+
// head(collect(...)) for the same reason the TimeEntry match above uses
|
|
22106
|
+
// it: a second ASSIGNED_TO edge would fan the row out, duplicating
|
|
22107
|
+
// rowKey and double-counting the assignee.
|
|
22108
|
+
WITH t, openTe, head(collect(a)) AS assignee
|
|
22019
22109
|
RETURN t.taskId AS taskId, elementId(t) AS rowKey, t.name AS name, t.clientName AS clientName,
|
|
22020
22110
|
t.propertyAddress AS propertyAddress, t.fee AS fee, t.status AS status,
|
|
22021
22111
|
coalesce(t.secondsLogged, 0) AS secondsLogged,
|
|
22022
|
-
openTe.startedAt AS runningStartedAt
|
|
22112
|
+
openTe.startedAt AS runningStartedAt,
|
|
22113
|
+
t.createdAt AS createdAt,
|
|
22114
|
+
assignee.userId AS assigneeUserId, assignee.name AS assigneeName
|
|
22023
22115
|
ORDER BY t.createdAt DESC`,
|
|
22024
22116
|
{ accountId }
|
|
22025
22117
|
);
|
|
22118
|
+
const totalResult = await session.run(
|
|
22119
|
+
`MATCH (t:Task {accountId: $accountId}) RETURN count(t) AS total`,
|
|
22120
|
+
{ accountId }
|
|
22121
|
+
);
|
|
22122
|
+
const graphTotal = totalResult.records.length > 0 ? toNum(totalResult.records[0].get("total")) : 0;
|
|
22026
22123
|
const open = [];
|
|
22027
22124
|
const completed = [];
|
|
22028
22125
|
let missingTaskId = 0;
|
|
22126
|
+
let missingCreatedAt = 0;
|
|
22127
|
+
let assigned = 0;
|
|
22029
22128
|
for (const rec of result.records) {
|
|
22030
22129
|
const status = rec.get("status") ?? "pending";
|
|
22031
22130
|
const runningStartedAt = rec.get("runningStartedAt") ?? null;
|
|
@@ -22033,6 +22132,10 @@ app47.get("/", requireAdminSession, async (c) => {
|
|
|
22033
22132
|
const rawTaskId = rec.get("taskId");
|
|
22034
22133
|
const taskId = typeof rawTaskId === "string" && rawTaskId !== "" ? rawTaskId : null;
|
|
22035
22134
|
if (taskId === null) missingTaskId++;
|
|
22135
|
+
const createdAt = rec.get("createdAt") ?? null;
|
|
22136
|
+
if (createdAt === null) missingCreatedAt++;
|
|
22137
|
+
const assigneeUserId = rec.get("assigneeUserId") ?? null;
|
|
22138
|
+
if (assigneeUserId !== null) assigned++;
|
|
22036
22139
|
const row = {
|
|
22037
22140
|
taskId,
|
|
22038
22141
|
rowKey: rec.get("rowKey"),
|
|
@@ -22043,12 +22146,23 @@ app47.get("/", requireAdminSession, async (c) => {
|
|
|
22043
22146
|
status,
|
|
22044
22147
|
secondsLogged: toNum(rec.get("secondsLogged")),
|
|
22045
22148
|
running: runningStartedAt !== null,
|
|
22046
|
-
runningStartedAt
|
|
22149
|
+
runningStartedAt,
|
|
22150
|
+
createdAt,
|
|
22151
|
+
assigneeUserId,
|
|
22152
|
+
assigneeName: rec.get("assigneeName") ?? null
|
|
22047
22153
|
};
|
|
22048
22154
|
if (COMPLETED.has(status)) completed.push(row);
|
|
22049
22155
|
else if (!HIDDEN_FROM_OPEN.has(status)) open.push(row);
|
|
22050
22156
|
}
|
|
22051
|
-
|
|
22157
|
+
const returned = result.records.length;
|
|
22158
|
+
if (returned < graphTotal) {
|
|
22159
|
+
console.error(
|
|
22160
|
+
`${TAG37} op=list row-count-shortfall account=${accountId} returned=${returned} graphTotal=${graphTotal} missing=${graphTotal - returned}`
|
|
22161
|
+
);
|
|
22162
|
+
}
|
|
22163
|
+
console.log(
|
|
22164
|
+
`${TAG37} op=list account=${accountId} returned=${returned} graphTotal=${graphTotal} open=${open.length} completed=${completed.length} missingTaskId=${missingTaskId} missingCreatedAt=${missingCreatedAt} assigned=${assigned}`
|
|
22165
|
+
);
|
|
22052
22166
|
return c.json({ open, completed });
|
|
22053
22167
|
} catch (err) {
|
|
22054
22168
|
console.error(`${TAG37} op=list error="${err instanceof Error ? err.message : String(err)}"`);
|
|
@@ -22366,7 +22480,13 @@ app52.get("/", requireAdminSession, async (c) => {
|
|
|
22366
22480
|
const start = Date.now();
|
|
22367
22481
|
let res;
|
|
22368
22482
|
try {
|
|
22369
|
-
|
|
22483
|
+
const qs = new URLSearchParams();
|
|
22484
|
+
const from = c.req.query("from");
|
|
22485
|
+
const to = c.req.query("to");
|
|
22486
|
+
if (from) qs.set("from", from);
|
|
22487
|
+
if (to) qs.set("to", to);
|
|
22488
|
+
const suffix = qs.size > 0 ? `?${qs.toString()}` : "";
|
|
22489
|
+
res = await fetch(`${managerBase("activity:wrapper")}/activity${suffix}`, {
|
|
22370
22490
|
signal: AbortSignal.timeout(3e4)
|
|
22371
22491
|
});
|
|
22372
22492
|
} catch (err) {
|
|
@@ -22420,6 +22540,11 @@ app52.get("/", requireAdminSession, async (c) => {
|
|
|
22420
22540
|
rows,
|
|
22421
22541
|
census,
|
|
22422
22542
|
censusAgeMs,
|
|
22543
|
+
// `satisfies` and not a bare literal (Task 1825). LoopsPayload is what the
|
|
22544
|
+
// activity page destructures; without the check, a key renamed or dropped
|
|
22545
|
+
// here still compiles and the page reads undefined, which its own
|
|
22546
|
+
// vocabulary renders as a dash meaning "not measured". The check runs both
|
|
22547
|
+
// ways: a key the page does not know about fails as an excess property.
|
|
22423
22548
|
loops: {
|
|
22424
22549
|
armed: armed2,
|
|
22425
22550
|
rows: loopRows,
|
|
@@ -28764,6 +28889,16 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
|
|
|
28764
28889
|
firstRunDelayMs: 35e3,
|
|
28765
28890
|
run: runPagesAuditSafe
|
|
28766
28891
|
});
|
|
28892
|
+
const runDataPortalAuditSafe = () => runDataPortalAudit(auditPlatformRoot).catch((err) => {
|
|
28893
|
+
console.error(`[data-portal-audit] error="${err.message}"`);
|
|
28894
|
+
throw err;
|
|
28895
|
+
});
|
|
28896
|
+
registerLoop({
|
|
28897
|
+
name: "data-portal-audit",
|
|
28898
|
+
intervalMs: STORAGE_AUDIT_INTERVAL_MS,
|
|
28899
|
+
firstRunDelayMs: 5e4,
|
|
28900
|
+
run: runDataPortalAuditSafe
|
|
28901
|
+
});
|
|
28767
28902
|
}
|
|
28768
28903
|
{
|
|
28769
28904
|
const publishPlatformRoot = process.env.MAXY_PLATFORM_ROOT ?? join42(__dirname, "..");
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
makeHouseCfExec,
|
|
15
15
|
makeHousePagesExec,
|
|
16
16
|
readHouseCredential,
|
|
17
|
+
reconcileDataPortal,
|
|
17
18
|
reconcilePages,
|
|
18
19
|
reconcileStorage,
|
|
19
20
|
registerResource,
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
stripAccountWideTokens,
|
|
23
24
|
tooLargeMessage,
|
|
24
25
|
validateMapping
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-3XLLTG6R.js";
|
|
26
27
|
import "./chunk-PFF6I7KP.js";
|
|
27
28
|
export {
|
|
28
29
|
D1_MAX_SQL_STATEMENT_BYTES,
|
|
@@ -39,6 +40,7 @@ export {
|
|
|
39
40
|
makeHouseCfExec,
|
|
40
41
|
makeHousePagesExec,
|
|
41
42
|
readHouseCredential,
|
|
43
|
+
reconcileDataPortal,
|
|
42
44
|
reconcilePages,
|
|
43
45
|
reconcileStorage,
|
|
44
46
|
registerResource,
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-TPjIAO9U.js";import{D as t,E as n,S as r,_ as i,a,d as o,i as s,l as c,m as l,n as u,o as d,p as f,s as p,t as m,u as h,v as g,x as ee}from"./useSubAccountSwitcher-CFa6ZAT1.js";import{c as te,d as ne,f as re,h as ie,m as ae,o as oe,p as se,r as ce,s as le,t as ue,u as _}from"./useSelectionMode-DnnM7A8-.js";async function v(){try{let e=await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})});return e.ok?(await e.json().catch(()=>({})))?.logged_out===!0:(console.error(`[admin-ui] claude-logout http-status=${e.status}`),!1)}catch(e){return console.error(`[admin-ui] claude-logout fetch failed: ${e instanceof Error?e.message:String(e)}`),!1}}var y=e(t(),1),b=r(),x={sm:14,md:16,lg:18},de={sm:30,md:38,lg:46};function S({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,style:u,className:d,children:f}){let p=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,d].filter(Boolean).join(` `),m=x[t],h={...e===`send`?{width:de[t],height:de[t]}:{},...u},g=Object.keys(h).length>0;return(0,b.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,b.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,b.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,b.jsx)(n,{size:m})]}),i&&(0,b.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var C=i(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),w=i(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),fe=i(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),pe=i(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),me=i(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),he=i(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),ge=i(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),T=i(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),_e=i(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),ve=i(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),E=`maxy-shell-side-px`;function D(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function O(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-D());return Math.min(Math.max(e,248),n)}function ye(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(E);if(!e)return 264;let t=parseInt(e,10);if(!Number.isFinite(t))return console.warn(`[admin-ui] sidebar-width-parse-failed stored=${JSON.stringify(e)} fallback=264`),264;if(t>=248)return O(t)}catch{}return 264}function k({targetSelector:e=`.platform`}){let t=(0,y.useRef)(null),[n,r]=(0,y.useState)(()=>ye()),i=(0,y.useRef)(n);(0,y.useLayoutEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,y.useCallback)(()=>{r(e=>{let t=O(e);return t===e?e:t})},[]);(0,y.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(O(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(E,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=O(264);r(e);try{window.localStorage.removeItem(E)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,b.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var be=n();function xe({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,y.useRef)(null),[s,c]=(0,y.useState)({position:`fixed`,visibility:`hidden`}),l=(0,y.useCallback)(()=>{let t=e.current,n=o.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right-i.width;a<4&&(a=4);let s=window.innerHeight-r.bottom<i.height+8&&r.top>i.height+8?r.top-i.height:r.bottom;c({position:`fixed`,left:a,top:s,visibility:`visible`})},[e]);return(0,y.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,y.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||o.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,be.createPortal)((0,b.jsx)(`div`,{ref:o,className:n,role:r,"aria-label":i,style:s,children:a}),document.body)}function Se({actions:e,disabled:t}){let[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(null),o=(0,y.useRef)(null),s=(0,y.useCallback)(()=>{r(!1),a(null)},[]);return(0,b.jsxs)(`div`,{className:`conv-actions`,children:[(0,b.jsx)(`button`,{ref:o,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>r(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Session actions`,title:`Session actions`,children:(0,b.jsx)(h,{size:12})}),n&&(0,b.jsx)(xe,{anchorRef:o,onClose:s,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,b.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,b.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":i===e.key,disabled:t,onClick:()=>a(t=>t===e.key?null:e.key),children:[e.icon,(0,b.jsx)(`span`,{children:e.menuLabel})]}),i===e.key&&(0,b.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,b.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),s()},children:[e.icon,(0,b.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var A=`claude-opus-4-8[1m]`,j=`claude-sonnet-5`,M=`claude-haiku-4-5`,Ce={[A]:`Opus 4.8 (1M context)`,[j]:`Sonnet 5`,[M]:`Haiku 4.5`};function N(e){return Ce[e]??e}var we=[A,j,M];function P(e){return e.replace(/\[1m\]$/,``)}function Te(e){return we.find(t=>P(t)===P(e))??e}var F=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],I=[`low`,`medium`,`high`,`xhigh`];[...F],[...I],[...I];var L=[A,j,M],Ee={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},De=F.map(e=>({value:e,label:Ee[e]??e})),Oe={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},R=I.map(e=>({value:e,label:Oe[e]??e}));function z(e){if(e){let t=L.find(t=>P(t)===P(e));if(t)return t}return A}function ke({row:e,adminFetch:t,onError:n}){let[r,i]=(0,y.useState)(()=>z(e.model)),[a,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(!1),f=(0,y.useRef)(!1);(0,y.useEffect)(()=>{i(z(e.model))},[e.model]);let p=async()=>{if(!f.current){f.current=!0,d(!0);try{let i=await t(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:r,...a?{permissionMode:a}:{},...c?{effort:c}:{}})});if(!i.ok){n(`Could not reset ${e.title} (status ${i.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${i.status}`),f.current=!1,d(!1);return}let o=await i.json().catch(()=>({}));o.target?window.location.assign(o.target):(n(`Reset of ${e.title} returned no target`),f.current=!1,d(!1))}catch(t){n(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),f.current=!1,d(!1)}}};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`label`,{className:`reseat-field`,children:[(0,b.jsx)(`span`,{children:`Model`}),(0,b.jsx)(`select`,{"data-kind":`model`,value:r,disabled:u,onChange:e=>i(e.target.value),children:L.map(e=>(0,b.jsx)(`option`,{value:e,children:N(e)},e))})]}),(0,b.jsxs)(`label`,{className:`reseat-field`,children:[(0,b.jsx)(`span`,{children:`Mode`}),(0,b.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:u,onChange:e=>s(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Keep current`}),De.map(e=>(0,b.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,b.jsxs)(`label`,{className:`reseat-field`,children:[(0,b.jsx)(`span`,{children:`Effort`}),(0,b.jsxs)(`select`,{"data-kind":`effort`,value:c,disabled:u,onChange:e=>l(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Keep current`}),R.map(e=>(0,b.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,b.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:u,"aria-busy":u,onClick:()=>void p(),children:u?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(o,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function Ae(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function B(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function je({target:e,anchorEl:t,onConfirm:n,onCancel:r}){let i=(0,y.useRef)(null);return i.current=t,e?(0,b.jsxs)(xe,{anchorRef:i,onClose:r,className:`conv-delete-confirm`,role:`alertdialog`,ariaLabel:`Confirm delete session`,children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsx)(`span`,{children:`Delete this conversation?`}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:r,"aria-label":`Close`,children:`✕`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[(0,b.jsxs)(`div`,{className:`conv-delete-target`,children:[(0,b.jsx)(`span`,{className:`conv-delete-label`,title:e.title,children:e.title||`Untitled session`}),(0,b.jsx)(`code`,{className:`conv-delete-id`,title:e.sessionId,children:e.sessionId.slice(0,8)})]}),(0,b.jsx)(`div`,{style:{marginTop:`8px`},children:`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`}),e.live&&(0,b.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,b.jsx)(S,{variant:`danger`,size:`sm`,style:{flex:1},onClick:n,children:`Delete`}),(0,b.jsx)(S,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:r,children:`Cancel`})]})]}):null}function Me({open:e,count:t,liveCount:n,onConfirm:r,onCancel:i}){if(!e)return null;let a=t===1?``:`s`;return(0,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:i,children:(0,b.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete sessions`,children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsxs)(`span`,{children:[`Delete `,t,` conversation`,a,`?`]}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:i,"aria-label":`Close`,children:`✕`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes `,t,` transcript`,a,`. `,t===1?`It is`:`They are`,` not moved to Archive and cannot be recovered.`,n>0&&(0,b.jsxs)(`div`,{style:{marginTop:`8px`},children:[n,` `,n===1?`is`:`are`,` running and will be stopped first.`]})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,b.jsxs)(S,{variant:`danger`,size:`sm`,style:{flex:1},onClick:r,children:[`Delete `,t]}),(0,b.jsx)(S,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:i,children:`Cancel`})]})]})})}var Ne=`auth-refresh-failed`;function Pe({error:e,onClose:t}){if(!e)return null;let n=e.reason===Ne,r=n?`Claude sign-in expired`:`Session didn’t open`,i=n?`Your claude.ai login has expired. Re-authenticate to resume sessions.`:`The session did not bind within 60 seconds, so there is no live conversation to open.`;return(0,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,b.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsx)(`span`,{children:r}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,b.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,b.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Fe(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,y.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,ee=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,b.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,b.jsx)(`span`,{children:`Claude Code`}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,children:[(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,b.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,b.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,b.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:ee(m.resetsAt)})]}),m.isUsingOverage&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,b.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,children:[(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:p>0?B(p):`—`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:Ae(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,b.jsx)(`button`,{type:`button`,className:`claude-info-value claude-info-id-copy`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await ue(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function Ie({open:e,onConnect:t,onClose:n}){return e?(0,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,b.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsx)(`span`,{children:`Claude isn’t connected`}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,b.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,b.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,b.jsx)(S,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,b.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function V(e){let t=Math.round(e/6e4),n=Math.floor(t/60),r=t%60;return`${n}h ${String(r).padStart(2,`0`)}m`}function Le(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function H(e){return e.toLocaleString(`en-GB`)}function U(e){return`£${e.toFixed(2)}`}function Re(e){let t=[`Day`,`Active`,`Output tokens`,`Input tokens`,`Cache write`,`Cache read`,`Opus 4.8 (GBP)`,`Sonnet 4.6 (GBP)`],n=(e,t)=>[e,V(Le(t)),String(t.tokens.output),String(t.tokens.input),String(t.tokens.cacheWrite),String(t.tokens.cacheRead),t.costGBP.opus.toFixed(2),t.costGBP.sonnet.toFixed(2)];return[t,...e.days.map(e=>n(e.date,e)),n(`TOTAL (${e.days.length} d)`,e.totals)].map(e=>e.join(`,`)).join(`
|
|
2
|
-
`)}function ze({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,b.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,b.jsx)(r,{className:`usage-day`,children:e}),(0,b.jsx)(r,{children:V(Le(t))}),(0,b.jsx)(r,{children:H(t.tokens.output)}),(0,b.jsx)(r,{children:H(t.tokens.input)}),(0,b.jsx)(r,{children:H(t.tokens.cacheWrite)}),(0,b.jsx)(r,{children:H(t.tokens.cacheRead)}),(0,b.jsx)(r,{children:U(t.costGBP.opus)}),(0,b.jsx)(r,{children:U(t.costGBP.sonnet)})]})}function Be({show:e,onClose:t,sessionId:n,summary:r,loading:i,error:o}){if(!e)return null;let s=!!r&&r.days.length>0,c=()=>{if(!r)return;let e=new Blob([Re(r)],{type:`text/csv;charset=utf-8`}),t=URL.createObjectURL(e),i=document.createElement(`a`);i.href=t,i.download=`usage-${n?n.slice(0,8):`session`}.csv`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(t)};return(0,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,b.jsxs)(`div`,{className:`claude-info-modal usage-modal`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Session usage and cost`,children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsxs)(`span`,{children:[`Usage & cost`,n?` · ${n.slice(0,8)}`:``]}),s&&(0,b.jsx)(`button`,{className:`usage-download`,onClick:c,"aria-label":`Download as CSV`,title:`Download as CSV`,children:(0,b.jsx)(ie,{size:14})}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,b.jsx)(a,{size:14})})]}),(0,b.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[i&&(0,b.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!i&&o&&(0,b.jsx)(`div`,{className:`usage-note usage-error`,children:o}),!i&&!o&&r&&r.days.length===0&&(0,b.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!i&&!o&&r&&r.days.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`usage-table-scroll`,children:(0,b.jsxs)(`table`,{className:`usage-table`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,b.jsx)(`th`,{children:`Active`}),(0,b.jsx)(`th`,{children:`Output tok`}),(0,b.jsx)(`th`,{children:`Input tok`}),(0,b.jsx)(`th`,{children:`Cache write`}),(0,b.jsx)(`th`,{children:`Cache read`}),(0,b.jsx)(`th`,{children:`Opus 4.8 (£)`}),(0,b.jsx)(`th`,{children:`Sonnet 4.6 (£)`})]})}),(0,b.jsxs)(`tbody`,{children:[r.days.map(e=>(0,b.jsx)(ze,{label:e.date,d:e},e.date)),(0,b.jsx)(ze,{label:`TOTAL (${r.days.length} d)`,d:r.totals,bold:!0})]})]})}),(0,b.jsxs)(`div`,{className:`usage-note usage-caveats`,children:[`Prices dated `,r.pricing.opusPriceDate,` · £/$ `,r.pricing.usdPerGbp,` · Sonnet tokenizer factor `,r.pricing.tokenizerFactor,`. Idle human-wait dominates the calendar span; cache-read tokens dominate cost; Sonnet is a tokenizer-adjusted estimate.`]})]})]})]})})}var Ve=`https://claude.ai/code`,He=200,Ue=[500,1e3,1500,2e3,2500,3e3,3e3];function We(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target,sameOrigin:!0};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${Ve}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function Ge(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Ke(e){let{businessName:t,cacheKey:n,onConnectClaude:r,role:i,userName:a,userAvatar:o,onSelectProjects:u,onSelectPeople:m,onSelectTasks:h,onSelectAgents:ue,onCloseMobileDrawer:v,collapsed:x,selectedWhatsappId:de,onSelectWhatsappConversation:S,initialWhatsappSurface:E=!1,onSelectData:D,onCloseData:O,initialDataSurface:ye=!1}=e,k=s(n),be=(0,y.useCallback)(e=>({key:`reseat`,label:`Reset session ${e.title} (model, mode, effort)`,menuLabel:`Reset`,title:`Reset — move this session onto a chosen model, mode, and effort`,icon:(0,b.jsx)(_e,{size:12}),panel:()=>(0,b.jsx)(ke,{row:e,adminFetch:k,onError:e=>z({message:e,failed:!0})})}),[k]),xe=g.productName,A=typeof a==`string`?a:a===null?`name unavailable`:t||xe,j=(A.trim().charAt(0)||`?`).toUpperCase(),[M,Ce]=(0,y.useState)(ye?`data`:E?`whatsapp`:`sessions`),[N,we]=(0,y.useState)([]),[P,Te]=(0,y.useState)(!1),[F,I]=(0,y.useState)(null),[L,Ee]=(0,y.useState)(!1),[De,Oe]=(0,y.useState)(`file`),[R,z]=(0,y.useState)(null),[Ae,B]=(0,y.useState)(null),[Ne,Fe]=(0,y.useState)(!1),[V,Le]=(0,y.useState)([]),[H]=(0,y.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`session`)),[U,Re]=(0,y.useState)(!1),[ze,Ve]=(0,y.useState)(null),[Ke,qe]=(0,y.useState)(!1),[W,Ze]=(0,y.useState)(!1),[G,Qe]=(0,y.useState)(!1),[$e,et]=(0,y.useState)(null),[K,tt]=(0,y.useState)(new Set),nt=(0,y.useRef)(new Map),[q,rt]=(0,y.useState)(!1),[J,it]=(0,y.useState)(new Set),[at,ot]=(0,y.useState)(!1),[Y,st]=(0,y.useState)(null),[ct,lt]=(0,y.useState)(new Set),[ut,dt]=(0,y.useState)(new Set),[ft,pt]=(0,y.useState)(new Set),[X,mt]=(0,y.useState)(null),[ht,Z]=(0,y.useState)(``),[gt,_t]=(0,y.useState)(!1),[vt,yt]=(0,y.useState)(null),[bt,xt]=(0,y.useState)(null),[St,Ct]=(0,y.useState)(!1),[wt,Tt]=(0,y.useState)(null),[Et,Dt]=(0,y.useState)(!1),Ot=(0,y.useRef)(0),[kt,At]=(0,y.useState)([]),[jt,Mt]=(0,y.useState)(!1),[Nt,Pt]=(0,y.useState)(null),[Ft,It]=(0,y.useState)(`whatsapp`),Lt=(0,y.useCallback)(e=>{if(v(),!n){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),z({message:`Session not ready — try again`,failed:!0});return}if(!e.downloadPath){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=not-downloadable`),z({message:`${e.name} can’t be downloaded`,failed:!0});return}console.info(`[admin-ui] artefact-download id=${e.id} root=${e.downloadRoot??`data`} path=${e.downloadPath}`),ce(n,e.downloadPath,e.downloadRoot??`data`),z({message:`Downloading ${e.name}`,failed:!1})},[n,v]);(0,y.useEffect)(()=>{if(!R)return;let e=setTimeout(()=>z(null),2500);return()=>clearTimeout(e)},[R]);let Rt=H!=null&&V.some(e=>e.sessionId===H);(0,y.useEffect)(()=>{H==null||!U||console.info(`[sidebar-sessions] op=select-highlight session=${H.slice(0,8)} matched=${Rt}`)},[H,Rt,U]);let zt=(0,y.useCallback)(async()=>{if(n){Ee(!0),I(null);try{let e=await k(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);we((await e.json()).artefacts??[]),Te(!0)}catch(e){let t=e instanceof Error?e.message:String(e);I(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{Ee(!1)}}},[n,k]),Q=(0,y.useCallback)(async()=>{if(!n)return null;let e=++Ot.current;qe(!0),Ve(null);try{let t=await k(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===Ot.current?(Le(r),et(n.accountId??null),Re(!0),r):(console.info(`[admin-ui] sidebar-sessions-stale-response-dropped token=${e}`),r)}catch(t){let n=t instanceof Error?t.message:String(t);return e===Ot.current&&Ve(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===Ot.current&&qe(!1)}},[n,k]),Bt=(0,y.useCallback)(async()=>{if(n){Pt(null);try{let e=await k(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);At((await e.json()).conversations??[]),Mt(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Pt(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[n,k]);(0,y.useEffect)(()=>{!n||U||Q()},[n,U,Q]),(0,y.useEffect)(()=>{if(!n)return;let e=null;return Bt(),e=setInterval(()=>{Bt()},Je),()=>{e!==null&&clearInterval(e)}},[n,Bt]),(0,y.useEffect)(()=>{if(!n)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function r(){e===null&&(e=setInterval(t,Ye))}function i(){e!==null&&(clearInterval(e),e=null)}function a(){document.hidden?i():(t(),r())}return document.hidden||r(),document.addEventListener(`visibilitychange`,a),()=>{i(),document.removeEventListener(`visibilitychange`,a)}},[n,Q]);let Vt=(0,y.useMemo)(()=>{let e=new Map;for(let t of le)e.set(t,[]);for(let t of kt)e.get(t.channel)?.push(t);for(let t of le)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[kt]),Ht={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},Ut=()=>{S(null),Ce(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${P?N.length:0} collapsed=${x}`),zt()},$=1.5,Wt=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),zt()},Gt=()=>{S(null),Ce(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${U?V.length:0} collapsed=${x}`),U||Q()},Kt=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},qt=()=>{Ce(`data`),console.info(`[admin-ui] sidebar-nav surface=data collapsed=${x}`),D(),v()},Jt=e=>{O?.(),Ce(`whatsapp`),It(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${Vt.get(e)?.length??0} collapsed=${x}`)},Yt=(0,y.useCallback)(async e=>{if(ct.has(e.sessionId))return;lt(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await k(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=We(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});console.info(`[admin-ui] sidebar-session-resume sessionId=${e.sessionId} status=${n.status} outcome=${i.kind} slug=${r.slug??r.bridgeSessionId??`none`}`),i.kind===`navigate`?(v(),t?t.location.href=i.url:window.open(i.url,`_blank`)):(t?.close(),console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} status=${n.status} reason=${i.reason}`),B(i))}catch(n){t?.close();let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} error=${r}`),B({sessionId:e.sessionId,reason:r})}finally{lt(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[k,v,ct]),Xt=(0,y.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=Ue.length;n++){await new Promise(e=>setTimeout(e,Ue[n-1]));let r=await Q();if(r&&r.some(t=>t.sessionId===e)){console.info(`[admin-ui] sidebar-new-session-converged sessionId=${t} via=retry attempts=${n}`);return}}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Q]),Zt=(0,y.useCallback)(async()=>{if(!Et){Dt(!0);try{let e=await k(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>({})),n=We(e.ok,e.status,t);console.info(`[admin-ui] sidebar-new-session-spawned status=${e.status} outcome=${n.kind} slug=${t.slug??t.bridgeSessionId??`none`}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),t.sessionId?Xt(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):e.status===503||n.reason===`claude-auth-dead`?(console.info(`[admin-ui] op=llm-action-blocked action=spawn reason=claude-disconnected`),Fe(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),B(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),B({sessionId:null,reason:t})}finally{Dt(!1)}}},[k,Et,Xt]),Qt=(0,y.useCallback)((e,t)=>{e.stopPropagation(),st(t)},[]),$t=(0,y.useCallback)(async(e,t)=>{e.stopPropagation(),yt(t),xt(null),Tt(null),Ct(!0);try{let e=await k(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?xt(n):Tt(n.error??`status ${e.status}`)}catch(e){Tt(e instanceof Error?e.message:String(e))}finally{Ct(!1)}},[k]),en=(0,y.useCallback)(async(e,t={})=>{let n=t.refresh??!0;if(K.has(e.sessionId))return!1;tt(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await k(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));return console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),z({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0}),!1}let r=await t.json();return console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${r.pidKilled??`?`} deleted=${r.deleted??`?`}`),Le(t=>t.filter(t=>t.sessionId!==e.sessionId)),n&&Q(),!0}catch(t){let n=t instanceof Error?t.message:String(t);return console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),z({message:`Delete failed: ${n}`,failed:!0}),!1}finally{tt(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[k,K,Q]),tn=(0,y.useCallback)(e=>{it(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),nn=(0,y.useCallback)(()=>{rt(!1),it(new Set)},[]),rn=(0,y.useCallback)(async()=>{let e=[...J].map(e=>V.find(t=>t.sessionId===e)).filter(e=>!!e),t=e.filter(e=>e.live).length;console.info(`[admin-ui] sidebar-bulk-delete op=start count=${e.length} live=${t}`);let n=(await Promise.all(e.map(e=>en(e,{refresh:!1})))).filter(Boolean).length;console.info(`[admin-ui] sidebar-bulk-delete op=done requested=${e.length} ok=${n} failed=${e.length-n}`),Q(),nn()},[J,V,en,Q,nn]),an=(0,y.useCallback)(async(e,t)=>{if(e.stopPropagation(),!ut.has(t.sessionId)){dt(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await k(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),z({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Q()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),z({message:`Stop failed: ${n}`,failed:!0})}finally{dt(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[k,ut,Q]),on=(0,y.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!ft.has(t.sessionId)){pt(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await k(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),z({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Q()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),z({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{pt(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[k,ft,Q]),sn=(0,y.useCallback)(async e=>{let t=ht.trim();if(!t){z({message:`Title can’t be empty`,failed:!0});return}if(t.length>He){z({message:`Title too long (max ${He})`,failed:!0});return}_t(!0);try{let n=await k(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),z({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),mt(null),Z(``),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),z({message:`Rename failed: ${n}`,failed:!0})}finally{_t(!1)}},[k,ht,Q]);return(0,b.jsxs)(`aside`,{className:`side`,children:[(0,b.jsx)(`div`,{className:`side-new-session-row`,children:(0,b.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:Zt,disabled:Et,"aria-busy":Et,children:[(0,b.jsx)(se,{size:14}),(0,b.jsx)(`span`,{children:Et?`Spawning…`:`New session`})]})}),(0,b.jsxs)(`nav`,{className:`side-nav`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),m(),v()},children:[(0,b.jsx)(ve,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`People`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),ue(),v()},children:[(0,b.jsx)(fe,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Agents`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),u(),v()},children:[(0,b.jsx)(pe,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:ee().term}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),h(),v()},children:[(0,b.jsx)(ge,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row${M===`artefacts`?` active`:``}`,onClick:Ut,children:[(0,b.jsx)(ae,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row${M===`sessions`?` active`:``}`,onClick:Gt,children:[(0,b.jsx)(he,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row${M===`data`?` active`:``}`,onClick:qt,children:[(0,b.jsx)(l,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Data`}),(0,b.jsx)(`span`,{className:`kbd`})]}),jt&&le.filter(e=>Vt.get(e).length>0).map(e=>(0,b.jsxs)(`button`,{type:`button`,className:`nav-row${M===`whatsapp`&&Ft===e?` active`:``}`,onClick:()=>Jt(e),children:[(0,b.jsx)(_,{channel:e,size:16}),(0,b.jsx)(`span`,{className:`label`,children:Ht[e]}),(0,b.jsx)(`span`,{className:`kbd`})]},e)),Nt&&(0,b.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,b.jsx)(`span`,{className:`label`,children:Nt})})]}),M===`artefacts`&&(0,b.jsxs)(`div`,{className:`side-list`,children:[(0,b.jsxs)(`div`,{className:`group-head`,children:[(0,b.jsx)(`span`,{children:`Artefacts`}),(0,b.jsxs)(`span`,{className:`group-head-meta`,children:[(0,b.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:Wt,disabled:L,children:(0,b.jsx)(re,{size:12,className:L?`spinning`:void 0})}),(0,b.jsx)(`span`,{children:L?`…`:String(N.length)})]})]}),F&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:F}),P&&!F&&N.length>0&&(()=>{let e=N.filter(e=>e.kind===`agent-template`).length,t=N.length-e;return(0,b.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:N.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,b.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${De===e.key?` active`:``}`,onClick:()=>Oe(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,b.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),P&&!F&&N.length===0&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),N.filter(e=>De===`all`?!0:De===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?fe:ae,r=Ge(e.updatedAt),i=e.downloadPath!==null;return(0,b.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>Lt(e),disabled:!i,style:i?void 0:{cursor:`default`},title:i?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,b.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,b.jsxs)(`span`,{className:`conv-stack`,children:[(0,b.jsx)(`span`,{className:`conv-name-line`,children:(0,b.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,b.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),i&&(0,b.jsx)(ie,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),M===`sessions`&&(()=>{let e=V.filter(e=>W?!0:!e.isSubagent).filter(e=>G?!0:!e.archived),t=V.some(e=>e.isSubagent),n=V.some(e=>e.archived);return(0,b.jsxs)(`div`,{className:`side-list`,children:[(0,b.jsxs)(`div`,{className:`group-head`,children:[(0,b.jsx)(`span`,{children:`Sessions`}),(0,b.jsxs)(`span`,{className:`group-head-meta`,children:[(0,b.jsx)(`button`,{type:`button`,className:`group-head-select${q?` active`:``}`,"aria-pressed":q,title:q?`Exit select mode`:`Select multiple sessions to delete`,onClick:()=>{rt(e=>!e),it(new Set),mt(null),Z(``)},children:`Select`}),(0,b.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Kt,disabled:Ke,children:(0,b.jsx)(re,{size:12,className:Ke?`spinning`:void 0})}),(0,b.jsx)(`span`,{children:Ke?`…`:String(e.length)})]})]}),q&&(0,b.jsxs)(`div`,{className:`session-select-bar`,children:[(0,b.jsxs)(`span`,{className:`session-select-count`,children:[J.size,` selected`]}),(0,b.jsxs)(`button`,{type:`button`,className:`session-select-delete`,disabled:J.size===0,onClick:()=>ot(!0),children:[`Delete `,J.size]}),(0,b.jsx)(`button`,{type:`button`,className:`session-select-cancel`,onClick:nn,children:`Cancel`})]}),$e&&(0,b.jsx)(`div`,{className:`side-account-id`,title:`This install's accountId. The first 8 characters match the truncated UUID label on the live Remote Control daemon entry in claude.ai/code.`,children:(0,b.jsx)(`code`,{children:$e})}),(t||n)&&(0,b.jsxs)(`div`,{className:`artefact-filter-chips`,children:[t&&(0,b.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${W?` active`:``}`,"aria-pressed":W,onClick:()=>Ze(e=>!e),title:W?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),n&&(0,b.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${G?` active`:``}`,"aria-pressed":G,onClick:()=>Qe(e=>!e),title:G?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),ze&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:ze}),U&&!ze&&e.length===0&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=Ge(e.startedAt),n=ct.has(e.sessionId),r=K.has(e.sessionId),i=ut.has(e.sessionId),a=ft.has(e.sessionId),o=n||r||i||a,s=()=>{window.location.assign(`/chat?session=${e.sessionId}`)},l=[{key:`open`,label:`Resume session ${e.title} in claude.ai/code`,menuLabel:`Resume in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,icon:(0,b.jsx)(f,{size:12}),busy:n,onClick:()=>{Yt(e)}},{key:`message`,label:`Open session ${e.title} in admin webchat`,menuLabel:`Open in webchat`,title:`Open in admin webchat (/chat) — sending resumes this session`,icon:(0,b.jsx)(T,{size:12}),onClick:()=>{s()}},{key:`usage`,label:`Usage and cost for session ${e.title}`,menuLabel:`Usage & cost`,title:`Per-day active time, tokens, and estimated GBP cost`,icon:(0,b.jsx)(me,{size:12}),onClick:t=>{$t(t,e)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,b.jsx)(p,{size:12}),busy:i,onClick:t=>{an(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,b.jsx)(C,{size:12}),busy:a,onClick:t=>{on(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,b.jsx)(w,{size:12}),busy:a,onClick:t=>{on(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,b.jsx)(c,{size:12}),busy:gt&&X===e.sessionId,onClick:t=>{t.stopPropagation(),mt(e.sessionId),Z(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,b.jsx)(d,{size:12}),danger:!0,busy:r,onClick:t=>{Qt(t,e)}},be({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})],u=e.channel===`whatsapp`?` conv-channel-whatsapp`:e.channel===`telegram`?` conv-channel-telegram`:``,m=e.channel===`whatsapp`||e.channel===`telegram`||e.channel===`webchat`,h=le.includes(e.channel??``)&&e.senderId&&e.titleSource===`prefix`?oe({operatorName:e.personName??null,whatsappName:e.whatsappName??null,senderId:e.senderId,title:e.title}):e.personName??e.title;return(0,b.jsxs)(`div`,{ref:t=>{let n=nt.current;t?n.set(e.sessionId,t):n.delete(e.sessionId)},className:`conv conv-with-actions${u}${e.sessionId===H?` active`:``}`,children:[(0,b.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${h} in webchat`,onClick:()=>{if(X!==e.sessionId){if(q){tn(e.sessionId);return}s()}},onKeyDown:t=>{X!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),q?tn(e.sessionId):s())},children:[q&&(0,b.jsx)(`input`,{type:`checkbox`,className:`conv-select-check`,checked:J.has(e.sessionId),"aria-label":`Select ${h}`,onChange:()=>tn(e.sessionId),onClick:e=>e.stopPropagation()}),(0,b.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,b.jsxs)(`span`,{className:`conv-stack`,children:[(0,b.jsxs)(`span`,{className:`conv-name-line`,children:[m&&(0,b.jsx)(ne,{channel:e.channel,size:13}),X===e.sessionId?(0,b.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,onFocus:e=>e.currentTarget.select(),value:ht,disabled:gt,"aria-label":`New title for session ${e.title}`,onChange:e=>Z(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),sn(e)):t.key===`Escape`&&(t.preventDefault(),mt(null),Z(``))},onBlur:()=>{X===e.sessionId&&!gt&&(mt(null),Z(``))}}):(0,b.jsx)(`span`,{className:`conv-name`,title:h,children:h})]}),(0,b.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,b.jsx)(`code`,{className:`conv-session-id`,title:`First 8 characters of this session's id — distinguishes rows with identical auto-titles. The resume/delete buttons act on the full id.`,children:e.sessionId.slice(0,8)}),t&&(0,b.jsxs)(`span`,{children:[` · `,t]})]})]})]}),!q&&(0,b.jsx)(Se,{actions:l,disabled:o})]},e.sessionId)})]})})(),M===`whatsapp`&&(0,b.jsxs)(`div`,{className:`side-list`,children:[(0,b.jsxs)(`div`,{className:`group-head`,children:[(0,b.jsx)(`span`,{children:Ht[Ft]}),(0,b.jsxs)(`span`,{className:`group-head-meta`,children:[(0,b.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{Bt()},children:(0,b.jsx)(re,{size:12})}),(0,b.jsx)(`span`,{children:String(Vt.get(Ft).length)})]})]}),Vt.get(Ft).map(e=>{let t=Ge(e.lastMessageAt),n=te(e);return(0,b.jsxs)(`div`,{className:`conv conv-with-actions${e.source===`store`?e.scope===`admin`?` conv-scope-admin`:` conv-scope-public`:``}${de===n?` active`:``}`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{S(e),v()},title:e.title,children:[(0,b.jsx)(_,{channel:e.channel,size:14}),(0,b.jsxs)(`span`,{className:`conv-stack`,children:[(0,b.jsx)(`span`,{className:`conv-name-line`,children:(0,b.jsx)(`span`,{className:`conv-name`,children:oe(e)})}),t&&(0,b.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),e.source===`session`&&(0,b.jsx)(Se,{actions:[be({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1})]},n)})]}),(0,b.jsx)(Xe,{}),(0,b.jsxs)(`div`,{className:`side-foot`,children:[(0,b.jsx)(`div`,{className:`avatar`,children:o?(0,b.jsx)(`img`,{src:o,alt:A}):j}),(0,b.jsxs)(`div`,{className:`who`,children:[(0,b.jsx)(`span`,{className:`name`,children:A}),(0,b.jsx)(`span`,{className:`role`,children:i??`operator`})]})]}),R&&(0,b.jsx)(`div`,{className:`copy-toast${R.failed?` copy-toast-failed`:``}`,role:`status`,children:R.message}),(0,b.jsx)(Pe,{error:Ae,onClose:()=>B(null)}),(0,b.jsx)(Ie,{open:Ne,onConnect:()=>{Fe(!1),r?.()},onClose:()=>Fe(!1)}),(0,b.jsx)(je,{target:Y,anchorEl:Y?nt.current.get(Y.sessionId)??null:null,onCancel:()=>st(null),onConfirm:()=>{let e=Y;st(null),e&&en(e)}},Y?.sessionId??`none`),(0,b.jsx)(Me,{open:at,count:J.size,liveCount:V.filter(e=>J.has(e.sessionId)&&e.live).length,onConfirm:()=>{ot(!1),rn()},onCancel:()=>ot(!1)}),(0,b.jsx)(Be,{show:vt!==null,onClose:()=>{yt(null),xt(null),Tt(null)},sessionId:vt?.sessionId??null,summary:bt,loading:St,error:wt})]})}var qe=5e3,Je=3e4,Ye=3e4;function Xe(){let[e,t]=(0,y.useState)(null);if((0,y.useEffect)(()=>{let e=!1,n=null;async function r(){try{let n=await fetch(`/api/admin/system-stats`);if(!n.ok){console.error(`[admin-ui] system-stats-fetch-failed status=${n.status}`);return}let r=await n.json();e||t(r)}catch(e){console.error(`[admin-ui] system-stats-fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}}function i(){n===null&&(r(),n=setInterval(()=>{r()},qe))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=e=>{if(e===null)return{width:`0%`,background:`var(--text-tertiary)`};let t=Math.min(1,Math.max(0,e)),n=Math.round(140*(1-t));return{width:`${Math.round(t*100)}%`,background:`hsl(${n}, 65%, 45%)`}},f=[`system-stats`];return c&&f.push(`system-stats--warn`),l&&f.push(`system-stats--crit`),(0,b.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,b.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,b.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,b.jsx)(`div`,{className:`system-stats__bar`,children:(0,b.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,b.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,b.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,b.jsx)(`div`,{className:`system-stats__bar`,children:(0,b.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var W=`admin-sidebar-collapsed`,Ze=`admin-sidebar-drawer-open`;function G(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(W)===`1`}catch{return!1}}function Qe(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(W,`1`):window.sessionStorage.removeItem(W)}catch{}}function $e(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Ze)===`1`}catch{return!1}}function et(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Ze,`1`):window.sessionStorage.removeItem(Ze)}catch{}}function K(e){let[t,n]=(0,y.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(e).matches);return(0,y.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var tt=720;function nt(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function q(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function rt(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`acct`);return!r||!i?null:{sessionId:``,projectDir:``,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`public`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null,source:`store`,accountId:i,remoteJid:r}}function J(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function it(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:e===`activity`?`/activity`:`/browser`}function at(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:s,onConnectClaude:c,userName:l,userAvatar:d,role:f,onOpenConversations:p,children:h,footer:g}=e,{subAccounts:ne,activeAccountId:re,switching:ie,switchAccount:ae,refreshAccounts:oe}=m(t),[se,ce]=(0,y.useState)(!0);(0,y.useEffect)(()=>{if(s!==void 0||r!==`admin`)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||ce(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[s,r]);let le=s??se,ue=c??(()=>{window.location.assign(`/?connect=claude`)}),[_,v]=(0,y.useState)(()=>G()),[x,de]=(0,y.useState)(()=>$e()),S=K(`(max-width: ${tt}px)`),[C,w]=(0,y.useState)(()=>typeof window>`u`||J(window.location.pathname,window.location.search)?null:rt(window.location.pathname,window.location.search)),[fe]=(0,y.useState)(()=>C!==null),[pe,me]=(0,y.useState)(()=>typeof window>`u`?!1:J(window.location.pathname,window.location.search)),[he]=(0,y.useState)(()=>pe),ge=(0,y.useCallback)(e=>{Qe(e),v(e)},[]),T=(0,y.useCallback)(e=>{et(e),de(e)},[]);(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${r} sidebar=${r===`operator`?`none`:`present`} collapsed=${_} drawer=${x}`)},[]),(0,y.useEffect)(()=>{typeof window>`u`||!C||(console.info(`[admin-ui] wa-hydrate route=/ remoteJid=${C.remoteJid??``}`),window.history.replaceState(null,``,`/`))},[]),(0,y.useEffect)(()=>{typeof window>`u`||!pe||(console.info(`[admin-ui] data-hydrate route=/`),window.history.replaceState(null,``,`/`))},[]);let _e=(0,y.useCallback)(e=>{if(me(!1),e===null){w(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=nt(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?w(e):window.location.href=n.href},[]),ve=(0,y.useCallback)(()=>{let e=typeof window<`u`?window.location.pathname:`/`,t=q(e);if(console.info(`[admin-ui] data-open route=${e} via=${t.via}`),t.via===`navigate`){window.location.href=t.href;return}w(null),me(!0)},[]),E=S?x:!_,D=(0,y.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${tt}px)`).matches){let e=x;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),T(!e)}else{let e=_;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),ge(!e)}},[_,x,ge,T]),O=(0,y.useCallback)(e=>{let t=it(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),ye={collapsed:_,mobileDrawerOpen:x,sidebarOpen:E,onToggleSidebar:D,setMobileDrawerOpen:T,selectedWhatsapp:C,onClearWhatsapp:()=>w(null),dataOpen:pe};return r===`operator`?(0,b.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,b.jsx)(u,{businessName:n,variant:r,onNavigate:O,onOpenConversations:p,onToggleSidebar:D,sidebarOpen:E,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t,subAccounts:ne,activeAccountId:re,switchingAccount:ie,onSwitchAccount:ae,refreshAccounts:oe}),(0,b.jsx)(`div`,{className:`platform platform-operator`,children:typeof h==`function`?h(ye):h}),g]}):(0,b.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,b.jsx)(u,{businessName:n,variant:r,onNavigate:O,onOpenConversations:p,onToggleSidebar:D,sidebarOpen:E,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:le,onConnectClaude:ue,cacheKey:t,subAccounts:ne,activeAccountId:re,switchingAccount:ie,onSwitchAccount:ae,refreshAccounts:oe}),(0,b.jsxs)(`div`,{className:`platform${x?` menu-open`:``}${_?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,b.jsx)(Ke,{businessName:n,cacheKey:t,onConnectClaude:ue,role:f??null,userName:l,userAvatar:d??null,onSelectProjects:()=>{window.location.href=`/graph?label=${ee().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/tasks`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>T(!1),collapsed:_,mobileDrawerOpen:x,selectedWhatsappId:C?te(C):null,onSelectWhatsappConversation:_e,initialWhatsappSurface:fe,onSelectData:ve,onCloseData:()=>me(!1),initialDataSurface:he}),!S&&(0,b.jsx)(k,{}),typeof h==`function`?h(ye):h]}),x&&(0,b.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>T(!1)}),g]})}export{C as _,Fe as a,j as c,ve as d,_e as f,w as g,fe as h,Ie as i,Te as l,me as m,K as n,M as o,ge as p,We as r,A as s,at as t,N as u,S as v,v as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-TPjIAO9U.js";import{D as t,S as n,T as r,_ as i,d as a,g as o,r as s,w as c}from"./useSubAccountSwitcher-CFa6ZAT1.js";import{t as l,y as u}from"./AdminShell-BwSaZ88d.js";import"./useSelectionMode-DnnM7A8-.js";import{t as d}from"./triangle-alert-BPgCgIef.js";var f=i(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),p=i(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),m=r(),h=e(t(),1),g=n(),_=`—`;function v(e){switch(e){case`waiting`:return`Waiting`;case`never-run`:return`Never run`;case`never-succeeded`:return`Never succeeded`;case`failing`:return`Failing`;case`stalled`:return`Stalled`;case`running`:return`Running`;case`ok`:return`Healthy`}}var y={waiting:`Armed and not due yet. It has no start-up run and its first interval has not elapsed, so it has correctly not fired.`,"never-run":`Its interval has elapsed and it still has not fired once. This is not the same as waiting its turn.`,"never-succeeded":`It has fired, and not one run has finished. The work this loop exists to do has never happened.`,failing:`It worked before and is failing now.`,stalled:`It has not started within three of its own intervals. Something is holding it up.`,running:`A run is in progress right now.`,ok:`The last run finished and the next is due within the interval.`},b=new Set([`never-run`,`never-succeeded`,`failing`,`stalled`]),x=10;function S(e){return e===null||!Number.isFinite(e)?_:`${e.toFixed(1)}%`}function C(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function w(e,t){if(e===null)return _;let n=t-e;return n<0?`in ${C(-n)}`:n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function T(e,t){if(e===null)return _;let n=e-t;return n>=0?`in ${C(n)}`:`overdue by ${C(-n)}`}function E({loops:e,nowMs:t=Date.now()}){let[n,r]=(0,h.useState)(!1);if(!e)return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsx)(`p`,{className:`activity-loops-empty`,children:`Scheduled work could not be read from the server.`})]});let i=e.armed-e.rows.length,a=e.rows.filter(e=>b.has(e.state)),o=e.rows.filter(e=>!b.has(e.state)&&typeof e.cpuPct==`number`&&e.cpuPct>=x),s=n?e.rows:[...a,...o];return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsxs)(`p`,{className:`activity-loops-sub`,children:[e.armed,` `,e.armed===1?`loop`:`loops`,` armed`,a.length>0?` · ${a.length} ${a.length===1?`needs`:`need`} attention`:` · all healthy`,o.length>0&&` · ${o.length} using significant processor`,`. `,(0,g.jsx)(`button`,{type:`button`,className:`activity-loops-toggle`,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`Show less`:`Show all`})]}),typeof e.processPct==`number`&&(0,g.jsxs)(`p`,{className:`activity-loops-cpu`,children:[`Server process at `,e.processPct.toFixed(1),`% of one core`,typeof e.attributedPct==`number`&&(0,g.jsxs)(g.Fragment,{children:[` · these loops explain `,e.attributedPct.toFixed(1),`%`]}),typeof e.unattributedPct==`number`&&e.unattributedPct>=1&&(0,g.jsxs)(g.Fragment,{children:[` · `,(0,g.jsxs)(`strong`,{children:[e.unattributedPct.toFixed(1),`% is not from these loops`]})]})]}),i>0&&(0,g.jsxs)(`p`,{className:`activity-loops-omission`,role:`status`,children:[i,` armed `,i===1?`loop is`:`loops are`,` missing from this list. The server armed `,e.armed,` but sent `,e.rows.length,`.`]}),s.length===0?null:(0,g.jsxs)(`table`,{className:`activity-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Loop`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`State`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Every`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last run`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Took`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`CPU`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Runs`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Produced`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Next due`})]})}),(0,g.jsx)(`tbody`,{children:s.map(e=>(0,g.jsxs)(`tr`,{className:b.has(e.state)?`activity-loop-row activity-loop-unhealthy`:`activity-loop-row`,children:[(0,g.jsx)(`td`,{className:`activity-td`,children:e.name}),(0,g.jsx)(`td`,{className:`activity-td`,title:y[e.state],children:v(e.state)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:C(e.intervalMs)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastStartMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:e.lastDurationMs===null?_:`${e.lastDurationMs} ms`}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,title:e.cpuAttributable?e.detached?`Includes the processor time of the separate process this loop starts.`:void 0:`This loop waits on other work while it runs, so the processor time it uses cannot be separated from the rest of the server.`,children:S(e.cpuPct)}),(0,g.jsxs)(`td`,{className:`activity-td activity-num`,children:[e.successCount,`/`,e.runCount]}),(0,g.jsx)(`td`,{className:`activity-td activity-loop-note`,children:(0,g.jsx)(`span`,{className:`activity-loop-note-text`,title:e.lastError??e.lastNote??void 0,children:e.lastError??e.lastNote??_})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:T(e.nextDueMs,t)})]},e.name))})]}),(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`Runs`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Finished runs out of attempted runs since the server started. 0 out of a large number means it has tried many times and never once finished.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`CPU`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Share of one processor core this loop is using, measured between the last two refreshes. It includes any separate process the loop starts, and can pass 100% because those run alongside each other. A dash means it could not be measured: the loop waits on other work while it runs, so its share cannot be separated from the rest of the server.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:_}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Not measured. It does not mean zero.`})]})]})]})}var D=`maxy-admin-session-key`;function O(e){switch(e.costUnavailable){case`metering-failed`:return`Cost could not be calculated: ${e.meteringError??`the transcript could not be read`}`;case`model-not-priced`:return`No published price for this model, so cost cannot be estimated.`;case`no-transcript`:return`This session has no transcript yet, so there is nothing to cost.`;default:return}}var k=[{key:`accountId`,label:`Account`,numeric:!1,help:`The business this session belongs to. "untagged" means the session records no account.`},{key:`title`,label:`Session`,numeric:!1,help:`The conversation name, or its short id when it has none yet.`},{key:`model`,label:`Model`,numeric:!1,help:`The model that answered the most recent turn.`},{key:`status`,label:`Status`,numeric:!1,help:`What the process is doing right now.`},{key:`ageMs`,label:`Age`,numeric:!0,help:`How long ago this conversation started.`},{key:`lastMessageAt`,label:`Last activity`,numeric:!0,help:`The clock time of the most recent message, in your timezone. A date appears once it is not today.`},{key:`turnCount`,label:`Turns`,numeric:!0,help:`Messages exchanged. A trailing + means the count is a minimum — the conversation is too long to count exactly.`},{key:`rssKb`,label:`RAM`,numeric:!0,help:`Memory held by this session and all its helper processes together.`},{key:`cpuPct`,label:`CPU (avg)`,numeric:!0,help:`AVERAGE share of one processor core over the last census interval, up to 60 seconds. It is not a reading of this instant, so a session that answered a turn a minute ago still shows a high figure while sitting quiet now. Can exceed 100% because a session runs many processes at once.`},{key:`usedTokens`,label:`Tokens`,numeric:!0,help:`Size of the conversation the model currently reads back on every turn.`},{key:`costGbp`,label:`Cost`,numeric:!0,help:`Estimated spend on this conversation so far, at published prices for its model.`}],A=[`lastMessageAt`,`turnCount`,`rssKb`,`cpuPct`];function j(e,t){let n=t?.[e];return n&&n.trim()!==``?n:e.slice(0,8)}var M=`—`;function N(e){if(e===null||!Number.isFinite(e)||e<0)return M;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function P(e){return e===null||!Number.isFinite(e)?M:`${(e/1024/1024).toFixed(1)} GB`}function F(e,t){if(!e)return M;let n=Date.parse(e);if(!Number.isFinite(n))return M;let r=new Date(n),i=new Date(t),a=`${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`;return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()?a:`${r.getDate()} ${r.toLocaleString(`en-GB`,{month:`short`})} ${a}`}function I(e){return e===null||!Number.isFinite(e)?M:`${e.toFixed(1)}%`}function L(e){return e===null||!Number.isFinite(e)?M:e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function R(e){return e===null||!Number.isFinite(e)?M:`£${e.toFixed(2)}`}function z(e,t,n,r){let i=e[n],a=t[n];if(i===null&&a===null)return 0;if(i===null)return 1;if(a===null)return-1;if(n===`lastMessageAt`){let e=Date.parse(String(i)),t=Date.parse(String(a));return!Number.isFinite(e)&&!Number.isFinite(t)?0:Number.isFinite(e)?Number.isFinite(t)?(e-t)*r:-1:1}return typeof i==`number`&&typeof a==`number`?(i-a)*r:String(i).localeCompare(String(a))*r}function B({adminFetch:e}){let[t,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(null),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(`cpuPct`),[m,_]=(0,h.useState)(-1),v=(0,h.useRef)(!1),y=(0,h.useCallback)(async()=>{if(!v.current){v.current=!0;try{let t=await e(`/api/admin/activity`);if(t.status===403){i(`This view is available to the house account only.`),c(!0);return}if(!t.ok){i(`The session manager did not answer (status ${t.status}).`),c(!0);return}n(await t.json()),i(null)}catch(e){i(e instanceof Error?e.message:String(e))}finally{c(!0),v.current=!1}}},[e]);(0,h.useEffect)(()=>{y();let e=setInterval(()=>void y(),15e3);return()=>clearInterval(e)},[y]);let b=(0,h.useMemo)(()=>t?[...t.rows].sort((e,t)=>z(e,t,l,m)):[],[t,l,m]),x=e=>{e===l?_(e=>e===1?-1:1):(u(e),_(-1))};if(!s)return(0,g.jsxs)(`div`,{className:`activity-loading`,children:[(0,g.jsx)(a,{size:18,className:`spin`}),` Loading…`]});if(r)return(0,g.jsx)(`div`,{className:`activity-empty`,children:r});if(!t)return(0,g.jsx)(`div`,{className:`activity-empty`,children:`No response.`});let{accounts:S,census:C,censusAgeMs:w}=t,T=Date.now(),D=S.onDisk!==null&&S.onDisk>S.valid;return(0,g.jsxs)(`div`,{className:`activity-body`,children:[(0,g.jsxs)(`div`,{className:`activity-head`,children:[(0,g.jsxs)(`span`,{className:`activity-title`,children:[(0,g.jsx)(o,{size:16}),` Live sessions`]}),(0,g.jsxs)(`span`,{className:`activity-meta`,children:[b.length,` live · `,S.valid,` accounts`,S.untaggedCount>0?` · ${S.untaggedCount} untagged`:``]})]}),(0,g.jsx)(`div`,{className:`activity-census`,children:C===null?`No census collected yet, so memory and CPU are unavailable.`:`Memory and CPU measured ${N(w)} ago, averaged over the minute before that · ${C.cpuNull} of ${C.live} without a CPU reading`}),D&&(0,g.jsxs)(`div`,{className:`activity-warning`,children:[(0,g.jsx)(d,{size:14}),` `,S.onDisk,` account folders on disk but only`,` `,S.valid,` are readable. Sessions belonging to the rest cannot be attributed.`]}),b.length===0?(0,g.jsx)(`div`,{className:`activity-empty`,children:`No sessions are running.`}):(0,g.jsx)(`div`,{className:`activity-scroll`,children:(0,g.jsxs)(`table`,{className:`activity-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsx)(`tr`,{children:k.map(e=>(0,g.jsx)(`th`,{className:e.numeric?`activity-th activity-num`:`activity-th`,title:e.help,children:(0,g.jsxs)(`button`,{type:`button`,className:`activity-sort`,onClick:()=>x(e.key),children:[e.label,l===e.key&&(m===1?(0,g.jsx)(p,{size:11}):(0,g.jsx)(f,{size:11}))]})},e.key))})}),(0,g.jsx)(`tbody`,{children:b.map(e=>(0,g.jsxs)(`tr`,{className:`activity-row`,children:[(0,g.jsx)(`td`,{className:`activity-td`,title:e.accountId??void 0,children:e.accountId===null?(0,g.jsx)(`span`,{className:`activity-untagged`,title:`This session records no account, so it cannot be attributed to a business.`,children:`untagged`}):j(e.accountId,S.names)}),(0,g.jsx)(`td`,{className:`activity-td`,children:e.title??e.sessionId.slice(0,8)}),(0,g.jsx)(`td`,{className:`activity-td`,children:e.model??M}),(0,g.jsx)(`td`,{className:`activity-td`,children:e.status??M}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:N(e.ageMs)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:F(e.lastMessageAt,T)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:e.turnCount===null?M:`${e.turnCount}${e.turnCountCapped?`+`:``}`}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:P(e.rssKb)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:I(e.cpuPct)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:L(e.usedTokens)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,title:O(e),children:R(e.costGbp)})]},e.sessionId))})]})}),b.length>0&&(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[A.map(e=>{let t=k.find(t=>t.key===e);return(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:t.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:t.help})]},e)}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:M}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Not measured. It does not mean zero — hover the cell for the reason where one exists.`})]})]}),(0,g.jsx)(E,{loops:t?.loops})]})}function V({cacheKey:e}){let{adminFetch:t}=c({initialCacheKey:e,surface:`activity`});return(0,g.jsx)(B,{adminFetch:t})}function H(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)(!1),[i,o]=(0,h.useState)(void 0),[c,d]=(0,h.useState)(null),[f,p]=(0,h.useState)(null),[m,_]=(0,h.useState)(null),[v,y]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(D)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&d(e.sessionId??null),p(e.role??null),_(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let b=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},[]),[x,S]=(0,h.useState)(!1),C=(0,h.useCallback)(async()=>{S(!0);try{let e=await u();if(e){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`}return e}finally{S(!1)}},[]);return n?e?(0,g.jsx)(s,{cacheKey:e,surface:`activity`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=activity`);try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},children:(0,g.jsx)(l,{cacheKey:e,businessName:i,sessionId:c,onLogout:b,onDisconnect:C,disconnecting:x,userName:m,userAvatar:v,role:f,children:(0,g.jsx)(V,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`activity-page`,children:(0,g.jsxs)(`div`,{className:`activity-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`activity-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(`div`,{className:`activity-page`,children:(0,g.jsxs)(`div`,{className:`activity-loading`,children:[(0,g.jsx)(a,{size:18,className:`spin`}),` Loading…`]})})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(H,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,T as t}from"./useSubAccountSwitcher-CFa6ZAT1.js";import"./useVoiceRecorder-u2dwZfen.js";import"./AdminShell-BwSaZ88d.js";import{n}from"./page-CTP7OFZa.js";import"./useCopyFeedback-BmLa2aes.js";import"./useSelectionMode-DnnM7A8-.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e}from"./useSubAccountSwitcher-CFa6ZAT1.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,T as t}from"./useSubAccountSwitcher-CFa6ZAT1.js";import"./useVoiceRecorder-u2dwZfen.js";import{t as n}from"./page-DL6Zsdvk.js";import"./useSelectionMode-DnnM7A8-.js";import"./graph-labels-qnBleOE6.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-TPjIAO9U.js";import{D as t,S as n,T as r,_ as i,a,d as o,h as s,l as c,n as l,r as u,s as d,t as f,w as p}from"./useSubAccountSwitcher-CFa6ZAT1.js";import{n as m,t as h}from"./time-entry-format-j669DgXj.js";import{t as g}from"./rotate-ccw-CzkkKx4-.js";var _=i(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),v=i(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),y=r(),b=e(t(),1);function x(e=3e4){let[t,n]=(0,b.useState)(()=>Date.now());return(0,b.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function S(e,t){let n=new Map,r=(e,t,r)=>{let i=n.get(e)??{openCount:0,totalSeconds:0};i.totalSeconds+=t,r&&(i.openCount+=1),n.set(e,i)};for(let t of e)t.clientName&&r(t.clientName,t.secondsLogged,!0);for(let e of t)e.clientName&&r(e.clientName,e.secondsLogged,!1);let i=[...n.entries()].map(([e,t])=>({name:e,openCount:t.openCount,totalSeconds:t.totalSeconds}));return i.sort((e,t)=>t.openCount-e.openCount||e.name.localeCompare(t.name)),C(e,i),i}function C(e,t){let n=t.reduce((e,t)=>e+t.openCount,0),r=e.filter(e=>!e.clientName).length,i=n+r===e.length;return i||console.warn(`[tasks-clients] reconcile-mismatch assigned=${n} unassigned=${r} openTotal=${e.length}`),i}var w=n();function T(e){let t=[];return e.clientName&&t.push(e.clientName),e.propertyAddress&&t.push(e.propertyAddress),e.fee!=null&&t.push(`£${e.fee}`),t.join(` · `)}function E(e){return[e.clientName,e.propertyAddress].filter(Boolean).join(` · `)}function D(e,t){if(e.running&&e.runningStartedAt){let n=Date.parse(e.runningStartedAt);if(Number.isFinite(n))return e.secondsLogged+Math.max(0,(t-n)/1e3)}return e.secondsLogged}function O({clients:e,onSelect:t}){return(0,w.jsxs)(`section`,{className:`tasks-card`,children:[(0,w.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,w.jsx)(`span`,{className:`tasks-card-title`,children:`Clients`}),(0,w.jsxs)(`span`,{className:`tasks-card-count`,children:[e.length,` total`]})]}),e.length===0&&(0,w.jsx)(`div`,{className:`tasks-empty`,children:`No clients yet.`}),e.map(e=>(0,w.jsx)(`button`,{className:`tasks-row tasks-client-row`,onClick:()=>t(e.name),children:(0,w.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,w.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,w.jsxs)(`div`,{className:`tasks-row-sub`,children:[e.openCount,` open · `,h(e.totalSeconds),` logged`]})]})},e.name))]})}function k({adminFetch:e}){let[t,n]=(0,b.useState)({open:[],completed:[]}),[r,i]=(0,b.useState)(!1),[l,u]=(0,b.useState)(!1),f=(0,b.useRef)(!1),p=(0,b.useRef)(``),y=x(1e3),[C,k]=(0,b.useState)(`open`),[A,j]=(0,b.useState)(null),[M,N]=(0,b.useState)(null),[P,F]=(0,b.useState)(``),I=(0,b.useMemo)(()=>S(t.open,t.completed),[t]),L=(0,b.useCallback)(e=>{j(e),k(`open`)},[]);(0,b.useEffect)(()=>{A&&!I.some(e=>e.name===A)&&j(null)},[I,A]);let R=A?t.open.filter(e=>e.clientName===A||e.running):t.open,z=A?t.completed.filter(e=>e.clientName===A):t.completed,B=(0,b.useCallback)(async()=>{let t=await e(`/api/admin/tasks-list`);t.ok&&n(await t.json()),i(!0)},[e]);(0,b.useEffect)(()=>{B()},[B]);let V=(0,b.useCallback)(async(t,n,r)=>{if(!f.current){f.current=!0,u(!0);try{await e(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:n,...r})}),await B()}finally{f.current=!1,u(!1)}}},[e,B]),H=(0,b.useCallback)((e,t)=>{let n=String(Math.round(e.secondsLogged/60));p.current=n,N(t),F(n)},[]),U=(0,b.useCallback)(()=>{N(null),F(``)},[]),W=(0,b.useCallback)(async e=>{let t=P.trim(),n=Number(t);if(!(t===``||!Number.isInteger(n)||n<0)){if(t===p.current){U();return}N(null),F(``),await V(`/api/admin/task-time-adjust`,e,{newSeconds:n*60})}},[P,V,U]),G=(0,b.useCallback)(e=>{V(`/api/admin/task-time-adjust`,e,{newSeconds:0})},[V]);if(!r)return(0,w.jsxs)(`div`,{className:`tasks-loading`,children:[(0,w.jsx)(o,{size:18,className:`spin`}),` Loading…`]});let K=e=>e.taskId!==null&&M===e.taskId,q=(e,t)=>K(e)?(0,w.jsxs)(`div`,{className:`tasks-edit`,children:[(0,w.jsx)(`input`,{className:`tasks-edit-input`,type:`number`,min:0,step:1,"aria-label":`Logged minutes`,value:P,onChange:e=>F(e.target.value)}),(0,w.jsx)(`span`,{className:`tasks-edit-unit`,children:`min`}),(0,w.jsxs)(`button`,{className:`tasks-btn tasks-btn-start`,disabled:l,onClick:()=>void W(t),children:[(0,w.jsx)(s,{size:14}),` Save`]}),(0,w.jsxs)(`button`,{className:`tasks-btn tasks-btn-stop`,onClick:U,children:[(0,w.jsx)(a,{size:14}),` Cancel`]})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`button`,{className:`tasks-time-btn`,"aria-label":`Edit time`,disabled:l||e.running,title:e.running?`Stop the timer before editing time`:void 0,onClick:()=>H(e,t),children:(0,w.jsx)(c,{size:14})}),(0,w.jsx)(`button`,{className:`tasks-time-btn`,"aria-label":`Reset time`,disabled:l||e.running,title:e.running?`Stop the timer before resetting time`:void 0,onClick:()=>G(t),children:(0,w.jsx)(g,{size:14})})]});return(0,w.jsxs)(`div`,{className:`tasks-body`,children:[(0,w.jsxs)(`div`,{className:`tasks-tabs`,children:[(0,w.jsxs)(`button`,{className:`tasks-tab ${C===`open`?`tasks-tab-active`:``}`,onClick:()=>k(`open`),children:[`Open `,(0,w.jsx)(`span`,{className:`tasks-tab-badge`,children:t.open.length})]}),(0,w.jsxs)(`button`,{className:`tasks-tab ${C===`completed`?`tasks-tab-active`:``}`,onClick:()=>k(`completed`),children:[`Completed `,(0,w.jsx)(`span`,{className:`tasks-tab-badge`,children:t.completed.length})]}),(0,w.jsxs)(`button`,{className:`tasks-tab ${C===`clients`?`tasks-tab-active`:``}`,onClick:()=>k(`clients`),children:[`Clients `,(0,w.jsx)(`span`,{className:`tasks-tab-badge`,children:I.length})]})]}),C===`clients`?(0,w.jsx)(O,{clients:I,onSelect:L}):(0,w.jsxs)(w.Fragment,{children:[A&&(0,w.jsxs)(`div`,{className:`tasks-filter-banner`,children:[(0,w.jsxs)(`span`,{children:[`Showing `,A]}),(0,w.jsx)(`button`,{className:`tasks-filter-clear`,onClick:()=>j(null),children:`Clear`})]}),C===`open`?(0,w.jsxs)(`section`,{className:`tasks-card`,children:[(0,w.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,w.jsx)(`span`,{className:`tasks-card-title`,children:`Open tasks`}),(0,w.jsxs)(`span`,{className:`tasks-card-count`,children:[R.length,` to do`]})]}),R.length===0&&(0,w.jsx)(`div`,{className:`tasks-empty`,children:`No open tasks.`}),R.map(e=>(0,w.jsxs)(`div`,{className:`tasks-row`,children:[e.taskId===null?(0,w.jsx)(`span`,{className:`tasks-check tasks-check-done`,title:`This task has no id, so it cannot be completed. Repair it by running platform/scripts/backfill-task-ids.sh on this install.`,children:(0,w.jsx)(v,{size:18})}):(0,w.jsx)(`button`,{className:`tasks-check`,"aria-label":`Mark complete`,disabled:l||e.running,title:e.running?`Stop the timer before completing`:void 0,onClick:()=>void V(`/api/admin/task-complete`,e.taskId),children:(0,w.jsx)(v,{size:18})}),(0,w.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,w.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),T(e)&&(0,w.jsx)(`div`,{className:`tasks-row-sub`,children:T(e)})]}),(0,w.jsx)(`div`,{className:`tasks-row-elapsed`,children:h(D(e,y))}),e.taskId===null?(0,w.jsx)(`span`,{className:`tasks-row-broken`,title:`This task has no id, so it cannot be started, edited or completed. Repair it by running platform/scripts/backfill-task-ids.sh on this install.`,children:`Needs repair`}):(0,w.jsxs)(w.Fragment,{children:[q(e,e.taskId),K(e)?null:e.running?(0,w.jsxs)(`button`,{className:`tasks-btn tasks-btn-stop`,disabled:l,onClick:()=>void V(`/api/admin/task-timer-stop`,e.taskId),children:[(0,w.jsx)(d,{size:14}),` Stop`]}):(0,w.jsxs)(`button`,{className:`tasks-btn tasks-btn-start`,disabled:l,onClick:()=>void V(`/api/admin/task-timer-start`,e.taskId),children:[(0,w.jsx)(m,{size:14}),` Start`]})]})]},e.rowKey))]}):(0,w.jsxs)(`section`,{className:`tasks-card`,children:[(0,w.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,w.jsx)(`span`,{className:`tasks-card-title`,children:`Completed`}),(0,w.jsxs)(`span`,{className:`tasks-card-count`,children:[z.length,` done`]})]}),z.length===0&&(0,w.jsx)(`div`,{className:`tasks-empty`,children:`Nothing completed yet.`}),z.map(e=>(0,w.jsxs)(`div`,{className:`tasks-row tasks-row-done`,children:[(0,w.jsx)(`span`,{className:`tasks-check tasks-check-done`,children:(0,w.jsx)(_,{size:18})}),(0,w.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,w.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),E(e)&&(0,w.jsx)(`div`,{className:`tasks-row-sub`,children:E(e)})]}),(0,w.jsxs)(`div`,{className:`tasks-row-elapsed`,children:[h(e.secondsLogged),e.fee==null?``:` · £${e.fee}`]}),e.taskId===null?(0,w.jsx)(`span`,{className:`tasks-row-broken`,title:`This task has no id, so its logged time cannot be edited. Repair it by running platform/scripts/backfill-task-ids.sh on this install.`,children:`Needs repair`}):q(e,e.taskId)]},e.rowKey))]})]})]})}function A({cacheKey:e}){let{adminFetch:t,cacheKey:n}=p({initialCacheKey:e,surface:`tasks`}),{subAccounts:r,activeAccountId:i,switching:a,switchAccount:o}=f(n),s=(0,b.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]);return(0,w.jsxs)(`main`,{className:`tasks-main`,children:[(0,w.jsx)(l,{variant:`operator`,onNavigate:(0,b.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:s,onDisconnect:async()=>!0,disconnecting:!1,cacheKey:n,subAccounts:r,activeAccountId:i,switchingAccount:a,onSwitchAccount:o}),(0,w.jsx)(k,{adminFetch:t})]})}function j(){let[e,t]=(0,b.useState)(null),[n,r]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,w.jsx)(u,{cacheKey:e,surface:`tasks`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=tasks`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,w.jsx)(`div`,{className:`tasks-page tasks-page-full`,children:(0,w.jsx)(A,{cacheKey:e})})}):(0,w.jsx)(`div`,{className:`tasks-page`,children:(0,w.jsxs)(`div`,{className:`tasks-empty`,children:[(0,w.jsx)(`p`,{children:`You are not signed in.`}),(0,w.jsxs)(`p`,{children:[`Open the `,(0,w.jsx)(`a`,{href:`/`,className:`tasks-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,w.jsx)(`div`,{className:`tasks-page`,children:(0,w.jsxs)(`div`,{className:`tasks-loading`,children:[(0,w.jsx)(o,{size:18,className:`spin`}),` Loading…`]})})}(0,y.createRoot)(document.getElementById(`root`)).render((0,w.jsx)(j,{}));
|