@wrongstack/webui 0.302.2 → 0.303.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AgentRosterView-BnnhSRau.js +9 -0
- package/dist/assets/{AnalyticsDashboard-C9aPEyov.js → AnalyticsDashboard-CMs176Dp.js} +1 -1
- package/dist/assets/{AudienceMemoryPanel-Bciki41o.js → AudienceMemoryPanel-BRXM47H1.js} +2 -2
- package/dist/assets/{ChangesView-DumffowD.js → ChangesView-DxAQY4v4.js} +1 -1
- package/dist/assets/ChronicleDashboard-DPI_5S2R.js +1 -0
- package/dist/assets/CodeEditor-9Fu9hRrw.js +1 -0
- package/dist/assets/CodeMap-B7YGx2G0.js +1 -0
- package/dist/assets/{ConfirmModal-CdKg3EOQ.js → ConfirmModal-DXy17_uy.js} +1 -1
- package/dist/assets/{CronJobsPanel-CJ7Vc1Am.js → CronJobsPanel-C_bGieGQ.js} +1 -1
- package/dist/assets/{DeadCodeScanPanel-DaeHUzc5.js → DeadCodeScanPanel-hkBvamWn.js} +2 -2
- package/dist/assets/{DebugDashboard-BI3EmXrM.js → DebugDashboard-CDWJ9nLR.js} +1 -1
- package/dist/assets/{DesignGalleryView-DMW6Ab__.js → DesignGalleryView-BG-p6kFX.js} +1 -1
- package/dist/assets/GoalView-CCklBpTx.js +1 -0
- package/dist/assets/KanbanView-Dzvn9y79.js +3 -0
- package/dist/assets/MailboxDetailView-7dtt5joR.js +1 -0
- package/dist/assets/MemoryDrawer-D2Yq9oba.js +1 -0
- package/dist/assets/MemoryManager-CL5AiyKr.js +1 -0
- package/dist/assets/{ModelPicker-IOZSUnqM.js → ModelPicker-BazB-GbH.js} +1 -1
- package/dist/assets/OfficeMapPanel-Dtb75DlY.js +4 -0
- package/dist/assets/{ProcessMonitor-TGqyXxmB.js → ProcessMonitor-BTjaxnO-.js} +1 -1
- package/dist/assets/{QueuePanel-5aMgQbHv.js → QueuePanel-BOD9qtHp.js} +1 -1
- package/dist/assets/{RefreshDebugView-DfBYFPEF.js → RefreshDebugView-DfbZ-vgF.js} +1 -1
- package/dist/assets/{RequirementIntakeView-CNAFKiQ3.js → RequirementIntakeView-CeZFJlrn.js} +1 -1
- package/dist/assets/SageTabs-BlK58zgb.js +2 -0
- package/dist/assets/SddFlowGraph-DWphr6Tr.js +1 -0
- package/dist/assets/SddHub-ZRkMmA7e.js +2 -0
- package/dist/assets/{SessionInspectView-CytBw7Y9.js → SessionInspectView-DqrSHseG.js} +1 -1
- package/dist/assets/SessionList-DLoIKc1b.js +1 -0
- package/dist/assets/{SessionsDashboard-CridPbkX.js → SessionsDashboard-CUj2WSYM.js} +1 -1
- package/dist/assets/SetupScreen-B_2CuLeR.js +1 -0
- package/dist/assets/SkillDetailView-ChspOaAw.js +3 -0
- package/dist/assets/{SpecsView-DUx1sgtH.js → SpecsView-Cl4vpAoL.js} +1 -1
- package/dist/assets/{TechStackView-CvUiAISX.js → TechStackView-DsFV85XT.js} +1 -1
- package/dist/assets/{TerminalPanel-Dg5hqYTA.js → TerminalPanel-GraS3zw1.js} +1 -1
- package/dist/assets/{Toaster-BgN2bRJx.js → Toaster-D76T-Ld4.js} +1 -1
- package/dist/assets/{button-Dcy288Mc.js → button-ELs5xgtQ.js} +1 -1
- package/dist/assets/{chat-store-DbxFVDwi.js → chat-store-CBJ1gc8n.js} +1 -1
- package/dist/assets/{codemap-activity-store-DQfjo7-j.js → codemap-activity-store-D67-genN.js} +1 -1
- package/dist/assets/codemap-index-store-ByAYIzQA.js +1 -0
- package/dist/assets/{dialog-ftgTihmF.js → dialog-CfAoIH8P.js} +1 -1
- package/dist/assets/{empty-state-RRSqQaCk.js → empty-state-BDwjdvMh.js} +1 -1
- package/dist/assets/{i18n-9T7iGYgW.js → i18n-BvFgJYE2.js} +2 -2
- package/dist/assets/index-BTRQG7C5.js +132 -0
- package/dist/assets/index-DHsJniTZ.css +1 -0
- package/dist/assets/{input-fo9-BPBC.js → input-DSTQkMEh.js} +1 -1
- package/dist/assets/{mailbox-store-C1mzoSqJ.js → mailbox-store-CKpkM0H1.js} +1 -1
- package/dist/assets/{roster-ws-Da57e_sI.js → roster-ws-a3-SO1Yb.js} +1 -1
- package/dist/assets/{session-store-Df7_hhe9.js → session-store-Ce4Dck2K.js} +1 -1
- package/dist/assets/settings-BUtmAZBV.js +1 -0
- package/dist/assets/settings-BlMNd_AC.js +1 -0
- package/dist/assets/settings-ClpzPWKE.js +1 -0
- package/dist/assets/settings-CyYYbmdR.js +1 -0
- package/dist/assets/settings-DyIEVRJT.js +1 -0
- package/dist/assets/settings-Orwkg3lH.js +1 -0
- package/dist/assets/settings-XRC0dC9D.js +1 -0
- package/dist/assets/{shared-KAzksK0C.js → shared-D368RBth.js} +1 -1
- package/dist/assets/stores-BATHCuMN.js +7 -0
- package/dist/assets/{ui-store-CE4-TlwB.js → ui-store-BGNdg1e4.js} +1 -1
- package/dist/assets/{useWebSocket-CZSpbA3M.js → useWebSocket-B2opfRwA.js} +3 -3
- package/dist/assets/utils-CUCQrODG.js +1 -0
- package/dist/assets/{vendor-BuarzSSb.js → vendor-GiKfK4Iw.js} +30 -30
- package/dist/assets/{view-navigation-DIDEcp4V.js → view-navigation-FdnvQSOv.js} +1 -1
- package/dist/assets/{ws-client-TTMa0XaT.js → ws-client-CGEB75Dy.js} +1 -1
- package/dist/components/KanbanContractGraphDashboard.d.ts +7 -0
- package/dist/components/KanbanContractGraphPanel.d.ts +7 -0
- package/dist/components/KanbanContractGraphView.d.ts +40 -0
- package/dist/components/KanbanViewModeTabs.d.ts +1 -1
- package/dist/components/KanbanWorkbench.d.ts +9 -0
- package/dist/components/TaskVerificationSection.d.ts +3 -3
- package/dist/components/agent-roster-data.d.ts +9 -0
- package/dist/index.html +22 -22
- package/dist/index.js +5260 -3984
- package/dist/lib/palettes.d.ts +1 -1
- package/dist/stores/kanban-store.d.ts +2 -1
- package/dist/stores/session-store.d.ts +2 -0
- package/dist/types/sage.d.ts +5 -13
- package/dist/types/system.d.ts +2 -0
- package/package.json +8 -8
- package/dist/assets/AgentRosterView-BwukmHoA.js +0 -9
- package/dist/assets/ChronicleDashboard-BYGV5twz.js +0 -1
- package/dist/assets/CodeEditor-D2Dnax7e.js +0 -1
- package/dist/assets/CodeMap-DIKKs3Ux.js +0 -1
- package/dist/assets/GoalView-3291Hxnb.js +0 -1
- package/dist/assets/KanbanView-CFE63A4a.js +0 -3
- package/dist/assets/MailboxDetailView-CUTWkSyK.js +0 -1
- package/dist/assets/MemoryDrawer-Dsy0AX6f.js +0 -1
- package/dist/assets/MemoryManager-D1kXeVE3.js +0 -1
- package/dist/assets/OfficeMapPanel-Q81eioDB.js +0 -4
- package/dist/assets/SageTabs-olgLJfg_.js +0 -2
- package/dist/assets/SddHub-7Z55QY-M.js +0 -2
- package/dist/assets/SessionList-C3ygQN8A.js +0 -1
- package/dist/assets/SetupScreen-BkVjdky4.js +0 -1
- package/dist/assets/SkillDetailView-Cp-xEHww.js +0 -3
- package/dist/assets/codemap-index-store-COStDU-8.js +0 -1
- package/dist/assets/index-Cw20Xg0d.css +0 -1
- package/dist/assets/index-FHt-sKVF.js +0 -132
- package/dist/assets/progress-ring-B9pqitSa.js +0 -1
- package/dist/assets/settings-Bb7_utQE.js +0 -1
- package/dist/assets/settings-Bd8zMwvC.js +0 -1
- package/dist/assets/settings-DdFgBMAw.js +0 -1
- package/dist/assets/settings-De6sXIFO.js +0 -1
- package/dist/assets/settings-E8SKMLxq.js +0 -1
- package/dist/assets/settings-zIY9-ivF.js +0 -1
- package/dist/assets/settings-zKBcRjqE.js +0 -1
- package/dist/assets/stores-vuG0AaKy.js +0 -7
- package/dist/assets/utils-B-9lSDIn.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,Cn as n,Dn as r,Ea as i,Ft as a,Mi as o,Mn as s,Nr as c,Ot as l,Pa as u,Qi as d,Ui as f,Vt as p,Wt as m,Xi as h,Zt as g,_,a as ee,an as v,dr as te,dt as ne,f as y,fa as re,fi as ie,i as b,ir as ae,jn as oe,jt as x,lt as S,n as C,oa as w,oi as T,r as E,s as D,un as se,vi as ce,vn as le,xa as ue,za as de,zn as fe,zr as pe}from"./vendor-BuarzSSb.js";import"./i18n-9T7iGYgW.js";import{t as me}from"./useWebSocket-CZSpbA3M.js";import{t as O}from"./utils-B-9lSDIn.js";import{I as he}from"./stores-vuG0AaKy.js";import{n as ge}from"./ui-store-CE4-TlwB.js";import{a as _e,i as ve,n as k,o as ye,r as A,t as j}from"./dialog-ftgTihmF.js";import{t as M}from"./button-Dcy288Mc.js";import{t as N}from"./input-fo9-BPBC.js";import{c as be}from"./index-FHt-sKVF.js";import{t as P}from"./roster-ws-Da57e_sI.js";import{_ as xe,a as Se,b as Ce,c as we,d as Te,f as Ee,g as F,h as I,i as L,l as R,m as z,n as De,o as Oe,p as ke,r as B,s as Ae,t as je,u as Me,v as Ne,y as V}from"./shared-KAzksK0C.js";import{t as Pe}from"./MemoryDrawer-Dsy0AX6f.js";var H=e(de(),1),U=S();function Fe({busyAction:e,deletingId:t,memories:n,onCancel:r,onConfirm:i,onOpenChange:a}){let{t:o}=u();return(0,U.jsx)(j,{open:!!t,onOpenChange:a,children:(0,U.jsxs)(k,{className:`max-w-md`,children:[(0,U.jsxs)(_e,{children:[(0,U.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,U.jsx)(x,{className:`size-4`})}),(0,U.jsx)(ye,{children:o(`activity:memoryManager.deleteTitle`)}),(0,U.jsx)(A,{className:`leading-6`,children:o(`activity:deleteMemoryDialog.sageWillMarkTheRecordDeleted`)})]}),(0,U.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:F(n.find(e=>e.id===t)?.text??``,180)}),(0,U.jsxs)(ve,{children:[(0,U.jsx)(M,{variant:`outline`,onClick:r,disabled:e===`delete`,children:o(`common:action.cancel`)}),(0,U.jsxs)(M,{variant:`destructive`,onClick:i,disabled:e===`delete`,children:[e===`delete`?(0,U.jsx)(ae,{className:`size-4 animate-spin`}):(0,U.jsx)(x,{className:`size-4`}),o(e===`delete`?`activity:memoryManager.deletingLabel`:`activity:memoryManager.actionDeleteMemory`)]})]})]})})}var W=212,Ie=188;function G(e){return e.length>14?`${e.slice(0,11)}…`:e}function Le(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function Re(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.role??e.type}function ze(e){return e===`active`?`border-success/45 bg-success/10 text-success`:e===`stale`?`border-warning/45 bg-warning/10 text-warning`:e===`contradicted`?`border-destructive/45 bg-destructive/10 text-destructive`:e===`superseded`?`border-warning/35 bg-warning/5 text-warning`:`border-border bg-muted/55 text-muted-foreground`}function Be({data:e}){let{entry:t,center:n}=e;return(0,U.jsxs)(`div`,{className:n?`border border-primary/70 bg-card px-3 py-2.5 text-card-foreground shadow-[0_0_0_1px_hsl(var(--primary)/0.2),0_0_24px_hsl(var(--primary)/0.12)]`:`border border-border/80 bg-card/95 px-3 py-2.5 text-card-foreground shadow-lg`,style:{width:W},title:t.text,children:[(0,U.jsx)(D,{type:`target`,position:_.Top,className:`!border-background !bg-muted-foreground`}),(0,U.jsx)(D,{type:`source`,position:_.Bottom,className:`!border-background !bg-primary`}),(0,U.jsx)(D,{type:`source`,position:_.Right,className:`!border-background !bg-primary`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${ze(t.status)}`,children:t.status}),(0,U.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:G(t.id)})]}),(0,U.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:Le(t.text)}),(0,U.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function Ve({data:e}){return(0,U.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:Ie},title:e.label,children:[(0,U.jsx)(D,{type:`target`,position:_.Left,className:`!border-background !bg-info`}),(0,U.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,U.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var He={memoryNode:Be,anchorNode:Ve};function Ue(e,t){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:t(`activity:memoryManager.memoryUnavailable`),importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function We({nodes:e,edges:t,className:n}){return(0,U.jsx)(`div`,{className:O(`w-full`,n),children:(0,U.jsxs)(y,{nodes:e,edges:t,nodeTypes:He,fitView:!0,fitViewOptions:{padding:.24,maxZoom:1.05},minZoom:.4,maxZoom:1.5,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!1,zoomOnScroll:!1,proOptions:{hideAttribution:!0},children:[(0,U.jsx)(E,{variant:b.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,U.jsx)(ee,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})})}function Ge({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let{t:a}=u(),[o,s]=(0,H.useState)(!1),c=`mem:${e.id}`,l=(0,H.useMemo)(()=>n.filter(e=>e.from===c&&e.to.startsWith(`mem:`)||e.to===c&&e.from.startsWith(`mem:`)).slice(0,24),[c,n]),{nodes:d,edges:f}=(0,H.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-W/2,y:120},data:{entry:e,center:!0}});let o=[...e.supersededBy?[{id:e.supersededBy,relation:`superseded by`}]:[],...(e.supersedes??[]).map(e=>({id:e,relation:`supersedes`})),...(e.contradicts??[]).map(e=>({id:e,relation:`contradicts`}))];for(let e of l){let t=(e.from===c?e.to:e.from).slice(4);o.some(n=>n.id===t&&n.relation===e.relation)||o.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let s=320-(o.length-1)*220/2;return o.forEach((t,o)=>{let c=i.get(t.id)??Ue(t.id,a),l=t.relation===`superseded by`,u=l?0:280+Math.floor(o/3)*130,d=l?320-W/2:s+o*220-W/2;n.push({id:`memory:${t.id}:${o}`,type:`memoryNode`,position:{x:d,y:u},data:{entry:c,center:!1}});let f=t.relation===`contradicts`,p=l?`memory:${t.id}:${o}`:e.id,m=l?e.id:`memory:${t.id}:${o}`;r.push({id:`relation:${t.relation}:${t.id}:${o}`,source:p,target:m,type:`smoothstep`,animated:!f,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:f?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...f?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:f?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`,fontSize:9,fontWeight:700},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.9}})}),e.anchors.forEach((t,i)=>{let a=`anchor:${i}`;n.push({id:a,type:`anchorNode`,position:{x:540,y:120+(i-(e.anchors.length-1)/2)*66},data:{anchor:t,label:Re(t)}}),r.push({id:`anchor-edge:${i}`,source:e.id,target:a,type:`smoothstep`,style:{stroke:`hsl(var(--info))`,strokeWidth:1.3}})}),{nodes:n,edges:r}},[t,e,c,l]);return d.length<=1&&!r&&!i?null:(0,U.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":a(`activity:memoryManager.graphAria`),children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeading`)}),d.length>1&&(0,U.jsxs)(M,{variant:`ghost`,size:`sm`,onClick:()=>s(!0),className:`h-6 gap-1 px-2 text-[9px] font-bold uppercase tracking-[0.12em]`,"aria-label":a(`activity:memoryManager.graphFullscreenAria`),children:[(0,U.jsx)(ie,{className:`size-3`}),a(`activity:memoryManager.graphOpenFullscreen`)]})]}),(0,U.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?a(`activity:memoryManager.loadingGraph`):a(`activity:memoryManager.graphStats`,{nodes:d.length,edges:f.length})})]}),i&&(0,U.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),d.length>1&&(0,U.jsx)(We,{nodes:d,edges:f,className:`h-[320px]`}),l.some(e=>e.evidence?.length)&&(0,U.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:l.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===c?e.to:e.from).slice(4);return(0,U.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,G(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})}),o&&(0,U.jsx)(j,{open:o,onOpenChange:s,children:(0,U.jsxs)(k,{className:`flex max-h-[90dvh] max-w-[90vw] flex-col p-0`,showCloseButton:!1,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-4 py-3`,children:[(0,U.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeadingFull`,{id:e.id})}),(0,U.jsx)(M,{variant:`ghost`,size:`sm`,onClick:()=>s(!1),className:`h-7 gap-1 px-2 text-[10px]`,children:a(`common:action.close`)})]}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4`,children:(0,U.jsx)(We,{nodes:d,edges:f,className:`h-[65vh]`})})]})})]})}function Ke({memory:e,allMemories:t,relatedMemories:n,graphEdges:i,graphLoading:a,graphError:s,onClose:c,onOpenMemory:l,onEdit:d,onDelete:f,onTagSelect:p,onNotice:m}){let{t:h}=u();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/65 px-4 py-3 backdrop-blur-xl`,children:[(0,U.jsx)(M,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:c,"aria-label":h(`activity:memoryManager.backToList`),children:(0,U.jsx)(ue,{className:`size-4`})}),(0,U.jsx)(`span`,{className:O(`text-[10px] font-bold uppercase tracking-[0.14em]`,I(e.kind)),children:B[e.kind]??e.kind}),(0,U.jsx)(R,{status:e.status}),(0,U.jsx)(`span`,{className:`border border-border/70 px-2 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,U.jsxs)(`span`,{className:`flex items-center gap-1 border border-primary/30 bg-primary/10 px-2 py-0.5 font-mono text-[9px] text-primary`,title:ke(e.audience),children:[(0,U.jsx)(w,{className:`size-3`}),ke(e.audience)]}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,U.jsx)(M,{variant:`ghost`,size:`icon`,"aria-label":h(`activity:memoryManager.copyId`),title:h(`activity:memoryManager.copyId`),onClick:()=>{navigator.clipboard?.writeText(e.id),m(h(`activity:memoryManager.copiedNotice`))},children:(0,U.jsx)(o,{className:`size-4`})}),(0,U.jsxs)(M,{variant:`outline`,size:`sm`,onClick:d,disabled:e.status===`deleted`,children:[(0,U.jsx)(r,{className:`size-3.5`}),` `,h(`common:action.edit`)]}),(0,U.jsxs)(M,{variant:`destructive`,size:`sm`,onClick:f,disabled:e.status===`deleted`,children:[(0,U.jsx)(x,{className:`size-3.5`}),` `,h(`common:action.delete`)]})]})]}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,U.jsx)(qe,{memory:e}),(0,U.jsx)(Je,{memory:e}),e.tags.length>0&&(0,U.jsx)(K,{tags:e.tags,onTagSelect:p}),e.anchors.length>0&&(0,U.jsx)(Ye,{anchors:e.anchors}),n.length>0&&(0,U.jsx)(Xe,{relatedMemories:n,allMemories:t,onOpenMemory:l}),(0,U.jsx)(Ge,{centerMemory:e,allMemories:t,graphEdges:i,loading:a,error:s}),(0,U.jsx)(q,{memory:e}),e.status===`deleted`&&(0,U.jsx)(Ze,{contextPolicy:e.contextPolicy})]})})]})}function qe({memory:e}){let{t}=u();return(0,U.jsxs)(`div`,{className:`relative overflow-hidden border border-border/75 bg-card/55 p-5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.04)]`,children:[(0,U.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-10 size-36 bg-[radial-gradient(circle,hsl(var(--info)/0.13),transparent_68%)]`}),(0,U.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,U.jsx)(`p`,{className:`relative mt-4 border-l-2 border-info/50 pl-3 text-xs italic leading-5 text-muted-foreground`,children:e.summary}),(0,U.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,U.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,U.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:t(`activity:memoryManager.revisionSuffix`,{n:e.revision})})]})]})}function Je({memory:e}){let{t}=u();return(0,U.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:[[t(`activity:memoryManager.editorImportance`),e.importance,g],[t(`activity:memoryManager.editorConfidence`),e.confidence,f],[t(`activity:memoryManager.editorFreshness`),e.freshness,le]].map(([e,t,n])=>(0,U.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(n,{className:`size-3.5 text-info`}),(0,U.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,U.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,U.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,U.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function K({tags:e,onTagSelect:t}){let{t:n}=u();return(0,U.jsxs)(`section`,{children:[(0,U.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,U.jsx)(a,{className:`size-3.5 text-info`}),` `,n(`activity:memoryManager.tagsLabel`)]}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`border border-info/25 bg-info/5 px-2 py-1 font-mono text-[10px] text-info hover:border-info/55 hover:bg-info/10`,children:[`#`,e]},e))})]})}function Ye({anchors:e}){let{t}=u();return(0,U.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,U.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,U.jsx)(T,{className:`size-3.5 text-info`}),` `,t(`activity:memoryManager.editorAnchors`)]}),(0,U.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,U.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,U.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,U.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center border border-info/25 bg-info/5 text-info`,children:e.type===`command`?(0,U.jsx)(p,{className:`size-3.5`}):(0,U.jsx)(T,{className:`size-3.5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,U.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??e.role??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,U.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`L`,e.lineStart??`?`,`–`,e.lineEnd??`?`]})]},`${e.type}:${e.path??e.command??e.symbol??e.role}:${t}`))})]})}function Xe({relatedMemories:e,allMemories:t,onOpenMemory:n}){let{t:r}=u();return(0,U.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,U.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,U.jsx)(c,{className:`size-3.5 text-info`}),` `,r(`activity:memoryManager.memoryRelationships`)]}),(0,U.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,U.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let i=t.find(t=>t.id===e.id);return(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,disabled:!i,onClick:()=>i&&n(i.id),className:`group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left hover:bg-info/5 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,U.jsx)(`span`,{className:O(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:i?F(i.text,95):r(`activity:memoryManager.referencedUnavailable`)}),(0,U.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),i&&(0,U.jsx)(h,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function q({memory:e}){let{t}=u();return(0,U.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:[[t(`activity:memoryManager.metaCreated`),z(e.createdAt),re],[t(`activity:memoryManager.metaUpdated`),z(e.updatedAt),le],[t(`activity:memoryManager.metaLastAccessed`),z(e.lastAccessedAt),fe],[t(`activity:memoryManager.metaLastVerified`),z(e.lastVerifiedAt),g]].map(([e,t,n])=>(0,U.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,U.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,U.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,U.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function Ze({contextPolicy:e}){let{t}=u();return(0,U.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,U.jsx)(i,{className:`mt-0.5 size-4 shrink-0`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`font-bold text-foreground`,children:t(`activity:memoryManager.deletedMemory`)}),(0,U.jsx)(`p`,{className:`mt-1 leading-5`,children:t(e===`never`?`activity:memoryManager.deletedNeverPolicy`:`activity:memoryManager.deletedEligiblePolicy`)})]})]})}function Qe({mode:e,draft:t,busy:i,error:a,onChange:o,onCancel:s,onSubmit:c}){let{t:d}=u(),f=(0,H.useRef)(null),[p,h]=(0,H.useState)([]);(0,H.useEffect)(()=>{f.current?.focus();let e=new AbortController;return P(`agent-roster.list`,{},e.signal).then(e=>{let t=e.roles;Array.isArray(t)&&h(t.filter(e=>typeof e==`string`))}).catch(()=>void 0),()=>e.abort()},[]);let g=(e,n)=>{o({...t,[e]:n})},_=()=>{g(`anchors`,[...t.anchors,{type:`file`,path:``}])};return(0,U.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),c()},"aria-busy":i,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/70 px-4 py-3 backdrop-blur-xl`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,U.jsx)(m,{className:`size-4`}):(0,U.jsx)(r,{className:`size-4`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`truncate text-sm font-bold`,children:d(e===`create`?`activity:memoryManager.captureMemory`:`activity:memoryManager.editMemory`)}),(0,U.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:d(e===`create`?`activity:memoryManager.editorCreateHint`:`activity:memoryManager.editorEditHint`)})]})]}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,U.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,disabled:i,children:[(0,U.jsx)(ne,{className:`size-3.5`}),` `,d(`common:action.cancel`)]}),(0,U.jsxs)(M,{type:`submit`,size:`sm`,disabled:i||!t.text.trim(),children:[i?(0,U.jsx)(ae,{className:`size-3.5 animate-spin`}):e===`create`?(0,U.jsx)(n,{className:`size-3.5`}):(0,U.jsx)(se,{className:`size-3.5`}),d(i?`common:action.saving`:e===`create`?`activity:memoryManager.createMemory`:`activity:memoryManager.saveChanges`)]})]})]}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[a&&(0,U.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border border-destructive/40 bg-destructive/10 px-3 py-2.5 text-sm text-destructive`,children:[(0,U.jsx)(l,{className:`mt-0.5 size-4 shrink-0`}),(0,U.jsx)(`span`,{children:a})]}),(0,U.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:d(`activity:memoryManager.editorKnowledge`)}),(0,U.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:d(`activity:memEditor.writeTheDurableFactOrDecision`)})]}),(0,U.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:d(`activity:memoryManager.editorCharCount`,{count:t.text.length})})]}),(0,U.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:d(`activity:memoryManager.editorContentLabel`)}),(0,U.jsx)(`textarea`,{ref:f,id:`memory-text`,value:t.text,onChange:e=>g(`text`,e.target.value),rows:7,required:!0,placeholder:d(`activity:memoryManager.editorContentPlaceholder`),className:`min-h-36 w-full resize-y border border-input bg-background/75 px-3 py-3 text-sm leading-6 text-foreground shadow-inner placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,U.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:memoryManager.editorKind`)}),(0,U.jsx)(`select`,{id:`memory-kind`,value:t.kind,onChange:e=>g(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:L.map(e=>(0,U.jsx)(`option`,{value:e,children:B[e]},e))})]}),e===`create`?(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:memoryManager.editorScope`)}),(0,U.jsx)(`select`,{id:`memory-scope`,value:t.scope,onChange:e=>g(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Se.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]}):(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:memoryManager.editorLifecycleStatus`)}),(0,U.jsx)(`select`,{id:`memory-status`,value:t.status,onChange:e=>g(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:De.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]}),(0,U.jsxs)(`div`,{className:O(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,U.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:memoryManager.tagsLabel`)}),(0,U.jsx)(N,{id:`memory-tags`,value:t.tags,onChange:e=>g(`tags`,e.target.value),placeholder:d(`activity:memEditor.architectureWebuiWorkflow`),className:`h-10 bg-background`})]})]}),(0,U.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,U.jsx)(we,{id:`memory-importance`,label:d(`activity:memoryManager.editorImportance`),value:t.importance,onChange:e=>g(`importance`,e)}),(0,U.jsx)(we,{id:`memory-confidence`,label:d(`activity:memoryManager.editorConfidence`),value:t.confidence,onChange:e=>g(`confidence`,e)}),(0,U.jsx)(we,{id:`memory-freshness`,label:d(`activity:memoryManager.editorFreshness`),value:t.freshness,onChange:e=>g(`freshness`,e)})]}),(0,U.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:d(`activity:memoryManager.editorAnchors`)}),(0,U.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:d(`activity:memEditor.bindKnowledgeToFilesSymbolsPackages`)})]}),(0,U.jsxs)(M,{type:`button`,variant:`outline`,size:`sm`,onClick:_,children:[(0,U.jsx)(n,{className:`size-3.5`}),` `,d(`activity:memoryManager.addAnchor`)]})]}),t.anchors.length===0?(0,U.jsxs)(`button`,{type:`button`,onClick:_,className:`mt-4 flex w-full items-center justify-center gap-2 border border-dashed border-border px-4 py-7 text-xs text-muted-foreground transition-colors hover:border-info/50 hover:bg-info/5 hover:text-info`,children:[(0,U.jsx)(te,{className:`size-4`}),` `,d(`activity:memoryManager.noAnchors`)]}):(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:t.anchors.map((e,n)=>(0,U.jsxs)(`div`,{className:`grid gap-2 border border-border/65 bg-background/40 p-2 sm:grid-cols-[9rem_minmax(0,1fr)_auto]`,children:[(0,U.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${n}`,children:[`Anchor `,n+1,` type`]}),(0,U.jsx)(`select`,{id:`anchor-type-${n}`,value:e.type,onChange:e=>{let r=e.target.value,i=r===`command`?{type:r,command:``}:r===`agent`?{type:r,role:``}:{type:r,path:``},a=t.anchors.map((e,t)=>t===n?i:e);g(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:je.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))}),(0,U.jsxs)(`div`,{className:O(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,U.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${n}`,children:[`Anchor `,n+1,` value`]}),(0,U.jsx)(N,{id:`anchor-value-${n}`,list:e.type===`agent`?`memory-agent-role-options`:void 0,value:Me(e),onChange:e=>{let r=t.anchors.map((t,r)=>r===n?Ce(t,e.target.value):t);g(`anchors`,r)},placeholder:e.type===`command`?`pnpm test --filter webui`:e.type===`agent`?`reviewer`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${n}`,children:[`Anchor `,n+1,` symbol`]}),(0,U.jsx)(N,{id:`anchor-symbol-${n}`,value:e.symbol??``,onChange:e=>{let r=t.anchors.map((t,r)=>r===n?{...t,symbol:e.target.value}:t);g(`anchors`,r)},placeholder:d(`activity:memoryManager.editorSymbolPlaceholder`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,U.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${n+1}`,onClick:()=>g(`anchors`,t.anchors.filter((e,t)=>t!==n)),children:(0,U.jsx)(x,{className:`size-4 text-destructive`})})]},`${e.type}:${n}`))}),(0,U.jsx)(`datalist`,{id:`memory-agent-role-options`,children:p.map(e=>(0,U.jsx)(`option`,{value:e},e))})]}),(0,U.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,U.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,U.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:d(`activity:memoryManager.editorRelationships`)}),(0,U.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:d(`activity:memoryManager.editorRelationshipsHint`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:memoryManager.editorSupersedes`)}),(0,U.jsx)(N,{id:`memory-supersedes`,value:t.supersedes,onChange:e=>g(`supersedes`,e.target.value),placeholder:d(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:memoryManager.editorContradicts`)}),(0,U.jsx)(N,{id:`memory-contradicts`,value:t.contradicts,onChange:e=>g(`contradicts`,e.target.value),placeholder:d(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,U.jsxs)(`section`,{className:`space-y-2`,children:[(0,U.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:memEditor.audienceOptional`)}),(0,U.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:d(`activity:memEditor.targetThisMemoryToSpecificAgent`)}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:memEditor.roles`)}),(0,U.jsx)(N,{id:`memory-audience-roles`,value:t.audienceRoles,onChange:e=>g(`audienceRoles`,e.target.value),placeholder:d(`activity:memEditor.reviewerRefactorPlanner`),className:`h-9 bg-background font-mono text-xs`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:memoryManager.editorTaskTypes`)}),(0,U.jsx)(N,{id:`memory-audience-task-types`,value:t.audienceTaskTypes,onChange:e=>g(`audienceTaskTypes`,e.target.value),placeholder:d(`activity:memEditor.reviewRefactorBugfix`),className:`h-9 bg-background font-mono text-xs`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:memEditor.modes`)}),(0,U.jsx)(N,{id:`memory-audience-modes`,value:t.audienceModes,onChange:e=>g(`audienceModes`,e.target.value),placeholder:d(`activity:memEditor.teachCodeReview`),className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function $e({searchQuery:e,statusFilter:t,kindFilter:n,audienceOnly:r,tagFilter:i,hasFilters:o,allTags:s,stats:c,onSearchChange:l,onStatusFilterChange:f,onKindFilterChange:p,onToggleAudienceOnly:m,onTagFilterChange:h,onClearFilters:g}){let{t:_}=u(),[ee,te]=(0,H.useState)(!!i),y=ee||!!i,re=s.length>0;return(0,U.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,U.jsx)(v,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,U.jsx)(N,{"aria-label":_(`activity:memoryManager.searchAria`),value:e,onChange:e=>l(e.target.value),placeholder:_(`activity:memoryManager.searchPlaceholder`),className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,U.jsx)(`button`,{type:`button`,"aria-label":_(`activity:memoryManager.clearSearchAria`),onClick:()=>l(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(ne,{className:`size-3.5`})})]}),(0,U.jsx)(M,{variant:r?`default`:`ghost`,size:`icon`,onClick:m,"aria-label":_(`activity:memoryManager.audienceFilterAria`),title:_(`activity:memoryManager.audienceFilterTitle`),className:`shrink-0`,children:(0,U.jsx)(w,{className:`size-4`})}),o&&(0,U.jsx)(M,{variant:`ghost`,size:`icon`,onClick:g,"aria-label":_(`activity:memoryManager.clearFiltersAria`),title:_(`activity:memoryManager.clearFiltersTitle`),children:(0,U.jsx)(pe,{className:`size-4`})})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:_(`activity:memoryManager.filterByStatus`)}),(0,U.jsxs)(`select`,{id:`memory-status-filter`,value:t,onChange:e=>f(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,U.jsx)(`option`,{value:`all`,children:_(`activity:memoryManager.allStatuses`)}),Oe.map(e=>(0,U.jsxs)(`option`,{value:e,children:[e,` · `,c?.byStatus[e]??0]},e))]}),(0,U.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:_(`activity:memoryManager.filterByKind`)}),(0,U.jsxs)(`select`,{id:`memory-kind-filter`,value:n,onChange:e=>p(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,U.jsx)(`option`,{value:`all`,children:_(`activity:memoryManager.allKinds`)}),L.map(e=>(0,U.jsxs)(`option`,{value:e,children:[B[e],` · `,c?.byKind[e]??0]},e))]})]}),re&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{i||te(e=>!e)},"aria-expanded":y,"aria-controls":`memory-tags-panel`,disabled:!!i,className:O(`flex items-center gap-1.5 px-1 py-0.5 text-[10px] uppercase tracking-wide transition-colors`,y?`text-foreground`:`text-muted-foreground hover:text-foreground`,!!i&&`cursor-default`),title:i?`Active filter: ${i} (click the chip to clear)`:y?`Hide tag filters`:`Show tag filters (${s.length})`,children:[(0,U.jsx)(d,{className:O(`size-3 transition-transform`,!y&&`-rotate-90`)}),(0,U.jsx)(a,{className:`size-3`}),(0,U.jsx)(`span`,{className:`font-semibold`,children:_(`activity:memoryManager.tagsLabel`)}),(0,U.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:s.length})]}),i&&(0,U.jsx)(`span`,{role:`status`,"aria-label":`Active tag filter: ${i}`,className:`border border-info/55 bg-info/10 px-1 font-mono text-[9px] uppercase text-info`,children:i})]}),re&&y&&(0,U.jsxs)(`fieldset`,{id:`memory-tags-panel`,className:`min-w-0 border-0 p-0`,children:[(0,U.jsx)(`legend`,{className:`sr-only`,children:_(`activity:memoryManager.popularTags`)}),(0,U.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:s.slice(0,18).map(([e,t])=>(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":i===e,onClick:()=>h(i===e?null:e),className:O(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,i===e?`border-info/55 bg-info/10 text-info`:`border-border/70 bg-background/45 text-muted-foreground hover:border-info/35 hover:text-foreground`),children:[(0,U.jsx)(a,{className:`size-2.5`}),` `,e,(0,U.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}var J=100;function et({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:o}){let{t:s}=u(),c=n.length>J,l=C({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:c});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:s(`activity:memoryManager.memoryCountSummary`,{shown:n.length,total:t.length})}),(0,U.jsx)(`span`,{className:`font-mono uppercase`,children:s(`activity:memoryManager.updatedSortLabel`)})]}),(0,U.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":s(`activity:memoryManager.listAria`),children:n.length===0?(0,U.jsx)(Y,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:o}):c?(0,U.jsx)(`div`,{style:{height:`${l.getTotalSize()}px`,width:`100%`,position:`relative`},children:l.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,U.jsx)(`div`,{"data-index":e.index,ref:l.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,U.jsx)(X,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,U.jsx)(X,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function Y({hasMemories:e,onOpenCreate:t,onClearFilters:r}){let{t:i}=u();return(0,U.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,U.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,U.jsx)(ce,{className:`size-5`})}),(0,U.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:i(e?`activity:memoryManager.noMatching`:`activity:memoryManager.buildGraph`)}),(0,U.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:i(e?`activity:memoryManager.emptyFiltered`:`activity:memoryManager.emptyCapture`)}),(0,U.jsxs)(M,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?r:t,children:[e?(0,U.jsx)(pe,{className:`size-3.5`}):(0,U.jsx)(n,{className:`size-3.5`}),i(e?`activity:memoryManager.clearFilters`:`activity:memoryManager.createFirst`)]})]})}function X({memory:e,isSelected:t,onClick:n}){return(0,U.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,className:O(`group relative block w-full border-b border-border/55 px-3 py-3 text-left transition-[background-color,border-color] hover:bg-info/5`,t&&`bg-info/8`),children:[t&&(0,U.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:O(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,I(e.kind)),children:B[e.kind]??e.kind}),(0,U.jsx)(R,{status:e.status}),(0,U.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,U.jsx)(`p`,{className:O(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:F(e.text)}),(0,U.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`border border-border/60 bg-background/50 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,U.jsxs)(`span`,{className:`flex items-center gap-0.5 border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[9px] text-primary`,children:[(0,U.jsx)(w,{className:`size-2.5`}),(e.audience.roles??e.audience.taskTypes??e.audience.modes??[]).slice(0,1)[0]??`scoped`]}),e.tags.slice(0,2).map(e=>(0,U.jsxs)(`span`,{className:`max-w-24 truncate border border-border/60 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,e]},e)),e.tags.length>2&&(0,U.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,U.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:Ne(e.updatedAt)}),(0,U.jsx)(h,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function tt({onCapture:e}){let{t:r}=u();return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,U.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,U.jsx)(w,{className:`size-8`}),(0,U.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,U.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:r(`activity:memoryManager.emptyTitle`)}),(0,U.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:r(`activity:memoryManager.emptyBody`)}),(0,U.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,U.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,U.jsx)(t,{className:`mx-auto size-4 text-success`}),(0,U.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:r(`activity:memoryManager.emptyVerifiedAnchors`)})]}),(0,U.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,U.jsx)(w,{className:`mx-auto size-4 text-info`}),(0,U.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:r(`activity:memoryManager.emptyTypedRelations`)})]}),(0,U.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,U.jsx)(n,{className:`mx-auto size-4 text-warning`}),(0,U.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:r(`activity:memoryManager.emptyAgentRecall`)})]})]}),(0,U.jsxs)(M,{onClick:e,children:[(0,U.jsx)(n,{className:`size-4`}),` `,r(`activity:memoryManager.captureButton`)]})]})}function nt(e,t){let n=t.searchQuery.trim().toLowerCase();return e.filter(e=>{if(t.statusFilter!==`all`&&e.status!==t.statusFilter||t.kindFilter!==`all`&&e.kind!==t.kindFilter||t.tagFilter&&!e.tags.includes(t.tagFilter)||t.audienceOnly&&!e.audience)return!1;if(!n)return!0;let r=e.anchors.map(e=>[e.path,e.symbol,e.command,e.role].filter(Boolean).join(` `)).join(` `),i=e.audience?[e.audience.roles?.join(` `)??``,e.audience.taskTypes?.join(` `)??``,e.audience.modes?.join(` `)??``].join(` `):``;return[e.id,e.text,e.summary??``,e.kind,e.scope,e.tags.join(` `),r,i].join(` `).toLowerCase().includes(n)})}function rt(e){let t=new Map;for(let n of e)for(let e of n.tags)t.set(e,(t.get(e)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function it(e){if(!e)return[];let t=[];e.supersededBy&&t.push({relation:`Superseded by`,id:e.supersededBy});for(let n of e.supersedes??[])t.push({relation:`Supersedes`,id:n});for(let n of e.contradicts??[])t.push({relation:`Contradicts`,id:n});return t}function at(){let{t:e}=u(),{client:r,listSageMemoriesPage:i,rememberSage:a,updateSage:o,deleteSage:c,getSageGraph:d,recoverSage:f,resolveMemoryCandidate:p}=me(),m=he(e=>e.wsConnected),h=ge(e=>e.setCurrentView),g=be(`memory`),[_,ee]=(0,H.useState)([]),[v,te]=(0,H.useState)(null),[ne,y]=(0,H.useState)(!0),[re,ie]=(0,H.useState)(!1),[b,ae]=(0,H.useState)(null),[x,S]=(0,H.useState)(null),[C,T]=(0,H.useState)(null),[E,D]=(0,H.useState)(null),[se,ce]=(0,H.useState)([]),[de,fe]=(0,H.useState)([]),[pe,_e]=(0,H.useState)(null),[ve,k]=(0,H.useState)(!1),[ye,A]=(0,H.useState)(!1),[j,N]=(0,H.useState)(!1),[P,Se]=(0,H.useState)(Ee),[Ce,we]=(0,H.useState)(Ee),[F,I]=(0,H.useState)(null),[L,R]=(0,H.useState)(null),[z,De]=(0,H.useState)(``),[Oe,ke]=(0,H.useState)(`all`),[B,je]=(0,H.useState)(`all`),[Me,Ne]=(0,H.useState)(!1),[W,Ie]=(0,H.useState)(null),[G,Le]=(0,H.useState)(!1),[Re,ze]=(0,H.useState)(null),[Be,Ve]=(0,H.useState)(!1),[He,Ue]=(0,H.useState)(!1),[We,Ge]=(0,H.useState)({}),[qe,Je]=(0,H.useState)(!1),[K,Ye]=(0,H.useState)(null),Xe=(0,H.useRef)(!1),q=(0,H.useRef)(!0),Ze=(0,H.useRef)(0),J=(0,H.useRef)(0),Y=(0,H.useRef)(null),X=(0,H.useRef)(null),at=(0,H.useMemo)(()=>{let e=new Set;for(let t of _)for(let n of t.anchors??[])n.type===`file`&&n.path&&e.add(n.path);return e},[_]),ot=(0,H.useMemo)(()=>JSON.stringify(P)!==JSON.stringify(Ce),[Ce,P]),Z=(0,H.useMemo)(()=>_.find(e=>e.id===E)??null,[_,E]),st=(0,H.useCallback)(e=>{let t=e!==null,n=++Ze.current;Y.current?.(),ae(null),t?Ue(!0):(ie(!0),Xe.current||y(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),Y.current===c&&(Y.current=null))};a=r.on(`memory.sage.listPage`,e=>{if(n!==Ze.current||!q.current){c();return}if(c(),e.payload.error)ae(e.payload.error);else{let n=e.payload.memories??[];ee(e=>t?[...e,...n]:n),ze(e.payload.nextCursor??null),Ve(!!e.payload.nextCursor);let r=e.payload.statusCounts??{};Ge(r);let i=Object.values(r).reduce((e,t)=>e+t,0);e.payload.stats?te(e.payload.stats):te(e=>({total:i,byStatus:r,byKind:e?.byKind??{},edges:e?.edges??0})),Xe.current=!0,t||D(e=>e&&n.some(t=>t.id===e)?e:null)}y(!1),ie(!1),Ue(!1)}),o=setTimeout(()=>{n!==Ze.current||!q.current||(c(),ae(`The memory store did not respond. Check the WebSocket connection and try again.`),y(!1),ie(!1),Ue(!1))},2e4),Y.current=c,i({limit:100,...G?{statuses:[`deleted`]}:{},...e?{cursor:e}:{}},{echoToChat:!1})},[r,i,G]),Q=(0,H.useCallback)(()=>{ze(null),Ve(!1),st(null)},[st]),ct=(0,H.useCallback)(()=>{He||!Re||st(Re)},[st,He,Re]);(0,H.useEffect)(()=>(q.current=!0,Q(),()=>{q.current=!1,Ze.current+=1,J.current+=1,Y.current?.(),X.current?.()}),[Q]),(0,H.useEffect)(()=>{if(ce([]),fe([]),_e(null),!E){k(!1);return}let e=E;k(!0);let t=null,n=r.on(`memory.sage.graph`,n=>{n.payload.query===e&&(t!==null&&clearTimeout(t),ce(n.payload.edges??[]),fe(n.payload.memories??[]),_e(n.payload.error??null),k(!1))});return t=setTimeout(()=>{_e(`Relationship graph did not respond in time.`),k(!1)},15e3),d(e,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{t!==null&&clearTimeout(t),n()}},[r,d,E]);let lt=(0,H.useRef)(m);(0,H.useEffect)(()=>{m&&!lt.current&&Xe.current&&Q(),lt.current=m},[Q,m]),(0,H.useEffect)(()=>{if(!C)return;let e=setTimeout(()=>T(null),4e3);return()=>clearTimeout(e)},[C]);let ut=(0,H.useCallback)(()=>!ot||!ye&&!j||window.confirm(`Discard the unsaved memory changes?`),[j,ot,ye]),dt=(0,H.useCallback)(()=>{if(!ut())return;let e=Ee();Se(e),we(e),N(!0),A(!1),D(null),S(null)},[ut]),ft=(0,H.useCallback)(e=>{ut()&&(D(e),N(!1),A(!1),S(null))},[ut]),pt=(0,H.useCallback)(e=>{let t=e===void 0?Z:_.find(t=>t.id===e)??null;if(!t||t.status===`deleted`)return;e!==void 0&&D(e);let n=Te(t);Se(n),we(n),A(!0),N(!1),S(null)},[_,Z]),mt=(0,H.useCallback)(()=>{ut()&&(A(!1),N(!1),S(null))},[ut]),ht=(0,H.useCallback)((t,n,i)=>{if(!P.text.trim()){S(`Memory content is required.`);return}let a=++J.current;X.current?.(),I(i),S(null),T(null);let o=()=>{},s=null,c=!1,l=()=>{c||(c=!0,s!==null&&clearTimeout(s),o(),X.current===l&&(X.current=null))},u=t=>{if(a!==J.current||!q.current){l();return}if(l(),I(null),t.payload.error||!t.payload.memory){S(t.payload.error??`The server returned no memory record.`);return}let n=t.payload.memory;ee(e=>{let t=e.filter(e=>e.id!==n.id);return[n,...t]}),D(n.id),N(!1),A(!1),T(e(i===`create`?`activity:memoryManager.memoryCaptured`:`activity:memoryManager.memoryUpdated`)),Q()};o=t===`memory.sage.remember`?r.on(`memory.sage.remember`,u):r.on(`memory.sage.update`,u),s=setTimeout(()=>{a!==J.current||!q.current||(l(),I(null),S(e(`activity:memoryManager.mutationTimeout`,{verb:e(i===`create`?`activity:memoryManager.createAction`:`common:action.save`)})))},2e4),X.current=l,n()},[r,P.text,Q,e]),gt=(0,H.useCallback)(()=>{ht(`memory.sage.remember`,()=>a({text:P.text.trim(),kind:P.kind,scope:P.scope,tags:V(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:xe(P.anchors),...V(P.audienceRoles).length||V(P.audienceTaskTypes).length||V(P.audienceModes).length?{audience:{roles:V(P.audienceRoles),taskTypes:V(P.audienceTaskTypes),modes:V(P.audienceModes)}}:{},supersedes:V(P.supersedes),contradicts:V(P.contradicts)},{echoToChat:!1}),`create`)},[P,a,ht]),_t=(0,H.useCallback)(()=>{Z&&ht(`memory.sage.update`,()=>o(Z.id,{text:P.text.trim(),kind:P.kind,status:P.status,tags:V(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:xe(P.anchors),...V(P.audienceRoles).length||V(P.audienceTaskTypes).length||V(P.audienceModes).length?{audience:{roles:V(P.audienceRoles),taskTypes:V(P.audienceTaskTypes),modes:V(P.audienceModes)}}:{},supersedes:V(P.supersedes),contradicts:V(P.contradicts)},{echoToChat:!1}),`update`)},[P,ht,Z,o]),vt=(0,H.useCallback)(()=>{if(!L)return;let e=++J.current;X.current?.(),I(`delete`),S(null);let t=()=>{},n=null,i=!1,a=()=>{i||(i=!0,n!==null&&clearTimeout(n),t(),X.current===a&&(X.current=null))};t=r.on(`memory.sage.delete`,t=>{if(e!==J.current||!q.current){a();return}if(a(),I(null),!t.payload.success){S(t.payload.message||`Delete failed.`);return}R(null),D(null),A(!1),T(`Memory deleted and relationship edges cleaned up.`),Q()}),n=setTimeout(()=>{e!==J.current||!q.current||(a(),I(null),S(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),X.current=a,c(L,`Deleted from the WebUI Memory Manager.`)},[r,c,L,Q]),yt=(0,H.useCallback)((e,t,n)=>{let i=++J.current;X.current?.(),S(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),X.current===c&&(X.current=null))};a=r.on(e,e=>{if(i!==J.current||!q.current){c();return}c(),n(e.payload)}),o=setTimeout(()=>{i!==J.current||!q.current||(c(),S(`The memory store did not respond. Check the WebSocket connection and try again.`))},2e4),X.current=c,t()},[r]),bt=(0,H.useMemo)(()=>nt(_,{searchQuery:z,statusFilter:Oe,kindFilter:B,tagFilter:W,audienceOnly:Me}),[Me,B,_,z,Oe,W]),xt=(0,H.useMemo)(()=>rt(_),[_]),St=(0,H.useMemo)(()=>it(Z),[Z]),Ct=(0,H.useCallback)(()=>{De(``),ke(`all`),je(`all`),Ne(!1),Ie(null)},[]),wt=!!(z||Oe!==`all`||B!==`all`||W||Me),Tt=j||!!Z,$=qe&&!!K;return ne&&_.length===0?(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,U.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,U.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,U.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,U.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,U.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,U.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,U.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,U.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,U.jsx)(`span`,{className:`sr-only`,role:`status`,children:e(`activity:memoryManager.loadingSageContent`)})]}):b&&_.length===0?(0,U.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,U.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,U.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,U.jsx)(l,{className:`size-5`})}),(0,U.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:e(`activity:memoryManager.storeUnavailable`)}),(0,U.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:b}),(0,U.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,U.jsxs)(M,{onClick:Q,children:[(0,U.jsx)(le,{className:`size-4`}),` `,e(`common:action.retry`)]}),(0,U.jsxs)(M,{variant:`outline`,onClick:()=>h(`chat`),children:[(0,U.jsx)(ue,{className:`size-4`}),` `,e(`activity:memoryManager.backToChat`)]})]})]})}):(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,U.jsxs)(`header`,{className:`relative shrink-0 overflow-hidden border-b border-border/70 bg-card/72 px-4 py-3 backdrop-blur-xl sm:px-5`,children:[(0,U.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 w-1/2 bg-[radial-gradient(circle_at_right,hsl(var(--info)/0.11),transparent_68%)]`}),(0,U.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,U.jsx)(M,{variant:`ghost`,size:`icon`,onClick:()=>h(`chat`),"aria-label":e(`activity:memoryManager.backToChat`),title:e(`activity:memoryManager.backToChat`),children:(0,U.jsx)(ue,{className:`size-4`})}),(0,U.jsx)(`span`,{className:`flex size-10 items-center justify-center border border-info/40 bg-info/10 text-info shadow-[0_0_20px_hsl(var(--info)/0.12)]`,children:(0,U.jsx)(w,{className:`size-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:e(`activity:memoryManager.sageHeading`)}),(0,U.jsx)(`span`,{className:`border border-success/35 bg-success/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-success`,children:e(`activity:memoryManager.projectKnowledge`)})]}),(0,U.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:e(`activity:memoryManager.sageSubtitle`)})]}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{className:O(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,m?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,U.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,e(m?`activity:memoryManager.liveStore`:`activity:memoryManager.reconnecting`)]}),(0,U.jsxs)(M,{variant:`outline`,size:`sm`,onClick:Q,disabled:re,"aria-label":e(`activity:memoryManager.refreshAria`),children:[(0,U.jsx)(le,{className:O(`size-3.5`,re&&`animate-spin`)}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common:action.refresh`)})]}),(0,U.jsxs)(M,{size:`sm`,onClick:dt,children:[(0,U.jsx)(n,{className:`size-3.5`}),` `,e(`activity:memoryManager.newMemory`)]})]})]})]}),(0,U.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,U.jsx)(Ae,{label:e(`activity:memoryManager.tabMemories`),value:v?.total??_.length,hint:`${bt.length} visible`}),(0,U.jsx)(Ae,{label:e(`activity:memoryManager.tabActive`),value:v?.byStatus.active??_.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,U.jsx)(Ae,{label:e(`activity:memoryManager.tabNeedsReview`),value:(v?.byStatus.stale??0)+(v?.byStatus.contradicted??0),hint:e(`activity:memoryManager.staleConflicts`),tone:`warning`}),(0,U.jsx)(`div`,{className:`hidden sm:block`,children:(0,U.jsx)(Ae,{label:e(`activity:memoryManager.tabGraphEdges`),value:v?.edges??0,hint:`${xt.length} tags`,tone:`info`})})]}),(()=>{let e=_.filter(e=>e.audience).length;if(e===0)return null;let t=new Set;for(let e of _)if(e.audience){for(let n of e.audience.roles??[])t.add(n);for(let n of e.audience.taskTypes??[])t.add(n);for(let n of e.audience.modes??[])t.add(n)}return(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/70 bg-primary/5 px-4 py-1.5`,children:[(0,U.jsx)(w,{className:`size-3.5 text-primary`}),(0,U.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[e,` audience-scoped memory`,e===1?``:`ies`]}),t.size>0&&(0,U.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...t].sort().join(`, `),`)`]})]})})(),(C||b||x)&&(0,U.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[C&&(0,U.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,U.jsx)(t,{className:`size-3.5`}),` `,C]}),b&&(0,U.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,U.jsx)(l,{className:`size-3.5`}),` `,b,` Existing content remains available.`]}),x&&!ye&&!j&&(0,U.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,U.jsx)(l,{className:`size-3.5`}),` `,x]})]}),(0,U.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,U.jsxs)(`section`,{className:O(`min-h-0 border-r border-border/70 bg-card/25`,Tt?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":e(`activity:memoryManager.libraryAria`),children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":e(`activity:memoryManager.viewAria`),children:[(0,U.jsx)(M,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":!G,onClick:()=>{G&&Le(!1)},className:O(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,G?`border-transparent text-muted-foreground`:`border-primary text-foreground`),children:e(`activity:memoryManager.tabActive`)}),(0,U.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":G,onClick:()=>{G||Le(!0)},className:O(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,G?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[e(`activity:memoryManager.tabDeleted`),typeof We.deleted==`number`?` (${We.deleted})`:``]})]}),(0,U.jsx)($e,{searchQuery:z,statusFilter:Oe,kindFilter:B,audienceOnly:Me,tagFilter:W,hasFilters:wt,allTags:xt,stats:v,onSearchChange:De,onStatusFilterChange:ke,onKindFilterChange:je,onToggleAudienceOnly:()=>Ne(e=>!e),onTagFilterChange:Ie,onClearFilters:Ct}),(0,U.jsx)(et,{memoryListRef:g,memories:_,filteredMemories:bt,selectedId:E,onSelectMemory:ft,onOpenCreate:dt,onClearFilters:Ct}),Be?(0,U.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,U.jsx)(M,{type:`button`,variant:`outline`,size:`sm`,onClick:ct,disabled:He,className:`h-7 w-full text-[11px]`,children:He?e(`common:action.loading`):`Load more (${_.length} loaded)`})}):null]}),(0,U.jsxs)(`section`,{className:O(`min-h-0 bg-background`,Tt?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":e(`activity:memoryManager.detailAria`),children:[_.some(e=>(e.anchors??[]).some(e=>e.type===`file`&&e.path))&&(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/60 bg-card/30 px-3 py-1.5`,children:[(0,U.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:memoryManager.fileDrawerLabel`)}),(0,U.jsx)(`input`,{type:`text`,list:`memory-drawer-file-list`,value:K??``,onChange:e=>{let t=e.target.value.trim()||null;t&&at.has(t)?(Ye(t),Je(!0)):Ye(t||null)},placeholder:e(`activity:memoryManager.selectFilePlaceholder`),className:`min-w-0 max-w-[260px] flex-1 truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":e(`activity:memoryManager.fileForDrawerAria`),"data-testid":`memory-drawer-file-select`}),(0,U.jsx)(`datalist`,{id:`memory-drawer-file-list`,children:[...at].sort().map(e=>(0,U.jsx)(`option`,{value:e},e))}),(0,U.jsxs)(M,{type:`button`,size:`sm`,variant:$?`default`:`outline`,onClick:()=>{K&&Je(e=>!e)},disabled:!K,className:`h-7 shrink-0 gap-1 px-2 text-[11px]`,"aria-pressed":$,title:e($?`activity:memoryManager.hideFileDrawer`:`activity:memoryManager.showFileDrawer`),children:[$?(0,U.jsx)(s,{className:`size-3`}):(0,U.jsx)(oe,{className:`size-3`}),e($?`activity:memoryManager.hideDrawer`:`activity:memoryManager.showDrawer`)]})]}),j?(0,U.jsx)(Qe,{mode:`create`,draft:P,busy:F===`create`,error:x,onChange:Se,onCancel:mt,onSubmit:gt}):Z?ye?(0,U.jsx)(Qe,{mode:`edit`,draft:P,busy:F===`update`,error:x,onChange:Se,onCancel:mt,onSubmit:_t}):$?(0,U.jsx)(Pe,{filePath:K,open:$,onClose:()=>Je(!1),onShowMemory:e=>D(e),onAcceptDeletion:(e,t)=>{yt(`memory.sage.candidateResolve`,()=>p({candidateId:e,action:`accept`}),n=>{if(n.error){S(n.error);return}T(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),Q()})},onKeep:(e,t)=>{yt(`memory.sage.candidateResolve`,()=>p({candidateId:e,action:`reject`}),n=>{if(n.error){S(n.error);return}T(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`),Q()})},onUpdate:e=>{pt(e)},onMarkPermanent:e=>{yt(`memory.sage.update`,()=>o(e,{persistence:`permanent`}),t=>{if(t.error||!t.memory){S(t.error??`The server returned no memory record.`);return}T(`Memory ${e.slice(0,12)}… promoted to permanent.`),Q()})},onRecover:e=>{yt(`memory.sage.recover`,()=>f({id:e,reason:`recovered via file drawer`}),t=>{if(t.error){S(t.error);return}T(`Recovered ${e.slice(0,12)}…`),Q()})}}):(0,U.jsx)(Ke,{memory:Z,allMemories:[..._,...de],relatedMemories:St,graphEdges:se,graphLoading:ve,graphError:pe,onClose:()=>D(null),onOpenMemory:ft,onEdit:pt,onDelete:()=>R(Z.id),onTagSelect:e=>{Ie(e),D(null)},onNotice:T}):(0,U.jsx)(tt,{onCapture:dt})]})]}),(0,U.jsx)(Fe,{busyAction:F,deletingId:L,memories:_,onCancel:()=>R(null),onConfirm:vt,onOpenChange:e=>{!e&&F!==`delete`&&R(null)}})]})}export{at as MemoryManager};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,$r as n,Ai as r,An as i,Di as a,Dr as o,Jr as s,Ki as c,La as l,Nt as u,Oa as d,Oi as f,Or as p,Pa as m,Qn as h,Ta as g,Un as _,Ur as v,Vt as y,Wi as b,Wr as x,Xn as S,Yn as C,Zn as w,_ as T,_i as E,a as D,an as O,bi as k,c as A,d as ee,dt as j,f as M,h as te,hi as N,hr as ne,i as P,ia as re,in as F,ja as ie,ji as ae,l as oe,la as I,lt as se,m as ce,mt as le,nr as ue,o as de,or as fe,p as pe,pt as L,r as me,s as R,sn as z,u as B,ut as he,v as ge,xr as _e,xt as ve,yt as ye,za as be,zn as V}from"./vendor-BuarzSSb.js";import"./i18n-9T7iGYgW.js";import{s as xe}from"./ws-client-TTMa0XaT.js";import{t as H}from"./utils-B-9lSDIn.js";import{t as Se}from"./session-store-Df7_hhe9.js";import{T as Ce,d as U,f as we,x as Te}from"./stores-vuG0AaKy.js";import{r as Ee}from"./mailbox-store-C1mzoSqJ.js";import{d as De}from"./markdown-sSmz-Ua_.js";import{S as Oe,_ as ke,d as Ae,f as je,g as Me,l as Ne,u as Pe}from"./index-FHt-sKVF.js";var W=e(be(),1);function Fe(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Ie(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function G(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function K(e,t){for(let n of t){let t=G(e[n]);if(t)return t}}function q(e,t){for(let n of t){let t=Ie(e[n]);if(t!==void 0)return t}}function Le(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function Re(e){return e?e.split(/\r?\n/).length:0}function ze(e){let t=0,n=0;for(let r of e.split(/\r?\n/))r.startsWith(`+++`)||r.startsWith(`---`)||(r.startsWith(`+`)&&(t+=1),r.startsWith(`-`)&&(n+=1));return t||n?{added:t,removed:n}:null}function Be(e){let t=e.split(/\r?\n/,1)[0]?.trim()??e;return t.length>72?`${t.slice(0,69)}…`:t}function Ve(e){let t=e.toLowerCase().replace(/[.:/-]+/g,`_`);return/^(read|view|open_file|read_file)|file_read/.test(t)?`read`:/^(write|create|save)|file_write/.test(t)?`write`:/edit|update|patch|replace|apply_patch/.test(t)?`edit`:/bash|shell|terminal|exec|command|powershell|cmd/.test(t)?`terminal`:/fetch|browser|browse|http|url|web/.test(t)?`web`:/search|grep|find|glob|query/.test(t)?`search`:/memory|recall|remember/.test(t)?`memory`:`other`}function He(e,t){let n=(Array.isArray(e.fileTargets)?e.fileTargets:[]).flatMap(e=>{let t=Fe(e),n=K(t,[`filePath`,`file_path`,`path`]);return n?[{filePath:n,operation:G(t.operation),line:q(t,[`line`,`startLine`,`start_line`]),endLine:q(t,[`endLine`,`end_line`])}]:[]});if(n.length>0)return n;let r=K(t,[`file_path`,`filePath`,`path`,`filename`,`target_file`,`targetFile`]);return r?[{filePath:r,line:q(t,[`line`,`start_line`,`startLine`,`offset`]),endLine:q(t,[`end_line`,`endLine`])}]:[]}function Ue(e,t){let n=e?.line??q(t,[`line`,`start_line`,`startLine`,`offset`]),r=e?.endLine??q(t,[`end_line`,`endLine`]),i=q(t,[`limit`,`line_count`,`lineCount`]);return r===void 0&&n!==void 0&&i!==void 0&&i>0&&(r=n+i-1),n!==void 0&&r!==void 0?{start:n,end:r,label:`L${n}–${r}`}:n===void 0?{}:{start:n,label:`L${n}`}}function We(e,t,n,r,i,a){let o=Ue(a,n),s=a?.filePath??K(n,[`file_path`,`filePath`,`path`,`filename`]),c=s?Le(s):void 0;if(e===`read`)return{target:s,summary:i===void 0?o.label?`${o.label} queued to read`:`Reading file`:`${i.toLocaleString()} lines read`,lineLabel:o.label};if(e===`write`){let e=K(n,[`content`,`text`,`data`]),t=q(r,[`inputLines`])??(e?Re(e):void 0);return{target:s,summary:t===void 0?`Writing file`:`${t.toLocaleString()} lines written`,lineLabel:o.label}}if(e===`edit`){let e=K(n,[`patch`,`diff`]),t=e?ze(e):null,i=K(n,[`old_string`,`oldString`,`search`]),a=K(n,[`new_string`,`newString`,`replacement`]),c=q(r,[`addedLines`]),l=q(r,[`removedLines`]),u=q(r,[`oldLines`]),d=q(r,[`newLines`]);return{target:s,summary:t||c!==void 0||l!==void 0?`+${t?.added??c??0} / −${t?.removed??l??0} lines`:i!==void 0||a!==void 0||u!==void 0||d!==void 0?`${i?Re(i):u??0} → ${a?Re(a):d??0} lines`:o.label?`${o.label} updated`:`Updating file`,lineLabel:o.label}}if(e===`terminal`){let e=K(n,[`command`,`cmd`,`script`,`shell`])??t;return{summary:Be(e),target:e}}if(e===`web`){let e=K(n,[`url`,`href`,`uri`]),t=K(n,[`query`,`q`,`search`]);return{target:e??t,summary:e?`Fetched ${e}`:t?`Looked up “${t}”`:`Went online`}}if(e===`search`){let e=K(n,[`query`,`pattern`,`q`,`search`])??c;return{target:s??e,summary:e?`Searched “${e}”`:`Searching project`}}if(e===`memory`){let e=K(n,[`query`,`text`,`key`]);return{target:e,summary:e?`Recalled “${e}”`:`Checking memory`}}return{target:s,summary:c?`${t} · ${c}`:t}}function Ge(e,t){let n=G(t.name)??G(t.toolName);if(n)return n;if(e.kind===`agent:tool`)return e.target??void 0;if(e.kind.startsWith(`tool:`))return e.source}function Ke(e,t,n){return G(t.agentId)??G(t.subagentId)??(e.kind===`agent:tool`?e.source:void 0)??(e.source!==n&&e.source!==`filesystem`?e.source:void 0)??`leader`}function qe(e){return G(e.parentSessionId)??G(e.sessionId)}function Je(e,t){return e.kind===`tool:started`||e.kind===`tool:progress`?`running`:t.ok===!1?`failed`:`succeeded`}function Ye(e){if(![`tool:started`,`tool:progress`,`tool:executed`,`agent:tool`].includes(e.kind))return null;let t=Fe(e.data),n=Ge(e,t);if(!n)return null;let r=Ke(e,t,n),i=t.input,a=Fe(i),o=He(t,a),s=Ie(t.outputLines),c=Ve(n),l=We(c,n,a,t,s,o[0]),u=G(t.id),d=Math.floor(e.timestamp/2e3),f=Je(e,t),p=Ie(t.durationMs);return{id:u?`${r}:${u}`:`${r}:${n}:${d}`,agentId:r,agentName:G(t.agentName),sessionId:qe(t),toolName:n,kind:c,status:f,startedAt:f===`running`?e.timestamp:Math.max(0,e.timestamp-(p??0)),...f===`running`?{}:{completedAt:e.timestamp},durationMs:p,target:l.target,summary:l.summary,lineLabel:l.lineLabel,outputLines:s,outputBytes:Ie(t.outputBytes),outputTokens:Ie(t.outputTokens),input:i,output:G(t.output),fileTargets:o,raw:e.raw??t}}function Xe(e,t,n){return e?.length?tt(e.map(e=>({id:`snapshot:${n??`session`}:${t}:${e.id}`,kind:`tool:executed`,timestamp:e.completedAt,source:t,target:e.name,label:e.name,data:{...e,agentId:t,sessionId:n},flowGroup:`agent:${t}`})),t,n):[]}function Ze(e){return e?.length?e.map(e=>({id:e.id,direction:e.direction,from:e.from,to:e.to,type:e.type,subject:e.subject,body:``,priority:`normal`,timestamp:new Date(e.at).toISOString(),timestampMs:e.at,unread:e.direction===`incoming`})).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,12):[]}function Qe(e,t,n=3e4){let r=new Map;e.forEach((e,t)=>{for(let n of[e.agent.serverId,e.agent.mailboxId,e.agent.name]){let e=J(n);e&&!r.has(e)&&r.set(e,t)}});let i=new Set,a=[];for(let o of e){let e=o.mail[0];if(!e||i.has(e.id)||t-e.timestampMs>n)continue;let s=r.get(J(e.from)),c=r.get(J(e.to));s===void 0||c===void 0||s===c||(i.add(e.id),a.push({id:e.id,mail:e,fromIndex:s,toIndex:c}))}return a}function $e(e,t){return e.toLowerCase()===t.toLowerCase()}function J(e){return e?.trim().toLowerCase()??``}function et(e,t,n){let r=new Set([t.serverId,t.mailboxId,t.name].map(J).filter(e=>e.length>0)),i=n?`@session:${J(n)}`:``,a=J(t.role),o=J(t.serverId)===`leader`||J(t.serverId).startsWith(`leader@`)||a===`lead`||a===`leader`;return e.flatMap(e=>{let t=J(e.from),n=J(e.to),a=r.has(t),s=n===`*`||n===`all`||i.length>0&&n===i,c=(e.audience!==`leaders`||o)&&(r.has(n)||o&&s);if(!c&&!a)return[];let l=Date.parse(e.timestamp);return[{...e,direction:c?`incoming`:`outgoing`,timestampMs:Number.isFinite(l)?l:0,unread:c&&!Object.keys(e.readBy??{}).some(e=>r.has(J(e)))}]}).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,8)}function tt(e,t,n){let r=new Map;for(let i=e.length-1;i>=0;--i){let a=e[i];if(!a)continue;let o=Ye(a);if(!o||!$e(o.agentId,t)||n&&o.sessionId&&o.sessionId!==n)continue;let s=r.get(o.id);r.set(o.id,s?{...s,...o,startedAt:Math.min(s.startedAt,o.startedAt),fileTargets:o.fileTargets.length>0?o.fileTargets:s.fileTargets,input:o.input??s.input,output:o.output??s.output,raw:o.raw??s.raw}:o)}let i=[...r.values()].sort((e,t)=>(t.completedAt??t.startedAt)-(e.completedAt??e.startedAt));return i.filter((e,t)=>e.input!==void 0||e.fileTargets.length>0||e.output!==void 0||!i.some((n,r)=>r!==t&&n.toolName===e.toolName&&(n.input!==void 0||n.fileTargets.length>0||n.output!==void 0)&&Math.abs((n.completedAt??n.startedAt)-(e.completedAt??e.startedAt))<2500))}function nt(e,t,n){let r=Ve(t),i={read:`Reading a file`,write:`Writing a file`,edit:`Updating code`,terminal:`Running a command`,web:`Working online`,search:`Searching project`,memory:`Checking memory`,other:t};return{id:`${e}:live:${t}`,agentId:e,sessionId:n,toolName:t,kind:r,status:`running`,startedAt:Date.now(),summary:i[r],fileTargets:[]}}var Y=se(),rt={read:O,write:n,edit:n,terminal:y,web:N,search:v,memory:S,other:a};function it(e,t=46){if(!e||e.length<=t)return e;let n=e.split(/[\\/]/).slice(-2).join(`/`);return n.length<=t?`…/${n}`:`…${e.slice(-(t-1))}`}function at(e){return e===void 0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function ot(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function X({label:e,value:t}){return(0,Y.jsxs)(`div`,{className:`agent-office__detail-row`,children:[(0,Y.jsx)(`span`,{children:e}),(0,Y.jsx)(`strong`,{children:t})]})}function st({selected:e,onClose:t}){let{t:n}=m(),{call:r,agentName:i}=e,a=rt[r.kind],o=ot(r.input),c=ot(r.output);return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${r.toolName} details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:H(`agent-office__detail-icon`,`is-${r.kind}`),children:(0,Y.jsx)(a,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.toolCall`)}),(0,Y.jsx)(`h2`,{children:r.toolName})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`activity:agentOffice.closeDetails`),children:(0,Y.jsx)(j,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:H(`agent-office__status-dot`,r.status===`running`&&`is-active`,r.status===`failed`&&`is-failed`)}),(0,Y.jsx)(`strong`,{children:r.summary}),(0,Y.jsx)(`span`,{children:r.status})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.execution`)}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.agent`),value:i}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.started`),value:new Date(r.startedAt).toLocaleTimeString()}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.duration`),value:at(r.durationMs)}),r.sessionId&&(0,Y.jsx)(X,{label:n(`activity:agentOffice.session`),value:it(r.sessionId,28)})]}),(r.target||r.fileTargets.length>0)&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.target`)}),r.target&&(0,Y.jsx)(`code`,{className:`agent-office__target-code`,children:r.target}),r.fileTargets.map((e,t)=>(0,Y.jsxs)(`div`,{className:`agent-office__file-target`,children:[(0,Y.jsx)(s,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:e.filePath}),(e.line||e.endLine)&&(0,Y.jsxs)(`strong`,{children:[`L`,e.line??1,e.endLine?`–${e.endLine}`:``]})]},`${e.filePath}:${t}`))]}),(r.outputLines!==void 0||r.outputBytes!==void 0||r.outputTokens!==void 0)&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.resultSize`)}),(0,Y.jsxs)(`div`,{className:`agent-office__metric-grid`,children:[r.outputLines!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:r.outputLines.toLocaleString()}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.lines`)})]}),r.outputBytes!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:r.outputBytes.toLocaleString()}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.bytes`)})]}),r.outputTokens!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`strong`,{children:[`≈`,r.outputTokens.toLocaleString()]}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.tokens`)})]})]})]}),o&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.input`)}),(0,Y.jsx)(`pre`,{children:(0,Y.jsx)(`code`,{children:o})})]}),c&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.outputPreview`)}),(0,Y.jsx)(`pre`,{children:(0,Y.jsx)(`code`,{children:c})})]})]})}function ct({selected:e,onClose:t}){let{t:n}=m(),{mail:r,agentName:i}=e;return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${r.subject} details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-mail`,children:(0,Y.jsx)(h,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:r.direction===`incoming`?`INCOMING MAIL`:`OUTGOING MAIL`}),(0,Y.jsx)(`h2`,{children:r.subject})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`activity:agentOffice.closeMailDetails`),children:(0,Y.jsx)(j,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:H(`agent-office__status-dot`,r.unread&&`is-active`)}),(0,Y.jsxs)(`strong`,{children:[r.from,` → `,r.to]}),(0,Y.jsx)(`span`,{children:r.type}),r.audience===`leaders`&&(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ue,{className:`h-3 w-3`}),` `,n(`activity:mailbox.audienceLeaders`)]})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:mailbox.messages`)}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.agent`),value:i}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.started`),value:new Date(r.timestampMs).toLocaleTimeString()}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.priority`),value:r.priority}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.route`),value:`${r.from} → ${r.to}`})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:r.subject}),(0,Y.jsx)(`div`,{className:`agent-office__mail-body`,children:r.body})]})]})}function lt({selected:e,onClose:t}){let{t:n}=m();return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.agentName} task details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-task`,children:(0,Y.jsx)(fe,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`h2`,{children:e.agentName})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`activity:agentOffice.closeTaskDetails`),children:(0,Y.jsx)(j,{})})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.task`)}),e.taskId&&(0,Y.jsx)(X,{label:`ID`,value:e.taskId}),(0,Y.jsx)(`div`,{className:`agent-office__task-body`,children:e.task})]})]})}function ut({selected:e,onClose:t}){let{t:n}=m(),r=e.todos.filter(e=>e.status!==`completed`).length;return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.officeLabel} briefing`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-briefing`,children:(0,Y.jsx)(C,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.officeBriefing`)}),(0,Y.jsx)(`h2`,{children:e.officeLabel})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`activity:agentOffice.closeOfficeBriefing`),children:(0,Y.jsx)(j,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:H(`agent-office__status-dot`,(e.instructionActive||r>0)&&`is-active`)}),(0,Y.jsx)(`strong`,{children:e.telemetryConnected?n(`activity:agentOffice.activeTodos`):n(`activity:agentOffice.telemetryWaiting`)}),(0,Y.jsx)(`span`,{children:e.telemetryConnected?r:`—`})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.leaderPrompt`)}),e.promptAt!==void 0&&(0,Y.jsx)(X,{label:n(`activity:agentOffice.promptReceived`),value:new Date(e.promptAt).toLocaleString()}),(0,Y.jsx)(`div`,{className:`agent-office__task-body`,children:e.prompt??(e.telemetryConnected?n(`activity:agentOffice.noPrompt`):n(`activity:agentOffice.telemetryWaiting`))})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.todos`)}),(0,Y.jsx)(`div`,{className:`agent-office__todo-detail-list`,children:e.telemetryConnected?e.todos.length>0?e.todos.map(e=>(0,Y.jsxs)(`div`,{className:H(`agent-office__todo-detail`,`is-${e.status}`),children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.content}),(0,Y.jsx)(`small`,{children:n(`activity:agentOffice.todoStatus.${e.status}`)})]})]},e.id)):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.noActiveTodos`)}):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.todoTelemetryWaiting`)})})]})]})}function dt({selected:e,onClose:t}){return e.kind===`tool`?(0,Y.jsx)(st,{selected:e,onClose:t}):e.kind===`mail`?(0,Y.jsx)(ct,{selected:e,onClose:t}):e.kind===`task`?(0,Y.jsx)(lt,{selected:e,onClose:t}):(0,Y.jsx)(ut,{selected:e,onClose:t})}function ft(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 pt(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 mt(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 ht(e){if(!e)return;let t=e.split(`/`);return t[t.length-1]?.slice(0,18)}function gt(e,t=56){if(!e)return;let n=e.replace(/\s+/g,` `).trim();if(n)return n.length<=t?n:t<=1?`…`:`${n.slice(0,t-1).trimEnd()}…`}function _t(e,t){if(e.length===0)return{positions:new Map,columns:0,rows:0,columnWidth:380};let n=Math.max(1,...e.map(e=>e.agentCount)),r=Math.max(380,Math.min(3,n)*190+80),i=e=>270+Math.max(1,...e.map(e=>Math.ceil(Math.max(1,e.agentCount)/3)))*150,a=Math.max(320,t.width),o=Math.max(240,t.height),s=1,c=-1/0,l=1/0;for(let t=1;t<=e.length;t+=1){let n=[];for(let r=0;r<e.length;r+=t)n.push(i(e.slice(r,r+t)));let u=n.length,d=Math.max(660,Math.min(t,e.length)*r),f=320+n.reduce((e,t)=>e+t,0)+Math.max(0,u-1)*100,p=Math.min(a/d,o/f),m=Math.abs(Math.log(d/f/(a/o)));(p>c+1e-9||Math.abs(p-c)<=1e-9&&m<l)&&(s=t,c=p,l=m)}let u=new Map,d=370;for(let t=0;t<e.length;t+=s){let n=e.slice(t,t+s);n.forEach((e,t)=>{u.set(e.id,{x:600+(t-(n.length-1)/2)*r,y:d})}),d+=i(n)+100}return{positions:u,columns:s,rows:Math.ceil(e.length/s),columnWidth:r}}function vt(e,t,n,r=640){let i=Math.min(3,n),a=Math.floor(t/i),o=t%i;return{x:e-(Math.min(i,n-a*i)-1)*190/2+o*190,y:r+a*150}}function yt(e){return e===`tui`?`tui`:e===`repl`||e===`cli`?`repl`:`webui`}function bt(e){return e===`tui`?`TUI`:e===`repl`?`REPL`:`WebUI`}function xt(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 St(e){if(e)return e.split(`/`).filter(Boolean).pop()??e}function Ct(e){let t=St(e)??e??``;return t.length>10?`…${t.slice(-8)}`:t}function wt(e,t){let n=St(t);if(n)return e.find(e=>St(e.sessionId)===n)}function Tt(e,t){let n=xt(t.status);return{officeId:`${e}__agent-${t.id}`,serverId:t.id,name:t.name??t.id,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,currentTool:t.currentTool,currentTask:t.description,taskId:t.taskId,presenceSource:`fleet`}}function Et(e,t){return e===`cli`?`CLI`:e===`repl`?`REPL`:bt(t)}function Dt(e,t,n=[],r=new Map,i=Date.now()){let a=new Set,o=[];for(let n of e){let e=yt(n.clientType),r=Et(n.clientType,e),i=`client-${n.pid??n.sessionId}`,s=[],c=!1;for(let e of n.agents){a.add(e.id);let n=t.get(e.id),r=xt(n?.status??e.status);(r===`active`||r===`streaming`)&&(c=!0),s.push({officeId:`${i}__agent-${e.id}`,serverId:e.id,name:n?.name??e.name??e.id,status:r,iteration:n?.iteration??e.iterations??0,toolCalls:n?.toolCalls??e.toolCalls??0,costUsd:n?.costUsd??e.costUsd??0,tokensIn:n?.tokensIn??e.tokensIn??0,tokensOut:n?.tokensOut??e.tokensOut??0,ctxPct:n?.ctxPct??e.ctxPct,model:n?.model??e.model,lastActivityAt:e.lastActivityAt,currentTool:n?.currentTool??e.currentTool,currentTask:e.currentTask??n?.description,taskId:e.taskId??n?.taskId,recentTools:e.recentTools,recentMail:e.recentMail,activity:e.activity,presenceSource:`registry`})}let l=n.status===`closing`||n.status===`stale`||n.status===`lost`?`offline`:c?`active`:`idle`,u=n.agents.find(e=>e.id===`leader`);o.push({id:i,type:e,label:`${r} · ${n.pid?`PID ${n.pid}`:Ct(n.sessionId)}`,sublabel:[`session ${Ct(n.sessionId)}`,n.gitBranch?`⎇ ${n.gitBranch}`:``,n.workingDir?n.workingDir.split(/[\\/]/).filter(Boolean).pop():``].filter(Boolean).join(` · `),status:l,sessionId:n.sessionId,pid:n.pid,branch:n.gitBranch,workingDir:n.workingDir,startedAt:n.startedAt,lastHeartbeatAt:n.lastHeartbeatAt,latestPrompt:u?.latestPrompt,latestPromptAt:u?.latestPromptAt,activeInstruction:u?.status===`running`||u?.status===`streaming`?u.latestPrompt??u.currentTask:void 0,todos:u?.todos,agents:s})}for(let e of n.filter(e=>e.online)){let t=wt(o,e.sessionId);if(!t)continue;let n=e.name.trim().toLowerCase(),r=t.agents.find(t=>t.serverId===e.agentId||t.name.trim().toLowerCase()===n);r&&(a.add(e.agentId),r.mailboxId=e.agentId,r.role=e.role,r.currentTask=r.currentTask??e.currentTask,r.currentTool=r.currentTool??e.currentTool)}let s=[...t.values()].filter(e=>!a.has(e.id)),c,l=()=>{if(c)return c;let e=o.find(e=>e.type===`webui`);return e?(c=e,e):(c={id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI`,status:`idle`,agents:[]},o.push(c),c)};for(let e of s){let t=wt(o,e.sessionId)??l(),n=Tt(t.id,e);(n.status===`active`||n.status===`streaming`)&&t.status!==`offline`&&(t.status=`active`),t.agents.push(n),a.add(e.id)}for(let[e,t]of r){if(a.has(e)||i-t.finishedAt>9e5)continue;let n=wt(o,t.agent.sessionId);n&&n.agents.push(Tt(n.id,t.agent))}return o.length===0&&o.push({id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI · connecting…`,status:`idle`,agents:[]}),o}function Ot(e){return e.startsWith(`tool`)?`hsl(var(--warning))`:e.startsWith(`mailbox`)?`hsl(var(--info))`:e.startsWith(`provider`)?`hsl(var(--primary))`:e.startsWith(`agent`)||e.startsWith(`subagent`)?`hsl(var(--success))`:e.includes(`error`)?`hsl(var(--destructive))`:`hsl(var(--primary))`}var kt=new Set([`completed`,`failed`,`timeout`,`stopped`]);function At(e){let t=(0,W.useRef)(new Map).current;return(0,W.useMemo)(()=>{let n=Date.now(),r=new Set;for(let i of e.values())if(r.add(i.id),kt.has(i.status)){let e=t.get(i.id);e?e.agent=i:t.set(i.id,{agent:i,finishedAt:i.completedAt??n})}else t.delete(i.id);for(let[e,n]of[...t.entries()])!r.has(e)&&!kt.has(n.agent.status)&&t.set(e,{agent:{...n.agent,status:`stopped`},finishedAt:n.finishedAt});for(let[e,r]of t)n-r.finishedAt>9e5&&t.delete(e);return{map:t,now:n}},[e,t])}var jt=[`bot`,`cactus`,`duck`,`radio`],Mt={leader:`plum`,builder:`ocean`,researcher:`mint`,reviewer:`rose`,planner:`amber`,operator:`graphite`},Nt={leader:0,builder:1,researcher:2,reviewer:3,planner:4,operator:5},Pt={read:O,write:n,edit:n,terminal:y,web:N,search:v,memory:S,other:a},Ft={leader:re,builder:a,researcher:O,reviewer:t,planner:fe,operator:y};function It(e){if(e.serverId===`leader`||e.serverId.startsWith(`leader@`))return`leader`;let t=[e.role,e.name,e.currentTask].filter(Boolean).join(` `).toLowerCase();return/review|critic|audit|security|test|qa|verify|checker/.test(t)?`reviewer`:/research|analyst|explor|investig|search|hunter|recon/.test(t)?`researcher`:/plan|architect|design|coordinat|strateg|spec/.test(t)?`planner`:/build|implement|code|develop|engineer|refactor|fix|frontend|backend/.test(t)?`builder`:`operator`}function Lt(e,t){let n=2166136261;for(let t=0;t<e.length;t+=1)n^=e.charCodeAt(t),n=Math.imul(n,16777619);let r=n>>>0;return{palette:Mt[t],layout:r%4,clutter:Math.floor(r/4)%3,avatar:Nt[t],motion:Math.floor(r/31)%4,charm:jt[Math.floor(r/47)%jt.length]}}function Rt(e,t=22){let n=e.split(`/`).filter(Boolean).pop()??e;return n.length>t?`${n.slice(0,t-1)}…`:n}function zt(e,t=46){if(!e||e.length<=t)return e;let n=e.split(/[\\/]/).slice(-2).join(`/`);return n.length<=t?`…/${n}`:`…${e.slice(-(t-1))}`}function Bt(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m`:`${Math.floor(r/60)}h`}function Vt(e,t){if(!e)return`—`;let n=Date.parse(e);if(!Number.isFinite(n))return`—`;let r=Math.max(0,Math.floor((t-n)/1e3));return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}function Ht(e){let t=new Set,n=new Set,r=new Set,i=0,a=0,o={files:0,reads:0,writes:0,edits:0,linesAdded:0,linesRemoved:0,terminalCalls:0,incomingMail:0,outgoingMail:0};for(let s of e){let e=s.agent.activity;for(let n of e?.filesTouched??[])t.add(n);o.reads+=e?.reads??0,o.writes+=e?.writes??0,o.edits+=e?.edits??0,o.linesAdded+=e?.linesAdded??0,o.linesRemoved+=e?.linesRemoved??0,o.terminalCalls+=e?.terminalCalls??0,i+=e?.mailReceived??0,a+=e?.mailSent??0;for(let e of s.mail)(e.direction===`incoming`?n:r).add(e.id)}return o.files=t.size,o.incomingMail=Math.max(i,n.size),o.outgoingMail=Math.max(a,r.size),o}function Ut(e,t,n){return n.map((n,r)=>({...nt(e.serverId,n.name,t.sessionId),id:`${e.serverId}:log:${n.at}:${r}`,kind:Ve(n.name),status:n.ok?`succeeded`:`failed`,startedAt:Math.max(0,n.at-n.durationMs),completedAt:n.at,durationMs:n.durationMs,summary:n.ok?`${n.name} completed`:`${n.name} failed`}))}function Wt(...e){let t=[];for(let n of e.flat()){let e=n.completedAt??n.startedAt;t.some(t=>(t.id===n.id||t.toolName===n.toolName)&&Math.abs((t.completedAt??t.startedAt)-e)<2500)||t.push(n)}return t.sort((e,t)=>(t.completedAt??t.startedAt)-(e.completedAt??e.startedAt))}function Gt(...e){let t=new Map;for(let n of e.flat())t.set(n.id,n);return[...t.values()].sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,12)}function Kt({kind:e,active:t}){let n=Pt[e];return(0,Y.jsxs)(`span`,{className:H(`agent-office__tool-glyph`,`is-${e}`,t&&`is-active`),children:[e===`read`&&(0,Y.jsx)(s,{className:`agent-office__file-underlay`,"aria-hidden":`true`}),(0,Y.jsx)(n,{"aria-hidden":`true`})]})}function qt({active:e,failed:t,role:n,variant:r,motion:i}){let a=Ft[n];return(0,Y.jsxs)(`div`,{className:H(`agent-office__avatar`,`is-${n}`,`is-avatar-${r}`,`is-motion-${i}`,e&&`is-active`,!e&&!t&&`is-idle`,t&&`is-failed`),"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{className:`agent-office__avatar-chair`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-body`}),(0,Y.jsxs)(`span`,{className:`agent-office__avatar-head`,children:[(0,Y.jsx)(`span`,{className:`agent-office__avatar-hair`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-face`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-mouth`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-headset`})]}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-arm`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-prop`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-role-badge`,children:(0,Y.jsx)(a,{})})]})}function Jt({call:e,compact:n=!1,onSelect:r}){let i=e.status===`running`;return(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__parcel`,`is-${e.kind}`,n&&`is-compact`,i&&`is-running`,e.status===`failed`&&`is-failed`),onClick:r,"aria-label":`${e.toolName}: ${e.summary}`,children:[(0,Y.jsx)(Kt,{kind:e.kind,active:i}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsxs)(`span`,{className:`agent-office__parcel-topline`,children:[(0,Y.jsx)(`strong`,{children:e.toolName}),e.lineLabel&&(0,Y.jsx)(`span`,{className:`agent-office__line-chip`,children:e.lineLabel})]}),!n&&e.target&&(0,Y.jsx)(`span`,{className:`agent-office__parcel-target`,children:zt(e.target)}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.summary})]}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-state`,"aria-hidden":`true`,children:i?(0,Y.jsx)(`span`,{className:`agent-office__pulse-dot`}):e.status===`failed`?(0,Y.jsx)(j,{}):(0,Y.jsx)(t,{})})]})}function Yt({mail:e,compact:t=!1,onSelect:n}){let r=e.direction===`incoming`;return(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__mail-parcel`,t&&`is-compact`,r?`is-incoming`:`is-outgoing`,e.unread&&`is-unread`),onClick:n,"aria-label":`${r?`Incoming`:`Outgoing`} mail: ${e.subject}`,children:[(0,Y.jsx)(`span`,{className:`agent-office__mail-icon`,children:r?(0,Y.jsx)(_e,{"aria-hidden":`true`}):(0,Y.jsx)(F,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsx)(`strong`,{children:r?`${e.from} →`:`→ ${e.to}`}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.subject})]}),(0,Y.jsx)(h,{"aria-hidden":`true`})]})}function Xt({office:e,now:t}){let{t:r}=m(),{client:i,agents:a,stats:o}=e,s=i.lastHeartbeatAt?Date.parse(i.lastHeartbeatAt):NaN,c=Number.isFinite(s)&&t-s<2e4,l=Number.isFinite(s)&&!c,u=a.some(({agent:e})=>e.presenceSource===`registry`),f=c?`VERIFIED`:l?`DELAYED`:u?`REGISTRY`:`LOCAL`,p=a.some(({agent:e})=>e.recentTools!==void 0||e.activity!==void 0),g=a.some(({agent:e})=>e.toolCalls>0&&e.recentTools===void 0&&e.activity===void 0);return(0,Y.jsxs)(`header`,{className:`agent-office__client-header`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__client-title`,children:[(0,Y.jsx)(`span`,{className:`agent-office__client-icon`,children:(0,Y.jsx)(re,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{className:`agent-office__client-copy`,children:[(0,Y.jsx)(`strong`,{children:i.label}),(0,Y.jsx)(`span`,{children:i.sublabel||i.sessionId})]}),(0,Y.jsxs)(`div`,{className:`agent-office__client-presence`,children:[(0,Y.jsxs)(`span`,{className:`agent-office__client-agent-count`,children:[a.length,` `,r(`activity:agentOffice.agents`)]}),(0,Y.jsxs)(`span`,{className:H(`agent-office__presence-chip`,!l&&`is-live`,l&&`is-legacy`),children:[(0,Y.jsx)(L,{"aria-hidden":`true`}),` `,f]}),(0,Y.jsxs)(`span`,{className:`agent-office__presence-chip`,children:[(0,Y.jsx)(ae,{"aria-hidden":`true`}),` `,Vt(i.startedAt,t),` UP`]}),(0,Y.jsxs)(`span`,{className:H(`agent-office__presence-chip`,g?`is-legacy`:p&&`is-telemetry`),children:[(0,Y.jsx)(d,{"aria-hidden":`true`}),g?`RECONNECT`:p?`TOOLS LIVE`:`READY`]})]})]}),(0,Y.jsxs)(`fieldset`,{className:`agent-office__client-stats`,"aria-label":r(`activity:agentOffice.sessionActivityTotals`),children:[(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.uniqueFilesTouched`),children:[(0,Y.jsx)(x,{}),` `,(0,Y.jsx)(`strong`,{children:o.files}),` `,r(`activity:agentOffice.files`)]}),(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.fileReads`),children:[(0,Y.jsx)(O,{}),` `,(0,Y.jsx)(`strong`,{children:o.reads}),` `,r(`activity:agentOffice.read`)]}),(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.filesWritten`),children:[(0,Y.jsx)(n,{}),` `,(0,Y.jsx)(`strong`,{children:o.writes}),` `,r(`activity:agentOffice.write`)]}),(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.filesEdited`),children:[(0,Y.jsx)(n,{}),` `,(0,Y.jsx)(`strong`,{children:o.edits}),` `,r(`activity:agentOffice.edit`)]}),(0,Y.jsxs)(`span`,{className:`agent-office__client-delta`,title:r(`activity:agentOffice.linesAddedAndRemoved`),children:[(0,Y.jsxs)(`strong`,{children:[`+`,o.linesAdded]}),` / `,(0,Y.jsxs)(`b`,{children:[`−`,o.linesRemoved]})]}),(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.terminalCommands`),children:[(0,Y.jsx)(y,{}),` `,(0,Y.jsx)(`strong`,{children:o.terminalCalls}),` `,r(`activity:agentOffice.term`)]}),(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.incomingAndOutgoingMail`),children:[(0,Y.jsx)(h,{}),` `,(0,Y.jsx)(`strong`,{children:o.incomingMail}),`↓ `,(0,Y.jsx)(`strong`,{children:o.outgoingMail}),`↑`]})]})]})}function Zt({office:e,now:t,onSelect:n}){let{t:r}=m(),{client:i}=e,a=i.todos!==void 0,o=i.todos??[],s=o.filter(e=>e.status!==`completed`),c=o.length-s.length,l=!!i.activeInstruction,u=i.activeInstruction??i.latestPrompt,f=i.latestPromptAt!==void 0&&t-i.latestPromptAt<3e4,p=()=>n({kind:`briefing`,officeLabel:i.label,prompt:u,promptAt:i.latestPromptAt,instructionActive:l,telemetryConnected:a,todos:o});return(0,Y.jsxs)(`section`,{className:`agent-office__briefing`,"aria-label":r(`activity:agentOffice.officeBriefing`),children:[(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__prompt-card`,l&&`is-active`,f&&`is-fresh`,!a&&`is-waiting`),onClick:p,children:[(0,Y.jsx)(`span`,{className:`agent-office__briefing-icon is-prompt`,children:(0,Y.jsx)(C,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__briefing-copy`,children:[(0,Y.jsx)(`span`,{children:r(l?`activity:agentOffice.activeInstruction`:`activity:agentOffice.leaderPrompt`)}),(0,Y.jsx)(`strong`,{children:u??r(a?`activity:agentOffice.noPrompt`:`activity:agentOffice.telemetryWaiting`)})]}),l&&(0,Y.jsxs)(`span`,{className:`agent-office__instruction-live`,children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),` `,r(`activity:agentOffice.live`)]}),i.latestPromptAt!==void 0&&(0,Y.jsx)(`time`,{dateTime:new Date(i.latestPromptAt).toISOString(),children:Bt(i.latestPromptAt,t)})]}),(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__todo-board`,s.length>0&&`has-active`,!a&&`is-waiting`),onClick:p,children:[(0,Y.jsxs)(`span`,{className:`agent-office__todo-heading`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(fe,{"aria-hidden":`true`}),` `,r(`activity:agentOffice.activeTodos`)]}),(0,Y.jsx)(`strong`,{children:a?r(`activity:agentOffice.todoProgress`,{done:c,total:o.length}):r(`activity:agentOffice.syncWaiting`)})]}),(0,Y.jsxs)(`span`,{className:`agent-office__todo-preview`,children:[a?s.length>0?s.slice(0,3).map(e=>(0,Y.jsxs)(`span`,{className:H(`agent-office__todo-line`,`is-${e.status}`),children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:e.activeForm||e.content})]},e.id)):(0,Y.jsxs)(`span`,{className:`agent-office__todo-empty`,children:[(0,Y.jsx)(b,{"aria-hidden":`true`}),o.length>0?r(`activity:agentOffice.allTodosDone`):r(`activity:agentOffice.noActiveTodos`)]}):(0,Y.jsxs)(`span`,{className:`agent-office__todo-empty is-waiting`,children:[(0,Y.jsx)(d,{"aria-hidden":`true`}),r(`activity:agentOffice.todoTelemetryWaiting`)]}),s.length>3&&(0,Y.jsx)(`span`,{className:`agent-office__todo-more`,children:r(`activity:agentOffice.moreTodos`,{count:s.length-3})})]})]})]})}function Qt({active:e}){let{t}=m();return(0,Y.jsxs)(`div`,{className:`agent-office__parcel agent-office__parcel--empty`,children:[(0,Y.jsx)(`span`,{className:`agent-office__tool-glyph`,children:(0,Y.jsx)(I,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsx)(`strong`,{children:t(e?`activity:agentOffice.thinking`:`activity:agentOffice.waiting`)}),(0,Y.jsx)(`span`,{children:t(e?`activity:agentOffice.preparing`:`activity:agentOffice.deskReady`)})]})]})}function $t({model:e,now:n,onSelect:r,routedMailIds:i}){let{t:o}=m(),{agent:s,client:c,current:l,display:u,history:f,mail:p}=e,g=s.status===`active`||s.status===`streaming`,_=s.status===`error`,v=p[0],y=It(s),b=Lt(`${c.sessionId}:${s.serverId}:${s.name}`,y),x=v&&n-v.timestampMs<3e4&&!i?.has(v.id),S=f.slice(0,6),C=S[0]?.completedAt??S[0]?.startedAt??u?.completedAt??u?.startedAt,w=l?`is-tool-${l.kind}`:void 0;return(0,Y.jsxs)(`article`,{className:H(`agent-office__lane`,`is-desk-${b.palette}`,`is-layout-${b.layout}`,`is-clutter-${b.clutter}`,g&&`is-active`,_&&`is-failed`),children:[(0,Y.jsxs)(`div`,{className:`agent-office__identity`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__identity-line`,children:[(0,Y.jsx)(`span`,{className:H(`agent-office__status-dot`,g&&`is-active`,_&&`is-failed`)}),(0,Y.jsx)(`strong`,{title:s.name,children:s.name}),(0,Y.jsxs)(`span`,{className:`agent-office__agent-verified`,title:s.presenceSource===`registry`?`Verified by live session registry`:`Verified by local fleet state`,children:[(0,Y.jsx)(t,{"aria-hidden":`true`}),s.presenceSource===`registry`?`LIVE`:`LOCAL`]})]}),(0,Y.jsx)(`span`,{className:`agent-office__role`,children:s.role??(s.serverId===`leader`||s.serverId.startsWith(`leader@`)?o(`activity:agentOffice.leadAgent`):o(`activity:agentOffice.agent`))}),(0,Y.jsxs)(`div`,{className:`agent-office__agent-meta`,children:[(0,Y.jsx)(`span`,{children:c.branch?`⎇ ${c.branch}`:c.type.toUpperCase()}),(0,Y.jsx)(`span`,{children:o(`activity:agentOffice.callsCount`,{count:s.toolCalls})}),s.model&&(0,Y.jsx)(`span`,{className:`agent-office__model-chip`,title:s.model,children:Rt(s.model)})]}),s.currentTask&&(0,Y.jsxs)(`button`,{type:`button`,className:`agent-office__agent-task`,onClick:()=>r({kind:`task`,task:s.currentTask??``,taskId:s.taskId,agentName:s.name}),children:[(0,Y.jsx)(fe,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:o(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`small`,{children:s.currentTask})]})]}),!s.currentTask&&g&&(0,Y.jsxs)(`div`,{className:`agent-office__agent-task is-missing`,children:[(0,Y.jsx)(d,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:o(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`small`,{children:c.todos===void 0?o(`activity:agentOffice.telemetryWaiting`):o(`activity:agentOffice.taskNotReported`)})]})]}),v&&(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__identity-mail`,v.unread&&`is-unread`),onClick:()=>r({kind:`mail`,mail:v,agentName:s.name}),"aria-label":`${p.length} mail messages. Latest: ${v.subject}`,children:[(0,Y.jsx)(h,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(`strong`,{children:[p.length,` MAIL`]}),(0,Y.jsx)(`small`,{children:v.subject})]})]})]}),(0,Y.jsxs)(`div`,{className:H(`agent-office__scene`,w),children:[(0,Y.jsxs)(`div`,{className:`agent-office__window`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsxs)(`div`,{className:`agent-office__plant`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`div`,{className:`agent-office__desk-zone`,"aria-hidden":`true`,children:[(0,Y.jsx)(qt,{active:g,failed:_,role:y,variant:b.avatar,motion:b.motion}),(0,Y.jsx)(`span`,{className:`agent-office__monitor`,children:u?(0,Y.jsx)(Kt,{kind:u.kind,active:l!==void 0}):(0,Y.jsx)(a,{})}),(0,Y.jsxs)(`span`,{className:`agent-office__activity-fx`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsx)(`span`,{className:`agent-office__desk`}),(0,Y.jsx)(`span`,{className:`agent-office__desk-lamp`}),(0,Y.jsxs)(`span`,{className:`agent-office__desk-clutter`,children:[(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`span`,{className:H(`agent-office__desk-charm`,`is-${b.charm}`),children:[(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`span`,{className:H(`agent-office__mug`,`is-${y}`),children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),(0,Y.jsx)(`b`,{"aria-hidden":`true`})]})]}),x&&(0,Y.jsx)(`div`,{className:H(`agent-office__mail-flyby`,`is-${v.direction}`),children:(0,Y.jsx)(Yt,{mail:v,compact:!0,onSelect:()=>r({kind:`mail`,mail:v,agentName:s.name})},v.id)}),(0,Y.jsxs)(`div`,{className:H(`agent-office__conveyor`,l&&`is-moving`),children:[(0,Y.jsxs)(`div`,{className:`agent-office__belt`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsx)(`div`,{className:`agent-office__current-action`,children:u?(0,Y.jsx)(Jt,{call:u,onSelect:()=>r({kind:`tool`,call:u,agentName:s.name})},u.id):(0,Y.jsx)(Qt,{active:g})})]})]}),(0,Y.jsxs)(`div`,{className:`agent-office__history`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__history-heading`,children:[(0,Y.jsx)(`span`,{children:o(`activity:agentOffice.recent`)}),C!==void 0&&(0,Y.jsx)(`span`,{children:Bt(C,n)})]}),(0,Y.jsx)(`div`,{className:`agent-office__history-list`,children:S.length>0?S.map(e=>(0,Y.jsx)(Jt,{call:e,compact:!0,onSelect:()=>r({kind:`tool`,call:e,agentName:s.name})},`tool:${e.id}`)):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:s.toolCalls>0&&s.recentTools===void 0&&s.activity===void 0?o(`activity:agentOffice.telemetryReconnect`):o(`activity:agentOffice.noCalls`)})})]})]})}function en(e){return e.agent.status===`active`||e.agent.status===`streaming`||e.agent.status===`error`}function tn({agents:e,now:t,onSelect:n}){let{t:r}=m();return(0,Y.jsxs)(`section`,{className:`agent-office__lounge`,"aria-label":r(`activity:agentOffice.breakRoom`),children:[(0,Y.jsxs)(`header`,{className:`agent-office__lounge-heading`,children:[(0,Y.jsx)(f,{"aria-hidden":`true`}),(0,Y.jsx)(`strong`,{children:r(`activity:agentOffice.breakRoom`)}),(0,Y.jsx)(`span`,{children:r(`activity:agentOffice.onBreak`,{count:e.length})})]}),(0,Y.jsx)(`div`,{className:`agent-office__lounge-seats`,children:e.map(e=>{let{agent:i,history:a,mail:o}=e,s=It(i),c=Ft[s],l=o.filter(e=>e.unread).length,u=a[0]?.completedAt??a[0]?.startedAt,d=o[0],f=()=>{i.currentTask?n({kind:`task`,task:i.currentTask,taskId:i.taskId,agentName:i.name}):d&&n({kind:`mail`,mail:d,agentName:i.name})},p=!!i.currentTask||!!d;return(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__lounge-seat`,`is-${s}`),onClick:f,disabled:!p,children:[(0,Y.jsx)(`span`,{className:`agent-office__lounge-avatar`,children:(0,Y.jsx)(c,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__lounge-copy`,children:[(0,Y.jsx)(`strong`,{children:i.name}),(0,Y.jsx)(`small`,{children:i.role??r(`activity:agentOffice.agent`)})]}),(0,Y.jsxs)(`span`,{className:`agent-office__lounge-meta`,children:[u!==void 0&&(0,Y.jsx)(`span`,{children:Bt(u,t)}),l>0&&(0,Y.jsxs)(`span`,{className:`agent-office__lounge-mail`,children:[(0,Y.jsx)(h,{"aria-hidden":`true`}),` `,l]})]})]},e.key)})})]})}function nn(){let{t:e}=m(),t=we(e=>e.liveSessions),n=we(e=>e.aggregate),r=Ce(e=>e.agents),i=Ee(e=>e.agents),a=Ee(e=>e.messages),o=xe(e=>e.toolEvents),s=Se(e=>e.projectName),c=At(r),[l,u]=(0,W.useState)(null),g=(0,W.useMemo)(()=>Dt(t,r,i,c.map,c.now),[t,r,i,c]),_=(0,W.useMemo)(()=>g.flatMap(e=>e.agents.map(t=>{let n=Wt(tt(o,t.serverId,e.sessionId),Xe(t.recentTools,t.serverId,e.sessionId),Ut(t,e,r.get(t.serverId)?.toolLog??[])),i=t.status===`active`||t.status===`streaming`,s=n.find(e=>e.status===`running`);!s&&i&&t.currentTool&&(s=nt(t.serverId,t.currentTool,e.sessionId));let c=s??n[0],l=n.filter(e=>e.status!==`running`).slice(0,6),u=Gt(Ze(t.recentMail),et(a,t,e.sessionId));return{key:t.officeId,client:e,agent:t,calls:n,current:s,display:c,history:l,mail:u}})),[g,r,a,o]),v=(0,W.useMemo)(()=>g.map(e=>{let t=_.filter(t=>t.client.id===e.id);return{client:e,agents:t,stats:Ht(t)}}).filter(e=>e.agents.length>0),[g,_]),y=_.filter(({agent:e})=>e.status===`active`||e.status===`streaming`).length,b=s||t.find(e=>e.projectName)?.projectName||e(`activity:office.fleetHq`),x=Date.now();return(0,Y.jsxs)(`div`,{className:`agent-office`,children:[(0,Y.jsxs)(`header`,{className:`agent-office__header`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__title`,children:[(0,Y.jsx)(`span`,{className:`agent-office__brand-mark`,children:(0,Y.jsx)(re,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.liveProjectOffice`)}),(0,Y.jsx)(`h1`,{children:b})]})]}),(0,Y.jsxs)(`div`,{className:`agent-office__live-pill`,children:[(0,Y.jsx)(`span`,{}),` `,e(`activity:agentOffice.live`)]}),(0,Y.jsxs)(`div`,{className:`agent-office__summary`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(I,{}),(0,Y.jsx)(`strong`,{children:_.length}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.agents`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(he,{}),(0,Y.jsx)(`strong`,{children:y}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.working`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(d,{}),(0,Y.jsx)(`strong`,{children:n.toolCalls.toLocaleString()}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.toolCalls`)})]})]})]}),(0,Y.jsx)(`main`,{className:`agent-office__floor`,children:_.length>0?v.map(t=>{let n=t.agents.filter(en),r=t.agents.filter(e=>!en(e)),i=Qe(n,x),a=new Set(i.map(e=>e.id));return(0,Y.jsxs)(`section`,{className:`agent-office__client-office`,children:[(0,Y.jsx)(Xt,{office:t,now:x}),(0,Y.jsx)(Zt,{office:t,now:x,onSelect:u}),n.length>0&&(0,Y.jsxs)(`div`,{className:`agent-office__column-headings`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.team`)}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.liveDesk`)}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.lastActions`)})]}),(0,Y.jsxs)(`div`,{className:`agent-office__client-desks`,children:[n.map(e=>(0,Y.jsx)($t,{model:e,now:x,onSelect:u,routedMailIds:a},e.key)),i.length>0&&(0,Y.jsx)(`div`,{className:`agent-office__mail-routes`,"aria-hidden":`true`,children:i.map(e=>(0,Y.jsx)(`div`,{className:`agent-office__mail-route`,style:{"--from":`${(e.fromIndex+.5)/n.length*100}%`,"--to":`${(e.toIndex+.5)/n.length*100}%`},children:(0,Y.jsx)(`span`,{className:`agent-office__mail-route-parcel`,children:(0,Y.jsx)(h,{"aria-hidden":`true`})})},e.id))}),n.length===0&&(0,Y.jsxs)(`div`,{className:`agent-office__desks-empty`,children:[(0,Y.jsx)(f,{"aria-hidden":`true`}),e(`activity:agentOffice.desksEmpty`)]})]}),r.length>0&&(0,Y.jsx)(tn,{agents:r,now:x,onSelect:u})]},t.client.id)}):(0,Y.jsxs)(`div`,{className:`agent-office__empty-state`,children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(L,{"aria-hidden":`true`})}),(0,Y.jsx)(`h2`,{children:e(`activity:agentOffice.readyTitle`)}),(0,Y.jsx)(`p`,{children:e(`activity:agentOffice.readyBody`)})]})}),(0,Y.jsxs)(`footer`,{className:`agent-office__footer`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`agent-office__status-dot is-active`}),` `,e(`activity:agentOffice.liveEvent`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(p,{}),` `,e(`activity:agentOffice.connectedSessions`,{count:t.length})]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ae,{}),` `,e(`activity:agentOffice.detailHint`)]})]}),l&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,className:`agent-office__detail-backdrop`,onClick:()=>u(null),"aria-label":e(`activity:agentOffice.closeToolDetails`)}),(0,Y.jsx)(dt,{selected:l,onClose:()=>u(null)})]})]})}function rn(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 an={user:{Icon:ve,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-transparent`,bubbleBorder:`border-primary/40`,textColor:`text-foreground`},assistant:{Icon:I,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:u,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:I,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:c,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 on({entry:e}){let{t}=m();return e.role===`error`?(0,Y.jsx)(Ae,{text:e.text}):e.role===`tool`?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 tool-details`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,Y.jsx)(u,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{className:`font-mono`,children:e.tool??t(`activity:watch.toolFallback`)}),e.durationMs!==void 0&&(0,Y.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground font-normal tabular-nums`,children:[(0,Y.jsx)(r,{className:`h-3 w-3 inline mr-0.5 align-text-bottom`}),rn(e.durationMs)]})]}),e.input!==void 0&&e.input!==null&&(0,Y.jsx)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:(0,Y.jsx)(Ne,{input:e.input})}),e.output!==void 0&&e.output!==null?(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:typeof e.output==`string`?(0,Y.jsx)(Pe,{remarkPlugins:[De],rehypePlugins:ke,components:Me,children:e.output}):(0,Y.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,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,Y.jsx)(Pe,{remarkPlugins:[De],rehypePlugins:ke,components:Me,children:e.text})}):null,e.isError&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:t(`activity:watch.toolFailed`)}),e.text&&(0,Y.jsx)(`pre`,{className:`mt-1 text-xs whitespace-pre-wrap text-destructive/80`,children:e.text})]})]}):(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,Y.jsx)(Pe,{remarkPlugins:[De],rehypePlugins:ke,components:Me,children:e.text})})}function sn({entry:e,isContinuation:t=!1}){let{t:n}=m(),r=an[e.role],i=r.Icon;return(0,Y.jsxs)(`div`,{className:`group flex gap-3 animate-message msg-bubble rounded-lg transition-shadow`,children:[t?(0,Y.jsx)(`div`,{className:`flex-shrink-0 w-8`}):(0,Y.jsx)(`div`,{className:H(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,r.avatarBg,r.avatarColor,r.avatarRing),children:(0,Y.jsx)(i,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0 flex-1`,children:[!t&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:H(`text-xs font-medium`,r.textColor),children:e.role===`tool`&&e.tool?e.tool:n(r.labelKey)}),(0,Y.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,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`· `,rn(e.durationMs)]})]}),(0,Y.jsx)(`div`,{className:H(`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,Y.jsx)(`div`,{className:H(`text-sm leading-relaxed markdown-content`,r.textColor),children:(0,Y.jsx)(on,{entry:e})})}),e.text&&e.role!==`error`&&(0,Y.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Y.jsx)(je,{text:e.text,label:n(`common:action.copy`)})})]})]})}var cn=[`steer`,`ask`,`assign`,`note`],ln=2500;function un({sessionId:e,limit:t=200}){let[n,r]=(0,W.useState)(null),{t:i}=m(),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(``),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),[h,g]=(0,W.useState)(`steer`),[_,v]=(0,W.useState)(`high`),[y,b]=(0,W.useState)([]),[x,S]=(0,W.useState)(!1),C=(0,W.useRef)(null),w=(0,W.useRef)(!0),T=(0,W.useRef)(!0),E=we(e=>e.liveSessions),D=(0,W.useMemo)(()=>E.find(t=>t.sessionId===e),[E,e]),O=(0,W.useMemo)(()=>{let e=D;return e?`${e.status}|${e.agents.map(e=>`${e.id}:${e.status}:${e.toolCalls??0}:${e.iterations??0}`).join(`,`)}`:``},[D]),k=D?.status===`active`||(D?.agents.some(e=>e.status===`running`||e.status===`streaming`)??!1),A=(0,W.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]),ee=(0,W.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]),j=(0,W.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();T.current&&(r(i),o(null))}catch(e){T.current&&o(e instanceof Error?e.message:String(e))}},[e,t]),M=(0,W.useCallback)(async()=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/mailbox`);if(!t.ok)return;let n=await t.json();T.current&&Array.isArray(n.thread)&&b(n.thread)}catch{}},[e]);(0,W.useEffect)(()=>{T.current=!0,r(null),o(null),b([]),j(),M();let e=setInterval(()=>{document.hidden||(j(),M())},ln);return()=>{T.current=!1,clearInterval(e)}},[j,M]),(0,W.useEffect)(()=>{O&&j()},[O,j]),(0,W.useEffect)(()=>{w.current&&C.current&&(C.current.scrollTop=C.current.scrollHeight)},[n,ee]);let te=()=>{let e=C.current;e&&(w.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},N=async()=>{let t=s.trim();if(!(!t||u)){d(!0),p(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:_})});if(!n.ok)throw Error(`HTTP ${n.status}`);c(``),p(k?l.t(`activity:sessionWatch.sentRunning`):l.t(`activity:sessionWatch.sentIdle`)),M()}catch(e){p(l.t(`activity:sessionWatch.sentFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{d(!1)}}},ne=async()=>{if(!x){S(!0),p(null);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({reason:l.t(`activity:sessionWatch.interruptReason`)})});if(!t.ok)throw Error(`HTTP ${t.status}`);p(l.t(`activity:sessionWatch.interruptSent`)),M()}catch(e){p(l.t(`activity:sessionWatch.interruptFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{S(!1)}}},P=n?.entries??[];return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:H(`h-1.5 w-1.5 rounded-full`,k?`bg-success animate-pulse`:`bg-muted-foreground`)}),i(`activity:sessionWatch.liveStream`)]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[i(`activity:sessionWatch.events`,{count:n.total}),` · `,n.status]}),k&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void ne(),disabled:x,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(x?`activity:sessionWatch.interrupting`:`activity:sessionWatch.interrupt`)})]})]}),A&&(0,Y.jsxs)(`div`,{className:`mb-1.5 shrink-0 text-[10px] text-foreground truncate`,children:[`▶ `,A]}),a&&(0,Y.jsxs)(`div`,{className:`text-[11px] text-destructive mb-1 shrink-0`,children:[`· `,a]}),(0,Y.jsxs)(`div`,{ref:C,onScroll:te,className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain space-y-1.5 pr-1`,children:[P.length===0&&!a&&(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:i(`activity:sessionWatch.loading`)}),P.map((e,t)=>(0,Y.jsx)(sn,{entry:e,isContinuation:t>0&&P[t-1].role===e.role},`${e.ts}-${t}`)),ee&&(0,Y.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,Y.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,Y.jsx)(I,{className:`h-4 w-4 animate-pulse`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground px-1`,children:ee.label}),(0,Y.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-4 py-3 bg-card border border-border`,children:(0,Y.jsxs)(`span`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:[ee.text,(0,Y.jsx)(`span`,{className:`animate-pulse text-primary`,children:`▋`})]})})]})]})]}),y.length>0&&(0,Y.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0 max-h-28 overflow-y-auto space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:i(`activity:mailbox.messages`)}),y.slice(-6).map(e=>{let t=e.completed?i(`activity:sessionWatch.done`):e.readByLeader?i(`activity:sessionWatch.read`):i(`activity:sessionWatch.delivered`);return(0,Y.jsxs)(`div`,{className:`text-[10px] leading-snug`,children:[(0,Y.jsx)(`span`,{className:H(`font-semibold mr-1.5`,e.fromLeader?`text-accent`:`text-primary`),children:e.fromLeader?i(`activity:sessionWatch.agent`):i(`activity:sessionWatch.you`)}),(0,Y.jsx)(`span`,{className:`text-foreground whitespace-pre-wrap break-words`,children:e.body}),!e.fromLeader&&(0,Y.jsx)(`span`,{className:H(`ml-1.5 text-[9px]`,e.completed?`text-success`:e.readByLeader?`text-primary`:`text-muted-foreground`),children:t})]},e.id)})]}),(0,Y.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,Y.jsx)(`select`,{value:h,onChange:e=>g(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:cn.map(e=>(0,Y.jsx)(`option`,{value:e,children:i(`activity:sessionWatch.msgType.${e}Label`)},e))}),(0,Y.jsxs)(`select`,{value:_,onChange:e=>v(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,Y.jsx)(`option`,{value:`high`,children:`high`}),(0,Y.jsx)(`option`,{value:`normal`,children:`normal`}),(0,Y.jsx)(`option`,{value:`low`,children:`low`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,Y.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),N())},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,Y.jsx)(`button`,{type:`button`,onClick:()=>void N(),disabled:u||!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:u?`…`:i(`activity:sessionWatch.send`)})]}),f&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:f}),(0,Y.jsx)(`div`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:i(`activity:sessionWatch.sendHint`)})]})]})}var Z={primary:`hsl(var(--primary))`,info:`hsl(var(--info))`,success:`hsl(var(--success))`,warning:`hsl(var(--warning))`,destructive:`hsl(var(--destructive))`,muted:`hsl(var(--muted-foreground))`},dn=.12;function fn(e){return Math.min(100,Math.max(0,e??0))}function pn({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,a={idle:`bg-muted-foreground`,active:`bg-success`,streaming:`bg-primary`,completed:`bg-primary`,error:`bg-destructive`,offline:`bg-muted-foreground/60`},o={idle:Z.muted,active:Z.success,streaming:Z.primary,completed:Z.primary,error:Z.destructive,offline:Z.muted};return(0,Y.jsx)(`span`,{className:H(`rounded-full`,r,n>0&&`animate-pulse`,a[e]),style:{boxShadow:n>0?`0 0 ${i}px ${o[e]}`:void 0}})}function Q(){let e={opacity:0,width:1,height:1,minWidth:0,border:`none`,background:`transparent`};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(R,{type:`target`,position:T.Top,style:e,isConnectable:!1}),(0,Y.jsx)(R,{type:`source`,position:T.Bottom,style:e,isConnectable:!1})]})}function mn({data:e}){let{t}=m();return(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-border/60 pt-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:e.agentCount??0}),` `,t(`activity:office.agentsSuffix`)]}),e.startedAt&&(0,Y.jsx)(`span`,{children:t(`activity:office.upPrefix`,{time:mt(e.startedAt,Date.now())})})]})}function hn({data:e}){let{t}=m(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`offline`,a=e.color||Z.info;return(0,Y.jsxs)(`div`,{className:H(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-primary/15`,r&&`border-destructive/50 bg-destructive/10`,i&&`border-border/70 bg-muted/35 opacity-60`,!n&&!r&&!i&&`border-primary/30 bg-primary/10`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:H(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-primary/15`:`bg-primary/10`),children:(0,Y.jsx)(_,{className:`h-5 w-5`,style:{color:a}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:a},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.webuiClient`)})]}),(0,Y.jsx)(pn,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(le,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{children:t(`activity:office.disconnected`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L,{className:`h-3 w-3 text-success`}),(0,Y.jsx)(`span`,{children:t(`activity:office.connected`)})]})}),n&&(0,Y.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-primary/20`,children:(0,Y.jsx)(`div`,{className:`h-full animate-pulse bg-primary`,style:{width:`60%`}})}),(0,Y.jsx)(mn,{data:e})]})}function gn({data:e}){let{t}=m(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.color||Z.success;return(0,Y.jsxs)(`div`,{className:H(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-success/15`,r&&`border-destructive/50 bg-destructive/10`,!n&&!r&&`border-success/30 bg-success/10`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:H(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-success/15`:`bg-success/10`),children:(0,Y.jsx)(u,{className:`h-5 w-5`,style:{color:i}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:i},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.tuiClient`)})]}),(0,Y.jsx)(pn,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(u,{className:`h-3 w-3 text-success`}),(0,Y.jsx)(`span`,{children:t(`activity:office.terminal`)})]}),(0,Y.jsx)(mn,{data:e})]})}function _n({data:e}){let{t}=m(),n=e.status===`active`||e.status===`streaming`,r=e.color||Z.warning;return(0,Y.jsxs)(`div`,{className:H(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-warning/15`,!n&&`border-warning/30 bg-warning/10`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:H(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-warning/15`:`bg-warning/10`),children:(0,Y.jsx)(u,{className:`h-5 w-5`,style:{color:r}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:r},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.repl`)})]}),(0,Y.jsx)(pn,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-1 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsx)(mn,{data:e})]})}function vn({data:e}){let{t}=m(),n=e.status===`active`||e.status===`streaming`,r=e.color||Z.primary;return(0,Y.jsxs)(`div`,{className:`relative min-w-[200px] rounded-xl border-2 border-border/70 bg-card/90 p-4 shadow-lg backdrop-blur-sm transition-all`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 rounded-full bg-primary px-2 py-0.5 text-[11px] font-bold text-primary-foreground`,children:t(`activity:office.coordinator`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,Y.jsx)(`div`,{className:H(`flex items-center justify-center w-12 h-12 rounded-xl`,n?`bg-primary/15`:`bg-primary/10`),children:(0,Y.jsx)(k,{className:`h-6 w-6`,style:{color:r}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-bold truncate`,style:{color:r},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e.sublabel||t(`activity:office.fleetSummary`)})]}),(0,Y.jsx)(pn,{status:e.status,activity:e.vizActivity??0})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px] mb-2`,children:[(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`font-mono`,children:[(0,Y.jsx)(`span`,{className:`text-success`,children:e.agentsActive||0}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,Y.jsx)(`span`,{className:`text-primary`,children:e.agentsTotal||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:officeMap.agents`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-warning`,children:(e.toolCalls||0).toLocaleString()}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.toolCallsLabel`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-foreground`,children:ft(e.tokensIn)}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.tokensLabel`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.cost`)})]})]}),n&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-primary`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-primary`}),t(`activity:office.coordinatingFleet`)]})]})}function yn({data:e}){let{t}=m(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`completed`,a=e.color||Z.primary,o=fn(e.ctxPct);return(0,Y.jsxs)(`div`,{className:H(`w-[170px] min-w-0 max-w-[170px] overflow-hidden rounded-lg border p-3 transition-all backdrop-blur-sm`,n&&`border-primary/50 bg-primary/10 shadow-lg shadow-primary/10`,r&&`border-destructive/50 bg-destructive/10`,i&&`border-border/70 bg-muted/35`,!n&&!r&&!i&&`border-primary/30 bg-primary/10`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,Y.jsx)(I,{className:`h-4 w-4 shrink-0`,style:{color:a}}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-bold truncate`,style:{color:a},children:e.label}),e.model&&(0,Y.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:ht(e.model)})]}),(0,Y.jsx)(pn,{status:e.status,small:!0,activity:e.vizActivity??0})]}),e.currentTask&&(0,Y.jsxs)(`div`,{className:`mb-1.5 flex min-w-0 items-center gap-1 overflow-hidden text-[11px] text-primary`,children:[(0,Y.jsx)(`span`,{className:H(`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`,n&&`animate-pulse`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.currentTask,children:gt(e.currentTask,72)})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-0.5 text-[11px] mb-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`iter`}),(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:e.iteration||0})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`tools`}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:e.toolCalls||0})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`tok`}),(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:ft((e.tokensIn||0)+(e.tokensOut||0))})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`cost`}),(0,Y.jsxs)(`span`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]})]})]}),o>0&&(0,Y.jsxs)(`div`,{className:`mb-1`,children:[(0,Y.jsxs)(`div`,{className:`mb-0.5 flex justify-between text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:`ctx`}),(0,Y.jsxs)(`span`,{className:H(`font-mono`,o>=90?`text-destructive`:o>=70?`text-warning`:`text-muted-foreground`),children:[o,`%`]})]}),(0,Y.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:H(`h-full`,o>=90?`bg-destructive`:o>=70?`bg-warning`:`bg-primary`),style:{width:`${o}%`}})})]}),e.lastActivityAt&&(0,Y.jsxs)(`div`,{className:H(`flex items-center gap-1 text-[10px]`,n?`text-muted-foreground/70`:`text-muted-foreground`),children:[i&&(0,Y.jsx)(`span`,{className:`text-success`,children:t(`activity:office.donePrefix`)}),r&&(0,Y.jsx)(`span`,{className:`text-destructive`,children:t(`activity:office.failedPrefix`)}),(0,Y.jsx)(`span`,{children:t(`activity:office.seenPrefix`,{time:pt(e.lastActivityAt,Date.now())})})]})]})}function bn({data:e}){let{t}=m();return(0,Y.jsxs)(`div`,{className:H(`rounded-lg border border-dashed p-3 min-w-[120px] transition-all opacity-40`,`border-border/70 bg-muted/30`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(g,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:e.label})}),(0,Y.jsx)(pn,{status:e.status,small:!0,activity:e.vizActivity??0})]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:office.availableDesk`)})]})}function xn({data:e}){let{t}=m(),n=e.color||Z.warning,r=(e.unreadCount||0)>0;return(0,Y.jsxs)(`div`,{className:H(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,r&&`border-warning/50 bg-warning/10 shadow-lg shadow-warning/10`,!r&&`border-warning/30 bg-warning/6`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:H(`flex items-center justify-center w-10 h-10 rounded-lg`,r?`bg-warning/18`:`bg-warning/10`),children:(0,Y.jsx)(h,{className:`h-5 w-5`,style:{color:n}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold`,style:{color:n},children:t(`activity:office.mailboxHub`)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r?t(`activity:office.unreadSuffix`,{count:e.unreadCount||0}):t(`activity:office.allClear`)})]}),r&&(0,Y.jsx)(`div`,{className:`flex h-5 w-5 items-center justify-center rounded-full bg-warning text-[10px] font-bold text-background`,children:e.unreadCount})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-warning`,children:[(0,Y.jsx)(F,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e.messageCount||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.total`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-success`,children:[(0,Y.jsx)(_e,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e.unreadCount||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.unreadLabel`)})]})]}),e.sublabel&&(0,Y.jsxs)(`div`,{className:`mt-2 truncate border-t border-border/60 pt-1.5 text-[11px] text-muted-foreground`,children:[`✉ `,e.sublabel]})]})}var Sn={webui:hn,tui:gn,repl:_n,coordinator:vn,agent:yn,mailbox:xn,desk:bn};function Cn({broadcastOpen:e,labels:t,onArrange:n,onBroadcastToggle:r,onFeedToggle:i,showFeed:a}){return(0,Y.jsxs)(oe,{position:`top-right`,className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:n,title:t.arrangeTitle,className:`flex items-center gap-1.5 rounded-md border border-border/70 bg-card/90 px-2.5 py-1.5 text-xs text-foreground shadow-sm transition-colors hover:bg-accent`,children:[(0,Y.jsx)(ne,{className:`h-3.5 w-3.5`}),t.arrange]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:i,title:t.feedTitle,className:H(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,a?`border-primary/35 bg-primary/10 text-primary`:`border-border/70 bg-card/90 text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,Y.jsx)(z,{className:`h-3.5 w-3.5`}),t.feed]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:r,title:t.broadcastTitle,className:H(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,e?`border-warning/35 bg-warning/10 text-warning`:`border-border/70 bg-card/90 text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,Y.jsx)(F,{className:`h-3.5 w-3.5`}),t.broadcast]})]})}function wn(){return(0,Y.jsx)(A,{className:`rounded-lg border border-border/70 bg-card/90`,nodeColor:e=>{switch(e.data.kind){case`coordinator`:return Z.primary;case`webui`:return Z.info;case`tui`:return Z.success;case`repl`:case`mailbox`:return Z.warning;default:return Z.primary}},maskColor:`hsl(var(--background) / 0.72)`})}function Tn({closeTitle:e,label:t,onClose:n,sessionId:r,streamTitle:i}){return(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5 shrink-0 bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(I,{className:`h-4 w-4 text-primary shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:t}),(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:i})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,title:e,className:`text-muted-foreground hover:text-foreground text-xl leading-none shrink-0`,children:`×`})]}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 p-4`,children:(0,Y.jsx)(un,{sessionId:r,limit:500})})]})}var En={wire:({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i,targetPosition:a,data:o,selected:s})=>{let c=o?.color||Z.primary,l=U(e=>e.animateEdges),u=o?.animated&&l?Math.max(.15,o?.intensity??.6):0,[d,f,p]=ge({sourceX:e,sourceY:t,sourcePosition:i??T.Bottom,targetX:n,targetY:r,targetPosition:a??T.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.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,Y.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:g,to:`0`,dur:_,repeatCount:`indefinite`})}),o?.label&&u>.1&&(0,Y.jsx)(de,{children:(0,Y.jsx)(`div`,{style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${f}px, ${p}px)`},className:`pointer-events-none max-w-[220px] truncate whitespace-nowrap rounded-full border border-border/70 bg-card/90 px-1.5 py-0.5 text-[8px] font-medium text-foreground backdrop-blur-sm`,children:o.label})})]})}};function Dn(){let{t:e}=m(),{clientCounts:t,currentSession:n,totalAgents:r,activeAgents:i,aggregate:a}=we(ie(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents,aggregate:e.aggregate}))),s=t.tui+t.webui+t.repl,c=e=>e?.toLocaleString()??`0`;return(0,Y.jsxs)(`div`,{className:`absolute left-4 top-20 z-10 rounded-xl border border-border/70 bg-card/90 p-3 text-foreground shadow-xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(d,{className:`h-3.5 w-3.5 text-success`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-bold uppercase text-muted-foreground`,children:e(`activity:office.sessionStats`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5 text-[10px]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(ye,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.clients`)})]}),(0,Y.jsxs)(`span`,{className:`font-mono text-foreground`,children:[i,` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,Y.jsx)(`span`,{className:`text-success`,children:s})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 pl-4 text-[9px]`,children:[t.tui>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(u,{className:`h-2.5 w-2.5 text-success`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:hud.tui`)}),(0,Y.jsx)(`span`,{className:`font-mono text-success`,children:t.tui})]}),t.webui>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(_,{className:`h-2.5 w-2.5 text-primary`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:hud.webui`)}),(0,Y.jsx)(`span`,{className:`font-mono text-primary`,children:t.webui})]}),t.repl>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(u,{className:`h-2.5 w-2.5 text-warning`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:hud.repl`)}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:t.repl})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(I,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.agents`)})]}),(0,Y.jsxs)(`span`,{className:`font-mono text-foreground`,children:[i,` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,Y.jsx)(`span`,{className:`text-primary`,children:r})]})]}),n.model&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(k,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.model`)})]}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate font-mono text-primary`,title:n.model,children:n.model.split(`/`).pop()?.slice(0,16)})]}),n.mode&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(he,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.mode`)})]}),(0,Y.jsx)(`span`,{className:H(`font-mono uppercase text-[9px] px-1.5 py-0.5 rounded`,n.mode===`auto`&&`bg-primary/10 text-primary`,n.mode===`suggest`&&`bg-success/10 text-success`,n.mode===`off`&&`bg-muted text-muted-foreground`,![`auto`,`suggest`,`off`].includes(n.mode||``)&&`bg-muted text-muted-foreground`),children:n.mode})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(o,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.toolCallsLabel`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:c(a.toolCalls)})]}),(0,Y.jsxs)(`div`,{className:`mt-1.5 space-y-1 border-t border-border/70 pt-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`IN`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.input`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:c(a.tokensIn)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:e(`activity:hud.out`)}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.output`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:c(a.tokensOut)})]})]}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-4 border-t border-border/70 pt-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(E,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.cost`)})]}),(0,Y.jsx)(`span`,{className:`font-mono font-medium text-success`,children:(e=>e==null?`$0.0000`:`$${e.toFixed(4)}`)(a.costUsd)})]})]})]})}function On({events:e,now:t}){let{t:n}=m(),r=e.slice(0,14);return(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pointer-events-none px-3 pb-3`,children:(0,Y.jsxs)(`div`,{className:`pointer-events-auto mx-auto max-w-3xl rounded-lg border border-border/70 bg-card/90 px-3 py-2 shadow-xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] uppercase text-primary`,children:[(0,Y.jsx)(d,{className:`h-3 w-3`}),n(`activity:office.liveActivity`)]}),r.length===0?(0,Y.jsx)(`div`,{className:`text-[11px] italic text-muted-foreground`,children:n(`activity:office.waitingActivity`)}):(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] leading-tight`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{backgroundColor:Ot(e.kind)}}),(0,Y.jsx)(`span`,{className:`flex-1 truncate text-foreground`,children:e.label}),(0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:r<1?n(`activity:office.now`):`${r}s`})]},e.id)})})]})})}function kn(){let{t:e}=m();return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-10 rounded-lg border border-border/70 bg-card/90 p-3 text-[10px] shadow-xl backdrop-blur`,children:[(0,Y.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendStatus`)}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-success`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendActive`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendIdle`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-destructive`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendError`)})]})]})]}),(0,Y.jsxs)(`div`,{className:`absolute bottom-4 right-4 z-10 rounded-lg border border-border/70 bg-card/90 p-3 text-[10px] shadow-xl backdrop-blur`,children:[(0,Y.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendConnections`)}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-warning`,children:`✉`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendMail`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-primary`,children:`→`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendTask`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-success`,children:`●`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendStatusConn`)})]})]})]})]})}function An({draft:e,isSending:t,result:n,onClose:r,onDraftChange:i,onSend:a}){let{t:o}=m();return(0,Y.jsxs)(`div`,{className:`absolute right-4 top-16 z-30 w-80 rounded-xl border border-warning/35 bg-card/95 p-3 shadow-2xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold text-warning`,children:[(0,Y.jsx)(F,{className:`h-3.5 w-3.5`}),` `,o(`activity:office.broadcastToAll`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`text-base leading-none text-muted-foreground hover:text-foreground`,children:`×`})]}),(0,Y.jsx)(`textarea`,{value:e,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),a())},rows:3,placeholder:o(`activity:office.broadcastPlaceholder`),className:`w-full resize-none rounded-md border border-border/70 bg-background/70 px-2 py-1 text-[11px] text-foreground placeholder:text-muted-foreground focus:border-warning/45 focus:outline-none`}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:o(`activity:office.broadcastSendHint`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:a,disabled:t||!e.trim(),className:`rounded-md border border-warning/35 bg-warning/12 px-2.5 py-1 text-[11px] text-warning transition-colors hover:bg-warning/18 disabled:cursor-not-allowed disabled:opacity-40`,children:t?`…`:o(`activity:office.broadcast`)})]}),n&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:n})]})}function $({k:e,v:t,accent:n}){return(0,Y.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,Y.jsx)(`span`,{className:H(`font-mono truncate text-right`,n??`text-foreground/80`),children:t})]})}function jn({selectedNode:e,selectedAgentTranscript:t,mailboxMessages:n,onClose:r,onOpenWatch:i}){let{t:a}=m(),o=e.data,s=Date.now(),c=o.kind===`agent`,l=o.kind===`webui`||o.kind===`tui`||o.kind===`repl`,d=(o.tokensIn||0)+(o.tokensOut||0),f=fn(o.ctxPct);return(0,Y.jsxs)(`div`,{className:H(`absolute top-20 right-4 bg-background border border-border rounded-lg p-4 shadow-xl z-20`,o.kind===`agent`?`w-[28rem] max-w-[calc(100%-2rem)]`:o.sessionId?`w-80`:`w-64`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o.kind===`webui`&&(0,Y.jsx)(_,{className:`h-4 w-4 text-info`}),o.kind===`tui`&&(0,Y.jsx)(u,{className:`h-4 w-4 text-success`}),o.kind===`coordinator`&&(0,Y.jsx)(k,{className:`h-4 w-4 text-primary`}),o.kind===`agent`&&(0,Y.jsx)(I,{className:`h-4 w-4 text-primary`}),o.kind===`mailbox`&&(0,Y.jsx)(h,{className:`h-4 w-4 text-warning`}),(0,Y.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:o.label})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[o.sessionId&&(0,Y.jsx)(`button`,{type:`button`,title:a(`activity:office.openFullView`),onClick:()=>i({sessionId:o.sessionId,label:o.label}),className:`text-muted-foreground hover:text-primary`,children:(0,Y.jsx)(w,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,Y.jsx)($,{k:`Status`,v:String(o.status).toUpperCase(),accent:H(o.status===`active`&&`text-success`,o.status===`streaming`&&`text-primary`,o.status===`error`&&`text-destructive`,o.status===`idle`&&`text-muted-foreground`,o.status===`offline`&&`text-muted-foreground/70`)}),c&&(0,Y.jsxs)(Y.Fragment,{children:[o.model&&(0,Y.jsx)($,{k:`Model`,v:ht(o.model),accent:`text-primary`}),o.currentTask&&(0,Y.jsxs)(`div`,{className:`pt-1`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:a(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`div`,{className:`mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap break-words font-mono text-[10px] text-primary`,children:o.currentTask})]}),(0,Y.jsx)($,{k:`Iterations`,v:o.iteration||0,accent:`text-primary`}),(0,Y.jsx)($,{k:`Tool calls`,v:o.toolCalls||0,accent:`text-warning`}),(0,Y.jsx)($,{k:`Tokens in`,v:ft(o.tokensIn)}),(0,Y.jsx)($,{k:`Tokens out`,v:ft(o.tokensOut)}),(0,Y.jsx)($,{k:`Tokens total`,v:ft(d)}),f>0&&(0,Y.jsx)($,{k:`Context`,v:`${f}%`,accent:f>=90?`text-destructive`:f>=70?`text-warning`:`text-foreground/70`}),(0,Y.jsx)($,{k:`Cost`,v:`$${(o.costUsd||0).toFixed(4)}`,accent:`text-success`}),o.lastActivityAt&&(0,Y.jsx)($,{k:`Last seen`,v:pt(o.lastActivityAt,s),accent:`text-muted-foreground`}),(0,Y.jsx)(`div`,{className:`pt-2`,children:(0,Y.jsx)(Oe,{entries:t,agentName:o.label,compact:!0,maxHeightClassName:`max-h-64`})})]}),l&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{k:`Surface`,v:bt(o.kind),accent:`text-foreground/80`}),o.branch&&(0,Y.jsx)($,{k:`Branch`,v:`⎇ ${o.branch}`,accent:`text-foreground/70`}),o.pid!=null&&(0,Y.jsx)($,{k:`PID`,v:o.pid}),o.workingDir&&(0,Y.jsx)($,{k:`Dir`,v:o.workingDir,accent:`text-muted-foreground`}),(0,Y.jsx)($,{k:`Agents`,v:o.agentCount??0,accent:`text-primary`}),o.startedAt&&(0,Y.jsx)($,{k:`Uptime`,v:mt(o.startedAt,s),accent:`text-foreground/70`})]}),o.kind===`mailbox`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{k:`Total messages`,v:o.messageCount||0,accent:`text-warning`}),(0,Y.jsx)($,{k:`Unread`,v:o.unreadCount||0,accent:`text-warning`}),n.length>0&&(0,Y.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-border pt-2`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:a(`activity:office.recent`)}),[...n].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp)).slice(0,6).map(e=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px]`,children:[(0,Y.jsx)(`span`,{className:H(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,!e.completed&&(e.readByCount??0)===0?`bg-warning`:e.completed?`bg-success`:`bg-muted`)}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate text-foreground/80`,children:e.subject||a(`activity:office.noSubject`)}),(0,Y.jsxs)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[e.from,` → `,e.to,` · `,pt(e.timestamp,s),e.audience===`leaders`?` · ${a(`activity:mailbox.audienceLeaders`)}`:``]})]})]},e.id))]})]}),o.kind===`coordinator`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{k:`Connections`,v:o.connections||0,accent:`text-primary`}),(0,Y.jsx)($,{k:`Iterations`,v:o.iteration||0,accent:`text-primary`})]}),(c||l)&&o.sessionId&&(0,Y.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 h-72`,children:(0,Y.jsx)(un,{sessionId:o.sessionId})})]})]})}function Mn(){let{t:e}=m(),{fitView:t}=te(),n=(0,W.useRef)(null),[r,i]=(0,W.useState)({width:1280,height:720});(0,W.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let{width:t,height:n}=e.getBoundingClientRect();t<1||n<1||i(e=>Math.abs(e.width-t)<2&&Math.abs(e.height-n)<2?e:{width:t,height:n})};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]);let a=xe(e=>e.events),o=Ce(e=>e.agents),s=Ce(e=>e.agentTranscripts),c=Ce(e=>e.leaderId),l=we(e=>e.liveSessions),u=Ee(e=>e.messages),d=Ee(e=>e.agents),f=Se(e=>e.session),p=At(o),h=(0,W.useMemo)(()=>Dt(l,o,d,p.map,p.now),[l,o,d,p]),g=U(e=>e.showHud),_=U(e=>e.showLegend),v=U(e=>e.showMinimap),y=U(e=>e.showControls),b=U(e=>e.showFeed),x=U(e=>e.setShowFeed),S=U(e=>e.background),[C,w,T]=ce([]),[E,O,k]=pe([]),[A,j]=(0,W.useState)(null),[N,ne]=(0,W.useState)(null),[F,ie]=(0,W.useState)(!1),[ae,oe]=(0,W.useState)(``),[I,se]=(0,W.useState)(!1),[le,ue]=(0,W.useState)(null),de=(0,W.useMemo)(()=>{if(A?.data.kind!==`agent`)return Te;let e=A.data.serverId??(A.id.includes(`__agent-`)?A.id.split(`__agent-`).pop():A.id.replace(/^agent-/,``));return e?s.get(e)??Te:Te},[s,A]),fe=(0,W.useCallback)(async()=>{let e=ae.trim();if(!(!e||I)){se(!0),ue(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();oe(``),ue(`Delivered to ${n.delivered??0}/${n.targets??0} session(s)`)}catch(e){ue(`Failed: ${e instanceof Error?e.message:String(e)}`)}finally{se(!1)}}},[ae,I]),L=(0,W.useRef)(new Map),R=4e3,z=(0,W.useRef)(new Map),B=(0,W.useRef)(new Map),he=(0,W.useRef)(new Map),ge=(0,W.useRef)(new Map),_e=(0,W.useRef)(``);(0,W.useEffect)(()=>{let n=[],i=[],a=Date.now(),s=_t(h.map(e=>({id:e.id,agentCount:e.agents.length})),r),l=u.filter(e=>!e.completed&&(e.readByCount??0)===0).length,d=u.length?[...u].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:l>0?`active`:`idle`,unreadCount:l,messageCount:u.length,sublabel:d?`${d.from} → ${d.to}: ${d.subject}`:void 0,color:Z.warning}});let f=0,p=0,m=0,g=0,_=0;for(let e of h)for(let t of e.agents)p+=1,(t.status===`active`||t.status===`streaming`)&&(f+=1),m+=t.toolCalls,g+=t.costUsd,_+=t.tokensIn+t.tokensOut;let v=c?o.get(c):null,y=f>0;n.push({id:`coordinator`,type:`coordinator`,position:{x:370,y:50},data:{label:e(`activity:office.fleetHqLabel`),sublabel:e(`activity:office.clientsSuffix`,{count:h.length}),kind:`coordinator`,status:v?.status===`failed`?`error`:y?`active`:`idle`,connections:h.length,agentsActive:f,agentsTotal:p,toolCalls:m,costUsd:g,tokensIn:_,color:Z.primary}});let b={tui:Z.success,webui:Z.info,repl:Z.warning};for(let t of h){let r=s.positions.get(t.id)??{x:600,y:370},o=r.x,c=r.y,u=b[t.type],d=t.status===`active`;if(n.push({id:t.id,type:t.type,position:{x:o,y:c},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:u}}),i.push({id:`${t.id}->coordinator`,source:t.id,target:`coordinator`,type:`wire`,animated:d,data:{color:u,animated:d,label:e(`activity:office.controlLabel`),flowType:`task`}}),i.push({id:`mailbox->${t.id}`,source:`mailbox`,target:t.id,type:`wire`,animated:l>0,data:{color:Z.warning,animated:l>0,label:l>0?`${l}`:void 0,flowType:`mail`}}),t.agents.length===0){n.push({id:`desk-${t.id}`,type:`desk`,position:{x:o,y:c+270},data:{label:e(`activity:office.idleDesk`),kind:`agent`,status:`idle`,color:Z.muted}});continue}t.agents.forEach((r,s)=>{let l=r.status===`active`||r.status===`streaming`,u=ge.current.get(r.serverId);if(u&&(r.toolCalls>u.toolCalls||r.iteration>u.iteration)||l){L.current.set(r.officeId,a+R);let e=B.current.get(r.officeId)??0;B.current.set(r.officeId,Math.min(1,e+(1-e)*.5));for(let e of[`${t.id}->${r.officeId}`,`${t.id}->coordinator`]){let t=z.current.get(e)??0;z.current.set(e,Math.min(1,t+.5))}}ge.current.set(r.serverId,{toolCalls:r.toolCalls,iteration:r.iteration}),n.push({id:r.officeId,type:`agent`,position:vt(o,s,t.agents.length,c+270),data:{label:r.name,kind:`agent`,status:r.status,serverId:r.serverId,sessionId:t.sessionId,currentTask:r.currentTask,iteration:r.iteration,toolCalls:r.toolCalls,costUsd:r.costUsd,tokensIn:r.tokensIn,tokensOut:r.tokensOut,ctxPct:r.ctxPct,model:r.model,lastActivityAt:r.lastActivityAt,color:Z.primary}}),i.push({id:`${t.id}->${r.officeId}`,source:t.id,target:r.officeId,type:`wire`,animated:l,data:{color:Z.primary,animated:l,label:l?gt(r.currentTask,48)??e(`activity:office.taskFallback`):void 0,flowType:`task`}})})}let x=new Set(h.flatMap(e=>e.agents.map(e=>e.serverId)));for(let e of[...ge.current.keys()])x.has(e)||ge.current.delete(e);for(let[e,t]of[...L.current])t<=a&&L.current.delete(e);let S=n.map(e=>{let t=L.current.get(e.id),n=B.current.get(e.id)??0;return t&&t>a&&e.data.status!==`error`&&e.data.status!==`offline`?{...e,data:{...e.data,status:`active`,vizActivity:n}}:{...e,data:{...e.data,vizActivity:n}}}),C=i.map(e=>{let t=z.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 S)T.set(e.id,{...e.position});he.current=T,w(S),O(C);let E=[`${Math.round(r.width)}x${Math.round(r.height)}`,`${s.columns}x${s.rows}`,h.map(e=>`${e.id}:${e.agents.length}`).join(`|`),S.map(e=>e.id).sort().join(`|`)].join(`:`);if(E!==_e.current){_e.current=E;let e=setTimeout(()=>t({padding:dn,duration:300}),50);return()=>clearTimeout(e)}},[h,c,o,u,f,r,R,w,O,t]);let ve=h.flatMap(e=>e.agents.map(t=>({clientId:e.id,clientType:e.type,officeId:t.officeId,serverId:t.serverId}))),ye=h.map(e=>e.id),be=new Map;for(let e of ve)(!be.has(e.serverId)||e.clientType===`webui`)&&be.set(e.serverId,e.officeId);function V(e){return be.get(e)??`agent-${e}`}function H(e){let t=e.split(`__agent-`)[0];return t&&t!==e?`${t}->${e}`:`coordinator->${e}`}function De(e){switch(e.kind){case`mailbox:send`:case`mailbox:deliver`:return{nodes:[`mailbox`],edges:e.kind===`mailbox:send`?ye.map(e=>`mailbox->${e}`):[],status:`active`};case`agent:spawned`:{let t=V(e.source);return{nodes:[`coordinator`,t],edges:[H(t)],status:`active`}}case`agent:tool`:case`tool:started`:case`tool:progress`:{let t=V(e.source);return{nodes:[`coordinator`,t],edges:[H(t)],status:e.kind===`tool:progress`||e.kind===`tool:started`?`streaming`:`active`}}case`tool:executed`:{let t=V(e.target??e.source);return{nodes:[t],edges:[H(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:ve.map(e=>H(e.officeId)),status:e.kind===`iteration:start`?`streaming`:`active`};case`agent:text`:{let t=V(e.source);return{nodes:[t],edges:[H(t)],status:`streaming`}}case`agent:status`:{let t=V(e.source);return{nodes:[`coordinator`,t],edges:[H(t)],status:e.data&&typeof e.data==`object`&&`status`in e.data&&String(e.data.status)===`failed`?`error`:`completed`}}case`agent:ctx`:return{nodes:[V(e.source)],edges:[],status:`active`};case`budget:extended`:return{nodes:[`coordinator`,V(e.source)],edges:[],status:`active`};case`context:compacted`:case`context:repaired`:return{nodes:[`coordinator`],edges:[],status:`active`};case`error`:return{nodes:e.source?[V(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=V(t.id);n.includes(e)||n.push(e)}return{nodes:n,edges:[],status:`active`}}default:return{nodes:[],edges:[],status:`idle`}}}(0,W.useEffect)(()=>{if(a.length===0)return;let e=a[0];if(!e)return;let{nodes:t,edges:n,status:r}=De(e),i=Date.now();t.length>0&&(t.forEach(e=>{L.current.set(e,i+R);let t=B.current.get(e)??0;B.current.set(e,Math.min(1,t+(1-t)*.5))}),w(e=>e.map(e=>t.includes(e.id)?{...e,data:{...e.data,status:r,vizActivity:B.current.get(e.id)??0}}:e))),n.length>0&&(n.forEach(e=>{let t=z.current.get(e)??0;z.current.set(e,Math.min(1,t+.5))}),O(e=>e.map(e=>n.includes(e.id)?{...e,animated:!0,data:{...e.data,animated:!0,intensity:z.current.get(e.id)??1}}:e)))},[a,w,O,R,o]),(0,W.useEffect)(()=>{let e=setInterval(()=>{let e=new Map,t=!1;for(let[n,r]of z.current){let i=r*.85;i<.05?(z.current.delete(n),e.set(n,{intensity:0,animated:!1}),t=!0):(z.current.set(n,i),e.set(n,{intensity:i,animated:!0}),t=!0)}t&&O(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 B.current){let i=t*.9;i<.03?(B.current.delete(e),n.set(e,0),r=!0):(B.current.set(e,i),n.set(e,i),r=!0)}r&&w(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)},[O,w]);let Oe=(0,W.useCallback)(e=>O(t=>ee({...e,type:`wire`},t)),[O]),ke=(0,W.useCallback)((e,t)=>{j(t)},[]),Ae=(0,W.useCallback)(()=>{j(null)},[]);(0,W.useEffect)(()=>{if(!N)return;let e=e=>{e.key===`Escape`&&ne(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N]);let je=(0,W.useCallback)(()=>{w(e=>e.map(e=>{let t=he.current.get(e.id);return t?{...e,position:{...t}}:e})),setTimeout(()=>t({padding:dn,duration:300}),50)},[w,t]),[,Me]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let e=setInterval(()=>{document.hidden||Me(e=>e+1)},2e3);return()=>clearInterval(e)},[]),(0,Y.jsxs)(`div`,{ref:n,className:`relative h-full w-full overflow-hidden bg-[hsl(var(--surface-2)/0.55)]`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`
|
|
2
|
-
linear-gradient(hsl(var(--foreground) / 0.1) 1px, transparent 1px),
|
|
3
|
-
linear-gradient(90deg, hsl(var(--foreground) / 0.1) 1px, transparent 1px)
|
|
4
|
-
`,backgroundSize:`40px 40px`}}),g&&(0,Y.jsx)(Dn,{}),(0,Y.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-10`,children:(0,Y.jsx)(`div`,{className:`rounded-lg border border-border/70 bg-card/90 px-4 py-2 shadow-xl backdrop-blur`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold text-foreground`,children:[(0,Y.jsx)(re,{className:`h-4 w-4 text-primary`}),e(`activity:office.fleetHq`),(0,Y.jsx)(`span`,{className:`ml-2 h-2 w-2 animate-pulse rounded-full bg-success`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:e(`activity:office.live`)})]})})}),_&&(0,Y.jsx)(kn,{}),(0,Y.jsxs)(M,{nodes:C,edges:E,onNodesChange:T,onEdgesChange:k,onConnect:Oe,onNodeClick:ke,onPaneClick:Ae,nodeTypes:Sn,edgeTypes:En,fitView:!0,fitViewOptions:{padding:dn},minZoom:.15,maxZoom:1.5,defaultEdgeOptions:{type:`wire`},proOptions:{hideAttribution:!0},children:[(0,Y.jsx)(Cn,{broadcastOpen:F,labels:{arrange:e(`activity:office.arrange`),arrangeTitle:e(`activity:office.arrangeTitle`),broadcast:e(`activity:office.broadcast`),broadcastTitle:e(`activity:office.broadcastTitle`),feed:e(`activity:office.feed`),feedTitle:e(`activity:office.feedTitle`)},onArrange:je,onBroadcastToggle:()=>ie(e=>!e),onFeedToggle:()=>x(!b),showFeed:b}),S!==`none`&&(0,Y.jsx)(me,{variant:S===`lines`?P.Lines:S===`cross`?P.Cross:P.Dots,gap:20,size:1,color:`hsl(var(--border) / 0.35)`}),y&&(0,Y.jsx)(D,{className:`rounded-lg border border-border/70 bg-card/90 [&>button]:bg-card [&>button]:text-foreground`}),v&&(0,Y.jsx)(wn,{})]}),b&&(0,Y.jsx)(On,{events:a,now:Date.now()}),F&&(0,Y.jsx)(An,{draft:ae,isSending:I,result:le,onClose:()=>ie(!1),onDraftChange:oe,onSend:()=>void fe()}),A&&(0,Y.jsx)(jn,{selectedNode:A,selectedAgentTranscript:de,mailboxMessages:u,onClose:Ae,onOpenWatch:ne}),N&&(0,Y.jsx)(Tn,{closeTitle:e(`activity:office.closeEsc`),label:N.label,onClose:()=>ne(null),sessionId:N.sessionId,streamTitle:e(`activity:office.fullOperationStream`)})]})}function Nn(){let{t:e}=m(),t=U(e=>e.viewMode),n=U(e=>e.setViewMode),r=[{id:`office`,label:e(`activity:agentOffice.office`),description:e(`activity:agentOffice.officeDescription`),icon:i},{id:`topology`,label:e(`activity:agentOffice.topology`),description:e(`activity:agentOffice.topologyDescription`),icon:V}],a=(e,t)=>{let i;if(e.key===`ArrowLeft`&&(i=(t-1+r.length)%r.length),e.key===`ArrowRight`&&(i=(t+1)%r.length),e.key===`Home`&&(i=0),e.key===`End`&&(i=r.length-1),i===void 0)return;e.preventDefault();let a=r[i];a&&(n(a.id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[i]?.focus())};return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col bg-background`,children:[(0,Y.jsx)(`nav`,{"aria-label":`${e(`activity:agentOffice.office`)} / ${e(`activity:agentOffice.topology`)}`,className:`relative z-[60] shrink-0 border-b border-border bg-card/95 px-3 pt-2 shadow-[0_8px_28px_hsl(var(--shadow-color)/0.1)] backdrop-blur-xl sm:px-5`,children:(0,Y.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,className:`mx-auto grid w-full max-w-3xl grid-cols-2 gap-1`,children:r.map((e,r)=>{let i=e.icon,o=t===e.id;return(0,Y.jsxs)(`button`,{id:`office-map-tab-${e.id}`,type:`button`,role:`tab`,"aria-selected":o,"aria-controls":`office-map-view-panel`,tabIndex:o?0:-1,onClick:()=>n(e.id),onKeyDown:e=>a(e,r),className:H(`group relative flex min-w-0 items-center gap-2.5 border-b-2 px-3 py-2.5 text-left transition-all duration-200 sm:gap-3 sm:px-5`,o?`border-primary bg-primary/[0.07] text-foreground`:`border-transparent text-muted-foreground hover:border-border hover:bg-accent/60 hover:text-foreground`),children:[(0,Y.jsx)(`span`,{className:H(`grid h-8 w-8 shrink-0 place-items-center rounded-lg border transition-colors`,o?`border-primary/35 bg-primary/15 text-primary`:`border-border bg-background/70 text-muted-foreground group-hover:text-foreground`),children:(0,Y.jsx)(i,{className:`h-4 w-4`,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`strong`,{className:`block truncate font-display text-xs font-semibold sm:text-sm`,children:e.label}),(0,Y.jsx)(`small`,{className:`hidden truncate font-mono text-[9px] font-normal text-muted-foreground sm:block`,children:e.description})]}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:H(`ml-auto h-1.5 w-1.5 shrink-0 rounded-full transition-all`,o?`bg-primary shadow-[0_0_0_4px_hsl(var(--primary)/0.12)]`:`bg-border`)})]},e.id)})})}),(0,Y.jsx)(`div`,{id:`office-map-view-panel`,role:`tabpanel`,"aria-labelledby":`office-map-tab-${t}`,className:`relative min-h-0 flex-1`,children:t===`office`?(0,Y.jsx)(nn,{}):(0,Y.jsx)(B,{children:(0,Y.jsx)(Mn,{})})})]})}export{Nn as OfficeMapPanel};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MemoryManager-D1kXeVE3.js","assets/rolldown-runtime-QTnfLwEv.js","assets/vendor-BuarzSSb.js","assets/monaco-BLUV5g0U.js","assets/monaco-Bowa0-zp.css","assets/markdown-sSmz-Ua_.js","assets/vendor-BMdWcCR4.css","assets/i18n-9T7iGYgW.js","assets/activity-BwEBEQ51.js","assets/chat-CdiY7G6Z.js","assets/commandPalette-DpaemFux.js","assets/common-COVxQ0FV.js","assets/settings-zIY9-ivF.js","assets/setup-BFcmn89w.js","assets/toasts-BL_8kH4B.js","assets/useWebSocket-CZSpbA3M.js","assets/chat-store-DbxFVDwi.js","assets/utils-B-9lSDIn.js","assets/ws-client-TTMa0XaT.js","assets/session-store-Df7_hhe9.js","assets/codemap-activity-store-DQfjo7-j.js","assets/stores-vuG0AaKy.js","assets/mailbox-store-C1mzoSqJ.js","assets/ui-store-CE4-TlwB.js","assets/view-navigation-DIDEcp4V.js","assets/codemap-index-store-COStDU-8.js","assets/Toaster-BgN2bRJx.js","assets/dialog-ftgTihmF.js","assets/button-Dcy288Mc.js","assets/input-fo9-BPBC.js","assets/index-FHt-sKVF.js","assets/ConfirmModal-CdKg3EOQ.js","assets/ModelPicker-IOZSUnqM.js","assets/index-Cw20Xg0d.css","assets/roster-ws-Da57e_sI.js","assets/shared-KAzksK0C.js","assets/MemoryDrawer-Dsy0AX6f.js","assets/AudienceMemoryPanel-Bciki41o.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Pa as t,bt as n,lr as r,lt as i,za as a}from"./vendor-BuarzSSb.js";import"./i18n-9T7iGYgW.js";import{s as o}from"./monaco-BLUV5g0U.js";import{t as s}from"./utils-B-9lSDIn.js";import{C as c,E as l,T as u,w as d}from"./index-FHt-sKVF.js";var f=e(a(),1),p=i(),m=(0,f.lazy)(()=>o(()=>import(`./MemoryManager-D1kXeVE3.js`).then(e=>({default:e.MemoryManager})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]))),h=(0,f.lazy)(()=>o(()=>import(`./AudienceMemoryPanel-Bciki41o.js`).then(e=>({default:e.AudienceMemoryPanel})),__vite__mapDeps([37,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35])));function g({label:e}){return(0,p.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background text-xs text-muted-foreground`,"aria-busy":`true`,children:(0,p.jsxs)(`span`,{className:`font-mono uppercase tracking-wide`,children:[e,`…`]})})}var _=[{value:`all`,label:`activity:memoryManager.tabAllMemories`,hint:`activity:memoryManager.tabAllMemoriesHint`,Icon:r},{value:`audience`,label:`activity:memoryManager.tabAudience`,hint:`activity:memoryManager.tabAudienceHint`,Icon:n}];function v({defaultValue:e=`all`}={}){let{t:n}=t();return(0,p.jsxs)(c,{defaultValue:e,className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:[(0,p.jsx)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-border/70 bg-card/55 px-4 py-2 sm:px-5`,role:`presentation`,children:(0,p.jsx)(u,{"aria-label":n(`activity:memoryManager.lensesAria`),className:`h-9 bg-muted/40 p-1 shadow-none`,children:_.map(({value:e,label:t,hint:r,Icon:i})=>(0,p.jsxs)(l,{value:e,className:s(`h-7 gap-2 px-3 text-[11px] font-semibold uppercase tracking-wide`,`data-[state=active]:bg-background data-[state=active]:text-foreground`,`data-[state=active]:shadow-[0_0_0_1px_hsl(var(--border)/0.7)]`),children:[(0,p.jsx)(i,{className:`size-3.5`}),(0,p.jsx)(`span`,{children:n(t)}),(0,p.jsx)(`span`,{className:`hidden font-mono text-[9px] font-normal normal-case text-muted-foreground sm:inline`,children:n(r)})]},e))})}),(0,p.jsx)(d,{value:`all`,className:`mt-0 flex-1 overflow-hidden ring-offset-0 focus-visible:ring-0`,children:(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(g,{label:n(`activity:memoryManager.loadingSage`)}),children:(0,p.jsx)(m,{})})}),(0,p.jsx)(d,{value:`audience`,className:`mt-0 flex-1 overflow-hidden ring-offset-0 focus-visible:ring-0`,children:(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(g,{label:n(`activity:memoryManager.loadingAudience`)}),children:(0,p.jsx)(h,{})})})]})}export{v as SageTabs};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,Ai as n,Bt as r,Ct as i,Et as a,Gn as o,Gt as s,Ii as c,La as l,Nr as u,Nt as d,Oa as f,Ot as p,Pa as m,Pt as h,Qi as g,Ut as _,Wi as v,Wt as y,Xi as b,Xr as ee,Zn as x,bi as te,dt as S,hn as C,in as w,ir as T,jt as E,kn as D,la as O,lt as k,mn as A,pi as ne,ut as re,wn as j,xa as M,xt as N,za as P,zn as F}from"./vendor-BuarzSSb.js";import"./i18n-9T7iGYgW.js";import{t as I}from"./useWebSocket-CZSpbA3M.js";import{t as L}from"./utils-B-9lSDIn.js";import{c as R,p as z,s as B}from"./stores-vuG0AaKy.js";import{n as ie}from"./ui-store-CE4-TlwB.js";import{o as V}from"./view-navigation-DIDEcp4V.js";import{a as H,i as U,n as W,o as G,r as K,t as q}from"./dialog-ftgTihmF.js";import{t as J}from"./button-Dcy288Mc.js";import{n as ae,t as oe}from"./ModelPicker-IOZSUnqM.js";import{c as se,s as ce}from"./index-FHt-sKVF.js";import{a as Y,c as le,i as X,l as Z,n as ue,o as de,r as fe,s as pe,t as me,u as he}from"./progress-ring-B9pqitSa.js";import{SpecsView as ge}from"./SpecsView-DUx1sgtH.js";var Q=e(P(),1),$=k();function _e({feed:e,now:t}){let{t:n}=m();return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,$.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,$.jsx)(f,{className:`h-3.5 w-3.5 text-warning`}),n(`activity:sdd.activityHeading`)]}),(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-1 overflow-auto overscroll-contain p-2`,children:e.length===0?(0,$.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=X[e.kind]??X.started,i=r.icon;return(0,$.jsxs)(`div`,{className:L(`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,$.jsx)(i,{className:L(`mt-0.5 h-3.5 w-3.5 shrink-0`,r.color)}),(0,$.jsx)(`span`,{className:`flex-1 leading-snug text-foreground`,children:e.text}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums text-[10px] text-muted-foreground`,children:pe(e.ts,t)})]},`${e.ts}-${n}`)})})]})}function ve({open:e,onOpenChange:t,snapshot:n,busy:r,onConfirm:i}){let{t:a}=m(),o=n?.mergedCommits?.length??0,s=n?.baseBranch,[c,l]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&l(!1)},[e]);let u=n?.status===`running`||n?.status===`paused`,d=(0,Q.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.worktreeBranch&&e.add(t.worktreeBranch);return e.size},[n?.tasks]),f=(0,Q.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,$.jsx)(q,{open:e,onOpenChange:e=>!r&&t(e),children:(0,$.jsxs)(W,{className:`sm:max-w-lg border-destructive/50`,children:[(0,$.jsxs)(H,{children:[(0,$.jsxs)(G,{className:`flex items-center gap-2`,children:[(0,$.jsx)(E,{className:`h-5 w-5 text-destructive`}),a(`activity:sdd.destroyTitle`)]}),(0,$.jsx)(K,{children:a(`activity:sdd.destroyDesc`)})]}),(0,$.jsxs)(`ul`,{className:`space-y-1.5 py-1 text-sm`,children:[u&&(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,$.jsx)(`span`,{children:f>0?a(`activity:sdd.stopRunAgents`,{count:f}):a(`activity:sdd.stopRun`)})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,$.jsx)(`span`,{children:d>0?a(`activity:sdd.removeWorktreesCount`,{count:d}):a(`activity:sdd.removeWorktreesAll`)})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,$.jsx)(`span`,{children:a(`activity:sdd.deleteArtifacts`)})]})]}),o>0&&(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md border border-warning/30 bg-warning/5 p-2.5 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`mt-0.5 h-4 w-4 accent-warning`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:a(`activity:sdd.revertMerged`,{count:o})}),` `,`on `,(0,$.jsx)(`code`,{className:`text-xs`,children:s??a(`activity:sdd.baseBranchFallback`)}),(0,$.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:a(`activity:sdd.revertHint`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md bg-muted/50 p-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),a(o>0&&!c?`activity:sdd.noteLeaveMerged`:`activity:sdd.noteAbandon`)]}),(0,$.jsxs)(U,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(J,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,$.jsx)(J,{size:`sm`,disabled:r,onClick:()=>i(c),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{className:`mr-1 h-3.5 w-3.5 animate-spin`}),` `,a(`activity:sdd.destroying`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{className:`mr-1 h-3.5 w-3.5`}),` `,a(`activity:sdd.destroyAll`)]})})]})]})})}var ye=[{key:`pending`,labelKey:`kanbanBacklog`,accent:`border-border/70`,head:`text-muted-foreground`},{key:`queued`,labelKey:`kanbanReady`,accent:`border-primary/35`,head:`text-primary`},{key:`in_progress`,labelKey:`kanbanRunning`,accent:`border-warning/45`,head:`text-warning`},{key:`review`,labelKey:`kanbanReview`,accent:`border-primary/35`,head:`text-primary`},{key:`failed`,labelKey:`kanbanFailed`,accent:`border-destructive/35`,head:`text-destructive`},{key:`completed`,labelKey:`kanbanDone`,accent:`border-success/35`,head:`text-success`}];function be({tasks:e,selectedId:t,onTaskClick:n}){let{t:r}=m(),i=(0,Q.useMemo)(()=>{let t=new Map;for(let e of ye)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,$.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 gap-3 overflow-x-auto p-4`,children:ye.map(e=>{let a=i.get(e.key)??[];return(0,$.jsxs)(`div`,{className:`flex min-h-0 w-64 shrink-0 flex-col`,children:[(0,$.jsxs)(`div`,{className:L(`mb-2 flex items-center gap-2 border-b-2 pb-1.5`,e.accent),children:[(0,$.jsx)(`span`,{className:L(`text-xs font-bold uppercase tracking-wide`,e.head),children:r(`activity:sdd.${e.labelKey}`)}),(0,$.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-[10px] text-muted-foreground`,children:a.length})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain pr-1`,children:[a.map(e=>(0,$.jsx)(xe,{task:e,selected:e.id===t,onClick:()=>n(e.id)},e.id)),a.length===0&&(0,$.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 xe({task:e,selected:n,onClick:r}){let i=e.displayStatus===`in_progress`;return(0,$.jsxs)(`button`,{type:`button`,onClick:r,className:L(`sdd-node-enter w-full rounded-lg border bg-card/85 p-2 text-left shadow-sm transition hover:border-primary/35 hover:bg-accent/35`,n?`border-primary/55 ring-1 ring-primary/35`:`border-border/70`,i&&`sdd-node-running`,e.displayStatus===`completed`&&`sdd-node-complete`,e.displayStatus===`failed`&&`sdd-node-failed`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[i&&(0,$.jsx)(T,{className:`h-3 w-3 animate-spin text-warning`}),e.displayStatus===`completed`&&(0,$.jsx)(t,{className:`h-3 w-3 text-success`}),e.displayStatus===`failed`&&(0,$.jsx)(S,{className:`h-3 w-3 text-destructive`}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.shortId}),(0,$.jsx)(`span`,{className:L(`ml-auto rounded px-1.5 text-[9px] font-bold uppercase`,Z(e.priority).chip),children:e.priority})]}),(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-snug text-foreground`,children:e.title}),(e.agentName||e.worktreeBranch||e.retries)&&(0,$.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[e.agentName&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:L(`flex h-4 w-4 items-center justify-center rounded-full text-[8px] font-bold text-white`,i?`bg-warning sdd-agent-live`:`bg-muted-foreground`),children:de(e.agentName)}),(0,$.jsx)(`span`,{className:`max-w-[80px] truncate text-[10px] text-muted-foreground`,children:e.agentName})]}),e.retries?(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[9px] text-destructive`,children:[(0,$.jsx)(A,{className:`h-2.5 w-2.5`}),e.retries]}):null,e.worktreeBranch&&(0,$.jsx)(u,{className:`ml-auto h-2.5 w-2.5 text-muted-foreground`})]})]})}function Se({task:e,allTasks:a,feed:s,now:c,expanded:l,modelCandidates:d,defaultModel:f,onClose:p,onToggleExpanded:h,onRetry:g,onReassign:v,onSetModel:y,onSetVerification:b,onCancel:ee,onDelete:te,onSplit:C,onSelectTask:w}){let{t:T}=m(),D=he(e.displayStatus),O=D.icon,k=e.displayStatus===`in_progress`,ne=e.displayStatus===`pending`||e.displayStatus===`blocked`||e.displayStatus===`queued`,[re,j]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(``),[F,I]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(!1),[B,ie]=(0,Q.useState)(``),[V,H]=(0,Q.useState)(!1),[U,W]=(0,Q.useState)(e.verificationCommand??``),G=()=>{N.trim()&&(v(e.id,N.trim()),j(!1),P(``))},K=()=>{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&&(C(e.id,t),z(!1),ie(``))},q=(0,Q.useMemo)(()=>new Map(a.map(e=>[e.shortId,e])),[a]),J=(0,Q.useMemo)(()=>a.filter(t=>t.deps.includes(e.shortId)),[a,e.shortId]),ae=(0,Q.useMemo)(()=>s.filter(t=>t.taskId===e.id||t.taskShortId===e.shortId),[s,e.id,e.shortId]),se=e.startedAt&&!e.completedAt?le(c-e.startedAt):e.startedAt&&e.completedAt?le(e.completedAt-e.startedAt):null;return(0,$.jsxs)(`div`,{className:`sdd-rise flex h-full min-h-0 min-w-0 flex-col`,children:[(0,$.jsxs)(`div`,{className:L(`flex items-center gap-2 border-b border-border/70 bg-card/70 px-3 py-2`,l&&`px-5 py-3`),children:[(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`text-muted-foreground hover:text-foreground`,title:T(`activity:sddTask.backTitle`),children:(0,$.jsx)(M,{className:`h-4 w-4`})}),(0,$.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.shortId}),h&&(0,$.jsx)(`button`,{type:`button`,onClick:h,className:`ml-1 inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted hover:text-foreground`,title:T(l?`activity:sddTask.collapseTitle`:`activity:sddTask.expandTitle`),"aria-label":T(l?`activity:sddTask.collapseTitle`:`activity:sddTask.expandTitle`),"aria-pressed":l,children:l?(0,$.jsx)(o,{className:`h-4 w-4`}):(0,$.jsx)(x,{className:`h-4 w-4`})}),(0,$.jsxs)(`span`,{className:L(`ml-auto flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px]`,D.ring,D.text),children:[(0,$.jsx)(O,{className:L(`h-3 w-3`,k&&`animate-spin`)}),D.label]})]}),(0,$.jsxs)(`div`,{className:L(`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain`,l?`grid grid-cols-2 content-start gap-4 p-5`:`space-y-3 p-3`),children:[(0,$.jsx)(`h3`,{className:L(`text-sm font-semibold leading-snug text-foreground`,l&&`col-span-2 text-lg`),children:e.title}),e.agentName&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/70 bg-muted/45 p-2`,children:[(0,$.jsx)(`span`,{className:L(`flex h-7 w-7 items-center justify-center rounded-full text-[10px] font-bold text-white`,k?`bg-warning sdd-agent-live`:`bg-muted-foreground`),children:de(e.agentName)}),(0,$.jsxs)(`div`,{className:`leading-tight`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:e.agentName}),(0,$.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:T(k?`activity:sddTask.workingOn`:`activity:sddTask.assigned`)})]})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 text-[11px]`,children:[(0,$.jsx)(we,{label:T(`activity:sddTask.metaPriority`),children:(0,$.jsx)(`span`,{className:L(`font-medium uppercase`,Z(e.priority).text),children:e.priority})}),(0,$.jsx)(we,{label:T(`activity:sddTask.metaType`),children:e.type}),se&&(0,$.jsx)(we,{label:e.completedAt?T(`activity:sddTask.metaDuration`):T(`activity:sddTask.metaElapsed`),children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(n,{className:`h-3 w-3 text-muted-foreground`}),se]})}),e.retries?(0,$.jsx)(we,{label:T(`activity:sddTask.metaRetries`),children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-destructive`,children:[(0,$.jsx)(A,{className:`h-3 w-3`}),e.retries]})}):null,e.worktreeBranch&&(0,$.jsx)(we,{label:T(`activity:sddTask.metaWorktree`),full:!0,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-foreground`,title:e.worktreeBranch,children:[(0,$.jsx)(u,{className:`h-3 w-3 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.worktreeBranch})]})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[T(`activity:sddTask.workerModel`),!e.model&&f&&(0,$.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,T(`activity:sddTask.runDefault`,{model:f})]})]}),(0,$.jsx)(oe,{value:e.model,provider:e.provider,candidates:d,placeholder:f?T(`activity:sddTask.runDefaultPlaceholderModel`,{model:f}):T(`activity:sddTask.runDefaultPlaceholder`),onPick:(t,n)=>y(e.id,t,n),onReset:e.model?()=>y(e.id,void 0,void 0):void 0}),e.fallbackModels&&e.fallbackModels.length>0&&(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.fallbackModels.map(e=>(0,$.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`↳ `,e]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[T(`activity:sddTask.verificationCmd`),(0,$.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,T(`activity:sddTask.gatesCompletion`)]})]}),V?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`input`,{value:U,onChange:e=>W(e.target.value),onKeyDown:t=>{t.key===`Enter`?(b(e.id,U.trim()||void 0),H(!1)):t.key===`Escape`&&(W(e.verificationCommand??``),H(!1))},placeholder:T(`activity:sddTask.verifyPlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 font-mono text-[11px] text-foreground`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>{b(e.id,U.trim()||void 0),H(!1)},className:`rounded bg-primary px-2 py-0.5 text-[10px] text-primary-foreground hover:opacity-90`,children:T(`common:action.save`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{W(e.verificationCommand??``),H(!1)},className:`rounded bg-muted px-2 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:T(`common:action.cancel`)})]})]}):e.verificationCommand?(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.verificationState&&(0,$.jsx)(`span`,{title:e.verificationDetail,className:e.verificationState===`passed`?`rounded bg-success/10 px-1.5 py-0.5 text-[10px] text-success`:`rounded bg-destructive/10 px-1.5 py-0.5 text-[10px] text-destructive`,children:e.verificationState===`passed`?`✓ verified`:`✗ failed`}),(0,$.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,$.jsx)(`button`,{type:`button`,onClick:()=>H(!0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:T(`common:action.edit`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(e.id,void 0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:T(`common:action.clear`)})]}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>H(!0),className:`rounded border border-dashed border-border px-2 py-1 text-[10px] text-muted-foreground hover:bg-muted`,children:T(`activity:sddTask.addVerify`)})]}),e.description&&(0,$.jsxs)(`div`,{className:L(l&&`col-span-2`),children:[(0,$.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:T(`activity:sddTask.description`)}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap rounded-md bg-muted p-2 text-[11px] leading-relaxed text-foreground`,children:e.description})]}),(0,$.jsx)(Ce,{events:ae,expanded:l}),e.deps.length>0&&(0,$.jsx)(Te,{title:T(`activity:sddTask.dependsOn`),shortIds:e.deps,byShort:q,onSelectTask:w}),J.length>0&&(0,$.jsx)(Te,{title:T(`activity:sddTask.blocks`),shortIds:J.map(e=>e.shortId),byShort:q,onSelectTask:w})]}),(0,$.jsxs)(`div`,{className:L(`border-t border-border p-2`,l&&`px-5 py-3`),children:[re?(0,$.jsxs)(`div`,{className:`sdd-rise flex items-center gap-1.5`,children:[(0,$.jsx)(`input`,{value:N,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&G(),e.key===`Escape`&&j(!1)},placeholder:T(`activity:sddTask.newWorkerPlaceholder`),className:`min-w-0 flex-1 rounded-md border border-border/70 bg-background px-2 py-1.5 text-xs outline-none focus:border-primary/60`}),(0,$.jsx)(`button`,{type:`button`,onClick:G,disabled:!N.trim(),className:`rounded-md bg-primary/10 px-2 py-1.5 text-xs font-medium text-primary hover:bg-primary/15 disabled:opacity-40`,children:(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(!1),className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,$.jsx)(S,{className:`h-3.5 w-3.5`})})]}):F?(0,$.jsxs)(`div`,{className:`sdd-rise flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex-1 text-xs text-foreground`,children:T(F===`stop`?`activity:sddTask.confirmStop`:`activity:sddTask.confirmDelete`)}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{F===`stop`?ee(e.id):te(e.id),I(null)},className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2.5 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),` `,T(F===`stop`?`common:action.stop`:`common:action.delete`)]}),(0,$.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,$.jsx)(S,{className:`h-3.5 w-3.5`})})]}):(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>g(e.id),title:T(`activity:sddTask.retryTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-warning/12 py-1.5 text-xs font-medium text-warning hover:bg-warning/18`,children:[(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),` `,T(`common:action.retry`)]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>j(!0),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,$.jsx)(i,{className:`h-3.5 w-3.5`}),` `,T(`activity:sddTask.reassign`)]}),k&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>I(`stop`),title:T(`activity:sddTask.stopTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-destructive/10 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,$.jsx)(r,{className:`h-3.5 w-3.5`}),` `,T(`common:action.stop`)]}),!k&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>z(!0),title:T(`activity:sddTask.splitTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,$.jsx)(_,{className:`h-3.5 w-3.5`}),` `,T(`activity:sddTask.split`)]}),ne&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>I(`delete`),title:T(`activity:sddTask.deleteTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-destructive/10 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,$.jsx)(E,{className:`h-3.5 w-3.5`}),` `,T(`common:action.delete`)]})]}),R&&(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,htmlFor:`sdd-split-input`,children:T(`activity:sddTask.splitHint`)}),(0,$.jsx)(`textarea`,{id:`sdd-split-input`,rows:3,value:B,onChange:e=>ie(e.target.value),placeholder:T(`activity:sddTask.splitPlaceholder`),className:`w-full resize-y rounded-md border border-border/70 bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:K,className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,$.jsx)(_,{className:`h-3.5 w-3.5`}),` `,T(`activity:sddTask.splitInto`)]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{z(!1),ie(``)},className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,$.jsx)(S,{className:`h-3.5 w-3.5`})})]})]})]})]})}function Ce({events:e,expanded:t}){let{t:n}=m();return(0,$.jsxs)(`section`,{className:L(`rounded-lg border border-border/70 bg-background/45`,t&&`col-span-2`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-3 py-2.5`,children:[(0,$.jsx)(f,{className:`h-4 w-4 text-primary`}),(0,$.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`activity:sddTask.eventLog`)}),(0,$.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[10px] text-muted-foreground`,children:e.length}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:n(`activity:sddTask.newestFirst`)})]}),e.length===0?(0,$.jsx)(`p`,{className:`px-3 py-5 text-center text-[11px] text-muted-foreground`,children:n(`activity:sddTask.noEvents`)}):(0,$.jsx)(`div`,{className:L(`divide-y divide-border/45 overflow-auto`,t?`max-h-[32rem]`:`max-h-72`),children:e.map((e,t)=>{let n=e.kind===`file`,r=e.kind===`tool`,i=e.ok===!1||e.kind===`failed`||e.kind===`verification_failed`,a=n?ee:r?d:f;return(0,$.jsxs)(`div`,{className:L(`grid grid-cols-[4.75rem_1rem_minmax(0,1fr)] gap-2 px-3 py-2.5 text-[11px]`,i&&`bg-destructive/[0.035]`),children:[(0,$.jsx)(`time`,{dateTime:new Date(e.ts).toISOString(),className:`font-mono text-[10px] text-muted-foreground`,title:new Date(e.ts).toLocaleString(),children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,$.jsx)(a,{className:L(`mt-0.5 h-3.5 w-3.5`,i?`text-destructive`:n?`text-info`:r?`text-warning`:`text-primary`)}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.action&&(0,$.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] font-medium text-foreground`,children:e.action}),e.agentName&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.agentName}),e.durationMs!==void 0&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.durationMs<1e3?`${Math.round(e.durationMs)}ms`:`${(e.durationMs/1e3).toFixed(1)}s`})]}),e.filePath?(0,$.jsx)(`code`,{className:`mt-1 block break-all font-mono text-[10px] leading-relaxed text-foreground`,children:e.filePath}):e.detail?(0,$.jsx)(`code`,{className:`mt-1 block break-words font-mono text-[10px] leading-relaxed text-muted-foreground`,children:e.detail}):(0,$.jsx)(`p`,{className:`mt-1 break-words leading-relaxed text-foreground`,children:e.text})]})]},`${e.ts}-${e.kind}-${t}`)})})]})}function we({label:e,children:t,full:n}){return(0,$.jsxs)(`div`,{className:L(`rounded-md border border-border bg-muted/50 px-2 py-1`,n&&`col-span-2`),children:[(0,$.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,$.jsx)(`div`,{className:`text-foreground`,children:t})]})}function Te({title:e,shortIds:t,byShort:n,onSelectTask:r}){return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>{let t=n.get(e);return(0,$.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,$.jsx)(`span`,{className:L(`h-1.5 w-1.5 rounded-full`,he(t?.displayStatus??`pending`).dot)}),(0,$.jsx)(`span`,{className:`font-mono`,children:e})]},e)})})]})}function Ee({onClose:e}){let{t}=m(),{client:n}=I(),i=R(e=>e.snapshot),o=R(e=>e.lifecycleResult),s=R(e=>e.destroying),c=R(e=>e.setDestroying),l=R(e=>e.setLifecycleResult),[u,d]=(0,Q.useState)(()=>Date.now()),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(`graph`),[ee,x]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{n?.send?.({type:`sdd.board.get`})},[n]);let C=i&&(i.status===`running`||i.status===`paused`);(0,Q.useEffect)(()=>{if(!C)return;let e=setInterval(()=>d(Date.now()),1e3);return d(Date.now()),()=>clearInterval(e)},[C]);let w=(0,Q.useCallback)(e=>n?.send?.(e),[n]),T=(0,Q.useRef)(null),O=(0,Q.useCallback)(e=>{T.current=null,w({type:`sdd.board.destroy`,payload:{revertMerged:e}})},[w]),k=(0,Q.useCallback)(e=>{x(!1),l(null),c(!0),C?(w({type:`sdd.board.stop`,payload:{}}),T.current={revertMerged:e,deadline:Date.now()+2e4}):O(e)},[C,w,O,c,l]);(0,Q.useEffect)(()=>{let e=T.current;if(!e)return;if(!C||Date.now()>=e.deadline){O(e.revertMerged);return}let t=setTimeout(()=>{let e=T.current;e&&O(e.revertMerged)},Math.max(0,e.deadline-Date.now()));return()=>clearTimeout(t)},[C,i,O]);let M=(0,Q.useCallback)(()=>{l(null),w({type:`sdd.board.cleanup_worktrees`,payload:{}})},[w,l]),N=(0,Q.useCallback)(()=>{l(null),w({type:`sdd.board.rollback`,payload:{}})},[w,l]),P=(0,Q.useMemo)(()=>(i?.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})),[i?.tasks]),F=(0,Q.useMemo)(()=>{let e=new Map;for(let t of i?.tasks??[])t.displayStatus===`in_progress`&&t.agentName&&e.set(t.agentName,{name:t.agentName,task:t.title});return[...e.values()]},[i?.tasks]),B=(0,Q.useCallback)(e=>g(e),[]),V=(0,Q.useCallback)(()=>{g(null),v(!1)},[]),H=(0,Q.useCallback)(e=>w({type:`sdd.board.retry`,payload:{taskId:e}}),[w]),U=(0,Q.useCallback)(()=>w({type:`sdd.board.retry_all_failed`,payload:{}}),[w]),W=(0,Q.useCallback)((e,t)=>{let n=t.trim();n&&w({type:`sdd.board.reassign`,payload:{taskId:e,agentName:n}})},[w]),G=(0,Q.useCallback)((e,t,n)=>w({type:`sdd.board.set_task_model`,payload:{taskId:e,model:t,provider:n}}),[w]),K=(0,Q.useCallback)((e,t)=>w({type:`sdd.board.set_task_verification`,payload:{taskId:e,verificationCommand:t}}),[w]),q=(0,Q.useCallback)(e=>w({type:`sdd.board.cancel_task`,payload:{taskId:e}}),[w]),oe=(0,Q.useCallback)(e=>{w({type:`sdd.board.delete_task`,payload:{taskId:e}}),g(null),v(!1)},[w]),se=(0,Q.useCallback)((e,t)=>{w({type:`sdd.board.split_task`,payload:{taskId:e,subtasks:t}}),g(null),v(!1)},[w]),ce=ae(h!==null),X=(0,Q.useMemo)(()=>i?.tasks.find(e=>e.id===h)??null,[i?.tasks,h]),Z=i?.progress,pe=i?.diagnostics?.deadlockChains??[];return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,$.jsxs)(`header`,{className:`sdd-sheen shrink-0 border-b border-border px-4 pb-3 pt-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(f,{className:`h-5 w-5 text-warning`}),(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:i?.title??t(`activity:sddBoard.titleFallback`)}),i&&(0,$.jsx)(`span`,{className:L(`rounded-full border px-2 py-0.5 text-[11px] font-medium capitalize`,Y[i.status]??Y.idle),children:i.status}),i?.defaultModel&&(0,$.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,$.jsx)(te,{className:`h-3 w-3 text-primary`}),i.defaultModel]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&(0,$.jsxs)(`button`,{type:`button`,title:t(`activity:sddBoardView.openTheMirroredKanbanBoardSForThisRunOnePerDependencyWave`),onClick:()=>{let e=`run:${i.runId}`,t=z.getState().boards.filter(t=>t.tags?.includes(e)),r=t.find(e=>e.tags?.includes(`phase:wave-0`))??t[0];r&&(z.getState().setActiveBoardId(r.id),n?.send?.({type:`kanban.get`,payload:{boardId:r.id}})),ie.getState().setCurrentView(`kanban`)},className:`inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-muted-foreground hover:bg-muted`,children:[(0,$.jsx)(f,{className:`h-3.5 w-3.5`}),` Kanban`]}),i&&(0,$.jsx)(`div`,{className:`flex items-center rounded-md border border-border bg-muted p-0.5 text-[11px]`,children:[`graph`,`kanban`].map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(e),className:L(`rounded px-2 py-0.5 capitalize transition`,y===e?`bg-primary/12 text-primary`:`text-muted-foreground hover:text-foreground`),children:t(e===`graph`?`activity:sddBoard.graphLabel`:`activity:sddBoard.kanbanLabel`)},e))}),C&&(Z?.failed??0)>0&&(0,$.jsxs)(`button`,{type:`button`,onClick:U,title:t(`activity:sddBoard.retryAllTitle`),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.retryFailed`,{count:Z?.failed??0})]}),C&&(0,$.jsxs)($.Fragment,{children:[i?.status===`paused`?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>w({type:`sdd.board.resume`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-success/15 px-2.5 py-1 text-xs font-medium text-success hover:bg-success/25`,children:[(0,$.jsx)(j,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.resume`)]}):(0,$.jsxs)(`button`,{type:`button`,onClick:()=>w({type:`sdd.board.pause`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,$.jsx)(D,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.pause`)]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>w({type:`sdd.board.stop`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/15 px-2.5 py-1 text-xs font-medium text-destructive hover:bg-destructive/25`,children:[(0,$.jsx)(r,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.stop`)]})]}),i&&!C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:M,title:t(`activity:sddBoard.cleanTitle`),className:`inline-flex items-center gap-1 rounded-md bg-muted px-2.5 py-1 text-xs font-medium text-muted-foreground hover:bg-muted/80`,children:[(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.cleanWorktrees`)]}),(i.mergedCommits?.length??0)>0&&(0,$.jsxs)(`button`,{type:`button`,onClick:N,title:t(`activity:sddBoard.rollbackTitle`,{count:i.mergedCommits?.length??0,base:i.baseBranch??t(`activity:sdd.baseBranchFallback`)}),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,$.jsx)(a,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.rollback`,{count:i.mergedCommits?.length??0})]})]}),i&&(s?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-destructive/15 px-2.5 py-1 text-xs font-medium text-destructive`,children:[(0,$.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}),` `,t(C?`activity:sddBoard.stopping`:`activity:sddBoard.destroying`)]}):(0,$.jsxs)(`button`,{type:`button`,onClick:()=>x(!0),title:t(`activity:sddBoard.destroyTitle`),className:`inline-flex items-center gap-1 rounded-md bg-destructive px-2.5 py-1 text-xs font-medium text-destructive-foreground hover:bg-destructive/90`,children:[(0,$.jsx)(E,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.destroy`)]})),(0,$.jsx)(J,{variant:`ghost`,size:`icon`,onClick:e,children:(0,$.jsx)(S,{className:`h-4 w-4`})})]})]}),i&&Z&&(0,$.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-5`,children:[(0,$.jsx)(me,{pct:Z.percentComplete}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,$.jsx)(ke,{label:t(`activity:sddBoard.statDone`),value:`${Z.completed}/${Z.total}`,color:`text-success`}),Z.inProgress>0&&(0,$.jsx)(ke,{label:t(`activity:sddBoard.statRunning`),value:Z.inProgress,color:`text-warning`}),Z.failed>0&&(0,$.jsx)(ke,{label:t(`activity:sddBoard.statFailed`),value:Z.failed,color:`text-destructive`}),(0,$.jsx)(ke,{label:t(`activity:sddBoard.statWave`),value:i.wave+1,color:`text-primary`}),C&&i.startedAt>0&&(0,$.jsx)(ke,{label:t(`activity:sddBoard.statElapsed`),value:le(u-i.startedAt),color:`text-foreground`})]}),(0,$.jsx)(`div`,{className:`flex min-h-[24px] items-center gap-1.5`,children:F.length===0?(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:sddBoard.noActiveWorkers`)}):F.map((e,t)=>(0,$.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,$.jsx)(`span`,{className:L(`sdd-agent-live flex h-5 w-5 items-center justify-center rounded-full text-[9px] font-bold text-white`,fe[t%fe.length]),children:de(e.name)}),(0,$.jsx)(`span`,{className:`max-w-[90px] truncate text-[11px] text-foreground`,children:e.name})]},e.name))})]})]})]}),o&&(0,$.jsx)(Oe,{result:o,onDismiss:()=>l(null)}),pe.length>0&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-destructive/30 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:[(0,$.jsx)(p,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`font-semibold`,children:t(`activity:sddBoard.deadlock`)}),pe.map(e=>(0,$.jsxs)(`div`,{className:`font-mono`,children:[e.blocked,` ← `,e.blockedBy.join(`, `)]},e.blocked))]})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:i?y===`graph`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ue,{tasks:P,columns:i.columns,onTaskClick:B}),(0,$.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,$.jsx)(be,{tasks:i.tasks,selectedId:h,onTaskClick:B}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground`,children:[(0,$.jsx)(re,{className:`h-10 w-10 text-primary/40`}),(0,$.jsx)(`p`,{className:`text-foreground`,children:t(`activity:sddBoard.noRunTitle`)}),(0,$.jsx)(`p`,{className:`max-w-sm text-center text-xs text-muted-foreground`,children:t(`activity:sddBoard.noRunBody`)})]})}),i&&(0,$.jsx)(`aside`,{"data-testid":`sdd-task-panel`,"data-expanded":_&&X?`true`:`false`,className:L(`shrink-0 border-l border-border bg-card transition-[width] duration-200 ease-out`,_&&X?`w-[min(72rem,72vw)]`:`w-80`),children:X?(0,$.jsx)(Se,{task:X,allTasks:i.tasks,feed:i.taskEvents?.[X.id]??i.feed??[],now:u,expanded:_,modelCandidates:ce,defaultModel:i.defaultModel,onClose:V,onToggleExpanded:()=>v(e=>!e),onRetry:H,onReassign:W,onSetModel:G,onSetVerification:K,onCancel:q,onDelete:oe,onSplit:se,onSelectTask:g},X.id):(0,$.jsx)(_e,{feed:i.feed??[],now:u})})]}),(0,$.jsx)(ve,{open:ee,onOpenChange:x,snapshot:i,busy:s,onConfirm:k})]})}function De(e){let t=e.op===`cleanup_worktrees`?`lcClean`:e.op===`rollback`?`lcRollback`:`lcDestroy`,n=l.t(`activity:sddBoard.${t}`);if(!e.ok)return l.t(`activity:sddBoard.lcFailed`,{op:n,reason:e.reason??l.t(`activity:sddBoard.lcUnknownError`)});let r=[];typeof e.removed==`number`&&r.push(l.t(`activity:sddBoard.lcWorktrees`,{count:e.removed})),typeof e.reverted==`number`&&e.reverted>0&&r.push(l.t(`activity:sddBoard.lcCommits`,{count:e.reverted})),e.deleted?.length&&r.push(l.t(`activity:sddBoard.lcDeleted`,{items:e.deleted.join(`, `)}));let i=r.length?r.join(` · `):l.t(`activity:sddBoard.lcNothing`);return e.reason?l.t(`activity:sddBoard.lcNote`,{op:n,body:i,reason:e.reason}):l.t(`activity:sddBoard.lcOk`,{op:n,body:i})}function Oe({result:e,onDismiss:t}){let n=!e.ok||!!e.reason;return(0,$.jsxs)(`div`,{className:L(`flex items-start gap-2 border-b px-4 py-2 text-xs`,n?`border-warning/30 bg-warning/5 text-warning`:`border-success/30 bg-success/5 text-success`),children:[n?(0,$.jsx)(c,{className:`mt-0.5 h-4 w-4 shrink-0`}):(0,$.jsx)(v,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:De(e)}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 opacity-60 hover:opacity-100`,children:(0,$.jsx)(S,{className:`h-3.5 w-3.5`})})]})}function ke({label:e,value:t,color:n}){return(0,$.jsxs)(`span`,{className:`flex items-baseline gap-1`,children:[(0,$.jsx)(`span`,{className:L(`font-semibold tabular-nums`,n),children:t}),(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e})]})}var Ae={idle:`phaseStart`,questioning:`phaseInterview`,spec_review:`phaseSpecReview`,implementation:`phasePlanning`,task_review:`phaseTaskReview`,executing:`phaseRunning`,done:`phaseDone`},je=[`questioning`,`spec_review`,`implementation`,`task_review`,`executing`];function Me({onClose:e,onRunStarted:n}){let{t:r}=m(),{client:i}=I(),a=B(e=>e.snapshot),o=B(e=>e.agentText),c=B(e=>e.error),l=B(e=>e.startedRunId),u=B(e=>e.setStartedRunId),[d,f]=(0,Q.useState)(``),[p,_]=(0,Q.useState)(``),[v,ee]=(0,Q.useState)(!1),[x,te]=(0,Q.useState)(!0),[E,D]=(0,Q.useState)(!0),[O,k]=(0,Q.useState)(!1),[A,ne]=(0,Q.useState)(void 0),[re,j]=(0,Q.useState)(void 0),[M,N]=(0,Q.useState)([]),[P,R]=(0,Q.useState)(4),[z,ie]=(0,Q.useState)(!0),[V,H]=(0,Q.useState)(!1),U=ae(O),W=(0,Q.useCallback)(e=>i?.send?.(e),[i]),G=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{W({type:`sdd.spec.get`})},[W]),(0,Q.useEffect)(()=>{G.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[a?.answers.length??0,o]),(0,Q.useEffect)(()=>{l&&(u(null),n?.())},[n,u,l]);let K=a?.busy??!1,q=a?.phase??`idle`,Y=!!a?.sessionId,le=!!a?.resumed,X=a?.lastRunId;(0,Q.useEffect)(()=>{Y&&ee(!1)},[Y]);let de=a?.answers[a.answers.length-1]?.question??``,fe=!!a&&(a.taskCount>0||!!a.graphId||q===`task_review`||q===`executing`),pe=()=>{let e=d.trim();!e||K||v||(ee(!0),W({type:`sdd.spec.start`,payload:{goal:e}}))},me=()=>{let e=p.trim();!e||K||(W({type:`sdd.spec.message`,payload:{text:e}}),_(``))},he=()=>!K&&W({type:`sdd.spec.approve`,payload:{}}),ge=()=>{W({type:`sdd.run.start`,payload:{parallelSlots:P,worktrees:z,planDecompose:V,...A?{model:A,provider:re}:{},...M.length?{fallbackModels:M}:{}}}),k(!1)},_e=()=>{K||W({type:`sdd.spec.discard`,payload:{}})},ve=(0,Q.useMemo)(()=>(a?.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})),[a?.board]),ye=ve.length>0;return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,$.jsxs)(`header`,{className:`sdd-sheen flex shrink-0 items-center justify-between border-b border-border px-4 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(y,{className:`h-5 w-5 text-primary`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold`,children:a?.title||r(`activity:sddWizard.titleFallback`)}),Y&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r(`activity:sddWizard.${Ae[q]??`phaseStart`}`),q===`questioning`&&` · ${r(`activity:sddWizard.questionsSuffix`,{cur:a?.questionCount??0,max:a?.maxQuestions??0})}`,a&&a.taskCount>0?` · ${r(`activity:sddWizard.tasksSuffix`,{count:a.taskCount})}`:``]})]}),K&&(0,$.jsx)(T,{className:`h-4 w-4 animate-spin text-muted-foreground`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[X&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n?.(),className:`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-muted`,children:[(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),` `,r(`activity:sddWizard.openLiveBoard`)]}),Y&&(0,$.jsx)(`button`,{type:`button`,onClick:_e,disabled:K,title:r(`activity:sddWizard.discardTitle`),className:`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-destructive/10 hover:text-destructive disabled:opacity-50`,children:r(`activity:sddWizard.discardInterview`)}),fe&&(0,$.jsxs)(`div`,{className:`relative flex items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>k(e=>!e),title:r(`activity:sddWizard.runCfgTitle`),className:L(`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs font-medium`,A||M.length||V?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-muted text-muted-foreground hover:text-foreground`),children:[(0,$.jsx)(s,{className:`h-3.5 w-3.5`}),A||r(`activity:sddWizard.modelsLabel`)]}),(0,$.jsxs)(`button`,{type:`button`,onClick:ge,className:`inline-flex items-center gap-1 rounded-md bg-success/15 px-2.5 py-1 text-xs font-medium text-success hover:bg-success/25`,children:[(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),` `,r(`activity:sddWizard.startRun`)]}),O&&(0,$.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,$.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.defaultWorkerModel`)}),(0,$.jsx)(oe,{value:A,provider:re,candidates:U,placeholder:r(`activity:sddWizard.leaderDefaultPlaceholder`),resetLabel:r(`activity:sddWizard.useSessionDefault`),onPick:(e,t)=>{ne(e),j(t)},onReset:A?()=>{ne(void 0),j(void 0)}:void 0}),(0,$.jsx)(`div`,{className:`mb-1 mt-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.fallbackChain`)}),(0,$.jsx)(ce,{value:M,candidates:U,onChange:N}),(0,$.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:r(`activity:sddWizard.appliesToAll`)}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`label`,{htmlFor:`sdd-slots`,className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.parallelAgents`)}),(0,$.jsx)(`input`,{id:`sdd-slots`,type:`number`,min:1,max:16,value:P,onChange:e=>{let t=Number.parseInt(e.target.value,10);R(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-primary`})]}),(0,$.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.isolateWorktrees`)}),(0,$.jsx)(`input`,{type:`checkbox`,checked:z,onChange:e=>ie(e.target.checked),className:`h-3.5 w-3.5 accent-primary`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:r(z?`activity:sddWizard.worktreeOn`:`activity:sddWizard.worktreeOff`)}),(0,$.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.planDecompose`)}),(0,$.jsx)(`input`,{type:`checkbox`,checked:V,onChange:e=>H(e.target.checked),className:`h-3.5 w-3.5 accent-primary`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:r(V?`activity:sddWizard.planDecomposeOn`:`activity:sddWizard.planDecomposeOff`)})]})]}),(0,$.jsx)(J,{variant:`ghost`,size:`icon`,onClick:e,children:(0,$.jsx)(S,{className:`h-4 w-4`})})]})]}),Y&&(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b bg-card/50 px-4 py-1.5 text-[11px]`,children:je.map((e,n)=>{let i=e===q,a=je.indexOf(q)>n;return(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(`span`,{className:L(`rounded-full px-2 py-0.5`,i?`bg-primary/15 text-primary`:a?`text-success`:`text-muted-foreground`),children:[a&&(0,$.jsx)(t,{className:`mr-0.5 inline h-3 w-3`}),r(`activity:sddWizard.${Ae[e]}`)]}),n<je.length-1&&(0,$.jsx)(`span`,{className:`text-muted-foreground/65`,children:`→`})]},e)})}),(0,$.jsxs)(`div`,{ref:se(`sdd-wizard`),className:`min-h-0 flex-1 overflow-auto overscroll-contain p-4`,children:[c&&(0,$.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/5 p-2 text-xs text-destructive`,children:c}),le&&Y&&(0,$.jsx)(`div`,{className:`mb-3 rounded-md border border-primary/30 bg-primary/5 px-3 py-2 text-xs text-primary`,children:r(`activity:sddWizard.resumeBanner`)}),Y?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ye&&(0,$.jsxs)(`div`,{className:`sdd-rise overflow-hidden rounded-lg border border-primary/20 bg-[hsl(var(--surface-2)/0.85)]`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>te(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-border/60 px-3 py-1.5 text-[11px] font-medium text-primary hover:bg-muted/40`,children:[x?(0,$.jsx)(g,{className:`h-3.5 w-3.5`}):(0,$.jsx)(b,{className:`h-3.5 w-3.5`}),(0,$.jsx)(F,{className:`h-3.5 w-3.5`}),r(`activity:sddWizard.taskGraphSummary`,{count:a?.taskCount??0}),(0,$.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:r(x?`activity:sddWizard.dragToExplore`:`activity:sddWizard.show`)})]}),x&&(0,$.jsx)(`div`,{className:`h-[32dvh] min-h-[200px]`,children:(0,$.jsx)(ue,{tasks:ve,columns:a?.board?.columns??[]})})]}),(0,$.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-3`,children:[a?.goal&&(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,$.jsx)(h,{className:`h-3 w-3`}),` `,r(`activity:sddWizard.goalLabel`)]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:a.goal})]}),a?.answers.length||o&&q===`questioning`||K?(0,$.jsxs)(`div`,{className:`space-y-2.5`,children:[a?.answers.map(e=>(0,$.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,$.jsx)(Pe,{speaker:`assistant`,text:e.question}),(0,$.jsx)(Pe,{speaker:`user`,text:e.answer})]},e.question.slice(0,64))),o&&q===`questioning`&&o!==de&&(0,$.jsx)(Pe,{speaker:`assistant`,text:o}),K&&(0,$.jsx)(Pe,{speaker:`assistant`,text:``,thinking:!0})]}):null,a?.spec&&(0,$.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-semibold`,children:[(0,$.jsx)(y,{className:`h-3.5 w-3.5 text-primary`}),a.spec.title]}),(0,$.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:a.spec.overview}),(0,$.jsx)(`ul`,{className:`space-y-0.5 text-xs`,children:a.spec.requirements.map(e=>(0,$.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,$.jsx)(`span`,{className:L(`shrink-0 font-mono uppercase`,Z(e.priority).text),children:e.priority[0]}),(0,$.jsx)(`span`,{children:e.description})]},`${e.priority}-${e.description.slice(0,32)}`))})]}),o&&(q===`implementation`||q===`task_review`)&&(0,$.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>D(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:[E?(0,$.jsx)(g,{className:`h-3.5 w-3.5`}):(0,$.jsx)(b,{className:`h-3.5 w-3.5`}),(0,$.jsx)(y,{className:`h-3.5 w-3.5 text-primary`}),` `,r(`activity:sddWizard.implementationPlan`)]}),E&&(0,$.jsx)(`div`,{className:`max-h-[40dvh] overflow-auto px-3 py-2`,children:(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:Ne(o)})})]}),o&&q!==`questioning`&&q!==`implementation`&&q!==`task_review`&&!a?.spec&&(0,$.jsx)(Pe,{speaker:`assistant`,text:o}),(q===`spec_review`||q===`implementation`||q===`task_review`)&&(0,$.jsxs)(J,{variant:`secondary`,onClick:he,disabled:K,children:[(0,$.jsx)(t,{className:`mr-1.5 h-4 w-4`}),r(q===`spec_review`?`activity:sddWizard.approveSpec`:q===`task_review`?`activity:sddWizard.approveTasks`:`activity:sddWizard.approvePlan`)]}),(0,$.jsx)(`div`,{ref:G})]})]}):(0,$.jsxs)(`div`,{className:`mx-auto mt-8 max-w-xl`,children:[(0,$.jsx)(`label`,{className:`mb-2 block text-sm font-medium`,htmlFor:`sdd-goal`,children:r(`activity:sddWizard.goalPrompt`)}),(0,$.jsx)(`textarea`,{id:`sdd-goal`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&pe()},rows:4,placeholder:r(`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-primary`}),(0,$.jsx)(J,{className:`mt-3`,onClick:pe,disabled:!d.trim()||v,children:v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{className:`mr-1.5 h-4 w-4 animate-spin`}),` `,r(`activity:sddWizard.startingInterview`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{className:`mr-1.5 h-4 w-4`}),` `,r(`activity:sddWizard.startInterview`)]})}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:r(`activity:sddWizard.introBody`)})]})]}),Y&&q!==`executing`&&q!==`done`&&(0,$.jsxs)(`div`,{className:`flex shrink-0 items-end gap-2 border-t bg-card px-4 py-2`,children:[(0,$.jsx)(`textarea`,{value:p,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),me())},rows:1,placeholder:r(q===`questioning`?`activity:sddWizard.answerPlaceholder`:`activity:sddWizard.changePlaceholder`),disabled:K,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-primary disabled:opacity-50`}),(0,$.jsx)(J,{size:`icon`,onClick:me,disabled:K||!p.trim(),children:(0,$.jsx)(w,{className:`h-4 w-4`})})]})]})}function Ne(e){let t=e.replace(/```json[\s\S]*?```/gi,``).trim();return t.length>0?t:e.trim()}function Pe({speaker:e,text:t,live:n,thinking:r}){let i=e===`user`;return(0,$.jsxs)(`div`,{className:L(`sdd-rise flex items-start gap-2`,i&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:L(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,i?`bg-info/15 text-info`:`bg-primary/15 text-primary`,(n||r)&&`sdd-agent-live`),children:i?(0,$.jsx)(N,{className:`h-3.5 w-3.5`}):(0,$.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`div`,{className:L(`max-w-[80%] whitespace-pre-wrap rounded-2xl px-3 py-2 text-sm leading-relaxed text-foreground`,i?`rounded-tr-sm bg-info/10`:`rounded-tl-sm bg-muted`),children:r?(0,$.jsxs)(`span`,{className:`flex items-center gap-1 py-0.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-200ms]`}),(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-100ms]`}),(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground`})]}):t})]})}var Fe=[{id:`project`,labelKey:`activity:sddhub.tabProject`},{id:`board`,labelKey:`activity:sddhub.tabBoard`},{id:`specs`,labelKey:`activity:sddhub.tabSpecs`}];function Ie(){let{t:e}=m(),[t,n]=(0,Q.useState)(`project`),r=B(e=>e.startedRunId),i=B(e=>e.setStartedRunId),a=()=>V(`chat`),o=(0,Q.useCallback)(()=>n(`board`),[]);(0,Q.useEffect)(()=>{r&&(n(`board`),i(null))},[r,i]);let s=(e,t)=>{let r;if(e.key===`ArrowLeft`&&(r=(t-1+Fe.length)%Fe.length),e.key===`ArrowRight`&&(r=(t+1)%Fe.length),e.key===`Home`&&(r=0),e.key===`End`&&(r=Fe.length-1),r===void 0)return;e.preventDefault();let i=Fe[r];i&&(n(i.id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[r]?.focus())};return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,$.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,className:`flex shrink-0 items-end border-b border-border/70 bg-card px-4`,children:Fe.map((r,i)=>{let a=t===r.id;return(0,$.jsxs)(`button`,{id:`sdd-hub-tab-${r.id}`,type:`button`,role:`tab`,"aria-selected":a,"aria-controls":`sdd-hub-panel-${r.id}`,tabIndex:a?0:-1,onClick:()=>n(r.id),onKeyDown:e=>s(e,i),className:L(`relative px-4 py-2.5 text-sm font-medium transition-colors`,a?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e(r.labelKey),a&&(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute bottom-0 left-0 right-0 h-0.5 bg-primary`})]},r.id)})}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:[(0,$.jsx)(`div`,{id:`sdd-hub-panel-project`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-project`,hidden:t!==`project`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,$.jsx)(Me,{onClose:a,onRunStarted:o})}),(0,$.jsx)(`div`,{id:`sdd-hub-panel-board`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-board`,hidden:t!==`board`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,$.jsx)(Ee,{onClose:a})}),(0,$.jsx)(`div`,{id:`sdd-hub-panel-specs`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-specs`,hidden:t!==`specs`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,$.jsx)(ge,{onClose:a,onRunStarted:o})})]})]})}export{Ie as SddHub};
|