@wrongstack/webui-hq 0.292.1 → 0.295.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/assets/{alerts-CWaseVj8.js → alerts-CCugwgav.js} +1 -1
- package/dist/assets/{brain-DU8mix0V.js → brain-B4c9I7Iz.js} +1 -1
- package/dist/assets/{cockpit-DP0tuuzs.js → cockpit-BNmAUOW3.js} +1 -1
- package/dist/assets/control-S5yrWkvI.js +1 -0
- package/dist/assets/{cost-D2BIAuKs.js → cost-Dv9QJeiN.js} +1 -1
- package/dist/assets/{fleet-map-BtYC_Ydf.js → fleet-map-DwyIJ9eT.js} +2 -2
- package/dist/assets/{fleet-topology-C_gii-RC.js → fleet-topology-BvvbVfxl.js} +7 -7
- package/dist/assets/icons-DqAimWQw.js +1 -0
- package/dist/assets/index-BzkE5Twh.js +2 -0
- package/dist/assets/{index-G4pDhbF0.css → index-DK0iHwRK.css} +1 -1
- package/dist/assets/kanban-CCFMWoeJ.js +1 -0
- package/dist/assets/{live-console-BlqOehGt.js → live-console-BohkVPBV.js} +1 -1
- package/dist/assets/mailbox-BvywYC09.js +1 -0
- package/dist/assets/{markdown-Dm2qU66U.js → markdown-CXUACKKT.js} +1 -1
- package/dist/assets/{settings-DdncdaZK.js → settings-CMLIjhdk.js} +1 -1
- package/dist/assets/{trends-DWnLrGaS.js → trends-UVxCM20H.js} +1 -1
- package/dist/assets/{use-backfilled-events-DMTqAxHb.js → use-backfilled-events-DsMh9jtv.js} +1 -1
- package/dist/assets/{vendor-BoaR8QxN.js → vendor-CQLHN-L-.js} +1 -1
- package/dist/assets/worktree-DTw8uGwj.js +1 -0
- package/dist/index.html +5 -5
- package/package.json +4 -3
- package/dist/assets/control-CynJZLcm.js +0 -1
- package/dist/assets/icons-BlGYTg3M.js +0 -1
- package/dist/assets/index-DzLBc00n.js +0 -2
- package/dist/assets/mailbox-BCg0PskE.js +0 -1
- package/dist/assets/worktree-C_TC9kKj.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/cockpit-DP0tuuzs.js","assets/rolldown-runtime-QTnfLwEv.js","assets/icons-BlGYTg3M.js","assets/markdown-Dm2qU66U.js","assets/fleet-map-BtYC_Ydf.js","assets/vendor-BoaR8QxN.js","assets/fleet-topology-C_gii-RC.js","assets/live-console-BlqOehGt.js","assets/mailbox-BCg0PskE.js","assets/use-backfilled-events-DMTqAxHb.js","assets/cost-D2BIAuKs.js","assets/brain-DU8mix0V.js","assets/worktree-C_TC9kKj.js","assets/trends-DWnLrGaS.js","assets/alerts-CWaseVj8.js","assets/control-CynJZLcm.js","assets/settings-DdncdaZK.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{A as t,At as n,Et as r,G as i,L as a,M as o,Mt as s,Nt as c,Ot as l,S as u,T as d,_ as ee,a as te,c as f,ft as p,g as m,i as ne,k as h,o as re,p as ie,q as g,tt as _,u as ae,vt as v,w as oe,x as y}from"./icons-BlGYTg3M.js";import{t as b}from"./vendor-BoaR8QxN.js";import{i as x}from"./markdown-Dm2qU66U.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var S=e(c(),1),C=b(),w=e=>Symbol.iterator in e,T=e=>`entries`in e,E=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},se=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function ce(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:w(e)&&w(t)?T(e)&&T(t)?E(e,t):se(e,t):E({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function le(e){let t=S.useRef(void 0);return n=>{let r=e(n);return ce(t.current,r)?t.current:t.current=r}}var D=`wrongstack.hq.token.v1`;function ue(){if(typeof window>`u`)return null;try{let e=new URLSearchParams(window.location.search).get(`token`);return e!==null&&e.length>0?e:null}catch{return null}}function O(){if(typeof window>`u`)return null;try{return window.sessionStorage??null}catch{return null}}function de(){try{let e=O()?.getItem(D)??null;return e!==null&&e.length>0?e:null}catch{return null}}function k(e){try{O()?.setItem(D,e)}catch{}}function A(){try{O()?.removeItem(D)}catch{}}function j(){let e=ue();return e===null?de():(k(e),e)}function fe(){if(typeof window>`u`)return;let e=ue();if(e!==null&&(k(e),de()===e))try{let e=new URL(window.location.href);e.searchParams.delete(`token`),window.history.replaceState(null,``,`${e.pathname}${e.search}${e.hash}`)}catch{}}function pe(){let e=j();return e===null?{}:{Authorization:`Bearer ${e}`}}function M(e,t){let n={...t?.headers??{},...pe()};return fetch(e,{...t,headers:n})}var N=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},me=(e=>e?N(e):N),he=e=>e;function ge(e,t=he){let n=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(n),n}var P=e=>{let t=me(e),n=e=>ge(t,e);return Object.assign(n,t),n},_e=(e=>e?P(e):P);function F(e,t){let n=t.liveSessions??[],r=e.selectedSessionId===null?void 0:n.find(t=>t.sessionId===e.selectedSessionId),i=e.selectedAgentId===null||r?.agents.some(t=>t.id===e.selectedAgentId)===!0,a=e.selectedClientId===null||t.clients.some(t=>t.clientId===e.selectedClientId);return{snapshot:t,...e.selectedSessionId!==null&&r===void 0?{selectedSessionId:null,selectedAgentId:null}:i?{}:{selectedAgentId:null},...a?{}:{selectedClientId:null}}}function ve(e,t){return e.timestamp===t.timestamp&&e.severity===t.severity&&e.message===t.message}var I=_e()(e=>({snapshot:null,events:[],alerts:[],commandStatuses:[],activeView:`cockpit`,selectedSessionId:null,selectedAgentId:null,selectedClientId:null,connected:!1,authRequired:!1,setActiveView:t=>e({activeView:t}),selectSession:(t,n=null)=>e({selectedSessionId:t,selectedAgentId:n}),selectAgent:(t,n)=>e({selectedSessionId:t,selectedAgentId:n}),selectClient:t=>e({selectedClientId:t}),markAuthRequired:()=>e(e=>e.authRequired?{}:{authRequired:!0}),_hydrateSnapshot:t=>e(e=>e.snapshot===null?F(e,t):{}),_onSnapshot:t=>e(e=>({...F(e,t),connected:!0})),_onEvent:t=>e(e=>e.events.some(e=>e.id===t.id)?{}:{events:[...e.events,t].slice(-500)}),_onAlert:t=>e(e=>e.alerts.some(e=>ve(e,t))?{}:{alerts:[...e.alerts,t].slice(-100)}),_onCommandStatus:t=>e(e=>{let n=e.commandStatuses.findIndex(e=>e.commandId===t.commandId);if(n<0)return{commandStatuses:[...e.commandStatuses,t].slice(-200)};let r=[...e.commandStatuses];return r[n]=t,{commandStatuses:r}}),_setConnected:t=>e({connected:t})}));async function L(e){let t;try{t=await M(e)}catch{throw Error(`Network error fetching ${e}`)}if(t.status===401)throw I.getState().markAuthRequired(),Error(`401 Unauthorized fetching ${e} — browser token required`);if(!t.ok)throw Error(`${t.status} ${t.statusText}`);try{return await t.json()}catch{throw Error(`Invalid JSON response from ${e}: ${t.status}`)}}async function ye(e){let t;try{t=await M(`/api/mailbox-send`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}catch{throw Error(`Network error sending mailbox message`)}if(t.status===401)throw I.getState().markAuthRequired(),Error(`401 Unauthorized — browser token required`);if(!t.ok){let e=await t.json().catch(()=>null),n=typeof e?.error==`string`?e.error:t.statusText||`HTTP ${t.status}`;throw Error(n)}try{return await t.json()}catch{throw Error(`Invalid JSON response from mailbox-send API`)}}async function be(e,t,n){let r;try{r=await M(`/api/command`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:e,type:t,payload:n})})}catch{throw Error(`Network error sending command`)}if(r.status===401)throw I.getState().markAuthRequired(),Error(`401 Unauthorized — browser token required`);if(!r.ok){let e=(await r.json().catch(()=>null))?.error??(r.statusText||`HTTP ${r.status}`);throw Error(e)}try{return await r.json()}catch{throw Error(`Invalid JSON response from command API`)}}var R=`wrongstack.hq.local-prefs.v1`,z={appearance:{theme:`dark`},fleet:{scope:`all`,layout:`map`,machineId:``,projectId:``},console:{delivery:`steer`,subject:``,body:``},control:{cmdType:`steer`,abortTarget:`leader`,spawnRole:`bug-hunter`,spawnTask:``,steerTo:`leader`,steerSubject:``,steerBody:``,broadcastSubject:``,broadcastBody:``},mailbox:{query:``,types:[],priorities:[],includeCompleted:!0}},B=null,V=new Set;function H(){for(let e of V)e()}function U(e){return typeof structuredClone==`function`?structuredClone(e):JSON.parse(JSON.stringify(e))}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xe(){if(typeof window>`u`||window.localStorage===void 0)return U(z);try{let e=window.localStorage.getItem(R);return e===null?U(z):Se(JSON.parse(e))}catch{return U(z)}}function Se(e){if(!W(e))return U(z);let t=W(e.appearance)?e.appearance:{},n=W(e.fleet)?e.fleet:{},r=W(e.console)?e.console:{},i=W(e.control)?e.control:{},a=W(e.mailbox)?e.mailbox:{};return{appearance:{theme:t.theme===`light`?`light`:`dark`},fleet:{scope:n.scope===`machine`||n.scope===`project`?n.scope:`all`,layout:n.layout===`compact`?`compact`:`map`,machineId:typeof n.machineId==`string`?n.machineId:``,projectId:typeof n.projectId==`string`?n.projectId:``},console:{delivery:r.delivery===`btw`||r.delivery===`queue`?r.delivery:`steer`,subject:typeof r.subject==`string`?r.subject:``,body:typeof r.body==`string`?r.body:``},control:{cmdType:i.cmdType===`btw`||i.cmdType===`queue`||i.cmdType===`abort`||i.cmdType===`spawn`||i.cmdType===`broadcast`||i.cmdType===`run-command`?i.cmdType:z.control.cmdType,abortTarget:i.abortTarget===`fleet`?`fleet`:`leader`,spawnRole:typeof i.spawnRole==`string`&&i.spawnRole.length>0?i.spawnRole:z.control.spawnRole,spawnTask:typeof i.spawnTask==`string`?i.spawnTask:z.control.spawnTask,steerTo:typeof i.steerTo==`string`?i.steerTo:z.control.steerTo,steerSubject:typeof i.steerSubject==`string`?i.steerSubject:z.control.steerSubject,steerBody:typeof i.steerBody==`string`?i.steerBody:z.control.steerBody,broadcastSubject:typeof i.broadcastSubject==`string`?i.broadcastSubject:z.control.broadcastSubject,broadcastBody:typeof i.broadcastBody==`string`?i.broadcastBody:z.control.broadcastBody},mailbox:{query:typeof a.query==`string`?a.query:z.mailbox.query,types:Array.isArray(a.types)?a.types.filter(e=>typeof e==`string`):[],priorities:Array.isArray(a.priorities)?a.priorities.filter(e=>typeof e==`string`):[],includeCompleted:typeof a.includeCompleted!=`boolean`||a.includeCompleted}}}function G(){return B===null&&(B=xe()),B}function K(e){if(!(typeof window>`u`||window.localStorage===void 0))try{window.localStorage.setItem(R,JSON.stringify(e))}catch{}}function Ce(e){return V.add(e),()=>V.delete(e)}function we(){return G()}function Te(){return z}function q(){return(0,S.useSyncExternalStore)(Ce,we,Te)}function Ee(e){let t=G();B={...t,control:{...t.control,...e}},K(B),H()}function De(e){let t=G();B={...t,appearance:{...t.appearance,...e}},K(B),H()}function Oe(e){let t=G();B={...t,fleet:{...t.fleet,...e}},K(B),H()}function ke(e){let t=G();B={...t,console:{...t.console,...e}},K(B),H()}function Ae(e){let t=G();B={...t,mailbox:{...t.mailbox,...e}},K(B),H()}var J=x();function je({hadToken:e}){let[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(null);(0,S.useEffect)(()=>{fetch(`/api/auth/status`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(n).catch(()=>i(`Could not load HQ auth status.`))},[]);let a=t?.tokenMode??!0,o=t?.passwordMode??!1,[s,c]=(0,S.useState)(`token`);return(0,S.useEffect)(()=>{t&&c(t.passwordMode?`password`:`token`)},[t]),r?(0,J.jsx)(`div`,{className:`hq-token-gate`,children:(0,J.jsxs)(`div`,{className:`hq-token-card`,children:[(0,J.jsx)(`div`,{className:`hq-brand`,children:`WrongStack HQ`}),(0,J.jsx)(`div`,{className:`hq-token-title`,children:`Auth status unavailable`}),(0,J.jsx)(`p`,{className:`hq-token-text`,children:r})]})}):t?(0,J.jsx)(`div`,{className:`hq-token-gate`,children:(0,J.jsxs)(`div`,{className:`hq-token-card`,children:[(0,J.jsx)(`div`,{className:`hq-brand`,children:`WrongStack HQ`}),a&&o?(0,J.jsxs)(`div`,{className:`hq-token-tabs`,children:[(0,J.jsx)(`button`,{type:`button`,className:`hq-token-tab`+(s===`token`?` active`:``),onClick:()=>c(`token`),children:`Browser token`}),(0,J.jsx)(`button`,{type:`button`,className:`hq-token-tab`+(s===`password`?` active`:``),onClick:()=>c(`password`),children:`Password`})]}):null,s===`token`||!o?(0,J.jsx)(Me,{hadToken:e}):(0,J.jsx)(Ne,{})]})}):(0,J.jsx)(`div`,{className:`hq-token-gate`,children:(0,J.jsxs)(`div`,{className:`hq-token-card`,children:[(0,J.jsx)(`div`,{className:`hq-brand`,children:`WrongStack HQ`}),(0,J.jsx)(`div`,{className:`hq-token-title`,children:`Checking auth mode…`})]})})}function Me({hadToken:e}){let[t,n]=(0,S.useState)(``),r=()=>{let e=t.trim();e.length!==0&&(k(e),window.location.reload())};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`hq-token-title`,children:`Browser token required`}),(0,J.jsx)(`p`,{className:`hq-token-text`,children:e?`The saved token was rejected — it may have been revoked or the server was reset. Paste a current browser token.`:`This HQ server runs in token mode. Paste the browser token printed at startup (the ?token= value in the URL wstack --hq shows).`}),(0,J.jsx)(`input`,{className:`hq-token-input`,type:`password`,placeholder:`browser token`,autoComplete:`off`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}}),(0,J.jsx)(`button`,{type:`button`,className:`hq-token-submit`,onClick:r,disabled:t.trim().length===0,children:`Connect`}),(0,J.jsxs)(`p`,{className:`hq-token-hint`,children:[`Manage tokens with `,(0,J.jsx)(`code`,{children:`wstack hq token list`}),` / `,(0,J.jsx)(`code`,{children:`wstack hq token create`}),` — they live in `,(0,J.jsx)(`code`,{children:`~/.wrongstack/hq/auth.json`}),`.`]})]})}function Ne(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(!1),o=async()=>{let t=e;if(t.length!==0){a(!0),r(null);try{let e=await fetch(`/api/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:t})});if(!e.ok){let t=`Login failed.`;try{let n=(await e.json()).error;typeof n==`string`?t=n:typeof n?.message==`string`&&(t=n.message)}catch{}r(t),a(!1);return}A(),window.location.reload()}catch{r(`Network error. Is the HQ server running?`),a(!1)}}};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`hq-token-title`,children:`Password required`}),(0,J.jsx)(`p`,{className:`hq-token-text`,children:`This HQ server is protected by a password. Enter it to open the dashboard.`}),n?(0,J.jsx)(`p`,{className:`hq-token-error`,children:n}):null,(0,J.jsx)(`input`,{className:`hq-token-input`,type:`password`,placeholder:`password`,autoComplete:`current-password`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&o()}}),(0,J.jsx)(`button`,{type:`button`,className:`hq-token-submit`,onClick:()=>void o(),disabled:e.length===0||i,children:i?`Logging in…`:`Log in`}),(0,J.jsxs)(`p`,{className:`hq-token-hint`,children:[`Set or change the password with `,(0,J.jsx)(`code`,{children:`wstack --hq --password <secret>`}),`.`]})]})}var Pe=`modulepreload`,Fe=function(e){return`/`+e},Ie={},Y=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Fe(t,n),t=s(t),t in Ie)return;Ie[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Pe,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Le=360*60*1e3,X=[{id:`cockpit`,label:`Cockpit`,eyebrow:`Fleet overview`,description:`Health, active work, alerts, cost and command shortcuts.`,group:`Operations`,icon:i,shortcut:1},{id:`fleet`,label:`Fleet Map`,eyebrow:`Topology`,description:`Machines, projects, terminals and agents in one live graph.`,group:`Operations`,icon:h,shortcut:2},{id:`console`,label:`Live Console`,eyebrow:`Transcripts`,description:`Stream and inspect session or agent conversations.`,group:`Operations`,icon:o,shortcut:3},{id:`mailbox`,label:`Mailbox`,eyebrow:`Coordination`,description:`Cross-project messages, unread work and direct delivery.`,group:`Operations`,icon:g,shortcut:4},{id:`alerts`,label:`Alerts`,eyebrow:`Attention`,description:`Active fleet warnings and alert transition history.`,group:`Intelligence`,icon:n,shortcut:5},{id:`cost`,label:`Cost`,eyebrow:`Economics`,description:`Project, provider and model spending distribution.`,group:`Intelligence`,icon:v,shortcut:6},{id:`trends`,label:`Trends`,eyebrow:`Telemetry`,description:`Cost, token and tool activity over time.`,group:`Intelligence`,icon:r,shortcut:7},{id:`brain`,label:`Brain`,eyebrow:`Decisions`,description:`Autonomous decisions, escalations and interventions.`,group:`Intelligence`,icon:l,shortcut:8},{id:`worktree`,label:`Worktrees`,eyebrow:`Workspace`,description:`Distributed branches, worktrees and ownership state.`,group:`System`,icon:_,shortcut:9},{id:`control`,label:`Control`,eyebrow:`Command plane`,description:`Steer, queue, broadcast and audit remote commands.`,group:`System`,icon:u,shortcut:0},{id:`settings`,label:`Security`,eyebrow:`Access control`,description:`Manage the HQ browser password, authentication and active credentials.`,group:`System`,icon:m}],Re=[`Operations`,`Intelligence`,`System`],ze={cockpit:(0,S.lazy)(()=>Y(()=>import(`./cockpit-DP0tuuzs.js`).then(e=>({default:e.CockpitView})),__vite__mapDeps([0,1,2,3]))),fleet:(0,S.lazy)(()=>Y(()=>import(`./fleet-map-BtYC_Ydf.js`).then(e=>({default:e.FleetMapView})),__vite__mapDeps([4,1,2,5,3,6]))),console:(0,S.lazy)(()=>Y(()=>import(`./live-console-BlqOehGt.js`).then(e=>({default:e.LiveConsoleView})),__vite__mapDeps([7,1,2,3,6,5]))),mailbox:(0,S.lazy)(()=>Y(()=>import(`./mailbox-BCg0PskE.js`).then(e=>({default:e.MailboxView})),__vite__mapDeps([8,1,2,3,9]))),cost:(0,S.lazy)(()=>Y(()=>import(`./cost-D2BIAuKs.js`).then(e=>({default:e.CostView})),__vite__mapDeps([10,1,2,3]))),brain:(0,S.lazy)(()=>Y(()=>import(`./brain-DU8mix0V.js`).then(e=>({default:e.BrainView})),__vite__mapDeps([11,2,1,3,9]))),worktree:(0,S.lazy)(()=>Y(()=>import(`./worktree-C_TC9kKj.js`).then(e=>({default:e.WorktreeView})),__vite__mapDeps([12,1,2,3,9]))),trends:(0,S.lazy)(()=>Y(()=>import(`./trends-DWnLrGaS.js`).then(e=>({default:e.TrendsView})),__vite__mapDeps([13,1,2,3]))),alerts:(0,S.lazy)(()=>Y(()=>import(`./alerts-CWaseVj8.js`).then(e=>({default:e.AlertsView})),__vite__mapDeps([14,1,2,3]))),control:(0,S.lazy)(()=>Y(()=>import(`./control-CynJZLcm.js`).then(e=>({default:e.ControlView})),__vite__mapDeps([15,1,2,3]))),settings:(0,S.lazy)(()=>Y(()=>import(`./settings-DdncdaZK.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([16,1,2,3])))};function Be(e){return X.find(t=>t.id===e)??X[0]}var Ve=class extends S.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e.message:String(e)}}componentDidUpdate(e){e.view!==this.props.view&&this.state.error!==null&&this.setState({error:null})}render(){return this.state.error===null?this.props.children:(0,J.jsxs)(`div`,{className:`hq-view-error`,role:`alert`,children:[(0,J.jsx)(ie,{size:22}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:`This HQ surface stopped safely.`}),(0,J.jsx)(`p`,{children:this.state.error})]}),(0,J.jsxs)(`button`,{type:`button`,className:`hq-btn secondary`,onClick:()=>this.setState({error:null}),children:[(0,J.jsx)(y,{size:13}),`Retry view`]})]})}};function He(){let{snapshot:e,alerts:n,activeView:r,authRequired:i,connected:o}=I(le(e=>({snapshot:e.snapshot,alerts:e.alerts,activeView:e.activeView,authRequired:e.authRequired,connected:e.connected}))),[c,l]=(0,S.useState)(()=>typeof window>`u`||window.innerWidth>=1180),[u,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(null),[h,ie]=(0,S.useState)(!1),{theme:g}=q().appearance;if((0,S.useEffect)(()=>(document.documentElement.dataset.hqTheme=g,()=>{delete document.documentElement.dataset.hqTheme}),[g]),(0,S.useEffect)(()=>{let e=!1;return L(`/api/snapshot`).then(t=>{e||I.getState()._hydrateSnapshot(t)}).catch(()=>{}),()=>{e=!0}},[]),(0,S.useEffect)(()=>{let e=!1;return L(`/api/auth/status`).then(t=>{e||m(t)}).catch(()=>{}),()=>{e=!0}},[]),(0,S.useEffect)(()=>{let e=!1,t=()=>{L(`/api/system/update`).then(t=>{e||f(t)}).catch(()=>{})};t();let n=window.setInterval(t,Le);return()=>{e=!0,window.clearInterval(n)}},[]),(0,S.useEffect)(()=>{let e=e=>{if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`b`){e.preventDefault(),l(e=>!e);return}if(e.altKey&&/^\d$/.test(e.key)){let t=Number(e.key),n=X.find(e=>e.shortcut===t);n&&(e.preventDefault(),I.getState().setActiveView(n.id));return}e.key===`Escape`&&c&&window.innerWidth<900&&l(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c]),i)return(0,J.jsx)(je,{hadToken:j()!==null});let _=e?.totals,y=_?.unreadMailboxMessages??0,b=n.filter(e=>e.severity!==`info`).length,x=Be(r),C=x.icon,w=ze[r],T=e=>{I.getState().setActiveView(e),window.innerWidth<900&&l(!1)},E=async()=>{ie(!0);try{await M(`/api/logout`,{method:`POST`})}finally{A(),window.location.reload()}};return(0,J.jsxs)(`div`,{className:`hq-app`,"data-theme":g,"data-testid":`hq-workbench`,children:[(0,J.jsx)(`button`,{type:`button`,className:`hq-sidebar-scrim`,"data-open":c,"aria-label":`Close HQ navigation`,onClick:()=>l(!1)}),(0,J.jsxs)(`aside`,{className:`hq-secondary-nav`,"data-open":c,"aria-label":`HQ navigation`,children:[(0,J.jsxs)(`div`,{className:`hq-secondary-header`,children:[(0,J.jsxs)(`div`,{className:`hq-secondary-brand`,children:[(0,J.jsx)(`img`,{src:`/wrongstack.svg`,alt:``,"aria-hidden":`true`,draggable:!1}),(0,J.jsxs)(`div`,{className:`hq-secondary-copy`,children:[(0,J.jsx)(`span`,{className:`hq-secondary-eyebrow`,children:`Command center`}),(0,J.jsx)(`strong`,{children:`WrongStack HQ`})]})]}),(0,J.jsx)(`button`,{type:`button`,className:`hq-icon-button hq-secondary-close`,"aria-label":`Collapse HQ navigation`,title:`Collapse navigation (Ctrl+B)`,onClick:()=>l(!1),children:(0,J.jsx)(d,{size:16})})]}),(0,J.jsx)(`div`,{className:`hq-secondary-scroll`,children:Re.map(e=>(0,J.jsxs)(`section`,{className:`hq-nav-group`,children:[(0,J.jsx)(`div`,{className:`hq-nav-group-label`,children:e}),X.filter(t=>t.group===e).map(e=>{let t=e.icon,n=e.id===`mailbox`?y:e.id===`alerts`?b:0;return(0,J.jsxs)(`button`,{type:`button`,className:`hq-nav-item`,"data-active":r===e.id,"aria-current":r===e.id?`page`:void 0,onClick:()=>T(e.id),children:[(0,J.jsx)(t,{size:15}),(0,J.jsx)(`span`,{children:e.label}),e.shortcut===void 0?null:(0,J.jsxs)(`kbd`,{children:[`Alt+`,e.shortcut]}),n>0?(0,J.jsx)(`span`,{className:`hq-nav-badge`,children:n}):null]},e.id)})]},e))}),(0,J.jsxs)(`div`,{className:`hq-secondary-footer`,children:[(0,J.jsxs)(`div`,{className:`hq-link-state`,"data-live":o,children:[(0,J.jsx)(`span`,{className:`hq-link-dot`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:o?`Connected`:`Reconnecting`}),(0,J.jsxs)(`span`,{children:[_?.activeMachines??0,` machines · `,_?.activeClients??0,` clients`]})]})]}),(0,J.jsx)(`span`,{className:`hq-build-label`,children:`@wrongstack/webui-hq`})]})]}),(0,J.jsxs)(`section`,{className:`hq-workbench`,"data-update-available":u?.outdated===!0,children:[(0,J.jsxs)(`header`,{className:`hq-header`,children:[(0,J.jsx)(`button`,{type:`button`,className:`hq-icon-button hq-sidebar-toggle`,"aria-label":c?`Collapse HQ navigation`:`Expand HQ navigation`,"aria-expanded":c,title:`Toggle navigation (Ctrl+B)`,onClick:()=>l(e=>!e),children:c?(0,J.jsx)(d,{size:17}):(0,J.jsx)(oe,{size:17})}),(0,J.jsx)(`div`,{className:`hq-view-icon`,"aria-hidden":`true`,children:(0,J.jsx)(C,{size:18})}),(0,J.jsxs)(`div`,{className:`hq-view-identity`,children:[(0,J.jsx)(`span`,{children:x.eyebrow}),(0,J.jsx)(`h1`,{children:x.label}),(0,J.jsx)(`p`,{children:x.description})]}),(0,J.jsxs)(`div`,{className:`hq-top-metrics`,children:[(0,J.jsx)(Z,{icon:ee,label:`Machines`,value:_?.activeMachines??0}),(0,J.jsx)(Z,{icon:re,label:`Agents`,value:_?.activeAgents??0}),(0,J.jsx)(Z,{icon:s,label:`Sessions`,value:_?.activeSessions??0}),(0,J.jsx)(Z,{icon:v,label:`Cost`,value:`$${(_?.totalCostUsd??0).toFixed(2)}`,accent:!0})]}),(0,J.jsxs)(`div`,{className:`hq-connection-pill`,"data-live":o,children:[o?(0,J.jsx)(ne,{size:13}):(0,J.jsx)(te,{size:13}),o?`Live`:`Reconnecting`]}),(0,J.jsx)(`button`,{type:`button`,className:`hq-icon-button hq-theme-toggle`,"aria-label":`Switch to ${g===`dark`?`light`:`dark`} mode`,title:`Switch to ${g===`dark`?`light`:`dark`} mode`,onClick:()=>De({theme:g===`dark`?`light`:`dark`}),children:g===`dark`?(0,J.jsx)(ae,{size:16}):(0,J.jsx)(t,{size:16})}),p?.tokenMode||p?.passwordMode?(0,J.jsx)(`button`,{type:`button`,className:`hq-icon-button`,"aria-label":`Log out of HQ`,title:`Log out and clear this tab's HQ credentials`,disabled:h,onClick:()=>void E(),children:(0,J.jsx)(a,{size:16})}):null]}),u?.outdated?(0,J.jsx)(Ue,{status:u}):null,(0,J.jsx)(`main`,{className:`hq-main`,id:`hq-main`,tabIndex:-1,children:(0,J.jsx)(Ve,{view:r,children:(0,J.jsx)(S.Suspense,{fallback:(0,J.jsx)(We,{label:x.label}),children:(0,J.jsx)(w,{})})})})]})]})}function Ue({status:e}){let[t,n]=(0,S.useState)(!1),r=async()=>{try{await navigator.clipboard.writeText(e.command),n(!0),window.setTimeout(()=>n(!1),1500)}catch{n(!1)}};return(0,J.jsxs)(`aside`,{className:`hq-update-notice`,role:`status`,"aria-live":`polite`,children:[(0,J.jsx)(f,{size:16,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:`WrongStack update available`}),(0,J.jsxs)(`span`,{children:[`v`,e.current,` → v`,e.latest,`. Run `,(0,J.jsx)(`code`,{children:e.command}),` in your terminal, then restart HQ.`]})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>void r(),title:`Copy update command`,children:[(0,J.jsx)(p,{size:13,"aria-hidden":`true`}),t?`Copied`:`Copy command`]})]})}function Z({icon:e,label:t,value:n,accent:r=!1}){return(0,J.jsxs)(`div`,{className:`hq-top-metric`,"data-accent":r,children:[(0,J.jsx)(e,{size:12}),(0,J.jsx)(`span`,{children:t}),(0,J.jsx)(`strong`,{children:n})]})}function We({label:e}){return(0,J.jsxs)(`div`,{className:`hq-view-loading`,role:`status`,children:[(0,J.jsx)(u,{size:18}),(0,J.jsxs)(`span`,{children:[`Loading `,e,`…`]})]})}var Ge=25e3,Ke=1e4,qe=3e4,Je=class{ws=null;handlers=new Set;stateHandlers=new Set;reconnectAttempt=0;reconnectTimer=null;heartbeatTimer=null;lastMessageAt=0;stopped=!1;_state=`disconnected`;url;maxRetries;heartbeatIntervalMs;heartbeatTimeoutMs;maxBackoffMs;constructor(e){if(this.maxRetries=e?.maxRetries??1/0,this.heartbeatIntervalMs=e?.heartbeatIntervalMs??Ge,this.heartbeatTimeoutMs=e?.heartbeatTimeoutMs??Ke,this.maxBackoffMs=e?.maxBackoffMs??qe,e?.url)this.url=e.url;else{let e=typeof window<`u`?window.location:{host:`127.0.0.1:3499`,protocol:`http:`},t=e.protocol===`https:`?`wss:`:`ws:`,n=j(),r=`${t}//${e.host}/ws/browser`;this.url=n===null?r:`${r}?token=${encodeURIComponent(n)}`}}get state(){return this._state}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}connect(){if(this.stopped||this.ws!==null)return;this.emitState(`connecting`);let e;try{e=new WebSocket(this.url)}catch{this.scheduleReconnect();return}this.ws=e,e.onopen=()=>{this.reconnectAttempt=0,this.lastMessageAt=Date.now(),this.emitState(`connected`),this.startHeartbeat()},e.onmessage=e=>{this.lastMessageAt=Date.now();try{let t=JSON.parse(typeof e.data==`string`?e.data:``);for(let e of this.handlers)try{e(t)}catch{}}catch{}},e.onclose=()=>this.handleClose(`close`),e.onerror=()=>this.handleClose(`error`)}close(){this.stopped=!0,this.stopHeartbeat(),this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws?.close(1e3,`client closed`),this.ws=null,this.emitState(`disconnected`)}on(e){return this.handlers.add(e),()=>this.handlers.delete(e)}onStateChange(e){return this.stateHandlers.add(e),e(this._state),()=>this.stateHandlers.delete(e)}handleClose(e){this.ws!==null&&(this.ws=null,this.stopHeartbeat(),this.scheduleReconnect())}scheduleReconnect(){if(this.stopped||this.reconnectTimer!==null)return;if(this.reconnectAttempt>=this.maxRetries){this.emitState(`disconnected`);return}let e=1e3*2**Math.min(this.reconnectAttempt,4)*(.5+Math.random()*.5),t=Math.min(e,this.maxBackoffMs);this.reconnectAttempt++,this.emitState(`reconnecting`),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},t)}get isHeartbeatTimedOut(){return this.ws===null||Date.now()-this.lastMessageAt>this.heartbeatIntervalMs+this.heartbeatTimeoutMs}startHeartbeat(){this.stopHeartbeat(),this.lastMessageAt=Date.now(),this.heartbeatTimer=setInterval(()=>{this.isHeartbeatTimedOut&&this.ws!==null&&(this.ws.close(4e3,`heartbeat timeout`),this.ws=null,this.scheduleReconnect())},this.heartbeatIntervalMs)}stopHeartbeat(){this.heartbeatTimer!==null&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}emitState(e){this._state=e;for(let t of this.stateHandlers)try{t(e)}catch{}}},Q=null;function Ye(){return Q===null&&(Q=new Je,Q.connect()),Q}var $=document.getElementById(`root`);if($!==null){fe();let e=Ye();e.onStateChange(e=>{I.getState()._setConnected(e===`connected`)}),e.on(e=>{e.type===`hq.snapshot`?I.getState()._onSnapshot(e.snapshot):e.type===`hq.event`?I.getState()._onEvent(e.event):e.type===`hq.alert`?I.getState()._onAlert(e):e.type===`hq.command_status`&&I.getState()._onCommandStatus(e.command)}),(0,C.createRoot)($).render((0,J.jsx)(S.StrictMode,{children:(0,J.jsx)(He,{})}))}export{q as a,ye as c,A as d,le as f,Ae as i,I as l,Ee as n,L as o,Oe as r,be as s,ke as t,M as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,F as n,I as r,N as i,Nt as a,O as o,P as s,U as c,bt as l,h as u,nt as d,y as f}from"./icons-BlGYTg3M.js";import{i as p}from"./markdown-Dm2qU66U.js";import{a as m,c as h,f as g,i as _,l as v,u as y}from"./index-DzLBc00n.js";import{t as b}from"./use-backfilled-events-DMTqAxHb.js";var x=e(a(),1),S=p(),C=[{value:`steer`,label:`steer — redirect the current work`},{value:`btw`,label:`btw — FYI, no action required`},{value:`queue`,label:`queue — note for the next agent`},{value:`broadcast`,label:`broadcast — all agents in the project`}];function w({projects:e,sender:t}){let n=t??h,[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(``),[c,l]=(0,x.useState)(`steer`),[u,d]=(0,x.useState)(`leader`),[f,p]=(0,x.useState)(`normal`),[m,g]=(0,x.useState)(``),[_,v]=(0,x.useState)(``),[y,b]=(0,x.useState)({phase:`idle`}),w=o||e[0]?.projectId||``,T=y.phase!==`sending`&&_.trim().length>0&&w.length>0,E=async()=>{if(T){b({phase:`sending`});try{let e=await n({projectId:w,type:c,...c===`broadcast`?{}:{to:u.trim()||`leader`},subject:m.trim()||`HQ prompt`,body:_.trim(),priority:f});b({phase:`sent`,messageId:e.messageId}),v(``)}catch(e){b({phase:`error`,message:e instanceof Error?e.message:String(e)})}}};return i?(0,S.jsxs)(`div`,{className:`hq-card hq-composer`,children:[(0,S.jsxs)(`div`,{className:`hq-row hq-row-baseline`,children:[(0,S.jsx)(`span`,{className:`hq-card-title hq-title-inline`,children:`Send to project mailbox`}),(0,S.jsx)(`span`,{className:`hq-composer-hint`,children:`lands in the mailbox file — picked up by the next agent, no live client needed`}),(0,S.jsx)(`button`,{type:`button`,className:`hq-toggle hq-ml-auto`,"aria-label":`Collapse composer`,onClick:()=>a(!1),children:`▾`})]}),(0,S.jsxs)(`div`,{className:`hq-composer-grid`,children:[(0,S.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,S.jsx)(`span`,{children:`project`}),(0,S.jsx)(`select`,{className:`hq-select`,value:w,onChange:e=>s(e.target.value),children:e.map(e=>(0,S.jsx)(`option`,{value:e.projectId,children:e.label??e.projectId},e.projectId))})]}),(0,S.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,S.jsx)(`span`,{children:`type`}),(0,S.jsx)(`select`,{className:`hq-select`,value:c,onChange:e=>l(e.target.value),children:C.map(e=>(0,S.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),c!==`broadcast`&&(0,S.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,S.jsx)(`span`,{children:`to`}),(0,S.jsx)(`input`,{className:`hq-input`,value:u,placeholder:`leader`,onChange:e=>d(e.target.value)})]}),(0,S.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,S.jsx)(`span`,{children:`priority`}),(0,S.jsxs)(`select`,{className:`hq-select`,value:f,onChange:e=>p(e.target.value),children:[(0,S.jsx)(`option`,{value:`high`,children:`high`}),(0,S.jsx)(`option`,{value:`normal`,children:`normal`}),(0,S.jsx)(`option`,{value:`low`,children:`low`})]})]})]}),(0,S.jsx)(`input`,{className:`hq-input`,value:m,placeholder:`subject (optional)`,onChange:e=>g(e.target.value)}),(0,S.jsx)(`textarea`,{className:`hq-input hq-composer-body`,value:_,rows:3,placeholder:`Message body — e.g. “after the current task, run the full test suite”`,onChange:e=>v(e.target.value)}),(0,S.jsxs)(`div`,{className:`hq-row`,children:[(0,S.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:!T,onClick:()=>void E(),children:y.phase===`sending`?`Sending…`:`Send`}),y.phase===`sent`&&(0,S.jsxs)(`span`,{className:`hq-composer-status ok`,children:[`delivered`,y.messageId===void 0?``:` · ${y.messageId.slice(0,8)}`]}),y.phase===`error`&&(0,S.jsx)(`span`,{className:`hq-composer-status err`,title:y.message,children:y.message})]})]}):(0,S.jsxs)(`div`,{className:`hq-composer-bar`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`hq-btn`,disabled:e.length===0,title:e.length===0?`No projects reported yet — connect a client first`:`Write a message into a project mailbox (works with zero connected agents)`,onClick:()=>a(!0),children:[(0,S.jsx)(r,{size:13}),` Compose`]}),y.phase===`sent`&&(0,S.jsxs)(`span`,{className:`hq-composer-status ok`,children:[`delivered`,y.messageId===void 0?``:` · ${y.messageId.slice(0,8)}`]})]})}function T(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.mailboxId==`string`&&(t.scope===`project`||t.scope===`global`)&&Array.isArray(t.messages)&&Array.isArray(t.agents)&&typeof t.totals==`object`&&t.totals!==null}function E(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.mailboxId==`string`&&typeof t.action==`string`&&(t.message===void 0||typeof t.message==`object`)}function D(e,t){let n=e.get(t);return n===void 0&&(n={projectId:t,messages:[],countersFromSnapshot:!1,onlineAgentCount:0,highPriorityCount:0,unreadCount:0,incompleteCount:0},e.set(t,n)),n}function O(e){let t=0,n=0,r=0;for(let i of e){let e=i.message;e.priority===`high`&&(t+=1),e.completed||(r+=1,(e.readCount??0)===0&&(n+=1))}return{highPriorityCount:t,unreadCount:n,incompleteCount:r}}function k(e){let t=new Map;for(let n of e)(t.get(n.message.mailId)===void 0||n.source===`event`)&&t.set(n.message.mailId,n);return Array.from(t.values()).sort((e,t)=>t.message.timestamp.localeCompare(e.message.timestamp))}function A(e,t){let n=new Map;if(e!==null)for(let t of e.mailboxes){let e=D(n,t.projectId);e.mailboxId=t.mailboxId,e.scope=t.scope,e.onlineAgentCount=t.onlineAgentCount,e.highPriorityCount=t.highPriorityCount,e.unreadCount=t.unreadCount,e.incompleteCount=t.incompleteCount,e.countersFromSnapshot=!0}for(let e of t){if(e.type!==`mailbox.snapshot`||!T(e.payload))continue;let t=e.payload,r=D(n,e.projectId);r.mailboxId=t.mailboxId,r.scope=t.scope;for(let n of t.messages)r.messages.push({message:n,source:`snapshot`,key:`s:${e.id}:${n.messageId}`,projectId:e.projectId})}let r=new Map;for(let e of t){if(e.type!==`mailbox.event`||!E(e.payload))continue;let t=e.payload,i=D(n,e.projectId);i.mailboxId=t.mailboxId,i.scope=i.scope??`project`,t.message!==void 0&&!r.has(t.message.mailId)&&(r.set(t.message.mailId,i),i.messages.push({message:t.message,source:`event`,key:`e:${t.message.mailId}:${e.seq}`,projectId:e.projectId})),t.agent?.online&&(i.onlineAgentCount+=1)}for(let e of n.values())if(e.messages=k(e.messages),!e.countersFromSnapshot){let t=O(e.messages);e.highPriorityCount=t.highPriorityCount,e.unreadCount=t.unreadCount,e.incompleteCount=t.incompleteCount}let i=Array.from(n.values()).sort((e,t)=>{let n=e.messages[0]?.message.timestamp??``;return(t.messages[0]?.message.timestamp??``).localeCompare(n)});return{projects:i,hasAnyActivity:i.some(e=>e.messages.length>0)}}var j=Object.freeze({types:new Set,priorities:new Set,projectIds:new Set,includeCompleted:!0,query:``});function M(e,t){switch(t.type){case`toggle-type`:{let n=new Set(e.types);return n.has(t.value)?n.delete(t.value):n.add(t.value),{...e,types:n}}case`toggle-priority`:{let n=new Set(e.priorities);return n.has(t.value)?n.delete(t.value):n.add(t.value),{...e,priorities:n}}case`toggle-project`:{let n=new Set(e.projectIds);return n.has(t.value)?n.delete(t.value):n.add(t.value),{...e,projectIds:n}}case`set-query`:return{...e,query:t.value};case`set-include-completed`:return{...e,includeCompleted:t.value};case`clear-all`:return j;default:return e}}function N(e,t={}){let n=t.includeCompleted??!0,r=t.types&&t.types.length>0?new Set(t.types):null,i=t.priorities&&t.priorities.length>0?new Set(t.priorities):null,a=t.projectIds&&t.projectIds.length>0?new Set(t.projectIds):null,o=t.query?.trim().toLowerCase()??``,s=t.limit??500,c=[];for(let t of e){let e=t.message;!n&&e.completed||r&&!r.has(e.type)||i&&!i.has(e.priority)||a||o.length>0&&!`${e.subject}\n${e.from}\n${e.to}\n${e.bodyPreview??``}`.toLowerCase().includes(o)||c.push({key:t.key,flat:t})}c.sort((e,t)=>{let n=t.flat.message.timestamp.localeCompare(e.flat.message.timestamp);return n===0?e.flat.message.mailId.localeCompare(t.flat.message.mailId):n});let l=c.length,u=l>s,d=u?c.slice(0,s):c;return{totalMatched:l,returned:d.length,truncated:u,entries:d}}function P(e,t,n={}){let{projectIds:r,...i}=n,a=A(e,t),o=[],s=r!==void 0&&r.length>0?new Set(r):null;for(let e of a.projects)s&&!s.has(e.projectId)||(o=o.concat(e.messages));return N(o,i)}function F(e){if(typeof e!=`object`||!e)return!1;let t=e;if(typeof t.error==`string`)return!0;if(typeof t.error!=`object`||t.error===null)return!1;let n=t.error;return typeof n.code==`string`&&typeof n.message==`string`}async function I(e){let t=await y(`/api/mailbox/messages/${encodeURIComponent(e.mailId)}/action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(t.status===401&&v.getState().markAuthRequired(),!t.ok){let e=`${t.status} ${t.statusText}`;try{let n=await t.json();F(n)&&(e=typeof n.error==`string`?n.error:`${n.error.code}: ${n.error.message}`)}catch{}throw Error(`mailbox action failed — ${e}`)}return await t.json()}var L={markRead:e=>I({...e,action:`mark-read`}),acknowledge:e=>I({...e,action:`acknowledge`}),reopen:e=>I({...e,action:`reopen`}),softDelete:e=>I({...e,action:`soft-delete`}),restore:e=>I({...e,action:`restore`})};function R({mailId:e,actorId:t,projectId:n,isDeleted:r=!1,onAction:i,disabled:a=!1}){let[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)(null),u=async(t,n)=>{if(!(a||o!==null)){s(t),l(null);try{await n(),i?.(e,t)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(null)}}},d={mailId:e,readerId:t,projectId:n};return(0,S.jsxs)(`div`,{className:`hq-msg-actions`,children:[!r&&(0,S.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:a||o!==null,onClick:()=>u(`mark-read`,()=>L.markRead(d)),children:o===`mark-read`?`…`:`Mark read`}),!r&&(0,S.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:a||o!==null,onClick:()=>u(`acknowledge`,()=>L.acknowledge(d)),children:o===`acknowledge`?`…`:`Acknowledge`}),!r&&(0,S.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:a||o!==null,onClick:()=>u(`reopen`,()=>L.reopen(d)),children:o===`reopen`?`…`:`Reopen`}),!r&&(0,S.jsx)(`button`,{type:`button`,className:`hq-btn danger`,disabled:a||o!==null,onClick:()=>u(`soft-delete`,()=>L.softDelete(d)),children:o===`soft-delete`?`…`:`Delete`}),r&&(0,S.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:a||o!==null,onClick:()=>u(`restore`,()=>L.restore(d)),children:o===`restore`?`…`:`Restore`}),c!==null&&(0,S.jsx)(`span`,{className:`hq-msg-action-error`,title:c,children:c})]})}function z(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function B(e){return e.length<=14?e:`${e.slice(0,8)}…${e.slice(-4)}`}var V={note:{icon:o,tone:`info`},ask:{icon:c,tone:`warn`},assign:{icon:t,tone:`warn`},steer:{icon:c,tone:`warn`},btw:{icon:i,tone:`info`},broadcast:{icon:s,tone:`info`},status:{icon:d,tone:`idle`},result:{icon:l,tone:`running`},review:{icon:f,tone:`info`},control:{icon:u,tone:`error`}};Object.keys(V);var H=`hq-operator`;function U({flat:e,defaultExpanded:t}){let[r,i]=(0,x.useState)(!!t),a=e.message,o=a.hasBody||a.bodyPreview!==void 0&&a.bodyPreview.length>0,s=V[a.type]??{icon:n,tone:`info`},c=s.icon,l=`${a.from} → ${a.to}`;return(0,S.jsxs)(`div`,{className:`hq-msg`+(a.completed?` done`:``),children:[(0,S.jsxs)(`div`,{className:`hq-msg-head`,children:[(0,S.jsx)(`span`,{className:`hq-msg-icon`,title:a.type,children:(0,S.jsx)(c,{size:13})}),(0,S.jsx)(`span`,{className:`hq-pill `+s.tone,children:a.type}),a.priority===`high`&&(0,S.jsx)(`span`,{className:`hq-pill error`,children:`high`}),a.priority===`low`&&(0,S.jsx)(`span`,{className:`hq-pill idle`,children:`low`}),(0,S.jsx)(`span`,{className:`hq-msg-subject`,title:a.subject,children:a.subject||`(no subject)`}),(0,S.jsx)(`span`,{className:`hq-mono hq-msg-route`,children:l}),(0,S.jsx)(`span`,{className:`hq-mono hq-msg-time`,title:a.timestamp,children:z(a.timestamp)}),(0,S.jsx)(`span`,{className:`hq-mono hq-msg-id`,children:B(a.messageId)}),(0,S.jsx)(`span`,{className:`hq-msg-flag `+(a.completed?`done`:`open`),children:a.completed?`completed${a.completedBy===void 0?``:` by ${a.completedBy}`}`:`open`}),o&&(0,S.jsx)(`button`,{type:`button`,className:`hq-toggle hq-msg-toggle`,onClick:()=>i(e=>!e),"aria-expanded":r,"aria-label":r?`Collapse body`:`Expand body`,children:r?`▾`:`▸`})]}),r&&(0,S.jsxs)(`div`,{className:`hq-msg-body`,children:[a.bodyPreview!==void 0&&a.bodyPreview.length>0?(0,S.jsx)(`pre`,{className:`hq-msg-pre`,children:a.bodyPreview}):(0,S.jsx)(`div`,{className:`hq-empty hq-pad-sm`,children:`(empty body)`}),a.outcomePreview!==void 0&&a.outcomePreview.length>0&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`hq-msg-sublabel`,children:`outcome`}),(0,S.jsx)(`pre`,{className:`hq-msg-pre`,children:a.outcomePreview})]}),(0,S.jsxs)(`div`,{className:`hq-msg-meta`,children:[(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`strong`,{children:`source:`}),` `,e.source]}),a.replyTo!==void 0&&(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`strong`,{children:`reply to:`}),` `,B(a.replyTo)]}),a.senderSessionId!==void 0&&(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`strong`,{children:`sender session:`}),` `,B(a.senderSessionId)]}),(a.readCount??0)>0&&(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`strong`,{children:`reads:`}),` `,a.readCount]}),a.unreadCount!==void 0&&a.unreadCount>0&&(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`strong`,{children:`unread:`}),` `,a.unreadCount]}),a.task!==void 0&&(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`strong`,{children:`task:`}),` `,a.task.taskId??`—`,a.task.agentName===void 0?``:` · ${a.task.agentName}`,a.task.status===void 0?``:` (${a.task.status})`]})]}),e.projectId!==void 0&&(0,S.jsx)(R,{mailId:a.mailId,actorId:H,projectId:e.projectId})]})]})}var W=[`ask`,`assign`,`steer`,`review`,`result`,`status`,`broadcast`,`note`,`btw`,`control`],G=[`high`,`normal`,`low`];function K({snapshot:e,events:t}={}){let n=v(e=>e.snapshot),r=e===void 0?n:e,i=t===void 0?v.getState().events:t,a=m(),[o,s]=(0,x.useReducer)(M,(0,x.useMemo)(()=>{let e=a.mailbox;return{types:new Set(e.types),priorities:new Set(e.priorities),projectIds:new Set,includeCompleted:e.includeCompleted,query:e.query}},[a.mailbox]));(0,x.useEffect)(()=>{_({query:o.query,types:Array.from(o.types),priorities:Array.from(o.priorities),includeCompleted:o.includeCompleted})},[o.query,o.types,o.priorities,o.includeCompleted]);let c=(0,x.useMemo)(()=>A(r??null,i).projects.map(e=>({projectId:e.projectId,count:e.messages.length})),[r,i]),l=(0,x.useMemo)(()=>P(r??null,i,{types:Array.from(o.types),priorities:Array.from(o.priorities),projectIds:Array.from(o.projectIds),includeCompleted:o.includeCompleted,query:o.query||void 0,limit:500}),[r,i,o]),u=o.types.size+o.priorities.size+o.projectIds.size+ +!o.includeCompleted+ +(o.query.trim().length>0);return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`hq-card-title`,children:[`Live mailbox feed · `,l.returned,` of `,l.totalMatched,` message`,l.totalMatched===1?``:`s`,l.truncated?` · refined to fit`:``]}),(0,S.jsxs)(`div`,{className:`hq-card hq-mailbox-filterbar`,children:[(0,S.jsx)(`label`,{className:`hq-label`,htmlFor:`mailbox-live-query`,children:`Search`}),(0,S.jsx)(`input`,{id:`mailbox-live-query`,className:`hq-input`,value:o.query,onChange:e=>s({type:`set-query`,value:e.target.value}),placeholder:`subject / sender / recipient / body…`}),(0,S.jsx)(q,{title:`Types`,children:W.map(e=>(0,S.jsx)(J,{selected:o.types.has(e),label:e,onClick:()=>s({type:`toggle-type`,value:e})},e))}),(0,S.jsx)(q,{title:`Priority`,children:G.map(e=>(0,S.jsx)(J,{selected:o.priorities.has(e),label:e,tone:e===`high`?`error`:e===`low`?`idle`:`info`,onClick:()=>s({type:`toggle-priority`,value:e})},e))}),c.length>0&&(0,S.jsx)(q,{title:`Projects`,children:c.map(e=>(0,S.jsx)(J,{selected:o.projectIds.has(e.projectId),label:`${e.projectId} (${e.count})`,onClick:()=>s({type:`toggle-project`,value:e.projectId})},e.projectId))}),(0,S.jsxs)(`div`,{className:`hq-row hq-mailbox-filter-actions`,children:[(0,S.jsxs)(`label`,{className:`hq-check`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:o.includeCompleted,onChange:e=>s({type:`set-include-completed`,value:e.target.checked})}),`include completed`]}),(0,S.jsxs)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:u===0,onClick:()=>s({type:`clear-all`}),children:[`Clear filters`,u>0?` (${u})`:``]})]})]}),l.entries.length===0?(0,S.jsx)(`div`,{className:`hq-empty`,children:`No mailbox activity matches the current filters.`}):(0,S.jsx)(`div`,{className:`hq-msg-list hq-live-feed`,children:l.entries.map((e,t)=>(0,S.jsx)(U,{flat:e.flat,defaultExpanded:t===0&&o.query.trim().length>0},e.key))})]})}function q({title:e,children:t}){return(0,S.jsxs)(`div`,{className:`hq-filter-section`,children:[(0,S.jsx)(`div`,{className:`hq-msg-sublabel`,children:e}),(0,S.jsx)(`div`,{className:`hq-filter-chip-row`,children:t})]})}function J({selected:e,label:t,onClick:n,tone:r=`info`}){return(0,S.jsx)(`button`,{type:`button`,className:`hq-filter-chip hq-pill ${r}${e?` selected`:``}`,"aria-pressed":e,onClick:n,children:t})}function Y(){let{snapshot:e,events:t}=v(g(e=>({snapshot:e.snapshot,events:e.events}))),[n,r]=(0,x.useState)(`live`),{events:i}=b(`mailbox.event`,300),a=(0,x.useMemo)(()=>[...i,...t.filter(e=>e.type!==`mailbox.event`)],[i,t]),{projects:o,hasAnyActivity:s}=(0,x.useMemo)(()=>A(e,a),[e,a]),c=e?.totals.unreadMailboxMessages??0,l=e?.totals.incompleteMailboxMessages??0,u=(0,x.useMemo)(()=>{let t=new Map;for(let n of e?.projects??[])t.set(n.projectId,{projectId:n.projectId,label:n.projectName});for(let e of o)t.has(e.projectId)||t.set(e.projectId,{projectId:e.projectId});return Array.from(t.values())},[e,o]);return o.length===0&&u.length===0?(0,S.jsx)(`div`,{className:`hq-empty`,children:`No mailbox activity reported by connected clients.`}):(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`hq-card-title`,children:[`Mailbox Activity — `,o.length,` project`,o.length===1?``:`s`,` ·`,` `,c,` unread · `,l,` incomplete`,s?` · showing detailed messages`:``]}),(0,S.jsx)(w,{projects:u}),(0,S.jsxs)(`div`,{className:`hq-mailbox-modebar`,role:`tablist`,"aria-label":`Mailbox view mode`,children:[(0,S.jsx)(`button`,{type:`button`,role:`tab`,className:`hq-btn secondary`+(n===`live`?` hq-btn-selected`:``),"aria-selected":n===`live`,onClick:()=>r(`live`),children:`Live feed`}),(0,S.jsx)(`button`,{type:`button`,role:`tab`,className:`hq-btn secondary`+(n===`grouped`?` hq-btn-selected`:``),"aria-selected":n===`grouped`,onClick:()=>r(`grouped`),children:`Grouped by project`})]}),n===`live`?(0,S.jsx)(K,{snapshot:e,events:a}):o.map(e=>(0,S.jsx)(X,{group:e},e.projectId))]})}function X({group:e}){let[t,n]=(0,x.useState)(!0);return(0,S.jsxs)(`div`,{className:`hq-card`,children:[(0,S.jsxs)(`div`,{className:`hq-row hq-row-baseline`,children:[(0,S.jsx)(`button`,{type:`button`,className:`hq-toggle`,onClick:()=>n(e=>!e),"aria-label":t?`Collapse project messages`:`Expand project messages`,children:t?`▾`:`▸`}),(0,S.jsx)(`span`,{className:`hq-text-bright`,children:e.projectId}),e.scope!==void 0&&(0,S.jsx)(`span`,{className:`hq-pill info`,children:e.scope}),e.mailboxId!==void 0&&(0,S.jsx)(`span`,{className:`hq-mono hq-text-dim`,children:e.mailboxId}),(0,S.jsxs)(`span`,{className:`hq-mono hq-text-dim hq-ml-auto`,children:[e.messages.length,` message`,e.messages.length===1?``:`s`]})]}),(0,S.jsxs)(`div`,{className:`hq-grid hq-mt-8`,style:{gridTemplateColumns:`repeat(5,1fr)`},children:[(0,S.jsx)(Z,{label:`messages`,value:e.messages.length}),(0,S.jsx)(Z,{label:`unread`,value:e.unreadCount,accent:e.unreadCount>0?`amber`:void 0}),(0,S.jsx)(Z,{label:`incomplete`,value:e.incompleteCount,accent:e.incompleteCount>0?`red`:void 0}),(0,S.jsx)(Z,{label:`high-priority`,value:e.highPriorityCount,accent:e.highPriorityCount>0?`red`:void 0}),(0,S.jsx)(Z,{label:`online agents`,value:e.onlineAgentCount,accent:e.onlineAgentCount>0?`green`:void 0})]}),t&&e.messages.length>0&&(0,S.jsx)(`div`,{className:`hq-msg-list hq-mt-12`,children:e.messages.map(e=>(0,S.jsx)(U,{flat:e},e.key))}),t&&e.messages.length===0&&(0,S.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:`Snapshot counters reported for this project, but no detailed mailbox events have streamed yet.`})]})}function Z({label:e,value:t,accent:n}){return(0,S.jsxs)(`div`,{className:`hq-text-center`,children:[(0,S.jsx)(`div`,{className:`hq-stat-num`,style:{color:n===`amber`?`var(--amber)`:n===`red`?`var(--red)`:n===`green`?`var(--green)`:`var(--text)`},children:t}),(0,S.jsx)(`div`,{className:`hq-stat-label`,children:e})]})}export{Y as MailboxView};
|
|
@@ -1 +0,0 @@
|
|
|
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-DMTqAxHb.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};
|