Agent Harness
Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
const { chromium } = require("playwright-core");
// A 60 Hz screen cannot be had here (this display runs at 144 Hz), so the headroom is shown the hard way:
// throttle the CPU 4x and see whether the counter still sits above 60.
(async () => {
const b = await chromium.launch({ channel: "chrome", args: ["--force-device-scale-factor=1"] });
const p = await b.newPage({ viewport: { width: 1280, height: 720 }, deviceScaleFactor: 1 });
const cdp = await p.context().newCDPSession(p);
await p.addInitScript(() => { window.__frames = []; let prev = 0; const t = (x) => { if (prev) window.__frames.push(x - prev); prev = x; requestAnimationFrame(t); }; requestAnimationFrame(t); });
await p.goto("http://localhost:4173/arena/", { waitUntil: "networkidle" });
await p.waitForTimeout(1500);
for (const rate of [1, 2, 4, 6]) {
await cdp.send("Emulation.setCPUThrottlingRate", { rate });
await p.waitForTimeout(600);
await p.evaluate(() => (window.__frames.length = 0));
const start = Date.now();
let i = 0;
while (Date.now() - start < 5000) {
const st = await p.evaluate(() => ({ phase: window.__arena.phase, ready: window.__arena.ready }));
if (st.phase !== "fight") await p.evaluate(() => window.__arena.reset());
if (st.ready[i % 5]) { await p.keyboard.press(`Digit${1 + (i % 5)}`); i++; }
await p.waitForTimeout(80);
}
const r = await p.evaluate(() => {
const f = window.__frames.slice().sort((a, b) => a - b), at = (q) => f[Math.floor(f.length * q)];
return { fpsP50: +(1000 / at(0.5)).toFixed(1), fpsP95: +(1000 / at(0.95)).toFixed(1), worst: +(1000 / f[f.length - 1]).toFixed(1), over20ms: f.filter((x) => x > 20).length, n: f.length, counter: Math.round(window.__arena.fps), cost: window.__arena.cost };
});
console.log(`cpu x${rate}:`, JSON.stringify(r));
}
await b.close();
})();