@wrongstack/webui-hq 0.295.0 → 0.295.1
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/alerts-B1qqqWUr.js +1 -0
- package/dist/assets/brain-CpQB7l6M.js +1 -0
- package/dist/assets/cockpit-C75mdKG0.js +1 -0
- package/dist/assets/{control-S5yrWkvI.js → control-9gbHkIxG.js} +1 -1
- package/dist/assets/{cost-Dv9QJeiN.js → cost-C0gImFmq.js} +1 -1
- package/dist/assets/{fleet-map-DwyIJ9eT.js → fleet-map-ZXyaXmLN.js} +2 -2
- package/dist/assets/{fleet-topology-BvvbVfxl.js → fleet-topology-BsJ5_kT5.js} +7 -7
- package/dist/assets/{icons-DqAimWQw.js → icons-By3Hdl4l.js} +1 -1
- package/dist/assets/index-B7CIS4YI.js +2 -0
- package/dist/assets/index-BwMtTmmk.css +1 -0
- package/dist/assets/{kanban-CCFMWoeJ.js → kanban-B2AFjoqo.js} +1 -1
- package/dist/assets/live-console-Becmkvl_.js +1 -0
- package/dist/assets/{mailbox-BvywYC09.js → mailbox-DaGVP3NU.js} +1 -1
- package/dist/assets/{markdown-CXUACKKT.js → markdown-Gk0ONVoB.js} +1 -1
- package/dist/assets/{settings-CMLIjhdk.js → settings-Do22vzV5.js} +1 -1
- package/dist/assets/{trends-UVxCM20H.js → trends-DeKfDR_M.js} +1 -1
- package/dist/assets/{use-backfilled-events-DsMh9jtv.js → use-backfilled-events-DxtA7tOA.js} +1 -1
- package/dist/assets/{vendor-CQLHN-L-.js → vendor-BZ0LLq_u.js} +1 -1
- package/dist/assets/{worktree-DTw8uGwj.js → worktree-BEg27SYD.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +4 -4
- package/dist/assets/alerts-CCugwgav.js +0 -1
- package/dist/assets/brain-B4c9I7Iz.js +0 -1
- package/dist/assets/cockpit-BNmAUOW3.js +0 -1
- package/dist/assets/index-BzkE5Twh.js +0 -2
- package/dist/assets/index-DK0iHwRK.css +0 -1
- package/dist/assets/live-console-BohkVPBV.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Lt as t}from"./icons-By3Hdl4l.js";import{i as n}from"./markdown-Gk0ONVoB.js";import{f as r,l as i,o as a}from"./index-B7CIS4YI.js";var o=e(t(),1),s=n();function c(){let e=i(r(e=>e.alerts)),[t,n]=(0,o.useState)([]),[c,l]=(0,o.useState)([]);(0,o.useEffect)(()=>{let e=!1,t=()=>{a(`/api/alerts`).then(t=>{e||(n(t.active),l(t.history))}).catch(()=>{})};t();let r=setInterval(t,15e3);return()=>{e=!0,clearInterval(r)}},[]);let u=e.slice(-50).reverse();return(0,s.jsxs)(`div`,{children:[t.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`div`,{className:`hq-card-title`,children:[`Active Alerts (`,t.length,`)`]}),t.map(e=>(0,s.jsxs)(`div`,{className:`hq-card hq-card-severity `+e.severity,children:[(0,s.jsxs)(`div`,{className:`hq-row`,children:[(0,s.jsx)(`span`,{className:`hq-pill `+e.severity,children:e.severity}),(0,s.jsx)(`span`,{className:`hq-text-bright`,children:e.ruleId}),(0,s.jsxs)(`span`,{className:`hq-mono hq-ml-auto hq-text-dim`,children:[`since `,new Date(e.firstFiredAt).toLocaleTimeString()]})]}),(0,s.jsx)(`div`,{className:`hq-row-detail`,children:e.message})]},e.id))]}),(0,s.jsxs)(`div`,{className:`hq-card-title`,children:[`Live Alert Feed (last `,u.length,`)`]}),u.length===0?(0,s.jsx)(`div`,{className:`hq-empty`,children:`No live alerts. Alerts fire when fleet rules trigger (cost, stale, failures).`}):u.map((e,t)=>(0,s.jsxs)(`div`,{className:`hq-card`,children:[(0,s.jsxs)(`div`,{className:`hq-row`,children:[(0,s.jsx)(`span`,{className:`hq-pill `+e.severity,children:e.severity}),(0,s.jsx)(`span`,{className:`hq-mono hq-ml-auto hq-text-dim`,children:new Date(e.timestamp).toLocaleTimeString()})]}),(0,s.jsx)(`div`,{className:`hq-row-detail`,children:e.message})]},t)),(0,s.jsxs)(`div`,{className:`hq-card-title`,children:[`Alert History (`,c.length,`)`]}),(0,s.jsx)(`div`,{className:`hq-card`,children:c.length===0?(0,s.jsx)(`div`,{className:`hq-empty`,children:`No historical alerts.`}):c.slice(-30).reverse().map((e,t)=>(0,s.jsxs)(`div`,{className:`hq-row`,children:[(0,s.jsx)(`span`,{className:`hq-pill `+e.severity,children:e.severity}),(0,s.jsx)(`span`,{className:`hq-mono`,children:e.ruleId}),(0,s.jsx)(`span`,{className:`hq-text-muted`,children:e.message}),(0,s.jsx)(`span`,{className:`hq-mono hq-ml-auto hq-text-dim`,children:new Date(e.lastFiredAt).toLocaleTimeString()})]},t))})]})}export{c as AlertsView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ct as e,Q as t,bt as n,jt as r,s as i,t as a,xt as o}from"./icons-By3Hdl4l.js";import{i as s}from"./markdown-Gk0ONVoB.js";import{t as c}from"./use-backfilled-events-DxtA7tOA.js";var l=s(),u={decision_requested:{label:`Requested`,Icon:o,cls:`info`},decision_answered:{label:`Answered`,Icon:e,cls:`active`},decision_ask_human:{label:`Ask Human`,Icon:t,cls:`warn`},decision_denied:{label:`Denied`,Icon:n,cls:`error`},human_answered:{label:`Human`,Icon:i,cls:`info`},intervention:{label:`Intervention`,Icon:a,cls:`warn`}};function d(){let{events:e,loading:t}=c(`brain.event`,200),n=e.slice(-200).reverse();return n.length===0?(0,l.jsx)(`div`,{className:`hq-empty`,children:t?`Loading brain history…`:`No brain decisions yet. Brain events appear when autonomous consumers (Director, Goal, Eternal) route decisions through the Brain.`}):(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`div`,{className:`hq-card-title`,children:[`Brain Decisions (last `,n.length,`)`]}),n.map(e=>{let t=e.payload,n=u[t.kind]??{label:t.kind,Icon:r,cls:`info`};return(0,l.jsxs)(`div`,{className:`hq-card`,children:[(0,l.jsxs)(`div`,{className:`hq-row`,children:[(0,l.jsx)(n.Icon,{size:15,className:`hq-kind-icon ${n.cls}`}),(0,l.jsx)(`span`,{className:`hq-text-bright`,children:n.label}),t.source!==void 0&&(0,l.jsx)(`span`,{className:`hq-pill info`,children:t.source}),t.risk!==void 0&&(0,l.jsxs)(`span`,{className:`hq-pill ${t.risk===`high`||t.risk===`critical`?`error`:`warn`}`,children:[t.risk,` risk`]}),(0,l.jsx)(`span`,{className:`hq-mono hq-row-time`,children:new Date(t.at).toLocaleTimeString()})]}),t.question!==void 0&&(0,l.jsx)(`div`,{className:`hq-mono hq-row-detail`,children:t.question}),t.decision!==void 0&&(0,l.jsx)(`div`,{className:`hq-row hq-row-detail`,children:(0,l.jsxs)(`span`,{className:`hq-pill active`,children:[`→ `,t.decision]})}),t.detail!==void 0&&(0,l.jsx)(`div`,{className:`hq-mono hq-row-subtle`,children:t.detail}),t.kind===`intervention`&&(0,l.jsxs)(`div`,{className:`hq-row hq-row-detail`,children:[(0,l.jsx)(`span`,{className:`hq-pill warn`,children:t.interventionKind}),(0,l.jsx)(`span`,{className:`hq-pill`,children:t.intervened?`steered`:`observed`})]})]},e.id)})]})}export{d as BrainView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Lt as t,_ as n}from"./icons-By3Hdl4l.js";import{i as r}from"./markdown-Gk0ONVoB.js";import{f as i,l as a,o,s}from"./index-B7CIS4YI.js";var c=e(t(),1),l=r();function u(){let{snapshot:e,alerts:t,selectedClientId:r,connected:u}=a(i(e=>({snapshot:e.snapshot,alerts:e.alerts,selectedClientId:e.selectedClientId,connected:e.connected}))),g=e,_=g?.totals,v=g?.machines??[],y=g?.projects??[],b=g?.clients??[],x=g?.liveSessions??[],S=b.filter(e=>e.capabilities.includes(`control.receive`)),C=r??S[0]?.clientId??null,w=S.find(e=>e.clientId===C)??S[0]??null,[T,E]=(0,c.useState)([]),[D,O]=(0,c.useState)([]),[k,A]=(0,c.useState)(null),[j,M]=(0,c.useState)(null),[N,P]=(0,c.useState)(null),[F,I]=(0,c.useState)(null),[L,R]=(0,c.useState)(null),[z,B]=(0,c.useState)(null);(0,c.useEffect)(()=>{let e=!1,t=()=>{o(`/api/system/health`).then(t=>{e||(R(t),B(null))}).catch(t=>{e||B(t instanceof Error?t.message:String(t))})};t();let n=setInterval(t,3e4);return()=>{e=!0,clearInterval(n)}},[]),(0,c.useEffect)(()=>{let e=!1,t=()=>{o(`/api/alerts`).then(t=>{e||(E(t.active),O(t.history),A(null))}).catch(t=>{e||A(t instanceof Error?t.message:String(t))})};t();let n=setInterval(t,15e3);return()=>{e=!0,clearInterval(n)}},[]);let V=(0,c.useMemo)(()=>{let e=t.slice(-30).reverse().map(e=>({severity:typeof e.severity==`string`?e.severity:`info`,ruleId:e.type??`hq.alert`,message:typeof e.message==`string`?e.message:`Alert envelope received`,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString()})),n=[...T??[],...D??[]].slice(-30).reverse().map(e=>({severity:typeof e.severity==`string`?e.severity:`info`,ruleId:typeof e.ruleId==`string`?e.ruleId:`alert`,message:typeof e.message==`string`?e.message:``,timestamp:typeof e.lastFiredAt==`string`?e.lastFiredAt:typeof e.firstFiredAt==`string`?e.firstFiredAt:new Date().toISOString()})),r=[...e,...n],i=new Set,a=[];for(let e of r){let t=`${e.ruleId}|${e.message}|${e.timestamp}`;if(!i.has(t)&&(i.add(t),a.push(e),a.length>=12))break}return a},[t,T,D]),H=(0,c.useMemo)(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of x){a.status===`active`&&(i+=1);for(let i of a.agents??[])e+=1,i.status===`running`||i.status===`streaming`?t+=1:i.status===`waiting_user`?n+=1:i.status===`error`&&(r+=1)}return{total:e,busy:t,waiting:n,errored:r,activeSessions:i}},[x]),U=(0,c.useMemo)(()=>[...y].sort((e,t)=>t.totalCostUsd-e.totalCostUsd).slice(0,4),[y]);async function W(e){if(w!==null){M(e),P(null),I(null);try{let t=e===`pause-noisy`?{subject:`HQ quick action: pause noisy agents`,body:`HQ operator requests: pause non-critical/noisy agent work, reduce chatter, and keep only essential status updates until resumed.`,priority:`high`}:{subject:`HQ quick action: status request`,body:`HQ operator requests a concise status broadcast from active agents: current task, blocker if any, and next expected action.`,priority:`normal`},n=await s(w.clientId,`broadcast`,t);P(`queued ${n.commandId}`)}catch(e){I(e instanceof Error?e.message:String(e))}finally{M(null)}}}let G=[{title:`Fleet`,view:`fleet`,cta:`open fleet`,body:(0,l.jsxs)(`div`,{className:`hq-cockpit-grid`,children:[(0,l.jsx)(d,{label:`machines`,value:v.length}),(0,l.jsx)(d,{label:`clients`,value:b.length}),(0,l.jsx)(d,{label:`sessions`,value:H.activeSessions,accent:H.activeSessions>0?`green`:void 0}),(0,l.jsx)(d,{label:`agents`,value:H.total}),(0,l.jsx)(d,{label:`busy`,value:H.busy,accent:H.busy>0?`green`:void 0}),(0,l.jsx)(d,{label:`waiting`,value:H.waiting,accent:H.waiting>0?`warn`:void 0}),(0,l.jsx)(d,{label:`errored`,value:H.errored,accent:H.errored>0?`error`:void 0}),(0,l.jsx)(d,{label:`cost $`,value:(_?.totalCostUsd??0).toFixed(2),accent:`green`})]})}],K={title:`Auth Tokens`,view:`settings`,cta:`open settings`,body:(0,l.jsx)(f,{tokenStats:_?.tokenStats})},q={title:`Alerts`,view:`alerts`,cta:`open alerts`,body:V.length===0?(0,l.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:`No alerts in the last few minutes.`}):(0,l.jsx)(`div`,{className:`hq-cockpit-alert-list`,children:V.map((e,t)=>(0,l.jsxs)(`div`,{className:`hq-cockpit-alert-row`,children:[(0,l.jsx)(`span`,{className:`hq-pill `+h(e.severity),children:e.severity}),(0,l.jsx)(`span`,{className:`hq-mono`,children:e.ruleId}),(0,l.jsx)(`span`,{className:`hq-cockpit-alert-msg`,children:e.message}),(0,l.jsx)(`span`,{className:`hq-mono hq-text-dim hq-ml-auto`,children:m(e.timestamp)})]},`${e.ruleId}-${e.timestamp}-${t}`))})},J={title:`Cost`,view:`cost`,cta:`open cost`,body:U.length===0?(0,l.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:`No cost data yet — connect some clients.`}):(0,l.jsx)(`div`,{className:`hq-cockpit-cost-list`,children:U.map(e=>{let t=(_?.totalCostUsd??0)>0?e.totalCostUsd/_.totalCostUsd*100:0;return(0,l.jsxs)(`div`,{className:`hq-cockpit-cost-row`,children:[(0,l.jsxs)(`div`,{className:`hq-cockpit-cost-line`,children:[(0,l.jsx)(`span`,{className:`hq-cockpit-cost-name`,children:e.projectName}),(0,l.jsx)(`span`,{className:`hq-mono hq-text-dim`,children:e.projectId}),(0,l.jsxs)(`span`,{className:`hq-mono hq-cockpit-cost-amount hq-ml-auto`,children:[`$`,e.totalCostUsd.toFixed(4)]}),(0,l.jsxs)(`span`,{className:`hq-mono hq-text-dim`,children:[t.toFixed(1),`%`]})]}),(0,l.jsx)(`div`,{className:`hq-cockpit-cost-bar`,role:`progressbar`,"aria-label":`${e.projectName} share of fleet cost`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Number(t.toFixed(1)),children:(0,l.jsx)(`span`,{style:{width:`${Math.max(2,t)}%`}})}),(0,l.jsxs)(`div`,{className:`hq-cockpit-cost-meta`,children:[(0,l.jsxs)(`span`,{children:[e.activeSessions,` sessions`]}),(0,l.jsxs)(`span`,{children:[e.activeSubagents,` subagents`]}),(0,l.jsxs)(`span`,{children:[e.activeClients,` clients`]})]})]},e.projectId)})})};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`hq-card-title`,children:`Cockpit`}),(0,l.jsxs)(`div`,{className:`hq-card hq-cockpit-summary`,children:[(0,l.jsxs)(`div`,{className:`hq-row`,children:[(0,l.jsx)(`span`,{className:`hq-pill info`,children:u?`connected`:`reconnecting`}),(0,l.jsxs)(`span`,{className:`hq-pill`,children:[_?.activeMachines??0,` machines`]}),(0,l.jsxs)(`span`,{className:`hq-pill`,children:[_?.activeSessions??0,` sessions`]}),(0,l.jsxs)(`span`,{className:`hq-pill`,children:[_?.activeAgents??0,` agents`]}),(0,l.jsxs)(`span`,{className:`hq-pill green`,children:[`$`,(_?.totalCostUsd??0).toFixed(2)]}),(T?.length??0)>0&&(0,l.jsxs)(`span`,{className:`hq-pill error`,children:[T?.length??0,` active alerts`]}),k!==null&&(0,l.jsx)(`span`,{className:`hq-pill error`,children:k}),(0,l.jsx)(`button`,{type:`button`,className:`hq-btn secondary hq-ml-auto`,onClick:()=>a.getState().setActiveView(`fleet`),children:`Open Fleet`})]}),(0,l.jsxs)(`section`,{className:`hq-cockpit-actions`,"aria-label":`Cockpit quick actions`,children:[(0,l.jsxs)(`div`,{className:`hq-cockpit-actions-copy`,children:[(0,l.jsx)(`span`,{className:`hq-cockpit-section-title`,children:`Quick Actions`}),(0,l.jsx)(`span`,{className:`hq-mono`,children:w===null?`no controllable client connected`:`target ${p(w.clientId)}`})]}),(0,l.jsxs)(`div`,{className:`hq-cockpit-actions-buttons`,children:[(0,l.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:w===null||j!==null,onClick:()=>void W(`pause-noisy`),children:j===`pause-noisy`?`Queuing…`:`Pause noisy agents`}),(0,l.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:w===null||j!==null,onClick:()=>void W(`status-request`),children:j===`status-request`?`Queuing…`:`Broadcast status request`}),(0,l.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,onClick:()=>a.getState().setActiveView(`control`),children:`Open Control`})]}),N!==null&&(0,l.jsx)(`span`,{className:`hq-pill info`,children:N}),F!==null&&(0,l.jsx)(`span`,{className:`hq-pill error`,children:F})]})]}),L!==null||z!==null?(0,l.jsxs)(`div`,{className:`hq-card hq-cockpit-section`,children:[(0,l.jsxs)(`div`,{className:`hq-row`,children:[(0,l.jsxs)(`span`,{className:`hq-cockpit-section-title`,children:[(0,l.jsx)(n,{size:14,style:{marginRight:`0.375rem`}}),`System Health`]}),(0,l.jsx)(`button`,{type:`button`,className:`hq-btn secondary hq-ml-auto`,onClick:()=>a.getState().setActiveView(`settings`),children:`open settings`})]}),z===null?L===null?null:(0,l.jsxs)(`div`,{className:`hq-cockpit-grid`,children:[(0,l.jsx)(d,{label:`status`,value:L.status,accent:L.status===`healthy`?`green`:`error`}),(0,l.jsx)(d,{label:`event log`,value:L.uptime.eventLogSize}),(0,l.jsx)(d,{label:`connections`,value:L.connections.total}),(0,l.jsx)(d,{label:`active`,value:L.connections.active,accent:L.connections.active>0?`green`:void 0}),(0,l.jsx)(d,{label:`stale`,value:L.connections.stale,accent:L.connections.stale>3?`warn`:void 0})]}):(0,l.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:z})]}):null,[...G,K,q,J].map(e=>(0,l.jsxs)(`div`,{className:`hq-card hq-cockpit-section`,children:[(0,l.jsxs)(`div`,{className:`hq-row`,children:[(0,l.jsx)(`span`,{className:`hq-cockpit-section-title`,children:e.title}),(0,l.jsx)(`button`,{type:`button`,className:`hq-btn secondary hq-ml-auto`,onClick:()=>a.getState().setActiveView(e.view),children:e.cta})]}),e.body]},e.title))]})}function d({label:e,value:t,accent:n}){return(0,l.jsxs)(`div`,{className:`hq-stat`+(n?` ${n}`:``),children:[(0,l.jsx)(`span`,{className:`hq-stat-num`,children:t}),(0,l.jsx)(`span`,{className:`hq-stat-label`,children:e})]})}function f({tokenStats:e}){if(e===void 0)return(0,l.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:`Token expiry stats unavailable on this HQ version.`});let{browserTotal:t,clientTotal:n,expired:r,expiringSoon:i}=e,a=t+n;return(0,l.jsxs)(`fieldset`,{className:`hq-cockpit-grid`,"aria-label":`Auth token stats`,style:{border:0,margin:0,padding:0},children:[(0,l.jsx)(d,{label:`browser`,value:t}),(0,l.jsx)(d,{label:`client`,value:n}),(0,l.jsx)(d,{label:`total`,value:a}),(0,l.jsx)(d,{label:`expired`,value:r,accent:r>0?`error`:void 0}),(0,l.jsx)(d,{label:`expiring soon`,value:i,accent:i>0?`warn`:void 0})]})}function p(e){return e.length<=18?e:`${e.slice(0,9)}…${e.slice(-6)}`}function m(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function h(e){return e===`critical`||e===`error`||e===`high`?`error`:e===`warn`||e===`warning`||e===`medium`?`warn`:e===`info`||e===`low`?`info`:`idle`}export{u as CockpitView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{F as t,H as n,It as r,Mt as i,N as a,O as o,c as ee,d as s,t as c}from"./icons-DqAimWQw.js";import{i as l}from"./markdown-CXUACKKT.js";import{a as te,f as u,l as d,n as f,o as p,s as ne}from"./index-BzkE5Twh.js";var m=e(r(),1),h=l(),g={steer:{label:`steer`,icon:(0,h.jsx)(c,{size:13}),desc:`High-priority course correction — interrupts the agent at the next turn.`},btw:{label:`btw`,icon:(0,h.jsx)(a,{size:13}),desc:`Non-urgent FYI — rides alongside the run without interrupting it.`},queue:{label:`queue`,icon:(0,h.jsx)(n,{size:13}),desc:`Queue a prompt — picked up after the current run finishes.`},abort:{label:`abort`,icon:(0,h.jsx)(o,{size:13}),desc:`Stop the leader run or every subagent on the client. Destructive.`,danger:!0},spawn:{label:`spawn`,icon:(0,h.jsx)(i,{size:13}),desc:`Launch a role subagent (bug-hunter, critic, …) with an optional task.`},broadcast:{label:`broadcast`,icon:(0,h.jsx)(t,{size:13}),desc:`Mailbox message to every agent in the client’s project.`},"run-command":{label:`run-command`,icon:(0,h.jsx)(s,{size:13}),desc:`Route a shell command to the client. RCE-gated (--hq-allow-exec + control.execute).`,danger:!0}};function _(){let{snapshot:e,selectedClientId:t,commandStatuses:n}=d(u(e=>({snapshot:e.snapshot,selectedClientId:e.selectedClientId,commandStatuses:e.commandStatuses}))),r=(e?.clients??[]).filter(e=>e.capabilities.includes(`control.receive`)),i=r.some(e=>e.clientId===t)?t:r[0]?.clientId??null,a=r.find(e=>e.clientId===i)??null,o=a===null?void 0:(e?.liveSessions??[]).find(e=>e.clientId===a.clientId||e.machineId===a.machineId&&e.projectId===a.projectId&&e.pid!==void 0&&e.pid===a.pid),s=te().control,[c,l]=(0,m.useState)(s.cmdType),[_,x]=(0,m.useState)(`compose`),[S,ae]=(0,m.useState)(s.steerTo),[C,oe]=(0,m.useState)(s.steerSubject),[w,se]=(0,m.useState)(s.steerBody),[T,ce]=(0,m.useState)(s.spawnRole),[E,le]=(0,m.useState)(s.spawnTask),[D,O]=(0,m.useState)(s.abortTarget),[k,ue]=(0,m.useState)(s.broadcastSubject),[A,de]=(0,m.useState)(s.broadcastBody),[j,fe]=(0,m.useState)(``),[M,pe]=(0,m.useState)(``),[N,P]=(0,m.useState)(``),[F,I]=(0,m.useState)(null),[L,R]=(0,m.useState)(null),[z,B]=(0,m.useState)(!1),[V,H]=(0,m.useState)([]),[me,U]=(0,m.useState)(!1),[W,G]=(0,m.useState)(null),[he,ge]=(0,m.useState)(null),K=(0,m.useMemo)(()=>ve(),[c,S,C,w,T,E,D,k,A,j,M]),q=K.risk===`danger`,J=c===`run-command`?`RUN`:`ABORT`,Y=i!==null&&K.disabledReason===null&&(!q||N===J),X=K.disabledReason===null&&i!==null;function Z(){x(`compose`),P(``),R(null),I(null)}function _e(e){l(e),f({cmdType:e}),Z()}async function Q(){U(!0),G(null);try{let e=await p(`/api/commands?limit=25`);H(e.commands.slice().reverse())}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}}(0,m.useEffect)(()=>{Q();let e=setInterval(()=>{document.hidden||Q()},15e3);return()=>clearInterval(e)},[]),(0,m.useEffect)(()=>{n.length!==0&&H(e=>{let t=new Map(e.map(e=>[e.commandId,e]));for(let e of n)t.set(e.commandId,e);return[...t.values()].sort((e,t)=>t.enqueuedAt.localeCompare(e.enqueuedAt)).slice(0,25)})},[n]);async function $(){if(!(i===null||!Y)){B(!0),R(null),I(null);try{let e=await ne(i,K.type,K.payload);I(`queued ${K.type} command ${e.commandId}`),ge(e.commandId),x(`compose`),P(``),Q()}catch(e){R(e instanceof Error?e.message:String(e))}finally{B(!1)}}}(0,m.useEffect)(()=>{let e=e=>{e.key!==`Enter`||!(e.ctrlKey||e.metaKey)||(e.preventDefault(),_===`compose`&&X?(x(`preview`),I(null),R(null)):_===`preview`&&Y&&!z&&$())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});function ve(){if(c===`steer`||c===`btw`||c===`queue`){let e=w.trim(),t=c===`steer`?`Send high-priority steer to`:c===`btw`?`Post a non-urgent FYI (btw) to`:`Queue a prompt for`;return{type:c,payload:{to:S||`leader`,subject:C||`HQ ${c}`,body:w,priority:c===`steer`?`high`:`normal`},disabledReason:e.length===0?`Message body is required.`:null,risk:`normal`,summary:`${t} ${S||`leader`}.`}}if(c===`run-command`){let e=j.trim();return{type:`run-command`,payload:{command:j,...M.trim()?{cwd:M.trim()}:{}},disabledReason:e.length===0?`Command is required.`:null,risk:`danger`,summary:`Route a shell command to the client (requires --hq-allow-exec + control.execute; delivered as a steer, the agent’s permission policy still applies).`}}if(c===`abort`)return{type:`abort`,payload:{target:D},disabledReason:null,risk:`danger`,summary:D===`fleet`?`Abort all subagents on the selected client.`:`Abort the selected target on the selected client.`};if(c===`spawn`){let e=E.trim();return{type:`spawn`,payload:{role:T,...e?{task:e}:{}},disabledReason:T.trim().length===0?`Role is required.`:null,risk:`normal`,summary:`Spawn a ${T} subagent${e?` with an initial task`:``}.`}}let e=A.trim();return{type:`broadcast`,payload:{subject:k||`HQ broadcast`,body:A,priority:`normal`},disabledReason:e.length===0?`Broadcast body is required.`:null,risk:`normal`,summary:`Broadcast a normal-priority mailbox message to the selected client project.`}}return r.length===0?(0,h.jsxs)(`div`,{className:`hq-empty`,children:[`No controllable clients connected. Clients must advertise the `,(0,h.jsx)(`code`,{children:`control.receive`}),` `,`capability (CLI/TUI/WebUI surfaces do this automatically when connected to HQ).`]}):(0,h.jsxs)(`div`,{className:`hq-control-grid`,children:[(0,h.jsxs)(`div`,{className:`hq-control-composer`,children:[(0,h.jsx)(`div`,{className:`hq-card-title`,children:`Command Target`}),(0,h.jsxs)(`div`,{className:`hq-card hq-control-target`,children:[(0,h.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-client`,children:`Client`}),(0,h.jsx)(`select`,{id:`hq-control-client`,className:`hq-select`,value:i??``,onChange:e=>{d.getState().selectClient(e.target.value),Z()},children:r.map(t=>(0,h.jsx)(`option`,{value:t.clientId,children:re(t,e)},t.clientId))}),a!==null&&(0,h.jsxs)(`div`,{className:`hq-control-meta`,children:[(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`kind`}),` `,a.kind]}),(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`host`}),` `,a.hostname??`unknown`]}),(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`project`}),` `,a.projectId]}),(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`client`}),` `,v(a.clientId)]}),o!==void 0&&(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`session`}),` `,v(o.sessionId),` ·`,` `,o.agentCount,` agents`]})]})]}),(0,h.jsx)(`div`,{className:`hq-card-title`,children:`Command Type`}),(0,h.jsxs)(`fieldset`,{className:`hq-control-steps`,"aria-label":`Control command stages`,children:[(0,h.jsx)(`span`,{className:`hq-step active`,children:`1 compose`}),(0,h.jsx)(`span`,{className:`hq-step`+(_===`preview`?` active`:``),children:`2 preview`}),(0,h.jsx)(`span`,{className:`hq-step`+(F===null?``:` active`),children:`3 queued`})]}),(0,h.jsx)(`div`,{className:`hq-control-types`,children:Object.keys(g).map(e=>{let t=g[e];return(0,h.jsxs)(`button`,{type:`button`,title:t.desc,className:`hq-control-type`+(c===e?` selected`:``)+(t.danger===!0?` danger`:``),onClick:()=>_e(e),children:[t.icon,t.label]},e)})}),(0,h.jsxs)(`div`,{className:`hq-control-typedesc`,children:[g[c].danger===!0&&(0,h.jsx)(ee,{size:12}),g[c].desc]}),(0,h.jsxs)(`div`,{className:`hq-mt-12`,children:[(c===`steer`||c===`btw`||c===`queue`)&&(0,h.jsxs)(`div`,{className:`hq-card`,children:[(0,h.jsxs)(`label`,{className:`hq-label`,htmlFor:`hq-control-recipient`,children:[`To (agent address — e.g. `,(0,h.jsx)(`code`,{children:`leader`}),`, `,(0,h.jsx)(`code`,{children:`leader@sessionTag`}),`, or a subagent id)`]}),(0,h.jsx)(`input`,{id:`hq-control-recipient`,className:`hq-input`,value:S,onChange:e=>{ae(e.target.value),f({steerTo:e.target.value})},placeholder:`leader`}),(0,h.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-subject`,children:`Subject`}),(0,h.jsx)(`input`,{id:`hq-control-subject`,className:`hq-input`,value:C,onChange:e=>{oe(e.target.value),f({steerSubject:e.target.value})}}),(0,h.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-body`,children:`Body`}),(0,h.jsx)(`textarea`,{id:`hq-control-body`,className:`hq-textarea`,value:w,onChange:e=>{se(e.target.value),f({steerBody:e.target.value})}})]}),c===`abort`&&(0,h.jsxs)(`div`,{className:`hq-card hq-card-danger`,children:[(0,h.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-abort-target`,children:`Target`}),(0,h.jsxs)(`select`,{id:`hq-control-abort-target`,className:`hq-select`,value:D,onChange:e=>{O(e.target.value),f({abortTarget:e.target.value})},children:[(0,h.jsx)(`option`,{value:`leader`,children:`leader (session leader)`}),(0,h.jsx)(`option`,{value:`fleet`,children:`fleet (all subagents)`})]}),(0,h.jsxs)(`div`,{className:`hq-control-warning`,children:[`Abort is destructive. Preview requires typing `,(0,h.jsx)(`strong`,{children:`ABORT`}),` before dispatch.`]})]}),c===`spawn`&&(0,h.jsxs)(`div`,{className:`hq-card`,children:[(0,h.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-spawn-role`,children:`Role`}),(0,h.jsxs)(`select`,{id:`hq-control-spawn-role`,className:`hq-select`,value:T,onChange:e=>{ce(e.target.value),f({spawnRole:e.target.value})},children:[(0,h.jsx)(`option`,{value:`bug-hunter`,children:`bug-hunter`}),(0,h.jsx)(`option`,{value:`refactor-planner`,children:`refactor-planner`}),(0,h.jsx)(`option`,{value:`critic`,children:`critic`}),(0,h.jsx)(`option`,{value:`security-scanner`,children:`security-scanner`}),(0,h.jsx)(`option`,{value:`code-reviewer`,children:`code-reviewer`})]}),(0,h.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-spawn-task`,children:`Task (optional)`}),(0,h.jsx)(`textarea`,{id:`hq-control-spawn-task`,className:`hq-textarea`,value:E,onChange:e=>{le(e.target.value),f({spawnTask:e.target.value})},placeholder:`Describe the task…`})]}),c===`run-command`&&(0,h.jsxs)(`div`,{className:`hq-card hq-card-danger`,children:[(0,h.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-run-command`,children:`Shell command`}),(0,h.jsx)(`textarea`,{id:`hq-control-run-command`,className:`hq-textarea`,value:j,onChange:e=>fe(e.target.value),placeholder:`pnpm test`}),(0,h.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-run-cwd`,children:`Working directory (optional — defaults to the agent's project root)`}),(0,h.jsx)(`input`,{id:`hq-control-run-cwd`,className:`hq-input`,value:M,onChange:e=>pe(e.target.value),placeholder:``}),(0,h.jsxs)(`div`,{className:`hq-control-warning`,children:[`RCE-gated: the client must run with `,(0,h.jsx)(`code`,{children:`--hq-allow-exec`}),` and your token needs the `,(0,h.jsx)(`code`,{children:`control.execute`}),` capability — otherwise the server rejects this. Preview requires typing `,(0,h.jsx)(`strong`,{children:`RUN`}),` before dispatch.`]})]}),c===`broadcast`&&(0,h.jsxs)(`div`,{className:`hq-card`,children:[(0,h.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-broadcast-subject`,children:`Subject`}),(0,h.jsx)(`input`,{id:`hq-control-broadcast-subject`,className:`hq-input`,value:k,onChange:e=>{ue(e.target.value),f({broadcastSubject:e.target.value})}}),(0,h.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-broadcast-body`,children:`Body`}),(0,h.jsx)(`textarea`,{id:`hq-control-broadcast-body`,className:`hq-textarea`,value:A,onChange:e=>{de(e.target.value),f({broadcastBody:e.target.value})}})]})]}),(0,h.jsx)(`div`,{className:`hq-card-title`,children:`Dispatch Gate`}),(0,h.jsxs)(`div`,{className:`hq-card hq-command-preview`+(K.risk===`danger`?` hq-card-danger`:``),children:[(0,h.jsxs)(`div`,{className:`hq-row`,children:[(0,h.jsx)(`span`,{className:`hq-pill `+(K.risk===`danger`?`error`:`info`),children:K.risk}),(0,h.jsx)(`span`,{children:K.summary}),K.disabledReason!==null&&(0,h.jsx)(`span`,{className:`hq-pill warn`,children:K.disabledReason})]}),_===`preview`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`hq-msg-sublabel`,children:`payload preview`}),(0,h.jsx)(`pre`,{className:`hq-msg-pre`,children:JSON.stringify({clientId:i,type:K.type,payload:K.payload},null,2)}),q&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`label`,{className:`hq-label hq-mt-12`,htmlFor:`hq-control-confirm`,children:`Confirm destructive dispatch`}),(0,h.jsx)(`input`,{id:`hq-control-confirm`,className:`hq-input`,value:N,onChange:e=>P(e.target.value),placeholder:`Type ${J}`})]}),(0,h.jsxs)(`div`,{className:`hq-row hq-mt-12`,children:[(0,h.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:z||!Y,onClick:()=>void $(),title:`Ctrl+Enter`,children:z?`Dispatching…`:`Dispatch Command`}),(0,h.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:z,onClick:Z,children:`Back to Compose`})]})]}):(0,h.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:!X,onClick:()=>{x(`preview`),I(null),R(null)},title:`Ctrl+Enter`,children:`Preview Command`})]}),F&&(0,h.jsx)(`div`,{className:`hq-pill active hq-mt-12`,children:F}),L&&(0,h.jsx)(`div`,{className:`hq-pill error hq-mt-12`,children:L})]}),(0,h.jsxs)(`div`,{className:`hq-control-audit`,children:[(0,h.jsx)(`div`,{className:`hq-card-title`,children:`Command Audit`}),(0,h.jsxs)(`div`,{className:`hq-card hq-command-audit`,children:[(0,h.jsxs)(`div`,{className:`hq-row`,children:[(0,h.jsxs)(`span`,{className:`hq-pill info`,children:[`recent `,V.length]}),me&&(0,h.jsx)(`span`,{className:`hq-pill idle`,children:`refreshing`}),W!==null&&(0,h.jsx)(`span`,{className:`hq-pill error`,children:W}),(0,h.jsx)(`button`,{type:`button`,className:`hq-btn secondary hq-ml-auto`,onClick:()=>void Q(),children:`Refresh`})]}),V.length===0?(0,h.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:`No command audit entries yet.`}):(0,h.jsx)(`div`,{className:`hq-audit-list`,children:V.map(e=>(0,h.jsxs)(`div`,{className:`hq-audit-row`+(e.commandId===he?` just-dispatched`:``)+(i!==null&&e.clientId===i?``:` other-client`),children:[(0,h.jsxs)(`div`,{className:`hq-audit-main`,children:[(0,h.jsx)(`span`,{className:`hq-pill `+ie(e),children:e.status}),(0,h.jsx)(`span`,{className:`hq-pill info`,children:e.type}),(0,h.jsx)(`span`,{className:`hq-mono`,children:v(e.commandId)}),e.ackStatus!==void 0&&(0,h.jsxs)(`span`,{className:`hq-pill `+b(e.ackStatus),children:[`ack `,e.ackStatus]})]}),(0,h.jsxs)(`div`,{className:`hq-audit-meta`,children:[(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`client`}),` `,v(e.clientId)]}),(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`by`}),` `,e.enqueuedBy]}),(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`queued`}),` `,y(e.enqueuedAt)]}),e.ackedAt!==void 0&&(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`acked`}),` `,y(e.ackedAt)]})]}),e.ackMessage!==void 0&&e.ackMessage.length>0&&(0,h.jsx)(`div`,{className:`hq-audit-message`,children:e.ackMessage})]},e.commandId))})]})]})]})}function v(e){return e.length>18?`${e.slice(0,10)}…${e.slice(-6)}`:e}function re(e,t){let n=t?.projects.find(t=>t.projectId===e.projectId),r=(t?.liveSessions??[]).find(t=>t.clientId===e.clientId||t.machineId===e.machineId&&t.projectId===e.projectId&&t.pid!==void 0&&t.pid===e.pid);return`${e.hostname??e.machineId} › ${n?.projectName??e.projectId} › ${`${e.kind.toUpperCase()}${e.pid===void 0?``:` · pid ${e.pid}`}`} › ${v(r?.sessionId??e.clientId)}`}function y(e,t=Date.now()){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;let r=Math.max(0,t-n.getTime());return r<6e4?`${Math.floor(r/1e3)}s ago`:r<36e5?`${Math.floor(r/6e4)}m ago`:n.toLocaleTimeString()}function ie(e){return e.ackStatus===`failed`||e.ackStatus===`rejected`?`error`:e.status===`acked`?`active`:e.status===`delivered`?`info`:e.status===`queued`?`warn`:`idle`}function b(e){return e===`failed`||e===`rejected`?`error`:e===`completed`?`active`:`info`}export{_ as ControlView};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{F as t,H as n,Lt as r,N as i,Nt as a,O as o,c as ee,d as s,t as c}from"./icons-By3Hdl4l.js";import{i as l}from"./markdown-Gk0ONVoB.js";import{a as te,f as u,l as d,n as f,o as p,s as ne}from"./index-B7CIS4YI.js";var m=e(r(),1),h=l(),g={steer:{label:`steer`,icon:(0,h.jsx)(c,{size:13}),desc:`High-priority course correction — interrupts the agent at the next turn.`},btw:{label:`btw`,icon:(0,h.jsx)(i,{size:13}),desc:`Non-urgent FYI — rides alongside the run without interrupting it.`},queue:{label:`queue`,icon:(0,h.jsx)(n,{size:13}),desc:`Queue a prompt — picked up after the current run finishes.`},abort:{label:`abort`,icon:(0,h.jsx)(o,{size:13}),desc:`Stop the leader run or every subagent on the client. Destructive.`,danger:!0},spawn:{label:`spawn`,icon:(0,h.jsx)(a,{size:13}),desc:`Launch a role subagent (bug-hunter, critic, …) with an optional task.`},broadcast:{label:`broadcast`,icon:(0,h.jsx)(t,{size:13}),desc:`Mailbox message to every agent in the client’s project.`},"run-command":{label:`run-command`,icon:(0,h.jsx)(s,{size:13}),desc:`Route a shell command to the client. RCE-gated (--hq-allow-exec + control.execute).`,danger:!0}};function _(){let{snapshot:e,selectedClientId:t,commandStatuses:n}=d(u(e=>({snapshot:e.snapshot,selectedClientId:e.selectedClientId,commandStatuses:e.commandStatuses}))),r=(e?.clients??[]).filter(e=>e.capabilities.includes(`control.receive`)),i=r.some(e=>e.clientId===t)?t:r[0]?.clientId??null,a=r.find(e=>e.clientId===i)??null,o=a===null?void 0:(e?.liveSessions??[]).find(e=>e.clientId===a.clientId||e.machineId===a.machineId&&e.projectId===a.projectId&&e.pid!==void 0&&e.pid===a.pid),s=te().control,[c,l]=(0,m.useState)(s.cmdType),[_,x]=(0,m.useState)(`compose`),[S,ae]=(0,m.useState)(s.steerTo),[C,oe]=(0,m.useState)(s.steerSubject),[w,se]=(0,m.useState)(s.steerBody),[T,ce]=(0,m.useState)(s.spawnRole),[E,le]=(0,m.useState)(s.spawnTask),[D,O]=(0,m.useState)(s.abortTarget),[k,ue]=(0,m.useState)(s.broadcastSubject),[A,de]=(0,m.useState)(s.broadcastBody),[j,fe]=(0,m.useState)(``),[M,pe]=(0,m.useState)(``),[N,P]=(0,m.useState)(``),[F,I]=(0,m.useState)(null),[L,R]=(0,m.useState)(null),[z,B]=(0,m.useState)(!1),[V,H]=(0,m.useState)([]),[me,U]=(0,m.useState)(!1),[W,G]=(0,m.useState)(null),[he,ge]=(0,m.useState)(null),K=(0,m.useMemo)(()=>ve(),[c,S,C,w,T,E,D,k,A,j,M]),q=K.risk===`danger`,J=c===`run-command`?`RUN`:`ABORT`,Y=i!==null&&K.disabledReason===null&&(!q||N===J),X=K.disabledReason===null&&i!==null;function Z(){x(`compose`),P(``),R(null),I(null)}function _e(e){l(e),f({cmdType:e}),Z()}async function Q(){U(!0),G(null);try{let e=await p(`/api/commands?limit=25`);H(e.commands.slice().reverse())}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}}(0,m.useEffect)(()=>{Q();let e=setInterval(()=>{document.hidden||Q()},15e3);return()=>clearInterval(e)},[]),(0,m.useEffect)(()=>{n.length!==0&&H(e=>{let t=new Map(e.map(e=>[e.commandId,e]));for(let e of n)t.set(e.commandId,e);return[...t.values()].sort((e,t)=>t.enqueuedAt.localeCompare(e.enqueuedAt)).slice(0,25)})},[n]);async function $(){if(!(i===null||!Y)){B(!0),R(null),I(null);try{let e=await ne(i,K.type,K.payload);I(`queued ${K.type} command ${e.commandId}`),ge(e.commandId),x(`compose`),P(``),Q()}catch(e){R(e instanceof Error?e.message:String(e))}finally{B(!1)}}}(0,m.useEffect)(()=>{let e=e=>{e.key!==`Enter`||!(e.ctrlKey||e.metaKey)||(e.preventDefault(),_===`compose`&&X?(x(`preview`),I(null),R(null)):_===`preview`&&Y&&!z&&$())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});function ve(){if(c===`steer`||c===`btw`||c===`queue`){let e=w.trim(),t=c===`steer`?`Send high-priority steer to`:c===`btw`?`Post a non-urgent FYI (btw) to`:`Queue a prompt for`;return{type:c,payload:{to:S||`leader`,subject:C||`HQ ${c}`,body:w,priority:c===`steer`?`high`:`normal`},disabledReason:e.length===0?`Message body is required.`:null,risk:`normal`,summary:`${t} ${S||`leader`}.`}}if(c===`run-command`){let e=j.trim();return{type:`run-command`,payload:{command:j,...M.trim()?{cwd:M.trim()}:{}},disabledReason:e.length===0?`Command is required.`:null,risk:`danger`,summary:`Route a shell command to the client (requires --hq-allow-exec + control.execute; delivered as a steer, the agent’s permission policy still applies).`}}if(c===`abort`)return{type:`abort`,payload:{target:D},disabledReason:null,risk:`danger`,summary:D===`fleet`?`Abort all subagents on the selected client.`:`Abort the selected target on the selected client.`};if(c===`spawn`){let e=E.trim();return{type:`spawn`,payload:{role:T,...e?{task:e}:{}},disabledReason:T.trim().length===0?`Role is required.`:null,risk:`normal`,summary:`Spawn a ${T} subagent${e?` with an initial task`:``}.`}}let e=A.trim();return{type:`broadcast`,payload:{subject:k||`HQ broadcast`,body:A,priority:`normal`},disabledReason:e.length===0?`Broadcast body is required.`:null,risk:`normal`,summary:`Broadcast a normal-priority mailbox message to the selected client project.`}}return r.length===0?(0,h.jsxs)(`div`,{className:`hq-empty`,children:[`No controllable clients connected. Clients must advertise the `,(0,h.jsx)(`code`,{children:`control.receive`}),` `,`capability (CLI/TUI/WebUI surfaces do this automatically when connected to HQ).`]}):(0,h.jsxs)(`div`,{className:`hq-control-grid`,children:[(0,h.jsxs)(`div`,{className:`hq-control-composer`,children:[(0,h.jsx)(`div`,{className:`hq-card-title`,children:`Command Target`}),(0,h.jsxs)(`div`,{className:`hq-card hq-control-target`,children:[(0,h.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-client`,children:`Client`}),(0,h.jsx)(`select`,{id:`hq-control-client`,className:`hq-select`,value:i??``,onChange:e=>{d.getState().selectClient(e.target.value),Z()},children:r.map(t=>(0,h.jsx)(`option`,{value:t.clientId,children:re(t,e)},t.clientId))}),a!==null&&(0,h.jsxs)(`div`,{className:`hq-control-meta`,children:[(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`kind`}),` `,a.kind]}),(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`host`}),` `,a.hostname??`unknown`]}),(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`project`}),` `,a.projectId]}),(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`client`}),` `,v(a.clientId)]}),o!==void 0&&(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`session`}),` `,v(o.sessionId),` ·`,` `,o.agentCount,` agents`]})]})]}),(0,h.jsx)(`div`,{className:`hq-card-title`,children:`Command Type`}),(0,h.jsxs)(`fieldset`,{className:`hq-control-steps`,"aria-label":`Control command stages`,children:[(0,h.jsx)(`span`,{className:`hq-step active`,children:`1 compose`}),(0,h.jsx)(`span`,{className:`hq-step`+(_===`preview`?` active`:``),children:`2 preview`}),(0,h.jsx)(`span`,{className:`hq-step`+(F===null?``:` active`),children:`3 queued`})]}),(0,h.jsx)(`div`,{className:`hq-control-types`,children:Object.keys(g).map(e=>{let t=g[e];return(0,h.jsxs)(`button`,{type:`button`,title:t.desc,className:`hq-control-type`+(c===e?` selected`:``)+(t.danger===!0?` danger`:``),onClick:()=>_e(e),children:[t.icon,t.label]},e)})}),(0,h.jsxs)(`div`,{className:`hq-control-typedesc`,children:[g[c].danger===!0&&(0,h.jsx)(ee,{size:12}),g[c].desc]}),(0,h.jsxs)(`div`,{className:`hq-mt-12`,children:[(c===`steer`||c===`btw`||c===`queue`)&&(0,h.jsxs)(`div`,{className:`hq-card`,children:[(0,h.jsxs)(`label`,{className:`hq-label`,htmlFor:`hq-control-recipient`,children:[`To (agent address — e.g. `,(0,h.jsx)(`code`,{children:`leader`}),`, `,(0,h.jsx)(`code`,{children:`leader@sessionTag`}),`, or a subagent id)`]}),(0,h.jsx)(`input`,{id:`hq-control-recipient`,className:`hq-input`,value:S,onChange:e=>{ae(e.target.value),f({steerTo:e.target.value})},placeholder:`leader`}),(0,h.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-subject`,children:`Subject`}),(0,h.jsx)(`input`,{id:`hq-control-subject`,className:`hq-input`,value:C,onChange:e=>{oe(e.target.value),f({steerSubject:e.target.value})}}),(0,h.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-body`,children:`Body`}),(0,h.jsx)(`textarea`,{id:`hq-control-body`,className:`hq-textarea`,value:w,onChange:e=>{se(e.target.value),f({steerBody:e.target.value})}})]}),c===`abort`&&(0,h.jsxs)(`div`,{className:`hq-card hq-card-danger`,children:[(0,h.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-abort-target`,children:`Target`}),(0,h.jsxs)(`select`,{id:`hq-control-abort-target`,className:`hq-select`,value:D,onChange:e=>{O(e.target.value),f({abortTarget:e.target.value})},children:[(0,h.jsx)(`option`,{value:`leader`,children:`leader (session leader)`}),(0,h.jsx)(`option`,{value:`fleet`,children:`fleet (all subagents)`})]}),(0,h.jsxs)(`div`,{className:`hq-control-warning`,children:[`Abort is destructive. Preview requires typing `,(0,h.jsx)(`strong`,{children:`ABORT`}),` before dispatch.`]})]}),c===`spawn`&&(0,h.jsxs)(`div`,{className:`hq-card`,children:[(0,h.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-spawn-role`,children:`Role`}),(0,h.jsxs)(`select`,{id:`hq-control-spawn-role`,className:`hq-select`,value:T,onChange:e=>{ce(e.target.value),f({spawnRole:e.target.value})},children:[(0,h.jsx)(`option`,{value:`bug-hunter`,children:`bug-hunter`}),(0,h.jsx)(`option`,{value:`refactor-planner`,children:`refactor-planner`}),(0,h.jsx)(`option`,{value:`critic`,children:`critic`}),(0,h.jsx)(`option`,{value:`security-scanner`,children:`security-scanner`}),(0,h.jsx)(`option`,{value:`code-reviewer`,children:`code-reviewer`})]}),(0,h.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-spawn-task`,children:`Task (optional)`}),(0,h.jsx)(`textarea`,{id:`hq-control-spawn-task`,className:`hq-textarea`,value:E,onChange:e=>{le(e.target.value),f({spawnTask:e.target.value})},placeholder:`Describe the task…`})]}),c===`run-command`&&(0,h.jsxs)(`div`,{className:`hq-card hq-card-danger`,children:[(0,h.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-run-command`,children:`Shell command`}),(0,h.jsx)(`textarea`,{id:`hq-control-run-command`,className:`hq-textarea`,value:j,onChange:e=>fe(e.target.value),placeholder:`pnpm test`}),(0,h.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-run-cwd`,children:`Working directory (optional — defaults to the agent's project root)`}),(0,h.jsx)(`input`,{id:`hq-control-run-cwd`,className:`hq-input`,value:M,onChange:e=>pe(e.target.value),placeholder:``}),(0,h.jsxs)(`div`,{className:`hq-control-warning`,children:[`RCE-gated: the client must run with `,(0,h.jsx)(`code`,{children:`--hq-allow-exec`}),` and your token needs the `,(0,h.jsx)(`code`,{children:`control.execute`}),` capability — otherwise the server rejects this. Preview requires typing `,(0,h.jsx)(`strong`,{children:`RUN`}),` before dispatch.`]})]}),c===`broadcast`&&(0,h.jsxs)(`div`,{className:`hq-card`,children:[(0,h.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-broadcast-subject`,children:`Subject`}),(0,h.jsx)(`input`,{id:`hq-control-broadcast-subject`,className:`hq-input`,value:k,onChange:e=>{ue(e.target.value),f({broadcastSubject:e.target.value})}}),(0,h.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-broadcast-body`,children:`Body`}),(0,h.jsx)(`textarea`,{id:`hq-control-broadcast-body`,className:`hq-textarea`,value:A,onChange:e=>{de(e.target.value),f({broadcastBody:e.target.value})}})]})]}),(0,h.jsx)(`div`,{className:`hq-card-title`,children:`Dispatch Gate`}),(0,h.jsxs)(`div`,{className:`hq-card hq-command-preview`+(K.risk===`danger`?` hq-card-danger`:``),children:[(0,h.jsxs)(`div`,{className:`hq-row`,children:[(0,h.jsx)(`span`,{className:`hq-pill `+(K.risk===`danger`?`error`:`info`),children:K.risk}),(0,h.jsx)(`span`,{children:K.summary}),K.disabledReason!==null&&(0,h.jsx)(`span`,{className:`hq-pill warn`,children:K.disabledReason})]}),_===`preview`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`hq-msg-sublabel`,children:`payload preview`}),(0,h.jsx)(`pre`,{className:`hq-msg-pre`,children:JSON.stringify({clientId:i,type:K.type,payload:K.payload},null,2)}),q&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`label`,{className:`hq-label hq-mt-12`,htmlFor:`hq-control-confirm`,children:`Confirm destructive dispatch`}),(0,h.jsx)(`input`,{id:`hq-control-confirm`,className:`hq-input`,value:N,onChange:e=>P(e.target.value),placeholder:`Type ${J}`})]}),(0,h.jsxs)(`div`,{className:`hq-row hq-mt-12`,children:[(0,h.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:z||!Y,onClick:()=>void $(),title:`Ctrl+Enter`,children:z?`Dispatching…`:`Dispatch Command`}),(0,h.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:z,onClick:Z,children:`Back to Compose`})]})]}):(0,h.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:!X,onClick:()=>{x(`preview`),I(null),R(null)},title:`Ctrl+Enter`,children:`Preview Command`})]}),F&&(0,h.jsx)(`div`,{className:`hq-pill active hq-mt-12`,children:F}),L&&(0,h.jsx)(`div`,{className:`hq-pill error hq-mt-12`,children:L})]}),(0,h.jsxs)(`div`,{className:`hq-control-audit`,children:[(0,h.jsx)(`div`,{className:`hq-card-title`,children:`Command Audit`}),(0,h.jsxs)(`div`,{className:`hq-card hq-command-audit`,children:[(0,h.jsxs)(`div`,{className:`hq-row`,children:[(0,h.jsxs)(`span`,{className:`hq-pill info`,children:[`recent `,V.length]}),me&&(0,h.jsx)(`span`,{className:`hq-pill idle`,children:`refreshing`}),W!==null&&(0,h.jsx)(`span`,{className:`hq-pill error`,children:W}),(0,h.jsx)(`button`,{type:`button`,className:`hq-btn secondary hq-ml-auto`,onClick:()=>void Q(),children:`Refresh`})]}),V.length===0?(0,h.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:`No command audit entries yet.`}):(0,h.jsx)(`div`,{className:`hq-audit-list`,children:V.map(e=>(0,h.jsxs)(`div`,{className:`hq-audit-row`+(e.commandId===he?` just-dispatched`:``)+(i!==null&&e.clientId===i?``:` other-client`),children:[(0,h.jsxs)(`div`,{className:`hq-audit-main`,children:[(0,h.jsx)(`span`,{className:`hq-pill `+ie(e),children:e.status}),(0,h.jsx)(`span`,{className:`hq-pill info`,children:e.type}),(0,h.jsx)(`span`,{className:`hq-mono`,children:v(e.commandId)}),e.ackStatus!==void 0&&(0,h.jsxs)(`span`,{className:`hq-pill `+b(e.ackStatus),children:[`ack `,e.ackStatus]})]}),(0,h.jsxs)(`div`,{className:`hq-audit-meta`,children:[(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`client`}),` `,v(e.clientId)]}),(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`by`}),` `,e.enqueuedBy]}),(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`queued`}),` `,y(e.enqueuedAt)]}),e.ackedAt!==void 0&&(0,h.jsxs)(`span`,{children:[(0,h.jsx)(`strong`,{children:`acked`}),` `,y(e.ackedAt)]})]}),e.ackMessage!==void 0&&e.ackMessage.length>0&&(0,h.jsx)(`div`,{className:`hq-audit-message`,children:e.ackMessage})]},e.commandId))})]})]})]})}function v(e){return e.length>18?`${e.slice(0,10)}…${e.slice(-6)}`:e}function re(e,t){let n=t?.projects.find(t=>t.projectId===e.projectId),r=(t?.liveSessions??[]).find(t=>t.clientId===e.clientId||t.machineId===e.machineId&&t.projectId===e.projectId&&t.pid!==void 0&&t.pid===e.pid);return`${e.hostname??e.machineId} › ${n?.projectName??e.projectId} › ${`${e.kind.toUpperCase()}${e.pid===void 0?``:` · pid ${e.pid}`}`} › ${v(r?.sessionId??e.clientId)}`}function y(e,t=Date.now()){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;let r=Math.max(0,t-n.getTime());return r<6e4?`${Math.floor(r/1e3)}s ago`:r<36e5?`${Math.floor(r/6e4)}m ago`:n.toLocaleTimeString()}function ie(e){return e.ackStatus===`failed`||e.ackStatus===`rejected`?`error`:e.status===`acked`?`active`:e.status===`delivered`?`info`:e.status===`queued`?`warn`:`idle`}function b(e){return e===`failed`||e===`rejected`?`error`:e===`completed`?`active`:`info`}export{_ as ControlView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Lt as t}from"./icons-By3Hdl4l.js";import{i as n}from"./markdown-Gk0ONVoB.js";import{l as r}from"./index-B7CIS4YI.js";var i=e(t(),1),a=n();function o(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function s(){let e=r(e=>e.snapshot),t=e?.projects??[],n=e?.liveSessions??[],s=e?.totals.totalCostUsd??0,c=(0,i.useMemo)(()=>n.map(e=>{let t=0,n=0,r=new Set;for(let i of e.agents)t+=i.costUsd??0,n+=(i.tokensIn??0)+(i.tokensOut??0),i.model!==void 0&&r.add(i.model);return{s:e,cost:t,tokens:n,models:[...r]}}).filter(e=>e.cost>0||e.tokens>0).sort((e,t)=>t.cost-e.cost),[n]);if(t.length===0)return(0,a.jsx)(`div`,{className:`hq-empty`,children:`No cost data yet — connect some clients.`});let l=[...t].sort((e,t)=>t.totalCostUsd-e.totalCostUsd);return(0,a.jsxs)(`div`,{children:[(0,a.jsxs)(`div`,{className:`hq-kpi-row`,children:[(0,a.jsxs)(`div`,{className:`hq-kpi hero`,children:[(0,a.jsxs)(`span`,{className:`hq-kpi-value accent-cost`,children:[`$`,s.toFixed(4)]}),(0,a.jsx)(`span`,{className:`hq-kpi-label`,children:`total fleet cost`})]}),(0,a.jsxs)(`div`,{className:`hq-kpi`,children:[(0,a.jsx)(`span`,{className:`hq-kpi-value`,children:t.length}),(0,a.jsx)(`span`,{className:`hq-kpi-label`,children:`projects`})]}),(0,a.jsxs)(`div`,{className:`hq-kpi`,children:[(0,a.jsx)(`span`,{className:`hq-kpi-value`,children:c.length}),(0,a.jsx)(`span`,{className:`hq-kpi-label`,children:`costed sessions`})]})]}),(0,a.jsx)(`div`,{className:`hq-card-title`,children:`By Project`}),l.map(e=>{let t=s>0?e.totalCostUsd/s*100:0;return(0,a.jsxs)(`div`,{className:`hq-card`,children:[(0,a.jsxs)(`div`,{className:`hq-row`,children:[(0,a.jsx)(`span`,{className:`hq-text-bright`,children:e.projectName}),(0,a.jsx)(`span`,{className:`hq-mono hq-row-subtle`,children:e.projectId}),(0,a.jsxs)(`span`,{className:`hq-cost-amount`,children:[`$`,e.totalCostUsd.toFixed(4)]}),(0,a.jsxs)(`span`,{className:`hq-mono hq-row-subtle`,children:[t.toFixed(1),`%`]})]}),(0,a.jsx)(`div`,{className:`hq-share-track`,children:(0,a.jsx)(`div`,{className:`hq-share-fill`,style:{width:`${t}%`}})}),(0,a.jsxs)(`div`,{className:`hq-row hq-row-detail`,children:[(0,a.jsxs)(`span`,{className:`hq-pill info`,children:[e.activeSessions,` sessions`]}),(0,a.jsxs)(`span`,{className:`hq-pill active`,children:[e.activeSubagents,` subagents`]}),(0,a.jsxs)(`span`,{className:`hq-pill idle`,children:[e.activeClients,` clients`]})]})]},e.projectId)}),c.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`div`,{className:`hq-card-title`,children:`By Session`}),(0,a.jsx)(`div`,{className:`hq-card`,children:c.map(({s:e,cost:t,tokens:n,models:i})=>(0,a.jsxs)(`button`,{type:`button`,className:`hq-row hq-row-click`,onClick:()=>{r.getState().selectSession(e.sessionId),r.getState().setActiveView(`console`)},title:`Open in Console`,children:[(0,a.jsx)(`span`,{className:`hq-text-bright`,children:e.projectName}),(0,a.jsx)(`span`,{className:`hq-pill idle`,children:e.clientKind}),i.map(e=>(0,a.jsx)(`span`,{className:`hq-pill info`,children:e},e)),(0,a.jsxs)(`span`,{className:`hq-mono hq-row-subtle`,children:[o(n),` tok`]}),(0,a.jsxs)(`span`,{className:`hq-cost-amount`,children:[`$`,t.toFixed(4)]})]},e.sessionId))})]})]})}export{s as CostView};
|