@henryqw/pi-subagent 4.0.0 → 4.0.1
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/dist/index.js +20 -21
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { readFileSync, readdirSync } from "node:fs";
|
|
3
|
-
import { setTimeout as delay } from "node:timers/promises";
|
|
4
3
|
import { isAbsolute, join } from "node:path";
|
|
5
4
|
import { fileURLToPath } from "node:url";
|
|
6
5
|
import { getAgentDir, parseFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
7
|
-
import { createHerdrClient, herdrCommandFailure, hasHerdrErrorCode } from "@henryqw/pi-herdr";
|
|
6
|
+
import { createHerdrClient, herdrCommandFailure, hasHerdrErrorCode, startPiAgent } from "@henryqw/pi-herdr";
|
|
8
7
|
import { modelReference, orderedProfileRoutes, readTaskModelsConfig, resolveConfiguredTaskRoute, resolveTaskModelRoute, } from "@henryqw/pi-task-models";
|
|
9
8
|
export { addUsage, capEphemeralSubagentOutput, createEphemeralSubagentExecutor, EphemeralSubagentError, formatDuration, } from "./ephemeral.js";
|
|
10
9
|
export { createChildWorktree, finalizeChildWorktree, worktreeContextNote, } from "./worktree.js";
|
|
@@ -310,27 +309,27 @@ export async function startManagedSubagent(host, agent, pane, launch, options, h
|
|
|
310
309
|
return "existing";
|
|
311
310
|
}
|
|
312
311
|
await hooks.beforeStart?.();
|
|
313
|
-
const arguments_ = ["agent", "start", name, "--kind", "pi", "--pane", paneId, "--", ...launch.args];
|
|
314
312
|
const herdr = createHerdrClient(options.execute);
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
313
|
+
const startArgs = ["agent", "start", name, "--kind", "pi", "--pane", paneId, "--", ...launch.args];
|
|
314
|
+
const result = await startPiAgent(herdr, {
|
|
315
|
+
name,
|
|
316
|
+
pane: paneId,
|
|
317
|
+
args: launch.args,
|
|
318
|
+
options: { cwd: host.cwd },
|
|
319
|
+
delay: options.delay,
|
|
320
|
+
});
|
|
321
|
+
if (result.code === 0 && !result.killed) {
|
|
322
|
+
await hooks.onStarted?.();
|
|
323
|
+
return "started";
|
|
324
|
+
}
|
|
325
|
+
if (hasHerdrErrorCode(result, "agent_name_taken")) {
|
|
326
|
+
const raced = await getManagedSubagent(host, name, options);
|
|
327
|
+
if (!raced)
|
|
328
|
+
throw new Error(`Herdr agent ${name} reported agent_name_taken but could not be found; refusing to start a duplicate`);
|
|
329
|
+
assertAgentPane(name, paneId, raced);
|
|
330
|
+
return "existing";
|
|
332
331
|
}
|
|
333
|
-
throw new Error(
|
|
332
|
+
throw new Error(herdrCommandFailure(startArgs, result));
|
|
334
333
|
}
|
|
335
334
|
export async function promptManagedSubagent(host, agent, prompt, options) {
|
|
336
335
|
assertAgentName(agent);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henryqw/pi-subagent",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Delegate bounded single, parallel, or chained tasks to isolated Pi roles.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
]
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@henryqw/pi-herdr": "^0.
|
|
63
|
+
"@henryqw/pi-herdr": "^0.4.0",
|
|
64
64
|
"@henryqw/pi-multi-codex": "^0.3.8",
|
|
65
65
|
"@henryqw/pi-task-models": "^1.0.0"
|
|
66
66
|
}
|