barebrowse 0.11.0 → 0.13.0
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/CHANGELOG.md +78 -0
- package/README.md +9 -4
- package/barebrowse.context.md +34 -5
- package/cli.js +3 -0
- package/mcp-server.js +35 -7
- package/package.json +35 -5
- package/src/auth.js +7 -4
- package/src/bareagent.js +26 -5
- package/src/cdp.js +15 -4
- package/src/chromium.js +7 -2
- package/src/daemon.js +37 -4
- package/src/index.js +28 -1
- package/src/network-idle.js +4 -1
- package/src/prune.js +1 -1
- package/src/readable.js +116 -0
- package/src/session-client.js +1 -1
- package/src/wearehere.d.ts +6 -0
- package/types/aria.d.ts +17 -0
- package/types/auth.d.ts +35 -0
- package/types/bareagent.d.ts +25 -0
- package/types/blocklist.d.ts +21 -0
- package/types/cdp.d.ts +6 -0
- package/types/chromium.d.ts +58 -0
- package/types/consent.d.ts +9 -0
- package/types/daemon.d.ts +10 -0
- package/types/index.d.ts +138 -0
- package/types/interact.d.ts +79 -0
- package/types/network-idle.d.ts +19 -0
- package/types/prune.d.ts +13 -0
- package/types/readable.d.ts +18 -0
- package/types/session-client.d.ts +19 -0
- package/types/stealth.d.ts +14 -0
- package/types/url-guard.d.ts +26 -0
- package/.github/workflows/publish.yml +0 -26
- package/commands/barebrowse/SKILL.md +0 -137
- package/commands/barebrowse.md +0 -136
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Click an element by its backendDOMNodeId.
|
|
3
|
+
* Scrolls into view, resolves coordinates, then dispatches mousePressed + mouseReleased.
|
|
4
|
+
*
|
|
5
|
+
* @param {object} session - Session-scoped CDP handle
|
|
6
|
+
* @param {number} backendNodeId - Backend DOM node ID
|
|
7
|
+
*/
|
|
8
|
+
export function click(session: object, backendNodeId: number): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Type text into an element by its backendDOMNodeId.
|
|
11
|
+
* Default: DOM.focus + Input.insertText (fast, no key events).
|
|
12
|
+
* With { keyEvents: true }: dispatches keyDown/keyUp per character (triggers handlers).
|
|
13
|
+
* With { clear: true }: selects all existing text and deletes it before typing.
|
|
14
|
+
*
|
|
15
|
+
* @param {object} session - Session-scoped CDP handle
|
|
16
|
+
* @param {number} backendNodeId - Backend DOM node ID
|
|
17
|
+
* @param {string} text - Text to type
|
|
18
|
+
* @param {object} [opts]
|
|
19
|
+
* @param {boolean} [opts.keyEvents=false] - Use char-by-char key events
|
|
20
|
+
* @param {boolean} [opts.clear=false] - Clear existing content before typing
|
|
21
|
+
*/
|
|
22
|
+
export function type(session: object, backendNodeId: number, text: string, opts?: {
|
|
23
|
+
keyEvents?: boolean | undefined;
|
|
24
|
+
clear?: boolean | undefined;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Press a special key (Enter, Tab, Escape, etc.).
|
|
28
|
+
* Dispatches keyDown + keyUp for the named key.
|
|
29
|
+
*
|
|
30
|
+
* @param {object} session - Session-scoped CDP handle
|
|
31
|
+
* @param {string} key - Key name (e.g. 'Enter', 'Tab', 'Escape', 'ArrowDown')
|
|
32
|
+
*/
|
|
33
|
+
export function press(session: object, key: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Scroll the page via mouseWheel event.
|
|
36
|
+
* Dispatches at viewport center by default, or at given coordinates.
|
|
37
|
+
*
|
|
38
|
+
* @param {object} session - Session-scoped CDP handle
|
|
39
|
+
* @param {number} deltaY - Pixels to scroll (positive = down, negative = up)
|
|
40
|
+
* @param {number} [x=400] - X coordinate for scroll event
|
|
41
|
+
* @param {number} [y=300] - Y coordinate for scroll event
|
|
42
|
+
*/
|
|
43
|
+
export function scroll(session: object, deltaY: number, x?: number, y?: number): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Hover over an element by its backendDOMNodeId.
|
|
46
|
+
* Scrolls into view, then dispatches mouseMoved at center.
|
|
47
|
+
*
|
|
48
|
+
* @param {object} session - Session-scoped CDP handle
|
|
49
|
+
* @param {number} backendNodeId - Backend DOM node ID
|
|
50
|
+
*/
|
|
51
|
+
export function hover(session: object, backendNodeId: number): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Select a value in a <select> element or custom dropdown.
|
|
54
|
+
*
|
|
55
|
+
* Strategy 1: Native <select> — set .value + dispatch 'change' event.
|
|
56
|
+
* Strategy 2: Custom dropdown — click to open, find matching option, click it.
|
|
57
|
+
*
|
|
58
|
+
* @param {object} session - Session-scoped CDP handle
|
|
59
|
+
* @param {number} backendNodeId - Backend DOM node ID of the select/combobox
|
|
60
|
+
* @param {string} value - Value or visible text to select
|
|
61
|
+
*/
|
|
62
|
+
export function select(session: object, backendNodeId: number, value: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Drag one element to another.
|
|
65
|
+
* Scrolls source into view, mouse down, move to target center, mouse up.
|
|
66
|
+
*
|
|
67
|
+
* @param {object} session - Session-scoped CDP handle
|
|
68
|
+
* @param {number} fromNodeId - Source element backendDOMNodeId
|
|
69
|
+
* @param {number} toNodeId - Target element backendDOMNodeId
|
|
70
|
+
*/
|
|
71
|
+
export function drag(session: object, fromNodeId: number, toNodeId: number): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Upload files to a file input element.
|
|
74
|
+
*
|
|
75
|
+
* @param {object} session - Session-scoped CDP handle
|
|
76
|
+
* @param {number} backendNodeId - Backend DOM node ID of the file input
|
|
77
|
+
* @param {string[]} files - Absolute paths to files to upload
|
|
78
|
+
*/
|
|
79
|
+
export function upload(session: object, backendNodeId: number, files: string[]): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* network-idle.js — wait until the page's network has been idle for N ms.
|
|
3
|
+
*
|
|
4
|
+
* Tracks in-flight requests by requestId in a Set, so an orphan
|
|
5
|
+
* loadingFinished/Failed (event for a request whose requestWillBeSent
|
|
6
|
+
* arrived before our listener attached) is a harmless no-op instead of
|
|
7
|
+
* driving a counter negative and resolving prematurely.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @param {object} session - CDP session-scoped handle with .on() returning unsub
|
|
11
|
+
* @param {object} [opts]
|
|
12
|
+
* @param {number} [opts.timeout=30000] - Max wait time before reject
|
|
13
|
+
* @param {number} [opts.idle=500] - Required idle duration before resolve
|
|
14
|
+
* @returns {Promise<void>}
|
|
15
|
+
*/
|
|
16
|
+
export function waitForNetworkIdle(session: object, opts?: {
|
|
17
|
+
timeout?: number | undefined;
|
|
18
|
+
idle?: number | undefined;
|
|
19
|
+
}): Promise<void>;
|
package/types/prune.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prune an ARIA tree for agent consumption.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} tree - Root node from buildTree() (CDP format)
|
|
5
|
+
* @param {object} [options]
|
|
6
|
+
* @param {'act'|'browse'|'navigate'|'full'|'read'} [options.mode='act'] - Pruning mode ('read' is an alias for 'browse')
|
|
7
|
+
* @param {string} [options.context=''] - Search context for relevance filtering
|
|
8
|
+
* @returns {object|null} Pruned tree
|
|
9
|
+
*/
|
|
10
|
+
export function prune(tree: object, options?: {
|
|
11
|
+
mode?: "act" | "browse" | "navigate" | "full" | "read" | undefined;
|
|
12
|
+
context?: string | undefined;
|
|
13
|
+
}): object | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render a readable() result as a text block: a short header (title / byline /
|
|
3
|
+
* confidence, with the fall-back hint inline when present) then the body. On a
|
|
4
|
+
* failed extraction it returns the hint. Shared by the MCP, bareagent, and
|
|
5
|
+
* CLI/daemon surfaces so their output can't drift apart.
|
|
6
|
+
* @param {object} r - a readable() result.
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export function formatReadable(r: object): string;
|
|
10
|
+
/**
|
|
11
|
+
* Extract the main article from the current page.
|
|
12
|
+
* @param {object} session - CDP session-scoped handle (.send()).
|
|
13
|
+
* @returns {Promise<object>} One of:
|
|
14
|
+
* { ok: false, hint } — no article content found
|
|
15
|
+
* { ok: true, title, byline, text, length,
|
|
16
|
+
* confidence: 'high'|'low', readerable, hint? } — extracted article
|
|
17
|
+
*/
|
|
18
|
+
export function readable(session: object): Promise<object>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read session.json from the output directory.
|
|
3
|
+
* @returns {{ port: number, pid: number, token?: string, startedAt: string } | null}
|
|
4
|
+
*/
|
|
5
|
+
export function readSession(outputDir: any): {
|
|
6
|
+
port: number;
|
|
7
|
+
pid: number;
|
|
8
|
+
token?: string;
|
|
9
|
+
startedAt: string;
|
|
10
|
+
} | null;
|
|
11
|
+
/**
|
|
12
|
+
* Check if the daemon is alive by hitting GET /status.
|
|
13
|
+
*/
|
|
14
|
+
export function isAlive(outputDir: any): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Send a command to the running daemon.
|
|
17
|
+
* @returns {Promise<object>} The daemon's response
|
|
18
|
+
*/
|
|
19
|
+
export function sendCommand(command: any, args: any, outputDir: any): Promise<object>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply stealth patches to a CDP session.
|
|
3
|
+
* Must be called before any navigation.
|
|
4
|
+
*
|
|
5
|
+
* Splits into two layers:
|
|
6
|
+
* 1. Network.setUserAgentOverride strips "HeadlessChrome" from the UA
|
|
7
|
+
* that ships in HTTP request headers AND that navigator.userAgent
|
|
8
|
+
* reports — `--headless=new` leaves "HeadlessChrome" in there.
|
|
9
|
+
* 2. Page.addScriptToEvaluateOnNewDocument injects the JS-level patches
|
|
10
|
+
* before any page script runs.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} session - Session-scoped CDP handle
|
|
13
|
+
*/
|
|
14
|
+
export function applyStealth(session: object): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throw if `url` is unsafe to navigate to under the given policy.
|
|
3
|
+
* @param {string} url
|
|
4
|
+
* @param {object} [opts]
|
|
5
|
+
* @param {boolean} [opts.allowLocalUrls=false] - permit file:/chrome:/etc.
|
|
6
|
+
* @param {boolean} [opts.blockPrivateNetwork=false] - reject loopback/RFC-1918/metadata.
|
|
7
|
+
*/
|
|
8
|
+
export function assertNavigable(url: string, opts?: {
|
|
9
|
+
allowLocalUrls?: boolean | undefined;
|
|
10
|
+
blockPrivateNetwork?: boolean | undefined;
|
|
11
|
+
}): void;
|
|
12
|
+
/**
|
|
13
|
+
* Throw if any file in `files` resolves outside `uploadDir`. Both the base
|
|
14
|
+
* dir and each file are resolved through realpath, so symlinks (in either the
|
|
15
|
+
* base path — e.g. macOS /tmp → /private/tmp — or the file) can't be used to
|
|
16
|
+
* escape the sandbox or to false-reject a legitimate file.
|
|
17
|
+
* No-op when `uploadDir` is falsy (no restriction configured).
|
|
18
|
+
* @param {string|string[]} files
|
|
19
|
+
* @param {string|null} uploadDir
|
|
20
|
+
*/
|
|
21
|
+
export function assertUploadAllowed(files: string | string[], uploadDir: string | null): void;
|
|
22
|
+
/**
|
|
23
|
+
* @param {string} host - hostname (no brackets for IPv6)
|
|
24
|
+
* @returns {boolean} true if it names a private/loopback/link-local/internal host
|
|
25
|
+
*/
|
|
26
|
+
export function isPrivateHost(host: string): boolean;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: Publish to npm
|
|
2
|
-
|
|
3
|
-
# Trusted publishing via OIDC — no NPM_TOKEN needed.
|
|
4
|
-
# Configure the trusted publisher at npmjs.com first (see repo notes).
|
|
5
|
-
on:
|
|
6
|
-
workflow_dispatch: # manual "Run workflow" button
|
|
7
|
-
release:
|
|
8
|
-
types: [published] # also publishes when you cut a GitHub release
|
|
9
|
-
|
|
10
|
-
permissions:
|
|
11
|
-
contents: read
|
|
12
|
-
id-token: write # required: lets npm mint OIDC credentials
|
|
13
|
-
|
|
14
|
-
jobs:
|
|
15
|
-
publish:
|
|
16
|
-
runs-on: ubuntu-latest
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: actions/setup-node@v4
|
|
20
|
-
with:
|
|
21
|
-
node-version: 22
|
|
22
|
-
registry-url: 'https://registry.npmjs.org'
|
|
23
|
-
- name: Upgrade npm (trusted publishing needs >= 11.5.1)
|
|
24
|
-
run: npm install -g npm@latest
|
|
25
|
-
- name: Publish
|
|
26
|
-
run: npm publish
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: barebrowse
|
|
3
|
-
description: Browser automation using the user's real browser with real cookies. Handles consent walls, login sessions, and bot detection automatically.
|
|
4
|
-
allowed-tools: Bash(barebrowse:*)
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# barebrowse CLI — Browser Automation for Agents
|
|
8
|
-
|
|
9
|
-
Browse any URL using the user's real browser with real cookies. Returns pruned ARIA snapshots (40-90% smaller than raw) with `[ref=N]` markers for interaction. Handles cookie consent, login sessions, JS dialogs, and bot detection automatically.
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
barebrowse open https://example.com # Start session + navigate
|
|
15
|
-
barebrowse snapshot # Get ARIA snapshot → .barebrowse/page-*.yml
|
|
16
|
-
barebrowse click 8 # Click element with ref=8
|
|
17
|
-
barebrowse snapshot # See result
|
|
18
|
-
barebrowse close # End session
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
All output files go to `.barebrowse/` in the current directory. Read them with the Read tool when needed.
|
|
22
|
-
|
|
23
|
-
## Commands
|
|
24
|
-
|
|
25
|
-
### Session Lifecycle
|
|
26
|
-
|
|
27
|
-
| Command | Description |
|
|
28
|
-
|---------|-------------|
|
|
29
|
-
| `barebrowse open [url] [flags]` | Start browser session. Optionally navigate to URL. |
|
|
30
|
-
| `barebrowse close` | Close session and kill browser. |
|
|
31
|
-
| `barebrowse status` | Check if session is running. |
|
|
32
|
-
|
|
33
|
-
**Open flags:**
|
|
34
|
-
- `--mode=headless|headed|hybrid` — Browser mode (default: headless)
|
|
35
|
-
- `--no-cookies` — Skip cookie injection
|
|
36
|
-
- `--browser=firefox|chromium` — Cookie source
|
|
37
|
-
- `--prune-mode=act|read` — Default pruning mode
|
|
38
|
-
- `--timeout=N` — Navigation timeout in ms
|
|
39
|
-
- `--proxy=URL` — HTTP/SOCKS proxy server
|
|
40
|
-
- `--viewport=WxH` — Viewport size (e.g. 1280x720)
|
|
41
|
-
- `--storage-state=FILE` — Load cookies/localStorage from JSON file
|
|
42
|
-
- `--block-private-network` — SSRF guard: refuse loopback / RFC-1918 / link-local / cloud-metadata hosts (v0.11.0)
|
|
43
|
-
- `--upload-dir=DIR` — Sandbox uploads to DIR; reject files outside it (v0.11.0)
|
|
44
|
-
|
|
45
|
-
> Security (v0.11.0): `file:`/`chrome:`/etc. navigation is blocked by default, and the daemon requires a per-session token (handled transparently by the CLI). Snapshots and saved state are written owner-only (`0600`).
|
|
46
|
-
|
|
47
|
-
### Navigation
|
|
48
|
-
|
|
49
|
-
| Command | Output |
|
|
50
|
-
|---------|--------|
|
|
51
|
-
| `barebrowse goto <url>` | Navigates, waits for load, dismisses consent. Prints "ok". |
|
|
52
|
-
| `barebrowse back` | Go back in browser history. |
|
|
53
|
-
| `barebrowse forward` | Go forward in browser history. |
|
|
54
|
-
| `barebrowse snapshot` | ARIA snapshot → `.barebrowse/page-<timestamp>.yml` |
|
|
55
|
-
| `barebrowse snapshot --mode=read` | Read mode: keeps all text (for content extraction) |
|
|
56
|
-
| `barebrowse screenshot` | Screenshot → `.barebrowse/screenshot-<timestamp>.png` |
|
|
57
|
-
| `barebrowse pdf [--landscape]` | PDF export → `.barebrowse/page-<timestamp>.pdf` |
|
|
58
|
-
|
|
59
|
-
### Interaction
|
|
60
|
-
|
|
61
|
-
| Command | Description |
|
|
62
|
-
|---------|-------------|
|
|
63
|
-
| `barebrowse click <ref>` | Click element (scrolls into view first) |
|
|
64
|
-
| `barebrowse type <ref> <text>` | Type text into element |
|
|
65
|
-
| `barebrowse fill <ref> <text>` | Clear existing content + type new text |
|
|
66
|
-
| `barebrowse press <key>` | Press key: Enter, Tab, Escape, Backspace, Delete, arrows, Space |
|
|
67
|
-
| `barebrowse scroll <deltaY>` | Scroll page (positive=down, negative=up) |
|
|
68
|
-
| `barebrowse hover <ref>` | Hover over element (triggers tooltips) |
|
|
69
|
-
| `barebrowse select <ref> <value>` | Select dropdown option |
|
|
70
|
-
| `barebrowse drag <fromRef> <toRef>` | Drag element to another element |
|
|
71
|
-
| `barebrowse upload <ref> <files..>` | Upload file(s) to a file input element |
|
|
72
|
-
|
|
73
|
-
### Tabs
|
|
74
|
-
|
|
75
|
-
| Command | Description |
|
|
76
|
-
|---------|-------------|
|
|
77
|
-
| `barebrowse tabs` | List open tabs (index, url, title) |
|
|
78
|
-
| `barebrowse tab <index>` | Switch to tab by index |
|
|
79
|
-
|
|
80
|
-
### Debugging
|
|
81
|
-
|
|
82
|
-
| Command | Output |
|
|
83
|
-
|---------|--------|
|
|
84
|
-
| `barebrowse eval <expression>` | Evaluate JS in page, print result |
|
|
85
|
-
| `barebrowse wait-idle` | Wait for network idle (no requests for 500ms) |
|
|
86
|
-
| `barebrowse wait-for [opts]` | Wait for content to appear on page |
|
|
87
|
-
| `barebrowse console-logs` | Console logs → `.barebrowse/console-<timestamp>.json` |
|
|
88
|
-
| `barebrowse network-log` | Network log → `.barebrowse/network-<timestamp>.json` |
|
|
89
|
-
| `barebrowse network-log --failed` | Only failed/4xx/5xx requests |
|
|
90
|
-
| `barebrowse dialog-log` | JS dialog log → `.barebrowse/dialogs-<timestamp>.json` |
|
|
91
|
-
| `barebrowse save-state` | Cookies + localStorage → `.barebrowse/state-<timestamp>.json` |
|
|
92
|
-
|
|
93
|
-
**wait-for flags:**
|
|
94
|
-
- `--text=STRING` — Wait for text to appear in page body
|
|
95
|
-
- `--selector=CSS` — Wait for CSS selector to match
|
|
96
|
-
- `--timeout=N` — Max wait time in ms (default: 30000)
|
|
97
|
-
|
|
98
|
-
## Snapshot Format
|
|
99
|
-
|
|
100
|
-
The snapshot is a YAML-like ARIA tree. Each line is one node:
|
|
101
|
-
|
|
102
|
-
```
|
|
103
|
-
# https://example.com/
|
|
104
|
-
# 379 chars → 45 chars (88% pruned)
|
|
105
|
-
- heading "Example Domain" [level=1] [ref=3]
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
- `[ref=N]` — Use this number with click, type, fill, hover, select, drag, upload
|
|
109
|
-
- Refs change on every snapshot — always take a fresh snapshot before interacting
|
|
110
|
-
- **act mode** (default): interactive elements + labels — for clicking, typing, navigating
|
|
111
|
-
- **read mode**: all text content — for reading articles, extracting data
|
|
112
|
-
|
|
113
|
-
## Workflow Pattern
|
|
114
|
-
|
|
115
|
-
1. `barebrowse open <url>` — start session
|
|
116
|
-
2. `barebrowse snapshot` — observe page (read the .yml file)
|
|
117
|
-
3. Decide action based on snapshot content
|
|
118
|
-
4. `barebrowse click/type/fill/press/scroll/drag/upload <ref>` — act
|
|
119
|
-
5. `barebrowse snapshot` — observe result (refs are now different!)
|
|
120
|
-
6. Repeat 3-5 until goal achieved
|
|
121
|
-
7. `barebrowse close` — clean up
|
|
122
|
-
|
|
123
|
-
## Tips
|
|
124
|
-
|
|
125
|
-
- **Always snapshot before interacting** — refs are ephemeral and change every time
|
|
126
|
-
- **Use `fill` instead of `type`** when replacing existing text in input fields
|
|
127
|
-
- **Use `--mode=read`** for snapshot when you need to extract article content or data
|
|
128
|
-
- **Use `back`/`forward`** to navigate browser history instead of re-entering URLs
|
|
129
|
-
- **Use `upload`** for file inputs — pass absolute paths to the files
|
|
130
|
-
- **Use `wait-for`** when content loads asynchronously — more reliable than `wait-idle`
|
|
131
|
-
- **Check `dialog-log`** if JS alerts/confirms were auto-dismissed during your session
|
|
132
|
-
- **Use `save-state`** to persist cookies/localStorage for later sessions via `--storage-state`
|
|
133
|
-
- **Check `console-logs`** when page behavior seems wrong — JS errors show up there
|
|
134
|
-
- **Check `network-log --failed`** to debug missing content or broken API calls
|
|
135
|
-
- **Use `eval`** as an escape hatch when ARIA tree doesn't show what you need
|
|
136
|
-
- **One session per project** — `.barebrowse/` is project-scoped
|
|
137
|
-
- For bot-detected sites, use `--mode=headed` (requires browser with `--remote-debugging-port=9222`)
|
package/commands/barebrowse.md
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: barebrowse
|
|
3
|
-
description: Browser automation using the user's real browser with real cookies. Handles consent walls, login sessions, and bot detection automatically.
|
|
4
|
-
allowed-tools: Bash(barebrowse:*)
|
|
5
|
-
---
|
|
6
|
-
# barebrowse CLI — Browser Automation for Agents
|
|
7
|
-
|
|
8
|
-
Browse any URL using the user's real browser with real cookies. Returns pruned ARIA snapshots (40-90% smaller than raw) with `[ref=N]` markers for interaction. Handles cookie consent, login sessions, JS dialogs, and bot detection automatically.
|
|
9
|
-
|
|
10
|
-
## Quick Start
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
barebrowse open https://example.com # Start session + navigate
|
|
14
|
-
barebrowse snapshot # Get ARIA snapshot → .barebrowse/page-*.yml
|
|
15
|
-
barebrowse click 8 # Click element with ref=8
|
|
16
|
-
barebrowse snapshot # See result
|
|
17
|
-
barebrowse close # End session
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
All output files go to `.barebrowse/` in the current directory. Read them with the Read tool when needed.
|
|
21
|
-
|
|
22
|
-
## Commands
|
|
23
|
-
|
|
24
|
-
### Session Lifecycle
|
|
25
|
-
|
|
26
|
-
| Command | Description |
|
|
27
|
-
|---------|-------------|
|
|
28
|
-
| `barebrowse open [url] [flags]` | Start browser session. Optionally navigate to URL. |
|
|
29
|
-
| `barebrowse close` | Close session and kill browser. |
|
|
30
|
-
| `barebrowse status` | Check if session is running. |
|
|
31
|
-
|
|
32
|
-
**Open flags:**
|
|
33
|
-
- `--mode=headless|headed|hybrid` — Browser mode (default: headless)
|
|
34
|
-
- `--no-cookies` — Skip cookie injection
|
|
35
|
-
- `--browser=firefox|chromium` — Cookie source
|
|
36
|
-
- `--prune-mode=act|read` — Default pruning mode
|
|
37
|
-
- `--timeout=N` — Navigation timeout in ms
|
|
38
|
-
- `--proxy=URL` — HTTP/SOCKS proxy server
|
|
39
|
-
- `--viewport=WxH` — Viewport size (e.g. 1280x720)
|
|
40
|
-
- `--storage-state=FILE` — Load cookies/localStorage from JSON file
|
|
41
|
-
- `--block-private-network` — SSRF guard: refuse loopback / RFC-1918 / link-local / cloud-metadata hosts (v0.11.0)
|
|
42
|
-
- `--upload-dir=DIR` — Sandbox uploads to DIR; reject files outside it (v0.11.0)
|
|
43
|
-
|
|
44
|
-
> Security (v0.11.0): `file:`/`chrome:`/etc. navigation is blocked by default, and the daemon requires a per-session token (handled transparently by the CLI). Snapshots and saved state are written owner-only (`0600`).
|
|
45
|
-
|
|
46
|
-
### Navigation
|
|
47
|
-
|
|
48
|
-
| Command | Output |
|
|
49
|
-
|---------|--------|
|
|
50
|
-
| `barebrowse goto <url>` | Navigates, waits for load, dismisses consent. Prints "ok". |
|
|
51
|
-
| `barebrowse back` | Go back in browser history. |
|
|
52
|
-
| `barebrowse forward` | Go forward in browser history. |
|
|
53
|
-
| `barebrowse snapshot` | ARIA snapshot → `.barebrowse/page-<timestamp>.yml` |
|
|
54
|
-
| `barebrowse snapshot --mode=read` | Read mode: keeps all text (for content extraction) |
|
|
55
|
-
| `barebrowse screenshot` | Screenshot → `.barebrowse/screenshot-<timestamp>.png` |
|
|
56
|
-
| `barebrowse pdf [--landscape]` | PDF export → `.barebrowse/page-<timestamp>.pdf` |
|
|
57
|
-
|
|
58
|
-
### Interaction
|
|
59
|
-
|
|
60
|
-
| Command | Description |
|
|
61
|
-
|---------|-------------|
|
|
62
|
-
| `barebrowse click <ref>` | Click element (scrolls into view first) |
|
|
63
|
-
| `barebrowse type <ref> <text>` | Type text into element |
|
|
64
|
-
| `barebrowse fill <ref> <text>` | Clear existing content + type new text |
|
|
65
|
-
| `barebrowse press <key>` | Press key: Enter, Tab, Escape, Backspace, Delete, arrows, Space |
|
|
66
|
-
| `barebrowse scroll <deltaY>` | Scroll page (positive=down, negative=up) |
|
|
67
|
-
| `barebrowse hover <ref>` | Hover over element (triggers tooltips) |
|
|
68
|
-
| `barebrowse select <ref> <value>` | Select dropdown option |
|
|
69
|
-
| `barebrowse drag <fromRef> <toRef>` | Drag element to another element |
|
|
70
|
-
| `barebrowse upload <ref> <files..>` | Upload file(s) to a file input element |
|
|
71
|
-
|
|
72
|
-
### Tabs
|
|
73
|
-
|
|
74
|
-
| Command | Description |
|
|
75
|
-
|---------|-------------|
|
|
76
|
-
| `barebrowse tabs` | List open tabs (index, url, title) |
|
|
77
|
-
| `barebrowse tab <index>` | Switch to tab by index |
|
|
78
|
-
|
|
79
|
-
### Debugging
|
|
80
|
-
|
|
81
|
-
| Command | Output |
|
|
82
|
-
|---------|--------|
|
|
83
|
-
| `barebrowse eval <expression>` | Evaluate JS in page, print result |
|
|
84
|
-
| `barebrowse wait-idle` | Wait for network idle (no requests for 500ms) |
|
|
85
|
-
| `barebrowse wait-for [opts]` | Wait for content to appear on page |
|
|
86
|
-
| `barebrowse console-logs` | Console logs → `.barebrowse/console-<timestamp>.json` |
|
|
87
|
-
| `barebrowse network-log` | Network log → `.barebrowse/network-<timestamp>.json` |
|
|
88
|
-
| `barebrowse network-log --failed` | Only failed/4xx/5xx requests |
|
|
89
|
-
| `barebrowse dialog-log` | JS dialog log → `.barebrowse/dialogs-<timestamp>.json` |
|
|
90
|
-
| `barebrowse save-state` | Cookies + localStorage → `.barebrowse/state-<timestamp>.json` |
|
|
91
|
-
|
|
92
|
-
**wait-for flags:**
|
|
93
|
-
- `--text=STRING` — Wait for text to appear in page body
|
|
94
|
-
- `--selector=CSS` — Wait for CSS selector to match
|
|
95
|
-
- `--timeout=N` — Max wait time in ms (default: 30000)
|
|
96
|
-
|
|
97
|
-
## Snapshot Format
|
|
98
|
-
|
|
99
|
-
The snapshot is a YAML-like ARIA tree. Each line is one node:
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
# https://example.com/
|
|
103
|
-
# 379 chars → 45 chars (88% pruned)
|
|
104
|
-
- heading "Example Domain" [level=1] [ref=3]
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
- `[ref=N]` — Use this number with click, type, fill, hover, select, drag, upload
|
|
108
|
-
- Refs change on every snapshot — always take a fresh snapshot before interacting
|
|
109
|
-
- **act mode** (default): interactive elements + labels — for clicking, typing, navigating
|
|
110
|
-
- **read mode**: all text content — for reading articles, extracting data
|
|
111
|
-
|
|
112
|
-
## Workflow Pattern
|
|
113
|
-
|
|
114
|
-
1. `barebrowse open <url>` — start session
|
|
115
|
-
2. `barebrowse snapshot` — observe page (read the .yml file)
|
|
116
|
-
3. Decide action based on snapshot content
|
|
117
|
-
4. `barebrowse click/type/fill/press/scroll/drag/upload <ref>` — act
|
|
118
|
-
5. `barebrowse snapshot` — observe result (refs are now different!)
|
|
119
|
-
6. Repeat 3-5 until goal achieved
|
|
120
|
-
7. `barebrowse close` — clean up
|
|
121
|
-
|
|
122
|
-
## Tips
|
|
123
|
-
|
|
124
|
-
- **Always snapshot before interacting** — refs are ephemeral and change every time
|
|
125
|
-
- **Use `fill` instead of `type`** when replacing existing text in input fields
|
|
126
|
-
- **Use `--mode=read`** for snapshot when you need to extract article content or data
|
|
127
|
-
- **Use `back`/`forward`** to navigate browser history instead of re-entering URLs
|
|
128
|
-
- **Use `upload`** for file inputs — pass absolute paths to the files
|
|
129
|
-
- **Use `wait-for`** when content loads asynchronously — more reliable than `wait-idle`
|
|
130
|
-
- **Check `dialog-log`** if JS alerts/confirms were auto-dismissed during your session
|
|
131
|
-
- **Use `save-state`** to persist cookies/localStorage for later sessions via `--storage-state`
|
|
132
|
-
- **Check `console-logs`** when page behavior seems wrong — JS errors show up there
|
|
133
|
-
- **Check `network-log --failed`** to debug missing content or broken API calls
|
|
134
|
-
- **Use `eval`** as an escape hatch when ARIA tree doesn't show what you need
|
|
135
|
-
- **One session per project** — `.barebrowse/` is project-scoped
|
|
136
|
-
- For bot-detected sites, use `--mode=headed` (requires browser with `--remote-debugging-port=9222`)
|