dsh-hive-panel 1.0.10 → 1.0.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 CHANGED
@@ -4,6 +4,44 @@ All notable changes to this project are documented in this file. The format is
4
4
  based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project
5
5
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.0.12] - 2026-12-05
8
+
9
+ ### Fixed
10
+
11
+ - **Repository isolation is enforced end to end.** The injected queen prompt gains a
12
+ dynamic repository-scope line naming the Session's absolute root (two Sessions in
13
+ different repositories receive different contracts), and every snapshot/action is
14
+ bound to the session cwd: a repo/repoPath/cwd parameter is accepted only when it
15
+ resolves to that same root, any other value (including a relative .. escape) is
16
+ rejected before execution with `hive/foreign-repo`. The UI reads the supervisor's
17
+ `crossRepoBlocked` / `lastCrossRepoBlocked` and shows a toast plus a tooltip line
18
+ naming the blocked tool, the requested repository and the only allowed cwd.
19
+ - Two plugin-owned invariants are added: act only on summaries/tasks/anomalies/worker
20
+ Sessions of your own repository, and call the Hive tools inside `run_code` as
21
+ `await tools.hive_*` under the PTC preset. The role cap rises 24576 -> 32768 so the
22
+ growing contract no longer truncates the workspace role file.
23
+
24
+ ### Tests
25
+
26
+ - 48 checks cover the per-repository injection, foreign-repo query/body rejection with
27
+ zero spawn, the panel-side rejection toast/tooltip (en + zh) and the 32768 role cap.
28
+
29
+ ## [1.0.11] - 2026-12-05
30
+
31
+ ### Changed
32
+
33
+ - Renderer and stylesheet re-synced from hive-panel 1.0.6: the supervisor heartbeat now
34
+ shows a semantic state — green normal, amber paused, grey unresponsive — with an
35
+ explanatory tooltip and the last-seen time. Browser bundle rebuilt.
36
+
37
+ ### Tests
38
+
39
+ - 43 checks pass, including the synced heartbeat states and the rebuilt client.
40
+
41
+ ### Published
42
+
43
+ - npm: `dsh-hive-panel@1.0.11` on 2026-12-05.
44
+
7
45
  ## [1.0.10] - 2026-12-05
8
46
 
9
47
  ### Fixed
@@ -18,6 +56,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
18
56
 
19
57
  - 43 checks pass, including the worker Session skip and the unchanged queen paths.
20
58
 
59
+ ### Published
60
+
61
+ - npm: `dsh-hive-panel@1.0.10` on 2026-12-05.
62
+
21
63
  ## [1.0.9] - 2026-12-05
22
64
 
23
65
  ### Fixed
package/README.md CHANGED
@@ -279,13 +279,22 @@ supervisor registration happens on the same first assembly.
279
279
  Session audit log. The security boundary is the Session sandbox plus the host-side
280
280
  action allowlist; `writable: true` hands the panel repo-scoped command ability. Keep it
281
281
  `false` when you only need to watch.
282
+ - Every snapshot/action is bound to the Session's own repository: `repo`/`repoPath`/`cwd`
283
+ parameters may only echo that root, and a cross-repository value is rejected with
284
+ `hive/foreign-repo` before any command runs (the panel toast shows the reason). The queen's
285
+ injected contract names its absolute repository root and only that repository; when the
286
+ supervisor blocks a queen `hive_*` call for another repository, the panel surfaces that
287
+ rejection (tool, requested repo, allowed cwd) as a toast and in the supervisor tooltip.
282
288
  - The queen role text comes from `<repo>/.hive/roles/queen.md` and is treated as
283
289
  low-trust input: it is labelled as untrusted, has a built-in coordinator fallback and is
284
- capped at 24576 characters. A plugin-owned **trusted invariants** block is always injected
290
+ capped at 32768 characters. A plugin-owned **trusted invariants** block is always injected
285
291
  above it (never call `subagent`/`subagent_fork`/`subagent_claude_code` or execution tools to
286
292
  implement; never call `write`/`edit`/`apply_patch`/`bash`/`cua` or any file-mutating or
287
293
  command-executing tool; tasks and state use only `hive_*` tools; `claim`/`done`/`fail` are
288
- worker actions the queen must not call; implementation is delegated to the supervisor). The
294
+ worker actions the queen must not call; implementation is delegated to the supervisor). It
295
+ also scopes the queen to its own repository (other repositories' digests/tasks are ignored)
296
+ and explains that under the PTC preset the Hive tools are reached inside `run_code` with
297
+ `await tools.hive_*`, not by assuming the tools are missing. The
289
298
  Card-worker Sessions are never injected or registered as the queen (the supervisor's
290
299
  `isWorkerSession(sessionId)`, or the parent/queen and subagent header markers), so they keep
291
300
  their normal write/edit/bash tools. The tool-boundary sentence is injected in English and
package/README.zh-CN.md CHANGED
@@ -203,7 +203,8 @@ DSH 宿主进程
203
203
  - 浏览器只能选动作名和合法的参数值。host 侧为每个动作构造固定命令,参数逐项校验、作为单个 token 加引号,绝不拼进 shell 语法。
204
204
  - 命令经 DSH 的 shell 执行层执行:当前 Session 的 sandbox 策略、凭证擦除、超时、输出上限和取消都会生效。插件自己不 spawn 进程。
205
205
  - 面板触发的动作**不经过审批**,也不写进会话审计。安全边界是「当前 Session sandbox + host 侧动作白名单」;`writable: true` 相当于把仓库范围内的命令能力交给这个看板。只需要看时保持 `false`。
206
- - 女王角色文本来自 `<repo>/.hive/roles/queen.md`,按低信任输入处理:带不可信标注、缺失时用内置的协调者兜底、总长上限 24576 字符。
206
+ - 女王角色文本来自 `<repo>/.hive/roles/queen.md`,按低信任输入处理:带不可信标注、缺失时用内置的协调者兜底、总长上限 32768 字符。插件自有 invariants 还会限定女王只处理本仓库的摘要/任务(其他仓库忽略),并说明 PTC 预设下 Hive 工具需在 `run_code` 里用 `await tools.hive_*` 调用。
207
+ - 仓库隔离逐层生效:快照/动作只认 `sessionId` 对应会话的 cwd,`repo`/`repoPath`/`cwd` 参数只允许回显该根目录,其他仓库在执行前返回 `hive/foreign-repo`(面板 toast 显示原因);女王注入文本会写明「你只能操作根目录为 <绝对 cwd> 的这一个仓库」;supervisor 拒绝女王跨仓 `hive_*` 调用时,面板用 toast 和 supervisor tooltip 显示被拒的 tool、请求仓库与允许的 cwd。
207
208
  - 要把 DSH Web 暴露到本机之外,先在 DSH 层做认证或反向代理。
208
209
 
209
210
  ## 开发
package/SPEC.md CHANGED
@@ -66,10 +66,18 @@ Requests:
66
66
  | unknown `op` | `400 { ok:false, error:{ code:'hive/unknown-op', message } }` |
67
67
  | wrong method | `405` |
68
68
  | invalid JSON body (op=action) | `400 { ok:false, code:2, stdout:'', stderr:'hive/invalid-body: …' }` |
69
+ | `repo` / `repoPath` / `cwd` parameter naming another repository | snapshot/actions: `400 { ok:false, error:{ code:'hive/foreign-repo', message } }`; action: `400 { ok:false, code:2, stdout:'', stderr:'hive/foreign-repo: …' }` |
69
70
 
70
71
  `name=queen-on` and `name=queen-off` are accepted in read-only mode because they only
71
72
  touch host memory.
72
73
 
74
+ **Repository binding.** Every request is bound to the `sessionId` it names: the host
75
+ resolves that Session's cwd and never accepts a path from the client. A `repo`, `repoPath`
76
+ or `cwd` query/body parameter is allowed only when it resolves to the same repository root
77
+ (clients may echo the snapshot's `repo`); any other value — including a relative path that
78
+ escapes with `..` — is rejected with `hive/foreign-repo` before any shell command runs. The
79
+ action envelope carries that code in `stderr`, so the panel toast shows the reason.
80
+
73
81
  ## 4. Snapshot
74
82
 
75
83
  The snapshot is assembled from fixed CLI reads and file reads in the Session cwd and always
@@ -362,7 +370,7 @@ assembly (see Activation 1), renders role + invariants for the marked Session an
362
370
  string for every other Session. It does not enter the conversation history.
363
371
 
364
372
  Role text: `<cwd>/.hive/roles/queen.md`, prefixed with an "untrusted role file" label
365
- naming the absolute source path, capped at 24576 characters and marked `[truncated]`
373
+ naming the absolute source path, capped at 32768 characters and marked `[truncated]`
366
374
  when cut; a built-in fallback is labelled when the file is missing. Between the label and the
367
375
  workspace body the plugin always injects a **trusted invariants** block (`QUEEN_INVARIANTS`):
368
376
  never call `subagent`/`subagent_fork`/`subagent_claude_code` or execution tools to implement;
@@ -371,6 +379,22 @@ command-executing tool; tasks and state use only `hive_*` tools; `claim`/`done`/
371
379
  worker actions the queen must not call; implementation is delegated to the supervisor. The
372
380
  tool-boundary sentence is injected in English and Chinese, so a repository initialised by an
373
381
  older `hive init` (whose role file predates this contract) gets it without re-running init.
382
+ Two more invariants ride the same block: **scope** (act only on this repository's summaries,
383
+ tasks, anomalies and worker Sessions; ignore every other repository) and **tool calling under
384
+ the PTC preset** (the Hive tools may not be exposed directly — call them inside `run_code`
385
+ as `await tools.hive_*`, e.g. `await tools.hive_tasks({ action: "list" })`; not seeing a
386
+ directly exposed tool does not mean the tool is missing). Both are injected in English and
387
+ Chinese as well.
388
+
389
+ A per-Session **repository scope line** follows the static invariants and names the absolute
390
+ root: "you may only operate on the repository rooted at `<cwd>`; reject and ignore every
391
+ hive_* call, task, card, digest, worker Session or supervisor request that names another
392
+ repository". Two Sessions in different repositories therefore receive different injected
393
+ contracts. When the mounted supervisor blocks a queen `hive_*` call for naming another
394
+ repository, it records `crossRepoBlocked` / `lastCrossRepoBlocked { tool, repo, cwd, at }`
395
+ in `/api/hive-runner?op=status`; the panel renders that rejection as a toast and in the
396
+ supervisor tooltip (tool, requested repo, allowed cwd), so the human sees the reason and not
397
+ only the backend refusal.
374
398
  Goals become Hive tasks and the supervisor dispatches them; discussion creates tasks only when
375
399
  the human asks to execute. The block is plugin-owned and cannot be overridden by the workspace file.
376
400
  The fallback and the exit hint both carry the coordinator contract (fine-grained tasks,
package/docs/DESIGN.md CHANGED
@@ -171,6 +171,13 @@ interface ConnectionFetchRoute {
171
171
  | 未知 `op` | `400 { ok:false, error:{ code:'hive/unknown-op', message } }` |
172
172
 
173
173
  - `sessionId` 缺失/无法解析(活会话也没有 `sessionPersistence` 记录)返回 400。
174
+ - **仓库绑定(逐层隔离)**:任何请求只认 `sessionId` → 该会话 cwd;`repo`/`repoPath`/`cwd`
175
+ 查询或 body 参数只有解析后等于该 cwd 才接受(客户端可回显 snapshot 的 `repo`),其他值
176
+ (含 `..` 逃逸)在 spawn 前返回 `hive/foreign-repo`:snapshot/actions 是 error JSON,动作进入
177
+ `stderr`(面板 toast 显示被拒原因)。
178
+ - **UI 显示跨仓拒绝**:面板读 `/api/hive-runner?op=status` 的 `crossRepoBlocked` /
179
+ `lastCrossRepoBlocked { tool, repo, cwd, at }`;出现新拒绝时弹 toast(含工具、请求仓库、
180
+ 允许的 cwd),并写进 supervisor 条目的 tooltip,而不只是后端 tool result 里报错。
174
181
  - 方法不匹配返回 405;JSON body 非法返回 400,动作请求仍保持 `{ ok, code, stdout, stderr }` 形状。
175
182
  - 快照里的 `writable` 来自插件配置(默认 `false`),与 `hive-panel` 的只读语义一致。
176
183
  - 快照里的 `queen` 是 host 内存状态:`{ active: boolean, source: 'auto'|'manual'|null, repo }`;
@@ -332,7 +339,12 @@ token(PATH 名或绝对路径)。
332
339
  人类明确要执行时建任务)——旧版 `hive init` 写出的工作区角色文件无法覆盖它,因此生产红线不依赖
333
340
  仓库是否重新 init。invariants 另含**工具边界**(中英各一句):禁止 `write`/`edit`/`apply_patch`/
334
341
  `bash`/`cua` 等修改文件或执行命令的工具,任务与状态只用 `hive_*` 工具,`claim`/`done`/`fail` 是
335
- worker 动作女王不得调用,实现交给 supervisor;这样老仓库不重跑 init 也能拿到该边界。总长 **≤ 24576 字符**;超长截断并标注
342
+ worker 动作女王不得调用,实现交给 supervisor;**仓库范围**(只处理自己仓库的摘要/任务/异常/worker 会话,
343
+ 其他仓库一律忽略)与 **PTC 工具调用方式**(Hive 工具可能不直接暴露,在 `run_code` 里用
344
+ `await tools.hive_*` 调用,例如 `await tools.hive_tasks({ action: "list" })`;看不到直接工具≠工具不存在),
345
+ 中英各一句;这样老仓库不重跑 init 也能拿到该边界。每次注入还会在 invariants 后追加**动态仓库范围行**
346
+ `formatRepoScope(cwd)`,写明“你只能操作根目录为 "<绝对 cwd>" 的这一个仓库”,不同仓库会话拿到不同文本。
347
+ 总长 **≤ 32768 字符**;超长截断并标注
336
348
  `[truncated]`。文件缺失时用内置兜底角色,并标注 `missing; built-in fallback`;兜底与退出提示
337
349
  都写明协调者契约(细粒度卡、每卡必须有验收命令、排序/监督/审查/汇报,永不写码)。
338
350
  - **不污染会话日志**:不 append 自定义 session 事件(第三方未知事件会让 resume 拒绝解释日志),
@@ -417,7 +429,7 @@ ctx.uiWorkspace.openSession(address /* SubagentAddress */)
417
429
  | `ctx.systemPrompt.section` 行号 `:485-495` | 实际 `:485` 起;`assemble()` 在 `:621` | 一致 |
418
430
  | `commands.register` 未给行号 | `dsh-commands/src/index.ts:285`,返回同步 disposer | 已在 queen 中显式 dispose |
419
431
  | 女王端点样例是独立路由 `/api/hive-panel/queen` | 本实现折叠进单一路由 `/api/hive?op=action&name=init\|queen-on\|queen-off` | 少一条路由;语义不变 |
420
- | 女王角色上限 24 KiB | 本实现与之一致:**24576 字符**(含来源标注/退出提示) | 与协调者任务契约一致 |
432
+ | 女王角色上限 24 KiB | 本实现提高到 **32768 字符**(32 KiB,含来源标注/退出提示) | 契约增长后不再截断 |
421
433
  | “用 `resolveCore` 解析 hive 二进制” | host 侧无自动解析;本实现用受信配置 `bins` 或 PATH(`hive`/`hive-tasks`/`hive-run`/`moc`) | 找不到命令时返回干净的非 0 退出码与 stderr,不假装成功 |
422
434
  | 组合位置行号 | `dsh-base/cordis.patch.yml`:agent `:82`、commands `:321`、system-prompt `:528`、subprocess `:234`、sandbox `:240`、sandbox-policy `:243`、bash-sandbox `:249`、shell-env `:278`;`dsh-web-app/cordis.patch.yml`:connection `:238`、tool-bash disabled `:517` | 文档行号一致;`ctx.shell` 在 host 平面,第三方 bundle patch 可直接 inject |
423
435
 
@@ -447,7 +459,7 @@ npm run check
447
459
  # ok - node --check lib/queen.js
448
460
  # ok - node --check lib/client.js
449
461
  # ...
450
- # 43 checks passed
462
+ # 48 checks passed
451
463
  ```
452
464
 
453
465
  覆盖:语法、package/bundle 声明、无代理残留、client bundle 的 `/api/hive` URL 与 Session 注入、
@@ -463,9 +475,13 @@ Connection Fetch 路由注册、快照走 `ctx.shell` 且 cwd/policy 正确、
463
475
  (含 `QUEEN_INVARIANTS`、supervisor 幂等登记、跨仓库隔离)、`/queen off` 后不注入、
464
476
  `autoQueen=false` 不注入、未初始化仓库不注入;prompt/init/queen-on 路径对
465
477
  `hiveSupervisor.addRepo` 的登记(幂等去重、只登记有 queen.md 的仓库、退出与卸载不删除);
466
- invariants 的工具边界断言(write/edit/apply_patch/bash/cua/claim、hive_*、中英两句);
478
+ invariants 的工具边界与范围/工具调用断言(write/edit/apply_patch/bash/cua/claim、hive_*、
479
+ own repository/其他仓库、run_code + await tools.hive_*、32768 上限与 40k 截断);
467
480
  worker 会话跳过注入/登记(supervisor `isWorkerSession` 优先与 `parentSession===queen` 兜底),
468
- 配套集成验证真实 runner 的 queen guard 放行 worker 的 write、仍拦截 queen 的 write。
481
+ 配套集成验证真实 runner 的 queen guard 放行 worker 的 write、仍拦截 queen 的 write;
482
+ 跨仓库隔离(两个会话各自注入/查询自己的仓库根、互不泄漏)、`repo`/`repoPath`/`cwd` 跨仓参数
483
+ 被拒(snapshot/actions 的 error JSON、动作的 stderr 原因、拒绝前零 spawn)、面板把 runner
484
+ `crossRepoBlocked`/`lastCrossRepoBlocked` 渲染成 toast/tooltip 理由。
469
485
 
470
486
  不启动、不重启任何 DSH 进程,也不写运行中的 `~/.dsh`。
471
487