The broker gains a read-only state verb (launch state with the event that set it, open tasks capped). The runner fetches it before each turn and puts a "Current state" block at the top of the request; a failed read fails the turn. turnRequest() adds the message time. roles/pm.md gets one rule: the block is the truth for launch state and task status. Seat session, seat sandbox and cli launcher tests re-anchored to the new request shape. Built by Researcher, packet875c515e9. Filbert approved round 3, comment 28333, candidate manifest 0a62225e (11 paths). Sage gate on9774d70dbplus row109.patch: every package node suite and every scripts/test-*.sh green on the first run, skipped 0 in bus, harness and seat. Vikunja #259. Co-Authored-By: Claude Opus 5.5 <[email protected]>
38 lines
1.6 KiB
JavaScript
38 lines
1.6 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
|
|
// 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 === "NOMARKER") {
|
|
process.stdout.write("half an answer");
|
|
} else {
|
|
process.stdout.write(`echo: ${request}\n`);
|
|
done();
|
|
}
|