The Agents views gain a Hierarchie view: an org chart of the chair and the line offices read from the council claims. The operator appoints, hands over and recalls an office there; the page signs each change with the passkey and a host unit (client/offices.py, offices path unit) verifies the signature, removes a live holder itself and runs a plain council.py claim for the successor. council.py loses the --operator flag, so no agent can override a live holder. The agent order is now separate from task priority: rasci.py agents order stores it in agent-order.json beside the register through the nofollow helpers and never writes a --prio pin. It only breaks ties of equal task rank, also among the queue grants. The Hierarchie view edits it as a drag list. Host units run the installed skill scripts, so orchestrator.sh keeps the offices unit off while the installed council.py, nofollow.py or rasci.py differ from the tree. Job files, council files and hub records are read with O_NOFOLLOW and O_NONBLOCK and size caps; nofollow.rewrite replaces a claim without creating directories, so a beat never revives a released office. 🎯 Fix: 92 % 💥 Break: 4 % 💸 Cost: 100 % ⏱️ Time: 79 % 🛡️ Security: 100 % 🏆 Score: 100 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
107 lines
4.9 KiB
JavaScript
107 lines
4.9 KiB
JavaScript
import {spawn} from "node:child_process";
|
|
import {mkdtempSync, readFileSync, rmSync, writeFileSync} from "node:fs";
|
|
import {tmpdir} from "node:os";
|
|
import {join} from "node:path";
|
|
|
|
// Args: <chromium binary> <plan.json>; the plan lists steps {width, height, url, wait, keys, probe, shot, media}, keys
|
|
// being real key presses (Enter, Tab) on the focused element before the probe, and an optional
|
|
// authenticator {credentialId, privateKey, rpId}: base64 id and PKCS#8 key of a passkey the page may sign with.
|
|
// Prints {results, errors}: one probe value per step and every uncaught page exception.
|
|
const [binary, planFile] = process.argv.slice(2);
|
|
const plan = JSON.parse(readFileSync(planFile, "utf8"));
|
|
const profile = mkdtempSync(join(tmpdir(), "cdp-"));
|
|
// --no-sandbox: the agent sandbox already forbids the user namespaces Chromium's own sandbox needs.
|
|
// --enable-unsafe-swiftshader: without a GPU, headless Chromium gives WebGL only through SwiftShader, which it no longer enables by itself.
|
|
const flags = ["--headless", "--no-sandbox", "--disable-gpu", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--no-first-run", "--no-default-browser-check", "--hide-scrollbars", `--user-data-dir=${profile}`, "--remote-debugging-port=0", "about:blank"];
|
|
const browser = spawn(binary, flags, {stdio: ["ignore", "ignore", "pipe"]});
|
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
const KEYS = {Enter: [13, "\r"], Tab: [9, ""]};
|
|
|
|
const address = await new Promise((resolve, reject) => {
|
|
let text = "";
|
|
const timer = setTimeout(() => reject(new Error(`no DevTools address: ${text.slice(-500)}`)), 30000);
|
|
browser.stderr.on("data", (chunk) => {
|
|
text += chunk;
|
|
const found = /DevTools listening on (ws:\/\/\S+)/.exec(text);
|
|
if (found) {
|
|
clearTimeout(timer);
|
|
resolve(found[1]);
|
|
}
|
|
});
|
|
browser.on("exit", (code) => reject(new Error(`browser exited with ${code}: ${text.slice(-500)}`)));
|
|
});
|
|
|
|
const socket = new WebSocket(address);
|
|
await new Promise((resolve, reject) => {
|
|
socket.onopen = resolve;
|
|
socket.onerror = reject;
|
|
});
|
|
const waiting = new Map();
|
|
const errors = [];
|
|
let next = 0;
|
|
socket.onmessage = (event) => {
|
|
const data = JSON.parse(event.data);
|
|
if (data.method === "Runtime.exceptionThrown") {
|
|
const details = data.params.exceptionDetails;
|
|
errors.push(details.exception ? details.exception.description : details.text);
|
|
}
|
|
if (data.id && waiting.has(data.id)) {
|
|
const {resolve, reject} = waiting.get(data.id);
|
|
waiting.delete(data.id);
|
|
if (data.error) {
|
|
reject(new Error(JSON.stringify(data.error)));
|
|
} else {
|
|
resolve(data.result);
|
|
}
|
|
}
|
|
};
|
|
|
|
function send(method, params, sessionId) {
|
|
next += 1;
|
|
const id = next;
|
|
socket.send(JSON.stringify({id, method, params, ...(sessionId ? {sessionId} : {})}));
|
|
return new Promise((resolve, reject) => waiting.set(id, {resolve, reject}));
|
|
}
|
|
|
|
const results = [];
|
|
try {
|
|
const {targetId} = await send("Target.createTarget", {url: "about:blank"});
|
|
const {sessionId} = await send("Target.attachToTarget", {targetId, flatten: true});
|
|
const page = (method, params) => send(method, params, sessionId);
|
|
await page("Runtime.enable", {});
|
|
if (plan.authenticator) {
|
|
await page("WebAuthn.enable", {enableUI: false});
|
|
const {authenticatorId} = await page("WebAuthn.addVirtualAuthenticator", {options: {protocol: "ctap2", transport: "internal", hasResidentKey: true, hasUserVerification: true, isUserVerified: true, automaticPresenceSimulation: true}});
|
|
await page("WebAuthn.addCredential", {authenticatorId, credential: {...plan.authenticator, isResidentCredential: false, signCount: 0}});
|
|
}
|
|
for (const step of plan.steps) {
|
|
await page("Emulation.setDeviceMetricsOverride", {width: step.width, height: step.height, deviceScaleFactor: 1, mobile: false});
|
|
await page("Emulation.setEmulatedMedia", {features: step.media || []});
|
|
if (step.url) {
|
|
await page("Page.navigate", {url: step.url});
|
|
}
|
|
await sleep(step.wait);
|
|
for (const key of step.keys || []) {
|
|
const [code, text] = KEYS[key];
|
|
await page("Input.dispatchKeyEvent", {type: "keyDown", key, code: key, windowsVirtualKeyCode: code, text});
|
|
await page("Input.dispatchKeyEvent", {type: "keyUp", key, code: key, windowsVirtualKeyCode: code});
|
|
await sleep(250);
|
|
}
|
|
let value = null;
|
|
if (step.probe) {
|
|
const {result, exceptionDetails} = await page("Runtime.evaluate", {expression: step.probe, awaitPromise: true, returnByValue: true});
|
|
value = exceptionDetails ? {error: exceptionDetails.exception ? exceptionDetails.exception.description : exceptionDetails.text} : result.value;
|
|
}
|
|
if (step.shot) {
|
|
const {data} = await page("Page.captureScreenshot", {format: "png"});
|
|
writeFileSync(step.shot, Buffer.from(data, "base64"));
|
|
}
|
|
results.push(value);
|
|
}
|
|
} finally {
|
|
socket.close();
|
|
browser.kill();
|
|
rmSync(profile, {recursive: true, force: true});
|
|
}
|
|
console.log(JSON.stringify({results, errors}));
|