@wrongstack/webui 0.298.3 → 0.299.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-RvxaV08Y.js → AgentRosterView-BqojERFR.js} +4 -4
- package/dist/assets/{AnalyticsDashboard-irejsLMt.js → AnalyticsDashboard-D58kSekC.js} +1 -1
- package/dist/assets/{AudienceMemoryPanel-DDW_WPjf.js → AudienceMemoryPanel-Cc1UkbDl.js} +1 -1
- package/dist/assets/ChangesView-BKU80ANq.js +1 -0
- package/dist/assets/ChronicleDashboard-CvCS1Dj1.js +1 -0
- package/dist/assets/CodeEditor-BHZQhx_8.js +1 -0
- package/dist/assets/CodeMap-qllGEFLB.js +1 -0
- package/dist/assets/{CronJobsPanel-BXujnpGC.js → CronJobsPanel-DD5mhZ4Q.js} +1 -1
- package/dist/assets/{DeadCodeScanPanel-HTbGUTMl.js → DeadCodeScanPanel-PB-c8et_.js} +1 -1
- package/dist/assets/{DebugDashboard-B5kJBUv0.js → DebugDashboard-Q8QiVflQ.js} +1 -1
- package/dist/assets/{DesignGalleryView-BQ0CZpQm.js → DesignGalleryView-CGOtWO7s.js} +1 -1
- package/dist/assets/{GoalView-DvaSR6CO.js → GoalView-Dlk42vW7.js} +1 -1
- package/dist/assets/KanbanView-DIP6kKmU.js +3 -0
- package/dist/assets/{MailboxDetailView-Dh8ekyMw.js → MailboxDetailView-ZcKcOEAe.js} +1 -1
- package/dist/assets/MemoryManager-B7620q_K.js +1 -0
- package/dist/assets/{ModelPicker-BxYMTEEN.js → ModelPicker-DvNLZzkm.js} +1 -1
- package/dist/assets/OfficeMapPanel-DKJNTtOZ.js +4 -0
- package/dist/assets/{ProcessMonitor-DVUCtVHZ.js → ProcessMonitor-2nSk6sXA.js} +1 -1
- package/dist/assets/{QueuePanel-n9lScdWu.js → QueuePanel-4KBBWFxj.js} +1 -1
- package/dist/assets/{RefreshDebugView-eZQ3wdxU.js → RefreshDebugView-D3XnE53y.js} +1 -1
- package/dist/assets/RequirementIntakeView-BMxlf8bt.js +1 -0
- package/dist/assets/{SageTabs-B-eQ--Sb.js → SageTabs-g1hO2hJ0.js} +2 -2
- package/dist/assets/SddHub-Kv_TbTgT.js +2 -0
- package/dist/assets/SessionInspectView-PnKTvyvP.js +1 -0
- package/dist/assets/SessionList-BeinIC-h.js +1 -0
- package/dist/assets/SessionsDashboard-DEG_BylE.js +1 -0
- package/dist/assets/SetupScreen-DxJwZ1OZ.js +1 -0
- package/dist/assets/SkillDetailView-D7EQ2XtV.js +3 -0
- package/dist/assets/{SpecsView-BYiJr__T.js → SpecsView-Fm7pYYcj.js} +1 -1
- package/dist/assets/TechStackView-Bo_UenRF.js +1 -0
- package/dist/assets/{TerminalPanel-BgMsGfGa.js → TerminalPanel-BL9ZPGJt.js} +1 -1
- package/dist/assets/{Toaster-EXqX2jqp.js → Toaster-CJI70aa-.js} +1 -1
- package/dist/assets/{activity-DReNmuta.js → activity-BCgOEWgR.js} +2 -2
- package/dist/assets/{activity-Dyh19u3P.js → activity-BQ0zqkw2.js} +2 -2
- package/dist/assets/{activity-BJijwuIr.js → activity-CAovbq3e.js} +2 -2
- package/dist/assets/{activity-BBPMHCAJ.js → activity-CFQyCvgu.js} +2 -2
- package/dist/assets/{activity-GR8KiHvf.js → activity-CdQf7zRK.js} +2 -2
- package/dist/assets/{activity-iuGHFz2B.js → activity-DACvyn2-.js} +2 -2
- package/dist/assets/{activity-DeEOo2zu.js → activity-DOwYydU-.js} +2 -2
- package/dist/assets/{button-DwmC7ENW.js → button-Dcy288Mc.js} +1 -1
- package/dist/assets/{chat-store-LHzJqRCp.js → chat-store-CtOyUCdF.js} +2 -2
- package/dist/assets/{codemap-activity-store-B6n7KiS8.js → codemap-activity-store-DQfjo7-j.js} +1 -1
- package/dist/assets/codemap-index-store-COStDU-8.js +1 -0
- package/dist/assets/{dialog-DsCmc6eL.js → dialog-ftgTihmF.js} +1 -1
- package/dist/assets/{empty-state-02bIS4x7.js → empty-state-RRSqQaCk.js} +1 -1
- package/dist/assets/{i18n-DxnYsmc-.js → i18n-B0hsnanh.js} +2 -2
- package/dist/assets/index-DHdO0CRE.js +132 -0
- package/dist/assets/index-DKrFQ76m.css +1 -0
- package/dist/assets/{input-UhWgodVi.js → input-fo9-BPBC.js} +1 -1
- package/dist/assets/{mailbox-store-xh2Ux-Xs.js → mailbox-store-D8TvJsuk.js} +1 -1
- package/dist/assets/{progress-ring-C0O73ZjR.js → progress-ring-61A-xUEl.js} +1 -1
- package/dist/assets/{roster-ws-DlQQL7Eh.js → roster-ws-Dfg_187V.js} +1 -1
- package/dist/assets/{session-store-BE_S1f5v.js → session-store-b2KGFwkX.js} +1 -1
- package/dist/assets/{shared-bBntASiy.js → shared-KAzksK0C.js} +1 -1
- package/dist/assets/stores-BptlyD_v.js +7 -0
- package/dist/assets/ui-store-BsBnjO3w.js +1 -0
- package/dist/assets/useWebSocket-Bc4S0N4r.js +29 -0
- package/dist/assets/{utils-_s0GyctV.js → utils-B-9lSDIn.js} +1 -1
- package/dist/assets/{vendor-CxV3l5PQ.js → vendor-BuarzSSb.js} +30 -30
- package/dist/assets/{view-navigation-DLdE7qHU.js → view-navigation-DxfiZrXS.js} +1 -1
- package/dist/assets/ws-client-DqFoX4jJ.js +1 -0
- package/dist/components/CouncilLogTimeline.d.ts +2 -0
- package/dist/components/QuickModelSwitcher.filter.d.ts +9 -4
- package/dist/components/RequirementIntakeView.d.ts +2 -0
- package/dist/components/SessionInspectView.d.ts +2 -0
- package/dist/components/SettingsPanel/ModelCatalogPicker.d.ts +1 -2
- package/dist/components/SettingsPanel/brain-section-options.d.ts +16 -0
- package/dist/components/ViewRouter.d.ts +1 -1
- package/dist/hooks/useWebSocket.d.ts +1 -0
- package/dist/index.html +21 -21
- package/dist/index.js +10761 -9484
- package/dist/lib/view-navigation.d.ts +2 -2
- package/dist/lib/ws-client-actions.d.ts +1 -0
- package/dist/stores/council-log-store.d.ts +67 -0
- package/dist/stores/index.d.ts +3 -1
- package/dist/stores/session-inspect-store.d.ts +51 -0
- package/dist/stores/ui-store.d.ts +19 -7
- package/dist/stores/viz-store.d.ts +1 -1
- package/dist/types/brain.d.ts +15 -0
- package/dist/types/client-message.d.ts +5 -0
- package/dist/types/server-message.d.ts +2 -2
- package/dist/types/system.d.ts +35 -0
- package/package.json +8 -8
- package/dist/assets/ChangesView-Bnd167hf.js +0 -1
- package/dist/assets/ChronicleDashboard-DC62FDEt.js +0 -1
- package/dist/assets/CodeEditor-DCWcCQPO.js +0 -1
- package/dist/assets/CodeMap-DSqqgBuD.js +0 -1
- package/dist/assets/KanbanView-DpWs_i8T.js +0 -3
- package/dist/assets/MemoryManager-CUAbNwsz.js +0 -1
- package/dist/assets/OfficeMapPanel-HgERknuN.js +0 -4
- package/dist/assets/SddHub-D81poT6w.js +0 -2
- package/dist/assets/SessionsDashboard-CR3NZeHw.js +0 -1
- package/dist/assets/SetupScreen-t6wrhv6l.js +0 -1
- package/dist/assets/SkillDetailView-D6TOvMQU.js +0 -3
- package/dist/assets/TechStackView-HEMM3PkG.js +0 -1
- package/dist/assets/codemap-index-store-oapPwtvI.js +0 -1
- package/dist/assets/index-Bf75VrDE.js +0 -132
- package/dist/assets/index-NFp5CXyK.css +0 -1
- package/dist/assets/stores-BS-Bdi-5.js +0 -7
- package/dist/assets/ui-store-C4Ybfoon.js +0 -1
- package/dist/assets/useWebSocket-x8PMoTq8.js +0 -28
- package/dist/assets/ws-client-Cy3oRAmZ.js +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
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-B0hsnanh.js";import{s as xe}from"./ws-client-DqFoX4jJ.js";import{t as H}from"./utils-B-9lSDIn.js";import{t as Se}from"./session-store-b2KGFwkX.js";import{C as Ce,d as we,u as U,y as Te}from"./stores-BptlyD_v.js";import{r as Ee}from"./mailbox-store-D8TvJsuk.js";import{d as De}from"./markdown-sSmz-Ua_.js";import{_ as Oe,d as ke,f as Ae,g as je,l as Me,u as Ne,w as Pe}from"./index-DHdO0CRE.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":`Close details`,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":`Close mail details`,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:`Priority`,value:r.priority}),(0,Y.jsx)(X,{label:`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":`Close task details`,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":`Close office briefing`,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":`Session activity totals`,children:[(0,Y.jsxs)(`span`,{title:`Unique files touched`,children:[(0,Y.jsx)(x,{}),` `,(0,Y.jsx)(`strong`,{children:o.files}),` FILES`]}),(0,Y.jsxs)(`span`,{title:`File reads`,children:[(0,Y.jsx)(O,{}),` `,(0,Y.jsx)(`strong`,{children:o.reads}),` READ`]}),(0,Y.jsxs)(`span`,{title:`Files written`,children:[(0,Y.jsx)(n,{}),` `,(0,Y.jsx)(`strong`,{children:o.writes}),` WRITE`]}),(0,Y.jsxs)(`span`,{title:`Files edited`,children:[(0,Y.jsx)(n,{}),` `,(0,Y.jsx)(`strong`,{children:o.edits}),` EDIT`]}),(0,Y.jsxs)(`span`,{className:`agent-office__client-delta`,title:`Lines added and removed`,children:[(0,Y.jsxs)(`strong`,{children:[`+`,o.linesAdded]}),` / `,(0,Y.jsxs)(`b`,{children:[`−`,o.linesRemoved]})]}),(0,Y.jsxs)(`span`,{title:`Terminal commands`,children:[(0,Y.jsx)(y,{}),` `,(0,Y.jsx)(`strong`,{children:o.terminalCalls}),` TERM`]}),(0,Y.jsxs)(`span`,{title:`Incoming and outgoing mail`,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`}),` 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`,{}),` 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":`Close tool details`}),(0,Y.jsx)(dt,{selected:l,onClose:()=>u(null)})]})]})}function rn(){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:`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:`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:`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:`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 an({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 on(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 sn={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 cn({entry:e}){let{t}=m();return e.role===`error`?(0,Y.jsx)(ke,{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`}),on(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)(Me,{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)(Ne,{remarkPlugins:[De],rehypePlugins:Oe,components:je,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)(Ne,{remarkPlugins:[De],rehypePlugins:Oe,components:je,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)(Ne,{remarkPlugins:[De],rehypePlugins:Oe,components:je,children:e.text})})}function ln({entry:e,isContinuation:t=!1}){let{t:n}=m(),r=sn[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:[`· `,on(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)(cn,{entry:e})})}),e.text&&e.role!==`error`&&(0,Y.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Y.jsx)(Ae,{text:e.text,label:n(`common:action.copy`)})})]})]})}var un=[`steer`,`ask`,`assign`,`note`],dn=2500;function fn({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())},dn);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)(ln,{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:un.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))`},pn=.12;function mn(e){return Math.min(100,Math.max(0,e??0))}function hn({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 gn({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 _n({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)(hn,{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)(gn,{data:e})]})}function vn({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)(hn,{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)(gn,{data:e})]})}function yn({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)(hn,{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)(gn,{data:e})]})}function bn({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)(hn,{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 xn({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=mn(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)(hn,{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 Sn({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)(hn,{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 Cn({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 wn={webui:_n,tui:vn,repl:yn,coordinator:bn,agent:xn,mailbox:Cn,desk:Sn};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 Tn({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=mn(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)(Pe,{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)(fn,{sessionId:o.sessionId})})]})]})}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();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 On({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 kn({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 An(){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 jn({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)(fn,{sessionId:r,limit:500})})]})}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);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:pn,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:pn,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(rgba(255,255,255,0.1) 1px, transparent 1px),
|
|
3
|
+
linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px)
|
|
4
|
+
`,backgroundSize:`40px 40px`}}),g&&(0,Y.jsx)(rn,{}),(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)(Dn,{}),(0,Y.jsxs)(M,{nodes:C,edges:E,onNodesChange:T,onEdgesChange:k,onConnect:Oe,onNodeClick:ke,onPaneClick:Ae,nodeTypes:wn,edgeTypes:En,fitView:!0,fitViewOptions:{padding:pn},minZoom:.15,maxZoom:1.5,defaultEdgeOptions:{type:`wire`},proOptions:{hideAttribution:!0},children:[(0,Y.jsx)(kn,{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)(An,{})]}),b&&(0,Y.jsx)(an,{events:a,now:Date.now()}),F&&(0,Y.jsx)(On,{draft:ae,isSending:I,result:le,onClose:()=>ie(!1),onDraftChange:oe,onSend:()=>void fe()}),A&&(0,Y.jsx)(Tn,{selectedNode:A,selectedAgentTranscript:de,mailboxMessages:u,onClose:Ae,onOpenWatch:ne}),N&&(0,Y.jsx)(jn,{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 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bt as t,
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bt as t,Jt as n,Nt as r,Pa as i,lt as a,za as o}from"./vendor-BuarzSSb.js";import"./i18n-B0hsnanh.js";import{t as s}from"./useWebSocket-Bc4S0N4r.js";import{t as c}from"./utils-B-9lSDIn.js";import{P as l}from"./stores-BptlyD_v.js";import{n as u,o as d,r as f,t as p}from"./dialog-ftgTihmF.js";var m=e(o(),1),h=a();function g({open:e,onClose:a,className:o}){let{t:g}=i(),[_,v]=(0,m.useState)([]),y=s(),b=l(e=>e.wsConnected),x=(0,m.useRef)(null),S=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!(!e||!b||!y.client?.isConnected))return y.client.send?.({type:`process.list`}),x.current=y.client.on?.(`process.list`,e=>{let t=e?.payload;t?.processes&&v(t.processes)})??null,S.current=setInterval(()=>{y.client.send?.({type:`process.list`})},3e3),()=>{x.current?.(),S.current&&clearInterval(S.current)}},[e,b,y.client]);let C=_.filter(e=>e.status===`running`),w=(0,m.useCallback)(e=>{e.background&&!window.confirm(g(`activity:process.confirmKillBackground`,{pid:e.pid,defaultValue:`Terminate detached background process ${e.pid}?`}))||y.client.send?.({type:`process.kill`,payload:{pid:e.pid}})},[g,y.client]),T=(0,m.useCallback)(()=>{window.confirm(g(`activity:process.confirmKillAll`,{count:C.length,defaultValue:`Terminate all ${C.length} running processes?`}))&&y.client.send?.({type:`process.killAll`})},[C.length,g,y.client]);return(0,h.jsx)(p,{open:e,onOpenChange:e=>{e||a()},children:(0,h.jsxs)(u,{className:c(`max-w-lg gap-0 p-0 overflow-hidden flex flex-col max-h-[75dvh] pt-[10dvh]`,o),showCloseButton:!1,children:[(0,h.jsx)(d,{className:`sr-only`,children:g(`activity:process.heading`)}),(0,h.jsx)(f,{className:`sr-only`,children:g(`activity:process.subtitle`,{active:C.length,total:_.length})}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b shrink-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,h.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-warning/10 text-warning`,children:(0,h.jsx)(r,{className:`h-4 w-4`})}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold`,children:g(`activity:process.heading`)}),(0,h.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:g(`activity:process.subtitle`,{active:C.length,total:_.length})})]})]}),(0,h.jsx)(`div`,{className:`flex items-center gap-1`,children:C.length>0&&(0,h.jsxs)(`button`,{type:`button`,onClick:T,className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,children:[(0,h.jsx)(t,{className:`h-3 w-3 fill-current`}),g(`activity:process.killAll`)]})})]}),(0,h.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:_.length===0?(0,h.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,h.jsx)(r,{className:`h-10 w-10 opacity-15`}),(0,h.jsx)(`p`,{className:`text-sm font-medium`,children:g(`activity:process.emptyTitle`)}),(0,h.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:g(`activity:process.emptyBody`)})]}):(0,h.jsx)(`div`,{className:`divide-y`,children:_.map(e=>{let r=e.status===`running`?Math.floor((Date.now()-e.startedAt)/1e3):null,i=r?r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`:null,a=e.protected===!0,o=e.background===!0;return(0,h.jsxs)(`div`,{className:c(`flex items-center justify-between px-4 py-3 text-xs transition-colors`,e.status===`running`?`bg-background hover:bg-muted/30`:`bg-muted/20 text-muted-foreground`),children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:c(`led shrink-0`,e.status===`running`?a?`text-info`:`text-success led-pulse`:`text-muted-foreground`)}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:g(`activity:process.pidLabel`,{pid:e.pid})}),(0,h.jsx)(`span`,{className:`font-medium truncate`,children:e.tool}),a&&(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] bg-info/10 text-info font-medium shrink-0`,title:g(`activity:process.protectedTitle`),children:[(0,h.jsx)(n,{className:`h-2.5 w-2.5`}),g(`activity:process.protected`)]}),o&&(0,h.jsx)(`span`,{className:`inline-flex items-center px-1 py-0.5 rounded text-[9px] bg-success/10 text-success font-medium shrink-0`,title:g(`activity:process.backgroundTitle`),children:g(`activity:process.background`)})]}),(0,h.jsx)(`code`,{className:`text-[10px] text-muted-foreground/70 truncate block mt-0.5 font-mono`,children:e.command})]})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 ml-3`,children:[i&&(0,h.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:i}),e.status===`running`&&!a&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>w(e),className:`p-1.5 rounded-md hover:bg-destructive/10 hover:text-destructive transition-colors`,title:g(`activity:process.killTitle`,{pid:e.pid}),children:(0,h.jsx)(t,{className:`h-3.5 w-3.5 fill-current`})})]})]},e.pid)})})})]})})}export{g as ProcessMonitor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-CtOyUCdF.js";import{$i as n,Pa as r,cr as i,dt as a,jt as o,lt as s,va as c,wa as l,za as u}from"./vendor-BuarzSSb.js";import"./i18n-B0hsnanh.js";import{t as d}from"./utils-B-9lSDIn.js";import"./stores-BptlyD_v.js";import{n as f,o as p,r as m,t as h}from"./dialog-ftgTihmF.js";var g=e(u(),1),_=s(),v={btw:{label:`btw`,titleKey:`btwTitle`,tone:`bg-primary/10 text-primary border-primary/30`},steer:{label:`steer`,titleKey:`steerTitle`,tone:`bg-warning/10 text-warning border-warning/35`},queue:{label:`queue`,titleKey:`queueTitle`,tone:`bg-info/10 text-info border-info/30`}};function y({open:e,onClose:s,className:u}){let{t:y}=r(),b=t(e=>e.queue),x=t(e=>e.removeQueued),S=t(e=>e.clearQueue),[C,w]=(0,g.useState)(`oldest`),T=(0,g.useCallback)(e=>{x(e)},[x]),E=(0,g.useMemo)(()=>{let e=b.map((e,t)=>({item:e,sourceIdx:t}));return e.sort((e,t)=>C===`newest`?t.item.addedAt-e.item.addedAt:e.item.addedAt-t.item.addedAt),e},[b,C]),D=b.length>0&&b.every(e=>e.alreadyDispatched);return(0,_.jsx)(h,{open:e,onOpenChange:e=>{e||s()},children:(0,_.jsxs)(f,{className:d(`max-w-lg gap-0 overflow-hidden border-border/80 bg-card p-0 pt-[10dvh] flex flex-col max-h-[70dvh]`,u),showCloseButton:!1,children:[(0,_.jsx)(p,{className:`sr-only`,children:y(`activity:queue.heading`)}),(0,_.jsx)(m,{className:`sr-only`,children:y(`activity:queue.subtitle`,{count:b.length})}),(0,_.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/95 px-4 py-3 shrink-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,_.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,_.jsx)(i,{className:`h-4 w-4`})}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{className:`text-sm font-semibold`,children:y(`activity:queue.heading`)}),(0,_.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:y(`activity:queue.subtitle`,{count:b.length})})]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,_.jsxs)(`button`,{type:`button`,onClick:()=>w(e=>e===`newest`?`oldest`:`newest`),className:d(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs transition-colors font-medium`,`text-muted-foreground hover:bg-muted hover:text-foreground`),title:y(C===`newest`?`activity:queue.sortNewestTitle`:`activity:queue.sortOldestTitle`),"data-testid":`queue-sort-toggle`,children:[C===`newest`?(0,_.jsx)(l,{className:`h-3 w-3`}):(0,_.jsx)(c,{className:`h-3 w-3`}),y(C===`newest`?`activity:queue.newest`:`activity:queue.oldest`)]}),b.length>0&&!D&&(0,_.jsxs)(`button`,{type:`button`,onClick:()=>S(),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,title:y(`activity:queue.clearDispatchedTitle`),"data-testid":`queue-clear-all`,children:[(0,_.jsx)(o,{className:`h-3 w-3`}),y(`activity:queue.clear`)]})]})]}),(0,_.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:b.length===0?(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,_.jsx)(i,{className:`h-10 w-10 opacity-15`}),(0,_.jsx)(`p`,{className:`text-sm font-medium`,children:y(`activity:queue.emptyTitle`)}),(0,_.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:y(`activity:queue.emptyBody`)})]}):(0,_.jsx)(`ul`,{className:`divide-y divide-border/60`,"data-testid":`queue-list`,children:E.map(({item:e,sourceIdx:t},r)=>{let i=v[e.mode],o=e.alreadyDispatched===!0;return(0,_.jsxs)(`li`,{className:d(`flex items-start justify-between gap-3 px-4 py-3 text-xs transition-colors`,o?`bg-muted/30 text-muted-foreground hover:bg-muted/40`:`hover:bg-muted/35`),"data-testid":`queue-item`,"data-dispatched":o?`true`:void 0,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0 flex-1`,children:[(0,_.jsxs)(`span`,{className:`mt-1 text-[10px] font-mono text-muted-foreground shrink-0 w-5 text-right tabular-nums`,children:[r+1,`.`]}),(0,_.jsx)(`span`,{className:d(`shrink-0 inline-flex items-center justify-center rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,i.tone,o&&`opacity-60`),title:y(`activity:queue.${i.titleKey}`),"data-testid":`queue-mode-${e.mode}`,children:i.label}),(0,_.jsx)(`p`,{className:`text-sm leading-relaxed min-w-0 break-words flex-1`,children:e.text.length>120?`${e.text.slice(0,117)}…`:e.text}),o&&(0,_.jsxs)(`span`,{className:`shrink-0 mt-0.5 inline-flex items-center gap-1 text-[10px] font-semibold uppercase text-success`,title:y(`activity:queue.dispatchedTitle`),"data-testid":`queue-dispatched-${t}`,children:[(0,_.jsx)(n,{className:`h-3 w-3`}),y(`activity:queue.dispatchedLabel`)]})]}),!o&&(0,_.jsx)(`button`,{type:`button`,onClick:()=>T(t),className:`ml-1 p-1.5 rounded-md shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors`,title:y(`activity:queue.removeTitle`),"data-testid":`queue-remove-${t}`,children:(0,_.jsx)(a,{className:`h-3.5 w-3.5`})})]},`${e.addedAt}-${t}`)})})}),b.length>0&&(0,_.jsx)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-2.5 shrink-0`,children:(0,_.jsx)(`p`,{className:`text-[10px] text-muted-foreground text-center`,children:y(`activity:queue.footer`)})})]})})}export{y as QueuePanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-CtOyUCdF.js";import{Er as n,Oa as r,Ot as i,Pa as a,Wi as o,lt as s,pn as c,rn as l,vi as u,za as d}from"./vendor-BuarzSSb.js";import"./i18n-B0hsnanh.js";import{n as f}from"./ui-store-BsBnjO3w.js";import{t as p}from"./session-store-b2KGFwkX.js";var m=e(d(),1),h=s();function g(){let e=p(e=>e.session),{t:s}=a(),d=p.getState().session?.id,g=p(e=>e.projectName),x=p(e=>e.cwd),S=p(e=>e.mode),C=p(e=>e.contextMode),w=p(e=>e.lastVisitedAt),T=t(e=>e.messages),E=t(e=>e.queue.length),D=t(e=>e.boundSessionId),O=f(e=>e.currentView),k=f(e=>e.dockSection),[A,j]=(0,m.useState)([]),M=(0,m.useMemo)(()=>{if(typeof window>`u`)return 0;let e=0;for(let t of[`wrongstack-session`,`wrongstack-chat`,`wrongstack-ui`,`wrongstack-config`]){let n=window.localStorage.getItem(t);typeof n==`string`&&(e+=n.length)}return e},[T.length]),N=typeof window<`u`&&!!window.__wrongstackSessionRehydrated,P=typeof window<`u`&&!!window.__wrongstackChatRehydrated;function F(e,t){j(n=>[{ts:Date.now(),note:e,ok:t},...n].slice(0,20))}function I(){F(s(`activity:refresh.simulatedF5`),!0)}let L=D!==null&&d!==void 0&&D!==d;return(0,h.jsx)(`div`,{className:`h-full min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,h.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5 sm:space-y-6`,children:[(0,h.jsx)(`header`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`h1`,{className:`flex min-w-0 items-center gap-2 text-xl font-bold sm:text-2xl`,children:[(0,h.jsx)(c,{className:`h-6 w-6 shrink-0 text-primary sm:h-7 sm:w-7`}),s(`activity:refresh.heading`)]}),(0,h.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:s(`activity:refresh.subtitle`)})]}),(0,h.jsx)(`button`,{type:`button`,onClick:I,className:`inline-flex h-9 w-full items-center justify-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground shadow-sm shadow-primary/15 hover:bg-primary/90 sm:w-auto`,children:s(`activity:refresh.recordProbe`)})]})}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(r,{className:`w-5 h-5`}),s(`activity:refresh.latestSession`)]}),(0,h.jsx)(_,{label:s(`activity:refresh.restoredLocal`),ok:N,extra:d?s(`activity:refresh.sessionIdExtra`,{id:d}):s(`activity:refresh.noSessionYet`)}),(0,h.jsx)(_,{label:s(`activity:refresh.activePointer`),ok:!!e?.id,extra:e?y(e):`null`}),(0,h.jsx)(_,{label:s(`activity:refresh.lastVisited`),ok:w>0,extra:w>0?new Date(w).toISOString():s(`activity:refresh.never`)})]}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(u,{className:`w-5 h-5`}),s(`activity:refresh.persistedEnv`)]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,h.jsx)(v,{label:`projectName`,value:g||`∅`}),(0,h.jsx)(v,{label:`cwd`,value:x||`∅`,mono:!0}),(0,h.jsx)(v,{label:`mode`,value:S,mono:!0}),(0,h.jsx)(v,{label:`contextMode`,value:C,mono:!0})]})]}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(n,{className:`w-5 h-5`}),s(`activity:refresh.transcriptRehydrate`)]}),(0,h.jsx)(_,{label:s(`activity:refresh.localTranscript`),ok:P&&(T.length>0||D===null),extra:T.length===0?s(`activity:refresh.noMessages`):s(`activity:refresh.messagesExtra`,{count:T.length,queued:E})}),(0,h.jsx)(_,{label:s(`activity:refresh.noBleed`),ok:!L,extra:L?s(`activity:refresh.bleedExtra`,{bound:D??`∅`,active:d??`∅`}):s(`activity:refresh.transcriptBinds`),warn:L}),T.length>0&&(0,h.jsxs)(`div`,{className:`space-y-1 rounded-lg border border-border/70 bg-card/65 p-3 text-xs font-mono`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:`first:`}),` `,b(T[0])]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:`last:`}),` `,b(T[T.length-1]??T[0])]})]})]}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(l,{className:`w-5 h-5`}),s(`activity:refresh.uiWorkspace`)]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,h.jsx)(v,{label:`currentView`,value:O,mono:!0}),(0,h.jsx)(v,{label:`dockSection`,value:k??s(`activity:refresh.noneValue`),mono:!0})]}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`activity:refresh.payloadSize`,{count:M})})]}),(0,h.jsxs)(`section`,{className:`space-y-2`,children:[(0,h.jsx)(`h2`,{className:`text-lg font-semibold`,children:s(`activity:refresh.probeLog`)}),A.length===0?(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`activity:refresh.noProbes`)}):(0,h.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:A.map((e,t)=>(0,h.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.ok?(0,h.jsx)(o,{className:`w-4 h-4 text-success shrink-0`}):(0,h.jsx)(i,{className:`w-4 h-4 text-warning shrink-0`}),(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()}),(0,h.jsx)(`span`,{children:e.note})]},`${e.ts}-${t}`))})]})]})})}function _({label:e,extra:t,ok:n,warn:r}){return(0,h.jsxs)(`div`,{className:`rounded-lg border px-3 py-2 ${r?`border-warning/40 bg-warning/10 text-warning`:n?`border-success/40 bg-success/10 text-success`:`border-border bg-muted/40 text-muted-foreground`}`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs font-medium`,children:[n&&!r?(0,h.jsx)(o,{className:`h-4 w-4 shrink-0`}):(0,h.jsx)(i,{className:`h-4 w-4 shrink-0`}),(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]}),(0,h.jsx)(`div`,{className:`text-xs font-mono mt-1 break-all`,children:t})]})}function v({label:e,value:t,mono:n}){return(0,h.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-card/75 p-3 shadow-sm`,children:[(0,h.jsx)(`p`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:e}),(0,h.jsx)(`p`,{className:`mt-1 text-sm break-all `+(n?`font-mono`:`font-medium`),children:t})]})}function y(e){let t=e.title?.trim();return t?`${e.id} — "${t}" (${e.provider}/${e.model})`:`${e.id} (${e.provider}/${e.model})`}function b(e){let t=(e.content??``).trim().replace(/\s+/g,` `);return`[${e.role}] ${t.length>100?`${t.slice(0,99)}…`:t}`}export{g as RefreshDebugView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{lt as t,za as n}from"./vendor-BuarzSSb.js";import{t as r}from"./utils-B-9lSDIn.js";import{t as i}from"./button-Dcy288Mc.js";import{t as a}from"./input-fo9-BPBC.js";import{o}from"./index-DHdO0CRE.js";var s=e(n(),1),c=t(),l=[`feature`,`bug_fix`,`refactor`,`performance`,`security`,`ui_change`,`api_change`,`infrastructure`,`migration`,`testing`,`documentation`,`maintenance`,`other`,`unspecified`],u=[`unspecified`,`low`,`medium`,`high`,`critical`],d={draft:`bg-muted text-muted-foreground`,collecting_information:`bg-amber-500/15 text-amber-700 dark:text-amber-300`,submitted:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,cancelled:`bg-destructive/15 text-destructive`,archived:`bg-muted text-muted-foreground`};function f(e){let t=Date.now()-e;if(t<6e4)return`just now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function p(){let[e,t]=(0,s.useState)(null),[n,p]=(0,s.useState)([]),[m,h]=(0,s.useState)(!0),[g,_]=(0,s.useState)(null),[v,y]=(0,s.useState)(``),[b,x]=(0,s.useState)(``),[S,C]=(0,s.useState)(`unspecified`),[w,T]=(0,s.useState)(`unspecified`),[E,D]=(0,s.useState)(!1),[O,k]=(0,s.useState)(null),[A,j]=(0,s.useState)(null),M=(0,s.useCallback)(async()=>{h(!0),_(null);try{let e=await fetch(`/api/requirement-intakes`);if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error?.message??`List failed (HTTP ${e.status})`)}let n=await e.json();t(n.projectId),p(n.intakes)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}},[]);(0,s.useEffect)(()=>{M()},[M]);let N=(0,s.useCallback)(async()=>{let t=v.trim();if(!t){k(`Describe the request first — it is preserved verbatim.`);return}if(!e){k(`No project identity available yet.`);return}D(!0),k(null),j(null);try{let n=await fetch(`/api/projects/${encodeURIComponent(e)}/requirement-intakes`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({originalRequest:t,...b.trim()?{title:b.trim()}:{},...S===`unspecified`?{}:{requestType:S},...w===`unspecified`?{}:{priority:w}})}),r=await n.json().catch(()=>null);if(!n.ok||!r?.record)throw Error(r?.error?.message??`Create failed (HTTP ${n.status})`);let i=await fetch(`/api/requirement-intakes/${r.record.id}/submit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!i.ok){let e=await i.json().catch(()=>null);throw Error(e?.error?.message??`Submit failed (HTTP ${i.status})`)}j(`Intake recorded and submitted (${r.record.id}).`),y(``),x(``),C(`unspecified`),T(`unspecified`),await M()}catch(e){k(e instanceof Error?e.message:String(e))}finally{D(!1)}},[v,b,S,w,e,M]);return(0,c.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[(0,c.jsxs)(`header`,{className:`border-b border-border/70 px-5 py-3`,children:[(0,c.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Requirements Intake`}),(0,c.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:`Collect and preserve software development requests as structured intake records`})]}),(0,c.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[g?(0,c.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[g,(0,c.jsx)(`button`,{type:`button`,className:`ml-2 underline underline-offset-2`,onClick:()=>void M(),children:`Retry`})]}):null,(0,c.jsxs)(`section`,{"aria-label":`File a new intake`,className:`mb-6 rounded-lg border border-border/70 bg-card/60 p-4`,children:[(0,c.jsx)(`div`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`File a new request`}),(0,c.jsxs)(`div`,{className:`space-y-3`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsxs)(`label`,{htmlFor:`intake-request`,className:`mb-1 block text-xs text-foreground`,children:[`Request text `,(0,c.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,c.jsx)(`textarea`,{id:`intake-request`,value:v,onChange:e=>y(e.target.value),placeholder:`Describe the feature, bug fix, refactor, or change…`,rows:4,className:r(`w-full resize-y rounded-md border border-border/70 bg-background px-3 py-2`,`text-sm text-foreground placeholder:text-muted-foreground/70`,`focus:outline-none focus:ring-2 focus:ring-ring`)}),(0,c.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`Stored verbatim as the record's original request — never rewritten.`})]}),(0,c.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`label`,{htmlFor:`intake-title`,className:`mb-1 block text-xs text-foreground`,children:`Title (optional)`}),(0,c.jsx)(a,{id:`intake-title`,value:b,onChange:e=>x(e.target.value),placeholder:`Short display title`})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`label`,{htmlFor:`intake-type`,className:`mb-1 block text-xs text-foreground`,children:`Type`}),(0,c.jsx)(`select`,{id:`intake-type`,value:S,onChange:e=>C(e.target.value),className:r(`w-full rounded-md border border-border/70 bg-background px-2 py-2`,`text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring`),children:l.map(e=>(0,c.jsx)(`option`,{value:e,children:e},e))})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`label`,{htmlFor:`intake-priority`,className:`mb-1 block text-xs text-foreground`,children:`Priority`}),(0,c.jsx)(`select`,{id:`intake-priority`,value:w,onChange:e=>T(e.target.value),className:r(`w-full rounded-md border border-border/70 bg-background px-2 py-2`,`text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring`),children:u.map(e=>(0,c.jsx)(`option`,{value:e,children:e},e))})]})]}),O?(0,c.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:O}):null,A?(0,c.jsx)(`div`,{role:`status`,className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-700 dark:text-emerald-300`,children:A}):null,(0,c.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,c.jsx)(i,{variant:`secondary`,size:`sm`,disabled:E,onClick:()=>{y(``),k(null),j(null)},children:`Clear`}),(0,c.jsx)(i,{size:`sm`,disabled:E||!v.trim(),onClick:()=>void N(),children:E?`Filing…`:`File + submit`})]})]})]}),(0,c.jsxs)(`section`,{"aria-label":`Intake records`,className:`space-y-2`,children:[(0,c.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,c.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Records`}),(0,c.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[n.length,` total`]})]}),m?(0,c.jsx)(`div`,{className:`py-8 text-center text-xs text-muted-foreground`,children:`Loading…`}):n.length===0?(0,c.jsx)(`div`,{className:`rounded-md border border-dashed border-border/70 py-10 text-center text-xs text-muted-foreground`,children:`No intake records yet — file the first one above.`}):(0,c.jsx)(`ul`,{className:`space-y-2`,children:n.map(e=>(0,c.jsxs)(`li`,{className:`rounded-md border border-border/70 bg-card/60 p-3`,children:[(0,c.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,c.jsxs)(`div`,{className:`min-w-0`,children:[(0,c.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,title:e.title,children:e.title}),(0,c.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-muted-foreground`,children:e.id})]}),(0,c.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5`,children:[(0,c.jsx)(o,{variant:`secondary`,className:`text-[10px]`,children:e.requestType}),(0,c.jsx)(o,{className:r(`text-[10px]`,d[e.status]??`bg-muted text-muted-foreground`),children:e.status})]})]}),(0,c.jsxs)(`div`,{className:`mt-1.5 text-[11px] text-muted-foreground`,children:[e.priority,` · updated `,f(e.updatedAt)]})]},e.id))})]})]})]})}export{p as RequirementIntakeView};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MemoryManager-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MemoryManager-B7620q_K.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/ui-store-BsBnjO3w.js","assets/useWebSocket-Bc4S0N4r.js","assets/chat-store-CtOyUCdF.js","assets/utils-B-9lSDIn.js","assets/i18n-B0hsnanh.js","assets/activity-BQ0zqkw2.js","assets/chat-DLn1hY01.js","assets/commandPalette-DpaemFux.js","assets/common-BfVFjVhf.js","assets/settings-BHtFy8EG.js","assets/setup-BFcmn89w.js","assets/toasts-BL_8kH4B.js","assets/ws-client-DqFoX4jJ.js","assets/session-store-b2KGFwkX.js","assets/codemap-activity-store-DQfjo7-j.js","assets/stores-BptlyD_v.js","assets/mailbox-store-D8TvJsuk.js","assets/view-navigation-DxfiZrXS.js","assets/codemap-index-store-COStDU-8.js","assets/Toaster-CJI70aa-.js","assets/dialog-ftgTihmF.js","assets/button-Dcy288Mc.js","assets/input-fo9-BPBC.js","assets/index-DHdO0CRE.js","assets/ModelPicker-DvNLZzkm.js","assets/index-DKrFQ76m.css","assets/roster-ws-Dfg_187V.js","assets/shared-KAzksK0C.js","assets/AudienceMemoryPanel-Cc1UkbDl.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{bt as t,lr as n,lt as r,za as i}from"./vendor-BuarzSSb.js";import{s as a}from"./monaco-BLUV5g0U.js";import{t as o}from"./utils-B-9lSDIn.js";import{D as s,E as c,O as l,T as u}from"./index-DHdO0CRE.js";var d=e(i(),1),f=r(),p=(0,d.lazy)(()=>a(()=>import(`./MemoryManager-B7620q_K.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]))),m=(0,d.lazy)(()=>a(()=>import(`./AudienceMemoryPanel-Cc1UkbDl.js`).then(e=>({default:e.AudienceMemoryPanel})),__vite__mapDeps([35,1,2,3,4,5,6,8,9,10,11,7,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34])));function h({label:e}){return(0,f.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,f.jsxs)(`span`,{className:`font-mono uppercase tracking-wide`,children:[e,`…`]})})}var g=[{value:`all`,label:`All memories`,hint:`Inspect, curate, retire`,Icon:n},{value:`audience`,label:`Audience-scoped`,hint:`Guidance routed to agents`,Icon:t}];function _({defaultValue:e=`all`}={}){return(0,f.jsxs)(u,{defaultValue:e,className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:[(0,f.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,f.jsx)(s,{"aria-label":`SAGE memory lenses`,className:`h-9 bg-muted/40 p-1 shadow-none`,children:g.map(({value:e,label:t,hint:n,Icon:r})=>(0,f.jsxs)(l,{value:e,className:o(`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,f.jsx)(r,{className:`size-3.5`}),(0,f.jsx)(`span`,{children:t}),(0,f.jsx)(`span`,{className:`hidden font-mono text-[9px] font-normal normal-case text-muted-foreground sm:inline`,children:n})]},e))})}),(0,f.jsx)(c,{value:`all`,className:`mt-0 flex-1 overflow-hidden ring-offset-0 focus-visible:ring-0`,children:(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(h,{label:`Loading SAGE`}),children:(0,f.jsx)(p,{})})}),(0,f.jsx)(c,{value:`audience`,className:`mt-0 flex-1 overflow-hidden ring-offset-0 focus-visible:ring-0`,children:(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(h,{label:`Loading audience memories`}),children:(0,f.jsx)(m,{})})})]})}export{_ as SageTabs};
|
|
@@ -0,0 +1,2 @@
|
|
|
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-B0hsnanh.js";import{n as I}from"./ui-store-BsBnjO3w.js";import{t as ie}from"./useWebSocket-Bc4S0N4r.js";import{t as L}from"./utils-B-9lSDIn.js";import{c as R,f as ae,s as z}from"./stores-BptlyD_v.js";import{o as B}from"./view-navigation-DxfiZrXS.js";import{a as V,i as H,n as U,o as W,r as G,t as K}from"./dialog-ftgTihmF.js";import{t as q}from"./button-Dcy288Mc.js";import{n as oe,t as se}from"./ModelPicker-DvNLZzkm.js";import{c as ce,s as le}from"./index-DHdO0CRE.js";import{a as J,c as ue,i as Y,l as X,n as de,o as fe,r as pe,s as me,t as he,u as ge}from"./progress-ring-61A-xUEl.js";import{SpecsView as _e}from"./SpecsView-Fm7pYYcj.js";var Z=e(P(),1),Q=k();function ve({feed:e,now:t}){let{t:n}=m();return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.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,Q.jsx)(f,{className:`h-3.5 w-3.5 text-warning`}),n(`activity:sdd.activityHeading`)]}),(0,Q.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,Q.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=Y[e.kind]??Y.started,i=r.icon;return(0,Q.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,Q.jsx)(i,{className:L(`mt-0.5 h-3.5 w-3.5 shrink-0`,r.color)}),(0,Q.jsx)(`span`,{className:`flex-1 leading-snug text-foreground`,children:e.text}),(0,Q.jsx)(`span`,{className:`shrink-0 tabular-nums text-[10px] text-muted-foreground`,children:me(e.ts,t)})]},`${e.ts}-${n}`)})})]})}function ye({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,Z.useState)(!1);(0,Z.useEffect)(()=>{e&&l(!1)},[e]);let u=n?.status===`running`||n?.status===`paused`,d=(0,Z.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.worktreeBranch&&e.add(t.worktreeBranch);return e.size},[n?.tasks]),f=(0,Z.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,Q.jsx)(K,{open:e,onOpenChange:e=>!r&&t(e),children:(0,Q.jsxs)(U,{className:`sm:max-w-lg border-destructive/50`,children:[(0,Q.jsxs)(V,{children:[(0,Q.jsxs)(W,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(E,{className:`h-5 w-5 text-destructive`}),a(`activity:sdd.destroyTitle`)]}),(0,Q.jsx)(G,{children:a(`activity:sdd.destroyDesc`)})]}),(0,Q.jsxs)(`ul`,{className:`space-y-1.5 py-1 text-sm`,children:[u&&(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:f>0?a(`activity:sdd.stopRunAgents`,{count:f}):a(`activity:sdd.stopRun`)})]}),(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:d>0?a(`activity:sdd.removeWorktreesCount`,{count:d}):a(`activity:sdd.removeWorktreesAll`)})]}),(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:a(`activity:sdd.deleteArtifacts`)})]})]}),o>0&&(0,Q.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,Q.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`mt-0.5 h-4 w-4 accent-warning`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:a(`activity:sdd.revertMerged`,{count:o})}),` `,`on `,(0,Q.jsx)(`code`,{className:`text-xs`,children:s??a(`activity:sdd.baseBranchFallback`)}),(0,Q.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:a(`activity:sdd.revertHint`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md bg-muted/50 p-2 text-xs text-muted-foreground`,children:[(0,Q.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,Q.jsxs)(H,{className:`gap-2 sm:gap-2`,children:[(0,Q.jsx)(q,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Q.jsx)(q,{size:`sm`,disabled:r,onClick:()=>i(c),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(T,{className:`mr-1 h-3.5 w-3.5 animate-spin`}),` `,a(`activity:sdd.destroying`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{className:`mr-1 h-3.5 w-3.5`}),` `,a(`activity:sdd.destroyAll`)]})})]})]})})}var be=[{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 xe({tasks:e,selectedId:t,onTaskClick:n}){let{t:r}=m(),i=(0,Z.useMemo)(()=>{let t=new Map;for(let e of be)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,Q.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 gap-3 overflow-x-auto p-4`,children:be.map(e=>{let a=i.get(e.key)??[];return(0,Q.jsxs)(`div`,{className:`flex min-h-0 w-64 shrink-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:L(`mb-2 flex items-center gap-2 border-b-2 pb-1.5`,e.accent),children:[(0,Q.jsx)(`span`,{className:L(`text-xs font-bold uppercase tracking-wide`,e.head),children:r(`activity:sdd.${e.labelKey}`)}),(0,Q.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-[10px] text-muted-foreground`,children:a.length})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain pr-1`,children:[a.map(e=>(0,Q.jsx)(Se,{task:e,selected:e.id===t,onClick:()=>n(e.id)},e.id)),a.length===0&&(0,Q.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 Se({task:e,selected:n,onClick:r}){let i=e.displayStatus===`in_progress`;return(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[i&&(0,Q.jsx)(T,{className:`h-3 w-3 animate-spin text-warning`}),e.displayStatus===`completed`&&(0,Q.jsx)(t,{className:`h-3 w-3 text-success`}),e.displayStatus===`failed`&&(0,Q.jsx)(S,{className:`h-3 w-3 text-destructive`}),(0,Q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.shortId}),(0,Q.jsx)(`span`,{className:L(`ml-auto rounded px-1.5 text-[9px] font-bold uppercase`,X(e.priority).chip),children:e.priority})]}),(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-snug text-foreground`,children:e.title}),(e.agentName||e.worktreeBranch||e.retries)&&(0,Q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[e.agentName&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.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:fe(e.agentName)}),(0,Q.jsx)(`span`,{className:`max-w-[80px] truncate text-[10px] text-muted-foreground`,children:e.agentName})]}),e.retries?(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[9px] text-destructive`,children:[(0,Q.jsx)(A,{className:`h-2.5 w-2.5`}),e.retries]}):null,e.worktreeBranch&&(0,Q.jsx)(u,{className:`ml-auto h-2.5 w-2.5 text-muted-foreground`})]})]})}function Ce({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=ge(e.displayStatus),O=D.icon,k=e.displayStatus===`in_progress`,ne=e.displayStatus===`pending`||e.displayStatus===`blocked`||e.displayStatus===`queued`,[re,j]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(null),[ie,R]=(0,Z.useState)(!1),[ae,z]=(0,Z.useState)(``),[B,V]=(0,Z.useState)(!1),[H,U]=(0,Z.useState)(e.verificationCommand??``),W=()=>{N.trim()&&(v(e.id,N.trim()),j(!1),P(``))},G=()=>{let t=ae.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),R(!1),z(``))},K=(0,Z.useMemo)(()=>new Map(a.map(e=>[e.shortId,e])),[a]),q=(0,Z.useMemo)(()=>a.filter(t=>t.deps.includes(e.shortId)),[a,e.shortId]),oe=(0,Z.useMemo)(()=>s.filter(t=>t.taskId===e.id||t.taskShortId===e.shortId),[s,e.id,e.shortId]),ce=e.startedAt&&!e.completedAt?ue(c-e.startedAt):e.startedAt&&e.completedAt?ue(e.completedAt-e.startedAt):null;return(0,Q.jsxs)(`div`,{className:`sdd-rise flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.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,Q.jsx)(`button`,{type:`button`,onClick:p,className:`text-muted-foreground hover:text-foreground`,title:T(`activity:sddTask.backTitle`),children:(0,Q.jsx)(M,{className:`h-4 w-4`})}),(0,Q.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.shortId}),h&&(0,Q.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,Q.jsx)(o,{className:`h-4 w-4`}):(0,Q.jsx)(x,{className:`h-4 w-4`})}),(0,Q.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,Q.jsx)(O,{className:L(`h-3 w-3`,k&&`animate-spin`)}),D.label]})]}),(0,Q.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,Q.jsx)(`h3`,{className:L(`text-sm font-semibold leading-snug text-foreground`,l&&`col-span-2 text-lg`),children:e.title}),e.agentName&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/70 bg-muted/45 p-2`,children:[(0,Q.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:fe(e.agentName)}),(0,Q.jsxs)(`div`,{className:`leading-tight`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:e.agentName}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:T(k?`activity:sddTask.workingOn`:`activity:sddTask.assigned`)})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 text-[11px]`,children:[(0,Q.jsx)(Te,{label:T(`activity:sddTask.metaPriority`),children:(0,Q.jsx)(`span`,{className:L(`font-medium uppercase`,X(e.priority).text),children:e.priority})}),(0,Q.jsx)(Te,{label:T(`activity:sddTask.metaType`),children:e.type}),ce&&(0,Q.jsx)(Te,{label:e.completedAt?T(`activity:sddTask.metaDuration`):T(`activity:sddTask.metaElapsed`),children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(n,{className:`h-3 w-3 text-muted-foreground`}),ce]})}),e.retries?(0,Q.jsx)(Te,{label:T(`activity:sddTask.metaRetries`),children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-destructive`,children:[(0,Q.jsx)(A,{className:`h-3 w-3`}),e.retries]})}):null,e.worktreeBranch&&(0,Q.jsx)(Te,{label:T(`activity:sddTask.metaWorktree`),full:!0,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-foreground`,title:e.worktreeBranch,children:[(0,Q.jsx)(u,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.worktreeBranch})]})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.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,Q.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,T(`activity:sddTask.runDefault`,{model:f})]})]}),(0,Q.jsx)(se,{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,Q.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.fallbackModels.map(e=>(0,Q.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`↳ `,e]},e))})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.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,Q.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,T(`activity:sddTask.gatesCompletion`)]})]}),B?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`input`,{value:H,onChange:e=>U(e.target.value),onKeyDown:t=>{t.key===`Enter`?(b(e.id,H.trim()||void 0),V(!1)):t.key===`Escape`&&(U(e.verificationCommand??``),V(!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,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{b(e.id,H.trim()||void 0),V(!1)},className:`rounded bg-primary px-2 py-0.5 text-[10px] text-primary-foreground hover:opacity-90`,children:T(`common:action.save`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{U(e.verificationCommand??``),V(!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,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.verificationState&&(0,Q.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,Q.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,Q.jsx)(`button`,{type:`button`,onClick:()=>V(!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,Q.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,Q.jsx)(`button`,{type:`button`,onClick:()=>V(!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,Q.jsxs)(`div`,{className:L(l&&`col-span-2`),children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:T(`activity:sddTask.description`)}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap rounded-md bg-muted p-2 text-[11px] leading-relaxed text-foreground`,children:e.description})]}),(0,Q.jsx)(we,{events:oe,expanded:l}),e.deps.length>0&&(0,Q.jsx)(Ee,{title:T(`activity:sddTask.dependsOn`),shortIds:e.deps,byShort:K,onSelectTask:w}),q.length>0&&(0,Q.jsx)(Ee,{title:T(`activity:sddTask.blocks`),shortIds:q.map(e=>e.shortId),byShort:K,onSelectTask:w})]}),(0,Q.jsxs)(`div`,{className:L(`border-t border-border p-2`,l&&`px-5 py-3`),children:[re?(0,Q.jsxs)(`div`,{className:`sdd-rise flex items-center gap-1.5`,children:[(0,Q.jsx)(`input`,{value:N,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&W(),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,Q.jsx)(`button`,{type:`button`,onClick:W,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,Q.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,Q.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,Q.jsx)(S,{className:`h-3.5 w-3.5`})})]}):F?(0,Q.jsxs)(`div`,{className:`sdd-rise flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`flex-1 text-xs text-foreground`,children:T(F===`stop`?`activity:sddTask.confirmStop`:`activity:sddTask.confirmDelete`)}),(0,Q.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,Q.jsx)(t,{className:`h-3.5 w-3.5`}),` `,T(F===`stop`?`common:action.stop`:`common:action.delete`)]}),(0,Q.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,Q.jsx)(S,{className:`h-3.5 w-3.5`})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.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,Q.jsx)(A,{className:`h-3.5 w-3.5`}),` `,T(`common:action.retry`)]}),(0,Q.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,Q.jsx)(i,{className:`h-3.5 w-3.5`}),` `,T(`activity:sddTask.reassign`)]}),k&&(0,Q.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,Q.jsx)(r,{className:`h-3.5 w-3.5`}),` `,T(`common:action.stop`)]}),!k&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>R(!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,Q.jsx)(_,{className:`h-3.5 w-3.5`}),` `,T(`activity:sddTask.split`)]}),ne&&(0,Q.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,Q.jsx)(E,{className:`h-3.5 w-3.5`}),` `,T(`common:action.delete`)]})]}),ie&&(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,Q.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,htmlFor:`sdd-split-input`,children:T(`activity:sddTask.splitHint`)}),(0,Q.jsx)(`textarea`,{id:`sdd-split-input`,rows:3,value:ae,onChange:e=>z(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,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:G,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,Q.jsx)(_,{className:`h-3.5 w-3.5`}),` `,T(`activity:sddTask.splitInto`)]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{R(!1),z(``)},className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(S,{className:`h-3.5 w-3.5`})})]})]})]})]})}function we({events:e,expanded:t}){let{t:n}=m();return(0,Q.jsxs)(`section`,{className:L(`rounded-lg border border-border/70 bg-background/45`,t&&`col-span-2`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-3 py-2.5`,children:[(0,Q.jsx)(f,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`activity:sddTask.eventLog`)}),(0,Q.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[10px] text-muted-foreground`,children:e.length}),(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:n(`activity:sddTask.newestFirst`)})]}),e.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-5 text-center text-[11px] text-muted-foreground`,children:n(`activity:sddTask.noEvents`)}):(0,Q.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,Q.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,Q.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,Q.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,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.action&&(0,Q.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,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.agentName}),e.durationMs!==void 0&&(0,Q.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,Q.jsx)(`code`,{className:`mt-1 block break-all font-mono text-[10px] leading-relaxed text-foreground`,children:e.filePath}):e.detail?(0,Q.jsx)(`code`,{className:`mt-1 block break-words font-mono text-[10px] leading-relaxed text-muted-foreground`,children:e.detail}):(0,Q.jsx)(`p`,{className:`mt-1 break-words leading-relaxed text-foreground`,children:e.text})]})]},`${e.ts}-${e.kind}-${t}`)})})]})}function Te({label:e,children:t,full:n}){return(0,Q.jsxs)(`div`,{className:L(`rounded-md border border-border bg-muted/50 px-2 py-1`,n&&`col-span-2`),children:[(0,Q.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`text-foreground`,children:t})]})}function Ee({title:e,shortIds:t,byShort:n,onSelectTask:r}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>{let t=n.get(e);return(0,Q.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,Q.jsx)(`span`,{className:L(`h-1.5 w-1.5 rounded-full`,ge(t?.displayStatus??`pending`).dot)}),(0,Q.jsx)(`span`,{className:`font-mono`,children:e})]},e)})})]})}function De({onClose:e}){let{t}=m(),{client:n}=ie(),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,Z.useState)(()=>Date.now()),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`graph`),[ee,x]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{n?.send?.({type:`sdd.board.get`})},[n]);let C=i&&(i.status===`running`||i.status===`paused`);(0,Z.useEffect)(()=>{if(!C)return;let e=setInterval(()=>d(Date.now()),1e3);return d(Date.now()),()=>clearInterval(e)},[C]);let w=(0,Z.useCallback)(e=>n?.send?.(e),[n]),T=(0,Z.useRef)(null),O=(0,Z.useCallback)(e=>{T.current=null,w({type:`sdd.board.destroy`,payload:{revertMerged:e}})},[w]),k=(0,Z.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,Z.useEffect)(()=>{let e=T.current;e&&(!C||Date.now()>=e.deadline)&&O(e.revertMerged)},[C,i,O]);let M=(0,Z.useCallback)(()=>{l(null),w({type:`sdd.board.cleanup_worktrees`,payload:{}})},[w,l]),N=(0,Z.useCallback)(()=>{l(null),w({type:`sdd.board.rollback`,payload:{}})},[w,l]),P=(0,Z.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,Z.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]),z=(0,Z.useCallback)(e=>g(e),[]),B=(0,Z.useCallback)(()=>{g(null),v(!1)},[]),V=(0,Z.useCallback)(e=>w({type:`sdd.board.retry`,payload:{taskId:e}}),[w]),H=(0,Z.useCallback)(()=>w({type:`sdd.board.retry_all_failed`,payload:{}}),[w]),U=(0,Z.useCallback)((e,t)=>{let n=t.trim();n&&w({type:`sdd.board.reassign`,payload:{taskId:e,agentName:n}})},[w]),W=(0,Z.useCallback)((e,t,n)=>w({type:`sdd.board.set_task_model`,payload:{taskId:e,model:t,provider:n}}),[w]),G=(0,Z.useCallback)((e,t)=>w({type:`sdd.board.set_task_verification`,payload:{taskId:e,verificationCommand:t}}),[w]),K=(0,Z.useCallback)(e=>w({type:`sdd.board.cancel_task`,payload:{taskId:e}}),[w]),se=(0,Z.useCallback)(e=>{w({type:`sdd.board.delete_task`,payload:{taskId:e}}),g(null),v(!1)},[w]),ce=(0,Z.useCallback)((e,t)=>{w({type:`sdd.board.split_task`,payload:{taskId:e,subtasks:t}}),g(null),v(!1)},[w]),le=oe(h!==null),Y=(0,Z.useMemo)(()=>i?.tasks.find(e=>e.id===h)??null,[i?.tasks,h]),X=i?.progress,me=i?.diagnostics?.deadlockChains??[];return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsxs)(`header`,{className:`sdd-sheen shrink-0 border-b border-border px-4 pb-3 pt-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(f,{className:`h-5 w-5 text-warning`}),(0,Q.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:i?.title??t(`activity:sddBoard.titleFallback`)}),i&&(0,Q.jsx)(`span`,{className:L(`rounded-full border px-2 py-0.5 text-[11px] font-medium capitalize`,J[i.status]??J.idle),children:i.status}),i?.defaultModel&&(0,Q.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,Q.jsx)(te,{className:`h-3 w-3 text-primary`}),i.defaultModel]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&(0,Q.jsxs)(`button`,{type:`button`,title:`Open the mirrored kanban board(s) for this run (one per dependency wave)`,onClick:()=>{let e=`run:${i.runId}`,t=ae.getState().boards.filter(t=>t.tags?.includes(e)),n=t.find(e=>e.tags?.includes(`phase:wave-0`))??t[0];n&&ae.getState().setActiveBoardId(n.id),I.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,Q.jsx)(f,{className:`h-3.5 w-3.5`}),` Kanban`]}),i&&(0,Q.jsx)(`div`,{className:`flex items-center rounded-md border border-border bg-muted p-0.5 text-[11px]`,children:[`graph`,`kanban`].map(e=>(0,Q.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&&(X?.failed??0)>0&&(0,Q.jsxs)(`button`,{type:`button`,onClick:H,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,Q.jsx)(A,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.retryFailed`,{count:X?.failed??0})]}),C&&(0,Q.jsxs)(Q.Fragment,{children:[i?.status===`paused`?(0,Q.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,Q.jsx)(j,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.resume`)]}):(0,Q.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,Q.jsx)(D,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.pause`)]}),(0,Q.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,Q.jsx)(r,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.stop`)]})]}),i&&!C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.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,Q.jsx)(ne,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.cleanWorktrees`)]}),(i.mergedCommits?.length??0)>0&&(0,Q.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,Q.jsx)(a,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.rollback`,{count:i.mergedCommits?.length??0})]})]}),i&&(s?(0,Q.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,Q.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}),` `,t(C?`activity:sddBoard.stopping`:`activity:sddBoard.destroying`)]}):(0,Q.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,Q.jsx)(E,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.destroy`)]})),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Q.jsx)(S,{className:`h-4 w-4`})})]})]}),i&&X&&(0,Q.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-5`,children:[(0,Q.jsx)(he,{pct:X.percentComplete}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,Q.jsx)(Ae,{label:t(`activity:sddBoard.statDone`),value:`${X.completed}/${X.total}`,color:`text-success`}),X.inProgress>0&&(0,Q.jsx)(Ae,{label:t(`activity:sddBoard.statRunning`),value:X.inProgress,color:`text-warning`}),X.failed>0&&(0,Q.jsx)(Ae,{label:t(`activity:sddBoard.statFailed`),value:X.failed,color:`text-destructive`}),(0,Q.jsx)(Ae,{label:t(`activity:sddBoard.statWave`),value:i.wave+1,color:`text-primary`}),C&&i.startedAt>0&&(0,Q.jsx)(Ae,{label:t(`activity:sddBoard.statElapsed`),value:ue(u-i.startedAt),color:`text-foreground`})]}),(0,Q.jsx)(`div`,{className:`flex min-h-[24px] items-center gap-1.5`,children:F.length===0?(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:sddBoard.noActiveWorkers`)}):F.map((e,t)=>(0,Q.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,Q.jsx)(`span`,{className:L(`sdd-agent-live flex h-5 w-5 items-center justify-center rounded-full text-[9px] font-bold text-white`,pe[t%pe.length]),children:fe(e.name)}),(0,Q.jsx)(`span`,{className:`max-w-[90px] truncate text-[11px] text-foreground`,children:e.name})]},e.name))})]})]})]}),o&&(0,Q.jsx)(ke,{result:o,onDismiss:()=>l(null)}),me.length>0&&(0,Q.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,Q.jsx)(p,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`font-semibold`,children:t(`activity:sddBoard.deadlock`)}),me.map(e=>(0,Q.jsxs)(`div`,{className:`font-mono`,children:[e.blocked,` ← `,e.blockedBy.join(`, `)]},e.blocked))]})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:i?y===`graph`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(de,{tasks:P,columns:i.columns,onTaskClick:z}),(0,Q.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,Q.jsx)(xe,{tasks:i.tasks,selectedId:h,onTaskClick:z}):(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground`,children:[(0,Q.jsx)(re,{className:`h-10 w-10 text-primary/40`}),(0,Q.jsx)(`p`,{className:`text-foreground`,children:t(`activity:sddBoard.noRunTitle`)}),(0,Q.jsx)(`p`,{className:`max-w-sm text-center text-xs text-muted-foreground`,children:t(`activity:sddBoard.noRunBody`)})]})}),i&&(0,Q.jsx)(`aside`,{"data-testid":`sdd-task-panel`,"data-expanded":_&&Y?`true`:`false`,className:L(`shrink-0 border-l border-border bg-card transition-[width] duration-200 ease-out`,_&&Y?`w-[min(72rem,72vw)]`:`w-80`),children:Y?(0,Q.jsx)(Ce,{task:Y,allTasks:i.tasks,feed:i.taskEvents?.[Y.id]??i.feed??[],now:u,expanded:_,modelCandidates:le,defaultModel:i.defaultModel,onClose:B,onToggleExpanded:()=>v(e=>!e),onRetry:V,onReassign:U,onSetModel:W,onSetVerification:G,onCancel:K,onDelete:se,onSplit:ce,onSelectTask:g},Y.id):(0,Q.jsx)(ve,{feed:i.feed??[],now:u})})]}),(0,Q.jsx)(ye,{open:ee,onOpenChange:x,snapshot:i,busy:s,onConfirm:k})]})}function Oe(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 ke({result:e,onDismiss:t}){let n=!e.ok||!!e.reason;return(0,Q.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,Q.jsx)(c,{className:`mt-0.5 h-4 w-4 shrink-0`}):(0,Q.jsx)(v,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:Oe(e)}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 opacity-60 hover:opacity-100`,children:(0,Q.jsx)(S,{className:`h-3.5 w-3.5`})})]})}function Ae({label:e,value:t,color:n}){return(0,Q.jsxs)(`span`,{className:`flex items-baseline gap-1`,children:[(0,Q.jsx)(`span`,{className:L(`font-semibold tabular-nums`,n),children:t}),(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e})]})}var je={idle:`phaseStart`,questioning:`phaseInterview`,spec_review:`phaseSpecReview`,implementation:`phasePlanning`,task_review:`phaseTaskReview`,executing:`phaseRunning`,done:`phaseDone`},Me=[`questioning`,`spec_review`,`implementation`,`task_review`,`executing`];function Ne({onClose:e,onRunStarted:n}){let{t:r}=m(),{client:i}=ie(),a=z(e=>e.snapshot),o=z(e=>e.agentText),c=z(e=>e.error),l=z(e=>e.startedRunId),u=z(e=>e.setStartedRunId),[d,f]=(0,Z.useState)(``),[p,_]=(0,Z.useState)(``),[v,ee]=(0,Z.useState)(!1),[x,te]=(0,Z.useState)(!0),[E,D]=(0,Z.useState)(!0),[O,k]=(0,Z.useState)(!1),[A,ne]=(0,Z.useState)(void 0),[re,j]=(0,Z.useState)(void 0),[M,N]=(0,Z.useState)([]),[P,I]=(0,Z.useState)(4),[R,ae]=(0,Z.useState)(!0),[B,V]=(0,Z.useState)(!1),H=oe(O),U=(0,Z.useCallback)(e=>i?.send?.(e),[i]),W=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{U({type:`sdd.spec.get`})},[U]),(0,Z.useEffect)(()=>{W.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[a?.answers.length??0,o]),(0,Z.useEffect)(()=>{l&&(u(null),n?.())},[n,u,l]);let G=a?.busy??!1,K=a?.phase??`idle`,J=!!a?.sessionId,ue=!!a?.resumed,Y=a?.lastRunId;(0,Z.useEffect)(()=>{J&&ee(!1)},[J]);let fe=a?.answers[a.answers.length-1]?.question??``,pe=!!a&&(a.taskCount>0||!!a.graphId||K===`task_review`||K===`executing`),me=()=>{let e=d.trim();!e||G||v||(ee(!0),U({type:`sdd.spec.start`,payload:{goal:e}}))},he=()=>{let e=p.trim();!e||G||(U({type:`sdd.spec.message`,payload:{text:e}}),_(``))},ge=()=>!G&&U({type:`sdd.spec.approve`,payload:{}}),_e=()=>{U({type:`sdd.run.start`,payload:{parallelSlots:P,worktrees:R,planDecompose:B,...A?{model:A,provider:re}:{},...M.length?{fallbackModels:M}:{}}}),k(!1)},ve=()=>{G||U({type:`sdd.spec.discard`,payload:{}})},ye=(0,Z.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]),be=ye.length>0;return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsxs)(`header`,{className:`sdd-sheen flex shrink-0 items-center justify-between border-b border-border px-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(y,{className:`h-5 w-5 text-primary`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-lg font-semibold`,children:a?.title||r(`activity:sddWizard.titleFallback`)}),J&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r(`activity:sddWizard.${je[K]??`phaseStart`}`),K===`questioning`&&` · ${r(`activity:sddWizard.questionsSuffix`,{cur:a?.questionCount??0,max:a?.maxQuestions??0})}`,a&&a.taskCount>0?` · ${r(`activity:sddWizard.tasksSuffix`,{count:a.taskCount})}`:``]})]}),G&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-muted-foreground`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Y&&(0,Q.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,Q.jsx)(C,{className:`h-3.5 w-3.5`}),` `,r(`activity:sddWizard.openLiveBoard`)]}),J&&(0,Q.jsx)(`button`,{type:`button`,onClick:ve,disabled:G,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`)}),pe&&(0,Q.jsxs)(`div`,{className:`relative flex items-center gap-1.5`,children:[(0,Q.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||B?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-muted text-muted-foreground hover:text-foreground`),children:[(0,Q.jsx)(s,{className:`h-3.5 w-3.5`}),A||r(`activity:sddWizard.modelsLabel`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:_e,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,Q.jsx)(C,{className:`h-3.5 w-3.5`}),` `,r(`activity:sddWizard.startRun`)]}),O&&(0,Q.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,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.defaultWorkerModel`)}),(0,Q.jsx)(se,{value:A,provider:re,candidates:H,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,Q.jsx)(`div`,{className:`mb-1 mt-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.fallbackChain`)}),(0,Q.jsx)(le,{value:M,candidates:H,onChange:N}),(0,Q.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:r(`activity:sddWizard.appliesToAll`)}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`sdd-slots`,className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.parallelAgents`)}),(0,Q.jsx)(`input`,{id:`sdd-slots`,type:`number`,min:1,max:16,value:P,onChange:e=>{let t=Number.parseInt(e.target.value,10);I(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,Q.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.isolateWorktrees`)}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:R,onChange:e=>ae(e.target.checked),className:`h-3.5 w-3.5 accent-primary`})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:r(R?`activity:sddWizard.worktreeOn`:`activity:sddWizard.worktreeOff`)}),(0,Q.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.planDecompose`)}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:B,onChange:e=>V(e.target.checked),className:`h-3.5 w-3.5 accent-primary`})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:r(B?`activity:sddWizard.planDecomposeOn`:`activity:sddWizard.planDecomposeOff`)})]})]}),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Q.jsx)(S,{className:`h-4 w-4`})})]})]}),J&&(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b bg-card/50 px-4 py-1.5 text-[11px]`,children:Me.map((e,n)=>{let i=e===K,a=Me.indexOf(K)>n;return(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.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,Q.jsx)(t,{className:`mr-0.5 inline h-3 w-3`}),r(`activity:sddWizard.${je[e]}`)]}),n<Me.length-1&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/65`,children:`→`})]},e)})}),(0,Q.jsxs)(`div`,{ref:ce(`sdd-wizard`),className:`min-h-0 flex-1 overflow-auto overscroll-contain p-4`,children:[c&&(0,Q.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/5 p-2 text-xs text-destructive`,children:c}),ue&&J&&(0,Q.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`)}),J?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[be&&(0,Q.jsxs)(`div`,{className:`sdd-rise overflow-hidden rounded-lg border border-primary/20 bg-[hsl(var(--surface-2)/0.85)]`,children:[(0,Q.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,Q.jsx)(g,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(b,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(F,{className:`h-3.5 w-3.5`}),r(`activity:sddWizard.taskGraphSummary`,{count:a?.taskCount??0}),(0,Q.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:r(x?`activity:sddWizard.dragToExplore`:`activity:sddWizard.show`)})]}),x&&(0,Q.jsx)(`div`,{className:`h-[32dvh] min-h-[200px]`,children:(0,Q.jsx)(de,{tasks:ye,columns:a?.board?.columns??[]})})]}),(0,Q.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-3`,children:[a?.goal&&(0,Q.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(h,{className:`h-3 w-3`}),` `,r(`activity:sddWizard.goalLabel`)]}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:a.goal})]}),a?.answers.length||o&&K===`questioning`||G?(0,Q.jsxs)(`div`,{className:`space-y-2.5`,children:[a?.answers.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Q.jsx)(Fe,{speaker:`assistant`,text:e.question}),(0,Q.jsx)(Fe,{speaker:`user`,text:e.answer})]},e.question.slice(0,64))),o&&K===`questioning`&&o!==fe&&(0,Q.jsx)(Fe,{speaker:`assistant`,text:o}),G&&(0,Q.jsx)(Fe,{speaker:`assistant`,text:``,thinking:!0})]}):null,a?.spec&&(0,Q.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card p-3`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-semibold`,children:[(0,Q.jsx)(y,{className:`h-3.5 w-3.5 text-primary`}),a.spec.title]}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:a.spec.overview}),(0,Q.jsx)(`ul`,{className:`space-y-0.5 text-xs`,children:a.spec.requirements.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(`span`,{className:L(`shrink-0 font-mono uppercase`,X(e.priority).text),children:e.priority[0]}),(0,Q.jsx)(`span`,{children:e.description})]},`${e.priority}-${e.description.slice(0,32)}`))})]}),o&&(K===`implementation`||K===`task_review`)&&(0,Q.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card`,children:[(0,Q.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,Q.jsx)(g,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(b,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(y,{className:`h-3.5 w-3.5 text-primary`}),` `,r(`activity:sddWizard.implementationPlan`)]}),E&&(0,Q.jsx)(`div`,{className:`max-h-[40dvh] overflow-auto px-3 py-2`,children:(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:Pe(o)})})]}),o&&K!==`questioning`&&K!==`implementation`&&K!==`task_review`&&!a?.spec&&(0,Q.jsx)(Fe,{speaker:`assistant`,text:o}),(K===`spec_review`||K===`implementation`||K===`task_review`)&&(0,Q.jsxs)(q,{variant:`secondary`,onClick:ge,disabled:G,children:[(0,Q.jsx)(t,{className:`mr-1.5 h-4 w-4`}),r(K===`spec_review`?`activity:sddWizard.approveSpec`:K===`task_review`?`activity:sddWizard.approveTasks`:`activity:sddWizard.approvePlan`)]}),(0,Q.jsx)(`div`,{ref:W})]})]}):(0,Q.jsxs)(`div`,{className:`mx-auto mt-8 max-w-xl`,children:[(0,Q.jsx)(`label`,{className:`mb-2 block text-sm font-medium`,htmlFor:`sdd-goal`,children:r(`activity:sddWizard.goalPrompt`)}),(0,Q.jsx)(`textarea`,{id:`sdd-goal`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&me()},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,Q.jsx)(q,{className:`mt-3`,onClick:me,disabled:!d.trim()||v,children:v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(T,{className:`mr-1.5 h-4 w-4 animate-spin`}),` `,r(`activity:sddWizard.startingInterview`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(y,{className:`mr-1.5 h-4 w-4`}),` `,r(`activity:sddWizard.startInterview`)]})}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:r(`activity:sddWizard.introBody`)})]})]}),J&&K!==`executing`&&K!==`done`&&(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-end gap-2 border-t bg-card px-4 py-2`,children:[(0,Q.jsx)(`textarea`,{value:p,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),he())},rows:1,placeholder:r(K===`questioning`?`activity:sddWizard.answerPlaceholder`:`activity:sddWizard.changePlaceholder`),disabled:G,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,Q.jsx)(q,{size:`icon`,onClick:he,disabled:G||!p.trim(),children:(0,Q.jsx)(w,{className:`h-4 w-4`})})]})]})}function Pe(e){let t=e.replace(/```json[\s\S]*?```/gi,``).trim();return t.length>0?t:e.trim()}function Fe({speaker:e,text:t,live:n,thinking:r}){let i=e===`user`;return(0,Q.jsxs)(`div`,{className:L(`sdd-rise flex items-start gap-2`,i&&`flex-row-reverse`),children:[(0,Q.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,Q.jsx)(N,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,Q.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,Q.jsxs)(`span`,{className:`flex items-center gap-1 py-0.5`,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-200ms]`}),(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-100ms]`}),(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground`})]}):t})]})}var $=[{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,Z.useState)(`project`),r=z(e=>e.startedRunId),i=z(e=>e.setStartedRunId),a=()=>B(`chat`),o=(0,Z.useCallback)(()=>n(`board`),[]);(0,Z.useEffect)(()=>{r&&(n(`board`),i(null))},[r,i]);let s=(e,t)=>{let r;if(e.key===`ArrowLeft`&&(r=(t-1+$.length)%$.length),e.key===`ArrowRight`&&(r=(t+1)%$.length),e.key===`Home`&&(r=0),e.key===`End`&&(r=$.length-1),r===void 0)return;e.preventDefault();let i=$[r];i&&(n(i.id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[r]?.focus())};return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,className:`flex shrink-0 items-end border-b border-border/70 bg-card px-4`,children:$.map((r,i)=>{let a=t===r.id;return(0,Q.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,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute bottom-0 left-0 right-0 h-0.5 bg-primary`})]},r.id)})}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:[(0,Q.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,Q.jsx)(Ne,{onClose:a,onRunStarted:o})}),(0,Q.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,Q.jsx)(De,{onClose:a})}),(0,Q.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,Q.jsx)(_e,{onClose:a,onRunStarted:o})})]})]})}export{Ie as SddHub};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Er as t,Ii as n,Na as r,Oa as i,Ot as a,Wi as o,Yn as s,an as c,bi as l,ft as u,ir as d,lt as f,na as p,oi as m,pn as h,xa as g,za as _}from"./vendor-BuarzSSb.js";import{n as v}from"./ui-store-BsBnjO3w.js";import{t as y}from"./useWebSocket-Bc4S0N4r.js";import{t as b}from"./ws-client-DqFoX4jJ.js";import{t as x}from"./utils-B-9lSDIn.js";import{P as S}from"./stores-BptlyD_v.js";import{i as C,n as w,r as T}from"./SessionList-BeinIC-h.js";var E=e(_(),1),D=r(e=>({payload:null,loading:!1,error:null,setPayload:t=>e({payload:t,loading:!1,error:null}),setError:t=>e({error:t,loading:!1}),setLoading:t=>e({loading:t}),clear:()=>e({payload:null,loading:!1,error:null})})),O=!1;function k(){if(O)return;let e=S.getState().wsUrl;e&&(b(e).on(`session.inspect`,e=>{let t=e.payload,n=D.getState();t?.error?n.setError(t.error):t&&n.setPayload(t)}),O=!0)}var A=f(),j={session_start:i,session_resumed:h,user_input:s,llm_request:l,llm_response:l,tool_use:u,tool_call_start:u,tool_call_end:u,tool_result:u,compaction:h,context_snapshot:t,error:n,session_end:o,message_appended:s,message_updated:s,messages_replaced:s,file_event:m,mode_changed:i,task_created:i,task_updated:i,task_completed:o,task_failed:n,agent_spawned:i,agent_stopped:i,agent_error:n,provider_retry:h,provider_error:a};function M(e){switch(e){case`error`:case`task_failed`:case`agent_error`:return`text-destructive border-destructive/30 bg-destructive/5`;case`tool_call_end`:case`tool_use`:case`tool_call_start`:return`text-primary border-primary/30 bg-primary/5`;case`file_event`:return`text-success border-success/30 bg-success/5`;case`compaction`:return`text-warning border-warning/30 bg-warning/5`;case`user_input`:return`text-foreground border-border`;default:return`text-muted-foreground border-border`}}function N(e){switch(e){case`completed`:return{label:`Completed`,cls:`border-success/30 bg-success/10 text-success`};case`error`:return{label:`Error`,cls:`border-destructive/30 bg-destructive/10 text-destructive`};case`timeout`:return{label:`Timed out`,cls:`border-warning/30 bg-warning/10 text-warning`};case`aborted`:return{label:`Aborted`,cls:`border-muted-foreground/30 bg-muted text-muted-foreground`};default:return{label:`Unknown`,cls:`border-border bg-muted text-muted-foreground`}}}var P={create:`Created`,read:`Read`,update:`Modified`,delete:`Deleted`,rename:`Renamed`};function F(){let e=v(e=>e.inspectSessionId),n=v(e=>e.clearInspectSession),{inspectSession:r}=y(),o=S(e=>e.wsConnected),{payload:f,loading:_,error:b,clear:O}=D(),[F,L]=(0,E.useState)(``),[R,z]=(0,E.useState)(!1);(0,E.useEffect)(()=>{k()},[]),(0,E.useEffect)(()=>{e&&(D.getState().setLoading(!0),r(e))},[e,r]),(0,E.useEffect)(()=>()=>O(),[O]);let B=(0,E.useCallback)(()=>{n()},[n]),V=(0,E.useCallback)(()=>{e&&(D.getState().setLoading(!0),r(e))},[e,r]),H=(0,E.useMemo)(()=>F?f?.events.filter(e=>e.label.toLowerCase().includes(F.toLowerCase())||e.type.toLowerCase().includes(F.toLowerCase()))??[]:f?.events??[],[f,F]),U=(0,E.useMemo)(()=>f?Object.entries(f.toolBreakdown).sort(([,e],[,t])=>t-e):[],[f]);if(_)return(0,A.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)]`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-4 border border-border/60 bg-card text-sm text-muted-foreground`,children:[(0,A.jsx)(d,{className:`h-5 w-5 animate-spin text-primary`}),`Loading session inspection…`]})});if(b)return(0,A.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col items-center justify-center gap-3 bg-[hsl(var(--surface-2)/0.45)] p-6`,children:[(0,A.jsx)(a,{className:`h-8 w-8 text-destructive`}),(0,A.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:b}),(0,A.jsxs)(`button`,{type:`button`,onClick:B,className:`mt-2 inline-flex items-center gap-1.5 border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-muted`,children:[(0,A.jsx)(g,{className:`h-3.5 w-3.5`}),`Back to sessions`]})]});if(!e)return(0,A.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)]`,children:(0,A.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3 p-6 text-center`,children:[(0,A.jsx)(c,{className:`h-9 w-9 text-muted-foreground opacity-30`}),(0,A.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No session selected`}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Select a session from the Sessions dashboard or sidebar to inspect it.`})]})});if(!f)return null;let W=N(f.outcome),G=f.name||f.title||`Untitled`;return(0,A.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-[hsl(var(--surface-2)/0.45)] overflow-y-auto overscroll-contain`,children:[(0,A.jsx)(`header`,{className:`sticky top-0 z-10 shrink-0 border-b border-border/70 bg-card/90 px-4 py-3 backdrop-blur-sm`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:B,className:`mb-2 inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,A.jsx)(g,{className:`h-3.5 w-3.5`}),`Back to sessions`]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h1`,{className:`truncate text-lg font-semibold tracking-tight`,title:G,children:G}),f.outcome?(0,A.jsx)(`span`,{className:x(`inline-flex items-center border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,W.cls),children:W.label}):null]}),(0,A.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,A.jsxs)(`span`,{className:`font-mono`,children:[f.provider,`/`,f.model]}),(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,A.jsx)(p,{className:`h-3 w-3`}),T(f.startedAt)]}),(0,A.jsx)(`span`,{children:C({id:f.id,title:f.title,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,provider:f.provider,tokenTotal:f.tokenTotal,isCurrent:!1})}),(0,A.jsxs)(`span`,{className:`font-mono text-[10px]`,children:[`ID: `,f.id.slice(0,12),`…`]})]}),f.lastUserMessage?(0,A.jsxs)(`p`,{className:`mt-2 truncate text-xs text-muted-foreground`,title:f.lastUserMessage,children:[`"`,f.lastUserMessage,`"`]}):null]}),(0,A.jsxs)(`button`,{type:`button`,onClick:V,disabled:!o,className:`inline-flex h-8 items-center gap-1 border border-border/70 px-2 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground hover:bg-muted disabled:opacity-40`,title:`Refresh`,children:[(0,A.jsx)(h,{className:`h-3.5 w-3.5`}),`Refresh`]})]})}),(0,A.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl space-y-4 p-4 sm:p-6`,children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4 lg:grid-cols-7`,children:[(0,A.jsx)(I,{icon:l,label:`Tokens`,value:w(f.tokenTotal)}),(0,A.jsx)(I,{icon:s,label:`Messages`,value:w(f.messageCount)}),(0,A.jsx)(I,{icon:i,label:`Iterations`,value:w(f.iterationCount)}),(0,A.jsx)(I,{icon:u,label:`Tool calls`,value:w(f.toolCallCount),errorCount:f.toolErrorCount>0?f.toolErrorCount:void 0}),(0,A.jsx)(I,{icon:m,label:`Files`,value:w(f.fileChangeCount)}),(0,A.jsx)(I,{icon:h,label:`Compactions`,value:w(f.compactionCount)}),(0,A.jsx)(I,{icon:t,label:`Events`,value:w(f.events.length)})]}),(0,A.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1fr_20rem]`,children:[(0,A.jsxs)(`section`,{className:`min-w-0 border border-border/70 bg-card/70`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 px-4 py-2.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(t,{className:`h-4 w-4 text-primary`}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Event timeline`}),(0,A.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:[H.length,` / `,f.events.length]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(c,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(`input`,{type:`search`,value:F,onChange:e=>L(e.target.value),placeholder:`Filter events…`,className:`h-7 w-36 border border-border/60 bg-background pl-7 pr-2 text-[11px] outline-none focus:border-primary`})]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>z(!R),className:`text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground hover:text-foreground`,children:R?`Expand`:`Collapse`})]})]}),!R&&(0,A.jsx)(`div`,{className:`divide-y divide-border/60`,children:H.length===0?(0,A.jsx)(`div`,{className:`px-4 py-8 text-center text-xs text-muted-foreground`,children:`No events match the filter.`}):H.map((e,t)=>{let n=j[e.type]??i;return(0,A.jsxs)(`div`,{className:x(`grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-x-2.5 gap-y-0.5 px-3 py-2 text-xs`,M(e.type)),children:[(0,A.jsx)(n,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`div`,{className:`truncate font-medium`,children:e.label}),e.detail?(0,A.jsx)(`div`,{className:`truncate font-mono text-[10px] opacity-70`,children:e.detail}):null]}),(0,A.jsx)(`time`,{dateTime:e.ts,className:`whitespace-nowrap font-mono text-[10px] opacity-60`,children:new Date(e.ts).toLocaleTimeString()})]},`${e.ts}-${t}`)})})]}),(0,A.jsxs)(`aside`,{className:`flex flex-col gap-4`,children:[U.length>0?(0,A.jsxs)(`section`,{className:`border border-border/70 bg-card/70`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-4 py-2.5`,children:[(0,A.jsx)(u,{className:`h-4 w-4 text-primary`}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Tool breakdown`})]}),(0,A.jsx)(`div`,{className:`divide-y divide-border/60`,children:U.map(([e,t])=>(0,A.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,A.jsx)(`span`,{className:`ml-2 shrink-0 font-mono font-semibold tabular-nums`,children:t})]},e))})]}):null,f.fileEvents.length>0?(0,A.jsxs)(`section`,{className:`border border-border/70 bg-card/70`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-4 py-2.5`,children:[(0,A.jsx)(m,{className:`h-4 w-4 text-success`}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold`,children:`File changes`}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:f.fileEvents.length})]}),(0,A.jsx)(`div`,{className:`divide-y divide-border/60`,children:f.fileEvents.map((e,t)=>(0,A.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-2 px-4 py-2 text-xs`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`div`,{className:`truncate font-mono font-medium`,title:e.filePath,children:e.filePath}),(0,A.jsx)(`div`,{className:`mt-0.5 text-[10px] text-muted-foreground`,children:e.toolName})]}),(0,A.jsx)(`span`,{className:x(`shrink-0 inline-flex items-center border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,e.operation===`delete`?`border-destructive/30 bg-destructive/10 text-destructive`:e.operation===`create`?`border-success/30 bg-success/10 text-success`:`border-border bg-muted text-muted-foreground`),children:P[e.operation]??e.operation})]},`${e.filePath}-${t}`))})]}):null]})]})]})]})}function I({icon:e,label:t,value:n,errorCount:r}){return(0,A.jsxs)(`div`,{className:`border border-border/70 bg-card/70 px-3 py-2.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[(0,A.jsx)(e,{className:`h-3 w-3`}),t]}),(0,A.jsxs)(`div`,{className:`mt-1 flex items-baseline gap-1.5`,children:[(0,A.jsx)(`span`,{className:`font-mono text-lg font-semibold tabular-nums`,children:n}),r!==void 0&&r>0?(0,A.jsxs)(`span`,{className:`font-mono text-xs text-destructive`,children:[`(`,r,` err)`]}):null]})]})}export{F as SessionInspectView};
|