@b3os/cli 0.2.1 → 0.2.2

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.
Files changed (214) hide show
  1. package/README.md +87 -8
  2. package/assets/b3os-run.py +137 -0
  3. package/assets/skill/b3os/SKILL.md +111 -0
  4. package/dist/commands/_agents.d.ts +14 -0
  5. package/dist/commands/_agents.js +33 -0
  6. package/dist/commands/_agents.js.map +1 -0
  7. package/dist/commands/_common.js +6 -2
  8. package/dist/commands/_common.js.map +1 -1
  9. package/dist/commands/_context.d.ts +49 -0
  10. package/dist/commands/_context.js +260 -0
  11. package/dist/commands/_context.js.map +1 -0
  12. package/dist/commands/_next.d.ts +39 -0
  13. package/dist/commands/_next.js +77 -0
  14. package/dist/commands/_next.js.map +1 -0
  15. package/dist/commands/agent.d.ts +42 -0
  16. package/dist/commands/agent.js +218 -0
  17. package/dist/commands/agent.js.map +1 -0
  18. package/dist/commands/app.d.ts +2 -5
  19. package/dist/commands/app.js +229 -69
  20. package/dist/commands/app.js.map +1 -1
  21. package/dist/commands/auth.d.ts +70 -2
  22. package/dist/commands/auth.js +308 -33
  23. package/dist/commands/auth.js.map +1 -1
  24. package/dist/commands/docs.d.ts +54 -0
  25. package/dist/commands/docs.js +202 -0
  26. package/dist/commands/docs.js.map +1 -0
  27. package/dist/commands/doctor.d.ts +23 -0
  28. package/dist/commands/doctor.js +313 -0
  29. package/dist/commands/doctor.js.map +1 -0
  30. package/dist/commands/init.d.ts +38 -1
  31. package/dist/commands/init.js +259 -60
  32. package/dist/commands/init.js.map +1 -1
  33. package/dist/commands/listen.d.ts +30 -0
  34. package/dist/commands/listen.js +194 -0
  35. package/dist/commands/listen.js.map +1 -0
  36. package/dist/commands/manifest.d.ts +13 -1
  37. package/dist/commands/manifest.js +59 -7
  38. package/dist/commands/manifest.js.map +1 -1
  39. package/dist/commands/mcp.d.ts +25 -2
  40. package/dist/commands/mcp.js +120 -11
  41. package/dist/commands/mcp.js.map +1 -1
  42. package/dist/commands/sandbox.d.ts +35 -6
  43. package/dist/commands/sandbox.js +208 -9
  44. package/dist/commands/sandbox.js.map +1 -1
  45. package/dist/commands/setup.d.ts +39 -0
  46. package/dist/commands/setup.js +203 -0
  47. package/dist/commands/setup.js.map +1 -0
  48. package/dist/commands/tool.d.ts +109 -1
  49. package/dist/commands/tool.js +635 -47
  50. package/dist/commands/tool.js.map +1 -1
  51. package/dist/config.d.ts +30 -6
  52. package/dist/config.js +39 -8
  53. package/dist/config.js.map +1 -1
  54. package/dist/ctx.d.ts +5 -45
  55. package/dist/ctx.js +25 -160
  56. package/dist/ctx.js.map +1 -1
  57. package/dist/docs/index.json +1 -0
  58. package/dist/docs/pages/actions/call.md +300 -0
  59. package/dist/docs/pages/actions/catalog/airtable.md +737 -0
  60. package/dist/docs/pages/actions/catalog/arxiv.md +166 -0
  61. package/dist/docs/pages/actions/catalog/chainalysis-sanctions.md +125 -0
  62. package/dist/docs/pages/actions/catalog/coingecko.md +1558 -0
  63. package/dist/docs/pages/actions/catalog/deps-dev.md +465 -0
  64. package/dist/docs/pages/actions/catalog/dexscreener.md +568 -0
  65. package/dist/docs/pages/actions/catalog/discord.md +784 -0
  66. package/dist/docs/pages/actions/catalog/finnhub.md +776 -0
  67. package/dist/docs/pages/actions/catalog/frankfurter.md +438 -0
  68. package/dist/docs/pages/actions/catalog/github.md +1853 -0
  69. package/dist/docs/pages/actions/catalog/gmail.md +575 -0
  70. package/dist/docs/pages/actions/catalog/google-calendar.md +654 -0
  71. package/dist/docs/pages/actions/catalog/google-drive.md +502 -0
  72. package/dist/docs/pages/actions/catalog/google-sheets.md +700 -0
  73. package/dist/docs/pages/actions/catalog/hacker-news.md +542 -0
  74. package/dist/docs/pages/actions/catalog/http.md +824 -0
  75. package/dist/docs/pages/actions/catalog/hyperliquid.md +942 -0
  76. package/dist/docs/pages/actions/catalog/jira.md +920 -0
  77. package/dist/docs/pages/actions/catalog/kalshi.md +917 -0
  78. package/dist/docs/pages/actions/catalog/linear.md +1030 -0
  79. package/dist/docs/pages/actions/catalog/markets.md +21 -0
  80. package/dist/docs/pages/actions/catalog/morpho.md +247 -0
  81. package/dist/docs/pages/actions/catalog/notion.md +1077 -0
  82. package/dist/docs/pages/actions/catalog/nws.md +485 -0
  83. package/dist/docs/pages/actions/catalog/open-meteo.md +559 -0
  84. package/dist/docs/pages/actions/catalog/polymarket.md +1523 -0
  85. package/dist/docs/pages/actions/catalog/pushbullet.md +220 -0
  86. package/dist/docs/pages/actions/catalog/resend.md +307 -0
  87. package/dist/docs/pages/actions/catalog/s3.md +513 -0
  88. package/dist/docs/pages/actions/catalog/sec-edgar.md +487 -0
  89. package/dist/docs/pages/actions/catalog/slack.md +2629 -0
  90. package/dist/docs/pages/actions/catalog/stripe.md +1405 -0
  91. package/dist/docs/pages/actions/catalog/wikipedia.md +379 -0
  92. package/dist/docs/pages/actions/catalog.md +46 -0
  93. package/dist/docs/pages/actions/limits.md +50 -0
  94. package/dist/docs/pages/actions/model-tools.md +225 -0
  95. package/dist/docs/pages/actions/packs.md +148 -0
  96. package/dist/docs/pages/actions/settings.md +69 -0
  97. package/dist/docs/pages/actions/tools.md +244 -0
  98. package/dist/docs/pages/actions/triggers.md +149 -0
  99. package/dist/docs/pages/actions.md +88 -0
  100. package/dist/docs/pages/compat/anthropic.md +168 -0
  101. package/dist/docs/pages/compat/e2b.md +194 -0
  102. package/dist/docs/pages/compat/firecrawl.md +138 -0
  103. package/dist/docs/pages/compat/openai.md +168 -0
  104. package/dist/docs/pages/concepts/auth.md +151 -0
  105. package/dist/docs/pages/concepts/beta.md +55 -0
  106. package/dist/docs/pages/concepts/glossary.md +71 -0
  107. package/dist/docs/pages/concepts/ids.md +98 -0
  108. package/dist/docs/pages/concepts/jobs.md +229 -0
  109. package/dist/docs/pages/concepts/latency.md +138 -0
  110. package/dist/docs/pages/concepts/limits.md +191 -0
  111. package/dist/docs/pages/concepts/stack.md +59 -0
  112. package/dist/docs/pages/concepts/timing.md +86 -0
  113. package/dist/docs/pages/concepts/usage.md +110 -0
  114. package/dist/docs/pages/design/b3os-yaml.md +370 -0
  115. package/dist/docs/pages/design/deploy-from-github.md +122 -0
  116. package/dist/docs/pages/design/observability.md +134 -0
  117. package/dist/docs/pages/errors.md +1824 -0
  118. package/dist/docs/pages/infer/chat.md +570 -0
  119. package/dist/docs/pages/infer/limits.md +55 -0
  120. package/dist/docs/pages/infer/messages.md +185 -0
  121. package/dist/docs/pages/infer/responses.md +173 -0
  122. package/dist/docs/pages/infer/settings.md +154 -0
  123. package/dist/docs/pages/infer/speech.md +323 -0
  124. package/dist/docs/pages/infer.md +154 -0
  125. package/dist/docs/pages/introduction.md +162 -0
  126. package/dist/docs/pages/platform/addresses.md +174 -0
  127. package/dist/docs/pages/platform/call-log.md +99 -0
  128. package/dist/docs/pages/platform/custom-domains.md +104 -0
  129. package/dist/docs/pages/platform/keys.md +79 -0
  130. package/dist/docs/pages/platform/limits.md +57 -0
  131. package/dist/docs/pages/platform/members.md +101 -0
  132. package/dist/docs/pages/platform/requests.md +116 -0
  133. package/dist/docs/pages/platform/settings.md +129 -0
  134. package/dist/docs/pages/platform/webhooks.md +68 -0
  135. package/dist/docs/pages/platform.md +67 -0
  136. package/dist/docs/pages/quickstart/mcp.md +94 -0
  137. package/dist/docs/pages/quickstart/sandbox-agent.md +205 -0
  138. package/dist/docs/pages/quickstart/scrape.md +134 -0
  139. package/dist/docs/pages/quickstart.md +45 -0
  140. package/dist/docs/pages/render/inspections.md +162 -0
  141. package/dist/docs/pages/render/limits.md +72 -0
  142. package/dist/docs/pages/render/screenshots.md +179 -0
  143. package/dist/docs/pages/render/settings.md +431 -0
  144. package/dist/docs/pages/render/styles.md +342 -0
  145. package/dist/docs/pages/render/videos.md +272 -0
  146. package/dist/docs/pages/render.md +118 -0
  147. package/dist/docs/pages/routines/callables.md +174 -0
  148. package/dist/docs/pages/routines/definitions.md +361 -0
  149. package/dist/docs/pages/routines/limits.md +117 -0
  150. package/dist/docs/pages/routines/runs.md +328 -0
  151. package/dist/docs/pages/routines/settings.md +104 -0
  152. package/dist/docs/pages/routines/triggers.md +339 -0
  153. package/dist/docs/pages/routines.md +216 -0
  154. package/dist/docs/pages/sandboxes/agents.md +217 -0
  155. package/dist/docs/pages/sandboxes/commands.md +272 -0
  156. package/dist/docs/pages/sandboxes/images.md +166 -0
  157. package/dist/docs/pages/sandboxes/limits.md +143 -0
  158. package/dist/docs/pages/sandboxes/ports.md +260 -0
  159. package/dist/docs/pages/sandboxes/settings.md +358 -0
  160. package/dist/docs/pages/sandboxes/snapshots.md +423 -0
  161. package/dist/docs/pages/sandboxes/swarms.md +146 -0
  162. package/dist/docs/pages/sandboxes/volumes.md +131 -0
  163. package/dist/docs/pages/sandboxes.md +231 -0
  164. package/dist/docs/pages/sdks/cli.md +121 -0
  165. package/dist/docs/pages/sdks/mcp.md +169 -0
  166. package/dist/docs/pages/sdks/python.md +146 -0
  167. package/dist/docs/pages/sdks/typescript.md +202 -0
  168. package/dist/docs/pages/sdks.md +282 -0
  169. package/dist/docs/pages/settings.md +33 -0
  170. package/dist/docs/pages/vault/limits.md +46 -0
  171. package/dist/docs/pages/vault.md +133 -0
  172. package/dist/docs/pages/vision/agent-browser.md +115 -0
  173. package/dist/docs/pages/vision/crawl.md +333 -0
  174. package/dist/docs/pages/vision/extract.md +152 -0
  175. package/dist/docs/pages/vision/fetcher.md +15 -0
  176. package/dist/docs/pages/vision/limits.md +79 -0
  177. package/dist/docs/pages/vision/profiles.md +111 -0
  178. package/dist/docs/pages/vision/proxy.md +131 -0
  179. package/dist/docs/pages/vision/scrape.md +356 -0
  180. package/dist/docs/pages/vision/sessions.md +311 -0
  181. package/dist/docs/pages/vision/settings.md +656 -0
  182. package/dist/docs/pages/vision.md +175 -0
  183. package/dist/errors.d.ts +129 -0
  184. package/dist/errors.js +326 -0
  185. package/dist/errors.js.map +1 -0
  186. package/dist/main.d.ts +1 -1
  187. package/dist/main.js +26 -13
  188. package/dist/main.js.map +1 -1
  189. package/dist/manifest/domains.d.ts +50 -0
  190. package/dist/manifest/domains.js +159 -0
  191. package/dist/manifest/domains.js.map +1 -0
  192. package/dist/manifest/link.d.ts +20 -0
  193. package/dist/manifest/link.js +24 -0
  194. package/dist/manifest/link.js.map +1 -0
  195. package/dist/manifest/record.d.ts +1 -1
  196. package/dist/tool/archive.d.ts +33 -0
  197. package/dist/tool/archive.js +174 -0
  198. package/dist/tool/archive.js.map +1 -0
  199. package/dist/tool/calls.d.ts +46 -0
  200. package/dist/tool/calls.js +274 -0
  201. package/dist/tool/calls.js.map +1 -0
  202. package/dist/tool/checks.d.ts +21 -0
  203. package/dist/tool/checks.js +145 -0
  204. package/dist/tool/checks.js.map +1 -0
  205. package/dist/tool/elf.d.ts +19 -0
  206. package/dist/tool/elf.js +107 -0
  207. package/dist/tool/elf.js.map +1 -0
  208. package/dist/tool/predict.d.ts +8 -0
  209. package/dist/tool/predict.js +38 -0
  210. package/dist/tool/predict.js.map +1 -0
  211. package/dist/tool/ustar.d.ts +5 -0
  212. package/dist/tool/ustar.js +220 -0
  213. package/dist/tool/ustar.js.map +1 -0
  214. package/package.json +6 -5
@@ -0,0 +1,79 @@
1
+ # Vision limits and FAQ
2
+
3
+ > Rate, concurrency and size limits for scrapes, crawls and browser sessions in the beta, and answers to common questions about vision.
4
+
5
+ Source: https://docs.beta.b3os.org/vision/limits.md
6
+
7
+ ## Limits
8
+
9
+ Per organization, beta defaults. `GET /v1/limits` shows yours with current usage.
10
+
11
+ | Limit | Default |
12
+ |---|---|
13
+ | Scrapes per minute (`vision.scrape.rpm`) | 60 |
14
+ | Scrapes at once (`vision.scrape.concurrent`) | 5 |
15
+ | Crawls at once (`vision.crawl.concurrent`) | 1 |
16
+ | Pages per crawl (`vision.crawl.pages_max`) | 500 |
17
+ | Browser sessions at once (`vision.sessions.concurrent`), counting scrapes with a `profile` while they run | 5 |
18
+ | Pages per month (`vision.pages.monthly`) | 100,000 to start; past it scrapes answer `429 quota_exceeded` until the next UTC month |
19
+ | Session lifetime (`vision.session.timeout_max`) | 1,800 seconds |
20
+
21
+ Per request:
22
+
23
+ | Request | Limit |
24
+ |---|---|
25
+ | Scrape | `timeout_ms` up to 60 seconds; up to 50 browser actions; URL up to 8,192 characters; body up to 1 MiB |
26
+ | Map | `limit` up to 5,000 URLs |
27
+ | Batch | Up to 1,000 URLs; body up to 4 MiB |
28
+ | Crawl | `limit` up to 500 pages, `max_depth` up to 20 |
29
+ | Session `act` | Up to 100 actions, `timeout_ms` up to 60 seconds |
30
+ | Profile | State up to 5 MiB, 3,000 cookies and 500 origins; up to 32 domains |
31
+ | Page markup | Elements nested more than 1,024 levels deep lose their tags and keep their text; markup that would take too long to parse is read up to that point. Either adds an entry to `warnings` |
32
+
33
+ A request over a size limit fails with [`limit_exceeded`](https://docs.beta.b3os.org/errors#limit_exceeded) or [`payload_too_large`](https://docs.beta.b3os.org/errors#payload_too_large); a rate or concurrency limit returns `429` with `Retry-After`. See [limits](https://docs.beta.b3os.org/concepts/limits).
34
+
35
+ ## Retention
36
+
37
+ Cached pages: 2 days. Crawl and batch records with their pages, and closed sessions: 7 days after they end. Profiles: until you delete them or their `expires_at`.
38
+
39
+ ## Fixed in the beta
40
+
41
+ No request field changes these in the beta.
42
+
43
+ - [**TLS verification**](https://docs.beta.b3os.org/vision/settings#tls-verification): Always on. Vision checks every site's certificate. A site with an expired, self-signed or mismatched certificate fails, and retrying does not help: the fetch answers `502 upstream_unreachable` with `reason: tls`, and the browser `502 navigation_failed` with Chrome's certificate error. The Firecrawl surface accepts `skipTlsVerification` and ignores it.
44
+ - [**PDF files**](https://docs.beta.b3os.org/vision/settings#pdf-files): Read from their text layer. A URL that serves a PDF (its type says so, or an untyped or octet-stream body starts with `%PDF-`) is read by the HTTP fetch tier, never in a browser: Markdown in reading order with headings, lists, clear tables and links, pages joined by Firecrawl's page marker (an HTML comment naming the page number). It bills one `vision.page` per page read. Pages without a text layer (scans) come back empty with a warning, as there is no OCR yet. `pdf.mode: off`, and on the Firecrawl surface `parsers: []` or `parsePDF: false`, answer `422 content_type_unsupported` instead.
45
+ - [**Challenge pages**](https://docs.beta.b3os.org/vision/settings#challenge-pages): Not waited on. Vision does not wait for a Cloudflare or Akamai challenge to pass, and never solves a CAPTCHA. A challenge comes back as `page_state` `captcha` or `blocked`, which is free under `walls: free`.
46
+ - [**Walled pages in full Chrome**](https://docs.beta.b3os.org/vision/settings#walled-pages-in-full-chrome): On. A page from the scrape pool that comes back a wall is read once more in a full Chrome browser of your organization's own, and that answer is used when it is not a wall; a warning says so. It adds time to a walled page and takes none of your `vision.sessions.concurrent` places. It is skipped when the request names `browser` or runs `actions`.
47
+ - [**Model for structured data**](https://docs.beta.b3os.org/vision/settings#model-for-structured-data): The node's default chat model. The `json` format asks `b3os/default` (see [Infer](https://docs.beta.b3os.org/infer#models)) for at most 2,048 tokens per call, at most two calls per page. When no answer is JSON, the page comes back without `json` and with a warning.
48
+ - [**Spacing between job pages**](https://docs.beta.b3os.org/vision/settings#spacing-between-job-pages): 250 ms per host. Pages of batches and crawls to one host start at least 250 ms apart across every organization on the node, with at most 2 in flight for one organization and 2 for all. A crawl's `delay_ms` can only add to it. Single scrapes are not spaced.
49
+ - [**Proxy on other surfaces**](https://docs.beta.b3os.org/vision/settings#proxy-on-other-surfaces): Node address. Batches, crawls, sessions and the Firecrawl surface leave from the node's own address. A session's CDP socket refuses a browser context with proxy settings of its own. The Firecrawl surface's `proxy: "enhanced"` and `"stealth"` answer `400 unsupported_option`.
50
+
51
+ ## FAQ
52
+
53
+ **Why did my scrape use a browser?**
54
+
55
+ With `engine: "auto"`, vision starts a browser when a page needs JavaScript to show its content, when the fetch came back thin or mostly script, and when the fetch failed in a way a browser may not. Browser actions, a `screenshot` format and a `profile` always need one. Set `engine: "fetch"` to forbid it; pages that build their content with JavaScript may then come back incomplete.
56
+ **Why is cache.state bypass?**
57
+
58
+ The request had custom headers, a profile or browser actions, or the site set cookies. Those results are fetched fresh and never shared with other organizations.
59
+ **Does a 404 page fail the scrape?**
60
+
61
+ No. A page the site served with an error status is still a successful scrape, billed as one page; check `status_code`. A scrape fails when vision cannot fetch or convert the page at all, for example on a timeout or a network error.
62
+ **Do failed scrapes count?**
63
+
64
+ No. A scrape that returns no page (an upstream error, a timeout, an egress refusal or a failed extraction) records no `vision.page`, so it does not count toward your page allowance. In a batch or crawl only the pages that succeeded count. A wall (`page_state` `blocked` or `captcha`) does not count either, and its content is withheld (`content_withheld: true`) unless you set `walls: "bill"`.
65
+ **Does vision check robots.txt?**
66
+
67
+ Only when you ask: set `respect_robots: true` on a scrape, batch, crawl or map (`X-B3OS-Respect-Robots: true` on `r/{url}`). A URL that robots.txt or Content Signals then disallow fails with `robots_disallowed`, and a crawl lists the URLs it skipped in `result.robots_blocked`.
68
+ **Can I bring my own proxy?**
69
+
70
+ Yes, on single scrapes. Set `proxy` to your proxy's `http://host:port`, with its username and password in a vault connection. Batches, crawls and sessions leave from the node's address for now, and a session's CDP socket still refuses browser contexts with proxy settings of their own. See [Proxies](https://docs.beta.b3os.org/vision/proxy).
71
+ **When should I use a session instead of a scrape with actions?**
72
+
73
+ A scrape with `actions` suits one page: act, then capture, then the browser is released. A session suits work across many steps or pages, or anything that needs Playwright or Puppeteer. Sessions bill browser time while open; scrapes bill one page each.
74
+ **Is my session's browser shared with anyone?**
75
+
76
+ No. Each session gets its own browser process and profile directory, one browser never serves two organizations, and only your organization's profiles load into it. Chrome runs with its renderer sandbox on: renderers run in their own user and PID namespaces under seccomp. The browsers of one pool share an OS user and a network namespace, so the renderer sandbox is the boundary between sessions, and a production node refuses sessions when that sandbox does not work. Browsers in microVMs of their own, a stronger boundary, are planned. The shared scrape pool runs only scrapes that B3OS drives and accepts no CDP connections.
77
+ **Can I use vision from inside a sandbox?**
78
+
79
+ Yes. Grant the sandbox `vision:run` and call `http://127.0.0.1:7700/v1/vision/scrape` from inside it, with no key. The call reaches vision over vsock without leaving the node.
@@ -0,0 +1,111 @@
1
+ # Profiles
2
+
3
+ > Save browser cookies and storage as an encrypted profile, load it into scrapes, sessions and screenshots, and keep it current without losing newer logins.
4
+
5
+ Source: https://docs.beta.b3os.org/vision/profiles.md
6
+
7
+ A profile holds a browser's cookies and storage under a name, so an agent can start signed in. Scrapes, browser sessions, screenshots and videos load profiles by ID or name. Profiles are encrypted in the node's vault, decrypted only inside the browser that loads them, never logged and never sent to a model. They never leave your organization.
8
+
9
+ ## Create one from Playwright
10
+
11
+ A profile's state is Playwright's `storageState` JSON, uploaded as is. Sign in once with Playwright, export the state, and upload it.
12
+
13
+ To try it without an account anywhere, use the [demo app](https://beta.b3os.org/demo/login/): its sign-in form takes any email address and password and only sets the cookie `b3os_demo_session=1` for `/demo/`. The state Playwright exports after that sign-in, which you can also save by hand as `state.json`:
14
+
15
+ ```json
16
+ {
17
+ "cookies": [
18
+ {
19
+ "name": "b3os_demo_session",
20
+ "value": "1",
21
+ "domain": "beta.b3os.org",
22
+ "path": "/demo/",
23
+ "expires": -1,
24
+ "httpOnly": false,
25
+ "secure": true,
26
+ "sameSite": "Lax"
27
+ }
28
+ ],
29
+ "origins": []
30
+ }
31
+ ```
32
+
33
+ Upload it as the profile `demo-signed-in`:
34
+
35
+ **curl**
36
+
37
+ ```bash
38
+ # state.json comes from Playwright: await context.storageState({ path: "state.json", indexedDB: true })
39
+ curl -s https://beta-api.b3os.org/v1/vision/profiles \
40
+ -H "Authorization: Bearer $B3OS_API_KEY" \
41
+ -H "Content-Type: application/json" \
42
+ -d "{\"name\": \"demo-signed-in\", \"state\": $(cat state.json)}"
43
+ ```
44
+ **TypeScript**
45
+
46
+ ```ts
47
+ import { readFile } from "node:fs/promises";
48
+ import { B3OS } from "@b3os/sdk";
49
+
50
+ const b3os = new B3OS();
51
+ const state = JSON.parse(await readFile("state.json", "utf8"));
52
+ const profile = await b3os.vision.createProfile({ name: "demo-signed-in", state });
53
+ console.log(profile.id, profile.domains, profile.stats);
54
+ ```
55
+ **Python**
56
+
57
+ ```python
58
+ import json
59
+ from b3os import B3OS
60
+
61
+ b3os = B3OS()
62
+ with open("state.json") as f:
63
+ profile = b3os.vision.create_profile({"name": "demo-signed-in", "state": json.load(f)})
64
+ print(profile["id"], profile["domains"], profile["stats"])
65
+ ```
66
+ **MCP**
67
+
68
+ Profiles hold live session cookies, so create them from your own code rather than through an agent. An agent can then use one by name where its tool takes a profile: the remote MCP server's `vision_scrape` takes the whole scrape request, `profile` included, and on the local server `vision_scrape` and `vision_act` take `profile` (`vision_act` loads it into the session it creates). An agent that drives a session with a profile loaded can read that profile's cookies and storage (see [what the export rules cover](#what-the-export-rules-cover)).
69
+
70
+ Loading a profile into a scrape, batch, crawl, session, screenshot or video needs `vision:profiles:use`, which default keys have.
71
+
72
+ Every cookie domain and storage origin must belong to the profile's `domains`. Leave `domains` out and B3OS derives it from the state; a state that strays outside the listed domains fails with [`profile_domain_mismatch`](https://docs.beta.b3os.org/errors#profile_domain_mismatch). Names are unique per project. The API returns the domains and counts of cookies, origins and bytes, never the values.
73
+
74
+ ## Use a profile
75
+
76
+ | Where | Field |
77
+ |---|---|
78
+ | [Scrape](https://docs.beta.b3os.org/vision/scrape#use-a-profile), batch, crawl | `profile` (implies the browser tier) |
79
+ | [Browser session](https://docs.beta.b3os.org/vision/sessions) | `profile`, with `persist_profile` to save back on close |
80
+ | [Screenshot](https://docs.beta.b3os.org/render/screenshots#capture-a-signed-in-page), [video](https://docs.beta.b3os.org/render/videos) | `profile`, or `source.profile` for videos. A page that is still signed out fails with [`profile_expired`](https://docs.beta.b3os.org/errors#profile_expired) |
81
+
82
+ ## Save from a session
83
+
84
+ Sign in inside a session (an agent, or a person through the CDP socket), then save its current cookies and storage:
85
+
86
+ ```bash
87
+ curl -s "https://beta-api.b3os.org/v1/vision/sessions/$SESSION_ID/profile" \
88
+ -H "Authorization: Bearer $B3OS_API_KEY" \
89
+ -H "Content-Type: application/json" \
90
+ -d '{"name": "demo-signed-in"}'
91
+ ```
92
+
93
+ This creates the profile if the name is new, or writes a new revision if it exists. A session created with `profile` and `persist_profile: true` does the same automatically when it closes.
94
+
95
+ ## Revisions and conflicts
96
+
97
+ Every save increments the profile's `revision`. Two sessions can load the same revision; if one saves first, the other's save would throw away newer state, so it fails with [`profile_conflict`](https://docs.beta.b3os.org/errors#profile_conflict). Save with `overwrite` (or create the session with `overwrite_profile`) to replace it anyway, or load the profile again in a new session. While a session with `persist_profile` holds a profile, its status is `locked`; other loads still see the last saved revision.
98
+
99
+ ## Change, export or delete
100
+
101
+ - `PATCH /v1/vision/profiles/{profile_id}` renames it, changes its domains, expiry or metadata, or replaces its state with a new revision.
102
+ - `GET /v1/vision/profiles/{profile_id}/state` exports the current state in the same `storageState` shape, so you can load it into your own browser. It contains live session cookies: treat the response like a password. It needs `vision:profiles:export` as well as `vision:write`. No key has the export scope unless it is granted by name: default keys, `*` and `vision:*` leave it out. Until 2026-11-16 a key with `vision:write` still exports without it, and the response's `Sunset` header gives that date. A profile whose state a B3OS session saved reads `exportable: false`, and this route answers 403 [`profile_not_exportable`](https://docs.beta.b3os.org/errors#profile_not_exportable) for it with any scope once that date passes. It still loads into your sessions, scrapes and render jobs. An uploaded state reads `exportable: true`, and uploading a new state makes a profile exportable again. Tested in crates/b3os-vision/tests/e2e.rs.
103
+ - `DELETE /v1/vision/profiles/{profile_id}` deletes the profile and every revision. Sessions that already loaded it keep their cookies until they close.
104
+
105
+ A profile can carry an `expires_at`, after which it is deleted.
106
+
107
+ ## What the export rules cover
108
+
109
+ `vision:profiles:export` decides who reads a profile's state out of B3OS: through the state route above, and through a session's CDP socket. A session that loads a profile has its cookies and storage in the browser, so a CDP client whose key lacks the export scope cannot read them: `Network.getAllCookies`, `Network.getCookies`, `Storage.getCookies`, `Storage.getSharedStorageEntries` and the `DOMStorage`, `IndexedDB` and `CacheStorage` methods answer [`forbidden`](https://docs.beta.b3os.org/errors#forbidden) with `required_scope` in `error.b3os`, and network events reach it without `Cookie` and `Set-Cookie` headers. The site still gets the cookies. Default keys, `*` and `vision:*` do not have the export scope; in the dashboard, owners and admins have it and members do not. Until 2026-11-16 these reads still work with any key, as before the export scope existed. Tested in crates/b3os-vision/tests/e2e.rs.
110
+
111
+ The export scope does not cover what scripts in the page can read. A CDP client's `Runtime.evaluate`, and an `evaluate` step in a session or a scrape, read what the page's own scripts can, such as `document.cookie` (without HttpOnly cookies) and `localStorage`, and a page that shows a cookie's value shows it to them too. Any key of the project with `vision:run` can drive an open session, and a key with `vision:write` and `vision:profiles:use` (both in default keys) can create a session with a profile. Treat a key that can do either as able to read what pages see of those profiles. `exportable: false` keeps a session-saved profile from the state route only: a CDP client with the export scope reads its cookies like any other.
@@ -0,0 +1,131 @@
1
+ # Proxies
2
+
3
+ > Send a scrape through your own HTTP proxy, or let vision ask once more from a residential address when the node's address gets a wall.
4
+
5
+ Source: https://docs.beta.b3os.org/vision/proxy.md
6
+
7
+ A scrape leaves from the node's own address unless it sets `proxy`. Set it on `POST /v1/vision/scrape` to send the scrape through your own proxy, or to have vision read the page from a residential address. Batches, crawls, extract jobs, sessions and the Firecrawl surface do not take it yet: they leave from the node's address.
8
+
9
+ | `proxy` | Where the scrape leaves from |
10
+ |---|---|
11
+ | left out | The node's default: `none`, unless its operator set `auto` |
12
+ | `"none"` | The node's own address |
13
+ | `"auto"` | The node's address. When the page comes back a wall, vision asks once more from a residential address, unless the request or the site rules that out. Where residential reads are off, exactly `none`, never an error |
14
+ | `"residential"` | Vision reads the page from a residential address, every request of the scrape |
15
+ | `"http://host:port"` | Your proxy, without credentials |
16
+ | `{"url": "http://host:port", "connection": "conn_..."}` | Your proxy, with the username and password of a vault connection |
17
+
18
+ ## Your own proxy
19
+
20
+ Give the proxy's URL, or an object with the URL and a vault connection that holds its username and password:
21
+
22
+ ```bash
23
+ curl -s https://beta-api.b3os.org/v1/vision/scrape \
24
+ -H "Authorization: Bearer $B3OS_API_KEY" \
25
+ -H "Content-Type: application/json" \
26
+ -d '{"url": "https://example.com", "proxy": {"url": "http://proxy.example.net:8080", "connection": "conn_01jc8x2v7m4k9p3q5r6s7t8w9y"}}'
27
+ ```
28
+
29
+ - The URL is `http://host:port` (port 80 when left out), with no path, query or fragment. A URL with a username or password in it is refused with `400 invalid_request`: put them in a connection. `https://` and `socks5://` proxies are not taken yet.
30
+ - The connection is a custom [vault connection](https://docs.beta.b3os.org/vault#three-kinds-of-connection) of type `basic` (`secret: {"username": ..., "password": ...}`), active, with the proxy's host in its `hosts`: its host name, or for a proxy given by its address that IP address (a public one; the vault refuses private, loopback, link-local, CGNAT, multicast and metadata addresses). Naming it takes `vault:run`, as any request that names a connection does. If your proxy's vendor wants a country or a session, put it in the username or password the way the vendor asks.
31
+ - The proxy is plain HTTP, so the username and password cross the network to your proxy unencrypted, as `Proxy-Authorization`. The pages themselves stay encrypted end to end: an `https://` page goes through the proxy as a tunnel, and the node checks the site's certificate as always.
32
+ - Both tiers use it: the plain fetch and the browser. A page through a proxy renders in a browser of your organization's own (it holds one of your `vision.sessions.concurrent` places while it renders), never in the shared scrape pool, and is never read from or stored in the cache (`cache.state` is `bypass`).
33
+ - When the proxy fails, the scrape answers the proxy's own error, not the site's: [`proxy_unreachable`](https://docs.beta.b3os.org/errors#proxy_unreachable), [`proxy_auth_failed`](https://docs.beta.b3os.org/errors#proxy_auth_failed) or [`proxy_refused`](https://docs.beta.b3os.org/errors#proxy_refused) with `upstream_status`. On a plain `http://` page there is no tunnel: the request goes to the proxy whole, so a `502` the proxy sends because it could not reach the site comes back as the page, with `status_code: 502` and `egress.exit: "byo"`. A `407` from the proxy is `proxy_auth_failed` on either kind of page.
34
+
35
+ B3OS adds no retry and no rotation through your proxy. robots.txt is read through it only when the request sets `respect_robots: true`, as from the node's address. A scrape through your proxy or from a residential address waits its turn at the host as crawl pages do, and a host paused after a `429` or `503` answers `503 capacity_unavailable` until its `Retry-After` ends.
36
+
37
+ ## Residential reads
38
+
39
+ Note:
40
+ Residential reads are off on the beta's node for now: `proxy: "residential"` answers `422 option_not_allowed` with `bound_by: node`, and `proxy: "auto"` is exactly `none`.
41
+
42
+ When a site walls the node's own address, vision can ask once more from a residential address, the address of a home connection. It is part of how vision reads pages, for every organization: nobody gets an address, credentials or any traffic through it other than vision's own page reads. `proxy: "none"` keeps a scrape on the node's own address, and [the rules](#rules) apply to every residential read.
43
+
44
+ - **`auto`** reads the page from the node's address first. When that answer is a wall (`page_state` `blocked` or `captcha`), vision asks once more from a residential address. That gets around the site's IP-based block. When the second answer is the page, you get it, with the node's wall in `egress.first` and a warning that says the node's address was walled; when it is a wall too, you get the node's wall, and vision does not ask that host from a residential address again for your organization for an hour. When no residential retry can run, `auto` behaves as `none` and `egress.retry.skipped` says why. The residential retry takes the place of the node's own retry in full Chrome, so a walled host gets one more request, not two.
45
+ - **`residential`** reads the page from a residential address: the page, what it loads, and its robots.txt.
46
+ - **`proxy_country`** picks the country of the residential address (two letters, any case; `US` by default) for `auto` and `residential`. The node lists the countries it offers; another answers `422 option_not_allowed` with the list. The browser's locale and time zone do not follow it: set `locale` and `timezone` yourself.
47
+ - **One address per organization and host.** Your organization reaches one host from one residential address (one exit session) for 30 minutes by default; the page, its subresources and its robots.txt share it. The address can change inside that time. Another organization reading the same host gets another address.
48
+
49
+ What a residential read never does: it does not solve CAPTCHAs (a CAPTCHA that still shows comes back as a wall), changes nothing about the browser's fingerprint beyond what [Browsers](https://docs.beta.b3os.org/vision#browsers) says, never signs in, and never retries a `429` or `503` from another address. A host that answered `429` or `503` is paused for its `Retry-After` for every proxied request.
50
+
51
+ ## What the result says
52
+
53
+ Every scrape result carries `egress`, which exit served the page it returns, and `options`, what the scrape read for `vision.proxy` and `vision.proxy_country` and where each value came from (`request` or `node`). The response header `X-B3OS-Options` says the same, for example `vision.proxy=auto;from=request, vision.proxy_country=US;from=node`. Batch and crawl pages carry `egress: {"exit": "node"}` and no `options`.
54
+
55
+ From the node's address:
56
+
57
+ ```json
58
+ "egress": {"exit": "node"}
59
+ ```
60
+
61
+ Through your proxy (`host` is the proxy's, never its credentials; `bytes` counts both directions through the exit):
62
+
63
+ ```json
64
+ "egress": {"exit": "byo", "host": "proxy.example.net", "bytes": 183422}
65
+ ```
66
+
67
+ Read from a residential address after the node's address got a wall:
68
+
69
+ ```json
70
+ "egress": {
71
+ "exit": "residential",
72
+ "country": "US",
73
+ "exit_session": "xs_01jc8x5d2f7g9h3k4m6n8p0q2r",
74
+ "bytes": 241907,
75
+ "retried_from": "node",
76
+ "first": {"page_state": "blocked", "signal": "cloudflare_challenge", "status_code": 403}
77
+ }
78
+ ```
79
+
80
+ `auto` on a wall when no retry ran:
81
+
82
+ ```json
83
+ "egress": {"exit": "node", "retry": {"skipped": "robots"}}
84
+ ```
85
+
86
+ `retry.skipped` is one of `org` (reading from a residential address is switched off for your organization), `node` (this node does not offer it), `credentials`, `opt_out`, `category`, `memory` (the host walled your organization's residential read within the hour), `rate_limited` (a `429` or `503`, or a paused host), `time` (too little of `timeout_ms` left), `quota`, `robots` or `capacity`. When the retry ran and did not help, `egress.exit` stays `node`, the page returned is the node's wall, and `retry` says how it ended: `{"exit": "residential", "outcome": "wall", "page_state": "captcha", "bytes": 52114}` or `{"exit": "residential", "outcome": "failed", "error": "proxy_refused", "bytes": 0}`. `Server-Timing` has `proxy`, the time spent connecting to the exit.
87
+
88
+ ## Errors
89
+
90
+ Each refusal happens before any request leaves the node, and none bills.
91
+
92
+ | Code | Status | When |
93
+ |---|---|---|
94
+ | [`invalid_request`](https://docs.beta.b3os.org/errors#invalid_request) | 400 | A word other than the three, a URL with a username or password, a scheme other than `http`, a path, query or fragment, a `connection` that is not a `conn_` ID or not a `basic` connection listing the proxy's host, `proxy_country` that is not two letters or given with `none` or your own proxy, `cache_only` with a proxy |
95
+ | [`egress_denied`](https://docs.beta.b3os.org/errors#egress_denied) | 403 | The proxy's host is an address the egress guard refuses (private, loopback, metadata) |
96
+ | [`option_not_allowed`](https://docs.beta.b3os.org/errors#option_not_allowed) | 422 | This node takes no customer proxy, or does not read from residential addresses (`bound_by: node`); reading from a residential address is switched off for your organization (`bound_by: org`); a country the node does not offer |
97
+ | [`proxy_not_allowed`](https://docs.beta.b3os.org/errors#proxy_not_allowed) | 403 | Vision does not read this page from a residential address: `reason` `credentials` (a profile, a credential header or actions), `opt_out` (the site is on the opt-out list) or `category` (a restricted category, named in the detail) |
98
+ | [`robots_disallowed`](https://docs.beta.b3os.org/errors#robots_disallowed) | 403 | On a residential read, robots.txt or Content Signals disallow the page, or robots.txt could not be read |
99
+ | [`quota_exceeded`](https://docs.beta.b3os.org/errors#quota_exceeded) | 429 | Your organization reached this month's limit on residential reads; `Retry-After` runs to the end of the month |
100
+ | [`capacity_unavailable`](https://docs.beta.b3os.org/errors#capacity_unavailable) | 503 | The host is paused after its `429` or `503` (`reason: host_backoff`, `Retry-After` the seconds left); or the record B3OS keeps of a residential read's connection ([rule 7](#rules)) could not be written, or not in time for the read, robots.txt's included (`Retry-After: 5`) |
101
+ | [`proxy_unreachable`](https://docs.beta.b3os.org/errors#proxy_unreachable) | 502 | The node could not connect to the proxy, or it closed before answering. Retryable |
102
+ | [`proxy_auth_failed`](https://docs.beta.b3os.org/errors#proxy_auth_failed) | 502 | The proxy answered `407`, or the connection has no username and password |
103
+ | [`proxy_refused`](https://docs.beta.b3os.org/errors#proxy_refused) | 502 | The proxy answered `CONNECT` with another status that is not 2xx, in `upstream_status` |
104
+
105
+ A residential read uses the same three proxy codes, and the detail says "reading from a residential address". A site the residential exit refuses comes back as `proxy_refused` with the exit's status.
106
+
107
+ ## Billing and the monthly limit
108
+
109
+ A page bills one `vision.page`, whichever address it was read from, and a wall is free as always. Bytes are never billed. Bytes through your own proxy count toward `egress.bytes` as any egress does.
110
+
111
+ Reading from a residential address has a safety limit, not a price: vision counts the bytes of those reads (`vision.proxy_bytes`, both directions, walls and robots.txt included) against `vision.proxy.bytes.monthly`, 1 GiB per organization per UTC calendar month ([Limits](https://docs.beta.b3os.org/concepts/limits)). It limits residential retries; it is not an allowance you buy. Once it is reached, `residential` answers `429 quota_exceeded` and `auto` skips the retry (`retry.skipped: "quota"`) until the month ends. A connection already open when the limit is reached finishes.
112
+
113
+ <h2 id="rules">Rules for residential reads</h2>
114
+
115
+ 1. Public pages only. A request with a profile, a credential header (`Cookie`, `Authorization` and the like) or browser actions is never read from a residential address.
116
+ 2. No logins, cookies or credentials: residential reads are not for signing in, submitting forms or reaching anything behind an account.
117
+ 3. Vision never reads the sites on its opt-out list, or sites in restricted categories, from a residential address: government, banking, crypto exchanges, streaming, gambling, ticketing, webmail, game stores and adult sites.
118
+ 4. robots.txt (product token `B3OSBot`, else `*`) and Content Signals are always followed on residential reads, whatever the request says.
119
+ 5. One residential address per organization and host at a time. Vision never changes addresses to find one a site does not block.
120
+ 6. Your use of vision, residential reads included, is under B3OS's terms.
121
+ 7. B3OS keeps a record of each connection a residential read makes, with its time, organization, request and destination host.
122
+
123
+ ## Site owners
124
+
125
+ A site stays off residential reads in any of three ways:
126
+
127
+ - a robots.txt group for `B3OSBot` or `*` that disallows the path;
128
+ - the Content Signal `ai-input=no` in robots.txt;
129
+ - the opt-out list, which keeps a site off residential reads entirely: no `auto` retry and no `residential` request reaches it from a residential address, whatever the request says. It does not stop reads from the node's own address.
130
+
131
+ No site is on the list yet.