@vicary/pi-subagents 0.88.0 → 0.89.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.
- package/CHANGELOG.md +54 -1
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +3 -3
- package/bundle/{chunk-6EUQPQY7.js → chunk-443LPCRI.js} +5 -5
- package/bundle/{chunk-4QFZZV3O.js → chunk-4AL6LDBY.js} +3 -1
- package/bundle/{chunk-CKLZ5FGU.js → chunk-4ALRHKGE.js} +1 -1
- package/bundle/{chunk-SVIXQDIV.js → chunk-6JD4XCA4.js} +77 -19
- package/bundle/{chunk-XZXYPZUT.js → chunk-7JLNWAMO.js} +54 -36
- package/bundle/{chunk-RHYVKQQL.js → chunk-7W2IQFP4.js} +4 -4
- package/bundle/{chunk-W6HIYD2Z.js → chunk-A3INCQ6Z.js} +1 -1
- package/bundle/{chunk-JYHTDTOZ.js → chunk-CFIYO2IV.js} +5 -5
- package/bundle/{chunk-CYKNHFXB.js → chunk-EPMRDKQT.js} +1 -1
- package/bundle/{chunk-6PR44R7E.js → chunk-ETDE2VYK.js} +2 -2
- package/bundle/{chunk-4MVDMA5C.js → chunk-GHJ6BH5U.js} +13 -7
- package/bundle/{chunk-IZEKQEY4.js → chunk-HSHLPYCQ.js} +27 -10
- package/bundle/{chunk-3MFYKBKI.js → chunk-HZDLR73C.js} +4 -4
- package/bundle/{chunk-2DIEL4WG.js → chunk-JFACGAJT.js} +2 -2
- package/bundle/{chunk-L4YY2TOE.js → chunk-JRO2CU4D.js} +1 -1
- package/bundle/{chunk-KXW62VBU.js → chunk-KOLLMZ2X.js} +1 -1
- package/bundle/{chunk-TDJKY2NE.js → chunk-LEPIY76E.js} +34 -5
- package/bundle/{chunk-BW5JLKIU.js → chunk-MJHQIUU7.js} +68 -41
- package/bundle/{chunk-47ZN7NKR.js → chunk-NONHDYXE.js} +1 -1
- package/bundle/{chunk-PJSOS2Q4.js → chunk-NQ26PJSQ.js} +96 -96
- package/bundle/{chunk-AOSILI5R.js → chunk-OVBUEVOT.js} +95 -49
- package/bundle/{chunk-NVGQE2H2.js → chunk-PFZZMVD5.js} +75 -32
- package/bundle/{chunk-YDZ7BZD5.js → chunk-S77ZKDLS.js} +1 -1
- package/bundle/{chunk-3DT5X2QC.js → chunk-SLLZJ5EC.js} +50 -18
- package/bundle/{chunk-V7SZMS6W.js → chunk-SWL2EITY.js} +2 -2
- package/bundle/{chunk-XIA5GSEU.js → chunk-UQT2EQ4U.js} +2 -2
- package/bundle/{chunk-YZPVALSQ.js → chunk-WW6GQBBS.js} +4 -4
- package/bundle/{chunk-CTPAE36Y.js → chunk-YARY7JWU.js} +22 -0
- package/bundle/{chunk-GDR2ILWY.js → chunk-ZSCIHMUI.js} +50 -22
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +2 -2
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +9 -9
- package/bundle/project-panes.js +3 -3
- package/bundle/required-child-extensions.js +1 -1
- package/docs/agents.md +14 -6
- package/docs/configuration.md +2 -0
- package/docs/extension-api.md +1 -1
- package/docs/tool-reference.md +1 -1
- package/docs/workflows.md +8 -4
- package/package.json +2 -2
- package/src/extension/herdr-pi-bridge.js +78 -22
- package/src/extension/index.d.ts +1 -1
- package/src/extension/index.js +43 -20
- package/src/extension/schemas.js +1 -1
- package/src/extension/subagent-launch-tool.d.ts +6 -2
- package/src/extension/subagent-launch-tool.js +13 -9
- package/src/extension/subagent-options.js +5 -0
- package/src/intercom/result-intercom.js +3 -2
- package/src/runs/background/notify.d.ts +3 -0
- package/src/runs/background/notify.js +7 -2
- package/src/runs/background/run-status.js +3 -2
- package/src/runs/background/runner-child-launch.js +1 -0
- package/src/runs/background/stale-run-reconciler.js +17 -8
- package/src/runs/background/subagent-runner.js +11 -8
- package/src/runs/foreground/execution.js +8 -7
- package/src/runs/foreground/subagent-executor.js +42 -11
- package/src/runs/shared/child-launch.d.ts +2 -0
- package/src/runs/shared/child-launch.js +7 -4
- package/src/runs/shared/child-session.d.ts +3 -2
- package/src/runs/shared/child-session.js +3 -27
- package/src/runs/shared/herdr-connection.d.ts +6 -0
- package/src/runs/shared/herdr-connection.js +11 -1
- package/src/runs/shared/herdr-machine.d.ts +2 -2
- package/src/runs/shared/herdr-machine.js +47 -22
- package/src/runs/shared/herdr-pane-host.d.ts +7 -19
- package/src/runs/shared/herdr-pane-host.js +48 -33
- package/src/runs/shared/herdr-pi-protocol.d.ts +1 -0
- package/src/runs/shared/herdr-pi-protocol.js +3 -2
- package/src/runs/shared/herdr-placed-run.d.ts +2 -12
- package/src/runs/shared/herdr-placed-run.js +10 -8
- package/src/runs/shared/kept-branch-text.d.ts +8 -0
- package/src/runs/shared/kept-branch-text.js +24 -0
- package/src/runs/shared/local-machine-access.d.ts +4 -1
- package/src/runs/shared/local-machine-access.js +6 -3
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +5 -3
- package/src/runs/shared/mcp-direct-tool-allowlist.js +5 -4
- package/src/runs/shared/mutation-evidence.d.ts +7 -1
- package/src/runs/shared/mutation-evidence.js +18 -2
- package/src/runs/shared/parallel-handoff.js +19 -7
- package/src/runs/shared/placed-run-owner.d.ts +4 -2
- package/src/runs/shared/placed-run-owner.js +15 -7
- package/src/runs/shared/rex-machine.d.ts +7 -3
- package/src/runs/shared/rex-machine.js +12 -9
- package/src/runs/shared/rex-pane-host.js +7 -27
- package/src/runs/shared/single-output.js +2 -2
- package/src/runs/shared/subagent-prompt-runtime.js +33 -0
- package/src/runs/shared/tool-availability.d.ts +4 -0
- package/src/runs/shared/tool-availability.js +7 -0
- package/src/runs/shared/worktree-cleanup-plan.js +2 -2
- package/src/runs/shared/worktree.d.ts +4 -14
- package/src/runs/shared/worktree.js +38 -8
- package/src/shared/compaction-interruption.d.ts +9 -0
- package/src/shared/compaction-interruption.js +47 -0
- package/src/shared/parent-wake.d.ts +3 -2
- package/src/shared/parent-wake.js +14 -3
- package/src/shared/required-child-extensions.d.ts +2 -0
- package/src/shared/required-child-extensions.js +27 -0
- package/src/shared/types.d.ts +26 -2
- package/src/tui/fleet.d.ts +7 -2
- package/src/tui/fleet.js +22 -0
- package/src/workflows/workflow-child-summary.d.ts +2 -1
- package/src/workflows/workflow-child-summary.js +14 -6
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
PROJECT_SUBAGENTS_RELATIVE_DIR,
|
|
6
6
|
canonicalSessionId,
|
|
7
7
|
inspectSessionLease
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-S77ZKDLS.js";
|
|
9
9
|
import {
|
|
10
10
|
DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
|
|
11
11
|
DEFAULT_GLOBAL_CONCURRENCY_LIMIT,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
withFileLease,
|
|
28
28
|
writeAtomicJson,
|
|
29
29
|
writePrivateAtomicJson
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
31
31
|
import {
|
|
32
32
|
DIRS,
|
|
33
33
|
SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
@@ -5978,8 +5978,17 @@ function reconcileAsyncRun(asyncDir, options = {}, observeStatus) {
|
|
|
5978
5978
|
const resultsDir = options.resultsDir ?? DIRS.results;
|
|
5979
5979
|
const resultPath = resultFilePath(resultsDir, runId);
|
|
5980
5980
|
const existingResultPath = effectiveStatus.sessionId ? resultPayloadPathForSessionRun(resultsDir, effectiveStatus.sessionId, runId) ?? (regularFileExists(resultPath) ? resultPath : void 0) : regularFileExists(resultPath) ? resultPath : void 0;
|
|
5981
|
+
const staleAfterMs = options.staleAlivePidMs ?? 24 * 60 * 60 * 1e3;
|
|
5982
|
+
const lastUpdate = effectiveStatus.lastUpdate ?? effectiveStatus.startedAt;
|
|
5983
|
+
const observedScope = options.pidNamespaceScope ? options.pidNamespaceScope() : currentPidNamespaceScope();
|
|
5984
|
+
const runnerLiveness = (pid) => checkRecordedPidLiveness({ pid, pidNamespaceScope: effectiveStatus.pidNamespaceScope, bootId: effectiveStatus.bootId }, {
|
|
5985
|
+
kill: options.kill,
|
|
5986
|
+
observedScope,
|
|
5987
|
+
observedBootId: options.bootId ? options.bootId() : currentBootId()
|
|
5988
|
+
});
|
|
5981
5989
|
if (existingResultPath) {
|
|
5982
|
-
const
|
|
5990
|
+
const runnerStillFinishing = effectiveStatus.state === "running" && effectiveStatus.mode !== "workflow" && typeof effectiveStatus.pid === "number" && effectiveStatus.pidNamespaceScope === observedScope && now - lastUpdate <= staleAfterMs && runnerLiveness(effectiveStatus.pid) === "alive";
|
|
5991
|
+
const terminalStatus = (effectiveStatus.state === "running" || effectiveStatus.state === "queued") && !runnerStillFinishing ? terminalStatusFromResult(effectiveStatus, existingResultPath, now) : void 0;
|
|
5983
5992
|
if (terminalStatus) {
|
|
5984
5993
|
const currentStatus = readStatus(asyncDir);
|
|
5985
5994
|
const currentRootError = failureDiagnostic(currentStatus?.error);
|
|
@@ -6012,14 +6021,8 @@ function reconcileAsyncRun(asyncDir, options = {}, observeStatus) {
|
|
|
6012
6021
|
return { status: null, repaired: false, resultPath };
|
|
6013
6022
|
}
|
|
6014
6023
|
}
|
|
6015
|
-
const liveness =
|
|
6016
|
-
kill: options.kill,
|
|
6017
|
-
observedScope: options.pidNamespaceScope ? options.pidNamespaceScope() : currentPidNamespaceScope(),
|
|
6018
|
-
observedBootId: options.bootId ? options.bootId() : currentBootId()
|
|
6019
|
-
});
|
|
6024
|
+
const liveness = runnerLiveness(effectiveStatus.pid);
|
|
6020
6025
|
if (liveness !== "dead") {
|
|
6021
|
-
const staleAfterMs = options.staleAlivePidMs ?? 24 * 60 * 60 * 1e3;
|
|
6022
|
-
const lastUpdate = effectiveStatus.lastUpdate ?? effectiveStatus.startedAt;
|
|
6023
6026
|
if (now - lastUpdate <= staleAfterMs) return { status: status ?? null, repaired: false, resultPath };
|
|
6024
6027
|
const probe = liveness === "alive" ? "is still live" : "cannot be probed from this process";
|
|
6025
6028
|
const message = `Async runner PID ${effectiveStatus.pid} ${probe}; status has not updated for ${now - lastUpdate}ms, so stale-run reconciliation marked the run failed because PID ownership is unverified.`;
|
|
@@ -6448,8 +6451,13 @@ async function probeWorktreeSource(tx, cwd) {
|
|
|
6448
6451
|
if (repoCheck.status !== 0 || repoCheck.stdout.trim() !== "true") throw new Error("worktree isolation requires a git repository");
|
|
6449
6452
|
const toplevel = (await tx.gitChecked(cwd, ["rev-parse", "--show-toplevel"])).trim();
|
|
6450
6453
|
const status = await tx.gitChecked(toplevel, ["status", "--porcelain", "--", `:!${PROJECT_SUBAGENTS_RELATIVE_DIR}`]);
|
|
6451
|
-
|
|
6452
|
-
|
|
6454
|
+
const changes = status.split("\n").filter((line) => line.trim().length > 0);
|
|
6455
|
+
if (changes.length > 0) {
|
|
6456
|
+
const shown = changes.slice(0, 10).map((line) => ` ${line}`);
|
|
6457
|
+
if (changes.length > shown.length) shown.push(` \u2026 and ${changes.length - shown.length} more`);
|
|
6458
|
+
throw new Error(`worktree isolation requires a clean git working tree: ${toplevel} has ${changes.length} uncommitted change(s):
|
|
6459
|
+
${shown.join("\n")}
|
|
6460
|
+
Commit or stash them first.`);
|
|
6453
6461
|
}
|
|
6454
6462
|
return toplevel;
|
|
6455
6463
|
}
|
|
@@ -7100,6 +7108,7 @@ function cleanupSingleWorktree(setup, worktree, intent) {
|
|
|
7100
7108
|
const errors = [];
|
|
7101
7109
|
let worktreeRemoved = false;
|
|
7102
7110
|
let branchRemoved = false;
|
|
7111
|
+
let keptBranchTip;
|
|
7103
7112
|
if (intent.kind === "preserve" && intent.cleanupBlocker) {
|
|
7104
7113
|
return {
|
|
7105
7114
|
index: worktree.index,
|
|
@@ -7198,11 +7207,29 @@ function cleanupSingleWorktree(setup, worktree, intent) {
|
|
|
7198
7207
|
errors.push(`worktree removal failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
7199
7208
|
}
|
|
7200
7209
|
if (worktreeRemoved) {
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7210
|
+
let deleteBranch = true;
|
|
7211
|
+
if (intent.kind === "preserve") {
|
|
7212
|
+
try {
|
|
7213
|
+
const tip = runGitChecked(setup.cwd, ["rev-parse", "--verify", `refs/heads/${worktree.branch}^{commit}`]).trim();
|
|
7214
|
+
if (tip !== setup.baseCommit) {
|
|
7215
|
+
const containing = runGitChecked(setup.cwd, ["for-each-ref", "--contains", tip, "--format=%(refname)", "refs/heads", "refs/remotes", "refs/tags"]);
|
|
7216
|
+
if (!containing.split("\n").some((ref) => ref && ref !== `refs/heads/${worktree.branch}`)) {
|
|
7217
|
+
keptBranchTip = tip;
|
|
7218
|
+
deleteBranch = false;
|
|
7219
|
+
}
|
|
7220
|
+
}
|
|
7221
|
+
} catch (error) {
|
|
7222
|
+
deleteBranch = false;
|
|
7223
|
+
errors.push(`branch check failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
7224
|
+
}
|
|
7225
|
+
}
|
|
7226
|
+
if (deleteBranch) {
|
|
7227
|
+
try {
|
|
7228
|
+
runGitChecked(setup.cwd, ["branch", "-D", worktree.branch]);
|
|
7229
|
+
branchRemoved = true;
|
|
7230
|
+
} catch (error) {
|
|
7231
|
+
errors.push(`branch removal failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
7232
|
+
}
|
|
7206
7233
|
}
|
|
7207
7234
|
}
|
|
7208
7235
|
return {
|
|
@@ -7214,6 +7241,7 @@ function cleanupSingleWorktree(setup, worktree, intent) {
|
|
|
7214
7241
|
...worktree.recordedBaseDir ? { recordedBaseDir: worktree.recordedBaseDir } : {},
|
|
7215
7242
|
worktreeRemoved,
|
|
7216
7243
|
branchRemoved,
|
|
7244
|
+
...keptBranchTip ? { keptBranchTip } : {},
|
|
7217
7245
|
...errors.length ? { errors } : {}
|
|
7218
7246
|
};
|
|
7219
7247
|
}
|
|
@@ -7414,6 +7442,9 @@ function diffWorktrees(setup, agents, diffsDir) {
|
|
|
7414
7442
|
setup.capturedDiffs = diffs;
|
|
7415
7443
|
return diffs;
|
|
7416
7444
|
}
|
|
7445
|
+
function isWorktreeCleanupTaskDone(task) {
|
|
7446
|
+
return task.worktreeRemoved && (task.branchRemoved || task.keptBranchTip !== void 0);
|
|
7447
|
+
}
|
|
7417
7448
|
function cleanupWorktrees(setup, intent = { kind: "preserve", ...setup.capturedDiffs ? { capturedDiffs: setup.capturedDiffs } : {} }) {
|
|
7418
7449
|
assertWorktreeMutationAllowed();
|
|
7419
7450
|
const tasks = [];
|
|
@@ -7429,7 +7460,7 @@ function cleanupWorktrees(setup, intent = { kind: "preserve", ...setup.capturedD
|
|
|
7429
7460
|
} catch (error) {
|
|
7430
7461
|
errors.push(`worktree prune failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
7431
7462
|
}
|
|
7432
|
-
const state = tasks.every(
|
|
7463
|
+
const state = tasks.every(isWorktreeCleanupTaskDone) && pruned ? "complete" : "partial";
|
|
7433
7464
|
return {
|
|
7434
7465
|
state,
|
|
7435
7466
|
tasks,
|
|
@@ -7623,6 +7654,7 @@ export {
|
|
|
7623
7654
|
resolveExpectedWorktreeAgentCwd,
|
|
7624
7655
|
createWorktrees,
|
|
7625
7656
|
diffWorktrees,
|
|
7657
|
+
isWorktreeCleanupTaskDone,
|
|
7626
7658
|
cleanupWorktrees,
|
|
7627
7659
|
formatWorktreeDiffSummary,
|
|
7628
7660
|
validateModelResponseAliases
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
appendAgentRefinementOverlay
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UQT2EQ4U.js";
|
|
4
4
|
import {
|
|
5
5
|
buildAgentMemoryInjection,
|
|
6
6
|
buildSkillInjection
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
8
8
|
|
|
9
9
|
// src/runs/shared/effective-system-prompt.ts
|
|
10
10
|
function appendSection(prompt, section) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getProjectSubagentsDir
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-S77ZKDLS.js";
|
|
4
4
|
import {
|
|
5
5
|
discoverAgents,
|
|
6
6
|
formatUnknownAgentError,
|
|
7
7
|
resolveAgentName,
|
|
8
8
|
unknownAgentDiagnosticContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
10
10
|
|
|
11
11
|
// src/agents/agent-refinements.ts
|
|
12
12
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildWorkflowChatProgressRows
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7W2IQFP4.js";
|
|
4
4
|
import {
|
|
5
5
|
aggregateStepStatus,
|
|
6
6
|
contextModeBadge,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
projectAsyncWorkflowRows,
|
|
23
23
|
projectWorkflowChecklist,
|
|
24
24
|
workflowGraphStageNodes
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-6JD4XCA4.js";
|
|
26
26
|
import {
|
|
27
27
|
isStaleExtensionContextError,
|
|
28
28
|
isUnboundExtensionRuntimeError,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
formatWorkflowJsonPreview,
|
|
35
35
|
hostStepReportName,
|
|
36
36
|
hostStepVerdictLabel
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-SLLZJ5EC.js";
|
|
38
38
|
import {
|
|
39
39
|
snapshotExternalRuns
|
|
40
40
|
} from "./chunk-UKG4V45O.js";
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
getSingleResultOutput,
|
|
53
53
|
shortenPath,
|
|
54
54
|
unresolvedChildWatchdogBlockers
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
56
56
|
import {
|
|
57
57
|
MAX_WIDGET_JOBS,
|
|
58
58
|
WIDGET_ANIMATION_INTERVAL_MS,
|
|
@@ -68,6 +68,27 @@ function assertRequiredChildExtensionsAdmitted(snapshots, launch) {
|
|
|
68
68
|
const route = launch.machine ? `machine '${launch.machine}'` : launch.runnerType !== void 0 && launch.runnerType !== "pi" ? `runner.type='${launch.runnerType}'` : void 0;
|
|
69
69
|
if (route) throw new Error(`Agent '${launch.agent}' cannot run on ${route}: the host requires child extensions (${ids.join(", ")}) for every runner, and only local native Pi children load them.`);
|
|
70
70
|
}
|
|
71
|
+
function childExtensionFileIdentity(extensionPath) {
|
|
72
|
+
if (!path.isAbsolute(extensionPath)) return void 0;
|
|
73
|
+
try {
|
|
74
|
+
const stat = fs.statSync(extensionPath, { bigint: true });
|
|
75
|
+
return stat.isFile() ? `${stat.dev}:${stat.ino}` : void 0;
|
|
76
|
+
} catch {
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function createRequiredChildExtensionIdentity(requiredPaths) {
|
|
81
|
+
const aliases = new Map([...requiredPaths].map((extensionPath) => [extensionPath, childExtensionFileIdentity(extensionPath) ?? extensionPath]));
|
|
82
|
+
const identities = new Set(aliases.values());
|
|
83
|
+
return (extensionPath) => {
|
|
84
|
+
const known = aliases.get(extensionPath);
|
|
85
|
+
if (known !== void 0) return known;
|
|
86
|
+
const identity = childExtensionFileIdentity(extensionPath);
|
|
87
|
+
if (identity === void 0 || !identities.has(identity)) return void 0;
|
|
88
|
+
aliases.set(extensionPath, identity);
|
|
89
|
+
return identity;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
71
92
|
function hasMandatoryRequiredChildExtensions(snapshot) {
|
|
72
93
|
return snapshot?.some((entry) => entry.requireForAllRunners) === true;
|
|
73
94
|
}
|
|
@@ -88,6 +109,7 @@ export {
|
|
|
88
109
|
registerRequiredChildExtensions,
|
|
89
110
|
resolveRequiredChildExtensions,
|
|
90
111
|
assertRequiredChildExtensionsAdmitted,
|
|
112
|
+
createRequiredChildExtensionIdentity,
|
|
91
113
|
hasMandatoryRequiredChildExtensions,
|
|
92
114
|
writeRetainedRequiredChildExtensions,
|
|
93
115
|
readRetainedRequiredChildExtensions
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
REX_LOCAL_MACHINE,
|
|
4
4
|
getAgentDir,
|
|
5
5
|
getProjectConfigDir,
|
|
6
|
+
resolveLocalLaunchCwd,
|
|
6
7
|
resolveRexLocalPlacement
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
8
9
|
|
|
9
10
|
// src/runs/shared/herdr-machine.ts
|
|
10
11
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
@@ -54,12 +55,20 @@ function decodeHerdrJsonLine(line) {
|
|
|
54
55
|
function shellQuoteRemote(value) {
|
|
55
56
|
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
56
57
|
}
|
|
58
|
+
function shellScriptCommand(script, args = []) {
|
|
59
|
+
return `sh -c ${shellQuoteRemote(script)} sh${args.map((arg) => ` ${shellQuoteRemote(arg)}`).join("")}`;
|
|
60
|
+
}
|
|
57
61
|
function remoteShellCommand(script, args = []) {
|
|
58
|
-
return
|
|
62
|
+
return shellScriptCommand(`PATH="${HERDR_REMOTE_PATH}"; export PATH; ${script}`, args);
|
|
59
63
|
}
|
|
60
64
|
function canonicalHerdrSession(session) {
|
|
61
65
|
return session && session !== "default" ? session : null;
|
|
62
66
|
}
|
|
67
|
+
function herdrLocalEnv(socket, session, source) {
|
|
68
|
+
const { HERDR_SESSION: _session, HERDR_CLIENT_SOCKET_PATH: _client, HERDR_PANE_ID: _pane, HERDR_ENV: _env, HERDR_SOCKET_PATH: _socket, ...env } = source;
|
|
69
|
+
const selected = canonicalHerdrSession(session);
|
|
70
|
+
return { ...env, HERDR_SOCKET_PATH: socket, ...selected ? { HERDR_SESSION: selected } : {} };
|
|
71
|
+
}
|
|
63
72
|
function sshEnvCommand(session, command) {
|
|
64
73
|
const selected = canonicalHerdrSession(session), assignment = selected ? ` HERDR_SESSION=${shellQuoteRemote(selected)}` : "";
|
|
65
74
|
return `/usr/bin/env -u HERDR_SOCKET_PATH -u HERDR_SESSION${assignment} ${remoteShellCommand(command)}`;
|
|
@@ -393,20 +402,13 @@ function parseMachineCatalog(json) {
|
|
|
393
402
|
});
|
|
394
403
|
}
|
|
395
404
|
function readHerdrMachineCatalog(env, herdrBin) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
if (result.error) {
|
|
404
|
-
const code = result.error.code;
|
|
405
|
-
if (code === "ENOENT") throw new Error(`Herdr CLI '${herdrBin}' was not found on PATH. Saved-machine placement needs Herdr installed locally.`);
|
|
406
|
-
throw new Error(`Failed to run herdr machine list --json: ${result.error.message}`);
|
|
407
|
-
}
|
|
408
|
-
if (result.status !== 0) throw new Error(`herdr machine list --json exited with code ${result.status}: ${(result.stderr || result.stdout).trim()}`);
|
|
409
|
-
return parseMachineCatalog(result.stdout);
|
|
405
|
+
return parseMachineCatalog(runLocalHerdr(herdrBin, ["machine", "list", "--json"], env, `Herdr CLI '${herdrBin}' was not found on PATH. Saved-machine placement needs Herdr installed locally.`));
|
|
406
|
+
}
|
|
407
|
+
function runLocalHerdr(bin, args, env, notFound) {
|
|
408
|
+
const result = spawnSync2(bin, args, { env, encoding: "utf-8", maxBuffer: MAX_HERDR_MACHINE_LIST_BYTES, timeout: HERDR_MACHINE_LIST_TIMEOUT_MS, windowsHide: true });
|
|
409
|
+
if (result.error) throw new Error(result.error.code === "ENOENT" ? notFound : `Failed to run herdr ${args.join(" ")}: ${result.error.message}`, { cause: result.error });
|
|
410
|
+
if (result.status !== 0) throw new Error(`herdr ${args.join(" ")} exited with code ${result.status}: ${(result.stderr || result.stdout).trim().slice(0, 512)}`);
|
|
411
|
+
return result.stdout;
|
|
410
412
|
}
|
|
411
413
|
function selectMachine(catalog, requested) {
|
|
412
414
|
const byId = catalog.find((entry) => entry.id === requested);
|
|
@@ -513,12 +515,34 @@ function resolveHerdrMachinePlacement(input) {
|
|
|
513
515
|
...settings?.env ? { env: settings.env } : {}
|
|
514
516
|
};
|
|
515
517
|
}
|
|
518
|
+
function resolveHerdrLocalPlacement(input) {
|
|
519
|
+
if (process.platform === "win32") throw new Error("Machine 'local' runs the child in a Herdr pane, which is not supported on Windows.");
|
|
520
|
+
const env = input.env, paneId = env.HERDR_PANE_ID.trim(), bin = input.herdrBin ?? env.HERDR_BIN ?? "herdr", notFound = `Machine 'local' needs the Herdr CLI, but '${bin}' was not found on PATH.`;
|
|
521
|
+
let endpoint;
|
|
522
|
+
try {
|
|
523
|
+
endpoint = parseHerdrEndpoint(runLocalHerdr(bin, ["status", "server", "--json"], env, notFound), env.HERDR_SESSION);
|
|
524
|
+
} catch (error) {
|
|
525
|
+
throw new Error(`Machine 'local' could not confirm this pane's Herdr server: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
526
|
+
}
|
|
527
|
+
let pane;
|
|
528
|
+
try {
|
|
529
|
+
pane = JSON.parse(runLocalHerdr(bin, ["pane", "get", paneId], herdrLocalEnv(endpoint.socket, endpoint.session, env), notFound));
|
|
530
|
+
} catch (error) {
|
|
531
|
+
throw new Error(`Machine 'local' needs this Pi's Herdr pane ${paneId}, but the Herdr server at ${endpoint.socket} did not return it: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
532
|
+
}
|
|
533
|
+
const result = pane?.result;
|
|
534
|
+
if (result?.type !== "pane_info" || result.pane?.pane_id !== paneId) throw new Error(`The Herdr server at ${endpoint.socket} did not confirm pane ${paneId}.`);
|
|
535
|
+
return { provider: "herdr", id: REX_LOCAL_MACHINE, socket: endpoint.socket, ...endpoint.session ? { session: endpoint.session } : {}, cwd: resolveLocalLaunchCwd(input.cwd, input.stepCwd) };
|
|
536
|
+
}
|
|
516
537
|
function resolveMachinePlacement(input) {
|
|
517
538
|
const requested = validateMachineName(input.machine);
|
|
518
539
|
const settings = input.settings ?? readMachineSettings(input.cwd, [requested]);
|
|
519
540
|
if (requested === REX_LOCAL_MACHINE) {
|
|
520
|
-
if (settings?.rex) throw new Error("Machine 'local' is reserved for a
|
|
521
|
-
|
|
541
|
+
if (settings?.rex) throw new Error("Machine 'local' is reserved for a new tab on this machine; give the Rex SSH host in subagents.machines.local.rex another name.");
|
|
542
|
+
const env = input.env ?? process.env;
|
|
543
|
+
if (env.HERDR_ENV === "1" && env.HERDR_PANE_ID?.trim()) return { machine: resolveHerdrLocalPlacement({ cwd: input.cwd, stepCwd: input.stepCwd, env, herdrBin: input.herdrBin }) };
|
|
544
|
+
if (env.REX_SESSION?.trim()) return { machine: resolveRexLocalPlacement({ cwd: input.cwd, stepCwd: input.stepCwd, env }) };
|
|
545
|
+
throw new Error("Machine 'local' opens the child in a new tab of the terminal this Pi runs in, but this Pi is running in neither Herdr (HERDR_ENV=1 with HERDR_PANE_ID) nor Rex (REX_SESSION).");
|
|
522
546
|
}
|
|
523
547
|
if (settings?.rex) return { machine: { provider: "rex", id: requested, target: settings.rex.ssh, cwd: validateRemoteCwd(remoteMachineCwd(input.stepCwd, settings.cwd, requested), requested) } };
|
|
524
548
|
return resolveHerdrMachinePlacement(input);
|
|
@@ -527,16 +551,17 @@ var PLACED_RESTORE_UNSUPPORTED = "Pane-native remote Pi does not support fork, r
|
|
|
527
551
|
function formatHerdrMachineRunnerUnsupported(input) {
|
|
528
552
|
if (input.machine === void 0) return void 0;
|
|
529
553
|
const name = input.machine.trim();
|
|
554
|
+
const local = name === REX_LOCAL_MACHINE;
|
|
530
555
|
let rex;
|
|
531
556
|
try {
|
|
532
|
-
rex =
|
|
557
|
+
rex = local || userRexMachine(name);
|
|
533
558
|
} catch (error) {
|
|
534
559
|
return error instanceof Error ? error.message : String(error);
|
|
535
560
|
}
|
|
536
561
|
if (rex) {
|
|
537
|
-
if (input.runnerType !== void 0 && input.runnerType !== "pi") return `Agent '${input.agentName}' requested machine '${name}', but Rex supports native Pi children only. Remove the machine or use a native Pi agent.`;
|
|
562
|
+
if (input.runnerType !== void 0 && input.runnerType !== "pi") return `Agent '${input.agentName}' requested machine '${name}', but ${local ? "machine 'local' runs" : "Rex supports"} native Pi children only. Remove the machine or use a native Pi agent.`;
|
|
538
563
|
if (input.worktree === true) return `Agent '${input.agentName}' requested machine '${name}', but managed worktrees cannot be combined with machine placement.`;
|
|
539
|
-
if (process.platform === "win32") return `Machine '${name}' runs the child in a Rex pane, which is not supported on Windows.`;
|
|
564
|
+
if (process.platform === "win32") return `Machine '${name}' runs the child in ${local ? "a Herdr or Rex pane" : "a Rex pane"}, which is not supported on Windows.`;
|
|
540
565
|
return void 0;
|
|
541
566
|
}
|
|
542
567
|
if (input.runnerType !== void 0 && input.runnerType !== "pi" && input.runnerType !== "external-cli") {
|
|
@@ -551,8 +576,11 @@ function formatHerdrMachineRunnerUnsupported(input) {
|
|
|
551
576
|
}
|
|
552
577
|
|
|
553
578
|
export {
|
|
554
|
-
|
|
579
|
+
shellScriptCommand,
|
|
580
|
+
herdrLocalEnv,
|
|
555
581
|
runBoundedCommand,
|
|
582
|
+
parseHerdrEndpoint,
|
|
583
|
+
SocketRpcClient,
|
|
556
584
|
sshMachineAccess,
|
|
557
585
|
connectHerdrMachine,
|
|
558
586
|
resolveMachinePlacement,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
requestAsyncStop
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-A3INCQ6Z.js";
|
|
4
4
|
import "./chunk-NIXWDZZV.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-GHJ6BH5U.js";
|
|
6
6
|
import "./chunk-JEZOSEWG.js";
|
|
7
7
|
import "./chunk-YFCK7H2S.js";
|
|
8
8
|
import "./chunk-QXASAHIA.js";
|
package/bundle/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HERDR_PI_MODE_ENV
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4AL6LDBY.js";
|
|
4
4
|
|
|
5
5
|
// src/shared/package-version.ts
|
|
6
6
|
import * as fs from "node:fs";
|
|
@@ -17,7 +17,7 @@ function readInstalledPackageVersion() {
|
|
|
17
17
|
var loadedPackageVersion = readInstalledPackageVersion();
|
|
18
18
|
|
|
19
19
|
// index.ts
|
|
20
|
-
var registerExtension = process.env[HERDR_PI_MODE_ENV] === "1" ? (await import("./chunk-
|
|
20
|
+
var registerExtension = process.env[HERDR_PI_MODE_ENV] === "1" ? (await import("./chunk-PFZZMVD5.js")).default : process.env.PI_SUBAGENT_CHILD === "1" ? void 0 : (await import("./chunk-7JLNWAMO.js")).default;
|
|
21
21
|
function registerSubagentExtension(pi) {
|
|
22
22
|
const installedVersion = readInstalledPackageVersion();
|
|
23
23
|
if (installedVersion !== loadedPackageVersion) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveIntercomSessionTarget
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NONHDYXE.js";
|
|
4
4
|
import "./chunk-7F6RKT6W.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-GHJ6BH5U.js";
|
|
6
6
|
import "./chunk-JEZOSEWG.js";
|
|
7
7
|
import "./chunk-YFCK7H2S.js";
|
|
8
8
|
import "./chunk-QXASAHIA.js";
|
package/bundle/preflight.js
CHANGED
|
@@ -2,22 +2,22 @@ import {
|
|
|
2
2
|
buildEffectiveSystemPrompt,
|
|
3
3
|
canPreferForkFromSnapshot,
|
|
4
4
|
resolveSubagentLaunchContext
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-SWL2EITY.js";
|
|
6
|
+
import "./chunk-UQT2EQ4U.js";
|
|
7
7
|
import {
|
|
8
8
|
loadConfig
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ETDE2VYK.js";
|
|
10
10
|
import {
|
|
11
11
|
nestedResultsPath,
|
|
12
12
|
processTerminalCandidatePath,
|
|
13
13
|
processTerminalPath,
|
|
14
14
|
resultFilePath
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-SLLZJ5EC.js";
|
|
16
16
|
import {
|
|
17
17
|
applyIntercomBridgeToAgent,
|
|
18
18
|
resolveIntercomBridge,
|
|
19
19
|
validateIntercomBridgeConfig
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-NONHDYXE.js";
|
|
21
21
|
import {
|
|
22
22
|
AGENT_DEFINITION_PROJECTION_VERSION,
|
|
23
23
|
resolveLaunchBinding,
|
|
@@ -26,15 +26,15 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
applyThinkingSuffix,
|
|
28
28
|
resolvePiLaunchToolPlan
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-HZDLR73C.js";
|
|
30
30
|
import {
|
|
31
31
|
assertRequiredChildExtensionsAdmitted,
|
|
32
32
|
resolveRequiredChildExtensions
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-YARY7JWU.js";
|
|
34
34
|
import {
|
|
35
35
|
getArtifactPaths,
|
|
36
36
|
getArtifactsDir
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-S77ZKDLS.js";
|
|
38
38
|
import {
|
|
39
39
|
assertClaudeCodeModelScope,
|
|
40
40
|
assertThinkingWithinCeiling,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
resolveSkillsWithFallback,
|
|
62
62
|
resolveStepBehavior,
|
|
63
63
|
unknownAgentDiagnosticContext
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
65
65
|
import {
|
|
66
66
|
DIRS,
|
|
67
67
|
SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
package/bundle/project-panes.js
CHANGED
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
openProjectPane,
|
|
9
9
|
projectPaneBindingPath,
|
|
10
10
|
readProjectPaneBinding
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-JFACGAJT.js";
|
|
12
12
|
import "./chunk-7J4ZXMY7.js";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-S77ZKDLS.js";
|
|
14
|
+
import "./chunk-GHJ6BH5U.js";
|
|
15
15
|
import "./chunk-JEZOSEWG.js";
|
|
16
16
|
import "./chunk-YFCK7H2S.js";
|
|
17
17
|
import "./chunk-QXASAHIA.js";
|
package/docs/agents.md
CHANGED
|
@@ -269,6 +269,8 @@ A custom agent file that shadows a bundled agent replaces the bundled definition
|
|
|
269
269
|
|
|
270
270
|
Native Pi and the six code-owned Claude Code, Codex, and Cursor profiles can run on a Herdr machine (`herdr machine add <target> --label <name>`). Herdr owns each visible agent process in a fresh no-focus pane; SSH is used only as bounded transport for Herdr RPC and ownership checks. Herdr's catalog is the host allowlist; raw ssh targets are rejected.
|
|
271
271
|
|
|
272
|
+
For a pane on this machine you don't need a saved machine: run Pi inside Herdr and use `machine: "local"`.
|
|
273
|
+
|
|
272
274
|
`machine` is a top-level frontmatter key, a settings override (`subagents.agentOverrides.<agent>.machine`, project beats user, `false` clears a pin), and a launch option on the `subagent` tool, workflow `runs.run`, chain, parallel, and dynamic-fanout steps. The launch option wins. Placement survives `subagent({ action: "disable" })`, `reset`, and model profile switches.
|
|
273
275
|
|
|
274
276
|
`cwd` means the directory on that machine when a machine is set. An absolute path or `~/...` is used as given; a relative path joins the repo's configured machine root; with no cwd the root is used; with no root the launch fails closed naming the setting:
|
|
@@ -288,13 +290,15 @@ Placed external profiles are one-shot and stop-only: they cannot steer, resume,
|
|
|
288
290
|
|
|
289
291
|
pi-subagents never clones, pulls, or checks out on the machine. Generic `external-cli` commands and managed worktrees are rejected before launch; saved-machine placement accepts native Pi and only the six code-owned external profiles.
|
|
290
292
|
|
|
291
|
-
## Running a Pi child in a
|
|
293
|
+
## Running a Pi child in a new tab on this machine (Rex or Herdr)
|
|
294
|
+
|
|
295
|
+
`machine: "local"` runs a native Pi child as a visible Pi in a new background tab of the terminal this Pi runs in, labeled `subagent-<run id tail>`. Inside Rex, that is a tab in your Rex session. Inside a Herdr pane (`HERDR_ENV=1` and `HERDR_PANE_ID` set), it is a tab in your own Herdr session, reached over the local Herdr socket with no saved machine and no SSH. When both are set (Herdr running inside a Rex tab), Herdr wins, because the Herdr pane is where Pi is drawn. Outside both, or when the Rex or Herdr server does not confirm this Pi's session or pane, the launch fails before anything starts. `local` is reserved and never looks in the Herdr catalog. It works wherever `machine` works: frontmatter, settings overrides, the `subagent` tool, workflow `runs.run`, chain, parallel, and dynamic-fanout steps.
|
|
292
296
|
|
|
293
|
-
|
|
297
|
+
The parent drives the child through the same bridge as a Herdr-placed Pi: prompt, steer, follow-up, abort, `contact_supervisor`, and results. The child Pi loads pi-subagents from its own extensions, so it must be installed at the same version. `cwd` is a directory on this machine; a relative path joins the launch directory. In Herdr, the tab opens in the `pi-subagents-…` workspace pi-subagents made for that directory if there is one, else in the one workspace with a pane in that directory, else in a new no-focus `pi-subagents-…` workspace. In Rex, pi-subagents finds `rex` in `$REX_BIN_DIR`, then on `PATH`, then in the Rex server app; in Herdr, it runs `herdr` from `$HERDR_BIN` or `PATH`.
|
|
294
298
|
|
|
295
|
-
|
|
299
|
+
A finished child keeps its tab open, with the idle Pi, until you close it; an aborted or stopped child's tab is closed. Limits: native Pi only (Claude Code, Codex, Cursor, and generic `external-cli` agents are rejected), fresh context only, and the same restrictions as a Herdr-placed Pi (no local extension paths, process environment, nested delegation, permission rules, tool budgets, or `outputSchema`).
|
|
296
300
|
|
|
297
|
-
A
|
|
301
|
+
A `local` child edits this machine's disk, so in either terminal it gets the same local cwd check, Git evidence and output-file handling as a child without `machine`.
|
|
298
302
|
|
|
299
303
|
## Running a Pi child in a Rex pane on another Mac
|
|
300
304
|
|
|
@@ -571,6 +575,8 @@ How `tools` behaves:
|
|
|
571
575
|
|
|
572
576
|
An allowlisted name does not load the extension that registers it. Load that provider through `extensions`, `subagentOnlyExtensions`, a path-like `tools` entry, or (background children only) normal Pi extension discovery. Pi's built-in `codemode` is the exception: native children register the host SDK's official factory when codemode is permitted, without enabling it in the main session. On older Pi hosts without that factory, a child that requests codemode still reports it as unavailable; a capability ceiling that denies extensions prevents its registration.
|
|
573
577
|
|
|
578
|
+
An extension loaded in the child can also replace the tools sent to the model, as pi-fabric's code mode does when it offers only `fabric_exec`. A child with a `tools` allowlist then fails before its first model request, and the error names the allowlisted tools the request left out. Set `extensions: []` or list only the extensions the child needs, or omit `tools` to use that extension's tool surface.
|
|
579
|
+
|
|
574
580
|
Ambient extensions depend on where the child runs. Local foreground children are sessions inside the parent Pi process and never load the parent's ambient extensions; otherwise the parent would start a second copy of each ambient extension, including this one. Background children are sessions inside the detached runner process and load the ambient extensions unless the agent sets `extensions` or the capability ceiling denies extensions. Local foreground children do inherit the providers the parent's extensions registered (`pi.registerProvider`), so their models resolve without loading those extensions again. The child gets the provider but not the registering extension's session hooks, so a provider that relies on its own hooks (for example to record each session's system prompt) can fail the child's first request; the foreground error then says so. Use `async: true` or list that extension in the agent's `subagentOnlyExtensions` or `extensions`. Pane-native remote foreground children instead use the remote machine's provider discovery and configuration. Agents that need MCP tools from an ambient adapter such as pi-mcp-adapter (including `mcp:` entries the adapter resolves) must therefore run as background children (`async: true`). A foreground launch of such an agent fails with a diagnostic that says exactly that.
|
|
575
581
|
|
|
576
582
|
More rules:
|
|
@@ -591,9 +597,11 @@ Examples:
|
|
|
591
597
|
|
|
592
598
|
### MCP tools
|
|
593
599
|
|
|
594
|
-
When [pi-mcp-adapter](https://github.com/nicobailon/pi-mcp-adapter) is not installed, `mcp:server` and `mcp:server/tool` entries resolve against Pi's built-in MCP. Name the server and tool as the server reports them: `mcp:my-docs/get-item` selects the tool Pi registers as `mcp__my_docs__get_item`. The server part may also use the `-`→`_` form of its name that Pi's MCP namespace uses, such as `mcp:my_docs`. The child connects the servers in Pi's `mcp.json` (the project's `.pi/mcp.json` only when the parent trusts the project) and gets only the selected tools, as direct tools, whatever exposure the server is configured with; tools configured as `hidden` cannot be selected. Servers that an extension adds with `pi.registerMcpServer()` work in background children, because the registering extension loads there too.
|
|
600
|
+
When [pi-mcp-adapter](https://github.com/nicobailon/pi-mcp-adapter) is not installed, `mcp:server` and `mcp:server/tool` entries resolve against Pi's built-in MCP. Name the server and tool as the server reports them: `mcp:my-docs/get-item` selects the tool Pi registers as `mcp__my_docs__get_item`. The server part may also use the `-`→`_` form of its name that Pi's MCP namespace uses, such as `mcp:my_docs`. The child connects the servers in Pi's `mcp.json` (the project's `.pi/mcp.json` only when the parent trusts the project) and gets only the selected tools, as direct tools, whatever exposure the server is configured with; tools configured as `hidden` cannot be selected. Servers that an extension adds with `pi.registerMcpServer()` work in background children, because the registering extension loads there too. Foreground children load no ambient extensions, so they get only the servers their required child extensions (see Required host extensions) register, and a foreground launch that selects a server from any other extension fails and says to use `async: true`. The child waits for the selected servers' current MCP connection attempts before its first prompt, then rejects the launch if any selected tool is missing or not available as a direct tool. Pi's MCP request timeout still bounds each connection; stopping, interrupting, timing out, or shutting down the child cancels the startup wait. An unrelated server does not delay this check.
|
|
601
|
+
|
|
602
|
+
When pi-mcp-adapter is installed, it keeps priority and provides the direct MCP tools. A background child with omitted `tools` and no capability ceiling uses the adapter's configured direct tools, including `directTools: true`. This also applies to agents that set only `excludeTools`: the child loads the configured tools, then excludes the listed names.
|
|
595
603
|
|
|
596
|
-
|
|
604
|
+
With an explicit `tools` allowlist, include `mcp:` entries for the direct MCP tools the child needs. A capability ceiling continues to restrict the child's MCP selections. The generic `mcp` proxy tool can still be used for discovery when available. The adapter caches tool metadata at startup, so after connecting a new MCP server for the first time, restart Pi before relying on direct tools. Selectors for servers explicitly configured with `disabled: true` are skipped; unknown servers and enabled servers without matching cached tools still fail the launch. Server `includeTools` and `excludeTools` policies are enforced while resolving cached metadata for children: both accept exact names and `*`/`?` glob patterns against raw, generated-resource, and server/short/mcp/none-prefixed names, with `excludeTools` taking precedence. `mcp:` entries must name servers from the adapter's configuration files. A server that exists only in the adapter's runtime snapshot (registered at runtime, not persisted) cannot be provided to a child: children are pi sessions inside the parent or the runner process, not `pi` processes that could receive an MCP config argument, so such a launch fails with an error saying that MCP tools must come from an ambient adapter extension in a background child. An `mcp:` entry named `subagent` does not authorize nested fanout; declare the builtin `subagent` tool or set `allowNestedSubagents: true`. If a resolved direct MCP name is missing from the child registry, pi-subagents keeps the launch failed under the strict allowlist and reports the registration mismatch; check the resolved names against what the host or pi-mcp-adapter actually registers before child startup.
|
|
597
605
|
|
|
598
606
|
### Extension loading
|
|
599
607
|
|
package/docs/configuration.md
CHANGED
|
@@ -668,6 +668,8 @@ Set `worktree` to `true` to make managed worktree isolation the default for laun
|
|
|
668
668
|
|
|
669
669
|
The hook runs once per created worktree. Paths must be absolute, `~/...`, or repo-relative; bare command names are rejected.
|
|
670
670
|
|
|
671
|
+
Before the hook runs, a new worktree gets a `node_modules` link to the main checkout's `node_modules` when one exists, so a worktree that installs nothing can still load its dependencies. A hook that installs dependencies must remove that link first, for example with `fs.rmSync(path.join(worktreePath, "node_modules"), { force: true })`. Otherwise the install writes through the link into the main checkout's `node_modules`.
|
|
672
|
+
|
|
671
673
|
Setup command waits are nonblocking and cancellable through existing run controls. Existing run deadlines and the hook timeout still apply; there is no new setup timeout or configuration.
|
|
672
674
|
|
|
673
675
|
Setup commands, including Git hooks, must be finite and await all descendants before reporting success; do not start background services. Exit zero, natural pipe closure, complete bounded output, and valid JSON/path metadata are trusted completion for launch and cleanup—not observed process-tree proof. Violations are unsupported: protection against deleting a worktree with an undisclosed live descendant is not guaranteed. No additional Windows containment guarantee is provided.
|
package/docs/extension-api.md
CHANGED
|
@@ -152,7 +152,7 @@ A host that shows background subagent activity (an editor panel, a footer, a sta
|
|
|
152
152
|
|
|
153
153
|
`subagent:jobs-changed` carries only `{ version: 1 }`. It fires whenever the parent's background job view changes: a run starts, moves to another step (no other event reports a chain or parallel run's step changes), reports new activity (a tool, a turn, tokens, or output), finishes, or is cleared from the widget. While a child streams output this can be about once per second per run. Starts and finishes fire right away; step and activity changes fire when the parent next reads the run's status file, which on macOS is a check every 5 seconds. It fires only in sessions with a UI, which covers interactive and RPC mode; print mode (`pi -p`) and SDK embeddings without a UI do not get it. It fires even when the async widget is turned off.
|
|
154
154
|
|
|
155
|
-
Foreground children are not background jobs. Their progress arrives as updates to the parent's `subagent` tool call (Pi's `tool_execution_update` events), with the `details.results[]` rows described above.
|
|
155
|
+
Foreground children are not background jobs. Their progress arrives as updates to the parent's `subagent` tool call (Pi's `tool_execution_update` events), with the `details.results[]` rows described above. Each `details.progress[]` row names the child's `sessionFile` from launch when the child has one, so a host can follow the child's transcript while it runs instead of waiting for the final result; the file may appear only once the child writes its first entry.
|
|
156
156
|
|
|
157
157
|
To rebuild what ran in a session after a reload, read the records the session file already holds: the `subagent` tool result's `details.results[]` for foreground runs and the `subagent-notify` message's `details.runs[]` for background runs (see [Host session lifetime and completion wakes](#host-session-lifetime-and-completion-wakes)). The `cost` method returns per-child rows built from the same records.
|
|
158
158
|
|
package/docs/tool-reference.md
CHANGED
|
@@ -114,7 +114,7 @@ The `subagent` tool schema lists `agent`, `task`, `workflow`, `args`, `async`, `
|
|
|
114
114
|
| `options.extensionBindings` | object | none | Child-only plain JSON keyed by namespaces like `package.name/1` (positive version): at most 16 namespaces, nesting depth 16, 256 total object properties, and 16 KiB of canonical UTF-8 JSON. Native Pi launches only; external runners and retained resumes reject it. A child's extensions read it as canonical JSON from `PI_SUBAGENT_EXTENSION_BINDINGS` in their factory or `session_start`; a foreground child sees it only until its session has started, after which the parent's environment is restored. |
|
|
115
115
|
| `options.preflight` | object | none | Advisory lane hints for raw scripts (`workflow: true` or a script path) only; not accepted with named workflows or direct children. See [bounded workflows](workflows.md#opt-in-bounded-workflows). |
|
|
116
116
|
| `cwd` | string | runtime cwd | Override working directory. With `machine`, the directory on that machine. |
|
|
117
|
-
| `options.machine` | string | - | Herdr saved machine (label or profile id)
|
|
117
|
+
| `options.machine` | string | - | Herdr saved machine (label or profile id), a Rex host from settings, or `"local"` (a new tab in the Herdr or Rex session this Pi runs in); see [agents.md](agents.md#running-a-pi-child-in-a-new-tab-on-this-machine-rex-or-herdr). |
|
|
118
118
|
| `options.maxOutput` | object | none | Final output truncation limits `{ bytes?, lines? }`. For child runs it is only applied when set; there is no default cap on the inline path, so use `outputMode: "file-only"` for large outputs. For workflow script results, the Return, Emitted, and Console sections are always capped, at 200 KB / 5000 lines unless `maxOutput` sets other limits. |
|
|
119
119
|
| `options.artifacts` | boolean | true | Write debug artifacts. |
|
|
120
120
|
| `options.includeProgress` | boolean | false | Include full progress in result. |
|