@ashx-j/lunr-dev 0.2.40-dev.54.2 → 0.2.40-dev.58.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/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/runs/foreground/async-run-control.d.ts +19 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-run-control.js +331 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution-input.d.ts +37 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution-input.js +321 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/executor-types.d.ts +124 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/executor-types.js +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/foreground-notifications.d.ts +17 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/foreground-notifications.js +98 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/foreground-run-registry.d.ts +40 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/foreground-run-registry.js +172 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/fork-policy.d.ts +14 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/fork-policy.js +161 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/nested-run-control.d.ts +46 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/nested-run-control.js +195 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/parallel-run.d.ts +10 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/parallel-run.js +537 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts +5 -81
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +26 -1763
- package/dist/builtin-extensions/pi-subagents/src/shared/settings.d.ts +1 -1
- package/dist/core/credential-files.d.ts +3 -2
- package/dist/core/credential-files.js +10 -4
- package/dist/core/permissions.d.ts +6 -0
- package/dist/core/permissions.js +6 -0
- package/dist/core/tool-call-hooks.js +3 -2
- 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-KH5CIGC3.js} +5 -5
- package/dist/node-runtime/{builtin-extensions-VQHK3YKF.js → builtin-extensions-RZS4SMIS.js} +3 -3
- package/dist/node-runtime/{chunk-UZMXBZQT.js → chunk-AKQRASEH.js} +9 -9
- package/dist/node-runtime/{chunk-4ZEDT3YW.js → chunk-BJXBM6KD.js} +3 -3
- package/dist/node-runtime/{chunk-BNNBTBXY.js → chunk-EJMB4PAV.js} +3 -3
- package/dist/node-runtime/{chunk-HVXDYQNN.js → chunk-JI7AUY2T.js} +1 -1
- package/dist/node-runtime/{chunk-ITVBE3HR.js → chunk-JJTHGEUS.js} +5 -4
- package/dist/node-runtime/{chunk-YDY7A2WB.js → chunk-K24P7GMM.js} +7 -7
- package/dist/node-runtime/{chunk-KTCZH72R.js → chunk-LGRRFSE7.js} +3 -2
- package/dist/node-runtime/{chunk-7LCR56AK.js → chunk-NWYFKXP5.js} +1 -1
- package/dist/node-runtime/{chunk-SV42POA3.js → chunk-PGWSMQ4K.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-N574FRFF.js → chunk-TSZESZ6H.js} +2 -2
- package/dist/node-runtime/{chunk-VIYDTWDK.js → chunk-U7MTVVT3.js} +606 -604
- package/dist/node-runtime/{chunk-MFDTF25H.js → chunk-UTZCCNFC.js} +5 -5
- package/dist/node-runtime/{chunk-U2LTTIWZ.js → chunk-WYJUGRVE.js} +1 -1
- package/dist/node-runtime/{chunk-7LNPTBQJ.js → chunk-XPKOWSYN.js} +6 -2
- package/dist/node-runtime/{chunk-2ZI6Q6JG.js → chunk-YFXGOLZ6.js} +1 -1
- package/dist/node-runtime/{command-SRDEBPUR.js → command-6S6C62CX.js} +1 -1
- package/dist/node-runtime/{commands-7EETGZ7V.js → commands-GSZWAQJW.js} +5 -5
- package/dist/node-runtime/{commands-CV2JUYHM.js → commands-MM2TPV5I.js} +4 -4
- package/dist/node-runtime/{direct-tool-executor-DNZ2MS6Z.js → direct-tool-executor-WJLVHH7U.js} +6 -6
- package/dist/node-runtime/{gateway-AMEMDTUT.js → gateway-CWIWPUVC.js} +6 -6
- package/dist/node-runtime/index.js +10 -10
- package/dist/node-runtime/{init-G23PFPKF.js → init-P3RQ6EFK.js} +5 -5
- package/dist/node-runtime/{interactive-mode-7GX3UJFX.js → interactive-mode-2L5JMVKQ.js} +6 -6
- package/dist/node-runtime/{lunr-cron-OMQBN3UK.js → lunr-cron-LT3O64NO.js} +4 -4
- package/dist/node-runtime/main.js +7 -7
- package/dist/node-runtime/{mobile-commands-JQJU35OT.js → mobile-commands-PFXEWP2R.js} +3 -3
- package/dist/node-runtime/{pi-mcp-adapter-NKAL5CFR.js → pi-mcp-adapter-2OP5BBC6.js} +8 -8
- package/dist/node-runtime/{pi-subagents-36KOL5SV.js → pi-subagents-G2T5XRAX.js} +6 -6
- package/dist/node-runtime/{print-mode-Y363FXY4.js → print-mode-S6ZUVPMU.js} +6 -6
- package/dist/node-runtime/{proxy-modes-EEYRUGQL.js → proxy-modes-RD2PQ6UH.js} +6 -6
- package/dist/node-runtime/rpc-entry.js +7 -7
- package/dist/node-runtime/{rpc-mode-ENVT7AXW.js → rpc-mode-C33WERBG.js} +3 -3
- package/dist/node-runtime/{src-Y3S2FIS5.js → src-J6FSKIFT.js} +1 -1
- package/dist/node-runtime/{subagent-executor-D42G55F5.js → subagent-executor-RTGKJ35C.js} +1924 -1901
- 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,491 @@
|
|
|
1
|
+
// Runs one async step: an attached async root, or a child with model fallback, acceptance, structured output
|
|
2
|
+
// and the step's output files.
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import { createChildTranscriptWriter } from "../../shared/child-transcript.js";
|
|
6
|
+
import { deliverTimeoutRequest, deliverStopRequest } from "./control-channel.js";
|
|
7
|
+
import { getArtifactPaths, ensureArtifactsDir, writeArtifact } from "../../shared/artifacts.js";
|
|
8
|
+
import { captureSingleOutputSnapshot, resolveSingleOutput, formatSavedOutputReference, extractChildWrittenOutput, finalizeSingleOutput } from "../shared/single-output.js";
|
|
9
|
+
import { buildPiArgs, cleanupTempDir } from "../shared/pi-args.js";
|
|
10
|
+
import { snapshotParentPermissionMode } from "../../../../../core/subagent-permission-inherit.js";
|
|
11
|
+
import { resolveChildExcludeTools } from "../shared/child-tools.js";
|
|
12
|
+
import { resolveOutputReferences, withChainHandoff } from "../shared/chain-outputs.js";
|
|
13
|
+
import { createStructuredOutputRuntime, readStructuredOutput } from "../shared/structured-output.js";
|
|
14
|
+
import { readChildToolDiagnosticError } from "../shared/tool-availability.js";
|
|
15
|
+
import { isRetryableModelFailure, formatModelAttemptNote } from "../shared/model-fallback.js";
|
|
16
|
+
import { readStatus, detectSubagentError, extractTextFromContent } from "../../shared/utils.js";
|
|
17
|
+
import { evaluateCompletionMutationGuard } from "../shared/completion-guard.js";
|
|
18
|
+
import { parseSessionRequests, parseSessionUsage, sessionUsageDelta } from "../../shared/session-tokens.js";
|
|
19
|
+
import { resolveEffectiveThinking } from "../../shared/model-info.js";
|
|
20
|
+
import { formatAcceptancePrompt, stripAcceptanceReport, evaluateAcceptance, buildSkippedAcceptanceLedger, acceptanceFailureMessage } from "../shared/acceptance.js";
|
|
21
|
+
import { waitForImportedAsyncRoot } from "./chain-root-attachment.js";
|
|
22
|
+
import { initialTurnBudgetState, appendTurnBudgetSystemPrompt, turnBudgetState, shouldAbortForTurnBudget, formatTurnBudgetOutput, turnBudgetExceededMessage, turnBudgetSoftNote } from "../shared/turn-budget.js";
|
|
23
|
+
import { initialToolBudgetState, toolBudgetState } from "../shared/tool-budget.js";
|
|
24
|
+
import { resolveWatchdogConfig } from "../../watchdog/settings.js";
|
|
25
|
+
import { resolveChildWatchdogConfig } from "../../watchdog/child-status.js";
|
|
26
|
+
import { costSummaryFromAttempts } from "./attempt-usage.js";
|
|
27
|
+
import { runPiStreaming, isTerminalAssistantStop } from "./child-stream.js";
|
|
28
|
+
function findLatestSessionFile(sessionDir) {
|
|
29
|
+
try {
|
|
30
|
+
const files = fs
|
|
31
|
+
.readdirSync(sessionDir)
|
|
32
|
+
.filter((f) => f.endsWith(".jsonl"))
|
|
33
|
+
.map((f) => path.join(sessionDir, f));
|
|
34
|
+
if (files.length === 0)
|
|
35
|
+
return null;
|
|
36
|
+
files.sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs || b.localeCompare(a));
|
|
37
|
+
return files[0] ?? null;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Session lookup is optional metadata.
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Run a single pi agent step, returning output and metadata */
|
|
45
|
+
export async function runSingleStep(step, ctx) {
|
|
46
|
+
if (step.importAsyncRoot) {
|
|
47
|
+
let importTimedOut = false;
|
|
48
|
+
let importStopped = false;
|
|
49
|
+
ctx.registerTimeout?.(() => {
|
|
50
|
+
importTimedOut = true;
|
|
51
|
+
let pid;
|
|
52
|
+
try {
|
|
53
|
+
pid = readStatus(step.importAsyncRoot.asyncDir)?.pid;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
pid = undefined;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
deliverTimeoutRequest({ asyncDir: step.importAsyncRoot.asyncDir, pid, source: "ancestor-timeout" });
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// The parent runner's own timeout result is authoritative for the attached step.
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
ctx.registerStop?.(() => {
|
|
66
|
+
importStopped = true;
|
|
67
|
+
let pid;
|
|
68
|
+
try {
|
|
69
|
+
pid = readStatus(step.importAsyncRoot.asyncDir)?.pid;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
pid = undefined;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
deliverStopRequest({ asyncDir: step.importAsyncRoot.asyncDir, pid, source: "ancestor-stop" });
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// The parent runner's own stopped result is authoritative for the attached step.
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
try {
|
|
82
|
+
const imported = await waitForImportedAsyncRoot(step.importAsyncRoot, {
|
|
83
|
+
shouldAbort: () => importTimedOut || importStopped || ctx.timeoutSignal?.aborted === true || ctx.stopSignal?.aborted === true || ctx.skipAcceptance?.() === true,
|
|
84
|
+
timeoutMessage: importStopped || ctx.stopSignal?.aborted === true ? ctx.stopMessage : ctx.timeoutMessage,
|
|
85
|
+
});
|
|
86
|
+
try {
|
|
87
|
+
fs.writeFileSync(ctx.outputFile, imported.output, "utf-8");
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Output files are observability only for imported roots.
|
|
91
|
+
}
|
|
92
|
+
const stopped = importStopped || imported.stopped === true || ctx.stopSignal?.aborted === true;
|
|
93
|
+
const timedOut = !stopped && (importTimedOut || imported.timedOut === true || ctx.timeoutSignal?.aborted === true || ctx.skipAcceptance?.() === true);
|
|
94
|
+
const message = stopped ? ctx.stopMessage ?? "Subagent stopped by user." : ctx.timeoutMessage ?? "Subagent timed out.";
|
|
95
|
+
return {
|
|
96
|
+
agent: imported.agent,
|
|
97
|
+
output: timedOut || stopped ? message : imported.output,
|
|
98
|
+
exitCode: timedOut || stopped ? 1 : imported.exitCode,
|
|
99
|
+
error: timedOut || stopped ? message : imported.error,
|
|
100
|
+
timedOut: timedOut ? true : undefined,
|
|
101
|
+
stopped: stopped ? true : undefined,
|
|
102
|
+
sessionFile: imported.sessionFile,
|
|
103
|
+
intercomTarget: imported.intercomTarget,
|
|
104
|
+
model: imported.model,
|
|
105
|
+
attemptedModels: imported.attemptedModels,
|
|
106
|
+
modelAttempts: imported.modelAttempts,
|
|
107
|
+
receiptUsage: imported.usage,
|
|
108
|
+
usageRequests: imported.usageRequests,
|
|
109
|
+
totalCost: imported.totalCost,
|
|
110
|
+
structuredOutput: timedOut || stopped ? undefined : imported.structuredOutput,
|
|
111
|
+
structuredOutputPath: timedOut || stopped ? undefined : imported.structuredOutputPath,
|
|
112
|
+
structuredOutputSchemaPath: timedOut || stopped ? undefined : imported.structuredOutputSchemaPath,
|
|
113
|
+
acceptance: timedOut || stopped ? undefined : imported.acceptance,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
ctx.registerTimeout?.(undefined);
|
|
118
|
+
ctx.registerStop?.(undefined);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const effectiveStructuredOutput = step.structuredOutput ?? (step.structuredOutputSchema
|
|
122
|
+
? createStructuredOutputRuntime(step.structuredOutputSchema, path.join(path.dirname(ctx.outputFile), "structured-output"))
|
|
123
|
+
: undefined);
|
|
124
|
+
const placeholderRegex = new RegExp(ctx.placeholder.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g");
|
|
125
|
+
let task = step.task.replace(placeholderRegex, () => ctx.previousOutput);
|
|
126
|
+
if (ctx.outputs)
|
|
127
|
+
task = resolveOutputReferences(task, ctx.outputs);
|
|
128
|
+
const taskForCompletionGuard = step.completionTask ?? task;
|
|
129
|
+
if (step.effectiveAcceptance) {
|
|
130
|
+
const acceptancePrompt = formatAcceptancePrompt(step.effectiveAcceptance);
|
|
131
|
+
if (acceptancePrompt)
|
|
132
|
+
task = `${task}\n${acceptancePrompt}`;
|
|
133
|
+
}
|
|
134
|
+
task = withChainHandoff(task, ctx.handoffToNext === true);
|
|
135
|
+
const sessionEnabled = Boolean(step.sessionFile) || ctx.sessionEnabled;
|
|
136
|
+
const sessionDir = step.sessionFile ? undefined : ctx.sessionDir;
|
|
137
|
+
let artifactPaths;
|
|
138
|
+
let transcriptWriter;
|
|
139
|
+
if (ctx.artifactsDir && ctx.artifactConfig?.enabled !== false) {
|
|
140
|
+
const index = ctx.flatStepCount > 1 ? ctx.flatIndex : undefined;
|
|
141
|
+
artifactPaths = getArtifactPaths(ctx.artifactsDir, ctx.id, step.agent, index);
|
|
142
|
+
ensureArtifactsDir(ctx.artifactsDir);
|
|
143
|
+
if (ctx.artifactConfig?.includeInput !== false) {
|
|
144
|
+
writeArtifact(artifactPaths.inputPath, `# Task for ${step.agent}\n\n${task}`);
|
|
145
|
+
}
|
|
146
|
+
if (ctx.artifactConfig?.includeTranscript !== false) {
|
|
147
|
+
transcriptWriter = createChildTranscriptWriter({
|
|
148
|
+
transcriptPath: artifactPaths.transcriptPath,
|
|
149
|
+
source: "async",
|
|
150
|
+
runId: ctx.id,
|
|
151
|
+
agent: step.agent,
|
|
152
|
+
childIndex: ctx.flatIndex,
|
|
153
|
+
cwd: step.cwd ?? ctx.cwd,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
transcriptWriter?.writeInitialUserMessage(task);
|
|
158
|
+
const candidates = step.modelCandidates && step.modelCandidates.length > 0
|
|
159
|
+
? step.modelCandidates
|
|
160
|
+
: step.model
|
|
161
|
+
? [step.model]
|
|
162
|
+
: [undefined];
|
|
163
|
+
const attemptedModels = [];
|
|
164
|
+
const modelAttempts = [];
|
|
165
|
+
const priorRequestIds = new Set(parseSessionRequests(step.sessionFile ?? sessionDir).map((request) => request.id));
|
|
166
|
+
const attemptNotes = [];
|
|
167
|
+
const eventsPath = path.join(path.dirname(ctx.outputFile), "events.jsonl");
|
|
168
|
+
let finalResult;
|
|
169
|
+
let finalOutputSnapshot;
|
|
170
|
+
let completionGuardTriggeredFinal = false;
|
|
171
|
+
let turnBudget = ctx.turnBudget ? initialTurnBudgetState(ctx.turnBudget) : undefined;
|
|
172
|
+
let toolBudget = step.toolBudget ? initialToolBudgetState(step.toolBudget) : undefined;
|
|
173
|
+
let toolBudgetBlocked = false;
|
|
174
|
+
for (let index = 0; index < candidates.length; index++) {
|
|
175
|
+
if (ctx.timeoutSignal?.aborted || ctx.skipAcceptance?.())
|
|
176
|
+
break;
|
|
177
|
+
const candidate = candidates[index];
|
|
178
|
+
ctx.onAttemptStart?.({ model: candidate, thinking: resolveEffectiveThinking(candidate, step.thinking) });
|
|
179
|
+
const outputSnapshot = captureSingleOutputSnapshot(step.outputPath);
|
|
180
|
+
if (effectiveStructuredOutput) {
|
|
181
|
+
try {
|
|
182
|
+
if (fs.existsSync(effectiveStructuredOutput.outputPath))
|
|
183
|
+
fs.unlinkSync(effectiveStructuredOutput.outputPath);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// Missing/stale structured-output files are handled after the child exits.
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const watchdogConfig = resolveWatchdogConfig(step.cwd ?? ctx.cwd);
|
|
190
|
+
const childWatchdog = watchdogConfig.ok
|
|
191
|
+
? resolveChildWatchdogConfig({
|
|
192
|
+
config: watchdogConfig.config,
|
|
193
|
+
agent: step.agent,
|
|
194
|
+
runId: ctx.id,
|
|
195
|
+
childIndex: ctx.flatIndex,
|
|
196
|
+
})
|
|
197
|
+
: undefined;
|
|
198
|
+
const parentPermissionMode = step.parentPermissionMode ?? snapshotParentPermissionMode(step.parentSessionId);
|
|
199
|
+
const childPermission = step.permissions === "read-only" || parentPermissionMode === "read-only" ? "read-only" : "full";
|
|
200
|
+
const excludeTools = resolveChildExcludeTools({
|
|
201
|
+
permissions: childPermission,
|
|
202
|
+
fanoutAuthorized: Array.isArray(step.tools) && step.tools.includes("subagent"),
|
|
203
|
+
});
|
|
204
|
+
const { args, env, tempDir, toolDiagnosticPath } = buildPiArgs({
|
|
205
|
+
parentSessionId: step.parentSessionId,
|
|
206
|
+
supervisorSessionId: ctx.supervisorSessionId,
|
|
207
|
+
baseArgs: ["--mode", "json", "-p"],
|
|
208
|
+
task,
|
|
209
|
+
sessionEnabled,
|
|
210
|
+
sessionDir,
|
|
211
|
+
sessionFile: step.sessionFile,
|
|
212
|
+
model: candidate,
|
|
213
|
+
inheritProjectContext: true,
|
|
214
|
+
inheritSkills: false,
|
|
215
|
+
requireReadTool: Boolean(step.skills?.length),
|
|
216
|
+
excludeTools,
|
|
217
|
+
childPermission,
|
|
218
|
+
childId: step.childId ?? step.agent,
|
|
219
|
+
childDescription: step.description ?? step.agent,
|
|
220
|
+
systemPrompt: appendTurnBudgetSystemPrompt(step.systemPrompt && !step.systemPrompt.includes("You are `") ? step.systemPrompt : "", ctx.turnBudget) || undefined,
|
|
221
|
+
systemPromptMode: "append",
|
|
222
|
+
cwd: step.cwd ?? ctx.cwd,
|
|
223
|
+
promptFileStem: step.childId ?? step.agent,
|
|
224
|
+
intercomSessionName: ctx.childIntercomTarget,
|
|
225
|
+
orchestratorIntercomTarget: ctx.orchestratorIntercomTarget,
|
|
226
|
+
runId: ctx.id,
|
|
227
|
+
childAgentName: step.childId ?? step.agent,
|
|
228
|
+
childIndex: ctx.flatIndex,
|
|
229
|
+
parentEventSink: ctx.nestedRoute?.eventSink,
|
|
230
|
+
parentControlInbox: ctx.nestedRoute?.controlInbox,
|
|
231
|
+
parentRootRunId: ctx.nestedRoute?.rootRunId,
|
|
232
|
+
parentCapabilityToken: ctx.nestedRoute?.capabilityToken,
|
|
233
|
+
steerInboxDir: ctx.steerInboxDir,
|
|
234
|
+
steerCapabilityPath: ctx.steerCapabilityPath,
|
|
235
|
+
steerAckDir: ctx.steerAckDir,
|
|
236
|
+
structuredOutput: effectiveStructuredOutput,
|
|
237
|
+
toolBudget: step.toolBudget,
|
|
238
|
+
childWatchdog,
|
|
239
|
+
waitToolEnabled: step.waitToolEnabled,
|
|
240
|
+
parentPermissionMode,
|
|
241
|
+
parentAutoReview: step.parentAutoReview,
|
|
242
|
+
});
|
|
243
|
+
const usageBeforeAttempt = parseSessionUsage(step.sessionFile ?? sessionDir);
|
|
244
|
+
const run = await runPiStreaming(args, step.cwd ?? ctx.cwd, ctx.outputFile, env, ctx.piPackageRoot, ctx.piArgv1, step.maxSubagentDepth, { eventsPath, runId: ctx.id, stepIndex: ctx.flatIndex, agent: step.agent }, ctx.registerInterrupt, ctx.onChildEvent, transcriptWriter, ctx.registerTimeout, ctx.timeoutMessage, ctx.registerStop, ctx.stopMessage, ctx.registerTurnBudgetAbort, ctx.onWriterProcess);
|
|
245
|
+
const persistedUsage = parseSessionUsage(step.sessionFile ?? sessionDir);
|
|
246
|
+
if (persistedUsage)
|
|
247
|
+
run.usage = sessionUsageDelta(persistedUsage, usageBeforeAttempt);
|
|
248
|
+
if (run.turnBudget)
|
|
249
|
+
turnBudget = run.turnBudget;
|
|
250
|
+
else if (ctx.turnBudget) {
|
|
251
|
+
const assistantMessages = run.messages.filter((message) => message.role === "assistant");
|
|
252
|
+
const turnCount = assistantMessages.length;
|
|
253
|
+
const lastAssistantMessage = assistantMessages.at(-1);
|
|
254
|
+
if (turnCount > 0 && turnCount < ctx.turnBudget.maxTurns) {
|
|
255
|
+
turnBudget = { ...ctx.turnBudget, outcome: "within-budget", turnCount };
|
|
256
|
+
}
|
|
257
|
+
else if (turnCount >= ctx.turnBudget.maxTurns) {
|
|
258
|
+
turnBudget = turnBudgetState(ctx.turnBudget, turnCount, shouldAbortForTurnBudget(ctx.turnBudget, turnCount, lastAssistantMessage ? isTerminalAssistantStop(lastAssistantMessage) : false));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const toolAvailabilityError = run.exitCode === 0 && !run.error
|
|
262
|
+
? readChildToolDiagnosticError(toolDiagnosticPath)
|
|
263
|
+
: undefined;
|
|
264
|
+
cleanupTempDir(tempDir);
|
|
265
|
+
const hiddenError = run.exitCode === 0 && !run.error && !toolAvailabilityError ? detectSubagentError(run.messages) : null;
|
|
266
|
+
const missingStructuredOutput = effectiveStructuredOutput
|
|
267
|
+
? !fs.existsSync(effectiveStructuredOutput.outputPath)
|
|
268
|
+
: false;
|
|
269
|
+
const emptyOutputError = run.exitCode === 0 && !run.error && !toolAvailabilityError && !hiddenError?.hasError && !run.finalOutput.trim() && (!effectiveStructuredOutput || missingStructuredOutput)
|
|
270
|
+
? "Subagent produced no output (possible model cold-start or empty response)."
|
|
271
|
+
: undefined;
|
|
272
|
+
let structuredOutput;
|
|
273
|
+
let structuredError;
|
|
274
|
+
if (effectiveStructuredOutput && run.exitCode === 0 && !run.error && !toolAvailabilityError && !hiddenError?.hasError && !emptyOutputError) {
|
|
275
|
+
const structured = readStructuredOutput({
|
|
276
|
+
schema: effectiveStructuredOutput.schema,
|
|
277
|
+
schemaPath: effectiveStructuredOutput.schemaPath,
|
|
278
|
+
outputPath: effectiveStructuredOutput.outputPath,
|
|
279
|
+
});
|
|
280
|
+
if (structured.error)
|
|
281
|
+
structuredError = structured.error;
|
|
282
|
+
else
|
|
283
|
+
structuredOutput = structured.value;
|
|
284
|
+
}
|
|
285
|
+
const completionGuard = run.exitCode === 0 && !run.error && !toolAvailabilityError && !hiddenError?.hasError && !emptyOutputError && step.completionGuard !== false
|
|
286
|
+
? evaluateCompletionMutationGuard({
|
|
287
|
+
permissions: childPermission,
|
|
288
|
+
task: taskForCompletionGuard,
|
|
289
|
+
messages: run.messages,
|
|
290
|
+
tools: step.tools,
|
|
291
|
+
mcpDirectTools: step.mcpDirectTools,
|
|
292
|
+
})
|
|
293
|
+
: undefined;
|
|
294
|
+
const completionGuardTriggered = completionGuard?.triggered === true && !run.observedMutationAttempt;
|
|
295
|
+
const completionGuardError = completionGuardTriggered
|
|
296
|
+
? "Subagent completed without making edits for an implementation task.\nIt appears to have returned planning or scratchpad output instead of applying changes."
|
|
297
|
+
: undefined;
|
|
298
|
+
const effectiveExitCode = toolAvailabilityError || completionGuardTriggered || structuredError
|
|
299
|
+
? 1
|
|
300
|
+
: hiddenError?.hasError
|
|
301
|
+
? (hiddenError.exitCode ?? 1)
|
|
302
|
+
: emptyOutputError
|
|
303
|
+
? 1
|
|
304
|
+
: run.error && run.exitCode === 0
|
|
305
|
+
? 1
|
|
306
|
+
: run.exitCode;
|
|
307
|
+
const error = toolAvailabilityError
|
|
308
|
+
?? completionGuardError
|
|
309
|
+
?? structuredError
|
|
310
|
+
?? (hiddenError?.hasError
|
|
311
|
+
? hiddenError.details
|
|
312
|
+
? `${hiddenError.errorType} failed (exit ${effectiveExitCode}): ${hiddenError.details}`
|
|
313
|
+
: `${hiddenError.errorType} failed with exit code ${effectiveExitCode}`
|
|
314
|
+
: emptyOutputError ?? (run.error || (run.exitCode !== 0 && run.stderr.trim() ? run.stderr.trim() : undefined)));
|
|
315
|
+
const attempt = {
|
|
316
|
+
model: candidate ?? run.model ?? step.model ?? "default",
|
|
317
|
+
success: effectiveExitCode === 0 && !error,
|
|
318
|
+
exitCode: effectiveExitCode,
|
|
319
|
+
error,
|
|
320
|
+
usage: run.usage,
|
|
321
|
+
};
|
|
322
|
+
modelAttempts.push(attempt);
|
|
323
|
+
if (candidate)
|
|
324
|
+
attemptedModels.push(candidate);
|
|
325
|
+
completionGuardTriggeredFinal = completionGuardTriggered;
|
|
326
|
+
finalOutputSnapshot = outputSnapshot;
|
|
327
|
+
if (step.toolBudget) {
|
|
328
|
+
const toolMessages = run.messages.filter((message) => message.role === "toolResult");
|
|
329
|
+
const blockedMessage = toolMessages.find((message) => extractTextFromContent(message.content).includes("Tool budget hard limit reached"));
|
|
330
|
+
toolBudgetBlocked = Boolean(blockedMessage);
|
|
331
|
+
toolBudget = toolBudgetState(step.toolBudget, toolMessages.length, blockedMessage ? blockedMessage.toolName : undefined);
|
|
332
|
+
}
|
|
333
|
+
finalResult = { ...run, exitCode: effectiveExitCode, model: candidate ?? run.model, error, structuredOutput };
|
|
334
|
+
if (run.turnBudgetExceeded)
|
|
335
|
+
break;
|
|
336
|
+
if (run.stopped || run.timedOut || ctx.timeoutSignal?.aborted || ctx.stopSignal?.aborted || ctx.skipAcceptance?.())
|
|
337
|
+
break;
|
|
338
|
+
if (attempt.success || completionGuardTriggered)
|
|
339
|
+
break;
|
|
340
|
+
if (!isRetryableModelFailure(error) || index === candidates.length - 1)
|
|
341
|
+
break;
|
|
342
|
+
attemptNotes.push(formatModelAttemptNote(attempt, candidates[index + 1]));
|
|
343
|
+
}
|
|
344
|
+
const rawOutput = finalResult?.finalOutput ?? "";
|
|
345
|
+
const outputForPersistence = stripAcceptanceReport(rawOutput);
|
|
346
|
+
const resolvedOutput = step.outputPath && finalResult?.exitCode === 0
|
|
347
|
+
? resolveSingleOutput(step.outputPath, outputForPersistence, finalOutputSnapshot, ctx.sessionCwd ?? ctx.cwd)
|
|
348
|
+
: { fullOutput: outputForPersistence };
|
|
349
|
+
const output = stripAcceptanceReport(resolvedOutput.fullOutput);
|
|
350
|
+
const outputReference = resolvedOutput.savedPath ? formatSavedOutputReference(resolvedOutput.savedPath, output) : undefined;
|
|
351
|
+
let outputForSummary = output;
|
|
352
|
+
if (attemptNotes.length > 0) {
|
|
353
|
+
outputForSummary = `${attemptNotes.join("\n")}\n\n${outputForSummary}`.trim();
|
|
354
|
+
}
|
|
355
|
+
if (finalResult?.stopped && !outputForSummary.trim()) {
|
|
356
|
+
outputForSummary = ctx.stopMessage ?? "Subagent stopped by user.";
|
|
357
|
+
}
|
|
358
|
+
else if (!finalResult?.timedOut && !finalResult?.stopped && finalResult?.turnBudgetExceeded && turnBudget) {
|
|
359
|
+
outputForSummary = formatTurnBudgetOutput(turnBudgetExceededMessage(turnBudget, turnBudget.turnCount), outputForSummary);
|
|
360
|
+
}
|
|
361
|
+
else if (!finalResult?.timedOut && !finalResult?.stopped && turnBudget?.outcome === "wrap-up-requested") {
|
|
362
|
+
const note = turnBudgetSoftNote(turnBudget, turnBudget.wrapUpRequestedAtTurn ?? turnBudget.turnCount);
|
|
363
|
+
outputForSummary = outputForSummary.trim() ? `${note}\n\n${outputForSummary}` : note;
|
|
364
|
+
}
|
|
365
|
+
const outputForAcceptance = rawOutput;
|
|
366
|
+
const childWrittenOutput = step.outputPath
|
|
367
|
+
? extractChildWrittenOutput(finalResult?.messages, step.outputPath, step.cwd ?? ctx.cwd)
|
|
368
|
+
: undefined;
|
|
369
|
+
const finalizedOutput = finalizeSingleOutput({
|
|
370
|
+
fullOutput: outputForSummary,
|
|
371
|
+
outputPath: step.outputPath,
|
|
372
|
+
outputMode: step.outputMode,
|
|
373
|
+
exitCode: finalResult?.exitCode ?? 1,
|
|
374
|
+
savedPath: resolvedOutput.savedPath,
|
|
375
|
+
outputReference,
|
|
376
|
+
saveError: resolvedOutput.saveError,
|
|
377
|
+
});
|
|
378
|
+
outputForSummary = finalizedOutput.displayOutput;
|
|
379
|
+
const acceptance = step.effectiveAcceptance && !finalResult?.stopped && !finalResult?.turnBudgetExceeded && !ctx.timeoutSignal?.aborted && !ctx.stopSignal?.aborted && !ctx.skipAcceptance?.()
|
|
380
|
+
? await evaluateAcceptance({
|
|
381
|
+
acceptance: step.effectiveAcceptance,
|
|
382
|
+
output: outputForAcceptance,
|
|
383
|
+
fileOutput: childWrittenOutput !== undefined && step.outputPath
|
|
384
|
+
? { content: childWrittenOutput, path: step.outputPath, authoritative: step.outputMode === "file-only" }
|
|
385
|
+
: undefined,
|
|
386
|
+
cwd: step.cwd ?? ctx.cwd,
|
|
387
|
+
signal: combinedAbortSignal([ctx.timeoutSignal, ctx.stopSignal]),
|
|
388
|
+
abortMessage: ctx.stopSignal?.aborted ? ctx.stopMessage ?? "Subagent stopped by user." : ctx.timeoutMessage ?? "Subagent timed out.",
|
|
389
|
+
})
|
|
390
|
+
: undefined;
|
|
391
|
+
const stoppedAfterAcceptance = finalResult?.stopped === true || ctx.stopSignal?.aborted === true;
|
|
392
|
+
const timedOutAfterAcceptance = !stoppedAfterAcceptance && (finalResult?.timedOut === true || ctx.timeoutSignal?.aborted === true);
|
|
393
|
+
const turnBudgetExceeded = finalResult?.turnBudgetExceeded === true;
|
|
394
|
+
const effectiveAcceptance = step.effectiveAcceptance
|
|
395
|
+
? stoppedAfterAcceptance
|
|
396
|
+
? buildSkippedAcceptanceLedger(step.effectiveAcceptance, { id: "stopped", message: "Acceptance was not evaluated because the subagent was stopped." })
|
|
397
|
+
: timedOutAfterAcceptance
|
|
398
|
+
? buildSkippedAcceptanceLedger(step.effectiveAcceptance, { id: "timeout", message: "Acceptance was not evaluated because the subagent timed out." })
|
|
399
|
+
: turnBudgetExceeded
|
|
400
|
+
? buildSkippedAcceptanceLedger(step.effectiveAcceptance, { id: "turn-budget", message: "Acceptance was not evaluated because the subagent exceeded its turn budget." })
|
|
401
|
+
: acceptance
|
|
402
|
+
: undefined;
|
|
403
|
+
const acceptanceFailure = effectiveAcceptance ? acceptanceFailureMessage(effectiveAcceptance) : undefined;
|
|
404
|
+
const acceptanceCanFailRun = acceptanceFailure && effectiveAcceptance?.explicit && (finalResult?.exitCode ?? 1) === 0 && !finalResult?.interrupted && !timedOutAfterAcceptance && !stoppedAfterAcceptance && !turnBudgetExceeded;
|
|
405
|
+
const effectiveFinalExitCode = timedOutAfterAcceptance || stoppedAfterAcceptance || turnBudgetExceeded ? 1 : acceptanceCanFailRun ? 1 : finalResult?.exitCode ?? 1;
|
|
406
|
+
const effectiveFinalError = stoppedAfterAcceptance
|
|
407
|
+
? ctx.stopMessage ?? "Subagent stopped by user."
|
|
408
|
+
: timedOutAfterAcceptance
|
|
409
|
+
? ctx.timeoutMessage ?? "Subagent timed out."
|
|
410
|
+
: turnBudgetExceeded
|
|
411
|
+
? finalResult?.error ?? (turnBudget ? turnBudgetExceededMessage(turnBudget, turnBudget.turnCount) : "Subagent exceeded turn budget.")
|
|
412
|
+
: acceptanceCanFailRun
|
|
413
|
+
? (finalResult?.error ? `${finalResult.error}\n${acceptanceFailure}` : acceptanceFailure)
|
|
414
|
+
: finalResult?.error;
|
|
415
|
+
if (artifactPaths && ctx.artifactConfig?.enabled !== false) {
|
|
416
|
+
if (ctx.artifactConfig?.includeOutput !== false) {
|
|
417
|
+
writeArtifact(artifactPaths.outputPath, output);
|
|
418
|
+
}
|
|
419
|
+
if (ctx.artifactConfig?.includeMetadata !== false) {
|
|
420
|
+
fs.writeFileSync(artifactPaths.metadataPath, JSON.stringify({
|
|
421
|
+
runId: ctx.id,
|
|
422
|
+
agent: step.agent,
|
|
423
|
+
task,
|
|
424
|
+
exitCode: effectiveFinalExitCode,
|
|
425
|
+
model: finalResult?.model,
|
|
426
|
+
attemptedModels: attemptedModels.length > 0 ? attemptedModels : undefined,
|
|
427
|
+
modelAttempts,
|
|
428
|
+
error: effectiveFinalError,
|
|
429
|
+
acceptance: effectiveAcceptance,
|
|
430
|
+
...(transcriptWriter ? { transcriptPath: artifactPaths.transcriptPath } : {}),
|
|
431
|
+
transcriptError: transcriptWriter?.getError(),
|
|
432
|
+
skills: step.skills,
|
|
433
|
+
timestamp: Date.now(),
|
|
434
|
+
}, null, 2), { encoding: "utf-8", mode: 0o600 });
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
const usageRequests = parseSessionRequests(step.sessionFile ?? sessionDir).filter((request) => Boolean(step.sessionFile) || !priorRequestIds.has(request.id));
|
|
438
|
+
return {
|
|
439
|
+
childId: step.childId,
|
|
440
|
+
description: step.description,
|
|
441
|
+
permissions: step.permissions,
|
|
442
|
+
agent: step.agent,
|
|
443
|
+
output: outputForSummary,
|
|
444
|
+
exitCode: effectiveFinalExitCode,
|
|
445
|
+
error: effectiveFinalError,
|
|
446
|
+
protocolError: finalResult?.protocolError,
|
|
447
|
+
sessionFile: step.sessionFile ?? (sessionDir ? findLatestSessionFile(sessionDir) ?? undefined : undefined),
|
|
448
|
+
receiptUsage: step.sessionFile ? parseSessionUsage(step.sessionFile) ?? undefined : undefined,
|
|
449
|
+
usageRequests: usageRequests.length > 0 ? usageRequests : undefined,
|
|
450
|
+
intercomTarget: ctx.childIntercomTarget,
|
|
451
|
+
model: finalResult?.model,
|
|
452
|
+
attemptedModels: attemptedModels.length > 0 ? attemptedModels : undefined,
|
|
453
|
+
modelAttempts,
|
|
454
|
+
totalCost: costSummaryFromAttempts(modelAttempts),
|
|
455
|
+
artifactPaths,
|
|
456
|
+
transcriptPath: transcriptWriter ? artifactPaths?.transcriptPath : undefined,
|
|
457
|
+
transcriptError: transcriptWriter?.getError(),
|
|
458
|
+
interrupted: timedOutAfterAcceptance || stoppedAfterAcceptance || turnBudgetExceeded ? false : finalResult?.interrupted,
|
|
459
|
+
timedOut: timedOutAfterAcceptance ? true : finalResult?.timedOut,
|
|
460
|
+
stopped: stoppedAfterAcceptance ? true : finalResult?.stopped,
|
|
461
|
+
turnBudget,
|
|
462
|
+
turnBudgetExceeded: turnBudgetExceeded || undefined,
|
|
463
|
+
wrapUpRequested: finalResult?.wrapUpRequested || turnBudget?.outcome === "wrap-up-requested" || turnBudgetExceeded || undefined,
|
|
464
|
+
toolBudget,
|
|
465
|
+
toolBudgetBlocked: toolBudgetBlocked || undefined,
|
|
466
|
+
completionGuardTriggered: completionGuardTriggeredFinal,
|
|
467
|
+
structuredOutput: timedOutAfterAcceptance || stoppedAfterAcceptance || turnBudgetExceeded ? undefined : finalResult?.structuredOutput,
|
|
468
|
+
structuredOutputPath: timedOutAfterAcceptance || stoppedAfterAcceptance || turnBudgetExceeded ? undefined : effectiveStructuredOutput?.outputPath,
|
|
469
|
+
structuredOutputSchemaPath: timedOutAfterAcceptance || stoppedAfterAcceptance || turnBudgetExceeded ? undefined : effectiveStructuredOutput?.schemaPath,
|
|
470
|
+
acceptance: effectiveAcceptance,
|
|
471
|
+
watchdog: finalResult?.watchdog,
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
export function combinedAbortSignal(signals) {
|
|
475
|
+
const activeSignals = signals.filter((signal) => Boolean(signal));
|
|
476
|
+
if (activeSignals.length === 0)
|
|
477
|
+
return undefined;
|
|
478
|
+
if (activeSignals.length === 1)
|
|
479
|
+
return activeSignals[0];
|
|
480
|
+
const controller = new AbortController();
|
|
481
|
+
const abort = () => controller.abort();
|
|
482
|
+
for (const signal of activeSignals) {
|
|
483
|
+
if (signal.aborted) {
|
|
484
|
+
abort();
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
488
|
+
}
|
|
489
|
+
return controller.signal;
|
|
490
|
+
}
|
|
491
|
+
//# sourceMappingURL=runner-single-step.js.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { TurnBudgetState, ToolBudgetState, ModelAttempt, CostSummary, ArtifactPaths, Usage, AsyncStatus, AsyncParallelGroupStatus, ArtifactConfig } from "../../shared/types.ts";
|
|
2
|
+
import type { ProtocolOutputLimit } from "../shared/child-protocol.ts";
|
|
3
|
+
export interface StepResult {
|
|
4
|
+
childId?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
permissions?: "full" | "read-only";
|
|
7
|
+
agent: string;
|
|
8
|
+
output: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
protocolError?: ProtocolOutputLimit;
|
|
11
|
+
success: boolean;
|
|
12
|
+
exitCode?: number | null;
|
|
13
|
+
skipped?: boolean;
|
|
14
|
+
interrupted?: boolean;
|
|
15
|
+
timedOut?: boolean;
|
|
16
|
+
stopped?: boolean;
|
|
17
|
+
turnBudget?: TurnBudgetState;
|
|
18
|
+
turnBudgetExceeded?: boolean;
|
|
19
|
+
wrapUpRequested?: boolean;
|
|
20
|
+
toolBudget?: ToolBudgetState;
|
|
21
|
+
toolBudgetBlocked?: boolean;
|
|
22
|
+
sessionFile?: string;
|
|
23
|
+
intercomTarget?: string;
|
|
24
|
+
model?: string;
|
|
25
|
+
attemptedModels?: string[];
|
|
26
|
+
modelAttempts?: ModelAttempt[];
|
|
27
|
+
totalCost?: CostSummary;
|
|
28
|
+
artifactPaths?: ArtifactPaths;
|
|
29
|
+
truncated?: boolean;
|
|
30
|
+
transcriptPath?: string;
|
|
31
|
+
transcriptError?: string;
|
|
32
|
+
structuredOutput?: unknown;
|
|
33
|
+
structuredOutputPath?: string;
|
|
34
|
+
structuredOutputSchemaPath?: string;
|
|
35
|
+
acceptance?: import("../../shared/types.ts").AcceptanceLedger;
|
|
36
|
+
watchdog?: import("../../shared/types.ts").ChildWatchdogProgress;
|
|
37
|
+
receiptUsage?: Usage;
|
|
38
|
+
usageRequests?: import("../../../../../core/usage-accounting.ts").AccountedRequest[];
|
|
39
|
+
}
|
|
40
|
+
export declare function appendRecentStepOutput(step: RunnerStatusStep, lines: string[]): void;
|
|
41
|
+
export declare function resetStepLiveDetail(step: RunnerStatusStep): void;
|
|
42
|
+
export type RunnerStatusStep = NonNullable<AsyncStatus["steps"]>[number] & {
|
|
43
|
+
exitCode?: number | null;
|
|
44
|
+
};
|
|
45
|
+
export type RunnerStatusPayload = Omit<AsyncStatus, "steps" | "parallelGroups" | "pid" | "cwd" | "currentStep" | "chainStepCount" | "lastUpdate"> & {
|
|
46
|
+
pid: number;
|
|
47
|
+
cwd: string;
|
|
48
|
+
currentStep: number;
|
|
49
|
+
chainStepCount: number;
|
|
50
|
+
parallelGroups: AsyncParallelGroupStatus[];
|
|
51
|
+
steps: RunnerStatusStep[];
|
|
52
|
+
lastUpdate: number;
|
|
53
|
+
artifactsDir?: string;
|
|
54
|
+
error?: string;
|
|
55
|
+
};
|
|
56
|
+
export declare function resolveAsyncStepTranscriptPath(input: {
|
|
57
|
+
artifactsDir?: string;
|
|
58
|
+
artifactConfig?: Partial<ArtifactConfig>;
|
|
59
|
+
runId: string;
|
|
60
|
+
agent: string;
|
|
61
|
+
flatIndex: number;
|
|
62
|
+
flatStepCount: number;
|
|
63
|
+
}): string | undefined;
|
|
64
|
+
//# sourceMappingURL=runner-status.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// The step result and status.json shapes the async runner writes, and helpers that edit one step's live fields.
|
|
2
|
+
import { getArtifactPaths } from "../../shared/artifacts.js";
|
|
3
|
+
export function appendRecentStepOutput(step, lines) {
|
|
4
|
+
const nonEmpty = lines.filter((line) => line.trim());
|
|
5
|
+
if (nonEmpty.length === 0)
|
|
6
|
+
return;
|
|
7
|
+
step.recentOutput ??= [];
|
|
8
|
+
step.recentOutput.push(...nonEmpty);
|
|
9
|
+
if (step.recentOutput.length > 50) {
|
|
10
|
+
step.recentOutput.splice(0, step.recentOutput.length - 50);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function resetStepLiveDetail(step) {
|
|
14
|
+
step.currentTool = undefined;
|
|
15
|
+
step.currentToolArgs = undefined;
|
|
16
|
+
step.currentToolStartedAt = undefined;
|
|
17
|
+
step.currentPath = undefined;
|
|
18
|
+
step.recentTools = [];
|
|
19
|
+
step.recentOutput = [];
|
|
20
|
+
}
|
|
21
|
+
export function resolveAsyncStepTranscriptPath(input) {
|
|
22
|
+
if (!input.artifactsDir || input.artifactConfig?.enabled === false || input.artifactConfig?.includeTranscript === false)
|
|
23
|
+
return undefined;
|
|
24
|
+
return getArtifactPaths(input.artifactsDir, input.runId, input.agent, input.flatStepCount > 1 ? input.flatIndex : undefined).transcriptPath;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=runner-status.js.map
|