@wrongstack/webui-hq 0.289.0 → 0.291.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/assets/{alerts-Nd3-2kbb.js → alerts-Coy0VQOD.js} +1 -1
  2. package/dist/assets/brain-B4Tdewfy.js +1 -0
  3. package/dist/assets/cockpit-CZa8Ik0r.js +1 -0
  4. package/dist/assets/control-BRj__LMC.js +1 -0
  5. package/dist/assets/{cost-DtYd1WXA.js → cost-C4nlUQAz.js} +1 -1
  6. package/dist/assets/fleet-map-VOzbj36e.js +7 -0
  7. package/dist/assets/{fleet-topology-B3uTvH1s.js → fleet-topology-CHOsHZc9.js} +7 -7
  8. package/dist/assets/icons-BlGYTg3M.js +1 -0
  9. package/dist/assets/index-Ckam6WOR.js +2 -0
  10. package/dist/assets/index-G4pDhbF0.css +1 -0
  11. package/dist/assets/live-console-CGxRZ15o.js +1 -0
  12. package/dist/assets/mailbox-B3ZDFEyg.js +1 -0
  13. package/dist/assets/markdown-Dm2qU66U.js +35 -0
  14. package/dist/assets/settings-BncyJ7aj.js +1 -0
  15. package/dist/assets/{trends-p7bdJFIi.js → trends-C6j-auPf.js} +1 -1
  16. package/dist/assets/{use-backfilled-events-BGr4w2qq.js → use-backfilled-events-BnFvycsd.js} +1 -1
  17. package/dist/assets/{vendor-DIU0H2e8.js → vendor-BoaR8QxN.js} +1 -1
  18. package/dist/assets/worktree-BXf7yQRK.js +1 -0
  19. package/dist/index.html +6 -5
  20. package/dist/wrongstack.svg +6 -0
  21. package/package.json +12 -12
  22. package/dist/assets/brain-BnkIw8nW.js +0 -1
  23. package/dist/assets/cockpit-DIEoqkG7.js +0 -1
  24. package/dist/assets/control-6Aw5wcrt.js +0 -1
  25. package/dist/assets/fleet-map-DhxF-gdt.js +0 -7
  26. package/dist/assets/icons-9m5clYwH.js +0 -1
  27. package/dist/assets/index-Cd7L2eHB.css +0 -1
  28. package/dist/assets/index-v8d2cF2E.js +0 -2
  29. package/dist/assets/live-console-BMEdzPs2.js +0 -1
  30. package/dist/assets/mailbox-BPdImpld.js +0 -1
  31. package/dist/assets/markdown-Cq9pnQX9.js +0 -35
  32. package/dist/assets/worktree-B9isI17f.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{K as t,L as n,Nt as r,R as i,S as a,f as o,ft as s,p as c}from"./icons-BlGYTg3M.js";import{i as l}from"./markdown-Dm2qU66U.js";import{d as u,u as d}from"./index-Ckam6WOR.js";var f=e(r(),1),p=l();async function m(e){let t=e.statusText||`HTTP ${e.status}`;try{let n=await e.json();return typeof n.error==`string`?n.error:n.error?.message??t}catch{return t}}function h(){let[e,r]=(0,f.useState)(null),[l,h]=(0,f.useState)(``),[g,_]=(0,f.useState)(``),[v,y]=(0,f.useState)(``),[b,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(null),[w,T]=(0,f.useState)(!1),E=async()=>{let e=await d(`/api/auth/status`);if(!e.ok)throw Error(await m(e));r(await e.json())};(0,f.useEffect)(()=>{E().catch(e=>{C({tone:`error`,text:e instanceof Error?e.message:String(e)})})},[]);let D=e?.passwordMode===!0&&e.authKind===`password`,O=g.length>=8&&g.length<=1024,k=g===v,A=O&&k&&(!D||l.length>0)&&!b,j=async()=>{if(A){x(!0),C(null);try{let t=await d(`/api/auth/password`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...D?{currentPassword:l}:{},newPassword:g})});if(!t.ok)throw Error(await m(t));r(await t.json()),h(``),_(``),y(``),C({tone:`ok`,text:e?.passwordMode?`Password changed.`:`Password enabled.`})}catch(e){C({tone:`error`,text:e instanceof Error?e.message:String(e)})}finally{x(!1)}}},M=async()=>{x(!0),C(null);try{let e=await d(`/api/auth/password`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...D?{currentPassword:l}:{}})});if(!e.ok)throw Error(await m(e));r(await e.json()),h(``),T(!1),C({tone:`ok`,text:`Password protection removed.`})}catch(e){C({tone:`error`,text:e instanceof Error?e.message:String(e)})}finally{x(!1)}},N=async()=>{x(!0);try{await d(`/api/logout`,{method:`POST`})}finally{u(),window.location.reload()}},P=async()=>{if(!(!e?.publicOrigin||!e.passwordMode))try{await navigator.clipboard.writeText(e.publicOrigin),C({tone:`ok`,text:`Public tunnel URL copied.`})}catch{C({tone:`error`,text:`Could not copy the public tunnel URL.`})}};return(0,p.jsxs)(`div`,{className:`hq-security-page`,children:[(0,p.jsxs)(`section`,{className:`hq-security-summary`,"aria-label":`Authentication status`,children:[(0,p.jsxs)(`div`,{className:`hq-security-card`,children:[(0,p.jsx)(c,{size:18}),(0,p.jsx)(`span`,{children:`Browser access`}),(0,p.jsx)(`strong`,{children:e?.loggedIn?`Authenticated`:`Checking…`})]}),(0,p.jsxs)(`div`,{className:`hq-security-card`,children:[(0,p.jsx)(t,{size:18}),(0,p.jsx)(`span`,{children:`Browser tokens`}),(0,p.jsx)(`strong`,{children:e?.tokenMode?`Enabled`:`Disabled`})]}),(0,p.jsxs)(`div`,{className:`hq-security-card`,children:[(0,p.jsx)(i,{size:18}),(0,p.jsx)(`span`,{children:`Password login`}),(0,p.jsx)(`strong`,{children:e?.passwordMode?`Enabled`:`Disabled`})]}),(0,p.jsxs)(`div`,{className:`hq-security-card`,children:[(0,p.jsx)(a,{size:18}),(0,p.jsx)(`span`,{children:`Public tunnel`}),(0,p.jsx)(`strong`,{children:e?.publicRelay?`Active`:`Disabled`}),e?.publicOrigin&&e.passwordMode?(0,p.jsxs)(`button`,{type:`button`,className:`hq-security-copy`,"aria-label":`Copy public tunnel URL`,title:e.publicOrigin,onClick:()=>void P(),children:[(0,p.jsx)(s,{size:12}),`Copy URL`]}):null]})]}),(0,p.jsxs)(`section`,{className:`hq-security-panel`,children:[(0,p.jsxs)(`div`,{className:`hq-security-panel-head`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`span`,{children:`Browser credential`}),(0,p.jsx)(`h2`,{children:e?.passwordMode?`Change HQ password`:`Enable HQ password`}),(0,p.jsx)(`p`,{children:`Passwords are stored as salted scrypt hashes. Changing the password invalidates older password sessions.`})]}),(0,p.jsx)(i,{size:22})]}),S?(0,p.jsx)(`div`,{className:`hq-security-message`,"data-tone":S.tone,role:`status`,children:S.text}):null,(0,p.jsxs)(`div`,{className:`hq-security-form`,children:[D?(0,p.jsxs)(`label`,{children:[(0,p.jsx)(`span`,{children:`Current password`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`current-password`,value:l,onChange:e=>h(e.target.value)})]}):null,(0,p.jsxs)(`label`,{children:[(0,p.jsx)(`span`,{children:`New password`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`new-password`,minLength:8,maxLength:1024,value:g,onChange:e=>_(e.target.value)}),(0,p.jsx)(`small`,{children:`Minimum 8 characters.`})]}),(0,p.jsxs)(`label`,{children:[(0,p.jsx)(`span`,{children:`Confirm new password`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`new-password`,minLength:8,maxLength:1024,value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j()}}),v&&!k?(0,p.jsx)(`small`,{"data-error":!0,children:`Passwords do not match.`}):null]}),(0,p.jsx)(`div`,{className:`hq-security-actions`,children:(0,p.jsxs)(`button`,{type:`button`,className:`hq-btn`,disabled:!A,onClick:()=>void j(),children:[(0,p.jsx)(c,{size:14}),b?`Saving…`:e?.passwordMode?`Change password`:`Enable password`]})})]})]}),(0,p.jsxs)(`section`,{className:`hq-security-panel danger-zone`,children:[(0,p.jsxs)(`div`,{className:`hq-security-panel-head`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`span`,{children:`Session and recovery`}),(0,p.jsx)(`h2`,{children:`Access controls`}),(0,p.jsx)(`p`,{children:`Browser tokens remain available as a recovery path. Public tunnel mode will refuse to remove the last browser authentication method.`})]}),(0,p.jsx)(o,{size:22})]}),(0,p.jsxs)(`div`,{className:`hq-security-actions split`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:b,onClick:()=>void N(),children:[(0,p.jsx)(n,{size:14}),`Log out this browser`]}),e?.passwordMode?w?(0,p.jsxs)(`div`,{className:`hq-security-confirm-remove`,children:[(0,p.jsx)(`span`,{children:`Remove password protection?`}),(0,p.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:b,onClick:()=>T(!1),children:`Cancel`}),(0,p.jsx)(`button`,{type:`button`,className:`hq-btn danger`,disabled:b||D&&!l,onClick:()=>void M(),children:`Remove password`})]}):(0,p.jsxs)(`button`,{type:`button`,className:`hq-btn danger`,disabled:b,onClick:()=>T(!0),children:[(0,p.jsx)(o,{size:14}),`Remove password`]}):null]})]})]})}export{h as SettingsView};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ot as t}from"./icons-9m5clYwH.js";import{i as n}from"./markdown-Cq9pnQX9.js";import{o as r}from"./index-v8d2cF2E.js";var i=e(t(),1),a=n();function o({points:e,color:t,height:n=140,format:r,emptyLabel:o=`no data`}){let[s,c]=(0,i.useState)(null),l=(0,i.useId)(),u=n,d=u-10-22,f=(0,i.useMemo)(()=>Math.max(...e.map(e=>e.value),0),[e]);if(e.length===0||f<=0)return(0,a.jsx)(`div`,{className:`hq-chart-empty`,children:o});let p=e.length,m=666/p,h=Math.max(2,Math.min(18,m-2)),g=e=>10+d*(1-e/f),_=[f*.25,f*.5,f*.75,f],v=Math.max(1,Math.round(p/5)),y=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),b=s===null?void 0:e[s];return(0,a.jsxs)(`div`,{className:`hq-chart`,children:[(0,a.jsxs)(`svg`,{viewBox:`0 0 720 ${u}`,className:`hq-chart-svg`,role:`img`,"aria-label":`Time series chart with ${e.length} data points`,onMouseLeave:()=>c(null),onMouseMove:t=>{let n=t.currentTarget.getBoundingClientRect(),r=(t.clientX-n.left)/n.width*720,i=Math.floor((r-46)/m);c(i>=0&&i<e.length?i:null)},children:[(0,a.jsx)(`clipPath`,{id:l,children:(0,a.jsx)(`rect`,{x:46,y:10,width:666,height:d})}),_.map((e,t)=>(0,a.jsxs)(`g`,{children:[(0,a.jsx)(`line`,{x1:46,x2:712,y1:g(e),y2:g(e),className:`hq-chart-grid`}),(0,a.jsx)(`text`,{x:40,y:g(e)+3,className:`hq-chart-ytick`,textAnchor:`end`,children:r(e)})]},t)),(0,a.jsx)(`line`,{x1:46,x2:712,y1:10+d,y2:10+d,className:`hq-chart-axis`}),(0,a.jsx)(`g`,{clipPath:`url(#${l})`,children:e.map((e,n)=>{let r=46+n*m+(m-h)/2,i=g(e.value),o=10+d-i;return o<=0?null:(0,a.jsx)(`rect`,{x:r,y:i,width:h,height:o,rx:Math.min(3,h/2),fill:t,opacity:s===null||s===n?1:.45},n)})}),e.map((e,t)=>t%v===0?(0,a.jsx)(`text`,{x:46+t*m+m/2,y:u-6,className:`hq-chart-xtick`,textAnchor:`middle`,children:y(e.ts)},t):null),(0,a.jsx)(`rect`,{x:46,y:10,width:666,height:d,fill:`transparent`})]}),b!==void 0&&(0,a.jsxs)(`div`,{className:`hq-chart-tooltip`,children:[(0,a.jsx)(`span`,{className:`hq-chart-tooltip-swatch`,style:{background:t}}),(0,a.jsx)(`span`,{className:`hq-chart-tooltip-value`,children:r(b.value)}),(0,a.jsx)(`span`,{className:`hq-chart-tooltip-time`,children:y(b.ts)})]})]})}var s=[{label:`1h`,ms:3600*1e3},{label:`6h`,ms:360*60*1e3},{label:`24h`,ms:1440*60*1e3},{label:`7d`,ms:10080*60*1e3}];function c(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function l(e,t){let n=new Map;for(let r of e){let e=r[t];if(e!==void 0)for(let[t,r]of Object.entries(e)){let e=n.get(t);e===void 0?n.set(t,{...r}):(e.costUsd+=r.costUsd,e.inputTokens+=r.inputTokens,e.outputTokens+=r.outputTokens,e.cacheRead=(e.cacheRead??0)+(r.cacheRead??0),e.cacheWrite=(e.cacheWrite??0)+(r.cacheWrite??0))}}return[...n.entries()].map(([e,t])=>({key:e,entry:t})).sort((e,t)=>t.entry.costUsd-e.entry.costUsd)}function u(){let[e,t]=(0,i.useState)([]),[n,u]=(0,i.useState)(null),[d,f]=(0,i.useState)(s[2].ms);(0,i.useEffect)(()=>{let e=!1,n=()=>{r(`/api/trends/cost`).then(n=>{e||(t(n.samples),u(null))}).catch(t=>{e||u(t.message)})};n();let i=setInterval(n,3e4);return()=>{e=!0,clearInterval(i)}},[]);let{shown:p,totalCost:m,totalTokens:h,totalTools:g,byModel:_,byProvider:v,totalCacheRead:y,totalCacheWrite:b}=(0,i.useMemo)(()=>{let t=Date.now()-d,n=e.filter(e=>e.ts>=t),r=n.length>0?n:e.slice(-24),i=r.reduce((e,t)=>e+t.costUsd,0),a=r.reduce((e,t)=>e+t.inputTokens+t.outputTokens,0),o=r.reduce((e,t)=>e+t.toolCalls,0),s=l(r,`byModel`);return{shown:r,totalCost:i,totalTokens:a,totalTools:o,byModel:s,byProvider:l(r,`byProvider`),totalCacheRead:s.reduce((e,t)=>e+(t.entry.cacheRead??0),0),totalCacheWrite:s.reduce((e,t)=>e+(t.entry.cacheWrite??0),0)}},[e,d]);if(n!==null)return(0,a.jsxs)(`div`,{className:`hq-empty`,children:[`Error loading trends: `,n]});if(e.length===0)return(0,a.jsx)(`div`,{className:`hq-empty`,children:`No trend data yet. Trends accumulate as cost signals arrive.`});let x=_.length>0,S=y+b>0?y/(y+b)*100:null;return(0,a.jsxs)(`div`,{children:[(0,a.jsxs)(`div`,{className:`hq-filter-row`,children:[s.map(e=>(0,a.jsx)(`button`,{type:`button`,className:`hq-pill hq-filter-chip${d===e.ms?` selected`:``}`,onClick:()=>f(e.ms),children:e.label},e.label)),(0,a.jsxs)(`span`,{className:`hq-mono hq-row-subtle hq-ml-auto`,children:[p.length,` × 5-min buckets`]})]}),(0,a.jsxs)(`div`,{className:`hq-stat-row`,children:[(0,a.jsxs)(`div`,{className:`hq-stat-block`,children:[(0,a.jsxs)(`span`,{className:`hq-stat-block-value accent-cost`,children:[`$`,m.toFixed(4)]}),(0,a.jsx)(`span`,{className:`hq-stat-block-label`,children:`cost`})]}),(0,a.jsxs)(`div`,{className:`hq-stat-block`,children:[(0,a.jsx)(`span`,{className:`hq-stat-block-value accent-tokens`,children:c(h)}),(0,a.jsx)(`span`,{className:`hq-stat-block-label`,children:`tokens`})]}),(0,a.jsxs)(`div`,{className:`hq-stat-block`,children:[(0,a.jsx)(`span`,{className:`hq-stat-block-value accent-tools`,children:g.toLocaleString()}),(0,a.jsx)(`span`,{className:`hq-stat-block-label`,children:`tool calls`})]}),S!==null&&(0,a.jsxs)(`div`,{className:`hq-stat-block`,children:[(0,a.jsxs)(`span`,{className:`hq-stat-block-value`,children:[S.toFixed(0),`%`]}),(0,a.jsx)(`span`,{className:`hq-stat-block-label`,children:`cache hit`}),(0,a.jsxs)(`span`,{className:`hq-stat-block-sub`,children:[c(y),` read · `,c(b),` write`]})]})]}),(0,a.jsxs)(`div`,{className:`hq-card`,children:[(0,a.jsx)(`div`,{className:`hq-card-title`,children:`Cost (USD)`}),(0,a.jsx)(o,{points:p.map(e=>({ts:e.ts,value:e.costUsd})),color:`var(--chart-1)`,format:e=>`$${e>=1?e.toFixed(2):e.toFixed(4)}`})]}),(0,a.jsxs)(`div`,{className:`hq-card`,children:[(0,a.jsx)(`div`,{className:`hq-card-title`,children:`Tokens (in + out)`}),(0,a.jsx)(o,{points:p.map(e=>({ts:e.ts,value:e.inputTokens+e.outputTokens})),color:`var(--chart-2)`,format:c})]}),(0,a.jsxs)(`div`,{className:`hq-card`,children:[(0,a.jsx)(`div`,{className:`hq-card-title`,children:`Tool calls`}),(0,a.jsx)(o,{points:p.map(e=>({ts:e.ts,value:e.toolCalls})),color:`var(--chart-3)`,format:e=>String(Math.round(e))})]}),x&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`div`,{className:`hq-card-title`,children:`By Model`}),(0,a.jsx)(`div`,{className:`hq-card`,children:_.map(({key:e,entry:t})=>{let n=m>0?t.costUsd/m*100:0;return(0,a.jsxs)(`div`,{className:`hq-row`,children:[(0,a.jsx)(`span`,{className:`hq-text-bright`,children:e}),(0,a.jsxs)(`span`,{className:`hq-mono hq-row-subtle`,children:[c(t.inputTokens),`→`,c(t.outputTokens),t.cacheRead!==void 0||t.cacheWrite!==void 0?` · cache ${c((t.cacheRead??0)+(t.cacheWrite??0))}`:``]}),(0,a.jsxs)(`span`,{className:`hq-cost-amount hq-ml-auto`,children:[`$`,t.costUsd.toFixed(4)]}),(0,a.jsxs)(`span`,{className:`hq-mono hq-row-subtle`,children:[n.toFixed(1),`%`]})]},e)})}),v.length>1&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`div`,{className:`hq-card-title`,children:`By Provider`}),(0,a.jsx)(`div`,{className:`hq-card`,children:v.map(({key:e,entry:t})=>{let n=m>0?t.costUsd/m*100:0;return(0,a.jsxs)(`div`,{className:`hq-row`,children:[(0,a.jsx)(`span`,{className:`hq-text-bright`,children:e}),(0,a.jsxs)(`span`,{className:`hq-cost-amount hq-ml-auto`,children:[`$`,t.costUsd.toFixed(4)]}),(0,a.jsxs)(`span`,{className:`hq-mono hq-row-subtle`,children:[n.toFixed(1),`%`]})]},e)})})]})]})]})}export{u as TrendsView};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Nt as t}from"./icons-BlGYTg3M.js";import{i as n}from"./markdown-Dm2qU66U.js";import{o as r}from"./index-Ckam6WOR.js";var i=e(t(),1),a=n();function o({points:e,color:t,height:n=140,format:r,emptyLabel:o=`no data`}){let[s,c]=(0,i.useState)(null),l=(0,i.useId)(),u=n,d=u-10-22,f=(0,i.useMemo)(()=>Math.max(...e.map(e=>e.value),0),[e]);if(e.length===0||f<=0)return(0,a.jsx)(`div`,{className:`hq-chart-empty`,children:o});let p=e.length,m=666/p,h=Math.max(2,Math.min(18,m-2)),g=e=>10+d*(1-e/f),_=[f*.25,f*.5,f*.75,f],v=Math.max(1,Math.round(p/5)),y=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),b=s===null?void 0:e[s];return(0,a.jsxs)(`div`,{className:`hq-chart`,children:[(0,a.jsxs)(`svg`,{viewBox:`0 0 720 ${u}`,className:`hq-chart-svg`,role:`img`,"aria-label":`Time series chart with ${e.length} data points`,onMouseLeave:()=>c(null),onMouseMove:t=>{let n=t.currentTarget.getBoundingClientRect(),r=(t.clientX-n.left)/n.width*720,i=Math.floor((r-46)/m);c(i>=0&&i<e.length?i:null)},children:[(0,a.jsx)(`clipPath`,{id:l,children:(0,a.jsx)(`rect`,{x:46,y:10,width:666,height:d})}),_.map((e,t)=>(0,a.jsxs)(`g`,{children:[(0,a.jsx)(`line`,{x1:46,x2:712,y1:g(e),y2:g(e),className:`hq-chart-grid`}),(0,a.jsx)(`text`,{x:40,y:g(e)+3,className:`hq-chart-ytick`,textAnchor:`end`,children:r(e)})]},t)),(0,a.jsx)(`line`,{x1:46,x2:712,y1:10+d,y2:10+d,className:`hq-chart-axis`}),(0,a.jsx)(`g`,{clipPath:`url(#${l})`,children:e.map((e,n)=>{let r=46+n*m+(m-h)/2,i=g(e.value),o=10+d-i;return o<=0?null:(0,a.jsx)(`rect`,{x:r,y:i,width:h,height:o,rx:Math.min(3,h/2),fill:t,opacity:s===null||s===n?1:.45},n)})}),e.map((e,t)=>t%v===0?(0,a.jsx)(`text`,{x:46+t*m+m/2,y:u-6,className:`hq-chart-xtick`,textAnchor:`middle`,children:y(e.ts)},t):null),(0,a.jsx)(`rect`,{x:46,y:10,width:666,height:d,fill:`transparent`})]}),b!==void 0&&(0,a.jsxs)(`div`,{className:`hq-chart-tooltip`,children:[(0,a.jsx)(`span`,{className:`hq-chart-tooltip-swatch`,style:{background:t}}),(0,a.jsx)(`span`,{className:`hq-chart-tooltip-value`,children:r(b.value)}),(0,a.jsx)(`span`,{className:`hq-chart-tooltip-time`,children:y(b.ts)})]})]})}var s=[{label:`1h`,ms:3600*1e3},{label:`6h`,ms:360*60*1e3},{label:`24h`,ms:1440*60*1e3},{label:`7d`,ms:10080*60*1e3}];function c(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function l(e,t){let n=new Map;for(let r of e){let e=r[t];if(e!==void 0)for(let[t,r]of Object.entries(e)){let e=n.get(t);e===void 0?n.set(t,{...r}):(e.costUsd+=r.costUsd,e.inputTokens+=r.inputTokens,e.outputTokens+=r.outputTokens,e.cacheRead=(e.cacheRead??0)+(r.cacheRead??0),e.cacheWrite=(e.cacheWrite??0)+(r.cacheWrite??0))}}return[...n.entries()].map(([e,t])=>({key:e,entry:t})).sort((e,t)=>t.entry.costUsd-e.entry.costUsd)}function u(){let[e,t]=(0,i.useState)([]),[n,u]=(0,i.useState)(null),[d,f]=(0,i.useState)(s[2].ms);(0,i.useEffect)(()=>{let e=!1,n=()=>{r(`/api/trends/cost`).then(n=>{e||(t(n.samples),u(null))}).catch(t=>{e||u(t.message)})};n();let i=setInterval(n,3e4);return()=>{e=!0,clearInterval(i)}},[]);let{shown:p,totalCost:m,totalTokens:h,totalTools:g,byModel:_,byProvider:v,totalCacheRead:y,totalCacheWrite:b}=(0,i.useMemo)(()=>{let t=Date.now()-d,n=e.filter(e=>e.ts>=t),r=n.length>0?n:e.slice(-24),i=r.reduce((e,t)=>e+t.costUsd,0),a=r.reduce((e,t)=>e+t.inputTokens+t.outputTokens,0),o=r.reduce((e,t)=>e+t.toolCalls,0),s=l(r,`byModel`);return{shown:r,totalCost:i,totalTokens:a,totalTools:o,byModel:s,byProvider:l(r,`byProvider`),totalCacheRead:s.reduce((e,t)=>e+(t.entry.cacheRead??0),0),totalCacheWrite:s.reduce((e,t)=>e+(t.entry.cacheWrite??0),0)}},[e,d]);if(n!==null)return(0,a.jsxs)(`div`,{className:`hq-empty`,children:[`Error loading trends: `,n]});if(e.length===0)return(0,a.jsx)(`div`,{className:`hq-empty`,children:`No trend data yet. Trends accumulate as cost signals arrive.`});let x=_.length>0,S=y+b>0?y/(y+b)*100:null;return(0,a.jsxs)(`div`,{children:[(0,a.jsxs)(`div`,{className:`hq-filter-row`,children:[s.map(e=>(0,a.jsx)(`button`,{type:`button`,className:`hq-pill hq-filter-chip${d===e.ms?` selected`:``}`,onClick:()=>f(e.ms),children:e.label},e.label)),(0,a.jsxs)(`span`,{className:`hq-mono hq-row-subtle hq-ml-auto`,children:[p.length,` × 5-min buckets`]})]}),(0,a.jsxs)(`div`,{className:`hq-stat-row`,children:[(0,a.jsxs)(`div`,{className:`hq-stat-block`,children:[(0,a.jsxs)(`span`,{className:`hq-stat-block-value accent-cost`,children:[`$`,m.toFixed(4)]}),(0,a.jsx)(`span`,{className:`hq-stat-block-label`,children:`cost`})]}),(0,a.jsxs)(`div`,{className:`hq-stat-block`,children:[(0,a.jsx)(`span`,{className:`hq-stat-block-value accent-tokens`,children:c(h)}),(0,a.jsx)(`span`,{className:`hq-stat-block-label`,children:`tokens`})]}),(0,a.jsxs)(`div`,{className:`hq-stat-block`,children:[(0,a.jsx)(`span`,{className:`hq-stat-block-value accent-tools`,children:g.toLocaleString()}),(0,a.jsx)(`span`,{className:`hq-stat-block-label`,children:`tool calls`})]}),S!==null&&(0,a.jsxs)(`div`,{className:`hq-stat-block`,children:[(0,a.jsxs)(`span`,{className:`hq-stat-block-value`,children:[S.toFixed(0),`%`]}),(0,a.jsx)(`span`,{className:`hq-stat-block-label`,children:`cache hit`}),(0,a.jsxs)(`span`,{className:`hq-stat-block-sub`,children:[c(y),` read · `,c(b),` write`]})]})]}),(0,a.jsxs)(`div`,{className:`hq-card`,children:[(0,a.jsx)(`div`,{className:`hq-card-title`,children:`Cost (USD)`}),(0,a.jsx)(o,{points:p.map(e=>({ts:e.ts,value:e.costUsd})),color:`var(--chart-1)`,format:e=>`$${e>=1?e.toFixed(2):e.toFixed(4)}`})]}),(0,a.jsxs)(`div`,{className:`hq-card`,children:[(0,a.jsx)(`div`,{className:`hq-card-title`,children:`Tokens (in + out)`}),(0,a.jsx)(o,{points:p.map(e=>({ts:e.ts,value:e.inputTokens+e.outputTokens})),color:`var(--chart-2)`,format:c})]}),(0,a.jsxs)(`div`,{className:`hq-card`,children:[(0,a.jsx)(`div`,{className:`hq-card-title`,children:`Tool calls`}),(0,a.jsx)(o,{points:p.map(e=>({ts:e.ts,value:e.toolCalls})),color:`var(--chart-3)`,format:e=>String(Math.round(e))})]}),x&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`div`,{className:`hq-card-title`,children:`By Model`}),(0,a.jsx)(`div`,{className:`hq-card`,children:_.map(({key:e,entry:t})=>{let n=m>0?t.costUsd/m*100:0;return(0,a.jsxs)(`div`,{className:`hq-row`,children:[(0,a.jsx)(`span`,{className:`hq-text-bright`,children:e}),(0,a.jsxs)(`span`,{className:`hq-mono hq-row-subtle`,children:[c(t.inputTokens),`→`,c(t.outputTokens),t.cacheRead!==void 0||t.cacheWrite!==void 0?` · cache ${c((t.cacheRead??0)+(t.cacheWrite??0))}`:``]}),(0,a.jsxs)(`span`,{className:`hq-cost-amount hq-ml-auto`,children:[`$`,t.costUsd.toFixed(4)]}),(0,a.jsxs)(`span`,{className:`hq-mono hq-row-subtle`,children:[n.toFixed(1),`%`]})]},e)})}),v.length>1&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`div`,{className:`hq-card-title`,children:`By Provider`}),(0,a.jsx)(`div`,{className:`hq-card`,children:v.map(({key:e,entry:t})=>{let n=m>0?t.costUsd/m*100:0;return(0,a.jsxs)(`div`,{className:`hq-row`,children:[(0,a.jsx)(`span`,{className:`hq-text-bright`,children:e}),(0,a.jsxs)(`span`,{className:`hq-cost-amount hq-ml-auto`,children:[`$`,t.costUsd.toFixed(4)]}),(0,a.jsxs)(`span`,{className:`hq-mono hq-row-subtle`,children:[n.toFixed(1),`%`]})]},e)})})]})]})]})}export{u as TrendsView};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ot as t}from"./icons-9m5clYwH.js";import{l as n,o as r}from"./index-v8d2cF2E.js";var i=e(t(),1);function a(e,t=200){let a=n(e=>e.events),[o,s]=(0,i.useState)([]),[c,l]=(0,i.useState)(!0);return(0,i.useEffect)(()=>{let n=!1;return r(`/api/events?type=${encodeURIComponent(e)}&limit=${t}`).then(e=>{n||(s([...e.events??[]].reverse()),l(!1))}).catch(()=>{n||l(!1)}),()=>{n=!0}},[e,t]),{events:(0,i.useMemo)(()=>{let t=new Set,n=[];for(let r of o)r.type!==e||t.has(r.id)||(t.add(r.id),n.push(r));for(let r of a)r.type!==e||t.has(r.id)||(t.add(r.id),n.push(r));return n},[o,a,e]),loading:c}}export{a as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Nt as t}from"./icons-BlGYTg3M.js";import{l as n,o as r}from"./index-Ckam6WOR.js";var i=e(t(),1);function a(e,t=200){let a=n(e=>e.events),[o,s]=(0,i.useState)([]),[c,l]=(0,i.useState)(!0);return(0,i.useEffect)(()=>{let n=!1;return r(`/api/events?type=${encodeURIComponent(e)}&limit=${t}`).then(e=>{n||(s([...e.events??[]].reverse()),l(!1))}).catch(()=>{n||l(!1)}),()=>{n=!0}},[e,t]),{events:(0,i.useMemo)(()=>{let t=new Set,n=[];for(let r of o)r.type!==e||t.has(r.id)||(t.add(r.id),n.push(r));for(let r of a)r.type!==e||t.has(r.id)||(t.add(r.id),n.push(r));return n},[o,a,e]),loading:c}}export{a as t};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ot as t}from"./icons-9m5clYwH.js";var n=e((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,ee||(ee=!0,oe());else{var t=n(l);t!==null&&le(x,t.startTime-e)}}var ee=!1,te=-1,ne=5,re=-1;function ie(){return g?!0:!(e.unstable_now()-re<ne)}function ae(){if(g=!1,ee){var t=e.unstable_now();re=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(te),te=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ie());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&le(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?oe():ee=!1}}}var oe;if(typeof y==`function`)oe=function(){y(ae)};else if(typeof MessageChannel<`u`){var se=new MessageChannel,ce=se.port2;se.port1.onmessage=ae,oe=function(){ce.postMessage(null)}}else oe=function(){_(ae,0)};function le(t,n){te=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):ne=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(te),te=-1):h=!0,le(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ee||(ee=!0,oe()))),r},e.unstable_shouldYield=ie,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),r=e(((e,t)=>{t.exports=n()})),i=e((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.7`})),a=e(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=i()})),o=e((e=>{var n=r(),i=t(),o=a();function s(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(s(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(s(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return f(i),e;if(a===r)return f(i),t;a=a.sibling}throw Error(s(188))}if(n.return!==r.return)n=i,r=a;else{for(var o=!1,c=i.child;c;){if(c===n){o=!0,n=i,r=a;break}if(c===r){o=!0,r=i,n=a;break}c=c.sibling}if(!o){for(c=a.child;c;){if(c===n){o=!0,n=a,r=i;break}if(c===r){o=!0,r=a,n=i;break}c=c.sibling}if(!o)throw Error(s(189))}}if(n.alternate!==r)throw Error(s(190))}if(n.tag!==3)throw Error(s(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),ee=Symbol.for(`react.consumer`),te=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.activity`),ce=Symbol.for(`react.memo_cache_sentinel`),le=Symbol.iterator;function ue(e){return typeof e!=`object`||!e?null:(e=le&&e[le]||e[`@@iterator`],typeof e==`function`?e:null)}var de=Symbol.for(`react.client.reference`);function fe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===de?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case se:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case te:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?fe(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return fe(e(t))}catch{}}return null}var pe=Array.isArray,S=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,C=o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,me={pending:!1,data:null,method:null,action:null},he=[],ge=-1;function _e(e){return{current:e}}function w(e){0>ge||(e.current=he[ge],he[ge]=null,ge--)}function T(e,t){ge++,he[ge]=e.current,e.current=t}var ve=_e(null),ye=_e(null),be=_e(null),xe=_e(null);function Se(e,t){switch(T(be,t),T(ye,e),T(ve,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}w(ve),T(ve,e)}function Ce(){w(ve),w(ye),w(be)}function we(e){e.memoizedState!==null&&T(xe,e);var t=ve.current,n=Hd(t,e.type);t!==n&&(T(ye,e),T(ve,n))}function Te(e){ye.current===e&&(w(ve),w(ye)),xe.current===e&&(w(xe),Qf._currentValue=me)}var Ee,De;function Oe(e){if(Ee===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ee=t&&t[1]||``,De=-1<e.stack.indexOf(`
1
+ import{t as e}from"./rolldown-runtime-QTnfLwEv.js";import{Nt as t}from"./icons-BlGYTg3M.js";var n=e((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,ee||(ee=!0,oe());else{var t=n(l);t!==null&&le(x,t.startTime-e)}}var ee=!1,te=-1,ne=5,re=-1;function ie(){return g?!0:!(e.unstable_now()-re<ne)}function ae(){if(g=!1,ee){var t=e.unstable_now();re=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(te),te=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ie());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&le(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?oe():ee=!1}}}var oe;if(typeof y==`function`)oe=function(){y(ae)};else if(typeof MessageChannel<`u`){var se=new MessageChannel,ce=se.port2;se.port1.onmessage=ae,oe=function(){ce.postMessage(null)}}else oe=function(){_(ae,0)};function le(t,n){te=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):ne=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(te),te=-1):h=!0,le(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ee||(ee=!0,oe()))),r},e.unstable_shouldYield=ie,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),r=e(((e,t)=>{t.exports=n()})),i=e((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.7`})),a=e(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=i()})),o=e((e=>{var n=r(),i=t(),o=a();function s(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(s(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(s(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return f(i),e;if(a===r)return f(i),t;a=a.sibling}throw Error(s(188))}if(n.return!==r.return)n=i,r=a;else{for(var o=!1,c=i.child;c;){if(c===n){o=!0,n=i,r=a;break}if(c===r){o=!0,r=i,n=a;break}c=c.sibling}if(!o){for(c=a.child;c;){if(c===n){o=!0,n=a,r=i;break}if(c===r){o=!0,r=a,n=i;break}c=c.sibling}if(!o)throw Error(s(189))}}if(n.alternate!==r)throw Error(s(190))}if(n.tag!==3)throw Error(s(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),ee=Symbol.for(`react.consumer`),te=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.activity`),ce=Symbol.for(`react.memo_cache_sentinel`),le=Symbol.iterator;function ue(e){return typeof e!=`object`||!e?null:(e=le&&e[le]||e[`@@iterator`],typeof e==`function`?e:null)}var de=Symbol.for(`react.client.reference`);function fe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===de?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case se:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case te:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?fe(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return fe(e(t))}catch{}}return null}var pe=Array.isArray,S=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,C=o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,me={pending:!1,data:null,method:null,action:null},he=[],ge=-1;function _e(e){return{current:e}}function w(e){0>ge||(e.current=he[ge],he[ge]=null,ge--)}function T(e,t){ge++,he[ge]=e.current,e.current=t}var ve=_e(null),ye=_e(null),be=_e(null),xe=_e(null);function Se(e,t){switch(T(be,t),T(ye,e),T(ve,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}w(ve),T(ve,e)}function Ce(){w(ve),w(ye),w(be)}function we(e){e.memoizedState!==null&&T(xe,e);var t=ve.current,n=Hd(t,e.type);t!==n&&(T(ye,e),T(ve,n))}function Te(e){ye.current===e&&(w(ve),w(ye)),xe.current===e&&(w(xe),Qf._currentValue=me)}var Ee,De;function Oe(e){if(Ee===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ee=t&&t[1]||``,De=-1<e.stack.indexOf(`
2
2
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
3
3
  `+Ee+e+De}var ke=!1;function Ae(e,t){if(!e||ke)return``;ke=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
4
4
  `),l=s.split(`
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$ as t,E as n,Nt as r,Tt as i,c as a,ht as o,l as s}from"./icons-BlGYTg3M.js";import{i as c}from"./markdown-Dm2qU66U.js";import{t as l}from"./use-backfilled-events-BnFvycsd.js";var u=e(r(),1),d=c(),f={allocated:{Icon:n,cls:`info`},committed:{Icon:i,cls:`active`},merged:{Icon:t,cls:`active`},conflict:{Icon:a,cls:`warn`},released:{Icon:s,cls:`idle`},failed:{Icon:o,cls:`error`}};function p({e}){let t=e.payload,r=f[t.kind]??{Icon:n,cls:`info`};return(0,d.jsxs)(`div`,{className:`hq-row`,children:[(0,d.jsx)(r.Icon,{size:14,className:`hq-kind-icon ${r.cls}`}),(0,d.jsx)(`span`,{className:`hq-text-bright`,children:t.kind}),t.branch!==void 0&&(0,d.jsx)(`span`,{className:`hq-pill info`,children:t.branch}),t.kind===`committed`&&(0,d.jsxs)(`span`,{className:`hq-mono hq-diffstat`,children:[(0,d.jsxs)(`span`,{className:`hq-diff-add-count`,children:[`+`,t.insertions??0]}),` `,(0,d.jsxs)(`span`,{className:`hq-diff-del-count`,children:[`−`,t.deletions??0]}),` in `,t.files??0,` file(s)`,` `,t.sha===void 0?``:`(${t.sha.slice(0,7)})`]}),t.kind===`conflict`&&t.conflictFiles!==void 0&&(0,d.jsxs)(`span`,{className:`hq-mono hq-row-error`,children:[`conflicts: `,t.conflictFiles.join(`, `)]}),t.kind===`failed`&&(0,d.jsx)(`span`,{className:`hq-mono hq-row-error`,children:t.error}),(0,d.jsx)(`span`,{className:`hq-mono hq-row-time`,children:new Date(e.timestamp).toLocaleTimeString()})]})}function m(){let{events:e,loading:t}=l(`worktree.event`,300),r=(0,u.useMemo)(()=>{let t=new Map;for(let n of e){let e=n.payload.ownerId??`(unknown)`,r=t.get(e)??[];r.push(n),t.set(e,r)}return Array.from(t.entries()).reverse()},[e]);return r.length===0?(0,d.jsx)(`div`,{className:`hq-empty`,children:t?`Loading worktree history…`:`No worktree events yet. These appear when Goal allocates/merges git worktrees for parallel phases.`}):(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`hq-card-title`,children:[`Worktree Lifecycle (`,r.length,` worktree`,r.length===1?``:`s`,`)`]}),r.map(([e,t])=>{let r=t[t.length-1].payload,i=f[r.kind]??{Icon:n,cls:`info`};return(0,d.jsxs)(`div`,{className:`hq-card`,children:[(0,d.jsxs)(`div`,{className:`hq-row hq-lane-head`,children:[(0,d.jsx)(`span`,{className:`hq-mono hq-text-bright`,children:e}),(0,d.jsx)(`span`,{className:`hq-pill ${i.cls}`,children:r.kind}),(0,d.jsxs)(`span`,{className:`hq-mono hq-row-time`,children:[t.length,` events`]})]}),t.map(e=>(0,d.jsx)(p,{e},e.id))]},e)})]})}export{m as WorktreeView};
package/dist/index.html CHANGED
@@ -2,14 +2,15 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/wrongstack.svg" />
5
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
7
  <title>WrongStack HQ</title>
7
- <script type="module" crossorigin src="/assets/index-v8d2cF2E.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-Ckam6WOR.js"></script>
8
9
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-QTnfLwEv.js">
9
- <link rel="modulepreload" crossorigin href="/assets/icons-9m5clYwH.js">
10
- <link rel="modulepreload" crossorigin href="/assets/vendor-DIU0H2e8.js">
11
- <link rel="modulepreload" crossorigin href="/assets/markdown-Cq9pnQX9.js">
12
- <link rel="stylesheet" crossorigin href="/assets/index-Cd7L2eHB.css">
10
+ <link rel="modulepreload" crossorigin href="/assets/icons-BlGYTg3M.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/vendor-BoaR8QxN.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/markdown-Dm2qU66U.js">
13
+ <link rel="stylesheet" crossorigin href="/assets/index-G4pDhbF0.css">
13
14
  </head>
14
15
  <body>
15
16
  <div id="root"></div>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" fill="none" role="img" aria-labelledby="wrongstack-logo-title" shape-rendering="crispEdges">
2
+ <title id="wrongstack-logo-title">WrongStack</title>
3
+ <rect width="400" height="400" fill="#121210"/>
4
+ <path fill="#FD9F02" d="M30 170h60v60H30zM170 170h60v60h-60zM240 170h60v60h-60zM310 170h60v60h-60z"/>
5
+ <path fill="#FE2E5F" d="M100 200h60v60h-60z"/>
6
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/webui-hq",
3
- "version": "0.289.0",
3
+ "version": "0.291.0",
4
4
  "license": "MIT",
5
5
  "description": "HQ Command Center dashboard — offline React app for the cross-machine coordination surface (port 3499).",
6
6
  "type": "module",
@@ -12,24 +12,24 @@
12
12
  "@fontsource-variable/manrope": "^5.2.8",
13
13
  "@fontsource-variable/space-grotesk": "^5.2.10",
14
14
  "@fontsource/ibm-plex-mono": "^5.2.7",
15
- "@xyflow/react": "^12.11.1",
16
- "lucide-react": "^1.24.0",
17
- "react": "^19.0.0",
18
- "react-dom": "^19.0.0",
15
+ "@xyflow/react": "^12.11.2",
16
+ "lucide-react": "^1.25.0",
17
+ "react": "^19.2.7",
18
+ "react-dom": "^19.2.7",
19
19
  "react-markdown": "^10.1.0",
20
20
  "rehype-highlight": "^7.0.2",
21
21
  "remark-gfm": "^4.0.1",
22
- "virtua": "^0.49.1",
22
+ "virtua": "^0.49.3",
23
23
  "zustand": "5.0.14",
24
- "@wrongstack/core": "0.289.0",
25
- "@wrongstack/tools": "0.289.0"
24
+ "@wrongstack/core": "0.291.0",
25
+ "@wrongstack/tools": "0.291.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@types/react": "^19.0.0",
29
- "@types/react-dom": "^19.0.0",
30
- "@vitejs/plugin-react": "^6.0.0",
28
+ "@types/react": "^19.2.17",
29
+ "@types/react-dom": "^19.2.3",
30
+ "@vitejs/plugin-react": "^6.0.3",
31
31
  "typescript": "^7.0.2",
32
- "vite": "^8.1.0",
32
+ "vite": "^8.1.5",
33
33
  "vitest": "4.1.10"
34
34
  },
35
35
  "files": [
@@ -1 +0,0 @@
1
- import{Et as e,Tt as t,ht as n,lt as r,n as i,tt as a,z as o}from"./icons-9m5clYwH.js";import{i as s}from"./markdown-Cq9pnQX9.js";import{t as c}from"./use-backfilled-events-BGr4w2qq.js";var l=s(),u={decision_requested:{label:`Requested`,Icon:t,cls:`info`},decision_answered:{label:`Answered`,Icon:e,cls:`active`},decision_ask_human:{label:`Ask Human`,Icon:o,cls:`warn`},decision_denied:{label:`Denied`,Icon:a,cls:`error`},human_answered:{label:`Human`,Icon:n,cls:`info`},intervention:{label:`Intervention`,Icon:i,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};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ot as t}from"./icons-9m5clYwH.js";import{i as n}from"./markdown-Cq9pnQX9.js";import{d as r,l as i,o as a,s as o}from"./index-v8d2cF2E.js";var s=e(t(),1),c=n();function l(){let{snapshot:e,alerts:t,selectedClientId:n,connected:l}=i(r(e=>({snapshot:e.snapshot,alerts:e.alerts,selectedClientId:e.selectedClientId,connected:e.connected}))),m=e,h=m?.totals,g=m?.machines??[],_=m?.projects??[],v=m?.clients??[],y=m?.liveSessions??[],b=v.filter(e=>e.capabilities.includes(`control.receive`)),x=n??b[0]?.clientId??null,S=b.find(e=>e.clientId===x)??b[0]??null,[C,w]=(0,s.useState)([]),[T,E]=(0,s.useState)([]),[D,O]=(0,s.useState)(null),[k,A]=(0,s.useState)(null),[j,M]=(0,s.useState)(null),[N,P]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=!1,t=()=>{a(`/api/alerts`).then(t=>{e||(w(t.active),E(t.history),O(null))}).catch(t=>{e||O(t instanceof Error?t.message:String(t))})};t();let n=setInterval(t,15e3);return()=>{e=!0,clearInterval(n)}},[]);let F=(0,s.useMemo)(()=>{let e=t.slice(-30).reverse().map(e=>({severity:typeof e.severity==`string`?e.severity:`info`,ruleId:`live`,message:`Live alert envelope received.`,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString()})),n=[...C,...T].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,C,T]),I=(0,s.useMemo)(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of y){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}},[y]),L=(0,s.useMemo)(()=>[..._].sort((e,t)=>t.totalCostUsd-e.totalCostUsd).slice(0,4),[_]);async function R(e){if(S!==null){A(e),M(null),P(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`};M(`queued ${(await o(S.clientId,`broadcast`,t)).commandId}`)}catch(e){P(e instanceof Error?e.message:String(e))}finally{A(null)}}}let z=[{title:`Fleet`,view:`fleet`,cta:`open fleet`,body:(0,c.jsxs)(`div`,{className:`hq-cockpit-grid`,children:[(0,c.jsx)(u,{label:`machines`,value:g.length}),(0,c.jsx)(u,{label:`clients`,value:v.length}),(0,c.jsx)(u,{label:`sessions`,value:I.activeSessions,accent:I.activeSessions>0?`green`:void 0}),(0,c.jsx)(u,{label:`agents`,value:I.total}),(0,c.jsx)(u,{label:`busy`,value:I.busy,accent:I.busy>0?`green`:void 0}),(0,c.jsx)(u,{label:`waiting`,value:I.waiting,accent:I.waiting>0?`warn`:void 0}),(0,c.jsx)(u,{label:`errored`,value:I.errored,accent:I.errored>0?`error`:void 0}),(0,c.jsx)(u,{label:`cost $`,value:(h?.totalCostUsd??0).toFixed(2),accent:`green`})]})}],B={title:`Alerts`,view:`alerts`,cta:`open alerts`,body:F.length===0?(0,c.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:`No alerts in the last few minutes.`}):(0,c.jsx)(`div`,{className:`hq-cockpit-alert-list`,children:F.map((e,t)=>(0,c.jsxs)(`div`,{className:`hq-cockpit-alert-row`,children:[(0,c.jsx)(`span`,{className:`hq-pill `+p(e.severity),children:e.severity}),(0,c.jsx)(`span`,{className:`hq-mono`,children:e.ruleId}),(0,c.jsx)(`span`,{className:`hq-cockpit-alert-msg`,children:e.message}),(0,c.jsx)(`span`,{className:`hq-mono hq-text-dim hq-ml-auto`,children:f(e.timestamp)})]},`${e.ruleId}-${e.timestamp}-${t}`))})},V={title:`Cost`,view:`cost`,cta:`open cost`,body:L.length===0?(0,c.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:`No cost data yet — connect some clients.`}):(0,c.jsx)(`div`,{className:`hq-cockpit-cost-list`,children:L.map(e=>{let t=(h?.totalCostUsd??0)>0?e.totalCostUsd/h.totalCostUsd*100:0;return(0,c.jsxs)(`div`,{className:`hq-cockpit-cost-row`,children:[(0,c.jsxs)(`div`,{className:`hq-cockpit-cost-line`,children:[(0,c.jsx)(`span`,{className:`hq-cockpit-cost-name`,children:e.projectName}),(0,c.jsx)(`span`,{className:`hq-mono hq-text-dim`,children:e.projectId}),(0,c.jsxs)(`span`,{className:`hq-mono hq-cockpit-cost-amount hq-ml-auto`,children:[`$`,e.totalCostUsd.toFixed(4)]}),(0,c.jsxs)(`span`,{className:`hq-mono hq-text-dim`,children:[t.toFixed(1),`%`]})]}),(0,c.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,c.jsx)(`span`,{style:{width:`${Math.max(2,t)}%`}})}),(0,c.jsxs)(`div`,{className:`hq-cockpit-cost-meta`,children:[(0,c.jsxs)(`span`,{children:[e.activeSessions,` sessions`]}),(0,c.jsxs)(`span`,{children:[e.activeSubagents,` subagents`]}),(0,c.jsxs)(`span`,{children:[e.activeClients,` clients`]})]})]},e.projectId)})})};return(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`div`,{className:`hq-card-title`,children:`Cockpit`}),(0,c.jsxs)(`div`,{className:`hq-card hq-cockpit-summary`,children:[(0,c.jsxs)(`div`,{className:`hq-row`,children:[(0,c.jsx)(`span`,{className:`hq-pill info`,children:l?`connected`:`reconnecting`}),(0,c.jsxs)(`span`,{className:`hq-pill`,children:[h?.activeMachines??0,` machines`]}),(0,c.jsxs)(`span`,{className:`hq-pill`,children:[h?.activeSessions??0,` sessions`]}),(0,c.jsxs)(`span`,{className:`hq-pill`,children:[h?.activeAgents??0,` agents`]}),(0,c.jsxs)(`span`,{className:`hq-pill green`,children:[`$`,(h?.totalCostUsd??0).toFixed(2)]}),C.length>0&&(0,c.jsxs)(`span`,{className:`hq-pill error`,children:[C.length,` active alerts`]}),D!==null&&(0,c.jsx)(`span`,{className:`hq-pill error`,children:D}),(0,c.jsx)(`button`,{type:`button`,className:`hq-btn secondary hq-ml-auto`,onClick:()=>i.getState().setActiveView(`fleet`),children:`Open Fleet`})]}),(0,c.jsxs)(`section`,{className:`hq-cockpit-actions`,"aria-label":`Cockpit quick actions`,children:[(0,c.jsxs)(`div`,{className:`hq-cockpit-actions-copy`,children:[(0,c.jsx)(`span`,{className:`hq-cockpit-section-title`,children:`Quick Actions`}),(0,c.jsx)(`span`,{className:`hq-mono`,children:S===null?`no controllable client connected`:`target ${d(S.clientId)}`})]}),(0,c.jsxs)(`div`,{className:`hq-cockpit-actions-buttons`,children:[(0,c.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:S===null||k!==null,onClick:()=>void R(`pause-noisy`),children:k===`pause-noisy`?`Queuing…`:`Pause noisy agents`}),(0,c.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:S===null||k!==null,onClick:()=>void R(`status-request`),children:k===`status-request`?`Queuing…`:`Broadcast status request`}),(0,c.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,onClick:()=>i.getState().setActiveView(`control`),children:`Open Control`})]}),j!==null&&(0,c.jsx)(`span`,{className:`hq-pill info`,children:j}),N!==null&&(0,c.jsx)(`span`,{className:`hq-pill error`,children:N})]})]}),[...z,B,V].map(e=>(0,c.jsxs)(`div`,{className:`hq-card hq-cockpit-section`,children:[(0,c.jsxs)(`div`,{className:`hq-row`,children:[(0,c.jsx)(`span`,{className:`hq-cockpit-section-title`,children:e.title}),(0,c.jsx)(`button`,{type:`button`,className:`hq-btn secondary hq-ml-auto`,onClick:()=>i.getState().setActiveView(e.view),children:e.cta})]}),e.body]},e.title))]})}function u({label:e,value:t,accent:n}){return(0,c.jsxs)(`div`,{className:`hq-stat`+(n?` ${n}`:``),children:[(0,c.jsx)(`span`,{className:`hq-stat-num`,children:t}),(0,c.jsx)(`span`,{className:`hq-stat-label`,children:e})]})}function d(e){return e.length<=18?e:`${e.slice(0,9)}…${e.slice(-6)}`}function f(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function p(e){return e===`critical`||e===`error`||e===`high`?`error`:e===`warn`||e===`warning`||e===`medium`?`warn`:e===`info`||e===`low`?`info`:`idle`}export{l as CockpitView};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,Ot as n,_t as r,bt as i,dt as a,gt as ee,j as o,n as s,w as c}from"./icons-9m5clYwH.js";import{i as l}from"./markdown-Cq9pnQX9.js";import{a as te,d as ne,l as u,n as d,o as f,s as re}from"./index-v8d2cF2E.js";var p=e(n(),1),m=l(),h={steer:{label:`steer`,icon:(0,m.jsx)(s,{size:13}),desc:`High-priority course correction — interrupts the agent at the next turn.`},btw:{label:`btw`,icon:(0,m.jsx)(c,{size:13}),desc:`Non-urgent FYI — rides alongside the run without interrupting it.`},queue:{label:`queue`,icon:(0,m.jsx)(o,{size:13}),desc:`Queue a prompt — picked up after the current run finishes.`},abort:{label:`abort`,icon:(0,m.jsx)(i,{size:13}),desc:`Stop the leader run or every subagent on the client. Destructive.`,danger:!0},spawn:{label:`spawn`,icon:(0,m.jsx)(a,{size:13}),desc:`Launch a role subagent (bug-hunter, critic, …) with an optional task.`},broadcast:{label:`broadcast`,icon:(0,m.jsx)(t,{size:13}),desc:`Mailbox message to every agent in the client’s project.`},"run-command":{label:`run-command`,icon:(0,m.jsx)(r,{size:13}),desc:`Route a shell command to the client. RCE-gated (--hq-allow-exec + control.execute).`,danger:!0}};function g(){let{snapshot:e,selectedClientId:t,commandStatuses:n}=u(ne(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,p.useState)(s.cmdType),[g,b]=(0,p.useState)(`compose`),[x,oe]=(0,p.useState)(s.steerTo),[S,se]=(0,p.useState)(s.steerSubject),[C,w]=(0,p.useState)(s.steerBody),[T,ce]=(0,p.useState)(s.spawnRole),[E,le]=(0,p.useState)(s.spawnTask),[D,O]=(0,p.useState)(s.abortTarget),[k,ue]=(0,p.useState)(s.broadcastSubject),[A,de]=(0,p.useState)(s.broadcastBody),[j,fe]=(0,p.useState)(``),[M,pe]=(0,p.useState)(``),[N,P]=(0,p.useState)(``),[F,I]=(0,p.useState)(null),[L,R]=(0,p.useState)(null),[z,B]=(0,p.useState)(!1),[V,H]=(0,p.useState)([]),[me,U]=(0,p.useState)(!1),[W,G]=(0,p.useState)(null),[he,ge]=(0,p.useState)(null),K=(0,p.useMemo)(()=>ve(),[c,x,S,C,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(){b(`compose`),P(``),R(null),I(null)}function _e(e){l(e),d({cmdType:e}),Z()}async function Q(){U(!0),G(null);try{H((await f(`/api/commands?limit=25`)).commands.slice().reverse())}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}}(0,p.useEffect)(()=>{Q();let e=setInterval(()=>{document.hidden||Q()},15e3);return()=>clearInterval(e)},[]),(0,p.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 re(i,K.type,K.payload);I(`queued ${K.type} command ${e.commandId}`),ge(e.commandId),b(`compose`),P(``),Q()}catch(e){R(e instanceof Error?e.message:String(e))}finally{B(!1)}}}(0,p.useEffect)(()=>{let e=e=>{e.key!==`Enter`||!(e.ctrlKey||e.metaKey)||(e.preventDefault(),g===`compose`&&X?(b(`preview`),I(null),R(null)):g===`preview`&&Y&&!z&&$())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});function ve(){if(c===`steer`||c===`btw`||c===`queue`){let e=C.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:x||`leader`,subject:S||`HQ ${c}`,body:C,priority:c===`steer`?`high`:`normal`},disabledReason:e.length===0?`Message body is required.`:null,risk:`normal`,summary:`${t} ${x||`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,m.jsxs)(`div`,{className:`hq-empty`,children:[`No controllable clients connected. Clients must advertise the `,(0,m.jsx)(`code`,{children:`control.receive`}),` `,`capability (CLI/TUI/WebUI surfaces do this automatically when connected to HQ).`]}):(0,m.jsxs)(`div`,{className:`hq-control-grid`,children:[(0,m.jsxs)(`div`,{className:`hq-control-composer`,children:[(0,m.jsx)(`div`,{className:`hq-card-title`,children:`Command Target`}),(0,m.jsxs)(`div`,{className:`hq-card hq-control-target`,children:[(0,m.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-client`,children:`Client`}),(0,m.jsx)(`select`,{id:`hq-control-client`,className:`hq-select`,value:i??``,onChange:e=>{u.getState().selectClient(e.target.value),Z()},children:r.map(t=>(0,m.jsx)(`option`,{value:t.clientId,children:ie(t,e)},t.clientId))}),a!==null&&(0,m.jsxs)(`div`,{className:`hq-control-meta`,children:[(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`kind`}),` `,a.kind]}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`host`}),` `,a.hostname??`unknown`]}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`project`}),` `,a.projectId]}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`client`}),` `,_(a.clientId)]}),o!==void 0&&(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`session`}),` `,_(o.sessionId),` ·`,` `,o.agentCount,` agents`]})]})]}),(0,m.jsx)(`div`,{className:`hq-card-title`,children:`Command Type`}),(0,m.jsxs)(`fieldset`,{className:`hq-control-steps`,"aria-label":`Control command stages`,children:[(0,m.jsx)(`span`,{className:`hq-step active`,children:`1 compose`}),(0,m.jsx)(`span`,{className:`hq-step`+(g===`preview`?` active`:``),children:`2 preview`}),(0,m.jsx)(`span`,{className:`hq-step`+(F===null?``:` active`),children:`3 queued`})]}),(0,m.jsx)(`div`,{className:`hq-control-types`,children:Object.keys(h).map(e=>{let t=h[e];return(0,m.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,m.jsxs)(`div`,{className:`hq-control-typedesc`,children:[h[c].danger===!0&&(0,m.jsx)(ee,{size:12}),h[c].desc]}),(0,m.jsxs)(`div`,{className:`hq-mt-12`,children:[(c===`steer`||c===`btw`||c===`queue`)&&(0,m.jsxs)(`div`,{className:`hq-card`,children:[(0,m.jsxs)(`label`,{className:`hq-label`,htmlFor:`hq-control-recipient`,children:[`To (agent address — e.g. `,(0,m.jsx)(`code`,{children:`leader`}),`, `,(0,m.jsx)(`code`,{children:`leader@sessionTag`}),`, or a subagent id)`]}),(0,m.jsx)(`input`,{id:`hq-control-recipient`,className:`hq-input`,value:x,onChange:e=>{oe(e.target.value),d({steerTo:e.target.value})},placeholder:`leader`}),(0,m.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-subject`,children:`Subject`}),(0,m.jsx)(`input`,{id:`hq-control-subject`,className:`hq-input`,value:S,onChange:e=>{se(e.target.value),d({steerSubject:e.target.value})}}),(0,m.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-body`,children:`Body`}),(0,m.jsx)(`textarea`,{id:`hq-control-body`,className:`hq-textarea`,value:C,onChange:e=>{w(e.target.value),d({steerBody:e.target.value})}})]}),c===`abort`&&(0,m.jsxs)(`div`,{className:`hq-card hq-card-danger`,children:[(0,m.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-abort-target`,children:`Target`}),(0,m.jsxs)(`select`,{id:`hq-control-abort-target`,className:`hq-select`,value:D,onChange:e=>{O(e.target.value),d({abortTarget:e.target.value})},children:[(0,m.jsx)(`option`,{value:`leader`,children:`leader (session leader)`}),(0,m.jsx)(`option`,{value:`fleet`,children:`fleet (all subagents)`})]}),(0,m.jsxs)(`div`,{className:`hq-control-warning`,children:[`Abort is destructive. Preview requires typing `,(0,m.jsx)(`strong`,{children:`ABORT`}),` before dispatch.`]})]}),c===`spawn`&&(0,m.jsxs)(`div`,{className:`hq-card`,children:[(0,m.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-spawn-role`,children:`Role`}),(0,m.jsxs)(`select`,{id:`hq-control-spawn-role`,className:`hq-select`,value:T,onChange:e=>{ce(e.target.value),d({spawnRole:e.target.value})},children:[(0,m.jsx)(`option`,{value:`bug-hunter`,children:`bug-hunter`}),(0,m.jsx)(`option`,{value:`refactor-planner`,children:`refactor-planner`}),(0,m.jsx)(`option`,{value:`critic`,children:`critic`}),(0,m.jsx)(`option`,{value:`security-scanner`,children:`security-scanner`}),(0,m.jsx)(`option`,{value:`code-reviewer`,children:`code-reviewer`})]}),(0,m.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-spawn-task`,children:`Task (optional)`}),(0,m.jsx)(`textarea`,{id:`hq-control-spawn-task`,className:`hq-textarea`,value:E,onChange:e=>{le(e.target.value),d({spawnTask:e.target.value})},placeholder:`Describe the task…`})]}),c===`run-command`&&(0,m.jsxs)(`div`,{className:`hq-card hq-card-danger`,children:[(0,m.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-run-command`,children:`Shell command`}),(0,m.jsx)(`textarea`,{id:`hq-control-run-command`,className:`hq-textarea`,value:j,onChange:e=>fe(e.target.value),placeholder:`pnpm test`}),(0,m.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,m.jsx)(`input`,{id:`hq-control-run-cwd`,className:`hq-input`,value:M,onChange:e=>pe(e.target.value),placeholder:``}),(0,m.jsxs)(`div`,{className:`hq-control-warning`,children:[`RCE-gated: the client must run with `,(0,m.jsx)(`code`,{children:`--hq-allow-exec`}),` and your token needs the `,(0,m.jsx)(`code`,{children:`control.execute`}),` capability — otherwise the server rejects this. Preview requires typing `,(0,m.jsx)(`strong`,{children:`RUN`}),` before dispatch.`]})]}),c===`broadcast`&&(0,m.jsxs)(`div`,{className:`hq-card`,children:[(0,m.jsx)(`label`,{className:`hq-label`,htmlFor:`hq-control-broadcast-subject`,children:`Subject`}),(0,m.jsx)(`input`,{id:`hq-control-broadcast-subject`,className:`hq-input`,value:k,onChange:e=>{ue(e.target.value),d({broadcastSubject:e.target.value})}}),(0,m.jsx)(`label`,{className:`hq-label hq-mt-8`,htmlFor:`hq-control-broadcast-body`,children:`Body`}),(0,m.jsx)(`textarea`,{id:`hq-control-broadcast-body`,className:`hq-textarea`,value:A,onChange:e=>{de(e.target.value),d({broadcastBody:e.target.value})}})]})]}),(0,m.jsx)(`div`,{className:`hq-card-title`,children:`Dispatch Gate`}),(0,m.jsxs)(`div`,{className:`hq-card hq-command-preview`+(K.risk===`danger`?` hq-card-danger`:``),children:[(0,m.jsxs)(`div`,{className:`hq-row`,children:[(0,m.jsx)(`span`,{className:`hq-pill `+(K.risk===`danger`?`error`:`info`),children:K.risk}),(0,m.jsx)(`span`,{children:K.summary}),K.disabledReason!==null&&(0,m.jsx)(`span`,{className:`hq-pill warn`,children:K.disabledReason})]}),g===`preview`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`hq-msg-sublabel`,children:`payload preview`}),(0,m.jsx)(`pre`,{className:`hq-msg-pre`,children:JSON.stringify({clientId:i,type:K.type,payload:K.payload},null,2)}),q&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`label`,{className:`hq-label hq-mt-12`,htmlFor:`hq-control-confirm`,children:`Confirm destructive dispatch`}),(0,m.jsx)(`input`,{id:`hq-control-confirm`,className:`hq-input`,value:N,onChange:e=>P(e.target.value),placeholder:`Type ${J}`})]}),(0,m.jsxs)(`div`,{className:`hq-row hq-mt-12`,children:[(0,m.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:z||!Y,onClick:()=>void $(),title:`Ctrl+Enter`,children:z?`Dispatching…`:`Dispatch Command`}),(0,m.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:z,onClick:Z,children:`Back to Compose`})]})]}):(0,m.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:!X,onClick:()=>{b(`preview`),I(null),R(null)},title:`Ctrl+Enter`,children:`Preview Command`})]}),F&&(0,m.jsx)(`div`,{className:`hq-pill active hq-mt-12`,children:F}),L&&(0,m.jsx)(`div`,{className:`hq-pill error hq-mt-12`,children:L})]}),(0,m.jsxs)(`div`,{className:`hq-control-audit`,children:[(0,m.jsx)(`div`,{className:`hq-card-title`,children:`Command Audit`}),(0,m.jsxs)(`div`,{className:`hq-card hq-command-audit`,children:[(0,m.jsxs)(`div`,{className:`hq-row`,children:[(0,m.jsxs)(`span`,{className:`hq-pill info`,children:[`recent `,V.length]}),me&&(0,m.jsx)(`span`,{className:`hq-pill idle`,children:`refreshing`}),W!==null&&(0,m.jsx)(`span`,{className:`hq-pill error`,children:W}),(0,m.jsx)(`button`,{type:`button`,className:`hq-btn secondary hq-ml-auto`,onClick:()=>void Q(),children:`Refresh`})]}),V.length===0?(0,m.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:`No command audit entries yet.`}):(0,m.jsx)(`div`,{className:`hq-audit-list`,children:V.map(e=>(0,m.jsxs)(`div`,{className:`hq-audit-row`+(e.commandId===he?` just-dispatched`:``)+(i!==null&&e.clientId===i?``:` other-client`),children:[(0,m.jsxs)(`div`,{className:`hq-audit-main`,children:[(0,m.jsx)(`span`,{className:`hq-pill `+ae(e),children:e.status}),(0,m.jsx)(`span`,{className:`hq-pill info`,children:e.type}),(0,m.jsx)(`span`,{className:`hq-mono`,children:_(e.commandId)}),e.ackStatus!==void 0&&(0,m.jsxs)(`span`,{className:`hq-pill `+y(e.ackStatus),children:[`ack `,e.ackStatus]})]}),(0,m.jsxs)(`div`,{className:`hq-audit-meta`,children:[(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`client`}),` `,_(e.clientId)]}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`by`}),` `,e.enqueuedBy]}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`queued`}),` `,v(e.enqueuedAt)]}),e.ackedAt!==void 0&&(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`acked`}),` `,v(e.ackedAt)]})]}),e.ackMessage!==void 0&&e.ackMessage.length>0&&(0,m.jsx)(`div`,{className:`hq-audit-message`,children:e.ackMessage})]},e.commandId))})]})]})]})}function _(e){return e.length>18?`${e.slice(0,10)}…${e.slice(-6)}`:e}function ie(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}`}`} › ${_(r?.sessionId??e.clientId)}`}function v(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 ae(e){return e.ackStatus===`failed`||e.ackStatus===`rejected`?`error`:e.status===`acked`?`active`:e.status===`delivered`?`info`:e.status===`queued`?`warn`:`idle`}function y(e){return e===`failed`||e===`rejected`?`error`:e===`completed`?`active`:`info`}export{g as ControlView};