diff --git a/apps/server/src/browserUse/BrowserUseDriver.ts b/apps/server/src/browserUse/BrowserUseDriver.ts index 9264f56c3e..2092177cd3 100644 --- a/apps/server/src/browserUse/BrowserUseDriver.ts +++ b/apps/server/src/browserUse/BrowserUseDriver.ts @@ -9,15 +9,15 @@ import * as PinnedTool from "../tools/PinnedTool.ts"; // Update the version, sizes and hashes together from the assets of // https://github.com/aislopware/oni-browser-use/releases (tag v). -const VERSION = "4.8.1"; +export const VERSION = "4.9.0"; const BINARIES = { "darwin-arm64": { - bytes: 7_186_880, - sha256: "1e9643bd93b39e865c2fdf443194aa11e779b5349f3a68282e71a51c8e498e33", + bytes: 7_220_160, + sha256: "e84a4c47b133510c0bc82c0f54ddc05669962209b62e5e540443d9e31b77d39e", }, "linux-x64": { - bytes: 8_460_336, - sha256: "63cbac9b0a6ba5211b1949b116995b697d185c512414a68e76574484aba08dd0", + bytes: 8_504_504, + sha256: "f0a4f15c8ed9714d1d339307eda75bb6419761baf334d9629953d586c351c359", }, } as const; diff --git a/apps/server/src/browserUse/BrowserUseService.ts b/apps/server/src/browserUse/BrowserUseService.ts index d6520d09a2..3076676584 100644 --- a/apps/server/src/browserUse/BrowserUseService.ts +++ b/apps/server/src/browserUse/BrowserUseService.ts @@ -50,10 +50,10 @@ const STOP_TIMEOUT = "20 seconds"; const SHARED_ENVIRONMENT = { OBU_NO_UPDATE_CHECK: "1" }; // obu tells the agent these in place of its own guess that an attached browser is the user's. // The personal browser needs none: that guess is right there. -const PANEL_NOTE = - "Use these tools for browser work: they drive your tab in Onicode's Browser panel, which the user watches."; -const ISOLATED_NOTE = - "Use these tools for browser work: they drive a Chrome of your own, which the user cannot see."; +export const PANEL_NOTE = + "Use these tools for browser work, in place of starting a browser of your own: they drive a tab of your own in Onicode's Browser panel, where the user can watch. It is not the user's own browser, so a task that names theirs is not for these tools. It opens http and https pages only: for a local file, serve its folder over http, as with `python3 -m http.server`, and open that address."; +export const ISOLATED_NOTE = + "Use these tools for browser work, in place of starting a browser of your own: they drive a Chrome of your own, which the user cannot see. It is not the user's own browser, so a task that names theirs is not for these tools."; const RealBrowserConfig = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown)); const decodeRealBrowserConfig = Schema.decodeUnknownOption(RealBrowserConfig); diff --git a/apps/server/src/preview/PreviewCdpBridge.test.ts b/apps/server/src/preview/PreviewCdpBridge.test.ts index b4670f33f2..58764dd102 100644 --- a/apps/server/src/preview/PreviewCdpBridge.test.ts +++ b/apps/server/src/preview/PreviewCdpBridge.test.ts @@ -168,7 +168,10 @@ it.live("serves a thread's panel tabs as a debug endpoint only its driver can re }); expect(yield* page.call(4, "Page.navigate", { url: "file:///etc/passwd" })).toMatchObject({ id: 4, - error: { message: "The Browser panel opens http and https pages only." }, + error: { + message: + "The Browser panel opens http and https pages only. To open a local file, serve its folder over http, as with `python3 -m http.server`, and open that address.", + }, }); expect(yield* page.call(5, "Target.getTargets")).toMatchObject({ id: 5, diff --git a/apps/server/src/preview/PreviewCdpBridge.ts b/apps/server/src/preview/PreviewCdpBridge.ts index 01011bd2ff..b3b9db4d50 100644 --- a/apps/server/src/preview/PreviewCdpBridge.ts +++ b/apps/server/src/preview/PreviewCdpBridge.ts @@ -25,6 +25,8 @@ import { cdpErrorMessage, driverTargetId, isPanelUrl, + PANEL_URL_REQUIRED, + pageCommandParams, routePageCommand, } from "./previewCdpPolicy.ts"; import * as ServerBrowser from "./ServerBrowser.ts"; @@ -90,7 +92,6 @@ const HOST = "127.0.0.1"; const ENDPOINT_PATH = /^\/k\/([A-Za-z0-9_-]+)(\/.*)$/; const BROWSER_SOCKET = "/devtools/browser/onicode"; const PAGE_SOCKET = "/devtools/page/"; -const PANEL_URL_REQUIRED = "The Browser panel opens http and https pages only."; const textDecoder = new TextDecoder(); const stringField = (value: unknown, field: string) => @@ -244,7 +245,7 @@ const make = Effect.gen(function* () { return Effect.fail(new CommandRefused({ message: PANEL_URL_REQUIRED })); } return Effect.tryPromise({ - try: () => driver.send(command.method, command.params ?? {}), + try: () => driver.send(command.method, pageCommandParams(command.method, command.params)), catch: (cause) => new CommandRefused({ message: cdpErrorMessage(cause) }), }); } diff --git a/apps/server/src/preview/ServerBrowser.test.ts b/apps/server/src/preview/ServerBrowser.test.ts index 7a9d0a3da9..f28a1ced1f 100644 --- a/apps/server/src/preview/ServerBrowser.test.ts +++ b/apps/server/src/preview/ServerBrowser.test.ts @@ -969,12 +969,25 @@ it.effect("a tab the desktop does not draw is marked headless, so the desktop st operation: "open", input: { reuseExistingTab: false, show: false }, }); + // A hidden window: the desktop mounts the agent's tab, but its page answers no capture. + desktopRendersNext = true; + heldStill = () => Promise.reject(new Error("No frame")); + const hiddenTab = yield* broker.invoke({ + scope, + operation: "open", + input: { reuseExistingTab: false, show: false }, + }); + heldStill = null; const { sessions } = yield* manager.list({ threadId: scope.thread.threadId }); const headlessOf = (id: string | null) => sessions.find((session) => session.tabId === id)?.headless; expect(headlessOf(tabId)).toBe(true); expect(headlessOf(desktopTab.tabId)).toBeUndefined(); + expect(headlessOf(hiddenTab.tabId)).toBe(true); + expect(desktopConnections.map(({ browser }) => browser.close.mock.calls.length)).toEqual([ + 0, 1, + ]); }), ).pipe(Effect.provide(layer)), ); @@ -4250,6 +4263,63 @@ it.effect("an agent's own driver works its tab's page until a human takes contro ["mouseReleased", 5], ]); + // A capture's size goes to the page the way a resize does, since Playwright holds its metrics. + const { page } = contexts[0]!; + const sized = () => + driver.send("Emulation.setDeviceMetricsOverride", { + width: 1920, + height: 1080, + deviceScaleFactor: 1, + mobile: false, + }); + // A driver pipelines: the clear that follows a set undoes it, however long the set takes. + page.setViewportSize.mockClear(); + yield* Effect.promise(() => + Promise.all([sized(), driver.send("Emulation.clearDeviceMetricsOverride", undefined)]), + ); + const widths = page.setViewportSize.mock.calls.map(([size]) => size?.width); + expect([widths[0], widths.at(-1)]).toEqual([1920, 1280]); + yield* Effect.promise(sized); + expect(page.setViewportSize).toHaveBeenLastCalledWith({ width: 1920, height: 1080 }); + + // A driver that leaves while the page has not answered its size change: the wait is + // bounded, and the page has its own size back before the session detaches, since a clear + // sent after that reaches no page. + const left = Promise.withResolvers(); + vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] }); + let unanswered: Promise = Promise.resolve("never sent"); + yield* Effect.scoped( + Effect.gen(function* () { + const leaving = yield* drivers.attach({ + threadId, + tabId, + agentSessionId, + onEvent: () => {}, + }); + contexts[0]!.sessions + .at(-1)! + .detach.mockImplementation(async () => + left.resolve(page.setViewportSize.mock.lastCall?.[0]), + ); + page.setViewportSize.mockImplementationOnce(() => new Promise(() => {})); + unanswered = leaving + .send("Emulation.setDeviceMetricsOverride", { width: 390, height: 844 }) + .then(String, String); + }), + ); + yield* Effect.promise(() => vi.advanceTimersByTimeAsync(5_000)); + expect(yield* Effect.promise(() => unanswered)).toContain("did not answer a size change"); + expect(yield* Effect.promise(() => left.promise)).toEqual({ width: 1280, height: 800 }); + // A pointer move the page never answers holds the command behind it that long and no more. + session.send.mockImplementationOnce(() => new Promise(() => {})); + yield* Effect.promise(() => mouse("mouseMoved", 9)); + const behind = driver.send("Runtime.evaluate", { expression: "2" }); + yield* Effect.promise(() => vi.advanceTimersByTimeAsync(5_000)); + yield* Effect.promise(() => behind); + expect(session.send).toHaveBeenLastCalledWith("Runtime.evaluate", { expression: "2" }); + vi.useRealTimers(); + yield* Effect.promise(sized); + const viewer = yield* browser.attachViewer(viewerInput(tabId, true)); yield* viewer.input({ type: "takeControl" }); const refused = yield* Effect.promise(() => @@ -4260,13 +4330,129 @@ it.effect("an agent's own driver works its tab's page until a human takes contro ); expect(refused).toMatchObject({ reason: "humanControl" }); expect(session.send).not.toHaveBeenCalledWith("Input.dispatchKeyEvent", expect.anything()); + // The page gets its own size back even while the human holds it. + yield* Effect.promise(() => driver.send("Emulation.clearDeviceMetricsOverride", undefined)); + expect(page.setViewportSize).toHaveBeenLastCalledWith({ width: 1280, height: 800 }); + expect(session.send).not.toHaveBeenCalledWith( + expect.stringContaining("DeviceMetricsOverride"), + expect.anything(), + ); contexts[0]!.page.emit("close"); yield* Effect.promise(() => driver.closed); // A browser that has stopped answering must not hold the driver's release, or shutdown. session.detach.mockReturnValue(new Promise(() => {})); }), - ).pipe(Effect.provide(layer)), + ).pipe(Effect.ensuring(Effect.sync(() => vi.useRealTimers())), Effect.provide(layer)), +); + +it.effect("a driver's captures of a desktop tab take their turn with its size changes", () => + Effect.scoped( + Effect.gen(function* () { + const { broker } = yield* ready; + const drivers = yield* ServerBrowser.ServerBrowserDrivers; + desktopRendersNext = true; + const opened = yield* broker.invoke({ + scope, + operation: "open", + input: { reuseExistingTab: false, show: false }, + }); + const driver = yield* drivers.attach({ + threadId: scope.thread.threadId, + tabId: PreviewTabId.make(opened.tabId!), + agentSessionId: Broker.hostAssignmentKey(scope), + onEvent: () => {}, + }); + const session = desktopConnections[0]!.context.sessions.at(-1)!; + const sent = () => + session.send.mock.calls.flatMap(([method, input]) => + method === "Page.captureScreenshot" + ? ["capture"] + : method === "Emulation.setDeviceMetricsOverride" + ? [`set ${(input as { width: number }).width}`] + : method === "Emulation.clearDeviceMetricsOverride" + ? ["clear"] + : [], + ); + const size = (width: number) => + driver.send("Emulation.setDeviceMetricsOverride", { width, height: 1080 }); + const shot = () => + driver.send("Page.captureScreenshot", { format: "png" }).then(() => "captured", String); + const clear = () => driver.send("Emulation.clearDeviceMetricsOverride", undefined); + + // A driver pipelines: the capture is taken at the size set before it, not after the clear + // behind it. The first capture is the server's own, measuring what the page paints. + yield* Effect.promise(() => Promise.all([size(1920), shot(), clear()])); + expect(sent()).toEqual(["capture", "set 1920", "capture", "clear"]); + + // A capture the page answers too late: Chromium then puts back the size that capture + // began at, so no other is taken until it has answered and the size is repaired. + vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] }); + yield* Effect.promise(() => size(1920)); + const late = Promise.withResolvers>(); + session.send.mockImplementationOnce(() => late.promise); + const missed = shot(); + yield* Effect.promise(() => vi.advanceTimersByTimeAsync(3_000)); + expect(yield* Effect.promise(() => missed)).toContain("not producing screenshot frames"); + // A clear partway through that capture costs Chromium the size to go back to, so it is + // left to the repair, and the driver hears when the capture has not answered by then. + session.send.mockClear(); + const leftSized = clear().then(() => "cleared", String); + yield* Effect.promise(() => vi.advanceTimersByTimeAsync(5_000)); + expect(yield* Effect.promise(() => leftSized)).toContain("did not answer a size change"); + yield* Effect.promise(() => size(390)); + expect(yield* Effect.promise(shot)).toContain("not producing screenshot frames"); + expect(sent()).toEqual(["set 390"]); + + const repaired = Promise.withResolvers(); + const answer = session.send.getMockImplementation()!; + session.send.mockImplementation(async (method, input) => { + const result = await answer(method, input); + if (method === "Emulation.setDeviceMetricsOverride") repaired.resolve(); + return result; + }); + session.send.mockClear(); + late.resolve({ data: "ZnJhbWU=" }); + yield* Effect.promise(() => repaired.promise); + expect(yield* Effect.promise(shot)).toBe("captured"); + expect(sent()).toEqual(["set 390", "capture"]); + + // A repair the page refuses leaves its size unknown: no capture until the driver's next + // size change lands. + const again = Promise.withResolvers>(); + session.send.mockImplementationOnce(() => again.promise); + const missedAgain = shot(); + yield* Effect.promise(() => vi.advanceTimersByTimeAsync(3_000)); + expect(yield* Effect.promise(() => missedAgain)).toContain("not producing screenshot frames"); + const refusedRepair = Promise.withResolvers(); + let refuse = true; + session.send.mockImplementation(async (method, input) => { + if (method !== "Emulation.setDeviceMetricsOverride" || !refuse) + return answer(method, input); + refuse = false; + refusedRepair.resolve(); + throw new Error("No page"); + }); + again.resolve({ data: "ZnJhbWU=" }); + yield* Effect.promise(() => refusedRepair.promise); + expect(yield* Effect.promise(shot)).toContain("not producing screenshot frames"); + yield* Effect.promise(() => size(390)); + expect(yield* Effect.promise(shot)).toBe("captured"); + + // A clear behind a late capture is sent once that capture has answered, and only then. + session.send.mockImplementation(answer); + const last = Promise.withResolvers>(); + session.send.mockImplementationOnce(() => last.promise); + const missedLast = shot(); + yield* Effect.promise(() => vi.advanceTimersByTimeAsync(3_000)); + expect(yield* Effect.promise(() => missedLast)).toContain("not producing screenshot frames"); + session.send.mockClear(); + const handedBack = clear(); + last.resolve({ data: "ZnJhbWU=" }); + yield* Effect.promise(() => handedBack); + expect(sent()).toEqual(["clear"]); + }), + ).pipe(Effect.ensuring(Effect.sync(() => vi.useRealTimers())), Effect.provide(layer)), ); it.live("a page's title change without navigation reaches its session", () => diff --git a/apps/server/src/preview/ServerBrowser.ts b/apps/server/src/preview/ServerBrowser.ts index ebe83cf4a7..f07659b163 100644 --- a/apps/server/src/preview/ServerBrowser.ts +++ b/apps/server/src/preview/ServerBrowser.ts @@ -124,6 +124,7 @@ const AGENT_CURSOR_MOVE_MS = 160; const AGENT_CURSOR_CLICK_LEAD_MS = 40; /** How long a driver's pointer rests before the page is told where it stopped. */ const DRIVER_POINTER_REST_MS = 40; +const DRIVER_SIZING_TIMEOUT_MS = 5_000; /** A dialog blocks page script, so a desktop size read gives up after this. */ const DESKTOP_VIEWPORT_READ_TIMEOUT = "1 second"; /** A desktop page that keeps its size draws nothing on a resize, so the wait gives up. */ @@ -1149,11 +1150,25 @@ const make = Effect.gen(function* () { ): Promise => { const adopted = adoptedPages.get(tabKey(snapshot.threadId, snapshot.tabId)); adoptedPages.delete(tabKey(snapshot.threadId, snapshot.tabId)); - const desktop = + let desktop = adopted === undefined && (await desktopRenders(snapshot)) ? await connectDesktop(snapshot) : null; if (desktop) opened.push(desktop.close); + let desktopCdp = desktop ? await desktop.page.context().newCDPSession(desktop.page) : null; + // An agent captures its tab with nobody at the desktop. A window that is hidden or covered + // paints no frame for it, so the server runs such a tab itself, as it does with no desktop. + if ( + desktop && + desktopCdp && + snapshot.automationOwner !== undefined && + !(await ServerBrowserPage.paints(desktopCdp)) + ) { + opened.pop(); + await desktop.close().catch(constVoid); + desktop = null; + desktopCdp = null; + } // Attaching over CDP emulates a light scheme; a tab on System follows the desktop's. if (desktop) await desktop.page.emulateMedia({ colorScheme: null }); // Otherwise a desktop that attaches late, or has no channel to draw it, shows its own page. @@ -1181,7 +1196,7 @@ const make = Effect.gen(function* () { if (!desktop) await prepareContext(context); const page = adopted?.page ?? desktop?.page ?? (await context.newPage()); if (!desktop) opened.push(() => page.close()); - const cdp = await context.newCDPSession(page); + const cdp = desktopCdp ?? (await context.newCDPSession(page)); await installPdfDocumentNavigation(cdp); // The desktop's page is already a normal browser. A popup's first request // precedes this override, so its Sec-CH-UA brands still name HeadlessChrome. @@ -3597,6 +3612,7 @@ const make = Effect.gen(function* () { "ServerBrowser.attachDriver", )(function* (input) { const tab = yield* findTab(input.threadId, input.tabId); + let beforeDetach: () => Promise = () => Promise.resolve(); const session = yield* Effect.acquireRelease( Effect.tryPromise({ try: () => tab.page.context().newCDPSession(tab.page), @@ -3604,7 +3620,14 @@ const make = Effect.gen(function* () { }), // Not awaited: at shutdown the browser stops answering before a driver's socket closes, // and waiting on a detach it never answers would keep the server from exiting. - (session) => Effect.sync(() => void session.detach().catch(constVoid)), + (session) => + Effect.sync( + () => + void beforeDetach() + .catch(constVoid) + .then(() => session.detach()) + .catch(constVoid), + ), ); // Playwright subscribes to CDP events by name; a driver needs every one its session enabled. const emitter = session as unknown as { @@ -3620,6 +3643,17 @@ const make = Effect.gen(function* () { tab.driverClosers.add(close); yield* Effect.addFinalizer(() => Effect.sync(() => tab.driverClosers.delete(close))); if (tab.closing) close(); + // A page that never answers must not hold the commands behind this one, or the detach. + const answered = (change: Promise, what = "a size change") => { + let timer: ReturnType | undefined; + const late = new Promise((_, reject) => { + timer = setTimeout( + () => reject(new Error(`The page did not answer ${what} in time.`)), + DRIVER_SIZING_TIMEOUT_MS, + ); + }); + return Promise.race([change, late]).finally(() => clearTimeout(timer)); + }; const pointer = pointerFor(tab); // A driver walks the pointer to its target in many small moves, and Chromium answers each // on the page's next frame. A tab nobody watches paints a few frames a second, so the walk @@ -3638,30 +3672,147 @@ const make = Effect.gen(function* () { dropTravel(); // The page may be gone by now; the command that needed the pointer there reports that. arrived = arrived - .then(() => session.send("Input.dispatchMouseEvent", params as never)) + .then(() => + answered(session.send("Input.dispatchMouseEvent", params as never), "a pointer move"), + ) .then(constVoid, constVoid); return arrived; }; yield* Effect.addFinalizer(() => Effect.sync(dropTravel)); + // A driver sizes the page for one capture with a metrics override, then clears it. The + // panel's own viewport setting stays as it was, so nothing the user chose changes. + let override: { readonly params: unknown } | null = null; + let stale = false; + let painted: { readonly width: number; readonly height: number } | null = null; + // One at a time: a driver pipelines, so a clear can arrive while its set still measures or + // while a capture is partway through its tiles. + let sizing: Promise = Promise.resolve(); + const inTurn = (change: () => Promise) => { + const turn = sizing.then(change); + sizing = turn.catch(constVoid); + return turn; + }; + // Captures that missed their deadline and are not answered yet. Chromium puts back the size + // such a capture began at when it answers, which leaves the page's size `stale` until the + // driver's own is applied again. No other capture is taken in either state. + let unanswered = 0; + let repaired: Promise = Promise.resolve(); + const repairAfter = (answer: Promise) => { + unanswered += 1; + repaired = answer.then(() => + inTurn(async () => { + unanswered -= 1; + stale = true; + await answered( + override === null + ? session.send("Emulation.clearDeviceMetricsOverride") + : session.send("Emulation.setDeviceMetricsOverride", override.params as never), + ); + if (override === null) painted = null; + stale = false; + }), + ); + repaired.catch(constVoid); + }; + const restoreViewport = async () => { + const left = await inTurn(async () => { + // Chromium forgets the size to go back to when a clear arrives partway through a + // capture, so the clear is left to that capture's repair. + if (unanswered > 0) { + override = null; + return { repaired }; + } + if (override === null && !stale) return null; + // Playwright holds a headless page's viewport; a desktop page takes its webview's size. + await answered( + tab.desktop + ? session.send("Emulation.clearDeviceMetricsOverride") + : applySetting(tab, tab.setting), + ); + // Only now: a clear that failed is tried again by the next one, or on detach. + override = null; + painted = null; + stale = false; + return null; + }); + // Outside the turn, which the repair needs. A capture that never answers leaves the page + // sized, and the driver is told so. + if (left !== null) await answered(left.repaired); + }; + // The session detaches behind it: a clear sent after the detach reaches no page. + beforeDetach = restoreViewport; + const refusal = () => + !tab.control.agentMayAct(input.agentSessionId) + ? new BrowserControlInterrupted({ + message: "This tab belongs to another agent session. Open your own tab to act.", + reason: "agentMismatch", + }) + : tab.control.controller !== null + ? new BrowserControlInterrupted({ + message: "A human controls this tab.", + reason: "humanControl", + }) + : null; return { closed: closed.promise, // Unqueued: a driver pipelines commands, and one that waits on the page must not hold // back the input that page waits for. Control is checked per command instead. send: async (method, params) => { - const refusal = !tab.control.agentMayAct(input.agentSessionId) - ? new BrowserControlInterrupted({ - message: "This tab belongs to another agent session. Open your own tab to act.", - reason: "agentMismatch", - }) - : tab.control.controller !== null - ? new BrowserControlInterrupted({ - message: "A human controls this tab.", - reason: "humanControl", - }) - : null; - if (refusal !== null) { + // Giving the page its size back is no action on it, so a human's hold does not stop it. + if (method === "Emulation.clearDeviceMetricsOverride") { + await restoreViewport(); + return {}; + } + const refused = refusal(); + if (refused !== null) { dropTravel(); - throw refusal; + throw refused; + } + // Before anything this awaits, so a set keeps its place ahead of the clear behind it. + if (method === "Emulation.setDeviceMetricsOverride") { + const size = asRecord(params); + tab.usedAt = Date.now(); + return inTurn(async () => { + // Read before the override: under it a plain capture is as large as the emulated page. + if (tab.desktop && painted === null) { + painted = await ServerBrowserPage.paintedSize(session); + } + // A human may have taken the tab while this waited its turn. + const taken = refusal(); + if (taken !== null) throw taken; + override = { params }; + if (tab.desktop) { + const sized = await answered(session.send(method, params as never)); + stale = false; + return sized; + } + // Playwright holds a headless page's metrics and would not notice another session's, + // so the page takes the size the way the panel's own resize gives it one. + await answered( + tab.page.setViewportSize({ width: num(size?.width), height: num(size?.height) }), + ); + return {}; + }); + } + // In turn as well, and before anything this awaits: a clear behind a capture must not + // resize the page under it or between two of its tiles. + if (method === "Page.captureScreenshot" && tab.desktop) { + tab.usedAt = Date.now(); + return inTurn(async () => { + await arrive(); + const taken = refusal(); + if (taken !== null) throw taken; + if (unanswered > 0 || stale) throw ServerBrowserPage.noFrames(); + const measured = painted; + return ServerBrowserPage.carried( + await ServerBrowserPage.captureDesktopPage( + session, + asRecord(params) ?? {}, + async () => measured ?? ServerBrowserPage.paintedSize(session), + repairAfter, + ), + ); + }); } const mouse = method === "Input.dispatchMouseEvent" ? asRecord(params) : null; // A drag's path is the gesture itself, so moves with a button down all reach the page. @@ -3679,6 +3830,9 @@ const make = Effect.gen(function* () { } else if (mouse?.type === "mouseReleased") { buttonsDown = Math.max(0, buttonsDown - 1); } + if (method === "Page.captureScreenshot") { + return ServerBrowserPage.carried(await session.send(method, params as never)); + } return session.send(method as never, params as never); }, }; diff --git a/apps/server/src/preview/ServerBrowserPage.test.ts b/apps/server/src/preview/ServerBrowserPage.test.ts index 7e1c24e4cc..854c08b8a1 100644 --- a/apps/server/src/preview/ServerBrowserPage.test.ts +++ b/apps/server/src/preview/ServerBrowserPage.test.ts @@ -18,6 +18,7 @@ import { vi, } from "vite-plus/test"; +import { decodePng } from "./pngTiles.ts"; import * as ServerBrowserPage from "./ServerBrowserPage.ts"; import { SessionControl } from "./SessionControl.ts"; @@ -687,6 +688,46 @@ describe("server browser snapshot screenshot", () => { }); }); + it("joins the tiles of a region larger than a desktop page paints into the same pixels", async () => { + const page = await context.newPage(); + await page.setContent(halves("")); + const cdp = await context.newCDPSession(page); + const params = { + format: "png", + clip: { x: 320, y: 200, width: 640, height: 400, scale: 1 }, + } as const; + const rgb = (data: string) => { + const image = decodePng(Buffer.from(data, "base64")); + const size = [image.width, image.height]; + if (image.channels === 3) return { size, pixels: image.data }; + return { size, pixels: Buffer.from(image.data.filter((_, index) => index % 4 !== 3)) }; + }; + const send = vi.spyOn(cdp, "send"); + + const painted = async () => ({ width: 500, height: 300 }); + const joined = await ServerBrowserPage.captureDesktopPage(cdp, params, painted, () => {}); + const tiles = send.mock.calls.filter(([method]) => method === "Page.captureScreenshot"); + const whole = await cdp.send("Page.captureScreenshot", params); + + expect(tiles).toHaveLength(9); + expect(rgb(joined.data).size).toEqual([1280, 800]); + expect(rgb(joined.data).pixels.equals(rgb(whole.data).pixels)).toBe(true); + // A region whose pixels the server cannot hold whole is refused before any tile is taken. + await expect( + ServerBrowserPage.captureDesktopPage( + cdp, + { format: "png", clip: { x: 0, y: 0, width: 8192, height: 8192, scale: 1 } }, + painted, + () => {}, + ), + ).rejects.toThrow("at most 40 megapixels"); + // A reply the driver's connection would close on is refused, not sent. + expect(ServerBrowserPage.carried(joined, joined.data.length)).toBe(joined); + expect(() => ServerBrowserPage.carried(joined, joined.data.length - 1)).toThrow( + "more than the driver's connection carries", + ); + }); + it("records the destination of a finite entrance animation without waiting on infinite ones", async () => { const page = await context.newPage(); await page.setContent(` diff --git a/apps/server/src/preview/ServerBrowserPage.ts b/apps/server/src/preview/ServerBrowserPage.ts index 5808bae052..85969d244d 100644 --- a/apps/server/src/preview/ServerBrowserPage.ts +++ b/apps/server/src/preview/ServerBrowserPage.ts @@ -25,6 +25,7 @@ import * as Schema from "effect/Schema"; import type { CDPSession, ConsoleMessage, Frame, Locator, Page } from "playwright-core"; import * as NodeCrypto from "node:crypto"; import * as NodeUtil from "node:util"; +import { type CaptureClip, joinTiles, tileClip } from "./pngTiles.ts"; import { BrowserControlInterrupted } from "./SessionControl.ts"; const isBrowserControlInterrupted = Schema.is(BrowserControlInterrupted); @@ -549,36 +550,146 @@ const readPageMetrics = async (cdp: CDPSession) => { ); }; +// Hidden native guests can leave CDP captures pending forever. This deadline also +// releases a viewer's still-capture lock, which an agent snapshot may be waiting for. +const NO_FRAMES = + "The browser is not producing screenshot frames. For a desktop tab the Onicode window is hidden: close the tab and open the page in a new one, which captures without the window."; + +/** What a capture of a page that paints nothing fails with. */ +export const noFrames = (message = NO_FRAMES) => + new ServerBrowserOperationError({ tag: "PreviewAutomationExecutionError", message }); + +/** `onExpired` is handed a promise that settles once the abandoned work is answered after all. */ +const withinFrameDeadline = ( + capture: Promise, + onExpired?: (answered: Promise) => void, + message = NO_FRAMES, +) => { + let timer: ReturnType | undefined; + const expired = new Promise((_, reject) => { + timer = setTimeout(() => { + onExpired?.(capture.then(constVoid, constVoid)); + reject(noFrames(message)); + }, SCREENSHOT_TIMEOUT_MS); + }); + return Promise.race([capture, expired]).finally(() => clearTimeout(timer)); +}; + +// A page whose script is busy answers no read. A capture waits its turn behind this one. +const measuredForCapture = (cdp: CDPSession) => + withinFrameDeadline( + readPageMetrics(cdp), + undefined, + "The page did not answer in time to be measured for a capture. Try again once it is idle.", + ); + // Never pass a clip scale: Chromium mirrors the top-left of the page into a `backdrop-filter` // in any capture it shrinks. export const captureViewport = async ( cdp: CDPSession, options: { readonly format: "png" | "jpeg"; readonly quality?: number }, ) => { - const capture = cdp.send("Page.captureScreenshot", { - format: options.format, - ...(options.quality === undefined ? {} : { quality: options.quality }), - }); - let timer: ReturnType | undefined; - const expired = new Promise((_, reject) => { - timer = setTimeout( - () => - reject( - new ServerBrowserOperationError({ - tag: "PreviewAutomationExecutionError", - message: - "The browser is not producing screenshot frames. For a desktop tab, show or restore the Onicode window and try again.", - }), - ), - SCREENSHOT_TIMEOUT_MS, - ); - }); - // Hidden native guests can leave CDP captures pending forever. This deadline also - // releases a viewer's still-capture lock, which an agent snapshot may be waiting for. - const { data } = await Promise.race([capture, expired]).finally(() => clearTimeout(timer)); + const { data } = await withinFrameDeadline( + cdp.send("Page.captureScreenshot", { + format: options.format, + ...(options.quality === undefined ? {} : { quality: options.quality }), + }), + ); return data; }; +/** Whether a desktop page answers a capture. In a hidden or covered window it paints nothing. */ +export const paints = (cdp: CDPSession) => + captureViewport(cdp, { format: "jpeg", quality: 1 }).then( + () => true, + () => false, + ); + +// The app's smallest window, which every desktop page paints at least. +const SMALLEST_PAINTED = { width: 400, height: 360 }; + +/** + * How much of a desktop page Chromium paints, in display-independent pixels. Fails when the page + * paints nothing, as in a hidden window: no capture of it would answer either. + */ +export const paintedSize = async (cdp: CDPSession) => { + const page = await measuredForCapture(cdp); + const shown = pngSize(await captureViewport(cdp, { format: "png" })); + const display = page.ratio / page.zoom; + return { + width: Math.max(SMALLEST_PAINTED.width, Math.floor(shown.width / display)), + height: Math.max(SMALLEST_PAINTED.height, Math.floor(shown.height / display)), + }; +}; + +const finite = (value: unknown) => + typeof value === "number" && Number.isFinite(value) ? value : null; + +const clipOf = (value: unknown): CaptureClip | null => { + const clip = + typeof value === "object" && value !== null ? (value as Readonly>) : {}; + const x = finite(clip.x); + const y = finite(clip.y); + const width = finite(clip.width); + const height = finite(clip.height); + const scale = clip.scale === undefined ? 1 : finite(clip.scale); + if (x === null || y === null || width === null || height === null || scale === null) return null; + return width > 0 && height > 0 && scale > 0 ? { x, y, width, height, scale } : null; +}; + +/** + * A driver's `Page.captureScreenshot` on a desktop page. A clip larger than the page paints is + * captured in tiles and joined, since Chromium repeats the page across a capture it cannot paint. + * `onExpired` is told of a capture that missed its deadline: when Chromium answers it after all, + * it puts back the emulation it saved when that capture began. + */ +export const captureDesktopPage = async ( + cdp: CDPSession, + params: Readonly>, + painted: () => Promise<{ readonly width: number; readonly height: number }>, + onExpired: (answered: Promise) => void, +) => { + const send = (clip?: CaptureClip) => + withinFrameDeadline( + cdp.send("Page.captureScreenshot", { ...params, ...(clip ? { format: "png", clip } : {}) }), + onExpired, + ); + const clip = clipOf(params.clip); + if (clip === null) return send(); + const page = await measuredForCapture(cdp); + const plan = tileClip(clip, page.ratio / page.zoom, await painted()); + if (plan.tiles.length === 1) return send(); + if (params.format !== undefined && params.format !== "png") { + throw new Error("The Browser panel captures a region this large as PNG only."); + } + const tiles: Array<{ left: number; top: number; png: Buffer }> = []; + // As large as its tiles came back: how Chromium rounds a clip's last part pixel is its own. + let width = 0; + let height = 0; + for (const tile of plan.tiles) { + const { data } = await send(tile.clip); + const size = pngSize(data); + width = Math.max(width, tile.left + size.width); + height = Math.max(height, tile.top + size.height); + tiles.push({ left: tile.left, top: tile.top, png: Buffer.from(data, "base64") }); + } + return { data: (await joinTiles(width, height, tiles)).toString("base64") }; +}; + +// obu closes its connection on a CDP message above 224 MiB, and a capture travels in base64. +const MAX_CAPTURE_REPLY_CHARS = 215 * 1024 * 1024; + +/** A capture a driver's connection carries, refused when its reply would close that connection. */ +export const carried = ( + shot: A, + limit = MAX_CAPTURE_REPLY_CHARS, +) => { + if (shot.data.length <= limit) return shot; + throw new Error( + `The capture is ${Math.round((shot.data.length * 0.75) / 1_000_000)} MB as an image, more than the driver's connection carries. Capture a smaller size or scale.`, + ); +}; + export const captureFinalRecordingFrame = (cdp: CDPSession, quality: number) => answered( cdp diff --git a/apps/server/src/preview/pngTiles.test.ts b/apps/server/src/preview/pngTiles.test.ts new file mode 100644 index 0000000000..0dab408d01 --- /dev/null +++ b/apps/server/src/preview/pngTiles.test.ts @@ -0,0 +1,153 @@ +import { expect, it } from "vite-plus/test"; + +import { decodePng, encodePng, joinTiles, tileClip } from "./pngTiles.ts"; + +// A 16x16 capture Chromium made of a gradient page: RGB, rows filtered with Paeth and Up. +const CHROMIUM_CAPTURE = Buffer.from( + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAACWUlEQVR4nDRSy27TQBQ9nozHduw83TTQh0BCVUU3" + + "UCRWIPULEEKIBWyQWPEVLPgJVqh0y5IdO1aodBUhIiFRVYJASVNnYseP2I4fzLh0dHSlmTlz7rn3DuWDDkLAr+Bd" + + "wq3i/PJcECJgAcSg0IEMSOVG7EAgVwnkwLI6F0gqxIgNQTHkg5OT4ugwu8oU76x8sM6UC3ZFevMnfkjYWkIiA4ku" + + "BE0IvP2Q3L1N9+6oX37mxzyX8hfCEfZqqi3YJhYmRKThou7Ng9NpsXZNEdavr5KjUX7Is3SGv7x4TNj7Wfqko61Y" + + "ZKEj0UDn8xZRFaiLpQ7DQkHQtxSPowNFLXAeloLkNcCa0k/CQDnvWBZ7+iw/OvHXa8Qwcb9L331LTbfkfpk3C6co" + + "R/VCbZOUYamCTqe9KLI2N+vdLm8b45stDZ/wUsTfOL0B3sGOxYSZWcXOKejZWU9Vl7remU67/X5ja/sYH4Ehhjtw" + + "VhCa0vcFNSfSsHhwRVFk5wkph8P8s37v+f7B/gtpV1yX4kqRU/kfxajG436WqUnCosh0HHsw2H39Cs1HB9vf0Z3B" + + "WICloBlqOUghQSeTfhwbQWBybo9GG9gdINbnk62vt36sn6LtwgyhxWBLUIEc9Px8JQxNz2s5Tg8bI9iONDteTRre" + + "r41JaKA1Rz2EnoAlUDPZVjsILNdto+fA5jAjUQ7CBridaem052ZMTsCIoCXQhD2h7fsNmbvpwQykjqgu1uBbqLey" + + "Wua2gowgFZ8uRpqASnbDRyOAFcKosoqOLBniOkJLlJzXyqAZFjXZ2UzFPwAAAP//RKuAsQAAAAZJREFUAwD2LCmd" + + "7sDtgwAAAABJRU5ErkJggg==", + "base64", +); + +const solid = (width: number, height: number, channels: 3 | 4, color: ReadonlyArray) => + encodePng({ + width, + height, + channels, + data: Buffer.from( + Array.from({ length: width * height }, () => color.slice(0, channels)).flat(), + ), + }); + +const pixel = (image: ReturnType, x: number, y: number) => [ + ...image.data.subarray( + (y * image.width + x) * image.channels, + (y * image.width + x + 1) * image.channels, + ), +]; + +it("reads the pixels of a capture Chromium made", () => { + const image = decodePng(CHROMIUM_CAPTURE); + expect([image.width, image.height, image.channels]).toEqual([16, 16, 3]); + expect(pixel(image, 0, 0)).toEqual([238, 208, 17]); + expect(pixel(image, 15, 0)).toEqual([238, 17, 17]); + expect(pixel(image, 9, 3)).toEqual([238, 62, 17]); + expect(pixel(image, 7, 9)).toEqual([141, 115, 17]); + expect(pixel(image, 0, 15)).toEqual([17, 17, 238]); + expect(pixel(image, 15, 15)).toEqual([47, 209, 17]); + expect(decodePng(encodePng(image)).data.equals(image.data)).toBe(true); + expect(() => decodePng(Buffer.from("not a png"))).toThrow("not a PNG"); +}); + +it("cuts a clip into tiles the page paints whole", () => { + // A 1920x1080 page at 2 device pixels per CSS pixel, where 1430x1016 pixels are painted. + const plan = tileClip({ x: 0, y: 0, width: 1920, height: 1080, scale: 1 }, 2, { + width: 1430, + height: 1016, + }); + expect([plan.width, plan.height]).toEqual([3840, 2160]); + expect(plan.tiles.map((tile) => [tile.left, tile.top])).toEqual([ + [0, 0], + [1430, 0], + [2860, 0], + [0, 1016], + [1430, 1016], + [2860, 1016], + [0, 2032], + [1430, 2032], + [2860, 2032], + ]); + expect(plan.tiles[0]?.clip).toEqual({ x: 0, y: 0, width: 715, height: 508, scale: 1 }); + expect(plan.tiles[8]?.clip).toEqual({ x: 1430, y: 1016, width: 490, height: 64, scale: 1 }); + + // The clip's own scale counts: half the pixels per CSS pixel, twice the CSS pixels per tile. + const scaled = tileClip({ x: 10, y: 20, width: 1920, height: 400, scale: 0.5 }, 2, { + width: 1430, + height: 1016, + }); + expect([scaled.width, scaled.height]).toEqual([1920, 400]); + expect(scaled.tiles.map((tile) => tile.clip)).toEqual([ + { x: 10, y: 20, width: 1430, height: 400, scale: 0.5 }, + { x: 1440, y: 20, width: 490, height: 400, scale: 0.5 }, + ]); + + // 1.25 pixels per CSS pixel: 401 CSS pixels fit, but 400 make whole pixels, so tiles meet. + const fractional = tileClip({ x: 0, y: 0, width: 1000, height: 300, scale: 1 }, 1.25, { + width: 502, + height: 400, + }); + expect(fractional.tiles.map((tile) => [tile.left, tile.clip.x, tile.clip.width])).toEqual([ + [0, 0, 400], + [500, 400, 400], + [1000, 800, 200], + ]); + + // obu sizes a full page to its last drawn pixel, which is part of a page pixel at this ratio. + const partPixel = tileClip({ x: 0, y: 0, width: 800, height: 1000.5, scale: 1 }, 2, { + width: 1700, + height: 800, + }); + expect(partPixel.height).toBe(2001); + expect(partPixel.tiles.map((tile) => [tile.top, tile.clip.height])).toEqual([ + [0, 400], + [800, 400], + [1600, 200.5], + ]); + + // Refused before any of it is captured: a scale no whole step meets, too many pixels to + // hold, and more tiles than one image is joined from. + const refused = ( + clip: { readonly width: number; readonly height: number }, + ratio: number, + painted: { readonly width: number; readonly height: number }, + ) => { + try { + tileClip({ x: 0, y: 0, scale: 1, ...clip }, ratio, painted); + return "joined"; + } catch (cause) { + return String(cause); + } + }; + expect(refused({ width: 3000, height: 200 }, 1.2345, { width: 700, height: 400 })).toContain( + "cannot join a capture at 1.2345 image pixels per page pixel", + ); + expect(refused({ width: 8192, height: 8192 }, 1, { width: 500, height: 300 })).toContain( + "at most 40 megapixels in one image, and this one is 8192x8192", + ); + expect(refused({ width: 4000, height: 4000 }, 1, { width: 200, height: 200 })).toContain( + "at most 256 pieces", + ); + + // A clip the page paints whole is one tile, which the caller sends as it came. + expect( + tileClip({ x: 0, y: 0, width: 700, height: 500, scale: 1 }, 2, { width: 1430, height: 1016 }) + .tiles, + ).toHaveLength(1); +}); + +it("joins tiles at their places, whether a tile has an alpha channel or not", async () => { + const joined = decodePng( + await joinTiles(5, 3, [ + { left: 0, top: 0, png: solid(3, 2, 3, [200, 10, 10]) }, + { left: 3, top: 0, png: solid(2, 2, 4, [10, 200, 10, 255]) }, + // One pixel taller and wider than its place: the image keeps its own size. + { left: 0, top: 2, png: solid(6, 2, 3, [10, 10, 200]) }, + ]), + ); + expect([joined.width, joined.height, joined.channels]).toEqual([5, 3, 4]); + expect(pixel(joined, 0, 0)).toEqual([200, 10, 10, 255]); + expect(pixel(joined, 2, 1)).toEqual([200, 10, 10, 255]); + expect(pixel(joined, 3, 0)).toEqual([10, 200, 10, 255]); + expect(pixel(joined, 4, 1)).toEqual([10, 200, 10, 255]); + expect(pixel(joined, 0, 2)).toEqual([10, 10, 200, 255]); + expect(pixel(joined, 4, 2)).toEqual([10, 10, 200, 255]); +}); diff --git a/apps/server/src/preview/pngTiles.ts b/apps/server/src/preview/pngTiles.ts new file mode 100644 index 0000000000..fa30948b03 --- /dev/null +++ b/apps/server/src/preview/pngTiles.ts @@ -0,0 +1,226 @@ +// @effect-diagnostics nodeBuiltinImport:off - zlib is the PNG codec; Effect has no wrapper for it. +import * as NodeUtil from "node:util"; +import * as NodeZlib from "node:zlib"; + +/** + * A capture assembled from tiles. A desktop tab is a webview inside the app window, and Chromium + * paints only as much of one as that window could show: a capture larger than that comes back + * with the page repeated across it, while each tile within it comes back whole. + */ +export interface CaptureClip { + readonly x: number; + readonly y: number; + readonly width: number; + readonly height: number; + readonly scale: number; +} + +interface Pixels { + readonly width: number; + readonly height: number; + /** 3 for RGB, 4 for RGBA; one byte each. */ + readonly channels: number; + readonly data: Buffer; +} + +const SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); + +const paeth = (left: number, up: number, upLeft: number) => { + const estimate = left + up - upLeft; + const toLeft = Math.abs(estimate - left); + const toUp = Math.abs(estimate - up); + const toUpLeft = Math.abs(estimate - upLeft); + return toLeft <= toUp && toLeft <= toUpLeft ? left : toUp <= toUpLeft ? up : upLeft; +}; + +/** Reads what Chromium writes: 8-bit RGB or RGBA, not interlaced. */ +export const decodePng = (png: Buffer): Pixels => { + if (!png.subarray(0, 8).equals(SIGNATURE)) throw new Error("The capture is not a PNG."); + let header: Buffer | undefined; + const compressed: Array = []; + for (let offset = 8; offset + 12 <= png.length;) { + const length = png.readUInt32BE(offset); + const type = png.toString("latin1", offset + 4, offset + 8); + const body = png.subarray(offset + 8, offset + 8 + length); + if (type === "IHDR") header = body; + if (type === "IDAT") compressed.push(body); + if (type === "IEND") break; + offset += 12 + length; + } + const colorType = header?.[9]; + if ( + header === undefined || + header[8] !== 8 || + header[12] !== 0 || + (colorType !== 2 && colorType !== 6) + ) { + throw new Error("The capture is a PNG of a kind the panel cannot join."); + } + const width = header.readUInt32BE(0); + const height = header.readUInt32BE(4); + const channels = colorType === 6 ? 4 : 3; + const stride = width * channels; + const filtered = NodeZlib.inflateSync(Buffer.concat(compressed)); + const data = Buffer.alloc(stride * height); + for (let y = 0; y < height; y += 1) { + const filter = filtered[y * (stride + 1)]; + const from = y * (stride + 1) + 1; + const row = y * stride; + for (let i = 0; i < stride; i += 1) { + const left = i >= channels ? data[row + i - channels]! : 0; + const up = y > 0 ? data[row - stride + i]! : 0; + const upLeft = y > 0 && i >= channels ? data[row - stride + i - channels]! : 0; + const predicted = + filter === 1 + ? left + : filter === 2 + ? up + : filter === 3 + ? (left + up) >> 1 + : filter === 4 + ? paeth(left, up, upLeft) + : 0; + data[row + i] = (filtered[from + i]! + predicted) & 0xff; + } + } + return { width, height, channels, data }; +}; + +const chunk = (type: string, body: Buffer) => { + const head = Buffer.alloc(8); + head.writeUInt32BE(body.length, 0); + head.write(type, 4, "latin1"); + const check = Buffer.alloc(4); + check.writeUInt32BE(NodeZlib.crc32(Buffer.concat([head.subarray(4), body])), 0); + return Buffer.concat([head, body, check]); +}; + +/** A PNG file around scanlines that are already compressed. */ +const pngFile = (width: number, height: number, channels: number, compressed: Buffer) => { + const header = Buffer.alloc(13); + header.writeUInt32BE(width, 0); + header.writeUInt32BE(height, 4); + header[8] = 8; + header[9] = channels === 4 ? 6 : 2; + return Buffer.concat([ + SIGNATURE, + chunk("IHDR", header), + chunk("IDAT", compressed), + chunk("IEND", Buffer.alloc(0)), + ]); +}; + +export const encodePng = ({ width, height, channels, data }: Pixels) => { + const stride = width * channels; + const rows = Buffer.alloc((stride + 1) * height); + for (let y = 0; y < height; y += 1) { + data.copy(rows, y * (stride + 1) + 1, y * stride, (y + 1) * stride); + } + return pngFile(width, height, channels, NodeZlib.deflateSync(rows, { level: 4 })); +}; + +/** + * The largest image the server joins: its pixels are held whole, at four bytes each. obu cuts + * a capture to the same area, so one it sends is never refused here for its size. + */ +const MAX_JOINED_PIXELS = 40_000_000; + +/** The most tiles one image is joined from: each is a capture of its own. */ +const MAX_TILES = 256; + +/** + * The tiles of a clip, each no larger in output pixels than `painted`. `ratio` is the page's + * device pixels per CSS pixel. A tile steps by whole CSS pixels that are whole output pixels + * too, so tiles meet exactly and none overlaps another. A clip that needs tiles and has no such + * step, or too many pixels or tiles, is refused before any of it is captured. + */ +export const tileClip = ( + clip: CaptureClip, + ratio: number, + painted: { readonly width: number; readonly height: number }, +) => { + const perCss = clip.scale * ratio; + const width = Math.max(1, Math.round(clip.width * perCss)); + const height = Math.max(1, Math.round(clip.height * perCss)); + const along = (limit: number, length: number) => { + const most = Math.max(1, Math.floor(limit / perCss)); + if (length <= most) return length; + for (let step = most; step >= 1; step -= 1) { + if (Math.abs(step * perCss - Math.round(step * perCss)) < 1e-6) return step; + } + return null; + }; + const across = along(painted.width, clip.width); + const down = along(painted.height, clip.height); + if (across === clip.width && down === clip.height) { + return { width, height, tiles: [{ left: 0, top: 0, clip }] }; + } + if (across === null || down === null) { + throw new Error( + `The Browser panel cannot join a capture at ${Number(perCss.toFixed(4))} image pixels per page pixel: no whole number of page pixels is a whole number of image pixels. Capture at a scale such as 1, 1.5 or 2, or a size the Onicode window can show whole.`, + ); + } + if (width * height > MAX_JOINED_PIXELS) { + throw new Error( + `The Browser panel captures at most ${MAX_JOINED_PIXELS / 1_000_000} megapixels in one image, and this one is ${width}x${height}. Capture a smaller size or scale.`, + ); + } + if (Math.ceil(clip.width / across) * Math.ceil(clip.height / down) > MAX_TILES) { + throw new Error( + `The Browser panel joins at most ${MAX_TILES} pieces into one image, and this ${width}x${height} one needs more. Capture a smaller size, or make the Onicode window larger.`, + ); + } + const tiles: Array<{ readonly left: number; readonly top: number; readonly clip: CaptureClip }> = + []; + for (let y = 0; y < clip.height; y += down) { + for (let x = 0; x < clip.width; x += across) { + tiles.push({ + left: Math.round(x * perCss), + top: Math.round(y * perCss), + clip: { + x: clip.x + x, + y: clip.y + y, + width: Math.min(across, clip.width - x), + height: Math.min(down, clip.height - y), + scale: clip.scale, + }, + }); + } + } + return { width, height, tiles }; +}; + +const deflate = NodeUtil.promisify(NodeZlib.deflate); + +/** + * One opaque image of `width` by `height` with each tile's pixels at its place. Tiles land + * straight in the PNG's scanlines and are compressed off the event loop: a large capture must + * not hold the server's other work. + */ +export const joinTiles = async ( + width: number, + height: number, + tiles: ReadonlyArray<{ readonly left: number; readonly top: number; readonly png: Buffer }>, +) => { + const stride = width * 4 + 1; + const scanlines = Buffer.alloc(stride * height, 0xff); + for (let y = 0; y < height; y += 1) scanlines[y * stride] = 0; + for (const tile of tiles) { + const pixels = decodePng(tile.png); + const columns = Math.min(pixels.width, width - tile.left); + const rows = Math.min(pixels.height, height - tile.top); + for (let y = 0; y < rows; y += 1) { + const from = y * pixels.width * pixels.channels; + const to = (tile.top + y) * stride + 1 + tile.left * 4; + if (pixels.channels === 4) { + pixels.data.copy(scanlines, to, from, from + columns * 4); + continue; + } + for (let x = 0; x < columns; x += 1) { + pixels.data.copy(scanlines, to + x * 4, from + x * 3, from + x * 3 + 3); + scanlines[to + x * 4 + 3] = 0xff; + } + } + } + return pngFile(width, height, 4, await deflate(scanlines, { level: 4 })); +}; diff --git a/apps/server/src/preview/previewCdpPolicy.test.ts b/apps/server/src/preview/previewCdpPolicy.test.ts index ee450fc193..aded6dce57 100644 --- a/apps/server/src/preview/previewCdpPolicy.test.ts +++ b/apps/server/src/preview/previewCdpPolicy.test.ts @@ -4,6 +4,7 @@ import { cdpErrorMessage, driverTargetId, isPanelUrl, + pageCommandParams, routePageCommand, } from "./previewCdpPolicy.ts"; @@ -43,6 +44,16 @@ it("opens web pages and a driver's blank start page, nothing else", () => { ).toEqual([]); }); +it("captures the page, never the window a tab sits in", () => { + const clip = { x: 0, y: 0, width: 800, height: 600, scale: 1 }; + expect( + pageCommandParams("Page.captureScreenshot", { format: "png", clip, fromSurface: false }), + ).toEqual({ format: "png", clip }); + expect(pageCommandParams("Runtime.evaluate", { fromSurface: false })).toEqual({ + fromSurface: false, + }); +}); + it("names a tab with an id obu accepts as a file name, the same every time", () => { const id = driverTargetId("thread-1", "tab_17"); expect(id).toMatch(/^[0-9A-F]{32}$/); diff --git a/apps/server/src/preview/previewCdpPolicy.ts b/apps/server/src/preview/previewCdpPolicy.ts index 09d5f3e097..06c0a3a3cb 100644 --- a/apps/server/src/preview/previewCdpPolicy.ts +++ b/apps/server/src/preview/previewCdpPolicy.ts @@ -57,6 +57,17 @@ export const routePageCommand = (method: string): PageCommandRoute => { return FORWARDED_DOMAINS.has(method.slice(0, method.indexOf("."))) ? "forward" : "refuse"; }; +export const PANEL_URL_REQUIRED = + "The Browser panel opens http and https pages only. To open a local file, serve its folder over http, as with `python3 -m http.server`, and open that address."; + +/** What the page gets of a command: `fromSurface: false` would capture the window around a tab. */ +export const pageCommandParams = (method: string, params: unknown) => { + if (typeof params !== "object" || params === null) return {}; + if (method !== "Page.captureScreenshot") return params; + const { fromSurface: _, ...page } = params as Readonly>; + return page; +}; + /** The panel shows http and https pages; `about:blank` is what a driver's new tab starts on. */ export const isPanelUrl = (url: string) => { if (url === "about:blank") return true; diff --git a/apps/server/src/provider/agentContextBudget.json b/apps/server/src/provider/agentContextBudget.json index f1aea61a5b..bc19d81de8 100644 --- a/apps/server/src/provider/agentContextBudget.json +++ b/apps/server/src/provider/agentContextBudget.json @@ -1,5 +1,5 @@ { - "claudeSystemAppendBytes": 5954, - "codexAdditionalContextBytes": 7342, + "claudeSystemAppendBytes": 6910, + "codexAdditionalContextBytes": 8483, "mcpToolListJsonBytes": 50089 } diff --git a/docs/internals/browser-use.md b/docs/internals/browser-use.md index ec0fc00abe..0132c2d824 100644 --- a/docs/internals/browser-use.md +++ b/docs/internals/browser-use.md @@ -38,6 +38,52 @@ carries obu's commands, beside the session Playwright already holds. to its target in many small moves, and Chromium answers each on the page's next frame. A tab nobody watches paints too rarely for that, so the bridge forwards only where the pointer came to rest. A drag's moves all pass. +- **A sized capture is the page's, not the panel's.** obu sizes a page for one + `vision` capture with `Emulation.setDeviceMetricsOverride` and clears it + after. A desktop page takes the override itself. Playwright holds a headless + page's metrics and would not see another session's override, so that page is + resized through its viewport and keeps the browser's own pixel ratio. The + tab's viewport setting never changes, and + [`ServerBrowser`](../../apps/server/src/preview/ServerBrowser.ts) restores the + page when the driver clears the override or detaches, even while a human + holds the tab. Sets, clears and a desktop tab's captures run one at a time in + the order they arrived: obu pipelines them, and a clear that overtook its set + or landed between two tiles would leave the page or the image at the wrong + size. A size change the page does not answer within five seconds gives up + its turn. The session detaches only after that restore, since a clear sent + to a detached session reaches no page. +- **A desktop tab is captured in tiles.** Chromium paints only about as much of + a webview as the app window could show, and repeats the page across any + larger capture. The server captures a larger clip as tiles within the painted + size and joins them ([`pngTiles`](../../apps/server/src/preview/pngTiles.ts)). + Tiles step by CSS pixels that are whole output pixels too, so they meet + without a seam at a fractional ratio. A clip is refused before any tile is + taken when no such step exists, when the joined image, held whole in memory, + would pass 40 megapixels (obu's own cap, so a page it cut to fit is never + refused here), or when it needs more than 256 tiles. The joined + image is as large as its tiles came back, so Chromium's rounding of a clip's + last part pixel is kept. `fromSurface: false` would + capture the app window around the tab, so it is dropped. A visible tab the + panel shows scaled down captures soft. +- **A hidden window paints nothing.** With the app window minimized or fully + covered, a desktop tab answers no capture, and no CDP command wakes it. An + agent works with nobody at the desktop, so its new tab is checked once: when + the desktop page answers no capture, the server runs the tab headless, as it + does with no desktop at all. A desktop tab whose window is hidden later + fails a capture after three seconds with a message that tells the agent to + open the page in a new tab, instead of hanging until obu gives up on the + browser. Chromium saves the page's emulation when a clipped capture begins + and puts it back when the capture is answered, however late. So until such + a capture has answered and the driver's current size has been applied again, + the tab takes no other capture. A clear that arrives while such a capture is + out is not sent: Chromium would drop the size to go back to and leave the + webview at the capture's. The repair sends it once the capture has answered, + and the driver is told the page is still sized when that takes more than + five seconds. +- **A capture must fit one CDP message.** obu closes its connection on a + message above 224 MiB, and a capture travels as base64. obu caps what it + asks for, and the server refuses to send a larger reply instead of ending + the driver's session. - **Page-scoped domains only.** `Browser`, `Storage`, `SystemInfo` and the rest of `Target` reach other tabs, the profile or the host, and are refused. The table is [`previewCdpPolicy`](../../apps/server/src/preview/previewCdpPolicy.ts). @@ -56,10 +102,11 @@ tool list. Two ways to read and act on one page make an agent mix their element refs. The capability is part of the credential, so changing the target issues a new one. -The model learns which browser it holds from obu, not from Onicode's -instructions: `OBU_HOST_NOTE` adds one line to obu's MCP instructions and to -its first result. That text is model-facing; treat a change to it like any -other instruction change. +Onicode's instructions tell an agent that the `browser` tools are its browser +and that it starts none of its own. Which browser that is comes from obu: +`OBU_HOST_NOTE` adds one line to obu's MCP instructions and to its first +result. Both texts are model-facing; `evals/mcp-tool-use` replays them with +obu's captured tool list (`cases/browser-driver.ndjson`). ## One home, one session per thread diff --git a/docs/user/browser-use.md b/docs/user/browser-use.md index 917445269d..aa375f7d8c 100644 --- a/docs/user/browser-use.md +++ b/docs/user/browser-use.md @@ -26,7 +26,8 @@ environment. panel, so you watch it work, and you can take the tab over at any moment; the agent's actions are refused while you hold it. This choice needs **Agent browser access** on, and nothing else installed. The panel opens http and https -pages only. A thread's panel tabs close when you archive or delete the thread. +pages only, so for a local HTML file the agent serves its folder first. A +thread's panel tabs close when you archive or delete the thread. **Its own Chrome** gives the agent a separate Chrome with logins of its own. You do not see that browser. Sign-ins made there stay for later threads, and @@ -41,6 +42,13 @@ browser with `--remote-debugging-port` and enter that port in **Browser debug port** on the desktop app. Otherwise obu starts your browser on a copy of your profile. Tabs the agent opened close when you archive or delete its thread. +## Screenshots + +Ask for a screenshot as a file and the agent saves a PNG where you say: at a +size you name, such as 1920×1080 (or twice that for a sharper image), or of the +whole page. In the Browser panel the page takes that size for the capture only; +the tab's own size setting does not change. + ## What agents can reach In the Browser panel an agent reaches the tabs it opened in its own thread and diff --git a/evals/mcp-tool-use/README.md b/evals/mcp-tool-use/README.md index 4c410b3ea6..c9a537de11 100644 --- a/evals/mcp-tool-use/README.md +++ b/evals/mcp-tool-use/README.md @@ -270,6 +270,64 @@ Fidelity limits: - **Shared framing.** GPT gets the same Claude Code CLAUDE.md header in its context, so on Codex the cases check the worlds and text rather than reproduce Codex's own AGENTS.md loading. - **Out of scope.** Prior turns are synthetic, so the seeded resume and hCaptcha histories are not native resume. Native subagents are not covered. +## Browser driver cases + +`cases/browser-driver.ndjson` checks that an agent with obu's `browser` tools does its browser work with them and starts no browser of its own. The bad cases come from the maintainers' 2026-11 field review: three days of Claude threads that listed the `browser` tools, where requested screenshots, blocked fetches and delegated checks went to a headless Chrome, a cached Playwright shell or a Playwright script. Prompts, files and pages are authored Acme data. + +| Case | Kind | What it checks | +| ------------------------------------ | ------- | ------------------------------------------------------------------------------------------------------ | +| bd-look-on-web | bad | "How does it look on web?" after the agent's own edit: a `browser` tool, no launched browser. | +| bd-deck-slides-to-png | bad | Six slides of a local HTML deck as 1920x1080 PNGs: `vision` writes them. The panel refuses `file://`. | +| bd-deck-slides-to-png-isolated | bad | The same export where the driver runs its own Chrome, which opens the file directly. | +| bd-full-page-reference | bad | A full-page PNG of a public page at 1440 wide: `vision`, not a Playwright `fullPage` script. | +| bd-child-research-fetch-blocked | bad | A research child whose WebFetch and curl meet a bot challenge reads the page with the driver. | +| bd-child-brief-forbids-users-browser | bad | A brief forbids the user's own browser: the child's panel tab is not that, so it takes the screenshot. | +| bd-guard-unasked-edit | guard | A styling edit nobody asked to check: no browser call of any kind. | +| bd-guard-signed-in-dashboard | guard | The user names playwriter and their signed-in Chrome: playwriter, no driver call. | +| bd-guard-desktop-debug-port | guard | An Electron dev app the project drives over its documented debug port: that script, no driver call. | +| bd-guard-public-page-fetch | guard | Public pages a fetch can read stay with web fetch. | +| bd-control-repo-e2e | control | "Run the e2e suite": the project's own runner, no driver call. | + +Bad cases need the named `browser` call, with the page or the capture in its result so an empty `run` does not pass, and no launched browser, graded by the browser routing cases' `shellMustNot` patterns. The screenshot cases also need each file the user asked for in the result of a `vision` or `run` call, at the size asked (a call's `output`). Beyond that they gate on the routing decision, not on a finished task. + +Runner support: + +- An expected call's `output` is a regex its result must match. A failed call never matches. +- `world.browserDriver` (`panel` or `isolated`) lists obu's tools as `mcp__browser__*`, adds obu's MCP instructions with Onicode's host note, and for the panel leaves out the page tools obu replaces, as Onicode does. +- obu is a binary, so its instructions and tool list come from `browser-driver.json`, captured from the release Onicode pins. `run.test.ts` fails when the capture's version is not the pinned one. Refresh it with `pnpm mcp-tool-use:capture-browser-driver `. +- `browserDriver.ts` answers driver calls a case does not mock: a page has the world's `pages` text, the panel refuses a URL that is not http or https with Onicode's own message, and `vision` with `path` names the file it wrote, which the shell simulator then finds. It accepts only the arguments the capture's schema has, so the cases fail on a driver without `path`, `size` and `full`. + +From `evals/`: + +```sh +pnpm mcp-tool-use --cases mcp-tool-use/cases/browser-driver.ndjson --model gpt-6.2-sol --shell-model gpt-6.1-terra --samples 3 --out runs/browser-driver +``` + +Fidelity limits, beyond those of the browser routing cases: + +- **A scripted driver.** Results are text. No page renders, a click changes nothing, a saved PNG exists only as a line the shell simulator is told, and a screenshot result ends with the address of the page it was taken of, which obu's does not. +- **One capture.** A case replays the tool list of one obu release. A release that renames a tool or an argument needs a new capture before its cases mean anything. +- **Routing only.** Whether a capture has the right pixels is tested in obu and in `apps/server/src/preview`, not here. +- **A capture of any page counts.** The scripted driver names the file a `vision` call asked for whether or not the agent opened the page first, so a case does not catch a capture of the wrong page. + +### Results + +Passing samples, the text and driver before the change → after, 3 samples a case on GPT-6.2 Sol. Before: 17/33. After: 33/33. + +| Case | GPT-6.2 Sol | +| ------------------------------------ | ------------- | +| bd-look-on-web | 0/3 → 3/3 | +| bd-deck-slides-to-png | 0/3 → 3/3 | +| bd-deck-slides-to-png-isolated | 0/3 → 3/3 | +| bd-full-page-reference | 0/3 → 3/3 | +| bd-child-research-fetch-blocked | 2/3 → 3/3 | +| bd-child-brief-forbids-users-browser | 0/3 → 3/3 | +| guards and control | 15/15 → 15/15 | + +Smaller Claude models are sensitive to the wording of the first browser bullet. In real Onicode turns on Claude Haiku 5.5, exporting a local deck's slides as PNG files went through the driver in 7 of 7 turns with one wording, in 0 of 4 with a rewording that meant the same, and in 6 of 7 with the current one. After an edit to the browser bullets, run `bd-deck-slides-to-png` with `--model claude-haiku-5-5` as well. + +A first draft of the text said the agent's browser was "never" the user's own. GPT-6.2 Sol then refused playwriter in `bd-guard-signed-in-dashboard` (0/3); the shipped wording passes 3/3. + ## File links cases `cases/file-links.ndjson` checks the file references in an agent's final answer. Chat turns every file-shaped Markdown link and inline code span into a pill, resolves it against the thread's cwd, and opens that path. `expect.fileLinks` replays the final answer through the same shared resolver (`file-link-grading.ts`) and fails on any pill that lands on no `world.files` entry, except a bare basename that the client's on-click lookup finds exactly once. `minWorking` sets how many working pills the answer needs, so an answer that cites no files cannot pass. Paths outside the thread cwd, `/home` and `/Users` are ignored. @@ -294,6 +352,7 @@ After the change, the first reference to a file is an absolute link. The remaini - `packages/provider-core/src/server/runtimeInstructions.ts` - `packages/provider-core/src/server/orchestrationInstructions.ts` - `apps/server/src/provider/CodexDeveloperInstructions.ts` +- `apps/server/src/browserUse/BrowserUseService.ts` (the host notes obu passes on) - `apps/server/src/mcp/toolkits/*/tools.ts` (tool descriptions) - `packages/contracts/src/*Mcp.ts` (parameter descriptions and result text) diff --git a/evals/mcp-tool-use/browser-driver.json b/evals/mcp-tool-use/browser-driver.json new file mode 100644 index 0000000000..44e48e169e --- /dev/null +++ b/evals/mcp-tool-use/browser-driver.json @@ -0,0 +1,575 @@ +{ + "version": "4.9.0", + "instructions": "Stealth browser driver. act interacts (navigate/click/type/fill/batch/eval), see reads (extract=\"auto\" first on list/search/product pages; mode=\"content\" for articles; format=\"json\" for pure JSON), state manages cookies/tabs/sessions, run executes step batches with branching and inline reads, vision screenshots (path= saves the PNG, size= sets the viewport, full= takes the whole page). WORK LOOP: navigate -> act by text (no see needed) or by ref (refs are page-scoped: refresh them after a navigation or tab switch; within a page they self-heal) -> every action returns an observation, so a see after acting is usually unnecessary. act eval answers one line, `result: ` (a returned string containing JSON is flagged in a note). Results disclose what the driver cannot verify: page_total/partial (lazy or paginated results), sponsored items, unwrapped redirect links, duplicates removed, and a URL range filter whose page prices fall outside it. Oversized payloads go to an artifact file, read back with see artifact=\"...\" - nothing is truncated silently. Errors carry the current page state; never blind-retry a submit. HOST: {{HOST_NOTE}}", + "tools": [ + { + "name": "act", + "description": "Interact; verified verdict + page delta, navigate also returns refs/content. Prefer ref, then text/label, then CSS; click x,y overrides other targets. Refs self-heal within a page; refresh after navigation/tab switch. Ambiguity returns candidates: choose ref/selector/nth. Popup clicks keep opener active; switch-tab by returned ID.\nType replaces/verifies text; type+press=Enter submits once. Targeted press focuses first; otherwise current focus. fill sets multiple fields then optionally submits once.\nwait text= matches visible page text; selector= traverses open shadows/same-origin frames; condition=element matches visible role/text. title/url match text; js evaluates js= (legacy text=); settle waits DOM quiet; network waits 300ms without tracked requests, excluding streams.\nbatch runs sequential steps; optional:true continues runtime failures. Plans validate before effects (1000 steps, nesting 32); runtime failures retain prior effects. slim inherits through batch/run, preserves reads/errors. url= navigates first except download/state ops.\nErrors carry page state. trusted:false means untrusted input fallback; degraded:true means client deadline/transport failure with unknown outcome. Observe destination before repeating input. Quiet dispatched clicks never replay.", + "input_schema": { + "properties": { + "accept": { + "description": "act dialog: accept (default true) or cancel the matching dialog.", + "type": "boolean" + }, + "action": { + "enum": [ + "click", + "type", + "clear", + "select", + "press", + "scroll", + "navigate", + "read", + "wait", + "dialog", + "back", + "forward", + "reload", + "hover", + "upload", + "fill", + "batch", + "eval", + "pdf", + "download", + "collect", + "paginate", + "extract", + "open-tab", + "close-tab", + "switch-tab", + "save", + "load" + ], + "type": "string" + }, + "block": { + "description": "navigate: comma-separated images,fonts,media,trackers; applied before loading.", + "type": "string" + }, + "body": { + "description": "Download: HTTP body instead of browser attachment, <=32 MiB/30s. No browser cookies; honors HTTP(S) OBU_PROXY, refuses other proxy types; returns status/path.", + "type": "boolean" + }, + "condition": { + "description": "Wait kind; js needs js=, selector uses selector= (or text= with condition=selector). network waits 300ms idle.", + "enum": [ + "element", + "selector", + "title", + "settle", + "network", + "network-idle", + "url", + "text", + "js" + ], + "type": "string" + }, + "dx": { + "type": "integer" + }, + "dy": { + "type": "integer" + }, + "expect": { + "description": "dialog: alert|confirm|prompt|beforeunload|any|clear; arm before trigger. Other actions: expected navigation|dom-change|none|any.", + "type": "string" + }, + "extract": { + "description": "Extract/paginate read kind; default auto.", + "enum": ["auto", "json", "links", "forms"], + "type": "string" + }, + "fields": { + "description": "Fill: [{ref|label|selector,text|option|check}]. Toggles accept only check=true/false; omit values to toggle.", + "items": { + "properties": { + "check": { + "description": "true=check, false=uncheck, omit=toggle.", + "type": "boolean" + }, + "label": { + "type": "string" + }, + "option": { + "type": "string" + }, + "ref": { + "type": "string" + }, + "selector": { + "type": "string" + }, + "text": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + }, + "format": { + "description": "read: live value/toggle state + select options (first 80; clipping explicit). eval/read/extract json: payload, {data,note} for notices, or {artifact,bytes,next_offset:0}; page artifacts with see.", + "enum": ["text", "json"], + "type": "string" + }, + "js": { + "description": "eval: required JavaScript; ref/selector exposes target as el. wait/if/while condition=js: expression.", + "type": "string" + }, + "key": { + "description": "Key or chord: Enter, Tab, Escape, Backspace, ArrowDown, Control+a, Meta+Enter, Shift+Tab.", + "type": "string" + }, + "label": { + "description": "Field label for click/type/fill/select/clear/read/hover/press.", + "type": "string" + }, + "landscape": { + "type": "boolean" + }, + "limit": { + "description": "Per-page extraction item limit.", + "type": "integer" + }, + "max": { + "description": "Collect items (default 100); paginate pages (default 5, max 100).", + "type": "integer" + }, + "message": { + "description": "act dialog: only match dialogs whose text contains this (case-insensitive).", + "type": "string" + }, + "name": { + "description": "save/load: session name (state tool contract).", + "type": "string" + }, + "next": { + "description": "Paginate: CSS selector or text=Next / label= / ref=.", + "type": "string" + }, + "nth": { + "description": "1-based match index; out of range refuses with the real count.", + "minimum": 1, + "type": "integer" + }, + "option": { + "description": "Select: label, text or value.", + "type": "string" + }, + "path": { + "description": "PDF: output path.", + "type": "string" + }, + "press": { + "description": "type: key/chord to dispatch once after verified typing, e.g. Enter.", + "type": "string" + }, + "printBackground": { + "type": "boolean" + }, + "prompt_text": { + "description": "act dialog: text typed into a matching prompt() when accepting.", + "type": "string" + }, + "ref": { + "description": "Page-scoped element ID, e.g. e5; refresh after navigation/tab switch.", + "type": "string" + }, + "role": { + "description": "Filter by role (button, textbox, link, etc.).", + "type": "string" + }, + "scale": { + "type": "number" + }, + "selector": { + "description": "CSS target (including press/wait); open shadows. Wait selectors also traverse same-origin frames. nth disambiguates; hidden targets refuse.", + "type": "string" + }, + "slim": { + "description": "Verdicts only for successful actions; batch/run inherit. Reads and errors retained.", + "type": "boolean" + }, + "sort": { + "description": "Reddit post extract sort.", + "enum": ["confidence", "top", "new", "controversial", "old", "qa"], + "type": "string" + }, + "steps": { + "description": "Sequential act steps (no nested batch), see/extract reads and {action:state,op,...}. Reuse each tool's fields. optional:true continues runtime failures; otherwise stops with prior results/page state. Navigation continues on the new page.", + "items": { + "properties": { + "action": { + "enum": [ + "click", + "type", + "clear", + "select", + "press", + "scroll", + "navigate", + "read", + "wait", + "dialog", + "back", + "forward", + "reload", + "hover", + "upload", + "fill", + "eval", + "pdf", + "download", + "collect", + "paginate", + "extract", + "open-tab", + "close-tab", + "switch-tab", + "save", + "load", + "see", + "state" + ], + "type": "string" + } + }, + "required": ["action"], + "type": "object" + }, + "type": "array" + }, + "submit": { + "description": "Fill: ref or text of submit button. Dispatched once; inspect the verdict before repeating.", + "type": "string" + }, + "target_id": { + "description": "close-tab/switch-tab: ID returned by state tabs/open-tab.", + "type": "string" + }, + "template": { + "description": "See template contract; for extract=json.", + "type": "object" + }, + "text": { + "description": "click/hover: visible text; type: replacement value; upload: file path; wait: match text. navigate uses url=.", + "type": "string" + }, + "timeout": { + "description": "Seconds, integer 0-3600. Defaults: wait 10, download/collect/dialog 30.", + "maximum": 3600, + "minimum": 0, + "type": "integer" + }, + "url": { + "description": "navigate requires url; download uses file URL; other actions navigate first except state ops (cookie scope/tab URL).", + "type": "string" + }, + "x": { + "description": "click: viewport CSS pixels; supply both x and y. Coordinates override other targets.", + "type": "number" + }, + "y": { + "type": "number" + } + }, + "required": ["action"], + "type": "object" + } + }, + { + "name": "see", + "description": "Read: model gives refs, content rendered markdown, outline headings. extract=auto detects list/search/product/site fields; preview=true samples schema without rows. Reddit comments disclose complete/partial, API denial and fuzzed_score; sort overrides page sort. Opaque redirects are flagged. find searches text; scope narrows reads. Logs: console=current document, network=current navigation; clear=true reads then clears.\nformat=json: payload, {data,note} for caveats/events, or artifact envelope. Default artifact pages are character chunks: concatenate data strings before parsing payload. items=true pages JSON array rows independently. next_offset=0 starts paging; null ends. changes=true gives model delta since last capture (JSON supported). Large reads offload; inspect partial/limit notes.", + "input_schema": { + "properties": { + "artifact": { + "description": "Read a previously offloaded payload from disk, paged. Pass the full payload path from a previous response; offset/limit are char-based (defaults 0 and 20000). With format=json each envelope is valid JSON; data is a text chunk, concatenate before parsing. items=true pages array rows.", + "type": "string" + }, + "budget": { + "description": "Max chars in response. Default 8000.", + "type": "integer" + }, + "changes": { + "description": "Model delta since last capture; format=json for structured output.", + "type": "boolean" + }, + "clear": { + "description": "Read then clear selected log.", + "type": "boolean" + }, + "content": { + "description": "Include page's visible text. model mode only. Use mode=content instead for clean markdown.", + "type": "boolean" + }, + "extract": { + "description": "auto (site-aware; Reddit posts attempt the full tree, inspect complete/partial), json (template), links, forms.", + "enum": ["links", "forms", "json", "auto"], + "type": "string" + }, + "filter": { + "description": "Filter by role/name (comma-separated). model mode only.", + "type": "string" + }, + "find": { + "description": "Search elements by text. Returns refs + scores.", + "type": "string" + }, + "format": { + "description": "text (default) | json — pure JSON output for extract= and artifact= reads (zero preamble; never truncated JSON).", + "enum": ["text", "json"], + "type": "string" + }, + "items": { + "description": "Artifact: page JSON array rows, not character chunks; offset/limit in items.", + "type": "boolean" + }, + "limit": { + "description": "Max items for extract. Default 50 (Reddit post comments: all available, capped at 1000, unless set). Artifact: chars (default 20000), or rows with items=true (default 50).", + "type": "integer" + }, + "logs": { + "description": "Console: current document - logs, uncaught errors with stack, failed loads. Network: current navigation.", + "enum": ["console", "network"], + "type": "string" + }, + "mode": { + "description": "model (default): interactive elements with refs. content: page text as markdown for reading. outline: headings only, ultra-minimal.", + "enum": ["model", "content", "outline"], + "type": "string" + }, + "offset": { + "description": "Artifact read: start char (row with items=true). Default 0.", + "minimum": 0, + "type": "integer" + }, + "preview": { + "description": "extract=auto: sampled container and fields, without rows.", + "type": "boolean" + }, + "scope": { + "description": "Ref id of element to view subtree text of; with mode=content, returns just that element's subtree as markdown (budget honored).", + "type": "string" + }, + "sort": { + "description": "Reddit post auto-extract sort; overrides page sort.", + "enum": ["confidence", "top", "new", "controversial", "old", "qa"], + "type": "string" + }, + "template": { + "description": "For extract=json: {\"items\":{\"container\":\"css\",\"fields\":{\"name\":\"css or css@attr\"}}}. @attr reads the container attribute. Text reads are RENDERED - a hidden element is omitted (the item lists it in _omitted); read one explicitly with {\"sel\":\"css\",\"raw\":true}. Lookups span light DOM, open shadow roots and same-origin frames; skipped frames are reported.", + "type": "object" + } + }, + "type": "object" + } + }, + { + "name": "state", + "description": "Manage tabs, cookies, storage, sessions, blocking. open-tab opens AND switches, returning an ID; switch-tab/close-tab require target_id. Save after login; navigate to saved origin before load, then reload. Setters require name/value (empty value allowed); ls/ss/cookies preserve full values, large reads offload to JSON artifacts. block affects inert assets, never first-party scripts. compress toggles response pruning. As steps use {action:\"state\",op:...,...}.", + "input_schema": { + "properties": { + "classes": { + "description": "Block: comma-separated (images, fonts, media, trackers).", + "type": "string" + }, + "clear": { + "description": "Block: true stops blocking. Without classes/clear, returns measured blocked-request count; byte/time savings unmeasured.", + "type": "boolean" + }, + "domain": { + "description": "Domain for del-cookie (alternative to url).", + "type": "string" + }, + "httpOnly": { + "type": "boolean" + }, + "mode": { + "description": "compress: response pruning toggle.", + "enum": ["on", "off", "status"], + "type": "string" + }, + "name": { + "description": "Cookie name, storage key, or session name.", + "type": "string" + }, + "op": { + "enum": [ + "cookies", + "set-cookie", + "del-cookie", + "ls", + "ss", + "set-ls", + "set-ss", + "rm-ls", + "rm-ss", + "clear-ls", + "clear-ss", + "tabs", + "open-tab", + "close-tab", + "switch-tab", + "save", + "load", + "block", + "compress" + ], + "type": "string" + }, + "path": { + "description": "set-cookie scope path.", + "type": "string" + }, + "sameSite": { + "enum": ["Strict", "Lax", "None"], + "type": "string" + }, + "secure": { + "type": "boolean" + }, + "slim": { + "description": "Tab lifecycle: retain tab ID, omit model.", + "type": "boolean" + }, + "target_id": { + "description": "Tab id for close-tab/switch-tab.", + "type": "string" + }, + "url": { + "description": "URL for open-tab, cookie scope (set-cookie/del-cookie), or domain filter (cookies).", + "type": "string" + }, + "value": { + "description": "Cookie or storage value.", + "type": "string" + } + }, + "required": ["op"], + "type": "object" + } + }, + { + "name": "run", + "description": "Sequential act actions (fill/eval included), see/extract reads and state ops with branches/loops. Reuse act/see/state fields. if: {action:\"if\",condition,text,then:[...],else:[...]}; while: {action:\"while\",condition,text,steps:[...],max:5}. JS conditions use js=; CSS uses selector=. False branches may finish before timeout on quiet pages; use wait for a deadline. wait+else falls back on timeout. optional:true continues runtime failure locally, including nested steps. Invalid plans fail before effects (1000 steps, nesting 32, while max 0-100). Other failures stop, preserving prior observations/effects; a failed batch stops enclosing run. slim inherits, reads/errors retained. url= navigates before each step; open-tab switches.", + "input_schema": { + "properties": { + "format": { + "description": "json: {status:completed|stopped,results:[{step,status:ok|optional_failed|failed,output,error?}],stopped_at?,error?,page?,note?}. Steps are 1-based; nested observations stay in output text. Not inherited: set each read's format explicitly. Oversized results use artifact paging.", + "enum": ["text", "json"], + "type": "string" + }, + "slim": { + "description": "Inherit verdict-only actions; preserve reads and errors.", + "type": "boolean" + }, + "steps": { + "description": "Steps reuse act/see/state fields plus optional:true and if/while branches. wait may carry else:[...].", + "items": { + "properties": { + "action": { + "enum": [ + "click", + "type", + "clear", + "select", + "press", + "scroll", + "navigate", + "read", + "wait", + "dialog", + "back", + "forward", + "reload", + "hover", + "upload", + "fill", + "eval", + "pdf", + "download", + "collect", + "paginate", + "extract", + "open-tab", + "close-tab", + "switch-tab", + "save", + "load", + "see", + "state", + "batch", + "if", + "while", + "js", + "vision" + ], + "type": "string" + }, + "condition": { + "description": "Same condition fields as act wait; js= expression, selector= CSS.", + "type": "string" + }, + "else": { + "description": "Sub-steps if condition times out.", + "type": "array" + }, + "max": { + "description": "Max iterations 0-100. Default 10.", + "maximum": 100, + "minimum": 0, + "type": "integer" + }, + "steps": { + "description": "Body steps for while loop.", + "type": "array" + }, + "then": { + "description": "Sub-steps if condition met.", + "type": "array" + } + }, + "required": ["action"], + "type": "object" + }, + "type": "array" + } + }, + "required": ["steps"], + "type": "object" + } + }, + { + "name": "vision", + "description": "PNG screenshot for canvas/image UIs, visual checks, or when refs/content cannot answer. marks=true overlays ref badges for visible main-frame elements; frames may be unmarked. Inline unless path= names a file; large PNGs offload to a local artifact. Also a run step. Prefer act/see for structural interactions.", + "input_schema": { + "properties": { + "full": { + "description": "Whole page.", + "type": "boolean" + }, + "marks": { + "description": "Overlay numbered ref badges on visible elements.", + "type": "boolean" + }, + "path": { + "description": "Write the .png here; no inline image.", + "type": "string" + }, + "size": { + "description": "Viewport for this capture, WxH[@scale]: 1440x900@2.", + "type": "string" + }, + "url": { + "description": "Navigate first.", + "type": "string" + } + }, + "type": "object" + } + } + ] +} diff --git a/evals/mcp-tool-use/browserDriver.ts b/evals/mcp-tool-use/browserDriver.ts new file mode 100644 index 0000000000..34e7b9c852 --- /dev/null +++ b/evals/mcp-tool-use/browserDriver.ts @@ -0,0 +1,179 @@ +// The eval reads the driver's captured MCP surface from a file beside it. +// @effect-diagnostics nodeBuiltinImport:off +import * as NodeFS from "node:fs"; +import * as NodePath from "node:path"; +import * as Schema from "effect/Schema"; + +import { ISOLATED_NOTE, PANEL_NOTE } from "../../apps/server/src/browserUse/BrowserUseService.ts"; +import { PANEL_URL_REQUIRED } from "../../apps/server/src/preview/previewCdpPolicy.ts"; + +/** The browser a thread's obu drives: its tab in the Browser panel, or a Chrome of its own. */ +export const BrowserDriverTarget = Schema.Literals(["panel", "isolated"]); +export type BrowserDriverTarget = typeof BrowserDriverTarget.Type; + +export const BROWSER_DRIVER_PREFIX = "mcp__browser__"; +const HOST_NOTE = "{{HOST_NOTE}}"; + +/** + * obu's `initialize` instructions and `tools/list`, captured from the release Onicode pins with + * `OBU_HOST_NOTE={{HOST_NOTE}}`. obu is a binary, so its text cannot be imported from source. + */ +export const browserDriverCapture = Schema.decodeSync( + Schema.fromJsonString( + Schema.Struct({ + version: Schema.String, + instructions: Schema.String, + tools: Schema.Array( + Schema.Struct({ + name: Schema.String, + description: Schema.String, + input_schema: Schema.Unknown, + }), + ), + }), + ), +)(NodeFS.readFileSync(NodePath.join(import.meta.dirname, "browser-driver.json"), "utf8")); + +const hostNote = (target: BrowserDriverTarget) => (target === "panel" ? PANEL_NOTE : ISOLATED_NOTE); + +export const browserDriverTools = browserDriverCapture.tools.map((tool) => ({ + ...tool, + name: `${BROWSER_DRIVER_PREFIX}${tool.name}`, +})); + +export const isBrowserDriverTool = (name: string) => name.startsWith(BROWSER_DRIVER_PREFIX); + +const isRecord = (value: unknown): value is Readonly> => + typeof value === "object" && value !== null && !Array.isArray(value); + +const schemaOf = (tool: string) => { + const schema = browserDriverCapture.tools.find((entry) => entry.name === tool)?.input_schema; + return isRecord(schema) && isRecord(schema.properties) ? schema.properties : {}; +}; +// The captured release decides what `vision` takes, so a case fails on a driver that lacks it. +const visionFields = new Set(Object.keys(schemaOf("vision"))); +const runAction = schemaOf("run").steps; +const visionIsRunStep = JSON.stringify(runAction ?? null).includes('"vision"'); + +/** The block Claude Code builds from an MCP server's instructions. */ +export const browserDriverInstructions = (target: BrowserDriverTarget) => + [ + "# MCP Server Instructions", + "The following MCP servers have provided instructions for how to use their tools and resources:", + `## browser\n${browserDriverCapture.instructions.replace(HOST_NOTE, hostNote(target))}`, + ].join("\n\n"); + +/** What a sample's driver has done so far. */ +export interface BrowserDriverState { + url: string | undefined; + /** obu says whose browser it drives on its first result too. */ + noted: boolean; + /** The screenshots `vision` wrote, each as the shell simulator should find it. */ + readonly saved: Array; +} + +export interface BrowserDriverResult { + readonly text: string; + readonly isError: boolean; +} + +/** + * obu's result for a call the case does not mock. It keeps the facts an agent's next step turns + * on: the panel refuses a local file, a named file gets the capture, a page has the world's text. + */ +export const browserDriverResult = ( + state: BrowserDriverState, + target: BrowserDriverTarget, + tool: string, + input: Readonly>, + world: { readonly cwd: string; readonly pages?: Readonly> | undefined }, +): BrowserDriverResult => { + const failed = (text: string): BrowserDriverResult => ({ + text: `✗ error: ${text}`, + isError: true, + }); + const pageText = (url: string) => { + const html = [url, url.replace(/\/$/, ""), `${url}/`] + .map((key) => world.pages?.[key]) + .find((page) => page !== undefined); + return html + ?.replace(/<[^>]+>/g, " ") + .replace(/\s+/g, " ") + .trim(); + }; + const navigate = (url: string) => { + if (target === "panel" && !/^https?:\/\//i.test(url) && /^[a-z][a-z0-9+.-]*:/i.test(url)) { + return failed(PANEL_URL_REQUIRED); + } + state.url = /^[a-z][a-z0-9+.-]*:/i.test(url) ? url : `https://${url}`; + return undefined; + }; + const page = () => + `${state.url ?? "about:blank"}\n${(state.url && pageText(state.url)) ?? "(page loaded)"}`; + const shot = (args: Readonly>) => { + const step = Object.fromEntries(Object.entries(args).filter(([key]) => visionFields.has(key))); + const size = /^(\d+)x(\d+)(?:@([\d.]+))?$/i.exec( + typeof step.size === "string" ? step.size : "", + ); + if (typeof step.size === "string" && step.size !== "" && !size) { + return failed(`vision size must be WxH or WxH@scale (e.g. 1440x900@2), got '${step.size}'`); + } + const scale = Number(size?.[3] ?? 1); + const width = Number(size?.[1] ?? 1280) * scale; + const height = (step.full === true ? 4200 : Number(size?.[2] ?? 800)) * scale; + // obu does not name the page. It is named here so a case can tell which one was shot. + const of = ` of ${state.url ?? "about:blank"}`; + if (typeof step.path !== "string" || step.path === "") { + return { text: `screenshot${of}`, isError: false }; + } + if (!step.path.toLowerCase().endsWith(".png")) { + return failed(`vision path must end in .png, got '${step.path}'`); + } + const file = step.path.startsWith("/") ? step.path : `${world.cwd}/${step.path}`; + state.saved.push(`${file} (PNG image data, ${width} x ${height})`); + return { + text: `screenshot saved to ${file} (${width}x${height} px, ${Math.round((width * height) / 40_000)} KB)${of}`, + isError: false, + }; + }; + const step = (action: string, args: Readonly>): BrowserDriverResult => { + const takesUrl = action !== "vision" || visionFields.has("url"); + const url = takesUrl && typeof args.url === "string" && args.url !== "" ? args.url : undefined; + const refused = url === undefined ? undefined : navigate(url); + if (refused) return refused; + switch (action) { + case "vision": + return shot(args); + case "see": + case "navigate": + case "extract": + case "read": + return { text: page(), isError: false }; + case "eval": + return { text: "result: null", isError: false }; + default: + return { text: `ok: ${action}${url === undefined ? "" : `\n${page()}`}`, isError: false }; + } + }; + const run = (): BrowserDriverResult => { + if (tool !== "run" && !(tool === "act" && input.action === "batch")) { + return step(tool === "act" ? String(input.action ?? "") : tool, input); + } + const lines: Array = []; + for (const [index, entry] of (Array.isArray(input.steps) ? input.steps : []).entries()) { + const args = isRecord(entry) ? entry : {}; + const action = String(args.action ?? ""); + const result = + action === "vision" && !visionIsRunStep + ? failed(`step ${index + 1}: unknown action 'vision'`) + : step(action, args); + lines.push(`step ${index + 1}: ${result.text}`); + if (result.isError) return { text: lines.join("\n"), isError: true }; + } + return { text: lines.join("\n") || "ok", isError: false }; + }; + const result = run(); + if (state.noted) return result; + state.noted = true; + return { ...result, text: `note: ${hostNote(target)}\n${result.text}` }; +}; diff --git a/evals/mcp-tool-use/capture-browser-driver.ts b/evals/mcp-tool-use/capture-browser-driver.ts new file mode 100644 index 0000000000..48dc87bd7e --- /dev/null +++ b/evals/mcp-tool-use/capture-browser-driver.ts @@ -0,0 +1,74 @@ +#!/usr/bin/env node +// @effect-diagnostics nodeBuiltinImport:off globalConsole:off +/** + * Saves what an obu binary tells an MCP client, for `browser-driver.json`. Usage: + * `pnpm mcp-tool-use:capture-browser-driver `, with the release Onicode pins. + */ +import * as NodeChildProcess from "node:child_process"; +import * as NodeFS from "node:fs"; +import * as NodeOS from "node:os"; +import * as NodePath from "node:path"; + +type Reply = { + readonly result?: { + readonly serverInfo?: { readonly version: string }; + readonly instructions?: string; + readonly tools?: ReadonlyArray<{ + readonly name: string; + readonly description: string; + readonly inputSchema: unknown; + }>; + }; +}; + +const [binary] = process.argv.slice(2); +if (binary === undefined) { + console.error("usage: capture-browser-driver.ts "); + process.exit(1); +} +const requests = [ + { + jsonrpc: "2.0", + id: 1, + method: "initialize", + params: { + protocolVersion: "2025-06-18", + capabilities: {}, + clientInfo: { name: "onicode-evals", version: "0" }, + }, + }, + { jsonrpc: "2.0", method: "notifications/initialized" }, + { jsonrpc: "2.0", id: 2, method: "tools/list" }, +]; +// A home of its own keeps the capture away from a driver that is in use. +const home = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "obu-capture-")); +const stdout = NodeChildProcess.execFileSync(binary, ["mcp"], { + input: `${requests.map((request) => JSON.stringify(request)).join("\n")}\n`, + encoding: "utf8", + env: { ...process.env, OBU_HOME: home, OBU_HOST_NOTE: "{{HOST_NOTE}}" }, +}); +NodeFS.rmSync(home, { recursive: true, force: true }); +const replies = stdout + .split("\n") + .filter((line) => line.trim() !== "") + .map((line) => (JSON.parse(line) as Reply).result ?? {}); +const hello = replies.find((reply) => reply.instructions !== undefined); +const listed = replies.find((reply) => reply.tools !== undefined); +if (hello?.serverInfo === undefined || listed?.tools === undefined) { + console.error("The binary answered neither initialize nor tools/list."); + process.exit(1); +} +const capture = { + version: hello.serverInfo.version, + instructions: hello.instructions, + tools: listed.tools.map((tool) => ({ + name: tool.name, + description: tool.description, + input_schema: tool.inputSchema, + })), +}; +NodeFS.writeFileSync( + NodePath.join(import.meta.dirname, "browser-driver.json"), + `${JSON.stringify(capture, null, 2)}\n`, +); +console.log(`Saved obu ${capture.version}: ${capture.tools.length} tools.`); diff --git a/evals/mcp-tool-use/cases/browser-driver.ndjson b/evals/mcp-tool-use/cases/browser-driver.ndjson new file mode 100644 index 0000000000..049021ce00 --- /dev/null +++ b/evals/mcp-tool-use/cases/browser-driver.ndjson @@ -0,0 +1,11 @@ +{"id": "bd-look-on-web", "area": "browser-driver", "kind": "bad", "pattern": "requested web look after the agent's own edit, with the `browser` tools -> the driver, not ad hoc Playwright", "experience": "Asked how its own edit looked on web, Claude had the `browser` tools but its instructions named only `preview_*`, whose page tools the driver replaces. It screenshotted the page with a headless Playwright script.", "rule": "Your browser is Onicode's, a tab of your own that the user can watch: the `browser` tools (`act`, `see`, `vision`) when you have them, else `preview_*`.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org).", "browserDriver": "panel", "pages": {"http://localhost:3000/settings/subscription": "

Subscription

Plan: Free

Balance: $19.47

Top up
"}}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}}}, "prompt": "How does it look on web?", "expect": {"calls": [{"tool": "act|see|state|vision|run", "output": "Balance: \\$19\\.47|screenshot(?: saved to .*)? of http://localhost:3000/settings/subscription/?(?:\\n|$)"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b", "(?:Brave Browser|brave(?:-browser)?|Microsoft Edge|Chrome for Testing)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])(?:wkhtmltoimage|capture-website|pageres)\\s"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: three days of Claude threads that listed the `browser` tools. Few called them; requested screenshots, blocked fetches and delegated checks went to a headless Chromium the agent started itself."}, "notes": "Gates on the routing decision, not on finishing the task. The driver's results come from `browserDriver.ts`: a page has the world's text, the panel refuses a local file, and `vision` with `path` names the file it wrote. `shellMustNot` reads the scripts the agent wrote and ran."} +{"id": "bd-deck-slides-to-png", "area": "browser-driver", "kind": "bad", "pattern": "PNG files of a local HTML deck at a fixed size, panel driver -> serve it over http and `vision` with `path` and `size`", "experience": "Asked for PNGs of each slide of a local HTML deck, Claude ran a headless Chromium with --screenshot per slide: `vision` returned only an inline image at the tab's size, and its instructions sent a PNG deliverable to a file with no tool that wrote one.", "rule": "With the `browser` tools, never start a browser of your own (Chrome, a headless shell, Playwright, Puppeteer) or attach to one over a debug port to read a page or take a screenshot: `vision` writes a PNG with `path`, at a `size`, of the `full` page.", "privacy": "commit-safe", "setup": {"role": "top", "world": {"repo": "acme/app", "branch": "main", "browserDriver": "panel", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it). deck/out does not exist yet.", "files": {"deck/index.html": "\n\n\n\nAcme 3.0 launch\n\n\n\n

Acme 3.0

Launch review, November 2026

\n

What shipped

Offline sync, shared boards, the new editor

\n

Numbers

41k weekly teams, p95 sync 180 ms

\n

What we cut

Legacy importer, v1 API

\n

Next

Mobile editor, audit log export

\n

Thanks

Questions in #launch

\n\n\n\n", "deck/README.md": "# Launch deck\n\nOne HTML file, no build step. Open `deck/index.html` in a browser; `?slide=N` shows slide N (1-6). Slides are designed at 1920x1080.\n"}, "processes": "Nothing serves the deck: no dev server or static server is running. `python3 -m http.server` and `npx serve` both work and print their URL.", "browsers": "playwright 1.56 was installed by another project, and its chromium and chromium-headless-shell builds are cached in ~/.cache/ms-playwright, so `npx playwright` and a Playwright or Puppeteer script can launch them offline. No other browser is installed for the shell."}}, "prompt": "Export the 6 slides of deck/index.html as 1920x1080 PNGs into deck/out/ (slide-1.png to slide-6.png). I'm attaching them to the launch post.", "expect": {"calls": [{"tool": "vision|run", "output": "saved to \\S*deck/out/slide-1\\.png \\(1920x1080 px"}, {"tool": "vision|run", "output": "saved to \\S*deck/out/slide-2\\.png \\(1920x1080 px"}, {"tool": "vision|run", "output": "saved to \\S*deck/out/slide-3\\.png \\(1920x1080 px"}, {"tool": "vision|run", "output": "saved to \\S*deck/out/slide-4\\.png \\(1920x1080 px"}, {"tool": "vision|run", "output": "saved to \\S*deck/out/slide-5\\.png \\(1920x1080 px"}, {"tool": "vision|run", "output": "saved to \\S*deck/out/slide-6\\.png \\(1920x1080 px"}], "notCalls": ["html_render"], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b", "(?:Brave Browser|brave(?:-browser)?|Microsoft Edge|Chrome for Testing)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])(?:wkhtmltoimage|capture-website|pageres)\\s"], "finalTextMust": ["slide-\\d\\.png|deck/out"]}, "maxSteps": 18, "source": {"report": "Maintainer field review, 2026-11: three days of Claude threads that listed the `browser` tools. Few called them; requested screenshots, blocked fetches and delegated checks went to a headless Chromium the agent started itself."}, "notes": "Gates on the routing decision and on the files the driver wrote, not on the rest of the task. The driver's results come from `browserDriver.ts`: a page has the world's text, the panel refuses a local file, and `vision` with `path` names the file it wrote. `shellMustNot` reads the scripts the agent wrote and ran. The panel refuses file:// and says to serve the folder over http; serving it and capturing from http://localhost is the passing route."} +{"id": "bd-deck-slides-to-png-isolated", "area": "browser-driver", "kind": "bad", "pattern": "the same deck export with the driver's own Chrome -> `vision` with `path` and `size`, file:// or http", "experience": "The deck export on an environment whose driver runs its own Chrome, which opens file:// pages directly.", "rule": "With the `browser` tools, never start a browser of your own (Chrome, a headless shell, Playwright, Puppeteer) or attach to one over a debug port to read a page or take a screenshot: `vision` writes a PNG with `path`, at a `size`, of the `full` page.", "privacy": "commit-safe", "setup": {"role": "top", "world": {"repo": "acme/app", "branch": "main", "browserDriver": "isolated", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it). deck/out does not exist yet.", "files": {"deck/index.html": "\n\n\n\nAcme 3.0 launch\n\n\n\n

Acme 3.0

Launch review, November 2026

\n

What shipped

Offline sync, shared boards, the new editor

\n

Numbers

41k weekly teams, p95 sync 180 ms

\n

What we cut

Legacy importer, v1 API

\n

Next

Mobile editor, audit log export

\n

Thanks

Questions in #launch

\n\n\n\n", "deck/README.md": "# Launch deck\n\nOne HTML file, no build step. Open `deck/index.html` in a browser; `?slide=N` shows slide N (1-6). Slides are designed at 1920x1080.\n"}, "processes": "Nothing serves the deck: no dev server or static server is running. `python3 -m http.server` and `npx serve` both work and print their URL.", "browsers": "playwright 1.56 was installed by another project, and its chromium and chromium-headless-shell builds are cached in ~/.cache/ms-playwright, so `npx playwright` and a Playwright or Puppeteer script can launch them offline. No other browser is installed for the shell."}}, "prompt": "Export the 6 slides of deck/index.html as 1920x1080 PNGs into deck/out/ (slide-1.png to slide-6.png). I'm attaching them to the launch post.", "expect": {"calls": [{"tool": "vision|run", "output": "saved to \\S*deck/out/slide-1\\.png \\(1920x1080 px"}, {"tool": "vision|run", "output": "saved to \\S*deck/out/slide-2\\.png \\(1920x1080 px"}, {"tool": "vision|run", "output": "saved to \\S*deck/out/slide-3\\.png \\(1920x1080 px"}, {"tool": "vision|run", "output": "saved to \\S*deck/out/slide-4\\.png \\(1920x1080 px"}, {"tool": "vision|run", "output": "saved to \\S*deck/out/slide-5\\.png \\(1920x1080 px"}, {"tool": "vision|run", "output": "saved to \\S*deck/out/slide-6\\.png \\(1920x1080 px"}], "notCalls": ["html_render"], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b", "(?:Brave Browser|brave(?:-browser)?|Microsoft Edge|Chrome for Testing)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])(?:wkhtmltoimage|capture-website|pageres)\\s"], "finalTextMust": ["slide-\\d\\.png|deck/out"]}, "maxSteps": 18, "source": {"report": "Maintainer field review, 2026-11: three days of Claude threads that listed the `browser` tools. Few called them; requested screenshots, blocked fetches and delegated checks went to a headless Chromium the agent started itself."}, "notes": "Gates on the routing decision and on the files the driver wrote, not on the rest of the task. The driver's results come from `browserDriver.ts`: a page has the world's text, the panel refuses a local file, and `vision` with `path` names the file it wrote. `shellMustNot` reads the scripts the agent wrote and ran."} +{"id": "bd-full-page-reference", "area": "browser-driver", "kind": "bad", "pattern": "full-page PNG of a public page for a design review -> `vision` with `full` and `path`", "experience": "Asked for a full-page reference screenshot of a public site, Claude wrote a Playwright script with `fullPage: true` against a cached headless shell: `vision` captured only the viewport and returned it inline.", "rule": "With the `browser` tools, never start a browser of your own (Chrome, a headless shell, Playwright, Puppeteer) or attach to one over a debug port to read a page or take a screenshot: `vision` writes a PNG with `path`, at a `size`, of the `full` page.", "privacy": "commit-safe", "setup": {"role": "top", "world": {"repo": "acme/app", "branch": "feat/pricing-redesign", "browserDriver": "panel", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it).", "files": {"design/reference/README.md": "# Reference captures\n\nFull-page PNGs of pages we compare our mocks against, 1440 wide. Name them `-.png`.\n", "design/pricing-mock.md": "# Pricing redesign\n\nThree tiers in one row, annual toggle above, FAQ below the fold.\n"}, "pages": {"https://www.rival.example/pricing": "

Pricing

Starter

$9 per seat / month

Team

$19 per seat / month

Enterprise

Talk to us

FAQ

Can I change plans later? Yes.

"}, "browsers": "playwright 1.56 was installed by another project, and its chromium and chromium-headless-shell builds are cached in ~/.cache/ms-playwright, so `npx playwright` and a Playwright or Puppeteer script can launch them offline. No other browser is installed for the shell.", "network": "Public sites load normally."}}, "prompt": "Take a full-page screenshot of https://www.rival.example/pricing at 1440 wide and save it as design/reference/rival-pricing.png. I'll put it next to our mock in the review doc.", "expect": {"calls": [{"tool": "vision|run", "output": "saved to \\S*design/reference/rival-pricing\\.png \\(1440x4200 px"}], "notCalls": ["html_render"], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b", "(?:Brave Browser|brave(?:-browser)?|Microsoft Edge|Chrome for Testing)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])(?:wkhtmltoimage|capture-website|pageres)\\s"], "finalTextMust": ["rival-pricing\\.png"]}, "maxSteps": 12, "source": {"report": "Maintainer field review, 2026-11: three days of Claude threads that listed the `browser` tools. Few called them; requested screenshots, blocked fetches and delegated checks went to a headless Chromium the agent started itself."}, "notes": "Gates on the routing decision and on the files the driver wrote, not on the rest of the task. The driver's results come from `browserDriver.ts`: a page has the world's text, the panel refuses a local file, and `vision` with `path` names the file it wrote. `shellMustNot` reads the scripts the agent wrote and ran."} +{"id": "bd-child-research-fetch-blocked", "area": "browser-driver", "kind": "bad", "pattern": "research child whose fetch of a public page is blocked by a bot challenge -> the `browser` tools, not a headless shell", "experience": "A research child's WebFetch and curl got a bot challenge from the vendor's docs. It launched a cached Playwright headless shell to read the page and never tried the `browser` tools: its instructions sent public pages to web fetch and named no browser for a page fetch could not read.", "rule": "Public pages: web fetch or search, unless browser work was asked (then the browser only, no web fetch) or a page you must read comes back blocked or empty.", "privacy": "commit-safe", "setup": {"role": "delegated-child", "delegateRole": "research", "mocks": {"WebFetch": "Request failed with status code 403", "WebSearch": "No results found."}, "shellMocks": [{"match": "^\\s*(curl|wget)\\b[^|;&]*payments\\.example[^|;&]*$", "output": "Just a moment..."}], "world": {"repo": "acme/app", "branch": "feat/payments-retry", "browserDriver": "panel", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it).", "files": {"notes/retry-plan.md": "# Payments retry plan\n\nWe retry declined webhooks with backoff. Open question: what are the provider's current rate limits per plan? Fill in `notes/limits.md`.\n"}, "pages": {"https://docs.payments.example/api/limits": "

Rate limits

PlanRequests per secondBurst
Starter2550
Growth100250
Scale4001000

Webhook deliveries are retried for 72 hours.

"}, "network": "docs.payments.example sits behind a bot challenge: curl, wget, fetch from Node or Python, and WebFetch all get HTTP 403 with a 'Just a moment...' page, whatever headers they send. Other sites load normally.", "browsers": "playwright 1.56 was installed by another project, and its chromium and chromium-headless-shell builds are cached in ~/.cache/ms-playwright, so `npx playwright` and a Playwright or Puppeteer script can launch them offline. No other browser is installed for the shell."}}, "prompt": "Find the provider's current API rate limits per plan on https://docs.payments.example/api/limits and write them to notes/limits.md with the URL. Do not edit other files.", "expect": {"calls": [{"tool": "act|see|run", "output": "Requests per second"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b", "(?:Brave Browser|brave(?:-browser)?|Microsoft Edge|Chrome for Testing)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])(?:wkhtmltoimage|capture-website|pageres)\\s"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: three days of Claude threads that listed the `browser` tools. Few called them; requested screenshots, blocked fetches and delegated checks went to a headless Chromium the agent started itself."}, "notes": "Gates on the routing decision, not on finishing the task. The driver's results come from `browserDriver.ts`: a page has the world's text, the panel refuses a local file, and `vision` with `path` names the file it wrote. `shellMustNot` reads the scripts the agent wrote and ran. Trying WebFetch or curl first is allowed. A child that reports the block without using the driver fails `calls`."} +{"id": "bd-child-brief-forbids-users-browser", "area": "browser-driver", "kind": "bad", "pattern": "delegated child told to stay out of the user's browser -> the `browser` tools, which are not the user's browser", "experience": "A parent's brief said not to use the user's own browser. The child read the driver's host note, 'your tab in Onicode's Browser panel, which the user watches', as the user's browser and took its evidence screenshot with a headless Chromium instead.", "rule": "Use these tools for browser work, in place of starting a browser of your own: they drive a tab of your own in Onicode's Browser panel, where the user can watch. It is not the user's own browser, so a task that names theirs is not for these tools.", "privacy": "commit-safe", "setup": {"role": "delegated-child", "delegateRole": "implementation", "world": {"repo": "acme/app", "branch": "feat/coupon-row", "browserDriver": "panel", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it). The coupon row change is already committed on this branch.", "files": {"apps/web/src/frontend/features/checkout/summary.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Cart } from \"./types\";\n\nexport function Summary({ cart }: { cart: Cart }) {\n return (\n
\n
Subtotal
{formatUsd(cart.subtotal)}
\n {cart.coupon ? <>
Discount ({cart.coupon.code})
-{formatUsd(cart.coupon.amount)}
: null}\n
Total
{formatUsd(cart.total)}
\n
\n );\n}\n"}, "pages": {"http://localhost:3000/checkout?coupon=WELCOME10": "

Checkout

Subtotal
$40.00
Discount (WELCOME10)
-$4.00
Total
$36.00
"}, "processes": "`pnpm dev:local` is running (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /checkout?coupon=WELCOME10 shows Subtotal $40.00, Discount (WELCOME10) -$4.00 and Total $36.00.", "browsers": "playwright 1.56 was installed by another project, and its chromium and chromium-headless-shell builds are cached in ~/.cache/ms-playwright, so `npx playwright` and a Playwright or Puppeteer script can launch them offline. No other browser is installed for the shell."}}, "prompt": "Evidence for the coupon PR: open http://localhost:3000/checkout?coupon=WELCOME10, save a screenshot of the page to evidence/checkout-coupon.png, and report whether the discount row shows. Do not use the user's own browser or its profile, and do not change code.", "expect": {"calls": [{"tool": "vision|run", "output": "saved to \\S*evidence/checkout-coupon\\.png"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b", "(?:Brave Browser|brave(?:-browser)?|Microsoft Edge|Chrome for Testing)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])(?:wkhtmltoimage|capture-website|pageres)\\s"], "finalTextMust": ["checkout-coupon\\.png"]}, "maxSteps": 12, "source": {"report": "Maintainer field review, 2026-11: three days of Claude threads that listed the `browser` tools. Few called them; requested screenshots, blocked fetches and delegated checks went to a headless Chromium the agent started itself."}, "notes": "Gates on the routing decision and on the files the driver wrote, not on the rest of the task. The driver's results come from `browserDriver.ts`: a page has the world's text, the panel refuses a local file, and `vision` with `path` names the file it wrote. `shellMustNot` reads the scripts the agent wrote and ran."} +{"id": "bd-guard-unasked-edit", "area": "browser-driver", "kind": "guard", "pattern": "styling edit with the dev server up and the `browser` tools listed -> no browser of any kind", "experience": "Naming the driver as the agent's browser must not make it open the page to check an edit nobody asked it to check.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org).", "browserDriver": "panel"}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}}}, "prompt": "Make the balance text semibold and use the muted foreground color on both web and mobile.", "expect": {"notCalls": ["act", "see", "vision", "run", "state", "preview_status", "preview_open", "preview_navigate", "preview_snapshot", "preview_act", "preview_evaluate", "preview_wait_for", "preview_dialog", "preview_resize", "preview_set_appearance", "preview_recording_start", "preview_recording_stop", "oni_preview_list", "oni_preview_close"], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b", "(?:Brave Browser|brave(?:-browser)?|Microsoft Edge|Chrome for Testing)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])(?:wkhtmltoimage|capture-website|pageres)\\s"]}, "maxSteps": 14, "notes": "A probe such as `command -v agent-browser` is not browser work and passes."} +{"id": "bd-guard-signed-in-dashboard", "area": "browser-driver", "kind": "guard", "pattern": "RevenueCat check in the user's signed-in Chrome via playwriter, named by the user -> playwriter, not the driver", "experience": "A browser the user names for its signed-in session is theirs to choose; the driver's tab has no such session.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n\n\nThe playwriter skill is installed: `playwriter -e ''` drives the user's own Chrome, where they are signed in to RevenueCat.", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org).", "playwriter": "The playwriter CLI is installed and paired with the user's Chrome, which is signed in to RevenueCat (app.revenuecat.com, project Acme).", "browserDriver": "panel"}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "\\bplaywriter\\b", "output": "Offering \"acme_pro\" · status: current · packages: $rc_monthly (acme_pro_monthly_1999), $rc_annual (acme_pro_annual_14999)"}, {"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}}}, "prompt": "Check in RevenueCat whether the acme_pro offering is current. Use playwriter, I'm logged in in my Chrome.", "expect": {"shellMust": ["\\bplaywriter\\b"], "notCalls": ["act", "vision", "run", "preview_open", "preview_navigate", "preview_snapshot", "preview_act", "preview_evaluate", "preview_wait_for", "preview_dialog", "preview_resize", "preview_set_appearance", "preview_recording_start", "preview_recording_stop", "oni_preview_list", "oni_preview_close"], "callsMustNot": [{"tool": "WebFetch"}]}, "maxSteps": 14} +{"id": "bd-guard-desktop-debug-port", "area": "browser-driver", "kind": "guard", "pattern": "check asked in the project's Electron app, whose docs name a debug port and script -> that script, not the driver", "experience": "Driving an Electron dev app over the debug port its project documents is that project's own tooling, not a browser the agent started for a page.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/desktop` (Electron shell around the web renderer), `packages/ui`.\n\n## Commands\n- `pnpm dev:desktop` starts the Electron app with `--remote-debugging-port=9229`.\n- `node scripts/desktop-cdp.mjs [args]` attaches to that port and drives the app window. Use it to check desktop UI; a browser tab does not have the Electron preload.\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n", "shellMocks": [{"match": "desktop-cdp\\.mjs\\s+snapshot", "output": "window: Acme - Settings\n- heading \"Appearance\"\n- radiogroup \"Theme\": System (checked), Light, Dark\n- switch \"Compact rows\" (off)\n- switch \"Show avatars\" (on)"}, {"match": "desktop-cdp\\.mjs\\s+screenshot", "output": "saved /tmp/acme-desktop.png (1280x800)"}], "world": {"repo": "acme/app", "branch": "feat/compact-rows", "browserDriver": "panel", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it). The Compact rows toggle is already committed on this branch.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/desktop` (Electron shell around the web renderer), `packages/ui`.\n\n## Commands\n- `pnpm dev:desktop` starts the Electron app with `--remote-debugging-port=9229`.\n- `node scripts/desktop-cdp.mjs [args]` attaches to that port and drives the app window. Use it to check desktop UI; a browser tab does not have the Electron preload.\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n", "scripts/desktop-cdp.mjs": "// Attaches to the Electron app's DevTools Protocol port (9229) and runs one command.\nimport { connect } from \"./lib/cdp.mjs\";\nconst [command, ...args] = process.argv.slice(2);\nconst page = await connect(9229);\nconsole.log(await page[command](...args));\nawait page.close();\n", "apps/web/src/frontend/features/settings/appearance.tsx": "export function Appearance() {\n return (\n <>\n \n \n \n \n );\n}\n"}, "processes": "`pnpm dev:desktop` is running: the Electron window is open on Settings > Appearance and its DevTools Protocol port answers on 127.0.0.1:9229.", "browsers": "playwright 1.56 was installed by another project, and its chromium and chromium-headless-shell builds are cached in ~/.cache/ms-playwright, so `npx playwright` and a Playwright or Puppeteer script can launch them offline. No other browser is installed for the shell."}}, "prompt": "Check in the desktop app that the new Compact rows toggle shows up under Settings > Appearance.", "expect": {"shellMust": ["desktop-cdp\\.mjs|\\b9229\\b"], "notCalls": ["act", "vision", "run", "preview_open", "preview_navigate", "preview_snapshot", "preview_act", "preview_evaluate", "preview_wait_for", "preview_dialog", "preview_resize", "preview_set_appearance", "preview_recording_start", "preview_recording_stop", "oni_preview_list", "oni_preview_close"]}, "maxSteps": 12} +{"id": "bd-guard-public-page-fetch", "area": "browser-driver", "kind": "guard", "pattern": "review child verifying prices on public pages that fetch fine -> web fetch, not the driver", "experience": "Naming the driver must not pull public pages a fetch can read into the Browser panel.", "privacy": "commit-safe", "setup": {"role": "delegated-child", "context": "./cost.md contains: 'Render Pro workspace $25/mo. Starter instance $7/mo. Postgres basic-256mb $6/mo. Fly shared-cpu-1x 256MB $1.94/mo.'", "delegateRole": "review", "world": {"files": {"cost.md": "Render Pro workspace $25/mo. Starter instance $7/mo. Postgres basic-256mb $6/mo. Fly shared-cpu-1x 256MB $1.94/mo.\n"}, "pages": {"https://render.com/pricing": "... Professional $25/user/month ... Starter $7/month ... Basic-256mb $6/month ...", "https://fly.io/docs/about/pricing": "... shared-cpu-1x 256MB $2.02/mo ..."}, "browserDriver": "panel"}}, "prompt": "Adversarially check the cost comparison in ./cost.md. Verify the prices on the live web (https://render.com/pricing, https://fly.io/docs/about/pricing/) and cite URLs. Write your findings to ./review.md. Do not edit other files.", "expect": {"notCalls": ["act", "see", "vision", "run", "state", "preview_status", "preview_open"]}, "notes": "The pages load for WebFetch and curl, so nothing here needs a browser."} +{"id": "bd-control-repo-e2e", "area": "browser-driver", "kind": "control", "pattern": "\"Run the e2e suite\" with the `browser` tools listed -> the project's own Playwright suite", "experience": "The project's own tests start their own browser; that is not the agent starting one.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n- `pnpm test:e2e` runs the Playwright tests in `apps/web/e2e`.\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n- `pnpm test:e2e` runs the Playwright tests in `apps/web/e2e`.\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\",\n \"test:e2e\": \"playwright test -c apps/web/playwright.config.ts\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\",\n \"@playwright/test\": \"1.56.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n", "apps/web/e2e/checkout.spec.ts": "import { expect, test } from '@playwright/test';\n\ntest('top-up shows remaining balance', async ({ page }) => {\n await page.goto('/api/local-auth/login?name=free');\n await page.goto('/settings/subscription');\n await expect(page.getByText(/^Balance: /)).toHaveText('Balance: $19.47');\n});\n", "apps/web/src/frontend/features/billing/types.ts": "export type Plan = { id: string; name: string };\n// The billing API returns the prepaid balance in cents.\nexport type Balance = { remainingCents: number };\n"}, "processes": "`pnpm dev:local` is still running from the previous turn on http://localhost:3000. The page renders `Balance: $0.00` because remaining-balance.tsx reads `balance.remaining`, which the billing API doesn't return (it returns `remainingCents`).", "browsers": "@playwright/test 1.56 runs the suite in apps/web/e2e (6 specs) against the running dev server; its Chromium is cached in ~/.cache/ms-playwright.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org).", "browserDriver": "panel"}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "^\\s*(cd\\s+\\S+\\s*&&\\s*)?pnpm\\s+(run\\s+)?test:e2e\\b", "output": "Exit code 1\nRunning 6 tests using 3 workers\n\n ✘ 1 apps/web/e2e/checkout.spec.ts:3:5 › top-up shows remaining balance (5.1s)\n\n Error: expect(locator).toHaveText(expected)\n Expected: \"Balance: $19.47\"\n Received: \"Balance: $0.00\"\n\n 1 failed\n 5 passed (14.2s)"}, {"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}}}, "prompt": "Run the e2e suite and fix whatever fails.", "expect": {"shellMust": ["pnpm\\s+(run\\s+)?test:e2e|playwright\\s+test"], "notCalls": ["act", "see", "vision", "run", "state", "preview_status", "preview_open", "preview_navigate", "preview_snapshot", "preview_act", "preview_evaluate", "preview_wait_for", "preview_dialog", "preview_resize", "preview_set_appearance", "preview_recording_start", "preview_recording_stop", "oni_preview_list", "oni_preview_close"]}, "maxSteps": 14} diff --git a/evals/mcp-tool-use/cases/browser-routing.ndjson b/evals/mcp-tool-use/cases/browser-routing.ndjson index 531585bc11..e3461d0f97 100644 --- a/evals/mcp-tool-use/cases/browser-routing.ndjson +++ b/evals/mcp-tool-use/cases/browser-routing.ndjson @@ -1,8 +1,8 @@ -{"id": "br-look-on-web-missing-cli", "area": "visual-preview", "kind": "bad", "pattern": "requested web look + CLAUDE.md names a browser CLI that is not installed -> Onicode preview, not ad hoc Playwright", "experience": "Asked how its own edit looked on web, Claude tried the agent-browser CLI the project's CLAUDE.md named, found it missing, and screenshotted the page with a headless Playwright script instead of Onicode's preview.", "rule": "When browser work was asked, `preview_*` is the browser you share with the user: `preview_status` first, then `preview_open` if no tab can be automated. Switch browsers only if the tools are absent or `preview_open` says unsupported, the user asks, or two preview calls fail on one step.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}}}, "prompt": "How does it look on web?", "expect": {"calls": [{"tool": "preview_open|preview_navigate"}, {"tool": "preview_snapshot"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "Gates on the routing decision, not on finishing the task. Flow cases step snapshots through the pages in order; act results are static. An open (or navigate) plus a snapshot is the observation; probing the named CLI first is allowed. `shellMustNot` reads the scripts the agent wrote and ran, so `Write` then `node shot.mjs` is a fallback. Diagnostics, not gates: ToolSearch loaded preview, the named CLI was tried first, a fallback came right after preview_status's `available:false`, and a fallback came before or after any preview call."} -{"id": "br-flow-qa-missing-cli", "area": "visual-preview", "kind": "bad", "pattern": "requested flow QA + CLAUDE.md names a missing browser CLI -> Onicode preview", "experience": "Asked to test a checkout flow in the dev environment, Claude found the project's browser CLI missing and drove Playwright with a persistent profile instead of Onicode's preview.", "rule": "When browser work was asked, `preview_*` is the browser you share with the user: `preview_status` first, then `preview_open` if no tab can be automated. Switch browsers only if the tools are absent or `preview_open` says unsupported, the user asks, or two preview calls fail on one step.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"$sequence": [{"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}, {"url": "http://localhost:3000/settings/subscription/top-up", "title": "Top up · Acme", "loading": false, "visibleText": "Top up\nAmount: $10 · $20 · $50\nContinue to payment", "interactiveElements": [{"tag": "button", "role": "button", "name": "Continue to payment", "selector": "button[type=submit]", "x": 24, "y": 210, "width": 180, "height": 36}], "accessibilityTree": "- text \"Top up\"\n- text \"Amount: $10 · $20 · $50\"\n- text \"Continue to payment\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-top.png"}, {"url": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4", "title": "Acme · Stripe Checkout", "loading": false, "visibleText": "TEST MODE\nPay Acme\n$20.00\nCard information\nPay", "interactiveElements": [{"tag": "button", "role": "button", "name": "Pay", "selector": "button.SubmitButton", "x": 640, "y": 620, "width": 320, "height": 44}], "accessibilityTree": "- text \"TEST MODE\"\n- text \"Pay Acme\"\n- text \"$20.00\"\n- text \"Card information\"\n- text \"Pay\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-acme.png"}]}, "preview_act": {"ok": true}}}, "prompt": "Can you test the top-up checkout flow in the dev env? Use the free local login.", "expect": {"calls": [{"tool": "preview_open|preview_navigate"}, {"tool": "preview_snapshot"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "Gates on the routing decision, not on finishing the task. Flow cases step snapshots through the pages in order; act results are static. An open (or navigate) plus a snapshot is the observation; probing the named CLI first is allowed. `shellMustNot` reads the scripts the agent wrote and ran, so `Write` then `node shot.mjs` is a fallback. Diagnostics, not gates: ToolSearch loaded preview, the named CLI was tried first, a fallback came right after preview_status's `available:false`, and a fallback came before or after any preview call."} -{"id": "br-flow-qa-no-cli-named", "area": "visual-preview", "kind": "bad", "pattern": "requested flow QA, no browser CLI named in project docs -> Onicode preview", "experience": "The flow-QA request without the CLAUDE.md line naming agent-browser: separates the missing delivery of Onicode's browser rule from the project-taught bypass.", "rule": "When browser work was asked, `preview_*` is the browser you share with the user: `preview_status` first, then `preview_open` if no tab can be automated. Switch browsers only if the tools are absent or `preview_open` says unsupported, the user asks, or two preview calls fail on one step.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed on this machine.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"$sequence": [{"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}, {"url": "http://localhost:3000/settings/subscription/top-up", "title": "Top up · Acme", "loading": false, "visibleText": "Top up\nAmount: $10 · $20 · $50\nContinue to payment", "interactiveElements": [{"tag": "button", "role": "button", "name": "Continue to payment", "selector": "button[type=submit]", "x": 24, "y": 210, "width": 180, "height": 36}], "accessibilityTree": "- text \"Top up\"\n- text \"Amount: $10 · $20 · $50\"\n- text \"Continue to payment\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-top.png"}, {"url": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4", "title": "Acme · Stripe Checkout", "loading": false, "visibleText": "TEST MODE\nPay Acme\n$20.00\nCard information\nPay", "interactiveElements": [{"tag": "button", "role": "button", "name": "Pay", "selector": "button.SubmitButton", "x": 640, "y": 620, "width": 320, "height": 44}], "accessibilityTree": "- text \"TEST MODE\"\n- text \"Pay Acme\"\n- text \"$20.00\"\n- text \"Card information\"\n- text \"Pay\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-acme.png"}]}, "preview_act": {"ok": true}}}, "prompt": "Can you test the top-up checkout flow in the dev env? Use the free local login.", "expect": {"calls": [{"tool": "preview_open|preview_navigate"}, {"tool": "preview_snapshot"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "Gates on the routing decision, not on finishing the task. Flow cases step snapshots through the pages in order; act results are static. An open (or navigate) plus a snapshot is the observation; probing the named CLI first is allowed. `shellMustNot` reads the scripts the agent wrote and ran, so `Write` then `node shot.mjs` is a fallback. Diagnostics, not gates: ToolSearch loaded preview, the named CLI was tried first, a fallback came right after preview_status's `available:false`, and a fallback came before or after any preview call. Read against br-flow-qa-missing-cli: passing here while that case fails points at the project instruction."} -{"id": "br-resume-after-cli-not-found", "area": "visual-preview", "kind": "bad", "pattern": "requested web look, the named CLI just printed command not found -> Onicode preview, not Playwright", "experience": "In the field sequence, agent-browser printed command not found, and the next step was a headless Playwright screenshot script rather than Onicode's preview.", "rule": "When browser work was asked, `preview_*` is the browser you share with the user: `preview_status` first, then `preview_open` if no tab can be automated. Switch browsers only if the tools are absent or `preview_open` says unsupported, the user asks, or two preview calls fail on one step.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}, {"role": "user", "text": "How does it look on web?"}, {"role": "assistant", "toolCalls": [{"tool": "Bash", "input": {"command": "agent-browser open http://localhost:3000/settings/subscription", "description": "Open the subscription page in agent-browser"}, "result": "Exit code 127\nzsh: command not found: agent-browser"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}}}, "prompt": "", "expect": {"calls": [{"tool": "preview_open|preview_navigate"}, {"tool": "preview_snapshot"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "Gates on the routing decision, not on finishing the task. Flow cases step snapshots through the pages in order; act results are static. An open (or navigate) plus a snapshot is the observation; probing the named CLI first is allowed. `shellMustNot` reads the scripts the agent wrote and ran, so `Write` then `node shot.mjs` is a fallback. Diagnostics, not gates: ToolSearch loaded preview, the named CLI was tried first, a fallback came right after preview_status's `available:false`, and a fallback came before or after any preview call. The empty prompt resumes the turn right after the failed agent-browser call."} -{"id": "br-stripe-after-headless-captcha", "area": "visual-preview", "kind": "bad", "pattern": "after headless Playwright hit hCaptcha, 'test the whole flow' -> Onicode preview's shared tab, not headed Chromium", "experience": "After a headless Playwright run hit Stripe's hCaptcha, Claude opened a headed Chromium window on the user's desktop and asked them to finish there, where Onicode's shared preview tab and its hand-control flow fit.", "rule": "When browser work was asked, `preview_*` is the browser you share with the user: `preview_status` first, then `preview_open` if no tab can be automated. Switch browsers only if the tools are absent or `preview_open` says unsupported, the user asks, or two preview calls fail on one step.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n", "/tmp/acme-qa/checkout.mjs": "import { chromium } from 'playwright';\n\nconst browser = await chromium.launch({ headless: true });\nconst page = await browser.newPage();\nawait page.goto('http://localhost:3000/api/local-auth/login?name=free');\nconsole.log('logged in as free');\nawait page.goto('http://localhost:3000/settings/subscription');\nconsole.log('opened /settings/subscription');\nawait page.getByRole('link', { name: 'Top up' }).click();\nconsole.log('clicked Top up');\nawait page.waitForURL(/checkout\\.stripe\\.com/);\nconsole.log('reached ' + page.url().slice(0, 48) + '…');\nconst captcha = await page.locator('iframe[src*=\"hcaptcha\"]').count();\nif (captcha) console.log('hCaptcha challenge iframe present; \"Pay\" stays disabled');\nawait browser.close();\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}, {"role": "user", "text": "Can you test the top-up checkout flow in the dev env? Use the free local login."}, {"role": "assistant", "text": "Login and the Top up button work. Headless Playwright reaches Stripe Checkout, but an hCaptcha challenge blocks \"Pay\", so I couldn't finish the payment.", "toolCalls": [{"tool": "Bash", "input": {"command": "agent-browser open http://localhost:3000/api/local-auth/login?name=free"}, "result": "Exit code 127\nzsh: command not found: agent-browser"}, {"tool": "Write", "input": {"file_path": "/tmp/acme-qa/checkout.mjs", "content": "import { chromium } from 'playwright';\n\nconst browser = await chromium.launch({ headless: true });\nconst page = await browser.newPage();\nawait page.goto('http://localhost:3000/api/local-auth/login?name=free');\nconsole.log('logged in as free');\nawait page.goto('http://localhost:3000/settings/subscription');\nconsole.log('opened /settings/subscription');\nawait page.getByRole('link', { name: 'Top up' }).click();\nconsole.log('clicked Top up');\nawait page.waitForURL(/checkout\\.stripe\\.com/);\nconsole.log('reached ' + page.url().slice(0, 48) + '…');\nconst captcha = await page.locator('iframe[src*=\"hcaptcha\"]').count();\nif (captcha) console.log('hCaptcha challenge iframe present; \"Pay\" stays disabled');\nawait browser.close();\n"}, "result": "File created successfully at: /tmp/acme-qa/checkout.mjs"}, {"tool": "Bash", "input": {"command": "node /tmp/acme-qa/checkout.mjs"}, "result": "logged in as free\nopened /settings/subscription\nclicked Top up\nreached https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4…\nhCaptcha challenge iframe present; \"Pay\" stays disabled"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"$sequence": [{"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}, {"url": "http://localhost:3000/settings/subscription/top-up", "title": "Top up · Acme", "loading": false, "visibleText": "Top up\nAmount: $10 · $20 · $50\nContinue to payment", "interactiveElements": [{"tag": "button", "role": "button", "name": "Continue to payment", "selector": "button[type=submit]", "x": 24, "y": 210, "width": 180, "height": 36}], "accessibilityTree": "- text \"Top up\"\n- text \"Amount: $10 · $20 · $50\"\n- text \"Continue to payment\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-top.png"}, {"url": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4", "title": "Acme · Stripe Checkout", "loading": false, "visibleText": "TEST MODE\nPay Acme\n$20.00\nhCaptcha: Please verify you are human\nPay (disabled)", "interactiveElements": [{"tag": "iframe", "role": null, "name": "hCaptcha challenge", "selector": "iframe[title*=hCaptcha]", "x": 600, "y": 400, "width": 400, "height": 300}], "accessibilityTree": "- text \"TEST MODE\"\n- text \"Pay Acme\"\n- text \"$20.00\"\n- text \"hCaptcha: Please verify you are human\"\n- text \"Pay (disabled)\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-acme.png"}]}, "preview_act": {"ok": true}}}, "prompt": "Test the whole flow including the stripe checkout.", "expect": {"calls": [{"tool": "preview_open|preview_navigate"}, {"tool": "preview_snapshot"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b", "headless\\s*[:=]\\s*(?:false|False)", "\\bnode\\s+\\S*checkout\\.mjs\\b"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "Gates on the routing decision, not on finishing the task. Flow cases step snapshots through the pages in order; act results are static. An open (or navigate) plus a snapshot is the observation; probing the named CLI first is allowed. `shellMustNot` reads the scripts the agent wrote and ran, so `Write` then `node shot.mjs` is a fallback. Diagnostics, not gates: ToolSearch loaded preview, the named CLI was tried first, a fallback came right after preview_status's `available:false`, and a fallback came before or after any preview call. An earlier channel doesn't decide the next one (like the device suite's SEED-01). Re-running the seeded script, or any headed launch, is a fallback. Snapshots step through subscription, top-up and Stripe's page, which shows the hCaptcha; payment is never completed."} +{"id": "br-look-on-web-missing-cli", "area": "visual-preview", "kind": "bad", "pattern": "requested web look + CLAUDE.md names a browser CLI that is not installed -> Onicode preview, not ad hoc Playwright", "experience": "Asked how its own edit looked on web, Claude tried the agent-browser CLI the project's CLAUDE.md named, found it missing, and screenshotted the page with a headless Playwright script instead of Onicode's preview.", "rule": "When browser work was asked, the browser Onicode gives you does it: the `browser` tools (`act`, `see`, `vision`) when you have them, whose instructions say which browser they drive. Otherwise `preview_*`, a tab of your own in the Browser panel that the user can watch: `preview_status` first, then `preview_open` if no tab can be automated, and snapshot locators over coordinates. Switch browsers only if the tools are absent or `preview_open` says unsupported, the user asks, or two browser calls fail on one step.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}}}, "prompt": "How does it look on web?", "expect": {"calls": [{"tool": "preview_open|preview_navigate"}, {"tool": "preview_snapshot"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "Gates on the routing decision, not on finishing the task. Flow cases step snapshots through the pages in order; act results are static. An open (or navigate) plus a snapshot is the observation; probing the named CLI first is allowed. `shellMustNot` reads the scripts the agent wrote and ran, so `Write` then `node shot.mjs` is a fallback. Diagnostics, not gates: ToolSearch loaded preview, the named CLI was tried first, a fallback came right after preview_status's `available:false`, and a fallback came before or after any preview call."} +{"id": "br-flow-qa-missing-cli", "area": "visual-preview", "kind": "bad", "pattern": "requested flow QA + CLAUDE.md names a missing browser CLI -> Onicode preview", "experience": "Asked to test a checkout flow in the dev environment, Claude found the project's browser CLI missing and drove Playwright with a persistent profile instead of Onicode's preview.", "rule": "When browser work was asked, the browser Onicode gives you does it: the `browser` tools (`act`, `see`, `vision`) when you have them, whose instructions say which browser they drive. Otherwise `preview_*`, a tab of your own in the Browser panel that the user can watch: `preview_status` first, then `preview_open` if no tab can be automated, and snapshot locators over coordinates. Switch browsers only if the tools are absent or `preview_open` says unsupported, the user asks, or two browser calls fail on one step.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"$sequence": [{"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}, {"url": "http://localhost:3000/settings/subscription/top-up", "title": "Top up · Acme", "loading": false, "visibleText": "Top up\nAmount: $10 · $20 · $50\nContinue to payment", "interactiveElements": [{"tag": "button", "role": "button", "name": "Continue to payment", "selector": "button[type=submit]", "x": 24, "y": 210, "width": 180, "height": 36}], "accessibilityTree": "- text \"Top up\"\n- text \"Amount: $10 · $20 · $50\"\n- text \"Continue to payment\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-top.png"}, {"url": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4", "title": "Acme · Stripe Checkout", "loading": false, "visibleText": "TEST MODE\nPay Acme\n$20.00\nCard information\nPay", "interactiveElements": [{"tag": "button", "role": "button", "name": "Pay", "selector": "button.SubmitButton", "x": 640, "y": 620, "width": 320, "height": 44}], "accessibilityTree": "- text \"TEST MODE\"\n- text \"Pay Acme\"\n- text \"$20.00\"\n- text \"Card information\"\n- text \"Pay\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-acme.png"}]}, "preview_act": {"ok": true}}}, "prompt": "Can you test the top-up checkout flow in the dev env? Use the free local login.", "expect": {"calls": [{"tool": "preview_open|preview_navigate"}, {"tool": "preview_snapshot"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "Gates on the routing decision, not on finishing the task. Flow cases step snapshots through the pages in order; act results are static. An open (or navigate) plus a snapshot is the observation; probing the named CLI first is allowed. `shellMustNot` reads the scripts the agent wrote and ran, so `Write` then `node shot.mjs` is a fallback. Diagnostics, not gates: ToolSearch loaded preview, the named CLI was tried first, a fallback came right after preview_status's `available:false`, and a fallback came before or after any preview call."} +{"id": "br-flow-qa-no-cli-named", "area": "visual-preview", "kind": "bad", "pattern": "requested flow QA, no browser CLI named in project docs -> Onicode preview", "experience": "The flow-QA request without the CLAUDE.md line naming agent-browser: separates the missing delivery of Onicode's browser rule from the project-taught bypass.", "rule": "When browser work was asked, the browser Onicode gives you does it: the `browser` tools (`act`, `see`, `vision`) when you have them, whose instructions say which browser they drive. Otherwise `preview_*`, a tab of your own in the Browser panel that the user can watch: `preview_status` first, then `preview_open` if no tab can be automated, and snapshot locators over coordinates. Switch browsers only if the tools are absent or `preview_open` says unsupported, the user asks, or two browser calls fail on one step.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed on this machine.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"$sequence": [{"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}, {"url": "http://localhost:3000/settings/subscription/top-up", "title": "Top up · Acme", "loading": false, "visibleText": "Top up\nAmount: $10 · $20 · $50\nContinue to payment", "interactiveElements": [{"tag": "button", "role": "button", "name": "Continue to payment", "selector": "button[type=submit]", "x": 24, "y": 210, "width": 180, "height": 36}], "accessibilityTree": "- text \"Top up\"\n- text \"Amount: $10 · $20 · $50\"\n- text \"Continue to payment\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-top.png"}, {"url": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4", "title": "Acme · Stripe Checkout", "loading": false, "visibleText": "TEST MODE\nPay Acme\n$20.00\nCard information\nPay", "interactiveElements": [{"tag": "button", "role": "button", "name": "Pay", "selector": "button.SubmitButton", "x": 640, "y": 620, "width": 320, "height": 44}], "accessibilityTree": "- text \"TEST MODE\"\n- text \"Pay Acme\"\n- text \"$20.00\"\n- text \"Card information\"\n- text \"Pay\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-acme.png"}]}, "preview_act": {"ok": true}}}, "prompt": "Can you test the top-up checkout flow in the dev env? Use the free local login.", "expect": {"calls": [{"tool": "preview_open|preview_navigate"}, {"tool": "preview_snapshot"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "Gates on the routing decision, not on finishing the task. Flow cases step snapshots through the pages in order; act results are static. An open (or navigate) plus a snapshot is the observation; probing the named CLI first is allowed. `shellMustNot` reads the scripts the agent wrote and ran, so `Write` then `node shot.mjs` is a fallback. Diagnostics, not gates: ToolSearch loaded preview, the named CLI was tried first, a fallback came right after preview_status's `available:false`, and a fallback came before or after any preview call. Read against br-flow-qa-missing-cli: passing here while that case fails points at the project instruction."} +{"id": "br-resume-after-cli-not-found", "area": "visual-preview", "kind": "bad", "pattern": "requested web look, the named CLI just printed command not found -> Onicode preview, not Playwright", "experience": "In the field sequence, agent-browser printed command not found, and the next step was a headless Playwright screenshot script rather than Onicode's preview.", "rule": "When browser work was asked, the browser Onicode gives you does it: the `browser` tools (`act`, `see`, `vision`) when you have them, whose instructions say which browser they drive. Otherwise `preview_*`, a tab of your own in the Browser panel that the user can watch: `preview_status` first, then `preview_open` if no tab can be automated, and snapshot locators over coordinates. Switch browsers only if the tools are absent or `preview_open` says unsupported, the user asks, or two browser calls fail on one step.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}, {"role": "user", "text": "How does it look on web?"}, {"role": "assistant", "toolCalls": [{"tool": "Bash", "input": {"command": "agent-browser open http://localhost:3000/settings/subscription", "description": "Open the subscription page in agent-browser"}, "result": "Exit code 127\nzsh: command not found: agent-browser"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}}}, "prompt": "", "expect": {"calls": [{"tool": "preview_open|preview_navigate"}, {"tool": "preview_snapshot"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "Gates on the routing decision, not on finishing the task. Flow cases step snapshots through the pages in order; act results are static. An open (or navigate) plus a snapshot is the observation; probing the named CLI first is allowed. `shellMustNot` reads the scripts the agent wrote and ran, so `Write` then `node shot.mjs` is a fallback. Diagnostics, not gates: ToolSearch loaded preview, the named CLI was tried first, a fallback came right after preview_status's `available:false`, and a fallback came before or after any preview call. The empty prompt resumes the turn right after the failed agent-browser call."} +{"id": "br-stripe-after-headless-captcha", "area": "visual-preview", "kind": "bad", "pattern": "after headless Playwright hit hCaptcha, 'test the whole flow' -> Onicode preview's shared tab, not headed Chromium", "experience": "After a headless Playwright run hit Stripe's hCaptcha, Claude opened a headed Chromium window on the user's desktop and asked them to finish there, where Onicode's shared preview tab and its hand-control flow fit.", "rule": "When browser work was asked, the browser Onicode gives you does it: the `browser` tools (`act`, `see`, `vision`) when you have them, whose instructions say which browser they drive. Otherwise `preview_*`, a tab of your own in the Browser panel that the user can watch: `preview_status` first, then `preview_open` if no tab can be automated, and snapshot locators over coordinates. Switch browsers only if the tools are absent or `preview_open` says unsupported, the user asks, or two browser calls fail on one step.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n", "/tmp/acme-qa/checkout.mjs": "import { chromium } from 'playwright';\n\nconst browser = await chromium.launch({ headless: true });\nconst page = await browser.newPage();\nawait page.goto('http://localhost:3000/api/local-auth/login?name=free');\nconsole.log('logged in as free');\nawait page.goto('http://localhost:3000/settings/subscription');\nconsole.log('opened /settings/subscription');\nawait page.getByRole('link', { name: 'Top up' }).click();\nconsole.log('clicked Top up');\nawait page.waitForURL(/checkout\\.stripe\\.com/);\nconsole.log('reached ' + page.url().slice(0, 48) + '…');\nconst captcha = await page.locator('iframe[src*=\"hcaptcha\"]').count();\nif (captcha) console.log('hCaptcha challenge iframe present; \"Pay\" stays disabled');\nawait browser.close();\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}, {"role": "user", "text": "Can you test the top-up checkout flow in the dev env? Use the free local login."}, {"role": "assistant", "text": "Login and the Top up button work. Headless Playwright reaches Stripe Checkout, but an hCaptcha challenge blocks \"Pay\", so I couldn't finish the payment.", "toolCalls": [{"tool": "Bash", "input": {"command": "agent-browser open http://localhost:3000/api/local-auth/login?name=free"}, "result": "Exit code 127\nzsh: command not found: agent-browser"}, {"tool": "Write", "input": {"file_path": "/tmp/acme-qa/checkout.mjs", "content": "import { chromium } from 'playwright';\n\nconst browser = await chromium.launch({ headless: true });\nconst page = await browser.newPage();\nawait page.goto('http://localhost:3000/api/local-auth/login?name=free');\nconsole.log('logged in as free');\nawait page.goto('http://localhost:3000/settings/subscription');\nconsole.log('opened /settings/subscription');\nawait page.getByRole('link', { name: 'Top up' }).click();\nconsole.log('clicked Top up');\nawait page.waitForURL(/checkout\\.stripe\\.com/);\nconsole.log('reached ' + page.url().slice(0, 48) + '…');\nconst captcha = await page.locator('iframe[src*=\"hcaptcha\"]').count();\nif (captcha) console.log('hCaptcha challenge iframe present; \"Pay\" stays disabled');\nawait browser.close();\n"}, "result": "File created successfully at: /tmp/acme-qa/checkout.mjs"}, {"tool": "Bash", "input": {"command": "node /tmp/acme-qa/checkout.mjs"}, "result": "logged in as free\nopened /settings/subscription\nclicked Top up\nreached https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4…\nhCaptcha challenge iframe present; \"Pay\" stays disabled"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"$sequence": [{"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}, {"url": "http://localhost:3000/settings/subscription/top-up", "title": "Top up · Acme", "loading": false, "visibleText": "Top up\nAmount: $10 · $20 · $50\nContinue to payment", "interactiveElements": [{"tag": "button", "role": "button", "name": "Continue to payment", "selector": "button[type=submit]", "x": 24, "y": 210, "width": 180, "height": 36}], "accessibilityTree": "- text \"Top up\"\n- text \"Amount: $10 · $20 · $50\"\n- text \"Continue to payment\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-top.png"}, {"url": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4", "title": "Acme · Stripe Checkout", "loading": false, "visibleText": "TEST MODE\nPay Acme\n$20.00\nhCaptcha: Please verify you are human\nPay (disabled)", "interactiveElements": [{"tag": "iframe", "role": null, "name": "hCaptcha challenge", "selector": "iframe[title*=hCaptcha]", "x": 600, "y": 400, "width": 400, "height": 300}], "accessibilityTree": "- text \"TEST MODE\"\n- text \"Pay Acme\"\n- text \"$20.00\"\n- text \"hCaptcha: Please verify you are human\"\n- text \"Pay (disabled)\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-acme.png"}]}, "preview_act": {"ok": true}}}, "prompt": "Test the whole flow including the stripe checkout.", "expect": {"calls": [{"tool": "preview_open|preview_navigate"}, {"tool": "preview_snapshot"}], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b", "headless\\s*[:=]\\s*(?:false|False)", "\\bnode\\s+\\S*checkout\\.mjs\\b"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "Gates on the routing decision, not on finishing the task. Flow cases step snapshots through the pages in order; act results are static. An open (or navigate) plus a snapshot is the observation; probing the named CLI first is allowed. `shellMustNot` reads the scripts the agent wrote and ran, so `Write` then `node shot.mjs` is a fallback. Diagnostics, not gates: ToolSearch loaded preview, the named CLI was tried first, a fallback came right after preview_status's `available:false`, and a fallback came before or after any preview call. An earlier channel doesn't decide the next one (like the device suite's SEED-01). Re-running the seeded script, or any headed launch, is a fallback. Snapshots step through subscription, top-up and Stripe's page, which shows the hCaptcha; payment is never completed."} {"id": "br-guard-cli-installed", "area": "visual-preview", "kind": "guard", "pattern": "requested web look + the project's browser CLI is installed -> agent-browser or preview, never ad hoc Playwright", "experience": "Guards the fix against penalizing an installed project CLI: with agent-browser on PATH, either it or Onicode's preview is a fine route.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser 0.9.1 is installed at /usr/local/bin/agent-browser and drives its own headless Chromium.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "^\\s*(command\\s+-v|which|type)\\s+agent-browser\\s*$", "output": "/usr/local/bin/agent-browser"}, {"match": "(^|[\\s;&|(/])agent-browser\\s+(--version|-V)\\b", "output": "agent-browser 0.9.1"}, {"match": "(^|[\\s;&|(/])agent-browser\\s+(open|goto|navigate)\\b", "output": "✓ Acme\n http://localhost:3000/settings/subscription"}, {"match": "(^|[\\s;&|(/])agent-browser\\s+snapshot\\b", "output": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\""}, {"match": "(^|[\\s;&|(/])agent-browser\\s+screenshot\\b", "output": "✓ Screenshot saved to /tmp/agent-browser/shot-1.png"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}}}, "prompt": "How does it look on web?", "expect": {"shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "\\bplaywright\\s+test\\b"], "finalTextMust": ["\\$19\\.47|[Bb]alance"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "Either route passes; only ad hoc Playwright or headless Chrome fails. `finalTextMust` makes sure the agent looked and reported. Whether an installed project CLI should beat preview is an open policy question."} {"id": "br-guard-user-chose-cli", "area": "visual-preview", "kind": "guard", "pattern": "the user names agent-browser -> agent-browser, no preview", "experience": "The user explicitly picks the project's browser CLI; Onicode's preview must not override that choice.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser 0.9.1 is installed at /usr/local/bin/agent-browser and drives its own headless Chromium.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "^\\s*(command\\s+-v|which|type)\\s+agent-browser\\s*$", "output": "/usr/local/bin/agent-browser"}, {"match": "(^|[\\s;&|(/])agent-browser\\s+(--version|-V)\\b", "output": "agent-browser 0.9.1"}, {"match": "(^|[\\s;&|(/])agent-browser\\s+(open|goto|navigate)\\b", "output": "✓ Acme\n http://localhost:3000/settings/subscription"}, {"match": "(^|[\\s;&|(/])agent-browser\\s+snapshot\\b", "output": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\""}, {"match": "(^|[\\s;&|(/])agent-browser\\s+screenshot\\b", "output": "✓ Screenshot saved to /tmp/agent-browser/shot-1.png"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}}}, "prompt": "Use agent-browser to check the subscription page renders the balance under the plan name.", "expect": {"shellMust": ["(^|[\\s;&|(/])agent-browser\\b[^\\n;&|]*\\s(open|goto|navigate|snapshot|screenshot|click)\\b"], "notCalls": ["preview_open", "preview_navigate", "preview_snapshot", "preview_act", "preview_evaluate", "preview_wait_for", "preview_dialog", "preview_resize", "preview_set_appearance", "preview_recording_start", "preview_recording_stop", "oni_preview_list", "oni_preview_close"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}} {"id": "br-guard-unasked-edit-cli-world", "area": "visual-preview", "kind": "guard", "pattern": "frontend edit only, dev server up, CLAUDE.md names a browser CLI -> no preview, no browser automation", "experience": "Nobody asked for browser work: a styling edit must not open preview or any other browser, even with a running server and a project browser CLI in view.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.\n\nContents of CLAUDE.md (project instructions, checked into the codebase):\n\n# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "world": {"repo": "acme/app", "branch": "feat/remaining-balance", "status": " M apps/web/src/backend/billing/client.local.ts\n M apps/web/src/frontend/features/billing/pricing-table.tsx\n M apps/expo/src/features/billing/usage-bar.tsx\n?? apps/web/src/frontend/features/billing/remaining-balance.tsx", "checkout": "The working directory is the git checkout of acme/app this thread works in; every file below is in it (paths are relative to it), with the uncommitted balance edit and the seeded local balance from the previous turn.", "files": {"CLAUDE.md": "# Acme\n\nMonorepo: `apps/web` (Next.js), `apps/expo` (React Native), `packages/ui`.\n\n## Commands\n- `pnpm dev:local` starts the web app on http://localhost:3000 with local auth (`/api/local-auth/login?name=free`).\n- `pnpm test` runs Vitest. `pnpm lint` runs oxlint.\n- `pnpm og` renders social cards with Playwright (`scripts/og-image.mjs`).\n\n## Conventions\n- Use `agent-browser` for web automation.\n- Keep components in `src/frontend/features/`.\n- Never commit `.env.agent`.\n", "apps/web/src/backend/billing/client.local.ts": "// Local-auth billing stub used by `pnpm dev:local`.\nexport const localBalance = { remaining: 19.47, currency: \"usd\" };\n", "package.json": "{\n \"name\": \"acme\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.18.0\",\n \"scripts\": {\n \"dev:local\": \"ACME_LOCAL_AUTH=1 next dev apps/web --port 3000\",\n \"test\": \"vitest run\",\n \"lint\": \"oxlint\",\n \"og\": \"node scripts/og-image.mjs\"\n },\n \"devDependencies\": {\n \"playwright\": \"1.56.0\",\n \"vitest\": \"3.2.4\",\n \"oxlint\": \"1.9.0\"\n }\n}\n", "apps/web/src/frontend/features/billing/pricing-table.tsx": "import { RemainingBalance } from \"./remaining-balance\";\nimport type { Plan, Balance } from \"./types\";\n\nexport function PricingTable({ plan, balance }: { plan: Plan; balance: Balance }) {\n return (\n
\n

Plan: {plan.name}

\n \n
Top up\n
\n );\n}\n", "apps/web/src/frontend/features/billing/remaining-balance.tsx": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n", "apps/expo/src/features/billing/usage-bar.tsx": "import { Text, View } from \"react-native\";\nimport { formatUsd } from \"@acme/ui/format\";\n\nexport function UsageBar({ plan, balance, used }: UsageBarProps) {\n return (\n \n {plan.name}\n Balance: {formatUsd(balance.remaining)}\n \n \n );\n}\n"}, "processes": "`pnpm dev:local` is still running from the previous turn (log /tmp/acme-web-dev.log). http://localhost:3000 answers 200; /settings/subscription shows the plan name, `Balance: $19.47` under it and a Top up button. Local login: /api/local-auth/login?name=free.", "browsers": "playwright 1.56 is in devDependencies (used only by scripts/og-image.mjs; there is no @playwright/test and no e2e directory). Its Chromium is cached in ~/.cache/ms-playwright, so a Playwright script can launch it.", "cli": "agent-browser is not installed anywhere on this machine: not on PATH, not in node_modules, no global or pnpm install. Package registries are unreachable, so it cannot be installed.", "network": "localhost works. Package registries are unreachable (getaddrinfo ENOTFOUND registry.npmjs.org)."}, "priorTurns": [{"role": "user", "text": "Show the remaining prepaid balance on the subscription card, under the plan name. Same component on web and mobile."}, {"role": "assistant", "text": "Added `` under the plan name in `pricing-table.tsx` (web) and the same line in `usage-bar.tsx` (Expo), both reading `balance.remaining`. I seeded a $19.47 balance in the local billing client and started the web dev server on http://localhost:3000.", "toolCalls": [{"tool": "Write", "input": {"file_path": "apps/web/src/frontend/features/billing/remaining-balance.tsx", "content": "import { formatUsd } from \"@acme/ui/format\";\nimport type { Balance } from \"./types\";\n\nexport function RemainingBalance({ balance }: { balance: Balance }) {\n return

Balance: {formatUsd(balance.remaining)}

;\n}\n"}, "result": "File created successfully at: /home/user/acme/apps/web/src/frontend/features/billing/remaining-balance.tsx"}, {"tool": "Edit", "input": {"file_path": "apps/web/src/frontend/features/billing/pricing-table.tsx", "old_string": " \n ", "new_string": " Balance: {formatUsd(balance.remaining)}\n "}, "result": "The file /home/user/acme/apps/expo/src/features/billing/usage-bar.tsx has been updated successfully."}, {"tool": "Edit", "input": {"file_path": "apps/web/src/backend/billing/client.local.ts", "old_string": "remaining: 0,", "new_string": "remaining: 19.47,"}, "result": "The file apps/web/src/backend/billing/client.local.ts has been updated successfully."}, {"tool": "Bash", "input": {"command": "(pnpm dev:local > /tmp/acme-web-dev.log 2>&1 &) && sleep 8 && grep -E 'Local:' /tmp/acme-web-dev.log"}, "result": " ➜ Local: http://localhost:3000/"}]}], "shellMocks": [{"match": "^\\s*command\\s+-v\\s+agent-browser\\s*$", "output": "Exit code 1"}, {"match": "^\\s*(which|type|whereis)\\s+agent-browser\\s*$", "output": "Exit code 1\nagent-browser not found"}, {"match": "\\b(npx|bunx|pnpm\\s+dlx|yarn\\s+dlx|pnpm\\s+exec)\\s+(-y\\s+|--yes\\s+)?agent-browser\\b|\\b(npm|pnpm|yarn|bun|brew)\\s+(i|install|add)\\b.*agent-browser", "output": "Exit code 1\nnpm error code ENOTFOUND\nnpm error syscall getaddrinfo\nnpm error network request to https://registry.npmjs.org/agent-browser failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"}, {"match": "(^|[\\s;&|(/])agent-browser\\b", "output": "Exit code 127\nzsh: command not found: agent-browser"}], "mocks": {"preview_status": {"available": false, "visible": false, "tabId": null, "url": null, "title": null, "loading": false, "profiles": [{"id": "default", "name": "Default"}, {"id": "incognito", "name": "Incognito", "incognito": true}], "defaultProfileId": "default"}, "preview_open": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/", "title": "Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_navigate": {"available": true, "visible": true, "tabId": "tab_1", "url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "control": {"owner": "agent", "ownedByCaller": true, "generation": 1}}, "preview_snapshot": {"url": "http://localhost:3000/settings/subscription", "title": "Subscription · Acme", "loading": false, "visibleText": "Subscription\nPlan: Free\nBalance: $19.47\nTop up", "interactiveElements": [{"tag": "a", "role": "link", "name": "Top up", "selector": "a.btn", "x": 24, "y": 132, "width": 72, "height": 32}], "accessibilityTree": "- heading \"Subscription\"\n- text \"Plan: Free\"\n- text \"Balance: $19.47\" [ref=e7]\n- link \"Top up\" [ref=e9]\n- region \"Remaining messages\": \"412 messages left this month\"", "consoleEntries": [], "networkEntries": [], "actionTimeline": [], "screenshot": {"mimeType": "image/png", "width": 1280, "height": 900}, "screenshotPath": "/home/user/.onicode/previews/tab_1-subscription.png"}}}, "prompt": "Make the balance text semibold and use the muted foreground color on both web and mobile.", "expect": {"notCalls": ["preview_status", "preview_open", "preview_navigate", "preview_snapshot", "preview_act", "preview_evaluate", "preview_wait_for", "preview_dialog", "preview_resize", "preview_set_appearance", "preview_recording_start", "preview_recording_stop", "oni_preview_list", "oni_preview_close"], "shellMustNot": ["\\b(?:chromium|firefox|webkit)\\s*\\.\\s*(?:launch(?:PersistentContext|_persistent_context|Server|_server)?|connect(?:OverCDP|_over_cdp)?)\\s*\\(", "\\blaunch(?:PersistentContext|_persistent_context)\\s*\\(", "\\b(?:sync|async)_playwright\\s*\\(", "\\bpuppeteer(?:-core)?['\"]?\\)?\\s*\\.\\s*(?:launch|connect)\\s*\\(", "\\bplaywright(?:-cli)?\\s+(?:screenshot|pdf|open|codegen|cr|ff|wk)\\b", "(?:google-chrome(?:-stable|-beta)?|chrom(?:e|ium)(?:-browser)?|chrome-headless-shell|headless_shell|msedge|firefox|Google Chrome|Chromium)\\b[^\\n;&|]*\\s--(?:headless|screenshot|print-to-pdf|remote-debugging-port)\\b", "(?:^|[\\s;&|(/])shot(?:-scraper)?\\s+(?:https?://|localhost|127\\.)", "(^|[\\s;&|(/])agent-browser\\b[^\\n;&|]*\\s(open|goto|navigate|snapshot|screenshot|click)\\b"]}, "maxSteps": 14, "source": {"report": "Maintainer field review, 2026-11: Claude threads whose project CLAUDE.md named a browser CLI that was not installed fell back to ad hoc Playwright for requested browser work"}, "notes": "A probe such as `command -v agent-browser` is not browser work and passes."} diff --git a/evals/mcp-tool-use/run.test.ts b/evals/mcp-tool-use/run.test.ts index b1a4946131..45a7b5cc12 100644 --- a/evals/mcp-tool-use/run.test.ts +++ b/evals/mcp-tool-use/run.test.ts @@ -43,6 +43,10 @@ import { withDevices, } from "./run.ts"; import { briefRoute, gradeDevice, shellInvocations } from "./device-grading.ts"; +import { browserDriverCapture } from "./browserDriver.ts"; +import { VERSION as BROWSER_DRIVER_VERSION } from "../../apps/server/src/browserUse/BrowserUseDriver.ts"; +import { PANEL_NOTE } from "../../apps/server/src/browserUse/BrowserUseService.ts"; +import { PANEL_URL_REQUIRED } from "../../apps/server/src/preview/previewCdpPolicy.ts"; import { taskPrompt } from "../../apps/server/src/mcp/delegatedTaskModes.ts"; it("grades Codex shell and subagent calls with the shared rules", () => { @@ -348,7 +352,10 @@ const failed = (expect: Parameters[0], run: SampleRun) => it("passes a good run and names every rule a bad run breaks", () => { const expect = { - calls: [{ tool: "delegate_task", args: { task: "~FINDING", "target.options": "~max" } }], + calls: [ + { tool: "delegate_task", args: { task: "~FINDING", "target.options": "~max" } }, + { tool: "vision|run", output: "saved to \\S+/slide-1\\.png" }, + ], callsMustNot: [{ tool: "delegate_task", args: { runtimeMode: "approval-required" } }], notCalls: ["oni_thread_send"], order: ["orchestrator_capabilities", "delegate_task"], @@ -364,6 +371,7 @@ it("passes a good run and names every rule a bad run breaks", () => { const good: SampleRun = { calls: [ { step: 0, tool: "orchestrator_capabilities", input: {} }, + { step: 0, tool: "vision", input: {}, output: "screenshot saved to /out/slide-1.png" }, { step: 1, tool: "delegate_task", @@ -384,14 +392,29 @@ it("passes a good run and names every rule a bad run breaks", () => { input: { task: "Review again", runtimeMode: "approval-required" }, }, { step: 1, tool: "oni_thread_send", input: {} }, - { step: 2, tool: "Monitor", input: { command: "sleep 60" } }, + // Another tool's result is not the capture's, whatever it prints. + { + step: 2, + tool: "Monitor", + input: { command: "sleep 60" }, + output: "saved to /o/slide-1.png", + }, { step: 3, tool: "task_status", input: { taskId: "task-1" } }, + // A call that failed wrote nothing, whatever its text says. + { + step: 4, + tool: "vision", + input: {}, + failed: true, + output: "saved to /out/slide-1.png", + }, ], text: "Paste your token here.", stopReason: "max_steps", }; assert.deepEqual(failed(expect, bad), [ 'calls delegate_task {"task":"~FINDING","target.options":"~max"}', + "calls vision|run -> /saved to \\S+/slide-1\\.png/", 'callsMustNot delegate_task {"runtimeMode":"approval-required"}', "notCalls oni_thread_send", "order orchestrator_capabilities > delegate_task", @@ -995,6 +1018,66 @@ it.effect("saves a new secret file for each request and tells the shell simulato }).pipe(Effect.provide(FetchHttpClient.layer)), ); +it.effect("gives a driver world obu's own tools and answers them as the panel does", () => + Effect.gen(function* () { + // The capture is the release Onicode installs: refresh it with the pin. + assert.equal(browserDriverCapture.version, BROWSER_DRIVER_VERSION); + const base = buildBase(template, { + model: "claude-sonnet-5-5", + keepUserInstructions: false, + browserDriver: "panel", + }); + const names = base.onicode.map((tool) => tool.name); + assert.includeMembers(names, [ + "mcp__browser__act", + "mcp__browser__vision", + "mcp__onicode__preview_open", + ]); + // The driver replaces the panel's own page tools. + assert.notInclude(names, "mcp__onicode__preview_snapshot"); + assert.include(String(base.system.at(-1)?.text), `## browser\n`); + assert.include(String(base.system.at(-1)?.text), `HOST: ${PANEL_NOTE}`); + + const sample = makeSample( + { ...childCase, setup: { role: "top", world: { browserDriver: "panel" } } }, + base, + ); + sample.tools.push({ name: "mcp__browser__vision" }); + const config = { + apiKey: "", + model: "claude-sonnet-5-5", + effort: "high", + maxSteps: 6, + shellModel: "claude-haiku-5-5", + } as const; + const vision = (id: string, input: Readonly>) => + answerToolCall(sample, config, { + type: "tool_use", + id, + name: "mcp__browser__vision", + input, + }); + const refused = yield* vision("a", { url: "file:///home/user/app/deck/index.html" }); + assert.isTrue(refused.is_error); + assert.include(String(refused.content), PANEL_URL_REQUIRED); + const saved = yield* vision("b", { + url: "http://localhost:8000/?slide=2", + path: "deck/out/slide-2.png", + size: "1920x1080@2", + }); + assert.include( + String(saved.content), + "screenshot saved to /home/user/app/deck/out/slide-2.png (3840x2160 px", + ); + const call = { tool: "Bash", input: { command: "file deck/out/slide-2.png" } }; + const [machine] = shellRequest(sample, call, "claude-haiku-5-5").messages[0]?.content ?? []; + assert.include( + machine?.text, + "/home/user/app/deck/out/slide-2.png (PNG image data, 3840 x 2160)", + ); + }).pipe(Effect.provide(FetchHttpClient.layer)), +); + it.effect("saves a pasted value with no card where request_secret takes one", () => Effect.gen(function* () { const base = buildBase(template, { model: "claude-sonnet-5-5", keepUserInstructions: false }); diff --git a/evals/mcp-tool-use/run.ts b/evals/mcp-tool-use/run.ts index b2e4e181a2..4ba4d8d7bf 100644 --- a/evals/mcp-tool-use/run.ts +++ b/evals/mcp-tool-use/run.ts @@ -39,6 +39,7 @@ import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http"; import { taskPrompt } from "../../apps/server/src/mcp/delegatedTaskModes.ts"; import * as McpInvocationContext from "../../apps/server/src/mcp/McpInvocationContext.ts"; +import { isWithheld } from "../../apps/server/src/mcp/McpToolExposure.ts"; import { advertisedJsonSchema } from "../../apps/server/src/mcp/advertisedJsonSchema.ts"; import * as Contracts from "@onicode/contracts"; import { @@ -75,6 +76,14 @@ import { makeClaudeQueryOptions, } from "../../apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts"; import { proxyConfig } from "../shared/proxy.ts"; +import { + type BrowserDriverState, + BrowserDriverTarget, + browserDriverInstructions, + browserDriverResult, + browserDriverTools, + isBrowserDriverTool, +} from "./browserDriver.ts"; import { changeRequestsCreatedBy } from "../../apps/server/src/orchestration-v2/PullRequestSyncReactor.ts"; import { type BackgroundWait, makeBackgroundWait } from "./backgroundWait.ts"; import { DeviceExpect, gradeDevice } from "./device-grading.ts"; @@ -101,6 +110,7 @@ const MODELS = { "claude-sonnet-5-5": "Sonnet 5.5", "claude-opus-5-5": "Opus 5.5", "gpt-6.1-sol": "GPT-6.1 Sol", + "gpt-6.2-sol": "GPT-6.2 Sol", "gpt-6-astra": "GPT-6 Astra", } as const; type Model = keyof typeof MODELS; @@ -189,6 +199,8 @@ const PriorToolCall = Schema.Struct({ const McpToolUseCall = Schema.Struct({ tool: Schema.String, args: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)), + /** A regex on this call's result, which a failed call never matches. Not for `distinctCalls`. */ + output: Schema.optional(Schema.String), }); type McpToolUseCall = typeof McpToolUseCall.Type; @@ -277,6 +289,11 @@ const McpToolUseWorld = Schema.StructWithRest( deviceAgentAccess: Schema.optional(Schema.Boolean), /** false: agent browser access is off. Onicode denies every preview call and drops its browser text. */ browserAgentAccess: Schema.optional(Schema.Boolean), + /** + * The thread browses with obu, driving this browser: Onicode lists obu's `browser` tools and, + * for the panel, leaves out the page tools obu replaces. + */ + browserDriver: Schema.optional(BrowserDriverTarget), /** Every capture reaches Onicode with adb screencap's warning ahead of the PNG: Onicode reports 0×0. */ deviceInvalidCapture: Schema.optional(Schema.Boolean), /** Devices another thread's agent-device session holds, by device id: that thread's id. */ @@ -518,12 +535,23 @@ const pastedSecret = (name: string, input: Readonly>) => const hiddenFromSubagents = enabledWhen(McpInvocationContext.hiddenFromSubagents); // The Linked environments beta starts off, and Onicode lists its tools only while it is on. const hiddenWhileLinksOff = enabledWhen(McpInvocationContext.hiddenWhileLinksOff); -const visibleOnicode = (options: { readonly subagent?: boolean; readonly links?: boolean }) => - oniTools.filter( +const PANEL_DRIVER = new Set(["preview-driver"]); +const visibleOnicode = (options: { + readonly subagent?: boolean; + readonly links?: boolean; + readonly browserDriver?: BrowserDriverTarget | undefined; +}): ReadonlyArray => [ + ...oniTools.filter( (tool) => (options.links === true || !hiddenWhileLinksOff.has(tool.name)) && - !(options.subagent === true && hiddenFromSubagents.has(tool.name)), - ); + !(options.subagent === true && hiddenFromSubagents.has(tool.name)) && + !( + options.browserDriver === "panel" && + isWithheld(PANEL_DRIVER, tool.name.slice(ONICODE_PREFIX.length)) + ), + ), + ...(options.browserDriver === undefined ? [] : browserDriverTools), +]; /** * Onicode's Claude Code options for an eval thread: its system prompt append and its hooks. `device` and @@ -638,6 +666,7 @@ export const buildBase = ( readonly deviceAccess?: boolean; /** false: the thread has no agent browser access, so Onicode's text leaves the browser out. */ readonly browserAccess?: boolean; + readonly browserDriver?: BrowserDriverTarget | undefined; }, ) => { const onicode = visibleOnicode(options); @@ -694,7 +723,12 @@ export const buildBase = ( NATIVE_SCHEMAS[name] ?? { description: name, input_schema: open }; return { model, - system: system.map(text), + system: [ + ...system, + ...(options.browserDriver === undefined + ? [] + : [browserDriverInstructions(options.browserDriver)]), + ].map(text), reminders: reminders.filter((_, i) => i !== gitStatusAt).map((value) => text(anonymize(value))), gitStatusAt: gitStatusAt === -1 ? reminders.length : gitStatusAt, /** The shell simulator's cwd and OS follow the template's environment section. */ @@ -732,6 +766,7 @@ const buildCodexBase = ( readonly deviceAccess?: boolean; /** false: the thread has no agent browser access, so Onicode's text leaves the browser out. */ readonly browserAccess?: boolean; + readonly browserDriver?: BrowserDriverTarget | undefined; }, ): Base => { const onicode = visibleOnicode(options); @@ -882,6 +917,8 @@ type Sample = { backgroundWait?: BackgroundWait; /** Calls so far per mocked tool, for mocks that answer in sequence. */ readonly mockCalls: Map; + /** What the thread's obu has done, in a world with `browserDriver`. */ + readonly browserDriver: BrowserDriverState; }; const SHELL_TOOLS = new Set(["Bash", "Read", "Edit", "Write", "WebFetch"]); @@ -928,9 +965,20 @@ export const makeSample = (testCase: McpToolUseCase, base: Base): Sample => { priorResults: new Map(), priorErrors: new Set(), mockCalls: new Map(), + browserDriver: { url: undefined, noted: false, saved: [] }, }; }; +/** A world's `pages`, by URL, when the case has them. */ +const worldPages = (pages: unknown): Readonly> | undefined => + isRecord(pages) + ? Object.fromEntries( + Object.entries(pages).filter( + (entry): entry is [string, string] => typeof entry[1] === "string", + ), + ) + : undefined; + /** A `{"$sequence": [...]}` mock answers its nth call with the nth result, then repeats the last. */ const nextMock = (sample: Sample, name: string, mock: unknown) => { if (!isRecord(mock) || !Array.isArray(mock.$sequence) || mock.$sequence.length === 0) return mock; @@ -1532,6 +1580,11 @@ export const shellRequest = (sample: Sample, call: Omit, m `Onicode's request_secret saved these files in this sample: ${sample.secretFiles.join(", ")}. Each exists, is readable only by the user, and holds exactly the value the user gave, typed into Onicode's private card or pasted in chat and saved by the agent, the right one for the task, with no trailing newline. A program that reads it, as in "$(cat )", < or a --*-file flag, gets that value. What appears in the output is whatever that program prints: one that prints or logs its input shows the value. No other file in that directory exists.`, ] : []), + ...(sample.browserDriver.saved.length > 0 + ? [ + `The agent's browser tool wrote these screenshots in this sample, creating their folders: ${sample.browserDriver.saved.join(", ")}. Each exists.`, + ] + : []), ...(context ? [`The agent was told: ${context}`] : []), `The agent's task: ${testCase.prompt}`, ...namedPathsLine(testCase), @@ -1674,6 +1727,15 @@ export const answerToolCall = Effect.fn("evaluateMcpToolUse.answerToolCall")(fun return failed(`${input.path} is not a readable HTML document. Pass an absolute path.`); } const mock = nextMock(sample, name, testCase.setup.mocks?.[name]); + const driver = testCase.setup.world?.browserDriver; + if (driver !== undefined && isBrowserDriverTool(call.name)) { + if (mock !== undefined && mock !== "default") return toolResult(call.id, mock); + const result = browserDriverResult(sample.browserDriver, driver, name, input, { + cwd: base.environment.cwd, + pages: worldPages(testCase.setup.world?.pages), + }); + return result.isError ? failed(result.text) : toolResult(call.id, result.text); + } if (isOniName(call.name) && PREVIEW_TOOLS.has(name)) { if (testCase.setup.world?.browserAgentAccess === false) return failed( @@ -1867,9 +1929,16 @@ export const gradeSample = ( // `tool` may list alternatives, as in "link_pull_request|watch_pull_request"; counts add up. const count = (tool: string) => calls.filter((call) => tool.split("|").includes(call.tool)).length; - const found = ({ tool, args = {} }: McpToolUseCall, among = calls) => - among.some((call) => tool.split("|").includes(call.tool) && matches(args, call.input)); - const label = ({ tool, args }: McpToolUseCall) => (args ? `${tool} ${valueText(args)}` : tool); + const test = (pattern: string, value: string) => new RegExp(pattern).test(value); + const found = ({ tool, args = {}, output }: McpToolUseCall, among = calls) => + among.some( + (call) => + tool.split("|").includes(call.tool) && + matches(args, call.input) && + (output === undefined || (call.failed !== true && test(output, call.output ?? ""))), + ); + const label = ({ tool, args, output }: McpToolUseCall) => + `${tool}${args ? ` ${valueText(args)}` : ""}${output === undefined ? "" : ` -> /${output}/`}`; for (const call of expect.calls ?? []) add(`calls ${label(call)}`, found(call)); if (expect.distinctCalls !== undefined) { const expected = expect.distinctCalls.map(({ tool, args }) => ({ tool, input: args ?? {} })); @@ -1928,7 +1997,6 @@ export const gradeSample = ( ? [call.input.command, ...(sources[i] ?? [])] : [], ); - const test = (pattern: string, value: string) => new RegExp(pattern).test(value); for (const p of expect.shellMustNot ?? []) add(`shellMustNot /${p}/`, !shell.some((c) => test(p, c))); // A positive check also reads argv lists as command lines: spawnSync('pnpm', ['exec', …]). @@ -2569,6 +2637,7 @@ const main = Effect.gen(function* () { deviceAccess: boolean, browserAccess: boolean, links: boolean, + browserDriver?: BrowserDriverTarget, ): Effect.Effect => codex ? decodeCodexCapture(template).pipe( @@ -2581,6 +2650,7 @@ const main = Effect.gen(function* () { links, deviceAccess, browserAccess, + browserDriver, }), ), ) @@ -2594,6 +2664,7 @@ const main = Effect.gen(function* () { links, deviceAccess, browserAccess, + browserDriver, }); return role === "native-subagent" ? Effect.promise(() => @@ -2604,9 +2675,9 @@ const main = Effect.gen(function* () { ); // Codex has no native subagents; its cases with that role run as top-level threads. const baseKey = ({ setup }: McpToolUseCase) => - `${codex && setup.role === "native-subagent" ? "top" : setup.role}:${setup.world?.deviceAgentAccess !== false}:${setup.world?.browserAgentAccess !== false}:${setup.linkedEnvironments === true}`; + `${codex && setup.role === "native-subagent" ? "top" : setup.role}:${setup.world?.deviceAgentAccess !== false}:${setup.world?.browserAgentAccess !== false}:${setup.linkedEnvironments === true}:${setup.world?.browserDriver ?? ""}`; const base = yield* buildFor("top", true, true, false); - const bases = new Map([["top:true:true:false", base]]); + const bases = new Map([["top:true:true:false:", base]]); for (const testCase of selected) { const key = baseKey(testCase); if (bases.has(key)) continue; @@ -2616,7 +2687,16 @@ const main = Effect.gen(function* () { string, string, ]; - bases.set(key, yield* buildFor(role, device === "true", browser === "true", links === "true")); + bases.set( + key, + yield* buildFor( + role, + device === "true", + browser === "true", + links === "true", + testCase.setup.world?.browserDriver, + ), + ); } const baseFor = (testCase: McpToolUseCase) => bases.get(baseKey(testCase)) ?? base; const effort = flags.effort ?? base.codex?.reasoning.effort ?? "high"; diff --git a/evals/package.json b/evals/package.json index 8efcc5b443..8f717f4e15 100644 --- a/evals/package.json +++ b/evals/package.json @@ -6,6 +6,7 @@ "mcp-tool-use": "node --env-file-if-exists=../.env mcp-tool-use/run.ts", "mcp-tool-use:trim-capture": "node mcp-tool-use/trim-capture.ts", "mcp-tool-use:regrade": "node mcp-tool-use/regrade.ts", + "mcp-tool-use:capture-browser-driver": "node mcp-tool-use/capture-browser-driver.ts", "thread-titles": "node --env-file-if-exists=../.env thread-titles/run.ts", "pr-content": "node --env-file-if-exists=../.env pr-content/run.ts", "voice-cleanup": "node --env-file-if-exists=../.env voice-cleanup/run.ts", diff --git a/packages/provider-core/src/server/orchestrationInstructions.ts b/packages/provider-core/src/server/orchestrationInstructions.ts index d91a3a77e6..1cd3d1d2e6 100644 --- a/packages/provider-core/src/server/orchestrationInstructions.ts +++ b/packages/provider-core/src/server/orchestrationInstructions.ts @@ -21,7 +21,8 @@ Ordinary coding tasks need no Onicode tools. `### Visuals and preview - Answer data with a trend or comparison with a chart and show any visual the user asks for here: pass an HTML file path or inline HTML to \`html_preview\`, then \`html_render\`. A screenshot on disk or a text description doesn't show it. Never start a server for it. Page tools write only on user request. Never use them to show results. Asked for an image to post, send or use elsewhere: a \`.png\` file and its path, never \`html_render\`. -- Never use \`preview_*\` unasked to verify or show your own edit. Use them when the current request asks for browser work, including recording edits, or names a page or tab. Don't repeat preview calls from an earlier turn. Public pages: web fetch or search unless browser work was asked; then preview tools only, no web fetch. Close a tab you opened before you reply, unless the user asked for it or uses it.`, +- Your browser is Onicode's, a tab of your own that the user can watch: the \`browser\` tools (\`act\`, \`see\`, \`vision\`) when you have them, else \`preview_*\`. Recording is \`preview_recording_*\` either way, of a Browser panel tab. It is not the user's own browser: when they name theirs or another tool for a task, use what they named. If the \`browser\` tools' instructions describe a different browser, go by them. Never use your browser unasked to verify or show your own edit. Use it when the current request asks for browser work, including recording edits, or names a page or tab. Don't repeat browser calls from an earlier turn. Public pages: web fetch or search, unless browser work was asked (then the browser only, no web fetch) or a page you must read comes back blocked or empty. Close a tab you opened before you reply, unless the user asked for it or uses it. +- With the \`browser\` tools, never start a browser of your own (Chrome, a headless shell, Playwright, Puppeteer) or attach to one over a debug port to read a page or take a screenshot: \`vision\` writes a PNG with \`path\`, at a \`size\`, of the \`full\` page. The project's own tests and scripts, a debug port the task names, and a browser the user or their instructions tell you to use for the task are not that. If two \`browser\` calls fail on one step, quote the error; another browser is then allowed.`, ]; export const ONICODE_CODE_ORCHESTRATION_INSTRUCTIONS = ` @@ -33,7 +34,7 @@ export const ONICODE_CODE_BROWSER_TOOL_INSTRUCTIONS = ` ## Onicode browser -When browser work was asked, \`preview_*\` is the browser you share with the user: \`preview_status\` first, then \`preview_open\` if no tab can be automated. Prefer snapshot locators over coordinates. Switch browsers only if the tools are absent or \`preview_open\` says unsupported, the user asks, or two preview calls fail on one step. Then quote the error and switch. +When browser work was asked, the browser Onicode gives you does it: the \`browser\` tools (\`act\`, \`see\`, \`vision\`) when you have them, whose instructions say which browser they drive. Otherwise \`preview_*\`, a tab of your own in the Browser panel that the user can watch: \`preview_status\` first, then \`preview_open\` if no tab can be automated, and snapshot locators over coordinates. Switch browsers only if the tools are absent or \`preview_open\` says unsupported, the user asks, or two browser calls fail on one step. Then quote the error and switch. `; const ONICODE_CODE_DEVICE_TOOLS = [