Emit job events, checkpoint at terminal, and bound the run wait

This commit is contained in:
alex committed 2026-12-01 11:39:54 +00:00
1 parent bf70be5729
commit df929590e8
17 files changed
+501 -166

No files matched your search

+7 -4
View File
@@ -6,7 +6,7 @@ import test from "node:test";
import { fileURLToPath } from "node:url";
import type { AgentConfig } from "../src/agents.ts";
import { ProcessRunner, type ProcessRunnerOptions } from "../src/runner.ts";
import type { DispatchDefaults, PreparedTask, RunOptions, RunResult } from "../src/types.ts";
import type { DispatchDefaults, PreparedTask, RunOptions, RunUpdate } from "../src/types.ts";
const fixturePath = fileURLToPath(new URL("./fixtures/fake-pi.mjs", import.meta.url));
const stderrLimit = 64 * 1024;
@@ -79,9 +79,9 @@ function processIsAlive(pid: number): boolean {
test("collects message_end JSONL, ignores tool_result_end, aggregates usage and returns final output", async (t) => {
const runner = makeRunner({ FAKE_PI_MODE: "success" });
const updates: RunResult[] = [];
const updates: RunUpdate[] = [];
const result = await runner.run(makeTask(), {}, runOptions({ onUpdate: (partial) => updates.push(partial) }));
const result = await runner.run(makeTask(), {}, runOptions({ onUpdate: (update) => updates.push(update) }));
assert.equal(result.exitCode, 0);
assert.equal(result.terminationSignal, undefined);
@@ -114,9 +114,12 @@ test("collects message_end JSONL, ignores tool_result_end, aggregates usage and
assert.ok(updates.length > 0);
assert.equal(
updates.some((partial) => partial.messages.some((message) => message.role === "toolResult")),
updates.some((update) => update.message?.role === "toolResult"),
true,
);
// Every update shares the runner's live transcript instead of copying it;
// the appended message rides along as the delta.
assert.equal(new Set(updates.map((update) => update.result.messages)).size, 1);
t.diagnostic(`onUpdate calls: ${updates.length}`);
});