@rubytech/create-maxy-code 0.1.301 → 0.1.303
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/dist/__tests__/install-immutability.test.js +55 -0
- package/dist/index.js +46 -1
- package/dist/install-immutability.js +59 -0
- package/package.json +1 -1
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +10 -1
- package/payload/platform/plugins/cloudflare/PLUGIN.md +1 -1
- package/payload/platform/plugins/cloudflare/references/reset-guide.md +1 -1
- package/payload/platform/plugins/cloudflare/skills/cloudflare/SKILL.md +2 -2
- package/payload/platform/plugins/docs/references/admin-ui.md +9 -0
- package/payload/platform/scripts/__tests__/check-no-task-id-leaks.test.sh +28 -0
- package/payload/platform/scripts/check-no-task-id-leaks.mjs +51 -8
- package/payload/platform/services/claude-session-manager/dist/system-prompt.d.ts +1 -0
- package/payload/platform/services/claude-session-manager/dist/system-prompt.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/system-prompt.js +23 -0
- package/payload/platform/services/claude-session-manager/dist/system-prompt.js.map +1 -1
- package/payload/platform/services/webchat-channel/dist/notification.d.ts +12 -0
- package/payload/platform/services/webchat-channel/dist/notification.d.ts.map +1 -1
- package/payload/platform/services/webchat-channel/dist/notification.js +29 -0
- package/payload/platform/services/webchat-channel/dist/notification.js.map +1 -1
- package/payload/platform/services/webchat-channel/dist/server.d.ts +1 -0
- package/payload/platform/services/webchat-channel/dist/server.d.ts.map +1 -1
- package/payload/platform/services/webchat-channel/dist/server.js +21 -6
- package/payload/platform/services/webchat-channel/dist/server.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts +12 -0
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.js +29 -0
- package/payload/platform/services/whatsapp-channel/dist/notification.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/server.d.ts +4 -4
- package/payload/platform/services/whatsapp-channel/dist/server.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/server.js +71 -38
- package/payload/platform/services/whatsapp-channel/dist/server.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/turn-follow.d.ts +9 -5
- package/payload/platform/services/whatsapp-channel/dist/turn-follow.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/turn-follow.js +47 -27
- package/payload/platform/services/whatsapp-channel/dist/turn-follow.js.map +1 -1
- package/payload/premium-plugins/venture-studio/skills/prototype-host/SKILL.md +1 -1
- package/payload/premium-plugins/writer-craft/PLUGIN.md +4 -4
- package/payload/premium-plugins/writer-craft/skills/voice-mirror/SKILL.md +4 -4
- package/payload/server/public/assets/AdminLoginScreens-B11_s63y.js +1 -0
- package/payload/server/public/assets/AdminShell-CXYu03dO.js +1 -0
- package/payload/server/public/assets/{Checkbox-C7bBRzLP.js → Checkbox-D01p5NFD.js} +1 -1
- package/payload/server/public/assets/{Transcript-bGy_Gx99.js → Transcript-NcTfeF7W.js} +1 -1
- package/payload/server/public/assets/admin-DdoI2RXi.js +1 -0
- package/payload/server/public/assets/{arc-DxSm8tli.js → arc-BrTRjBIM.js} +1 -1
- package/payload/server/public/assets/architecture-YZFGNWBL-DqQB3T6j.js +1 -0
- package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-7JSAh0vL.js → architectureDiagram-Q4EWVU46-DJ9on7sZ.js} +1 -1
- package/payload/server/public/assets/{audio-attachment-mime-DL5R1M2A.js → audio-attachment-mime-WRXiXXUG.js} +3 -3
- package/payload/server/public/assets/{blockDiagram-DXYQGD6D-DLoVmHKD.js → blockDiagram-DXYQGD6D-CIcyQn0q.js} +1 -1
- package/payload/server/public/assets/{browser-7fyPCFWB.js → browser-Db0TaQdG.js} +1 -1
- package/payload/server/public/assets/{c4Diagram-AHTNJAMY-Nv1G0o9P.js → c4Diagram-AHTNJAMY-Dt5dh_GR.js} +1 -1
- package/payload/server/public/assets/channel-NZeJdLVK.js +1 -0
- package/payload/server/public/assets/chat-BMTC0f2h.js +1 -0
- package/payload/server/public/assets/{chunk-2KRD3SAO-BpqPMhoA.js → chunk-2KRD3SAO-BUq3MqUy.js} +1 -1
- package/payload/server/public/assets/{chunk-336JU56O-DgXHlVU_.js → chunk-336JU56O-CUzJH5Qt.js} +2 -2
- package/payload/server/public/assets/chunk-426QAEUC-DFKX5l0L.js +1 -0
- package/payload/server/public/assets/{chunk-4BX2VUAB-nwyZSZH8.js → chunk-4BX2VUAB-B4JUc3UA.js} +1 -1
- package/payload/server/public/assets/{chunk-4TB4RGXK-Tfxz9LHX.js → chunk-4TB4RGXK-HRO9fIIs.js} +1 -1
- package/payload/server/public/assets/{chunk-55IACEB6-6FMJQGXG.js → chunk-55IACEB6-MZdrLBuw.js} +1 -1
- package/payload/server/public/assets/{chunk-5FUZZQ4R-g2FgZF3D.js → chunk-5FUZZQ4R-XcAN5zlM.js} +1 -1
- package/payload/server/public/assets/{chunk-5PVQY5BW-DtLwXsPH.js → chunk-5PVQY5BW-PQ1GEsxo.js} +1 -1
- package/payload/server/public/assets/{chunk-67CJDMHE-K91CP5ZU.js → chunk-67CJDMHE-BVvCaqGd.js} +1 -1
- package/payload/server/public/assets/{chunk-7N4EOEYR-BGpCQhqK.js → chunk-7N4EOEYR-BlBbZdpM.js} +1 -1
- package/payload/server/public/assets/{chunk-AA7GKIK3-jkDbInck.js → chunk-AA7GKIK3-Ct-PgkGa.js} +1 -1
- package/payload/server/public/assets/{chunk-BSJP7CBP-mDosdzGs.js → chunk-BSJP7CBP-DZRRfCSz.js} +1 -1
- package/payload/server/public/assets/{chunk-CIAEETIT-DhBxewpQ.js → chunk-CIAEETIT-BoGEJiXe.js} +1 -1
- package/payload/server/public/assets/{chunk-EDXVE4YY-B7c-9Emg.js → chunk-EDXVE4YY-DiSmN31f.js} +1 -1
- package/payload/server/public/assets/{chunk-ENJZ2VHE-Cqhhncox.js → chunk-ENJZ2VHE-uhhokIvs.js} +1 -1
- package/payload/server/public/assets/{chunk-FMBD7UC4-BpDq6wj1.js → chunk-FMBD7UC4-CfCx5WI7.js} +1 -1
- package/payload/server/public/assets/{chunk-FOC6F5B3-Ds02-ktu.js → chunk-FOC6F5B3-Dj9E9gTu.js} +1 -1
- package/payload/server/public/assets/{chunk-ICPOFSXX-BTX5POFr.js → chunk-ICPOFSXX-DcBs_FNy.js} +2 -2
- package/payload/server/public/assets/{chunk-K5T4RW27-Du1PXXBU.js → chunk-K5T4RW27-7-VefyJD.js} +1 -1
- package/payload/server/public/assets/{chunk-KGLVRYIC-siasOAf8.js → chunk-KGLVRYIC-CqgTEVxm.js} +1 -1
- package/payload/server/public/assets/{chunk-LIHQZDEY-xf1rbZtf.js → chunk-LIHQZDEY-C0gzDXha.js} +1 -1
- package/payload/server/public/assets/{chunk-ORNJ4GCN-DeTLQ_LD.js → chunk-ORNJ4GCN-JXz23R1H.js} +1 -1
- package/payload/server/public/assets/{chunk-OYMX7WX6-DQ7_oVJn.js → chunk-OYMX7WX6-C2snCNq9.js} +1 -1
- package/payload/server/public/assets/chunk-QZHKN3VN-BWCCN0AM.js +1 -0
- package/payload/server/public/assets/{chunk-U2HBQHQK-CXmFUKgn.js → chunk-U2HBQHQK-CXCU7M-M.js} +1 -1
- package/payload/server/public/assets/{chunk-X2U36JSP-Bj8-8Wkz.js → chunk-X2U36JSP-CEdcSb28.js} +1 -1
- package/payload/server/public/assets/{chunk-XPW4576I-Con3TXqt.js → chunk-XPW4576I-Cckc75YS.js} +1 -1
- package/payload/server/public/assets/{chunk-YZCP3GAM-Dx8BHGWf.js → chunk-YZCP3GAM-4nN8AO7H.js} +1 -1
- package/payload/server/public/assets/{chunk-ZZ45TVLE-Dp4Q5Y-f.js → chunk-ZZ45TVLE-DcoBc8-7.js} +1 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-DPlCQCX2.js +1 -0
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-CqkQq74h.js +1 -0
- package/payload/server/public/assets/clone-CSykdD1A.js +1 -0
- package/payload/server/public/assets/{cose-bilkent-S5V4N54A-pZiCv69E.js → cose-bilkent-S5V4N54A-BFFro_t9.js} +1 -1
- package/payload/server/public/assets/{dagre-CLqhEgbL.js → dagre-CN5to_JM.js} +1 -1
- package/payload/server/public/assets/{dagre-KV5264BT-BCxE8iyk.js → dagre-KV5264BT-WYrPwDg0.js} +1 -1
- package/payload/server/public/assets/{data-CIJnkfgX.js → data-BiWVJQmi.js} +1 -1
- package/payload/server/public/assets/{diagram-5BDNPKRD-slUEdZzz.js → diagram-5BDNPKRD-Dz2CiboN.js} +1 -1
- package/payload/server/public/assets/{diagram-G4DWMVQ6-DPcraMfu.js → diagram-G4DWMVQ6-r8h3Ip9O.js} +1 -1
- package/payload/server/public/assets/{diagram-MMDJMWI5-DR6luhGK.js → diagram-MMDJMWI5-CECcpGtr.js} +1 -1
- package/payload/server/public/assets/{diagram-TYMM5635-Jap1B4wA.js → diagram-TYMM5635-CHOcAyIP.js} +1 -1
- package/payload/server/public/assets/{erDiagram-SMLLAGMA-DJKUs2hO.js → erDiagram-SMLLAGMA-YIqKdPbS.js} +1 -1
- package/payload/server/public/assets/{file-download-gth6Gpmn.js → file-download-7T2ye2nL.js} +1 -1
- package/payload/server/public/assets/{flatten-Cl1Bc3dR.js → flatten-DhYYI_lo.js} +1 -1
- package/payload/server/public/assets/{flowDiagram-DWJPFMVM-C8W-ZZ9W.js → flowDiagram-DWJPFMVM-DaEvQWpj.js} +1 -1
- package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-DYCX4Xu2.js → ganttDiagram-T4ZO3ILL-x1hClEOB.js} +1 -1
- package/payload/server/public/assets/gitGraph-7Q5UKJZL-V7Tx7_eY.js +1 -0
- package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-CZu_fpgS.js → gitGraphDiagram-UUTBAWPF-C-sZsh6Z.js} +1 -1
- package/payload/server/public/assets/{graph-DHnB3BHK.js → graph-CWxi74vF.js} +1 -1
- package/payload/server/public/assets/{graph-labels-huk-fKcY.js → graph-labels-Bxt4mIUp.js} +1 -1
- package/payload/server/public/assets/{graphlib-Bdp7TA4y.js → graphlib-CNkAqm2w.js} +1 -1
- package/payload/server/public/assets/info-OMHHGYJF-D3DqVPGn.js +1 -0
- package/payload/server/public/assets/infoDiagram-42DDH7IO-B_O-R0vN.js +2 -0
- package/payload/server/public/assets/{isEmpty-D1pGOD1J.js → isEmpty-DGhq_DBP.js} +1 -1
- package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-B7KfIX6z.js → ishikawaDiagram-UXIWVN3A-wHE-RwzZ.js} +1 -1
- package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-CSDwBfhF.js → journeyDiagram-VCZTEJTY-DQB6iThz.js} +1 -1
- package/payload/server/public/assets/{jsx-runtime-DZddXDvJ.css → jsx-runtime-BAMC3pMk.css} +1 -1
- package/payload/server/public/assets/{kanban-definition-6JOO6SKY-CWzcEKTr.js → kanban-definition-6JOO6SKY-Ck08vXSA.js} +1 -1
- package/payload/server/public/assets/{line-BNQSlbYn.js → line-Cdc2FBEU.js} +1 -1
- package/payload/server/public/assets/{linear-BN6kGN93.js → linear-DhtUm5H7.js} +1 -1
- package/payload/server/public/assets/{mermaid-parser.core-CcFhkElq.js → mermaid-parser.core-CSYulPIL.js} +2 -2
- package/payload/server/public/assets/{mermaid.core-BsIeJ7Cc.js → mermaid.core-CP-hOmMh.js} +3 -3
- package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-CQVzj6D_.js → mindmap-definition-QFDTVHPH-GxlkvV1Z.js} +1 -1
- package/payload/server/public/assets/operator-Dw1Sep47.js +1 -0
- package/payload/server/public/assets/{ordinal-CBZeH4Yp.js → ordinal-CibZU3PM.js} +1 -1
- package/payload/server/public/assets/packet-4T2RLAQJ-BY7mgCTQ.js +1 -0
- package/payload/server/public/assets/page-DZ5OxzgL.js +1 -0
- package/payload/server/public/assets/pie-ZZUOXDRM-B9f6jN54.js +1 -0
- package/payload/server/public/assets/{pieDiagram-DEJITSTG-DnrQ9fyn.js → pieDiagram-DEJITSTG-Di6kWh9c.js} +1 -1
- package/payload/server/public/assets/{public-B4LqL6lA.js → public-C3iO20f3.js} +1 -1
- package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-BQWlCyWi.js → quadrantDiagram-34T5L4WZ-iNHC5bkO.js} +1 -1
- package/payload/server/public/assets/radar-PYXPWWZC-BKS8JOUe.js +1 -0
- package/payload/server/public/assets/{reduce-PuPlFPRX.js → reduce-Da0RBva0.js} +1 -1
- package/payload/server/public/assets/{requirementDiagram-MS252O5E-Du_vZhU1.js → requirementDiagram-MS252O5E-BBlLREXo.js} +1 -1
- package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-Cf6Z8GPQ.js → sankeyDiagram-XADWPNL6-qyDkP-Ca.js} +1 -1
- package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-CS8GVol8.js → sequenceDiagram-FGHM5R23-C0MJuS0m.js} +1 -1
- package/payload/server/public/assets/{stateDiagram-FHFEXIEX-Bv1NW2F1.js → stateDiagram-FHFEXIEX-aHTrlosa.js} +1 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-V2vo4BjY.js +1 -0
- package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-ClGYAsr0.js → timeline-definition-GMOUNBTQ-BlRZIxEp.js} +1 -1
- package/payload/server/public/assets/treeView-SZITEDCU-bIKzyIdw.js +1 -0
- package/payload/server/public/assets/treemap-W4RFUUIX-CQycQ4H9.js +1 -0
- package/payload/server/public/assets/{useSelectionMode-lrH0qwAR.js → useSelectionMode-DDpddXMY.js} +1 -1
- package/payload/server/public/assets/{vennDiagram-DHZGUBPP-C2wTcxQT.js → vennDiagram-DHZGUBPP-s76adysx.js} +1 -1
- package/payload/server/public/assets/wardley-RL74JXVD-COr9o-nG.js +1 -0
- package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-D86-ivEx.js → wardleyDiagram-NUSXRM2D-xC8t2QGW.js} +1 -1
- package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-Ba5WAN8P.js → xychartDiagram-5P7HB3ND-DRcHg-Wj.js} +1 -1
- package/payload/server/public/browser.html +6 -6
- package/payload/server/public/chat.html +10 -9
- package/payload/server/public/data.html +5 -5
- package/payload/server/public/graph.html +8 -8
- package/payload/server/public/index.html +10 -10
- package/payload/server/public/operator.html +13 -10
- package/payload/server/public/public.html +7 -7
- package/payload/server/server.js +1 -1
- package/payload/server/public/assets/AdminShell-BJrxifYa.js +0 -1
- package/payload/server/public/assets/admin-jYKA7jR5.js +0 -1
- package/payload/server/public/assets/architecture-YZFGNWBL-6g9jRVgc.js +0 -1
- package/payload/server/public/assets/channel-BgQLJanG.js +0 -1
- package/payload/server/public/assets/chat-UF9ATDwe.js +0 -1
- package/payload/server/public/assets/chunk-426QAEUC-Dr_XVuUq.js +0 -1
- package/payload/server/public/assets/chunk-QZHKN3VN-DF4o9HRJ.js +0 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-DAbPKU6u.js +0 -1
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-BKuFQLcv.js +0 -1
- package/payload/server/public/assets/clone-DnNHGhNe.js +0 -1
- package/payload/server/public/assets/gitGraph-7Q5UKJZL-g7mvu6IY.js +0 -1
- package/payload/server/public/assets/info-OMHHGYJF-DZqJuIkB.js +0 -1
- package/payload/server/public/assets/infoDiagram-42DDH7IO-cGfGccHz.js +0 -2
- package/payload/server/public/assets/operator-D3QAzlPs.js +0 -1
- package/payload/server/public/assets/packet-4T2RLAQJ-Hn8rlHpy.js +0 -1
- package/payload/server/public/assets/page-86edaOS1.js +0 -1
- package/payload/server/public/assets/pie-ZZUOXDRM-BPGWVqBm.js +0 -1
- package/payload/server/public/assets/radar-PYXPWWZC-DMdLrj3E.js +0 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-BGUCxPmp.js +0 -1
- package/payload/server/public/assets/treeView-SZITEDCU-CWxofUbI.js +0 -1
- package/payload/server/public/assets/treemap-W4RFUUIX-Cfgb_ZG0.js +0 -1
- package/payload/server/public/assets/wardley-RL74JXVD-B45olYjj.js +0 -1
- /package/payload/server/public/assets/{page-CWMpccrR.css → AdminLoginScreens-CWMpccrR.css} +0 -0
- /package/payload/server/public/assets/{_baseFor-brRjpUOX.js → _baseFor-BFYpZGkN.js} +0 -0
- /package/payload/server/public/assets/{array-BGFCBI0e.js → array-CYkMkqnU.js} +0 -0
- /package/payload/server/public/assets/{cytoscape.esm-TvRJ2tGX.js → cytoscape.esm-DqlHsaog.js} +0 -0
- /package/payload/server/public/assets/{defaultLocale-CRZydyG6.js → defaultLocale-Beh6XjaL.js} +0 -0
- /package/payload/server/public/assets/{dist-Dbh7HrZX.js → dist-t9p-NJH2.js} +0 -0
- /package/payload/server/public/assets/{init-B8gtcn7T.js → init-Rr1s_RiX.js} +0 -0
- /package/payload/server/public/assets/{jsx-runtime-CMu8uN0-.js → jsx-runtime-DhMPqcKn.js} +0 -0
- /package/payload/server/public/assets/{katex-RxgSu_dy.js → katex-pVJiI_rc.js} +0 -0
- /package/payload/server/public/assets/{path-DZF-JdEe.js → path-BAQ3hXlG.js} +0 -0
- /package/payload/server/public/assets/{preload-helper-CQ36nxok.js → preload-helper-B_l5jfgx.js} +0 -0
- /package/payload/server/public/assets/{rough.esm-6CnTHTkH.js → rough.esm-nHaDi0Kw.js} +0 -0
- /package/payload/server/public/assets/{src-BoaldmnP.js → src-DuPQVw-H.js} +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
// Turn-end detector for the WhatsApp native channel (Task 832
|
|
2
|
-
// SDK so it unit-tests in isolation.
|
|
3
|
-
// lines into the delivery decision;
|
|
4
|
-
//
|
|
1
|
+
// Turn-end detector for the WhatsApp native channel (Task 832, extended in
|
|
2
|
+
// Task 839). Pure of the MCP SDK so it unit-tests in isolation.
|
|
3
|
+
// `reduceTurnFromLines` folds one turn's JSONL lines into the delivery decision;
|
|
4
|
+
// `followTurnEnds` tails the session JSONL from a byte offset and reports every
|
|
5
|
+
// assistant end_turn (not just the first), so a follow-on turn produced from a
|
|
6
|
+
// mid-turn-queued message is covered too.
|
|
5
7
|
import { closeSync, openSync, readSync, statSync, watch } from 'node:fs';
|
|
6
8
|
// The reply tools the agent uses to deliver to WhatsApp. Either one appearing in
|
|
7
9
|
// a turn means the operator received something this turn — so the turn was not
|
|
@@ -54,50 +56,66 @@ export function reduceTurnFromLines(lines) {
|
|
|
54
56
|
}
|
|
55
57
|
return { replied, finalText, reachedEndTurn };
|
|
56
58
|
}
|
|
59
|
+
/** True iff `line` is an assistant message with stop_reason 'end_turn'. */
|
|
60
|
+
function isAssistantEndTurn(line) {
|
|
61
|
+
if (!line)
|
|
62
|
+
return false;
|
|
63
|
+
let ev;
|
|
64
|
+
try {
|
|
65
|
+
ev = JSON.parse(line);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return ev.type === 'assistant' && ev.message?.stop_reason === 'end_turn';
|
|
71
|
+
}
|
|
57
72
|
/**
|
|
58
|
-
* Tail `jsonlPath` from `startOffset`
|
|
59
|
-
* `
|
|
60
|
-
*
|
|
61
|
-
*
|
|
73
|
+
* Tail `jsonlPath` from `startOffset` for the life of the session, invoking
|
|
74
|
+
* `onTurnEnd` once for every assistant end_turn with that turn's outcome
|
|
75
|
+
* (Task 839). Unlike a one-shot follow it does not stop at the first end_turn:
|
|
76
|
+
* it segments the JSONL at each end_turn so a follow-on turn produced from a
|
|
77
|
+
* mid-turn-queued message is reported too. The process dies with the session,
|
|
78
|
+
* so there is no per-turn timeout; the promise resolves only when the file
|
|
79
|
+
* becomes unreadable (mirrors watchForGrowth's stat-failure bail). Never rejects.
|
|
62
80
|
*/
|
|
63
|
-
export async function
|
|
81
|
+
export async function followTurnEnds(jsonlPath, startOffset, onTurnEnd) {
|
|
64
82
|
let baseSize;
|
|
65
83
|
try {
|
|
66
84
|
baseSize = statSync(jsonlPath).size;
|
|
67
85
|
}
|
|
68
86
|
catch {
|
|
69
|
-
return
|
|
87
|
+
return;
|
|
70
88
|
}
|
|
71
89
|
return new Promise((resolve) => {
|
|
72
90
|
let offset = Math.min(startOffset, baseSize);
|
|
73
91
|
let carry = '';
|
|
74
|
-
|
|
92
|
+
// The lines of the turn currently being accumulated; reset after each
|
|
93
|
+
// end_turn so each onTurnEnd sees exactly one turn's lines.
|
|
94
|
+
let segment = [];
|
|
75
95
|
let settled = false;
|
|
76
|
-
const settle = (
|
|
96
|
+
const settle = () => {
|
|
77
97
|
if (settled)
|
|
78
98
|
return;
|
|
79
99
|
settled = true;
|
|
80
100
|
watcher.close();
|
|
81
|
-
clearTimeout(timer);
|
|
82
101
|
clearInterval(poll);
|
|
83
|
-
resolve(
|
|
102
|
+
resolve();
|
|
84
103
|
};
|
|
85
|
-
const timer = setTimeout(() => settle(reduceTurnFromLines(lines)), timeoutMs);
|
|
86
104
|
// Poll as well as watch: fs.watch misses appends on some platforms (notably
|
|
87
105
|
// macOS), so a light poll guarantees growth is seen within the interval.
|
|
88
106
|
const poll = setInterval(() => drain(), 200);
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
//
|
|
107
|
+
// Fully synchronous read of newly-appended bytes. Being synchronous, two
|
|
108
|
+
// pending invocations (the poll and the fs.watch callback) run to completion
|
|
109
|
+
// serially on the event loop, so `offset`/`carry`/`segment` advance
|
|
110
|
+
// atomically per call — overlapping reads can never reassemble bytes out of
|
|
111
|
+
// order or split a turn across two onTurnEnd calls.
|
|
94
112
|
const drain = () => {
|
|
95
113
|
let end;
|
|
96
114
|
try {
|
|
97
115
|
end = statSync(jsonlPath).size;
|
|
98
116
|
}
|
|
99
117
|
catch {
|
|
100
|
-
settle(
|
|
118
|
+
settle();
|
|
101
119
|
return;
|
|
102
120
|
}
|
|
103
121
|
if (end <= offset)
|
|
@@ -114,23 +132,25 @@ export async function followTurnOutcome(jsonlPath, startOffset, timeoutMs) {
|
|
|
114
132
|
}
|
|
115
133
|
}
|
|
116
134
|
catch {
|
|
117
|
-
settle(
|
|
135
|
+
settle();
|
|
118
136
|
return;
|
|
119
137
|
}
|
|
120
138
|
offset = end;
|
|
121
139
|
carry += buf.toString('utf8');
|
|
122
140
|
let nl = carry.indexOf('\n');
|
|
123
141
|
while (nl !== -1) {
|
|
124
|
-
|
|
142
|
+
const line = carry.slice(0, nl);
|
|
125
143
|
carry = carry.slice(nl + 1);
|
|
126
144
|
nl = carry.indexOf('\n');
|
|
145
|
+
segment.push(line);
|
|
146
|
+
if (isAssistantEndTurn(line)) {
|
|
147
|
+
onTurnEnd(reduceTurnFromLines(segment));
|
|
148
|
+
segment = [];
|
|
149
|
+
}
|
|
127
150
|
}
|
|
128
|
-
const out = reduceTurnFromLines(lines);
|
|
129
|
-
if (out.reachedEndTurn)
|
|
130
|
-
settle(out);
|
|
131
151
|
};
|
|
132
152
|
const watcher = watch(jsonlPath, { persistent: false }, () => drain());
|
|
133
|
-
watcher.on('error', () => settle(
|
|
153
|
+
watcher.on('error', () => settle());
|
|
134
154
|
drain(); // catch lines already present between startOffset and now
|
|
135
155
|
});
|
|
136
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-follow.js","sourceRoot":"","sources":["../src/turn-follow.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"turn-follow.js","sourceRoot":"","sources":["../src/turn-follow.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,gEAAgE;AAChE,iFAAiF;AACjF,gFAAgF;AAChF,+EAA+E;AAC/E,0CAA0C;AAC1C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAExE,iFAAiF;AACjF,+EAA+E;AAC/E,oEAAoE;AACpE,gFAAgF;AAChF,gDAAgD;AAChD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,8BAA8B;IAC9B,uCAAuC;CACxC,CAAC,CAAA;AAmBF,2EAA2E;AAC3E,MAAM,UAAU,mBAAmB,CAAC,KAAe;IACjD,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,SAAS,GAAG,EAAE,CAAA;IAClB,IAAI,cAAc,GAAG,KAAK,CAAA;IAC1B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI;YAAE,SAAQ;QACnB,IAAI,EAAsC,CAAA;QAC1C,IAAI,CAAC;YACH,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,SAAQ;QACV,CAAC;QACD,IAAK,EAAwB,CAAC,IAAI,KAAK,WAAW;YAAE,SAAQ;QAC5D,MAAM,GAAG,GAAI,EAAqB,CAAC,OAAO,CAAA;QAC1C,MAAM,KAAK,GAAG,GAAG,EAAE,WAAW,KAAK,UAAU,CAAA;QAC7C,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACxC,IAAI,KAAK,EAAE,CAAC;gBACV,cAAc,GAAG,IAAI,CAAA;gBACrB,SAAS,GAAG,EAAE,CAAA;YAChB,CAAC;YACD,SAAQ;QACV,CAAC;QACD,IAAI,OAAO,GAAG,EAAE,CAAA;QAChB,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChC,IAAI,KAAK,EAAE,IAAI,KAAK,UAAU,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrG,OAAO,GAAG,IAAI,CAAA;YAChB,CAAC;iBAAM,IAAI,KAAK,EAAE,IAAI,KAAK,MAAM,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,EAAE,CAAC;gBAC7E,OAAO,IAAI,KAAK,CAAC,IAAI,CAAA;YACvB,CAAC;QACH,CAAC;QACD,IAAI,KAAK,EAAE,CAAC;YACV,cAAc,GAAG,IAAI,CAAA;YACrB,SAAS,GAAG,OAAO,CAAA;QACrB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAA;AAC/C,CAAC;AAID,2EAA2E;AAC3E,SAAS,kBAAkB,CAAC,IAAY;IACtC,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAA;IACvB,IAAI,EAAgE,CAAA;IACpE,IAAI,CAAC;QACH,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,EAAE,CAAC,IAAI,KAAK,WAAW,IAAI,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,UAAU,CAAA;AAC1E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,SAAiB,EACjB,WAAmB,EACnB,SAAoB;IAEpB,IAAI,QAAgB,CAAA;IACpB,IAAI,CAAC;QACH,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,CAAA;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAM;IACR,CAAC;IACD,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACnC,IAAI,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;QAC5C,IAAI,KAAK,GAAG,EAAE,CAAA;QACd,sEAAsE;QACtE,4DAA4D;QAC5D,IAAI,OAAO,GAAa,EAAE,CAAA;QAC1B,IAAI,OAAO,GAAG,KAAK,CAAA;QACnB,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,IAAI,OAAO;gBAAE,OAAM;YACnB,OAAO,GAAG,IAAI,CAAA;YACd,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,aAAa,CAAC,IAAI,CAAC,CAAA;YACnB,OAAO,EAAE,CAAA;QACX,CAAC,CAAA;QACD,4EAA4E;QAC5E,yEAAyE;QACzE,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,CAAA;QAE5C,yEAAyE;QACzE,6EAA6E;QAC7E,oEAAoE;QACpE,4EAA4E;QAC5E,oDAAoD;QACpD,MAAM,KAAK,GAAG,GAAG,EAAE;YACjB,IAAI,GAAW,CAAA;YACf,IAAI,CAAC;gBACH,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,CAAA;YAChC,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,EAAE,CAAA;gBACR,OAAM;YACR,CAAC;YACD,IAAI,GAAG,IAAI,MAAM;gBAAE,OAAM;YACzB,IAAI,GAAW,CAAA;YACf,IAAI,CAAC;gBACH,MAAM,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;gBACnC,IAAI,CAAC;oBACH,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,CAAA;oBAChC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;gBAC1C,CAAC;wBAAS,CAAC;oBACT,SAAS,CAAC,EAAE,CAAC,CAAA;gBACf,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,EAAE,CAAA;gBACR,OAAM;YACR,CAAC;YACD,MAAM,GAAG,GAAG,CAAA;YACZ,KAAK,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YAC7B,IAAI,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAC5B,OAAO,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;gBACjB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;gBAC/B,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;gBAC3B,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBACxB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBAClB,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC7B,SAAS,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAA;oBACvC,OAAO,GAAG,EAAE,CAAA;gBACd,CAAC;YACH,CAAC;QACH,CAAC,CAAA;QAED,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAA;QACtE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;QACnC,KAAK,EAAE,CAAA,CAAC,0DAA0D;IACpE,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -119,7 +119,7 @@ Check `systemctl --user is-active "${BRAND}-prototype-<surface>.service"` return
|
|
|
119
119
|
curl -I -m 15 "https://<surface>.<BRAND_HOSTNAME>"
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
The skill emits the full HTTP response line (e.g. `HTTP/2 200`) to chat. Anything other than `200` aborts with the full curl output as literal stderr — same setup-done contract
|
|
122
|
+
The skill emits the full HTTP response line (e.g. `HTTP/2 200`) to chat. Anything other than `200` aborts with the full curl output as literal stderr — same setup-done contract established for cloudflare setup. This is end-to-end proof because the chat itself runs through the same tunnel: if the cloudflared connector were dead, the agent would never have answered the operator.
|
|
123
123
|
|
|
124
124
|
Final success line:
|
|
125
125
|
|
|
@@ -106,10 +106,10 @@ Voice-mirror introduces five deterministic plugin tools. They route writes throu
|
|
|
106
106
|
|
|
107
107
|
| Tool | Purpose |
|
|
108
108
|
|------|---------|
|
|
109
|
-
| `voice-tag-content` | Stamp `authorshipMode ∈ {human-only, human-led-agent-assisted, agent-led-human-reviewed, agent-only, unknown}`, `format ∈ {text, email, social-post, article, note, marketing-copy}`, and `voiceAuthor` on one or many `:KnowledgeDocument | :Message | :SocialPost` nodes (email threads live as `:KnowledgeDocument {source:'email'}`
|
|
110
|
-
| `voice-distil-profile` | Three modes, scope-aware (
|
|
111
|
-
| `voice-retrieve-conditioning` | Return `{styleCard, exemplars[], status}` for a drafting brief. Requires `brief.format` (one of the six corpus formats). `brief.scope` (default `personal`) picks personal vs org voice; a personal request with no personal profile falls back to the org profile (`status='fallback-org'
|
|
112
|
-
| `voice-record-feedback` | Capture an operator edit on an agent draft as a `:VoiceEdit {format, scope}` with a Haiku-summarised `intent`, linked back to the scoped per-format `:VoiceProfile` via `:FEEDBACK_FOR` (org edits → org profile; editor preserved via `:AUTHORED
|
|
109
|
+
| `voice-tag-content` | Stamp `authorshipMode ∈ {human-only, human-led-agent-assisted, agent-led-human-reviewed, agent-only, unknown}`, `format ∈ {text, email, social-post, article, note, marketing-copy}`, and `voiceAuthor` on one or many `:KnowledgeDocument | :Message | :SocialPost` nodes (email threads live as `:KnowledgeDocument {source:'email'}`). Bulk-mode for backfill batches. `format` is required. `author` is optional — omit to attribute to the tagging operator. |
|
|
110
|
+
| `voice-distil-profile` | Three modes, scope-aware (`scope='personal'` default walks one author; `scope='org'` walks the whole account onto the business). `mode='sample'` (default) walks the `human-only` corpus for the given `format`/`scope` and returns exemplars + recent edit intents for the agent to compose a style card; cadence-guarded (≥20% growth or ≥30 days). `mode='amend'` reads only `nodeIds` plus the existing `:VoiceProfile.styleCard` so the agent can decide whether named documents move the profile — operator-initiated, no cadence guard. `mode='write'` persists the YAML card; supply `amendedFromNodeIds` to attribute the write to specific documents (bypasses cadence + corpus walk). Trashed nodes are excluded from every walk. Omit `format` on `'sample'` to enumerate all formats in that scope's corpus and distil each. |
|
|
111
|
+
| `voice-retrieve-conditioning` | Return `{styleCard, exemplars[], status}` for a drafting brief. Requires `brief.format` (one of the six corpus formats). `brief.scope` (default `personal`) picks personal vs org voice; a personal request with no personal profile falls back to the org profile (`status='fallback-org'`). K=5 short-form (`brief.length:'short'`), K=15 long-form (`brief.length:'long'`). Token-budget bounded. `status ∈ {ok, fallback-org, no-data, error}`. |
|
|
112
|
+
| `voice-record-feedback` | Capture an operator edit on an agent draft as a `:VoiceEdit {format, scope}` with a Haiku-summarised `intent`, linked back to the scoped per-format `:VoiceProfile` via `:FEEDBACK_FOR` (org edits → org profile; editor preserved via `:AUTHORED`). Requires `format`. |
|
|
113
113
|
| `voice-ingest-session-text` | Write operator turns from the current session as `:Message {format:'text', authorshipMode:'human-only'}` corpus nodes. The agent reads its own operator turns from context and passes them as `turns`. Deduplicates via SHA256 `contentHash`. Invoked on demand by the voice-mirror skill when the operator asks to capture this session's voice. |
|
|
114
114
|
|
|
115
115
|
The non-voice skills continue to operate via existing platform tools (`memory-search` for knowledge retrieval). Structured choices are still presented as numbered lists in plain chat — the platform has no inline-UI component primitive on the admin / native-CC surface.
|
|
@@ -63,7 +63,7 @@ Run when the operator first installs voice-mirror, then whenever they want to re
|
|
|
63
63
|
|
|
64
64
|
The operator's authored content lives in two stream shapes that the backfill UX handles differently:
|
|
65
65
|
|
|
66
|
-
- **Discrete documents and posts** — `:KnowledgeDocument` (covers email threads via `source:'email'`
|
|
66
|
+
- **Discrete documents and posts** — `:KnowledgeDocument` (covers email threads via `source:'email'`), `:SocialPost`, and one-off `:Message` nodes. Per-item tagging with previews.
|
|
67
67
|
- **Chat archives** — conversation-document `:KnowledgeDocument` nodes (those carrying `conversationIdentity`) with their child `:Section` chunks. Per-conversation tagging because chunking happens server-side and the operator owns whole conversations, not individual chunks. Chat is the highest-leverage corpus — the unguarded voice that email rarely captures.
|
|
68
68
|
|
|
69
69
|
Ask the operator which stream to backfill first. Default to chat archives when the account has any conversation-document `:KnowledgeDocument` nodes, because that's where voice signal is strongest.
|
|
@@ -133,7 +133,7 @@ exemplars:
|
|
|
133
133
|
|
|
134
134
|
Drafting skills inject both blocks into their prompt. Opt-out is per-skill: declare `voiceMirror: false` in the skill's frontmatter and the calling site skips the fetch. Default is on.
|
|
135
135
|
|
|
136
|
-
The tool returns `{styleCard, exemplars, status}` with a discriminated `status
|
|
136
|
+
The tool returns `{styleCard, exemplars, status}` with a discriminated `status`:
|
|
137
137
|
|
|
138
138
|
- **`ok`** — a profile and/or exemplars were returned for the requested scope; inject both blocks.
|
|
139
139
|
- **`fallback-org`** — a `personal` request found no personal profile/corpus, so the **org (house) voice** was returned instead. Inject the (org) blocks and draft normally. This is the standing signal that the calling operator has no personal attribution yet — the account is running on the house voice. Don't tell the operator they have "no profile"; they have the house one.
|
|
@@ -188,7 +188,7 @@ Amend mode does not apply to the on-demand session-text capture path. Session-te
|
|
|
188
188
|
|
|
189
189
|
## Org and personal scope
|
|
190
190
|
|
|
191
|
-
Every account holds, per format, **one org (house) profile and any number of personal profiles** at once
|
|
191
|
+
Every account holds, per format, **one org (house) profile and any number of personal profiles** at once:
|
|
192
192
|
|
|
193
193
|
- **Personal** — one operator's own voice. Key `(accountId, userId, format)`, `scope='personal'`, anchored on the operator's `:AdminUser`. Distilled from that operator's author-tagged content only (`n.voiceAuthor = userId`).
|
|
194
194
|
- **Org** — the account/house voice. Key `(accountId, '__org__', format)`, `scope='org'`, anchored on the account's `:LocalBusiness`. Distilled from the **whole account** (every author's content), not one person's.
|
|
@@ -197,7 +197,7 @@ Every account holds, per format, **one org (house) profile and any number of per
|
|
|
197
197
|
|
|
198
198
|
Which voice a draft uses is the `scope` on the retrieval brief: `"my voice"` → personal, `"the house/org voice"` → org. A personal request with no personal profile yet falls back to the org profile (`status: "fallback-org"`); an org request with no org profile degrades to the default register (`status: "no-data"`).
|
|
199
199
|
|
|
200
|
-
**Single-operator accounts are unchanged.** With author omitted at tag time, the sole operator is the implicit author, so their personal corpus equals the account-wide corpus and personal distillation reproduces the prior single profile. Legacy content
|
|
200
|
+
**Single-operator accounts are unchanged.** With author omitted at tag time, the sole operator is the implicit author, so their personal corpus equals the account-wide corpus and personal distillation reproduces the prior single profile. Legacy content carries no `voiceAuthor`; it appears only in the account-wide org walk until re-tagged, and personal drafts fall back to the org voice in the meantime.
|
|
201
201
|
|
|
202
202
|
## Observability
|
|
203
203
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-Pqm5yXtL.js";import{a as t,t as n}from"./jsx-runtime-DhMPqcKn.js";import{s as r}from"./file-download-7T2ye2nL.js";import{u as i}from"./AdminShell-CXYu03dO.js";import{c as a,r as o,s}from"./useSelectionMode-DDpddXMY.js";import{t as c}from"./Checkbox-D01p5NFD.js";new Set(`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar,application/zip,application/x-zip-compressed,audio/ogg,audio/opus,audio/mp4,audio/mpeg,audio/webm,audio/wav,.opus,.ogg,.m4a,.mp3,.wav,.webm`.split(`,`).filter(e=>!e.startsWith(`.`)));function l(e){switch(e){case`expanded`:return!0;case`collapsed`:return!1;default:return}}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,a]=(0,p.useState)(``),[o,s]=(0,p.useState)(``),[c,m]=(0,p.useState)(``),[h,g]=(0,p.useState)(!1),[_,v]=(0,p.useState)(!1),[y,b]=(0,p.useState)(!1),[x,S]=(0,p.useState)(!1),[C,w]=(0,p.useState)(!1),[T,E]=(0,p.useState)(null),[D,O]=(0,p.useState)(null),[k,A]=(0,p.useState)(void 0),[j,M]=(0,p.useState)(null),[N,P]=(0,p.useState)(void 0),[F,I]=(0,p.useState)(null),[L,R]=(0,p.useState)(null),[z,B]=(0,p.useState)([]),[V,H]=(0,p.useState)(!1),[U,W]=(0,p.useState)(void 0),G=(0,p.useRef)(void 0),[K,q]=(0,p.useState)(!1);(0,p.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&q(!0)}).catch(()=>{})},[]);let J=(0,p.useRef)(null),Y=(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();E(r.session_key),R(r.sessionId??null),A(r.businessName),M(r.role??null),P(r.userName===void 0?null:r.userName),I(r.avatar??null);let i=l(r.thinkingView);return G.current=i,W(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}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&&O(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 X=(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();if(t.auth_status===`dead`||t.auth_status===`missing`){n(`connect-claude`);return}}}catch{}if(T)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(T)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),X.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,T]),(0,p.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&n(`enter-pin`)}).catch(()=>{})},[t]);async function Z(e,t){v(!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){m((await r.json().catch(()=>({}))).error||`Invalid PIN`);return}let i=await r.json();if(i.accounts&&!i.session_key){console.log(`[admin] account picker shown: userId=${i.userId} accountCount=${i.accounts.length}`),B(i.accounts),n(`account-picker`);return}E(i.session_key),R(i.sessionId??null),A(i.businessName),M(i.role??null),P(i.userName===void 0?null:i.userName),I(i.avatar??null);let o=l(i.thinkingView);if(G.current=o,W(o),t)try{sessionStorage.setItem(`maxy-account-id`,t)}catch{}try{sessionStorage.setItem(`maxy-admin-session-key`,i.session_key)}catch{}a(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),m(`Could not connect.`)}finally{v(!1),H(!1)}}let Q=(0,p.useCallback)(async e=>{if(e.preventDefault(),_)return;m(``);let t=o.trim();if(!t){m(`Please enter your name.`);return}if(r.length<4){m(`PIN must be at least 4 characters.`);return}let i=r;v(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:i,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));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`):m(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}m(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await Z(i);return}a(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),m(`Could not connect.`)}finally{v(!1)}},[r,_,o]),ee=(0,p.useCallback)(async e=>{e.preventDefault(),m(``),await Z(r)},[r]),te=(0,p.useCallback)(async()=>{w(!0);try{if(!await i())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;E(null),M(null),P(void 0),I(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(`maxy-account-id`),sessionStorage.removeItem(u)}catch{}return n(`connect-claude`),!0}finally{w(!1)}},[]),$=(0,p.useCallback)(()=>{E(null),M(null),P(void 0),I(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(`maxy-account-id`),sessionStorage.removeItem(u)}catch{}a(``),m(``),n(`enter-pin`)},[]);return(0,p.useEffect)(()=>{X.current=$},[$]),{appState:t,setAppState:n,pin:r,setPin:a,operatorName:o,setOperatorName:s,pinError:c,setPinError:m,showPin:h,setShowPin:g,pinLoading:_,authPolling:y,setAuthPolling:b,authLoading:x,setAuthLoading:S,disconnecting:C,cacheKey:T,setCacheKey:E,claudeInfo:D,setClaudeInfo:O,businessName:k,role:j,userName:N,userAvatar:F,sessionId:L,setSessionId:R,accounts:z,accountPickerLoading:V,expandAll:U,setExpandAll:W,expandAllDefaultRef:G,remoteAuthEnabled:K,pinInputRef:J,setPinFormRef:Y,handleSetPin:Q,handleLogin:ee,handleAccountSelect:(0,p.useCallback)(async e=>{H(!0),m(``),await Z(r,e)},[r]),handleDisconnect:te,handleLogout:$,handleChangePin:(0,p.useCallback)(async()=>{if(!r){m(`Enter your current PIN first.`);return}v(!0),m(``);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({currentPin:r})});if(!e.ok){m((await e.json().catch(()=>({error:`Incorrect PIN.`}))).error||`Incorrect PIN.`);return}a(``),m(``),n(`set-pin`)}catch(e){console.error(`[admin-auth] change pin failed:`,e),m(e instanceof Error?e.message:String(e))}finally{v(!1)}},[r])}}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:r,setShowPin:i,pinLoading:l,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:s,alt:o.productName,className:`connect-logo connect-logo--maxy`}),!o.logoContainsName&&(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,o.productName]}),(0,h.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,o.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:r}),(0,h.jsx)(a,{variant:`send`,type:`submit`,disabled:!t||!m.trim(),loading:l,"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)(c,{checked:r,onChange:()=>i(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:r,setShowPin:i,pinLoading:l,pinError:u,pinInputRef:d,onSubmit:f,onChangePin:p,remoteAuthEnabled:m,onSignOutRemote:_}=e;return(0,h.jsxs)(`div`,{className:`connect-page`,children:[m&&_&&(0,h.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:_,children:`Sign out`}),(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:s,alt:o.productName,className:`connect-logo connect-logo--maxy`}),!o.logoContainsName&&(0,h.jsx)(`h1`,{className:`connect-title`,children:o.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:r,autoFocus:!0}),(0,h.jsx)(a,{variant:`send`,type:`submit`,disabled:!t,loading:l,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.jsxs)(`div`,{className:`pin-options`,children:[(0,h.jsx)(c,{checked:r,onChange:()=>i(e=>!e),label:`Show PIN`}),(0,h.jsx)(a,{type:`button`,variant:`ghost`,onClick:p,children:`Change PIN`})]})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function y(e){let{accounts:t,loading:n,error:i,onSelect:a}=e;return(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:s,alt:o.productName,className:`connect-logo connect-logo--maxy`}),!o.logoContainsName&&(0,h.jsx)(`h1`,{className:`connect-title`,children:o.productName}),(0,h.jsx)(`p`,{className:`connect-subtitle`,children:`Select an account`}),(0,h.jsx)(`div`,{className:`account-picker-list`,children:t.map(e=>(0,h.jsxs)(`button`,{className:`account-picker-card`,onClick:()=>a(e.accountId),disabled:n,type:`button`,children:[(0,h.jsx)(`span`,{className:`account-picker-name`,children:e.businessName||e.accountId}),(0,h.jsx)(`span`,{className:`account-picker-role`,children:e.role}),n&&(0,h.jsx)(r,{className:`account-picker-spinner`,size:16})]},e.accountId))}),i&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:i})]})})}function b(e){let{authPolling:t,setAuthPolling:n,authLoading:r,setAuthLoading:i,pinError:c,setPinError:l,setAppState:u}=e,[d,f]=(0,p.useState)(!1),[m,g]=(0,p.useState)(!1);async function _(){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 v(){i(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){n(!0),f(!0),i(!1);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.`)}i(!1)}async function y(){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:y,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)(a,{variant:`primary`,onClick:v,disabled:r,children:r?(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)(`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`})}),c&&(0,h.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:c})]}):(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:s,alt:o.productName,className:`connect-logo connect-logo--maxy`}),!o.logoContainsName&&(0,h.jsx)(`span`,{className:`connect-logo-label`,children:o.productName})]})]}),(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,o.productName]}),(0,h.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,h.jsx)(a,{variant:`primary`,onClick:v,disabled:r,children:r?(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:_,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`}),c&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:c})]})})}function x({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)(b,{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,onChangePin:e.handleChangePin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):e.appState===`account-picker`?(0,h.jsx)(y,{accounts:e.accounts,loading:e.accountPickerLoading,error:e.pinError,onSelect:e.handleAccountSelect}):null}export{m as n,x as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-Pqm5yXtL.js";import{a as t,n,r,t as i}from"./jsx-runtime-DhMPqcKn.js";import{a,c as o,o as s,r as c,s as l,t as u}from"./file-download-7T2ye2nL.js";import{l as d,o as f,r as p,t as m}from"./useSelectionMode-DDpddXMY.js";async function h(){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 g=r(`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`}]]),_=r(`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`}]]),v=r(`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`}]]),y=r(`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`}]]),b=r(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),x=r(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),S=r(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),C=r(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),w=r(`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`}]]),T=r(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),E=r(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),D=r(`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`}]]),ee=r(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),O=r(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),te=r(`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`}]]),ne=r(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),k=r(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),A=r(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),re=r(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),ie=r(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),j=r(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),M=r(`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`}]]),N=e(t(),1),P=i();function F(e){let{businessName:t,variant:r=`admin`,onNavigate:i,onToggleSidebar:o,sidebarOpen:s,onLogout:u,onDisconnect:d,disconnecting:m}=e,[h,g]=(0,N.useState)(!1),_=(0,N.useRef)(null),v=(0,N.useRef)(null),y=c(null),[w,D]=(0,N.useState)(null),[te,A]=(0,N.useState)(!1),[ie,M]=(0,N.useState)(null),[F,I]=(0,N.useState)(null),[ae,L]=(0,N.useState)(!1),[oe,R]=(0,N.useState)(null),[z,se]=(0,N.useState)(null),[ce,B]=(0,N.useState)(``);(0,N.useEffect)(()=>{B(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,N.useEffect)(()=>{if(!h)return;let e=e=>{_.current&&!_.current.contains(e.target)&&g(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[h]),(0,N.useEffect)(()=>{if(!h)return;let e=e=>{e.key===`Escape`&&g(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h]),(0,N.useEffect)(()=>{h&&v.current?.focus()},[h]),(0,N.useEffect)(()=>{if(!h||r!==`admin`)return;let e=!1;return y(`/api/admin/version`).then(e=>e.json()).then(t=>{e||se(t)}).catch(e=>{console.error(`[admin/version] menu-open client fetch failed:`,e)}),()=>{e=!0}},[h,r,y]);let V=(0,N.useCallback)(()=>{g(e=>{let t=!e;return t&&console.info(`[admin-ui] header-menu-open`),t})},[]),H=(0,N.useCallback)(e=>{g(!1),i(e)},[i]),le=(0,N.useCallback)(async()=>{if(w!==null){D(null),I(null);return}A(!0),M(null);try{let e=await y(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);D((await e.json()).agents??[])}catch(e){console.error(`[admin/agents] list failed:`,e),M(e instanceof Error?e.message:String(e)),D([])}finally{A(!1)}},[w,y]),ue=(0,N.useCallback)(e=>{I(null),D(t=>t?.filter(t=>t.slug!==e)??null),y(`/api/admin/agents/${encodeURIComponent(e)}`,{method:`DELETE`}).catch(e=>console.error(`[admin/agents] delete failed:`,e))},[y]),U=(0,N.useCallback)(()=>{g(!1),u()},[u]),de=(0,N.useCallback)(async()=>{R(null),await d()?(L(!1),g(!1)):R(`Disconnect failed — credentials still present. Try again.`)},[d]),fe=t||p.productName;return(0,P.jsxs)(`header`,{className:`admin-header`,children:[r===`admin`&&(0,P.jsx)(`button`,{type:`button`,className:`admin-sidebar-toggle`,"aria-label":s?`Hide sidebar`:`Show sidebar`,title:s?`Hide sidebar`:`Show sidebar`,"aria-expanded":s,onClick:o,children:s?(0,P.jsx)(ne,{size:20,strokeWidth:1.5}):(0,P.jsx)(k,{size:20,strokeWidth:1.5})}),(0,P.jsxs)(`div`,{className:`chat-header-label`,children:[(0,P.jsx)(`span`,{className:`chat-logo-btn`,"aria-hidden":`true`,children:(0,P.jsx)(`img`,{src:f,alt:``,className:`chat-logo`})}),(0,P.jsx)(`h1`,{className:`chat-tagline`,children:fe})]}),(0,P.jsxs)(`div`,{className:`chat-burger-wrap`,ref:_,children:[(0,P.jsx)(`button`,{type:`button`,className:`admin-burger`,onClick:V,"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":h,children:(0,P.jsx)(O,{size:20})}),h&&(0,P.jsxs)(`div`,{className:`admin-menu`,role:`menu`,children:[r===`admin`&&(0,P.jsxs)(`button`,{ref:v,type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>H(`dashboard`),children:[(0,P.jsx)(E,{size:14}),` Dashboard`]}),r===`operator`&&(0,P.jsxs)(`button`,{ref:v,type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>H(`chat`),children:[(0,P.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`chat-menu-claude-icon`}),` Chat`]}),(0,P.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>H(`data`),children:[(0,P.jsx)(x,{size:14}),` Data`]}),r===`admin`&&(0,P.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>H(`graph`),children:[(0,P.jsx)(re,{size:14}),` Graph`]}),r===`admin`&&(0,P.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>H(`browser`),children:[(0,P.jsx)(C,{size:14}),` Browser`]}),r===`admin`&&(0,P.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>H(`chat`),children:[(0,P.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`chat-menu-claude-icon`}),` Chat`]}),r===`admin`&&(0,P.jsx)(`div`,{className:`chat-menu-divider`}),r===`admin`&&(0,P.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:le,children:[(0,P.jsx)(S,{size:14}),` Public`,te&&(0,P.jsx)(l,{size:12,className:`spin`})]}),r===`admin`&&w!==null&&(0,P.jsxs)(`div`,{className:`chat-menu-agents`,children:[ie&&(0,P.jsx)(`span`,{className:`chat-menu-agent-error`,children:ie}),w.length===0&&!ie&&(0,P.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),w.map(e=>(0,P.jsxs)(`div`,{className:`chat-menu-item chat-menu-agent-item`,children:[(0,P.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,P.jsxs)(`span`,{className:`agent-text`,children:[(0,P.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,P.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]}),F===e.slug?(0,P.jsxs)(`span`,{className:`agent-actions agent-confirm`,children:[(0,P.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-yes`,title:`Confirm delete`,onClick:()=>ue(e.slug),children:(0,P.jsx)(b,{size:12})}),(0,P.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-no`,title:`Cancel`,onClick:()=>I(null),children:(0,P.jsx)(a,{size:12})})]}):(0,P.jsxs)(`span`,{className:`agent-actions`,children:[(0,P.jsx)(`a`,{href:`${ce}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`agent-action-btn`,title:`Open agent`,onClick:()=>g(!1),children:(0,P.jsx)(S,{size:12})}),(0,P.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-delete-btn`,title:`Delete agent`,onClick:()=>I(e.slug),children:(0,P.jsx)(n,{size:12})})]})]},e.slug))]}),r===`admin`&&(0,P.jsx)(`div`,{className:`chat-menu-divider`}),r===`admin`&&(0,P.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,P.jsx)(T,{size:14}),(0,P.jsxs)(`span`,{className:`version-installed`,children:[z?`v${z.installed}`:`…`,z&&!z.updateAvailable&&(0,P.jsx)(`span`,{className:`version-uptodate-dot`}),z?.updateAvailable&&(0,P.jsx)(`span`,{className:`version-update-dot`})]})]}),r===`admin`&&(ae?(0,P.jsxs)(`div`,{className:`chat-menu-item chat-menu-disconnect`,children:[(0,P.jsx)(`span`,{children:`Disconnect Claude account?`}),(0,P.jsxs)(`span`,{className:`agent-actions agent-confirm`,children:[(0,P.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-yes`,title:`Confirm disconnect`,disabled:m,onClick:de,children:m?(0,P.jsx)(l,{size:12,className:`spin`}):(0,P.jsx)(b,{size:12})}),(0,P.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-no`,title:`Cancel disconnect`,disabled:m,onClick:()=>{L(!1),R(null)},children:(0,P.jsx)(a,{size:12})})]})]}):(0,P.jsxs)(`button`,{type:`button`,className:`chat-menu-item chat-menu-disconnect`,role:`menuitem`,onClick:()=>{R(null),L(!0)},children:[(0,P.jsx)(j,{size:14}),` Disconnect Claude account`]})),r===`admin`&&oe&&(0,P.jsx)(`span`,{className:`chat-menu-agent-error`,children:oe}),(0,P.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:U,children:[(0,P.jsx)(ee,{size:14}),` Log out`]})]})]})]})}var I=`maxy-shell-side-px`;function ae(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function L(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-ae());return Math.min(Math.max(e,248),n)}function oe(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(I);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 L(t)}catch{}return 264}function R({targetSelector:e=`.platform`}){let t=(0,N.useRef)(null),[n,r]=(0,N.useState)(()=>oe()),i=(0,N.useRef)(n);(0,N.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,N.useCallback)(()=>{r(e=>{let t=L(e);return t===e?e:t})},[]);(0,N.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(L(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(I,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=L(264);r(e);try{window.localStorage.removeItem(I)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,P.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var z={whatsapp:{fill:`#25D366`,label:`WhatsApp`,path:`M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.71.306 1.263.489 1.694.625.712.227 1.36.195 1.872.118.571-.085 1.758-.719 2.006-1.413.247-.694.247-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.885-9.885 9.885M20.52 3.449C18.24 1.245 15.24.044 12.045.044 5.463.044.103 5.404.1 11.99c0 2.096.546 4.142 1.588 5.945L0 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.585 0 11.946-5.36 11.949-11.946 0-3.193-1.24-6.19-3.495-8.445`},telegram:{fill:`#229ED9`,label:`Telegram`,path:`M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z`}};function se({channel:e,size:t=16}){let n=z[e];return(0,P.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:n.fill,role:`img`,"aria-label":n.label,className:`channel-icon`,children:(0,P.jsx)(`path`,{d:n.path})})}var ce=[`whatsapp`,`telegram`];function B(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 V(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}var H=`auth-refresh-failed`;function le({error:e,onClose:t}){if(!e)return null;let n=e.reason===H,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,P.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,P.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,P.jsxs)(`div`,{className:`claude-info-header`,children:[(0,P.jsx)(`span`,{children:r}),(0,P.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,P.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,P.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,P.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,P.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function ue(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,N.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),h=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),g=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),_=r?.account?.subscriptionType,v=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,P.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,P.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,P.jsxs)(`div`,{className:`claude-info-header`,children:[(0,P.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,P.jsx)(`span`,{children:`Claude Code`}),(0,P.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,P.jsxs)(`div`,{className:`claude-info-section`,children:[(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,P.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,P.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(_||h||g>0)&&(0,P.jsxs)(`div`,{className:`claude-info-section`,children:[_&&(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,P.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:_})]}),h&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,P.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(h.utilization*100),`%`]})]}),(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,P.jsx)(`span`,{className:`claude-info-value`,children:v(h.resetsAt)})]}),h.isUsingOverage&&(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,P.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),g>0&&(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,P.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,g<.01?g.toFixed(4):g.toFixed(2)]})]})]}),(0,P.jsxs)(`div`,{className:`claude-info-section`,children:[(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,P.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,P.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,P.jsx)(`span`,{className:`claude-info-value`,children:p>0?V(p):`—`})]}),(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,P.jsx)(`span`,{className:`claude-info-value`,children:B(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,P.jsxs)(`div`,{className:`claude-info-row`,children:[(0,P.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,P.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 m(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}var U=`https://claude.ai/code`,de=[500,1e3,1500,2e3,2500,3e3,3e3];function fe(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${U}/${r}`};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function pe(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function W(e){let{businessName:t,cacheKey:r,role:i,userName:a,userAvatar:l,onSelectProjects:f,onSelectPeople:m,onSelectTasks:h,onSelectAgents:b,onCloseMobileDrawer:x,collapsed:C,selectedWhatsappId:T,onSelectWhatsappConversation:E,initialWhatsappSurface:ee=!1}=e,O=c(r),ne=p.productName,k=typeof a==`string`?a:a===null?`name unavailable`:t||ne,re=(k.trim().charAt(0)||`?`).toUpperCase(),[j,F]=(0,N.useState)(ee?`whatsapp`:`sessions`),[I,ae]=(0,N.useState)([]),[L,oe]=(0,N.useState)(!1),[R,z]=(0,N.useState)(null),[B,V]=(0,N.useState)(!1),[H,ue]=(0,N.useState)(`file`),[U,W]=(0,N.useState)(null),[me,G]=(0,N.useState)(null),[K,_e]=(0,N.useState)([]),[q,ve]=(0,N.useState)(!1),[J,Y]=(0,N.useState)(null),[ye,be]=(0,N.useState)(!1),[xe,Se]=(0,N.useState)(!1),[Ce,we]=(0,N.useState)(!1),[Te,Ee]=(0,N.useState)(null),[De,Oe]=(0,N.useState)(new Set),[ke,Ae]=(0,N.useState)(new Set),[je,Me]=(0,N.useState)(new Set),[Ne,Pe]=(0,N.useState)(new Set),[X,Fe]=(0,N.useState)(!1),[Ie,Le]=(0,N.useState)([]),[Re,ze]=(0,N.useState)(!1),[Be,Ve]=(0,N.useState)(null),[He,Ue]=(0,N.useState)(`whatsapp`),We=(0,N.useCallback)(e=>{if(x(),!r){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),W({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`),W({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}`),u(r,e.downloadPath,e.downloadRoot??`data`),W({message:`Downloading ${e.name}`,failed:!1})},[r,x]);(0,N.useEffect)(()=>{if(!U)return;let e=setTimeout(()=>W(null),2500);return()=>clearTimeout(e)},[U]);let Ge=(0,N.useCallback)(async()=>{if(r){V(!0),z(null);try{let e=await O(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);ae((await e.json()).artefacts??[]),oe(!0)}catch(e){let t=e instanceof Error?e.message:String(e);z(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{V(!1)}}},[r,O]),Z=(0,N.useCallback)(async()=>{if(!r)return null;be(!0),Y(null);try{let e=await O(`/api/admin/sidebar-sessions`);if(!e.ok)throw Error(`status ${e.status}`);let t=await e.json(),n=t.sessions??[];return _e(n),Ee(t.accountId??null),ve(!0),n}catch(e){let t=e instanceof Error?e.message:String(e);return Y(`Failed to load sessions: ${t}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${t}`),null}finally{be(!1)}},[r,O]),Q=(0,N.useCallback)(async()=>{if(r){Ve(null);try{let e=await O(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);Le((await e.json()).conversations??[]),ze(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Ve(`Couldn't load conversations: ${t}`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[r,O]);(0,N.useEffect)(()=>{!r||q||Z()},[r,q,Z]),(0,N.useEffect)(()=>{if(!r)return;let e=null;return Q(),e=setInterval(()=>{Q()},he),()=>{e!==null&&clearInterval(e)}},[r,Q]);let Ke=(0,N.useMemo)(()=>{let e=new Map;for(let t of ce)e.set(t,[]);for(let t of Ie)e.get(t.channel)?.push(t);for(let t of ce)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[Ie]),qe={whatsapp:`WhatsApp`,telegram:`Telegram`},Je=()=>{E(null),F(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${L?I.length:0} collapsed=${C}`),Ge()},$=1.5,Ye=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),Ge()},Xe=()=>{E(null),F(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${q?K.length:0} collapsed=${C}`),q||Z()},Ze=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions`),Z()},Qe=e=>{F(`whatsapp`),Ue(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${Ke.get(e)?.length??0} collapsed=${C}`)},$e=(0,N.useCallback)(async e=>{if(e.resumable===!1||ke.has(e.sessionId))return;Ae(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await O(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId})}),r=await n.json().catch(()=>({})),i=fe(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`?(x(),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}`),G(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}`),G({sessionId:e.sessionId,reason:r})}finally{Ae(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[O,x,ke]),et=(0,N.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=de.length;n++){await new Promise(e=>setTimeout(e,de[n-1]));let r=await Z();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}`)},[Z]),tt=(0,N.useCallback)(async()=>{if(X)return;Fe(!0);let e=window.open(``,`_blank`);try{let t=await O(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),n=await t.json().catch(()=>({})),r=fe(t.ok,t.status,n);console.info(`[admin-ui] sidebar-new-session-spawned status=${t.status} outcome=${r.kind} slug=${n.slug??n.bridgeSessionId??`none`}`),r.kind===`navigate`?(e?e.location.href=r.url:window.open(r.url,`_blank`),n.sessionId?et(n.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):(e?.close(),console.error(`[admin-ui] sidebar-new-session-failed status=${t.status} reason=${r.reason}`),G(r))}catch(t){e?.close();let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-new-session-failed error=${n}`),G({sessionId:null,reason:n})}finally{Fe(!1)}},[O,X,et]),nt=(0,N.useCallback)(async(e,t)=>{if(e.stopPropagation(),!De.has(t.sessionId)){Oe(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await O(`/api/admin/session-delete`,{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-delete-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),W({message:`Delete failed: ${n.error??`status ${e.status}`}`,failed:!0});return}let n=await e.json();console.info(`[admin-ui] sidebar-session-delete sessionId=${t.sessionId} pidKilled=${n.pidKilled??`?`} deleted=${n.deleted??`?`}`),_e(e=>e.filter(e=>e.sessionId!==t.sessionId)),Z()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${t.sessionId} error=${n}`),W({message:`Delete failed: ${n}`,failed:!0})}finally{Oe(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[O,De,Z]),rt=(0,N.useCallback)(async(e,t)=>{if(e.stopPropagation(),!je.has(t.sessionId)){Me(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await O(`/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`}`),W({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Z()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),W({message:`Stop failed: ${n}`,failed:!0})}finally{Me(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[O,je,Z]),it=(0,N.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!Ne.has(t.sessionId)){Pe(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await O(`/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`}`),W({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Z()}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}`),W({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{Pe(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[O,Ne,Z]);return(0,P.jsxs)(`aside`,{className:`side`,children:[(0,P.jsx)(`div`,{className:`side-new-session-row`,children:(0,P.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:tt,disabled:X,"aria-busy":X,children:[(0,P.jsx)(A,{size:14}),(0,P.jsx)(`span`,{children:X?`Spawning…`:`New session`})]})}),(0,P.jsxs)(`nav`,{className:`side-nav`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),m(),x()},children:[(0,P.jsx)(M,{size:20,strokeWidth:$}),(0,P.jsx)(`span`,{className:`label`,children:`People`}),(0,P.jsx)(`span`,{className:`kbd`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),b(),x()},children:[(0,P.jsx)(v,{size:20,strokeWidth:$}),(0,P.jsx)(`span`,{className:`label`,children:`Agents`}),(0,P.jsx)(`span`,{className:`kbd`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),f(),x()},children:[(0,P.jsx)(y,{size:20,strokeWidth:$}),(0,P.jsx)(`span`,{className:`label`,children:`Projects`}),(0,P.jsx)(`span`,{className:`kbd`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),h(),x()},children:[(0,P.jsx)(D,{size:20,strokeWidth:$}),(0,P.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,P.jsx)(`span`,{className:`kbd`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`nav-row${j===`artefacts`?` active`:``}`,onClick:Je,children:[(0,P.jsx)(d,{size:20,strokeWidth:$}),(0,P.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,P.jsx)(`span`,{className:`kbd`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`nav-row${j===`sessions`?` active`:``}`,onClick:Xe,children:[(0,P.jsx)(w,{size:20,strokeWidth:$}),(0,P.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,P.jsx)(`span`,{className:`kbd`})]}),Re&&ce.filter(e=>Ke.get(e).length>0).map(e=>(0,P.jsxs)(`button`,{type:`button`,className:`nav-row${j===`whatsapp`&&He===e?` active`:``}`,onClick:()=>Qe(e),children:[(0,P.jsx)(se,{channel:e,size:16}),(0,P.jsx)(`span`,{className:`label`,children:qe[e]}),(0,P.jsx)(`span`,{className:`kbd`})]},e)),Be&&(0,P.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,P.jsx)(`span`,{className:`label`,children:Be})})]}),j===`artefacts`&&(0,P.jsxs)(`div`,{className:`side-list`,children:[(0,P.jsxs)(`div`,{className:`group-head`,children:[(0,P.jsx)(`span`,{children:`Artefacts`}),(0,P.jsxs)(`span`,{className:`group-head-meta`,children:[(0,P.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:Ye,disabled:B,children:(0,P.jsx)(s,{size:12,className:B?`spinning`:void 0})}),(0,P.jsx)(`span`,{children:B?`…`:String(I.length)})]})]}),R&&(0,P.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:R}),L&&!R&&I.length>0&&(()=>{let e=I.filter(e=>e.kind===`agent-template`).length,t=I.length-e;return(0,P.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:I.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,P.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${H===e.key?` active`:``}`,onClick:()=>ue(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,P.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),L&&!R&&I.length===0&&(0,P.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),I.filter(e=>H===`all`?!0:H===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?v:d,r=pe(e.updatedAt),i=e.downloadPath!==null;return(0,P.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>We(e),disabled:!i,style:i?void 0:{cursor:`default`},title:i?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,P.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,P.jsxs)(`span`,{className:`conv-stack`,children:[(0,P.jsx)(`span`,{className:`conv-name-line`,children:(0,P.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,P.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),i&&(0,P.jsx)(o,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),j===`sessions`&&(()=>{let e=K.filter(e=>xe?!0:!e.isSubagent).filter(e=>Ce?!0:!e.archived),t=K.some(e=>e.isSubagent),r=K.some(e=>e.archived);return(0,P.jsxs)(`div`,{className:`side-list`,children:[(0,P.jsxs)(`div`,{className:`group-head`,children:[(0,P.jsx)(`span`,{children:`Sessions`}),(0,P.jsxs)(`span`,{className:`group-head-meta`,children:[(0,P.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Ze,disabled:ye,children:(0,P.jsx)(s,{size:12,className:ye?`spinning`:void 0})}),(0,P.jsx)(`span`,{children:ye?`…`:String(e.length)})]})]}),Te&&(0,P.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,P.jsx)(`code`,{children:Te})}),(t||r)&&(0,P.jsxs)(`div`,{className:`artefact-filter-chips`,children:[t&&(0,P.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${xe?` active`:``}`,onClick:()=>Se(e=>!e),title:xe?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),r&&(0,P.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${Ce?` active`:``}`,onClick:()=>we(e=>!e),title:Ce?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),J&&(0,P.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:J}),q&&!J&&e.length===0&&(0,P.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=pe(e.startedAt),r=ke.has(e.sessionId),i=De.has(e.sessionId),a=je.has(e.sessionId),o=Ne.has(e.sessionId);return(0,P.jsxs)(`div`,{className:`conv conv-with-actions`,children:[(0,P.jsxs)(`div`,{className:`conv-main-static`,children:[(0,P.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,P.jsxs)(`span`,{className:`conv-stack`,children:[(0,P.jsx)(`span`,{className:`conv-name-line`,children:(0,P.jsx)(`span`,{className:`conv-name`,title:e.title,children:e.title})}),(0,P.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,P.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,P.jsxs)(`span`,{children:[` · `,t]})]})]})]}),(0,P.jsxs)(`div`,{className:`conv-actions`,children:[e.resumable===!1?(0,P.jsx)(`span`,{className:`conv-ephemeral`,title:`Public webchat session — ephemeral, not resumable`,"aria-label":`Ephemeral public session (not resumable)`,children:(0,P.jsx)(w,{size:12})}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`conv-action`,onClick:()=>{$e(e)},disabled:r||i||a||o,"aria-busy":r,"aria-label":`Resume session ${e.title} in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,children:(0,P.jsx)(S,{size:12})}),(0,P.jsx)(`button`,{type:`button`,className:`conv-action`,onClick:()=>{window.location.assign(`/chat?session=${e.sessionId}`)},disabled:r||i||a||o,"aria-label":`Open session ${e.title} in admin webchat`,title:`Open in admin webchat (/chat) — sending resumes this session`,children:(0,P.jsx)(te,{size:12})})]}),e.live?(0,P.jsx)(`button`,{type:`button`,className:`conv-action`,onClick:t=>{rt(t,e)},disabled:r||i||a||o,"aria-busy":a,"aria-label":`Stop session ${e.title}`,title:`Stop session process (keeps the conversation, can resume later)`,children:(0,P.jsx)(ie,{size:12})}):null,e.archived?(0,P.jsx)(`button`,{type:`button`,className:`conv-action`,onClick:t=>{it(t,e,`unarchive`)},disabled:r||i||a||o,"aria-busy":o,"aria-label":`Unarchive session ${e.title}`,title:`Unarchive (move back to the active list)`,children:(0,P.jsx)(g,{size:12})}):(0,P.jsx)(`button`,{type:`button`,className:`conv-action`,onClick:t=>{it(t,e,`archive`)},disabled:r||i||a||o,"aria-busy":o,"aria-label":`Archive session ${e.title}`,title:`Archive (hide from the list, keeps the conversation resumable)`,children:(0,P.jsx)(_,{size:12})}),(0,P.jsx)(`button`,{type:`button`,className:`conv-action conv-action-danger`,onClick:t=>{nt(t,e)},disabled:r||i||a||o,"aria-busy":i,"aria-label":`Delete session ${e.title}`,title:`Delete session (stops the process, removes the conversation)`,children:(0,P.jsx)(n,{size:12})})]})]},e.sessionId)})]})})(),j===`whatsapp`&&(0,P.jsxs)(`div`,{className:`side-list`,children:[(0,P.jsxs)(`div`,{className:`group-head`,children:[(0,P.jsx)(`span`,{children:qe[He]}),(0,P.jsxs)(`span`,{className:`group-head-meta`,children:[(0,P.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{Q()},children:(0,P.jsx)(s,{size:12})}),(0,P.jsx)(`span`,{children:String(Ke.get(He).length)})]})]}),Ke.get(He).map(e=>{let t=pe(e.lastMessageAt);return(0,P.jsxs)(`button`,{type:`button`,className:`conv${T===e.sessionId?` active`:``}`,onClick:()=>{E(e),x()},title:e.title,children:[(0,P.jsx)(se,{channel:e.channel,size:14}),(0,P.jsxs)(`span`,{className:`conv-stack`,children:[(0,P.jsx)(`span`,{className:`conv-name-line`,children:(0,P.jsx)(`span`,{className:`conv-name`,children:e.operatorName??e.whatsappName??e.senderId??e.title})}),t&&(0,P.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]},e.sessionId)})]}),(0,P.jsx)(ge,{}),(0,P.jsxs)(`div`,{className:`side-foot`,children:[(0,P.jsx)(`div`,{className:`avatar`,children:l?(0,P.jsx)(`img`,{src:l,alt:k}):re}),(0,P.jsxs)(`div`,{className:`who`,children:[(0,P.jsx)(`span`,{className:`name`,children:k}),(0,P.jsx)(`span`,{className:`role`,children:i??`operator`})]})]}),U&&(0,P.jsx)(`div`,{className:`copy-toast${U.failed?` copy-toast-failed`:``}`,role:`status`,children:U.message}),(0,P.jsx)(le,{error:me,onClose:()=>G(null)})]})}var me=5e3,he=3e4;function ge(){let[e,t]=(0,N.useState)(null);if((0,N.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()},me))}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,P.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,P.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,P.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,P.jsx)(`div`,{className:`system-stats__bar`,children:(0,P.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,P.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,P.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,P.jsx)(`div`,{className:`system-stats__bar`,children:(0,P.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var G=`admin-sidebar-collapsed`,K=`admin-sidebar-drawer-open`;function _e(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(G)===`1`}catch{return!1}}function q(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(G,`1`):window.sessionStorage.removeItem(G)}catch{}}function ve(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(K)===`1`}catch{return!1}}function J(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(K,`1`):window.sessionStorage.removeItem(K)}catch{}}var Y=720;function ye(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.sessionId)}&projectDir=${encodeURIComponent(t.projectDir)}`}}function be(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`projectDir`);return!r||!i?null:{sessionId:r,projectDir:i,title:``,senderId:null,startedAt:``,channel:`whatsapp`,operatorName:null,whatsappName:null,lastMessageAt:null}}function xe(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`chat`?`/chat`:`/browser`}function Se(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,userName:s,userAvatar:c,role:l,children:u,footer:d}=e,[f,p]=(0,N.useState)(()=>_e()),[m,h]=(0,N.useState)(()=>ve()),[g,_]=(0,N.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${Y}px)`).matches),[v,y]=(0,N.useState)(()=>typeof window>`u`?null:be(window.location.pathname,window.location.search)),[b]=(0,N.useState)(()=>v!==null);(0,N.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${Y}px)`),t=e=>_(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let x=(0,N.useCallback)(e=>{q(e),p(e)},[]),S=(0,N.useCallback)(e=>{J(e),h(e)},[]);(0,N.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=${f} drawer=${m}`)},[]),(0,N.useEffect)(()=>{typeof window>`u`||!v||(console.info(`[admin-ui] wa-hydrate route=/ sessionId=${v.sessionId.slice(0,8)}`),window.history.replaceState(null,``,`/`))},[]);let C=(0,N.useCallback)(e=>{if(e===null){y(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=ye(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?y(e):window.location.href=n.href},[]),w=g?m:!f,T=(0,N.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${Y}px)`).matches){let e=m;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),S(!e)}else{let e=f;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),x(!e)}},[f,m,x,S]),E=(0,N.useCallback)(e=>{let t=xe(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),D={collapsed:f,mobileDrawerOpen:m,sidebarOpen:w,onToggleSidebar:T,setMobileDrawerOpen:S,selectedWhatsapp:v,onClearWhatsapp:()=>y(null)};return r===`operator`?(0,P.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,P.jsx)(F,{businessName:n,variant:r,onNavigate:E,onToggleSidebar:T,sidebarOpen:w,onLogout:i,onDisconnect:a,disconnecting:o}),(0,P.jsx)(`div`,{className:`platform platform-operator`,children:typeof u==`function`?u(D):u}),d]}):(0,P.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,P.jsx)(F,{businessName:n,variant:r,onNavigate:E,onToggleSidebar:T,sidebarOpen:w,onLogout:i,onDisconnect:a,disconnecting:o}),(0,P.jsxs)(`div`,{className:`platform${m?` menu-open`:``}${f?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,P.jsx)(W,{businessName:n,cacheKey:t,role:l??null,userName:s,userAvatar:c??null,onSelectProjects:()=>{window.location.href=`/graph?label=Project`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/graph?label=Task`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>S(!1),collapsed:f,mobileDrawerOpen:m,selectedWhatsappId:v?.sessionId??null,onSelectWhatsappConversation:C,initialWhatsappSurface:b}),!g&&(0,P.jsx)(R,{}),typeof u==`function`?u(D):u]}),m&&(0,P.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>S(!1)}),d]})}export{A as a,S as c,re as i,b as l,ue as n,D as o,M as r,C as s,Se as t,h as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-
|
|
1
|
+
import{t as e}from"./jsx-runtime-DhMPqcKn.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-Pqm5yXtL.js";import{a as t,t as n}from"./jsx-runtime-
|
|
1
|
+
import{o as e}from"./chunk-Pqm5yXtL.js";import{a as t,t as n}from"./jsx-runtime-DhMPqcKn.js";var r=e(t(),1);function i(e,t,n){let[i,a]=(0,r.useState)([]),[o,s]=(0,r.useState)(`open`);return(0,r.useEffect)(()=>{a([]),s(`open`);let r=`/api/whatsapp-reader/stream?sessionId=${encodeURIComponent(e)}&projectDir=${encodeURIComponent(t)}&session_key=${encodeURIComponent(n)}`,i=new EventSource(r);return i.onopen=()=>{console.info(`[admin-ui] wa-stream onopen sessionId=${e}`),s(`open`)},i.onmessage=e=>{try{a(t=>[...t,JSON.parse(e.data)])}catch{}},i.onerror=()=>{i.readyState===2&&(console.error(`[admin-ui] wa-stream onerror readyState=${i.readyState}`),s(`error`))},()=>i.close()},[e,t,n]),{turns:i,status:o}}var a=e=>{if(!e)return 1/0;let t=new Date(e).getTime();return Number.isNaN(t)?1/0:t};function o(e,t){let n=[],r=0;return e.forEach((e,t)=>n.push({sort:a(e.ts),sub:1,ins:r++,item:{kind:`turn`,turn:e,idx:t}})),t.forEach(e=>n.push({sort:a(e.ts),sub:0,ins:r++,item:{kind:`directive`,entry:e}})),n.sort((e,t)=>e.sort===t.sort?e.sort===1/0?e.ins-t.ins:e.sub-t.sub||e.ins-t.ins:e.sort<t.sort?-1:1).map(e=>e.item)}function s(e,t){let[n,i]=(0,r.useState)([]);return(0,r.useEffect)(()=>{if(typeof fetch!=`function`)return;let n=!0,r=`/api/whatsapp-reader/directives?sessionId=${encodeURIComponent(e)}&session_key=${encodeURIComponent(t)}`;return fetch(r).then(e=>e.ok?e.json():{entries:[]}).then(e=>{n&&i(Array.isArray(e.entries)?e.entries:[])}).catch(()=>{n&&i([])}),()=>{n=!1}},[e,t]),n}var c=n();function l(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function u(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function d({label:e,ts:t}){return(0,c.jsxs)(`div`,{className:`wa-turn-head`,children:[(0,c.jsx)(`span`,{className:`wa-who`,children:e}),(0,c.jsx)(`time`,{className:`wa-time`,children:l(t)})]})}function f({turn:e}){let[t,n]=(0,r.useState)(!1),i=e.kind===`tool-result`,a=i?`wa-turn wa-turn-result${e.isError?` is-error`:``}`:`wa-turn wa-turn-tool`,o=i?e.isError?`result (error)`:`result`:`↳ ${e.name}`,s=i?e.text:JSON.stringify(e.input,null,2);return(0,c.jsxs)(`div`,{className:a,children:[(0,c.jsxs)(`button`,{type:`button`,className:`wa-tool-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,c.jsx)(`span`,{className:`wa-chevron`,children:t?`▾`:`▸`}),(0,c.jsx)(`span`,{className:`wa-who`,children:o}),(0,c.jsx)(`time`,{className:`wa-time`,children:l(e.ts)})]}),t&&(0,c.jsx)(`pre`,{className:`wa-code`,children:s})]})}function p({entry:e,sessionId:t,sessionKey:n}){let[i,a]=(0,r.useState)(!1),[o,s]=(0,r.useState)(null),u=()=>{let r=!i;if(a(r),r&&o===null&&typeof fetch==`function`){let r=`/api/whatsapp-reader/directive?sessionId=${encodeURIComponent(t)}&name=${encodeURIComponent(e.name)}&session_key=${encodeURIComponent(n)}`;fetch(r).then(e=>e.ok?e.text():`(directive unavailable)`).then(s).catch(()=>s(`(directive unavailable)`))}};return(0,c.jsxs)(`div`,{className:`wa-turn wa-turn-directive`,children:[(0,c.jsxs)(`button`,{type:`button`,className:`wa-tool-toggle`,"aria-expanded":i,onClick:u,children:[(0,c.jsx)(`span`,{className:`wa-chevron`,children:i?`▾`:`▸`}),(0,c.jsxs)(`span`,{className:`wa-who`,children:[`⚙ directive injected (`,e.len,` B)`]}),(0,c.jsx)(`time`,{className:`wa-time`,children:l(e.ts)})]}),i&&(0,c.jsx)(`pre`,{className:`wa-code`,children:o??`Loading…`})]})}function m(e,t){switch(e.kind){case`operator-inbound`:return(0,c.jsxs)(`div`,{className:`wa-turn wa-turn-in`,children:[(0,c.jsx)(d,{label:`Operator`,ts:e.ts}),(0,c.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`operator-typed`:return(0,c.jsxs)(`div`,{className:`wa-turn wa-turn-in wa-turn-typed`,children:[(0,c.jsx)(d,{label:`Operator (web)`,ts:e.ts}),(0,c.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-text`:return(0,c.jsxs)(`div`,{className:`wa-turn wa-turn-think`,children:[(0,c.jsx)(d,{label:`Agent`,ts:e.ts}),(0,c.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-reply`:return(0,c.jsxs)(`div`,{className:`wa-turn wa-turn-out`,children:[(0,c.jsx)(d,{label:`Agent`,ts:e.ts}),(0,c.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-reply-document`:return(0,c.jsxs)(`div`,{className:`wa-turn wa-turn-out`,children:[(0,c.jsx)(d,{label:`Agent`,ts:e.ts}),(0,c.jsxs)(`p`,{className:`wa-doc`,children:[`📎 sent document(s): `,e.files.map(u).join(`, `)]}),e.caption&&(0,c.jsx)(`p`,{className:`wa-body`,children:e.caption})]},t);case`tool-call`:case`tool-result`:return(0,c.jsx)(f,{turn:e},t)}}function h(e,t,n){return e.map((e,r)=>e.kind===`turn`?m(e.turn,r):(0,c.jsx)(p,{entry:e.entry,sessionId:t,sessionKey:n},r))}var g=new Set([`operator-inbound`,`operator-typed`,`agent-reply`,`agent-reply-document`]),_=`maxy:whatsapp-reader:clean-view`;function v(e){return e.filter(e=>e.kind===`turn`&&g.has(e.turn.kind))}function y({sessionId:e,projectDir:t,sessionKey:n,renderItems:a=h,cleanViewToggle:l=!1,forceDeliveredOnly:u=!1}){let{turns:d,status:f}=i(e,t,n),p=o(d,s(e,n)),[m,g]=(0,r.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(_)===`1`}catch{return!1}}),y=()=>g(e=>{let t=!e;try{window.localStorage.setItem(_,t?`1`:`0`)}catch{}return t}),b=u||l&&m?v(p):p,x=(0,r.useRef)(null),S=(0,r.useRef)(!0),[C,w]=(0,r.useState)(!0),T=e=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight<=32;S.current=t,w(e=>e===t?e:t)};return(0,r.useLayoutEffect)(()=>{let e=x.current;e&&S.current&&(e.scrollTop=e.scrollHeight)},[d,m]),(0,c.jsxs)(`div`,{className:`wa-reader${l?` wa-reader--clean-toggle`:``}`,children:[(0,c.jsx)(`div`,{className:`wa-reader-thread`,ref:x,onScroll:()=>{let e=x.current;e&&T(e)},children:(0,c.jsxs)(`div`,{className:`wa-thread-scroll`,children:[f===`error`&&(0,c.jsx)(`div`,{className:`wa-reader-error`,children:`Stream disconnected.`}),d.length===0&&f===`open`&&(0,c.jsx)(`div`,{className:`wa-reader-placeholder`,children:`No messages in this conversation yet.`}),a(b,e,n)]})}),!C&&(0,c.jsx)(`button`,{type:`button`,className:`wa-jump`,onClick:()=>{let e=x.current;e&&(e.scrollTop=e.scrollHeight,S.current=!0,w(!0))},"aria-label":`Jump to latest message`,title:`Jump to latest message`,children:`↓`}),l&&!u&&(0,c.jsxs)(`button`,{type:`button`,className:`wa-clean-toggle${m?` is-active`:``}`,role:`switch`,"aria-checked":m,onClick:y,title:m?`Showing delivered messages only — click to show tool calls, results, and narration`:`Hide tool calls, results, and narration — show delivered messages only`,children:[(0,c.jsx)(`span`,{className:`wa-clean-label`,children:`Messages only`}),(0,c.jsx)(`span`,{className:`wa-switch`,"aria-hidden":`true`,children:(0,c.jsx)(`span`,{className:`wa-switch-thumb`})})]})]})}export{y as n,u as r,p as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-Pqm5yXtL.js";import{a as t,i as n,t as r}from"./jsx-runtime-DhMPqcKn.js";import{n as i}from"./file-download-7T2ye2nL.js";import{n as a,t as o}from"./AdminLoginScreens-B11_s63y.js";import{n as s,t as c}from"./AdminShell-CXYu03dO.js";import"./useSelectionMode-DDpddXMY.js";import"./Checkbox-D01p5NFD.js";import{n as l}from"./Transcript-NcTfeF7W.js";var u=n(),d=e(t(),1),f=r();function p({onOpen:e}){return(0,f.jsx)(`footer`,{className:`admin-footer`,children:(0,f.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,f.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,f.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function m(){let e=a(),[t,n]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,d.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let r=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()-r}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),u=(0,d.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,f.jsx)(i,{cacheKey:e.cacheKey,onSessionExpired:u,surface:`chat`,children:(0,f.jsx)(c,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(p,{onOpen:r}),(0,f.jsx)(s,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,f.jsx)(f.Fragment,{children:t.selectedWhatsapp&&e.cacheKey?(0,f.jsx)(l,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,cleanViewToggle:!0},t.selectedWhatsapp.sessionId):(0,f.jsx)(`main`,{})})})}):(0,f.jsx)(o,{auth:e})}(0,u.createRoot)(document.getElementById(`root`)).render((0,f.jsx)(m,{}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./path-
|
|
1
|
+
import{n as e,t}from"./path-BAQ3hXlG.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-t9p-NJH2.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-7-VefyJD.js";import{n as e}from"./chunk-7N4EOEYR-BlBbZdpM.js";export{e as createArchitectureServices};
|