dsh-hive-runner 0.6.4 → 0.6.7
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 +112 -0
- package/README.md +42 -13
- package/README.zh-CN.md +24 -9
- package/SPEC.md +95 -31
- package/cordis.patch.yml +14 -2
- package/docs/DESIGN.md +48 -3
- package/index.js +22 -0
- package/lib/commands.js +16 -9
- package/lib/config.js +27 -1
- package/lib/host-env.js +51 -22
- package/lib/http.js +18 -1
- package/lib/round.js +385 -121
- package/lib/runs.js +77 -4
- package/lib/supervisor.js +56 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,114 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
7
7
|
Version 0.6.0 is the first public snapshot; 0.1.0-0.5.0 were local development
|
|
8
8
|
iterations of the plugin before this repository was published.
|
|
9
9
|
|
|
10
|
+
## [0.6.7] - 2026-12-04
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Card workers are now parented to the **queen conversation** — the Session where the
|
|
15
|
+
panel was initialised and the queen took over. The panel registers that Session id
|
|
16
|
+
with the supervisor (`POST /api/hive-runner?op=queen { sessionId }`, or the
|
|
17
|
+
`hiveSupervisor.setQueenSession()` service), and every worker activation uses exactly
|
|
18
|
+
that parent, so the subagents appear in the user's own queen session instead of a
|
|
19
|
+
hidden session or an arbitrary live agent.
|
|
20
|
+
- Nothing is dispatched before that registration: the supervisor skips the round and
|
|
21
|
+
status reports `waiting: no-queen-session` per repository (and at the top level),
|
|
22
|
+
which is a startup-order hint, not an error. It never falls back to another Session.
|
|
23
|
+
- `status` exposes `queenSessionId` and the workers of each repository keep their
|
|
24
|
+
`sessionId`/`parentSource: "queen"`; last-run records carry `parentSource: "queen"`
|
|
25
|
+
as well.
|
|
26
|
+
- Requires `dsh-hive-panel` 0.2.3 or newer: its init/queen activation registers the
|
|
27
|
+
queen Session and every panel snapshot re-registers it after a plugin restart.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [0.6.6] - 2026-12-04
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- Follows hive-consensus 1.5.0's announcement board: `hive claim` and `hive guard`
|
|
35
|
+
never block, so the runner no longer fails a card when another agent already
|
|
36
|
+
announced the same or a related path. `hive guard --json` overlaps are parsed,
|
|
37
|
+
logged (`card <id> in <repo> overlaps: ...`), kept on the last-run record and
|
|
38
|
+
treated as information: the worker keeps working and merge-on-commit three-way
|
|
39
|
+
merges the concurrent edits at commit time (unresolved conflicts stay as markers).
|
|
40
|
+
- Worker prompt rewritten for announcements: announce every scope entry (including
|
|
41
|
+
`resource:` keys) with `hive guard --task <card id>` before starting — the task id
|
|
42
|
+
ties the worker's own announcement to the card, so a retry or a re-announcement never
|
|
43
|
+
reports itself as an overlap — treat overlaps as information
|
|
44
|
+
only, and keep the release/lesson/commit/finish rules. The old "guard exits 2" stop
|
|
45
|
+
rule, the `HIVE_AGENT`-on-every-command rule and the "lease enforcement skipped"
|
|
46
|
+
warning are gone; the repository hook is owned by merge-on-commit and needs no
|
|
47
|
+
environment variable for a commit.
|
|
48
|
+
- Every per-card Hive command now runs with `HIVE_INSTANCE=<card id>` (claim, guard,
|
|
49
|
+
done, fail, release, renew), and the worker activation injects the same value, so
|
|
50
|
+
concurrent workers of one runner are distinct announcers and their overlaps surface
|
|
51
|
+
instead of being mistaken for the announcer itself.
|
|
52
|
+
- Lessons are now a pair: before dispatch `hive recall` runs for every scope path plus
|
|
53
|
+
the repository root and the deduplicated matches lead the worker prompt
|
|
54
|
+
(`## Recalled experience (hive recall)`); after the work, workers write genuinely new
|
|
55
|
+
knowledge with `hive lesson add`. A read error is logged and recorded on the run
|
|
56
|
+
record, never a card failure.
|
|
57
|
+
- Last-run records carry the optional `overlaps` array (`{ key, agent, task,
|
|
58
|
+
expiresAt }`, valid entries only, at most 100) on the opening `running` write and the
|
|
59
|
+
terminal write, and the `lessons` summary (`{ count, scopes, error? }`) the panel
|
|
60
|
+
reads to show how many lessons were read.
|
|
61
|
+
|
|
62
|
+
### Fixed
|
|
63
|
+
|
|
64
|
+
- The last-run record's `output` is now the worker's **final result message** only:
|
|
65
|
+
the text blocks of the last assistant message. Reasoning/thinking blocks, tool calls
|
|
66
|
+
and the narration around them are stripped, and the provider diagnostic is no longer
|
|
67
|
+
appended (the card verdict already carries the failure reason). If a provider returns
|
|
68
|
+
no typed text block, the last non-empty text is used as a fallback; a run with no
|
|
69
|
+
text at all falls back to the card verdict. The 200-line/32-KiB cap is unchanged.
|
|
70
|
+
|
|
71
|
+
### Removed
|
|
72
|
+
|
|
73
|
+
- The consensus claim-expiry abort: the `leaseCheckMs` config key and
|
|
74
|
+
`DEFAULT_LEASE_CHECK_MS` export, the claim-deadline interval and the lease-expiry
|
|
75
|
+
failure branch. The hard `cardTimeoutMs` remains; the claim deadline stays as status
|
|
76
|
+
observability only.
|
|
77
|
+
- The `hive/no-hive-agent-env` deferrable error and the hook-warning detection it fed
|
|
78
|
+
(hive-consensus 1.5.0 emits no such warnings).
|
|
79
|
+
|
|
80
|
+
### Tests
|
|
81
|
+
|
|
82
|
+
- 124 `node:test` scenarios: announcement overlaps never block a card and are
|
|
83
|
+
logged/recorded, guard CLI problems only warn, per-card `HIVE_INSTANCE` injection,
|
|
84
|
+
lesson reads for every scope path and the repository root, run records with
|
|
85
|
+
`overlaps`/`lessons`, and the unchanged freeze-mode skip.
|
|
86
|
+
|
|
87
|
+
## [0.6.5] - 2026-12-04
|
|
88
|
+
|
|
89
|
+
### Fixed
|
|
90
|
+
|
|
91
|
+
- Every card now has a hard wall-clock timeout (`cardTimeoutMs`, default 15 min).
|
|
92
|
+
At the deadline the worker is aborted, the card is recorded failed, and its
|
|
93
|
+
leases are released, so a stuck worker can no longer stay "running" forever.
|
|
94
|
+
- While a card is in flight its claim lease is checked every `leaseCheckMs`
|
|
95
|
+
(default 1 s); an expired claim immediately aborts the worker, fails the card
|
|
96
|
+
and releases the leases.
|
|
97
|
+
- The running last-run record is refreshed as soon as the worker activation is
|
|
98
|
+
accepted: it carries `sessionId`/`agentName` while the card is still in progress,
|
|
99
|
+
not only after the terminal write. Panels can therefore open the worker chat for a
|
|
100
|
+
card that is currently running instead of waiting for done/failed.
|
|
101
|
+
- Status exposes the live `workers` of each repository with `cardId`, `sessionId`,
|
|
102
|
+
`agentName`, `startedAt`, `lastOutputAt`, `heartbeat`, `claimDeadline` and
|
|
103
|
+
`timeoutAt`, so the panel can jump to the worker session and show a stuck card.
|
|
104
|
+
- Heartbeat: while a worker runs, the repository HEAD is used as the observable
|
|
105
|
+
output signal. No movement for `heartbeatWarnMs` (default 5 min) marks the
|
|
106
|
+
worker `heartbeat: "warn"` in status and the last-run record and logs a warning.
|
|
107
|
+
|
|
108
|
+
### Added
|
|
109
|
+
|
|
110
|
+
- Config keys `cardTimeoutMs`, `heartbeatWarnMs`, `heartbeatIntervalMs` and
|
|
111
|
+
`leaseCheckMs` (all defaulted; see `cordis.patch.yml`).
|
|
112
|
+
|
|
113
|
+
### Changed
|
|
114
|
+
|
|
115
|
+
- Default claim TTL raised from `5m` to `20m` so the new 15-minute card timeout fits
|
|
116
|
+
inside a claim; set `ttl` ≥ `cardTimeoutMs` if you override either.
|
|
117
|
+
|
|
10
118
|
## [0.6.4] - 2026-12-04
|
|
11
119
|
|
|
12
120
|
### Added
|
|
@@ -19,6 +127,10 @@ iterations of the plugin before this repository was published.
|
|
|
19
127
|
failure records keep them. Records without an activation stay byte-identical
|
|
20
128
|
to the previous shape.
|
|
21
129
|
|
|
130
|
+
### Published
|
|
131
|
+
|
|
132
|
+
- npm: `dsh-hive-runner@0.6.4` on 2026-12-04.
|
|
133
|
+
|
|
22
134
|
## [0.6.3] - 2026-12-04
|
|
23
135
|
|
|
24
136
|
### Added
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ per-role worker limits you set in the Hive panel.
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
20
|
[Hive](https://github.com/d86e/hive) coordinates a swarm of coding agents inside git: task
|
|
21
|
-
cards with acceptance commands,
|
|
21
|
+
cards with acceptance commands, path announcements, a presence board and a commit-time
|
|
22
22
|
merge, all stored as refs and files in the repository itself. The
|
|
23
23
|
[hive-runner](https://github.com/d86e/hive-runner) CLI runs **one** round and exits.
|
|
24
24
|
|
|
@@ -44,16 +44,38 @@ the plugin never spawns processes outside the harness.
|
|
|
44
44
|
early is recorded as failed in Hive; the rest of the queue continues.
|
|
45
45
|
- If a repository keeps failing, it backs off and is auto-paused after three consecutive
|
|
46
46
|
failures. Paused repositories never resume by themselves.
|
|
47
|
-
- Workers follow the Hive consensus protocol:
|
|
48
|
-
with `hive guard`
|
|
49
|
-
and
|
|
50
|
-
|
|
47
|
+
- Workers follow the Hive consensus announcement protocol: before a worker starts, the
|
|
48
|
+
supervisor announces the card's scope with `hive guard` (every scope entry, including
|
|
49
|
+
`resource:` keys) and clears those announcements afterwards. An overlap with another
|
|
50
|
+
agent's announcement is advisory only: the worker keeps working, and merge-on-commit
|
|
51
|
+
three-way merges the concurrent edits at commit time (unresolved conflicts stay as
|
|
52
|
+
markers).
|
|
53
|
+
- Lessons are read before every card and written after it: the supervisor runs
|
|
54
|
+
`hive recall` for every scope path plus the repository root and injects the
|
|
55
|
+
deduplicated matches at the top of the worker prompt; workers record genuinely new
|
|
56
|
+
knowledge with `hive lesson add`. Writing a lesson and reading it at the start of the
|
|
57
|
+
next card are a pair — one without the other does not compound.
|
|
51
58
|
- Commits are verified against merge-on-commit: the repository must have the
|
|
52
59
|
merge-on-commit pre-commit hook (`hive init` installs it), and a card only counts as
|
|
53
60
|
done when HEAD moved through that hook.
|
|
54
61
|
- While the repository is in Hive freeze mode, non-fix cards stay on the board instead of
|
|
55
62
|
failing.
|
|
56
63
|
|
|
64
|
+
## Worker sessions
|
|
65
|
+
|
|
66
|
+
Workers run in the **queen conversation**: the Session where you opened the Hive panel
|
|
67
|
+
and finished `hive init` (or where the queen took over). The panel registers that
|
|
68
|
+
Session with the supervisor, and from then on every card worker is parented to it — the
|
|
69
|
+
workers show up as subagents in that same conversation, so you can open them from your
|
|
70
|
+
own session.
|
|
71
|
+
|
|
72
|
+
- Nothing is dispatched before the queen Session is registered: status reports
|
|
73
|
+
`waiting: no-queen-session`, a startup-order hint rather than an error.
|
|
74
|
+
- The supervisor keeps using exactly that registered Session; it never switches to a
|
|
75
|
+
different chat.
|
|
76
|
+
- Once registered, dispatch works with zero other user sessions and keeps running when
|
|
77
|
+
the panel/UI is closed.
|
|
78
|
+
|
|
57
79
|
## Requirements
|
|
58
80
|
|
|
59
81
|
- DSH 0.2.2-rc.5 with the `desktop` or `web` profile — the version the plugin is
|
|
@@ -63,8 +85,10 @@ the plugin never spawns processes outside the harness.
|
|
|
63
85
|
are called by their PATH names by default and retried through `npx` when the shell
|
|
64
86
|
cannot find them; `tasksBin`/`hiveBin` pin an explicit executable instead.
|
|
65
87
|
- Repositories already initialised with Hive (`hive init`), unless you enable discovery.
|
|
66
|
-
- The [Hive panel](https://github.com/d86e/dsh-hive-panel)
|
|
67
|
-
|
|
88
|
+
- The [Hive panel](https://github.com/d86e/dsh-hive-panel) **0.2.3 or newer**. It
|
|
89
|
+
registers the queen conversation when you initialise the repository there (and
|
|
90
|
+
re-registers it on every panel access); without that registration the supervisor
|
|
91
|
+
waits and dispatches nothing.
|
|
68
92
|
|
|
69
93
|
## Install
|
|
70
94
|
|
|
@@ -92,7 +116,7 @@ DSH 0.2.2-rc.5):
|
|
|
92
116
|
<details>
|
|
93
117
|
<summary>Manual profile edit (same result, only needed when the CLI is unavailable)</summary>
|
|
94
118
|
|
|
95
|
-
While DSH Desktop is not running, add `"dsh-hive-runner": "^0.6.
|
|
119
|
+
While DSH Desktop is not running, add `"dsh-hive-runner": "^0.6.7"` to the profile's
|
|
96
120
|
`dependencies`, add `dsh-hive-runner` to `dsh.profile.bundles`, then
|
|
97
121
|
`cd ~/.dsh/profiles/desktop && pnpm install`.
|
|
98
122
|
|
|
@@ -145,7 +169,10 @@ Runner tab. Pause stops new work from being scheduled; cards that are already ru
|
|
|
145
169
|
finish, and resume makes the repository eligible again on the next tick.
|
|
146
170
|
|
|
147
171
|
The panel also shows, per role, the configured limit, how many workers are live right now,
|
|
148
|
-
and how many cards are waiting for a slot.
|
|
172
|
+
and how many cards are waiting for a slot. For a running card it exposes the worker
|
|
173
|
+
Session (so you can open that conversation), the start time and a heartbeat warning when
|
|
174
|
+
the worker has produced no commit/output for a while; stuck cards are aborted and failed
|
|
175
|
+
at `cardTimeoutMs` (default 15 minutes).
|
|
149
176
|
|
|
150
177
|
## How many bees should I set?
|
|
151
178
|
|
|
@@ -175,10 +202,12 @@ accepted as plugin `config`. User-facing keys:
|
|
|
175
202
|
| `discoverRoots` | `[]` | Roots to scan when auto-discovering; empty = parents of `repos` |
|
|
176
203
|
| `intervalMs` / `idleBackoffMs` | `30000` / `120000` | How often to look for work / how long to wait when a repository is empty |
|
|
177
204
|
| `maxConcurrentRepos` | `2` | How many repositories may work at the same time |
|
|
205
|
+
| `cardTimeoutMs` | `900000` | Hard limit per card: abort the worker and fail the card at the deadline |
|
|
206
|
+
| `heartbeatWarnMs` / `heartbeatIntervalMs` | `300000` / `30000` | Mark a running worker as heartbeat-warn after this long without output / how often to check |
|
|
178
207
|
| `roleConcurrency` | `{ coder: 5, tester: 5 }` | Initial/fallback per-role worker limits |
|
|
179
208
|
| `defaultRoleConcurrency` | `5` | Fallback for roles not listed in `roleConcurrency` |
|
|
180
209
|
| `paused` | `[]` | Repositories paused at startup (absolute paths) |
|
|
181
|
-
| `agent` / `ttl` | `dsh` / `
|
|
210
|
+
| `agent` / `ttl` | `dsh` / `20m` | Identity and claim TTL for claims (raise `ttl` for very large waiting queues) |
|
|
182
211
|
| `provider` | `spawn` | DSH subagent provider used for workers |
|
|
183
212
|
| `parentSession` | `null` | Optional live session used as the parent for workers |
|
|
184
213
|
| `tasksBin` / `hiveBin` | `null` | Explicit `hive-tasks` / `hive` executables (PATH name or absolute path). Default: the PATH name, retried once through `npx -y -p hive-tasks` / `npx -y -p hive-consensus` when missing |
|
|
@@ -228,7 +257,7 @@ applicable sandbox policy.
|
|
|
228
257
|
| --- | --- | --- |
|
|
229
258
|
| [hive](https://github.com/d86e/hive) | One CLI entry point: init, roles, tasks, run, board, commit, doctor | The supervisor reads state and cards through the Hive CLIs |
|
|
230
259
|
| [hive-tasks](https://github.com/d86e/hive-tasks) | Task cards with dependencies, priority and acceptance | Ready cards are fetched, claimed, completed or failed through it |
|
|
231
|
-
| [hive-consensus](https://github.com/d86e/hive-consensus) | Path
|
|
260
|
+
| [hive-consensus](https://github.com/d86e/hive-consensus) | Path announcements, presence board, freeze mode, shared lessons | `hive guard` publishes each worker's paths; overlaps are advisory and merge-on-commit resolves the concurrent writes |
|
|
232
261
|
| [hive-runner](https://github.com/d86e/hive-runner) | One execution round per invocation (`hive-run --once`) | This plugin uses the same round primitives, resident and DSH-native |
|
|
233
262
|
| [merge-on-commit](https://github.com/d86e/merge-on-commit) | Three-way merge at commit time | Workers' commits go through the repository hook like any other commit |
|
|
234
263
|
| [hive-panel](https://github.com/d86e/hive-panel) | Standalone read-only board outside DSH | Not needed; [dsh-hive-panel](https://github.com/d86e/dsh-hive-panel) is the DSH-native board |
|
|
@@ -251,7 +280,7 @@ do not fit wait and are retried, so very large limits do not increase real throu
|
|
|
251
280
|
themselves, and token cost grows with concurrency.
|
|
252
281
|
|
|
253
282
|
**A card is claimed but not started.** Cards waiting in a repository's queue hold their
|
|
254
|
-
Hive claim; if the wait outlives the claim TTL (`ttl`, default
|
|
283
|
+
Hive claim; if the wait outlives the claim TTL (`ttl`, default 20m) the claim expires and
|
|
255
284
|
the card can be reclaimed. Raise `ttl` for very large queues.
|
|
256
285
|
|
|
257
286
|
**A repository says it is waiting.** Workers need a live DSH agent as their parent. When
|
|
@@ -275,7 +304,7 @@ pause/resume; the supervisor works from `cordis.patch.yml` alone.
|
|
|
275
304
|
## Development
|
|
276
305
|
|
|
277
306
|
```bash
|
|
278
|
-
npm test # node --test test/*.test.js (
|
|
307
|
+
npm test # node --test test/*.test.js (124 tests)
|
|
279
308
|
npm run check # node --check on index.js and lib/
|
|
280
309
|
npm pack --dry-run
|
|
281
310
|
```
|
package/README.zh-CN.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
[Hive](https://github.com/d86e/hive) 让一群 AI agent 在 git
|
|
18
|
+
[Hive](https://github.com/d86e/hive) 让一群 AI agent 在 git 里协调:带验收命令的任务卡、路径公告、在场看板、提交时合并,全部存在仓库自己的 refs 和文件里。[hive-runner](https://github.com/d86e/hive-runner) CLI 跑**一轮**就退出。
|
|
19
19
|
|
|
20
20
|
**dsh-hive-runner** 把这个循环常驻进 DSH:supervisor 活在 DSH 宿主进程里(不在浏览器 tab 里),关掉面板或窗口都照常工作,只要 DSH 还在运行。worker 是 DSH subagent,所有命令都走 DSH 自己的 shell 执行层,受部署 sandbox 约束——插件不会绕过 harness 直接 spawn 进程。
|
|
21
21
|
|
|
@@ -28,17 +28,28 @@
|
|
|
28
28
|
- 单仓库一次只处理一轮;不同仓库可以并行(默认 2 个仓库)。
|
|
29
29
|
- 卡片没产生 commit、验收命令失败或 worker 提前停止,会在 Hive 里记为失败,队列继续跑其余卡。
|
|
30
30
|
- 仓库连续失败会退避,连续 3 次异常自动暂停;暂停的仓库不会自己恢复。
|
|
31
|
-
- worker 遵循 Hive consensus
|
|
31
|
+
- worker 遵循 Hive consensus 公告协议:派发前 supervisor 用 `hive guard` 公告卡片的每个 scope 项(包括 `resource:` 键),结束后清除自己的公告。路径已被其他 agent 公告时只是提示:worker 照常干活,由 merge-on-commit 在提交时做三方合并(未解决的冲突会保留成标记)。
|
|
32
|
+
- 经验是「开工读取、收工写入」的一对:每张卡派发前 supervisor 对每个 scope 路径加仓库根各跑一次 `hive recall`,把去重后的命中结果注入 worker prompt 顶部;worker 发现真正的新知识用 `hive lesson add` 写回。写经验与读取经验缺一不可,只写不读不会积累。
|
|
32
33
|
- 提交受 merge-on-commit 约束:仓库必须装好 merge-on-commit 的 pre-commit 钩子(`hive init` 会装),只有 HEAD 经过该钩子推进的卡才算 done。
|
|
33
34
|
- 仓库处于 Hive freeze 模式时,非 fix 卡留在看板上,而不是记为失败。
|
|
34
35
|
|
|
36
|
+
## Worker 会话归属
|
|
37
|
+
|
|
38
|
+
worker 跑在**女王会话**里:你打开 Hive 面板并完成 `hive init`(或女王接管)的那个会话。
|
|
39
|
+
面板会把这个 Session 登记给 supervisor;之后每张卡的 worker 都以它为 parent——
|
|
40
|
+
子智能体就出现在同一个会话里,你可以直接点开。
|
|
41
|
+
|
|
42
|
+
- 女王会话登记前不派发:status 显示 `waiting: no-queen-session`,这是启动顺序提示,不是错误。
|
|
43
|
+
- supervisor 始终使用登记的那个 Session,绝不会换成别的聊天窗口。
|
|
44
|
+
- 登记之后,即使没有别的用户会话、面板/界面关闭,也会继续派发和运行。
|
|
45
|
+
|
|
35
46
|
## 环境要求
|
|
36
47
|
|
|
37
48
|
- DSH 0.2.2-rc.5,`desktop` 或 `web` profile——插件按这个版本开发;Node 22.19 或更新。
|
|
38
49
|
- [hive](https://github.com/d86e/hive) 与 [hive-tasks](https://github.com/d86e/hive-tasks)。
|
|
39
50
|
`hive-tasks` 和 `hive` 默认按 PATH 名调用,shell 找不到时自动用 `npx` 重试;`tasksBin`/`hiveBin` 可以显式固定可执行文件。
|
|
40
51
|
- 已经用 Hive 初始化过的仓库(`hive init`),除非开启自动发现。
|
|
41
|
-
- [Hive 面板](https://github.com/d86e/dsh-hive-panel)
|
|
52
|
+
- [Hive 面板](https://github.com/d86e/dsh-hive-panel) **0.2.3 或更新**。在面板里初始化仓库时会登记女王会话(每次面板访问都会重新登记);没有这个登记 supervisor 会一直等待、不派发。
|
|
42
53
|
|
|
43
54
|
## 安装
|
|
44
55
|
|
|
@@ -62,7 +73,7 @@
|
|
|
62
73
|
<details>
|
|
63
74
|
<summary>手工改 profile(效果相同,仅在 CLI 不可用时使用)</summary>
|
|
64
75
|
|
|
65
|
-
在 DSH Desktop 退出时,把 `"dsh-hive-runner": "^0.6.
|
|
76
|
+
在 DSH Desktop 退出时,把 `"dsh-hive-runner": "^0.6.7"` 加进 profile 的
|
|
66
77
|
`dependencies`、把 `dsh-hive-runner` 加进 `dsh.profile.bundles`,然后
|
|
67
78
|
`cd ~/.dsh/profiles/desktop && pnpm install`。
|
|
68
79
|
|
|
@@ -104,7 +115,9 @@
|
|
|
104
115
|
|
|
105
116
|
要暂停/恢复整个仓库,用同一个 Runner 标签页里的 **暂停 / 恢复** 按钮。暂停会阻止后续调度;已经在跑的卡会跑完,恢复后在下一个 tick 重新参与调度。
|
|
106
117
|
|
|
107
|
-
面板会按角色显示:当前上限、正在跑的 worker
|
|
118
|
+
面板会按角色显示:当前上限、正在跑的 worker 数、等待名额的卡数。对正在跑的卡,
|
|
119
|
+
面板会显示 worker Session(可直接打开该会话)、开始时间,以及长时间无输出时的
|
|
120
|
+
heartbeat 告警;卡住的任务会在 `cardTimeoutMs`(默认 15 分钟)到点时被 abort 并判失败。
|
|
108
121
|
|
|
109
122
|
## 设多少只蜂合适?
|
|
110
123
|
|
|
@@ -125,10 +138,12 @@
|
|
|
125
138
|
| `discoverRoots` | `[]` | 自动发现的扫描根目录;空 = 使用 `repos` 的父目录 |
|
|
126
139
|
| `intervalMs` / `idleBackoffMs` | `30000` / `120000` | 多久找一次活 / 仓库没活时等多久 |
|
|
127
140
|
| `maxConcurrentRepos` | `2` | 同时工作的仓库数 |
|
|
141
|
+
| `cardTimeoutMs` | `900000` | 每张卡的硬超时:到点 abort worker 并判失败 |
|
|
142
|
+
| `heartbeatWarnMs` / `heartbeatIntervalMs` | `300000` / `30000` | 运行中的 worker 多久无输出标记 heartbeat 告警 / 检查间隔 |
|
|
128
143
|
| `roleConcurrency` | `{ coder: 5, tester: 5 }` | 每角色 worker 数的初始值/兜底值 |
|
|
129
144
|
| `defaultRoleConcurrency` | `5` | 未在 `roleConcurrency` 中列出的角色的兜底值 |
|
|
130
145
|
| `paused` | `[]` | 启动即暂停的仓库(绝对路径) |
|
|
131
|
-
| `agent` / `ttl` | `dsh` / `
|
|
146
|
+
| `agent` / `ttl` | `dsh` / `20m` | claim 身份 / claim TTL(队列很长时调大 `ttl`) |
|
|
132
147
|
| `provider` | `spawn` | 卡片 worker 使用的 DSH subagent provider |
|
|
133
148
|
| `parentSession` | `null` | 可选的、作为 worker parent 的 live session |
|
|
134
149
|
| `tasksBin` / `hiveBin` | `null` | 显式指定 `hive-tasks` / `hive` 可执行文件(PATH 名或绝对路径)。默认用 PATH 名,找不到时用 `npx -y -p hive-tasks` / `npx -y -p hive-consensus` 重试一次 |
|
|
@@ -167,7 +182,7 @@ DSH 宿主进程(应用开着就一直在)
|
|
|
167
182
|
| --- | --- | --- |
|
|
168
183
|
| [hive](https://github.com/d86e/hive) | 统一入口:init、roles、tasks、run、board、commit、doctor | supervisor 通过 Hive CLI 读状态和任务卡 |
|
|
169
184
|
| [hive-tasks](https://github.com/d86e/hive-tasks) | 带依赖、优先级、验收命令的任务卡 | ready 卡的读取、认领、完成、失败都经它 |
|
|
170
|
-
| [hive-consensus](https://github.com/d86e/hive-consensus) |
|
|
185
|
+
| [hive-consensus](https://github.com/d86e/hive-consensus) | 路径公告、在场看板、冻结模式、共享经验 | `hive guard` 公告每个 worker 的路径;重叠只是提示,由 merge-on-commit 合并并发写入 |
|
|
171
186
|
| [hive-runner](https://github.com/d86e/hive-runner) | 每次调用跑一轮(`hive-run --once`) | 本插件复用同样的轮次原语,但常驻在 DSH 里 |
|
|
172
187
|
| [merge-on-commit](https://github.com/d86e/merge-on-commit) | 提交时三方合并 | worker 的提交和普通提交一样经过仓库钩子 |
|
|
173
188
|
| [hive-panel](https://github.com/d86e/hive-panel) | DSH 之外的独立只读看板 | 不需要;DSH 原生看板是 [dsh-hive-panel](https://github.com/d86e/dsh-hive-panel) |
|
|
@@ -181,7 +196,7 @@ DSH 宿主进程(应用开着就一直在)
|
|
|
181
196
|
|
|
182
197
|
**同时能跑多少只蜂?** 每仓库每角色的上限(默认 5)个在飞 worker。跨仓库最多 `maxConcurrentRepos` 个仓库同时处理;再往下的硬天花板是 DSH 的 `subagent.maxActiveSubagents`。放不下的卡只会等待重试,所以把上限调得很大并不会自动提高真实吞吐,token 成本随并发增长。
|
|
183
198
|
|
|
184
|
-
**卡片被 claim 了却迟迟不跑。** 仓库队列里的卡会持有 Hive claim;等待时间超过 claim TTL(`ttl`,默认
|
|
199
|
+
**卡片被 claim 了却迟迟不跑。** 仓库队列里的卡会持有 Hive claim;等待时间超过 claim TTL(`ttl`,默认 20m)后 claim 过期、卡片可被重新认领。队列很长时请调大 `ttl`。
|
|
185
200
|
|
|
186
201
|
**仓库显示在等待。** worker 需要一个 live DSH agent 作为 parent。没有 live session 时仓库会等待(面板会说明原因),而不是直接失败。
|
|
187
202
|
|
|
@@ -196,7 +211,7 @@ DSH 宿主进程(应用开着就一直在)
|
|
|
196
211
|
## 开发
|
|
197
212
|
|
|
198
213
|
```bash
|
|
199
|
-
npm test # node --test test/*.test.js(
|
|
214
|
+
npm test # node --test test/*.test.js(124 项)
|
|
200
215
|
npm run check # node --check index.js 和 lib/
|
|
201
216
|
npm pack --dry-run
|
|
202
217
|
```
|
package/SPEC.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-hive-runner — protocol specification
|
|
2
2
|
|
|
3
|
-
Status: 0.6.
|
|
3
|
+
Status: 0.6.7, verified against DSH 0.2.2-rc.5.
|
|
4
4
|
|
|
5
5
|
This document is normative for the host contract of the plugin. It is written for
|
|
6
6
|
maintainers: user documentation is [README.md](README.md) and
|
|
@@ -53,6 +53,8 @@ wrong method -> `405` (`hive/method-not-allowed`).
|
|
|
53
53
|
"repoRoleConcurrency": {},
|
|
54
54
|
"defaultRoleConcurrency": 5,
|
|
55
55
|
"capacityRetryMs": 2000,
|
|
56
|
+
"queenSessionId": "queen-session-id",
|
|
57
|
+
"waiting": null,
|
|
56
58
|
"lastTickAt": "2026-12-04T00:00:00.000Z",
|
|
57
59
|
"lastDiscoverError": null,
|
|
58
60
|
"repos": [
|
|
@@ -70,11 +72,27 @@ wrong method -> `405` (`hive/method-not-allowed`).
|
|
|
70
72
|
"consecutiveFailures": 0,
|
|
71
73
|
"lastCards": 0,
|
|
72
74
|
"lastResults": 0,
|
|
75
|
+
"waiting": null,
|
|
73
76
|
"backlog": { "queued": 3, "inFlight": 5, "completed": 12 },
|
|
74
77
|
"roles": {
|
|
75
78
|
"coder": { "limit": 5, "live": 5, "queued": 3 },
|
|
76
79
|
"tester": { "limit": 5, "live": 0, "queued": 0 }
|
|
77
80
|
},
|
|
81
|
+
"workers": [
|
|
82
|
+
{
|
|
83
|
+
"cardId": "readme-89ab",
|
|
84
|
+
"role": "coder",
|
|
85
|
+
"agent": "dsh",
|
|
86
|
+
"sessionId": "session-id",
|
|
87
|
+
"agentName": "agent-1",
|
|
88
|
+
"parentSource": "queen",
|
|
89
|
+
"startedAt": "2026-12-04T00:00:03.000Z",
|
|
90
|
+
"lastOutputAt": "2026-12-04T00:02:00.000Z",
|
|
91
|
+
"heartbeat": "ok",
|
|
92
|
+
"claimDeadline": "2026-12-04T00:05:03.000Z",
|
|
93
|
+
"timeoutAt": "2026-12-04T00:15:03.000Z"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
78
96
|
"limitsError": null,
|
|
79
97
|
"environmentError": null,
|
|
80
98
|
"mode": null,
|
|
@@ -91,6 +109,15 @@ wrong method -> `405` (`hive/method-not-allowed`).
|
|
|
91
109
|
immediately.
|
|
92
110
|
- `roles[role].queued` — fetched cards waiting for a slot; they do not count as live.
|
|
93
111
|
- `backlog` — aggregate `{ queued, inFlight, completed }` for the current or last drain.
|
|
112
|
+
- `queenSessionId` — the queen conversation registered by the panel; every worker is
|
|
113
|
+
parented to it. `waiting` is `"no-queen-session"` until that registration happens.
|
|
114
|
+
- `waiting` — per repository (and top level) `"no-queen-session"` before the queen
|
|
115
|
+
Session is registered; then `null`. It is a startup-order hint, never an error.
|
|
116
|
+
- `workers` — the cards currently running in this repository, each with
|
|
117
|
+
`cardId`, `role`, `agent`, `sessionId`, `agentName`, `parentSource` (`queen`),
|
|
118
|
+
`startedAt`, `lastOutputAt`,
|
|
119
|
+
`heartbeat` (`ok` | `warn`), `claimDeadline` and `timeoutAt`; the panel uses the
|
|
120
|
+
Session id to open the worker chat.
|
|
94
121
|
- `state` — `idle` | `running` | `backoff` | `paused`.
|
|
95
122
|
|
|
96
123
|
### 3.2 `POST ?op=pause` / `POST ?op=resume`
|
|
@@ -171,6 +198,17 @@ deployment policy with the repository pinned as the workspace root.
|
|
|
171
198
|
|
|
172
199
|
## 8. Round preconditions and worker protocol
|
|
173
200
|
|
|
201
|
+
Every card worker is parented to the **queen conversation**: the Session where the
|
|
202
|
+
panel was initialised and the queen took over. The panel registers that Session id
|
|
203
|
+
with the supervisor (`POST /api/hive-runner?op=queen { sessionId }` or
|
|
204
|
+
`hiveSupervisor.setQueenSession()`); the registration lives in plugin memory and the
|
|
205
|
+
next panel access re-registers it after a restart. Before registration the supervisor
|
|
206
|
+
does not dispatch: the round is skipped and status reports
|
|
207
|
+
`waiting: "no-queen-session"` (a startup-order hint, not an error). The supervisor
|
|
208
|
+
always uses exactly the registered queen Session and never falls back to another
|
|
209
|
+
Session or an arbitrary live agent. Once registered, dispatch does not depend on any
|
|
210
|
+
other user session being live.
|
|
211
|
+
|
|
174
212
|
Before every drain the supervisor requires a Hive-initialised repository whose
|
|
175
213
|
`<repo>/.git/hooks/pre-commit` runs merge-on-commit (it mentions merge-on-commit or moc).
|
|
176
214
|
A missing hook is a deferrable environment error: the repository backs off,
|
|
@@ -178,38 +216,64 @@ A missing hook is a deferrable environment error: the repository backs off,
|
|
|
178
216
|
|
|
179
217
|
Per card:
|
|
180
218
|
|
|
181
|
-
1. `hive guard <scope...> --
|
|
182
|
-
the worker starts, using the
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
the
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
worker
|
|
198
|
-
|
|
199
|
-
|
|
219
|
+
1. `hive guard <scope...> --task <id> --ttl <ttl> --json` announces the card's scope
|
|
220
|
+
before the worker starts, using the claim agent and a per-card `HIVE_INSTANCE` (the
|
|
221
|
+
card id) so concurrent workers of one runner are distinct announcers. hive-consensus
|
|
222
|
+
1.5.0 announcements never block: `hive guard` always exits 0 and publishes the
|
|
223
|
+
announced paths on the board. The runner parses the JSON document's advisory
|
|
224
|
+
`overlaps` array, logs the agent names and keeps the entries on the run record. A
|
|
225
|
+
non-zero exit (an unexpected CLI problem) and malformed or empty JSON are tolerated:
|
|
226
|
+
they are logged or ignored and never fail the card.
|
|
227
|
+
2. `hive recall` runs once for every scope entry and once for the repository root (query
|
|
228
|
+
`.`); the deduplicated lessons are injected at the top of the worker prompt (after
|
|
229
|
+
the title/role, before the goal) under `## Recalled experience (hive recall)`. A read
|
|
230
|
+
error is logged and recorded on the run record's `lessons.error`, and never blocks
|
|
231
|
+
the card. Writing lessons (`hive lesson add`) and reading them at the start are a
|
|
232
|
+
pair: a lesson nobody reads does not compound.
|
|
233
|
+
3. The worker prompt hard-codes the consensus rules (announce every scope entry
|
|
234
|
+
including `resource:` keys with `--task <card id>` and the runner's claim identity,
|
|
235
|
+
so the worker's announcement belongs to this card and can never be mistaken for
|
|
236
|
+
another writer's; treat overlaps as information only, keep working and do not shrink
|
|
237
|
+
the scope; clear your own announcements before finishing; never delete another
|
|
238
|
+
agent's announcements) and the commit rules (plain `git commit` only, never
|
|
239
|
+
`--no-verify`/history rewrites, resolve hook conflicts in place keeping both sides).
|
|
240
|
+
4. Every Hive/git shell command carries `HIVE_AGENT=<claim identity>` in its
|
|
241
|
+
environment; every per-card Hive command (`claim`, `guard`, `done`, `fail`,
|
|
242
|
+
`release`, `renew`) also carries `HIVE_INSTANCE=<card id>`. Worker subagent
|
|
243
|
+
activations inject both variables into the
|
|
244
|
+
in-process worker environment for their lifetime (DSH's model-facing bash tool
|
|
245
|
+
inherits ambient env) and restore the previous values afterwards.
|
|
200
246
|
5. Done verification requires HEAD to have moved and the merge-on-commit hook to still be
|
|
201
|
-
present;
|
|
247
|
+
present; announcements for the scope are best-effort released after done or fail.
|
|
202
248
|
6. Every attempt writes `<repo>/.hive/runs/<cardId>.json`: `running` when the attempt
|
|
203
|
-
starts,
|
|
204
|
-
endings. The record carries
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
249
|
+
starts, a second `running` write after the lesson read (now carrying `lessons`), then
|
|
250
|
+
the terminal state for done, failed and exceptional endings. The record carries
|
|
251
|
+
`cardId`, `agent`, `startedAt`, `endedAt`, `status`, optional
|
|
252
|
+
`exitCode`/`commit`, optional `overlaps` (`[{ key, agent, task, expiresAt }]`, only
|
|
253
|
+
entries with a non-empty string agent, capped at 100, omitted when empty), `lessons`
|
|
254
|
+
(`{ count, scopes, error? }`: the number of deduplicated lessons read, the queries
|
|
255
|
+
used and the read error when one occurred), and `output` (the worker's final
|
|
256
|
+
result message only: the text blocks of its last assistant message, with
|
|
257
|
+
reasoning/thinking, tool calls and the narration around them stripped; a provider
|
|
258
|
+
that returned no typed text block falls back to the last non-empty text, and a run
|
|
259
|
+
with no text at all falls back to the card verdict; capped to the smaller of the
|
|
260
|
+
last 200 lines and the last 32 KiB of UTF-8). A started worker activation
|
|
261
|
+
also adds `sessionId` (the child Session id returned by `startActivation`) and
|
|
262
|
+
`agentName` (its model-facing child name); both keys are omitted when no activation
|
|
263
|
+
was accepted (for example an activation that threw, or a deferrable environment
|
|
264
|
+
error), so consumers can distinguish "no worker chat" from an empty value. The
|
|
265
|
+
running record is rewritten as soon as the activation is accepted, so a card that is
|
|
266
|
+
still in progress already exposes its worker Session and name. The file is
|
|
267
|
+
overwritten per attempt, so only the most recent run is kept; read failures and
|
|
268
|
+
write failures are ignored by the round and never change the card verdict. While the
|
|
269
|
+
worker runs, the record also carries `heartbeat` (`ok`/`warn`) and
|
|
270
|
+
`lastOutputAt`, advanced when the repository HEAD moves.
|
|
271
|
+
7. Every card has a hard wall-clock limit `cardTimeoutMs` (default 15 min). At the
|
|
272
|
+
deadline the worker signal is aborted, the card is recorded failed with a timeout
|
|
273
|
+
reason, and the scope announcements are released. The claim TTL never aborts a
|
|
274
|
+
running card. A running worker whose HEAD has not moved for `heartbeatWarnMs`
|
|
275
|
+
(default 5 min) is marked `heartbeat: "warn"` in status and the run record;
|
|
276
|
+
heartbeat polling uses `heartbeatIntervalMs` (default 30 s).
|
|
213
277
|
|
|
214
278
|
The supervisor reads the Hive mode every round: in freeze mode only fix cards are
|
|
215
279
|
dispatched, other ready cards stay on the board and are reported through `mode`,
|
package/cordis.patch.yml
CHANGED
|
@@ -43,9 +43,12 @@
|
|
|
43
43
|
maxConsecutiveFailures: 3
|
|
44
44
|
# Repositories paused at startup (absolute paths). Manual resume works.
|
|
45
45
|
paused: []
|
|
46
|
-
# Claim identity / claim TTL.
|
|
46
|
+
# Claim identity / claim TTL. Every card also runs its consensus calls
|
|
47
|
+
# with HIVE_INSTANCE=<card id>, so concurrent workers of this runner are
|
|
48
|
+
# distinct announcers on the board. The claim TTL never aborts a running
|
|
49
|
+
# card (cardTimeoutMs does that); raise ttl for very large queues.
|
|
47
50
|
agent: dsh
|
|
48
|
-
ttl:
|
|
51
|
+
ttl: 20m
|
|
49
52
|
# Per-role LIVE-worker limits, per repository. Default five workers per
|
|
50
53
|
# role; 0 pauses a role (its ready cards stay on the board). These are
|
|
51
54
|
# the config defaults/fallbacks — each repository can persist its own
|
|
@@ -62,6 +65,15 @@
|
|
|
62
65
|
# Delay (ms) before retrying queued cards when DSH subagent capacity is
|
|
63
66
|
# exhausted (ACTIVATION_LIMIT_REACHED).
|
|
64
67
|
capacityRetryMs: 2000
|
|
68
|
+
# Hard per-card wall-clock limit (ms). At the deadline the worker is
|
|
69
|
+
# aborted, the card is recorded failed and its announcements are released.
|
|
70
|
+
cardTimeoutMs: 900000
|
|
71
|
+
# Heartbeat: while a worker runs, watch the repository HEAD as the
|
|
72
|
+
# observable output signal. No movement for heartbeatWarnMs marks the
|
|
73
|
+
# worker heartbeat=warn in status/run record; heartbeatIntervalMs is the
|
|
74
|
+
# poll cadence.
|
|
75
|
+
heartbeatWarnMs: 300000
|
|
76
|
+
heartbeatIntervalMs: 30000
|
|
65
77
|
# Subagent provider used to run card workers (spawn is the shipped
|
|
66
78
|
# in-process fresh-child backend).
|
|
67
79
|
provider: spawn
|