barebrowse 0.24.1 → 0.26.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 CHANGED
@@ -1,5 +1,86 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.26.0] - 2026-10-27
4
+
5
+ ### Added
6
+
7
+ - **Opt-in link URLs in snapshots.** `links: true` adds each link's absolute URL
8
+ after its name, in every mode: `link "name" <absolute-url> [ref=N]`. Headings
9
+ that wrap a link keep its URL, and in data mode so do group items and table
10
+ cells. `javascript:` links and same-page `#fragment` links are skipped, and
11
+ spaces and `<>` in a URL are percent-encoded. It is available as
12
+ `snapshot({ links: true })`, in `browse()` and `connect()`, as the `links`
13
+ argument of the MCP `browse` and `snapshot` tools, as `--links` on
14
+ `barebrowse snapshot` and `barebrowse browse`, and in the bareagent tools.
15
+ Off by default, and the output is unchanged when it is off. The data-mode
16
+ legend gains a links note only when links are on.
17
+ - **`goto()` now reports where it landed.** It resolves `{ url, status }`: the
18
+ final URL after redirects and the main document's HTTP status, on both
19
+ engines. `page.lastNavigation` holds the same value and is reset to `null`
20
+ after `goBack()`, `goForward()`, `reload()` and a tab switch. After a non-2xx
21
+ `goto()`, the next `snapshot()` and the `browse()` output start with
22
+ `[HTTP n — the page may be an error page]`. An HTTP 4xx or 5xx is reported,
23
+ never thrown, including an error response with an empty body. The MCP and
24
+ CLI `goto` print `ok (HTTP n)` for a non-2xx page.
25
+ - **Network failures reject with a typed error.** An unreachable host (DNS
26
+ failure, connection refused, TLS error and the like) rejects with
27
+ `err.code === 'NAV_FAILED'` and the browser's raw message in `err.reason`.
28
+ Behaviour change: on Chromium, `goto()` and `browse()` to an unreachable host
29
+ used to resolve with the browser's own error page; they now reject. Firefox
30
+ already rejected, with an untyped error; it is now the same typed error.
31
+
32
+ ### Fixed
33
+
34
+ - **A download no longer makes `goto()` wait 30s and time out on Chromium.**
35
+ Navigating to a URL that turns into a download, or to a 204 response, returns
36
+ at once. A 204 reports status 204 on both engines.
37
+ - **`barebrowse install --skill` works from an npm install.** The skill file
38
+ was missing from the published package, so the command failed outside a
39
+ checkout.
40
+
41
+ ## [0.25.0] - 2026-10-26
42
+
43
+ ### Added
44
+
45
+ - **Opt-in data mode for pages made of records.** `snapshot({ mode: 'data' })`
46
+ turns tables, listings and repeated items into one line per record instead of
47
+ a nested tree: table rows are mapped to their column headers, repeated
48
+ siblings are grouped, and noise is dropped. Refs are shared with the default
49
+ mode, so you can still click what you read. It is available as
50
+ `pruneMode: 'data'` in `browse()` and `connect()`, as the `pruneMode`
51
+ argument of the MCP `browse` and `snapshot` tools, as
52
+ `barebrowse open --prune-mode=data` and `barebrowse snapshot --mode=data` in
53
+ the CLI, and in the bareagent tools. The default (`act`) and `read` output
54
+ are unchanged.
55
+ - **Every data-mode snapshot starts with a one-line legend.** An agent that has
56
+ never seen the format learns how to read table rows, groups and
57
+ title-plus-detail blocks from the output itself. Data mode keeps main content
58
+ only, so use `act` for menus and page controls. Buttons and links whose only
59
+ name is an icon-font glyph (private-use characters) are dropped as nameless.
60
+
61
+ ### Fixed
62
+
63
+ - **A consent dialog whose only button says "Consent" is now dismissed.** The
64
+ bare label matched no accept pattern, so a Google Funding Choices dialog
65
+ stayed open. It is matched only inside a consent dialog, never page-wide, so
66
+ "Manage consent", "Consent settings" and "Do not consent" are not clicked.
67
+ - **Consent dialogs that render 1-3s after load are dismissed.** Consent used
68
+ to run once, right after navigation, and never looked again. The first
69
+ `snapshot()` after a `goto()` now checks once more, with no added waiting, and
70
+ rebuilds the snapshot if it dismissed something. It only fires on the same
71
+ document the `goto()` landed on, so a later redirect or click to a different
72
+ page is not auto-accepted, while `pushState` and hash changes on the same
73
+ page do not skip it. This also applies in attach mode (`connect({port})`).
74
+ `createTab().goto()` and the one-shot `browse()` are not covered.
75
+ - **Chromium `snapshot()` now honours the `connect({ pruneMode })` default.** It
76
+ ignored the option and always returned `act` output, while Firefox honoured
77
+ it. An explicit `snapshot({ mode })` still wins, then the `connect()` default,
78
+ then `act`. Behaviour change: Chromium callers who set `pruneMode` (for
79
+ example `read`) will now get that mode from a bare `snapshot()`.
80
+ - **Data mode's "% pruned" no longer counts the legend.** A tiny page could
81
+ report a negative figure because the legend outweighed the content. A page
82
+ with no records now returns an empty string instead of a lone legend line.
83
+
3
84
  ## [0.24.1] - 2026-10-25
4
85
 
5
86
  ### Fixed
package/README.md CHANGED
@@ -102,7 +102,9 @@ MCP tools: `browse`, `goto`, `snapshot`, `readable`, `click`, `type`, `press`, `
102
102
 
103
103
  **Hard-kill safety (Linux).** If the process that launched a browser is `kill -9`'d or crashes, the browser dies with it: Chromium via a `--remote-debugging-pipe` tether, Firefox via `setpriv --pdeathsig` (needs `setpriv` from util-linux; without it, or off Linux, a hard kill still orphans Firefox, as does a Snap Firefox). The dead launcher's leftover `barebrowse-*` temp dirs are cleaned at the next launch. Known limits: a reused pid keeps its dir, and dirs created under a different hostname are never removed.
104
104
 
105
- `browse` and `snapshot` accept `pruneMode: 'act'|'read'`. `act` (default) keeps interactive elements — best for clicking/filling. `read` keeps paragraphs, headings, and long text — best for articles, docs, and content extraction. If act-mode collapses a content-heavy page near-totally, the snapshot includes a `hint: …` line suggesting `pruneMode='read'` so the agent doesn't bail to a separate HTTP fetch.
105
+ `browse` and `snapshot` accept `pruneMode: 'act'|'read'|'data'`. `act` (default) keeps interactive elements — best for clicking/filling. `read` keeps paragraphs, headings, and long text — best for articles, docs, and content extraction. If act-mode collapses a content-heavy page near-totally, the snapshot includes a `hint: …` line suggesting `pruneMode='read'` so the agent doesn't bail to a separate HTTP fetch. `data` is one line per record — tables with headers, repeated items grouped; for data pages, not articles. Output starts with a one-line legend (`# data mode: …`): table rows read `row "<label>": <column>: <value> · …`, groups read `<label>: a, b, c`, and a title line followed by detail lines is one block, up to the next title line. It covers the main landmark only (nav, header and pagination outside `<main>` are dropped): use `act` for menus and page controls.
106
+
107
+ `links: true` (opt-in, `snapshot({ links: true })`, `browse(url, { links: true })`, or the `connect({ links: true })` default; MCP/bareagent `links` param, CLI `snapshot --links` / `browse <url> --links`) adds each link's absolute URL right after its quoted name: `- link "Fix login bug" <https://github.com/o/r/issues/42> [ref=12]`. Works in every mode; a heading that wraps a link keeps the URL on its own line (`heading "title" <url> [level=3] [ref=N]`); data mode also puts it after link cells in table rows and each item of a collapsed group (`Labels: bug <url> [ref=1], docs <url> [ref=2]`) and its legend gains ` Links: "name" <url>.`. `javascript:` and same-page `#fragment` links get no URL, every link line, row cell and group item carries its own URL (nothing is deduped across them, even when two links share a URL), and URLs never contain a raw space, `<` or `>`. Off by default: output is unchanged and costs nothing (about +23% chars on a GitHub issue list in data mode).
106
108
 
107
109
  `npx barebrowse doctor` reports the runtime environment first — default engine/mode, installed Chromium/Firefox binaries, cookie sources, and any live session's engine + capabilities — then scans every known MCP config location and flags scope conflicts. `npx barebrowse install --force` overwrites an existing entry pointing at a different endpoint.
108
110
 
@@ -138,6 +140,25 @@ const snap = await page.snapshot();
138
140
  await page.close(); // closes only the tab barebrowse opened — your browser keeps running
139
141
  ```
140
142
 
143
+ ### Did the navigation work?
144
+
145
+ `goto()` resolves to `{ url, status }` — the final URL after redirects and the
146
+ main document's HTTP status (`0` when no HTTP response was observed, e.g. an aborted navigation).
147
+ `page.lastNavigation` returns the same object (`null` before any goto, and reset
148
+ to `null` by `goBack`/`goForward`/`reload`/`switchTab` — status is reported for
149
+ `goto()` only, so those never leave a stale warning). A
150
+ non-2xx page still loads, and its snapshot (and `browse()` output) carries a
151
+ `[HTTP 404 — the page may be an error page]` line. If the browser cannot
152
+ reach a document at all (DNS failure, connection refused, TLS error) `goto()`
153
+ and `browse()` reject with an Error whose `code` is `'NAV_FAILED'` and `reason`
154
+ the browser's raw string (`net::ERR_NAME_NOT_RESOLVED`, `NS_ERROR_UNKNOWN_HOST`).
155
+ A download or a 204 is not a failure. Through MCP and the CLI, `goto` prints
156
+ `ok` for 2xx and `ok (HTTP 404)` otherwise.
157
+
158
+ ```js
159
+ const { url, status } = await page.goto('https://example.com/gone');
160
+ ```
161
+
141
162
  ### Firefox (WebDriver BiDi)
142
163
 
143
164
  CDP is deprecated in Firefox, so barebrowse drives it over the W3C WebDriver
@@ -203,7 +224,7 @@ Raw ARIA output from a page is noisy -- decorative wrappers, hidden elements, st
203
224
  | Wikipedia (article) | 109,479 chars | 40,566 chars | 63% |
204
225
  | DuckDuckGo | 42,254 chars | 5,407 chars | 87% |
205
226
 
206
- Two pruning modes: **act** (default) keeps interactive elements and visible labels -- for clicking, typing, navigating. **read** keeps all text content -- for reading articles and extracting information.
227
+ Three snapshot modes: **act** (default) keeps interactive elements and visible labels -- for clicking, typing, navigating. **read** keeps all text content -- for reading articles and extracting information. **data** (opt-in) emits one line per record -- tables become `row "Label": Header: value · ...`, repeated items are grouped (`Lines: Red, Green, Blue`) -- for data pages (timetables, listings, results). `[ref=N]` stays on interactive nodes, so click/type work as in act. Every data snapshot starts with a one-line legend explaining the format. It is larger than act on prose pages; use `read` or `readable()` for articles.
207
228
 
208
229
  ## Actions
209
230
 
@@ -213,7 +234,7 @@ Everything the agent can do through barebrowse:
213
234
  |--------|-------------|
214
235
  | **Navigate** | Load a URL, wait for page load, auto-dismiss consent |
215
236
  | **Back / Forward** | Browser history navigation |
216
- | **Snapshot** | Pruned ARIA tree with `[ref=N]` markers. Two modes: `act` (buttons, links, inputs) and `read` (full text). 40-90% token reduction. |
237
+ | **Snapshot** | Pruned ARIA tree with `[ref=N]` markers. Modes: `act` (buttons, links, inputs), `read` (full text), `data` (one line per record, for tables/listings). 40-90% token reduction. |
217
238
  | **Readable** | Clean article text (title + body, chrome stripped — Reader-View engine). For *reading* article-like pages, not interacting. Advisory `confidence`; falls back to snapshot on non-articles. |
218
239
  | **Click** | Scroll into view + mouse click at element center, JS fallback for hidden elements |
219
240
  | **Type** | Focus + insert text, with option to clear existing content first |
@@ -49,7 +49,8 @@ const snapshot = await browse('https://example.com', {
49
49
  incognito: false, // clean, unauthenticated session: skip ALL auth injection
50
50
  browser: 'firefox', // cookie source: 'firefox' | 'chromium' (auto-detected)
51
51
  prune: true, // apply ARIA pruning (47-95% token reduction)
52
- pruneMode: 'act', // 'act' (interactive elements) | 'read' (all content)
52
+ pruneMode: 'act', // 'act' (interactive elements) | 'read' (all content) | 'data' (one line per record)
53
+ links: false, // default for snapshot({ links }): link URLs after each link name
53
54
  consent: true, // auto-dismiss cookie consent dialogs
54
55
  blockAds: true, // block 128 ad/tracker URL patterns (default on for owned browsers)
55
56
  blockUrls: [], // extra URL globs to block (merged with the default)
@@ -65,11 +66,12 @@ const snapshot = await browse('https://example.com', {
65
66
 
66
67
  | Method | Args | Returns | Notes |
67
68
  |---|---|---|---|
68
- | `goto(url, timeout?)` | url: string, timeout: number (default 30000) | void | Navigate + wait for load + dismiss consent |
69
+ | `goto(url, timeout?)` | url: string, timeout: number (default 30000) | `{ url, status }` | Navigate + wait for load + dismiss consent. Resolves to the final URL (after redirects) and the main document's HTTP status (`0` = no HTTP response observed, e.g. an aborted navigation). Non-2xx still resolves; `snapshot()` then carries `[HTTP 404 — the page may be an error page]`. Network failure (DNS, refused, TLS) rejects with `err.code === 'NAV_FAILED'` and `err.reason` (raw browser string, e.g. `net::ERR_NAME_NOT_RESOLVED` / `NS_ERROR_UNKNOWN_HOST`). A download or 204 (`ERR_ABORTED` / `NS_BINDING_ABORTED`) is not a failure and returns without waiting for a load event. `browse()` still returns a string (warning line prepended when non-2xx) and rejects with the same `NAV_FAILED`. |
70
+ | `lastNavigation` | -- | `{ url, status }` or null | Outcome of the latest `goto()`; null before any goto and while a goto is failing. Reset to null by `reload`/`goBack`/`goForward`/`switchTab` (status is reported for `goto()` only) |
69
71
  | `goBack()` | -- | void | Navigate back in browser history |
70
72
  | `goForward()` | -- | void | Navigate forward in browser history |
71
73
  | `reload(opts?)` | { ignoreCache?: boolean, timeout?: number } | void | Reload the current page. Clears refMap (refs from pre-reload reject). |
72
- | `snapshot(pruneOpts?)` | false or { mode: 'act'\|'read' } | string | ARIA tree with `[ref=N]` markers. Pass `false` for raw. |
74
+ | `snapshot(pruneOpts?)` | false or { mode: 'act'\|'read'\|'data', links?: boolean } | string | ARIA tree with `[ref=N]` markers. Pass `false` for raw. `links: true` adds `<absolute-url>` after each link name (see below). |
73
75
  | `readable()` | -- | object | Clean article text (Reader-View engine). `{ ok, title, byline, text, length, confidence: 'high'\|'low', readerable, hint? }` or `{ ok: false, hint }`. For *reading*, not interacting — see note below. |
74
76
  | `click(ref)` | ref: string | void | Scroll into view + mouse press+release at center |
75
77
  | `type(ref, text, opts?)` | ref: string, text: string, opts: { clear?, keyEvents? } | void | Focus + insert text. `clear: true` replaces existing. |
@@ -193,7 +195,7 @@ barebrowse can inject cookies from the user's real browser sessions, bypassing l
193
195
 
194
196
  | Obstacle | How | Mode |
195
197
  |---|---|---|
196
- | Cookie consent | ARIA scan for the accept button, 29 languages. CDP: `jsClick` (overlay-bypassing) then a real-mouse-click fallback for CMPs that ignore synthetic clicks. Firefox/BiDi: a single real pointer click. A page-wide accept scan runs only for banner-style consent (no dialog) — when a dialog is detected but has no in-dialog accept button, no page-wide scan runs, to avoid clicking an unrelated `Accept all …` control | Both engines |
198
+ | Cookie consent | ARIA scan for the accept button, 29 languages. CDP: `jsClick` (overlay-bypassing) then a real-mouse-click fallback for CMPs that ignore synthetic clicks. Firefox/BiDi: a single real pointer click. A page-wide accept scan runs only for banner-style consent (no dialog) — when a dialog is detected but has no in-dialog accept button, no page-wide scan runs, to avoid clicking an unrelated `Accept all …` control. A bare `Consent` button (Google Funding Choices) is accepted only inside a detected dialog. If `goto()` found no dialog, the first `snapshot()` after it re-checks once, on the same document only, for CMPs that render 1-3s after load (not covered by one-shot `browse()` or `createTab().goto()`) | Both engines |
197
199
  | Consent behind iframes | Scanned/clicked in the owning frame (CDP `DOM.resolveNode`; Firefox resolves the ref in its browsing context) | Both engines |
198
200
  | Permission prompts | Launch flags + CDP Browser.setPermission auto-deny | Both |
199
201
  | Media autoplay blocked | `--autoplay-policy=no-user-gesture-required` | Both |
@@ -302,9 +304,11 @@ Action tools return `'ok'` -- the agent calls `snapshot` explicitly to observe.
302
304
 
303
305
  `browse`, `snapshot`, and `readable` accept a `maxChars` param (default 30000). If the output exceeds the limit it's saved to `.barebrowse/` and a short message with the file path is returned instead (`page-<timestamp>.yml` for snapshots, `article-<timestamp>.txt` for `readable`). `screenshot` always saves to `.barebrowse/screenshot-<timestamp>.{png,jpeg,webp}` and returns the file path (raw base64 in a JSON-RPC response would blow `maxChars`). `tabs` returns the JSON array, or with `switchTo: N` it switches and returns `'ok'`. All files MCP writes are owner-only (`0600` in a `0700` dir) — they can hold authenticated page content, so they're not world-readable on a shared host.
304
306
 
305
- `browse` and `snapshot` also accept `pruneMode: 'act'|'read'`. `act` (the default) keeps interactive elements and short labels — best for clicking/filling. `read` keeps paragraphs, headings, and long text — best for articles, docs, and content extraction. Same surface on the bareagent adapter. If act mode collapses a content-heavy page (raw > 5 KB → pruned < 500 chars AND < 5% of raw), the result includes a `hint: act mode dropped most of the page — retry with pruneMode='read' …` line between the stats and the tree so the caller knows to re-snapshot in read mode instead of bailing to a separate HTTP fetch.
307
+ `browse` and `snapshot` also accept `pruneMode: 'act'|'read'|'data'`. `act` (the default) keeps interactive elements and short labels — best for clicking/filling. `read` keeps paragraphs, headings, and long text — best for articles, docs, and content extraction. `data` (opt-in) is one line per record — tables with headers (`row "Label": Header: value · …`), repeated items grouped (`Label: a, b, c`) — for data pages (timetables, listings, results), not articles; every data snapshot starts with ONE legend line (`# data mode: one line per record. Tables: row "<label>": <column>: <value> · … Groups: <label>: a, b, c. A title line followed by detail lines is one block, up to the next title line. Main content only; use mode "act" for menus and page controls.`) so you can read it without docs; it keeps `[ref=N]` on interactive nodes (clickable like act) and is *larger* than act on prose pages — use `read`/`readable()` there. Same surface on the bareagent adapter. If act mode collapses a content-heavy page (raw > 5 KB → pruned < 500 chars AND < 5% of raw), the result includes a `hint: act mode dropped most of the page — retry with pruneMode='read' …` line between the stats and the tree so the caller knows to re-snapshot in read mode instead of bailing to a separate HTTP fetch.
306
308
 
307
- Session runs in hybrid mode (headless with automatic headed fallback on bot detection). `goto` injects cookies from the user's browser before navigation for authenticated access.
309
+ `links: true` (opt-in, `snapshot({ links: true })`, `browse(url, { links: true })`, or the `connect({ links: true })` default; MCP/bareagent `links` param, CLI `snapshot --links` / `browse <url> --links`) adds each link's absolute URL right after its quoted name: `- link "Fix login bug" <https://github.com/o/r/issues/42> [ref=12]`. Works in every mode; a heading that wraps a link keeps the URL on its own line (`heading "title" <url> [level=3] [ref=N]`); data mode also puts it after link cells in table rows and each item of a collapsed group (`Labels: bug <url> [ref=1], docs <url> [ref=2]`) and its legend gains ` Links: "name" <url>.`. `javascript:` and same-page `#fragment` links get no URL, every link line, row cell and group item carries its own URL (nothing is deduped across them, even when two links share a URL), and URLs never contain a raw space, `<` or `>`. Off by default: output is unchanged and costs nothing (about +23% chars on a GitHub issue list in data mode).
310
+
311
+ `goto` answers `ok` for 2xx and `ok (HTTP 404)` for other statuses (the next `snapshot` starts with an `[HTTP 404 …]` warning line); an unreachable host is an error. Session runs in hybrid mode (headless with automatic headed fallback on bot detection). `goto` injects cookies from the user's browser before navigation for authenticated access.
308
312
 
309
313
  Session tools share a singleton page, lazy-created on first use. All session tools have auto-retry on transient failures (browser crash, WebSocket close, navigation timeout) on a per-tool deadline (v0.9.0 H5): `goto`/`reload`/`wait_for` 60s, `back`/`forward` 30s, interactive ops (`click`/`type`/`press`/`scroll`/`hover`/`select`/`drag`/`snapshot`/`eval`) 15s, `tabs` 5s, heavy I/O (`pdf`/`screenshot`/`upload`) 45s — replaces the prior blanket 30s. Session resets between attempts. Idempotent tools retry once; mutating tools (`click`/`type`/`upload`/etc.) `{ retry: false }` so partial first attempts don't replay on a fresh page. Scroll accepts `direction: "up"/"down"` in addition to numeric `deltaY`. Click falls back to JS `.click()` when elements have no layout. `browse` has a 60s timeout (no retry — stateless). Assess tries headless first; if bot-blocked, retries headed. Browser OOM/crash auto-recovers (session resets, server stays alive).
310
314
 
@@ -373,7 +377,7 @@ Useful for agent threshold decisions: "skip sites above score 40", "warn if term
373
377
 
374
378
  2. **SPA navigation has no loadEventFired.** For single-page apps (React, YouTube, GitHub), use `waitForNetworkIdle()` or a timed wait after click instead of `waitForNavigation()`.
375
379
 
376
- 3. **Pruning modes matter.** `act` mode (default) keeps interactive elements + visible labels. `read` mode keeps all text content. Use `read` for content extraction, `act` for form filling and navigation.
380
+ 3. **Pruning modes matter.** `act` mode (default) keeps interactive elements + visible labels. `read` mode keeps all text content. Use `read` for content extraction, `act` for form filling and navigation, `data` for tables and listings.
377
381
 
378
382
  4. **Headed mode auto-launches Chromium.** No need to start a browser manually — barebrowse launches a headed Chromium instance with CDP enabled automatically.
379
383
 
package/cli.js CHANGED
@@ -37,7 +37,7 @@ if (args.includes('--daemon-internal')) {
37
37
  } else if (cmd === 'goto' && args[1]) {
38
38
  await cmdProxy('goto', { url: args[1], timeout: parseFlag('--timeout') });
39
39
  } else if (cmd === 'snapshot') {
40
- await cmdProxy('snapshot', { mode: parseFlag('--mode') });
40
+ await cmdProxy('snapshot', { mode: parseFlag('--mode'), links: hasFlag('--links') || undefined });
41
41
  } else if (cmd === 'readable') {
42
42
  await cmdProxy('readable');
43
43
  } else if (cmd === 'screenshot') {
@@ -185,7 +185,7 @@ async function cmdProxy(command, cmdArgs) {
185
185
  try { unlinkSync(sessionPath); } catch { /* already gone */ }
186
186
  process.stdout.write('Session closed.\n');
187
187
  } else {
188
- process.stdout.write('ok\n');
188
+ process.stdout.write(result.status ? `ok (HTTP ${result.status})\n` : 'ok\n');
189
189
  }
190
190
  } catch (err) {
191
191
  if (command === 'close') {
@@ -203,9 +203,9 @@ async function cmdProxy(command, cmdArgs) {
203
203
  async function oneShot() {
204
204
  const { browse } = await import('./src/index.js');
205
205
  const url = args[1];
206
- const mode = args[2] || 'headless';
206
+ const mode = args[2] && !args[2].startsWith('--') ? args[2] : 'headless';
207
207
  try {
208
- const snapshot = await browse(url, { mode, incognito: hasFlag('--incognito') || undefined });
208
+ const snapshot = await browse(url, { mode, incognito: hasFlag('--incognito') || undefined, links: hasFlag('--links') || undefined });
209
209
  process.stdout.write(snapshot + '\n');
210
210
  process.exit(0);
211
211
  } catch (err) {
@@ -563,7 +563,9 @@ Session:
563
563
  --incognito Clean, unauthenticated session (skip all auth injection)
564
564
  --browser=firefox|chromium Cookie source browser
565
565
  --timeout=N Navigation timeout in ms
566
- --prune-mode=act|read Default pruning mode
566
+ --prune-mode=act|read|data Default pruning mode (data: one line per record — tables with headers,
567
+ repeated items grouped; for data pages, not articles;
568
+ output starts with a one-line legend)
567
569
  --no-consent Skip consent dismissal
568
570
  --proxy=URL HTTP/SOCKS proxy server
569
571
  --viewport=WxH Viewport size (e.g. 1280x720)
@@ -583,7 +585,7 @@ Navigation:
583
585
  barebrowse back Go back in history
584
586
  barebrowse forward Go forward in history
585
587
  barebrowse reload [--no-cache] Reload current page
586
- barebrowse snapshot [--mode=M] ARIA snapshot -> .barebrowse/page-*.yml
588
+ barebrowse snapshot [--mode=M] [--links] ARIA snapshot -> .barebrowse/page-*.yml (--links: link URLs)
587
589
  barebrowse readable Clean article text -> .barebrowse/article-*.txt
588
590
  barebrowse screenshot [--format] Screenshot -> .barebrowse/screenshot-*.png
589
591
  barebrowse pdf [--landscape] PDF export -> .barebrowse/page-*.pdf
@@ -618,7 +620,7 @@ Debugging:
618
620
  barebrowse switch-engine <chromium|firefox> Swap the browser in place (page, tabs, refs are lost)
619
621
 
620
622
  One-shot:
621
- barebrowse browse <url> [mode] Browse + print snapshot to stdout
623
+ barebrowse browse <url> [mode] [--links] Browse + print snapshot to stdout
622
624
 
623
625
  MCP:
624
626
  barebrowse mcp Start MCP server (JSON-RPC over stdio)
@@ -0,0 +1,141 @@
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. Output files older than 7 days are removed automatically at `open`; saved state files (`state-*.json`) are kept.
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|data` — 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", or "ok (HTTP 404)" for a non-2xx page (the next snapshot starts with an `[HTTP 404 …]` warning). Unreachable host: error. |
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 snapshot --mode=data` | Data mode: one line per record (table rows with headers, repeated items grouped). For data pages, not articles. Main content only; use `act` for menus and page controls. |
57
+ | `barebrowse snapshot --links` | Add each link's absolute URL after its name: `link "title" <https://…> [ref=N]` (combine with `--mode`; also on `browse <url> --links`). `javascript:` and same-page `#` links get none. |
58
+ | `barebrowse readable` | Clean article text → `.barebrowse/article-<timestamp>.txt`. For reading/summarising articles (news, blogs, docs); falls back to snapshot on non-articles. |
59
+ | `barebrowse screenshot` | Screenshot → `.barebrowse/screenshot-<timestamp>.png` |
60
+ | `barebrowse pdf [--landscape]` | PDF export → `.barebrowse/page-<timestamp>.pdf` |
61
+
62
+ ### Interaction
63
+
64
+ | Command | Description |
65
+ |---------|-------------|
66
+ | `barebrowse click <ref>` | Click element (scrolls into view first) |
67
+ | `barebrowse type <ref> <text>` | Type text into element |
68
+ | `barebrowse fill <ref> <text>` | Clear existing content + type new text |
69
+ | `barebrowse press <key>` | Press key: Enter, Tab, Escape, Backspace, Delete, arrows, Space |
70
+ | `barebrowse scroll <deltaY>` | Scroll page (positive=down, negative=up) |
71
+ | `barebrowse hover <ref>` | Hover over element (triggers tooltips) |
72
+ | `barebrowse select <ref> <value>` | Select dropdown option |
73
+ | `barebrowse drag <fromRef> <toRef>` | Drag element to another element |
74
+ | `barebrowse upload <ref> <files..>` | Upload file(s) to a file input element |
75
+
76
+ ### Tabs
77
+
78
+ | Command | Description |
79
+ |---------|-------------|
80
+ | `barebrowse tabs` | List open tabs (index, url, title) |
81
+ | `barebrowse tab <index>` | Switch to tab by index |
82
+
83
+ ### Debugging
84
+
85
+ | Command | Output |
86
+ |---------|--------|
87
+ | `barebrowse eval <expression>` | Evaluate JS in page, print result |
88
+ | `barebrowse wait-idle` | Wait for network idle (no requests for 500ms) |
89
+ | `barebrowse wait-for [opts]` | Wait for content to appear on page |
90
+ | `barebrowse console-logs` | Console logs → `.barebrowse/console-<timestamp>.json` |
91
+ | `barebrowse network-log` | Network log → `.barebrowse/network-<timestamp>.json` |
92
+ | `barebrowse network-log --failed` | Only failed/4xx/5xx requests |
93
+ | `barebrowse dialog-log` | JS dialog log → `.barebrowse/dialogs-<timestamp>.json` |
94
+ | `barebrowse save-state` | Cookies + localStorage → `.barebrowse/state-<timestamp>.json` |
95
+ | `barebrowse switch-engine <chromium\|firefox>` | Swap the session's browser engine in place; page, tabs and refs are lost, so `goto` again |
96
+
97
+ **wait-for flags:**
98
+ - `--text=STRING` — Wait for text to appear in page body
99
+ - `--selector=CSS` — Wait for CSS selector to match
100
+ - `--timeout=N` — Max wait time in ms (default: 30000)
101
+
102
+ ## Snapshot Format
103
+
104
+ The snapshot is a YAML-like ARIA tree. Each line is one node:
105
+
106
+ ```
107
+ # https://example.com/
108
+ # 379 chars → 45 chars (88% pruned)
109
+ - heading "Example Domain" [level=1] [ref=3]
110
+ ```
111
+
112
+ - `[ref=N]` — Use this number with click, type, fill, hover, select, drag, upload
113
+ - Refs change on every snapshot — always take a fresh snapshot before interacting
114
+ - **act mode** (default): interactive elements + labels — for clicking, typing, navigating
115
+ - **read mode**: all text content — for reading articles, extracting data
116
+
117
+ ## Workflow Pattern
118
+
119
+ 1. `barebrowse open <url>` — start session
120
+ 2. `barebrowse snapshot` — observe page (read the .yml file)
121
+ 3. Decide action based on snapshot content
122
+ 4. `barebrowse click/type/fill/press/scroll/drag/upload <ref>` — act
123
+ 5. `barebrowse snapshot` — observe result (refs are now different!)
124
+ 6. Repeat 3-5 until goal achieved
125
+ 7. `barebrowse close` — clean up
126
+
127
+ ## Tips
128
+
129
+ - **Always snapshot before interacting** — refs are ephemeral and change every time
130
+ - **Use `fill` instead of `type`** when replacing existing text in input fields
131
+ - **Use `--mode=read`** for snapshot when you need to extract article content or data
132
+ - **Use `back`/`forward`** to navigate browser history instead of re-entering URLs
133
+ - **Use `upload`** for file inputs — pass absolute paths to the files
134
+ - **Use `wait-for`** when content loads asynchronously — more reliable than `wait-idle`
135
+ - **Check `dialog-log`** if JS alerts/confirms were auto-dismissed during your session
136
+ - **Use `save-state`** to persist cookies/localStorage for later sessions via `--storage-state`
137
+ - **Check `console-logs`** when page behavior seems wrong — JS errors show up there
138
+ - **Check `network-log --failed`** to debug missing content or broken API calls
139
+ - **Use `eval`** as an escape hatch when ARIA tree doesn't show what you need
140
+ - **One session per project** — `.barebrowse/` is project-scoped
141
+ - For bot-detected sites, use `--mode=headed` (requires browser with `--remote-debugging-port=9222`)
@@ -0,0 +1,140 @@
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. Output files older than 7 days are removed automatically at `open`; saved state files (`state-*.json`) are kept.
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|data` — 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", or "ok (HTTP 404)" for a non-2xx page (the next snapshot starts with an `[HTTP 404 …]` warning). Unreachable host: error. |
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 snapshot --mode=data` | Data mode: one line per record (table rows with headers, repeated items grouped). For data pages, not articles. Main content only; use `act` for menus and page controls. |
56
+ | `barebrowse snapshot --links` | Add each link's absolute URL after its name: `link "title" <https://…> [ref=N]` (combine with `--mode`; also on `browse <url> --links`). `javascript:` and same-page `#` links get none. |
57
+ | `barebrowse readable` | Clean article text → `.barebrowse/article-<timestamp>.txt`. For reading/summarising articles (news, blogs, docs); falls back to snapshot on non-articles. |
58
+ | `barebrowse screenshot` | Screenshot → `.barebrowse/screenshot-<timestamp>.png` |
59
+ | `barebrowse pdf [--landscape]` | PDF export → `.barebrowse/page-<timestamp>.pdf` |
60
+
61
+ ### Interaction
62
+
63
+ | Command | Description |
64
+ |---------|-------------|
65
+ | `barebrowse click <ref>` | Click element (scrolls into view first) |
66
+ | `barebrowse type <ref> <text>` | Type text into element |
67
+ | `barebrowse fill <ref> <text>` | Clear existing content + type new text |
68
+ | `barebrowse press <key>` | Press key: Enter, Tab, Escape, Backspace, Delete, arrows, Space |
69
+ | `barebrowse scroll <deltaY>` | Scroll page (positive=down, negative=up) |
70
+ | `barebrowse hover <ref>` | Hover over element (triggers tooltips) |
71
+ | `barebrowse select <ref> <value>` | Select dropdown option |
72
+ | `barebrowse drag <fromRef> <toRef>` | Drag element to another element |
73
+ | `barebrowse upload <ref> <files..>` | Upload file(s) to a file input element |
74
+
75
+ ### Tabs
76
+
77
+ | Command | Description |
78
+ |---------|-------------|
79
+ | `barebrowse tabs` | List open tabs (index, url, title) |
80
+ | `barebrowse tab <index>` | Switch to tab by index |
81
+
82
+ ### Debugging
83
+
84
+ | Command | Output |
85
+ |---------|--------|
86
+ | `barebrowse eval <expression>` | Evaluate JS in page, print result |
87
+ | `barebrowse wait-idle` | Wait for network idle (no requests for 500ms) |
88
+ | `barebrowse wait-for [opts]` | Wait for content to appear on page |
89
+ | `barebrowse console-logs` | Console logs → `.barebrowse/console-<timestamp>.json` |
90
+ | `barebrowse network-log` | Network log → `.barebrowse/network-<timestamp>.json` |
91
+ | `barebrowse network-log --failed` | Only failed/4xx/5xx requests |
92
+ | `barebrowse dialog-log` | JS dialog log → `.barebrowse/dialogs-<timestamp>.json` |
93
+ | `barebrowse save-state` | Cookies + localStorage → `.barebrowse/state-<timestamp>.json` |
94
+ | `barebrowse switch-engine <chromium\|firefox>` | Swap the session's browser engine in place; page, tabs and refs are lost, so `goto` again |
95
+
96
+ **wait-for flags:**
97
+ - `--text=STRING` — Wait for text to appear in page body
98
+ - `--selector=CSS` — Wait for CSS selector to match
99
+ - `--timeout=N` — Max wait time in ms (default: 30000)
100
+
101
+ ## Snapshot Format
102
+
103
+ The snapshot is a YAML-like ARIA tree. Each line is one node:
104
+
105
+ ```
106
+ # https://example.com/
107
+ # 379 chars → 45 chars (88% pruned)
108
+ - heading "Example Domain" [level=1] [ref=3]
109
+ ```
110
+
111
+ - `[ref=N]` — Use this number with click, type, fill, hover, select, drag, upload
112
+ - Refs change on every snapshot — always take a fresh snapshot before interacting
113
+ - **act mode** (default): interactive elements + labels — for clicking, typing, navigating
114
+ - **read mode**: all text content — for reading articles, extracting data
115
+
116
+ ## Workflow Pattern
117
+
118
+ 1. `barebrowse open <url>` — start session
119
+ 2. `barebrowse snapshot` — observe page (read the .yml file)
120
+ 3. Decide action based on snapshot content
121
+ 4. `barebrowse click/type/fill/press/scroll/drag/upload <ref>` — act
122
+ 5. `barebrowse snapshot` — observe result (refs are now different!)
123
+ 6. Repeat 3-5 until goal achieved
124
+ 7. `barebrowse close` — clean up
125
+
126
+ ## Tips
127
+
128
+ - **Always snapshot before interacting** — refs are ephemeral and change every time
129
+ - **Use `fill` instead of `type`** when replacing existing text in input fields
130
+ - **Use `--mode=read`** for snapshot when you need to extract article content or data
131
+ - **Use `back`/`forward`** to navigate browser history instead of re-entering URLs
132
+ - **Use `upload`** for file inputs — pass absolute paths to the files
133
+ - **Use `wait-for`** when content loads asynchronously — more reliable than `wait-idle`
134
+ - **Check `dialog-log`** if JS alerts/confirms were auto-dismissed during your session
135
+ - **Use `save-state`** to persist cookies/localStorage for later sessions via `--storage-state`
136
+ - **Check `console-logs`** when page behavior seems wrong — JS errors show up there
137
+ - **Check `network-log --failed`** to debug missing content or broken API calls
138
+ - **Use `eval`** as an escape hatch when ARIA tree doesn't show what you need
139
+ - **One session per project** — `.barebrowse/` is project-scoped
140
+ - For bot-detected sites, use `--mode=headed` (requires browser with `--remote-debugging-port=9222`)
package/mcp-server.js CHANGED
@@ -14,6 +14,7 @@ import { browse, connect } from './src/index.js';
14
14
  import { formatReadable } from './src/readable.js';
15
15
  import { cleanOld } from './src/output-clean.js';
16
16
  import { scopedCookiesForUrl } from './src/auth.js';
17
+ import { isHttpError } from './src/navigation.js';
17
18
  import { mkdirSync, writeFileSync, readFileSync } from 'node:fs';
18
19
  import { join, dirname } from 'node:path';
19
20
  import { pathToFileURL, fileURLToPath } from 'node:url';
@@ -266,8 +267,9 @@ export const TOOLS = [
266
267
  properties: {
267
268
  url: { type: 'string', description: 'URL to browse' },
268
269
  mode: { type: 'string', enum: ['headless', 'headed', 'hybrid'], description: 'Browser mode (default: headless)' },
269
- pruneMode: { type: 'string', enum: ['act', 'read'], description: 'Pruning mode. "act" (default) keeps interactive elements and short labels — best for clicking/filling. "read" keeps paragraphs, headings, and long text — best for articles, docs, and content extraction. If the page is content-heavy and act-mode returns mostly empty, retry with "read".' },
270
+ pruneMode: { type: 'string', enum: ['act', 'read', 'data'], description: 'Pruning mode. "act" (default) keeps interactive elements and short labels — best for clicking/filling. "read" keeps paragraphs, headings, and long text — best for articles, docs, and content extraction. If the page is content-heavy and act-mode returns mostly empty, retry with "read". "data": one line per record — tables with headers, repeated items grouped; for data pages, not articles. Output starts with a legend line; read it as: table rows `row "<label>": <column>: <value> · …`, groups `<label>: a, b, c`, and a title line followed by detail lines is one block up to the next title line. Main content only: use "act" for menus and page controls.' },
270
271
  incognito: { type: 'boolean', description: 'Clean, unauthenticated session: skip cookie injection so the page loads logged-out (default: false).' },
272
+ links: { type: 'boolean', description: 'Show each link\'s absolute URL after its name: link "name" <url> [ref=N]. Default off.' },
271
273
  maxChars: { type: 'number', description: 'Max chars to return inline. Larger snapshots are saved to .barebrowse/ and a file path is returned instead. Default: 30000.' },
272
274
  },
273
275
  required: ['url'],
@@ -275,7 +277,7 @@ export const TOOLS = [
275
277
  },
276
278
  {
277
279
  name: 'goto',
278
- description: 'Open URL in a persistent interactive browser session (pair with snapshot/click/type/press for multi-step flows). Use when the task needs clicking, typing, or form submission. Injects auth cookies. Returns ok — call snapshot to observe.',
280
+ description: 'Open URL in a persistent interactive browser session (pair with snapshot/click/type/press for multi-step flows). Use when the task needs clicking, typing, or form submission. Injects auth cookies. Returns ok — call snapshot to observe. A non-2xx page answers `ok (HTTP 404)` and the snapshot starts with an [HTTP …] warning line; an unreachable host (DNS, refused, TLS) is an error.',
279
281
  inputSchema: {
280
282
  type: 'object',
281
283
  properties: {
@@ -290,7 +292,8 @@ export const TOOLS = [
290
292
  inputSchema: {
291
293
  type: 'object',
292
294
  properties: {
293
- pruneMode: { type: 'string', enum: ['act', 'read'], description: 'Pruning mode. "act" (default) keeps interactive elements and short labels — best for clicking/filling. "read" keeps paragraphs, headings, and long text — best for articles, docs, and content extraction. If a previous snapshot looked empty on a content-heavy page, retry with "read".' },
295
+ pruneMode: { type: 'string', enum: ['act', 'read', 'data'], description: 'Pruning mode. "act" (default) keeps interactive elements and short labels — best for clicking/filling. "read" keeps paragraphs, headings, and long text — best for articles, docs, and content extraction. If a previous snapshot looked empty on a content-heavy page, retry with "read". "data": one line per record — tables with headers, repeated items grouped; for data pages, not articles. Output starts with a legend line; read it as: table rows `row "<label>": <column>: <value> · …`, groups `<label>: a, b, c`, and a title line followed by detail lines is one block up to the next title line. Main content only: use "act" for menus and page controls.' },
296
+ links: { type: 'boolean', description: 'Show each link\'s absolute URL after its name: link "name" <url> [ref=N]. Default off.' },
294
297
  maxChars: { type: 'number', description: 'Max chars to return inline. Larger snapshots are saved to .barebrowse/ and a file path is returned instead. Default: 30000.' },
295
298
  },
296
299
  },
@@ -544,7 +547,7 @@ async function handleToolCall(name, args) {
544
547
  case 'browse': {
545
548
  let timer;
546
549
  const text = await Promise.race([
547
- browse(args.url, { mode: args.mode, pruneMode: args.pruneMode, incognito: args.incognito }),
550
+ browse(args.url, { mode: args.mode, pruneMode: args.pruneMode, incognito: args.incognito, links: args.links }),
548
551
  new Promise((_, rej) => { timer = setTimeout(() => rej(new Error('browse timed out after 60s')), 60000); }),
549
552
  ]);
550
553
  clearTimeout(timer);
@@ -566,12 +569,12 @@ async function handleToolCall(name, args) {
566
569
  try { await page.injectCookies(args.url); } catch (e) { error ??= e.message; }
567
570
  _lastCookies = cookieReport(args.url, { cookies, error });
568
571
  }
569
- await page.goto(args.url);
570
- return 'ok';
572
+ const { status } = await page.goto(args.url);
573
+ return isHttpError(status) ? `ok (HTTP ${status})` : 'ok';
571
574
  }, TIMEOUTS.goto);
572
575
  case 'snapshot': return withRetry(async () => {
573
576
  const page = await getPage();
574
- const text = await page.snapshot(args.pruneMode ? { mode: args.pruneMode } : undefined);
577
+ const text = await page.snapshot(args.pruneMode || args.links ? { mode: args.pruneMode, links: args.links } : undefined);
575
578
  const limit = args.maxChars ?? MAX_CHARS_DEFAULT;
576
579
  if (text.length > limit) {
577
580
  const file = saveSnapshot(text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "barebrowse",
3
- "version": "0.24.1",
3
+ "version": "0.26.0",
4
4
  "description": "Authenticated web browsing for autonomous agents via CDP. URL in, pruned ARIA snapshot out.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,6 +28,7 @@
28
28
  "src/",
29
29
  "types/",
30
30
  "cli.js",
31
+ "commands/",
31
32
  "mcp-server.js",
32
33
  "barebrowse.context.md",
33
34
  "README.md",