dsh-hive-runner 1.0.7 → 1.0.9

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
@@ -7,6 +7,38 @@ 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
+ ## [1.0.9] - 2026-12-05
11
+
12
+ ### Removed
13
+
14
+ - Removed the temporary mount diagnostics from `apply()`: the plugin no longer
15
+ writes `/tmp/dsh-hive-runner-probe.json` or `/tmp/dsh-hive-runner-error.txt`.
16
+ `apply()` is a single function again; policy/config failures still propagate (the
17
+ temporary diagnostic wrapper never swallowed them) and real runtime errors keep
18
+ being logged through `console` / the plugin logger.
19
+
20
+ ## [1.0.8] - 2026-12-05
21
+
22
+ ### Added
23
+
24
+ - `hiveSupervisor.addRepo(repo)` registers a repository at runtime: the path must be
25
+ absolute and initialized (a Hive `refs/hive/v1` namespace, or
26
+ `.hive/roles/queen.md`/`.hive/config.json`); registration is idempotent and the
27
+ repository immediately appears in `status().repos` / `status().repoCount`. Panel
28
+ queen activation calls it for the initialized Session cwd, so a repository outside
29
+ the static config starts being supervised without a restart. Relative or
30
+ uninitialized paths are rejected.
31
+ - The queen tool boundary now also vetoes mutation tools (write/edit/bash/apply_patch/
32
+ notebook/office/terminal/run_code/...): the queen gets
33
+ `女王不改代码,请用 hive_tasks 建任务,执行交给 supervisor`, the attempt is recorded
34
+ as `queen_boundary_violation`, and read-only tools (read/grep/glob/web_*/hive_*/
35
+ list_agents) stay allowed. DSH has no mutability bit on a tool execution, so
36
+ `QUEEN_MUTATING_TOOLS` is an explicit name list.
37
+
38
+ ### Published
39
+
40
+ - npm: `dsh-hive-runner@1.0.8` on 2026-12-05.
41
+
10
42
  ## [1.0.7] - 2026-12-05
11
43
 
12
44
  ### Diagnostics
package/README.md CHANGED
@@ -102,10 +102,13 @@ she must act on. The authoritative contract is `<repo>/.hive/roles/queen.md` (wr
102
102
  The tool surface keeps the boundary: none of the queen's tools claims or finishes a task
103
103
  (`hive-tasks claim` / `done` belong to agents and the supervisor), and none edits or
104
104
  commits code. The boundary is enforced, not just documented: the runner registers a
105
- DSH `ctx.tools.guard`, so a queen Session calling `subagent`, `subagent_fork` or
106
- `subagent_claude_code` directly gets a failed tool result telling her
107
- `女王不改代码,请用 hive_tasks 建任务`, and the attempt is recorded as a
108
- `queen_boundary_violation` event (with an anomaly digest for self-correction). The
105
+ DSH `ctx.tools.guard`, so a queen Session calling a delegation tool (`subagent`,
106
+ `subagent_fork`, `subagent_claude_code`) or a mutation tool (`write`, `edit`, `bash`,
107
+ `apply_patch`, notebook/office/terminal/run_code tools, ...) directly gets a failed
108
+ tool result telling her `女王不改代码,请用 hive_tasks 建任务,执行交给 supervisor`;
109
+ read-only tools (`read`, `grep`, `glob`, `web_*`, `hive_*`, `list_agents`, ...) stay
110
+ available. The attempt is recorded as a `queen_boundary_violation` event (with an
111
+ anomaly digest for self-correction). The
109
112
  guard recognizes the queen by registration or by an ordinary chat Session whose cwd
110
113
  is a Hive-initialized repository (`.hive/roles/queen.md`), so it works without the
111
114
  panel; `/queen off` explicitly exempts that Session, and detection registers it
package/SPEC.md CHANGED
@@ -61,6 +61,7 @@ wrong method -> `405` (`hive/method-not-allowed`).
61
61
  "lastTickAt": "2026-12-04T00:00:00.000Z",
62
62
  "lastDiscoverError": null,
63
63
  "pendingAnomalies": 0,
64
+ "repoCount": 1,
64
65
  "repos": [
65
66
  {
66
67
  "repo": "/abs/repo",
@@ -114,6 +115,9 @@ wrong method -> `405` (`hive/method-not-allowed`).
114
115
  immediately.
115
116
  - `roles[role].queued` — fetched tasks waiting for a slot; they do not count as live.
116
117
  - `backlog` — aggregate `{ queued, inFlight, completed }` for the current or last drain.
118
+ - `repos` / `repoCount` — the status-visible repository registry. `hiveSupervisor.addRepo(repo)`
119
+ adds one at runtime (absolute path, must be an initialized Hive repository; idempotent;
120
+ rejects a relative or uninitialized path).
117
121
  - `queenSessionId` — the queen conversation registered by the panel; agents are
118
122
  parented to that Session while it is live (see §8). `waiting` is
119
123
  `"no-queen-session"` until that registration happens.
@@ -232,7 +236,10 @@ deployment policy with the repository pinned as the workspace root.
232
236
  Every task agent is parented to the **queen conversation**: the Session where the
233
237
  panel was initialised and the queen took over. The panel registers that Session id
234
238
  with the supervisor (`POST /api/hive-runner?op=queen { sessionId }` or
235
- `hiveSupervisor.setQueenSession()`); the registration lives in plugin memory and the
239
+ `hiveSupervisor.setQueenSession()`); the same activation calls
240
+ `hiveSupervisor.addRepo(cwd)` for the initialized repository (absolute, validated,
241
+ idempotent) so it appears in `status.repos` and is supervised without a restart. The
242
+ registration lives in plugin memory and the
236
243
  next panel access re-registers it after a restart. Before registration the supervisor
237
244
  does not dispatch: the round is skipped and status reports
238
245
  `waiting: "no-queen-session"` (a startup-order hint, not an error). While the
@@ -349,10 +356,13 @@ DSH's `ctx.tools.guard` lets a plugin veto a tool call after pre-execute policy
349
356
  before the body. The runner registers one global guard. A Session is recognized as
350
357
  queen when its id equals `queenSessionId` **or** it is an ordinary non-worker Session
351
358
  whose cwd contains `.hive/roles/queen.md`; an explicit latest `/queen off` command event
352
- suppresses the veto for that Session (`/queen on` re-enables it). For the tool
353
- `subagent`, `subagent_fork` or `subagent_claude_code` the call fails with
354
- `女王不改代码,请用 hive_tasks 建任务(检测到 <tool> 调用,已拦截...)`; the body never
355
- runs. The attempt is appended to `<repo>/.hive/events.jsonl` with
359
+ suppresses the veto for that Session (`/queen on` re-enables it). Two tool classes are
360
+ vetoed: delegation (`subagent`, `subagent_fork`, `subagent_claude_code`) and mutation
361
+ (an explicit `QUEEN_MUTATING_TOOLS` name list: write/edit/apply_patch/str_replace_editor,
362
+ bash/pwsh/run_code, notebook/office/terminal/ralph/create_worktree and common aliases).
363
+ Read-only tools (read/grep/glob/web_*/hive_*/list_agents/...) stay allowed. The call
364
+ fails with `女王不改代码,请用 hive_tasks 建任务,执行交给 supervisor(检测到 <tool>
365
+ 调用,已拦截)`; the body never runs. The attempt is appended to `<repo>/.hive/events.jsonl` with
356
366
  `kind: "queen_boundary_violation"` (`ts`, `actor`, `tool`, `message`, `sessionId`),
357
367
  pushed as a `queen-boundary-violation` anomaly so the digest reaches the queen, and
358
368
  counted in status (`queenBoundaryViolations`, `lastQueenBoundaryViolation`). A cwd-
package/docs/DESIGN.md CHANGED
@@ -50,6 +50,7 @@ Response:
50
50
  "lastTickAt": "2026-12-04T00:00:00.000Z",
51
51
  "lastDiscoverError": null,
52
52
  "pendingAnomalies": 0,
53
+ "repoCount": 1,
53
54
  "repos": [
54
55
  {
55
56
  "repo": "/abs/repo",
@@ -104,6 +105,9 @@ Response:
104
105
  against `live`).
105
106
  - `backlog` — aggregate `{ queued, inFlight, completed }` for the current or
106
107
  last drain.
108
+ - `repos` / `repoCount` — the repositories the supervisor currently tracks; this is the
109
+ status-visible registry the panel renders. Runtime additions go through
110
+ `hiveSupervisor.addRepo(repo)` (absolute path, initialized Hive repository, idempotent).
107
111
  - `queenSessionId` — the queen conversation registered by the panel **or detected by
108
112
  the queen tool guard** when an ordinary initialized-repo Session calls a subagent
109
113
  tool; agents are parented to that Session while its Agent is live. `waiting` is
@@ -152,7 +156,10 @@ Body: `{ "sessionId": "<live queen Session id>" }`.
152
156
 
153
157
  - Registers the queen conversation that parents task agents. The panel calls this
154
158
  when its init/queen activation succeeds (or calls the `hiveSupervisor`
155
- service's `setQueenSession()` from the host side). Registration is in-memory;
159
+ service's `setQueenSession()` from the host side). The same activation calls
160
+ `hiveSupervisor.addRepo(cwd)` for the initialized repository (idempotent, absolute path
161
+ required; an uninitialized path is rejected), so a repo outside `config.repos` appears in
162
+ `status.repos` without a restart. Registration is in-memory;
156
163
  after a plugin restart the next panel access re-registers it.
157
164
  - Until registration the supervisor does not dispatch: `status` reports
158
165
  `waiting: "no-queen-session"` per repository and at the top level. This is a
@@ -288,8 +295,15 @@ needed and is not implemented.
288
295
  `lib/queen-boundary.js` registers one global guard from `apply()` inside a
289
296
  `ctx.effect`:
290
297
 
291
- - predicate: the tool name is `subagent`, `subagent_fork` or `subagent_claude_code`, and
292
- the calling Session is a queen in one of two ways:
298
+ - predicate: the tool is in one of two classes — delegation (`subagent`,
299
+ `subagent_fork`, `subagent_claude_code`) or mutation (the explicit
300
+ `QUEEN_MUTATING_TOOLS` list: `write`/`edit`/`apply_patch`/`str_replace_editor`,
301
+ `bash`/`pwsh`/`run_code`, notebook editors, `create_worktree`, `office_*`, `ralph*`,
302
+ `terminal_*`, and common aliases). Read-only tools (`read`, `grep`, `glob`,
303
+ `web_*`, `hive_*`, `list_agents`, ...) are not in the list and stay allowed.
304
+ DSH does not expose a mutability bit on a tool execution, so the name list is
305
+ explicit and must be extended when a new mutation tool is composed. The calling
306
+ Session is a queen in one of two ways:
293
307
  1. `exec.agent.session.id` equals the registered `queenSessionId` (legacy/explicit
294
308
  panel registration), or
295
309
  2. it is an ordinary **non-worker** Session whose cwd contains
@@ -301,8 +315,8 @@ needed and is not implemented.
301
315
  - when path 2 recognizes a Session, the guard calls the supervisor's
302
316
  `setQueenSession()` (idempotent) so the panel can display it and future workers
303
317
  use it as parent;
304
- - denial: `女王不改代码,请用 hive_tasks 建任务(检测到 <tool> 调用,已拦截;请把工作
305
- 拆成任务卡并交给 hive_tasks。)`, with `info.code = QUEEN_BOUNDARY_VIOLATION`;
318
+ - denial: `女王不改代码,请用 hive_tasks 建任务,执行交给 supervisor(检测到 <tool>
319
+ 调用,已拦截)`, with `info.code = QUEEN_BOUNDARY_VIOLATION`;
306
320
  - the attempt is appended to `<repo>/.hive/events.jsonl` as
307
321
  `{ ts, actor: "hive-runner", kind: "queen_boundary_violation", tool, message,
308
322
  "sessionId" }` through `appendQueenBoundaryViolation`;
@@ -315,7 +329,9 @@ needed and is not implemented.
315
329
  queen Session; worker/child Sessions and their own subagent tools are unaffected
316
330
  (PTC nested tool calls share the same pipeline and are covered by the predicate).
317
331
 
318
- Tests: `test/queen-boundary.test.js` covers all three vetoed tools, the queen-only
332
+ Tests: `test/queen-boundary.test.js` covers all three delegation tools and the
333
+ mutation tools (write/edit/bash/notebook/run_code denied; read/grep/web/hive allowed),
334
+ the queen-only
319
335
  predicate, cwd-role detection and auto-registration, `/queen off` suppression,
320
336
  uninitialized repositories, worker/other Sessions, the durable event, the anomaly and
321
337
  the status counters; `test/queen-boundary-dispatch.test.js` proves supervisor dispatch
package/index.js CHANGED
@@ -20,7 +20,6 @@
20
20
  * cancellation. Card workers are DSH subagents (`ctx.subagents`), not processes.
21
21
  */
22
22
  import { defineTool } from '@deepseek-ai/dsh-tools';
23
- import { writeFileSync } from 'node:fs';
24
23
 
25
24
  import { createCommands } from './lib/commands.js';
26
25
  import { normalizeRepoKey, resolveConfig } from './lib/config.js';
@@ -89,22 +88,6 @@ function jsonText(value) {
89
88
  * @param {Record<string, unknown>} [config]
90
89
  */
91
90
  export function apply(ctx, config = {}) {
92
- try {
93
- return applyInner(ctx, config);
94
- } catch (error) {
95
- try {
96
- writeFileSync('/tmp/dsh-hive-runner-error.txt', String((error && error.stack) || error) + '\n');
97
- } catch {}
98
- throw error;
99
- }
100
- }
101
-
102
- function applyInner(ctx, config = {}) {
103
- // Load probe: proves the host actually mounted this plugin. Removed once the
104
- // desktop profile load path is confirmed.
105
- try {
106
- writeFileSync('/tmp/dsh-hive-runner-probe.json', JSON.stringify({ at: new Date().toISOString() }) + '\n');
107
- } catch {}
108
91
  const resolved = resolveConfig(config);
109
92
  const commands = createCommands({ ctx, config: resolved });
110
93
  const limits = new RepoLimits({
@@ -721,7 +704,9 @@ function applyInner(ctx, config = {}) {
721
704
  reason: { type: 'string', description: 'pause: why dispatch is throttled.' },
722
705
  roleLimits: {
723
706
  type: 'object',
724
- additionalProperties: { type: 'number' },
707
+ // The host schema compiler only accepts a boolean here; values are
708
+ // validated as integers in execute().
709
+ additionalProperties: true,
725
710
  description: 'limits: role -> integer 0..999 (0 pauses the role).',
726
711
  },
727
712
  },
package/lib/events.js CHANGED
@@ -108,7 +108,7 @@ export const ESCALATION_KIND = 'queen_escalation';
108
108
  /** Event kind written when the queen tries to delegate coding directly. */
109
109
  export const QUEEN_BOUNDARY_KIND = 'queen_boundary_violation';
110
110
  /** Model-facing correction carried by a boundary violation. */
111
- export const QUEEN_BOUNDARY_MESSAGE = '女王不改代码,请用 hive_tasks 建任务';
111
+ export const QUEEN_BOUNDARY_MESSAGE = '女王不改代码,请用 hive_tasks 建任务,执行交给 supervisor';
112
112
  /** Intervention actions the queen may record. */
113
113
  export const INTERVENTION_ACTIONS = Object.freeze([
114
114
  'reopen', 'split', 'reassign', 'pause', 'fail', 'guide', 'remove', 'rebuild', 'escalate',
@@ -28,15 +28,61 @@ import { ANOMALY_KINDS } from './anomalies.js';
28
28
  /** Repository-relative queen role file: its presence marks a Hive-initialised repo. */
29
29
  export const QUEEN_ROLE_FILE = path.join('.hive', 'roles', 'queen.md');
30
30
 
31
- /** Tools a queen Session may never call directly. */
31
+ /** Delegation tools a queen Session may never call directly. */
32
32
  export const QUEEN_FORBIDDEN_TOOLS = Object.freeze([
33
33
  'subagent',
34
34
  'subagent_fork',
35
35
  'subagent_claude_code',
36
36
  ]);
37
37
 
38
- /** Model-facing correction. */
39
- export const QUEEN_BOUNDARY_MESSAGE = '女王不改代码,请用 hive_tasks 建任务';
38
+ /**
39
+ * Mutation tools a queen Session may never call directly. DSH does not expose a
40
+ * mutability bit on a tool execution, so this is the explicit name list of the
41
+ * shipped file/command/office/terminal tools (unknown read-only tools stay
42
+ * allowed). Keep it in sync when a new mutation tool is composed.
43
+ */
44
+ export const QUEEN_MUTATING_TOOLS = Object.freeze([
45
+ 'write',
46
+ 'write_file',
47
+ 'edit',
48
+ 'edit_file',
49
+ 'multi_edit',
50
+ 'apply_patch',
51
+ 'str_replace_editor',
52
+ 'bash',
53
+ 'pwsh',
54
+ 'run_code',
55
+ 'create_worktree',
56
+ 'notebook',
57
+ 'notebook_edit',
58
+ 'notebook_write',
59
+ 'edit_notebook',
60
+ 'notebook_cell_edit',
61
+ 'office_convert',
62
+ 'office_recalculate',
63
+ 'office_render',
64
+ 'ralph',
65
+ 'ralph-loop',
66
+ 'terminal_open',
67
+ 'terminal_send',
68
+ 'terminal_signal',
69
+ 'terminal_close',
70
+ ]);
71
+
72
+ /** Model-facing correction for a blocked queen tool call. */
73
+ export const QUEEN_BOUNDARY_MESSAGE = '女王不改代码,请用 hive_tasks 建任务,执行交给 supervisor';
74
+
75
+ /**
76
+ * Classify a tool name inside the queen boundary.
77
+ * @param {string} name
78
+ * @returns {'delegation' | 'mutation' | null}
79
+ */
80
+ export function queenBoundaryToolClass(name) {
81
+ if (typeof name !== 'string' || name === '') return null;
82
+ if (QUEEN_FORBIDDEN_TOOLS.includes(name)) return 'delegation';
83
+ if (QUEEN_MUTATING_TOOLS.includes(name)) return 'mutation';
84
+ return null;
85
+ }
40
86
 
41
87
  /**
42
88
  * Record one vetoed attempt: bump the shared counter, append the durable
@@ -56,15 +102,19 @@ export function recordQueenBoundaryViolation(violation, {
56
102
  if (state === undefined || state === null) return null;
57
103
  const at = Number.isFinite(violation?.at) ? violation.at : Date.now();
58
104
  state.count = (Number.isInteger(state.count) ? state.count : 0) + 1;
105
+ const message = typeof violation?.message === 'string' && violation.message !== ''
106
+ ? violation.message
107
+ : QUEEN_BOUNDARY_MESSAGE;
59
108
  state.last = {
60
109
  tool: violation?.tool,
110
+ ...(typeof violation?.toolClass === 'string' ? { toolClass: violation.toolClass } : {}),
61
111
  sessionId: violation?.sessionId,
62
112
  at: new Date(at).toISOString(),
63
113
  repo: typeof repo === 'string' && repo !== '' ? repo : null,
64
114
  };
65
115
  if (typeof appendEvent === 'function' && typeof repo === 'string' && repo !== '') {
66
116
  try {
67
- appendEvent(repo, { tool: violation?.tool, sessionId: violation?.sessionId, at });
117
+ appendEvent(repo, { tool: violation?.tool, sessionId: violation?.sessionId, message, at });
68
118
  } catch (error) {
69
119
  log('warn', 'queen boundary event append failed', error);
70
120
  }
@@ -74,7 +124,7 @@ export function recordQueenBoundaryViolation(violation, {
74
124
  recordAnomaly({
75
125
  kind: ANOMALY_KINDS.QUEEN_BOUNDARY_VIOLATION,
76
126
  repo: state.last.repo ?? '',
77
- summary: QUEEN_BOUNDARY_MESSAGE
127
+ summary: message
78
128
  + '(已拦截 ' + String(violation?.tool) + ' 调用,请把工作写成任务卡)',
79
129
  detail: 'queen session ' + String(violation?.sessionId) + ' called ' + String(violation?.tool),
80
130
  at,
@@ -168,7 +218,8 @@ export function createQueenBoundaryGuard({
168
218
  } = {}) {
169
219
  return function queenBoundaryGuard(exec) {
170
220
  if (exec === null || typeof exec !== 'object') return undefined;
171
- if (!QUEEN_FORBIDDEN_TOOLS.includes(exec.name)) return undefined;
221
+ const toolClass = queenBoundaryToolClass(exec.name);
222
+ if (toolClass === null) return undefined;
172
223
  const session = exec.agent?.session;
173
224
  const sessionId = session?.id;
174
225
  if (typeof sessionId !== 'string' || sessionId === '') return undefined;
@@ -206,9 +257,14 @@ export function createQueenBoundaryGuard({
206
257
  }
207
258
  }
208
259
 
260
+ const message = toolClass === 'mutation'
261
+ ? QUEEN_BOUNDARY_MESSAGE + '(检测到 ' + exec.name + ' 调用,已拦截)'
262
+ : QUEEN_BOUNDARY_MESSAGE + '(检测到 ' + exec.name + ' 调用,已拦截;请不要自己派活或改代码,把工作拆成任务卡并交给 hive_tasks。)';
209
263
  const violation = {
210
264
  sessionId,
211
265
  tool: exec.name,
266
+ toolClass,
267
+ message,
212
268
  at: Date.now(),
213
269
  repo: typeof cwd === 'string' && cwd !== '' ? cwd : null,
214
270
  detectedBy: registered ? 'registration' : 'cwd-role',
@@ -219,8 +275,7 @@ export function createQueenBoundaryGuard({
219
275
  log('warn', 'queen boundary violation recording failed', error);
220
276
  }
221
277
  return {
222
- reason: QUEEN_BOUNDARY_MESSAGE
223
- + '(检测到 ' + exec.name + ' 调用,已拦截;请不要自己派活或改代码,把工作拆成任务卡并交给 hive_tasks。)',
278
+ reason: message,
224
279
  info: { ...QUEEN_BOUNDARY_ERROR },
225
280
  };
226
281
  };
package/lib/supervisor.js CHANGED
@@ -23,15 +23,40 @@
23
23
  *
24
24
  * One repository is always serial: at most one drain in flight.
25
25
  */
26
+ import fs from 'node:fs';
27
+ import path from 'node:path';
28
+
26
29
  import {
27
30
  DEFAULT_DEFAULT_ROLE_CONCURRENCY,
28
31
  DEFAULT_ROLE_CONCURRENCY,
29
32
  normalizeRepoKey,
30
33
  } from './config.js';
34
+ import { hasHiveRef } from './discover.js';
31
35
  import { filterDispatchable, gatePhase } from './gates.js';
32
36
  import { RepoLimits, validateRoleLimits } from './limits.js';
33
37
  import { drainQueue } from './queue.js';
34
38
 
39
+ /**
40
+ * Whether a path looks like an initialized Hive repository: the authoritative
41
+ * `refs/hive/v1` git namespace, or a repository-local marker written by
42
+ * `hive init` (`.hive/roles/queen.md` / `.hive/config.json`). This mirrors
43
+ * what the panel and the discovery scanner treat as initialized.
44
+ * @param {string} repo absolute path
45
+ * @returns {boolean}
46
+ */
47
+ export function isInitializedHiveRepo(repo) {
48
+ if (typeof repo !== 'string' || repo === '') return false;
49
+ if (hasHiveRef(repo)) return true;
50
+ for (const relative of [path.join('.hive', 'roles', 'queen.md'), path.join('.hive', 'config.json')]) {
51
+ try {
52
+ if (fs.existsSync(path.join(repo, relative))) return true;
53
+ } catch {
54
+ // Try the next marker.
55
+ }
56
+ }
57
+ return false;
58
+ }
59
+
35
60
  /** Per-repository lifecycle states exposed by `op=status`. */
36
61
  export const STATES = Object.freeze({
37
62
  /** Waiting for the next scheduled attempt. */
@@ -159,7 +184,10 @@ export class HiveSupervisor {
159
184
  this.repos = new Map();
160
185
  /** Repository paths paused by config; applied when they are first registered. */
161
186
  this.configPaused = new Set((options.paused ?? []).map((repo) => normalizeRepoKey(repo)));
162
- for (const repo of options.repos ?? []) this.addRepo(repo);
187
+ // Config/discovery repositories were validated when configured; the
188
+ // public addRepo() adds the stricter runtime validation for panel-driven
189
+ // registrations without changing the historical constructor contract.
190
+ for (const repo of options.repos ?? []) this.#registerRepo(repo);
163
191
 
164
192
  this.started = false;
165
193
  this.timer = null;
@@ -188,11 +216,36 @@ export class HiveSupervisor {
188
216
  }
189
217
 
190
218
  /**
191
- * Register a repository (idempotent). Config-paused paths start paused.
192
- * @param {string} repo absolute path
219
+ * Register a runtime repository (idempotent, absolute, initialized only).
220
+ * The panel queen activation calls this when a Session opens an initialized
221
+ * Hive repository, so a repo outside config.repos starts being supervised.
222
+ * @param {string} repo absolute path to an initialized Hive repository
193
223
  * @returns {object} the repository status snapshot
224
+ * @throws {TypeError} when the path is not absolute or not initialized
194
225
  */
195
226
  addRepo(repo) {
227
+ if (typeof repo !== 'string' || repo.trim() === '') {
228
+ throw new TypeError('addRepo: repo must be a non-empty absolute path');
229
+ }
230
+ if (!path.isAbsolute(repo)) {
231
+ throw new TypeError('addRepo: repo must be an absolute path, got ' + JSON.stringify(repo));
232
+ }
233
+ const key = normalizeRepoKey(repo);
234
+ const existing = this.repos.get(key);
235
+ if (existing !== undefined) return this.#snapshot(existing);
236
+ if (!isInitializedHiveRepo(key)) {
237
+ throw new TypeError('addRepo: repo is not an initialized Hive repository '
238
+ + '(missing refs/hive/v1 or .hive/roles/queen.md): ' + key);
239
+ }
240
+ return this.#registerRepo(key);
241
+ }
242
+
243
+ /**
244
+ * Internal registration for config, discovery and validated addRepo() calls.
245
+ * @param {string} repo normalized absolute path
246
+ * @returns {object}
247
+ */
248
+ #registerRepo(repo) {
196
249
  const key = normalizeRepoKey(repo);
197
250
  const existing = this.repos.get(key);
198
251
  if (existing !== undefined) return this.#snapshot(existing);
@@ -454,6 +507,7 @@ export class HiveSupervisor {
454
507
  lastDiscoverError: this.lastDiscoverError,
455
508
  // Undelivered anomaly digests waiting for a live queen Session.
456
509
  pendingAnomalies: this.#pendingAnomalyCount(),
510
+ repoCount: this.repos.size,
457
511
  repos: [...this.repos.values()]
458
512
  .map((entry) => this.#snapshot(entry))
459
513
  .sort((a, b) => a.repo.localeCompare(b.repo)),
@@ -468,7 +522,7 @@ export class HiveSupervisor {
468
522
  for (const repo of found ?? []) {
469
523
  const key = normalizeRepoKey(repo);
470
524
  if (!this.repos.has(key)) {
471
- this.addRepo(key);
525
+ this.#registerRepo(key);
472
526
  added += 1;
473
527
  }
474
528
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-hive-runner",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "DSH host plugin for Hive: a resident supervisor that runs one DSH subagent per ready task card, with per-role worker limits, pause/resume and Hive tools.",
5
5
  "type": "module",
6
6
  "main": "./index.js",