libretto-playwright-debugger lets an existing Playwright script keep its current
browser provider, retries, logging, and fallback logic while adding one agent
call in the failure path.1pnpm add libretto-playwright-debugger
123456789101112import { createPlaywrightDebugger } from "libretto-playwright-debugger"; const playwrightDebugger = createPlaywrightDebugger({ github: { owner: "acme", repo: "automations", baseBranch: "main", }, agent: { model: "openai/gpt-5.4", }, });
agent.model value uses Libretto's provider/model-id convention. For
example, openai/gpt-5.4 resolves to provider openai and model id gpt-5.4.
The first version supports openai/... and anthropic/....debugFailure() with the error and the live Page before Playwright
teardown runs:1234567try { await runAutomation(page); } catch (error) { await playwrightDebugger.debugFailure(error, page); // Existing fallback and logging stay here. throw error; }
debugFailure() captures the error message, stack trace, page URL, page title,
screenshot, and DOM snapshot from the failed page. It uses the stack frames —
plus any paths you pass in includeFiles — to read the relevant source files
from GitHub at baseBranch.123await playwrightDebugger.debugFailure(error, page, { includeFiles: ["src/workflows/acme.ts"], });
includeFiles is optional. When the error stack references files inside the
repository, the debugger discovers them automatically; pass includeFiles when
the stack does not cover the file that needs the fix (for example bundled or
minified stacks, or a cross-file change).libretto-browser-tools
SDK: the model is given the failure context and source files, then drives a real
browser to confirm the root cause before proposing a change. It stays attached
to the supplied failed Page, preserving its authentication, storage, routes,
open tabs, and in-memory state. It can:browser_status the existing pages in the failed browser context,browser_snapshot the live accessibility tree (and a screenshot), andbrowser_exec Playwright code against the page — for example counting a
selector's matches to check whether it actually resolves.status: "no_changes".status: "debugger_failed" so the caller's existing
fallback and original error handling can continue.123export OPENAI_API_KEY=... # or export ANTHROPIC_API_KEY=...
agent.apiKey directly when the key is provided by your
secrets manager.1export LIBRETTO_API_KEY=...
owner/repo and only the
permissions needed to read and write contents and open pull requests.