@wrongstack/webui 0.296.2 → 0.296.3
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-CG7hiTO5.js → AgentRosterView-Bnfjs7SR.js} +1 -1
- package/dist/assets/{AnalyticsDashboard-BQH6L1S1.js → AnalyticsDashboard-Df_4y-Kx.js} +1 -1
- package/dist/assets/{AudienceMemoryPanel-DX4uLxnp.js → AudienceMemoryPanel-BCXl0qMA.js} +1 -1
- package/dist/assets/{ChangesView-B2DsGWiA.js → ChangesView-CngAYbT4.js} +1 -1
- package/dist/assets/{ChronicleDashboard-DI6fBbLJ.js → ChronicleDashboard-BTnRluuW.js} +1 -1
- package/dist/assets/{CodeEditor-CgXWP1-I.js → CodeEditor-Bb8Oyrho.js} +1 -1
- package/dist/assets/{CronJobsPanel-ByrWTFMO.js → CronJobsPanel-CUjKpoEA.js} +1 -1
- package/dist/assets/DeadCodeScanPanel-DHsw8Nn4.js +2 -0
- package/dist/assets/{DebugDashboard-C4jNeXwd.js → DebugDashboard-CF9tnDg7.js} +1 -1
- package/dist/assets/{DesignGalleryView-DR2MqDGO.js → DesignGalleryView-DDOG2RxE.js} +1 -1
- package/dist/assets/{GoalView-BsZXe4sN.js → GoalView-CAckYUC5.js} +1 -1
- package/dist/assets/{KanbanView-CjAQz5ko.js → KanbanView-BMzDV1-z.js} +1 -1
- package/dist/assets/{LazyMarkdown-BGp00cAh.js → LazyMarkdown-CaNUh8CL.js} +1 -1
- package/dist/assets/{MailboxDetailView-D2zOtsHb.js → MailboxDetailView-DQUJsig8.js} +1 -1
- package/dist/assets/{MemoryManager-C0c6SLEn.js → MemoryManager-JTZWsb0i.js} +1 -1
- package/dist/assets/{ModelPicker-HVIA8pKx.js → ModelPicker-D5XBxW8U.js} +1 -1
- package/dist/assets/{OfficeMapPanel-DtMjwPJ2.js → OfficeMapPanel-C6S89GWN.js} +1 -1
- package/dist/assets/{ProcessMonitor-Es5rkf_W.js → ProcessMonitor-DJaaQP3Q.js} +1 -1
- package/dist/assets/{QueuePanel-BO4V720k.js → QueuePanel-DBQkV_Ka.js} +1 -1
- package/dist/assets/{RefreshDebugView-CnOMdm5p.js → RefreshDebugView-BL9PikWZ.js} +1 -1
- package/dist/assets/{SageTabs-C630-UtZ.js → SageTabs-CPyvLW73.js} +2 -2
- package/dist/assets/{SddHub-BUPmZYcI.js → SddHub-CLFzMwKX.js} +1 -1
- package/dist/assets/{SessionsDashboard-_a7mqxAP.js → SessionsDashboard-B1lpqE1X.js} +1 -1
- package/dist/assets/{SetupScreen-BiOzT5PT.js → SetupScreen-M95bQ1A6.js} +1 -1
- package/dist/assets/{SkillDetailView-BucSq6E1.js → SkillDetailView-CeA6lnQh.js} +1 -1
- package/dist/assets/{SpecsView-C4BODULT.js → SpecsView-T1qjfodF.js} +1 -1
- package/dist/assets/{TechStackView-CibHS3rz.js → TechStackView-ByuNsOIe.js} +1 -1
- package/dist/assets/{TerminalPanel-AM_WVT3e.js → TerminalPanel-yTWOVqll.js} +1 -1
- package/dist/assets/{Toaster-C6a7sphP.js → Toaster-D5WTIK_V.js} +1 -1
- package/dist/assets/{i18n-CIqbHugq.js → i18n-D-JnOQZX.js} +1 -1
- package/dist/assets/{index-Dy7C2V-G.js → index-WvJRbCoi.js} +31 -30
- package/dist/assets/{progress-ring-D8StLpFh.js → progress-ring-DZ7API6e.js} +1 -1
- package/dist/assets/{roster-ws-DOgj2SAo.js → roster-ws-CVCrt_ih.js} +1 -1
- package/dist/assets/{stores-nxVpq1NP.js → stores-hEu6z1qz.js} +1 -1
- package/dist/assets/ui-store-BI3LH2q8.js +1 -0
- package/dist/assets/{useWebSocket-DLQNx26C.js → useWebSocket-DAm5zYOB.js} +2 -2
- package/dist/assets/{view-navigation-DuOBOluC.js → view-navigation-BSA3_knE.js} +1 -1
- package/dist/assets/ws-client-eyEv8wbm.js +1 -0
- package/dist/components/ChatInput.d.ts.map +1 -1
- package/dist/components/ChatView/index.d.ts.map +1 -1
- package/dist/components/DeadCodeScanPanel/DeadCodeScanPanel.d.ts.map +1 -1
- package/dist/components/MessageBubble/ToolLedgerCard.d.ts.map +1 -1
- package/dist/components/MessageBubble/index.d.ts.map +1 -1
- package/dist/components/NextStepsBar.d.ts +9 -3
- package/dist/components/NextStepsBar.d.ts.map +1 -1
- package/dist/components/SettingsPanel/ConnectionsHealthSection.d.ts.map +1 -1
- package/dist/components/ToolResult.d.ts +8 -1
- package/dist/components/ToolResult.d.ts.map +1 -1
- package/dist/hooks/ws-handlers/chat-handlers.d.ts.map +1 -1
- package/dist/index.html +10 -10
- package/dist/index.js +3167 -2825
- package/dist/index.js.map +4 -4
- package/dist/lib/sage-block.d.ts.map +1 -1
- package/dist/lib/ws-client.d.ts +11 -1
- package/dist/lib/ws-client.d.ts.map +1 -1
- package/dist/stores/local-prefs.d.ts +1 -1
- package/dist/stores/local-prefs.d.ts.map +1 -1
- package/dist/stores/types.d.ts +9 -0
- package/dist/stores/types.d.ts.map +1 -1
- package/dist/types/client-message.d.ts +6 -0
- package/dist/types/client-message.d.ts.map +1 -1
- package/dist/types/connections.d.ts +6 -0
- package/dist/types/connections.d.ts.map +1 -1
- package/dist/types/protocol-core.d.ts +6 -0
- package/dist/types/protocol-core.d.ts.map +1 -1
- package/dist/types/server-message.d.ts +4 -1
- package/dist/types/server-message.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/assets/DeadCodeScanPanel-mREO2zoW.js +0 -2
- package/dist/assets/ui-store-CBdBem9f.js +0 -1
- package/dist/assets/ws-client-D0KuNwAk.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Ar as n,Bn as r,Ji as i,Jn as a,Ln as o,Mn as s,Nt as c,On as l,Pr as u,Qt as d,Ri as f,Rn as p,Tt as m,Ui as h,Wn as g,Xt as _,Zt as v,_ as y,_i as b,a as x,at as S,bn as C,c as w,ct as T,d as E,et as ee,f as te,ft as ne,ga as D,gi as O,h as k,hr as A,i as re,it as j,ji as ie,kr as M,l as ae,lr as oe,m as se,mi as ce,mr as le,mt as ue,o as de,oi as N,p as fe,pa as P,pi as F,r as pe,ri as me,rr as he,rt as ge,s as I,st as L,ti as R,u as _e,ua as ve,v as ye,xa as be,ya as z,zn as xe,zr as B}from"./vendor-9hC4n4Me.js";import"./i18n-CIqbHugq.js";import{s as Se}from"./ws-client-D0KuNwAk.js";import{t as V}from"./utils-DzRQUvln.js";import{t as Ce}from"./session-store-w5G2euPs.js";import{_ as we,c as H,l as Te,x as Ee}from"./stores-nxVpq1NP.js";import{r as De}from"./mailbox-store-BN2cGkN_.js";import{f as Oe}from"./markdown-L6DLSM7f.js";import{c as ke,s as Ae,t as je}from"./LazyMarkdown-BGp00cAh.js";import{C as Me,D as Ne,E as Pe,m as Fe}from"./index-Dy7C2V-G.js";var U=e(be(),1);function Ie(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Le(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function W(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function G(e,t){for(let n of t){let t=W(e[n]);if(t)return t}}function K(e,t){for(let n of t){let t=Le(e[n]);if(t!==void 0)return t}}function Re(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function ze(e){return e?e.split(/\r?\n/).length:0}function Be(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 Ve(e){let t=e.split(/\r?\n/,1)[0]?.trim()??e;return t.length>72?`${t.slice(0,69)}…`:t}function He(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 Ue(e,t){let n=(Array.isArray(e.fileTargets)?e.fileTargets:[]).flatMap(e=>{let t=Ie(e),n=G(t,[`filePath`,`file_path`,`path`]);return n?[{filePath:n,operation:W(t.operation),line:K(t,[`line`,`startLine`,`start_line`]),endLine:K(t,[`endLine`,`end_line`])}]:[]});if(n.length>0)return n;let r=G(t,[`file_path`,`filePath`,`path`,`filename`,`target_file`,`targetFile`]);return r?[{filePath:r,line:K(t,[`line`,`start_line`,`startLine`,`offset`]),endLine:K(t,[`end_line`,`endLine`])}]:[]}function We(e,t){let n=e?.line??K(t,[`line`,`start_line`,`startLine`,`offset`]),r=e?.endLine??K(t,[`end_line`,`endLine`]),i=K(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 Ge(e,t,n,r,i,a){let o=We(a,n),s=a?.filePath??G(n,[`file_path`,`filePath`,`path`,`filename`]),c=s?Re(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=G(n,[`content`,`text`,`data`]),t=K(r,[`inputLines`])??(e?ze(e):void 0);return{target:s,summary:t===void 0?`Writing file`:`${t.toLocaleString()} lines written`,lineLabel:o.label}}if(e===`edit`){let e=G(n,[`patch`,`diff`]),t=e?Be(e):null,i=G(n,[`old_string`,`oldString`,`search`]),a=G(n,[`new_string`,`newString`,`replacement`]),c=K(r,[`addedLines`]),l=K(r,[`removedLines`]),u=K(r,[`oldLines`]),d=K(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?ze(i):u??0} → ${a?ze(a):d??0} lines`:o.label?`${o.label} updated`:`Updating file`,lineLabel:o.label}}if(e===`terminal`){let e=G(n,[`command`,`cmd`,`script`,`shell`])??t;return{summary:Ve(e),target:e}}if(e===`web`){let e=G(n,[`url`,`href`,`uri`]),t=G(n,[`query`,`q`,`search`]);return{target:e??t,summary:e?`Fetched ${e}`:t?`Looked up “${t}”`:`Went online`}}if(e===`search`){let e=G(n,[`query`,`pattern`,`q`,`search`])??c;return{target:s??e,summary:e?`Searched “${e}”`:`Searching project`}}if(e===`memory`){let e=G(n,[`query`,`text`,`key`]);return{target:e,summary:e?`Recalled “${e}”`:`Checking memory`}}return{target:s,summary:c?`${t} · ${c}`:t}}function Ke(e,t){let n=W(t.name)??W(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 qe(e,t,n){return W(t.agentId)??W(t.subagentId)??(e.kind===`agent:tool`?e.source:void 0)??(e.source!==n&&e.source!==`filesystem`?e.source:void 0)??`leader`}function Je(e){return W(e.parentSessionId)??W(e.sessionId)}function Ye(e,t){return e.kind===`tool:started`||e.kind===`tool:progress`?`running`:t.ok===!1?`failed`:`succeeded`}function Xe(e){if(![`tool:started`,`tool:progress`,`tool:executed`,`agent:tool`].includes(e.kind))return null;let t=Ie(e.data),n=Ke(e,t);if(!n)return null;let r=qe(e,t,n),i=t.input,a=Ie(i),o=Ue(t,a),s=Le(t.outputLines),c=He(n),l=Ge(c,n,a,t,s,o[0]),u=W(t.id),d=Math.floor(e.timestamp/2e3),f=Ye(e,t),p=Le(t.durationMs);return{id:u?`${r}:${u}`:`${r}:${n}:${d}`,agentId:r,agentName:W(t.agentName),sessionId:Je(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:Le(t.outputBytes),outputTokens:Le(t.outputTokens),input:i,output:W(t.output),fileTargets:o,raw:e.raw??t}}function Ze(e,t,n){return e?.length?nt(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 Qe(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 $e(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=q(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(q(e.from)),c=r.get(q(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 et(e,t){return e.toLowerCase()===t.toLowerCase()}function q(e){return e?.trim().toLowerCase()??``}function tt(e,t,n){let r=new Set([t.serverId,t.mailboxId,t.name].map(q).filter(e=>e.length>0)),i=n?`@session:${q(n)}`:``,a=q(t.role),o=q(t.serverId)===`leader`||q(t.serverId).startsWith(`leader@`)||a===`lead`||a===`leader`;return e.flatMap(e=>{let t=q(e.from),n=q(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(q(e)))}]}).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,8)}function nt(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=Xe(a);if(!o||!et(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 rt(e,t,n){let r=He(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 J=ee(),it={read:v,write:B,edit:B,terminal:c,web:R,search:M,memory:p,other:F};function at(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 ot(e){return e===void 0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function st(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Y({label:e,value:t}){return(0,J.jsxs)(`div`,{className:`agent-office__detail-row`,children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsx)(`strong`,{children:t})]})}function ct({selected:e,onClose:t}){let{t:n}=D(),{call:r,agentName:i}=e,a=it[r.kind],o=st(r.input),s=st(r.output);return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${r.toolName} details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:V(`agent-office__detail-icon`,`is-${r.kind}`),children:(0,J.jsx)(a,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:n(`activity:agentOffice.toolCall`)}),(0,J.jsx)(`h2`,{children:r.toolName})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close details`,children:(0,J.jsx)(S,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,r.status===`running`&&`is-active`,r.status===`failed`&&`is-failed`)}),(0,J.jsx)(`strong`,{children:r.summary}),(0,J.jsx)(`span`,{children:r.status})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.execution`)}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.agent`),value:i}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.started`),value:new Date(r.startedAt).toLocaleTimeString()}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.duration`),value:ot(r.durationMs)}),r.sessionId&&(0,J.jsx)(Y,{label:n(`activity:agentOffice.session`),value:at(r.sessionId,28)})]}),(r.target||r.fileTargets.length>0)&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.target`)}),r.target&&(0,J.jsx)(`code`,{className:`agent-office__target-code`,children:r.target}),r.fileTargets.map((e,t)=>(0,J.jsxs)(`div`,{className:`agent-office__file-target`,children:[(0,J.jsx)(u,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:e.filePath}),(e.line||e.endLine)&&(0,J.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,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.resultSize`)}),(0,J.jsxs)(`div`,{className:`agent-office__metric-grid`,children:[r.outputLines!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r.outputLines.toLocaleString()}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.lines`)})]}),r.outputBytes!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r.outputBytes.toLocaleString()}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.bytes`)})]}),r.outputTokens!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`strong`,{children:[`≈`,r.outputTokens.toLocaleString()]}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.tokens`)})]})]})]}),o&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.input`)}),(0,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:o})})]}),s&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.outputPreview`)}),(0,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:s})})]})]})}function lt({selected:e,onClose:t}){let{t:n}=D(),{mail:i,agentName:a}=e;return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${i.subject} details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-mail`,children:(0,J.jsx)(r,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:i.direction===`incoming`?`INCOMING MAIL`:`OUTGOING MAIL`}),(0,J.jsx)(`h2`,{children:i.subject})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close mail details`,children:(0,J.jsx)(S,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,i.unread&&`is-active`)}),(0,J.jsxs)(`strong`,{children:[i.from,` → `,i.to]}),(0,J.jsx)(`span`,{children:i.type}),i.audience===`leaders`&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(g,{className:`h-3 w-3`}),` `,n(`activity:mailbox.audienceLeaders`)]})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:mailbox.messages`)}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.agent`),value:a}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.started`),value:new Date(i.timestampMs).toLocaleTimeString()}),(0,J.jsx)(Y,{label:`Priority`,value:i.priority}),(0,J.jsx)(Y,{label:`Route`,value:`${i.from} → ${i.to}`})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:i.subject}),(0,J.jsx)(`div`,{className:`agent-office__mail-body`,children:i.body})]})]})}function ut({selected:e,onClose:t}){let{t:n}=D();return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.agentName} task details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-task`,children:(0,J.jsx)(a,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:n(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`h2`,{children:e.agentName})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close task details`,children:(0,J.jsx)(S,{})})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.task`)}),e.taskId&&(0,J.jsx)(Y,{label:`ID`,value:e.taskId}),(0,J.jsx)(`div`,{className:`agent-office__task-body`,children:e.task})]})]})}function dt({selected:e,onClose:t}){let{t:n}=D(),r=e.todos.filter(e=>e.status!==`completed`).length;return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.officeLabel} briefing`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-briefing`,children:(0,J.jsx)(o,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.officeBriefing`)}),(0,J.jsx)(`h2`,{children:e.officeLabel})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close office briefing`,children:(0,J.jsx)(S,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,(e.instructionActive||r>0)&&`is-active`)}),(0,J.jsx)(`strong`,{children:e.telemetryConnected?n(`activity:agentOffice.activeTodos`):n(`activity:agentOffice.telemetryWaiting`)}),(0,J.jsx)(`span`,{children:e.telemetryConnected?r:`—`})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.leaderPrompt`)}),e.promptAt!==void 0&&(0,J.jsx)(Y,{label:n(`activity:agentOffice.promptReceived`),value:new Date(e.promptAt).toLocaleString()}),(0,J.jsx)(`div`,{className:`agent-office__task-body`,children:e.prompt??(e.telemetryConnected?n(`activity:agentOffice.noPrompt`):n(`activity:agentOffice.telemetryWaiting`))})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.todos`)}),(0,J.jsx)(`div`,{className:`agent-office__todo-detail-list`,children:e.telemetryConnected?e.todos.length>0?e.todos.map(e=>(0,J.jsxs)(`div`,{className:V(`agent-office__todo-detail`,`is-${e.status}`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.content}),(0,J.jsx)(`small`,{children:n(`activity:agentOffice.todoStatus.${e.status}`)})]})]},e.id)):(0,J.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.noActiveTodos`)}):(0,J.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.todoTelemetryWaiting`)})})]})]})}function ft({selected:e,onClose:t}){return e.kind===`tool`?(0,J.jsx)(ct,{selected:e,onClose:t}):e.kind===`mail`?(0,J.jsx)(lt,{selected:e,onClose:t}):e.kind===`task`?(0,J.jsx)(ut,{selected:e,onClose:t}):(0,J.jsx)(dt,{selected:e,onClose:t})}function pt(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 mt(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 ht(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 gt(e){if(!e)return;let t=e.split(`/`);return t[t.length-1]?.slice(0,18)}function _t(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 vt(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 yt(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 bt(e){return e===`tui`?`tui`:e===`repl`||e===`cli`?`repl`:`webui`}function xt(e){return e===`tui`?`TUI`:e===`repl`?`REPL`:`WebUI`}function St(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 Ct(e){if(e)return e.split(`/`).filter(Boolean).pop()??e}function wt(e){let t=Ct(e)??e??``;return t.length>10?`…${t.slice(-8)}`:t}function Tt(e,t){let n=Ct(t);if(n)return e.find(e=>Ct(e.sessionId)===n)}function Et(e,t){let n=St(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 Dt(e,t){return e===`cli`?`CLI`:e===`repl`?`REPL`:xt(t)}function Ot(e,t,n=[],r=new Map,i=Date.now()){let a=new Set,o=[];for(let n of e){let e=bt(n.clientType),r=Dt(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=St(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}`:wt(n.sessionId)}`,sublabel:[`session ${wt(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=Tt(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=Tt(o,e.sessionId)??l(),n=Et(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=Tt(o,t.agent.sessionId);n&&n.agents.push(Et(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 kt(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 At=new Set([`completed`,`failed`,`timeout`,`stopped`]);function jt(e){let t=(0,U.useRef)(new Map).current;return(0,U.useMemo)(()=>{let n=Date.now(),r=new Set;for(let i of e.values())if(r.add(i.id),At.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)&&!At.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 Mt=[`bot`,`cactus`,`duck`,`radio`],Nt={leader:`plum`,builder:`ocean`,researcher:`mint`,reviewer:`rose`,planner:`amber`,operator:`graphite`},Pt={leader:0,builder:1,researcher:2,reviewer:3,planner:4,operator:5},Ft={read:v,write:B,edit:B,terminal:c,web:R,search:M,memory:p,other:F},It={leader:h,builder:F,researcher:v,reviewer:f,planner:a,operator:c};function Lt(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 Rt(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:Nt[t],layout:r%4,clutter:Math.floor(r/4)%3,avatar:Pt[t],motion:Math.floor(r/31)%4,charm:Mt[Math.floor(r/47)%Mt.length]}}function zt(e,t=22){let n=e.split(`/`).filter(Boolean).pop()??e;return n.length>t?`${n.slice(0,t-1)}…`:n}function Bt(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 Vt(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 Ht(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 Ut(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 Wt(e,t,n){return n.map((n,r)=>({...rt(e.serverId,n.name,t.sessionId),id:`${e.serverId}:log:${n.at}:${r}`,kind:He(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 Gt(...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 Kt(...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 qt({kind:e,active:t}){let n=Ft[e];return(0,J.jsxs)(`span`,{className:V(`agent-office__tool-glyph`,`is-${e}`,t&&`is-active`),children:[e===`read`&&(0,J.jsx)(u,{className:`agent-office__file-underlay`,"aria-hidden":`true`}),(0,J.jsx)(n,{"aria-hidden":`true`})]})}function Jt({active:e,failed:t,role:n,variant:r,motion:i}){let a=It[n];return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(`span`,{className:`agent-office__avatar-chair`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-body`}),(0,J.jsxs)(`span`,{className:`agent-office__avatar-head`,children:[(0,J.jsx)(`span`,{className:`agent-office__avatar-hair`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-face`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-mouth`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-headset`})]}),(0,J.jsx)(`span`,{className:`agent-office__avatar-arm`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-prop`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-role-badge`,children:(0,J.jsx)(a,{})})]})}function Yt({call:e,compact:t=!1,onSelect:n}){let r=e.status===`running`;return(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__parcel`,`is-${e.kind}`,t&&`is-compact`,r&&`is-running`,e.status===`failed`&&`is-failed`),onClick:n,"aria-label":`${e.toolName}: ${e.summary}`,children:[(0,J.jsx)(qt,{kind:e.kind,active:r}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsxs)(`span`,{className:`agent-office__parcel-topline`,children:[(0,J.jsx)(`strong`,{children:e.toolName}),e.lineLabel&&(0,J.jsx)(`span`,{className:`agent-office__line-chip`,children:e.lineLabel})]}),!t&&e.target&&(0,J.jsx)(`span`,{className:`agent-office__parcel-target`,children:Bt(e.target)}),(0,J.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.summary})]}),(0,J.jsx)(`span`,{className:`agent-office__parcel-state`,"aria-hidden":`true`,children:r?(0,J.jsx)(`span`,{className:`agent-office__pulse-dot`}):e.status===`failed`?(0,J.jsx)(S,{}):(0,J.jsx)(f,{})})]})}function Xt({mail:e,compact:t=!1,onSelect:n}){let i=e.direction===`incoming`;return(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__mail-parcel`,t&&`is-compact`,i?`is-incoming`:`is-outgoing`,e.unread&&`is-unread`),onClick:n,"aria-label":`${i?`Incoming`:`Outgoing`} mail: ${e.subject}`,children:[(0,J.jsx)(`span`,{className:`agent-office__mail-icon`,children:i?(0,J.jsx)(oe,{"aria-hidden":`true`}):(0,J.jsx)(_,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsx)(`strong`,{children:i?`${e.from} →`:`→ ${e.to}`}),(0,J.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.subject})]}),(0,J.jsx)(r,{"aria-hidden":`true`})]})}function Zt({office:e,now:t}){let{t:i}=D(),{client:a,agents:o,stats:s}=e,l=a.lastHeartbeatAt?Date.parse(a.lastHeartbeatAt):NaN,u=Number.isFinite(l)&&t-l<2e4,d=Number.isFinite(l)&&!u,f=o.some(({agent:e})=>e.presenceSource===`registry`),p=u?`VERIFIED`:d?`DELAYED`:f?`REGISTRY`:`LOCAL`,m=o.some(({agent:e})=>e.recentTools!==void 0||e.activity!==void 0),g=o.some(({agent:e})=>e.toolCalls>0&&e.recentTools===void 0&&e.activity===void 0);return(0,J.jsxs)(`header`,{className:`agent-office__client-header`,children:[(0,J.jsxs)(`div`,{className:`agent-office__client-title`,children:[(0,J.jsx)(`span`,{className:`agent-office__client-icon`,children:(0,J.jsx)(h,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{className:`agent-office__client-copy`,children:[(0,J.jsx)(`strong`,{children:a.label}),(0,J.jsx)(`span`,{children:a.sublabel||a.sessionId})]}),(0,J.jsxs)(`div`,{className:`agent-office__client-presence`,children:[(0,J.jsxs)(`span`,{className:`agent-office__client-agent-count`,children:[o.length,` `,i(`activity:agentOffice.agents`)]}),(0,J.jsxs)(`span`,{className:V(`agent-office__presence-chip`,!d&&`is-live`,d&&`is-legacy`),children:[(0,J.jsx)(L,{"aria-hidden":`true`}),` `,p]}),(0,J.jsxs)(`span`,{className:`agent-office__presence-chip`,children:[(0,J.jsx)(b,{"aria-hidden":`true`}),` `,Ht(a.startedAt,t),` UP`]}),(0,J.jsxs)(`span`,{className:V(`agent-office__presence-chip`,g?`is-legacy`:m&&`is-telemetry`),children:[(0,J.jsx)(P,{"aria-hidden":`true`}),g?`RECONNECT`:m?`TOOLS LIVE`:`READY`]})]})]}),(0,J.jsxs)(`fieldset`,{className:`agent-office__client-stats`,"aria-label":`Session activity totals`,children:[(0,J.jsxs)(`span`,{title:`Unique files touched`,children:[(0,J.jsx)(n,{}),` `,(0,J.jsx)(`strong`,{children:s.files}),` FILES`]}),(0,J.jsxs)(`span`,{title:`File reads`,children:[(0,J.jsx)(v,{}),` `,(0,J.jsx)(`strong`,{children:s.reads}),` READ`]}),(0,J.jsxs)(`span`,{title:`Files written`,children:[(0,J.jsx)(B,{}),` `,(0,J.jsx)(`strong`,{children:s.writes}),` WRITE`]}),(0,J.jsxs)(`span`,{title:`Files edited`,children:[(0,J.jsx)(B,{}),` `,(0,J.jsx)(`strong`,{children:s.edits}),` EDIT`]}),(0,J.jsxs)(`span`,{className:`agent-office__client-delta`,title:`Lines added and removed`,children:[(0,J.jsxs)(`strong`,{children:[`+`,s.linesAdded]}),` / `,(0,J.jsxs)(`b`,{children:[`−`,s.linesRemoved]})]}),(0,J.jsxs)(`span`,{title:`Terminal commands`,children:[(0,J.jsx)(c,{}),` `,(0,J.jsx)(`strong`,{children:s.terminalCalls}),` TERM`]}),(0,J.jsxs)(`span`,{title:`Incoming and outgoing mail`,children:[(0,J.jsx)(r,{}),` `,(0,J.jsx)(`strong`,{children:s.incomingMail}),`↓ `,(0,J.jsx)(`strong`,{children:s.outgoingMail}),`↑`]})]})]})}function Qt({office:e,now:n,onSelect:r}){let{t:i}=D(),{client:s}=e,c=s.todos!==void 0,l=s.todos??[],u=l.filter(e=>e.status!==`completed`),d=l.length-u.length,f=!!s.activeInstruction,p=s.activeInstruction??s.latestPrompt,m=s.latestPromptAt!==void 0&&n-s.latestPromptAt<3e4,h=()=>r({kind:`briefing`,officeLabel:s.label,prompt:p,promptAt:s.latestPromptAt,instructionActive:f,telemetryConnected:c,todos:l});return(0,J.jsxs)(`section`,{className:`agent-office__briefing`,"aria-label":i(`activity:agentOffice.officeBriefing`),children:[(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__prompt-card`,f&&`is-active`,m&&`is-fresh`,!c&&`is-waiting`),onClick:h,children:[(0,J.jsx)(`span`,{className:`agent-office__briefing-icon is-prompt`,children:(0,J.jsx)(o,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__briefing-copy`,children:[(0,J.jsx)(`span`,{children:i(f?`activity:agentOffice.activeInstruction`:`activity:agentOffice.leaderPrompt`)}),(0,J.jsx)(`strong`,{children:p??i(c?`activity:agentOffice.noPrompt`:`activity:agentOffice.telemetryWaiting`)})]}),f&&(0,J.jsxs)(`span`,{className:`agent-office__instruction-live`,children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),` LIVE`]}),s.latestPromptAt!==void 0&&(0,J.jsx)(`time`,{dateTime:new Date(s.latestPromptAt).toISOString(),children:Vt(s.latestPromptAt,n)})]}),(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__todo-board`,u.length>0&&`has-active`,!c&&`is-waiting`),onClick:h,children:[(0,J.jsxs)(`span`,{className:`agent-office__todo-heading`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(a,{"aria-hidden":`true`}),` `,i(`activity:agentOffice.activeTodos`)]}),(0,J.jsx)(`strong`,{children:c?i(`activity:agentOffice.todoProgress`,{done:d,total:l.length}):i(`activity:agentOffice.syncWaiting`)})]}),(0,J.jsxs)(`span`,{className:`agent-office__todo-preview`,children:[c?u.length>0?u.slice(0,3).map(e=>(0,J.jsxs)(`span`,{className:V(`agent-office__todo-line`,`is-${e.status}`),children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:e.activeForm||e.content})]},e.id)):(0,J.jsxs)(`span`,{className:`agent-office__todo-empty`,children:[(0,J.jsx)(t,{"aria-hidden":`true`}),l.length>0?i(`activity:agentOffice.allTodosDone`):i(`activity:agentOffice.noActiveTodos`)]}):(0,J.jsxs)(`span`,{className:`agent-office__todo-empty is-waiting`,children:[(0,J.jsx)(P,{"aria-hidden":`true`}),i(`activity:agentOffice.todoTelemetryWaiting`)]}),u.length>3&&(0,J.jsx)(`span`,{className:`agent-office__todo-more`,children:i(`activity:agentOffice.moreTodos`,{count:u.length-3})})]})]})]})}function $t({active:e}){let{t}=D();return(0,J.jsxs)(`div`,{className:`agent-office__parcel agent-office__parcel--empty`,children:[(0,J.jsx)(`span`,{className:`agent-office__tool-glyph`,children:(0,J.jsx)(i,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsx)(`strong`,{children:t(e?`activity:agentOffice.thinking`:`activity:agentOffice.waiting`)}),(0,J.jsx)(`span`,{children:t(e?`activity:agentOffice.preparing`:`activity:agentOffice.deskReady`)})]})]})}function en({model:e,now:t,onSelect:n,routedMailIds:i}){let{t:o}=D(),{agent:s,client:c,current:l,display:u,history:d,mail:p}=e,m=s.status===`active`||s.status===`streaming`,h=s.status===`error`,g=p[0],_=Lt(s),v=Rt(`${c.sessionId}:${s.serverId}:${s.name}`,_),y=g&&t-g.timestampMs<3e4&&!i?.has(g.id),b=d.slice(0,6),x=b[0]?.completedAt??b[0]?.startedAt??u?.completedAt??u?.startedAt,S=l?`is-tool-${l.kind}`:void 0;return(0,J.jsxs)(`article`,{className:V(`agent-office__lane`,`is-desk-${v.palette}`,`is-layout-${v.layout}`,`is-clutter-${v.clutter}`,m&&`is-active`,h&&`is-failed`),children:[(0,J.jsxs)(`div`,{className:`agent-office__identity`,children:[(0,J.jsxs)(`div`,{className:`agent-office__identity-line`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,m&&`is-active`,h&&`is-failed`)}),(0,J.jsx)(`strong`,{title:s.name,children:s.name}),(0,J.jsxs)(`span`,{className:`agent-office__agent-verified`,title:s.presenceSource===`registry`?`Verified by live session registry`:`Verified by local fleet state`,children:[(0,J.jsx)(f,{"aria-hidden":`true`}),s.presenceSource===`registry`?`LIVE`:`LOCAL`]})]}),(0,J.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,J.jsxs)(`div`,{className:`agent-office__agent-meta`,children:[(0,J.jsx)(`span`,{children:c.branch?`⎇ ${c.branch}`:c.type.toUpperCase()}),(0,J.jsx)(`span`,{children:o(`activity:agentOffice.callsCount`,{count:s.toolCalls})}),s.model&&(0,J.jsx)(`span`,{className:`agent-office__model-chip`,title:s.model,children:zt(s.model)})]}),s.currentTask&&(0,J.jsxs)(`button`,{type:`button`,className:`agent-office__agent-task`,onClick:()=>n({kind:`task`,task:s.currentTask??``,taskId:s.taskId,agentName:s.name}),children:[(0,J.jsx)(a,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:o(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`small`,{children:s.currentTask})]})]}),!s.currentTask&&m&&(0,J.jsxs)(`div`,{className:`agent-office__agent-task is-missing`,children:[(0,J.jsx)(P,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:o(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`small`,{children:c.todos===void 0?o(`activity:agentOffice.telemetryWaiting`):o(`activity:agentOffice.taskNotReported`)})]})]}),g&&(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__identity-mail`,g.unread&&`is-unread`),onClick:()=>n({kind:`mail`,mail:g,agentName:s.name}),"aria-label":`${p.length} mail messages. Latest: ${g.subject}`,children:[(0,J.jsx)(r,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsxs)(`strong`,{children:[p.length,` MAIL`]}),(0,J.jsx)(`small`,{children:g.subject})]})]})]}),(0,J.jsxs)(`div`,{className:V(`agent-office__scene`,S),children:[(0,J.jsxs)(`div`,{className:`agent-office__window`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsxs)(`div`,{className:`agent-office__plant`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`div`,{className:`agent-office__desk-zone`,"aria-hidden":`true`,children:[(0,J.jsx)(Jt,{active:m,failed:h,role:_,variant:v.avatar,motion:v.motion}),(0,J.jsx)(`span`,{className:`agent-office__monitor`,children:u?(0,J.jsx)(qt,{kind:u.kind,active:l!==void 0}):(0,J.jsx)(F,{})}),(0,J.jsxs)(`span`,{className:`agent-office__activity-fx`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsx)(`span`,{className:`agent-office__desk`}),(0,J.jsx)(`span`,{className:`agent-office__desk-lamp`}),(0,J.jsxs)(`span`,{className:`agent-office__desk-clutter`,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`span`,{className:V(`agent-office__desk-charm`,`is-${v.charm}`),children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`span`,{className:V(`agent-office__mug`,`is-${_}`),children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),(0,J.jsx)(`b`,{"aria-hidden":`true`})]})]}),y&&(0,J.jsx)(`div`,{className:V(`agent-office__mail-flyby`,`is-${g.direction}`),children:(0,J.jsx)(Xt,{mail:g,compact:!0,onSelect:()=>n({kind:`mail`,mail:g,agentName:s.name})},g.id)}),(0,J.jsxs)(`div`,{className:V(`agent-office__conveyor`,l&&`is-moving`),children:[(0,J.jsxs)(`div`,{className:`agent-office__belt`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsx)(`div`,{className:`agent-office__current-action`,children:u?(0,J.jsx)(Yt,{call:u,onSelect:()=>n({kind:`tool`,call:u,agentName:s.name})},u.id):(0,J.jsx)($t,{active:m})})]})]}),(0,J.jsxs)(`div`,{className:`agent-office__history`,children:[(0,J.jsxs)(`div`,{className:`agent-office__history-heading`,children:[(0,J.jsx)(`span`,{children:o(`activity:agentOffice.recent`)}),x!==void 0&&(0,J.jsx)(`span`,{children:Vt(x,t)})]}),(0,J.jsx)(`div`,{className:`agent-office__history-list`,children:b.length>0?b.map(e=>(0,J.jsx)(Yt,{call:e,compact:!0,onSelect:()=>n({kind:`tool`,call:e,agentName:s.name})},`tool:${e.id}`)):(0,J.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 tn(e){return e.agent.status===`active`||e.agent.status===`streaming`||e.agent.status===`error`}function nn({agents:e,now:t,onSelect:n}){let{t:i}=D();return(0,J.jsxs)(`section`,{className:`agent-office__lounge`,"aria-label":i(`activity:agentOffice.breakRoom`),children:[(0,J.jsxs)(`header`,{className:`agent-office__lounge-heading`,children:[(0,J.jsx)(ce,{"aria-hidden":`true`}),(0,J.jsx)(`strong`,{children:i(`activity:agentOffice.breakRoom`)}),(0,J.jsx)(`span`,{children:i(`activity:agentOffice.onBreak`,{count:e.length})})]}),(0,J.jsx)(`div`,{className:`agent-office__lounge-seats`,children:e.map(e=>{let{agent:a,history:o,mail:s}=e,c=Lt(a),l=It[c],u=s.filter(e=>e.unread).length,d=o[0]?.completedAt??o[0]?.startedAt,f=s[0],p=()=>{a.currentTask?n({kind:`task`,task:a.currentTask,taskId:a.taskId,agentName:a.name}):f&&n({kind:`mail`,mail:f,agentName:a.name})},m=!!a.currentTask||!!f;return(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__lounge-seat`,`is-${c}`),onClick:p,disabled:!m,children:[(0,J.jsx)(`span`,{className:`agent-office__lounge-avatar`,children:(0,J.jsx)(l,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__lounge-copy`,children:[(0,J.jsx)(`strong`,{children:a.name}),(0,J.jsx)(`small`,{children:a.role??i(`activity:agentOffice.agent`)})]}),(0,J.jsxs)(`span`,{className:`agent-office__lounge-meta`,children:[d!==void 0&&(0,J.jsx)(`span`,{children:Vt(d,t)}),u>0&&(0,J.jsxs)(`span`,{className:`agent-office__lounge-mail`,children:[(0,J.jsx)(r,{"aria-hidden":`true`}),` `,u]})]})]},e.key)})})]})}function rn(){let{t:e}=D(),t=Te(e=>e.liveSessions),n=Te(e=>e.aggregate),a=Ee(e=>e.agents),o=De(e=>e.agents),s=De(e=>e.messages),c=Se(e=>e.toolEvents),l=Ce(e=>e.projectName),u=jt(a),[d,f]=(0,U.useState)(null),p=(0,U.useMemo)(()=>Ot(t,a,o,u.map,u.now),[t,a,o,u]),m=(0,U.useMemo)(()=>p.flatMap(e=>e.agents.map(t=>{let n=Gt(nt(c,t.serverId,e.sessionId),Ze(t.recentTools,t.serverId,e.sessionId),Wt(t,e,a.get(t.serverId)?.toolLog??[])),r=t.status===`active`||t.status===`streaming`,i=n.find(e=>e.status===`running`);!i&&r&&t.currentTool&&(i=rt(t.serverId,t.currentTool,e.sessionId));let o=i??n[0],l=n.filter(e=>e.status!==`running`).slice(0,6),u=Kt(Qe(t.recentMail),tt(s,t,e.sessionId));return{key:t.officeId,client:e,agent:t,calls:n,current:i,display:o,history:l,mail:u}})),[p,a,s,c]),g=(0,U.useMemo)(()=>p.map(e=>{let t=m.filter(t=>t.client.id===e.id);return{client:e,agents:t,stats:Ut(t)}}).filter(e=>e.agents.length>0),[p,m]),_=m.filter(({agent:e})=>e.status===`active`||e.status===`streaming`).length,v=l||t.find(e=>e.projectName)?.projectName||e(`activity:office.fleetHq`),y=Date.now();return(0,J.jsxs)(`div`,{className:`agent-office`,children:[(0,J.jsxs)(`header`,{className:`agent-office__header`,children:[(0,J.jsxs)(`div`,{className:`agent-office__title`,children:[(0,J.jsx)(`span`,{className:`agent-office__brand-mark`,children:(0,J.jsx)(h,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:e(`activity:agentOffice.liveProjectOffice`)}),(0,J.jsx)(`h1`,{children:v})]})]}),(0,J.jsxs)(`div`,{className:`agent-office__live-pill`,children:[(0,J.jsx)(`span`,{}),` LIVE`]}),(0,J.jsxs)(`div`,{className:`agent-office__summary`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(i,{}),(0,J.jsx)(`strong`,{children:m.length}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.agents`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(j,{}),(0,J.jsx)(`strong`,{children:_}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.working`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(P,{}),(0,J.jsx)(`strong`,{children:n.toolCalls.toLocaleString()}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.toolCalls`)})]})]})]}),(0,J.jsx)(`main`,{className:`agent-office__floor`,children:m.length>0?g.map(t=>{let n=t.agents.filter(tn),i=t.agents.filter(e=>!tn(e)),a=$e(n,y),o=new Set(a.map(e=>e.id));return(0,J.jsxs)(`section`,{className:`agent-office__client-office`,children:[(0,J.jsx)(Zt,{office:t,now:y}),(0,J.jsx)(Qt,{office:t,now:y,onSelect:f}),n.length>0&&(0,J.jsxs)(`div`,{className:`agent-office__column-headings`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{children:e(`activity:agentOffice.team`)}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.liveDesk`)}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.lastActions`)})]}),(0,J.jsxs)(`div`,{className:`agent-office__client-desks`,children:[n.map(e=>(0,J.jsx)(en,{model:e,now:y,onSelect:f,routedMailIds:o},e.key)),a.length>0&&(0,J.jsx)(`div`,{className:`agent-office__mail-routes`,"aria-hidden":`true`,children:a.map(e=>(0,J.jsx)(`div`,{className:`agent-office__mail-route`,style:{"--from":`${(e.fromIndex+.5)/n.length*100}%`,"--to":`${(e.toIndex+.5)/n.length*100}%`},children:(0,J.jsx)(`span`,{className:`agent-office__mail-route-parcel`,children:(0,J.jsx)(r,{"aria-hidden":`true`})})},e.id))}),n.length===0&&(0,J.jsxs)(`div`,{className:`agent-office__desks-empty`,children:[(0,J.jsx)(ce,{"aria-hidden":`true`}),e(`activity:agentOffice.desksEmpty`)]})]}),i.length>0&&(0,J.jsx)(nn,{agents:i,now:y,onSelect:f})]},t.client.id)}):(0,J.jsxs)(`div`,{className:`agent-office__empty-state`,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(L,{"aria-hidden":`true`})}),(0,J.jsx)(`h2`,{children:e(`activity:agentOffice.readyTitle`)}),(0,J.jsx)(`p`,{children:e(`activity:agentOffice.readyBody`)})]})}),(0,J.jsxs)(`footer`,{className:`agent-office__footer`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:`agent-office__status-dot is-active`}),` `,e(`activity:agentOffice.liveEvent`)]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(A,{}),` `,e(`activity:agentOffice.connectedSessions`,{count:t.length})]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(b,{}),` `,e(`activity:agentOffice.detailHint`)]})]}),d&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,className:`agent-office__detail-backdrop`,onClick:()=>f(null),"aria-label":`Close tool details`}),(0,J.jsx)(ft,{selected:d,onClose:()=>f(null)})]})]})}function an(){let{t:e}=D(),{clientCounts:t,currentSession:n,totalAgents:r,activeAgents:a,aggregate:o}=Te(ge(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents,aggregate:e.aggregate}))),c=t.tui+t.webui+t.repl,l=e=>e?.toLocaleString()??`0`;return(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsx)(P,{className:`h-3.5 w-3.5 text-success`}),(0,J.jsx)(`span`,{className:`text-[10px] font-bold uppercase text-muted-foreground`,children:e(`activity:office.sessionStats`)})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5 text-[10px]`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(ne,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.clients`)})]}),(0,J.jsxs)(`span`,{className:`font-mono text-foreground`,children:[a,` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,J.jsx)(`span`,{className:`text-success`,children:c})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 pl-4 text-[9px]`,children:[t.tui>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(m,{className:`h-2.5 w-2.5 text-success`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`TUI`}),(0,J.jsx)(`span`,{className:`font-mono text-success`,children:t.tui})]}),t.webui>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(s,{className:`h-2.5 w-2.5 text-primary`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`WebUI`}),(0,J.jsx)(`span`,{className:`font-mono text-primary`,children:t.webui})]}),t.repl>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(m,{className:`h-2.5 w-2.5 text-warning`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`REPL`}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:t.repl})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(i,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.agents`)})]}),(0,J.jsxs)(`span`,{className:`font-mono text-foreground`,children:[a,` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,J.jsx)(`span`,{className:`text-primary`,children:r})]})]}),n.model&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(N,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.model`)})]}),(0,J.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,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(j,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.mode`)})]}),(0,J.jsx)(`span`,{className:V(`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,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(le,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.toolCallsLabel`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:l(o.toolCalls)})]}),(0,J.jsxs)(`div`,{className:`mt-1.5 space-y-1 border-t border-border/70 pt-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`IN`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.input`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:l(o.tokensIn)})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`OUT`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.output`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:l(o.tokensOut)})]})]}),(0,J.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-4 border-t border-border/70 pt-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(me,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.cost`)})]}),(0,J.jsx)(`span`,{className:`font-mono font-medium text-success`,children:(e=>e==null?`$0.0000`:`$${e.toFixed(4)}`)(o.costUsd)})]})]})]})}function on({events:e,now:t}){let{t:n}=D(),r=e.slice(0,14);return(0,J.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pointer-events-none px-3 pb-3`,children:(0,J.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,J.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] uppercase text-primary`,children:[(0,J.jsx)(P,{className:`h-3 w-3`}),n(`activity:office.liveActivity`)]}),r.length===0?(0,J.jsx)(`div`,{className:`text-[11px] italic text-muted-foreground`,children:n(`activity:office.waitingActivity`)}):(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] leading-tight`,children:[(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{backgroundColor:kt(e.kind)}}),(0,J.jsx)(`span`,{className:`flex-1 truncate text-foreground`,children:e.label}),(0,J.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:r<1?n(`activity:office.now`):`${r}s`})]},e.id)})})]})})}function sn(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 cn={user:{Icon:ue,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:m,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:ie,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 ln({entry:e}){let{t}=D();return e.role===`error`?(0,J.jsx)(Pe,{text:e.text}):e.role===`tool`?(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 tool-details`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,J.jsx)(m,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{className:`font-mono`,children:e.tool??t(`activity:watch.toolFallback`)}),e.durationMs!==void 0&&(0,J.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground font-normal tabular-nums`,children:[(0,J.jsx)(O,{className:`h-3 w-3 inline mr-0.5 align-text-bottom`}),sn(e.durationMs)]})]}),e.input!==void 0&&e.input!==null&&(0,J.jsx)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:(0,J.jsx)(Me,{input:e.input})}),e.output!==void 0&&e.output!==null?(0,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:typeof e.output==`string`?(0,J.jsx)(je,{remarkPlugins:[Oe],rehypePlugins:ke,components:Ae,children:e.output}):(0,J.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,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,J.jsx)(je,{remarkPlugins:[Oe],rehypePlugins:ke,components:Ae,children:e.text})}):null,e.isError&&(0,J.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:t(`activity:watch.toolFailed`)}),e.text&&(0,J.jsx)(`pre`,{className:`mt-1 text-xs whitespace-pre-wrap text-destructive/80`,children:e.text})]})]}):(0,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,J.jsx)(je,{remarkPlugins:[Oe],rehypePlugins:ke,components:Ae,children:e.text})})}function un({entry:e,isContinuation:t=!1}){let{t:n}=D(),r=cn[e.role],i=r.Icon;return(0,J.jsxs)(`div`,{className:`group flex gap-3 animate-message msg-bubble rounded-lg transition-shadow`,children:[t?(0,J.jsx)(`div`,{className:`flex-shrink-0 w-8`}):(0,J.jsx)(`div`,{className:V(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,r.avatarBg,r.avatarColor,r.avatarRing),children:(0,J.jsx)(i,{className:`h-4 w-4`})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0 flex-1`,children:[!t&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:V(`text-xs font-medium`,r.textColor),children:e.role===`tool`&&e.tool?e.tool:n(r.labelKey)}),(0,J.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,J.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`· `,sn(e.durationMs)]})]}),(0,J.jsx)(`div`,{className:V(`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,J.jsx)(`div`,{className:V(`text-sm leading-relaxed markdown-content`,r.textColor),children:(0,J.jsx)(ln,{entry:e})})}),e.text&&e.role!==`error`&&(0,J.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,J.jsx)(Ne,{text:e.text,label:n(`common:action.copy`)})})]})]})}var dn=[`steer`,`ask`,`assign`,`note`],fn=2500;function pn({sessionId:e,limit:t=200}){let[n,r]=(0,U.useState)(null),{t:a}=D(),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(`steer`),[g,_]=(0,U.useState)(`high`),[v,y]=(0,U.useState)([]),[b,x]=(0,U.useState)(!1),S=(0,U.useRef)(null),C=(0,U.useRef)(!0),w=(0,U.useRef)(!0),T=Te(e=>e.liveSessions),E=(0,U.useMemo)(()=>T.find(t=>t.sessionId===e),[T,e]),ee=(0,U.useMemo)(()=>{let e=E;return e?`${e.status}|${e.agents.map(e=>`${e.id}:${e.status}:${e.toolCalls??0}:${e.iterations??0}`).join(`,`)}`:``},[E]),te=E?.status===`active`||(E?.agents.some(e=>e.status===`running`||e.status===`streaming`)??!1),ne=(0,U.useMemo)(()=>{if(!E)return null;let e=E.agents.find(e=>e.status===`running`||e.status===`streaming`);return e?.currentTool?`🔧 ${e.currentTool}`:e?a(`activity:sessionWatch.working`,{name:e.name??e.id}):null},[E,a]),O=(0,U.useMemo)(()=>{if(!E)return null;let e=E.agents.find(e=>e.partialText&&(e.status===`streaming`||e.status===`running`))??E.agents.find(e=>e.partialText);return e?.partialText?{label:e.id===`leader`?a(`activity:sessionWatch.claude`):e.name||e.id,text:e.partialText}:null},[E,a]),k=(0,U.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();w.current&&(r(i),s(null))}catch(e){w.current&&s(e instanceof Error?e.message:String(e))}},[e,t]),A=(0,U.useCallback)(async()=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/mailbox`);if(!t.ok)return;let n=await t.json();w.current&&Array.isArray(n.thread)&&y(n.thread)}catch{}},[e]);(0,U.useEffect)(()=>{w.current=!0,r(null),s(null),y([]),k(),A();let e=setInterval(()=>{document.hidden||(k(),A())},fn);return()=>{w.current=!1,clearInterval(e)}},[k,A]),(0,U.useEffect)(()=>{ee&&k()},[ee,k]),(0,U.useEffect)(()=>{C.current&&S.current&&(S.current.scrollTop=S.current.scrollHeight)},[n,O]);let re=()=>{let e=S.current;e&&(C.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},j=async()=>{let t=c.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:m,priority:g})});if(!n.ok)throw Error(`HTTP ${n.status}`);l(``),p(te?z.t(`activity:sessionWatch.sentRunning`):z.t(`activity:sessionWatch.sentIdle`)),A()}catch(e){p(z.t(`activity:sessionWatch.sentFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{d(!1)}}},ie=async()=>{if(!b){x(!0),p(null);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({reason:z.t(`activity:sessionWatch.interruptReason`)})});if(!t.ok)throw Error(`HTTP ${t.status}`);p(z.t(`activity:sessionWatch.interruptSent`)),A()}catch(e){p(z.t(`activity:sessionWatch.interruptFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{x(!1)}}},M=n?.entries??[];return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 shrink-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:V(`h-1.5 w-1.5 rounded-full`,te?`bg-success animate-pulse`:`bg-muted-foreground`)}),a(`activity:sessionWatch.liveStream`)]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,J.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[a(`activity:sessionWatch.events`,{count:n.total}),` · `,n.status]}),te&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>void ie(),disabled:b,title:a(`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:a(b?`activity:sessionWatch.interrupting`:`activity:sessionWatch.interrupt`)})]})]}),ne&&(0,J.jsxs)(`div`,{className:`mb-1.5 shrink-0 text-[10px] text-foreground truncate`,children:[`▶ `,ne]}),o&&(0,J.jsxs)(`div`,{className:`text-[11px] text-destructive mb-1 shrink-0`,children:[`· `,o]}),(0,J.jsxs)(`div`,{ref:S,onScroll:re,className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain space-y-1.5 pr-1`,children:[M.length===0&&!o&&(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:a(`activity:sessionWatch.loading`)}),M.map((e,t)=>(0,J.jsx)(un,{entry:e,isContinuation:t>0&&M[t-1].role===e.role},`${e.ts}-${t}`)),O&&(0,J.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,J.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,J.jsx)(i,{className:`h-4 w-4 animate-pulse`})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] min-w-0`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground px-1`,children:O.label}),(0,J.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-4 py-3 bg-card border border-border`,children:(0,J.jsxs)(`span`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:[O.text,(0,J.jsx)(`span`,{className:`animate-pulse text-primary`,children:`▋`})]})})]})]})]}),v.length>0&&(0,J.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0 max-h-28 overflow-y-auto space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:a(`activity:mailbox.messages`)}),v.slice(-6).map(e=>{let t=e.completed?a(`activity:sessionWatch.done`):e.readByLeader?a(`activity:sessionWatch.read`):a(`activity:sessionWatch.delivered`);return(0,J.jsxs)(`div`,{className:`text-[10px] leading-snug`,children:[(0,J.jsx)(`span`,{className:V(`font-semibold mr-1.5`,e.fromLeader?`text-accent`:`text-primary`),children:e.fromLeader?a(`activity:sessionWatch.agent`):a(`activity:sessionWatch.you`)}),(0,J.jsx)(`span`,{className:`text-foreground whitespace-pre-wrap break-words`,children:e.body}),!e.fromLeader&&(0,J.jsx)(`span`,{className:V(`ml-1.5 text-[9px]`,e.completed?`text-success`:e.readByLeader?`text-primary`:`text-muted-foreground`),children:t})]},e.id)})]}),(0,J.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0`,children:[(0,J.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,J.jsx)(`select`,{value:m,onChange:e=>h(e.target.value),title:a(`activity:sessionWatch.msgType.${m}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:dn.map(e=>(0,J.jsx)(`option`,{value:e,children:a(`activity:sessionWatch.msgType.${e}Label`)},e))}),(0,J.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),title:a(`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,J.jsx)(`option`,{value:`high`,children:`high`}),(0,J.jsx)(`option`,{value:`normal`,children:`normal`}),(0,J.jsx)(`option`,{value:`low`,children:`low`})]})]}),(0,J.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,J.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),j())},rows:2,placeholder:a(`activity:sessionWatch.placeholder`,{label:a(`activity:sessionWatch.msgType.${m}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,J.jsx)(`button`,{type:`button`,onClick:()=>void j(),disabled:u||!c.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?`…`:a(`activity:sessionWatch.send`)})]}),f&&(0,J.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:f}),(0,J.jsx)(`div`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:a(`activity:sessionWatch.sendHint`)})]})]})}var X={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))`},mn=.12;function hn(e){return Math.min(100,Math.max(0,e??0))}function Z({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:X.muted,active:X.success,streaming:X.primary,completed:X.primary,error:X.destructive,offline:X.muted};return(0,J.jsx)(`span`,{className:V(`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,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(I,{type:`target`,position:y.Top,style:e,isConnectable:!1}),(0,J.jsx)(I,{type:`source`,position:y.Bottom,style:e,isConnectable:!1})]})}function gn({data:e}){let{t}=D();return(0,J.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,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:e.agentCount??0}),` `,t(`activity:office.agentsSuffix`)]}),e.startedAt&&(0,J.jsx)(`span`,{children:t(`activity:office.upPrefix`,{time:ht(e.startedAt,Date.now())})})]})}function _n({data:e}){let{t}=D(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`offline`,a=e.color||X.info;return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-primary/15`:`bg-primary/10`),children:(0,J.jsx)(s,{className:`h-5 w-5`,style:{color:a}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:a},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.webuiClient`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(T,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{children:t(`activity:office.disconnected`)})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(L,{className:`h-3 w-3 text-success`}),(0,J.jsx)(`span`,{children:t(`activity:office.connected`)})]})}),n&&(0,J.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-primary/20`,children:(0,J.jsx)(`div`,{className:`h-full animate-pulse bg-primary`,style:{width:`60%`}})}),(0,J.jsx)(gn,{data:e})]})}function vn({data:e}){let{t}=D(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.color||X.success;return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-success/15`:`bg-success/10`),children:(0,J.jsx)(m,{className:`h-5 w-5`,style:{color:i}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:i},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.tuiClient`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,J.jsx)(m,{className:`h-3 w-3 text-success`}),(0,J.jsx)(`span`,{children:t(`activity:office.terminal`)})]}),(0,J.jsx)(gn,{data:e})]})}function yn({data:e}){let{t}=D(),n=e.status===`active`||e.status===`streaming`,r=e.color||X.warning;return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-warning/15`:`bg-warning/10`),children:(0,J.jsx)(m,{className:`h-5 w-5`,style:{color:r}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:r},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.repl`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-1 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsx)(gn,{data:e})]})}function bn({data:e}){let{t}=D(),n=e.status===`active`||e.status===`streaming`,r=e.color||X.primary;return(0,J.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,J.jsx)(Q,{}),(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-12 h-12 rounded-xl`,n?`bg-primary/15`:`bg-primary/10`),children:(0,J.jsx)(N,{className:`h-6 w-6`,style:{color:r}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-sm font-bold truncate`,style:{color:r},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e.sublabel||t(`activity:office.fleetSummary`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px] mb-2`,children:[(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`font-mono`,children:[(0,J.jsx)(`span`,{className:`text-success`,children:e.agentsActive||0}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,J.jsx)(`span`,{className:`text-primary`,children:e.agentsTotal||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:officeMap.agents`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsx)(`div`,{className:`font-mono text-warning`,children:(e.toolCalls||0).toLocaleString()}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.toolCallsLabel`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsx)(`div`,{className:`font-mono text-foreground`,children:pt(e.tokensIn)}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.tokensLabel`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.cost`)})]})]}),n&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-primary`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-primary`}),t(`activity:office.coordinatingFleet`)]})]})}function xn({data:e}){let{t}=D(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,a=e.status===`completed`,o=e.color||X.primary,s=hn(e.ctxPct);return(0,J.jsxs)(`div`,{className:V(`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`,a&&`border-border/70 bg-muted/35`,!n&&!r&&!a&&`border-primary/30 bg-primary/10`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,J.jsx)(i,{className:`h-4 w-4 shrink-0`,style:{color:o}}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-[11px] font-bold truncate`,style:{color:o},children:e.label}),e.model&&(0,J.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:gt(e.model)})]}),(0,J.jsx)(Z,{status:e.status,small:!0,activity:e.vizActivity??0})]}),e.currentTask&&(0,J.jsxs)(`div`,{className:`mb-1.5 flex min-w-0 items-center gap-1 overflow-hidden text-[11px] text-primary`,children:[(0,J.jsx)(`span`,{className:V(`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`,n&&`animate-pulse`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.currentTask,children:_t(e.currentTask,72)})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-0.5 text-[11px] mb-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`iter`}),(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:e.iteration||0})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tools`}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:e.toolCalls||0})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tok`}),(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:pt((e.tokensIn||0)+(e.tokensOut||0))})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`cost`}),(0,J.jsxs)(`span`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]})]})]}),s>0&&(0,J.jsxs)(`div`,{className:`mb-1`,children:[(0,J.jsxs)(`div`,{className:`mb-0.5 flex justify-between text-[10px] text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:`ctx`}),(0,J.jsxs)(`span`,{className:V(`font-mono`,s>=90?`text-destructive`:s>=70?`text-warning`:`text-muted-foreground`),children:[s,`%`]})]}),(0,J.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-muted`,children:(0,J.jsx)(`div`,{className:V(`h-full`,s>=90?`bg-destructive`:s>=70?`bg-warning`:`bg-primary`),style:{width:`${s}%`}})})]}),e.lastActivityAt&&(0,J.jsxs)(`div`,{className:V(`flex items-center gap-1 text-[10px]`,n?`text-muted-foreground/70`:`text-muted-foreground`),children:[a&&(0,J.jsx)(`span`,{className:`text-success`,children:t(`activity:office.donePrefix`)}),r&&(0,J.jsx)(`span`,{className:`text-destructive`,children:t(`activity:office.failedPrefix`)}),(0,J.jsx)(`span`,{children:t(`activity:office.seenPrefix`,{time:mt(e.lastActivityAt,Date.now())})})]})]})}function Sn({data:e}){let{t}=D();return(0,J.jsxs)(`div`,{className:V(`rounded-lg border border-dashed p-3 min-w-[120px] transition-all opacity-40`,`border-border/70 bg-muted/30`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsx)(ve,{className:`h-4 w-4 text-muted-foreground`}),(0,J.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,J.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:e.label})}),(0,J.jsx)(Z,{status:e.status,small:!0,activity:e.vizActivity??0})]}),(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:office.availableDesk`)})]})}function Cn({data:e}){let{t}=D(),n=e.color||X.warning,i=(e.unreadCount||0)>0;return(0,J.jsxs)(`div`,{className:V(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,i&&`border-warning/50 bg-warning/10 shadow-lg shadow-warning/10`,!i&&`border-warning/30 bg-warning/6`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,i?`bg-warning/18`:`bg-warning/10`),children:(0,J.jsx)(r,{className:`h-5 w-5`,style:{color:n}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold`,style:{color:n},children:t(`activity:office.mailboxHub`)}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:i?t(`activity:office.unreadSuffix`,{count:e.unreadCount||0}):t(`activity:office.allClear`)})]}),i&&(0,J.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,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-warning`,children:[(0,J.jsx)(_,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e.messageCount||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.total`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-success`,children:[(0,J.jsx)(oe,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e.unreadCount||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.unreadLabel`)})]})]}),e.sublabel&&(0,J.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,J.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,J.jsx)(`span`,{className:V(`font-mono truncate text-right`,n??`text-foreground/80`),children:t})]})}function Tn({selectedNode:e,selectedAgentTranscript:t,mailboxMessages:n,onClose:a,onOpenWatch:o}){let{t:c}=D(),l=e.data,u=Date.now(),d=l.kind===`agent`,f=l.kind===`webui`||l.kind===`tui`||l.kind===`repl`,p=(l.tokensIn||0)+(l.tokensOut||0),h=hn(l.ctxPct);return(0,J.jsxs)(`div`,{className:V(`absolute top-20 right-4 bg-background border border-border rounded-lg p-4 shadow-xl z-20`,l.kind===`agent`?`w-[28rem] max-w-[calc(100%-2rem)]`:l.sessionId?`w-80`:`w-64`),children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l.kind===`webui`&&(0,J.jsx)(s,{className:`h-4 w-4 text-info`}),l.kind===`tui`&&(0,J.jsx)(m,{className:`h-4 w-4 text-success`}),l.kind===`coordinator`&&(0,J.jsx)(N,{className:`h-4 w-4 text-primary`}),l.kind===`agent`&&(0,J.jsx)(i,{className:`h-4 w-4 text-primary`}),l.kind===`mailbox`&&(0,J.jsx)(r,{className:`h-4 w-4 text-warning`}),(0,J.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:l.label})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[l.sessionId&&(0,J.jsx)(`button`,{type:`button`,title:c(`activity:office.openFullView`),onClick:()=>o({sessionId:l.sessionId,label:l.label}),className:`text-muted-foreground hover:text-primary`,children:(0,J.jsx)(xe,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:a,className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,J.jsx)($,{k:`Status`,v:String(l.status).toUpperCase(),accent:V(l.status===`active`&&`text-success`,l.status===`streaming`&&`text-primary`,l.status===`error`&&`text-destructive`,l.status===`idle`&&`text-muted-foreground`,l.status===`offline`&&`text-muted-foreground/70`)}),d&&(0,J.jsxs)(J.Fragment,{children:[l.model&&(0,J.jsx)($,{k:`Model`,v:gt(l.model),accent:`text-primary`}),l.currentTask&&(0,J.jsxs)(`div`,{className:`pt-1`,children:[(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:c(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`div`,{className:`mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap break-words font-mono text-[10px] text-primary`,children:l.currentTask})]}),(0,J.jsx)($,{k:`Iterations`,v:l.iteration||0,accent:`text-primary`}),(0,J.jsx)($,{k:`Tool calls`,v:l.toolCalls||0,accent:`text-warning`}),(0,J.jsx)($,{k:`Tokens in`,v:pt(l.tokensIn)}),(0,J.jsx)($,{k:`Tokens out`,v:pt(l.tokensOut)}),(0,J.jsx)($,{k:`Tokens total`,v:pt(p)}),h>0&&(0,J.jsx)($,{k:`Context`,v:`${h}%`,accent:h>=90?`text-destructive`:h>=70?`text-warning`:`text-foreground/70`}),(0,J.jsx)($,{k:`Cost`,v:`$${(l.costUsd||0).toFixed(4)}`,accent:`text-success`}),l.lastActivityAt&&(0,J.jsx)($,{k:`Last seen`,v:mt(l.lastActivityAt,u),accent:`text-muted-foreground`}),(0,J.jsx)(`div`,{className:`pt-2`,children:(0,J.jsx)(Fe,{entries:t,agentName:l.label,compact:!0,maxHeightClassName:`max-h-64`})})]}),f&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Surface`,v:xt(l.kind),accent:`text-foreground/80`}),l.branch&&(0,J.jsx)($,{k:`Branch`,v:`⎇ ${l.branch}`,accent:`text-foreground/70`}),l.pid!=null&&(0,J.jsx)($,{k:`PID`,v:l.pid}),l.workingDir&&(0,J.jsx)($,{k:`Dir`,v:l.workingDir,accent:`text-muted-foreground`}),(0,J.jsx)($,{k:`Agents`,v:l.agentCount??0,accent:`text-primary`}),l.startedAt&&(0,J.jsx)($,{k:`Uptime`,v:ht(l.startedAt,u),accent:`text-foreground/70`})]}),l.kind===`mailbox`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Total messages`,v:l.messageCount||0,accent:`text-warning`}),(0,J.jsx)($,{k:`Unread`,v:l.unreadCount||0,accent:`text-warning`}),n.length>0&&(0,J.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-border pt-2`,children:[(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:c(`activity:office.recent`)}),[...n].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp)).slice(0,6).map(e=>(0,J.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px]`,children:[(0,J.jsx)(`span`,{className:V(`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,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`truncate text-foreground/80`,children:e.subject||c(`activity:office.noSubject`)}),(0,J.jsxs)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[e.from,` → `,e.to,` · `,mt(e.timestamp,u),e.audience===`leaders`?` · ${c(`activity:mailbox.audienceLeaders`)}`:``]})]})]},e.id))]})]}),l.kind===`coordinator`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Connections`,v:l.connections||0,accent:`text-primary`}),(0,J.jsx)($,{k:`Iterations`,v:l.iteration||0,accent:`text-primary`})]}),(d||f)&&l.sessionId&&(0,J.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 h-72`,children:(0,J.jsx)(pn,{sessionId:l.sessionId})})]})]})}var En={wire:({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i,targetPosition:a,data:o,selected:s})=>{let c=o?.color||X.primary,l=H(e=>e.animateEdges),u=o?.animated&&l?Math.max(.15,o?.intensity??.6):0,[d,f,p]=ye({sourceX:e,sourceY:t,sourcePosition:i??y.Bottom,targetX:n,targetY:r,targetPosition:a??y.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,J.jsxs)(J.Fragment,{children:[(0,J.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,J.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,J.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:g,to:`0`,dur:_,repeatCount:`indefinite`})}),o?.label&&u>.1&&(0,J.jsx)(de,{children:(0,J.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}=D();return(0,J.jsxs)(J.Fragment,{children:[(0,J.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,J.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendStatus`)}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-success`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendActive`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendIdle`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-destructive`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendError`)})]})]})]}),(0,J.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,J.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendConnections`)}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-warning`,children:`✉`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendMail`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-primary`,children:`→`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendTask`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-success`,children:`●`}),(0,J.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}=D();return(0,J.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,J.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold text-warning`,children:[(0,J.jsx)(_,{className:`h-3.5 w-3.5`}),` `,o(`activity:office.broadcastToAll`)]}),(0,J.jsx)(`button`,{type:`button`,onClick:r,className:`text-base leading-none text-muted-foreground hover:text-foreground`,children:`×`})]}),(0,J.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,J.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:o(`activity:office.broadcastSendHint`)}),(0,J.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,J.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,J.jsxs)(ae,{position:`top-right`,className:`flex items-center gap-2`,children:[(0,J.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,J.jsx)(he,{className:`h-3.5 w-3.5`}),t.arrange]}),(0,J.jsxs)(`button`,{type:`button`,onClick:i,title:t.feedTitle,className:V(`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,J.jsx)(d,{className:`h-3.5 w-3.5`}),t.feed]}),(0,J.jsxs)(`button`,{type:`button`,onClick:r,title:t.broadcastTitle,className:V(`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,J.jsx)(_,{className:`h-3.5 w-3.5`}),t.broadcast]})]})}function An(){return(0,J.jsx)(w,{className:`rounded-lg border border-border/70 bg-card/90`,nodeColor:e=>{switch(e.data.kind){case`coordinator`:return X.primary;case`webui`:return X.info;case`tui`:return X.success;case`repl`:case`mailbox`:return X.warning;default:return X.primary}},maskColor:`hsl(var(--background) / 0.72)`})}function jn({closeTitle:e,label:t,onClose:n,sessionId:r,streamTitle:a}){return(0,J.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,J.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5 shrink-0 bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,J.jsx)(i,{className:`h-4 w-4 text-primary shrink-0`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:t}),(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:a})]})]}),(0,J.jsx)(`button`,{type:`button`,onClick:n,title:e,className:`text-muted-foreground hover:text-foreground text-xl leading-none shrink-0`,children:`×`})]}),(0,J.jsx)(`div`,{className:`flex-1 min-h-0 p-4`,children:(0,J.jsx)(pn,{sessionId:r,limit:500})})]})}function Mn(){let{t:e}=D(),{fitView:t}=k(),n=(0,U.useRef)(null),[r,i]=(0,U.useState)({width:1280,height:720});(0,U.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=Se(e=>e.events),o=Ee(e=>e.agents),s=Ee(e=>e.agentTranscripts),c=Ee(e=>e.leaderId),l=Te(e=>e.liveSessions),u=De(e=>e.messages),d=De(e=>e.agents),f=Ce(e=>e.session),p=jt(o),m=(0,U.useMemo)(()=>Ot(l,o,d,p.map,p.now),[l,o,d,p]),g=H(e=>e.showHud),_=H(e=>e.showLegend),v=H(e=>e.showMinimap),y=H(e=>e.showControls),b=H(e=>e.showFeed),S=H(e=>e.setShowFeed),C=H(e=>e.background),[w,T,ee]=se([]),[ne,O,A]=fe([]),[j,ie]=(0,U.useState)(null),[M,ae]=(0,U.useState)(null),[oe,ce]=(0,U.useState)(!1),[le,ue]=(0,U.useState)(``),[de,N]=(0,U.useState)(!1),[P,F]=(0,U.useState)(null),me=(0,U.useMemo)(()=>{if(j?.data.kind!==`agent`)return we;let e=j.data.serverId??(j.id.includes(`__agent-`)?j.id.split(`__agent-`).pop():j.id.replace(/^agent-/,``));return e?s.get(e)??we:we},[s,j]),he=(0,U.useCallback)(async()=>{let e=le.trim();if(!(!e||de)){N(!0),F(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();ue(``),F(`Delivered to ${n.delivered??0}/${n.targets??0} session(s)`)}catch(e){F(`Failed: ${e instanceof Error?e.message:String(e)}`)}finally{N(!1)}}},[le,de]),ge=(0,U.useRef)(new Map),I=4e3,L=(0,U.useRef)(new Map),R=(0,U.useRef)(new Map),_e=(0,U.useRef)(new Map),ve=(0,U.useRef)(new Map),ye=(0,U.useRef)(``);(0,U.useEffect)(()=>{let n=[],i=[],a=Date.now(),s=vt(m.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:X.warning}});let f=0,p=0,h=0,g=0,_=0;for(let e of m)for(let t of e.agents)p+=1,(t.status===`active`||t.status===`streaming`)&&(f+=1),h+=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:m.length}),kind:`coordinator`,status:v?.status===`failed`?`error`:y?`active`:`idle`,connections:m.length,agentsActive:f,agentsTotal:p,toolCalls:h,costUsd:g,tokensIn:_,color:X.primary}});let b={tui:X.success,webui:X.info,repl:X.warning};for(let t of m){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:X.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:X.muted}});continue}t.agents.forEach((r,s)=>{let l=r.status===`active`||r.status===`streaming`,u=ve.current.get(r.serverId);if(u&&(r.toolCalls>u.toolCalls||r.iteration>u.iteration)||l){ge.current.set(r.officeId,a+I);let e=R.current.get(r.officeId)??0;R.current.set(r.officeId,Math.min(1,e+(1-e)*.5));for(let e of[`${t.id}->${r.officeId}`,`${t.id}->coordinator`]){let t=L.current.get(e)??0;L.current.set(e,Math.min(1,t+.5))}}ve.current.set(r.serverId,{toolCalls:r.toolCalls,iteration:r.iteration}),n.push({id:r.officeId,type:`agent`,position:yt(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:X.primary}}),i.push({id:`${t.id}->${r.officeId}`,source:t.id,target:r.officeId,type:`wire`,animated:l,data:{color:X.primary,animated:l,label:l?_t(r.currentTask,48)??e(`activity:office.taskFallback`):void 0,flowType:`task`}})})}let x=new Set(m.flatMap(e=>e.agents.map(e=>e.serverId)));for(let e of[...ve.current.keys()])x.has(e)||ve.current.delete(e);let S=n.map(e=>{let t=ge.current.get(e.id),n=R.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=L.current.get(e.id)??0;return t>.05?{...e,animated:!0,data:{...e.data,animated:!0,intensity:t}}:e}),w=new Map;for(let e of S)w.set(e.id,{...e.position});_e.current=w,T(S),O(C);let E=[`${Math.round(r.width)}x${Math.round(r.height)}`,`${s.columns}x${s.rows}`,m.map(e=>`${e.id}:${e.agents.length}`).join(`|`),S.map(e=>e.id).sort().join(`|`)].join(`:`);if(E!==ye.current){ye.current=E;let e=setTimeout(()=>t({padding:mn,duration:300}),50);return()=>clearTimeout(e)}},[m,c,o,u,f,r,I,T,O,t]);let be=m.flatMap(e=>e.agents.map(t=>({clientId:e.id,clientType:e.type,officeId:t.officeId,serverId:t.serverId}))),z=m.map(e=>e.id),xe=new Map;for(let e of be)(!xe.has(e.serverId)||e.clientType===`webui`)&&xe.set(e.serverId,e.officeId);function B(e){return xe.get(e)??`agent-${e}`}function V(e){let t=e.split(`__agent-`)[0];return t&&t!==e?`${t}->${e}`:`coordinator->${e}`}function Oe(e){switch(e.kind){case`mailbox:send`:case`mailbox:deliver`:return{nodes:[`mailbox`],edges:e.kind===`mailbox:send`?z.map(e=>`mailbox->${e}`):[],status:`active`};case`agent:spawned`:{let t=B(e.source);return{nodes:[`coordinator`,t],edges:[V(t)],status:`active`}}case`agent:tool`:case`tool:started`:case`tool:progress`:{let t=B(e.source);return{nodes:[`coordinator`,t],edges:[V(t)],status:e.kind===`tool:progress`||e.kind===`tool:started`?`streaming`:`active`}}case`tool:executed`:{let t=B(e.target??e.source);return{nodes:[t],edges:[V(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:be.map(e=>V(e.officeId)),status:e.kind===`iteration:start`?`streaming`:`active`};case`agent:text`:{let t=B(e.source);return{nodes:[t],edges:[V(t)],status:`streaming`}}case`agent:status`:{let t=B(e.source);return{nodes:[`coordinator`,t],edges:[V(t)],status:e.data&&typeof e.data==`object`&&`status`in e.data&&String(e.data.status)===`failed`?`error`:`completed`}}case`agent:ctx`:return{nodes:[B(e.source)],edges:[],status:`active`};case`budget:extended`:return{nodes:[`coordinator`,B(e.source)],edges:[],status:`active`};case`context:compacted`:case`context:repaired`:return{nodes:[`coordinator`],edges:[],status:`active`};case`error`:return{nodes:e.source?[B(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=B(t.id);n.includes(e)||n.push(e)}return{nodes:n,edges:[],status:`active`}}default:return{nodes:[],edges:[],status:`idle`}}}(0,U.useEffect)(()=>{if(a.length===0)return;let e=a[0];if(!e)return;let{nodes:t,edges:n,status:r}=Oe(e),i=Date.now();t.length>0&&(t.forEach(e=>{ge.current.set(e,i+I);let t=R.current.get(e)??0;R.current.set(e,Math.min(1,t+(1-t)*.5))}),T(e=>e.map(e=>t.includes(e.id)?{...e,data:{...e.data,status:r,vizActivity:R.current.get(e.id)??0}}:e))),n.length>0&&(n.forEach(e=>{let t=L.current.get(e)??0;L.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:L.current.get(e.id)??1}}:e)))},[a,T,O,I,o]),(0,U.useEffect)(()=>{let e=setInterval(()=>{let e=new Map,t=!1;for(let[n,r]of L.current){let i=r*.85;i<.05?(L.current.delete(n),e.set(n,{intensity:0,animated:!1}),t=!0):(L.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 R.current){let i=t*.9;i<.03?(R.current.delete(e),n.set(e,0),r=!0):(R.current.set(e,i),n.set(e,i),r=!0)}r&&T(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,T]);let ke=(0,U.useCallback)(e=>O(t=>E({...e,type:`wire`},t)),[O]),Ae=(0,U.useCallback)((e,t)=>{ie(t)},[]),je=(0,U.useCallback)(()=>{ie(null)},[]);(0,U.useEffect)(()=>{if(!M)return;let e=e=>{e.key===`Escape`&&ae(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[M]);let Me=(0,U.useCallback)(()=>{T(e=>e.map(e=>{let t=_e.current.get(e.id);return t?{...e,position:{...t}}:e})),setTimeout(()=>t({padding:mn,duration:300}),50)},[T,t]),[,Ne]=(0,U.useState)(0);return(0,U.useEffect)(()=>{let e=setInterval(()=>{document.hidden||Ne(e=>e+1)},2e3);return()=>clearInterval(e)},[]),(0,J.jsxs)(`div`,{ref:n,className:`relative h-full w-full overflow-hidden bg-[hsl(var(--surface-2)/0.55)]`,children:[(0,J.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Ar as n,Bn as r,Ji as i,Jn as a,Ln as o,Mn as s,Nt as c,On as l,Pr as u,Qt as d,Ri as f,Rn as p,Tt as m,Ui as h,Wn as g,Xt as _,Zt as v,_ as y,_i as b,a as x,at as S,bn as C,c as w,ct as T,d as E,et as ee,f as te,ft as ne,ga as D,gi as O,h as k,hr as A,i as re,it as j,ji as ie,kr as M,l as ae,lr as oe,m as se,mi as ce,mr as le,mt as ue,o as de,oi as N,p as fe,pa as P,pi as F,r as pe,ri as me,rr as he,rt as ge,s as I,st as L,ti as R,u as _e,ua as ve,v as ye,xa as be,ya as z,zn as xe,zr as B}from"./vendor-9hC4n4Me.js";import"./i18n-D-JnOQZX.js";import{s as Se}from"./ws-client-eyEv8wbm.js";import{t as V}from"./utils-DzRQUvln.js";import{t as Ce}from"./session-store-w5G2euPs.js";import{_ as we,c as H,l as Te,x as Ee}from"./stores-hEu6z1qz.js";import{r as De}from"./mailbox-store-BN2cGkN_.js";import{f as Oe}from"./markdown-L6DLSM7f.js";import{c as ke,s as Ae,t as je}from"./LazyMarkdown-CaNUh8CL.js";import{C as Me,D as Ne,E as Pe,m as Fe}from"./index-WvJRbCoi.js";var U=e(be(),1);function Ie(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Le(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function W(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function G(e,t){for(let n of t){let t=W(e[n]);if(t)return t}}function K(e,t){for(let n of t){let t=Le(e[n]);if(t!==void 0)return t}}function Re(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function ze(e){return e?e.split(/\r?\n/).length:0}function Be(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 Ve(e){let t=e.split(/\r?\n/,1)[0]?.trim()??e;return t.length>72?`${t.slice(0,69)}…`:t}function He(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 Ue(e,t){let n=(Array.isArray(e.fileTargets)?e.fileTargets:[]).flatMap(e=>{let t=Ie(e),n=G(t,[`filePath`,`file_path`,`path`]);return n?[{filePath:n,operation:W(t.operation),line:K(t,[`line`,`startLine`,`start_line`]),endLine:K(t,[`endLine`,`end_line`])}]:[]});if(n.length>0)return n;let r=G(t,[`file_path`,`filePath`,`path`,`filename`,`target_file`,`targetFile`]);return r?[{filePath:r,line:K(t,[`line`,`start_line`,`startLine`,`offset`]),endLine:K(t,[`end_line`,`endLine`])}]:[]}function We(e,t){let n=e?.line??K(t,[`line`,`start_line`,`startLine`,`offset`]),r=e?.endLine??K(t,[`end_line`,`endLine`]),i=K(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 Ge(e,t,n,r,i,a){let o=We(a,n),s=a?.filePath??G(n,[`file_path`,`filePath`,`path`,`filename`]),c=s?Re(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=G(n,[`content`,`text`,`data`]),t=K(r,[`inputLines`])??(e?ze(e):void 0);return{target:s,summary:t===void 0?`Writing file`:`${t.toLocaleString()} lines written`,lineLabel:o.label}}if(e===`edit`){let e=G(n,[`patch`,`diff`]),t=e?Be(e):null,i=G(n,[`old_string`,`oldString`,`search`]),a=G(n,[`new_string`,`newString`,`replacement`]),c=K(r,[`addedLines`]),l=K(r,[`removedLines`]),u=K(r,[`oldLines`]),d=K(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?ze(i):u??0} → ${a?ze(a):d??0} lines`:o.label?`${o.label} updated`:`Updating file`,lineLabel:o.label}}if(e===`terminal`){let e=G(n,[`command`,`cmd`,`script`,`shell`])??t;return{summary:Ve(e),target:e}}if(e===`web`){let e=G(n,[`url`,`href`,`uri`]),t=G(n,[`query`,`q`,`search`]);return{target:e??t,summary:e?`Fetched ${e}`:t?`Looked up “${t}”`:`Went online`}}if(e===`search`){let e=G(n,[`query`,`pattern`,`q`,`search`])??c;return{target:s??e,summary:e?`Searched “${e}”`:`Searching project`}}if(e===`memory`){let e=G(n,[`query`,`text`,`key`]);return{target:e,summary:e?`Recalled “${e}”`:`Checking memory`}}return{target:s,summary:c?`${t} · ${c}`:t}}function Ke(e,t){let n=W(t.name)??W(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 qe(e,t,n){return W(t.agentId)??W(t.subagentId)??(e.kind===`agent:tool`?e.source:void 0)??(e.source!==n&&e.source!==`filesystem`?e.source:void 0)??`leader`}function Je(e){return W(e.parentSessionId)??W(e.sessionId)}function Ye(e,t){return e.kind===`tool:started`||e.kind===`tool:progress`?`running`:t.ok===!1?`failed`:`succeeded`}function Xe(e){if(![`tool:started`,`tool:progress`,`tool:executed`,`agent:tool`].includes(e.kind))return null;let t=Ie(e.data),n=Ke(e,t);if(!n)return null;let r=qe(e,t,n),i=t.input,a=Ie(i),o=Ue(t,a),s=Le(t.outputLines),c=He(n),l=Ge(c,n,a,t,s,o[0]),u=W(t.id),d=Math.floor(e.timestamp/2e3),f=Ye(e,t),p=Le(t.durationMs);return{id:u?`${r}:${u}`:`${r}:${n}:${d}`,agentId:r,agentName:W(t.agentName),sessionId:Je(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:Le(t.outputBytes),outputTokens:Le(t.outputTokens),input:i,output:W(t.output),fileTargets:o,raw:e.raw??t}}function Ze(e,t,n){return e?.length?nt(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 Qe(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 $e(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=q(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(q(e.from)),c=r.get(q(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 et(e,t){return e.toLowerCase()===t.toLowerCase()}function q(e){return e?.trim().toLowerCase()??``}function tt(e,t,n){let r=new Set([t.serverId,t.mailboxId,t.name].map(q).filter(e=>e.length>0)),i=n?`@session:${q(n)}`:``,a=q(t.role),o=q(t.serverId)===`leader`||q(t.serverId).startsWith(`leader@`)||a===`lead`||a===`leader`;return e.flatMap(e=>{let t=q(e.from),n=q(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(q(e)))}]}).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,8)}function nt(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=Xe(a);if(!o||!et(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 rt(e,t,n){let r=He(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 J=ee(),it={read:v,write:B,edit:B,terminal:c,web:R,search:M,memory:p,other:F};function at(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 ot(e){return e===void 0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function st(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Y({label:e,value:t}){return(0,J.jsxs)(`div`,{className:`agent-office__detail-row`,children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsx)(`strong`,{children:t})]})}function ct({selected:e,onClose:t}){let{t:n}=D(),{call:r,agentName:i}=e,a=it[r.kind],o=st(r.input),s=st(r.output);return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${r.toolName} details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:V(`agent-office__detail-icon`,`is-${r.kind}`),children:(0,J.jsx)(a,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:n(`activity:agentOffice.toolCall`)}),(0,J.jsx)(`h2`,{children:r.toolName})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close details`,children:(0,J.jsx)(S,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,r.status===`running`&&`is-active`,r.status===`failed`&&`is-failed`)}),(0,J.jsx)(`strong`,{children:r.summary}),(0,J.jsx)(`span`,{children:r.status})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.execution`)}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.agent`),value:i}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.started`),value:new Date(r.startedAt).toLocaleTimeString()}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.duration`),value:ot(r.durationMs)}),r.sessionId&&(0,J.jsx)(Y,{label:n(`activity:agentOffice.session`),value:at(r.sessionId,28)})]}),(r.target||r.fileTargets.length>0)&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.target`)}),r.target&&(0,J.jsx)(`code`,{className:`agent-office__target-code`,children:r.target}),r.fileTargets.map((e,t)=>(0,J.jsxs)(`div`,{className:`agent-office__file-target`,children:[(0,J.jsx)(u,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:e.filePath}),(e.line||e.endLine)&&(0,J.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,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.resultSize`)}),(0,J.jsxs)(`div`,{className:`agent-office__metric-grid`,children:[r.outputLines!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r.outputLines.toLocaleString()}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.lines`)})]}),r.outputBytes!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r.outputBytes.toLocaleString()}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.bytes`)})]}),r.outputTokens!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`strong`,{children:[`≈`,r.outputTokens.toLocaleString()]}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.tokens`)})]})]})]}),o&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.input`)}),(0,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:o})})]}),s&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.outputPreview`)}),(0,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:s})})]})]})}function lt({selected:e,onClose:t}){let{t:n}=D(),{mail:i,agentName:a}=e;return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${i.subject} details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-mail`,children:(0,J.jsx)(r,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:i.direction===`incoming`?`INCOMING MAIL`:`OUTGOING MAIL`}),(0,J.jsx)(`h2`,{children:i.subject})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close mail details`,children:(0,J.jsx)(S,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,i.unread&&`is-active`)}),(0,J.jsxs)(`strong`,{children:[i.from,` → `,i.to]}),(0,J.jsx)(`span`,{children:i.type}),i.audience===`leaders`&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(g,{className:`h-3 w-3`}),` `,n(`activity:mailbox.audienceLeaders`)]})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:mailbox.messages`)}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.agent`),value:a}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.started`),value:new Date(i.timestampMs).toLocaleTimeString()}),(0,J.jsx)(Y,{label:`Priority`,value:i.priority}),(0,J.jsx)(Y,{label:`Route`,value:`${i.from} → ${i.to}`})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:i.subject}),(0,J.jsx)(`div`,{className:`agent-office__mail-body`,children:i.body})]})]})}function ut({selected:e,onClose:t}){let{t:n}=D();return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.agentName} task details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-task`,children:(0,J.jsx)(a,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:n(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`h2`,{children:e.agentName})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close task details`,children:(0,J.jsx)(S,{})})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.task`)}),e.taskId&&(0,J.jsx)(Y,{label:`ID`,value:e.taskId}),(0,J.jsx)(`div`,{className:`agent-office__task-body`,children:e.task})]})]})}function dt({selected:e,onClose:t}){let{t:n}=D(),r=e.todos.filter(e=>e.status!==`completed`).length;return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.officeLabel} briefing`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-briefing`,children:(0,J.jsx)(o,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.officeBriefing`)}),(0,J.jsx)(`h2`,{children:e.officeLabel})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close office briefing`,children:(0,J.jsx)(S,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,(e.instructionActive||r>0)&&`is-active`)}),(0,J.jsx)(`strong`,{children:e.telemetryConnected?n(`activity:agentOffice.activeTodos`):n(`activity:agentOffice.telemetryWaiting`)}),(0,J.jsx)(`span`,{children:e.telemetryConnected?r:`—`})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.leaderPrompt`)}),e.promptAt!==void 0&&(0,J.jsx)(Y,{label:n(`activity:agentOffice.promptReceived`),value:new Date(e.promptAt).toLocaleString()}),(0,J.jsx)(`div`,{className:`agent-office__task-body`,children:e.prompt??(e.telemetryConnected?n(`activity:agentOffice.noPrompt`):n(`activity:agentOffice.telemetryWaiting`))})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.todos`)}),(0,J.jsx)(`div`,{className:`agent-office__todo-detail-list`,children:e.telemetryConnected?e.todos.length>0?e.todos.map(e=>(0,J.jsxs)(`div`,{className:V(`agent-office__todo-detail`,`is-${e.status}`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.content}),(0,J.jsx)(`small`,{children:n(`activity:agentOffice.todoStatus.${e.status}`)})]})]},e.id)):(0,J.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.noActiveTodos`)}):(0,J.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.todoTelemetryWaiting`)})})]})]})}function ft({selected:e,onClose:t}){return e.kind===`tool`?(0,J.jsx)(ct,{selected:e,onClose:t}):e.kind===`mail`?(0,J.jsx)(lt,{selected:e,onClose:t}):e.kind===`task`?(0,J.jsx)(ut,{selected:e,onClose:t}):(0,J.jsx)(dt,{selected:e,onClose:t})}function pt(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 mt(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 ht(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 gt(e){if(!e)return;let t=e.split(`/`);return t[t.length-1]?.slice(0,18)}function _t(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 vt(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 yt(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 bt(e){return e===`tui`?`tui`:e===`repl`||e===`cli`?`repl`:`webui`}function xt(e){return e===`tui`?`TUI`:e===`repl`?`REPL`:`WebUI`}function St(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 Ct(e){if(e)return e.split(`/`).filter(Boolean).pop()??e}function wt(e){let t=Ct(e)??e??``;return t.length>10?`…${t.slice(-8)}`:t}function Tt(e,t){let n=Ct(t);if(n)return e.find(e=>Ct(e.sessionId)===n)}function Et(e,t){let n=St(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 Dt(e,t){return e===`cli`?`CLI`:e===`repl`?`REPL`:xt(t)}function Ot(e,t,n=[],r=new Map,i=Date.now()){let a=new Set,o=[];for(let n of e){let e=bt(n.clientType),r=Dt(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=St(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}`:wt(n.sessionId)}`,sublabel:[`session ${wt(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=Tt(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=Tt(o,e.sessionId)??l(),n=Et(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=Tt(o,t.agent.sessionId);n&&n.agents.push(Et(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 kt(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 At=new Set([`completed`,`failed`,`timeout`,`stopped`]);function jt(e){let t=(0,U.useRef)(new Map).current;return(0,U.useMemo)(()=>{let n=Date.now(),r=new Set;for(let i of e.values())if(r.add(i.id),At.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)&&!At.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 Mt=[`bot`,`cactus`,`duck`,`radio`],Nt={leader:`plum`,builder:`ocean`,researcher:`mint`,reviewer:`rose`,planner:`amber`,operator:`graphite`},Pt={leader:0,builder:1,researcher:2,reviewer:3,planner:4,operator:5},Ft={read:v,write:B,edit:B,terminal:c,web:R,search:M,memory:p,other:F},It={leader:h,builder:F,researcher:v,reviewer:f,planner:a,operator:c};function Lt(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 Rt(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:Nt[t],layout:r%4,clutter:Math.floor(r/4)%3,avatar:Pt[t],motion:Math.floor(r/31)%4,charm:Mt[Math.floor(r/47)%Mt.length]}}function zt(e,t=22){let n=e.split(`/`).filter(Boolean).pop()??e;return n.length>t?`${n.slice(0,t-1)}…`:n}function Bt(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 Vt(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 Ht(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 Ut(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 Wt(e,t,n){return n.map((n,r)=>({...rt(e.serverId,n.name,t.sessionId),id:`${e.serverId}:log:${n.at}:${r}`,kind:He(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 Gt(...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 Kt(...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 qt({kind:e,active:t}){let n=Ft[e];return(0,J.jsxs)(`span`,{className:V(`agent-office__tool-glyph`,`is-${e}`,t&&`is-active`),children:[e===`read`&&(0,J.jsx)(u,{className:`agent-office__file-underlay`,"aria-hidden":`true`}),(0,J.jsx)(n,{"aria-hidden":`true`})]})}function Jt({active:e,failed:t,role:n,variant:r,motion:i}){let a=It[n];return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(`span`,{className:`agent-office__avatar-chair`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-body`}),(0,J.jsxs)(`span`,{className:`agent-office__avatar-head`,children:[(0,J.jsx)(`span`,{className:`agent-office__avatar-hair`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-face`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-mouth`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-headset`})]}),(0,J.jsx)(`span`,{className:`agent-office__avatar-arm`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-prop`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-role-badge`,children:(0,J.jsx)(a,{})})]})}function Yt({call:e,compact:t=!1,onSelect:n}){let r=e.status===`running`;return(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__parcel`,`is-${e.kind}`,t&&`is-compact`,r&&`is-running`,e.status===`failed`&&`is-failed`),onClick:n,"aria-label":`${e.toolName}: ${e.summary}`,children:[(0,J.jsx)(qt,{kind:e.kind,active:r}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsxs)(`span`,{className:`agent-office__parcel-topline`,children:[(0,J.jsx)(`strong`,{children:e.toolName}),e.lineLabel&&(0,J.jsx)(`span`,{className:`agent-office__line-chip`,children:e.lineLabel})]}),!t&&e.target&&(0,J.jsx)(`span`,{className:`agent-office__parcel-target`,children:Bt(e.target)}),(0,J.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.summary})]}),(0,J.jsx)(`span`,{className:`agent-office__parcel-state`,"aria-hidden":`true`,children:r?(0,J.jsx)(`span`,{className:`agent-office__pulse-dot`}):e.status===`failed`?(0,J.jsx)(S,{}):(0,J.jsx)(f,{})})]})}function Xt({mail:e,compact:t=!1,onSelect:n}){let i=e.direction===`incoming`;return(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__mail-parcel`,t&&`is-compact`,i?`is-incoming`:`is-outgoing`,e.unread&&`is-unread`),onClick:n,"aria-label":`${i?`Incoming`:`Outgoing`} mail: ${e.subject}`,children:[(0,J.jsx)(`span`,{className:`agent-office__mail-icon`,children:i?(0,J.jsx)(oe,{"aria-hidden":`true`}):(0,J.jsx)(_,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsx)(`strong`,{children:i?`${e.from} →`:`→ ${e.to}`}),(0,J.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.subject})]}),(0,J.jsx)(r,{"aria-hidden":`true`})]})}function Zt({office:e,now:t}){let{t:i}=D(),{client:a,agents:o,stats:s}=e,l=a.lastHeartbeatAt?Date.parse(a.lastHeartbeatAt):NaN,u=Number.isFinite(l)&&t-l<2e4,d=Number.isFinite(l)&&!u,f=o.some(({agent:e})=>e.presenceSource===`registry`),p=u?`VERIFIED`:d?`DELAYED`:f?`REGISTRY`:`LOCAL`,m=o.some(({agent:e})=>e.recentTools!==void 0||e.activity!==void 0),g=o.some(({agent:e})=>e.toolCalls>0&&e.recentTools===void 0&&e.activity===void 0);return(0,J.jsxs)(`header`,{className:`agent-office__client-header`,children:[(0,J.jsxs)(`div`,{className:`agent-office__client-title`,children:[(0,J.jsx)(`span`,{className:`agent-office__client-icon`,children:(0,J.jsx)(h,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{className:`agent-office__client-copy`,children:[(0,J.jsx)(`strong`,{children:a.label}),(0,J.jsx)(`span`,{children:a.sublabel||a.sessionId})]}),(0,J.jsxs)(`div`,{className:`agent-office__client-presence`,children:[(0,J.jsxs)(`span`,{className:`agent-office__client-agent-count`,children:[o.length,` `,i(`activity:agentOffice.agents`)]}),(0,J.jsxs)(`span`,{className:V(`agent-office__presence-chip`,!d&&`is-live`,d&&`is-legacy`),children:[(0,J.jsx)(L,{"aria-hidden":`true`}),` `,p]}),(0,J.jsxs)(`span`,{className:`agent-office__presence-chip`,children:[(0,J.jsx)(b,{"aria-hidden":`true`}),` `,Ht(a.startedAt,t),` UP`]}),(0,J.jsxs)(`span`,{className:V(`agent-office__presence-chip`,g?`is-legacy`:m&&`is-telemetry`),children:[(0,J.jsx)(P,{"aria-hidden":`true`}),g?`RECONNECT`:m?`TOOLS LIVE`:`READY`]})]})]}),(0,J.jsxs)(`fieldset`,{className:`agent-office__client-stats`,"aria-label":`Session activity totals`,children:[(0,J.jsxs)(`span`,{title:`Unique files touched`,children:[(0,J.jsx)(n,{}),` `,(0,J.jsx)(`strong`,{children:s.files}),` FILES`]}),(0,J.jsxs)(`span`,{title:`File reads`,children:[(0,J.jsx)(v,{}),` `,(0,J.jsx)(`strong`,{children:s.reads}),` READ`]}),(0,J.jsxs)(`span`,{title:`Files written`,children:[(0,J.jsx)(B,{}),` `,(0,J.jsx)(`strong`,{children:s.writes}),` WRITE`]}),(0,J.jsxs)(`span`,{title:`Files edited`,children:[(0,J.jsx)(B,{}),` `,(0,J.jsx)(`strong`,{children:s.edits}),` EDIT`]}),(0,J.jsxs)(`span`,{className:`agent-office__client-delta`,title:`Lines added and removed`,children:[(0,J.jsxs)(`strong`,{children:[`+`,s.linesAdded]}),` / `,(0,J.jsxs)(`b`,{children:[`−`,s.linesRemoved]})]}),(0,J.jsxs)(`span`,{title:`Terminal commands`,children:[(0,J.jsx)(c,{}),` `,(0,J.jsx)(`strong`,{children:s.terminalCalls}),` TERM`]}),(0,J.jsxs)(`span`,{title:`Incoming and outgoing mail`,children:[(0,J.jsx)(r,{}),` `,(0,J.jsx)(`strong`,{children:s.incomingMail}),`↓ `,(0,J.jsx)(`strong`,{children:s.outgoingMail}),`↑`]})]})]})}function Qt({office:e,now:n,onSelect:r}){let{t:i}=D(),{client:s}=e,c=s.todos!==void 0,l=s.todos??[],u=l.filter(e=>e.status!==`completed`),d=l.length-u.length,f=!!s.activeInstruction,p=s.activeInstruction??s.latestPrompt,m=s.latestPromptAt!==void 0&&n-s.latestPromptAt<3e4,h=()=>r({kind:`briefing`,officeLabel:s.label,prompt:p,promptAt:s.latestPromptAt,instructionActive:f,telemetryConnected:c,todos:l});return(0,J.jsxs)(`section`,{className:`agent-office__briefing`,"aria-label":i(`activity:agentOffice.officeBriefing`),children:[(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__prompt-card`,f&&`is-active`,m&&`is-fresh`,!c&&`is-waiting`),onClick:h,children:[(0,J.jsx)(`span`,{className:`agent-office__briefing-icon is-prompt`,children:(0,J.jsx)(o,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__briefing-copy`,children:[(0,J.jsx)(`span`,{children:i(f?`activity:agentOffice.activeInstruction`:`activity:agentOffice.leaderPrompt`)}),(0,J.jsx)(`strong`,{children:p??i(c?`activity:agentOffice.noPrompt`:`activity:agentOffice.telemetryWaiting`)})]}),f&&(0,J.jsxs)(`span`,{className:`agent-office__instruction-live`,children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),` LIVE`]}),s.latestPromptAt!==void 0&&(0,J.jsx)(`time`,{dateTime:new Date(s.latestPromptAt).toISOString(),children:Vt(s.latestPromptAt,n)})]}),(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__todo-board`,u.length>0&&`has-active`,!c&&`is-waiting`),onClick:h,children:[(0,J.jsxs)(`span`,{className:`agent-office__todo-heading`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(a,{"aria-hidden":`true`}),` `,i(`activity:agentOffice.activeTodos`)]}),(0,J.jsx)(`strong`,{children:c?i(`activity:agentOffice.todoProgress`,{done:d,total:l.length}):i(`activity:agentOffice.syncWaiting`)})]}),(0,J.jsxs)(`span`,{className:`agent-office__todo-preview`,children:[c?u.length>0?u.slice(0,3).map(e=>(0,J.jsxs)(`span`,{className:V(`agent-office__todo-line`,`is-${e.status}`),children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:e.activeForm||e.content})]},e.id)):(0,J.jsxs)(`span`,{className:`agent-office__todo-empty`,children:[(0,J.jsx)(t,{"aria-hidden":`true`}),l.length>0?i(`activity:agentOffice.allTodosDone`):i(`activity:agentOffice.noActiveTodos`)]}):(0,J.jsxs)(`span`,{className:`agent-office__todo-empty is-waiting`,children:[(0,J.jsx)(P,{"aria-hidden":`true`}),i(`activity:agentOffice.todoTelemetryWaiting`)]}),u.length>3&&(0,J.jsx)(`span`,{className:`agent-office__todo-more`,children:i(`activity:agentOffice.moreTodos`,{count:u.length-3})})]})]})]})}function $t({active:e}){let{t}=D();return(0,J.jsxs)(`div`,{className:`agent-office__parcel agent-office__parcel--empty`,children:[(0,J.jsx)(`span`,{className:`agent-office__tool-glyph`,children:(0,J.jsx)(i,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsx)(`strong`,{children:t(e?`activity:agentOffice.thinking`:`activity:agentOffice.waiting`)}),(0,J.jsx)(`span`,{children:t(e?`activity:agentOffice.preparing`:`activity:agentOffice.deskReady`)})]})]})}function en({model:e,now:t,onSelect:n,routedMailIds:i}){let{t:o}=D(),{agent:s,client:c,current:l,display:u,history:d,mail:p}=e,m=s.status===`active`||s.status===`streaming`,h=s.status===`error`,g=p[0],_=Lt(s),v=Rt(`${c.sessionId}:${s.serverId}:${s.name}`,_),y=g&&t-g.timestampMs<3e4&&!i?.has(g.id),b=d.slice(0,6),x=b[0]?.completedAt??b[0]?.startedAt??u?.completedAt??u?.startedAt,S=l?`is-tool-${l.kind}`:void 0;return(0,J.jsxs)(`article`,{className:V(`agent-office__lane`,`is-desk-${v.palette}`,`is-layout-${v.layout}`,`is-clutter-${v.clutter}`,m&&`is-active`,h&&`is-failed`),children:[(0,J.jsxs)(`div`,{className:`agent-office__identity`,children:[(0,J.jsxs)(`div`,{className:`agent-office__identity-line`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,m&&`is-active`,h&&`is-failed`)}),(0,J.jsx)(`strong`,{title:s.name,children:s.name}),(0,J.jsxs)(`span`,{className:`agent-office__agent-verified`,title:s.presenceSource===`registry`?`Verified by live session registry`:`Verified by local fleet state`,children:[(0,J.jsx)(f,{"aria-hidden":`true`}),s.presenceSource===`registry`?`LIVE`:`LOCAL`]})]}),(0,J.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,J.jsxs)(`div`,{className:`agent-office__agent-meta`,children:[(0,J.jsx)(`span`,{children:c.branch?`⎇ ${c.branch}`:c.type.toUpperCase()}),(0,J.jsx)(`span`,{children:o(`activity:agentOffice.callsCount`,{count:s.toolCalls})}),s.model&&(0,J.jsx)(`span`,{className:`agent-office__model-chip`,title:s.model,children:zt(s.model)})]}),s.currentTask&&(0,J.jsxs)(`button`,{type:`button`,className:`agent-office__agent-task`,onClick:()=>n({kind:`task`,task:s.currentTask??``,taskId:s.taskId,agentName:s.name}),children:[(0,J.jsx)(a,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:o(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`small`,{children:s.currentTask})]})]}),!s.currentTask&&m&&(0,J.jsxs)(`div`,{className:`agent-office__agent-task is-missing`,children:[(0,J.jsx)(P,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:o(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`small`,{children:c.todos===void 0?o(`activity:agentOffice.telemetryWaiting`):o(`activity:agentOffice.taskNotReported`)})]})]}),g&&(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__identity-mail`,g.unread&&`is-unread`),onClick:()=>n({kind:`mail`,mail:g,agentName:s.name}),"aria-label":`${p.length} mail messages. Latest: ${g.subject}`,children:[(0,J.jsx)(r,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsxs)(`strong`,{children:[p.length,` MAIL`]}),(0,J.jsx)(`small`,{children:g.subject})]})]})]}),(0,J.jsxs)(`div`,{className:V(`agent-office__scene`,S),children:[(0,J.jsxs)(`div`,{className:`agent-office__window`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsxs)(`div`,{className:`agent-office__plant`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`div`,{className:`agent-office__desk-zone`,"aria-hidden":`true`,children:[(0,J.jsx)(Jt,{active:m,failed:h,role:_,variant:v.avatar,motion:v.motion}),(0,J.jsx)(`span`,{className:`agent-office__monitor`,children:u?(0,J.jsx)(qt,{kind:u.kind,active:l!==void 0}):(0,J.jsx)(F,{})}),(0,J.jsxs)(`span`,{className:`agent-office__activity-fx`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsx)(`span`,{className:`agent-office__desk`}),(0,J.jsx)(`span`,{className:`agent-office__desk-lamp`}),(0,J.jsxs)(`span`,{className:`agent-office__desk-clutter`,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`span`,{className:V(`agent-office__desk-charm`,`is-${v.charm}`),children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`span`,{className:V(`agent-office__mug`,`is-${_}`),children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),(0,J.jsx)(`b`,{"aria-hidden":`true`})]})]}),y&&(0,J.jsx)(`div`,{className:V(`agent-office__mail-flyby`,`is-${g.direction}`),children:(0,J.jsx)(Xt,{mail:g,compact:!0,onSelect:()=>n({kind:`mail`,mail:g,agentName:s.name})},g.id)}),(0,J.jsxs)(`div`,{className:V(`agent-office__conveyor`,l&&`is-moving`),children:[(0,J.jsxs)(`div`,{className:`agent-office__belt`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsx)(`div`,{className:`agent-office__current-action`,children:u?(0,J.jsx)(Yt,{call:u,onSelect:()=>n({kind:`tool`,call:u,agentName:s.name})},u.id):(0,J.jsx)($t,{active:m})})]})]}),(0,J.jsxs)(`div`,{className:`agent-office__history`,children:[(0,J.jsxs)(`div`,{className:`agent-office__history-heading`,children:[(0,J.jsx)(`span`,{children:o(`activity:agentOffice.recent`)}),x!==void 0&&(0,J.jsx)(`span`,{children:Vt(x,t)})]}),(0,J.jsx)(`div`,{className:`agent-office__history-list`,children:b.length>0?b.map(e=>(0,J.jsx)(Yt,{call:e,compact:!0,onSelect:()=>n({kind:`tool`,call:e,agentName:s.name})},`tool:${e.id}`)):(0,J.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 tn(e){return e.agent.status===`active`||e.agent.status===`streaming`||e.agent.status===`error`}function nn({agents:e,now:t,onSelect:n}){let{t:i}=D();return(0,J.jsxs)(`section`,{className:`agent-office__lounge`,"aria-label":i(`activity:agentOffice.breakRoom`),children:[(0,J.jsxs)(`header`,{className:`agent-office__lounge-heading`,children:[(0,J.jsx)(ce,{"aria-hidden":`true`}),(0,J.jsx)(`strong`,{children:i(`activity:agentOffice.breakRoom`)}),(0,J.jsx)(`span`,{children:i(`activity:agentOffice.onBreak`,{count:e.length})})]}),(0,J.jsx)(`div`,{className:`agent-office__lounge-seats`,children:e.map(e=>{let{agent:a,history:o,mail:s}=e,c=Lt(a),l=It[c],u=s.filter(e=>e.unread).length,d=o[0]?.completedAt??o[0]?.startedAt,f=s[0],p=()=>{a.currentTask?n({kind:`task`,task:a.currentTask,taskId:a.taskId,agentName:a.name}):f&&n({kind:`mail`,mail:f,agentName:a.name})},m=!!a.currentTask||!!f;return(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__lounge-seat`,`is-${c}`),onClick:p,disabled:!m,children:[(0,J.jsx)(`span`,{className:`agent-office__lounge-avatar`,children:(0,J.jsx)(l,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__lounge-copy`,children:[(0,J.jsx)(`strong`,{children:a.name}),(0,J.jsx)(`small`,{children:a.role??i(`activity:agentOffice.agent`)})]}),(0,J.jsxs)(`span`,{className:`agent-office__lounge-meta`,children:[d!==void 0&&(0,J.jsx)(`span`,{children:Vt(d,t)}),u>0&&(0,J.jsxs)(`span`,{className:`agent-office__lounge-mail`,children:[(0,J.jsx)(r,{"aria-hidden":`true`}),` `,u]})]})]},e.key)})})]})}function rn(){let{t:e}=D(),t=Te(e=>e.liveSessions),n=Te(e=>e.aggregate),a=Ee(e=>e.agents),o=De(e=>e.agents),s=De(e=>e.messages),c=Se(e=>e.toolEvents),l=Ce(e=>e.projectName),u=jt(a),[d,f]=(0,U.useState)(null),p=(0,U.useMemo)(()=>Ot(t,a,o,u.map,u.now),[t,a,o,u]),m=(0,U.useMemo)(()=>p.flatMap(e=>e.agents.map(t=>{let n=Gt(nt(c,t.serverId,e.sessionId),Ze(t.recentTools,t.serverId,e.sessionId),Wt(t,e,a.get(t.serverId)?.toolLog??[])),r=t.status===`active`||t.status===`streaming`,i=n.find(e=>e.status===`running`);!i&&r&&t.currentTool&&(i=rt(t.serverId,t.currentTool,e.sessionId));let o=i??n[0],l=n.filter(e=>e.status!==`running`).slice(0,6),u=Kt(Qe(t.recentMail),tt(s,t,e.sessionId));return{key:t.officeId,client:e,agent:t,calls:n,current:i,display:o,history:l,mail:u}})),[p,a,s,c]),g=(0,U.useMemo)(()=>p.map(e=>{let t=m.filter(t=>t.client.id===e.id);return{client:e,agents:t,stats:Ut(t)}}).filter(e=>e.agents.length>0),[p,m]),_=m.filter(({agent:e})=>e.status===`active`||e.status===`streaming`).length,v=l||t.find(e=>e.projectName)?.projectName||e(`activity:office.fleetHq`),y=Date.now();return(0,J.jsxs)(`div`,{className:`agent-office`,children:[(0,J.jsxs)(`header`,{className:`agent-office__header`,children:[(0,J.jsxs)(`div`,{className:`agent-office__title`,children:[(0,J.jsx)(`span`,{className:`agent-office__brand-mark`,children:(0,J.jsx)(h,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:e(`activity:agentOffice.liveProjectOffice`)}),(0,J.jsx)(`h1`,{children:v})]})]}),(0,J.jsxs)(`div`,{className:`agent-office__live-pill`,children:[(0,J.jsx)(`span`,{}),` LIVE`]}),(0,J.jsxs)(`div`,{className:`agent-office__summary`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(i,{}),(0,J.jsx)(`strong`,{children:m.length}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.agents`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(j,{}),(0,J.jsx)(`strong`,{children:_}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.working`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(P,{}),(0,J.jsx)(`strong`,{children:n.toolCalls.toLocaleString()}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.toolCalls`)})]})]})]}),(0,J.jsx)(`main`,{className:`agent-office__floor`,children:m.length>0?g.map(t=>{let n=t.agents.filter(tn),i=t.agents.filter(e=>!tn(e)),a=$e(n,y),o=new Set(a.map(e=>e.id));return(0,J.jsxs)(`section`,{className:`agent-office__client-office`,children:[(0,J.jsx)(Zt,{office:t,now:y}),(0,J.jsx)(Qt,{office:t,now:y,onSelect:f}),n.length>0&&(0,J.jsxs)(`div`,{className:`agent-office__column-headings`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{children:e(`activity:agentOffice.team`)}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.liveDesk`)}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.lastActions`)})]}),(0,J.jsxs)(`div`,{className:`agent-office__client-desks`,children:[n.map(e=>(0,J.jsx)(en,{model:e,now:y,onSelect:f,routedMailIds:o},e.key)),a.length>0&&(0,J.jsx)(`div`,{className:`agent-office__mail-routes`,"aria-hidden":`true`,children:a.map(e=>(0,J.jsx)(`div`,{className:`agent-office__mail-route`,style:{"--from":`${(e.fromIndex+.5)/n.length*100}%`,"--to":`${(e.toIndex+.5)/n.length*100}%`},children:(0,J.jsx)(`span`,{className:`agent-office__mail-route-parcel`,children:(0,J.jsx)(r,{"aria-hidden":`true`})})},e.id))}),n.length===0&&(0,J.jsxs)(`div`,{className:`agent-office__desks-empty`,children:[(0,J.jsx)(ce,{"aria-hidden":`true`}),e(`activity:agentOffice.desksEmpty`)]})]}),i.length>0&&(0,J.jsx)(nn,{agents:i,now:y,onSelect:f})]},t.client.id)}):(0,J.jsxs)(`div`,{className:`agent-office__empty-state`,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(L,{"aria-hidden":`true`})}),(0,J.jsx)(`h2`,{children:e(`activity:agentOffice.readyTitle`)}),(0,J.jsx)(`p`,{children:e(`activity:agentOffice.readyBody`)})]})}),(0,J.jsxs)(`footer`,{className:`agent-office__footer`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:`agent-office__status-dot is-active`}),` `,e(`activity:agentOffice.liveEvent`)]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(A,{}),` `,e(`activity:agentOffice.connectedSessions`,{count:t.length})]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(b,{}),` `,e(`activity:agentOffice.detailHint`)]})]}),d&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,className:`agent-office__detail-backdrop`,onClick:()=>f(null),"aria-label":`Close tool details`}),(0,J.jsx)(ft,{selected:d,onClose:()=>f(null)})]})]})}function an(){let{t:e}=D(),{clientCounts:t,currentSession:n,totalAgents:r,activeAgents:a,aggregate:o}=Te(ge(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents,aggregate:e.aggregate}))),c=t.tui+t.webui+t.repl,l=e=>e?.toLocaleString()??`0`;return(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsx)(P,{className:`h-3.5 w-3.5 text-success`}),(0,J.jsx)(`span`,{className:`text-[10px] font-bold uppercase text-muted-foreground`,children:e(`activity:office.sessionStats`)})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5 text-[10px]`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(ne,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.clients`)})]}),(0,J.jsxs)(`span`,{className:`font-mono text-foreground`,children:[a,` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,J.jsx)(`span`,{className:`text-success`,children:c})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 pl-4 text-[9px]`,children:[t.tui>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(m,{className:`h-2.5 w-2.5 text-success`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`TUI`}),(0,J.jsx)(`span`,{className:`font-mono text-success`,children:t.tui})]}),t.webui>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(s,{className:`h-2.5 w-2.5 text-primary`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`WebUI`}),(0,J.jsx)(`span`,{className:`font-mono text-primary`,children:t.webui})]}),t.repl>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(m,{className:`h-2.5 w-2.5 text-warning`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`REPL`}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:t.repl})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(i,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.agents`)})]}),(0,J.jsxs)(`span`,{className:`font-mono text-foreground`,children:[a,` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,J.jsx)(`span`,{className:`text-primary`,children:r})]})]}),n.model&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(N,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.model`)})]}),(0,J.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,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(j,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.mode`)})]}),(0,J.jsx)(`span`,{className:V(`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,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(le,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.toolCallsLabel`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:l(o.toolCalls)})]}),(0,J.jsxs)(`div`,{className:`mt-1.5 space-y-1 border-t border-border/70 pt-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`IN`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.input`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:l(o.tokensIn)})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`OUT`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.output`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:l(o.tokensOut)})]})]}),(0,J.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-4 border-t border-border/70 pt-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(me,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.cost`)})]}),(0,J.jsx)(`span`,{className:`font-mono font-medium text-success`,children:(e=>e==null?`$0.0000`:`$${e.toFixed(4)}`)(o.costUsd)})]})]})]})}function on({events:e,now:t}){let{t:n}=D(),r=e.slice(0,14);return(0,J.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pointer-events-none px-3 pb-3`,children:(0,J.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,J.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] uppercase text-primary`,children:[(0,J.jsx)(P,{className:`h-3 w-3`}),n(`activity:office.liveActivity`)]}),r.length===0?(0,J.jsx)(`div`,{className:`text-[11px] italic text-muted-foreground`,children:n(`activity:office.waitingActivity`)}):(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] leading-tight`,children:[(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{backgroundColor:kt(e.kind)}}),(0,J.jsx)(`span`,{className:`flex-1 truncate text-foreground`,children:e.label}),(0,J.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:r<1?n(`activity:office.now`):`${r}s`})]},e.id)})})]})})}function sn(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 cn={user:{Icon:ue,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:m,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:ie,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 ln({entry:e}){let{t}=D();return e.role===`error`?(0,J.jsx)(Pe,{text:e.text}):e.role===`tool`?(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 tool-details`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,J.jsx)(m,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{className:`font-mono`,children:e.tool??t(`activity:watch.toolFallback`)}),e.durationMs!==void 0&&(0,J.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground font-normal tabular-nums`,children:[(0,J.jsx)(O,{className:`h-3 w-3 inline mr-0.5 align-text-bottom`}),sn(e.durationMs)]})]}),e.input!==void 0&&e.input!==null&&(0,J.jsx)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:(0,J.jsx)(Me,{input:e.input})}),e.output!==void 0&&e.output!==null?(0,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:typeof e.output==`string`?(0,J.jsx)(je,{remarkPlugins:[Oe],rehypePlugins:ke,components:Ae,children:e.output}):(0,J.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,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,J.jsx)(je,{remarkPlugins:[Oe],rehypePlugins:ke,components:Ae,children:e.text})}):null,e.isError&&(0,J.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:t(`activity:watch.toolFailed`)}),e.text&&(0,J.jsx)(`pre`,{className:`mt-1 text-xs whitespace-pre-wrap text-destructive/80`,children:e.text})]})]}):(0,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,J.jsx)(je,{remarkPlugins:[Oe],rehypePlugins:ke,components:Ae,children:e.text})})}function un({entry:e,isContinuation:t=!1}){let{t:n}=D(),r=cn[e.role],i=r.Icon;return(0,J.jsxs)(`div`,{className:`group flex gap-3 animate-message msg-bubble rounded-lg transition-shadow`,children:[t?(0,J.jsx)(`div`,{className:`flex-shrink-0 w-8`}):(0,J.jsx)(`div`,{className:V(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,r.avatarBg,r.avatarColor,r.avatarRing),children:(0,J.jsx)(i,{className:`h-4 w-4`})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0 flex-1`,children:[!t&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:V(`text-xs font-medium`,r.textColor),children:e.role===`tool`&&e.tool?e.tool:n(r.labelKey)}),(0,J.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,J.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`· `,sn(e.durationMs)]})]}),(0,J.jsx)(`div`,{className:V(`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,J.jsx)(`div`,{className:V(`text-sm leading-relaxed markdown-content`,r.textColor),children:(0,J.jsx)(ln,{entry:e})})}),e.text&&e.role!==`error`&&(0,J.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,J.jsx)(Ne,{text:e.text,label:n(`common:action.copy`)})})]})]})}var dn=[`steer`,`ask`,`assign`,`note`],fn=2500;function pn({sessionId:e,limit:t=200}){let[n,r]=(0,U.useState)(null),{t:a}=D(),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(`steer`),[g,_]=(0,U.useState)(`high`),[v,y]=(0,U.useState)([]),[b,x]=(0,U.useState)(!1),S=(0,U.useRef)(null),C=(0,U.useRef)(!0),w=(0,U.useRef)(!0),T=Te(e=>e.liveSessions),E=(0,U.useMemo)(()=>T.find(t=>t.sessionId===e),[T,e]),ee=(0,U.useMemo)(()=>{let e=E;return e?`${e.status}|${e.agents.map(e=>`${e.id}:${e.status}:${e.toolCalls??0}:${e.iterations??0}`).join(`,`)}`:``},[E]),te=E?.status===`active`||(E?.agents.some(e=>e.status===`running`||e.status===`streaming`)??!1),ne=(0,U.useMemo)(()=>{if(!E)return null;let e=E.agents.find(e=>e.status===`running`||e.status===`streaming`);return e?.currentTool?`🔧 ${e.currentTool}`:e?a(`activity:sessionWatch.working`,{name:e.name??e.id}):null},[E,a]),O=(0,U.useMemo)(()=>{if(!E)return null;let e=E.agents.find(e=>e.partialText&&(e.status===`streaming`||e.status===`running`))??E.agents.find(e=>e.partialText);return e?.partialText?{label:e.id===`leader`?a(`activity:sessionWatch.claude`):e.name||e.id,text:e.partialText}:null},[E,a]),k=(0,U.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();w.current&&(r(i),s(null))}catch(e){w.current&&s(e instanceof Error?e.message:String(e))}},[e,t]),A=(0,U.useCallback)(async()=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/mailbox`);if(!t.ok)return;let n=await t.json();w.current&&Array.isArray(n.thread)&&y(n.thread)}catch{}},[e]);(0,U.useEffect)(()=>{w.current=!0,r(null),s(null),y([]),k(),A();let e=setInterval(()=>{document.hidden||(k(),A())},fn);return()=>{w.current=!1,clearInterval(e)}},[k,A]),(0,U.useEffect)(()=>{ee&&k()},[ee,k]),(0,U.useEffect)(()=>{C.current&&S.current&&(S.current.scrollTop=S.current.scrollHeight)},[n,O]);let re=()=>{let e=S.current;e&&(C.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},j=async()=>{let t=c.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:m,priority:g})});if(!n.ok)throw Error(`HTTP ${n.status}`);l(``),p(te?z.t(`activity:sessionWatch.sentRunning`):z.t(`activity:sessionWatch.sentIdle`)),A()}catch(e){p(z.t(`activity:sessionWatch.sentFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{d(!1)}}},ie=async()=>{if(!b){x(!0),p(null);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({reason:z.t(`activity:sessionWatch.interruptReason`)})});if(!t.ok)throw Error(`HTTP ${t.status}`);p(z.t(`activity:sessionWatch.interruptSent`)),A()}catch(e){p(z.t(`activity:sessionWatch.interruptFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{x(!1)}}},M=n?.entries??[];return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 shrink-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:V(`h-1.5 w-1.5 rounded-full`,te?`bg-success animate-pulse`:`bg-muted-foreground`)}),a(`activity:sessionWatch.liveStream`)]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,J.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[a(`activity:sessionWatch.events`,{count:n.total}),` · `,n.status]}),te&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>void ie(),disabled:b,title:a(`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:a(b?`activity:sessionWatch.interrupting`:`activity:sessionWatch.interrupt`)})]})]}),ne&&(0,J.jsxs)(`div`,{className:`mb-1.5 shrink-0 text-[10px] text-foreground truncate`,children:[`▶ `,ne]}),o&&(0,J.jsxs)(`div`,{className:`text-[11px] text-destructive mb-1 shrink-0`,children:[`· `,o]}),(0,J.jsxs)(`div`,{ref:S,onScroll:re,className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain space-y-1.5 pr-1`,children:[M.length===0&&!o&&(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:a(`activity:sessionWatch.loading`)}),M.map((e,t)=>(0,J.jsx)(un,{entry:e,isContinuation:t>0&&M[t-1].role===e.role},`${e.ts}-${t}`)),O&&(0,J.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,J.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,J.jsx)(i,{className:`h-4 w-4 animate-pulse`})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] min-w-0`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground px-1`,children:O.label}),(0,J.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-4 py-3 bg-card border border-border`,children:(0,J.jsxs)(`span`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:[O.text,(0,J.jsx)(`span`,{className:`animate-pulse text-primary`,children:`▋`})]})})]})]})]}),v.length>0&&(0,J.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0 max-h-28 overflow-y-auto space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:a(`activity:mailbox.messages`)}),v.slice(-6).map(e=>{let t=e.completed?a(`activity:sessionWatch.done`):e.readByLeader?a(`activity:sessionWatch.read`):a(`activity:sessionWatch.delivered`);return(0,J.jsxs)(`div`,{className:`text-[10px] leading-snug`,children:[(0,J.jsx)(`span`,{className:V(`font-semibold mr-1.5`,e.fromLeader?`text-accent`:`text-primary`),children:e.fromLeader?a(`activity:sessionWatch.agent`):a(`activity:sessionWatch.you`)}),(0,J.jsx)(`span`,{className:`text-foreground whitespace-pre-wrap break-words`,children:e.body}),!e.fromLeader&&(0,J.jsx)(`span`,{className:V(`ml-1.5 text-[9px]`,e.completed?`text-success`:e.readByLeader?`text-primary`:`text-muted-foreground`),children:t})]},e.id)})]}),(0,J.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0`,children:[(0,J.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,J.jsx)(`select`,{value:m,onChange:e=>h(e.target.value),title:a(`activity:sessionWatch.msgType.${m}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:dn.map(e=>(0,J.jsx)(`option`,{value:e,children:a(`activity:sessionWatch.msgType.${e}Label`)},e))}),(0,J.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),title:a(`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,J.jsx)(`option`,{value:`high`,children:`high`}),(0,J.jsx)(`option`,{value:`normal`,children:`normal`}),(0,J.jsx)(`option`,{value:`low`,children:`low`})]})]}),(0,J.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,J.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),j())},rows:2,placeholder:a(`activity:sessionWatch.placeholder`,{label:a(`activity:sessionWatch.msgType.${m}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,J.jsx)(`button`,{type:`button`,onClick:()=>void j(),disabled:u||!c.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?`…`:a(`activity:sessionWatch.send`)})]}),f&&(0,J.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:f}),(0,J.jsx)(`div`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:a(`activity:sessionWatch.sendHint`)})]})]})}var X={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))`},mn=.12;function hn(e){return Math.min(100,Math.max(0,e??0))}function Z({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:X.muted,active:X.success,streaming:X.primary,completed:X.primary,error:X.destructive,offline:X.muted};return(0,J.jsx)(`span`,{className:V(`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,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(I,{type:`target`,position:y.Top,style:e,isConnectable:!1}),(0,J.jsx)(I,{type:`source`,position:y.Bottom,style:e,isConnectable:!1})]})}function gn({data:e}){let{t}=D();return(0,J.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,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:e.agentCount??0}),` `,t(`activity:office.agentsSuffix`)]}),e.startedAt&&(0,J.jsx)(`span`,{children:t(`activity:office.upPrefix`,{time:ht(e.startedAt,Date.now())})})]})}function _n({data:e}){let{t}=D(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`offline`,a=e.color||X.info;return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-primary/15`:`bg-primary/10`),children:(0,J.jsx)(s,{className:`h-5 w-5`,style:{color:a}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:a},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.webuiClient`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(T,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{children:t(`activity:office.disconnected`)})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(L,{className:`h-3 w-3 text-success`}),(0,J.jsx)(`span`,{children:t(`activity:office.connected`)})]})}),n&&(0,J.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-primary/20`,children:(0,J.jsx)(`div`,{className:`h-full animate-pulse bg-primary`,style:{width:`60%`}})}),(0,J.jsx)(gn,{data:e})]})}function vn({data:e}){let{t}=D(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.color||X.success;return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-success/15`:`bg-success/10`),children:(0,J.jsx)(m,{className:`h-5 w-5`,style:{color:i}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:i},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.tuiClient`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,J.jsx)(m,{className:`h-3 w-3 text-success`}),(0,J.jsx)(`span`,{children:t(`activity:office.terminal`)})]}),(0,J.jsx)(gn,{data:e})]})}function yn({data:e}){let{t}=D(),n=e.status===`active`||e.status===`streaming`,r=e.color||X.warning;return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-warning/15`:`bg-warning/10`),children:(0,J.jsx)(m,{className:`h-5 w-5`,style:{color:r}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:r},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.repl`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-1 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsx)(gn,{data:e})]})}function bn({data:e}){let{t}=D(),n=e.status===`active`||e.status===`streaming`,r=e.color||X.primary;return(0,J.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,J.jsx)(Q,{}),(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-12 h-12 rounded-xl`,n?`bg-primary/15`:`bg-primary/10`),children:(0,J.jsx)(N,{className:`h-6 w-6`,style:{color:r}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-sm font-bold truncate`,style:{color:r},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e.sublabel||t(`activity:office.fleetSummary`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px] mb-2`,children:[(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`font-mono`,children:[(0,J.jsx)(`span`,{className:`text-success`,children:e.agentsActive||0}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,J.jsx)(`span`,{className:`text-primary`,children:e.agentsTotal||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:officeMap.agents`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsx)(`div`,{className:`font-mono text-warning`,children:(e.toolCalls||0).toLocaleString()}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.toolCallsLabel`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsx)(`div`,{className:`font-mono text-foreground`,children:pt(e.tokensIn)}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.tokensLabel`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.cost`)})]})]}),n&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-primary`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-primary`}),t(`activity:office.coordinatingFleet`)]})]})}function xn({data:e}){let{t}=D(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,a=e.status===`completed`,o=e.color||X.primary,s=hn(e.ctxPct);return(0,J.jsxs)(`div`,{className:V(`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`,a&&`border-border/70 bg-muted/35`,!n&&!r&&!a&&`border-primary/30 bg-primary/10`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,J.jsx)(i,{className:`h-4 w-4 shrink-0`,style:{color:o}}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-[11px] font-bold truncate`,style:{color:o},children:e.label}),e.model&&(0,J.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:gt(e.model)})]}),(0,J.jsx)(Z,{status:e.status,small:!0,activity:e.vizActivity??0})]}),e.currentTask&&(0,J.jsxs)(`div`,{className:`mb-1.5 flex min-w-0 items-center gap-1 overflow-hidden text-[11px] text-primary`,children:[(0,J.jsx)(`span`,{className:V(`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`,n&&`animate-pulse`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.currentTask,children:_t(e.currentTask,72)})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-0.5 text-[11px] mb-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`iter`}),(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:e.iteration||0})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tools`}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:e.toolCalls||0})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tok`}),(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:pt((e.tokensIn||0)+(e.tokensOut||0))})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`cost`}),(0,J.jsxs)(`span`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]})]})]}),s>0&&(0,J.jsxs)(`div`,{className:`mb-1`,children:[(0,J.jsxs)(`div`,{className:`mb-0.5 flex justify-between text-[10px] text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:`ctx`}),(0,J.jsxs)(`span`,{className:V(`font-mono`,s>=90?`text-destructive`:s>=70?`text-warning`:`text-muted-foreground`),children:[s,`%`]})]}),(0,J.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-muted`,children:(0,J.jsx)(`div`,{className:V(`h-full`,s>=90?`bg-destructive`:s>=70?`bg-warning`:`bg-primary`),style:{width:`${s}%`}})})]}),e.lastActivityAt&&(0,J.jsxs)(`div`,{className:V(`flex items-center gap-1 text-[10px]`,n?`text-muted-foreground/70`:`text-muted-foreground`),children:[a&&(0,J.jsx)(`span`,{className:`text-success`,children:t(`activity:office.donePrefix`)}),r&&(0,J.jsx)(`span`,{className:`text-destructive`,children:t(`activity:office.failedPrefix`)}),(0,J.jsx)(`span`,{children:t(`activity:office.seenPrefix`,{time:mt(e.lastActivityAt,Date.now())})})]})]})}function Sn({data:e}){let{t}=D();return(0,J.jsxs)(`div`,{className:V(`rounded-lg border border-dashed p-3 min-w-[120px] transition-all opacity-40`,`border-border/70 bg-muted/30`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsx)(ve,{className:`h-4 w-4 text-muted-foreground`}),(0,J.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,J.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:e.label})}),(0,J.jsx)(Z,{status:e.status,small:!0,activity:e.vizActivity??0})]}),(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:office.availableDesk`)})]})}function Cn({data:e}){let{t}=D(),n=e.color||X.warning,i=(e.unreadCount||0)>0;return(0,J.jsxs)(`div`,{className:V(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,i&&`border-warning/50 bg-warning/10 shadow-lg shadow-warning/10`,!i&&`border-warning/30 bg-warning/6`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,i?`bg-warning/18`:`bg-warning/10`),children:(0,J.jsx)(r,{className:`h-5 w-5`,style:{color:n}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold`,style:{color:n},children:t(`activity:office.mailboxHub`)}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:i?t(`activity:office.unreadSuffix`,{count:e.unreadCount||0}):t(`activity:office.allClear`)})]}),i&&(0,J.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,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-warning`,children:[(0,J.jsx)(_,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e.messageCount||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.total`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-success`,children:[(0,J.jsx)(oe,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e.unreadCount||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.unreadLabel`)})]})]}),e.sublabel&&(0,J.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,J.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,J.jsx)(`span`,{className:V(`font-mono truncate text-right`,n??`text-foreground/80`),children:t})]})}function Tn({selectedNode:e,selectedAgentTranscript:t,mailboxMessages:n,onClose:a,onOpenWatch:o}){let{t:c}=D(),l=e.data,u=Date.now(),d=l.kind===`agent`,f=l.kind===`webui`||l.kind===`tui`||l.kind===`repl`,p=(l.tokensIn||0)+(l.tokensOut||0),h=hn(l.ctxPct);return(0,J.jsxs)(`div`,{className:V(`absolute top-20 right-4 bg-background border border-border rounded-lg p-4 shadow-xl z-20`,l.kind===`agent`?`w-[28rem] max-w-[calc(100%-2rem)]`:l.sessionId?`w-80`:`w-64`),children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l.kind===`webui`&&(0,J.jsx)(s,{className:`h-4 w-4 text-info`}),l.kind===`tui`&&(0,J.jsx)(m,{className:`h-4 w-4 text-success`}),l.kind===`coordinator`&&(0,J.jsx)(N,{className:`h-4 w-4 text-primary`}),l.kind===`agent`&&(0,J.jsx)(i,{className:`h-4 w-4 text-primary`}),l.kind===`mailbox`&&(0,J.jsx)(r,{className:`h-4 w-4 text-warning`}),(0,J.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:l.label})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[l.sessionId&&(0,J.jsx)(`button`,{type:`button`,title:c(`activity:office.openFullView`),onClick:()=>o({sessionId:l.sessionId,label:l.label}),className:`text-muted-foreground hover:text-primary`,children:(0,J.jsx)(xe,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:a,className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,J.jsx)($,{k:`Status`,v:String(l.status).toUpperCase(),accent:V(l.status===`active`&&`text-success`,l.status===`streaming`&&`text-primary`,l.status===`error`&&`text-destructive`,l.status===`idle`&&`text-muted-foreground`,l.status===`offline`&&`text-muted-foreground/70`)}),d&&(0,J.jsxs)(J.Fragment,{children:[l.model&&(0,J.jsx)($,{k:`Model`,v:gt(l.model),accent:`text-primary`}),l.currentTask&&(0,J.jsxs)(`div`,{className:`pt-1`,children:[(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:c(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`div`,{className:`mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap break-words font-mono text-[10px] text-primary`,children:l.currentTask})]}),(0,J.jsx)($,{k:`Iterations`,v:l.iteration||0,accent:`text-primary`}),(0,J.jsx)($,{k:`Tool calls`,v:l.toolCalls||0,accent:`text-warning`}),(0,J.jsx)($,{k:`Tokens in`,v:pt(l.tokensIn)}),(0,J.jsx)($,{k:`Tokens out`,v:pt(l.tokensOut)}),(0,J.jsx)($,{k:`Tokens total`,v:pt(p)}),h>0&&(0,J.jsx)($,{k:`Context`,v:`${h}%`,accent:h>=90?`text-destructive`:h>=70?`text-warning`:`text-foreground/70`}),(0,J.jsx)($,{k:`Cost`,v:`$${(l.costUsd||0).toFixed(4)}`,accent:`text-success`}),l.lastActivityAt&&(0,J.jsx)($,{k:`Last seen`,v:mt(l.lastActivityAt,u),accent:`text-muted-foreground`}),(0,J.jsx)(`div`,{className:`pt-2`,children:(0,J.jsx)(Fe,{entries:t,agentName:l.label,compact:!0,maxHeightClassName:`max-h-64`})})]}),f&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Surface`,v:xt(l.kind),accent:`text-foreground/80`}),l.branch&&(0,J.jsx)($,{k:`Branch`,v:`⎇ ${l.branch}`,accent:`text-foreground/70`}),l.pid!=null&&(0,J.jsx)($,{k:`PID`,v:l.pid}),l.workingDir&&(0,J.jsx)($,{k:`Dir`,v:l.workingDir,accent:`text-muted-foreground`}),(0,J.jsx)($,{k:`Agents`,v:l.agentCount??0,accent:`text-primary`}),l.startedAt&&(0,J.jsx)($,{k:`Uptime`,v:ht(l.startedAt,u),accent:`text-foreground/70`})]}),l.kind===`mailbox`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Total messages`,v:l.messageCount||0,accent:`text-warning`}),(0,J.jsx)($,{k:`Unread`,v:l.unreadCount||0,accent:`text-warning`}),n.length>0&&(0,J.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-border pt-2`,children:[(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:c(`activity:office.recent`)}),[...n].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp)).slice(0,6).map(e=>(0,J.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px]`,children:[(0,J.jsx)(`span`,{className:V(`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,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`truncate text-foreground/80`,children:e.subject||c(`activity:office.noSubject`)}),(0,J.jsxs)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[e.from,` → `,e.to,` · `,mt(e.timestamp,u),e.audience===`leaders`?` · ${c(`activity:mailbox.audienceLeaders`)}`:``]})]})]},e.id))]})]}),l.kind===`coordinator`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Connections`,v:l.connections||0,accent:`text-primary`}),(0,J.jsx)($,{k:`Iterations`,v:l.iteration||0,accent:`text-primary`})]}),(d||f)&&l.sessionId&&(0,J.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 h-72`,children:(0,J.jsx)(pn,{sessionId:l.sessionId})})]})]})}var En={wire:({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i,targetPosition:a,data:o,selected:s})=>{let c=o?.color||X.primary,l=H(e=>e.animateEdges),u=o?.animated&&l?Math.max(.15,o?.intensity??.6):0,[d,f,p]=ye({sourceX:e,sourceY:t,sourcePosition:i??y.Bottom,targetX:n,targetY:r,targetPosition:a??y.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,J.jsxs)(J.Fragment,{children:[(0,J.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,J.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,J.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:g,to:`0`,dur:_,repeatCount:`indefinite`})}),o?.label&&u>.1&&(0,J.jsx)(de,{children:(0,J.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}=D();return(0,J.jsxs)(J.Fragment,{children:[(0,J.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,J.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendStatus`)}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-success`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendActive`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendIdle`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-destructive`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendError`)})]})]})]}),(0,J.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,J.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendConnections`)}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-warning`,children:`✉`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendMail`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-primary`,children:`→`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendTask`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-success`,children:`●`}),(0,J.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}=D();return(0,J.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,J.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold text-warning`,children:[(0,J.jsx)(_,{className:`h-3.5 w-3.5`}),` `,o(`activity:office.broadcastToAll`)]}),(0,J.jsx)(`button`,{type:`button`,onClick:r,className:`text-base leading-none text-muted-foreground hover:text-foreground`,children:`×`})]}),(0,J.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,J.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:o(`activity:office.broadcastSendHint`)}),(0,J.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,J.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,J.jsxs)(ae,{position:`top-right`,className:`flex items-center gap-2`,children:[(0,J.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,J.jsx)(he,{className:`h-3.5 w-3.5`}),t.arrange]}),(0,J.jsxs)(`button`,{type:`button`,onClick:i,title:t.feedTitle,className:V(`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,J.jsx)(d,{className:`h-3.5 w-3.5`}),t.feed]}),(0,J.jsxs)(`button`,{type:`button`,onClick:r,title:t.broadcastTitle,className:V(`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,J.jsx)(_,{className:`h-3.5 w-3.5`}),t.broadcast]})]})}function An(){return(0,J.jsx)(w,{className:`rounded-lg border border-border/70 bg-card/90`,nodeColor:e=>{switch(e.data.kind){case`coordinator`:return X.primary;case`webui`:return X.info;case`tui`:return X.success;case`repl`:case`mailbox`:return X.warning;default:return X.primary}},maskColor:`hsl(var(--background) / 0.72)`})}function jn({closeTitle:e,label:t,onClose:n,sessionId:r,streamTitle:a}){return(0,J.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,J.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5 shrink-0 bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,J.jsx)(i,{className:`h-4 w-4 text-primary shrink-0`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:t}),(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:a})]})]}),(0,J.jsx)(`button`,{type:`button`,onClick:n,title:e,className:`text-muted-foreground hover:text-foreground text-xl leading-none shrink-0`,children:`×`})]}),(0,J.jsx)(`div`,{className:`flex-1 min-h-0 p-4`,children:(0,J.jsx)(pn,{sessionId:r,limit:500})})]})}function Mn(){let{t:e}=D(),{fitView:t}=k(),n=(0,U.useRef)(null),[r,i]=(0,U.useState)({width:1280,height:720});(0,U.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=Se(e=>e.events),o=Ee(e=>e.agents),s=Ee(e=>e.agentTranscripts),c=Ee(e=>e.leaderId),l=Te(e=>e.liveSessions),u=De(e=>e.messages),d=De(e=>e.agents),f=Ce(e=>e.session),p=jt(o),m=(0,U.useMemo)(()=>Ot(l,o,d,p.map,p.now),[l,o,d,p]),g=H(e=>e.showHud),_=H(e=>e.showLegend),v=H(e=>e.showMinimap),y=H(e=>e.showControls),b=H(e=>e.showFeed),S=H(e=>e.setShowFeed),C=H(e=>e.background),[w,T,ee]=se([]),[ne,O,A]=fe([]),[j,ie]=(0,U.useState)(null),[M,ae]=(0,U.useState)(null),[oe,ce]=(0,U.useState)(!1),[le,ue]=(0,U.useState)(``),[de,N]=(0,U.useState)(!1),[P,F]=(0,U.useState)(null),me=(0,U.useMemo)(()=>{if(j?.data.kind!==`agent`)return we;let e=j.data.serverId??(j.id.includes(`__agent-`)?j.id.split(`__agent-`).pop():j.id.replace(/^agent-/,``));return e?s.get(e)??we:we},[s,j]),he=(0,U.useCallback)(async()=>{let e=le.trim();if(!(!e||de)){N(!0),F(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();ue(``),F(`Delivered to ${n.delivered??0}/${n.targets??0} session(s)`)}catch(e){F(`Failed: ${e instanceof Error?e.message:String(e)}`)}finally{N(!1)}}},[le,de]),ge=(0,U.useRef)(new Map),I=4e3,L=(0,U.useRef)(new Map),R=(0,U.useRef)(new Map),_e=(0,U.useRef)(new Map),ve=(0,U.useRef)(new Map),ye=(0,U.useRef)(``);(0,U.useEffect)(()=>{let n=[],i=[],a=Date.now(),s=vt(m.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:X.warning}});let f=0,p=0,h=0,g=0,_=0;for(let e of m)for(let t of e.agents)p+=1,(t.status===`active`||t.status===`streaming`)&&(f+=1),h+=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:m.length}),kind:`coordinator`,status:v?.status===`failed`?`error`:y?`active`:`idle`,connections:m.length,agentsActive:f,agentsTotal:p,toolCalls:h,costUsd:g,tokensIn:_,color:X.primary}});let b={tui:X.success,webui:X.info,repl:X.warning};for(let t of m){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:X.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:X.muted}});continue}t.agents.forEach((r,s)=>{let l=r.status===`active`||r.status===`streaming`,u=ve.current.get(r.serverId);if(u&&(r.toolCalls>u.toolCalls||r.iteration>u.iteration)||l){ge.current.set(r.officeId,a+I);let e=R.current.get(r.officeId)??0;R.current.set(r.officeId,Math.min(1,e+(1-e)*.5));for(let e of[`${t.id}->${r.officeId}`,`${t.id}->coordinator`]){let t=L.current.get(e)??0;L.current.set(e,Math.min(1,t+.5))}}ve.current.set(r.serverId,{toolCalls:r.toolCalls,iteration:r.iteration}),n.push({id:r.officeId,type:`agent`,position:yt(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:X.primary}}),i.push({id:`${t.id}->${r.officeId}`,source:t.id,target:r.officeId,type:`wire`,animated:l,data:{color:X.primary,animated:l,label:l?_t(r.currentTask,48)??e(`activity:office.taskFallback`):void 0,flowType:`task`}})})}let x=new Set(m.flatMap(e=>e.agents.map(e=>e.serverId)));for(let e of[...ve.current.keys()])x.has(e)||ve.current.delete(e);let S=n.map(e=>{let t=ge.current.get(e.id),n=R.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=L.current.get(e.id)??0;return t>.05?{...e,animated:!0,data:{...e.data,animated:!0,intensity:t}}:e}),w=new Map;for(let e of S)w.set(e.id,{...e.position});_e.current=w,T(S),O(C);let E=[`${Math.round(r.width)}x${Math.round(r.height)}`,`${s.columns}x${s.rows}`,m.map(e=>`${e.id}:${e.agents.length}`).join(`|`),S.map(e=>e.id).sort().join(`|`)].join(`:`);if(E!==ye.current){ye.current=E;let e=setTimeout(()=>t({padding:mn,duration:300}),50);return()=>clearTimeout(e)}},[m,c,o,u,f,r,I,T,O,t]);let be=m.flatMap(e=>e.agents.map(t=>({clientId:e.id,clientType:e.type,officeId:t.officeId,serverId:t.serverId}))),z=m.map(e=>e.id),xe=new Map;for(let e of be)(!xe.has(e.serverId)||e.clientType===`webui`)&&xe.set(e.serverId,e.officeId);function B(e){return xe.get(e)??`agent-${e}`}function V(e){let t=e.split(`__agent-`)[0];return t&&t!==e?`${t}->${e}`:`coordinator->${e}`}function Oe(e){switch(e.kind){case`mailbox:send`:case`mailbox:deliver`:return{nodes:[`mailbox`],edges:e.kind===`mailbox:send`?z.map(e=>`mailbox->${e}`):[],status:`active`};case`agent:spawned`:{let t=B(e.source);return{nodes:[`coordinator`,t],edges:[V(t)],status:`active`}}case`agent:tool`:case`tool:started`:case`tool:progress`:{let t=B(e.source);return{nodes:[`coordinator`,t],edges:[V(t)],status:e.kind===`tool:progress`||e.kind===`tool:started`?`streaming`:`active`}}case`tool:executed`:{let t=B(e.target??e.source);return{nodes:[t],edges:[V(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:be.map(e=>V(e.officeId)),status:e.kind===`iteration:start`?`streaming`:`active`};case`agent:text`:{let t=B(e.source);return{nodes:[t],edges:[V(t)],status:`streaming`}}case`agent:status`:{let t=B(e.source);return{nodes:[`coordinator`,t],edges:[V(t)],status:e.data&&typeof e.data==`object`&&`status`in e.data&&String(e.data.status)===`failed`?`error`:`completed`}}case`agent:ctx`:return{nodes:[B(e.source)],edges:[],status:`active`};case`budget:extended`:return{nodes:[`coordinator`,B(e.source)],edges:[],status:`active`};case`context:compacted`:case`context:repaired`:return{nodes:[`coordinator`],edges:[],status:`active`};case`error`:return{nodes:e.source?[B(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=B(t.id);n.includes(e)||n.push(e)}return{nodes:n,edges:[],status:`active`}}default:return{nodes:[],edges:[],status:`idle`}}}(0,U.useEffect)(()=>{if(a.length===0)return;let e=a[0];if(!e)return;let{nodes:t,edges:n,status:r}=Oe(e),i=Date.now();t.length>0&&(t.forEach(e=>{ge.current.set(e,i+I);let t=R.current.get(e)??0;R.current.set(e,Math.min(1,t+(1-t)*.5))}),T(e=>e.map(e=>t.includes(e.id)?{...e,data:{...e.data,status:r,vizActivity:R.current.get(e.id)??0}}:e))),n.length>0&&(n.forEach(e=>{let t=L.current.get(e)??0;L.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:L.current.get(e.id)??1}}:e)))},[a,T,O,I,o]),(0,U.useEffect)(()=>{let e=setInterval(()=>{let e=new Map,t=!1;for(let[n,r]of L.current){let i=r*.85;i<.05?(L.current.delete(n),e.set(n,{intensity:0,animated:!1}),t=!0):(L.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 R.current){let i=t*.9;i<.03?(R.current.delete(e),n.set(e,0),r=!0):(R.current.set(e,i),n.set(e,i),r=!0)}r&&T(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,T]);let ke=(0,U.useCallback)(e=>O(t=>E({...e,type:`wire`},t)),[O]),Ae=(0,U.useCallback)((e,t)=>{ie(t)},[]),je=(0,U.useCallback)(()=>{ie(null)},[]);(0,U.useEffect)(()=>{if(!M)return;let e=e=>{e.key===`Escape`&&ae(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[M]);let Me=(0,U.useCallback)(()=>{T(e=>e.map(e=>{let t=_e.current.get(e.id);return t?{...e,position:{...t}}:e})),setTimeout(()=>t({padding:mn,duration:300}),50)},[T,t]),[,Ne]=(0,U.useState)(0);return(0,U.useEffect)(()=>{let e=setInterval(()=>{document.hidden||Ne(e=>e+1)},2e3);return()=>clearInterval(e)},[]),(0,J.jsxs)(`div`,{ref:n,className:`relative h-full w-full overflow-hidden bg-[hsl(var(--surface-2)/0.55)]`,children:[(0,J.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`
|
|
2
2
|
linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
|
|
3
3
|
linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px)
|
|
4
4
|
`,backgroundSize:`40px 40px`}}),g&&(0,J.jsx)(an,{}),(0,J.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-10`,children:(0,J.jsx)(`div`,{className:`rounded-lg border border-border/70 bg-card/90 px-4 py-2 shadow-xl backdrop-blur`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold text-foreground`,children:[(0,J.jsx)(h,{className:`h-4 w-4 text-primary`}),e(`activity:office.fleetHq`),(0,J.jsx)(`span`,{className:`ml-2 h-2 w-2 animate-pulse rounded-full bg-success`}),(0,J.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:e(`activity:office.live`)})]})})}),_&&(0,J.jsx)(Dn,{}),(0,J.jsxs)(te,{nodes:w,edges:ne,onNodesChange:ee,onEdgesChange:A,onConnect:ke,onNodeClick:Ae,onPaneClick:je,nodeTypes:wn,edgeTypes:En,fitView:!0,fitViewOptions:{padding:mn},minZoom:.15,maxZoom:1.5,defaultEdgeOptions:{type:`wire`},proOptions:{hideAttribution:!0},children:[(0,J.jsx)(kn,{broadcastOpen:oe,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:Me,onBroadcastToggle:()=>ce(e=>!e),onFeedToggle:()=>S(!b),showFeed:b}),C!==`none`&&(0,J.jsx)(pe,{variant:C===`lines`?re.Lines:C===`cross`?re.Cross:re.Dots,gap:20,size:1,color:`hsl(var(--border) / 0.35)`}),y&&(0,J.jsx)(x,{className:`rounded-lg border border-border/70 bg-card/90 [&>button]:bg-card [&>button]:text-foreground`}),v&&(0,J.jsx)(An,{})]}),b&&(0,J.jsx)(on,{events:a,now:Date.now()}),oe&&(0,J.jsx)(On,{draft:le,isSending:de,result:P,onClose:()=>ce(!1),onDraftChange:ue,onSend:()=>void he()}),j&&(0,J.jsx)(Tn,{selectedNode:j,selectedAgentTranscript:me,mailboxMessages:u,onClose:je,onOpenWatch:ae}),M&&(0,J.jsx)(jn,{closeTitle:e(`activity:office.closeEsc`),label:M.label,onClose:()=>ae(null),sessionId:M.sessionId,streamTitle:e(`activity:office.fullOperationStream`)})]})}function Nn(){let{t:e}=D(),t=H(e=>e.viewMode),n=H(e=>e.setViewMode),r=[{id:`office`,label:e(`activity:agentOffice.office`),description:e(`activity:agentOffice.officeDescription`),icon:C},{id:`topology`,label:e(`activity:agentOffice.topology`),description:e(`activity:agentOffice.topologyDescription`),icon:l}],i=(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,J.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col bg-background`,children:[(0,J.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,J.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 a=e.icon,o=t===e.id;return(0,J.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=>i(e,r),className:V(`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,J.jsx)(`span`,{className:V(`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,J.jsx)(a,{className:`h-4 w-4`,"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`strong`,{className:`block truncate font-display text-xs font-semibold sm:text-sm`,children:e.label}),(0,J.jsx)(`small`,{className:`hidden truncate font-mono text-[9px] font-normal text-muted-foreground sm:block`,children:e.description})]}),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:V(`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,J.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,J.jsx)(rn,{}):(0,J.jsx)(_e,{children:(0,J.jsx)(Mn,{})})})]})}export{Nn as OfficeMapPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bt as t,Mt as n,Tt as r,et as i,ga as a,xa as o}from"./vendor-9hC4n4Me.js";import"./i18n-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bt as t,Mt as n,Tt as r,et as i,ga as a,xa as o}from"./vendor-9hC4n4Me.js";import"./i18n-D-JnOQZX.js";import{t as s}from"./useWebSocket-DAm5zYOB.js";import{t as c}from"./utils-DzRQUvln.js";import{M as l}from"./stores-hEu6z1qz.js";import{n as u,o as d,r as f,t as p}from"./dialog-BLr7olIX.js";var m=e(o(),1),h=i();function g({open:e,onClose:i,className:o}){let{t:g}=a(),[_,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||i()},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)(n,{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)(t,{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)(n,{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-DaSs2P3S.js";import{Ct as n,Xn as r,at as i,et as a,ga as o,la as s,ra as c,xa as l}from"./vendor-9hC4n4Me.js";import"./i18n-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-DaSs2P3S.js";import{Ct as n,Xn as r,at as i,et as a,ga as o,la as s,ra as c,xa as l}from"./vendor-9hC4n4Me.js";import"./i18n-D-JnOQZX.js";import{t as u}from"./utils-DzRQUvln.js";import"./stores-hEu6z1qz.js";import{n as d,o as f,r as p,t as m}from"./dialog-BLr7olIX.js";var h=e(l(),1),g=a(),_={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 v({open:e,onClose:a,className:l}){let{t:v}=o(),y=t(e=>e.queue),b=t(e=>e.removeQueued),x=t(e=>e.clearQueue),[S,C]=(0,h.useState)(`oldest`),w=(0,h.useCallback)(e=>{b(e)},[b]),T=(0,h.useMemo)(()=>{let e=y.map((e,t)=>({item:e,sourceIdx:t}));return e.sort((e,t)=>S===`newest`?t.item.addedAt-e.item.addedAt:e.item.addedAt-t.item.addedAt),e},[y,S]);return(0,g.jsx)(m,{open:e,onOpenChange:e=>{e||a()},children:(0,g.jsxs)(d,{className:u(`max-w-lg gap-0 overflow-hidden border-border/80 bg-card p-0 pt-[10dvh] flex flex-col max-h-[70dvh]`,l),showCloseButton:!1,children:[(0,g.jsx)(f,{className:`sr-only`,children:v(`activity:queue.heading`)}),(0,g.jsx)(p,{className:`sr-only`,children:v(`activity:queue.subtitle`,{count:y.length})}),(0,g.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/95 px-4 py-3 shrink-0`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,g.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,g.jsx)(r,{className:`h-4 w-4`})}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold`,children:v(`activity:queue.heading`)}),(0,g.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:v(`activity:queue.subtitle`,{count:y.length})})]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,g.jsxs)(`button`,{type:`button`,onClick:()=>C(e=>e===`newest`?`oldest`:`newest`),className:u(`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:v(S===`newest`?`activity:queue.sortNewestTitle`:`activity:queue.sortOldestTitle`),"data-testid":`queue-sort-toggle`,children:[S===`newest`?(0,g.jsx)(s,{className:`h-3 w-3`}):(0,g.jsx)(c,{className:`h-3 w-3`}),v(S===`newest`?`activity:queue.newest`:`activity:queue.oldest`)]}),y.length>0&&(0,g.jsxs)(`button`,{type:`button`,onClick:()=>x(),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:v(`activity:queue.clearTitle`),"data-testid":`queue-clear-all`,children:[(0,g.jsx)(n,{className:`h-3 w-3`}),v(`activity:queue.clear`)]})]})]}),(0,g.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:y.length===0?(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,g.jsx)(r,{className:`h-10 w-10 opacity-15`}),(0,g.jsx)(`p`,{className:`text-sm font-medium`,children:v(`activity:queue.emptyTitle`)}),(0,g.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:v(`activity:queue.emptyBody`)})]}):(0,g.jsx)(`ul`,{className:`divide-y divide-border/60`,"data-testid":`queue-list`,children:T.map(({item:e,sourceIdx:t},n)=>{let r=_[e.mode];return(0,g.jsxs)(`li`,{className:`flex items-start justify-between gap-3 px-4 py-3 text-xs transition-colors hover:bg-muted/35`,"data-testid":`queue-item`,children:[(0,g.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0 flex-1`,children:[(0,g.jsxs)(`span`,{className:`mt-1 text-[10px] font-mono text-muted-foreground shrink-0 w-5 text-right tabular-nums`,children:[n+1,`.`]}),(0,g.jsx)(`span`,{className:u(`shrink-0 inline-flex items-center justify-center rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,r.tone),title:v(`activity:queue.${r.titleKey}`),"data-testid":`queue-mode-${e.mode}`,children:r.label}),(0,g.jsx)(`p`,{className:`text-sm text-foreground leading-relaxed min-w-0 break-words`,children:e.text.length>120?`${e.text.slice(0,117)}…`:e.text})]}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>w(t),className:`ml-1 p-1.5 rounded-md shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors`,title:v(`activity:queue.removeTitle`),"data-testid":`queue-remove-${t}`,children:(0,g.jsx)(i,{className:`h-3.5 w-3.5`})})]},`${e.addedAt}-${t}`)})})}),y.length>0&&(0,g.jsx)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-2.5 shrink-0`,children:(0,g.jsx)(`p`,{className:`text-[10px] text-muted-foreground text-center`,children:v(`activity:queue.footer`)})})]})})}export{v as QueuePanel};
|