@tt-a1i/hive 1.1.3 → 1.1.4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable user-facing changes will be documented in this file.
4
4
 
5
+ ## 1.1.4 - 2026-05-17
6
+
7
+ Update guidance polish.
8
+
9
+ - Shows `npm install -g @tt-a1i/hive@latest` in update prompts instead of
10
+ `npm update -g @tt-a1i/hive`, making the upgrade command explicit and
11
+ deterministic across npm versions.
12
+
5
13
  ## 1.1.3 - 2026-05-17
6
14
 
7
15
  Brand polish.
@@ -27,7 +27,7 @@ export const compareVersions = (left, right) => {
27
27
  };
28
28
  const buildVersionInfo = (currentVersion, latestVersion) => ({
29
29
  current_version: currentVersion,
30
- install_hint: `npm update -g ${PACKAGE_NAME}`,
30
+ install_hint: `npm install -g ${PACKAGE_NAME}@latest`,
31
31
  latest_version: latestVersion,
32
32
  package_name: PACKAGE_NAME,
33
33
  release_url: `https://www.npmjs.com/package/${PACKAGE_NAME}/v/${latestVersion}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tt-a1i/hive",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Browser-native hive-mind for CLI coding agents — Claude Code, Codex, Gemini, and OpenCode collaborate as real PTY processes via a team protocol.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.30.3",
@@ -63,4 +63,4 @@ $ team list\r
63
63
  `),custom:["你是自定义成员。请把这段改成该成员的行为契约。","建议包含:","- 目标:这个成员主要负责什么。","- 边界:哪些事可以做,哪些事不要做。","- 工作方式:如何调查、修改、验证或审查。","- 完成标准:交付时需要说明哪些结果、风险和阻塞。"].join(`
64
64
  `),reviewer:["你是监工型 Reviewer,负责质量审查,不替代 Orchestrator,也不默认改代码。","工作方式:","- 优先找真实 bug、回归风险、边界条件和测试缺口。","- 发现问题时给出严重度、文件/行号、触发条件和最小修复建议。","- 没有高风险问题时明确说清剩余风险和未验证范围。","交付说明按严重度排序,先列 blocking 问题。"].join(`
65
65
  `),tester:["你是验证型 Tester,负责复现、测试和证据化验证。","工作方式:","- 先明确要验证的行为、入口和失败条件。","- 优先跑真实命令或真实链路;必要时补充最小测试。","- 记录命令、结果、关键输出和不能覆盖的场景。","交付说明要区分通过、失败、未验证和建议下一步。"].join(`
66
- `)}},ci=(a,s,o)=>o==="zh"?s.find(i=>i.roleType===a)?.description??Lu.zh[a]:Lu.en[a],jE=({createWorker:a,open:s})=>{const{language:o}=ve(),[i,d]=y.useState(""),[f,m]=y.useState("coder"),[g,h]=y.useState([]),[v,b]=y.useState(Lu[o].coder),[w,k]=y.useState([]),[E,S]=y.useState("claude"),[j,R]=y.useState(!1),[_,q]=y.useState(""),[Y,D]=y.useState(null),[Q,Z]=y.useState(!1),M=y.useRef(!1),$=y.useRef(!1),J=ci(f,g,o);y.useEffect(()=>{if(!s)return;let L=!1;return Gv().then(z=>{L||(k(z),S(F=>z.some(ee=>ee.id===F&&ee.available)?F:z.find(ee=>ee.id==="claude"&&ee.available)?.id??z.find(ee=>ee.available)?.id??z[0]?.id??""))}).catch(z=>{L||D(z instanceof Error?z.message:String(z))}),()=>{L=!0}},[s]),y.useEffect(()=>{if(!s)return;let L=!1;return aS().then(z=>{L||(h(z),$.current||b(ci(f,z,o)))}).catch(z=>{L||D(z instanceof Error?z.message:String(z))}),()=>{L=!0}},[s,f,o]),y.useEffect(()=>{$.current||b(ci(f,g,o))},[o,g,f]);const ae=L=>{$.current=!0,b(L)},I=L=>{M.current=!1,d(L)},ie=()=>{M.current=!0,d(og(o))};y.useEffect(()=>{M.current&&d(og(o))},[o]);const se=L=>{m(L),$.current=!1,b(ci(L,g,o))};return{commandPresets:w,commandPresetId:E,createWorkerError:Y,creating:Q,roleDescription:v,roleDescriptionDefault:J,startupCommand:_,workerName:i,workerRole:f,setCommandPresetId:L=>{R(!0),S(L)},setRoleDescription:ae,setStartupCommand:q,setWorkerName:I,setWorkerRole:se,randomizeWorkerName:ie,resetRoleDescription:()=>{$.current=!1,b(J)},resetError:()=>D(null),submit:(L,z)=>{L.preventDefault(),Z(!0),D(null);const F=_.trim()&&!j?"":E;a({commandPresetId:F,name:i,role:f,roleDescription:v,startupCommand:_}).then(({error:ee})=>{d(""),M.current=!1,se("coder"),S("claude"),R(!1),q(""),z(),ee&&D(ee)}).catch(ee=>{D(ee instanceof Error?ee.message:String(ee))}).finally(()=>Z(!1))}}},NE=[{icon:u.jsx(Sg,{size:16}),titleKey:"welcome.step1Title",descriptionKey:"welcome.step1Desc"},{icon:u.jsx(F0,{size:16}),titleKey:"welcome.step2Title",descriptionKey:"welcome.step2Desc"},{icon:u.jsx(G0,{size:16}),titleKey:"welcome.step3Title",descriptionKey:"welcome.step3Desc"}],CE=({onAddWorkspace:a,onTryDemo:s,heroImageSrc:o,disabledReason:i})=>{const{t:d}=ve(),f=!!i;return u.jsxs("div",{"data-testid":"welcome-pane",className:"m-auto flex w-full flex-col items-center gap-6 px-6 py-12 text-center",style:{maxWidth:"540px"},children:[o?u.jsx("img",{src:o,alt:"",className:"h-24 w-24","aria-hidden":!0}):null,u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"text-2xl font-semibold text-pri",children:d("welcome.title")}),u.jsx("div",{className:"text-sm text-sec",children:d("welcome.desc")})]}),u.jsx("ol",{className:"grid w-full grid-cols-3 gap-3 text-left",children:NE.map((m,g)=>u.jsxs("li",{className:"rounded border bg-1 p-3",style:{borderColor:"var(--border)"},children:[u.jsxs("div",{className:"mb-1 flex items-center gap-2 text-pri",children:[u.jsx("span",{className:"font-medium text-xs text-ter",children:g+1}),m.icon]}),u.jsx("div",{className:"text-xs font-medium text-pri",children:d(m.titleKey)}),u.jsx("div",{className:"mt-1 text-xs text-ter",children:d(m.descriptionKey)})]},m.titleKey))}),f?u.jsxs("div",{role:"alert","data-testid":"welcome-pane-disabled-reason",className:"flex items-start gap-2 rounded px-3 py-2 text-left text-xs",style:{background:"color-mix(in oklab, var(--status-red) 10%, transparent)",border:"1px solid color-mix(in oklab, var(--status-red) 28%, transparent)",color:"var(--status-red)"},children:[u.jsx(Oa,{size:14,className:"mt-0.5 shrink-0","aria-hidden":!0}),u.jsx("span",{className:"break-words",children:i})]}):null,u.jsxs("button",{type:"button",disabled:f,onClick:f?void 0:a,"aria-disabled":f||void 0,title:i,className:"icon-btn icon-btn--primary inline-flex items-center gap-2 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"welcome-pane-add",children:[u.jsx("span",{children:d("welcome.addWorkspace")}),u.jsx(Fx,{size:14,"aria-hidden":!0})]}),s?u.jsx("button",{type:"button",onClick:s,className:"text-xs text-sec underline hover:text-pri",children:d("welcome.demo")}):null]})},TE=a=>{switch(a){case"coder":return{badgeClass:"role-badge--coder",label:"Coder"};case"tester":return{badgeClass:"role-badge--tester",label:"Tester"};case"reviewer":return{badgeClass:"role-badge--reviewer",label:"Reviewer"};case"custom":return{badgeClass:"role-badge--custom",label:"Custom"};default:return{badgeClass:"role-badge--custom",label:String(a)}}},sy="hive.worker-modal.width",Os=480,AE=.5,Ei=a=>{const s=typeof window<"u"?window.innerWidth-24:1200;return Math.min(Math.max(a,Os),Math.max(Os,s))},ku=()=>typeof window>"u"?Os:Ei(Math.round(window.innerWidth*AE)),RE=()=>{try{const a=localStorage.getItem(sy);if(!a)return ku();const s=Number.parseInt(a,10);return Number.isFinite(s)?Ei(s):ku()}catch{return ku()}},_E=()=>{const[a,s]=y.useState(()=>RE()),[o,i]=y.useState(!1);y.useEffect(()=>{try{localStorage.setItem(sy,String(Math.round(a)))}catch{}},[a]),y.useEffect(()=>{const f=()=>{s(m=>Ei(m))};return window.addEventListener("resize",f),()=>window.removeEventListener("resize",f)},[]);const d=y.useCallback(f=>m=>{m.preventDefault();const g=m.clientX,h=a;i(!0);const v=document.body.style.cursor,b=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const w=E=>{const S=E.clientX-g,j=f==="left"?h-2*S:h+2*S;s(Ei(j))},k=()=>{i(!1),document.body.style.cursor=v,document.body.style.userSelect=b,document.removeEventListener("pointermove",w),document.removeEventListener("pointerup",k),document.removeEventListener("pointercancel",k)};document.addEventListener("pointermove",w),document.addEventListener("pointerup",k),document.addEventListener("pointercancel",k)},[a]);return{width:a,resizing:o,beginResize:d}},OE=({onClose:a,onStart:s,runId:o,startError:i,starting:d,worker:f})=>{const{t:m}=ve(),g=TE(f.role),h=!!o,v=WS(h),b=_E(),w=k=>{k||a()};return u.jsx(It,{open:!0,onOpenChange:w,children:u.jsxs(en,{children:[u.jsx(tn,{"data-testid":"worker-modal-overlay",className:"app-overlay fixed inset-0 z-40"}),u.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center",children:u.jsxs(nn,{"data-testid":"worker-modal","aria-label":m("worker.detail",{name:f.name}),className:"dialog-scale-pop pointer-events-auto relative flex h-screen max-h-screen max-w-full flex-col overflow-hidden",onEscapeKeyDown:k=>k.preventDefault(),style:{background:"var(--bg-1)",width:`${b.width}px`},children:[u.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":m("worker.widthResize"),"aria-valuemin":Os,"aria-valuenow":Math.round(b.width),className:"modal-resize-handle modal-resize-handle--left",tabIndex:-1,"data-resizing":b.resizing||void 0,onPointerDown:b.beginResize("left")}),u.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":m("worker.widthResize"),"aria-valuemin":Os,"aria-valuenow":Math.round(b.width),className:"modal-resize-handle modal-resize-handle--right",tabIndex:-1,"data-resizing":b.resizing||void 0,onPointerDown:b.beginResize("right")}),u.jsx(Gt,{className:"sr-only",children:f.name}),u.jsxs(An,{className:"sr-only",children:[g.label," agent — status ",v.label]}),i?u.jsxs("div",{role:"alert",className:"flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 10%, transparent)",borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--status-red)"},children:[u.jsx(Oa,{size:12,"aria-hidden":!0}),u.jsx("span",{className:"break-words",children:i})]}):null,u.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col p-3","data-testid":"worker-modal-terminal-slot",children:[u.jsx(Je,{label:m("common.close"),children:u.jsx(ld,{asChild:!0,children:u.jsx("button",{type:"button","aria-label":"Close worker detail",className:"float-action absolute top-4 right-4 z-10",children:u.jsx(El,{size:14,"aria-hidden":!0})})})}),u.jsx("div",{className:"flex min-h-0 flex-1 rounded-lg border",style:{background:"var(--bg-crust)",borderColor:"var(--border)"},children:h?u.jsx("div",{id:`worker-pty-${o}`,className:"flex h-full w-full","data-pty-slot":"worker"}):u.jsxs("div",{className:"m-auto flex max-w-[400px] flex-col items-center gap-3 px-6 text-center",children:[u.jsx(ey,{commandPresetId:f.commandPresetId,workerRole:f.role,size:48}),u.jsx("div",{className:"text-sm text-pri",children:f.name}),u.jsxs("div",{className:"text-xs text-ter",children:[f.status==="stopped"?m("worker.terminalStopped"):m("worker.terminalNotStarted"),f.pendingTaskCount>0?m("worker.pendingResume",{count:f.pendingTaskCount}):m("worker.startAgent")]}),u.jsxs("button",{type:"button",onClick:()=>s(f),disabled:d,className:"icon-btn icon-btn--primary","data-testid":"worker-start-empty",children:[u.jsx(ji,{size:12,"aria-hidden":!0})," ",m(d?"common.starting":"common.start")]})]})})]})]})})]})})},DE=({onCreateWorker:a,onDeleteWorker:s,onDeleteWorkspace:o,onStartWorker:i,onOrchestratorResult:d,onRequestAddWorkspace:f,onTryDemo:m,welcomeDisabledReason:g,orchestratorAutostartError:h,orchestratorAutostartRunId:v,terminalRuns:b,workers:w,workspace:k})=>{const{t:E}=ve(),[S,j]=y.useState(null),[R,_]=y.useState(!1),[q,Y]=y.useState(null),[D,Q]=y.useState(null),[Z,M]=y.useState(!1),[$,J]=y.useState(null),[ae,I]=y.useState(!1),[ie,se]=y.useState(null),[oe,fe]=y.useState(null),A=Ol(),L=w.find(pe=>pe.id===S)??null;y.useEffect(()=>{S&&!L&&j(null)},[S,L]);const z=jE({createWorker:a,open:R});y.useEffect(()=>{z.createWorkerError&&A.show({kind:"error",message:z.createWorkerError})},[z.createWorkerError,A]),y.useEffect(()=>{q&&A.show({kind:"error",message:q})},[q,A]),y.useEffect(()=>{Y(null),Q(null),M(!1),J(null),I(!1),se(null),fe(null)},[k?.id]);const F=bE({workspaceId:k?.id??"",terminalRuns:b,autostartError:h,suppressAutostartRunId:v,onClearAutostartError:()=>{k&&d(k.id,{ok:!0,error:null,run_id:null})},onAfterStart:pe=>{k&&d(k.id,pe)}}),ee=eE();if(!k){const pe={onAddWorkspace:f};return m&&(pe.onTryDemo=m),g&&(pe.disabledReason=g),u.jsx(CE,{...pe})}const C=L?Pv(b,L.id):void 0,X=b.filter(pe=>eS(pe,k.id)),te=(X.find(pe=>pe.run_id===$)??X[0]??null)?.run_id??null,ue=pe=>{Y(null),s(pe.id).then(()=>j(null)).catch(Me=>{Y(Me instanceof Error?Me.message:String(Me))})},me=pe=>{se(null),fe(pe.id),i(pe.id).then(({error:Me})=>{Me&&se(Me)}).catch(Me=>{se(Me instanceof Error?Me.message:String(Me))}).finally(()=>fe(null))},be=async(pe,Me)=>{try{return await rS(k.id,pe.id,Me),A.show({kind:"success",message:E("worker.renameSuccess",{name:Me})}),{error:null}}catch(Ie){const Rn=Ie instanceof Error?Ie.message:String(Ie);return A.show({kind:"error",message:E("worker.renameFailed",{message:Rn})}),{error:Rn}}},qe=()=>{Q(null),I(!0),tS(k.id).then(pe=>J(pe.run_id)).catch(pe=>{Q(pe instanceof Error?pe.message:String(pe))}).finally(()=>I(!1))},ze=()=>{M(!0),X.length===0&&!ae?qe():te||J(X[0]?.run_id??null)},ln=pe=>{const Me=X.find(Ie=>Ie.run_id!==pe)??null;te===pe&&J(Me?.run_id??null),nS(k.id,pe).catch(Ie=>{const Rn=Ie instanceof Error?Ie.message:String(Ie);A.show({kind:"error",message:E("shellTerminal.closeFailed",{message:Rn})})})},sn=`${(ee.orchPct*100).toFixed(2)}%`;return u.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",style:{background:"var(--bg-2)"},children:[u.jsx(FS,{terminalRuns:b,workers:w,workspace:k}),u.jsxs("div",{ref:ee.containerRef,className:"relative flex min-h-0 flex-1",children:[u.jsx("div",{className:"flex min-w-[480px] shrink-0 flex-col",style:{width:sn},"data-testid":"orchestrator-pane-shell",children:u.jsx(yE,{state:F.state,onStop:F.stop,onRemoveWorkspace:()=>{k&&o(k).catch(pe=>{const Me=pe instanceof Error?pe.message:String(pe);A.show({kind:"error",message:`Delete failed: ${Me}`})})},onStart:F.start,onRestart:F.restart})}),u.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":E("workerPane.resize"),"aria-valuenow":Math.round(ee.orchPct*100),"aria-valuemin":30,"aria-valuemax":78,tabIndex:0,className:"pane-splitter",style:{left:`calc(${sn} - 4px)`},"data-dragging":ee.dragging||void 0,"data-testid":"pane-splitter",onPointerDown:ee.beginDrag,onKeyDown:ee.onKeyDown}),u.jsx(ty,{onAddWorkerClick:()=>_(!0),onDeleteWorker:ue,onOpenShellTerminal:ze,onOpenWorker:pe=>j(pe.id),onRenameWorker:be,onStartWorker:me,startingWorkerId:oe,terminalRuns:b,workers:w})]}),L?u.jsx(OE,{onClose:()=>j(null),onStart:me,runId:C?.run_id??null,startError:ie,starting:oe===L.id,worker:L}):null,R?u.jsx(pE,{commandPresets:z.commandPresets,commandPresetId:z.commandPresetId,creating:z.creating,onClose:()=>_(!1),onNameChange:z.setWorkerName,onPresetChange:z.setCommandPresetId,onRandomName:z.randomizeWorkerName,onRoleDescriptionChange:z.setRoleDescription,onRoleDescriptionReset:z.resetRoleDescription,onRoleChange:z.setWorkerRole,onSubmit:pe=>z.submit(pe,()=>_(!1)),onStartupCommandChange:z.setStartupCommand,roleDescription:z.roleDescription,roleDescriptionDefault:z.roleDescriptionDefault,startupCommand:z.startupCommand,workerName:z.workerName,workerRole:z.workerRole}):null,u.jsx(PS,{activeRunId:te,error:D,onActiveRunChange:J,onClose:()=>M(!1),onCloseTab:ln,onNewTab:qe,open:Z,shellRuns:X,starting:ae,workspace:k})]})},zE="modulepreload",ME=function(a){return"/"+a},cg={},wl=function(s,o,i){let d=Promise.resolve();if(o&&o.length>0){let v=function(b){return Promise.all(b.map(w=>Promise.resolve(w).then(k=>({status:"fulfilled",value:k}),k=>({status:"rejected",reason:k}))))};var m=v;document.getElementsByTagName("link");const g=document.querySelector("meta[property=csp-nonce]"),h=g?.nonce||g?.getAttribute("nonce");d=v(o.map(b=>{if(b=ME(b),b in cg)return;cg[b]=!0;const w=b.endsWith(".css"),k=w?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${b}"]${k}`))return;const E=document.createElement("link");if(E.rel=w?"stylesheet":zE,w||(E.as="script"),E.crossOrigin="",E.href=b,h&&E.setAttribute("nonce",h),document.head.appendChild(E),w)return new Promise((S,j)=>{E.addEventListener("load",S),E.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${b}`)))})}))}function f(g){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=g,window.dispatchEvent(h),!h.defaultPrevented)throw g}return d.then(g=>{for(const h of g||[])h.status==="rejected"&&f(h.reason);return s().catch(f)})},LE=()=>typeof navigator>"u"?!1:/Mac|iPhone|iPad/.test(navigator.platform),Na={killToLineStart:"",lineStart:"",lineEnd:"",killWordBack:"\x1B",wordBack:"\x1Bb",wordForward:"\x1Bf",shiftEnter:"\x1B[13;2u"},HE=(a,s={})=>{const o=s.isMac??LE();if(a.key==="Enter"&&a.shiftKey)return a.type==="keypress"?{kind:"send",bytes:Na.shiftEnter}:{kind:"block"};if(!o||a.type!=="keydown")return{kind:"passthrough"};const i=a.metaKey&&!a.ctrlKey&&!a.altKey&&!a.shiftKey,d=a.altKey&&!a.metaKey&&!a.ctrlKey;if(i)switch(a.key){case"Backspace":return{kind:"send",bytes:Na.killToLineStart};case"ArrowLeft":return{kind:"send",bytes:Na.lineStart};case"ArrowRight":return{kind:"send",bytes:Na.lineEnd};case"k":case"K":return{kind:"clear"}}if(d)switch(a.key){case"Backspace":return{kind:"send",bytes:Na.killWordBack};case"ArrowLeft":return{kind:"send",bytes:Na.wordBack};case"ArrowRight":return{kind:"send",bytes:Na.wordForward}}return{kind:"passthrough"}},ug=(a,s={})=>{const o=new URL(a,window.location.href);o.protocol=o.protocol==="https:"?"wss:":"ws:";for(const[i,d]of Object.entries(s))d!==void 0&&o.searchParams.set(i,String(d));return o.toString()},UE=({initialSize:a,onError:s,onExit:o,onOutput:i,onRestore:d,runId:f})=>{const m=crypto.randomUUID(),g={...a,clientId:m},h=new WebSocket(ug(`/ws/terminal/${f}/io`,g)),v=new WebSocket(ug(`/ws/terminal/${f}/control`,g));let b=!1;const w=[];let k=null;const E=()=>{!k||v.readyState!==v.OPEN||(v.send(JSON.stringify({type:"resize",...k})),k=null)};return h.onmessage=S=>{const j=typeof S.data=="string"?S.data:"",R=_=>{v.readyState===v.OPEN&&v.send(JSON.stringify({type:"output_ack",bytes:_}))};if(!b){w.push({chunk:j,acknowledge:R});return}i(j,R)},v.onopen=()=>{E()},v.onmessage=S=>{const j=JSON.parse(String(S.data));if(j.type==="exit"&&o(j.code),j.type==="error"&&s(j.message),j.type==="restore"){d(j.snapshot),b=!0,v.readyState===v.OPEN&&v.send(JSON.stringify({type:"restore_complete"}));for(const R of w.splice(0))i(R.chunk,R.acknowledge)}},{dispose(){h.close(),v.close()},resize(S,j,R,_){k={cols:S,rows:j},R!==void 0&&(k.pixelWidth=R),_!==void 0&&(k.pixelHeight=_),E()},sendInput(S){h.readyState===h.OPEN&&h.send(S)}}},BE=a=>{const s=y.useRef(null),[o,i]=y.useState(null),[d,f]=y.useState("connecting");return y.useEffect(()=>{if(!s.current)return;let m=!1,g,h,v,b,w,k,E,S=null,j,R;const _={current:!1};return Promise.all([wl(()=>import("./xterm-B-qIQCd3.js"),[]),wl(()=>import("./addon-fit-DX4qG4td.js"),[]),wl(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]),wl(()=>import("./addon-webgl-DCtw1yLn.js"),[]),wl(()=>import("./addon-clipboard-wHJhZAA4.js"),[]),wl(()=>import("./addon-web-links-DIbG5aQx.js"),[])]).then(([q,Y,D,Q,Z,M])=>{if(m||!s.current)return;const $=typeof window<"u"?getComputedStyle(document.documentElement):null,J=$?.getPropertyValue("--bg-crust").trim()||"#0e0e0e",ae=$?.getPropertyValue("--text-primary").trim()||"#ebebeb",I=new q.Terminal({allowProposedApi:!0,convertEol:!1,fontFamily:"'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:13,letterSpacing:0,lineHeight:1,scrollback:1e4,theme:{background:J,foreground:ae}}),ie=new Y.FitAddon;I.loadAddon(ie),I.loadAddon(new D.Unicode11Addon),I.unicode.activeVersion="11",I.loadAddon(new Z.ClipboardAddon),I.loadAddon(new M.WebLinksAddon),I.open(s.current),ie.fit(),b=I,w=ie;try{const A=new Q.WebglAddon;A.onContextLoss(()=>A.dispose()),I.loadAddon(A)}catch{}if(S=s.current.querySelector(".xterm-helper-textarea"),S){const A=S;j=()=>{_.current=!0},R=L=>{const z=L.data;z&&v?.sendInput(z),A.value="",setTimeout(()=>{_.current=!1},0)},S.addEventListener("compositionstart",j,{capture:!0}),S.addEventListener("compositionend",R,{capture:!0})}typeof I.attachCustomKeyEventHandler=="function"&&I.attachCustomKeyEventHandler(A=>{const L=HE(A);switch(L.kind){case"send":return A.preventDefault(),v?.sendInput(L.bytes),!1;case"clear":return A.preventDefault(),I.clear(),!1;case"block":return!1;case"passthrough":return!0}});const se=()=>{if(!s.current)return{};const A=s.current.clientWidth,L=s.current.clientHeight,z={};return L>0&&(z.pixelHeight=L),A>0&&(z.pixelWidth=A),z},oe=()=>{if(!s.current)return;w?.fit();const{pixelHeight:A,pixelWidth:L}=se();v?.resize(b?.cols??80,b?.rows??24,L,A)},fe=()=>{E&&window.clearTimeout(E),E=window.setTimeout(()=>{E=void 0,oe()},50)};v=UE({initialSize:{cols:I.cols,rows:I.rows,...se()},onError(A){i(A)},onExit(){f("stopped")},onOutput(A,L){I.write(A,()=>L(new TextEncoder().encode(A).byteLength))},onRestore(A){I.write(A)},runId:a}),h=I.onData(A=>{_.current||v?.sendInput(A)}),f("running"),oe(),typeof ResizeObserver<"u"&&s.current&&(k=new ResizeObserver(fe),k.observe(s.current)),g=()=>oe(),window.addEventListener("resize",g)}),()=>{m=!0,g&&window.removeEventListener("resize",g),k?.disconnect(),E&&window.clearTimeout(E),S&&j&&S.removeEventListener("compositionstart",j,{capture:!0}),S&&R&&S.removeEventListener("compositionend",R,{capture:!0}),h?.dispose(),v?.dispose(),b?.dispose(),w?.dispose()}},[a]),{containerRef:s,error:o,status:d}},WE={connecting:"terminal.statusConnecting",running:"terminal.statusRunning",stopped:"common.stopped"},qE=a=>[`worker-pty-${a}`,`orch-pty-${a}`,`shell-pty-${a}`],YE=a=>{const[s,o]=y.useState(null);return y.useEffect(()=>{const i=qE(a),d=()=>{for(const m of i){const g=document.getElementById(m);if(g)return g}return null};o(d());const f=window.setInterval(()=>{const m=d();o(g=>g===m?g:m)},100);return()=>window.clearInterval(f)},[a]),s},GE=({runId:a,title:s})=>{const o=YE(a),i=o?o.id:"inline",d=u.jsx(XE,{runId:a,title:s},i);return o?Ni.createPortal(d,o):null},XE=({runId:a,title:s})=>{const{t:o}=ve(),{containerRef:i,error:d,status:f}=BE(a),m=WE[f];return u.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden",children:[u.jsx("p",{className:"sr-only",children:m?o(m):f}),d?u.jsx("p",{role:"alert",className:"mono shrink-0 break-words px-3 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 12%, transparent)",borderBottom:"1px solid color-mix(in oklab, var(--status-red) 30%, transparent)",color:"var(--status-red)"},children:d}):null,u.jsx("div",{"data-testid":`terminal-${a}`,ref:i,className:"bg-crust h-full min-h-0 w-full min-w-0 flex-1 overflow-hidden"})]})},VE=3e3,ry=(a,s)=>{const o=new Set(a.map(d=>d.run_id)),i=new Set(a.map(d=>d.agent_id));return[...a,...s.filter(d=>!o.has(d.run_id)&&!i.has(d.agent_id))]},KE=(a,s)=>{const[o,i]=y.useState({}),d=y.useRef(new Map);y.useEffect(()=>()=>{for(const h of d.current.values())window.clearTimeout(h);d.current.clear()},[]);const f=y.useCallback((h,v)=>{i(b=>({...b,[h]:(b[h]??[]).filter(w=>w.agent_id!==v)}))},[]),m=y.useCallback(({agentId:h,agentName:v,runId:b,status:w="starting",workspaceId:k})=>{const E={agent_id:h,agent_name:v,run_id:b,status:w};i(R=>{const _=(R[k]??[]).filter(q=>q.run_id!==E.run_id&&q.agent_id!==E.agent_id);return{...R,[k]:[..._,E]}});const S=d.current.get(b);S&&window.clearTimeout(S);const j=window.setTimeout(()=>{i(R=>({...R,[k]:(R[k]??[]).filter(_=>_.run_id!==b)})),d.current.delete(b)},VE);d.current.set(b,j)},[]),g=y.useMemo(()=>ry(s,a?o[a]??[]:[]),[s,o,a]);return{forgetOptimisticAgent:f,optimisticRunsByWorkspaceId:o,recordOptimisticRun:m,terminalRuns:g}},QE=500,ZE=({hidden:a=!1,optimisticRuns:s=[],workspaceId:o})=>{const{t:i}=ve(),[d,f]=y.useState([]),m=ry(d,s);return y.useEffect(()=>{let g=!1;const h=()=>{Xv(o).then(b=>{g||f(b)}).catch(b=>{g||f([]),console.error("[hive] swallowed:terminalPanels.listRuns",b)})};h();const v=window.setInterval(h,QE);return()=>{g=!0,window.clearInterval(v)}},[o]),u.jsx("section",{hidden:a,"aria-hidden":a||void 0,"aria-label":i("terminalPanels.aria"),children:m.map(g=>u.jsx(GE,{runId:g.run_id,title:`${g.agent_name} (${g.status})`},g.run_id))})},$E=({activeId:a,activeWorkspace:s,bootstrapError:o,demoMode:i,onDeleteWorkspace:d,onExitDemo:f,onRequestAddWorkspace:m,onTryDemo:g,optimisticRunsByWorkspaceId:h,orchestratorAutostartErrors:v,orchestratorAutostartRunIds:b,recordOrchestratorResult:w,terminalRuns:k,workerActions:E,workers:S})=>i?u.jsx(ZS,{onExit:f}):u.jsxs(u.Fragment,{children:[a?u.jsx(ZE,{optimisticRuns:h[a]??[],workspaceId:a},`terminal-${a}`):null,u.jsx(DE,{onCreateWorker:E.createWorker,onDeleteWorker:E.deleteWorker,onDeleteWorkspace:d,onStartWorker:E.startWorker,onOrchestratorResult:w,onRequestAddWorkspace:m,onTryDemo:g,welcomeDisabledReason:o??void 0,orchestratorAutostartError:a?v[a]??null:null,orchestratorAutostartRunId:a?b[a]??null:null,terminalRuns:k,workers:S,workspace:s})]}),JE=()=>{const[a,s]=y.useState(!1);return{demoMode:a,enableDemo:()=>s(!0),exitDemo:()=>s(!1)}},FE=a=>{const{demoMode:s,workspaces:o,activeWorkspaceId:i,workersByWorkspaceId:d}=a,f=s?[ii]:o,m=s?{[ii.id]:ny}:d,g=s?ii.id:i,h=s?ii:o?.find(b=>b.id===i);return{effectiveActiveWorkspaceId:g,effectiveWorkspaces:f,effectiveWorkersByWorkspaceId:m,effectiveActiveWorkspace:h,pollWorkspaceId:s?null:i}},PE=[{accent:"var(--status-green)",descriptionKey:"notifications.sound.soft.description",labelKey:"notifications.sound.soft.label",length:"short",value:"soft"},{accent:"var(--status-blue)",descriptionKey:"notifications.sound.ping.description",labelKey:"notifications.sound.ping.label",length:"short",value:"ping"},{accent:"var(--status-gold)",descriptionKey:"notifications.sound.chime.description",labelKey:"notifications.sound.chime.label",length:"short",value:"chime"},{accent:"var(--accent)",descriptionKey:"notifications.sound.cascade.description",labelKey:"notifications.sound.cascade.label",length:"long",value:"cascade"},{accent:"var(--status-orange)",descriptionKey:"notifications.sound.beacon.description",labelKey:"notifications.sound.beacon.label",length:"long",value:"beacon"},{accent:"var(--status-purple)",descriptionKey:"notifications.sound.resolve.description",labelKey:"notifications.sound.resolve.label",length:"long",value:"resolve"},{accent:"var(--text-tertiary)",descriptionKey:"notifications.sound.off.description",labelKey:"notifications.sound.off.label",length:"silent",value:"off"}],IE=[{descriptionKey:"notifications.detail.brief.description",labelKey:"notifications.detail.brief.label",value:"brief"},{descriptionKey:"notifications.detail.detailed.description",labelKey:"notifications.detail.detailed.label",value:"detailed"}],ej=()=>{const{t:a}=ve(),[s,o]=y.useState(!1),i=y.useRef(null),d=y.useRef(null),{notify:f,previewSound:m,requestDesktopNotifications:g,settings:h,updateSettings:v}=Jv(),b=typeof window<"u"&&!("Notification"in window),w=y.useMemo(()=>PE.map(S=>({...S,description:a(S.descriptionKey),label:a(S.labelKey)})),[a]),k=y.useMemo(()=>IE.map(S=>({...S,description:a(S.descriptionKey),label:a(S.labelKey)})),[a]),E=S=>{if(!S){v({desktop:!1});return}g()};return y.useEffect(()=>{if(!s)return;const S=R=>{R.key==="Escape"&&(o(!1),d.current?.focus())},j=R=>{const _=i.current;_&&!_.contains(R.target)&&o(!1)};return document.addEventListener("keydown",S),document.addEventListener("pointerdown",j),()=>{document.removeEventListener("keydown",S),document.removeEventListener("pointerdown",j)}},[s]),u.jsxs("div",{ref:i,className:"relative",children:[u.jsx(Je,{label:a("notifications.settings.tooltip"),children:u.jsx("button",{ref:d,type:"button","aria-expanded":s,"aria-haspopup":"dialog","aria-label":a("notifications.settings.aria"),className:"flex h-7 w-7 cursor-pointer items-center justify-center rounded text-sec hover:bg-3 hover:text-pri","data-testid":"topbar-settings",onClick:()=>o(S=>!S),children:u.jsx(wh,{size:14,"aria-hidden":!0})})}),s?u.jsxs("div",{role:"dialog","aria-label":a("notifications.settings.aria"),className:"elev-2 absolute top-8 right-0 z-50 w-[380px] rounded border p-3",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},"data-testid":"notification-settings",children:[u.jsxs("div",{className:"mb-3 flex items-start gap-2",children:[u.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded bg-3 text-sec",children:u.jsx(wh,{size:16,"aria-hidden":!0})}),u.jsxs("div",{className:"min-w-0",children:[u.jsx("div",{className:"text-sm font-semibold text-pri",children:a("notifications.settings.heading")}),u.jsx("div",{className:"text-ter text-xs",children:a("notifications.settings.subtitle")})]})]}),u.jsxs("section",{className:"mb-3",children:[u.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-ter text-xs uppercase tracking-wider",children:[u.jsx(Sh,{size:12,"aria-hidden":!0}),a("notifications.sound.sectionLabel")]}),u.jsx("div",{role:"radiogroup","aria-label":a("notifications.sound.sectionLabel"),className:"grid grid-cols-2 gap-2",children:w.map(S=>u.jsxs("div",{className:"relative min-h-[78px] rounded border transition-colors",style:{background:h.sound===S.value?`color-mix(in oklab, ${S.accent} 10%, var(--bg-2))`:"var(--bg-2)",borderColor:h.sound===S.value?`color-mix(in oklab, ${S.accent} 54%, var(--border-bright))`:"var(--border)"},children:[u.jsxs("label",{className:"block h-full w-full cursor-pointer rounded px-3 py-2 pr-10 text-left transition-colors hover:bg-3 focus-within:outline-none focus-within:ring-2 focus-within:ring-[var(--ring-focus)]",children:[u.jsx("input",{type:"radio",name:"notification-sound",value:S.value,checked:h.sound===S.value,className:"sr-only",onChange:()=>v({sound:S.value})}),u.jsxs("span",{className:"mb-1 flex items-center gap-2",children:[u.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded",style:{background:`color-mix(in oklab, ${S.accent} 16%, transparent)`,color:S.accent},children:S.value==="off"?u.jsx(e1,{size:12,"aria-hidden":!0}):u.jsx(Sh,{size:12,"aria-hidden":!0})}),u.jsx("span",{className:"font-medium text-pri text-xs",children:S.label}),S.length==="long"?u.jsx("span",{className:"rounded border border-[var(--border-bright)] px-1.5 py-0.5 text-xs text-ter uppercase",children:a("notifications.sound.longerBadge")}):null,h.sound===S.value?u.jsx(Ds,{size:12,className:"ml-auto text-pri","aria-hidden":!0}):null]}),u.jsx("span",{className:"block text-ter text-xs",children:S.description})]}),S.value!=="off"?u.jsx("button",{type:"button","aria-label":a("notifications.sound.previewAria",{label:S.label}),className:"absolute right-2 bottom-2 flex h-6 w-6 items-center justify-center rounded border text-sec transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border-bright)"},onClick:()=>m(S.value),children:u.jsx(ji,{size:12,"aria-hidden":!0})}):null]},S.value))})]}),u.jsxs("section",{className:"mb-3",children:[u.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-ter text-xs uppercase tracking-wider",children:[u.jsx(T0,{size:12,"aria-hidden":!0}),a("notifications.detail.sectionLabel")]}),u.jsx("div",{role:"radiogroup","aria-label":a("notifications.detail.sectionLabel"),className:"grid grid-cols-2 rounded border p-1",style:{background:"var(--bg-1)",borderColor:"var(--border)"},children:k.map(S=>u.jsxs("label",{className:"cursor-pointer rounded px-3 py-2 text-left transition-colors hover:bg-3 focus-within:outline-none focus-within:ring-2 focus-within:ring-[var(--ring-focus)]",style:{background:h.detail===S.value?"var(--bg-3)":"transparent",color:h.detail===S.value?"var(--text-primary)":"var(--text-secondary)"},children:[u.jsx("input",{type:"radio",name:"notification-detail",value:S.value,checked:h.detail===S.value,className:"sr-only",onChange:()=>v({detail:S.value})}),u.jsx("span",{className:"block font-medium text-xs",children:S.label}),u.jsx("span",{className:"block text-ter text-xs",children:S.description})]},S.value))})]}),u.jsxs("label",{className:"mb-3 flex items-start gap-2 rounded border p-2 text-sec text-xs",children:[u.jsx("input",{type:"checkbox","aria-label":a("notifications.desktop.aria"),checked:h.desktop,disabled:b,className:"mt-0.5",onChange:S=>E(S.currentTarget.checked)}),u.jsxs("span",{children:[u.jsx("span",{className:"block font-medium text-pri",children:a("notifications.desktop.label")}),u.jsx("span",{className:"text-ter",children:a(b?"notifications.desktop.unsupported":"notifications.desktop.helper")})]})]}),u.jsxs("div",{className:"flex justify-end gap-2 border-t pt-3",style:{borderColor:"var(--border)"},children:[u.jsx("button",{type:"button",className:"icon-btn",onClick:()=>o(!1),children:a("common.close")}),u.jsx("button",{type:"button",className:"icon-btn icon-btn--primary",onClick:()=>f({brief:a("notifications.test.brief"),detail:a("notifications.test.detail"),kind:"success",title:a("notifications.test.title")}),children:a("notifications.test.button")})]})]}):null]})},tj=a=>{const[s,o]=y.useState(null);return y.useEffect(()=>{if(a)return;let i=!0;return Z2().then(d=>{i&&o(d)}).catch(()=>{i&&o(null)}),()=>{i=!1}},[a]),a??s},nj="1.1.3",aj={version:nj},lj=aj.version,sj=()=>{const{language:a,setLanguage:s,t:o}=ve(),i=a==="en"?"zh":"en",d=o(i==="en"?"language.switchToEn":"language.switchToZh"),f=o(a==="en"?"language.currentEn":"language.currentZh");return u.jsx(Je,{label:d,children:u.jsx("span",{children:u.jsxs("button",{type:"button","aria-label":d,onClick:()=>s(i),className:"flex h-7 items-center gap-1 rounded border px-2 text-xs font-medium text-ter transition-colors hover:bg-3 hover:text-pri focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[u.jsx(R0,{size:13,"aria-hidden":!0}),u.jsx("span",{children:f})]})})})},rj=({hideActions:a=!1,version:s=lj,versionInfo:o})=>{const{t:i}=ve(),d=tj(o),f=d?.updateAvailable&&d.latestVersion!==s?d:null;return u.jsxs("header",{className:"flex h-11 shrink-0 items-center px-4",style:{background:"var(--bg-0)",borderBottom:"1px solid var(--border)"},children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("img",{src:"/logo.png",alt:"","aria-hidden":!0,className:"h-5 w-5 rounded-md","data-testid":"topbar-logo"}),u.jsx("span",{className:"font-semibold text-pri",children:"Hive"}),u.jsxs("span",{className:"text-ter text-xs tabular-nums",children:["v",s]}),f?u.jsxs("div",{className:"flex items-center gap-2 text-xs","data-testid":"topbar-update-badge",children:[u.jsx("span",{className:"rounded border px-2 py-0.5 font-medium",style:{background:"color-mix(in oklab, var(--accent) 10%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 30%, transparent)",color:"var(--accent)"},children:i("topbar.updateAvailable")}),u.jsxs("span",{className:"text-ter",children:["v",s," → v",f.latestVersion]}),u.jsx("code",{className:"mono text-ter",children:f.installHint})]}):null]}),u.jsx("div",{className:"flex-1"}),a?null:u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(sj,{}),u.jsx(ej,{})]})]})},iy="hive.workspace-sidebar.width",id=56,od=280,Su=256,dg=16,gi=a=>Math.min(od,Math.max(id,a)),ij=()=>{try{const a=localStorage.getItem(iy);if(!a)return Su;const s=Number.parseInt(a,10);return Number.isFinite(s)?gi(s):Su}catch{return Su}},oj=()=>{const[a,s]=y.useState(ij),[o,i]=y.useState(!1);y.useEffect(()=>{try{localStorage.setItem(iy,String(Math.round(a)))}catch{}},[a]);const d=y.useCallback(m=>{m.preventDefault();const g=m.clientX,h=a;i(!0);const v=document.body.style.cursor,b=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const w=E=>{s(gi(h+E.clientX-g))},k=()=>{i(!1),document.body.style.cursor=v,document.body.style.userSelect=b,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",k)},[a]),f=y.useCallback(m=>{m.key==="ArrowLeft"?(m.preventDefault(),s(g=>gi(g-dg))):m.key==="ArrowRight"?(m.preventDefault(),s(g=>gi(g+dg))):m.key==="Home"?(m.preventDefault(),s(id)):m.key==="End"&&(m.preventDefault(),s(od))},[]);return{beginResize:d,onResizeKeyDown:f,resizing:o,width:a}},cj=({children:a,hideTopbarActions:s=!1,sidebar:o})=>{const{t:i}=ve(),d=oj();return u.jsxs("div",{className:"flex h-screen w-full flex-col overflow-hidden",style:{background:"var(--bg-0)",color:"var(--text-primary)"},children:[u.jsx(rj,{hideActions:s}),u.jsxs("div",{className:"flex min-h-0 flex-1",children:[u.jsxs("aside",{"aria-label":i("layout.sidebarAria"),className:"workspace-sidebar relative flex shrink-0 flex-col","data-resizing":d.resizing?"true":"false",style:{background:"var(--bg-0)",boxShadow:"inset -1px 0 0 var(--border)",width:`${d.width}px`},children:[o,u.jsx("hr",{"aria-label":i("layout.sidebarResizeAria"),"aria-orientation":"vertical","aria-valuemin":id,"aria-valuemax":od,"aria-valuenow":Math.round(d.width),tabIndex:0,className:"workspace-sidebar-resizer","data-resizing":d.resizing?"true":"false",onMouseDown:d.beginResize,onKeyDown:d.onResizeKeyDown})]}),u.jsx("section",{className:"relative flex min-w-0 flex-1",children:a})]})]})},fg=[{token:"var(--accent)",label:"accent"},{token:"var(--status-blue)",label:"blue"},{token:"var(--status-purple)",label:"purple"},{token:"var(--status-orange)",label:"orange"},{token:"var(--status-green)",label:"green"},{token:"var(--status-gold)",label:"gold"}],uj=a=>{let s=0;for(let i=0;i<a.length;i+=1)s=s*31+a.charCodeAt(i)|0;const o=Math.abs(s)%fg.length;return fg[o]},dj=a=>{const s=a.trim();if(s.length===0)return"?";const o=s.codePointAt(0);return o===void 0?"?":String.fromCodePoint(o).toUpperCase()},mg=({workspaceId:a,name:s,isActive:o,working:i,workingCount:d,size:f=32})=>{const{token:m,label:g}=uj(a),h=dj(s),v=d&&d>1?d:null;return u.jsx(sd,{size:f,color:m,fontRatio:.45,ringColor:o?m:null,testId:"workspace-avatar",data:{"workspace-id":a,active:o?"true":void 0,"color-label":g},decoration:v!==null?u.jsx("span",{className:"absolute flex h-[16px] min-w-[16px] items-center justify-center rounded-full px-1 font-medium text-xs tabular-nums leading-none",style:{right:"-4px",bottom:"-4px",background:"var(--status-green)",color:"#0a1f0a",boxShadow:"0 0 0 2px var(--bg-1)"},"data-testid":"workspace-avatar-working-count","aria-hidden":!0,children:v>9?"9+":v}):i?u.jsx("span",{className:"status-dot status-dot--working absolute",style:{right:"-2px",bottom:"-2px",boxShadow:"0 0 0 2px var(--bg-1)"},"aria-hidden":!0}):null,children:h})},fj=a=>!!a?.some(s=>s.status==="working"),mj=a=>a?.filter(s=>s.status==="working").length??0,pj=(a,s)=>{if(!a||a.length===0)return s("sidebar.noMembers");const o=a.filter(i=>i.status==="working").length;return o>0?s("sidebar.workingCount",{working:o,total:a.length}):s("sidebar.teamMemberCount",{count:a.length})},oy="hive.sidebar.githubDismissed",hj=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(oy)==="1"}catch{return!1}},gj=({activeWorkspaceId:a,createDisabledReason:s,onCreateClick:o,onDeleteWorkspace:i,onSelectWorkspace:d,workersByWorkspaceId:f,workspaces:m})=>{const{t:g}=ve(),[h,v]=y.useState(null),[b,w]=y.useState(!1),[k,E]=y.useState(hj),S=Ol(),j=()=>{E(!0);try{window.localStorage.setItem(oy,"1")}catch{}},R=!!s,_=D=>{v(D)},q=()=>{if(!h||b)return;const D=h;w(!0),Promise.resolve(i(D)).then(()=>{S.show({kind:"success",message:g("sidebar.removed",{name:D.name})})}).catch(Q=>{const Z=Q instanceof Error?Q.message:String(Q);S.show({kind:"error",message:g("sidebar.deleteFailed",{message:Z})})}).finally(()=>{w(!1),v(null)})},Y=u.jsx(Iv,{open:h!==null,onOpenChange:D=>{!D&&!b&&v(null)},title:h?g("sidebar.deleteConfirm",{name:h.name}):g("sidebar.deleteLabel"),description:h?g("sidebar.deleteDescription",{path:h.path,summary:pj(f[h.id],g)}):"",confirmLabel:g(b?"sidebar.deleting":"sidebar.deleteLabel"),confirmKind:"danger",onConfirm:q});return u.jsxs("nav",{"aria-label":"Workspaces",className:"flex h-full flex-col",children:[u.jsx("div",{className:"flex items-center justify-between gap-2 px-3 pt-3 pb-2",style:{boxShadow:"inset 0 -1px 0 var(--border)"},children:u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{className:"ws-sidebar-title__text text-xs font-medium text-ter","data-testid":"workspace-sidebar-title",children:g("sidebar.workspaces")}),m&&m.length>0?u.jsx("span",{className:"ws-sidebar-count mono rounded bg-2 px-1.5 py-0.5 text-xs text-ter",children:m.length}):null]})}),m===null?u.jsx("p",{className:"px-3 py-2 text-xs text-ter",children:g("common.loading")}):m.length===0?u.jsx("div",{className:"flex-1 px-2 py-4",children:u.jsx(Tl,{title:g("sidebar.noWorkspaces"),description:s??g("sidebar.noWorkspacesDesc"),icon:u.jsx(Sg,{size:20}),action:u.jsxs("button",{type:"button",onClick:R?void 0:o,disabled:R,"aria-label":g("sidebar.newWorkspace"),title:s??g("sidebar.newWorkspace"),className:"icon-btn icon-btn--primary mt-1 flex items-center gap-1.5 px-4 py-2 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50",children:[u.jsx(As,{size:14,"aria-hidden":!0}),g("sidebar.newWorkspace")]})})}):u.jsxs("ul",{className:"flex-1 scroll-y pb-2",children:[m.map(D=>{const Q=f[D.id],Z=D.id===a,M=fj(Q),$=mj(Q);return u.jsxs("li",{className:"group relative",children:[u.jsx(Je,{side:"right",label:u.jsxs("span",{className:"flex flex-col gap-0.5",children:[u.jsx("span",{className:"font-medium",children:D.name}),u.jsx("span",{className:"mono text-ter",children:D.path})]}),children:u.jsxs("button",{type:"button","aria-label":D.name,"aria-current":Z?"true":void 0,"data-workspace-path":D.path,onClick:()=>d(D.id),className:`ws-row flex w-full items-center gap-2.5 py-1.5 pr-7 pl-2 text-left${Z?" active":""}`,children:[u.jsx(mg,{workspaceId:D.id,name:D.name,isActive:Z,working:M,workingCount:$,size:22}),u.jsx("span",{className:`min-w-0 flex-1 truncate text-sm ${Z?"font-medium text-pri":"text-pri"}`,children:D.name})]})}),u.jsx(Je,{side:"right",label:u.jsxs("span",{className:"flex flex-col gap-0.5",children:[u.jsx("span",{className:"font-medium",children:D.name}),u.jsx("span",{className:"mono text-ter",children:D.path})]}),children:u.jsx("button",{type:"button","aria-label":D.name,"aria-current":Z?"true":void 0,onClick:()=>d(D.id),className:"ws-avatar-cell hidden w-full justify-center py-2","data-testid":"ws-avatar-cell",children:u.jsx(mg,{workspaceId:D.id,name:D.name,isActive:Z,working:M,workingCount:$})})}),u.jsx(Je,{label:g("sidebar.deleteAria",{name:D.name}),children:u.jsx("button",{type:"button","aria-label":g("sidebar.deleteAria",{name:D.name}),onClick:()=>_(D),className:"ws-row-delete absolute top-2 right-2 flex h-6 w-6 items-center justify-center rounded text-ter opacity-0 transition-colors hover:text-status-red focus:opacity-100 group-hover:opacity-100",children:u.jsx(qu,{size:14,"aria-hidden":!0})})})]},D.id)}),u.jsx("li",{children:u.jsx(Je,{label:s??g("sidebar.newWorkspace"),children:u.jsxs("button",{type:"button",onClick:R?void 0:o,disabled:R,"aria-label":g("sidebar.newWorkspace"),title:s??void 0,className:"ws-add ws-add--inline mx-3 mt-1 flex items-center justify-center gap-1.5 rounded border border-dashed px-3 py-2 text-xs font-medium text-sec transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:"var(--border-bright)"},children:[u.jsx(As,{size:14,"aria-hidden":!0}),u.jsx("span",{className:"ws-add__label",children:g("sidebar.newWorkspace")})]})})})]}),k?null:u.jsxs("div",{className:"ws-sidebar-footer group relative",style:{boxShadow:"inset 0 1px 0 var(--border)"},children:[u.jsxs("a",{href:"https://github.com/tt-a1i/hive",target:"_blank",rel:"noopener noreferrer","aria-label":g("sidebar.openRepository"),title:g("sidebar.openRepository"),className:"ws-sidebar-footer__link flex items-center gap-2.5 px-3 py-3 text-sm text-ter transition-colors hover:text-pri",children:[u.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:u.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"})}),u.jsx("span",{className:"ws-sidebar-footer__label",children:"GitHub"})]}),u.jsx("button",{type:"button","aria-label":g("sidebar.dismissRepository"),title:g("sidebar.dismissRepository"),onClick:j,className:"ws-sidebar-footer__dismiss absolute top-1.5 right-1.5 flex h-4 w-4 items-center justify-center rounded text-ter opacity-0 transition-opacity hover:bg-3 hover:text-pri focus:opacity-100 group-hover:opacity-100",children:u.jsx(El,{size:10,"aria-hidden":!0})})]}),Y]})},vj=(a,s,o)=>a===s||a===o,yj=(a,s)=>{const[o,i]=y.useState(""),[d,f]=y.useState(!1),[m,g]=y.useState(!1),[h,v]=y.useState(null),b=y.useRef(!1),w=y.useRef(""),k=y.useRef(""),E=y.useCallback((j,R)=>{if(!b.current){w.current=j,k.current=j,i(j),g(!1),v(null);return}vj(j,w.current,R)||(v(j),g(!0))},[]);y.useEffect(()=>{{i(""),f(!1),g(!1),v(null),b.current=!1,w.current="",k.current="";return}},[a]),y.useEffect(()=>{},[E,a]);const S=async(j,R)=>{};return{content:o,hasConflict:m,loaded:d,onChange:j=>{b.current=j!==w.current,k.current=j,i(j)},onKeepLocal:()=>{g(!1),v(null)},onReload:()=>{const j=h??w.current;w.current=j,b.current=!1,k.current=j,i(j),g(!1),v(null)},onSave:async()=>{},toggleTaskAtLine:async j=>{},appendTask:async j=>{j.trim()},appendSubtask:async(j,R)=>{R.trim()&&await S()},updateTaskText:async(j,R)=>{R.trim()&&await S()},deleteTask:async j=>{await S()}}},bj=a=>{if(!a||!(a instanceof HTMLElement))return!1;const s=a.tagName.toLowerCase();return!!(s==="input"||s==="textarea"||s==="select"||a.isContentEditable||a.closest(".xterm"))},xj=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),wj=a=>xj?a.metaKey:a.ctrlKey,kj=a=>{y.useEffect(()=>{const s=o=>{if(bj(o.target))return;const i=o.key.toLowerCase();for(const d of a){if(i!==d.key||(d.mod??!1)!==wj(o)||(d.shift??!1)!==o.shiftKey)continue;d.handler(o)!==!1&&o.preventDefault();return}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[a])},Sj=({bootstrapError:a,onSelectWorkspace:s,onTriggerAddDialog:o,workspaces:i})=>{const d=y.useMemo(()=>{const f=(i??[]).slice(0,9).map((m,g)=>({key:String(g+1),mod:!0,handler:()=>s(m.id)}));return[{key:"n",mod:!0,shift:!0,handler:()=>{a||o()}},...f]},[a,s,o,i]);kj(d)},Ej=(a,s)=>s&&a.some(o=>o.id===s)?s:a[0]?.id??null,jj=(a,s)=>{if(a===null)return s;const o=new Map(a.map(i=>[i.id,i]));for(const i of s)o.set(i.id,i);return Array.from(o.values())},Nj=(a,s,o)=>{y.useEffect(()=>{let i=!1;return qv().then(async()=>{const[d,f]=await Promise.all([Q2(),F2().catch(()=>null)]);return{items:d,persistedId:f}}).then(({items:d,persistedId:f})=>{i||a(m=>{const g=jj(m,d),h=Ej(g,f);return s(h),f!==h&&Yv(h).catch(v=>{console.error("[hive] swallowed:initSession.save",v)}),g})}).catch(d=>{i||(s(null),o&&o("Could not reach Hive runtime. Refresh once the runtime is back up.")),console.error("[hive] swallowed:initSession.bootstrap",d)}),()=>{i=!0}},[s,a,o])},Cj=()=>{const a=y.useRef(null);return y.useCallback(s=>{if(typeof document>"u")return;const o=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(s):s.replace(/"/g,'\\"'),i=document.querySelector(`[data-worker-name="${o}"]`);i&&(i.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),i.classList.add("worker-card-shell--highlight"),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i.classList.remove("worker-card-shell--highlight"),a.current=null},1e3))},[])},Tj=({onWorkspaceCreated:a,onError:s})=>{const[o,i]=y.useState({}),[d,f]=y.useState({}),m=y.useCallback((h,v)=>{i(b=>({...b,[h]:v.ok?null:v.error})),f(b=>({...b,[h]:v.ok?v.run_id:null}))},[]),g=y.useCallback(async h=>{try{const v=await $2({name:h.name,path:h.path,autostart_orchestrator:!0,command_preset_id:h.commandPresetId,startup_command:h.startupCommand??null});return m(v.id,v.orchestrator_start),a({id:v.id,name:v.name,path:v.path}),v}catch(v){const b=v instanceof Error?v.message:"Failed to create workspace";throw s?.(b),v}},[a,s,m]);return{orchestratorAutostartErrors:o,orchestratorAutostartRunIds:d,recordOrchestratorResult:m,createNewWorkspace:g}},Aj=(a,s)=>{const o=a.findIndex(d=>d.id===s),i=a.filter(d=>d.id!==s);return o<0?i[0]?.id??null:i[Math.min(o,i.length-1)]?.id??null},Rj=({activeWorkspaceId:a,onActiveDeleted:s,selectWorkspace:o,setWorkersByWorkspaceId:i,setWorkspaces:d,workspaces:f})=>async m=>{const h=Aj(f??[],m.id);await J2(m.id),d(v=>v?.filter(b=>b.id!==m.id)??v),i(v=>{const b={...v};return delete b[m.id],b}),m.id===a&&(s(),o(h))},_j=()=>{const[a,s]=y.useState(null),o=y.useRef(Promise.resolve());return{activeWorkspaceId:a,selectWorkspace:d=>{s(d),o.current=o.current.catch(Ca("selectWorkspace.prevQueue")).then(()=>Yv(d)).catch(Ca("selectWorkspace.save"))},setActiveWorkspaceId:s}},Oj=500,Dj=5e3,zj=a=>Math.min(Oj*2**a,Dj),Mj=a=>{const s=a.join("\0"),[o,i]=y.useState({});return y.useEffect(()=>{if(!s){i({});return}let d=!1,f=!1,m=0,g;const h=s.split("\0"),v=()=>{d||(g=window.setTimeout(b,zj(m)))},b=()=>{f||(f=!0,Promise.all(h.map(async w=>{try{return[w,await P2(w)]}catch(k){return console.error("[hive] swallowed:workspaceWorkers.list",k),null}})).then(w=>{d||(m=w.some(Boolean)?0:Math.min(m+1,4),i(k=>{const E={};for(const S of h)E[S]=k[S]??[];for(const S of w)S&&(E[S[0]]=S[1]);return E}))}).finally(()=>{f=!1,v()}))};return b(),()=>{d=!0,g!==void 0&&window.clearTimeout(g)}},[s]),[o,i]},pg="hive.first-run-seen",Lj=()=>{const[a,s]=y.useState(()=>{try{return window.localStorage.getItem(pg)==="1"}catch{return!0}}),o=y.useCallback(()=>{try{window.localStorage.setItem(pg,"1")}catch{}s(!0)},[]);return{seen:a,markSeen:o}},Hj=a=>{const{seen:s,markSeen:o}=Lj(),[i,d]=y.useState(!1);y.useEffect(()=>{!s&&a!==null&&a.length===0&&d(!0)},[s,a]);const f=y.useCallback((m=!0)=>{m&&o(),d(!1)},[o]);return{wizardOpen:i,closeWizard:f}},Uj=(a,s)=>a.findIndex(i=>i.id===s.id)===-1?[...a,s]:a.map(i=>i.id===s.id?s:i),Bj=({activeWorkspaceId:a,onWorkerDeleted:s,onWorkerRunStarted:o,setWorkersByWorkspaceId:i})=>{const d=y.useCallback(async({commandPresetId:h,name:v,role:b,roleDescription:w,startupCommand:k})=>{if(!a)return{error:"No active workspace",runId:null};const E=k.trim(),S=await lS(a,{autostart:!0,command_preset_id:h||null,description:w.trim(),name:v,role:b,startup_command:E||null});return i(j=>({...j,[a]:Uj(j[a]??[],S.worker)})),S.agentStart.ok&&S.agentStart.runId&&o?.({agentId:S.worker.id,agentName:S.worker.name,runId:S.agentStart.runId,workspaceId:a}),{error:S.agentStart.ok?null:S.agentStart.error,runId:S.agentStart.ok?S.agentStart.runId:null}},[a,o,i]),f=y.useCallback(async h=>{if(!a)throw new Error("No active workspace");await sS(a,h),i(v=>({...v,[a]:(v[a]??[]).filter(b=>b.id!==h)})),s?.(a,h)},[a,s,i]),m=y.useCallback(async h=>{if(!a)return{error:"No active workspace",runId:null};try{const v=await zu(a,h);return o?.({agentId:h,agentName:h,runId:v.runId,workspaceId:a}),{error:null,runId:v.runId}}catch(v){return{error:v instanceof Error?v.message:String(v),runId:null}}},[a,o]),g=y.useCallback(async h=>{try{return await Mu(h),{error:null}}catch(v){return{error:v instanceof Error?v.message:String(v)}}},[]);return{createWorker:d,deleteWorker:f,startWorker:m,stopWorkerRun:g}},Wj=!1,qj=()=>{const[a,s]=y.useState(null),{activeWorkspaceId:o,selectWorkspace:i,setActiveWorkspaceId:d}=_j(),{demoMode:f,enableDemo:m,exitDemo:g}=JE(),h=f||!a?[]:a.map(({id:z})=>z),[v,b]=Mj(h),[w,k]=y.useState(0),[E,S]=y.useState(!1),j=Ol(),{wizardOpen:R,closeWizard:_}=Hj(a),q=y.useCallback(()=>k(z=>z+1),[]),[Y,D]=y.useState(null),Q=y.useCallback(z=>{D(z),j.show({kind:"error",message:z})},[j]);Nj(s,d,Q);const Z=Tj({onWorkspaceCreated:z=>{s(F=>F===null?[z]:[...F,z]),i(z.id),b(F=>({...F,[z.id]:[]}))},onError:z=>j.show({kind:"error",message:z})}),$=FE({demoMode:f,workspaces:a,activeWorkspaceId:o,workersByWorkspaceId:v}),J=$.effectiveActiveWorkspace?.id,ae=J?$.effectiveWorkersByWorkspaceId[J]??[]:[],I=KE($.pollWorkspaceId,DS($.pollWorkspaceId)),se=yj(null),oe=Wj,fe=Bj({activeWorkspaceId:o,onWorkerDeleted:I.forgetOptimisticAgent,onWorkerRunStarted:I.recordOptimisticRun,setWorkersByWorkspaceId:b}),A=Rj({activeWorkspaceId:o,onActiveDeleted:()=>S(!1),selectWorkspace:i,setWorkersByWorkspaceId:b,setWorkspaces:s,workspaces:a});Sj({bootstrapError:Y,onSelectWorkspace:i,onTriggerAddDialog:q,workspaces:$.effectiveWorkspaces});const L=Cj();return u.jsxs(cj,{hideTopbarActions:!$.effectiveActiveWorkspace,sidebar:u.jsx(gj,{activeWorkspaceId:$.effectiveActiveWorkspaceId,createDisabledReason:Y??void 0,onCreateClick:q,onDeleteWorkspace:A,onSelectWorkspace:i,workersByWorkspaceId:$.effectiveWorkersByWorkspaceId,workspaces:$.effectiveWorkspaces}),children:[u.jsx($E,{activeId:J,activeWorkspace:$.effectiveActiveWorkspace,bootstrapError:Y,demoMode:f,onDeleteWorkspace:A,onExitDemo:g,onRequestAddWorkspace:q,onTryDemo:m,optimisticRunsByWorkspaceId:I.optimisticRunsByWorkspaceId,orchestratorAutostartErrors:Z.orchestratorAutostartErrors,orchestratorAutostartRunIds:Z.orchestratorAutostartRunIds,recordOrchestratorResult:Z.recordOrchestratorResult,terminalRuns:I.terminalRuns,workerActions:fe,workers:ae}),u.jsx(bS,{addDialogTrigger:w,wizardOpen:R,onAddWorkspace:q,onCloseTaskGraph:()=>S(!1),onCloseWizard:_,onCreateWorkspace:Z.createNewWorkspace,onTryDemo:m,taskGraphOpen:oe,tasksFile:se,workspacePath:$.effectiveActiveWorkspace?.path??null,workers:ae,onSelectOwner:L})]})},Yj=()=>u.jsx(_S,{children:u.jsx(qj,{})}),cy=document.getElementById("root");if(!cy)throw new Error("Root element not found");Gx.createRoot(cy).render(u.jsx(y.StrictMode,{children:u.jsx(Yj,{})}));
66
+ `)}},ci=(a,s,o)=>o==="zh"?s.find(i=>i.roleType===a)?.description??Lu.zh[a]:Lu.en[a],jE=({createWorker:a,open:s})=>{const{language:o}=ve(),[i,d]=y.useState(""),[f,m]=y.useState("coder"),[g,h]=y.useState([]),[v,b]=y.useState(Lu[o].coder),[w,k]=y.useState([]),[E,S]=y.useState("claude"),[j,R]=y.useState(!1),[_,q]=y.useState(""),[Y,D]=y.useState(null),[Q,Z]=y.useState(!1),M=y.useRef(!1),$=y.useRef(!1),J=ci(f,g,o);y.useEffect(()=>{if(!s)return;let L=!1;return Gv().then(z=>{L||(k(z),S(F=>z.some(ee=>ee.id===F&&ee.available)?F:z.find(ee=>ee.id==="claude"&&ee.available)?.id??z.find(ee=>ee.available)?.id??z[0]?.id??""))}).catch(z=>{L||D(z instanceof Error?z.message:String(z))}),()=>{L=!0}},[s]),y.useEffect(()=>{if(!s)return;let L=!1;return aS().then(z=>{L||(h(z),$.current||b(ci(f,z,o)))}).catch(z=>{L||D(z instanceof Error?z.message:String(z))}),()=>{L=!0}},[s,f,o]),y.useEffect(()=>{$.current||b(ci(f,g,o))},[o,g,f]);const ae=L=>{$.current=!0,b(L)},I=L=>{M.current=!1,d(L)},ie=()=>{M.current=!0,d(og(o))};y.useEffect(()=>{M.current&&d(og(o))},[o]);const se=L=>{m(L),$.current=!1,b(ci(L,g,o))};return{commandPresets:w,commandPresetId:E,createWorkerError:Y,creating:Q,roleDescription:v,roleDescriptionDefault:J,startupCommand:_,workerName:i,workerRole:f,setCommandPresetId:L=>{R(!0),S(L)},setRoleDescription:ae,setStartupCommand:q,setWorkerName:I,setWorkerRole:se,randomizeWorkerName:ie,resetRoleDescription:()=>{$.current=!1,b(J)},resetError:()=>D(null),submit:(L,z)=>{L.preventDefault(),Z(!0),D(null);const F=_.trim()&&!j?"":E;a({commandPresetId:F,name:i,role:f,roleDescription:v,startupCommand:_}).then(({error:ee})=>{d(""),M.current=!1,se("coder"),S("claude"),R(!1),q(""),z(),ee&&D(ee)}).catch(ee=>{D(ee instanceof Error?ee.message:String(ee))}).finally(()=>Z(!1))}}},NE=[{icon:u.jsx(Sg,{size:16}),titleKey:"welcome.step1Title",descriptionKey:"welcome.step1Desc"},{icon:u.jsx(F0,{size:16}),titleKey:"welcome.step2Title",descriptionKey:"welcome.step2Desc"},{icon:u.jsx(G0,{size:16}),titleKey:"welcome.step3Title",descriptionKey:"welcome.step3Desc"}],CE=({onAddWorkspace:a,onTryDemo:s,heroImageSrc:o,disabledReason:i})=>{const{t:d}=ve(),f=!!i;return u.jsxs("div",{"data-testid":"welcome-pane",className:"m-auto flex w-full flex-col items-center gap-6 px-6 py-12 text-center",style:{maxWidth:"540px"},children:[o?u.jsx("img",{src:o,alt:"",className:"h-24 w-24","aria-hidden":!0}):null,u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"text-2xl font-semibold text-pri",children:d("welcome.title")}),u.jsx("div",{className:"text-sm text-sec",children:d("welcome.desc")})]}),u.jsx("ol",{className:"grid w-full grid-cols-3 gap-3 text-left",children:NE.map((m,g)=>u.jsxs("li",{className:"rounded border bg-1 p-3",style:{borderColor:"var(--border)"},children:[u.jsxs("div",{className:"mb-1 flex items-center gap-2 text-pri",children:[u.jsx("span",{className:"font-medium text-xs text-ter",children:g+1}),m.icon]}),u.jsx("div",{className:"text-xs font-medium text-pri",children:d(m.titleKey)}),u.jsx("div",{className:"mt-1 text-xs text-ter",children:d(m.descriptionKey)})]},m.titleKey))}),f?u.jsxs("div",{role:"alert","data-testid":"welcome-pane-disabled-reason",className:"flex items-start gap-2 rounded px-3 py-2 text-left text-xs",style:{background:"color-mix(in oklab, var(--status-red) 10%, transparent)",border:"1px solid color-mix(in oklab, var(--status-red) 28%, transparent)",color:"var(--status-red)"},children:[u.jsx(Oa,{size:14,className:"mt-0.5 shrink-0","aria-hidden":!0}),u.jsx("span",{className:"break-words",children:i})]}):null,u.jsxs("button",{type:"button",disabled:f,onClick:f?void 0:a,"aria-disabled":f||void 0,title:i,className:"icon-btn icon-btn--primary inline-flex items-center gap-2 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"welcome-pane-add",children:[u.jsx("span",{children:d("welcome.addWorkspace")}),u.jsx(Fx,{size:14,"aria-hidden":!0})]}),s?u.jsx("button",{type:"button",onClick:s,className:"text-xs text-sec underline hover:text-pri",children:d("welcome.demo")}):null]})},TE=a=>{switch(a){case"coder":return{badgeClass:"role-badge--coder",label:"Coder"};case"tester":return{badgeClass:"role-badge--tester",label:"Tester"};case"reviewer":return{badgeClass:"role-badge--reviewer",label:"Reviewer"};case"custom":return{badgeClass:"role-badge--custom",label:"Custom"};default:return{badgeClass:"role-badge--custom",label:String(a)}}},sy="hive.worker-modal.width",Os=480,AE=.5,Ei=a=>{const s=typeof window<"u"?window.innerWidth-24:1200;return Math.min(Math.max(a,Os),Math.max(Os,s))},ku=()=>typeof window>"u"?Os:Ei(Math.round(window.innerWidth*AE)),RE=()=>{try{const a=localStorage.getItem(sy);if(!a)return ku();const s=Number.parseInt(a,10);return Number.isFinite(s)?Ei(s):ku()}catch{return ku()}},_E=()=>{const[a,s]=y.useState(()=>RE()),[o,i]=y.useState(!1);y.useEffect(()=>{try{localStorage.setItem(sy,String(Math.round(a)))}catch{}},[a]),y.useEffect(()=>{const f=()=>{s(m=>Ei(m))};return window.addEventListener("resize",f),()=>window.removeEventListener("resize",f)},[]);const d=y.useCallback(f=>m=>{m.preventDefault();const g=m.clientX,h=a;i(!0);const v=document.body.style.cursor,b=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const w=E=>{const S=E.clientX-g,j=f==="left"?h-2*S:h+2*S;s(Ei(j))},k=()=>{i(!1),document.body.style.cursor=v,document.body.style.userSelect=b,document.removeEventListener("pointermove",w),document.removeEventListener("pointerup",k),document.removeEventListener("pointercancel",k)};document.addEventListener("pointermove",w),document.addEventListener("pointerup",k),document.addEventListener("pointercancel",k)},[a]);return{width:a,resizing:o,beginResize:d}},OE=({onClose:a,onStart:s,runId:o,startError:i,starting:d,worker:f})=>{const{t:m}=ve(),g=TE(f.role),h=!!o,v=WS(h),b=_E(),w=k=>{k||a()};return u.jsx(It,{open:!0,onOpenChange:w,children:u.jsxs(en,{children:[u.jsx(tn,{"data-testid":"worker-modal-overlay",className:"app-overlay fixed inset-0 z-40"}),u.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center",children:u.jsxs(nn,{"data-testid":"worker-modal","aria-label":m("worker.detail",{name:f.name}),className:"dialog-scale-pop pointer-events-auto relative flex h-screen max-h-screen max-w-full flex-col overflow-hidden",onEscapeKeyDown:k=>k.preventDefault(),style:{background:"var(--bg-1)",width:`${b.width}px`},children:[u.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":m("worker.widthResize"),"aria-valuemin":Os,"aria-valuenow":Math.round(b.width),className:"modal-resize-handle modal-resize-handle--left",tabIndex:-1,"data-resizing":b.resizing||void 0,onPointerDown:b.beginResize("left")}),u.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":m("worker.widthResize"),"aria-valuemin":Os,"aria-valuenow":Math.round(b.width),className:"modal-resize-handle modal-resize-handle--right",tabIndex:-1,"data-resizing":b.resizing||void 0,onPointerDown:b.beginResize("right")}),u.jsx(Gt,{className:"sr-only",children:f.name}),u.jsxs(An,{className:"sr-only",children:[g.label," agent — status ",v.label]}),i?u.jsxs("div",{role:"alert",className:"flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 10%, transparent)",borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--status-red)"},children:[u.jsx(Oa,{size:12,"aria-hidden":!0}),u.jsx("span",{className:"break-words",children:i})]}):null,u.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col p-3","data-testid":"worker-modal-terminal-slot",children:[u.jsx(Je,{label:m("common.close"),children:u.jsx(ld,{asChild:!0,children:u.jsx("button",{type:"button","aria-label":"Close worker detail",className:"float-action absolute top-4 right-4 z-10",children:u.jsx(El,{size:14,"aria-hidden":!0})})})}),u.jsx("div",{className:"flex min-h-0 flex-1 rounded-lg border",style:{background:"var(--bg-crust)",borderColor:"var(--border)"},children:h?u.jsx("div",{id:`worker-pty-${o}`,className:"flex h-full w-full","data-pty-slot":"worker"}):u.jsxs("div",{className:"m-auto flex max-w-[400px] flex-col items-center gap-3 px-6 text-center",children:[u.jsx(ey,{commandPresetId:f.commandPresetId,workerRole:f.role,size:48}),u.jsx("div",{className:"text-sm text-pri",children:f.name}),u.jsxs("div",{className:"text-xs text-ter",children:[f.status==="stopped"?m("worker.terminalStopped"):m("worker.terminalNotStarted"),f.pendingTaskCount>0?m("worker.pendingResume",{count:f.pendingTaskCount}):m("worker.startAgent")]}),u.jsxs("button",{type:"button",onClick:()=>s(f),disabled:d,className:"icon-btn icon-btn--primary","data-testid":"worker-start-empty",children:[u.jsx(ji,{size:12,"aria-hidden":!0})," ",m(d?"common.starting":"common.start")]})]})})]})]})})]})})},DE=({onCreateWorker:a,onDeleteWorker:s,onDeleteWorkspace:o,onStartWorker:i,onOrchestratorResult:d,onRequestAddWorkspace:f,onTryDemo:m,welcomeDisabledReason:g,orchestratorAutostartError:h,orchestratorAutostartRunId:v,terminalRuns:b,workers:w,workspace:k})=>{const{t:E}=ve(),[S,j]=y.useState(null),[R,_]=y.useState(!1),[q,Y]=y.useState(null),[D,Q]=y.useState(null),[Z,M]=y.useState(!1),[$,J]=y.useState(null),[ae,I]=y.useState(!1),[ie,se]=y.useState(null),[oe,fe]=y.useState(null),A=Ol(),L=w.find(pe=>pe.id===S)??null;y.useEffect(()=>{S&&!L&&j(null)},[S,L]);const z=jE({createWorker:a,open:R});y.useEffect(()=>{z.createWorkerError&&A.show({kind:"error",message:z.createWorkerError})},[z.createWorkerError,A]),y.useEffect(()=>{q&&A.show({kind:"error",message:q})},[q,A]),y.useEffect(()=>{Y(null),Q(null),M(!1),J(null),I(!1),se(null),fe(null)},[k?.id]);const F=bE({workspaceId:k?.id??"",terminalRuns:b,autostartError:h,suppressAutostartRunId:v,onClearAutostartError:()=>{k&&d(k.id,{ok:!0,error:null,run_id:null})},onAfterStart:pe=>{k&&d(k.id,pe)}}),ee=eE();if(!k){const pe={onAddWorkspace:f};return m&&(pe.onTryDemo=m),g&&(pe.disabledReason=g),u.jsx(CE,{...pe})}const C=L?Pv(b,L.id):void 0,X=b.filter(pe=>eS(pe,k.id)),te=(X.find(pe=>pe.run_id===$)??X[0]??null)?.run_id??null,ue=pe=>{Y(null),s(pe.id).then(()=>j(null)).catch(Me=>{Y(Me instanceof Error?Me.message:String(Me))})},me=pe=>{se(null),fe(pe.id),i(pe.id).then(({error:Me})=>{Me&&se(Me)}).catch(Me=>{se(Me instanceof Error?Me.message:String(Me))}).finally(()=>fe(null))},be=async(pe,Me)=>{try{return await rS(k.id,pe.id,Me),A.show({kind:"success",message:E("worker.renameSuccess",{name:Me})}),{error:null}}catch(Ie){const Rn=Ie instanceof Error?Ie.message:String(Ie);return A.show({kind:"error",message:E("worker.renameFailed",{message:Rn})}),{error:Rn}}},qe=()=>{Q(null),I(!0),tS(k.id).then(pe=>J(pe.run_id)).catch(pe=>{Q(pe instanceof Error?pe.message:String(pe))}).finally(()=>I(!1))},ze=()=>{M(!0),X.length===0&&!ae?qe():te||J(X[0]?.run_id??null)},ln=pe=>{const Me=X.find(Ie=>Ie.run_id!==pe)??null;te===pe&&J(Me?.run_id??null),nS(k.id,pe).catch(Ie=>{const Rn=Ie instanceof Error?Ie.message:String(Ie);A.show({kind:"error",message:E("shellTerminal.closeFailed",{message:Rn})})})},sn=`${(ee.orchPct*100).toFixed(2)}%`;return u.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",style:{background:"var(--bg-2)"},children:[u.jsx(FS,{terminalRuns:b,workers:w,workspace:k}),u.jsxs("div",{ref:ee.containerRef,className:"relative flex min-h-0 flex-1",children:[u.jsx("div",{className:"flex min-w-[480px] shrink-0 flex-col",style:{width:sn},"data-testid":"orchestrator-pane-shell",children:u.jsx(yE,{state:F.state,onStop:F.stop,onRemoveWorkspace:()=>{k&&o(k).catch(pe=>{const Me=pe instanceof Error?pe.message:String(pe);A.show({kind:"error",message:`Delete failed: ${Me}`})})},onStart:F.start,onRestart:F.restart})}),u.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":E("workerPane.resize"),"aria-valuenow":Math.round(ee.orchPct*100),"aria-valuemin":30,"aria-valuemax":78,tabIndex:0,className:"pane-splitter",style:{left:`calc(${sn} - 4px)`},"data-dragging":ee.dragging||void 0,"data-testid":"pane-splitter",onPointerDown:ee.beginDrag,onKeyDown:ee.onKeyDown}),u.jsx(ty,{onAddWorkerClick:()=>_(!0),onDeleteWorker:ue,onOpenShellTerminal:ze,onOpenWorker:pe=>j(pe.id),onRenameWorker:be,onStartWorker:me,startingWorkerId:oe,terminalRuns:b,workers:w})]}),L?u.jsx(OE,{onClose:()=>j(null),onStart:me,runId:C?.run_id??null,startError:ie,starting:oe===L.id,worker:L}):null,R?u.jsx(pE,{commandPresets:z.commandPresets,commandPresetId:z.commandPresetId,creating:z.creating,onClose:()=>_(!1),onNameChange:z.setWorkerName,onPresetChange:z.setCommandPresetId,onRandomName:z.randomizeWorkerName,onRoleDescriptionChange:z.setRoleDescription,onRoleDescriptionReset:z.resetRoleDescription,onRoleChange:z.setWorkerRole,onSubmit:pe=>z.submit(pe,()=>_(!1)),onStartupCommandChange:z.setStartupCommand,roleDescription:z.roleDescription,roleDescriptionDefault:z.roleDescriptionDefault,startupCommand:z.startupCommand,workerName:z.workerName,workerRole:z.workerRole}):null,u.jsx(PS,{activeRunId:te,error:D,onActiveRunChange:J,onClose:()=>M(!1),onCloseTab:ln,onNewTab:qe,open:Z,shellRuns:X,starting:ae,workspace:k})]})},zE="modulepreload",ME=function(a){return"/"+a},cg={},wl=function(s,o,i){let d=Promise.resolve();if(o&&o.length>0){let v=function(b){return Promise.all(b.map(w=>Promise.resolve(w).then(k=>({status:"fulfilled",value:k}),k=>({status:"rejected",reason:k}))))};var m=v;document.getElementsByTagName("link");const g=document.querySelector("meta[property=csp-nonce]"),h=g?.nonce||g?.getAttribute("nonce");d=v(o.map(b=>{if(b=ME(b),b in cg)return;cg[b]=!0;const w=b.endsWith(".css"),k=w?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${b}"]${k}`))return;const E=document.createElement("link");if(E.rel=w?"stylesheet":zE,w||(E.as="script"),E.crossOrigin="",E.href=b,h&&E.setAttribute("nonce",h),document.head.appendChild(E),w)return new Promise((S,j)=>{E.addEventListener("load",S),E.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${b}`)))})}))}function f(g){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=g,window.dispatchEvent(h),!h.defaultPrevented)throw g}return d.then(g=>{for(const h of g||[])h.status==="rejected"&&f(h.reason);return s().catch(f)})},LE=()=>typeof navigator>"u"?!1:/Mac|iPhone|iPad/.test(navigator.platform),Na={killToLineStart:"",lineStart:"",lineEnd:"",killWordBack:"\x1B",wordBack:"\x1Bb",wordForward:"\x1Bf",shiftEnter:"\x1B[13;2u"},HE=(a,s={})=>{const o=s.isMac??LE();if(a.key==="Enter"&&a.shiftKey)return a.type==="keypress"?{kind:"send",bytes:Na.shiftEnter}:{kind:"block"};if(!o||a.type!=="keydown")return{kind:"passthrough"};const i=a.metaKey&&!a.ctrlKey&&!a.altKey&&!a.shiftKey,d=a.altKey&&!a.metaKey&&!a.ctrlKey;if(i)switch(a.key){case"Backspace":return{kind:"send",bytes:Na.killToLineStart};case"ArrowLeft":return{kind:"send",bytes:Na.lineStart};case"ArrowRight":return{kind:"send",bytes:Na.lineEnd};case"k":case"K":return{kind:"clear"}}if(d)switch(a.key){case"Backspace":return{kind:"send",bytes:Na.killWordBack};case"ArrowLeft":return{kind:"send",bytes:Na.wordBack};case"ArrowRight":return{kind:"send",bytes:Na.wordForward}}return{kind:"passthrough"}},ug=(a,s={})=>{const o=new URL(a,window.location.href);o.protocol=o.protocol==="https:"?"wss:":"ws:";for(const[i,d]of Object.entries(s))d!==void 0&&o.searchParams.set(i,String(d));return o.toString()},UE=({initialSize:a,onError:s,onExit:o,onOutput:i,onRestore:d,runId:f})=>{const m=crypto.randomUUID(),g={...a,clientId:m},h=new WebSocket(ug(`/ws/terminal/${f}/io`,g)),v=new WebSocket(ug(`/ws/terminal/${f}/control`,g));let b=!1;const w=[];let k=null;const E=()=>{!k||v.readyState!==v.OPEN||(v.send(JSON.stringify({type:"resize",...k})),k=null)};return h.onmessage=S=>{const j=typeof S.data=="string"?S.data:"",R=_=>{v.readyState===v.OPEN&&v.send(JSON.stringify({type:"output_ack",bytes:_}))};if(!b){w.push({chunk:j,acknowledge:R});return}i(j,R)},v.onopen=()=>{E()},v.onmessage=S=>{const j=JSON.parse(String(S.data));if(j.type==="exit"&&o(j.code),j.type==="error"&&s(j.message),j.type==="restore"){d(j.snapshot),b=!0,v.readyState===v.OPEN&&v.send(JSON.stringify({type:"restore_complete"}));for(const R of w.splice(0))i(R.chunk,R.acknowledge)}},{dispose(){h.close(),v.close()},resize(S,j,R,_){k={cols:S,rows:j},R!==void 0&&(k.pixelWidth=R),_!==void 0&&(k.pixelHeight=_),E()},sendInput(S){h.readyState===h.OPEN&&h.send(S)}}},BE=a=>{const s=y.useRef(null),[o,i]=y.useState(null),[d,f]=y.useState("connecting");return y.useEffect(()=>{if(!s.current)return;let m=!1,g,h,v,b,w,k,E,S=null,j,R;const _={current:!1};return Promise.all([wl(()=>import("./xterm-B-qIQCd3.js"),[]),wl(()=>import("./addon-fit-DX4qG4td.js"),[]),wl(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]),wl(()=>import("./addon-webgl-DCtw1yLn.js"),[]),wl(()=>import("./addon-clipboard-wHJhZAA4.js"),[]),wl(()=>import("./addon-web-links-DIbG5aQx.js"),[])]).then(([q,Y,D,Q,Z,M])=>{if(m||!s.current)return;const $=typeof window<"u"?getComputedStyle(document.documentElement):null,J=$?.getPropertyValue("--bg-crust").trim()||"#0e0e0e",ae=$?.getPropertyValue("--text-primary").trim()||"#ebebeb",I=new q.Terminal({allowProposedApi:!0,convertEol:!1,fontFamily:"'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:13,letterSpacing:0,lineHeight:1,scrollback:1e4,theme:{background:J,foreground:ae}}),ie=new Y.FitAddon;I.loadAddon(ie),I.loadAddon(new D.Unicode11Addon),I.unicode.activeVersion="11",I.loadAddon(new Z.ClipboardAddon),I.loadAddon(new M.WebLinksAddon),I.open(s.current),ie.fit(),b=I,w=ie;try{const A=new Q.WebglAddon;A.onContextLoss(()=>A.dispose()),I.loadAddon(A)}catch{}if(S=s.current.querySelector(".xterm-helper-textarea"),S){const A=S;j=()=>{_.current=!0},R=L=>{const z=L.data;z&&v?.sendInput(z),A.value="",setTimeout(()=>{_.current=!1},0)},S.addEventListener("compositionstart",j,{capture:!0}),S.addEventListener("compositionend",R,{capture:!0})}typeof I.attachCustomKeyEventHandler=="function"&&I.attachCustomKeyEventHandler(A=>{const L=HE(A);switch(L.kind){case"send":return A.preventDefault(),v?.sendInput(L.bytes),!1;case"clear":return A.preventDefault(),I.clear(),!1;case"block":return!1;case"passthrough":return!0}});const se=()=>{if(!s.current)return{};const A=s.current.clientWidth,L=s.current.clientHeight,z={};return L>0&&(z.pixelHeight=L),A>0&&(z.pixelWidth=A),z},oe=()=>{if(!s.current)return;w?.fit();const{pixelHeight:A,pixelWidth:L}=se();v?.resize(b?.cols??80,b?.rows??24,L,A)},fe=()=>{E&&window.clearTimeout(E),E=window.setTimeout(()=>{E=void 0,oe()},50)};v=UE({initialSize:{cols:I.cols,rows:I.rows,...se()},onError(A){i(A)},onExit(){f("stopped")},onOutput(A,L){I.write(A,()=>L(new TextEncoder().encode(A).byteLength))},onRestore(A){I.write(A)},runId:a}),h=I.onData(A=>{_.current||v?.sendInput(A)}),f("running"),oe(),typeof ResizeObserver<"u"&&s.current&&(k=new ResizeObserver(fe),k.observe(s.current)),g=()=>oe(),window.addEventListener("resize",g)}),()=>{m=!0,g&&window.removeEventListener("resize",g),k?.disconnect(),E&&window.clearTimeout(E),S&&j&&S.removeEventListener("compositionstart",j,{capture:!0}),S&&R&&S.removeEventListener("compositionend",R,{capture:!0}),h?.dispose(),v?.dispose(),b?.dispose(),w?.dispose()}},[a]),{containerRef:s,error:o,status:d}},WE={connecting:"terminal.statusConnecting",running:"terminal.statusRunning",stopped:"common.stopped"},qE=a=>[`worker-pty-${a}`,`orch-pty-${a}`,`shell-pty-${a}`],YE=a=>{const[s,o]=y.useState(null);return y.useEffect(()=>{const i=qE(a),d=()=>{for(const m of i){const g=document.getElementById(m);if(g)return g}return null};o(d());const f=window.setInterval(()=>{const m=d();o(g=>g===m?g:m)},100);return()=>window.clearInterval(f)},[a]),s},GE=({runId:a,title:s})=>{const o=YE(a),i=o?o.id:"inline",d=u.jsx(XE,{runId:a,title:s},i);return o?Ni.createPortal(d,o):null},XE=({runId:a,title:s})=>{const{t:o}=ve(),{containerRef:i,error:d,status:f}=BE(a),m=WE[f];return u.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden",children:[u.jsx("p",{className:"sr-only",children:m?o(m):f}),d?u.jsx("p",{role:"alert",className:"mono shrink-0 break-words px-3 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 12%, transparent)",borderBottom:"1px solid color-mix(in oklab, var(--status-red) 30%, transparent)",color:"var(--status-red)"},children:d}):null,u.jsx("div",{"data-testid":`terminal-${a}`,ref:i,className:"bg-crust h-full min-h-0 w-full min-w-0 flex-1 overflow-hidden"})]})},VE=3e3,ry=(a,s)=>{const o=new Set(a.map(d=>d.run_id)),i=new Set(a.map(d=>d.agent_id));return[...a,...s.filter(d=>!o.has(d.run_id)&&!i.has(d.agent_id))]},KE=(a,s)=>{const[o,i]=y.useState({}),d=y.useRef(new Map);y.useEffect(()=>()=>{for(const h of d.current.values())window.clearTimeout(h);d.current.clear()},[]);const f=y.useCallback((h,v)=>{i(b=>({...b,[h]:(b[h]??[]).filter(w=>w.agent_id!==v)}))},[]),m=y.useCallback(({agentId:h,agentName:v,runId:b,status:w="starting",workspaceId:k})=>{const E={agent_id:h,agent_name:v,run_id:b,status:w};i(R=>{const _=(R[k]??[]).filter(q=>q.run_id!==E.run_id&&q.agent_id!==E.agent_id);return{...R,[k]:[..._,E]}});const S=d.current.get(b);S&&window.clearTimeout(S);const j=window.setTimeout(()=>{i(R=>({...R,[k]:(R[k]??[]).filter(_=>_.run_id!==b)})),d.current.delete(b)},VE);d.current.set(b,j)},[]),g=y.useMemo(()=>ry(s,a?o[a]??[]:[]),[s,o,a]);return{forgetOptimisticAgent:f,optimisticRunsByWorkspaceId:o,recordOptimisticRun:m,terminalRuns:g}},QE=500,ZE=({hidden:a=!1,optimisticRuns:s=[],workspaceId:o})=>{const{t:i}=ve(),[d,f]=y.useState([]),m=ry(d,s);return y.useEffect(()=>{let g=!1;const h=()=>{Xv(o).then(b=>{g||f(b)}).catch(b=>{g||f([]),console.error("[hive] swallowed:terminalPanels.listRuns",b)})};h();const v=window.setInterval(h,QE);return()=>{g=!0,window.clearInterval(v)}},[o]),u.jsx("section",{hidden:a,"aria-hidden":a||void 0,"aria-label":i("terminalPanels.aria"),children:m.map(g=>u.jsx(GE,{runId:g.run_id,title:`${g.agent_name} (${g.status})`},g.run_id))})},$E=({activeId:a,activeWorkspace:s,bootstrapError:o,demoMode:i,onDeleteWorkspace:d,onExitDemo:f,onRequestAddWorkspace:m,onTryDemo:g,optimisticRunsByWorkspaceId:h,orchestratorAutostartErrors:v,orchestratorAutostartRunIds:b,recordOrchestratorResult:w,terminalRuns:k,workerActions:E,workers:S})=>i?u.jsx(ZS,{onExit:f}):u.jsxs(u.Fragment,{children:[a?u.jsx(ZE,{optimisticRuns:h[a]??[],workspaceId:a},`terminal-${a}`):null,u.jsx(DE,{onCreateWorker:E.createWorker,onDeleteWorker:E.deleteWorker,onDeleteWorkspace:d,onStartWorker:E.startWorker,onOrchestratorResult:w,onRequestAddWorkspace:m,onTryDemo:g,welcomeDisabledReason:o??void 0,orchestratorAutostartError:a?v[a]??null:null,orchestratorAutostartRunId:a?b[a]??null:null,terminalRuns:k,workers:S,workspace:s})]}),JE=()=>{const[a,s]=y.useState(!1);return{demoMode:a,enableDemo:()=>s(!0),exitDemo:()=>s(!1)}},FE=a=>{const{demoMode:s,workspaces:o,activeWorkspaceId:i,workersByWorkspaceId:d}=a,f=s?[ii]:o,m=s?{[ii.id]:ny}:d,g=s?ii.id:i,h=s?ii:o?.find(b=>b.id===i);return{effectiveActiveWorkspaceId:g,effectiveWorkspaces:f,effectiveWorkersByWorkspaceId:m,effectiveActiveWorkspace:h,pollWorkspaceId:s?null:i}},PE=[{accent:"var(--status-green)",descriptionKey:"notifications.sound.soft.description",labelKey:"notifications.sound.soft.label",length:"short",value:"soft"},{accent:"var(--status-blue)",descriptionKey:"notifications.sound.ping.description",labelKey:"notifications.sound.ping.label",length:"short",value:"ping"},{accent:"var(--status-gold)",descriptionKey:"notifications.sound.chime.description",labelKey:"notifications.sound.chime.label",length:"short",value:"chime"},{accent:"var(--accent)",descriptionKey:"notifications.sound.cascade.description",labelKey:"notifications.sound.cascade.label",length:"long",value:"cascade"},{accent:"var(--status-orange)",descriptionKey:"notifications.sound.beacon.description",labelKey:"notifications.sound.beacon.label",length:"long",value:"beacon"},{accent:"var(--status-purple)",descriptionKey:"notifications.sound.resolve.description",labelKey:"notifications.sound.resolve.label",length:"long",value:"resolve"},{accent:"var(--text-tertiary)",descriptionKey:"notifications.sound.off.description",labelKey:"notifications.sound.off.label",length:"silent",value:"off"}],IE=[{descriptionKey:"notifications.detail.brief.description",labelKey:"notifications.detail.brief.label",value:"brief"},{descriptionKey:"notifications.detail.detailed.description",labelKey:"notifications.detail.detailed.label",value:"detailed"}],ej=()=>{const{t:a}=ve(),[s,o]=y.useState(!1),i=y.useRef(null),d=y.useRef(null),{notify:f,previewSound:m,requestDesktopNotifications:g,settings:h,updateSettings:v}=Jv(),b=typeof window<"u"&&!("Notification"in window),w=y.useMemo(()=>PE.map(S=>({...S,description:a(S.descriptionKey),label:a(S.labelKey)})),[a]),k=y.useMemo(()=>IE.map(S=>({...S,description:a(S.descriptionKey),label:a(S.labelKey)})),[a]),E=S=>{if(!S){v({desktop:!1});return}g()};return y.useEffect(()=>{if(!s)return;const S=R=>{R.key==="Escape"&&(o(!1),d.current?.focus())},j=R=>{const _=i.current;_&&!_.contains(R.target)&&o(!1)};return document.addEventListener("keydown",S),document.addEventListener("pointerdown",j),()=>{document.removeEventListener("keydown",S),document.removeEventListener("pointerdown",j)}},[s]),u.jsxs("div",{ref:i,className:"relative",children:[u.jsx(Je,{label:a("notifications.settings.tooltip"),children:u.jsx("button",{ref:d,type:"button","aria-expanded":s,"aria-haspopup":"dialog","aria-label":a("notifications.settings.aria"),className:"flex h-7 w-7 cursor-pointer items-center justify-center rounded text-sec hover:bg-3 hover:text-pri","data-testid":"topbar-settings",onClick:()=>o(S=>!S),children:u.jsx(wh,{size:14,"aria-hidden":!0})})}),s?u.jsxs("div",{role:"dialog","aria-label":a("notifications.settings.aria"),className:"elev-2 absolute top-8 right-0 z-50 w-[380px] rounded border p-3",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},"data-testid":"notification-settings",children:[u.jsxs("div",{className:"mb-3 flex items-start gap-2",children:[u.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded bg-3 text-sec",children:u.jsx(wh,{size:16,"aria-hidden":!0})}),u.jsxs("div",{className:"min-w-0",children:[u.jsx("div",{className:"text-sm font-semibold text-pri",children:a("notifications.settings.heading")}),u.jsx("div",{className:"text-ter text-xs",children:a("notifications.settings.subtitle")})]})]}),u.jsxs("section",{className:"mb-3",children:[u.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-ter text-xs uppercase tracking-wider",children:[u.jsx(Sh,{size:12,"aria-hidden":!0}),a("notifications.sound.sectionLabel")]}),u.jsx("div",{role:"radiogroup","aria-label":a("notifications.sound.sectionLabel"),className:"grid grid-cols-2 gap-2",children:w.map(S=>u.jsxs("div",{className:"relative min-h-[78px] rounded border transition-colors",style:{background:h.sound===S.value?`color-mix(in oklab, ${S.accent} 10%, var(--bg-2))`:"var(--bg-2)",borderColor:h.sound===S.value?`color-mix(in oklab, ${S.accent} 54%, var(--border-bright))`:"var(--border)"},children:[u.jsxs("label",{className:"block h-full w-full cursor-pointer rounded px-3 py-2 pr-10 text-left transition-colors hover:bg-3 focus-within:outline-none focus-within:ring-2 focus-within:ring-[var(--ring-focus)]",children:[u.jsx("input",{type:"radio",name:"notification-sound",value:S.value,checked:h.sound===S.value,className:"sr-only",onChange:()=>v({sound:S.value})}),u.jsxs("span",{className:"mb-1 flex items-center gap-2",children:[u.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded",style:{background:`color-mix(in oklab, ${S.accent} 16%, transparent)`,color:S.accent},children:S.value==="off"?u.jsx(e1,{size:12,"aria-hidden":!0}):u.jsx(Sh,{size:12,"aria-hidden":!0})}),u.jsx("span",{className:"font-medium text-pri text-xs",children:S.label}),S.length==="long"?u.jsx("span",{className:"rounded border border-[var(--border-bright)] px-1.5 py-0.5 text-xs text-ter uppercase",children:a("notifications.sound.longerBadge")}):null,h.sound===S.value?u.jsx(Ds,{size:12,className:"ml-auto text-pri","aria-hidden":!0}):null]}),u.jsx("span",{className:"block text-ter text-xs",children:S.description})]}),S.value!=="off"?u.jsx("button",{type:"button","aria-label":a("notifications.sound.previewAria",{label:S.label}),className:"absolute right-2 bottom-2 flex h-6 w-6 items-center justify-center rounded border text-sec transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border-bright)"},onClick:()=>m(S.value),children:u.jsx(ji,{size:12,"aria-hidden":!0})}):null]},S.value))})]}),u.jsxs("section",{className:"mb-3",children:[u.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-ter text-xs uppercase tracking-wider",children:[u.jsx(T0,{size:12,"aria-hidden":!0}),a("notifications.detail.sectionLabel")]}),u.jsx("div",{role:"radiogroup","aria-label":a("notifications.detail.sectionLabel"),className:"grid grid-cols-2 rounded border p-1",style:{background:"var(--bg-1)",borderColor:"var(--border)"},children:k.map(S=>u.jsxs("label",{className:"cursor-pointer rounded px-3 py-2 text-left transition-colors hover:bg-3 focus-within:outline-none focus-within:ring-2 focus-within:ring-[var(--ring-focus)]",style:{background:h.detail===S.value?"var(--bg-3)":"transparent",color:h.detail===S.value?"var(--text-primary)":"var(--text-secondary)"},children:[u.jsx("input",{type:"radio",name:"notification-detail",value:S.value,checked:h.detail===S.value,className:"sr-only",onChange:()=>v({detail:S.value})}),u.jsx("span",{className:"block font-medium text-xs",children:S.label}),u.jsx("span",{className:"block text-ter text-xs",children:S.description})]},S.value))})]}),u.jsxs("label",{className:"mb-3 flex items-start gap-2 rounded border p-2 text-sec text-xs",children:[u.jsx("input",{type:"checkbox","aria-label":a("notifications.desktop.aria"),checked:h.desktop,disabled:b,className:"mt-0.5",onChange:S=>E(S.currentTarget.checked)}),u.jsxs("span",{children:[u.jsx("span",{className:"block font-medium text-pri",children:a("notifications.desktop.label")}),u.jsx("span",{className:"text-ter",children:a(b?"notifications.desktop.unsupported":"notifications.desktop.helper")})]})]}),u.jsxs("div",{className:"flex justify-end gap-2 border-t pt-3",style:{borderColor:"var(--border)"},children:[u.jsx("button",{type:"button",className:"icon-btn",onClick:()=>o(!1),children:a("common.close")}),u.jsx("button",{type:"button",className:"icon-btn icon-btn--primary",onClick:()=>f({brief:a("notifications.test.brief"),detail:a("notifications.test.detail"),kind:"success",title:a("notifications.test.title")}),children:a("notifications.test.button")})]})]}):null]})},tj=a=>{const[s,o]=y.useState(null);return y.useEffect(()=>{if(a)return;let i=!0;return Z2().then(d=>{i&&o(d)}).catch(()=>{i&&o(null)}),()=>{i=!1}},[a]),a??s},nj="1.1.4",aj={version:nj},lj=aj.version,sj=()=>{const{language:a,setLanguage:s,t:o}=ve(),i=a==="en"?"zh":"en",d=o(i==="en"?"language.switchToEn":"language.switchToZh"),f=o(a==="en"?"language.currentEn":"language.currentZh");return u.jsx(Je,{label:d,children:u.jsx("span",{children:u.jsxs("button",{type:"button","aria-label":d,onClick:()=>s(i),className:"flex h-7 items-center gap-1 rounded border px-2 text-xs font-medium text-ter transition-colors hover:bg-3 hover:text-pri focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[u.jsx(R0,{size:13,"aria-hidden":!0}),u.jsx("span",{children:f})]})})})},rj=({hideActions:a=!1,version:s=lj,versionInfo:o})=>{const{t:i}=ve(),d=tj(o),f=d?.updateAvailable&&d.latestVersion!==s?d:null;return u.jsxs("header",{className:"flex h-11 shrink-0 items-center px-4",style:{background:"var(--bg-0)",borderBottom:"1px solid var(--border)"},children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("img",{src:"/logo.png",alt:"","aria-hidden":!0,className:"h-5 w-5 rounded-md","data-testid":"topbar-logo"}),u.jsx("span",{className:"font-semibold text-pri",children:"Hive"}),u.jsxs("span",{className:"text-ter text-xs tabular-nums",children:["v",s]}),f?u.jsxs("div",{className:"flex items-center gap-2 text-xs","data-testid":"topbar-update-badge",children:[u.jsx("span",{className:"rounded border px-2 py-0.5 font-medium",style:{background:"color-mix(in oklab, var(--accent) 10%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 30%, transparent)",color:"var(--accent)"},children:i("topbar.updateAvailable")}),u.jsxs("span",{className:"text-ter",children:["v",s," → v",f.latestVersion]}),u.jsx("code",{className:"mono text-ter",children:f.installHint})]}):null]}),u.jsx("div",{className:"flex-1"}),a?null:u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(sj,{}),u.jsx(ej,{})]})]})},iy="hive.workspace-sidebar.width",id=56,od=280,Su=256,dg=16,gi=a=>Math.min(od,Math.max(id,a)),ij=()=>{try{const a=localStorage.getItem(iy);if(!a)return Su;const s=Number.parseInt(a,10);return Number.isFinite(s)?gi(s):Su}catch{return Su}},oj=()=>{const[a,s]=y.useState(ij),[o,i]=y.useState(!1);y.useEffect(()=>{try{localStorage.setItem(iy,String(Math.round(a)))}catch{}},[a]);const d=y.useCallback(m=>{m.preventDefault();const g=m.clientX,h=a;i(!0);const v=document.body.style.cursor,b=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const w=E=>{s(gi(h+E.clientX-g))},k=()=>{i(!1),document.body.style.cursor=v,document.body.style.userSelect=b,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",k)},[a]),f=y.useCallback(m=>{m.key==="ArrowLeft"?(m.preventDefault(),s(g=>gi(g-dg))):m.key==="ArrowRight"?(m.preventDefault(),s(g=>gi(g+dg))):m.key==="Home"?(m.preventDefault(),s(id)):m.key==="End"&&(m.preventDefault(),s(od))},[]);return{beginResize:d,onResizeKeyDown:f,resizing:o,width:a}},cj=({children:a,hideTopbarActions:s=!1,sidebar:o})=>{const{t:i}=ve(),d=oj();return u.jsxs("div",{className:"flex h-screen w-full flex-col overflow-hidden",style:{background:"var(--bg-0)",color:"var(--text-primary)"},children:[u.jsx(rj,{hideActions:s}),u.jsxs("div",{className:"flex min-h-0 flex-1",children:[u.jsxs("aside",{"aria-label":i("layout.sidebarAria"),className:"workspace-sidebar relative flex shrink-0 flex-col","data-resizing":d.resizing?"true":"false",style:{background:"var(--bg-0)",boxShadow:"inset -1px 0 0 var(--border)",width:`${d.width}px`},children:[o,u.jsx("hr",{"aria-label":i("layout.sidebarResizeAria"),"aria-orientation":"vertical","aria-valuemin":id,"aria-valuemax":od,"aria-valuenow":Math.round(d.width),tabIndex:0,className:"workspace-sidebar-resizer","data-resizing":d.resizing?"true":"false",onMouseDown:d.beginResize,onKeyDown:d.onResizeKeyDown})]}),u.jsx("section",{className:"relative flex min-w-0 flex-1",children:a})]})]})},fg=[{token:"var(--accent)",label:"accent"},{token:"var(--status-blue)",label:"blue"},{token:"var(--status-purple)",label:"purple"},{token:"var(--status-orange)",label:"orange"},{token:"var(--status-green)",label:"green"},{token:"var(--status-gold)",label:"gold"}],uj=a=>{let s=0;for(let i=0;i<a.length;i+=1)s=s*31+a.charCodeAt(i)|0;const o=Math.abs(s)%fg.length;return fg[o]},dj=a=>{const s=a.trim();if(s.length===0)return"?";const o=s.codePointAt(0);return o===void 0?"?":String.fromCodePoint(o).toUpperCase()},mg=({workspaceId:a,name:s,isActive:o,working:i,workingCount:d,size:f=32})=>{const{token:m,label:g}=uj(a),h=dj(s),v=d&&d>1?d:null;return u.jsx(sd,{size:f,color:m,fontRatio:.45,ringColor:o?m:null,testId:"workspace-avatar",data:{"workspace-id":a,active:o?"true":void 0,"color-label":g},decoration:v!==null?u.jsx("span",{className:"absolute flex h-[16px] min-w-[16px] items-center justify-center rounded-full px-1 font-medium text-xs tabular-nums leading-none",style:{right:"-4px",bottom:"-4px",background:"var(--status-green)",color:"#0a1f0a",boxShadow:"0 0 0 2px var(--bg-1)"},"data-testid":"workspace-avatar-working-count","aria-hidden":!0,children:v>9?"9+":v}):i?u.jsx("span",{className:"status-dot status-dot--working absolute",style:{right:"-2px",bottom:"-2px",boxShadow:"0 0 0 2px var(--bg-1)"},"aria-hidden":!0}):null,children:h})},fj=a=>!!a?.some(s=>s.status==="working"),mj=a=>a?.filter(s=>s.status==="working").length??0,pj=(a,s)=>{if(!a||a.length===0)return s("sidebar.noMembers");const o=a.filter(i=>i.status==="working").length;return o>0?s("sidebar.workingCount",{working:o,total:a.length}):s("sidebar.teamMemberCount",{count:a.length})},oy="hive.sidebar.githubDismissed",hj=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(oy)==="1"}catch{return!1}},gj=({activeWorkspaceId:a,createDisabledReason:s,onCreateClick:o,onDeleteWorkspace:i,onSelectWorkspace:d,workersByWorkspaceId:f,workspaces:m})=>{const{t:g}=ve(),[h,v]=y.useState(null),[b,w]=y.useState(!1),[k,E]=y.useState(hj),S=Ol(),j=()=>{E(!0);try{window.localStorage.setItem(oy,"1")}catch{}},R=!!s,_=D=>{v(D)},q=()=>{if(!h||b)return;const D=h;w(!0),Promise.resolve(i(D)).then(()=>{S.show({kind:"success",message:g("sidebar.removed",{name:D.name})})}).catch(Q=>{const Z=Q instanceof Error?Q.message:String(Q);S.show({kind:"error",message:g("sidebar.deleteFailed",{message:Z})})}).finally(()=>{w(!1),v(null)})},Y=u.jsx(Iv,{open:h!==null,onOpenChange:D=>{!D&&!b&&v(null)},title:h?g("sidebar.deleteConfirm",{name:h.name}):g("sidebar.deleteLabel"),description:h?g("sidebar.deleteDescription",{path:h.path,summary:pj(f[h.id],g)}):"",confirmLabel:g(b?"sidebar.deleting":"sidebar.deleteLabel"),confirmKind:"danger",onConfirm:q});return u.jsxs("nav",{"aria-label":"Workspaces",className:"flex h-full flex-col",children:[u.jsx("div",{className:"flex items-center justify-between gap-2 px-3 pt-3 pb-2",style:{boxShadow:"inset 0 -1px 0 var(--border)"},children:u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{className:"ws-sidebar-title__text text-xs font-medium text-ter","data-testid":"workspace-sidebar-title",children:g("sidebar.workspaces")}),m&&m.length>0?u.jsx("span",{className:"ws-sidebar-count mono rounded bg-2 px-1.5 py-0.5 text-xs text-ter",children:m.length}):null]})}),m===null?u.jsx("p",{className:"px-3 py-2 text-xs text-ter",children:g("common.loading")}):m.length===0?u.jsx("div",{className:"flex-1 px-2 py-4",children:u.jsx(Tl,{title:g("sidebar.noWorkspaces"),description:s??g("sidebar.noWorkspacesDesc"),icon:u.jsx(Sg,{size:20}),action:u.jsxs("button",{type:"button",onClick:R?void 0:o,disabled:R,"aria-label":g("sidebar.newWorkspace"),title:s??g("sidebar.newWorkspace"),className:"icon-btn icon-btn--primary mt-1 flex items-center gap-1.5 px-4 py-2 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50",children:[u.jsx(As,{size:14,"aria-hidden":!0}),g("sidebar.newWorkspace")]})})}):u.jsxs("ul",{className:"flex-1 scroll-y pb-2",children:[m.map(D=>{const Q=f[D.id],Z=D.id===a,M=fj(Q),$=mj(Q);return u.jsxs("li",{className:"group relative",children:[u.jsx(Je,{side:"right",label:u.jsxs("span",{className:"flex flex-col gap-0.5",children:[u.jsx("span",{className:"font-medium",children:D.name}),u.jsx("span",{className:"mono text-ter",children:D.path})]}),children:u.jsxs("button",{type:"button","aria-label":D.name,"aria-current":Z?"true":void 0,"data-workspace-path":D.path,onClick:()=>d(D.id),className:`ws-row flex w-full items-center gap-2.5 py-1.5 pr-7 pl-2 text-left${Z?" active":""}`,children:[u.jsx(mg,{workspaceId:D.id,name:D.name,isActive:Z,working:M,workingCount:$,size:22}),u.jsx("span",{className:`min-w-0 flex-1 truncate text-sm ${Z?"font-medium text-pri":"text-pri"}`,children:D.name})]})}),u.jsx(Je,{side:"right",label:u.jsxs("span",{className:"flex flex-col gap-0.5",children:[u.jsx("span",{className:"font-medium",children:D.name}),u.jsx("span",{className:"mono text-ter",children:D.path})]}),children:u.jsx("button",{type:"button","aria-label":D.name,"aria-current":Z?"true":void 0,onClick:()=>d(D.id),className:"ws-avatar-cell hidden w-full justify-center py-2","data-testid":"ws-avatar-cell",children:u.jsx(mg,{workspaceId:D.id,name:D.name,isActive:Z,working:M,workingCount:$})})}),u.jsx(Je,{label:g("sidebar.deleteAria",{name:D.name}),children:u.jsx("button",{type:"button","aria-label":g("sidebar.deleteAria",{name:D.name}),onClick:()=>_(D),className:"ws-row-delete absolute top-2 right-2 flex h-6 w-6 items-center justify-center rounded text-ter opacity-0 transition-colors hover:text-status-red focus:opacity-100 group-hover:opacity-100",children:u.jsx(qu,{size:14,"aria-hidden":!0})})})]},D.id)}),u.jsx("li",{children:u.jsx(Je,{label:s??g("sidebar.newWorkspace"),children:u.jsxs("button",{type:"button",onClick:R?void 0:o,disabled:R,"aria-label":g("sidebar.newWorkspace"),title:s??void 0,className:"ws-add ws-add--inline mx-3 mt-1 flex items-center justify-center gap-1.5 rounded border border-dashed px-3 py-2 text-xs font-medium text-sec transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:"var(--border-bright)"},children:[u.jsx(As,{size:14,"aria-hidden":!0}),u.jsx("span",{className:"ws-add__label",children:g("sidebar.newWorkspace")})]})})})]}),k?null:u.jsxs("div",{className:"ws-sidebar-footer group relative",style:{boxShadow:"inset 0 1px 0 var(--border)"},children:[u.jsxs("a",{href:"https://github.com/tt-a1i/hive",target:"_blank",rel:"noopener noreferrer","aria-label":g("sidebar.openRepository"),title:g("sidebar.openRepository"),className:"ws-sidebar-footer__link flex items-center gap-2.5 px-3 py-3 text-sm text-ter transition-colors hover:text-pri",children:[u.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:u.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"})}),u.jsx("span",{className:"ws-sidebar-footer__label",children:"GitHub"})]}),u.jsx("button",{type:"button","aria-label":g("sidebar.dismissRepository"),title:g("sidebar.dismissRepository"),onClick:j,className:"ws-sidebar-footer__dismiss absolute top-1.5 right-1.5 flex h-4 w-4 items-center justify-center rounded text-ter opacity-0 transition-opacity hover:bg-3 hover:text-pri focus:opacity-100 group-hover:opacity-100",children:u.jsx(El,{size:10,"aria-hidden":!0})})]}),Y]})},vj=(a,s,o)=>a===s||a===o,yj=(a,s)=>{const[o,i]=y.useState(""),[d,f]=y.useState(!1),[m,g]=y.useState(!1),[h,v]=y.useState(null),b=y.useRef(!1),w=y.useRef(""),k=y.useRef(""),E=y.useCallback((j,R)=>{if(!b.current){w.current=j,k.current=j,i(j),g(!1),v(null);return}vj(j,w.current,R)||(v(j),g(!0))},[]);y.useEffect(()=>{{i(""),f(!1),g(!1),v(null),b.current=!1,w.current="",k.current="";return}},[a]),y.useEffect(()=>{},[E,a]);const S=async(j,R)=>{};return{content:o,hasConflict:m,loaded:d,onChange:j=>{b.current=j!==w.current,k.current=j,i(j)},onKeepLocal:()=>{g(!1),v(null)},onReload:()=>{const j=h??w.current;w.current=j,b.current=!1,k.current=j,i(j),g(!1),v(null)},onSave:async()=>{},toggleTaskAtLine:async j=>{},appendTask:async j=>{j.trim()},appendSubtask:async(j,R)=>{R.trim()&&await S()},updateTaskText:async(j,R)=>{R.trim()&&await S()},deleteTask:async j=>{await S()}}},bj=a=>{if(!a||!(a instanceof HTMLElement))return!1;const s=a.tagName.toLowerCase();return!!(s==="input"||s==="textarea"||s==="select"||a.isContentEditable||a.closest(".xterm"))},xj=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),wj=a=>xj?a.metaKey:a.ctrlKey,kj=a=>{y.useEffect(()=>{const s=o=>{if(bj(o.target))return;const i=o.key.toLowerCase();for(const d of a){if(i!==d.key||(d.mod??!1)!==wj(o)||(d.shift??!1)!==o.shiftKey)continue;d.handler(o)!==!1&&o.preventDefault();return}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[a])},Sj=({bootstrapError:a,onSelectWorkspace:s,onTriggerAddDialog:o,workspaces:i})=>{const d=y.useMemo(()=>{const f=(i??[]).slice(0,9).map((m,g)=>({key:String(g+1),mod:!0,handler:()=>s(m.id)}));return[{key:"n",mod:!0,shift:!0,handler:()=>{a||o()}},...f]},[a,s,o,i]);kj(d)},Ej=(a,s)=>s&&a.some(o=>o.id===s)?s:a[0]?.id??null,jj=(a,s)=>{if(a===null)return s;const o=new Map(a.map(i=>[i.id,i]));for(const i of s)o.set(i.id,i);return Array.from(o.values())},Nj=(a,s,o)=>{y.useEffect(()=>{let i=!1;return qv().then(async()=>{const[d,f]=await Promise.all([Q2(),F2().catch(()=>null)]);return{items:d,persistedId:f}}).then(({items:d,persistedId:f})=>{i||a(m=>{const g=jj(m,d),h=Ej(g,f);return s(h),f!==h&&Yv(h).catch(v=>{console.error("[hive] swallowed:initSession.save",v)}),g})}).catch(d=>{i||(s(null),o&&o("Could not reach Hive runtime. Refresh once the runtime is back up.")),console.error("[hive] swallowed:initSession.bootstrap",d)}),()=>{i=!0}},[s,a,o])},Cj=()=>{const a=y.useRef(null);return y.useCallback(s=>{if(typeof document>"u")return;const o=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(s):s.replace(/"/g,'\\"'),i=document.querySelector(`[data-worker-name="${o}"]`);i&&(i.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),i.classList.add("worker-card-shell--highlight"),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i.classList.remove("worker-card-shell--highlight"),a.current=null},1e3))},[])},Tj=({onWorkspaceCreated:a,onError:s})=>{const[o,i]=y.useState({}),[d,f]=y.useState({}),m=y.useCallback((h,v)=>{i(b=>({...b,[h]:v.ok?null:v.error})),f(b=>({...b,[h]:v.ok?v.run_id:null}))},[]),g=y.useCallback(async h=>{try{const v=await $2({name:h.name,path:h.path,autostart_orchestrator:!0,command_preset_id:h.commandPresetId,startup_command:h.startupCommand??null});return m(v.id,v.orchestrator_start),a({id:v.id,name:v.name,path:v.path}),v}catch(v){const b=v instanceof Error?v.message:"Failed to create workspace";throw s?.(b),v}},[a,s,m]);return{orchestratorAutostartErrors:o,orchestratorAutostartRunIds:d,recordOrchestratorResult:m,createNewWorkspace:g}},Aj=(a,s)=>{const o=a.findIndex(d=>d.id===s),i=a.filter(d=>d.id!==s);return o<0?i[0]?.id??null:i[Math.min(o,i.length-1)]?.id??null},Rj=({activeWorkspaceId:a,onActiveDeleted:s,selectWorkspace:o,setWorkersByWorkspaceId:i,setWorkspaces:d,workspaces:f})=>async m=>{const h=Aj(f??[],m.id);await J2(m.id),d(v=>v?.filter(b=>b.id!==m.id)??v),i(v=>{const b={...v};return delete b[m.id],b}),m.id===a&&(s(),o(h))},_j=()=>{const[a,s]=y.useState(null),o=y.useRef(Promise.resolve());return{activeWorkspaceId:a,selectWorkspace:d=>{s(d),o.current=o.current.catch(Ca("selectWorkspace.prevQueue")).then(()=>Yv(d)).catch(Ca("selectWorkspace.save"))},setActiveWorkspaceId:s}},Oj=500,Dj=5e3,zj=a=>Math.min(Oj*2**a,Dj),Mj=a=>{const s=a.join("\0"),[o,i]=y.useState({});return y.useEffect(()=>{if(!s){i({});return}let d=!1,f=!1,m=0,g;const h=s.split("\0"),v=()=>{d||(g=window.setTimeout(b,zj(m)))},b=()=>{f||(f=!0,Promise.all(h.map(async w=>{try{return[w,await P2(w)]}catch(k){return console.error("[hive] swallowed:workspaceWorkers.list",k),null}})).then(w=>{d||(m=w.some(Boolean)?0:Math.min(m+1,4),i(k=>{const E={};for(const S of h)E[S]=k[S]??[];for(const S of w)S&&(E[S[0]]=S[1]);return E}))}).finally(()=>{f=!1,v()}))};return b(),()=>{d=!0,g!==void 0&&window.clearTimeout(g)}},[s]),[o,i]},pg="hive.first-run-seen",Lj=()=>{const[a,s]=y.useState(()=>{try{return window.localStorage.getItem(pg)==="1"}catch{return!0}}),o=y.useCallback(()=>{try{window.localStorage.setItem(pg,"1")}catch{}s(!0)},[]);return{seen:a,markSeen:o}},Hj=a=>{const{seen:s,markSeen:o}=Lj(),[i,d]=y.useState(!1);y.useEffect(()=>{!s&&a!==null&&a.length===0&&d(!0)},[s,a]);const f=y.useCallback((m=!0)=>{m&&o(),d(!1)},[o]);return{wizardOpen:i,closeWizard:f}},Uj=(a,s)=>a.findIndex(i=>i.id===s.id)===-1?[...a,s]:a.map(i=>i.id===s.id?s:i),Bj=({activeWorkspaceId:a,onWorkerDeleted:s,onWorkerRunStarted:o,setWorkersByWorkspaceId:i})=>{const d=y.useCallback(async({commandPresetId:h,name:v,role:b,roleDescription:w,startupCommand:k})=>{if(!a)return{error:"No active workspace",runId:null};const E=k.trim(),S=await lS(a,{autostart:!0,command_preset_id:h||null,description:w.trim(),name:v,role:b,startup_command:E||null});return i(j=>({...j,[a]:Uj(j[a]??[],S.worker)})),S.agentStart.ok&&S.agentStart.runId&&o?.({agentId:S.worker.id,agentName:S.worker.name,runId:S.agentStart.runId,workspaceId:a}),{error:S.agentStart.ok?null:S.agentStart.error,runId:S.agentStart.ok?S.agentStart.runId:null}},[a,o,i]),f=y.useCallback(async h=>{if(!a)throw new Error("No active workspace");await sS(a,h),i(v=>({...v,[a]:(v[a]??[]).filter(b=>b.id!==h)})),s?.(a,h)},[a,s,i]),m=y.useCallback(async h=>{if(!a)return{error:"No active workspace",runId:null};try{const v=await zu(a,h);return o?.({agentId:h,agentName:h,runId:v.runId,workspaceId:a}),{error:null,runId:v.runId}}catch(v){return{error:v instanceof Error?v.message:String(v),runId:null}}},[a,o]),g=y.useCallback(async h=>{try{return await Mu(h),{error:null}}catch(v){return{error:v instanceof Error?v.message:String(v)}}},[]);return{createWorker:d,deleteWorker:f,startWorker:m,stopWorkerRun:g}},Wj=!1,qj=()=>{const[a,s]=y.useState(null),{activeWorkspaceId:o,selectWorkspace:i,setActiveWorkspaceId:d}=_j(),{demoMode:f,enableDemo:m,exitDemo:g}=JE(),h=f||!a?[]:a.map(({id:z})=>z),[v,b]=Mj(h),[w,k]=y.useState(0),[E,S]=y.useState(!1),j=Ol(),{wizardOpen:R,closeWizard:_}=Hj(a),q=y.useCallback(()=>k(z=>z+1),[]),[Y,D]=y.useState(null),Q=y.useCallback(z=>{D(z),j.show({kind:"error",message:z})},[j]);Nj(s,d,Q);const Z=Tj({onWorkspaceCreated:z=>{s(F=>F===null?[z]:[...F,z]),i(z.id),b(F=>({...F,[z.id]:[]}))},onError:z=>j.show({kind:"error",message:z})}),$=FE({demoMode:f,workspaces:a,activeWorkspaceId:o,workersByWorkspaceId:v}),J=$.effectiveActiveWorkspace?.id,ae=J?$.effectiveWorkersByWorkspaceId[J]??[]:[],I=KE($.pollWorkspaceId,DS($.pollWorkspaceId)),se=yj(null),oe=Wj,fe=Bj({activeWorkspaceId:o,onWorkerDeleted:I.forgetOptimisticAgent,onWorkerRunStarted:I.recordOptimisticRun,setWorkersByWorkspaceId:b}),A=Rj({activeWorkspaceId:o,onActiveDeleted:()=>S(!1),selectWorkspace:i,setWorkersByWorkspaceId:b,setWorkspaces:s,workspaces:a});Sj({bootstrapError:Y,onSelectWorkspace:i,onTriggerAddDialog:q,workspaces:$.effectiveWorkspaces});const L=Cj();return u.jsxs(cj,{hideTopbarActions:!$.effectiveActiveWorkspace,sidebar:u.jsx(gj,{activeWorkspaceId:$.effectiveActiveWorkspaceId,createDisabledReason:Y??void 0,onCreateClick:q,onDeleteWorkspace:A,onSelectWorkspace:i,workersByWorkspaceId:$.effectiveWorkersByWorkspaceId,workspaces:$.effectiveWorkspaces}),children:[u.jsx($E,{activeId:J,activeWorkspace:$.effectiveActiveWorkspace,bootstrapError:Y,demoMode:f,onDeleteWorkspace:A,onExitDemo:g,onRequestAddWorkspace:q,onTryDemo:m,optimisticRunsByWorkspaceId:I.optimisticRunsByWorkspaceId,orchestratorAutostartErrors:Z.orchestratorAutostartErrors,orchestratorAutostartRunIds:Z.orchestratorAutostartRunIds,recordOrchestratorResult:Z.recordOrchestratorResult,terminalRuns:I.terminalRuns,workerActions:fe,workers:ae}),u.jsx(bS,{addDialogTrigger:w,wizardOpen:R,onAddWorkspace:q,onCloseTaskGraph:()=>S(!1),onCloseWizard:_,onCreateWorkspace:Z.createNewWorkspace,onTryDemo:m,taskGraphOpen:oe,tasksFile:se,workspacePath:$.effectiveActiveWorkspace?.path??null,workers:ae,onSelectOwner:L})]})},Yj=()=>u.jsx(_S,{children:u.jsx(qj,{})}),cy=document.getElementById("root");if(!cy)throw new Error("Root element not found");Gx.createRoot(cy).render(u.jsx(y.StrictMode,{children:u.jsx(Yj,{})}));
@@ -19,7 +19,7 @@
19
19
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap"
20
20
  rel="stylesheet"
21
21
  />
22
- <script type="module" crossorigin src="/assets/index-B048NECd.js"></script>
22
+ <script type="module" crossorigin src="/assets/index-CWfszf16.js"></script>
23
23
  <link rel="stylesheet" crossorigin href="/assets/index-DUlPKsEn.css">
24
24
  </head>
25
25
  <body>