@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
|
@@ -4,6 +4,7 @@ import * as path from "node:path";
|
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
5
|
import type { Message } from "@earendil-works/pi-ai";
|
|
6
6
|
import { resolveNodeExecutable } from "../../shared/node-executable.ts";
|
|
7
|
+
import { getProjectSubagentsDir } from "../../shared/artifacts.ts";
|
|
7
8
|
import { TEMP_ROOT_DIR, type OrcaProgressTabsConfig } from "../../shared/types.ts";
|
|
8
9
|
import { extractTextFromContent, extractToolArgsPreview, getAgentDir } from "../../shared/utils.ts";
|
|
9
10
|
|
|
@@ -23,20 +24,22 @@ const ORCA_CREATE_WATCHDOG_SCRIPT = [
|
|
|
23
24
|
"const {spawn}=require('node:child_process');",
|
|
24
25
|
"const fs=require('node:fs');",
|
|
25
26
|
"const timeout=Number(process.argv[1]),grace=Number(process.argv[2]),waitTimeout=Number(process.argv[3]);",
|
|
26
|
-
"const previous=process.argv[4],done=process.argv[5],
|
|
27
|
+
"const previous=process.argv[4],done=process.argv[5],manifest=process.argv[6],command=process.argv[7],args=process.argv.slice(8);",
|
|
27
28
|
"function mark(){try{fs.writeFileSync(done.replace(/\\.pending$/,'.ready'),'')}catch{}}",
|
|
28
29
|
"function exists(file){try{return fs.existsSync(file)}catch{return false}}",
|
|
29
30
|
"function keepQueued(){try{const now=new Date();fs.utimesSync(done,now,now)}catch{}}",
|
|
30
31
|
"function predecessorReady(){if(previous==='-')return true;if(exists(previous.replace(/\\.pending$/,'.ready')))return true;try{return Date.now()-fs.statSync(previous).mtimeMs>=waitTimeout}catch{return true}}",
|
|
32
|
+
"function updateManifest(state,stdout=''){if(manifest==='-')return;try{const payload=JSON.parse(fs.readFileSync(manifest,'utf8'));payload.state=state;payload.updatedAt=new Date().toISOString();const raw=stdout.trim().split(/\\r?\\n/).filter(Boolean).at(-1);if(raw){try{payload.orca=JSON.parse(raw)}catch{payload.orcaRaw=raw.slice(0,4096)}}fs.writeFileSync(manifest,JSON.stringify(payload,null,2)+'\\n')}catch{}}",
|
|
31
33
|
"function start(){",
|
|
32
34
|
" try{",
|
|
33
|
-
" const child=spawn(command,args,{stdio:'ignore',windowsHide:true});",
|
|
34
|
-
" let hardKill;",
|
|
35
|
+
" const child=spawn(command,args,{stdio:['ignore','pipe','ignore'],windowsHide:true});",
|
|
36
|
+
" let hardKill,stdout='';",
|
|
37
|
+
" if(child.stdout)child.stdout.on('data',chunk=>{stdout+=String(chunk);if(stdout.length>65536)stdout=stdout.slice(-65536)});",
|
|
35
38
|
" const timer=setTimeout(()=>{child.kill('SIGTERM');hardKill=setTimeout(()=>child.kill('SIGKILL'),grace)},timeout);",
|
|
36
39
|
" const clear=()=>{clearTimeout(timer);if(hardKill)clearTimeout(hardKill);mark()};",
|
|
37
|
-
" child.once('error',()=>{clear();process.exitCode=1});",
|
|
38
|
-
" child.once('close',code=>{clear();process.exitCode=code===0?0:1});",
|
|
39
|
-
" }catch{mark();process.exitCode=1}",
|
|
40
|
+
" child.once('error',()=>{updateManifest('failed');clear();process.exitCode=1});",
|
|
41
|
+
" child.once('close',code=>{updateManifest(code===0?'open':'failed',stdout);clear();process.exitCode=code===0?0:1});",
|
|
42
|
+
" }catch{updateManifest('failed');mark();process.exitCode=1}",
|
|
40
43
|
"}",
|
|
41
44
|
"if(predecessorReady())start();",
|
|
42
45
|
"else{(function waitPrev(){keepQueued();if(predecessorReady())return start();setTimeout(waitPrev,20)})();}",
|
|
@@ -51,8 +54,10 @@ const ORCA_CLEANUP_WATCHDOG_SCRIPT = [
|
|
|
51
54
|
|
|
52
55
|
export interface OrcaProgressTab {
|
|
53
56
|
append(text: string): void;
|
|
57
|
+
section(input: { agent: string; index: number; count: number }): void;
|
|
54
58
|
event(event: { type?: string; message?: Message; toolName?: string; args?: unknown }): void;
|
|
55
|
-
|
|
59
|
+
/** Resolves once the mirrored log and its done marker are on disk, so a host may exit afterwards. */
|
|
60
|
+
finish(status: "completed" | "failed" | "stopped", sessionFile?: string): Promise<void>;
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
function executableFile(candidate: string): boolean {
|
|
@@ -143,6 +148,41 @@ function safeSegment(value: unknown, fallback = "subagent"): string {
|
|
|
143
148
|
return value.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48) || fallback;
|
|
144
149
|
}
|
|
145
150
|
|
|
151
|
+
interface OrcaObserverManifest {
|
|
152
|
+
schemaVersion: 1;
|
|
153
|
+
kind: "orca-observer-view";
|
|
154
|
+
observer: "orca";
|
|
155
|
+
role: "run";
|
|
156
|
+
runId: string;
|
|
157
|
+
title: string;
|
|
158
|
+
worktree: string;
|
|
159
|
+
state: "opening" | "open" | "failed";
|
|
160
|
+
createdAt: string;
|
|
161
|
+
updatedAt?: string;
|
|
162
|
+
logPath: string;
|
|
163
|
+
orca?: unknown;
|
|
164
|
+
orcaRaw?: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function observerManifestPath(cwd: string, stem: string): string | undefined {
|
|
168
|
+
try {
|
|
169
|
+
const dir = path.join(getProjectSubagentsDir(resolveSequenceScope(cwd)), "views", "orca");
|
|
170
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
171
|
+
return path.join(dir, `${stem}.json`);
|
|
172
|
+
} catch {
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function writeObserverManifest(manifestPath: string | undefined, manifest: OrcaObserverManifest): void {
|
|
178
|
+
if (!manifestPath) return;
|
|
179
|
+
try {
|
|
180
|
+
fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, { encoding: "utf-8", mode: 0o600 });
|
|
181
|
+
} catch {
|
|
182
|
+
// The Orca observer stays display-only when project-local manifests cannot be written.
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
146
186
|
function sleepSync(ms: number): void {
|
|
147
187
|
const signal = new Int32Array(new SharedArrayBuffer(4));
|
|
148
188
|
Atomics.wait(signal, 0, 0, ms);
|
|
@@ -280,6 +320,7 @@ export function createOrcaProgressTab(input: {
|
|
|
280
320
|
runId: string;
|
|
281
321
|
agent: string;
|
|
282
322
|
index: number;
|
|
323
|
+
stepCount?: number;
|
|
283
324
|
config?: OrcaProgressTabsConfig;
|
|
284
325
|
env?: NodeJS.ProcessEnv;
|
|
285
326
|
command?: string;
|
|
@@ -305,14 +346,28 @@ export function createOrcaProgressTab(input: {
|
|
|
305
346
|
if (reservation === undefined) return undefined;
|
|
306
347
|
const tabSequence = reservation.sequence;
|
|
307
348
|
const stem = `${runId}-${index}-${randomUUID()}`;
|
|
349
|
+
const stepCount = typeof input.stepCount === "number" && Number.isInteger(input.stepCount) && input.stepCount > 0 ? input.stepCount : 1;
|
|
308
350
|
const logPath = path.join(root, `${stem}.log`);
|
|
309
351
|
const donePath = path.join(root, `${stem}.done`);
|
|
310
|
-
const title = `
|
|
352
|
+
const title = `subagents · ${agent} · ${tabSequence}`;
|
|
311
353
|
const markCreateReady = () => {
|
|
312
354
|
try { fs.writeFileSync(reservation.createDone.replace(/\.pending$/, ".ready"), ""); } catch { /* unblock later tabs */ }
|
|
313
355
|
};
|
|
356
|
+
const manifestPath = observerManifestPath(cwd, stem);
|
|
357
|
+
writeObserverManifest(manifestPath, {
|
|
358
|
+
schemaVersion: 1,
|
|
359
|
+
kind: "orca-observer-view",
|
|
360
|
+
observer: "orca",
|
|
361
|
+
role: "run",
|
|
362
|
+
runId,
|
|
363
|
+
title,
|
|
364
|
+
worktree: path.resolve(cwd),
|
|
365
|
+
state: "opening",
|
|
366
|
+
createdAt: new Date().toISOString(),
|
|
367
|
+
logPath,
|
|
368
|
+
});
|
|
314
369
|
try {
|
|
315
|
-
fs.writeFileSync(logPath, `pi-subagents / ${agent}\nrun ${runId} ·
|
|
370
|
+
fs.writeFileSync(logPath, `pi-subagents / ${agent}\nrun ${runId} · ${stepCount === 1 ? "1 child" : `${stepCount} children`}\n${"─".repeat(48)}\n`, { encoding: "utf-8", mode: 0o600 });
|
|
316
371
|
fs.rmSync(donePath, { force: true });
|
|
317
372
|
} catch {
|
|
318
373
|
markCreateReady();
|
|
@@ -361,6 +416,7 @@ export function createOrcaProgressTab(input: {
|
|
|
361
416
|
String(ORCA_CREATE_WAIT_TIMEOUT_MS),
|
|
362
417
|
reservation.previousCreateDone ?? "-",
|
|
363
418
|
reservation.createDone,
|
|
419
|
+
manifestPath ?? "-",
|
|
364
420
|
command,
|
|
365
421
|
"terminal", "create",
|
|
366
422
|
"--worktree", `path:${path.resolve(cwd)}`,
|
|
@@ -398,6 +454,13 @@ export function createOrcaProgressTab(input: {
|
|
|
398
454
|
if (finished) return;
|
|
399
455
|
writeProgress(text);
|
|
400
456
|
},
|
|
457
|
+
section(section) {
|
|
458
|
+
if (finished) return;
|
|
459
|
+
const label = safeSegment(section.agent, "subagent");
|
|
460
|
+
const count = Number.isInteger(section.count) && section.count > 0 ? section.count : 1;
|
|
461
|
+
const index = Number.isInteger(section.index) && section.index >= 0 ? section.index : 0;
|
|
462
|
+
writeProgress(`\n${"─".repeat(16)} child ${index + 1}/${count} · ${label} ${"─".repeat(16)}\n`);
|
|
463
|
+
},
|
|
401
464
|
event(event) {
|
|
402
465
|
if (!available || finished) return;
|
|
403
466
|
if (event.type === "tool_execution_start" && event.toolName) {
|
|
@@ -413,7 +476,7 @@ export function createOrcaProgressTab(input: {
|
|
|
413
476
|
}
|
|
414
477
|
},
|
|
415
478
|
finish(status, sessionFile) {
|
|
416
|
-
if (!available || finished) return;
|
|
479
|
+
if (!available || finished) return Promise.resolve();
|
|
417
480
|
finished = true;
|
|
418
481
|
const sessionId = status === "completed" ? resolvePiSessionId(sessionFile) : undefined;
|
|
419
482
|
let verifiedSessionFile: string | undefined;
|
|
@@ -421,16 +484,20 @@ export function createOrcaProgressTab(input: {
|
|
|
421
484
|
try { verifiedSessionFile = fs.realpathSync(sessionFile); } catch { /* the session is no longer available */ }
|
|
422
485
|
}
|
|
423
486
|
const terminalMessage = verifiedSessionFile
|
|
424
|
-
? `completed. To remove the Pi session
|
|
487
|
+
? `completed. To remove the Pi session for this run, run rm -- ${shellQuote(verifiedSessionFile)}`
|
|
425
488
|
: status;
|
|
426
489
|
const truncation = truncated ? `\n[progress mirror truncated at ${MAX_MIRROR_BYTES} bytes]\n` : "";
|
|
427
490
|
let footer = `${truncation}\n${"─".repeat(48)}\n${terminalMessage}\n`;
|
|
428
491
|
if (scheduledBytes + Buffer.byteLength(footer) > MAX_MIRROR_BYTES) footer = `\n${status}\n`;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
492
|
+
return new Promise<void>((resolve) => {
|
|
493
|
+
logStream.end(footer, () => {
|
|
494
|
+
if (available) {
|
|
495
|
+
try { fs.writeFileSync(donePath, `${status}\n`, { encoding: "utf-8", mode: 0o600 }); } catch { /* best effort */ }
|
|
496
|
+
cleanupPaths = [logPath, donePath];
|
|
497
|
+
scheduleDeferredCleanup();
|
|
498
|
+
}
|
|
499
|
+
resolve();
|
|
500
|
+
});
|
|
434
501
|
});
|
|
435
502
|
},
|
|
436
503
|
};
|