@xzzpig/pi-subagents 0.19.0 → 0.21.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 +214 -0
- package/README.md +1 -1
- package/agents/oracle.md +8 -19
- package/agents/researcher.md +0 -3
- package/agents/reviewer.md +17 -61
- package/agents/scout.md +1 -4
- package/agents/worker.md +8 -25
- package/docs/agents.md +86 -11
- package/docs/configuration.md +68 -7
- package/docs/extension-api.md +37 -12
- package/docs/fork-extensions.md +1 -0
- package/docs/missions.md +48 -17
- package/docs/models.md +7 -3
- package/docs/observability.md +18 -8
- package/docs/tool-reference.md +138 -80
- package/docs/watchdog.md +8 -6
- package/docs/workflows.md +18 -9
- package/index.ts +5 -0
- package/package.json +5 -3
- package/prompts/council.md +1 -1
- package/skills/pi-subagents/SKILL.md +1 -1
- package/skills/pi-subagents/references/constraints-and-recipes.md +1 -1
- package/skills/pi-subagents/references/execution-controls.md +16 -16
- package/skills/pi-subagents/references/management-authoring-rpc.md +16 -12
- package/skills/pi-subagents/references/prompting-and-roles.md +3 -3
- package/src/agents/advertised-agent-prompt.ts +9 -1
- package/src/agents/agent-management.ts +4 -0
- package/src/agents/agent-memory.ts +3 -3
- package/src/agents/agent-scope.ts +4 -0
- package/src/agents/agent-serializer.ts +8 -1
- package/src/agents/agents.ts +224 -122
- package/src/api/preflight.ts +50 -5
- package/src/extension/config.ts +24 -2
- package/src/extension/context-injection.ts +6 -1
- package/src/extension/control-notices.ts +1 -9
- package/src/extension/declaration-pinning.ts +164 -0
- package/src/extension/doctor.ts +7 -10
- package/src/extension/fanout-child.ts +7 -8
- package/src/extension/index.ts +134 -145
- package/src/extension/public-execution.ts +3 -0
- package/src/extension/reply-workflow-script.ts +21 -12
- package/src/extension/rpc.ts +12 -7
- package/src/extension/schemas.ts +39 -33
- package/src/extension/subagent-guide.ts +86 -6
- package/src/extension/subagent-options.ts +47 -0
- package/src/extension/tool-activation.ts +3 -2
- package/src/extension/tool-description.ts +51 -68
- package/src/inspectors/actions.ts +37 -11
- package/src/inspectors/plugins.ts +3 -2
- package/src/inspectors/tmux/actions.ts +204 -0
- package/src/inspectors/tmux/client.ts +85 -0
- package/src/inspectors/tmux/plugin.ts +21 -0
- package/src/integrations/herdr-status.ts +18 -49
- package/src/integrations/program-status.ts +215 -0
- package/src/intercom/native-supervisor-channel.ts +77 -4
- package/src/intercom/result-intercom.ts +3 -2
- package/src/intercom/supervisor-ui.ts +2 -174
- package/src/missions/goal-driver.ts +44 -31
- package/src/missions/store.ts +35 -6
- package/src/profiles/profiles.ts +29 -23
- package/src/runs/background/active-async-capacity.ts +58 -8
- package/src/runs/background/async-execution.ts +231 -44
- package/src/runs/background/async-job-tracker.ts +12 -4
- package/src/runs/background/async-resume.ts +5 -2
- package/src/runs/background/await-async-run.ts +18 -11
- package/src/runs/background/binary-bootstrap.ts +2 -1
- package/src/runs/background/calendar-schedule.ts +90 -0
- package/src/runs/background/chain-root-attachment.ts +9 -5
- package/src/runs/background/control-channel.ts +43 -0
- package/src/runs/background/fleet-view.ts +5 -5
- package/src/runs/background/notify.ts +185 -12
- package/src/runs/background/result-files.ts +116 -5
- package/src/runs/background/result-watcher.ts +99 -66
- package/src/runs/background/resume-guidance.ts +2 -2
- package/src/runs/background/run-child-session.ts +29 -8
- package/src/runs/background/run-id-resolver.ts +8 -5
- package/src/runs/background/run-status.ts +21 -16
- package/src/runs/background/runner-aliases.ts +7 -4
- package/src/runs/background/runner-child-launch.ts +1 -0
- package/src/runs/background/runner-http-dispatcher.ts +3 -0
- package/src/runs/background/scheduled-runs.ts +282 -72
- package/src/runs/background/stale-run-reconciler.ts +13 -2
- package/src/runs/background/subagent-runner-bootstrap.ts +4 -1
- package/src/runs/background/subagent-runner.ts +75 -16
- package/src/runs/background/subagent-wait.ts +38 -19
- package/src/runs/background/terminal-run-index.ts +46 -1
- package/src/runs/background/wait-completions.ts +1 -0
- package/src/runs/background/wait-tool.ts +33 -23
- package/src/runs/background/workflow-terminal-proof.ts +39 -22
- package/src/runs/foreground/async-stop-action.ts +48 -22
- package/src/runs/foreground/command-action.ts +41 -0
- package/src/runs/foreground/execution.ts +109 -58
- package/src/runs/foreground/foreground-history.ts +1 -0
- package/src/runs/foreground/subagent-executor.ts +270 -89
- package/src/runs/shared/child-commands.ts +229 -0
- package/src/runs/shared/child-hooks.ts +4 -3
- package/src/runs/shared/child-launch.ts +3 -0
- package/src/runs/shared/child-session.ts +131 -40
- package/src/runs/shared/child-tool-plan.ts +14 -27
- package/src/runs/shared/claude-code-adapter.ts +157 -2
- package/src/runs/shared/dynamic-fanout.ts +2 -2
- package/src/runs/shared/external-cli-preflight.ts +54 -6
- package/src/runs/shared/external-cli-runner.ts +5 -1
- package/src/runs/shared/fork-command-result.ts +10 -0
- package/src/runs/shared/herdr-placed-run.ts +5 -4
- package/src/runs/shared/mcp-direct-tool-allowlist.ts +8 -5
- package/src/runs/shared/model-resolution-diagnostic.ts +25 -0
- package/src/runs/shared/model-resolution.ts +39 -2
- package/src/runs/shared/nested-events.ts +5 -0
- package/src/runs/shared/parallel-handoff.ts +56 -8
- package/src/runs/shared/parallel-utils.ts +4 -0
- package/src/runs/shared/partial-output.ts +48 -0
- package/src/runs/shared/run-history.ts +87 -0
- package/src/runs/shared/runner-launcher.ts +25 -0
- package/src/runs/shared/single-output.ts +53 -0
- package/src/runs/shared/structured-output.ts +14 -7
- package/src/runs/shared/subagent-control.ts +33 -18
- package/src/runs/shared/subagent-prompt-runtime.ts +59 -30
- package/src/runs/shared/workflow-async-child-guidance.ts +1 -1
- package/src/runs/shared/worktree-cleanup-apply.ts +160 -0
- package/src/runs/shared/worktree-cleanup-plan.ts +41 -19
- package/src/runs/shared/worktree-lock.ts +29 -0
- package/src/runs/shared/worktree.ts +12 -1
- package/src/shared/atomic-json.ts +4 -2
- package/src/shared/edit-distance.ts +33 -0
- package/src/shared/file-lease.ts +74 -0
- package/src/shared/formatters.ts +1 -5
- package/src/shared/model-info.ts +22 -0
- package/src/shared/package-version.ts +17 -0
- package/src/shared/parent-wake.ts +79 -0
- package/src/shared/pruned-fork.ts +7 -1
- package/src/shared/required-child-extensions.ts +39 -5
- package/src/shared/runtime-module-path.ts +19 -0
- package/src/shared/settings-file-lease.ts +36 -0
- package/src/shared/types.ts +42 -3
- package/src/shared/utils.ts +8 -6
- package/src/slash/slash-commands.ts +3 -3
- package/src/slash/subagent-cost.ts +9 -5
- package/src/slash/subagents-admin.ts +2 -1
- package/src/tui/fleet-native-transcript.ts +2 -0
- package/src/tui/fleet-transcript.ts +12 -3
- package/src/tui/fleet.ts +11 -8
- package/src/tui/render.ts +28 -20
- package/src/tui/subagent-messages.ts +305 -0
- package/src/watchdog/diff-tool.ts +2 -2
- package/src/watchdog/register-main.ts +2 -22
- package/src/watchdog/render.ts +2 -24
- package/src/watchdog/runtime.ts +6 -4
- package/src/watchdog/settings.ts +18 -13
- package/src/watchdog/tool-actions.ts +2 -2
- package/src/workflows/scripted-workflow.ts +20 -6
- package/src/workflows/workflow-receipt.ts +2 -2
- package/src/workflows/workflow-resources.ts +18 -4
|
@@ -35,6 +35,10 @@ import { formatWorkflowChecklistText, projectWorkflowChecklist } from "../../wor
|
|
|
35
35
|
import { validHostStepNodes } from "../shared/host-step-status.ts";
|
|
36
36
|
import { workflowAsyncChildSteeringGuidance } from "../shared/workflow-async-child-guidance.ts";
|
|
37
37
|
import { formatWorkflowKeyRevival, projectWorkflowKeyRevival } from "../../workflows/workflow-revival.ts";
|
|
38
|
+
import { capSummaryOutputs } from "../shared/single-output.ts";
|
|
39
|
+
|
|
40
|
+
/** A step whose structured output has a path line needs only a short inline preview. */
|
|
41
|
+
const STRUCTURED_PREVIEW_WITH_PATH_CHARS = 500;
|
|
38
42
|
|
|
39
43
|
interface RunStatusParams {
|
|
40
44
|
action?: string;
|
|
@@ -146,7 +150,7 @@ function formatResumeGuidance(runId: string | undefined, children: Array<{ agent
|
|
|
146
150
|
}
|
|
147
151
|
const childWithSession = knownChildren.find(({ child }) => hasExistingSessionFile(child.sessionFile));
|
|
148
152
|
if (childWithSession) {
|
|
149
|
-
return `Revive child: subagent({ action: "resume", id: "${runId}", index: ${childWithSession.index}
|
|
153
|
+
return `Revive child: subagent({ action: "resume", id: "${runId}", message: "...", options: { index: ${childWithSession.index} } })`;
|
|
150
154
|
}
|
|
151
155
|
return "Resume: unavailable; no child session file was persisted.";
|
|
152
156
|
}
|
|
@@ -231,8 +235,8 @@ function formatRememberedForegroundStatus(run: ForegroundResumeRun): string {
|
|
|
231
235
|
if (child.transcriptError) lines.push(` Transcript warning: ${child.transcriptError}`);
|
|
232
236
|
}
|
|
233
237
|
lines.push("", `Status: subagent({ action: "status", id: "${run.runId}" })`);
|
|
234
|
-
if (run.children.length === 1) lines.push(`Transcript: subagent({ action: "status", id: "${run.runId}", view: "transcript" })`);
|
|
235
|
-
else lines.push(`Transcript: subagent({ action: "status", id: "${run.runId}", index: 0, view: "transcript" })`);
|
|
238
|
+
if (run.children.length === 1) lines.push(`Transcript: subagent({ action: "status", id: "${run.runId}", options: { view: "transcript" } })`);
|
|
239
|
+
else lines.push(`Transcript: subagent({ action: "status", id: "${run.runId}", options: { index: 0, view: "transcript" } })`);
|
|
236
240
|
const detached = run.children.some((child) => child.status === "detached");
|
|
237
241
|
const resumable = run.children.find((child) => hasExistingSessionFile(child.sessionFile));
|
|
238
242
|
if (detached) {
|
|
@@ -240,7 +244,7 @@ function formatRememberedForegroundStatus(run: ForegroundResumeRun): string {
|
|
|
240
244
|
} else if (resumable) {
|
|
241
245
|
lines.push(run.children.length === 1
|
|
242
246
|
? `Revive: subagent({ action: "resume", id: "${run.runId}", message: "..." })`
|
|
243
|
-
: `Revive child: subagent({ action: "resume", id: "${run.runId}", index: ${resumable.index}
|
|
247
|
+
: `Revive child: subagent({ action: "resume", id: "${run.runId}", message: "...", options: { index: ${resumable.index} } })`);
|
|
244
248
|
} else {
|
|
245
249
|
lines.push("Resume: unavailable; no child session file was persisted.");
|
|
246
250
|
}
|
|
@@ -385,7 +389,7 @@ export function inspectSubagentStatus(params: RunStatusParams, deps: RunStatusDe
|
|
|
385
389
|
if (params.view === "transcript") {
|
|
386
390
|
if (runs.length === 1) return inspectSubagentStatus({ ...params, id: runs[0]!.id }, deps);
|
|
387
391
|
return {
|
|
388
|
-
content: [{ type: "text", text: runs.length === 0 ? "No active async run transcript is available." : `Transcript view requires an id when ${runs.length} active async runs exist. Use subagent({ action: "status", view: "fleet" }) to choose one.` }],
|
|
392
|
+
content: [{ type: "text", text: runs.length === 0 ? "No active async run transcript is available." : `Transcript view requires an id when ${runs.length} active async runs exist. Use subagent({ action: "status", options: { view: "fleet" } }) to choose one.` }],
|
|
389
393
|
isError: true,
|
|
390
394
|
details: { mode: "single", results: [] },
|
|
391
395
|
};
|
|
@@ -640,7 +644,7 @@ export function inspectSubagentStatus(params: RunStatusParams, deps: RunStatusDe
|
|
|
640
644
|
const revival = projectWorkflowKeyRevival(asyncDirRoot, status.runId, step.workflowKey, step.runId);
|
|
641
645
|
if (revival) lines.push(` ${formatWorkflowKeyRevival(revival)}`);
|
|
642
646
|
}
|
|
643
|
-
const structuredOutputPreview = step.structuredOutput === undefined ? undefined : formatWorkflowJsonPreview(step.structuredOutput, 4_000);
|
|
647
|
+
const structuredOutputPreview = step.structuredOutput === undefined ? undefined : formatWorkflowJsonPreview(step.structuredOutput, step.structuredOutputPath ? STRUCTURED_PREVIEW_WITH_PATH_CHARS : 4_000);
|
|
644
648
|
if (structuredOutputPreview !== undefined) lines.push(` Structured output: ${structuredOutputPreview}`);
|
|
645
649
|
if (step.structuredOutputPath) lines.push(` Structured output path: ${step.structuredOutputPath}`);
|
|
646
650
|
lines.push(...formatTimeoutRecoveryLines(step.timeoutRecovery, " "));
|
|
@@ -676,7 +680,7 @@ export function inspectSubagentStatus(params: RunStatusParams, deps: RunStatusDe
|
|
|
676
680
|
if (step.externalJob?.resultArtifactPath) lines.push(` Result artifact: ${step.externalJob.resultArtifactPath}`);
|
|
677
681
|
if ((step.status === "complete" || step.status === "completed") && step.externalJob?.state === "completed" && step.externalJob.providerJobId && externalJobFollowUpSupported(step.runner.provider)) {
|
|
678
682
|
hasExternalJobFollowUpHint = true;
|
|
679
|
-
lines.push(` Follow-up: subagent({ action: "resume", id: "${status.runId}", index: ${index}
|
|
683
|
+
lines.push(` Follow-up: subagent({ action: "resume", id: "${status.runId}", message: "...", options: { index: ${index} } })`);
|
|
680
684
|
}
|
|
681
685
|
}
|
|
682
686
|
lines.push(...formatNestedRunStatusLines(step.children, { indent: " ", commandHints: true, maxLines: 20 }));
|
|
@@ -684,7 +688,7 @@ export function inspectSubagentStatus(params: RunStatusParams, deps: RunStatusDe
|
|
|
684
688
|
if (stepOutputPath !== outputPath && fs.existsSync(stepOutputPath)) lines.push(` Output: ${stepOutputPath}`);
|
|
685
689
|
if (step.status === "running" && step.runner?.type !== "external-cli" && step.runner?.type !== "external-job" && status.mode !== "workflow") {
|
|
686
690
|
lines.push(` Intercom target: ${resolveSubagentIntercomTarget(status.runId, step.agent, index)} (if registered)`);
|
|
687
|
-
lines.push(` Steer: subagent({ action: "steer", id: "${status.runId}", index: ${index}
|
|
691
|
+
lines.push(` Steer: subagent({ action: "steer", id: "${status.runId}", message: "...", options: { index: ${index} } })`);
|
|
688
692
|
} else if (step.status === "running" && (step.runner?.type === "external-cli" || step.runner?.type === "external-job")) {
|
|
689
693
|
lines.push(" Steer: unavailable; external runners do not accept live messages.");
|
|
690
694
|
}
|
|
@@ -701,7 +705,7 @@ export function inspectSubagentStatus(params: RunStatusParams, deps: RunStatusDe
|
|
|
701
705
|
if (liveWorkflowControls.length === 0) lines.push("Steer: unavailable; no live foreground route is registered in the active session.");
|
|
702
706
|
else for (const control of liveWorkflowControls) {
|
|
703
707
|
for (const index of [...control.activeChildren!.keys()].sort((left, right) => left - right)) {
|
|
704
|
-
lines.push(`Steer live foreground child: subagent({ action: "steer", id: "${control.runId}", index: ${index}
|
|
708
|
+
lines.push(`Steer live foreground child: subagent({ action: "steer", id: "${control.runId}", message: "...", options: { index: ${index} } })`);
|
|
705
709
|
}
|
|
706
710
|
}
|
|
707
711
|
lines.push(...workflowAsyncChildSteeringGuidance(status, deps.state));
|
|
@@ -719,7 +723,7 @@ export function inspectSubagentStatus(params: RunStatusParams, deps: RunStatusDe
|
|
|
719
723
|
if (fs.existsSync(logPath)) lines.push(`Log: ${logPath}`);
|
|
720
724
|
if (fs.existsSync(eventsPath)) lines.push(`Events: ${eventsPath}`);
|
|
721
725
|
|
|
722
|
-
return { content: [{ type: "text", text: lines.join("\n") }], details: { mode: "single", results: [], ...(status.workflowReceiptPath ? { workflowReceiptPath: status.workflowReceiptPath } : {}), ...(status.preflight ? { preflight: status.preflight } : {}), ...(status.workflow?.preflightWarnings?.length ? { preflightWarnings: status.workflow.preflightWarnings } : {}), ...(workflowChildren ? { workflowChildren } : {}), ...(workflowTerminalProof ? { workflowTerminalProof } : {}), ...(runFanoutBudget ? { runFanoutBudget } : {}), ...(processTerminal ? { lifecycleStatus: { processTerminal } } : {}) } };
|
|
726
|
+
return { content: [{ type: "text", text: lines.join("\n") }], details: { mode: "single", runId: status.runId, ...(status.toolCallId ? { toolCallId: status.toolCallId } : {}), results: [], ...(status.workflowReceiptPath ? { workflowReceiptPath: status.workflowReceiptPath } : {}), ...(status.preflight ? { preflight: status.preflight } : {}), ...(status.workflow?.preflightWarnings?.length ? { preflightWarnings: status.workflow.preflightWarnings } : {}), ...(workflowChildren ? { workflowChildren } : {}), ...(workflowTerminalProof ? { workflowTerminalProof } : {}), ...(runFanoutBudget ? { runFanoutBudget } : {}), ...(processTerminal ? { lifecycleStatus: { processTerminal } } : {}) } };
|
|
723
727
|
}
|
|
724
728
|
}
|
|
725
729
|
|
|
@@ -733,7 +737,7 @@ export function inspectSubagentStatus(params: RunStatusParams, deps: RunStatusDe
|
|
|
733
737
|
}
|
|
734
738
|
try {
|
|
735
739
|
const raw = fs.readFileSync(resultPath, "utf-8");
|
|
736
|
-
const data = JSON.parse(raw) as { id?: string; runId?: string; toolCallId?: string; agent?: string; success?: boolean; summary?: string; output?: string; exitCode?: number; state?: string; stopped?: boolean; timedOut?: boolean; turnBudgetExceeded?: boolean; processSignal?: string | null; sessionFile?: string; timeoutRecovery?: unknown; parallelHandoff?: { path?: string }; results?: Array<{ agent?: string; sessionName?: string; runId?: string; workflowKey?: string; output?: string; summary?: string; sessionFile?: string; state?: string; success?: boolean; exitCode?: number | null; stopped?: boolean; timedOut?: boolean; turnBudgetExceeded?: boolean; interrupted?: boolean; processSignal?: string | null; timeoutRecovery?: unknown }> };
|
|
740
|
+
const data = JSON.parse(raw) as { id?: string; runId?: string; toolCallId?: string; agent?: string; success?: boolean; summary?: string; output?: string; exitCode?: number; state?: string; stopped?: boolean; timedOut?: boolean; turnBudgetExceeded?: boolean; processSignal?: string | null; sessionFile?: string; timeoutRecovery?: unknown; parallelHandoff?: { path?: string }; results?: Array<{ agent?: string; sessionName?: string; runId?: string; workflowKey?: string; output?: string; summary?: string; sessionFile?: string; state?: string; success?: boolean; exitCode?: number | null; stopped?: boolean; timedOut?: boolean; turnBudgetExceeded?: boolean; interrupted?: boolean; processSignal?: string | null; timeoutRecovery?: unknown; savedOutputPath?: string; artifactPaths?: { outputPath?: string } }> };
|
|
737
741
|
if (params.view === "transcript") {
|
|
738
742
|
try {
|
|
739
743
|
return { content: [{ type: "text", text: formatAsyncResultTranscript(data, resultPath, { index: params.index, lines: params.lines }) }], details: { mode: "single", results: [] } };
|
|
@@ -769,17 +773,18 @@ export function inspectSubagentStatus(params: RunStatusParams, deps: RunStatusDe
|
|
|
769
773
|
lines.push(...formatTimeoutRecoveryLines(data.timeoutRecovery, " "));
|
|
770
774
|
for (const [index, child] of children.entries()) {
|
|
771
775
|
const structuredOutput = (child as { structuredOutput?: unknown }).structuredOutput;
|
|
772
|
-
const structuredOutputPreview = structuredOutput === undefined ? undefined : formatWorkflowJsonPreview(structuredOutput, 4_000);
|
|
773
|
-
if (structuredOutputPreview !== undefined) lines.push(` Structured output${children.length > 1 ? ` (${index + 1})` : ""}: ${structuredOutputPreview}`);
|
|
774
776
|
const structuredOutputPath = (child as { structuredOutputPath?: unknown }).structuredOutputPath;
|
|
775
|
-
|
|
777
|
+
const hasStructuredOutputPath = typeof structuredOutputPath === "string" && structuredOutputPath.trim() !== "";
|
|
778
|
+
const structuredOutputPreview = structuredOutput === undefined ? undefined : formatWorkflowJsonPreview(structuredOutput, hasStructuredOutputPath ? STRUCTURED_PREVIEW_WITH_PATH_CHARS : 4_000);
|
|
779
|
+
if (structuredOutputPreview !== undefined) lines.push(` Structured output${children.length > 1 ? ` (${index + 1})` : ""}: ${structuredOutputPreview}`);
|
|
780
|
+
if (hasStructuredOutputPath) lines.push(` Structured output path${children.length > 1 ? ` (${index + 1})` : ""}: ${structuredOutputPath}`);
|
|
776
781
|
lines.push(...formatTimeoutRecoveryLines(child.timeoutRecovery, " "));
|
|
777
782
|
}
|
|
778
783
|
lines.push(formatResumeGuidance(runId, children, data.sessionFile, { stopped: status === "stopped" }));
|
|
779
|
-
if (data.summary) lines.push("", data.summary);
|
|
784
|
+
if (data.summary) lines.push("", capSummaryOutputs(data.summary, data.results));
|
|
780
785
|
const workflowChildren = parseWorkflowChildSummary((data as unknown as Record<string, unknown>).workflowChildren);
|
|
781
786
|
if (workflowChildren && workflowChildren.workflowRunId !== runId) throw new Error("workflowChildren.workflowRunId does not match the result run id.");
|
|
782
|
-
return { content: [{ type: "text", text: lines.join("\n") }], details: { mode: "single", results: [], ...(workflowReceiptPath ? { workflowReceiptPath } : {}), ...(workflowChildren ? { workflowChildren } : {}) } };
|
|
787
|
+
return { content: [{ type: "text", text: lines.join("\n") }], details: { mode: "single", ...(runId ? { runId } : {}), ...(data.toolCallId ? { toolCallId: data.toolCallId } : {}), results: [], ...(workflowReceiptPath ? { workflowReceiptPath } : {}), ...(workflowChildren ? { workflowChildren } : {}) } };
|
|
783
788
|
} catch (error) {
|
|
784
789
|
const message = error instanceof Error ? error.message : String(error);
|
|
785
790
|
return {
|
|
@@ -15,10 +15,11 @@ import * as path from "node:path";
|
|
|
15
15
|
export const JITI_ALIAS_ENV = "JITI_ALIAS";
|
|
16
16
|
|
|
17
17
|
/** Specifiers the runner's import graph may use, with the package and export subpath each resolves to. */
|
|
18
|
-
export const HOST_PEER_ALIASES: ReadonlyArray<{ specifier: string; pkg: string; subpath: string }> = [
|
|
18
|
+
export const HOST_PEER_ALIASES: ReadonlyArray<{ specifier: string; pkg: string; subpath: string; optional?: boolean }> = [
|
|
19
19
|
{ specifier: "@earendil-works/pi-coding-agent", pkg: "@earendil-works/pi-coding-agent", subpath: "." },
|
|
20
20
|
{ specifier: "@earendil-works/pi-agent-core", pkg: "@earendil-works/pi-agent-core", subpath: "." },
|
|
21
|
-
|
|
21
|
+
// Optional: hosts whose pi-agent-core declares no "./node" export cannot import it, so no alias is needed.
|
|
22
|
+
{ specifier: "@earendil-works/pi-agent-core/node", pkg: "@earendil-works/pi-agent-core", subpath: "./node", optional: true },
|
|
22
23
|
{ specifier: "@earendil-works/pi-tui", pkg: "@earendil-works/pi-tui", subpath: "." },
|
|
23
24
|
{ specifier: "@earendil-works/pi-ai", pkg: "@earendil-works/pi-ai", subpath: "./compat" },
|
|
24
25
|
{ specifier: "@earendil-works/pi-ai/compat", pkg: "@earendil-works/pi-ai", subpath: "./compat" },
|
|
@@ -160,10 +161,12 @@ export function resolveHostPeerAliases(piPackageRoot: string): { aliases: Record
|
|
|
160
161
|
// hosts retain the required aliases, rather than hiding a broken install.
|
|
161
162
|
const stableVersion = typeof hostManifest?.version === "string" ? /^0\.(\d+)\.\d+$/.exec(hostManifest.version) : null;
|
|
162
163
|
const isPreChord = stableVersion !== null && Number(stableVersion[1]) < 85;
|
|
163
|
-
const required = [...HOST_PEER_ALIASES, ...(isPreChord ? [] : CHORD_PEER_ALIASES)];
|
|
164
|
-
for (const { specifier, pkg, subpath } of required) {
|
|
164
|
+
const required: ReadonlyArray<(typeof HOST_PEER_ALIASES)[number]> = [...HOST_PEER_ALIASES, ...(isPreChord ? [] : CHORD_PEER_ALIASES)];
|
|
165
|
+
for (const { specifier, pkg, subpath, optional } of required) {
|
|
165
166
|
const packageDir = findPeerPackageDir(piPackageRoot, pkg, hostManifest?.name);
|
|
166
167
|
const target = packageDir ? resolvePackageSubpath(packageDir, subpath) : undefined;
|
|
168
|
+
// An optional subpath the package does not declare is unreachable, so skip it; a declared but missing file still fails.
|
|
169
|
+
if (optional && packageDir && target === undefined) continue;
|
|
167
170
|
// Native loaders short-circuit resolution, so aliases must retain the real package's dependency scope.
|
|
168
171
|
if (target && fs.existsSync(target)) {
|
|
169
172
|
aliases[specifier] = fs.realpathSync(target);
|
|
@@ -39,6 +39,7 @@ export function buildRunnerChildLaunch(step: RunnerSubagentStep, ctx: RunnerChil
|
|
|
39
39
|
remoteSkillNames: step.skills,
|
|
40
40
|
remoteReads: step.remoteReads,
|
|
41
41
|
parentSessionId: step.parentSessionId,
|
|
42
|
+
parentSessionFile: step.parentSessionFile,
|
|
42
43
|
forkCacheKey: step.context === "fork" ? deriveForkPromptCacheKey(step.parentSessionId) : undefined,
|
|
43
44
|
sessionEnabled: attempt.sessionEnabled,
|
|
44
45
|
sessionDir: attempt.sessionDir,
|
|
@@ -84,6 +84,7 @@ export function runnerHttpDispatcherOptions(timeoutMs: number): {
|
|
|
84
84
|
proxyTunnel: true;
|
|
85
85
|
headersTimeout: number;
|
|
86
86
|
bodyTimeout: number;
|
|
87
|
+
connect: { autoSelectFamilyAttemptTimeout: number };
|
|
87
88
|
} {
|
|
88
89
|
return {
|
|
89
90
|
allowH2: false,
|
|
@@ -91,6 +92,8 @@ export function runnerHttpDispatcherOptions(timeoutMs: number): {
|
|
|
91
92
|
proxyTunnel: true,
|
|
92
93
|
headersTimeout: timeoutMs,
|
|
93
94
|
bodyTimeout: timeoutMs,
|
|
95
|
+
// Match Pi's dispatcher: Node's 250ms default ends valid connection attempts on high-latency routes.
|
|
96
|
+
connect: { autoSelectFamilyAttemptTimeout: 2_000 },
|
|
94
97
|
};
|
|
95
98
|
}
|
|
96
99
|
|