The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.
JavaScript agent-skillsai-agentautomationbrowserbrowser-automationclaude-codecodexhermes-agentskillsskills-sh
docs(ego-browser): keep one task space per goal across replies
0x03648507f57a7
diff --git a/package/ego-browser/skill-body/SKILL.md b/package/ego-browser/skill-body/SKILL.mdindex f6ed9d9..571c2be 100644--- a/package/ego-browser/skill-body/SKILL.md+++ b/package/ego-browser/skill-body/SKILL.md@@ -116,14 +116,11 @@ and diagnose the CLI or installation only if it fails.## Spaces, rounds, and pages-- Use exactly one TaskSpace for the entire user goal. Create it once, print its- `spaceId`, and resume that same space in later rounds. Use multiple spaces- only when the user explicitly requests them.-- Task space names are unique. `taskSpace(name)` resumes your own space with- that name instead of creating a second one. If the name belongs to a- user-owned space, it fails with `EGO_TASK_SPACE_NAME_IN_USE`: ask the user- whether to work in that space (then `claimTaskSpace(id)`), or pick another- name.+- One user goal uses one TaskSpace across all of your replies about it. Use+ multiple spaces only when the user explicitly requests them.+- Start and end each message's browser work as described in "Starting and+ ending a message" below. Task space names are unique; prefer the numeric id+ once you have it.- Never use a new TaskSpace to recover from a stuck, blocked, timed-out, orunexpected Page. Recover within the existing space; if it cannot continue,stop and ask the user.@@ -134,13 +131,6 @@ and diagnose the CLI or installation only if it fails.- Reuse a Page with `goto()` instead of opening a new Page for every URL.- All time values are milliseconds.-```js-// Later round: use the space id and Page label printed earlier.-const resumed = await taskSpace(7);-const source = resumed.page("p1");-await source.goto("https://example.com/releases");-```-Do not inspect or select profiles unless the user explicitly requests aparticular Ego Lite profile. A `profileId` applies only when creating a space;use `help("profiles")` for the exact workflow.@@ -490,7 +480,56 @@ await page.fetch("/image.png", { saveAs: "/absolute/path/image.png" });Use standard Node.js `fetch()` for background requests that do not need Pagebrowser semantics.-## User control and completion+## Starting and ending a message++Begin the first script of each message by choosing the space. A new goal gets a+new space. A message that continues an earlier goal, such as a further+question, a correction, or a request to continue, continues in that goal's+space, whatever state your last reply left it in:++```js+const SPACE_ID = 7; // printed by your last reply about this goal; null for a new goal+const entry =+ SPACE_ID === null+ ? undefined+ : (await listTaskSpaces()).find((s) => s.id === SPACE_ID);+const task = !entry+ ? await taskSpace("descriptive goal name") // new goal, or the earlier space was closed+ : entry.ownership === "user"+ ? await claimTaskSpace(SPACE_ID) // you finished it with kept Pages+ : await taskSpace(SPACE_ID); // not finished, still yours+console.log({ taskSpaceId: task.spaceId, tabs: await task.tabs() });+// A claimed space has no Page labels yet: adopt its tab before operating.+const page =+ (await task.pages())[0] ?? (await task.adopt((await task.tabs())[0].page));+```++After a claim, earlier Page labels are gone; use the adopted Page. Do not call+`taskSpace(name)` or `takeOverTaskSpace()` on a space you finished; both stop.++End each message's browser work with one `finish()` in a separate last script,+run after earlier output has shown that the request is done, and wait for it+before you report. A space finished too early cannot take more work in this+message:++```js+// Default: close the space. Closing its Pages first also covers Pages adopted after a claim,+// which `keep: []` alone would hand back to the user.+for (const page of await task.pages()) await page.close();+await task.finish({ keep: [] });++// Exception: keep only the result Page for the user.+await task.finish({ keep: ["p2"] });+```++Keeping Pages is a rare exception: retain only necessary Pages when the user+explicitly asks, or when the result must remain in the browser for the user to+view or continue working with. Pages merely visited, search results, and+intermediate steps do not need to remain open.++After `finish()`, do not operate any Page in the same script.++## User controlStop when the user takes control or the space is inactive or unassigned. Do notretry or route around the stop. Permission prompts, device choosers, and@@ -508,45 +547,17 @@ const userPage = task.userPage();```Adopt `userPage` if it is unmanaged. Use `waitForControl()` only when the current-script must wait in place. Claim a user-owned or inactive space only when the-user explicitly asks; this includes a space you finished with kept Pages, which-`takeOverTaskSpace()` cannot resume. Find its numeric id first; names may be-duplicated. `listTaskSpaces()` entries expose that id as `id` (`spaceId` exists-only on a TaskSpace handle), so pass `entry.id` to `claimTaskSpace()` or-`taskSpace()`:--```js-const spaces = await listTaskSpaces();-console.log(spaces.filter((space) => space.ownership === "user"));--const task = await claimTaskSpace(7);-const userPage = task.userPage();-```--When the task succeeds, close the TaskSpace by default with-`await task.finish({ keep: [] })`. Call `finish()` exactly once and wait for it-to resolve before reporting completion.+script must wait in place.-`finish()` ends the task and all of its Page labels, including Pages kept for the-user. Put it last in the final round only; do not operate any Page after it in-the same script or in later rounds.--Keeping Pages is a rare exception: retain only necessary Pages when the user-explicitly asks, or when the result must remain in the browser for the user to-view or continue working with. Pages merely visited, search results, and-intermediate steps do not need to remain open.--```js-await task.finish({ keep: [] }); // Default: keep no Agent-managed Pages.-await task.finish({ keep: ["p2"] }); // Exception: keep only the result Page for the user.-```+Claim a user-owned or inactive space that is not yours to continue only when the+user explicitly asks.User-created and unknown-origin tabs are protected; if any remain, `keep: []`-does not close the whole space. The blank tab that `page.close()` leaves when it-closes the last Page is SDK-owned and never blocks closing. Do not close-unwanted Pages one by one at completion; list the Pages to keep instead.-Use `page.close()` only while the task is still in progress. Do not call-`finish()` when the task stops for user control or an error.+does not close the whole space. Tabs adopted after a claim keep an unknown+origin, which is why the default close above closes the Pages first. The blank+tab that `page.close()` leaves when it closes the last Page is SDK-owned and+never blocks closing. Do not call `finish()` when the task stops for user+control or an error.If the final output contains `[ego-browser:notice]`, finish the current browsertask, tell the user an Ego Lite update is available, and rundiff --git a/package/ego-browser/src/skill-package.test.mjs b/package/ego-browser/src/skill-package.test.mjsindex 02089a1..fdeb5db 100644--- a/package/ego-browser/src/skill-package.test.mjs+++ b/package/ego-browser/src/skill-package.test.mjs@@ -52,9 +52,7 @@ test("the bundled usage guide is the unwrapped source guide between version andtest("the guide hands login, verification and manual steps back to the user", async () => {const guide = await readFile(join(outDir, "ego-browser/SKILL.md"), "utf8");- const section = /^## User control and completion$[\s\S]*?(?=^## )/m.exec(- guide,- )[0];+ const section = /^## User control$[\s\S]*?(?=^## )/m.exec(guide)[0];const rule = section.split("\n\n").find((paragraph) => paragraph.includes("task.handOff()"));diff --git a/plugins/ego/tests/claude-plugin-mode-isolation.test.mjs b/plugins/ego/tests/claude-plugin-mode-isolation.test.mjsindex b288b80..74a4c62 100644--- a/plugins/ego/tests/claude-plugin-mode-isolation.test.mjs+++ b/plugins/ego/tests/claude-plugin-mode-isolation.test.mjs@@ -37,17 +37,17 @@ function assertPureSkillText(value, label) {function assertTaskSpaceSafety(skill, label) {assert.match(skill,- /exactly one TaskSpace for the entire user goal/i,+ /One user goal uses one TaskSpace across all of your replies about it/i,`${label} must keep one TaskSpace per user goal`,);assert.match(skill,- /resume that same space in later rounds/i,+ /continues in that goal's\s+space, whatever state your last reply left it in/i,`${label} must resume the existing TaskSpace across rounds`,);assert.match(skill,- /Claim a user-owned or inactive space only when the\s+user explicitly asks/i,+ /Claim a user-owned or inactive space that is not yours to continue only when the\s+user explicitly asks/i,`${label} must not implicitly claim a user-owned TaskSpace`,);assert.match(@@ -67,7 +67,7 @@ function assertTaskSpaceSafety(skill, label) {);assert.match(skill,- /Call `finish\(\)` exactly once and wait for it\s+to resolve before reporting completion/i,+ /End each message's browser work with one `finish\(\)` in a separate last script,[\s\S]*?wait for it\s+before you report/i,`${label} must wait for cleanup before reporting completion`,);assert.match(@@ -162,7 +162,7 @@ test("versioned guide restores v2 Pages across script rounds", () => {skill,/Every invocation starts a new Node\.js process[\s\S]*Page labels\s+persist; JavaScript variables do not/i,);- assert.match(skill, /await taskSpace\(7\);[\s\S]*resumed\.page\("p1"\)/);+ assert.match(skill, /await taskSpace\(SPACE_ID\);[\s\S]*task\.adopt\(/);assert.match(skill, /After the page changes, take a new snapshot/);assert.doesNotMatch(skill,