@wrongstack/webui 0.282.1 → 0.282.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/assets/{AnalyticsDashboard-TCNC-sVb.js → AnalyticsDashboard-CPLSpHzV.js} +1 -1
  2. package/dist/assets/{AutoPhaseView-BMUiT6aI.js → AutoPhaseView-HIzNPExo.js} +1 -1
  3. package/dist/assets/{CodeEditor-C0si742k.js → CodeEditor-dOQDoCfn.js} +1 -1
  4. package/dist/assets/{DebugDashboard-BHpiEOcf.js → DebugDashboard-CQCI-B4W.js} +1 -1
  5. package/dist/assets/{DesignGalleryView-BfZTw48N.js → DesignGalleryView-BxTlrmrr.js} +1 -1
  6. package/dist/assets/{KanbanView-C4T4y0b7.js → KanbanView-2uDRr6Qd.js} +1 -1
  7. package/dist/assets/{MailboxDetailView-DJtjP0NF.js → MailboxDetailView-B0DCs5lu.js} +1 -1
  8. package/dist/assets/OfficeMapPanel-lGSaptet.js +4 -0
  9. package/dist/assets/{ProcessMonitor-D53zn0h4.js → ProcessMonitor-eTb8_-ZW.js} +1 -1
  10. package/dist/assets/{QueuePanel-DTO68vaB.js → QueuePanel-TbbkNAx_.js} +1 -1
  11. package/dist/assets/{RefreshDebugView-BXq2P3wo.js → RefreshDebugView-CX6x-xHs.js} +1 -1
  12. package/dist/assets/SddBoardView-BXQsH6fr.js +2 -0
  13. package/dist/assets/{SddFlowGraph-CtMpzU4S.js → SddFlowGraph-DTWV-DPB.js} +1 -1
  14. package/dist/assets/SddWizard-1ZhDgcgM.js +1 -0
  15. package/dist/assets/{SessionsDashboard-Dqsrp5CK.js → SessionsDashboard-CfNbqjeh.js} +1 -1
  16. package/dist/assets/SkillDetailView-UzixISza.js +2 -0
  17. package/dist/assets/{SpecsView-Cwd6PiYr.js → SpecsView-BO8yG6ID.js} +1 -1
  18. package/dist/assets/{TerminalPanel-Bzyhr2aC.js → TerminalPanel-Bjbu9ktV.js} +1 -1
  19. package/dist/assets/{chat-store-CIMOL6-x.js → chat-store-7ekEnPAf.js} +1 -1
  20. package/dist/assets/{i18n-CNo6A2vu.js → i18n-BCQuDmQo.js} +2 -2
  21. package/dist/assets/index-Cb-hw9qG.js +147 -0
  22. package/dist/assets/index-ZtF5f7wy.css +1 -0
  23. package/dist/assets/{session-store-DN1UYDL9.js → session-store-KCJiKVqL.js} +1 -1
  24. package/dist/assets/settings-wb322bGN.js +1 -0
  25. package/dist/assets/{ui-store-BdOsq6T-.js → ui-store-CcznRsiV.js} +1 -1
  26. package/dist/assets/utils-C3qJEm2b.js +1 -0
  27. package/dist/assets/{vendor-Ch4m_qLI.js → vendor-Cm3Womkr.js} +25 -25
  28. package/dist/assets/{ws-client-BAV7SLzK.js → ws-client-9j1mjm9I.js} +1 -1
  29. package/dist/assets/{xyflow-D5_yey7w.js → xyflow-Dy5Edi88.js} +3 -3
  30. package/dist/index.html +10 -10
  31. package/dist/index.js +4040 -3685
  32. package/dist/index.js.map +1 -1
  33. package/dist/server/entry.js +42 -5
  34. package/dist/server/entry.js.map +1 -1
  35. package/dist/server/index.js +42 -5
  36. package/dist/server/index.js.map +1 -1
  37. package/dist/types.d.ts +28 -0
  38. package/package.json +6 -6
  39. package/dist/assets/OfficeMapPanel-CgvHvGQm.js +0 -4
  40. package/dist/assets/SddBoardView-C8X4MiTy.js +0 -2
  41. package/dist/assets/SddWizard-t5Cly3CG.js +0 -1
  42. package/dist/assets/SkillDetailView-Dq-fTqSp.js +0 -2
  43. package/dist/assets/index-CWj2bI87.js +0 -145
  44. package/dist/assets/index-D7_FeyCA.css +0 -1
  45. package/dist/assets/settings-CGhOOFpI.js +0 -1
  46. package/dist/assets/utils-DBns3uMk.js +0 -1
package/dist/types.d.ts CHANGED
@@ -390,8 +390,12 @@ interface WSToolsList {
390
390
  payload: {
391
391
  tools: Array<{
392
392
  name: string;
393
+ owner: string;
393
394
  description: string;
394
395
  params: string[];
396
+ disabled: boolean;
397
+ mutating: boolean;
398
+ permission: string;
395
399
  }>;
396
400
  };
397
401
  }
@@ -1803,6 +1807,18 @@ type WSClientMessage = WSUserMessage | WSToolConfirmResult | {
1803
1807
  payload: {
1804
1808
  id: string;
1805
1809
  };
1810
+ } | {
1811
+ type: 'tools.list';
1812
+ } | {
1813
+ type: 'tool.enable';
1814
+ payload: {
1815
+ name: string;
1816
+ };
1817
+ } | {
1818
+ type: 'tool.disable';
1819
+ payload: {
1820
+ name: string;
1821
+ };
1806
1822
  } | {
1807
1823
  type: `kanban.${string}`;
1808
1824
  payload?: Record<string, unknown> | undefined;
@@ -2197,6 +2213,18 @@ type WSServerMessage = WSSessionStart | WSSessionEnd | WSTextDelta | WSThinkingD
2197
2213
  subagentId: string;
2198
2214
  error: string;
2199
2215
  };
2216
+ } | {
2217
+ type: 'tool.disabled';
2218
+ payload: {
2219
+ name: string;
2220
+ ok: boolean;
2221
+ };
2222
+ } | {
2223
+ type: 'tool.enabled';
2224
+ payload: {
2225
+ name: string;
2226
+ ok: boolean;
2227
+ };
2200
2228
  } | {
2201
2229
  type: 'mcp.list';
2202
2230
  payload: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/webui",
3
- "version": "0.282.1",
3
+ "version": "0.282.2",
4
4
  "license": "MIT",
5
5
  "description": "Browser-based WebUI for WrongStack — React + Vite frontend with WebSocket backend that drives the same agent kernel as the CLI/TUI.",
6
6
  "keywords": [
@@ -84,11 +84,11 @@
84
84
  "virtua": "^0.49.1",
85
85
  "ws": "^8.21.0",
86
86
  "zustand": "^5.0.14",
87
- "@wrongstack/mcp": "0.282.1",
88
- "@wrongstack/runtime": "0.282.1",
89
- "@wrongstack/core": "0.282.1",
90
- "@wrongstack/providers": "0.282.1",
91
- "@wrongstack/tools": "0.282.1"
87
+ "@wrongstack/core": "0.282.2",
88
+ "@wrongstack/providers": "0.282.2",
89
+ "@wrongstack/mcp": "0.282.2",
90
+ "@wrongstack/runtime": "0.282.2",
91
+ "@wrongstack/tools": "0.282.2"
92
92
  },
93
93
  "peerDependencies": {
94
94
  "node-pty": "^1.1.0"
@@ -1,4 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{c as t,m as n,p as r,s as i}from"./markdown-D0X23O-i.js";import{$ as a,$n as o,Ar as s,En as c,Mr as l,Nt as u,T as d,X as f,br as p,ci as m,cn as h,di as g,et as _,it as v,jt as y,ni as b,pt as x,rr as S,rt as C,sn as w,sr as T,tn as E,vr as ee,wn as D,yn as te}from"./vendor-Ch4m_qLI.js";import"./i18n-CNo6A2vu.js";import{s as ne}from"./ws-client-BAV7SLzK.js";import{t as re}from"./session-store-DN1UYDL9.js";import{t as O}from"./utils-DBns3uMk.js";import{A as k,F as A,M as j,P as M,S as ie,c as ae,d as N,f as P,j as oe,l as se,u as F}from"./index-CWj2bI87.js";import{a as ce,c as I,d as le,f as ue,h as L,i as de,l as fe,m as R,n as pe,o as me,p as he,r as ge,s as _e,t as ve,u as ye}from"./xyflow-D5_yey7w.js";var z=e(n(),1),B=r();function V(e){if(e<1e3)return`${e}ms`;let t=Math.round(e/100);return t<600?`${(t/10).toFixed(1)}s`:`${Math.floor(t/600)}m ${Math.round(t%600/10)}s`}var be={user:{Icon:v,labelKey:`activity:message.roleYou`,avatarBg:`bg-primary`,avatarColor:`text-primary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-primary/20`,bubbleBg:`bg-primary`,bubbleBorder:`border-transparent`,textColor:`text-primary-foreground`},assistant:{Icon:p,labelKey:`activity:message.roleAssistant`,avatarBg:`bg-accent`,avatarColor:`text-accent-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-accent/20`,bubbleBg:`bg-card`,bubbleBorder:`border-border`,textColor:`text-foreground`},tool:{Icon:x,labelKey:`activity:message.roleTool`,avatarBg:`bg-secondary`,avatarColor:`text-secondary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-secondary/20`,bubbleBg:`bg-muted/80`,bubbleBorder:`border-border`,textColor:`text-foreground`},system:{Icon:p,labelKey:`activity:transcript.kindSystem`,avatarBg:`bg-muted`,avatarColor:`text-muted-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-muted/20`,bubbleBg:`bg-muted/50`,bubbleBorder:`border-border`,textColor:`text-muted-foreground`},error:{Icon:b,labelKey:`activity:transcript.kindError`,avatarBg:`bg-destructive`,avatarColor:`text-destructive-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-destructive/20`,bubbleBg:`bg-destructive/5`,bubbleBorder:`border-destructive/20`,textColor:`text-destructive`}};function H({entry:e}){let{t:n}=m();return e.role===`error`?(0,B.jsx)(se,{text:e.text}):e.role===`tool`?(0,B.jsxs)(`div`,{className:`flex flex-col gap-1.5 tool-details`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,B.jsx)(x,{className:`h-3 w-3`}),(0,B.jsx)(`span`,{className:`font-mono`,children:e.tool??n(`activity:watch.toolFallback`)}),e.durationMs!==void 0&&(0,B.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground font-normal tabular-nums`,children:[(0,B.jsx)(T,{className:`h-3 w-3 inline mr-0.5 align-text-bottom`}),V(e.durationMs)]})]}),e.input!==void 0&&e.input!==null&&(0,B.jsx)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:(0,B.jsx)(ae,{input:e.input})}),e.output!==void 0&&e.output!==null?(0,B.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:typeof e.output==`string`?(0,B.jsx)(t,{remarkPlugins:[i],rehypePlugins:P,components:N,children:e.output}):(0,B.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs bg-card rounded-lg p-2 border border-border overflow-x-auto`,children:JSON.stringify(e.output,null,2)})}):e.text?(0,B.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,B.jsx)(t,{remarkPlugins:[i],rehypePlugins:P,components:N,children:e.text})}):null,e.isError&&(0,B.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:n(`activity:watch.toolFailed`)}),e.text&&(0,B.jsx)(`pre`,{className:`mt-1 text-xs whitespace-pre-wrap text-destructive/80`,children:e.text})]})]}):(0,B.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,B.jsx)(t,{remarkPlugins:[i],rehypePlugins:P,components:N,children:e.text})})}function xe({entry:e,isContinuation:t=!1}){let{t:n}=m(),r=be[e.role],i=r.Icon;return(0,B.jsxs)(`div`,{className:`group flex gap-3 animate-message msg-bubble rounded-lg transition-shadow`,children:[t?(0,B.jsx)(`div`,{className:`flex-shrink-0 w-8`}):(0,B.jsx)(`div`,{className:O(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,r.avatarBg,r.avatarColor,r.avatarRing),children:(0,B.jsx)(i,{className:`h-4 w-4`})}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0 flex-1`,children:[!t&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:O(`text-xs font-medium`,r.textColor),children:e.role===`tool`&&e.tool?e.tool:n(r.labelKey)}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),e.role===`tool`&&e.durationMs!==void 0&&(0,B.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`· `,V(e.durationMs)]})]}),(0,B.jsx)(`div`,{className:O(`rounded-2xl px-4 py-3 border`,e.role===`user`&&`rounded-br-md`,e.role===`assistant`&&`rounded-bl-md`,e.role===`tool`&&`rounded-bl-sm`,e.role===`system`&&`rounded-bl-sm opacity-70`,e.role===`error`&&`rounded-bl-sm`,r.bubbleBg,r.bubbleBorder),children:(0,B.jsx)(`div`,{className:O(`text-sm leading-relaxed markdown-content`,r.textColor),children:(0,B.jsx)(H,{entry:e})})}),e.text&&e.role!==`error`&&(0,B.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,B.jsx)(F,{text:e.text,label:n(`common:action.copy`)})})]})]})}var Se=[`steer`,`ask`,`assign`,`note`],U=2500;function Ce({sessionId:e,limit:t=200}){let[n,r]=(0,z.useState)(null),{t:i}=m(),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(null),[h,_]=(0,z.useState)(`steer`),[v,y]=(0,z.useState)(`high`),[b,x]=(0,z.useState)([]),[S,C]=(0,z.useState)(!1),w=(0,z.useRef)(null),T=(0,z.useRef)(!0),E=(0,z.useRef)(!0),ee=oe(e=>e.liveSessions),D=(0,z.useMemo)(()=>ee.find(t=>t.sessionId===e),[ee,e]),te=(0,z.useMemo)(()=>{let e=D;return e?`${e.status}|${e.agents.map(e=>`${e.id}:${e.status}:${e.toolCalls??0}:${e.iterations??0}`).join(`,`)}`:``},[D]),ne=D?.status===`active`||(D?.agents.some(e=>e.status===`running`||e.status===`streaming`)??!1),re=(0,z.useMemo)(()=>{if(!D)return null;let e=D.agents.find(e=>e.status===`running`||e.status===`streaming`);return e?.currentTool?`🔧 ${e.currentTool}`:e?i(`activity:sessionWatch.working`,{name:e.name??e.id}):null},[D,i]),k=(0,z.useMemo)(()=>{if(!D)return null;let e=D.agents.find(e=>e.partialText&&(e.status===`streaming`||e.status===`running`))??D.agents.find(e=>e.partialText);return e?.partialText?{label:e.id===`leader`?i(`activity:sessionWatch.claude`):e.name||e.id,text:e.partialText}:null},[D,i]),A=(0,z.useCallback)(async()=>{try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/events?limit=${t}`);if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();E.current&&(r(i),o(null))}catch(e){E.current&&o(e instanceof Error?e.message:String(e))}},[e,t]),j=(0,z.useCallback)(async()=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/mailbox`);if(!t.ok)return;let n=await t.json();E.current&&Array.isArray(n.thread)&&x(n.thread)}catch{}},[e]);(0,z.useEffect)(()=>{E.current=!0,r(null),o(null),x([]),A(),j();let e=setInterval(()=>void A(),U),t=setInterval(()=>void j(),U);return()=>{E.current=!1,clearInterval(e),clearInterval(t)}},[A,j]),(0,z.useEffect)(()=>{te&&A()},[te,A]),(0,z.useEffect)(()=>{T.current&&w.current&&(w.current.scrollTop=w.current.scrollHeight)},[n,k]);let M=()=>{let e=w.current;e&&(T.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},ie=async()=>{let t=s.trim();if(!(!t||l)){u(!0),f(null);try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t,type:h,priority:v})});if(!n.ok)throw Error(`HTTP ${n.status}`);c(``),f(ne?g.t(`activity:sessionWatch.sentRunning`):g.t(`activity:sessionWatch.sentIdle`)),j()}catch(e){f(g.t(`activity:sessionWatch.sentFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(!1)}}},ae=async()=>{if(!S){C(!0),f(null);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({reason:g.t(`activity:sessionWatch.interruptReason`)})});if(!t.ok)throw Error(`HTTP ${t.status}`);f(g.t(`activity:sessionWatch.interruptSent`)),j()}catch(e){f(g.t(`activity:sessionWatch.interruptFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{C(!1)}}},N=n?.entries??[];return(0,B.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 shrink-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:O(`h-1.5 w-1.5 rounded-full`,ne?`bg-green-500 animate-pulse`:`bg-muted-foreground`)}),i(`activity:sessionWatch.liveStream`)]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,B.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[i(`activity:sessionWatch.events`,{count:n.total}),` · `,n.status]}),ne&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>void ae(),disabled:S,title:i(`activity:sessionWatch.interruptTitle`),className:`rounded border border-destructive/40 bg-destructive/15 px-1.5 py-0.5 text-[10px] text-destructive hover:bg-destructive/25 disabled:opacity-40 transition-colors`,children:i(S?`activity:sessionWatch.interrupting`:`activity:sessionWatch.interrupt`)})]})]}),re&&(0,B.jsxs)(`div`,{className:`mb-1.5 shrink-0 text-[10px] text-foreground truncate`,children:[`▶ `,re]}),a&&(0,B.jsxs)(`div`,{className:`text-[11px] text-destructive mb-1 shrink-0`,children:[`· `,a]}),(0,B.jsxs)(`div`,{ref:w,onScroll:M,className:`min-h-0 min-w-0 flex-1 overflow-y-auto space-y-1.5 pr-1`,children:[N.length===0&&!a&&(0,B.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:i(`activity:sessionWatch.loading`)}),N.map((e,t)=>(0,B.jsx)(xe,{entry:e,isContinuation:t>0&&N[t-1].role===e.role},`${e.ts}-${t}`)),k&&(0,B.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,B.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-accent text-accent-foreground ring-2 ring-offset-2 ring-offset-background ring-accent/20`,children:(0,B.jsx)(p,{className:`h-4 w-4 animate-pulse`})}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground px-1`,children:k.label}),(0,B.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-4 py-3 bg-card border border-border`,children:(0,B.jsxs)(`span`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:[k.text,(0,B.jsx)(`span`,{className:`animate-pulse text-primary`,children:`▋`})]})})]})]})]}),b.length>0&&(0,B.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0 max-h-28 overflow-y-auto space-y-1`,children:[(0,B.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:i(`activity:mailbox.messages`)}),b.slice(-6).map(e=>{let t=e.completed?i(`activity:sessionWatch.done`):e.readByLeader?i(`activity:sessionWatch.read`):i(`activity:sessionWatch.delivered`);return(0,B.jsxs)(`div`,{className:`text-[10px] leading-snug`,children:[(0,B.jsx)(`span`,{className:O(`font-semibold mr-1.5`,e.fromLeader?`text-accent`:`text-primary`),children:e.fromLeader?i(`activity:sessionWatch.agent`):i(`activity:sessionWatch.you`)}),(0,B.jsx)(`span`,{className:`text-foreground whitespace-pre-wrap break-words`,children:e.body}),!e.fromLeader&&(0,B.jsx)(`span`,{className:O(`ml-1.5 text-[9px]`,e.completed?`text-green-500`:e.readByLeader?`text-cyan-500`:`text-muted-foreground`),children:t})]},e.id)})]}),(0,B.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,B.jsx)(`select`,{value:h,onChange:e=>_(e.target.value),title:i(`activity:sessionWatch.msgType.${h}Hint`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:Se.map(e=>(0,B.jsx)(`option`,{value:e,children:i(`activity:sessionWatch.msgType.${e}Label`)},e))}),(0,B.jsxs)(`select`,{value:v,onChange:e=>y(e.target.value),title:i(`activity:sessionWatch.priority`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:[(0,B.jsx)(`option`,{value:`high`,children:`high`}),(0,B.jsx)(`option`,{value:`normal`,children:`normal`}),(0,B.jsx)(`option`,{value:`low`,children:`low`})]})]}),(0,B.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,B.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),ie())},rows:2,placeholder:i(`activity:sessionWatch.placeholder`,{label:i(`activity:sessionWatch.msgType.${h}Label`)}),className:`flex-1 resize-none rounded-md bg-muted border border-border px-2 py-1 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void ie(),disabled:l||!s.trim(),className:`shrink-0 rounded-md bg-primary text-primary-foreground px-2.5 py-1.5 text-xs hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:l?`…`:i(`activity:sessionWatch.send`)})]}),d&&(0,B.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:d}),(0,B.jsx)(`div`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:i(`activity:sessionWatch.sendHint`)})]})]})}function W(e){return e==null||!Number.isFinite(e)?`0`:e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`}function we(e,t){if(!e)return`never`;let n=Date.parse(e);if(!Number.isFinite(n))return`never`;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s ago`:r<3600?`${Math.round(r/60)}m ago`:r<86400?`${Math.round(r/3600)}h ago`:`${Math.round(r/86400)}d ago`}function Te(e,t){if(!e)return``;let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s`:r<3600?`${Math.round(r/60)}m`:`${Math.round(r/3600)}h`}function Ee(e){if(!e)return;let t=e.split(`/`);return t[t.length-1]?.slice(0,18)}function De(e,t=380){let n=new Map,r=Math.max(1,e.length);return e.forEach((e,i)=>{let a=(i-(r-1)/2)*t;n.set(e,600+a)}),n}function Oe(e,t,n){let r=Math.min(3,n),i=Math.floor(t/r),a=t%r;return{x:e-(Math.min(r,n-i*r)-1)*190/2+a*190,y:640+i*150}}function ke(e){return e===`tui`?`tui`:e===`repl`||e===`cli`?`repl`:`webui`}function Ae(e){return e===`tui`?`TUI`:e===`repl`?`REPL`:`WebUI`}function G(e){switch(e){case`running`:case`active`:return`active`;case`idle`:return`idle`;case`completed`:return`completed`;case`failed`:case`error`:return`error`;case`stopped`:return`offline`;default:return`idle`}}function je(e,t){let n=new Set,r=[];for(let i of e){let e=ke(i.clientType),a=`client-${i.pid??i.sessionId}`,o=[],s=!1;for(let e of i.agents){n.add(e.id);let r=t.get(e.id),i=G(r?.status??e.status);(i===`active`||i===`streaming`)&&(s=!0),o.push({officeId:`${a}__agent-${e.id}`,serverId:e.id,name:r?.name??e.name??e.id,status:i,iteration:r?.iteration??e.iterations??0,toolCalls:r?.toolCalls??e.toolCalls??0,costUsd:r?.costUsd??e.costUsd??0,tokensIn:r?.tokensIn??e.tokensIn??0,tokensOut:r?.tokensOut??e.tokensOut??0,ctxPct:r?.ctxPct??e.ctxPct,model:r?.model??e.model,lastActivityAt:e.lastActivityAt,currentTask:r?.currentTool??r?.lastTool??e.currentTool})}let c=i.status===`closing`||i.status===`stale`?`offline`:s?`active`:`idle`;r.push({id:a,type:e,label:i.projectName||Ae(e),sublabel:[Ae(e),i.gitBranch?`⎇ ${i.gitBranch}`:``,i.pid?`pid ${i.pid}`:``].filter(Boolean).join(` · `),status:c,sessionId:i.sessionId,pid:i.pid,branch:i.gitBranch,workingDir:i.workingDir,startedAt:i.startedAt,agents:o})}let i=[...t.values()].filter(e=>!n.has(e.id));if(i.length>0){let e=r.find(e=>e.type===`webui`);e||(e={id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI`,status:`idle`,agents:[]},r.push(e));for(let t of i){let n=G(t.status);(n===`active`||n===`streaming`)&&(e.status=`active`),e.agents.push({officeId:`${e.id}__agent-${t.id}`,serverId:t.id,name:t.name,status:n,iteration:t.iteration??0,toolCalls:t.toolCalls??0,costUsd:t.costUsd??0,tokensIn:t.tokensIn??0,tokensOut:t.tokensOut??0,ctxPct:t.ctxPct,model:t.model,currentTask:t.currentTool??t.lastTool})}}return r.length===0&&r.push({id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI · connecting…`,status:`idle`,agents:[]}),r}function K(e){return e.startsWith(`tool`)?`#eab308`:e.startsWith(`mailbox`)?`#06b6d4`:e.startsWith(`provider`)?`#a855f7`:e.startsWith(`agent`)||e.startsWith(`subagent`)?`#22c55e`:e.includes(`error`)?`#ef4444`:`#6366f1`}function Me(e){return Math.min(100,Math.max(0,e??0))}function q({status:e,small:t,activity:n=0}){let r=t?`w-2 h-2`:`w-3 h-3`,i=t?4+n*4:6+n*6;return(0,B.jsx)(`span`,{className:O(`rounded-full`,r,n>0&&`animate-pulse`,{idle:`bg-gray-500`,active:`bg-emerald-500`,streaming:`bg-blue-500`,completed:`bg-blue-500`,error:`bg-red-500`,offline:`bg-gray-600`}[e]),style:{boxShadow:n>0?`0 0 ${i}px ${{idle:`#9ca3af`,active:`#22c55e`,streaming:`#3b82f6`,completed:`#3b82f6`,error:`#ef4444`,offline:`#6b7280`}[e]}`:void 0}})}function Ne(){let{t:e}=m(),{clientCounts:t,currentSession:n,totalAgents:r,activeAgents:i,aggregate:a}=oe(d(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents,aggregate:e.aggregate}))),s=t.tui+t.webui+t.repl,u=e=>e?.toLocaleString()??`0`;return(0,B.jsxs)(`div`,{className:`absolute top-20 left-4 z-10 bg-slate-800/95 backdrop-blur border border-slate-700 rounded-lg p-3 shadow-xl`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,B.jsx)(l,{className:`h-3.5 w-3.5 text-emerald-400`}),(0,B.jsx)(`span`,{className:`text-[10px] font-bold text-gray-300 uppercase tracking-wide`,children:e(`activity:office.sessionStats`)})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5 text-[10px]`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(C,{className:`h-3 w-3 text-gray-500`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.clients`)})]}),(0,B.jsxs)(`span`,{className:`text-gray-200 font-mono`,children:[i,` `,(0,B.jsx)(`span`,{className:`text-gray-500`,children:`/`}),` `,(0,B.jsx)(`span`,{className:`text-emerald-400`,children:s})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 pl-4 text-[9px]`,children:[t.tui>0&&(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(x,{className:`h-2.5 w-2.5 text-emerald-500`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:`TUI`}),(0,B.jsx)(`span`,{className:`text-emerald-400 font-mono`,children:t.tui})]}),t.webui>0&&(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(E,{className:`h-2.5 w-2.5 text-blue-500`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:`WebUI`}),(0,B.jsx)(`span`,{className:`text-blue-400 font-mono`,children:t.webui})]}),t.repl>0&&(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(x,{className:`h-2.5 w-2.5 text-amber-500`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:`REPL`}),(0,B.jsx)(`span`,{className:`text-amber-400 font-mono`,children:t.repl})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(p,{className:`h-3 w-3 text-gray-500`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:officeMap.agents`)})]}),(0,B.jsxs)(`span`,{className:`text-gray-200 font-mono`,children:[i,` `,(0,B.jsx)(`span`,{className:`text-gray-500`,children:`/`}),` `,(0,B.jsx)(`span`,{className:`text-cyan-400`,children:r})]})]}),n.model&&(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(S,{className:`h-3 w-3 text-gray-500`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:officeMap.model`)})]}),(0,B.jsx)(`span`,{className:`text-cyan-400 font-mono truncate max-w-[120px]`,title:n.model,children:n.model.split(`/`).pop()?.slice(0,16)})]}),n.mode&&(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(f,{className:`h-3 w-3 text-gray-500`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:officeMap.mode`)})]}),(0,B.jsx)(`span`,{className:O(`font-mono uppercase text-[9px] px-1.5 py-0.5 rounded`,n.mode===`auto`&&`bg-purple-500/20 text-purple-400`,n.mode===`suggest`&&`bg-blue-500/20 text-blue-400`,n.mode===`off`&&`bg-gray-500/20 text-gray-400`,![`auto`,`suggest`,`off`].includes(n.mode||``)&&`bg-gray-500/20 text-gray-400`),children:n.mode})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(c,{className:`h-3 w-3 text-gray-500`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.toolCallsLabel`)})]}),(0,B.jsx)(`span`,{className:`text-yellow-400 font-mono`,children:u(a.toolCalls)})]}),(0,B.jsxs)(`div`,{className:`border-t border-slate-700 pt-1.5 mt-1.5 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`text-gray-500 text-[8px]`,children:`IN`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.input`)})]}),(0,B.jsx)(`span`,{className:`text-gray-300 font-mono text-[9px]`,children:u(a.tokensIn)})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`text-gray-500 text-[8px]`,children:`OUT`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.output`)})]}),(0,B.jsx)(`span`,{className:`text-gray-300 font-mono text-[9px]`,children:u(a.tokensOut)})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border-t border-slate-700 pt-1.5 mt-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(o,{className:`h-3 w-3 text-gray-500`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.cost`)})]}),(0,B.jsx)(`span`,{className:`text-emerald-400 font-mono font-medium`,children:(e=>e==null?`$0.0000`:`$${e.toFixed(4)}`)(a.costUsd)})]})]})]})}function J(){let e={opacity:0,width:1,height:1,minWidth:0,border:`none`,background:`transparent`};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ce,{type:`target`,position:R.Top,style:e,isConnectable:!1}),(0,B.jsx)(ce,{type:`source`,position:R.Bottom,style:e,isConnectable:!1})]})}function Y({data:e}){let{t}=m();return(0,B.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-white/5 pt-1.5 text-[8px] text-gray-500`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`font-mono text-gray-300`,children:e.agentCount??0}),` `,t(`activity:office.agentsSuffix`)]}),e.startedAt&&(0,B.jsx)(`span`,{children:t(`activity:office.upPrefix`,{time:Te(e.startedAt,Date.now())})})]})}function Pe({data:e}){let{t}=m(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`offline`,o=e.color||`#3b82f6`;return(0,B.jsxs)(`div`,{className:O(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-blue-500/20`,r&&`border-red-500/50 bg-red-500/10`,i&&`border-gray-500/30 bg-gray-500/5 opacity-60`,!n&&!r&&!i&&`border-blue-500/30 bg-blue-500/10`),children:[(0,B.jsx)(J,{}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,B.jsx)(`div`,{className:O(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-blue-500/20`:`bg-blue-500/10`),children:(0,B.jsx)(E,{className:`h-5 w-5`,style:{color:o}})}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:o},children:e.label}),(0,B.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:t(`activity:office.webuiClient`)})]}),(0,B.jsx)(q,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,B.jsx)(`div`,{className:`text-[10px] text-gray-400 mb-2 truncate`,children:e.sublabel}),(0,B.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] text-gray-500`,children:i?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(_,{className:`h-3 w-3 text-gray-500`}),(0,B.jsx)(`span`,{children:t(`activity:office.disconnected`)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(a,{className:`h-3 w-3 text-emerald-500`}),(0,B.jsx)(`span`,{children:t(`activity:office.connected`)})]})}),n&&(0,B.jsx)(`div`,{className:`mt-2 h-1 rounded-full bg-blue-500/30 overflow-hidden`,children:(0,B.jsx)(`div`,{className:`h-full bg-blue-500 animate-pulse`,style:{width:`60%`}})}),(0,B.jsx)(Y,{data:e})]})}function X({data:e}){let{t}=m(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.color||`#22c55e`;return(0,B.jsxs)(`div`,{className:O(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-emerald-500/20`,r&&`border-red-500/50 bg-red-500/10`,!n&&!r&&`border-emerald-500/30 bg-emerald-500/10`),children:[(0,B.jsx)(J,{}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,B.jsx)(`div`,{className:O(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-emerald-500/20`:`bg-emerald-500/10`),children:(0,B.jsx)(x,{className:`h-5 w-5`,style:{color:i}})}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:i},children:e.label}),(0,B.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:t(`activity:office.tuiClient`)})]}),(0,B.jsx)(q,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,B.jsx)(`div`,{className:`text-[10px] text-gray-400 mb-2 truncate`,children:e.sublabel}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-gray-500`,children:[(0,B.jsx)(x,{className:`h-3 w-3 text-emerald-500`}),(0,B.jsx)(`span`,{children:t(`activity:office.terminal`)})]}),(0,B.jsx)(Y,{data:e})]})}function Fe({data:e}){let{t}=m(),n=e.status===`active`||e.status===`streaming`,r=e.color||`#f59e0b`;return(0,B.jsxs)(`div`,{className:O(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-amber-500/20`,!n&&`border-amber-500/30 bg-amber-500/10`),children:[(0,B.jsx)(J,{}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,B.jsx)(`div`,{className:O(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-amber-500/20`:`bg-amber-500/10`),children:(0,B.jsx)(x,{className:`h-5 w-5`,style:{color:r}})}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:r},children:e.label}),(0,B.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:t(`activity:office.repl`)})]}),(0,B.jsx)(q,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,B.jsx)(`div`,{className:`text-[10px] text-gray-400 mb-1 truncate`,children:e.sublabel}),(0,B.jsx)(Y,{data:e})]})}function Ie({data:e}){let{t}=m(),n=e.status===`active`||e.status===`streaming`,r=e.color||`#a855f7`;return(0,B.jsxs)(`div`,{className:`rounded-xl border-2 p-4 min-w-[200px] transition-all backdrop-blur-sm relative bg-slate-900/90`,children:[(0,B.jsx)(J,{}),(0,B.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-purple-600 text-white text-[9px] rounded-full font-bold`,children:t(`activity:office.coordinator`)}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,B.jsx)(`div`,{className:O(`flex items-center justify-center w-12 h-12 rounded-xl`,n?`bg-purple-500/20`:`bg-purple-500/10`),children:(0,B.jsx)(S,{className:`h-6 w-6`,style:{color:r}})}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-sm font-bold truncate`,style:{color:r},children:e.label}),(0,B.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:e.sublabel||t(`activity:office.fleetSummary`)})]}),(0,B.jsx)(q,{status:e.status,activity:e.vizActivity??0})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px] mb-2`,children:[(0,B.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,B.jsxs)(`div`,{className:`font-mono`,children:[(0,B.jsx)(`span`,{className:`text-emerald-400`,children:e.agentsActive||0}),(0,B.jsx)(`span`,{className:`text-gray-500`,children:` / `}),(0,B.jsx)(`span`,{className:`text-purple-400`,children:e.agentsTotal||0})]}),(0,B.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:officeMap.agents`)})]}),(0,B.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,B.jsx)(`div`,{className:`font-mono text-yellow-400`,children:(e.toolCalls||0).toLocaleString()}),(0,B.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.toolCallsLabel`)})]}),(0,B.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,B.jsx)(`div`,{className:`font-mono text-gray-300`,children:W(e.tokensIn)}),(0,B.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.tokensLabel`)})]}),(0,B.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-emerald-400`,children:[`$`,(e.costUsd||0).toFixed(3)]}),(0,B.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.cost`)})]})]}),n&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-purple-400`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-purple-400 animate-pulse`}),t(`activity:office.coordinatingFleet`)]})]})}function Le({data:e}){let{t}=m(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`completed`,a=e.color||`#06b6d4`,o=Me(e.ctxPct);return(0,B.jsxs)(`div`,{className:O(`rounded-lg border p-3 min-w-[150px] transition-all backdrop-blur-sm`,n&&`border-cyan-500/50 bg-cyan-500/10 shadow-lg shadow-cyan-500/10`,r&&`border-red-500/50 bg-red-500/10`,i&&`border-gray-500/30 bg-gray-500/5`,!n&&!r&&!i&&`border-cyan-500/30 bg-cyan-500/10`),children:[(0,B.jsx)(J,{}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,B.jsx)(p,{className:`h-4 w-4 shrink-0`,style:{color:a}}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-[11px] font-bold truncate`,style:{color:a},children:e.label}),e.model&&(0,B.jsx)(`div`,{className:`text-[8px] text-gray-500 truncate`,children:Ee(e.model)})]}),(0,B.jsx)(q,{status:e.status,small:!0,activity:e.vizActivity??0})]}),e.currentTask&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-cyan-300/90 truncate mb-1.5`,children:[(0,B.jsx)(`span`,{className:O(`w-1.5 h-1.5 rounded-full bg-cyan-400 shrink-0`,n&&`animate-pulse`)}),(0,B.jsx)(`span`,{className:`truncate font-mono`,children:e.currentTask})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-0.5 text-[9px] mb-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between`,children:[(0,B.jsx)(`span`,{className:`text-gray-500`,children:`iter`}),(0,B.jsx)(`span`,{className:`text-gray-300 font-mono`,children:e.iteration||0})]}),(0,B.jsxs)(`div`,{className:`flex justify-between`,children:[(0,B.jsx)(`span`,{className:`text-gray-500`,children:`tools`}),(0,B.jsx)(`span`,{className:`text-yellow-400/90 font-mono`,children:e.toolCalls||0})]}),(0,B.jsxs)(`div`,{className:`flex justify-between`,children:[(0,B.jsx)(`span`,{className:`text-gray-500`,children:`tok`}),(0,B.jsx)(`span`,{className:`text-gray-300 font-mono`,children:W((e.tokensIn||0)+(e.tokensOut||0))})]}),(0,B.jsxs)(`div`,{className:`flex justify-between`,children:[(0,B.jsx)(`span`,{className:`text-gray-500`,children:`cost`}),(0,B.jsxs)(`span`,{className:`text-emerald-400/90 font-mono`,children:[`$`,(e.costUsd||0).toFixed(3)]})]})]}),o>0&&(0,B.jsxs)(`div`,{className:`mb-1`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-[8px] text-gray-500 mb-0.5`,children:[(0,B.jsx)(`span`,{children:`ctx`}),(0,B.jsxs)(`span`,{className:O(`font-mono`,o>=90?`text-red-400`:o>=70?`text-amber-400`:`text-gray-400`),children:[o,`%`]})]}),(0,B.jsx)(`div`,{className:`h-1 rounded-full bg-slate-700/60 overflow-hidden`,children:(0,B.jsx)(`div`,{className:O(`h-full`,o>=90?`bg-red-500`:o>=70?`bg-amber-500`:`bg-cyan-500`),style:{width:`${o}%`}})})]}),e.lastActivityAt&&(0,B.jsxs)(`div`,{className:O(`flex items-center gap-1 text-[8px]`,n?`text-gray-600`:`text-gray-500`),children:[i&&(0,B.jsx)(`span`,{className:`text-emerald-500/70`,children:t(`activity:office.donePrefix`)}),r&&(0,B.jsx)(`span`,{className:`text-red-400/80`,children:t(`activity:office.failedPrefix`)}),(0,B.jsx)(`span`,{children:t(`activity:office.seenPrefix`,{time:we(e.lastActivityAt,Date.now())})})]})]})}function Z({data:e}){let{t}=m();return(0,B.jsxs)(`div`,{className:O(`rounded-lg border border-dashed p-3 min-w-[120px] transition-all opacity-40`,`border-gray-600 bg-gray-800/30`),children:[(0,B.jsx)(J,{}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,B.jsx)(s,{className:`h-4 w-4 text-gray-600`}),(0,B.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,B.jsx)(`div`,{className:`text-[10px] text-gray-500 truncate`,children:e.label})}),(0,B.jsx)(q,{status:e.status,small:!0,activity:e.vizActivity??0})]}),(0,B.jsx)(`div`,{className:`text-[9px] text-gray-600`,children:t(`activity:office.availableDesk`)})]})}function Q({data:e}){let{t}=m(),n=e.color||`#eab308`,r=(e.unreadCount||0)>0;return(0,B.jsxs)(`div`,{className:O(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,r&&`border-yellow-500/50 bg-yellow-500/10 shadow-lg shadow-yellow-500/10`,!r&&`border-yellow-500/30 bg-yellow-500/5`),children:[(0,B.jsx)(J,{}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,B.jsx)(`div`,{className:O(`flex items-center justify-center w-10 h-10 rounded-lg`,r?`bg-yellow-500/20`:`bg-yellow-500/10`),children:(0,B.jsx)(h,{className:`h-5 w-5`,style:{color:n}})}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-xs font-bold`,style:{color:n},children:t(`activity:office.mailboxHub`)}),(0,B.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:r?t(`activity:office.unreadSuffix`,{count:e.unreadCount||0}):t(`activity:office.allClear`)})]}),r&&(0,B.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-yellow-500 text-black text-[10px] font-bold flex items-center justify-center`,children:e.unreadCount})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[(0,B.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-yellow-400`,children:[(0,B.jsx)(y,{className:`h-3 w-3`}),(0,B.jsx)(`span`,{children:e.messageCount||0})]}),(0,B.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.total`)})]}),(0,B.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-emerald-400`,children:[(0,B.jsx)(D,{className:`h-3 w-3`}),(0,B.jsx)(`span`,{children:e.unreadCount||0})]}),(0,B.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.unreadLabel`)})]})]}),e.sublabel&&(0,B.jsxs)(`div`,{className:`mt-2 truncate border-t border-white/5 pt-1.5 text-[9px] text-gray-400`,children:[`✉ `,e.sublabel]})]})}var Re={webui:Pe,tui:X,repl:Fe,coordinator:Ie,agent:Le,mailbox:Q,desk:Z},ze={wire:({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i,targetPosition:a,data:o,selected:s})=>{let c=o?.color||`#6366f1`,l=k(e=>e.animateEdges),u=o?.animated&&l?Math.max(.15,o?.intensity??.6):0,[d,f,p]=L({sourceX:e,sourceY:t,sourcePosition:i??R.Bottom,targetX:n,targetY:r,targetPosition:a??R.Top,curvature:.28}),m=5+u*7,h=5+u*4,g=m+h,_=`${Math.max(.5,1.6-u).toFixed(2)}s`;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:s?2.5:1.4,strokeOpacity:s?.9:.28,className:`react-flow__edge-path`}),u>.05&&(0,B.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:2.2,strokeOpacity:.45+u*.5,strokeDasharray:`${m} ${h}`,strokeLinecap:`round`,style:{filter:`drop-shadow(0 0 ${2+u*4}px ${c})`},children:(0,B.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:g,to:`0`,dur:_,repeatCount:`indefinite`})}),o?.label&&u>.1&&(0,B.jsx)(de,{children:(0,B.jsx)(`div`,{style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${f}px, ${p}px)`},className:`pointer-events-none rounded-full border border-white/15 bg-slate-800/90 px-1.5 py-0.5 text-[8px] font-medium text-white/85 backdrop-blur-sm`,children:o.label})})]})}};function Be({events:e,now:t}){let{t:n}=m(),r=e.slice(0,14);return(0,B.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pointer-events-none px-3 pb-3`,children:(0,B.jsxs)(`div`,{className:`pointer-events-auto rounded-lg bg-slate-900/85 border border-slate-700/70 backdrop-blur px-3 py-2 max-w-3xl mx-auto`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5 text-[10px] uppercase tracking-wide text-cyan-400/80`,children:[(0,B.jsx)(l,{className:`h-3 w-3`}),n(`activity:office.liveActivity`)]}),r.length===0?(0,B.jsx)(`div`,{className:`text-[11px] text-gray-500 italic`,children:n(`activity:office.waitingActivity`)}):(0,B.jsx)(`div`,{className:`flex flex-col gap-0.5 max-h-32 overflow-hidden`,children:r.map(e=>{let r=Math.max(0,Math.round((t-e.timestamp)/1e3));return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] leading-tight`,children:[(0,B.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{backgroundColor:K(e.kind)}}),(0,B.jsx)(`span`,{className:`text-gray-300 truncate flex-1`,children:e.label}),(0,B.jsx)(`span`,{className:`text-gray-600 shrink-0 tabular-nums`,children:r<1?n(`activity:office.now`):`${r}s`})]},e.id)})})]})})}function $(){let{t:e}=m(),{fitView:t}=he(),n=ne(e=>e.events),r=A(e=>e.agents),i=A(e=>e.agentTranscripts),a=A(e=>e.leaderId),o=oe(e=>e.liveSessions),s=j(e=>e.messages),c=re(e=>e.session),l=(0,z.useMemo)(()=>je(o,r),[o,r]),d=k(e=>e.showHud),f=k(e=>e.showLegend),g=k(e=>e.showMinimap),_=k(e=>e.showControls),v=k(e=>e.showFeed),b=k(e=>e.setShowFeed),C=k(e=>e.background),[T,D,ae]=ue([]),[N,P,se]=le([]),[F,ce]=(0,z.useState)(null),[I,L]=(0,z.useState)(null),[de,R]=(0,z.useState)(!1),[V,be]=(0,z.useState)(``),[H,xe]=(0,z.useState)(!1),[Se,U]=(0,z.useState)(null),ke=(0,z.useMemo)(()=>{if(F?.data.kind!==`agent`)return M;let e=F.data.serverId??(F.id.includes(`__agent-`)?F.id.split(`__agent-`).pop():F.id.replace(/^agent-/,``));return e?i.get(e)??M:M},[i,F]),G=(0,z.useCallback)(async()=>{let e=V.trim();if(!(!e||H)){xe(!0),U(null);try{let t=await fetch(`/api/fleet/broadcast`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();be(``),U(`Delivered to ${n.delivered??0}/${n.targets??0} session(s)`)}catch(e){U(`Failed: ${e instanceof Error?e.message:String(e)}`)}finally{xe(!1)}}},[V,H]),K=(0,z.useRef)(new Map),q=4e3,J=(0,z.useRef)(new Map),Y=(0,z.useRef)(new Map),Pe=(0,z.useRef)(new Map),X=(0,z.useRef)(new Map),Fe=(0,z.useRef)(``);(0,z.useEffect)(()=>{let n=[],i=[],o=Date.now(),c=Math.max(1,...l.map(e=>e.agents.length||1)),u=Math.max(380,Math.min(3,c)*190+80),d=De(l.map(e=>e.id),u),f=s.filter(e=>!e.completed&&(e.readByCount??0)===0).length,p=s.length?[...s].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp))[0]:void 0;n.push({id:`mailbox`,type:`mailbox`,position:{x:830,y:50},data:{label:e(`activity:office.mailboxHub`),kind:`mailbox`,status:f>0?`active`:`idle`,unreadCount:f,messageCount:s.length,sublabel:p?`${p.from} → ${p.to}: ${p.subject}`:void 0,color:`#eab308`}});let m=0,h=0,g=0,_=0,v=0;for(let e of l)for(let t of e.agents)h+=1,(t.status===`active`||t.status===`streaming`)&&(m+=1),g+=t.toolCalls,_+=t.costUsd,v+=t.tokensIn+t.tokensOut;let y=a?r.get(a):null,b=m>0;n.push({id:`coordinator`,type:`coordinator`,position:{x:370,y:50},data:{label:e(`activity:office.fleetHqLabel`),sublabel:e(`activity:office.clientsSuffix`,{count:l.length}),kind:`coordinator`,status:y?.status===`failed`?`error`:b?`active`:`idle`,connections:l.length,agentsActive:m,agentsTotal:h,toolCalls:g,costUsd:_,tokensIn:v,color:`#a855f7`}});let x={tui:`#22c55e`,webui:`#3b82f6`,repl:`#f59e0b`};for(let t of l){let r=d.get(t.id)??600,a=x[t.type],s=t.status===`active`;if(n.push({id:t.id,type:t.type,position:{x:r,y:370},data:{label:t.label,sublabel:t.sublabel,kind:t.type,status:t.status,sessionId:t.sessionId,pid:t.pid,branch:t.branch,workingDir:t.workingDir,startedAt:t.startedAt,agentCount:t.agents.length,color:a}}),i.push({id:`${t.id}->coordinator`,source:t.id,target:`coordinator`,type:`wire`,animated:s,data:{color:a,animated:s,label:e(`activity:office.controlLabel`),flowType:`task`}}),i.push({id:`mailbox->${t.id}`,source:`mailbox`,target:t.id,type:`wire`,animated:f>0,data:{color:`#eab308`,animated:f>0,label:f>0?`${f}`:void 0,flowType:`mail`}}),t.agents.length===0){n.push({id:`desk-${t.id}`,type:`desk`,position:{x:r,y:640},data:{label:e(`activity:office.idleDesk`),kind:`agent`,status:`idle`,color:`#374151`}});continue}t.agents.forEach((a,s)=>{let c=a.status===`active`||a.status===`streaming`,l=X.current.get(a.serverId);if(l&&(a.toolCalls>l.toolCalls||a.iteration>l.iteration)||c){K.current.set(a.officeId,o+q);let e=Y.current.get(a.officeId)??0;Y.current.set(a.officeId,Math.min(1,e+(1-e)*.5));for(let e of[`${t.id}->${a.officeId}`,`${t.id}->coordinator`]){let t=J.current.get(e)??0;J.current.set(e,Math.min(1,t+.5))}}X.current.set(a.serverId,{toolCalls:a.toolCalls,iteration:a.iteration}),n.push({id:a.officeId,type:`agent`,position:Oe(r,s,t.agents.length),data:{label:a.name,kind:`agent`,status:a.status,serverId:a.serverId,sessionId:t.sessionId,currentTask:a.currentTask,iteration:a.iteration,toolCalls:a.toolCalls,costUsd:a.costUsd,tokensIn:a.tokensIn,tokensOut:a.tokensOut,ctxPct:a.ctxPct,model:a.model,lastActivityAt:a.lastActivityAt,color:`#06b6d4`}}),i.push({id:`${t.id}->${a.officeId}`,source:t.id,target:a.officeId,type:`wire`,animated:c,data:{color:`#06b6d4`,animated:c,label:c?a.currentTask??e(`activity:office.taskFallback`):void 0,flowType:`task`}})})}let S=new Set(l.flatMap(e=>e.agents.map(e=>e.serverId)));for(let e of[...X.current.keys()])S.has(e)||X.current.delete(e);let C=n.map(e=>{let t=K.current.get(e.id),n=Y.current.get(e.id)??0;return t&&t>o&&e.data.status!==`error`&&e.data.status!==`offline`?{...e,data:{...e.data,status:`active`,vizActivity:n}}:{...e,data:{...e.data,vizActivity:n}}}),w=i.map(e=>{let t=J.current.get(e.id)??0;return t>.05?{...e,animated:!0,data:{...e.data,animated:!0,intensity:t}}:e}),T=new Map;for(let e of C)T.set(e.id,{...e.position});Pe.current=T,D(C),P(w);let E=C.map(e=>e.id).sort().join(`|`);if(E!==Fe.current){Fe.current=E;let e=setTimeout(()=>t({padding:.2,duration:300}),50);return()=>clearTimeout(e)}},[l,a,r,s,c,q,D,P,t]);let Ie=l.flatMap(e=>e.agents.map(t=>({clientId:e.id,clientType:e.type,officeId:t.officeId,serverId:t.serverId}))),Le=l.map(e=>e.id),Z=new Map;for(let e of Ie)(!Z.has(e.serverId)||e.clientType===`webui`)&&Z.set(e.serverId,e.officeId);function Q(e){return Z.get(e)??`agent-${e}`}function $(e){let t=e.split(`__agent-`)[0];return t&&t!==e?`${t}->${e}`:`coordinator->${e}`}function Ve(e){switch(e.kind){case`mailbox:send`:case`mailbox:deliver`:return{nodes:[`mailbox`],edges:e.kind===`mailbox:send`?Le.map(e=>`mailbox->${e}`):[],status:`active`};case`agent:spawned`:{let t=Q(e.source);return{nodes:[`coordinator`,t],edges:[$(t)],status:`active`}}case`agent:tool`:case`tool:started`:case`tool:progress`:{let t=Q(e.source);return{nodes:[`coordinator`,t],edges:[$(t)],status:e.kind===`tool:progress`||e.kind===`tool:started`?`streaming`:`active`}}case`tool:executed`:{let t=Q(e.target??e.source);return{nodes:[t],edges:[$(t)],status:`active`}}case`provider:call`:case`provider:delta`:case`provider:response`:return{nodes:[`coordinator`],edges:[],status:e.kind===`provider:delta`?`streaming`:`active`};case`iteration:start`:case`iteration:end`:return{nodes:[`coordinator`],edges:Ie.map(e=>$(e.officeId)),status:e.kind===`iteration:start`?`streaming`:`active`};case`agent:text`:{let t=Q(e.source);return{nodes:[t],edges:[$(t)],status:`streaming`}}case`agent:status`:{let t=Q(e.source);return{nodes:[`coordinator`,t],edges:[$(t)],status:e.data&&typeof e.data==`object`&&`status`in e.data&&String(e.data.status)===`failed`?`error`:`completed`}}case`agent:ctx`:return{nodes:[Q(e.source)],edges:[],status:`active`};case`budget:extended`:return{nodes:[`coordinator`,Q(e.source)],edges:[],status:`active`};case`context:compacted`:case`context:repaired`:return{nodes:[`coordinator`],edges:[],status:`active`};case`error`:return{nodes:e.source?[Q(e.source)]:[],edges:[],status:`error`};case`cost:update`:return{nodes:[`coordinator`],edges:[],status:`active`};case`fleet:snapshot`:{let t=e.data?.sessions??[],n=[`coordinator`];for(let e of t)if(e.agents)for(let t of e.agents){let e=Q(t.id);n.includes(e)||n.push(e)}return{nodes:n,edges:[],status:`active`}}default:return{nodes:[],edges:[],status:`idle`}}}(0,z.useEffect)(()=>{if(n.length===0)return;let e=n[0];if(!e)return;let{nodes:t,edges:r,status:i}=Ve(e),a=Date.now();t.length>0&&(t.forEach(e=>{K.current.set(e,a+q);let t=Y.current.get(e)??0;Y.current.set(e,Math.min(1,t+(1-t)*.5))}),D(e=>e.map(e=>t.includes(e.id)?{...e,data:{...e.data,status:i,vizActivity:Y.current.get(e.id)??0}}:e))),r.length>0&&(r.forEach(e=>{let t=J.current.get(e)??0;J.current.set(e,Math.min(1,t+.5))}),P(e=>e.map(e=>r.includes(e.id)?{...e,animated:!0,data:{...e.data,animated:!0,intensity:J.current.get(e.id)??1}}:e)))},[n,D,P,q,r]),(0,z.useEffect)(()=>{let e=setInterval(()=>{let e=new Map,t=!1;for(let[n,r]of J.current){let i=r*.85;i<.05?(J.current.delete(n),e.set(n,{intensity:0,animated:!1}),t=!0):(J.current.set(n,i),e.set(n,{intensity:i,animated:!0}),t=!0)}t&&P(t=>t.map(t=>{let n=e.get(t.id);return n?{...t,animated:n.animated,data:{...t.data,animated:n.animated,intensity:n.intensity}}:t}));let n=new Map,r=!1;for(let[e,t]of Y.current){let i=t*.9;i<.03?(Y.current.delete(e),n.set(e,0),r=!0):(Y.current.set(e,i),n.set(e,i),r=!0)}r&&D(e=>e.map(e=>{let t=n.get(e.id);return t===void 0?e:{...e,data:{...e.data,vizActivity:t}}}))},1e3);return()=>clearInterval(e)},[P,D]);let He=(0,z.useCallback)(e=>P(t=>fe({...e,type:`wire`},t)),[P]),Ue=(0,z.useCallback)((e,t)=>{ce(t)},[]),We=(0,z.useCallback)(()=>{ce(null)},[]);(0,z.useEffect)(()=>{if(!I)return;let e=e=>{e.key===`Escape`&&L(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[I]);let Ge=(0,z.useCallback)(()=>{D(e=>e.map(e=>{let t=Pe.current.get(e.id);return t?{...e,position:{...t}}:e})),setTimeout(()=>t({padding:.2,duration:300}),50)},[D,t]),[,Ke]=(0,z.useState)(0);return(0,z.useEffect)(()=>{let e=setInterval(()=>Ke(e=>e+1),2e3);return()=>clearInterval(e)},[]),(0,B.jsxs)(`div`,{className:`w-full h-full bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 relative overflow-hidden`,children:[(0,B.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`
2
- linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
3
- linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px)
4
- `,backgroundSize:`40px 40px`}}),d&&(0,B.jsx)(Ne,{}),(0,B.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-10`,children:(0,B.jsx)(`div`,{className:`bg-slate-800/90 backdrop-blur px-4 py-2 rounded-lg border border-slate-700 shadow-xl`,children:(0,B.jsxs)(`div`,{className:`text-xs font-bold text-slate-300 flex items-center gap-2`,children:[(0,B.jsx)(ee,{className:`h-4 w-4 text-purple-400`}),e(`activity:office.fleetHq`),(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500 animate-pulse ml-2`}),(0,B.jsx)(`span`,{className:`text-[10px] text-gray-400 font-normal`,children:e(`activity:office.live`)})]})})}),f&&(0,B.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-10 bg-slate-800/90 backdrop-blur rounded-lg border border-slate-700 p-3 text-[10px]`,children:[(0,B.jsx)(`div`,{className:`font-bold text-gray-300 mb-2`,children:e(`activity:office.legendStatus`)}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500 animate-pulse`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendActive`)})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-gray-500`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendIdle`)})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-red-500 animate-pulse`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendError`)})]})]})]}),f&&(0,B.jsxs)(`div`,{className:`absolute bottom-4 right-4 z-10 bg-slate-800/90 backdrop-blur rounded-lg border border-slate-700 p-3 text-[10px]`,children:[(0,B.jsx)(`div`,{className:`font-bold text-gray-300 mb-2`,children:e(`activity:office.legendConnections`)}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-yellow-400`,children:`✉`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendMail`)})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-purple-400`,children:`→`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendTask`)})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-emerald-400`,children:`●`}),(0,B.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendStatusConn`)})]})]})]}),(0,B.jsxs)(ye,{nodes:T,edges:N,onNodesChange:ae,onEdgesChange:se,onConnect:He,onNodeClick:Ue,onPaneClick:We,nodeTypes:Re,edgeTypes:ze,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:1.5,defaultEdgeOptions:{type:`wire`},proOptions:{hideAttribution:!0},children:[(0,B.jsxs)(_e,{position:`top-right`,className:`flex items-center gap-2`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:Ge,title:e(`activity:office.arrangeTitle`),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md bg-slate-800/90 border border-slate-700 text-xs text-slate-200 hover:bg-slate-700 transition-colors`,children:[(0,B.jsx)(te,{className:`h-3.5 w-3.5`}),e(`activity:office.arrange`)]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>b(!v),title:e(`activity:office.feedTitle`),className:O(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,v?`bg-cyan-500/20 border-cyan-500/40 text-cyan-300`:`bg-slate-800/90 border-slate-700 text-slate-300 hover:bg-slate-700`),children:[(0,B.jsx)(u,{className:`h-3.5 w-3.5`}),e(`activity:office.feed`)]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>R(e=>!e),title:e(`activity:office.broadcastTitle`),className:O(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,de?`bg-amber-500/20 border-amber-500/40 text-amber-300`:`bg-slate-800/90 border-slate-700 text-slate-300 hover:bg-slate-700`),children:[(0,B.jsx)(y,{className:`h-3.5 w-3.5`}),e(`activity:office.broadcast`)]})]}),C!==`none`&&(0,B.jsx)(ve,{variant:C===`lines`?pe.Lines:C===`cross`?pe.Cross:pe.Dots,gap:20,size:1,color:`rgba(255,255,255,0.05)`}),_&&(0,B.jsx)(ge,{className:`bg-slate-800 border border-slate-700 rounded-lg [&>button]:bg-slate-700 [&>button]:text-slate-200`}),g&&(0,B.jsx)(me,{className:`bg-slate-800/90 border border-slate-700 rounded-lg`,nodeColor:e=>{switch(e.data.kind){case`coordinator`:return`#a855f7`;case`webui`:return`#3b82f6`;case`tui`:return`#22c55e`;case`repl`:return`#f59e0b`;case`mailbox`:return`#eab308`;case`agent`:return`#06b6d4`;default:return`#6366f1`}},maskColor:`rgba(0,0,0,0.8)`})]}),v&&(0,B.jsx)(Be,{events:n,now:Date.now()}),de&&(0,B.jsxs)(`div`,{className:`absolute top-16 right-4 z-30 w-80 rounded-lg border border-amber-500/40 bg-slate-900/97 p-3 shadow-2xl backdrop-blur`,children:[(0,B.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold text-amber-300`,children:[(0,B.jsx)(y,{className:`h-3.5 w-3.5`}),` `,e(`activity:office.broadcastToAll`)]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>R(!1),className:`text-gray-400 hover:text-white text-base leading-none`,children:`×`})]}),(0,B.jsx)(`textarea`,{value:V,onChange:e=>be(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),G())},rows:3,placeholder:e(`activity:office.broadcastPlaceholder`),className:`w-full resize-none rounded-md border border-slate-700 bg-slate-900/70 px-2 py-1 text-[11px] text-gray-200 placeholder:text-gray-600 focus:border-amber-500/50 focus:outline-none`}),(0,B.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-gray-600`,children:e(`activity:office.broadcastSendHint`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void G(),disabled:H||!V.trim(),className:`rounded-md border border-amber-500/40 bg-amber-500/20 px-2.5 py-1 text-[11px] text-amber-200 transition-colors hover:bg-amber-500/30 disabled:cursor-not-allowed disabled:opacity-40`,children:H?`…`:e(`activity:office.broadcast`)})]}),Se&&(0,B.jsx)(`div`,{className:`mt-1 text-[10px] text-gray-400`,children:Se})]}),F&&(0,B.jsxs)(`div`,{className:O(`absolute top-20 right-4 bg-background border border-border rounded-lg p-4 shadow-xl z-20`,F.data.kind===`agent`?`w-[28rem] max-w-[calc(100%-2rem)]`:F.data.sessionId?`w-80`:`w-64`),children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[F.data.kind===`webui`&&(0,B.jsx)(E,{className:`h-4 w-4 text-blue-500`}),F.data.kind===`tui`&&(0,B.jsx)(x,{className:`h-4 w-4 text-emerald-500`}),F.data.kind===`coordinator`&&(0,B.jsx)(S,{className:`h-4 w-4 text-purple-500`}),F.data.kind===`agent`&&(0,B.jsx)(p,{className:`h-4 w-4 text-cyan-500`}),F.data.kind===`mailbox`&&(0,B.jsx)(h,{className:`h-4 w-4 text-yellow-500`}),(0,B.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:F.data.label})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[F.data.sessionId&&(0,B.jsx)(`button`,{type:`button`,title:e(`activity:office.openFullView`),onClick:()=>L({sessionId:F.data.sessionId,label:F.data.label}),className:`text-muted-foreground hover:text-primary`,children:(0,B.jsx)(w,{className:`h-3.5 w-3.5`})}),(0,B.jsx)(`button`,{onClick:We,className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]})]}),(()=>{let t=F.data,n=Date.now(),r=({k:e,v:t,accent:n})=>(0,B.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,B.jsx)(`span`,{className:O(`font-mono truncate text-right`,n??`text-foreground/80`),children:t})]}),i=t.kind===`agent`,a=t.kind===`webui`||t.kind===`tui`||t.kind===`repl`,o=(t.tokensIn||0)+(t.tokensOut||0),c=Me(t.ctxPct);return(0,B.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,B.jsx)(r,{k:`Status`,v:String(t.status).toUpperCase(),accent:O(t.status===`active`&&`text-emerald-600 dark:text-emerald-400`,t.status===`streaming`&&`text-blue-600 dark:text-blue-400`,t.status===`error`&&`text-destructive`,t.status===`idle`&&`text-muted-foreground`,t.status===`offline`&&`text-muted-foreground/50`)}),i&&(0,B.jsxs)(B.Fragment,{children:[t.model&&(0,B.jsx)(r,{k:`Model`,v:Ee(t.model),accent:`text-cyan-600 dark:text-cyan-400`}),t.currentTask&&(0,B.jsx)(r,{k:`Tool`,v:t.currentTask,accent:`text-cyan-600 dark:text-cyan-400`}),(0,B.jsx)(r,{k:`Iterations`,v:t.iteration||0,accent:`text-cyan-600 dark:text-cyan-400`}),(0,B.jsx)(r,{k:`Tool calls`,v:t.toolCalls||0,accent:`text-amber-600 dark:text-amber-400`}),(0,B.jsx)(r,{k:`Tokens in`,v:W(t.tokensIn)}),(0,B.jsx)(r,{k:`Tokens out`,v:W(t.tokensOut)}),(0,B.jsx)(r,{k:`Tokens total`,v:W(o)}),c>0&&(0,B.jsx)(r,{k:`Context`,v:`${c}%`,accent:c>=90?`text-destructive`:c>=70?`text-amber-600 dark:text-amber-400`:`text-foreground/70`}),(0,B.jsx)(r,{k:`Cost`,v:`$${(t.costUsd||0).toFixed(4)}`,accent:`text-emerald-600 dark:text-emerald-400`}),t.lastActivityAt&&(0,B.jsx)(r,{k:`Last seen`,v:we(t.lastActivityAt,n),accent:`text-muted-foreground`}),(0,B.jsx)(`div`,{className:`pt-2`,children:(0,B.jsx)(ie,{entries:ke,agentName:t.label,compact:!0,maxHeightClassName:`max-h-64`})})]}),a&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(r,{k:`Surface`,v:Ae(t.kind),accent:`text-foreground/80`}),t.branch&&(0,B.jsx)(r,{k:`Branch`,v:`⎇ ${t.branch}`,accent:`text-foreground/70`}),t.pid!=null&&(0,B.jsx)(r,{k:`PID`,v:t.pid}),t.workingDir&&(0,B.jsx)(r,{k:`Dir`,v:t.workingDir,accent:`text-muted-foreground`}),(0,B.jsx)(r,{k:`Agents`,v:t.agentCount??0,accent:`text-cyan-600 dark:text-cyan-400`}),t.startedAt&&(0,B.jsx)(r,{k:`Uptime`,v:Te(t.startedAt,n),accent:`text-foreground/70`})]}),t.kind===`mailbox`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(r,{k:`Total messages`,v:t.messageCount||0,accent:`text-amber-600 dark:text-amber-400`}),(0,B.jsx)(r,{k:`Unread`,v:t.unreadCount||0,accent:`text-amber-600 dark:text-amber-400`}),s.length>0&&(0,B.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-border pt-2`,children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:office.recent`)}),[...s].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp)).slice(0,6).map(t=>(0,B.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px]`,children:[(0,B.jsx)(`span`,{className:O(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,!t.completed&&(t.readByCount??0)===0?`bg-amber-500`:t.completed?`bg-emerald-500`:`bg-muted`)}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate text-foreground/80`,children:t.subject||e(`activity:office.noSubject`)}),(0,B.jsxs)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[t.from,` → `,t.to,` · `,we(t.timestamp,n)]})]})]},t.id))]})]}),t.kind===`coordinator`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(r,{k:`Connections`,v:t.connections||0,accent:`text-purple-600 dark:text-purple-400`}),(0,B.jsx)(r,{k:`Iterations`,v:t.iteration||0,accent:`text-purple-600 dark:text-purple-400`})]}),(i||a)&&t.sessionId&&(0,B.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 h-72`,children:(0,B.jsx)(Ce,{sessionId:t.sessionId})})]})})()]}),I&&(0,B.jsxs)(`div`,{className:`absolute inset-y-0 right-0 z-30 flex w-[min(680px,92%)] flex-col border-l border-border bg-background shadow-2xl`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5 shrink-0 bg-card`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(p,{className:`h-4 w-4 text-primary shrink-0`}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:I.label}),(0,B.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:office.fullOperationStream`)})]})]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>L(null),title:e(`activity:office.closeEsc`),className:`text-muted-foreground hover:text-foreground text-xl leading-none shrink-0`,children:`×`})]}),(0,B.jsx)(`div`,{className:`flex-1 min-h-0 p-4`,children:(0,B.jsx)(Ce,{sessionId:I.sessionId,limit:500})})]})]})}function Ve(){return(0,B.jsx)(I,{children:(0,B.jsx)($,{})})}export{Ve as OfficeMapPanel};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{m as t,p as n}from"./markdown-D0X23O-i.js";import{$r as r,It as i,Mr as a,Or as o,Pr as s,Ut as c,Vr as l,X as u,Z as d,Zn as f,_r as p,bt as m,ci as h,ct as g,di as _,dt as v,jn as y,ot as ee,qt as te,rr as ne,sr as b,ti as x,xt as S}from"./vendor-Ch4m_qLI.js";import"./i18n-CNo6A2vu.js";import{t as C}from"./utils-DBns3uMk.js";import{C as w,_ as T,a as re,g as E,h as D,k as O,m as k,o as A,p as j,v as M,y as N}from"./index-CWj2bI87.js";import{a as P,c as F,i as I,l as L,n as R,o as z,r as B,s as V,t as H}from"./SddFlowGraph-CtMpzU4S.js";var U=e(t(),1),W=n();function ie({feed:e,now:t}){let{t:n}=h();return(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs font-semibold text-foreground`,children:[(0,W.jsx)(a,{className:`h-3.5 w-3.5 text-orange-500 dark:text-orange-400`}),n(`activity:sdd.activityHeading`)]}),(0,W.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-1 overflow-auto p-2`,children:e.length===0?(0,W.jsx)(`p`,{className:`px-1 pt-4 text-center text-[11px] text-muted-foreground`,children:n(`activity:sdd.feedEmpty`)}):e.map((e,n)=>{let r=B[e.kind]??B.started,i=r.icon;return(0,W.jsxs)(`div`,{className:C(`sdd-rise flex items-start gap-2 rounded-md px-2 py-1.5 text-[11px]`,n===0?`bg-muted`:`hover:bg-muted`),children:[(0,W.jsx)(i,{className:C(`mt-0.5 h-3.5 w-3.5 shrink-0`,r.color)}),(0,W.jsx)(`span`,{className:`flex-1 leading-snug text-foreground`,children:e.text}),(0,W.jsx)(`span`,{className:`shrink-0 tabular-nums text-[10px] text-muted-foreground`,children:z(e.ts,t)})]},`${e.ts}-${n}`)})})]})}function G({open:e,onOpenChange:t,snapshot:n,busy:r,onConfirm:i}){let{t:a}=h(),o=n?.mergedCommits?.length??0,c=n?.baseBranch,[u,d]=(0,U.useState)(!1);(0,U.useEffect)(()=>{e&&d(!1)},[e]);let f=n?.status===`running`||n?.status===`paused`,p=(0,U.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.worktreeBranch&&e.add(t.worktreeBranch);return e.size},[n?.tasks]),m=(0,U.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.displayStatus===`in_progress`&&t.agentName&&e.add(t.agentName);return e.size},[n?.tasks]);return(0,W.jsx)(k,{open:e,onOpenChange:e=>!r&&t(e),children:(0,W.jsxs)(D,{className:`sm:max-w-lg border-red-500/50`,children:[(0,W.jsxs)(M,{children:[(0,W.jsxs)(N,{className:`flex items-center gap-2`,children:[(0,W.jsx)(v,{className:`h-5 w-5 text-red-500`}),a(`activity:sdd.destroyTitle`)]}),(0,W.jsx)(E,{children:a(`activity:sdd.destroyDesc`)})]}),(0,W.jsxs)(`ul`,{className:`space-y-1.5 py-1 text-sm`,children:[f&&(0,W.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 text-red-500`,children:`■`}),(0,W.jsx)(`span`,{children:m>0?a(`activity:sdd.stopRunAgents`,{count:m}):a(`activity:sdd.stopRun`)})]}),(0,W.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 text-red-500`,children:`■`}),(0,W.jsx)(`span`,{children:p>0?a(`activity:sdd.removeWorktreesCount`,{count:p}):a(`activity:sdd.removeWorktreesAll`)})]}),(0,W.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 text-red-500`,children:`■`}),(0,W.jsx)(`span`,{children:a(`activity:sdd.deleteArtifacts`)})]})]}),o>0&&(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2.5 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),className:`mt-0.5 h-4 w-4 accent-amber-500`}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`font-medium`,children:a(`activity:sdd.revertMerged`,{count:o})}),` `,`on `,(0,W.jsx)(`code`,{className:`text-xs`,children:c??a(`activity:sdd.baseBranchFallback`)}),(0,W.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:a(`activity:sdd.revertHint`)})]})]}),(0,W.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md bg-muted/50 p-2 text-xs text-muted-foreground`,children:[(0,W.jsx)(s,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-500`}),a(o>0&&!u?`activity:sdd.noteLeaveMerged`:`activity:sdd.noteAbandon`)]}),(0,W.jsxs)(T,{className:`gap-2 sm:gap-2`,children:[(0,W.jsx)(j,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,W.jsx)(j,{size:`sm`,disabled:r,onClick:()=>i(u),className:`bg-red-600 text-white hover:bg-red-700`,children:r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(l,{className:`mr-1 h-3.5 w-3.5 animate-spin`}),` `,a(`activity:sdd.destroying`)]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(v,{className:`mr-1 h-3.5 w-3.5`}),` `,a(`activity:sdd.destroyAll`)]})})]})]})})}var K=[{key:`pending`,labelKey:`kanbanBacklog`,accent:`border-slate-600/40`,head:`text-muted-foreground`},{key:`queued`,labelKey:`kanbanReady`,accent:`border-cyan-500/40`,head:`text-cyan-600 dark:text-cyan-300`},{key:`in_progress`,labelKey:`kanbanRunning`,accent:`border-amber-400/50`,head:`text-amber-600 dark:text-amber-300`},{key:`review`,labelKey:`kanbanReview`,accent:`border-sky-500/40`,head:`text-sky-600 dark:text-sky-300`},{key:`failed`,labelKey:`kanbanFailed`,accent:`border-red-500/40`,head:`text-red-600 dark:text-red-300`},{key:`completed`,labelKey:`kanbanDone`,accent:`border-emerald-500/40`,head:`text-emerald-600 dark:text-emerald-300`}];function q({tasks:e,selectedId:t,onTaskClick:n}){let{t:r}=h(),i=(0,U.useMemo)(()=>{let t=new Map;for(let e of K)t.set(e.key,[]);for(let n of e){let e=n.displayStatus===`blocked`?`pending`:n.displayStatus===`cancelled`?`failed`:n.displayStatus;(t.get(e)??t.get(`pending`))?.push(n)}return t},[e]);return(0,W.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 gap-3 overflow-x-auto p-4`,children:K.map(e=>{let a=i.get(e.key)??[];return(0,W.jsxs)(`div`,{className:`flex min-h-0 w-64 shrink-0 flex-col`,children:[(0,W.jsxs)(`div`,{className:C(`mb-2 flex items-center gap-2 border-b-2 pb-1.5`,e.accent),children:[(0,W.jsx)(`span`,{className:C(`text-xs font-bold uppercase tracking-wide`,e.head),children:r(`activity:sdd.${e.labelKey}`)}),(0,W.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-[10px] text-muted-foreground`,children:a.length})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto pr-1`,children:[a.map(e=>(0,W.jsx)(J,{task:e,selected:e.id===t,onClick:()=>n(e.id)},e.id)),a.length===0&&(0,W.jsx)(`div`,{className:`rounded-md border border-dashed border-border py-6 text-center text-[10px] text-muted-foreground`,children:r(`activity:sdd.kanbanEmpty`)})]})]},e.key)})})}function J({task:e,selected:t,onClick:n}){let r=e.displayStatus===`in_progress`;return(0,W.jsxs)(`button`,{type:`button`,onClick:n,className:C(`sdd-node-enter w-full rounded-lg border bg-card p-2 text-left transition hover:brightness-125`,t?`border-violet-400/70 ring-1 ring-violet-400/40`:`border-border`,r&&`sdd-node-running`,e.displayStatus===`completed`&&`sdd-node-complete`,e.displayStatus===`failed`&&`sdd-node-failed`),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[r&&(0,W.jsx)(l,{className:`h-3 w-3 animate-spin text-amber-400`}),e.displayStatus===`completed`&&(0,W.jsx)(p,{className:`h-3 w-3 text-emerald-400`}),e.displayStatus===`failed`&&(0,W.jsx)(d,{className:`h-3 w-3 text-red-400`}),(0,W.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.shortId}),(0,W.jsx)(`span`,{className:C(`ml-auto rounded px-1.5 text-[9px] font-bold uppercase`,F(e.priority).chip),children:e.priority})]}),(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-snug text-foreground`,children:e.title}),(e.agentName||e.worktreeBranch||e.retries)&&(0,W.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[e.agentName&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:C(`flex h-4 w-4 items-center justify-center rounded-full text-[8px] font-bold text-white`,r?`bg-amber-500 sdd-agent-live`:`bg-slate-600`),children:P(e.agentName)}),(0,W.jsx)(`span`,{className:`max-w-[80px] truncate text-[10px] text-muted-foreground`,children:e.agentName})]}),e.retries?(0,W.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[9px] text-red-400`,children:[(0,W.jsx)(i,{className:`h-2.5 w-2.5`}),e.retries]}):null,e.worktreeBranch&&(0,W.jsx)(y,{className:`ml-auto h-2.5 w-2.5 text-muted-foreground`})]})]})}function ae({task:e,allTasks:t,feed:n,now:r,modelCandidates:a,defaultModel:s,onClose:c,onRetry:l,onReassign:u,onSetModel:f,onSetVerification:g,onCancel:_,onDelete:te,onSplit:ne,onSelectTask:x}){let{t:w}=h(),T=L(e.displayStatus),E=T.icon,D=e.displayStatus===`in_progress`,O=e.displayStatus===`pending`||e.displayStatus===`blocked`||e.displayStatus===`queued`,[k,A]=(0,U.useState)(!1),[j,M]=(0,U.useState)(``),[N,I]=(0,U.useState)(null),[R,z]=(0,U.useState)(!1),[B,H]=(0,U.useState)(``),[ie,G]=(0,U.useState)(!1),[K,q]=(0,U.useState)(e.verificationCommand??``),J=()=>{j.trim()&&(u(e.id,j.trim()),A(!1),M(``))},ae=()=>{let t=B.split(`
2
- `).map(e=>e.trim()).filter(Boolean).map(e=>{let[t,...n]=e.split(`::`),r=(t??``).trim();return{title:r,description:n.join(`::`).trim()||r}}).filter(e=>e.title);t.length&&(ne(e.id,t),z(!1),H(``))},se=(0,U.useMemo)(()=>new Map(t.map(e=>[e.shortId,e])),[t]),X=(0,U.useMemo)(()=>t.filter(t=>t.deps.includes(e.shortId)),[t,e.shortId]),Z=(0,U.useMemo)(()=>n.filter(t=>t.taskShortId===e.shortId),[n,e.shortId]),ce=e.startedAt&&!e.completedAt?V(r-e.startedAt):e.startedAt&&e.completedAt?V(e.completedAt-e.startedAt):null;return(0,W.jsxs)(`div`,{className:`sdd-rise flex h-full min-h-0 min-w-0 flex-col`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:c,className:`text-muted-foreground hover:text-foreground`,title:w(`activity:sddTask.backTitle`),children:(0,W.jsx)(o,{className:`h-4 w-4`})}),(0,W.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.shortId}),(0,W.jsxs)(`span`,{className:C(`ml-auto flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px]`,T.ring,T.text),children:[(0,W.jsx)(E,{className:C(`h-3 w-3`,D&&`animate-spin`)}),T.label]})]}),(0,W.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-3 overflow-auto p-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold leading-snug text-foreground`,children:e.title}),e.agentName&&(0,W.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-muted p-2`,children:[(0,W.jsx)(`span`,{className:C(`flex h-7 w-7 items-center justify-center rounded-full text-[10px] font-bold text-white`,D?`bg-amber-500 sdd-agent-live`:`bg-slate-600`),children:P(e.agentName)}),(0,W.jsxs)(`div`,{className:`leading-tight`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:e.agentName}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:w(D?`activity:sddTask.workingOn`:`activity:sddTask.assigned`)})]})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 text-[11px]`,children:[(0,W.jsx)(Y,{label:w(`activity:sddTask.metaPriority`),children:(0,W.jsx)(`span`,{className:C(`font-medium uppercase`,F(e.priority).text),children:e.priority})}),(0,W.jsx)(Y,{label:w(`activity:sddTask.metaType`),children:e.type}),ce&&(0,W.jsx)(Y,{label:e.completedAt?w(`activity:sddTask.metaDuration`):w(`activity:sddTask.metaElapsed`),children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(b,{className:`h-3 w-3 text-muted-foreground`}),ce]})}),e.retries?(0,W.jsx)(Y,{label:w(`activity:sddTask.metaRetries`),children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,W.jsx)(i,{className:`h-3 w-3`}),e.retries]})}):null,e.worktreeBranch&&(0,W.jsx)(Y,{label:w(`activity:sddTask.metaWorktree`),full:!0,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-foreground`,title:e.worktreeBranch,children:[(0,W.jsx)(y,{className:`h-3 w-3 text-muted-foreground`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.worktreeBranch})]})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[w(`activity:sddTask.workerModel`),!e.model&&s&&(0,W.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,w(`activity:sddTask.runDefault`,{model:s})]})]}),(0,W.jsx)(re,{value:e.model,provider:e.provider,candidates:a,placeholder:s?w(`activity:sddTask.runDefaultPlaceholderModel`,{model:s}):w(`activity:sddTask.runDefaultPlaceholder`),onPick:(t,n)=>f(e.id,t,n),onReset:e.model?()=>f(e.id,void 0,void 0):void 0}),e.fallbackModels&&e.fallbackModels.length>0&&(0,W.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.fallbackModels.map((e,t)=>(0,W.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`↳ `,e]},t))})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[w(`activity:sddTask.verificationCmd`),(0,W.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,w(`activity:sddTask.gatesCompletion`)]})]}),ie?(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(`input`,{autoFocus:!0,value:K,onChange:e=>q(e.target.value),onKeyDown:t=>{t.key===`Enter`?(g(e.id,K.trim()||void 0),G(!1)):t.key===`Escape`&&(q(e.verificationCommand??``),G(!1))},placeholder:w(`activity:sddTask.verifyPlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 font-mono text-[11px] text-foreground`}),(0,W.jsxs)(`div`,{className:`flex gap-1`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>{g(e.id,K.trim()||void 0),G(!1)},className:`rounded bg-primary px-2 py-0.5 text-[10px] text-primary-foreground hover:opacity-90`,children:w(`common:action.save`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{q(e.verificationCommand??``),G(!1)},className:`rounded bg-muted px-2 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:w(`common:action.cancel`)})]})]}):e.verificationCommand?(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`code`,{className:`flex-1 truncate rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e.verificationCommand}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>G(!0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:w(`common:action.edit`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>g(e.id,void 0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:w(`common:action.clear`)})]}):(0,W.jsx)(`button`,{type:`button`,onClick:()=>G(!0),className:`rounded border border-dashed border-border px-2 py-1 text-[10px] text-muted-foreground hover:bg-muted`,children:w(`activity:sddTask.addVerify`)})]}),e.description&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:w(`activity:sddTask.description`)}),(0,W.jsx)(`p`,{className:`whitespace-pre-wrap rounded-md bg-muted p-2 text-[11px] leading-relaxed text-foreground`,children:e.description})]}),Z.length>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:w(`activity:sddTask.timeline`)}),(0,W.jsx)(`div`,{className:`space-y-1 border-l border-border pl-2.5`,children:Z.map((e,t)=>(0,W.jsxs)(`div`,{className:`relative text-[11px] leading-snug text-foreground`,children:[(0,W.jsx)(`span`,{className:C(`absolute -left-[14px] top-1 h-1.5 w-1.5 rounded-full`,e.kind===`completed`?`bg-emerald-400`:e.kind===`failed`?`bg-red-400`:e.kind===`retrying`?`bg-orange-400`:`bg-amber-400`)}),e.text]},`${e.ts}-${t}`))})]}),e.deps.length>0&&(0,W.jsx)(oe,{title:w(`activity:sddTask.dependsOn`),shortIds:e.deps,byShort:se,onSelectTask:x}),X.length>0&&(0,W.jsx)(oe,{title:w(`activity:sddTask.blocks`),shortIds:X.map(e=>e.shortId),byShort:se,onSelectTask:x})]}),(0,W.jsxs)(`div`,{className:`border-t border-border p-2`,children:[k?(0,W.jsxs)(`div`,{className:`sdd-rise flex items-center gap-1.5`,children:[(0,W.jsx)(`input`,{autoFocus:!0,value:j,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`Enter`&&J(),e.key===`Escape`&&A(!1)},placeholder:w(`activity:sddTask.newWorkerPlaceholder`),className:`min-w-0 flex-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs outline-none focus:border-violet-500`}),(0,W.jsx)(`button`,{type:`button`,onClick:J,disabled:!j.trim(),className:`rounded-md bg-violet-500/20 px-2 py-1.5 text-xs font-medium text-violet-700 dark:text-violet-200 hover:bg-violet-500/30 disabled:opacity-40`,children:(0,W.jsx)(p,{className:`h-3.5 w-3.5`})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>A(!1),className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,W.jsx)(d,{className:`h-3.5 w-3.5`})})]}):N?(0,W.jsxs)(`div`,{className:`sdd-rise flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`flex-1 text-xs text-foreground`,children:w(N===`stop`?`activity:sddTask.confirmStop`:`activity:sddTask.confirmDelete`)}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{N===`stop`?_(e.id):te(e.id),I(null)},className:`inline-flex items-center gap-1 rounded-md bg-red-500/20 px-2.5 py-1.5 text-xs font-medium text-red-700 dark:text-red-200 hover:bg-red-500/30`,children:[(0,W.jsx)(p,{className:`h-3.5 w-3.5`}),` `,w(N===`stop`?`common:action.stop`:`common:action.delete`)]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>I(null),className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,W.jsx)(d,{className:`h-3.5 w-3.5`})})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id),title:w(`activity:sddTask.retryTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-orange-500/15 py-1.5 text-xs font-medium text-orange-600 dark:text-orange-300 hover:bg-orange-500/25`,children:[(0,W.jsx)(i,{className:`h-3.5 w-3.5`}),` `,w(`common:action.retry`)]}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>A(!0),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-violet-500/15 py-1.5 text-xs font-medium text-violet-600 dark:text-violet-300 hover:bg-violet-500/25`,children:[(0,W.jsx)(ee,{className:`h-3.5 w-3.5`}),` `,w(`activity:sddTask.reassign`)]}),D&&(0,W.jsxs)(`button`,{type:`button`,onClick:()=>I(`stop`),title:w(`activity:sddTask.stopTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-red-500/15 py-1.5 text-xs font-medium text-red-600 dark:text-red-300 hover:bg-red-500/25`,children:[(0,W.jsx)(m,{className:`h-3.5 w-3.5`}),` `,w(`common:action.stop`)]}),!D&&(0,W.jsxs)(`button`,{type:`button`,onClick:()=>z(!0),title:w(`activity:sddTask.splitTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-sky-500/15 py-1.5 text-xs font-medium text-sky-600 dark:text-sky-300 hover:bg-sky-500/25`,children:[(0,W.jsx)(S,{className:`h-3.5 w-3.5`}),` `,w(`activity:sddTask.split`)]}),O&&(0,W.jsxs)(`button`,{type:`button`,onClick:()=>I(`delete`),title:w(`activity:sddTask.deleteTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-red-500/10 py-1.5 text-xs font-medium text-red-600 dark:text-red-300/90 hover:bg-red-500/20`,children:[(0,W.jsx)(v,{className:`h-3.5 w-3.5`}),` `,w(`common:action.delete`)]})]}),R&&(0,W.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,W.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,htmlFor:`sdd-split-input`,children:w(`activity:sddTask.splitHint`)}),(0,W.jsx)(`textarea`,{id:`sdd-split-input`,autoFocus:!0,rows:3,value:B,onChange:e=>H(e.target.value),placeholder:w(`activity:sddTask.splitPlaceholder`),className:`w-full resize-y rounded-md border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-sky-500`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:ae,className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-sky-500/20 py-1.5 text-xs font-medium text-sky-700 dark:text-sky-200 hover:bg-sky-500/30`,children:[(0,W.jsx)(S,{className:`h-3.5 w-3.5`}),` `,w(`activity:sddTask.splitInto`)]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{z(!1),H(``)},className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,W.jsx)(d,{className:`h-3.5 w-3.5`})})]})]})]})]})}function Y({label:e,children:t,full:n}){return(0,W.jsxs)(`div`,{className:C(`rounded-md border border-border bg-muted/50 px-2 py-1`,n&&`col-span-2`),children:[(0,W.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,W.jsx)(`div`,{className:`text-foreground`,children:t})]})}function oe({title:e,shortIds:t,byShort:n,onSelectTask:r}){return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>{let t=n.get(e);return(0,W.jsxs)(`button`,{type:`button`,disabled:!t,onClick:()=>t&&r(t.id),className:`flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] text-foreground hover:bg-muted disabled:opacity-50`,title:t?.title,children:[(0,W.jsx)(`span`,{className:C(`h-1.5 w-1.5 rounded-full`,L(t?.displayStatus??`pending`).dot)}),(0,W.jsx)(`span`,{className:`font-mono`,children:e})]},e)})})]})}function se({pct:e}){let t=2*Math.PI*26,n=t-Math.max(0,Math.min(100,e))/100*t;return(0,W.jsxs)(`div`,{className:`relative h-16 w-16 shrink-0`,children:[(0,W.jsxs)(`svg`,{viewBox:`0 0 64 64`,className:`h-16 w-16 -rotate-90`,children:[(0,W.jsx)(`circle`,{cx:`32`,cy:`32`,r:26,fill:`none`,stroke:`hsl(215 28% 22%)`,strokeWidth:`6`}),(0,W.jsx)(`circle`,{cx:`32`,cy:`32`,r:26,fill:`none`,stroke:`url(#sddgrad)`,strokeWidth:`6`,strokeLinecap:`round`,strokeDasharray:t,strokeDashoffset:n,style:{transition:`stroke-dashoffset 0.6s cubic-bezier(0.16,1,0.3,1)`}}),(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:`sddgrad`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:`#a78bfa`}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:`#22d3ee`})]})})]}),(0,W.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm font-bold text-foreground`,children:[Math.round(e),`%`]})]})}function X({onClose:e}){let{t}=h(),{client:n}=w(),r=O(e=>e.snapshot),o=O(e=>e.lifecycleResult),l=O(e=>e.destroying),p=O(e=>e.setDestroying),_=O(e=>e.setLifecycleResult),[y,ee]=(0,U.useState)(()=>Date.now()),[b,x]=(0,U.useState)(null),[S,T]=(0,U.useState)(`graph`),[re,E]=(0,U.useState)(!1);(0,U.useEffect)(()=>{n?.send?.({type:`sdd.board.get`})},[n]);let D=r&&(r.status===`running`||r.status===`paused`);(0,U.useEffect)(()=>{if(!D)return;let e=setInterval(()=>ee(Date.now()),1e3);return ee(Date.now()),()=>clearInterval(e)},[D]);let k=(0,U.useCallback)(e=>n?.send?.(e),[n]),M=(0,U.useRef)(null),N=(0,U.useCallback)(e=>{M.current=null,k({type:`sdd.board.destroy`,payload:{revertMerged:e}})},[k]),F=(0,U.useCallback)(e=>{E(!1),_(null),p(!0),D?(k({type:`sdd.board.stop`,payload:{}}),M.current={revertMerged:e,deadline:Date.now()+2e4}):N(e)},[D,k,N,p,_]);(0,U.useEffect)(()=>{let e=M.current;e&&(!D||Date.now()>=e.deadline)&&N(e.revertMerged)},[D,r,N]);let L=(0,U.useCallback)(()=>{_(null),k({type:`sdd.board.cleanup_worktrees`,payload:{}})},[k,_]),z=(0,U.useCallback)(()=>{_(null),k({type:`sdd.board.rollback`,payload:{}})},[k,_]),B=(0,U.useMemo)(()=>(r?.tasks??[]).map(e=>({id:e.id,shortId:e.shortId,title:e.title,displayStatus:e.displayStatus,priority:e.priority,deps:e.deps,agentName:e.agentName,worktreeBranch:e.worktreeBranch})),[r?.tasks]),K=(0,U.useMemo)(()=>{let e=new Map;for(let t of r?.tasks??[])t.displayStatus===`in_progress`&&t.agentName&&e.set(t.agentName,{name:t.agentName,task:t.title});return[...e.values()]},[r?.tasks]),J=(0,U.useCallback)(e=>x(e),[]),Y=(0,U.useCallback)(e=>k({type:`sdd.board.retry`,payload:{taskId:e}}),[k]),oe=(0,U.useCallback)(()=>k({type:`sdd.board.retry_all_failed`,payload:{}}),[k]),X=(0,U.useCallback)((e,t)=>{let n=t.trim();n&&k({type:`sdd.board.reassign`,payload:{taskId:e,agentName:n}})},[k]),Z=(0,U.useCallback)((e,t,n)=>k({type:`sdd.board.set_task_model`,payload:{taskId:e,model:t,provider:n}}),[k]),le=(0,U.useCallback)((e,t)=>k({type:`sdd.board.set_task_verification`,payload:{taskId:e,verificationCommand:t}}),[k]),ue=(0,U.useCallback)(e=>k({type:`sdd.board.cancel_task`,payload:{taskId:e}}),[k]),de=(0,U.useCallback)(e=>{k({type:`sdd.board.delete_task`,payload:{taskId:e}}),x(null)},[k]),fe=(0,U.useCallback)((e,t)=>{k({type:`sdd.board.split_task`,payload:{taskId:e,subtasks:t}}),x(null)},[k]),pe=A(b!==null),me=(0,U.useMemo)(()=>r?.tasks.find(e=>e.id===b)??null,[r?.tasks,b]),$=r?.progress,he=r?.diagnostics?.deadlockChains??[];return(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,W.jsxs)(`header`,{className:`sdd-sheen shrink-0 border-b border-border px-4 pb-3 pt-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(a,{className:`h-5 w-5 text-orange-400`}),(0,W.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:r?.title??t(`activity:sddBoard.titleFallback`)}),r&&(0,W.jsx)(`span`,{className:C(`rounded-full border px-2 py-0.5 text-[11px] font-medium capitalize`,I[r.status]??I.idle),children:r.status}),r?.defaultModel&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] text-muted-foreground`,title:t(`activity:sddBoard.defaultModelTitle`),children:[(0,W.jsx)(ne,{className:`h-3 w-3 text-violet-400`}),r.defaultModel]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,W.jsx)(`div`,{className:`flex items-center rounded-md border border-border bg-muted p-0.5 text-[11px]`,children:[`graph`,`kanban`].map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>T(e),className:C(`rounded px-2 py-0.5 capitalize transition`,S===e?`bg-violet-500/25 text-violet-700 dark:text-violet-200`:`text-muted-foreground hover:text-foreground`),children:t(e===`graph`?`activity:sddBoard.graphLabel`:`activity:sddBoard.kanbanLabel`)},e))}),D&&($?.failed??0)>0&&(0,W.jsxs)(`button`,{type:`button`,onClick:oe,title:t(`activity:sddBoard.retryAllTitle`),className:`inline-flex items-center gap-1 rounded-md bg-orange-500/15 px-2.5 py-1 text-xs font-medium text-orange-600 dark:text-orange-300 hover:bg-orange-500/25`,children:[(0,W.jsx)(i,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.retryFailed`,{count:$?.failed??0})]}),D&&(0,W.jsxs)(W.Fragment,{children:[r?.status===`paused`?(0,W.jsxs)(`button`,{type:`button`,onClick:()=>k({type:`sdd.board.resume`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-sky-500/15 px-2.5 py-1 text-xs font-medium text-sky-600 dark:text-sky-300 hover:bg-sky-500/25`,children:[(0,W.jsx)(c,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.resume`)]}):(0,W.jsxs)(`button`,{type:`button`,onClick:()=>k({type:`sdd.board.pause`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-amber-500/15 px-2.5 py-1 text-xs font-medium text-amber-600 dark:text-amber-300 hover:bg-amber-500/25`,children:[(0,W.jsx)(te,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.pause`)]}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>k({type:`sdd.board.stop`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-red-500/15 px-2.5 py-1 text-xs font-medium text-red-600 dark:text-red-300 hover:bg-red-500/25`,children:[(0,W.jsx)(m,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.stop`)]})]}),r&&!D&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`button`,{type:`button`,onClick:L,title:t(`activity:sddBoard.cleanTitle`),className:`inline-flex items-center gap-1 rounded-md bg-slate-500/15 px-2.5 py-1 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-500/25`,children:[(0,W.jsx)(f,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.cleanWorktrees`)]}),(r.mergedCommits?.length??0)>0&&(0,W.jsxs)(`button`,{type:`button`,onClick:z,title:t(`activity:sddBoard.rollbackTitle`,{count:r.mergedCommits?.length??0,base:r.baseBranch??t(`activity:sdd.baseBranchFallback`)}),className:`inline-flex items-center gap-1 rounded-md bg-amber-500/15 px-2.5 py-1 text-xs font-medium text-amber-600 dark:text-amber-300 hover:bg-amber-500/25`,children:[(0,W.jsx)(g,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.rollback`,{count:r.mergedCommits?.length??0})]})]}),r&&(l?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-red-500/15 px-2.5 py-1 text-xs font-medium text-red-600 dark:text-red-300`,children:[(0,W.jsx)(i,{className:`h-3.5 w-3.5 animate-spin`}),` `,t(D?`activity:sddBoard.stopping`:`activity:sddBoard.destroying`)]}):(0,W.jsxs)(`button`,{type:`button`,onClick:()=>E(!0),title:t(`activity:sddBoard.destroyTitle`),className:`inline-flex items-center gap-1 rounded-md bg-red-600/90 px-2.5 py-1 text-xs font-medium text-white hover:bg-red-700`,children:[(0,W.jsx)(v,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.destroy`)]})),(0,W.jsx)(j,{variant:`ghost`,size:`icon`,onClick:e,children:(0,W.jsx)(d,{className:`h-4 w-4`})})]})]}),r&&$&&(0,W.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-5`,children:[(0,W.jsx)(se,{pct:$.percentComplete}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,W.jsx)(Q,{label:t(`activity:sddBoard.statDone`),value:`${$.completed}/${$.total}`,color:`text-emerald-600 dark:text-emerald-300`}),$.inProgress>0&&(0,W.jsx)(Q,{label:t(`activity:sddBoard.statRunning`),value:$.inProgress,color:`text-amber-600 dark:text-amber-300`}),$.failed>0&&(0,W.jsx)(Q,{label:t(`activity:sddBoard.statFailed`),value:$.failed,color:`text-red-600 dark:text-red-300`}),(0,W.jsx)(Q,{label:t(`activity:sddBoard.statWave`),value:r.wave+1,color:`text-violet-600 dark:text-violet-300`}),D&&r.startedAt>0&&(0,W.jsx)(Q,{label:t(`activity:sddBoard.statElapsed`),value:V(y-r.startedAt),color:`text-foreground`})]}),(0,W.jsx)(`div`,{className:`flex min-h-[24px] items-center gap-1.5`,children:K.length===0?(0,W.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:sddBoard.noActiveWorkers`)}):K.map((e,t)=>(0,W.jsxs)(`span`,{title:`${e.name} → ${e.task}`,className:`flex items-center gap-1 rounded-full bg-muted py-0.5 pl-0.5 pr-2`,children:[(0,W.jsx)(`span`,{className:C(`sdd-agent-live flex h-5 w-5 items-center justify-center rounded-full text-[9px] font-bold text-white`,R[t%R.length]),children:P(e.name)}),(0,W.jsx)(`span`,{className:`max-w-[90px] truncate text-[11px] text-foreground`,children:e.name})]},e.name))})]})]})]}),o&&(0,W.jsx)(ce,{result:o,onDismiss:()=>_(null)}),he.length>0&&(0,W.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-rose-500/30 bg-rose-500/5 px-4 py-2 text-xs text-rose-600 dark:text-rose-300`,children:[(0,W.jsx)(s,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`font-semibold`,children:t(`activity:sddBoard.deadlock`)}),he.map(e=>(0,W.jsxs)(`div`,{className:`font-mono`,children:[e.blocked,` ← `,e.blockedBy.join(`, `)]},e.blocked))]})]}),(0,W.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:r?S===`graph`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(H,{tasks:B,columns:r.columns,onTaskClick:J}),(0,W.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 left-1/2 -translate-x-1/2 rounded-full bg-black/40 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur`,children:t(`activity:sddBoard.clickTaskHint`)})]}):(0,W.jsx)(q,{tasks:r.tasks,selectedId:b,onTaskClick:J}):(0,W.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground`,children:[(0,W.jsx)(u,{className:`h-10 w-10 text-violet-500/40`}),(0,W.jsx)(`p`,{className:`text-foreground`,children:t(`activity:sddBoard.noRunTitle`)}),(0,W.jsx)(`p`,{className:`max-w-sm text-center text-xs text-muted-foreground`,children:t(`activity:sddBoard.noRunBody`)})]})}),r&&(0,W.jsx)(`aside`,{className:`w-80 shrink-0 border-l border-border bg-card`,children:me?(0,W.jsx)(ae,{task:me,allTasks:r.tasks,feed:r.feed??[],now:y,modelCandidates:pe,defaultModel:r.defaultModel,onClose:()=>x(null),onRetry:Y,onReassign:X,onSetModel:Z,onSetVerification:le,onCancel:ue,onDelete:de,onSplit:fe,onSelectTask:x},me.id):(0,W.jsx)(ie,{feed:r.feed??[],now:y})})]}),(0,W.jsx)(G,{open:re,onOpenChange:E,snapshot:r,busy:l,onConfirm:F})]})}function Z(e){let t=e.op===`cleanup_worktrees`?`lcClean`:e.op===`rollback`?`lcRollback`:`lcDestroy`,n=_.t(`activity:sddBoard.${t}`);if(!e.ok)return _.t(`activity:sddBoard.lcFailed`,{op:n,reason:e.reason??_.t(`activity:sddBoard.lcUnknownError`)});let r=[];typeof e.removed==`number`&&r.push(_.t(`activity:sddBoard.lcWorktrees`,{count:e.removed})),typeof e.reverted==`number`&&e.reverted>0&&r.push(_.t(`activity:sddBoard.lcCommits`,{count:e.reverted})),e.deleted?.length&&r.push(_.t(`activity:sddBoard.lcDeleted`,{items:e.deleted.join(`, `)}));let i=r.length?r.join(` · `):_.t(`activity:sddBoard.lcNothing`);return e.reason?_.t(`activity:sddBoard.lcNote`,{op:n,body:i,reason:e.reason}):_.t(`activity:sddBoard.lcOk`,{op:n,body:i})}function ce({result:e,onDismiss:t}){let n=!e.ok||!!e.reason;return(0,W.jsxs)(`div`,{className:C(`flex items-start gap-2 border-b px-4 py-2 text-xs`,n?`border-amber-500/30 bg-amber-500/5 text-amber-700 dark:text-amber-300`:`border-emerald-500/30 bg-emerald-500/5 text-emerald-700 dark:text-emerald-300`),children:[n?(0,W.jsx)(r,{className:`mt-0.5 h-4 w-4 shrink-0`}):(0,W.jsx)(x,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,W.jsx)(`span`,{className:`flex-1`,children:Z(e)}),(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 opacity-60 hover:opacity-100`,children:(0,W.jsx)(d,{className:`h-3.5 w-3.5`})})]})}function Q({label:e,value:t,color:n}){return(0,W.jsxs)(`span`,{className:`flex items-baseline gap-1`,children:[(0,W.jsx)(`span`,{className:C(`font-semibold tabular-nums`,n),children:t}),(0,W.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e})]})}export{X as SddBoardView};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{m as t,p as n}from"./markdown-D0X23O-i.js";import{Ir as r,Lt as i,St as ee,Vr as a,Z as te,Zt as ne,_r as o,br as s,ci as re,gr as c,it as l,jt as ie,mt as u,pr as d}from"./vendor-Ch4m_qLI.js";import"./i18n-CNo6A2vu.js";import{t as f}from"./utils-DBns3uMk.js";import{C as p,O as m,a as ae,i as h,o as oe,p as g,w as _}from"./index-CWj2bI87.js";import{c as v,t as se}from"./SddFlowGraph-CtMpzU4S.js";var y=e(t(),1),b=n(),x={idle:`phaseStart`,questioning:`phaseInterview`,spec_review:`phaseSpecReview`,implementation:`phasePlanning`,task_review:`phaseTaskReview`,executing:`phaseRunning`,done:`phaseDone`},S=[`questioning`,`spec_review`,`implementation`,`task_review`,`executing`];function C({onClose:e}){let{t}=re(),{client:n}=p(),s=m(e=>e.snapshot),l=m(e=>e.agentText),C=m(e=>e.error),E=m(e=>e.startedRunId),D=m(e=>e.setStartedRunId),[O,ce]=(0,y.useState)(``),[k,A]=(0,y.useState)(``),[j,M]=(0,y.useState)(!1),[N,le]=(0,y.useState)(!0),[P,ue]=(0,y.useState)(!0),[F,I]=(0,y.useState)(!1),[L,R]=(0,y.useState)(void 0),[z,B]=(0,y.useState)(void 0),[V,H]=(0,y.useState)([]),[U,de]=(0,y.useState)(4),[W,fe]=(0,y.useState)(!0),G=oe(F),K=(0,y.useCallback)(e=>n?.send?.(e),[n]),q=(0,y.useRef)(null);(0,y.useEffect)(()=>{K({type:`sdd.spec.get`})},[K]),(0,y.useEffect)(()=>{q.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[s?.answers.length??0,l]),(0,y.useEffect)(()=>{E&&(_(`sddboard`),D(null))},[E,D]);let J=s?.busy??!1,Y=s?.phase??`idle`,X=!!s;(0,y.useEffect)(()=>{X&&M(!1)},[X]);let pe=s?.answers[s.answers.length-1]?.question??``,me=!!s&&(s.taskCount>0||!!s.graphId||Y===`task_review`||Y===`executing`),Z=()=>{let e=O.trim();!e||J||j||(M(!0),K({type:`sdd.spec.start`,payload:{goal:e}}))},Q=()=>{let e=k.trim();!e||J||(K({type:`sdd.spec.message`,payload:{text:e}}),A(``))},he=()=>!J&&K({type:`sdd.spec.approve`,payload:{}}),ge=()=>{K({type:`sdd.run.start`,payload:{parallelSlots:U,worktrees:W,...L?{model:L,provider:z}:{},...V.length?{fallbackModels:V}:{}}}),I(!1)},$=(0,y.useMemo)(()=>(s?.board?.tasks??[]).map(e=>({id:e.id,shortId:e.shortId,title:e.title,displayStatus:e.displayStatus,priority:e.priority,deps:e.deps,agentName:e.agentName,worktreeBranch:e.worktreeBranch,retries:e.retries})),[s?.board]),_e=$.length>0;return(0,b.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,b.jsxs)(`header`,{className:`sdd-sheen flex shrink-0 items-center justify-between border-b border-border px-4 py-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(r,{className:`h-5 w-5 text-violet-400`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h1`,{className:`text-lg font-semibold`,children:s?.title||t(`activity:sddWizard.titleFallback`)}),X&&(0,b.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t(`activity:sddWizard.${x[Y]??`phaseStart`}`),Y===`questioning`&&` · ${t(`activity:sddWizard.questionsSuffix`,{cur:s?.questionCount??0,max:s?.maxQuestions??0})}`,s&&s.taskCount>0?` · ${t(`activity:sddWizard.tasksSuffix`,{count:s.taskCount})}`:``]})]}),J&&(0,b.jsx)(a,{className:`h-4 w-4 animate-spin text-muted-foreground`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[me&&(0,b.jsxs)(`div`,{className:`relative flex items-center gap-1.5`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>I(e=>!e),title:t(`activity:sddWizard.runCfgTitle`),className:f(`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs font-medium`,L||V.length?`border-violet-500/40 bg-violet-500/10 text-violet-600 dark:text-violet-300`:`border-border bg-muted text-muted-foreground hover:text-foreground`),children:[(0,b.jsx)(ee,{className:`h-3.5 w-3.5`}),L||t(`activity:sddWizard.modelsLabel`)]}),(0,b.jsxs)(`button`,{type:`button`,onClick:ge,className:`inline-flex items-center gap-1 rounded-md bg-emerald-500/15 px-2.5 py-1 text-xs font-medium text-emerald-700 hover:bg-emerald-500/25 dark:text-emerald-400`,children:[(0,b.jsx)(i,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddWizard.startRun`)]}),F&&(0,b.jsxs)(`div`,{className:`sdd-rise absolute right-0 top-9 z-50 w-72 rounded-lg border border-border bg-popover p-3 shadow-xl`,children:[(0,b.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.defaultWorkerModel`)}),(0,b.jsx)(ae,{value:L,provider:z,candidates:G,placeholder:t(`activity:sddWizard.leaderDefaultPlaceholder`),resetLabel:t(`activity:sddWizard.useSessionDefault`),onPick:(e,t)=>{R(e),B(t)},onReset:L?()=>{R(void 0),B(void 0)}:void 0}),(0,b.jsx)(`div`,{className:`mb-1 mt-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.fallbackChain`)}),(0,b.jsx)(h,{value:V,candidates:G,onChange:H}),(0,b.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:t(`activity:sddWizard.appliesToAll`)}),(0,b.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,b.jsx)(`label`,{htmlFor:`sdd-slots`,className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.parallelAgents`)}),(0,b.jsx)(`input`,{id:`sdd-slots`,type:`number`,min:1,max:16,value:U,onChange:e=>{let t=Number.parseInt(e.target.value,10);de(Number.isFinite(t)?Math.min(16,Math.max(1,t)):1)},className:`w-16 rounded-md border border-border bg-background px-2 py-1 text-right text-xs outline-none focus:border-violet-500`})]}),(0,b.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.isolateWorktrees`)}),(0,b.jsx)(`input`,{type:`checkbox`,checked:W,onChange:e=>fe(e.target.checked),className:`h-3.5 w-3.5 accent-violet-500`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:t(W?`activity:sddWizard.worktreeOn`:`activity:sddWizard.worktreeOff`)})]})]}),(0,b.jsx)(g,{variant:`ghost`,size:`icon`,onClick:e,children:(0,b.jsx)(te,{className:`h-4 w-4`})})]})]}),X&&(0,b.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b bg-card/50 px-4 py-1.5 text-[11px]`,children:S.map((e,n)=>{let r=e===Y,i=S.indexOf(Y)>n;return(0,b.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,b.jsxs)(`span`,{className:f(`rounded-full px-2 py-0.5`,r?`bg-violet-500/20 text-violet-600 dark:text-violet-300`:i?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`),children:[i&&(0,b.jsx)(o,{className:`mr-0.5 inline h-3 w-3`}),t(`activity:sddWizard.${x[e]}`)]}),n<S.length-1&&(0,b.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`})]},e)})}),(0,b.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:[C&&(0,b.jsx)(`div`,{className:`mb-3 rounded-md border border-red-500/40 bg-red-500/5 p-2 text-xs text-red-300`,children:C}),X?(0,b.jsxs)(`div`,{className:`space-y-4`,children:[_e&&(0,b.jsxs)(`div`,{className:`sdd-rise overflow-hidden rounded-lg border border-violet-500/20 bg-[#0a0d14]`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>le(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-white/5 px-3 py-1.5 text-[11px] font-medium text-violet-300 hover:bg-white/5`,children:[N?(0,b.jsx)(c,{className:`h-3.5 w-3.5`}):(0,b.jsx)(d,{className:`h-3.5 w-3.5`}),(0,b.jsx)(ne,{className:`h-3.5 w-3.5`}),t(`activity:sddWizard.taskGraphSummary`,{count:s?.taskCount??0}),(0,b.jsx)(`span`,{className:`ml-auto text-slate-500`,children:t(N?`activity:sddWizard.dragToExplore`:`activity:sddWizard.show`)})]}),N&&(0,b.jsx)(`div`,{className:`h-[32dvh] min-h-[200px]`,children:(0,b.jsx)(se,{tasks:$,columns:s?.board?.columns??[]})})]}),(0,b.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-3`,children:[s?.goal&&(0,b.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,b.jsx)(u,{className:`h-3 w-3`}),` `,t(`activity:sddWizard.goalLabel`)]}),(0,b.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:s.goal})]}),s?.answers.length||l&&Y===`questioning`||J?(0,b.jsxs)(`div`,{className:`space-y-2.5`,children:[s?.answers.map((e,t)=>(0,b.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,b.jsx)(T,{role:`assistant`,text:e.question}),(0,b.jsx)(T,{role:`user`,text:e.answer})]},t)),l&&Y===`questioning`&&l!==pe&&(0,b.jsx)(T,{role:`assistant`,text:l}),J&&(0,b.jsx)(T,{role:`assistant`,text:``,thinking:!0})]}):null,s?.spec&&(0,b.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card p-3`,children:[(0,b.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-semibold`,children:[(0,b.jsx)(r,{className:`h-3.5 w-3.5 text-violet-400`}),s.spec.title]}),(0,b.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:s.spec.overview}),(0,b.jsx)(`ul`,{className:`space-y-0.5 text-xs`,children:s.spec.requirements.map((e,t)=>(0,b.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,b.jsx)(`span`,{className:f(`shrink-0 font-mono uppercase`,v(e.priority).text),children:e.priority[0]}),(0,b.jsx)(`span`,{children:e.description})]},t))})]}),l&&(Y===`implementation`||Y===`task_review`)&&(0,b.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>ue(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-border/60 px-3 py-2 text-sm font-semibold hover:bg-muted/40`,children:[P?(0,b.jsx)(c,{className:`h-3.5 w-3.5`}):(0,b.jsx)(d,{className:`h-3.5 w-3.5`}),(0,b.jsx)(r,{className:`h-3.5 w-3.5 text-violet-400`}),` `,t(`activity:sddWizard.implementationPlan`)]}),P&&(0,b.jsx)(`div`,{className:`max-h-[40dvh] overflow-auto px-3 py-2`,children:(0,b.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:w(l)})})]}),l&&Y!==`questioning`&&Y!==`implementation`&&Y!==`task_review`&&!s?.spec&&(0,b.jsx)(T,{role:`assistant`,text:l}),(Y===`spec_review`||Y===`implementation`||Y===`task_review`)&&(0,b.jsxs)(g,{variant:`secondary`,onClick:he,disabled:J,children:[(0,b.jsx)(o,{className:`mr-1.5 h-4 w-4`}),t(Y===`spec_review`?`activity:sddWizard.approveSpec`:Y===`task_review`?`activity:sddWizard.approveTasks`:`activity:sddWizard.approvePlan`)]}),(0,b.jsx)(`div`,{ref:q})]})]}):(0,b.jsxs)(`div`,{className:`mx-auto mt-8 max-w-xl`,children:[(0,b.jsx)(`label`,{className:`mb-2 block text-sm font-medium`,htmlFor:`sdd-goal`,children:t(`activity:sddWizard.goalPrompt`)}),(0,b.jsx)(`textarea`,{id:`sdd-goal`,value:O,onChange:e=>ce(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&Z()},rows:4,placeholder:t(`activity:sddWizard.goalPlaceholder`),className:`w-full resize-none rounded-md border border-border bg-card px-3 py-2 text-sm outline-none focus:border-violet-500`}),(0,b.jsx)(g,{className:`mt-3`,onClick:Z,disabled:!O.trim()||j,children:j?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a,{className:`mr-1.5 h-4 w-4 animate-spin`}),` `,t(`activity:sddWizard.startingInterview`)]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r,{className:`mr-1.5 h-4 w-4`}),` `,t(`activity:sddWizard.startInterview`)]})}),(0,b.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:t(`activity:sddWizard.introBody`)})]})]}),X&&Y!==`executing`&&Y!==`done`&&(0,b.jsxs)(`div`,{className:`flex shrink-0 items-end gap-2 border-t bg-card px-4 py-2`,children:[(0,b.jsx)(`textarea`,{value:k,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Q())},rows:1,placeholder:t(Y===`questioning`?`activity:sddWizard.answerPlaceholder`:`activity:sddWizard.changePlaceholder`),disabled:J,className:`max-h-32 flex-1 resize-none rounded-md border border-border bg-background px-3 py-2 text-sm outline-none focus:border-violet-500 disabled:opacity-50`}),(0,b.jsx)(g,{size:`icon`,onClick:Q,disabled:J||!k.trim(),children:(0,b.jsx)(ie,{className:`h-4 w-4`})})]})]})}function w(e){let t=e.replace(/```json[\s\S]*?```/gi,``).trim();return t.length>0?t:e.trim()}function T({role:e,text:t,live:n,thinking:r}){let i=e===`user`;return(0,b.jsxs)(`div`,{className:f(`sdd-rise flex items-start gap-2`,i&&`flex-row-reverse`),children:[(0,b.jsx)(`span`,{className:f(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,i?`bg-sky-500/20 text-sky-600 dark:text-sky-300`:`bg-violet-500/20 text-violet-600 dark:text-violet-300`,(n||r)&&`sdd-agent-live`),children:i?(0,b.jsx)(l,{className:`h-3.5 w-3.5`}):(0,b.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(`div`,{className:f(`max-w-[80%] whitespace-pre-wrap rounded-2xl px-3 py-2 text-sm leading-relaxed text-foreground`,i?`rounded-tr-sm bg-sky-500/15`:`rounded-tl-sm bg-muted`),children:r?(0,b.jsxs)(`span`,{className:`flex items-center gap-1 py-0.5`,children:[(0,b.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-200ms]`}),(0,b.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-100ms]`}),(0,b.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground`})]}):t})]})}export{C as SddWizard};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{c as t,m as n,o as r,p as i}from"./markdown-D0X23O-i.js";import{Bt as ee,Ir as te,Jt as ne,Kt as re,Ln as ie,On as ae,Qn as oe,Tr as se,Un as ce,Vr as a,Z as o,_r as le,ar as ue,ci as s,di as c,dt as de,hr as fe,pr as pe,t as me,xr as he}from"./vendor-Ch4m_qLI.js";import"./i18n-CNo6A2vu.js";import{n as l}from"./ui-store-BdOsq6T-.js";import{t as u}from"./utils-DBns3uMk.js";import{C as ge,T as _e,d}from"./index-CWj2bI87.js";var f=e(n(),1),p=i();function m(e){return e===`project`||e===`user`}function h(e){let t=e.match(/^(.+?)\/SKILL(?:\.save)?\.md$/);return t?t[1]:null}function ve({source:e}){let{t}=s(),n=e===`project`?`project`:e===`user`?`user`:`bundled`;return(0,p.jsx)(`span`,{className:u(`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide`,n===`project`&&`bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-400`,n===`user`&&`bg-violet-100 text-violet-700 dark:bg-violet-950 dark:text-violet-400`,n===`bundled`&&`bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400`),children:t(`activity:skillDetail.${{project:`scopeProject`,user:`scopeGlobal`,bundled:`scopeBundled`}[n]}`)})}function g({className:e}){let{t:n}=s(),{client:i}=ge(),g=l(e=>e.skillsState),_=l(e=>e.setSkillsState),v=g.selectedSkill,y=g.navHistory,b=g.historyIndex,[x,S]=(0,f.useState)(null),[ye,C]=(0,f.useState)(!1),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(``),[A,j]=(0,f.useState)(!1),[M,N]=(0,f.useState)(null),[P,F]=(0,f.useState)(!1),[I,L]=(0,f.useState)(null),[R,z]=(0,f.useState)(!1),B=(0,f.useRef)(``),[V,H]=(0,f.useState)(!1),[U,W]=(0,f.useState)(null),[be,xe]=(0,f.useState)(!1),[G,K]=(0,f.useState)(null),[q,Se]=(0,f.useState)(!1),[Ce,we]=(0,f.useState)([]),J=(0,f.useRef)(g);J.current=g;let Y=(0,f.useRef)(!1),X=(0,f.useMemo)(()=>O?{lines:O.split(`
2
- `).length,words:O.trim()?O.trim().split(/\s+/).length:0,chars:O.length}:{lines:0,words:0,chars:0},[O]),Z=(0,f.useMemo)(()=>{if(!O)return null;let e=5*1024*1024,t=new Blob([O]).size;return t>=e?{level:`critical`,used:t,limit:e}:t>=4194304?{level:`warn`,used:t,limit:e}:null},[O]);(0,f.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>L(null),2e3);return()=>clearTimeout(e)},[I]),(0,f.useEffect)(()=>{if(!E||!v)return;let e=setInterval(()=>{O&&O!==B.current&&(B.current=O,localStorage.setItem(`skills_draft_${v.name}`,JSON.stringify({content:O,savedAt:Date.now()})),L(Date.now()))},5e3);return()=>clearInterval(e)},[E,O,v]),(0,f.useEffect)(()=>{if(!v||!E)return;let e=localStorage.getItem(`skills_draft_${v.name}`);if(e)try{let{content:t}=JSON.parse(e);t&&t!==O&&t!==B.current&&(k(t),B.current=t,z(!0))}catch{}},[v?.name,E]),(0,f.useEffect)(()=>{if(!i||!v)return;C(!0),S(null),T(null);let e=setTimeout(()=>{C(!1),T(c.t(`activity:skillDetail.timeoutError`))},1e4),t=t=>{clearTimeout(e);let n=t;n.payload.error?T(n.payload.error):n.payload.name&&S(n.payload),C(!1)},n=e=>{let t=e;H(!1);let n=J.current;if(t.payload.success){let e={...n.knownRefs};for(let n of t.payload.updated??[])e[n.name]=n.newRef;_({...n,knownRefs:e,updateAvailableCount:0}),W({updated:t.payload.updated??[],unchanged:t.payload.unchanged??[],errors:t.payload.errors??[]}),i.send({type:`skills.list`})}else W({updated:[],unchanged:[],errors:[{name:``,error:t.payload.error??c.t(`activity:skillDetail.updateFailed`)}]})},r=e=>{let t=e;t.payload.skills&&we(t.payload.skills)};return i.on(`skills.content`,t),i.on(`skills.updated`,n),i.on(`skills.list`,r),i.send({type:`skills.content`,payload:{name:v.name,source:v.source}}),()=>{clearTimeout(e),i.off(`skills.content`,t),i.off(`skills.updated`,n),i.off(`skills.list`,r)}},[i,v?.name,v?.source]),(0,f.useEffect)(()=>{E&&(D(!1),k(``),N(null))},[v?.name]);let Q=(0,f.useCallback)(e=>Ce.find(t=>t.name.toLowerCase()===e.toLowerCase()),[Ce]),Te=(0,f.useCallback)(e=>{let t=Q(e);if(t){Y.current=!1;let e=y.slice(0,b+1);e.push(t),_({...J.current,selectedSkill:t,navHistory:e,historyIndex:e.length-1}),D(!1),k(``),W(null)}},[Q,y,b,_]),Ee=(0,f.useCallback)(()=>{if(b<=0)return;Y.current=!0;let e=b-1,t=y[e];_({...J.current,selectedSkill:t,historyIndex:e}),D(!1),k(``),W(null)},[b,y,_]),De=(0,f.useCallback)(()=>{if(b>=y.length-1)return;Y.current=!0;let e=b+1,t=y[e];_({...J.current,selectedSkill:t,historyIndex:e}),D(!1),k(``),W(null)},[b,y,_]),$=(0,f.useCallback)(()=>{_e(`chat`)},[]),Oe=(0,f.useCallback)(()=>{x&&(k(x.body),B.current=x.body,z(!1),N(null),D(!0),F(!1))},[x]),ke=(0,f.useCallback)(()=>{D(!1),k(``),N(null),F(!1),z(!1),v&&localStorage.removeItem(`skills_draft_${v.name}`)},[v]),Ae=(0,f.useCallback)(()=>{!v||!x||(z(!1),k(x.body),B.current=x.body,v&&localStorage.removeItem(`skills_draft_${v.name}`))},[v,x]),je=(0,f.useCallback)(()=>{if(!i||!v||!O.trim())return;j(!0),N(null);let e=t=>{let n=t;j(!1),n.payload.success?(B.current=``,localStorage.removeItem(`skills_draft_${v.name}`),z(!1),D(!1),i.send({type:`skills.content`,payload:{name:v.name,source:v.source}}),i.send({type:`skills.list`})):N(n.payload.error??c.t(`activity:skillDetail.saveFailed`)),i.off(`skills.edited`,e)};i.on(`skills.edited`,e),i.editSkill(v.name,O)},[i,v,O]),Me=(0,f.useCallback)(()=>{!i||!v||(H(!0),W(null),i.checkForUpdates(v.name,v.source===`user`))},[i,v]),Ne=(0,f.useCallback)(()=>{v?.sourceUrl&&navigator.clipboard.writeText(v.sourceUrl).then(()=>{xe(!0),setTimeout(()=>xe(!1),2e3)})},[v]),Pe=(0,f.useCallback)(()=>{if(!x?.body)return;let e=new Blob([x.body],{type:`text/markdown`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${x.name.replace(/\//g,`_`)}-SKILL.md`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},[x]),Fe=(0,f.useCallback)(async e=>{if(!i||!e)return;Se(!0);let t=e=>{let n=e;Se(!1),n.payload.success?(K(null),i.send({type:`skills.list`}),$()):N(n.payload.error??c.t(`activity:skillDetail.uninstallFailed`)),i.off(`skills.uninstalled`,t)};i.on(`skills.uninstalled`,t),i.uninstallSkill(e.name,e.source===`user`)},[i,$]);return v?(0,p.jsxs)(`div`,{className:u(`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-background`,e),children:[(0,p.jsxs)(`div`,{className:`px-4 py-3 border-b bg-card shrink-0`,children:[(0,p.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(te,{className:`h-4 w-4 text-primary shrink-0`}),(0,p.jsx)(`h1`,{className:`text-base font-semibold truncate`,children:v.name}),v.version&&(0,p.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,v.version]}),(0,p.jsx)(ve,{source:v.source})]}),(0,p.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:v.description||v.trigger}),v.sourceUrl&&(0,p.jsxs)(`div`,{className:`flex items-center gap-1 mt-2`,children:[(0,p.jsxs)(`a`,{href:`https://${v.sourceUrl.replace(`github:`,``)}`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:n(`activity:skillDetail.openSourceRepo`),children:[(0,p.jsx)(ae,{className:`h-3 w-3 shrink-0`}),(0,p.jsx)(`span`,{className:`truncate font-mono`,children:v.sourceUrl})]}),(0,p.jsx)(`button`,{type:`button`,onClick:Ne,className:`flex items-center shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:n(`activity:skillDetail.copySourceUrl`),children:be?(0,p.jsx)(le,{className:`h-3 w-3 text-green-500`}):(0,p.jsx)(ue,{className:`h-3 w-3`})})]}),v.scope.length>0&&(0,p.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:v.scope.map(e=>(0,p.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-muted text-muted-foreground`,children:e},e))}),U&&(0,p.jsxs)(`div`,{className:`mt-2 text-xs space-y-1`,children:[U.updated.length>0&&(0,p.jsx)(`div`,{className:`text-green-600`,children:n(`activity:skillDetail.updatedLabel`,{list:U.updated.map(e=>`${e.name} (${e.oldRef} → ${e.newRef})`).join(`, `)})}),U.unchanged.length>0&&(0,p.jsx)(`div`,{className:`text-muted-foreground`,children:n(`activity:skillDetail.upToDateLabel`,{list:U.unchanged.join(`, `)})}),U.errors.length>0&&(0,p.jsx)(`div`,{className:`text-destructive`,children:n(`activity:skillDetail.errorsLabel`,{list:U.errors.map(e=>`${e.name?`${e.name}: `:``}${e.error}`).join(`; `)})})]})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto shrink-0`,children:[m(v.source)&&v.sourceUrl&&(0,p.jsx)(`button`,{type:`button`,onClick:Me,disabled:V,className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer disabled:opacity-50`,title:n(`activity:skillDetail.checkUpdatesTitle`),children:V?(0,p.jsx)(a,{className:`h-3.5 w-3.5 animate-spin`}):(0,p.jsx)(ee,{className:`h-3.5 w-3.5`})}),v.source!==`bundled`&&!E&&(0,p.jsx)(`button`,{type:`button`,onClick:Pe,className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer`,title:n(`activity:skillDetail.exportTitle`),children:(0,p.jsx)(oe,{className:`h-3.5 w-3.5`})}),m(v.source)&&!E&&(0,p.jsx)(`button`,{type:`button`,onClick:Oe,className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer`,title:n(`activity:skillDetail.editTitle`),children:(0,p.jsx)(re,{className:`h-3.5 w-3.5`})}),m(v.source)&&(0,p.jsx)(`button`,{type:`button`,onClick:()=>K(v),className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors cursor-pointer`,title:n(`activity:skillDetail.uninstallTitle`),children:(0,p.jsx)(de,{className:`h-3.5 w-3.5`})}),(0,p.jsx)(`button`,{type:`button`,onClick:$,className:`p-1.5 rounded hover:bg-accent text-muted-foreground cursor-pointer`,title:n(`activity:skillDetail.closeTitle`),children:(0,p.jsx)(o,{className:`h-4 w-4`})})]})]}),y.length>1&&(0,p.jsxs)(`div`,{className:`flex items-center gap-1 mt-2`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:Ee,disabled:b<=0,className:u(`p-1 rounded transition-colors`,b<=0?`text-muted-foreground/40 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:n(`activity:skillDetail.backTitle`),children:(0,p.jsx)(fe,{className:`h-4 w-4`})}),(0,p.jsx)(`button`,{type:`button`,onClick:De,disabled:b>=y.length-1,className:u(`p-1 rounded transition-colors`,b>=y.length-1?`text-muted-foreground/40 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:n(`activity:skillDetail.forwardTitle`),children:(0,p.jsx)(pe,{className:`h-4 w-4`})}),(0,p.jsx)(`div`,{className:`flex items-center gap-0.5 overflow-x-auto text-xs`,children:y.map((e,t)=>(0,p.jsxs)(`span`,{className:`flex items-center shrink-0`,children:[t>0&&(0,p.jsx)(pe,{className:`h-3 w-3 text-muted-foreground/40 mx-0.5 shrink-0`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>{t<b&&(Y.current=!0,_({...J.current,selectedSkill:e,historyIndex:t}),D(!1),k(``),W(null))},className:u(`hover:text-primary cursor-pointer transition-colors`,t===b?`text-primary font-medium`:`text-muted-foreground`),children:e.name})]},e.name+t))})]})]}),x&&(x.relatedFiles.length>0||x.references.length>0)&&(0,p.jsxs)(`div`,{className:`px-4 py-2 border-b bg-muted/30 shrink-0 space-y-2`,children:[x.relatedFiles.length>0&&(0,p.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,p.jsx)(ie,{className:`h-3 w-3`}),(0,p.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:n(`activity:skillDetail.relatedFiles`)})]}),x.relatedFiles.map(e=>{let t=h(e);return t&&Q(t)?(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Te(t),className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded bg-background border border-border hover:border-primary hover:text-primary transition-colors cursor-pointer`,title:n(`activity:skillDetail.goToSkillTitle`,{name:t}),children:[(0,p.jsx)(se,{className:`h-2.5 w-2.5`}),e]},e):(0,p.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-background border border-border text-muted-foreground`,children:e},e)})]}),x.references.length>0&&(0,p.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,p.jsx)(ce,{className:`h-3 w-3`}),(0,p.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:n(`activity:skillDetail.references`)})]}),x.references.map(e=>{let t=h(e)??e.replace(/\.md$/,``);return Q(t)?(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Te(t),className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded bg-primary/5 border border-primary/20 text-primary hover:bg-primary/10 hover:border-primary/30 transition-colors cursor-pointer`,title:n(`activity:skillDetail.goToSkillTitle`,{name:t}),children:[(0,p.jsx)(se,{className:`h-2.5 w-2.5`}),t]},e):(0,p.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-muted text-muted-foreground`,children:t},e)})]})]}),(0,p.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:ye?(0,p.jsxs)(`div`,{className:`p-8 text-center text-muted-foreground`,children:[(0,p.jsx)(a,{className:`h-6 w-6 animate-spin mx-auto mb-2`}),(0,p.jsx)(`p`,{children:n(`activity:skillDetail.loadingContent`)})]}):E?(0,p.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,p.jsxs)(`div`,{className:`px-4 py-2 border-b shrink-0 flex items-center justify-between gap-2`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,p.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:skillDetail.editingLabel`,{name:v.name})}),(0,p.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:n(`activity:skillDetail.editStats`,{lines:X.lines,words:X.words,chars:X.chars})}),Z&&(0,p.jsx)(`span`,{className:`text-xs tabular-nums ${Z.level===`critical`?`text-red-500 font-medium`:`text-amber-500`}`,children:n(`activity:skillDetail.charsWarningFmt`,{used:(Z.used/(1024*1024)).toFixed(1),limit:(Z.limit/(1024*1024)).toFixed(0)})}),I&&(0,p.jsx)(`span`,{className:`text-xs text-green-500 animate-pulse`,children:n(`activity:skillDetail.draftSaved`)}),R&&(0,p.jsx)(`span`,{className:`text-xs text-amber-500 animate-pulse`,children:n(`activity:skillDetail.draftRestored`)})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[M&&(0,p.jsx)(`span`,{className:`text-xs text-destructive`,children:M}),R&&(0,p.jsx)(`button`,{type:`button`,onClick:Ae,className:`px-2 py-1 text-[10px] rounded border border-amber-500/50 text-amber-600 dark:text-amber-400 hover:bg-amber-500/10 transition-colors cursor-pointer`,children:n(`activity:skillDetail.discardDraft`)}),(0,p.jsx)(`button`,{type:`button`,onClick:ke,className:`px-2 py-1 text-xs rounded border border-border hover:bg-accent transition-colors cursor-pointer`,children:n(`common:action.cancel`)}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>F(e=>!e),title:n(P?`activity:skillDetail.hidePreviewTitle`:`activity:skillDetail.splitViewTitle`),className:`px-2 py-1 text-xs rounded border transition-colors cursor-pointer ${P?`border-primary bg-primary/10 text-primary`:`border-border hover:bg-accent text-muted-foreground`}`,children:(0,p.jsx)(ne,{className:`h-3 w-3 inline`})}),(0,p.jsx)(`button`,{type:`button`,onClick:je,disabled:A||!O.trim(),className:`px-3 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors cursor-pointer`,children:A?(0,p.jsx)(a,{className:`h-3 w-3 animate-spin inline`}):n(`common:action.save`)})]})]}),P?(0,p.jsxs)(`div`,{className:`flex flex-1 min-h-0 gap-0.5`,children:[(0,p.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0`,children:(0,p.jsx)(me,{value:O,onChange:e=>k(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:n(`activity:skillDetail.contentPlaceholder`)})}),(0,p.jsx)(`div`,{className:`w-px bg-border flex-shrink-0`}),(0,p.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-4 prose prose-sm dark:prose-invert max-w-none`,children:(0,p.jsx)(t,{rehypePlugins:[r],components:d,children:O})})]}):(0,p.jsx)(me,{value:O,onChange:e=>k(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:n(`activity:skillDetail.contentPlaceholder`)})]}):x?(0,p.jsx)(`div`,{className:`p-6 prose prose-sm dark:prose-invert max-w-none`,children:(0,p.jsx)(t,{rehypePlugins:[r],components:d,children:x.body})}):w?(0,p.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,p.jsx)(`p`,{className:`text-destructive mb-2`,children:n(`activity:skillDetail.loadFailed`)}),(0,p.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:w}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>{i&&v&&(C(!0),T(null),i.send({type:`skills.content`,payload:{name:v.name,source:v.source}}))},className:`mt-4 px-3 py-1.5 text-xs rounded border border-border hover:bg-accent transition-colors`,children:n(`common:action.retry`)})]}):(0,p.jsx)(`div`,{className:`p-8 text-center text-muted-foreground`,children:n(`activity:skillDetail.noContent`)})}),G&&(0,p.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,onClick:e=>{e.target===e.currentTarget&&K(null)},children:(0,p.jsxs)(`div`,{className:`flex max-h-[calc(100dvh-2rem)] w-[380px] max-w-[90vw] flex-col overflow-hidden rounded-lg border bg-background shadow-xl`,children:[(0,p.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between p-4 border-b`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(de,{className:`h-4 w-4 text-destructive`}),(0,p.jsx)(`span`,{className:`font-semibold text-sm`,children:n(`activity:skillDetail.uninstallSkillHeading`)})]}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>K(null),className:`p-1 rounded hover:bg-accent text-muted-foreground cursor-pointer`,children:(0,p.jsx)(o,{className:`h-4 w-4`})})]}),(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 space-y-2`,children:[(0,p.jsx)(`p`,{className:`text-sm`,children:n(`activity:skillDetail.uninstallConfirm`,{name:G.name})}),(0,p.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`activity:skillDetail.uninstallRemovePath`,{path:G.source===`user`?`~/.wrongstack/skills`:`.wrongstack/skills`})})]}),(0,p.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 p-4 border-t bg-muted/20`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>K(null),disabled:q,className:`px-3 py-1.5 text-xs rounded border border-border hover:bg-accent transition-colors disabled:opacity-50`,children:n(`common:action.cancel`)}),(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Fe(G),disabled:q,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[q&&(0,p.jsx)(a,{className:`h-3 w-3 animate-spin`}),n(`activity:skillDetail.uninstallAction`)]})]})]})})]}):(0,p.jsxs)(`div`,{className:u(`flex-1 flex flex-col items-center justify-center text-muted-foreground p-8`,e),children:[(0,p.jsx)(he,{className:`h-12 w-12 mb-4 opacity-20`}),(0,p.jsx)(`p`,{className:`text-base font-medium`,children:n(`activity:skillDetail.noSkillSelected`)}),(0,p.jsx)(`p`,{className:`text-sm mt-1 text-center max-w-[300px]`,children:n(`activity:skillDetail.selectSkillHint`)}),(0,p.jsx)(`button`,{type:`button`,onClick:$,className:`mt-4 px-4 py-2 text-sm rounded-md border border-border hover:bg-accent transition-colors`,children:n(`activity:skillDetail.goToChat`)})]})}export{g as SkillDetailView};