pi-subagents 0.84.0 → 0.85.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 +62 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-235AWJUQ.js → chunk-3UZ5FVVJ.js} +310 -101
- package/bundle/{chunk-F4ASL6OV.js → chunk-7MAE3DJV.js} +1 -1
- package/bundle/{chunk-4E7BKDTX.js → chunk-CS4O36CZ.js} +11 -156
- package/bundle/{chunk-VQVVHSY6.js → chunk-DV2NCNPR.js} +22 -11
- package/bundle/{chunk-G2Z6ZH26.js → chunk-GCSLVFCX.js} +1 -1
- package/bundle/{chunk-2S4K53MV.js → chunk-H2NLFTC5.js} +1 -1
- package/bundle/{chunk-NKQ6JNAS.js → chunk-HFTBF7SG.js} +2 -1
- package/bundle/chunk-HXRB42AF.js +108 -0
- package/bundle/{chunk-7BWGNDNK.js → chunk-IQIWF2VX.js} +190 -1177
- package/bundle/{chunk-XDQORLZ5.js → chunk-JNXT3MPI.js} +15 -6
- package/bundle/{chunk-J5YL7LYR.js → chunk-JO67XSKD.js} +59 -27
- package/bundle/{chunk-JG4QKI5M.js → chunk-JWYG26RE.js} +209 -93
- package/bundle/{chunk-C5P5CHYK.js → chunk-KDMFBYFM.js} +1 -1
- package/bundle/{chunk-V2BZYLEP.js → chunk-KEY3UQMQ.js} +7 -2
- package/bundle/{chunk-NENDSQUY.js → chunk-KZ34KQQH.js} +9 -6
- package/bundle/{chunk-AKOIVLA5.js → chunk-L2ENOFVZ.js} +76 -58
- package/bundle/{chunk-CGN2TVE7.js → chunk-LGMILZNE.js} +322 -18
- package/bundle/{chunk-L3WFKBEI.js → chunk-LTPH2DXH.js} +247 -153
- package/bundle/{chunk-2D52JFLF.js → chunk-N7B2KD74.js} +41 -117
- package/bundle/{chunk-PV63UFUR.js → chunk-O7CPL6H4.js} +183 -28
- package/bundle/{chunk-D3JAFGMO.js → chunk-PHZP3KHB.js} +1 -1
- package/bundle/{chunk-2DHZTCOL.js → chunk-PVIVCDG2.js} +2 -2
- package/bundle/{chunk-LFDBD4PW.js → chunk-QO75KJBT.js} +2 -2
- package/bundle/{chunk-SSG7IEP5.js → chunk-RQAUNAWG.js} +2 -2
- package/bundle/{chunk-PALJGGYC.js → chunk-RV5OGHLO.js} +6 -3
- package/bundle/chunk-T5V5BRCL.js +1067 -0
- package/bundle/{chunk-LNRJCP2Y.js → chunk-UX4SCV5N.js} +337 -207
- package/bundle/{chunk-DZDETGRJ.js → chunk-WOVMHDES.js} +231 -182
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +8 -8
- package/bundle/project-panes.js +3 -3
- package/docs/agents.md +17 -2
- package/docs/configuration.md +2 -2
- package/docs/extension-api.md +16 -1
- package/docs/workflows.md +30 -2
- package/package.json +1 -1
- package/src/agents/agent-management.js +27 -11
- package/src/agents/agent-memory.d.ts +1 -4
- package/src/agents/agent-memory.js +1 -4
- package/src/agents/agents.d.ts +1 -3
- package/src/agents/agents.js +7 -6
- package/src/agents/frontmatter.js +1 -8
- package/src/agents/global-npm-root.d.ts +1 -0
- package/src/agents/global-npm-root.js +11 -3
- package/src/agents/skills.d.ts +0 -3
- package/src/agents/skills.js +0 -3
- package/src/extension/config.js +7 -1
- package/src/extension/herdr-pi-bridge.js +10 -2
- package/src/extension/index.d.ts +0 -13
- package/src/extension/index.js +43 -32
- package/src/extension/public-execution.d.ts +1 -0
- package/src/extension/public-execution.js +4 -0
- package/src/extension/reply-workflow-script.js +24 -4
- package/src/extension/schemas.d.ts +8 -3
- package/src/extension/schemas.js +5 -3
- package/src/extension/session-switch.d.ts +25 -0
- package/src/extension/session-switch.js +138 -0
- package/src/extension/subagent-guide.d.ts +1 -1
- package/src/extension/subagent-guide.js +1 -1
- package/src/extension/subagent-launch-tool.d.ts +25 -0
- package/src/extension/subagent-launch-tool.js +48 -0
- package/src/extension/tool-activation.js +25 -11
- package/src/extension/tool-description.js +6 -0
- package/src/inspectors/herdr/actions.d.ts +0 -1
- package/src/inspectors/herdr/actions.js +0 -1
- package/src/inspectors/session-roots-codec.d.ts +0 -1
- package/src/inspectors/session-roots-codec.js +0 -1
- package/src/inspectors/tmux/actions.d.ts +0 -1
- package/src/inspectors/tmux/actions.js +0 -1
- package/src/integrations/herdr-status.js +3 -8
- package/src/intercom/native-supervisor-channel.js +65 -9
- package/src/runs/background/async-execution.d.ts +5 -9
- package/src/runs/background/async-execution.js +62 -27
- package/src/runs/background/async-job-tracker.js +12 -0
- package/src/runs/background/async-resume.d.ts +2 -1
- package/src/runs/background/async-resume.js +112 -39
- package/src/runs/background/async-retention.js +6 -1
- package/src/runs/background/auto-drain.js +2 -1
- package/src/runs/background/boot-id.d.ts +1 -3
- package/src/runs/background/boot-id.js +1 -3
- package/src/runs/background/completion-batcher.d.ts +3 -4
- package/src/runs/background/completion-batcher.js +2 -3
- package/src/runs/background/control-channel.d.ts +0 -6
- package/src/runs/background/control-channel.js +0 -6
- package/src/runs/background/fleet-view.js +2 -3
- package/src/runs/background/notify.d.ts +0 -2
- package/src/runs/background/notify.js +0 -2
- package/src/runs/background/result-watcher.d.ts +1 -0
- package/src/runs/background/result-watcher.js +59 -29
- package/src/runs/background/resume-guidance.js +4 -2
- package/src/runs/background/retained-children.js +2 -1
- package/src/runs/background/run-child-session.d.ts +0 -1
- package/src/runs/background/run-child-session.js +1 -1
- package/src/runs/background/run-status.js +4 -3
- package/src/runs/background/scheduled-runs.d.ts +3 -1
- package/src/runs/background/scheduled-runs.js +13 -16
- package/src/runs/background/subagent-runner.d.ts +2 -4
- package/src/runs/background/subagent-runner.js +9 -6
- package/src/runs/background/subagent-wait.js +12 -15
- package/src/runs/background/wait-config.d.ts +2 -0
- package/src/runs/background/wait-config.js +17 -3
- package/src/runs/background/wait-tool.js +4 -2
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +0 -1
- package/src/runs/foreground/execution.d.ts +0 -3
- package/src/runs/foreground/execution.js +17 -9
- package/src/runs/foreground/subagent-executor.d.ts +3 -2
- package/src/runs/foreground/subagent-executor.js +107 -26
- package/src/runs/shared/child-commands.js +15 -2
- package/src/runs/shared/child-hooks.d.ts +1 -7
- package/src/runs/shared/child-hooks.js +13 -5
- package/src/runs/shared/child-launch.js +6 -2
- package/src/runs/shared/child-runtime-config.d.ts +0 -1
- package/src/runs/shared/child-session.d.ts +1 -1
- package/src/runs/shared/child-session.js +21 -2
- package/src/runs/shared/child-tool-plan.d.ts +0 -1
- package/src/runs/shared/child-tool-plan.js +0 -1
- package/src/runs/shared/claude-code-adapter.js +11 -0
- package/src/runs/shared/external-cli-runner.js +26 -6
- package/src/runs/shared/herdr-connection.js +2 -1
- package/src/runs/shared/herdr-pane-host.d.ts +2 -2
- package/src/runs/shared/herdr-pane-host.js +17 -1
- package/src/runs/shared/herdr-placed-run.js +48 -22
- package/src/runs/shared/lane-metadata.d.ts +0 -1
- package/src/runs/shared/lane-metadata.js +0 -1
- package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
- package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
- package/src/runs/shared/model-resolution.d.ts +2 -2
- package/src/runs/shared/model-resolution.js +7 -1
- package/src/runs/shared/model-scope.d.ts +1 -5
- package/src/runs/shared/model-scope.js +1 -5
- package/src/runs/shared/mutation-evidence.d.ts +1 -1
- package/src/runs/shared/mutation-evidence.js +52 -7
- package/src/runs/shared/nested-events.d.ts +1 -0
- package/src/runs/shared/nested-events.js +1 -1
- package/src/runs/shared/parallel-utils.d.ts +0 -1
- package/src/runs/shared/permissions.js +5 -3
- package/src/runs/shared/placement-host.d.ts +5 -1
- package/src/runs/shared/rex-pane-host.d.ts +0 -1
- package/src/runs/shared/rex-pane-host.js +0 -2
- package/src/runs/shared/run-launch-folder.d.ts +12 -0
- package/src/runs/shared/run-launch-folder.js +21 -0
- package/src/runs/shared/runner-launcher.d.ts +12 -1
- package/src/runs/shared/runner-launcher.js +16 -0
- package/src/runs/shared/single-output.d.ts +3 -3
- package/src/runs/shared/single-output.js +5 -3
- package/src/runs/shared/structured-output.d.ts +8 -0
- package/src/runs/shared/structured-output.js +30 -2
- package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js +4 -2
- package/src/runs/shared/tool-timeout.js +2 -1
- package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
- package/src/runs/shared/worktree-cleanup-plan.js +0 -1
- package/src/runs/shared/worktree.d.ts +3 -0
- package/src/runs/shared/worktree.js +20 -0
- package/src/shared/capacity-resilient-json.d.ts +1 -1
- package/src/shared/child-cache-retention.d.ts +1 -2
- package/src/shared/child-cache-retention.js +1 -2
- package/src/shared/fleet-transcript-reader.d.ts +51 -0
- package/src/shared/fleet-transcript-reader.js +333 -0
- package/src/shared/formatters.d.ts +0 -18
- package/src/shared/formatters.js +0 -18
- package/src/shared/session-succession.d.ts +16 -1
- package/src/shared/session-succession.js +41 -2
- package/src/shared/session-warnings.d.ts +7 -0
- package/src/shared/session-warnings.js +26 -0
- package/src/shared/settings.d.ts +0 -23
- package/src/shared/settings.js +3 -35
- package/src/shared/types.d.ts +28 -11
- package/src/shared/types.js +0 -12
- package/src/shared/utils.d.ts +0 -14
- package/src/shared/utils.js +0 -22
- package/src/shared/wait-tool-name.d.ts +8 -0
- package/src/shared/wait-tool-name.js +13 -0
- package/src/slash/slash-commands.js +2 -1
- package/src/slash/subagent-cost.d.ts +3 -2
- package/src/slash/subagent-cost.js +22 -3
- package/src/slash/subagents-admin.js +0 -1
- package/src/tui/fleet-status.d.ts +0 -5
- package/src/tui/fleet-status.js +4 -24
- package/src/tui/fleet-transcript.d.ts +1 -44
- package/src/tui/fleet-transcript.js +1 -327
- package/src/tui/fleet.js +6 -4
- package/src/tui/render.d.ts +0 -9
- package/src/tui/render.js +81 -47
- package/src/tui/subagent-messages.js +3 -2
- package/src/watchdog/register-child.d.ts +2 -3
- package/src/watchdog/register-child.js +2 -3
- package/src/watchdog/turn-delta.js +2 -1
- package/src/workflows/scripted-workflow.js +241 -20
- package/src/workflows/workflow-launch-record.d.ts +15 -6
- package/src/workflows/workflow-launch-record.js +30 -12
- package/src/workflows/workflow-resume-claim.js +2 -2
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +11 -8
- package/src/workflows/workflow-script-worker.d.ts +13 -0
- package/src/workflows/workflow-script-worker.js +79 -0
- package/workflow-script-process.cjs +36 -0
- package/workflow-script-worker.cjs +4 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { listAsyncRuns } from "./async-status.js";
|
|
2
2
|
import { backgroundWorkForSession, waitForSubagents, waitRunScopes } from "./subagent-wait.js";
|
|
3
|
+
import { waitToolName } from "../../shared/wait-tool-name.js";
|
|
3
4
|
export const DEFAULT_AUTO_DRAIN_TIMEOUT_MS = 30 * 60 * 1000;
|
|
4
5
|
function resultText(value) {
|
|
5
6
|
return value.content.map((part) => part.type === "text" ? part.text : "").join(" ").trim();
|
|
@@ -55,7 +56,7 @@ export async function drainOutstandingWork(deps, observation) {
|
|
|
55
56
|
hasPendingSupervisorRequest: deps.hasPendingSupervisorRequest,
|
|
56
57
|
});
|
|
57
58
|
if (waitResult.isError) {
|
|
58
|
-
throw new Error(`Auto-drain failed for session '${sessionId}': ${resultText(waitResult) ||
|
|
59
|
+
throw new Error(`Auto-drain failed for session '${sessionId}': ${resultText(waitResult) || `${waitToolName()} returned an error without details`}.`);
|
|
59
60
|
}
|
|
60
61
|
if (waitResult.details.wait?.reason === "supervisor_request")
|
|
61
62
|
break;
|
|
@@ -4,9 +4,7 @@ import type { RecordedPid } from "./stale-run-reconciler.ts";
|
|
|
4
4
|
* different boot id cannot still be running. Undefined when the platform has none.
|
|
5
5
|
*/
|
|
6
6
|
export declare function currentBootId(): string | undefined;
|
|
7
|
-
/** This process as a recorded pid, without the fields the platform does not have. */
|
|
8
7
|
export declare function currentRecordedPid(): RecordedPid;
|
|
9
|
-
/**
|
|
8
|
+
/** Runners take Pi's value from their config. */
|
|
10
9
|
export declare function primeBootId(value: string | undefined): void;
|
|
11
|
-
/** Clears the cache so the next read calls `nextReader` (default: the OS reader). */
|
|
12
10
|
export declare function resetBootIdForTesting(nextReader?: () => string | undefined): void;
|
|
@@ -30,17 +30,15 @@ export function currentBootId() {
|
|
|
30
30
|
runtime[BOOT_ID_KEY] = { value };
|
|
31
31
|
return value;
|
|
32
32
|
}
|
|
33
|
-
/** This process as a recorded pid, without the fields the platform does not have. */
|
|
34
33
|
export function currentRecordedPid() {
|
|
35
34
|
const pidNamespaceScope = currentPidNamespaceScope();
|
|
36
35
|
const bootId = currentBootId();
|
|
37
36
|
return { pid: process.pid, ...(pidNamespaceScope ? { pidNamespaceScope } : {}), ...(bootId ? { bootId } : {}) };
|
|
38
37
|
}
|
|
39
|
-
/**
|
|
38
|
+
/** Runners take Pi's value from their config. */
|
|
40
39
|
export function primeBootId(value) {
|
|
41
40
|
runtime[BOOT_ID_KEY] = { value };
|
|
42
41
|
}
|
|
43
|
-
/** Clears the cache so the next read calls `nextReader` (default: the OS reader). */
|
|
44
42
|
export function resetBootIdForTesting(nextReader) {
|
|
45
43
|
reader = nextReader ?? readBootIdFromOs;
|
|
46
44
|
delete runtime[BOOT_ID_KEY];
|
|
@@ -36,7 +36,7 @@ export interface CompletionBatcherOptions<T> {
|
|
|
36
36
|
now?: () => number;
|
|
37
37
|
}
|
|
38
38
|
export interface CompletionBatcher<T> {
|
|
39
|
-
/**
|
|
39
|
+
/** Emits immediately when batching is disabled. */
|
|
40
40
|
push(item: T): void;
|
|
41
41
|
/** Emit any held items immediately as a single group. */
|
|
42
42
|
flush(): void;
|
|
@@ -44,8 +44,7 @@ export interface CompletionBatcher<T> {
|
|
|
44
44
|
dispose(): T[];
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* timers for reload/shutdown without emitting.
|
|
47
|
+
* The batcher is single-use per registration: it holds at most one open group.
|
|
48
|
+
* `flush` forces emission; `dispose` tears down timers for reload/shutdown without emitting.
|
|
50
49
|
*/
|
|
51
50
|
export declare function createCompletionBatcher<T>(options: CompletionBatcherOptions<T>): CompletionBatcher<T>;
|
|
@@ -50,9 +50,8 @@ function unrefHandle(handle) {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* timers for reload/shutdown without emitting.
|
|
53
|
+
* The batcher is single-use per registration: it holds at most one open group.
|
|
54
|
+
* `flush` forces emission; `dispose` tears down timers for reload/shutdown without emitting.
|
|
56
55
|
*/
|
|
57
56
|
export function createCompletionBatcher(options) {
|
|
58
57
|
const timers = options.timers ?? defaultTimers;
|
|
@@ -63,17 +63,11 @@ export interface CommandRequest {
|
|
|
63
63
|
}
|
|
64
64
|
export declare function requestAsyncCommand(dir: string, request: CommandRequest): void;
|
|
65
65
|
export declare const MAX_STEER_QUEUE_SIZE = 20;
|
|
66
|
-
/** Control inbox directory inside an async run dir. */
|
|
67
66
|
export declare function controlInboxDir(asyncDir: string): string;
|
|
68
|
-
/** Path of the portable interrupt request file. */
|
|
69
67
|
export declare function interruptRequestPath(asyncDir: string): string;
|
|
70
|
-
/** Path of the portable timeout request file. */
|
|
71
68
|
export declare function timeoutRequestPath(asyncDir: string): string;
|
|
72
|
-
/** Path of the portable manual stop request file. */
|
|
73
69
|
export declare function stopRequestPath(asyncDir: string): string;
|
|
74
|
-
/** Directory of parent-to-runner stop requests. */
|
|
75
70
|
export declare function stopRequestsDir(asyncDir: string): string;
|
|
76
|
-
/** Directory of parent-to-runner steering requests. */
|
|
77
71
|
export declare function steerRequestsDir(asyncDir: string): string;
|
|
78
72
|
export declare function steerInboxClosedPath(asyncDir: string): string;
|
|
79
73
|
export declare function stopInboxClosedPath(asyncDir: string): string;
|
|
@@ -82,27 +82,21 @@ const STOP_INBOX_CLOSED_FILE = "stop-inbox-closed.json";
|
|
|
82
82
|
const STOP_INBOX_CLOSED_MESSAGE = "Runner stop inbox is closed. Retry stop after runner shutdown is observed.";
|
|
83
83
|
const MAX_STEER_MESSAGE_BYTES = 128 * 1024;
|
|
84
84
|
const MAX_STEER_REQUEST_ID_LENGTH = 256;
|
|
85
|
-
/** Control inbox directory inside an async run dir. */
|
|
86
85
|
export function controlInboxDir(asyncDir) {
|
|
87
86
|
return path.join(asyncDir, "control");
|
|
88
87
|
}
|
|
89
|
-
/** Path of the portable interrupt request file. */
|
|
90
88
|
export function interruptRequestPath(asyncDir) {
|
|
91
89
|
return path.join(controlInboxDir(asyncDir), "interrupt.json");
|
|
92
90
|
}
|
|
93
|
-
/** Path of the portable timeout request file. */
|
|
94
91
|
export function timeoutRequestPath(asyncDir) {
|
|
95
92
|
return path.join(controlInboxDir(asyncDir), "timeout.json");
|
|
96
93
|
}
|
|
97
|
-
/** Path of the portable manual stop request file. */
|
|
98
94
|
export function stopRequestPath(asyncDir) {
|
|
99
95
|
return path.join(controlInboxDir(asyncDir), "stop.json");
|
|
100
96
|
}
|
|
101
|
-
/** Directory of parent-to-runner stop requests. */
|
|
102
97
|
export function stopRequestsDir(asyncDir) {
|
|
103
98
|
return path.join(controlInboxDir(asyncDir), STOP_REQUESTS_DIR);
|
|
104
99
|
}
|
|
105
|
-
/** Directory of parent-to-runner steering requests. */
|
|
106
100
|
export function steerRequestsDir(asyncDir) {
|
|
107
101
|
return path.join(controlInboxDir(asyncDir), STEER_REQUESTS_DIR);
|
|
108
102
|
}
|
|
@@ -9,6 +9,7 @@ import { formatNestedRunStatusLines } from "../shared/nested-render.js";
|
|
|
9
9
|
import { contextModeLabel, summarizeContextModes } from "../shared/context-mode.js";
|
|
10
10
|
import { formatAsyncRunOutputPath, formatAsyncRunProgressLabel, listAsyncRuns } from "./async-status.js";
|
|
11
11
|
import { isTrustedRecordedSessionFile } from "../../shared/session-file-trust.js";
|
|
12
|
+
import { waitToolName } from "../../shared/wait-tool-name.js";
|
|
12
13
|
const DEFAULT_TRANSCRIPT_LINES = 80;
|
|
13
14
|
const MAX_TRANSCRIPT_LINES = 500;
|
|
14
15
|
const TRANSCRIPT_TAIL_BYTES = 256 * 1024;
|
|
@@ -299,7 +300,7 @@ function formatDetachedForegroundFleetLines(runs) {
|
|
|
299
300
|
const childSummary = detachedChildren.map((child) => `${fleetChildDisplayName(child)} #${child.index}`).join(", ");
|
|
300
301
|
lines.push(`- ${run.runId} | detached | ${run.mode}${childSummary ? ` | ${childSummary}` : ""}`);
|
|
301
302
|
lines.push(` status: subagent({ action: "status", id: "${run.runId}" })`);
|
|
302
|
-
lines.push(` recovery: reply to the supervisor request first, then wait with
|
|
303
|
+
lines.push(` recovery: reply to the supervisor request first, then wait with ${waitToolName()}({ id: "${run.runId}" }); do not resume or launch a replacement while any child remains detached.`);
|
|
303
304
|
}
|
|
304
305
|
return lines;
|
|
305
306
|
}
|
|
@@ -467,8 +468,6 @@ function appendKnownArtifacts(lines, input) {
|
|
|
467
468
|
lines.push(` ${artifact}`);
|
|
468
469
|
}
|
|
469
470
|
/**
|
|
470
|
-
* Sanitizes each assembled line independently.
|
|
471
|
-
*
|
|
472
471
|
* Sanitizing the joined response would let a single binary fragment in child
|
|
473
472
|
* output collapse the whole transcript, including run state, artifact paths, and
|
|
474
473
|
* warnings, into the binary placeholder. Per-line sanitization keeps that damage
|
|
@@ -11,6 +11,7 @@ import { FileLeaseBusyError } from "../../shared/file-lease.js";
|
|
|
11
11
|
import { recordWaitCompletion } from "./wait-completions.js";
|
|
12
12
|
import { syncMissionFromAsyncCompletion } from "../../missions/lifecycle.js";
|
|
13
13
|
import { acknowledgeMissionObserverSnapshot, missionObserverIndexPath, missionObserverResultCandidateFiles, promotePendingResultFile, readResultPayload, resultCandidateFilesForSession, resultPayloadPathForIndexedRun, resultPayloadPathForMissionObserverRun, resultPayloadPathForSessionRun, resultSnapshotReplaced, retireResultSnapshot, withResultRunLease, writeAsyncResultFile, writeResultIndexForData } from "./result-files.js";
|
|
14
|
+
import { reportSessionWarning } from "../../shared/session-warnings.js";
|
|
14
15
|
const WATCHER_RESTART_DELAY_MS = 3000;
|
|
15
16
|
const POLL_INTERVAL_MS = 3000;
|
|
16
17
|
const HEALTHY_SCAN_INTERVAL_MS = 60_000;
|
|
@@ -47,16 +48,20 @@ function resultFileIdentity(raw, file) {
|
|
|
47
48
|
runId: file.replace(/\.json$/i, ""),
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function reportResultWatcherWarning(state, message, error, key = message) {
|
|
52
|
+
const detail = error === undefined ? "" : `: ${error instanceof Error ? error.message : String(error)}`;
|
|
53
|
+
reportSessionWarning(state, `${message}${detail}`, key);
|
|
54
|
+
}
|
|
55
|
+
function sanitizeNestedResultChildren(state, value, resultPath, label) {
|
|
51
56
|
if (value === undefined)
|
|
52
57
|
return undefined;
|
|
53
58
|
if (!Array.isArray(value)) {
|
|
54
|
-
|
|
59
|
+
reportResultWatcherWarning(state, `Ignoring invalid nested children in subagent result file '${resultPath}' at ${label}: expected an array.`);
|
|
55
60
|
return undefined;
|
|
56
61
|
}
|
|
57
62
|
const children = value.map((child) => sanitizeSummary(child)).filter((child) => Boolean(child));
|
|
58
63
|
if (children.length !== value.length) {
|
|
59
|
-
|
|
64
|
+
reportResultWatcherWarning(state, `Ignoring ${value.length - children.length} invalid nested child record(s) in subagent result file '${resultPath}' at ${label}.`, undefined, `result-nested-records-invalid:${resultPath}:${label}`);
|
|
60
65
|
}
|
|
61
66
|
return children.length ? children : undefined;
|
|
62
67
|
}
|
|
@@ -114,6 +119,8 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
114
119
|
// Result file -> last logged mission-sync error. A failed sync is retried
|
|
115
120
|
// every pass, so the same error is logged once per result file.
|
|
116
121
|
const reportedMissionSyncFailures = new Map();
|
|
122
|
+
// reportedMissionSyncFailures decides when to report; each report gets its own key so the session warning dedupe never hides it.
|
|
123
|
+
let missionSyncReports = 0;
|
|
117
124
|
let deliveryActive = true;
|
|
118
125
|
let deliveryEpoch = 0;
|
|
119
126
|
let resultScanTimer = null;
|
|
@@ -145,7 +152,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
145
152
|
}
|
|
146
153
|
catch (error) {
|
|
147
154
|
if (!isAbsentResultCandidate(error))
|
|
148
|
-
|
|
155
|
+
reportResultWatcherWarning(state, `Failed to inspect subagent result file '${publicResultPath(file)}'`, error);
|
|
149
156
|
return false;
|
|
150
157
|
}
|
|
151
158
|
};
|
|
@@ -187,7 +194,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
187
194
|
if (isAccessDenied(error))
|
|
188
195
|
throw error;
|
|
189
196
|
if (!isAbsentResultCandidate(error))
|
|
190
|
-
|
|
197
|
+
reportResultWatcherWarning(state, `Failed to inspect subagent result file '${resultPath}'`, error);
|
|
191
198
|
return undefined;
|
|
192
199
|
}
|
|
193
200
|
};
|
|
@@ -211,7 +218,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
211
218
|
if (isAccessDenied(error))
|
|
212
219
|
throw error;
|
|
213
220
|
if (!isAbsentResultCandidate(error))
|
|
214
|
-
|
|
221
|
+
reportResultWatcherWarning(state, `Failed to inspect subagent result file '${resultPath}'`, error);
|
|
215
222
|
return undefined;
|
|
216
223
|
}
|
|
217
224
|
};
|
|
@@ -220,7 +227,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
220
227
|
return new Set(deps.observedCompletionRunIds?.() ?? []);
|
|
221
228
|
}
|
|
222
229
|
catch (error) {
|
|
223
|
-
|
|
230
|
+
reportResultWatcherWarning(state, "Failed to inspect observed subagent completion ids", error);
|
|
224
231
|
return new Set();
|
|
225
232
|
}
|
|
226
233
|
};
|
|
@@ -253,7 +260,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
253
260
|
if (isAbsentResultCandidate(error))
|
|
254
261
|
return;
|
|
255
262
|
if (!(error instanceof FileLeaseBusyError))
|
|
256
|
-
|
|
263
|
+
reportResultWatcherWarning(state, `Failed to remove delivered subagent result '${publicResultPath(file)}'; will retry`, error);
|
|
257
264
|
scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
|
|
258
265
|
}
|
|
259
266
|
};
|
|
@@ -272,7 +279,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
272
279
|
catch (error) {
|
|
273
280
|
if (!isAccessDenied(error))
|
|
274
281
|
throw error;
|
|
275
|
-
|
|
282
|
+
reportResultWatcherWarning(state, `Failed to inspect subagent result file '${publicResultPath(file)}'; will retry`, error);
|
|
276
283
|
scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
|
|
277
284
|
return;
|
|
278
285
|
}
|
|
@@ -330,7 +337,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
330
337
|
catch (error) {
|
|
331
338
|
if (isAccessDenied(error))
|
|
332
339
|
throw error;
|
|
333
|
-
|
|
340
|
+
reportResultWatcherWarning(state, `Failed to re-read subagent result file '${publicResultPath(file)}'`, error);
|
|
334
341
|
}
|
|
335
342
|
identityCache.delete(file);
|
|
336
343
|
rereadReplacedPayload = true;
|
|
@@ -346,7 +353,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
346
353
|
const message = error instanceof Error ? error.message : String(error);
|
|
347
354
|
if (reportedMissionSyncFailures.get(file) !== message) {
|
|
348
355
|
reportedMissionSyncFailures.set(file, message);
|
|
349
|
-
|
|
356
|
+
reportResultWatcherWarning(state, `Mission completion sync failed for '${resultPath}'`, error, `result-mission-sync-failed:${++missionSyncReports}`);
|
|
350
357
|
}
|
|
351
358
|
}
|
|
352
359
|
try {
|
|
@@ -354,7 +361,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
354
361
|
}
|
|
355
362
|
catch (error) {
|
|
356
363
|
observerSucceeded = false;
|
|
357
|
-
|
|
364
|
+
reportResultWatcherWarning(state, `Completion observer failed for '${resultPath}'`, error);
|
|
358
365
|
}
|
|
359
366
|
if (observerSucceeded) {
|
|
360
367
|
try {
|
|
@@ -364,7 +371,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
364
371
|
catch (error) {
|
|
365
372
|
observerSucceeded = false;
|
|
366
373
|
if (!(error instanceof FileLeaseBusyError))
|
|
367
|
-
|
|
374
|
+
reportResultWatcherWarning(state, `Failed to acknowledge the mission observer for '${resultPath}'; will retry`, error);
|
|
368
375
|
}
|
|
369
376
|
}
|
|
370
377
|
const epoch = deliveryEpoch;
|
|
@@ -377,13 +384,13 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
377
384
|
sessionId,
|
|
378
385
|
});
|
|
379
386
|
const hasExplicitNestedChildren = data.nestedChildren !== undefined;
|
|
380
|
-
let nestedChildren = compactNestedResultChildren(sanitizeNestedResultChildren(data.nestedChildren, resultPath, "nestedChildren"));
|
|
387
|
+
let nestedChildren = compactNestedResultChildren(sanitizeNestedResultChildren(state, data.nestedChildren, resultPath, "nestedChildren"));
|
|
381
388
|
if (!nestedChildren?.length && !hasExplicitNestedChildren) {
|
|
382
389
|
try {
|
|
383
390
|
nestedChildren = compactNestedResultChildren(projectNestedRegistryForRoot(runId)?.children);
|
|
384
391
|
}
|
|
385
392
|
catch (error) {
|
|
386
|
-
|
|
393
|
+
reportResultWatcherWarning(state, `Failed to enrich subagent result file '${resultPath}' with nested registry children; will retry later`, error);
|
|
387
394
|
scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
|
|
388
395
|
return;
|
|
389
396
|
}
|
|
@@ -424,7 +431,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
424
431
|
? `${result.error}${hasRealOutput ? `\n\nOutput:\n${baseOutput}` : ""}`
|
|
425
432
|
: output;
|
|
426
433
|
const sessionPath = result.sessionFile ?? (resultChildren.length === 1 ? data.sessionFile : undefined);
|
|
427
|
-
const childNestedChildren = sanitizeNestedResultChildren(result.children, resultPath, `results[${index}].children`);
|
|
434
|
+
const childNestedChildren = sanitizeNestedResultChildren(state, result.children, resultPath, `results[${index}].children`);
|
|
428
435
|
const childState = result.state === "running" || result.state === "queued" || result.state === "paused" || result.state === "stopped"
|
|
429
436
|
? result.state
|
|
430
437
|
: result.stopped === true
|
|
@@ -493,7 +500,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
493
500
|
if (!ownsCompletion(sessionId, completionOwnerId, epoch))
|
|
494
501
|
return;
|
|
495
502
|
if (!intercomDelivered)
|
|
496
|
-
|
|
503
|
+
reportResultWatcherWarning(state, `Subagent async grouped result intercom delivery was not acknowledged for '${resultPath}'.`);
|
|
497
504
|
}
|
|
498
505
|
const delivery = notifier.deliver({
|
|
499
506
|
...data,
|
|
@@ -539,7 +546,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
539
546
|
({ data, read } = marked);
|
|
540
547
|
}
|
|
541
548
|
catch (error) {
|
|
542
|
-
|
|
549
|
+
reportResultWatcherWarning(state, `Failed to mark subagent result notification delivered for '${resultPath}'; will retry`, error);
|
|
543
550
|
scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
|
|
544
551
|
return;
|
|
545
552
|
}
|
|
@@ -566,7 +573,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
566
573
|
});
|
|
567
574
|
}
|
|
568
575
|
catch (error) {
|
|
569
|
-
|
|
576
|
+
reportResultWatcherWarning(state, `Completion observer failed for '${resultPath}'`, error);
|
|
570
577
|
}
|
|
571
578
|
if (!observerSucceeded) {
|
|
572
579
|
scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
|
|
@@ -582,11 +589,11 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
582
589
|
}
|
|
583
590
|
catch (error) {
|
|
584
591
|
if (isAccessDenied(error)) {
|
|
585
|
-
|
|
592
|
+
reportResultWatcherWarning(state, `Failed to process subagent result file '${resultPath}'; will retry`, error);
|
|
586
593
|
scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
|
|
587
594
|
}
|
|
588
595
|
else if (!isNotFound(error))
|
|
589
|
-
|
|
596
|
+
reportResultWatcherWarning(state, `Failed to process subagent result file '${resultPath}'`, error);
|
|
590
597
|
}
|
|
591
598
|
finally {
|
|
592
599
|
processing.delete(file);
|
|
@@ -615,7 +622,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
615
622
|
// session transcript.
|
|
616
623
|
if (resultScanLogging === "activity" && stats.files === 0 && stats.scheduled === 0)
|
|
617
624
|
return;
|
|
618
|
-
|
|
625
|
+
reportSessionWarning(state, `Subagent result scan inspected ${stats.files} indexed result file(s), scheduled ${stats.scheduled} in ${elapsed}ms (${resultsDir}).`, "slow-result-scan");
|
|
619
626
|
};
|
|
620
627
|
const indexedResultCandidates = (observed) => {
|
|
621
628
|
const files = new Set();
|
|
@@ -652,10 +659,33 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
652
659
|
}
|
|
653
660
|
catch (error) {
|
|
654
661
|
if (!isNotFound(error))
|
|
655
|
-
|
|
662
|
+
reportResultWatcherWarning(state, `Failed to scan subagent result index in '${resultsDir}'`, error);
|
|
656
663
|
}
|
|
657
664
|
return files;
|
|
658
665
|
};
|
|
666
|
+
const hasPendingResults = () => eligibleResultFiles().some((file) => {
|
|
667
|
+
const payloadPath = resultPayloadPath(file);
|
|
668
|
+
if (!payloadPath)
|
|
669
|
+
return false;
|
|
670
|
+
let raw;
|
|
671
|
+
try {
|
|
672
|
+
raw = fsApi.readFileSync(payloadPath, "utf-8");
|
|
673
|
+
}
|
|
674
|
+
catch (error) {
|
|
675
|
+
// Removed since the scan means delivered; an unreadable file is still owed to someone, so the switch asks.
|
|
676
|
+
return !isNotFound(error);
|
|
677
|
+
}
|
|
678
|
+
const identity = resultFileIdentity(raw, file);
|
|
679
|
+
if (!identity.sessionId || !ownsResult(identity.sessionId, deliveryOwnerId(identity.sessionId, identity.completionOwnerId, identity.completionOwnerProcess, identity.parentWorkflowRunId)))
|
|
680
|
+
return false;
|
|
681
|
+
try {
|
|
682
|
+
return !hasDeliveredNotification(parseResult(raw));
|
|
683
|
+
}
|
|
684
|
+
catch {
|
|
685
|
+
// A partial write is retried by the watcher; until then it counts as undelivered.
|
|
686
|
+
return true;
|
|
687
|
+
}
|
|
688
|
+
});
|
|
659
689
|
const primeExistingResults = (options = {}) => {
|
|
660
690
|
const triggerTurn = options.triggerTurn !== false;
|
|
661
691
|
for (const file of eligibleResultFiles())
|
|
@@ -689,7 +719,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
689
719
|
return deps.hasDeliveryDemand?.() === true;
|
|
690
720
|
}
|
|
691
721
|
catch (error) {
|
|
692
|
-
|
|
722
|
+
reportResultWatcherWarning(state, "Failed to inspect subagent result delivery demand", error);
|
|
693
723
|
return false;
|
|
694
724
|
}
|
|
695
725
|
};
|
|
@@ -718,7 +748,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
718
748
|
clearResultScan();
|
|
719
749
|
if (state.watcherRestartTimer)
|
|
720
750
|
return;
|
|
721
|
-
|
|
751
|
+
reportResultWatcherWarning(state, `Subagent result watcher for '${resultsDir}' fell back to polling because native fs.watch is unavailable (${errorCode(reason) ?? "unknown error"}).`, undefined, `result-poll-fallback:${resultsDir}`);
|
|
722
752
|
primeExistingResults();
|
|
723
753
|
state.watcherRestartTimer = timers.setInterval(primeExistingResults, POLL_INTERVAL_MS);
|
|
724
754
|
state.watcherRestartTimer.unref?.();
|
|
@@ -736,7 +766,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
736
766
|
catch (error) {
|
|
737
767
|
if (shouldPoll(error))
|
|
738
768
|
return startPolling(error);
|
|
739
|
-
|
|
769
|
+
reportResultWatcherWarning(state, `Failed to restart subagent result watcher for '${resultsDir}'`, error);
|
|
740
770
|
scheduleRestart();
|
|
741
771
|
}
|
|
742
772
|
}, WATCHER_RESTART_DELAY_MS);
|
|
@@ -779,7 +809,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
779
809
|
state.watcher.on("error", (error) => {
|
|
780
810
|
if (shouldPoll(error))
|
|
781
811
|
return startPolling(error);
|
|
782
|
-
|
|
812
|
+
reportResultWatcherWarning(state, `Subagent result watcher failed for '${resultsDir}'`, error);
|
|
783
813
|
state.watcher?.close();
|
|
784
814
|
state.watcher = null;
|
|
785
815
|
scheduleRestart();
|
|
@@ -791,7 +821,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
791
821
|
catch (error) {
|
|
792
822
|
if (shouldPoll(error))
|
|
793
823
|
return startPolling(error);
|
|
794
|
-
|
|
824
|
+
reportResultWatcherWarning(state, `Failed to start subagent result watcher for '${resultsDir}'`, error);
|
|
795
825
|
state.watcher = null;
|
|
796
826
|
scheduleRestart();
|
|
797
827
|
}
|
|
@@ -815,5 +845,5 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
|
|
|
815
845
|
processing.clear();
|
|
816
846
|
identityCache.clear();
|
|
817
847
|
};
|
|
818
|
-
return { startResultWatcher, transitionResultDelivery, primeExistingResults, deliverPendingResults, stopResultWatcher, refreshResultDelivery: () => { primeExistingResults(); startDemandPolling(); } };
|
|
848
|
+
return { startResultWatcher, transitionResultDelivery, primeExistingResults, deliverPendingResults, hasPendingResults, stopResultWatcher, refreshResultDelivery: () => { primeExistingResults(); startDemandPolling(); } };
|
|
819
849
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
2
3
|
import { readAsyncRecoveryDescriptor } from "./async-resume.js";
|
|
3
4
|
import { errorWithoutReplyText } from "../shared/model-resolution.js";
|
|
5
|
+
import { waitToolName } from "../../shared/wait-tool-name.js";
|
|
4
6
|
const INTERCOM_DETACH_ERROR = "detached for intercom coordination";
|
|
5
7
|
function isIntercomDetached(run) {
|
|
6
8
|
return run.steps.some((step) => step.execution?.status === "detached"
|
|
@@ -10,7 +12,7 @@ function isIntercomDetached(run) {
|
|
|
10
12
|
function formatIntercomDetachGuidance(run) {
|
|
11
13
|
if (!isIntercomDetached(run))
|
|
12
14
|
return undefined;
|
|
13
|
-
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 ${waitToolName()}({ 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.`;
|
|
14
16
|
}
|
|
15
17
|
export function formatAsyncReviveCommand(run) {
|
|
16
18
|
const step = run.steps.find((candidate) => candidate.status === "failed");
|
|
@@ -18,7 +20,7 @@ export function formatAsyncReviveCommand(run) {
|
|
|
18
20
|
if (!step || !sessionFile || !fs.existsSync(sessionFile))
|
|
19
21
|
return undefined;
|
|
20
22
|
try {
|
|
21
|
-
const descriptor = readAsyncRecoveryDescriptor(run.asyncDir);
|
|
23
|
+
const descriptor = readAsyncRecoveryDescriptor(path.dirname(run.asyncDir), path.basename(run.asyncDir));
|
|
22
24
|
if (!descriptor || descriptor.sourceRunId !== run.id || descriptor.agent !== step.agent)
|
|
23
25
|
return undefined;
|
|
24
26
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
2
3
|
import { listAsyncRuns } from "./async-status.js";
|
|
3
4
|
import { readAsyncRecoveryDescriptor } from "./async-resume.js";
|
|
4
5
|
import { parallelHandoffPath, resolveRetainedWorktreeCwd } from "../shared/parallel-handoff.js";
|
|
@@ -39,7 +40,7 @@ function childResumability(run, step) {
|
|
|
39
40
|
return session;
|
|
40
41
|
let recoveryDescriptor;
|
|
41
42
|
try {
|
|
42
|
-
recoveryDescriptor = readAsyncRecoveryDescriptor(run.asyncDir);
|
|
43
|
+
recoveryDescriptor = readAsyncRecoveryDescriptor(path.dirname(run.asyncDir), path.basename(run.asyncDir));
|
|
43
44
|
if (!recoveryDescriptor)
|
|
44
45
|
return { state: "not-resumable", reason: "missing recovery descriptor" };
|
|
45
46
|
if (recoveryDescriptor.sourceRunId !== run.id)
|
|
@@ -42,7 +42,6 @@ export interface ChildEvent {
|
|
|
42
42
|
args?: Record<string, unknown>;
|
|
43
43
|
willRetry?: unknown;
|
|
44
44
|
}
|
|
45
|
-
/** Outcome of handing a steer request to a live child session. */
|
|
46
45
|
export interface SteerDelivery {
|
|
47
46
|
state: "delivered" | "queued" | "failed";
|
|
48
47
|
deliveryStatus?: SteerDeliveryStatus;
|
|
@@ -480,12 +480,12 @@ export function runChildSession(input) {
|
|
|
480
480
|
await Promise.resolve().then(() => session?.dispose()).catch(() => undefined);
|
|
481
481
|
return commandError;
|
|
482
482
|
};
|
|
483
|
-
/** The child run ended (or was forced to end); fold in the outcome once the child's shutdown work is done. */
|
|
484
483
|
const failUnconsumedSteers = () => {
|
|
485
484
|
for (const entry of acceptedSteers.splice(0)) {
|
|
486
485
|
input.onSteerOutcome?.(entry.request, { state: "failed", message: unconsumedSteerReason(entry.request.mode) });
|
|
487
486
|
}
|
|
488
487
|
};
|
|
488
|
+
/** The child run ended (or was forced to end); fold in the outcome once the child's shutdown work is done. */
|
|
489
489
|
const settle = (promptError, forced = false) => {
|
|
490
490
|
if (settled)
|
|
491
491
|
return;
|
|
@@ -2,7 +2,7 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { safeTerminalText } from "../../shared/display-text.js";
|
|
4
4
|
import { getArtifactPaths, getArtifactsDir } from "../../shared/artifacts.js";
|
|
5
|
-
import { readFleetTranscript } from "../../
|
|
5
|
+
import { readFleetTranscript } from "../../shared/fleet-transcript-reader.js";
|
|
6
6
|
import { formatAsyncRunList, formatAsyncRunOutputPath, formatAsyncRunProgressLabel, formatWorkflowStageLine, listAsyncRuns } from "./async-status.js";
|
|
7
7
|
import { formatAsyncResultTranscript, formatAsyncRunTranscript, formatNestedRunTranscript, inspectSubagentFleet } from "./fleet-view.js";
|
|
8
8
|
import { formatNestedRunStatusLines } from "../shared/nested-render.js";
|
|
@@ -37,6 +37,7 @@ import { formatWorkflowKeyRevival, projectWorkflowKeyRevival } from "../../workf
|
|
|
37
37
|
import { capSummaryOutputs } from "../shared/single-output.js";
|
|
38
38
|
import { ownsRun } from "../shared/run-ownership.js";
|
|
39
39
|
import { foregroundChildStateLabel } from "../foreground/foreground-history.js";
|
|
40
|
+
import { waitToolName } from "../../shared/wait-tool-name.js";
|
|
40
41
|
/** A step whose structured output has a path line needs only a short inline preview. */
|
|
41
42
|
const STRUCTURED_PREVIEW_WITH_PATH_CHARS = 500;
|
|
42
43
|
function formatProcessTerminal(value) {
|
|
@@ -119,7 +120,7 @@ function formatResumeGuidance(runId, children, fallbackSessionFile, options = {}
|
|
|
119
120
|
const resumableWorkflowChildren = workflowChildren.filter(({ child }) => !(child.status === "paused" && child.activityState === "needs_attention"));
|
|
120
121
|
if (workflowChildren.length > 0) {
|
|
121
122
|
return [
|
|
122
|
-
...supervisorDetachedWorkflowChildren.map(({ child }) => `Recovery workflow child${typeof child.workflowKey === "string" && child.workflowKey.trim() ? ` '${child.workflowKey}'` : ""}: reply to the supervisor request first, then wait with
|
|
123
|
+
...supervisorDetachedWorkflowChildren.map(({ child }) => `Recovery workflow child${typeof child.workflowKey === "string" && child.workflowKey.trim() ? ` '${child.workflowKey}'` : ""}: reply to the supervisor request first, then wait with ${waitToolName()}({ id: "${child.runId}" }). Use subagent({ action: "status", id: "${child.runId}" }) to recover the result; do not resume or launch a replacement while it remains detached.`),
|
|
123
124
|
...resumableWorkflowChildren.map(({ child }) => `Revive workflow child${typeof child.workflowKey === "string" && child.workflowKey.trim() ? ` '${child.workflowKey}'` : ""}: subagent({ action: "resume", id: "${child.runId}", message: "..." })`),
|
|
124
125
|
].join("\n");
|
|
125
126
|
}
|
|
@@ -230,7 +231,7 @@ function formatRememberedForegroundStatus(run) {
|
|
|
230
231
|
const detached = run.children.some((child) => child.status === "detached");
|
|
231
232
|
const resumable = run.children.find((child) => hasExistingSessionFile(child.sessionFile));
|
|
232
233
|
if (detached) {
|
|
233
|
-
lines.push(`Recovery: reply to the supervisor request first, then wait with
|
|
234
|
+
lines.push(`Recovery: reply to the supervisor request first, then wait with ${waitToolName()}({ id: "${run.runId}" }); do not resume or launch a replacement while any child remains detached.`);
|
|
234
235
|
}
|
|
235
236
|
else if (resumable) {
|
|
236
237
|
lines.push(run.children.length === 1
|
|
@@ -17,7 +17,7 @@ export type ScheduleTrigger = {
|
|
|
17
17
|
every: string;
|
|
18
18
|
everyMs: number;
|
|
19
19
|
anchorAt: string;
|
|
20
|
-
nextRunAt
|
|
20
|
+
nextRunAt?: string;
|
|
21
21
|
} | CalendarTrigger;
|
|
22
22
|
export type ScheduleTarget = {
|
|
23
23
|
workflowScript: string;
|
|
@@ -66,6 +66,8 @@ type ScheduledRunManagerDeps = {
|
|
|
66
66
|
resolveCapabilityCeiling?: (sessionId: string) => ResolvedSubagentCapabilityCeiling | undefined;
|
|
67
67
|
timers?: ScheduledRunTimers;
|
|
68
68
|
kill?: (pid: number, signal?: NodeJS.Signals | 0) => boolean;
|
|
69
|
+
/** Shows a warning once per key without drawing over the editor. */
|
|
70
|
+
reportWarning?: (message: string, key: string) => void;
|
|
69
71
|
};
|
|
70
72
|
export declare function isScheduledRunAction(action: unknown): action is ScheduledRunAction;
|
|
71
73
|
export declare function scheduledRunsEnabled(config: ExtensionConfig): boolean;
|