Accessibility-first browser & computer use for AI agents — one MCP server for every harness (Codex, Claude Code, OpenCode, Antigravity). Instruments the DOM/accessibility tree via CDP instead of screenshot loops: diffed snapshots, stable element refs, trusted input, typed errors. Zero dependencies
JavaScript agentic-automationai-agentsbrowser-automationbrowser-usecdpchrome-devtools-protocolcomputer-usecuamcpmodel-context-protocolrpaweb-automation
Bug fixes
soloratechdb49e977594c
diff --git a/src/core/controller.js b/src/core/controller.jsindex 719561e..2a253d6 100644--- a/src/core/controller.js+++ b/src/core/controller.js@@ -527,6 +527,7 @@ export class Controller {let tab;try {tab = this.registerTab(browser, targetId, sessionId, "about:blank");+ await this.applyPersonaTimezone(tab);await this.ensureVisible(tab).catch(() => null);await this.navigateInTab(tab, url, a.settle_ms ?? 300);} catch (e) {@@ -708,8 +709,9 @@ export class Controller {if (ti?.type !== "page" || !ti.openerId) return;const opener = [...this.tabs.values()].find((t) => t.targetId === ti.openerId && t.browserId === rec.browserId);if (!opener || [...this.tabs.values()].some((t) => t.targetId === ti.targetId)) return;- const p = rec.handle.attachTab(ti.targetId).then(({ sessionId }) => {+ const p = rec.handle.attachTab(ti.targetId).then(async ({ sessionId }) => {const tab = this.registerTab(rec, ti.targetId, sessionId, ti.url || "about:blank", opener.tabId);+ await this.applyPersonaTimezone(tab);this.recordEvent(opener, "tab.opened", { tab_id: tab.tabId, url: ti.url });rec.adopted.push(tab.tabId);return tab;@@ -889,6 +891,18 @@ export class Controller {tab.offEventRouting = off;}+ /** Persona timezone on Windows. The launch sets TZ for the browser process,+ * which Linux and macOS Chrome honor but Windows Chrome ignores, so a Tokyo+ * persona silently kept the machine's clock. CDP's timezone override is the+ * cross-platform lever; it is applied where TZ is ineffective, before the+ * tab's first navigation (and on every adopted popup / OOPIF frame). */+ async applyPersonaTimezone(tab, sessionId = tab.sessionId) {+ if (process.platform !== "win32") return;+ const timezoneId = tab.browser?.persona?.timezone ?? tab.browser?.handle?.persona?.timezone;+ if (!timezoneId) return;+ try { await tab.browser.handle.conn.send("Emulation.setTimezoneOverride", { timezoneId }, sessionId); } catch { /* invalid zone ids already fail the launch check */ }+ }+/** In-flight XHR/fetch/document tracking for post-action settling. Passive:* nothing is injected into the page, only CDP Network events are counted.* AXUSE_NET_SETTLE=0 turns it off (then settling is timing-only). */@@ -964,6 +978,7 @@ export class Controller {await conn.send("Page.enable", {}, sessionId);await conn.send("Runtime.enable", {}, sessionId);await conn.send("Log.enable", {}, sessionId);+ await this.applyPersonaTimezone(tab, sessionId);// Nested cross-origin frames auto-attach within the frame session too.await conn.send("Target.setAutoAttach",{ autoAttach: true, waitForDebuggerOnStart: false, flatten: true }, sessionId);diff --git a/src/desktop/index.js b/src/desktop/index.jsindex a648ce4..c79b88d 100644--- a/src/desktop/index.js+++ b/src/desktop/index.js@@ -139,7 +139,10 @@ class WindowsDriver {/* ------------------------------------------------------------ operations */async screenInfo() {- return this.check(this.op({ op: "screen_info" }));+ const info = await this.check(this.op({ op: "screen_info" }));+ // Same field the Linux and macOS drivers report: the agent is told which+ // units x/y/w/h (and every click) are in. The script returns physical px.+ return { ...info, coordinate_space: "Windows virtual-screen physical pixels (spans all monitors; x,y is the top-left)" };}async screenshot({ x, y, w, h, budgetBytes = DEFAULT_BUDGET_BYTES, quality = 80 } = {}) {diff --git a/test/cdp.test.js b/test/cdp.test.jsindex f7b8cb2..71b94d0 100644--- a/test/cdp.test.js+++ b/test/cdp.test.js@@ -29,6 +29,10 @@ test("browser candidates cover preview channels (beta/canary) per platform", ()// Unpinned discovery tries preview channels after stable + CfT.assert.ok(all.findIndex((p) => /Chrome Beta\.app/.test(p)) > all.findIndex((p) => /Chrome for Testing\.app/.test(p)),"preview channels rank AFTER the stable automation builds");+ } else if (process.platform === "win32") {+ // Windows installs Beta under "Chrome Beta" and Canary under "Chrome SxS".+ assert.ok(browserCandidates({ browser: "chrome-beta", ignoreEnv: true }).some((p) => /Google\\Chrome Beta\\Application\\chrome\.exe$/.test(p)));+ assert.ok(browserCandidates({ browser: "chrome-canary", ignoreEnv: true }).some((p) => /Google\\Chrome SxS\\Application\\chrome\.exe$/.test(p)));} else {assert.ok(browserCandidates({ browser: "chrome-beta", ignoreEnv: true }).some((p) => /chrome-beta/i.test(p)));}diff --git a/test/managed-browser.test.js b/test/managed-browser.test.jsindex 11b059c..92a3063 100644--- a/test/managed-browser.test.js+++ b/test/managed-browser.test.js@@ -9,7 +9,7 @@ import assert from "node:assert/strict";import { deflateRawSync } from "node:zlib";import { chmodSync, existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";import { tmpdir } from "node:os";-import { join } from "node:path";+import { join, relative, sep } from "node:path";import { unzip } from "../src/core/zip.js";import { managedBinary, managedBrowserCandidates, managedVersion, resolveDownload } from "../src/core/managed-browser.js";import { browserCandidates } from "../src/core/cdp.js";@@ -106,8 +106,10 @@ test("zip: STORE and DEFLATE entries extract byte-exact, dirs created, exec bitsassert.deepEqual(readFileSync(join(dir, "chrome-linux64/chrome")), binary);assert.equal(readFileSync(join(dir, "chrome-linux64/notes.txt"), "utf8"), "hello zip");assert.equal(readFileSync(join(dir, "chrome-linux64/sub/deep.txt"), "utf8"), "nested");- assert.equal(statSync(join(dir, "chrome-linux64/chrome")).mode & 0o777, 0o755, "exec bit restored from external attrs");- assert.equal(statSync(join(dir, "chrome-linux64/sub/deep.txt")).mode & 0o777, 0o600);+ if (process.platform !== "win32") { // NTFS has no POSIX permission bits to restore+ assert.equal(statSync(join(dir, "chrome-linux64/chrome")).mode & 0o777, 0o755, "exec bit restored from external attrs");+ assert.equal(statSync(join(dir, "chrome-linux64/sub/deep.txt")).mode & 0o777, 0o600);+ }} finally {rmSync(dir, { recursive: true, force: true });}@@ -183,9 +185,13 @@ test("managed browser: install promotes, stamps, lands executable; second run shconst root = mkdtempSync(join(tmpdir(), "axuse-install-"));process.env.AXUSE_MANAGED_BROWSER_DIR = root;try {+ // The archive layout is whatever this platform's managed binary path says+ // (chrome-linux64/chrome, chrome-win64/chrome.exe, the macOS .app bundle).+ const binRel = relative(root, managedBinary(root)).split(sep).join("/");+ const top = binRel.split("/")[0];const archive = buildZip([- { name: "chrome-linux64/chrome", data: Buffer.from("#!/bin/sh\n"), mode: 0o755 },- { name: "chrome-linux64/priv.json", data: Buffer.from("{}") },+ { name: binRel, data: Buffer.from("#!/bin/sh\n"), mode: 0o755 },+ { name: `${top}/priv.json`, data: Buffer.from("{}") },]);const resolve = async () => ({ url: "injected://cft.zip", version: "151.0.0.1", platform: "linux64" });const fetchZip = async () => archive;@@ -195,7 +201,8 @@ test("managed browser: install promotes, stamps, lands executable; second run shassert.equal(r.files, 2);const bin = managedBinary(root);assert.equal(r.binary, bin);- assert.equal(statSync(bin).mode & 0o111, 0o111, "executable after promote");+ if (process.platform === "win32") assert.ok(statSync(bin).isFile(), "binary landed (NTFS has no exec bit)");+ else assert.equal(statSync(bin).mode & 0o111, 0o111, "executable after promote");assert.equal(managedVersion(root), "151.0.0.1");// Same version again → no re-download (fetchZip would throw if called).const again = await installManagedBrowser({ resolve, fetchZip: async () => { throw new Error("must not download"); } });diff --git a/test/persona-timezone.test.js b/test/persona-timezone.test.jsnew file mode 100644index 0000000..9d486e6--- /dev/null+++ b/test/persona-timezone.test.js@@ -0,0 +1,46 @@+/**+ * A persona timezone must reach the page, its web workers and its popups.+ *+ * Linux/macOS Chrome honor the TZ env the launch sets; Windows Chrome ignores+ * it, so a Tokyo persona silently kept the machine's clock (the persona tests+ * failed on Windows only). Windows now applies CDP's timezone override to every+ * tab, adopted popup and cross-origin frame. This test pins the behavior on+ * every platform.+ */+import { test } from "node:test";+import assert from "node:assert/strict";+import { createServer } from "node:http";+import { locateBrowser } from "../src/core/cdp.js";+import { Controller } from "../src/core/controller.js";++const hasBrowser = !!locateBrowser();+const PAGE = `<a id="a" target="_blank" href="/pop">open</a><script>+window.workerTz = new Promise((ok) => { const w = new Worker(URL.createObjectURL(new Blob(["postMessage(Intl.DateTimeFormat().resolvedOptions().timeZone)"]))); w.onmessage = (e) => ok(e.data); });</script>`;++test("persona timezone reaches the page, its workers and its popups", { skip: !hasBrowser ? "live-gate-browser: needs any Chromium-family browser" : false }, async (t) => {+ const srv = createServer((req, res) => { res.setHeader("content-type", "text/html"); res.end(req.url.startsWith("/pop") ? "<title>pop</title><p>popup</p>" : PAGE); });+ await new Promise((ok) => srv.listen(0, "127.0.0.1", ok));+ const c = new Controller();+ t.after(() => { c.dispose(); srv.close(); });++ // Pick a zone that cannot be the machine's own.+ const zone = Intl.DateTimeFormat().resolvedOptions().timeZone === "Asia/Tokyo" ? "America/New_York" : "Asia/Tokyo";+ const tz = (tab) => c.execute("evaluate", { tab_id: tab, expression: "Intl.DateTimeFormat().resolvedOptions().timeZone" }).then((r) => JSON.parse(r.value));+ const opened = await c.execute("open", { url: `http://127.0.0.1:${srv.address().port}/`, headless: true, timezone: zone, lang: "en-GB", settle_ms: 200 });+ const tab = opened.tab_id;++ assert.equal(await tz(tab), zone, "page clock follows the persona");+ const worker = await c.execute("evaluate", { tab_id: tab, expression: "window.workerTz" });+ assert.equal(JSON.parse(worker.value), zone, "web worker clock follows the persona");++ const ref = opened.observation.text.match(/link "open"[^\[]*\[ref=(e\d+)\]/)?.[1];+ assert.ok(ref, "popup link has a ref");+ await c.execute("click", { tab_id: tab, target: { ref }, settle_ms: 400 });+ let pop;+ for (let i = 0; i < 20 && !pop; i++) {+ pop = ((await c.execute("tabs", {})).tabs ?? []).find((x) => x.tab_id !== tab);+ if (!pop) await new Promise((r) => setTimeout(r, 150));+ }+ assert.ok(pop, "the popup was adopted as a controlled tab");+ assert.equal(await tz(pop.tab_id), zone, "popup clock follows the persona");+});diff --git a/test/server-mode.test.js b/test/server-mode.test.jsindex 14d7e9a..c8ec593 100644--- a/test/server-mode.test.js+++ b/test/server-mode.test.js@@ -56,8 +56,9 @@ test("server mode: DISPLAY parsing and dead-display detection", () => {// on hosts that carry a stale value (closed SSH forward, dead CI :99).assert.equal(displayUsable(":65530"), false); // no such X socket, ever// Injectable exists seam: a "socket" for :42 → usable- assert.equal(displayUsable(":42", { exists: (p) => /\/X42$/.test(p) }), true);- assert.equal(displayUsable(":43", { exists: (p) => /\/X42$/.test(p) }), false);+ // (the socket path uses the platform's separator, so match either)+ assert.equal(displayUsable(":42", { exists: (p) => /[\\/]X42$/.test(p) }), true);+ assert.equal(displayUsable(":43", { exists: (p) => /[\\/]X42$/.test(p) }), false);});test("server mode: the launch decision matrix is pure and typed", () => {