Lands Sage's sage/row66-r5 at7ffb640ac, round 4 (r4d82c830779) rebased ontoa36523713after row 197, approved by Dewey (comment 30085) and Filbert (30086) on manifest 6cfd812da4ca (23 paths, rev 2905). The rebase had no conflict. The range-diff is = except one pi-session.test.mjs hunk header. Patch-id without agents/ is d67275ac4251 on7b9737953,a36523713and this commit's parent. Gate (mos-1186): unslop, harness, cli and every scripts/test-*.sh green on r4d, harness 149/0 again on r5. Landing sessions on a scratch root from the candidate tree: Claude Code r4ab24630d323 showed the note, the injected notice and counts checked 2, flagged 1, notices 1. Pi r1dd94171bede is launch only until #383 (Vikunja #454).
51 lines
2.4 KiB
JavaScript
51 lines
2.4 KiB
JavaScript
// A stand-in harness turn for the runner tests. MOSAIC_REQUEST's body
|
|
// (after the blank line) picks the behaviour:
|
|
// TOOL <name> <json> call a typed tool through the tool socket, print the result or refusal
|
|
// SLEEP hang until killed
|
|
// FAIL exit 3
|
|
// NOMARKER answer without writing the turn marker
|
|
// ENV <name> answer "env: <value of name>"
|
|
// UNSLOP <json> append each event of the JSON array to $MOSAIC_UNSLOP_LOG, as the harness's
|
|
// unslop check does (row 66), and answer "unslop: <count>"
|
|
// UNSLOPLONG <json> the same, with an answer of 40000 more characters, over the runner's clip
|
|
// anything else answer "echo: <request>"
|
|
// Every turn appends its pid to $FAKE_PIDS when set.
|
|
|
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
import { callTool } from "../../src/tools.mjs";
|
|
|
|
const request = process.env.MOSAIC_REQUEST ?? "";
|
|
// The message body follows the "Message ...:" header line; a state block (row 109) may sit above it.
|
|
const body = request.match(/^Message [^\n]*:\n\n([\s\S]*)$/m)?.[1] ?? request.split("\n\n").slice(1).join("\n\n");
|
|
if (process.env.FAKE_PIDS) appendFileSync(process.env.FAKE_PIDS, `${process.pid}\n`);
|
|
process.stderr.write(`fake adapter: ${process.env.MOSAIC_MODEL}\n`);
|
|
const done = () => writeFileSync(process.env.MOSAIC_TURN_MARKER, "done\n");
|
|
|
|
if (body.startsWith("TOOL ")) {
|
|
const [, name, ...rest] = body.split(" ");
|
|
try {
|
|
process.stdout.write(JSON.stringify(await callTool(process.env.MOSAIC_TOOL_SOCKET, name, JSON.parse(rest.join(" ") || "{}"))));
|
|
} catch (e) {
|
|
process.stdout.write(e.message);
|
|
}
|
|
done();
|
|
} else if (body === "SLEEP") {
|
|
setInterval(() => {}, 1000);
|
|
} else if (body === "FAIL") {
|
|
process.exit(3);
|
|
} else if (body.startsWith("ENV ")) {
|
|
process.stdout.write(`env: ${process.env[body.slice(4)]}\n`);
|
|
done();
|
|
} else if (body.startsWith("UNSLOP ") || body.startsWith("UNSLOPLONG ")) {
|
|
const long = body.startsWith("UNSLOPLONG ");
|
|
const events = JSON.parse(body.slice(long ? 11 : 7));
|
|
for (const e of events) appendFileSync(process.env.MOSAIC_UNSLOP_LOG, JSON.stringify({ ts: Date.now(), ...e }) + "\n");
|
|
process.stdout.write(`unslop: ${events.length}${long ? " " + "x".repeat(40000) : ""}\n`);
|
|
done();
|
|
} else if (body === "NOMARKER") {
|
|
process.stdout.write("half an answer");
|
|
} else {
|
|
process.stdout.write(`echo: ${request}\n`);
|
|
done();
|
|
}
|