@rubytech/create-maxy-code 0.1.602 → 0.1.604
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/email-sampler-unit.test.js +22 -0
- package/dist/index.js +3 -0
- package/dist/port-resolution.js +9 -1
- package/package.json +1 -1
- package/payload/platform/lib/routine-templates/dist/roster.d.ts +17 -1
- package/payload/platform/lib/routine-templates/dist/roster.d.ts.map +1 -1
- package/payload/platform/lib/routine-templates/dist/roster.js +8 -0
- package/payload/platform/lib/routine-templates/dist/roster.js.map +1 -1
- package/payload/platform/lib/routine-templates/src/__tests__/seed.test.ts +26 -1
- package/payload/platform/lib/routine-templates/src/roster.ts +26 -1
- package/payload/platform/lib/telegram-store-read/dist/index.d.ts +59 -0
- package/payload/platform/lib/telegram-store-read/dist/index.d.ts.map +1 -0
- package/payload/platform/lib/telegram-store-read/dist/index.js +219 -0
- package/payload/platform/lib/telegram-store-read/dist/index.js.map +1 -0
- package/payload/platform/lib/telegram-store-read/src/__tests__/fold.test.ts +124 -0
- package/payload/platform/lib/telegram-store-read/src/index.ts +262 -0
- package/payload/platform/lib/telegram-store-read/tsconfig.json +9 -0
- package/payload/platform/lib/telegram-store-read/vitest.config.ts +9 -0
- package/payload/platform/neo4j/schema.cypher +7 -0
- package/payload/platform/package.json +2 -2
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +51 -4
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +12 -0
- package/payload/platform/plugins/docs/references/outlook-guide.md +21 -2
- package/payload/platform/plugins/docs/references/telegram-guide.md +29 -1
- package/payload/platform/plugins/email/PLUGIN.md +10 -1
- package/payload/platform/plugins/email/mcp/dist/sampler/__tests__/sample-mailbox.test.js +30 -0
- package/payload/platform/plugins/email/mcp/dist/sampler/__tests__/sample-mailbox.test.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/sampler/main.js +49 -3
- package/payload/platform/plugins/email/mcp/dist/sampler/main.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/sampler/sample-mailbox.d.ts +5 -0
- package/payload/platform/plugins/email/mcp/dist/sampler/sample-mailbox.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/sampler/sample-mailbox.js +10 -5
- package/payload/platform/plugins/email/mcp/dist/sampler/sample-mailbox.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-section-properties-strip.test.js +11 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-section-properties-strip.test.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-ingest.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-ingest.js +8 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-ingest.js.map +1 -1
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sample-outlook-mailbox.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sample-outlook-mailbox.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sample-outlook-mailbox.test.js +324 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sample-outlook-mailbox.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sampler-cursor.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sampler-cursor.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sampler-cursor.test.js +102 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sampler-cursor.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sampler-enumerate.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sampler-enumerate.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sampler-enumerate.test.js +125 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/sampler-enumerate.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/arm.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/arm.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/arm.js +109 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/arm.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/cursor.d.ts +25 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/cursor.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/cursor.js +94 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/cursor.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/enumerate.d.ts +41 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/enumerate.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/enumerate.js +122 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/enumerate.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/sample-outlook-mailbox.d.ts +73 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/sample-outlook-mailbox.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/sample-outlook-mailbox.js +162 -0
- package/payload/platform/plugins/outlook/mcp/dist/sampler/sample-outlook-mailbox.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/index.js +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-flag.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-flag.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-flag.test.js +90 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-flag.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate.test.js +26 -4
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate.test.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate-flag.d.ts +78 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate-flag.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate-flag.js +76 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate-flag.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate.d.ts +8 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate.js +9 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/gate-dispatch-wiring.test.js +15 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/gate-dispatch-wiring.test.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.d.ts +12 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.js +34 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/check-due-events.js +9 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/check-due-events.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/scheduling-gate.test.js +116 -4
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/scheduling-gate.test.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/scheduling-gate.d.ts +60 -2
- package/payload/platform/plugins/scheduling/mcp/dist/tools/scheduling-gate.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/scheduling-gate.js +101 -4
- package/payload/platform/plugins/scheduling/mcp/dist/tools/scheduling-gate.js.map +1 -1
- package/payload/platform/plugins/telegram/PLUGIN.md +1 -1
- package/payload/platform/plugins/telegram/mcp/dist/__tests__/messages.test.d.ts +2 -0
- package/payload/platform/plugins/telegram/mcp/dist/__tests__/messages.test.d.ts.map +1 -0
- package/payload/platform/plugins/telegram/mcp/dist/__tests__/messages.test.js +157 -0
- package/payload/platform/plugins/telegram/mcp/dist/__tests__/messages.test.js.map +1 -0
- package/payload/platform/plugins/telegram/mcp/dist/__tests__/public-pin.test.js +2 -2
- package/payload/platform/plugins/telegram/mcp/dist/__tests__/public-pin.test.js.map +1 -1
- package/payload/platform/plugins/telegram/mcp/dist/index.js +32 -34
- package/payload/platform/plugins/telegram/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/telegram/mcp/dist/lib/public-pin.js +1 -1
- package/payload/platform/plugins/telegram/mcp/dist/lib/public-pin.js.map +1 -1
- package/payload/platform/plugins/telegram/mcp/dist/tools/messages.d.ts +27 -0
- package/payload/platform/plugins/telegram/mcp/dist/tools/messages.d.ts.map +1 -0
- package/payload/platform/plugins/telegram/mcp/dist/tools/messages.js +152 -0
- package/payload/platform/plugins/telegram/mcp/dist/tools/messages.js.map +1 -0
- package/payload/platform/plugins/telegram/skills/build/SKILL.md +1 -1
- package/payload/platform/plugins/telegram/skills/configure/SKILL.md +15 -1
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +1 -1
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
- package/payload/platform/templates/specialists/agents/personal-assistant.md +1 -1
- package/payload/server/public/activity.html +6 -6
- package/payload/server/public/agents.html +5 -5
- package/payload/server/public/assets/{AdminLoginScreens-CaQqLuxZ.js → AdminLoginScreens-DI5bNlX8.js} +1 -1
- package/payload/server/public/assets/AdminLoginScreens-DI5bNlX8.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-DI5bNlX8.js.gz +0 -0
- package/payload/server/public/assets/{AdminShell-D8WTrqem.js → AdminShell-B-iX9ahJ.js} +1 -1
- package/payload/server/public/assets/AdminShell-B-iX9ahJ.js.br +0 -0
- package/payload/server/public/assets/AdminShell-B-iX9ahJ.js.gz +0 -0
- package/payload/server/public/assets/{activity-B3fiJrC2.js → activity-CqgFwANo.js} +1 -1
- package/payload/server/public/assets/activity-CqgFwANo.js.br +0 -0
- package/payload/server/public/assets/activity-CqgFwANo.js.gz +0 -0
- package/payload/server/public/assets/{admin-ouF-DflP.js → admin-K63n6ybW.js} +1 -1
- package/payload/server/public/assets/admin-K63n6ybW.js.br +0 -0
- package/payload/server/public/assets/admin-K63n6ybW.js.gz +0 -0
- package/payload/server/public/assets/{agents-C8RSXHdh.js → agents-cue5Zf8X.js} +1 -1
- package/payload/server/public/assets/agents-cue5Zf8X.js.br +0 -0
- package/payload/server/public/assets/agents-cue5Zf8X.js.gz +0 -0
- package/payload/server/public/assets/{browser-Dbv6-Rag.js → browser-CqDBcKwU.js} +1 -1
- package/payload/server/public/assets/browser-CqDBcKwU.js.br +0 -0
- package/payload/server/public/assets/browser-CqDBcKwU.js.gz +0 -0
- package/payload/server/public/assets/{calendar-vJjtsH9n.js → calendar-BgzuW5Rt.js} +1 -1
- package/payload/server/public/assets/calendar-BgzuW5Rt.js.br +0 -0
- package/payload/server/public/assets/calendar-BgzuW5Rt.js.gz +0 -0
- package/payload/server/public/assets/chat-HYZViu2u.js +1 -0
- package/payload/server/public/assets/chat-HYZViu2u.js.br +3 -0
- package/payload/server/public/assets/chat-HYZViu2u.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-C5FXH9r_.js +1 -0
- package/payload/server/public/assets/chevron-left-C5FXH9r_.js.br +0 -0
- package/payload/server/public/assets/clock-DxPtyejC.js +1 -0
- package/payload/server/public/assets/clock-DxPtyejC.js.br +0 -0
- package/payload/server/public/assets/clock-DxPtyejC.js.gz +0 -0
- package/payload/server/public/assets/{copy-DyG7sC5o.js → copy-BNhZ0flH.js} +1 -1
- package/payload/server/public/assets/copy-BNhZ0flH.js.br +0 -0
- package/payload/server/public/assets/copy-BNhZ0flH.js.gz +0 -0
- package/payload/server/public/assets/data-kCBB8Z4Z.js +1 -0
- package/payload/server/public/assets/data-kCBB8Z4Z.js.br +0 -0
- package/payload/server/public/assets/data-kCBB8Z4Z.js.gz +0 -0
- package/payload/server/public/assets/{field-Bx6pM-vq.js → field-X4OVA3vx.js} +1 -1
- package/payload/server/public/assets/field-X4OVA3vx.js.br +0 -0
- package/payload/server/public/assets/field-X4OVA3vx.js.gz +0 -0
- package/payload/server/public/assets/{file-text-CpHWsMGe.js → file-text-BddO_2EI.js} +1 -1
- package/payload/server/public/assets/file-text-BddO_2EI.js.br +0 -0
- package/payload/server/public/assets/file-text-BddO_2EI.js.gz +0 -0
- package/payload/server/public/assets/{graph-DjOywuv_.js → graph-l7tzHqvm.js} +1 -1
- package/payload/server/public/assets/graph-l7tzHqvm.js.br +0 -0
- package/payload/server/public/assets/graph-l7tzHqvm.js.gz +0 -0
- package/payload/server/public/assets/{graph-labels-CGWtqa-m.js → graph-labels-CtFFq5W2.js} +1 -1
- package/payload/server/public/assets/graph-labels-CtFFq5W2.js.br +0 -0
- package/payload/server/public/assets/graph-labels-CtFFq5W2.js.gz +0 -0
- package/payload/server/public/assets/jsx-runtime-bq0g4NlA.css +1 -0
- package/payload/server/public/assets/jsx-runtime-bq0g4NlA.css.br +0 -0
- package/payload/server/public/assets/jsx-runtime-bq0g4NlA.css.gz +0 -0
- package/payload/server/public/assets/{operator-_DN0RF1R.js → operator-Dg-dwf7a.js} +1 -1
- package/payload/server/public/assets/operator-Dg-dwf7a.js.br +7 -0
- package/payload/server/public/assets/operator-Dg-dwf7a.js.gz +0 -0
- package/payload/server/public/assets/{page-DI4qQIK0.js → page-Ci1bfIbs.js} +1 -1
- package/payload/server/public/assets/page-Ci1bfIbs.js.br +0 -0
- package/payload/server/public/assets/page-Ci1bfIbs.js.gz +0 -0
- package/payload/server/public/assets/{page-zCwgrs8m.js → page-Y9JmFq0Q.js} +1 -1
- package/payload/server/public/assets/page-Y9JmFq0Q.js.br +0 -0
- package/payload/server/public/assets/page-Y9JmFq0Q.js.gz +0 -0
- package/payload/server/public/assets/play-BSZVGpQT.js +1 -0
- package/payload/server/public/assets/play-BSZVGpQT.js.br +0 -0
- package/payload/server/public/assets/play-BSZVGpQT.js.gz +0 -0
- package/payload/server/public/assets/{public-DDVWBNSH.js → public-m66FAza_.js} +1 -1
- package/payload/server/public/assets/public-m66FAza_.js.br +0 -0
- package/payload/server/public/assets/public-m66FAza_.js.gz +0 -0
- package/payload/server/public/assets/{rotate-ccw-xTwkf-m7.js → rotate-ccw-DTOJmOxB.js} +1 -1
- package/payload/server/public/assets/rotate-ccw-DTOJmOxB.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-DTOJmOxB.js.gz +0 -0
- package/payload/server/public/assets/{routines-Bu5MdNmG.js → routines-6fxZNacQ.js} +1 -1
- package/payload/server/public/assets/routines-6fxZNacQ.js.br +0 -0
- package/payload/server/public/assets/routines-6fxZNacQ.js.gz +0 -0
- package/payload/server/public/assets/{skills-DRunh5vy.js → skills-51mqx-s5.js} +1 -1
- package/payload/server/public/assets/skills-51mqx-s5.js.br +0 -0
- package/payload/server/public/assets/skills-51mqx-s5.js.gz +0 -0
- package/payload/server/public/assets/{tasks-DI2fznvd.js → tasks-D4y-Cwa3.js} +1 -1
- package/payload/server/public/assets/tasks-D4y-Cwa3.js.br +0 -0
- package/payload/server/public/assets/tasks-D4y-Cwa3.js.gz +0 -0
- package/payload/server/public/assets/{triangle-alert-B6CHZeUf.js → triangle-alert-BzCjDFts.js} +1 -1
- package/payload/server/public/assets/triangle-alert-BzCjDFts.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-BzCjDFts.js.gz +0 -0
- package/payload/server/public/assets/{useCopyFeedback-6rU2IEPk.js → useCopyFeedback-BG7h37Rx.js} +1 -1
- package/payload/server/public/assets/useCopyFeedback-BG7h37Rx.js.br +2 -0
- package/payload/server/public/assets/useCopyFeedback-BG7h37Rx.js.gz +0 -0
- package/payload/server/public/assets/{useMediaQuery-D7A5Bzs3.js → useMediaQuery-CqwktQr_.js} +1 -1
- package/payload/server/public/assets/useMediaQuery-CqwktQr_.js.br +0 -0
- package/payload/server/public/assets/{useMediaQuery-D7A5Bzs3.js.gz → useMediaQuery-CqwktQr_.js.gz} +0 -0
- package/payload/server/public/assets/{useVoiceRecorder-CptrerVA.js → useVoiceRecorder-CAZcUc1s.js} +1 -1
- package/payload/server/public/assets/useVoiceRecorder-CAZcUc1s.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-CAZcUc1s.js.gz +0 -0
- package/payload/server/public/assets/{wrench-DyX4C8aY.js → wrench-B2WKLLQG.js} +1 -1
- package/payload/server/public/assets/wrench-B2WKLLQG.js.br +0 -0
- package/payload/server/public/assets/wrench-B2WKLLQG.js.gz +0 -0
- package/payload/server/public/browser.html +5 -5
- package/payload/server/public/calendar.html +8 -8
- package/payload/server/public/chat.html +14 -14
- package/payload/server/public/data.html +12 -12
- package/payload/server/public/field.html +3 -3
- package/payload/server/public/graph.html +10 -10
- package/payload/server/public/index.html +14 -14
- package/payload/server/public/operator.html +16 -16
- package/payload/server/public/public.html +14 -14
- package/payload/server/public/routines.html +8 -8
- package/payload/server/public/skills.html +6 -6
- package/payload/server/public/tasks.html +7 -7
- package/payload/server/server.js +500 -325
- package/payload/platform/plugins/telegram/mcp/dist/tools/message-history.d.ts +0 -16
- package/payload/platform/plugins/telegram/mcp/dist/tools/message-history.d.ts.map +0 -1
- package/payload/platform/plugins/telegram/mcp/dist/tools/message-history.js +0 -68
- package/payload/platform/plugins/telegram/mcp/dist/tools/message-history.js.map +0 -1
- package/payload/server/public/assets/AdminLoginScreens-CaQqLuxZ.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-CaQqLuxZ.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-D8WTrqem.js.br +0 -0
- package/payload/server/public/assets/AdminShell-D8WTrqem.js.gz +0 -0
- package/payload/server/public/assets/activity-B3fiJrC2.js.br +0 -0
- package/payload/server/public/assets/activity-B3fiJrC2.js.gz +0 -0
- package/payload/server/public/assets/admin-ouF-DflP.js.br +0 -0
- package/payload/server/public/assets/admin-ouF-DflP.js.gz +0 -0
- package/payload/server/public/assets/agents-C8RSXHdh.js.br +0 -0
- package/payload/server/public/assets/agents-C8RSXHdh.js.gz +0 -0
- package/payload/server/public/assets/browser-Dbv6-Rag.js.br +0 -0
- package/payload/server/public/assets/browser-Dbv6-Rag.js.gz +0 -0
- package/payload/server/public/assets/calendar-vJjtsH9n.js.br +0 -0
- package/payload/server/public/assets/calendar-vJjtsH9n.js.gz +0 -0
- package/payload/server/public/assets/chat-cqL4qPUy.js +0 -1
- package/payload/server/public/assets/chat-cqL4qPUy.js.br +0 -1
- package/payload/server/public/assets/chat-cqL4qPUy.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-DB98DSG3.js +0 -1
- package/payload/server/public/assets/chevron-left-DB98DSG3.js.br +0 -0
- package/payload/server/public/assets/clock-4YwsYe4L.js +0 -1
- package/payload/server/public/assets/clock-4YwsYe4L.js.br +0 -0
- package/payload/server/public/assets/clock-4YwsYe4L.js.gz +0 -0
- package/payload/server/public/assets/copy-DyG7sC5o.js.br +0 -0
- package/payload/server/public/assets/copy-DyG7sC5o.js.gz +0 -0
- package/payload/server/public/assets/data-BAzLtx9C.js +0 -1
- package/payload/server/public/assets/data-BAzLtx9C.js.br +0 -0
- package/payload/server/public/assets/data-BAzLtx9C.js.gz +0 -0
- package/payload/server/public/assets/field-Bx6pM-vq.js.br +0 -0
- package/payload/server/public/assets/field-Bx6pM-vq.js.gz +0 -0
- package/payload/server/public/assets/file-text-CpHWsMGe.js.br +0 -0
- package/payload/server/public/assets/file-text-CpHWsMGe.js.gz +0 -0
- package/payload/server/public/assets/graph-DjOywuv_.js.br +0 -0
- package/payload/server/public/assets/graph-DjOywuv_.js.gz +0 -0
- package/payload/server/public/assets/graph-labels-CGWtqa-m.js.br +0 -0
- package/payload/server/public/assets/graph-labels-CGWtqa-m.js.gz +0 -0
- package/payload/server/public/assets/jsx-runtime-D75_aR1J.css +0 -1
- package/payload/server/public/assets/jsx-runtime-D75_aR1J.css.br +0 -0
- package/payload/server/public/assets/jsx-runtime-D75_aR1J.css.gz +0 -0
- package/payload/server/public/assets/operator-_DN0RF1R.js.br +0 -0
- package/payload/server/public/assets/operator-_DN0RF1R.js.gz +0 -0
- package/payload/server/public/assets/page-DI4qQIK0.js.br +0 -0
- package/payload/server/public/assets/page-DI4qQIK0.js.gz +0 -0
- package/payload/server/public/assets/page-zCwgrs8m.js.br +0 -0
- package/payload/server/public/assets/page-zCwgrs8m.js.gz +0 -0
- package/payload/server/public/assets/play-CHQ5a9yh.js +0 -1
- package/payload/server/public/assets/play-CHQ5a9yh.js.br +0 -0
- package/payload/server/public/assets/play-CHQ5a9yh.js.gz +0 -0
- package/payload/server/public/assets/public-DDVWBNSH.js.br +0 -0
- package/payload/server/public/assets/public-DDVWBNSH.js.gz +0 -0
- package/payload/server/public/assets/rotate-ccw-xTwkf-m7.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-xTwkf-m7.js.gz +0 -0
- package/payload/server/public/assets/routines-Bu5MdNmG.js.br +0 -0
- package/payload/server/public/assets/routines-Bu5MdNmG.js.gz +0 -0
- package/payload/server/public/assets/skills-DRunh5vy.js.br +0 -0
- package/payload/server/public/assets/skills-DRunh5vy.js.gz +0 -0
- package/payload/server/public/assets/tasks-DI2fznvd.js.br +0 -0
- package/payload/server/public/assets/tasks-DI2fznvd.js.gz +0 -0
- package/payload/server/public/assets/triangle-alert-B6CHZeUf.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-B6CHZeUf.js.gz +0 -0
- package/payload/server/public/assets/useCopyFeedback-6rU2IEPk.js.br +0 -2
- package/payload/server/public/assets/useCopyFeedback-6rU2IEPk.js.gz +0 -0
- package/payload/server/public/assets/useMediaQuery-D7A5Bzs3.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-CptrerVA.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-CptrerVA.js.gz +0 -0
- package/payload/server/public/assets/wrench-DyX4C8aY.js.br +0 -0
- package/payload/server/public/assets/wrench-DyX4C8aY.js.gz +0 -0
- /package/payload/server/public/assets/{jsx-runtime-B2Q1UOSJ.js → jsx-runtime-UK6hgBWO.js} +0 -0
- /package/payload/server/public/assets/{jsx-runtime-B2Q1UOSJ.js.br → jsx-runtime-UK6hgBWO.js.br} +0 -0
- /package/payload/server/public/assets/{jsx-runtime-B2Q1UOSJ.js.gz → jsx-runtime-UK6hgBWO.js.gz} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e,t}from"./chunk-BycB0eMI.js";import{i as n,n as r,t as i}from"./jsx-runtime-B2Q1UOSJ.js";import{F as a,G as o,L as s,M as c,O as l,V as u,Y as d,Z as f,_ as p,it as m,j as h,k as g,m as _,p as v,v as y}from"./useMediaQuery-D7A5Bzs3.js";import{A as b,m as x,t as S}from"./AdminShell-D8WTrqem.js";import{t as C}from"./clock-4YwsYe4L.js";import{t as w}from"./triangle-alert-B6CHZeUf.js";import{t as ee}from"./wrench-DyX4C8aY.js";import{r as T}from"./file-download-B7zwa78w.js";var te=f(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),ne=f(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),E=f(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),D=r(),O=e(n(),1),k=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function A(e,t){if(e===`*`)return{kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1};let n=e.match(/^(\*|\d+-\d+)\/(\d+)$/);if(n){let e=Number(n[2]);if(e<1)return null;if(n[1]===`*`)return{kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:e};let[r,i]=n[1].split(`-`).map(Number);return r>t||i>t||r>i?null:{kind:`step`,value:0,rangeStart:r,rangeEnd:i,step:e}}let r=e.match(/^(\d+)-(\d+)$/);if(r){let e=Number(r[1]),n=Number(r[2]);return e>t||n>t||e>n?null:{kind:`step`,value:0,rangeStart:e,rangeEnd:n,step:1}}if(/^\d+$/.test(e)){let n=Number(e);return n>t?null:{kind:`fixed`,value:n,rangeStart:null,rangeEnd:null,step:1}}return null}function j(e){return String(e).padStart(2,`0`)}function M(e){if(e===`*`)return null;let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);return e>7||n>7||e>n?`invalid`:`${k[e%7]} to ${k[n%7]}`}let n=e.split(`,`);return n.length>0&&n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?n.map(e=>k[Number(e)%7]).join(`, `):`invalid`}function N(e){let t=e.trim().split(/\s+/);if(t.length!==5)return e;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i)||i!==`*`&&(Number(i)<1||Number(i)>31))return e;let s=A(n,59),c=A(r,23);if(!s||!c)return e;let l=M(o);if(l===`invalid`||s.kind===`step`&&s.rangeStart!==null||(s.kind===`any`&&(s={kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:1}),c.kind===`step`&&c.step===1&&c.rangeStart===null&&(c={kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1}),i!==`*`&&!(s.kind===`fixed`&&c.kind===`fixed`&&o===`*`))||s.kind===`step`&&c.kind===`step`&&c.step>1)return e;let u=l?`, ${l}`:``,d=e=>e.rangeStart+Math.floor((e.rangeEnd-e.rangeStart)/e.step)*e.step;if(s.kind===`step`){let e=s.step===1?`Every minute`:`Every ${s.step} minutes`;return c.kind===`any`?`${e}${u}`:c.kind===`fixed`?`${e}, ${j(c.value)}:00 to ${j(c.value)}:59${u}`:`${e}, ${j(c.rangeStart)}:00 to ${j(d(c))}:00${u}`}if(c.kind===`step`){let e=j(s.value),t=s.value===0?``:` at :${e}`;return c.rangeStart===null?`Every ${c.step} hours${t}${u}`:c.step===1?`Hourly, ${j(c.rangeStart)}:${e} to ${j(c.rangeEnd)}:${e}${u}`:`Every ${c.step} hours, ${j(c.rangeStart)}:${e} to ${j(d(c))}:${e}${u}`}if(c.kind===`any`)return`${s.value===0?`Every hour`:`Every hour at :${j(s.value)}`}${u}`;let f=`${j(c.value)}:${j(s.value)}`;return i===`*`?l?`${l} at ${f}`:`Daily at ${f}`:`Monthly on day ${Number(i)} at ${f}`}var P={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function F(e){let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);if(e>7||n>7||e>n)return null;let r=[];for(let t=e;t<=n;t+=1)r.push(t%7);return[...new Set(r)].sort((e,t)=>e-t)}let n=e.split(`,`);return n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?[...new Set(n.map(e=>Number(e)%7))].sort((e,t)=>e-t):null}function I(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i))return null;let s=A(n,59),c=A(r,23);if(!s||!c||s.kind===`step`&&s.rangeStart!==null)return null;let l=`every`,u=[],d=1;if(i!==`*`){if(o!==`*`)return null;let e=Number(i);if(e<1||e>31||s.kind!==`fixed`||c.kind!==`fixed`)return null;l=`dayOfMonth`,d=e}else if(o!==`*`){let e=F(o);if(e===null)return null;l=`weekdays`,u=e}let f={dayMode:l,weekdays:u,dayOfMonth:d};if(s.kind===`any`||s.kind===`step`){if(c.kind===`step`&&c.step>1)return null;let e=s.kind===`any`?1:s.step,t=c.kind===`any`?null:c.kind===`fixed`?{start:c.value,end:c.value}:{start:c.rangeStart,end:c.rangeEnd};return{...P,...f,timeMode:`everyMinutes`,minute:0,interval:e,window:t}}return c.kind===`fixed`?{...P,...f,timeMode:`at`,minute:s.value,hour:c.value}:c.kind===`any`?{...P,...f,timeMode:`everyHours`,minute:s.value,interval:1,window:null}:{...P,...f,timeMode:`everyHours`,minute:s.value,interval:c.step,window:c.rangeStart===null?null:{start:c.rangeStart,end:c.rangeEnd}}}function L(e){return e.dayMode===`dayOfMonth`?[String(e.dayOfMonth),`*`]:e.dayMode===`weekdays`&&e.weekdays.length>0?[`*`,[...e.weekdays].sort((e,t)=>e-t).join(`,`)]:[`*`,`*`]}function R(e){let[t,n]=L(e);if(e.timeMode===`everyMinutes`){let r=e.window===null?`*`:e.window.start===e.window.end?String(e.window.start):`${e.window.start}-${e.window.end}`;return`*/${e.interval} ${r} ${t} * ${n}`}if(e.timeMode===`everyHours`){let r=e.window===null?e.interval===1?`*`:`*/${e.interval}`:e.interval===1?`${e.window.start}-${e.window.end}`:`${e.window.start}-${e.window.end}/${e.interval}`;return`${e.minute} ${r} ${t} * ${n}`}return`${e.minute} ${e.hour} ${t} * ${n}`}var z={scheduled:`live`,suspended:`stood-down`,due:`inert`,cancelled:`inert`,completed:`inert`};function B(e){return e==null||!Object.hasOwn(z,e)?`unknown`:z[e]}var V={scheduled:{control:`suspend`,note:null},suspended:{control:`resume`,note:null},due:{control:`none`,note:`This one-time routine has already been dispatched. It will not run again.`},cancelled:{control:`none`,note:`This routine was cancelled and cannot be restarted. Delete it, or create a new one.`},completed:{control:`none`,note:`This routine has finished and will not run again.`}},H={control:`none`,note:`This routine's status is not one this dashboard recognises, so no start or stop is offered.`};function re(e){return e==null||!Object.hasOwn(V,e)?H:V[e]}var U={finished:`live`,gated:`live`,started:`in-flight`,accepted:`in-flight`,open:`in-flight`,failed:`error`,"no-destination":`warning`};function ie(e){return e==null||!Object.hasOwn(U,e)?`unknown`:U[e]}function W(e){return e===`gated`?`skipped: no work`:e??`unknown`}var G=i(),ae=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}],K=Array.from({length:24},(e,t)=>t),q=e=>String(e).padStart(2,`0`),J={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function oe({recurrence:e,onChange:t,disabled:n}){let r=e?I(e):J,[i,a]=(0,O.useState)(r??J),[o]=(0,O.useState)(e!=null&&r==null),[s,c]=(0,O.useState)(e??``);if((0,O.useEffect)(()=>{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`routines`,op:`schedule-editor`,mode:o?`raw`:`builder`}),keepalive:!0}).catch(()=>{})},[o]),o)return(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Schedule (advanced)`}),(0,G.jsx)(`input`,{type:`text`,className:`routine-raw-cron`,value:s,disabled:n,onChange:e=>{c(e.target.value),t(e.target.value)},"aria-label":`Cron expression`}),(0,G.jsx)(`span`,{className:`routine-raw-note`,children:`This routine uses an advanced schedule, edited as a raw cron expression.`})]});let l=e=>{a(e),t(R(e))},u=e=>{let t=e!==`at`&&i.dayMode===`dayOfMonth`?`every`:i.dayMode;l({...i,timeMode:e,dayMode:t})},d=e=>{let t=e===`weekdays`&&i.weekdays.length===0?[1]:i.weekdays;l({...i,dayMode:e,weekdays:t})},f=e=>{let[t,n]=e.split(`:`);l({...i,hour:Number(t)||0,minute:Number(n)||0})},p=e=>{let t=i.weekdays.includes(e);if(t&&i.weekdays.length===1)return;let n=t?i.weekdays.filter(t=>t!==e):[...i.weekdays,e];l({...i,weekdays:n})},m=e=>l({...i,window:e?{start:0,end:23}:null}),h=(e,t)=>{let n={...i.window??{start:0,end:23},[e]:Number(t)};n.start>n.end&&(e===`start`?n.end=n.start:n.start=n.end),l({...i,window:n})},g=(e,t,n)=>Math.min(n,Math.max(t,Number(e)||t));return(0,G.jsxs)(`div`,{className:`routine-sched`,children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`How often`}),(0,G.jsxs)(`select`,{"aria-label":`How often`,value:i.timeMode,disabled:n,onChange:e=>u(e.target.value),children:[(0,G.jsx)(`option`,{value:`at`,children:`At a time of day`}),(0,G.jsx)(`option`,{value:`everyMinutes`,children:`Every few minutes`}),(0,G.jsx)(`option`,{value:`everyHours`,children:`Every few hours`})]})]}),i.timeMode===`at`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Time of day`}),(0,G.jsx)(`input`,{type:`time`,"aria-label":`Time of day`,value:`${q(i.hour)}:${q(i.minute)}`,disabled:n,onChange:e=>f(e.target.value)})]}),i.timeMode===`everyMinutes`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Minutes between runs`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:59,"aria-label":`Minutes between runs`,value:i.interval,disabled:n,onChange:e=>l({...i,interval:g(e.target.value,1,59)})})]}),i.timeMode===`everyHours`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Hours between runs`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:23,"aria-label":`Hours between runs`,value:i.interval,disabled:n,onChange:e=>l({...i,interval:g(e.target.value,1,23)})})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Minute of the hour`}),(0,G.jsx)(`input`,{type:`number`,min:0,max:59,"aria-label":`Minute of the hour`,value:i.minute,disabled:n,onChange:e=>l({...i,minute:g(e.target.value,0,59)})})]})]}),i.timeMode!==`at`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`cal-modal-field routine-sched-check`,children:[(0,G.jsx)(`input`,{type:`checkbox`,"aria-label":`Only between certain hours`,checked:i.window!==null,disabled:n,onChange:e=>m(e.target.checked)}),(0,G.jsx)(`span`,{children:`Only between certain hours`})]}),i.window!==null&&(0,G.jsxs)(`div`,{className:`routine-sched-row`,children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`From hour`}),(0,G.jsx)(`select`,{"aria-label":`From hour`,value:i.window.start,disabled:n,onChange:e=>h(`start`,e.target.value),children:K.map(e=>(0,G.jsxs)(`option`,{value:e,children:[q(e),`:00`]},e))})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`To hour`}),(0,G.jsx)(`select`,{"aria-label":`To hour`,value:i.window.end,disabled:n,onChange:e=>h(`end`,e.target.value),children:K.map(e=>(0,G.jsxs)(`option`,{value:e,children:[q(e),`:00`]},e))})]})]})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Which days`}),(0,G.jsxs)(`select`,{"aria-label":`Which days`,value:i.dayMode,disabled:n,onChange:e=>d(e.target.value),children:[(0,G.jsx)(`option`,{value:`every`,children:`Every day`}),(0,G.jsx)(`option`,{value:`weekdays`,children:`Specific days`}),i.timeMode===`at`&&(0,G.jsx)(`option`,{value:`dayOfMonth`,children:`A day of the month`})]})]}),i.dayMode===`weekdays`&&(0,G.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Days`}),(0,G.jsx)(`div`,{className:`routine-weekdays`,children:ae.map(e=>(0,G.jsx)(`button`,{type:`button`,className:`routine-weekday${i.weekdays.includes(e.value)?` routine-weekday-on`:``}`,"aria-pressed":i.weekdays.includes(e.value),disabled:n,onClick:()=>p(e.value),children:e.label},e.value))})]}),i.dayMode===`dayOfMonth`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Day of month`}),(0,G.jsx)(`select`,{"aria-label":`Day of month`,value:i.dayOfMonth,disabled:n,onChange:e=>l({...i,dayOfMonth:Number(e.target.value)||1}),children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]})]})}function Y(e){let t=e.trim().replace(/[\s\-().]/g,``).replace(/^\+/,``);return/^\d{11,15}$/.test(t)?`+${t.slice(0,2)} ${t.slice(2,6)} ${t.slice(6)}`:e}function se(e){if(e.name)return`${e.name} · ${e.label}`;let t=e.channel===`whatsapp`?Y(e.destination):e.destination;return`${e.label} · ${t}`}function ce({eventStatus:e}){let t=B(e);return(0,G.jsx)(`span`,{className:`routine-status-dot is-${t}`,"data-state":t,"aria-hidden":`true`})}function le(e){return e.agentChannel==null?e.actionPlugin==null?`trigger`:`deterministic`:e.gateTool==null?`agent-every-fire`:`checked-agent`}var ue={"checked-agent":`checks first, model only when there is work`,"agent-every-fire":`model every fire`,deterministic:`runs a tool, no model`,trigger:null};function de(e){return e.agentChannel&&e.agentDestination&&e.agentPrompt?`model`:e.actionPlugin&&e.actionTool?`tool`:`none`}function fe(e){let t=e.filter(e=>e.eventStatus===`scheduled`&&e.recurrence!=null),n={live:t.length,model:0,tool:0,none:0};for(let e of t)n[de(e)]++;return n}function pe(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}let n=t?.checks;return Array.isArray(n)?n.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return typeof t.type==`string`?[{kind:t.type,target:X(t.type,t)}]:[]}):[]}function X(e,t){let n=e=>typeof t[e]==`string`?t[e]:null;if(e===`mail`){let e=n(`mailbox`);if(e===null)return null;let t=n(`folder`);return t?`${e}/${t}`:e}return e===`d1`?n(`database`):e===`whatsapp`?n(`scope`):e===`calendar`?n(`connector`):null}function me(e,t){if(!e)return null;let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=Math.max(t-n,0);return r<6e4?`${Math.round(r/1e3)}s ago`:r<36e5?`${Math.round(r/6e4)}m ago`:`${Math.round(r/36e5)}h ago`}function he(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function ge(e){return e?e.split(`
|
|
1
|
+
import{o as e,t}from"./chunk-BycB0eMI.js";import{i as n,n as r,t as i}from"./jsx-runtime-UK6hgBWO.js";import{F as a,G as o,L as s,M as c,O as l,V as u,Y as d,Z as f,_ as p,it as m,j as h,k as g,m as _,p as v,v as y}from"./useMediaQuery-CqwktQr_.js";import{A as b,m as x,t as S}from"./AdminShell-B-iX9ahJ.js";import{t as C}from"./clock-DxPtyejC.js";import{t as w}from"./triangle-alert-BzCjDFts.js";import{t as ee}from"./wrench-B2WKLLQG.js";import{r as T}from"./file-download-B7zwa78w.js";var te=f(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),ne=f(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),E=f(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),D=r(),O=e(n(),1),k=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function A(e,t){if(e===`*`)return{kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1};let n=e.match(/^(\*|\d+-\d+)\/(\d+)$/);if(n){let e=Number(n[2]);if(e<1)return null;if(n[1]===`*`)return{kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:e};let[r,i]=n[1].split(`-`).map(Number);return r>t||i>t||r>i?null:{kind:`step`,value:0,rangeStart:r,rangeEnd:i,step:e}}let r=e.match(/^(\d+)-(\d+)$/);if(r){let e=Number(r[1]),n=Number(r[2]);return e>t||n>t||e>n?null:{kind:`step`,value:0,rangeStart:e,rangeEnd:n,step:1}}if(/^\d+$/.test(e)){let n=Number(e);return n>t?null:{kind:`fixed`,value:n,rangeStart:null,rangeEnd:null,step:1}}return null}function j(e){return String(e).padStart(2,`0`)}function M(e){if(e===`*`)return null;let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);return e>7||n>7||e>n?`invalid`:`${k[e%7]} to ${k[n%7]}`}let n=e.split(`,`);return n.length>0&&n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?n.map(e=>k[Number(e)%7]).join(`, `):`invalid`}function N(e){let t=e.trim().split(/\s+/);if(t.length!==5)return e;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i)||i!==`*`&&(Number(i)<1||Number(i)>31))return e;let s=A(n,59),c=A(r,23);if(!s||!c)return e;let l=M(o);if(l===`invalid`||s.kind===`step`&&s.rangeStart!==null||(s.kind===`any`&&(s={kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:1}),c.kind===`step`&&c.step===1&&c.rangeStart===null&&(c={kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1}),i!==`*`&&!(s.kind===`fixed`&&c.kind===`fixed`&&o===`*`))||s.kind===`step`&&c.kind===`step`&&c.step>1)return e;let u=l?`, ${l}`:``,d=e=>e.rangeStart+Math.floor((e.rangeEnd-e.rangeStart)/e.step)*e.step;if(s.kind===`step`){let e=s.step===1?`Every minute`:`Every ${s.step} minutes`;return c.kind===`any`?`${e}${u}`:c.kind===`fixed`?`${e}, ${j(c.value)}:00 to ${j(c.value)}:59${u}`:`${e}, ${j(c.rangeStart)}:00 to ${j(d(c))}:00${u}`}if(c.kind===`step`){let e=j(s.value),t=s.value===0?``:` at :${e}`;return c.rangeStart===null?`Every ${c.step} hours${t}${u}`:c.step===1?`Hourly, ${j(c.rangeStart)}:${e} to ${j(c.rangeEnd)}:${e}${u}`:`Every ${c.step} hours, ${j(c.rangeStart)}:${e} to ${j(d(c))}:${e}${u}`}if(c.kind===`any`)return`${s.value===0?`Every hour`:`Every hour at :${j(s.value)}`}${u}`;let f=`${j(c.value)}:${j(s.value)}`;return i===`*`?l?`${l} at ${f}`:`Daily at ${f}`:`Monthly on day ${Number(i)} at ${f}`}var P={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function F(e){let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);if(e>7||n>7||e>n)return null;let r=[];for(let t=e;t<=n;t+=1)r.push(t%7);return[...new Set(r)].sort((e,t)=>e-t)}let n=e.split(`,`);return n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?[...new Set(n.map(e=>Number(e)%7))].sort((e,t)=>e-t):null}function I(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i))return null;let s=A(n,59),c=A(r,23);if(!s||!c||s.kind===`step`&&s.rangeStart!==null)return null;let l=`every`,u=[],d=1;if(i!==`*`){if(o!==`*`)return null;let e=Number(i);if(e<1||e>31||s.kind!==`fixed`||c.kind!==`fixed`)return null;l=`dayOfMonth`,d=e}else if(o!==`*`){let e=F(o);if(e===null)return null;l=`weekdays`,u=e}let f={dayMode:l,weekdays:u,dayOfMonth:d};if(s.kind===`any`||s.kind===`step`){if(c.kind===`step`&&c.step>1)return null;let e=s.kind===`any`?1:s.step,t=c.kind===`any`?null:c.kind===`fixed`?{start:c.value,end:c.value}:{start:c.rangeStart,end:c.rangeEnd};return{...P,...f,timeMode:`everyMinutes`,minute:0,interval:e,window:t}}return c.kind===`fixed`?{...P,...f,timeMode:`at`,minute:s.value,hour:c.value}:c.kind===`any`?{...P,...f,timeMode:`everyHours`,minute:s.value,interval:1,window:null}:{...P,...f,timeMode:`everyHours`,minute:s.value,interval:c.step,window:c.rangeStart===null?null:{start:c.rangeStart,end:c.rangeEnd}}}function L(e){return e.dayMode===`dayOfMonth`?[String(e.dayOfMonth),`*`]:e.dayMode===`weekdays`&&e.weekdays.length>0?[`*`,[...e.weekdays].sort((e,t)=>e-t).join(`,`)]:[`*`,`*`]}function R(e){let[t,n]=L(e);if(e.timeMode===`everyMinutes`){let r=e.window===null?`*`:e.window.start===e.window.end?String(e.window.start):`${e.window.start}-${e.window.end}`;return`*/${e.interval} ${r} ${t} * ${n}`}if(e.timeMode===`everyHours`){let r=e.window===null?e.interval===1?`*`:`*/${e.interval}`:e.interval===1?`${e.window.start}-${e.window.end}`:`${e.window.start}-${e.window.end}/${e.interval}`;return`${e.minute} ${r} ${t} * ${n}`}return`${e.minute} ${e.hour} ${t} * ${n}`}var z={scheduled:`live`,suspended:`stood-down`,due:`inert`,cancelled:`inert`,completed:`inert`};function B(e){return e==null||!Object.hasOwn(z,e)?`unknown`:z[e]}var V={scheduled:{control:`suspend`,note:null},suspended:{control:`resume`,note:null},due:{control:`none`,note:`This one-time routine has already been dispatched. It will not run again.`},cancelled:{control:`none`,note:`This routine was cancelled and cannot be restarted. Delete it, or create a new one.`},completed:{control:`none`,note:`This routine has finished and will not run again.`}},H={control:`none`,note:`This routine's status is not one this dashboard recognises, so no start or stop is offered.`};function re(e){return e==null||!Object.hasOwn(V,e)?H:V[e]}var U={finished:`live`,gated:`live`,started:`in-flight`,accepted:`in-flight`,open:`in-flight`,failed:`error`,"no-destination":`warning`};function ie(e){return e==null||!Object.hasOwn(U,e)?`unknown`:U[e]}function W(e){return e===`gated`?`skipped: no work`:e??`unknown`}var G=i(),ae=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}],K=Array.from({length:24},(e,t)=>t),q=e=>String(e).padStart(2,`0`),J={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function oe({recurrence:e,onChange:t,disabled:n}){let r=e?I(e):J,[i,a]=(0,O.useState)(r??J),[o]=(0,O.useState)(e!=null&&r==null),[s,c]=(0,O.useState)(e??``);if((0,O.useEffect)(()=>{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`routines`,op:`schedule-editor`,mode:o?`raw`:`builder`}),keepalive:!0}).catch(()=>{})},[o]),o)return(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Schedule (advanced)`}),(0,G.jsx)(`input`,{type:`text`,className:`routine-raw-cron`,value:s,disabled:n,onChange:e=>{c(e.target.value),t(e.target.value)},"aria-label":`Cron expression`}),(0,G.jsx)(`span`,{className:`routine-raw-note`,children:`This routine uses an advanced schedule, edited as a raw cron expression.`})]});let l=e=>{a(e),t(R(e))},u=e=>{let t=e!==`at`&&i.dayMode===`dayOfMonth`?`every`:i.dayMode;l({...i,timeMode:e,dayMode:t})},d=e=>{let t=e===`weekdays`&&i.weekdays.length===0?[1]:i.weekdays;l({...i,dayMode:e,weekdays:t})},f=e=>{let[t,n]=e.split(`:`);l({...i,hour:Number(t)||0,minute:Number(n)||0})},p=e=>{let t=i.weekdays.includes(e);if(t&&i.weekdays.length===1)return;let n=t?i.weekdays.filter(t=>t!==e):[...i.weekdays,e];l({...i,weekdays:n})},m=e=>l({...i,window:e?{start:0,end:23}:null}),h=(e,t)=>{let n={...i.window??{start:0,end:23},[e]:Number(t)};n.start>n.end&&(e===`start`?n.end=n.start:n.start=n.end),l({...i,window:n})},g=(e,t,n)=>Math.min(n,Math.max(t,Number(e)||t));return(0,G.jsxs)(`div`,{className:`routine-sched`,children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`How often`}),(0,G.jsxs)(`select`,{"aria-label":`How often`,value:i.timeMode,disabled:n,onChange:e=>u(e.target.value),children:[(0,G.jsx)(`option`,{value:`at`,children:`At a time of day`}),(0,G.jsx)(`option`,{value:`everyMinutes`,children:`Every few minutes`}),(0,G.jsx)(`option`,{value:`everyHours`,children:`Every few hours`})]})]}),i.timeMode===`at`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Time of day`}),(0,G.jsx)(`input`,{type:`time`,"aria-label":`Time of day`,value:`${q(i.hour)}:${q(i.minute)}`,disabled:n,onChange:e=>f(e.target.value)})]}),i.timeMode===`everyMinutes`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Minutes between runs`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:59,"aria-label":`Minutes between runs`,value:i.interval,disabled:n,onChange:e=>l({...i,interval:g(e.target.value,1,59)})})]}),i.timeMode===`everyHours`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Hours between runs`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:23,"aria-label":`Hours between runs`,value:i.interval,disabled:n,onChange:e=>l({...i,interval:g(e.target.value,1,23)})})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Minute of the hour`}),(0,G.jsx)(`input`,{type:`number`,min:0,max:59,"aria-label":`Minute of the hour`,value:i.minute,disabled:n,onChange:e=>l({...i,minute:g(e.target.value,0,59)})})]})]}),i.timeMode!==`at`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`cal-modal-field routine-sched-check`,children:[(0,G.jsx)(`input`,{type:`checkbox`,"aria-label":`Only between certain hours`,checked:i.window!==null,disabled:n,onChange:e=>m(e.target.checked)}),(0,G.jsx)(`span`,{children:`Only between certain hours`})]}),i.window!==null&&(0,G.jsxs)(`div`,{className:`routine-sched-row`,children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`From hour`}),(0,G.jsx)(`select`,{"aria-label":`From hour`,value:i.window.start,disabled:n,onChange:e=>h(`start`,e.target.value),children:K.map(e=>(0,G.jsxs)(`option`,{value:e,children:[q(e),`:00`]},e))})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`To hour`}),(0,G.jsx)(`select`,{"aria-label":`To hour`,value:i.window.end,disabled:n,onChange:e=>h(`end`,e.target.value),children:K.map(e=>(0,G.jsxs)(`option`,{value:e,children:[q(e),`:00`]},e))})]})]})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Which days`}),(0,G.jsxs)(`select`,{"aria-label":`Which days`,value:i.dayMode,disabled:n,onChange:e=>d(e.target.value),children:[(0,G.jsx)(`option`,{value:`every`,children:`Every day`}),(0,G.jsx)(`option`,{value:`weekdays`,children:`Specific days`}),i.timeMode===`at`&&(0,G.jsx)(`option`,{value:`dayOfMonth`,children:`A day of the month`})]})]}),i.dayMode===`weekdays`&&(0,G.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Days`}),(0,G.jsx)(`div`,{className:`routine-weekdays`,children:ae.map(e=>(0,G.jsx)(`button`,{type:`button`,className:`routine-weekday${i.weekdays.includes(e.value)?` routine-weekday-on`:``}`,"aria-pressed":i.weekdays.includes(e.value),disabled:n,onClick:()=>p(e.value),children:e.label},e.value))})]}),i.dayMode===`dayOfMonth`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Day of month`}),(0,G.jsx)(`select`,{"aria-label":`Day of month`,value:i.dayOfMonth,disabled:n,onChange:e=>l({...i,dayOfMonth:Number(e.target.value)||1}),children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]})]})}function Y(e){let t=e.trim().replace(/[\s\-().]/g,``).replace(/^\+/,``);return/^\d{11,15}$/.test(t)?`+${t.slice(0,2)} ${t.slice(2,6)} ${t.slice(6)}`:e}function se(e){if(e.name)return`${e.name} · ${e.label}`;let t=e.channel===`whatsapp`?Y(e.destination):e.destination;return`${e.label} · ${t}`}function ce({eventStatus:e}){let t=B(e);return(0,G.jsx)(`span`,{className:`routine-status-dot is-${t}`,"data-state":t,"aria-hidden":`true`})}function le(e){return e.agentChannel==null?e.actionPlugin==null?`trigger`:`deterministic`:e.gateTool==null?`agent-every-fire`:`checked-agent`}var ue={"checked-agent":`checks first, model only when there is work`,"agent-every-fire":`model every fire`,deterministic:`runs a tool, no model`,trigger:null};function de(e){return e.agentChannel&&e.agentDestination&&e.agentPrompt?`model`:e.actionPlugin&&e.actionTool?`tool`:`none`}function fe(e){let t=e.filter(e=>e.eventStatus===`scheduled`&&e.recurrence!=null),n={live:t.length,model:0,tool:0,none:0};for(let e of t)n[de(e)]++;return n}function pe(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}let n=t?.checks;return Array.isArray(n)?n.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return typeof t.type==`string`?[{kind:t.type,target:X(t.type,t)}]:[]}):[]}function X(e,t){let n=e=>typeof t[e]==`string`?t[e]:null;if(e===`mail`){let e=n(`mailbox`);if(e===null)return null;let t=n(`folder`);return t?`${e}/${t}`:e}return e===`d1`?n(`database`):e===`whatsapp`?n(`scope`):e===`calendar`?n(`connector`):null}function me(e,t){if(!e)return null;let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=Math.max(t-n,0);return r<6e4?`${Math.round(r/1e3)}s ago`:r<36e5?`${Math.round(r/6e4)}m ago`:`${Math.round(r/36e5)}h ago`}function he(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function ge(e){return e?e.split(`
|
|
2
2
|
`).filter(e=>e.trim()!==``).reverse():[]}function Z({routine:e,adminFetch:t,onClose:n,onSaved:r,onDeleted:i,onViewRuns:a}){let{zone:o}=y(),[l,d]=(0,O.useState)(!1),[f,p]=(0,O.useState)(!1),[m,g]=(0,O.useState)(null),[b,S]=(0,O.useState)(e),[w,T]=(0,O.useState)(!1),D=b.agentChannel!=null,k=le(b),A=pe(b.gateArgs),j=me(b.gateLastCommitAt,Date.now()),M=re(b.eventStatus),P=M.control===`resume`,[F,I]=(0,O.useState)(!1),[L,R]=(0,O.useState)(e.agentPrompt??``),[z,B]=(0,O.useState)(e.name??``),[V,H]=(0,O.useState)(e.description??``),[U,ie]=(0,O.useState)(e.recurrence),[W,ae]=(0,O.useState)(e.agentChannel??``),[K,q]=(0,O.useState)(e.agentDestination??``),[J,Y]=(0,O.useState)(null),[de,fe]=(0,O.useState)(null),X=D||b.actionPlugin==null,Z=ge(b.notes);(0,O.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!f&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[f,n]),(0,O.useEffect)(()=>{if(!l||!X||J!==null)return;let e=!1;return t(`/api/admin/dispatch-destinations`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(t=>{e||Y(t.destinations)}).catch(t=>{e||(Y([]),fe(t instanceof Error?t.message:`Could not load destinations`))}),()=>{e=!0}},[l,X,J,t]);let Q=(J??[]).filter(e=>e.channel===W),_e=W.length>0&&K.length>0,ve=z.trim().length===0&&(b.name??``).length>0||W.length>0&&K.length===0||_e&&L.trim().length===0,ye=(0,O.useCallback)(()=>{let e={},t=W.length>0&&K.length>0,n=z.trim();n!==(b.name??``)&&(e.name=n),(D||t)&&L!==(b.agentPrompt??``)&&(e.agentPrompt=L);let r=V.trim().length>0?V:null;return r!==(b.description??null)&&(e.description=r),U!=null&&U!==(b.recurrence??null)&&(e.recurrence=U),t&&(W!==(b.agentChannel??``)||K!==(b.agentDestination??``))?(e.agentChannel=W,e.agentDestination=K):!t&&W===``&&(b.agentChannel??``)!==``&&(e.agentChannel=null,e.agentDestination=null),e},[D,z,L,V,U,W,K,b]),be=(0,O.useCallback)(async()=>{let n=ye();if(Object.keys(n).length===0){d(!1);return}p(!0),g(null);try{let i=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();S(a.routine),B(a.routine.name??``),R(a.routine.agentPrompt??``),H(a.routine.description??``),ie(a.routine.recurrence),ae(a.routine.agentChannel??``),q(a.routine.agentDestination??``),r(a.routine),d(!1)}catch(e){g(e instanceof Error?e.message:`Save failed`)}finally{p(!1)}},[t,ye,e.eventId,r]),xe=(0,O.useCallback)(async()=>{if(f)return;if(!F){T(!1),I(!0);return}let n=P?`resume`:`suspend`;p(!0),g(null);try{let i=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}/${n}`,{method:`POST`});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();S(a.routine),r(a.routine),I(!1)}catch(e){g(e instanceof Error?e.message:`${n} failed`),I(!1)}finally{p(!1)}},[t,f,F,P,e.eventId,r]),Se=(0,O.useCallback)(async()=>{if(!f){if(!w){I(!1),T(!0);return}p(!0),g(null);try{let n=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`DELETE`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}i(e.eventId)}catch(e){g(e instanceof Error?e.message:`Delete failed`),T(!1)}finally{p(!1)}}},[t,f,w,e.eventId,i]);return(0,G.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{f||n()},children:(0,G.jsxs)(`div`,{className:`cal-modal ${!l||D||_e?`cal-modal-wide`:`cal-modal-dispatch`}`,role:`dialog`,"aria-modal":`true`,"aria-label":l?`Edit routine`:`Routine detail`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,G.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,G.jsx)(x,{size:13}),` Routine`]}),(0,G.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,disabled:f,children:(0,G.jsx)(h,{size:16})})]}),!l&&(0,G.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,G.jsx)(`div`,{className:`cal-modal-title`,children:b.name??`Untitled routine`}),(0,G.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,G.jsx)(C,{size:14}),(0,G.jsx)(`span`,{children:b.recurrence?N(b.recurrence):`One-time`})]}),(0,G.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,G.jsx)(ce,{eventStatus:b.eventStatus}),(0,G.jsxs)(`span`,{children:[`Status: `,b.eventStatus??`unknown`]})]}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Next run: `,he(b.nextRun,o)]})}),(0,G.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,G.jsx)(E,{size:14}),(0,G.jsxs)(`span`,{children:[`Last run: `,he(b.lastTriggered,o),b.lastDispatchResult?` (${b.lastDispatchResult})`:``]})]}),b.description&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsx)(`span`,{children:`Description`})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,G.jsx)(`span`,{children:b.description})})]}),ue[k]&&(0,G.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`routine-mode`,children:[(0,G.jsx)(x,{size:14}),(0,G.jsxs)(`span`,{children:[ue[k],k===`agent-every-fire`&&b.gateWaived?`: ${b.gateWaived}`:``]})]}),b.gateClassified===!1&&b.gateTool==null&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`gate-unclassified`,children:(0,G.jsx)(`span`,{children:`No check is set and no reason is recorded, so every fire spends a model turn.`})}),D?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,G.jsx)(_,{channel:b.agentChannel,size:14}),(0,G.jsxs)(`span`,{children:[v[b.agentChannel]??b.agentChannel,` to `,b.agentDestination??`—`]})]}),b.gateTool!=null&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsx)(`span`,{children:`Checks before the agent runs`})}),(0,G.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,G.jsx)(ee,{size:14}),(0,G.jsxs)(`span`,{children:[b.gatePlugin,`.`,b.gateTool]})]}),A.map((e,t)=>(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`gate-check`,children:(0,G.jsxs)(`span`,{children:[e.kind,e.target?` · ${e.target}`:``]})},t)),b.lastTriggered!=null&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`gate-commit-age`,children:(0,G.jsx)(`span`,{children:j===null?`This gate has never committed, so it reports work on every fire.`:`Checks last committed ${j} (${he(b.gateLastCommitAt,o)})`})})]}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsx)(`span`,{children:`Instruction sent to the agent`})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,G.jsx)(`span`,{children:b.agentPrompt??`No instruction sent to the agent.`})})]}):b.actionPlugin?(0,G.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,G.jsx)(ee,{size:14}),(0,G.jsxs)(`span`,{children:[b.actionPlugin,`.`,b.actionTool,b.actionArgs?` ${b.actionArgs}`:``]})]}):(0,G.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,G.jsx)(C,{size:14}),(0,G.jsx)(`span`,{children:`Scheduled trigger (no dispatch)`})]}),Z.length===0?(0,G.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,G.jsx)(E,{size:14}),(0,G.jsx)(`span`,{children:`No history recorded.`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,G.jsx)(E,{size:14}),(0,G.jsxs)(`span`,{children:[`History (`,Z.length,` `,Z.length===1?`entry`:`entries`,`)`]})]}),(0,G.jsx)(`div`,{className:`routine-history`,children:Z.map((e,t)=>(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:e},t))})]})]}),l&&(0,G.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Name`}),(0,G.jsx)(`input`,{type:`text`,value:z,onChange:e=>B(e.target.value),disabled:f,maxLength:200,placeholder:`The routine's title, shown on the card`})]}),X&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Send to`}),(0,G.jsxs)(`div`,{className:`cal-modal-field-inline`,children:[(0,G.jsxs)(`select`,{value:W,disabled:f,onChange:e=>{ae(e.target.value),q(``)},children:[(0,G.jsx)(`option`,{value:``,children:`None (no dispatch)`}),(0,G.jsx)(`option`,{value:`whatsapp`,children:`WhatsApp`}),(0,G.jsx)(`option`,{value:`telegram`,children:`Telegram`})]}),W!==``&&(0,G.jsx)(_,{channel:W,size:16})]})]}),W!==``&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Destination`}),(0,G.jsxs)(`select`,{value:K,disabled:f||J===null,onChange:e=>q(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:J===null?`Loading destinations`:Q.length===0?`No registered destinations`:`Choose a destination`}),K!==``&&!Q.some(e=>e.destination===K)&&(0,G.jsxs)(`option`,{value:K,children:[K,` (not in the current list)`]}),Q.map(e=>(0,G.jsx)(`option`,{value:e.destination,children:se(e)},e.destination))]})]}),de&&(0,G.jsxs)(`div`,{className:`cal-modal-error`,children:[`Could not load destinations: `,de]})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Description`}),(0,G.jsx)(`input`,{type:`text`,value:V,onChange:e=>H(e.target.value),disabled:f,placeholder:`One line: what this routine is for`})]}),(D||_e)&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Instruction sent to the agent`}),(0,G.jsx)(`textarea`,{className:`cal-modal-textarea`,value:L,onChange:e=>R(e.target.value),disabled:f,rows:16,placeholder:`What should the agent do when this routine fires?`})]}),(0,G.jsx)(oe,{recurrence:b.recurrence,onChange:ie,disabled:f})]}),m&&(0,G.jsx)(`div`,{className:`cal-modal-error`,children:m}),(0,G.jsxs)(`div`,{className:`cal-modal-actions`,children:[!l&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{T(!1),I(!1),d(!0)},disabled:f,children:[(0,G.jsx)(s,{size:14}),` Edit`]}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>a(b),disabled:f,children:[(0,G.jsx)(E,{size:14}),` Runs`]}),M.control===`none`?(0,G.jsx)(`span`,{className:`cal-modal-confirm-text`,children:M.note}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:xe,disabled:f,children:[f&&F?(0,G.jsx)(u,{size:14,className:`spin`}):P?(0,G.jsx)(ne,{size:14}):(0,G.jsx)(te,{size:14}),F?P?`Confirm resume`:`Confirm suspend`:P?`Resume`:`Suspend`]}),F&&(0,G.jsx)(`span`,{className:`cal-modal-confirm-text`,children:P?`This routine will run at its next scheduled time. It will not run for the times it missed.`:`This routine stops running until you resume it. Nothing is deleted.`})]}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:Se,disabled:f,children:[f&&w?(0,G.jsx)(u,{size:14,className:`spin`}):(0,G.jsx)(c,{size:14}),w?`Confirm delete`:`Delete`]})]}),l&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:be,disabled:f||ve,children:[f?(0,G.jsx)(u,{size:14,className:`spin`}):null,` Save`]}),(0,G.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{d(!1),g(null)},disabled:f,children:`Cancel`})]})]})]})})}function Q(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function _e(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function ve({run:e,routineName:t,onClose:n}){let{zone:r}=y();return(0,O.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,G.jsx)(`div`,{className:`cal-modal-overlay`,onClick:n,children:(0,G.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Run detail`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,G.jsx)(`span`,{className:`cal-modal-kind`,children:`Run`}),(0,G.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,children:(0,G.jsx)(h,{size:16})})]}),(0,G.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,G.jsx)(`div`,{className:`cal-modal-title`,children:t??`Untitled routine`}),e.outputExcerpt!==null&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,"data-testid":`run-output`,children:(0,G.jsx)(`span`,{children:e.outputExcerpt})}),e.outputExcerpt===null&&e.status===`finished`&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`run-output-none`,children:(0,G.jsx)(`span`,{children:`This run finished without sending anything.`})}),(0,G.jsx)(`div`,{className:`cal-modal-row`,children:(0,G.jsx)(`span`,{children:W(e.status)})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Due: `,Q(e.scheduledFor,r)]})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Started: `,Q(e.startedAt,r)]})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Dispatch ended: `,Q(e.endedAt,r),` (`,_e(e.ranMs),`)`]})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Output seen: `,Q(e.finishedAt,r)]})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Sent to: `,e.target,` · `,e.mode,` · `,e.kind]})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Transport: `,e.dispatchResult??`—`,e.httpStatus===null?``:` (HTTP ${e.httpStatus})`]})}),e.error&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,G.jsx)(`span`,{children:e.error})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Conversation: `,e.sessionKey??`—`,e.transcriptOffset===null?``:` at byte ${e.transcriptOffset}`]})}),!e.bounded&&e.status!==`gated`&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsx)(`span`,{children:`This run shares its conversation with other traffic, so what it produced cannot be separated out. Its status stays at whatever the dispatch reported.`})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Run `,e.runId]})})]})]})})}function ye({status:e}){let t=ie(e);return(0,G.jsx)(`span`,{className:`routine-status-dot is-${t}`,"data-state":t,"aria-hidden":`true`})}var be=500;function xe(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function Se(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}var Ce={channel:`a channel`,destination:`a destination`,prompt:`an instruction`};function we(e){if(e===`no-dispatch-configured`)return`This routine has no dispatch set up, so there was nothing to do.`;if(e===`no-action-plugin`)return`The tool action names no plugin, so nothing ran.`;if(e===`no-action-tool`)return`The tool action names no tool, so nothing ran.`;let t=e.startsWith(`no-`)?e.slice(3).split(`+`):[];if(t.length>0&&t.every(e=>e in Ce)){let e=t.map(e=>Ce[e]);return`This routine has no ${(e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`).replace(/^an? /,``)} set, so nothing was sent.`}return e}function Te(e){return e.status===`no-destination`?e.error?we(e.error):`Nothing was dispatched, and no reason was recorded.`:e.status===`failed`?e.error??e.dispatchResult??`The dispatch failed.`:e.status===`open`?`Opened and never closed. The dispatch did not report back.`:null}function Ee(e){let t=e.indexOf(`:`);return t<=0?{channel:null,destination:e}:{channel:e.slice(0,t),destination:e.slice(t+1)}}function De(e){return e.outputExcerpt===null?e.status===`finished`?`Finished and sent nothing.`:null:e.outputExcerpt}function Oe({routine:e,adminFetch:t,cacheKey:n,from:r=`card`,onBack:i}){let{zone:s}=y(),[c,l]=(0,O.useState)([]),[f,p]=(0,O.useState)(!0),[m,h]=(0,O.useState)(null),[g,b]=(0,O.useState)(null),x=(0,O.useRef)(0),S=(0,O.useCallback)(()=>{let n=!1,i=++x.current,a=()=>n||i!==x.current;return p(!0),h(null),t(`/api/admin/routines/${encodeURIComponent(e.eventId)}/runs?limit=${be}&from=${r}`).then(async e=>{if(a())return;if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();a()||l(Array.isArray(t.runs)?t.runs:[])}).catch(e=>{a()||(h(e instanceof Error?e.message:`Failed to load`),l([]))}).finally(()=>{a()||p(!1)}),()=>{n=!0}},[t,e.eventId,r]);(0,O.useEffect)(()=>S(),[S]);let C=(0,O.useCallback)(()=>{T(n,e.eventId)},[n,e.eventId]);return(0,G.jsxs)(`div`,{className:`cal-page`,children:[(0,G.jsx)(`header`,{className:`cal-header`,children:(0,G.jsxs)(`div`,{className:`cal-nav`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:i,children:[(0,G.jsx)(d,{size:14}),` Routines`]}),(0,G.jsx)(`span`,{className:`cal-range-label runs-title`,"data-testid":`runs-title`,title:e.name??`Untitled routine`,children:e.name??`Untitled routine`}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,"data-testid":`runs-refresh`,onClick:S,disabled:f,title:`Refresh runs`,"aria-label":`Refresh runs`,children:[f?(0,G.jsx)(u,{size:14,className:`spin`}):(0,G.jsx)(a,{size:14}),` Refresh`]}),c.length>0&&(0,G.jsx)(`div`,{className:`routine-bulk-actions`,children:(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:C,children:[(0,G.jsx)(o,{size:14}),` Download all runs`]})})]})}),(0,G.jsxs)(`div`,{className:`cal-body`,children:[m&&(0,G.jsxs)(`div`,{className:`cal-error`,children:[`Could not load runs: `,m]}),!m&&!f&&c.length===0&&(0,G.jsxs)(`div`,{className:`cal-empty`,"data-testid":`runs-empty`,children:[(0,G.jsx)(`p`,{children:`Nothing to show for this routine.`}),(0,G.jsx)(`p`,{children:`That means one of three things, and this page cannot tell them apart: it has never run, it ran but no record was written, or every run it did have is older than the 30 days records are kept for.`}),(0,G.jsxs)(`p`,{children:[`For a repeating routine, the server log settles the middle one: a`,(0,G.jsx)(`code`,{children:` fires-without-records `}),` count above zero names a routine that fired and left no record. It does not distinguish the other two, and it does not cover a one-time routine.`]})]}),c.length>=be&&(0,G.jsxs)(`div`,{className:`cal-modal-confirm-text`,"data-testid":`runs-capped`,children:[`Showing the most recent `,be,` runs. There may be more; the download has everything still on record.`]}),(0,G.jsx)(`div`,{className:`routine-list`,children:c.map(e=>{let t=Te(e),n=De(e),{channel:r,destination:i}=Ee(e.target);return(0,G.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,"data-testid":`run-row-${e.runId}`,onClick:()=>b(e),children:[(0,G.jsxs)(`span`,{className:`admin-card-title routine-card-title run-card-title`,children:[(0,G.jsx)(ye,{status:e.status}),` `,W(e.status)]}),(0,G.jsx)(`span`,{className:`routine-card-sched`,children:Se(e.ranMs)}),(0,G.jsx)(`span`,{className:`routine-card-target`,children:r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_,{channel:r,size:13}),` `,v[r]??r,` to `,r===`whatsapp`?Y(i):i]}):i}),(0,G.jsxs)(`span`,{className:`routine-card-meta`,children:[`Due `,xe(e.scheduledFor,s)]}),n&&(0,G.jsx)(`span`,{className:`routine-card-meta run-card-output`,children:n}),t&&(0,G.jsx)(`span`,{className:`routine-card-meta run-card-detail`,children:t})]},e.runId)})})]}),g&&(0,G.jsx)(ve,{run:g,routineName:e.name,onClose:()=>b(null)})]})}var ke=500;function Ae(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function je(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function Me({adminFetch:e,onBack:t}){let{zone:n}=y(),[r,i]=(0,O.useState)([]),[o,s]=(0,O.useState)(!0),[c,l]=(0,O.useState)(null),[f,p]=(0,O.useState)(null),m=(0,O.useRef)(0),h=(0,O.useCallback)(()=>{let t=!1,n=++m.current,r=()=>t||n!==m.current;return s(!0),l(null),e(`/api/admin/routines/runs?limit=${ke}`).then(async e=>{if(r())return;if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();r()||i(Array.isArray(t.runs)?t.runs:[])}).catch(e=>{r()||(l(e instanceof Error?e.message:`Failed to load`),i([]))}).finally(()=>{r()||s(!1)}),()=>{t=!0}},[e]);return(0,O.useEffect)(()=>h(),[h]),(0,G.jsxs)(`div`,{className:`cal-page`,children:[(0,G.jsx)(`header`,{className:`cal-header`,children:(0,G.jsxs)(`div`,{className:`cal-nav`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:t,children:[(0,G.jsx)(d,{size:14}),` Routines`]}),(0,G.jsx)(`span`,{className:`cal-range-label runs-title`,"data-testid":`all-runs-title`,children:`All routine runs`}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,"data-testid":`all-runs-refresh`,onClick:h,disabled:o,title:`Refresh runs`,"aria-label":`Refresh runs`,children:[o?(0,G.jsx)(u,{size:14,className:`spin`}):(0,G.jsx)(a,{size:14}),` Refresh`]})]})}),(0,G.jsxs)(`div`,{className:`cal-body`,children:[c&&(0,G.jsxs)(`div`,{className:`cal-error`,children:[`Could not load runs: `,c]}),!c&&!o&&r.length===0&&(0,G.jsx)(`div`,{className:`cal-empty`,"data-testid":`all-runs-empty`,children:(0,G.jsx)(`p`,{children:`No routine has run yet.`})}),r.length>=ke&&(0,G.jsxs)(`div`,{className:`cal-modal-confirm-text`,"data-testid":`all-runs-capped`,children:[`Showing the most recent `,ke,` runs. There may be more on record.`]}),(0,G.jsx)(`div`,{className:`routine-list`,children:r.map(e=>{let t=Te(e),r=De(e),{channel:i,destination:a}=Ee(e.target);return(0,G.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,"data-testid":`all-run-row-${e.runId}`,onClick:()=>p(e),children:[(0,G.jsxs)(`span`,{className:`admin-card-title routine-card-title run-card-title`,children:[(0,G.jsx)(ye,{status:e.status}),` `,e.eventName]}),(0,G.jsxs)(`span`,{className:`routine-card-sched`,children:[W(e.status),` · `,je(e.ranMs)]}),(0,G.jsx)(`span`,{className:`routine-card-target`,children:i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_,{channel:i,size:13}),` `,v[i]??i,` to `,i===`whatsapp`?Y(a):a]}):a}),(0,G.jsxs)(`span`,{className:`routine-card-meta`,children:[`Due `,Ae(e.scheduledFor,n)]}),r&&(0,G.jsx)(`span`,{className:`routine-card-meta run-card-output`,children:r}),t&&(0,G.jsx)(`span`,{className:`routine-card-meta run-card-detail`,children:t})]},e.runId)})})]}),f&&(0,G.jsx)(ve,{run:f,routineName:f.eventName,onClose:()=>p(null)})]})}t(((e,t)=>{t.exports={}}))();function Ne(e){return e.agentChannel&&e.agentDestination&&e.agentPrompt?!0:!!(e.actionPlugin&&e.actionTool)}function Pe(e){if(e.agentChannel||e.agentDestination||e.agentPrompt){let t=[];return e.agentChannel||t.push(`channel`),e.agentDestination||t.push(`destination`),e.agentPrompt||t.push(`prompt`),`no-${t.join(`+`)}`}return e.actionPlugin||e.actionTool?e.actionTool?`no-action-plugin`:`no-action-tool`:`no-dispatch-configured`}var $=`maxy-admin-session-key`;function Fe(e){return e?N(e):`One-time`}function Ie(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function Le(){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,u]=(0,O.useState)(void 0),[d,f]=(0,O.useState)(null),[p,m]=(0,O.useState)(null);(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),m(e.role??null),u(e.userName===void 0?null:e.userName),f(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let h=(0,O.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[_,v]=(0,O.useState)(!1),y=(0,O.useCallback)(async()=>{v(!0);try{let e=await b();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{v(!1)}},[]);return n?e?(0,G.jsx)(g,{cacheKey:e,surface:`routines`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=routines`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,G.jsx)(S,{cacheKey:e,businessName:i,sessionId:o,onLogout:h,onDisconnect:y,disconnecting:_,userName:c,userAvatar:d,role:p,children:(0,G.jsx)(Re,{cacheKey:e})})}):(0,G.jsx)(`div`,{className:`cal-page`,children:(0,G.jsxs)(`div`,{className:`cal-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:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,G.jsx)(l,{surface:`gate`})}function Re({cacheKey:e}){let{zone:t}=y(),{adminFetch:n,cacheKey:r,sessionRefetchNonce:i}=m({initialCacheKey:e,surface:`routines`}),[o,s]=(0,O.useState)([]),[c,d]=(0,O.useState)(null),[f,p]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1),[b,S]=(0,O.useState)(null),[T,D]=(0,O.useState)(null),[k,A]=(0,O.useState)(null),[j,M]=(0,O.useState)(!1),N=(0,O.useCallback)(()=>{let e=!1;return p(!0),S(null),n(`/api/admin/routines`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();s(Array.isArray(n.routines)?n.routines:[]),d(typeof n.workflowRuns24h==`number`?n.workflowRuns24h:null)}).catch(t=>{e||(S(t instanceof Error?t.message:`Failed to load`),s([]),d(null))}).finally(()=>{e||(p(!1),g(!0))}),()=>{e=!0}},[n]);(0,O.useEffect)(()=>N(),[N,i]);let P=(0,O.useCallback)(e=>{s(t=>t.map(t=>t.eventId===e.eventId?e:t)),D(e)},[]),F=(0,O.useCallback)(e=>{s(t=>t.filter(t=>t.eventId!==e)),D(null)},[]),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(null),B=o.filter(e=>e.eventStatus===`scheduled`).length,V=o.filter(e=>e.suspendedInBulk).length,H=(0,O.useCallback)(async e=>{L(!0),z(null);try{let t=await n(`/api/admin/routines/${e}`,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}let r=await t.json(),i=r.refused?.length??0;z(e===`suspend-all`?`Suspended ${r.suspended??0}. Nothing runs on its own until you resume it.`:`Resumed ${r.restored??0}${i>0?`. ${i} could not be resumed and stayed suspended`:``}. Routines you suspended one at a time are still suspended.`),N()}catch(e){z(e instanceof Error?e.message:`Failed`)}finally{L(!1)}},[n,N]);return h?j?(0,G.jsx)(Me,{adminFetch:n,onBack:()=>M(!1)}):k?(0,G.jsx)(Oe,{routine:k,adminFetch:n,cacheKey:r,from:`modal`,onBack:()=>A(null)}):(0,G.jsxs)(`div`,{className:`cal-page`,children:[(0,G.jsx)(`header`,{className:`cal-header`,children:(0,G.jsxs)(`div`,{className:`cal-nav`,children:[(0,G.jsxs)(`span`,{className:`cal-range-label`,children:[(0,G.jsx)(x,{size:16}),` Routines`]}),(0,G.jsxs)(`div`,{className:`routine-bulk-actions`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,"data-testid":`routines-refresh`,onClick:N,disabled:f,title:`Refresh routines`,"aria-label":`Refresh routines`,children:[f?(0,G.jsx)(u,{size:14,className:`spin`}):(0,G.jsx)(a,{size:14}),` Refresh`]}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,"data-testid":`routines-history`,onClick:()=>M(!0),title:`All routine runs`,"aria-label":`All routine runs`,children:[(0,G.jsx)(E,{size:14}),` History`]}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>H(`suspend-all`),disabled:I||B===0,children:[(0,G.jsx)(te,{size:14}),` Suspend all (`,B,`)`]}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>H(`resume-all`),disabled:I||V===0,children:[(0,G.jsx)(ne,{size:14}),` Resume all (`,V,`)`]})]})]})}),(0,G.jsxs)(`div`,{className:`cal-body`,children:[!b&&(()=>{let e=fe(o);return(0,G.jsxs)(`div`,{className:`routine-rail-strip`,"data-testid":`routine-rail-strip`,children:[`Live recurring: `,e.live,` · `,e.model,` model · `,e.tool,` tool · `,e.none,` no dispatch`,` · `,`Workflow runs (24h): `,c===null?`—`:c]})})(),R&&(0,G.jsx)(`div`,{className:`cal-modal-confirm-text`,children:R}),b&&(0,G.jsxs)(`div`,{className:`cal-error`,children:[`Could not load routines: `,b]}),!b&&!f&&o.length===0&&(0,G.jsx)(`div`,{className:`cal-empty`,children:(0,G.jsx)(`p`,{children:`No routines yet.`})}),(0,G.jsx)(`div`,{className:`routine-list`,children:o.map(e=>{let n=e.eventStatus===`scheduled`&&!Ne(e)?Pe(e):null;return(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:`admin-card admin-card--padded routine-card`,"data-testid":`routine-card-${e.eventId}`,onClick:()=>D(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),D(e))},children:[(0,G.jsx)(`span`,{className:`admin-card-title routine-card-title`,title:e.name??`Untitled routine`,children:e.name??`Untitled routine`}),(0,G.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,G.jsx)(C,{size:13}),` `,Fe(e.recurrence)]}),e.description&&(0,G.jsx)(`span`,{className:`routine-card-desc`,children:e.description}),n===null?(0,G.jsx)(`span`,{className:`routine-card-target`,children:e.agentChannel?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_,{channel:e.agentChannel,size:13}),` `,v[e.agentChannel]??e.agentChannel,` to `,e.agentDestination??`—`]}):e.actionPlugin?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ee,{size:13}),` `,e.actionPlugin,`.`,e.actionTool]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(C,{size:13}),` Scheduled trigger`]})}):(0,G.jsxs)(`span`,{className:`routine-card-target routine-card-target--gap`,children:[(0,G.jsx)(w,{size:13}),` `,we(n)]}),e.dispatchFailing===!0&&n===null&&(0,G.jsxs)(`span`,{className:`routine-card-target routine-card-target--gap`,"data-testid":`routine-dispatch-${e.eventId}`,children:[(0,G.jsx)(w,{size:13}),` Last dispatch failed: `,e.lastDispatchResult]}),(()=>{let t=[],n=ue[le(e)];n&&t.push(n),e.runs24h>0&&t.push(`24h: ${e.runs24h} ${e.runs24h===1?`fire`:`fires`}, ${e.gated24h} skipped`);let r=e.gateNeverGates===!0&&e.dispatchFailing!==!0;return r&&t.push(`this gate is decoration`),t.length===0?null:(0,G.jsx)(`span`,{className:r?`routine-card-gate routine-card-target--gap`:`routine-card-gate`,"data-testid":`routine-gate-${e.eventId}`,children:r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(w,{size:13}),` `,t.join(` · `)]}):t.join(` · `)})})(),(0,G.jsxs)(`span`,{className:`routine-card-meta`,children:[(0,G.jsx)(ce,{eventStatus:e.eventStatus}),`Next: `,Ie(e.nextRun,t),` · `,e.eventStatus??`unknown`]})]},e.eventId)})})]}),T&&(0,G.jsx)(Z,{routine:T,adminFetch:n,onClose:()=>D(null),onSaved:P,onDeleted:F,onViewRuns:e=>{D(null),A(e)}})]}):(0,G.jsx)(l,{surface:`gate`})}(0,D.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(Le,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-BycB0eMI.js";import{i as t,n,t as r}from"./jsx-runtime-
|
|
1
|
+
import{o as e}from"./chunk-BycB0eMI.js";import{i as t,n,t as r}from"./jsx-runtime-UK6hgBWO.js";import{M as i,O as a,U as o,V as s,it as c,j as l,k as u}from"./useMediaQuery-CqwktQr_.js";import{A as d,h as f,t as p}from"./AdminShell-B-iX9ahJ.js";import{t as m}from"./file-text-BddO_2EI.js";var h=n(),g=e(t(),1),_=r();function v({summary:e,adminFetch:t,onClose:n,onDeleted:r}){let[a,c]=(0,g.useState)(null),[u,d]=(0,g.useState)(!0),[p,h]=(0,g.useState)(null),[v,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let n=!1;return d(!0),h(null),t(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`).then(async e=>{if(!n){if(!e.ok)throw Error(`HTTP ${e.status}`);c((await e.json()).skill)}}).catch(e=>{n||h(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{n||d(!1)}),()=>{n=!0}},[t,e.plugin,e.skill]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!b&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,n]);let S=(0,g.useCallback)(async()=>{x(!0),h(null);try{let n=await t(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`,{method:`DELETE`,headers:{"content-type":`application/json`}});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}r(e)}catch(e){h(e instanceof Error?e.message:`Delete failed`),x(!1),y(!1)}},[t,e,r]);return(0,_.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{b||n()},children:(0,_.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Skill detail`,onClick:e=>e.stopPropagation(),children:[(0,_.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,_.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,_.jsx)(f,{size:13}),` Skill`]}),(0,_.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,disabled:b,children:(0,_.jsx)(l,{size:16})})]}),(0,_.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,_.jsx)(`div`,{className:`cal-modal-title`,children:e.skill}),(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(m,{size:14}),(0,_.jsx)(`span`,{children:e.plugin})]}),u&&(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(s,{size:14,className:`spin`}),(0,_.jsx)(`span`,{children:`Loading…`})]}),a&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,_.jsx)(`span`,{children:a.frontmatter.description||`No description.`})}),a.frontmatter.publicEmbed&&(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(o,{size:14}),(0,_.jsx)(`span`,{children:`Public embed`})]}),(0,_.jsx)(`pre`,{className:`skill-body`,children:a.body.trim()||`No body content.`}),a.references.length>0&&(0,_.jsxs)(`div`,{className:`skill-refs`,children:[(0,_.jsx)(`span`,{className:`skill-refs-label`,children:`References`}),a.references.map(e=>(0,_.jsxs)(`span`,{className:`skill-ref`,children:[(0,_.jsx)(m,{size:13}),` `,e]},e))]})]})]}),p&&(0,_.jsx)(`div`,{className:`cal-modal-error`,children:p}),(0,_.jsxs)(`div`,{className:`cal-modal-actions`,children:[!v&&(0,_.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>y(!0),disabled:b||u,children:[(0,_.jsx)(i,{size:14}),` Delete`]}),v&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this skill?`}),(0,_.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:S,disabled:b,children:[b?(0,_.jsx)(s,{size:14,className:`spin`}):(0,_.jsx)(i,{size:14}),` Delete`]}),(0,_.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>y(!1),disabled:b,children:`Cancel`})]})]})]})})}var y=`maxy-admin-session-key`;function b(){let[e,t]=(0,g.useState)(null),[n,r]=(0,g.useState)(!1),[i,o]=(0,g.useState)(void 0),[s,c]=(0,g.useState)(null),[l,f]=(0,g.useState)(void 0),[m,h]=(0,g.useState)(null),[v,b]=(0,g.useState)(null);(0,g.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(y)}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(y)}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&&c(e.sessionId??null),b(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 S=(0,g.useCallback)(()=>{try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`},[]),[C,w]=(0,g.useState)(!1),T=(0,g.useCallback)(async()=>{w(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return n?e?(0,_.jsx)(u,{cacheKey:e,surface:`skills`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=skills`);try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`},children:(0,_.jsx)(p,{cacheKey:e,businessName:i,sessionId:s,onLogout:S,onDisconnect:T,disconnecting:C,userName:l,userAvatar:m,role:v,children:(0,_.jsx)(x,{cacheKey:e})})}):(0,_.jsx)(`div`,{className:`cal-page`,children:(0,_.jsxs)(`div`,{className:`cal-empty`,children:[(0,_.jsx)(`p`,{children:`You are not signed in.`}),(0,_.jsxs)(`p`,{children:[`Open the `,(0,_.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,_.jsx)(a,{surface:`gate`})}function x({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=c({initialCacheKey:e,surface:`skills`}),[r,i]=(0,g.useState)([]),[o,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(!1),[p,h]=(0,g.useState)(null),[y,b]=(0,g.useState)(null),x=(0,g.useCallback)(()=>{let e=!1;return l(!0),h(null),t(`/api/admin/skills`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();i(Array.isArray(n.skills)?n.skills:[])}).catch(t=>{e||(h(t instanceof Error?t.message:`Failed to load`),i([]))}).finally(()=>{e||(l(!1),d(!0))}),()=>{e=!0}},[t]);(0,g.useEffect)(()=>x(),[x,n]);let S=(0,g.useCallback)(e=>{i(t=>t.filter(t=>!(t.plugin===e.plugin&&t.skill===e.skill))),b(null),x()},[x]);return u?(0,_.jsxs)(`div`,{className:`cal-page`,children:[(0,_.jsx)(`header`,{className:`cal-header`,children:(0,_.jsxs)(`div`,{className:`cal-nav`,children:[(0,_.jsxs)(`span`,{className:`cal-range-label`,children:[(0,_.jsx)(f,{size:16}),` Skills`]}),o&&(0,_.jsx)(s,{size:16,className:`spin`})]})}),(0,_.jsxs)(`div`,{className:`cal-body`,children:[p&&(0,_.jsxs)(`div`,{className:`cal-error`,children:[`Could not load skills: `,p]}),!p&&!o&&r.length===0&&(0,_.jsx)(`div`,{className:`cal-empty`,children:(0,_.jsx)(`p`,{children:`No skills yet. Ask in chat to create one.`})}),r.length>0&&(0,_.jsx)(`div`,{className:`routine-list`,children:r.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,onClick:()=>b(e),children:[(0,_.jsx)(`span`,{className:`admin-card-title routine-card-title`,children:e.skill}),(0,_.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,_.jsx)(m,{size:13}),` `,e.plugin]}),(0,_.jsx)(`span`,{className:`skill-card-desc`,children:e.description||`No description.`}),(0,_.jsx)(`span`,{className:`routine-card-meta`,children:e.refCount===0?`No references`:`${e.refCount} reference${e.refCount===1?``:`s`}`})]},`${e.plugin}/${e.skill}`))})]}),y&&(0,_.jsx)(v,{summary:y,adminFetch:t,onClose:()=>b(null),onDeleted:S})]}):(0,_.jsx)(a,{surface:`gate`})}(0,h.createRoot)(document.getElementById(`root`)).render((0,_.jsx)(b,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{o as e}from"./chunk-BycB0eMI.js";import{i as t,n,t as r}from"./jsx-runtime-
|
|
1
|
+
import{o as e}from"./chunk-BycB0eMI.js";import{i as t,n,t as r}from"./jsx-runtime-UK6hgBWO.js";import{L as i,M as a,N as o,O as s,it as c,j as l,k as u,o as d,q as f}from"./useMediaQuery-CqwktQr_.js";import{A as p,a as m,f as h,n as ee,t as g,v as _}from"./AdminShell-B-iX9ahJ.js";import{t as v}from"./play-BSZVGpQT.js";import{t as y}from"./rotate-ccw-DTOJmOxB.js";var b=n(),x=e(t(),1);function te(e=3e4){let[t,n]=(0,x.useState)(()=>Date.now());return(0,x.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ne(e,t){let n=new Map,r=(e,t,r)=>{let i=n.get(e)??{openCount:0,totalSeconds:0};i.totalSeconds+=t,r&&(i.openCount+=1),n.set(e,i)};for(let t of e)t.clientName&&r(t.clientName,t.secondsLogged,!0);for(let e of t)e.clientName&&r(e.clientName,e.secondsLogged,!1);let i=[...n.entries()].map(([e,t])=>({name:e,openCount:t.openCount,totalSeconds:t.totalSeconds}));return i.sort((e,t)=>t.openCount-e.openCount||e.name.localeCompare(t.name)),S(e,i),i}function S(e,t){let n=t.reduce((e,t)=>e+t.openCount,0),r=e.filter(e=>!e.clientName).length,i=n+r===e.length;return i||console.warn(`[tasks-clients] reconcile-mismatch assigned=${n} unassigned=${r} openTotal=${e.length}`),i}var C=`__unassigned__`;function w(e,t){return e===`__unassigned__`?`Unassigned`:t||e.slice(0,8)}function T(e){return e===null||e===``?C:e}function re(e,t){let n=new Map,r=(e,t)=>{let r=T(e.assigneeUserId),i=n.get(r)??{name:null,openCount:0,totalCount:0};i.name===null&&e.assigneeName&&(i.name=e.assigneeName),i.totalCount+=1,t&&(i.openCount+=1),n.set(r,i)};for(let t of e)r(t,!0);for(let e of t)r(e,!1);let i=[...n.entries()].map(([e,t])=>({userId:e,label:w(e,t.name),openCount:t.openCount,totalCount:t.totalCount}));return i.sort((e,t)=>t.openCount-e.openCount||e.label.localeCompare(t.label)),i}function E(e,t){return t===null?!0:T(e.assigneeUserId)===t}var D=r();function O(e){let t=e.name??e.userId.slice(0,8);return e.kind===`owner`?`${t} (owner)`:t}var k=`maxy-admin-session-key`;function A(e){let t=[];return e.clientName&&t.push(e.clientName),e.propertyAddress&&t.push(e.propertyAddress),e.fee!=null&&t.push(`£${e.fee}`),t.join(` · `)}function j(e){if(!e)return``;let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=new Date(t);return`${n.getUTCDate()} ${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][n.getUTCMonth()]} ${n.getUTCFullYear()}`}function M(e){return e.assigneeName?e.assigneeName:e.assigneeUserId?e.assigneeUserId.slice(0,8):`Unassigned`}function N(e,t){return[t,j(e.createdAt),M(e)].filter(Boolean).join(` · `)}function ie(e,t){if(e.running&&e.runningStartedAt){let n=Date.parse(e.runningStartedAt);if(Number.isFinite(n))return e.secondsLogged+Math.max(0,(t-n)/1e3)}return e.secondsLogged}function ae(e){let t=[`Task: ${e.title}\nTask id: ${e.taskId}`],n=e.description.trim();n.length>0&&t.push(n);let r=e.notes.trim();return r.length>0&&t.push(`Notes:\n${r}`),t.join(`
|
|
2
2
|
|
|
3
3
|
`).slice(0,2e3)}function oe({clients:e,onSelect:t}){return(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Clients`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[e.length,` total`]})]}),e.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`No clients yet.`}),e.map(e=>(0,D.jsx)(`button`,{className:`tasks-row tasks-client-row`,onClick:()=>t(e.name),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsxs)(`div`,{className:`tasks-row-sub`,children:[e.openCount,` open · `,d(e.totalSeconds),` logged`]})]})},e.name))]})}function se({task:e,roster:t,busy:n,onAssign:r,onClose:i}){return(0,x.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,D.jsx)(`div`,{className:`tasks-detail-backdrop`,onClick:i,children:(0,D.jsxs)(`div`,{className:`tasks-detail`,role:`dialog`,"aria-modal":`true`,"aria-label":`Task detail`,onClick:e=>e.stopPropagation(),children:[(0,D.jsxs)(`div`,{className:`tasks-detail-head`,children:[(0,D.jsx)(`h2`,{className:`tasks-detail-title`,children:e?e.name:`Task no longer available`}),(0,D.jsx)(`button`,{className:`tasks-detail-close`,"aria-label":`Close`,onClick:i,children:(0,D.jsx)(l,{size:16})})]}),e===null?(0,D.jsx)(`p`,{className:`tasks-detail-gone`,children:`This task is no longer in the list. It may have been completed, cancelled or removed. Close this and reload to see the current list.`}):(0,D.jsxs)(`dl`,{className:`tasks-detail-fields`,children:[(0,D.jsx)(`dt`,{children:`Status`}),(0,D.jsx)(`dd`,{children:e.status}),(0,D.jsx)(`dt`,{children:`Logged`}),(0,D.jsx)(`dd`,{children:d(e.secondsLogged)}),(0,D.jsx)(`dt`,{children:`Created`}),(0,D.jsx)(`dd`,{children:j(e.createdAt)||`Not recorded`}),(0,D.jsx)(`dt`,{children:`Assignee`}),(0,D.jsx)(`dd`,{children:e.taskId===null?M(e):(0,D.jsxs)(`select`,{className:`tasks-assign-select`,"aria-label":`Assignee`,disabled:n,value:e.assigneeUserId??``,onChange:t=>r(e.taskId,t.target.value===``?null:t.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Unassigned`}),e.assigneeUserId&&!t.some(t=>t.userId===e.assigneeUserId)&&(0,D.jsxs)(`option`,{value:e.assigneeUserId,children:[M(e),` (not in roster)`]}),t.map(e=>(0,D.jsx)(`option`,{value:e.userId,children:O(e)},e.userId))]})}),e.clientName&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Client`}),(0,D.jsx)(`dd`,{children:e.clientName})]}),e.propertyAddress&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Property`}),(0,D.jsx)(`dd`,{children:e.propertyAddress})]}),e.fee!=null&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Fee`}),(0,D.jsxs)(`dd`,{children:[`£`,e.fee]})]})]})]})})}function P({adminFetch:e}){let[t,n]=(0,x.useState)({open:[],completed:[]}),[r,c]=(0,x.useState)(!1),[u,p]=(0,x.useState)(!1),g=(0,x.useRef)(!1),b=(0,x.useRef)(``),S=te(1e3),[C,w]=(0,x.useState)(`open`),[T,O]=(0,x.useState)(null),[k,j]=(0,x.useState)(null),[M,P]=(0,x.useState)(null),[F,I]=(0,x.useState)(``),[L,R]=(0,x.useState)(null),[ce,z]=(0,x.useState)(null),[B,V]=(0,x.useState)(null),H=(0,x.useRef)(new Map),U=(0,x.useRef)(new Set),[le,ue]=(0,x.useState)(new Set),W=(0,x.useMemo)(()=>{if(L!==null)return[...t.open,...t.completed].find(e=>e.rowKey===L)??null},[t,L]),G=(0,x.useMemo)(()=>B===null?null:[...t.open,...t.completed].find(e=>e.rowKey===B)??null,[t,B]);(0,x.useEffect)(()=>{L!==null&&W===null&&console.error(`[tasks-ui] op=detail-failed rowKey=${L} reason=not-in-list`)},[L,W]);let K=(0,x.useMemo)(()=>ne(t.open,t.completed),[t]),q=(0,x.useMemo)(()=>T===null?{open:t.open,completed:t.completed}:{open:t.open.filter(e=>e.clientName===T),completed:t.completed.filter(e=>e.clientName===T)},[t,T]),J=(0,x.useMemo)(()=>re(q.open,q.completed),[q]),de=(0,x.useCallback)(e=>{O(e),w(`open`)},[]);(0,x.useEffect)(()=>{T&&!K.some(e=>e.name===T)&&O(null)},[K,T]),(0,x.useEffect)(()=>{k&&!J.some(e=>e.userId===k)&&j(null)},[J,k]),(0,x.useEffect)(()=>{z(null),V(null)},[C,T,k]);let Y=t.open.filter(e=>e.running||(T===null||e.clientName===T)&&E(e,k)),X=(T?t.completed.filter(e=>e.clientName===T):t.completed).filter(e=>E(e,k)),[fe,pe]=(0,x.useState)([]),Z=(0,x.useCallback)(async()=>{let t=await e(`/api/admin/tasks-list`);t.ok&&n(await t.json()),c(!0)},[e]);(0,x.useEffect)(()=>{Z()},[Z]),(0,x.useEffect)(()=>{(async()=>{let t=await e(`/api/admin/admin-users-list`);if(t.ok){let e=await t.json();e.ok&&Array.isArray(e.users)&&pe(e.users)}})()},[e]);let Q=(0,x.useCallback)(async(t,n,r)=>{if(g.current)return!1;g.current=!0,p(!0);try{return await e(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:n,...r})}),await Z(),!0}finally{g.current=!1,p(!1)}},[e,Z]),me=(0,x.useCallback)(async e=>{await Q(`/api/admin/task-complete`,e)},[Q]),he=(0,x.useCallback)(async e=>{await Q(`/api/admin/task-delete`,e,{confirmed:!0})},[Q]),ge=(0,x.useCallback)((e,t)=>{let n=String(Math.round(e.secondsLogged/60));b.current=n,P(t),I(n)},[]),$=(0,x.useCallback)(()=>{P(null),I(``)},[]),_e=(0,x.useCallback)(async e=>{let t=F.trim(),n=Number(t);if(!(t===``||!Number.isInteger(n)||n<0)){if(t===b.current){$();return}P(null),I(``),await Q(`/api/admin/task-time-adjust`,e,{newSeconds:n*60})}},[F,Q,$]),ve=(0,x.useCallback)(e=>{Q(`/api/admin/task-time-adjust`,e,{newSeconds:0})},[Q]),ye=(0,x.useCallback)((e,t)=>{Q(`/api/admin/task-assign`,e,{assigneeUserId:t})},[Q]),be=(0,x.useCallback)(async t=>{if(!U.current.has(t)){U.current.add(t),ue(new Set(U.current));try{let n=await e(`/api/admin/task-session-open`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:t})});if(!n.ok){console.error(`[admin-ui] task-session op=open-failed taskId=${t} status=${n.status}`);return}let{sessionId:r,title:i,description:a,notes:o}=await n.json();if(r!==null){let e=`/chat?session=${r}`;window.location.assign(e);return}let s=ae({title:i,taskId:t,description:a??``,notes:o??``}),c=await e(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:i,initialMessage:s})}),l=await c.json().catch(()=>({})),u=ee(c.ok,c.status,l),d=l.sessionId??null;if(u.kind!==`navigate`){console.error(`[admin-ui] task-session op=spawn-failed taskId=${t} reason=${u.reason}`);return}if(d!==null){let n=await e(`/api/admin/task-session-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:t,sessionId:d})});n.ok&&(await n.json().catch(()=>({}))).linked}else console.error(`[admin-ui] task-session op=link-skipped taskId=${t} reason=no-landed-session-id`);window.location.assign(u.url)}catch(e){console.error(`[admin-ui] task-session op=failed taskId=${t} error=${e instanceof Error?e.message:String(e)}`)}finally{U.current.delete(t),ue(new Set(U.current))}}},[e]);if(!r)return(0,D.jsx)(s,{surface:`gate`});let xe=e=>e.taskId!==null&&M===e.taskId,Se=e=>(0,D.jsxs)(`div`,{className:`tasks-edit`,children:[(0,D.jsx)(`input`,{className:`tasks-edit-input`,type:`number`,min:0,step:1,"aria-label":`Logged minutes`,value:F,onChange:e=>I(e.target.value)}),(0,D.jsx)(`span`,{className:`tasks-edit-unit`,children:`min`}),(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:u,onClick:()=>void _e(e),children:[(0,D.jsx)(f,{size:14}),` Save`]}),(0,D.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:$,children:[(0,D.jsx)(l,{size:14}),` Cancel`]})]}),Ce=(e,t)=>[{key:`edit-time`,label:`Edit logged time for task: ${e.name}`,menuLabel:`Edit time`,title:e.running?`Stop the timer before editing time`:`Set the logged time for this task`,icon:(0,D.jsx)(i,{size:12}),disabled:u||e.running,onClick:()=>ge(e,t)},{key:`reset-time`,label:`Reset logged time for task: ${e.name}`,menuLabel:`Reset logged time to 0:00`,title:e.running?`Stop the timer before resetting time`:`Set the logged time back to zero`,icon:(0,D.jsx)(y,{size:12}),disabled:u||e.running,onClick:()=>ve(t)},{key:`session`,label:`Open session for task: ${e.name}`,menuLabel:`Session`,title:e.sessionId?`Resume this task’s session`:`Start a session for this task`,icon:(0,D.jsx)(_,{size:12}),disabled:le.has(t),onClick:()=>{be(t)}},{key:`delete`,label:`Delete task: ${e.name}`,menuLabel:`Delete`,title:e.running?`Stop the timer before deleting`:`Delete this task and its time records`,icon:(0,D.jsx)(a,{size:12}),danger:!0,disabled:u||e.running,onClick:()=>V(e.rowKey)}];return(0,D.jsxs)(`div`,{className:`ui-page ui-page--full tasks-body`,children:[L!==null&&(0,D.jsx)(se,{task:W??null,roster:fe,busy:u,onAssign:ye,onClose:()=>R(null)}),(0,D.jsx)(m,{target:G?{name:G.name,secondsLogged:G.secondsLogged}:null,anchorEl:B?H.current.get(B)??null:null,onCancel:()=>V(null),onConfirm:()=>{let e=G;V(null),e?.taskId&&he(e.taskId)}},B??`none`),(0,D.jsxs)(`div`,{className:`tasks-tabs`,children:[(0,D.jsxs)(`button`,{className:`admin-chip ${C===`open`?`is-active`:``}`,onClick:()=>w(`open`),children:[`Open `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:t.open.length})]}),(0,D.jsxs)(`button`,{className:`admin-chip ${C===`completed`?`is-active`:``}`,onClick:()=>w(`completed`),children:[`Completed `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:t.completed.length})]}),(0,D.jsxs)(`button`,{className:`admin-chip ${C===`clients`?`is-active`:``}`,onClick:()=>w(`clients`),children:[`Clients `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:K.length})]})]}),C===`clients`?(0,D.jsx)(oe,{clients:K,onSelect:de}):(0,D.jsxs)(D.Fragment,{children:[T&&(0,D.jsxs)(`div`,{className:`tasks-filter-banner`,children:[(0,D.jsxs)(`span`,{children:[`Showing `,T]}),(0,D.jsx)(`button`,{className:`tasks-filter-clear`,onClick:()=>O(null),children:`Clear`})]}),J.length>0&&(0,D.jsxs)(`div`,{className:`tasks-assignee-bar`,children:[(0,D.jsxs)(`button`,{className:`admin-chip ${k===null?`is-active`:``}`,"aria-pressed":k===null,onClick:()=>j(null),children:[`All `,(0,D.jsx)(`span`,{className:`tasks-assignee-count`,children:q.open.length})]}),J.map(e=>(0,D.jsxs)(`button`,{className:`admin-chip ${k===e.userId?`is-active`:``}`,"aria-pressed":k===e.userId,"aria-label":`Assignee ${e.label}`,title:e.userId===`__unassigned__`?`Tasks with no assigned admin`:`AdminUser ${e.userId}`,onClick:()=>j(k===e.userId?null:e.userId),children:[e.label,` `,(0,D.jsx)(`span`,{className:`tasks-assignee-count`,children:e.openCount})]},e.userId))]}),C===`open`?(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Open tasks`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[Y.length,` to do`]})]}),Y.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`No open tasks.`}),Y.map(e=>(0,D.jsxs)(`div`,{className:`tasks-row`,ref:t=>{t?H.current.set(e.rowKey,t):H.current.delete(e.rowKey)},children:[(0,D.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>R(e.rowKey),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsx)(`div`,{className:`tasks-row-sub`,children:N(e,A(e))})]})}),(0,D.jsx)(`div`,{className:`tasks-row-elapsed ${e.running?`tasks-row-elapsed-running`:``}`,children:d(ie(e,S))}),(0,D.jsx)(`div`,{className:`tasks-row-controls`,children:e.taskId!==null&&ce===e.taskId?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`tasks-confirm-label`,children:`Complete?`}),(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:u,onClick:()=>{z(null),me(e.taskId)},children:[(0,D.jsx)(f,{size:14}),` Confirm complete`]}),(0,D.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:()=>z(null),children:[(0,D.jsx)(l,{size:14}),` Keep open`]})]}):e.taskId===null?(0,D.jsx)(`span`,{className:`tasks-row-broken`,title:`This task has no id, so it cannot be started, edited or completed. Repair it by running platform/scripts/backfill-task-ids.sh on this install.`,children:`Needs repair`}):xe(e)?Se(e.taskId):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(h,{actions:Ce(e,e.taskId),disabled:!1,label:`Task actions`}),(0,D.jsx)(`button`,{className:`tasks-btn-secondary tasks-btn-action tasks-btn-icon`,"aria-label":`Complete task: ${e.name}`,disabled:u||e.running,title:e.running?`Stop the timer before completing`:`Complete task`,onClick:()=>z(e.taskId),children:(0,D.jsx)(f,{size:14})}),e.running?(0,D.jsxs)(`button`,{className:`admin-btn-danger tasks-btn-action`,disabled:u,title:`Stop the timer`,onClick:()=>void Q(`/api/admin/task-timer-stop`,e.taskId),children:[(0,D.jsx)(o,{size:14}),` Stop`]}):(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:u,title:`Start the timer`,onClick:()=>void Q(`/api/admin/task-timer-start`,e.taskId),children:[(0,D.jsx)(v,{size:14}),` Start`]})]})})]},e.rowKey))]}):(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Completed`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[X.length,` done`]})]}),X.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`Nothing completed yet.`}),X.map(e=>(0,D.jsxs)(`div`,{className:`tasks-row tasks-row-done`,ref:t=>{t?H.current.set(e.rowKey,t):H.current.delete(e.rowKey)},children:[(0,D.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>R(e.rowKey),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsx)(`div`,{className:`tasks-row-sub`,children:N(e,A(e))})]})}),(0,D.jsx)(`div`,{className:`tasks-row-elapsed`,children:d(e.secondsLogged)}),(0,D.jsx)(`div`,{className:`tasks-row-controls`,children:e.taskId===null?(0,D.jsx)(`span`,{className:`tasks-row-broken`,title:`This task has no id, so its logged time cannot be edited. Repair it by running platform/scripts/backfill-task-ids.sh on this install.`,children:`Needs repair`}):xe(e)?Se(e.taskId):(0,D.jsx)(h,{actions:Ce(e,e.taskId),disabled:!1,label:`Task actions`})})]},e.rowKey))]})]})]})}function F({cacheKey:e}){let{adminFetch:t}=c({initialCacheKey:e,surface:`tasks`});return(0,D.jsx)(P,{adminFetch:t})}function I(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(void 0),[o,c]=(0,x.useState)(null),[l,d]=(0,x.useState)(null),[f,m]=(0,x.useState)(null),[h,ee]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(k)}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(k)}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),d(e.role??null),m(e.userName===void 0?null:e.userName),ee(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let _=(0,x.useCallback)(()=>{try{sessionStorage.removeItem(k)}catch{}window.location.href=`/`},[]),[v,y]=(0,x.useState)(!1),b=(0,x.useCallback)(async()=>{y(!0);try{let e=await p();if(e){try{sessionStorage.removeItem(k)}catch{}window.location.href=`/`}return e}finally{y(!1)}},[]);return n?e?(0,D.jsx)(u,{cacheKey:e,surface:`tasks`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=tasks`);try{sessionStorage.removeItem(k)}catch{}window.location.href=`/`},children:(0,D.jsx)(g,{cacheKey:e,businessName:i,sessionId:o,onLogout:_,onDisconnect:b,disconnecting:v,userName:f,userAvatar:h,role:l,children:(0,D.jsx)(F,{cacheKey:e})})}):(0,D.jsx)(`div`,{className:`tasks-page`,children:(0,D.jsxs)(`div`,{className:`tasks-empty`,children:[(0,D.jsx)(`p`,{children:`You are not signed in.`}),(0,D.jsxs)(`p`,{children:[`Open the `,(0,D.jsx)(`a`,{href:`/`,className:`tasks-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,D.jsx)(s,{surface:`gate`})}(0,b.createRoot)(document.getElementById(`root`)).render((0,D.jsx)(I,{}));
|
|
Binary file
|
|
Binary file
|
package/payload/server/public/assets/{triangle-alert-B6CHZeUf.js → triangle-alert-BzCjDFts.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Z as e}from"./useMediaQuery-
|
|
1
|
+
import{Z as e}from"./useMediaQuery-CqwktQr_.js";var t=e(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]);export{t};
|
|
Binary file
|
|
Binary file
|
package/payload/server/public/assets/{useCopyFeedback-6rU2IEPk.js → useCopyFeedback-BG7h37Rx.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-BycB0eMI.js";import{i as t}from"./jsx-runtime-
|
|
1
|
+
import{o as e}from"./chunk-BycB0eMI.js";import{i as t}from"./jsx-runtime-UK6hgBWO.js";import{a as n}from"./useMediaQuery-CqwktQr_.js";var r=e(t(),1);function i(e){let[t,i]=(0,r.useState)(`idle`),a=(0,r.useRef)(null),o=(0,r.useRef)(e?.onResult);return o.current=e?.onResult,(0,r.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]),{status:t,copy:(0,r.useCallback)(async e=>{let t=await n(e);i(t?`ok`:`fail`),o.current?.(t),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(`idle`),1500)},[])}}export{i as t};
|
|
Binary file
|