titan-agent 5.3.0 → 5.3.2

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.
Files changed (116) hide show
  1. package/README.md +5 -5
  2. package/dist/agent/agent.js +33 -4
  3. package/dist/agent/agent.js.map +1 -1
  4. package/dist/agent/subAgent.js +16 -1
  5. package/dist/agent/subAgent.js.map +1 -1
  6. package/dist/agent/toolRunner.js +17 -0
  7. package/dist/agent/toolRunner.js.map +1 -1
  8. package/dist/config/schema.js +10 -0
  9. package/dist/config/schema.js.map +1 -1
  10. package/dist/eval/record.js +21 -2
  11. package/dist/eval/record.js.map +1 -1
  12. package/dist/gateway/metrics.js +26 -3
  13. package/dist/gateway/metrics.js.map +1 -1
  14. package/dist/gateway/server.js +58 -6
  15. package/dist/gateway/server.js.map +1 -1
  16. package/dist/organism/drives.js +47 -11
  17. package/dist/organism/drives.js.map +1 -1
  18. package/dist/organism/pressure.js +16 -0
  19. package/dist/organism/pressure.js.map +1 -1
  20. package/dist/skills/builtin/fb_autopilot.js +16 -1
  21. package/dist/skills/builtin/fb_autopilot.js.map +1 -1
  22. package/dist/telemetry/activityLog.js +158 -0
  23. package/dist/telemetry/activityLog.js.map +1 -0
  24. package/dist/utils/constants.js +3 -1
  25. package/dist/utils/constants.js.map +1 -1
  26. package/package.json +1 -1
  27. package/ui/dist/assets/{AuditPanel-C31LRHZX.js → AuditPanel-CM6Wg9hO.js} +1 -1
  28. package/ui/dist/assets/{AutonomyPanel-CxQU72ZY.js → AutonomyPanel-CESx3ANg.js} +1 -1
  29. package/ui/dist/assets/{AutopilotPanel-D4FnBwJm.js → AutopilotPanel-DtEet1hJ.js} +1 -1
  30. package/ui/dist/assets/{AutoresearchPanel-BYHXZ9AO.js → AutoresearchPanel-DR47NqT5.js} +1 -1
  31. package/ui/dist/assets/{BackupPanel-C4CQKf2P.js → BackupPanel-BGP8p3l3.js} +1 -1
  32. package/ui/dist/assets/{BrowserPanel-C-OFYyLm.js → BrowserPanel-C15x9bLn.js} +1 -1
  33. package/ui/dist/assets/{CPAgents-CvkZDm_3.js → CPAgents-DYUtPzSq.js} +1 -1
  34. package/ui/dist/assets/{CPDashboard-JmBLBbj7.js → CPDashboard-Bf0-SyCh.js} +1 -1
  35. package/ui/dist/assets/{CPFiles-BDToRw0a.js → CPFiles-CxgxjQcO.js} +1 -1
  36. package/ui/dist/assets/{CPGoals-Dh9qJNWa.js → CPGoals-BsmCMTvT.js} +1 -1
  37. package/ui/dist/assets/{CPInbox-B6iaIbNG.js → CPInbox-tMSbmQ9H.js} +1 -1
  38. package/ui/dist/assets/{CPSocial-CsFrwZRC.js → CPSocial-nb-j7sOE.js} +1 -1
  39. package/ui/dist/assets/{ChannelsPanel-D-S4ktFn.js → ChannelsPanel-DP5C2OKd.js} +1 -1
  40. package/ui/dist/assets/{CheckpointsPanel-D-sP9ZuS.js → CheckpointsPanel-DlranVLZ.js} +1 -1
  41. package/ui/dist/assets/{CommandPostHub-BhlNyeDH.js → CommandPostHub-BgxIa4Ev.js} +3 -3
  42. package/ui/dist/assets/{CronPanel-Bf3rV7N2.js → CronPanel-LoT5yKwJ.js} +1 -1
  43. package/ui/dist/assets/{DaemonPanel-GGBWjTG2.js → DaemonPanel-DBGMqaE_.js} +1 -1
  44. package/ui/dist/assets/{DataTable-D2Px4o6f.js → DataTable-B2Ma8hfi.js} +1 -1
  45. package/ui/dist/assets/{EmptyState-DH6-Jy6A.js → EmptyState-CcKyk5Yn.js} +1 -1
  46. package/ui/dist/assets/EvalHarnessPanel-BqtMc1ZM.js +2 -0
  47. package/ui/dist/assets/{EvalPanel-CdjxzHlJ.js → EvalPanel-Bc33j0pN.js} +1 -1
  48. package/ui/dist/assets/{FilesPanel-Dz8TFydL.js → FilesPanel-3QKvrWPo.js} +1 -1
  49. package/ui/dist/assets/{FleetPanel-CWwWWTD4.js → FleetPanel-CSsXuQYj.js} +1 -1
  50. package/ui/dist/assets/{HomelabPanel-C7VBV7AC.js → HomelabPanel-DhrjTX9m.js} +1 -1
  51. package/ui/dist/assets/{InfraView-B1TgXARJ.js → InfraView-CR6HyrL6.js} +2 -2
  52. package/ui/dist/assets/{InlineEditableField-DOJNOL8m.js → InlineEditableField-CnvF-yFR.js} +1 -1
  53. package/ui/dist/assets/{Input-BgyHgQ3D.js → Input-GTHp2Rkr.js} +1 -1
  54. package/ui/dist/assets/{IntegrationsPanel-O26b4nhv.js → IntegrationsPanel-CymCRE3T.js} +1 -1
  55. package/ui/dist/assets/{IntelligenceView-DUhTQ8f_.js → IntelligenceView-C1IHxJRC.js} +2 -2
  56. package/ui/dist/assets/{LearningPanel-DX5S9ovg.js → LearningPanel-DOCES3lH.js} +1 -1
  57. package/ui/dist/assets/{LogsPanel-DdeTnATQ.js → LogsPanel-BLnAqEaZ.js} +1 -1
  58. package/ui/dist/assets/{McpPanel-BpXWrP1a.js → McpPanel-ChUzmr3z.js} +1 -1
  59. package/ui/dist/assets/{MemoryGraphPanel-CNkZmTUy.js → MemoryGraphPanel-Bzvjmzvk.js} +1 -1
  60. package/ui/dist/assets/{MemoryWikiPanel-o4L8Df-n.js → MemoryWikiPanel-Dwk3Aqwd.js} +1 -1
  61. package/ui/dist/assets/{MeshPanel-DMBQJFCC.js → MeshPanel-C3LJSlht.js} +1 -1
  62. package/ui/dist/assets/{NvidiaPanel-C8P-tJFG.js → NvidiaPanel-CeZK_-CV.js} +1 -1
  63. package/ui/dist/assets/{OrganismPanel-CcfHDWDk.js → OrganismPanel-BB6YOiQV.js} +1 -1
  64. package/ui/dist/assets/{OverviewPanel-BSotI1Zv.js → OverviewPanel-BmtBhQnv.js} +1 -1
  65. package/ui/dist/assets/{PageHeader-DPJuAgJk.js → PageHeader-BimceqQo.js} +1 -1
  66. package/ui/dist/assets/{PaperclipPanel-aXoXUjo6.js → PaperclipPanel-C-brgwA3.js} +1 -1
  67. package/ui/dist/assets/{PersonasPanel-DdPZxz2C.js → PersonasPanel-L1j78p6H.js} +1 -1
  68. package/ui/dist/assets/{RecipesPanel-D7qffXQN.js → RecipesPanel-34lCfynJ.js} +1 -1
  69. package/ui/dist/assets/{SecurityPanel-BDRK5el7.js → SecurityPanel-CBTPWLj6.js} +1 -1
  70. package/ui/dist/assets/{SelfImprovePanel-oYiMwFnA.js → SelfImprovePanel-BrPbFHhG.js} +1 -1
  71. package/ui/dist/assets/{SelfProposalsPanel-DOpNU_rr.js → SelfProposalsPanel-lNmiDThB.js} +1 -1
  72. package/ui/dist/assets/{SessionsPanel-eRbM3D9P.js → SessionsPanel-DAEYIn83.js} +1 -1
  73. package/ui/dist/assets/{SessionsTab-Jq3UKQCI.js → SessionsTab-JQbltWww.js} +1 -1
  74. package/ui/dist/assets/{SettingsPanel-DBIvKUYY.js → SettingsPanel-CzRROAYQ.js} +1 -1
  75. package/ui/dist/assets/{SettingsView-yfSY4OLt.js → SettingsView-CN7ii2uw.js} +2 -2
  76. package/ui/dist/assets/{SkeletonLoader-D1d-Gyyg.js → SkeletonLoader-atQtpcF5.js} +1 -1
  77. package/ui/dist/assets/{SkillsPanel-bubl9nag.js → SkillsPanel-DlFs2ih7.js} +1 -1
  78. package/ui/dist/assets/{SomaView-D3aFL8Tw.js → SomaView-Ba642Oqb.js} +1 -1
  79. package/ui/dist/assets/{StatCard-CEVFsz7t.js → StatCard-DciE_Iqc.js} +1 -1
  80. package/ui/dist/assets/{StatusBadge-DxeA9LNd.js → StatusBadge-BtfSPoW2.js} +1 -1
  81. package/ui/dist/assets/{TeamsPanel-D6IJJIR_.js → TeamsPanel-DKQ5z2Qe.js} +1 -1
  82. package/ui/dist/assets/{TelemetryPanel-SMPebdjQ.js → TelemetryPanel-B6KAc55Q.js} +1 -1
  83. package/ui/dist/assets/{TitanCanvas-BQU1yxqf.js → TitanCanvas-C-s0A-lv.js} +3 -3
  84. package/ui/dist/assets/{ToolsView-DgP4uRPr.js → ToolsView-Dei0KMP0.js} +2 -2
  85. package/ui/dist/assets/{Tooltip-CNPQr7IO.js → Tooltip-70UK0E2I.js} +1 -1
  86. package/ui/dist/assets/{TraceViewer-BbISy_ET.js → TraceViewer-BniolyBx.js} +1 -1
  87. package/ui/dist/assets/{TrainingPanel-BdCHcv6t.js → TrainingPanel-Bz4CTPGW.js} +1 -1
  88. package/ui/dist/assets/{VoiceOverlay-l6yoasVz.js → VoiceOverlay-CmNCrLcd.js} +1 -1
  89. package/ui/dist/assets/{VramPanel-XLhmen92.js → VramPanel-Xh_OtRDR.js} +1 -1
  90. package/ui/dist/assets/{WatchView-Bt-lNNWJ.js → WatchView-C-sGFpVy.js} +1 -1
  91. package/ui/dist/assets/{WorkTab-IG-F6Qll.js → WorkTab-BjLNmgIK.js} +1 -1
  92. package/ui/dist/assets/{WorkflowsPanel-DsMpnwLK.js → WorkflowsPanel-CvgQU1xI.js} +1 -1
  93. package/ui/dist/assets/{arrow-left-C_H9Z2Tm.js → arrow-left-DwqHtJiU.js} +1 -1
  94. package/ui/dist/assets/{chart-column-rR6tb72l.js → chart-column-BtNO6sRy.js} +1 -1
  95. package/ui/dist/assets/{circle-check-big-B1hMwau0.js → circle-check-big-DZRE_MbN.js} +1 -1
  96. package/ui/dist/assets/{dollar-sign-DhYwsTnR.js → dollar-sign-aVG3a5eL.js} +1 -1
  97. package/ui/dist/assets/{download-UDDcAlZC.js → download-BxiWJU4G.js} +1 -1
  98. package/ui/dist/assets/{eye-off-Cx0M_VQb.js → eye-off-CkgfFYhm.js} +1 -1
  99. package/ui/dist/assets/{funnel-B7YvM1ei.js → funnel-PkLdxKyC.js} +1 -1
  100. package/ui/dist/assets/{git-branch-BhTBN3J6.js → git-branch-BM-Gw95X.js} +1 -1
  101. package/ui/dist/assets/{index-D7Clon2u.js → index-CahJbWSR.js} +2 -2
  102. package/ui/dist/assets/{layers-B6jDzitD.js → layers-BuGf4FIJ.js} +1 -1
  103. package/ui/dist/assets/{legacy-av079XKu.js → legacy-CR6o4t-y.js} +1 -1
  104. package/ui/dist/assets/{lightbulb-DRuQ3Chf.js → lightbulb-n8gc_XAL.js} +1 -1
  105. package/ui/dist/assets/{pause-DqkRWPB_.js → pause-DCV52koX.js} +1 -1
  106. package/ui/dist/assets/{play-hUyR3CVS.js → play-CcJ9BnCh.js} +1 -1
  107. package/ui/dist/assets/{plug-CvpyjJt_.js → plug-CfWBXfCl.js} +1 -1
  108. package/ui/dist/assets/{proxy-Cc5bR828.js → proxy-CzZDfLmm.js} +1 -1
  109. package/ui/dist/assets/{square-CdiC0J8Z.js → square-DJpUhlxi.js} +1 -1
  110. package/ui/dist/assets/{target-DemL8_0v.js → target-DWcmM_9m.js} +1 -1
  111. package/ui/dist/assets/{toggle-right-Dsk892k5.js → toggle-right-YusFQ69L.js} +1 -1
  112. package/ui/dist/assets/{trash-2-Byj4OvKB.js → trash-2-CK7yQ55V.js} +1 -1
  113. package/ui/dist/assets/{trending-up-Dh_CffGX.js → trending-up-DGjFyubC.js} +1 -1
  114. package/ui/dist/assets/{trophy-DDr2AePx.js → trophy-uQv_NgDB.js} +1 -1
  115. package/ui/dist/index.html +1 -1
  116. package/ui/dist/assets/EvalHarnessPanel-Cz9dRg61.js +0 -2
@@ -1 +1 @@
1
- import{r as s,aH as p,j as e,aI as u,aJ as h}from"./index-D7Clon2u.js";import{P as g}from"./PageHeader-DPJuAgJk.js";import{P as b,R as y,A as j}from"./TitanCanvas-BQU1yxqf.js";import{C as v}from"./circle-check-big-B1hMwau0.js";import"./VoiceOverlay-l6yoasVz.js";function S(){const[i,x]=s.useState([]),[c,r]=s.useState(!0),[l,n]=s.useState(!1),[d,o]=s.useState(null),t=s.useCallback(async()=>{r(!0);try{const a=await p();x(a.backups||[])}catch{}r(!1)},[]);s.useEffect(()=>{t()},[t]);const m=async()=>{n(!0);try{await u(),await t()}catch{}n(!1)},f=async a=>{o(a);try{await h(a),alert("Backup verified successfully")}catch{alert("Backup verification failed")}o(null)};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{title:"Backup Manager",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Backups"}]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:m,disabled:l,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#6366f1] text-white text-sm font-medium hover:bg-[#4f46e5] disabled:opacity-50",children:[e.jsx(b,{className:"w-4 h-4"})," ",l?"Creating...":"Create Backup"]}),e.jsxs("button",{onClick:t,disabled:c,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(y,{className:`w-4 h-4 ${c?"animate-spin":""}`})," Refresh"]})]}),i.length===0&&!c&&e.jsx("div",{className:"text-sm text-[#52525b]",children:"No backups found."}),e.jsx("div",{className:"space-y-2",children:i.map(a=>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(j,{className:"w-4 h-4 text-[#6366f1]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[#e4e4e7]",children:new Date(a.createdAt).toLocaleString()}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[(a.sizeBytes/1024/1024).toFixed(1)," MB"]})]})]}),e.jsxs("button",{onClick:()=>f(a.path),disabled:d===a.path,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] text-xs hover:bg-[#3f3f46] disabled:opacity-50",children:[e.jsx(v,{className:"w-3.5 h-3.5"})," ",d===a.path?"Verifying...":"Verify"]})]},a.path))})]})}export{S as default};
1
+ import{r as s,aH as p,j as e,aI as u,aJ as h}from"./index-CahJbWSR.js";import{P as g}from"./PageHeader-BimceqQo.js";import{P as b,R as y,A as j}from"./TitanCanvas-C-s0A-lv.js";import{C as v}from"./circle-check-big-DZRE_MbN.js";import"./VoiceOverlay-CmNCrLcd.js";function S(){const[i,x]=s.useState([]),[c,r]=s.useState(!0),[l,n]=s.useState(!1),[d,o]=s.useState(null),t=s.useCallback(async()=>{r(!0);try{const a=await p();x(a.backups||[])}catch{}r(!1)},[]);s.useEffect(()=>{t()},[t]);const m=async()=>{n(!0);try{await u(),await t()}catch{}n(!1)},f=async a=>{o(a);try{await h(a),alert("Backup verified successfully")}catch{alert("Backup verification failed")}o(null)};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{title:"Backup Manager",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Backups"}]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:m,disabled:l,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#6366f1] text-white text-sm font-medium hover:bg-[#4f46e5] disabled:opacity-50",children:[e.jsx(b,{className:"w-4 h-4"})," ",l?"Creating...":"Create Backup"]}),e.jsxs("button",{onClick:t,disabled:c,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(y,{className:`w-4 h-4 ${c?"animate-spin":""}`})," Refresh"]})]}),i.length===0&&!c&&e.jsx("div",{className:"text-sm text-[#52525b]",children:"No backups found."}),e.jsx("div",{className:"space-y-2",children:i.map(a=>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(j,{className:"w-4 h-4 text-[#6366f1]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[#e4e4e7]",children:new Date(a.createdAt).toLocaleString()}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[(a.sizeBytes/1024/1024).toFixed(1)," MB"]})]})]}),e.jsxs("button",{onClick:()=>f(a.path),disabled:d===a.path,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] text-xs hover:bg-[#3f3f46] disabled:opacity-50",children:[e.jsx(v,{className:"w-3.5 h-3.5"})," ",d===a.path?"Verifying...":"Verify"]})]},a.path))})]})}export{S as default};
@@ -1,4 +1,4 @@
1
- import{c as i,r as s,j as e,G as m,a$ as p}from"./index-D7Clon2u.js";import{P as h}from"./PageHeader-DPJuAgJk.js";import"./VoiceOverlay-l6yoasVz.js";/**
1
+ import{c as i,r as s,j as e,G as m,a$ as p}from"./index-CahJbWSR.js";import{P as h}from"./PageHeader-BimceqQo.js";import"./VoiceOverlay-CmNCrLcd.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r,bb as m,j as e,aA as p,X as u,b as h}from"./index-D7Clon2u.js";import"./Input-BgyHgQ3D.js";import{S as j}from"./StatusBadge-DxeA9LNd.js";import{P as f}from"./PageHeader-DPJuAgJk.js";import{E as g}from"./EmptyState-DH6-Jy6A.js";import{S as b}from"./SkeletonLoader-D1d-Gyyg.js";import{U as N}from"./TitanCanvas-BQU1yxqf.js";import"./VoiceOverlay-l6yoasVz.js";function y(a){const s=Math.floor((Date.now()-new Date(a).getTime())/1e3);return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m`:s<86400?`${Math.floor(s/3600)}h`:`${Math.floor(s/86400)}d`}function v(a){const s=a.split("/");return s[s.length-1]}function D(){const[a,s]=r.useState([]),[c,d]=r.useState(!0),[o,l]=r.useState(null),i=r.useCallback(async()=>{try{const t=await m();s(t),l(null)}catch(t){l(t instanceof Error?t.message:"Failed to load agents")}d(!1)},[]);r.useEffect(()=>{i()},[i]);const x=async(t,n)=>{n.preventDefault(),n.stopPropagation();try{await h(`/api/command-post/agents/${t}`,{method:"DELETE"}),await i()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(f,{title:"Agents",breadcrumbs:[{label:"Command Post"},{label:"Agents"}]}),c&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.jsx(b,{variant:"card",count:6})}),o&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:o}),!c&&!o&&a.length===0&&e.jsx(g,{icon:e.jsx(N,{size:32}),title:"No agents registered",description:"Agents will appear here once they connect to Command Post."}),!c&&!o&&a.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:a.map(t=>e.jsxs(p,{to:`/command-post/agents/${t.id}`,className:"relative bg-bg-secondary border border-border rounded-xl p-4 hover:border-border-light transition-colors group",children:[t.role!=="ceo"&&e.jsx("button",{onClick:n=>x(t.id,n),className:"absolute top-3 right-3 p-1 rounded-md text-text-muted hover:text-error hover:bg-error/10 opacity-0 group-hover:opacity-100 transition-all",title:"Remove agent",children:e.jsx(u,{size:14})}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-sm font-semibold text-text",children:t.name}),e.jsx(j,{status:t.status,size:"sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Role"}),e.jsx("span",{className:"text-xs text-text-secondary capitalize",children:t.role})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Model"}),e.jsx("span",{className:"text-xs text-text-secondary truncate max-w-[140px]",children:v(t.model)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Last Heartbeat"}),e.jsxs("span",{className:"text-xs text-text-secondary",children:[y(t.lastHeartbeat)," ago"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Tasks Done"}),e.jsx("span",{className:"text-xs text-text-secondary",children:t.totalTasksCompleted})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Cost"}),e.jsxs("span",{className:"text-xs text-text-secondary",children:["$",t.totalCostUsd.toFixed(4)]})]})]})]},t.id))})]})}export{D as default};
1
+ import{r,bb as m,j as e,aA as p,X as u,b as h}from"./index-CahJbWSR.js";import"./Input-GTHp2Rkr.js";import{S as j}from"./StatusBadge-BtfSPoW2.js";import{P as f}from"./PageHeader-BimceqQo.js";import{E as g}from"./EmptyState-CcKyk5Yn.js";import{S as b}from"./SkeletonLoader-atQtpcF5.js";import{U as N}from"./TitanCanvas-C-s0A-lv.js";import"./VoiceOverlay-CmNCrLcd.js";function y(a){const s=Math.floor((Date.now()-new Date(a).getTime())/1e3);return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m`:s<86400?`${Math.floor(s/3600)}h`:`${Math.floor(s/86400)}d`}function v(a){const s=a.split("/");return s[s.length-1]}function D(){const[a,s]=r.useState([]),[c,d]=r.useState(!0),[o,l]=r.useState(null),i=r.useCallback(async()=>{try{const t=await m();s(t),l(null)}catch(t){l(t instanceof Error?t.message:"Failed to load agents")}d(!1)},[]);r.useEffect(()=>{i()},[i]);const x=async(t,n)=>{n.preventDefault(),n.stopPropagation();try{await h(`/api/command-post/agents/${t}`,{method:"DELETE"}),await i()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(f,{title:"Agents",breadcrumbs:[{label:"Command Post"},{label:"Agents"}]}),c&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.jsx(b,{variant:"card",count:6})}),o&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:o}),!c&&!o&&a.length===0&&e.jsx(g,{icon:e.jsx(N,{size:32}),title:"No agents registered",description:"Agents will appear here once they connect to Command Post."}),!c&&!o&&a.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:a.map(t=>e.jsxs(p,{to:`/command-post/agents/${t.id}`,className:"relative bg-bg-secondary border border-border rounded-xl p-4 hover:border-border-light transition-colors group",children:[t.role!=="ceo"&&e.jsx("button",{onClick:n=>x(t.id,n),className:"absolute top-3 right-3 p-1 rounded-md text-text-muted hover:text-error hover:bg-error/10 opacity-0 group-hover:opacity-100 transition-all",title:"Remove agent",children:e.jsx(u,{size:14})}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-sm font-semibold text-text",children:t.name}),e.jsx(j,{status:t.status,size:"sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Role"}),e.jsx("span",{className:"text-xs text-text-secondary capitalize",children:t.role})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Model"}),e.jsx("span",{className:"text-xs text-text-secondary truncate max-w-[140px]",children:v(t.model)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Last Heartbeat"}),e.jsxs("span",{className:"text-xs text-text-secondary",children:[y(t.lastHeartbeat)," ago"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Tasks Done"}),e.jsx("span",{className:"text-xs text-text-secondary",children:t.totalTasksCompleted})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Cost"}),e.jsxs("span",{className:"text-xs text-text-secondary",children:["$",t.totalCostUsd.toFixed(4)]})]})]})]},t.id))})]})}export{D as default};
@@ -1,4 +1,4 @@
1
- import{c as se,r as g,j as t,q as le,bo as ae,bc as re,ba as oe,A as _,aA as q}from"./index-D7Clon2u.js";import"./Input-BgyHgQ3D.js";import{S as ie}from"./StatusBadge-DxeA9LNd.js";import{P as G}from"./PageHeader-DPJuAgJk.js";import{S as ne}from"./SkeletonLoader-D1d-Gyyg.js";import{R as ce,U as de}from"./TitanCanvas-BQU1yxqf.js";import{D as xe}from"./dollar-sign-DhYwsTnR.js";import{T as me}from"./target-DemL8_0v.js";import"./VoiceOverlay-l6yoasVz.js";/**
1
+ import{c as se,r as g,j as t,q as le,bo as ae,bc as re,ba as oe,A as _,aA as q}from"./index-CahJbWSR.js";import"./Input-GTHp2Rkr.js";import{S as ie}from"./StatusBadge-BtfSPoW2.js";import{P as G}from"./PageHeader-BimceqQo.js";import{S as ne}from"./SkeletonLoader-atQtpcF5.js";import{R as ce,U as de}from"./TitanCanvas-C-s0A-lv.js";import{D as xe}from"./dollar-sign-aVG3a5eL.js";import{T as me}from"./target-DWcmM_9m.js";import"./VoiceOverlay-CmNCrLcd.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as i,j as e,b as f,X as j}from"./index-D7Clon2u.js";import{s as N,o as y,a as v,R as p,F as w}from"./TitanCanvas-BQU1yxqf.js";import"./VoiceOverlay-l6yoasVz.js";async function h(t){const a=await f(t);if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.json()}function b(t){return t===void 0?"—":t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}K`:`${(t/1024/1024).toFixed(1)}M`}function g(t){const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function k({path:t,onClose:a}){const[r,c]=i.useState(null);return i.useEffect(()=>{c(null),h(`/api/files/content?path=${encodeURIComponent(t)}`).then(l=>c(l)).catch(l=>c({error:String(l)}))},[t]),e.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:a,children:e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-full max-w-5xl max-h-[90vh] flex flex-col shadow-2xl",onClick:l=>l.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text truncate",children:t}),r&&"sizeBytes"in r&&e.jsxs("div",{className:"text-xs text-text-muted",children:[b(r.sizeBytes)," · ",r.encoding,r.truncated?" · truncated at 1MB":""]})]}),e.jsx("button",{onClick:a,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted",title:"Close",children:e.jsx(j,{size:18})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[r===null&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"Loading…"}),r&&"error"in r&&e.jsx("div",{className:"text-error text-sm py-8 text-center",children:r.error}),r&&"content"in r&&e.jsx("pre",{className:"text-[12px] font-mono leading-snug whitespace-pre-wrap text-text-secondary",children:r.content})]})]})})}function C(){const[t,a]=i.useState([]),[r,c]=i.useState(!0),[l,m]=i.useState(""),[o,n]=i.useState(null),d=i.useCallback(async()=>{c(!0);try{const s=await h("/api/files/edited?limit=300");a(s.files||[])}catch{}c(!1)},[]);i.useEffect(()=>{d()},[d]);const x=l?t.filter(s=>s.path.toLowerCase().includes(l.toLowerCase())):t;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded-lg border border-border bg-bg-secondary",children:[e.jsx(v,{size:14,className:"text-text-muted"}),e.jsx("input",{type:"text",placeholder:"Filter by path…",value:l,onChange:s=>m(s.target.value),className:"flex-1 bg-transparent text-sm outline-none"})]}),e.jsxs("button",{onClick:d,className:"px-3 py-1.5 rounded-lg border border-border bg-bg-secondary text-sm hover:bg-bg-tertiary flex items-center gap-1.5",title:"Refresh",children:[e.jsx(p,{size:14,className:r?"animate-spin":""}),r?"Loading":"Refresh"]}),e.jsxs("div",{className:"text-xs text-text-muted",children:[x.length," / ",t.length]})]}),r&&t.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"Loading…"}),!r&&x.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:l?"No files match filter":"No file edits recorded yet"}),x.length>0&&e.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:x.map(s=>e.jsxs("button",{onClick:()=>s.readable&&s.exists&&n(s.path),disabled:!s.readable||!s.exists,className:"w-full flex items-start gap-3 px-4 py-2.5 text-left hover:bg-bg-tertiary transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(w,{size:14,className:s.isSelfMod?"text-accent mt-0.5 flex-shrink-0":"text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-mono text-text truncate",children:s.path}),e.jsxs("div",{className:"text-xs text-text-muted mt-0.5 flex items-center gap-2 flex-wrap",children:[s.isSelfMod&&e.jsx("span",{className:"px-1 rounded bg-accent/15 text-accent text-[10px]",children:"self-mod"}),e.jsxs("span",{children:["×",s.writeCount]}),s.tools.length>0&&e.jsx("span",{children:s.tools.join("+")}),s.channels.length>0&&e.jsxs("span",{children:["via ",s.channels.join(", ")]}),!s.exists&&e.jsx("span",{className:"text-warn",children:"deleted"}),e.jsx("span",{children:b(s.sizeBytes)})]})]}),e.jsx("div",{className:"text-xs text-text-muted flex-shrink-0",children:g(s.lastWrittenAt)})]},s.path))}),o&&e.jsx(k,{path:o,onClose:()=>n(null)})]})}function S(){const[t,a]=i.useState([]),[r,c]=i.useState(!0),[l,m]=i.useState(null),o=i.useCallback(async()=>{c(!0);try{const n=await h("/api/research/recent?limit=50");a(n.research||[])}catch{}c(!1)},[]);return i.useEffect(()=>{o()},[o]),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:o,className:"px-3 py-1.5 rounded-lg border border-border bg-bg-secondary text-sm hover:bg-bg-tertiary flex items-center gap-1.5",children:[e.jsx(p,{size:14,className:r?"animate-spin":""}),r?"Loading":"Refresh"]}),e.jsxs("div",{className:"text-xs text-text-muted",children:[t.length," items"]})]}),r&&t.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"Loading…"}),!r&&t.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"No research recorded yet. Complete a goal and results will appear here."}),e.jsx("div",{className:"space-y-2",children:t.map(n=>{var u;const d=l===n.id,x=n.content.slice(0,200),s=n.subtaskTitle?`${n.goalTitle} — ${n.subtaskTitle}`:((u=n.tags)==null?void 0:u.join(" · "))||n.kind;return e.jsxs("div",{className:"rounded-xl border border-border bg-bg-secondary overflow-hidden",children:[e.jsxs("button",{onClick:()=>m(d?null:n.id),className:"w-full text-left px-4 py-3 hover:bg-bg-tertiary transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary text-text-muted uppercase tracking-wide font-medium",children:n.kind.replace(/_/g," ")}),e.jsx("span",{className:"text-xs text-text-muted",children:g(n.at)})]}),e.jsx("div",{className:"text-sm font-medium text-text truncate",children:s}),!d&&e.jsxs("div",{className:"text-xs text-text-secondary mt-1 line-clamp-2",children:[x,n.content.length>200?"…":""]})]}),d&&e.jsx("div",{className:"px-4 pb-4",children:e.jsx("pre",{className:"text-[12px] font-mono leading-snug whitespace-pre-wrap text-text-secondary",children:n.content})})]},n.id)})})]})}function T(){const[t,a]=i.useState("files");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>a("files"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-colors ${t==="files"?"bg-accent/15 text-accent border border-accent/30":"text-text-secondary hover:text-text hover:bg-bg-tertiary border border-transparent"}`,children:[e.jsx(N,{size:14})," Files edited"]}),e.jsxs("button",{onClick:()=>a("research"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-colors ${t==="research"?"bg-accent/15 text-accent border border-accent/30":"text-text-secondary hover:text-text hover:bg-bg-tertiary border border-transparent"}`,children:[e.jsx(y,{size:14})," Research"]})]}),t==="files"?e.jsx(C,{}):e.jsx(S,{})]})}export{T as default};
1
+ import{r as i,j as e,b as f,X as j}from"./index-CahJbWSR.js";import{s as N,o as y,a as v,R as p,F as w}from"./TitanCanvas-C-s0A-lv.js";import"./VoiceOverlay-CmNCrLcd.js";async function h(t){const a=await f(t);if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.json()}function b(t){return t===void 0?"—":t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}K`:`${(t/1024/1024).toFixed(1)}M`}function g(t){const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function k({path:t,onClose:a}){const[r,c]=i.useState(null);return i.useEffect(()=>{c(null),h(`/api/files/content?path=${encodeURIComponent(t)}`).then(l=>c(l)).catch(l=>c({error:String(l)}))},[t]),e.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:a,children:e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-full max-w-5xl max-h-[90vh] flex flex-col shadow-2xl",onClick:l=>l.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text truncate",children:t}),r&&"sizeBytes"in r&&e.jsxs("div",{className:"text-xs text-text-muted",children:[b(r.sizeBytes)," · ",r.encoding,r.truncated?" · truncated at 1MB":""]})]}),e.jsx("button",{onClick:a,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted",title:"Close",children:e.jsx(j,{size:18})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[r===null&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"Loading…"}),r&&"error"in r&&e.jsx("div",{className:"text-error text-sm py-8 text-center",children:r.error}),r&&"content"in r&&e.jsx("pre",{className:"text-[12px] font-mono leading-snug whitespace-pre-wrap text-text-secondary",children:r.content})]})]})})}function C(){const[t,a]=i.useState([]),[r,c]=i.useState(!0),[l,m]=i.useState(""),[o,n]=i.useState(null),d=i.useCallback(async()=>{c(!0);try{const s=await h("/api/files/edited?limit=300");a(s.files||[])}catch{}c(!1)},[]);i.useEffect(()=>{d()},[d]);const x=l?t.filter(s=>s.path.toLowerCase().includes(l.toLowerCase())):t;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded-lg border border-border bg-bg-secondary",children:[e.jsx(v,{size:14,className:"text-text-muted"}),e.jsx("input",{type:"text",placeholder:"Filter by path…",value:l,onChange:s=>m(s.target.value),className:"flex-1 bg-transparent text-sm outline-none"})]}),e.jsxs("button",{onClick:d,className:"px-3 py-1.5 rounded-lg border border-border bg-bg-secondary text-sm hover:bg-bg-tertiary flex items-center gap-1.5",title:"Refresh",children:[e.jsx(p,{size:14,className:r?"animate-spin":""}),r?"Loading":"Refresh"]}),e.jsxs("div",{className:"text-xs text-text-muted",children:[x.length," / ",t.length]})]}),r&&t.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"Loading…"}),!r&&x.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:l?"No files match filter":"No file edits recorded yet"}),x.length>0&&e.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:x.map(s=>e.jsxs("button",{onClick:()=>s.readable&&s.exists&&n(s.path),disabled:!s.readable||!s.exists,className:"w-full flex items-start gap-3 px-4 py-2.5 text-left hover:bg-bg-tertiary transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(w,{size:14,className:s.isSelfMod?"text-accent mt-0.5 flex-shrink-0":"text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-mono text-text truncate",children:s.path}),e.jsxs("div",{className:"text-xs text-text-muted mt-0.5 flex items-center gap-2 flex-wrap",children:[s.isSelfMod&&e.jsx("span",{className:"px-1 rounded bg-accent/15 text-accent text-[10px]",children:"self-mod"}),e.jsxs("span",{children:["×",s.writeCount]}),s.tools.length>0&&e.jsx("span",{children:s.tools.join("+")}),s.channels.length>0&&e.jsxs("span",{children:["via ",s.channels.join(", ")]}),!s.exists&&e.jsx("span",{className:"text-warn",children:"deleted"}),e.jsx("span",{children:b(s.sizeBytes)})]})]}),e.jsx("div",{className:"text-xs text-text-muted flex-shrink-0",children:g(s.lastWrittenAt)})]},s.path))}),o&&e.jsx(k,{path:o,onClose:()=>n(null)})]})}function S(){const[t,a]=i.useState([]),[r,c]=i.useState(!0),[l,m]=i.useState(null),o=i.useCallback(async()=>{c(!0);try{const n=await h("/api/research/recent?limit=50");a(n.research||[])}catch{}c(!1)},[]);return i.useEffect(()=>{o()},[o]),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:o,className:"px-3 py-1.5 rounded-lg border border-border bg-bg-secondary text-sm hover:bg-bg-tertiary flex items-center gap-1.5",children:[e.jsx(p,{size:14,className:r?"animate-spin":""}),r?"Loading":"Refresh"]}),e.jsxs("div",{className:"text-xs text-text-muted",children:[t.length," items"]})]}),r&&t.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"Loading…"}),!r&&t.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"No research recorded yet. Complete a goal and results will appear here."}),e.jsx("div",{className:"space-y-2",children:t.map(n=>{var u;const d=l===n.id,x=n.content.slice(0,200),s=n.subtaskTitle?`${n.goalTitle} — ${n.subtaskTitle}`:((u=n.tags)==null?void 0:u.join(" · "))||n.kind;return e.jsxs("div",{className:"rounded-xl border border-border bg-bg-secondary overflow-hidden",children:[e.jsxs("button",{onClick:()=>m(d?null:n.id),className:"w-full text-left px-4 py-3 hover:bg-bg-tertiary transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary text-text-muted uppercase tracking-wide font-medium",children:n.kind.replace(/_/g," ")}),e.jsx("span",{className:"text-xs text-text-muted",children:g(n.at)})]}),e.jsx("div",{className:"text-sm font-medium text-text truncate",children:s}),!d&&e.jsxs("div",{className:"text-xs text-text-secondary mt-1 line-clamp-2",children:[x,n.content.length>200?"…":""]})]}),d&&e.jsx("div",{className:"px-4 pb-4",children:e.jsx("pre",{className:"text-[12px] font-mono leading-snug whitespace-pre-wrap text-text-secondary",children:n.content})})]},n.id)})})]})}function T(){const[t,a]=i.useState("files");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>a("files"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-colors ${t==="files"?"bg-accent/15 text-accent border border-accent/30":"text-text-secondary hover:text-text hover:bg-bg-tertiary border border-transparent"}`,children:[e.jsx(N,{size:14})," Files edited"]}),e.jsxs("button",{onClick:()=>a("research"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-colors ${t==="research"?"bg-accent/15 text-accent border border-accent/30":"text-text-secondary hover:text-text hover:bg-bg-tertiary border border-transparent"}`,children:[e.jsx(y,{size:14})," Research"]})]}),t==="files"?e.jsx(C,{}):e.jsx(S,{})]})}export{T as default};
@@ -1 +1 @@
1
- import{r as i,bp as D,j as e,X as $,b as N}from"./index-D7Clon2u.js";import{B as j}from"./Input-BgyHgQ3D.js";import{S as T}from"./StatusBadge-DxeA9LNd.js";import{P as M}from"./PageHeader-DPJuAgJk.js";import{E as O}from"./EmptyState-DH6-Jy6A.js";import{M as A}from"./CommandPostHub-BhlNyeDH.js";import{S as F}from"./SkeletonLoader-D1d-Gyyg.js";import{P as L}from"./TitanCanvas-BQU1yxqf.js";import{T as y}from"./target-DemL8_0v.js";import{a as B,C as I}from"./VoiceOverlay-l6yoasVz.js";import{T as U}from"./trash-2-Byj4OvKB.js";import"./proxy-Cc5bR828.js";import"./InlineEditableField-DOJNOL8m.js";import"./Tooltip-CNPQr7IO.js";import"./pause-DqkRWPB_.js";import"./dollar-sign-DhYwsTnR.js";import"./git-branch-BhTBN3J6.js";import"./chart-column-rR6tb72l.js";function _(t){const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}const H=["pending","in_progress","completed","blocked"];function J({node:t,onClose:a,onRefresh:l}){const[d,c]=i.useState(!1),[x,m]=i.useState(!1),r=t.goal,g=async()=>{c(!0);try{await N(`/api/goals/${r.id}`,{method:"DELETE"}),l(),a()}catch{}c(!1)},o=async n=>{m(!0);try{await N(`/api/goals/${r.id}`,{method:"PATCH",body:JSON.stringify({status:n})}),l()}catch{}m(!1)};return e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-text",children:r.title}),r.description&&e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:r.description})]}),e.jsx("button",{onClick:a,className:"p-1 text-text-muted hover:text-text rounded-lg hover:bg-bg-tertiary transition-colors",children:e.jsx($,{size:16})})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs",children:[e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Status: "}),e.jsx(T,{status:r.status,size:"sm"})]}),r.progress>0&&e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Progress: "}),e.jsxs("span",{className:"text-text font-medium",children:[Math.round(r.progress),"%"]})]}),t.children.length>0&&e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Sub-goals: "}),e.jsxs("span",{className:"text-text font-medium",children:[t.children.filter(n=>n.goal.status==="completed"||n.goal.status==="done").length,"/",t.children.length," done"]})]}),e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Updated: "}),e.jsxs("span",{className:"text-text font-medium",children:[_(r.updatedAt||r.createdAt||new Date().toISOString())," ago"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-2",children:"Change Status"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:H.map(n=>e.jsx("button",{disabled:x||r.status===n,onClick:()=>o(n),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${r.status===n?"bg-accent/20 text-accent border border-accent/30":"bg-bg-tertiary text-text-secondary hover:bg-bg-tertiary/80 border border-border"} disabled:opacity-50`,children:n.replace("_"," ")},n))})]}),e.jsx("div",{className:"pt-2 border-t border-border flex justify-end",children:e.jsxs("button",{onClick:g,disabled:d,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-error hover:bg-error/10 transition-colors disabled:opacity-50",children:[e.jsx(U,{size:12}),d?"Deleting...":"Delete Goal"]})})]})}function z({node:t,expanded:a,toggleExpand:l,selectedId:d,onSelect:c}){const x=t.children.length>0,m=a.has(t.goal.id),r=d===t.goal.id,g=t.children.filter(o=>o.goal.status==="completed"||o.goal.status==="done").length;return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-center gap-2 py-2 px-3 rounded-lg transition-colors cursor-pointer group ${r?"bg-accent/10 border-l-2 border-accent":"hover:bg-bg-tertiary/50"}`,style:{paddingLeft:`${t.depth*24+12}px`},onClick:()=>c(t),children:[x?e.jsx("button",{onClick:o=>{o.stopPropagation(),l(t.goal.id)},className:"p-0.5 rounded hover:bg-bg-tertiary transition-colors",children:m?e.jsx(B,{size:14,className:"text-text-muted"}):e.jsx(I,{size:14,className:"text-text-muted"})}):e.jsx("span",{className:"w-[18px] flex-shrink-0"}),e.jsx(y,{size:14,className:r?"text-accent":"text-text-muted"}),e.jsx("span",{className:"text-sm text-text flex-1 truncate",children:t.goal.title}),e.jsx(T,{status:t.goal.status,size:"sm"}),x&&e.jsxs("span",{className:"text-[10px] text-text-muted",children:[g,"/",t.children.length]}),t.goal.progress>0&&e.jsx("div",{className:"w-16 h-1.5 bg-bg-tertiary rounded-full overflow-hidden flex-shrink-0",children:e.jsx("div",{className:"h-full bg-accent rounded-full transition-all",style:{width:`${Math.min(100,t.goal.progress)}%`}})})]}),x&&m&&e.jsx("div",{children:t.children.map(o=>e.jsx(z,{node:o,expanded:a,toggleExpand:l,selectedId:d,onSelect:c},o.goal.id))})]})}function E(t,a){for(const l of t){if(l.goal.id===a)return l;const d=E(l.children,a);if(d)return d}return null}function de(){const[t,a]=i.useState([]),[l,d]=i.useState(!0),[c,x]=i.useState(null),[m,r]=i.useState(new Set),[g,o]=i.useState(null),[n,u]=i.useState(!1),[p,v]=i.useState(""),[P,S]=i.useState(!1),b=i.useCallback(async()=>{try{const s=await D();a(s),r(new Set(s.map(h=>h.goal.id))),x(null)}catch(s){x(s instanceof Error?s.message:"Failed to load goals")}d(!1)},[]);i.useEffect(()=>{b()},[b]);const C=s=>{r(h=>{const f=new Set(h);return f.has(s)?f.delete(s):f.add(s),f})},G=s=>{o(h=>h===s.goal.id?null:s.goal.id),s.children.length>0&&!m.has(s.goal.id)&&C(s.goal.id)},w=async()=>{if(p.trim()){S(!0);try{await N("/api/command-post/goals",{method:"POST",body:JSON.stringify({title:p.trim()})}),u(!1),v(""),await b()}catch{}S(!1)}},k=g?E(t,g):null;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(M,{title:"Goals",breadcrumbs:[{label:"Command Post"},{label:"Goals"}],actions:e.jsx(j,{size:"sm",icon:e.jsx(L,{size:14}),onClick:()=>u(!0),children:"Create Goal"})}),l&&e.jsx(F,{variant:"row",count:5}),c&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:c}),!l&&!c&&t.length===0&&e.jsx(O,{icon:e.jsx(y,{size:32}),title:"No goals",description:"Create your first goal to start organizing agent work.",action:{label:"Create Goal",onClick:()=>u(!0)}}),!l&&!c&&t.length>0&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"lg:col-span-2 rounded-xl border border-border bg-bg-secondary overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[t.length," top-level goal",t.length!==1?"s":""]}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"Click a goal to view details"})]}),e.jsx("div",{className:"divide-y divide-border",children:t.map(s=>e.jsx(z,{node:s,expanded:m,toggleExpand:C,selectedId:g,onSelect:G},s.goal.id))})]}),e.jsx("div",{className:"lg:col-span-1",children:k?e.jsx(J,{node:k,onClose:()=>o(null),onRefresh:b}):e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-8 text-center",children:[e.jsx(y,{size:24,className:"text-text-muted mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Select a goal to view details"})]})})]}),e.jsx(A,{open:n,onClose:()=>u(!1),title:"Create Goal",footer:e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:()=>u(!1),children:"Cancel"}),e.jsx(j,{size:"sm",onClick:w,loading:P,disabled:!p.trim(),children:"Create"})]}),children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Goal Title"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"Enter goal title...",value:p,onChange:s=>v(s.target.value),onKeyDown:s=>s.key==="Enter"&&w(),autoFocus:!0})]})})]})}export{de as default};
1
+ import{r as i,bp as D,j as e,X as $,b as N}from"./index-CahJbWSR.js";import{B as j}from"./Input-GTHp2Rkr.js";import{S as T}from"./StatusBadge-BtfSPoW2.js";import{P as M}from"./PageHeader-BimceqQo.js";import{E as O}from"./EmptyState-CcKyk5Yn.js";import{M as A}from"./CommandPostHub-BgxIa4Ev.js";import{S as F}from"./SkeletonLoader-atQtpcF5.js";import{P as L}from"./TitanCanvas-C-s0A-lv.js";import{T as y}from"./target-DWcmM_9m.js";import{a as B,C as I}from"./VoiceOverlay-CmNCrLcd.js";import{T as U}from"./trash-2-CK7yQ55V.js";import"./proxy-CzZDfLmm.js";import"./InlineEditableField-CnvF-yFR.js";import"./Tooltip-70UK0E2I.js";import"./pause-DCV52koX.js";import"./dollar-sign-aVG3a5eL.js";import"./git-branch-BM-Gw95X.js";import"./chart-column-BtNO6sRy.js";function _(t){const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}const H=["pending","in_progress","completed","blocked"];function J({node:t,onClose:a,onRefresh:l}){const[d,c]=i.useState(!1),[x,m]=i.useState(!1),r=t.goal,g=async()=>{c(!0);try{await N(`/api/goals/${r.id}`,{method:"DELETE"}),l(),a()}catch{}c(!1)},o=async n=>{m(!0);try{await N(`/api/goals/${r.id}`,{method:"PATCH",body:JSON.stringify({status:n})}),l()}catch{}m(!1)};return e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-text",children:r.title}),r.description&&e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:r.description})]}),e.jsx("button",{onClick:a,className:"p-1 text-text-muted hover:text-text rounded-lg hover:bg-bg-tertiary transition-colors",children:e.jsx($,{size:16})})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs",children:[e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Status: "}),e.jsx(T,{status:r.status,size:"sm"})]}),r.progress>0&&e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Progress: "}),e.jsxs("span",{className:"text-text font-medium",children:[Math.round(r.progress),"%"]})]}),t.children.length>0&&e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Sub-goals: "}),e.jsxs("span",{className:"text-text font-medium",children:[t.children.filter(n=>n.goal.status==="completed"||n.goal.status==="done").length,"/",t.children.length," done"]})]}),e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Updated: "}),e.jsxs("span",{className:"text-text font-medium",children:[_(r.updatedAt||r.createdAt||new Date().toISOString())," ago"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-2",children:"Change Status"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:H.map(n=>e.jsx("button",{disabled:x||r.status===n,onClick:()=>o(n),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${r.status===n?"bg-accent/20 text-accent border border-accent/30":"bg-bg-tertiary text-text-secondary hover:bg-bg-tertiary/80 border border-border"} disabled:opacity-50`,children:n.replace("_"," ")},n))})]}),e.jsx("div",{className:"pt-2 border-t border-border flex justify-end",children:e.jsxs("button",{onClick:g,disabled:d,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-error hover:bg-error/10 transition-colors disabled:opacity-50",children:[e.jsx(U,{size:12}),d?"Deleting...":"Delete Goal"]})})]})}function z({node:t,expanded:a,toggleExpand:l,selectedId:d,onSelect:c}){const x=t.children.length>0,m=a.has(t.goal.id),r=d===t.goal.id,g=t.children.filter(o=>o.goal.status==="completed"||o.goal.status==="done").length;return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-center gap-2 py-2 px-3 rounded-lg transition-colors cursor-pointer group ${r?"bg-accent/10 border-l-2 border-accent":"hover:bg-bg-tertiary/50"}`,style:{paddingLeft:`${t.depth*24+12}px`},onClick:()=>c(t),children:[x?e.jsx("button",{onClick:o=>{o.stopPropagation(),l(t.goal.id)},className:"p-0.5 rounded hover:bg-bg-tertiary transition-colors",children:m?e.jsx(B,{size:14,className:"text-text-muted"}):e.jsx(I,{size:14,className:"text-text-muted"})}):e.jsx("span",{className:"w-[18px] flex-shrink-0"}),e.jsx(y,{size:14,className:r?"text-accent":"text-text-muted"}),e.jsx("span",{className:"text-sm text-text flex-1 truncate",children:t.goal.title}),e.jsx(T,{status:t.goal.status,size:"sm"}),x&&e.jsxs("span",{className:"text-[10px] text-text-muted",children:[g,"/",t.children.length]}),t.goal.progress>0&&e.jsx("div",{className:"w-16 h-1.5 bg-bg-tertiary rounded-full overflow-hidden flex-shrink-0",children:e.jsx("div",{className:"h-full bg-accent rounded-full transition-all",style:{width:`${Math.min(100,t.goal.progress)}%`}})})]}),x&&m&&e.jsx("div",{children:t.children.map(o=>e.jsx(z,{node:o,expanded:a,toggleExpand:l,selectedId:d,onSelect:c},o.goal.id))})]})}function E(t,a){for(const l of t){if(l.goal.id===a)return l;const d=E(l.children,a);if(d)return d}return null}function de(){const[t,a]=i.useState([]),[l,d]=i.useState(!0),[c,x]=i.useState(null),[m,r]=i.useState(new Set),[g,o]=i.useState(null),[n,u]=i.useState(!1),[p,v]=i.useState(""),[P,S]=i.useState(!1),b=i.useCallback(async()=>{try{const s=await D();a(s),r(new Set(s.map(h=>h.goal.id))),x(null)}catch(s){x(s instanceof Error?s.message:"Failed to load goals")}d(!1)},[]);i.useEffect(()=>{b()},[b]);const C=s=>{r(h=>{const f=new Set(h);return f.has(s)?f.delete(s):f.add(s),f})},G=s=>{o(h=>h===s.goal.id?null:s.goal.id),s.children.length>0&&!m.has(s.goal.id)&&C(s.goal.id)},w=async()=>{if(p.trim()){S(!0);try{await N("/api/command-post/goals",{method:"POST",body:JSON.stringify({title:p.trim()})}),u(!1),v(""),await b()}catch{}S(!1)}},k=g?E(t,g):null;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(M,{title:"Goals",breadcrumbs:[{label:"Command Post"},{label:"Goals"}],actions:e.jsx(j,{size:"sm",icon:e.jsx(L,{size:14}),onClick:()=>u(!0),children:"Create Goal"})}),l&&e.jsx(F,{variant:"row",count:5}),c&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:c}),!l&&!c&&t.length===0&&e.jsx(O,{icon:e.jsx(y,{size:32}),title:"No goals",description:"Create your first goal to start organizing agent work.",action:{label:"Create Goal",onClick:()=>u(!0)}}),!l&&!c&&t.length>0&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"lg:col-span-2 rounded-xl border border-border bg-bg-secondary overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[t.length," top-level goal",t.length!==1?"s":""]}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"Click a goal to view details"})]}),e.jsx("div",{className:"divide-y divide-border",children:t.map(s=>e.jsx(z,{node:s,expanded:m,toggleExpand:C,selectedId:g,onSelect:G},s.goal.id))})]}),e.jsx("div",{className:"lg:col-span-1",children:k?e.jsx(J,{node:k,onClose:()=>o(null),onRefresh:b}):e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-8 text-center",children:[e.jsx(y,{size:24,className:"text-text-muted mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Select a goal to view details"})]})})]}),e.jsx(A,{open:n,onClose:()=>u(!1),title:"Create Goal",footer:e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:()=>u(!1),children:"Cancel"}),e.jsx(j,{size:"sm",onClick:w,loading:P,disabled:!p.trim(),children:"Create"})]}),children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Goal Title"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"Enter goal title...",value:p,onChange:s=>v(s.target.value),onKeyDown:s=>s.key==="Enter"&&w(),autoFocus:!0})]})})]})}export{de as default};
@@ -1,4 +1,4 @@
1
- import{c as L,j as e,n as C,r as h,b7 as P,b8 as J,b9 as Y,i as Z,ba as ee,o as te,bb as se,bc as re,h as ae,T as E,X as B,aA as q,bd as ne,be as ie,bf as oe,bg as le,b as de}from"./index-D7Clon2u.js";import{B as v}from"./Input-BgyHgQ3D.js";import{P as ce}from"./PageHeader-DPJuAgJk.js";import{E as ue}from"./EmptyState-DH6-Jy6A.js";import{S as pe}from"./SkeletonLoader-D1d-Gyyg.js";import{M as D,B as U,C as z,S as xe,n as he,k as F,r as ge,q as me}from"./TitanCanvas-BQU1yxqf.js";import{F as fe}from"./funnel-B7YvM1ei.js";import{S as be}from"./square-CdiC0J8Z.js";import{a as ye}from"./VoiceOverlay-l6yoasVz.js";/**
1
+ import{c as L,j as e,n as C,r as h,b7 as P,b8 as J,b9 as Y,i as Z,ba as ee,o as te,bb as se,bc as re,h as ae,T as E,X as B,aA as q,bd as ne,be as ie,bf as oe,bg as le,b as de}from"./index-CahJbWSR.js";import{B as v}from"./Input-GTHp2Rkr.js";import{P as ce}from"./PageHeader-BimceqQo.js";import{E as ue}from"./EmptyState-CcKyk5Yn.js";import{S as pe}from"./SkeletonLoader-atQtpcF5.js";import{M as D,B as U,C as z,S as xe,n as he,k as F,r as ge,q as me}from"./TitanCanvas-C-s0A-lv.js";import{F as fe}from"./funnel-PkLdxKyC.js";import{S as be}from"./square-DJpUhlxi.js";import{a as ye}from"./VoiceOverlay-CmNCrLcd.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as v,r as n,bi as A,bj as M,j as e,e as D,f as L,h as q,bk as _,bl as I,bm as O,bn as z}from"./index-D7Clon2u.js";import{R as b,S as G,C as H,M as F}from"./TitanCanvas-BQU1yxqf.js";import{L as B}from"./lightbulb-DRuQ3Chf.js";import"./VoiceOverlay-l6yoasVz.js";/**
1
+ import{c as v,r as n,bi as A,bj as M,j as e,e as D,f as L,h as q,bk as _,bl as I,bm as O,bn as z}from"./index-CahJbWSR.js";import{R as b,S as G,C as H,M as F}from"./TitanCanvas-C-s0A-lv.js";import{L as B}from"./lightbulb-n8gc_XAL.js";import"./VoiceOverlay-CmNCrLcd.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as a,j as e,e as $,ao as E,ap as D,aq as F}from"./index-D7Clon2u.js";import{P as R}from"./PageHeader-DPJuAgJk.js";import{R as O,i as K,c as W}from"./TitanCanvas-BQU1yxqf.js";import{C as _}from"./circle-check-big-B1hMwau0.js";import{a as G,C as H}from"./VoiceOverlay-l6yoasVz.js";import{E as I}from"./eye-off-Cx0M_VQb.js";const L=[{id:"discord",label:"Discord",description:"Discord bot via discord.js",fields:[{key:"token",label:"Bot Token",placeholder:"Bot token from Discord Developer Portal"}]},{id:"telegram",label:"Telegram",description:"Telegram bot via Grammy",fields:[{key:"token",label:"Bot Token",placeholder:"Token from @BotFather"}]},{id:"slack",label:"Slack",description:"Slack workspace via Bolt SDK",fields:[{key:"token",label:"Bot Token",placeholder:"xoxb-..."},{key:"apiKey",label:"Signing Secret",placeholder:"Signing secret from Slack app settings"}]},{id:"whatsapp",label:"WhatsApp",description:"WhatsApp via Twilio",fields:[{key:"token",label:"Auth Token",placeholder:"Twilio auth token"},{key:"apiKey",label:"Account SID",placeholder:"Twilio account SID"}]},{id:"googlechat",label:"Google Chat",description:"Google Chat spaces",fields:[{key:"token",label:"Service Account Key",placeholder:"JSON key path or content"}]},{id:"matrix",label:"Matrix",description:"Matrix protocol (Element, etc.)",fields:[{key:"token",label:"Access Token",placeholder:"Matrix access token"}]},{id:"signal",label:"Signal",description:"Signal messenger",fields:[{key:"token",label:"API Token",placeholder:"Signal API token"}]},{id:"msteams",label:"Microsoft Teams",description:"MS Teams via Bot Framework",fields:[{key:"token",label:"App Password",placeholder:"Bot framework app password"},{key:"apiKey",label:"App ID",placeholder:"Bot framework app ID"}]},{id:"irc",label:"IRC",description:"Internet Relay Chat",fields:[{key:"token",label:"Password",placeholder:"NickServ password (optional)"}]},{id:"mattermost",label:"Mattermost",description:"Self-hosted team chat",fields:[{key:"token",label:"Bot Token",placeholder:"Mattermost bot access token"}]},{id:"lark",label:"Lark",description:"Lark/Feishu messaging",fields:[{key:"token",label:"App Token",placeholder:"Lark app token"},{key:"apiKey",label:"App Secret",placeholder:"Lark app secret"}]},{id:"email_inbound",label:"Email (Inbound)",description:"IMAP email webhook",fields:[{key:"token",label:"IMAP Password",placeholder:"IMAP password or app password"}]},{id:"line",label:"LINE",description:"LINE messaging platform",fields:[{key:"token",label:"Channel Access Token",placeholder:"LINE channel access token"},{key:"apiKey",label:"Channel Secret",placeholder:"LINE channel secret"}]},{id:"zulip",label:"Zulip",description:"Zulip team chat",fields:[{key:"apiKey",label:"API Key",placeholder:"Zulip API key"}]}],Z=[{value:"pairing",label:"Pairing",desc:"User must pair first"},{value:"open",label:"Open",desc:"Anyone can DM"},{value:"closed",label:"Closed",desc:"DMs disabled"}];function q({def:l,config:o,status:b,onSave:f,saving:v}){const[d,k]=a.useState(!1),[x,N]=a.useState(o.enabled),[p,c]=a.useState(""),[m,u]=a.useState(""),[g,w]=a.useState(o.dmPolicy),[y,t]=a.useState(!1),[n,h]=a.useState(!1),[r,i]=a.useState(!1),j=v===l.id,C=(b==null?void 0:b.status)==="connected",A=!!o.token,P=!!o.apiKey,M=()=>{N(!x),i(!0)},B=async()=>{const s={enabled:x,dmPolicy:g};p&&(s.token=p),m&&(s.apiKey=m),await f(l.id,s),c(""),u(""),i(!1)},S=l.fields.find(s=>s.key==="token"),T=l.fields.find(s=>s.key==="apiKey");return e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary",children:[e.jsxs("button",{onClick:()=>k(!d),className:"flex w-full items-center justify-between px-4 py-3 text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[d?e.jsx(G,{className:"h-4 w-4 text-text-muted"}):e.jsx(H,{className:"h-4 w-4 text-text-muted"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-text",children:l.label}),e.jsx("span",{className:"ml-2 text-xs text-text-muted",children:l.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[C&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-success/10 px-2.5 py-0.5 text-xs font-medium text-success",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-success"}),"Connected"]}),e.jsx("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium ${o.enabled?"bg-accent/10 text-accent-hover":"bg-border-light/20 text-text-muted"}`,children:o.enabled?"Enabled":"Disabled"})]})]}),d&&e.jsxs("div",{className:"border-t border-bg-tertiary px-4 py-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm text-text-secondary",children:"Enabled"}),e.jsx("button",{onClick:M,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${x?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${x?"translate-x-6":"translate-x-1"}`})})]}),S&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1 flex items-center gap-2 text-xs text-text-muted",children:[S.label,A&&e.jsx("span",{className:"rounded bg-success/10 px-1.5 py-0.5 text-[10px] text-success",children:"set"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:`channel-${l.id}-token`,name:`channel-${l.id}-token`,type:y?"text":"password",value:p,onChange:s=>{c(s.target.value),i(!0)},placeholder:A?"(configured — enter new value to change)":S.placeholder,className:"w-full rounded-lg border border-border bg-bg px-3 py-2 pr-10 text-sm text-text outline-none focus:border-accent"}),e.jsx("button",{type:"button",onClick:()=>t(!y),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary",children:y?e.jsx(I,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})})]})]}),T&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1 flex items-center gap-2 text-xs text-text-muted",children:[T.label,P&&e.jsx("span",{className:"rounded bg-success/10 px-1.5 py-0.5 text-[10px] text-success",children:"set"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:`channel-${l.id}-api-key`,name:`channel-${l.id}-api-key`,type:n?"text":"password",value:m,onChange:s=>{u(s.target.value),i(!0)},placeholder:P?"(configured — enter new value to change)":T.placeholder,className:"w-full rounded-lg border border-border bg-bg px-3 py-2 pr-10 text-sm text-text outline-none focus:border-accent"}),e.jsx("button",{type:"button",onClick:()=>h(!n),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary",children:n?e.jsx(I,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:"DM Policy"}),e.jsx("div",{className:"flex gap-2",children:Z.map(s=>e.jsx("button",{onClick:()=>{w(s.value),i(!0)},className:`rounded-lg border px-3 py-1.5 text-xs transition-colors ${g===s.value?"border-accent bg-accent/10 text-accent-hover":"border-border text-text-muted hover:border-border-light"}`,title:s.desc,children:s.label},s.value))})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{onClick:B,disabled:j||!r,className:"flex items-center gap-2 rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/80 disabled:opacity-50",children:[e.jsx(W,{className:"h-3.5 w-3.5"}),j?"Saving...":"Save"]})})]})]})}function Y(){const[l,o]=a.useState([]),[b,f]=a.useState({}),[v,d]=a.useState(!0),[k,x]=a.useState(null),[N,p]=a.useState(null),[c,m]=a.useState(null),u=async()=>{try{const[t,n]=await Promise.all([E(),D()]);o(t),f(n)}catch(t){x(t instanceof Error?t.message:"Failed to fetch channels")}finally{d(!1)}};a.useEffect(()=>{u()},[]);const g=(t,n)=>{m({type:t,message:n}),setTimeout(()=>m(null),3e3)},w=async(t,n)=>{var h;p(t);try{await F(t,n);const[r,i]=await Promise.all([E(),D()]);o(r),f(i);const j=((h=L.find(C=>C.id===t))==null?void 0:h.label)??t;g("success",`${j} settings saved (restart gateway to apply)`)}catch(r){g("error",r instanceof Error?r.message:"Failed to save")}finally{p(null)}};if(v)return e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((t,n)=>e.jsx("div",{className:"h-14 animate-pulse rounded-xl border border-border bg-bg-secondary"},n))});if(k)return e.jsx("div",{className:"rounded-xl border border-error/50 bg-bg-secondary p-6 text-center text-error",children:k});const y={enabled:!1,allowFrom:[],dmPolicy:"pairing"};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(R,{title:"Channels",subtitle:`Configure messaging channels — ${l.filter(t=>t.status==="connected").length} connected`,breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Tools"},{label:"Channels"}],actions:e.jsxs("button",{onClick:()=>{d(!0),u()},className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-text-secondary hover:border-border-light hover:text-text",children:[e.jsx(O,{className:"h-3.5 w-3.5"}),"Refresh"]})}),c&&e.jsxs("div",{className:`flex items-center gap-2 rounded-lg border px-4 py-2 text-sm ${c.type==="success"?"border-success/50 text-success":"border-error/50 text-error"}`,children:[c.type==="success"?e.jsx(_,{className:"h-4 w-4"}):e.jsx($,{className:"h-4 w-4"}),c.message]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Built-in"}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-text",children:"WebChat"}),e.jsx("span",{className:"text-xs text-text-muted",children:"HTTP/WebSocket — always enabled"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-success/10 px-2.5 py-0.5 text-xs font-medium text-success",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-success"}),"Connected"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Messaging Channels"}),e.jsx("div",{className:"space-y-2",children:L.map(t=>{const n=b[t.id]??y,h=l.find(r=>r.name===t.id||r.type===t.id);return e.jsx(q,{def:t,config:n,status:h,onSave:w,saving:N},t.id)})})]}),e.jsx("p",{className:"text-xs text-text-muted text-center",children:"Channel changes are saved to config. Restart the gateway to connect/disconnect channels."})]})}export{Y as default};
1
+ import{r as a,j as e,e as $,ao as E,ap as D,aq as F}from"./index-CahJbWSR.js";import{P as R}from"./PageHeader-BimceqQo.js";import{R as O,i as K,c as W}from"./TitanCanvas-C-s0A-lv.js";import{C as _}from"./circle-check-big-DZRE_MbN.js";import{a as G,C as H}from"./VoiceOverlay-CmNCrLcd.js";import{E as I}from"./eye-off-CkgfFYhm.js";const L=[{id:"discord",label:"Discord",description:"Discord bot via discord.js",fields:[{key:"token",label:"Bot Token",placeholder:"Bot token from Discord Developer Portal"}]},{id:"telegram",label:"Telegram",description:"Telegram bot via Grammy",fields:[{key:"token",label:"Bot Token",placeholder:"Token from @BotFather"}]},{id:"slack",label:"Slack",description:"Slack workspace via Bolt SDK",fields:[{key:"token",label:"Bot Token",placeholder:"xoxb-..."},{key:"apiKey",label:"Signing Secret",placeholder:"Signing secret from Slack app settings"}]},{id:"whatsapp",label:"WhatsApp",description:"WhatsApp via Twilio",fields:[{key:"token",label:"Auth Token",placeholder:"Twilio auth token"},{key:"apiKey",label:"Account SID",placeholder:"Twilio account SID"}]},{id:"googlechat",label:"Google Chat",description:"Google Chat spaces",fields:[{key:"token",label:"Service Account Key",placeholder:"JSON key path or content"}]},{id:"matrix",label:"Matrix",description:"Matrix protocol (Element, etc.)",fields:[{key:"token",label:"Access Token",placeholder:"Matrix access token"}]},{id:"signal",label:"Signal",description:"Signal messenger",fields:[{key:"token",label:"API Token",placeholder:"Signal API token"}]},{id:"msteams",label:"Microsoft Teams",description:"MS Teams via Bot Framework",fields:[{key:"token",label:"App Password",placeholder:"Bot framework app password"},{key:"apiKey",label:"App ID",placeholder:"Bot framework app ID"}]},{id:"irc",label:"IRC",description:"Internet Relay Chat",fields:[{key:"token",label:"Password",placeholder:"NickServ password (optional)"}]},{id:"mattermost",label:"Mattermost",description:"Self-hosted team chat",fields:[{key:"token",label:"Bot Token",placeholder:"Mattermost bot access token"}]},{id:"lark",label:"Lark",description:"Lark/Feishu messaging",fields:[{key:"token",label:"App Token",placeholder:"Lark app token"},{key:"apiKey",label:"App Secret",placeholder:"Lark app secret"}]},{id:"email_inbound",label:"Email (Inbound)",description:"IMAP email webhook",fields:[{key:"token",label:"IMAP Password",placeholder:"IMAP password or app password"}]},{id:"line",label:"LINE",description:"LINE messaging platform",fields:[{key:"token",label:"Channel Access Token",placeholder:"LINE channel access token"},{key:"apiKey",label:"Channel Secret",placeholder:"LINE channel secret"}]},{id:"zulip",label:"Zulip",description:"Zulip team chat",fields:[{key:"apiKey",label:"API Key",placeholder:"Zulip API key"}]}],Z=[{value:"pairing",label:"Pairing",desc:"User must pair first"},{value:"open",label:"Open",desc:"Anyone can DM"},{value:"closed",label:"Closed",desc:"DMs disabled"}];function q({def:l,config:o,status:b,onSave:f,saving:v}){const[d,k]=a.useState(!1),[x,N]=a.useState(o.enabled),[p,c]=a.useState(""),[m,u]=a.useState(""),[g,w]=a.useState(o.dmPolicy),[y,t]=a.useState(!1),[n,h]=a.useState(!1),[r,i]=a.useState(!1),j=v===l.id,C=(b==null?void 0:b.status)==="connected",A=!!o.token,P=!!o.apiKey,M=()=>{N(!x),i(!0)},B=async()=>{const s={enabled:x,dmPolicy:g};p&&(s.token=p),m&&(s.apiKey=m),await f(l.id,s),c(""),u(""),i(!1)},S=l.fields.find(s=>s.key==="token"),T=l.fields.find(s=>s.key==="apiKey");return e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary",children:[e.jsxs("button",{onClick:()=>k(!d),className:"flex w-full items-center justify-between px-4 py-3 text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[d?e.jsx(G,{className:"h-4 w-4 text-text-muted"}):e.jsx(H,{className:"h-4 w-4 text-text-muted"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-text",children:l.label}),e.jsx("span",{className:"ml-2 text-xs text-text-muted",children:l.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[C&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-success/10 px-2.5 py-0.5 text-xs font-medium text-success",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-success"}),"Connected"]}),e.jsx("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium ${o.enabled?"bg-accent/10 text-accent-hover":"bg-border-light/20 text-text-muted"}`,children:o.enabled?"Enabled":"Disabled"})]})]}),d&&e.jsxs("div",{className:"border-t border-bg-tertiary px-4 py-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm text-text-secondary",children:"Enabled"}),e.jsx("button",{onClick:M,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${x?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${x?"translate-x-6":"translate-x-1"}`})})]}),S&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1 flex items-center gap-2 text-xs text-text-muted",children:[S.label,A&&e.jsx("span",{className:"rounded bg-success/10 px-1.5 py-0.5 text-[10px] text-success",children:"set"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:`channel-${l.id}-token`,name:`channel-${l.id}-token`,type:y?"text":"password",value:p,onChange:s=>{c(s.target.value),i(!0)},placeholder:A?"(configured — enter new value to change)":S.placeholder,className:"w-full rounded-lg border border-border bg-bg px-3 py-2 pr-10 text-sm text-text outline-none focus:border-accent"}),e.jsx("button",{type:"button",onClick:()=>t(!y),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary",children:y?e.jsx(I,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})})]})]}),T&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1 flex items-center gap-2 text-xs text-text-muted",children:[T.label,P&&e.jsx("span",{className:"rounded bg-success/10 px-1.5 py-0.5 text-[10px] text-success",children:"set"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:`channel-${l.id}-api-key`,name:`channel-${l.id}-api-key`,type:n?"text":"password",value:m,onChange:s=>{u(s.target.value),i(!0)},placeholder:P?"(configured — enter new value to change)":T.placeholder,className:"w-full rounded-lg border border-border bg-bg px-3 py-2 pr-10 text-sm text-text outline-none focus:border-accent"}),e.jsx("button",{type:"button",onClick:()=>h(!n),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary",children:n?e.jsx(I,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:"DM Policy"}),e.jsx("div",{className:"flex gap-2",children:Z.map(s=>e.jsx("button",{onClick:()=>{w(s.value),i(!0)},className:`rounded-lg border px-3 py-1.5 text-xs transition-colors ${g===s.value?"border-accent bg-accent/10 text-accent-hover":"border-border text-text-muted hover:border-border-light"}`,title:s.desc,children:s.label},s.value))})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{onClick:B,disabled:j||!r,className:"flex items-center gap-2 rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/80 disabled:opacity-50",children:[e.jsx(W,{className:"h-3.5 w-3.5"}),j?"Saving...":"Save"]})})]})]})}function Y(){const[l,o]=a.useState([]),[b,f]=a.useState({}),[v,d]=a.useState(!0),[k,x]=a.useState(null),[N,p]=a.useState(null),[c,m]=a.useState(null),u=async()=>{try{const[t,n]=await Promise.all([E(),D()]);o(t),f(n)}catch(t){x(t instanceof Error?t.message:"Failed to fetch channels")}finally{d(!1)}};a.useEffect(()=>{u()},[]);const g=(t,n)=>{m({type:t,message:n}),setTimeout(()=>m(null),3e3)},w=async(t,n)=>{var h;p(t);try{await F(t,n);const[r,i]=await Promise.all([E(),D()]);o(r),f(i);const j=((h=L.find(C=>C.id===t))==null?void 0:h.label)??t;g("success",`${j} settings saved (restart gateway to apply)`)}catch(r){g("error",r instanceof Error?r.message:"Failed to save")}finally{p(null)}};if(v)return e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((t,n)=>e.jsx("div",{className:"h-14 animate-pulse rounded-xl border border-border bg-bg-secondary"},n))});if(k)return e.jsx("div",{className:"rounded-xl border border-error/50 bg-bg-secondary p-6 text-center text-error",children:k});const y={enabled:!1,allowFrom:[],dmPolicy:"pairing"};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(R,{title:"Channels",subtitle:`Configure messaging channels — ${l.filter(t=>t.status==="connected").length} connected`,breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Tools"},{label:"Channels"}],actions:e.jsxs("button",{onClick:()=>{d(!0),u()},className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-text-secondary hover:border-border-light hover:text-text",children:[e.jsx(O,{className:"h-3.5 w-3.5"}),"Refresh"]})}),c&&e.jsxs("div",{className:`flex items-center gap-2 rounded-lg border px-4 py-2 text-sm ${c.type==="success"?"border-success/50 text-success":"border-error/50 text-error"}`,children:[c.type==="success"?e.jsx(_,{className:"h-4 w-4"}):e.jsx($,{className:"h-4 w-4"}),c.message]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Built-in"}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-text",children:"WebChat"}),e.jsx("span",{className:"text-xs text-text-muted",children:"HTTP/WebSocket — always enabled"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-success/10 px-2.5 py-0.5 text-xs font-medium text-success",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-success"}),"Connected"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Messaging Channels"}),e.jsx("div",{className:"space-y-2",children:L.map(t=>{const n=b[t.id]??y,h=l.find(r=>r.name===t.id||r.type===t.id);return e.jsx(q,{def:t,config:n,status:h,onSave:w,saving:N},t.id)})})]}),e.jsx("p",{className:"text-xs text-text-muted text-center",children:"Channel changes are saved to config. Restart the gateway to connect/disconnect channels."})]})}export{Y as default};
@@ -1 +1 @@
1
- import{r as t,aV as o,j as e,aW as d}from"./index-D7Clon2u.js";import{P as m}from"./PageHeader-DPJuAgJk.js";import{R as h,c as x}from"./TitanCanvas-BQU1yxqf.js";import{T as p}from"./trash-2-Byj4OvKB.js";import"./VoiceOverlay-l6yoasVz.js";function v(){const[r,n]=t.useState([]),[i,c]=t.useState(!0),a=t.useCallback(async()=>{c(!0);try{const s=await o();n(s.checkpoints||[])}catch{}c(!1)},[]);t.useEffect(()=>{a()},[a]);const l=async s=>{if(confirm("Delete this checkpoint?"))try{await d(s),await a()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(m,{title:"Checkpoints",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Checkpoints"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:a,disabled:i,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 ${i?"animate-spin":""}`})," Refresh"]})}),e.jsx("div",{className:"space-y-2",children:r.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(x,{className:"w-4 h-4 text-[#6366f1]"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-[#e4e4e7]",children:[s.sessionId.slice(0,16),"..."]}),e.jsx("div",{className:"text-xs text-[#52525b]",children:new Date(s.createdAt).toLocaleString()})]})]}),e.jsx("button",{onClick:()=>l(s.sessionId),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46] hover:text-red-400",children:e.jsx(p,{className:"w-3.5 h-3.5"})})]},s.sessionId))})]})}export{v as default};
1
+ import{r as t,aV as o,j as e,aW as d}from"./index-CahJbWSR.js";import{P as m}from"./PageHeader-BimceqQo.js";import{R as h,c as x}from"./TitanCanvas-C-s0A-lv.js";import{T as p}from"./trash-2-CK7yQ55V.js";import"./VoiceOverlay-CmNCrLcd.js";function v(){const[r,n]=t.useState([]),[i,c]=t.useState(!0),a=t.useCallback(async()=>{c(!0);try{const s=await o();n(s.checkpoints||[])}catch{}c(!1)},[]);t.useEffect(()=>{a()},[a]);const l=async s=>{if(confirm("Delete this checkpoint?"))try{await d(s),await a()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(m,{title:"Checkpoints",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Checkpoints"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:a,disabled:i,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 ${i?"animate-spin":""}`})," Refresh"]})}),e.jsx("div",{className:"space-y-2",children:r.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(x,{className:"w-4 h-4 text-[#6366f1]"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-[#e4e4e7]",children:[s.sessionId.slice(0,16),"..."]}),e.jsx("div",{className:"text-xs text-[#52525b]",children:new Date(s.createdAt).toLocaleString()})]})]}),e.jsx("button",{onClick:()=>l(s.sessionId),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46] hover:text-red-400",children:e.jsx(p,{className:"w-3.5 h-3.5"})})]},s.sessionId))})]})}export{v as default};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkTab-IG-F6Qll.js","assets/index-D7Clon2u.js","assets/index-D0RJ8701.css","assets/proxy-Cc5bR828.js","assets/TitanCanvas-BQU1yxqf.js","assets/VoiceOverlay-l6yoasVz.js","assets/TitanCanvas-BfitWg9R.css","assets/play-hUyR3CVS.js","assets/trash-2-Byj4OvKB.js","assets/pause-DqkRWPB_.js","assets/SessionsTab-Jq3UKQCI.js","assets/CPInbox-B6iaIbNG.js","assets/Input-BgyHgQ3D.js","assets/PageHeader-DPJuAgJk.js","assets/EmptyState-DH6-Jy6A.js","assets/SkeletonLoader-D1d-Gyyg.js","assets/funnel-B7YvM1ei.js","assets/square-CdiC0J8Z.js","assets/CPFiles-BDToRw0a.js","assets/TraceViewer-BbISy_ET.js","assets/trending-up-Dh_CffGX.js","assets/git-branch-BhTBN3J6.js","assets/chart-column-rR6tb72l.js","assets/arrow-left-C_H9Z2Tm.js","assets/CPSocial-CsFrwZRC.js","assets/lightbulb-DRuQ3Chf.js","assets/CPDashboard-JmBLBbj7.js","assets/StatusBadge-DxeA9LNd.js","assets/dollar-sign-DhYwsTnR.js","assets/target-DemL8_0v.js","assets/CPGoals-Dh9qJNWa.js","assets/InlineEditableField-DOJNOL8m.js","assets/Tooltip-CNPQr7IO.js","assets/CPAgents-CvkZDm_3.js"])))=>i.map(i=>d[i]);
2
- import{c as E,r as s,j as e,n as ne,k as le,f as A,h as L,A as P,T as F,o as K,p as oe,q as ce,s as ie,_,b as O,v as de,w as xe,x as ue,y as me,z as pe,B as he,D as be,E as ge,I as je}from"./index-D7Clon2u.js";import{B as q}from"./Input-BgyHgQ3D.js";import{A as fe,m as G}from"./proxy-Cc5bR828.js";import{I as $}from"./InlineEditableField-DOJNOL8m.js";import{H as ye}from"./Tooltip-CNPQr7IO.js";import{C as H}from"./VoiceOverlay-l6yoasVz.js";import{B as ve,W as Q,C as X,M as Y,U as Ne,F as we,T as Ce,R as ke,S as Se,P as V}from"./TitanCanvas-BQU1yxqf.js";import{P as ze}from"./pause-DqkRWPB_.js";import{D as W}from"./dollar-sign-DhYwsTnR.js";import{G as ee}from"./git-branch-BhTBN3J6.js";import{C as te}from"./chart-column-rR6tb72l.js";import{T as Te}from"./target-DemL8_0v.js";import{T as se}from"./trash-2-Byj4OvKB.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkTab-BjLNmgIK.js","assets/index-CahJbWSR.js","assets/index-D0RJ8701.css","assets/proxy-CzZDfLmm.js","assets/TitanCanvas-C-s0A-lv.js","assets/VoiceOverlay-CmNCrLcd.js","assets/TitanCanvas-BfitWg9R.css","assets/play-CcJ9BnCh.js","assets/trash-2-CK7yQ55V.js","assets/pause-DCV52koX.js","assets/SessionsTab-JQbltWww.js","assets/CPInbox-tMSbmQ9H.js","assets/Input-GTHp2Rkr.js","assets/PageHeader-BimceqQo.js","assets/EmptyState-CcKyk5Yn.js","assets/SkeletonLoader-atQtpcF5.js","assets/funnel-PkLdxKyC.js","assets/square-DJpUhlxi.js","assets/CPFiles-CxgxjQcO.js","assets/TraceViewer-BniolyBx.js","assets/trending-up-DGjFyubC.js","assets/git-branch-BM-Gw95X.js","assets/chart-column-BtNO6sRy.js","assets/arrow-left-DwqHtJiU.js","assets/CPSocial-nb-j7sOE.js","assets/lightbulb-n8gc_XAL.js","assets/CPDashboard-Bf0-SyCh.js","assets/StatusBadge-BtfSPoW2.js","assets/dollar-sign-aVG3a5eL.js","assets/target-DWcmM_9m.js","assets/CPGoals-BsmCMTvT.js","assets/InlineEditableField-CnvF-yFR.js","assets/Tooltip-70UK0E2I.js","assets/CPAgents-DYUtPzSq.js"])))=>i.map(i=>d[i]);
2
+ import{c as E,r as s,j as e,n as ne,k as le,f as A,h as L,A as P,T as F,o as K,p as oe,q as ce,s as ie,_,b as O,v as de,w as xe,x as ue,y as me,z as pe,B as he,D as be,E as ge,I as je}from"./index-CahJbWSR.js";import{B as q}from"./Input-GTHp2Rkr.js";import{A as fe,m as G}from"./proxy-CzZDfLmm.js";import{I as $}from"./InlineEditableField-CnvF-yFR.js";import{H as ye}from"./Tooltip-70UK0E2I.js";import{C as H}from"./VoiceOverlay-CmNCrLcd.js";import{B as ve,W as Q,C as X,M as Y,U as Ne,F as we,T as Ce,R as ke,S as Se,P as V}from"./TitanCanvas-C-s0A-lv.js";import{P as ze}from"./pause-DCV52koX.js";import{D as W}from"./dollar-sign-aVG3a5eL.js";import{G as ee}from"./git-branch-BM-Gw95X.js";import{C as te}from"./chart-column-BtNO6sRy.js";import{T as Te}from"./target-DWcmM_9m.js";import{T as se}from"./trash-2-CK7yQ55V.js";/**
3
3
  * @license lucide-react v0.513.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -26,4 +26,4 @@ import{c as E,r as s,j as e,n as ne,k as le,f as A,h as L,A as P,T as F,o as K,p
26
26
  * See the LICENSE file in the root directory of this source tree.
27
27
  */const Ae=[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]],ae=E("scale",Ae),Le={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl"};function M({open:t,onClose:l,title:a,children:m,footer:i,size:j="md"}){const p=s.useCallback(n=>{n.key==="Escape"&&l()},[l]);return s.useEffect(()=>{if(t)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[t,p]),e.jsx(fe,{children:t&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",children:[e.jsx(G.div,{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:l,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15}}),e.jsxs(G.div,{className:ne("relative w-full mx-4 rounded-xl border border-border bg-bg-secondary shadow-2xl",Le[j]),initial:{opacity:0,y:-16,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-16,scale:.97},transition:{duration:.2,ease:"easeOut"},children:[a&&e.jsx("div",{className:"border-b border-border px-5 py-4",children:e.jsx("h2",{className:"text-base font-semibold text-text",children:a})}),e.jsx("div",{className:"px-5 py-4",children:m}),i&&e.jsx("div",{className:"flex items-center justify-end gap-2 border-t border-border px-5 py-3",children:i})]})]})})}function re({open:t,title:l,message:a,confirmLabel:m="Confirm",cancelLabel:i="Cancel",variant:j="danger",onConfirm:p,onCancel:n}){const[g,h]=s.useState(!1),c=async()=>{h(!0);try{await p()}finally{h(!1)}};return e.jsx(M,{open:t,onClose:()=>!g&&n(),title:l,size:"sm",footer:e.jsxs(e.Fragment,{children:[e.jsx(q,{variant:"ghost",size:"sm",onClick:n,disabled:g,children:i}),e.jsx(q,{variant:j==="danger"?"danger":"primary",size:"sm",onClick:c,loading:g,children:m})]}),children:e.jsx("div",{className:"text-sm text-text-secondary leading-relaxed",children:a})})}function Re(t){switch(t){case"active":return e.jsx(P,{size:12,className:"text-success animate-pulse"});case"paused":return e.jsx(ze,{size:12,className:"text-warning"});case"error":return e.jsx(F,{size:12,className:"text-error"});default:return e.jsx(ve,{size:12,className:"text-text-muted"})}}function Ie(t){switch(t){case"active":return"border-success/30 bg-success/5";case"paused":return"border-warning/30 bg-warning/5";case"error":return"border-error/30 bg-error/5";default:return"border-border bg-bg-secondary"}}function Oe({agents:t,runs:l,collapsed:a=!1,onToggle:m,onAgentClick:i}){const[j,p]=s.useState(null);return a?e.jsxs("div",{className:"w-10 border-l border-border bg-bg-secondary flex flex-col items-center py-3 gap-3 shrink-0",children:[e.jsx("button",{onClick:m,className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted",children:e.jsx(le,{size:14})}),t.map(n=>e.jsxs("button",{className:"relative",title:n.name,onClick:()=>i==null?void 0:i(n),children:[e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[9px] font-bold ${n.status==="error"?"bg-error/20 text-error":n.status==="active"?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"}`,children:n.name.charAt(0).toUpperCase()}),n.status==="active"&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-success animate-pulse"})]},n.id))]}):e.jsxs("div",{className:"w-64 border-l border-border bg-bg-secondary flex flex-col h-full shrink-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[e.jsx("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Agents"}),e.jsx("button",{onClick:m,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted",children:e.jsx(H,{size:14})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-2",children:[t.length===0&&e.jsx("div",{className:"text-center py-4 text-xs text-text-muted",children:"No agents registered"}),t.map(n=>{var f;const g=j===n.id,h=l.filter(y=>y.agentId===n.id),c=h[0],d=h.filter(y=>y.status==="failed"||y.status==="error").length;return e.jsxs("div",{className:`rounded-lg border p-2 cursor-pointer transition-colors ${Ie(n.status)}`,onClick:y=>{y.target.closest(".expand-toggle")?p(g?null:n.id):i==null||i(n)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center text-[10px] font-bold ${n.status==="error"?"bg-error/20 text-error":n.status==="active"?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"}`,children:n.name.charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-medium truncate",children:n.name}),e.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-1",children:[Re(n.status),e.jsx("span",{className:"capitalize",children:n.status}),n.model&&e.jsxs("span",{className:"truncate",children:["· ",n.model.split("/").pop()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[n.status==="active"&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-success animate-pulse"}),e.jsx("button",{className:"expand-toggle p-0.5 rounded hover:bg-bg-tertiary text-text-muted",onClick:y=>{y.stopPropagation(),p(g?null:n.id)},children:e.jsx(H,{size:12,className:`transition-transform ${g?"rotate-90":""}`})})]})]}),g&&e.jsxs("div",{className:"mt-2 space-y-2 border-t border-border/50 pt-2",children:[e.jsxs("div",{className:"text-[10px] text-text-muted space-y-0.5",children:[e.jsxs("div",{children:["Role: ",n.role||"general"]}),e.jsxs("div",{children:["Tasks: ",n.totalTasksCompleted??0," completed"]}),n.totalCostUsd!==void 0&&e.jsxs("div",{children:["Cost: $",n.totalCostUsd.toFixed(2)]}),d>0&&e.jsxs("div",{className:"text-error",children:[d," failed run",d===1?"":"s"]})]}),c&&e.jsxs("div",{className:"text-[10px] bg-bg rounded p-1.5 border border-border",children:[e.jsxs("div",{className:"font-medium text-text-secondary flex items-center gap-1",children:[c.status==="succeeded"?e.jsx(A,{size:10,className:"text-success"}):c.status==="failed"||c.status==="error"?e.jsx(L,{size:10,className:"text-error"}):e.jsx(P,{size:10,className:"text-cyan animate-pulse"}),"Latest run"]}),e.jsxs("div",{className:c.status==="failed"||c.status==="error"?"text-error":"text-success",children:[c.status," · ",((f=c.toolsUsed)==null?void 0:f.length)??0," tools"]}),c.error&&e.jsx("div",{className:"text-error truncate mt-0.5",children:c.error})]})]})]},n.id)})]})]})}function J(t){const l={active:"bg-success/10 text-success border-success/20",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",paused:"bg-warning/10 text-warning border-warning/20",error:"bg-error/10 text-error border-error/20",stopped:"bg-zinc-500/10 text-zinc-400 border-zinc-500/20"};return l[t]||l.idle}function I(t){const l=Math.floor((Date.now()-new Date(t).getTime())/1e3);return l<60?`${l}s`:l<3600?`${Math.floor(l/60)}m`:l<86400?`${Math.floor(l/3600)}h`:`${Math.floor(l/86400)}d`}function Be({agent:t,onClose:l}){const[a,m]=s.useState([]),[i,j]=s.useState([]),[p,n]=s.useState(!0),[g,h]=s.useState(null),c=s.useCallback(async()=>{try{const[r,u]=await Promise.all([K(t.id,10),oe(20,void 0)]);m(r),j(u.traces||[])}catch{}n(!1)},[t.id]);s.useEffect(()=>{c();const r=setInterval(c,1e4);return()=>clearInterval(r)},[c]);const d=a[0],f=a.filter(r=>r.status==="failed"||r.status==="error"),y=a.reduce((r,u)=>r+u.toolsUsed.length,0);return e.jsx(M,{open:!0,onClose:l,size:"lg",title:t.name,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-12 h-12 rounded-xl flex items-center justify-center text-lg font-bold border ${J(t.status)}`,children:t.name.charAt(0).toUpperCase()}),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-semibold text-text",children:t.name}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full border capitalize ${J(t.status)}`,children:t.status})]}),e.jsxs("div",{className:"text-[11px] text-text-muted mt-0.5",children:[t.title||t.role," · ",t.model.split("/").pop()," · heartbeat ",I(t.lastHeartbeat)," ago"]})]})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[{icon:A,label:"Tasks",value:t.totalTasksCompleted,color:"text-success"},{icon:W,label:"Cost",value:`$${t.totalCostUsd.toFixed(2)}`,color:"text-warning"},{icon:Q,label:"Tools",value:y,color:"text-accent"},{icon:L,label:"Failed",value:f.length,color:f.length>0?"text-error":"text-text-muted"}].map(r=>e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg p-2.5 text-center",children:[e.jsx(r.icon,{size:14,className:`mx-auto mb-1 ${r.color}`}),e.jsx("div",{className:"text-sm font-bold text-text",children:r.value}),e.jsx("div",{className:"text-[9px] text-text-muted uppercase tracking-wider",children:r.label})]},r.label))}),t.status==="active"&&d&&d.status==="running"&&e.jsxs("div",{className:"bg-success/5 border border-success/20 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-success mb-1",children:[e.jsx(P,{size:12,className:"animate-pulse"}),e.jsx("span",{className:"font-medium",children:"Currently working"})]}),e.jsxs("div",{className:"text-[11px] text-text-secondary",children:["Run started ",I(d.startedAt)," ago · ",d.toolsUsed.length," tools used so far"]})]}),t.status==="error"&&(d==null?void 0:d.error)&&e.jsxs("div",{className:"bg-error/5 border border-error/20 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-error mb-1",children:[e.jsx(F,{size:12}),e.jsx("span",{className:"font-medium",children:"Last error"})]}),e.jsx("div",{className:"text-[11px] text-text-secondary font-mono",children:d.error})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-text-secondary",children:[e.jsx(ee,{size:12,className:"text-accent"}),"Recent Runs"]}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:[a.length," total"]})]}),p?e.jsx("div",{className:"space-y-1.5",children:[1,2,3].map(r=>e.jsx("div",{className:"h-10 rounded-lg bg-bg-secondary animate-pulse"},r))}):a.length===0?e.jsx("div",{className:"text-center py-4 text-[11px] text-text-muted",children:"No runs recorded yet"}):e.jsx("div",{className:"space-y-1.5 max-h-48 overflow-y-auto pr-1",children:a.map(r=>e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2 rounded-lg bg-bg-secondary border border-border",children:[r.status==="succeeded"?e.jsx(A,{size:12,className:"text-success shrink-0"}):r.status==="failed"||r.status==="error"?e.jsx(L,{size:12,className:"text-error shrink-0"}):e.jsx(Ue,{size:12,className:"text-cyan animate-spin shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-[11px] text-text-secondary truncate",children:[r.source," · ",r.toolsUsed.length," tools"]}),e.jsxs("div",{className:"text-[10px] text-text-muted",children:[r.durationMs?`${r.durationMs}ms`:"..."," · ",I(r.startedAt)," ago"]})]}),r.error&&e.jsx("span",{className:"text-[10px] text-error truncate max-w-[120px]",title:r.error,children:r.error})]},r.id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-text-secondary",children:[e.jsx(te,{size:12,className:"text-accent"}),"Recent Traces"]}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:[i.length," loaded"]})]}),i.length===0?e.jsx("div",{className:"text-center py-4 text-[11px] text-text-muted",children:"No traces available"}):e.jsx("div",{className:"space-y-1 max-h-40 overflow-y-auto pr-1",children:i.slice(0,10).map(r=>e.jsxs("button",{onClick:()=>h(r),className:"w-full text-left px-2.5 py-2 rounded-lg bg-bg-secondary border border-border hover:bg-bg-secondary/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r.status==="running"?e.jsx(P,{size:12,className:"text-cyan animate-pulse shrink-0"}):r.status==="completed"?e.jsx(A,{size:12,className:"text-success shrink-0"}):e.jsx(L,{size:12,className:"text-error shrink-0"}),e.jsx("span",{className:"text-[11px] text-text-secondary truncate flex-1",children:r.message}),e.jsx("span",{className:"text-[10px] text-text-muted shrink-0",children:r.totalMs?`${r.totalMs}ms`:"..."})]}),e.jsxs("div",{className:"flex gap-2 mt-0.5 text-[10px] text-text-muted ml-5",children:[e.jsxs("span",{children:[r.toolCalls.length," tools"]}),e.jsxs("span",{children:[r.rounds," rounds"]}),r.error&&e.jsx("span",{className:"text-error truncate",children:r.error})]})]},r.traceId))})]}),g&&e.jsx(Fe,{trace:g,onClose:()=>h(null)})]})})}function Ue({size:t,className:l}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",className:`animate-spin ${l||""}`,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",fill:"none",strokeDasharray:"31.4 31.4",opacity:"0.3"}),e.jsx("path",{d:"M12 2a10 10 0 0 1 10 10",stroke:"currentColor",strokeWidth:"3",fill:"none"})]})}function Fe({trace:t,onClose:l}){return e.jsx(M,{open:!0,onClose:l,size:"md",title:`Trace ${t.traceId.slice(0,8)}`,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-xs text-text-secondary truncate",children:t.message}),e.jsxs("div",{className:"flex gap-3 text-[10px] text-text-muted",children:[e.jsx("span",{className:t.status==="completed"?"text-success":t.status==="failed"?"text-error":"text-cyan",children:t.status}),e.jsxs("span",{children:[t.totalMs,"ms"]}),e.jsxs("span",{children:[t.rounds," rounds"]}),t.model&&e.jsx("span",{children:t.model.split("/").pop()})]}),t.spans.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:"Spans"}),e.jsx("div",{className:"space-y-1",children:t.spans.map((a,m)=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx(X,{size:10,className:"text-text-muted shrink-0"}),e.jsx("span",{className:"text-text-secondary font-mono",children:a.name}),e.jsxs("span",{className:"text-text-muted",children:[a.durationMs,"ms"]})]},m))})]}),t.toolCalls.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:"Tool Calls"}),e.jsx("div",{className:"space-y-1",children:t.toolCalls.map((a,m)=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx(Q,{size:10,className:a.success?"text-success":"text-error"}),e.jsx("span",{className:"text-text-secondary font-mono",children:a.tool}),e.jsxs("span",{className:"text-text-muted",children:[a.durationMs,"ms"]}),e.jsxs("span",{className:"text-text-muted",children:["round ",a.round]})]},m))})]}),t.error&&e.jsxs("div",{className:"bg-error/5 border border-error/20 rounded-lg p-2.5",children:[e.jsx("div",{className:"text-[10px] text-error uppercase tracking-wider mb-1",children:"Error"}),e.jsx("div",{className:"text-[11px] text-text-secondary font-mono",children:t.error})]})]})})}function T({label:t}){return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-accent/30 border-t-accent rounded-full animate-spin"}),e.jsxs("span",{className:"text-sm text-text-muted",children:["Loading ",t,"…"]})]})})}function Ve(t){const l=Math.floor((Date.now()-new Date(t).getTime())/1e3);return l<60?`${l}s`:l<3600?`${Math.floor(l/60)}m`:l<86400?`${Math.floor(l/3600)}h`:`${Math.floor(l/86400)}d`}function Z({status:t}){const l={active:"bg-success/10 text-success",idle:"bg-warning/10 text-warning",running:"bg-cyan/10 text-cyan",paused:"bg-info/10 text-info",error:"bg-error/10 text-error",stopped:"bg-bg-tertiary text-text-muted",pending:"bg-warning/10 text-warning",approved:"bg-success/10 text-success",rejected:"bg-error/10 text-error",succeeded:"bg-success/10 text-success",failed:"bg-error/10 text-error",backlog:"bg-bg-tertiary text-text-muted",todo:"bg-info/10 text-info",in_progress:"bg-cyan/10 text-cyan",in_review:"bg-purple/10 text-purple-light",done:"bg-success/10 text-success",blocked:"bg-error/10 text-error",cancelled:"bg-bg-tertiary text-text-muted",critical:"bg-error/10 text-error",high:"bg-warning/10 text-warning",medium:"bg-warning/10 text-warning",low:"bg-bg-tertiary text-text-muted"},a=t||"unknown";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium ${l[a]||"bg-bg-tertiary text-text-muted"}`,children:a.replace("_"," ")})}function D({icon:t,title:l,count:a,action:m,help:i}){return e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t,{size:14,className:"text-accent-light"}),e.jsx("h2",{className:"text-sm font-semibold text-text",children:l}),a!==void 0&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-accent/10 text-accent-light",children:a}),i&&e.jsx(ye,{title:i.title,description:i.description})]}),m]})}function We({agents:t}){const[l,a]=s.useState([]),[m,i]=s.useState([]),[j,p]=s.useState(!1),[n,g]=s.useState(""),[h,c]=s.useState(""),[d,f]=s.useState(null),y=s.useCallback(()=>{de().then(a).catch(()=>{}),xe().then(o=>i(o)).catch(()=>{})},[]);s.useEffect(()=>{y()},[y]);const r=async()=>{n.trim()&&(await me({name:n.trim(),mission:h.trim()||void 0}),g(""),c(""),p(!1),y())},u=async(o,k,z)=>{try{await pe(o,{[k]:z}),y()}catch(S){alert(`Save failed: ${S.message}`)}},x=async()=>{d&&(await he(d.id),f(null),y())},v=async(o,k,z)=>{try{await je(o,{[k]:z||void 0}),y()}catch(S){alert(`Save failed: ${S.message}`)}},C=["ceo","manager","engineer","researcher","general"];function b(o,k=0){var S;const z=((S=t.find(N=>N.id===o.id))==null?void 0:S.reportsTo)||"";return o.model&&o.model.split("/").pop(),e.jsxs("div",{className:k>0?"ml-6 border-l border-border pl-4":"",children:[e.jsxs("div",{className:"bg-bg-tertiary/30 border border-border rounded-xl p-3.5 mb-2 max-w-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2",children:[e.jsx("span",{className:"text-[14px] font-semibold text-text min-w-0",children:e.jsx($,{value:o.name,onSave:N=>v(o.id,"name",N),placeholder:"Agent name"})}),e.jsx(Z,{status:o.status})]}),e.jsxs("div",{className:"grid grid-cols-[72px_1fr] gap-x-3 gap-y-1.5 text-[11px]",children:[e.jsx("span",{className:"text-text-muted",children:"Title"}),e.jsx("span",{className:"text-text-secondary min-w-0",children:e.jsx($,{value:o.title||"",onSave:N=>v(o.id,"title",N),placeholder:"Add a title",emptyLabel:"—"})}),e.jsx("span",{className:"text-text-muted",children:"Role"}),e.jsx("select",{value:o.role,onChange:N=>v(o.id,"role",N.target.value),className:"bg-bg-tertiary border border-border rounded px-1.5 py-0.5 text-[11px] text-text-secondary capitalize focus:outline-none focus:border-accent/30 justify-self-start",children:C.map(N=>e.jsx("option",{value:N,children:N},N))}),e.jsx("span",{className:"text-text-muted",children:"Reports to"}),e.jsxs("select",{value:z,onChange:N=>v(o.id,"reportsTo",N.target.value),className:"bg-bg-tertiary border border-border rounded px-1.5 py-0.5 text-[11px] text-text-secondary focus:outline-none focus:border-accent/30 justify-self-start",children:[e.jsx("option",{value:"",children:"— nobody"}),t.filter(N=>N.id!==o.id).map(N=>e.jsx("option",{value:N.id,children:N.name},N.id))]}),e.jsx("span",{className:"text-text-muted",children:"Model"}),e.jsx("span",{className:"text-text-secondary min-w-0",children:e.jsx($,{value:o.model||"",onSave:N=>v(o.id,"model",N),placeholder:"e.g. ollama/qwen3.5:cloud",emptyLabel:"—"})})]})]}),o.reports.map(N=>b(N,k+1))]},o.id)}return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(D,{icon:U,title:"Organization Chart",count:t.length}),e.jsx("div",{className:"p-4",children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(U,{size:24,className:"mx-auto mb-2 text-text/10"}),e.jsx("p",{className:"text-[12px] text-text-muted",children:"No agents in org chart yet"}),e.jsx("p",{className:"text-[10px] text-text-muted mt-1",children:'Spawn agents from the Agents tab, then set "Reports to" on each to build the hierarchy.'})]}):l.map(o=>b(o))})]}),e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(D,{icon:B,title:"Companies",count:m.length,action:e.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-1 px-2.5 py-1 text-[10px] bg-accent text-text rounded-lg hover:bg-accent-hover",children:[e.jsx(V,{size:10})," New"]})}),j&&e.jsxs("div",{className:"p-4 border-b border-border bg-bg-secondary/30 space-y-2",children:[e.jsx("input",{value:n,onChange:o=>g(o.target.value),placeholder:"Company name...",className:"w-full bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[13px] text-text placeholder-white/20 focus:outline-none focus:border-accent/30",onKeyDown:o=>o.key==="Enter"&&r()}),e.jsx("input",{value:h,onChange:o=>c(o.target.value),placeholder:"Mission (optional)...",className:"w-full bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[12px] text-text-secondary placeholder-white/15 focus:outline-none focus:border-accent/30"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:r,className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded-lg",children:"Create"}),e.jsx("button",{onClick:()=>p(!1),className:"px-3 py-1.5 text-[11px] text-text-muted",children:"Cancel"})]})]}),e.jsx("div",{className:"divide-y divide-border/30",children:m.length===0?e.jsx("div",{className:"py-6 text-center text-[12px] text-text-muted",children:'No companies yet — click "+ New" to create one.'}):m.map(o=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 hover:bg-bg-secondary/30 transition-colors",children:[e.jsx(B,{size:14,className:"text-accent-light flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[e.jsx("div",{className:"text-[13px] text-text font-medium",children:e.jsx($,{value:o.name,onSave:k=>u(o.id,"name",k),placeholder:"Company name"})}),e.jsx("div",{className:"text-[10px] text-text-muted",children:e.jsx($,{value:o.mission||"",onSave:k=>u(o.id,"mission",k),placeholder:"Add a mission",emptyLabel:"(no mission — click to add)"})})]}),e.jsx(Z,{status:o.status||"active"}),e.jsx("button",{onClick:()=>f({id:o.id,name:o.name}),className:"p-1 rounded text-text-muted hover:text-error hover:bg-error/10 transition-colors",title:"Delete company",children:e.jsx(se,{size:12})})]},o.id))})]}),e.jsx(re,{open:!!d,title:`Delete company "${(d==null?void 0:d.name)||""}"?`,message:"This removes the company record. Agents and goals linked to it stay; they just lose the company association. This can't be undone.",confirmLabel:"Delete",onConfirm:x,onCancel:()=>f(null)})]})}function qe({budgets:t,onRefresh:l}){const[a,m]=s.useState(null),[i,j]=s.useState(!1),[p,n]=s.useState(null),g=async()=>{p&&(await ue(p.id),n(null),l())};return e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(D,{icon:W,title:"Budget Policies",count:t.length,action:e.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-1 px-2.5 py-1 text-[10px] bg-accent text-text rounded-lg hover:bg-accent-hover",children:[e.jsx(V,{size:10})," New Budget"]})}),e.jsx("div",{className:"p-4 space-y-3",children:t.length===0?e.jsx("div",{className:"text-center py-6 text-[12px] text-text-muted",children:'No budget policies yet — click "+ New Budget" to set spending limits per agent, goal, or globally.'}):t.map(h=>{const c=h.limitUsd>0?Math.min(100,h.currentSpend/h.limitUsd*100):0,d=c>=100?"bg-error":c>=80?"bg-warning":"bg-success";return e.jsxs("div",{className:"bg-bg-tertiary/30 border border-border rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-[12px] font-medium text-text",children:h.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-text-muted capitalize",children:h.scope.type}),e.jsx("span",{className:"text-[10px] text-text-muted",children:h.period}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${h.enabled?"text-success bg-success/10":"text-text-muted bg-bg-tertiary"}`,children:h.enabled?"on":"off"}),e.jsx("button",{onClick:()=>m(h),className:"text-[10px] text-text-muted hover:text-text-secondary px-1",title:"Edit budget",children:"Edit"}),e.jsx("button",{onClick:()=>n(h),className:"p-1 rounded text-text-muted hover:text-error hover:bg-error/10 transition-colors",title:"Delete budget",children:e.jsx(se,{size:12})})]})]}),e.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden mb-1.5",children:e.jsx("div",{className:`h-full ${d} rounded-full transition-all`,style:{width:`${c}%`}})}),e.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted",children:[e.jsxs("span",{children:["$",h.currentSpend.toFixed(2)," spent"]}),e.jsxs("span",{children:["$",h.limitUsd.toFixed(2)," limit · action: ",h.action]})]})]},h.id)})}),(i||a)&&e.jsx(Ge,{existing:a,onClose:()=>{j(!1),m(null)},onSaved:()=>{j(!1),m(null),l()}}),e.jsx(re,{open:!!p,title:`Delete budget "${(p==null?void 0:p.name)||""}"?`,message:"The policy and its spend history are removed. Agents/goals it covered will no longer be budget-enforced unless another policy applies.",confirmLabel:"Delete",onConfirm:g,onCancel:()=>n(null)})]})}function Ge({existing:t,onClose:l,onSaved:a}){var S,N;const m=!!t,[i,j]=s.useState((t==null?void 0:t.name)||""),[p,n]=s.useState((t==null?void 0:t.scope.type)||"global"),[g,h]=s.useState((t==null?void 0:t.scope.targetId)||""),[c,d]=s.useState((t==null?void 0:t.period)||"daily"),[f,y]=s.useState(((S=t==null?void 0:t.limitUsd)==null?void 0:S.toString())||"10"),[r,u]=s.useState(((N=t==null?void 0:t.warningThresholdPercent)==null?void 0:N.toString())||"80"),[x,v]=s.useState((t==null?void 0:t.action)||"warn"),[C,b]=s.useState((t==null?void 0:t.enabled)??!0),[o,k]=s.useState(!1),z=async()=>{if(i.trim()){k(!0);try{const w={name:i.trim(),scope:{type:p,targetId:p==="global"?void 0:g||void 0},period:c,limitUsd:Number(f)||0,warningThresholdPercent:Number(r)||80,action:x,enabled:C};m&&t?await be(t.id,w):await ge(w),a()}catch(w){alert(`Save failed: ${w.message}`)}finally{k(!1)}}};return e.jsx(M,{open:!0,onClose:l,size:"md",title:m?"Edit Budget Policy":"New Budget Policy",footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:l,className:"px-3 py-1.5 text-[11px] text-text-secondary hover:text-text",children:"Cancel"}),e.jsx("button",{onClick:z,disabled:o||!i.trim(),className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded hover:bg-accent-hover disabled:opacity-50",children:o?"Saving…":m?"Save changes":"Create budget"})]}),children:e.jsxs("div",{className:"space-y-3 text-[12px]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Name"}),e.jsx("input",{value:i,onChange:w=>j(w.target.value),placeholder:"e.g. Daily global cap",className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none focus:border-accent/40"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Scope"}),e.jsxs("select",{value:p,onChange:w=>n(w.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[e.jsx("option",{value:"global",children:"Global (all agents)"}),e.jsx("option",{value:"agent",children:"Per-agent"}),e.jsx("option",{value:"goal",children:"Per-goal"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Target ID"}),e.jsx("input",{value:g,onChange:w=>h(w.target.value),placeholder:p==="global"?"n/a":p==="agent"?"agent-id":"goal-id",disabled:p==="global",className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none disabled:opacity-40"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Period"}),e.jsxs("select",{value:c,onChange:w=>d(w.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Limit (USD)"}),e.jsx("input",{type:"number",step:"0.01",value:f,onChange:w=>y(w.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none focus:border-accent/40"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Warn at %"}),e.jsx("input",{type:"number",min:"1",max:"100",value:r,onChange:w=>u(w.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none focus:border-accent/40"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Action at limit"}),e.jsxs("select",{value:x,onChange:w=>v(w.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[e.jsx("option",{value:"warn",children:"Warn only"}),e.jsx("option",{value:"pause",children:"Pause agent"}),e.jsx("option",{value:"stop",children:"Stop agent"})]})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsxs("label",{className:"flex items-center gap-2 text-text-secondary cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:C,onChange:w=>b(w.target.checked),className:"accent-accent"}),e.jsx("span",{children:"Enabled"})]})})]})]})})}function He({dashboard:t}){const[l,a]=s.useState([]),[m,i]=s.useState(""),[j,p]=s.useState(!1),[n,g]=s.useState(""),[h,c]=s.useState(),d=s.useRef(null),f=s.useRef(null),y=s.useCallback(()=>{var v;const u=t,x=u.agents.map(C=>`${C.name} (${C.status}, ${C.role}, cost=$${C.totalCostUsd.toFixed(2)})`).join("; ")||"none";return`[COMMAND POST] ${u.totalAgents} agents (${u.activeAgents} active), ${u.activeCheckouts} locked tasks, budget ${Math.round(u.budgetUtilization??0)}% used, ${((v=u.goalTree)==null?void 0:v.length)??0} goals. Agents: ${x}. You manage this agent organization. Be concise.
28
28
 
29
- `},[t]),r=s.useCallback(async()=>{const u=m.trim();if(!u||j)return;i(""),a(b=>[...b,{role:"user",content:u}]),p(!0),g("");const x=new AbortController;d.current=x;let v="",C=h;try{await ie(y()+u,h,b=>{b.type==="token"&&(v+=b.data,g(v)),b.type==="done"&&b.sessionId&&(C=b.sessionId)},x.signal),C&&c(C),v&&a(b=>[...b,{role:"assistant",content:v}])}catch(b){b.name!=="AbortError"&&a(o=>[...o,{role:"assistant",content:`Error: ${b.message}`}])}finally{p(!1),g(""),d.current=null}},[m,j,h,y]);return s.useEffect(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight)},[l,n]),e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden flex flex-col",style:{height:400},children:[e.jsx(D,{icon:Y,title:"Console",action:j?e.jsxs("button",{onClick:()=>{var u;return(u=d.current)==null?void 0:u.abort()},className:"text-[10px] text-error flex items-center gap-1",children:[e.jsx(De,{size:12}),"Stop"]}):void 0}),e.jsxs("div",{ref:f,className:"flex-1 overflow-y-auto px-4 py-3 space-y-2",children:[l.length===0&&!j&&e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-[11px] text-text-muted mb-3",children:"Manage your organization through natural language"}),e.jsx("div",{className:"flex flex-wrap justify-center gap-1.5",children:["Status report","Create issue: Research competitors","Spawn a research agent","Set $50/day budget"].map(u=>e.jsx("button",{onClick:()=>i(u),className:"text-[10px] text-text-muted hover:text-text-muted px-2.5 py-1 rounded-full border border-border hover:border-border-light",children:u},u))})]}),l.map((u,x)=>e.jsx("div",{className:`flex ${u.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[85%] px-3 py-2 rounded-xl text-[12px] leading-relaxed whitespace-pre-wrap ${u.role==="user"?"bg-accent/80 text-text rounded-br-sm":"bg-bg-tertiary text-text-secondary border border-border rounded-bl-sm"}`,children:u.content})},x)),j&&n&&e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"max-w-[85%] px-3 py-2 rounded-xl rounded-bl-sm bg-bg-tertiary text-text-secondary border border-border text-[12px] whitespace-pre-wrap",children:[n,e.jsx("span",{className:"inline-block w-1 h-3.5 bg-accent-light ml-0.5 animate-pulse"})]})}),j&&!n&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"px-3 py-2 rounded-xl bg-bg-tertiary border border-border",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted/20 animate-bounce"}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted/20 animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted/20 animate-bounce",style:{animationDelay:"300ms"}})]})})})]}),e.jsx("div",{className:"px-3 py-2 border-t border-border",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:m,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),r())},placeholder:"Tell Command Post what to do...",className:"flex-1 bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[12px] text-text placeholder-white/20 focus:outline-none focus:border-accent/30"}),e.jsx("button",{onClick:r,disabled:!m.trim()||j,className:"p-2 rounded-lg bg-accent text-text hover:bg-accent-hover disabled:opacity-30",children:e.jsx(Se,{size:14})})]})})]})}function Je({onClose:t,onCreated:l}){const[a,m]=s.useState(""),[i,j]=s.useState([{role:"pragmatist",model:""},{role:"skeptic",model:""}]),[p,n]=s.useState(2),[g,h]=s.useState("judge"),[c,d]=s.useState(!1),f=()=>{i.length>=5||j([...i,{role:`participant-${i.length+1}`,model:""}])},y=x=>{i.length<=2||j(i.filter((v,C)=>C!==x))},r=(x,v)=>{j(i.map((C,b)=>b===x?{...C,...v}:C))},u=async()=>{if(!(!a.trim()||i.length<2)){d(!0);try{const x=await O("/api/command-post/debates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:a.trim(),participants:i.map(v=>({role:v.role.trim()||"participant",model:v.model.trim()||void 0})),rounds:p,resolution:g})});if(!x.ok)throw new Error(`${x.status} ${x.statusText}`);l()}catch(x){alert(`Debate failed: ${x.message}`)}finally{d(!1)}}};return e.jsx(M,{open:!0,onClose:t,title:"Start a new debate",size:"lg",footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:t,className:"px-3 py-1.5 text-[11px] text-text-secondary hover:text-text",children:"Cancel"}),e.jsx("button",{onClick:u,disabled:c||!a.trim()||i.length<2,className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded hover:bg-accent-hover disabled:opacity-50",children:c?"Running debate…":"Run debate"})]}),children:e.jsxs("div",{className:"space-y-3 text-[12px]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Question"}),e.jsx("textarea",{value:a,onChange:x=>m(x.target.value),placeholder:"e.g. Should we cache the Ollama probe results for 7 days or 30 days?",rows:2,className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none focus:border-accent/40 resize-none"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:["Participants (",i.length,"/5)"]}),e.jsx("button",{onClick:f,disabled:i.length>=5,className:"text-[10px] text-accent-light/70 hover:text-accent-light disabled:opacity-40",children:"+ Add participant"})]}),e.jsx("div",{className:"space-y-2",children:i.map((x,v)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("input",{value:x.role,onChange:C=>r(v,{role:C.target.value}),placeholder:"role (e.g. pragmatist)",className:"flex-1 bg-bg-tertiary border border-border rounded px-2 py-1 text-text focus:outline-none"}),e.jsx("input",{value:x.model,onChange:C=>r(v,{model:C.target.value}),placeholder:"model (optional — defaults to agent.model)",className:"flex-1 bg-bg-tertiary border border-border rounded px-2 py-1 text-text-secondary focus:outline-none"}),e.jsx("button",{onClick:()=>y(v),disabled:i.length<=2,className:"text-text-muted hover:text-error disabled:opacity-20 px-1",title:"Remove",children:"×"})]},v))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Rounds"}),e.jsx("select",{value:p,onChange:x=>n(Number(x.target.value)),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[1,2,3,4].map(x=>e.jsxs("option",{value:x,children:[x," round",x===1?"":"s"]},x))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Resolution"}),e.jsxs("select",{value:g,onChange:x=>h(x.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[e.jsx("option",{value:"judge",children:"Judge (LLM picks winner)"}),e.jsx("option",{value:"synthesize",children:"Synthesize (LLM merges)"}),e.jsx("option",{value:"vote",children:"Vote (word-overlap consensus)"})]})]})]}),e.jsx("div",{className:"text-[10px] text-text-muted/70 italic",children:"Runs live — 1-3 minutes depending on model + rounds. Transcript saves automatically."})]})})}function Ze(){const[t,l]=s.useState([]),[a,m]=s.useState(null),[i,j]=s.useState(!1),[p,n]=s.useState(!1),g=s.useCallback(async()=>{j(!0);try{const c=await O("/api/command-post/debates");if(c.ok){const d=await c.json();l((d==null?void 0:d.items)||[])}}catch{}j(!1)},[]);s.useEffect(()=>{g()},[g]);const h=async c=>{try{const d=await O(`/api/command-post/debates/${c}`);if(d.ok){const f=await d.json();m(f)}}catch{}};if(a){const c=new Map;for(const d of a.turns){const f=c.get(d.round)||[];f.push(d),c.set(d.round,f)}return e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{onClick:()=>m(null),className:"text-[11px] text-text-muted hover:text-text-secondary",children:"← Back to debates"}),e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl p-4",children:[e.jsx("div",{className:"text-[13px] font-semibold text-text mb-1",children:a.question}),e.jsxs("div",{className:"text-[10px] text-text-muted/70",children:[a.resolution," • ",a.rounds," round",a.rounds===1?"":"s"," • ",(a.durationMs/1e3).toFixed(1),"s"]}),a.winner&&e.jsxs("div",{className:"mt-3 p-3 bg-success/[0.06] border border-success/30 rounded-lg",children:[e.jsxs("div",{className:"text-[11px] text-success/80/80 uppercase tracking-wider",children:["Winner: ",a.winner.role]}),e.jsx("div",{className:"text-[12px] text-text mt-1",children:a.winner.content}),a.winner.justification&&e.jsx("div",{className:"text-[10px] text-text-muted italic mt-2",children:a.winner.justification})]})]}),[...c.entries()].sort((d,f)=>d[0]-f[0]).map(([d,f])=>e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 border-b border-border/50 text-[11px] font-medium text-text-secondary uppercase tracking-wider",children:["Round ",d]}),e.jsx("div",{className:"divide-y divide-border/30",children:f.map((y,r)=>e.jsxs("div",{className:"px-4 py-3",children:[e.jsx("div",{className:"text-[11px] font-semibold text-accent-light/80 mb-1",children:y.role}),e.jsx("div",{className:"text-[11px] text-text-secondary whitespace-pre-wrap",children:y.content}),e.jsxs("div",{className:"text-[9px] text-text-muted mt-1",children:[y.model.split("/").pop()," • ",y.durationMs,"ms"]})]},r))})]},d))]})}return e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(D,{icon:ae,title:"Debates",count:t.length,help:{title:"Debates",description:"Pit two or more agents against each other to explore different sides of a decision. Useful for risk assessment and trade-off analysis."},action:e.jsxs("button",{onClick:()=>n(!0),className:"flex items-center gap-1 px-2.5 py-1 text-[10px] bg-accent text-text rounded-lg hover:bg-accent-hover",children:[e.jsx(V,{size:10})," New Debate"]})}),p&&e.jsx(Je,{onClose:()=>n(!1),onCreated:()=>{n(!1),g()}}),e.jsx("div",{className:"divide-y divide-border/30",children:i?e.jsx("div",{className:"py-8 text-center text-[12px] text-text-muted",children:"Loading..."}):t.length===0?e.jsxs("div",{className:"py-8 text-center text-[12px] text-text-muted",children:["No debates yet. Call the ",e.jsx("code",{className:"text-accent-light/70",children:"agent_debate"})," tool to start one."]}):t.map(c=>e.jsxs("button",{onClick:()=>h(c.id),className:"w-full text-left px-4 py-3 hover:bg-bg-tertiary/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("div",{className:"text-[12px] text-text flex-1 truncate pr-2",children:c.question}),e.jsxs("span",{className:"text-[10px] text-text-muted whitespace-nowrap",children:[Ve(c.startedAt)," ago"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[e.jsx("span",{children:c.resolution}),e.jsxs("span",{children:[c.rounds," round",c.rounds===1?"":"s"]}),e.jsxs("span",{children:[(c.durationMs/1e3).toFixed(1),"s"]}),c.winnerRole&&e.jsxs("span",{className:"text-success/80/70",children:["winner: ",c.winnerRole]})]})]},c.id))})]})}const Ke=[{label:"Overview",tabs:[{id:"Dashboard",label:"Dashboard",icon:te}]},{label:"Operations",tabs:[{id:"Social",label:"Social",icon:Y},{id:"Inbox",label:"Inbox",icon:Me},{id:"Goals",label:"Goals",icon:Te},{id:"Work",label:"Work",icon:B},{id:"Sessions",label:"Sessions",icon:X}]},{label:"Governance",tabs:[{id:"Org Chart",label:"Org Chart",icon:ee},{id:"Agents",label:"Agents",icon:Ne},{id:"Files",label:"Files",icon:we},{id:"Debates",label:"Debates",icon:ae},{id:"Costs",label:"Costs",icon:W}]},{label:"System",tabs:[{id:"Traces",label:"Traces",icon:P},{id:"Console",label:"Console",icon:Ce}]}],Qe=s.lazy(()=>_(()=>import("./WorkTab-IG-F6Qll.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Xe=s.lazy(()=>_(()=>import("./SessionsTab-Jq3UKQCI.js"),__vite__mapDeps([10,1,2,3]))),Ye=s.lazy(()=>_(()=>import("./CPInbox-B6iaIbNG.js"),__vite__mapDeps([11,1,2,12,4,5,6,13,14,15,16,17]))),et=s.lazy(()=>_(()=>import("./CPFiles-BDToRw0a.js"),__vite__mapDeps([18,1,2,4,5,6]))),tt=s.lazy(()=>_(()=>import("./TraceViewer-BbISy_ET.js"),__vite__mapDeps([19,1,2,20,4,5,6,21,22,23]))),st=s.lazy(()=>_(()=>import("./CPSocial-CsFrwZRC.js"),__vite__mapDeps([24,1,2,4,5,6,25]))),at=s.lazy(()=>_(()=>import("./CPDashboard-JmBLBbj7.js"),__vite__mapDeps([26,1,2,12,4,5,6,27,13,15,28,29]))),rt=s.lazy(()=>_(()=>import("./CPGoals-Dh9qJNWa.js"),__vite__mapDeps([30,1,2,12,4,5,6,27,13,14,15,29,8,3,31,32,9,28,21,22]))),nt=s.lazy(()=>_(()=>import("./CPAgents-CvkZDm_3.js"),__vite__mapDeps([33,1,2,12,4,5,6,27,13,14,15])));function lt(){const[t,l]=s.useState("Dashboard"),[a,m]=s.useState(null),[i,j]=s.useState([]),[p,n]=s.useState(!0),[g,h]=s.useState(null),[c,d]=s.useState([]),[f,y]=s.useState(!1),[r,u]=s.useState(null),x=s.useCallback(async()=>{try{const[b,o]=await Promise.allSettled([ce(),K()]);b.status==="fulfilled"&&(m(b.value),d(b.value.recentActivity||[])),o.status==="fulfilled"&&j(o.value),h(null)}catch(b){h(b.message)}n(!1)},[]);if(s.useEffect(()=>{x()},[x]),s.useEffect(()=>{if(!a)return;const b=localStorage.getItem("titan-token"),o=b?`/api/command-post/stream?token=${b}`:"/api/command-post/stream",k=new EventSource(o);let z=0;return k.addEventListener("commandpost:activity",S=>{z=0;try{d(N=>[...N.slice(-49),JSON.parse(S.data)])}catch{}}),k.addEventListener("commandpost:agent:status",S=>{z=0;try{const N=JSON.parse(S.data);m(w=>w&&{...w,agents:w.agents.map(R=>R.id===N.agentId?{...R,status:N.status}:R)})}catch{}}),k.onerror=()=>{z++,z>5&&k.close()},()=>k.close()},[a]),s.useEffect(()=>{const b=setInterval(x,3e4);return()=>clearInterval(b)},[x]),p)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-accent/30 border-t-accent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Loading Command Post..."})]})});if(g)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(F,{className:"mx-auto mb-3 text-warning",size:32}),e.jsx("p",{className:"text-sm text-text-secondary mb-4",children:g}),e.jsx("button",{onClick:x,className:"px-4 py-2 text-sm bg-bg-tertiary rounded-lg hover:bg-border text-text-secondary transition-colors",children:"Retry"})]})});const v=a??{agents:[],totalAgents:0,activeAgents:0,activeCheckouts:0,budgetUtilization:0,recentActivity:[],checkouts:[],budgets:[],goalTree:[],companies:[]},C=()=>{switch(t){case"Dashboard":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"dashboard"}),children:e.jsx(at,{})});case"Social":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"social"}),children:e.jsx(st,{})});case"Inbox":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"inbox"}),children:e.jsx(Ye,{})});case"Goals":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"goals"}),children:e.jsx(rt,{})});case"Work":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"work"}),children:e.jsx(Qe,{})});case"Sessions":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"sessions"}),children:e.jsx(Xe,{})});case"Org Chart":return e.jsx(We,{agents:v.agents});case"Agents":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"agents"}),children:e.jsx(nt,{})});case"Files":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"files"}),children:e.jsx(et,{})});case"Debates":return e.jsx(Ze,{});case"Costs":return e.jsx(qe,{budgets:v.budgets,onRefresh:x});case"Traces":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"traces"}),children:e.jsx(tt,{})});case"Console":return e.jsx(He,{dashboard:v});default:return null}};return e.jsxs("div",{className:"h-full flex overflow-hidden",children:[e.jsxs("div",{className:"w-52 shrink-0 flex flex-col border-r border-border bg-bg-secondary/30",children:[e.jsx("div",{className:"px-4 py-4 border-b border-border",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-accent/10 border border-accent/20",children:e.jsx(U,{size:16,className:"text-accent-light"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-sm font-bold text-text",children:"Command Post"}),e.jsx("p",{className:"text-[10px] text-text-muted",children:"Agent governance"})]})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto py-2 space-y-4",children:Ke.map(b=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 mb-1 text-[10px] font-semibold text-text-muted uppercase tracking-wider",children:b.label}),e.jsx("div",{className:"px-2 space-y-0.5",children:b.tabs.map(o=>{const k=t===o.id;return e.jsxs("button",{onClick:()=>l(o.id),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-[12px] transition-all duration-150 ${k?"bg-accent/10 text-accent-light font-medium":"text-text-secondary hover:text-text hover:bg-bg-tertiary/50"}`,children:[e.jsx(o.icon,{size:14,className:k?"text-accent-light":"text-text-muted"}),e.jsx("span",{children:o.label})]},o.id)})})]},b.label))}),e.jsx("div",{className:"px-3 py-2 border-t border-border",children:e.jsxs("button",{onClick:x,className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-[11px] text-text-muted bg-bg-tertiary/50 border border-border rounded-lg hover:bg-bg-tertiary transition-colors",children:[e.jsx(ke,{size:12,className:p?"animate-spin":""}),"Refresh"]})})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"max-w-6xl mx-auto px-4 md:px-6 py-4 md:py-6",children:e.jsx(C,{})})}),e.jsx(Oe,{collapsed:f,onToggle:()=>y(!f),agents:v.agents,runs:i,onAgentClick:b=>u(b)}),r&&e.jsx(Be,{agent:r,onClose:()=>u(null)})]})}const yt=Object.freeze(Object.defineProperty({__proto__:null,default:lt},Symbol.toStringTag,{value:"Module"}));export{yt as C,M};
29
+ `},[t]),r=s.useCallback(async()=>{const u=m.trim();if(!u||j)return;i(""),a(b=>[...b,{role:"user",content:u}]),p(!0),g("");const x=new AbortController;d.current=x;let v="",C=h;try{await ie(y()+u,h,b=>{b.type==="token"&&(v+=b.data,g(v)),b.type==="done"&&b.sessionId&&(C=b.sessionId)},x.signal),C&&c(C),v&&a(b=>[...b,{role:"assistant",content:v}])}catch(b){b.name!=="AbortError"&&a(o=>[...o,{role:"assistant",content:`Error: ${b.message}`}])}finally{p(!1),g(""),d.current=null}},[m,j,h,y]);return s.useEffect(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight)},[l,n]),e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden flex flex-col",style:{height:400},children:[e.jsx(D,{icon:Y,title:"Console",action:j?e.jsxs("button",{onClick:()=>{var u;return(u=d.current)==null?void 0:u.abort()},className:"text-[10px] text-error flex items-center gap-1",children:[e.jsx(De,{size:12}),"Stop"]}):void 0}),e.jsxs("div",{ref:f,className:"flex-1 overflow-y-auto px-4 py-3 space-y-2",children:[l.length===0&&!j&&e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-[11px] text-text-muted mb-3",children:"Manage your organization through natural language"}),e.jsx("div",{className:"flex flex-wrap justify-center gap-1.5",children:["Status report","Create issue: Research competitors","Spawn a research agent","Set $50/day budget"].map(u=>e.jsx("button",{onClick:()=>i(u),className:"text-[10px] text-text-muted hover:text-text-muted px-2.5 py-1 rounded-full border border-border hover:border-border-light",children:u},u))})]}),l.map((u,x)=>e.jsx("div",{className:`flex ${u.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[85%] px-3 py-2 rounded-xl text-[12px] leading-relaxed whitespace-pre-wrap ${u.role==="user"?"bg-accent/80 text-text rounded-br-sm":"bg-bg-tertiary text-text-secondary border border-border rounded-bl-sm"}`,children:u.content})},x)),j&&n&&e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"max-w-[85%] px-3 py-2 rounded-xl rounded-bl-sm bg-bg-tertiary text-text-secondary border border-border text-[12px] whitespace-pre-wrap",children:[n,e.jsx("span",{className:"inline-block w-1 h-3.5 bg-accent-light ml-0.5 animate-pulse"})]})}),j&&!n&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"px-3 py-2 rounded-xl bg-bg-tertiary border border-border",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted/20 animate-bounce"}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted/20 animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted/20 animate-bounce",style:{animationDelay:"300ms"}})]})})})]}),e.jsx("div",{className:"px-3 py-2 border-t border-border",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:m,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),r())},placeholder:"Tell Command Post what to do...",className:"flex-1 bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[12px] text-text placeholder-white/20 focus:outline-none focus:border-accent/30"}),e.jsx("button",{onClick:r,disabled:!m.trim()||j,className:"p-2 rounded-lg bg-accent text-text hover:bg-accent-hover disabled:opacity-30",children:e.jsx(Se,{size:14})})]})})]})}function Je({onClose:t,onCreated:l}){const[a,m]=s.useState(""),[i,j]=s.useState([{role:"pragmatist",model:""},{role:"skeptic",model:""}]),[p,n]=s.useState(2),[g,h]=s.useState("judge"),[c,d]=s.useState(!1),f=()=>{i.length>=5||j([...i,{role:`participant-${i.length+1}`,model:""}])},y=x=>{i.length<=2||j(i.filter((v,C)=>C!==x))},r=(x,v)=>{j(i.map((C,b)=>b===x?{...C,...v}:C))},u=async()=>{if(!(!a.trim()||i.length<2)){d(!0);try{const x=await O("/api/command-post/debates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:a.trim(),participants:i.map(v=>({role:v.role.trim()||"participant",model:v.model.trim()||void 0})),rounds:p,resolution:g})});if(!x.ok)throw new Error(`${x.status} ${x.statusText}`);l()}catch(x){alert(`Debate failed: ${x.message}`)}finally{d(!1)}}};return e.jsx(M,{open:!0,onClose:t,title:"Start a new debate",size:"lg",footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:t,className:"px-3 py-1.5 text-[11px] text-text-secondary hover:text-text",children:"Cancel"}),e.jsx("button",{onClick:u,disabled:c||!a.trim()||i.length<2,className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded hover:bg-accent-hover disabled:opacity-50",children:c?"Running debate…":"Run debate"})]}),children:e.jsxs("div",{className:"space-y-3 text-[12px]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Question"}),e.jsx("textarea",{value:a,onChange:x=>m(x.target.value),placeholder:"e.g. Should we cache the Ollama probe results for 7 days or 30 days?",rows:2,className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none focus:border-accent/40 resize-none"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:["Participants (",i.length,"/5)"]}),e.jsx("button",{onClick:f,disabled:i.length>=5,className:"text-[10px] text-accent-light/70 hover:text-accent-light disabled:opacity-40",children:"+ Add participant"})]}),e.jsx("div",{className:"space-y-2",children:i.map((x,v)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("input",{value:x.role,onChange:C=>r(v,{role:C.target.value}),placeholder:"role (e.g. pragmatist)",className:"flex-1 bg-bg-tertiary border border-border rounded px-2 py-1 text-text focus:outline-none"}),e.jsx("input",{value:x.model,onChange:C=>r(v,{model:C.target.value}),placeholder:"model (optional — defaults to agent.model)",className:"flex-1 bg-bg-tertiary border border-border rounded px-2 py-1 text-text-secondary focus:outline-none"}),e.jsx("button",{onClick:()=>y(v),disabled:i.length<=2,className:"text-text-muted hover:text-error disabled:opacity-20 px-1",title:"Remove",children:"×"})]},v))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Rounds"}),e.jsx("select",{value:p,onChange:x=>n(Number(x.target.value)),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[1,2,3,4].map(x=>e.jsxs("option",{value:x,children:[x," round",x===1?"":"s"]},x))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Resolution"}),e.jsxs("select",{value:g,onChange:x=>h(x.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[e.jsx("option",{value:"judge",children:"Judge (LLM picks winner)"}),e.jsx("option",{value:"synthesize",children:"Synthesize (LLM merges)"}),e.jsx("option",{value:"vote",children:"Vote (word-overlap consensus)"})]})]})]}),e.jsx("div",{className:"text-[10px] text-text-muted/70 italic",children:"Runs live — 1-3 minutes depending on model + rounds. Transcript saves automatically."})]})})}function Ze(){const[t,l]=s.useState([]),[a,m]=s.useState(null),[i,j]=s.useState(!1),[p,n]=s.useState(!1),g=s.useCallback(async()=>{j(!0);try{const c=await O("/api/command-post/debates");if(c.ok){const d=await c.json();l((d==null?void 0:d.items)||[])}}catch{}j(!1)},[]);s.useEffect(()=>{g()},[g]);const h=async c=>{try{const d=await O(`/api/command-post/debates/${c}`);if(d.ok){const f=await d.json();m(f)}}catch{}};if(a){const c=new Map;for(const d of a.turns){const f=c.get(d.round)||[];f.push(d),c.set(d.round,f)}return e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{onClick:()=>m(null),className:"text-[11px] text-text-muted hover:text-text-secondary",children:"← Back to debates"}),e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl p-4",children:[e.jsx("div",{className:"text-[13px] font-semibold text-text mb-1",children:a.question}),e.jsxs("div",{className:"text-[10px] text-text-muted/70",children:[a.resolution," • ",a.rounds," round",a.rounds===1?"":"s"," • ",(a.durationMs/1e3).toFixed(1),"s"]}),a.winner&&e.jsxs("div",{className:"mt-3 p-3 bg-success/[0.06] border border-success/30 rounded-lg",children:[e.jsxs("div",{className:"text-[11px] text-success/80/80 uppercase tracking-wider",children:["Winner: ",a.winner.role]}),e.jsx("div",{className:"text-[12px] text-text mt-1",children:a.winner.content}),a.winner.justification&&e.jsx("div",{className:"text-[10px] text-text-muted italic mt-2",children:a.winner.justification})]})]}),[...c.entries()].sort((d,f)=>d[0]-f[0]).map(([d,f])=>e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 border-b border-border/50 text-[11px] font-medium text-text-secondary uppercase tracking-wider",children:["Round ",d]}),e.jsx("div",{className:"divide-y divide-border/30",children:f.map((y,r)=>e.jsxs("div",{className:"px-4 py-3",children:[e.jsx("div",{className:"text-[11px] font-semibold text-accent-light/80 mb-1",children:y.role}),e.jsx("div",{className:"text-[11px] text-text-secondary whitespace-pre-wrap",children:y.content}),e.jsxs("div",{className:"text-[9px] text-text-muted mt-1",children:[y.model.split("/").pop()," • ",y.durationMs,"ms"]})]},r))})]},d))]})}return e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(D,{icon:ae,title:"Debates",count:t.length,help:{title:"Debates",description:"Pit two or more agents against each other to explore different sides of a decision. Useful for risk assessment and trade-off analysis."},action:e.jsxs("button",{onClick:()=>n(!0),className:"flex items-center gap-1 px-2.5 py-1 text-[10px] bg-accent text-text rounded-lg hover:bg-accent-hover",children:[e.jsx(V,{size:10})," New Debate"]})}),p&&e.jsx(Je,{onClose:()=>n(!1),onCreated:()=>{n(!1),g()}}),e.jsx("div",{className:"divide-y divide-border/30",children:i?e.jsx("div",{className:"py-8 text-center text-[12px] text-text-muted",children:"Loading..."}):t.length===0?e.jsxs("div",{className:"py-8 text-center text-[12px] text-text-muted",children:["No debates yet. Call the ",e.jsx("code",{className:"text-accent-light/70",children:"agent_debate"})," tool to start one."]}):t.map(c=>e.jsxs("button",{onClick:()=>h(c.id),className:"w-full text-left px-4 py-3 hover:bg-bg-tertiary/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("div",{className:"text-[12px] text-text flex-1 truncate pr-2",children:c.question}),e.jsxs("span",{className:"text-[10px] text-text-muted whitespace-nowrap",children:[Ve(c.startedAt)," ago"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[e.jsx("span",{children:c.resolution}),e.jsxs("span",{children:[c.rounds," round",c.rounds===1?"":"s"]}),e.jsxs("span",{children:[(c.durationMs/1e3).toFixed(1),"s"]}),c.winnerRole&&e.jsxs("span",{className:"text-success/80/70",children:["winner: ",c.winnerRole]})]})]},c.id))})]})}const Ke=[{label:"Overview",tabs:[{id:"Dashboard",label:"Dashboard",icon:te}]},{label:"Operations",tabs:[{id:"Social",label:"Social",icon:Y},{id:"Inbox",label:"Inbox",icon:Me},{id:"Goals",label:"Goals",icon:Te},{id:"Work",label:"Work",icon:B},{id:"Sessions",label:"Sessions",icon:X}]},{label:"Governance",tabs:[{id:"Org Chart",label:"Org Chart",icon:ee},{id:"Agents",label:"Agents",icon:Ne},{id:"Files",label:"Files",icon:we},{id:"Debates",label:"Debates",icon:ae},{id:"Costs",label:"Costs",icon:W}]},{label:"System",tabs:[{id:"Traces",label:"Traces",icon:P},{id:"Console",label:"Console",icon:Ce}]}],Qe=s.lazy(()=>_(()=>import("./WorkTab-BjLNmgIK.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Xe=s.lazy(()=>_(()=>import("./SessionsTab-JQbltWww.js"),__vite__mapDeps([10,1,2,3]))),Ye=s.lazy(()=>_(()=>import("./CPInbox-tMSbmQ9H.js"),__vite__mapDeps([11,1,2,12,4,5,6,13,14,15,16,17]))),et=s.lazy(()=>_(()=>import("./CPFiles-CxgxjQcO.js"),__vite__mapDeps([18,1,2,4,5,6]))),tt=s.lazy(()=>_(()=>import("./TraceViewer-BniolyBx.js"),__vite__mapDeps([19,1,2,20,4,5,6,21,22,23]))),st=s.lazy(()=>_(()=>import("./CPSocial-nb-j7sOE.js"),__vite__mapDeps([24,1,2,4,5,6,25]))),at=s.lazy(()=>_(()=>import("./CPDashboard-Bf0-SyCh.js"),__vite__mapDeps([26,1,2,12,4,5,6,27,13,15,28,29]))),rt=s.lazy(()=>_(()=>import("./CPGoals-BsmCMTvT.js"),__vite__mapDeps([30,1,2,12,4,5,6,27,13,14,15,29,8,3,31,32,9,28,21,22]))),nt=s.lazy(()=>_(()=>import("./CPAgents-DYUtPzSq.js"),__vite__mapDeps([33,1,2,12,4,5,6,27,13,14,15])));function lt(){const[t,l]=s.useState("Dashboard"),[a,m]=s.useState(null),[i,j]=s.useState([]),[p,n]=s.useState(!0),[g,h]=s.useState(null),[c,d]=s.useState([]),[f,y]=s.useState(!1),[r,u]=s.useState(null),x=s.useCallback(async()=>{try{const[b,o]=await Promise.allSettled([ce(),K()]);b.status==="fulfilled"&&(m(b.value),d(b.value.recentActivity||[])),o.status==="fulfilled"&&j(o.value),h(null)}catch(b){h(b.message)}n(!1)},[]);if(s.useEffect(()=>{x()},[x]),s.useEffect(()=>{if(!a)return;const b=localStorage.getItem("titan-token"),o=b?`/api/command-post/stream?token=${b}`:"/api/command-post/stream",k=new EventSource(o);let z=0;return k.addEventListener("commandpost:activity",S=>{z=0;try{d(N=>[...N.slice(-49),JSON.parse(S.data)])}catch{}}),k.addEventListener("commandpost:agent:status",S=>{z=0;try{const N=JSON.parse(S.data);m(w=>w&&{...w,agents:w.agents.map(R=>R.id===N.agentId?{...R,status:N.status}:R)})}catch{}}),k.onerror=()=>{z++,z>5&&k.close()},()=>k.close()},[a]),s.useEffect(()=>{const b=setInterval(x,3e4);return()=>clearInterval(b)},[x]),p)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-accent/30 border-t-accent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Loading Command Post..."})]})});if(g)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(F,{className:"mx-auto mb-3 text-warning",size:32}),e.jsx("p",{className:"text-sm text-text-secondary mb-4",children:g}),e.jsx("button",{onClick:x,className:"px-4 py-2 text-sm bg-bg-tertiary rounded-lg hover:bg-border text-text-secondary transition-colors",children:"Retry"})]})});const v=a??{agents:[],totalAgents:0,activeAgents:0,activeCheckouts:0,budgetUtilization:0,recentActivity:[],checkouts:[],budgets:[],goalTree:[],companies:[]},C=()=>{switch(t){case"Dashboard":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"dashboard"}),children:e.jsx(at,{})});case"Social":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"social"}),children:e.jsx(st,{})});case"Inbox":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"inbox"}),children:e.jsx(Ye,{})});case"Goals":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"goals"}),children:e.jsx(rt,{})});case"Work":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"work"}),children:e.jsx(Qe,{})});case"Sessions":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"sessions"}),children:e.jsx(Xe,{})});case"Org Chart":return e.jsx(We,{agents:v.agents});case"Agents":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"agents"}),children:e.jsx(nt,{})});case"Files":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"files"}),children:e.jsx(et,{})});case"Debates":return e.jsx(Ze,{});case"Costs":return e.jsx(qe,{budgets:v.budgets,onRefresh:x});case"Traces":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"traces"}),children:e.jsx(tt,{})});case"Console":return e.jsx(He,{dashboard:v});default:return null}};return e.jsxs("div",{className:"h-full flex overflow-hidden",children:[e.jsxs("div",{className:"w-52 shrink-0 flex flex-col border-r border-border bg-bg-secondary/30",children:[e.jsx("div",{className:"px-4 py-4 border-b border-border",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-accent/10 border border-accent/20",children:e.jsx(U,{size:16,className:"text-accent-light"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-sm font-bold text-text",children:"Command Post"}),e.jsx("p",{className:"text-[10px] text-text-muted",children:"Agent governance"})]})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto py-2 space-y-4",children:Ke.map(b=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 mb-1 text-[10px] font-semibold text-text-muted uppercase tracking-wider",children:b.label}),e.jsx("div",{className:"px-2 space-y-0.5",children:b.tabs.map(o=>{const k=t===o.id;return e.jsxs("button",{onClick:()=>l(o.id),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-[12px] transition-all duration-150 ${k?"bg-accent/10 text-accent-light font-medium":"text-text-secondary hover:text-text hover:bg-bg-tertiary/50"}`,children:[e.jsx(o.icon,{size:14,className:k?"text-accent-light":"text-text-muted"}),e.jsx("span",{children:o.label})]},o.id)})})]},b.label))}),e.jsx("div",{className:"px-3 py-2 border-t border-border",children:e.jsxs("button",{onClick:x,className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-[11px] text-text-muted bg-bg-tertiary/50 border border-border rounded-lg hover:bg-bg-tertiary transition-colors",children:[e.jsx(ke,{size:12,className:p?"animate-spin":""}),"Refresh"]})})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"max-w-6xl mx-auto px-4 md:px-6 py-4 md:py-6",children:e.jsx(C,{})})}),e.jsx(Oe,{collapsed:f,onToggle:()=>y(!f),agents:v.agents,runs:i,onAgentClick:b=>u(b)}),r&&e.jsx(Be,{agent:r,onClose:()=>u(null)})]})}const yt=Object.freeze(Object.defineProperty({__proto__:null,default:lt},Symbol.toStringTag,{value:"Module"}));export{yt as C,M};
@@ -1 +1 @@
1
- import{r as t,aS as d,j as e,aT as m,aU as x}from"./index-D7Clon2u.js";import{P as h}from"./PageHeader-DPJuAgJk.js";import{R as f,C as b}from"./TitanCanvas-BQU1yxqf.js";import{T as g,a as p}from"./toggle-right-Dsk892k5.js";import{T as u}from"./trash-2-Byj4OvKB.js";import"./VoiceOverlay-l6yoasVz.js";function T(){const[c,o]=t.useState([]),[r,l]=t.useState(!0),s=t.useCallback(async()=>{l(!0);try{const a=await d();o(a.jobs||[])}catch{}l(!1)},[]);t.useEffect(()=>{s()},[s]);const n=async a=>{try{await m(a),await s()}catch{}},i=async a=>{if(confirm("Delete this cron job?"))try{await x(a),await s()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(h,{title:"Cron Scheduler",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Cron"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:s,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(f,{className:`w-4 h-4 ${r?"animate-spin":""}`})," Refresh"]})}),e.jsx("div",{className:"space-y-2",children:c.map(a=>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(b,{className:"w-4 h-4 text-[#6366f1]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[#e4e4e7]",children:a.name}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[a.schedule," • ",a.command]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>n(a.id),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46]",children:a.enabled?e.jsx(g,{className:"w-4 h-4 text-emerald-400"}):e.jsx(p,{className:"w-4 h-4 text-[#52525b]"})}),e.jsx("button",{onClick:()=>i(a.id),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46] hover:text-red-400",children:e.jsx(u,{className:"w-3.5 h-3.5"})})]})]},a.id))})]})}export{T as default};
1
+ import{r as t,aS as d,j as e,aT as m,aU as x}from"./index-CahJbWSR.js";import{P as h}from"./PageHeader-BimceqQo.js";import{R as f,C as b}from"./TitanCanvas-C-s0A-lv.js";import{T as g,a as p}from"./toggle-right-YusFQ69L.js";import{T as u}from"./trash-2-CK7yQ55V.js";import"./VoiceOverlay-CmNCrLcd.js";function T(){const[c,o]=t.useState([]),[r,l]=t.useState(!0),s=t.useCallback(async()=>{l(!0);try{const a=await d();o(a.jobs||[])}catch{}l(!1)},[]);t.useEffect(()=>{s()},[s]);const n=async a=>{try{await m(a),await s()}catch{}},i=async a=>{if(confirm("Delete this cron job?"))try{await x(a),await s()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(h,{title:"Cron Scheduler",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Cron"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:s,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(f,{className:`w-4 h-4 ${r?"animate-spin":""}`})," Refresh"]})}),e.jsx("div",{className:"space-y-2",children:c.map(a=>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(b,{className:"w-4 h-4 text-[#6366f1]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[#e4e4e7]",children:a.name}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[a.schedule," • ",a.command]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>n(a.id),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46]",children:a.enabled?e.jsx(g,{className:"w-4 h-4 text-emerald-400"}):e.jsx(p,{className:"w-4 h-4 text-[#52525b]"})}),e.jsx("button",{onClick:()=>i(a.id),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46] hover:text-red-400",children:e.jsx(u,{className:"w-3.5 h-3.5"})})]})]},a.id))})]})}export{T as default};
@@ -1 +1 @@
1
- import{r as n,j as e,T as m,f as j,A as N,aw as f,ax as y,ay as w}from"./index-D7Clon2u.js";import{i as R,R as S,C as P}from"./TitanCanvas-BQU1yxqf.js";import{P as k}from"./pause-DqkRWPB_.js";import{P as E}from"./play-hUyR3CVS.js";import"./VoiceOverlay-l6yoasVz.js";function M(){const[s,v]=n.useState(null),[h,o]=n.useState(!0),[i,x]=n.useState([]),g=n.useRef(null),r=async()=>{o(!0);try{v(await f())}catch{}o(!1)};n.useEffect(()=>{r();const a=new EventSource("/api/daemon/stream");g.current=a,a.onmessage=d=>{try{const t=JSON.parse(d.data);x(l=>[{event:t.event||"message",data:JSON.stringify(t.data||t,null,0),time:new Date().toLocaleTimeString()},...l].slice(0,50))}catch{}};for(const d of["daemon:started","daemon:stopped","daemon:paused","daemon:resumed","daemon:heartbeat","goal:subtask:ready","health:ollama:down","health:ollama:degraded","cron:stuck"])a.addEventListener(d,t=>{x(l=>[{event:d,data:t.data||"",time:new Date().toLocaleTimeString()},...l].slice(0,50))});const c=setInterval(r,15e3);return()=>{a.close(),clearInterval(c)}},[]);const u=async()=>{await y(),r()},p=async()=>{await w(),r()},b=a=>a<6e4?`${Math.round(a/1e3)}s`:a<36e5?`${Math.round(a/6e4)}m`:`${Math.round(a/36e5)}h ${Math.round(a%36e5/6e4)}m`;return h&&!s?e.jsx("div",{className:"text-[var(--text-muted)]",children:"Loading daemon status..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(R,{className:"w-6 h-6 text-[var(--accent)]"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-[var(--text)]",children:"Daemon"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Persistent background watchers and event loop"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:r,className:"p-2 rounded-md border border-[var(--border)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] transition-colors",children:e.jsx(S,{size:14})}),(s==null?void 0:s.running)&&!s.paused&&e.jsxs("button",{onClick:u,className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded-md bg-[var(--warning)]/15 text-[var(--warning)] border border-[var(--warning)]/25 hover:bg-[var(--warning)]/25 transition-colors",children:[e.jsx(k,{size:14})," Pause"]}),(s==null?void 0:s.running)&&s.paused&&e.jsxs("button",{onClick:p,className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded-md bg-[var(--success)]/15 text-[var(--success)] border border-[var(--success)]/25 hover:bg-[var(--success)]/25 transition-colors",children:[e.jsx(E,{size:14})," Resume"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[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:"Status"}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:s!=null&&s.running?s.paused?e.jsxs(e.Fragment,{children:[e.jsx(m,{size:18,className:"text-[var(--warning)]"}),e.jsx("span",{className:"text-lg font-semibold text-[var(--warning)]",children:"Paused"})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{size:18,className:"text-[var(--success)]"}),e.jsx("span",{className:"text-lg font-semibold text-[var(--success)]",children:"Running"})]}):e.jsx(e.Fragment,{children:e.jsx("span",{className:"text-lg font-semibold text-[var(--text-muted)]",children:"Stopped"})})})]}),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:"Uptime"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(P,{size:18,className:"text-[var(--text-muted)]"}),e.jsx("p",{className:"text-lg font-semibold text-[var(--text)]",children:s?b(s.uptimeMs):"-"})]})]}),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:"Actions / Hour"}),e.jsxs("p",{className:"text-lg font-semibold text-[var(--text)] mt-1",children:[(s==null?void 0:s.actionsThisHour)??0," ",e.jsxs("span",{className:"text-sm font-normal text-[var(--text-muted)]",children:["/ ",(s==null?void 0:s.maxActionsPerHour)??10]})]})]}),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:"Error Rate"}),e.jsxs("p",{className:`text-lg font-semibold mt-1 ${((s==null?void 0:s.errorRatePercent)??0)>30?"text-[var(--error)]":"text-[var(--text)]"}`,children:[(s==null?void 0:s.errorRatePercent)??0,"%"]})]})]}),(s==null?void 0:s.pauseReason)&&e.jsxs("div",{className:"bg-[var(--warning)]/10 border border-[var(--warning)]/25 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(m,{size:16,className:"text-[var(--warning)] flex-shrink-0"}),e.jsx("span",{className:"text-sm text-[var(--warning)]",children:s.pauseReason})]}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] mb-3",children:"Active Watchers"}),s!=null&&s.activeWatchers&&s.activeWatchers.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:s.activeWatchers.map(a=>e.jsxs("span",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-[var(--success)]/10 text-[var(--success)] border border-[var(--success)]/20",children:[e.jsx(N,{size:12})," ",a]},a))}):e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"No active watchers"})]}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] mb-3",children:"Event Feed"}),i.length>0?e.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto font-mono text-xs",children:i.map((a,c)=>e.jsxs("div",{className:"flex gap-3 py-1 border-b border-[var(--border)]/50 last:border-0",children:[e.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 w-16",children:a.time}),e.jsx("span",{className:"text-[var(--accent)] flex-shrink-0",children:a.event}),e.jsx("span",{className:"text-[var(--text-secondary)] truncate",children:a.data})]},c))}):e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Waiting for events..."})]})]})}export{M as default};
1
+ import{r as n,j as e,T as m,f as j,A as N,aw as f,ax as y,ay as w}from"./index-CahJbWSR.js";import{i as R,R as S,C as P}from"./TitanCanvas-C-s0A-lv.js";import{P as k}from"./pause-DCV52koX.js";import{P as E}from"./play-CcJ9BnCh.js";import"./VoiceOverlay-CmNCrLcd.js";function M(){const[s,v]=n.useState(null),[h,o]=n.useState(!0),[i,x]=n.useState([]),g=n.useRef(null),r=async()=>{o(!0);try{v(await f())}catch{}o(!1)};n.useEffect(()=>{r();const a=new EventSource("/api/daemon/stream");g.current=a,a.onmessage=d=>{try{const t=JSON.parse(d.data);x(l=>[{event:t.event||"message",data:JSON.stringify(t.data||t,null,0),time:new Date().toLocaleTimeString()},...l].slice(0,50))}catch{}};for(const d of["daemon:started","daemon:stopped","daemon:paused","daemon:resumed","daemon:heartbeat","goal:subtask:ready","health:ollama:down","health:ollama:degraded","cron:stuck"])a.addEventListener(d,t=>{x(l=>[{event:d,data:t.data||"",time:new Date().toLocaleTimeString()},...l].slice(0,50))});const c=setInterval(r,15e3);return()=>{a.close(),clearInterval(c)}},[]);const u=async()=>{await y(),r()},p=async()=>{await w(),r()},b=a=>a<6e4?`${Math.round(a/1e3)}s`:a<36e5?`${Math.round(a/6e4)}m`:`${Math.round(a/36e5)}h ${Math.round(a%36e5/6e4)}m`;return h&&!s?e.jsx("div",{className:"text-[var(--text-muted)]",children:"Loading daemon status..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(R,{className:"w-6 h-6 text-[var(--accent)]"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-[var(--text)]",children:"Daemon"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Persistent background watchers and event loop"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:r,className:"p-2 rounded-md border border-[var(--border)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] transition-colors",children:e.jsx(S,{size:14})}),(s==null?void 0:s.running)&&!s.paused&&e.jsxs("button",{onClick:u,className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded-md bg-[var(--warning)]/15 text-[var(--warning)] border border-[var(--warning)]/25 hover:bg-[var(--warning)]/25 transition-colors",children:[e.jsx(k,{size:14})," Pause"]}),(s==null?void 0:s.running)&&s.paused&&e.jsxs("button",{onClick:p,className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded-md bg-[var(--success)]/15 text-[var(--success)] border border-[var(--success)]/25 hover:bg-[var(--success)]/25 transition-colors",children:[e.jsx(E,{size:14})," Resume"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[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:"Status"}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:s!=null&&s.running?s.paused?e.jsxs(e.Fragment,{children:[e.jsx(m,{size:18,className:"text-[var(--warning)]"}),e.jsx("span",{className:"text-lg font-semibold text-[var(--warning)]",children:"Paused"})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{size:18,className:"text-[var(--success)]"}),e.jsx("span",{className:"text-lg font-semibold text-[var(--success)]",children:"Running"})]}):e.jsx(e.Fragment,{children:e.jsx("span",{className:"text-lg font-semibold text-[var(--text-muted)]",children:"Stopped"})})})]}),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:"Uptime"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(P,{size:18,className:"text-[var(--text-muted)]"}),e.jsx("p",{className:"text-lg font-semibold text-[var(--text)]",children:s?b(s.uptimeMs):"-"})]})]}),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:"Actions / Hour"}),e.jsxs("p",{className:"text-lg font-semibold text-[var(--text)] mt-1",children:[(s==null?void 0:s.actionsThisHour)??0," ",e.jsxs("span",{className:"text-sm font-normal text-[var(--text-muted)]",children:["/ ",(s==null?void 0:s.maxActionsPerHour)??10]})]})]}),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:"Error Rate"}),e.jsxs("p",{className:`text-lg font-semibold mt-1 ${((s==null?void 0:s.errorRatePercent)??0)>30?"text-[var(--error)]":"text-[var(--text)]"}`,children:[(s==null?void 0:s.errorRatePercent)??0,"%"]})]})]}),(s==null?void 0:s.pauseReason)&&e.jsxs("div",{className:"bg-[var(--warning)]/10 border border-[var(--warning)]/25 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(m,{size:16,className:"text-[var(--warning)] flex-shrink-0"}),e.jsx("span",{className:"text-sm text-[var(--warning)]",children:s.pauseReason})]}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] mb-3",children:"Active Watchers"}),s!=null&&s.activeWatchers&&s.activeWatchers.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:s.activeWatchers.map(a=>e.jsxs("span",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-[var(--success)]/10 text-[var(--success)] border border-[var(--success)]/20",children:[e.jsx(N,{size:12})," ",a]},a))}):e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"No active watchers"})]}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] mb-3",children:"Event Feed"}),i.length>0?e.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto font-mono text-xs",children:i.map((a,c)=>e.jsxs("div",{className:"flex gap-3 py-1 border-b border-[var(--border)]/50 last:border-0",children:[e.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 w-16",children:a.time}),e.jsx("span",{className:"text-[var(--accent)] flex-shrink-0",children:a.event}),e.jsx("span",{className:"text-[var(--text-secondary)] truncate",children:a.data})]},c))}):e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Waiting for events..."})]})]})}export{M as default};
@@ -1 +1 @@
1
- import{j as e}from"./index-D7Clon2u.js";function i({columns:s,data:d,onRowClick:a,emptyMessage:x="No data available"}){return e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-bg-secondary",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-bg-tertiary",children:s.map(t=>e.jsx("th",{className:`px-4 py-3 text-sm font-medium text-text-secondary ${t.className??""}`,children:t.header},t.key))})}),e.jsx("tbody",{children:d.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:s.length,className:"px-4 py-12 text-center text-text-muted",children:x})}):d.map((t,n)=>e.jsx("tr",{onClick:()=>a==null?void 0:a(t),className:`border-t border-border transition-colors hover:bg-bg-tertiary/50 ${a?"cursor-pointer":""}`,children:s.map(r=>e.jsx("td",{className:`px-4 py-3 text-text ${r.className??""}`,children:r.render?r.render(t):String(t[r.key]??"")},r.key))},n))})]})})}export{i as D};
1
+ import{j as e}from"./index-CahJbWSR.js";function i({columns:s,data:d,onRowClick:a,emptyMessage:x="No data available"}){return e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-bg-secondary",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-bg-tertiary",children:s.map(t=>e.jsx("th",{className:`px-4 py-3 text-sm font-medium text-text-secondary ${t.className??""}`,children:t.header},t.key))})}),e.jsx("tbody",{children:d.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:s.length,className:"px-4 py-12 text-center text-text-muted",children:x})}):d.map((t,n)=>e.jsx("tr",{onClick:()=>a==null?void 0:a(t),className:`border-t border-border transition-colors hover:bg-bg-tertiary/50 ${a?"cursor-pointer":""}`,children:s.map(r=>e.jsx("td",{className:`px-4 py-3 text-text ${r.className??""}`,children:r.render?r.render(t):String(t[r.key]??"")},r.key))},n))})]})})}export{i as D};
@@ -1 +1 @@
1
- import{j as t}from"./index-D7Clon2u.js";import{B as r}from"./Input-BgyHgQ3D.js";function n({icon:s,title:x,description:m,action:e,className:a}){return t.jsxs("div",{className:`flex flex-col items-center justify-center py-16 text-center ${a??""}`,children:[s&&t.jsx("div",{className:"mb-4 text-text-muted opacity-50",children:s}),t.jsx("h3",{className:"text-sm font-medium text-text-secondary",children:x}),m&&t.jsx("p",{className:"mt-1 max-w-sm text-xs text-text-muted",children:m}),e&&t.jsx(r,{variant:"secondary",size:"sm",onClick:e.onClick,className:"mt-4",children:e.label})]})}export{n as E};
1
+ import{j as t}from"./index-CahJbWSR.js";import{B as r}from"./Input-GTHp2Rkr.js";function n({icon:s,title:x,description:m,action:e,className:a}){return t.jsxs("div",{className:`flex flex-col items-center justify-center py-16 text-center ${a??""}`,children:[s&&t.jsx("div",{className:"mb-4 text-text-muted opacity-50",children:s}),t.jsx("h3",{className:"text-sm font-medium text-text-secondary",children:x}),m&&t.jsx("p",{className:"mt-1 max-w-sm text-xs text-text-muted",children:m}),e&&t.jsx(r,{variant:"secondary",size:"sm",onClick:e.onClick,className:"mt-4",children:e.label})]})}export{n as E};