Установка
SKILL.md
ego-browser
ego-browser gives AI agents a CLI-accessible Node.js runtime, with built-in helpers — snapshotText, click, js, cdp, and more — that agents call directly inside JS scripts to observe pages, interact with UI, evaluate browser-side JavaScript, and drive a real browser for any web automation task.
For setup, install, or connection problems, read references/install.md.
Use the Bash tool to run all browser operations via ego-browser nodejs <<'EOF' ... EOF heredoc. Do not write code to a .js file first.
Quick start
ego-browser nodejs <<'EOF'
// Name the task space for the whole user task, then reuse that space across heredoc rounds.
const task = await useOrCreateTaskSpace('inspect example page')
cliLog('task space id: ' + task.id)
await openOrReuseTab('https://example.com', { wait: true, timeout: 20 })
cliLog(await snapshotText())
EOF
The heredoc body runs as a Node.js script that controls the selected ego-browser task space. All ego-browser helpers are preloaded into that script.
Common helpers
- Task spaces:
listTaskSpaces,useOrCreateTaskSpace,claimTaskSpace,handOffTaskSpace,takeOverTaskSpace,waitForAgentControl,completeTaskSpace - Navigation / state:
listTabs,openOrReuseTab,closeTab,gotoAndWait,currentTab,switchTab,gotoUrl,pageInfo,ensureRealTab - Observation:
snapshotText,captureScreenshot,drainEvents - Scroll / mouse:
scrollBy,scrollToBottomUntil,scroll,click,doubleClick,hover,dragMouse - Keyboard & input:
typeText,fillInput,pressKey,dispatchKey - File:
uploadFile - Wait:
wait,waitForLoad,waitForElement,waitForNetworkIdle - Fetch:
serverFetch,browserFetch - CDP / evaluate:
js,cdp - Output:
cliLog,help
Notes:
cliLog(value)— prints to the terminal; it is the only output mechanism inside a heredoc, and all final results must go through it.await pageInfo()— normally resolves to{ url, title, w, h, sx, sy, pw, ph }; if a native browser dialog is open, resolves to{ dialog: ... }instead because page JavaScript is blocked.- If
await pageInfo()resolves to{ dialog: ... }, handle the dialog withawait cdp('Page.handleJavaScriptDialog', { accept: true })oraccept: falsebefore running page JavaScript. await ensureRealTab()— switches to an existing non-internal page tab if needed and resolves to it; resolves tonullwhen none exists. It does not create a tab — useawait openOrReuseTab(...)for that.await closeTab(target?)— closes the given target id / tab object, or the current tab when omitted.await drainEvents()— consumes and returns the async event queue produced by the page (navigation events, network events, etc.).await serverFetch(url, options)— issues a request from Node and returns the response body.await browserFetch(url, options)— issues a request from the current browser page context and returns the response body.help(name)— prints usage for a given helper, e.g.cliLog(help('click')).
Task spaces
A task space is an isolated browsing context that ego-browser provides for AI Agents. Each task space has its own set of tabs but inherits the current user's login state by default, so Agents can operate on authenticated sites without competing with or disturbing the user's normal browser windows.
Closing all tabs in a task space is equivalent to closing that task space.
A task often takes multiple heredoc rounds to complete. Because the Node.js runtime exits after each heredoc and retains no state, normal working heredocs should start with an explicit call to useOrCreateTaskSpace(nameOrId) to reuse the same space — this lets you operate continuously and reuse tabs across rounds. The exception is resuming after a handoff: once the user confirms "continue" (through an Ask or in chat), start the next heredoc with takeOverTaskSpace(nameOrId) instead.
nameOrId can be a task space name, numeric id, or digit-only numeric id string. String values match name/taskId first, then digit-only strings fall back to numeric id. Number values match existing numeric ids only; if no matching id exists, useOrCreateTaskSpace fails instead of creating a new space.
Use a short name for the active user goal when creating a new task space. Keep reusing that task space for follow-up questions, corrections, refinements, re-checks, and result validation, even if you previously thought the task was complete. Choose a new task space only when the user clearly starts a separate, unrelated goal. Prefer using the numeric id returned by useOrCreateTaskSpace (for example, task.id) to resume a known task in later rounds and avoid name collisions.
For any follow-up on the same user goal — including continue, corrections, retries, validation, user-reported problems, or work after completeTaskSpace(..., { keep: true }) — resume the original task space first if it still exists. Do not create a new task space for the same goal unless the user asks for a fresh space, starts an unrelated goal, or the original space is unavailable after checking. If a new space is necessary, state why.
After explicit user confirmation, to continue work from an existing user-owned, inactive, or unassigned task space, use await listTaskSpaces() to find the space, call await claimTaskSpace(id) to take ownership and select it, then use await listTabs() and await switchTab(targetId) to select the exact tab before acting.
Ownership policy — every task space has ownership: 'agent' | 'agentDelegatedToUser' | 'user'; the helpers treat user-owned spaces differently:
| Helper | When the target space is user-owned |
|---|---|
switchTaskSpace | throws — agent-owned spaces only |
claimTaskSpace | claims it (ownership transfers to the agent), then selects it |
handOffTaskSpace | skipped — resolves { done: false, skipped: 'user-owned' } |
completeTaskSpace(…, { keep: true }) | skipped — resolves { done: false, skipped: 'user-owned' } |
completeTaskSpace(…, { keep: false }) | claims it, then closes it |
takeOverTaskSpace / waitForAgentControl | no ownership check |
handOffTaskSpace and completeTaskSpace resolve { done: true } when the operation actually happened. Check done before telling the user the handoff/cleanup is finished — a skipped result usually means you targeted a space that was never yours.
completeTaskSpace(nameOrId, { keep }) must occupy its own dedicated final heredoc, and run only after a prior heredoc's output has confirmed the task is genuinely done. keep is required and defaults by policy to false: close the task space after completion unless there is a concrete reason to leave the live page visible.
Use { keep: true } only when the user explicitly asks to keep the page open, the task needs manual user action in that exact page, or the result cannot be delivered well as a URL, file, artifact, or summary. Do not keep a task space open merely because a page was visited, a document was created, or a screenshot was used for verification.
When passing a string that may create a new task space, the string should reflect the task's intent (e.g. 'search github issues'); don't use literal placeholders.
If the task space needs to be preserved after the task ends, keep only the tabs that need to be shown to the user. Keep loose awareness of how many tabs are open — a quick (await listTabs()).length is enough; there's no need to spend a dedicated round just to check. When scratch tabs (search-result pages, cross-check pages, and other one-off pages) pile up, close them as you go rather than letting them all accumulate for the end. When finishing with { keep: true } to leave pages for the user, clear out the remaining scratch tabs so only the pages worth showing stay open. Close a single tab with await closeTab(targetId) (targetId comes from listTabs() or an openOrReuseTab return value).
Control handoff
Only one side — agent or user — holds control of a task space at any time. While the user holds control, any browser operation by the agent fails with a "user is controlling" message — do not retry it; follow the steps below to resume.
A "user is controlling" error is a hard stop on the whole task — not an obstacle to route around. It means the user has deliberately taken the browser back, often because your current approach is going wrong. Honoring it is the correct outcome here; pushing the goal forward anyway is the failure. The only thing you may do is ask the user and wait.
An "inactive", "not assigned to an agent", or similar task-space error is also a hard stop with the same confirmation requirement. Resume only after explicit user confirmation, then start with await claimTaskSpace(id).
Handing off: When the task requires user intervention (e.g. login, captcha, manual confirmation), call await handOffTaskSpace([nameOrId]) to give control to the user, and tell them exactly what to do. Omitting nameOrId uses the currently selected task space; pass task.id across heredoc rounds to avoid ambiguity.
Regaining control: Take control back only after the user explicitly confirms — through an Ask (your harness's button/option prompt, e.g. "Continue" vs "Finish task") or a "continue" message in chat. Then start a new heredoc with await takeOverTaskSpace([nameOrId]) and resume; if the user chooses to finish, close out with await completeTaskSpace(nameOrId, { keep }). Never call takeOverTaskSpace on your own to grab control back — it has no ownership check and will seize the browser away from the user.
Unexpected takeover: The user can take over at any time via the browser GUI — the same effect as the agent calling handOffTaskSpace. Do not retry the failed operation and do not auto-takeover; surface the Ask above (Continue / Finish) and resume only when the user picks Continue.
await waitForAgentControl(nameOrId) is a read-only blocking poll (it never takes control); use it only to wait inside the current heredoc for a handoff you initiated.
Scroll / mouse
// DOM scroll
await scrollBy(900)
await scrollToBottomUntil(
async () => await js(String.raw`document.querySelectorAll('article').length`) >= 20,
{ step: 900, wait: 1, maxSteps: 20 }
)
// Real wheel event
await scroll({ dy: 900 })
Element-target helpers such as click, doubleClick, hover, dragMouse, fillInput, uploadFile, and waitForElement accept the same selector/ref surface: raw CSS, xpath=..., @N / ref=N, and loc=... values from snapshotText() (loc=css:..., loc=role:..., loc=href:...). @N refs are for ego-browser helpers only; they are not valid selectors inside document.querySelector(...).
click, doubleClick, hover, and dragMouse share these target formats. Coordinates are in CSS pixels:
string— CSS selector,xpath=...,@N/ref=N, orloc=...; clicks the element's center.[x, y]or{x, y}— viewport coordinates.{selector}— CSS selector,xpath=...,@N/ref=N, orloc=...; clicks the element's center.{selector, x, y}— offset from the element's top-left corner byx/y.options.label(optional) — a 3-6 word action description; triggers a visual highlight animation.
await click('@21', { label: 'check login status' })
await click('button.primary', { label: 'click submit button' })
await click([420, 260])
await click({ x: 420, y: 260 })
await click({ selector: 'canvas#stage', x: 12, y: 8 })
await hover('@5', { label: 'hover to reveal menu' })
await dragMouse([from, to], { label: 'drag card' })
uploadFile
await uploadFile('input[type="file"]', "/absolute/path/to/file.pdf")
js
js() is essentially Runtime.evaluate and takes a string. You can pass a function, but doing so triggers a one-time warning and wraps it via .toString() — closures are not captured and there is no argument channel. Do not use js() the way you would Puppeteer / Playwright's page.evaluate(fn, ...args).
When you need to run multi-step logic inside the browser, wrap it in a single self-invoking closure and return once — don't split it across multiple await js() calls:
const data = await js(String.raw`(() => {
const items = [...document.querySelectorAll('article')]
return items.map(el => ({
text: el.innerText,
links: [...el.querySelectorAll('a')].map(a => a.href),
}))
})()`)
Recommended workflow
ego-browser has three main workflows. Pick the workflow that fits the page and task before acting.
Use the semantic workflow first for ordinary websites with real DOM controls. For canvas-like productivity apps and rich editors — including Google Docs, Google Sheets, Lark/Feishu Docs, Notion, Figma, whiteboards, maps, and other virtualized editors — use the visual workflow first for the main editing surface. These apps often expose toolbars, title inputs, hidden textareas, offscreen iframes, or canvas layers in the DOM that do not represent the actual user-editable document or grid. Do not rely on await fillInput(...), DOM selectors, or snapshotText() refs for the main editing surface unless a small write probe proves the text lands in the intended place.
Before writing substantial content into a rich editor, perform a tiny write probe, then verify it with await captureScreenshot(), an export/readback path, or another reliable visual/state check. If the probe appears in the title bar, toolbar search, hidden input, or any wrong field, stop using DOM/input helpers for that surface and switch to screenshot-guided mouse actions plus real keyboard operations.
-
Semantic workflow:
snapshotText()+ refs / locators — default for most pages with normal text, links, buttons, forms, tables, and lists.- Reuse or create a task space:
const task = await useOrCreateTaskSpace(name). - Open or switch pages with
await openOrReuseTab(url, { wait: true }); useawait gotoAndWait(url, { timeout, settle })only when navigating inside the current tab. - Observe with
await snapshotText()to get a full-page semantic tree annotated with[ref=N, loc=..., url=...]. - Act with
await click('@N'),await fillInput('@N', ...), or stableloc=...values. Use direct DOM logic only when it is simpler than helper calls. - After meaningful clicks, input, or navigation, observe again with
await snapshotText(),await pageInfo(), orawait captureScreenshot()before assuming success.
- Reuse or create a task space:
-
Visual workflow:
await captureScreenshot()+ coordinate/keyboard actions — use when the page is primarily visual, canvas-like, heavily virtualized, or when accessibility / semantic structure is incomplete.- Inspect the screenshot, act with viewport coordinates such as
await click([x, y]),await doubleClick([x, y]),await pressKey(...), andawait typeText(...), then verify with another screenshot or a reliable export/readback path. - Prefer this path for rich editors, spreadsheets, visual menus, map/canvas UIs, drag interactions, and targets that are obvious visually but poor in the DOM/AX tree.
- Inspect the screenshot, act with viewport coordinates such as
-
Direct DOM / CDP workflow:
await js(...)/await cdp(...)— use when you need browser state, compact data extraction, custom DOM traversal, or raw browser capabilities.- Keep browser-side logic in one explicit IIFE and return once.
- Use
await cdp(...)for browser protocol operations that helpers do not cover.
Эти рабочие процессы можно комбинировать. Задача может потребовать нескольких раундов heredoc, когда следующий шаг зависит от свежего состояния страницы или передачи управления пользователю. В каждом раунде пишите связный скрипт, продвигающий задачу: наблюдение, действие или извлечение, проверка и отчёт с cliLog(...). Избегайте крошечных пробных скриптов, но не втискивайте всю задачу в один раздутый скрипт.
Оговорки
wait(...)иtimeoutзначения указаны в секундах; только параметры, имена которых заканчиваются наMsуказываются в миллисекундах.snapshotText()по умолчанию равенscope: 'full_page', охватывая всю страницу. Используйте значение по умолчанию почти во всех случаях; передавайтеscope: 'only_within_viewport'только когда задаче нужен лишь видимый контент.@Nrefs действительны только для самого последнего вызоваsnapshotText— каждый вызов перестраивает refMap. Номера ref берутся из CDPbackendNodeId, поэтому один и тот же элемент сохраняет один и тот же номер между вызовами; но чтобы использовать@N, N должен присутствовать в последнем выводе snapshotText. Элемент, прокрученный за пределы области просмотра, повторный рендер DOM или предыдущий вызов сscope:'only_within_viewport', который не охватил элемент, — всё это приведёт кUnknown ref. Для элементов, на которые нужно ссылаться долго, используйтеloc=...значение из вывода snapshotText как стабильный селектор или пишите CSS-селектор напрямую.js()возвращает вычисленный результат, а не строку JSON — не оборачивайте его вJSON.parse(...).- Внутри
js(...)шаблонной строки обратные слэши регулярных выражений нужно удваивать (например,\\d,\\s), или используйтеString.raw. - Если исходный код, переданный в
js(), содержитreturnверхнего уровня, он будет автоматически обёрнут в IIFE;returnвнутри вложенных колбэков также может случайно вызвать это. Для сложных выражений предпочитайте явную(() => { ... })()форму. - If
await pageInfo()сообщаетw: 0orh: 0, не продолжайте действия с координатами или скриншоты, пока область просмотра не исправлена. Попробуйте переключиться на реальную вкладку, перезагрузить или использовать метрики области просмотра CDP, затем проверьте с помощьюawait pageInfo()иawait captureScreenshot(). - Код в теле heredoc выполняется в Node.js; код внутри
js(...)выполняется на странице браузера. Навигация, ожидания иcliLog(...)относятся к телу heredoc;document,window, и селекторы страницы относятся внутрьjs(...). - Всегда вызывайте
completeTaskSpace(name, { keep }), когда задача выполнена — не оставляйте пространство висеть. По умолчанию используйте{ keep: false }; используйте{ keep: true }только для конкретных случаев с живой страницей, описанных в разделе Task spaces. - Когда пользователь явно просит использовать ego-browser, считайте, что и
ego-browser, и среда выполнения репозитория готовы. Не проверяйте заранееwhich ego-browser,node -v, метаданные пакета или вывод справки. Исследуйте проблемы окружения только если первый запуск выдаёт ошибку. - Если первый запуск сообщает
command not found/ об отсутствующем окружении (скорее всего, ego lite ещё не установлен), или пользователь явно просит установить ego lite, сначала прочитайтеreferences/install.mdи следуйте его последовательности действий, чтобы завершить установку, затем вернитесь к исходной задаче — не сдавайтесь и не продолжайте повторять один и тот же heredoc.
Вставить в README
Ссылка на карточку для вашего README — без картинок и счётчиков.
[DarkPlay: ego-browser](https://darkplay.ru/ai/skills/citrolabs-ego-lite-ego-browser)
Похожие скиллы и другие разделы каталога
Самые востребованные скиллов раздела по установкам и звёздам.
find-skillsvercel-labs · Помогает находить и устанавливать навыки агентов по запросам вроде «как сделать X»…
grill-memattpocock · Настойчивое интервью для доработки плана или дизайна.
hyperframesheygen-com · Обязательная точка входа для любых задач по видео, анимации и motion-графике в…
hyperframes-cliheygen-com · Цикл разработки HyperFrames CLI: init, add, render, preview, publish и другие команды.
agent-browservercel-labs · CLI для автоматизации браузера для ИИ-агентов: навигация по страницам, заполнение форм…
media-useheygen-com · Agent Media OS: единый навык для медиа в HyperFrames — BGM, SFX, изображения, голос, LUT.
hyperframes-registryheygen-com · Установка и подключение блоков реестра в композиции HyperFrames через add и catalog.
grill-with-docsmattpocock · Настойчивое интервью для доработки плана или дизайна, попутно создающее документацию (ADR…
improve-codebase-architecturemattpocock · Поиск в кодовой базе возможностей для углубления, визуальный HTML-отчёт о них и детальный…
tddmattpocock · Разработка через тестирование (TDD): red-green-refactor и интеграционные тесты.Соседние разделы каталога: возможно, нужный инструмент живёт там.
E2e Runneraffaan-m · Специалист по E2E-тестам на Vercel Agent Browser и Playwright: генерация, запуск и…
ruflo-browserruvnet · Агентная автоматизация браузера на Playwright для тестирования, скрапинга и…
agent-browservercel-labs · Автоматизирует взаимодействия в браузере для веб-тестирования, заполнения форм…
brightdata-pluginanthropics · Веб-скрапинг, поиск в Google, извлечение структурированных данных и интеграция…
chrome-devtools-mcpanthropics · Управление и инспекция живого браузера Chrome из вашего агента разработки. Запись…
hostingeranthropics · Развёртывание, управление и мониторинг сервисов Hostinger: сайты, домены, ecommerce…
playwrightanthropics · MCP-сервер для автоматизации браузера и end-to-end тестирования от Microsoft. Позволяет…
valtownanthropics · Создание и развёртывание на Val Town. Включает MCP-сервер Val Town и навыки платформы…
qa-orchestrawshobson · Мультиагентный QA-набор из 10 специализированных агентов на весь жизненный цикл QA…
b12-claude-pluginanthropics · Плагин B12 с двумя навыками: Website Generator (создание сайта B12 по краткому описанию)…Лучшие ИИ-инструменты для автоматизации и ассистентов
Подборка ИИ-ассистентов для автоматизации рутины и ускорения рабочих процессов. Сервисы, которые берут на себя переписку, анализ данных, ведение базы знаний и подготовку продаж, эк
Give Me Public
AITunnelAitunnel
STIVAStiva
Wikibot (Викибот)Wikibot
mymeet.aiMymeet
InsighterInsighter
TGHuntTghunt
LegiscanLegiscan
RouterAIRouterai
Wikibot 1.0 (Викибот)WikibotЛучшие ИИ-инструменты для генерации видео
Подборка нейросетей для генерации и монтажа видео. Инструменты, которые превращают текст в готовые ролики, экономят часы на съемках и постпродакшне. Подходит для SMM-специалистов,
VEED.IOVeed
MootionMootion
Sora (OpenAI)OpenAI
viralpulse.appViralpulse
Viral Maker AIViral-makerЛучшие ИИ-инструменты для генерации текста и копирайтинга
Подборка нейросетей для генерации текстов и копирайтинга. Сервисы, которые помогают создавать статьи, посты и рекламные объявления с нуля или по черновику, экономя часы рутинной ра
NeuroscribeNeuroscribe
GoGPTGogpt
НейроТекстерNeuro-texter
ChatGPTOpenAI
Cosmo ScribeCosmoscribe
Memo HelperCopilot33
LibraChatLibrachat