pi-subagents 0.87.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 +50 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +3 -3
- package/bundle/{chunk-3CVOAS77.js → chunk-2DIEL4WG.js} +2 -2
- package/bundle/{chunk-ESWW6XSX.js → chunk-47ZN7NKR.js} +1 -1
- package/bundle/{chunk-C3KWLXDH.js → chunk-4MVDMA5C.js} +9 -1
- package/bundle/{chunk-XV7RTWTS.js → chunk-4ZQBZDF3.js} +21 -6
- package/bundle/{chunk-LZKVUWIY.js → chunk-5EMPFFO4.js} +30 -5
- package/bundle/{chunk-OOE3R7IQ.js → chunk-6CG2VAG4.js} +2 -2
- package/bundle/{chunk-LFKMM3UH.js → chunk-6OWNDN7R.js} +2 -2
- package/bundle/{chunk-HDICKROY.js → chunk-7OX6O7DQ.js} +31 -14
- package/bundle/{chunk-PGU4TZV3.js → chunk-CPSUJHZE.js} +417 -455
- package/bundle/{chunk-W52LJANO.js → chunk-CYKNHFXB.js} +1 -1
- package/bundle/{chunk-SIAQXPJ4.js → chunk-D32H53HM.js} +21 -9
- package/bundle/{chunk-YEXKJJVS.js → chunk-DSHQWGHO.js} +4 -4
- package/bundle/{chunk-DGTZKYIE.js → chunk-FLNDHNPE.js} +75 -44
- package/bundle/{chunk-6O7YH2QV.js → chunk-GDR2ILWY.js} +1 -1
- package/bundle/{chunk-C5QWQSSM.js → chunk-KXW62VBU.js} +1 -1
- package/bundle/{chunk-BFF6YDK6.js → chunk-L4YY2TOE.js} +1 -1
- package/bundle/{chunk-2NY5PCKQ.js → chunk-LV3CPYXJ.js} +4 -4
- package/bundle/{chunk-AIL46SZU.js → chunk-N6TAAIB3.js} +6 -4
- package/bundle/{chunk-EYGBK6CE.js → chunk-PCZEQQAQ.js} +114 -49
- package/bundle/{chunk-2D2DQGC2.js → chunk-PYKBTBY6.js} +27 -10
- package/bundle/{chunk-M2VBGET6.js → chunk-RMZAAXIR.js} +7 -2
- package/bundle/{chunk-OTLDAYEQ.js → chunk-VTUUOLM4.js} +14 -5
- package/bundle/{chunk-VFUFOZBU.js → chunk-W6HIYD2Z.js} +1 -1
- package/bundle/{chunk-USRX7QXD.js → chunk-XIA5GSEU.js} +2 -2
- package/bundle/{chunk-CTPAE36Y.js → chunk-YARY7JWU.js} +22 -0
- package/bundle/chunk-YDZ7BZD5.js +523 -0
- package/bundle/{chunk-JLDQ6YUR.js → chunk-YQSTGPEU.js} +12 -12
- package/bundle/{chunk-OZCPYJEY.js → chunk-ZJ2BT5TI.js} +130 -49
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- 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 +4 -2
- package/docs/configuration.md +7 -3
- package/docs/observability.md +2 -0
- package/docs/tool-reference.md +4 -1
- package/docs/workflows.md +3 -1
- package/package.json +2 -2
- package/skills/pi-subagents/SKILL.md +8 -2
- package/src/agents/agent-management.d.ts +1 -0
- package/src/agents/agent-management.js +12 -4
- package/src/agents/agents.d.ts +1 -0
- package/src/agents/agents.js +2 -2
- package/src/extension/config.d.ts +1 -0
- package/src/extension/config.js +6 -0
- package/src/extension/index.d.ts +1 -1
- package/src/extension/index.js +47 -23
- package/src/extension/schemas.d.ts +2 -0
- package/src/extension/schemas.js +1 -0
- package/src/extension/subagent-launch-tool.d.ts +6 -2
- package/src/extension/subagent-launch-tool.js +13 -9
- package/src/extension/tool-activation.js +20 -3
- package/src/runs/background/async-resume.js +2 -1
- package/src/runs/background/async-retention.d.ts +0 -2
- package/src/runs/background/async-retention.js +11 -5
- package/src/runs/background/async-status.d.ts +2 -0
- package/src/runs/background/async-status.js +4 -0
- package/src/runs/background/run-child-session.d.ts +2 -2
- package/src/runs/background/run-child-session.js +4 -7
- package/src/runs/background/stale-run-reconciler.js +17 -8
- package/src/runs/background/steering.d.ts +2 -11
- package/src/runs/background/steering.js +11 -6
- package/src/runs/background/subagent-runner.d.ts +0 -2
- package/src/runs/background/subagent-runner.js +73 -58
- package/src/runs/foreground/async-steering-action.js +24 -9
- package/src/runs/foreground/execution.js +32 -15
- package/src/runs/foreground/prompt-audit.js +1 -0
- package/src/runs/foreground/subagent-executor.d.ts +1 -8
- package/src/runs/foreground/subagent-executor.js +17 -21
- package/src/runs/shared/async-status-projection.d.ts +2 -0
- package/src/runs/shared/async-status-projection.js +10 -0
- 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 +24 -30
- package/src/runs/shared/mcp-config-sources.d.ts +2 -0
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +5 -5
- package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -15
- package/src/runs/shared/subagent-prompt-runtime.js +14 -2
- package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
- package/src/runs/shared/supervisor-wait-timer.js +61 -0
- package/src/shared/artifacts.d.ts +1 -0
- package/src/shared/artifacts.js +107 -9
- 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/reported-progress.d.ts +1 -0
- package/src/shared/reported-progress.js +12 -0
- package/src/shared/required-child-extensions.d.ts +2 -0
- package/src/shared/required-child-extensions.js +27 -0
- package/src/shared/status-format.d.ts +1 -0
- package/src/shared/status-format.js +1 -1
- package/src/shared/types.d.ts +9 -0
- package/src/shared/utils.d.ts +3 -1
- package/src/shared/utils.js +4 -0
- package/src/tui/fleet.d.ts +7 -2
- package/src/tui/fleet.js +22 -0
- package/src/tui/render.js +33 -2
- package/src/watchdog/permission-arbiter.js +1 -0
- package/src/watchdog/review.d.ts +0 -5
- package/src/watchdog/review.js +2 -1
- package/src/workflows/workflow-script-worker.js +3 -1
- package/bundle/chunk-XSDYTXHF.js +0 -242
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
startWatchdogDiffBaselineCapture,
|
|
12
12
|
writeUserWatchdogEnabled,
|
|
13
13
|
writeWatchdogModelSettings
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-N6TAAIB3.js";
|
|
15
15
|
import {
|
|
16
16
|
resolveGitRepositoryIdentity
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-LV3CPYXJ.js";
|
|
18
18
|
import {
|
|
19
19
|
listAsyncRuns,
|
|
20
20
|
parallelHandoffPath,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
readAsyncRecoveryDescriptor,
|
|
23
23
|
readWorkflowLaunchRecord,
|
|
24
24
|
resolveRetainedWorktreeCwd
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-4ZQBZDF3.js";
|
|
26
26
|
import {
|
|
27
27
|
ownsRun
|
|
28
28
|
} from "./chunk-HXRB42AF.js";
|
|
@@ -54,21 +54,24 @@ import {
|
|
|
54
54
|
resolveMissionStoreLocation,
|
|
55
55
|
validateMissionId,
|
|
56
56
|
workflowRunParamsFingerprint
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-CPSUJHZE.js";
|
|
58
58
|
import {
|
|
59
59
|
requestAsyncCommand,
|
|
60
60
|
watchAsyncControlInbox
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-W6HIYD2Z.js";
|
|
62
62
|
import {
|
|
63
63
|
supervisorChannelDir
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-D32H53HM.js";
|
|
65
|
+
import {
|
|
66
|
+
createRequiredChildExtensionIdentity
|
|
67
|
+
} from "./chunk-YARY7JWU.js";
|
|
65
68
|
import {
|
|
66
69
|
createHerdrClient,
|
|
67
70
|
detectHerdr
|
|
68
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-2DIEL4WG.js";
|
|
69
72
|
import {
|
|
70
73
|
getProjectSubagentsDir
|
|
71
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-YDZ7BZD5.js";
|
|
72
75
|
import {
|
|
73
76
|
ExternalJobProviderError,
|
|
74
77
|
getExternalJobProvider,
|
|
@@ -78,10 +81,11 @@ import {
|
|
|
78
81
|
} from "./chunk-YYREO77V.js";
|
|
79
82
|
import {
|
|
80
83
|
mergeRuntimeAgents
|
|
81
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-KXW62VBU.js";
|
|
82
85
|
import {
|
|
83
86
|
CODE_OWNED_EXTERNAL_CLI_ADAPTER_LABEL,
|
|
84
87
|
EXTERNAL_CLI_ADAPTER_SAFETY,
|
|
88
|
+
MAX_LISTED_AGENTS,
|
|
85
89
|
PI_CODING_AGENT_PACKAGE,
|
|
86
90
|
PI_CODING_AGENT_PACKAGE_ROOT_ENV,
|
|
87
91
|
PROMPT_REDACTED,
|
|
@@ -111,6 +115,7 @@ import {
|
|
|
111
115
|
mergeBuiltinAgentOverride,
|
|
112
116
|
normalizeModelSegment,
|
|
113
117
|
normalizeWorkflowLaneMetadata,
|
|
118
|
+
parseAcceptanceReport,
|
|
114
119
|
parseFrontmatter,
|
|
115
120
|
parsePackageName,
|
|
116
121
|
parseUnquotedList,
|
|
@@ -137,7 +142,7 @@ import {
|
|
|
137
142
|
withFileLease,
|
|
138
143
|
writeAtomicJson,
|
|
139
144
|
writePrivateAtomicJson
|
|
140
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-4MVDMA5C.js";
|
|
141
146
|
import {
|
|
142
147
|
DIRS,
|
|
143
148
|
INTERCOM_DETACH_REQUEST_EVENT,
|
|
@@ -165,6 +170,43 @@ import {
|
|
|
165
170
|
resolveCurrentSubagentCapabilityCeiling
|
|
166
171
|
} from "./chunk-QXASAHIA.js";
|
|
167
172
|
|
|
173
|
+
// src/shared/compaction-interruption.ts
|
|
174
|
+
var stateSymbol = /* @__PURE__ */ Symbol.for("pi-subagents.compaction-interruption.v1");
|
|
175
|
+
var wrappedSymbol = /* @__PURE__ */ Symbol.for("pi-subagents.compaction-interruption.v1.wrapped");
|
|
176
|
+
var globalStore = globalThis;
|
|
177
|
+
var compactions = globalStore[stateSymbol] ??= /* @__PURE__ */ new WeakMap();
|
|
178
|
+
function installCompactionInterruptionCapture(sessionClass) {
|
|
179
|
+
const prototype = sessionClass.prototype;
|
|
180
|
+
const original = prototype.compact;
|
|
181
|
+
if (original[wrappedSymbol]) return;
|
|
182
|
+
const compact = async function(...args) {
|
|
183
|
+
const manager = this.sessionManager;
|
|
184
|
+
const compaction = compactions.get(manager) ?? { calls: 0, interrupted: false, abortPending: false };
|
|
185
|
+
compactions.set(manager, compaction);
|
|
186
|
+
compaction.calls += 1;
|
|
187
|
+
if (this.isStreaming) compaction.interrupted = compaction.abortPending = true;
|
|
188
|
+
try {
|
|
189
|
+
return await original.apply(this, args);
|
|
190
|
+
} finally {
|
|
191
|
+
if (--compaction.calls === 0) compactions.delete(manager);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
compact[wrappedSymbol] = true;
|
|
195
|
+
prototype.compact = compact;
|
|
196
|
+
}
|
|
197
|
+
function compactionInProgress(sessionManager) {
|
|
198
|
+
return compactions.has(sessionManager);
|
|
199
|
+
}
|
|
200
|
+
function compactionInterruptedRun(sessionManager) {
|
|
201
|
+
return compactions.get(sessionManager)?.interrupted === true;
|
|
202
|
+
}
|
|
203
|
+
function takeCompactionAbort(sessionManager) {
|
|
204
|
+
const compaction = compactions.get(sessionManager);
|
|
205
|
+
if (!compaction?.abortPending) return false;
|
|
206
|
+
compaction.abortPending = false;
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
|
|
168
210
|
// src/inspectors/herdr/actions.ts
|
|
169
211
|
import * as fs from "node:fs";
|
|
170
212
|
import * as path from "node:path";
|
|
@@ -3767,7 +3809,8 @@ function handleList(params, ctx) {
|
|
|
3767
3809
|
let scopedAgents = effectiveAgentsForScope(scope, d, ctx.runtimeAgentOwner, ctx.model?.provider);
|
|
3768
3810
|
scopedAgents = scopedAgents.sort((a, b) => a.name.localeCompare(b.name));
|
|
3769
3811
|
const capabilityCeiling = resolveCurrentSubagentCapabilityCeiling(ctx.piSessionId);
|
|
3770
|
-
const
|
|
3812
|
+
const search = typeof params.search === "string" ? params.search.trim().toLowerCase() : "";
|
|
3813
|
+
const visibleAgents = scopedAgents.filter((a) => !a.disabled && (!search || [a.name, a.description, ...a.aliases ?? []].some((text2) => text2.toLowerCase().includes(search))));
|
|
3771
3814
|
const agents = visibleAgents.filter((a) => isAgentAllowedByCapabilityCeiling(a.name, capabilityCeiling));
|
|
3772
3815
|
const restrictedAgents = visibleAgents.filter((a) => !isAgentAllowedByCapabilityCeiling(a.name, capabilityCeiling));
|
|
3773
3816
|
const restrictedSources = capabilityCeilingAgentRestrictionSources(capabilityCeiling);
|
|
@@ -3784,11 +3827,15 @@ function handleList(params, ctx) {
|
|
|
3784
3827
|
const knownProviders = knownModelProviders(ctx.modelRegistry);
|
|
3785
3828
|
const unavailableModels = new Set([...agents, ...restrictedAgents].filter((agent) => (agent.runner?.type ?? "pi") === "pi" && isUnavailableSubagentModel(agent.model, availableModels, agent.modelProvider ?? ctx.model?.provider, knownProviders)));
|
|
3786
3829
|
const formatLine = capabilityMode ? (agent, names) => formatAgentCapabilitiesLine(agent, names, externalCliAvailability, unavailableModels) : formatAgentListLine;
|
|
3830
|
+
const shownAgents = agents.slice(0, MAX_LISTED_AGENTS);
|
|
3831
|
+
const shownRestrictedAgents = restrictedAgents.slice(0, MAX_LISTED_AGENTS - shownAgents.length);
|
|
3832
|
+
const omittedCount = Math.max(0, agents.length + restrictedAgents.length - MAX_LISTED_AGENTS);
|
|
3787
3833
|
const lines = [
|
|
3788
3834
|
capabilityMode ? "Executable agents (capabilities):" : "Executable agents:",
|
|
3789
|
-
...formatAgentListSections(
|
|
3835
|
+
...formatAgentListSections(shownAgents, providerNameSet, formatLine)
|
|
3790
3836
|
];
|
|
3791
|
-
appendRestrictedAgentLines({ lines, agents:
|
|
3837
|
+
appendRestrictedAgentLines({ lines, agents: shownRestrictedAgents, sources: restrictedSources, providerNames: providerNameSet, formatLine });
|
|
3838
|
+
if (omittedCount > 0) lines.push("", `+${omittedCount} more; narrow with {action:"list", options:{search:"<term>"}}`);
|
|
3792
3839
|
appendExternalJobRegistryLine(lines, [...agents, ...restrictedAgents], providerStatus);
|
|
3793
3840
|
appendAgentDiagnosticLines(lines, d.agentDiagnostics);
|
|
3794
3841
|
if (proactiveSuggestions.length) lines.push("", ...proactiveSuggestions);
|
|
@@ -5047,6 +5094,7 @@ function createParentWake(pi, now = Date.now) {
|
|
|
5047
5094
|
let ctx;
|
|
5048
5095
|
let session;
|
|
5049
5096
|
let held = false;
|
|
5097
|
+
let deferred = false;
|
|
5050
5098
|
const reservation = () => {
|
|
5051
5099
|
if (!session) return { sessionId: "" };
|
|
5052
5100
|
const current = reservations.get(session.manager);
|
|
@@ -5069,6 +5117,11 @@ function createParentWake(pi, now = Date.now) {
|
|
|
5069
5117
|
pi.sendMessage(message, { triggerTurn: false });
|
|
5070
5118
|
return true;
|
|
5071
5119
|
}
|
|
5120
|
+
if (session && compactionInProgress(session.manager)) {
|
|
5121
|
+
deferred = true;
|
|
5122
|
+
pi.sendMessage(message, { triggerTurn: false });
|
|
5123
|
+
return true;
|
|
5124
|
+
}
|
|
5072
5125
|
if (ctx.isIdle()) reservation().sentAt = now();
|
|
5073
5126
|
pi.sendMessage(message, options);
|
|
5074
5127
|
return false;
|
|
@@ -5077,19 +5130,21 @@ function createParentWake(pi, now = Date.now) {
|
|
|
5077
5130
|
bindSession(context) {
|
|
5078
5131
|
ctx = context;
|
|
5079
5132
|
session = { manager: context.sessionManager, id: context.sessionManager.getSessionId() };
|
|
5080
|
-
held = false;
|
|
5133
|
+
held = deferred = false;
|
|
5081
5134
|
},
|
|
5082
5135
|
agentStarted() {
|
|
5083
5136
|
reservation().sentAt = void 0;
|
|
5084
|
-
held = false;
|
|
5137
|
+
held = deferred = false;
|
|
5085
5138
|
},
|
|
5086
5139
|
userAborted: () => {
|
|
5087
5140
|
held = true;
|
|
5088
5141
|
},
|
|
5089
|
-
releaseHold: () => {
|
|
5090
|
-
held = false;
|
|
5091
|
-
},
|
|
5092
5142
|
isHeld: () => held,
|
|
5143
|
+
takeDeferredWake() {
|
|
5144
|
+
const wasDeferred = deferred;
|
|
5145
|
+
deferred = false;
|
|
5146
|
+
return wasDeferred;
|
|
5147
|
+
},
|
|
5093
5148
|
sessionShutdown(reason) {
|
|
5094
5149
|
if (reason !== "reload") reservation().sentAt = void 0;
|
|
5095
5150
|
}
|
|
@@ -7328,27 +7383,6 @@ function inheritParentProviders(modelRuntime, parentProviders, claimedProviderId
|
|
|
7328
7383
|
var CHILD_PROMPT_RUNTIME_EXTENSION_PATH = "<inline:pi-subagents:prompt-runtime>";
|
|
7329
7384
|
var CHILD_PROMPT_BOUNDARY_EXTENSION_PATH = "<inline:pi-subagents:prompt-boundary>";
|
|
7330
7385
|
var PI_UNICODE_SPACES = new RegExp("[\\u00A0\\u2000-\\u200A\\u202F\\u205F\\u3000]", "g");
|
|
7331
|
-
function childExtensionFileIdentity(extensionPath) {
|
|
7332
|
-
if (!path12.isAbsolute(extensionPath)) return void 0;
|
|
7333
|
-
try {
|
|
7334
|
-
const stat = fs13.statSync(extensionPath, { bigint: true });
|
|
7335
|
-
return stat.isFile() ? `${stat.dev}:${stat.ino}` : void 0;
|
|
7336
|
-
} catch {
|
|
7337
|
-
return void 0;
|
|
7338
|
-
}
|
|
7339
|
-
}
|
|
7340
|
-
function createRequiredChildExtensionIdentity(requiredPaths) {
|
|
7341
|
-
const aliases = new Map([...requiredPaths].map((extensionPath) => [extensionPath, childExtensionFileIdentity(extensionPath) ?? extensionPath]));
|
|
7342
|
-
const identities = new Set(aliases.values());
|
|
7343
|
-
return (extensionPath) => {
|
|
7344
|
-
const known = aliases.get(extensionPath);
|
|
7345
|
-
if (known !== void 0) return known;
|
|
7346
|
-
const identity = childExtensionFileIdentity(extensionPath);
|
|
7347
|
-
if (identity === void 0 || !identities.has(identity)) return void 0;
|
|
7348
|
-
aliases.set(extensionPath, identity);
|
|
7349
|
-
return identity;
|
|
7350
|
-
};
|
|
7351
|
-
}
|
|
7352
7386
|
function orderChildPromptHooks(result5) {
|
|
7353
7387
|
const runtime = result5.extensions.filter(({ path: path17 }) => path17 === CHILD_PROMPT_RUNTIME_EXTENSION_PATH);
|
|
7354
7388
|
const boundary = result5.extensions.filter(({ path: path17 }) => path17 === CHILD_PROMPT_BOUNDARY_EXTENSION_PATH);
|
|
@@ -7703,7 +7737,7 @@ function createDefaultChildSessionFactory(options = {}) {
|
|
|
7703
7737
|
await session2.bindExtensions({
|
|
7704
7738
|
mode: "print",
|
|
7705
7739
|
onError: (error2) => {
|
|
7706
|
-
if (binding && isRequiredSource(error2.extensionPath)) requiredStartupErrors.push(`${error2.extensionPath} (${error2.event}): ${error2.error}`);
|
|
7740
|
+
if (binding && error2.event !== "register_mcp_server" && isRequiredSource(error2.extensionPath)) requiredStartupErrors.push(`${error2.extensionPath} (${error2.event}): ${error2.error}`);
|
|
7707
7741
|
launch.onExtensionError?.({ extensionPath: error2.extensionPath, event: error2.event, error: error2.error });
|
|
7708
7742
|
}
|
|
7709
7743
|
});
|
|
@@ -7756,14 +7790,37 @@ function createDefaultChildSessionFactory(options = {}) {
|
|
|
7756
7790
|
mcpWaits.delete(cancel);
|
|
7757
7791
|
}
|
|
7758
7792
|
}
|
|
7793
|
+
let reportCompleted = false;
|
|
7794
|
+
const guidanceClosed = "Child completed its acceptance report; resume it for further guidance.";
|
|
7795
|
+
const assertAcceptsGuidance = () => {
|
|
7796
|
+
if (reportCompleted) throw new Error(guidanceClosed);
|
|
7797
|
+
};
|
|
7798
|
+
const rejectQueuedGuidance = () => {
|
|
7799
|
+
session.clearQueue();
|
|
7800
|
+
throw new Error(guidanceClosed);
|
|
7801
|
+
};
|
|
7759
7802
|
const child = {
|
|
7760
|
-
subscribe: (listener) => session.subscribe((event) =>
|
|
7803
|
+
subscribe: (listener) => session.subscribe((event) => {
|
|
7804
|
+
if (event.type === "message_end" && event.message.role === "assistant" && event.message.stopReason === "stop") {
|
|
7805
|
+
const text2 = event.message.content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
7806
|
+
const report = parseAcceptanceReport(text2);
|
|
7807
|
+
if (report.report || report.malformed) {
|
|
7808
|
+
reportCompleted = true;
|
|
7809
|
+
session.clearQueue();
|
|
7810
|
+
session.agent.steer = rejectQueuedGuidance;
|
|
7811
|
+
session.agent.followUp = rejectQueuedGuidance;
|
|
7812
|
+
}
|
|
7813
|
+
}
|
|
7814
|
+
listener(event);
|
|
7815
|
+
}),
|
|
7761
7816
|
prompt: (text2) => session.prompt(text2),
|
|
7762
7817
|
...commands ? { finishCommands: () => commands.finish() } : {},
|
|
7763
7818
|
steer: async (text2) => {
|
|
7819
|
+
assertAcceptsGuidance();
|
|
7764
7820
|
await session.steer(text2);
|
|
7765
7821
|
},
|
|
7766
7822
|
followUp: async (text2) => {
|
|
7823
|
+
assertAcceptsGuidance();
|
|
7767
7824
|
await session.followUp(text2);
|
|
7768
7825
|
},
|
|
7769
7826
|
abort: () => session.abort(),
|
|
@@ -7824,7 +7881,7 @@ function childSessionFactory() {
|
|
|
7824
7881
|
}
|
|
7825
7882
|
function createLazyPlacementFactory(local) {
|
|
7826
7883
|
let placed;
|
|
7827
|
-
const factory = async () => placed ??= (await import("./chunk-
|
|
7884
|
+
const factory = async () => placed ??= (await import("./chunk-DSHQWGHO.js")).createPlacementAwareChildSessionFactory(local);
|
|
7828
7885
|
return {
|
|
7829
7886
|
async create(launch) {
|
|
7830
7887
|
return launch.machine ? (await factory()).create(launch) : local.create(launch);
|
|
@@ -8219,23 +8276,27 @@ function registerSubagentLaunchTool(pi) {
|
|
|
8219
8276
|
pi.registerTool({
|
|
8220
8277
|
name: SUBAGENT_LAUNCH_TOOL,
|
|
8221
8278
|
label: "Subagent launch",
|
|
8222
|
-
description: "A workflow is about to start this subagent. Blocking this call stops that child from starting.",
|
|
8279
|
+
description: "A workflow is about to start this subagent. Blocking this call stops that child from starting; changing its task changes what the child is told.",
|
|
8223
8280
|
parameters,
|
|
8224
8281
|
exposure: "deferred",
|
|
8225
|
-
|
|
8226
|
-
|
|
8282
|
+
// Pi hands execute the input after every tool_call handler ran, so a handler's change to task arrives here.
|
|
8283
|
+
async execute(_toolCallId, params) {
|
|
8284
|
+
return { content: [{ type: "text", text: "Records approval for a workflow child launch; it starts nothing itself." }], details: { task: params.task } };
|
|
8227
8285
|
}
|
|
8228
8286
|
});
|
|
8229
8287
|
}
|
|
8230
8288
|
async function approveWorkflowChildLaunch(ctx, describe, signal) {
|
|
8231
|
-
if (!("executeTool" in ctx)) return
|
|
8289
|
+
if (!("executeTool" in ctx)) return {};
|
|
8232
8290
|
const toolCtx = ctx;
|
|
8233
|
-
if (!toolCtx.tools.some((tool) => tool.name === SUBAGENT_LAUNCH_TOOL)) return
|
|
8291
|
+
if (!toolCtx.tools.some((tool) => tool.name === SUBAGENT_LAUNCH_TOOL)) return {};
|
|
8234
8292
|
const args = describe();
|
|
8235
8293
|
const outcome = await toolCtx.executeTool(SUBAGENT_LAUNCH_TOOL, args, { signal });
|
|
8236
|
-
if (!outcome.isError)
|
|
8294
|
+
if (!outcome.isError) {
|
|
8295
|
+
const task = outcome.result.details?.task;
|
|
8296
|
+
return { task: typeof task === "string" ? task : void 0 };
|
|
8297
|
+
}
|
|
8237
8298
|
const reason = outcome.result.content.flatMap((block) => block.type === "text" ? [block.text] : []).join("\n").trim();
|
|
8238
|
-
return `Workflow child '${args.key}' was not started: the ${SUBAGENT_LAUNCH_TOOL} call was refused${reason ? `: ${reason}` : "."}
|
|
8299
|
+
return { refusal: `Workflow child '${args.key}' was not started: the ${SUBAGENT_LAUNCH_TOOL} call was refused${reason ? `: ${reason}` : "."}` };
|
|
8239
8300
|
}
|
|
8240
8301
|
|
|
8241
8302
|
// src/runs/shared/external-job-bridge.ts
|
|
@@ -8662,6 +8723,10 @@ function sameProviderDiagnostics(left, right) {
|
|
|
8662
8723
|
}
|
|
8663
8724
|
|
|
8664
8725
|
export {
|
|
8726
|
+
installCompactionInterruptionCapture,
|
|
8727
|
+
compactionInProgress,
|
|
8728
|
+
compactionInterruptedRun,
|
|
8729
|
+
takeCompactionAbort,
|
|
8665
8730
|
getInspectorPlugins,
|
|
8666
8731
|
registerInspectorEventListener,
|
|
8667
8732
|
effectiveToolTimeoutMs,
|
|
@@ -7,37 +7,37 @@ 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-
|
|
31
|
-
import "./chunk-
|
|
30
|
+
import "./chunk-CPSUJHZE.js";
|
|
31
|
+
import "./chunk-W6HIYD2Z.js";
|
|
32
32
|
import "./chunk-NIXWDZZV.js";
|
|
33
|
-
import "./chunk-
|
|
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,
|
|
39
39
|
getArtifactsDir
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-YDZ7BZD5.js";
|
|
41
41
|
import {
|
|
42
42
|
snapshotExternalRuns
|
|
43
43
|
} from "./chunk-UKG4V45O.js";
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
formatTokens,
|
|
50
50
|
readStatus,
|
|
51
51
|
shortenPath
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-4MVDMA5C.js";
|
|
53
53
|
import {
|
|
54
54
|
DIRS
|
|
55
55
|
} from "./chunk-JEZOSEWG.js";
|
|
@@ -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)];
|
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
validateAuthorityPolicy,
|
|
12
12
|
validateMissionStoreConfig,
|
|
13
13
|
validateModelResponseAliases
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-CPSUJHZE.js";
|
|
15
15
|
import {
|
|
16
16
|
getAgentDir,
|
|
17
17
|
readStatus,
|
|
18
18
|
validatePermissionConfig,
|
|
19
19
|
writePrivateAtomicJson
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-4MVDMA5C.js";
|
|
21
21
|
import {
|
|
22
22
|
FLEET_KEYBINDING_ACTIONS,
|
|
23
23
|
RUNNER_LAUNCHER_NAME_PATTERN,
|
|
@@ -702,6 +702,10 @@ function validateConfig(config) {
|
|
|
702
702
|
validateOrcaProgressTabsConfig(config.orcaProgressTabs);
|
|
703
703
|
validateRunnerLaunchersConfig(config.runnerLaunchers);
|
|
704
704
|
}
|
|
705
|
+
function resolveConfigDefaultTimeoutMs(raw) {
|
|
706
|
+
if (typeof raw !== "number" || !Number.isInteger(raw) || raw <= 0 || raw > 2147483647) return void 0;
|
|
707
|
+
return raw;
|
|
708
|
+
}
|
|
705
709
|
function getConfigPath() {
|
|
706
710
|
return path2.join(getAgentDir(), "extensions", "subagent", "config.json");
|
|
707
711
|
}
|
|
@@ -747,6 +751,7 @@ export {
|
|
|
747
751
|
acquireActiveAsyncCapacity,
|
|
748
752
|
transferActiveAsyncCapacity,
|
|
749
753
|
resolveScheduledStoreRoot,
|
|
754
|
+
resolveConfigDefaultTimeoutMs,
|
|
750
755
|
resolveAsyncByDefault,
|
|
751
756
|
loadConfig
|
|
752
757
|
};
|
|
@@ -14,20 +14,20 @@ import {
|
|
|
14
14
|
resolveCurrentSessionId,
|
|
15
15
|
resolveWatchdogReviewModel,
|
|
16
16
|
startWatchdogDiffBaselineCapture
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-N6TAAIB3.js";
|
|
18
18
|
import {
|
|
19
19
|
agentStreamOptions,
|
|
20
20
|
opencodeSessionHeaders
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-4ZQBZDF3.js";
|
|
22
22
|
import {
|
|
23
23
|
registerNativeSupervisorClient
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-CYKNHFXB.js";
|
|
25
25
|
import {
|
|
26
26
|
MODEL_ONLY_TOOL
|
|
27
27
|
} from "./chunk-HXRB42AF.js";
|
|
28
28
|
import {
|
|
29
29
|
inheritedNestedRouteOf
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-CPSUJHZE.js";
|
|
31
31
|
import {
|
|
32
32
|
CHILD_WATCHDOG_STATUS_EVENT,
|
|
33
33
|
DEFAULT_WAIT_TOOL_NAME,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
toolBudgetSoftNudge,
|
|
47
47
|
validateAcceptanceReport,
|
|
48
48
|
validateStructuredOutputValue
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-4MVDMA5C.js";
|
|
50
50
|
import {
|
|
51
51
|
INTERCOM_SESSION_IDENTITY_EVENT
|
|
52
52
|
} from "./chunk-JEZOSEWG.js";
|
|
@@ -295,6 +295,7 @@ function createWatchdogPermissionArbiter(options = {}) {
|
|
|
295
295
|
].join("\n");
|
|
296
296
|
const tools = [tool];
|
|
297
297
|
agent = new Agent({
|
|
298
|
+
sessionId,
|
|
298
299
|
initialState: {
|
|
299
300
|
systemPrompt,
|
|
300
301
|
model: selection.model,
|
|
@@ -584,6 +585,11 @@ function modelBefore(messages, forkedAt) {
|
|
|
584
585
|
return void 0;
|
|
585
586
|
}
|
|
586
587
|
var LOADOUT_SECTIONS = /* @__PURE__ */ new Set(["tools", "rules", "docs", "skills", "advertised_subagents", "mcp_servers", "project_context"]);
|
|
588
|
+
function projectInstructionBlocks(section) {
|
|
589
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
590
|
+
for (const match of (section ?? "").matchAll(/<project_instructions\s+path=(["'])(.*?)\1\s*>[\s\S]*?<\/project_instructions>/gi)) blocks.set(match[2], match[0]);
|
|
591
|
+
return blocks;
|
|
592
|
+
}
|
|
587
593
|
function forkInstructions(input) {
|
|
588
594
|
const parent = getCurrentSystemMessage(input.parent);
|
|
589
595
|
const child = getCurrentSystemMessage(input.child);
|
|
@@ -596,6 +602,9 @@ function forkInstructions(input) {
|
|
|
596
602
|
for (const [name, value] of Object.entries(child?.sections ?? {})) {
|
|
597
603
|
if (!LOADOUT_SECTIONS.has(name) && value && parent?.sections?.[name] !== value) parts.push(value);
|
|
598
604
|
}
|
|
605
|
+
const parentFiles = projectInstructionBlocks(parent?.sections?.project_context);
|
|
606
|
+
const missingFiles = [...projectInstructionBlocks(child?.sections?.project_context)].filter(([filePath]) => !parentFiles.has(filePath)).map(([, block]) => block);
|
|
607
|
+
if (missingFiles.length > 0) parts.push(["Project instructions for your working folder, which the parent's prompt does not include:", ...missingFiles].join("\n\n"));
|
|
599
608
|
if (input.boundary) parts.push(input.boundary);
|
|
600
609
|
return `<subagent_instructions>
|
|
601
610
|
${parts.join("\n\n")}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getProjectSubagentsDir
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YDZ7BZD5.js";
|
|
4
4
|
import {
|
|
5
5
|
discoverAgents,
|
|
6
6
|
formatUnknownAgentError,
|
|
7
7
|
resolveAgentName,
|
|
8
8
|
unknownAgentDiagnosticContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4MVDMA5C.js";
|
|
10
10
|
|
|
11
11
|
// src/agents/agent-refinements.ts
|
|
12
12
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -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
|