dsh-browser-cdp 0.0.1 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +27 -0
- package/README.md +279 -9
- package/THIRD_PARTY_NOTICES.md +62 -0
- package/bin/cdp-cast-worker.mjs +6960 -0
- package/bin/cdp-chrome-wrapper.sh +53 -0
- package/bin/cdp-render-worker.mjs +610 -0
- package/bin/record-normalize.d.mts +32 -0
- package/bin/record-normalize.mjs +156 -0
- package/cordis.patch.yml +17 -0
- package/dsh-plugin.json +148 -0
- package/lib/client.js +3235 -0
- package/lib/index.js +8865 -0
- package/lib/launcher-CQyI8-By.js +3 -0
- package/lib/launcher-DBaxfIsF.js +269 -0
- package/package.json +90 -14
- package/runtime/PATCHES.md +30 -0
- package/runtime/ego-browser/dist/out/index.js +7206 -0
- package/runtime/ego-browser/screenshot-clip.d.mts +22 -0
- package/runtime/ego-browser/screenshot-clip.mjs +45 -0
- package/runtime/ego-linux/bin/ego-browser.mjs +399 -0
- package/runtime/ego-linux/src/agent-identity.mjs +65 -0
- package/runtime/ego-linux/src/chrome.mjs +867 -0
- package/runtime/ego-linux/src/cursor.mjs +1292 -0
- package/runtime/ego-linux/src/desktop.mjs +73 -0
- package/runtime/ego-linux/src/paths.mjs +35 -0
- package/runtime/ego-linux/src/session.mjs +37 -0
- package/runtime/ego-linux/src/shim.mjs +145 -0
- package/runtime/ego-linux/src/snapshot.mjs +424 -0
- package/runtime/ego-linux/src/spaces-server.mjs +355 -0
- package/runtime/ego-linux/src/spaces-ui.mjs +456 -0
- package/runtime/ego-linux/src/tabs.mjs +109 -0
- package/runtime/ego-linux/src/task-spaces.mjs +671 -0
- package/runtime/ego-linux/src/transport.mjs +321 -0
- package/runtime/ego-linux/src/window-fit.mjs +107 -0
- package/runtime/skills/ego-browser/SKILL.md +209 -0
- package/runtime/skills/ego-browser/agents/openai.yaml +7 -0
- package/runtime/skills/ego-browser/assets/composer-icon.png +0 -0
- package/runtime/skills/ego-browser/assets/logo.png +0 -0
- package/runtime/skills/ego-browser/learnings/google/browser-tools/autocomplete.js +11 -0
- package/runtime/skills/ego-browser/learnings/google/manifest.json +40 -0
- package/runtime/skills/ego-browser/learnings/google/notes/overview.md +23 -0
- package/runtime/skills/ego-browser/learnings/google/tools/search-extract.js +35 -0
- package/runtime/skills/ego-browser/learnings/x-com/browser-tools/extract-post.js +9 -0
- package/runtime/skills/ego-browser/learnings/x-com/manifest.json +51 -0
- package/runtime/skills/ego-browser/learnings/x-com/notes/overview.md +18 -0
- package/runtime/skills/ego-browser/learnings/x-com/notes/timeline.md +19 -0
- package/runtime/skills/ego-browser/learnings/x-com/tools/search-users.js +33 -0
- package/runtime/skills/ego-browser/learnings/x-com/tools/timeline.js +32 -0
- package/runtime/skills/ego-browser/references/install.md +131 -0
- package/runtime/skills/ego-browser/references/task-spaces.md +122 -0
- package/runtime/skills/ego-browser/references/video.md +17 -0
- package/runtime/skills/ego-browser/scripts/install.sh +309 -0
- package/index.js +0 -11
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "google",
|
|
3
|
+
"name": "Google Search",
|
|
4
|
+
"domains": ["google.com", "*.google.com", "www.google.com"],
|
|
5
|
+
"notes": ["notes/overview.md"],
|
|
6
|
+
"nodeTools": {
|
|
7
|
+
"search_and_extract": {
|
|
8
|
+
"description": "Perform a Google search and extract top organic results.",
|
|
9
|
+
"path": "tools/search-extract.js",
|
|
10
|
+
"callable": "searchAndExtract",
|
|
11
|
+
"args": {
|
|
12
|
+
"query": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"required": true,
|
|
15
|
+
"description": "Search query string."
|
|
16
|
+
},
|
|
17
|
+
"maxResults": {
|
|
18
|
+
"type": "integer",
|
|
19
|
+
"required": false,
|
|
20
|
+
"description": "Maximum number of results to extract."
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"returns": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"description": "Array of {title, url, snippet} objects."
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"browserTools": {
|
|
30
|
+
"get_autocomplete_suggestions": {
|
|
31
|
+
"description": "Get autocomplete suggestions for the current search query.",
|
|
32
|
+
"path": "browser-tools/autocomplete.js",
|
|
33
|
+
"args": {},
|
|
34
|
+
"returns": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"description": "Array of suggestion strings."
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Google Search Overview
|
|
2
|
+
|
|
3
|
+
## Page structure
|
|
4
|
+
|
|
5
|
+
- Search input: `textarea[name="q"]` or `input[name="q"]`
|
|
6
|
+
- Results container: `div#search`
|
|
7
|
+
- Individual result items: `div.g`
|
|
8
|
+
- Result title: `h3` inside `div.g`
|
|
9
|
+
- Result link: `a[href]` inside `div.g a`
|
|
10
|
+
- Result snippet: text content below the title
|
|
11
|
+
|
|
12
|
+
## Navigation
|
|
13
|
+
|
|
14
|
+
- Use `browser.openOrReuseTab` with `https://www.google.com/search?q=...`
|
|
15
|
+
- Results load immediately, no infinite scroll on first page
|
|
16
|
+
- Pagination links at bottom: `a[href*="/search?q="]`
|
|
17
|
+
|
|
18
|
+
## Common selectors
|
|
19
|
+
|
|
20
|
+
- Query box: `textarea[name="q"]`
|
|
21
|
+
- Search button: `input[type="submit"]`
|
|
22
|
+
- Auto-complete dropdown: `div[role="listbox"]`
|
|
23
|
+
- Auto-complete items: `.ssb-a`
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function boundedInteger(value, fallback, max) {
|
|
2
|
+
const number = value === undefined ? fallback : Number(value);
|
|
3
|
+
if (!Number.isFinite(number)) return fallback;
|
|
4
|
+
return Math.max(1, Math.min(max, Math.trunc(number)));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export async function searchAndExtract(ctx, args = {}) {
|
|
8
|
+
const query = args.query || "";
|
|
9
|
+
const maxResults = boundedInteger(args.maxResults, 10, 100);
|
|
10
|
+
if (!query) throw new Error("search query is required");
|
|
11
|
+
|
|
12
|
+
await ctx.browser.openOrReuseTab(
|
|
13
|
+
`https://www.google.com/search?q=${encodeURIComponent(query)}`,
|
|
14
|
+
{ wait: true },
|
|
15
|
+
);
|
|
16
|
+
await ctx.page.waitForLoadState("load");
|
|
17
|
+
|
|
18
|
+
const results = await ctx.page
|
|
19
|
+
.locator("div.g")
|
|
20
|
+
.evaluateAll((items, limit) => {
|
|
21
|
+
return items
|
|
22
|
+
.slice(0, limit)
|
|
23
|
+
.map((el) => ({
|
|
24
|
+
title: el.querySelector("h3")?.innerText?.trim() || "",
|
|
25
|
+
url: el.querySelector("a")?.getAttribute("href") || "",
|
|
26
|
+
snippet:
|
|
27
|
+
el.querySelector("[data-sncf]")?.innerText?.trim() ||
|
|
28
|
+
el.querySelector("span")?.innerText?.trim() ||
|
|
29
|
+
"",
|
|
30
|
+
}))
|
|
31
|
+
.filter((r) => r.title);
|
|
32
|
+
}, maxResults);
|
|
33
|
+
|
|
34
|
+
return results;
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
async function(args) {
|
|
2
|
+
const el = document.querySelector('[data-testid="tweet"]:focus') || document.querySelector('[data-testid="tweet"]');
|
|
3
|
+
if (!el) return { error: 'no active tweet found' };
|
|
4
|
+
return {
|
|
5
|
+
text: el.querySelector('[data-testid="tweetText"]')?.innerText?.trim() || '',
|
|
6
|
+
author: el.querySelector('[data-testid="User-Name"] span')?.innerText?.trim() || '',
|
|
7
|
+
timestamp: el.querySelector('time')?.getAttribute('datetime') || '',
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "x-com",
|
|
3
|
+
"name": "X (Twitter)",
|
|
4
|
+
"domains": ["x.com", "*.x.com", "twitter.com", "*.twitter.com"],
|
|
5
|
+
"notes": ["notes/overview.md", "notes/timeline.md"],
|
|
6
|
+
"nodeTools": {
|
|
7
|
+
"get_timeline_posts": {
|
|
8
|
+
"description": "Extract posts from the current X timeline using the anti-click-wrap pattern.",
|
|
9
|
+
"path": "tools/timeline.js",
|
|
10
|
+
"callable": "getTimelinePosts",
|
|
11
|
+
"args": {
|
|
12
|
+
"maxPosts": {
|
|
13
|
+
"type": "integer",
|
|
14
|
+
"required": false,
|
|
15
|
+
"description": "Maximum number of posts to extract."
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"returns": {
|
|
19
|
+
"type": "array",
|
|
20
|
+
"description": "Array of post objects with text, author, and timestamp."
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"search_users": {
|
|
24
|
+
"description": "Search for users on X.",
|
|
25
|
+
"path": "tools/search-users.js",
|
|
26
|
+
"callable": "searchUsers",
|
|
27
|
+
"args": {
|
|
28
|
+
"query": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"required": true,
|
|
31
|
+
"description": "Search query string."
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"returns": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"description": "Array of user info objects."
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"browserTools": {
|
|
41
|
+
"post_from_active_element": {
|
|
42
|
+
"description": "Extract tweet data from the currently focused element in the timeline.",
|
|
43
|
+
"path": "browser-tools/extract-post.js",
|
|
44
|
+
"args": {},
|
|
45
|
+
"returns": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"description": "Tweet text, author, timestamp."
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# X (Twitter) Overview
|
|
2
|
+
|
|
3
|
+
## Page structure
|
|
4
|
+
- Main navigation: Left sidebar `[data-testid="AppTabBar"]`
|
|
5
|
+
- Timeline content: `[data-testid="primaryColumn"]`
|
|
6
|
+
- Tweet items: `[data-testid="tweet"]` — each contains text, author, timestamp
|
|
7
|
+
- Compose box: `[data-testid="twaCreateTweetText"]`
|
|
8
|
+
|
|
9
|
+
## Anti-click-wrap
|
|
10
|
+
- Tweet text is inside `[data-testid="tweetText"]`, click target is `[data-testid="tweet"]`
|
|
11
|
+
- Actions (reply/retweet/like) are inside `div[role="group"]` at the bottom of each tweet card
|
|
12
|
+
|
|
13
|
+
## Common selectors
|
|
14
|
+
- Tweet text: `[data-testid="tweetText"]`
|
|
15
|
+
- Author name: `[data-testid="User-Name"] span`
|
|
16
|
+
- Timestamp: `time` element with `datetime` attribute
|
|
17
|
+
- Search input: `[data-testid="SearchBox_Search_Input"]`
|
|
18
|
+
- Compose textarea: `[data-testid="twaCreateTweetTextarea"]`
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# X Timeline Navigation
|
|
2
|
+
|
|
3
|
+
## Scrolling timeline
|
|
4
|
+
|
|
5
|
+
- Timeline is inside `[data-testid="primaryColumn"]`
|
|
6
|
+
- Posts load lazily as you scroll — scroll down with `page.mouse.wheel(0, 1000)` repeatedly to load more
|
|
7
|
+
- Virtual list: DOM only renders visible articles + buffer
|
|
8
|
+
|
|
9
|
+
## Extracting posts
|
|
10
|
+
|
|
11
|
+
- Query `[data-testid="tweet"]` for post elements
|
|
12
|
+
- Each post has `[data-testid="tweetText"]` for content
|
|
13
|
+
- Author info at `[data-testid="User-Name"]`
|
|
14
|
+
- Always extract in one pass via browser-side closure
|
|
15
|
+
|
|
16
|
+
## Pinned post
|
|
17
|
+
|
|
18
|
+
- Pinned post is the first `[data-testid="tweet"]` in timeline
|
|
19
|
+
- To filter pinned post, skip the first element only when at top of timeline
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export async function searchUsers(ctx, args = {}) {
|
|
2
|
+
const query = args.query || "";
|
|
3
|
+
if (!query) throw new Error("search query is required");
|
|
4
|
+
|
|
5
|
+
await ctx.browser.openOrReuseTab(
|
|
6
|
+
`https://x.com/search?f=user&q=${encodeURIComponent(query)}`,
|
|
7
|
+
{ wait: true },
|
|
8
|
+
);
|
|
9
|
+
await ctx.page.waitForLoadState("load");
|
|
10
|
+
|
|
11
|
+
const users = await ctx.page
|
|
12
|
+
.locator('[data-testid="cellInnerDiv"]')
|
|
13
|
+
.evaluateAll((results) => {
|
|
14
|
+
return results
|
|
15
|
+
.map((el) => ({
|
|
16
|
+
name:
|
|
17
|
+
el
|
|
18
|
+
.querySelector('[data-testid="User-Name"] span')
|
|
19
|
+
?.innerText?.trim() || "",
|
|
20
|
+
handle:
|
|
21
|
+
el
|
|
22
|
+
.querySelector('[data-testid="User-Name"] a')
|
|
23
|
+
?.innerText?.trim() || "",
|
|
24
|
+
followers:
|
|
25
|
+
el
|
|
26
|
+
.querySelector('[data-testid="Follow"]')
|
|
27
|
+
?.previousElementSibling?.innerText?.trim() || "",
|
|
28
|
+
}))
|
|
29
|
+
.filter((u) => u.name || u.handle);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return users;
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function boundedInteger(value, fallback, max) {
|
|
2
|
+
const number = value === undefined ? fallback : Number(value);
|
|
3
|
+
if (!Number.isFinite(number)) return fallback;
|
|
4
|
+
return Math.max(1, Math.min(max, Math.trunc(number)));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export async function getTimelinePosts(ctx, args = {}) {
|
|
8
|
+
const maxPosts = boundedInteger(args.maxPosts, 50, 100);
|
|
9
|
+
|
|
10
|
+
const posts = await ctx.page
|
|
11
|
+
.locator('[data-testid="tweet"]')
|
|
12
|
+
.evaluateAll((articles, limit) => {
|
|
13
|
+
return articles.slice(0, limit).map((el) => ({
|
|
14
|
+
text:
|
|
15
|
+
el.querySelector('[data-testid="tweetText"]')?.innerText?.trim() ||
|
|
16
|
+
"",
|
|
17
|
+
author:
|
|
18
|
+
el
|
|
19
|
+
.querySelector('[data-testid="User-Name"]')
|
|
20
|
+
?.querySelector("span")
|
|
21
|
+
?.innerText?.trim() || "",
|
|
22
|
+
handle:
|
|
23
|
+
el
|
|
24
|
+
.querySelector('[data-testid="User-Name"]')
|
|
25
|
+
?.querySelector("a")
|
|
26
|
+
?.getAttribute("href") || "",
|
|
27
|
+
timestamp: el.querySelector("time")?.getAttribute("datetime") || "",
|
|
28
|
+
}));
|
|
29
|
+
}, maxPosts);
|
|
30
|
+
|
|
31
|
+
return posts;
|
|
32
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Install ego lite
|
|
2
|
+
|
|
3
|
+
Read this file only when ego lite isn't installed yet, or when the user asks to install ego lite. For day-to-day browser work, go back to `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
The ego-browser skill depends on a browser it can drive. On macOS that is the ego lite app, which provides the `ego-browser` command. On Linux there is no app bundle: the same harness drives a stock Chrome/Chromium over CDP. Either way, once the install is done the `ego-browser` command is on PATH and there are no further environment issues.
|
|
6
|
+
|
|
7
|
+
ego lite website: https://lite.ego.app/
|
|
8
|
+
|
|
9
|
+
## Install steps
|
|
10
|
+
|
|
11
|
+
One script covers both platforms — it reads `uname -s` and runs the matching flow, so you do not have to pick:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
sh skills/ego-browser/scripts/install.sh
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
On an unsupported platform it stops with `unsupported platform: <name>` rather than half-installing.
|
|
18
|
+
|
|
19
|
+
### macOS
|
|
20
|
+
|
|
21
|
+
The script will:
|
|
22
|
+
|
|
23
|
+
- Download the ego lite installer (a DMG) for your CPU architecture (arm64 / x64).
|
|
24
|
+
- Install `ego lite.app` to `/Applications` (falling back to `~/Applications` when needed).
|
|
25
|
+
- Strip the quarantine attribute to keep Gatekeeper from blocking the first launch.
|
|
26
|
+
- After installing, launch the `ego lite` app.
|
|
27
|
+
|
|
28
|
+
If ego lite is already installed, the script skips the download and opens the app directly.
|
|
29
|
+
|
|
30
|
+
After the script opens the ego lite app, the user completes the first-run onboarding in the app:
|
|
31
|
+
|
|
32
|
+
- Choose to import data from Chrome or another browser as needed.
|
|
33
|
+
- Onboarding registers the `ego-browser` command on the PATH (usually under `~/.local/bin`).
|
|
34
|
+
|
|
35
|
+
Onboarding is a step the user completes in the GUI. After the script opens ego lite, wait for the user to confirm they've finished onboarding before continuing.
|
|
36
|
+
|
|
37
|
+
### Linux
|
|
38
|
+
|
|
39
|
+
There is nothing to download. The script builds the harness in `package/ego-browser` and links the CDP shim from `package/ego-linux` onto PATH as `ego-browser`, so run it from a checkout of this repository.
|
|
40
|
+
|
|
41
|
+
Requires Node >= 22 and any Chrome/Chromium/Brave/Edge on PATH. The script checks both before touching anything and stops with a clear error rather than half-installing. Set `EGO_LINUX_CHROME` to an absolute path to point it at a browser that is not on PATH, and `EGO_LINUX_BIN_DIR` to link somewhere other than `~/.local/bin`.
|
|
42
|
+
|
|
43
|
+
There is no GUI onboarding step: when the script finishes, the command is ready.
|
|
44
|
+
|
|
45
|
+
Two follow-ups it deliberately does not run for you, because both touch user data:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
ego-browser --import-chrome-profile # inherit the user's real logins
|
|
49
|
+
ego-browser --install-desktop-entry # app launcher icon
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Equivalent by hand, if you would rather see each step:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
cd <repo>/package/ego-browser
|
|
56
|
+
CI=true npm ci && CI=true npm run build # CI=true is required, not cosmetic: the
|
|
57
|
+
# prepare script runs lefthook install,
|
|
58
|
+
# which fails when core.hooksPath is set
|
|
59
|
+
|
|
60
|
+
ln -sf <repo>/package/ego-linux/bin/ego-browser.mjs ~/.local/bin/ego-browser
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### Linux-only commands
|
|
64
|
+
|
|
65
|
+
| Command | What it does |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `ego-browser --status` | backing browser connection state |
|
|
68
|
+
| `ego-browser --open` | open the shared agent browser window |
|
|
69
|
+
| `ego-browser --stop` | stop it and clear the profile lock |
|
|
70
|
+
| `ego-browser --import-chrome-profile` | copy the real Chrome profile in |
|
|
71
|
+
| `ego-browser --install-desktop-entry` | app launcher entry + icon |
|
|
72
|
+
| `ego-browser --headless` | run headless (first launch only) |
|
|
73
|
+
|
|
74
|
+
The browser persists between invocations — each heredoc is its own short-lived Node process, so the browser is what survives, not the process.
|
|
75
|
+
|
|
76
|
+
#### How Linux differs from the macOS app
|
|
77
|
+
|
|
78
|
+
- **`listTabs` is browser-wide**, not per task space. Task spaces still work (own tabs, ownership, `switch` / `claim` / `handOff` / `complete`), but CDP cannot place a tab in a chosen window, so per-space tab lists are not reproducible.
|
|
79
|
+
- **Spaces are isolated, but their login state is a copy.** Each space gets its own cookie jar, seeded from yours when the space is created — so your logins are there, but a login made inside one space does not appear in the others, and `localStorage` / IndexedDB / service workers are not carried at all.
|
|
80
|
+
- **Snapshot content is rebuilt** from `DOMSnapshot.captureSnapshot`. Refs (`@N`) are exact — they are real CDP `backendNodeId`s — but the tree's wording differs from the native snapshot.
|
|
81
|
+
|
|
82
|
+
Full details: `package/ego-linux/README.md`.
|
|
83
|
+
|
|
84
|
+
## After installing: confirm `ego-browser` is available
|
|
85
|
+
|
|
86
|
+
Confirm the command is ready:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
command -v ego-browser
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
If it reports that the command isn't found, `~/.local/bin` is most likely not on the current PATH. Fix it temporarily and retry:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
96
|
+
command -v ego-browser
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Once the command exists, verify the runtime with a minimal heredoc:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
ego-browser nodejs <<'EOF'
|
|
103
|
+
console.log('ego-browser ready')
|
|
104
|
+
EOF
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Printing `ego-browser ready` means the environment is ready.
|
|
108
|
+
|
|
109
|
+
## After that, return to the original task
|
|
110
|
+
|
|
111
|
+
Once the environment is ready, return to the user's original task and continue with the task space flow in `SKILL.md` — start from `taskSpaces.useOrCreate(name)` and proceed as usual.
|
|
112
|
+
|
|
113
|
+
## Troubleshooting
|
|
114
|
+
|
|
115
|
+
Any platform:
|
|
116
|
+
|
|
117
|
+
- **Command still unavailable after installing**: confirm `~/.local/bin` is on the PATH (see above).
|
|
118
|
+
- **Unsupported platform**: the script covers macOS and Linux. Elsewhere, have the user download and install from the ego lite website at https://lite.ego.app/.
|
|
119
|
+
|
|
120
|
+
macOS:
|
|
121
|
+
|
|
122
|
+
- **Download failed**: the script retries 3 times automatically; if it still fails, it's usually a network issue — have the user check their network and retry.
|
|
123
|
+
- **Gatekeeper still blocks it**: the script already tries to strip quarantine; if the first launch is still blocked, have the user allow ego lite manually under System Settings → Privacy & Security.
|
|
124
|
+
- **Command still unavailable after onboarding**: have the user reopen ego lite, finish onboarding, and retry.
|
|
125
|
+
|
|
126
|
+
Linux:
|
|
127
|
+
|
|
128
|
+
- **"no Chrome/Chromium/Brave/Edge found on PATH"**: install one, or set `EGO_LINUX_CHROME` to an absolute path.
|
|
129
|
+
- **"Chrome did not expose a DevTools port"**: a killed browser left a profile lock. `ego-browser --stop` clears it, then retry.
|
|
130
|
+
- **Clicks land on nothing / coordinates look wrong**: page zoom. The launcher pins the agent profile to 100%, but if a page was zoomed manually, reset it.
|
|
131
|
+
- **Duplicate drag events under heavy load**: `driver/pointer.ts` `finishDragProbe` waits a fixed 50 ms before re-synthesising a drag, so a trusted `mouseup` that lands later can be delivered twice. Retry when the machine is quieter.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Task spaces — ownership, handoff, and completion policy
|
|
2
|
+
|
|
3
|
+
The full contract behind the summary in `SKILL.md`. Read this before any
|
|
4
|
+
claim / handoff / takeover / complete edge case.
|
|
5
|
+
|
|
6
|
+
## Naming and reuse
|
|
7
|
+
|
|
8
|
+
`nameOrId` can be a task space name, numeric id, or digit-only numeric id
|
|
9
|
+
string. String values match `name`/`taskId` first, then digit-only strings fall
|
|
10
|
+
back to numeric id. Number values match existing numeric ids only; if no
|
|
11
|
+
matching id exists, `taskSpaces.useOrCreate` fails instead of creating a new
|
|
12
|
+
space.
|
|
13
|
+
|
|
14
|
+
Use a short name for the active user goal when creating a new task space. Keep
|
|
15
|
+
reusing that task space for follow-up questions, corrections, refinements,
|
|
16
|
+
re-checks, and result validation, even if you previously thought the task was
|
|
17
|
+
complete. Choose a new task space only when the user clearly starts a separate,
|
|
18
|
+
unrelated goal. Prefer using the numeric `id` returned by
|
|
19
|
+
`taskSpaces.useOrCreate` (for example, `task.id`) to resume a known task in
|
|
20
|
+
later rounds and avoid name collisions.
|
|
21
|
+
|
|
22
|
+
For any follow-up on the same user goal — including continue, corrections,
|
|
23
|
+
retries, validation, user-reported problems, or work after
|
|
24
|
+
`taskSpaces.complete(..., { keep: true })` — resume the original task space
|
|
25
|
+
first if it still exists. Do not create a new task space for the same goal
|
|
26
|
+
unless the user asks for a fresh space, starts an unrelated goal, or the
|
|
27
|
+
original space is unavailable after checking. If a new space is necessary,
|
|
28
|
+
state why.
|
|
29
|
+
|
|
30
|
+
After explicit user confirmation, to continue work from an existing user-owned,
|
|
31
|
+
inactive, or unassigned task space, use `await taskSpaces.list()` to find the
|
|
32
|
+
space, call `await taskSpaces.claim(id)` to take ownership and select it, then
|
|
33
|
+
use `await browser.listTabs()` and `await browser.switchTab(targetId)` to
|
|
34
|
+
select the exact tab before acting.
|
|
35
|
+
|
|
36
|
+
## Ownership policy
|
|
37
|
+
|
|
38
|
+
Every task space has `ownership: 'agent' | 'agentDelegatedToUser' | 'user'`;
|
|
39
|
+
the facades treat user-owned spaces differently:
|
|
40
|
+
|
|
41
|
+
| Call | When the target space is user-owned |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `taskSpaces.switch` | throws — agent-owned spaces only |
|
|
44
|
+
| `taskSpaces.claim` | claims it (ownership transfers to the agent), then selects it |
|
|
45
|
+
| `taskSpaces.handOff` | skipped — resolves `{ done: false, skipped: 'user-owned' }` |
|
|
46
|
+
| `taskSpaces.complete(…, { keep: true })` | skipped — resolves `{ done: false, skipped: 'user-owned' }` |
|
|
47
|
+
| `taskSpaces.complete(…, { keep: false })` | claims it, then closes it |
|
|
48
|
+
| `taskSpaces.takeOver` / `waitForAgentControl` | no ownership check |
|
|
49
|
+
|
|
50
|
+
`taskSpaces.handOff` and `taskSpaces.complete` resolve `{ done: true }` when
|
|
51
|
+
the operation actually happened. Check `done` before telling the user the
|
|
52
|
+
handoff/cleanup is finished — a `skipped` result usually means you targeted a
|
|
53
|
+
space that was never yours.
|
|
54
|
+
|
|
55
|
+
## Completion and cleanup
|
|
56
|
+
|
|
57
|
+
**`taskSpaces.complete(nameOrId, { keep })` must occupy its own dedicated final
|
|
58
|
+
heredoc, and run only after a prior heredoc's output has confirmed the task is
|
|
59
|
+
genuinely done.** `keep` is required and defaults by policy to `false`: close
|
|
60
|
+
the task space after completion unless there is a concrete reason to leave the
|
|
61
|
+
live page visible.
|
|
62
|
+
|
|
63
|
+
Use `{ keep: true }` only when the user explicitly asks to keep the page open,
|
|
64
|
+
the task needs manual user action in that exact page, or the result cannot be
|
|
65
|
+
delivered well as a URL, file, artifact, or summary. Do not keep a task space
|
|
66
|
+
open merely because a page was visited, a document was created, or a screenshot
|
|
67
|
+
was used for verification.
|
|
68
|
+
|
|
69
|
+
When passing a string that may create a new task space, the string should
|
|
70
|
+
reflect the task's intent (e.g. `'search github issues'`); don't use literal
|
|
71
|
+
placeholders.
|
|
72
|
+
|
|
73
|
+
**If the task space needs to be preserved after the task ends, keep only the
|
|
74
|
+
tabs that need to be shown to the user.** Keep loose awareness of how many tabs
|
|
75
|
+
are open — a quick `(await browser.listTabs()).length` is enough; there's no
|
|
76
|
+
need to spend a dedicated round just to check. When scratch tabs (search-result
|
|
77
|
+
pages, cross-check pages, and other one-off pages) pile up, close them as you
|
|
78
|
+
go rather than letting them all accumulate for the end. When finishing with
|
|
79
|
+
`{ keep: true }` to leave pages for the user, clear out the remaining scratch
|
|
80
|
+
tabs so only the pages worth showing stay open. Close a single tab with
|
|
81
|
+
`await browser.closeTab(targetId)` (`targetId` comes from `browser.listTabs()`
|
|
82
|
+
or an `openOrReuseTab` return value).
|
|
83
|
+
|
|
84
|
+
## Control handoff
|
|
85
|
+
|
|
86
|
+
Only one side — agent or user — holds control of a task space at any time.
|
|
87
|
+
While the user holds control, any browser operation by the agent fails with a
|
|
88
|
+
"user is controlling" message — do not retry it; follow the steps below to
|
|
89
|
+
resume.
|
|
90
|
+
|
|
91
|
+
A "user is controlling" error is a hard stop on the whole task — not an
|
|
92
|
+
obstacle to route around. It means the user has deliberately taken the browser
|
|
93
|
+
back, often because your current approach is going wrong. Honoring it *is* the
|
|
94
|
+
correct outcome here; pushing the goal forward anyway is the failure. The only
|
|
95
|
+
thing you may do is **ask the user and wait**.
|
|
96
|
+
|
|
97
|
+
An "inactive", "not assigned to an agent", or similar task-space error is also
|
|
98
|
+
a hard stop with the same confirmation requirement. Resume only after explicit
|
|
99
|
+
user confirmation, then start with `await taskSpaces.claim(id)`.
|
|
100
|
+
|
|
101
|
+
**Handing off**: When the task requires user intervention (e.g. login, captcha,
|
|
102
|
+
manual confirmation), call `await taskSpaces.handOff(nameOrId)` to give control
|
|
103
|
+
to the user, and tell them exactly what to do. Omitting `nameOrId` uses the
|
|
104
|
+
currently selected task space; pass `task.id` across heredoc rounds to avoid
|
|
105
|
+
ambiguity.
|
|
106
|
+
|
|
107
|
+
**Regaining control**: Take control back *only* after the user explicitly
|
|
108
|
+
confirms — through an Ask (your harness's button/option prompt, e.g. "Continue"
|
|
109
|
+
vs "Finish task") or a "continue" message in chat. Then start a new heredoc
|
|
110
|
+
with `await taskSpaces.takeOver(nameOrId)` and resume; if the user chooses to
|
|
111
|
+
finish, close out with `await taskSpaces.complete(nameOrId, { keep })`. Never
|
|
112
|
+
call `taskSpaces.takeOver` on your own to grab control back — it has no
|
|
113
|
+
ownership check and will seize the browser away from the user.
|
|
114
|
+
|
|
115
|
+
**Unexpected takeover**: The user can take over at any time via the browser GUI
|
|
116
|
+
— the same effect as the agent calling `taskSpaces.handOff`. Do not retry the
|
|
117
|
+
failed operation and do not auto-takeover; surface the Ask above (Continue /
|
|
118
|
+
Finish) and resume only when the user picks Continue.
|
|
119
|
+
|
|
120
|
+
`await taskSpaces.waitForAgentControl(nameOrId)` is a read-only blocking poll
|
|
121
|
+
(it never takes control); use it only to wait inside the current heredoc for a
|
|
122
|
+
handoff you initiated.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Video recording
|
|
2
|
+
|
|
3
|
+
Record the current page viewport with Playwright-style `page.screencast`. Start and stop the recording in the same Bash invocation so FFmpeg can finalize the silent VP8 WebM file.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
await page.screencast.start({
|
|
7
|
+
path: "/absolute/path/browser-run.webm",
|
|
8
|
+
size: { width: 1280, height: 720 },
|
|
9
|
+
quality: 90,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Perform and verify browser actions here.
|
|
13
|
+
|
|
14
|
+
await page.screencast.stop();
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The path must end in `.webm`; relative paths resolve from the CLI working directory, and missing parent directories are created. `quality` is an integer from 0 to 100. Dimensions are rounded down to even values for VP8. When `size` is omitted, the viewport is scaled down to fit within 800×800. Frames are scaled and letterboxed into the selected bounds if the viewport size changes during recording. The finalized file replaces the destination only after FFmpeg succeeds. Recording captures the page viewport without audio or browser chrome. Install `ffmpeg` on `PATH` or set `EGO_BROWSER_FFMPEG_PATH` to its executable.
|