@tt-a1i/hive 2.1.11 → 2.1.12
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 +13 -0
- package/README.md +13 -11
- package/README.zh.md +9 -8
- package/dist/src/cli/hive-defaults.d.ts +1 -0
- package/dist/src/cli/hive-defaults.js +1 -0
- package/dist/src/cli/hive-mcp.js +2 -1
- package/dist/src/cli/hive.d.ts +2 -0
- package/dist/src/cli/hive.js +4 -2
- package/dist/src/server/command-preset-defaults.d.ts +1 -1
- package/dist/src/server/command-preset-defaults.js +10 -0
- package/dist/src/server/post-start-input-writer.js +5 -1
- package/dist/src/server/sqlite-schema-v38.d.ts +2 -0
- package/dist/src/server/sqlite-schema-v38.js +26 -0
- package/dist/src/server/sqlite-schema.d.ts +1 -1
- package/dist/src/server/sqlite-schema.js +6 -1
- package/dist/src/server/workflow-cli-policy.d.ts +1 -1
- package/dist/src/server/workflow-cli-policy.js +1 -0
- package/package.json +3 -3
- package/web/dist/assets/{AddWorkerDialog-CMQdmZJQ.js → AddWorkerDialog-BA0p5Pcr.js} +2 -2
- package/web/dist/assets/{AddWorkspaceFlow-arGy-LVX.js → AddWorkspaceFlow-YO-HxdrH.js} +1 -1
- package/web/dist/assets/{FirstRunWizard-PRHGFYry.js → FirstRunWizard-C5iyX5QF.js} +1 -1
- package/web/dist/assets/{MarketplaceDrawer-Dm-Z-YL8.js → MarketplaceDrawer-BIyJIDK4.js} +1 -1
- package/web/dist/assets/{TaskGraphDrawer-HaGRlpar.js → TaskGraphDrawer-C0eOFQ8c.js} +1 -1
- package/web/dist/assets/{WhatsNewDialog-9upxbs9b.js → WhatsNewDialog-Ci9pUKEP.js} +1 -1
- package/web/dist/assets/{WorkerModal-DAC0fORb.js → WorkerModal-DXHUZSN-.js} +1 -1
- package/web/dist/assets/WorkflowsDrawer-C5cS2jKY.js +1 -0
- package/web/dist/assets/{WorkspaceMemoryDrawer-QvVUM6qp.js → WorkspaceMemoryDrawer-BsAoM-lK.js} +1 -1
- package/web/dist/assets/{WorkspaceTaskDrawer-CdiraIBo.js → WorkspaceTaskDrawer-rLaXBrNl.js} +1 -1
- package/web/dist/assets/{index-B1vvo0-M.js → index-CTJnf-r_.js} +5 -5
- package/web/dist/assets/{search-DgMNPsfM.js → search-CbyBNPSq.js} +1 -1
- package/web/dist/assets/{square-terminal-CiDDFh5Z.js → square-terminal-eIii6bbw.js} +1 -1
- package/web/dist/index.html +1 -1
- package/web/dist/manifest.webmanifest +1 -1
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/WorkflowsDrawer-Dqv4vNZW.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable user-facing changes will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 2.1.12 - 2026-06-25
|
|
6
|
+
|
|
7
|
+
Default port and Pi agent support.
|
|
8
|
+
|
|
9
|
+
- Changes Hive's default local runtime port from `3000` to `9483`, reducing
|
|
10
|
+
collisions with common local development services while keeping `--port 0`
|
|
11
|
+
available for OS-assigned ports.
|
|
12
|
+
- Updates the local Supervisor MCP adapter and Vite dev proxy to follow the
|
|
13
|
+
same default port.
|
|
14
|
+
- Adds Pi as a built-in agent preset with `pi --approve`, including workflow
|
|
15
|
+
CLI policy support, prompt-readiness handling, and migration support for
|
|
16
|
+
existing Hive databases.
|
|
17
|
+
|
|
5
18
|
## 2.1.11 - 2026-06-25
|
|
6
19
|
|
|
7
20
|
Supervisor MCP bridge and terminal input polish.
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<img src="./assets/hive-hero.png" alt="Hive local-first multi-agent collaboration workspace hero image" />
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
**Run Claude Code, Codex, Gemini, OpenCode, Qwen, and other CLI agents as a visible local team.** Hive gives you one browser workbench where an
|
|
11
|
+
**Run Claude Code, Codex, Gemini, OpenCode, Qwen, Pi, and other CLI agents as a visible local team.** Hive gives you one browser workbench where an
|
|
12
12
|
Orchestrator plans and delegates while workers implement, review, test,
|
|
13
13
|
research, and report back — all as real PTY processes on your laptop.
|
|
14
14
|
|
|
@@ -48,7 +48,7 @@ awkward:
|
|
|
48
48
|
|
|
49
49
|
Hive adds the coordination layer without replacing the CLIs. The Orchestrator
|
|
50
50
|
is a real `agy` / `claude` / `codex` / `opencode` / `gemini` / `hermes` /
|
|
51
|
-
`qwen` process, not a scripted PM. Workers are real CLI agents too. Hive
|
|
51
|
+
`qwen` / `pi` process, not a scripted PM. Workers are real CLI agents too. Hive
|
|
52
52
|
injects a small `team` command into their shells, so they can dispatch,
|
|
53
53
|
report, and keep a shared markdown task graph at `<workspace>/.hive/tasks.md`.
|
|
54
54
|
|
|
@@ -117,8 +117,8 @@ Those warnings usually come from npm's install-script review plus native
|
|
|
117
117
|
binary setup for `node-pty`, `better-sqlite3`, and `esbuild`; they do not mean
|
|
118
118
|
Hive failed to install. The troubleshooting section below breaks them down.
|
|
119
119
|
|
|
120
|
-
Open the printed local URL, usually `http://127.0.0.1:
|
|
121
|
-
`hive --port
|
|
120
|
+
Open the printed local URL, usually `http://127.0.0.1:9483/`. Use
|
|
121
|
+
`hive --port 0` when you want Hive to ask the OS for any free local port.
|
|
122
122
|
|
|
123
123
|
To upgrade in place:
|
|
124
124
|
|
|
@@ -133,7 +133,7 @@ npm copy will shadow your existing install.
|
|
|
133
133
|
|
|
134
134
|
Install Hive as an app (optional):
|
|
135
135
|
|
|
136
|
-
Open `http://127.0.0.1:
|
|
136
|
+
Open `http://127.0.0.1:9483/` in Chrome, Edge, or Brave and click the install
|
|
137
137
|
icon at the right edge of the browser's omnibox. The PWA launches in its own
|
|
138
138
|
dock-anchored window without browser chrome and shows **Add Workspace** /
|
|
139
139
|
**Try Demo** shortcuts from the dock right-click menu. Firefox and Safari
|
|
@@ -143,8 +143,8 @@ only appears in Chromium-based browsers.
|
|
|
143
143
|
The Hive daemon must still be running for the PWA to do anything; if the
|
|
144
144
|
runtime isn't reachable when you launch the app, you'll see a "Hive runtime
|
|
145
145
|
is not running" page that auto-reloads once `hive` is back on `127.0.0.1`.
|
|
146
|
-
The PWA install scope is keyed by origin, so `hive --port
|
|
147
|
-
a separate app from `hive --port
|
|
146
|
+
The PWA install scope is keyed by origin, so `hive --port 9484` installs as
|
|
147
|
+
a separate app from `hive --port 9483`. To uninstall, visit `chrome://apps`,
|
|
148
148
|
right-click the Hive tile, and choose **Remove from Chrome…**.
|
|
149
149
|
|
|
150
150
|
Hive asks the browser to confirm before closing the tab or PWA window so an
|
|
@@ -220,6 +220,7 @@ Three details matter:
|
|
|
220
220
|
| Gemini | `gemini` | `--yolo` | `--resume <session_id>` |
|
|
221
221
|
| Hermes | `hermes` | `--yolo` | `--resume <session_id>` |
|
|
222
222
|
| Qwen Code | `qwen` | `--approval-mode yolo` | `--resume <session_id>` |
|
|
223
|
+
| Pi | `pi` | `--approve` | Session id capture not wired yet |
|
|
223
224
|
| Cursor CLI | `cursor` | `--force` | Session id capture not wired yet |
|
|
224
225
|
| Grok Build | `grok` | `--always-approve` | Session id capture not wired yet |
|
|
225
226
|
| Custom | Any executable | User configured | User configured |
|
|
@@ -232,7 +233,7 @@ same shell environment you use to start Hive.
|
|
|
232
233
|
| Tier | CLIs | Commitment |
|
|
233
234
|
| --- | --- | --- |
|
|
234
235
|
| Tier 1 | Claude Code, Codex | Minimum compatibility report in CI (`pnpm compat:cli:report`): Node 22, `node-pty`, `better-sqlite3`, and CLI version detection when installed. |
|
|
235
|
-
| Tier 2 | Gemini, OpenCode, Qwen Code, Hermes, Cursor CLI, Grok Build, Antigravity CLI | Built-in presets and manual smoke coverage; upstream CLI changes may require user reports before Hive catches up. |
|
|
236
|
+
| Tier 2 | Gemini, OpenCode, Qwen Code, Hermes, Pi, Cursor CLI, Grok Build, Antigravity CLI | Built-in presets and manual smoke coverage; upstream CLI changes may require user reports before Hive catches up. |
|
|
236
237
|
| Custom | Any executable | User-maintained command, args, and auth behavior. Hive preserves the PTY/session wrapper but cannot promise CLI-specific compatibility. |
|
|
237
238
|
|
|
238
239
|
## What Hive Provides
|
|
@@ -250,7 +251,8 @@ same shell environment you use to start Hive.
|
|
|
250
251
|
- Workflow CLI policy: choose the default CLI for workflow-created agents and
|
|
251
252
|
restrict which CLIs workflow scripts may launch.
|
|
252
253
|
- `.hive/tasks.md` editor with external-file conflict handling.
|
|
253
|
-
- Background PTY preservation and best-effort native session resume
|
|
254
|
+
- Background PTY preservation and best-effort native session resume for presets with
|
|
255
|
+
configured session capture.
|
|
254
256
|
- A What's New dialog after upgrades with curated release highlights.
|
|
255
257
|
- Local SQLite metadata under `%APPDATA%\hive` on Windows and `~/.config/hive`
|
|
256
258
|
on macOS / Linux by default, or `$HIVE_DATA_DIR` when set.
|
|
@@ -404,7 +406,7 @@ pnpm install
|
|
|
404
406
|
pnpm dev
|
|
405
407
|
```
|
|
406
408
|
|
|
407
|
-
Development mode runs the runtime on `127.0.0.1:
|
|
409
|
+
Development mode runs the runtime on `127.0.0.1:9483`; Vite runs on
|
|
408
410
|
`127.0.0.1:5180` and proxies API and WebSocket traffic to the runtime.
|
|
409
411
|
|
|
410
412
|
Useful checks:
|
|
@@ -419,7 +421,7 @@ Production-style local run:
|
|
|
419
421
|
|
|
420
422
|
```bash
|
|
421
423
|
pnpm build
|
|
422
|
-
node dist/src/cli/hive.js --port
|
|
424
|
+
node dist/src/cli/hive.js --port 9483
|
|
423
425
|
```
|
|
424
426
|
|
|
425
427
|
The production server serves the built web UI directly. No Vite server is
|
package/README.zh.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<img src="./assets/hive-hero.png" alt="Hive 本机多 agent 协作工作台" />
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
**Hive 是浏览器里的 Agent 协作工作台——一群 Agent 在你本机各自开工,一个当 Orchestrator 派活、归总进展,其余各司其职。** Orchestrator 本身就是一个真实的 `agy` / `claude` / `codex` / `opencode` / `gemini` / `hermes` / `qwen` 进程——不是你、也不是脚本——它派单的 Worker 同样是真 CLI agent。所有 agent 都是本机真实的 PTY 进程,通过 Hive 注入到 shell 里的小型 `team` 协议互相通信,共享 `<workspace>/.hive/tasks.md` 这份 markdown 任务图。
|
|
11
|
+
**Hive 是浏览器里的 Agent 协作工作台——一群 Agent 在你本机各自开工,一个当 Orchestrator 派活、归总进展,其余各司其职。** Orchestrator 本身就是一个真实的 `agy` / `claude` / `codex` / `opencode` / `gemini` / `hermes` / `qwen` / `pi` 进程——不是你、也不是脚本——它派单的 Worker 同样是真 CLI agent。所有 agent 都是本机真实的 PTY 进程,通过 Hive 注入到 shell 里的小型 `team` 协议互相通信,共享 `<workspace>/.hive/tasks.md` 这份 markdown 任务图。
|
|
12
12
|
|
|
13
13
|
写代码、做调研、起草文档、做翻译——凡是能拆给一群人协作的脑力活,都可以让一群 Agent 合伙干。
|
|
14
14
|
|
|
@@ -94,7 +94,7 @@ npm install -g @tt-a1i/hive --registry=https://registry.npmmirror.com
|
|
|
94
94
|
|
|
95
95
|
安装时如果看到 `npm warn allow-scripts` 或 `prebuild-install@7.1.3 deprecated`,先看最后是否显示 `added ... packages`。这些 warning 多数来自 npm 对安装脚本的安全审查,以及 `node-pty` / `better-sqlite3` / `esbuild` 这类原生依赖的二进制安装链路;不代表 Hive 启动失败。下面的故障排查里有逐项解释。
|
|
96
96
|
|
|
97
|
-
打开终端打印出来的本机地址,通常是 `http://127.0.0.1:
|
|
97
|
+
打开终端打印出来的本机地址,通常是 `http://127.0.0.1:9483/`。如果你想让系统自动分配一个空闲端口,可以用 `hive --port 0`。
|
|
98
98
|
|
|
99
99
|
升级到最新版本:
|
|
100
100
|
|
|
@@ -106,9 +106,9 @@ hive update
|
|
|
106
106
|
|
|
107
107
|
把 Hive 装为应用(可选):
|
|
108
108
|
|
|
109
|
-
在 Chrome / Edge / Brave 里打开 `http://127.0.0.1:
|
|
109
|
+
在 Chrome / Edge / Brave 里打开 `http://127.0.0.1:9483/`,点浏览器地址栏右侧的安装图标即可。装好后 Hive 会以独立窗口启动、有自己的 dock 图标,且 dock 右键菜单上会显示 **添加 Workspace** / **试用演示** 两个快捷入口。Firefox 和 Safari 暂未实现 PWA install-prompt 协议,浏览器地址栏的安装图标只在 Chromium 系浏览器里出现。
|
|
110
110
|
|
|
111
|
-
PWA 只是 UI 壳,Hive 后端仍需要在终端里跑着。如果启动 PWA 时后端没起,会看到 “Hive 后端未启动” 页面,等你跑起 `hive` 后会自动刷新。PWA 的 install scope 按 origin(含端口)划分,所以 `hive --port
|
|
111
|
+
PWA 只是 UI 壳,Hive 后端仍需要在终端里跑着。如果启动 PWA 时后端没起,会看到 “Hive 后端未启动” 页面,等你跑起 `hive` 后会自动刷新。PWA 的 install scope 按 origin(含端口)划分,所以 `hive --port 9484` 跟 `hive --port 9483` 在浏览器看来是两个独立应用。卸载方法:浏览器地址栏访问 `chrome://apps`,右键 Hive 图标,选 **从 Chrome 中移除…**。
|
|
112
112
|
|
|
113
113
|
关闭 PWA 窗口或 tab 时 Hive 会主动请求浏览器弹原生确认对话框,避免关闭快捷键(macOS 上是 Cmd+W、Windows / Linux 上是 Ctrl+W)误关丢失会话。但现代浏览器要求你跟页面"交互过"(点击 / 滚动 / 输入)才会真的弹这个对话框——刚打开 PWA 立刻按关闭快捷键仍会直接关闭,这是浏览器策略,不是 Hive 的 bug。
|
|
114
114
|
|
|
@@ -165,6 +165,7 @@ Workspace 任务图:
|
|
|
165
165
|
| Gemini | `gemini` | `--yolo` | `--resume <session_id>` |
|
|
166
166
|
| Hermes | `hermes` | `--yolo` | `--resume <session_id>` |
|
|
167
167
|
| Qwen Code | `qwen` | `--approval-mode yolo` | `--resume <session_id>` |
|
|
168
|
+
| Pi | `pi` | `--approve` | 暂未自动捕获 session id |
|
|
168
169
|
| Cursor CLI | `cursor` | `--force` | 暂未自动捕获 session id |
|
|
169
170
|
| Grok Build | `grok` | `--always-approve` | 暂未自动捕获 session id |
|
|
170
171
|
| 自定义 | 任意可执行文件 | 自己配 | 自己配 |
|
|
@@ -176,7 +177,7 @@ Hive 不替你安装这些 CLI。请在启动 Hive 的同一个 shell 环境里
|
|
|
176
177
|
| 分级 | CLI | 承诺 |
|
|
177
178
|
| --- | --- | --- |
|
|
178
179
|
| Tier 1 | Claude Code、Codex | CI 生成最小兼容报告(`pnpm compat:cli:report`):检查 Node 22、`node-pty`、`better-sqlite3`,并在本机已安装 CLI 时记录版本。 |
|
|
179
|
-
| Tier 2 | Gemini、OpenCode、Qwen Code、Hermes、Cursor CLI、Grok Build、Antigravity CLI | 内置 preset + 手动 smoke 覆盖;上游 CLI 行为变化可能需要用户报告后再跟进。 |
|
|
180
|
+
| Tier 2 | Gemini、OpenCode、Qwen Code、Hermes、Pi、Cursor CLI、Grok Build、Antigravity CLI | 内置 preset + 手动 smoke 覆盖;上游 CLI 行为变化可能需要用户报告后再跟进。 |
|
|
180
181
|
| Custom | 任意可执行命令 | 用户自己维护命令、参数和登录状态;Hive 只保证 PTY/session 包装,不承诺 CLI 专属兼容性。 |
|
|
181
182
|
|
|
182
183
|
## Hive 提供什么
|
|
@@ -188,7 +189,7 @@ Hive 不替你安装这些 CLI。请在启动 Hive 的同一个 shell 环境里
|
|
|
188
189
|
- Workflows(实验性,默认关闭):Orchestrator 可以运行多阶段、多 agent 的 workflow,Hive 在 Workflows 面板里展示运行、日志、结果、定时任务和停止控制。
|
|
189
190
|
- Workflow CLI 策略:为 workflow 创建的 agent 选择默认 CLI,并限制允许使用的 CLI,避免脚本误启未配置的 agent。
|
|
190
191
|
- `.hive/tasks.md` 编辑器,带外部文件冲突处理。
|
|
191
|
-
- PTY
|
|
192
|
+
- PTY 后台保留;对已配置 session capture 的预设,尽力使用对应 CLI 的原生 session 恢复。
|
|
192
193
|
- 升级后的 What's New 弹窗,用简短 release highlights 告诉你新版改了什么。
|
|
193
194
|
- 元数据存在本机 SQLite,Windows 默认在 `%APPDATA%\hive`,macOS / Linux 默认在 `~/.config/hive`,也可以通过 `$HIVE_DATA_DIR` 指定。
|
|
194
195
|
|
|
@@ -294,7 +295,7 @@ pnpm install
|
|
|
294
295
|
pnpm dev
|
|
295
296
|
```
|
|
296
297
|
|
|
297
|
-
开发模式下 runtime 跑在 `127.0.0.1:
|
|
298
|
+
开发模式下 runtime 跑在 `127.0.0.1:9483`,Vite 跑在 `127.0.0.1:5180`,把 API 和 WebSocket 代理到 runtime。
|
|
298
299
|
|
|
299
300
|
常用命令:
|
|
300
301
|
|
|
@@ -308,7 +309,7 @@ pnpm test
|
|
|
308
309
|
|
|
309
310
|
```bash
|
|
310
311
|
pnpm build
|
|
311
|
-
node dist/src/cli/hive.js --port
|
|
312
|
+
node dist/src/cli/hive.js --port 9483
|
|
312
313
|
```
|
|
313
314
|
|
|
314
315
|
Production 模式下 runtime 直接服务构建好的 web UI,不需要单独的 Vite。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_HIVE_PORT = 9483;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_HIVE_PORT = 9483;
|
package/dist/src/cli/hive-mcp.js
CHANGED
|
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
4
4
|
import { HIVE_SUPERVISOR_TOKEN_HEADER } from '../server/external-goal-auth.js';
|
|
5
5
|
import { readPackageVersion } from '../server/package-version.js';
|
|
6
6
|
import { sameFilesystemPath } from '../server/path-canonicalization.js';
|
|
7
|
+
import { DEFAULT_HIVE_PORT } from './hive-defaults.js';
|
|
7
8
|
export const HIVE_MCP_TOOL_NAMES = [
|
|
8
9
|
'hive.list_workspaces',
|
|
9
10
|
'hive.inspect_workspace',
|
|
@@ -80,7 +81,7 @@ const parseBaseUrl = (argv, env) => {
|
|
|
80
81
|
return env.HIVE_MCP_BASE_URL.replace(/\/$/u, '');
|
|
81
82
|
if (env.HIVE_PORT)
|
|
82
83
|
return `http://127.0.0.1:${env.HIVE_PORT}`;
|
|
83
|
-
return
|
|
84
|
+
return `http://127.0.0.1:${DEFAULT_HIVE_PORT}`;
|
|
84
85
|
};
|
|
85
86
|
const readHttpErrorDetail = async (response) => {
|
|
86
87
|
const text = await response.text().catch(() => '');
|
package/dist/src/cli/hive.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { type RemoteTunnel, type RemoteTunnelDeps } from '../server/remote-tunnel.js';
|
|
3
3
|
import { type RuntimeStore } from '../server/runtime-store.js';
|
|
4
4
|
import { type VersionService } from '../server/version-service.js';
|
|
5
|
+
import { DEFAULT_HIVE_PORT } from './hive-defaults.js';
|
|
5
6
|
interface RunHiveCommandResult {
|
|
6
7
|
port: number;
|
|
7
8
|
close: () => Promise<void>;
|
|
@@ -40,6 +41,7 @@ type RunHiveCommandOptions = {
|
|
|
40
41
|
* registration is mostly about giving SQLite a chance to checkpoint.
|
|
41
42
|
*/
|
|
42
43
|
export declare const SHUTDOWN_SIGNALS: readonly ["SIGINT", "SIGTERM", "SIGHUP", "SIGBREAK"];
|
|
44
|
+
export { DEFAULT_HIVE_PORT };
|
|
43
45
|
export declare const HIVE_USAGE: string;
|
|
44
46
|
export declare const handleHiveInfoCommand: (argv: string[]) => boolean;
|
|
45
47
|
/**
|
package/dist/src/cli/hive.js
CHANGED
|
@@ -13,6 +13,7 @@ import { createRemoteConfigSource } from '../server/remote-config-keys.js';
|
|
|
13
13
|
import { createRemoteTunnel, } from '../server/remote-tunnel.js';
|
|
14
14
|
import { createRuntimeStore } from '../server/runtime-store.js';
|
|
15
15
|
import { createVersionService } from '../server/version-service.js';
|
|
16
|
+
import { DEFAULT_HIVE_PORT } from './hive-defaults.js';
|
|
16
17
|
import { runHiveMcpCommand } from './hive-mcp.js';
|
|
17
18
|
import { runHiveRemoteCommand } from './hive-remote.js';
|
|
18
19
|
import { runHiveUpdateCommand } from './hive-update.js';
|
|
@@ -38,13 +39,14 @@ import { runHiveUpdateCommand } from './hive-update.js';
|
|
|
38
39
|
* registration is mostly about giving SQLite a chance to checkpoint.
|
|
39
40
|
*/
|
|
40
41
|
export const SHUTDOWN_SIGNALS = ['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGBREAK'];
|
|
42
|
+
export { DEFAULT_HIVE_PORT };
|
|
41
43
|
export const HIVE_USAGE = [
|
|
42
44
|
'Usage:',
|
|
43
45
|
' hive [--port <port>] [--no-open]',
|
|
44
46
|
' hive update',
|
|
45
47
|
'',
|
|
46
48
|
'Options:',
|
|
47
|
-
|
|
49
|
+
` --port <port> Bind the local runtime to a specific port (default: ${DEFAULT_HIVE_PORT}).`,
|
|
48
50
|
' --no-open Do not auto-open the browser after start.',
|
|
49
51
|
' -h, --help Print this help.',
|
|
50
52
|
' -v, --version Print the installed Hive version.',
|
|
@@ -89,7 +91,7 @@ const parsePort = (argv) => {
|
|
|
89
91
|
parsedPort = port;
|
|
90
92
|
index += 1;
|
|
91
93
|
}
|
|
92
|
-
return parsedPort ??
|
|
94
|
+
return parsedPort ?? DEFAULT_HIVE_PORT;
|
|
93
95
|
};
|
|
94
96
|
/**
|
|
95
97
|
* Resolve the directory where Hive persists its SQLite DB and supporting
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SessionIdCaptureConfig } from './session-capture.js';
|
|
2
|
-
export declare const BUILTIN_COMMAND_PRESET_IDS: readonly ["claude", "codex", "opencode", "gemini", "hermes", "qwen", "agy", "cursor", "grok"];
|
|
2
|
+
export declare const BUILTIN_COMMAND_PRESET_IDS: readonly ["claude", "codex", "opencode", "gemini", "hermes", "qwen", "pi", "agy", "cursor", "grok"];
|
|
3
3
|
export type BuiltinCommandPresetId = (typeof BUILTIN_COMMAND_PRESET_IDS)[number];
|
|
4
4
|
export interface BuiltinCommandPresetDefaults {
|
|
5
5
|
id: BuiltinCommandPresetId;
|
|
@@ -6,6 +6,7 @@ export const BUILTIN_COMMAND_PRESET_IDS = [
|
|
|
6
6
|
'gemini',
|
|
7
7
|
'hermes',
|
|
8
8
|
'qwen',
|
|
9
|
+
'pi',
|
|
9
10
|
'agy',
|
|
10
11
|
'cursor',
|
|
11
12
|
'grok',
|
|
@@ -15,6 +16,7 @@ const OPENCODE_DEFAULT_YOLO_ARGS = [];
|
|
|
15
16
|
const GEMINI_DEFAULT_YOLO_ARGS = ['--yolo'];
|
|
16
17
|
const HERMES_DEFAULT_YOLO_ARGS = ['--yolo'];
|
|
17
18
|
const QWEN_DEFAULT_YOLO_ARGS = ['--approval-mode', 'yolo'];
|
|
19
|
+
const PI_DEFAULT_YOLO_ARGS = ['--approve'];
|
|
18
20
|
const AGY_DEFAULT_YOLO_ARGS = ['--dangerously-skip-permissions'];
|
|
19
21
|
const CURSOR_DEFAULT_YOLO_ARGS = ['--force'];
|
|
20
22
|
const GROK_DEFAULT_YOLO_ARGS = ['--always-approve'];
|
|
@@ -85,6 +87,14 @@ export const BUILTIN_COMMAND_PRESETS = [
|
|
|
85
87
|
},
|
|
86
88
|
yoloArgsTemplate: QWEN_DEFAULT_YOLO_ARGS,
|
|
87
89
|
},
|
|
90
|
+
{
|
|
91
|
+
command: 'pi',
|
|
92
|
+
displayName: 'Pi',
|
|
93
|
+
id: 'pi',
|
|
94
|
+
resumeArgsTemplate: null,
|
|
95
|
+
sessionIdCapture: null,
|
|
96
|
+
yoloArgsTemplate: PI_DEFAULT_YOLO_ARGS,
|
|
97
|
+
},
|
|
88
98
|
{
|
|
89
99
|
command: 'agy',
|
|
90
100
|
displayName: 'Antigravity CLI',
|
|
@@ -39,6 +39,7 @@ const COMMANDS_WITH_BRACKETED_PASTE = new Set([
|
|
|
39
39
|
'grok',
|
|
40
40
|
'hermes',
|
|
41
41
|
'opencode',
|
|
42
|
+
'pi',
|
|
42
43
|
]);
|
|
43
44
|
const COMMANDS_WAITING_FOR_PASTE_ACK = new Set(['claude', 'codex']);
|
|
44
45
|
const BRACKETED_PASTE_END = '\u001b[201~';
|
|
@@ -84,6 +85,7 @@ const hasHermesPromptReady = (output) => {
|
|
|
84
85
|
return /\bWelcome to Hermes Agent![\s\S]*❯/u.test(plain);
|
|
85
86
|
};
|
|
86
87
|
const hasGrokPromptReady = (output) => /\b(?:Enter:send|Composer\s+\S+)/u.test(output);
|
|
88
|
+
const hasPiPromptReady = (output) => /\bpi\s+v\d+(?:\.\d+){1,3}[\s\S]*\b(?:escape\s+interrupt|ctrl\+c\/ctrl\+d\s+clear\/exit)\b/iu.test(getPlainTerminalTail(output));
|
|
87
89
|
const hasAgyPromptReady = (output) => /(?:^|\n)\s*>\s*\n\s*(?:[─-]{8,}|\?\s*for shortcuts)/u.test(getPlainTerminalOutput(output));
|
|
88
90
|
const getLastNonEmptyTerminalLine = (output) => {
|
|
89
91
|
const normalized = getPlainTerminalOutput(output);
|
|
@@ -138,6 +140,7 @@ const getInteractivePromptReadyState = (output, command = '') => {
|
|
|
138
140
|
(commandName === 'agy' && hasAgyPromptReady(output)) ||
|
|
139
141
|
(commandName === 'grok' && hasGrokPromptReady(output)) ||
|
|
140
142
|
(commandName === 'hermes' && hasHermesPromptReady(output)) ||
|
|
143
|
+
(commandName === 'pi' && hasPiPromptReady(output)) ||
|
|
141
144
|
((commandName === 'gemini' || commandName === 'qwen') && hasGeminiPromptReady(output))) {
|
|
142
145
|
return 'ready';
|
|
143
146
|
}
|
|
@@ -184,11 +187,12 @@ const canTimeoutBeforePromptReady = (command) => {
|
|
|
184
187
|
commandName !== 'gemini' &&
|
|
185
188
|
commandName !== 'hermes' &&
|
|
186
189
|
commandName !== 'opencode' &&
|
|
190
|
+
commandName !== 'pi' &&
|
|
187
191
|
commandName !== 'qwen');
|
|
188
192
|
};
|
|
189
193
|
const hasPromptReadyHardTimeout = (command) => {
|
|
190
194
|
const commandName = getCommandName(command);
|
|
191
|
-
return commandName === 'hermes' || commandName === 'opencode';
|
|
195
|
+
return commandName === 'hermes' || commandName === 'opencode' || commandName === 'pi';
|
|
192
196
|
};
|
|
193
197
|
const isWritableRunStatus = (status) => status === undefined || status === 'starting' || status === 'running';
|
|
194
198
|
const writeIfRunWritable = (agentManager, runId, text) => {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getBuiltinCommandPreset } from './command-preset-defaults.js';
|
|
2
|
+
export const applySchemaVersion38 = (db) => {
|
|
3
|
+
const hasCommandPresets = db
|
|
4
|
+
.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'command_presets'")
|
|
5
|
+
.get();
|
|
6
|
+
if (!hasCommandPresets)
|
|
7
|
+
return;
|
|
8
|
+
const preset = getBuiltinCommandPreset('pi');
|
|
9
|
+
if (!preset)
|
|
10
|
+
return;
|
|
11
|
+
const now = Date.now();
|
|
12
|
+
db.prepare(`INSERT INTO command_presets (
|
|
13
|
+
id, display_name, command, args, env, resume_args_template, session_id_capture,
|
|
14
|
+
yolo_args_template, is_builtin, created_at, updated_at
|
|
15
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)
|
|
16
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
17
|
+
display_name = excluded.display_name,
|
|
18
|
+
command = excluded.command,
|
|
19
|
+
args = excluded.args,
|
|
20
|
+
env = excluded.env,
|
|
21
|
+
resume_args_template = excluded.resume_args_template,
|
|
22
|
+
session_id_capture = excluded.session_id_capture,
|
|
23
|
+
yolo_args_template = excluded.yolo_args_template,
|
|
24
|
+
updated_at = excluded.updated_at
|
|
25
|
+
WHERE command_presets.is_builtin = 1`).run(preset.id, preset.displayName, preset.command, '[]', '{}', preset.resumeArgsTemplate, preset.sessionIdCapture ? JSON.stringify(preset.sessionIdCapture) : null, preset.yoloArgsTemplate ? JSON.stringify(preset.yoloArgsTemplate) : null, now, now);
|
|
26
|
+
};
|
|
@@ -30,7 +30,8 @@ import { applySchemaVersion34 } from './sqlite-schema-v34.js';
|
|
|
30
30
|
import { applySchemaVersion35 } from './sqlite-schema-v35.js';
|
|
31
31
|
import { applySchemaVersion36 } from './sqlite-schema-v36.js';
|
|
32
32
|
import { applySchemaVersion37 } from './sqlite-schema-v37.js';
|
|
33
|
-
|
|
33
|
+
import { applySchemaVersion38 } from './sqlite-schema-v38.js';
|
|
34
|
+
export const CURRENT_SCHEMA_VERSION = 38;
|
|
34
35
|
// Idempotent column-add helper. SQLite doesn't have `ALTER TABLE … ADD COLUMN
|
|
35
36
|
// IF NOT EXISTS`, so PRAGMA-check first. Safe to call on every init; required
|
|
36
37
|
// for foreign-built DBs where the version-gated migration is skipped.
|
|
@@ -444,4 +445,8 @@ export const initializeRuntimeDatabase = (db) => {
|
|
|
444
445
|
if (!appliedVersions.has(37)) {
|
|
445
446
|
db.prepare('INSERT INTO schema_version (version, applied_at) VALUES (?, ?)').run(37, Date.now());
|
|
446
447
|
}
|
|
448
|
+
applySchemaVersion38(db);
|
|
449
|
+
if (!appliedVersions.has(38)) {
|
|
450
|
+
db.prepare('INSERT INTO schema_version (version, applied_at) VALUES (?, ?)').run(38, Date.now());
|
|
451
|
+
}
|
|
447
452
|
};
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Hive worker report loop should not become workflow agent targets merely by
|
|
19
19
|
* existing in settings.
|
|
20
20
|
*/
|
|
21
|
-
export declare const CANONICAL_WORKFLOW_CLIS: readonly ["claude", "codex", "opencode", "gemini", "hermes", "qwen", "agy"];
|
|
21
|
+
export declare const CANONICAL_WORKFLOW_CLIS: readonly ["claude", "codex", "opencode", "gemini", "hermes", "qwen", "pi", "agy"];
|
|
22
22
|
export type WorkflowCli = (typeof CANONICAL_WORKFLOW_CLIS)[number];
|
|
23
23
|
export declare const WORKFLOW_CLI_POLICY_KEY = "workflow.cli-policy";
|
|
24
24
|
export interface WorkflowCliPolicy {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tt-a1i/hive",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "Run Claude Code, Codex, Gemini, OpenCode, Qwen, and other CLI agents as a visible local team in your browser.",
|
|
3
|
+
"version": "2.1.12",
|
|
4
|
+
"description": "Run Claude Code, Codex, Gemini, OpenCode, Qwen, Pi, and other CLI agents as a visible local team in your browser.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@10.30.3",
|
|
7
7
|
"license": "BUSL-1.1",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"clean": "node scripts/clean-build.mjs",
|
|
54
54
|
"dev": "pnpm dev:all",
|
|
55
55
|
"dev:all": "concurrently \"pnpm dev:runtime\" \"pnpm dev:web\"",
|
|
56
|
-
"dev:runtime": "tsx src/cli/hive.ts
|
|
56
|
+
"dev:runtime": "tsx src/cli/hive.ts",
|
|
57
57
|
"dev:web": "vite --config web/vite.config.ts",
|
|
58
58
|
"build": "pnpm clean && tsc -p tsconfig.build.json && node scripts/prepare-build-artifacts.mjs && pnpm build:web",
|
|
59
59
|
"build:web": "vite build --config web/vite.config.ts",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-
|
|
2
|
-
import{c as z,j as e,u as j,r as d,C as M,x as L,t as U,J as Y,Q as Z,ag as ee,ah as te,e as ae,i as re,R as se,P as ne,O as oe,k as le,m as ie,a0 as de,z as ce,X as me,T as xe,ai as ue}from"./index-B1vvo0-M.js";import{S as pe}from"./search-DgMNPsfM.js";import{S as he}from"./square-terminal-CiDDFh5Z.js";const fe=[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],ge=z("bookmark-plus",fe);const be=[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]],ve=z("dices",be);const ke=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],je=z("store",ke),ye=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"sentinel"},{value:"custom",dashed:!0}],I=t=>`role.${t}`,S=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),Ne=({active:t,spec:a,onSelect:n})=>{const{t:s}=j();return e.jsxs("button",{type:"button",onClick:n,"aria-pressed":t,"data-testid":`role-card-${a.value}`,className:`selectable-card${a.dashed?" selectable-card--dashed":""} flex items-center gap-3 px-3 py-2`,children:[e.jsx(ee,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:s(I(a.value))}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Ce=({onRoleChange:t,workerRole:a})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:n("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ye.map(s=>e.jsx(Ne,{active:a===s.value,spec:s,onSelect:()=>t(s.value)},s.value))})]})},we=({customTemplates:t,disabledReason:a,onDeleteTemplate:n,onSelect:s,selectedTemplateId:c})=>{const{t:o}=j(),[g,x]=d.useState(!1),[m,u]=d.useState(""),[b,k]=d.useState(null),y=d.useRef(null),N=d.useMemo(()=>t.find(r=>r.id===c)??null,[t,c]),v=d.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(p=>p.name.toLowerCase().includes(r)||p.description.toLowerCase().includes(r)):t},[t,m]);return d.useEffect(()=>{if(!g)return;const r=h=>{h.key==="Escape"&&x(!1)},p=h=>{const l=y.current;l&&!l.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",p),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",p)}},[g]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":g,"data-testid":"role-template-picker-trigger",onClick:()=>x(r=>!r),className:"flex w-full items-center justify-between gap-2 rounded border px-3 py-2 text-left text-sm transition-colors hover:bg-3",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-pri",children:N?N.name:o("addWorker.templatePickPlaceholder")}),e.jsx(M,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),g?e.jsxs("div",{role:"listbox","aria-label":o("addWorker.template"),"data-testid":"role-template-picker-menu",className:"elev-2 absolute left-0 right-0 top-full z-30 mt-1 flex max-h-72 flex-col overflow-hidden rounded border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-2 py-1.5",style:{borderColor:"var(--border)"},children:[e.jsx(pe,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,onChange:r=>u(r.currentTarget.value),placeholder:o("addWorker.templateSearchPlaceholder"),"data-testid":"role-template-search-input",className:"w-full bg-transparent text-sm text-pri outline-none placeholder:text-ter",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?e.jsx("div",{"data-testid":"role-template-empty-state",className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateEmpty")}):v.length===0?e.jsx("div",{className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateNoMatch")}):v.map(r=>{const p=r.id===c;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",role:"option","aria-selected":p,"data-testid":`role-template-option-${r.id}`,onClick:()=>{s(r.id),x(!1),u("")},className:"flex w-full items-center gap-2 px-3 py-1.5 pr-9 text-left text-sm text-pri hover:bg-3",style:p?{background:"var(--bg-3)"}:void 0,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),p?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]}),e.jsx("button",{type:"button","aria-label":o("addWorker.templateDeleteAria",{name:r.name}),"data-testid":`role-template-delete-${r.id}`,disabled:!!a,title:a??void 0,onClick:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(r)},className:"absolute right-1 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-ter transition-colors hover:bg-3 hover:text-pri",children:e.jsx(U,{size:14,"aria-hidden":!0})})]},r.id)})}),c!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{s(null),x(!1),u("")},className:"border-t px-3 py-1.5 text-left text-sm text-ter transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border)"},children:o("addWorker.templateClear")}):null]}):null]}),e.jsx(Y,{open:b!==null,onOpenChange:r=>{r||k(null)},title:o("addWorker.templateDeleteTitle"),description:b?o("addWorker.templateDeleteConfirm",{name:b.name}):"",confirmLabel:o("addWorker.templateDeleteConfirmLabel"),confirmKind:"danger",onConfirm:()=>{if(!b||a)return;const r=b.id;k(null),n(r)}})]})},We=({canSaveAsTemplate:t,modified:a,onChange:n,onReset:s,onSaveAsTemplate:c,roleDescription:o,templateBusy:g,workerRole:x,writeDisabledReason:m})=>{const{t:u,language:b}=j(),[k,y]=d.useState(!1),[N,v]=d.useState(!1),[r,p]=d.useState("");d.useEffect(()=>{(x==="custom"||a)&&y(!0)},[a,x]),d.useEffect(()=>{t||(v(!1),p(""))},[t]);const h=b==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{open:k,onToggle:l=>y(l.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(M,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:u("addWorker.roleInstructions")}),a?e.jsxs("span",{className:"text-xs text-ter",children:["· ",u("addWorker.modifiedFrom",{role:u(I(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[k?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:h}),t&&!N?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:l=>{l.preventDefault(),l.stopPropagation(),v(!0)},className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium transition-colors hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--accent)",background:"color-mix(in oklab, var(--accent) 14%, transparent)"},children:[e.jsx(ge,{size:12,"aria-hidden":!0}),u("addWorker.saveAsTemplate")]}):null,a?e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:l=>{l.preventDefault(),l.stopPropagation(),s()},children:[e.jsx(Z,{size:12,"aria-hidden":!0}),u("addWorker.reset")]}):null]})]}),e.jsx("textarea",{"aria-label":"Role instructions",id:"add-worker-role-instructions",value:o,rows:5,onChange:l=>n(l.currentTarget.value),placeholder:x==="custom"?u("addWorker.customPlaceholder"):void 0,title:u("addWorker.roleInstructionsTitle"),className:"input mono resize-y text-sm",style:{minHeight:150},"data-testid":"role-instructions-textarea"}),t&&N?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:r,onChange:l=>p(l.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:g||!r.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const l=r.trim();if(l)try{await c(l),v(!1),p("")}catch{}},className:"icon-btn icon-btn--primary text-xs",children:u("addWorker.templateSaveConfirm")}),e.jsx("button",{type:"button","data-testid":"role-template-save-cancel",onClick:()=>{v(!1),p("")},className:"icon-btn text-xs",children:u("common.cancel")})]}):null]})},D=({active:t,command:a,displayName:n,logoPresetId:s,notFound:c=!1,testId:o,onSelect:g})=>{const{t:x}=j(),m=e.jsx("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-border bg-surface-1 text-ter","data-testid":`${o}-generic-icon`,"aria-hidden":!0,children:e.jsx(he,{size:13})});return e.jsxs("button",{type:"button",onClick:g,"aria-pressed":t,"data-testid":o,className:"selectable-card flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(te,{commandPresetId:s,fallback:m,size:22}),e.jsxs("span",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[e.jsx("span",{className:"truncate text-base font-medium text-pri",children:n}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,c?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Se=({active:t,preset:a,onSelect:n})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:n}),ze=({commandPresetId:t,commandPresets:a,onPresetChange:n})=>{const{t:s}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:s("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:s("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2 max-md:grid-cols-1",children:[a.map(c=>e.jsx(Se,{active:t===c.id,preset:c,onSelect:()=>n(c.id)},c.id)),e.jsx(D,{active:t==="",command:s("addWorker.genericCommand"),displayName:s("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>n("")})]})]})},Me=({onChange:t,value:a})=>{const{t:n,language:s}=j(),[c,o]=d.useState(!1),g=a.trim(),x=s==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{onToggle:m=>o(m.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(M,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:n("addWorker.startupCommand")}),g?e.jsxs("span",{className:"truncate text-xs text-ter",children:["· ",n("addWorker.startupOverrides")]}):null]}),c?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:x})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded border bg-2 p-3",style:{borderColor:"var(--border)"},children:[e.jsx("input",{"aria-label":"Startup command",value:a,onChange:m=>t(m.currentTarget.value),placeholder:"qwen --model qwen3-coder",className:"input mono text-sm",spellCheck:!1}),e.jsx("p",{className:"text-sm leading-5 text-ter",children:n("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Le=d.lazy(()=>ue(()=>import("./MarketplaceDrawer-Dm-Z-YL8.js"),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:n=!1,customTemplates:s,onApplyMarketplaceImport:c,onClose:o,onDeleteTemplate:g,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:b,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:N,onStartupCommandChange:v,onSubmit:r,onTemplateChange:p,roleDescription:h,roleDescriptionDefault:l,selectedTemplateId:P,startupCommand:E,templateBusy:B,workerName:O,workerRole:W,writeDisabledReason:w})=>{const{t:i}=j(),_=ae(),C=re(),[q,A]=d.useState(!1),[H,K]=d.useState(!1),V=d.useMemo(()=>new Set(s.map(f=>f.name)),[s]),Q=f=>{c(f),_.show({kind:"success",message:i("marketplace.imported",{name:f.name})})},J=f=>{f||o()},X=h!==l,$=t.find(f=>f.id===a),T=E.trim(),G=()=>w||(O.trim()?!a&&!T?i("addWorker.pickCliOrStartup"):$?.available===!1&&!T?i("addWorker.unavailable",{name:$.displayName}):h.trim()?null:i("addWorker.emptyInstructions"):i("addWorker.enterName")),R=f=>{const F=G();if(F){f.preventDefault(),_.show({kind:"warning",message:F});return}r(f)};return e.jsxs(se,{open:!0,onOpenChange:J,children:[e.jsxs(ne,{children:[e.jsx(oe,{"data-testid":"add-worker-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4 max-md:items-end max-md:p-0",children:e.jsx(le,{"data-testid":"add-worker-content","data-mobile":C||void 0,className:`${C?"dialog-slide-up add-worker-sheet":"dialog-scale-pop"} elev-2 pointer-events-auto flex max-h-[calc(100vh-32px)] w-[560px] max-w-full flex-col overflow-hidden rounded-lg border pointer-coarse:max-h-[85dvh] max-md:w-full max-md:rounded-b-none max-md:rounded-t-xl`,style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)",...C?{height:"85dvh"}:{}},children:e.jsxs("form",{onSubmit:R,"aria-label":i("addWorker.title"),className:"flex min-h-0 flex-1 flex-col overflow-hidden max-h-full",children:[e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-3 border-b px-5 py-4 max-md:px-4",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx(ie,{className:"text-lg font-semibold text-pri",children:i("addWorker.title")}),e.jsx(de,{className:"text-sm text-ter",children:i("addWorker.description",{command:"team send"})})]}),C?e.jsx(ce,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":i("common.closeDialog"),"data-testid":"add-worker-close",className:"-mr-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-sec",style:{background:"var(--bg-2)"},children:e.jsx(me,{size:18,"aria-hidden":!0})})}):null]}),e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col gap-4 overflow-y-auto px-5 py-4 max-md:gap-5 max-md:px-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:i("addWorker.name")}),e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{autoFocus:!C,value:O,onChange:f=>x(f.target.value),placeholder:i("addWorker.namePlaceholder"),className:"input w-full pr-24",style:{borderRadius:"10px"}}),e.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",children:e.jsx(xe,{label:i("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":i("addWorker.randomAria"),className:"flex h-7 items-center gap-1.5 rounded-lg border border-bright/10 bg-3 px-2.5 text-xs font-semibold text-sec hover:text-pri hover:bg-4 active:scale-95 transition-all outline-none",onClick:u,"data-testid":"random-worker-name",children:[e.jsx(ve,{size:13,"aria-hidden":!0}),e.jsx("span",{children:i("addWorker.random")})]})})})]})]}),e.jsx(Ce,{workerRole:W,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{K(!0),A(!0)},"data-testid":"open-marketplace",className:"marketplace-browse-btn flex cursor-pointer items-center gap-2 self-start rounded-lg border px-3 py-2 text-xs font-semibold text-sec outline-none transition-all duration-200 hover:text-pri hover:-translate-y-0.5 active:scale-98 shadow-sm hover:shadow-md",style:{background:"linear-gradient(to bottom, var(--bg-1), var(--bg-0))",borderColor:"var(--border-bright)","--tw-ring-color":"color-mix(in oklab, var(--accent) 45%, transparent)"},children:[e.jsx(je,{size:14,"aria-hidden":!0,className:"text-accent"}),e.jsx("span",{children:i("marketplace.openFromAddWorker")})]}),W==="custom"?e.jsx(we,{customTemplates:s,disabledReason:w,onDeleteTemplate:g,onSelect:p,selectedTemplateId:P}):null,e.jsx(We,{canSaveAsTemplate:W==="custom"&&!P&&h.trim().length>0,modified:X,onChange:b,onReset:k,onSaveAsTemplate:N,roleDescription:h,templateBusy:B,workerRole:W,writeDisabledReason:w}),e.jsx(ze,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(Me,{value:E,onChange:v})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3 max-md:px-4 max-md:pb-[max(12px,env(safe-area-inset-bottom))]",style:{borderColor:"var(--border)",background:"var(--bg-2)"},children:[e.jsx("button",{type:"button",onClick:o,className:`icon-btn border border-bright/20 rounded-lg hover:bg-3 hover:text-pri transition-all active:scale-95 ${C?"flex-1":""}`,"data-testid":"add-worker-cancel",children:i("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:n||!!w,title:w??void 0,className:`icon-btn icon-btn--primary rounded-lg font-bold shadow-md hover:shadow-lg transition-all active:scale-[0.97] hover:-translate-y-0.5 ${C?"flex-[2]":""}`,"data-testid":"add-worker-submit",children:i(n?"addWorker.creating":"addWorker.create")})]})]})})})]}),H?e.jsx(d.Suspense,{fallback:null,children:e.jsx(Le,{open:q,onClose:()=>A(!1),onImport:Q,importedNames:V})}):null]})};export{_e as AddWorkerDialog};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-BIyJIDK4.js","assets/index-CTJnf-r_.js","assets/index-DYIPzuPD.css","assets/search-CbyBNPSq.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as z,j as e,u as j,r as d,C as M,x as L,t as U,J as Y,Q as Z,ag as ee,ah as te,e as ae,i as re,R as se,P as ne,O as oe,k as le,m as ie,a0 as de,z as ce,X as me,T as xe,ai as ue}from"./index-CTJnf-r_.js";import{S as pe}from"./search-CbyBNPSq.js";import{S as he}from"./square-terminal-eIii6bbw.js";const fe=[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],ge=z("bookmark-plus",fe);const be=[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]],ve=z("dices",be);const ke=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],je=z("store",ke),ye=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"sentinel"},{value:"custom",dashed:!0}],I=t=>`role.${t}`,S=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),Ne=({active:t,spec:a,onSelect:n})=>{const{t:s}=j();return e.jsxs("button",{type:"button",onClick:n,"aria-pressed":t,"data-testid":`role-card-${a.value}`,className:`selectable-card${a.dashed?" selectable-card--dashed":""} flex items-center gap-3 px-3 py-2`,children:[e.jsx(ee,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:s(I(a.value))}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Ce=({onRoleChange:t,workerRole:a})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:n("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ye.map(s=>e.jsx(Ne,{active:a===s.value,spec:s,onSelect:()=>t(s.value)},s.value))})]})},we=({customTemplates:t,disabledReason:a,onDeleteTemplate:n,onSelect:s,selectedTemplateId:c})=>{const{t:o}=j(),[g,x]=d.useState(!1),[m,u]=d.useState(""),[b,k]=d.useState(null),y=d.useRef(null),N=d.useMemo(()=>t.find(r=>r.id===c)??null,[t,c]),v=d.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(p=>p.name.toLowerCase().includes(r)||p.description.toLowerCase().includes(r)):t},[t,m]);return d.useEffect(()=>{if(!g)return;const r=h=>{h.key==="Escape"&&x(!1)},p=h=>{const l=y.current;l&&!l.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",p),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",p)}},[g]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":g,"data-testid":"role-template-picker-trigger",onClick:()=>x(r=>!r),className:"flex w-full items-center justify-between gap-2 rounded border px-3 py-2 text-left text-sm transition-colors hover:bg-3",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-pri",children:N?N.name:o("addWorker.templatePickPlaceholder")}),e.jsx(M,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),g?e.jsxs("div",{role:"listbox","aria-label":o("addWorker.template"),"data-testid":"role-template-picker-menu",className:"elev-2 absolute left-0 right-0 top-full z-30 mt-1 flex max-h-72 flex-col overflow-hidden rounded border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-2 py-1.5",style:{borderColor:"var(--border)"},children:[e.jsx(pe,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,onChange:r=>u(r.currentTarget.value),placeholder:o("addWorker.templateSearchPlaceholder"),"data-testid":"role-template-search-input",className:"w-full bg-transparent text-sm text-pri outline-none placeholder:text-ter",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?e.jsx("div",{"data-testid":"role-template-empty-state",className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateEmpty")}):v.length===0?e.jsx("div",{className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateNoMatch")}):v.map(r=>{const p=r.id===c;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",role:"option","aria-selected":p,"data-testid":`role-template-option-${r.id}`,onClick:()=>{s(r.id),x(!1),u("")},className:"flex w-full items-center gap-2 px-3 py-1.5 pr-9 text-left text-sm text-pri hover:bg-3",style:p?{background:"var(--bg-3)"}:void 0,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),p?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]}),e.jsx("button",{type:"button","aria-label":o("addWorker.templateDeleteAria",{name:r.name}),"data-testid":`role-template-delete-${r.id}`,disabled:!!a,title:a??void 0,onClick:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(r)},className:"absolute right-1 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-ter transition-colors hover:bg-3 hover:text-pri",children:e.jsx(U,{size:14,"aria-hidden":!0})})]},r.id)})}),c!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{s(null),x(!1),u("")},className:"border-t px-3 py-1.5 text-left text-sm text-ter transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border)"},children:o("addWorker.templateClear")}):null]}):null]}),e.jsx(Y,{open:b!==null,onOpenChange:r=>{r||k(null)},title:o("addWorker.templateDeleteTitle"),description:b?o("addWorker.templateDeleteConfirm",{name:b.name}):"",confirmLabel:o("addWorker.templateDeleteConfirmLabel"),confirmKind:"danger",onConfirm:()=>{if(!b||a)return;const r=b.id;k(null),n(r)}})]})},We=({canSaveAsTemplate:t,modified:a,onChange:n,onReset:s,onSaveAsTemplate:c,roleDescription:o,templateBusy:g,workerRole:x,writeDisabledReason:m})=>{const{t:u,language:b}=j(),[k,y]=d.useState(!1),[N,v]=d.useState(!1),[r,p]=d.useState("");d.useEffect(()=>{(x==="custom"||a)&&y(!0)},[a,x]),d.useEffect(()=>{t||(v(!1),p(""))},[t]);const h=b==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{open:k,onToggle:l=>y(l.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(M,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:u("addWorker.roleInstructions")}),a?e.jsxs("span",{className:"text-xs text-ter",children:["· ",u("addWorker.modifiedFrom",{role:u(I(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[k?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:h}),t&&!N?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:l=>{l.preventDefault(),l.stopPropagation(),v(!0)},className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium transition-colors hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--accent)",background:"color-mix(in oklab, var(--accent) 14%, transparent)"},children:[e.jsx(ge,{size:12,"aria-hidden":!0}),u("addWorker.saveAsTemplate")]}):null,a?e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:l=>{l.preventDefault(),l.stopPropagation(),s()},children:[e.jsx(Z,{size:12,"aria-hidden":!0}),u("addWorker.reset")]}):null]})]}),e.jsx("textarea",{"aria-label":"Role instructions",id:"add-worker-role-instructions",value:o,rows:5,onChange:l=>n(l.currentTarget.value),placeholder:x==="custom"?u("addWorker.customPlaceholder"):void 0,title:u("addWorker.roleInstructionsTitle"),className:"input mono resize-y text-sm",style:{minHeight:150},"data-testid":"role-instructions-textarea"}),t&&N?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:r,onChange:l=>p(l.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:g||!r.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const l=r.trim();if(l)try{await c(l),v(!1),p("")}catch{}},className:"icon-btn icon-btn--primary text-xs",children:u("addWorker.templateSaveConfirm")}),e.jsx("button",{type:"button","data-testid":"role-template-save-cancel",onClick:()=>{v(!1),p("")},className:"icon-btn text-xs",children:u("common.cancel")})]}):null]})},D=({active:t,command:a,displayName:n,logoPresetId:s,notFound:c=!1,testId:o,onSelect:g})=>{const{t:x}=j(),m=e.jsx("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-border bg-surface-1 text-ter","data-testid":`${o}-generic-icon`,"aria-hidden":!0,children:e.jsx(he,{size:13})});return e.jsxs("button",{type:"button",onClick:g,"aria-pressed":t,"data-testid":o,className:"selectable-card flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(te,{commandPresetId:s,fallback:m,size:22}),e.jsxs("span",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[e.jsx("span",{className:"truncate text-base font-medium text-pri",children:n}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,c?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Se=({active:t,preset:a,onSelect:n})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:n}),ze=({commandPresetId:t,commandPresets:a,onPresetChange:n})=>{const{t:s}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:s("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:s("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2 max-md:grid-cols-1",children:[a.map(c=>e.jsx(Se,{active:t===c.id,preset:c,onSelect:()=>n(c.id)},c.id)),e.jsx(D,{active:t==="",command:s("addWorker.genericCommand"),displayName:s("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>n("")})]})]})},Me=({onChange:t,value:a})=>{const{t:n,language:s}=j(),[c,o]=d.useState(!1),g=a.trim(),x=s==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{onToggle:m=>o(m.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(M,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:n("addWorker.startupCommand")}),g?e.jsxs("span",{className:"truncate text-xs text-ter",children:["· ",n("addWorker.startupOverrides")]}):null]}),c?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:x})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded border bg-2 p-3",style:{borderColor:"var(--border)"},children:[e.jsx("input",{"aria-label":"Startup command",value:a,onChange:m=>t(m.currentTarget.value),placeholder:"qwen --model qwen3-coder",className:"input mono text-sm",spellCheck:!1}),e.jsx("p",{className:"text-sm leading-5 text-ter",children:n("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Le=d.lazy(()=>ue(()=>import("./MarketplaceDrawer-BIyJIDK4.js"),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:n=!1,customTemplates:s,onApplyMarketplaceImport:c,onClose:o,onDeleteTemplate:g,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:b,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:N,onStartupCommandChange:v,onSubmit:r,onTemplateChange:p,roleDescription:h,roleDescriptionDefault:l,selectedTemplateId:P,startupCommand:E,templateBusy:B,workerName:O,workerRole:W,writeDisabledReason:w})=>{const{t:i}=j(),_=ae(),C=re(),[q,A]=d.useState(!1),[H,K]=d.useState(!1),V=d.useMemo(()=>new Set(s.map(f=>f.name)),[s]),Q=f=>{c(f),_.show({kind:"success",message:i("marketplace.imported",{name:f.name})})},J=f=>{f||o()},X=h!==l,$=t.find(f=>f.id===a),T=E.trim(),G=()=>w||(O.trim()?!a&&!T?i("addWorker.pickCliOrStartup"):$?.available===!1&&!T?i("addWorker.unavailable",{name:$.displayName}):h.trim()?null:i("addWorker.emptyInstructions"):i("addWorker.enterName")),R=f=>{const F=G();if(F){f.preventDefault(),_.show({kind:"warning",message:F});return}r(f)};return e.jsxs(se,{open:!0,onOpenChange:J,children:[e.jsxs(ne,{children:[e.jsx(oe,{"data-testid":"add-worker-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4 max-md:items-end max-md:p-0",children:e.jsx(le,{"data-testid":"add-worker-content","data-mobile":C||void 0,className:`${C?"dialog-slide-up add-worker-sheet":"dialog-scale-pop"} elev-2 pointer-events-auto flex max-h-[calc(100vh-32px)] w-[560px] max-w-full flex-col overflow-hidden rounded-lg border pointer-coarse:max-h-[85dvh] max-md:w-full max-md:rounded-b-none max-md:rounded-t-xl`,style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)",...C?{height:"85dvh"}:{}},children:e.jsxs("form",{onSubmit:R,"aria-label":i("addWorker.title"),className:"flex min-h-0 flex-1 flex-col overflow-hidden max-h-full",children:[e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-3 border-b px-5 py-4 max-md:px-4",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx(ie,{className:"text-lg font-semibold text-pri",children:i("addWorker.title")}),e.jsx(de,{className:"text-sm text-ter",children:i("addWorker.description",{command:"team send"})})]}),C?e.jsx(ce,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":i("common.closeDialog"),"data-testid":"add-worker-close",className:"-mr-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-sec",style:{background:"var(--bg-2)"},children:e.jsx(me,{size:18,"aria-hidden":!0})})}):null]}),e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col gap-4 overflow-y-auto px-5 py-4 max-md:gap-5 max-md:px-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:i("addWorker.name")}),e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{autoFocus:!C,value:O,onChange:f=>x(f.target.value),placeholder:i("addWorker.namePlaceholder"),className:"input w-full pr-24",style:{borderRadius:"10px"}}),e.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",children:e.jsx(xe,{label:i("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":i("addWorker.randomAria"),className:"flex h-7 items-center gap-1.5 rounded-lg border border-bright/10 bg-3 px-2.5 text-xs font-semibold text-sec hover:text-pri hover:bg-4 active:scale-95 transition-all outline-none",onClick:u,"data-testid":"random-worker-name",children:[e.jsx(ve,{size:13,"aria-hidden":!0}),e.jsx("span",{children:i("addWorker.random")})]})})})]})]}),e.jsx(Ce,{workerRole:W,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{K(!0),A(!0)},"data-testid":"open-marketplace",className:"marketplace-browse-btn flex cursor-pointer items-center gap-2 self-start rounded-lg border px-3 py-2 text-xs font-semibold text-sec outline-none transition-all duration-200 hover:text-pri hover:-translate-y-0.5 active:scale-98 shadow-sm hover:shadow-md",style:{background:"linear-gradient(to bottom, var(--bg-1), var(--bg-0))",borderColor:"var(--border-bright)","--tw-ring-color":"color-mix(in oklab, var(--accent) 45%, transparent)"},children:[e.jsx(je,{size:14,"aria-hidden":!0,className:"text-accent"}),e.jsx("span",{children:i("marketplace.openFromAddWorker")})]}),W==="custom"?e.jsx(we,{customTemplates:s,disabledReason:w,onDeleteTemplate:g,onSelect:p,selectedTemplateId:P}):null,e.jsx(We,{canSaveAsTemplate:W==="custom"&&!P&&h.trim().length>0,modified:X,onChange:b,onReset:k,onSaveAsTemplate:N,roleDescription:h,templateBusy:B,workerRole:W,writeDisabledReason:w}),e.jsx(ze,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(Me,{value:E,onChange:v})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3 max-md:px-4 max-md:pb-[max(12px,env(safe-area-inset-bottom))]",style:{borderColor:"var(--border)",background:"var(--bg-2)"},children:[e.jsx("button",{type:"button",onClick:o,className:`icon-btn border border-bright/20 rounded-lg hover:bg-3 hover:text-pri transition-all active:scale-95 ${C?"flex-1":""}`,"data-testid":"add-worker-cancel",children:i("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:n||!!w,title:w??void 0,className:`icon-btn icon-btn--primary rounded-lg font-bold shadow-md hover:shadow-lg transition-all active:scale-[0.97] hover:-translate-y-0.5 ${C?"flex-[2]":""}`,"data-testid":"add-worker-submit",children:i(n?"addWorker.creating":"addWorker.create")})]})]})})})]}),H?e.jsx(d.Suspense,{fallback:null,children:e.jsx(Le,{open:q,onClose:()=>A(!1),onImport:Q,importedNames:V})}):null]})};export{_e as AddWorkerDialog};
|