@xzzpig/pi-subagents 0.7.0 → 0.9.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 +456 -4
- package/README.md +3 -3
- package/agents/claude-code-writer.md +15 -0
- package/agents/claude-code.md +15 -0
- package/agents/codex-exec-writer.md +15 -0
- package/agents/codex-exec.md +15 -0
- package/agents/cursor-agent-writer.md +14 -0
- package/agents/cursor-agent.md +14 -0
- package/agents/reviewer.md +13 -3
- package/agents/scout.md +1 -1
- package/docs/agents.md +154 -42
- package/docs/configuration.md +85 -26
- package/docs/extension-api.md +81 -16
- package/docs/missions.md +2 -0
- package/docs/models.md +75 -11
- package/docs/observability.md +34 -21
- package/docs/tool-reference.md +142 -18
- package/docs/watchdog.md +92 -114
- package/docs/workflows.md +148 -4
- package/index.ts +10 -1
- package/install.mjs +1 -1
- package/package.json +7 -6
- package/prompts/council.md +19 -7
- package/prompts/parallel-review.md +5 -1
- package/prompts/review-loop.md +11 -7
- package/skills/council-mode/SKILL.md +44 -215
- package/skills/council-mode/references/pass-contracts.md +150 -0
- package/skills/pi-subagents/SKILL.md +90 -32
- package/skills/pi-subagents/references/constraints-and-recipes.md +34 -223
- package/skills/pi-subagents/references/execution-controls.md +104 -19
- package/skills/pi-subagents/references/management-authoring-rpc.md +5 -5
- package/skills/pi-subagents/references/multi-lane-orchestration.md +16 -4
- package/skills/pi-subagents/references/prompting-and-roles.md +71 -36
- package/skills/pi-subagents/references/review-and-validation.md +73 -0
- package/src/agents/agent-management.ts +471 -114
- package/src/agents/agent-refinements.ts +4 -4
- package/src/agents/agent-serializer.ts +16 -4
- package/src/agents/agents.ts +1076 -351
- package/src/agents/builtin-names.ts +6 -0
- package/src/agents/runtime-agent-events.ts +70 -0
- package/src/agents/runtime-agent-registry.ts +31 -20
- package/src/api/agents.ts +10 -5
- package/src/api/background-work.ts +12 -3
- package/src/api/capability-ceiling.ts +0 -1
- package/src/api/{pi-args.ts → child-tool-plan.ts} +1 -1
- package/src/api/delegation.ts +0 -7
- package/src/api/external-job-provider.ts +10 -1
- package/src/api/external-runs.ts +67 -4
- package/src/api/preflight.ts +97 -34
- package/src/api/project-panes.ts +2 -0
- package/src/api/shared-types.ts +6 -0
- package/src/extension/config.ts +90 -0
- package/src/extension/doctor.ts +15 -13
- package/src/extension/fanout-child.ts +17 -16
- package/src/extension/index.ts +139 -41
- package/src/extension/public-execution.ts +113 -22
- package/src/extension/rpc.ts +182 -13
- package/src/extension/schemas.ts +63 -21
- package/src/extension/tool-description.ts +48 -23
- package/src/extension/tool-result.ts +19 -0
- package/src/inspectors/herdr/actions.ts +2 -1
- package/src/inspectors/herdr/client.ts +3 -3
- package/src/inspectors/herdr/focus.ts +55 -0
- package/src/inspectors/herdr/inspector-runner.ts +21 -23
- package/src/inspectors/herdr/project-panes.ts +228 -44
- package/src/inspectors/herdr/session-roots-codec.ts +42 -0
- package/src/integrations/herdr-status.ts +75 -5
- package/src/intercom/native-supervisor-channel.ts +138 -60
- package/src/intercom/result-intercom.ts +2 -0
- package/src/intercom/supervisor-ui.ts +243 -0
- package/src/profiles/profiles.ts +5 -6
- package/src/runs/background/active-async-capacity.ts +103 -18
- package/src/runs/background/async-execution.ts +492 -125
- package/src/runs/background/async-job-tracker.ts +127 -28
- package/src/runs/background/async-resume.ts +67 -29
- package/src/runs/background/async-retention.ts +21 -4
- package/src/runs/background/async-status-snapshot.ts +23 -261
- package/src/runs/background/async-status.ts +199 -14
- package/src/runs/background/auto-drain.ts +1 -1
- package/src/runs/background/chain-append.ts +8 -3
- package/src/runs/background/chain-root-attachment.ts +79 -8
- package/src/runs/background/control-channel.ts +101 -214
- package/src/runs/background/fleet-view.ts +38 -22
- package/src/runs/background/inspect-rpc.ts +8 -8
- package/src/runs/background/notify.ts +295 -8
- package/src/runs/background/process-terminal.ts +16 -0
- package/src/runs/background/result-delivery-ownership.ts +45 -0
- package/src/runs/background/result-files.ts +28 -14
- package/src/runs/background/result-watcher.ts +43 -19
- package/src/runs/background/resume-guidance.ts +2 -2
- package/src/runs/background/retained-children.ts +1 -1
- package/src/runs/background/run-child-session.ts +613 -0
- package/src/runs/background/run-status.ts +99 -18
- package/src/runs/background/runner-aliases.ts +125 -0
- package/src/runs/background/runner-child-sessions.ts +31 -0
- package/src/runs/background/scheduled-runs.ts +174 -18
- package/src/runs/background/stale-run-reconciler.ts +13 -4
- package/src/runs/background/steering.ts +8 -15
- package/src/runs/background/subagent-runner.ts +959 -1159
- package/src/runs/background/subagent-wait.ts +86 -31
- package/src/runs/background/terminal-run-index.ts +1 -1
- package/src/runs/background/wait-completions.ts +45 -2
- package/src/runs/background/wait-config.ts +23 -9
- package/src/runs/background/wait-tool.ts +27 -19
- package/src/runs/foreground/async-steering-action.ts +3 -19
- package/src/runs/foreground/async-stop-action.ts +23 -2
- package/src/runs/foreground/execution.ts +585 -481
- package/src/runs/foreground/foreground-control.ts +13 -0
- package/src/runs/foreground/foreground-history.ts +26 -3
- package/src/runs/foreground/subagent-executor.ts +1549 -410
- package/src/runs/foreground/workflow-detach-reconcile.ts +141 -104
- package/src/runs/foreground/workflow-foreground-steering.ts +24 -98
- package/src/runs/shared/abort-recovery.ts +119 -0
- package/src/runs/shared/acceptance.ts +147 -39
- package/src/runs/shared/agent-contract.ts +1 -1
- package/src/runs/shared/async-status-projection.ts +565 -0
- package/src/runs/shared/background-process-options.ts +9 -0
- package/src/runs/shared/capability-ceiling.ts +2 -2
- package/src/runs/shared/child-hooks.ts +25 -0
- package/src/runs/shared/child-identity.ts +62 -0
- package/src/runs/shared/child-launch-plan.ts +151 -0
- package/src/runs/shared/child-launch.ts +314 -0
- package/src/runs/shared/child-lifecycle.ts +25 -0
- package/src/runs/shared/child-runtime-config.ts +126 -0
- package/src/runs/shared/child-session.ts +342 -0
- package/src/runs/shared/child-tool-plan.ts +540 -0
- package/src/runs/shared/claude-code-adapter.ts +133 -0
- package/src/runs/shared/codex-exec-adapter.ts +129 -0
- package/src/runs/shared/completion-evidence.ts +89 -0
- package/src/runs/shared/completion-guard.ts +57 -6
- package/src/runs/shared/cursor-agent-adapter.ts +114 -0
- package/src/runs/shared/dynamic-fanout.ts +4 -4
- package/src/runs/shared/extension-bindings.ts +78 -0
- package/src/runs/shared/external-cli-contract.ts +167 -0
- package/src/runs/shared/external-cli-preflight.ts +138 -0
- package/src/runs/shared/external-cli-runner.ts +349 -54
- package/src/runs/shared/external-job-bridge.ts +53 -37
- package/src/runs/shared/external-job-runner.ts +126 -23
- package/src/runs/shared/fast-mode-extension.ts +10 -0
- package/src/runs/shared/host-step-status.ts +231 -0
- package/src/runs/shared/lane-metadata.ts +126 -0
- package/src/runs/shared/launch-cwd.ts +16 -0
- package/src/runs/shared/long-running-guard.ts +2 -1
- package/src/runs/shared/mcp-config-sources.ts +422 -0
- package/src/runs/shared/mcp-direct-tool-allowlist.ts +222 -158
- package/src/runs/shared/mcp-direct-tool-grant.ts +194 -0
- package/src/runs/shared/model-exclusions.ts +141 -10
- package/src/runs/shared/model-fallback.ts +187 -33
- package/src/runs/shared/model-scope.ts +106 -39
- package/src/runs/shared/mutation-evidence.ts +199 -0
- package/src/runs/shared/nested-events.ts +38 -48
- package/src/runs/shared/nested-path.ts +0 -14
- package/src/runs/shared/nested-render.ts +9 -5
- package/src/runs/shared/orca-progress-tabs.ts +83 -16
- package/src/runs/shared/parallel-handoff.ts +423 -7
- package/src/runs/shared/parallel-utils.ts +28 -5
- package/src/runs/shared/permissions.ts +1 -14
- package/src/runs/shared/pi-spawn.ts +69 -35
- package/src/runs/shared/process-signal.ts +16 -0
- package/src/runs/shared/run-fanout-budget.ts +0 -13
- package/src/runs/shared/run-history.ts +21 -1
- package/src/runs/shared/runtime-acknowledged-extensions.ts +0 -27
- package/src/runs/shared/single-output.ts +89 -22
- package/src/runs/shared/structured-output.ts +61 -7
- package/src/runs/shared/subagent-control.ts +6 -2
- package/src/runs/shared/subagent-prompt-runtime.ts +216 -360
- package/src/runs/shared/task-intent.ts +21 -7
- package/src/runs/shared/tool-availability.ts +18 -64
- package/src/runs/shared/tool-budget.ts +0 -14
- package/src/runs/shared/tool-timeout.ts +1 -1
- package/src/runs/shared/workflow-graph.ts +16 -0
- package/src/runs/shared/worktree-cleanup-plan.ts +866 -0
- package/src/runs/shared/worktree.ts +571 -62
- package/src/shared/atomic-json.ts +3 -1
- package/src/shared/child-session-name.ts +46 -0
- package/src/shared/extension-context.ts +24 -0
- package/src/shared/fork-context.ts +21 -12
- package/src/shared/fork-session-cwd.ts +27 -0
- package/src/shared/formatters.ts +18 -3
- package/src/shared/jsonl-writer.ts +11 -0
- package/src/shared/launch-contract.ts +20 -6
- package/src/shared/pruned-fork.ts +450 -0
- package/src/shared/session-file-trust.ts +19 -0
- package/src/shared/session-tokens.ts +14 -3
- package/src/shared/settings.ts +21 -102
- package/src/shared/shortcuts.ts +17 -0
- package/src/shared/thinking-ceiling.ts +46 -0
- package/src/shared/types.ts +644 -75
- package/src/shared/utils.ts +60 -93
- package/src/shared/workflow-child-permit.ts +207 -0
- package/src/slash/delegation-adapters.ts +1 -9
- package/src/slash/delegation-request.ts +0 -4
- package/src/slash/prompt-template-bridge.ts +37 -1
- package/src/slash/slash-bridge.ts +1 -2
- package/src/slash/slash-commands.ts +383 -116
- package/src/slash/slash-live-state.ts +22 -11
- package/src/slash/subagents-admin.ts +29 -12
- package/src/tui/fleet-native-transcript.ts +4 -0
- package/src/tui/fleet-status.ts +278 -90
- package/src/tui/fleet-transcript.ts +11 -5
- package/src/tui/fleet.ts +54 -28
- package/src/tui/render-helpers.ts +31 -0
- package/src/tui/render.ts +1433 -166
- package/src/watchdog/change-signature.ts +40 -1
- package/src/watchdog/child-status.ts +54 -34
- package/src/watchdog/diff-tool.ts +77 -0
- package/src/watchdog/emission-guard.ts +5 -3
- package/src/watchdog/guidance.ts +20 -0
- package/src/watchdog/permission-arbiter.ts +59 -52
- package/src/watchdog/register-child.ts +28 -25
- package/src/watchdog/register-main.ts +10 -9
- package/src/watchdog/render.ts +4 -5
- package/src/watchdog/review.ts +15 -4
- package/src/watchdog/rules.ts +70 -0
- package/src/watchdog/runtime.ts +75 -92
- package/src/watchdog/scope.ts +0 -11
- package/src/watchdog/settings.ts +48 -104
- package/src/watchdog/turn-delta.ts +1 -1
- package/src/watchdog/types.ts +18 -32
- package/src/watchdog/warning-format.ts +0 -1
- package/src/workflows/chat-progress.ts +7 -3
- package/src/workflows/host-command.ts +235 -0
- package/src/workflows/scripted-workflow.ts +1142 -69
- package/src/workflows/workflow-checklist.ts +439 -0
- package/src/workflows/workflow-child-summary.ts +121 -0
- package/src/workflows/workflow-preflight.ts +297 -0
- package/src/workflows/workflow-receipt.ts +232 -6
- package/src/workflows/workflow-resources.ts +150 -0
- package/src/workflows/workflow-settlement.ts +246 -0
- package/src/runs/shared/child-protocol.ts +0 -401
- package/src/runs/shared/pi-args.ts +0 -858
- package/src/runs/shared/subagent-startup-retry.ts +0 -116
- package/src/runs/shared/turn-budget.ts +0 -98
- package/src/shared/post-exit-stdio-guard.ts +0 -85
|
@@ -25,6 +25,7 @@ import { recordWaitCompletion } from "./wait-completions.ts";
|
|
|
25
25
|
import { MISSION_BINDING_FILE, syncMissionFromAsyncCompletion } from "../../missions/lifecycle.ts";
|
|
26
26
|
import { missionObserverResultCandidateFiles, promotePendingResultFile, removeMissionObserverIndex, removeResultIndex, resultCandidateFilesForSession, resultPayloadPathForIndexedRun, resultPayloadPathForMissionObserverRun, resultPayloadPathForSessionRun, writeAsyncResultFile, writeResultIndexForData } from "./result-files.ts";
|
|
27
27
|
import type { CompletionNotifier, CompletionNotification } from "./notify.ts";
|
|
28
|
+
import type { ResultDeliveryOwnership } from "./result-delivery-ownership.ts";
|
|
28
29
|
|
|
29
30
|
const WATCHER_RESTART_DELAY_MS = 3000;
|
|
30
31
|
const POLL_INTERVAL_MS = 3000;
|
|
@@ -57,13 +58,16 @@ type ResultWatcherDeps = {
|
|
|
57
58
|
coalesceDelayMs?: number;
|
|
58
59
|
/** Returns true while a durable completion source needs periodic delivery checks. */
|
|
59
60
|
hasDeliveryDemand?: () => boolean;
|
|
60
|
-
/** Control how slow result-index scans are logged. Defaults to \"
|
|
61
|
+
/** Control how slow result-index scans are logged. Defaults to \"activity\". */
|
|
61
62
|
resultScanLogging?: "all" | "activity" | "off";
|
|
62
63
|
platform?: NodeJS.Platform;
|
|
64
|
+
/** Shared current/predecessor session ownership used by the notifier. */
|
|
65
|
+
ownership?: Pick<ResultDeliveryOwnership, "owns" | "claimedSessionIds">;
|
|
63
66
|
};
|
|
64
67
|
|
|
65
68
|
type ResultFileChild = {
|
|
66
69
|
agent?: string;
|
|
70
|
+
sessionName?: string;
|
|
67
71
|
output?: string;
|
|
68
72
|
structuredOutput?: unknown;
|
|
69
73
|
outputState?: SubagentOutputState;
|
|
@@ -148,6 +152,10 @@ function isNotFound(error: unknown): boolean {
|
|
|
148
152
|
return errorCode(error) === "ENOENT";
|
|
149
153
|
}
|
|
150
154
|
|
|
155
|
+
function isAbsentResultCandidate(error: unknown): boolean {
|
|
156
|
+
return isNotFound(error) || errorCode(error) === "ENAMETOOLONG";
|
|
157
|
+
}
|
|
158
|
+
|
|
151
159
|
function isAccessDenied(error: unknown): boolean {
|
|
152
160
|
const code = errorCode(error);
|
|
153
161
|
return code === "EPERM" || code === "EACCES";
|
|
@@ -196,6 +204,7 @@ export function createResultWatcher(
|
|
|
196
204
|
deps: ResultWatcherDeps = {},
|
|
197
205
|
): {
|
|
198
206
|
startResultWatcher: () => void;
|
|
207
|
+
transitionResultDelivery: () => void;
|
|
199
208
|
primeExistingResults: (options?: { triggerTurn?: boolean }) => void;
|
|
200
209
|
refreshResultDelivery: () => void;
|
|
201
210
|
stopResultWatcher: () => void;
|
|
@@ -214,14 +223,16 @@ export function createResultWatcher(
|
|
|
214
223
|
// The sole in-memory ownership lease. It is acquired for one active session
|
|
215
224
|
// and revoked before the watcher, queues, or callbacks are torn down.
|
|
216
225
|
let activeSessionId: string | null = null;
|
|
226
|
+
const ownsResult = deps.ownership?.owns
|
|
227
|
+
?? ((sessionId: string, completionOwnerId: unknown) => sessionId === state.currentSessionId
|
|
228
|
+
&& typeof completionOwnerId === "string"
|
|
229
|
+
&& completionOwnerId === state.completionOwnerId);
|
|
230
|
+
const claimedSessionIds = () => deps.ownership?.claimedSessionIds() ?? [];
|
|
217
231
|
|
|
218
232
|
const ownsCompletion = (sessionId: string, completionOwnerId: unknown, epoch: number) => {
|
|
219
233
|
if (!deliveryActive || epoch !== deliveryEpoch) return false;
|
|
220
234
|
if (!activeSessionId && state.currentSessionId) activeSessionId = state.currentSessionId;
|
|
221
|
-
return activeSessionId === sessionId
|
|
222
|
-
&& state.currentSessionId === sessionId
|
|
223
|
-
&& typeof completionOwnerId === "string"
|
|
224
|
-
&& completionOwnerId === state.completionOwnerId;
|
|
235
|
+
return activeSessionId === state.currentSessionId && ownsResult(sessionId, completionOwnerId);
|
|
225
236
|
};
|
|
226
237
|
|
|
227
238
|
const scheduleResult = (file: string, triggerTurn: boolean, delayMs = 0) => {
|
|
@@ -235,15 +246,18 @@ export function createResultWatcher(
|
|
|
235
246
|
try {
|
|
236
247
|
return fsApi.statSync(publicResultPath(file)).isFile();
|
|
237
248
|
} catch (error) {
|
|
238
|
-
if (!
|
|
249
|
+
if (!isAbsentResultCandidate(error)) console.error(`Failed to inspect subagent result file '${publicResultPath(file)}':`, error);
|
|
239
250
|
return false;
|
|
240
251
|
}
|
|
241
252
|
};
|
|
242
253
|
const resultPayloadPath = (file: string, observed?: ReadonlySet<string>): string | undefined => {
|
|
243
254
|
if (file !== path.basename(file) || !file.endsWith(".json")) return undefined;
|
|
244
255
|
const runId = file.replace(/\.json$/i, "");
|
|
245
|
-
const
|
|
246
|
-
|
|
256
|
+
for (const sessionId of [state.currentSessionId, ...claimedSessionIds()]) {
|
|
257
|
+
if (!sessionId) continue;
|
|
258
|
+
const sessionResult = resultPayloadPathForSessionRun(resultsDir, sessionId, runId);
|
|
259
|
+
if (sessionResult) return sessionResult;
|
|
260
|
+
}
|
|
247
261
|
const observerResult = resultPayloadPathForMissionObserverRun(resultsDir, runId);
|
|
248
262
|
if (observerResult) return observerResult;
|
|
249
263
|
if (observed?.has(runId)) {
|
|
@@ -265,7 +279,7 @@ export function createResultWatcher(
|
|
|
265
279
|
} catch (error) {
|
|
266
280
|
identityCache.delete(file);
|
|
267
281
|
if (isAccessDenied(error)) throw error;
|
|
268
|
-
if (!
|
|
282
|
+
if (!isAbsentResultCandidate(error)) console.error(`Failed to inspect subagent result file '${resultPath}':`, error);
|
|
269
283
|
return undefined;
|
|
270
284
|
}
|
|
271
285
|
};
|
|
@@ -283,7 +297,7 @@ export function createResultWatcher(
|
|
|
283
297
|
} catch (error) {
|
|
284
298
|
identityCache.delete(file);
|
|
285
299
|
if (isAccessDenied(error)) throw error;
|
|
286
|
-
if (!
|
|
300
|
+
if (!isAbsentResultCandidate(error)) console.error(`Failed to inspect subagent result file '${resultPath}':`, error);
|
|
287
301
|
return undefined;
|
|
288
302
|
}
|
|
289
303
|
};
|
|
@@ -304,7 +318,7 @@ export function createResultWatcher(
|
|
|
304
318
|
// Missing identity stays on the normal parser path so malformed or legacy
|
|
305
319
|
// files keep their existing diagnostics and compatibility behavior.
|
|
306
320
|
if (!identity.sessionId) return true;
|
|
307
|
-
if (identity.sessionId
|
|
321
|
+
if (ownsResult(identity.sessionId, identity.completionOwnerId)) return true;
|
|
308
322
|
if (identity.asyncDir && fsApi.existsSync(path.join(identity.asyncDir, MISSION_BINDING_FILE))) return true;
|
|
309
323
|
if (identity.runId && (observed ?? observedRunIds()).has(identity.runId)) return true;
|
|
310
324
|
return Boolean(deps.observeCompletion && !deps.observedCompletionRunIds);
|
|
@@ -317,7 +331,7 @@ export function createResultWatcher(
|
|
|
317
331
|
removeResultIndex(resultsDir, sessionId, runId, toolCallId);
|
|
318
332
|
return true;
|
|
319
333
|
} catch (error) {
|
|
320
|
-
if (!
|
|
334
|
+
if (!isAbsentResultCandidate(error)) {
|
|
321
335
|
console.error(`Failed to remove delivered subagent result '${publicResultPath(file)}'; will retry:`, error);
|
|
322
336
|
return false;
|
|
323
337
|
}
|
|
@@ -384,7 +398,7 @@ export function createResultWatcher(
|
|
|
384
398
|
if (!resultPayloadWasReplaced(data, readPublicResultIdentity())) return false;
|
|
385
399
|
} catch (error) {
|
|
386
400
|
if (isAccessDenied(error)) throw error;
|
|
387
|
-
if (
|
|
401
|
+
if (isAbsentResultCandidate(error)) return false;
|
|
388
402
|
console.error(`Failed to re-read subagent result file '${publicResultPath(file)}':`, error);
|
|
389
403
|
}
|
|
390
404
|
identityCache.delete(file);
|
|
@@ -412,7 +426,7 @@ export function createResultWatcher(
|
|
|
412
426
|
if (observerSucceeded) removeMissionObserverIndex(resultsDir, runId);
|
|
413
427
|
const epoch = deliveryEpoch;
|
|
414
428
|
if (!ownsCompletion(sessionId, completionOwnerId, epoch)) return;
|
|
415
|
-
// Recorded before dedupe and before the unlink below so
|
|
429
|
+
// Recorded before dedupe and before the unlink below so bg_wait can
|
|
416
430
|
// use the in-memory record or its bounded durable replay after cleanup.
|
|
417
431
|
recordWaitCompletion(state, runId, data, Date.now(), completionTtlMs, {
|
|
418
432
|
resultsDir,
|
|
@@ -469,6 +483,7 @@ export function createResultWatcher(
|
|
|
469
483
|
: undefined;
|
|
470
484
|
return {
|
|
471
485
|
agent: result.agent ?? data.agent ?? `step-${index + 1}`,
|
|
486
|
+
...(result.sessionName ? { sessionName: result.sessionName } : {}),
|
|
472
487
|
status: resolveSubagentResultStatus({
|
|
473
488
|
success: result.success,
|
|
474
489
|
state: childState,
|
|
@@ -606,18 +621,20 @@ export function createResultWatcher(
|
|
|
606
621
|
const logScanStats = (stats: ResultScanStats) => {
|
|
607
622
|
const elapsed = Date.now() - stats.startedAt;
|
|
608
623
|
if (elapsed < SLOW_RESULT_SCAN_MS) return;
|
|
609
|
-
|
|
624
|
+
const resultScanLogging = deps.resultScanLogging ?? "activity";
|
|
625
|
+
if (resultScanLogging === "off") return;
|
|
610
626
|
// A scan that inspected and scheduled nothing is a quiet no-op (e.g. the
|
|
611
627
|
// healthy periodic rescan while no async runs are pending). Under
|
|
612
628
|
// "activity", skip it so empty scans do not burn context tokens in the
|
|
613
629
|
// session transcript.
|
|
614
|
-
if (
|
|
630
|
+
if (resultScanLogging === "activity" && stats.files === 0 && stats.scheduled === 0) return;
|
|
615
631
|
console.error(`Subagent result scan inspected ${stats.files} indexed result file(s), scheduled ${stats.scheduled} in ${elapsed}ms (${resultsDir}).`);
|
|
616
632
|
};
|
|
617
633
|
const indexedResultCandidates = (observed: ReadonlySet<string>): string[] => {
|
|
618
634
|
const files = new Set<string>();
|
|
619
|
-
|
|
620
|
-
|
|
635
|
+
for (const sessionId of [state.currentSessionId, ...claimedSessionIds()]) {
|
|
636
|
+
if (!sessionId) continue;
|
|
637
|
+
for (const file of resultCandidateFilesForSession(resultsDir, sessionId)) files.add(file);
|
|
621
638
|
}
|
|
622
639
|
for (const runId of state.asyncJobs.keys()) files.add(`${runId}.json`);
|
|
623
640
|
for (const file of missionObserverResultCandidateFiles(resultsDir)) files.add(file);
|
|
@@ -750,6 +767,13 @@ export function createResultWatcher(
|
|
|
750
767
|
}
|
|
751
768
|
};
|
|
752
769
|
|
|
770
|
+
const transitionResultDelivery = () => {
|
|
771
|
+
deliveryActive = true;
|
|
772
|
+
activeSessionId = state.currentSessionId;
|
|
773
|
+
deliveryEpoch += 1;
|
|
774
|
+
identityCache.clear();
|
|
775
|
+
};
|
|
776
|
+
|
|
753
777
|
const stopResultWatcher = () => {
|
|
754
778
|
deliveryActive = false;
|
|
755
779
|
activeSessionId = null;
|
|
@@ -764,5 +788,5 @@ export function createResultWatcher(
|
|
|
764
788
|
identityCache.clear();
|
|
765
789
|
};
|
|
766
790
|
|
|
767
|
-
return { startResultWatcher, primeExistingResults, stopResultWatcher, refreshResultDelivery: () => { primeExistingResults(); startDemandPolling(); } };
|
|
791
|
+
return { startResultWatcher, transitionResultDelivery, primeExistingResults, stopResultWatcher, refreshResultDelivery: () => { primeExistingResults(); startDemandPolling(); } };
|
|
768
792
|
}
|
|
@@ -12,7 +12,7 @@ function isIntercomDetached(run: AsyncRunSummary): boolean {
|
|
|
12
12
|
|
|
13
13
|
function formatIntercomDetachGuidance(run: AsyncRunSummary): string | undefined {
|
|
14
14
|
if (!isIntercomDetached(run)) return undefined;
|
|
15
|
-
return `Run "${run.id}" detached for intercom coordination. Reply to the supervisor request first, then wait with
|
|
15
|
+
return `Run "${run.id}" detached for intercom coordination. Reply to the supervisor request first, then wait with bg_wait({ id: "${run.id}" }). Use subagent({ action: "status", id: "${run.id}" }) to recover the result; do not resume or launch a replacement while it remains detached.`;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function formatAsyncReviveCommand(run: AsyncRunSummary): string | undefined {
|
|
@@ -39,7 +39,7 @@ export function formatResumeFirstFailedRunDetail(run: AsyncRunSummary): string |
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export function formatResumeFirstFailedRunsNote(runs: AsyncRunSummary[]): string {
|
|
42
|
-
const failedRuns = runs.filter((run) => run.state === "failed");
|
|
42
|
+
const failedRuns = runs.filter((run) => run.state === "failed" || run.state === "partial");
|
|
43
43
|
const detachGuidance = failedRuns
|
|
44
44
|
.map(formatIntercomDetachGuidance)
|
|
45
45
|
.filter((guidance): guidance is string => Boolean(guidance));
|
|
@@ -27,7 +27,7 @@ export interface RetainedChild {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function isRetainedChildState(state: AsyncRunSummary["state"]): state is RetainedChildState {
|
|
30
|
-
return state === "complete" || state === "failed" || state === "paused" || state === "stopped";
|
|
30
|
+
return state === "complete" || state === "failed" || state === "partial" || state === "paused" || state === "stopped";
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function isTerminalStepStatus(status: AsyncRunSummary["steps"][number]["status"]): boolean {
|