unbrowse 12.1.2 → 12.2.1-preview.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/README.md CHANGED
@@ -4,8 +4,8 @@ Call websites as APIs from a shell. A thin CLI over the Unbrowse REST API
4
4
  (`https://unbrowse.ai/api/v1`), built on [`@unbrowse/sdk`](https://www.npmjs.com/package/@unbrowse/sdk).
5
5
 
6
6
  ```bash
7
- unbrowse login # browser sign-in, or: login --key ub_live_…
8
- unbrowse run "top stories on Hacker News" # waits for a verified result
7
+ unbrowse login # browser sign-in, or: login --key ub_live_… (first use of any command does this too)
8
+ unbrowse run "top stories on Hacker News" # site requests go from your IP; --from-unbrowse to send them from Unbrowse
9
9
  unbrowse discover "flight search" # choose a returned capability
10
10
  unbrowse resume <runId> origin=SIN # answer on the same run
11
11
  ```
@@ -15,16 +15,19 @@ unbrowse resume <runId> origin=SIN # answer on the same run
15
15
  | `login [--key K]`, `logout`, `whoami`, `usage` | Account |
16
16
  | `discover <query>` | Your capabilities, then the public registry |
17
17
  | `run <task…>`, `inspect`, `resume`, `cancel` | Runs |
18
+ | `scrape <url>` | One page as markdown on stdout |
19
+ | `index <url>`, `index status [jobId]` | Teach a site: an agent explores it and compiles each flow into a tool |
18
20
  | `learn a.har b.har`, `learned [id]` | Teach a site from two recordings |
19
21
  | `logins`, `logins remove <origin>` | Saved logins, masked. The CLI never takes a password |
20
- | `registry [query]`, `site <host>` | Public compiled sites, no account |
22
+ | `registry [query]`, `site <host>`, `openapi <host>` | Public compiled sites, a site's tools, its OpenAPI 3.1 document — no account |
23
+ | `call <host> <tool> [JSON]` | Run one site tool (`--set k=v`, `--deadline MS`, `--select a,b`, `--idempotency-key K`, `--end-user ID`) |
21
24
 
22
- The CLI is the REST client. The remote MCP is a separate client; see the [install guide](https://github.com/unbrowse-ai/unbrowse-skill/blob/main/docs/install.md).
25
+ The CLI is the REST client. The remote MCP is a separate client; see the [install guide](https://github.com/unbrowse-ai/unbrowse/blob/main/docs/install.md).
23
26
 
24
27
  Exit codes: 0 accepted/ok (check status and verified), 1 error, 2 input required, 3 sign-in or saved login needed, 4 not verified.
25
28
  Env: `UNBROWSE_API_KEY`, `UNBROWSE_BASE_URL`. Node 18.17+, no dependencies.
26
29
 
27
- Install the hosted-client preview from the [installation guide](https://github.com/unbrowse-ai/unbrowse-skill/blob/main/docs/install.md); npm latest may be an older client.
30
+ Install: `npx unbrowse login` (OAuth in your browser), then any command. Guide: [installation guide](https://github.com/unbrowse-ai/unbrowse/blob/main/docs/install.md).
28
31
 
29
32
  The agent contract ships as `SKILL.md` with `references/` in this package. Full reference, docs and the whitepaper:
30
- https://github.com/unbrowse-ai/unbrowse-skill
33
+ https://github.com/unbrowse-ai/unbrowse
package/SKILL.md CHANGED
@@ -1,29 +1,50 @@
1
1
  ---
2
2
  name: unbrowse
3
- description: Search and call websites through Unbrowse's hosted API or remote MCP, reuse indexed site tools, read pages, and learn missing routes in its cloud browser. Use for structured website tasks, authenticated site access, and live canvas planning with Unbrowse.
3
+ description: Search and call websites through Unbrowse's hosted API or remote MCP, reuse indexed site tools, read pages, and learn missing routes in its cloud browser. Use for structured website tasks, and authenticated site access with Unbrowse.
4
4
  ---
5
5
 
6
6
  # Unbrowse
7
7
 
8
- Use the hosted service at `https://unbrowse.ai`. Execution, indexed routes and website sessions stay server-side. This skill supplies operating guidance; it does not authenticate the user or start a local MCP server.
8
+ Use the hosted service at `https://unbrowse.ai`. Execution, indexed routes and website sessions stay server-side. This skill supplies operating guidance; signing in is OAuth, below.
9
9
 
10
- ## Connect
10
+ ## Onboarding: sign in with OAuth
11
11
 
12
- Prefer the remote MCP for agents:
12
+ Sign-in is OAuth in the person's browser: an emailed sign-in link, then **Allow**. No password, and nothing to paste. Never ask the person for a token or key in chat.
13
+
14
+ Check first, then sign in only what is missing:
15
+
16
+ 1. MCP: if `unbrowse_discover` is in this session's tool list, the MCP is signed in.
17
+ 2. CLI: `npx unbrowse whoami`. Exit 0 means signed in. Exit 3 means not signed in.
18
+
19
+ Sign in the MCP (agent hosts):
13
20
 
14
21
  ```sh
15
22
  claude mcp add --transport http unbrowse https://unbrowse.ai/mcp
16
23
  ```
17
24
 
18
- Complete sign-in through the MCP client's OAuth flow. Other clients can use:
19
-
20
25
  ```json
21
26
  {"mcpServers":{"unbrowse":{"url":"https://unbrowse.ai/mcp"}}}
22
27
  ```
23
28
 
24
- CLI installation and SDK instructions: https://github.com/unbrowse-ai/unbrowse-skill#readme
25
- Use the client version identified there; older npm versions may target a different service.
26
- For automation, supply an API key via `UNBROWSE_API_KEY` using the caller's secret manager. Do not put keys into committed config, prompts, command arguments or logs. Create a key in the signed-in console at https://unbrowse.ai/app.
29
+ The host runs the OAuth sign-in itself (in Claude Code: `/mcp`, pick `unbrowse`, Authenticate). Do not put a bearer header in the config; with one set, hosts skip OAuth. A URL in a config is not a signed-in session: until the host finishes OAuth, the Unbrowse tools are not listed.
30
+
31
+ Sign in the CLI:
32
+
33
+ ```sh
34
+ npx skills add unbrowse-ai/unbrowse && npx unbrowse login
35
+ ```
36
+
37
+ `unbrowse login` opens the sign-in page in the browser on this machine. The person enters their email, opens the link, presses **Allow**; the CLI prints `Signed in to https://unbrowse.ai (workspace ws_…)` and stores the token at `~/.config/unbrowse/cli.json` (mode 0600, refreshed automatically).
38
+
39
+ From an agent's shell (no terminal for the person): run `npx unbrowse login --no-open` in the background, give the person the `https://unbrowse.ai/authorize?…` link it prints, and wait for the `Signed in` line. The link returns to `127.0.0.1` on this machine, so the person must open it in a browser on the same machine. On a remote or headless box, use an API key instead (below). Any other command run with no sign-in starts the same browser sign-in when it has a terminal; without one it exits 3 and asks for `unbrowse login`.
40
+
41
+ Then the first call: `npx unbrowse run 'top stories on hacker news'`. The site requests go from the person's own IP by default; `--from-unbrowse` sends them from Unbrowse instead.
42
+
43
+ `npx unbrowse mcp` (a stdio MCP for hosts that need one) uses the CLI sign-in. A remote MCP in a host config uses only that host's own OAuth: one sign-in does not cover the other, and the CLI token does not go into an MCP config.
44
+
45
+ For automation and CI without a browser, set `UNBROWSE_API_KEY` from the caller's secret manager (create a key in the signed-in console at https://unbrowse.ai/app). Never put keys into committed config, prompts, command arguments or logs.
46
+
47
+ CLI and SDK: https://github.com/unbrowse-ai/unbrowse
27
48
 
28
49
  ## Host plugins
29
50
 
@@ -38,45 +59,67 @@ Hosts that need a stdio server or reject dotted tool names can run `npx unbrowse
38
59
 
39
60
  ## Choose the interface
40
61
 
41
- - MCP: discovery, runs, page reading, cloud browsing, saved-login requests and live canvas cards.
42
- - CLI: `unbrowse discover`, `run`, `inspect`, `resume`, `registry`. It calls the REST API and is not an MCP client. `unbrowse help` describes the installed version.
62
+ - MCP: discovery, runs, page reading, cloud browsing, indexing and saved-login requests. These names are MCP tools. They are not CLI commands.
63
+ - CLI: `unbrowse discover`, `run`, `inspect`, `resume`, `scrape <url>` (one page as markdown), `index <url>` (teach a site; `index status`), `registry`, `site`, `whoami`. `scrape` and `index` need CLI 12.2.0 or later. `unbrowse run` never drives a website in a browser (the only browser it opens is the first-use sign-in). There is no `unbrowse browse` and no `unbrowse install`. `unbrowse help` describes the installed version.
43
64
  - SDK: REST integration and scripting. Consult the public SDK docs for its supported methods; MCP tools and REST methods are not interchangeable names.
44
65
 
45
- Core MCP tools: `unbrowse.discover`, `unbrowse.run`, `unbrowse.inspect`, `unbrowse.resume`, `unbrowse.cancel`, `unbrowse.scrape`, `unbrowse.map`, `unbrowse.sites`, `unbrowse.usage`, `unbrowse.credits`, `unbrowse.forget`, `unbrowse.learn`, `unbrowse.index`, `unbrowse.index.status`, `unbrowse.credentials.list`, `unbrowse.credentials.request`, `unbrowse.credentials.status`, and the cloud browser `unbrowse.browse.open`, `unbrowse.browse.snapshot`, `unbrowse.browse.act`, `unbrowse.browse.finish`, `unbrowse.browse.close`.
66
+ Core MCP tools: `unbrowse_discover`, `unbrowse_run`, `unbrowse_inspect`, `unbrowse_resume`, `unbrowse_cancel`, `unbrowse_scrape`, `unbrowse_map`, `unbrowse_sites`, `unbrowse_usage`, `unbrowse_credits`, `unbrowse_forget`, `unbrowse_learn`, `unbrowse_index`, `unbrowse_index_status`, `unbrowse_credentials_list`, `unbrowse_credentials_request`, `unbrowse_credentials_status`, `unbrowse_connect` (connect an app's own MCP server, such as Linear, Notion or GitHub, so its tools run as the person: an app with sign-in returns a link the person opens), and the cloud browser `unbrowse_browse_open`, `unbrowse_browse_snapshot`, `unbrowse_browse_act`, `unbrowse_browse_finish`, `unbrowse_browse_close`.
46
67
 
47
68
  [references/tools.json](references/tools.json) contains the exported core MCP input schemas. The connected server's `tools/list` is authoritative: it also includes dynamic tools available to this user's workspace. Never invent a capability ID or input schema.
48
69
 
49
70
  ## Execute a task
50
71
 
51
- 1. Discover with `unbrowse.discover {query}`. Inspect returned inputs, choices and hints. Prefer a healthy matching capability; `warm` means HTTP replay, `rendered` needs rendering. Check `unbrowse.sites` for saved session and login state when relevant.
52
- 2. Call the selected tool with its listed schema, or `unbrowse.run {capability, input}`. A natural-language `task` can route when no ID was selected. Use a stable `idempotencyKey` for the same intended mutation.
53
- 3. Inspect the returned status and actual result. `input_required` means answer the open requirements on the **same** run: `unbrowse.resume {runId, answers:{field:value}}`. For a choice, pass the listed option's value. Preserve revision checks when supplied.
54
- 4. `no_capability` means no reusable route matched. If browsing is available, do the task through `unbrowse.browse.*`, then finish to learn it. Report unsupported or blocked sites honestly.
72
+ 1. Discover with `unbrowse_discover {query}`. Inspect returned inputs, choices and hints. Prefer a healthy matching capability; `warm` means HTTP replay, `rendered` needs rendering. Check `unbrowse_sites` for saved session and login state when relevant. Public tools carry `version`, the Unbrowse version that generated them (YYYY.MM.DD); among equal matches the newest comes first, and `minVersion` leaves older ones out.
73
+ 2. Call the selected tool with its listed schema, or `unbrowse_run {capability, input}`. A natural-language `task` can route when no ID was selected. Use a stable `idempotencyKey` for the same intended mutation. For a large answer pass `select` (MCP run tools, `unbrowse_resume`, `unbrowse_inspect`, `POST /api/v1/runs`): paths like `["results[].{id,title,price}", "total"]`. It narrows only what comes back, after verification; billing is unchanged. Results over 40,000 characters are shortened (`truncated: true`); `selectMissing` lists paths that matched nothing.
74
+ 3. Inspect the returned status and actual result. `input_required` means answer the open requirements on the **same** run: `unbrowse_resume {runId, answers:{field:value}}`. For a choice, pass the listed option's value. Preserve revision checks when supplied.
75
+ 4. `no_capability` means no reusable route matched. Follow `result.next`: `tool` is `unbrowse_index` (`POST /api/v1/index`, then `GET /api/v1/index/{jobId}`; CLI `unbrowse index <url>`). To answer now, read the page instead: `unbrowse_scrape` (CLI `unbrowse scrape <url>`). Call `unbrowse_browse_open` only when that name is in this session's tool list. Do not POST `/api/v1/browse/open`. It is not a route. Report unsupported or blocked sites honestly.
55
76
  5. Only report completion from a verified result. `outcome_unknown` means a change may have occurred: inspect the effect receipt and destination before retrying. Cancellation stops future dispatches; it does not undo completed effects.
56
77
 
57
78
  Do not infer business success from HTTP 200, tool transport success, a screenshot, or a generated plan. Do not promise universal coverage or browserless execution on every first request. Obtain the user's authorization for posting, sending, purchasing or other external writes.
58
79
 
80
+ ## Unbrowse a URL
81
+
82
+ When the person names a site:
83
+
84
+ 1. If `unbrowse_discover` is not in this session's tool list, the MCP is not signed in. Stop. Name the configured MCP URL and say the CLI login does not cover it.
85
+ 2. Look the host up (`unbrowse_sites`, or CLI `unbrowse site <host>`). Tools already compiled: use one. Stop.
86
+ 3. No tools: `unbrowse_index {url, focus}` or `POST /api/v1/index`. Poll `unbrowse_index_status` or `GET /api/v1/index/{jobId}`.
87
+ 4. `status: failed` and `error.code: model_unavailable`: the indexing model is out of credit. Report the job id and the message. Do not browse instead, and do not start the same job again in a loop.
88
+ 5. `status: done` with `indexed: 0` means nothing was learned. Say so. `indexed > 0` means call one tool and check the result.
89
+
90
+ A 202 from `/api/v1/index` is a job id, not a compiled tool.
91
+
92
+ ## A site's tools over plain HTTP
93
+
94
+ Each compiled site is also a REST API, for code rather than an agent session:
95
+
96
+ - `GET https://unbrowse.ai/api/v1/sites/<host>/openapi.json`: OpenAPI 3.1, one operation per tool, typed inputs, an `example` input it was verified with, every status and header. No key needed to read.
97
+ - `POST https://unbrowse.ai/api/v1/sites/<host>/call/<tool>` with the tool's inputs as the JSON body and `Authorization: Bearer <key>`. Options: `x-unbrowse-deadline-ms`, `Idempotency-Key`, `select`. `202` means `input_required`; `504 run_timeout` gives a `runId` to poll; `409 tool_quarantined` means use another tool.
98
+ - SDK: `new Unbrowse().callTool(host, tool, input)`.
99
+
100
+ Contract and examples: https://unbrowse.ai/docs/site-apis.md
101
+
59
102
  ## Read or learn a site
60
103
 
61
- Use `unbrowse.scrape {url}` for a page; `unbrowse.map {url}` finds same-site pages. For interactive work with no matching route:
104
+ Prefer `unbrowse_discover` and a matching tool or `unbrowse_run` for structured data and site tasks. `unbrowse_scrape {url}` is a **last resort for static pages and documents**, only when no suitable API or learned tool is available. A PDF, .docx, .xls or .xlsx URL comes back as extracted markdown text (`metadata.pages` for PDFs; spreadsheets preserve sheet names, rows and formatted values). `metadata.truncated` marks bounded extraction; `formats: ["raw"]` returns the exact document bytes as base64; `unbrowse_map {url}` finds same-site URLs. A known URL or scrape's rendering support does not make it the default. For dynamic content, search, pagination or interaction with no matching route, use `unbrowse_index` or the available cloud browser tools to learn and replay the site's API:
62
105
 
63
- 1. `unbrowse.browse.open {url,task}` returns the page and element refs.
106
+ 1. `unbrowse_browse_open {url,task}` returns the page and element refs.
64
107
  2. Use `browse.act` with the latest refs. For ordinary inputs, include a meaningful `name` such as `date` or `query`; exercise every filter the task needs. Refresh the snapshot after page changes.
65
108
  3. Use `browse.finish {sessionId}` to return the final page and compile observed routes. Two sessions with different inputs help identify reusable parameters. Check `learnError` and `newTool`; browsing success alone does not prove a reusable route exists.
66
109
  4. Close sessions when finished. `browse.close` still indexes unless `discard:true`.
67
110
 
68
- To cover a whole site ahead of need, `unbrowse.index {url, focus?}` starts a background job: Unbrowse's own agent performs the site's core read-only capabilities, proves each with a browserless replay and adds them to your tools. Follow it with `unbrowse.index.status {jobId}`.
111
+ To cover a whole site ahead of need, `unbrowse_index {url, focus?, maxCapabilities?}` starts a background job: Unbrowse's own agent performs the site's core read-only capabilities, proves each with a browserless replay and adds them to your tools. Follow it with `unbrowse_index_status {jobId}`. `maxCapabilities` caps every tool the job indexes (declared, sitemap page types and recorded flows together). A `focus` keeps only sitemap page types that match it, and none when it names flows such as paging, page size, filters or search. Query keys in the start URL (`?page=0&pageSize=100`) become the tool's inputs. `stoppedReason` says why a job ended. The time budget is extended once, by half, while tools are still being proven.
69
112
 
70
- An existing HAR pair can be sent through `unbrowse.learn`. Only submit recordings the user authorized; HARs can contain private data. Private and loopback destinations are refused by the hosted service.
113
+ An existing HAR pair can be sent through `unbrowse_learn`. Only submit recordings the user authorized; HARs can contain private data. Private and loopback destinations are refused by the hosted service.
71
114
 
72
115
  ## Website sign-in
73
116
 
74
117
  Unbrowse account sign-in and a website's saved login are separate. Never ask for passwords in chat or type credentials via ordinary tool arguments.
75
118
 
76
119
  - On a login page, use `browse.act {sessionId,action:"autofill"}`, or `vault:"username"|"email"|"password"|"totp"` on a fill action. Values go directly from the vault to the site.
77
- - Missing login: present the returned `signIn.url` or `details.url` save-login link. `unbrowse.credentials.request` can create one; `credentials.status` checks whether it was fulfilled. Resume only after it is ready.
120
+ - Missing login: present the returned `signIn.url` or `details.url` save-login link. `unbrowse_credentials_request` can create one; `credentials.status` checks whether it was fulfilled. Resume only after it is ready.
78
121
  - Do not bypass CAPTCHA, MFA or human verification. Present the supported handoff or report the blocker.
79
- - Saved sessions are reused; do not sign in again merely because another task started.
122
+ - Saved sessions are reused automatically (the person can turn that off per site or for the whole workspace); do not sign in again merely because another task started.
80
123
 
81
124
  Read-only secretless learned routes may be scrubbed and shared to the public registry. The owner can opt out in the console. Logins, private session values and writes are not public tool definitions.
82
125
 
@@ -85,24 +128,17 @@ Read-only secretless learned routes may be scrubbed and shared to the public reg
85
128
  When the caller is an agent a builder runs for its own users, it uses an org key and names the user on every call: `X-Unbrowse-End-User: <that user's id>` (REST and MCP headers). Each user has their own logins and sessions.
86
129
 
87
130
  - Always send the id of the user the task is for. Never reuse one user's id for another user's task, and never omit it: without it the call acts as the org itself, not any user.
88
- - A `signIn.url` (a `/connect/…` link) is for that same user: deliver it to them, not to the builder or another user. They save the login there without an Unbrowse account; wait for `unbrowse.credentials.status` to be `fulfilled`, then call again.
131
+ - A `signIn.url` (a `/connect/…` link) is for that same user: deliver it to them, not to the builder or another user. They save the login there without an Unbrowse account; wait for `unbrowse_credentials_status` to be `fulfilled`, then call again.
89
132
  - `org__…` tools are shared by the org's users (read-only, no logins); `my__…` tools are the current user's own.
90
133
  - Quota errors are the org's balance, not the user's. Report them to the builder.
91
134
 
92
135
  Guide: https://github.com/lekt9/unbrowse6/blob/master/docs/orgs.md
93
136
 
94
- ## Live canvas
95
-
96
- When `unbrowse.canvas.read` and `.put` are listed, they connect to https://unbrowse.ai/app/canvas in the same signed-in workspace.
97
-
98
- Use notes and plans for static text; results for source data; drafts for proposed responses. Give child cards `parentId` to unfold from a result. Read current card revisions before updating; supply `expectedRevision` and preserve human edits. Put source links beside factual claims. Label proposed text as a draft.
99
-
100
- `canvas.put` creates cards, not external sends. Preparing reply drafts does not authorize posting them. Sending is reviewed separately in the canvas UI.
101
-
102
137
  ## Limits and recovery
103
138
 
104
- - 401: reconnect Unbrowse or replace the caller's expired key.
105
- - Quota/payment error: show the returned limit and console link; do not retry payments blindly. When listed, `unbrowse.credits` shows free/paid balances and can return a checkout link for the user. Opening a billing link does not authorize payment.
139
+ - 401: sign that door in again with OAuth. CLI 401: `npx unbrowse login`. Remote MCP 401: the host's own OAuth for that server (Claude Code: `/mcp`). One sign-in does not fix the other.
140
+ - `model_unavailable` on an index job: the indexing model is out of credit. Report the job id. No tools were compiled. This is not `unbrowse_usage` and not the site.
141
+ - Quota/payment error: show the returned limit and console link; do not retry payments blindly. When listed, `unbrowse_credits` shows free/paid balances and can return a checkout link for the user. Opening a billing link does not authorize payment.
106
142
  - Verification or login block: use the returned handoff; don't present a challenge page as source content.
107
143
  - Timeout on a write: inspect the existing run before retrying.
108
- - Pricing and quotas: consult the account's current plan and `unbrowse.usage`; this skill does not fix prices.
144
+ - Pricing and quotas: consult the account's current plan and `unbrowse_usage`; this skill does not fix prices.