@aiwayds/dsh-tui-pi 2.11.4 → 2.12.0

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.
@@ -5,20 +5,33 @@
5
5
  * decision point — no watcher needed (the /settings browser hot-applies, so
6
6
  * the next guard execution / turn count reads the new value):
7
7
  * - `maxAgents` caps concurrent live children. A `tools.guard` registered on
8
- * the plugin root ctx denies model-facing spawn tools once the bridge's
9
- * live child count meets the cap. The live-child COUNT covers every child
10
- * in the process, but the DENIAL scope is "belongs to this TUI": a caller
11
- * carrying the surface marker, or any live descendant of a marked root
12
- * (the ancestor walk closes the host-created-children hole). Foreign
13
- * roots fail open. The workflow/ralph fan-out bypasses the tool pipeline
14
- * (its worker thread spawns through the subagent provider directly), so a
15
- * `subagent/start` listener prunes any newcomer that slips past the guard
16
- * same ownership scope, decided by the child's parent ancestry.
8
+ * the plugin root ctx denies model-facing spawn tools once the EFFECTIVE
9
+ * child count meets the cap. The count is synchronous at the spawn
10
+ * decision: discovered live children plus an admission ledger of
11
+ * allowed-but-not-yet-discovered spawns, so a burst of parallel spawn
12
+ * calls inside one assistant message cannot overshoot while the bridge's
13
+ * firehose discovery catches up (each allowance enters the ledger the
14
+ * moment it is granted; each newly discovered child consumes one entry).
15
+ * The count covers every child in the process, but the DENIAL scope is
16
+ * "belongs to this TUI": a caller carrying the surface marker, or any
17
+ * live descendant of a marked root (the ancestor walk closes the
18
+ * host-created-children hole). Foreign roots fail open. A denial tells
19
+ * the model to record the task in its todo list and run it once a slot
20
+ * frees, instead of retrying the spawn. The workflow/ralph fan-out
21
+ * bypasses the tool pipeline (its worker thread spawns through the
22
+ * subagent provider directly), so a `subagent/start` listener prunes any
23
+ * newcomer that slips past the guard — same ownership scope, decided by
24
+ * the child's parent ancestry.
17
25
  * - `disableSubagent` disables the plain native `subagent` tool: its calls
18
26
  * are denied for every TUI-scoped caller (and it is hidden from the main
19
27
  * agent's catalog), so delegation goes through registered agent
20
28
  * definitions (`~/.dsh/agents/*.md` via the registry's `use_agent`).
21
29
  * `subagent_fork`, `workflow` and `ralph` stay available.
30
+ * - `registeredOnly` is the wider fence: EVERY spawn tool except
31
+ * `use_agent` is denied for TUI-scoped callers, so no child can exist
32
+ * without a registered agent definition behind it (no ad-hoc
33
+ * "implement <task>" children). Default off; the fence is read live like
34
+ * every other knob.
22
35
  * - `maxRounds` caps a child's assistant messages (each LLM round-trip is
23
36
  * one "round") through a TWO-STAGE ladder. Stage 1: at the cap — the
24
37
  * per-agent tier when the child's label resolves to an agent .md
@@ -136,6 +149,23 @@ export interface HardStopRecord {
136
149
  /** The grace window that was exhausted. */
137
150
  readonly grace: number;
138
151
  }
152
+ /**
153
+ * Cumulative subagent-runtime counters since the policy was installed (this
154
+ * TUI process), served to the model through the `subagent_status` tool and
155
+ * to the operator through the /agents limits panel.
156
+ */
157
+ export interface SubagentPolicyStats {
158
+ /** Children currently on the bridge's live board (settled excluded). */
159
+ live: number;
160
+ /** Spawn-tool calls the guard admitted. */
161
+ allowed: number;
162
+ /** Spawn-tool calls denied at the `maxAgents` cap. */
163
+ denied: number;
164
+ /** Fan-out children pruned by the `subagent/start` backstop. */
165
+ pruned: number;
166
+ /** Allowed-but-undiscovered spawns currently holding an admission slot. */
167
+ inFlight: number;
168
+ }
139
169
  /** The running policy: the bridge's `onRoundCount` sink plus the teardown. */
140
170
  export interface SubagentPolicy {
141
171
  /** Called by the bridge whenever one child produced another assistant message. */
@@ -145,6 +175,8 @@ export interface SubagentPolicy {
145
175
  * force-stopped child shows its `⏻` marker everywhere the view renders.
146
176
  */
147
177
  onHardStop?(record: HardStopRecord): void;
178
+ /** Snapshot of the runtime counters (live / allowed / denied / pruned / inFlight). */
179
+ getStats(): SubagentPolicyStats;
148
180
  /** Unwind the guard and event listeners. */
149
181
  dispose(): void;
150
182
  }
@@ -5,20 +5,33 @@
5
5
  * decision point — no watcher needed (the /settings browser hot-applies, so
6
6
  * the next guard execution / turn count reads the new value):
7
7
  * - `maxAgents` caps concurrent live children. A `tools.guard` registered on
8
- * the plugin root ctx denies model-facing spawn tools once the bridge's
9
- * live child count meets the cap. The live-child COUNT covers every child
10
- * in the process, but the DENIAL scope is "belongs to this TUI": a caller
11
- * carrying the surface marker, or any live descendant of a marked root
12
- * (the ancestor walk closes the host-created-children hole). Foreign
13
- * roots fail open. The workflow/ralph fan-out bypasses the tool pipeline
14
- * (its worker thread spawns through the subagent provider directly), so a
15
- * `subagent/start` listener prunes any newcomer that slips past the guard
16
- * same ownership scope, decided by the child's parent ancestry.
8
+ * the plugin root ctx denies model-facing spawn tools once the EFFECTIVE
9
+ * child count meets the cap. The count is synchronous at the spawn
10
+ * decision: discovered live children plus an admission ledger of
11
+ * allowed-but-not-yet-discovered spawns, so a burst of parallel spawn
12
+ * calls inside one assistant message cannot overshoot while the bridge's
13
+ * firehose discovery catches up (each allowance enters the ledger the
14
+ * moment it is granted; each newly discovered child consumes one entry).
15
+ * The count covers every child in the process, but the DENIAL scope is
16
+ * "belongs to this TUI": a caller carrying the surface marker, or any
17
+ * live descendant of a marked root (the ancestor walk closes the
18
+ * host-created-children hole). Foreign roots fail open. A denial tells
19
+ * the model to record the task in its todo list and run it once a slot
20
+ * frees, instead of retrying the spawn. The workflow/ralph fan-out
21
+ * bypasses the tool pipeline (its worker thread spawns through the
22
+ * subagent provider directly), so a `subagent/start` listener prunes any
23
+ * newcomer that slips past the guard — same ownership scope, decided by
24
+ * the child's parent ancestry.
17
25
  * - `disableSubagent` disables the plain native `subagent` tool: its calls
18
26
  * are denied for every TUI-scoped caller (and it is hidden from the main
19
27
  * agent's catalog), so delegation goes through registered agent
20
28
  * definitions (`~/.dsh/agents/*.md` via the registry's `use_agent`).
21
29
  * `subagent_fork`, `workflow` and `ralph` stay available.
30
+ * - `registeredOnly` is the wider fence: EVERY spawn tool except
31
+ * `use_agent` is denied for TUI-scoped callers, so no child can exist
32
+ * without a registered agent definition behind it (no ad-hoc
33
+ * "implement <task>" children). Default off; the fence is read live like
34
+ * every other knob.
22
35
  * - `maxRounds` caps a child's assistant messages (each LLM round-trip is
23
36
  * one "round") through a TWO-STAGE ladder. Stage 1: at the cap — the
24
37
  * per-agent tier when the child's label resolves to an agent .md
@@ -208,6 +221,15 @@ function callerBelongsToTui(ctx, agent) {
208
221
  }
209
222
  /** Walk depth cap: dsh's native depth default is 3; 4 hops cover it with room. */
210
223
  const ANCESTOR_WALK_MAX_DEPTH = 4;
224
+ /**
225
+ * How long an allowed-but-never-discovered admission may hold its slot.
226
+ * Discovery normally lands within one bridge reconcile tick (600ms); the
227
+ * TTL only releases the slot of a spawn that errored after the guard
228
+ * allowed it, so one failed spawn cannot shrink the budget forever.
229
+ */
230
+ const INFLIGHT_TTL_MS = 30_000;
231
+ /** Credited-id slack over the live board before stale ids are pruned. */
232
+ const CREDITED_SLACK = 64;
211
233
  /**
212
234
  * The wrap-up message injected into a child that reached `maxRounds`.
213
235
  * English and directive on purpose: it is a policy instruction to the child
@@ -245,14 +267,68 @@ export function applySubagentPolicy(ctx, state, resolveAgentCap) {
245
267
  const injected = new Set();
246
268
  /** Set by dispose: a pending deferred injection must not fire afterwards. */
247
269
  let disposed = false;
248
- // maxAgents guard: the live-child count is global (the bridge counts every
249
- // child it discovers), but the DENIAL — like the disableSubagent fence —
250
- // only fires for agents this bridge created or resumed (the surface
251
- // marker; unmarked callers fail open). Zero disables the guard.
252
- // The cap is approximate, not a hard admission lock: a burst of parallel
253
- // spawn calls can briefly overshoot before the bridge's firehose discovery
254
- // counts the newcomers the subagent/start backstop below prunes the
255
- // overshoot, and the next spawn's guard reads the caught-up count.
270
+ // ---- synchronous admission ledger -------------------------------------
271
+ //
272
+ // The maxAgents admission decision must not depend on discovery timing.
273
+ // Every allowance is recorded here the moment it is granted; every child
274
+ // the bridge later discovers consumes exactly one record (it is then
275
+ // counted in `live` directly). The next guard execution therefore always
276
+ // reads `live.length + inFlight.length`, so a burst of parallel spawn
277
+ // calls inside ONE assistant message sees itself: with cap 2 the calls
278
+ // read 0+0, 0+1, then deny at 0+2 — never six "Started" results.
279
+ const stats = { live: 0, allowed: 0, denied: 0, pruned: 0, inFlight: 0 };
280
+ /** Live child ids already folded into the ledger (each consumed one in-flight). */
281
+ const creditedIds = new Set();
282
+ /** Admission timestamps of allowed spawns not yet discovered in `getLive()`. */
283
+ const inFlightAt = [];
284
+ /**
285
+ * Fold the bridge's current live board into the admission ledger and
286
+ * return the effective child count the `maxAgents` cap compares against:
287
+ * discovered children plus allowed-but-undiscovered admissions.
288
+ *
289
+ * Each live child absent from `creditedIds` is a fresh discovery and
290
+ * consumes exactly one in-flight entry. A child the guard never admitted
291
+ * (workflow/ralph provider spawns, foreign surfaces) consumes a phantom
292
+ * entry at worst — shifting an empty list is a no-op — which can only
293
+ * make the estimate MORE conservative, never higher. Entries older than
294
+ * {@link INFLIGHT_TTL_MS} expire so a spawn that failed after the guard
295
+ * allowed it releases its slot instead of holding it forever.
296
+ */
297
+ function reconcileAdmission(live) {
298
+ let discovered = 0;
299
+ for (const view of live) {
300
+ const id = view.childId;
301
+ if (typeof id !== 'string' || id === '')
302
+ continue;
303
+ if (!creditedIds.has(id)) {
304
+ creditedIds.add(id);
305
+ discovered += 1;
306
+ }
307
+ }
308
+ for (let i = 0; i < discovered; i += 1)
309
+ inFlightAt.shift();
310
+ const now = Date.now();
311
+ while (inFlightAt.length > 0 && now - inFlightAt[0] > INFLIGHT_TTL_MS)
312
+ inFlightAt.shift();
313
+ if (creditedIds.size > live.length + CREDITED_SLACK) {
314
+ const liveIds = new Set(live.map(view => view.childId));
315
+ for (const id of creditedIds) {
316
+ if (!liveIds.has(id))
317
+ creditedIds.delete(id);
318
+ }
319
+ }
320
+ stats.inFlight = inFlightAt.length;
321
+ stats.live = live.length;
322
+ return live.length + inFlightAt.length;
323
+ }
324
+ // maxAgents guard: the effective child count is global (the bridge counts
325
+ // every child it discovers; the admission ledger adds the
326
+ // allowed-but-undiscovered spawns so a same-step burst cannot overshoot),
327
+ // but the DENIAL — like the disableSubagent fence — only fires for agents
328
+ // this bridge created or resumed (the surface marker; unmarked callers
329
+ // fail open). Zero disables the guard. The subagent/start backstop below
330
+ // still covers the workflow/ralph provider path, which never reaches this
331
+ // guard at all.
256
332
  //
257
333
  // disableSubagent fence: the plain native `subagent` tool is denied —
258
334
  // but ONLY for agents this bridge created or resumed (the surface marker
@@ -280,6 +356,21 @@ export function applySubagentPolicy(ctx, state, resolveAgentCap) {
280
356
  // roots still fail open.
281
357
  if (!callerBelongsToTui(ctx, exec.agent))
282
358
  return undefined;
359
+ // registeredOnly fence: EVERY spawn tool except the registry's
360
+ // use_agent is denied — a child may only ever be backed by a
361
+ // registered agent definition (~/.dsh/agents/*.md). Stricter than the
362
+ // disableSubagent fence: subagent_fork/workflow/ralph are fenced too,
363
+ // so the model cannot sidestep the roster with ad-hoc or forked
364
+ // spawns (the "实现 <task description>" label shape is exactly the
365
+ // leak this closes).
366
+ if (readSubagentLimits(ctx).registeredOnly && exec.name !== 'use_agent') {
367
+ return `Ad-hoc subagents are disabled here — the "${exec.name}" tool is not available. `
368
+ + 'Delegation goes through the use_agent tool with one of the REGISTERED agent names '
369
+ + '(~/.dsh/agents/*.md) only — it covers the same ground: background:true for a durable '
370
+ + 'background child, resume/fresh for continuation, parallel use_agent calls for fan-out. '
371
+ + 'If no registered agent fits this task, do it yourself or record it with todo_write and '
372
+ + 'surface it to the operator.';
373
+ }
283
374
  if (readSubagentLimits(ctx).disableSubagent && NATIVE_SPAWN_TOOLS.includes(exec.name)) {
284
375
  return `Tool "subagent" is disabled here - delegation goes through registered agents. `
285
376
  + 'Dispatch the work through the use_agent tool with one of the registered agent names instead.';
@@ -288,10 +379,21 @@ export function applySubagentPolicy(ctx, state, resolveAgentCap) {
288
379
  if (maxAgents <= 0)
289
380
  return undefined;
290
381
  const live = state.getLive();
291
- if (live.length < maxAgents)
382
+ // SYNCHRONOUS admission: the effective count folds in the ledger of
383
+ // spawns this guard already allowed but the bridge has not discovered
384
+ // yet — the burst window that let six parallel use_agent calls through
385
+ // a cap of two (2026-09-10 session 9c777e88).
386
+ const effective = reconcileAdmission(live);
387
+ if (effective < maxAgents) {
388
+ inFlightAt.push(Date.now());
389
+ stats.allowed += 1;
292
390
  return undefined;
391
+ }
392
+ stats.denied += 1;
293
393
  const running = live.map((agent) => agent.label).join(', ');
294
- return `Agent limit reached (${live.length}/${maxAgents}): ${running} still running — wait for them to finish before spawning more.`;
394
+ return `Agent limit reached (${effective}/${maxAgents}): ${running} still running — do NOT retry the spawn now. `
395
+ + 'Call subagent_status for the live board, record this task in the todo list (todo_write, status pending), '
396
+ + 'and execute it after a running agent finishes and frees a slot.';
295
397
  }));
296
398
  }
297
399
  // Workflow/ralph backstop: the worker thread fans children out through the
@@ -329,7 +431,11 @@ export function applySubagentPolicy(ctx, state, resolveAgentCap) {
329
431
  : ctx.agents.get(SessionId(parentSession));
330
432
  if (parent === undefined || !callerBelongsToTui(ctx, parent))
331
433
  return;
332
- ctx.agents.get(info.id)?.cancel({
434
+ const newcomerAgent = ctx.agents.get(info.id);
435
+ if (newcomerAgent === undefined)
436
+ return;
437
+ stats.pruned += 1;
438
+ newcomerAgent.cancel({
333
439
  kind: 'hook',
334
440
  reason: 'over the dsh-tui maxAgents policy cap — prune a fan-out child',
335
441
  });
@@ -496,6 +602,13 @@ export function applySubagentPolicy(ctx, state, resolveAgentCap) {
496
602
  set onHardStop(sink) {
497
603
  onHardStopSink = sink;
498
604
  },
605
+ getStats() {
606
+ return {
607
+ ...stats,
608
+ live: state.getLive().length,
609
+ inFlight: inFlightAt.length,
610
+ };
611
+ },
499
612
  dispose() {
500
613
  disposed = true;
501
614
  for (const dispose of disposers.splice(0)) {
@@ -1 +1 @@
1
- {"version":3,"file":"subagent-policy.js","sourceRoot":"","sources":["../src/subagent-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACx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AC,CAAA;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO;QACL,YAAY;QACZ,IAAI,UAAU;YACZ,OAAO,cAAc,CAAA;QACvB,CAAC;QACD,IAAI,UAAU,CAAC,IAAoD;YACjE,cAAc,GAAG,IAAI,CAAA;QACvB,CAAC;QACD,QAAQ;YACN,OAAO;gBACL,GAAG,KAAK;gBACR,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,MAAM;gBAC5B,QAAQ,EAAE,UAAU,CAAC,MAAM;aAC5B,CAAA;QACH,CAAC;QACD,OAAO;YACL,QAAQ,GAAG,IAAI,CAAA;YACf,KAAK,MAAM,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1C,IAAI,CAAC;oBAAC,OAAO,EAAE,CAAA;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The `subagent_status` model-facing tool: a read-only live board of this
3
+ * TUI's subagent runtime, served straight from the bridge's real-time views
4
+ * and the policy's admission counters.
5
+ *
6
+ * Why a tool: the runtime state already exists in-process (the bridge folds
7
+ * every child's firehose events and reconciles against the host's
8
+ * authoritative descendant listing every 600ms), but before this tool the
9
+ * model had no cheap way to READ it — it had to probe the spawn tool and
10
+ * read denial strings, or re-derive state from transcripts. One call here
11
+ * returns the whole board: cap headroom, per-child progress (rounds,
12
+ * tokens, context, last tool), the recent settles, and the admission
13
+ * counters (admitted / denied / pruned / in-flight). The maxAgents denial
14
+ * message points here, so the reject → check → todo_write → retry-later
15
+ * loop needs no other discovery.
16
+ *
17
+ * Read-only by design: steering and stopping stay on the human surfaces
18
+ * (Ctrl+G viewer, stop-everything dialog) — the model observing the board
19
+ * can plan around it but cannot reach through it.
20
+ */
21
+ import type { Context } from '@deepseek-ai/cordis';
22
+ import type { AgentView } from './dsh-events.ts';
23
+ import type { SubagentPolicyStats } from './subagent-policy.ts';
24
+ /** The global tool name — deliberately NOT in SPAWN_TOOLS: this spawns nothing. */
25
+ export declare const SUBAGENT_STATUS_TOOL_NAME = "subagent_status";
26
+ /**
27
+ * Where the board reads from: the bridge's real-time views and the policy's
28
+ * admission counters. Both are plain synchronous reads — the runtime state
29
+ * is maintained continuously, never computed on demand.
30
+ */
31
+ export interface SubagentRuntimeSource {
32
+ /** The bridge's child views (live and recently settled). */
33
+ views(): readonly AgentView[];
34
+ /** The policy's admission counters. */
35
+ stats(): SubagentPolicyStats;
36
+ }
37
+ /**
38
+ * Build the tool definition. `parameters` is empty — the board takes no
39
+ * arguments; every call is a full snapshot.
40
+ */
41
+ export declare function buildSubagentStatusTool(ctx: Context, runtime: SubagentRuntimeSource): import("@deepseek-ai/dsh-tools").ToolDefinition;
42
+ /**
43
+ * Register the board tool on the plugin root ctx. Best-effort like the
44
+ * policy's guard wiring: a tools-less deployment skips silently (the TUI's
45
+ * runtime management surfaces — viewer, limits panel — remain).
46
+ *
47
+ * @returns the registration disposer, or `undefined` when there is no tools
48
+ * service to register with.
49
+ */
50
+ export declare function installSubagentStatusTool(ctx: Context, runtime: SubagentRuntimeSource): (() => void) | undefined;
@@ -0,0 +1,125 @@
1
+ /**
2
+ * The `subagent_status` model-facing tool: a read-only live board of this
3
+ * TUI's subagent runtime, served straight from the bridge's real-time views
4
+ * and the policy's admission counters.
5
+ *
6
+ * Why a tool: the runtime state already exists in-process (the bridge folds
7
+ * every child's firehose events and reconciles against the host's
8
+ * authoritative descendant listing every 600ms), but before this tool the
9
+ * model had no cheap way to READ it — it had to probe the spawn tool and
10
+ * read denial strings, or re-derive state from transcripts. One call here
11
+ * returns the whole board: cap headroom, per-child progress (rounds,
12
+ * tokens, context, last tool), the recent settles, and the admission
13
+ * counters (admitted / denied / pruned / in-flight). The maxAgents denial
14
+ * message points here, so the reject → check → todo_write → retry-later
15
+ * loop needs no other discovery.
16
+ *
17
+ * Read-only by design: steering and stopping stay on the human surfaces
18
+ * (Ctrl+G viewer, stop-everything dialog) — the model observing the board
19
+ * can plan around it but cannot reach through it.
20
+ */
21
+ import { defineTool } from '@deepseek-ai/dsh-tools';
22
+ import { readSubagentLimits } from "./theme-settings.js";
23
+ /** The global tool name — deliberately NOT in SPAWN_TOOLS: this spawns nothing. */
24
+ export const SUBAGENT_STATUS_TOOL_NAME = 'subagent_status';
25
+ /** How many settled rows the board shows after the live rows (most recent first). */
26
+ const SETTLED_ROWS = 8;
27
+ /** Format one ms duration as a compact `4m02s` / `1h12m` / `37s` stamp. */
28
+ function formatDuration(ms) {
29
+ const totalSeconds = Math.max(0, Math.floor(ms / 1000));
30
+ const hours = Math.floor(totalSeconds / 3600);
31
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
32
+ const seconds = totalSeconds % 60;
33
+ if (hours > 0)
34
+ return `${hours}h${String(minutes).padStart(2, '0')}m`;
35
+ if (minutes > 0)
36
+ return `${minutes}m${String(seconds).padStart(2, '0')}s`;
37
+ return `${seconds}s`;
38
+ }
39
+ /** One board row: status, short id, label, progress, activity. */
40
+ function renderRow(prefix, view, now) {
41
+ const id = `#${view.childId.slice(0, 8)}`;
42
+ const parts = [
43
+ `${prefix} ${id} ${view.label}`,
44
+ `rounds ${view.rounds}`,
45
+ `tok ${view.tokens}`,
46
+ ];
47
+ if (view.contextWindow !== undefined && view.contextWindow > 0) {
48
+ parts.push(`ctx ${Math.round((view.contextTokens / view.contextWindow) * 100)}%`);
49
+ }
50
+ parts.push(formatDuration(now - view.startedAt));
51
+ if (view.lastTool !== undefined)
52
+ parts.push(`last=${view.lastTool}`);
53
+ if (view.retries > 0)
54
+ parts.push(`retry ${view.retries}`);
55
+ if (view.outcome !== undefined)
56
+ parts.push(`outcome=${view.outcome}`);
57
+ return parts.join(' ');
58
+ }
59
+ /**
60
+ * Build the tool definition. `parameters` is empty — the board takes no
61
+ * arguments; every call is a full snapshot.
62
+ */
63
+ export function buildSubagentStatusTool(ctx, runtime) {
64
+ return defineTool({
65
+ name: SUBAGENT_STATUS_TOOL_NAME,
66
+ description: 'Live board of this session\'s subagents: who is running, how far each has got '
67
+ + '(rounds, tokens, context, last tool), who settled, and the admission counters '
68
+ + '(admitted / denied by the maxAgents cap). Read-only, zero cost, always current — '
69
+ + 'call this INSTEAD of probing spawn tools or re-reading transcripts. '
70
+ + 'After an "Agent limit reached" denial: check the board, record the pending task '
71
+ + 'with todo_write, and dispatch it once a running agent finishes and frees a slot.',
72
+ parameters: {},
73
+ output: {
74
+ schema: {
75
+ type: 'object',
76
+ additionalProperties: false,
77
+ properties: {
78
+ kind: { type: 'string', required: true },
79
+ text: { type: 'string', required: true },
80
+ },
81
+ },
82
+ render: (_args, value) => {
83
+ const text = value.text;
84
+ return [{ type: 'text', text: typeof text === 'string' ? text : 'subagent board unavailable' }];
85
+ },
86
+ },
87
+ isConcurrencySafe: () => true,
88
+ async execute() {
89
+ const views = runtime.views();
90
+ const stats = runtime.stats();
91
+ const cap = readSubagentLimits(ctx).maxAgents;
92
+ const now = Date.now();
93
+ const live = views.filter(view => view.outcome === undefined).sort((a, b) => a.startedAt - b.startedAt);
94
+ const settled = views.filter(view => view.outcome !== undefined)
95
+ .sort((a, b) => (b.endedAt ?? b.startedAt) - (a.endedAt ?? a.startedAt))
96
+ .slice(0, SETTLED_ROWS);
97
+ const head = `subagent board — live ${stats.live}/${cap} (dsh-tui.maxAgents, 0 = unlimited)`
98
+ + ` · admitted ${stats.allowed} · denied ${stats.denied} · pruned ${stats.pruned} · in-flight ${stats.inFlight}`;
99
+ const rows = [
100
+ ...live.map(view => renderRow('live', view, now)),
101
+ ...(settled.length > 0 ? ['--- recent settles ---'] : []),
102
+ ...settled.map(view => renderRow('done', view, now)),
103
+ ];
104
+ const text = rows.length === 0
105
+ ? `${head}\n(no children yet — the board is empty)`
106
+ : `${head}\n${rows.join('\n')}`;
107
+ return { kind: 'subagent_status', text };
108
+ },
109
+ });
110
+ }
111
+ /**
112
+ * Register the board tool on the plugin root ctx. Best-effort like the
113
+ * policy's guard wiring: a tools-less deployment skips silently (the TUI's
114
+ * runtime management surfaces — viewer, limits panel — remain).
115
+ *
116
+ * @returns the registration disposer, or `undefined` when there is no tools
117
+ * service to register with.
118
+ */
119
+ export function installSubagentStatusTool(ctx, runtime) {
120
+ const tools = ctx.get('tools');
121
+ if (tools?.register === undefined)
122
+ return undefined;
123
+ return tools.register(buildSubagentStatusTool(ctx, runtime));
124
+ }
125
+ //# sourceMappingURL=subagent-status-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent-status-tool.js","sourceRoot":"","sources":["../src/subagent-status-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAInD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAExD,mFAAmF;AACnF,MAAM,CAAC,MAAM,yBAAyB,GAAG,iBAAiB,CAAA;AAE1D,qFAAqF;AACrF,MAAM,YAAY,GAAG,CAAC,CAAA;AAmBtB,2EAA2E;AAC3E,SAAS,cAAc,CAAC,EAAU;IAChC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAA;IACvD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,CAAA;IAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IACtD,MAAM,OAAO,GAAG,YAAY,GAAG,EAAE,CAAA;IACjC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAA;IACrE,IAAI,OAAO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iBAAiB,EAAE,IAAI,EAAE,CAAA;QAC1C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,GAAY,EAAE,OAA8B;IACpF,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAA8B,CAAA;IAC3D,IAAI,KAAK,EAAE,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACnD,OAAO,KAAK,CAAC,QAAQ,CAAC,uBAAuB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAA;AAC9D,CAAC"}
@@ -68,6 +68,17 @@ export interface SubagentLimits {
68
68
  * plain one-shot spawn the TUI's user wants fenced off).
69
69
  */
70
70
  disableSubagent: boolean;
71
+ /**
72
+ * Fence EVERY spawn tool except the registry's `use_agent`: delegation may
73
+ * only create subagents backed by a registered agent definition
74
+ * (`~/.dsh/agents/*.md`), and the ad-hoc paths — native `subagent`,
75
+ * `subagent_fork`, `workflow`, `ralph` — are denied at the guard. This is
76
+ * the "no subagents we did not define" lever: any child whose label is a
77
+ * task description rather than a registered agent's display name is a
78
+ * fence miss this knob closes. Default off (the narrower
79
+ * `disableSubagent` fence stays the out-of-the-box stance).
80
+ */
81
+ registeredOnly: boolean;
71
82
  }
72
83
  /**
73
84
  * Default subagent limits, applied whenever the settings service, namespace,
@@ -239,7 +250,7 @@ export declare function readSubagentLimits(ctx: Context): SubagentLimits;
239
250
  * failure message for the caller.
240
251
  * @returns undefined on success, the failure message otherwise.
241
252
  */
242
- export declare function writeSubagentLimit(ctx: Context, key: 'maxAgents' | 'maxRounds' | 'maxRoundsGrace' | 'disableSubagent', value: number | boolean): Promise<string | undefined>;
253
+ export declare function writeSubagentLimit(ctx: Context, key: 'maxAgents' | 'maxRounds' | 'maxRoundsGrace' | 'disableSubagent' | 'registeredOnly', value: number | boolean): Promise<string | undefined>;
243
254
  /** Persisted favorite/hidden model keys (`provider/id` composites). */
244
255
  export interface ModelPrefs {
245
256
  /** Models pinned to the top of the /model picker, in join order. */
@@ -57,6 +57,7 @@ export const DEFAULT_SUBAGENT_LIMITS = Object.freeze({
57
57
  maxRounds: 75,
58
58
  maxRoundsGrace: 7,
59
59
  disableSubagent: true,
60
+ registeredOnly: false,
60
61
  });
61
62
  /** Schema of the `dsh-tui` settings section. */
62
63
  const THEME_SETTINGS_SCHEMA = z.object({
@@ -92,6 +93,13 @@ const THEME_SETTINGS_SCHEMA = z.object({
92
93
  .description('Disable the native subagent tool (delegation goes through registered '
93
94
  + 'agents, ~/.dsh/agents/*.md via use_agent); subagent_fork/workflow/'
94
95
  + 'ralph stay available'),
96
+ registeredOnly: z
97
+ .boolean()
98
+ .default(DEFAULT_SUBAGENT_LIMITS.registeredOnly)
99
+ .description('Fence EVERY spawn tool except use_agent: delegation may only create '
100
+ + 'subagents backed by a registered agent definition (~/.dsh/agents/'
101
+ + '*.md); the ad-hoc paths (subagent, subagent_fork, workflow, ralph) '
102
+ + 'are denied at the guard'),
95
103
  footerHints: z
96
104
  .object({
97
105
  send: z.boolean().default(true).description('Show "Enter: send" in the footer hint bar'),
@@ -186,6 +194,7 @@ const THEME_SETTINGS_ENTRY = {
186
194
  maxRounds: DEFAULT_SUBAGENT_LIMITS.maxRounds,
187
195
  maxRoundsGrace: DEFAULT_SUBAGENT_LIMITS.maxRoundsGrace,
188
196
  disableSubagent: DEFAULT_SUBAGENT_LIMITS.disableSubagent,
197
+ registeredOnly: DEFAULT_SUBAGENT_LIMITS.registeredOnly,
189
198
  footerHints: { ...DEFAULT_FOOTER_HINTS },
190
199
  cacheHitMode: DEFAULT_CACHE_HIT_MODE,
191
200
  iconSet: 'auto',
@@ -558,6 +567,9 @@ export function readSubagentLimits(ctx) {
558
567
  disableSubagent: typeof section?.disableSubagent === 'boolean'
559
568
  ? section.disableSubagent
560
569
  : DEFAULT_SUBAGENT_LIMITS.disableSubagent,
570
+ registeredOnly: typeof section?.registeredOnly === 'boolean'
571
+ ? section.registeredOnly
572
+ : DEFAULT_SUBAGENT_LIMITS.registeredOnly,
561
573
  };
562
574
  }
563
575
  /**