titan-agent 5.2.1 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +33 -3
  2. package/dist/eval/harness.js +49 -0
  3. package/dist/eval/harness.js.map +1 -1
  4. package/dist/eval/parity.js +148 -0
  5. package/dist/eval/parity.js.map +1 -0
  6. package/dist/eval/record.js +96 -0
  7. package/dist/eval/record.js.map +1 -0
  8. package/dist/utils/constants.js +1 -1
  9. package/dist/utils/constants.js.map +1 -1
  10. package/dist/utils/safety.js +31 -1
  11. package/dist/utils/safety.js.map +1 -1
  12. package/package.json +5 -1
  13. package/scripts/eval-gate.sh +189 -0
  14. package/scripts/eval-record.ts +133 -0
  15. package/ui/dist/assets/{AuditPanel-DLy0WJQZ.js → AuditPanel-C31LRHZX.js} +1 -1
  16. package/ui/dist/assets/{AutonomyPanel-DjFAQGns.js → AutonomyPanel-CxQU72ZY.js} +1 -1
  17. package/ui/dist/assets/{AutopilotPanel-nBluaHA4.js → AutopilotPanel-D4FnBwJm.js} +1 -1
  18. package/ui/dist/assets/{AutoresearchPanel-BDy8y_Cs.js → AutoresearchPanel-BYHXZ9AO.js} +1 -1
  19. package/ui/dist/assets/{BackupPanel-B_Fv2pJA.js → BackupPanel-C4CQKf2P.js} +1 -1
  20. package/ui/dist/assets/{BrowserPanel-DOCT3-Rq.js → BrowserPanel-C-OFYyLm.js} +1 -1
  21. package/ui/dist/assets/{CPAgents-CpkHf0b8.js → CPAgents-CvkZDm_3.js} +1 -1
  22. package/ui/dist/assets/{CPDashboard-CnMd6qNK.js → CPDashboard-JmBLBbj7.js} +1 -1
  23. package/ui/dist/assets/{CPFiles-BDRjJpYl.js → CPFiles-BDToRw0a.js} +1 -1
  24. package/ui/dist/assets/{CPGoals-2DrwHk62.js → CPGoals-Dh9qJNWa.js} +1 -1
  25. package/ui/dist/assets/{CPInbox-C6l2o4FD.js → CPInbox-B6iaIbNG.js} +1 -1
  26. package/ui/dist/assets/{CPSocial-Cea6NptR.js → CPSocial-CsFrwZRC.js} +1 -1
  27. package/ui/dist/assets/{ChannelsPanel-5EhhyXeg.js → ChannelsPanel-D-S4ktFn.js} +1 -1
  28. package/ui/dist/assets/{CheckpointsPanel-BVt2oEUe.js → CheckpointsPanel-D-sP9ZuS.js} +1 -1
  29. package/ui/dist/assets/{CommandPostHub-PXKE62DN.js → CommandPostHub-BhlNyeDH.js} +3 -3
  30. package/ui/dist/assets/{CronPanel-lAsoKavq.js → CronPanel-Bf3rV7N2.js} +1 -1
  31. package/ui/dist/assets/{DaemonPanel-xt08Rs10.js → DaemonPanel-GGBWjTG2.js} +1 -1
  32. package/ui/dist/assets/{DataTable-BHOu7fZP.js → DataTable-D2Px4o6f.js} +1 -1
  33. package/ui/dist/assets/{EmptyState-Dk7BBthD.js → EmptyState-DH6-Jy6A.js} +1 -1
  34. package/ui/dist/assets/EvalHarnessPanel-Cz9dRg61.js +2 -0
  35. package/ui/dist/assets/{EvalPanel-D9rDf1bk.js → EvalPanel-CdjxzHlJ.js} +1 -1
  36. package/ui/dist/assets/{FilesPanel-CNrDLmix.js → FilesPanel-Dz8TFydL.js} +1 -1
  37. package/ui/dist/assets/{FleetPanel-DP_ji0AE.js → FleetPanel-CWwWWTD4.js} +1 -1
  38. package/ui/dist/assets/{HomelabPanel-B4bCsrBw.js → HomelabPanel-C7VBV7AC.js} +1 -1
  39. package/ui/dist/assets/{InfraView-C5OYx_9s.js → InfraView-B1TgXARJ.js} +2 -2
  40. package/ui/dist/assets/{InlineEditableField-DyBCbIoN.js → InlineEditableField-DOJNOL8m.js} +1 -1
  41. package/ui/dist/assets/{Input-DWnbv1Yh.js → Input-BgyHgQ3D.js} +1 -1
  42. package/ui/dist/assets/{IntegrationsPanel-DsB6hjvE.js → IntegrationsPanel-O26b4nhv.js} +1 -1
  43. package/ui/dist/assets/{IntelligenceView-PIFGvIg_.js → IntelligenceView-DUhTQ8f_.js} +2 -2
  44. package/ui/dist/assets/{LearningPanel-D_S4HFX5.js → LearningPanel-DX5S9ovg.js} +1 -1
  45. package/ui/dist/assets/{LogsPanel-BnWNREPX.js → LogsPanel-DdeTnATQ.js} +1 -1
  46. package/ui/dist/assets/{McpPanel-CIMxZ2Am.js → McpPanel-BpXWrP1a.js} +1 -1
  47. package/ui/dist/assets/{MemoryGraphPanel-DD7x4rrm.js → MemoryGraphPanel-CNkZmTUy.js} +1 -1
  48. package/ui/dist/assets/{MemoryWikiPanel-BPPVAH0b.js → MemoryWikiPanel-o4L8Df-n.js} +1 -1
  49. package/ui/dist/assets/{MeshPanel-CiuwR3oV.js → MeshPanel-DMBQJFCC.js} +1 -1
  50. package/ui/dist/assets/{NvidiaPanel-DVntoRrH.js → NvidiaPanel-C8P-tJFG.js} +1 -1
  51. package/ui/dist/assets/{OrganismPanel-pqIKtHrW.js → OrganismPanel-CcfHDWDk.js} +1 -1
  52. package/ui/dist/assets/OverviewPanel-BSotI1Zv.js +1 -0
  53. package/ui/dist/assets/{PageHeader-CF75km05.js → PageHeader-DPJuAgJk.js} +1 -1
  54. package/ui/dist/assets/{PaperclipPanel-CwN5-cKg.js → PaperclipPanel-aXoXUjo6.js} +1 -1
  55. package/ui/dist/assets/{PersonasPanel-ClC_TTGX.js → PersonasPanel-DdPZxz2C.js} +1 -1
  56. package/ui/dist/assets/{RecipesPanel-Di2l-eOe.js → RecipesPanel-D7qffXQN.js} +1 -1
  57. package/ui/dist/assets/{SecurityPanel-DjC4pXGM.js → SecurityPanel-BDRK5el7.js} +1 -1
  58. package/ui/dist/assets/{SelfImprovePanel-CNpCp5N4.js → SelfImprovePanel-oYiMwFnA.js} +1 -1
  59. package/ui/dist/assets/{SelfProposalsPanel-BJL6Fjxo.js → SelfProposalsPanel-DOpNU_rr.js} +1 -1
  60. package/ui/dist/assets/{SessionsPanel-EAGKDQp0.js → SessionsPanel-eRbM3D9P.js} +1 -1
  61. package/ui/dist/assets/{SessionsTab-tc0njI15.js → SessionsTab-Jq3UKQCI.js} +1 -1
  62. package/ui/dist/assets/{SettingsPanel-BdSGImIa.js → SettingsPanel-DBIvKUYY.js} +1 -1
  63. package/ui/dist/assets/{SettingsView-DQB64bjy.js → SettingsView-yfSY4OLt.js} +2 -2
  64. package/ui/dist/assets/{SkeletonLoader-P8SFCyGi.js → SkeletonLoader-D1d-Gyyg.js} +1 -1
  65. package/ui/dist/assets/{SkillsPanel-lDMl_8da.js → SkillsPanel-bubl9nag.js} +1 -1
  66. package/ui/dist/assets/{SomaView-BG7YvBu2.js → SomaView-D3aFL8Tw.js} +1 -1
  67. package/ui/dist/assets/{StatCard-Cv2u-yqA.js → StatCard-CEVFsz7t.js} +1 -1
  68. package/ui/dist/assets/{StatusBadge-JJeoEdCm.js → StatusBadge-DxeA9LNd.js} +1 -1
  69. package/ui/dist/assets/{TeamsPanel-D-iCyyYd.js → TeamsPanel-D6IJJIR_.js} +1 -1
  70. package/ui/dist/assets/{TelemetryPanel-DHNFyCwn.js → TelemetryPanel-SMPebdjQ.js} +1 -1
  71. package/ui/dist/assets/{TitanCanvas-BhurNMK3.js → TitanCanvas-BQU1yxqf.js} +3 -3
  72. package/ui/dist/assets/ToolsView-DgP4uRPr.js +2 -0
  73. package/ui/dist/assets/{Tooltip-D4IeQDJL.js → Tooltip-CNPQr7IO.js} +1 -1
  74. package/ui/dist/assets/{TraceViewer-CMd-Wi0z.js → TraceViewer-BbISy_ET.js} +1 -1
  75. package/ui/dist/assets/{TrainingPanel-CLtiBq2h.js → TrainingPanel-BdCHcv6t.js} +1 -1
  76. package/ui/dist/assets/{VoiceOverlay-BXPVdnJc.js → VoiceOverlay-l6yoasVz.js} +1 -1
  77. package/ui/dist/assets/{VramPanel-DjuwGUzA.js → VramPanel-XLhmen92.js} +1 -1
  78. package/ui/dist/assets/{WatchView-B7sDnMpl.js → WatchView-Bt-lNNWJ.js} +1 -1
  79. package/ui/dist/assets/{WorkTab-B5nQ4Y7A.js → WorkTab-IG-F6Qll.js} +1 -1
  80. package/ui/dist/assets/{WorkflowsPanel-2z0TeXyR.js → WorkflowsPanel-DsMpnwLK.js} +1 -1
  81. package/ui/dist/assets/{arrow-left-BKOkzkae.js → arrow-left-C_H9Z2Tm.js} +1 -1
  82. package/ui/dist/assets/{chart-column-D39PCk17.js → chart-column-rR6tb72l.js} +1 -1
  83. package/ui/dist/assets/{circle-check-big-CMz0QouP.js → circle-check-big-B1hMwau0.js} +1 -1
  84. package/ui/dist/assets/{dollar-sign-Bu8fZOQl.js → dollar-sign-DhYwsTnR.js} +1 -1
  85. package/ui/dist/assets/{download-vvx6zJ-U.js → download-UDDcAlZC.js} +1 -1
  86. package/ui/dist/assets/{eye-off-BPXFIzlW.js → eye-off-Cx0M_VQb.js} +1 -1
  87. package/ui/dist/assets/{funnel-Bqns-i8I.js → funnel-B7YvM1ei.js} +1 -1
  88. package/ui/dist/assets/{git-branch-CdmeqL8d.js → git-branch-BhTBN3J6.js} +1 -1
  89. package/ui/dist/assets/index-D0RJ8701.css +1 -0
  90. package/ui/dist/assets/{index-C6oarzis.js → index-D7Clon2u.js} +2 -2
  91. package/ui/dist/assets/layers-B6jDzitD.js +6 -0
  92. package/ui/dist/assets/{legacy-DFIaZTiF.js → legacy-av079XKu.js} +1 -1
  93. package/ui/dist/assets/{lightbulb-DOL6Q-iP.js → lightbulb-DRuQ3Chf.js} +1 -1
  94. package/ui/dist/assets/{pause-B0XymOnS.js → pause-DqkRWPB_.js} +1 -1
  95. package/ui/dist/assets/{play-Dwp2l5HG.js → play-hUyR3CVS.js} +1 -1
  96. package/ui/dist/assets/{plug-DRlTjWqQ.js → plug-CvpyjJt_.js} +1 -1
  97. package/ui/dist/assets/{proxy-sXxWK7WF.js → proxy-Cc5bR828.js} +1 -1
  98. package/ui/dist/assets/{square-yh0jffQZ.js → square-CdiC0J8Z.js} +1 -1
  99. package/ui/dist/assets/{target-GxtNG2RW.js → target-DemL8_0v.js} +1 -1
  100. package/ui/dist/assets/{toggle-right-CYQd_Ux1.js → toggle-right-Dsk892k5.js} +1 -1
  101. package/ui/dist/assets/{trash-2-B4jp_pAQ.js → trash-2-Byj4OvKB.js} +1 -1
  102. package/ui/dist/assets/{trending-up-B26tNhFP.js → trending-up-Dh_CffGX.js} +1 -1
  103. package/ui/dist/assets/{trophy-Bf3ZeSeb.js → trophy-DDr2AePx.js} +1 -1
  104. package/ui/dist/index.html +2 -2
  105. package/ui/dist/assets/EvalHarnessPanel-CJv8CUDy.js +0 -1
  106. package/ui/dist/assets/OverviewPanel-gqYRhmpF.js +0 -6
  107. package/ui/dist/assets/ToolsView-C8sWxLny.js +0 -2
  108. package/ui/dist/assets/index-DsFoD9SP.css +0 -1
@@ -1 +1 @@
1
- import{r as a,j as e,e as $,ao as E,ap as D,aq as F}from"./index-C6oarzis.js";import{P as R}from"./PageHeader-CF75km05.js";import{R as O,i as K,c as W}from"./TitanCanvas-BhurNMK3.js";import{C as _}from"./circle-check-big-CMz0QouP.js";import{a as G,C as H}from"./VoiceOverlay-BXPVdnJc.js";import{E as I}from"./eye-off-BPXFIzlW.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-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 +1 @@
1
- import{r as t,aV as o,j as e,aW as d}from"./index-C6oarzis.js";import{P as m}from"./PageHeader-CF75km05.js";import{R as h,c as x}from"./TitanCanvas-BhurNMK3.js";import{T as p}from"./trash-2-B4jp_pAQ.js";import"./VoiceOverlay-BXPVdnJc.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-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,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkTab-B5nQ4Y7A.js","assets/index-C6oarzis.js","assets/index-DsFoD9SP.css","assets/proxy-sXxWK7WF.js","assets/TitanCanvas-BhurNMK3.js","assets/VoiceOverlay-BXPVdnJc.js","assets/TitanCanvas-BfitWg9R.css","assets/play-Dwp2l5HG.js","assets/trash-2-B4jp_pAQ.js","assets/pause-B0XymOnS.js","assets/SessionsTab-tc0njI15.js","assets/CPInbox-C6l2o4FD.js","assets/Input-DWnbv1Yh.js","assets/PageHeader-CF75km05.js","assets/EmptyState-Dk7BBthD.js","assets/SkeletonLoader-P8SFCyGi.js","assets/funnel-Bqns-i8I.js","assets/square-yh0jffQZ.js","assets/CPFiles-BDRjJpYl.js","assets/TraceViewer-CMd-Wi0z.js","assets/trending-up-B26tNhFP.js","assets/git-branch-CdmeqL8d.js","assets/chart-column-D39PCk17.js","assets/arrow-left-BKOkzkae.js","assets/CPSocial-Cea6NptR.js","assets/lightbulb-DOL6Q-iP.js","assets/CPDashboard-CnMd6qNK.js","assets/StatusBadge-JJeoEdCm.js","assets/dollar-sign-Bu8fZOQl.js","assets/target-GxtNG2RW.js","assets/CPGoals-2DrwHk62.js","assets/InlineEditableField-DyBCbIoN.js","assets/Tooltip-D4IeQDJL.js","assets/CPAgents-CpkHf0b8.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-C6oarzis.js";import{B as q}from"./Input-DWnbv1Yh.js";import{A as fe,m as G}from"./proxy-sXxWK7WF.js";import{I as $}from"./InlineEditableField-DyBCbIoN.js";import{H as ye}from"./Tooltip-D4IeQDJL.js";import{C as H}from"./VoiceOverlay-BXPVdnJc.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-BhurNMK3.js";import{P as ze}from"./pause-B0XymOnS.js";import{D as W}from"./dollar-sign-Bu8fZOQl.js";import{G as ee}from"./git-branch-CdmeqL8d.js";import{C as te}from"./chart-column-D39PCk17.js";import{T as Te}from"./target-GxtNG2RW.js";import{T as se}from"./trash-2-B4jp_pAQ.js";/**
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";/**
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-B5nQ4Y7A.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Xe=s.lazy(()=>_(()=>import("./SessionsTab-tc0njI15.js"),__vite__mapDeps([10,1,2,3]))),Ye=s.lazy(()=>_(()=>import("./CPInbox-C6l2o4FD.js"),__vite__mapDeps([11,1,2,12,4,5,6,13,14,15,16,17]))),et=s.lazy(()=>_(()=>import("./CPFiles-BDRjJpYl.js"),__vite__mapDeps([18,1,2,4,5,6]))),tt=s.lazy(()=>_(()=>import("./TraceViewer-CMd-Wi0z.js"),__vite__mapDeps([19,1,2,20,4,5,6,21,22,23]))),st=s.lazy(()=>_(()=>import("./CPSocial-Cea6NptR.js"),__vite__mapDeps([24,1,2,4,5,6,25]))),at=s.lazy(()=>_(()=>import("./CPDashboard-CnMd6qNK.js"),__vite__mapDeps([26,1,2,12,4,5,6,27,13,15,28,29]))),rt=s.lazy(()=>_(()=>import("./CPGoals-2DrwHk62.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-CpkHf0b8.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-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};
@@ -1 +1 @@
1
- import{r as t,aS as d,j as e,aT as m,aU as x}from"./index-C6oarzis.js";import{P as h}from"./PageHeader-CF75km05.js";import{R as f,C as b}from"./TitanCanvas-BhurNMK3.js";import{T as g,a as p}from"./toggle-right-CYQd_Ux1.js";import{T as u}from"./trash-2-B4jp_pAQ.js";import"./VoiceOverlay-BXPVdnJc.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-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 +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-C6oarzis.js";import{i as R,R as S,C as P}from"./TitanCanvas-BhurNMK3.js";import{P as k}from"./pause-B0XymOnS.js";import{P as E}from"./play-Dwp2l5HG.js";import"./VoiceOverlay-BXPVdnJc.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-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 +1 @@
1
- import{j as e}from"./index-C6oarzis.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-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 +1 @@
1
- import{j as t}from"./index-C6oarzis.js";import{B as r}from"./Input-DWnbv1Yh.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-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};
@@ -0,0 +1,2 @@
1
+ import{b as S,r as h,j as e,bq as w,e as O,h as C}from"./index-D7Clon2u.js";import{L as F}from"./layers-B6jDzitD.js";import{e as $,R as E,L as M,W as T}from"./TitanCanvas-BQU1yxqf.js";import{T as P}from"./trending-up-Dh_CffGX.js";import{P as _}from"./play-hUyR3CVS.js";import{a as I,C as B}from"./VoiceOverlay-l6yoasVz.js";import{C as R}from"./circle-check-big-B1hMwau0.js";const A={"widget-creation":"Widget Creation",safety:"Safety","tool-routing":"Tool Routing","gate-format":"Gate Format",pipeline:"Pipeline Classification",adversarial:"Adversarial","tool-routing-v2":"Tool Routing v2",session:"Session Management","widget-v2":"Widget v2","gate-format-v2":"Gate Format v2",content:"Content Quality"};async function D(){const s=await S("/api/eval/suites");if(!s.ok)throw new Error(`/api/eval/suites failed: ${s.status}`);const i=await s.json();return Array.isArray(i.suites)?i.suites:[]}async function U(s){const i=await S("/api/eval/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({suite:s})});if(!i.ok){const t=await i.text().catch(()=>"");throw new Error(`/api/eval/run failed: ${i.status} ${t.slice(0,200)}`)}return i.json()}function L(s){return s.total?Math.round(s.passed/s.total*100):NaN}function N(s){return Number.isNaN(s)?"slate":s>=100?"emerald":s>=80?"amber":"red"}function W(s){const i=[];for(const t of s.split(`
2
+ `)){const n=t.trim();if(!n||n.startsWith("#"))continue;const l=n.match(/^([a-zA-Z_:][a-zA-Z0-9_:]*)(?:\{([^}]*)\})?\s+([0-9eE+\-.NaN]+)/);if(!l)continue;const d={};if(l[2])for(const b of l[2].split(",")){const[m,...c]=b.split("=");if(!m)continue;const j=c.join("=").trim().replace(/^"|"$/g,"");d[m.trim()]=j}const a=Number(l[3]);Number.isNaN(a)||i.push({name:l[1],labels:d,value:a})}return i}async function q(s){const i=await S("/metrics");if(!i.ok)throw new Error(`/metrics failed: ${i.status}`);const t=await i.text(),n=W(t);return s?n.filter(l=>l.name===s||l.name.startsWith(`${s}_`)):n}const y={emerald:"bg-emerald-500/15 text-emerald-300 border-emerald-500/40",amber:"bg-amber-500/15 text-amber-300 border-amber-500/40",red:"bg-red-500/15 text-red-300 border-red-500/40",slate:"bg-slate-500/15 text-slate-300 border-slate-500/40"},J=[{id:"suites",label:"Suites",icon:F},{id:"memory",label:"Memory Regression",icon:$},{id:"redteam",label:"Red Team",icon:w},{id:"trends",label:"Trends",icon:P}];function le(){const[s,i]=h.useState("suites"),[t,n]=h.useState([]),[l,d]=h.useState(!1),[a,b]=h.useState(null),m=h.useCallback(async()=>{d(!0);try{const r=await D();n(x=>{const f=new Map(x.map(p=>[p.name,p]));return r.map(p=>f.get(p)??{name:p,status:"idle"})})}catch(r){console.error("listEvalSuites failed:",r),n([])}finally{d(!1)}},[]);h.useEffect(()=>{m()},[m]);const c=h.useCallback(async r=>{n(x=>x.map(f=>f.name===r?{...f,status:"running",error:void 0}:f));try{const x=await U(r);n(f=>f.map(p=>p.name===r?{...p,status:"done",result:x}:p))}catch(x){n(f=>f.map(p=>p.name===r?{...p,status:"error",error:x.message}:p))}},[]),j=h.useCallback(async()=>{for(const r of t)await c(r.name)},[t,c]),g=t.reduce((r,x)=>{var f,p,k;return{total:r.total+(((f=x.result)==null?void 0:f.total)??0),passed:r.passed+(((p=x.result)==null?void 0:p.passed)??0),failed:r.failed+(((k=x.result)==null?void 0:k.failed)??0)}},{total:0,passed:0,failed:0}),o=L(g),u=N(o),v=t.some(r=>r.status==="running");return e.jsxs("div",{className:"flex h-full flex-col gap-4 p-4 text-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Eval Harness"}),e.jsx("div",{className:"flex items-center gap-1 rounded border border-slate-700 bg-slate-800/40 p-0.5",children:J.map(r=>{const x=r.icon,f=r.id===s;return e.jsxs("button",{onClick:()=>i(r.id),className:`flex items-center gap-1.5 rounded px-2.5 py-1 text-xs ${f?"bg-slate-700/80 text-slate-100":"text-slate-400 hover:bg-slate-700/30"}`,children:[e.jsx(x,{className:"h-3 w-3"}),r.label]},r.id)})}),s==="suites"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:m,disabled:l||v,className:"rounded border border-slate-700 bg-slate-800/40 p-1.5 hover:bg-slate-800 disabled:opacity-50",title:"Refresh suite list",children:e.jsx(E,{className:`h-3.5 w-3.5 ${l?"animate-spin":""}`})}),e.jsxs("button",{onClick:j,disabled:t.length===0||v,className:"ml-auto flex items-center gap-1.5 rounded border border-emerald-500/40 bg-emerald-500/10 px-3 py-1.5 text-sm text-emerald-300 hover:bg-emerald-500/20 disabled:opacity-50",children:[v?e.jsx(M,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(_,{className:"h-3.5 w-3.5"}),"Run all suites"]})]})]}),s==="suites"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex items-center gap-3 rounded-lg border p-3 text-sm ${y[u]}`,children:[e.jsxs("div",{className:"font-medium",children:["Overall: ",g.passed,"/",g.total," passed",Number.isFinite(o)&&e.jsxs("span",{className:"ml-2 opacity-80",children:["(",o,"%)"]})]}),g.failed>0&&e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[e.jsx(O,{className:"h-3.5 w-3.5"}),g.failed," failure",g.failed===1?"":"s"]})]}),e.jsxs("div",{className:"flex-1 space-y-2 overflow-auto",children:[t.length===0&&!l&&e.jsxs("div",{className:"rounded border border-slate-700 bg-slate-800/30 p-4 text-center text-sm text-slate-400",children:["No eval suites available. Verify ",e.jsx("code",{className:"font-mono text-xs",children:"/api/eval/suites"})," on the gateway."]}),t.map(r=>e.jsx(V,{suite:r,expanded:a===r.name,onToggle:()=>b(x=>x===r.name?null:r.name),onRun:()=>c(r.name)},r.name))]})]}),s==="memory"&&e.jsx(z,{suites:t,onRun:c}),s==="redteam"&&e.jsx(H,{suites:t,onRun:c}),s==="trends"&&e.jsx(K,{})]})}function z({suites:s,onRun:i}){const t=s.flatMap(l=>{var d;return(((d=l.result)==null?void 0:d.results)??[]).filter(a=>/memory|recall|stale|distract|context/i.test(a.name)).map(a=>({suite:l.name,case:a}))});if(t.length===0)return e.jsx("div",{className:"flex flex-1 items-center justify-center rounded border border-dashed border-slate-700 bg-slate-800/20 p-8 text-center",children:e.jsxs("div",{children:[e.jsx($,{className:"mx-auto mb-2 h-6 w-6 text-slate-500"}),e.jsx("div",{className:"text-sm text-slate-300",children:"No memory regression results yet."}),e.jsxs("div",{className:"mt-1 text-xs text-slate-500",children:["Run a suite that contains memory cases (session, content). Multi-turn fact recall is asserted via tape replay in ",e.jsx("code",{className:"font-mono",children:"tests/eval/memory.test.ts"}),"."]}),e.jsxs("div",{className:"mt-3 flex justify-center gap-2",children:[e.jsx("button",{onClick:()=>i("session"),className:"rounded border border-emerald-500/40 bg-emerald-500/10 px-3 py-1 text-xs text-emerald-300 hover:bg-emerald-500/20",children:"Run session suite"}),e.jsx("button",{onClick:()=>i("content"),className:"rounded border border-emerald-500/40 bg-emerald-500/10 px-3 py-1 text-xs text-emerald-300 hover:bg-emerald-500/20",children:"Run content suite"})]})]})});const n=t.filter(l=>l.case.passed).length;return e.jsxs("div",{className:"flex flex-1 flex-col gap-3 overflow-auto",children:[e.jsx("div",{className:`rounded-lg border p-3 text-sm ${y[N(n/t.length*100)]}`,children:e.jsxs("div",{className:"font-medium",children:["Memory recall: ",n,"/",t.length," cases passed",e.jsxs("span",{className:"ml-2 opacity-80",children:["(",Math.round(n/t.length*100),"%)"]})]})}),e.jsx("div",{className:"space-y-1.5",children:t.map(l=>e.jsxs("div",{className:`rounded p-2 text-xs ${l.case.passed?"bg-slate-800/30":"bg-red-950/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l.case.passed?e.jsx(R,{className:"h-3.5 w-3.5 text-emerald-400"}):e.jsx(C,{className:"h-3.5 w-3.5 text-red-400"}),e.jsx("div",{className:"font-mono text-slate-200",children:l.case.name}),e.jsx("div",{className:"ml-auto text-[10px] text-slate-500",children:l.suite})]}),!l.case.passed&&l.case.errors.length>0&&e.jsx("ul",{className:"mt-1 ml-5 list-disc text-red-300",children:l.case.errors.map((d,a)=>e.jsx("li",{children:d},a))})]},`${l.suite}/${l.case.name}`))})]})}const G=[{id:"ignore-prev",label:"Ignore-previous",pattern:/ignore.*(previous|prior)|disregard|forget/i},{id:"dan",label:"DAN / persona swap",pattern:/\bDAN\b|do anything|jailbreak/i},{id:"prompt-extract",label:"Prompt extraction",pattern:/system prompt|reveal|extract|leak/i},{id:"path-traversal",label:"Path traversal",pattern:/\.\.\/|\/etc\/passwd|path traversal/i},{id:"shell-inject",label:"Shell injection",pattern:/;.*rm|`whoami`|\$\(|\| ?bash/i},{id:"url-scheme",label:"URL scheme abuse",pattern:/file:\/\/|dict:\/\/|gopher:\/\//i},{id:"markdown-js",label:"Markdown JS link",pattern:/\[.*\]\(javascript:/i},{id:"other",label:"Other",pattern:/.*/}];function H({suites:s,onRun:i}){var d;const t=s.find(a=>a.name==="adversarial"),n=((d=t==null?void 0:t.result)==null?void 0:d.results)??[];if(n.length===0)return e.jsx("div",{className:"flex flex-1 items-center justify-center rounded border border-dashed border-slate-700 bg-slate-800/20 p-8 text-center",children:e.jsxs("div",{children:[e.jsx(w,{className:"mx-auto mb-2 h-6 w-6 text-slate-500"}),e.jsx("div",{className:"text-sm text-slate-300",children:"No red-team results yet."}),e.jsx("div",{className:"mt-1 text-xs text-slate-500",children:"Run the adversarial suite to populate this grid."}),e.jsx("button",{onClick:()=>i("adversarial"),className:"mt-3 rounded border border-red-500/40 bg-red-500/10 px-3 py-1 text-xs text-red-300 hover:bg-red-500/20",children:"Run adversarial suite"})]})});const l=G.map(a=>{const b=n.filter(c=>a.pattern.test(c.name)||a.pattern.test(c.content||"")),m=b.filter(c=>c.passed).length;return{vector:a,total:b.length,blocked:m,matched:b}}).filter(a=>a.total>0);return e.jsxs("div",{className:"flex flex-1 flex-col gap-3 overflow-auto",children:[e.jsx("div",{className:"text-xs text-slate-400",children:"Pass = attack BLOCKED (TITAN refused or sanitized). Fail = attack possibly EXPLOITED — investigate the case."}),e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:l.map(a=>{const b=a.total>0?Math.round(a.blocked/a.total*100):0,m=N(b);return e.jsxs("div",{className:`rounded-lg border p-3 ${y[m]}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(w,{className:"h-3.5 w-3.5"}),a.vector.label]}),e.jsxs("div",{className:"mt-1 text-xs",children:[a.blocked,"/",a.total," blocked (",b,"%)"]}),e.jsxs("div",{className:"mt-2 space-y-1",children:[a.matched.slice(0,4).map(c=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[c.passed?e.jsx(R,{className:"h-2.5 w-2.5 text-emerald-400"}):e.jsx(C,{className:"h-2.5 w-2.5 text-red-400"}),e.jsx("span",{className:"font-mono",children:c.name})]},c.name)),a.matched.length>4&&e.jsxs("div",{className:"text-[10px] text-slate-500",children:["+ ",a.matched.length-4," more"]})]})]},a.vector.id)})})]})}function K(){const[s,i]=h.useState([]),[t,n]=h.useState(!1),[l,d]=h.useState(null),[a,b]=h.useState(null),m=h.useCallback(async()=>{n(!0),d(null);try{const o=await q("titan_eval");i(o),b(new Date)}catch(o){d(o.message)}finally{n(!1)}},[]);h.useEffect(()=>{m();const o=setInterval(m,3e4);return()=>clearInterval(o)},[m]);const c=h.useMemo(()=>s.filter(o=>o.name==="titan_eval_pass_rate"&&o.labels.suite).map(o=>({suite:o.labels.suite,rate:o.value})).sort((o,u)=>o.rate-u.rate),[s]),j=h.useMemo(()=>{const o=new Map;for(const u of s){if(u.name!=="titan_eval_cases_total"||!u.labels.suite)continue;const v=o.get(u.labels.suite)??{passed:0,failed:0};u.labels.outcome==="passed"?v.passed=u.value:u.labels.outcome==="failed"&&(v.failed=u.value),o.set(u.labels.suite,v)}return o},[s]),g=100;return e.jsxs("div",{className:"flex flex-1 flex-col gap-3 overflow-auto",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400",children:[e.jsxs("span",{children:["Live from ",e.jsx("code",{className:"font-mono",children:"/metrics"})," (titan_eval_pass_rate gauge)."]}),e.jsx("span",{className:"ml-auto",children:a?`updated ${a.toLocaleTimeString()}`:""}),e.jsx("button",{onClick:m,disabled:t,className:"rounded border border-slate-700 bg-slate-800/40 p-1 hover:bg-slate-800 disabled:opacity-50",children:e.jsx(E,{className:`h-3 w-3 ${t?"animate-spin":""}`})})]}),l&&e.jsx("div",{className:"rounded border border-red-500/40 bg-red-500/10 p-2 text-xs text-red-300",children:l}),c.length===0&&!l&&e.jsxs("div",{className:"rounded border border-dashed border-slate-700 bg-slate-800/20 p-6 text-center text-sm text-slate-400",children:["No eval pass-rate metrics yet. Run a suite via the Suites tab to populate ",e.jsx("code",{className:"font-mono",children:"titan_eval_pass_rate"}),"."]}),e.jsx("div",{className:"space-y-1.5",children:c.map(({suite:o,rate:u})=>{const v=j.get(o),r=N(u),x=A[o]??o;return e.jsx("div",{className:`rounded border p-2 text-xs ${y[r]}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-32 truncate font-medium text-slate-200",children:x}),e.jsx("div",{className:"relative h-4 flex-1 overflow-hidden rounded bg-slate-800/60",children:e.jsx("div",{className:`h-full ${r==="emerald"?"bg-emerald-500/60":r==="amber"?"bg-amber-500/60":r==="red"?"bg-red-500/60":"bg-slate-500/60"}`,style:{width:`${u/g*100}%`}})}),e.jsxs("div",{className:"w-16 text-right font-mono",children:[u,"%"]}),v&&e.jsxs("div",{className:"w-20 text-right text-[10px] text-slate-500",children:[v.passed,"/",v.passed+v.failed," ever"]})]})},o)})})]})}function V({suite:s,expanded:i,onToggle:t,onRun:n}){var b;const l=A[s.name]??s.name,d=s.result?L(s.result):NaN,a=N(d);return e.jsxs("div",{className:`rounded-lg border ${y[a]}`,children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsx("button",{onClick:t,disabled:!s.result,className:"text-slate-300 disabled:opacity-30","aria-label":i?"Collapse":"Expand",children:i?e.jsx(I,{className:"h-4 w-4"}):e.jsx(B,{className:"h-4 w-4"})}),e.jsx("div",{className:"font-medium text-slate-100",children:l}),e.jsx("div",{className:"text-xs text-slate-400",children:s.result?`${s.result.passed}/${s.result.total} (${d}%)`:s.status==="running"?"running…":s.status==="error"?`error: ${s.error}`:"idle"}),((b=s.result)==null?void 0:b.durationMs)!==void 0&&e.jsxs("div",{className:"text-xs text-slate-500",children:[(s.result.durationMs/1e3).toFixed(1),"s"]}),e.jsxs("button",{onClick:n,disabled:s.status==="running",className:"ml-auto flex items-center gap-1 rounded border border-slate-600 bg-slate-800/60 px-2 py-1 text-xs text-slate-200 hover:bg-slate-800 disabled:opacity-50",children:[s.status==="running"?e.jsx(M,{className:"h-3 w-3 animate-spin"}):e.jsx(_,{className:"h-3 w-3"}),"Run"]})]}),i&&s.result&&e.jsx("div",{className:"space-y-1.5 border-t border-slate-700/40 px-3 py-2",children:s.result.results.map(m=>e.jsx(X,{caseResult:m},m.name))})]})}function X({caseResult:s}){const i=s.expectedToolSequence!==void 0&&JSON.stringify(s.expectedToolSequence)!==JSON.stringify(s.toolsUsed);return e.jsxs("div",{className:`rounded p-2 text-xs ${s.passed?"bg-slate-800/30":"bg-red-950/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s.passed?e.jsx(R,{className:"h-3.5 w-3.5 text-emerald-400"}):e.jsx(C,{className:"h-3.5 w-3.5 text-red-400"}),e.jsx("div",{className:"font-mono text-slate-200",children:s.name}),e.jsxs("div",{className:"ml-auto text-slate-500",children:[s.durationMs,"ms"]})]}),!s.passed&&s.errors.length>0&&e.jsx("ul",{className:"mt-1 ml-5 list-disc text-red-300",children:s.errors.map((t,n)=>e.jsx("li",{children:t},n))}),i&&e.jsxs("div",{className:"mt-2 ml-5 grid grid-cols-2 gap-2 rounded bg-slate-900/40 p-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-slate-400",children:[e.jsx(T,{className:"h-3 w-3"})," expected"]}),(s.expectedToolSequence??[]).map((t,n)=>e.jsxs("div",{className:"font-mono text-emerald-300",children:[n+1,". ",t]},n))]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-slate-400",children:[e.jsx(T,{className:"h-3 w-3"})," actual"]}),s.toolsUsed.length===0&&e.jsx("div",{className:"italic text-slate-500",children:"(no tool calls)"}),s.toolsUsed.map((t,n)=>{var a;const d=((a=s.expectedToolSequence)==null?void 0:a[n])===t;return e.jsxs("div",{className:`font-mono ${d?"text-emerald-300":"text-red-300"}`,children:[n+1,". ",t]},n)})]})]})]})}export{le as default};
@@ -1 +1 @@
1
- import{r as a,b3 as u,b4 as p,b5 as j,j as e,e as N,T as v,b6 as y}from"./index-C6oarzis.js";import{P as T}from"./PageHeader-CF75km05.js";import{R as w}from"./TitanCanvas-BhurNMK3.js";import{P as k}from"./play-Dwp2l5HG.js";import"./VoiceOverlay-BXPVdnJc.js";function E(){const[t,x]=a.useState(null),[r,o]=a.useState([]),[i,b]=a.useState([]),[d,n]=a.useState(!0),[c,m]=a.useState(!1),l=a.useCallback(async()=>{n(!0);try{const[s,h,f]=await Promise.all([u(),p(),j()]);x(s),o(h.tests||[]),b(f.tests||[])}catch{}n(!1)},[]);a.useEffect(()=>{l()},[l]);const g=async()=>{m(!0);try{await y(),await l()}catch{}m(!1)};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(T,{title:"Test Lab",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Quality"},{label:"Tests"}]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:l,disabled:d,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(w,{className:`w-4 h-4 ${d?"animate-spin":""}`})," Refresh"]}),e.jsxs("button",{onClick:g,disabled:c,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(k,{className:"w-4 h-4"})," ",c?"Running...":"Run Tests"]})]}),t&&e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Total"}),e.jsx("div",{className:"text-sm font-semibold text-[#e4e4e7]",children:t.total})]}),e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Passing"}),e.jsx("div",{className:"text-sm font-semibold text-emerald-400",children:t.passing})]}),e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Failing"}),e.jsx("div",{className:"text-sm font-semibold text-red-400",children:t.failing})]}),e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Flaky"}),e.jsx("div",{className:"text-sm font-semibold text-amber-400",children:t.flaky})]})]}),r.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium text-[#e4e4e7] flex items-center gap-2",children:[e.jsx(N,{className:"w-4 h-4 text-red-400"})," Failing Tests"]}),r.map(s=>e.jsxs("div",{className:"p-2 rounded-lg bg-red-950/20 border border-red-900/50",children:[e.jsx("div",{className:"text-xs text-[#e4e4e7]",children:s.name}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[s.suite," • ",s.error.slice(0,60)]})]},s.name))]}),i.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium text-[#e4e4e7] flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4 text-amber-400"})," Flaky Tests"]}),i.map(s=>e.jsxs("div",{className:"p-2 rounded-lg bg-amber-950/20 border border-amber-900/50",children:[e.jsx("div",{className:"text-xs text-[#e4e4e7]",children:s.name}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[s.suite," • ",s.passRate.toFixed(1),"% pass rate"]})]},s.name))]})]})}export{E as default};
1
+ import{r as a,b3 as u,b4 as p,b5 as j,j as e,e as N,T as v,b6 as y}from"./index-D7Clon2u.js";import{P as T}from"./PageHeader-DPJuAgJk.js";import{R as w}from"./TitanCanvas-BQU1yxqf.js";import{P as k}from"./play-hUyR3CVS.js";import"./VoiceOverlay-l6yoasVz.js";function E(){const[t,x]=a.useState(null),[r,o]=a.useState([]),[i,b]=a.useState([]),[d,n]=a.useState(!0),[c,m]=a.useState(!1),l=a.useCallback(async()=>{n(!0);try{const[s,h,f]=await Promise.all([u(),p(),j()]);x(s),o(h.tests||[]),b(f.tests||[])}catch{}n(!1)},[]);a.useEffect(()=>{l()},[l]);const g=async()=>{m(!0);try{await y(),await l()}catch{}m(!1)};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(T,{title:"Test Lab",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Quality"},{label:"Tests"}]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:l,disabled:d,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(w,{className:`w-4 h-4 ${d?"animate-spin":""}`})," Refresh"]}),e.jsxs("button",{onClick:g,disabled:c,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(k,{className:"w-4 h-4"})," ",c?"Running...":"Run Tests"]})]}),t&&e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Total"}),e.jsx("div",{className:"text-sm font-semibold text-[#e4e4e7]",children:t.total})]}),e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Passing"}),e.jsx("div",{className:"text-sm font-semibold text-emerald-400",children:t.passing})]}),e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Failing"}),e.jsx("div",{className:"text-sm font-semibold text-red-400",children:t.failing})]}),e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Flaky"}),e.jsx("div",{className:"text-sm font-semibold text-amber-400",children:t.flaky})]})]}),r.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium text-[#e4e4e7] flex items-center gap-2",children:[e.jsx(N,{className:"w-4 h-4 text-red-400"})," Failing Tests"]}),r.map(s=>e.jsxs("div",{className:"p-2 rounded-lg bg-red-950/20 border border-red-900/50",children:[e.jsx("div",{className:"text-xs text-[#e4e4e7]",children:s.name}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[s.suite," • ",s.error.slice(0,60)]})]},s.name))]}),i.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium text-[#e4e4e7] flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4 text-amber-400"})," Flaky Tests"]}),i.map(s=>e.jsxs("div",{className:"p-2 rounded-lg bg-amber-950/20 border border-amber-900/50",children:[e.jsx("div",{className:"text-xs text-[#e4e4e7]",children:s.name}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[s.suite," • ",s.passRate.toFixed(1),"% pass rate"]})]},s.name))]})]})}export{E as default};
@@ -1,4 +1,4 @@
1
- import{c as E,r,a4 as me,a5 as ue,j as e,X as q,a6 as he,a7 as pe,a8 as I,a9 as ve,aa as fe}from"./index-C6oarzis.js";import{P as be,R as ge,H as je,C as Ne,j as U,c as ye,k as J,D as Z,F as X,f as we}from"./TitanCanvas-BhurNMK3.js";import{C as G}from"./VoiceOverlay-BXPVdnJc.js";import{A as ke}from"./arrow-left-BKOkzkae.js";import{T as Q}from"./trash-2-B4jp_pAQ.js";import{D as Ce}from"./download-vvx6zJ-U.js";/**
1
+ import{c as E,r,a4 as me,a5 as ue,j as e,X as q,a6 as he,a7 as pe,a8 as I,a9 as ve,aa as fe}from"./index-D7Clon2u.js";import{P as be,R as ge,H as je,C as Ne,j as U,c as ye,k as J,D as Z,F as X,f as we}from"./TitanCanvas-BQU1yxqf.js";import{C as G}from"./VoiceOverlay-l6yoasVz.js";import{A as ke}from"./arrow-left-C_H9Z2Tm.js";import{T as Q}from"./trash-2-Byj4OvKB.js";import{D as Ce}from"./download-UDDcAlZC.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,a_ as c,j as e}from"./index-C6oarzis.js";import{P as x}from"./PageHeader-CF75km05.js";import{R as n,g as o}from"./TitanCanvas-BhurNMK3.js";import"./VoiceOverlay-BXPVdnJc.js";function h(){const[i,d]=a.useState([]),[r,l]=a.useState(!0),t=a.useCallback(async()=>{l(!0);try{const s=await c();d(s.nodes||[])}catch{}l(!1)},[]);return a.useEffect(()=>{t()},[t]),e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{title:"Fleet Router",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Mesh"},{label:"Fleet"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:t,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(n,{className:`w-4 h-4 ${r?"animate-spin":""}`})," Refresh"]})}),e.jsx("div",{className:"space-y-2",children:i.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(o,{className:`w-4 h-4 ${s.status==="online"?"text-emerald-400":s.status==="busy"?"text-amber-400":"text-red-400"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[#e4e4e7]",children:s.name}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[s.address," • ",s.capabilities.join(", ")]})]})]}),e.jsx("div",{className:"text-xs text-[#52525b]",children:s.status})]},s.id))})]})}export{h as default};
1
+ import{r as a,a_ as c,j as e}from"./index-D7Clon2u.js";import{P as x}from"./PageHeader-DPJuAgJk.js";import{R as n,g as o}from"./TitanCanvas-BQU1yxqf.js";import"./VoiceOverlay-l6yoasVz.js";function h(){const[i,d]=a.useState([]),[r,l]=a.useState(!0),t=a.useCallback(async()=>{l(!0);try{const s=await c();d(s.nodes||[])}catch{}l(!1)},[]);return a.useEffect(()=>{t()},[t]),e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{title:"Fleet Router",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Mesh"},{label:"Fleet"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:t,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(n,{className:`w-4 h-4 ${r?"animate-spin":""}`})," Refresh"]})}),e.jsx("div",{className:"space-y-2",children:i.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(o,{className:`w-4 h-4 ${s.status==="online"?"text-emerald-400":s.status==="busy"?"text-amber-400":"text-red-400"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[#e4e4e7]",children:s.name}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[s.address," • ",s.capabilities.join(", ")]})]})]}),e.jsx("div",{className:"text-xs text-[#52525b]",children:s.status})]},s.id))})]})}export{h as default};
@@ -1,4 +1,4 @@
1
- import{c as ee,r as d,b as m,j as e,Z as I,C as se,H as te,A as w,W as ae,h as ne,T as le}from"./index-C6oarzis.js";import{P as B}from"./PageHeader-CF75km05.js";import{S as h}from"./StatCard-Cv2u-yqA.js";import{S as re}from"./SkeletonLoader-P8SFCyGi.js";import{R as ie,C as ce,M as de,h as oe,N as D,b as xe,U as me}from"./TitanCanvas-BhurNMK3.js";import{C as he}from"./chart-column-D39PCk17.js";import{C as A}from"./circle-check-big-CMz0QouP.js";import{D as ue}from"./dollar-sign-Bu8fZOQl.js";import"./VoiceOverlay-BXPVdnJc.js";/**
1
+ import{c as ee,r as d,b as m,j as e,Z as I,C as se,H as te,A as w,W as ae,h as ne,T as le}from"./index-D7Clon2u.js";import{P as B}from"./PageHeader-DPJuAgJk.js";import{S as h}from"./StatCard-CEVFsz7t.js";import{S as re}from"./SkeletonLoader-D1d-Gyyg.js";import{R as ie,C as ce,M as de,h as oe,N as D,b as xe,U as me}from"./TitanCanvas-BQU1yxqf.js";import{C as he}from"./chart-column-rR6tb72l.js";import{C as A}from"./circle-check-big-B1hMwau0.js";import{D as ue}from"./dollar-sign-DhYwsTnR.js";import"./VoiceOverlay-l6yoasVz.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomelabPanel-B4bCsrBw.js","assets/index-C6oarzis.js","assets/index-DsFoD9SP.css","assets/PageHeader-CF75km05.js","assets/VoiceOverlay-BXPVdnJc.js","assets/StatCard-Cv2u-yqA.js","assets/SkeletonLoader-P8SFCyGi.js","assets/TitanCanvas-BhurNMK3.js","assets/TitanCanvas-BfitWg9R.css","assets/chart-column-D39PCk17.js","assets/circle-check-big-CMz0QouP.js","assets/dollar-sign-Bu8fZOQl.js","assets/NvidiaPanel-DVntoRrH.js","assets/eye-off-BPXFIzlW.js","assets/FilesPanel-CNrDLmix.js","assets/arrow-left-BKOkzkae.js","assets/trash-2-B4jp_pAQ.js","assets/download-vvx6zJ-U.js","assets/LogsPanel-BnWNREPX.js","assets/TelemetryPanel-DHNFyCwn.js","assets/git-branch-CdmeqL8d.js"])))=>i.map(i=>d[i]);
2
- import{r as s,j as e,n as o,_ as a}from"./index-C6oarzis.js";const r=s.lazy(()=>a(()=>import("./HomelabPanel-B4bCsrBw.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),n=s.lazy(()=>a(()=>import("./NvidiaPanel-DVntoRrH.js"),__vite__mapDeps([12,1,2,7,4,8,10,13]))),d=s.lazy(()=>a(()=>import("./FilesPanel-CNrDLmix.js"),__vite__mapDeps([14,1,2,7,4,8,15,16,17]))),c=s.lazy(()=>a(()=>import("./LogsPanel-BnWNREPX.js"),__vite__mapDeps([18,1,2,7,4,8]))),m=s.lazy(()=>a(()=>import("./TelemetryPanel-DHNFyCwn.js"),__vite__mapDeps([19,1,2,5,7,4,8,20,9]))),x=[{id:"homelab",label:"Homelab"},{id:"gpu",label:"GPU / NVIDIA"},{id:"files",label:"Files"},{id:"logs",label:"Logs"},{id:"telemetry",label:"Telemetry"}];function u(){const[l,i]=s.useState("homelab");return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-0",children:[e.jsx("h1",{className:"text-sm font-semibold text-text mb-3",children:"Infrastructure"}),e.jsx("div",{className:"flex items-center gap-0.5 border-b border-border/50",children:x.map(t=>e.jsxs("button",{onClick:()=>i(t.id),className:o("px-3 py-2 text-xs font-medium transition-colors relative",l===t.id?"text-accent":"text-text-muted hover:text-text-secondary"),children:[t.label,l===t.id&&e.jsx("div",{className:"absolute bottom-0 left-1 right-1 h-[2px] bg-accent rounded-full"})]},t.id))})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto p-5",children:e.jsxs(s.Suspense,{fallback:e.jsx("div",{className:"skeleton-shimmer h-40 rounded-lg"}),children:[l==="homelab"&&e.jsx(r,{}),l==="gpu"&&e.jsx(n,{}),l==="files"&&e.jsx(d,{}),l==="logs"&&e.jsx(c,{}),l==="telemetry"&&e.jsx(m,{})]})})]})}export{u as default};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomelabPanel-C7VBV7AC.js","assets/index-D7Clon2u.js","assets/index-D0RJ8701.css","assets/PageHeader-DPJuAgJk.js","assets/VoiceOverlay-l6yoasVz.js","assets/StatCard-CEVFsz7t.js","assets/SkeletonLoader-D1d-Gyyg.js","assets/TitanCanvas-BQU1yxqf.js","assets/TitanCanvas-BfitWg9R.css","assets/chart-column-rR6tb72l.js","assets/circle-check-big-B1hMwau0.js","assets/dollar-sign-DhYwsTnR.js","assets/NvidiaPanel-C8P-tJFG.js","assets/eye-off-Cx0M_VQb.js","assets/FilesPanel-Dz8TFydL.js","assets/arrow-left-C_H9Z2Tm.js","assets/trash-2-Byj4OvKB.js","assets/download-UDDcAlZC.js","assets/LogsPanel-DdeTnATQ.js","assets/TelemetryPanel-SMPebdjQ.js","assets/git-branch-BhTBN3J6.js"])))=>i.map(i=>d[i]);
2
+ import{r as s,j as e,n as o,_ as a}from"./index-D7Clon2u.js";const r=s.lazy(()=>a(()=>import("./HomelabPanel-C7VBV7AC.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),n=s.lazy(()=>a(()=>import("./NvidiaPanel-C8P-tJFG.js"),__vite__mapDeps([12,1,2,7,4,8,10,13]))),d=s.lazy(()=>a(()=>import("./FilesPanel-Dz8TFydL.js"),__vite__mapDeps([14,1,2,7,4,8,15,16,17]))),c=s.lazy(()=>a(()=>import("./LogsPanel-DdeTnATQ.js"),__vite__mapDeps([18,1,2,7,4,8]))),m=s.lazy(()=>a(()=>import("./TelemetryPanel-SMPebdjQ.js"),__vite__mapDeps([19,1,2,5,7,4,8,20,9]))),x=[{id:"homelab",label:"Homelab"},{id:"gpu",label:"GPU / NVIDIA"},{id:"files",label:"Files"},{id:"logs",label:"Logs"},{id:"telemetry",label:"Telemetry"}];function u(){const[l,i]=s.useState("homelab");return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-0",children:[e.jsx("h1",{className:"text-sm font-semibold text-text mb-3",children:"Infrastructure"}),e.jsx("div",{className:"flex items-center gap-0.5 border-b border-border/50",children:x.map(t=>e.jsxs("button",{onClick:()=>i(t.id),className:o("px-3 py-2 text-xs font-medium transition-colors relative",l===t.id?"text-accent":"text-text-muted hover:text-text-secondary"),children:[t.label,l===t.id&&e.jsx("div",{className:"absolute bottom-0 left-1 right-1 h-[2px] bg-accent rounded-full"})]},t.id))})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto p-5",children:e.jsxs(s.Suspense,{fallback:e.jsx("div",{className:"skeleton-shimmer h-40 rounded-lg"}),children:[l==="homelab"&&e.jsx(r,{}),l==="gpu"&&e.jsx(n,{}),l==="files"&&e.jsx(d,{}),l==="logs"&&e.jsx(c,{}),l==="telemetry"&&e.jsx(m,{})]})})]})}export{u as default};
@@ -1 +1 @@
1
- import{r,n as m,j as t,X as N}from"./index-C6oarzis.js";import{k as w,j as S}from"./TitanCanvas-BhurNMK3.js";function I({value:s,onSave:h,placeholder:p,multiline:a=!1,className:k,displayValue:j,emptyLabel:E="—",hidePencil:C=!1,maxLength:x,title:v}){const[i,c]=r.useState(!1),[o,l]=r.useState(s),[f,y]=r.useState(!1),n=r.useRef(null);r.useEffect(()=>{i&&n.current&&(n.current.focus(),"select"in n.current&&n.current.select())},[i]),r.useEffect(()=>{i||l(s)},[s,i]);const u=async()=>{if(o===s){c(!1);return}y(!0);try{await h(o),c(!1)}catch{}finally{y(!1)}},b=()=>{l(s),c(!1)},g=e=>{e.key==="Enter"&&!a||e.key==="Enter"&&a&&e.metaKey?(e.preventDefault(),u()):e.key==="Escape"&&(e.preventDefault(),b())};if(i){const e=m("bg-bg-tertiary border border-accent/60 rounded px-2 py-1 text-sm text-text","focus:outline-none focus:border-accent","w-full",a&&"resize-none min-h-[60px]");return t.jsxs("span",{className:"inline-flex items-start gap-1 w-full",children:[a?t.jsx("textarea",{ref:n,value:o,onChange:d=>l(d.target.value),onKeyDown:g,placeholder:p,maxLength:x,className:e,disabled:f}):t.jsx("input",{ref:n,type:"text",value:o,onChange:d=>l(d.target.value),onKeyDown:g,placeholder:p,maxLength:x,className:e,disabled:f}),t.jsx("button",{onClick:u,disabled:f,className:"text-success hover:bg-success/10 rounded p-1 shrink-0",title:a?"Save (Cmd+Enter)":"Save (Enter)",type:"button",children:t.jsx(w,{size:14})}),t.jsx("button",{onClick:b,disabled:f,className:"text-text-muted hover:bg-bg-tertiary rounded p-1 shrink-0",title:"Cancel (Esc)",type:"button",children:t.jsx(N,{size:14})})]})}const D=j??(s&&s.length>0?s:E);return t.jsxs("span",{className:m("inline-flex items-center gap-1 cursor-pointer group","hover:bg-bg-tertiary rounded px-1 -mx-1",k),onClick:()=>c(!0),title:v??"Click to edit",role:"button",tabIndex:0,onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),c(!0))},children:[t.jsx("span",{children:D}),!C&&t.jsx(S,{size:10,className:"text-text-muted opacity-0 group-hover:opacity-60 transition-opacity shrink-0"})]})}export{I};
1
+ import{r,n as m,j as t,X as N}from"./index-D7Clon2u.js";import{k as w,j as S}from"./TitanCanvas-BQU1yxqf.js";function I({value:s,onSave:h,placeholder:p,multiline:a=!1,className:k,displayValue:j,emptyLabel:E="—",hidePencil:C=!1,maxLength:x,title:v}){const[i,c]=r.useState(!1),[o,l]=r.useState(s),[f,y]=r.useState(!1),n=r.useRef(null);r.useEffect(()=>{i&&n.current&&(n.current.focus(),"select"in n.current&&n.current.select())},[i]),r.useEffect(()=>{i||l(s)},[s,i]);const u=async()=>{if(o===s){c(!1);return}y(!0);try{await h(o),c(!1)}catch{}finally{y(!1)}},b=()=>{l(s),c(!1)},g=e=>{e.key==="Enter"&&!a||e.key==="Enter"&&a&&e.metaKey?(e.preventDefault(),u()):e.key==="Escape"&&(e.preventDefault(),b())};if(i){const e=m("bg-bg-tertiary border border-accent/60 rounded px-2 py-1 text-sm text-text","focus:outline-none focus:border-accent","w-full",a&&"resize-none min-h-[60px]");return t.jsxs("span",{className:"inline-flex items-start gap-1 w-full",children:[a?t.jsx("textarea",{ref:n,value:o,onChange:d=>l(d.target.value),onKeyDown:g,placeholder:p,maxLength:x,className:e,disabled:f}):t.jsx("input",{ref:n,type:"text",value:o,onChange:d=>l(d.target.value),onKeyDown:g,placeholder:p,maxLength:x,className:e,disabled:f}),t.jsx("button",{onClick:u,disabled:f,className:"text-success hover:bg-success/10 rounded p-1 shrink-0",title:a?"Save (Cmd+Enter)":"Save (Enter)",type:"button",children:t.jsx(w,{size:14})}),t.jsx("button",{onClick:b,disabled:f,className:"text-text-muted hover:bg-bg-tertiary rounded p-1 shrink-0",title:"Cancel (Esc)",type:"button",children:t.jsx(N,{size:14})})]})}const D=j??(s&&s.length>0?s:E);return t.jsxs("span",{className:m("inline-flex items-center gap-1 cursor-pointer group","hover:bg-bg-tertiary rounded px-1 -mx-1",k),onClick:()=>c(!0),title:v??"Click to edit",role:"button",tabIndex:0,onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),c(!0))},children:[t.jsx("span",{children:D}),!C&&t.jsx(S,{size:10,className:"text-text-muted opacity-0 group-hover:opacity-60 transition-opacity shrink-0"})]})}export{I};
@@ -1 +1 @@
1
- import{r as n,j as e,n as d}from"./index-C6oarzis.js";import{L as b}from"./TitanCanvas-BhurNMK3.js";const m={primary:"text-white shadow-sm glow-accent-hover bg-[image:var(--gradient-accent)] hover:brightness-110",secondary:"bg-bg-tertiary text-text border border-border hover:border-border-light hover:bg-bg-secondary",ghost:"text-text-secondary hover:text-text hover:bg-bg-tertiary",danger:"bg-error/10 text-error border border-error/20 hover:bg-error/20"},p={sm:"px-2.5 py-1 text-xs gap-1.5 rounded-md",md:"px-3.5 py-2 text-sm gap-2 rounded-lg",lg:"px-5 py-2.5 text-sm gap-2 rounded-lg"},g=n.forwardRef(({variant:r="primary",size:t="md",icon:o,loading:s,disabled:a,children:i,className:l,...x},c)=>e.jsxs("button",{ref:c,disabled:a||s,className:d("inline-flex items-center justify-center font-medium transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50","disabled:opacity-50 disabled:pointer-events-none",m[r],p[t],l),...x,children:[s?e.jsx(b,{size:t==="sm"?14:16,className:"animate-spin"}):o,i]}));g.displayName="Button";const u=n.forwardRef(({icon:r,error:t,className:o,...s},a)=>e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"relative",children:[r&&e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-muted pointer-events-none",children:r}),e.jsx("input",{ref:a,className:d("w-full rounded-lg border bg-bg py-2 text-sm text-text outline-none transition-colors","placeholder:text-text-muted",r?"pl-10 pr-3":"px-3",t?"border-error focus:border-error":"border-border focus:border-accent",o),...s})]}),t&&e.jsx("p",{className:"mt-1 text-xs text-error",children:t})]}));u.displayName="Input";export{g as B};
1
+ import{r as n,j as e,n as d}from"./index-D7Clon2u.js";import{L as b}from"./TitanCanvas-BQU1yxqf.js";const m={primary:"text-white shadow-sm glow-accent-hover bg-[image:var(--gradient-accent)] hover:brightness-110",secondary:"bg-bg-tertiary text-text border border-border hover:border-border-light hover:bg-bg-secondary",ghost:"text-text-secondary hover:text-text hover:bg-bg-tertiary",danger:"bg-error/10 text-error border border-error/20 hover:bg-error/20"},p={sm:"px-2.5 py-1 text-xs gap-1.5 rounded-md",md:"px-3.5 py-2 text-sm gap-2 rounded-lg",lg:"px-5 py-2.5 text-sm gap-2 rounded-lg"},g=n.forwardRef(({variant:r="primary",size:t="md",icon:o,loading:s,disabled:a,children:i,className:l,...x},c)=>e.jsxs("button",{ref:c,disabled:a||s,className:d("inline-flex items-center justify-center font-medium transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50","disabled:opacity-50 disabled:pointer-events-none",m[r],p[t],l),...x,children:[s?e.jsx(b,{size:t==="sm"?14:16,className:"animate-spin"}):o,i]}));g.displayName="Button";const u=n.forwardRef(({icon:r,error:t,className:o,...s},a)=>e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"relative",children:[r&&e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-muted pointer-events-none",children:r}),e.jsx("input",{ref:a,className:d("w-full rounded-lg border bg-bg py-2 text-sm text-text outline-none transition-colors","placeholder:text-text-muted",r?"pl-10 pr-3":"px-3",t?"border-error focus:border-error":"border-border focus:border-accent",o),...s})]}),t&&e.jsx("p",{className:"mt-1 text-xs text-error",children:t})]}));u.displayName="Input";export{g as B};
@@ -1 +1 @@
1
- import{r as l,j as e,e as F,K as S,b as C,$ as K}from"./index-C6oarzis.js";import{P as A}from"./plug-DRlTjWqQ.js";import{C as U}from"./circle-check-big-CMz0QouP.js";import{E as T}from"./eye-off-BPXFIzlW.js";import{i as I,c as O}from"./TitanCanvas-BhurNMK3.js";import{a as R,C as q}from"./VoiceOverlay-BXPVdnJc.js";const k=[{id:"anthropic",label:"Anthropic",fieldKey:"anthropicKey",fieldType:"key",placeholder:"sk-ant-..."},{id:"openai",label:"OpenAI",fieldKey:"openaiKey",fieldType:"key",placeholder:"sk-..."},{id:"google",label:"Google AI",fieldKey:"googleKey",fieldType:"key",placeholder:"AIza..."},{id:"groq",label:"Groq",fieldKey:"groqKey",fieldType:"key",placeholder:"gsk_..."},{id:"mistral",label:"Mistral",fieldKey:"mistralKey",fieldType:"key",placeholder:"API key"},{id:"openrouter",label:"OpenRouter",fieldKey:"openrouterKey",fieldType:"key",placeholder:"sk-or-..."},{id:"fireworks",label:"Fireworks AI",fieldKey:"fireworksKey",fieldType:"key",placeholder:"API key"},{id:"xai",label:"xAI (Grok)",fieldKey:"xaiKey",fieldType:"key",placeholder:"xai-..."},{id:"together",label:"Together AI",fieldKey:"togetherKey",fieldType:"key",placeholder:"API key"},{id:"deepseek",label:"DeepSeek",fieldKey:"deepseekKey",fieldType:"key",placeholder:"sk-..."},{id:"perplexity",label:"Perplexity",fieldKey:"perplexityKey",fieldType:"key",placeholder:"pplx-..."},{id:"ollama",label:"Ollama",fieldKey:"ollamaUrl",fieldType:"url",placeholder:"http://localhost:11434"}];function P({configured:a}){return e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium ${a?"bg-success/10 text-success":"bg-border-light/20 text-text-muted"}`,children:[e.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${a?"bg-success":"bg-border-light"}`}),a?"Configured":"Not configured"]})}function M({provider:a,configured:b,currentUrl:o,onSave:p,saving:v}){const[f,y]=l.useState(!1),[c,d]=l.useState(a.fieldType==="url"&&o||""),[x,u]=l.useState(!1),h=a.fieldType==="key",i=v===a.id;return e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary",children:[e.jsxs("button",{onClick:()=>y(!f),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:[f?e.jsx(R,{className:"h-4 w-4 text-text-muted"}):e.jsx(q,{className:"h-4 w-4 text-text-muted"}),e.jsx("span",{className:"text-sm font-medium text-text",children:a.label})]}),e.jsx(P,{configured:b})]}),f&&e.jsxs("div",{className:"border-t border-bg-tertiary px-4 py-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:h?"API Key":"Base URL"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:`integration-${a.id}`,name:`integration-${a.id}`,type:h&&!x?"password":"text",value:c,onChange:j=>d(j.target.value),placeholder:a.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"}),h&&e.jsx("button",{type:"button",onClick:()=>u(!x),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary",children:x?e.jsx(T,{className:"h-4 w-4"}):e.jsx(I,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{onClick:()=>p(a.fieldKey,c),disabled:i||!c,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(O,{className:"h-3.5 w-3.5"}),i?"Saving...":"Save"]})})]})]})}function Q(){const[a,b]=l.useState({}),[o,p]=l.useState({clientIdSet:!1,clientSecretSet:!1}),[v,f]=l.useState(!0),[y,c]=l.useState(null),[d,x]=l.useState(null),[u,h]=l.useState(""),[i,j]=l.useState(""),[N,G]=l.useState(!1);l.useEffect(()=>{(async()=>{var t;try{const n=await S();if(n.providers&&b(n.providers),(t=n.oauth)!=null&&t.google){const g=n.oauth.google;try{const r=await(await C("/api/auth/google/status")).json();g.connected=r.connected,g.email=r.email}catch{}p(g)}}catch{}finally{f(!1)}})()},[]);const E=()=>{window.location.href="/api/auth/google/start"},$=async()=>{try{await C("/api/auth/google/disconnect",{method:"POST"}),p(s=>({...s,connected:!1,email:void 0})),m("success","Google account disconnected")}catch{m("error","Failed to disconnect")}},m=(s,t)=>{x({type:s,message:t}),setTimeout(()=>x(null),3e3)},D=async(s,t)=>{var g,w;const n=((g=k.find(r=>r.fieldKey===s))==null?void 0:g.id)||s;c(n);try{await K({[s]:t});const r=await S();r.providers&&b(r.providers),m("success",`${((w=k.find(B=>B.fieldKey===s))==null?void 0:w.label)||"Provider"} saved`)}catch(r){m("error",r instanceof Error?r.message:"Failed to save")}finally{c(null)}},L=async()=>{var s;c("oauth");try{const t={};u&&(t.googleOAuthClientId=u),i&&(t.googleOAuthClientSecret=i),await K(t);const n=await S();(s=n.oauth)!=null&&s.google&&p(n.oauth.google),m("success","Google OAuth settings saved"),h(""),j("")}catch(t){m("error",t instanceof Error?t.message:"Failed to save")}finally{c(null)}};return v?e.jsx("div",{className:"space-y-4",children:Array.from({length:4}).map((s,t)=>e.jsx("div",{className:"h-14 animate-pulse rounded-xl border border-border bg-bg-secondary"},t))}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-accent/10",children:e.jsx(A,{className:"h-4 w-4 text-accent-hover"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-text",children:"Integrations"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Configure LLM providers and external service connections"})]})]}),d&&e.jsxs("div",{className:`flex items-center gap-2 rounded-lg border px-4 py-2 text-sm ${d.type==="success"?"border-success/50 text-success":"border-error/50 text-error"}`,children:[d.type==="success"?e.jsx(U,{className:"h-4 w-4"}):e.jsx(F,{className:"h-4 w-4"}),d.message]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"LLM Providers"}),e.jsx("div",{className:"space-y-2",children:k.map(s=>{const t=a[s.id],n=s.id==="ollama"?!!(t!=null&&t.baseUrl):!!(t!=null&&t.configured);return e.jsx(M,{provider:s,configured:n,currentUrl:s.fieldType==="url"?(t==null?void 0:t.baseUrl)||"":void 0,onSave:D,saving:y},s.id)})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Google Services (OAuth)"}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-text",children:"Google OAuth 2.0"}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:o.connected&&o.email?`Connected as ${o.email}`:"Gmail, Drive, Calendar, Docs, Sheets, Tasks"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{configured:!!o.connected}),o.clientIdSet&&!o.connected&&e.jsxs("button",{onClick:E,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-white hover:bg-accent/80 transition-colors",children:[e.jsx(A,{className:"h-3.5 w-3.5"}),"Connect Google"]}),o.connected&&e.jsx("button",{onClick:$,className:"flex items-center gap-1.5 rounded-lg border border-red-500/30 px-3 py-1.5 text-xs font-medium text-red-400 hover:bg-red-500/10 transition-colors",children:"Disconnect"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:"Client ID"}),e.jsx("input",{id:"integration-google-client-id",name:"integration-google-client-id",type:"text",value:u,onChange:s=>h(s.target.value),placeholder:o.clientIdSet?"(configured)":"your-client-id.apps.googleusercontent.com",className:"w-full rounded-lg border border-border bg-bg px-3 py-2 text-sm text-text outline-none focus:border-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:"Client Secret"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:"integration-google-client-secret",name:"integration-google-client-secret",type:N?"text":"password",value:i,onChange:s=>j(s.target.value),placeholder:o.clientSecretSet?"(configured)":"GOCSPX-...",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:()=>G(!N),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary",children:N?e.jsx(T,{className:"h-4 w-4"}):e.jsx(I,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{onClick:L,disabled:y==="oauth"||!u&&!i,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(O,{className:"h-3.5 w-3.5"}),y==="oauth"?"Saving...":"Save OAuth Settings"]})})]})]})]})}export{Q as default};
1
+ import{r as l,j as e,e as F,K as S,b as C,$ as K}from"./index-D7Clon2u.js";import{P as A}from"./plug-CvpyjJt_.js";import{C as U}from"./circle-check-big-B1hMwau0.js";import{E as T}from"./eye-off-Cx0M_VQb.js";import{i as I,c as O}from"./TitanCanvas-BQU1yxqf.js";import{a as R,C as q}from"./VoiceOverlay-l6yoasVz.js";const k=[{id:"anthropic",label:"Anthropic",fieldKey:"anthropicKey",fieldType:"key",placeholder:"sk-ant-..."},{id:"openai",label:"OpenAI",fieldKey:"openaiKey",fieldType:"key",placeholder:"sk-..."},{id:"google",label:"Google AI",fieldKey:"googleKey",fieldType:"key",placeholder:"AIza..."},{id:"groq",label:"Groq",fieldKey:"groqKey",fieldType:"key",placeholder:"gsk_..."},{id:"mistral",label:"Mistral",fieldKey:"mistralKey",fieldType:"key",placeholder:"API key"},{id:"openrouter",label:"OpenRouter",fieldKey:"openrouterKey",fieldType:"key",placeholder:"sk-or-..."},{id:"fireworks",label:"Fireworks AI",fieldKey:"fireworksKey",fieldType:"key",placeholder:"API key"},{id:"xai",label:"xAI (Grok)",fieldKey:"xaiKey",fieldType:"key",placeholder:"xai-..."},{id:"together",label:"Together AI",fieldKey:"togetherKey",fieldType:"key",placeholder:"API key"},{id:"deepseek",label:"DeepSeek",fieldKey:"deepseekKey",fieldType:"key",placeholder:"sk-..."},{id:"perplexity",label:"Perplexity",fieldKey:"perplexityKey",fieldType:"key",placeholder:"pplx-..."},{id:"ollama",label:"Ollama",fieldKey:"ollamaUrl",fieldType:"url",placeholder:"http://localhost:11434"}];function P({configured:a}){return e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium ${a?"bg-success/10 text-success":"bg-border-light/20 text-text-muted"}`,children:[e.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${a?"bg-success":"bg-border-light"}`}),a?"Configured":"Not configured"]})}function M({provider:a,configured:b,currentUrl:o,onSave:p,saving:v}){const[f,y]=l.useState(!1),[c,d]=l.useState(a.fieldType==="url"&&o||""),[x,u]=l.useState(!1),h=a.fieldType==="key",i=v===a.id;return e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary",children:[e.jsxs("button",{onClick:()=>y(!f),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:[f?e.jsx(R,{className:"h-4 w-4 text-text-muted"}):e.jsx(q,{className:"h-4 w-4 text-text-muted"}),e.jsx("span",{className:"text-sm font-medium text-text",children:a.label})]}),e.jsx(P,{configured:b})]}),f&&e.jsxs("div",{className:"border-t border-bg-tertiary px-4 py-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:h?"API Key":"Base URL"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:`integration-${a.id}`,name:`integration-${a.id}`,type:h&&!x?"password":"text",value:c,onChange:j=>d(j.target.value),placeholder:a.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"}),h&&e.jsx("button",{type:"button",onClick:()=>u(!x),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary",children:x?e.jsx(T,{className:"h-4 w-4"}):e.jsx(I,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{onClick:()=>p(a.fieldKey,c),disabled:i||!c,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(O,{className:"h-3.5 w-3.5"}),i?"Saving...":"Save"]})})]})]})}function Q(){const[a,b]=l.useState({}),[o,p]=l.useState({clientIdSet:!1,clientSecretSet:!1}),[v,f]=l.useState(!0),[y,c]=l.useState(null),[d,x]=l.useState(null),[u,h]=l.useState(""),[i,j]=l.useState(""),[N,G]=l.useState(!1);l.useEffect(()=>{(async()=>{var t;try{const n=await S();if(n.providers&&b(n.providers),(t=n.oauth)!=null&&t.google){const g=n.oauth.google;try{const r=await(await C("/api/auth/google/status")).json();g.connected=r.connected,g.email=r.email}catch{}p(g)}}catch{}finally{f(!1)}})()},[]);const E=()=>{window.location.href="/api/auth/google/start"},$=async()=>{try{await C("/api/auth/google/disconnect",{method:"POST"}),p(s=>({...s,connected:!1,email:void 0})),m("success","Google account disconnected")}catch{m("error","Failed to disconnect")}},m=(s,t)=>{x({type:s,message:t}),setTimeout(()=>x(null),3e3)},D=async(s,t)=>{var g,w;const n=((g=k.find(r=>r.fieldKey===s))==null?void 0:g.id)||s;c(n);try{await K({[s]:t});const r=await S();r.providers&&b(r.providers),m("success",`${((w=k.find(B=>B.fieldKey===s))==null?void 0:w.label)||"Provider"} saved`)}catch(r){m("error",r instanceof Error?r.message:"Failed to save")}finally{c(null)}},L=async()=>{var s;c("oauth");try{const t={};u&&(t.googleOAuthClientId=u),i&&(t.googleOAuthClientSecret=i),await K(t);const n=await S();(s=n.oauth)!=null&&s.google&&p(n.oauth.google),m("success","Google OAuth settings saved"),h(""),j("")}catch(t){m("error",t instanceof Error?t.message:"Failed to save")}finally{c(null)}};return v?e.jsx("div",{className:"space-y-4",children:Array.from({length:4}).map((s,t)=>e.jsx("div",{className:"h-14 animate-pulse rounded-xl border border-border bg-bg-secondary"},t))}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-accent/10",children:e.jsx(A,{className:"h-4 w-4 text-accent-hover"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-text",children:"Integrations"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Configure LLM providers and external service connections"})]})]}),d&&e.jsxs("div",{className:`flex items-center gap-2 rounded-lg border px-4 py-2 text-sm ${d.type==="success"?"border-success/50 text-success":"border-error/50 text-error"}`,children:[d.type==="success"?e.jsx(U,{className:"h-4 w-4"}):e.jsx(F,{className:"h-4 w-4"}),d.message]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"LLM Providers"}),e.jsx("div",{className:"space-y-2",children:k.map(s=>{const t=a[s.id],n=s.id==="ollama"?!!(t!=null&&t.baseUrl):!!(t!=null&&t.configured);return e.jsx(M,{provider:s,configured:n,currentUrl:s.fieldType==="url"?(t==null?void 0:t.baseUrl)||"":void 0,onSave:D,saving:y},s.id)})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Google Services (OAuth)"}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-text",children:"Google OAuth 2.0"}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:o.connected&&o.email?`Connected as ${o.email}`:"Gmail, Drive, Calendar, Docs, Sheets, Tasks"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{configured:!!o.connected}),o.clientIdSet&&!o.connected&&e.jsxs("button",{onClick:E,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-white hover:bg-accent/80 transition-colors",children:[e.jsx(A,{className:"h-3.5 w-3.5"}),"Connect Google"]}),o.connected&&e.jsx("button",{onClick:$,className:"flex items-center gap-1.5 rounded-lg border border-red-500/30 px-3 py-1.5 text-xs font-medium text-red-400 hover:bg-red-500/10 transition-colors",children:"Disconnect"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:"Client ID"}),e.jsx("input",{id:"integration-google-client-id",name:"integration-google-client-id",type:"text",value:u,onChange:s=>h(s.target.value),placeholder:o.clientIdSet?"(configured)":"your-client-id.apps.googleusercontent.com",className:"w-full rounded-lg border border-border bg-bg px-3 py-2 text-sm text-text outline-none focus:border-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:"Client Secret"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:"integration-google-client-secret",name:"integration-google-client-secret",type:N?"text":"password",value:i,onChange:s=>j(s.target.value),placeholder:o.clientSecretSet?"(configured)":"GOCSPX-...",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:()=>G(!N),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary",children:N?e.jsx(T,{className:"h-4 w-4"}):e.jsx(I,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{onClick:L,disabled:y==="oauth"||!u&&!i,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(O,{className:"h-3.5 w-3.5"}),y==="oauth"?"Saving...":"Save OAuth Settings"]})})]})]})]})}export{Q as default};