@rubytech/create-maxy-code 0.1.537 → 0.1.539
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +121 -7
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +12 -0
- package/payload/platform/plugins/docs/PLUGIN.md +2 -0
- package/payload/platform/plugins/docs/references/admin-ui.md +40 -6
- package/payload/platform/plugins/docs/references/channel-wake-and-prompt.md +75 -0
- package/payload/platform/plugins/scheduling/PLUGIN.md +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-description.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-description.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-description.test.js +59 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-description.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-get.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-get.js +6 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-get.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.js +10 -6
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.js.map +1 -1
- package/payload/platform/plugins/whatsapp/PLUGIN.md +2 -0
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js +17 -2
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +16 -0
- package/payload/platform/plugins/whatsapp/skills/connect-whatsapp/SKILL.md +1 -1
- package/payload/platform/plugins/whatsapp/skills/manage-whatsapp-config/SKILL.md +29 -9
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +15 -2
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
- package/payload/platform/services/webchat-channel/dist/notification.d.ts +31 -0
- package/payload/platform/services/webchat-channel/dist/notification.d.ts.map +1 -1
- package/payload/platform/services/webchat-channel/dist/notification.js +31 -1
- package/payload/platform/services/webchat-channel/dist/notification.js.map +1 -1
- package/payload/platform/services/webchat-channel/dist/server.d.ts.map +1 -1
- package/payload/platform/services/webchat-channel/dist/server.js +15 -1
- package/payload/platform/services/webchat-channel/dist/server.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts +1 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.d.ts +1 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.js +5 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.js.map +1 -1
- package/payload/server/{chunk-44Z4ZFYS.js → chunk-S4FIEM3L.js} +62 -10
- package/payload/server/{manager-AJSPM6X2.js → manager-5QV2EAZ2.js} +1 -1
- package/payload/server/public/activity.html +5 -5
- package/payload/server/public/agents.html +4 -4
- package/payload/server/public/assets/{AdminLoginScreens-CYFf2awh.js → AdminLoginScreens-BpHnjHp_.js} +1 -1
- package/payload/server/public/assets/AdminLoginScreens-BpHnjHp_.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-BpHnjHp_.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-D24evn4t.js +2 -0
- package/payload/server/public/assets/AdminShell-D24evn4t.js.br +0 -0
- package/payload/server/public/assets/AdminShell-D24evn4t.js.gz +0 -0
- package/payload/server/public/assets/{activity-BH65sm9Q.js → activity-ZVUTB5uZ.js} +1 -1
- package/payload/server/public/assets/activity-ZVUTB5uZ.js.br +0 -0
- package/payload/server/public/assets/activity-ZVUTB5uZ.js.gz +0 -0
- package/payload/server/public/assets/{admin-CQtEjRGU.js → admin-XJqQz3QJ.js} +1 -1
- package/payload/server/public/assets/admin-XJqQz3QJ.js.br +0 -0
- package/payload/server/public/assets/admin-XJqQz3QJ.js.gz +0 -0
- package/payload/server/public/assets/{agents-CjhOWwl5.js → agents-Dc9SNC9N.js} +1 -1
- package/payload/server/public/assets/agents-Dc9SNC9N.js.br +0 -0
- package/payload/server/public/assets/agents-Dc9SNC9N.js.gz +0 -0
- package/payload/server/public/assets/{browser-DGXpfL99.js → browser-CCedMIga.js} +1 -1
- package/payload/server/public/assets/browser-CCedMIga.js.br +0 -0
- package/payload/server/public/assets/browser-CCedMIga.js.gz +0 -0
- package/payload/server/public/assets/calendar-BDoMLP2j.js +1 -0
- package/payload/server/public/assets/calendar-BDoMLP2j.js.br +0 -0
- package/payload/server/public/assets/calendar-BDoMLP2j.js.gz +0 -0
- package/payload/server/public/assets/chat-BAhoqTY9.js +1 -0
- package/payload/server/public/assets/chat-BAhoqTY9.js.br +0 -0
- package/payload/server/public/assets/chat-BAhoqTY9.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-NGLHgPjF.js +1 -0
- package/payload/server/public/assets/chevron-right-B4B7OkG8.js +1 -0
- package/payload/server/public/assets/chevron-right-B4B7OkG8.js.br +0 -0
- package/payload/server/public/assets/clock-7IMwxJdH.js +1 -0
- package/payload/server/public/assets/clock-7IMwxJdH.js.br +0 -0
- package/payload/server/public/assets/clock-7IMwxJdH.js.gz +0 -0
- package/payload/server/public/assets/copy-PkR4EFD6.js +1 -0
- package/payload/server/public/assets/copy-PkR4EFD6.js.br +0 -0
- package/payload/server/public/assets/copy-PkR4EFD6.js.gz +0 -0
- package/payload/server/public/assets/data-yQYhw2IR.js +1 -0
- package/payload/server/public/assets/data-yQYhw2IR.js.br +1 -0
- package/payload/server/public/assets/data-yQYhw2IR.js.gz +0 -0
- package/payload/server/public/assets/{file-text-CbQoZfJD.js → file-text-BA9p7TLU.js} +1 -1
- package/payload/server/public/assets/file-text-BA9p7TLU.js.br +0 -0
- package/payload/server/public/assets/file-text-BA9p7TLU.js.gz +0 -0
- package/payload/server/public/assets/graph-C8cQ6Nqf.js +51 -0
- package/payload/server/public/assets/graph-C8cQ6Nqf.js.br +0 -0
- package/payload/server/public/assets/graph-C8cQ6Nqf.js.gz +0 -0
- package/payload/server/public/assets/{graph-labels-D695CsC9.js → graph-labels-CiK412vE.js} +1 -1
- package/payload/server/public/assets/graph-labels-CiK412vE.js.br +0 -0
- package/payload/server/public/assets/graph-labels-CiK412vE.js.gz +0 -0
- package/payload/server/public/assets/operator-CaQAEUBu.js +1 -0
- package/payload/server/public/assets/operator-CaQAEUBu.js.br +0 -0
- package/payload/server/public/assets/operator-CaQAEUBu.js.gz +0 -0
- package/payload/server/public/assets/page-CpJpyoPS.js +32 -0
- package/payload/server/public/assets/page-CpJpyoPS.js.br +0 -0
- package/payload/server/public/assets/page-CpJpyoPS.js.gz +0 -0
- package/payload/server/public/assets/page-D0ShNyGE.js +1 -0
- package/payload/server/public/assets/page-D0ShNyGE.js.br +0 -0
- package/payload/server/public/assets/page-D0ShNyGE.js.gz +0 -0
- package/payload/server/public/assets/{play-CbRU6q0T.js → play-huZpq9ra.js} +1 -1
- package/payload/server/public/assets/play-huZpq9ra.js.br +0 -0
- package/payload/server/public/assets/play-huZpq9ra.js.gz +0 -0
- package/payload/server/public/assets/{public-CqbKJ-Q3.js → public--8RWWGjF.js} +1 -1
- package/payload/server/public/assets/public--8RWWGjF.js.br +0 -0
- package/payload/server/public/assets/public--8RWWGjF.js.gz +0 -0
- package/payload/server/public/assets/{rotate-ccw-CjliWBou.js → rotate-ccw-g7l4ZSR3.js} +1 -1
- package/payload/server/public/assets/rotate-ccw-g7l4ZSR3.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-g7l4ZSR3.js.gz +0 -0
- package/payload/server/public/assets/routines-DzFcPNMb.js +2 -0
- package/payload/server/public/assets/routines-DzFcPNMb.js.br +0 -0
- package/payload/server/public/assets/routines-DzFcPNMb.js.gz +0 -0
- package/payload/server/public/assets/{skills-ipK9BJFb.js → skills-5vl_Bt9U.js} +1 -1
- package/payload/server/public/assets/skills-5vl_Bt9U.js.br +0 -0
- package/payload/server/public/assets/skills-5vl_Bt9U.js.gz +0 -0
- package/payload/server/public/assets/{tasks-CGcJHQ3X.js → tasks-DQHtJ8Pq.js} +2 -2
- package/payload/server/public/assets/tasks-DQHtJ8Pq.js.br +0 -0
- package/payload/server/public/assets/tasks-DQHtJ8Pq.js.gz +0 -0
- package/payload/server/public/assets/{triangle-alert-CjsLPsBD.js → triangle-alert-Cy4Z0uFv.js} +1 -1
- package/payload/server/public/assets/triangle-alert-Cy4Z0uFv.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-Cy4Z0uFv.js.gz +0 -0
- package/payload/server/public/assets/{useCopyFeedback-umIgCxI_.js → useCopyFeedback-BwK1RhmF.js} +1 -1
- package/payload/server/public/assets/useCopyFeedback-BwK1RhmF.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-BwK1RhmF.js.gz +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-C7TtIbR3.js +14 -0
- package/payload/server/public/assets/useSubAccountSwitcher-C7TtIbR3.js.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-C7TtIbR3.js.gz +0 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-D8jXV7R5.css → useSubAccountSwitcher-DCkivCBS.css} +1 -1
- package/payload/server/public/assets/useSubAccountSwitcher-DCkivCBS.css.br +0 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-D8jXV7R5.css.gz → useSubAccountSwitcher-DCkivCBS.css.gz} +0 -0
- package/payload/server/public/assets/useVoiceRecorder-DgyAGgmF.js +2 -0
- package/payload/server/public/assets/useVoiceRecorder-DgyAGgmF.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-DgyAGgmF.js.gz +0 -0
- package/payload/server/public/assets/{wrench-DtfKfR4s.js → wrench-CICORrSc.js} +1 -1
- package/payload/server/public/assets/wrench-CICORrSc.js.br +0 -0
- package/payload/server/public/assets/wrench-CICORrSc.js.gz +0 -0
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +8 -7
- package/payload/server/public/chat.html +13 -13
- package/payload/server/public/data.html +11 -11
- package/payload/server/public/graph.html +9 -9
- package/payload/server/public/index.html +14 -14
- package/payload/server/public/operator.html +14 -14
- package/payload/server/public/public.html +13 -13
- package/payload/server/public/routines.html +6 -6
- package/payload/server/public/skills.html +5 -5
- package/payload/server/public/tasks.html +6 -6
- package/payload/server/server.js +436 -108
- package/payload/server/public/assets/AdminLoginScreens-CYFf2awh.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-CYFf2awh.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js +0 -2
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js.br +0 -0
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js.gz +0 -0
- package/payload/server/public/assets/activity-BH65sm9Q.js.br +0 -0
- package/payload/server/public/assets/activity-BH65sm9Q.js.gz +0 -0
- package/payload/server/public/assets/admin-CQtEjRGU.js.br +0 -0
- package/payload/server/public/assets/admin-CQtEjRGU.js.gz +0 -0
- package/payload/server/public/assets/agents-CjhOWwl5.js.br +0 -0
- package/payload/server/public/assets/agents-CjhOWwl5.js.gz +0 -0
- package/payload/server/public/assets/browser-DGXpfL99.js.br +0 -0
- package/payload/server/public/assets/browser-DGXpfL99.js.gz +0 -0
- package/payload/server/public/assets/calendar-Cu4yjEuX.js +0 -1
- package/payload/server/public/assets/calendar-Cu4yjEuX.js.br +0 -0
- package/payload/server/public/assets/calendar-Cu4yjEuX.js.gz +0 -0
- package/payload/server/public/assets/chat-0na4XVZC.js +0 -1
- package/payload/server/public/assets/chat-0na4XVZC.js.br +0 -0
- package/payload/server/public/assets/chat-0na4XVZC.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-DHzJobWp.js +0 -1
- package/payload/server/public/assets/chevron-left-DHzJobWp.js.br +0 -0
- package/payload/server/public/assets/chevron-right-yg4DMfLT.js +0 -1
- package/payload/server/public/assets/chevron-right-yg4DMfLT.js.br +0 -0
- package/payload/server/public/assets/clock-BIDzihvp.js +0 -1
- package/payload/server/public/assets/clock-BIDzihvp.js.br +0 -0
- package/payload/server/public/assets/clock-BIDzihvp.js.gz +0 -0
- package/payload/server/public/assets/data-Ql9qG3YO.js +0 -1
- package/payload/server/public/assets/data-Ql9qG3YO.js.br +0 -0
- package/payload/server/public/assets/data-Ql9qG3YO.js.gz +0 -0
- package/payload/server/public/assets/file-text-CbQoZfJD.js.br +0 -0
- package/payload/server/public/assets/file-text-CbQoZfJD.js.gz +0 -0
- package/payload/server/public/assets/graph-7414Kjn9.js +0 -51
- package/payload/server/public/assets/graph-7414Kjn9.js.br +0 -0
- package/payload/server/public/assets/graph-7414Kjn9.js.gz +0 -0
- package/payload/server/public/assets/graph-labels-D695CsC9.js.br +0 -0
- package/payload/server/public/assets/graph-labels-D695CsC9.js.gz +0 -0
- package/payload/server/public/assets/maximize-2-CD0gTjW_.js +0 -1
- package/payload/server/public/assets/maximize-2-CD0gTjW_.js.br +0 -0
- package/payload/server/public/assets/maximize-2-CD0gTjW_.js.gz +0 -0
- package/payload/server/public/assets/operator-CLw4PZs5.js +0 -1
- package/payload/server/public/assets/operator-CLw4PZs5.js.br +0 -0
- package/payload/server/public/assets/operator-CLw4PZs5.js.gz +0 -0
- package/payload/server/public/assets/page-BNRFmFc-.js +0 -32
- package/payload/server/public/assets/page-BNRFmFc-.js.br +0 -0
- package/payload/server/public/assets/page-BNRFmFc-.js.gz +0 -0
- package/payload/server/public/assets/page-BRr295G2.js +0 -1
- package/payload/server/public/assets/page-BRr295G2.js.br +0 -0
- package/payload/server/public/assets/page-BRr295G2.js.gz +0 -0
- package/payload/server/public/assets/play-CbRU6q0T.js.br +0 -0
- package/payload/server/public/assets/play-CbRU6q0T.js.gz +0 -0
- package/payload/server/public/assets/public-CqbKJ-Q3.js.br +0 -0
- package/payload/server/public/assets/public-CqbKJ-Q3.js.gz +0 -0
- package/payload/server/public/assets/rotate-ccw-CjliWBou.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-CjliWBou.js.gz +0 -0
- package/payload/server/public/assets/routines-yJuRuBfn.js +0 -2
- package/payload/server/public/assets/routines-yJuRuBfn.js.br +0 -0
- package/payload/server/public/assets/routines-yJuRuBfn.js.gz +0 -0
- package/payload/server/public/assets/skills-ipK9BJFb.js.br +0 -0
- package/payload/server/public/assets/skills-ipK9BJFb.js.gz +0 -0
- package/payload/server/public/assets/tasks-CGcJHQ3X.js.br +0 -0
- package/payload/server/public/assets/tasks-CGcJHQ3X.js.gz +0 -0
- package/payload/server/public/assets/triangle-alert-CjsLPsBD.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-CjsLPsBD.js.gz +0 -0
- package/payload/server/public/assets/useCopyFeedback-umIgCxI_.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-umIgCxI_.js.gz +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-D8jXV7R5.css.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js +0 -14
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js.gz +0 -0
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js +0 -2
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js.gz +0 -0
- package/payload/server/public/assets/wrench-DtfKfR4s.js.br +0 -0
- package/payload/server/public/assets/wrench-DtfKfR4s.js.gz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{J as t,R as n,W as r,X as i,_ as a,n as o,q as s,v as c}from"./useSubAccountSwitcher-UMg53kKF.js";import{D as l,O as u,k as d,t as f}from"./AdminShell-7l3ubYFZ.js";import{t as p}from"./triangle-alert-CjsLPsBD.js";var m=t(),h=e(i(),1),g=r(),_=`—`;function v(e){switch(e){case`waiting`:return`Waiting`;case`never-run`:return`Never run`;case`never-succeeded`:return`Never succeeded`;case`failing`:return`Failing`;case`stalled`:return`Stalled`;case`running`:return`Running`;case`ok`:return`Healthy`}}var y={waiting:`Armed and not due yet. It has no start-up run and its first interval has not elapsed, so it has correctly not fired.`,"never-run":`Its interval has elapsed and it still has not fired once. This is not the same as waiting its turn.`,"never-succeeded":`It has fired, and not one run has finished. The work this loop exists to do has never happened.`,failing:`It worked before and is failing now.`,stalled:`It has not started within three of its own intervals. Something is holding it up.`,running:`A run is in progress right now.`,ok:`The last run finished and the next is due within the interval.`},b=new Set([`never-run`,`never-succeeded`,`failing`,`stalled`]),x=10;function S(e){return e===null||!Number.isFinite(e)?_:`${e.toFixed(1)}%`}function C(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function w(e,t){if(e===null)return _;let n=t-e;return n<0?`in ${C(-n)}`:n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function T(e,t){if(e===null)return _;let n=e-t;return n>=0?`in ${C(n)}`:`overdue by ${C(-n)}`}function E({loops:e,nowMs:t=Date.now()}){let[n,r]=(0,h.useState)(!1);if(!e)return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsx)(`p`,{className:`activity-loops-empty`,children:`Scheduled work could not be read from the server.`})]});let i=e.armed-e.rows.length,a=e.rows.filter(e=>b.has(e.state)),o=e.rows.filter(e=>!b.has(e.state)&&typeof e.cpuPct==`number`&&e.cpuPct>=x),s=n?e.rows:[...a,...o];return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsxs)(`p`,{className:`activity-loops-sub`,children:[e.armed,` `,e.armed===1?`loop`:`loops`,` armed`,a.length>0?` · ${a.length} ${a.length===1?`needs`:`need`} attention`:` · all healthy`,o.length>0&&` · ${o.length} using significant processor`,`. `,(0,g.jsx)(`button`,{type:`button`,className:`activity-loops-toggle`,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`Show less`:`Show all`})]}),typeof e.processPct==`number`&&(0,g.jsxs)(`p`,{className:`activity-loops-cpu`,children:[`Server process at `,e.processPct.toFixed(1),`% of one core`,typeof e.attributedPct==`number`&&(0,g.jsxs)(g.Fragment,{children:[` · these loops explain `,e.attributedPct.toFixed(1),`%`]}),typeof e.unattributedPct==`number`&&e.unattributedPct>=1&&(0,g.jsxs)(g.Fragment,{children:[` · `,(0,g.jsxs)(`strong`,{children:[e.unattributedPct.toFixed(1),`% is not from these loops`]})]})]}),i>0&&(0,g.jsxs)(`p`,{className:`activity-loops-omission`,role:`status`,children:[i,` armed `,i===1?`loop is`:`loops are`,` missing from this list. The server armed `,e.armed,` but sent `,e.rows.length,`.`]}),s.length===0?null:(0,g.jsx)(`div`,{className:`activity-table-scroll`,children:(0,g.jsxs)(`table`,{className:`activity-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Loop`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`State`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Every`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last run`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last OK`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Took`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`CPU`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Runs`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Produced`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Next due`})]})}),(0,g.jsx)(`tbody`,{children:s.map(e=>(0,g.jsxs)(`tr`,{className:b.has(e.state)?`activity-loop-row activity-loop-unhealthy`:`activity-loop-row`,children:[(0,g.jsx)(`td`,{className:`activity-td`,children:e.name}),(0,g.jsx)(`td`,{className:`activity-td`,title:y[e.state],children:(0,g.jsxs)(`span`,{className:`activity-state`,children:[(0,g.jsx)(`span`,{className:e.state===`ok`?`activity-state-dot is-healthy`:b.has(e.state)?`activity-state-dot is-unhealthy`:`activity-state-dot`,"aria-hidden":`true`}),v(e.state)]})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:C(e.intervalMs)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastStartMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastSuccessMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:e.lastDurationMs===null?_:`${e.lastDurationMs} ms`}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,title:e.cpuAttributable?e.detached?`Includes the processor time of the separate process this loop starts.`:void 0:`This loop waits on other work while it runs, so the processor time it uses cannot be separated from the rest of the server.`,children:S(e.cpuPct)}),(0,g.jsxs)(`td`,{className:`activity-td activity-num`,children:[e.successCount,`/`,e.runCount]}),(0,g.jsx)(`td`,{className:`activity-td activity-loop-note`,children:(0,g.jsx)(`span`,{className:`activity-loop-note-text`,title:e.lastError??e.lastNote??void 0,children:e.lastError??e.lastNote??_})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:T(e.nextDueMs,t)})]},e.name))})]})}),(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`Runs`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Finished runs out of attempted runs since the server started. 0 out of a large number means it has tried many times and never once finished.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`CPU`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Share of one processor core this loop is using, measured between the last two refreshes. It includes any separate process the loop starts, and can pass 100% because those run alongside each other. A dash means it could not be measured: the loop waits on other work while it runs, so its share cannot be separated from the rest of the server.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:_}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Not measured. It does not mean zero.`})]})]})]})}var D=`maxy-admin-session-key`;function O(e){switch(e.costUnavailable){case`metering-failed`:return`Cost could not be calculated: ${e.meteringError??`the transcript could not be read`}`;case`model-not-priced`:return`No published price for this model, so cost cannot be estimated.`;case`no-transcript`:return`This session has no transcript yet, so there is nothing to cost.`;default:return}}var k=[{key:`lastMessageAt`,label:`Last activity`,dir:-1},{key:`activeMsInRange`,label:`Active time`,dir:-1},{key:`costGbp`,label:`Cost`,dir:-1},{key:`accountId`,label:`Account name`,dir:1}],A=[{key:`title`,label:`Session`,help:`The conversation name, or its short id when it has none yet.`},{key:`model`,label:`Model`,help:`The model that answered the most recent turn.`},{key:`status`,label:`Status`,help:`What the process is doing right now.`},{key:`activeMsInRange`,label:`Active`,help:`Time this session spent thinking, writing and running tools inside the selected range. This is worked time, not elapsed time.`},{key:`ageMs`,label:`Age`,help:`How long ago this conversation started. Wall-clock, so it counts every hour nobody was working.`},{key:`lastMessageAt`,label:`Last activity`,help:`The clock time of the most recent message, in your timezone. A date appears once it is not today.`},{key:`turnCount`,label:`Turns`,help:`Messages exchanged. A trailing + means the count is a minimum — the conversation is too long to count exactly.`},{key:`rssKb`,label:`RAM`,help:`Memory held by this session and all its helper processes together.`},{key:`cpuPct`,label:`CPU (avg)`,help:`AVERAGE share of one processor core over the last census interval, up to 60 seconds. It is not a reading of this instant, so a session that answered a turn a minute ago still shows a high figure while sitting quiet now. Can exceed 100% because a session runs many processes at once.`},{key:`tokensInRange`,label:`Tokens`,help:`Total tokens billed inside the selected range, added up across every day in it. A cumulative total, not the size of the conversation the model currently reads back.`},{key:`costGbp`,label:`Cost`,help:`Estimated spend inside the selected range, at published prices for this model.`}],j=[`activeMsInRange`,`lastMessageAt`,`cpuPct`,`tokensInRange`],M={label:`Account`,help:`The business this session belongs to. "untagged" means the session records no account.`};function N(e,t){let n=t?.[e];return n&&n.trim()!==``?n:e.slice(0,8)}var P=`—`;function F(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function I(e){return e===null||!Number.isFinite(e)?P:`${(e/1024/1024).toFixed(1)} GB`}function L(e,t){if(!e)return P;let n=Date.parse(e);if(!Number.isFinite(n))return P;let r=new Date(n),i=new Date(t),a=`${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`;return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()?a:`${r.getDate()} ${r.toLocaleString(`en-GB`,{month:`short`})} ${a}`}function R(e){return e===null||!Number.isFinite(e)?P:`${e.toFixed(1)}%`}function z(e){return e===null||!Number.isFinite(e)?P:e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function B(e){return e===null||!Number.isFinite(e)?P:`£${e.toFixed(2)}`}function V(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/6e4);return`${Math.floor(t/60)}h ${t%60}m`}function H(e,t,n,r){let i=e[n],a=t[n];if(i===null&&a===null)return 0;if(i===null)return 1;if(a===null)return-1;if(n===`lastMessageAt`){let e=Date.parse(String(i)),t=Date.parse(String(a));return!Number.isFinite(e)&&!Number.isFinite(t)?0:Number.isFinite(e)?Number.isFinite(t)?(e-t)*r:-1:1}return typeof i==`number`&&typeof a==`number`?(i-a)*r:String(i).localeCompare(String(a))*r}function U(e){return e.toISOString().slice(0,10)}function W(e){let t=e.getUTCFullYear(),n=e.getUTCMonth();return{from:U(new Date(Date.UTC(t,n,1))),to:U(new Date(Date.UTC(t,n+1,0)))}}function G(e,t){let n=new Date(`${e}T00:00:00.000Z`);return W(new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1)))}function ee(e,t){return{from:U(new Date(t-(e-1)*864e5)),to:U(new Date(t))}}function K(e){return new Date(`${e}T00:00:00.000Z`).toLocaleString(`en-GB`,{month:`long`,year:`numeric`,timeZone:`UTC`})}function q(e){if(e===null)return!1;let t=W(new Date(`${e.from}T00:00:00.000Z`));return t.from===e.from&&t.to===e.to}function J(e,t,n){switch(e){case`title`:return t.title??t.sessionId.slice(0,8);case`model`:return t.model??P;case`status`:return t.status??P;case`activeMsInRange`:return V(t.activeMsInRange);case`ageMs`:return F(t.ageMs);case`lastMessageAt`:return L(t.lastMessageAt,n);case`turnCount`:return t.turnCount===null?P:`${t.turnCount}${t.turnCountCapped?`+`:``}`;case`rssKb`:return I(t.rssKb);case`cpuPct`:return R(t.cpuPct);case`tokensInRange`:return z(t.tokensInRange);case`costGbp`:return B(t.costGbp);default:return P}}function Y({adminFetch:e,cacheKey:t}){let[r,i]=(0,h.useState)(null),[s,c]=(0,h.useState)(null),[d,f]=(0,h.useState)(!1),[m,_]=(0,h.useState)(`lastMessageAt`),[v,y]=(0,h.useState)(-1),[b,x]=(0,h.useState)(()=>W(new Date)),[S,C]=(0,h.useState)(!0),[w,T]=(0,h.useState)(!0),[D,I]=(0,h.useState)(!1),L=(0,h.useCallback)(async(e,n)=>{t&&await o(t,e)&&window.location.assign(`/chat?session=${encodeURIComponent(n)}`)},[t]),R=(0,h.useRef)(!1),z=(0,h.useRef)(void 0),B=(0,h.useCallback)(async t=>{if(R.current){z.current=t;return}R.current=!0;try{let n=await e(`/api/admin/activity${t?`?from=${t.from}&to=${t.to}`:``}`);if(n.status===403){c(`This view is available to the house account only.`),f(!0);return}if(!n.ok){c(`The session manager did not answer (status ${n.status}).`),f(!0);return}i(await n.json()),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{f(!0),R.current=!1;let e=z.current;z.current=void 0,e!==void 0&&B(e)}},[e]);(0,h.useEffect)(()=>{B(b);let e=setInterval(()=>void B(b),15e3);return()=>clearInterval(e)},[B,b]);let V=(0,h.useMemo)(()=>r?[...r.rows].sort((e,t)=>H(e,t,m,v)):[],[r,m,v]),U=(0,h.useMemo)(()=>V.filter(e=>e.status===`busy`?S:e.status===`idle`?w:!0),[V,S,w]),Y=V.length-U.length;if(!d)return(0,g.jsx)(a,{surface:`gate`});if(s)return(0,g.jsx)(`div`,{className:`activity-empty`,children:s});if(!r)return(0,g.jsx)(`div`,{className:`activity-empty`,children:`No response.`});let{accounts:X,census:Z,censusAgeMs:Q}=r,te=Date.now(),ne=X.onDisk!==null&&X.onDisk>X.valid,$=r.range===void 0?b:r.range;return(0,g.jsxs)(`div`,{className:`ui-page ui-page--full activity-body`,children:[(0,g.jsxs)(`div`,{className:`activity-head`,children:[(0,g.jsxs)(`span`,{className:`activity-title`,children:[(0,g.jsx)(n,{size:16}),` Live sessions`]}),(0,g.jsxs)(`span`,{className:`activity-meta`,children:[Y>0?`${U.length} of ${V.length} live · ${Y} hidden`:`${V.length} live`,` · `,X.valid,` accounts`,X.untaggedCount>0?` · ${X.untaggedCount} untagged`:``]})]}),(0,g.jsxs)(`div`,{className:`activity-controls`,children:[(0,g.jsxs)(`div`,{className:`activity-control activity-range`,children:[(0,g.jsx)(l,{variant:`secondary`,size:`sm`,"aria-label":`Previous month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,-1)),children:`‹`}),(0,g.jsx)(`span`,{className:`activity-range-label`,children:b===null?`All time`:q(b)?K(b.from):`${b.from} → ${b.to}`}),(0,g.jsx)(l,{variant:`secondary`,size:`sm`,"aria-label":`Next month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,1)),children:`›`})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-presets`,children:[(0,g.jsx)(l,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&q(b)&&b.from===W(new Date).from,onClick:()=>x(W(new Date)),children:`This month`}),(0,g.jsx)(l,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&!q(b),onClick:()=>x(ee(7,Date.now())),children:`Last 7 days`}),(0,g.jsx)(l,{variant:`secondary`,size:`sm`,"aria-pressed":b===null,onClick:()=>x(null),children:`All time`})]}),(0,g.jsxs)(`div`,{className:`activity-control`,children:[(0,g.jsx)(`label`,{className:`activity-control-label`,htmlFor:`activity-sort`,children:`Sort by`}),(0,g.jsx)(`span`,{className:`activity-select-wrap`,children:(0,g.jsx)(`select`,{id:`activity-sort`,className:`activity-select`,value:m,onChange:e=>{let t=k.find(t=>t.key===e.target.value);t&&(_(t.key),y(t.dir))},children:k.map(e=>(0,g.jsx)(`option`,{value:e.key,children:e.label},e.key))})})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-visibility`,children:[(0,g.jsx)(u,{checked:S,onChange:C,label:`Busy`}),(0,g.jsx)(u,{checked:w,onChange:T,label:`Idle`})]})]}),(0,g.jsxs)(`div`,{className:`activity-range-note`,children:[$===null?`Active time, tokens and cost cover each conversation’s whole history.`:`Active time, tokens and cost cover ${$.from} to ${$.to} (UTC), inclusive.`,r.fullRangeFallback&&(0,g.jsxs)(`strong`,{className:`activity-range-rejected`,children:[` `,`The range was not accepted, so these are all-time figures.`]})]}),(0,g.jsx)(`div`,{className:`activity-census`,children:Z===null?`No census collected yet, so memory and CPU are unavailable.`:`Memory and CPU measured ${F(Q)} ago, averaged over the minute before that · ${Z.cpuNull} of ${Z.live} without a CPU reading`}),ne&&(0,g.jsxs)(`div`,{className:`activity-warning`,children:[(0,g.jsx)(p,{size:14}),` `,X.onDisk,` account folders on disk but only`,` `,X.valid,` are readable. Sessions belonging to the rest cannot be attributed.`]}),V.length===0?(0,g.jsx)(`div`,{className:`activity-empty`,children:`No sessions are running.`}):U.length===0?(0,g.jsxs)(`div`,{className:`activity-empty`,children:[`All `,V.length,` running sessions are hidden by the Busy and Idle filters.`]}):(0,g.jsx)(`div`,{className:`activity-grid`,children:U.map(e=>{let n=e.accountId!==null&&!!t,r=n?()=>void L(e.accountId,e.sessionId):void 0;return(0,g.jsxs)(`article`,{className:`activity-card${n?` activity-card-clickable`:``}`,"data-testid":`activity-card`,"data-session-id":e.sessionId,role:n?`button`:void 0,tabIndex:n?0:void 0,onClick:r,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())}:void 0,children:[(0,g.jsx)(`h3`,{className:`activity-card-heading`,title:e.accountId??void 0,children:e.accountId===null?(0,g.jsx)(`span`,{className:`activity-untagged`,title:`This session records no account, so it cannot be attributed to a business.`,children:`untagged`}):N(e.accountId,X.names)}),(0,g.jsx)(`dl`,{className:`activity-card-rows`,children:A.map(t=>(0,g.jsxs)(`div`,{className:`activity-card-row`,children:[(0,g.jsx)(`dt`,{className:`activity-card-label`,"data-testid":`activity-card-label`,title:t.help,children:t.label}),(0,g.jsx)(`dd`,{className:`activity-card-value`,title:t.key===`costGbp`?O(e):void 0,children:J(t.key,e,te)})]},t.key))})]},e.sessionId)})}),V.length>0&&(0,g.jsxs)(`div`,{className:`activity-glossary`,children:[(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[D&&(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:M.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:M.help})]},`heading`),(D?A:A.filter(e=>j.includes(e.key))).map(e=>(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:e.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:e.help})]},e.key)),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:P}),(0,g.jsxs)(`dd`,{className:`activity-legend-def`,children:[`Not measured. It does not mean zero — a measured zero is written as a figure, so `,(0,g.jsx)(`em`,{children:`0h 0m`}),` and `,(0,g.jsx)(`em`,{children:`£0.00`}),` are real readings. Hover a dashed value for the reason where one exists.`]})]})]}),(0,g.jsx)(l,{variant:`secondary`,size:`sm`,className:`activity-glossary-toggle`,onClick:()=>I(e=>!e),children:D?`Show fewer`:`Explain every figure`})]}),(0,g.jsx)(E,{loops:r?.loops})]})}function X({cacheKey:e}){let{adminFetch:t}=s({initialCacheKey:e,surface:`activity`});return(0,g.jsx)(Y,{adminFetch:t,cacheKey:e})}function Z(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)(!1),[i,o]=(0,h.useState)(void 0),[s,l]=(0,h.useState)(null),[u,p]=(0,h.useState)(null),[m,_]=(0,h.useState)(null),[v,y]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(D)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&l(e.sessionId??null),p(e.role??null),_(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let b=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},[]),[x,S]=(0,h.useState)(!1),C=(0,h.useCallback)(async()=>{S(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`}return e}finally{S(!1)}},[]);return n?e?(0,g.jsx)(c,{cacheKey:e,surface:`activity`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=activity`);try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},children:(0,g.jsx)(f,{cacheKey:e,businessName:i,sessionId:s,onLogout:b,onDisconnect:C,disconnecting:x,userName:m,userAvatar:v,role:u,children:(0,g.jsx)(X,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`activity-page`,children:(0,g.jsxs)(`div`,{className:`activity-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`activity-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(a,{surface:`gate`})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(Z,{}));
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,J as n,Y as r,Z as i,_ as a,n as o,v as s,z as c}from"./useSubAccountSwitcher-C7TtIbR3.js";import{A as l,O as u,k as d,t as f}from"./AdminShell-D24evn4t.js";import{t as p}from"./triangle-alert-Cy4Z0uFv.js";var m=r(),h=e(i(),1),g=t(),_=`—`;function v(e){switch(e){case`waiting`:return`Waiting`;case`never-run`:return`Never run`;case`never-succeeded`:return`Never succeeded`;case`failing`:return`Failing`;case`stalled`:return`Stalled`;case`running`:return`Running`;case`ok`:return`Healthy`}}var y={waiting:`Armed and not due yet. It has no start-up run and its first interval has not elapsed, so it has correctly not fired.`,"never-run":`Its interval has elapsed and it still has not fired once. This is not the same as waiting its turn.`,"never-succeeded":`It has fired, and not one run has finished. The work this loop exists to do has never happened.`,failing:`It worked before and is failing now.`,stalled:`It has not started within three of its own intervals. Something is holding it up.`,running:`A run is in progress right now.`,ok:`The last run finished and the next is due within the interval.`},b=new Set([`never-run`,`never-succeeded`,`failing`,`stalled`]),x=10;function S(e){return e===null||!Number.isFinite(e)?_:`${e.toFixed(1)}%`}function C(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function w(e,t){if(e===null)return _;let n=t-e;return n<0?`in ${C(-n)}`:n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function T(e,t){if(e===null)return _;let n=e-t;return n>=0?`in ${C(n)}`:`overdue by ${C(-n)}`}function E({loops:e,nowMs:t=Date.now()}){let[n,r]=(0,h.useState)(!1);if(!e)return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsx)(`p`,{className:`activity-loops-empty`,children:`Scheduled work could not be read from the server.`})]});let i=e.armed-e.rows.length,a=e.rows.filter(e=>b.has(e.state)),o=e.rows.filter(e=>!b.has(e.state)&&typeof e.cpuPct==`number`&&e.cpuPct>=x),s=n?e.rows:[...a,...o];return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsxs)(`p`,{className:`activity-loops-sub`,children:[e.armed,` `,e.armed===1?`loop`:`loops`,` armed`,a.length>0?` · ${a.length} ${a.length===1?`needs`:`need`} attention`:` · all healthy`,o.length>0&&` · ${o.length} using significant processor`,`. `,(0,g.jsx)(`button`,{type:`button`,className:`activity-loops-toggle`,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`Show less`:`Show all`})]}),typeof e.processPct==`number`&&(0,g.jsxs)(`p`,{className:`activity-loops-cpu`,children:[`Server process at `,e.processPct.toFixed(1),`% of one core`,typeof e.attributedPct==`number`&&(0,g.jsxs)(g.Fragment,{children:[` · these loops explain `,e.attributedPct.toFixed(1),`%`]}),typeof e.unattributedPct==`number`&&e.unattributedPct>=1&&(0,g.jsxs)(g.Fragment,{children:[` · `,(0,g.jsxs)(`strong`,{children:[e.unattributedPct.toFixed(1),`% is not from these loops`]})]})]}),i>0&&(0,g.jsxs)(`p`,{className:`activity-loops-omission`,role:`status`,children:[i,` armed `,i===1?`loop is`:`loops are`,` missing from this list. The server armed `,e.armed,` but sent `,e.rows.length,`.`]}),s.length===0?null:(0,g.jsx)(`div`,{className:`activity-table-scroll`,children:(0,g.jsxs)(`table`,{className:`activity-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Loop`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`State`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Every`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last run`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last OK`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Took`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`CPU`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Runs`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Produced`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Next due`})]})}),(0,g.jsx)(`tbody`,{children:s.map(e=>(0,g.jsxs)(`tr`,{className:b.has(e.state)?`activity-loop-row activity-loop-unhealthy`:`activity-loop-row`,children:[(0,g.jsx)(`td`,{className:`activity-td`,children:e.name}),(0,g.jsx)(`td`,{className:`activity-td`,title:y[e.state],children:(0,g.jsxs)(`span`,{className:`activity-state`,children:[(0,g.jsx)(`span`,{className:e.state===`ok`?`activity-state-dot is-healthy`:b.has(e.state)?`activity-state-dot is-unhealthy`:`activity-state-dot`,"aria-hidden":`true`}),v(e.state)]})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:C(e.intervalMs)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastStartMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastSuccessMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:e.lastDurationMs===null?_:`${e.lastDurationMs} ms`}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,title:e.cpuAttributable?e.detached?`Includes the processor time of the separate process this loop starts.`:void 0:`This loop waits on other work while it runs, so the processor time it uses cannot be separated from the rest of the server.`,children:S(e.cpuPct)}),(0,g.jsxs)(`td`,{className:`activity-td activity-num`,children:[e.successCount,`/`,e.runCount]}),(0,g.jsx)(`td`,{className:`activity-td activity-loop-note`,children:(0,g.jsx)(`span`,{className:`activity-loop-note-text`,title:e.lastError??e.lastNote??void 0,children:e.lastError??e.lastNote??_})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:T(e.nextDueMs,t)})]},e.name))})]})}),(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`Runs`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Finished runs out of attempted runs since the server started. 0 out of a large number means it has tried many times and never once finished.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`CPU`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Share of one processor core this loop is using, measured between the last two refreshes. It includes any separate process the loop starts, and can pass 100% because those run alongside each other. A dash means it could not be measured: the loop waits on other work while it runs, so its share cannot be separated from the rest of the server.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:_}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Not measured. It does not mean zero.`})]})]})]})}var D=`maxy-admin-session-key`;function O(e){switch(e.costUnavailable){case`metering-failed`:return`Cost could not be calculated: ${e.meteringError??`the transcript could not be read`}`;case`model-not-priced`:return`No published price for this model, so cost cannot be estimated.`;case`no-transcript`:return`This session has no transcript yet, so there is nothing to cost.`;default:return}}var k=[{key:`lastMessageAt`,label:`Last activity`,dir:-1},{key:`activeMsInRange`,label:`Active time`,dir:-1},{key:`costGbp`,label:`Cost`,dir:-1},{key:`accountId`,label:`Account name`,dir:1}],A=[{key:`title`,label:`Session`,help:`The conversation name, or its short id when it has none yet.`},{key:`model`,label:`Model`,help:`The model that answered the most recent turn.`},{key:`status`,label:`Status`,help:`What the process is doing right now.`},{key:`activeMsInRange`,label:`Active`,help:`Time this session spent thinking, writing and running tools inside the selected range. This is worked time, not elapsed time.`},{key:`ageMs`,label:`Age`,help:`How long ago this conversation started. Wall-clock, so it counts every hour nobody was working.`},{key:`lastMessageAt`,label:`Last activity`,help:`The clock time of the most recent message, in your timezone. A date appears once it is not today.`},{key:`turnCount`,label:`Turns`,help:`Messages exchanged. A trailing + means the count is a minimum — the conversation is too long to count exactly.`},{key:`rssKb`,label:`RAM`,help:`Memory held by this session and all its helper processes together.`},{key:`cpuPct`,label:`CPU (avg)`,help:`AVERAGE share of one processor core over the last census interval, up to 60 seconds. It is not a reading of this instant, so a session that answered a turn a minute ago still shows a high figure while sitting quiet now. Can exceed 100% because a session runs many processes at once.`},{key:`tokensInRange`,label:`Tokens`,help:`Total tokens billed inside the selected range, added up across every day in it. A cumulative total, not the size of the conversation the model currently reads back.`},{key:`costGbp`,label:`Cost`,help:`Estimated spend inside the selected range, at published prices for this model.`}],j=[`activeMsInRange`,`lastMessageAt`,`cpuPct`,`tokensInRange`],M={label:`Account`,help:`The business this session belongs to. "untagged" means the session records no account.`};function N(e,t){let n=t?.[e];return n&&n.trim()!==``?n:e.slice(0,8)}var P=`—`;function F(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function I(e){return e===null||!Number.isFinite(e)?P:`${(e/1024/1024).toFixed(1)} GB`}function L(e,t){if(!e)return P;let n=Date.parse(e);if(!Number.isFinite(n))return P;let r=new Date(n),i=new Date(t),a=`${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`;return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()?a:`${r.getDate()} ${r.toLocaleString(`en-GB`,{month:`short`})} ${a}`}function R(e){return e===null||!Number.isFinite(e)?P:`${e.toFixed(1)}%`}function z(e){return e===null||!Number.isFinite(e)?P:e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function B(e){return e===null||!Number.isFinite(e)?P:`£${e.toFixed(2)}`}function V(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/6e4);return`${Math.floor(t/60)}h ${t%60}m`}function H(e,t,n,r){let i=e[n],a=t[n];if(i===null&&a===null)return 0;if(i===null)return 1;if(a===null)return-1;if(n===`lastMessageAt`){let e=Date.parse(String(i)),t=Date.parse(String(a));return!Number.isFinite(e)&&!Number.isFinite(t)?0:Number.isFinite(e)?Number.isFinite(t)?(e-t)*r:-1:1}return typeof i==`number`&&typeof a==`number`?(i-a)*r:String(i).localeCompare(String(a))*r}function U(e){return e.toISOString().slice(0,10)}function W(e){let t=e.getUTCFullYear(),n=e.getUTCMonth();return{from:U(new Date(Date.UTC(t,n,1))),to:U(new Date(Date.UTC(t,n+1,0)))}}function G(e,t){let n=new Date(`${e}T00:00:00.000Z`);return W(new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1)))}function ee(e,t){return{from:U(new Date(t-(e-1)*864e5)),to:U(new Date(t))}}function K(e){return new Date(`${e}T00:00:00.000Z`).toLocaleString(`en-GB`,{month:`long`,year:`numeric`,timeZone:`UTC`})}function q(e){if(e===null)return!1;let t=W(new Date(`${e.from}T00:00:00.000Z`));return t.from===e.from&&t.to===e.to}function J(e,t,n){switch(e){case`title`:return t.title??t.sessionId.slice(0,8);case`model`:return t.model??P;case`status`:return t.status??P;case`activeMsInRange`:return V(t.activeMsInRange);case`ageMs`:return F(t.ageMs);case`lastMessageAt`:return L(t.lastMessageAt,n);case`turnCount`:return t.turnCount===null?P:`${t.turnCount}${t.turnCountCapped?`+`:``}`;case`rssKb`:return I(t.rssKb);case`cpuPct`:return R(t.cpuPct);case`tokensInRange`:return z(t.tokensInRange);case`costGbp`:return B(t.costGbp);default:return P}}function Y({adminFetch:e,cacheKey:t}){let[n,r]=(0,h.useState)(null),[i,s]=(0,h.useState)(null),[l,f]=(0,h.useState)(!1),[m,_]=(0,h.useState)(`lastMessageAt`),[v,y]=(0,h.useState)(-1),[b,x]=(0,h.useState)(()=>W(new Date)),[S,C]=(0,h.useState)(!0),[w,T]=(0,h.useState)(!0),[D,I]=(0,h.useState)(!1),L=(0,h.useCallback)(async(e,n)=>{t&&await o(t,e)&&window.location.assign(`/chat?session=${encodeURIComponent(n)}`)},[t]),R=(0,h.useRef)(!1),z=(0,h.useRef)(void 0),B=(0,h.useCallback)(async t=>{if(R.current){z.current=t;return}R.current=!0;try{let n=await e(`/api/admin/activity${t?`?from=${t.from}&to=${t.to}`:``}`);if(n.status===403){s(`This view is available to the house account only.`),f(!0);return}if(!n.ok){s(`The session manager did not answer (status ${n.status}).`),f(!0);return}r(await n.json()),s(null)}catch(e){s(e instanceof Error?e.message:String(e))}finally{f(!0),R.current=!1;let e=z.current;z.current=void 0,e!==void 0&&B(e)}},[e]);(0,h.useEffect)(()=>{B(b);let e=setInterval(()=>void B(b),15e3);return()=>clearInterval(e)},[B,b]);let V=(0,h.useMemo)(()=>n?[...n.rows].sort((e,t)=>H(e,t,m,v)):[],[n,m,v]),U=(0,h.useMemo)(()=>V.filter(e=>e.status===`busy`?S:e.status===`idle`?w:!0),[V,S,w]),Y=V.length-U.length;if(!l)return(0,g.jsx)(a,{surface:`gate`});if(i)return(0,g.jsx)(`div`,{className:`activity-empty`,children:i});if(!n)return(0,g.jsx)(`div`,{className:`activity-empty`,children:`No response.`});let{accounts:X,census:Z,censusAgeMs:Q}=n,te=Date.now(),ne=X.onDisk!==null&&X.onDisk>X.valid,$=n.range===void 0?b:n.range;return(0,g.jsxs)(`div`,{className:`ui-page ui-page--full activity-body`,children:[(0,g.jsxs)(`div`,{className:`activity-head`,children:[(0,g.jsxs)(`span`,{className:`activity-title`,children:[(0,g.jsx)(c,{size:16}),` Live sessions`]}),(0,g.jsxs)(`span`,{className:`activity-meta`,children:[Y>0?`${U.length} of ${V.length} live · ${Y} hidden`:`${V.length} live`,` · `,X.valid,` accounts`,X.untaggedCount>0?` · ${X.untaggedCount} untagged`:``]})]}),(0,g.jsxs)(`div`,{className:`activity-controls`,children:[(0,g.jsxs)(`div`,{className:`activity-control activity-range`,children:[(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-label":`Previous month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,-1)),children:`‹`}),(0,g.jsx)(`span`,{className:`activity-range-label`,children:b===null?`All time`:q(b)?K(b.from):`${b.from} → ${b.to}`}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-label":`Next month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,1)),children:`›`})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-presets`,children:[(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&q(b)&&b.from===W(new Date).from,onClick:()=>x(W(new Date)),children:`This month`}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&!q(b),onClick:()=>x(ee(7,Date.now())),children:`Last 7 days`}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-pressed":b===null,onClick:()=>x(null),children:`All time`})]}),(0,g.jsxs)(`div`,{className:`activity-control`,children:[(0,g.jsx)(`label`,{className:`activity-control-label`,htmlFor:`activity-sort`,children:`Sort by`}),(0,g.jsx)(`span`,{className:`activity-select-wrap`,children:(0,g.jsx)(`select`,{id:`activity-sort`,className:`activity-select`,value:m,onChange:e=>{let t=k.find(t=>t.key===e.target.value);t&&(_(t.key),y(t.dir))},children:k.map(e=>(0,g.jsx)(`option`,{value:e.key,children:e.label},e.key))})})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-visibility`,children:[(0,g.jsx)(d,{checked:S,onChange:C,label:`Busy`}),(0,g.jsx)(d,{checked:w,onChange:T,label:`Idle`})]})]}),(0,g.jsxs)(`div`,{className:`activity-range-note`,children:[$===null?`Active time, tokens and cost cover each conversation’s whole history.`:`Active time, tokens and cost cover ${$.from} to ${$.to} (UTC), inclusive.`,n.fullRangeFallback&&(0,g.jsxs)(`strong`,{className:`activity-range-rejected`,children:[` `,`The range was not accepted, so these are all-time figures.`]})]}),(0,g.jsx)(`div`,{className:`activity-census`,children:Z===null?`No census collected yet, so memory and CPU are unavailable.`:`Memory and CPU measured ${F(Q)} ago, averaged over the minute before that · ${Z.cpuNull} of ${Z.live} without a CPU reading`}),ne&&(0,g.jsxs)(`div`,{className:`activity-warning`,children:[(0,g.jsx)(p,{size:14}),` `,X.onDisk,` account folders on disk but only`,` `,X.valid,` are readable. Sessions belonging to the rest cannot be attributed.`]}),V.length===0?(0,g.jsx)(`div`,{className:`activity-empty`,children:`No sessions are running.`}):U.length===0?(0,g.jsxs)(`div`,{className:`activity-empty`,children:[`All `,V.length,` running sessions are hidden by the Busy and Idle filters.`]}):(0,g.jsx)(`div`,{className:`activity-grid`,children:U.map(e=>{let n=e.accountId!==null&&!!t,r=n?()=>void L(e.accountId,e.sessionId):void 0;return(0,g.jsxs)(`article`,{className:`activity-card${n?` activity-card-clickable`:``}`,"data-testid":`activity-card`,"data-session-id":e.sessionId,role:n?`button`:void 0,tabIndex:n?0:void 0,onClick:r,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())}:void 0,children:[(0,g.jsx)(`h3`,{className:`activity-card-heading`,title:e.accountId??void 0,children:e.accountId===null?(0,g.jsx)(`span`,{className:`activity-untagged`,title:`This session records no account, so it cannot be attributed to a business.`,children:`untagged`}):N(e.accountId,X.names)}),(0,g.jsx)(`dl`,{className:`activity-card-rows`,children:A.map(t=>(0,g.jsxs)(`div`,{className:`activity-card-row`,children:[(0,g.jsx)(`dt`,{className:`activity-card-label`,"data-testid":`activity-card-label`,title:t.help,children:t.label}),(0,g.jsx)(`dd`,{className:`activity-card-value`,title:t.key===`costGbp`?O(e):void 0,children:J(t.key,e,te)})]},t.key))})]},e.sessionId)})}),V.length>0&&(0,g.jsxs)(`div`,{className:`activity-glossary`,children:[(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[D&&(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:M.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:M.help})]},`heading`),(D?A:A.filter(e=>j.includes(e.key))).map(e=>(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:e.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:e.help})]},e.key)),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:P}),(0,g.jsxs)(`dd`,{className:`activity-legend-def`,children:[`Not measured. It does not mean zero — a measured zero is written as a figure, so `,(0,g.jsx)(`em`,{children:`0h 0m`}),` and `,(0,g.jsx)(`em`,{children:`£0.00`}),` are real readings. Hover a dashed value for the reason where one exists.`]})]})]}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,className:`activity-glossary-toggle`,onClick:()=>I(e=>!e),children:D?`Show fewer`:`Explain every figure`})]}),(0,g.jsx)(E,{loops:n?.loops})]})}function X({cacheKey:e}){let{adminFetch:t}=n({initialCacheKey:e,surface:`activity`});return(0,g.jsx)(Y,{adminFetch:t,cacheKey:e})}function Z(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)(!1),[i,o]=(0,h.useState)(void 0),[c,u]=(0,h.useState)(null),[d,p]=(0,h.useState)(null),[m,_]=(0,h.useState)(null),[v,y]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(D)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&u(e.sessionId??null),p(e.role??null),_(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let b=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},[]),[x,S]=(0,h.useState)(!1),C=(0,h.useCallback)(async()=>{S(!0);try{let e=await l();if(e){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`}return e}finally{S(!1)}},[]);return n?e?(0,g.jsx)(s,{cacheKey:e,surface:`activity`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=activity`);try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},children:(0,g.jsx)(f,{cacheKey:e,businessName:i,sessionId:c,onLogout:b,onDisconnect:C,disconnecting:x,userName:m,userAvatar:v,role:d,children:(0,g.jsx)(X,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`activity-page`,children:(0,g.jsxs)(`div`,{className:`activity-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`activity-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(a,{surface:`gate`})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(Z,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,J as n,S as r,W as i,X as a,c as o,d as s,f as c,j as l,o as u,v as d,y as ee}from"./useSubAccountSwitcher-UMg53kKF.js";import{n as f,t as p}from"./AdminLoginScreens-CYFf2awh.js";import{f as te,s as m,x as h}from"./useVoiceRecorder-tzfqfXni.js";import{C as ne,a as g,g as re,t as _,w as ie,x as v}from"./AdminShell-7l3ubYFZ.js";import{t as y}from"./chevron-left-DHzJobWp.js";import{t as ae}from"./chevron-right-yg4DMfLT.js";import{n as b,r as x}from"./page-BRr295G2.js";import{t as oe}from"./file-text-CbQoZfJD.js";import"./graph-labels-D695CsC9.js";import{n as se}from"./file-download-DbNIjWiK.js";var S=n(),C=e(a(),1),w=i();function T({onOpen:e}){return(0,w.jsx)(`footer`,{className:`admin-footer`,children:(0,w.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,w.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,w.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function E({sessionId:e,projectDir:t,sessionKey:n,contactName:r,onBack:i}){return(0,w.jsxs)(`div`,{className:`wa-web`,children:[(0,w.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,w.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,w.jsx)(y,{size:20})}),(0,w.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,w.jsx)(h,{size:20})}),(0,w.jsx)(`div`,{className:`wa-web-titles`,children:(0,w.jsx)(`span`,{className:`wa-web-name`,children:r})})]}),(0,w.jsx)(`div`,{className:`wa-web-body`,children:(0,w.jsx)(m,{sessionId:e,projectDir:t,sessionKey:n,forceDeliveredOnly:!0})})]})}var D=6e4,O=60*D,k=24*O,A=D,j=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],M=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function N(e){return e<10?`0${e}`:String(e)}function P(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function F(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t))return`—`;let n=t-e;if(n<-A)return`—`;let r=n<0?0:n;if(r<D)return`just now`;if(r<O)return`${Math.floor(r/D)}m`;if(r<k)return`${Math.floor(r/O)}h`;let i=new Date(t),a=new Date(e),o=Math.round((P(i)-P(a))/k);if(o===1)return`yesterday`;if(o>=2&&o<=6)return M[a.getDay()];let s=N(a.getDate()),c=j[a.getMonth()];return a.getFullYear()===i.getFullYear()?`${s} ${c}`:`${s} ${c} ${a.getFullYear()}`}function I({variant:e=`row`,count:t=1}){return(0,w.jsx)(w.Fragment,{children:Array.from({length:t},(t,n)=>(0,w.jsx)(`span`,{className:`dashboard-skeleton dashboard-skeleton--${e}`,"data-testid":`dashboard-skeleton`,"aria-hidden":`true`},n))})}var ce=6e4;function le(e){return e<12?`morning`:e<18?`afternoon`:`evening`}function L(e){return e&&e.trim().split(/\s+/)[0]||`there`}function ue(e){if(!e)return`everything is running normally.`;let t=e.cpuPct,n=e.memUsedPct;return t!==null&&t>=.98||n!==null&&n>=.98?`system load is critical.`:t!==null&&t>=.9||n!==null&&n>=.9?`system load is high.`:`everything is running normally.`}function R(e){return e==null?`—`:`${Math.round(e*100)}%`}function de(e){return e.isGroup===!0?e.chatName??e.title:e.operatorName??e.chatName??e.whatsappName??e.senderId??e.title}function z(e,t){if(!e)return!1;let n=Date.parse(e);if(!Number.isFinite(n))return!1;let r=new Date(n),i=new Date(t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()}function fe(e){return e?e.replace(/^claude-/,``):null}var B=new Set([`sessions`,`conversations`,`tasks`,`artefacts`,`skills`,`stats`]),V=!1;function pe(e,t,n,r){let i=e=>t.get(e)??null,a=r?r.getEntriesByType(`navigation`)[0]:void 0,o=r?r.getEntriesByType(`resource`).filter(e=>new URL(e.name,`http://x`).pathname.startsWith(`/assets/`)):[],s=e=>e===void 0||!Number.isFinite(e)?null:Math.round(e),c=e=>e?s(e):null;return{batchMs:e,sessionsMs:i(`sessions`),conversationsMs:i(`conversations`),tasksMs:i(`tasks`),artefactsMs:i(`artefacts`),skillsMs:i(`skills`),statsMs:i(`stats`),failed:[...B].filter(e=>n.has(e)).join(`,`)||`none`,ttfbMs:s(a?.responseStart),domContentLoadedMs:c(a?.domContentLoadedEventEnd),loadMs:c(a?.loadEventEnd),assetCount:o.length,assetBytes:o.reduce((e,t)=>e+(t.transferSize||0),0),assetMs:o.length?s(Math.max(...o.map(e=>e.responseEnd))):null}}function H({cacheKey:e,userName:n,onSelectWhatsappConversation:i}){let a=ee(e),[d,f]=(0,C.useState)(null),[p,m]=(0,C.useState)(null),[h,g]=(0,C.useState)(null),_=(0,C.useRef)(!1),[y,b]=(0,C.useState)(null),[x,S]=(0,C.useState)(null),[T,E]=(0,C.useState)(null),[D,O]=(0,C.useState)(null),[k,A]=(0,C.useState)(null),[j,M]=(0,C.useState)(null),[N,P]=(0,C.useState)(new Set),[B,H]=(0,C.useState)(()=>new Set),U=(0,C.useCallback)(e=>{H(t=>t.has(e)?t:new Set(t).add(e))},[]),W=Date.now(),G=(0,C.useRef)(!1),K=(0,C.useRef)(new Map),q=(0,C.useRef)(new Set),J=(0,C.useRef)(null);(0,C.useEffect)(()=>{if(!e)return;let n=!1;async function r(e,t,r,i){let o=Date.now(),s=typeof t==`string`?t:`unresolved`;try{typeof t!=`string`&&(s=await t());let e=await a(s);if(!e.ok)throw Error(`status ${e.status}`);let o=await e.json();n||i(r(o))}catch(t){q.current.add(e),console.error(`[admin-ui] dashboard-fetch-failed slice=${e} url=${s} ms=${Date.now()-o} reason=${t instanceof Error?t.message:String(t)}`)}finally{K.current.set(e,Date.now()-o),U(e)}}async function i(){if(!J.current){let e=await a(`/api/admin/accounts`);if(!e.ok)throw Error(`accounts status ${e.status}`);let t=await e.json(),n=t.accounts??[],r=t.activeAccountId??null,i=n.find(e=>e.accountId===r);if(!i)throw Error(`accounts: active ${r??`none`} absent from list of ${n.length}`);let o=i.isHouse||n.length===1;J.current={accountId:i.accountId,isHouse:o}}let{accountId:e,isHouse:t}=J.current;return t?`/api/operator-conversations/conversations-all`:`/api/operator-conversations/conversations`}let o={"sidebar-sessions":()=>r(`sessions`,`/api/admin/sidebar-sessions`,e=>e.sessions??[],f),"conversations-all":()=>r(`conversations`,i,e=>e.conversations??[],m),"tasks-list":()=>r(`tasks`,`/api/admin/tasks-list`,e=>e,S),"sidebar-artefacts":()=>r(`artefacts`,`/api/admin/sidebar-artefacts`,e=>e.artefacts??[],E),skills:()=>r(`skills`,`/api/admin/skills`,e=>e.skills??[],O)};async function s(){if(G.current)return;G.current=!0;let e=Date.now();try{await Promise.all([...Object.values(o).map(e=>e()),r(`stats`,`/api/admin/system-stats`,e=>e,b),r(`bookingLink`,`/api/admin/calendar/booking-link`,e=>e.bookingDomain??null,A),r(`portalLink`,`/api/admin/data-portal/portal-link`,e=>e.portalDomain??null,M)])}finally{G.current=!1;let t=Date.now()-e;if(!V){V=!0;try{let e=pe(t,K.current,q.current,typeof performance>`u`?null:performance);fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`dashboard-load`,...e}),keepalive:!0}).catch(()=>{})}catch{}}}}s();let c=null;try{c=new EventSource(t(`/api/admin/events`,e)),c.onmessage=e=>{if(document.visibilityState===`visible`)try{let{resource:t}=JSON.parse(e.data),n=t?o[t]:void 0;n&&n()}catch{}},c.onerror=()=>{console.error(`[admin-ui] dashboard-events stream error`)}}catch(e){console.error(`[admin-ui] dashboard-events unavailable reason=${e instanceof Error?e.message:String(e)}`)}let l=setInterval(()=>{document.visibilityState===`visible`&&s()},ce),u=()=>{document.visibilityState===`visible`&&s()};return document.addEventListener(`visibilitychange`,u),()=>{n=!0,G.current=!1,clearInterval(l),c?.close(),document.removeEventListener(`visibilitychange`,u)}},[e,a]);let Y=(0,C.useMemo)(()=>(d??[]).filter(e=>!e.isSubagent),[d]),X=(0,C.useMemo)(()=>Y.filter(e=>e.live),[Y]),me=(0,C.useMemo)(()=>(p??[]).filter(e=>z(e.lastMessageAt,W)).length,[p,W]),he=x?.open.length??0,Z=(0,C.useMemo)(()=>{let e=new Map;for(let t of p??[]){let n=e.get(t.channel)??[];n.push(t),e.set(t.channel,n)}return[...e.entries()].map(([e,t])=>{let n=t.reduce((e,t)=>t.lastMessageAt&&(!e||Date.parse(t.lastMessageAt)>Date.parse(e.lastMessageAt??``))?t:e,null);return{channel:e,count:t.length,preview:n?de(n):``,rows:t}})},[p]);(0,C.useEffect)(()=>{_.current||Z.length!==0&&(_.current=!0,g(Z[0].channel))},[Z]);let Q=(0,C.useRef)(!1);(0,C.useEffect)(()=>{Q.current||!B.has(`bookingLink`)||!B.has(`portalLink`)||(Q.current=!0)},[B,k,j]);let ge=(0,C.useCallback)(async e=>{if(!N.has(e)){P(t=>new Set(t).add(e));try{let t=await a(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e})});if(!t.ok){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} status=${t.status}`);return}f(t=>(t??[]).map(t=>t.sessionId===e?{...t,live:!1}:t))}catch(t){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} reason=${t instanceof Error?t.message:String(t)}`)}finally{P(t=>{let n=new Set(t);return n.delete(e),n})}}},[a,N]),_e=(0,C.useCallback)(t=>{if(!e||!t.downloadPath){console.error(`[admin-ui] dashboard-artefact-download-blocked id=${t.id} reason=${e?`not-downloadable`:`no-cache-key`}`);return}se(e,t.downloadPath,t.downloadRoot??`data`)},[e]),$=le(new Date(W).getHours());return(0,w.jsxs)(`div`,{className:`ui-page ui-page--full dashboard-home`,children:[(0,w.jsx)(`p`,{className:`dashboard-greeting`,children:B.has(`stats`)?`Good ${$}, ${L(n)} — ${ue(y)}`:`Good ${$}, ${L(n)}`}),(0,w.jsxs)(`div`,{className:`dashboard-stats`,children:[(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Live sessions`}),B.has(`sessions`)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:X.length}),(0,w.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`of `,Y.length,` total`]})]}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Messages today`}),B.has(`conversations`)?(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:me}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`a`,{className:`admin-stat-card dashboard-stat-card dashboard-stat-card--link`,href:`/tasks`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Open tasks`}),B.has(`tasks`)?(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:he}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Host CPU`}),B.has(`stats`)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:R(y?.cpuPct??null)}),(0,w.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`RAM `,R(y?.memUsedPct??null)]})]}):(0,w.jsx)(I,{variant:`value`})]})]}),(0,w.jsxs)(`div`,{className:`dashboard-columns`,children:[(0,w.jsxs)(`div`,{className:`dashboard-col`,children:[(k||j)&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Public pages`}),(0,w.jsxs)(`div`,{className:`admin-card dashboard-public-pages`,children:[k&&(0,w.jsxs)(`a`,{className:`admin-row dashboard-public-row`,href:`https://${k}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,w.jsx)(`span`,{className:`dashboard-public-icon`,children:(0,w.jsx)(v,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-public-name`,children:`Booking page`})]}),j&&(0,w.jsxs)(`a`,{className:`admin-row dashboard-public-row`,href:`https://${j}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,w.jsx)(`span`,{className:`dashboard-public-icon`,children:(0,w.jsx)(v,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-public-name`,children:`File drop`})]})]})]}),(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Live now`}),B.has(`sessions`)?X.length===0?(0,w.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No live sessions right now.`}):X.map(e=>{let t=[e.sessionId.slice(0,8),fe(e.model),F(Date.parse(e.startedAt),W)].filter(Boolean).join(` · `);return(0,w.jsxs)(`div`,{className:`admin-card dashboard-live-card`,children:[(0,w.jsx)(`span`,{className:`admin-status-dot is-live`}),(0,w.jsxs)(`div`,{className:`dashboard-live-main`,children:[(0,w.jsx)(`span`,{className:`dashboard-live-name`,children:e.title}),(0,w.jsx)(`span`,{className:`dashboard-live-meta`,children:t})]}),(0,w.jsx)(`a`,{className:`admin-btn-cta dashboard-open-btn`,href:`/chat?session=${encodeURIComponent(e.sessionId)}`,children:`Open`}),(0,w.jsx)(`button`,{type:`button`,className:`dashboard-stop-btn`,"aria-label":`Stop ${e.title}`,disabled:N.has(e.sessionId),onClick:()=>void ge(e.sessionId),children:(0,w.jsx)(r,{size:12})})]},e.sessionId)}):(0,w.jsx)(I,{variant:`card`,count:2}),(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Recent artefacts`}),(0,w.jsx)(`div`,{className:`admin-card dashboard-artefacts`,children:B.has(`artefacts`)?(T??[]).length===0?(0,w.jsx)(`div`,{className:`dashboard-empty`,children:`No recent artefacts.`}):(T??[]).slice(0,6).map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-artefact-row`,onClick:()=>_e(e),children:[(0,w.jsx)(`span`,{className:`dashboard-artefact-icon`,children:e.kind===`agent-template`?(0,w.jsx)(ie,{size:16}):(0,w.jsx)(oe,{size:16})}),(0,w.jsx)(`div`,{className:`dashboard-artefact-body`,children:(0,w.jsx)(`span`,{className:`dashboard-artefact-name`,children:e.name})}),(0,w.jsx)(`span`,{className:`dashboard-artefact-time`,children:F(Date.parse(e.updatedAt),W)})]},e.id)):(0,w.jsx)(I,{count:3})}),(0,w.jsx)(`a`,{className:`admin-section-label dashboard-col-label dashboard-skills-label`,href:`/skills`,children:`Skills`}),(0,w.jsx)(`div`,{className:`admin-card dashboard-skills`,children:B.has(`skills`)?(D??[]).length===0?(0,w.jsx)(`div`,{className:`dashboard-empty`,children:`No skills yet.`}):(D??[]).map(e=>(0,w.jsxs)(`a`,{className:`admin-row dashboard-skill-row`,href:`/skills`,children:[(0,w.jsx)(`span`,{className:`dashboard-skill-icon`,children:(0,w.jsx)(re,{size:16})}),(0,w.jsxs)(`div`,{className:`dashboard-skill-body`,children:[(0,w.jsx)(`span`,{className:`dashboard-skill-name`,children:e.skill}),(0,w.jsx)(`span`,{className:`dashboard-skill-plugin`,children:e.plugin})]})]},`${e.plugin}/${e.skill}`)):(0,w.jsx)(I,{count:2})})]}),(0,w.jsxs)(`div`,{className:`dashboard-col`,children:[(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Channels`}),B.has(`conversations`)?Z.length===0?(0,w.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No channel activity.`}):Z.map(t=>{let n=h===t.channel;return(0,w.jsxs)(`div`,{className:`admin-card dashboard-channel-card`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`dashboard-channel-head`,"aria-expanded":n,onClick:()=>g(e=>e===t.channel?null:t.channel),children:[(0,w.jsx)(`span`,{className:`dashboard-channel-glyph`,children:t.channel===`whatsapp`||t.channel===`telegram`?(0,w.jsx)(c,{channel:t.channel,size:16}):(0,w.jsx)(l,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-channel-name`,children:s[t.channel]??t.channel}),(0,w.jsx)(`span`,{className:`dashboard-channel-badge`,children:t.count}),(0,w.jsx)(`span`,{className:`dashboard-channel-chevron`,children:n?(0,w.jsx)(ne,{size:14}):(0,w.jsx)(ae,{size:14})})]}),n?(0,w.jsx)(`div`,{className:`dashboard-channel-convs`,children:t.rows.map(t=>(0,w.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-channel-conv-row`,onClick:()=>i(t),title:t.title,children:[(0,w.jsxs)(`span`,{className:`dashboard-channel-conv-line`,children:[(0,w.jsx)(te,{accountId:t.accountId??``,jid:t.remoteJid,sessionKey:e??``,className:`dashboard-channel-conv-avatar`,size:16}),(0,w.jsx)(`span`,{className:`dashboard-channel-conv-name`,children:u(t)}),t.isGroup===!0&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag is-group`,children:`Group`}),t.role===`public`&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag is-public`,children:`Public`}),(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag`,children:t.isHouse?`House`:`Client`}),!t.preview&&t.lastMessageAt&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-time`,children:F(Date.parse(t.lastMessageAt),W)})]}),t.preview?(0,w.jsxs)(`span`,{className:`dashboard-channel-conv-sub`,children:[(0,w.jsx)(`span`,{className:`dashboard-channel-conv-preview`,children:t.preview}),t.lastMessageAt&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-time`,children:F(Date.parse(t.lastMessageAt),W)})]}):null]},o(t)))}):t.preview&&(0,w.jsx)(`span`,{className:`dashboard-channel-preview`,children:t.preview})]},t.channel)}):(0,w.jsx)(I,{variant:`card`,count:2})]})]})]})}function U(){let e=f(),[t,n]=(0,C.useState)(!1);(0,C.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,C.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t)return;let r=Date.now();if(!e.cacheKey){console.error(`[admin-ui] claude-info-fetch-skipped reason=no-session-key`);return}try{let t=await fetch(`/api/admin/claude-info?session_key=${encodeURIComponent(e.cacheKey)}`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),i=(0,C.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,w.jsx)(d,{cacheKey:e.cacheKey,onSessionExpired:i,surface:`chat`,children:(0,w.jsx)(_,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,claudeConnected:e.claudeConnected,onConnectClaude:()=>e.setAppState(`connect-claude`),userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(T,{onOpen:r}),(0,w.jsx)(g,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,w.jsx)(w.Fragment,{children:t.dataOpen&&e.cacheKey?(0,w.jsx)(b,{cacheKey:e.cacheKey}):t.selectedWhatsapp&&e.cacheKey?t.selectedWhatsapp.source===`store`&&t.selectedWhatsapp.remoteJid&&t.selectedWhatsapp.accountId?(0,w.jsx)(x,{accountId:t.selectedWhatsapp.accountId,remoteJid:t.selectedWhatsapp.remoteJid,contactName:u(t.selectedWhatsapp),sessionKey:e.cacheKey,onBack:t.onClearWhatsapp},o(t.selectedWhatsapp)):(0,w.jsx)(E,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,contactName:u(t.selectedWhatsapp),onBack:t.onClearWhatsapp},o(t.selectedWhatsapp)):(0,w.jsx)(H,{cacheKey:e.cacheKey,userName:e.userName,onSelectWhatsappConversation:t.onSelectWhatsappConversation})})})}):(0,w.jsx)(p,{auth:e})}(0,S.createRoot)(document.getElementById(`root`)).render((0,w.jsx)(U,{}));
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,K as n,M as r,S as i,Y as a,Z as o,c as s,d as c,f as l,o as u,v as d,y as ee}from"./useSubAccountSwitcher-C7TtIbR3.js";import{n as f,t as p}from"./AdminLoginScreens-BpHnjHp_.js";import{f as te,s as m,x as h}from"./useVoiceRecorder-DgyAGgmF.js";import{S as g,T as ne,a as _,g as re,t as v,w as ie}from"./AdminShell-D24evn4t.js";import{t as y}from"./chevron-left-NGLHgPjF.js";import{t as ae}from"./chevron-right-B4B7OkG8.js";import{n as b,r as x}from"./page-D0ShNyGE.js";import{t as oe}from"./file-text-BA9p7TLU.js";import"./graph-labels-CiK412vE.js";import{n as se}from"./file-download-DbNIjWiK.js";var S=a(),C=e(o(),1),w=t();function T({onOpen:e}){return(0,w.jsx)(`footer`,{className:`admin-footer`,children:(0,w.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,w.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,w.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function E({sessionId:e,projectDir:t,sessionKey:n,contactName:r,onBack:i}){return(0,w.jsxs)(`div`,{className:`wa-web`,children:[(0,w.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,w.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,w.jsx)(y,{size:20})}),(0,w.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,w.jsx)(h,{size:20})}),(0,w.jsx)(`div`,{className:`wa-web-titles`,children:(0,w.jsx)(`span`,{className:`wa-web-name`,children:r})})]}),(0,w.jsx)(`div`,{className:`wa-web-body`,children:(0,w.jsx)(m,{sessionId:e,projectDir:t,sessionKey:n,forceDeliveredOnly:!0})})]})}var D=6e4,O=60*D,k=24*O,A=D,j=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],M=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function N(e){return e<10?`0${e}`:String(e)}function P(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function F(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t))return`—`;let n=t-e;if(n<-A)return`—`;let r=n<0?0:n;if(r<D)return`just now`;if(r<O)return`${Math.floor(r/D)}m`;if(r<k)return`${Math.floor(r/O)}h`;let i=new Date(t),a=new Date(e),o=Math.round((P(i)-P(a))/k);if(o===1)return`yesterday`;if(o>=2&&o<=6)return M[a.getDay()];let s=N(a.getDate()),c=j[a.getMonth()];return a.getFullYear()===i.getFullYear()?`${s} ${c}`:`${s} ${c} ${a.getFullYear()}`}function I({variant:e=`row`,count:t=1}){return(0,w.jsx)(w.Fragment,{children:Array.from({length:t},(t,n)=>(0,w.jsx)(`span`,{className:`dashboard-skeleton dashboard-skeleton--${e}`,"data-testid":`dashboard-skeleton`,"aria-hidden":`true`},n))})}var L=6e4;function ce(e){return e<12?`morning`:e<18?`afternoon`:`evening`}function R(e){return e&&e.trim().split(/\s+/)[0]||`there`}function le(e){if(!e)return`everything is running normally.`;let t=e.cpuPct,n=e.memUsedPct;return t!==null&&t>=.98||n!==null&&n>=.98?`system load is critical.`:t!==null&&t>=.9||n!==null&&n>=.9?`system load is high.`:`everything is running normally.`}function z(e){return e==null?`—`:`${Math.round(e*100)}%`}function ue(e){return e.isGroup===!0?e.chatName??e.title:e.operatorName??e.chatName??e.whatsappName??e.senderId??e.title}function de(e,t){if(!e)return!1;let n=Date.parse(e);if(!Number.isFinite(n))return!1;let r=new Date(n),i=new Date(t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()}function fe(e){return e?e.replace(/^claude-/,``):null}var B=new Set([`sessions`,`conversations`,`tasks`,`artefacts`,`skills`,`stats`]),V=!1;function pe(e,t,n,r){let i=e=>t.get(e)??null,a=r?r.getEntriesByType(`navigation`)[0]:void 0,o=r?r.getEntriesByType(`resource`).filter(e=>new URL(e.name,`http://x`).pathname.startsWith(`/assets/`)):[],s=e=>e===void 0||!Number.isFinite(e)?null:Math.round(e),c=e=>e?s(e):null;return{batchMs:e,sessionsMs:i(`sessions`),conversationsMs:i(`conversations`),tasksMs:i(`tasks`),artefactsMs:i(`artefacts`),skillsMs:i(`skills`),statsMs:i(`stats`),failed:[...B].filter(e=>n.has(e)).join(`,`)||`none`,ttfbMs:s(a?.responseStart),domContentLoadedMs:c(a?.domContentLoadedEventEnd),loadMs:c(a?.loadEventEnd),assetCount:o.length,assetBytes:o.reduce((e,t)=>e+(t.transferSize||0),0),assetMs:o.length?s(Math.max(...o.map(e=>e.responseEnd))):null}}function H({cacheKey:e,userName:t,onSelectWhatsappConversation:a}){let o=ee(e),[d,f]=(0,C.useState)(null),[p,m]=(0,C.useState)(null),[h,_]=(0,C.useState)(null),v=(0,C.useRef)(!1),[y,b]=(0,C.useState)(null),[x,S]=(0,C.useState)(null),[T,E]=(0,C.useState)(null),[D,O]=(0,C.useState)(null),[k,A]=(0,C.useState)(null),[j,M]=(0,C.useState)(null),[N,P]=(0,C.useState)(new Set),[B,H]=(0,C.useState)(()=>new Set),U=(0,C.useCallback)(e=>{H(t=>t.has(e)?t:new Set(t).add(e))},[]),W=Date.now(),G=(0,C.useRef)(!1),K=(0,C.useRef)(new Map),q=(0,C.useRef)(new Set),J=(0,C.useRef)(null);(0,C.useEffect)(()=>{if(!e)return;let t=!1;async function r(e,n,r,i){let a=Date.now(),s=typeof n==`string`?n:`unresolved`;try{typeof n!=`string`&&(s=await n());let e=await o(s);if(!e.ok)throw Error(`status ${e.status}`);let a=await e.json();t||i(r(a))}catch(t){q.current.add(e),console.error(`[admin-ui] dashboard-fetch-failed slice=${e} url=${s} ms=${Date.now()-a} reason=${t instanceof Error?t.message:String(t)}`)}finally{K.current.set(e,Date.now()-a),U(e)}}async function i(){if(!J.current){let e=await o(`/api/admin/accounts`);if(!e.ok)throw Error(`accounts status ${e.status}`);let t=await e.json(),n=t.accounts??[],r=t.activeAccountId??null,i=n.find(e=>e.accountId===r);if(!i)throw Error(`accounts: active ${r??`none`} absent from list of ${n.length}`);let a=i.isHouse||n.length===1;J.current={accountId:i.accountId,isHouse:a}}let{accountId:e,isHouse:t}=J.current;return t?`/api/operator-conversations/conversations-all`:`/api/operator-conversations/conversations`}let a={"sidebar-sessions":()=>r(`sessions`,`/api/admin/sidebar-sessions`,e=>e.sessions??[],f),"conversations-all":()=>r(`conversations`,i,e=>e.conversations??[],m),"tasks-list":()=>r(`tasks`,`/api/admin/tasks-list`,e=>e,S),"sidebar-artefacts":()=>r(`artefacts`,`/api/admin/sidebar-artefacts`,e=>e.artefacts??[],E),skills:()=>r(`skills`,`/api/admin/skills`,e=>e.skills??[],O)};async function s(){if(G.current)return;G.current=!0;let e=Date.now();try{await Promise.all([...Object.values(a).map(e=>e()),r(`stats`,`/api/admin/system-stats`,e=>e,b),r(`bookingLink`,`/api/admin/calendar/booking-link`,e=>e.bookingDomain??null,A),r(`portalLink`,`/api/admin/data-portal/portal-link`,e=>e.portalDomain??null,M)])}finally{G.current=!1;let t=Date.now()-e;if(!V){V=!0;try{let e=pe(t,K.current,q.current,typeof performance>`u`?null:performance);fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`dashboard-load`,...e}),keepalive:!0}).catch(()=>{})}catch{}}}}s();let c=null;try{c=new EventSource(n(`/api/admin/events`,e)),c.onmessage=e=>{if(document.visibilityState===`visible`)try{let{resource:t}=JSON.parse(e.data),n=t?a[t]:void 0;n&&n()}catch{}},c.onerror=()=>{console.error(`[admin-ui] dashboard-events stream error`)}}catch(e){console.error(`[admin-ui] dashboard-events unavailable reason=${e instanceof Error?e.message:String(e)}`)}let l=setInterval(()=>{document.visibilityState===`visible`&&s()},L),u=()=>{document.visibilityState===`visible`&&s()};return document.addEventListener(`visibilitychange`,u),()=>{t=!0,G.current=!1,clearInterval(l),c?.close(),document.removeEventListener(`visibilitychange`,u)}},[e,o]);let Y=(0,C.useMemo)(()=>(d??[]).filter(e=>!e.isSubagent),[d]),X=(0,C.useMemo)(()=>Y.filter(e=>e.live),[Y]),me=(0,C.useMemo)(()=>(p??[]).filter(e=>de(e.lastMessageAt,W)).length,[p,W]),he=x?.open.length??0,Z=(0,C.useMemo)(()=>{let e=new Map;for(let t of p??[]){let n=e.get(t.channel)??[];n.push(t),e.set(t.channel,n)}return[...e.entries()].map(([e,t])=>{let n=t.reduce((e,t)=>t.lastMessageAt&&(!e||Date.parse(t.lastMessageAt)>Date.parse(e.lastMessageAt??``))?t:e,null);return{channel:e,count:t.length,preview:n?ue(n):``,rows:t}})},[p]);(0,C.useEffect)(()=>{v.current||Z.length!==0&&(v.current=!0,_(Z[0].channel))},[Z]);let Q=(0,C.useRef)(!1);(0,C.useEffect)(()=>{Q.current||!B.has(`bookingLink`)||!B.has(`portalLink`)||(Q.current=!0)},[B,k,j]);let ge=(0,C.useCallback)(async e=>{if(!N.has(e)){P(t=>new Set(t).add(e));try{let t=await o(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e})});if(!t.ok){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} status=${t.status}`);return}f(t=>(t??[]).map(t=>t.sessionId===e?{...t,live:!1}:t))}catch(t){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} reason=${t instanceof Error?t.message:String(t)}`)}finally{P(t=>{let n=new Set(t);return n.delete(e),n})}}},[o,N]),_e=(0,C.useCallback)(t=>{if(!e||!t.downloadPath){console.error(`[admin-ui] dashboard-artefact-download-blocked id=${t.id} reason=${e?`not-downloadable`:`no-cache-key`}`);return}se(e,t.downloadPath,t.downloadRoot??`data`)},[e]),$=ce(new Date(W).getHours());return(0,w.jsxs)(`div`,{className:`ui-page ui-page--full dashboard-home`,children:[(0,w.jsx)(`p`,{className:`dashboard-greeting`,children:B.has(`stats`)?`Good ${$}, ${R(t)} — ${le(y)}`:`Good ${$}, ${R(t)}`}),(0,w.jsxs)(`div`,{className:`dashboard-stats`,children:[(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Live sessions`}),B.has(`sessions`)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:X.length}),(0,w.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`of `,Y.length,` total`]})]}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Messages today`}),B.has(`conversations`)?(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:me}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`a`,{className:`admin-stat-card dashboard-stat-card dashboard-stat-card--link`,href:`/tasks`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Open tasks`}),B.has(`tasks`)?(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:he}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Host CPU`}),B.has(`stats`)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:z(y?.cpuPct??null)}),(0,w.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`RAM `,z(y?.memUsedPct??null)]})]}):(0,w.jsx)(I,{variant:`value`})]})]}),(0,w.jsxs)(`div`,{className:`dashboard-columns`,children:[(0,w.jsxs)(`div`,{className:`dashboard-col`,children:[(k||j)&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Public pages`}),(0,w.jsxs)(`div`,{className:`admin-card dashboard-public-pages`,children:[k&&(0,w.jsxs)(`a`,{className:`admin-row dashboard-public-row`,href:`https://${k}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,w.jsx)(`span`,{className:`dashboard-public-icon`,children:(0,w.jsx)(g,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-public-name`,children:`Booking page`})]}),j&&(0,w.jsxs)(`a`,{className:`admin-row dashboard-public-row`,href:`https://${j}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,w.jsx)(`span`,{className:`dashboard-public-icon`,children:(0,w.jsx)(g,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-public-name`,children:`File drop`})]})]})]}),(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Live now`}),B.has(`sessions`)?X.length===0?(0,w.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No live sessions right now.`}):X.map(e=>{let t=[e.sessionId.slice(0,8),fe(e.model),F(Date.parse(e.startedAt),W)].filter(Boolean).join(` · `);return(0,w.jsxs)(`div`,{className:`admin-card dashboard-live-card`,children:[(0,w.jsx)(`span`,{className:`admin-status-dot is-live`}),(0,w.jsxs)(`div`,{className:`dashboard-live-main`,children:[(0,w.jsx)(`span`,{className:`dashboard-live-name`,children:e.title}),(0,w.jsx)(`span`,{className:`dashboard-live-meta`,children:t})]}),(0,w.jsx)(`a`,{className:`admin-btn-cta dashboard-open-btn`,href:`/chat?session=${encodeURIComponent(e.sessionId)}`,children:`Open`}),(0,w.jsx)(`button`,{type:`button`,className:`dashboard-stop-btn`,"aria-label":`Stop ${e.title}`,disabled:N.has(e.sessionId),onClick:()=>void ge(e.sessionId),children:(0,w.jsx)(i,{size:12})})]},e.sessionId)}):(0,w.jsx)(I,{variant:`card`,count:2}),(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Recent artefacts`}),(0,w.jsx)(`div`,{className:`admin-card dashboard-artefacts`,children:B.has(`artefacts`)?(T??[]).length===0?(0,w.jsx)(`div`,{className:`dashboard-empty`,children:`No recent artefacts.`}):(T??[]).slice(0,6).map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-artefact-row`,onClick:()=>_e(e),children:[(0,w.jsx)(`span`,{className:`dashboard-artefact-icon`,children:e.kind===`agent-template`?(0,w.jsx)(ne,{size:16}):(0,w.jsx)(oe,{size:16})}),(0,w.jsx)(`div`,{className:`dashboard-artefact-body`,children:(0,w.jsx)(`span`,{className:`dashboard-artefact-name`,children:e.name})}),(0,w.jsx)(`span`,{className:`dashboard-artefact-time`,children:F(Date.parse(e.updatedAt),W)})]},e.id)):(0,w.jsx)(I,{count:3})}),(0,w.jsx)(`a`,{className:`admin-section-label dashboard-col-label dashboard-skills-label`,href:`/skills`,children:`Skills`}),(0,w.jsx)(`div`,{className:`admin-card dashboard-skills`,children:B.has(`skills`)?(D??[]).length===0?(0,w.jsx)(`div`,{className:`dashboard-empty`,children:`No skills yet.`}):(D??[]).map(e=>(0,w.jsxs)(`a`,{className:`admin-row dashboard-skill-row`,href:`/skills`,children:[(0,w.jsx)(`span`,{className:`dashboard-skill-icon`,children:(0,w.jsx)(re,{size:16})}),(0,w.jsxs)(`div`,{className:`dashboard-skill-body`,children:[(0,w.jsx)(`span`,{className:`dashboard-skill-name`,children:e.skill}),(0,w.jsx)(`span`,{className:`dashboard-skill-plugin`,children:e.plugin})]})]},`${e.plugin}/${e.skill}`)):(0,w.jsx)(I,{count:2})})]}),(0,w.jsxs)(`div`,{className:`dashboard-col`,children:[(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Channels`}),B.has(`conversations`)?Z.length===0?(0,w.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No channel activity.`}):Z.map(t=>{let n=h===t.channel;return(0,w.jsxs)(`div`,{className:`admin-card dashboard-channel-card`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`dashboard-channel-head`,"aria-expanded":n,onClick:()=>_(e=>e===t.channel?null:t.channel),children:[(0,w.jsx)(`span`,{className:`dashboard-channel-glyph`,children:t.channel===`whatsapp`||t.channel===`telegram`?(0,w.jsx)(l,{channel:t.channel,size:16}):(0,w.jsx)(r,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-channel-name`,children:c[t.channel]??t.channel}),(0,w.jsx)(`span`,{className:`dashboard-channel-badge`,children:t.count}),(0,w.jsx)(`span`,{className:`dashboard-channel-chevron`,children:n?(0,w.jsx)(ie,{size:14}):(0,w.jsx)(ae,{size:14})})]}),n?(0,w.jsx)(`div`,{className:`dashboard-channel-convs`,children:t.rows.map(t=>(0,w.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-channel-conv-row`,onClick:()=>a(t),title:t.title,children:[(0,w.jsxs)(`span`,{className:`dashboard-channel-conv-line`,children:[(0,w.jsx)(te,{accountId:t.accountId??``,jid:t.remoteJid,sessionKey:e??``,className:`dashboard-channel-conv-avatar`,size:16}),(0,w.jsx)(`span`,{className:`dashboard-channel-conv-name`,children:u(t)}),t.isGroup===!0&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag is-group`,children:`Group`}),t.role===`public`&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag is-public`,children:`Public`}),(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag`,children:t.isHouse?`House`:`Client`}),!t.preview&&t.lastMessageAt&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-time`,children:F(Date.parse(t.lastMessageAt),W)})]}),t.preview?(0,w.jsxs)(`span`,{className:`dashboard-channel-conv-sub`,children:[(0,w.jsx)(`span`,{className:`dashboard-channel-conv-preview`,children:t.preview}),t.lastMessageAt&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-time`,children:F(Date.parse(t.lastMessageAt),W)})]}):null]},s(t)))}):t.preview&&(0,w.jsx)(`span`,{className:`dashboard-channel-preview`,children:t.preview})]},t.channel)}):(0,w.jsx)(I,{variant:`card`,count:2})]})]})]})}function U(){let e=f(),[t,n]=(0,C.useState)(!1);(0,C.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,C.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t)return;let r=Date.now();if(!e.cacheKey){console.error(`[admin-ui] claude-info-fetch-skipped reason=no-session-key`);return}try{let t=await fetch(`/api/admin/claude-info?session_key=${encodeURIComponent(e.cacheKey)}`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),i=(0,C.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,w.jsx)(d,{cacheKey:e.cacheKey,onSessionExpired:i,surface:`chat`,children:(0,w.jsx)(v,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,claudeConnected:e.claudeConnected,onConnectClaude:()=>e.setAppState(`connect-claude`),userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(T,{onOpen:r}),(0,w.jsx)(_,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,w.jsx)(w.Fragment,{children:t.dataOpen&&e.cacheKey?(0,w.jsx)(b,{cacheKey:e.cacheKey}):t.selectedWhatsapp&&e.cacheKey?t.selectedWhatsapp.source===`store`&&t.selectedWhatsapp.remoteJid&&t.selectedWhatsapp.accountId?(0,w.jsx)(x,{accountId:t.selectedWhatsapp.accountId,remoteJid:t.selectedWhatsapp.remoteJid,contactName:u(t.selectedWhatsapp),sessionKey:e.cacheKey,onBack:t.onClearWhatsapp},s(t.selectedWhatsapp)):(0,w.jsx)(E,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,contactName:u(t.selectedWhatsapp),onBack:t.onClearWhatsapp},s(t.selectedWhatsapp)):(0,w.jsx)(H,{cacheKey:e.cacheKey,userName:e.userName,onSelectWhatsappConversation:t.onSelectWhatsappConversation})})})}):(0,w.jsx)(p,{auth:e})}(0,S.createRoot)(document.getElementById(`root`)).render((0,w.jsx)(U,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{J as t,W as n,X as r,_ as i,b as a,k as o,q as s,v as c,x as l,z as u}from"./useSubAccountSwitcher-UMg53kKF.js";import{k as d,t as f,w as p,x as m}from"./AdminShell-7l3ubYFZ.js";var h=u(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),g=u(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),_=t(),v=e(r(),1),y={green:`success`,amber:`warning`,red:`error`};function b(e){if(!e.startsWith(`mcp__`))return e;let t=e.slice(5),n=t.indexOf(`__`);if(n<0)return e;let r=t.slice(n+2);return r.length>0?r:e}function x(e){let t=` Nothing will be able to hand work to it until it is switched back on.`;if(e.length===0)return t;let n=e.length===1?`skill runs`:`skills run`;return` ${e.length} ${n} through it: ${e.join(`, `)}.${t}`}var S=n(),C={read:`read`,write_local:`writes`,exec:`runs`,external:`sends`},w={read:`tool-chip-read`,write_local:`tool-chip-write_local`,exec:`tool-chip-exec`,external:`tool-chip-external`,unresolved:`tool-chip-unresolved`};function T({label:e,body:t}){return(0,S.jsxs)(`div`,{className:`agent-doc`,children:[(0,S.jsx)(`span`,{className:`agent-doc-label`,children:e}),(0,S.jsx)(`pre`,{className:`skill-body`,children:t.trim()||`Empty.`})]})}function E({summary:e,publicBaseUrl:t,accountId:n,adminFetch:r,onClose:i,onDeleted:s,onToggled:c}){let u=e.kind===`specialist`,d=e.origin===`specialist`,f=e.origin===`shipped`&&e.disabled,_=d||f,[E]=(0,v.useState)(n),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!0),[j,M]=(0,v.useState)(null),[N,P]=(0,v.useState)(!1),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),[z,B]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let t=!1;A(!0),M(null);let n=e.origin===`shipped`?`?origin=shipped`:e.kind===`specialist`&&e.plugin?`?plugin=${encodeURIComponent(e.plugin)}`:``;return r(`/api/admin/agents/${encodeURIComponent(e.slug)}${n}`).then(async e=>{if(!t){if(!e.ok)throw Error(`HTTP ${e.status}`);O((await e.json()).agent)}}).catch(e=>{t||M(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{t||A(!1)}),()=>{t=!0}},[r,e.slug]),(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!F&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[F,i]);let V=(0,v.useCallback)(async()=>{I(!0),M(null);try{let t=await r(`/api/admin/agents/${encodeURIComponent(e.slug)}?accountId=${encodeURIComponent(E??``)}`,{method:`DELETE`,headers:{"content-type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}s(e)}catch(e){M(e instanceof Error?e.message:`Delete failed`),I(!1),P(!1)}},[r,e,E,s]),H=(0,v.useCallback)(async()=>{let t=e.disabled?`enable`:`disable`;B(!0),M(null);try{let n=await r(`/api/admin/agents/${encodeURIComponent(e.slug)}/${t}?accountId=${encodeURIComponent(E??``)}`,{method:`POST`,headers:{"content-type":`application/json`}});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}c(),i()}catch(e){M(e instanceof Error?e.message:`${t} failed`),B(!1),R(!1)}},[r,e,E,c,i]),U=u?null:D,W=u?D:null;return(0,S.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{F||i()},children:(0,S.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Agent detail`,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,S.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,S.jsx)(p,{size:13}),` `,u?`Specialist`:`Agent`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,autoFocus:!0,disabled:F,children:(0,S.jsx)(a,{size:16})})]}),(0,S.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,S.jsx)(`div`,{className:`cal-modal-title`,children:e.displayName}),(0,S.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[!u&&(0,S.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,S.jsxs)(`span`,{children:[`/`,e.slug]}),e.risk&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--solid-${y[e.risk]}`,children:e.risk===`green`?`Read only`:e.risk===`amber`?`Writes`:`Runs`}),e.disabled&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--tint-error`,children:`Disabled`})]}),e.risk&&e.riskReason&&(0,S.jsx)(`div`,{className:`cal-modal-row agent-risk-reason`,children:(0,S.jsx)(`span`,{children:e.riskReason})}),e.unresolved.length>0&&(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[`Forced to Runs: no declared risk class for `,e.unresolved.join(`, `),`.`]})}),k&&(0,S.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,S.jsx)(o,{size:14,className:`spin`}),(0,S.jsx)(`span`,{children:`Loading…`})]}),U&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[U.status,U.model?` · ${U.model}`:``]})}),(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`a`,{href:`${t}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`cal-link`,children:[(0,S.jsx)(m,{size:13}),` Open agent`]})}),U.present.identity&&(0,S.jsx)(T,{label:`Identity`,body:U.identity}),U.present.soul&&(0,S.jsx)(T,{label:`Soul`,body:U.soul}),U.present.knowledge&&(0,S.jsx)(T,{label:`Knowledge`,body:U.knowledge}),U.present.knowledgeSummary&&(0,S.jsx)(T,{label:`Knowledge summary`,body:U.knowledgeSummary}),U.knowledgeKeywords.length>0&&(0,S.jsxs)(`div`,{className:`skill-refs`,children:[(0,S.jsx)(`span`,{className:`skill-refs-label`,children:`Knowledge keywords`}),U.knowledgeKeywords.map(e=>(0,S.jsx)(`span`,{className:`skill-ref`,children:e},e))]})]}),W&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[e.plugin,W.model?` · ${W.model}`:``]})}),W.description&&(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsx)(`span`,{children:W.description})}),W.byTool.length>0&&(0,S.jsxs)(`div`,{className:`chip-refs`,children:[(0,S.jsxs)(`span`,{className:`skill-refs-label`,children:[`Tools (`,W.byTool.length,`)`]}),(0,S.jsx)(`div`,{className:`chip-row`,children:W.byTool.map(({tool:e,risk:t})=>(0,S.jsx)(`span`,{"data-testid":`tool-chip-${e}`,className:`tool-chip ${w[t??`unresolved`]}`,title:t?`${e} — ${C[t]}`:`${e} — no declared risk class`,children:b(e)},e))})]}),W.skills.length>0&&(0,S.jsxs)(`div`,{className:`chip-refs`,children:[(0,S.jsx)(`span`,{className:`skill-refs-label`,children:`Skills`}),(0,S.jsx)(`div`,{className:`chip-row`,children:W.skills.map(e=>(0,S.jsx)(`span`,{className:`tool-chip tool-chip-skill`,children:e},e))})]}),(0,S.jsx)(T,{label:`System prompt`,body:W.systemPrompt})]})]}),j&&(0,S.jsx)(`div`,{className:`cal-modal-error`,children:j}),(0,S.jsx)(`div`,{className:`cal-modal-actions`,children:_?L?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:e.disabled?`Put this agent back in the dispatchable set?`:`Stop this agent being dispatched?${x(W?.skills??[])}`}),(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:H,disabled:z,children:[z?(0,S.jsx)(o,{size:14,className:`spin`}):e.disabled?(0,S.jsx)(g,{size:14}):(0,S.jsx)(h,{size:14}),e.disabled?` Enable`:` Disable`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>R(!1),disabled:z,children:`Cancel`})]}):(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>R(!0),disabled:z||k||!E,children:e.disabled?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(g,{size:14}),` Enable`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(h,{size:14}),` Disable`]})}):u?(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`This agent is part of the product. To stop it running on its own, suspend the routines that dispatch it.`}):(0,S.jsxs)(S.Fragment,{children:[!N&&(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>P(!0),disabled:F||k||!E,children:[(0,S.jsx)(l,{size:14}),` Delete`]}),N&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this agent?`}),(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:V,disabled:F,children:[F?(0,S.jsx)(o,{size:14,className:`spin`}):(0,S.jsx)(l,{size:14}),` Delete`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>P(!1),disabled:F,children:`Cancel`})]})]})})]})})}var D=`maxy-admin-session-key`,O={green:`Read only`,amber:`Writes`,red:`Runs`},k={shipped:`Shipped`,specialist:`Specialist`,public:`Public`};function A(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1),[a,o]=(0,v.useState)(void 0),[s,l]=(0,v.useState)(null),[u,p]=(0,v.useState)(void 0),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(D)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&l(e.sessionId??null),_(e.role??null),p(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let y=(0,v.useCallback)(()=>{try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},[]),[b,x]=(0,v.useState)(!1),C=(0,v.useCallback)(async()=>{x(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`}return e}finally{x(!1)}},[]);return n?e?(0,S.jsx)(c,{cacheKey:e,surface:`agents`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=agents`);try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},children:(0,S.jsx)(f,{cacheKey:e,businessName:a,sessionId:s,onLogout:y,onDisconnect:C,disconnecting:b,userName:u,userAvatar:m,role:g,children:(0,S.jsx)(j,{cacheKey:e})})}):(0,S.jsx)(`div`,{className:`cal-page`,children:(0,S.jsxs)(`div`,{className:`cal-empty`,children:[(0,S.jsx)(`p`,{children:`You are not signed in.`}),(0,S.jsxs)(`p`,{children:[`Open the `,(0,S.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,S.jsx)(i,{surface:`gate`})}function j({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=s({initialCacheKey:e,surface:`agents`}),[r,a]=(0,v.useState)([]),[c,l]=(0,v.useState)(0),[u,d]=(0,v.useState)(0),[f,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,b]=(0,v.useState)(!1),[x,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(null),[D,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(``);(0,v.useEffect)(()=>{M(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]);let N=(0,v.useCallback)(()=>{let e=!1;return b(!0),T(null),t(`/api/admin/agents`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();a(Array.isArray(n.agents)?n.agents:[]),l(typeof n.skipped==`number`?n.skipped:0),d(typeof n.specialistsSkipped==`number`?n.specialistsSkipped:0),g(typeof n.accountId==`string`?n.accountId:null),m(n.riskSurfaceFailed===!0)}).catch(t=>{e||(T(t instanceof Error?t.message:`Failed to load`),a([]))}).finally(()=>{e||(b(!1),C(!0))}),()=>{e=!0}},[t]);(0,v.useEffect)(()=>N(),[N,n]);let P=(0,v.useCallback)(e=>{a(t=>t.filter(t=>t.slug!==e.slug)),A(null),N()},[N]);if(!x)return(0,S.jsx)(i,{surface:`gate`});let F=r.filter(e=>e.disabled).length;return(0,S.jsxs)(`div`,{className:`cal-page`,children:[(0,S.jsx)(`header`,{className:`cal-header`,children:(0,S.jsxs)(`div`,{className:`cal-nav`,children:[(0,S.jsxs)(`span`,{className:`cal-range-label`,children:[(0,S.jsx)(p,{size:16}),` `,r.length,` agent`,r.length===1?``:`s`,` · `,F,` stood down`]}),_&&(0,S.jsx)(o,{size:16,className:`spin`})]})}),(0,S.jsxs)(`div`,{className:`cal-body`,children:[w&&(0,S.jsxs)(`div`,{className:`cal-error`,children:[`Could not load agents: `,w]}),f&&(0,S.jsx)(`div`,{className:`cal-error`,children:`The plugin registry could not be read, so every agent below is shown at the highest risk regardless of the tools it declares. These badges are not derived.`}),c+u>0&&(0,S.jsxs)(`div`,{className:`cal-error`,children:[c+u,` agent`,c+u===1?``:`s`,` could not be read (malformed config or frontmatter).`]}),!w&&!_&&r.length===0&&(0,S.jsx)(`div`,{className:`cal-empty`,children:(0,S.jsx)(`p`,{children:`No agents yet. Ask in chat to create one.`})}),r.length>0&&(0,S.jsx)(`div`,{className:`routine-list`,children:r.map(e=>(0,S.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,onClick:()=>A(e),children:[(0,S.jsxs)(`span`,{className:`admin-card-title routine-card-title`,children:[e.displayName,e.risk&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--solid-${y[e.risk]}`,"data-testid":`agent-risk-badge`,children:O[e.risk]}),(0,S.jsx)(`span`,{className:`ui-pill agent-origin-${e.origin}`,children:k[e.origin]}),e.kind===`specialist`&&(0,S.jsx)(`span`,{className:`ui-pill ${e.disabled?`ui-pill--tint-error`:`ui-pill--tint-success`}`,children:e.disabled?`Stood down`:`Live`})]}),e.kind===`specialist`?(0,S.jsxs)(`span`,{className:`routine-card-sched`,children:[`/`,e.slug]}):(0,S.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,S.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),` /`,e.slug]}),(0,S.jsx)(`span`,{className:`routine-card-meta`,children:e.origin===`public`?e.status:e.plugin})]},`${e.origin}:${e.slug}`))})]}),D&&(0,S.jsx)(E,{summary:D,publicBaseUrl:j,accountId:h,adminFetch:t,onClose:()=>A(null),onDeleted:P,onToggled:N})]})}(0,_.createRoot)(document.getElementById(`root`)).render((0,S.jsx)(A,{}));
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,B as n,G as r,J as i,Y as a,Z as o,_ as s,b as c,v as l,x as u}from"./useSubAccountSwitcher-C7TtIbR3.js";import{A as d,S as f,T as p,t as m}from"./AdminShell-D24evn4t.js";var h=n(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),g=n(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),_=a(),v=e(o(),1),y={green:`success`,amber:`warning`,red:`error`};function b(e){if(!e.startsWith(`mcp__`))return e;let t=e.slice(5),n=t.indexOf(`__`);if(n<0)return e;let r=t.slice(n+2);return r.length>0?r:e}function x(e){let t=` Nothing will be able to hand work to it until it is switched back on.`;if(e.length===0)return t;let n=e.length===1?`skill runs`:`skills run`;return` ${e.length} ${n} through it: ${e.join(`, `)}.${t}`}var S=r(),C={read:`read`,write_local:`writes`,exec:`runs`,external:`sends`},w={read:`tool-chip-read`,write_local:`tool-chip-write_local`,exec:`tool-chip-exec`,external:`tool-chip-external`,unresolved:`tool-chip-unresolved`};function T({label:e,body:t}){return(0,S.jsxs)(`div`,{className:`agent-doc`,children:[(0,S.jsx)(`span`,{className:`agent-doc-label`,children:e}),(0,S.jsx)(`pre`,{className:`skill-body`,children:t.trim()||`Empty.`})]})}function E({summary:e,publicBaseUrl:n,accountId:r,adminFetch:i,onClose:a,onDeleted:o,onToggled:s}){let l=e.kind===`specialist`,d=e.origin===`specialist`,m=e.origin===`shipped`&&e.disabled,_=d||m,[E]=(0,v.useState)(r),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!0),[j,M]=(0,v.useState)(null),[N,P]=(0,v.useState)(!1),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),[z,B]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let t=!1;A(!0),M(null);let n=e.origin===`shipped`?`?origin=shipped`:e.kind===`specialist`&&e.plugin?`?plugin=${encodeURIComponent(e.plugin)}`:``;return i(`/api/admin/agents/${encodeURIComponent(e.slug)}${n}`).then(async e=>{if(!t){if(!e.ok)throw Error(`HTTP ${e.status}`);O((await e.json()).agent)}}).catch(e=>{t||M(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{t||A(!1)}),()=>{t=!0}},[i,e.slug]),(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!F&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[F,a]);let V=(0,v.useCallback)(async()=>{I(!0),M(null);try{let t=await i(`/api/admin/agents/${encodeURIComponent(e.slug)}?accountId=${encodeURIComponent(E??``)}`,{method:`DELETE`,headers:{"content-type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}o(e)}catch(e){M(e instanceof Error?e.message:`Delete failed`),I(!1),P(!1)}},[i,e,E,o]),H=(0,v.useCallback)(async()=>{let t=e.disabled?`enable`:`disable`;B(!0),M(null);try{let n=await i(`/api/admin/agents/${encodeURIComponent(e.slug)}/${t}?accountId=${encodeURIComponent(E??``)}`,{method:`POST`,headers:{"content-type":`application/json`}});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}s(),a()}catch(e){M(e instanceof Error?e.message:`${t} failed`),B(!1),R(!1)}},[i,e,E,s,a]),U=l?null:D,W=l?D:null;return(0,S.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{F||a()},children:(0,S.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Agent detail`,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,S.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,S.jsx)(p,{size:13}),` `,l?`Specialist`:`Agent`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:a,"aria-label":`Close`,autoFocus:!0,disabled:F,children:(0,S.jsx)(c,{size:16})})]}),(0,S.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,S.jsx)(`div`,{className:`cal-modal-title`,children:e.displayName}),(0,S.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[!l&&(0,S.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,S.jsxs)(`span`,{children:[`/`,e.slug]}),e.risk&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--solid-${y[e.risk]}`,children:e.risk===`green`?`Read only`:e.risk===`amber`?`Writes`:`Runs`}),e.disabled&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--tint-error`,children:`Disabled`})]}),e.risk&&e.riskReason&&(0,S.jsx)(`div`,{className:`cal-modal-row agent-risk-reason`,children:(0,S.jsx)(`span`,{children:e.riskReason})}),e.unresolved.length>0&&(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[`Forced to Runs: no declared risk class for `,e.unresolved.join(`, `),`.`]})}),k&&(0,S.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,S.jsx)(t,{size:14,className:`spin`}),(0,S.jsx)(`span`,{children:`Loading…`})]}),U&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[U.status,U.model?` · ${U.model}`:``]})}),(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`a`,{href:`${n}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`cal-link`,children:[(0,S.jsx)(f,{size:13}),` Open agent`]})}),U.present.identity&&(0,S.jsx)(T,{label:`Identity`,body:U.identity}),U.present.soul&&(0,S.jsx)(T,{label:`Soul`,body:U.soul}),U.present.knowledge&&(0,S.jsx)(T,{label:`Knowledge`,body:U.knowledge}),U.present.knowledgeSummary&&(0,S.jsx)(T,{label:`Knowledge summary`,body:U.knowledgeSummary}),U.knowledgeKeywords.length>0&&(0,S.jsxs)(`div`,{className:`skill-refs`,children:[(0,S.jsx)(`span`,{className:`skill-refs-label`,children:`Knowledge keywords`}),U.knowledgeKeywords.map(e=>(0,S.jsx)(`span`,{className:`skill-ref`,children:e},e))]})]}),W&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[e.plugin,W.model?` · ${W.model}`:``]})}),W.description&&(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsx)(`span`,{children:W.description})}),W.byTool.length>0&&(0,S.jsxs)(`div`,{className:`chip-refs`,children:[(0,S.jsxs)(`span`,{className:`skill-refs-label`,children:[`Tools (`,W.byTool.length,`)`]}),(0,S.jsx)(`div`,{className:`chip-row`,children:W.byTool.map(({tool:e,risk:t})=>(0,S.jsx)(`span`,{"data-testid":`tool-chip-${e}`,className:`tool-chip ${w[t??`unresolved`]}`,title:t?`${e} — ${C[t]}`:`${e} — no declared risk class`,children:b(e)},e))})]}),W.skills.length>0&&(0,S.jsxs)(`div`,{className:`chip-refs`,children:[(0,S.jsx)(`span`,{className:`skill-refs-label`,children:`Skills`}),(0,S.jsx)(`div`,{className:`chip-row`,children:W.skills.map(e=>(0,S.jsx)(`span`,{className:`tool-chip tool-chip-skill`,children:e},e))})]}),(0,S.jsx)(T,{label:`System prompt`,body:W.systemPrompt})]})]}),j&&(0,S.jsx)(`div`,{className:`cal-modal-error`,children:j}),(0,S.jsx)(`div`,{className:`cal-modal-actions`,children:_?L?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:e.disabled?`Put this agent back in the dispatchable set?`:`Stop this agent being dispatched?${x(W?.skills??[])}`}),(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:H,disabled:z,children:[z?(0,S.jsx)(t,{size:14,className:`spin`}):e.disabled?(0,S.jsx)(g,{size:14}):(0,S.jsx)(h,{size:14}),e.disabled?` Enable`:` Disable`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>R(!1),disabled:z,children:`Cancel`})]}):(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>R(!0),disabled:z||k||!E,children:e.disabled?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(g,{size:14}),` Enable`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(h,{size:14}),` Disable`]})}):l?(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`This agent is part of the product. To stop it running on its own, suspend the routines that dispatch it.`}):(0,S.jsxs)(S.Fragment,{children:[!N&&(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>P(!0),disabled:F||k||!E,children:[(0,S.jsx)(u,{size:14}),` Delete`]}),N&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this agent?`}),(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:V,disabled:F,children:[F?(0,S.jsx)(t,{size:14,className:`spin`}):(0,S.jsx)(u,{size:14}),` Delete`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>P(!1),disabled:F,children:`Cancel`})]})]})})]})})}var D=`maxy-admin-session-key`,O={green:`Read only`,amber:`Writes`,red:`Runs`},k={shipped:`Shipped`,specialist:`Specialist`,public:`Public`};function A(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(void 0),[o,c]=(0,v.useState)(null),[u,f]=(0,v.useState)(void 0),[p,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(D)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),f(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let y=(0,v.useCallback)(()=>{try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},[]),[b,x]=(0,v.useState)(!1),C=(0,v.useCallback)(async()=>{x(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`}return e}finally{x(!1)}},[]);return n?e?(0,S.jsx)(l,{cacheKey:e,surface:`agents`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=agents`);try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},children:(0,S.jsx)(m,{cacheKey:e,businessName:i,sessionId:o,onLogout:y,onDisconnect:C,disconnecting:b,userName:u,userAvatar:p,role:g,children:(0,S.jsx)(j,{cacheKey:e})})}):(0,S.jsx)(`div`,{className:`cal-page`,children:(0,S.jsxs)(`div`,{className:`cal-empty`,children:[(0,S.jsx)(`p`,{children:`You are not signed in.`}),(0,S.jsxs)(`p`,{children:[`Open the `,(0,S.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,S.jsx)(s,{surface:`gate`})}function j({cacheKey:e}){let{adminFetch:n,sessionRefetchNonce:r}=i({initialCacheKey:e,surface:`agents`}),[a,o]=(0,v.useState)([]),[c,l]=(0,v.useState)(0),[u,d]=(0,v.useState)(0),[f,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,b]=(0,v.useState)(!1),[x,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(null),[D,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(``);(0,v.useEffect)(()=>{M(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]);let N=(0,v.useCallback)(()=>{let e=!1;return b(!0),T(null),n(`/api/admin/agents`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();o(Array.isArray(n.agents)?n.agents:[]),l(typeof n.skipped==`number`?n.skipped:0),d(typeof n.specialistsSkipped==`number`?n.specialistsSkipped:0),g(typeof n.accountId==`string`?n.accountId:null),m(n.riskSurfaceFailed===!0)}).catch(t=>{e||(T(t instanceof Error?t.message:`Failed to load`),o([]))}).finally(()=>{e||(b(!1),C(!0))}),()=>{e=!0}},[n]);(0,v.useEffect)(()=>N(),[N,r]);let P=(0,v.useCallback)(e=>{o(t=>t.filter(t=>t.slug!==e.slug)),A(null),N()},[N]);if(!x)return(0,S.jsx)(s,{surface:`gate`});let F=a.filter(e=>e.disabled).length;return(0,S.jsxs)(`div`,{className:`cal-page`,children:[(0,S.jsx)(`header`,{className:`cal-header`,children:(0,S.jsxs)(`div`,{className:`cal-nav`,children:[(0,S.jsxs)(`span`,{className:`cal-range-label`,children:[(0,S.jsx)(p,{size:16}),` `,a.length,` agent`,a.length===1?``:`s`,` · `,F,` stood down`]}),_&&(0,S.jsx)(t,{size:16,className:`spin`})]})}),(0,S.jsxs)(`div`,{className:`cal-body agents-body`,children:[w&&(0,S.jsxs)(`div`,{className:`cal-error`,children:[`Could not load agents: `,w]}),f&&(0,S.jsx)(`div`,{className:`cal-error`,children:`The plugin registry could not be read, so every agent below is shown at the highest risk regardless of the tools it declares. These badges are not derived.`}),c+u>0&&(0,S.jsxs)(`div`,{className:`cal-error`,children:[c+u,` agent`,c+u===1?``:`s`,` could not be read (malformed config or frontmatter).`]}),!w&&!_&&a.length===0&&(0,S.jsx)(`div`,{className:`cal-empty`,children:(0,S.jsx)(`p`,{children:`No agents yet. Ask in chat to create one.`})}),a.length>0&&(0,S.jsx)(`div`,{className:`routine-list agents-list`,children:a.map(e=>(0,S.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,onClick:()=>A(e),children:[(0,S.jsxs)(`span`,{className:`admin-card-title routine-card-title`,children:[e.displayName,e.risk&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--solid-${y[e.risk]}`,"data-testid":`agent-risk-badge`,children:O[e.risk]}),(0,S.jsx)(`span`,{className:`ui-pill agent-origin-${e.origin}`,children:k[e.origin]}),e.kind===`specialist`&&(0,S.jsx)(`span`,{className:`ui-pill ${e.disabled?`ui-pill--tint-error`:`ui-pill--tint-success`}`,children:e.disabled?`Stood down`:`Live`})]}),e.kind===`specialist`?(0,S.jsxs)(`span`,{className:`routine-card-sched`,children:[`/`,e.slug]}):(0,S.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,S.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),` /`,e.slug]}),(0,S.jsx)(`span`,{className:`routine-card-meta`,children:e.origin===`public`?e.status:e.plugin})]},`${e.origin}:${e.slug}`))})]}),D&&(0,S.jsx)(E,{summary:D,publicBaseUrl:j,accountId:h,adminFetch:n,onClose:()=>A(null),onDeleted:P,onToggled:N})]})}(0,_.createRoot)(document.getElementById(`root`)).render((0,S.jsx)(A,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,G as n,M as r,Y as i,Z as a,v as o}from"./useSubAccountSwitcher-C7TtIbR3.js";import{A as s,m as c,t as l}from"./AdminShell-D24evn4t.js";var u=i(),d=e(a(),1),f=n();function p(){let[e,n]=(0,d.useState)(null),[i,a]=(0,d.useState)(!1),[u,p]=(0,d.useState)(void 0),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(void 0),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null);(0,d.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!t){n(null),a(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&p(e.businessName),e.sessionId!==void 0&&h(e.sessionId??null),x(e.role??null),_(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}n(t),a(!0)}}).catch(()=>{e||(n(t),a(!0))}),()=>{e=!0}},[]);let S=(0,d.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[C,w]=(0,d.useState)(!1),T=(0,d.useCallback)(async()=>{w(!0);try{let e=await s();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return i?e?(0,f.jsx)(o,{cacheKey:e,surface:`browser`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=browser`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,f.jsx)(l,{cacheKey:e,businessName:u,sessionId:m,onLogout:S,onDisconnect:T,disconnecting:C,userName:g,userAvatar:v,role:b,children:(0,f.jsxs)(`div`,{className:`data-page`,children:[(0,f.jsx)(`header`,{className:`data-header`,children:(0,f.jsxs)(`h1`,{className:`data-title`,children:[(0,f.jsx)(r,{size:18}),` Browser`]})}),(0,f.jsx)(c,{})]})})}):(0,f.jsxs)(`div`,{className:`data-page`,children:[(0,f.jsx)(`header`,{className:`data-header`,children:(0,f.jsxs)(`h1`,{className:`data-title`,children:[(0,f.jsx)(r,{size:18}),` Browser`]})}),(0,f.jsxs)(`div`,{className:`data-empty`,children:[(0,f.jsx)(`p`,{children:`You are not signed in.`}),(0,f.jsxs)(`p`,{children:[`Open the `,(0,f.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,f.jsx)(`div`,{className:`data-page`,children:(0,f.jsxs)(`div`,{className:`data-loading`,children:[(0,f.jsx)(t,{size:18,className:`spin`}),` Loading…`]})})}(0,u.createRoot)(document.getElementById(`root`)).render((0,f.jsx)(p,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,B as n,E as r,G as i,J as a,M as o,P as s,T as c,Y as l,Z as u,_ as d,b as f,v as p,x as m}from"./useSubAccountSwitcher-C7TtIbR3.js";import{A as h,S as g,t as _}from"./AdminShell-D24evn4t.js";import{t as v}from"./chevron-left-NGLHgPjF.js";import{t as y}from"./chevron-right-B4B7OkG8.js";import{t as b}from"./clock-7IMwxJdH.js";import{t as x}from"./file-text-BA9p7TLU.js";var S=n(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),C=n(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),w=n(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),T=n(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),E=n(`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`}]]),D=l(),O=e(u(),1),k=new Map;function A(e){let t=k.get(e);return t||(t=new Intl.DateTimeFormat(`en-CA`,{timeZone:e,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),k.set(e,t)),t}function j(e,t){let n=A(t).formatToParts(e),r=e=>Number(n.find(t=>t.type===e)?.value??`0`);return{y:r(`year`),m:r(`month`),d:r(`day`),hh:r(`hour`),mm:r(`minute`),ss:r(`second`)}}var M=e=>String(e).padStart(2,`0`);function N(e,t){let n=j(e,t);return`${n.y}-${M(n.m)}-${M(n.d)}`}function P(e,t){let n=j(e,t);return Date.UTC(n.y,n.m-1,n.d,n.hh,n.mm,n.ss)-e.getTime()}function F(e,t,n,r){let i=Date.UTC(e,t-1,n),a=i-P(new Date(i),r);return new Date(i-P(new Date(a),r))}function ee(e,t,n,r,i,a){let o=Date.UTC(e,t-1,n,r,i),s=o-P(new Date(o),a);return new Date(o-P(new Date(s),a))}var I=new Map;function L(e,t){let n=I.get(e);if(!n){try{n=new Intl.DateTimeFormat(`en-GB`,{timeZone:e,timeZoneName:`long`})}catch{return e}I.set(e,n)}return n.formatToParts(t).find(e=>e.type===`timeZoneName`)?.value??e}function R(){return Intl.DateTimeFormat().resolvedOptions().timeZone}var z=1440*60*1e3;function B(e,t){let n=j(e,t);return F(n.y,n.m,n.d,t)}function V(e,t,n){let r=j(e,n),i=new Date(Date.UTC(r.y,r.m-1,r.d)+t*z);return F(i.getUTCFullYear(),i.getUTCMonth()+1,i.getUTCDate(),n)}function H(e,t){let n=B(e,t),r=j(n,t),i=new Date(Date.UTC(r.y,r.m-1,r.d)).getUTCDay();return V(n,i===0?-6:1-i,t)}function U(e,t,n){let r=j(t,n);switch(e){case`day`:{let e=B(t,n);return{from:e,to:V(e,1,n)}}case`week`:{let e=H(t,n);return{from:e,to:V(e,7,n)}}case`month`:return{from:F(r.y,r.m,1,n),to:r.m===12?F(r.y+1,1,1,n):F(r.y,r.m+1,1,n)};case`year`:return{from:F(r.y,1,1,n),to:F(r.y+1,1,1,n)}}}function W(e,t,n,r){let i=j(t,r);switch(e){case`day`:return V(t,n,r);case`week`:return V(t,n*7,r);case`month`:{let e=i.y*12+(i.m-1)+n;return F(Math.floor(e/12),e%12+1,1,r)}case`year`:return F(i.y+n,i.m,1,r)}}function G(e,t,n){return N(e,n)===N(t,n)}var K=[`day`,`week`,`month`,`year`],te=`month`;function q(e,t){return e.toLocaleDateString([],{day:`numeric`,month:`short`,timeZone:t})}function ne(e,t){return e.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`,timeZone:t})}function re(e,t,n){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`,timeZone:n});case`week`:{let{from:e,to:r}=U(`week`,t,n);return`${q(e,n)} – ${ne(new Date(r.getTime()-1),n)}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`,timeZone:n});case`year`:return String(j(t,n).y)}}function ie(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var J=i(),ae={meeting:`Meeting`,event:`Event`,task:`Task`};function oe(e){return ae[e.kind??`meeting`]}function Y(e,t){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`,timeZone:t})}function se(e,t){if(e.isAllDay)return`All day`;let n=Y(new Date(e.startsAt),t);return e.endsAt?`${n} – ${Y(new Date(e.endsAt),t)}`:n}function X(e,t){if(!e)return``;let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=j(n,t),i=e=>String(e).padStart(2,`0`);return`${r.y}-${i(r.m)}-${i(r.d)}T${i(r.hh)}:${i(r.mm)}`}function Z(e,t){let n=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(e);if(!n)return``;let[,r,i,a,o,s]=n;return ee(Number(r),Number(i),Number(a),Number(o),Number(s),t).toISOString()}function ce(e,t){let n=new Date(e.startsAt),r={weekday:`long`,day:`numeric`,month:`long`,year:`numeric`,timeZone:t};if(e.isAllDay)return n.toLocaleDateString([],r);let i=n.toLocaleDateString([],r),a=Y(n,t);return e.endsAt?`${i} · ${a} – ${Y(new Date(e.endsAt),t)}`:`${i} · ${a}`}function le(e,t){return e.email??`${e.name??`unknown`}-${t}`}function ue(e){return e.map(e=>e.name||e.email||`Unknown`).join(`, `)}function de({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,J.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,J.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,J.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function fe(e){let t=[...e].sort((e,t)=>e.start.localeCompare(t.start)),n=[];for(let e of t){let t=n[n.length-1];t&&t.end===e.start?(t.end=e.end,t.slots+=1):n.push({start:e.start,end:e.end,slots:1})}return n}function pe(e,t){let n=e.slots===1?`slot`:`slots`;return`free ${Y(new Date(e.start),t)} – ${Y(new Date(e.end),t)} · ${e.slots} ${n}`}function me(e,t,n,r=[],i){let a=B(t,i),o=[];for(let t=0;t<n;t++){let n=V(a,t,i),s=e.filter(e=>G(new Date(e.startsAt),n,i)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),c=r.some(e=>G(new Date(e.start),n,i));(s.length>0||c)&&o.push({day:n,meetings:s})}return o}function he(e,t,n){return Math.round((B(t,n).getTime()-B(e,n).getTime())/864e5)}function ge(e,t,n){let r=e.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,timeZone:n});return G(e,t,n)?`${r} · today`:r}function _e({from:e,to:t,meetings:n,stretches:r,gapSource:i,showAllKinds:a,onToggleKinds:o,onSelect:s,onAddAt:c,zone:l,zoneSource:u}){let d=a?n:n.filter(e=>(e.kind??`meeting`)===`meeting`),f=n.length-d.length,p=new Date,m=me(d,e,he(e,t,l),r,l),h=(0,J.jsxs)(`div`,{className:`cal-list-controls`,children:[(0,J.jsx)(`button`,{type:`button`,className:`cal-kind-toggle${a?` cal-kind-toggle-on`:``}`,onClick:o,"aria-pressed":a,children:a?`Meetings only`:`Show reminders and tasks`}),f>0&&(0,J.jsxs)(`span`,{className:`cal-hidden-count`,children:[f,` hidden`]}),(0,J.jsxs)(`span`,{className:`cal-zone-label`,"data-zone":l,"data-zone-source":u,children:[`Times in `,L(l,p)]}),i===`none`&&(0,J.jsx)(`span`,{className:`cal-no-hours`,children:`Free time is not shown: working hours are not set.`})]});return m.length===0?(0,J.jsxs)(`div`,{className:`cal-schedule`,children:[h,(0,J.jsx)(`div`,{className:`cal-schedule-empty`,children:`No events in this period.`})]}):(0,J.jsxs)(`div`,{className:`cal-schedule`,children:[h,m.map(e=>{let t=r.filter(t=>G(new Date(t.start),e.day,l));return(0,J.jsxs)(`section`,{className:`cal-sched-group`,children:[(0,J.jsx)(`h3`,{className:`cal-sched-day${G(e.day,p,l)?` cal-sched-day-today`:``}`,children:ge(e.day,p,l)}),e.meetings.map(e=>{let t=[e.location,ue(e.attendees)||null,oe(e)].filter(Boolean);return(0,J.jsxs)(`div`,{className:`cal-sched-row`,"data-testid":`row-${e.meetingId}`,"data-meeting-id":e.meetingId,"data-kind":e.kind??`meeting`,...ie(e,s),children:[(0,J.jsx)(`span`,{className:`cal-sched-time`,children:se(e,l)}),(0,J.jsxs)(`span`,{className:`cal-sched-detail`,children:[(0,J.jsx)(`span`,{className:`cal-sched-title`,children:e.title??`Untitled`}),(0,J.jsx)(`span`,{className:`cal-sched-meta`,children:t.join(` · `)})]})]},e.meetingId)}),t.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`cal-gap`,"data-gap-start":e.start,onClick:()=>c(e.start,e.end),children:pe(e,l)},e.start))]},e.day.toISOString())})]})}function ve({initialStart:e,initialEnd:n,zone:r,adminFetch:i,onClose:a,onCreated:o}){let[s,c]=(0,O.useState)(``),[l,u]=(0,O.useState)(e),[d,p]=(0,O.useState)(n),[m,h]=(0,O.useState)(``),[g,_]=(0,O.useState)(``),[v,y]=(0,O.useState)(``),[b,x]=(0,O.useState)(!1),[S,C]=(0,O.useState)(null),w=(0,O.useCallback)(async()=>{if(!s.trim()){C(`Title is required`);return}if(!l){C(`Start time is required`);return}x(!0),C(null);try{let e=await i(`/api/admin/calendar/meetings`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({title:s.trim(),startsAt:Z(l,r),endsAt:d?Z(d,r):null,location:m.trim()||null,description:g.trim()||null,privateNote:v.trim()||null})}),t=await e.json();if(!e.ok){C(t.error??`Create failed (HTTP ${e.status})`);return}t.meeting&&o(t.meeting)}catch(e){C(e instanceof Error?e.message:`Create failed`)}finally{x(!1)}},[s,l,d,m,g,v,r,i,o]);return(0,J.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{b||a()},children:(0,J.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Add meeting`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,J.jsx)(`span`,{className:`cal-modal-kind`,children:`New meeting`}),(0,J.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:a,"aria-label":`Close`,disabled:b,children:(0,J.jsx)(f,{size:16})})]}),(0,J.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Title`}),(0,J.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),disabled:b,autoFocus:!0})]}),(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Starts`}),(0,J.jsx)(`input`,{type:`datetime-local`,value:l,onChange:e=>u(e.target.value),disabled:b})]}),(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Ends`}),(0,J.jsx)(`input`,{type:`datetime-local`,value:d,onChange:e=>p(e.target.value),disabled:b})]}),(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Location`}),(0,J.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),disabled:b})]}),(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Description`}),(0,J.jsx)(`textarea`,{value:g,onChange:e=>_(e.target.value),disabled:b,rows:3})]}),(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Private note`}),(0,J.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),disabled:b,rows:2})]}),S&&(0,J.jsx)(`div`,{className:`cal-modal-error`,children:S})]}),(0,J.jsxs)(`div`,{className:`cal-modal-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:a,disabled:b,children:`Cancel`}),(0,J.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:w,disabled:b,children:[b?(0,J.jsx)(t,{size:14,className:`spin`}):null,` Create`]})]})]})})}var ye=8;function be(e,t){return t?{op:`view-census`,range:e,nodes:t.nodes.length,clippedV:t.nodes.filter(e=>e.clippedV).length,clippedH:t.nodes.filter(e=>e.clippedH).length,hidden:t.hidden,fields:t.fields.length>0?t.fields.join(`,`):`-`,minBlockPx:t.minBlockPx??`-`,lineBoxPx:t.lineBoxPx??`-`,gapSource:t.gapSource??`-`,gaps:t.gaps??`-`,shownKinds:t.shownKinds??`-`,hiddenKinds:t.hiddenKinds??`-`,zone:t.zone??`-`,zoneSource:t.zoneSource??`-`,descrRows:t.descrRows??`-`,source:`measured`}:{op:`view-census`,range:e,nodes:`-`,clippedV:`-`,clippedH:`-`,hidden:`-`,fields:`-`,minBlockPx:`-`,lineBoxPx:`-`,gapSource:`-`,gaps:`-`,shownKinds:`-`,hiddenKinds:`-`,zone:`-`,zoneSource:`-`,descrRows:`-`,source:`unavailable`}}var xe=5;function Se(e,t){if(!t)return[];let n=[];for(let r of t.nodes)for(let t of[`v`,`h`])(t===`v`?r.clippedV:r.clippedH)&&n.push({op:`node-clipped`,view:e,meetingId:r.meetingId,axis:t,renderedPx:r.renderedPx,neededPx:r.neededPx,durationMin:r.durationMin??`-`});if(n.length<=xe)return n;let r=n.slice(0,xe);return r[r.length-1]={...r[r.length-1],truncated:n.length-xe},r}function Ce(e){let t=(e.textContent??``).length;if(t===0||e.scrollWidth===0||e.clientWidth>=e.scrollWidth-1)return!0;let n=e.scrollWidth/t;return e.clientWidth/n>=ye}function we(e){if(!e||typeof window>`u`||typeof window.getComputedStyle!=`function`)return null;let t=Array.from(e.querySelectorAll(`[data-meeting-id]`)),n=t.map(e=>e.getBoundingClientRect());if(t.length>0&&n.every(e=>e.height===0&&e.width===0))return null;let r=t.length>0?parseFloat(window.getComputedStyle(t[0]).lineHeight):null,i=t.map((e,t)=>{let r=e.querySelector(`.cal-sched-title`),i=e.querySelector(`.cal-event-title`)??r??e,a=i.scrollWidth>i.clientWidth+1,o=e.getAttribute(`data-duration-min`);return{meetingId:e.getAttribute(`data-meeting-id`)??`unknown`,clippedV:e.scrollHeight>e.clientHeight+1,clippedH:r?a:a&&!Ce(i),durationMin:o?Number(o):null,renderedPx:Math.round(n[t].height*10)/10,neededPx:Math.round(e.scrollHeight*10)/10}}),a=[];e.querySelector(`.cal-event-title, .cal-chip, .cal-sched-title`)&&a.push(`title`),e.querySelector(`.cal-event-time, .cal-sched-time`)&&a.push(`time`),e.querySelector(`.cal-sched-meta`)&&a.push(`meta`);let o=0;for(let t of Array.from(e.querySelectorAll(`.cal-more`)))o+=Number(t.getAttribute(`data-hidden-count`)??0);return{nodes:i,hidden:o,fields:a,minBlockPx:i.length>0?Math.min(...i.map(e=>e.renderedPx)):null,lineBoxPx:Number.isFinite(r)?r:null}}function Te(e,t){return{op:`detail-open`,descrPayload:e?1:0,descrShown:t?1:0}}function Ee(e){try{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`calendar-legibility`,...e}),keepalive:!0}).catch(()=>{})}catch{}}function De(e,t){for(let n of[be(e,t),...Se(e,t)])Ee(n)}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function Oe(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function ke({meeting:e,zone:n,adminFetch:i,onClose:a,onSaved:c,onDeleted:l}){let u=e.kind===`meeting`,[d,p]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1),[_,v]=(0,O.useState)(!1),[y,D]=(0,O.useState)(!1),[k,A]=(0,O.useState)(null),[j,M]=(0,O.useState)(e),[N,P]=(0,O.useState)(e.title??``),[F,ee]=(0,O.useState)(X(e.startsAt,n)),[I,L]=(0,O.useState)(e.endsAt?X(e.endsAt,n):``),[R,z]=(0,O.useState)(e.location??``),[B,V]=(0,O.useState)(e.description??``),[H,U]=(0,O.useState)(e.privateNote??``),[W,G]=(0,O.useState)(``),[K,te]=(0,O.useState)(``);(0,O.useLayoutEffect)(()=>{Ee(Te((j.description??``).trim().length>0,document.querySelector(`[data-testid="cal-descr"]`)!==null))},[j.meetingId,j.description]),(0,O.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!y&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y,a]);let q=(0,O.useCallback)(()=>{let e={},t=N.trim();t!==(j.title??``)&&(e.title=t);let r=Z(F,n);Q(r)!==Q(j.startsAt)&&(e.startsAt=r);let i=I?Z(I,n):null;(i===null?j.endsAt!==null:j.endsAt===null||Q(i)!==Q(j.endsAt))&&(e.endsAt=i);let a=R.trim()||null;a!==(j.location??null)&&(e.location=a);let o=B.trim()||null;o!==(j.description??null)&&(e.description=o);let s=H.trim()||null;return s!==(j.privateNote??null)&&(e.privateNote=s),e},[N,F,I,R,B,H,j,n]),ne=(0,O.useCallback)(async()=>{let t=q();if(Object.keys(t).length===0){p(!1);return}D(!0),A(null);try{let n=await i(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();M(r.meeting),c(r.meeting),p(!1)}catch(e){A(e instanceof Error?e.message:`Save failed`)}finally{D(!1)}},[i,q,e.meetingId,c]),re=(0,O.useCallback)(async()=>{let t=W.trim(),n=K.trim();if(!(!t&&!n)){D(!0),A(null);try{let r=await i(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t||void 0,email:n||void 0})});if(!r.ok)throw Error(`HTTP ${r.status}`);let a=await r.json();M(a.meeting),c(a.meeting),G(``),te(``)}catch(e){A(e instanceof Error?e.message:`Add failed`)}finally{D(!1)}}},[i,W,K,e.meetingId,c]),ie=(0,O.useCallback)(async t=>{let n=t.email?{email:t.email}:{name:t.name};D(!0),A(null);try{let t=await i(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();M(r.meeting),c(r.meeting)}catch(e){A(e instanceof Error?e.message:`Remove failed`)}finally{D(!1)}},[i,e.meetingId,c]),oe=(0,O.useCallback)(async()=>{D(!0),A(null);try{let t=await i(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);l(e.meetingId)}catch(e){A(e instanceof Error?e.message:`Delete failed`),D(!1)}},[i,e.meetingId,l]),Y=(0,O.useCallback)(async t=>{v(!1),D(!0),A(null);try{let n=await i(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${t?`1`:`0`}`);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.blob(),a=Oe(n.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(r),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){A(e instanceof Error?e.message:`Download failed`)}finally{D(!1)}},[i,e.meetingId]),se=ae[e.kind??`meeting`],ue=W.trim().length>0||K.trim().length>0;return(0,J.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{y||a()},children:(0,J.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":d?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,J.jsx)(`span`,{className:`cal-modal-kind`,children:se}),(0,J.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:a,"aria-label":`Close`,autoFocus:!0,disabled:y,children:(0,J.jsx)(f,{size:16})})]}),!d&&(0,J.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,J.jsx)(`div`,{className:`cal-modal-title`,children:j.title??`Untitled`}),(0,J.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,J.jsx)(b,{size:14}),(0,J.jsx)(`span`,{children:ce(j,n)})]}),j.timezone&&j.timezone!==n&&(0,J.jsxs)(`div`,{className:`cal-modal-row cal-modal-zone`,"data-testid":`cal-row-zone`,children:[(0,J.jsx)(o,{size:14}),(0,J.jsxs)(`span`,{children:[`Created in `,j.timezone]})]}),j.description&&(0,J.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,"data-testid":`cal-descr`,children:[(0,J.jsx)(x,{size:14}),(0,J.jsx)(`span`,{className:`cal-modal-descr`,children:j.description})]}),j.location&&(0,J.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,J.jsx)(C,{size:14}),(0,J.jsx)(`span`,{children:j.location})]}),j.attendees.length>0&&(0,J.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,J.jsx)(E,{size:14}),(0,J.jsx)(`div`,{className:`cal-modal-attendees`,children:j.attendees.map((e,t)=>(0,J.jsx)(`div`,{className:`cal-attendee-row`,children:(0,J.jsx)(de,{a:e})},le(e,t)))})]}),j.privateNote&&(0,J.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,J.jsx)(w,{size:14}),(0,J.jsx)(`span`,{className:`cal-modal-note`,children:j.privateNote})]}),(0,J.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,J.jsx)(S,{size:14}),(0,J.jsx)(`span`,{children:se})]})]}),d&&(0,J.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Title`}),(0,J.jsx)(`input`,{type:`text`,value:N,onChange:e=>P(e.target.value),disabled:y})]}),(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Start`}),(0,J.jsx)(`input`,{type:`datetime-local`,value:F,onChange:e=>ee(e.target.value),disabled:y})]}),(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`End`}),(0,J.jsx)(`input`,{type:`datetime-local`,value:I,onChange:e=>L(e.target.value),disabled:y})]}),(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Location`}),(0,J.jsx)(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),disabled:y})]}),(0,J.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Attendees`}),(0,J.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[j.attendees.length===0&&(0,J.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),j.attendees.map((e,t)=>(0,J.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,J.jsx)(de,{a:e}),(0,J.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>ie(e),disabled:y,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,J.jsx)(f,{size:13})})]},le(e,t)))]}),(0,J.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,J.jsx)(`input`,{type:`text`,placeholder:`Name`,value:W,onChange:e=>G(e.target.value),disabled:y,"aria-label":`Attendee name`}),(0,J.jsx)(`input`,{type:`email`,placeholder:`Email`,value:K,onChange:e=>te(e.target.value),disabled:y,"aria-label":`Attendee email`}),(0,J.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:re,disabled:y||!ue,"aria-label":`Add attendee`,children:y?(0,J.jsx)(t,{size:13,className:`spin`}):(0,J.jsx)(T,{size:13})})]})]}),(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Description`}),(0,J.jsx)(`textarea`,{className:`cal-modal-textarea`,value:B,onChange:e=>V(e.target.value),disabled:y,rows:3,placeholder:`The booking detail: who, what, how much.`})]}),(0,J.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,J.jsx)(`span`,{children:`Private note`}),(0,J.jsx)(`textarea`,{className:`cal-modal-textarea`,value:H,onChange:e=>U(e.target.value),disabled:y,rows:3,placeholder:`Only you and your team can see this.`})]})]}),k&&(0,J.jsx)(`div`,{className:`cal-modal-error`,children:k}),u&&(0,J.jsxs)(`div`,{className:`cal-modal-actions`,children:[!d&&!h&&!_&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>p(!0),disabled:y,children:[(0,J.jsx)(r,{size:14}),` Edit`]}),(0,J.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>g(!0),disabled:y,children:[(0,J.jsx)(m,{size:14}),` Delete`]}),(0,J.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{j.attendees.length>0?v(!0):Y(!1)},disabled:y,children:[y?(0,J.jsx)(t,{size:14,className:`spin`}):(0,J.jsx)(s,{size:14}),` Download`]})]}),_&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,J.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>Y(!0),disabled:y,children:[y?(0,J.jsx)(t,{size:14,className:`spin`}):null,` Yes`]}),(0,J.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>Y(!1),disabled:y,children:`No`}),(0,J.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>v(!1),disabled:y,children:`Cancel`})]}),d&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:ne,disabled:y,children:[y?(0,J.jsx)(t,{size:14,className:`spin`}):null,` Save`]}),(0,J.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{p(!1),A(null)},disabled:y,children:`Cancel`})]}),h&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,J.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:oe,disabled:y,children:[y?(0,J.jsx)(t,{size:14,className:`spin`}):null,` Delete`]}),(0,J.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>g(!1),disabled:y,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,Ae=`maxy-calendar-show-all-kinds`;function je(){let[e,t]=(0,O.useState)(null),[n,r]=(0,O.useState)(!1),[i,a]=(0,O.useState)(void 0),[o,s]=(0,O.useState)(null),[c,l]=(0,O.useState)(void 0),[u,f]=(0,O.useState)(null),[m,g]=(0,O.useState)(null),[v,y]=(0,O.useState)(null),[b,x]=(0,O.useState)(`browser`);(0,O.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&s(e.sessionId??null),g(e.role??null),l(e.userName===void 0?null:e.userName),f(e.avatar??null),typeof e.timezone==`string`&&e.timezone&&y(e.timezone),(e.timezoneSource===`account`||e.timezoneSource===`browser`)&&x(e.timezoneSource)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let S=(0,O.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[C,w]=(0,O.useState)(!1),T=(0,O.useCallback)(async()=>{w(!0);try{let e=await h();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return n?e?(0,J.jsx)(p,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,J.jsx)(_,{cacheKey:e,businessName:i,sessionId:o,onLogout:S,onDisconnect:T,disconnecting:C,userName:c,userAvatar:u,role:m,children:(0,J.jsx)(Me,{cacheKey:e,zone:v??R(),zoneSource:b})})}):(0,J.jsx)(`div`,{className:`cal-page`,children:(0,J.jsxs)(`div`,{className:`cal-empty`,children:[(0,J.jsx)(`p`,{children:`You are not signed in.`}),(0,J.jsxs)(`p`,{children:[`Open the `,(0,J.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,J.jsx)(d,{surface:`gate`})}function Me({cacheKey:e,zone:n,zoneSource:r}){let{adminFetch:i,sessionRefetchNonce:o}=a({initialCacheKey:e,surface:`calendar`}),[s,l]=(0,O.useState)(te),[u,f]=(0,O.useState)(()=>new Date),[p,m]=(0,O.useState)([]),[h,_]=(0,O.useState)(!1),[b,x]=(0,O.useState)(!1),[S,C]=(0,O.useState)(null),[w,T]=(0,O.useState)(null),[E,D]=(0,O.useState)([]),[k,A]=(0,O.useState)(`none`),[j,M]=(0,O.useState)(()=>{try{return sessionStorage.getItem(Ae)===`1`}catch{return!1}}),[N,P]=(0,O.useState)(null),[F,ee]=(0,O.useState)(0),[I,L]=(0,O.useState)(null);(0,O.useEffect)(()=>{let e=!1;return i(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&L(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[i]),(0,O.useEffect)(()=>{let e=!1,{from:t,to:r}=U(s,u,n);return _(!0),C(null),i(`/api/admin/calendar/meetings?from=${encodeURIComponent(t.toISOString())}&to=${encodeURIComponent(r.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();m(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(C(t instanceof Error?t.message:`Failed to load`),m([]))}).finally(()=>{e||(_(!1),x(!0))}),()=>{e=!0}},[s,u,n,o,i]),(0,O.useEffect)(()=>{let e=!1,{from:t,to:r}=U(s,u,n);return i(`/api/admin/calendar/free-busy?from=${encodeURIComponent(t.toISOString())}&to=${encodeURIComponent(r.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();D(fe(Array.isArray(n.slots)?n.slots:[])),A(n.gapSource===`config`?`config`:`none`)}).catch(()=>{e||(D([]),A(`none`))}),()=>{e=!0}},[s,u,n,o,i,F]);let R=(0,O.useCallback)(()=>f(new Date),[]),z=(0,O.useCallback)(()=>f(e=>W(s,e,-1,n)),[s,n]),B=(0,O.useCallback)(()=>f(e=>W(s,e,1,n)),[s,n]),V=(0,O.useCallback)(()=>{M(e=>{let t=!e;try{sessionStorage.setItem(Ae,t?`1`:`0`)}catch{}return t})},[]),H=(0,O.useCallback)((e,t)=>P({startsAt:X(e,n),endsAt:X(t,n)}),[n]),G=(0,O.useCallback)(e=>{m(t=>[...t,e]),ee(e=>e+1),P(null)},[]);(0,O.useEffect)(()=>{T(null)},[s,u]);let q=(0,O.useRef)(null);(0,O.useEffect)(()=>{if(h)return;let e=requestAnimationFrame(()=>{let e=we(q.current);De(s,e&&{...e,zone:n,zoneSource:r,descrRows:p.filter(e=>(e.description??``).trim().length>0).length,gapSource:k,gaps:E.length,shownKinds:j?`meeting,event,task`:`meeting`,hiddenKinds:j?0:p.filter(e=>(e.kind??`meeting`)!==`meeting`).length})});return()=>cancelAnimationFrame(e)},[s,p,h,k,E,j,n,r]);let ne=(0,O.useCallback)(e=>{m(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),T(e)},[]),ie=(0,O.useCallback)(e=>{m(t=>t.filter(t=>t.meetingId!==e)),T(null)},[]);return b?(0,J.jsxs)(`div`,{className:`cal-page`,children:[(0,J.jsxs)(`header`,{className:`cal-header`,children:[(0,J.jsxs)(`div`,{className:`cal-nav`,children:[(0,J.jsx)(`span`,{className:`cal-range-label`,children:re(s,u,n)}),(0,J.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:z,"aria-label":`Previous`,children:(0,J.jsx)(v,{size:18})}),(0,J.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:B,"aria-label":`Next`,children:(0,J.jsx)(y,{size:18})}),(0,J.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:R,children:`Today`}),h&&(0,J.jsx)(t,{size:16,className:`spin`})]}),(0,J.jsxs)(`button`,{type:`button`,className:`cal-add-btn`,onClick:()=>P({startsAt:``,endsAt:``}),children:[(0,J.jsx)(c,{size:14}),` Add`]}),(0,J.jsx)(`div`,{className:`cal-views`,children:K.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===s?` cal-view-btn-active`:``}`,onClick:()=>l(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),I&&(0,J.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${I}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,J.jsx)(g,{size:14}),` Booking page`]})]}),(0,J.jsxs)(`div`,{className:`cal-body`,ref:q,children:[S&&(0,J.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,S]}),(0,J.jsx)(_e,{zone:n,zoneSource:r,from:U(s,u,n).from,to:U(s,u,n).to,meetings:p,stretches:E,gapSource:k,showAllKinds:j,onToggleKinds:V,onSelect:T,onAddAt:H})]}),N&&(0,J.jsx)(ve,{zone:n,initialStart:N.startsAt,initialEnd:N.endsAt,adminFetch:i,onClose:()=>P(null),onCreated:G}),w&&(0,J.jsx)(ke,{zone:n,meeting:w,adminFetch:i,onClose:()=>T(null),onSaved:ne,onDeleted:ie})]}):(0,J.jsx)(d,{surface:`gate`})}(0,D.createRoot)(document.getElementById(`root`)).render((0,J.jsx)(je,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{G as e,Y as t}from"./useSubAccountSwitcher-C7TtIbR3.js";import"./useVoiceRecorder-DgyAGgmF.js";import"./AdminShell-D24evn4t.js";import{n}from"./page-CpJpyoPS.js";import"./useCopyFeedback-BwK1RhmF.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e}from"./useSubAccountSwitcher-C7TtIbR3.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e}from"./useSubAccountSwitcher-C7TtIbR3.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e}from"./useSubAccountSwitcher-C7TtIbR3.js";var t=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]);export{t};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e}from"./useSubAccountSwitcher-C7TtIbR3.js";var t=e(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]);export{t};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{G as e,Y as t}from"./useSubAccountSwitcher-C7TtIbR3.js";import"./useVoiceRecorder-DgyAGgmF.js";import{t as n}from"./page-D0ShNyGE.js";import"./graph-labels-CiK412vE.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
`�v��Kc�]����P(YW��KT�.?��ZlB��,� DH�s(��SX\v��|�sٶ_�]�PvK�Kpn��f���tl��:�
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{B as e}from"./useSubAccountSwitcher-C7TtIbR3.js";var t=e(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]);export{t};
|
|
Binary file
|
|
Binary file
|