pi-cowboy 0.3.5 → 0.4.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.
@@ -13,7 +13,8 @@ import * as path from "node:path";
13
13
  import { deleteWorktreeBranch, isWorktreeDirty, removeGitWorktree, resolveMainCheckout, } from "../infrastructure/git-client.js";
14
14
  import { getAgentInfo, listAgentRecords, listWorktrees, normalizeHerdrPath, } from "../infrastructure/herdr-client.js";
15
15
  import { createHerdrHost } from "../infrastructure/herdr-host.js";
16
- import { getSessionCtx, getStore, subagentResultFileFor } from "../shell.js";
16
+ import { getSessionCtx, getStore } from "../shell.js";
17
+ import { subagentResultFileFor } from "../paths.js";
17
18
  import { buildWorktreeBranch, isExtensionWorktree, isSpawnArtifactName, resolveWorktreeRoot, slugifyWorktreeType, } from "../spawn/worktree-policy.js";
18
19
  async function probeList(read) {
19
20
  try {
@@ -1,17 +1,25 @@
1
1
  /**
2
2
  * agent-manager.ts — Fleet controller for independently running subagents.
3
- * Exports AgentManager, ClearOutcome/ClearRefusal; re-exports transport, spawn,
4
- * and steer types.
3
+ * Exports AgentManager, ClearOutcome/ClearRefusal; re-exports spawn and steer
4
+ * types.
5
5
  */
6
- import { getAgentSpawns, getCoordinatorOrNull, getPiInstance, getSessionCtx, subagentResultFileFor, } from "../shell.js";
6
+ import { getAgentSpawns, getCoordinatorOrNull, getPiInstance, getSessionCtx, } from "../shell.js";
7
+ import { subagentResultFileFor } from "../paths.js";
8
+ import { createHerdrRuntime } from "../infrastructure/herdr-host.js";
7
9
  import { HerdrTaskRegistry, } from "../task-registry.js";
8
10
  import { createLogger } from "../logger.js";
9
11
  import { errorMessage } from "../utils.js";
10
12
  import { ACTIVE_AGENT_PHASES, ALL_AGENT_PHASES, hasOutcome, lifecycleStartTime, lifecycleStatus, } from "../types.js";
11
- import { removeResultArtifacts } from "../subagent/ipc.js";
13
+ import { FileDeliverable } from "../subagent/deliverable.js";
14
+ import { removeResultArtifacts } from "../subagent/result-artifacts.js";
12
15
  import { createCleanup } from "./agent-cleanup.js";
13
16
  import { createHerdrAgentAssets, } from "./agent-assets.js";
14
- import { DISPOSE_QUEUED_MESSAGE, SubagentSession, defaultAgentManagerTransport, } from "./subagent-session.js";
17
+ import { DISPOSE_QUEUED_MESSAGE, SubagentSession, } from "./subagent-session.js";
18
+ /** The transport the manager wires its sessions with unless the caller supplies one. */
19
+ export const defaultAgentManagerTransport = {
20
+ createHost: (pi) => createHerdrRuntime(pi).host,
21
+ createDeliverable: (resultFile) => new FileDeliverable(resultFile),
22
+ };
15
23
  /**
16
24
  * Removal address for a spawn's owned checkout. An owned checkout that no
17
25
  * recorded repository cwd can reach is `unaddressable`: its teardown has no
@@ -13,7 +13,8 @@
13
13
  */
14
14
  import * as fs from "node:fs";
15
15
  import * as path from "node:path";
16
- import { getPiInstance, subagentResultFileFor } from "../shell.js";
16
+ import { getPiInstance } from "../shell.js";
17
+ import { subagentResultFileFor } from "../paths.js";
17
18
  import { createPaneSupervisor, } from "../subagent/pane-supervisor.js";
18
19
  import { ensureResultDir } from "./result-file-permissions.js";
19
20
  /**
@@ -31,12 +32,11 @@ export function reviveSettledRun(request) {
31
32
  // fails instead of continuing with world-readable secrets.
32
33
  ensureResultDir(resultDir);
33
34
  fs.rmSync(launch.resultFile, { force: true });
34
- const { supervisor } = createPaneSupervisor({
35
+ const supervisor = createPaneSupervisor({
35
36
  host: transport.createHost(getPiInstance()),
36
37
  resultFile: launch.resultFile,
37
38
  supervisorOptions: request.supervisorOptions,
38
39
  transport,
39
- agentId: spawn.id,
40
40
  });
41
41
  // Adopted, never launched: the pane already holds the run's pi process.
42
42
  supervisor.adopt(hostRef);
@@ -48,17 +48,12 @@ export function reviveSettledRun(request) {
48
48
  }
49
49
  /**
50
50
  * What the revived turn resumes: the settled turn's own artifacts, or a fresh
51
- * report path for a run that settled before it launched anything. The revived
52
- * turn binds no channel and the child does not reboot, so only an
53
- * announcement already heard still names its process.
51
+ * report path for a run that settled before it launched anything.
54
52
  */
55
53
  function resumeLaunch(spawn) {
56
54
  const { lifecycle } = spawn;
57
55
  const resumed = lifecycle.phase === "settled" ? lifecycle.launch : undefined;
58
56
  return {
59
57
  resultFile: resumed?.resultFile ?? subagentResultFileFor(spawn.id),
60
- handshake: resumed?.handshake?.kind === "announced"
61
- ? resumed.handshake
62
- : { kind: "unavailable", reason: "revive" },
63
58
  };
64
59
  }
@@ -10,8 +10,8 @@ import fs from "node:fs";
10
10
  import path from "node:path";
11
11
  import { SettingsManager, } from "@earendil-works/pi-coding-agent";
12
12
  import { errorMessage } from "../utils.js";
13
- import { agentDir } from "../paths.js";
14
- import { getStore, subagentResultDirFor, subagentResultFileFor, subagentSystemFileFor, subagentTaskFileFor, subagentTokenFor, } from "../shell.js";
13
+ import { agentDir, subagentResultDirFor, subagentResultFileFor, subagentSystemFileFor, subagentTaskFileFor, subagentTokenFor, } from "../paths.js";
14
+ import { getStore } from "../shell.js";
15
15
  import { buildSubagentSystemPrompt, buildWorktreeBranchSection, } from "../prompt/subagent-system-prompt.js";
16
16
  import { getAgentConfig, getConfig, } from "./agent-types.js";
17
17
  import { ensureResultDir, writeResultFile } from "./result-file-permissions.js";
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * subagent-session.ts — One subagent run's lifecycle and spawn projection.
3
- * Exports SubagentSession, buildAgentSpawn, DISPOSE_QUEUED_MESSAGE, transport.
3
+ * Exports SubagentSession, buildAgentSpawn, DISPOSE_QUEUED_MESSAGE.
4
4
  */
5
5
  import { createLogger } from "../logger.js";
6
- import { createHerdrRuntime } from "../infrastructure/herdr-host.js";
7
6
  import { worktreeRetentionReason } from "../infrastructure/git-client.js";
8
- import { getAgentSpawns, getPiInstance, getStore, getWorktreeMaterialization, subagentResultFileFor, } from "../shell.js";
9
- import { HerdrSubagentIPC, removeResultArtifacts } from "../subagent/ipc.js";
10
- import { createPaneSupervisor } from "../subagent/pane-supervisor.js";
7
+ import { getAgentSpawns, getPiInstance, getStore, getWorktreeMaterialization, } from "../shell.js";
8
+ import { subagentResultFileFor } from "../paths.js";
9
+ import { removeResultArtifacts } from "../subagent/result-artifacts.js";
10
+ import { createPaneSupervisor, } from "../subagent/pane-supervisor.js";
11
11
  import { lifecycleResult } from "../types.js";
12
12
  import { errorMessage } from "../utils.js";
13
13
  import { buildWorktreeBranch, slugifyWorktreeType, } from "../spawn/worktree-policy.js";
@@ -19,10 +19,6 @@ import { abortQueuedRun, activateRun, createRun, disposeLiveRun, disposeQueuedRu
19
19
  import { reviveSettledRun } from "./agent-reviver.js";
20
20
  export { DISPOSE_QUEUED_MESSAGE } from "./run-state.js";
21
21
  const log = createLogger("session");
22
- export const defaultAgentManagerTransport = {
23
- createHost: (pi) => createHerdrRuntime(pi).host,
24
- createIpc: (options) => new HerdrSubagentIPC(options),
25
- };
26
22
  /** Spawn is born queued and mutated in place; its identity is public API. */
27
23
  export function buildAgentSpawn(args, promise) {
28
24
  const { type, options } = args;
@@ -81,8 +77,6 @@ export class SubagentSession {
81
77
  retention;
82
78
  /** Live supervisor attachment: launched, or adopted on revive. */
83
79
  supervisor;
84
- /** The run's channel: bound before the launch, released when the run is over for us. */
85
- ipc;
86
80
  parentBinding;
87
81
  constructor({ id, args, deps }) {
88
82
  this.id = id;
@@ -280,7 +274,6 @@ export class SubagentSession {
280
274
  // it; only a run whose removal is confirmed lets go of its artifacts.
281
275
  this.supervisor?.detach();
282
276
  this.supervisor = undefined;
283
- this.closeChannel();
284
277
  removeResultArtifacts(this.resultFilePath());
285
278
  this.detachParentBinding();
286
279
  this.gate.open("");
@@ -298,7 +291,6 @@ export class SubagentSession {
298
291
  // Disposal stops tracking only: abandon the poll loop, leave pane and process alive.
299
292
  this.supervisor?.abandon();
300
293
  this.supervisor = undefined;
301
- this.closeChannel();
302
294
  this.detachParentBinding();
303
295
  }
304
296
  async launch() {
@@ -379,18 +371,13 @@ export class SubagentSession {
379
371
  this.spawn.execution.host = ref;
380
372
  // The pane exists now, so the harness can bring it into its launch state.
381
373
  await harness.prepare({ pi, paneId: ref.paneId, cwd: plan.cwd });
382
- const { supervisor, ipc } = createPaneSupervisor({
374
+ const supervisor = createPaneSupervisor({
383
375
  host,
384
376
  resultFile: launch.resultFile,
385
377
  supervisorOptions: this.supervisorOptions(),
386
378
  transport: this.deps.transport,
387
- agentId: this.spawn.id,
388
- onFrame: (frame) => this.handleFrame(launch, frame),
389
379
  });
390
380
  this.supervisor = supervisor;
391
- this.ipc = ipc;
392
- // The child connects at boot, so the parent must already be listening.
393
- await this.openChannel(launch);
394
381
  await supervisor.start({
395
382
  name: agentName,
396
383
  cwd: plan.cwd,
@@ -430,56 +417,6 @@ export class SubagentSession {
430
417
  resultFilePath() {
431
418
  return this.launchState?.resultFile ?? subagentResultFileFor(this.id);
432
419
  }
433
- /**
434
- * Bind the run's channel before the child launches, so the child finds its
435
- * parent listening, and record what the channel can carry. A bind failure is
436
- * not a launch failure: the handshake is observability, and the run's own
437
- * reporting does not depend on it.
438
- */
439
- async openChannel(launch) {
440
- const { ipc } = this;
441
- if (ipc === undefined || ipc.start === undefined) {
442
- launch.handshake = {
443
- kind: "unavailable",
444
- reason: "no-channel",
445
- };
446
- return;
447
- }
448
- try {
449
- await ipc.start();
450
- launch.handshake = { kind: "awaiting" };
451
- }
452
- catch (error) {
453
- launch.handshake = {
454
- kind: "unavailable",
455
- reason: "bind-failed",
456
- };
457
- log.warn("subagent channel failed to bind", {
458
- agentId: this.id,
459
- errorMessage: errorMessage(error),
460
- });
461
- }
462
- }
463
- /**
464
- * Release the run's channel, leaving the artifacts alone: the run may still
465
- * write reports to them, so only drop() removes the directory.
466
- */
467
- closeChannel() {
468
- const ipc = this.ipc;
469
- this.ipc = undefined;
470
- void ipc?.close?.().catch(() => { });
471
- }
472
- /**
473
- * The child's frames. `ready` is the only kind the protocol defines so far, so
474
- * there is nothing to dispatch on: a ready frame names the run's process, and
475
- * only while the run is still awaiting one — a child reload announces again,
476
- * and a run whose channel was unavailable never gets to this at all.
477
- */
478
- handleFrame(launch, frame) {
479
- if (launch.handshake?.kind === "awaiting") {
480
- launch.handshake = { kind: "announced", pid: frame.pid };
481
- }
482
- }
483
420
  async applySupervisorOutcome(supervisor, outcome) {
484
421
  if (!this.isActive() || this.supervisor !== supervisor)
485
422
  return;
@@ -546,8 +483,6 @@ export class SubagentSession {
546
483
  const settlingRun = this.run;
547
484
  if (settlingRun.shell !== "held" || settlingRun.process.kind !== "settling")
548
485
  return;
549
- // The run is past its last frame: nothing will announce again.
550
- this.closeChannel();
551
486
  // The gate opens once: snapshot the entered run's result before a revive
552
487
  // can re-project the lifecycle to spawned.
553
488
  const result = lifecycleResult(this.spawn.lifecycle);
package/dist/index.js CHANGED
@@ -3,8 +3,7 @@
3
3
  * The tool's per-call `model` parameter is the caller's and is never written
4
4
  * by the listener; config lives in ConfigStore.
5
5
  */
6
- import { setPiInstance, setRuntime, isInsideHerdr } from "./shell.js";
7
- import { announceReadyForSpawn } from "./subagent/ipc-protocol.js";
6
+ import { setPiInstance, setRuntime, isInsideHerdr, detectSubagentSpawn, } from "./shell.js";
8
7
  import { createHerdrRuntime } from "./infrastructure/herdr-host.js";
9
8
  import { missingCloneProgramReport } from "./infrastructure/git/cow-clone.js";
10
9
  import { registerCowboyCommand, registerTools } from "./registration.js";
@@ -27,9 +26,8 @@ export default function (pi) {
27
26
  // Subagents launch through the parent session's `herdr` CLI.
28
27
  if (!isInsideHerdr())
29
28
  return;
30
- // Stay inert so subagents can never spawn further subagents — but first tell
31
- // the parent this process booted.
32
- if (announceReadyForSpawn())
29
+ // Stay inert so subagents can never spawn further subagents.
30
+ if (detectSubagentSpawn() !== undefined)
33
31
  return;
34
32
  // A program the clone path needs is missing, so copy-on-write could never
35
33
  // work here. Staying unregistered says so once; a volume that cannot clone
package/dist/logger.js CHANGED
@@ -5,7 +5,6 @@
5
5
  import { appendFileSync, mkdirSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent";
8
- import { getDetailedString } from "caller-id";
9
8
  const LEVELS = ["debug", "info", "warn", "error"];
10
9
  let minimumLevel = parseLevel(process.env.PI_COWBOY_LOG_LEVEL);
11
10
  const logDir = join(process.cwd(), CONFIG_DIR_NAME);
@@ -15,16 +14,16 @@ export function setLogLevel(level) {
15
14
  }
16
15
  export function createLogger(module) {
17
16
  function debug(msg, data) {
18
- write("debug", module, msg, data, debug);
17
+ write("debug", module, msg, data);
19
18
  }
20
19
  function info(msg, data) {
21
- write("info", module, msg, data, info);
20
+ write("info", module, msg, data);
22
21
  }
23
22
  function warn(msg, data) {
24
- write("warn", module, msg, data, warn);
23
+ write("warn", module, msg, data);
25
24
  }
26
25
  function error(msg, data) {
27
- write("error", module, msg, data, error);
26
+ write("error", module, msg, data);
28
27
  }
29
28
  return { debug, info, warn, error };
30
29
  }
@@ -34,12 +33,11 @@ function parseLevel(value) {
34
33
  ? normalized
35
34
  : "info";
36
35
  }
37
- function write(level, module, msg, data, loggerMethod) {
36
+ function write(level, module, msg, data) {
38
37
  if (LEVELS.indexOf(level) < LEVELS.indexOf(minimumLevel))
39
38
  return;
40
- const caller = getDetailedString(loggerMethod);
41
39
  const suffix = data === undefined ? "" : serializeData(data);
42
- const line = `${new Date().toISOString()} ${level.toUpperCase().padEnd(5)} [${module}] ${caller}() ${msg}${suffix}\n`;
40
+ const line = `${new Date().toISOString()} ${level.toUpperCase().padEnd(5)} [${module}] ${msg}${suffix}\n`;
43
41
  try {
44
42
  mkdirSync(logDir, { recursive: true });
45
43
  appendFileSync(logFile, line, "utf8");
@@ -83,6 +83,15 @@ function settledOutcome(lifecycle) {
83
83
  return assertNever(lifecycle);
84
84
  }
85
85
  }
86
+ /**
87
+ * The settled report's headline: which agent, and how it ended. The settled cue
88
+ * is the run's own report and names no id, so both deliveries — the blocking
89
+ * call's return and the completion nudge — headline it the same way, and the
90
+ * caller always leaves with the id it must still stop, merge and clean up.
91
+ */
92
+ export function settledHeadline(spawn) {
93
+ return `[Cowboy agent "${spawn.display.type}" ${spawn.id} ${lifecycleStatus(spawn.lifecycle)}]`;
94
+ }
86
95
  /** Result text plus status note, for display. Errors pass through verbatim. Worktree settles append a lifecycle note stating what remains and directing the orchestrator to call cleanup_cowboy_agent — removal is never implied to happen on its own. */
87
96
  export function formatResultContent(spawn) {
88
97
  const lifecycle = spawn.lifecycle;
@@ -202,7 +211,10 @@ export class DelegationProtocol {
202
211
  if (hasOutcome(spawn.lifecycle) && spawn.lifecycle.status === "error") {
203
212
  throw new Error(`agent ${agentId} stopped with an error: ${spawn.lifecycle.error || "no error message was recorded"}`);
204
213
  }
205
- return { message: formatResultContent(spawn), details };
214
+ return {
215
+ message: `${settledHeadline(spawn)}\n\n${formatResultContent(spawn)}`,
216
+ details,
217
+ };
206
218
  }
207
219
  // The spawn-time cue is gated on the worktree the launch will provision, never on a spawn field: its branch names exactly the ref the orchestrator merges.
208
220
  const cueWorktree = worktree;
package/dist/paths.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * paths.ts — extension-level directory resolution.
3
- * Everything here is a FUNCTION, not a module-scope constant: the agent dir
4
- * can be redirected per process, so a snapshot would freeze the wrong
5
- * directory — and resolving it must not pull pi's library barrel into the
2
+ * paths.ts — extension-level directory and staging resolution.
3
+ * A directory resolves per call rather than into a module-scope constant: the
4
+ * agent dir can be redirected per process, so a snapshot would freeze the
5
+ * wrong one. Resolving a directory must not pull pi's library barrel into the
6
6
  * boot-time import graph.
7
7
  */
8
8
  import * as fs from "node:fs";
@@ -56,11 +56,49 @@ export function defaultWorktreeRoot() {
56
56
  }
57
57
  /**
58
58
  * Staging root for a spawn's briefing, prompt and result files:
59
- * `<tmpdir>/pi-cowboy/<agentId>/`. Resolved per call, like every directory
60
- * here, so a `TMPDIR` override moves the whole staging area with it.
59
+ * `<tmpdir>/pi-cowboy/`. Resolved per call, like every directory here, so a
60
+ * `TMPDIR` override moves the whole staging area with it.
61
61
  */
62
62
  export function subagentResultDir() {
63
63
  return path.join(tmpdir(), "pi-cowboy");
64
64
  }
65
+ /**
66
+ * Canonical staging directory for a subagent id. Parent and child derive the
67
+ * same path independently, so no path ever travels between them.
68
+ */
69
+ export function subagentResultDirFor(agentId) {
70
+ return path.join(subagentResultDir(), agentId);
71
+ }
72
+ /** Canonical result.md for a subagent id. */
73
+ export function subagentResultFileFor(agentId) {
74
+ return path.join(subagentResultDirFor(agentId), "result.md");
75
+ }
76
+ /**
77
+ * pi reads a file whenever `--system-prompt`'s value is an existing path, so
78
+ * multi-line instructions ride out of herdr's single-line argv. The staging
79
+ * file name is fixed here, beside the path that joins it.
80
+ */
81
+ const SUBAGENT_SYSTEM_FILE_NAME = "system.md";
82
+ /** The pane's `@<file>` initial message; holds the task text and nothing else. */
83
+ const SUBAGENT_TASK_FILE_NAME = "prompt.md";
84
+ /** pi reads a file from `--system-prompt` when the value names an existing path. */
85
+ export function subagentSystemFileFor(agentId) {
86
+ return path.join(subagentResultDirFor(agentId), SUBAGENT_SYSTEM_FILE_NAME);
87
+ }
88
+ /** Canonical task file for a subagent id — the `@<file>` initial message. */
89
+ export function subagentTaskFileFor(agentId) {
90
+ return path.join(subagentResultDirFor(agentId), SUBAGENT_TASK_FILE_NAME);
91
+ }
92
+ /**
93
+ * Marker prefix a spawn injects into the child's argv so the child can tell it
94
+ * is a subagent. The shape is shell-inert on purpose: herdr types the launch
95
+ * arguments into the pane's shell, and `[...]` would be a glob there — zsh
96
+ * aborts the whole line with "no matches found" before pi ever runs.
97
+ */
98
+ export const SUBAGENT_TOKEN_PREFIX = "cowboy-subagent-";
99
+ /** The marker a spawn injects into the child's argv; see `detectSubagentSpawn`. */
100
+ export function subagentTokenFor(agentId) {
101
+ return `${SUBAGENT_TOKEN_PREFIX}${agentId}`;
102
+ }
65
103
  export const EXTENSION_AGENTS_DIR = fileURLToPath(new URL("../agents/", import.meta.url));
66
104
  export const EXTENSION_ORCHESTRATORS_DIR = fileURLToPath(new URL("../orchestrators/", import.meta.url));
package/dist/shell.js CHANGED
@@ -2,15 +2,13 @@
2
2
  * shell.ts — the single mutable container for all per-session state.
3
3
  * Handler modules read via getter functions — no module-level mutable globals.
4
4
  */
5
- import * as path from "node:path";
6
5
  import { RepoLock } from "./spawn/repo-lock.js";
7
6
  import { resolveWorktreeMaterialization, } from "./spawn/worktree-policy.js";
8
7
  import { resolveHarness } from "./agents/harness.js";
9
8
  import { unprobed } from "./availability.js";
10
9
  import { AgentSpawnStore } from "./agents/agent-spawn-store.js";
11
10
  import { ConfigStore } from "./config/config-store.js";
12
- import { subagentResultDir } from "./paths.js";
13
- import { SUBAGENT_SYSTEM_FILE_NAME, SUBAGENT_TASK_FILE_NAME } from "./types.js";
11
+ import { SUBAGENT_TOKEN_PREFIX } from "./paths.js";
14
12
  const NO_SCAN_DIRS = { user: "", project: "", shared: "" };
15
13
  /** Empty registries — the state every session starts from. */
16
14
  export function createSessionTemplates() {
@@ -181,21 +179,12 @@ export function setRuntime(r) {
181
179
  export function setSessionTemplates(next) {
182
180
  shell.sessionTemplates = next;
183
181
  }
182
+ /** The token within one argv entry; the id is a spawn id or an agent name. */
183
+ const SUBAGENT_TOKEN = new RegExp(`${SUBAGENT_TOKEN_PREFIX}([A-Za-z0-9_-]+)`);
184
184
  /**
185
- * Rides in the child's argv (a worktree-created pane gets no pane env, so env
186
- * is not a reliable channel). When present, the extension stays inert so a
187
- * subagent can never spawn further subagents.
188
- *
189
- * The shape is shell-inert on purpose: herdr types the launch arguments into the
190
- * pane's shell, and `[...]` would be a glob there — zsh aborts the whole
191
- * command line with "no matches found" before pi ever runs.
185
+ * Agent id from our argv's subagent token, or undefined in a root session. The
186
+ * marker is written by `subagentTokenFor`; this is its only reader.
192
187
  */
193
- export function subagentTokenFor(agentId) {
194
- return `cowboy-subagent-${agentId}`;
195
- }
196
- /** The token within one argv entry; the id is a spawn id or an agent name. */
197
- const SUBAGENT_TOKEN = /cowboy-subagent-([A-Za-z0-9_-]+)/;
198
- /** Agent id from our argv's subagent token, or undefined in a root session. */
199
188
  export function detectSubagentSpawn(argv = process.argv) {
200
189
  for (const arg of argv) {
201
190
  const match = SUBAGENT_TOKEN.exec(arg);
@@ -204,22 +193,6 @@ export function detectSubagentSpawn(argv = process.argv) {
204
193
  }
205
194
  return undefined;
206
195
  }
207
- /** Canonical staging directory for a subagent id (parent and child derive the same path). */
208
- export function subagentResultDirFor(agentId) {
209
- return path.join(subagentResultDir(), agentId);
210
- }
211
- /** Canonical result.md for a subagent id. */
212
- export function subagentResultFileFor(agentId) {
213
- return path.join(subagentResultDirFor(agentId), "result.md");
214
- }
215
- /** pi reads a file from `--system-prompt` when the value names an existing path. */
216
- export function subagentSystemFileFor(agentId) {
217
- return path.join(subagentResultDirFor(agentId), SUBAGENT_SYSTEM_FILE_NAME);
218
- }
219
- /** Canonical task file for a subagent id — the `@<file>` initial message. */
220
- export function subagentTaskFileFor(agentId) {
221
- return path.join(subagentResultDirFor(agentId), SUBAGENT_TASK_FILE_NAME);
222
- }
223
196
  export function isInsideHerdr() {
224
197
  return process.env.HERDR_ENV === "1";
225
198
  }