@cotal-ai/web 0.163.3 → 0.163.5

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.
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$t as t,B as n,C as r,G as i,Gt as a,Ht as o,I as s,Ir as c,J as l,K as u,L as d,M as ee,Pr as f,S as p,Sr as m,T as h,U as g,Vt as _,W as v,Wt as y,Xn as b,Y as te,Zt as ne,_ as x,a as S,at as C,b as w,br as re,bt as T,c as ie,cn as E,d as D,dr as ae,dt as oe,en as se,fn as O,ft as ce,g as le,gr as k,h as ue,i as de,in as A,ir as fe,it as pe,jr as me,l as j,ln as he,lt as ge,m as _e,mt as ve,nt as ye,o as M,pt as N,q as P,r as be,rn as xe,s as Se,st as Ce,tn as we,tr as F,u as Te,un as I,ur as Ee,v as L,w as De,wr as Oe,x as R,xt as z,y as B,yr as ke}from"./controller-ClpgDx0y.js";var Ae=[[`path`,{d:`M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],V=[[`path`,{d:`M7.5 7.5L8.72654 8.55719C9.24218 9.00163 9.5 9.22386 9.5 9.5C9.5 9.77614 9.24218 9.99836 8.72654 10.4428L7.5 11.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M11.5 12.5H15.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M12 21C15.7497 21 17.6246 21 18.9389 20.0451C19.3634 19.7367 19.7367 19.3634 20.0451 18.9389C21 17.6246 21 15.7497 21 12C21 8.25027 21 6.3754 20.0451 5.06107C19.7367 4.6366 19.3634 4.26331 18.9389 3.95491C17.6246 3 15.7497 3 12 3C8.25027 3 6.3754 3 5.06107 3.95491C4.6366 4.26331 4.26331 4.6366 3.95491 5.06107C3 6.3754 3 8.25027 3 12C3 15.7497 3 17.6246 3.95491 18.9389C4.26331 19.3634 4.6366 19.7367 5.06107 20.0451C6.3754 21 8.25027 21 12 21Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],H=[[`circle`,{cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M9.38886 15.1629C9.89331 15.5 10.5955 15.5 12 15.5C13.4045 15.5 14.1067 15.5 14.6111 15.1629C14.8295 15.017 15.017 14.8295 15.1629 14.6111C15.5 14.1067 15.5 13.4045 15.5 12C15.5 10.5955 15.5 9.89331 15.1629 9.38886C15.017 9.17048 14.8295 8.98298 14.6111 8.83706C14.1067 8.5 13.4045 8.5 12 8.5C10.5955 8.5 9.89331 8.5 9.38886 8.83706C9.17048 8.98298 8.98298 9.17048 8.83706 9.38886C8.5 9.89331 8.5 10.5955 8.5 12C8.5 13.4045 8.5 14.1067 8.83706 14.6111C8.98298 14.8295 9.17048 15.017 9.38886 15.1629Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],U=e(c(),1),W=b();function G({icon:e,title:t,children:n,action:r}){return(0,W.jsxs)(g,{children:[(0,W.jsxs)(u,{children:[(0,W.jsx)(P,{variant:`icon`,children:(0,W.jsx)(z,{icon:e})}),(0,W.jsx)(l,{children:t}),n&&(0,W.jsx)(i,{children:n})]}),r&&(0,W.jsx)(v,{children:r})]})}var K=e=>Number.isFinite(e.ts)?e.ts:-1/0;function je(e){let t=new Map;for(let{msg:n}of e){let e=typeof n.channel==`string`?n.channel:void 0,r=e===void 0&&typeof n.to==`string`?n.to:void 0;if(e===void 0&&r===void 0)continue;let i=e===void 0?`dm:${r}`:`channel:${e}`,a=t.get(i);a||t.set(i,a={key:i,...e===void 0?{to:r}:{channel:e},rows:[]}),a.rows.push(n)}let n=[...t.values()];for(let e of n)e.rows.sort((e,t)=>K(t)-K(e));return n.sort((e,t)=>K(t.rows[0])-K(e.rows[0]))}function q({msg:e,row:t,place:n,href:r,label:i}){let a=s();return(0,W.jsxs)(`div`,{className:`ui-msg ox-msg`,"data-post":e.id,children:[(0,W.jsx)(`div`,{className:`ui-gut`,children:(0,W.jsx)(d,{vendor:t.harness,status:t.status,size:34,dot:!1,badge:a(t.id)})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`ui-mh`,children:[(0,W.jsx)(`b`,{children:t.name}),(0,W.jsx)(T,{variant:`secondary`,children:n}),(0,W.jsx)(S,{ts:e.ts}),(0,W.jsx)(`span`,{className:`ui-sp`}),(0,W.jsxs)(`a`,{className:`ox-act`,href:r,children:[i,(0,W.jsx)(z,{icon:he,size:16})]})]}),(0,W.jsx)(M,{className:`ui-tx`,src:Oe(e.parts)})]})]})}function Me({groups:e,row:t,nameOf:n}){return(0,W.jsxs)(`div`,{className:`ox-msgs`,children:[e.length===0&&(0,W.jsx)(G,{icon:E,title:`No messages from ${t.name} on this page yet`}),e.map(e=>{let i=e.rows.length;if(e.channel!==void 0){let n=e.channel,a=k({view:`channel`,channel:n});return(0,W.jsxs)(`section`,{className:`ox-msg-group`,children:[(0,W.jsxs)(R,{className:`ox-marker`,children:[(0,W.jsx)(r,{children:(0,W.jsx)(z,{icon:A,size:16})}),(0,W.jsxs)(p,{children:[(0,W.jsx)(`b`,{children:`#${n}`}),` · ${i===1?`1 post`:`${i} posts`}`]})]}),e.rows.map(e=>(0,W.jsx)(q,{msg:e,row:t,place:`in #${n}`,href:a,label:`Open in #${n}`},e.id))]},e.key)}let a=e.to??``,o=n(a),s=k({view:`dm`,peer:t.id,with:a});return(0,W.jsxs)(`section`,{className:`ox-msg-group`,children:[(0,W.jsxs)(R,{className:`ox-marker`,children:[(0,W.jsx)(r,{children:(0,W.jsx)(z,{icon:E,size:16})}),(0,W.jsxs)(p,{children:[(0,W.jsx)(`b`,{children:`Direct messages`}),` · ${i} with ${o}`]})]}),e.rows.map(e=>(0,W.jsx)(q,{msg:e,row:t,place:`to ${o}`,href:s,label:`Open conversation`},e.id))]},e.key)}),(0,W.jsx)(`p`,{className:`ox-msgs-more`,children:`Older messages are in each channel's history.`})]})}var J=1e3,Y={on:`Published. Tool names, status and times only.`,off:`Not published`};function Ne({store:e,id:t,clock:r=Date.now}){let i=F(e,e=>e.roster),a=F(e,e=>e.channels),o=F(e,e=>e.membership),c=F(e,e=>e.activity),[,l]=(0,U.useReducer)(e=>e+1,0);(0,U.useEffect)(()=>{let e=setInterval(l,J);return()=>clearInterval(e)},[]);let u=s(),p=i.find(e=>e.card.id===t),h=(0,U.useMemo)(()=>p?te(t,o,a.map(e=>e.channel),c,p.channelModes):{channels:[],wide:!1},[p,t,o,a,c]);if(!p)return(0,W.jsx)(`p`,{className:`ui-nr`,children:`Not on the roster`});let g=fe([p],{includeOffline:!0})[0],_=typeof g.statusSince==`number`&&Number.isFinite(g.statusSince)?`Reported ${m(new Date(g.statusSince))}`:void 0,v=(p.card.skills??[]).map(e=>e.name).filter(e=>typeof e==`string`&&e!==``);return(0,W.jsxs)(`div`,{className:`ox-profile`,children:[(0,W.jsx)(`div`,{className:`ui-big`,children:(0,W.jsx)(d,{vendor:g.harness,status:g.status,size:88,dot:!1,badge:u(g.id)})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`ui-sline`,children:[(0,W.jsx)(n,{row:g}),(0,W.jsx)(`span`,{style:{color:`var(--ink)`},children:g.activity||`No current activity`}),_&&(0,W.jsx)(`small`,{children:_}),B(g,r())&&(0,W.jsx)(`small`,{className:`ui-facts`,children:B(g,r())})]}),(0,W.jsxs)(`div`,{className:`ui-actions`,children:[(0,W.jsx)(C,{icon:V,command:`cotal attach --name ${f(g.name)}`}),(0,W.jsx)(C,{icon:H,command:`cotal stop --name ${f(g.name)}`})]}),(0,W.jsxs)(`dl`,{className:`ui-kv`,children:[g.harness&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`Harness`}),(0,W.jsx)(`dd`,{children:ee(g.harness)})]}),(0,W.jsx)(`dt`,{children:`Model`}),g.model?(0,W.jsx)(`dd`,{className:`ui-mono`,style:{fontSize:12.5},children:g.model}):(0,W.jsx)(`dd`,{className:`ui-nr`,children:`not reported`}),g.host&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`Host`}),(0,W.jsx)(`dd`,{children:g.host})]}),(g.attention===`dnd`||g.attention===`focus`)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`Attention`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(x,{attention:g.attention})})]}),(0,W.jsx)(`dt`,{children:`Heartbeat`}),Number.isFinite(g.ts)?(0,W.jsxs)(`dd`,{className:`ui-num`,children:[w(r()-g.ts),` ago`]}):(0,W.jsx)(`dd`,{className:`ui-nr`,children:`not reported`}),(0,W.jsx)(`dt`,{children:`Work events`}),g.events?(0,W.jsx)(`dd`,{children:Y[g.events]}):(0,W.jsx)(`dd`,{className:`ui-nr`,children:`not reported`})]}),(h.wide||h.channels.length>0)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h5`,{children:`Channels`}),h.wide&&(0,W.jsxs)(`div`,{className:`ui-chrow`,children:[(0,W.jsx)(`span`,{children:`Reads every channel`}),(0,W.jsx)(`span`,{})]}),h.channels.map(e=>(0,W.jsxs)(`div`,{className:`ui-chrow`,children:[(0,W.jsx)(`span`,{children:`#${e.channel}`}),(0,W.jsx)(`span`,{children:e.mode??``})]},e.channel))]}),v.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h5`,{style:{marginTop:10},children:`Skills`}),(0,W.jsx)(`div`,{className:`ui-tags`,children:v.map(e=>(0,W.jsx)(T,{variant:`secondary`,children:e},e))})]})]})]})}var Pe=24,Fe=[];function Ie(e){return e.items.flatMap(e=>e.kind===`turn`?[e,...e.steps]:[e]).flatMap(e=>[{key:e.key,live:e.live,...e.kind===`post`?{post:e.msg.id}:{}},...e.kind===`tools`?e.calls.slice(1).map(e=>({key:e.key,live:e.live})):[]])}function Le(){let e=e=>(0,W.jsx)(a,{className:`h-2.5`,style:{width:e}});return(0,W.jsx)(`div`,{className:`ox-col`,"aria-busy":`true`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-hidden":`true`,children:[e(`36%`),e(`88%`),e(`64%`),e(`42%`),e(`30%`),e(`76%`)]})})}function Re({steps:e,away:t}){let{end:n}=ve(),{scrollToEnd:r}=N(),[i,a]=(0,U.useState)(null),o=n||t;o&&i===null&&a(new Set(e.map(e=>e.key))),!o&&i!==null&&a(null);let s=i?e.filter(e=>e.live&&!i.has(e.key)).length:0;return s===0?null:(0,W.jsxs)(O,{type:`button`,variant:`outline`,size:`sm`,className:`ox-newsteps`,"data-active":`true`,onClick:()=>r({behavior:L()?`auto`:`smooth`}),children:[(0,W.jsx)(z,{icon:I,"data-icon":`inline-start`}),s===1?`1 new step`:`${s} new steps`]})}function X({store:e,controller:r,id:i,tab:a,at:c,back:l,phone:u=!1,panelOpen:f=!1,onTogglePanel:m}){le(r,i);let g=(0,U.useContext)(be),v=F(e,e=>e.roster),b=F(e,e=>e.operatorId),te=F(e,e=>e.post),x=F(e,e=>e.sessions[i]),S=(0,U.useMemo)(()=>ae(v),[v]),w=v.find(e=>e.card.id===i),T=(0,U.useMemo)(()=>w?fe([w],{includeOffline:!0})[0]:void 0,[w]),E=T?.name??Ee(i,S,b),A=T??{id:i,name:E,status:`offline`,ts:NaN},he=(0,U.useMemo)(()=>_e(w),[w]),ve=s(),M=x?.frames??Fe,N=ue(e,i),P=(0,U.useMemo)(()=>re(M,N),[M,N]),I=(0,U.useMemo)(()=>Ie(P),[P]),L=(0,U.useMemo)(()=>je(N),[N]),Oe=L.reduce((e,t)=>e+t.rows.length,0),B=(0,U.useMemo)(()=>e=>Ee(e,S,b),[S,b]),V=(0,U.useMemo)(()=>({kind:`dm`,to:i}),[i]),H=[T?.role,T?.harness&&ee(T.harness)].filter(Boolean).join(` · `),K=T?.events,q=x?.load??`loading`,[J,Y]=(0,U.useState)(!0);a!==`work`&&!J&&Y(!0);let X=(0,U.useRef)(null),ze=()=>X.current,Be=()=>{let e=ze();!J&&e&&e.scrollHeight-e.scrollTop-e.clientHeight<=Pe&&Y(!0)},Z=(0,U.useRef)(void 0),Ve=c!==void 0&&I.some(e=>e.post===c);(0,U.useLayoutEffect)(()=>{if(!Ve||c===void 0||Z.current===c||q===`loading`)return;let e=ze();if(!e)return;let t=Array.from(e.querySelectorAll(`[data-post]`)).find(e=>e.getAttribute(`data-post`)===c);t&&(Z.current=c,Y(!1),t.scrollIntoView?.({block:`center`}))});let He=ke(M)>=2e3||(x?.limit??0)>=2e3,Ue=x?.more===!0&&K!==`off`,We=f?`Close panel`:`Open panel`,Q=`Back to ${l.label}`,Ge=k(me(i,b)),Ke=()=>pe(V),$=(0,W.jsx)(de,{work:P,row:A,condition:he,highlight:c,nameOf:B}),qe;return qe=q===`loading`&&I.length===0?(0,W.jsx)(Le,{}):q===`refused`?(0,W.jsxs)(`div`,{className:`ox-col`,children:[(0,W.jsxs)(G,{icon:t,title:`This dashboard can't read ${E}'s work`,action:x?.grant&&(0,W.jsx)(C,{command:x.grant}),children:[(0,W.jsx)(`p`,{children:`The broker refused it: ${x?.reason??``}.`}),x?.grant&&(0,W.jsx)(`p`,{children:`The mesh owner can grant a read on that channel:`})]}),I.length>0&&$]}):q===`failed`&&I.length===0?(0,W.jsx)(`div`,{className:`ox-col`,children:(0,W.jsx)(G,{icon:xe,title:`${E}'s work didn't load`,action:(0,W.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r?.reloadSession(i),children:`Try again`}),children:(0,W.jsx)(`p`,{children:x?.reason??``})})}):K===`off`&&q!==`failed`?(0,W.jsxs)(`div`,{className:`ox-col`,children:[(0,W.jsxs)(Se,{children:[`${E} publishes no work events, so Work shows only what ${E} posted. Agents started with `,(0,W.jsx)(`code`,{children:`cotal spawn`}),` publish them unless started with `,(0,W.jsx)(`code`,{children:`--no-events`}),`.`]}),$]}):I.length===0&&K===`on`?(0,W.jsx)(`div`,{className:`ox-col`,children:(0,W.jsx)(G,{icon:ne,title:`${E} hasn't started a turn yet`,children:(0,W.jsx)(`p`,{children:`Its first turn shows here as soon as it starts.`})})}):I.length===0?(0,W.jsx)(`div`,{className:`ox-col`,children:(0,W.jsx)(G,{icon:xe,title:`Nothing has arrived from ${E} yet`,children:(0,W.jsxs)(`p`,{children:[`Agents started with `,(0,W.jsx)(`code`,{children:`cotal spawn`}),` publish one unless started with `,(0,W.jsx)(`code`,{children:`--no-events`}),`. An agent you started yourself may not publish one at all.`]})})}):(0,W.jsxs)(`div`,{className:`ox-col`,children:[q===`failed`&&(0,W.jsx)(Se,{action:(0,W.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r?.reloadSession(i),children:`Try again`}),children:`${E}'s work didn't load. ${x?.reason??``}`}),Ue&&!He&&(0,W.jsx)(R,{variant:`separator`,className:`mb-3`,children:(0,W.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:q===`loading`,onClick:()=>void r?.loadEarlier(i),children:`Load earlier`})}),Ue&&He&&(0,W.jsx)(R,{className:`mb-3`,children:(0,W.jsx)(p,{children:`Showing the newest 2,000 events`})}),q===`loading`&&(0,W.jsx)(R,{className:`mb-3`,role:`status`,children:(0,W.jsx)(p,{children:`Loading`})}),$]}),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`header`,{className:`ox-head`,children:[(0,W.jsx)(De,{}),u?(0,W.jsxs)(_,{children:[(0,W.jsx)(y,{asChild:!0,children:(0,W.jsx)(O,{asChild:!0,variant:`ghost`,size:`icon`,children:(0,W.jsx)(`a`,{href:k(l.route),"aria-label":Q,children:(0,W.jsx)(z,{icon:Ae})})})}),(0,W.jsx)(o,{children:Q})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(_,{children:[(0,W.jsx)(y,{asChild:!0,children:(0,W.jsxs)(`a`,{className:`ui-crumb`,href:k(l.route),"aria-label":Q,children:[(0,W.jsx)(z,{icon:Ae,size:16,className:`ui-ic`}),l.label]})}),(0,W.jsx)(o,{children:Q})]}),(0,W.jsx)(`span`,{className:`ox-sep`})]}),(0,W.jsx)(d,{vendor:T?.harness,status:A.status,size:30,badge:T?ve(i):void 0}),(0,W.jsx)(`h1`,{children:E}),!u&&H&&(0,W.jsx)(`span`,{className:`ui-topic`,children:H}),T&&(0,W.jsx)(n,{row:T}),(0,W.jsx)(`span`,{className:`ui-sp`}),u?(0,W.jsxs)(_,{children:[(0,W.jsx)(y,{asChild:!0,children:(0,W.jsx)(O,{asChild:!0,variant:`ghost`,size:`icon`,children:(0,W.jsx)(`a`,{href:Ge,"aria-label":`Message ${E}`,onClick:Ke,children:(0,W.jsx)(z,{icon:we})})})}),(0,W.jsx)(o,{children:`Message ${E}`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(O,{asChild:!0,variant:`outline`,size:`sm`,children:(0,W.jsxs)(`a`,{href:Ge,onClick:Ke,children:[(0,W.jsx)(z,{icon:we,"data-icon":`inline-start`}),`Message`]})}),m&&(0,W.jsxs)(_,{children:[(0,W.jsx)(y,{asChild:!0,children:(0,W.jsx)(h,{"aria-label":We,pressed:f,onPressedChange:m,children:(0,W.jsx)(z,{icon:se})})}),(0,W.jsx)(o,{children:We})]})]})]}),(0,W.jsxs)(ie,{value:a,activationMode:`manual`,onValueChange:e=>(e===`work`||e===`messages`||e===`profile`)&&g({view:`agent`,id:i,tab:e}),className:`ox-tabs`,children:[(0,W.jsx)(`div`,{className:`ox-tablist`,children:(0,W.jsxs)(Te,{"aria-label":E,children:[(0,W.jsx)(D,{value:`work`,children:`Work`}),(0,W.jsxs)(D,{value:`messages`,children:[`Messages `,(0,W.jsx)(`span`,{className:`ox-n`,children:Oe})]}),(0,W.jsx)(D,{value:`profile`,children:`Profile`})]})}),(0,W.jsx)(j,{value:`work`,className:`ox-tabc`,children:(0,W.jsx)(oe,{autoScroll:J,children:(0,W.jsxs)(Ce,{className:`ox-scroller`,children:[(0,W.jsx)(ce,{ref:X,"aria-label":`Work`,onScroll:Be,children:(0,W.jsx)(ge,{className:`ox-scrollc`,children:qe})}),(0,W.jsx)(Re,{steps:I,away:!J})]})})}),(0,W.jsx)(j,{value:`messages`,className:`ox-tabc`,children:(0,W.jsx)(`div`,{className:`ui-scroll`,children:(0,W.jsx)(`div`,{className:`ox-col`,children:(0,W.jsx)(Me,{groups:L,row:A,nameOf:B})})})}),(0,W.jsx)(j,{value:`profile`,className:`ox-tabc`,children:(0,W.jsx)(`div`,{className:`ui-scroll`,children:(0,W.jsx)(`div`,{className:`ox-col`,children:(0,W.jsx)(Ne,{store:e,id:i})})})})]}),te&&(0,W.jsx)(`div`,{className:`ui-dock`,children:(0,W.jsx)(`div`,{className:`ui-dock-in`,children:(0,W.jsx)(ye,{store:e,target:V,where:E,to:`to ${E} · direct message`})})})]})}export{X as AgentPage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$t as t,B as n,C as r,G as i,Gt as a,Ht as o,I as s,Ir as c,J as l,K as u,L as d,M as ee,Pr as f,S as p,Sr as m,T as h,U as g,Vt as _,W as v,Wt as y,Xn as b,Y as te,Zt as ne,_ as x,a as S,at as C,b as w,br as re,bt as T,c as ie,cn as E,d as D,dr as ae,dt as oe,en as se,fn as O,ft as ce,g as le,gr as k,h as ue,i as de,in as A,ir as fe,it as pe,jr as me,l as j,ln as he,lt as ge,m as _e,mt as ve,nt as ye,o as M,pt as N,q as P,r as be,rn as xe,s as Se,st as Ce,tn as we,tr as F,u as Te,un as I,ur as Ee,v as L,w as De,wr as Oe,x as R,xt as z,y as B,yr as ke}from"./controller-BJZKC9Sf.js";var Ae=[[`path`,{d:`M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],V=[[`path`,{d:`M7.5 7.5L8.72654 8.55719C9.24218 9.00163 9.5 9.22386 9.5 9.5C9.5 9.77614 9.24218 9.99836 8.72654 10.4428L7.5 11.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M11.5 12.5H15.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M12 21C15.7497 21 17.6246 21 18.9389 20.0451C19.3634 19.7367 19.7367 19.3634 20.0451 18.9389C21 17.6246 21 15.7497 21 12C21 8.25027 21 6.3754 20.0451 5.06107C19.7367 4.6366 19.3634 4.26331 18.9389 3.95491C17.6246 3 15.7497 3 12 3C8.25027 3 6.3754 3 5.06107 3.95491C4.6366 4.26331 4.26331 4.6366 3.95491 5.06107C3 6.3754 3 8.25027 3 12C3 15.7497 3 17.6246 3.95491 18.9389C4.26331 19.3634 4.6366 19.7367 5.06107 20.0451C6.3754 21 8.25027 21 12 21Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],H=[[`circle`,{cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M9.38886 15.1629C9.89331 15.5 10.5955 15.5 12 15.5C13.4045 15.5 14.1067 15.5 14.6111 15.1629C14.8295 15.017 15.017 14.8295 15.1629 14.6111C15.5 14.1067 15.5 13.4045 15.5 12C15.5 10.5955 15.5 9.89331 15.1629 9.38886C15.017 9.17048 14.8295 8.98298 14.6111 8.83706C14.1067 8.5 13.4045 8.5 12 8.5C10.5955 8.5 9.89331 8.5 9.38886 8.83706C9.17048 8.98298 8.98298 9.17048 8.83706 9.38886C8.5 9.89331 8.5 10.5955 8.5 12C8.5 13.4045 8.5 14.1067 8.83706 14.6111C8.98298 14.8295 9.17048 15.017 9.38886 15.1629Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],U=e(c(),1),W=b();function G({icon:e,title:t,children:n,action:r}){return(0,W.jsxs)(g,{children:[(0,W.jsxs)(u,{children:[(0,W.jsx)(P,{variant:`icon`,children:(0,W.jsx)(z,{icon:e})}),(0,W.jsx)(l,{children:t}),n&&(0,W.jsx)(i,{children:n})]}),r&&(0,W.jsx)(v,{children:r})]})}var K=e=>Number.isFinite(e.ts)?e.ts:-1/0;function je(e){let t=new Map;for(let{msg:n}of e){let e=typeof n.channel==`string`?n.channel:void 0,r=e===void 0&&typeof n.to==`string`?n.to:void 0;if(e===void 0&&r===void 0)continue;let i=e===void 0?`dm:${r}`:`channel:${e}`,a=t.get(i);a||t.set(i,a={key:i,...e===void 0?{to:r}:{channel:e},rows:[]}),a.rows.push(n)}let n=[...t.values()];for(let e of n)e.rows.sort((e,t)=>K(t)-K(e));return n.sort((e,t)=>K(t.rows[0])-K(e.rows[0]))}function q({msg:e,row:t,place:n,href:r,label:i}){let a=s();return(0,W.jsxs)(`div`,{className:`ui-msg ox-msg`,"data-post":e.id,children:[(0,W.jsx)(`div`,{className:`ui-gut`,children:(0,W.jsx)(d,{vendor:t.harness,status:t.status,size:34,dot:!1,badge:a(t.id)})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`ui-mh`,children:[(0,W.jsx)(`b`,{children:t.name}),(0,W.jsx)(T,{variant:`secondary`,children:n}),(0,W.jsx)(S,{ts:e.ts}),(0,W.jsx)(`span`,{className:`ui-sp`}),(0,W.jsxs)(`a`,{className:`ox-act`,href:r,children:[i,(0,W.jsx)(z,{icon:he,size:16})]})]}),(0,W.jsx)(M,{className:`ui-tx`,src:Oe(e.parts)})]})]})}function Me({groups:e,row:t,nameOf:n}){return(0,W.jsxs)(`div`,{className:`ox-msgs`,children:[e.length===0&&(0,W.jsx)(G,{icon:E,title:`No messages from ${t.name} on this page yet`}),e.map(e=>{let i=e.rows.length;if(e.channel!==void 0){let n=e.channel,a=k({view:`channel`,channel:n});return(0,W.jsxs)(`section`,{className:`ox-msg-group`,children:[(0,W.jsxs)(R,{className:`ox-marker`,children:[(0,W.jsx)(r,{children:(0,W.jsx)(z,{icon:A,size:16})}),(0,W.jsxs)(p,{children:[(0,W.jsx)(`b`,{children:`#${n}`}),` · ${i===1?`1 post`:`${i} posts`}`]})]}),e.rows.map(e=>(0,W.jsx)(q,{msg:e,row:t,place:`in #${n}`,href:a,label:`Open in #${n}`},e.id))]},e.key)}let a=e.to??``,o=n(a),s=k({view:`dm`,peer:t.id,with:a});return(0,W.jsxs)(`section`,{className:`ox-msg-group`,children:[(0,W.jsxs)(R,{className:`ox-marker`,children:[(0,W.jsx)(r,{children:(0,W.jsx)(z,{icon:E,size:16})}),(0,W.jsxs)(p,{children:[(0,W.jsx)(`b`,{children:`Direct messages`}),` · ${i} with ${o}`]})]}),e.rows.map(e=>(0,W.jsx)(q,{msg:e,row:t,place:`to ${o}`,href:s,label:`Open conversation`},e.id))]},e.key)}),(0,W.jsx)(`p`,{className:`ox-msgs-more`,children:`Older messages are in each channel's history.`})]})}var J=1e3,Y={on:`Published. Tool names, status and times only.`,off:`Not published`};function Ne({store:e,id:t,clock:r=Date.now}){let i=F(e,e=>e.roster),a=F(e,e=>e.channels),o=F(e,e=>e.membership),c=F(e,e=>e.activity),[,l]=(0,U.useReducer)(e=>e+1,0);(0,U.useEffect)(()=>{let e=setInterval(l,J);return()=>clearInterval(e)},[]);let u=s(),p=i.find(e=>e.card.id===t),h=(0,U.useMemo)(()=>p?te(t,o,a.map(e=>e.channel),c,p.channelModes):{channels:[],wide:!1},[p,t,o,a,c]);if(!p)return(0,W.jsx)(`p`,{className:`ui-nr`,children:`Not on the roster`});let g=fe([p],{includeOffline:!0})[0],_=typeof g.statusSince==`number`&&Number.isFinite(g.statusSince)?`Reported ${m(new Date(g.statusSince))}`:void 0,v=(p.card.skills??[]).map(e=>e.name).filter(e=>typeof e==`string`&&e!==``);return(0,W.jsxs)(`div`,{className:`ox-profile`,children:[(0,W.jsx)(`div`,{className:`ui-big`,children:(0,W.jsx)(d,{vendor:g.harness,status:g.status,size:88,dot:!1,badge:u(g.id)})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`ui-sline`,children:[(0,W.jsx)(n,{row:g}),(0,W.jsx)(`span`,{style:{color:`var(--ink)`},children:g.activity||`No current activity`}),_&&(0,W.jsx)(`small`,{children:_}),B(g,r())&&(0,W.jsx)(`small`,{className:`ui-facts`,children:B(g,r())})]}),(0,W.jsxs)(`div`,{className:`ui-actions`,children:[(0,W.jsx)(C,{icon:V,command:`cotal attach --name ${f(g.name)}`}),(0,W.jsx)(C,{icon:H,command:`cotal stop --name ${f(g.name)}`})]}),(0,W.jsxs)(`dl`,{className:`ui-kv`,children:[g.harness&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`Harness`}),(0,W.jsx)(`dd`,{children:ee(g.harness)})]}),(0,W.jsx)(`dt`,{children:`Model`}),g.model?(0,W.jsx)(`dd`,{className:`ui-mono`,style:{fontSize:12.5},children:g.model}):(0,W.jsx)(`dd`,{className:`ui-nr`,children:`not reported`}),g.host&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`Host`}),(0,W.jsx)(`dd`,{children:g.host})]}),(g.attention===`dnd`||g.attention===`focus`)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`Attention`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(x,{attention:g.attention})})]}),(0,W.jsx)(`dt`,{children:`Heartbeat`}),Number.isFinite(g.ts)?(0,W.jsxs)(`dd`,{className:`ui-num`,children:[w(r()-g.ts),` ago`]}):(0,W.jsx)(`dd`,{className:`ui-nr`,children:`not reported`}),(0,W.jsx)(`dt`,{children:`Work events`}),g.events?(0,W.jsx)(`dd`,{children:Y[g.events]}):(0,W.jsx)(`dd`,{className:`ui-nr`,children:`not reported`})]}),(h.wide||h.channels.length>0)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h5`,{children:`Channels`}),h.wide&&(0,W.jsxs)(`div`,{className:`ui-chrow`,children:[(0,W.jsx)(`span`,{children:`Reads every channel`}),(0,W.jsx)(`span`,{})]}),h.channels.map(e=>(0,W.jsxs)(`div`,{className:`ui-chrow`,children:[(0,W.jsx)(`span`,{children:`#${e.channel}`}),(0,W.jsx)(`span`,{children:e.mode??``})]},e.channel))]}),v.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h5`,{style:{marginTop:10},children:`Skills`}),(0,W.jsx)(`div`,{className:`ui-tags`,children:v.map(e=>(0,W.jsx)(T,{variant:`secondary`,children:e},e))})]})]})]})}var Pe=24,Fe=[];function Ie(e){return e.items.flatMap(e=>e.kind===`turn`?[e,...e.steps]:[e]).flatMap(e=>[{key:e.key,live:e.live,...e.kind===`post`?{post:e.msg.id}:{}},...e.kind===`tools`?e.calls.slice(1).map(e=>({key:e.key,live:e.live})):[]])}function Le(){let e=e=>(0,W.jsx)(a,{className:`h-2.5`,style:{width:e}});return(0,W.jsx)(`div`,{className:`ox-col`,"aria-busy":`true`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-hidden":`true`,children:[e(`36%`),e(`88%`),e(`64%`),e(`42%`),e(`30%`),e(`76%`)]})})}function Re({steps:e,away:t}){let{end:n}=ve(),{scrollToEnd:r}=N(),[i,a]=(0,U.useState)(null),o=n||t;o&&i===null&&a(new Set(e.map(e=>e.key))),!o&&i!==null&&a(null);let s=i?e.filter(e=>e.live&&!i.has(e.key)).length:0;return s===0?null:(0,W.jsxs)(O,{type:`button`,variant:`outline`,size:`sm`,className:`ox-newsteps`,"data-active":`true`,onClick:()=>r({behavior:L()?`auto`:`smooth`}),children:[(0,W.jsx)(z,{icon:I,"data-icon":`inline-start`}),s===1?`1 new step`:`${s} new steps`]})}function X({store:e,controller:r,id:i,tab:a,at:c,back:l,phone:u=!1,panelOpen:f=!1,onTogglePanel:m}){le(r,i);let g=(0,U.useContext)(be),v=F(e,e=>e.roster),b=F(e,e=>e.operatorId),te=F(e,e=>e.post),x=F(e,e=>e.sessions[i]),S=(0,U.useMemo)(()=>ae(v),[v]),w=v.find(e=>e.card.id===i),T=(0,U.useMemo)(()=>w?fe([w],{includeOffline:!0})[0]:void 0,[w]),E=T?.name??Ee(i,S,b),A=T??{id:i,name:E,status:`offline`,ts:NaN},he=(0,U.useMemo)(()=>_e(w),[w]),ve=s(),M=x?.frames??Fe,N=ue(e,i),P=(0,U.useMemo)(()=>re(M,N),[M,N]),I=(0,U.useMemo)(()=>Ie(P),[P]),L=(0,U.useMemo)(()=>je(N),[N]),Oe=L.reduce((e,t)=>e+t.rows.length,0),B=(0,U.useMemo)(()=>e=>Ee(e,S,b),[S,b]),V=(0,U.useMemo)(()=>({kind:`dm`,to:i}),[i]),H=[T?.role,T?.harness&&ee(T.harness)].filter(Boolean).join(` · `),K=T?.events,q=x?.load??`loading`,[J,Y]=(0,U.useState)(!0);a!==`work`&&!J&&Y(!0);let X=(0,U.useRef)(null),ze=()=>X.current,Be=()=>{let e=ze();!J&&e&&e.scrollHeight-e.scrollTop-e.clientHeight<=Pe&&Y(!0)},Z=(0,U.useRef)(void 0),Ve=c!==void 0&&I.some(e=>e.post===c);(0,U.useLayoutEffect)(()=>{if(!Ve||c===void 0||Z.current===c||q===`loading`)return;let e=ze();if(!e)return;let t=Array.from(e.querySelectorAll(`[data-post]`)).find(e=>e.getAttribute(`data-post`)===c);t&&(Z.current=c,Y(!1),t.scrollIntoView?.({block:`center`}))});let He=ke(M)>=2e3||(x?.limit??0)>=2e3,Ue=x?.more===!0&&K!==`off`,We=f?`Close panel`:`Open panel`,Q=`Back to ${l.label}`,Ge=k(me(i,b)),Ke=()=>pe(V),$=(0,W.jsx)(de,{work:P,row:A,condition:he,highlight:c,nameOf:B}),qe;return qe=q===`loading`&&I.length===0?(0,W.jsx)(Le,{}):q===`refused`?(0,W.jsxs)(`div`,{className:`ox-col`,children:[(0,W.jsxs)(G,{icon:t,title:`This dashboard can't read ${E}'s work`,action:x?.grant&&(0,W.jsx)(C,{command:x.grant}),children:[(0,W.jsx)(`p`,{children:`The broker refused it: ${x?.reason??``}.`}),x?.grant&&(0,W.jsx)(`p`,{children:`The mesh owner can grant a read on that channel:`})]}),I.length>0&&$]}):q===`failed`&&I.length===0?(0,W.jsx)(`div`,{className:`ox-col`,children:(0,W.jsx)(G,{icon:xe,title:`${E}'s work didn't load`,action:(0,W.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r?.reloadSession(i),children:`Try again`}),children:(0,W.jsx)(`p`,{children:x?.reason??``})})}):K===`off`&&q!==`failed`?(0,W.jsxs)(`div`,{className:`ox-col`,children:[(0,W.jsxs)(Se,{children:[`${E} publishes no work events, so Work shows only what ${E} posted. Agents started with `,(0,W.jsx)(`code`,{children:`cotal spawn`}),` publish them unless started with `,(0,W.jsx)(`code`,{children:`--no-events`}),`.`]}),$]}):I.length===0&&K===`on`?(0,W.jsx)(`div`,{className:`ox-col`,children:(0,W.jsx)(G,{icon:ne,title:`${E} hasn't started a turn yet`,children:(0,W.jsx)(`p`,{children:`Its first turn shows here as soon as it starts.`})})}):I.length===0?(0,W.jsx)(`div`,{className:`ox-col`,children:(0,W.jsx)(G,{icon:xe,title:`Nothing has arrived from ${E} yet`,children:(0,W.jsxs)(`p`,{children:[`Agents started with `,(0,W.jsx)(`code`,{children:`cotal spawn`}),` publish one unless started with `,(0,W.jsx)(`code`,{children:`--no-events`}),`. An agent you started yourself may not publish one at all.`]})})}):(0,W.jsxs)(`div`,{className:`ox-col`,children:[q===`failed`&&(0,W.jsx)(Se,{action:(0,W.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r?.reloadSession(i),children:`Try again`}),children:`${E}'s work didn't load. ${x?.reason??``}`}),Ue&&!He&&(0,W.jsx)(R,{variant:`separator`,className:`mb-3`,children:(0,W.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:q===`loading`,onClick:()=>void r?.loadEarlier(i),children:`Load earlier`})}),Ue&&He&&(0,W.jsx)(R,{className:`mb-3`,children:(0,W.jsx)(p,{children:`Showing the newest 2,000 events`})}),q===`loading`&&(0,W.jsx)(R,{className:`mb-3`,role:`status`,children:(0,W.jsx)(p,{children:`Loading`})}),$]}),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`header`,{className:`ox-head`,children:[(0,W.jsx)(De,{}),u?(0,W.jsxs)(_,{children:[(0,W.jsx)(y,{asChild:!0,children:(0,W.jsx)(O,{asChild:!0,variant:`ghost`,size:`icon`,children:(0,W.jsx)(`a`,{href:k(l.route),"aria-label":Q,children:(0,W.jsx)(z,{icon:Ae})})})}),(0,W.jsx)(o,{children:Q})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(_,{children:[(0,W.jsx)(y,{asChild:!0,children:(0,W.jsxs)(`a`,{className:`ui-crumb`,href:k(l.route),"aria-label":Q,children:[(0,W.jsx)(z,{icon:Ae,size:16,className:`ui-ic`}),l.label]})}),(0,W.jsx)(o,{children:Q})]}),(0,W.jsx)(`span`,{className:`ox-sep`})]}),(0,W.jsx)(d,{vendor:T?.harness,status:A.status,size:30,badge:T?ve(i):void 0}),(0,W.jsx)(`h1`,{children:E}),!u&&H&&(0,W.jsx)(`span`,{className:`ui-topic`,children:H}),T&&(0,W.jsx)(n,{row:T}),(0,W.jsx)(`span`,{className:`ui-sp`}),u?(0,W.jsxs)(_,{children:[(0,W.jsx)(y,{asChild:!0,children:(0,W.jsx)(O,{asChild:!0,variant:`ghost`,size:`icon`,children:(0,W.jsx)(`a`,{href:Ge,"aria-label":`Message ${E}`,onClick:Ke,children:(0,W.jsx)(z,{icon:we})})})}),(0,W.jsx)(o,{children:`Message ${E}`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(O,{asChild:!0,variant:`outline`,size:`sm`,children:(0,W.jsxs)(`a`,{href:Ge,onClick:Ke,children:[(0,W.jsx)(z,{icon:we,"data-icon":`inline-start`}),`Message`]})}),m&&(0,W.jsxs)(_,{children:[(0,W.jsx)(y,{asChild:!0,children:(0,W.jsx)(h,{"aria-label":We,pressed:f,onPressedChange:m,children:(0,W.jsx)(z,{icon:se})})}),(0,W.jsx)(o,{children:We})]})]})]}),(0,W.jsxs)(ie,{value:a,activationMode:`manual`,onValueChange:e=>(e===`work`||e===`messages`||e===`profile`)&&g({view:`agent`,id:i,tab:e}),className:`ox-tabs`,children:[(0,W.jsx)(`div`,{className:`ox-tablist`,children:(0,W.jsxs)(Te,{"aria-label":E,children:[(0,W.jsx)(D,{value:`work`,children:`Work`}),(0,W.jsxs)(D,{value:`messages`,children:[`Messages `,(0,W.jsx)(`span`,{className:`ox-n`,children:Oe})]}),(0,W.jsx)(D,{value:`profile`,children:`Profile`})]})}),(0,W.jsx)(j,{value:`work`,className:`ox-tabc`,children:(0,W.jsx)(oe,{autoScroll:J,children:(0,W.jsxs)(Ce,{className:`ox-scroller`,children:[(0,W.jsx)(ce,{ref:X,"aria-label":`Work`,onScroll:Be,children:(0,W.jsx)(ge,{className:`ox-scrollc`,children:qe})}),(0,W.jsx)(Re,{steps:I,away:!J})]})})}),(0,W.jsx)(j,{value:`messages`,className:`ox-tabc`,children:(0,W.jsx)(`div`,{className:`ui-scroll`,children:(0,W.jsx)(`div`,{className:`ox-col`,children:(0,W.jsx)(Me,{groups:L,row:A,nameOf:B})})})}),(0,W.jsx)(j,{value:`profile`,className:`ox-tabc`,children:(0,W.jsx)(`div`,{className:`ui-scroll`,children:(0,W.jsx)(`div`,{className:`ox-col`,children:(0,W.jsx)(Ne,{store:e,id:i})})})})]}),te&&(0,W.jsx)(`div`,{className:`ui-dock`,children:(0,W.jsx)(`div`,{className:`ui-dock-in`,children:(0,W.jsx)(ye,{store:e,target:V,where:E,to:`to ${E} · direct message`})})})]})}export{X as AgentPage};