@vicary/pi-subagents 0.88.0 → 0.88.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/CHANGELOG.md +18 -0
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-AOSILI5R.js → chunk-2HKPEANZ.js} +75 -40
- package/bundle/{chunk-SVIXQDIV.js → chunk-4ZQBZDF3.js} +2 -2
- package/bundle/{chunk-YZPVALSQ.js → chunk-5EMPFFO4.js} +3 -3
- package/bundle/{chunk-CKLZ5FGU.js → chunk-6CG2VAG4.js} +1 -1
- package/bundle/{chunk-6EUQPQY7.js → chunk-7OX6O7DQ.js} +3 -3
- package/bundle/{chunk-TDJKY2NE.js → chunk-AZPP3G4N.js} +3 -3
- package/bundle/{chunk-BW5JLKIU.js → chunk-BKISQ5CJ.js} +21 -16
- package/bundle/{chunk-XZXYPZUT.js → chunk-CGWNA6EJ.js} +46 -28
- package/bundle/{chunk-3DT5X2QC.js → chunk-CPSUJHZE.js} +11 -8
- package/bundle/{chunk-3MFYKBKI.js → chunk-D32H53HM.js} +3 -3
- package/bundle/{chunk-PJSOS2Q4.js → chunk-DSHQWGHO.js} +1 -1
- package/bundle/{chunk-JYHTDTOZ.js → chunk-IYT7X46U.js} +2 -2
- package/bundle/{chunk-NVGQE2H2.js → chunk-JQTHG2ID.js} +7 -7
- package/bundle/{chunk-RHYVKQQL.js → chunk-LV3CPYXJ.js} +2 -2
- package/bundle/{chunk-IZEKQEY4.js → chunk-PYKBTBY6.js} +23 -6
- package/bundle/{chunk-6PR44R7E.js → chunk-RMZAAXIR.js} +1 -1
- package/bundle/{chunk-CTPAE36Y.js → chunk-YARY7JWU.js} +22 -0
- package/bundle/index.js +1 -1
- package/bundle/preflight.js +4 -4
- package/bundle/required-child-extensions.js +1 -1
- package/docs/agents.md +4 -2
- package/docs/workflows.md +3 -1
- package/package.json +2 -2
- package/src/extension/index.d.ts +1 -1
- package/src/extension/index.js +43 -20
- package/src/extension/subagent-launch-tool.d.ts +6 -2
- package/src/extension/subagent-launch-tool.js +13 -9
- package/src/runs/background/stale-run-reconciler.js +17 -8
- package/src/runs/foreground/subagent-executor.js +11 -6
- package/src/runs/shared/child-launch.js +6 -3
- package/src/runs/shared/child-session.d.ts +1 -1
- package/src/runs/shared/child-session.js +3 -27
- 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/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/tui/fleet.d.ts +7 -2
- package/src/tui/fleet.js +22 -0
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
setInlineWorkflowCoverage,
|
|
11
11
|
setMainThinkingLevelSource,
|
|
12
12
|
widgetRenderKey
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-5EMPFFO4.js";
|
|
14
14
|
import {
|
|
15
15
|
package_default
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-6CG2VAG4.js";
|
|
17
17
|
import {
|
|
18
18
|
EXTERNAL_JOB_BRIDGE_REQUEST_DIR,
|
|
19
19
|
REVIVAL_ORIGIN_FILE,
|
|
@@ -23,6 +23,8 @@ import {
|
|
|
23
23
|
buildSubagentResultIntercomPayload,
|
|
24
24
|
clearProviderRetry,
|
|
25
25
|
compactNestedResultChildren,
|
|
26
|
+
compactionInProgress,
|
|
27
|
+
compactionInterruptedRun,
|
|
26
28
|
controlNotificationKey,
|
|
27
29
|
createParentWake,
|
|
28
30
|
createScheduledRunManager,
|
|
@@ -37,6 +39,7 @@ import {
|
|
|
37
39
|
getInspectorPlugins,
|
|
38
40
|
hasLiveSubagentWork,
|
|
39
41
|
hasWorkflowResumeRefusal,
|
|
42
|
+
installCompactionInterruptionCapture,
|
|
40
43
|
listRetainedChildren,
|
|
41
44
|
listScheduledRunSummaries,
|
|
42
45
|
markSeenWithTtl,
|
|
@@ -60,9 +63,10 @@ import {
|
|
|
60
63
|
sameProviderDiagnostics,
|
|
61
64
|
serviceExternalJobBridgeRequests,
|
|
62
65
|
snapshotProviderDiagnostics,
|
|
66
|
+
takeCompactionAbort,
|
|
63
67
|
workflowResumeClaimState,
|
|
64
68
|
workflowResumeRefusal
|
|
65
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-2HKPEANZ.js";
|
|
66
70
|
import {
|
|
67
71
|
SUBAGENT_CHILD_ENV,
|
|
68
72
|
SUBAGENT_PARENT_SESSION_ENV,
|
|
@@ -82,14 +86,14 @@ import {
|
|
|
82
86
|
resolvePiSessionId,
|
|
83
87
|
resolveWaitToolConfig,
|
|
84
88
|
setDeclarationPinning
|
|
85
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-IYT7X46U.js";
|
|
86
90
|
import {
|
|
87
91
|
deliverAsyncRunStop,
|
|
88
92
|
ownerConfirmedDead,
|
|
89
93
|
readSessionMessagesTail,
|
|
90
94
|
resolveSubagentRunId,
|
|
91
95
|
restoreForegroundRunHistory
|
|
92
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-LV3CPYXJ.js";
|
|
93
97
|
import {
|
|
94
98
|
ASYNC_STATUS_SNAPSHOT_KIND,
|
|
95
99
|
ASYNC_STATUS_SNAPSHOT_VERSION,
|
|
@@ -105,7 +109,7 @@ import {
|
|
|
105
109
|
resolveAsyncStatusChild,
|
|
106
110
|
runLaunchDir,
|
|
107
111
|
stopStoppableAsyncStatusChildren
|
|
108
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-4ZQBZDF3.js";
|
|
109
113
|
import {
|
|
110
114
|
CONTACT_SUPERVISOR_TOOL_NAME,
|
|
111
115
|
NATIVE_SUPERVISOR_TOOL_NAME,
|
|
@@ -141,7 +145,7 @@ import {
|
|
|
141
145
|
resolveDisabledFeatureSurface,
|
|
142
146
|
resolveMaxActiveAsyncRunsPerSession,
|
|
143
147
|
resolveScheduledStoreRoot
|
|
144
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-RMZAAXIR.js";
|
|
145
149
|
import {
|
|
146
150
|
ACTIVE_RUN_INDEX_DIR,
|
|
147
151
|
MissionNotFoundError,
|
|
@@ -192,7 +196,7 @@ import {
|
|
|
192
196
|
withWorkflowChildRunModel,
|
|
193
197
|
writeAsyncResultFile,
|
|
194
198
|
writeResultIndexForData
|
|
195
|
-
} from "./chunk-
|
|
199
|
+
} from "./chunk-CPSUJHZE.js";
|
|
196
200
|
import "./chunk-W6HIYD2Z.js";
|
|
197
201
|
import {
|
|
198
202
|
shouldUseNativeFsWatch
|
|
@@ -201,8 +205,8 @@ import {
|
|
|
201
205
|
validateIntercomBridgeConfig
|
|
202
206
|
} from "./chunk-47ZN7NKR.js";
|
|
203
207
|
import "./chunk-7F6RKT6W.js";
|
|
204
|
-
import "./chunk-
|
|
205
|
-
import "./chunk-
|
|
208
|
+
import "./chunk-D32H53HM.js";
|
|
209
|
+
import "./chunk-YARY7JWU.js";
|
|
206
210
|
import {
|
|
207
211
|
listHerdrProjectPaneRoots,
|
|
208
212
|
restoreHerdrProjectPaneSnapshots
|
|
@@ -317,6 +321,7 @@ import { randomUUID as randomUUID3 } from "node:crypto";
|
|
|
317
321
|
import * as fs16 from "node:fs";
|
|
318
322
|
import * as os3 from "node:os";
|
|
319
323
|
import * as path16 from "node:path";
|
|
324
|
+
import { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
320
325
|
import { Box as Box2, Container as Container3, Spacer as Spacer3, Text as Text2 } from "@earendil-works/pi-tui";
|
|
321
326
|
|
|
322
327
|
// src/agents/global-npm-root.ts
|
|
@@ -5365,7 +5370,7 @@ function registerSlashCommands(pi, state, options = {}) {
|
|
|
5365
5370
|
}
|
|
5366
5371
|
fleetOpen = true;
|
|
5367
5372
|
try {
|
|
5368
|
-
const { openSubagentFleet } = await import("./chunk-
|
|
5373
|
+
const { openSubagentFleet } = await import("./chunk-PYKBTBY6.js");
|
|
5369
5374
|
await openSubagentFleet(ctx, state, { asyncDirRoot: DIRS.async, inspectorPlugins: () => getInspectorPlugins(pi), resultsDir: DIRS.results, fleetKeybindings: options.fleetKeybindings });
|
|
5370
5375
|
} finally {
|
|
5371
5376
|
fleetOpen = false;
|
|
@@ -8691,6 +8696,7 @@ function registerSubagentExtension(pi) {
|
|
|
8691
8696
|
if (process.env[SUBAGENT_CHILD_ENV] === "1") {
|
|
8692
8697
|
return;
|
|
8693
8698
|
}
|
|
8699
|
+
installCompactionInterruptionCapture(AgentSession);
|
|
8694
8700
|
const runtimeRegistry = getRuntimeRegistry();
|
|
8695
8701
|
setMainThinkingLevelSource(() => readMainThinkingLevel(() => pi.getThinkingLevel()));
|
|
8696
8702
|
DIRS.results = ensureAccessibleDir(DIRS.results);
|
|
@@ -8778,7 +8784,7 @@ function registerSubagentExtension(pi) {
|
|
|
8778
8784
|
const ctx = withLastUiContext((current) => current);
|
|
8779
8785
|
if (!ctx) return;
|
|
8780
8786
|
try {
|
|
8781
|
-
const { openSubagentFleet } = await import("./chunk-
|
|
8787
|
+
const { openSubagentFleet } = await import("./chunk-PYKBTBY6.js");
|
|
8782
8788
|
await openSubagentFleet(ctx, state, { initialKey: itemKey, asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: config.fleetKeybindings, inspectorPlugins: () => getInspectorPlugins(pi) });
|
|
8783
8789
|
} catch (error) {
|
|
8784
8790
|
if (isStaleExtensionContextError(error)) {
|
|
@@ -8987,7 +8993,7 @@ function registerSubagentExtension(pi) {
|
|
|
8987
8993
|
let executor;
|
|
8988
8994
|
let executorPromise;
|
|
8989
8995
|
let executorModulePromise;
|
|
8990
|
-
const loadExecutorModule = () => executorModulePromise ??= import("./chunk-
|
|
8996
|
+
const loadExecutorModule = () => executorModulePromise ??= import("./chunk-BKISQ5CJ.js");
|
|
8991
8997
|
const getExecutor = () => {
|
|
8992
8998
|
executorPromise ??= loadExecutorModule().then(({ createSubagentExecutor }) => {
|
|
8993
8999
|
executor = createSubagentExecutor(executorDeps);
|
|
@@ -9001,7 +9007,7 @@ function registerSubagentExtension(pi) {
|
|
|
9001
9007
|
modulePreloadTimer = setTimeout(() => {
|
|
9002
9008
|
loadExecutorModule().catch(() => {
|
|
9003
9009
|
});
|
|
9004
|
-
if (fleetViewEnabled) import("./chunk-
|
|
9010
|
+
if (fleetViewEnabled) import("./chunk-PYKBTBY6.js").catch(() => {
|
|
9005
9011
|
});
|
|
9006
9012
|
}, MODULE_PRELOAD_DELAY_MS);
|
|
9007
9013
|
modulePreloadTimer.unref?.();
|
|
@@ -9174,7 +9180,7 @@ ${close}` }]
|
|
|
9174
9180
|
registerWaitTool(pi, state, waitToolConfig.enabled, waitSubscriptionManager, waitToolConfig.defaultTimeoutMs, void 0, supervisorChannel.hasPendingRequests);
|
|
9175
9181
|
pi.on("agent_end", async (_event, ctx) => {
|
|
9176
9182
|
try {
|
|
9177
|
-
if (ctx.hasUI && ctx.signal?.aborted) {
|
|
9183
|
+
if (ctx.hasUI && ctx.signal?.aborted && !takeCompactionAbort(ctx.sessionManager)) {
|
|
9178
9184
|
parentWake.userAborted();
|
|
9179
9185
|
const active = activeAsyncJobCount();
|
|
9180
9186
|
if (active > 0) ctx.ui.notify(`${active} background subagent run${active === 1 ? " is" : "s are"} still active${slashCommandsEnabled ? " \xB7 /subagents-stop" : ""}`, "info");
|
|
@@ -9490,9 +9496,11 @@ ${close}` }]
|
|
|
9490
9496
|
}
|
|
9491
9497
|
};
|
|
9492
9498
|
let compactionResumeTimer;
|
|
9499
|
+
let compactionInterruptedParent = false;
|
|
9493
9500
|
const cancelCompactionResume = () => {
|
|
9494
9501
|
clearTimeout(compactionResumeTimer);
|
|
9495
9502
|
compactionResumeTimer = void 0;
|
|
9503
|
+
compactionInterruptedParent = false;
|
|
9496
9504
|
};
|
|
9497
9505
|
pi.on("agent_start", () => {
|
|
9498
9506
|
cancelCompactionResume();
|
|
@@ -9512,32 +9520,42 @@ ${close}` }]
|
|
|
9512
9520
|
pi.on("session_before_compact", (event) => {
|
|
9513
9521
|
if (event.reason !== "manual") suspendWidgetsForCompaction();
|
|
9514
9522
|
});
|
|
9515
|
-
|
|
9523
|
+
const wakeAfterCompaction = (completed) => (event, ctx) => {
|
|
9516
9524
|
if (event.reason !== "manual") return;
|
|
9517
|
-
|
|
9518
|
-
|
|
9525
|
+
const sessionManager = ctx.sessionManager;
|
|
9526
|
+
if (completed && compactionInterruptedRun(sessionManager)) compactionInterruptedParent = true;
|
|
9527
|
+
if (compactionResumeTimer) return;
|
|
9519
9528
|
const sessionId = state.currentSessionId;
|
|
9520
9529
|
const deadline = Date.now() + COMPACTION_RESUME_DEADLINE_MS;
|
|
9521
|
-
const
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9530
|
+
const wakeWhenIdle = () => {
|
|
9531
|
+
compactionResumeTimer = void 0;
|
|
9532
|
+
if (state.currentSessionId !== sessionId) return;
|
|
9533
|
+
let idle;
|
|
9534
|
+
try {
|
|
9535
|
+
idle = ctx.isIdle();
|
|
9536
|
+
} catch {
|
|
9527
9537
|
return;
|
|
9528
9538
|
}
|
|
9529
|
-
|
|
9539
|
+
if (!idle || compactionInProgress(sessionManager)) {
|
|
9540
|
+
if (Date.now() < deadline) compactionResumeTimer = setTimeout(wakeWhenIdle, COMPACTION_RESUME_POLL_MS);
|
|
9541
|
+
return;
|
|
9542
|
+
}
|
|
9543
|
+
const interrupted = compactionInterruptedParent && activeAsyncJobCount() > 0 && withLastUiContext(() => true) === true;
|
|
9544
|
+
compactionInterruptedParent = false;
|
|
9545
|
+
if (!parentWake.takeDeferredWake() && !interrupted) return;
|
|
9530
9546
|
parentWake.sendMessage(
|
|
9531
9547
|
{
|
|
9532
9548
|
customType: "subagent-compaction-resume",
|
|
9533
|
-
content: "Compaction is complete. Resume the parent task now; background subagent results will arrive separately when ready.",
|
|
9549
|
+
content: interrupted ? "Compaction is complete. Resume the parent task now; background subagent results will arrive separately when ready." : "Compaction is complete. Act on the background subagent notices above.",
|
|
9534
9550
|
display: false
|
|
9535
9551
|
},
|
|
9536
9552
|
{ triggerTurn: true }
|
|
9537
9553
|
);
|
|
9538
9554
|
};
|
|
9539
|
-
compactionResumeTimer = setTimeout(
|
|
9540
|
-
}
|
|
9555
|
+
compactionResumeTimer = setTimeout(wakeWhenIdle, COMPACTION_RESUME_POLL_MS);
|
|
9556
|
+
};
|
|
9557
|
+
pi.on("session_compact", wakeAfterCompaction(true));
|
|
9558
|
+
pi.on("session_compact_failed", wakeAfterCompaction(false));
|
|
9541
9559
|
pi.on("session_start", (event, ctx) => {
|
|
9542
9560
|
parentWake.bindSession(ctx);
|
|
9543
9561
|
completionNotifier.bindSession(ctx.sessionManager);
|
|
@@ -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.`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
snapshotRequiredChildExtensions
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YARY7JWU.js";
|
|
4
4
|
import {
|
|
5
5
|
THINKING_LEVELS,
|
|
6
6
|
findConfiguredProjectRoot,
|
|
@@ -563,8 +563,8 @@ function formatUnresolvedBuiltinMcpSelectors(agentName, selectors) {
|
|
|
563
563
|
const subject = agentName ? `Agent '${agentName}'` : "Subagent";
|
|
564
564
|
return `${subject} selects MCP tools that Pi's built-in MCP does not offer: ${selectors.map((selector) => `mcp:${selector}`).join(", ")}. The server may be missing, disconnected, still connecting, or its tools hidden; check /mcp.`;
|
|
565
565
|
}
|
|
566
|
-
function extensionOnlyMcpServers(selections, host, cwd, projectTrusted) {
|
|
567
|
-
const registered = new Set(host.getMcpServers?.().map(({ name }) => name));
|
|
566
|
+
function extensionOnlyMcpServers(selections, host, cwd, projectTrusted, loadedByChild) {
|
|
567
|
+
const registered = new Set(host.getMcpServers?.().filter(({ extensionPath }) => !loadedByChild(extensionPath)).map(({ name }) => name));
|
|
568
568
|
const servers = [...new Set(selections.map(({ selector }) => selector.split("/")[0]))].filter((server) => registered.has(server));
|
|
569
569
|
if (servers.length === 0) return [];
|
|
570
570
|
const files = [path2.join(getAgentDir(), "mcp.json"), ...projectTrusted ? [path2.join(cwd, ".pi", "mcp.json")] : []];
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
projectTimeoutRecovery,
|
|
9
9
|
readAsyncRecoveryDescriptor,
|
|
10
10
|
utf8Tail
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-4ZQBZDF3.js";
|
|
12
12
|
import {
|
|
13
13
|
MAX_ARGS_BYTES,
|
|
14
14
|
MAX_ARGS_DEPTH,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
resultFilePath,
|
|
22
22
|
resultPayloadMatchesSessionRun,
|
|
23
23
|
resultPayloadPathForSessionRun
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-CPSUJHZE.js";
|
|
25
25
|
import {
|
|
26
26
|
PROJECT_SUBAGENTS_RELATIVE_DIR
|
|
27
27
|
} from "./chunk-YDZ7BZD5.js";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
rewriteSubagentPrompt
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AZPP3G4N.js";
|
|
4
4
|
import {
|
|
5
5
|
package_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6CG2VAG4.js";
|
|
7
7
|
import {
|
|
8
8
|
WATCHDOG_DIFF_TOOL_NAME,
|
|
9
9
|
captureWatchdogDiffBaseline,
|
|
10
10
|
createWatchdogDiffTool
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-IYT7X46U.js";
|
|
12
|
+
import "./chunk-4ZQBZDF3.js";
|
|
13
13
|
import "./chunk-CYKNHFXB.js";
|
|
14
14
|
import {
|
|
15
15
|
MODEL_ONLY_TOOL
|
|
@@ -18,14 +18,14 @@ import "./chunk-W2BZS6UC.js";
|
|
|
18
18
|
import {
|
|
19
19
|
appendAgentRefinementOverlay
|
|
20
20
|
} from "./chunk-XIA5GSEU.js";
|
|
21
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-CPSUJHZE.js";
|
|
22
22
|
import "./chunk-NIXWDZZV.js";
|
|
23
23
|
import "./chunk-47ZN7NKR.js";
|
|
24
24
|
import "./chunk-7F6RKT6W.js";
|
|
25
25
|
import {
|
|
26
26
|
assertNoToolModifierEntries
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
27
|
+
} from "./chunk-D32H53HM.js";
|
|
28
|
+
import "./chunk-YARY7JWU.js";
|
|
29
29
|
import "./chunk-YDZ7BZD5.js";
|
|
30
30
|
import {
|
|
31
31
|
HERDR_PI_MAX_FRAME_BYTES,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
summarizeContextModes,
|
|
13
13
|
utf8Tail,
|
|
14
14
|
workflowPreflightLaneForRuntimeKey
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-4ZQBZDF3.js";
|
|
16
16
|
import {
|
|
17
17
|
ownsRun
|
|
18
18
|
} from "./chunk-HXRB42AF.js";
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
updateActiveRunIndex,
|
|
35
35
|
validateModelResponseAliases,
|
|
36
36
|
writeAsyncResultFile
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-CPSUJHZE.js";
|
|
38
38
|
import {
|
|
39
39
|
deliverStopRequest,
|
|
40
40
|
stopInboxClosedPath
|
|
@@ -7,32 +7,32 @@ import {
|
|
|
7
7
|
safeTranscriptEvent,
|
|
8
8
|
steerAsyncRun,
|
|
9
9
|
steerWorkflowForegroundTarget
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7OX6O7DQ.js";
|
|
11
11
|
import {
|
|
12
12
|
FLEET_STATUS_WIDGET_KEY,
|
|
13
13
|
runningTone,
|
|
14
14
|
stepTaskSummary
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-5EMPFFO4.js";
|
|
16
16
|
import {
|
|
17
17
|
foregroundChildStateLabel,
|
|
18
18
|
formatAsyncRunTranscript,
|
|
19
19
|
stopAsyncRun
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-LV3CPYXJ.js";
|
|
21
21
|
import {
|
|
22
22
|
contextModeBadge,
|
|
23
23
|
contextModeLabel,
|
|
24
24
|
decodeUtf8Tail,
|
|
25
25
|
listAsyncRuns
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-4ZQBZDF3.js";
|
|
27
27
|
import {
|
|
28
28
|
reportSessionWarning
|
|
29
29
|
} from "./chunk-HXRB42AF.js";
|
|
30
|
-
import "./chunk-
|
|
30
|
+
import "./chunk-CPSUJHZE.js";
|
|
31
31
|
import "./chunk-W6HIYD2Z.js";
|
|
32
32
|
import "./chunk-NIXWDZZV.js";
|
|
33
33
|
import "./chunk-47ZN7NKR.js";
|
|
34
34
|
import "./chunk-7F6RKT6W.js";
|
|
35
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-YARY7JWU.js";
|
|
36
36
|
import "./chunk-7J4ZXMY7.js";
|
|
37
37
|
import {
|
|
38
38
|
getArtifactPaths,
|
|
@@ -940,6 +940,10 @@ var SubagentFleetComponent = class {
|
|
|
940
940
|
actionBusy = false;
|
|
941
941
|
transcriptCache;
|
|
942
942
|
disposed = false;
|
|
943
|
+
// Undefined until a TUI first focuses the overlay, so a fleet rendered outside one still draws.
|
|
944
|
+
hasFocus;
|
|
945
|
+
// The component focused when the fleet opened (the overlay's preFocus).
|
|
946
|
+
openedOver;
|
|
943
947
|
refreshTimer;
|
|
944
948
|
refreshMs;
|
|
945
949
|
tui;
|
|
@@ -951,6 +955,7 @@ var SubagentFleetComponent = class {
|
|
|
951
955
|
keybindings;
|
|
952
956
|
constructor(tui, theme, state, done, options = {}) {
|
|
953
957
|
this.tui = tui;
|
|
958
|
+
this.openedOver = tui.getFocusedComponent?.();
|
|
954
959
|
this.viewport = new FleetViewport(() => this.tui.requestRender());
|
|
955
960
|
this.theme = theme;
|
|
956
961
|
this.markdownTheme = options.markdownTheme ?? getMarkdownTheme();
|
|
@@ -1120,6 +1125,14 @@ var SubagentFleetComponent = class {
|
|
|
1120
1125
|
scrollDetail(delta) {
|
|
1121
1126
|
this.viewport.scroll.scrollBy(delta);
|
|
1122
1127
|
}
|
|
1128
|
+
get focused() {
|
|
1129
|
+
return this.hasFocus === true;
|
|
1130
|
+
}
|
|
1131
|
+
set focused(value) {
|
|
1132
|
+
if (value === this.hasFocus) return;
|
|
1133
|
+
this.hasFocus = value;
|
|
1134
|
+
this.tui.requestRender();
|
|
1135
|
+
}
|
|
1123
1136
|
handleMouse(event) {
|
|
1124
1137
|
if (this.steerDraft !== void 0 || this.redoGuidanceDraft !== void 0 || this.stopConfirming || this.actionBusy) {
|
|
1125
1138
|
return { handled: true, render: false };
|
|
@@ -1417,6 +1430,10 @@ var SubagentFleetComponent = class {
|
|
|
1417
1430
|
return { header: [], body: this.withActionLines(lines) };
|
|
1418
1431
|
}
|
|
1419
1432
|
render(width) {
|
|
1433
|
+
if (this.hasFocus === false && this.tui.getFocusedComponent?.() !== this.openedOver) {
|
|
1434
|
+
this.renderedLayout = void 0;
|
|
1435
|
+
return [];
|
|
1436
|
+
}
|
|
1420
1437
|
const layout = fleetLayout(width, this.tui.terminal?.rows ?? 32, this.selected, this.snapshot.items);
|
|
1421
1438
|
this.renderedLayout = layout;
|
|
1422
1439
|
if (!layout) return [truncateToWidth2("Subagent fleet needs at least 36 columns. Esc closes.", width)];
|
|
@@ -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
|
package/bundle/index.js
CHANGED
|
@@ -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-JQTHG2ID.js")).default : process.env.PI_SUBAGENT_CHILD === "1" ? void 0 : (await import("./chunk-CGWNA6EJ.js")).default;
|
|
21
21
|
function registerSubagentExtension(pi) {
|
|
22
22
|
const installedVersion = readInstalledPackageVersion();
|
|
23
23
|
if (installedVersion !== loadedPackageVersion) {
|
package/bundle/preflight.js
CHANGED
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
import "./chunk-XIA5GSEU.js";
|
|
7
7
|
import {
|
|
8
8
|
loadConfig
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-RMZAAXIR.js";
|
|
10
10
|
import {
|
|
11
11
|
nestedResultsPath,
|
|
12
12
|
processTerminalCandidatePath,
|
|
13
13
|
processTerminalPath,
|
|
14
14
|
resultFilePath
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-CPSUJHZE.js";
|
|
16
16
|
import {
|
|
17
17
|
applyIntercomBridgeToAgent,
|
|
18
18
|
resolveIntercomBridge,
|
|
@@ -26,11 +26,11 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
applyThinkingSuffix,
|
|
28
28
|
resolvePiLaunchToolPlan
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-D32H53HM.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
|
package/docs/agents.md
CHANGED
|
@@ -591,9 +591,11 @@ Examples:
|
|
|
591
591
|
|
|
592
592
|
### MCP tools
|
|
593
593
|
|
|
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.
|
|
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. 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.
|
|
595
595
|
|
|
596
|
-
When pi-mcp-adapter is installed, it keeps priority and provides the direct MCP tools.
|
|
596
|
+
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.
|
|
597
|
+
|
|
598
|
+
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
599
|
|
|
598
600
|
### Extension loading
|
|
599
601
|
|
package/docs/workflows.md
CHANGED
|
@@ -149,7 +149,9 @@ The host resolves the name and validates bounded plain-JSON `args` before starti
|
|
|
149
149
|
|
|
150
150
|
### Approving workflow children in permission extensions
|
|
151
151
|
|
|
152
|
-
Before a workflow starts a child, pi-subagents makes a nested `subagent_launch` tool call, so permission extensions see it in their `tool_call` handler like any other tool call. This covers reply-block, file and named workflows, and `chain` and `tasks`. The call's input is `{ workflowRunId, key, agent?, task?, cwd?, model?, async?, worktree?, resume?, commands?, output? }`. `cwd` is the absolute directory the child starts in. It is left out for a resumed child, which keeps its earlier directory, and for a child placed on another machine. `commands` lists, in run order, the shell commands the child's `gate`, `acceptance.verify` or agent `acceptance` will run on this machine after the child finishes, each `{ command, cwd?, env? }`. A command's `cwd` is absolute and is left out when the child's is; for a `worktree: true` child it names the source directory, because the worktree does not exist yet. `env` lists only the variables the command sets on top of the parent's environment. `output` is the absolute path of the file the child's `output` writes. The other optional fields appear when the child request sets them. A blocked or failed call stops that child, so its commands never run and its output file is never written; it fails with `Workflow child '<key>' was not started: …` and the block reason.
|
|
152
|
+
Before a workflow starts a child, pi-subagents makes a nested `subagent_launch` tool call, so permission extensions see it in their `tool_call` handler like any other tool call. This covers reply-block, file and named workflows, and `chain` and `tasks`. The call's input is `{ workflowRunId, key, agent?, task?, cwd?, model?, async?, worktree?, resume?, commands?, output? }`. `cwd` is the absolute directory the child starts in. It is left out for a resumed child, which keeps its earlier directory, and for a child placed on another machine. `commands` lists, in run order, the shell commands the child's `gate`, `acceptance.verify` or agent `acceptance` will run on this machine after the child finishes, each `{ command, cwd?, env? }`. A command's `cwd` is absolute and is left out when the child's is; for a `worktree: true` child it names the source directory, because the worktree does not exist yet. `env` lists only the variables the command sets on top of the parent's environment. `output` is the absolute path of the file the child's `output` writes. The other optional fields appear when the child request sets them. A blocked or failed call stops that child, so its commands never run and its output file is never written; it fails with `Workflow child '<key>' was not started: …` and the block reason. The tool is not declared to the model.
|
|
153
|
+
|
|
154
|
+
A handler may also change `task` in place (`event.input.task = …`). A freshly launched child then receives the changed text, after `{previous}` is filled in and before any fork preamble is added. Changes to any other field, and to a resumed child's message, are ignored. Handlers run in registration order, so one registered earlier sees the original text.
|
|
153
155
|
|
|
154
156
|
Extensions that ask about tools they have no rule for ask once per workflow child until you allow `subagent_launch`. Ones that deny unknown tools without a UI, as in `pi -p`, refuse every workflow child until you allow it.
|
|
155
157
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@vicary/pi-subagents",
|
|
4
|
-
"version": "0.88.
|
|
4
|
+
"version": "0.88.1",
|
|
5
5
|
"description": "Pi extension for single-agent delegation and scripted multi-agent workflows",
|
|
6
6
|
"author": "Nico Bailon",
|
|
7
7
|
"license": "MIT",
|
|
@@ -135,5 +135,5 @@
|
|
|
135
135
|
"./prompts"
|
|
136
136
|
]
|
|
137
137
|
},
|
|
138
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "5091dc4108789ed257c421b927e7c7b960af5f4b"
|
|
139
139
|
}
|
package/src/extension/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { type HerdrStatusRun } from "../integrations/herdr-status.ts";
|
|
3
3
|
import { type SubagentState } from "../shared/types.ts";
|
|
4
4
|
export declare function projectActiveHerdrRuns(state: SubagentState): HerdrStatusRun[];
|