@tt-a1i/hive 0.6.0-alpha.7 → 0.6.0-alpha.8

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,23 @@
2
2
 
3
3
  All notable user-facing changes will be documented in this file.
4
4
 
5
+ ## 0.6.0-alpha.8 - 2026-05-16
6
+
7
+ License switch — no code changes from alpha.7.
8
+
9
+ - Starting from this version, Hive is licensed under the **Business Source
10
+ License 1.1** (BSL), not Apache-2.0. BSL allows personal use, internal
11
+ organizational deployment, embedding in non-competitive products, and
12
+ non-commercial forks. It only prohibits offering Hive as a hosted or
13
+ embedded multi-agent orchestration service to third parties on a paid
14
+ basis. On **2030-05-16** the license automatically converts to Apache-2.0.
15
+ - All versions at or before `0.6.0-alpha.7` remain permanently licensed
16
+ under Apache-2.0 — that grant is irrevocable and is not affected by this
17
+ switch.
18
+ - See [`LICENSE.BSL`](./LICENSE.BSL) for the full BSL text including the
19
+ Additional Use Grant, and [`LICENSE`](./LICENSE) for the historical
20
+ Apache-2.0 grant.
21
+
5
22
  ## 0.6.0-alpha.7 - 2026-05-16
6
23
 
7
24
  Worker identity, language, and workflow polish.
package/LICENSE CHANGED
@@ -1,3 +1,10 @@
1
+ This Apache License 2.0 applies only to versions of Hive at or before
2
+ 0.6.0-alpha.7. Starting from 0.6.0-alpha.8, Hive is licensed under the
3
+ Business Source License 1.1 (see LICENSE.BSL). The BSL automatically
4
+ converts to Apache-2.0 on 2030-05-16.
5
+
6
+ ---
7
+
1
8
  Apache License
2
9
  Version 2.0, January 2004
3
10
  https://www.apache.org/licenses/
@@ -199,4 +206,3 @@
199
206
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
207
  See the License for the specific language governing permissions and
201
208
  limitations under the License.
202
-
package/LICENSE.BSL ADDED
@@ -0,0 +1,101 @@
1
+ Business Source License 1.1
2
+
3
+ Licensor: Shaokun Tu (tt-a1i)
4
+ Licensed Work: Hive 0.6.0-alpha.8 and later
5
+ Change Date: 2030-05-16
6
+ Change License: Apache License, Version 2.0
7
+
8
+ Additional Use Grant:
9
+
10
+ You may make production use of the Licensed Work, provided Your use does not
11
+ include offering the Licensed Work to third parties on a hosted or embedded
12
+ basis in order to compete with Licensor's multi-CLI-agent orchestration
13
+ product.
14
+
15
+ For purposes of this license, a "competitive offering" is a Product that:
16
+ (a) is offered to third parties on a paid basis, including paid support
17
+ arrangements or any form of revenue-generating arrangement; and
18
+ (b) provides browser-accessible multi-CLI-agent collaboration
19
+ (orchestrator + worker agents running as PTY sessions communicating
20
+ via a team protocol), substantially overlapping with the core
21
+ capabilities of the Licensed Work.
22
+
23
+ Internal production use by Your organization, embedding the Licensed Work
24
+ into a non-competitive product, and non-commercial forks are not
25
+ "competitive offerings".
26
+
27
+ License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
28
+ "Business Source License" is a trademark of MariaDB plc.
29
+
30
+ Terms
31
+
32
+ The Licensor hereby grants you the right to copy, modify, create derivative
33
+ works, redistribute, and make non-production use of the Licensed Work. The
34
+ Licensor may make an Additional Use Grant, above, permitting limited
35
+ production use.
36
+
37
+ Effective on the Change Date, or the fourth anniversary of the first publicly
38
+ available distribution of a specific version of the Licensed Work under this
39
+ License, whichever comes first, the Licensor hereby grants you rights under
40
+ the terms of the Change License, and the rights granted in the paragraph
41
+ above terminate.
42
+
43
+ If your use of the Licensed Work does not comply with the requirements
44
+ currently in effect as described in this License, you must purchase a
45
+ commercial license from the Licensor, its affiliated entities, or authorized
46
+ resellers, or you must refrain from using the Licensed Work.
47
+
48
+ All copies of the original and modified Licensed Work, and derivative works
49
+ of the Licensed Work, are subject to this License. This License applies
50
+ separately for each version of the Licensed Work and the Change Date may
51
+ vary for each version of the Licensed Work released by Licensor.
52
+
53
+ You must conspicuously display this License on each original or modified copy
54
+ of the Licensed Work. If you receive the Licensed Work in original or
55
+ modified form from a third party, the terms and conditions set forth in this
56
+ License apply to your use of that work.
57
+
58
+ Any use of the Licensed Work in violation of this License will automatically
59
+ terminate your rights under this License for the current and all other
60
+ versions of the Licensed Work.
61
+
62
+ This License does not grant you any right in any trademark or logo of
63
+ Licensor or its affiliates (provided that you may use a trademark or logo of
64
+ Licensor as expressly required by this License).
65
+
66
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
67
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
68
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
69
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
70
+ TITLE.
71
+
72
+ MariaDB hereby grants you permission to use this License's text to license
73
+ your works, and to refer to it using the trademark "Business Source License",
74
+ as long as you comply with the Covenants of Licensor below.
75
+
76
+ Covenants of Licensor
77
+
78
+ In consideration of the right to use this License's text and the "Business
79
+ Source License" name and trademark, Licensor covenants to MariaDB, and to
80
+ all other recipients of the licensed work to be provided by Licensor:
81
+
82
+ To specify as the Change License the GPL Version 2.0 or any later version,
83
+ or a license that is compatible with GPL Version 2.0 or a later version,
84
+ where "compatible" means that software provided under the Change License can
85
+ be included in a program with software provided under GPL Version 2.0 or a
86
+ later version. Licensor may specify additional Change Licenses without
87
+ limitation.
88
+
89
+ To either: (a) specify an additional grant of rights to use that does not
90
+ impose any additional restriction on the right granted in this License, as
91
+ the Additional Use Grant; or (b) insert the text "None".
92
+
93
+ To specify a Change Date.
94
+
95
+ Not to modify this License in any other way.
96
+
97
+ Notice
98
+
99
+ The Business Source License (this document, or the "License") is not an Open
100
+ Source license. However, the Licensed Work will eventually be made available
101
+ under an Open Source License, as stated in this License.
package/README.en.md CHANGED
@@ -15,7 +15,7 @@ injects into each agent's shell, and shares a markdown task graph at
15
15
  [![ci](https://img.shields.io/github/actions/workflow/status/tt-a1i/hive/release.yml?branch=main&label=ci)](https://github.com/tt-a1i/hive/actions/workflows/release.yml)
16
16
  [![Website](https://img.shields.io/badge/website-hive--site.pages.dev-5a8a8a.svg)](https://hive-site.pages.dev)
17
17
  [![Node](https://img.shields.io/badge/node-%3E%3D22-3c873a.svg)](https://nodejs.org/)
18
- [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
18
+ [![License](https://img.shields.io/badge/license-BUSL--1.1-orange.svg)](./LICENSE.BSL)
19
19
  [![Platforms](https://img.shields.io/badge/platforms-macOS%20%C2%B7%20Linux%20%C2%B7%20Windows%20(best--effort)-lightgrey.svg)](#platform-support)
20
20
 
21
21
  🌐 **Website**: [hive-site.pages.dev/en/](https://hive-site.pages.dev/en/) · [中文](https://hive-site.pages.dev/)
@@ -269,4 +269,7 @@ while the core local orchestration model hardens.
269
269
 
270
270
  ## License
271
271
 
272
- Apache-2.0. See [LICENSE](LICENSE).
272
+ - **0.6.0-alpha.8 onward**: Business Source License 1.1 (see [LICENSE.BSL](LICENSE.BSL)). Automatically converts to Apache-2.0 on 2030-05-16.
273
+ - **0.6.0-alpha.7 and earlier**: Apache-2.0 (see [LICENSE](LICENSE)), permanent grant.
274
+
275
+ BSL permits personal use, internal deployment, embedding in non-competitive products, and non-commercial forks. **Only prohibits** offering Hive as a hosted multi-agent orchestration service to third parties. See the Additional Use Grant in [LICENSE.BSL](LICENSE.BSL) for the exact boundary.
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  [![ci](https://img.shields.io/github/actions/workflow/status/tt-a1i/hive/release.yml?branch=main&label=ci)](https://github.com/tt-a1i/hive/actions/workflows/release.yml)
11
11
  [![Website](https://img.shields.io/badge/website-hive--site.pages.dev-5a8a8a.svg)](https://hive-site.pages.dev)
12
12
  [![Node](https://img.shields.io/badge/node-%3E%3D22-3c873a.svg)](https://nodejs.org/)
13
- [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
13
+ [![License](https://img.shields.io/badge/license-BUSL--1.1-orange.svg)](./LICENSE.BSL)
14
14
  [![Platforms](https://img.shields.io/badge/platforms-macOS%20%C2%B7%20Linux%20%C2%B7%20Windows%20(best--effort)-lightgrey.svg)](#平台支持)
15
15
 
16
16
  🌐 **官网**:[hive-site.pages.dev](https://hive-site.pages.dev/)([English](https://hive-site.pages.dev/en/))
@@ -215,4 +215,7 @@ Hive 正处于 alpha public preview 阶段。在本机调度模型稳定下来
215
215
 
216
216
  ## License
217
217
 
218
- Apache-2.0。详见 [LICENSE](LICENSE)
218
+ - **0.6.0-alpha.8 及之后**: Business Source License 1.1([LICENSE.BSL](LICENSE.BSL)),4 年后(2030-05-16)自动转为 Apache-2.0
219
+ - **0.6.0-alpha.7 及之前**: Apache-2.0([LICENSE](LICENSE)),永久授权
220
+
221
+ BSL 允许个人使用、内部部署、嵌入其他产品、非商业 fork。**仅禁止**把 Hive 包装成多 agent 协作 SaaS 卖给第三方。详细边界见 [LICENSE.BSL](LICENSE.BSL) 的 Additional Use Grant。
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@tt-a1i/hive",
3
- "version": "0.6.0-alpha.7",
3
+ "version": "0.6.0-alpha.8",
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",
7
- "license": "Apache-2.0",
7
+ "license": "BUSL-1.1",
8
8
  "keywords": [
9
9
  "ai-agents",
10
10
  "cli",
@@ -30,6 +30,7 @@
30
30
  "assets/",
31
31
  "CHANGELOG.md",
32
32
  "LICENSE",
33
+ "LICENSE.BSL",
33
34
  "README.md",
34
35
  "README.en.md",
35
36
  "SECURITY.md",
@@ -74,7 +74,7 @@ $ team list\r
74
74
  `),custom:["你是自定义成员。请把这段改成该成员的行为契约。","建议包含:","- 目标:这个成员主要负责什么。","- 边界:哪些事可以做,哪些事不要做。","- 工作方式:如何调查、修改、验证或审查。","- 完成标准:交付时需要说明哪些结果、风险和阻塞。"].join(`
75
75
  `),reviewer:["你是监工型 Reviewer,负责质量审查,不替代 Orchestrator,也不默认改代码。","工作方式:","- 优先找真实 bug、回归风险、边界条件和测试缺口。","- 发现问题时给出严重度、文件/行号、触发条件和最小修复建议。","- 没有高风险问题时明确说清剩余风险和未验证范围。","交付说明按严重度排序,先列 blocking 问题。"].join(`
76
76
  `),tester:["你是验证型 Tester,负责复现、测试和证据化验证。","工作方式:","- 先明确要验证的行为、入口和失败条件。","- 优先跑真实命令或真实链路;必要时补充最小测试。","- 记录命令、结果、关键输出和不能覆盖的场景。","交付说明要区分通过、失败、未验证和建议下一步。"].join(`
77
- `)}},ii=(a,r,o)=>o==="zh"?r.find(i=>i.roleType===a)?.description??Mu.zh[a]:Mu.en[a],NE=({createWorker:a,open:r})=>{const{language:o}=ge(),[i,d]=y.useState(""),[f,m]=y.useState("coder"),[p,g]=y.useState([]),[v,b]=y.useState(Mu[o].coder),[x,k]=y.useState([]),[C,S]=y.useState("claude"),[E,j]=y.useState(!1),[N,L]=y.useState(""),[W,B]=y.useState(null),[G,Z]=y.useState(!1),Y=y.useRef(!1),F=y.useRef(!1),J=ii(f,p,o);y.useEffect(()=>{if(!r)return;let D=!1;return Vv().then(z=>{D||(k(z),S($=>z.some(te=>te.id===$&&te.available)?$:z.find(te=>te.id==="claude"&&te.available)?.id??z.find(te=>te.available)?.id??z[0]?.id??""))}).catch(z=>{D||B(z instanceof Error?z.message:String(z))}),()=>{D=!0}},[r]),y.useEffect(()=>{if(!r)return;let D=!1;return r2().then(z=>{D||(g(z),F.current||b(ii(f,z,o)))}).catch(z=>{D||B(z instanceof Error?z.message:String(z))}),()=>{D=!0}},[r,f,o]),y.useEffect(()=>{F.current||b(ii(f,p,o))},[o,p,f]);const P=D=>{F.current=!0,b(D)},I=D=>{Y.current=!1,d(D)},le=()=>{Y.current=!0,d(sg(o))};y.useEffect(()=>{Y.current&&d(sg(o))},[o]);const ie=D=>{m(D),F.current=!1,b(ii(D,p,o))};return{commandPresets:x,commandPresetId:C,createWorkerError:W,creating:G,roleDescription:v,roleDescriptionDefault:J,startupCommand:N,workerName:i,workerRole:f,setCommandPresetId:D=>{j(!0),S(D)},setRoleDescription:P,setStartupCommand:L,setWorkerName:I,setWorkerRole:ie,randomizeWorkerName:le,resetRoleDescription:()=>{F.current=!1,b(J)},resetError:()=>B(null),submit:(D,z)=>{D.preventDefault(),Z(!0),B(null);const $=N.trim()&&!E?"":C;a({commandPresetId:$,name:i,role:f,roleDescription:v,startupCommand:N}).then(({error:te})=>{d(""),Y.current=!1,ie("coder"),S("claude"),j(!1),L(""),z(),te&&B(te)}).catch(te=>{B(te instanceof Error?te.message:String(te))}).finally(()=>Z(!1))}}},TE=[{icon:u.jsx(xg,{size:16}),titleKey:"welcome.step1Title",descriptionKey:"welcome.step1Desc"},{icon:u.jsx(t1,{size:16}),titleKey:"welcome.step2Title",descriptionKey:"welcome.step2Desc"},{icon:u.jsx(K0,{size:16}),titleKey:"welcome.step3Title",descriptionKey:"welcome.step3Desc"}],jE=({onAddWorkspace:a,onTryDemo:r,heroImageSrc:o,disabledReason:i})=>{const{t:d}=ge(),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:TE.map((m,p)=>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:p+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(Sl,{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(Px,{size:14,"aria-hidden":!0})]}),r?u.jsx("button",{type:"button",onClick:r,className:"text-xs text-sec underline hover:text-pri",children:d("welcome.demo")}):null]})},AE=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)}}},iy="hive.worker-modal.width",jr=480,RE=.5,ki=a=>{const r=typeof window<"u"?window.innerWidth-24:1200;return Math.min(Math.max(a,jr),Math.max(jr,r))},ku=()=>typeof window>"u"?jr:ki(Math.round(window.innerWidth*RE)),_E=()=>{try{const a=localStorage.getItem(iy);if(!a)return ku();const r=Number.parseInt(a,10);return Number.isFinite(r)?ki(r):ku()}catch{return ku()}},OE=()=>{const[a,r]=y.useState(()=>_E()),[o,i]=y.useState(!1);y.useEffect(()=>{try{localStorage.setItem(iy,String(Math.round(a)))}catch{}},[a]),y.useEffect(()=>{const f=()=>{r(m=>ki(m))};return window.addEventListener("resize",f),()=>window.removeEventListener("resize",f)},[]);const d=y.useCallback(f=>m=>{m.preventDefault();const p=m.clientX,g=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 x=C=>{const S=C.clientX-p,E=f==="left"?g-2*S:g+2*S;r(ki(E))},k=()=>{i(!1),document.body.style.cursor=v,document.body.style.userSelect=b,document.removeEventListener("pointermove",x),document.removeEventListener("pointerup",k),document.removeEventListener("pointercancel",k)};document.addEventListener("pointermove",x),document.addEventListener("pointerup",k),document.addEventListener("pointercancel",k)},[a]);return{width:a,resizing:o,beginResize:d}},DE=({onClose:a,onStart:r,runId:o,startError:i,starting:d,worker:f})=>{const{t:m}=ge(),p=AE(f.role),g=Di(f),v=!!o,b=OE(),x=k=>{k||a()};return u.jsx(xn,{open:!0,onOpenChange:x,children:u.jsxs(wn,{children:[u.jsx(kn,{"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(Sn,{"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",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":jr,"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":jr,"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($t,{className:"sr-only",children:f.name}),u.jsxs(ea,{className:"sr-only",children:[p.label," agent — status ",g.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(Sl,{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(tt,{label:`${m("common.close")} (Esc)`,children:u.jsx(qv,{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(Wu,{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:v?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(ny,{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:()=>r(f),disabled:d,className:"icon-btn icon-btn--primary","data-testid":"worker-start-empty",children:[u.jsx(Si,{size:12,"aria-hidden":!0})," ",m(d?"common.starting":"common.start")]})]})})]})]})})]})})},zE=({onCreateWorker:a,onDeleteWorker:r,onDeleteWorkspace:o,onStartWorker:i,onOrchestratorResult:d,onRequestAddWorkspace:f,onTryDemo:m,welcomeDisabledReason:p,orchestratorAutostartError:g,orchestratorAutostartRunId:v,terminalRuns:b,workers:x,workspace:k})=>{const{t:C}=ge(),[S,E]=y.useState(null),[j,N]=y.useState(!1),[L,W]=y.useState(null),[B,G]=y.useState(null),[Z,Y]=y.useState(null),F=jl(),J=x.find(z=>z.id===S)??null;y.useEffect(()=>{S&&!J&&E(null)},[S,J]);const P=NE({createWorker:a,open:j});y.useEffect(()=>{P.createWorkerError&&F.show({kind:"error",message:P.createWorkerError})},[P.createWorkerError,F]),y.useEffect(()=>{L&&F.show({kind:"error",message:L})},[L,F]),y.useEffect(()=>{W(null),G(null),Y(null)},[k?.id]);const I=xE({workspaceId:k?.id??"",terminalRuns:b,autostartError:g,suppressAutostartRunId:v,onClearAutostartError:()=>{k&&d(k.id,{ok:!0,error:null,run_id:null})},onAfterStart:z=>{k&&d(k.id,z)}}),le=tE();if(!k){const z={onAddWorkspace:f};return m&&(z.onTryDemo=m),p&&(z.disabledReason=p),u.jsx(jE,{...z})}const ie=J?ey(b,J.id):void 0,oe=z=>{W(null),r(z.id).then(()=>E(null)).catch($=>{W($ instanceof Error?$.message:String($))})},me=z=>{G(null),Y(z.id),i(z.id).then(({error:$})=>{$&&G($)}).catch($=>{G($ instanceof Error?$.message:String($))}).finally(()=>Y(null))},_=async(z,$)=>{try{return await o2(k.id,z.id,$),F.show({kind:"success",message:C("worker.renameSuccess",{name:$})}),{error:null}}catch(te){const A=te instanceof Error?te.message:String(te);return F.show({kind:"error",message:C("worker.renameFailed",{message:A})}),{error:A}}},D=`${(le.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(I2,{terminalRuns:b,workers:x,workspace:k}),u.jsxs("div",{ref:le.containerRef,className:"relative flex min-h-0 flex-1",children:[u.jsx("div",{className:"flex min-w-[480px] shrink-0 flex-col",style:{width:D},"data-testid":"orchestrator-pane-shell",children:u.jsx(bE,{state:I.state,onStop:I.stop,onRemoveWorkspace:()=>{k&&o(k).catch(z=>{const $=z instanceof Error?z.message:String(z);F.show({kind:"error",message:`Delete failed: ${$}`})})},onStart:I.start,onRestart:I.restart})}),u.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":C("workerPane.resize"),"aria-valuenow":Math.round(le.orchPct*100),"aria-valuemin":30,"aria-valuemax":78,tabIndex:0,className:"pane-splitter",style:{left:`calc(${D} - 4px)`},"data-dragging":le.dragging||void 0,"data-testid":"pane-splitter",onPointerDown:le.beginDrag,onKeyDown:le.onKeyDown}),u.jsx(ay,{onAddWorkerClick:()=>N(!0),onDeleteWorker:oe,onOpenWorker:z=>E(z.id),onRenameWorker:_,onStartWorker:me,startingWorkerId:Z,terminalRuns:b,workers:x})]}),J?u.jsx(DE,{onClose:()=>E(null),onStart:me,runId:ie?.run_id??null,startError:B,starting:Z===J.id,worker:J}):null,j?u.jsx(hE,{commandPresets:P.commandPresets,commandPresetId:P.commandPresetId,creating:P.creating,onClose:()=>N(!1),onNameChange:P.setWorkerName,onPresetChange:P.setCommandPresetId,onRandomName:P.randomizeWorkerName,onRoleDescriptionChange:P.setRoleDescription,onRoleDescriptionReset:P.resetRoleDescription,onRoleChange:P.setWorkerRole,onSubmit:z=>P.submit(z,()=>N(!1)),onStartupCommandChange:P.setStartupCommand,roleDescription:P.roleDescription,roleDescriptionDefault:P.roleDescriptionDefault,startupCommand:P.startupCommand,workerName:P.workerName,workerRole:P.workerRole}):null]})},ME="modulepreload",LE=function(a){return"/"+a},ig={},vl=function(r,o,i){let d=Promise.resolve();if(o&&o.length>0){let v=function(b){return Promise.all(b.map(x=>Promise.resolve(x).then(k=>({status:"fulfilled",value:k}),k=>({status:"rejected",reason:k}))))};var m=v;document.getElementsByTagName("link");const p=document.querySelector("meta[property=csp-nonce]"),g=p?.nonce||p?.getAttribute("nonce");d=v(o.map(b=>{if(b=LE(b),b in ig)return;ig[b]=!0;const x=b.endsWith(".css"),k=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${b}"]${k}`))return;const C=document.createElement("link");if(C.rel=x?"stylesheet":ME,x||(C.as="script"),C.crossOrigin="",C.href=b,g&&C.setAttribute("nonce",g),document.head.appendChild(C),x)return new Promise((S,E)=>{C.addEventListener("load",S),C.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${b}`)))})}))}function f(p){const g=new Event("vite:preloadError",{cancelable:!0});if(g.payload=p,window.dispatchEvent(g),!g.defaultPrevented)throw p}return d.then(p=>{for(const g of p||[])g.status==="rejected"&&f(g.reason);return r().catch(f)})},og=(a,r={})=>{const o=new URL(a,window.location.href);o.protocol=o.protocol==="https:"?"wss:":"ws:";for(const[i,d]of Object.entries(r))d!==void 0&&o.searchParams.set(i,String(d));return o.toString()},UE=({initialSize:a,onError:r,onExit:o,onOutput:i,onRestore:d,runId:f})=>{const m=crypto.randomUUID(),p={...a,clientId:m},g=new WebSocket(og(`/ws/terminal/${f}/io`,p)),v=new WebSocket(og(`/ws/terminal/${f}/control`,p));let b=!1;const x=[];let k=null;const C=()=>{!k||v.readyState!==v.OPEN||(v.send(JSON.stringify({type:"resize",...k})),k=null)};return g.onmessage=S=>{const E=typeof S.data=="string"?S.data:"",j=N=>{v.readyState===v.OPEN&&v.send(JSON.stringify({type:"output_ack",bytes:N}))};if(!b){x.push({chunk:E,acknowledge:j});return}i(E,j)},v.onopen=()=>{C()},v.onmessage=S=>{const E=JSON.parse(String(S.data));if(E.type==="exit"&&o(E.code),E.type==="error"&&r(E.message),E.type==="restore"){d(E.snapshot),b=!0,v.readyState===v.OPEN&&v.send(JSON.stringify({type:"restore_complete"}));for(const j of x.splice(0))i(j.chunk,j.acknowledge)}},{dispose(){g.close(),v.close()},resize(S,E,j,N){k={cols:S,rows:E},j!==void 0&&(k.pixelWidth=j),N!==void 0&&(k.pixelHeight=N),C()},sendInput(S){g.readyState===g.OPEN&&g.send(S)}}},HE=a=>{const r=y.useRef(null),[o,i]=y.useState(null),[d,f]=y.useState("connecting");return y.useEffect(()=>{if(!r.current)return;let m=!1,p,g,v,b,x,k,C,S=null,E,j;const N={current:!1};return Promise.all([vl(()=>import("./xterm-B-qIQCd3.js"),[]),vl(()=>import("./addon-fit-DX4qG4td.js"),[]),vl(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]),vl(()=>import("./addon-webgl-DCtw1yLn.js"),[]),vl(()=>import("./addon-clipboard-wHJhZAA4.js"),[]),vl(()=>import("./addon-web-links-DIbG5aQx.js"),[])]).then(([L,W,B,G,Z,Y])=>{if(m||!r.current)return;const F=typeof window<"u"?getComputedStyle(document.documentElement):null,J=F?.getPropertyValue("--bg-crust").trim()||"#0e0e0e",P=F?.getPropertyValue("--text-primary").trim()||"#ebebeb",I=new L.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:P}}),le=new W.FitAddon;I.loadAddon(le),I.loadAddon(new B.Unicode11Addon),I.unicode.activeVersion="11",I.loadAddon(new Z.ClipboardAddon),I.loadAddon(new Y.WebLinksAddon),I.open(r.current),le.fit(),b=I,x=le;try{const _=new G.WebglAddon;_.onContextLoss(()=>_.dispose()),I.loadAddon(_)}catch{}if(S=r.current.querySelector(".xterm-helper-textarea"),S){const _=S;E=()=>{N.current=!0},j=D=>{const z=D.data;z&&v?.sendInput(z),_.value="",setTimeout(()=>{N.current=!1},0)},S.addEventListener("compositionstart",E,{capture:!0}),S.addEventListener("compositionend",j,{capture:!0})}typeof I.attachCustomKeyEventHandler=="function"&&I.attachCustomKeyEventHandler(_=>_.key!=="Enter"||!_.shiftKey?!0:(_.type==="keypress"&&v?.sendInput("\x1B[13;2u"),!1));const ie=()=>{if(!r.current)return{};const _=r.current.clientWidth,D=r.current.clientHeight,z={};return D>0&&(z.pixelHeight=D),_>0&&(z.pixelWidth=_),z},oe=()=>{if(!r.current)return;x?.fit();const{pixelHeight:_,pixelWidth:D}=ie();v?.resize(b?.cols??80,b?.rows??24,D,_)},me=()=>{C&&window.clearTimeout(C),C=window.setTimeout(()=>{C=void 0,oe()},50)};v=UE({initialSize:{cols:I.cols,rows:I.rows,...ie()},onError(_){i(_)},onExit(){f("stopped")},onOutput(_,D){I.write(_,()=>D(new TextEncoder().encode(_).byteLength))},onRestore(_){I.write(_)},runId:a}),g=I.onData(_=>{N.current||v?.sendInput(_)}),f("running"),oe(),typeof ResizeObserver<"u"&&r.current&&(k=new ResizeObserver(me),k.observe(r.current)),p=()=>oe(),window.addEventListener("resize",p)}),()=>{m=!0,p&&window.removeEventListener("resize",p),k?.disconnect(),C&&window.clearTimeout(C),S&&E&&S.removeEventListener("compositionstart",E,{capture:!0}),S&&j&&S.removeEventListener("compositionend",j,{capture:!0}),g?.dispose(),v?.dispose(),b?.dispose(),x?.dispose()}},[a]),{containerRef:r,error:o,status:d}},BE={connecting:"terminal.statusConnecting",running:"terminal.statusRunning",stopped:"common.stopped"},WE=a=>[`worker-pty-${a}`,`orch-pty-${a}`],qE=a=>{const[r,o]=y.useState(null);return y.useEffect(()=>{const i=WE(a),d=()=>{for(const m of i){const p=document.getElementById(m);if(p)return p}return null};o(d());const f=window.setInterval(()=>{const m=d();o(p=>p===m?p:m)},100);return()=>window.clearInterval(f)},[a]),r},YE=({runId:a,title:r})=>{const o=qE(a),i=o?o.id:"inline",d=u.jsx(GE,{runId:a,title:r},i);return o?Ei.createPortal(d,o):null},GE=({runId:a,title:r})=>{const{t:o}=ge(),{containerRef:i,error:d,status:f}=HE(a),m=BE[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"})]})},XE=3e3,oy=(a,r)=>{const o=new Set(a.map(d=>d.run_id)),i=new Set(a.map(d=>d.agent_id));return[...a,...r.filter(d=>!o.has(d.run_id)&&!i.has(d.agent_id))]},VE=(a,r)=>{const[o,i]=y.useState({}),d=y.useRef(new Map);y.useEffect(()=>()=>{for(const g of d.current.values())window.clearTimeout(g);d.current.clear()},[]);const f=y.useCallback((g,v)=>{i(b=>({...b,[g]:(b[g]??[]).filter(x=>x.agent_id!==v)}))},[]),m=y.useCallback(({agentId:g,agentName:v,runId:b,status:x="starting",workspaceId:k})=>{const C={agent_id:g,agent_name:v,run_id:b,status:x};i(j=>{const N=(j[k]??[]).filter(L=>L.run_id!==C.run_id&&L.agent_id!==C.agent_id);return{...j,[k]:[...N,C]}});const S=d.current.get(b);S&&window.clearTimeout(S);const E=window.setTimeout(()=>{i(j=>({...j,[k]:(j[k]??[]).filter(N=>N.run_id!==b)})),d.current.delete(b)},XE);d.current.set(b,E)},[]),p=y.useMemo(()=>oy(r,a?o[a]??[]:[]),[r,o,a]);return{forgetOptimisticAgent:f,optimisticRunsByWorkspaceId:o,recordOptimisticRun:m,terminalRuns:p}},KE=500,QE=({hidden:a=!1,optimisticRuns:r=[],workspaceId:o})=>{const{t:i}=ge(),[d,f]=y.useState([]),m=oy(d,r);return y.useEffect(()=>{let p=!1;const g=()=>{Kv(o).then(b=>{p||f(b)}).catch(b=>{p||f([]),console.error("[hive] swallowed:terminalPanels.listRuns",b)})};g();const v=window.setInterval(g,KE);return()=>{p=!0,window.clearInterval(v)}},[o]),u.jsx("section",{hidden:a,"aria-hidden":a||void 0,"aria-label":i("terminalPanels.aria"),children:m.map(p=>u.jsx(YE,{runId:p.run_id,title:`${p.agent_name} (${p.status})`},p.run_id))})},ZE=({activeId:a,activeWorkspace:r,bootstrapError:o,demoMode:i,onDeleteWorkspace:d,onExitDemo:f,onRequestAddWorkspace:m,onTryDemo:p,optimisticRunsByWorkspaceId:g,orchestratorAutostartErrors:v,orchestratorAutostartRunIds:b,recordOrchestratorResult:x,terminalRuns:k,workerActions:C,workers:S})=>i?u.jsx(J2,{onExit:f}):u.jsxs(u.Fragment,{children:[a?u.jsx(QE,{optimisticRuns:g[a]??[],workspaceId:a},`terminal-${a}`):null,u.jsx(zE,{onCreateWorker:C.createWorker,onDeleteWorker:C.deleteWorker,onDeleteWorkspace:d,onStartWorker:C.startWorker,onOrchestratorResult:x,onRequestAddWorkspace:m,onTryDemo:p,welcomeDisabledReason:o??void 0,orchestratorAutostartError:a?v[a]??null:null,orchestratorAutostartRunId:a?b[a]??null:null,terminalRuns:k,workers:S,workspace:r})]}),$E=()=>{const[a,r]=y.useState(!1);return{demoMode:a,enableDemo:()=>r(!0),exitDemo:()=>r(!1)}},JE=a=>{const{demoMode:r,workspaces:o,activeWorkspaceId:i,workersByWorkspaceId:d}=a,f=r?[ri]:o,m=r?{[ri.id]:ly}:d,p=r?ri.id:i,g=r?ri:o?.find(b=>b.id===i);return{effectiveActiveWorkspaceId:p,effectiveWorkspaces:f,effectiveWorkersByWorkspaceId:m,effectiveActiveWorkspace:g,pollWorkspaceId:r?null:i}},FE=[{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"}],PE=[{descriptionKey:"notifications.detail.brief.description",labelKey:"notifications.detail.brief.label",value:"brief"},{descriptionKey:"notifications.detail.detailed.description",labelKey:"notifications.detail.detailed.label",value:"detailed"}],IE=()=>{const{t:a}=ge(),[r,o]=y.useState(!1),i=y.useRef(null),d=y.useRef(null),{notify:f,previewSound:m,requestDesktopNotifications:p,settings:g,updateSettings:v}=Pv(),b=typeof window<"u"&&!("Notification"in window),x=y.useMemo(()=>FE.map(S=>({...S,description:a(S.descriptionKey),label:a(S.labelKey)})),[a]),k=y.useMemo(()=>PE.map(S=>({...S,description:a(S.descriptionKey),label:a(S.labelKey)})),[a]),C=S=>{if(!S){v({desktop:!1});return}p()};return y.useEffect(()=>{if(!r)return;const S=j=>{j.key==="Escape"&&(o(!1),d.current?.focus())},E=j=>{const N=i.current;N&&!N.contains(j.target)&&o(!1)};return document.addEventListener("keydown",S),document.addEventListener("pointerdown",E),()=>{document.removeEventListener("keydown",S),document.removeEventListener("pointerdown",E)}},[r]),u.jsxs("div",{ref:i,className:"relative",children:[u.jsx(tt,{label:a("notifications.settings.tooltip"),children:u.jsx("button",{ref:d,type:"button","aria-expanded":r,"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(yh,{size:14,"aria-hidden":!0})})}),r?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(yh,{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(xh,{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:x.map(S=>u.jsxs("div",{className:"relative min-h-[78px] rounded border transition-colors",style:{background:g.sound===S.value?`color-mix(in oklab, ${S.accent} 10%, var(--bg-2))`:"var(--bg-2)",borderColor:g.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:g.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(l1,{size:12,"aria-hidden":!0}):u.jsx(xh,{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,g.sound===S.value?u.jsx(Ar,{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(Si,{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(j0,{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:g.detail===S.value?"var(--bg-3)":"transparent",color:g.detail===S.value?"var(--text-primary)":"var(--text-secondary)"},children:[u.jsx("input",{type:"radio",name:"notification-detail",value:S.value,checked:g.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:g.desktop,disabled:b,className:"mt-0.5",onChange:S=>C(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]})},eC=a=>{const[r,o]=y.useState(null);return y.useEffect(()=>{if(a)return;let i=!0;return e2().then(d=>{i&&o(d)}).catch(()=>{i&&o(null)}),()=>{i=!1}},[a]),a??r},tC="0.6.0-alpha.7",nC={version:tC},aC=nC.version,lC=()=>{const{language:a,setLanguage:r,t:o}=ge(),i=a==="en"?"zh":"en",d=o(i==="en"?"language.switchToEn":"language.switchToZh"),f=o(a==="en"?"language.currentEn":"language.currentZh");return u.jsx(tt,{label:d,children:u.jsx("span",{children:u.jsxs("button",{type:"button","aria-label":d,onClick:()=>r(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})]})})})},rC=({hideActions:a=!1,onToggleTaskGraph:r,openTaskCount:o=0,taskGraphOpen:i,version:d=aC,versionInfo:f})=>{const{t:m}=ge(),p=eC(f),g=p?.updateAvailable&&p.latestVersion!==d?p:null,v=o>0,b=i?m("topbar.hideTodo"):v?m("topbar.todoOpen",{count:o}):m("topbar.showTodo");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(kg,{size:16,className:"text-pri","aria-hidden":!0}),u.jsx("span",{className:"font-semibold text-pri",children:"Hive"}),u.jsxs("span",{className:"text-ter text-xs tabular-nums",children:["v",d]}),g?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:m("topbar.updateAvailable")}),u.jsxs("span",{className:"text-ter",children:["v",d," → v",g.latestVersion]}),u.jsx("code",{className:"mono text-ter",children:g.installHint})]}):null]}),u.jsx("div",{className:"flex-1"}),a?null:u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(tt,{label:b,children:u.jsxs("button",{type:"button",onClick:r,"aria-pressed":i,"aria-label":"Toggle Todo","data-has-tasks":v?"true":void 0,className:"flex cursor-pointer items-center gap-1.5 rounded px-3 py-1 text-xs text-sec hover:bg-3 hover:text-pri","data-testid":"topbar-blueprint",children:[u.jsx(O0,{size:14,"aria-hidden":!0,className:v?"text-accent":void 0}),u.jsx("span",{children:m("topbar.todo")})]})}),u.jsx(lC,{}),u.jsx(IE,{})]})]})},cy="hive.workspace-sidebar.width",ld=56,rd=384,Su=256,cg=16,pi=a=>Math.min(rd,Math.max(ld,a)),sC=()=>{try{const a=localStorage.getItem(cy);if(!a)return Su;const r=Number.parseInt(a,10);return Number.isFinite(r)?pi(r):Su}catch{return Su}},iC=()=>{const[a,r]=y.useState(sC),[o,i]=y.useState(!1);y.useEffect(()=>{try{localStorage.setItem(cy,String(Math.round(a)))}catch{}},[a]);const d=y.useCallback(m=>{m.preventDefault();const p=m.clientX,g=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 x=C=>{r(pi(g+C.clientX-p))},k=()=>{i(!1),document.body.style.cursor=v,document.body.style.userSelect=b,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",k)},[a]),f=y.useCallback(m=>{m.key==="ArrowLeft"?(m.preventDefault(),r(p=>pi(p-cg))):m.key==="ArrowRight"?(m.preventDefault(),r(p=>pi(p+cg))):m.key==="Home"?(m.preventDefault(),r(ld)):m.key==="End"&&(m.preventDefault(),r(rd))},[]);return{beginResize:d,onResizeKeyDown:f,resizing:o,width:a}},oC=({children:a,hideTopbarActions:r=!1,onToggleTaskGraph:o,openTaskCount:i=0,sidebar:d,taskGraphOpen:f})=>{const{t:m}=ge(),p=iC();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(rC,{hideActions:r,onToggleTaskGraph:o,openTaskCount:i,taskGraphOpen:f}),u.jsxs("div",{className:"flex min-h-0 flex-1",children:[u.jsxs("aside",{"aria-label":m("layout.sidebarAria"),className:"workspace-sidebar relative flex shrink-0 flex-col","data-resizing":p.resizing?"true":"false",style:{background:"var(--bg-0)",boxShadow:"inset -1px 0 0 var(--border)",width:`${p.width}px`},children:[d,u.jsx("hr",{"aria-label":m("layout.sidebarResizeAria"),"aria-orientation":"vertical","aria-valuemin":ld,"aria-valuemax":rd,"aria-valuenow":Math.round(p.width),tabIndex:0,className:"workspace-sidebar-resizer","data-resizing":p.resizing?"true":"false",onMouseDown:p.beginResize,onKeyDown:p.onResizeKeyDown})]}),u.jsx("section",{className:"relative flex min-w-0 flex-1",children:a})]})]})},ug=[{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"}],cC=a=>{let r=0;for(let i=0;i<a.length;i+=1)r=r*31+a.charCodeAt(i)|0;const o=Math.abs(r)%ug.length;return ug[o]},uC=a=>{const r=a.trim();if(r.length===0)return"?";const o=r.codePointAt(0);return o===void 0?"?":String.fromCodePoint(o).toUpperCase()},dC=({workspaceId:a,name:r,isActive:o,working:i,workingCount:d,size:f=32})=>{const{token:m,label:p}=cC(a),g=uC(r),v=d&&d>1?d:null;return u.jsx(ad,{size:f,color:m,fontRatio:.45,ringColor:o?m:null,testId:"workspace-avatar",data:{"workspace-id":a,active:o?"true":void 0,"color-label":p},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:g})},fC=a=>!!a?.some(r=>r.status==="working"),mC=a=>a?.filter(r=>r.status==="working").length??0,pC=(a,r)=>{if(!a||a.length===0)return r("sidebar.noMembers");const o=a.filter(i=>i.status==="working").length;return o>0?r("sidebar.workingCount",{working:o,total:a.length}):r("sidebar.teamMemberCount",{count:a.length})},hC=({activeWorkspaceId:a,createDisabledReason:r,onCreateClick:o,onDeleteWorkspace:i,onSelectWorkspace:d,workersByWorkspaceId:f,workspaces:m})=>{const{t:p}=ge(),[g,v]=y.useState(null),[b,x]=y.useState(!1),k=jl(),C=!!r,S=N=>{v(N)},E=()=>{if(!g||b)return;const N=g;x(!0),Promise.resolve(i(N)).then(()=>{k.show({kind:"success",message:p("sidebar.removed",{name:N.name})})}).catch(L=>{const W=L instanceof Error?L.message:String(L);k.show({kind:"error",message:p("sidebar.deleteFailed",{message:W})})}).finally(()=>{x(!1),v(null)})},j=u.jsx(ty,{open:g!==null,onOpenChange:N=>{!N&&!b&&v(null)},title:g?p("sidebar.deleteConfirm",{name:g.name}):p("sidebar.deleteLabel"),description:g?p("sidebar.deleteDescription",{path:g.path,summary:pC(f[g.id],p)}):"",confirmLabel:p(b?"sidebar.deleting":"sidebar.deleteLabel"),confirmKind:"danger",onConfirm:E});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 uppercase tracking-wider text-ter","data-testid":"workspace-sidebar-title",children:p("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:p("common.loading")}):m.length===0?u.jsx("div",{className:"flex-1 px-2 py-4",children:u.jsx(Rr,{title:p("sidebar.noWorkspaces"),description:r??p("sidebar.noWorkspacesDesc"),icon:u.jsx(xg,{size:20}),action:u.jsxs("button",{type:"button",onClick:C?void 0:o,disabled:C,"aria-label":p("sidebar.newWorkspace"),title:r??p("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(gi,{size:14,"aria-hidden":!0}),p("sidebar.newWorkspace")]})})}):u.jsxs("ul",{className:"flex-1 scroll-y pb-2",children:[m.map(N=>{const L=f[N.id],W=N.id===a,B=fC(L),G=mC(L);return u.jsxs("li",{className:"group relative",children:[u.jsxs("button",{type:"button","aria-label":N.name,"aria-current":W?"true":void 0,onClick:()=>d(N.id),className:`ws-row block w-full py-2 pr-7 pl-3 text-left${W?" active":""}`,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`min-w-0 flex-1 truncate ${W?"font-medium text-pri":"text-pri"}`,children:N.name}),B?u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-ter tabular-nums",role:"img","aria-label":G>1?p("sidebar.workingMembers",{count:G}):p("sidebar.oneWorking"),title:G>1?p("sidebar.workingMembers",{count:G}):p("sidebar.oneWorking"),children:[u.jsx("span",{className:"status-dot status-dot--working","aria-hidden":!0}),G>1?G:null]}):null]}),u.jsx("div",{className:"ws-row__path mt-0.5 truncate text-xs text-ter",children:N.path})]}),u.jsx(tt,{side:"right",label:u.jsxs("span",{className:"flex flex-col gap-0.5",children:[u.jsx("span",{className:"font-medium",children:N.name}),u.jsx("span",{className:"mono text-ter",children:N.path})]}),children:u.jsx("button",{type:"button","aria-label":N.name,"aria-current":W?"true":void 0,onClick:()=>d(N.id),className:"ws-avatar-cell hidden w-full justify-center py-2","data-testid":"ws-avatar-cell",children:u.jsx(dC,{workspaceId:N.id,name:N.name,isActive:W,working:B,workingCount:G})})}),u.jsx(tt,{label:p("sidebar.deleteAria",{name:N.name}),children:u.jsx("button",{type:"button","aria-label":p("sidebar.deleteAria",{name:N.name}),onClick:()=>S(N),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(Bu,{size:14,"aria-hidden":!0})})})]},N.id)}),u.jsx("li",{children:u.jsx(tt,{label:r??p("sidebar.newWorkspace"),children:u.jsxs("button",{type:"button",onClick:C?void 0:o,disabled:C,"aria-label":p("sidebar.newWorkspace"),title:r??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(gi,{size:14,"aria-hidden":!0}),u.jsx("span",{className:"ws-add__label",children:p("sidebar.newWorkspace")})]})})})]}),j]})},gC=a=>`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/tasks/${a}`,vC=(a,r,o)=>a===r||a===o,yC=(a,r)=>{const[o,i]=y.useState(""),[d,f]=y.useState(!1),[m,p]=y.useState(!1),[g,v]=y.useState(null),b=y.useRef(!1),x=y.useRef(""),k=y.useRef(""),C=y.useCallback((E,j)=>{if(!b.current){x.current=E,k.current=E,i(E),p(!1),v(null);return}vC(E,x.current,j)||(v(E),p(!0))},[]);if(y.useEffect(()=>{if(!a){i(""),f(!1),p(!1),v(null),b.current=!1,x.current="",k.current="";return}let E=!1;return i(""),f(!1),p(!1),v(null),b.current=!1,x.current="",k.current="",Fh(a).then(({content:j})=>{E||(x.current=j,b.current=!1,k.current=j,i(j),f(!0),p(!1),v(null))}).catch(j=>{E||(x.current="",b.current=!1,k.current="",i(""),f(!0),p(!1),console.error("[hive] swallowed:tasks.initialLoad",j),v(null))}),()=>{E=!0}},[a]),y.useEffect(()=>{if(!a)return;let E=!1;const j=new WebSocket(gC(a));return j.onopen=()=>{Fh(a).then(({content:N})=>{E||C(N,k.current)}).catch(N=>{console.error("[hive] swallowed:tasks.getOnReconnect",N)})},j.onmessage=N=>{if(E)return;const L=JSON.parse(N.data);L.type==="tasks-updated"&&C(L.content,k.current)},()=>{E=!0,j.close()}},[C,a]),r!==void 0)return{content:r,hasConflict:!1,loaded:!0,onChange:E=>{},onKeepLocal:()=>{},onReload:()=>{},onSave:async()=>{},toggleTaskAtLine:async E=>{},appendTask:async E=>{},appendSubtask:async(E,j)=>{},updateTaskText:async(E,j)=>{},deleteTask:async E=>{}};const S=async(E,j)=>{if(!a)return;const N=k.current,L=E(N);if(L!==N){x.current=L,k.current=L,b.current=!1,i(L);try{const W=await ai(a,{content:L});x.current=W.content,k.current=W.content,i(W.content)}catch(W){throw x.current=N,k.current=N,i(N),console.error(`[hive] swallowed:tasks.${j}`,W),W}}};return{content:o,hasConflict:m,loaded:d,onChange:E=>{b.current=E!==x.current,k.current=E,i(E)},onKeepLocal:()=>{p(!1),v(null)},onReload:()=>{const E=g??x.current;x.current=E,b.current=!1,k.current=E,i(E),p(!1),v(null)},onSave:async()=>{if(!a)return;const E=await ai(a,{content:o});x.current=E.content,b.current=!1,k.current=E.content,i(E.content),p(!1),v(null)},toggleTaskAtLine:async E=>{if(!a)return;const j=k.current,N=Dk(j,E);if(N!==j){x.current=N,k.current=N,b.current=!1,i(N);try{const L=await ai(a,{content:N});x.current=L.content,k.current=L.content,i(L.content)}catch(L){throw x.current=j,k.current=j,i(j),L}}},appendTask:async E=>{const j=E.trim();if(!a||!j)return;const N=k.current,L=N.length>0&&!N.endsWith(`
77
+ `)}},ii=(a,r,o)=>o==="zh"?r.find(i=>i.roleType===a)?.description??Mu.zh[a]:Mu.en[a],NE=({createWorker:a,open:r})=>{const{language:o}=ge(),[i,d]=y.useState(""),[f,m]=y.useState("coder"),[p,g]=y.useState([]),[v,b]=y.useState(Mu[o].coder),[x,k]=y.useState([]),[C,S]=y.useState("claude"),[E,j]=y.useState(!1),[N,L]=y.useState(""),[W,B]=y.useState(null),[G,Z]=y.useState(!1),Y=y.useRef(!1),F=y.useRef(!1),J=ii(f,p,o);y.useEffect(()=>{if(!r)return;let D=!1;return Vv().then(z=>{D||(k(z),S($=>z.some(te=>te.id===$&&te.available)?$:z.find(te=>te.id==="claude"&&te.available)?.id??z.find(te=>te.available)?.id??z[0]?.id??""))}).catch(z=>{D||B(z instanceof Error?z.message:String(z))}),()=>{D=!0}},[r]),y.useEffect(()=>{if(!r)return;let D=!1;return r2().then(z=>{D||(g(z),F.current||b(ii(f,z,o)))}).catch(z=>{D||B(z instanceof Error?z.message:String(z))}),()=>{D=!0}},[r,f,o]),y.useEffect(()=>{F.current||b(ii(f,p,o))},[o,p,f]);const P=D=>{F.current=!0,b(D)},I=D=>{Y.current=!1,d(D)},le=()=>{Y.current=!0,d(sg(o))};y.useEffect(()=>{Y.current&&d(sg(o))},[o]);const ie=D=>{m(D),F.current=!1,b(ii(D,p,o))};return{commandPresets:x,commandPresetId:C,createWorkerError:W,creating:G,roleDescription:v,roleDescriptionDefault:J,startupCommand:N,workerName:i,workerRole:f,setCommandPresetId:D=>{j(!0),S(D)},setRoleDescription:P,setStartupCommand:L,setWorkerName:I,setWorkerRole:ie,randomizeWorkerName:le,resetRoleDescription:()=>{F.current=!1,b(J)},resetError:()=>B(null),submit:(D,z)=>{D.preventDefault(),Z(!0),B(null);const $=N.trim()&&!E?"":C;a({commandPresetId:$,name:i,role:f,roleDescription:v,startupCommand:N}).then(({error:te})=>{d(""),Y.current=!1,ie("coder"),S("claude"),j(!1),L(""),z(),te&&B(te)}).catch(te=>{B(te instanceof Error?te.message:String(te))}).finally(()=>Z(!1))}}},TE=[{icon:u.jsx(xg,{size:16}),titleKey:"welcome.step1Title",descriptionKey:"welcome.step1Desc"},{icon:u.jsx(t1,{size:16}),titleKey:"welcome.step2Title",descriptionKey:"welcome.step2Desc"},{icon:u.jsx(K0,{size:16}),titleKey:"welcome.step3Title",descriptionKey:"welcome.step3Desc"}],jE=({onAddWorkspace:a,onTryDemo:r,heroImageSrc:o,disabledReason:i})=>{const{t:d}=ge(),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:TE.map((m,p)=>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:p+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(Sl,{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(Px,{size:14,"aria-hidden":!0})]}),r?u.jsx("button",{type:"button",onClick:r,className:"text-xs text-sec underline hover:text-pri",children:d("welcome.demo")}):null]})},AE=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)}}},iy="hive.worker-modal.width",jr=480,RE=.5,ki=a=>{const r=typeof window<"u"?window.innerWidth-24:1200;return Math.min(Math.max(a,jr),Math.max(jr,r))},ku=()=>typeof window>"u"?jr:ki(Math.round(window.innerWidth*RE)),_E=()=>{try{const a=localStorage.getItem(iy);if(!a)return ku();const r=Number.parseInt(a,10);return Number.isFinite(r)?ki(r):ku()}catch{return ku()}},OE=()=>{const[a,r]=y.useState(()=>_E()),[o,i]=y.useState(!1);y.useEffect(()=>{try{localStorage.setItem(iy,String(Math.round(a)))}catch{}},[a]),y.useEffect(()=>{const f=()=>{r(m=>ki(m))};return window.addEventListener("resize",f),()=>window.removeEventListener("resize",f)},[]);const d=y.useCallback(f=>m=>{m.preventDefault();const p=m.clientX,g=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 x=C=>{const S=C.clientX-p,E=f==="left"?g-2*S:g+2*S;r(ki(E))},k=()=>{i(!1),document.body.style.cursor=v,document.body.style.userSelect=b,document.removeEventListener("pointermove",x),document.removeEventListener("pointerup",k),document.removeEventListener("pointercancel",k)};document.addEventListener("pointermove",x),document.addEventListener("pointerup",k),document.addEventListener("pointercancel",k)},[a]);return{width:a,resizing:o,beginResize:d}},DE=({onClose:a,onStart:r,runId:o,startError:i,starting:d,worker:f})=>{const{t:m}=ge(),p=AE(f.role),g=Di(f),v=!!o,b=OE(),x=k=>{k||a()};return u.jsx(xn,{open:!0,onOpenChange:x,children:u.jsxs(wn,{children:[u.jsx(kn,{"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(Sn,{"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",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":jr,"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":jr,"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($t,{className:"sr-only",children:f.name}),u.jsxs(ea,{className:"sr-only",children:[p.label," agent — status ",g.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(Sl,{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(tt,{label:`${m("common.close")} (Esc)`,children:u.jsx(qv,{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(Wu,{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:v?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(ny,{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:()=>r(f),disabled:d,className:"icon-btn icon-btn--primary","data-testid":"worker-start-empty",children:[u.jsx(Si,{size:12,"aria-hidden":!0})," ",m(d?"common.starting":"common.start")]})]})})]})]})})]})})},zE=({onCreateWorker:a,onDeleteWorker:r,onDeleteWorkspace:o,onStartWorker:i,onOrchestratorResult:d,onRequestAddWorkspace:f,onTryDemo:m,welcomeDisabledReason:p,orchestratorAutostartError:g,orchestratorAutostartRunId:v,terminalRuns:b,workers:x,workspace:k})=>{const{t:C}=ge(),[S,E]=y.useState(null),[j,N]=y.useState(!1),[L,W]=y.useState(null),[B,G]=y.useState(null),[Z,Y]=y.useState(null),F=jl(),J=x.find(z=>z.id===S)??null;y.useEffect(()=>{S&&!J&&E(null)},[S,J]);const P=NE({createWorker:a,open:j});y.useEffect(()=>{P.createWorkerError&&F.show({kind:"error",message:P.createWorkerError})},[P.createWorkerError,F]),y.useEffect(()=>{L&&F.show({kind:"error",message:L})},[L,F]),y.useEffect(()=>{W(null),G(null),Y(null)},[k?.id]);const I=xE({workspaceId:k?.id??"",terminalRuns:b,autostartError:g,suppressAutostartRunId:v,onClearAutostartError:()=>{k&&d(k.id,{ok:!0,error:null,run_id:null})},onAfterStart:z=>{k&&d(k.id,z)}}),le=tE();if(!k){const z={onAddWorkspace:f};return m&&(z.onTryDemo=m),p&&(z.disabledReason=p),u.jsx(jE,{...z})}const ie=J?ey(b,J.id):void 0,oe=z=>{W(null),r(z.id).then(()=>E(null)).catch($=>{W($ instanceof Error?$.message:String($))})},me=z=>{G(null),Y(z.id),i(z.id).then(({error:$})=>{$&&G($)}).catch($=>{G($ instanceof Error?$.message:String($))}).finally(()=>Y(null))},_=async(z,$)=>{try{return await o2(k.id,z.id,$),F.show({kind:"success",message:C("worker.renameSuccess",{name:$})}),{error:null}}catch(te){const A=te instanceof Error?te.message:String(te);return F.show({kind:"error",message:C("worker.renameFailed",{message:A})}),{error:A}}},D=`${(le.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(I2,{terminalRuns:b,workers:x,workspace:k}),u.jsxs("div",{ref:le.containerRef,className:"relative flex min-h-0 flex-1",children:[u.jsx("div",{className:"flex min-w-[480px] shrink-0 flex-col",style:{width:D},"data-testid":"orchestrator-pane-shell",children:u.jsx(bE,{state:I.state,onStop:I.stop,onRemoveWorkspace:()=>{k&&o(k).catch(z=>{const $=z instanceof Error?z.message:String(z);F.show({kind:"error",message:`Delete failed: ${$}`})})},onStart:I.start,onRestart:I.restart})}),u.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":C("workerPane.resize"),"aria-valuenow":Math.round(le.orchPct*100),"aria-valuemin":30,"aria-valuemax":78,tabIndex:0,className:"pane-splitter",style:{left:`calc(${D} - 4px)`},"data-dragging":le.dragging||void 0,"data-testid":"pane-splitter",onPointerDown:le.beginDrag,onKeyDown:le.onKeyDown}),u.jsx(ay,{onAddWorkerClick:()=>N(!0),onDeleteWorker:oe,onOpenWorker:z=>E(z.id),onRenameWorker:_,onStartWorker:me,startingWorkerId:Z,terminalRuns:b,workers:x})]}),J?u.jsx(DE,{onClose:()=>E(null),onStart:me,runId:ie?.run_id??null,startError:B,starting:Z===J.id,worker:J}):null,j?u.jsx(hE,{commandPresets:P.commandPresets,commandPresetId:P.commandPresetId,creating:P.creating,onClose:()=>N(!1),onNameChange:P.setWorkerName,onPresetChange:P.setCommandPresetId,onRandomName:P.randomizeWorkerName,onRoleDescriptionChange:P.setRoleDescription,onRoleDescriptionReset:P.resetRoleDescription,onRoleChange:P.setWorkerRole,onSubmit:z=>P.submit(z,()=>N(!1)),onStartupCommandChange:P.setStartupCommand,roleDescription:P.roleDescription,roleDescriptionDefault:P.roleDescriptionDefault,startupCommand:P.startupCommand,workerName:P.workerName,workerRole:P.workerRole}):null]})},ME="modulepreload",LE=function(a){return"/"+a},ig={},vl=function(r,o,i){let d=Promise.resolve();if(o&&o.length>0){let v=function(b){return Promise.all(b.map(x=>Promise.resolve(x).then(k=>({status:"fulfilled",value:k}),k=>({status:"rejected",reason:k}))))};var m=v;document.getElementsByTagName("link");const p=document.querySelector("meta[property=csp-nonce]"),g=p?.nonce||p?.getAttribute("nonce");d=v(o.map(b=>{if(b=LE(b),b in ig)return;ig[b]=!0;const x=b.endsWith(".css"),k=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${b}"]${k}`))return;const C=document.createElement("link");if(C.rel=x?"stylesheet":ME,x||(C.as="script"),C.crossOrigin="",C.href=b,g&&C.setAttribute("nonce",g),document.head.appendChild(C),x)return new Promise((S,E)=>{C.addEventListener("load",S),C.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${b}`)))})}))}function f(p){const g=new Event("vite:preloadError",{cancelable:!0});if(g.payload=p,window.dispatchEvent(g),!g.defaultPrevented)throw p}return d.then(p=>{for(const g of p||[])g.status==="rejected"&&f(g.reason);return r().catch(f)})},og=(a,r={})=>{const o=new URL(a,window.location.href);o.protocol=o.protocol==="https:"?"wss:":"ws:";for(const[i,d]of Object.entries(r))d!==void 0&&o.searchParams.set(i,String(d));return o.toString()},UE=({initialSize:a,onError:r,onExit:o,onOutput:i,onRestore:d,runId:f})=>{const m=crypto.randomUUID(),p={...a,clientId:m},g=new WebSocket(og(`/ws/terminal/${f}/io`,p)),v=new WebSocket(og(`/ws/terminal/${f}/control`,p));let b=!1;const x=[];let k=null;const C=()=>{!k||v.readyState!==v.OPEN||(v.send(JSON.stringify({type:"resize",...k})),k=null)};return g.onmessage=S=>{const E=typeof S.data=="string"?S.data:"",j=N=>{v.readyState===v.OPEN&&v.send(JSON.stringify({type:"output_ack",bytes:N}))};if(!b){x.push({chunk:E,acknowledge:j});return}i(E,j)},v.onopen=()=>{C()},v.onmessage=S=>{const E=JSON.parse(String(S.data));if(E.type==="exit"&&o(E.code),E.type==="error"&&r(E.message),E.type==="restore"){d(E.snapshot),b=!0,v.readyState===v.OPEN&&v.send(JSON.stringify({type:"restore_complete"}));for(const j of x.splice(0))i(j.chunk,j.acknowledge)}},{dispose(){g.close(),v.close()},resize(S,E,j,N){k={cols:S,rows:E},j!==void 0&&(k.pixelWidth=j),N!==void 0&&(k.pixelHeight=N),C()},sendInput(S){g.readyState===g.OPEN&&g.send(S)}}},HE=a=>{const r=y.useRef(null),[o,i]=y.useState(null),[d,f]=y.useState("connecting");return y.useEffect(()=>{if(!r.current)return;let m=!1,p,g,v,b,x,k,C,S=null,E,j;const N={current:!1};return Promise.all([vl(()=>import("./xterm-B-qIQCd3.js"),[]),vl(()=>import("./addon-fit-DX4qG4td.js"),[]),vl(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]),vl(()=>import("./addon-webgl-DCtw1yLn.js"),[]),vl(()=>import("./addon-clipboard-wHJhZAA4.js"),[]),vl(()=>import("./addon-web-links-DIbG5aQx.js"),[])]).then(([L,W,B,G,Z,Y])=>{if(m||!r.current)return;const F=typeof window<"u"?getComputedStyle(document.documentElement):null,J=F?.getPropertyValue("--bg-crust").trim()||"#0e0e0e",P=F?.getPropertyValue("--text-primary").trim()||"#ebebeb",I=new L.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:P}}),le=new W.FitAddon;I.loadAddon(le),I.loadAddon(new B.Unicode11Addon),I.unicode.activeVersion="11",I.loadAddon(new Z.ClipboardAddon),I.loadAddon(new Y.WebLinksAddon),I.open(r.current),le.fit(),b=I,x=le;try{const _=new G.WebglAddon;_.onContextLoss(()=>_.dispose()),I.loadAddon(_)}catch{}if(S=r.current.querySelector(".xterm-helper-textarea"),S){const _=S;E=()=>{N.current=!0},j=D=>{const z=D.data;z&&v?.sendInput(z),_.value="",setTimeout(()=>{N.current=!1},0)},S.addEventListener("compositionstart",E,{capture:!0}),S.addEventListener("compositionend",j,{capture:!0})}typeof I.attachCustomKeyEventHandler=="function"&&I.attachCustomKeyEventHandler(_=>_.key!=="Enter"||!_.shiftKey?!0:(_.type==="keypress"&&v?.sendInput("\x1B[13;2u"),!1));const ie=()=>{if(!r.current)return{};const _=r.current.clientWidth,D=r.current.clientHeight,z={};return D>0&&(z.pixelHeight=D),_>0&&(z.pixelWidth=_),z},oe=()=>{if(!r.current)return;x?.fit();const{pixelHeight:_,pixelWidth:D}=ie();v?.resize(b?.cols??80,b?.rows??24,D,_)},me=()=>{C&&window.clearTimeout(C),C=window.setTimeout(()=>{C=void 0,oe()},50)};v=UE({initialSize:{cols:I.cols,rows:I.rows,...ie()},onError(_){i(_)},onExit(){f("stopped")},onOutput(_,D){I.write(_,()=>D(new TextEncoder().encode(_).byteLength))},onRestore(_){I.write(_)},runId:a}),g=I.onData(_=>{N.current||v?.sendInput(_)}),f("running"),oe(),typeof ResizeObserver<"u"&&r.current&&(k=new ResizeObserver(me),k.observe(r.current)),p=()=>oe(),window.addEventListener("resize",p)}),()=>{m=!0,p&&window.removeEventListener("resize",p),k?.disconnect(),C&&window.clearTimeout(C),S&&E&&S.removeEventListener("compositionstart",E,{capture:!0}),S&&j&&S.removeEventListener("compositionend",j,{capture:!0}),g?.dispose(),v?.dispose(),b?.dispose(),x?.dispose()}},[a]),{containerRef:r,error:o,status:d}},BE={connecting:"terminal.statusConnecting",running:"terminal.statusRunning",stopped:"common.stopped"},WE=a=>[`worker-pty-${a}`,`orch-pty-${a}`],qE=a=>{const[r,o]=y.useState(null);return y.useEffect(()=>{const i=WE(a),d=()=>{for(const m of i){const p=document.getElementById(m);if(p)return p}return null};o(d());const f=window.setInterval(()=>{const m=d();o(p=>p===m?p:m)},100);return()=>window.clearInterval(f)},[a]),r},YE=({runId:a,title:r})=>{const o=qE(a),i=o?o.id:"inline",d=u.jsx(GE,{runId:a,title:r},i);return o?Ei.createPortal(d,o):null},GE=({runId:a,title:r})=>{const{t:o}=ge(),{containerRef:i,error:d,status:f}=HE(a),m=BE[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"})]})},XE=3e3,oy=(a,r)=>{const o=new Set(a.map(d=>d.run_id)),i=new Set(a.map(d=>d.agent_id));return[...a,...r.filter(d=>!o.has(d.run_id)&&!i.has(d.agent_id))]},VE=(a,r)=>{const[o,i]=y.useState({}),d=y.useRef(new Map);y.useEffect(()=>()=>{for(const g of d.current.values())window.clearTimeout(g);d.current.clear()},[]);const f=y.useCallback((g,v)=>{i(b=>({...b,[g]:(b[g]??[]).filter(x=>x.agent_id!==v)}))},[]),m=y.useCallback(({agentId:g,agentName:v,runId:b,status:x="starting",workspaceId:k})=>{const C={agent_id:g,agent_name:v,run_id:b,status:x};i(j=>{const N=(j[k]??[]).filter(L=>L.run_id!==C.run_id&&L.agent_id!==C.agent_id);return{...j,[k]:[...N,C]}});const S=d.current.get(b);S&&window.clearTimeout(S);const E=window.setTimeout(()=>{i(j=>({...j,[k]:(j[k]??[]).filter(N=>N.run_id!==b)})),d.current.delete(b)},XE);d.current.set(b,E)},[]),p=y.useMemo(()=>oy(r,a?o[a]??[]:[]),[r,o,a]);return{forgetOptimisticAgent:f,optimisticRunsByWorkspaceId:o,recordOptimisticRun:m,terminalRuns:p}},KE=500,QE=({hidden:a=!1,optimisticRuns:r=[],workspaceId:o})=>{const{t:i}=ge(),[d,f]=y.useState([]),m=oy(d,r);return y.useEffect(()=>{let p=!1;const g=()=>{Kv(o).then(b=>{p||f(b)}).catch(b=>{p||f([]),console.error("[hive] swallowed:terminalPanels.listRuns",b)})};g();const v=window.setInterval(g,KE);return()=>{p=!0,window.clearInterval(v)}},[o]),u.jsx("section",{hidden:a,"aria-hidden":a||void 0,"aria-label":i("terminalPanels.aria"),children:m.map(p=>u.jsx(YE,{runId:p.run_id,title:`${p.agent_name} (${p.status})`},p.run_id))})},ZE=({activeId:a,activeWorkspace:r,bootstrapError:o,demoMode:i,onDeleteWorkspace:d,onExitDemo:f,onRequestAddWorkspace:m,onTryDemo:p,optimisticRunsByWorkspaceId:g,orchestratorAutostartErrors:v,orchestratorAutostartRunIds:b,recordOrchestratorResult:x,terminalRuns:k,workerActions:C,workers:S})=>i?u.jsx(J2,{onExit:f}):u.jsxs(u.Fragment,{children:[a?u.jsx(QE,{optimisticRuns:g[a]??[],workspaceId:a},`terminal-${a}`):null,u.jsx(zE,{onCreateWorker:C.createWorker,onDeleteWorker:C.deleteWorker,onDeleteWorkspace:d,onStartWorker:C.startWorker,onOrchestratorResult:x,onRequestAddWorkspace:m,onTryDemo:p,welcomeDisabledReason:o??void 0,orchestratorAutostartError:a?v[a]??null:null,orchestratorAutostartRunId:a?b[a]??null:null,terminalRuns:k,workers:S,workspace:r})]}),$E=()=>{const[a,r]=y.useState(!1);return{demoMode:a,enableDemo:()=>r(!0),exitDemo:()=>r(!1)}},JE=a=>{const{demoMode:r,workspaces:o,activeWorkspaceId:i,workersByWorkspaceId:d}=a,f=r?[ri]:o,m=r?{[ri.id]:ly}:d,p=r?ri.id:i,g=r?ri:o?.find(b=>b.id===i);return{effectiveActiveWorkspaceId:p,effectiveWorkspaces:f,effectiveWorkersByWorkspaceId:m,effectiveActiveWorkspace:g,pollWorkspaceId:r?null:i}},FE=[{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"}],PE=[{descriptionKey:"notifications.detail.brief.description",labelKey:"notifications.detail.brief.label",value:"brief"},{descriptionKey:"notifications.detail.detailed.description",labelKey:"notifications.detail.detailed.label",value:"detailed"}],IE=()=>{const{t:a}=ge(),[r,o]=y.useState(!1),i=y.useRef(null),d=y.useRef(null),{notify:f,previewSound:m,requestDesktopNotifications:p,settings:g,updateSettings:v}=Pv(),b=typeof window<"u"&&!("Notification"in window),x=y.useMemo(()=>FE.map(S=>({...S,description:a(S.descriptionKey),label:a(S.labelKey)})),[a]),k=y.useMemo(()=>PE.map(S=>({...S,description:a(S.descriptionKey),label:a(S.labelKey)})),[a]),C=S=>{if(!S){v({desktop:!1});return}p()};return y.useEffect(()=>{if(!r)return;const S=j=>{j.key==="Escape"&&(o(!1),d.current?.focus())},E=j=>{const N=i.current;N&&!N.contains(j.target)&&o(!1)};return document.addEventListener("keydown",S),document.addEventListener("pointerdown",E),()=>{document.removeEventListener("keydown",S),document.removeEventListener("pointerdown",E)}},[r]),u.jsxs("div",{ref:i,className:"relative",children:[u.jsx(tt,{label:a("notifications.settings.tooltip"),children:u.jsx("button",{ref:d,type:"button","aria-expanded":r,"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(yh,{size:14,"aria-hidden":!0})})}),r?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(yh,{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(xh,{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:x.map(S=>u.jsxs("div",{className:"relative min-h-[78px] rounded border transition-colors",style:{background:g.sound===S.value?`color-mix(in oklab, ${S.accent} 10%, var(--bg-2))`:"var(--bg-2)",borderColor:g.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:g.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(l1,{size:12,"aria-hidden":!0}):u.jsx(xh,{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,g.sound===S.value?u.jsx(Ar,{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(Si,{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(j0,{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:g.detail===S.value?"var(--bg-3)":"transparent",color:g.detail===S.value?"var(--text-primary)":"var(--text-secondary)"},children:[u.jsx("input",{type:"radio",name:"notification-detail",value:S.value,checked:g.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:g.desktop,disabled:b,className:"mt-0.5",onChange:S=>C(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]})},eC=a=>{const[r,o]=y.useState(null);return y.useEffect(()=>{if(a)return;let i=!0;return e2().then(d=>{i&&o(d)}).catch(()=>{i&&o(null)}),()=>{i=!1}},[a]),a??r},tC="0.6.0-alpha.8",nC={version:tC},aC=nC.version,lC=()=>{const{language:a,setLanguage:r,t:o}=ge(),i=a==="en"?"zh":"en",d=o(i==="en"?"language.switchToEn":"language.switchToZh"),f=o(a==="en"?"language.currentEn":"language.currentZh");return u.jsx(tt,{label:d,children:u.jsx("span",{children:u.jsxs("button",{type:"button","aria-label":d,onClick:()=>r(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})]})})})},rC=({hideActions:a=!1,onToggleTaskGraph:r,openTaskCount:o=0,taskGraphOpen:i,version:d=aC,versionInfo:f})=>{const{t:m}=ge(),p=eC(f),g=p?.updateAvailable&&p.latestVersion!==d?p:null,v=o>0,b=i?m("topbar.hideTodo"):v?m("topbar.todoOpen",{count:o}):m("topbar.showTodo");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(kg,{size:16,className:"text-pri","aria-hidden":!0}),u.jsx("span",{className:"font-semibold text-pri",children:"Hive"}),u.jsxs("span",{className:"text-ter text-xs tabular-nums",children:["v",d]}),g?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:m("topbar.updateAvailable")}),u.jsxs("span",{className:"text-ter",children:["v",d," → v",g.latestVersion]}),u.jsx("code",{className:"mono text-ter",children:g.installHint})]}):null]}),u.jsx("div",{className:"flex-1"}),a?null:u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(tt,{label:b,children:u.jsxs("button",{type:"button",onClick:r,"aria-pressed":i,"aria-label":"Toggle Todo","data-has-tasks":v?"true":void 0,className:"flex cursor-pointer items-center gap-1.5 rounded px-3 py-1 text-xs text-sec hover:bg-3 hover:text-pri","data-testid":"topbar-blueprint",children:[u.jsx(O0,{size:14,"aria-hidden":!0,className:v?"text-accent":void 0}),u.jsx("span",{children:m("topbar.todo")})]})}),u.jsx(lC,{}),u.jsx(IE,{})]})]})},cy="hive.workspace-sidebar.width",ld=56,rd=384,Su=256,cg=16,pi=a=>Math.min(rd,Math.max(ld,a)),sC=()=>{try{const a=localStorage.getItem(cy);if(!a)return Su;const r=Number.parseInt(a,10);return Number.isFinite(r)?pi(r):Su}catch{return Su}},iC=()=>{const[a,r]=y.useState(sC),[o,i]=y.useState(!1);y.useEffect(()=>{try{localStorage.setItem(cy,String(Math.round(a)))}catch{}},[a]);const d=y.useCallback(m=>{m.preventDefault();const p=m.clientX,g=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 x=C=>{r(pi(g+C.clientX-p))},k=()=>{i(!1),document.body.style.cursor=v,document.body.style.userSelect=b,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",k)},[a]),f=y.useCallback(m=>{m.key==="ArrowLeft"?(m.preventDefault(),r(p=>pi(p-cg))):m.key==="ArrowRight"?(m.preventDefault(),r(p=>pi(p+cg))):m.key==="Home"?(m.preventDefault(),r(ld)):m.key==="End"&&(m.preventDefault(),r(rd))},[]);return{beginResize:d,onResizeKeyDown:f,resizing:o,width:a}},oC=({children:a,hideTopbarActions:r=!1,onToggleTaskGraph:o,openTaskCount:i=0,sidebar:d,taskGraphOpen:f})=>{const{t:m}=ge(),p=iC();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(rC,{hideActions:r,onToggleTaskGraph:o,openTaskCount:i,taskGraphOpen:f}),u.jsxs("div",{className:"flex min-h-0 flex-1",children:[u.jsxs("aside",{"aria-label":m("layout.sidebarAria"),className:"workspace-sidebar relative flex shrink-0 flex-col","data-resizing":p.resizing?"true":"false",style:{background:"var(--bg-0)",boxShadow:"inset -1px 0 0 var(--border)",width:`${p.width}px`},children:[d,u.jsx("hr",{"aria-label":m("layout.sidebarResizeAria"),"aria-orientation":"vertical","aria-valuemin":ld,"aria-valuemax":rd,"aria-valuenow":Math.round(p.width),tabIndex:0,className:"workspace-sidebar-resizer","data-resizing":p.resizing?"true":"false",onMouseDown:p.beginResize,onKeyDown:p.onResizeKeyDown})]}),u.jsx("section",{className:"relative flex min-w-0 flex-1",children:a})]})]})},ug=[{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"}],cC=a=>{let r=0;for(let i=0;i<a.length;i+=1)r=r*31+a.charCodeAt(i)|0;const o=Math.abs(r)%ug.length;return ug[o]},uC=a=>{const r=a.trim();if(r.length===0)return"?";const o=r.codePointAt(0);return o===void 0?"?":String.fromCodePoint(o).toUpperCase()},dC=({workspaceId:a,name:r,isActive:o,working:i,workingCount:d,size:f=32})=>{const{token:m,label:p}=cC(a),g=uC(r),v=d&&d>1?d:null;return u.jsx(ad,{size:f,color:m,fontRatio:.45,ringColor:o?m:null,testId:"workspace-avatar",data:{"workspace-id":a,active:o?"true":void 0,"color-label":p},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:g})},fC=a=>!!a?.some(r=>r.status==="working"),mC=a=>a?.filter(r=>r.status==="working").length??0,pC=(a,r)=>{if(!a||a.length===0)return r("sidebar.noMembers");const o=a.filter(i=>i.status==="working").length;return o>0?r("sidebar.workingCount",{working:o,total:a.length}):r("sidebar.teamMemberCount",{count:a.length})},hC=({activeWorkspaceId:a,createDisabledReason:r,onCreateClick:o,onDeleteWorkspace:i,onSelectWorkspace:d,workersByWorkspaceId:f,workspaces:m})=>{const{t:p}=ge(),[g,v]=y.useState(null),[b,x]=y.useState(!1),k=jl(),C=!!r,S=N=>{v(N)},E=()=>{if(!g||b)return;const N=g;x(!0),Promise.resolve(i(N)).then(()=>{k.show({kind:"success",message:p("sidebar.removed",{name:N.name})})}).catch(L=>{const W=L instanceof Error?L.message:String(L);k.show({kind:"error",message:p("sidebar.deleteFailed",{message:W})})}).finally(()=>{x(!1),v(null)})},j=u.jsx(ty,{open:g!==null,onOpenChange:N=>{!N&&!b&&v(null)},title:g?p("sidebar.deleteConfirm",{name:g.name}):p("sidebar.deleteLabel"),description:g?p("sidebar.deleteDescription",{path:g.path,summary:pC(f[g.id],p)}):"",confirmLabel:p(b?"sidebar.deleting":"sidebar.deleteLabel"),confirmKind:"danger",onConfirm:E});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 uppercase tracking-wider text-ter","data-testid":"workspace-sidebar-title",children:p("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:p("common.loading")}):m.length===0?u.jsx("div",{className:"flex-1 px-2 py-4",children:u.jsx(Rr,{title:p("sidebar.noWorkspaces"),description:r??p("sidebar.noWorkspacesDesc"),icon:u.jsx(xg,{size:20}),action:u.jsxs("button",{type:"button",onClick:C?void 0:o,disabled:C,"aria-label":p("sidebar.newWorkspace"),title:r??p("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(gi,{size:14,"aria-hidden":!0}),p("sidebar.newWorkspace")]})})}):u.jsxs("ul",{className:"flex-1 scroll-y pb-2",children:[m.map(N=>{const L=f[N.id],W=N.id===a,B=fC(L),G=mC(L);return u.jsxs("li",{className:"group relative",children:[u.jsxs("button",{type:"button","aria-label":N.name,"aria-current":W?"true":void 0,onClick:()=>d(N.id),className:`ws-row block w-full py-2 pr-7 pl-3 text-left${W?" active":""}`,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`min-w-0 flex-1 truncate ${W?"font-medium text-pri":"text-pri"}`,children:N.name}),B?u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-ter tabular-nums",role:"img","aria-label":G>1?p("sidebar.workingMembers",{count:G}):p("sidebar.oneWorking"),title:G>1?p("sidebar.workingMembers",{count:G}):p("sidebar.oneWorking"),children:[u.jsx("span",{className:"status-dot status-dot--working","aria-hidden":!0}),G>1?G:null]}):null]}),u.jsx("div",{className:"ws-row__path mt-0.5 truncate text-xs text-ter",children:N.path})]}),u.jsx(tt,{side:"right",label:u.jsxs("span",{className:"flex flex-col gap-0.5",children:[u.jsx("span",{className:"font-medium",children:N.name}),u.jsx("span",{className:"mono text-ter",children:N.path})]}),children:u.jsx("button",{type:"button","aria-label":N.name,"aria-current":W?"true":void 0,onClick:()=>d(N.id),className:"ws-avatar-cell hidden w-full justify-center py-2","data-testid":"ws-avatar-cell",children:u.jsx(dC,{workspaceId:N.id,name:N.name,isActive:W,working:B,workingCount:G})})}),u.jsx(tt,{label:p("sidebar.deleteAria",{name:N.name}),children:u.jsx("button",{type:"button","aria-label":p("sidebar.deleteAria",{name:N.name}),onClick:()=>S(N),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(Bu,{size:14,"aria-hidden":!0})})})]},N.id)}),u.jsx("li",{children:u.jsx(tt,{label:r??p("sidebar.newWorkspace"),children:u.jsxs("button",{type:"button",onClick:C?void 0:o,disabled:C,"aria-label":p("sidebar.newWorkspace"),title:r??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(gi,{size:14,"aria-hidden":!0}),u.jsx("span",{className:"ws-add__label",children:p("sidebar.newWorkspace")})]})})})]}),j]})},gC=a=>`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/tasks/${a}`,vC=(a,r,o)=>a===r||a===o,yC=(a,r)=>{const[o,i]=y.useState(""),[d,f]=y.useState(!1),[m,p]=y.useState(!1),[g,v]=y.useState(null),b=y.useRef(!1),x=y.useRef(""),k=y.useRef(""),C=y.useCallback((E,j)=>{if(!b.current){x.current=E,k.current=E,i(E),p(!1),v(null);return}vC(E,x.current,j)||(v(E),p(!0))},[]);if(y.useEffect(()=>{if(!a){i(""),f(!1),p(!1),v(null),b.current=!1,x.current="",k.current="";return}let E=!1;return i(""),f(!1),p(!1),v(null),b.current=!1,x.current="",k.current="",Fh(a).then(({content:j})=>{E||(x.current=j,b.current=!1,k.current=j,i(j),f(!0),p(!1),v(null))}).catch(j=>{E||(x.current="",b.current=!1,k.current="",i(""),f(!0),p(!1),console.error("[hive] swallowed:tasks.initialLoad",j),v(null))}),()=>{E=!0}},[a]),y.useEffect(()=>{if(!a)return;let E=!1;const j=new WebSocket(gC(a));return j.onopen=()=>{Fh(a).then(({content:N})=>{E||C(N,k.current)}).catch(N=>{console.error("[hive] swallowed:tasks.getOnReconnect",N)})},j.onmessage=N=>{if(E)return;const L=JSON.parse(N.data);L.type==="tasks-updated"&&C(L.content,k.current)},()=>{E=!0,j.close()}},[C,a]),r!==void 0)return{content:r,hasConflict:!1,loaded:!0,onChange:E=>{},onKeepLocal:()=>{},onReload:()=>{},onSave:async()=>{},toggleTaskAtLine:async E=>{},appendTask:async E=>{},appendSubtask:async(E,j)=>{},updateTaskText:async(E,j)=>{},deleteTask:async E=>{}};const S=async(E,j)=>{if(!a)return;const N=k.current,L=E(N);if(L!==N){x.current=L,k.current=L,b.current=!1,i(L);try{const W=await ai(a,{content:L});x.current=W.content,k.current=W.content,i(W.content)}catch(W){throw x.current=N,k.current=N,i(N),console.error(`[hive] swallowed:tasks.${j}`,W),W}}};return{content:o,hasConflict:m,loaded:d,onChange:E=>{b.current=E!==x.current,k.current=E,i(E)},onKeepLocal:()=>{p(!1),v(null)},onReload:()=>{const E=g??x.current;x.current=E,b.current=!1,k.current=E,i(E),p(!1),v(null)},onSave:async()=>{if(!a)return;const E=await ai(a,{content:o});x.current=E.content,b.current=!1,k.current=E.content,i(E.content),p(!1),v(null)},toggleTaskAtLine:async E=>{if(!a)return;const j=k.current,N=Dk(j,E);if(N!==j){x.current=N,k.current=N,b.current=!1,i(N);try{const L=await ai(a,{content:N});x.current=L.content,k.current=L.content,i(L.content)}catch(L){throw x.current=j,k.current=j,i(j),L}}},appendTask:async E=>{const j=E.trim();if(!a||!j)return;const N=k.current,L=N.length>0&&!N.endsWith(`
78
78
  `),W=`${N}${L?`
79
79
  `:""}- [ ] ${j}
80
80
  `;x.current=W,k.current=W,b.current=!1,i(W);try{const B=await ai(a,{content:W});x.current=B.content,k.current=B.content,i(B.content)}catch(B){throw x.current=N,k.current=N,i(N),B}},appendSubtask:async(E,j)=>{const N=j.trim();N&&await S(L=>Lk(L,E,N),"appendSubtask")},updateTaskText:async(E,j)=>{const N=j.trim();N&&await S(L=>zk(L,E,N),"updateTaskText")},deleteTask:async E=>{await S(j=>Mk(j,E),"deleteTask")}}},bC=a=>{if(!a||!(a instanceof HTMLElement))return!1;const r=a.tagName.toLowerCase();return!!(r==="input"||r==="textarea"||r==="select"||a.isContentEditable||a.closest(".xterm"))},xC=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),wC=a=>xC?a.metaKey:a.ctrlKey,kC=a=>{y.useEffect(()=>{const r=o=>{if(bC(o.target))return;const i=o.key.toLowerCase();for(const d of a){if(i!==d.key||(d.mod??!1)!==wC(o)||(d.shift??!1)!==o.shiftKey)continue;d.handler(o)!==!1&&o.preventDefault();return}};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[a])},SC=({activeWorkspace:a,bootstrapError:r,onSelectWorkspace:o,onToggleTaskGraph:i,onTriggerAddDialog:d,workspaces:f})=>{const m=y.useMemo(()=>{const p=(f??[]).slice(0,9).map((g,v)=>({key:String(v+1),mod:!0,handler:()=>o(g.id)}));return[{key:"b",mod:!0,handler:()=>{a&&i()}},{key:"n",mod:!0,shift:!0,handler:()=>{r||d()}},...p]},[a,r,o,i,d,f]);kC(m)},EC=(a,r)=>r&&a.some(o=>o.id===r)?r:a[0]?.id??null,CC=(a,r)=>{if(a===null)return r;const o=new Map(a.map(i=>[i.id,i]));for(const i of r)o.set(i.id,i);return Array.from(o.values())},NC=(a,r,o)=>{y.useEffect(()=>{let i=!1;return Gv().then(async()=>{const[d,f]=await Promise.all([IS(),a2().catch(()=>null)]);return{items:d,persistedId:f}}).then(({items:d,persistedId:f})=>{i||a(m=>{const p=CC(m,d),g=EC(p,f);return r(g),f!==g&&Xv(g).catch(v=>{console.error("[hive] swallowed:initSession.save",v)}),p})}).catch(d=>{i||(r(null),o&&o("Could not reach Hive runtime. Refresh once the runtime is back up.")),console.error("[hive] swallowed:initSession.bootstrap",d)}),()=>{i=!0}},[r,a,o])},TC=()=>{const a=y.useRef(null);return y.useCallback(r=>{if(typeof document>"u")return;const o=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(r):r.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))},[])},jC=({onWorkspaceCreated:a,onError:r})=>{const[o,i]=y.useState({}),[d,f]=y.useState({}),m=y.useCallback((g,v)=>{i(b=>({...b,[g]:v.ok?null:v.error})),f(b=>({...b,[g]:v.ok?v.run_id:null}))},[]),p=y.useCallback(async g=>{try{const v=await t2({name:g.name,path:g.path,autostart_orchestrator:!0,command_preset_id:g.commandPresetId,startup_command:g.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 r?.(b),v}},[a,r,m]);return{orchestratorAutostartErrors:o,orchestratorAutostartRunIds:d,recordOrchestratorResult:m,createNewWorkspace:p}},AC=(a,r)=>{const o=a.findIndex(d=>d.id===r),i=a.filter(d=>d.id!==r);return o<0?i[0]?.id??null:i[Math.min(o,i.length-1)]?.id??null},RC=({activeWorkspaceId:a,onActiveDeleted:r,selectWorkspace:o,setWorkersByWorkspaceId:i,setWorkspaces:d,workspaces:f})=>async m=>{const g=AC(f??[],m.id);await n2(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&&(r(),o(g))},_C=()=>{const[a,r]=y.useState(null),o=y.useRef(Promise.resolve());return{activeWorkspaceId:a,selectWorkspace:d=>{r(d),o.current=o.current.catch(Sa("selectWorkspace.prevQueue")).then(()=>Xv(d)).catch(Sa("selectWorkspace.save"))},setActiveWorkspaceId:r}},OC=500,DC=5e3,zC=a=>Math.min(OC*2**a,DC),MC=a=>{const r=a.join("\0"),[o,i]=y.useState({});return y.useEffect(()=>{if(!r){i({});return}let d=!1,f=!1,m=0,p;const g=r.split("\0"),v=()=>{d||(p=window.setTimeout(b,zC(m)))},b=()=>{f||(f=!0,Promise.all(g.map(async x=>{try{return[x,await l2(x)]}catch(k){return console.error("[hive] swallowed:workspaceWorkers.list",k),null}})).then(x=>{d||(m=x.some(Boolean)?0:Math.min(m+1,4),i(k=>{const C={};for(const S of g)C[S]=k[S]??[];for(const S of x)S&&(C[S[0]]=S[1]);return C}))}).finally(()=>{f=!1,v()}))};return b(),()=>{d=!0,p!==void 0&&window.clearTimeout(p)}},[r]),[o,i]},dg="hive.first-run-seen",LC=()=>{const[a,r]=y.useState(()=>{try{return window.localStorage.getItem(dg)==="1"}catch{return!0}}),o=y.useCallback(()=>{try{window.localStorage.setItem(dg,"1")}catch{}r(!0)},[]);return{seen:a,markSeen:o}},UC=a=>{const{seen:r,markSeen:o}=LC(),[i,d]=y.useState(!1);y.useEffect(()=>{!r&&a!==null&&a.length===0&&d(!0)},[r,a]);const f=y.useCallback((m=!0)=>{m&&o(),d(!1)},[o]);return{wizardOpen:i,closeWizard:f}},HC=(a,r)=>a.findIndex(i=>i.id===r.id)===-1?[...a,r]:a.map(i=>i.id===r.id?r:i),BC=({activeWorkspaceId:a,onWorkerDeleted:r,onWorkerRunStarted:o,setWorkersByWorkspaceId:i})=>{const d=y.useCallback(async({commandPresetId:g,name:v,role:b,roleDescription:x,startupCommand:k})=>{if(!a)return{error:"No active workspace",runId:null};const C=k.trim(),S=await s2(a,{autostart:!0,command_preset_id:g||null,description:x.trim(),name:v,role:b,startup_command:C||null});return i(E=>({...E,[a]:HC(E[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 g=>{if(!a)throw new Error("No active workspace");await i2(a,g),i(v=>({...v,[a]:(v[a]??[]).filter(b=>b.id!==g)})),r?.(a,g)},[a,r,i]),m=y.useCallback(async g=>{if(!a)return{error:"No active workspace",runId:null};try{const v=await Du(a,g);return o?.({agentId:g,agentName:g,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]),p=y.useCallback(async g=>{try{return await zu(g),{error:null}}catch(v){return{error:v instanceof Error?v.message:String(v)}}},[]);return{createWorker:d,deleteWorker:f,startWorker:m,stopWorkerRun:p}},WC=()=>{const[a,r]=y.useState(null),{activeWorkspaceId:o,selectWorkspace:i,setActiveWorkspaceId:d}=_C(),{demoMode:f,enableDemo:m,exitDemo:p}=$E(),g=f||!a?[]:a.map(({id:D})=>D),[v,b]=MC(g),[x,k]=y.useState(0),[C,S]=y.useState(!1),E=jl(),{wizardOpen:j,closeWizard:N}=UC(a),L=y.useCallback(()=>k(D=>D+1),[]),[W,B]=y.useState(null),G=y.useCallback(D=>{B(D),E.show({kind:"error",message:D})},[E]);NC(r,d,G);const Z=jC({onWorkspaceCreated:D=>{r(z=>z===null?[D]:[...z,D]),i(D.id),b(z=>({...z,[D.id]:[]}))},onError:D=>E.show({kind:"error",message:D})}),F=JE({demoMode:f,workspaces:a,activeWorkspaceId:o,workersByWorkspaceId:v}),J=F.effectiveActiveWorkspace?.id,P=J?F.effectiveWorkersByWorkspaceId[J]??[]:[],I=VE(F.pollWorkspaceId,M2(F.pollWorkspaceId)),le=yC(f?null:o??null,f?Z2:void 0),ie=F.effectiveActiveWorkspace?dv(le.content).filter(D=>!D.checked).length:0,oe=BC({activeWorkspaceId:o,onWorkerDeleted:I.forgetOptimisticAgent,onWorkerRunStarted:I.recordOptimisticRun,setWorkersByWorkspaceId:b}),me=RC({activeWorkspaceId:o,onActiveDeleted:()=>S(!1),selectWorkspace:i,setWorkersByWorkspaceId:b,setWorkspaces:r,workspaces:a});SC({activeWorkspace:F.effectiveActiveWorkspace,bootstrapError:W,onSelectWorkspace:i,onToggleTaskGraph:()=>S(D=>!D),onTriggerAddDialog:L,workspaces:F.effectiveWorkspaces});const _=TC();return u.jsxs(oC,{hideTopbarActions:!F.effectiveActiveWorkspace,onToggleTaskGraph:()=>S(D=>!D),openTaskCount:ie,sidebar:u.jsx(hC,{activeWorkspaceId:F.effectiveActiveWorkspaceId,createDisabledReason:W??void 0,onCreateClick:L,onDeleteWorkspace:me,onSelectWorkspace:i,workersByWorkspaceId:F.effectiveWorkersByWorkspaceId,workspaces:F.effectiveWorkspaces}),taskGraphOpen:C,children:[u.jsx(ZE,{activeId:J,activeWorkspace:F.effectiveActiveWorkspace,bootstrapError:W,demoMode:f,onDeleteWorkspace:me,onExitDemo:p,onRequestAddWorkspace:L,onTryDemo:m,optimisticRunsByWorkspaceId:I.optimisticRunsByWorkspaceId,orchestratorAutostartErrors:Z.orchestratorAutostartErrors,orchestratorAutostartRunIds:Z.orchestratorAutostartRunIds,recordOrchestratorResult:Z.recordOrchestratorResult,terminalRuns:I.terminalRuns,workerActions:oe,workers:P}),u.jsx(w2,{addDialogTrigger:x,wizardOpen:j,onAddWorkspace:L,onCloseTaskGraph:()=>S(!1),onCloseWizard:N,onCreateWorkspace:Z.createNewWorkspace,onTryDemo:m,taskGraphOpen:C,tasksFile:le,workspacePath:F.effectiveActiveWorkspace?.path??null,workers:P,onSelectOwner:_})]})},qC=()=>u.jsx(D2,{children:u.jsx(WC,{})}),uy=document.getElementById("root");if(!uy)throw new Error("Root element not found");Xx.createRoot(uy).render(u.jsx(y.StrictMode,{children:u.jsx(qC,{})}));
@@ -13,7 +13,7 @@
13
13
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap"
14
14
  rel="stylesheet"
15
15
  />
16
- <script type="module" crossorigin src="/assets/index-CGvIlvht.js"></script>
16
+ <script type="module" crossorigin src="/assets/index-DFE1Ia4e.js"></script>
17
17
  <link rel="stylesheet" crossorigin href="/assets/index-B8F00qo4.css">
18
18
  </head>
19
19
  <body>