Skip to main content

agent-events

Push browser tab and download lifecycle events plus manager-owned background tabs. Read this when an agent needs lifecycle notifications or a temporary tab without polling.

소스 정보

저장소
code-yeongyu/omowright
최근 소스 활동
2026년 9월 23일 05:10
감지된 SKILL.md 언어
영어
스타
3
포크
2

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
agent-events
description
Push browser tab and download lifecycle events plus manager-owned background tabs. Read this when an agent needs lifecycle notifications or a temporary tab without polling.
# Agent Events **TREAT THESE AS PUSH NOTIFICATIONS — NEVER POLL `Target.getTargets` TO DETECT OPENS, CLOSES, POPUPS, OR DOWNLOADS.** One events capability per connection; await `ready` before trusting baseline discovery or download configuration: ```js import { createEvents, createAgentTabs } from "omowright"; const events = createEvents(connection, { downloadBehavior: "allow", downloadPath: "/absolute/path/to/downloads", }); const tabs = createAgentTabs(connection); await Promise.all([events.ready, tabs.ready]); ``` ## Subscribe before acting Install the listener or `waitForEvent()` before the action that produces the event. Waits are bounded; predicates may be async: ```js const opened = events.waitForEvent("popupOpened", { timeout: 30_000, predicate: tab => tab.openerTargetId === mainTargetId, }); await mainPage.evaluate("window.open('https://example.com')"); const popup = await opened; ``` Six push events: `tabOpened`, `tabClosed`, `popupOpened`, `downloadStarted`, `downloadProgress`, `downloadFinished`. Only page targets produce tab events. A popup produces both `tabOpened` and `popupOpened`; `about:blank` is a valid URL and popup placeholder. Download progress is not coalesced; terminals fire exactly once. ## Own temporary tabs through the manager **CREATE TABS ONLY THROUGH `createAgentTabs(connection)`. NEVER SEND `Target.createTarget` YOURSELF, NEVER CALL `Target.activateTarget`, NEVER BRING A TAB TO THE FRONT.** The manager always requests background creation so automation cannot steal focus, and it owns cleanup. ```js const tab = await tabs.create("about:blank", { viewport: { width: 1440, height: 900 }, }); try { await tab.page.goto("https://example.com"); await tabs.repin(tab); } finally { await tabs.close(tab); } ``` CloakBrowser headless defers renderer startup for background targets, so the manager activates immediately before attaching — only for connections launched with a `--headless` argument. Headed connections attach without activation. `tabs.list()` / `tabs.get(targetId)` expose only manager-created tabs. The manager pins the viewport after attach and after main-frame navigation; child-frame navigation needs no re-pin. `tabs.repin` forces a fresh pin before a coordinate action. Cleanup: `await tabs.closeAll()` or `await tabs.dispose()` (owns its tabs by default); `events.dispose()` closes neither the browser nor the agent tabs.
GitHub에서 보기