@rubytech/create-maxy-code 0.1.436 → 0.1.438
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/lib/active-rules/dist/index.d.ts +14 -0
- package/payload/platform/lib/active-rules/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/active-rules/dist/index.js +56 -9
- package/payload/platform/lib/active-rules/dist/index.js.map +1 -1
- package/payload/platform/lib/active-rules/src/index.test.ts +106 -0
- package/payload/platform/lib/active-rules/src/index.ts +98 -9
- package/payload/platform/lib/admin-access-password/__tests__/index.test.ts +31 -0
- package/payload/platform/lib/admin-access-password/dist/index.d.ts +8 -0
- package/payload/platform/lib/admin-access-password/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/admin-access-password/dist/index.js +5 -1
- package/payload/platform/lib/admin-access-password/dist/index.js.map +1 -1
- package/payload/platform/lib/admin-access-password/src/index.ts +14 -1
- package/payload/platform/lib/admins-write/__tests__/index.test.ts +27 -0
- package/payload/platform/lib/admins-write/dist/index.d.ts +8 -0
- package/payload/platform/lib/admins-write/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/admins-write/dist/index.js +5 -1
- package/payload/platform/lib/admins-write/dist/index.js.map +1 -1
- package/payload/platform/lib/admins-write/src/index.ts +14 -1
- package/payload/platform/plugins/admin/.claude-plugin/plugin.json +1 -1
- package/payload/platform/plugins/admin/PLUGIN.md +4 -2
- package/payload/platform/plugins/admin/mcp/dist/credential-identity.d.ts +23 -0
- package/payload/platform/plugins/admin/mcp/dist/credential-identity.d.ts.map +1 -0
- package/payload/platform/plugins/admin/mcp/dist/credential-identity.js +35 -0
- package/payload/platform/plugins/admin/mcp/dist/credential-identity.js.map +1 -0
- package/payload/platform/plugins/admin/mcp/dist/index.js +110 -57
- package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts +22 -0
- package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts.map +1 -1
- package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js +62 -2
- package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js.map +1 -1
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +6 -6
- package/payload/platform/plugins/docs/references/admin-identity-gate.md +40 -0
- package/payload/platform/plugins/docs/references/admin-session.md +2 -0
- package/payload/platform/plugins/docs/references/admin-ui.md +2 -2
- package/payload/platform/plugins/docs/references/internals.md +3 -3
- package/payload/platform/plugins/linkedin-import/skills/linkedin-import/references/profile.md +1 -1
- package/payload/platform/plugins/memory/mcp/dist/index.js +12 -3
- package/payload/platform/plugins/memory/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-archive-write-progress.test.d.ts +2 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-archive-write-progress.test.d.ts.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-archive-write-progress.test.js +79 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-archive-write-progress.test.js.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-write-phase-progress.test.d.ts +2 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-write-phase-progress.test.d.ts.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-write-phase-progress.test.js +50 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-write-phase-progress.test.js.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-reindex-progress.test.d.ts +2 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-reindex-progress.test.d.ts.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-reindex-progress.test.js +114 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-reindex-progress.test.js.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-read-active-rules.test.js +5 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-read-active-rules.test.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-archive-write.d.ts +15 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-archive-write.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-archive-write.js +17 -17
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-archive-write.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-ingest.js +21 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-ingest.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-reindex.d.ts +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-reindex.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-reindex.js +19 -4
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-reindex.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-read.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-read.js +4 -2
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-read.js.map +1 -1
- package/payload/platform/scripts/remediate-glsmith-identity.sh +500 -0
- package/payload/platform/scripts/seed-neo4j.sh +77 -12
- 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 +36 -10
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/identity-audit.d.ts +51 -0
- package/payload/platform/services/claude-session-manager/dist/identity-audit.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/identity-audit.js +103 -0
- package/payload/platform/services/claude-session-manager/dist/identity-audit.js.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/index.js +33 -0
- package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.d.ts +7 -0
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.js +9 -0
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.d.ts +25 -0
- package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.js +42 -0
- package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.js.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/preference-reconciliation-audit.d.ts +4 -1
- package/payload/platform/services/claude-session-manager/dist/preference-reconciliation-audit.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/preference-reconciliation-audit.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.d.ts +44 -0
- package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.js +127 -0
- package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.js.map +1 -0
- package/payload/server/{chunk-LMLVOZ6G.js → chunk-UGPQCVIW.js} +11 -38
- package/payload/server/maxy-edge.js +1 -1
- package/payload/server/public/assets/{AdminLoginScreens-CMh1pdOp.js → AdminLoginScreens-DeR71H29.js} +1 -1
- package/payload/server/public/assets/AdminShell-DlAVQUda.js +2 -0
- package/payload/server/public/assets/{Checkbox-OCfZCTCO.js → Checkbox-B629mOPp.js} +1 -1
- package/payload/server/public/assets/{admin-Bi2uYnAg.js → admin-C15h-NL0.js} +1 -1
- package/payload/server/public/assets/{arc-Bm9oSOth.js → arc-qKfXIt8v.js} +1 -1
- package/payload/server/public/assets/architecture-YZFGNWBL-FPHT7s-C.js +1 -0
- package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-C2dK88g3.js → architectureDiagram-Q4EWVU46-DkVrGn7G.js} +1 -1
- package/payload/server/public/assets/{blockDiagram-DXYQGD6D-DfLSsjCJ.js → blockDiagram-DXYQGD6D-DqavswGH.js} +1 -1
- package/payload/server/public/assets/browser-B7xQLIRK.js +1 -0
- package/payload/server/public/assets/{c4Diagram-AHTNJAMY-Bxkmp6OL.js → c4Diagram-AHTNJAMY-B7fyKiXe.js} +1 -1
- package/payload/server/public/assets/calendar-A-vGm6pL.js +1 -0
- package/payload/server/public/assets/channel-j70eMvcL.js +1 -0
- package/payload/server/public/assets/chat-DAae6Z51.js +1 -0
- package/payload/server/public/assets/chevron-left-u4tjq7fI.js +1 -0
- package/payload/server/public/assets/{chunk-2KRD3SAO-BVNDFwNH.js → chunk-2KRD3SAO-DsgMtGkv.js} +1 -1
- package/payload/server/public/assets/{chunk-336JU56O-Daz6nMta.js → chunk-336JU56O-CkdISfNt.js} +2 -2
- package/payload/server/public/assets/chunk-426QAEUC-D-NcAlTW.js +1 -0
- package/payload/server/public/assets/{chunk-4BX2VUAB-DTldfvwP.js → chunk-4BX2VUAB-CYpiF2bl.js} +1 -1
- package/payload/server/public/assets/{chunk-4TB4RGXK-DhM8pwRG.js → chunk-4TB4RGXK-CWyc_F7v.js} +1 -1
- package/payload/server/public/assets/{chunk-55IACEB6-CzTsbIHo.js → chunk-55IACEB6-BbzKMw2Z.js} +1 -1
- package/payload/server/public/assets/{chunk-5FUZZQ4R-BrcObZhe.js → chunk-5FUZZQ4R-u19Nai9e.js} +1 -1
- package/payload/server/public/assets/{chunk-5PVQY5BW-SFqTuS11.js → chunk-5PVQY5BW-Ba8by6Uy.js} +1 -1
- package/payload/server/public/assets/{chunk-67CJDMHE-EIbrSGOo.js → chunk-67CJDMHE-BwUuxtyb.js} +1 -1
- package/payload/server/public/assets/{chunk-7N4EOEYR-B1D4Jorr.js → chunk-7N4EOEYR-BRH9iM9L.js} +1 -1
- package/payload/server/public/assets/{chunk-AA7GKIK3-BKHiX4cC.js → chunk-AA7GKIK3-BGoztgLL.js} +1 -1
- package/payload/server/public/assets/{chunk-BSJP7CBP-xBzu29m7.js → chunk-BSJP7CBP-C5GDAZTl.js} +1 -1
- package/payload/server/public/assets/{chunk-CIAEETIT-x2x0gMpL.js → chunk-CIAEETIT-ChY32VPS.js} +1 -1
- package/payload/server/public/assets/{chunk-EDXVE4YY-D5UkD28M.js → chunk-EDXVE4YY-CPSD3p6p.js} +1 -1
- package/payload/server/public/assets/{chunk-ENJZ2VHE-Dbz67a7E.js → chunk-ENJZ2VHE-D1oL-iUr.js} +1 -1
- package/payload/server/public/assets/{chunk-FMBD7UC4-XfWvuu2F.js → chunk-FMBD7UC4-CPvYEr54.js} +1 -1
- package/payload/server/public/assets/{chunk-FOC6F5B3-DfOEDS4q.js → chunk-FOC6F5B3-9Yyj7Vbz.js} +1 -1
- package/payload/server/public/assets/{chunk-ICPOFSXX-D_WEZZvg.js → chunk-ICPOFSXX-BaYgh8FR.js} +2 -2
- package/payload/server/public/assets/{chunk-K5T4RW27-7O627Xi1.js → chunk-K5T4RW27-5ucpeRvm.js} +1 -1
- package/payload/server/public/assets/{chunk-KGLVRYIC-BXI3XDP9.js → chunk-KGLVRYIC-DW-FHk7T.js} +1 -1
- package/payload/server/public/assets/{chunk-LIHQZDEY-B9cFNN0l.js → chunk-LIHQZDEY-CGGVfAyG.js} +1 -1
- package/payload/server/public/assets/{chunk-ORNJ4GCN-BR3UNDTn.js → chunk-ORNJ4GCN-Bv8EUa5d.js} +1 -1
- package/payload/server/public/assets/{chunk-OYMX7WX6-2wKIEtFZ.js → chunk-OYMX7WX6-C1mXJnyw.js} +1 -1
- package/payload/server/public/assets/chunk-QZHKN3VN-CAwbQBtf.js +1 -0
- package/payload/server/public/assets/{chunk-U2HBQHQK-augM3AXB.js → chunk-U2HBQHQK-PwSQz6EP.js} +1 -1
- package/payload/server/public/assets/{chunk-X2U36JSP-BAM9q9ZQ.js → chunk-X2U36JSP--NPHTBlU.js} +1 -1
- package/payload/server/public/assets/{chunk-XPW4576I-DxPpji5P.js → chunk-XPW4576I-Bbc7Da32.js} +1 -1
- package/payload/server/public/assets/{chunk-YZCP3GAM-BD3ClFXP.js → chunk-YZCP3GAM-D-9v8e--.js} +1 -1
- package/payload/server/public/assets/{chunk-ZZ45TVLE-CqxhLPep.js → chunk-ZZ45TVLE-CMPg670Q.js} +1 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-Ct6Rn0vt.js +1 -0
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-B_2XCIFv.js +1 -0
- package/payload/server/public/assets/clone-DjPWA_NH.js +1 -0
- package/payload/server/public/assets/{cose-bilkent-S5V4N54A-xywWX-9i.js → cose-bilkent-S5V4N54A-NVSb1Bhy.js} +1 -1
- package/payload/server/public/assets/{dagre-KV5264BT-ChRpqqiH.js → dagre-KV5264BT-V2Ai1DFl.js} +1 -1
- package/payload/server/public/assets/{dagre-BaHjDQ-8.js → dagre-QfLcO-1j.js} +1 -1
- package/payload/server/public/assets/data-BNWpKx1d.js +1 -0
- package/payload/server/public/assets/{diagram-5BDNPKRD-KjwTpyBi.js → diagram-5BDNPKRD-Caw21693.js} +1 -1
- package/payload/server/public/assets/{diagram-G4DWMVQ6-DZO9njAF.js → diagram-G4DWMVQ6-CgwVkT2q.js} +1 -1
- package/payload/server/public/assets/{diagram-MMDJMWI5-Bus-U-TI.js → diagram-MMDJMWI5-DFUrLZhs.js} +1 -1
- package/payload/server/public/assets/{diagram-TYMM5635-CfJodFgq.js → diagram-TYMM5635-CEEiEuZJ.js} +1 -1
- package/payload/server/public/assets/{erDiagram-SMLLAGMA-Bt5zqWiW.js → erDiagram-SMLLAGMA-CG10NrT3.js} +1 -1
- package/payload/server/public/assets/file-download-4mKJxUi-.js +1 -0
- package/payload/server/public/assets/{flatten-Bpu1L63d.js → flatten-DAO0sfCM.js} +1 -1
- package/payload/server/public/assets/{flowDiagram-DWJPFMVM-B64Q590S.js → flowDiagram-DWJPFMVM-BqkV9Okv.js} +1 -1
- package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-BWdgCEpH.js → ganttDiagram-T4ZO3ILL-DRiCDQF6.js} +1 -1
- package/payload/server/public/assets/gitGraph-7Q5UKJZL-B8Hx7f-D.js +1 -0
- package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-Djq2B0WT.js → gitGraphDiagram-UUTBAWPF-BZV2voyy.js} +1 -1
- package/payload/server/public/assets/{graph-CrJ-itbq.js → graph-D0orIRAh.js} +3 -3
- package/payload/server/public/assets/{graph-labels-CmCWaKJT.js → graph-labels-B8YAdo3Z.js} +1 -1
- package/payload/server/public/assets/{graphlib-CNJh9_lx.js → graphlib-DGPThX8M.js} +1 -1
- package/payload/server/public/assets/info-OMHHGYJF-BicCJTqU.js +1 -0
- package/payload/server/public/assets/infoDiagram-42DDH7IO-tf-8rOez.js +2 -0
- package/payload/server/public/assets/{isEmpty-DkDEVnMZ.js → isEmpty-Cb_U81C6.js} +1 -1
- package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-V3ACkWCW.js → ishikawaDiagram-UXIWVN3A-BKsAxSvp.js} +1 -1
- package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-9T0qZeH3.js → journeyDiagram-VCZTEJTY-CmliuOd-.js} +1 -1
- package/payload/server/public/assets/{kanban-definition-6JOO6SKY-CxZ0ukx3.js → kanban-definition-6JOO6SKY-DAlElMb-.js} +1 -1
- package/payload/server/public/assets/{line-DUHKCQZT.js → line-DKZqLKAC.js} +1 -1
- package/payload/server/public/assets/{linear-BgIBblun.js → linear-CbSGdh1x.js} +1 -1
- package/payload/server/public/assets/{maximize-2-_cJWIgx2.js → maximize-2-CxstTgoK.js} +1 -1
- package/payload/server/public/assets/{mermaid-parser.core-CyHygs0-.js → mermaid-parser.core-DFvbao9C.js} +2 -2
- package/payload/server/public/assets/{mermaid.core-L55fJBSx.js → mermaid.core-C0vEBxDm.js} +3 -3
- package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-DczaUX_E.js → mindmap-definition-QFDTVHPH-CShASUKd.js} +1 -1
- package/payload/server/public/assets/operator-DZzuotDB.js +1 -0
- package/payload/server/public/assets/{ordinal-DK3QISRR.js → ordinal-H0tVmBDP.js} +1 -1
- package/payload/server/public/assets/packet-4T2RLAQJ-Ckn_5hq0.js +1 -0
- package/payload/server/public/assets/{page-DbUaFfk6.js → page-3g0A19Rv.js} +6 -6
- package/payload/server/public/assets/page-Ck_pLhAk.js +1 -0
- package/payload/server/public/assets/{pdf-render-COLA4aPx.js → pdf-render-jAQU0nXt.js} +1 -1
- package/payload/server/public/assets/pie-ZZUOXDRM-DzlGQW3J.js +1 -0
- package/payload/server/public/assets/{pieDiagram-DEJITSTG-Da5TdnNt.js → pieDiagram-DEJITSTG-CBZHpDAJ.js} +1 -1
- package/payload/server/public/assets/{public-CYhDdDJd.js → public-WFUQw9AD.js} +1 -1
- package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-DX7J81uh.js → quadrantDiagram-34T5L4WZ-n3bB3K91.js} +1 -1
- package/payload/server/public/assets/radar-PYXPWWZC-BHo2YD8b.js +1 -0
- package/payload/server/public/assets/{reduce-uzWdoyL7.js → reduce-DAvwat-a.js} +1 -1
- package/payload/server/public/assets/{requirementDiagram-MS252O5E-DJQGrZPG.js → requirementDiagram-MS252O5E-DiDvQK3c.js} +1 -1
- package/payload/server/public/assets/rotate-ccw-COGQTi7n.js +1 -0
- package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-Ba8fGz96.js → sankeyDiagram-XADWPNL6-DWDQQZmd.js} +1 -1
- package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-BmDPC7qx.js → sequenceDiagram-FGHM5R23-DmAqRlBT.js} +1 -1
- package/payload/server/public/assets/{stateDiagram-FHFEXIEX-1VkptYFz.js → stateDiagram-FHFEXIEX-D4R-n6bZ.js} +1 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-BcFRbGRu.js +1 -0
- package/payload/server/public/assets/tasks-B97VpwEJ.js +1 -0
- package/payload/server/public/assets/{time-entry-format-D477WAes.js → time-entry-format-C09rDHo9.js} +1 -1
- package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-B92U3T_f.js → timeline-definition-GMOUNBTQ-CjiHGP4l.js} +1 -1
- package/payload/server/public/assets/treeView-SZITEDCU-BtRr5vXp.js +1 -0
- package/payload/server/public/assets/treemap-W4RFUUIX-D8p0sbyo.js +1 -0
- package/payload/server/public/assets/useCopyFeedback-CSk9KjhY.js +1 -0
- package/payload/server/public/assets/useSubAccountSwitcher-DLJFISqf.js +9 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-BKCWKo97.css → useSubAccountSwitcher-Dzmd7Aip.css} +1 -1
- package/payload/server/public/assets/{useVoiceRecorder-CZPtVpM-.js → useVoiceRecorder-DCyJQkFK.js} +2 -2
- package/payload/server/public/assets/{vennDiagram-DHZGUBPP-Y6Wkihrs.js → vennDiagram-DHZGUBPP-CBdDQ7c-.js} +1 -1
- package/payload/server/public/assets/wardley-RL74JXVD-DgMn-9ZJ.js +1 -0
- package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-iJpfal2z.js → wardleyDiagram-NUSXRM2D-BlIQPKLb.js} +1 -1
- package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-S0bv7oH0.js → xychartDiagram-5P7HB3ND-CslKgh9B.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 +13 -12
- package/payload/server/public/data.html +11 -11
- package/payload/server/public/graph.html +11 -10
- package/payload/server/public/index.html +14 -14
- package/payload/server/public/operator.html +15 -14
- package/payload/server/public/public.html +13 -12
- package/payload/server/public/tasks.html +5 -4
- package/payload/server/server.js +703 -555
- package/payload/server/public/assets/AdminShell-X9Bg3AKc.js +0 -2
- package/payload/server/public/assets/architecture-YZFGNWBL-Bbnxm4F4.js +0 -1
- package/payload/server/public/assets/browser-B0ieZy-b.js +0 -1
- package/payload/server/public/assets/calendar-CRL2_9Fl.js +0 -1
- package/payload/server/public/assets/channel-CatPTq-5.js +0 -1
- package/payload/server/public/assets/chat-DUc7bt5W.js +0 -1
- package/payload/server/public/assets/chevron-left-B2DKUxLk.js +0 -1
- package/payload/server/public/assets/chunk-426QAEUC-CqLMwOdA.js +0 -1
- package/payload/server/public/assets/chunk-QZHKN3VN-CjWy8NJ7.js +0 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-DHhR5rdN.js +0 -1
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-DH4pAdfu.js +0 -1
- package/payload/server/public/assets/clone-DCKzwjWW.js +0 -1
- package/payload/server/public/assets/data-C1ftMulP.js +0 -1
- package/payload/server/public/assets/file-download-CHTyUQqS.js +0 -1
- package/payload/server/public/assets/gitGraph-7Q5UKJZL-Ps5HDzLh.js +0 -1
- package/payload/server/public/assets/info-OMHHGYJF-gtlpwIig.js +0 -1
- package/payload/server/public/assets/infoDiagram-42DDH7IO-CPrWlrsa.js +0 -2
- package/payload/server/public/assets/operator-B3Mi3TW0.js +0 -1
- package/payload/server/public/assets/packet-4T2RLAQJ-DrSn1e0n.js +0 -1
- package/payload/server/public/assets/page-C1G57kPZ.js +0 -1
- package/payload/server/public/assets/pie-ZZUOXDRM-C09i6N-g.js +0 -1
- package/payload/server/public/assets/radar-PYXPWWZC-CMZN2KQH.js +0 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-BdgkPHuh.js +0 -1
- package/payload/server/public/assets/tasks-0OcRiBdQ.js +0 -1
- package/payload/server/public/assets/treeView-SZITEDCU-CeuUM5oL.js +0 -1
- package/payload/server/public/assets/treemap-W4RFUUIX-C--fAaJv.js +0 -1
- package/payload/server/public/assets/useCopyFeedback-CpfVOO26.js +0 -1
- package/payload/server/public/assets/useSubAccountSwitcher-Bo7bnFtC.js +0 -9
- package/payload/server/public/assets/wardley-RL74JXVD-4WPJ2UA9.js +0 -1
- /package/payload/server/public/assets/{_baseFor-Q4DeIqQC.js → _baseFor-D3BqAOBr.js} +0 -0
- /package/payload/server/public/assets/{array-WaOTgZu7.js → array-iYP9fzJp.js} +0 -0
- /package/payload/server/public/assets/{cytoscape.esm-CMmjo4hO.js → cytoscape.esm-BQSBzPsB.js} +0 -0
- /package/payload/server/public/assets/{defaultLocale-BxqJVxq5.js → defaultLocale-BrdA1gDi.js} +0 -0
- /package/payload/server/public/assets/{dist-Dx-cpU53.js → dist-Cvgxm7qv.js} +0 -0
- /package/payload/server/public/assets/{init-DX7c5Edh.js → init-Bx0S6pkp.js} +0 -0
- /package/payload/server/public/assets/{katex-B2dtGfSp.js → katex-BsiH_a6d.js} +0 -0
- /package/payload/server/public/assets/{path-CnSyroar.js → path-BLSgTy3w.js} +0 -0
- /package/payload/server/public/assets/{preload-helper-DqboRNgS.js → preload-helper-ClBMtM1g.js} +0 -0
- /package/payload/server/public/assets/{rough.esm-eLccZ4OJ.js → rough.esm-BMOtDaaS.js} +0 -0
- /package/payload/server/public/assets/{src-Dqs1wlnb.js → src-DV4LKv2E.js} +0 -0
package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redundant-operator-seat-audit.d.ts","sourceRoot":"","sources":["../src/redundant-operator-seat-audit.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CACD,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAA;CAC9D;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;8EAE8E;AAC9E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAEpE;AAED,2EAA2E;AAC3E,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAEvE;AAED;;;6CAG6C;AAC7C,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAkBjC;AAwBD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B;AAED;;;eAGe;AACf,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhG;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,IAAI,IAAI,CAAA;IACb,IAAI,IAAI,IAAI,CAAA;CACb;AAED;sCACsC;AACtC,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,sBAAsB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,GACpD,kBAAkB,CAiBpB"}
|
package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Task 1568 — standing redundant-operator-seat audit. A role:"client" sub-account
|
|
2
|
+
// carries exactly one identity node, its business owner (AdminUser{role:'owner'}).
|
|
3
|
+
// Any other AdminUser{accountId} on a client account is a redundant operator seat:
|
|
4
|
+
// since Task 999 admin access is install-wide, so the seat grants nothing an
|
|
5
|
+
// install-wide admin does not already have, and it fragments identity. admin-add
|
|
6
|
+
// no longer creates one going forward; this periodic read is the only signal for
|
|
7
|
+
// seats persisted before that fix, because a redundant seat emits no error and
|
|
8
|
+
// does not reproduce on demand. Detector only — removal is a deliberate
|
|
9
|
+
// remediation (Task 1569), never an automatic timer-driven delete.
|
|
10
|
+
//
|
|
11
|
+
// admin-add seats carry no au.role (role 'admin' lives on the ADMIN_OF edge), so
|
|
12
|
+
// the predicate is not-the-owner rather than a role:'admin' match. Best-effort by
|
|
13
|
+
// construction: a Neo4j-unreachable read logs `op=unavailable` rather than
|
|
14
|
+
// crashing the manager (Neo4j may not be up at boot). Shape mirrors
|
|
15
|
+
// rootless-client-audit.ts: a pure predicate + formatter (unit-tested) + an
|
|
16
|
+
// impure collector + a start/stop factory whose setInterval is unref'd.
|
|
17
|
+
import neo4j from 'neo4j-driver';
|
|
18
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
19
|
+
import { join } from 'node:path';
|
|
20
|
+
const TAG = '[identity-audit]';
|
|
21
|
+
/** The redundant-seat invariant, read side: an AdminUser on a client account is a
|
|
22
|
+
* redundant operator seat unless it is the owner. admin-add seats carry no
|
|
23
|
+
* au.role, so the predicate is not-the-owner, never a role:'admin' match. */
|
|
24
|
+
export function isRedundantOperatorSeat(role) {
|
|
25
|
+
return (role ?? '').trim() !== 'owner';
|
|
26
|
+
}
|
|
27
|
+
/** One alarm line per flagged seat; ids truncated to 8 for readability. */
|
|
28
|
+
export function formatRedundantSeatLine(f) {
|
|
29
|
+
return `${TAG} op=redundant-operator-seat account=${f.accountId.slice(0, 8)} adminUserId=${f.adminUserId.slice(0, 8)}`;
|
|
30
|
+
}
|
|
31
|
+
/** Return every non-owner AdminUser seated on the given client accounts. One
|
|
32
|
+
* round-trip: the cypher returns all AdminUser{accountId} rows for the client
|
|
33
|
+
* ids and the not-owner filter is applied in JS (same predicate the audit
|
|
34
|
+
* exposes). Empty input issues no query. */
|
|
35
|
+
export async function auditRedundantOperatorSeats(session, clientIds) {
|
|
36
|
+
if (clientIds.length === 0)
|
|
37
|
+
return [];
|
|
38
|
+
const res = await session.run(`UNWIND $ids AS id
|
|
39
|
+
MATCH (au:AdminUser {accountId: id})
|
|
40
|
+
RETURN id AS accountId, coalesce(au.userId, '') AS adminUserId, au.role AS role`, { ids: clientIds });
|
|
41
|
+
const findings = [];
|
|
42
|
+
for (const rec of res.records) {
|
|
43
|
+
if (isRedundantOperatorSeat(rec.get('role'))) {
|
|
44
|
+
findings.push({
|
|
45
|
+
accountId: String(rec.get('accountId')),
|
|
46
|
+
adminUserId: String(rec.get('adminUserId')),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return findings;
|
|
51
|
+
}
|
|
52
|
+
/** Enumerate role:"client" accountIds under the accounts root (filesystem). */
|
|
53
|
+
function clientAccountIds(accountsRoot) {
|
|
54
|
+
let entries;
|
|
55
|
+
try {
|
|
56
|
+
entries = readdirSync(accountsRoot);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
const cfgPath = join(accountsRoot, entry, 'account.json');
|
|
64
|
+
if (!existsSync(cfgPath))
|
|
65
|
+
continue;
|
|
66
|
+
try {
|
|
67
|
+
const cfg = JSON.parse(readFileSync(cfgPath, 'utf-8'));
|
|
68
|
+
if (cfg.role === 'client')
|
|
69
|
+
out.push(entry);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// unparseable account.json — excluded
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
/** Run one audit pass and log an alarm line per flagged seat. Best-effort Neo4j:
|
|
78
|
+
* absent env or an unreachable/erroring read logs `op=unavailable` and never
|
|
79
|
+
* throws. A clean pass logs a single `op=ok` line so the audit's own liveness is
|
|
80
|
+
* visible. */
|
|
81
|
+
export async function emitRedundantOperatorSeatAudit(deps) {
|
|
82
|
+
if (!deps.neo4jUri || !deps.neo4jPassword) {
|
|
83
|
+
deps.logger(`${TAG} op=unavailable reason=no-neo4j-env`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const driver = neo4j.driver(deps.neo4jUri, neo4j.auth.basic(deps.neo4jUser, deps.neo4jPassword));
|
|
87
|
+
const session = driver.session();
|
|
88
|
+
try {
|
|
89
|
+
const findings = await auditRedundantOperatorSeats(session, clientAccountIds(deps.accountsRoot));
|
|
90
|
+
if (findings.length === 0) {
|
|
91
|
+
deps.logger(`${TAG} op=ok redundant-operator-seats=0`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
for (const f of findings)
|
|
95
|
+
deps.logger(formatRedundantSeatLine(f));
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
deps.logger(`${TAG} op=unavailable reason=${err instanceof Error ? err.message : String(err)}`);
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
await session.close();
|
|
102
|
+
await driver.close();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Standing periodic audit. Unref'd interval so it never holds the process open;
|
|
106
|
+
* each tick re-emits best-effort. */
|
|
107
|
+
export function createRedundantOperatorSeatAudit(deps) {
|
|
108
|
+
let timer = null;
|
|
109
|
+
return {
|
|
110
|
+
start() {
|
|
111
|
+
if (timer)
|
|
112
|
+
return;
|
|
113
|
+
timer = setInterval(() => {
|
|
114
|
+
void emitRedundantOperatorSeatAudit(deps);
|
|
115
|
+
}, deps.intervalMs);
|
|
116
|
+
if (typeof timer.unref === 'function')
|
|
117
|
+
timer.unref();
|
|
118
|
+
},
|
|
119
|
+
stop() {
|
|
120
|
+
if (timer) {
|
|
121
|
+
clearInterval(timer);
|
|
122
|
+
timer = null;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=redundant-operator-seat-audit.js.map
|
package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redundant-operator-seat-audit.js","sourceRoot":"","sources":["../src/redundant-operator-seat-audit.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,mFAAmF;AACnF,mFAAmF;AACnF,6EAA6E;AAC7E,iFAAiF;AACjF,iFAAiF;AACjF,+EAA+E;AAC/E,wEAAwE;AACxE,mEAAmE;AACnE,EAAE;AACF,iFAAiF;AACjF,kFAAkF;AAClF,2EAA2E;AAC3E,oEAAoE;AACpE,4EAA4E;AAC5E,wEAAwE;AAExE,OAAO,KAAK,MAAM,cAAc,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,GAAG,GAAG,kBAAkB,CAAA;AAc9B;;8EAE8E;AAC9E,MAAM,UAAU,uBAAuB,CAAC,IAAmB;IACzD,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,OAAO,CAAA;AACxC,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,uBAAuB,CAAC,CAAuB;IAC7D,OAAO,GAAG,GAAG,uCAAuC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;AACxH,CAAC;AAED;;;6CAG6C;AAC7C,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAyB,EACzB,SAAmB;IAEnB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACrC,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,CAC3B;;qFAEiF,EACjF,EAAE,GAAG,EAAE,SAAS,EAAE,CACnB,CAAA;IACD,MAAM,QAAQ,GAA2B,EAAE,CAAA;IAC3C,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAC9B,IAAI,uBAAuB,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAkB,CAAC,EAAE,CAAC;YAC9D,QAAQ,CAAC,IAAI,CAAC;gBACZ,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;gBACvC,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;aAC5C,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,+EAA+E;AAC/E,SAAS,gBAAgB,CAAC,YAAoB;IAC5C,IAAI,OAAiB,CAAA;IACrB,IAAI,CAAC;QACH,OAAO,GAAG,WAAW,CAAC,YAAY,CAAC,CAAA;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;IACD,MAAM,GAAG,GAAa,EAAE,CAAA;IACxB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;QACzD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YAAE,SAAQ;QAClC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAuB,CAAA;YAC5E,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ;gBAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC5C,CAAC;QAAC,MAAM,CAAC;YACP,sCAAsC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAUD;;;eAGe;AACf,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,IAA4B;IAC/E,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,qCAAqC,CAAC,CAAA;QACxD,OAAM;IACR,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAA;IAChG,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;IAChC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,2BAA2B,CAAC,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAA;QAChG,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,mCAAmC,CAAC,CAAA;YACtD,OAAM;QACR,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,QAAQ;YAAE,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAA;IACnE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,0BAA0B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACjG,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;QACrB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IACtB,CAAC;AACH,CAAC;AAOD;sCACsC;AACtC,MAAM,UAAU,gCAAgC,CAC9C,IAAqD;IAErD,IAAI,KAAK,GAA0B,IAAI,CAAA;IACvC,OAAO;QACL,KAAK;YACH,IAAI,KAAK;gBAAE,OAAM;YACjB,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;gBACvB,KAAK,8BAA8B,CAAC,IAAI,CAAC,CAAA;YAC3C,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;YACnB,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU;gBAAE,KAAK,CAAC,KAAK,EAAE,CAAA;QACtD,CAAC;QACD,IAAI;YACF,IAAI,KAAK,EAAE,CAAC;gBACV,aAAa,CAAC,KAAK,CAAC,CAAA;gBACpB,KAAK,GAAG,IAAI,CAAA;YACd,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -2774,7 +2774,8 @@ function rowIds(users) {
|
|
|
2774
2774
|
function appendUsersAuditLine(audit, fields) {
|
|
2775
2775
|
const sess = audit.session ? ` session=${id8(audit.session)}` : "";
|
|
2776
2776
|
const actor = audit.actor.includes("-") ? id8(audit.actor) : audit.actor;
|
|
2777
|
-
const
|
|
2777
|
+
const targetFields = audit.target !== void 0 ? ` target=${audit.target.includes("-") ? id8(audit.target) : audit.target} explicitUserId=${audit.explicitUserId ? "true" : "false"}` : "";
|
|
2778
|
+
const line = `[users-audit] action=${fields.action} actor=${actor}${targetFields}${sess} field=${fields.field} rowsBefore=${fields.rowsBefore} rowsAfter=${fields.rowsAfter} ts=${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2778
2779
|
`;
|
|
2779
2780
|
try {
|
|
2780
2781
|
mkdirSync2(dirname(audit.logFile), { recursive: true, mode: 448 });
|
|
@@ -4515,7 +4516,7 @@ async function findRecentConversation(visitorId, accountId, agentSlug, maxAgeHou
|
|
|
4515
4516
|
await session.close();
|
|
4516
4517
|
}
|
|
4517
4518
|
}
|
|
4518
|
-
async function createNewAdminConversation(userId, accountId, cacheKey2,
|
|
4519
|
+
async function createNewAdminConversation(userId, accountId, cacheKey2, preMintedSessionId) {
|
|
4519
4520
|
if (!userId || !cacheKey2 || !accountId) {
|
|
4520
4521
|
console.error(`[admin/conversation-write] schema-violation userId=${userId ? "set" : "EMPTY"} cacheKey=${cacheKey2 ? "set" : "EMPTY"} accountId=${accountId ? "set" : "EMPTY"}`);
|
|
4521
4522
|
return null;
|
|
@@ -4528,7 +4529,6 @@ async function createNewAdminConversation(userId, accountId, cacheKey2, adminNam
|
|
|
4528
4529
|
WITH existing IS NULL AS adminUserCreated
|
|
4529
4530
|
MERGE (au:AdminUser {userId: $userId})
|
|
4530
4531
|
ON CREATE SET au.accountId = $accountId,
|
|
4531
|
-
au.name = COALESCE($adminName, 'Admin'),
|
|
4532
4532
|
au.createdAt = datetime(),
|
|
4533
4533
|
au.scope = 'admin'
|
|
4534
4534
|
CREATE (c:Conversation:AdminConversation {
|
|
@@ -4543,7 +4543,7 @@ async function createNewAdminConversation(userId, accountId, cacheKey2, adminNam
|
|
|
4543
4543
|
updatedAt: datetime()
|
|
4544
4544
|
})-[:STARTED_BY]->(au)
|
|
4545
4545
|
RETURN adminUserCreated`,
|
|
4546
|
-
{ sessionId, accountId, userId
|
|
4546
|
+
{ sessionId, accountId, userId }
|
|
4547
4547
|
);
|
|
4548
4548
|
const adminUserCreated = result.records[0]?.get("adminUserCreated") === true;
|
|
4549
4549
|
cacheSessionId(cacheKey2, sessionId);
|
|
@@ -5113,14 +5113,15 @@ async function getUserTimezone(accountId, userId) {
|
|
|
5113
5113
|
await session.close();
|
|
5114
5114
|
}
|
|
5115
5115
|
}
|
|
5116
|
-
async function loadAdminUserName(
|
|
5116
|
+
async function loadAdminUserName(userId) {
|
|
5117
5117
|
const session = getSession();
|
|
5118
5118
|
try {
|
|
5119
5119
|
const result = await session.run(
|
|
5120
|
-
`MATCH (au:AdminUser {userId: $userId})-[:OWNS]->(p:Person
|
|
5120
|
+
`MATCH (au:AdminUser {userId: $userId})-[:OWNS]->(p:Person)
|
|
5121
|
+
WHERE p.accountId = au.accountId
|
|
5121
5122
|
RETURN p.givenName AS givenName, p.familyName AS familyName, p.avatar AS avatar
|
|
5122
5123
|
LIMIT 1`,
|
|
5123
|
-
{
|
|
5124
|
+
{ userId }
|
|
5124
5125
|
);
|
|
5125
5126
|
if (result.records.length === 0) {
|
|
5126
5127
|
return { source: "fallback", reason: "no-person-node" };
|
|
@@ -5142,33 +5143,6 @@ async function loadAdminUserName(accountId, userId) {
|
|
|
5142
5143
|
await session.close();
|
|
5143
5144
|
}
|
|
5144
5145
|
}
|
|
5145
|
-
async function loadAdminDisplayIdentity(accountId, userId) {
|
|
5146
|
-
const session = getSession();
|
|
5147
|
-
try {
|
|
5148
|
-
const result = await session.run(
|
|
5149
|
-
`MATCH (au:AdminUser {userId: $userId})
|
|
5150
|
-
OPTIONAL MATCH (au)-[:OWNS]->(p:Person {accountId: $accountId})
|
|
5151
|
-
RETURN au.name AS name, p.avatar AS avatar
|
|
5152
|
-
LIMIT 1`,
|
|
5153
|
-
{ accountId, userId }
|
|
5154
|
-
);
|
|
5155
|
-
if (result.records.length === 0) {
|
|
5156
|
-
return { source: "fallback", reason: "no-admin-user" };
|
|
5157
|
-
}
|
|
5158
|
-
const name = result.records[0].get("name");
|
|
5159
|
-
const avatar = result.records[0].get("avatar");
|
|
5160
|
-
if (!name || name.trim().length === 0) {
|
|
5161
|
-
return { source: "fallback", reason: "no-name" };
|
|
5162
|
-
}
|
|
5163
|
-
const trimmedAvatar = avatar && avatar.trim().length > 0 ? avatar.trim() : null;
|
|
5164
|
-
return { source: "admin-user", name: name.trim(), avatar: trimmedAvatar };
|
|
5165
|
-
} catch (err) {
|
|
5166
|
-
console.error(`[admin-identity] loadAdminDisplayIdentity failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
5167
|
-
return { source: "fallback", reason: "neo4j-unreachable" };
|
|
5168
|
-
} finally {
|
|
5169
|
-
await session.close();
|
|
5170
|
-
}
|
|
5171
|
-
}
|
|
5172
5146
|
async function loadPersonNameByElementId(accountId, personId) {
|
|
5173
5147
|
const session = getSession();
|
|
5174
5148
|
try {
|
|
@@ -5226,9 +5200,9 @@ async function writeAdminUserAndPerson(params) {
|
|
|
5226
5200
|
// on the operator's first memory write. Mirrors seed-neo4j.sh:175-181
|
|
5227
5201
|
// and the sibling writers (neo4j-store.ts:537,:931). COALESCE on MATCH
|
|
5228
5202
|
// preserves an already-stamped node.
|
|
5229
|
-
ON CREATE SET au.
|
|
5203
|
+
ON CREATE SET au.createdAt = $now,
|
|
5230
5204
|
au.accountId = $accountId, au.role = 'owner'
|
|
5231
|
-
ON MATCH SET au.
|
|
5205
|
+
ON MATCH SET au.updatedAt = $now,
|
|
5232
5206
|
au.accountId = COALESCE(au.accountId, $accountId),
|
|
5233
5207
|
au.role = COALESCE(au.role, 'owner')
|
|
5234
5208
|
WITH au
|
|
@@ -5274,7 +5248,7 @@ async function writeAdminUserAndPerson(params) {
|
|
|
5274
5248
|
}
|
|
5275
5249
|
RETURN reused, profileIsNew, elementId(p) AS personElementId,
|
|
5276
5250
|
p.givenName AS givenName, p.familyName AS familyName`,
|
|
5277
|
-
{ userId,
|
|
5251
|
+
{ userId, accountId, givenName, familyName, now, personEmbedding, serverTimezone }
|
|
5278
5252
|
);
|
|
5279
5253
|
if (result.records.length === 0) {
|
|
5280
5254
|
throw new Error("writeAdminUserAndPerson: no record returned");
|
|
@@ -6020,7 +5994,6 @@ export {
|
|
|
6020
5994
|
renameConversation,
|
|
6021
5995
|
getUserTimezone,
|
|
6022
5996
|
loadAdminUserName,
|
|
6023
|
-
loadAdminDisplayIdentity,
|
|
6024
5997
|
loadPersonNameByElementId,
|
|
6025
5998
|
writeAdminUserAndPerson,
|
|
6026
5999
|
loadUserProfile,
|
package/payload/server/public/assets/{AdminLoginScreens-CMh1pdOp.js → AdminLoginScreens-DeR71H29.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-Ck5AOu5v.js";import{T as t,b as n,g as r,v as i,x as a}from"./useSubAccountSwitcher-Bo7bnFtC.js";import{E as o}from"./useVoiceRecorder-CZPtVpM-.js";import{b as s,y as c}from"./AdminShell-X9Bg3AKc.js";import{t as l}from"./Checkbox-OCfZCTCO.js";var u=`admin-landing-redirected`,d=`/graph`;function f(e){return e.variant===`operator`?!1:e.appState===`chat`&&!e.alreadyRedirected}var p=e(t(),1);function m(e=`admin`){let[t,n]=(0,p.useState)(`loading`),[r,i]=(0,p.useState)(``),[c,l]=(0,p.useState)(``),[m,h]=(0,p.useState)(``),[g,_]=(0,p.useState)(!1),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(!1),[S,C]=(0,p.useState)(!1),[w,T]=(0,p.useState)(!1),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(null),[A,j]=(0,p.useState)(void 0),[M,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(void 0),[I,L]=(0,p.useState)(null),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(void 0),H=(0,p.useRef)(void 0),[U,W]=(0,p.useState)(!1),[G,K]=(0,p.useState)(!0);(0,p.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&W(!0)}).catch(()=>{})},[]);let q=(0,p.useRef)(null),J=(0,p.useRef)(null);(0,p.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();D(r.session_key),z(r.sessionId??null),j(r.businessName),N(r.role??null),F(r.userName===void 0?null:r.userName),L(r.avatar??null);let i=o(r.thinkingView);return H.current=i,V(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}K(!!a.claude_authenticated);let o=!1;try{o=new URLSearchParams(window.location.search).get(`connect`)===`claude`}catch{}if(o){try{let e=new URL(window.location.href);e.searchParams.delete(`connect`),window.history.replaceState(null,``,e.pathname+e.search+e.hash)}catch{}if(!a.claude_authenticated){n(`connect-claude`);return}}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,p.useEffect)(()=>{t===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&k(e)}).catch(()=>{})},[t]),(0,p.useEffect)(()=>{if(typeof window>`u`)return;let n=!1;try{n=sessionStorage.getItem(u)===`1`}catch{}if(f({appState:t,alreadyRedirected:n,variant:e})){try{sessionStorage.setItem(u,`1`)}catch{}console.info(`[admin-ui] landing-redirect target=${d}`),window.location.replace(d)}},[t,e]);let Y=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();K(t.auth_status!==`dead`&&t.auth_status!==`missing`)}}catch{}if(E)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(E)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){a(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),Y.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,E]),(0,p.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&(K(!0),n(`enter-pin`))}).catch(()=>{})},[t]);async function X(e,t){y(!0);try{let r=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!r.ok){let e=await r.json().catch(()=>({}));if(r.status===401&&e?.code===`remote-auth-required`){a(`enter-pin`,`/api/admin/session`);return}h(e.error||`Invalid PIN`);return}let s=await r.json();D(s.session_key),z(s.sessionId??null),j(s.businessName),N(s.role??null),F(s.userName===void 0?null:s.userName),L(s.avatar??null);let c=o(s.thinkingView);H.current=c,V(c);try{sessionStorage.setItem(`maxy-admin-session-key`,s.session_key)}catch{}i(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}}let Z=(0,p.useCallback)(async e=>{if(e.preventDefault(),v)return;h(``);let t=c.trim();if(!t){h(`Please enter your name.`);return}if(r.length<4){h(`PIN must be at least 4 characters.`);return}let o=r;y(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:o,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){a(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):h(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}h(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await X(o);return}i(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}},[r,v,c]),Q=(0,p.useCallback)(async e=>{e.preventDefault(),h(``),await X(r)},[r]),ee=(0,p.useCallback)(async()=>{T(!0);try{if(!await s())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;K(!1),D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}return n(`connect-claude`),!0}finally{T(!1)}},[]),$=(0,p.useCallback)(()=>{D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}i(``),h(``),n(`enter-pin`)},[]);return(0,p.useEffect)(()=>{Y.current=$},[$]),{appState:t,setAppState:n,pin:r,setPin:i,operatorName:c,setOperatorName:l,pinError:m,setPinError:h,showPin:g,setShowPin:_,pinLoading:v,authPolling:b,setAuthPolling:x,authLoading:S,setAuthLoading:C,disconnecting:w,cacheKey:E,setCacheKey:D,claudeInfo:O,setClaudeInfo:k,businessName:A,role:M,userName:P,userAvatar:I,sessionId:R,setSessionId:z,expandAll:B,setExpandAll:V,expandAllDefaultRef:H,remoteAuthEnabled:U,claudeConnected:G,pinInputRef:q,setPinFormRef:J,handleSetPin:Z,handleLogin:Q,handleDisconnect:ee,handleLogout:$}}var h=n();function g({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,p.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,h.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,h.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function _(e){let{pin:t,setPin:n,showPin:a,setShowPin:o,pinLoading:s,pinError:u,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:m,setOperatorName:_}=e;return(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:i,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,r.productName]}),(0,h.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,r.productName,` who you are, then choose a PIN.`]}),(0,h.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:m,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,h.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:a}),(0,h.jsx)(c,{variant:`send`,type:`submit`,disabled:!t||!m.trim(),loading:s,"aria-label":`Set PIN`,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(l,{checked:a,onChange:()=>o(e=>!e),label:`Show PIN`})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})})}function v(e){let{pin:t,setPin:n,showPin:a,setShowPin:o,pinLoading:s,pinError:u,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:m}=e;return(0,h.jsxs)(`div`,{className:`connect-page`,children:[p&&m&&(0,h.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:m,children:`Sign out`}),(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:i,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,h.jsx)(`h1`,{className:`connect-title`,children:r.productName}),(0,h.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:a,autoFocus:!0}),(0,h.jsx)(c,{variant:`send`,type:`submit`,disabled:!t,loading:s,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(`div`,{className:`pin-options`,children:(0,h.jsx)(l,{checked:a,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function y(e){let{authPolling:t,setAuthPolling:n,authLoading:a,setAuthLoading:o,pinError:s,setPinError:l,setAppState:u}=e,[d,f]=(0,p.useState)(!1),[m,g]=(0,p.useState)(!1),[_,v]=(0,p.useState)(``),[y,b]=(0,p.useState)(``),[x,S]=(0,p.useState)(``);async function C(){S(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`paste-code`,code:y})})).json();e.accepted?(S(`Code submitted. Finishing sign-in…`),b(``)):S(e.error||`Could not submit code.`)}catch(e){console.error(`[admin] paste-code error:`,e),S(`Could not submit code.`)}}async function w(){g(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?f(!0):e.error&&l(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),l(`Could not launch browser.`)}g(!1)}async function T(){o(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){n(!0),f(!0),o(!1),v(e.transport||``);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}l(`Timed out waiting for sign-in. Try again.`),n(!1)}else e.error&&l(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),l(`Could not start auth flow.`)}o(!1)}async function E(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),n(!1),l(``)}return t||d?(0,h.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,h.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[t?(0,h.jsx)(`button`,{onClick:E,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,h.jsx)(`button`,{onClick:()=>f(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,h.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,h.jsx)(`p`,{className:`chat-intro`,children:t?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!t&&(0,h.jsx)(`div`,{style:{marginTop:`12px`},children:(0,h.jsx)(c,{variant:`primary`,onClick:T,disabled:a,children:a?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})}),t&&_===`native`&&(0,h.jsxs)(`div`,{style:{marginTop:`14px`,maxWidth:`420px`,margin:`14px auto 0`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,h.jsx)(`label`,{style:{fontSize:`12px`,color:`#999`,lineHeight:1.4},children:`If the browser didn't finish sign-in, paste the code or full redirect URL from Claude's page:`}),(0,h.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,h.jsx)(`input`,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`Paste code or redirect URL`,style:{flex:1,padding:`8px 10px`,fontSize:`13px`,border:`1px solid #ccc`,borderRadius:`6px`}}),(0,h.jsx)(c,{variant:`primary`,onClick:C,disabled:!y.trim(),children:`Submit`})]}),x&&(0,h.jsx)(`p`,{style:{fontSize:`12px`,color:`#999`,margin:0},children:x})]})]}),(0,h.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,h.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),s&&(0,h.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsxs)(`div`,{className:`connect-logos`,children:[(0,h.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,h.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,h.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,h.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,h.jsx)(`img`,{src:i,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,h.jsx)(`span`,{className:`connect-logo-label`,children:r.productName})]})]}),(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,r.productName]}),(0,h.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,h.jsx)(c,{variant:`primary`,onClick:T,disabled:a,children:a?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,h.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),(0,h.jsx)(`button`,{onClick:w,disabled:m,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:m?`Launching…`:`Open browser first`}),s&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function b({auth:e}){return e.appState===`loading`?(0,h.jsx)(`div`,{className:`connect-page`}):e.appState===`set-pin`?(0,h.jsx)(_,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,setPinFormRef:e.setPinFormRef,onSubmit:e.handleSetPin,operatorName:e.operatorName,setOperatorName:e.setOperatorName}):e.appState===`connect-claude`?(0,h.jsx)(y,{authPolling:e.authPolling,setAuthPolling:e.setAuthPolling,authLoading:e.authLoading,setAuthLoading:e.setAuthLoading,pinError:e.pinError,setPinError:e.setPinError,setAppState:e.setAppState}):e.appState===`enter-pin`?(0,h.jsx)(v,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,onSubmit:e.handleLogin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):null}export{m as n,b as t};
|
|
1
|
+
import{o as e}from"./chunk-Ck5AOu5v.js";import{E as t,S as n,_ as r,x as i,y as a}from"./useSubAccountSwitcher-DLJFISqf.js";import{E as o}from"./useVoiceRecorder-DCyJQkFK.js";import{b as s,y as c}from"./AdminShell-DlAVQUda.js";import{t as l}from"./Checkbox-B629mOPp.js";var u=`admin-landing-redirected`,d=`/graph`;function f(e){return e.variant===`operator`?!1:e.appState===`chat`&&!e.alreadyRedirected}var p=e(t(),1);function m(e=`admin`){let[t,r]=(0,p.useState)(`loading`),[i,a]=(0,p.useState)(``),[c,l]=(0,p.useState)(``),[m,h]=(0,p.useState)(``),[g,_]=(0,p.useState)(!1),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(!1),[S,C]=(0,p.useState)(!1),[w,T]=(0,p.useState)(!1),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(null),[A,j]=(0,p.useState)(void 0),[M,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(void 0),[I,L]=(0,p.useState)(null),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(void 0),H=(0,p.useRef)(void 0),[U,W]=(0,p.useState)(!1),[G,K]=(0,p.useState)(!0);(0,p.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&W(!0)}).catch(()=>{})},[]);let q=(0,p.useRef)(null),J=(0,p.useRef)(null);(0,p.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let n=await t.json();D(n.session_key),z(n.sessionId??null),j(n.businessName),N(n.role??null),F(n.userName===void 0?null:n.userName),L(n.avatar??null);let i=o(n.thinkingView);return H.current=i,V(i),r(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(n=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(n>0)return await new Promise(e=>setTimeout(e,1500)),t(n-1);console.error(`[admin] health check returned ${i.status} after retries`),r(`set-pin`);return}let a=await i.json();if(!a.pin_configured){r(`set-pin`);return}K(!!a.claude_authenticated);let o=!1;try{o=new URLSearchParams(window.location.search).get(`connect`)===`claude`}catch{}if(o){try{let e=new URL(window.location.href);e.searchParams.delete(`connect`),window.history.replaceState(null,``,e.pathname+e.search+e.hash)}catch{}if(!a.claude_authenticated){r(`connect-claude`);return}}if(await e())return;r(`enter-pin`)}catch(e){if(n>0)return await new Promise(e=>setTimeout(e,1500)),t(n-1);console.error(`[admin] health check failed:`,e),r(`set-pin`)}}t()},[]),(0,p.useEffect)(()=>{t===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&k(e)}).catch(()=>{})},[t]),(0,p.useEffect)(()=>{if(typeof window>`u`)return;let n=!1;try{n=sessionStorage.getItem(u)===`1`}catch{}if(f({appState:t,alreadyRedirected:n,variant:e})){try{sessionStorage.setItem(u,`1`)}catch{}console.info(`[admin-ui] landing-redirect target=${d}`),window.location.replace(d)}},[t,e]);let Y=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();K(t.auth_status!==`dead`&&t.auth_status!==`missing`)}}catch{}if(E)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(E)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){n(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),Y.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,E]),(0,p.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&(K(!0),r(`enter-pin`))}).catch(()=>{})},[t]);async function X(e,t){y(!0);try{let i=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!i.ok){let e=await i.json().catch(()=>({}));if(i.status===401&&e?.code===`remote-auth-required`){n(`enter-pin`,`/api/admin/session`);return}h(e.error||`Invalid PIN`);return}let s=await i.json();D(s.session_key),z(s.sessionId??null),j(s.businessName),N(s.role??null),F(s.userName===void 0?null:s.userName),L(s.avatar??null);let c=o(s.thinkingView);H.current=c,V(c);try{sessionStorage.setItem(`maxy-admin-session-key`,s.session_key)}catch{}a(``),r(`chat`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}}let Z=(0,p.useCallback)(async e=>{if(e.preventDefault(),v)return;h(``);let t=c.trim();if(!t){h(`Please enter your name.`);return}if(i.length<4){h(`PIN must be at least 4 characters.`);return}let o=i;y(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:o,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){n(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);try{let e=await fetch(`/api/health`);if(e.ok){let n=await e.json();n.pin_configured&&n.claude_authenticated?r(`enter-pin`):n.pin_configured?r(`connect-claude`):h(t.error||`Failed to set PIN.`)}else r(`enter-pin`)}catch{r(`enter-pin`)}return}h(t.error||`Failed to set PIN.`);return}let i=await fetch(`/api/health`);if((i.ok?await i.json():null)?.claude_authenticated){await X(o);return}a(``),r(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}},[i,v,c]),Q=(0,p.useCallback)(async e=>{e.preventDefault(),h(``),await X(i)},[i]),ee=(0,p.useCallback)(async()=>{T(!0);try{if(!await s())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;K(!1),D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}return r(`connect-claude`),!0}finally{T(!1)}},[]),$=(0,p.useCallback)(()=>{D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}a(``),h(``),r(`enter-pin`)},[]);return(0,p.useEffect)(()=>{Y.current=$},[$]),{appState:t,setAppState:r,pin:i,setPin:a,operatorName:c,setOperatorName:l,pinError:m,setPinError:h,showPin:g,setShowPin:_,pinLoading:v,authPolling:b,setAuthPolling:x,authLoading:S,setAuthLoading:C,disconnecting:w,cacheKey:E,setCacheKey:D,claudeInfo:O,setClaudeInfo:k,businessName:A,role:M,userName:P,userAvatar:I,sessionId:R,setSessionId:z,expandAll:B,setExpandAll:V,expandAllDefaultRef:H,remoteAuthEnabled:U,claudeConnected:G,pinInputRef:q,setPinFormRef:J,handleSetPin:Z,handleLogin:Q,handleDisconnect:ee,handleLogout:$}}var h=i();function g({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,p.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,h.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,h.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function _(e){let{pin:t,setPin:n,showPin:i,setShowPin:o,pinLoading:s,pinError:u,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:m,setOperatorName:_}=e;return(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:a,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,r.productName]}),(0,h.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,r.productName,` who you are, then choose a PIN.`]}),(0,h.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:m,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,h.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:i}),(0,h.jsx)(c,{variant:`send`,type:`submit`,disabled:!t||!m.trim(),loading:s,"aria-label":`Set PIN`,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})})}function v(e){let{pin:t,setPin:n,showPin:i,setShowPin:o,pinLoading:s,pinError:u,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:m}=e;return(0,h.jsxs)(`div`,{className:`connect-page`,children:[p&&m&&(0,h.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:m,children:`Sign out`}),(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:a,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,h.jsx)(`h1`,{className:`connect-title`,children:r.productName}),(0,h.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:i,autoFocus:!0}),(0,h.jsx)(c,{variant:`send`,type:`submit`,disabled:!t,loading:s,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(`div`,{className:`pin-options`,children:(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function y(e){let{authPolling:t,setAuthPolling:n,authLoading:i,setAuthLoading:o,pinError:s,setPinError:l,setAppState:u}=e,[d,f]=(0,p.useState)(!1),[m,g]=(0,p.useState)(!1),[_,v]=(0,p.useState)(``),[y,b]=(0,p.useState)(``),[x,S]=(0,p.useState)(``);async function C(){S(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`paste-code`,code:y})})).json();e.accepted?(S(`Code submitted. Finishing sign-in…`),b(``)):S(e.error||`Could not submit code.`)}catch(e){console.error(`[admin] paste-code error:`,e),S(`Could not submit code.`)}}async function w(){g(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?f(!0):e.error&&l(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),l(`Could not launch browser.`)}g(!1)}async function T(){o(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){n(!0),f(!0),o(!1),v(e.transport||``);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}l(`Timed out waiting for sign-in. Try again.`),n(!1)}else e.error&&l(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),l(`Could not start auth flow.`)}o(!1)}async function E(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),n(!1),l(``)}return t||d?(0,h.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,h.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[t?(0,h.jsx)(`button`,{onClick:E,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,h.jsx)(`button`,{onClick:()=>f(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,h.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,h.jsx)(`p`,{className:`chat-intro`,children:t?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!t&&(0,h.jsx)(`div`,{style:{marginTop:`12px`},children:(0,h.jsx)(c,{variant:`primary`,onClick:T,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})}),t&&_===`native`&&(0,h.jsxs)(`div`,{style:{marginTop:`14px`,maxWidth:`420px`,margin:`14px auto 0`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,h.jsx)(`label`,{style:{fontSize:`12px`,color:`#999`,lineHeight:1.4},children:`If the browser didn't finish sign-in, paste the code or full redirect URL from Claude's page:`}),(0,h.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,h.jsx)(`input`,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`Paste code or redirect URL`,style:{flex:1,padding:`8px 10px`,fontSize:`13px`,border:`1px solid #ccc`,borderRadius:`6px`}}),(0,h.jsx)(c,{variant:`primary`,onClick:C,disabled:!y.trim(),children:`Submit`})]}),x&&(0,h.jsx)(`p`,{style:{fontSize:`12px`,color:`#999`,margin:0},children:x})]})]}),(0,h.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,h.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),s&&(0,h.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsxs)(`div`,{className:`connect-logos`,children:[(0,h.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,h.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,h.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,h.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,h.jsx)(`img`,{src:a,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,h.jsx)(`span`,{className:`connect-logo-label`,children:r.productName})]})]}),(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,r.productName]}),(0,h.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,h.jsx)(c,{variant:`primary`,onClick:T,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,h.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),(0,h.jsx)(`button`,{onClick:w,disabled:m,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:m?`Launching…`:`Open browser first`}),s&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function b({auth:e}){return e.appState===`loading`?(0,h.jsx)(`div`,{className:`connect-page`}):e.appState===`set-pin`?(0,h.jsx)(_,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,setPinFormRef:e.setPinFormRef,onSubmit:e.handleSetPin,operatorName:e.operatorName,setOperatorName:e.setOperatorName}):e.appState===`connect-claude`?(0,h.jsx)(y,{authPolling:e.authPolling,setAuthPolling:e.setAuthPolling,authLoading:e.authLoading,setAuthLoading:e.setAuthLoading,pinError:e.pinError,setPinError:e.setPinError,setAppState:e.setAppState}):e.appState===`enter-pin`?(0,h.jsx)(v,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,onSubmit:e.handleLogin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):null}export{m as n,b as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{o as e}from"./chunk-Ck5AOu5v.js";import{E as t,T as n,_ as r,a as i,b as a,d as o,g as s,i as c,l,m as u,n as d,o as f,p,s as m,t as h,u as g,x as _}from"./useSubAccountSwitcher-DLJFISqf.js";import{a as ee,d as v,f as te,l as ne,m as re,n as ie,o as ae,p as oe,s as se,u as ce}from"./file-download-4mKJxUi-.js";async function y(){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 b=e(t(),1),x=_(),S={sm:14,md:16,lg:18},C={sm:30,md:38,lg:46};function w({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=S[t],h={...e===`send`?{width:C[t],height:C[t]}:{},...u},g=Object.keys(h).length>0;return(0,x.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,x.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,x.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,x.jsx)(n,{size:m})]}),i&&(0,x.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var le=s(`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`}]]),T=s(`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`}]]),E=s(`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`}]]),ue=s(`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`}]]),D=s(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),de=s(`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`}]]),fe=s(`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`}]]),pe=s(`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`}]]),O=s(`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`}]]),me=s(`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`}]]),k=`maxy-shell-side-px`;function A(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function j(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-A());return Math.min(Math.max(e,248),n)}function he(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(k);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 j(t)}catch{}return 264}function ge({targetSelector:e=`.platform`}){let t=(0,b.useRef)(null),[n,r]=(0,b.useState)(()=>he()),i=(0,b.useRef)(n);(0,b.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,b.useCallback)(()=>{r(e=>{let t=j(e);return t===e?e:t})},[]);(0,b.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(j(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(k,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=j(264);r(e);try{window.localStorage.removeItem(k)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,x.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var M=n();function _e({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,b.useRef)(null),[s,c]=(0,b.useState)({position:`fixed`,visibility:`hidden`}),l=(0,b.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,b.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,b.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,M.createPortal)((0,x.jsx)(`div`,{ref:o,className:n,role:r,"aria-label":i,style:s,children:a}),document.body)}function ve({actions:e,disabled:t}){let[n,r]=(0,b.useState)(!1),[i,a]=(0,b.useState)(null),o=(0,b.useRef)(null),s=(0,b.useCallback)(()=>{r(!1),a(null)},[]);return(0,x.jsxs)(`div`,{className:`conv-actions`,children:[(0,x.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,x.jsx)(g,{size:12})}),n&&(0,x.jsx)(_e,{anchorRef:o,onClose:s,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,x.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,x.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,x.jsx)(`span`,{children:e.menuLabel})]}),i===e.key&&(0,x.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,x.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,x.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var N=`claude-opus-4-8[1m]`,P=`claude-sonnet-5`,F=`claude-haiku-4-5`,I={[N]:`Opus 4.8 (1M context)`,[P]:`Sonnet 5`,[F]:`Haiku 4.5`};function L(e){return I[e]??e}var R=[N,P,F];function z(e){return e.replace(/\[1m\]$/,``)}function ye(e){return R.find(t=>z(t)===z(e))??e}var be=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],B=[`low`,`medium`,`high`,`xhigh`];[...be],[...B],[...B];var xe=[N,P,F],Se={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},Ce=be.map(e=>({value:e,label:Se[e]??e})),we={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},Te=B.map(e=>({value:e,label:we[e]??e}));function V(e){if(e){let t=xe.find(t=>z(t)===z(e));if(t)return t}return N}function Ee({row:e,adminFetch:t,onError:n}){let[r,i]=(0,b.useState)(()=>V(e.model)),[a,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(``),[u,d]=(0,b.useState)(!1),f=(0,b.useRef)(!1);(0,b.useEffect)(()=>{i(V(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,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`label`,{className:`reseat-field`,children:[(0,x.jsx)(`span`,{children:`Model`}),(0,x.jsx)(`select`,{"data-kind":`model`,value:r,disabled:u,onChange:e=>i(e.target.value),children:xe.map(e=>(0,x.jsx)(`option`,{value:e,children:L(e)},e))})]}),(0,x.jsxs)(`label`,{className:`reseat-field`,children:[(0,x.jsx)(`span`,{children:`Mode`}),(0,x.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:u,onChange:e=>s(e.target.value),children:[(0,x.jsx)(`option`,{value:``,children:`Keep current`}),Ce.map(e=>(0,x.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,x.jsxs)(`label`,{className:`reseat-field`,children:[(0,x.jsx)(`span`,{children:`Effort`}),(0,x.jsxs)(`select`,{"data-kind":`effort`,value:c,disabled:u,onChange:e=>l(e.target.value),children:[(0,x.jsx)(`option`,{value:``,children:`Keep current`}),Te.map(e=>(0,x.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,x.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:u,"aria-busy":u,onClick:()=>void p(),children:u?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(o,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function H(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 De(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}async function U(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Oe({target:e,onConfirm:t,onCancel:n}){return e?(0,x.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,x.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete session`,children:[(0,x.jsxs)(`div`,{className:`claude-info-header`,children:[(0,x.jsx)(`span`,{children:`Delete this conversation?`}),(0,x.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,x.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`,e.live&&(0,x.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,x.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,x.jsx)(w,{variant:`danger`,size:`sm`,style:{flex:1},onClick:t,children:`Delete`}),(0,x.jsx)(w,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:n,children:`Cancel`})]})]})}):null}var ke=`auth-refresh-failed`;function Ae({error:e,onClose:t}){if(!e)return null;let n=e.reason===ke,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,x.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,x.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,x.jsxs)(`div`,{className:`claude-info-header`,children:[(0,x.jsx)(`span`,{children:r}),(0,x.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,x.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,x.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,x.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function je(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,b.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,_=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,x.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,x.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,x.jsxs)(`div`,{className:`claude-info-header`,children:[(0,x.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,x.jsx)(`span`,{children:`Claude Code`}),(0,x.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,x.jsxs)(`div`,{className:`claude-info-section`,children:[(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,x.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,x.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,x.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,x.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,x.jsxs)(`div`,{className:`claude-info-section`,children:[(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:p>0?De(p):`—`})]}),(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:H(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,x.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 U(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function Me({open:e,onConnect:t,onClose:n}){return e?(0,x.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,x.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,x.jsxs)(`div`,{className:`claude-info-header`,children:[(0,x.jsx)(`span`,{children:`Claude isn’t connected`}),(0,x.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,x.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,x.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,x.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,x.jsx)(w,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,x.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function W(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 Ne(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function G(e){return e.toLocaleString(`en-GB`)}function K(e){return`£${e.toFixed(2)}`}function Pe(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,W(Ne(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 q({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,x.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,x.jsx)(r,{className:`usage-day`,children:e}),(0,x.jsx)(r,{children:W(Ne(t))}),(0,x.jsx)(r,{children:G(t.tokens.output)}),(0,x.jsx)(r,{children:G(t.tokens.input)}),(0,x.jsx)(r,{children:G(t.tokens.cacheWrite)}),(0,x.jsx)(r,{children:G(t.tokens.cacheRead)}),(0,x.jsx)(r,{children:K(t.costGBP.opus)}),(0,x.jsx)(r,{children:K(t.costGBP.sonnet)})]})}function Fe({show:e,onClose:t,sessionId:n,summary:r,loading:a,error:o}){if(!e)return null;let s=!!r&&r.days.length>0,c=()=>{if(!r)return;let e=new Blob([Pe(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,x.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,x.jsxs)(`div`,{className:`claude-info-modal usage-modal`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Session usage and cost`,children:[(0,x.jsxs)(`div`,{className:`claude-info-header`,children:[(0,x.jsxs)(`span`,{children:[`Usage & cost`,n?` · ${n.slice(0,8)}`:``]}),s&&(0,x.jsx)(`button`,{className:`usage-download`,onClick:c,"aria-label":`Download as CSV`,title:`Download as CSV`,children:(0,x.jsx)(re,{size:14})}),(0,x.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,x.jsx)(i,{size:14})})]}),(0,x.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[a&&(0,x.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!a&&o&&(0,x.jsx)(`div`,{className:`usage-note usage-error`,children:o}),!a&&!o&&r&&r.days.length===0&&(0,x.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!a&&!o&&r&&r.days.length>0&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`usage-table-scroll`,children:(0,x.jsxs)(`table`,{className:`usage-table`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,x.jsx)(`th`,{children:`Active`}),(0,x.jsx)(`th`,{children:`Output tok`}),(0,x.jsx)(`th`,{children:`Input tok`}),(0,x.jsx)(`th`,{children:`Cache write`}),(0,x.jsx)(`th`,{children:`Cache read`}),(0,x.jsx)(`th`,{children:`Opus 4.8 (£)`}),(0,x.jsx)(`th`,{children:`Sonnet 4.6 (£)`})]})}),(0,x.jsxs)(`tbody`,{children:[r.days.map(e=>(0,x.jsx)(q,{label:e.date,d:e},e.date)),(0,x.jsx)(q,{label:`TOTAL (${r.days.length} d)`,d:r.totals,bold:!0})]})]})}),(0,x.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 Ie=`https://claude.ai/code`,Le=200,Re=[500,1e3,1500,2e3,2500,3e3,3e3];function ze(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:`${Ie}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function Be(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Ve(e){let{businessName:t,cacheKey:n,onConnectClaude:i,role:o,userName:s,userAvatar:d,onSelectProjects:h,onSelectPeople:g,onSelectTasks:_,onSelectAgents:y,onCloseMobileDrawer:S,collapsed:C,selectedWhatsappId:w,onSelectWhatsappConversation:k,initialWhatsappSurface:A=!1,onSelectData:j,onCloseData:he,initialDataSurface:ge=!1}=e,M=c(n),_e=(0,b.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,x.jsx)(O,{size:12}),panel:()=>(0,x.jsx)(Ee,{row:e,adminFetch:M,onError:e=>H({message:e,failed:!0})})}),[M]),N=r.productName,P=typeof s==`string`?s:s===null?`name unavailable`:t||N,F=(P.trim().charAt(0)||`?`).toUpperCase(),[I,L]=(0,b.useState)(ge?`data`:A?`whatsapp`:`sessions`),[R,z]=(0,b.useState)([]),[ye,be]=(0,b.useState)(!1),[B,xe]=(0,b.useState)(null),[Se,Ce]=(0,b.useState)(!1),[we,Te]=(0,b.useState)(`file`),[V,H]=(0,b.useState)(null),[De,U]=(0,b.useState)(null),[ke,je]=(0,b.useState)(!1),[W,Ne]=(0,b.useState)([]),[G]=(0,b.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`session`)),[K,Pe]=(0,b.useState)(!1),[q,Ie]=(0,b.useState)(null),[Ve,He]=(0,b.useState)(!1),[J,Ke]=(0,b.useState)(!1),[Y,qe]=(0,b.useState)(!1),[Je,Ye]=(0,b.useState)(null),[X,Xe]=(0,b.useState)(new Set),[Ze,Qe]=(0,b.useState)(null),[$e,et]=(0,b.useState)(new Set),[tt,nt]=(0,b.useState)(new Set),[rt,it]=(0,b.useState)(new Set),[at,ot]=(0,b.useState)(null),[st,ct]=(0,b.useState)(``),[lt,ut]=(0,b.useState)(!1),[dt,ft]=(0,b.useState)(null),[pt,mt]=(0,b.useState)(null),[ht,gt]=(0,b.useState)(!1),[_t,vt]=(0,b.useState)(null),[Z,yt]=(0,b.useState)(!1),bt=(0,b.useRef)(0),[xt,St]=(0,b.useState)([]),[Ct,wt]=(0,b.useState)(!1),[Tt,Et]=(0,b.useState)(null),[Dt,Ot]=(0,b.useState)(`whatsapp`),kt=(0,b.useCallback)(e=>{if(S(),!n){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),H({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`),H({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}`),ie(n,e.downloadPath,e.downloadRoot??`data`),H({message:`Downloading ${e.name}`,failed:!1})},[n,S]);(0,b.useEffect)(()=>{if(!V)return;let e=setTimeout(()=>H(null),2500);return()=>clearTimeout(e)},[V]);let At=G!=null&&W.some(e=>e.sessionId===G);(0,b.useEffect)(()=>{G==null||!K||console.info(`[sidebar-sessions] op=select-highlight session=${G.slice(0,8)} matched=${At}`)},[G,At,K]);let jt=(0,b.useCallback)(async()=>{if(n){Ce(!0),xe(null);try{let e=await M(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);z((await e.json()).artefacts??[]),be(!0)}catch(e){let t=e instanceof Error?e.message:String(e);xe(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{Ce(!1)}}},[n,M]),Q=(0,b.useCallback)(async()=>{if(!n)return null;let e=++bt.current;He(!0),Ie(null);try{let t=await M(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===bt.current?(Ne(r),Ye(n.accountId??null),Pe(!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===bt.current&&Ie(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===bt.current&&He(!1)}},[n,M]),Mt=(0,b.useCallback)(async()=>{if(n){Et(null);try{let e=await M(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);St((await e.json()).conversations??[]),wt(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Et(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[n,M]);(0,b.useEffect)(()=>{!n||K||Q()},[n,K,Q]),(0,b.useEffect)(()=>{if(!n)return;let e=null;return Mt(),e=setInterval(()=>{Mt()},Ue),()=>{e!==null&&clearInterval(e)}},[n,Mt]),(0,b.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,We))}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 Nt=(0,b.useMemo)(()=>{let e=new Map;for(let t of ae)e.set(t,[]);for(let t of xt)e.get(t.channel)?.push(t);for(let t of ae)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[xt]),Pt={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},Ft=()=>{k(null),L(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${ye?R.length:0} collapsed=${C}`),jt()},$=1.5,It=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),jt()},Lt=()=>{k(null),L(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${K?W.length:0} collapsed=${C}`),K||Q()},Rt=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},zt=()=>{L(`data`),console.info(`[admin-ui] sidebar-nav surface=data collapsed=${C}`),j(),S()},Bt=e=>{he?.(),L(`whatsapp`),Ot(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${Nt.get(e)?.length??0} collapsed=${C}`)},Vt=(0,b.useCallback)(async e=>{if($e.has(e.sessionId))return;et(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await M(`/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=ze(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`?(S(),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}`),U(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}`),U({sessionId:e.sessionId,reason:r})}finally{et(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[M,S,$e]),Ht=(0,b.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=Re.length;n++){await new Promise(e=>setTimeout(e,Re[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]),Ut=(0,b.useCallback)(async()=>{if(!Z){yt(!0);try{let e=await M(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>({})),n=ze(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?Ht(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`),je(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),U(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),U({sessionId:null,reason:t})}finally{yt(!1)}}},[M,Z,Ht]),Wt=(0,b.useCallback)((e,t)=>{e.stopPropagation(),Qe(t)},[]),Gt=(0,b.useCallback)(async(e,t)=>{e.stopPropagation(),ft(t),mt(null),vt(null),gt(!0);try{let e=await M(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?mt(n):vt(n.error??`status ${e.status}`)}catch(e){vt(e instanceof Error?e.message:String(e))}finally{gt(!1)}},[M]),Kt=(0,b.useCallback)(async e=>{if(!X.has(e.sessionId)){Xe(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await M(`/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(()=>({}));console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),H({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0});return}let n=await t.json();console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${n.pidKilled??`?`} deleted=${n.deleted??`?`}`),Ne(t=>t.filter(t=>t.sessionId!==e.sessionId)),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),H({message:`Delete failed: ${n}`,failed:!0})}finally{Xe(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}}},[M,X,Q]),qt=(0,b.useCallback)(async(e,t)=>{if(e.stopPropagation(),!tt.has(t.sessionId)){nt(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await M(`/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`}`),H({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}`),H({message:`Stop failed: ${n}`,failed:!0})}finally{nt(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,tt,Q]),Jt=(0,b.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!rt.has(t.sessionId)){it(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await M(`/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`}`),H({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}`),H({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{it(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,rt,Q]),Yt=(0,b.useCallback)(async e=>{let t=st.trim();if(!t){H({message:`Title can’t be empty`,failed:!0});return}if(t.length>Le){H({message:`Title too long (max ${Le})`,failed:!0});return}ut(!0);try{let n=await M(`/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}`),H({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),ot(null),ct(``),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}`),H({message:`Rename failed: ${n}`,failed:!0})}finally{ut(!1)}},[M,st,Q]);return(0,x.jsxs)(`aside`,{className:`side`,children:[(0,x.jsx)(`div`,{className:`side-new-session-row`,children:(0,x.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:Ut,disabled:Z,"aria-busy":Z,children:[(0,x.jsx)(te,{size:14}),(0,x.jsx)(`span`,{children:Z?`Spawning…`:`New session`})]})}),(0,x.jsxs)(`nav`,{className:`side-nav`,children:[(0,x.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),g(),S()},children:[(0,x.jsx)(me,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`People`}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),y(),S()},children:[(0,x.jsx)(E,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`Agents`}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),h(),S()},children:[(0,x.jsx)(ue,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:a().term}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),_(),S()},children:[(0,x.jsx)(fe,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row${I===`artefacts`?` active`:``}`,onClick:Ft,children:[(0,x.jsx)(oe,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row${I===`sessions`?` active`:``}`,onClick:Lt,children:[(0,x.jsx)(de,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row${I===`data`?` active`:``}`,onClick:zt,children:[(0,x.jsx)(u,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`Data`}),(0,x.jsx)(`span`,{className:`kbd`})]}),Ct&&ae.filter(e=>Nt.get(e).length>0).map(e=>(0,x.jsxs)(`button`,{type:`button`,className:`nav-row${I===`whatsapp`&&Dt===e?` active`:``}`,onClick:()=>Bt(e),children:[(0,x.jsx)(ne,{channel:e,size:16}),(0,x.jsx)(`span`,{className:`label`,children:Pt[e]}),(0,x.jsx)(`span`,{className:`kbd`})]},e)),Tt&&(0,x.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,x.jsx)(`span`,{className:`label`,children:Tt})})]}),I===`artefacts`&&(0,x.jsxs)(`div`,{className:`side-list`,children:[(0,x.jsxs)(`div`,{className:`group-head`,children:[(0,x.jsx)(`span`,{children:`Artefacts`}),(0,x.jsxs)(`span`,{className:`group-head-meta`,children:[(0,x.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:It,disabled:Se,children:(0,x.jsx)(v,{size:12,className:Se?`spinning`:void 0})}),(0,x.jsx)(`span`,{children:Se?`…`:String(R.length)})]})]}),B&&(0,x.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:B}),ye&&!B&&R.length>0&&(()=>{let e=R.filter(e=>e.kind===`agent-template`).length,t=R.length-e;return(0,x.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:R.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,x.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${we===e.key?` active`:``}`,onClick:()=>Te(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,x.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),ye&&!B&&R.length===0&&(0,x.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),R.filter(e=>we===`all`?!0:we===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?E:oe,r=Be(e.updatedAt),i=e.downloadPath!==null;return(0,x.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>kt(e),disabled:!i,style:i?void 0:{cursor:`default`},title:i?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,x.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,x.jsxs)(`span`,{className:`conv-stack`,children:[(0,x.jsx)(`span`,{className:`conv-name-line`,children:(0,x.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,x.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),i&&(0,x.jsx)(re,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),I===`sessions`&&(()=>{let e=W.filter(e=>J?!0:!e.isSubagent).filter(e=>Y?!0:!e.archived),t=W.some(e=>e.isSubagent),n=W.some(e=>e.archived);return(0,x.jsxs)(`div`,{className:`side-list`,children:[(0,x.jsxs)(`div`,{className:`group-head`,children:[(0,x.jsx)(`span`,{children:`Sessions`}),(0,x.jsxs)(`span`,{className:`group-head-meta`,children:[(0,x.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Rt,disabled:Ve,children:(0,x.jsx)(v,{size:12,className:Ve?`spinning`:void 0})}),(0,x.jsx)(`span`,{children:Ve?`…`:String(e.length)})]})]}),Je&&(0,x.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,x.jsx)(`code`,{children:Je})}),(t||n)&&(0,x.jsxs)(`div`,{className:`artefact-filter-chips`,children:[t&&(0,x.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${J?` active`:``}`,"aria-pressed":J,onClick:()=>Ke(e=>!e),title:J?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),n&&(0,x.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${Y?` active`:``}`,"aria-pressed":Y,onClick:()=>qe(e=>!e),title:Y?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),q&&(0,x.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:q}),K&&!q&&e.length===0&&(0,x.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=Be(e.startedAt),n=$e.has(e.sessionId),r=X.has(e.sessionId),i=tt.has(e.sessionId),a=rt.has(e.sessionId),o=n||r||i||a,s=()=>{window.location.assign(`/chat?session=${e.sessionId}`)},c=[{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,x.jsx)(p,{size:12}),busy:n,onClick:()=>{Vt(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,x.jsx)(pe,{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,x.jsx)(D,{size:12}),onClick:t=>{Gt(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,x.jsx)(m,{size:12}),busy:i,onClick:t=>{qt(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,x.jsx)(le,{size:12}),busy:a,onClick:t=>{Jt(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,x.jsx)(T,{size:12}),busy:a,onClick:t=>{Jt(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,x.jsx)(l,{size:12}),busy:lt&&at===e.sessionId,onClick:t=>{t.stopPropagation(),ot(e.sessionId),ct(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,x.jsx)(f,{size:12}),danger:!0,busy:r,onClick:t=>{Wt(t,e)}},_e({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`:``,d=e.channel===`whatsapp`||e.channel===`telegram`||e.channel===`webchat`;return(0,x.jsxs)(`div`,{className:`conv conv-with-actions${u}${e.sessionId===G?` active`:``}`,children:[(0,x.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${e.personName??e.title} in webchat`,onClick:()=>{at!==e.sessionId&&s()},onKeyDown:t=>{at!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),s())},children:[(0,x.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,x.jsxs)(`span`,{className:`conv-stack`,children:[(0,x.jsxs)(`span`,{className:`conv-name-line`,children:[d&&(0,x.jsx)(ce,{channel:e.channel,size:13}),at===e.sessionId?(0,x.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,value:st,disabled:lt,"aria-label":`New title for session ${e.title}`,onChange:e=>ct(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),Yt(e)):t.key===`Escape`&&(t.preventDefault(),ot(null),ct(``))},onBlur:()=>{at===e.sessionId&&!lt&&(ot(null),ct(``))}}):(0,x.jsx)(`span`,{className:`conv-name`,title:e.personName??e.title,children:e.personName??e.title})]}),(0,x.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,x.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,x.jsxs)(`span`,{children:[` · `,t]})]})]})]}),(0,x.jsx)(ve,{actions:c,disabled:o})]},e.sessionId)})]})})(),I===`whatsapp`&&(0,x.jsxs)(`div`,{className:`side-list`,children:[(0,x.jsxs)(`div`,{className:`group-head`,children:[(0,x.jsx)(`span`,{children:Pt[Dt]}),(0,x.jsxs)(`span`,{className:`group-head-meta`,children:[(0,x.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{Mt()},children:(0,x.jsx)(v,{size:12})}),(0,x.jsx)(`span`,{children:String(Nt.get(Dt).length)})]})]}),Nt.get(Dt).map(e=>{let t=Be(e.lastMessageAt),n=se(e);return(0,x.jsxs)(`div`,{className:`conv conv-with-actions${e.source===`store`?e.scope===`admin`?` conv-scope-admin`:` conv-scope-public`:``}${w===n?` active`:``}`,children:[(0,x.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{k(e),S()},title:e.title,children:[(0,x.jsx)(ne,{channel:e.channel,size:14}),(0,x.jsxs)(`span`,{className:`conv-stack`,children:[(0,x.jsx)(`span`,{className:`conv-name-line`,children:(0,x.jsx)(`span`,{className:`conv-name`,children:ee(e)})}),t&&(0,x.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),e.source===`session`&&(0,x.jsx)(ve,{actions:[_e({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1})]},n)})]}),(0,x.jsx)(Ge,{}),(0,x.jsxs)(`div`,{className:`side-foot`,children:[(0,x.jsx)(`div`,{className:`avatar`,children:d?(0,x.jsx)(`img`,{src:d,alt:P}):F}),(0,x.jsxs)(`div`,{className:`who`,children:[(0,x.jsx)(`span`,{className:`name`,children:P}),(0,x.jsx)(`span`,{className:`role`,children:o??`operator`})]})]}),V&&(0,x.jsx)(`div`,{className:`copy-toast${V.failed?` copy-toast-failed`:``}`,role:`status`,children:V.message}),(0,x.jsx)(Ae,{error:De,onClose:()=>U(null)}),(0,x.jsx)(Me,{open:ke,onConnect:()=>{je(!1),i?.()},onClose:()=>je(!1)}),(0,x.jsx)(Oe,{target:Ze,onCancel:()=>Qe(null),onConfirm:()=>{let e=Ze;Qe(null),e&&Kt(e)}}),(0,x.jsx)(Fe,{show:dt!==null,onClose:()=>{ft(null),mt(null),vt(null)},sessionId:dt?.sessionId??null,summary:pt,loading:ht,error:_t})]})}var He=5e3,Ue=3e4,We=3e4;function Ge(){let[e,t]=(0,b.useState)(null);if((0,b.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()},He))}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,x.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,x.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,x.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,x.jsx)(`div`,{className:`system-stats__bar`,children:(0,x.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,x.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,x.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,x.jsx)(`div`,{className:`system-stats__bar`,children:(0,x.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var J=`admin-sidebar-collapsed`,Ke=`admin-sidebar-drawer-open`;function Y(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(J)===`1`}catch{return!1}}function qe(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(J,`1`):window.sessionStorage.removeItem(J)}catch{}}function Je(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Ke)===`1`}catch{return!1}}function Ye(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Ke,`1`):window.sessionStorage.removeItem(Ke)}catch{}}function X(e){let[t,n]=(0,b.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(e).matches);return(0,b.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 Xe=720;function Ze(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function Qe(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function $e(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 et(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function tt(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:`/browser`}function nt(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:o,disconnecting:s,claudeConnected:c,onConnectClaude:l,userName:u,userAvatar:f,role:p,onOpenConversations:m,children:g,footer:_}=e,{subAccounts:ee,activeAccountId:v,switching:te,switchAccount:ne,refreshAccounts:re}=h(t),[ie,ae]=(0,b.useState)(!0);(0,b.useEffect)(()=>{if(c!==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||ae(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[c,r]);let oe=c??ie,ce=l??(()=>{window.location.assign(`/?connect=claude`)}),[y,S]=(0,b.useState)(()=>Y()),[C,w]=(0,b.useState)(()=>Je()),le=X(`(max-width: ${Xe}px)`),[T,E]=(0,b.useState)(()=>typeof window>`u`||et(window.location.pathname,window.location.search)?null:$e(window.location.pathname,window.location.search)),[ue]=(0,b.useState)(()=>T!==null),[D,de]=(0,b.useState)(()=>typeof window>`u`?!1:et(window.location.pathname,window.location.search)),[fe]=(0,b.useState)(()=>D),pe=(0,b.useCallback)(e=>{qe(e),S(e)},[]),O=(0,b.useCallback)(e=>{Ye(e),w(e)},[]);(0,b.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=${y} drawer=${C}`)},[]),(0,b.useEffect)(()=>{typeof window>`u`||!T||(console.info(`[admin-ui] wa-hydrate route=/ remoteJid=${T.remoteJid??``}`),window.history.replaceState(null,``,`/`))},[]),(0,b.useEffect)(()=>{typeof window>`u`||!D||(console.info(`[admin-ui] data-hydrate route=/`),window.history.replaceState(null,``,`/`))},[]);let me=(0,b.useCallback)(e=>{if(de(!1),e===null){E(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=Ze(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?E(e):window.location.href=n.href},[]),k=(0,b.useCallback)(()=>{let e=typeof window<`u`?window.location.pathname:`/`,t=Qe(e);if(console.info(`[admin-ui] data-open route=${e} via=${t.via}`),t.via===`navigate`){window.location.href=t.href;return}E(null),de(!0)},[]),A=le?C:!y,j=(0,b.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${Xe}px)`).matches){let e=C;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),O(!e)}else{let e=y;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),pe(!e)}},[y,C,pe,O]),he=(0,b.useCallback)(e=>{let t=tt(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),M={collapsed:y,mobileDrawerOpen:C,sidebarOpen:A,onToggleSidebar:j,setMobileDrawerOpen:O,selectedWhatsapp:T,onClearWhatsapp:()=>E(null),dataOpen:D};return r===`operator`?(0,x.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,x.jsx)(d,{businessName:n,variant:r,onNavigate:he,onOpenConversations:m,onToggleSidebar:j,sidebarOpen:A,onLogout:i,onDisconnect:o,disconnecting:s,cacheKey:t,subAccounts:ee,activeAccountId:v,switchingAccount:te,onSwitchAccount:ne,refreshAccounts:re}),(0,x.jsx)(`div`,{className:`platform platform-operator`,children:typeof g==`function`?g(M):g}),_]}):(0,x.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,x.jsx)(d,{businessName:n,variant:r,onNavigate:he,onOpenConversations:m,onToggleSidebar:j,sidebarOpen:A,onLogout:i,onDisconnect:o,disconnecting:s,claudeConnected:oe,onConnectClaude:ce,cacheKey:t,subAccounts:ee,activeAccountId:v,switchingAccount:te,onSwitchAccount:ne,refreshAccounts:re}),(0,x.jsxs)(`div`,{className:`platform${C?` menu-open`:``}${y?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,x.jsx)(Ve,{businessName:n,cacheKey:t,onConnectClaude:ce,role:p??null,userName:u,userAvatar:f??null,onSelectProjects:()=>{window.location.href=`/graph?label=${a().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/tasks`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>O(!1),collapsed:y,mobileDrawerOpen:C,selectedWhatsappId:T?se(T):null,onSelectWhatsappConversation:me,initialWhatsappSurface:ue,onSelectData:k,onCloseData:()=>de(!1),initialDataSurface:fe}),!le&&(0,x.jsx)(ge,{}),typeof g==`function`?g(M):g]}),C&&(0,x.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>O(!1)}),_]})}export{T as _,je as a,y as b,N as c,L as d,me as f,E as g,D as h,Me as i,P as l,fe as m,X as n,U as o,O as p,ze as r,F as s,nt as t,ye as u,le as v,w as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{x as e}from"./useSubAccountSwitcher-DLJFISqf.js";var t=e();function n({checked:e,onChange:n,label:r,disabled:i}){return(0,t.jsxs)(`label`,{className:`maxy-checkbox${i?` maxy-checkbox--disabled`:``}`,children:[(0,t.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>n(e.target.checked),disabled:i}),(0,t.jsx)(`span`,{className:`maxy-checkbox__box`,children:`✱`}),r&&(0,t.jsx)(`span`,{className:`maxy-checkbox__label`,children:r})]})}export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-Ck5AOu5v.js";import{
|
|
1
|
+
import{o as e}from"./chunk-Ck5AOu5v.js";import{E as t,r as n,w as r,x as i}from"./useSubAccountSwitcher-DLJFISqf.js";import{n as a,t as o}from"./AdminLoginScreens-DeR71H29.js";import{s}from"./useVoiceRecorder-DCyJQkFK.js";import{a as c,t as l}from"./AdminShell-DlAVQUda.js";import"./Checkbox-B629mOPp.js";import{n as u,r as d}from"./page-Ck_pLhAk.js";import{a as f,s as p}from"./file-download-4mKJxUi-.js";import"./graph-labels-B8YAdo3Z.js";var m=r(),h=e(t(),1),g=i();function _({onOpen:e}){return(0,g.jsx)(`footer`,{className:`admin-footer`,children:(0,g.jsxs)(`div`,{className:`powered-by`,role:`button`,tabIndex:0,onClick:e,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},"aria-label":`Powered by Claude Code — show details`,children:[(0,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,g.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function v(){let e=a(),[t,r]=(0,h.useState)(!1);(0,h.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&r(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let i=(0,h.useCallback)(async()=>{let t=e.claudeInfo!=null;if(r(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let n=Date.now();try{let t=await fetch(`/api/admin/claude-info`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-n}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-n} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),m=(0,h.useCallback)(({code:t,path:n})=>{console.warn(`[admin-auth] outcome=chat-tab-logout-on-401 code=${t} path=${n}`),e.handleLogout()},[e]);return e.appState===`chat`?(0,g.jsx)(n,{cacheKey:e.cacheKey,onSessionExpired:m,surface:`chat`,children:(0,g.jsx)(l,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,claudeConnected:e.claudeConnected,onConnectClaude:()=>e.setAppState(`connect-claude`),userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(_,{onOpen:i}),(0,g.jsx)(c,{show:t,onClose:()=>r(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,g.jsx)(g.Fragment,{children:t.dataOpen&&e.cacheKey?(0,g.jsx)(u,{cacheKey:e.cacheKey}):t.selectedWhatsapp&&e.cacheKey?t.selectedWhatsapp.source===`store`&&t.selectedWhatsapp.remoteJid&&t.selectedWhatsapp.accountId?(0,g.jsx)(d,{accountId:t.selectedWhatsapp.accountId,remoteJid:t.selectedWhatsapp.remoteJid,contactName:f(t.selectedWhatsapp),sessionKey:e.cacheKey},p(t.selectedWhatsapp)):(0,g.jsx)(s,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,forceDeliveredOnly:!0},p(t.selectedWhatsapp)):(0,g.jsx)(`main`,{})})})}):(0,g.jsx)(o,{auth:e})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(v,{}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./path-
|
|
1
|
+
import{n as e,t}from"./path-BLSgTy3w.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,u as p}from"./dist-Cvgxm7qv.js";function m(e){return e.innerRadius}function h(e){return e.outerRadius}function g(e){return e.startAngle}function _(e){return e.endAngle}function v(e){return e&&e.padAngle}function y(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function b(e,t,n,r,i,a,o){var c=e-n,l=t-r,u=(o?a:-a)/d(c*c+l*l),f=u*l,p=-u*c,m=e+f,h=t+p,g=n+f,_=r+p,v=(m+g)/2,y=(h+_)/2,b=g-m,x=_-h,S=b*b+x*x,C=i-a,w=m*_-g*h,T=(x<0?-1:1)*d(s(0,C*C*S-w*w)),E=(w*x-b*T)/S,D=(-w*b-x*T)/S,O=(w*x+b*T)/S,k=(-w*b+x*T)/S,A=E-v,j=D-y,M=O-v,N=k-y;return A*A+j*j>M*M+N*N&&(E=O,D=k),{cx:E,cy:D,x01:-f,y01:-p,x11:E*(i/C-1),y11:D*(i/C-1)}}function x(){var s=m,x=h,S=e(0),C=null,w=g,T=_,E=v,D=null,O=t(k);function k(){var e,t,m=+s.apply(this,arguments),h=+x.apply(this,arguments),g=w.apply(this,arguments)-r,_=T.apply(this,arguments)-r,v=l(_-g),k=_>g;if(D||=e=O(),h<m&&(t=h,h=m,m=t),!(h>1e-12))D.moveTo(0,0);else if(v>c-1e-12)D.moveTo(h*u(g),h*a(g)),D.arc(0,0,h,g,_,!k),m>1e-12&&(D.moveTo(m*u(_),m*a(_)),D.arc(0,0,m,_,g,k));else{var A=g,j=_,M=g,N=_,P=v,F=v,I=E.apply(this,arguments)/2,L=I>1e-12&&(C?+C.apply(this,arguments):d(m*m+h*h)),R=p(l(h-m)/2,+S.apply(this,arguments)),z=R,B=R,V,H;if(L>1e-12){var U=o(L/m*a(I)),W=o(L/h*a(I));(P-=U*2)>1e-12?(U*=k?1:-1,M+=U,N-=U):(P=0,M=N=(g+_)/2),(F-=W*2)>1e-12?(W*=k?1:-1,A+=W,j-=W):(F=0,A=j=(g+_)/2)}var G=h*u(A),K=h*a(A),q=m*u(N),J=m*a(N);if(R>1e-12){var Y=h*u(j),X=h*a(j),Z=m*u(M),Q=m*a(M),$;if(v<i)if($=y(G,K,Z,Q,Y,X,q,J)){var ee=G-$[0],te=K-$[1],ne=Y-$[0],re=X-$[1],ie=1/a(f((ee*ne+te*re)/(d(ee*ee+te*te)*d(ne*ne+re*re)))/2),ae=d($[0]*$[0]+$[1]*$[1]);z=p(R,(m-ae)/(ie-1)),B=p(R,(h-ae)/(ie+1))}else z=B=0}F>1e-12?B>1e-12?(V=b(Z,Q,G,K,h,B,k),H=b(Y,X,q,J,h,B,k),D.moveTo(V.cx+V.x01,V.cy+V.y01),B<R?D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,h,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),!k),D.arc(H.cx,H.cy,B,n(H.y11,H.x11),n(H.y01,H.x01),!k))):(D.moveTo(G,K),D.arc(0,0,h,A,j,!k)):D.moveTo(G,K),!(m>1e-12)||!(P>1e-12)?D.lineTo(q,J):z>1e-12?(V=b(q,J,Y,X,m,-z,k),H=b(G,K,Z,Q,m,-z,k),D.lineTo(V.cx+V.x01,V.cy+V.y01),z<R?D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,m,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),k),D.arc(H.cx,H.cy,z,n(H.y11,H.x11),n(H.y01,H.x01),!k))):D.arc(0,0,m,N,M,k)}if(D.closePath(),e)return D=null,e+``||null}return k.centroid=function(){var e=(+s.apply(this,arguments)+ +x.apply(this,arguments))/2,t=(+w.apply(this,arguments)+ +T.apply(this,arguments))/2-i/2;return[u(t)*e,a(t)*e]},k.innerRadius=function(t){return arguments.length?(s=typeof t==`function`?t:e(+t),k):s},k.outerRadius=function(t){return arguments.length?(x=typeof t==`function`?t:e(+t),k):x},k.cornerRadius=function(t){return arguments.length?(S=typeof t==`function`?t:e(+t),k):S},k.padRadius=function(t){return arguments.length?(C=t==null?null:typeof t==`function`?t:e(+t),k):C},k.startAngle=function(t){return arguments.length?(w=typeof t==`function`?t:e(+t),k):w},k.endAngle=function(t){return arguments.length?(T=typeof t==`function`?t:e(+t),k):T},k.padAngle=function(t){return arguments.length?(E=typeof t==`function`?t:e(+t),k):E},k.context=function(e){return arguments.length?(D=e??null,k):D},k}export{x as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-K5T4RW27-5ucpeRvm.js";import{n as e}from"./chunk-7N4EOEYR-BRH9iM9L.js";export{e as createArchitectureServices};
|