harnery 0.27.0 → 0.28.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/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +27 -1
- package/dist/commands/work.d.ts +2 -0
- package/dist/commands/work.d.ts.map +1 -1
- package/dist/commands/work.js +47 -4
- package/dist/core/harnesses/types.d.ts +5 -0
- package/dist/core/harnesses/types.d.ts.map +1 -1
- package/dist/core/work/index.d.ts +1 -1
- package/dist/core/work/index.d.ts.map +1 -1
- package/dist/core/work/index.js +1 -1
- package/dist/core/work/runner.d.ts.map +1 -1
- package/dist/core/work/runner.js +8 -1
- package/dist/core/work/state.d.ts +24 -1
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +108 -14
- package/dist/core/workflow/approvals.d.ts.map +1 -1
- package/dist/core/workflow/approvals.js +3 -6
- package/dist/core/workflow/attempt-context.d.ts.map +1 -1
- package/dist/core/workflow/attempt-context.js +38 -1
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +20 -19
- package/dist/core/workflow/journal.d.ts +30 -0
- package/dist/core/workflow/journal.d.ts.map +1 -0
- package/dist/core/workflow/journal.js +70 -0
- package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
- package/dist/core/workflow/spawn-claude.js +8 -0
- package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
- package/dist/core/workflow/spawn-codex.js +8 -0
- package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
- package/dist/core/workflow/spawn-cursor.js +8 -0
- package/dist/core/workflow/types.d.ts +11 -0
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/state.d.ts +1 -1
- package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/state.js +9 -30
- package/dist/lib/browser/client.d.ts +50 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +103 -0
- package/dist/lib/exec.d.ts +4 -0
- package/dist/lib/exec.d.ts.map +1 -1
- package/dist/lib/exec.js +6 -1
- package/package.json +1 -1
- package/src/commands/browse.ts +33 -1
- package/src/commands/work.ts +80 -13
- package/src/core/harnesses/types.ts +5 -0
- package/src/core/work/index.ts +1 -0
- package/src/core/work/runner.ts +8 -0
- package/src/core/work/state.ts +177 -27
- package/src/core/workflow/approvals.ts +3 -6
- package/src/core/workflow/attempt-context.ts +47 -1
- package/src/core/workflow/engine.ts +48 -33
- package/src/core/workflow/journal.ts +90 -0
- package/src/core/workflow/spawn-claude.ts +8 -0
- package/src/core/workflow/spawn-codex.ts +8 -0
- package/src/core/workflow/spawn-cursor.ts +8 -0
- package/src/core/workflow/types.ts +12 -0
- package/src/core/workflow/workspaces/state.ts +13 -33
- package/src/lib/browser/client.ts +129 -0
- package/src/lib/exec.ts +10 -1
|
@@ -155,6 +155,109 @@ export class Browser {
|
|
|
155
155
|
const buf = await page.screenshot({ path, fullPage: opts.fullPage ?? true, type: "png" });
|
|
156
156
|
return buf.length;
|
|
157
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Capture a full-page screenshot from an explicit capture viewport and
|
|
160
|
+
* evaluate the caller's final evidence expression immediately before the
|
|
161
|
+
* pixels are written. Playwright normally manages the full-page viewport
|
|
162
|
+
* internally, which leaves callers unable to inspect fixed/sticky geometry
|
|
163
|
+
* in the state the PNG actually renders.
|
|
164
|
+
*/
|
|
165
|
+
async screenshotWithEvaluation(path, evaluation, opts = {}) {
|
|
166
|
+
const page = this.currentPage;
|
|
167
|
+
const fullPage = opts.fullPage ?? true;
|
|
168
|
+
const maxPasses = 4;
|
|
169
|
+
const maxDimension = 32_000;
|
|
170
|
+
const maxPixels = 128_000_000;
|
|
171
|
+
const documentExtent = () => page.evaluate(() => ({
|
|
172
|
+
width: Math.max(document.documentElement.scrollWidth, document.body?.scrollWidth ?? 0),
|
|
173
|
+
height: Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight ?? 0),
|
|
174
|
+
}));
|
|
175
|
+
const originalViewport = page.viewportSize();
|
|
176
|
+
if (!originalViewport) {
|
|
177
|
+
throw new Error("Capture-state evaluation requires a page with an explicit viewport.");
|
|
178
|
+
}
|
|
179
|
+
let captureViewport = originalViewport;
|
|
180
|
+
let passes = fullPage ? 0 : 1;
|
|
181
|
+
let extentBeforeEvaluation = await documentExtent();
|
|
182
|
+
let bounded = true;
|
|
183
|
+
if (fullPage) {
|
|
184
|
+
for (let pass = 0; pass < maxPasses; pass += 1) {
|
|
185
|
+
passes = pass + 1;
|
|
186
|
+
const nextViewport = {
|
|
187
|
+
width: originalViewport.width,
|
|
188
|
+
height: Math.max(originalViewport.height, Math.ceil(extentBeforeEvaluation.height)),
|
|
189
|
+
};
|
|
190
|
+
bounded =
|
|
191
|
+
nextViewport.width <= maxDimension &&
|
|
192
|
+
nextViewport.height <= maxDimension &&
|
|
193
|
+
nextViewport.width * nextViewport.height <= maxPixels;
|
|
194
|
+
if (!bounded)
|
|
195
|
+
break;
|
|
196
|
+
if (nextViewport.width === captureViewport.width &&
|
|
197
|
+
nextViewport.height === captureViewport.height &&
|
|
198
|
+
extentBeforeEvaluation.width <= captureViewport.width &&
|
|
199
|
+
extentBeforeEvaluation.height === captureViewport.height) {
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
captureViewport = nextViewport;
|
|
203
|
+
await page.setViewportSize(captureViewport);
|
|
204
|
+
extentBeforeEvaluation = await documentExtent();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
const evaluationResult = await page.evaluate(evaluation);
|
|
209
|
+
const extentAfterEvaluation = await documentExtent();
|
|
210
|
+
const buf = await page.screenshot({ path, fullPage: fullPage && bounded, type: "png" });
|
|
211
|
+
const extentAfterScreenshot = await documentExtent();
|
|
212
|
+
const screenshot = {
|
|
213
|
+
width: buf.readUInt32BE(16),
|
|
214
|
+
height: buf.readUInt32BE(20),
|
|
215
|
+
bytes: buf.length,
|
|
216
|
+
};
|
|
217
|
+
const exact = fullPage
|
|
218
|
+
? bounded &&
|
|
219
|
+
captureViewport.width === extentBeforeEvaluation.width &&
|
|
220
|
+
captureViewport.height === extentBeforeEvaluation.height &&
|
|
221
|
+
captureViewport.width === extentAfterEvaluation.width &&
|
|
222
|
+
captureViewport.height === extentAfterEvaluation.height &&
|
|
223
|
+
captureViewport.width === extentAfterScreenshot.width &&
|
|
224
|
+
captureViewport.height === extentAfterScreenshot.height &&
|
|
225
|
+
captureViewport.width === screenshot.width &&
|
|
226
|
+
captureViewport.height === screenshot.height
|
|
227
|
+
: captureViewport.width === screenshot.width &&
|
|
228
|
+
captureViewport.height === screenshot.height;
|
|
229
|
+
const reason = !bounded
|
|
230
|
+
? "capture_bounds_exceeded"
|
|
231
|
+
: exact
|
|
232
|
+
? "capture_viewport_converged"
|
|
233
|
+
: "capture_viewport_non_convergent";
|
|
234
|
+
return {
|
|
235
|
+
bytes: buf.length,
|
|
236
|
+
evaluation: evaluationResult,
|
|
237
|
+
viewport: captureViewport,
|
|
238
|
+
evidence: {
|
|
239
|
+
converged: exact,
|
|
240
|
+
reason,
|
|
241
|
+
passes,
|
|
242
|
+
max_passes: maxPasses,
|
|
243
|
+
max_dimension: maxDimension,
|
|
244
|
+
max_pixels: maxPixels,
|
|
245
|
+
original_viewport: originalViewport,
|
|
246
|
+
evaluated_viewport: captureViewport,
|
|
247
|
+
document_extent_before_evaluation: extentBeforeEvaluation,
|
|
248
|
+
document_extent_after_evaluation: extentAfterEvaluation,
|
|
249
|
+
document_extent_after_screenshot: extentAfterScreenshot,
|
|
250
|
+
screenshot,
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
finally {
|
|
255
|
+
if (captureViewport.width !== originalViewport.width ||
|
|
256
|
+
captureViewport.height !== originalViewport.height) {
|
|
257
|
+
await page.setViewportSize(originalViewport);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
158
261
|
/**
|
|
159
262
|
* Plain-text snapshot of the document body. Suitable as a coarse "what's
|
|
160
263
|
* on screen" signal for LLM iteration loops. For richer extraction, use
|
package/dist/lib/exec.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export interface ExecResult {
|
|
|
10
10
|
stdout: string;
|
|
11
11
|
stderr: string;
|
|
12
12
|
exitCode: number;
|
|
13
|
+
/** True when this process killed the child for exceeding `opts.timeout`. A
|
|
14
|
+
* child that handles the signal cleanly still exits 0, so the exit code alone
|
|
15
|
+
* cannot distinguish a kill from an ordinary finish. */
|
|
16
|
+
timedOut?: boolean;
|
|
13
17
|
}
|
|
14
18
|
export interface ExecOpts {
|
|
15
19
|
cwd?: string;
|
package/dist/lib/exec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/lib/exec.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/lib/exec.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;4DAEwD;IACxD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,QAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAwC5E;AAED,sEAAsE;AACtE,wBAAsB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAEhG"}
|
package/dist/lib/exec.js
CHANGED
|
@@ -29,7 +29,11 @@ export function exec(cmd, opts = {}) {
|
|
|
29
29
|
proc.stdout?.on("data", (d) => out.push(d));
|
|
30
30
|
proc.stderr?.on("data", (d) => err.push(d));
|
|
31
31
|
const timeout = opts.timeout ?? 30_000;
|
|
32
|
-
|
|
32
|
+
let timedOut = false;
|
|
33
|
+
const timer = setTimeout(() => {
|
|
34
|
+
timedOut = true;
|
|
35
|
+
proc.kill();
|
|
36
|
+
}, timeout);
|
|
33
37
|
const finish = (exitCode, errOverride) => {
|
|
34
38
|
clearTimeout(timer);
|
|
35
39
|
const stdout = Buffer.concat(out).toString("utf-8");
|
|
@@ -39,6 +43,7 @@ export function exec(cmd, opts = {}) {
|
|
|
39
43
|
stdout: shouldTrim ? stdout.trim() : stdout.replace(/\n$/, ""),
|
|
40
44
|
stderr: shouldTrim ? stderr.trim() : stderr.replace(/\n$/, ""),
|
|
41
45
|
exitCode,
|
|
46
|
+
...(timedOut ? { timedOut: true } : {}),
|
|
42
47
|
});
|
|
43
48
|
};
|
|
44
49
|
// ENOENT (binary not found) and similar spawn failures surface here rather
|
package/package.json
CHANGED
package/src/commands/browse.ts
CHANGED
|
@@ -67,6 +67,7 @@ interface BrowseOpts {
|
|
|
67
67
|
press?: string;
|
|
68
68
|
waitFor?: string;
|
|
69
69
|
evaluate?: string;
|
|
70
|
+
captureEvaluate?: string;
|
|
70
71
|
batch?: string;
|
|
71
72
|
networkHar?: string;
|
|
72
73
|
login?: boolean;
|
|
@@ -179,6 +180,10 @@ export function registerBrowseCommand(
|
|
|
179
180
|
"--evaluate <js>",
|
|
180
181
|
"Run JS in the page context after navigation; result printed to stdout",
|
|
181
182
|
)
|
|
183
|
+
.option(
|
|
184
|
+
"--capture-evaluate <js>",
|
|
185
|
+
"In trio mode, evaluate JS inside the exact screenshot viewport immediately before capture; result is written as captureEval",
|
|
186
|
+
)
|
|
182
187
|
.option(
|
|
183
188
|
"--batch <steps>",
|
|
184
189
|
"Run multiple steps in one session, semicolon-separated. Each step is one of: " +
|
|
@@ -601,6 +606,11 @@ async function runBrowse(
|
|
|
601
606
|
}
|
|
602
607
|
|
|
603
608
|
if (printMode) {
|
|
609
|
+
if (opts.captureEvaluate) {
|
|
610
|
+
throw new Error(
|
|
611
|
+
"--capture-evaluate requires trio mode so its result can be bound to a screenshot.",
|
|
612
|
+
);
|
|
613
|
+
}
|
|
604
614
|
if (opts.baseline || opts.diff) {
|
|
605
615
|
throw new Error(
|
|
606
616
|
"--baseline / --diff require trio mode (screenshot file). Remove --snapshot/--html/--json or capture the screenshot first.",
|
|
@@ -911,10 +921,27 @@ async function runTrioMode(
|
|
|
911
921
|
const skipScreenshot = opts.screenshot === false || opts.domOnly === true;
|
|
912
922
|
let pngPath: string | undefined;
|
|
913
923
|
let pngBytes: number | undefined;
|
|
924
|
+
let captureEvalResult: unknown;
|
|
925
|
+
let captureViewport: { width: number; height: number } | undefined;
|
|
926
|
+
let captureEvidence: unknown;
|
|
914
927
|
if (!skipScreenshot) {
|
|
915
928
|
pngPath = `${prefix}.png`;
|
|
916
|
-
|
|
929
|
+
if (opts.captureEvaluate) {
|
|
930
|
+
const captured = await browser.screenshotWithEvaluation(pngPath, opts.captureEvaluate, {
|
|
931
|
+
fullPage: opts.fullPage !== false,
|
|
932
|
+
});
|
|
933
|
+
pngBytes = captured.bytes;
|
|
934
|
+
captureEvalResult = captured.evaluation;
|
|
935
|
+
captureViewport = captured.viewport;
|
|
936
|
+
captureEvidence = captured.evidence;
|
|
937
|
+
} else {
|
|
938
|
+
pngBytes = await browser.screenshot(pngPath, { fullPage: opts.fullPage !== false });
|
|
939
|
+
}
|
|
917
940
|
written.push(pngPath);
|
|
941
|
+
} else if (opts.captureEvaluate) {
|
|
942
|
+
throw new Error(
|
|
943
|
+
"--capture-evaluate requires a screenshot; remove --no-screenshot / --dom-only.",
|
|
944
|
+
);
|
|
918
945
|
}
|
|
919
946
|
|
|
920
947
|
const htmlPath = `${prefix}.html`;
|
|
@@ -937,6 +964,11 @@ async function runTrioMode(
|
|
|
937
964
|
};
|
|
938
965
|
if (pngBytes !== undefined) envelope.screenshotBytes = pngBytes;
|
|
939
966
|
if (opts.evaluate) envelope.eval = evalResult;
|
|
967
|
+
if (opts.captureEvaluate) {
|
|
968
|
+
envelope.captureEval = captureEvalResult;
|
|
969
|
+
envelope.captureViewport = captureViewport;
|
|
970
|
+
envelope.captureEvidence = captureEvidence;
|
|
971
|
+
}
|
|
940
972
|
if (opts.networkHar) envelope.har = resolve(opts.networkHar);
|
|
941
973
|
if (visibility) envelope.visibility = visibility;
|
|
942
974
|
if (widths) envelope.width = widths;
|
package/src/commands/work.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
reconcileWorkItem,
|
|
20
20
|
reopenWorkItem,
|
|
21
21
|
runWorkItem,
|
|
22
|
+
type WorkAttempt,
|
|
22
23
|
type WorkRecord,
|
|
23
24
|
} from "../core/work/index.ts";
|
|
24
25
|
import { WorkflowParkedError } from "../core/workflow/index.ts";
|
|
@@ -52,8 +53,12 @@ interface GovernanceOpts {
|
|
|
52
53
|
actor?: string;
|
|
53
54
|
reason?: string;
|
|
54
55
|
json?: boolean;
|
|
56
|
+
finding?: string[];
|
|
57
|
+
dispose?: string[];
|
|
55
58
|
}
|
|
56
59
|
|
|
60
|
+
const MAX_ATTEMPT_JOURNAL_ERROR_RENDER = 240;
|
|
61
|
+
|
|
57
62
|
export function registerWorkCommand(program: Command, emit: EmitContext): void {
|
|
58
63
|
const registry = createBuiltinHarnessRegistry();
|
|
59
64
|
const harnesses = registry.ids();
|
|
@@ -257,14 +262,66 @@ function registerGovernanceCommand(
|
|
|
257
262
|
)
|
|
258
263
|
.option("--actor <name>", "Actor recorded in the governance receipt")
|
|
259
264
|
.option("--reason <text>", "Bounded decision reason")
|
|
260
|
-
.option("--json", "Emit the complete work record as JSON")
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
.option("--json", "Emit the complete work record as JSON");
|
|
266
|
+
const command = work.commands.at(-1) as Command;
|
|
267
|
+
if (name === "reopen") {
|
|
268
|
+
command.option(
|
|
269
|
+
"--finding <text>",
|
|
270
|
+
"Correction the next attempt must address (repeatable)",
|
|
271
|
+
collectValue,
|
|
272
|
+
[] as string[],
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
if (name === "accept") {
|
|
276
|
+
command.option(
|
|
277
|
+
"--dispose <id=outcome[:reason]>",
|
|
278
|
+
"Dispose of an open finding: fixed, or deferred:<reason> (repeatable)",
|
|
279
|
+
collectValue,
|
|
280
|
+
[] as string[],
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
command.action((workId: string, opts: GovernanceOpts) => {
|
|
284
|
+
withWorkRoot(emit, (coordRoot) => {
|
|
285
|
+
const fn =
|
|
286
|
+
name === "accept" ? acceptWorkItem : name === "cancel" ? cancelWorkItem : reopenWorkItem;
|
|
287
|
+
emitWork(
|
|
288
|
+
fn(coordRoot, workId, {
|
|
289
|
+
...opts,
|
|
290
|
+
...(opts.finding?.length ? { findings: opts.finding } : {}),
|
|
291
|
+
...(opts.dispose?.length ? { dispositions: opts.dispose.map(parseDisposition) } : {}),
|
|
292
|
+
}),
|
|
293
|
+
opts.json,
|
|
294
|
+
emit,
|
|
295
|
+
true,
|
|
296
|
+
);
|
|
267
297
|
});
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function collectValue(value: string, previous: string[]): string[] {
|
|
302
|
+
return [...previous, value];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** `<id>=fixed` or `<id>=deferred:<reason>`. Deferring without a reason is
|
|
306
|
+
* rejected downstream, so a lapsed finding cannot look like a decision. */
|
|
307
|
+
function parseDisposition(input: string): {
|
|
308
|
+
id: string;
|
|
309
|
+
outcome: "fixed" | "deferred";
|
|
310
|
+
reason?: string;
|
|
311
|
+
} {
|
|
312
|
+
const split = input.indexOf("=");
|
|
313
|
+
if (split <= 0)
|
|
314
|
+
throw new Error(`invalid --dispose ${JSON.stringify(input)}; expected <id>=<outcome>`);
|
|
315
|
+
const id = input.slice(0, split).trim();
|
|
316
|
+
const rest = input.slice(split + 1).trim();
|
|
317
|
+
const [outcome, ...reasonParts] = rest.split(":");
|
|
318
|
+
if (outcome !== "fixed" && outcome !== "deferred") {
|
|
319
|
+
throw new Error(
|
|
320
|
+
`invalid --dispose outcome ${JSON.stringify(outcome)}; expected fixed or deferred`,
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
const reason = reasonParts.join(":").trim();
|
|
324
|
+
return { id, outcome, ...(reason ? { reason } : {}) };
|
|
268
325
|
}
|
|
269
326
|
|
|
270
327
|
function emitWork(
|
|
@@ -297,18 +354,28 @@ function emitWork(
|
|
|
297
354
|
lines.push("acceptance:", ...record.intent.acceptance.map((item) => ` - ${item}`));
|
|
298
355
|
}
|
|
299
356
|
if (projection.attempts.length) {
|
|
300
|
-
lines.push(
|
|
301
|
-
"attempts:",
|
|
302
|
-
...projection.attempts.map(
|
|
303
|
-
(attempt) => ` ${attempt.number}. ${attempt.run_id} ${attempt.status}`,
|
|
304
|
-
),
|
|
305
|
-
);
|
|
357
|
+
lines.push("attempts:", ...projection.attempts.map(renderAttemptRow));
|
|
306
358
|
}
|
|
307
359
|
if (projection.approval_id) lines.push(`approval: ${projection.approval_id}`);
|
|
308
360
|
if (projection.proof_path) lines.push(`proof: ${projection.proof_path}`);
|
|
309
361
|
emit.text(`${lines.join("\n")}\n`);
|
|
310
362
|
}
|
|
311
363
|
|
|
364
|
+
export function renderAttemptRow(attempt: WorkAttempt): string {
|
|
365
|
+
const statusDetail =
|
|
366
|
+
attempt.status === "journal_unreadable"
|
|
367
|
+
? `: ${renderAttemptJournalError(attempt.journal_error)}`
|
|
368
|
+
: "";
|
|
369
|
+
return ` ${attempt.number}. ${attempt.run_id} ${attempt.status}${statusDetail}`;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function renderAttemptJournalError(error: string | undefined): string {
|
|
373
|
+
const normalized = (error ?? "").replace(/\s+/g, " ").trim();
|
|
374
|
+
const value = normalized || "unknown journal read error";
|
|
375
|
+
if (value.length <= MAX_ATTEMPT_JOURNAL_ERROR_RENDER) return value;
|
|
376
|
+
return `${value.slice(0, MAX_ATTEMPT_JOURNAL_ERROR_RENDER - 3).trimEnd()}...`;
|
|
377
|
+
}
|
|
378
|
+
|
|
312
379
|
function renderWorkRow(record: WorkRecord): string {
|
|
313
380
|
const projection = record.projection;
|
|
314
381
|
return `${record.intent.id} ${projection.state.padEnd(17)} ${projection.attempts_used}/${record.intent.max_attempts} ${projection.next_action.padEnd(21)} ${record.intent.title}`;
|
|
@@ -83,6 +83,11 @@ export interface HarnessRawResult {
|
|
|
83
83
|
exitCode: number;
|
|
84
84
|
durationMs: number;
|
|
85
85
|
resultFileText?: string;
|
|
86
|
+
/** The host killed this child for exceeding its timeout. A vendor CLI that
|
|
87
|
+
* handles the signal cleanly still exits 0, so exit code alone cannot tell a
|
|
88
|
+
* kill from a finish; without this a timed-out child reads as a success with
|
|
89
|
+
* an empty answer. */
|
|
90
|
+
timedOut?: boolean;
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
export interface HarnessBenchFixture {
|
package/src/core/work/index.ts
CHANGED
package/src/core/work/runner.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
assertWorkflowUnchanged,
|
|
19
19
|
boundedActor,
|
|
20
20
|
newWorkflowRunId,
|
|
21
|
+
openOperatorFindings,
|
|
21
22
|
readWorkItemIgnoringLease,
|
|
22
23
|
type WorkAttempt,
|
|
23
24
|
} from "./state.ts";
|
|
@@ -81,11 +82,18 @@ export async function runWorkItem(input: RunWorkItemInput): Promise<RunReport> {
|
|
|
81
82
|
}
|
|
82
83
|
prior = priorContext(coordRoot, latest);
|
|
83
84
|
}
|
|
85
|
+
const open = openOperatorFindings(coordRoot, input.workId);
|
|
86
|
+
const findings = open.findings.map((finding) => ({
|
|
87
|
+
id: finding.id,
|
|
88
|
+
actor: open.actor,
|
|
89
|
+
statement: finding.statement,
|
|
90
|
+
}));
|
|
84
91
|
const attemptContext: WorkflowAttemptContext = {
|
|
85
92
|
schema_version: WORKFLOW_ATTEMPT_CONTEXT_SCHEMA_VERSION,
|
|
86
93
|
number: attempt,
|
|
87
94
|
trigger,
|
|
88
95
|
...(prior ? { prior } : {}),
|
|
96
|
+
...(findings.length === 0 ? {} : { findings }),
|
|
89
97
|
};
|
|
90
98
|
const runId = newWorkflowRunId();
|
|
91
99
|
appendWorkEvent(coordRoot, input.workId, {
|