@ashx-j/lunr-dev 0.2.40-dev.55.1 → 0.2.40-dev.59.1
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/dist/builtin-extensions/lunr-browser.d.ts +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/attempt-usage.d.ts +5 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/attempt-usage.js +31 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/child-stream.d.ts +65 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/child-stream.js +456 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-group-status.d.ts +42 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-group-status.js +79 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-log.d.ts +18 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-log.js +43 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-event-log.d.ts +3 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-event-log.js +70 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-single-step.d.ts +92 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-single-step.js +491 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-status.d.ts +64 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-status.js +26 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts +1 -115
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +17 -1160
- package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/startup-ui.js +1 -1
- package/dist/core/agent-session.js +1 -1
- package/dist/core/credential-files.d.ts +3 -2
- package/dist/core/credential-files.js +10 -4
- package/dist/core/export-html/index.js +1 -1
- package/dist/core/export-html/tool-renderer.d.ts +1 -1
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/extensions/types.d.ts +1 -1
- package/dist/core/permissions.d.ts +6 -0
- package/dist/core/permissions.js +6 -0
- package/dist/core/resource-loader.d.ts +1 -1
- package/dist/core/resource-loader.js +1 -1
- package/dist/{modes/interactive → core}/theme/theme.d.ts +1 -1
- package/dist/{modes/interactive → core}/theme/theme.js +4 -4
- package/dist/core/tool-call-hooks.js +3 -2
- package/dist/gateway/agent-bridge.js +1 -1
- package/dist/gateway/setup.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/main.js +1 -1
- package/dist/modes/interactive/chat-history.js +1 -1
- package/dist/modes/interactive/components/assistant-message.js +1 -1
- package/dist/modes/interactive/components/bash-execution.js +1 -1
- package/dist/modes/interactive/components/boot-screen.js +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +1 -1
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/context-view.js +1 -1
- package/dist/modes/interactive/components/copyable-text.js +1 -1
- package/dist/modes/interactive/components/custom-entry.js +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -1
- package/dist/modes/interactive/components/diff.js +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +1 -1
- package/dist/modes/interactive/components/extension-editor.js +1 -1
- package/dist/modes/interactive/components/extension-input.js +1 -1
- package/dist/modes/interactive/components/extension-selector.js +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/injected-prompt-message.js +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +1 -1
- package/dist/modes/interactive/components/login-dialog.js +1 -1
- package/dist/modes/interactive/components/model-selector.js +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +1 -1
- package/dist/modes/interactive/components/onboarding.js +1 -1
- package/dist/modes/interactive/components/plan-message.js +1 -1
- package/dist/modes/interactive/components/processes-selector.js +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
- package/dist/modes/interactive/components/session-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +1 -1
- package/dist/modes/interactive/components/status-indicator.js +1 -1
- package/dist/modes/interactive/components/theme-selector.js +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/dist/modes/interactive/components/thinking-tail.js +1 -1
- package/dist/modes/interactive/components/tool-execution.js +1 -1
- package/dist/modes/interactive/components/tree-selector.js +1 -1
- package/dist/modes/interactive/components/trust-selector.js +1 -1
- package/dist/modes/interactive/components/usage-view.js +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +1 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/extension-dialogs.d.ts +1 -1
- package/dist/modes/interactive/extension-dialogs.js +1 -1
- package/dist/modes/interactive/extension-widgets.d.ts +1 -1
- package/dist/modes/interactive/extension-widgets.js +1 -1
- package/dist/modes/interactive/help-commands.js +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -1
- package/dist/modes/interactive/loaded-resources.js +1 -1
- package/dist/modes/interactive/login-flow.js +1 -1
- package/dist/modes/interactive/session-exit.js +1 -1
- package/dist/modes/interactive/session-naming.js +1 -1
- package/dist/modes/interactive/settings-screen.js +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +1 -1
- package/dist/modes/interactive/tool-renderers/bash.js +1 -1
- package/dist/modes/interactive/tool-renderers/read.js +1 -1
- package/dist/modes/interactive/tool-renderers/render-utils.d.ts +1 -1
- package/dist/modes/interactive/tool-renderers/write.js +1 -1
- package/dist/modes/interactive/usage-commands.js +1 -1
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/node-runtime/{acp-mode-CFYSYACH.js → acp-mode-5KZPFZBO.js} +2 -2
- package/dist/node-runtime/{agent-session-services-3ZHQJIKF.js → agent-session-services-UOVUJAX2.js} +8 -8
- package/dist/node-runtime/{builtin-extensions-YJ7F6GND.js → builtin-extensions-JNJRND4E.js} +3 -3
- package/dist/node-runtime/{chunk-GPNTGRL2.js → chunk-3RR3PVJB.js} +2 -2
- package/dist/node-runtime/{chunk-HVXDYQNN.js → chunk-6DVUDNS7.js} +2 -2
- package/dist/node-runtime/{chunk-5F7VOA34.js → chunk-AW6PDL4D.js} +1 -1
- package/dist/node-runtime/{chunk-VP2H4TI5.js → chunk-BJIF7GMV.js} +3 -3
- package/dist/node-runtime/{chunk-5HVA5ECB.js → chunk-BQROL43X.js} +17 -17
- package/dist/node-runtime/{chunk-BNNBTBXY.js → chunk-EJMB4PAV.js} +3 -3
- package/dist/node-runtime/{chunk-G3PARFR4.js → chunk-FCINT2KC.js} +7 -7
- package/dist/node-runtime/{chunk-KURXPCGO.js → chunk-FNS42TPZ.js} +3 -3
- package/dist/node-runtime/{chunk-N574FRFF.js → chunk-GAWWLIGY.js} +3 -3
- package/dist/node-runtime/{chunk-27QDDTTV.js → chunk-HYOPEHDE.js} +2 -2
- package/dist/node-runtime/{chunk-5JVP2JX4.js → chunk-JARNU4J4.js} +3 -3
- package/dist/node-runtime/{chunk-ITHKNPG4.js → chunk-JZK2WJ7U.js} +1 -1
- package/dist/node-runtime/{chunk-PLBYKAZC.js → chunk-KETNCBTB.js} +2 -2
- package/dist/node-runtime/{chunk-KTCZH72R.js → chunk-LGRRFSE7.js} +3 -2
- package/dist/node-runtime/{chunk-OXFD2OMR.js → chunk-LY6VVOF4.js} +3 -3
- package/dist/node-runtime/{chunk-DJB7P2V7.js → chunk-MEDBJXCC.js} +1 -1
- package/dist/node-runtime/{chunk-SV42POA3.js → chunk-PGWSMQ4K.js} +1 -1
- package/dist/node-runtime/{chunk-7LCR56AK.js → chunk-QDQAKIVU.js} +1 -1
- package/dist/node-runtime/{chunk-GNT2AURO.js → chunk-QP4I6GEW.js} +1 -1
- package/dist/node-runtime/{chunk-YDMZHLBV.js → chunk-QX5I7QEW.js} +1 -1
- package/dist/node-runtime/{chunk-BNZXW77G.js → chunk-RXDLSXEC.js} +1 -1
- package/dist/node-runtime/{chunk-U2LTTIWZ.js → chunk-RXG6DWO2.js} +1 -1
- package/dist/node-runtime/{chunk-ITVBE3HR.js → chunk-S46QLY2F.js} +10 -9
- package/dist/node-runtime/{chunk-CDILDA4F.js → chunk-U7MTVVT3.js} +2 -2
- package/dist/node-runtime/{chunk-MNYG5WLT.js → chunk-WBLSU6YV.js} +3 -3
- package/dist/node-runtime/{chunk-7LNPTBQJ.js → chunk-XPKOWSYN.js} +6 -2
- package/dist/node-runtime/{chunk-4ZEDT3YW.js → chunk-XXGJ7Z3C.js} +11 -11
- package/dist/node-runtime/{chunk-3UQ7ZNLI.js → chunk-Y7DFMHY5.js} +8 -8
- package/dist/node-runtime/{chunk-2ZI6Q6JG.js → chunk-YFXGOLZ6.js} +1 -1
- package/dist/node-runtime/cli-runtime.js +1 -1
- package/dist/node-runtime/{command-H52R5R2G.js → command-6GJNLXGD.js} +3 -3
- package/dist/node-runtime/{commands-CV2JUYHM.js → commands-2UG5F4VT.js} +6 -6
- package/dist/node-runtime/{commands-7EETGZ7V.js → commands-GSZWAQJW.js} +5 -5
- package/dist/node-runtime/{direct-tool-executor-DNZ2MS6Z.js → direct-tool-executor-WJLVHH7U.js} +6 -6
- package/dist/node-runtime/{export-html-7TEMZLK2.js → export-html-SW3CIZRJ.js} +1 -1
- package/dist/node-runtime/{extension-input-MNEKUZDZ.js → extension-input-DFQ76UJG.js} +4 -4
- package/dist/node-runtime/{extension-selector-6WJHCCQI.js → extension-selector-MWHCRWHQ.js} +4 -4
- package/dist/node-runtime/{gateway-OHPDCOOB.js → gateway-UDWVYEGX.js} +8 -8
- package/dist/node-runtime/{goal-PJ2NLX6M.js → goal-CVGA3XFI.js} +1 -1
- package/dist/node-runtime/index.js +22 -22
- package/dist/node-runtime/{init-G23PFPKF.js → init-P3RQ6EFK.js} +5 -5
- package/dist/node-runtime/{install-cli-4LUSDUPO.js → install-cli-YIIFVCFM.js} +1 -1
- package/dist/node-runtime/{interactive-mode-7GX3UJFX.js → interactive-mode-VCPSTUAW.js} +16 -16
- package/dist/node-runtime/{interactive-view-TUYWWEUV.js → interactive-view-GDP6M6UP.js} +6 -6
- package/dist/node-runtime/{lunr-cron-SV2EXYKV.js → lunr-cron-3VI5CLK3.js} +6 -6
- package/dist/node-runtime/main.js +17 -17
- package/dist/node-runtime/{mobile-commands-JQJU35OT.js → mobile-commands-HQXEYAF6.js} +5 -5
- package/dist/node-runtime/{package-manager-cli-FICMQY2Q.js → package-manager-cli-B6G22R6O.js} +9 -9
- package/dist/node-runtime/{pi-mcp-adapter-NKAL5CFR.js → pi-mcp-adapter-2OP5BBC6.js} +8 -8
- package/dist/node-runtime/{pi-prompt-template-model-63LFES2U.js → pi-prompt-template-model-UL2T2HLL.js} +2 -2
- package/dist/node-runtime/{pi-subagents-WS6OU5MG.js → pi-subagents-YVVMY4B4.js} +8 -8
- package/dist/node-runtime/{print-mode-Y363FXY4.js → print-mode-M52NLHKG.js} +9 -9
- package/dist/node-runtime/{proxy-modes-EEYRUGQL.js → proxy-modes-RD2PQ6UH.js} +6 -6
- package/dist/node-runtime/rpc-entry.js +17 -17
- package/dist/node-runtime/{rpc-mode-ENVT7AXW.js → rpc-mode-WAHP6U73.js} +4 -4
- package/dist/node-runtime/{session-selector-AF6V7DP6.js → session-selector-JABBEHK5.js} +4 -4
- package/dist/node-runtime/{setup-OHLYSWTW.js → setup-7IC2PQIB.js} +6 -6
- package/dist/node-runtime/{src-Y3S2FIS5.js → src-J6FSKIFT.js} +1 -1
- package/dist/node-runtime/{subagent-executor-LPVOWPMG.js → subagent-executor-RTGKJ35C.js} +5 -5
- package/dist/node-runtime/{theme-AY3J7JHP.js → theme-MVESIOLX.js} +1 -1
- package/dist/node-runtime/{tool-renderers-4RDKHPPB.js → tool-renderers-KL5EPAMN.js} +3 -3
- package/dist/startup/interactive-view.js +1 -1
- package/install-lock/package-lock.json +24 -24
- package/install-lock/package.json +2 -2
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Status, events and progress files for a parallel group in an async run: setup failure, start, task prep and the worktree summary.
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { writeAtomicJson } from "../../shared/atomic-json.js";
|
|
4
|
+
import { diffWorktrees, formatWorktreeDiffSummary } from "../shared/worktree.js";
|
|
5
|
+
import { writeInitialProgressFile } from "../../shared/settings.js";
|
|
6
|
+
import { appendJsonl } from "./runner-event-log.js";
|
|
7
|
+
export function markParallelGroupSetupFailure(input) {
|
|
8
|
+
for (let taskIndex = 0; taskIndex < input.group.parallel.length; taskIndex++) {
|
|
9
|
+
const flatTaskIndex = input.groupStartFlatIndex + taskIndex;
|
|
10
|
+
input.statusPayload.steps[flatTaskIndex].status = "failed";
|
|
11
|
+
input.statusPayload.steps[flatTaskIndex].startedAt = input.failedAt;
|
|
12
|
+
input.statusPayload.steps[flatTaskIndex].endedAt = input.failedAt;
|
|
13
|
+
input.statusPayload.steps[flatTaskIndex].durationMs = 0;
|
|
14
|
+
input.statusPayload.steps[flatTaskIndex].exitCode = 1;
|
|
15
|
+
input.results.push({ agent: input.group.parallel[taskIndex].agent, output: input.setupError, success: false, exitCode: 1, sessionFile: input.group.parallel[taskIndex].sessionFile });
|
|
16
|
+
}
|
|
17
|
+
input.statusPayload.currentStep = input.groupStartFlatIndex;
|
|
18
|
+
input.statusPayload.lastUpdate = input.failedAt;
|
|
19
|
+
input.statusPayload.outputFile = path.join(input.asyncDir, `output-${input.groupStartFlatIndex}.log`);
|
|
20
|
+
writeAtomicJson(input.statusPath, input.statusPayload);
|
|
21
|
+
appendJsonl(input.eventsPath, JSON.stringify({
|
|
22
|
+
type: "subagent.parallel.completed",
|
|
23
|
+
ts: input.failedAt,
|
|
24
|
+
runId: input.runId,
|
|
25
|
+
stepIndex: input.stepIndex,
|
|
26
|
+
success: false,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
export function markParallelGroupRunning(input) {
|
|
30
|
+
for (let taskIndex = 0; taskIndex < input.group.parallel.length; taskIndex++) {
|
|
31
|
+
const flatTaskIndex = input.groupStartFlatIndex + taskIndex;
|
|
32
|
+
input.statusPayload.steps[flatTaskIndex].status = "pending";
|
|
33
|
+
input.statusPayload.steps[flatTaskIndex].startedAt = undefined;
|
|
34
|
+
input.statusPayload.steps[flatTaskIndex].endedAt = undefined;
|
|
35
|
+
input.statusPayload.steps[flatTaskIndex].durationMs = undefined;
|
|
36
|
+
input.statusPayload.steps[flatTaskIndex].lastActivityAt = undefined;
|
|
37
|
+
input.statusPayload.steps[flatTaskIndex].activityState = undefined;
|
|
38
|
+
input.statusPayload.steps[flatTaskIndex].error = undefined;
|
|
39
|
+
}
|
|
40
|
+
input.statusPayload.currentStep = input.groupStartFlatIndex;
|
|
41
|
+
input.statusPayload.activityState = undefined;
|
|
42
|
+
input.statusPayload.lastActivityAt = input.groupStartTime;
|
|
43
|
+
input.statusPayload.lastUpdate = input.groupStartTime;
|
|
44
|
+
input.statusPayload.outputFile = path.join(input.asyncDir, `output-${input.groupStartFlatIndex}.log`);
|
|
45
|
+
writeAtomicJson(input.statusPath, input.statusPayload);
|
|
46
|
+
appendJsonl(input.eventsPath, JSON.stringify({
|
|
47
|
+
type: "subagent.parallel.started",
|
|
48
|
+
ts: input.groupStartTime,
|
|
49
|
+
runId: input.runId,
|
|
50
|
+
stepIndex: input.stepIndex,
|
|
51
|
+
agents: input.group.parallel.map((task) => task.agent),
|
|
52
|
+
count: input.group.parallel.length,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
export function prepareParallelTaskRun(task, cwd, worktreeSetup, taskIndex) {
|
|
56
|
+
if (!worktreeSetup)
|
|
57
|
+
return { taskForRun: task, taskCwd: cwd };
|
|
58
|
+
return {
|
|
59
|
+
taskForRun: { ...task, cwd: undefined },
|
|
60
|
+
taskCwd: worktreeSetup.worktrees[taskIndex].agentCwd,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function appendParallelWorktreeSummary(previousOutput, worktreeSetup, asyncDir, stepIndex, group) {
|
|
64
|
+
if (!worktreeSetup)
|
|
65
|
+
return previousOutput;
|
|
66
|
+
const diffsDir = path.join(asyncDir, "worktree-diffs", `step-${stepIndex}`);
|
|
67
|
+
const diffs = diffWorktrees(worktreeSetup, group.parallel.map((task) => task.agent), diffsDir);
|
|
68
|
+
const diffSummary = formatWorktreeDiffSummary(diffs);
|
|
69
|
+
if (!diffSummary)
|
|
70
|
+
return previousOutput;
|
|
71
|
+
return `${previousOutput}\n\n${diffSummary}`;
|
|
72
|
+
}
|
|
73
|
+
export function ensureParallelProgressFile(cwd, group) {
|
|
74
|
+
const progressPath = path.join(cwd, "progress.md");
|
|
75
|
+
if (!group.parallel.some((task) => task.task.includes(`Update progress at: ${progressPath}`)))
|
|
76
|
+
return;
|
|
77
|
+
writeInitialProgressFile(cwd);
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=parallel-group-status.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SubagentRunMode } from "../../shared/types.ts";
|
|
2
|
+
export declare function writeRunLog(logPath: string, input: {
|
|
3
|
+
id: string;
|
|
4
|
+
mode: SubagentRunMode;
|
|
5
|
+
cwd: string;
|
|
6
|
+
startedAt: number;
|
|
7
|
+
endedAt: number;
|
|
8
|
+
steps: Array<{
|
|
9
|
+
agent: string;
|
|
10
|
+
status: string;
|
|
11
|
+
durationMs?: number;
|
|
12
|
+
}>;
|
|
13
|
+
summary: string;
|
|
14
|
+
truncated: boolean;
|
|
15
|
+
artifactsDir?: string;
|
|
16
|
+
sessionFile?: string;
|
|
17
|
+
}): void;
|
|
18
|
+
//# sourceMappingURL=run-log.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// The markdown run log an async run writes when it finishes.
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
function formatDuration(ms) {
|
|
4
|
+
if (ms < 1000)
|
|
5
|
+
return `${ms}ms`;
|
|
6
|
+
if (ms < 60000)
|
|
7
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
8
|
+
const minutes = Math.floor(ms / 60000);
|
|
9
|
+
const seconds = Math.floor((ms % 60000) / 1000);
|
|
10
|
+
return `${minutes}m${seconds}s`;
|
|
11
|
+
}
|
|
12
|
+
export function writeRunLog(logPath, input) {
|
|
13
|
+
const lines = [];
|
|
14
|
+
lines.push(`# Subagent run ${input.id}`);
|
|
15
|
+
lines.push("");
|
|
16
|
+
lines.push(`- **Mode:** ${input.mode}`);
|
|
17
|
+
lines.push(`- **CWD:** ${input.cwd}`);
|
|
18
|
+
lines.push(`- **Started:** ${new Date(input.startedAt).toISOString()}`);
|
|
19
|
+
lines.push(`- **Ended:** ${new Date(input.endedAt).toISOString()}`);
|
|
20
|
+
lines.push(`- **Duration:** ${formatDuration(input.endedAt - input.startedAt)}`);
|
|
21
|
+
if (input.sessionFile)
|
|
22
|
+
lines.push(`- **Session:** ${input.sessionFile}`);
|
|
23
|
+
if (input.artifactsDir)
|
|
24
|
+
lines.push(`- **Artifacts:** ${input.artifactsDir}`);
|
|
25
|
+
lines.push("");
|
|
26
|
+
lines.push("## Steps");
|
|
27
|
+
lines.push("| Step | Agent | Status | Duration |");
|
|
28
|
+
lines.push("| --- | --- | --- | --- |");
|
|
29
|
+
input.steps.forEach((step, i) => {
|
|
30
|
+
const duration = step.durationMs !== undefined ? formatDuration(step.durationMs) : "-";
|
|
31
|
+
lines.push(`| ${i + 1} | ${step.agent} | ${step.status} | ${duration} |`);
|
|
32
|
+
});
|
|
33
|
+
lines.push("");
|
|
34
|
+
lines.push("## Summary");
|
|
35
|
+
if (input.truncated) {
|
|
36
|
+
lines.push("_Output truncated_");
|
|
37
|
+
lines.push("");
|
|
38
|
+
}
|
|
39
|
+
lines.push(input.summary.trim() || "(no output)");
|
|
40
|
+
lines.push("");
|
|
41
|
+
fs.writeFileSync(logPath, lines.join("\n"), "utf-8");
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=run-log.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// The async run's events.jsonl writer, with the byte cap that stops diagnostic events and leaves one truncation marker.
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import { appendJsonl as appendRawJsonl } from "../../shared/artifacts.js";
|
|
4
|
+
const DEFAULT_MAX_ASYNC_EVENTS_BYTES = 50 * 1024 * 1024;
|
|
5
|
+
const ASYNC_EVENTS_MAX_BYTES_ENV = "PI_SUBAGENT_ASYNC_EVENTS_MAX_BYTES";
|
|
6
|
+
const TRUNCATED_EVENT_TYPE = "subagent.events.truncated";
|
|
7
|
+
const TRUNCATION_MARKER_RESERVE_BYTES = 512;
|
|
8
|
+
const asyncEventLogStates = new Map();
|
|
9
|
+
function maxAsyncEventsBytes() {
|
|
10
|
+
const raw = process.env[ASYNC_EVENTS_MAX_BYTES_ENV];
|
|
11
|
+
if (!raw)
|
|
12
|
+
return DEFAULT_MAX_ASYNC_EVENTS_BYTES;
|
|
13
|
+
const parsed = Number(raw);
|
|
14
|
+
if (!Number.isFinite(parsed) || parsed < 0)
|
|
15
|
+
return DEFAULT_MAX_ASYNC_EVENTS_BYTES;
|
|
16
|
+
return Math.floor(parsed);
|
|
17
|
+
}
|
|
18
|
+
function eventLogState(filePath) {
|
|
19
|
+
let state = asyncEventLogStates.get(filePath);
|
|
20
|
+
if (state)
|
|
21
|
+
return state;
|
|
22
|
+
let bytes = 0;
|
|
23
|
+
try {
|
|
24
|
+
bytes = fs.statSync(filePath).size;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error.code !== "ENOENT") {
|
|
28
|
+
// Diagnostic event accounting is best-effort; writes below are also safe.
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
state = { bytes, diagnosticsTruncated: false };
|
|
32
|
+
asyncEventLogStates.set(filePath, state);
|
|
33
|
+
return state;
|
|
34
|
+
}
|
|
35
|
+
export function appendJsonl(filePath, line) {
|
|
36
|
+
try {
|
|
37
|
+
appendRawJsonl(filePath, line);
|
|
38
|
+
const state = asyncEventLogStates.get(filePath);
|
|
39
|
+
if (state)
|
|
40
|
+
state.bytes += Buffer.byteLength(`${line}\n`, "utf-8");
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Async event logging is diagnostic and must not fail the run.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function appendDiagnosticJsonl(filePath, line, droppedEventType) {
|
|
47
|
+
if (!line.trim())
|
|
48
|
+
return;
|
|
49
|
+
const state = eventLogState(filePath);
|
|
50
|
+
if (state.diagnosticsTruncated)
|
|
51
|
+
return;
|
|
52
|
+
const maxBytes = maxAsyncEventsBytes();
|
|
53
|
+
const chunkBytes = Buffer.byteLength(`${line}\n`, "utf-8");
|
|
54
|
+
const diagnosticBudget = Math.max(0, maxBytes - TRUNCATION_MARKER_RESERVE_BYTES);
|
|
55
|
+
if (state.bytes + chunkBytes <= diagnosticBudget) {
|
|
56
|
+
appendJsonl(filePath, line);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const marker = JSON.stringify({
|
|
60
|
+
type: TRUNCATED_EVENT_TYPE,
|
|
61
|
+
ts: Date.now(),
|
|
62
|
+
maxBytes,
|
|
63
|
+
droppedEventType,
|
|
64
|
+
});
|
|
65
|
+
if (state.bytes + Buffer.byteLength(`${marker}\n`, "utf-8") <= maxBytes) {
|
|
66
|
+
appendJsonl(filePath, marker);
|
|
67
|
+
}
|
|
68
|
+
state.diagnosticsTruncated = true;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=runner-event-log.js.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { ChainOutputMap, ArtifactConfig, TurnBudgetState, ResolvedTurnBudget, NestedRouteInfo, ModelAttempt, ArtifactPaths, ToolBudgetState, Usage, CostSummary } from "../../shared/types.ts";
|
|
2
|
+
import type { BuiltRunnerSubagentStep as SubagentStep } from "../shared/parallel-utils.ts";
|
|
3
|
+
import type { ProtocolOutputLimit } from "../shared/child-protocol.ts";
|
|
4
|
+
import { type ChildWatchdogStateSnapshot } from "../../watchdog/child-status.ts";
|
|
5
|
+
import { type ChildEvent } from "./child-stream.ts";
|
|
6
|
+
/** Context for running a single step */
|
|
7
|
+
interface SingleStepContext {
|
|
8
|
+
supervisorSessionId?: string;
|
|
9
|
+
previousOutput: string;
|
|
10
|
+
handoffToNext?: boolean;
|
|
11
|
+
outputs?: ChainOutputMap;
|
|
12
|
+
placeholder: string;
|
|
13
|
+
cwd: string;
|
|
14
|
+
sessionCwd?: string;
|
|
15
|
+
sessionEnabled: boolean;
|
|
16
|
+
sessionDir?: string;
|
|
17
|
+
artifactsDir?: string;
|
|
18
|
+
artifactConfig?: Partial<ArtifactConfig>;
|
|
19
|
+
id: string;
|
|
20
|
+
flatIndex: number;
|
|
21
|
+
flatStepCount: number;
|
|
22
|
+
outputFile: string;
|
|
23
|
+
steerInboxDir?: string;
|
|
24
|
+
steerCapabilityPath?: string;
|
|
25
|
+
steerAckDir?: string;
|
|
26
|
+
transcriptPath?: string;
|
|
27
|
+
piPackageRoot?: string;
|
|
28
|
+
piArgv1?: string;
|
|
29
|
+
registerInterrupt?: (interrupt: (() => void) | undefined) => void;
|
|
30
|
+
registerTimeout?: (interrupt: (() => void) | undefined) => void;
|
|
31
|
+
registerStop?: (stop: (() => void) | undefined) => void;
|
|
32
|
+
registerTurnBudgetAbort?: (abort: ((message: string, state?: TurnBudgetState) => void) | undefined) => void;
|
|
33
|
+
timeoutSignal?: AbortSignal;
|
|
34
|
+
stopSignal?: AbortSignal;
|
|
35
|
+
timeoutMessage?: string;
|
|
36
|
+
stopMessage?: string;
|
|
37
|
+
turnBudget?: ResolvedTurnBudget;
|
|
38
|
+
childIntercomTarget?: string;
|
|
39
|
+
orchestratorIntercomTarget?: string;
|
|
40
|
+
nestedRoute?: NestedRouteInfo;
|
|
41
|
+
onAttemptStart?: (attempt: {
|
|
42
|
+
model?: string;
|
|
43
|
+
thinking?: string;
|
|
44
|
+
}) => void;
|
|
45
|
+
onChildEvent?: (event: ChildEvent) => void;
|
|
46
|
+
onWriterProcess?: (writer: {
|
|
47
|
+
state: "none" | "spawning";
|
|
48
|
+
} | {
|
|
49
|
+
state: "running";
|
|
50
|
+
pid: number;
|
|
51
|
+
}) => void;
|
|
52
|
+
skipAcceptance?: () => boolean;
|
|
53
|
+
}
|
|
54
|
+
/** Run a single pi agent step, returning output and metadata */
|
|
55
|
+
export declare function runSingleStep(step: SubagentStep, ctx: SingleStepContext): Promise<{
|
|
56
|
+
childId?: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
permissions?: "full" | "read-only";
|
|
59
|
+
agent: string;
|
|
60
|
+
output: string;
|
|
61
|
+
exitCode: number | null;
|
|
62
|
+
error?: string;
|
|
63
|
+
protocolError?: ProtocolOutputLimit;
|
|
64
|
+
model?: string;
|
|
65
|
+
attemptedModels?: string[];
|
|
66
|
+
modelAttempts?: ModelAttempt[];
|
|
67
|
+
artifactPaths?: ArtifactPaths;
|
|
68
|
+
transcriptPath?: string;
|
|
69
|
+
transcriptError?: string;
|
|
70
|
+
interrupted?: boolean;
|
|
71
|
+
timedOut?: boolean;
|
|
72
|
+
stopped?: boolean;
|
|
73
|
+
turnBudget?: TurnBudgetState;
|
|
74
|
+
turnBudgetExceeded?: boolean;
|
|
75
|
+
wrapUpRequested?: boolean;
|
|
76
|
+
toolBudget?: ToolBudgetState;
|
|
77
|
+
toolBudgetBlocked?: boolean;
|
|
78
|
+
sessionFile?: string;
|
|
79
|
+
receiptUsage?: Usage;
|
|
80
|
+
usageRequests?: import("../../../../../core/usage-accounting.ts").AccountedRequest[];
|
|
81
|
+
intercomTarget?: string;
|
|
82
|
+
totalCost?: CostSummary;
|
|
83
|
+
completionGuardTriggered?: boolean;
|
|
84
|
+
structuredOutput?: unknown;
|
|
85
|
+
structuredOutputPath?: string;
|
|
86
|
+
structuredOutputSchemaPath?: string;
|
|
87
|
+
acceptance?: import("../../shared/types.ts").AcceptanceLedger;
|
|
88
|
+
watchdog?: ChildWatchdogStateSnapshot;
|
|
89
|
+
}>;
|
|
90
|
+
export declare function combinedAbortSignal(signals: Array<AbortSignal | undefined>): AbortSignal | undefined;
|
|
91
|
+
export {};
|
|
92
|
+
//# sourceMappingURL=runner-single-step.d.ts.map
|