titan-agent 6.5.2 → 7.0.0
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/README.md +180 -53
- package/assets/agent-skills/NOTICE-ECC.md +39 -0
- package/assets/agent-skills/agent-introspection-debugging/SKILL.md +153 -0
- package/assets/agent-skills/continuous-agent-loop/SKILL.md +45 -0
- package/assets/agent-skills/continuous-learning/SKILL.md +131 -0
- package/assets/agent-skills/continuous-learning/config.json +18 -0
- package/assets/agent-skills/continuous-learning/evaluate-session.sh +69 -0
- package/assets/agent-skills/production-audit/SKILL.md +206 -0
- package/assets/agent-skills/recursive-decision-ledger/SKILL.md +79 -0
- package/assets/agent-skills/scientific-thinking-literature-review/SKILL.md +192 -0
- package/assets/agent-skills/scientific-thinking-scholar-evaluation/SKILL.md +160 -0
- package/assets/agent-skills/verification-loop/SKILL.md +126 -0
- package/dist/agent/agent.js +67 -26
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/agentLoop.js +6 -2
- package/dist/agent/agentLoop.js.map +1 -1
- package/dist/agent/autoModeClassifier.js +26 -2
- package/dist/agent/autoModeClassifier.js.map +1 -1
- package/dist/agent/goalDriver.js +2 -0
- package/dist/agent/goalDriver.js.map +1 -1
- package/dist/agent/goalSpec.js +229 -0
- package/dist/agent/goalSpec.js.map +1 -0
- package/dist/agent/heartbeat.js +130 -0
- package/dist/agent/heartbeat.js.map +1 -0
- package/dist/agent/missionDecompose.js +38 -0
- package/dist/agent/missionDecompose.js.map +1 -0
- package/dist/agent/muscleMemory.js +291 -0
- package/dist/agent/muscleMemory.js.map +1 -0
- package/dist/agent/observationWriter.js +56 -0
- package/dist/agent/observationWriter.js.map +1 -0
- package/dist/agent/promptSectionCaps.js +6 -0
- package/dist/agent/promptSectionCaps.js.map +1 -1
- package/dist/agent/reminders.js +101 -0
- package/dist/agent/reminders.js.map +1 -0
- package/dist/agent/systemWidgets.js +41 -0
- package/dist/agent/systemWidgets.js.map +1 -0
- package/dist/agent/toolRunner.js +24 -0
- package/dist/agent/toolRunner.js.map +1 -1
- package/dist/agent/toolSearch.js +3 -0
- package/dist/agent/toolSearch.js.map +1 -1
- package/dist/channels/messenger.js +39 -0
- package/dist/channels/messenger.js.map +1 -1
- package/dist/config/config.js +7 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/schema.js +18 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/eval/harness.js +13 -3
- package/dist/eval/harness.js.map +1 -1
- package/dist/gateway/onboarding.js +91 -0
- package/dist/gateway/onboarding.js.map +1 -0
- package/dist/gateway/routes/skills.js +2 -1
- package/dist/gateway/routes/skills.js.map +1 -1
- package/dist/gateway/routes/studioRouter.js +88 -0
- package/dist/gateway/routes/studioRouter.js.map +1 -0
- package/dist/gateway/routes/watchRouter.js +4 -4
- package/dist/gateway/routes/watchRouter.js.map +1 -1
- package/dist/gateway/server.js +251 -43
- package/dist/gateway/server.js.map +1 -1
- package/dist/memory/taxonomy.js +117 -0
- package/dist/memory/taxonomy.js.map +1 -0
- package/dist/providers/modelCapabilities.js +13 -0
- package/dist/providers/modelCapabilities.js.map +1 -1
- package/dist/providers/ollama.js +8 -2
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openai.js +1 -1
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openai_compat.js +38 -2
- package/dist/providers/openai_compat.js.map +1 -1
- package/dist/providers/router.js +14 -0
- package/dist/providers/router.js.map +1 -1
- package/dist/recipes/runner.js +8 -1
- package/dist/recipes/runner.js.map +1 -1
- package/dist/recipes/store.js +2 -1
- package/dist/recipes/store.js.map +1 -1
- package/dist/skills/builtin/codebase_explore.js +214 -0
- package/dist/skills/builtin/codebase_explore.js.map +1 -0
- package/dist/skills/builtin/config_audit.js +160 -0
- package/dist/skills/builtin/config_audit.js.map +1 -0
- package/dist/skills/builtin/delegate_agent.js +107 -0
- package/dist/skills/builtin/delegate_agent.js.map +1 -0
- package/dist/skills/builtin/memory_map.js +38 -0
- package/dist/skills/builtin/memory_map.js.map +1 -0
- package/dist/skills/builtin/reminders.js +67 -0
- package/dist/skills/builtin/reminders.js.map +1 -0
- package/dist/skills/builtin/spec.js +139 -0
- package/dist/skills/builtin/spec.js.map +1 -0
- package/dist/skills/builtin/widget_gallery.js +12 -5
- package/dist/skills/builtin/widget_gallery.js.map +1 -1
- package/dist/skills/frontmatterLoader.js +7 -1
- package/dist/skills/frontmatterLoader.js.map +1 -1
- package/dist/skills/registry.js +12 -0
- package/dist/skills/registry.js.map +1 -1
- package/dist/substrate/traceBus.js.map +1 -1
- package/dist/telemetry/traceStore.js +127 -0
- package/dist/telemetry/traceStore.js.map +1 -0
- package/dist/utils/constants.js +1 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/contrast.js +69 -0
- package/dist/utils/contrast.js.map +1 -0
- package/dist/watch/sessionContext.js +14 -0
- package/dist/watch/sessionContext.js.map +1 -0
- package/dist/watch/sessionTrace.js +51 -0
- package/dist/watch/sessionTrace.js.map +1 -0
- package/dist/watch/studioBuffer.js +53 -0
- package/dist/watch/studioBuffer.js.map +1 -0
- package/package.json +4 -3
- package/ui/dist/assets/AboutYouMemory-CZKEOd_O.js +11 -0
- package/ui/dist/assets/AuditPanel-Bu71N5Er.js +1 -0
- package/ui/dist/assets/{AutonomyPanel-CmaXJV8d.js → AutonomyPanel-DB-39dX4.js} +2 -2
- package/ui/dist/assets/{AutopilotPanel-CbohPtXW.js → AutopilotPanel-Cj8oKxWv.js} +1 -1
- package/ui/dist/assets/{AutoresearchPanel-DCwiQ2v2.js → AutoresearchPanel-3s8pjm6Z.js} +2 -2
- package/ui/dist/assets/BackupPanel-EUQJMJE7.js +1 -0
- package/ui/dist/assets/{BrowserPanel-D6UaSxap.js → BrowserPanel-Beo4F5Ar.js} +2 -2
- package/ui/dist/assets/Button-MdXmb4_n.js +1 -0
- package/ui/dist/assets/CPActivity-B1Se9VVc.js +1 -0
- package/ui/dist/assets/CPAgentDetail-BYji6tT8.js +1 -0
- package/ui/dist/assets/CPAgents-BSUKucTe.js +1 -0
- package/ui/dist/assets/CPApprovals-B4v0em6e.js +1 -0
- package/ui/dist/assets/CPCosts-9ikh61Kv.js +1 -0
- package/ui/dist/assets/CPDashboard-sOok2T5v.js +1 -0
- package/ui/dist/assets/{CPFiles-BO73EZwJ.js → CPFiles-DB2nY5JE.js} +1 -1
- package/ui/dist/assets/CPGoals-8Z1yOY8e.js +1 -0
- package/ui/dist/assets/CPInbox-Cq6-UY8F.js +11 -0
- package/ui/dist/assets/CPIssueDetail-NAGfmJg8.js +1 -0
- package/ui/dist/assets/CPIssues-BzX6Rckx.js +1 -0
- package/ui/dist/assets/CPLayout-BcRM6QSg.js +2 -0
- package/ui/dist/assets/CPOrg-B7DQ4UQP.js +1 -0
- package/ui/dist/assets/CPRuns-D-cpPw_M.js +1 -0
- package/ui/dist/assets/{CPSocial-Qw5rKy_4.js → CPSocial-DshtmcK0.js} +3 -3
- package/ui/dist/assets/CPVoice-DfXRnQVU.js +1 -0
- package/ui/dist/assets/{ChannelsPanel-DS21E-Iz.js → ChannelsPanel-BnaTOeyf.js} +1 -1
- package/ui/dist/assets/CheckpointsPanel-C62naE4U.js +1 -0
- package/ui/dist/assets/CommandPostHub-B_L1CAss.js +24 -0
- package/ui/dist/assets/ConfirmDialog-VErHWAbo.js +1 -0
- package/ui/dist/assets/CronPanel-BwMrrZ5d.js +1 -0
- package/ui/dist/assets/{DataTable-PnhPeDBG.js → DataTable-BCqSUuN7.js} +1 -1
- package/ui/dist/assets/{DreamPanel-DIrtlk2K.js → DreamPanel-BNAcCLBB.js} +2 -2
- package/ui/dist/assets/EmptyState-D9kQf1PX.js +1 -0
- package/ui/dist/assets/{EvalHarnessPanel-uYb_ZEQG.js → EvalHarnessPanel-BaMLdBNm.js} +2 -2
- package/ui/dist/assets/EvalPanel-CW-SSjtg.js +1 -0
- package/ui/dist/assets/{FileViewer-CVO3TRs3.js → FileViewer-BL00nsd7.js} +1 -1
- package/ui/dist/assets/FilesPanel-CeC6YUSd.js +16 -0
- package/ui/dist/assets/FleetPanel-EyWF7l3W.js +1 -0
- package/ui/dist/assets/{HomelabPanel-BZvN4LPM.js → HomelabPanel-BRfKRYe7.js} +2 -2
- package/ui/dist/assets/InfraView-Jmqhg_Yc.js +2 -0
- package/ui/dist/assets/{InlineEditableField-mBzpbcLB.js → InlineEditableField-DgMrLDj1.js} +1 -1
- package/ui/dist/assets/Input-CBTwa_Iw.js +1 -0
- package/ui/dist/assets/IntegrationsPanel-DQL-7Ec6.js +1 -0
- package/ui/dist/assets/IntelligenceView-DxD78qfP.js +2 -0
- package/ui/dist/assets/LearningPanel-C_JzSbJU.js +1 -0
- package/ui/dist/assets/LiveStudio-Db5yeaWo.js +7 -0
- package/ui/dist/assets/{LogsPanel-DbP3Mwnr.js → LogsPanel-CpinKwaZ.js} +1 -1
- package/ui/dist/assets/McpPanel-D-MqN_f-.js +1 -0
- package/ui/dist/assets/MemoryGraphPanel-BnD5jRqf.js +1 -0
- package/ui/dist/assets/MemoryTaxonomyPanel-BBI202dd.js +6 -0
- package/ui/dist/assets/MemoryWikiPanel-Dn3XZHL0.js +6 -0
- package/ui/dist/assets/{MeshPanel-Bf-4brXL.js → MeshPanel-C-mRJpr0.js} +1 -1
- package/ui/dist/assets/{MissionCanvas-CJyhnauG.js → MissionCanvas-CbZW83Ch.js} +1 -1
- package/ui/dist/assets/{MissionChat-C2Nto3zM.js → MissionChat-Bs75jPAD.js} +1 -1
- package/ui/dist/assets/{MissionLibrary-RXyBHsLL.js → MissionLibrary-BxQ6SxPe.js} +1 -1
- package/ui/dist/assets/MissionStart-CBuBPasl.js +1 -0
- package/ui/dist/assets/Modal-ybPGvlQs.js +9 -0
- package/ui/dist/assets/{NvidiaPanel-4DlcQlyl.js → NvidiaPanel-DdG13OX4.js} +1 -1
- package/ui/dist/assets/OrganismPanel-xZWUJKyr.js +1 -0
- package/ui/dist/assets/OverviewPanel-B45ZYhJV.js +1 -0
- package/ui/dist/assets/{PageHeader-bnc85wQN.js → PageHeader-DdrbS1aq.js} +1 -1
- package/ui/dist/assets/PersonaProfilesPanel-CKER-EU5.js +8 -0
- package/ui/dist/assets/{PersonasPanel-dR8VppcD.js → PersonasPanel-CMMQ3nh3.js} +1 -1
- package/ui/dist/assets/{PhoneDeskPanel-CdVOY7H9.js → PhoneDeskPanel-Bw_Y-cVE.js} +2 -2
- package/ui/dist/assets/RecipesPanel-DzMcxpJJ.js +1 -0
- package/ui/dist/assets/SecurityPanel-BCq3Fzbr.js +1 -0
- package/ui/dist/assets/SelfImprovePanel-YE3hT8jK.js +1 -0
- package/ui/dist/assets/SelfProposalsPanel-DXuqBM6p.js +1 -0
- package/ui/dist/assets/SessionsPanel-DORz5goR.js +1 -0
- package/ui/dist/assets/SessionsTab-qYHDOuC8.js +1 -0
- package/ui/dist/assets/SettingsPanel-BbwPu1i7.js +1 -0
- package/ui/dist/assets/SettingsView-zgqkDDBJ.js +2 -0
- package/ui/dist/assets/{SkeletonLoader-Cax7YTqW.js → SkeletonLoader-r6OGXaU9.js} +1 -1
- package/ui/dist/assets/SkillsPanel-BjEOBMRo.js +11 -0
- package/ui/dist/assets/{SomaView-eG3wI4S1.js → SomaView-DLzApZVW.js} +2 -2
- package/ui/dist/assets/{StatCard-Djr487DV.js → StatCard-DLq8aBps.js} +1 -1
- package/ui/dist/assets/{StatusBadge-JpCoA33_.js → StatusBadge-BqlvIbdj.js} +1 -1
- package/ui/dist/assets/{Tabs-DJHu-roP.js → Tabs-DdUThlp1.js} +1 -1
- package/ui/dist/assets/TeamsPanel-uIIKoU7I.js +1 -0
- package/ui/dist/assets/{TelemetryPanel-D4PXsd-X.js → TelemetryPanel-dVr3yQQr.js} +1 -1
- package/ui/dist/assets/TitanCanvas-xHAJqwG2.js +945 -0
- package/ui/dist/assets/ToolsView-CG1mZdiy.js +2 -0
- package/ui/dist/assets/{Tooltip-B1LhTXJ8.js → Tooltip-C2tXJcrN.js} +1 -1
- package/ui/dist/assets/TraceViewer-BIMD_Osr.js +1 -0
- package/ui/dist/assets/TracesPanel-nMUiyMj5.js +1 -0
- package/ui/dist/assets/TrainingPanel-CT5R4HWm.js +1 -0
- package/ui/dist/assets/{VoiceOverlay-B_ss7Zg_.js → VoiceOverlay-Br4QnCtw.js} +3 -3
- package/ui/dist/assets/VramPanel-CdnJYytg.js +1 -0
- package/ui/dist/assets/WatchView-TNU6Ns1Q.js +13 -0
- package/ui/dist/assets/WorkTab-wTlX_UKP.js +1 -0
- package/ui/dist/assets/WorkflowBuilderPanel-CDpVt5ux.js +6 -0
- package/ui/dist/assets/WorkflowsPanel-zsFqsLdn.js +11 -0
- package/ui/dist/assets/{archive-gZFnGd5A.js → archive-Bh689DNg.js} +1 -1
- package/ui/dist/assets/{arrow-left-qA0Qer2h.js → arrow-left-WkVYLm80.js} +1 -1
- package/ui/dist/assets/{book-open-DIxdPqmD.js → book-open-ohEXgUsS.js} +1 -1
- package/ui/dist/assets/{bot-CvIF1uHi.js → bot-DvEcyQcD.js} +1 -1
- package/ui/dist/assets/{chart-column-BQiM-Td4.js → chart-column-w3goFd5f.js} +1 -1
- package/ui/dist/assets/{check-DgyDEFtq.js → check-CuRYh4Zh.js} +1 -1
- package/ui/dist/assets/{chevron-right-CQ1NTOtd.js → chevron-right-DbLSHmff.js} +1 -1
- package/ui/dist/assets/{circle-check-big-CAFcaPPH.js → circle-check-big-Bkba568b.js} +1 -1
- package/ui/dist/assets/{circle-stop-C-8xGv0n.js → circle-stop-Bx2ohEg8.js} +1 -1
- package/ui/dist/assets/{clipboard-list-9DdqBj1F.js → clipboard-list-Dj9tORnu.js} +1 -1
- package/ui/dist/assets/{clock-CF9BCIpL.js → clock-JyQAYy6X.js} +1 -1
- package/ui/dist/assets/{dollar-sign-LDRZBae6.js → dollar-sign-XxwPAA2a.js} +1 -1
- package/ui/dist/assets/{download-BBNXvBO0.js → download-D1izVEOL.js} +1 -1
- package/ui/dist/assets/{external-link-D_ji4Bec.js → external-link-DZ_rZsIt.js} +1 -1
- package/ui/dist/assets/{file-text-DrdTDEYp.js → file-text-Cfawu8Bs.js} +1 -1
- package/ui/dist/assets/{flask-conical-BGn5PgFX.js → flask-conical-Ql8QxhgY.js} +1 -1
- package/ui/dist/assets/{folder-BeZZUGnK.js → folder-DAdIw-Pb.js} +1 -1
- package/ui/dist/assets/{funnel-CAJgGO5M.js → funnel-FycfZcXo.js} +1 -1
- package/ui/dist/assets/{git-branch-BcXabeOs.js → git-branch-C2qrhGGu.js} +1 -1
- package/ui/dist/assets/index-Cml2x9pA.js +507 -0
- package/ui/dist/assets/index-yWybhcfI.css +1 -0
- package/ui/dist/assets/{layers-DxYDmPA_.js → layers-yzjtGlHB.js} +1 -1
- package/ui/dist/assets/{legacy-dHWI7k8P.js → legacy-D21WSMF1.js} +1 -1
- package/ui/dist/assets/{lightbulb-B0Du4SM4.js → lightbulb-BZJNK69S.js} +1 -1
- package/ui/dist/assets/{link-CUpaumqr.js → link-CnFkBkaY.js} +1 -1
- package/ui/dist/assets/{list-todo-CDDhmPQB.js → list-todo-BlgfQHup.js} +1 -1
- package/ui/dist/assets/{message-square-D5VWlv-Q.js → message-square-CRsG9u6_.js} +1 -1
- package/ui/dist/assets/{mic-Ddcc6Ann.js → mic-B32RHc7Y.js} +1 -1
- package/ui/dist/assets/{missions-2zox16Tc.js → missions-1iw8Z2_0.js} +1 -1
- package/ui/dist/assets/{network-DaJ7ugwX.js → network-C9RXQGrV.js} +1 -1
- package/ui/dist/assets/{pause-BukaK6rs.js → pause-BT1Bc2q3.js} +1 -1
- package/ui/dist/assets/{pencil-D_YwQBeg.js → pencil-BK5IU6o0.js} +1 -1
- package/ui/dist/assets/{play-BjdwtYMk.js → play-Cl1nC_gc.js} +1 -1
- package/ui/dist/assets/{plug-yISDdeW2.js → plug-DvcpOalj.js} +1 -1
- package/ui/dist/assets/{plus-BSjTdepW.js → plus-Dpo1qfrl.js} +1 -1
- package/ui/dist/assets/{radio-B7kX_yWE.js → radio-C5c9IyqX.js} +1 -1
- package/ui/dist/assets/{refresh-cw-CwDpzXUn.js → refresh-cw-C-iZkzuS.js} +1 -1
- package/ui/dist/assets/{rotate-ccw-7SQDTI0_.js → rotate-ccw-qzrB3SNw.js} +1 -1
- package/ui/dist/assets/{save-CjTPAQM0.js → save-DwR9wQVu.js} +1 -1
- package/ui/dist/assets/{search-BP7VlNxX.js → search-D10l0m3-.js} +1 -1
- package/ui/dist/assets/{send-C2XDuRPf.js → send-DtXGsaFW.js} +1 -1
- package/ui/dist/assets/{server-BE8W-AT4.js → server-BzisF3LL.js} +1 -1
- package/ui/dist/assets/settings-Dbwd1_-c.js +6 -0
- package/ui/dist/assets/{shield-check-s7la2J2K.js → shield-check-CXlDJyAW.js} +1 -1
- package/ui/dist/assets/square-BBC-JKzY.js +11 -0
- package/ui/dist/assets/{terminal-B8IK4WsO.js → terminal-DaBIlWEM.js} +1 -1
- package/ui/dist/assets/{test-tube-Xfn9DJeg.js → test-tube-CDATRD5t.js} +1 -1
- package/ui/dist/assets/{toggle-right-CHpzOIlj.js → toggle-right-DTmrC5RD.js} +1 -1
- package/ui/dist/assets/{trash-2-B1C85ePK.js → trash-2-CTeyjxD_.js} +1 -1
- package/ui/dist/assets/{trending-up-DDGHQZY1.js → trending-up-CXPRjRV4.js} +1 -1
- package/ui/dist/assets/{trophy-D0LhJSPA.js → trophy-DbVdXRtU.js} +1 -1
- package/ui/dist/assets/{volume-2-DMaE91b5.js → volume-2-DYDBmm3M.js} +1 -1
- package/ui/dist/assets/{wifi-off-DR9h8HGA.js → wifi-off-BBuIGbiP.js} +1 -1
- package/ui/dist/assets/zoom-out-D47_pRAO.js +16 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/sw.js +1 -1
- package/ui/dist/assets/AuditPanel-BaftX5MP.js +0 -1
- package/ui/dist/assets/BackupPanel-DAy9G7Wt.js +0 -1
- package/ui/dist/assets/CPActivity-BYDsUoMn.js +0 -1
- package/ui/dist/assets/CPAgentDetail-Bb9-GAJY.js +0 -1
- package/ui/dist/assets/CPAgents-BTZuGnki.js +0 -1
- package/ui/dist/assets/CPApprovals-BME2ARkO.js +0 -1
- package/ui/dist/assets/CPCosts-mOXwWq0i.js +0 -1
- package/ui/dist/assets/CPDashboard-CTlKGXXQ.js +0 -1
- package/ui/dist/assets/CPGoals-BNWhNP14.js +0 -1
- package/ui/dist/assets/CPInbox-ybe4r8LW.js +0 -16
- package/ui/dist/assets/CPIssueDetail-DaMMGbjw.js +0 -1
- package/ui/dist/assets/CPIssues-BgpQOISw.js +0 -1
- package/ui/dist/assets/CPLayout-bgErauTx.js +0 -2
- package/ui/dist/assets/CPOrg-C8l5SIWJ.js +0 -8
- package/ui/dist/assets/CPRuns-DB8S7loF.js +0 -1
- package/ui/dist/assets/CPVoice-DfwHPewA.js +0 -1
- package/ui/dist/assets/CheckpointsPanel-9-l_8GdG.js +0 -1
- package/ui/dist/assets/CommandPostHub-z55Yrhj1.js +0 -24
- package/ui/dist/assets/CronPanel-kEZK3gpx.js +0 -1
- package/ui/dist/assets/EmptyState-CfvU7SdB.js +0 -1
- package/ui/dist/assets/EvalPanel-CDG-njyj.js +0 -1
- package/ui/dist/assets/FilesPanel-CaLPog2e.js +0 -16
- package/ui/dist/assets/FleetPanel-BtlaV6pH.js +0 -1
- package/ui/dist/assets/InfraView-C0zEuFrR.js +0 -2
- package/ui/dist/assets/Input-CbrMbLgn.js +0 -1
- package/ui/dist/assets/IntegrationsPanel-B4TyR6jC.js +0 -1
- package/ui/dist/assets/IntelligenceView-DZ4HxYZ3.js +0 -2
- package/ui/dist/assets/LearningPanel-B4RIm_iQ.js +0 -1
- package/ui/dist/assets/McpPanel-BmNUFozc.js +0 -1
- package/ui/dist/assets/MemoryGraphPanel-JPurHV0L.js +0 -16
- package/ui/dist/assets/MemoryWikiPanel-DdvCAZHa.js +0 -6
- package/ui/dist/assets/MissionStart-wUkcEP0T.js +0 -1
- package/ui/dist/assets/Modal-BmS7C6FN.js +0 -1
- package/ui/dist/assets/OrganismPanel-C2LYDPrn.js +0 -1
- package/ui/dist/assets/OverviewPanel-DK8uuq4D.js +0 -1
- package/ui/dist/assets/PersonaProfilesPanel-DGtokXUu.js +0 -8
- package/ui/dist/assets/RecipesPanel-D3Zs2wxr.js +0 -1
- package/ui/dist/assets/SecurityPanel-BMERf796.js +0 -1
- package/ui/dist/assets/SelfImprovePanel-BxqWHXCU.js +0 -1
- package/ui/dist/assets/SelfProposalsPanel-CuC94vdx.js +0 -2
- package/ui/dist/assets/SessionsPanel-CQ8qvzp7.js +0 -1
- package/ui/dist/assets/SessionsTab-B3eHV3jf.js +0 -1
- package/ui/dist/assets/SettingsPanel-Cumls7N2.js +0 -1
- package/ui/dist/assets/SettingsView-BtA67pol.js +0 -2
- package/ui/dist/assets/SkillsPanel-CA415CT8.js +0 -11
- package/ui/dist/assets/TeamsPanel-C_Vu6vnY.js +0 -1
- package/ui/dist/assets/TitanCanvas-TuYZSZO7.js +0 -1117
- package/ui/dist/assets/ToolsView-BvTN6vFn.js +0 -2
- package/ui/dist/assets/TraceViewer-Bh8Jo3Dr.js +0 -1
- package/ui/dist/assets/TrainingPanel-Dmbd1rJ-.js +0 -1
- package/ui/dist/assets/VramPanel-CPICbZ2s.js +0 -1
- package/ui/dist/assets/WatchView-BCgLVfiV.js +0 -13
- package/ui/dist/assets/WorkTab-iptofXO9.js +0 -1
- package/ui/dist/assets/WorkflowsPanel-3RYkFHyf.js +0 -11
- package/ui/dist/assets/chevron-up-UyfdjRp6.js +0 -6
- package/ui/dist/assets/index-CUgepw5Q.js +0 -337
- package/ui/dist/assets/index-Dm6zcSTS.css +0 -1
- package/ui/dist/assets/proxy-CWET5FFX.js +0 -9
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SkillsPanel-BjEOBMRo.js","assets/index-Cml2x9pA.js","assets/index-yWybhcfI.css","assets/PageHeader-DdrbS1aq.js","assets/chevron-right-DbLSHmff.js","assets/ConfirmDialog-VErHWAbo.js","assets/Modal-ybPGvlQs.js","assets/clsx-B-dksMZM.js","assets/Button-MdXmb4_n.js","assets/search-D10l0m3-.js","assets/trash-2-CTeyjxD_.js","assets/download-D1izVEOL.js","assets/McpPanel-D-MqN_f-.js","assets/refresh-cw-C-iZkzuS.js","assets/plus-Dpo1qfrl.js","assets/server-BzisF3LL.js","assets/plug-DvcpOalj.js","assets/test-tube-CDATRD5t.js","assets/IntegrationsPanel-DQL-7Ec6.js","assets/circle-check-big-Bkba568b.js","assets/save-DwR9wQVu.js","assets/ChannelsPanel-BnaTOeyf.js","assets/MeshPanel-C-mRJpr0.js","assets/DataTable-BCqSUuN7.js","assets/shield-check-CXlDJyAW.js","assets/EvalHarnessPanel-BaMLdBNm.js","assets/layers-yzjtGlHB.js","assets/trending-up-CXPRjRV4.js","assets/play-Cl1nC_gc.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as l,j as e,_ as t}from"./index-Cml2x9pA.js";import{c as o}from"./clsx-B-dksMZM.js";const n=l.lazy(()=>t(()=>import("./SkillsPanel-BjEOBMRo.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),r=l.lazy(()=>t(()=>import("./McpPanel-D-MqN_f-.js"),__vite__mapDeps([12,1,2,3,4,5,6,7,8,13,14,15,16,17,10]))),c=l.lazy(()=>t(()=>import("./IntegrationsPanel-DQL-7Ec6.js"),__vite__mapDeps([18,1,2,3,4,19,16,20]))),d=l.lazy(()=>t(()=>import("./ChannelsPanel-BnaTOeyf.js"),__vite__mapDeps([21,1,2,3,4,13,19,20]))),x=l.lazy(()=>t(()=>import("./MeshPanel-C-mRJpr0.js"),__vite__mapDeps([22,1,2,23,3,4,13,24]))),m=l.lazy(()=>t(()=>import("./EvalHarnessPanel-BaMLdBNm.js"),__vite__mapDeps([25,1,2,26,27,13,28,4,19]))),_=[{id:"skills",label:"Skills"},{id:"mcp",label:"MCP Servers"},{id:"integrations",label:"Integrations"},{id:"channels",label:"Channels"},{id:"mesh",label:"Mesh Network"},{id:"evals",label:"Eval Harness"}];function v(){const[s,i]=l.useState("skills");return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-0",children:[e.jsx("h1",{className:"text-sm font-semibold text-text mb-3",children:"Tools & Connections"}),e.jsx("div",{className:"flex items-center gap-0.5 border-b border-border/50",children:_.map(a=>e.jsxs("button",{onClick:()=>i(a.id),className:o("px-3 py-2 text-xs font-medium transition-colors relative",s===a.id?"text-accent":"text-text-muted hover:text-text-secondary"),children:[a.label,s===a.id&&e.jsx("div",{className:"absolute bottom-0 left-1 right-1 h-[2px] bg-accent rounded-full"})]},a.id))})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto p-5",children:e.jsxs(l.Suspense,{fallback:e.jsx("div",{className:"skeleton-shimmer h-40 rounded-lg"}),children:[s==="skills"&&e.jsx(n,{}),s==="mcp"&&e.jsx(r,{}),s==="integrations"&&e.jsx(c,{}),s==="channels"&&e.jsx(d,{}),s==="mesh"&&e.jsx(x,{}),s==="evals"&&e.jsx(m,{})]})})]})}export{v as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,j as e,A as f,m as j,P as y,W as w,l as T,t as $,b9 as I,bQ as L}from"./index-Cml2x9pA.js";import{T as A}from"./trending-up-CXPRjRV4.js";import{G as v}from"./git-branch-C2qrhGGu.js";import{C as M}from"./clock-JyQAYy6X.js";import{C as F}from"./chart-column-w3goFd5f.js";import{S as R}from"./search-D10l0m3-.js";import{A as D}from"./arrow-left-WkVYLm80.js";function B(o){const r=o.toLowerCase();return r.includes("rate limit")||r.includes("too many requests")||r.includes("429")?{category:"Rate Limit",severity:"rate_limit",icon:"⏱️"}:r.includes("timeout")||r.includes("etimedout")||r.includes("econnreset")?{category:"Timeout",severity:"timeout",icon:"⏳"}:r.includes("auth")||r.includes("unauthorized")||r.includes("403")||r.includes("401")?{category:"Auth / Permission",severity:"permanent",icon:"🔒"}:r.includes("not found")||r.includes("404")||r.includes("enoent")?{category:"Not Found",severity:"permanent",icon:"❓"}:r.includes("context")||r.includes("too long")||r.includes("max tokens")?{category:"Context Overflow",severity:"permanent",icon:"📄"}:r.includes("quota")||r.includes("insufficient")||r.includes("exceeded")?{category:"Quota Exceeded",severity:"permanent",icon:"💰"}:r.includes("network")||r.includes("econnrefused")||r.includes("dns")?{category:"Network",severity:"transient",icon:"🌐"}:r.includes("empty")||r.includes("no response")?{category:"Empty Response",severity:"transient",icon:"👻"}:r.includes("format")||r.includes("json")||r.includes("parse")?{category:"Format Error",severity:"transient",icon:"🔧"}:{category:"Unknown",severity:"unknown",icon:"❓"}}const q={transient:"text-warning bg-warning/10 border-warning/20",permanent:"text-error bg-error/10 border-error/20",timeout:"text-cyan bg-cyan/10 border-cyan/20",rate_limit:"text-orange-400 bg-orange-400/10 border-orange-400/20",unknown:"text-text-muted bg-bg-tertiary border-border"};function O({traces:o,stats:r}){const u=i.useMemo(()=>o.filter(t=>t.status==="failed"&&t.error),[o]),l=i.useMemo(()=>{const t=new Map;for(const a of u){if(!a.error)continue;const{category:c,severity:d,icon:x}=B(a.error),g=t.get(c);g?(g.count++,g.examples.length<3&&g.examples.push(a.error)):t.set(c,{count:1,severity:d,icon:x,examples:[a.error]})}return Array.from(t.entries()).sort((a,c)=>c[1].count-a[1].count)},[u]),h=i.useMemo(()=>{const t=new Map;for(const a of o)for(const c of a.toolCalls){const d=t.get(c.tool)||{success:0,fail:0};c.success?d.success++:d.fail++,t.set(c.tool,d)}return Array.from(t.entries()).map(([a,{success:c,fail:d}])=>{const x=c+d;return{tool:a,success:c,fail:d,total:x,rate:x>0?Math.round(d/x*100):0}}).sort((a,c)=>c.fail-a.fail)},[o]),p=o.length,n=p>0?Math.round(u.length/p*100):0;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{icon:f,label:"Total",value:p,color:"text-accent"},{icon:j,label:"Failed",value:u.length,color:"text-error"},{icon:A,label:"Fail Rate",value:`${n}%`,color:n>20?"text-error":n>5?"text-warning":"text-success"},{icon:y,label:"Categories",value:l.length,color:"text-orange-400"}].map(t=>e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(t.icon,{size:14,className:t.color}),e.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:t.label})]}),e.jsx("div",{className:"text-2xl font-bold text-text",children:t.value})]},t.label))}),l.length>0&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border",children:[e.jsx(y,{size:14,className:"text-error"}),e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Hermes Error Taxonomy"})]}),e.jsx("div",{className:"divide-y divide-border",children:l.map(([t,a])=>e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:a.icon}),e.jsx("span",{className:"text-[12px] font-medium text-text-secondary",children:t}),e.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded border capitalize ${q[a.severity]}`,children:a.severity})]}),e.jsxs("span",{className:"text-[11px] text-text-muted",children:[a.count," occurrence",a.count===1?"":"s"]})]}),a.examples.length>0&&e.jsx("div",{className:"space-y-0.5 mt-1.5",children:a.examples.map((c,d)=>e.jsx("div",{className:"text-[10px] text-text-muted font-mono truncate pl-5",children:c},d))})]},t))})]}),h.length>0&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border",children:[e.jsx(w,{size:14,className:"text-accent"}),e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Tool Failure Rates"})]}),e.jsx("div",{className:"divide-y divide-border",children:h.slice(0,15).map(t=>{const a=t.total>0?Math.round(t.fail/t.total*100):0;return e.jsxs("div",{className:"px-4 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"text-[11px] text-text-secondary font-mono w-32 truncate",children:t.tool}),e.jsx("div",{className:"flex-1 h-1.5 bg-bg rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${a>50?"bg-error":a>10?"bg-warning":"bg-success"}`,style:{width:`${a}%`}})}),e.jsxs("div",{className:"text-[10px] text-text-muted w-20 text-right tabular-nums",children:[t.fail,"/",t.total," (",a,"%)"]})]},t.tool)})})]}),l.length===0&&h.every(t=>t.fail===0)&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-text-muted text-xs",children:[e.jsx(T,{size:24,className:"mb-2 text-success opacity-60"}),"No errors detected in recent traces"]})]})}function V(){const{toast:o}=$(),[r,u]=i.useState([]),[l,h]=i.useState(null),[p,n]=i.useState(!0),[t,a]=i.useState(null),[c,d]=i.useState(""),[x,g]=i.useState("all"),k=async()=>{try{const s=await I(100);u(s.traces||[]),h(s.stats||null)}catch(s){n(m=>(m&&o("error",`Couldn't load traces — try again. ${s.message}`),m))}n(!1)};i.useEffect(()=>{k();const s=setInterval(k,1e4);return()=>clearInterval(s)},[]);const N=i.useMemo(()=>{let s=r;if(x!=="all"&&(s=s.filter(m=>m.status===x)),c.trim()){const m=c.toLowerCase();s=s.filter(b=>b.message.toLowerCase().includes(m)||b.sessionId.toLowerCase().includes(m)||b.traceId.toLowerCase().includes(m)||b.toolCalls.some(E=>E.tool.toLowerCase().includes(m)))}return s},[r,x,c]),C=r.filter(s=>s.status==="failed"),S=(l==null?void 0:l.avgDurationMs)??0,z=(l==null?void 0:l.topTools)??[];return p?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"grid grid-cols-4 gap-3",children:[1,2,3,4].map(s=>e.jsx("div",{className:"h-20 rounded-xl bg-bg-secondary animate-pulse"},s))}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(s=>e.jsx("div",{className:"h-14 rounded-lg bg-bg-secondary animate-pulse"},s))})]}):t?e.jsx(P,{trace:t,onBack:()=>a(null)}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{icon:v,label:"Traces",value:(l==null?void 0:l.totalTraces)??0,sub:"in memory",color:"text-accent"},{icon:f,label:"Running",value:(l==null?void 0:l.running)??0,sub:"active now",color:"text-cyan"},{icon:j,label:"Failed",value:C.length,sub:`${r.length>0?Math.round(C.length/r.length*100):0}% rate`,color:"text-error"},{icon:M,label:"Avg Duration",value:`${S}ms`,sub:`${(l==null?void 0:l.avgRounds)??0} avg rounds`,color:"text-warning"}].map(s=>e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(s.icon,{size:14,className:s.color}),e.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:s.label})]}),e.jsx("div",{className:"text-2xl font-bold text-text",children:s.value}),s.sub&&e.jsx("div",{className:"text-[11px] text-text-muted mt-1",children:s.sub})]},s.label))}),e.jsx(O,{traces:r,stats:l}),z.length>0&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(F,{size:14,className:"text-accent"}),e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Top Tools"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:z.slice(0,8).map(s=>e.jsxs("span",{className:"text-[11px] px-2 py-1 rounded-full bg-bg border border-border text-text-secondary",children:[s.tool," ",e.jsxs("span",{className:"text-text-muted",children:["(",s.count,")"]})]},s.tool))})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(R,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-text-muted"}),e.jsx("input",{value:c,onChange:s=>d(s.target.value),placeholder:"Search traces, sessions, tools...",className:"w-full bg-bg-secondary border border-border rounded-lg pl-8 pr-3 py-2 text-[12px] text-text placeholder-text-muted focus:outline-none focus:border-accent"})]}),e.jsx("div",{className:"flex gap-1",children:["all","running","completed","failed"].map(s=>e.jsx("button",{onClick:()=>g(s),className:`px-2.5 py-1.5 text-[10px] rounded-lg capitalize transition-colors ${x===s?"bg-accent text-white":"bg-bg-secondary text-text-muted hover:text-text"}`,children:s},s))})]}),e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-2xl overflow-hidden",children:[e.jsx("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{size:14,className:"text-accent"}),e.jsx("span",{className:"text-[13px] font-medium text-text-secondary",children:"Execution Traces"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:N.length})]})}),e.jsx("div",{className:"divide-y divide-border max-h-[500px] overflow-y-auto",children:N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-text-muted text-xs",children:[e.jsx(v,{size:24,className:"mb-2 opacity-40"}),r.length===0?"No traces captured yet":"No traces match your filters"]}):N.map(s=>e.jsxs("button",{onClick:()=>a(s),className:"w-full text-left px-4 py-3 hover:bg-bg-secondary/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s.status==="running"?e.jsx(f,{size:14,className:"text-cyan animate-pulse shrink-0"}):s.status==="completed"?e.jsx(T,{size:14,className:"text-success shrink-0"}):e.jsx(j,{size:14,className:"text-error shrink-0"}),e.jsx("p",{className:"text-[12px] text-text-secondary truncate flex-1",children:s.message}),e.jsx("span",{className:"text-[10px] text-text-muted shrink-0 tabular-nums",children:s.totalMs?`${s.totalMs}ms`:"..."})]}),e.jsxs("div",{className:"flex gap-3 mt-1 text-[10px] text-text-muted ml-6",children:[e.jsxs("span",{children:[s.toolCalls.length," tools"]}),e.jsxs("span",{children:[s.rounds," rounds"]}),s.model&&e.jsx("span",{children:s.model.split("/").pop()}),s.error&&e.jsx("span",{className:"text-error truncate max-w-[200px]",children:s.error})]})]},s.traceId))})]})]})}function P({trace:o,onBack:r}){const[u,l]=i.useState(null),[h,p]=i.useState(!0);i.useEffect(()=>{let t=!0;return L(o.traceId).then(a=>{t&&l(a)}).catch(()=>{t&&l(o)}).finally(()=>{t&&p(!1)}),()=>{t=!1}},[o.traceId,o]);const n=u||o;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:r,className:"flex items-center gap-1 text-[11px] text-text-muted hover:text-text transition-colors",children:[e.jsx(D,{size:12})," Back to traces"]}),e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.status==="running"?e.jsx(f,{size:16,className:"text-cyan animate-pulse"}):n.status==="completed"?e.jsx(T,{size:16,className:"text-success"}):e.jsx(j,{size:16,className:"text-error"}),e.jsx("span",{className:`text-xs font-semibold capitalize ${n.status==="completed"?"text-success":n.status==="failed"?"text-error":"text-cyan"}`,children:n.status})]}),e.jsx("p",{className:"text-sm text-text mb-2",children:n.message}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-[11px] text-text-muted",children:[e.jsxs("span",{children:["ID: ",e.jsx("span",{className:"font-mono text-text-secondary",children:n.traceId.slice(0,12)})]}),e.jsxs("span",{children:["Session: ",e.jsx("span",{className:"font-mono text-text-secondary",children:n.sessionId.slice(0,12)})]}),n.totalMs&&e.jsxs("span",{children:[n.totalMs,"ms"]}),e.jsxs("span",{children:[n.rounds," rounds"]}),n.model&&e.jsx("span",{children:n.model}),n.tokens&&e.jsxs("span",{children:[n.tokens.prompt," prompt / ",n.tokens.completion," completion"]})]})]}),n.spans.length>0&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(M,{size:14,className:"text-accent"}),e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Timeline"})]}),e.jsx("div",{className:"space-y-2",children:n.spans.map((t,a)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-16 text-[10px] text-text-muted text-right tabular-nums",children:t.durationMs!==void 0?`${t.durationMs}ms`:"..."}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent shrink-0"}),e.jsx("span",{className:"text-[11px] text-text-secondary font-mono",children:t.name}),t.data&&Object.keys(t.data).length>0&&e.jsx("span",{className:"text-[10px] text-text-muted truncate max-w-[200px]",children:JSON.stringify(t.data).slice(0,60)})]},a))})]}),n.toolCalls.length>0&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(w,{size:14,className:"text-accent"}),e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Tool Calls"})]}),e.jsx("div",{className:"space-y-2",children:n.toolCalls.map((t,a)=>e.jsxs("div",{className:"flex items-center gap-3 px-2.5 py-2 rounded-lg bg-bg border border-border",children:[e.jsx(w,{size:12,className:t.success?"text-success shrink-0":"text-error shrink-0"}),e.jsx("span",{className:"text-[11px] text-text-secondary font-mono",children:t.tool}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:[t.durationMs,"ms"]}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:["round ",t.round]}),!t.success&&e.jsx("span",{className:"text-[10px] text-error ml-auto",children:"failed"})]},a))})]}),n.error&&e.jsxs("div",{className:"bg-error/5 border border-error/20 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(y,{size:14,className:"text-error"}),e.jsx("span",{className:"text-xs font-semibold text-error",children:"Error"})]}),e.jsx("div",{className:"text-[11px] text-text-secondary font-mono whitespace-pre-wrap",children:n.error})]})]})}export{V as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,j as e,A as p,b as d}from"./index-Cml2x9pA.js";import{P as h}from"./PageHeader-DdrbS1aq.js";import{D as j}from"./download-D1izVEOL.js";import"./chevron-right-DbLSHmff.js";function a({label:r,value:o}){return e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:r}),e.jsx("p",{className:"text-lg font-semibold text-[var(--text)]",children:o})]})}function N(){const[r,o]=l.useState([]),[s,c]=l.useState(null),[x,n]=l.useState(!0),i=()=>{n(!0),Promise.all([d("/api/traces?limit=100",{headers:{"Content-Type":"application/json"}}).then(t=>t.json()).then(t=>t.spans||[]).catch(()=>[]),d("/api/traces/summary",{headers:{"Content-Type":"application/json"}}).then(t=>t.json()).catch(()=>null)]).then(([t,m])=>{o(t),c(m)}).finally(()=>n(!1))};return l.useEffect(i,[]),e.jsxs("div",{className:"space-y-6",children:[e.jsx(h,{title:"Observability",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Tools"},{label:"Observability"}]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{size:18,className:"text-[var(--text-secondary)]"}),e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:"Per-run traces — latency, tokens, cost, tools"}),e.jsxs("a",{href:"/api/traces/export",target:"_blank",rel:"noopener noreferrer",className:"ml-auto flex items-center gap-1 text-xs px-2 py-1 rounded border border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text)]",children:[e.jsx(j,{size:12})," OTel export"]})]}),s&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(a,{label:"Runs",value:String(s.totalRuns)}),e.jsx(a,{label:"OK",value:`${s.okRuns}/${s.totalRuns}`}),e.jsx(a,{label:"Tokens",value:(s.totalPromptTokens+s.totalCompletionTokens).toLocaleString()}),e.jsx(a,{label:"Cost",value:`$${s.totalCostUsd.toFixed(4)}`}),e.jsx(a,{label:"Avg latency",value:`${(s.avgDurationMs/1e3).toFixed(1)}s`})]}),x?e.jsx("div",{className:"text-[var(--text-muted)]",children:"Loading traces…"}):r.length===0?e.jsx("div",{className:"text-[var(--text-muted)] text-sm",children:"No runs traced yet — send a message and they'll appear here."}):e.jsx("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"text-[var(--text-muted)] border-b border-[var(--border)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-2",children:"Model"}),e.jsx("th",{className:"text-left p-2",children:"Input"}),e.jsx("th",{className:"text-left p-2",children:"Tools"}),e.jsx("th",{className:"text-right p-2",children:"Tokens"}),e.jsx("th",{className:"text-right p-2",children:"Cost"}),e.jsx("th",{className:"text-right p-2",children:"Latency"}),e.jsx("th",{className:"text-center p-2",children:"OK"})]})}),e.jsx("tbody",{children:r.map(t=>e.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[e.jsx("td",{className:"p-2 font-mono text-[var(--text-secondary)] whitespace-nowrap",children:t.model}),e.jsx("td",{className:"p-2 text-[var(--text-secondary)] max-w-[220px] truncate",title:t.input,children:t.input}),e.jsx("td",{className:"p-2 text-[var(--text-muted)] whitespace-nowrap",children:t.toolsUsed.join(", ")||"—"}),e.jsx("td",{className:"p-2 text-right text-[var(--text-secondary)]",children:(t.promptTokens+t.completionTokens).toLocaleString()}),e.jsxs("td",{className:"p-2 text-right text-[var(--text-secondary)]",children:["$",t.costUsd.toFixed(4)]}),e.jsxs("td",{className:"p-2 text-right text-[var(--text-secondary)]",children:[(t.durationMs/1e3).toFixed(1),"s"]}),e.jsx("td",{className:"p-2 text-center",children:t.ok?"✓":"✗"})]},t.id))})]})})]})}export{N as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as m,r as t,ag as g,ah as b,j as e,B as p}from"./index-Cml2x9pA.js";import{P as h}from"./PageHeader-DdrbS1aq.js";import{R as f}from"./refresh-cw-C-iZkzuS.js";import{D as u}from"./download-D1izVEOL.js";import"./chevron-right-DbLSHmff.js";function S(){const{toast:i}=m(),[a,n]=t.useState(null),[c,x]=t.useState([]),[l,d]=t.useState(!0),r=t.useCallback(async()=>{d(!0);try{const[s,o]=await Promise.all([g(),b()]);n(s),x(o.runs||[])}catch(s){i("error",`Couldn't load training data — try again. (${s.message})`)}d(!1)},[i]);return t.useEffect(()=>{r()},[r]),e.jsxs("div",{className:"space-y-4",children:[e.jsx(h,{title:"Training Dashboard",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Intelligence"},{label:"Training"}]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:r,disabled:l,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#27272a] text-[#a1a1aa] text-sm font-medium hover:bg-[#3f3f46] disabled:opacity-50",children:[e.jsx(f,{className:`w-4 h-4 ${l?"animate-spin":""}`})," Refresh"]}),e.jsxs("a",{href:"/api/training/export",download:!0,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#27272a] text-[#a1a1aa] text-sm font-medium hover:bg-[#3f3f46]",children:[e.jsx(u,{className:"w-4 h-4"})," Export"]})]}),a&&e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Entries"}),e.jsx("div",{className:"text-lg font-semibold text-[#e4e4e7]",children:a.entries})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Size (bytes)"}),e.jsx("div",{className:"text-lg font-semibold text-[#e4e4e7]",children:a.sizeBytes})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Last Capture"}),e.jsx("div",{className:"text-lg font-semibold text-[#e4e4e7]",children:a.lastCapture?new Date(a.lastCapture).toLocaleString():"—"})]})]}),e.jsx("div",{className:"space-y-2",children:c.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(p,{className:`w-4 h-4 ${s.status==="running"?"text-amber-400":s.status==="completed"?"text-emerald-400":"text-red-400"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-[#e4e4e7]",children:[s.type," — ",s.id.slice(0,8)]}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[s.examplesProcessed," examples • ",s.status]})]})]}),e.jsx("div",{className:"text-xs text-[#52525b]",children:new Date(s.startedAt).toLocaleDateString()})]},s.id))})]})}export{S as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Se,r as e,j as n,b as le,
|
|
1
|
+
import{c as Se,r as e,j as n,b as le,aA as Pe,X as $e,$ as Ue,aB as _e}from"./index-Cml2x9pA.js";import{C as Fe}from"./chevron-right-DbLSHmff.js";import{V as Be}from"./volume-2-DYDBmm3M.js";import{M as ze}from"./mic-B32RHc7Y.js";/**
|
|
2
2
|
* @license lucide-react v0.513.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,5 +13,5 @@ import{c as Se,r as e,j as n,b as le,aM as Pe,X as Ue,V as $e,aN as _e}from"./in
|
|
|
13
13
|
0%, 100% { opacity: 1; transform: scale(1); }
|
|
14
14
|
50% { opacity: 0.4; transform: scale(0.8); }
|
|
15
15
|
}
|
|
16
|
-
`})]})]})}const Ce={default:{name:"Default",description:"F5-TTS base voice",gradient:"radial-gradient(circle at 35% 35%, #c084fc, #a855f7, #7c3aed)",glow:"#a855f7"}},ne=[{gradient:"radial-gradient(circle at 35% 35%, #93c5fd, #3b82f6, #1d4ed8)",glow:"#3b82f6"},{gradient:"radial-gradient(circle at 35% 35%, #fbbf24, #f59e0b, #b45309)",glow:"#f59e0b"},{gradient:"radial-gradient(circle at 35% 35%, #5eead4, #14b8a6, #0f766e)",glow:"#14b8a6"},{gradient:"radial-gradient(circle at 35% 35%, #fda4af, #fb7185, #e11d48)",glow:"#fb7185"},{gradient:"radial-gradient(circle at 35% 35%, #a5b4fc, #818cf8, #4f46e5)",glow:"#818cf8"},{gradient:"radial-gradient(circle at 35% 35%, #fdba74, #f97316, #c2410c)",glow:"#f97316"},{gradient:"radial-gradient(circle at 35% 35%, #86efac, #22c55e, #15803d)",glow:"#22c55e"},{gradient:"radial-gradient(circle at 35% 35%, #67e8f9, #22d3ee, #0891b2)",glow:"#22d3ee"}];function ue(u){return u.map((d,i)=>{const s=Ce[d];if(s)return{id:d,...s};const
|
|
17
|
-
`);p=x.pop()||"";for(const C of x)if(C.trim())try{const f=JSON.parse(C);if((T=f.message)!=null&&T.thinking&&(D+=f.message.thinking,(L=i.onThinking)==null||L.call(i,f.message.thinking)),(P=f.message)!=null&&P.content&&(q+=f.message.content,i.onToken(f.message.content)),f.done){(h=i.onDone)==null||h.call(i,{totalDuration:f.total_duration||0,promptTokens:f.prompt_eval_count||0,evalTokens:f.eval_count||0});return}}catch{}}if(p+=V.decode(),p.trim())try{const b=JSON.parse(p.trim());if((N=b.message)!=null&&N.content&&i.onToken(b.message.content),(E=b.message)!=null&&E.thinking&&((M=i.onThinking)==null||M.call(i,b.message.thinking)),b.done){(J=i.onDone)==null||J.call(i,{totalDuration:b.total_duration||0,promptTokens:b.prompt_eval_count||0,evalTokens:b.eval_count||0});return}}catch{}(I=i.onDone)==null||I.call(i,{totalDuration:0,promptTokens:0,evalTokens:0})}finally{m.releaseLock()}}let et=0;const xe=()=>`voice-msg-${Date.now()}-${++et}`,ke=u=>u.replace(/<(?:laugh|chuckle|sigh|cough|sniffle|groan|yawn|gasp)>/gi,"").replace(/\s{2,}/g," ").trim(),je=u=>u.replace(/```[\s\S]*?```/g,"").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/^#+\s+/gm,"").replace(/^[-*]\s+/gm,"").replace(/\n{2,}/g," ").trim(),Ae=u=>u.replace(/(?:Let me |I'll |I will |I'm going to )(?:use|call|check|run|invoke|execute|try)(?: the)? \w[\w_]*(?: tool)?(?:\s+(?:to|for|and)\b[^.!?]*)?[.!]?\s*/gi,"").replace(/\b(?:Using|Calling|Running|Checking|Invoking|Executing) (?:the )?\w[\w_]*(?: tool)?(?:\s+(?:to|for)\b[^.!?]*)?[.!]?\s*/gi,"").replace(/\b\w[\w_]*(?:_\w+)+\b/g,"").replace(/\s{2,}/g," ").trim();function st({onClose:u}){const[d,i]=e.useState(!1),s=localStorage.getItem("titan-voice")||"",[A,O]=e.useState(s?"active":"picking"),[S,m]=e.useState(s),V=e.useRef(s),[p,q]=e.useState(!1),[D,T]=e.useState(!1),[L,P]=e.useState(!1),[h,N]=e.useState(!1),[E,M]=e.useState([]),[J,I]=e.useState(0),[b,l]=e.useState(""),[x,C]=e.useState(null),[f,U]=e.useState(!1),[re,Y]=e.useState([]),R=e.useRef(null),Z=e.useRef(null),we=e.useRef(null),oe=e.useRef(null),F=e.useRef(null),X=e.useRef(""),se=e.useRef(0);e.useRef(void 0);const H=e.useRef(null),$=e.useRef(null),B=e.useRef(null),K=e.useRef(null),Q=e.useRef(null),ye=e.useRef(0),G=e.useRef(!1),de=e.useRef(null);e.useRef(typeof navigator<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent));const fe=e.useCallback(t=>new Promise(async r=>{var o,g;const a=B.current;if(a&&a.state!=="closed")try{a.state==="suspended"&&await a.resume();const w=await(await fetch(t)).arrayBuffer(),v=await a.decodeAudioData(w);try{(o=K.current)==null||o.stop()}catch{}const k=a.createBufferSource();k.buffer=v,k.connect(a.destination),K.current=k,k.onended=()=>{URL.revokeObjectURL(t),r()},k.start(0);try{(g=R.current)==null||g.stop()}catch{}console.log("[Voice] Playing via Web Audio API");return}catch(c){console.warn("[Voice] Web Audio failed:",c)}try{const c=$.current||new Audio;$.current=c,c.setAttribute("playsinline",""),c.setAttribute("autoplay",""),H.current=c,c.onplay=()=>{var w;try{(w=R.current)==null||w.stop()}catch{}},c.onended=()=>{URL.revokeObjectURL(t),r()},c.onerror=w=>{console.warn("[Voice] Audio element error:",w),URL.revokeObjectURL(t),r()},c.src=t,await c.play(),console.log("[Voice] Playing via Audio element")}catch(c){console.warn("[Voice] Audio element play failed:",c),URL.revokeObjectURL(t),r()}}),[]),ee=e.useRef(!1),ge=e.useRef(!1),W=e.useRef("picking");e.useEffect(()=>{ee.current=p},[p]),e.useEffect(()=>{ge.current=L},[L]),e.useEffect(()=>{W.current=A},[A]),e.useEffect(()=>{(async()=>{var t;try{const r=await le("/api/voice/voices");if(r.ok){const a=await r.json();if((t=a.voices)!=null&&t.length){if(Y(a.voices),s&&!a.voices.includes(s)){const o=a.voices[0];m(o),V.current=o,localStorage.setItem("titan-voice",o)}}else Y(["default"])}}catch{Y(["default"])}})()},[]),e.useEffect(()=>{requestAnimationFrame(()=>i(!0))},[]),e.useEffect(()=>()=>{var t,r,a,o;W.current="picking";try{(t=R.current)==null||t.stop()}catch{}R.current=null,(r=oe.current)==null||r.getTracks().forEach(g=>g.stop()),(a=Z.current)==null||a.close(),(o=Q.current)==null||o.abort(),F.current&&clearTimeout(F.current),de.current&&(clearInterval(de.current),de.current=null),cancelAnimationFrame(se.current),cancelAnimationFrame(ye.current)},[]),e.useEffect(()=>{if(!f)return;const t=()=>U(!1),r=setTimeout(()=>document.addEventListener("click",t),0);return()=>{clearTimeout(r),document.removeEventListener("click",t)}},[f]);const te=e.useCallback(async()=>{var t;try{let r=function(){c.getByteFrequencyData(w);let v=0;for(let y=0;y<w.length;y++)v+=w[y];const k=v/w.length/255;I(k),se.current=requestAnimationFrame(r)};if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia)){console.warn("[Voice] getUserMedia not available — may need HTTPS on mobile");return}const a=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});oe.current=a;let o=Z.current;(!o||o.state==="closed")&&(o=new(window.AudioContext||window.webkitAudioContext)),o.state==="suspended"&&await o.resume(),Z.current=o;const g=o.createMediaStreamSource(a),c=o.createAnalyser();c.fftSize=256,c.smoothingTimeConstant=.8,g.connect(c),we.current=c;const w=new Uint8Array(c.frequencyBinCount);se.current=requestAnimationFrame(r)}catch(r){console.error("Mic access denied:",r)}},[]),ae=e.useCallback(()=>{var t,r;cancelAnimationFrame(se.current),cancelAnimationFrame(ye.current),(t=oe.current)==null||t.getTracks().forEach(a=>a.stop()),(r=Z.current)==null||r.close(),oe.current=null,Z.current=null,we.current=null,I(0)},[]),me=e.useCallback(()=>{var a;const t=window.SpeechRecognition||window.webkitSpeechRecognition;if(!t){console.error("Speech recognition not supported");return}try{(a=R.current)==null||a.stop()}catch{}const r=new t;r.continuous=!0,r.interimResults=!0,r.lang="en-US",r.onresult=o=>{if(ge.current)return;let g="",c="";for(let w=o.resultIndex;w<o.results.length;w++){const v=o.results[w];v[0].confidence>0&&v[0].confidence<.5||(v.isFinal?c+=v[0].transcript:g+=v[0].transcript)}if(g&&l(g),c){X.current+=c,l(""),F.current&&clearTimeout(F.current);const v=X.current.trim().split(/\s+/).length<10?400:700;F.current=setTimeout(()=>{const k=X.current.trim();k&&(X.current="",Re(k))},v)}},r.onend=()=>{if(!ee.current&&!ge.current&&W.current==="active")try{r.start()}catch{}T(!1)},r.onstart=()=>{T(!0)},r.onerror=o=>{console.error("Speech recognition error:",o.error),o.error==="not-allowed"?(C("Mic access denied — check browser permissions"),T(!1)):o.error==="network"?(C("Speech recognition network error"),setTimeout(()=>{if(!ee.current&&W.current==="active")try{r.start()}catch{}},2e3)):o.error==="audio-capture"?(C("Mic not available — is another app using it?"),T(!1)):o.error!=="no-speech"&&console.error("STT error:",o.error)},R.current=r;try{r.start()}catch{}},[]),ce=e.useCallback(()=>{var r;try{(r=K.current)==null||r.stop()}catch{}K.current=null;const t=H.current;t&&(t.pause(),t.src="",H.current=null),"speechSynthesis"in window&&window.speechSynthesis.cancel(),P(!1),I(0)},[]);e.useEffect(()=>{if(s&&A==="active"){try{new Audio("data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=").play().catch(()=>{})}catch{}te(),me()}},[]),e.useCallback(()=>{const t=[];let r=0,a=!1,o=!1,g=null,c=null;const w=Date.now(),v=setInterval(()=>{if(!a){const j=(Date.now()-w)/600;I(.45+Math.sin(j*Math.PI*2)*.15)}},100),k=()=>{clearInterval(v),I(0)},y=()=>{if(a){k();return}if(r<t.length){const j=t[r++];fe(j).then(()=>y()).catch(()=>y())}else o?(k(),g&&g()):c=y};return{push(j){if(t.push(j),c){const z=c;c=null,z()}},finish(){if(o=!0,c){const j=c;c=null,j()}},start(j){g=j,y()},cancel(){var j;a=!0;try{(j=K.current)==null||j.stop()}catch{}H.current&&(H.current.pause(),H.current.src=""),k()},get length(){return t.length}}},[]);const Re=e.useCallback(async t=>{var c,w,v,k;if(G.current)return;G.current=!0,ce(),(c=Q.current)==null||c.abort(),M(y=>[...y,{id:xe(),role:"user",text:t}]),N(!0),T(!1),C(null);try{(w=R.current)==null||w.stop()}catch{}const r=new AbortController;Q.current=r;const a=V.current||"default";let o="",g="";try{const y=E.map(_=>({role:_.role,content:_.text,timestamp:(_.id,Date.now())}));await Ke([...y,{role:"user",content:t,timestamp:Date.now()}],"You are TITAN, a helpful AI assistant. Keep responses concise and natural for voice conversation. Use short sentences.",{onToken:_=>{g+=_;const ve=Ae(ke(je(g)));o?M(he=>he.map(pe=>pe.id===o?{...pe,text:ve}:pe)):(o=xe(),M(he=>[...he,{id:o,role:"assistant",text:ve}])),N(!1)}},{signal:r.signal});const j=Ae(ke(je(g)));if(!j){G.current=!1;try{(v=R.current)==null||v.start()}catch{}return}P(!0);const z=await fetch("/api/voice/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:j.slice(0,500),voice:a}),signal:AbortSignal.timeout(12e4)});if(!z.ok)throw new Error(`F5-TTS error: ${z.status}`);const Ve=await z.blob(),De=URL.createObjectURL(Ve);await fe(De),P(!1),I(0),X.current="",setTimeout(()=>{var _;if(G.current=!1,!ee.current&&W.current==="active")try{(_=R.current)==null||_.start()}catch{}},500)}catch(y){if((y==null?void 0:y.name)==="AbortError"&&!Q.current)return;const j=(y==null?void 0:y.name)==="AbortError"?"Request timed out":"Connection error";C(j),setTimeout(()=>C(null),4e3),console.error("Voice processing error:",y),M(z=>[...z,{id:xe(),role:"assistant",text:"Sorry, something went wrong."}]),N(!1),P(!1),X.current="",G.current=!1;try{(k=R.current)==null||k.start()}catch{}}},[ce,fe,E]),Te=e.useCallback(async t=>{m(t),V.current=t,localStorage.setItem("titan-voice",t);try{await le("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({voice:{ttsVoice:t}})})}catch{}if(O("active"),!B.current||B.current.state==="closed"){const r=window.AudioContext||window.webkitAudioContext;B.current=new r}B.current.state==="suspended"&&B.current.resume().catch(()=>{});try{const r=B.current,a=r.createBuffer(1,1,22050),o=r.createBufferSource();o.buffer=a,o.connect(r.destination),o.start(0)}catch{}$.current||($.current=new Audio,$.current.preload="auto"),te(),me()},[te,me]),Ne=e.useCallback(t=>{m(t),V.current=t,localStorage.setItem("titan-voice",t),U(!1),le("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({voice:{ttsVoice:t}})}).catch(()=>{})},[]),Me=e.useCallback(async t=>{try{const r=await fetch("/api/voice/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:"Hey! I'm TITAN, your AI assistant.",voice:t})});if(!r.ok)return;const a=await r.blob(),o=URL.createObjectURL(a),g=$.current||new Audio,c=()=>{URL.revokeObjectURL(o),g.src=""};g.onended=c,g.onerror=c,g.play()}catch{}},[]),be=e.useCallback(()=>{var t,r;i(!1),W.current="picking",O("picking"),(t=Q.current)==null||t.abort(),Q.current=null;try{(r=R.current)==null||r.stop()}catch{}R.current=null,ce(),ae(),F.current&&clearTimeout(F.current),G.current=!1,setTimeout(u,200)},[u,ae,ce]),Le=e.useCallback(()=>{q(t=>{var a,o;const r=!t;if(ee.current=r,r){try{(a=R.current)==null||a.stop()}catch{}ae(),T(!1)}else{te();try{(o=R.current)==null||o.start()}catch{}}return r})},[te,ae]),Ee=L?"assistant":h?"thinking":D?"user":"idle",Ie=p?"Muted":L?"TITAN is speaking...":h?"Thinking...":D?b?`"${b}"`:"Listening...":"Connected",Oe=L?"var(--color-purple-light)":h?"var(--color-warning)":D?"var(--color-cyan)":"var(--color-text-muted)";return n.jsxs(n.Fragment,{children:[n.jsx("audio",{ref:t=>{t&&!$.current&&($.current=t)},autoPlay:!0,playsInline:!0,style:{position:"absolute",width:0,height:0,opacity:0}}),n.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center backdrop-blur-sm transition-all duration-200",style:{backgroundColor:"rgba(9, 9, 11, 0.95)",opacity:d?1:0,transform:d?"scale(1)":"scale(0.95)"},children:[n.jsx("button",{onClick:be,className:"absolute right-6 top-6 rounded-full p-2 transition-colors hover:bg-bg-tertiary z-20 text-text-secondary",children:n.jsx(Ue,{className:"h-6 w-6"})}),A==="picking"&&n.jsx("div",{className:"w-full h-full",children:n.jsx(Ge,{currentVoice:S||void 0,onSelect:Te,onPreview:Me})}),A==="active"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mb-6 text-center",children:[n.jsx("div",{className:"text-base font-medium mb-0.5 transition-colors duration-500 max-w-md truncate px-4",style:{color:Oe},children:Ie}),x&&n.jsx("div",{className:"text-xs font-medium mt-1 animate-pulse text-error",children:x}),n.jsxs("div",{className:"relative mt-2",children:[n.jsxs("button",{onClick:()=>U(t=>!t),className:"inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium transition-colors hover:bg-bg-tertiary",style:{color:ie(S||"tara").glow},children:[n.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:ie(S||"tara").glow}}),ie(S||"tara").name,n.jsx($e,{className:"h-3 w-3"})]}),f&&n.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 mt-1 rounded-xl border border-bg-tertiary bg-bg-secondary/95 backdrop-blur-sm p-1.5 shadow-xl z-30",style:{minWidth:180},children:re.map(t=>{const r=ie(t),a=t===(S||"tara");return n.jsxs("button",{onClick:()=>Ne(t),className:"flex items-center gap-2.5 w-full rounded-lg px-3 py-2 text-left text-sm transition-colors hover:bg-bg-tertiary",style:{color:a?r.glow:"var(--color-text-secondary)"},children:[n.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:r.glow,boxShadow:a?`0 0 8px ${r.glow}60`:"none"}}),n.jsx("span",{className:"font-medium",children:r.name}),a&&n.jsx("span",{className:"ml-auto text-xs opacity-60",children:"✓"})]},t)})})]})]}),n.jsx(_e,{audioLevel:p?0:J,speaker:p?"idle":Ee,size:260}),n.jsx("div",{className:"mt-8 w-full max-w-lg px-4",children:n.jsx(Qe,{messages:E,isListening:D&&!p})}),n.jsxs("div",{className:"absolute bottom-12 flex items-center gap-6",children:[n.jsx("button",{onClick:Le,className:"rounded-full p-4 transition-colors",style:{backgroundColor:p?"var(--color-error)":"var(--color-bg-tertiary)",color:"var(--color-text)"},title:p?"Unmute":"Mute",children:p?n.jsx(Je,{className:"h-6 w-6"}):n.jsx(ze,{className:"h-6 w-6"})}),n.jsx("button",{onClick:be,className:"rounded-full p-4 transition-colors",style:{backgroundColor:"var(--color-error)",color:"var(--color-text)"},title:"End call",children:n.jsx(He,{className:"h-6 w-6"})})]})]})]})]})}export{st as VoiceOverlay};
|
|
16
|
+
`})]})]})}const Ce={default:{name:"Default",description:"F5-TTS base voice",gradient:"radial-gradient(circle at 35% 35%, #c084fc, #a855f7, #7c3aed)",glow:"#a855f7"}},ne=[{gradient:"radial-gradient(circle at 35% 35%, #93c5fd, #3b82f6, #1d4ed8)",glow:"#3b82f6"},{gradient:"radial-gradient(circle at 35% 35%, #fbbf24, #f59e0b, #b45309)",glow:"#f59e0b"},{gradient:"radial-gradient(circle at 35% 35%, #5eead4, #14b8a6, #0f766e)",glow:"#14b8a6"},{gradient:"radial-gradient(circle at 35% 35%, #fda4af, #fb7185, #e11d48)",glow:"#fb7185"},{gradient:"radial-gradient(circle at 35% 35%, #a5b4fc, #818cf8, #4f46e5)",glow:"#818cf8"},{gradient:"radial-gradient(circle at 35% 35%, #fdba74, #f97316, #c2410c)",glow:"#f97316"},{gradient:"radial-gradient(circle at 35% 35%, #86efac, #22c55e, #15803d)",glow:"#22c55e"},{gradient:"radial-gradient(circle at 35% 35%, #67e8f9, #22d3ee, #0891b2)",glow:"#22d3ee"}];function ue(u){return u.map((d,i)=>{const s=Ce[d];if(s)return{id:d,...s};const j=ne[i%ne.length],O=d.charAt(0).toUpperCase()+d.slice(1);return{id:d,name:O,description:"Cloned voice",gradient:j.gradient,glow:j.glow}})}function ie(u){const d=Ce[u];if(d)return{name:d.name,glow:d.glow};const i=ne.findIndex((j,O)=>O===u.length%ne.length),s=ne[i>=0?i:0];return{name:u.charAt(0).toUpperCase()+u.slice(1),glow:s.glow}}function Ge({currentVoice:u,onSelect:d,onPreview:i}){const[s,j]=e.useState([]),[O,S]=e.useState(!0),[m,V]=e.useState(0),[p,q]=e.useState(!1),[D,T]=e.useState(0),L=e.useRef(0),P=e.useRef(null);e.useEffect(()=>{(async()=>{var l;S(!0);try{const x=await le("/api/voice/voices");if(x.ok){const C=await x.json(),f=(l=C.voices)!=null&&l.length?C.voices:["default"],$=ue(f);if(j($),u){const re=$.findIndex(Y=>Y.id===u);re>=0&&V(re)}}else j(ue(["default"]))}catch{j(ue(["default"]))}finally{S(!1)}})()},[]);const h=s[m]||s[0],N=e.useCallback(l=>{V(Math.max(0,Math.min(s.length-1,l)))},[s.length]),E=e.useCallback(()=>N(m-1),[m,N]),M=e.useCallback(()=>N(m+1),[m,N]);e.useEffect(()=>{const l=x=>{x.key==="ArrowLeft"&&E(),x.key==="ArrowRight"&&M(),x.key==="Enter"&&d(s[m].id)};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[m,E,M,d,s]);const J=l=>{q(!0),L.current=l.clientX,T(0)},I=l=>{p&&T(l.clientX-L.current)},b=()=>{p&&(q(!1),D>60?E():D<-60&&M(),T(0))};return O||s.length===0?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full select-none",children:[n.jsx("div",{className:"w-8 h-8 border-2 border-accent border-t-transparent rounded-full animate-spin mb-4"}),n.jsx("p",{className:"text-sm text-text-muted",children:"Loading voices..."})]}):n.jsxs("div",{className:"flex flex-col items-center justify-center h-full select-none",children:[n.jsx("h2",{className:"text-xl font-semibold text-text mb-2",children:"Choose a voice"}),n.jsx("p",{className:"text-sm text-text-muted mb-10",children:s.length>1?`${s.length} cloned voices available`:"Swipe or use arrow keys"}),n.jsxs("div",{ref:P,className:"relative flex items-center justify-center w-full",style:{height:280,touchAction:"pan-y"},onPointerDown:J,onPointerMove:I,onPointerUp:b,onPointerLeave:b,children:[m>0&&n.jsx("button",{onClick:E,className:"absolute left-4 z-10 rounded-full p-2 text-text-muted hover:text-text hover:bg-bg-tertiary transition-colors",children:n.jsx(Pe,{size:28})}),n.jsx("div",{className:"relative",style:{width:220,height:220},children:s.map((l,x)=>{const C=x-m,f=x===m,$=p?D*.3:0;return n.jsxs("div",{className:"absolute inset-0 transition-all",style:{transitionDuration:p?"0ms":"400ms",transitionTimingFunction:"cubic-bezier(0.4, 0, 0.2, 1)",transform:`translateX(${C*260+$}px) scale(${f?1:.7})`,opacity:Math.abs(C)>1?0:f?1:.4,zIndex:f?10:1,pointerEvents:f?"auto":"none"},children:[n.jsx("div",{className:"absolute inset-0 rounded-full blur-2xl transition-opacity duration-500",style:{background:l.glow,opacity:f?.3:0,transform:"scale(1.2)"}}),n.jsx("div",{className:"w-full h-full rounded-full shadow-2xl",style:{background:l.gradient,boxShadow:f?`0 0 60px ${l.glow}40`:"none"}}),n.jsx("div",{className:"absolute rounded-full",style:{top:"12%",left:"18%",width:"35%",height:"35%",background:"radial-gradient(circle, rgba(255,255,255,0.4) 0%, transparent 70%)"}})]},l.id)})}),m<s.length-1&&n.jsx("button",{onClick:M,className:"absolute right-4 z-10 rounded-full p-2 text-text-muted hover:text-text hover:bg-bg-tertiary transition-colors",children:n.jsx(Fe,{size:28})})]}),n.jsxs("div",{className:"mt-8 text-center",children:[n.jsx("h3",{className:"text-2xl font-bold text-text mb-1",children:h.name}),n.jsx("p",{className:"text-sm text-text-secondary",children:h.description})]}),i&&n.jsxs("button",{onClick:()=>i(h.id),className:"mt-4 flex items-center gap-2 rounded-full px-4 py-2 text-xs font-medium text-text-secondary hover:text-text hover:bg-bg-tertiary transition-colors",children:[n.jsx(Be,{size:14}),"Preview"]}),n.jsx("div",{className:"flex items-center gap-2 mt-6",children:s.map((l,x)=>n.jsx("button",{onClick:()=>N(x),className:"rounded-full transition-all duration-300",style:{width:x===m?10:6,height:x===m?10:6,backgroundColor:x===m?h.glow:"var(--color-border)",boxShadow:x===m?`0 0 8px ${h.glow}80`:"none"}},l.id))}),n.jsxs("button",{onClick:()=>d(h.id),className:"mt-10 w-72 rounded-full py-3.5 text-base font-semibold transition-all duration-200",style:{background:`linear-gradient(135deg, ${h.glow}30, ${h.glow}15)`,border:`1px solid ${h.glow}40`,color:"var(--color-text)"},onMouseEnter:l=>{l.currentTarget.style.background=`linear-gradient(135deg, ${h.glow}50, ${h.glow}25)`,l.currentTarget.style.boxShadow=`0 0 20px ${h.glow}30`},onMouseLeave:l=>{l.currentTarget.style.background=`linear-gradient(135deg, ${h.glow}30, ${h.glow}15)`,l.currentTarget.style.boxShadow="none"},children:["Start with ",h.name]})]})}ue(["default"]);const We="/ollama",Ye="kimi-k2.6:cloud";function Ze(u,d){const i=[];i.push({role:"system",content:d});for(const s of u)s.role==="framework"?i.push({role:"user",content:s.content}):i.push({role:s.role,content:s.content});return i}async function Ke(u,d,i,s){var T,L,P,h,N,E,M,J,I;const j=(s==null?void 0:s.model)||Ye,O=Ze(u,d),S=await fetch(`${We}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:j,messages:O,stream:!0}),signal:s!=null&&s.signal?AbortSignal.any([s.signal,AbortSignal.timeout(12e4)]):AbortSignal.timeout(12e4)});if(!S.ok){const b=await S.text().catch(()=>S.statusText);throw new Error(`Ollama error ${S.status}: ${b}`)}if(!S.body)throw new Error("No response body from Ollama");const m=S.body.getReader(),V=new TextDecoder;let p="",q="",D="";try{for(;;){const{done:b,value:l}=await m.read();if(b)break;p+=V.decode(l,{stream:!0});const x=p.split(`
|
|
17
|
+
`);p=x.pop()||"";for(const C of x)if(C.trim())try{const f=JSON.parse(C);if((T=f.message)!=null&&T.thinking&&(D+=f.message.thinking,(L=i.onThinking)==null||L.call(i,f.message.thinking)),(P=f.message)!=null&&P.content&&(q+=f.message.content,i.onToken(f.message.content)),f.done){(h=i.onDone)==null||h.call(i,{totalDuration:f.total_duration||0,promptTokens:f.prompt_eval_count||0,evalTokens:f.eval_count||0});return}}catch{}}if(p+=V.decode(),p.trim())try{const b=JSON.parse(p.trim());if((N=b.message)!=null&&N.content&&i.onToken(b.message.content),(E=b.message)!=null&&E.thinking&&((M=i.onThinking)==null||M.call(i,b.message.thinking)),b.done){(J=i.onDone)==null||J.call(i,{totalDuration:b.total_duration||0,promptTokens:b.prompt_eval_count||0,evalTokens:b.eval_count||0});return}}catch{}(I=i.onDone)==null||I.call(i,{totalDuration:0,promptTokens:0,evalTokens:0})}finally{m.releaseLock()}}let et=0;const xe=()=>`voice-msg-${Date.now()}-${++et}`,ke=u=>u.replace(/<(?:laugh|chuckle|sigh|cough|sniffle|groan|yawn|gasp)>/gi,"").replace(/\s{2,}/g," ").trim(),Ae=u=>u.replace(/```[\s\S]*?```/g,"").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/^#+\s+/gm,"").replace(/^[-*]\s+/gm,"").replace(/\n{2,}/g," ").trim(),je=u=>u.replace(/(?:Let me |I'll |I will |I'm going to )(?:use|call|check|run|invoke|execute|try)(?: the)? \w[\w_]*(?: tool)?(?:\s+(?:to|for|and)\b[^.!?]*)?[.!]?\s*/gi,"").replace(/\b(?:Using|Calling|Running|Checking|Invoking|Executing) (?:the )?\w[\w_]*(?: tool)?(?:\s+(?:to|for)\b[^.!?]*)?[.!]?\s*/gi,"").replace(/\b\w[\w_]*(?:_\w+)+\b/g,"").replace(/\s{2,}/g," ").trim();function st({onClose:u}){const[d,i]=e.useState(!1),s=localStorage.getItem("titan-voice")||"",[j,O]=e.useState(s?"active":"picking"),[S,m]=e.useState(s),V=e.useRef(s),[p,q]=e.useState(!1),[D,T]=e.useState(!1),[L,P]=e.useState(!1),[h,N]=e.useState(!1),[E,M]=e.useState([]),[J,I]=e.useState(0),[b,l]=e.useState(""),[x,C]=e.useState(null),[f,$]=e.useState(!1),[re,Y]=e.useState([]),R=e.useRef(null),Z=e.useRef(null),we=e.useRef(null),oe=e.useRef(null),F=e.useRef(null),X=e.useRef(""),se=e.useRef(0);e.useRef(void 0);const H=e.useRef(null),U=e.useRef(null),B=e.useRef(null),K=e.useRef(null),Q=e.useRef(null),ye=e.useRef(0),G=e.useRef(!1),de=e.useRef(null);e.useRef(typeof navigator<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent));const fe=e.useCallback(t=>new Promise(async r=>{var o,g;const a=B.current;if(a&&a.state!=="closed")try{a.state==="suspended"&&await a.resume();const w=await(await fetch(t)).arrayBuffer(),v=await a.decodeAudioData(w);try{(o=K.current)==null||o.stop()}catch{}const k=a.createBufferSource();k.buffer=v,k.connect(a.destination),K.current=k,k.onended=()=>{URL.revokeObjectURL(t),r()},k.start(0);try{(g=R.current)==null||g.stop()}catch{}console.log("[Voice] Playing via Web Audio API");return}catch(c){console.warn("[Voice] Web Audio failed:",c)}try{const c=U.current||new Audio;U.current=c,c.setAttribute("playsinline",""),c.setAttribute("autoplay",""),H.current=c,c.onplay=()=>{var w;try{(w=R.current)==null||w.stop()}catch{}},c.onended=()=>{URL.revokeObjectURL(t),r()},c.onerror=w=>{console.warn("[Voice] Audio element error:",w),URL.revokeObjectURL(t),r()},c.src=t,await c.play(),console.log("[Voice] Playing via Audio element")}catch(c){console.warn("[Voice] Audio element play failed:",c),URL.revokeObjectURL(t),r()}}),[]),ee=e.useRef(!1),ge=e.useRef(!1),W=e.useRef("picking");e.useEffect(()=>{ee.current=p},[p]),e.useEffect(()=>{ge.current=L},[L]),e.useEffect(()=>{W.current=j},[j]),e.useEffect(()=>{(async()=>{var t;try{const r=await le("/api/voice/voices");if(r.ok){const a=await r.json();if((t=a.voices)!=null&&t.length){if(Y(a.voices),s&&!a.voices.includes(s)){const o=a.voices[0];m(o),V.current=o,localStorage.setItem("titan-voice",o)}}else Y(["default"])}}catch{Y(["default"])}})()},[]),e.useEffect(()=>{requestAnimationFrame(()=>i(!0))},[]),e.useEffect(()=>()=>{var t,r,a,o;W.current="picking";try{(t=R.current)==null||t.stop()}catch{}R.current=null,(r=oe.current)==null||r.getTracks().forEach(g=>g.stop()),(a=Z.current)==null||a.close(),(o=Q.current)==null||o.abort(),F.current&&clearTimeout(F.current),de.current&&(clearInterval(de.current),de.current=null),cancelAnimationFrame(se.current),cancelAnimationFrame(ye.current)},[]),e.useEffect(()=>{if(!f)return;const t=()=>$(!1),r=setTimeout(()=>document.addEventListener("click",t),0);return()=>{clearTimeout(r),document.removeEventListener("click",t)}},[f]);const te=e.useCallback(async()=>{var t;try{let r=function(){c.getByteFrequencyData(w);let v=0;for(let y=0;y<w.length;y++)v+=w[y];const k=v/w.length/255;I(k),se.current=requestAnimationFrame(r)};if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia)){console.warn("[Voice] getUserMedia not available — may need HTTPS on mobile");return}const a=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});oe.current=a;let o=Z.current;(!o||o.state==="closed")&&(o=new(window.AudioContext||window.webkitAudioContext)),o.state==="suspended"&&await o.resume(),Z.current=o;const g=o.createMediaStreamSource(a),c=o.createAnalyser();c.fftSize=256,c.smoothingTimeConstant=.8,g.connect(c),we.current=c;const w=new Uint8Array(c.frequencyBinCount);se.current=requestAnimationFrame(r)}catch(r){console.error("Mic access denied:",r)}},[]),ae=e.useCallback(()=>{var t,r;cancelAnimationFrame(se.current),cancelAnimationFrame(ye.current),(t=oe.current)==null||t.getTracks().forEach(a=>a.stop()),(r=Z.current)==null||r.close(),oe.current=null,Z.current=null,we.current=null,I(0)},[]),me=e.useCallback(()=>{var a;const t=window.SpeechRecognition||window.webkitSpeechRecognition;if(!t){console.error("Speech recognition not supported");return}try{(a=R.current)==null||a.stop()}catch{}const r=new t;r.continuous=!0,r.interimResults=!0,r.lang="en-US",r.onresult=o=>{if(ge.current)return;let g="",c="";for(let w=o.resultIndex;w<o.results.length;w++){const v=o.results[w];v[0].confidence>0&&v[0].confidence<.5||(v.isFinal?c+=v[0].transcript:g+=v[0].transcript)}if(g&&l(g),c){X.current+=c,l(""),F.current&&clearTimeout(F.current);const v=X.current.trim().split(/\s+/).length<10?400:700;F.current=setTimeout(()=>{const k=X.current.trim();k&&(X.current="",Re(k))},v)}},r.onend=()=>{if(!ee.current&&!ge.current&&W.current==="active")try{r.start()}catch{}T(!1)},r.onstart=()=>{T(!0)},r.onerror=o=>{console.error("Speech recognition error:",o.error),o.error==="not-allowed"?(C("Mic access denied — check browser permissions"),T(!1)):o.error==="network"?(C("Speech recognition network error"),setTimeout(()=>{if(!ee.current&&W.current==="active")try{r.start()}catch{}},2e3)):o.error==="audio-capture"?(C("Mic not available — is another app using it?"),T(!1)):o.error!=="no-speech"&&console.error("STT error:",o.error)},R.current=r;try{r.start()}catch{}},[]),ce=e.useCallback(()=>{var r;try{(r=K.current)==null||r.stop()}catch{}K.current=null;const t=H.current;t&&(t.pause(),t.src="",H.current=null),"speechSynthesis"in window&&window.speechSynthesis.cancel(),P(!1),I(0)},[]);e.useEffect(()=>{if(s&&j==="active"){try{new Audio("data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=").play().catch(()=>{})}catch{}te(),me()}},[]),e.useCallback(()=>{const t=[];let r=0,a=!1,o=!1,g=null,c=null;const w=Date.now(),v=setInterval(()=>{if(!a){const A=(Date.now()-w)/600;I(.45+Math.sin(A*Math.PI*2)*.15)}},100),k=()=>{clearInterval(v),I(0)},y=()=>{if(a){k();return}if(r<t.length){const A=t[r++];fe(A).then(()=>y()).catch(()=>y())}else o?(k(),g&&g()):c=y};return{push(A){if(t.push(A),c){const z=c;c=null,z()}},finish(){if(o=!0,c){const A=c;c=null,A()}},start(A){g=A,y()},cancel(){var A;a=!0;try{(A=K.current)==null||A.stop()}catch{}H.current&&(H.current.pause(),H.current.src=""),k()},get length(){return t.length}}},[]);const Re=e.useCallback(async t=>{var c,w,v,k;if(G.current)return;G.current=!0,ce(),(c=Q.current)==null||c.abort(),M(y=>[...y,{id:xe(),role:"user",text:t}]),N(!0),T(!1),C(null);try{(w=R.current)==null||w.stop()}catch{}const r=new AbortController;Q.current=r;const a=V.current||"default";let o="",g="";try{const y=E.map(_=>({role:_.role,content:_.text,timestamp:(_.id,Date.now())}));await Ke([...y,{role:"user",content:t,timestamp:Date.now()}],"You are TITAN, a helpful AI assistant. Keep responses concise and natural for voice conversation. Use short sentences.",{onToken:_=>{g+=_;const ve=je(ke(Ae(g)));o?M(he=>he.map(pe=>pe.id===o?{...pe,text:ve}:pe)):(o=xe(),M(he=>[...he,{id:o,role:"assistant",text:ve}])),N(!1)}},{signal:r.signal});const A=je(ke(Ae(g)));if(!A){G.current=!1;try{(v=R.current)==null||v.start()}catch{}return}P(!0);const z=await fetch("/api/voice/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:A.slice(0,500),voice:a}),signal:AbortSignal.timeout(12e4)});if(!z.ok)throw new Error(`F5-TTS error: ${z.status}`);const Ve=await z.blob(),De=URL.createObjectURL(Ve);await fe(De),P(!1),I(0),X.current="",setTimeout(()=>{var _;if(G.current=!1,!ee.current&&W.current==="active")try{(_=R.current)==null||_.start()}catch{}},500)}catch(y){if((y==null?void 0:y.name)==="AbortError"&&!Q.current)return;const A=(y==null?void 0:y.name)==="AbortError"?"Request timed out":"Connection error";C(A),setTimeout(()=>C(null),4e3),console.error("Voice processing error:",y),M(z=>[...z,{id:xe(),role:"assistant",text:"Sorry, something went wrong."}]),N(!1),P(!1),X.current="",G.current=!1;try{(k=R.current)==null||k.start()}catch{}}},[ce,fe,E]),Te=e.useCallback(async t=>{m(t),V.current=t,localStorage.setItem("titan-voice",t);try{await le("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({voice:{ttsVoice:t}})})}catch{}if(O("active"),!B.current||B.current.state==="closed"){const r=window.AudioContext||window.webkitAudioContext;B.current=new r}B.current.state==="suspended"&&B.current.resume().catch(()=>{});try{const r=B.current,a=r.createBuffer(1,1,22050),o=r.createBufferSource();o.buffer=a,o.connect(r.destination),o.start(0)}catch{}U.current||(U.current=new Audio,U.current.preload="auto"),te(),me()},[te,me]),Ne=e.useCallback(t=>{m(t),V.current=t,localStorage.setItem("titan-voice",t),$(!1),le("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({voice:{ttsVoice:t}})}).catch(()=>{})},[]),Me=e.useCallback(async t=>{try{const r=await fetch("/api/voice/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:"Hey! I'm TITAN, your AI assistant.",voice:t})});if(!r.ok)return;const a=await r.blob(),o=URL.createObjectURL(a),g=U.current||new Audio,c=()=>{URL.revokeObjectURL(o),g.src=""};g.onended=c,g.onerror=c,g.play()}catch{}},[]),be=e.useCallback(()=>{var t,r;i(!1),W.current="picking",O("picking"),(t=Q.current)==null||t.abort(),Q.current=null;try{(r=R.current)==null||r.stop()}catch{}R.current=null,ce(),ae(),F.current&&clearTimeout(F.current),G.current=!1,setTimeout(u,200)},[u,ae,ce]),Le=e.useCallback(()=>{q(t=>{var a,o;const r=!t;if(ee.current=r,r){try{(a=R.current)==null||a.stop()}catch{}ae(),T(!1)}else{te();try{(o=R.current)==null||o.start()}catch{}}return r})},[te,ae]),Ee=L?"assistant":h?"thinking":D?"user":"idle",Ie=p?"Muted":L?"TITAN is speaking...":h?"Thinking...":D?b?`"${b}"`:"Listening...":"Connected",Oe=L?"var(--color-purple-light)":h?"var(--color-warning)":D?"var(--color-cyan)":"var(--color-text-muted)";return n.jsxs(n.Fragment,{children:[n.jsx("audio",{ref:t=>{t&&!U.current&&(U.current=t)},autoPlay:!0,playsInline:!0,style:{position:"absolute",width:0,height:0,opacity:0}}),n.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center backdrop-blur-sm transition-all duration-200",style:{backgroundColor:"rgba(9, 9, 11, 0.95)",opacity:d?1:0,transform:d?"scale(1)":"scale(0.95)"},children:[n.jsx("button",{onClick:be,className:"absolute right-6 top-6 rounded-full p-2 transition-colors hover:bg-bg-tertiary z-20 text-text-secondary",children:n.jsx($e,{className:"h-6 w-6"})}),j==="picking"&&n.jsx("div",{className:"w-full h-full",children:n.jsx(Ge,{currentVoice:S||void 0,onSelect:Te,onPreview:Me})}),j==="active"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mb-6 text-center",children:[n.jsx("div",{className:"text-base font-medium mb-0.5 transition-colors duration-500 max-w-md truncate px-4",style:{color:Oe},children:Ie}),x&&n.jsx("div",{className:"text-xs font-medium mt-1 animate-pulse text-error",children:x}),n.jsxs("div",{className:"relative mt-2",children:[n.jsxs("button",{onClick:()=>$(t=>!t),className:"inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium transition-colors hover:bg-bg-tertiary",style:{color:ie(S||"tara").glow},children:[n.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:ie(S||"tara").glow}}),ie(S||"tara").name,n.jsx(Ue,{className:"h-3 w-3"})]}),f&&n.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 mt-1 rounded-xl border border-bg-tertiary bg-bg-secondary/95 backdrop-blur-sm p-1.5 shadow-xl z-30",style:{minWidth:180},children:re.map(t=>{const r=ie(t),a=t===(S||"tara");return n.jsxs("button",{onClick:()=>Ne(t),className:"flex items-center gap-2.5 w-full rounded-lg px-3 py-2 text-left text-sm transition-colors hover:bg-bg-tertiary",style:{color:a?r.glow:"var(--color-text-secondary)"},children:[n.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:r.glow,boxShadow:a?`0 0 8px ${r.glow}60`:"none"}}),n.jsx("span",{className:"font-medium",children:r.name}),a&&n.jsx("span",{className:"ml-auto text-xs opacity-60",children:"✓"})]},t)})})]})]}),n.jsx(_e,{audioLevel:p?0:J,speaker:p?"idle":Ee,size:260}),n.jsx("div",{className:"mt-8 w-full max-w-lg px-4",children:n.jsx(Qe,{messages:E,isListening:D&&!p})}),n.jsxs("div",{className:"absolute bottom-12 flex items-center gap-6",children:[n.jsx("button",{onClick:Le,className:"rounded-full p-4 transition-colors",style:{backgroundColor:p?"var(--color-error)":"var(--color-bg-tertiary)",color:"var(--color-text)"},title:p?"Unmute":"Mute",children:p?n.jsx(Je,{className:"h-6 w-6"}):n.jsx(ze,{className:"h-6 w-6"})}),n.jsx("button",{onClick:be,className:"rounded-full p-4 transition-colors",style:{backgroundColor:"var(--color-error)",color:"var(--color-text)"},title:"End call",children:n.jsx(He,{className:"h-6 w-6"})})]})]})]})]})}export{st as VoiceOverlay};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as n,r as t,aU as x,j as e,C as m,M as o}from"./index-Cml2x9pA.js";import{P as u}from"./PageHeader-DdrbS1aq.js";import{R as h}from"./refresh-cw-C-iZkzuS.js";import"./chevron-right-DbLSHmff.js";function v(){const{toast:l}=n(),[s,c]=t.useState(null),[r,i]=t.useState(!0),d=t.useCallback(async()=>{i(!0);try{const a=await x();c(a)}catch(a){l("error",`Couldn't load VRAM snapshot — try again. (${a.message})`)}i(!1)},[l]);return t.useEffect(()=>{d()},[d]),e.jsxs("div",{className:"space-y-4",children:[e.jsx(u,{title:"VRAM Monitor",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Infra"},{label:"VRAM"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:d,disabled:r,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#27272a] text-[#a1a1aa] text-sm font-medium hover:bg-[#3f3f46] disabled:opacity-50",children:[e.jsx(h,{className:`w-4 h-4 ${r?"animate-spin":""}`})," Refresh"]})}),(s==null?void 0:s.gpu)&&e.jsxs("div",{className:"p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(m,{className:"w-4 h-4 text-[#6366f1]"}),e.jsx("span",{className:"text-sm font-medium text-[#e4e4e7]",children:s.gpu.gpuName}),e.jsxs("span",{className:"text-xs text-[#52525b]",children:["(",s.gpu.vendor,")"]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[e.jsxs("div",{className:"p-2 rounded bg-[#27272a]/50",children:[e.jsx("div",{className:"text-[#52525b]",children:"Total"}),e.jsxs("div",{className:"text-[#e4e4e7]",children:[(s.gpu.totalMB/1024).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"p-2 rounded bg-[#27272a]/50",children:[e.jsx("div",{className:"text-[#52525b]",children:"Used"}),e.jsxs("div",{className:"text-[#e4e4e7]",children:[(s.gpu.usedMB/1024).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"p-2 rounded bg-[#27272a]/50",children:[e.jsx("div",{className:"text-[#52525b]",children:"Free"}),e.jsxs("div",{className:"text-[#e4e4e7]",children:[(s.gpu.freeMB/1024).toFixed(1)," GB"]})]})]}),e.jsx("div",{className:"mt-2 h-2 rounded-full bg-[#27272a] overflow-hidden",children:e.jsx("div",{className:"h-full bg-[#6366f1] rounded-full",style:{width:`${s.gpu.usedMB/s.gpu.totalMB*100}%`}})})]}),s&&s.activeLeases.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium text-[#e4e4e7]",children:"Active Leases"}),s.activeLeases.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{className:"w-3.5 h-3.5 text-[#6366f1]"}),e.jsx("span",{className:"text-xs text-[#e4e4e7]",children:a.service})]}),e.jsxs("span",{className:"text-xs text-[#52525b]",children:[(a.reservedMB/1024).toFixed(1)," GB"]})]},a.id))]})]})}export{v as default};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{r as d,j as e,X as ee,b as Q,bD as te}from"./index-Cml2x9pA.js";import{A as q,m as V}from"./Modal-ybPGvlQs.js";import"./clsx-B-dksMZM.js";const ne={purpose:"#a78bfa",hunger:"#fbbf24",curiosity:"#22d3ee",safety:"#34d399",social:"#f472b6"},ie={purpose:"Purpose",hunger:"Hunger",curiosity:"Curiosity",safety:"Safety",social:"Social"};function Y(t){return ne[t==null?void 0:t.toLowerCase()]||"#a1a1aa"}const se=new Set(["soma:proposal","turn:pre","tool:call","goal:subtask:ready","initiative:start","initiative:complete","pressure:threshold","goal:completed"]);function J(t,i=Date.now()){let n;if(typeof t=="number"&&!Number.isNaN(t)&&t>0)n=t;else if(typeof t=="string"){const h=Date.parse(t);n=Number.isNaN(h)?i:h}else n=i;const r=Math.max(0,Math.floor((i-n)/1e3));if(r<10)return"just now";if(r<60)return`${r}s ago`;const l=Math.floor(r/60);if(l<60)return`${l}m ago`;const o=Math.floor(l/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}const O=100,re=500;function X(){try{return localStorage.getItem("titan-token")||localStorage.getItem("titan_token")||""}catch{return""}}function ae(){const[t,i]=d.useState([]),[n,r]=d.useState([]),[l,o]=d.useState(!1),[h,y]=d.useState(!1),[s,m]=d.useState(0),[w,g]=d.useState(null),f=d.useRef(null),R=d.useCallback(x=>{if(!Array.isArray(x))return;const j=x.map(a=>{var S;return{id:a.id,label:a.label||ie[(S=a.id)==null?void 0:S.toLowerCase()]||a.id,satisfaction:a.satisfaction??1,setpoint:a.setpoint??.7,pressure:a.pressure??0,weight:a.weight,description:a.description}});i(j)},[]),M=d.useCallback(()=>{f.current&&f.current.close();const x=X(),j=`/api/watch/stream${x?`?token=${encodeURIComponent(x)}`:""}`,a=new EventSource(j);f.current=a;const S=Date.now();a.onopen=()=>{o(!0),y(!1)},a.onerror=()=>{o(!1),Date.now()-S>re&&y(!0)},a.onmessage=H=>{var T,N;try{const c=JSON.parse(H.data);if(c.type==="snapshot"){g({drives:c.drives||[],totalPressure:c.totalPressure||0,dominantDrives:c.dominantDrives||[],timestamp:c.timestamp||Date.now()}),R(c.drives);return}if(c.type==="event"){if(c.topic==="drive:tick"){const D=((T=c.raw)==null?void 0:T.drives)??[];R(D),m(Date.now());return}if(c.topic==="initiative:round"){const D=(N=c.raw)==null?void 0:N.subtaskTitle,F={id:c.id,timestamp:c.timestamp,topic:c.topic,kind:c.kind,icon:c.icon,captionTitan:c.captionTitan,captionControl:c.captionControl,detail:c.detail,raw:c.raw};r(v=>{const p=D?v.filter(b=>{var k;return!(b.topic==="initiative:round"&&((k=b.raw)==null?void 0:k.subtaskTitle)===D)}):v.filter(b=>b.topic!=="initiative:round"),A=[F,...p];return A.length>O&&(A.length=O),A}),m(Date.now());return}const $={id:c.id,timestamp:c.timestamp,topic:c.topic,kind:c.kind,icon:c.icon,captionTitan:c.captionTitan,captionControl:c.captionControl,detail:c.detail,raw:c.raw};r(D=>{const F=[$,...D];return F.length>O&&(F.length=O),F}),m(Date.now())}}catch{}}},[R]),I=d.useCallback(()=>{f.current&&f.current.close(),M()},[M]);return d.useEffect(()=>{const x=X(),j={};x&&(j.Authorization=`Bearer ${x}`),fetch("/api/watch/snapshot",{headers:j}).then(a=>a.status===401?(localStorage.removeItem("titan-token"),localStorage.removeItem("titan_token"),window.location.reload(),null):a.ok?a.json():null).then(a=>{a&&!a.error&&(g(a),R(a.drives))}).catch(()=>{})},[R]),d.useEffect(()=>(M(),()=>{var x;(x=f.current)==null||x.close(),f.current=null}),[M]),{drives:t,events:n,connected:l,reconnecting:h,lastActivity:s,snapshot:w,reconnect:I}}function oe(t){for(const i of t)if(se.has(i.topic))return i;return t[0]||null}function le({events:t,voice:i}){const n=d.useMemo(()=>oe(t),[t]),r=n?i==="titan"?n.captionTitan:n.captionControl:null;return e.jsxs("div",{style:{position:"relative",minHeight:80},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255, 255, 255, 0.35)",marginBottom:10,fontWeight:600},children:"What I'm doing"}),e.jsx(q,{mode:"wait",initial:!1,children:e.jsx(V.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.3},style:{fontSize:"clamp(18px, 2.4vw, 24px)",fontWeight:500,lineHeight:1.35,color:r?"rgba(255, 255, 255, 0.95)":"rgba(255, 255, 255, 0.45)"},children:r||"Standing by."},(n==null?void 0:n.id)||"idle")}),n&&e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12,fontSize:11,color:"rgba(255, 255, 255, 0.35)",flexWrap:"wrap"},children:[e.jsx("span",{children:J(n.timestamp)}),n.detail&&e.jsxs("span",{children:["· ",n.detail]})]})]})}const ce={drive:"var(--color-purple-light)",soma:"#c084fc",tool:"#60a5fa",goal:"var(--color-emerald)",channel:"#fb7185",agent:"#c084fc",health:"#fbbf24",memory:"#e879f9",system:"#9ca3af"};function de({events:t,voice:i,onEventClick:n}){const[,r]=d.useState(0);d.useEffect(()=>{const o=setInterval(()=>r(h=>h+1),2e4);return()=>clearInterval(o)},[]);const l=d.useMemo(()=>t.slice(0,80),[t]);return l.length===0?e.jsx("div",{style:{color:"rgba(255,255,255,0.35)",fontSize:13,fontStyle:"italic",padding:"24px 16px",textAlign:"center"},children:"Listening for TITAN to do something…"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,overflow:"hidden"},children:e.jsx(q,{initial:!1,children:l.map((o,h)=>{const y=i==="titan"?o.captionTitan:o.captionControl,s=ce[o.kind]||"#9ca3af",m=h===0;return e.jsxs(V.div,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.35,ease:"easeOut"},onClick:()=>n==null?void 0:n(o),style:{display:"flex",alignItems:"flex-start",gap:12,padding:"10px 12px",borderRadius:10,background:m?`${s}14`:"rgba(255, 255, 255, 0.015)",borderLeft:`2px solid ${s}`,fontSize:13,lineHeight:1.35,transition:"background 0.2s, transform 0.15s",cursor:n?"pointer":"default"},onMouseEnter:w=>{n&&(w.currentTarget.style.background=`${s}22`)},onMouseLeave:w=>{w.currentTarget.style.background=m?`${s}14`:"rgba(255, 255, 255, 0.015)"},title:`Click for details · ${o.topic}`,children:[e.jsx("div",{style:{fontSize:15,flexShrink:0,width:20,textAlign:"center",marginTop:1},children:o.icon}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{color:"rgba(255,255,255,0.92)"},children:y}),o.detail&&e.jsx("div",{style:{color:"rgba(255,255,255,0.45)",fontSize:11,marginTop:2,lineHeight:1.3},children:o.detail})]}),e.jsx("div",{style:{color:"rgba(255,255,255,0.35)",fontSize:11,flexShrink:0,fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap",marginTop:1},children:J(o.timestamp)})]},o.id)})})})}function P(t,i){const n=t.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);return n?`rgba(${parseInt(n[1],16)}, ${parseInt(n[2],16)}, ${parseInt(n[3],16)}, ${i})`:`rgba(160, 160, 160, ${i})`}function pe({drives:t,excited:i=!1,reducedMotion:n=!1}){const r=d.useRef(null),l=d.useRef(t),o=d.useRef(i),h=d.useRef(null);return d.useEffect(()=>{l.current=t},[t]),d.useEffect(()=>{o.current=i},[i]),d.useEffect(()=>{const y=r.current;if(!y)return;const s=y.getContext("2d",{alpha:!0});if(!s)return;const m=Math.min(window.devicePixelRatio||1,2),w=()=>{const I=y.getBoundingClientRect();y.width=Math.max(2,I.width*m),y.height=Math.max(2,I.height*m),s.setTransform(m,0,0,m,0,0)};w();const g=new ResizeObserver(w);g.observe(y);const f=[],R=60,M=()=>{h.current=requestAnimationFrame(M);const I=y.getBoundingClientRect(),x=I.width,j=I.height;if(x<10||j<10)return;const a=x/2,S=j/2,H=Math.min(x,j)*.11,T=Math.min(x,j)*.34,N=performance.now()/1e3,c=l.current;s.clearRect(0,0,x,j);const $=s.createRadialGradient(a,S,0,a,S,Math.min(x,j)*.55),D=n?.08:.08+.03*Math.sin(N*.5);$.addColorStop(0,`rgba(255, 255, 255, ${D*2})`),$.addColorStop(.3,`rgba(167, 139, 250, ${D})`),$.addColorStop(1,"rgba(167, 139, 250, 0)"),s.fillStyle=$,s.fillRect(0,0,x,j);const F=Math.max(c.length,5);for(let v=0;v<c.length;v++){const p=c[v],A=v/F*Math.PI*2-Math.PI/2,b=a+Math.cos(A)*T,k=S+Math.sin(A)*T,W=Math.min(1,(p.pressure||0)*3),G=n?0:.35+W*1.4,_=n?0:.04+W*.15,z=H*(.75+_*Math.sin(N*G+v*1.3)),C=Y(p.id),E=z*2.8,B=s.createRadialGradient(b,k,0,b,k,E);B.addColorStop(0,P(C,.35)),B.addColorStop(.35,P(C,.18)),B.addColorStop(1,P(C,0)),s.fillStyle=B,s.beginPath(),s.arc(b,k,E,0,Math.PI*2),s.fill();const L=s.createRadialGradient(b-z*.3,k-z*.3,0,b,k,z);L.addColorStop(0,P(C,.95)),L.addColorStop(.55,P(C,.55)),L.addColorStop(1,P(C,.2)),s.fillStyle=L,s.beginPath(),s.arc(b,k,z,0,Math.PI*2),s.fill(),W>.1&&(s.strokeStyle=P(C,.6+.3*Math.sin(N*3+v)),s.lineWidth=1.5,s.beginPath(),s.arc(b,k,z*1.05,0,Math.PI*2),s.stroke()),s.font='600 10px -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif',s.textAlign="center",s.fillStyle="rgba(255,255,255,0.65)",s.fillText(p.label.toUpperCase(),b,k+z+18),s.font="11px -apple-system, system-ui",s.fillStyle="rgba(255,255,255,0.35)",s.fillText(`${Math.round((p.satisfaction||0)*100)}%`,b,k+z+32);const Z=W*.25+(o.current?.03:0);!n&&f.length<R&&Math.random()<Z&&f.push({sourceIdx:v,phase:0,color:C,size:2+Math.random()*2})}if(!n)for(let v=f.length-1;v>=0;v--){const p=f[v];if(p.phase+=.012,p.phase>=1){f.splice(v,1);continue}if(!c[p.sourceIdx]){f.splice(v,1);continue}const b=p.sourceIdx/F*Math.PI*2-Math.PI/2,k=a+Math.cos(b)*T,W=S+Math.sin(b)*T,G=(k+a)/2+Math.sin(b+Math.PI/2)*20,_=(W+S)/2+Math.cos(b+Math.PI/2)*20,z=(1-p.phase)*(1-p.phase)*k+2*(1-p.phase)*p.phase*G+p.phase*p.phase*a,C=(1-p.phase)*(1-p.phase)*W+2*(1-p.phase)*p.phase*_+p.phase*p.phase*S,E=Math.sin(p.phase*Math.PI)*.9;s.fillStyle=P(p.color,E),s.beginPath(),s.arc(z,C,p.size,0,Math.PI*2),s.fill()}if(!n){const p=N%20/20;if(p<.18){const A=H+p*Math.min(x,j)*2.5,b=(1-p/.18)*.18;s.strokeStyle=`rgba(167, 139, 250, ${b})`,s.lineWidth=1.5,s.beginPath(),s.arc(a,S,A,0,Math.PI*2),s.stroke()}}};return h.current=requestAnimationFrame(M),()=>{g.disconnect(),h.current&&cancelAnimationFrame(h.current)}},[n]),e.jsx("canvas",{ref:r,style:{width:"100%",height:"100%",display:"block"},"aria-label":"TITAN organism — 5 drives breathing"})}function he({event:t,voice:i,onClose:n}){return e.jsx(q,{children:t&&e.jsxs(e.Fragment,{children:[e.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},onClick:n,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",zIndex:99}},"backdrop"),e.jsx(V.aside,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{duration:.28,ease:[.32,.72,0,1]},style:{position:"fixed",top:0,right:0,bottom:0,width:"min(540px, 100vw)",background:"rgba(10, 12, 20, 0.96)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderLeft:"1px solid rgba(167, 139, 250, 0.15)",display:"flex",flexDirection:"column",zIndex:100,color:"#f8f9fc",boxShadow:"-20px 0 60px rgba(0,0,0,0.5)"},role:"dialog","aria-modal":"true",children:e.jsx(ue,{event:t,voice:i,onClose:n})},"panel")]})})}function ue({event:t,voice:i,onClose:n}){const r=i==="titan"?t.captionTitan:t.captionControl,l=t.raw||{};return d.useEffect(()=>{const o=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"20px 24px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{fontSize:22,width:36,height:36,borderRadius:10,background:"rgba(255,255,255,0.04)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.icon}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:17,fontWeight:600,lineHeight:1.3,marginBottom:4},children:r}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.35)",display:"flex",gap:10},children:[e.jsx("span",{children:J(t.timestamp)}),e.jsx("span",{style:{opacity:.5},children:"·"}),e.jsx("span",{style:{textTransform:"uppercase",letterSpacing:"0.1em"},children:t.kind}),e.jsx("span",{style:{opacity:.5},children:"·"}),e.jsx("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:10},children:t.topic})]})]}),e.jsx("button",{onClick:n,"aria-label":"Close",style:{background:"transparent",border:0,color:"rgba(255,255,255,0.55)",cursor:"pointer",padding:6,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(ee,{size:18})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",minHeight:0},children:[t.detail&&e.jsx(u,{label:"Detail",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.75)",lineHeight:1.5},children:t.detail})}),t.kind==="soma"&&e.jsx(ge,{raw:l}),t.kind==="goal"&&e.jsx(fe,{raw:l}),t.kind==="tool"&&e.jsx(xe,{raw:l,topic:t.topic}),t.kind==="channel"&&e.jsx(me,{raw:l,topic:t.topic}),t.kind==="drive"&&e.jsx(be,{raw:l,topic:t.topic}),(t.kind==="system"||t.kind==="agent"||t.kind==="memory"||t.kind==="health")&&e.jsx(ye,{raw:l,topic:t.topic})]}),e.jsx(ve,{label:"Raw event data",raw:l})]})}function u({label:t,children:i}){return e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600,marginBottom:8},children:t}),i]})}function ge({raw:t}){const i=t.approvalId,n=t.dominantDrives||[],r=t.shadowVerdict;return e.jsxs(e.Fragment,{children:[e.jsx(u,{label:"What drove this",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.75)"},children:[n.length?n.map(l=>l[0].toUpperCase()+l.slice(1)).join(", "):"an unspecified drive"," ","was below its setpoint. Soma filed this proposal autonomously."]})}),i&&e.jsx(u,{label:"Command Post approval",children:e.jsx("code",{style:{fontSize:11,color:"rgba(167, 139, 250, 0.9)"},children:i})}),r&&e.jsx(u,{label:"Shadow rehearsal verdict",children:e.jsx("pre",{style:{fontSize:11,lineHeight:1.4,color:"rgba(255,255,255,0.7)",whiteSpace:"pre-wrap",wordBreak:"break-word",background:"rgba(255,255,255,0.02)",padding:12,borderRadius:8},children:JSON.stringify(r,null,2)})})]})}function fe({raw:t}){const i=t.goalId,[n,r]=d.useState(null),[l,o]=d.useState(!1);if(d.useEffect(()=>{i&&(o(!0),Q(`/api/goals/${i}`).then(s=>s.ok?s.json():null).then(s=>r((s==null?void 0:s.goal)||s||null)).catch(()=>{}).finally(()=>o(!1)))},[i]),!i)return null;if(l)return e.jsx(u,{label:"Goal",children:e.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:12},children:"Loading…"})});if(!n)return e.jsx(u,{label:"Goal",children:e.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:12},children:"Goal not found (may have been deleted)."})});const h=n.subtasks||[],y=h.filter(s=>s.status==="done"||s.status==="skipped").length;return e.jsxs(u,{label:"Goal",children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,marginBottom:6},children:String(n.title||"")}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",marginBottom:12},children:[String(n.status||"")," · ",y,"/",h.length," subtasks"]}),h.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:h.map((s,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:8,background:"rgba(255,255,255,0.02)",fontSize:12},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:K(s.status),boxShadow:`0 0 6px ${K(s.status)}`,flexShrink:0}}),e.jsx("span",{style:{flex:1},children:String(s.title||"")}),e.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.35)",textTransform:"uppercase",letterSpacing:"0.1em"},children:String(s.status||"")})]},m))})]})}function K(t){switch(t){case"done":return"var(--color-emerald)";case"running":return"var(--color-cyan)";case"failed":return"var(--color-error)";case"skipped":return"var(--color-text-secondary)";case"pending":return"#fbbf24";default:return"#9ca3af"}}function xe({raw:t,topic:i}){const n=t.tool,r=t.argsPreview,l=t.durationMs,o=t.success;return e.jsxs(e.Fragment,{children:[n&&e.jsx(u,{label:"Tool",children:e.jsx("code",{style:{fontSize:12,color:"rgba(96, 165, 250, 0.9)"},children:n})}),r!==void 0&&e.jsx(u,{label:"Arguments",children:e.jsx("pre",{style:{fontSize:11,lineHeight:1.4,color:"rgba(255,255,255,0.7)",whiteSpace:"pre-wrap",wordBreak:"break-word",background:"rgba(255,255,255,0.02)",padding:12,borderRadius:8,maxHeight:300,overflowY:"auto"},children:typeof r=="string"?r:JSON.stringify(r,null,2)})}),i==="tool:result"&&e.jsx(u,{label:"Result",children:e.jsxs("div",{style:{fontSize:13,color:o?"rgba(52,211,153,0.9)":"rgba(239,68,68,0.9)"},children:[o?"✓ Completed":"✗ Failed",l!==void 0&&e.jsxs("span",{style:{color:"rgba(255,255,255,0.5)",marginLeft:8},children:["in ",l,"ms"]})]})})]})}function me({raw:t,topic:i}){const n=t.sessionId,r=t.channel,l=t.userId,o=t.message,h=t.toolsUsed||[],y=t.model,s=t.durationMs,[m,w]=d.useState(null);return d.useEffect(()=>{n&&Q(`/api/sessions/${n}`).then(g=>g.ok?g.json():null).then(g=>{const f=Array.isArray(g)?g:(g==null?void 0:g.messages)||[];w(f)}).catch(()=>{})},[n]),e.jsxs(e.Fragment,{children:[r&&e.jsx(u,{label:"Channel",children:e.jsxs("div",{style:{fontSize:13},children:[r,l&&e.jsxs("span",{style:{color:"rgba(255,255,255,0.4)"},children:[" · ",l]})]})}),o&&e.jsx(u,{label:i==="turn:pre"?"What they said":"Message",children:e.jsx("div",{style:{fontSize:13,lineHeight:1.5,color:"rgba(255,255,255,0.8)",padding:12,background:"rgba(255,255,255,0.02)",borderRadius:8},children:o})}),i==="turn:post"&&e.jsx(u,{label:"Turn stats",children:e.jsxs("div",{style:{fontSize:12,color:"rgba(255,255,255,0.55)",lineHeight:1.6},children:[s!==void 0&&e.jsxs("div",{children:["Took ",(s/1e3).toFixed(1),"s"]}),y&&e.jsxs("div",{children:["Model: ",y]}),h.length>0&&e.jsxs("div",{children:["Used: ",h.join(", ")]})]})}),m&&m.length>0&&e.jsx(u,{label:"Session messages",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,maxHeight:400,overflowY:"auto"},children:m.slice(-8).map((g,f)=>e.jsxs("div",{style:{padding:10,borderRadius:8,background:g.role==="assistant"?"rgba(167, 139, 250, 0.06)":"rgba(255,255,255,0.02)",borderLeft:`2px solid ${g.role==="assistant"?"var(--color-purple-light)":"rgba(255,255,255,0.2)"}`,fontSize:12},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.1em",color:"rgba(255,255,255,0.35)",marginBottom:4},children:String(g.role||"?")}),e.jsxs("div",{style:{color:"rgba(255,255,255,0.85)",lineHeight:1.5,whiteSpace:"pre-wrap"},children:[String(g.content||"").slice(0,400),String(g.content||"").length>400&&"…"]})]},f))})})]})}function be({raw:t,topic:i}){const n=t.drives||[],r=t.totalPressure,l=t.dominantDrives||[];return e.jsxs(e.Fragment,{children:[r!==void 0&&e.jsx(u,{label:"Pressure snapshot",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.75)"},children:["Total: ",e.jsx("strong",{children:r.toFixed(3)}),l.length>0&&e.jsxs("span",{children:[" · Dominant: ",l.map(o=>o[0].toUpperCase()+o.slice(1)).join(", ")]})]})}),n.length>0&&i==="drive:tick"&&e.jsx(u,{label:"All drives this tick",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:n.map((o,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:8,background:"rgba(255,255,255,0.02)",fontSize:12},children:[e.jsx("span",{style:{flex:1,fontWeight:500},children:String(o.label||o.id)}),e.jsxs("span",{style:{color:"rgba(255,255,255,0.55)",fontVariantNumeric:"tabular-nums"},children:["sat ",(Number(o.satisfaction)*100).toFixed(0),"% · sp ",(Number(o.setpoint)*100).toFixed(0),"%"]}),e.jsx("span",{style:{color:Number(o.pressure)>0?"#fbbf24":"rgba(255,255,255,0.25)",fontVariantNumeric:"tabular-nums",width:50,textAlign:"right"},children:Number(o.pressure).toFixed(2)})]},h))})})]})}function ye({raw:t,topic:i}){if(i==="initiative:round"){const n=t.round,r=t.maxRounds,l=t.subtaskTitle;return e.jsx(u,{label:"What's happening",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:["TITAN is reasoning through round ",e.jsx("strong",{children:n})," of ",e.jsx("strong",{children:r}),l&&e.jsxs(e.Fragment,{children:[" on the subtask ",e.jsxs("em",{style:{color:"rgba(167, 139, 250, 0.9)"},children:['"',l,'"']})]}),".",e.jsx("br",{}),e.jsx("br",{}),"Each round is one tool-calling cycle — the agent thinks, picks a tool, runs it, then thinks again with the result. The cycle continues until the subtask is complete or the round budget runs out."]})})}if(i==="initiative:start"){const n=t.subtaskTitle,r=t.goalTitle;return e.jsx(u,{label:"What's happening",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:["TITAN picked up a task and started working.",n&&e.jsxs(e.Fragment,{children:[" Subtask: ",e.jsxs("em",{style:{color:"rgba(167, 139, 250, 0.9)"},children:['"',n,'"']}),"."]}),r&&e.jsxs(e.Fragment,{children:[" Part of goal: ",e.jsxs("em",{style:{color:"rgba(52, 211, 153, 0.9)"},children:['"',r,'"']}),"."]})]})})}if(i==="initiative:complete"){const n=t.success,r=t.toolsUsed||[],l=t.summary;return e.jsxs(u,{label:"Result",children:[e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:[n===!1?"The task ran but ended without full success.":"Task complete.",r.length>0&&e.jsxs(e.Fragment,{children:[" Tools used: ",r.join(", "),"."]})]}),l&&e.jsx("div",{style:{marginTop:8,padding:10,borderRadius:8,background:"rgba(255,255,255,0.02)",fontSize:12,lineHeight:1.5,color:"rgba(255,255,255,0.7)"},children:l})]})}if(i==="initiative:no_progress"){const n=t.reason;return e.jsx(u,{label:"Why it paused",children:e.jsx("div",{style:{fontSize:13,color:"rgba(251, 191, 36, 0.9)",lineHeight:1.6},children:n||"Ran but couldn't advance."})})}if(i==="dreaming:consolidated")return e.jsx(u,{label:"What's happening",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:"TITAN periodically consolidates recent memories — merging related facts, pruning stale ones, strengthening frequently-accessed associations. It's how it keeps the memory graph fast without losing useful context."})});if(i==="daemon:started"||i==="daemon:resumed")return e.jsx(u,{label:"What's happening",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:"TITAN's background daemon came online. All watchers (goals, cron, health, memory, drive ticks, Facebook autopilot) are active."})});if(i==="daemon:paused")return e.jsx(u,{label:"What's happening",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:"Background work is paused. Chat still works; cron, autopilot, and Soma ticks are halted until resumed."})});if(i.startsWith("health:"))return e.jsx(u,{label:"Health alert",children:e.jsx("div",{style:{fontSize:13,color:"rgba(251, 191, 36, 0.9)",lineHeight:1.6},children:"A subsystem reported a health issue. Check the Console tab for diagnostics."})});if(i==="agent:spawned"||i==="agent:stopped"){const n=t.name,r=t.model;return e.jsx(u,{label:"What's happening",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:[i==="agent:spawned"?"Spawned":"Stopped"," sub-agent",n&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:n})]}),r&&i==="agent:spawned"&&e.jsxs(e.Fragment,{children:[" running ",r]}),"."]})})}if(i==="agent:task:completed"||i==="agent:task:failed"){const n=t.agentId,r=t.reason,l=t.success;return e.jsx(u,{label:"Sub-agent result",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:[n&&e.jsxs(e.Fragment,{children:["Sub-agent ",e.jsx("strong",{children:n})," "]}),i==="agent:task:completed"&&l!==!1?"finished its task successfully.":r?`couldn't complete: ${r}.`:"did not complete its task."]})})}return e.jsx(je,{raw:t})}function je({raw:t}){const i=Object.entries(t||{}).filter(([n])=>n!=="timestamp");return i.length===0?null:e.jsx(u,{label:"Details",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:i.slice(0,8).map(([n,r])=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,padding:"6px 10px",borderRadius:6,background:"rgba(255,255,255,0.02)",fontSize:11},children:[e.jsx("span",{style:{color:"rgba(255,255,255,0.4)"},children:n}),e.jsx("span",{style:{color:"rgba(255,255,255,0.8)",fontFamily:"ui-monospace, monospace",textAlign:"right",wordBreak:"break-all"},children:Se(r)})]},n))})})}function Se(t){if(t==null)return"—";if(typeof t=="string")return t.length>80?t.slice(0,77)+"…":t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t).slice(0,80)}catch{return"[object]"}}function ve({label:t,raw:i}){const[n,r]=d.useState(!1);return e.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs("button",{onClick:()=>r(l=>!l),style:{width:"100%",padding:"14px 24px",background:"transparent",border:0,color:"rgba(255,255,255,0.5)",fontSize:11,textTransform:"uppercase",letterSpacing:"0.15em",fontWeight:600,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{children:t}),e.jsx("span",{style:{fontSize:14},children:n?"−":"+"})]}),n&&e.jsx("pre",{style:{margin:0,padding:"0 24px 20px",fontSize:10,lineHeight:1.4,color:"rgba(255,255,255,0.5)",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:300,overflowY:"auto"},children:JSON.stringify(i,null,2)})]})}function Te(){var x,j;const[t]=te(),i=t.get("kiosk")==="1",n=t.get("voice")==="control"?"control":"titan",[r,l]=d.useState(n),[o,h]=d.useState(null),{drives:y,events:s,connected:m,reconnecting:w,lastActivity:g}=ae(),f=g>0&&Date.now()-g<1e4,R=typeof window<"u"&&((j=(x=window.matchMedia)==null?void 0:x.call(window,"(prefers-reduced-motion: reduce)"))==null?void 0:j.matches);d.useEffect(()=>{if(!i)return;let a=null;const S=async()=>{try{"wakeLock"in navigator&&(a=await navigator.wakeLock.request("screen"))}catch{}};S();const H=()=>{document.visibilityState==="visible"&&S()};return document.addEventListener("visibilitychange",H),()=>{var T;document.removeEventListener("visibilitychange",H),(T=a==null?void 0:a.release)==null||T.call(a)}},[i]);const M=d.useMemo(()=>m?"live":w?"reconnecting…":"connecting…",[m,w]),I=m?"var(--color-emerald)":w?"#fbbf24":"#6b7280";return e.jsxs("div",{style:{position:i?"fixed":"relative",inset:i?0:void 0,height:"100%",width:"100%",minHeight:i?"100vh":"100%",background:"radial-gradient(ellipse at 20% 30%, rgba(167, 139, 250, 0.06) 0%, transparent 55%), radial-gradient(ellipse at 80% 70%, rgba(34, 211, 238, 0.05) 0%, transparent 55%), radial-gradient(ellipse at 50% 50%, rgba(52, 211, 153, 0.03) 0%, transparent 60%), #05060a",color:"#f8f9fc",overflow:"hidden",fontFamily:'-apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif',display:"flex",flexDirection:"column",zIndex:i?9999:void 0},children:[e.jsx("div",{"aria-hidden":!0,style:{position:"absolute",inset:0,opacity:.03,pointerEvents:"none",backgroundImage:`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/></filter><rect width='200' height='200' filter='url(%23n)' opacity='0.8'/></svg>")`}}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",padding:i?"32px 40px":"20px 24px",minHeight:0,zIndex:1},children:[!i&&e.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16,fontSize:13},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,color:"rgba(255,255,255,0.5)",fontWeight:600,letterSpacing:"0.02em"},children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:I,boxShadow:`0 0 10px ${I}`,animation:"watch-pulse 2s ease-in-out infinite"}}),e.jsx("span",{children:"TITAN"}),e.jsx("span",{style:{opacity:.4},children:"·"}),e.jsx("span",{children:M})]}),e.jsx("div",{style:{display:"flex",gap:2,background:"rgba(20, 24, 36, 0.6)",border:"1px solid rgba(80, 90, 120, 0.25)",borderRadius:999,padding:2},children:["titan","control"].map(a=>e.jsx("button",{onClick:()=>l(a),style:{background:r===a?"#f8f9fc":"transparent",color:r===a?"#05060a":"rgba(255,255,255,0.55)",border:0,padding:"6px 14px",borderRadius:999,cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.02em",transition:"all 0.15s",textTransform:"uppercase"},children:a==="titan"?"TITAN":"Mission"},a))})]}),e.jsxs("main",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1.05fr) minmax(0, 1fr)",gridTemplateRows:"auto 1fr",gridTemplateAreas:'"focus activity" "organism activity"',gap:i?28:18,flex:1,minHeight:0},className:"watch-grid",children:[e.jsx(U,{gridArea:"focus",excited:f,children:e.jsx(le,{events:s,voice:r})}),e.jsxs(U,{gridArea:"organism",excited:f,padding:i?24:16,children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600,marginBottom:6},children:"How I'm feeling"}),e.jsx("div",{style:{flex:1,minHeight:i?320:220},children:e.jsx(pe,{drives:y,excited:f,reducedMotion:R})}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(90px, 1fr))",gap:8,marginTop:10,fontSize:11},children:y.map(a=>{const S=(a.pressure||0)>.01;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",borderRadius:8,background:S?"rgba(251, 191, 36, 0.08)":"rgba(255,255,255,0.02)",border:`1px solid ${S?"rgba(251, 191, 36, 0.3)":"rgba(255,255,255,0.04)"}`},title:a.description||`${a.label}: satisfaction ${a.satisfaction.toFixed(2)}, setpoint ${a.setpoint.toFixed(2)}`,children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:Y(a.id),boxShadow:`0 0 8px ${Y(a.id)}`}}),e.jsx("div",{style:{flex:1,color:"rgba(255,255,255,0.65)",fontWeight:500},children:a.label}),e.jsxs("div",{style:{color:"rgba(255,255,255,0.35)",fontVariantNumeric:"tabular-nums"},children:[Math.round((a.satisfaction||0)*100),"%"]})]},a.id)})})]}),e.jsxs(U,{gridArea:"activity",excited:f,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600},children:"Recent activity"}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.35)",fontVariantNumeric:"tabular-nums"},children:[s.length," ",s.length===1?"event":"events"]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0,maskImage:"linear-gradient(to bottom, transparent 0, black 16px, black calc(100% - 16px), transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, transparent 0, black 16px, black calc(100% - 16px), transparent 100%)",paddingRight:4},children:e.jsx(de,{events:s,voice:r,onEventClick:h})})]})]})]}),e.jsx(he,{event:o,voice:r,onClose:()=>h(null)}),e.jsx("style",{children:`
|
|
2
|
+
@keyframes watch-pulse {
|
|
3
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
4
|
+
50% { opacity: 0.6; transform: scale(0.85); }
|
|
5
|
+
}
|
|
6
|
+
@media (max-width: 820px) {
|
|
7
|
+
.watch-grid {
|
|
8
|
+
grid-template-columns: 1fr !important;
|
|
9
|
+
grid-template-rows: auto auto 1fr !important;
|
|
10
|
+
grid-template-areas: "focus" "organism" "activity" !important;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`})]})}function U({gridArea:t,children:i,excited:n,padding:r=20}){return e.jsx("section",{style:{gridArea:t,background:"rgba(20, 24, 36, 0.6)",border:`1px solid ${n?"rgba(167, 139, 250, 0.35)":"rgba(80, 90, 120, 0.25)"}`,borderRadius:20,padding:r,backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",display:"flex",flexDirection:"column",minHeight:0,transition:"border-color 0.5s",position:"relative",overflow:"hidden"},children:i})}export{Te as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,j as e,X as L,b as S,t as B,l as q}from"./index-Cml2x9pA.js";import{A as D,m as $}from"./Modal-ybPGvlQs.js";import{E as K}from"./external-link-DZ_rZsIt.js";import{R as F}from"./rotate-ccw-qzrB3SNw.js";import{P as U}from"./plus-Dpo1qfrl.js";import{P as G}from"./play-Cl1nC_gc.js";import{T as M}from"./trash-2-CTeyjxD_.js";import{P as _}from"./pause-BT1Bc2q3.js";import"./clsx-B-dksMZM.js";function V({open:a,approval:s,onClose:n}){var N,k,w;const[c,o]=l.useState(null),[p,r]=l.useState(!1),[y,b]=l.useState(!1),d=(N=s==null?void 0:s.payload)==null?void 0:N.goalId;if(l.useEffect(()=>{if(!a||!d){o(null),b(!1);return}let g=!1;const C=async()=>{try{const f=await S(`/api/goals/${d}`);if(!f.ok){g||(b(!0),r(!1));return}const m=await f.json();if(g)return;o(m.goal||m),b(!1),r(!1)}catch{g||(b(!0),r(!1))}};r(!0),C();const x=setInterval(C,5e3);return()=>{g=!0,clearInterval(x)}},[a,d]),l.useEffect(()=>{if(!a)return;const g=C=>{C.key==="Escape"&&n()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[a,n]),!s)return null;const j=s.title||((k=s.payload)==null?void 0:k.title)||"Approval",u=(w=s.payload)==null?void 0:w.rationale;return e.jsx(D,{children:a&&e.jsxs(e.Fragment,{children:[e.jsx($.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},onClick:n,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",zIndex:99}},"backdrop"),e.jsxs($.aside,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{duration:.28,ease:[.32,.72,0,1]},style:{position:"fixed",top:0,right:0,bottom:0,width:"min(540px, 100vw)",background:"rgba(10, 12, 20, 0.96)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderLeft:"1px solid rgba(167, 139, 250, 0.15)",display:"flex",flexDirection:"column",zIndex:100,color:"#f8f9fc",boxShadow:"-20px 0 60px rgba(0,0,0,0.5)"},role:"dialog","aria-modal":"true",children:[e.jsxs("div",{style:{padding:"20px 24px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"flex-start",gap:12},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600,marginBottom:6},children:"Proposal"}),e.jsx("div",{style:{fontSize:17,fontWeight:600,lineHeight:1.3,marginBottom:6},children:j}),e.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.35)"},children:e.jsx(O,{status:s.status})})]}),e.jsx("button",{onClick:n,"aria-label":"Close",style:{background:"transparent",border:0,color:"rgba(255,255,255,0.55)",cursor:"pointer",padding:6,borderRadius:8},children:e.jsx(L,{size:18})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px"},children:[u&&e.jsx(z,{label:"Why this",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.75)",lineHeight:1.5},children:u})}),!d&&s.status==="pending"&&e.jsx(z,{label:"Status",children:e.jsx("div",{style:{fontSize:13,color:"rgba(251, 191, 36, 0.9)"},children:"Waiting for approval. Once approved, a goal will be created and TITAN will start working on it."})}),!d&&s.status==="rejected"&&e.jsx(z,{label:"Status",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.5)"},children:"Rejected. No work started."})}),d&&e.jsxs(e.Fragment,{children:[p&&!c&&e.jsx(z,{label:"Progress",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.4)"},children:"Loading goal…"})}),y&&e.jsx(z,{label:"Progress",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.4)"},children:"Goal linked to this approval wasn't found (may have been deleted)."})}),c&&e.jsx(X,{goal:c})]})]}),e.jsxs("div",{style:{padding:"14px 24px",borderTop:"1px solid rgba(255,255,255,0.06)",display:"flex",gap:10},children:[d&&e.jsxs("a",{href:"/command-post",onClick:g=>{g.preventDefault(),window.location.hash="#watch",n()},style:{display:"inline-flex",alignItems:"center",gap:6,padding:"8px 14px",borderRadius:8,background:"rgba(167, 139, 250, 0.12)",color:"#c4b5fd",fontSize:12,fontWeight:500,textDecoration:"none",cursor:"pointer"},children:[e.jsx(K,{size:12})," Watch live"]}),e.jsx("button",{onClick:n,style:{padding:"8px 14px",borderRadius:8,background:"rgba(255,255,255,0.04)",border:0,color:"rgba(255,255,255,0.55)",fontSize:12,cursor:"pointer"},children:"Close"})]})]},"panel")]})})}function X({goal:a}){const s=a.subtasks||[],n=s.filter(r=>r.status==="done"||r.status==="skipped").length,c=s.filter(r=>r.status==="failed").length,o=s.filter(r=>r.status==="running").length,p=s.length?n/s.length*100:a.progress||0;return e.jsxs(e.Fragment,{children:[e.jsxs(z,{label:"Progress",children:[e.jsxs("div",{style:{marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,marginBottom:6},children:[e.jsxs("span",{style:{color:"rgba(255,255,255,0.6)"},children:[n," / ",s.length," complete"]}),e.jsxs("span",{style:{color:"rgba(255,255,255,0.4)",fontVariantNumeric:"tabular-nums"},children:[p.toFixed(0),"%"]})]}),e.jsx("div",{style:{height:6,borderRadius:3,background:"rgba(255,255,255,0.04)",overflow:"hidden"},children:e.jsx("div",{style:{width:`${p}%`,height:"100%",background:c>0?"linear-gradient(to right, #34d399, #fbbf24)":"var(--color-emerald)",transition:"width 0.5s"}})})]}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",display:"flex",gap:12},children:[e.jsx(O,{status:a.status}),o>0&&e.jsxs("span",{children:["· ",o," running"]}),c>0&&e.jsxs("span",{style:{color:"rgba(239, 68, 68, 0.9)"},children:["· ",c," failed"]})]})]}),s.length>0&&e.jsx(z,{label:"Subtasks",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:s.map(r=>e.jsx(Y,{goalId:a.id,subtask:r},r.id))})})]})}function Y({goalId:a,subtask:s}){const{toast:n}=B(),c=H(s.status),o=s.status==="running",[p,r]=l.useState(!1),y=async()=>{r(!0);try{await S(`/api/goals/${a}/subtasks/${s.id}/retry`,{method:"POST"}),n("success","Subtask reset and retried.")}catch(d){n("error",`Couldn't retry subtask — try again. (${d.message})`)}r(!1)},b=async()=>{r(!0);try{await S(`/api/goals/${a}/subtasks/${s.id}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({result:"Marked complete from Command Post"})}),n("success","Subtask marked done.")}catch(d){n("error",`Couldn't mark subtask done — try again. (${d.message})`)}r(!1)};return e.jsxs("div",{style:{padding:"10px 12px",borderRadius:8,background:"rgba(255,255,255,0.02)",borderLeft:`2px solid ${c}`,fontSize:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:s.error||s.result?6:0},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:c,boxShadow:`0 0 ${o?10:5}px ${c}`,animation:o?"subtask-pulse 1.4s ease-in-out infinite":"none",flexShrink:0}}),e.jsx("span",{style:{flex:1,color:"rgba(255,255,255,0.85)",lineHeight:1.4},children:s.title}),s.status==="failed"&&e.jsx("button",{onClick:y,disabled:p,title:"Reset + retry",style:{background:"transparent",border:0,padding:4,borderRadius:4,color:"#fbbf24",cursor:"pointer",opacity:p?.4:.8},children:e.jsx(F,{size:12})}),s.status==="pending"&&e.jsx("button",{onClick:b,disabled:p,title:"Mark done",style:{background:"transparent",border:0,padding:4,borderRadius:4,color:"var(--color-emerald)",cursor:"pointer",opacity:p?.4:.8},children:e.jsx(q,{size:12})}),e.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.1em",color:c,fontWeight:600,flexShrink:0},children:s.status})]}),s.error&&e.jsx("div",{style:{fontSize:11,color:"rgba(239, 68, 68, 0.85)",padding:"6px 8px",borderRadius:6,background:"rgba(239, 68, 68, 0.06)",marginLeft:18},children:s.error}),s.result&&s.status==="done"&&e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.55)",lineHeight:1.4,marginLeft:18,marginTop:4},children:[s.result.slice(0,240),s.result.length>240?"…":""]}),e.jsx("style",{children:"@keyframes subtask-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }"})]})}function O({status:a}){const s=H(a);return e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:999,background:`${s}15`,color:s,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.1em"},children:a})}function H(a){switch(a){case"done":case"completed":case"approved":case"active":return"var(--color-emerald)";case"running":return"var(--color-cyan)";case"failed":case"rejected":return"var(--color-error)";case"skipped":return"var(--color-text-secondary)";case"pending":case"paused":return"#fbbf24";default:return"#9ca3af"}}function z({label:a,children:s}){return e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600,marginBottom:8},children:a}),s]})}function ce(){const[a,s]=l.useState([]),[n,c]=l.useState(!0),[o,p]=l.useState(null),[r,y]=l.useState(null),[b,d]=l.useState(!1),[j,u]=l.useState(null),[N,k]=l.useState(null),{toast:w}=B(),g=async()=>{try{const t=await S("/api/goals");if(t.ok){const i=await t.json();s(i.goals||[])}}catch{}},C=async t=>{k(t.id);const i=t.status==="paused"?"active":"paused";try{await S(`/api/goals/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:i})}),await g()}catch(h){w("error",`Update failed: ${h.message}`)}k(null)},x=async t=>{k(t.id);try{await S(`/api/goals/${t.id}`,{method:"DELETE"}),await g()}catch(i){w("error",`Delete failed: ${i.message}`)}k(null),u(null)},f=async t=>{k(t.id);try{const i=(t.subtasks||[]).filter(h=>h.status==="failed");for(const h of i)await S(`/api/goals/${t.id}/subtasks/${h.id}/retry`,{method:"POST"});t.status!=="active"&&await S(`/api/goals/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"active"})}),await g()}catch(i){w("error",`Restart failed: ${i.message}`)}k(null)};l.useEffect(()=>{let t=!0;const i=async()=>{try{const v=await S("/api/goals");if(!v.ok)return;const T=await v.json();if(!t)return;s(T.goals||[]),c(!1)}catch{}};i();const h=setInterval(i,1e4);return()=>{t=!1,clearInterval(h)}},[]),l.useEffect(()=>{const t=localStorage.getItem("titan-token")||localStorage.getItem("titan_token")||"",i=`/api/watch/stream${t?`?token=${encodeURIComponent(t)}`:""}`,h=new EventSource(i);return h.onmessage=v=>{try{const T=JSON.parse(v.data);if(T.type!=="event")return;if(T.topic==="initiative:start"||T.topic==="initiative:round"){const I=T.raw||{};y({goalTitle:I.goalTitle||"",subtaskTitle:I.subtaskTitle||"",round:I.round,maxRounds:I.maxRounds})}(T.topic==="initiative:complete"||T.topic==="initiative:no_progress")&&y(null)}catch{}},h.onerror=()=>{},()=>h.close()},[]);const m=l.useMemo(()=>a.filter(t=>t.status==="active").sort((t,i)=>(t.priority||5)-(i.priority||5)),[a]),A=l.useMemo(()=>a.filter(t=>t.status==="paused"),[a]),P=l.useMemo(()=>a.filter(t=>t.status==="completed").sort((t,i)=>(i.completedAt||i.updatedAt||"").localeCompare(t.completedAt||t.updatedAt||"")).slice(0,5),[a]),R=l.useMemo(()=>{const t=[];for(const i of m){const h=new Set((i.subtasks||[]).filter(v=>v.status==="done"||v.status==="skipped").map(v=>v.id));for(const v of i.subtasks||[]){if(v.status!=="pending")continue;(v.dependsOn||[]).every(J=>h.has(J))&&t.push({goal:i,subtask:v})}}return t},[m]),W=l.useMemo(()=>{const t=[];for(const i of a)if(!(i.status!=="active"&&i.status!=="paused"))for(const h of i.subtasks||[])h.status==="failed"&&t.push({goal:i,subtask:h});return t.slice(0,5)},[a]);return n?e.jsx("div",{className:"flex items-center justify-center h-64 text-sm text-text-muted",children:"Loading work…"}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-[11px] text-text-muted",children:[a.filter(t=>t.status==="active").length," active · ",a.filter(t=>t.status==="paused").length," paused · ",a.filter(t=>t.status==="completed").length," completed"]}),e.jsxs("button",{onClick:()=>d(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-[12px] font-medium rounded-lg bg-indigo-600 text-white hover:bg-indigo-500 transition-colors",children:[e.jsx(U,{size:13})," New goal"]})]}),e.jsx(E,{label:"Now",count:r?1:0,children:e.jsx(D,{mode:"wait",children:r?e.jsxs($.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:.25},className:"p-4 rounded-xl border border-cyan-500/20 bg-cyan-500/[0.04]",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-cyan-400 animate-pulse",style:{boxShadow:"0 0 12px #22d3ee"}}),e.jsx("span",{className:"text-[11px] text-cyan-300 uppercase tracking-wider font-semibold",children:"executing"}),r.round&&r.maxRounds&&e.jsxs("span",{className:"text-[11px] text-text-muted",children:["round ",r.round,"/",r.maxRounds]})]}),e.jsx("div",{className:"text-[15px] font-medium text-white/95 mb-1",children:r.subtaskTitle||"(unnamed subtask)"}),r.goalTitle&&e.jsxs("div",{className:"text-[11px] text-text-muted",children:["in goal: ",r.goalTitle]})]},`${r.goalTitle}-${r.subtaskTitle}`):e.jsxs($.div,{initial:{opacity:0},animate:{opacity:1},className:"p-6 rounded-xl border border-border text-center",children:[e.jsx("div",{className:"text-[13px] text-text-muted",children:"Nothing running right now."}),e.jsx("div",{className:"text-[11px] text-text-muted mt-1",children:R.length>0?`${R.length} task${R.length===1?"":"s"} queued — TITAN will start within 10 seconds`:m.length>0?`${m.length} goal${m.length===1?"":"s"} active — waiting for driver to begin`:"No work in queue. Approve a proposal from the Inbox to get started."})]},"idle")})}),R.length>0&&e.jsx(E,{label:"Up next",count:R.length,children:e.jsx("div",{className:"space-y-2",children:R.slice(0,3).map(({goal:t,subtask:i},h)=>e.jsxs("div",{onClick:()=>p(t),className:"flex items-center gap-3 p-3 rounded-lg bg-bg-secondary/30 border border-border/30 hover:bg-bg-secondary cursor-pointer transition-colors",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[13px] text-white/85 truncate",children:i.title}),e.jsx("div",{className:"text-[11px] text-text-muted truncate",children:t.title})]}),h===0&&e.jsx("span",{className:"text-[10px] text-cyan-300/70 uppercase tracking-wider",children:"next"})]},`${t.id}-${i.id}`))})}),e.jsx(E,{label:"Active goals",count:m.length,children:m.length===0?e.jsx("div",{className:"p-6 rounded-xl border border-border text-center text-[12px] text-text-muted",children:"No active goals. TITAN is idle. (Soma may propose one shortly.)"}):e.jsx("div",{className:"space-y-2",children:m.map(t=>e.jsx(Z,{goal:t,busy:N===t.id,onClick:()=>p(t),onPauseToggle:()=>C(t),onDelete:()=>u(t),onRestart:()=>f(t)},t.id))})}),P.length>0&&e.jsx(E,{label:"Recently done",count:P.length,children:e.jsx("div",{className:"space-y-2",children:P.map(t=>e.jsxs("div",{onClick:()=>p(t),className:"flex items-center gap-3 p-3 rounded-lg bg-emerald-500/[0.03] border border-emerald-500/10 hover:bg-emerald-500/[0.06] cursor-pointer",children:[e.jsx("span",{className:"text-emerald-400",children:"✓"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[13px] text-white/85 truncate",children:t.title}),e.jsxs("div",{className:"text-[11px] text-text-muted",children:["completed ",ee(t.completedAt||t.updatedAt)]})]})]},t.id))})}),(A.length>0||W.length>0)&&e.jsx(E,{label:"Needs attention",count:A.length+W.length,children:e.jsxs("div",{className:"space-y-2",children:[A.map(t=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-amber-500/[0.03] border border-amber-500/15 hover:bg-amber-500/[0.06]",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400"}),e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>p(t),children:[e.jsx("div",{className:"text-[13px] text-white/85 truncate",children:t.title}),e.jsx("div",{className:"text-[11px] text-text-muted",children:"paused"})]}),e.jsx("button",{onClick:i=>{i.stopPropagation(),C(t)},disabled:N===t.id,title:"Resume",className:"p-1.5 rounded hover:bg-bg-tertiary text-emerald-400/70 hover:text-emerald-400 disabled:opacity-40",children:e.jsx(G,{size:12})}),e.jsx("button",{onClick:i=>{i.stopPropagation(),u(t)},disabled:N===t.id,title:"Delete",className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-red-400 disabled:opacity-40",children:e.jsx(M,{size:12})})]},t.id)),W.map(({goal:t,subtask:i})=>e.jsxs("div",{onClick:()=>p(t),className:"flex items-start gap-3 p-3 rounded-lg bg-red-500/[0.03] border border-red-500/15 hover:bg-red-500/[0.06] cursor-pointer",children:[e.jsx("span",{className:"text-red-400 mt-0.5",children:"✗"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[13px] text-white/85 truncate",children:i.title}),e.jsxs("div",{className:"text-[11px] text-text-muted truncate",children:["in ",t.title]}),i.error&&e.jsx("div",{className:"text-[11px] text-red-300/70 mt-1 truncate",children:i.error})]})]},`${t.id}-${i.id}`))]})}),e.jsx(V,{open:o!==null,approval:o?{id:o.id,title:o.title,status:o.status,payload:{goalId:o.id,title:o.title,description:o.description,rationale:o.description}}:null,onClose:()=>p(null)}),e.jsx(Q,{open:b,onClose:()=>d(!1),onCreated:async()=>{d(!1),await g()}}),e.jsx(D,{children:j&&e.jsx($.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",backdropFilter:"blur(6px)",zIndex:200,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>u(null),children:e.jsxs($.div,{initial:{scale:.96,y:8},animate:{scale:1,y:0},exit:{scale:.96,y:8},onClick:t=>t.stopPropagation(),style:{background:"rgba(15, 17, 26, 0.98)",border:"1px solid rgba(239, 68, 68, 0.25)",borderRadius:16,padding:24,maxWidth:440,width:"calc(100% - 32px)",color:"#f8f9fc"},children:[e.jsx("div",{className:"text-[16px] font-semibold mb-2",children:"Delete this goal?"}),e.jsx("div",{className:"text-[13px] text-white/55 mb-1",children:j.title}),e.jsxs("div",{className:"text-[11px] text-text-muted mb-5",children:["All ",(j.subtasks||[]).length," subtasks will be removed. Can't undo."]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>u(null),className:"px-4 py-2 rounded-lg text-[12px] text-text-secondary hover:bg-bg-tertiary",children:"Cancel"}),e.jsx("button",{onClick:()=>x(j),disabled:N===j.id,className:"px-4 py-2 rounded-lg text-[12px] font-medium bg-red-600 text-white hover:bg-red-500 disabled:opacity-50",children:"Delete goal"})]})]})})})]})}function Q({open:a,onClose:s,onCreated:n}){const[c,o]=l.useState(""),[p,r]=l.useState(""),[y,b]=l.useState([]),[d,j]=l.useState(""),[u,N]=l.useState(!1),[k,w]=l.useState(null);l.useEffect(()=>{a||(o(""),r(""),b([]),j(""),w(null))},[a]),l.useEffect(()=>{if(!a)return;const x=f=>{f.key==="Escape"&&s()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[a,s]);const g=()=>{const x=d.trim();x&&(b(f=>[...f,x]),j(""))},C=async()=>{if(!c.trim()){w("Title is required");return}N(!0),w(null);try{const x={title:c.trim(),description:p.trim()||c.trim(),subtasks:y.map(m=>({title:m,description:m}))},f=await S("/api/goals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!f.ok){const m=await f.text().catch(()=>"");throw new Error(m||`HTTP ${f.status}`)}n()}catch(x){w(x.message)}N(!1)};return e.jsx(D,{children:a&&e.jsx($.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",backdropFilter:"blur(6px)",zIndex:200,display:"flex",alignItems:"center",justifyContent:"center",padding:16},onClick:s,children:e.jsxs($.div,{initial:{scale:.96,y:8},animate:{scale:1,y:0},exit:{scale:.96,y:8},onClick:x=>x.stopPropagation(),style:{background:"rgba(15, 17, 26, 0.98)",border:"1px solid rgba(99, 102, 241, 0.25)",borderRadius:16,padding:24,maxWidth:520,width:"100%",color:"#f8f9fc"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-[16px] font-semibold",children:"New goal"}),e.jsx("button",{onClick:s,className:"text-white/55 hover:text-text p-1",children:e.jsx(L,{size:18})})]}),e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold block mb-1.5",children:"Title"}),e.jsx("input",{value:c,onChange:x=>o(x.target.value),placeholder:"Build the Polymarket monitor",autoFocus:!0,className:"w-full bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[14px] text-white/95 placeholder-white/25 focus:outline-none focus:border-indigo-500/50 mb-4"}),e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold block mb-1.5",children:"Description (optional)"}),e.jsx("textarea",{value:p,onChange:x=>r(x.target.value),placeholder:"What should TITAN accomplish? Why?",rows:3,className:"w-full bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[13px] text-white/85 placeholder-white/25 focus:outline-none focus:border-indigo-500/50 resize-none mb-4"}),e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold block mb-1.5",children:"Subtasks (optional)"}),e.jsx("div",{className:"space-y-1.5 mb-2",children:y.map((x,f)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg bg-bg-tertiary/30 border border-border/50",children:[e.jsxs("span",{className:"text-[11px] text-text-muted tabular-nums",children:[f+1,"."]}),e.jsx("span",{className:"flex-1 text-[12px] text-text",children:x}),e.jsx("button",{onClick:()=>b(m=>m.filter((A,P)=>P!==f)),className:"text-text-muted hover:text-red-400","aria-label":"Remove",children:e.jsx(L,{size:12})})]},f))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:d,onChange:x=>j(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),g())},placeholder:"Add a subtask (press Enter)",className:"flex-1 bg-bg-tertiary border border-border rounded-lg px-3 py-1.5 text-[12px] text-white/85 placeholder-white/25 focus:outline-none focus:border-indigo-500/50"}),e.jsx("button",{onClick:g,disabled:!d.trim(),className:"px-3 rounded-lg text-[12px] bg-bg-tertiary text-text-secondary hover:bg-bg-tertiary disabled:opacity-30",children:"Add"})]}),y.length===0&&e.jsx("p",{className:"text-[10px] text-text-muted italic mt-2",children:"Leaving subtasks empty is fine — TITAN can plan them itself."}),k&&e.jsx("div",{className:"mt-4 p-2 rounded-lg bg-red-500/[0.08] border border-red-500/20 text-[12px] text-red-300",children:k}),e.jsxs("div",{className:"flex gap-2 justify-end mt-6",children:[e.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[12px] text-text-secondary hover:bg-bg-tertiary",children:"Cancel"}),e.jsx("button",{onClick:C,disabled:u||!c.trim(),className:"px-4 py-2 rounded-lg text-[12px] font-medium bg-indigo-600 text-white hover:bg-indigo-500 disabled:opacity-50",children:u?"Creating…":"Create goal"})]})]})})})}function Z({goal:a,busy:s,onClick:n,onPauseToggle:c,onDelete:o,onRestart:p}){const r=a.subtasks||[],y=r.filter(u=>u.status==="done"||u.status==="skipped").length,b=r.filter(u=>u.status==="running").length,d=r.filter(u=>u.status==="failed").length,j=r.length?y/r.length*100:a.progress||0;return e.jsxs("div",{className:"group p-3 rounded-lg bg-bg-secondary/30 border border-border/50 hover:bg-bg-secondary transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1.5",children:[e.jsx("div",{onClick:n,className:"flex-1 min-w-0 cursor-pointer",children:e.jsx("div",{className:"text-[13px] text-text truncate font-medium",children:a.title})}),e.jsxs("span",{className:"text-[10px] text-text-muted flex-shrink-0 tabular-nums",children:[y,"/",r.length]}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[d>0&&e.jsx("button",{onClick:u=>{u.stopPropagation(),p()},disabled:s,title:`Retry ${d} failed subtask${d===1?"":"s"}`,className:"p-1.5 rounded hover:bg-bg-tertiary text-amber-300/70 hover:text-amber-300 disabled:opacity-40",children:e.jsx(F,{size:12})}),e.jsx("button",{onClick:u=>{u.stopPropagation(),c()},disabled:s,title:a.status==="paused"?"Resume":"Pause",className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text disabled:opacity-40",children:a.status==="paused"?e.jsx(G,{size:12}):e.jsx(_,{size:12})}),e.jsx("button",{onClick:u=>{u.stopPropagation(),o()},disabled:s,title:"Delete",className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-red-400 disabled:opacity-40",children:e.jsx(M,{size:12})})]})]}),e.jsx("div",{className:"h-1 rounded-full bg-bg-tertiary overflow-hidden mb-2 cursor-pointer",onClick:n,children:e.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${j}%`,background:d>0?"linear-gradient(to right, #34d399, #fbbf24)":"var(--color-emerald)"}})}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-text-muted cursor-pointer",onClick:n,children:[b>0&&e.jsxs("span",{className:"text-cyan-300/80",children:["▶ ",b," running"]}),d>0&&e.jsxs("span",{className:"text-red-300/80",children:["✗ ",d," failed"]}),b===0&&d===0&&r.length>0&&e.jsxs("span",{children:[r.length-y," pending"]}),r.length===0&&e.jsx("span",{className:"italic text-text-muted",children:"no subtasks yet"})]})]})}function E({label:a,count:s,children:n}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("h3",{className:"text-[11px] uppercase tracking-wider text-text-muted font-semibold",children:a}),s!==void 0&&s>0&&e.jsx("span",{className:"text-[10px] text-text-muted tabular-nums",children:s})]}),n]})}function ee(a){if(!a)return"";const s=Date.parse(a);if(isNaN(s))return"";const n=Math.max(0,Math.floor((Date.now()-s)/1e3));if(n<60)return`${n}s ago`;const c=Math.floor(n/60);if(c<60)return`${c}m ago`;const o=Math.floor(c/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}export{ce as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as A,r as l,b as j,j as t}from"./index-Cml2x9pA.js";import{P as D}from"./PageHeader-DdrbS1aq.js";import{R as O}from"./refresh-cw-C-iZkzuS.js";import{P}from"./play-Cl1nC_gc.js";import"./chevron-right-DbLSHmff.js";/**
|
|
2
|
+
* @license lucide-react v0.513.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const T=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],z=A("workflow",T),_={done:"#22c55e",completed:"#22c55e",in_progress:"#3b82f6",running:"#3b82f6",pending:"#64748b",blocked:"#f59e0b",failed:"#ef4444",skipped:"#475569"};function $(u){const y=new Map(u.map(s=>[s.id,s])),c=new Map,g=(s,i=new Set)=>{var v;if(c.has(s))return c.get(s);if(i.has(s))return 0;i.add(s);const p=(((v=y.get(s))==null?void 0:v.dependsOn)||[]).filter(h=>y.has(h)),n=p.length===0?0:1+Math.max(...p.map(h=>g(h,i)));return c.set(s,n),n};u.forEach(s=>g(s.id));const a=new Map;u.forEach(s=>{const i=c.get(s.id)??0;a.has(i)||a.set(i,[]),a.get(i).push(s.id)});const m=new Map;let b=0;[...a.entries()].forEach(([s,i])=>i.forEach((p,n)=>{m.set(p,{x:s*240+20,y:n*92+20}),b=Math.max(b,n)}));const k=(Math.max(0,...a.keys())+1)*240+40,f=(b+1)*92+40;return{pos:m,width:k,height:f}}const M=190,w=64;function G(){const[u,y]=l.useState([]),[c,g]=l.useState(null),[a,m]=l.useState([]),[b,k]=l.useState(null),[f,s]=l.useState(""),[i,p]=l.useState(!1),[n,v]=l.useState(null),h=()=>{Promise.all([j("/api/missions/active",{headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>e.missions||e.active||(Array.isArray(e)?e:[])).catch(()=>[]),j("/api/missions/recent",{headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>e.recent||e.missions||(Array.isArray(e)?e:[])).catch(()=>[])]).then(([e,r])=>{const o=x=>({goalId:x.goalId||x.id,title:x.title||"(workflow)",phase:x.phase}),d=[...e.map(o),...r.map(o)],I=new Set;y(d.filter(x=>x.goalId&&!I.has(x.goalId)&&I.add(x.goalId)))})};l.useEffect(h,[]),l.useEffect(()=>{if(!c){m([]);return}j(`/api/mission/${c}`,{headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>{var r,o;m(((r=e.goal)==null?void 0:r.subtasks)||[]),k(((o=e.driver)==null?void 0:o.currentSubtaskId)||null)}).catch(()=>m([]))},[c]);const{pos:N,width:C,height:E}=l.useMemo(()=>$(a),[a]),W=l.useMemo(()=>new Map(a.map(e=>[e.id,e])),[a]),S=async()=>{var e;if(f.trim()){p(!0);try{const r=await j("/api/mission/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:f})}).then(d=>d.json());s(""),h();const o=((e=r.goal)==null?void 0:e.id)||r.goalId||r.id;o&&g(o)}finally{p(!1)}}};return t.jsxs("div",{className:"space-y-6",children:[t.jsx(D,{title:"Workflow Builder",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Missions"},{label:"Workflow Builder"}]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(z,{size:18,className:"text-[var(--text-secondary)]"}),t.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:"Visualize + author workflows as a goal/subtask DAG"}),t.jsxs("button",{onClick:h,className:"ml-auto flex items-center gap-1 text-xs px-2 py-1 rounded border border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text)]",children:[t.jsx(O,{size:12})," Refresh"]})]}),t.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-3 flex gap-2",children:[t.jsx("input",{value:f,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key==="Enter"&&S()},placeholder:"Describe a workflow in plain English (e.g. 'research X, draft a summary, then post it')",className:"flex-1 bg-transparent text-sm text-[var(--text)] placeholder:text-[var(--text-muted)] outline-none"}),t.jsxs("button",{onClick:S,disabled:i||!f.trim(),className:"flex items-center gap-1 text-xs px-3 py-1.5 rounded bg-blue-500/15 text-blue-400 border border-blue-500/30 disabled:opacity-50",children:[t.jsx(P,{size:12})," ",i?"Decomposing…":"Build"]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-2 space-y-1 max-h-[60vh] overflow-auto",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-[var(--text-muted)] px-2 py-1",children:"Workflows"}),u.length===0&&t.jsx("p",{className:"text-xs text-[var(--text-muted)] px-2",children:"None yet — build one above."}),u.map(e=>t.jsxs("button",{onClick:()=>g(e.goalId),className:`w-full text-left text-xs px-2 py-1.5 rounded ${c===e.goalId?"bg-blue-500/15 text-blue-300":"text-[var(--text-secondary)] hover:bg-[var(--bg)]"}`,children:[t.jsx("span",{className:"truncate block",children:e.title}),e.phase&&t.jsx("span",{className:"text-[10px] text-[var(--text-muted)]",children:e.phase})]},e.goalId))]}),t.jsx("div",{className:"md:col-span-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-2 overflow-auto max-h-[60vh]",children:a.length===0?t.jsx("div",{className:"text-[var(--text-muted)] text-sm p-6 text-center",children:"Select a workflow to view its DAG, or build one from a prompt."}):t.jsxs("svg",{width:C,height:E,className:"min-w-full",children:[a.flatMap(e=>(e.dependsOn||[]).filter(r=>W.has(r)).map(r=>{const o=N.get(r),d=N.get(e.id);return t.jsx("line",{x1:o.x+M,y1:o.y+w/2,x2:d.x,y2:d.y+w/2,stroke:"var(--border)",strokeWidth:1.5,markerEnd:"url(#arrow)"},`${r}->${e.id}`)})),t.jsx("defs",{children:t.jsx("marker",{id:"arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"3",orient:"auto",children:t.jsx("path",{d:"M0,0 L7,3 L0,6 Z",fill:"var(--text-muted)"})})}),a.map(e=>{const r=N.get(e.id),o=_[e.status]||"#64748b",d=e.id===b;return t.jsxs("g",{transform:`translate(${r.x},${r.y})`,onClick:()=>v(e),style:{cursor:"pointer"},children:[t.jsx("rect",{width:M,height:w,rx:8,fill:"var(--bg)",stroke:d?"#3b82f6":"var(--border)",strokeWidth:d?2:1}),t.jsx("rect",{width:4,height:w,rx:2,fill:o}),t.jsx("text",{x:12,y:22,fill:"var(--text)",fontSize:11,fontWeight:600,children:e.title.slice(0,26)}),t.jsxs("text",{x:12,y:40,fill:"var(--text-muted)",fontSize:9,children:[e.status,d?" • running":""]})]},e.id)})]})})]}),n&&t.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",onClick:()=>v(null),children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text)]",children:n.title}),t.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:["status: ",n.status," · depends on: ",n.dependsOn.length?n.dependsOn.join(", "):"—"]}),n.description&&t.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:n.description})]})]})}export{G as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{c as J,r as d,j as e,b as X,t as $,J as A,$ as K,Z as E,m as Q,l as L,P as U}from"./index-Cml2x9pA.js";import{P as V}from"./PageHeader-DdrbS1aq.js";import"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{I as Y}from"./InlineEditableField-DgMrLDj1.js";import{C as F}from"./ConfirmDialog-VErHWAbo.js";import{R as w}from"./refresh-cw-C-iZkzuS.js";import{P as G}from"./plus-Dpo1qfrl.js";import{C as ee}from"./chevron-right-DbLSHmff.js";import{P as D}from"./play-Cl1nC_gc.js";import{P as H}from"./pause-BT1Bc2q3.js";import{T as M}from"./trash-2-CTeyjxD_.js";import{C as O}from"./clock-JyQAYy6X.js";import{T as W,a as _}from"./toggle-right-DTmrC5RD.js";import{B as I}from"./book-open-ohEXgUsS.js";import"./clsx-B-dksMZM.js";import"./check-CuRYh4Zh.js";import"./pencil-BK5IU6o0.js";import"./Modal-ybPGvlQs.js";/**
|
|
2
|
+
* @license lucide-react v0.513.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const te=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],se=J("circle",te);/**
|
|
7
|
+
* @license lucide-react v0.513.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const ae=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],re=J("timer",ae);function B(t){const l=t.split(" ");if(l.length!==5)return t;const[s,n,h,y,r]=l,m={0:"Sun",1:"Mon",2:"Tue",3:"Wed",4:"Thu",5:"Fri",6:"Sat",7:"Sun"};if(h==="*"&&y==="*"){const p=`${n.padStart(2,"0")}:${s.padStart(2,"0")}`;return r==="*"?`Daily at ${p}`:r==="1-5"?`Weekdays at ${p}`:r==="0,6"?`Weekends at ${p}`:`${r.split(",").map(v=>m[v]||v).join(", ")} at ${p}`}return s.startsWith("*/")?`Every ${s.slice(2)} min`:n.startsWith("*/")?`Every ${n.slice(2)} hours`:t}function T(t){const l=Date.now()-new Date(t).getTime(),s=Math.floor(l/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const n=Math.floor(s/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}const g=async(t,l)=>{const s=await X(t,{headers:{"Content-Type":"application/json"},...l});if(!s.ok)throw new Error(`API ${s.status}`);return s.json()};function R({icon:t,title:l,count:s,accent:n="var(--color-accent)"}){return e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(t,{className:"w-5 h-5",style:{color:n}}),e.jsx("h2",{className:"text-base font-semibold text-text",children:l}),s!==void 0&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bg-tertiary text-text-secondary",children:s})]})}function z({status:t}){const l={active:{bg:"#34d39920",text:"var(--color-emerald)"},completed:{bg:"#6366f120",text:"var(--color-accent)"},paused:{bg:"#f59e0b20",text:"var(--color-warning)"},failed:{bg:"#ef444420",text:"var(--color-error)"},pending:{bg:"#52525b20",text:"var(--color-text-secondary)"},running:{bg:"#22d3ee20",text:"var(--color-cyan)"},done:{bg:"#34d39920",text:"var(--color-emerald)"},skipped:{bg:"#52525b20",text:"var(--color-border-light)"},ok:{bg:"#34d39920",text:"var(--color-emerald)"},notable:{bg:"#f59e0b20",text:"var(--color-warning)"},urgent:{bg:"#ef444420",text:"var(--color-error)"}},s=l[t]||l.pending;return e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium capitalize",style:{backgroundColor:s.bg,color:s.text},children:t})}function oe({status:t}){switch(t){case"done":return e.jsx(L,{className:"w-3.5 h-3.5 text-emerald"});case"failed":return e.jsx(Q,{className:"w-3.5 h-3.5 text-error"});case"running":return e.jsx(w,{className:"w-3.5 h-3.5 animate-spin text-cyan"});case"skipped":return e.jsx(H,{className:"w-3.5 h-3.5 text-text-muted"});default:return e.jsx(se,{className:"w-3.5 h-3.5 text-text-muted"})}}function le({goals:t,onRefresh:l}){const{toast:s}=$(),[n,h]=d.useState(new Set),[y,r]=d.useState(!1),[m,p]=d.useState(""),[j,v]=d.useState(""),[c,u]=d.useState(null),i=a=>{h(b=>{const f=new Set(b);return f.has(a)?f.delete(a):f.add(a),f})},k=async()=>{if(m.trim())try{await g("/api/goals",{method:"POST",body:JSON.stringify({title:m,description:j})}),p(""),v(""),r(!1),l(),s("success","Goal created.")}catch(a){s("error",`Couldn't create goal — try again. (${a.message})`)}},C=async a=>{try{await g(`/api/goals/${a}`,{method:"DELETE"}),l(),s("success","Goal deleted.")}catch(b){s("error",`Couldn't delete goal — try again. (${b.message})`)}},o=async(a,b)=>{const f=b==="paused"?"active":"paused";try{await g(`/api/goals/${a}`,{method:"PATCH",body:JSON.stringify({status:f})}),l()}catch(S){s("error",`Couldn't update goal — try again. (${S.message})`)}},N=async(a,b)=>{try{await g(`/api/goals/${a}/subtasks/${b}/retry`,{method:"POST"}),l(),s("success","Subtask retried.")}catch(f){s("error",`Couldn't retry subtask — try again. (${f.message})`)}},P=async(a,b,f)=>{try{await g(`/api/goals/${a}/subtasks/${b}`,{method:"PATCH",body:JSON.stringify({title:f})}),l()}catch(S){s("error",`Couldn't save subtask — try again. (${S.message})`)}},Z=async(a,b)=>{try{await g(`/api/goals/${a}/subtasks/${b}/complete`,{method:"POST",body:JSON.stringify({result:"Completed via dashboard"})}),l(),s("success","Subtask marked done.")}catch(f){s("error",`Couldn't complete subtask — try again. (${f.message})`)}};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(R,{icon:A,title:"Active Goals",count:t.length,accent:"#34d399"}),e.jsxs("button",{onClick:()=>r(!y),className:"flex items-center gap-1 text-xs px-3 py-1.5 rounded-lg transition-colors bg-bg-tertiary text-text-secondary",onMouseEnter:a=>{a.currentTarget.style.backgroundColor="#34d39930",a.currentTarget.style.color="var(--color-emerald)"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="var(--color-bg-tertiary)",a.currentTarget.style.color="var(--color-text-secondary)"},children:[e.jsx(G,{className:"w-3.5 h-3.5"})," New Goal"]})]}),y&&e.jsxs("div",{className:"rounded-lg p-4 mb-4",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx("input",{id:"workflow-goal-title",name:"workflow-goal-title",type:"text",placeholder:"Goal title...",value:m,onChange:a=>p(a.target.value),className:"w-full px-3 py-2 rounded-lg text-sm mb-2 outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsx("textarea",{id:"workflow-goal-description",name:"workflow-goal-description",placeholder:"Description (optional)...",value:j,onChange:a=>v(a.target.value),rows:2,className:"w-full px-3 py-2 rounded-lg text-sm mb-3 outline-none resize-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:k,className:"text-xs px-4 py-1.5 rounded-lg font-medium transition-opacity hover:opacity-80",style:{backgroundColor:"var(--color-emerald)",color:"var(--color-bg)"},children:"Create"}),e.jsx("button",{onClick:()=>r(!1),className:"text-xs px-4 py-1.5 rounded-lg transition-colors hover:opacity-80 bg-bg-tertiary text-text-secondary",children:"Cancel"})]})]}),t.length===0?e.jsxs("div",{className:"rounded-lg p-6 text-center",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx(A,{className:"w-8 h-8 mx-auto mb-2 text-text-muted"}),e.jsx("p",{className:"text-sm text-text-muted",children:"No goals yet. Create one to get started."})]}):e.jsx("div",{className:"space-y-2",children:t.map(a=>{const b=n.has(a.id),f=a.subtasks.filter(x=>x.status==="done"||x.status==="skipped").length,S=a.subtasks.length;return e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 cursor-pointer select-none",onClick:()=>i(a.id),children:[b?e.jsx(K,{className:"w-4 h-4 flex-shrink-0 text-text-muted"}):e.jsx(ee,{className:"w-4 h-4 flex-shrink-0 text-text-muted"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium truncate text-text",children:a.title}),e.jsx(z,{status:a.status})]}),S>0&&e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden bg-bg-tertiary",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${a.progress}%`,backgroundColor:"var(--color-emerald)"}})}),e.jsxs("span",{className:"text-xs flex-shrink-0 text-text-secondary",children:[f,"/",S]})]})]}),a.status!=="completed"&&e.jsx("button",{onClick:x=>{x.stopPropagation(),o(a.id,a.status)},className:"p-1 rounded hover:opacity-80 flex-shrink-0",title:a.status==="paused"?"Resume goal":"Pause goal",children:a.status==="paused"?e.jsx(D,{className:"w-3.5 h-3.5 text-emerald"}):e.jsx(H,{className:"w-3.5 h-3.5",style:{color:"#fbbf24"}})}),e.jsx("button",{onClick:x=>{x.stopPropagation(),u(a.id)},className:"p-1 rounded hover:opacity-80 flex-shrink-0",title:"Delete goal",children:e.jsx(M,{className:"w-3.5 h-3.5 text-text-muted"})})]}),b&&a.subtasks.length>0&&e.jsx("div",{className:"px-4 pb-3 border-t",style:{borderColor:"var(--color-bg-tertiary)"},children:e.jsx("div",{className:"space-y-1.5 mt-2",children:a.subtasks.map(x=>e.jsxs("div",{className:"flex items-center gap-2 py-1 px-2 rounded bg-bg",children:[e.jsx(oe,{status:x.status}),e.jsx("span",{className:"text-xs flex-1 min-w-0",style:{color:x.status==="done"?"var(--color-border-light)":"var(--color-text-secondary)"},children:e.jsx(Y,{value:x.title,onSave:q=>P(a.id,x.id,q),placeholder:"Subtask title"})}),x.status==="failed"&&x.error&&e.jsx("span",{className:"text-xs truncate max-w-40 text-error",title:x.error,children:x.error}),x.status==="failed"&&e.jsxs("button",{onClick:()=>N(a.id,x.id),className:"text-xs px-2 py-0.5 rounded transition-colors hover:opacity-80",style:{backgroundColor:"var(--color-bg-tertiary)",color:"#fbbf24"},title:"Reset to pending, clear error, retry",children:[e.jsx(w,{className:"w-3 h-3 inline"})," Retry"]}),x.status==="pending"&&e.jsx("button",{onClick:()=>Z(a.id,x.id),className:"text-xs px-2 py-0.5 rounded transition-colors hover:opacity-80",style:{backgroundColor:"var(--color-bg-tertiary)",color:"var(--color-emerald)"},children:"Done"})]},x.id))})})]},a.id)})}),e.jsx(F,{open:c!==null,title:"Delete this goal?",message:"This can't be undone. The goal and its subtasks will be permanently removed.",confirmLabel:"Delete",onConfirm:async()=>{c&&await C(c),u(null)},onCancel:()=>u(null)})]})}function ne({jobs:t,onRefresh:l}){const{toast:s}=$(),[n,h]=d.useState(!1),[y,r]=d.useState(""),[m,p]=d.useState(""),[j,v]=d.useState(""),[c,u]=d.useState(null),i=async()=>{if(!(!y.trim()||!m.trim()||!j.trim()))try{await g("/api/cron",{method:"POST",body:JSON.stringify({name:y,schedule:m,command:j})}),r(""),p(""),v(""),h(!1),l(),s("success","Cron job created.")}catch(o){s("error",`Couldn't create cron job — try again. (${o.message})`)}},k=async(o,N)=>{try{await g(`/api/cron/${o}/toggle`,{method:"POST",body:JSON.stringify({enabled:!N})}),l(),s("success",N?"Cron job disabled.":"Cron job enabled.")}catch(P){s("error",`Couldn't update cron job — try again. (${P.message})`)}},C=async o=>{try{await g(`/api/cron/${o}`,{method:"DELETE"}),l(),s("success","Cron job deleted.")}catch(N){s("error",`Couldn't delete cron job — try again. (${N.message})`)}};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(R,{icon:O,title:"Scheduled Tasks",count:t.length,accent:"#22d3ee"}),e.jsxs("button",{onClick:()=>h(!n),className:"flex items-center gap-1 text-xs px-3 py-1.5 rounded-lg transition-colors bg-bg-tertiary text-text-secondary",onMouseEnter:o=>{o.currentTarget.style.backgroundColor="#22d3ee30",o.currentTarget.style.color="var(--color-cyan)"},onMouseLeave:o=>{o.currentTarget.style.backgroundColor="var(--color-bg-tertiary)",o.currentTarget.style.color="var(--color-text-secondary)"},children:[e.jsx(G,{className:"w-3.5 h-3.5"})," New Cron"]})]}),n&&e.jsxs("div",{className:"rounded-lg p-4 mb-4",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 mb-2",children:[e.jsx("input",{id:"workflow-cron-name",name:"workflow-cron-name",type:"text",placeholder:"Job name...",value:y,onChange:o=>r(o.target.value),className:"px-3 py-2 rounded-lg text-sm outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsx("input",{id:"workflow-cron-schedule",name:"workflow-cron-schedule",type:"text",placeholder:"Schedule (e.g. */5 * * * *)",value:m,onChange:o=>p(o.target.value),className:"px-3 py-2 rounded-lg text-sm outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}})]}),e.jsx("input",{id:"workflow-cron-command",name:"workflow-cron-command",type:"text",placeholder:"Command to execute...",value:j,onChange:o=>v(o.target.value),className:"w-full px-3 py-2 rounded-lg text-sm mb-3 outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:i,className:"text-xs px-4 py-1.5 rounded-lg font-medium transition-opacity hover:opacity-80",style:{backgroundColor:"var(--color-cyan)",color:"var(--color-bg)"},children:"Create"}),e.jsx("button",{onClick:()=>h(!1),className:"text-xs px-4 py-1.5 rounded-lg transition-colors hover:opacity-80 bg-bg-tertiary text-text-secondary",children:"Cancel"})]})]}),t.length===0?e.jsxs("div",{className:"rounded-lg p-6 text-center",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx(O,{className:"w-8 h-8 mx-auto mb-2 text-text-muted"}),e.jsx("p",{className:"text-sm text-text-muted",children:"No scheduled tasks. Create a cron job to automate tasks."})]}):e.jsx("div",{className:"space-y-2",children:t.map(o=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg px-4 py-3",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx("button",{onClick:()=>k(o.id,o.enabled),title:o.enabled?"Disable":"Enable",children:o.enabled?e.jsx(W,{className:"w-5 h-5 text-emerald"}):e.jsx(_,{className:"w-5 h-5 text-text-muted"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium truncate",style:{color:o.enabled?"var(--color-text)":"var(--color-border-light)"},children:o.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{backgroundColor:"var(--color-bg-tertiary)",color:"var(--color-cyan)"},children:B(o.schedule)})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsx("span",{className:"text-xs font-mono truncate text-text-muted",children:o.command}),o.last_run&&e.jsxs("span",{className:"text-xs flex-shrink-0 text-text-muted",children:["Last: ",T(o.last_run)]})]})]}),e.jsx("button",{onClick:()=>u(o.id),className:"p-1 rounded hover:opacity-80 flex-shrink-0",title:"Delete",children:e.jsx(M,{className:"w-3.5 h-3.5 text-text-muted"})})]},o.id))}),e.jsx(F,{open:c!==null,title:"Delete this cron job?",message:"This can't be undone. The scheduled task will stop running and be removed.",confirmLabel:"Delete",onConfirm:async()=>{c&&await C(c),u(null)},onCancel:()=>u(null)})]})}function ce({recipes:t,onRefresh:l}){const{toast:s}=$(),[n,h]=d.useState(null),y=async r=>{h(r);try{await g(`/api/recipes/${r}/run`,{method:"POST",body:JSON.stringify({params:{}})}),l(),s("success","Recipe started.")}catch(m){s("error",`Couldn't run recipe — try again. (${m.message})`)}finally{h(null)}};return e.jsxs("div",{children:[e.jsx(R,{icon:I,title:"Recipes",count:t.length,accent:"#6366f1"}),t.length===0?e.jsxs("div",{className:"rounded-lg p-6 text-center",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx(I,{className:"w-8 h-8 mx-auto mb-2 text-text-muted"}),e.jsx("p",{className:"text-sm text-text-muted",children:"No recipes available."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:t.map(r=>{var m;return e.jsxs("div",{className:"rounded-lg p-4 flex flex-col",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-medium truncate text-text",children:r.name}),r.slashCommand&&e.jsxs("span",{className:"text-xs font-mono text-accent",children:["/",r.slashCommand]})]}),e.jsxs("button",{onClick:()=>y(r.id),disabled:n===r.id,className:"flex items-center gap-1 text-xs px-2.5 py-1 rounded-lg transition-opacity hover:opacity-80 flex-shrink-0",style:{backgroundColor:"#6366f130",color:"var(--color-accent)"},children:[n===r.id?e.jsx(w,{className:"w-3 h-3 animate-spin"}):e.jsx(D,{className:"w-3 h-3"}),"Run"]})]}),e.jsx("p",{className:"text-xs flex-1 line-clamp-2 mb-2 text-text-secondary",children:r.description}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[r.steps.length," step",r.steps.length!==1?"s":""]}),(m=r.tags)==null?void 0:m.map(p=>e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:p},p)),r.lastRunAt&&e.jsxs("span",{className:"text-xs ml-auto text-text-muted",children:["Ran ",T(r.lastRunAt)]})]})]},r.id)})})]})}function ie({status:t,history:l,onRefresh:s}){const{toast:n}=$(),[h,y]=d.useState(!1),[r,m]=d.useState(!1),p=async()=>{y(!0);try{await g("/api/autopilot/toggle",{method:"POST",body:JSON.stringify({enabled:!(t!=null&&t.enabled)})}),s(),n("success",t!=null&&t.enabled?"Autopilot disabled.":"Autopilot enabled.")}catch(c){n("error",`Couldn't update autopilot — try again. (${c.message})`)}finally{y(!1)}},j=async()=>{m(!0);try{await g("/api/autopilot/run",{method:"POST"}),s(),n("success","Autopilot run started.")}catch(c){n("error",`Couldn't start autopilot run — try again. (${c.message})`)}finally{m(!1)}},v=c=>{switch(c){case"urgent":return e.jsx(U,{className:"w-3.5 h-3.5 text-error"});case"notable":return e.jsx(E,{className:"w-3.5 h-3.5 text-warning"});default:return e.jsx(L,{className:"w-3.5 h-3.5 text-emerald"})}};return e.jsxs("div",{children:[e.jsx(R,{icon:E,title:"Autopilot",accent:"#f59e0b"}),e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"flex items-center gap-4 px-4 py-3",children:[e.jsx("button",{onClick:p,disabled:h,title:t!=null&&t.enabled?"Disable autopilot":"Enable autopilot",children:t!=null&&t.enabled?e.jsx(W,{className:"w-6 h-6 text-emerald"}):e.jsx(_,{className:"w-6 h-6 text-text-muted"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-text",children:t!=null&&t.enabled?"Active":"Disabled"}),(t==null?void 0:t.isRunning)&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-cyan",children:[e.jsx(w,{className:"w-3 h-3 animate-spin"})," Running..."]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[e.jsx(re,{className:"w-3 h-3 inline mr-1"}),t!=null&&t.schedule?B(t.schedule):"No schedule"]}),e.jsxs("span",{className:"text-xs text-text-muted",children:[(t==null?void 0:t.totalRuns)??0," total runs"]}),(t==null?void 0:t.lastRun)&&e.jsxs("span",{className:"text-xs text-text-muted",children:["Last: ",T(t.lastRun.timestamp)]})]})]}),e.jsxs("button",{onClick:j,disabled:r||(t==null?void 0:t.isRunning),className:"flex items-center gap-1 text-xs px-3 py-1.5 rounded-lg transition-opacity hover:opacity-80",style:{backgroundColor:"#f59e0b30",color:"var(--color-warning)"},children:[r?e.jsx(w,{className:"w-3 h-3 animate-spin"}):e.jsx(D,{className:"w-3 h-3"}),"Run Now"]})]}),l.length>0&&e.jsxs("div",{className:"border-t",style:{borderColor:"var(--color-bg-tertiary)"},children:[e.jsx("div",{className:"px-4 py-2",children:e.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Recent Runs"})}),e.jsx("div",{className:"divide-y",style:{borderColor:"var(--color-bg-tertiary)"},children:l.slice(-5).reverse().map((c,u)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[v(c.classification),e.jsx("span",{className:"text-xs flex-1 truncate text-text-secondary",children:c.skipped?`Skipped: ${c.summary}`:c.summary.slice(0,120)}),e.jsx(z,{status:c.classification}),e.jsx("span",{className:"text-xs flex-shrink-0 text-text-muted",children:T(c.timestamp)})]},u))})]})]})]})}function Re(){const[t,l]=d.useState([]),[s,n]=d.useState([]),[h,y]=d.useState([]),[r,m]=d.useState(null),[p,j]=d.useState([]),[v,c]=d.useState(!0),u=d.useCallback(async()=>{try{const[i,k,C,o,N]=await Promise.allSettled([g("/api/goals"),g("/api/cron"),g("/api/recipes"),g("/api/autopilot/status"),g("/api/autopilot/history?limit=5")]);i.status==="fulfilled"&&l(i.value.goals||[]),k.status==="fulfilled"&&n(k.value.jobs||[]),C.status==="fulfilled"&&y(C.value.recipes||[]),o.status==="fulfilled"&&m(o.value),N.status==="fulfilled"&&j(Array.isArray(N.value)?N.value:[])}finally{c(!1)}},[]);return d.useEffect(()=>{u();const i=setInterval(u,15e3);return()=>clearInterval(i)},[u]),v?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(w,{className:"w-6 h-6 animate-spin text-text-muted"})}):e.jsxs("div",{className:"space-y-8",children:[e.jsx(V,{title:"Workflows",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Agent"},{label:"Workflows"}],actions:e.jsx("button",{onClick:()=>{c(!0),u()},className:"p-2 rounded-lg transition-colors hover:opacity-80 bg-bg-tertiary",title:"Refresh",children:e.jsx(w,{className:"w-4 h-4 text-text-secondary"})})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[{label:"Goals",value:t.filter(i=>i.status==="active").length,total:t.length,color:"var(--color-emerald)"},{label:"Cron Jobs",value:s.filter(i=>i.enabled).length,total:s.length,color:"var(--color-cyan)"},{label:"Recipes",value:h.length,color:"var(--color-accent)"},{label:"Autopilot Runs",value:(r==null?void 0:r.totalRuns)??0,color:"var(--color-warning)"}].map(i=>e.jsxs("div",{className:"rounded-lg px-4 py-3",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx("p",{className:"text-xs mb-1 text-text-muted",children:i.label}),e.jsxs("p",{className:"text-lg font-bold",style:{color:i.color},children:[i.value,i.total!==void 0&&i.total!==i.value&&e.jsxs("span",{className:"text-xs font-normal ml-1 text-text-muted",children:["/ ",i.total]})]})]},i.label))}),e.jsx(le,{goals:t,onRefresh:u}),e.jsx(ne,{jobs:s,onRefresh:u}),e.jsx(ce,{recipes:h,onRefresh:u}),e.jsx(ie,{status:r,history:p,onRefresh:u})]})}export{Re as default};
|