agent-browser-electron
Agent Browser Electron
Overview
Inspect Electron renderer windows reliably when agent-browser alone is not enough to tell which CDP target maps to which BrowserWindow.
Prefer raw CDP target discovery over guessing from tab list, then connect agent-browser directly to the exact renderer target you want.
Why Raw CDP Discovery
Use raw CDP target discovery because agent-browser is operating as a convenience layer on top of Chrome DevTools Protocol, and that layer can hide or flatten details that matter in Electron.
Raw /json/list is the source of truth for target discovery because it exposes the browser's own target inventory without extra interpretation. In Electron, that matters because:
- multiple
BrowserWindowinstances can share the same URL - some windows are created lazily and appear only after an app action
- detached DevTools pages and workers add noise
agent-browser tab listmay show only a subset of targets or present them with reduced metadata- session state inside
agent-browsercan keep you attached to a previous renderer unless you reset and verify
In practice, the higher-level tab list view is useful for quick browsing, but not reliable enough for window-to-target mapping when:
- two Electron windows both look like
http://localhost:5173/#/ - the title is empty or collapsed
- a chat or settings window exists in CDP but is not obvious in the simplified tab output
Use curl http://127.0.0.1:<port>/json/list first whenever correct target selection matters. Treat agent-browser as the interaction client after target discovery, not as the discovery source.
Workflow
- Ensure the Electron window exists.
If the app uses lazy window creation, agent-browser cannot inspect a window that has not been created yet. Open it from the app UI or trigger its Electron-side open handler first.
- Inspect raw CDP targets instead of trusting
agent-browser --cdp <port> tab list.
curl -sS http://127.0.0.1:<port>/json/list
Read these fields:
titleurltypewebSocketDebuggerUrl
Use /json/version if you need the browser-level debugger URL:
curl -sS http://127.0.0.1:<port>/json/version
- Match the target to the Electron window.
Common patterns:
- Distinct route: chat may be
http://localhost:5173/#/chatwhile the main window ishttp://localhost:5173/#/. - Distinct title: Electron window titles may surface in the target list.
- Duplicate URLs: two windows may both report
http://localhost:5173/#/; in that case use screenshots, snapshots, and Electron app knowledge to disambiguate. - Hidden noise: worker targets and detached DevTools targets are not your app window.
- Reset
agent-browsersession state before switching targets.
agent-browser close --all
- Connect directly to the target you want.
agent-browser connect <webSocketDebuggerUrl>
- Verify the target immediately.
agent-browser get url
agent-browser get title
agent-browser snapshot -i
If needed:
agent-browser screenshot /tmp/electron-target.png --annotate
agent-browser console
agent-browser errors
Fast Triage
Use this order when the Electron app has multiple windows:
curl /json/list- Find the renderer page target with the route or title you expect
- Ignore
workertargets unless the task is specifically about workers - Ignore
DevToolspage targets unless debugging DevTools itself agent-browser close --allagent-browser connect <webSocketDebuggerUrl>agent-browser get urlagent-browser snapshot -i
AIRI Example
In apps/stage-tamagotchi, the chat window is lazy-created and loaded with /#/chat. The main window loads /#/.
Relevant files:
apps/stage-tamagotchi/src/main/windows/chat/index.tsapps/stage-tamagotchi/src/main/windows/main/index.tsapps/stage-tamagotchi/src/main/libs/electron/window-manager/reusable.tsapps/stage-tamagotchi/src/renderer/components/stage-islands/controls-island/index.vue
That means:
- chat does not exist in CDP until something calls
chatWindow() - once created, raw CDP target discovery will show a page target whose URL is
http://localhost:5173/#/chat - the stable way to inspect chat is to connect
agent-browserto that target'swebSocketDebuggerUrl
Example:
curl -sS http://127.0.0.1:9250/json/list
agent-browser close --all
agent-browser connect ws://127.0.0.1:9250/devtools/page/<chat-target-id>
agent-browser get url
agent-browser snapshot -i
Expected verification for chat:
agent-browser get urlreturnshttp://localhost:5173/#/chat- the snapshot exposes chat UI controls such as the message textbox or send button
Failure Modes
tab listomits or flattens the target you need: use raw/json/list.connectappears to succeed but later commands still point at the old renderer: runagent-browser close --all, then reconnect and verify withget url.- multiple windows share the same URL: use the target title, annotated screenshots, and app code to correlate them.
evalreturns{}for object values: preferget url,get title,snapshot -i, or primitive-only eval return values.- no chat target appears: the window may not have been created yet.
More from moeru-ai/airi
vue-best-practices
MUST be used for Vue.js tasks. Strongly recommends Composition API with `<script setup>` and TypeScript as the standard approach. Covers Vue 3, SSR, Volar, vue-tsc. Load for any Vue, .vue files, Vue Router, Pinia, or Vite with Vue work. ALWAYS use Composition API unless the project explicitly requires Options API.
37vue
Vue 3 Composition API, script setup macros, reactivity system, and built-in components. Use when writing Vue SFCs, defineProps/defineEmits/defineModel, watchers, or using Transition/Teleport/Suspense/KeepAlive.
29vueuse-functions
Apply VueUse composables where appropriate to build concise, maintainable Vue.js / Nuxt features.
22pnpm
Node.js package manager with strict dependency resolution. Use when running pnpm specific commands, configuring workspaces, or managing dependencies with catalogs, patches, or overrides.
11unocss
UnoCSS instant atomic CSS engine, superset of Tailwind CSS. Use when configuring UnoCSS, writing utility rules, shortcuts, or working with presets like Wind, Icons, Attributify.
8agent-browser
Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.
8