pi-subagents 0.24.4 → 0.27.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 +29 -0
- package/README.md +145 -27
- package/package.json +1 -1
- package/prompts/parallel-context-build.md +3 -1
- package/prompts/parallel-handoff-plan.md +3 -1
- package/prompts/review-loop.md +1 -1
- package/skills/pi-subagents/SKILL.md +71 -20
- package/src/agents/agent-management.ts +57 -15
- package/src/agents/agent-serializer.ts +3 -2
- package/src/agents/agents.ts +47 -16
- package/src/agents/chain-serializer.ts +120 -0
- package/src/extension/fanout-child.ts +171 -0
- package/src/extension/index.ts +7 -2
- package/src/extension/schemas.ts +138 -5
- package/src/intercom/result-intercom.ts +108 -0
- package/src/runs/background/async-execution.ts +185 -10
- package/src/runs/background/async-job-tracker.ts +41 -6
- package/src/runs/background/async-resume.ts +28 -15
- package/src/runs/background/async-status.ts +71 -31
- package/src/runs/background/result-watcher.ts +111 -54
- package/src/runs/background/run-id-resolver.ts +83 -0
- package/src/runs/background/run-status.ts +89 -4
- package/src/runs/background/stale-run-reconciler.ts +46 -1
- package/src/runs/background/subagent-runner.ts +648 -42
- package/src/runs/foreground/chain-execution.ts +331 -118
- package/src/runs/foreground/execution.ts +226 -10
- package/src/runs/foreground/subagent-executor.ts +377 -14
- package/src/runs/shared/acceptance-contract.ts +291 -0
- package/src/runs/shared/acceptance-evaluation.ts +221 -0
- package/src/runs/shared/acceptance-finalization.ts +161 -0
- package/src/runs/shared/acceptance-reports.ts +127 -0
- package/src/runs/shared/acceptance.ts +22 -0
- package/src/runs/shared/chain-outputs.ts +101 -0
- package/src/runs/shared/completion-guard.ts +26 -3
- package/src/runs/shared/dynamic-fanout.ts +293 -0
- package/src/runs/shared/nested-events.ts +819 -0
- package/src/runs/shared/nested-path.ts +52 -0
- package/src/runs/shared/nested-render.ts +115 -0
- package/src/runs/shared/parallel-utils.ts +31 -1
- package/src/runs/shared/pi-args.ts +73 -5
- package/src/runs/shared/structured-output.ts +77 -0
- package/src/runs/shared/subagent-prompt-runtime.ts +77 -7
- package/src/runs/shared/workflow-graph.ts +206 -0
- package/src/shared/formatters.ts +2 -2
- package/src/shared/settings.ts +53 -4
- package/src/shared/types.ts +345 -0
- package/src/slash/slash-commands.ts +41 -3
- package/src/tui/render.ts +268 -43
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { writeAtomicJson } from "../../shared/atomic-json.ts";
|
|
4
|
-
import { RESULTS_DIR, type AsyncParallelGroupStatus, type AsyncStatus, type SubagentRunMode } from "../../shared/types.ts";
|
|
4
|
+
import { RESULTS_DIR, type AsyncParallelGroupStatus, type AsyncStatus, type NestedRunSummary, type SubagentRunMode } from "../../shared/types.ts";
|
|
5
5
|
import { normalizeParallelGroups } from "./parallel-groups.ts";
|
|
6
|
+
import { nestedSummaryFromAsyncStatus, projectNestedEvents, resolveNestedAsyncDir, writeNestedEvent, type NestedRoute } from "../shared/nested-events.ts";
|
|
6
7
|
|
|
7
8
|
export type PidLiveness = "alive" | "dead" | "unknown";
|
|
8
9
|
|
|
@@ -233,6 +234,50 @@ function writeFailedRepair(asyncDir: string, status: AsyncStatus, resultPath: st
|
|
|
233
234
|
return { status: repair.status, repaired: true, resultPath, message: repair.message };
|
|
234
235
|
}
|
|
235
236
|
|
|
237
|
+
function terminal(state: AsyncStatus["state"]): boolean {
|
|
238
|
+
return state === "complete" || state === "failed" || state === "paused";
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function* nestedRuns(children: NestedRunSummary[] | undefined): Generator<NestedRunSummary> {
|
|
242
|
+
for (const child of children ?? []) {
|
|
243
|
+
yield child;
|
|
244
|
+
yield* nestedRuns(child.children);
|
|
245
|
+
yield* nestedRuns(child.steps?.flatMap((step) => step.children ?? []));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function reconcileNestedAsyncDescendants(route: NestedRoute, options: ReconcileAsyncRunOptions = {}): void {
|
|
250
|
+
const registry = projectNestedEvents(route);
|
|
251
|
+
for (const run of nestedRuns(registry.children)) {
|
|
252
|
+
if (run.state !== "running" && run.state !== "queued") continue;
|
|
253
|
+
const asyncDir = resolveNestedAsyncDir(route.rootRunId, run);
|
|
254
|
+
if (!asyncDir) continue;
|
|
255
|
+
const result = reconcileAsyncRun(asyncDir, {
|
|
256
|
+
...options,
|
|
257
|
+
resultsDir: path.join(options.resultsDir ?? RESULTS_DIR, "nested", route.rootRunId),
|
|
258
|
+
});
|
|
259
|
+
const status = result.status;
|
|
260
|
+
if (!status) continue;
|
|
261
|
+
if (!result.repaired && !terminal(status.state)) continue;
|
|
262
|
+
const ts = options.now?.() ?? Date.now();
|
|
263
|
+
writeNestedEvent(route, {
|
|
264
|
+
type: terminal(status.state) ? "subagent.nested.completed" : "subagent.nested.updated",
|
|
265
|
+
ts,
|
|
266
|
+
parentRunId: run.parentRunId,
|
|
267
|
+
parentStepIndex: run.parentStepIndex,
|
|
268
|
+
child: nestedSummaryFromAsyncStatus(status, asyncDir, {
|
|
269
|
+
id: run.id,
|
|
270
|
+
parentRunId: run.parentRunId,
|
|
271
|
+
parentStepIndex: run.parentStepIndex,
|
|
272
|
+
depth: run.depth,
|
|
273
|
+
path: run.path,
|
|
274
|
+
mode: run.mode,
|
|
275
|
+
ts,
|
|
276
|
+
}),
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
236
281
|
export function checkPidLiveness(pid: number, kill: KillFn = process.kill): PidLiveness {
|
|
237
282
|
try {
|
|
238
283
|
kill(pid, 0);
|