Agent Harness
Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
// Sustained frame pacing at 1280 x 720 with no screenshot in the window: a scripted battle that keeps casting
// whenever the hero is free, sampled from rAF timestamps. Prints what the counter and the raw timeline say.
const { chromium } = require("playwright-core");
const RUN_MS = 20000;
(async () => {
const browser = await chromium.launch({ channel: "chrome", args: ["--force-device-scale-factor=1", "--enable-gpu-rasterization", "--ignore-gpu-blocklist"] });
const page = await browser.newPage({ viewport: { width: 1280, height: 720 }, deviceScaleFactor: 1 });
await page.addInitScript(() => {
window.__frames = [];
let prev = 0;
const tick = (t) => { if (prev) window.__frames.push(t - prev); prev = t; requestAnimationFrame(tick); };
requestAnimationFrame(tick);
});
const errs = [];
page.on("pageerror", (e) => errs.push(e.message));
page.on("console", (m) => m.type() === "error" && errs.push(m.text()));
await page.goto("http://localhost:5173/arena/", { waitUntil: "networkidle" });
await page.waitForTimeout(1500);
// the battle driver: cast whatever is free, in a rotation that keeps several effects on screen at once
const result = await page.evaluate(async (RUN_MS) => {
const a = window.__arena;
a.reset();
window.__frames.length = 0;
const order = [0, 1, 2, 3, 4];
let i = 0;
const t0 = performance.now();
const costs = [], hud = [], worst = [];
while (performance.now() - t0 < RUN_MS) {
if (a.phase !== "fight") a.reset();
if (!a.locked) a.cast(order[i++ % order.length]);
await new Promise((r) => requestAnimationFrame(r));
if ((i & 15) === 0) { costs.push(a.cost); hud.push(a.fps); worst.push(a.worst); }
}
const f = window.__frames.slice().sort((x, y) => x - y);
const at = (q) => f[Math.min(f.length - 1, Math.floor(f.length * q))];
const med = (xs) => xs.slice().sort((x, y) => x - y)[xs.length >> 1];
return {
frames: f.length,
fps: { p50: +(1000 / at(0.5)).toFixed(2), p95: +(1000 / at(0.95)).toFixed(2), p99: +(1000 / at(0.99)).toFixed(2), min: +(1000 / f[f.length - 1]).toFixed(2) },
ms: { p50: +at(0.5).toFixed(2), p95: +at(0.95).toFixed(2), max: +f[f.length - 1].toFixed(2), over20: f.filter((x) => x > 20).length, over33: f.filter((x) => x > 33).length },
cost: { step: +med(costs.map((c) => c.step)).toFixed(3), draw: +med(costs.map((c) => c.draw)).toFixed(3), present: +med(costs.map((c) => c.present)).toFixed(3) },
hudFps: { min: Math.min(...hud).toFixed(1), med: med(hud).toFixed(1), max: Math.max(...hud).toFixed(1) },
hudWorst: Math.min(...worst),
};
}, RUN_MS);
console.log(JSON.stringify(result, null, 2));
console.log("errors:", errs.length ? errs.join(" | ") : "(none)");
await browser.close();
})();