@b3os/cli 0.2.0 → 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 (217) hide show
  1. package/README.md +87 -7
  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 -0
  19. package/dist/commands/app.js +559 -54
  20. package/dist/commands/app.js.map +1 -1
  21. package/dist/commands/auth.d.ts +88 -2
  22. package/dist/commands/auth.js +354 -44
  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 +81 -18
  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 +154 -0
  49. package/dist/commands/tool.js +785 -0
  50. package/dist/commands/tool.js.map +1 -0
  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/apply.d.ts +4 -0
  190. package/dist/manifest/apply.js +2 -0
  191. package/dist/manifest/apply.js.map +1 -1
  192. package/dist/manifest/domains.d.ts +50 -0
  193. package/dist/manifest/domains.js +159 -0
  194. package/dist/manifest/domains.js.map +1 -0
  195. package/dist/manifest/link.d.ts +20 -0
  196. package/dist/manifest/link.js +24 -0
  197. package/dist/manifest/link.js.map +1 -0
  198. package/dist/manifest/record.d.ts +1 -1
  199. package/dist/tool/archive.d.ts +33 -0
  200. package/dist/tool/archive.js +174 -0
  201. package/dist/tool/archive.js.map +1 -0
  202. package/dist/tool/calls.d.ts +46 -0
  203. package/dist/tool/calls.js +274 -0
  204. package/dist/tool/calls.js.map +1 -0
  205. package/dist/tool/checks.d.ts +21 -0
  206. package/dist/tool/checks.js +145 -0
  207. package/dist/tool/checks.js.map +1 -0
  208. package/dist/tool/elf.d.ts +19 -0
  209. package/dist/tool/elf.js +107 -0
  210. package/dist/tool/elf.js.map +1 -0
  211. package/dist/tool/predict.d.ts +8 -0
  212. package/dist/tool/predict.js +38 -0
  213. package/dist/tool/predict.js.map +1 -0
  214. package/dist/tool/ustar.d.ts +5 -0
  215. package/dist/tool/ustar.js +220 -0
  216. package/dist/tool/ustar.js.map +1 -0
  217. package/package.json +6 -5
@@ -0,0 +1,115 @@
1
+ # agent-browser with B3OS
2
+
3
+ > Drive a B3OS browser session with agent-browser, the browser CLI for AI agents by Vercel Labs, over CDP; the setup, what works, and what does not yet and why.
4
+
5
+ Source: https://docs.beta.b3os.org/vision/agent-browser.md
6
+
7
+ [agent-browser](https://github.com/vercel-labs/agent-browser) is a browser automation CLI for AI agents by Vercel Labs. An agent reads the page as text with a ref for each element (`snapshot -i`), acts on a ref (`click @e3`) and reads again. It connects to any Chrome DevTools Protocol endpoint, so it can drive a [B3OS browser session](https://docs.beta.b3os.org/vision/sessions) instead of a Chrome on your machine: a whole Chrome on the B3OS node, yours alone, with the session's egress and its [profile](https://docs.beta.b3os.org/vision/profiles) if you load one. agent-browser 0.43.0 runs its everyday commands and every tool of its MCP `core` profile against a session; file upload and cookie reads are the exceptions, below.
8
+
9
+ ## Set up
10
+
11
+ Create a session, then give agent-browser its CDP URL and your key. The key goes in `AGENT_BROWSER_CDP_HEADERS`, the headers agent-browser sends when it opens the socket, so it never appears on a command line:
12
+
13
+ ```bash
14
+ SESSION=$(curl -s https://beta-api.b3os.org/v1/vision/sessions \
15
+ -H "Authorization: Bearer $B3OS_API_KEY" \
16
+ -H "Content-Type: application/json" \
17
+ -d '{"timeout_s": 600}')
18
+ export AGENT_BROWSER_CDP=$(jq -r .cdp_url <<<"$SESSION")
19
+ export AGENT_BROWSER_CDP_HEADERS="{\"Authorization\":\"Bearer $B3OS_API_KEY\"}"
20
+
21
+ agent-browser open https://beta.b3os.org/demo/login/
22
+ agent-browser snapshot -i
23
+ ```
24
+
25
+ The snapshot lists the page's controls and headings with a ref for each, as it printed on a recorded run:
26
+
27
+ ```text
28
+ - navigation "Example" [ref=e1]
29
+ - link "Example Fernway" [ref=e2]
30
+ - link "Projects" [ref=e3]
31
+ - link "Billing" [ref=e4]
32
+ - link "Pricing" [ref=e5]
33
+ - link "Activity" [ref=e6]
34
+ - heading "Sign in" [level=1, ref=e8]
35
+ - textbox "Email" [ref=e9]
36
+ - textbox "Password" [ref=e10]
37
+ - button "Sign in" [ref=e7]
38
+ ```
39
+
40
+ Act on the refs and read the result:
41
+
42
+ ```bash
43
+ agent-browser fill @e9 "agent@example.com"
44
+ agent-browser fill @e10 "any text"
45
+ agent-browser click @e7
46
+ agent-browser wait --text "Launch plan"
47
+ agent-browser screenshot --full board.png
48
+ ```
49
+
50
+ Take refs from your own snapshot: they change when the page does. The key needs `vision:run` and `vision:read`, which default keys have.
51
+
52
+ When you are done, disconnect agent-browser and close the session, which ends its billing:
53
+
54
+ ```bash
55
+ agent-browser close
56
+ curl -s -X DELETE "https://beta-api.b3os.org/v1/vision/sessions/$(jq -r .id <<<"$SESSION")" \
57
+ -H "Authorization: Bearer $B3OS_API_KEY"
58
+ ```
59
+
60
+ `agent-browser close` only disconnects: agent-browser never closes a browser it did not launch. Until the `DELETE`, or until `timeout_s` passes, the session keeps its pages and bills `vision.browser_ms`.
61
+
62
+ ## MCP
63
+
64
+ `agent-browser mcp` serves the same commands as MCP tools over stdio, and it reads the same two variables. Create the session first, then start the server with them in its environment, for example from a script that exports them and runs your MCP client. A session's CDP URL names that session, so a server started for one session drives only that one.
65
+
66
+ B3OS's own MCP server has `vision_act`, which runs a whole sequence of browser actions in one call on the node. With agent-browser, each command is its own exchange between your machine and the browser.
67
+
68
+ ## What works
69
+
70
+ Tested on 2026-11-20 with agent-browser 0.43.0 on a laptop, over the internet, against a session on a development build of the node that carries this change, each command once in the order an agent uses them:
71
+
72
+ | Command | On a B3OS session |
73
+ |---|---|
74
+ | `open`, `back`, `forward`, `reload` | Works |
75
+ | `snapshot -i`, then `click @eN` or `fill @eN` on its refs | Works |
76
+ | `click`, `fill`, `type`, `press`, `check`, `uncheck`, `select`, `scroll`, `find role button click --name ...` | Works |
77
+ | `wait <selector>`, `wait <ms>`, `wait --text`, `wait --url`, `wait --load` | Works |
78
+ | `get title`, `get url`, `get text`, `get value`, `eval`, `read` (the rendered page) | Works |
79
+ | `agent-browser screenshot`, `agent-browser screenshot --full` | Works, also when the full-page PNG runs to tens of megabytes |
80
+ | `pdf` | Works |
81
+ | `record start`, `record stop` | Works; agent-browser encodes the video on your machine, so ffmpeg must be installed there |
82
+ | `tab new`, `tab`, `tab <id>`, `tab close` | Works |
83
+ | `storage local`, `storage local set` | Works |
84
+ | `cookies set`, `cookies clear` | Works |
85
+ | `cookies` (read) | Needs a key with `vision:profiles:export`; see below |
86
+ | `upload` | Refused; see below |
87
+ | `close` | Disconnects; the session stays open until you close it |
88
+ | `agent-browser mcp --tools core`: its 33 tools | Every one works. `agent_browser_flow_run` replays a saved flow over HTTP from your machine, with the browser's cookies only when the key has `vision:profiles:export` |
89
+
90
+ ## What does not work yet, and why
91
+
92
+ **`upload`.** agent-browser sets a file input with `DOM.setFileInputFiles`, which names files by their path on the machine that runs the browser. On a session that machine is the B3OS node, so the proxy refuses the method as host file access ([`cdp_method_blocked`](https://docs.beta.b3os.org/errors#cdp_method_blocked)): the paths you pass name files on your machine, which the session's browser cannot read. Until B3OS can take the file's bytes, set the input from the page with `eval`, which sends the bytes inside the expression:
93
+
94
+ ```bash
95
+ agent-browser eval '(() => {
96
+ const input = document.querySelector("input[type=file]");
97
+ const dt = new DataTransfer();
98
+ dt.items.add(new File(["hello from B3OS\n"], "hello.txt", { type: "text/plain" }));
99
+ input.files = dt.files;
100
+ input.dispatchEvent(new Event("change", { bubbles: true }));
101
+ return input.files[0].name;
102
+ })()'
103
+ ```
104
+
105
+ **`cookies` with a default key.** Reading the browser's cookies (`Network.getCookies`) needs `vision:profiles:export`, because the browser holds any profile the session loaded and default keys never include that scope ([what the export rules cover](https://docs.beta.b3os.org/vision/profiles#what-the-export-rules-cover)). Without it the read is refused with `forbidden` and a message that names the scope. Setting and clearing cookies, and `storage local`, work with any key. `agent_browser_flow_run` reads the cookies the same way, so with a default key its HTTP replay runs without them.
106
+
107
+ **`--allowed-domains`.** agent-browser refuses its own domain allowlist (`--allowed-domains`, `AGENT_BROWSER_ALLOWED_DOMAINS`) with `--cdp`, before it connects: in a browser it did not launch, it cannot install its WebRTC containment before the pages' own scripts run. On a session, B3OS's own egress rules apply to every request the browser makes, whoever drives it.
108
+
109
+ On a node from before the release that carries this change (see the [changelog](https://docs.beta.b3os.org/changelog)), agent-browser reports both refusals as `Malformed CDP response: invalid type: map, expected a string`: those nodes put the B3OS details of a refused call in `error.data` as an object, where agent-browser expects a string as Chrome sends it. Now `error.data` is the code (`cdp_method_blocked`, `forbidden`) and the details are in `error.b3os`, and agent-browser shows the refusal's own message.
110
+
111
+ **Saved flows hold your key.** `agent-browser flow save` (0.43.0) writes the session's settings into the flow file under `~/.agent-browser/flows/`, `AGENT_BROWSER_CDP_HEADERS` among them, so the file holds your B3OS key in plain text. Use a key you can revoke for sessions you record flows in, and do not share flow files.
112
+
113
+ ## Credits and license
114
+
115
+ agent-browser is developed by Vercel Labs and published under the [Apache License 2.0](https://github.com/vercel-labs/agent-browser/blob/main/LICENSE); its npm package also ships axe-core under the Mozilla Public License 2.0. B3OS hands out no copy of it: you install it yourself from npm, and it talks to B3OS over CDP. B3OS is not affiliated with Vercel, and Vercel does not endorse B3OS.
@@ -0,0 +1,333 @@
1
+ # Search, map, batch and crawl
2
+
3
+ > Search the web, list a site's URLs, scrape up to 1,000 known URLs, or crawl a site by following its links, as jobs you can wait on, stream or get a webhook for.
4
+
5
+ Source: https://docs.beta.b3os.org/vision/crawl.md
6
+
7
+ Four operations cover more than one page. Search and map are single calls; batch and crawl are [jobs](https://docs.beta.b3os.org/concepts/jobs).
8
+
9
+ ## Search the web
10
+
11
+ `POST /v1/vision/search` sends your query to the node's search provider, the [Brave Search API](https://brave.com/search/api/), and returns up to `limit` results in the provider's order, each with its URL, title and description. Add `scrape` and the node scrapes every result in the same call, so an agent goes from a question to readable pages in one request.
12
+
13
+ **curl**
14
+
15
+ ```bash
16
+ curl -s https://beta-api.b3os.org/v1/vision/search \
17
+ -H "Authorization: Bearer $B3OS_API_KEY" \
18
+ -H "Content-Type: application/json" \
19
+ -d '{"query": "rust async runtime", "limit": 3}'
20
+ ```
21
+ **TypeScript**
22
+
23
+ ```ts
24
+ import { B3OS } from "@b3os/sdk";
25
+
26
+ const b3os = new B3OS();
27
+ const found = await b3os.vision.search({ query: "rust async runtime", limit: 3 });
28
+ for (const r of found.results) console.log(r.position, r.title, r.url);
29
+ ```
30
+ **Python**
31
+
32
+ ```python
33
+ from b3os import B3OS
34
+
35
+ b3os = B3OS()
36
+ found = b3os.vision.search({"query": "rust async runtime", "limit": 3})
37
+ for r in found["results"]:
38
+ print(r["position"], r["title"], r["url"])
39
+ ```
40
+
41
+ The answer lists the results with their `position` from 1. Titles and descriptions are plain text: the provider's highlighting markup is removed and HTML entities are decoded. A result appears once even when the provider lists its URL twice, and only `http` and `https` results are kept. The answer also carries `timing`: `search_ms` and `total_ms`, and `scrape_ms` when it scraped the results.
42
+
43
+ ```json
44
+ {
45
+ "object": "search",
46
+ "query": "rust async runtime",
47
+ "results": [
48
+ {
49
+ "position": 1,
50
+ "url": "https://tokio.rs/",
51
+ "title": "Tokio - An asynchronous Rust runtime",
52
+ "description": "Tokio is an asynchronous runtime for the Rust programming language."
53
+ },
54
+ {
55
+ "position": 2,
56
+ "url": "https://docs.rs/tokio/latest/tokio/",
57
+ "title": "tokio - Rust",
58
+ "description": "A runtime for writing reliable network applications without compromising speed."
59
+ }
60
+ ]
61
+ }
62
+ ```
63
+
64
+ ### Get the pages too
65
+
66
+ With `scrape`, each result's `scrape` holds the same document a [scrape](https://docs.beta.b3os.org/vision/scrape) returns, with the formats you ask for (Markdown when you name none). The scrapes run side by side within your scrape concurrency, through the same egress guard and per-host politeness as any scrape, and all within the search's `timeout_ms` (30 seconds by default).
67
+
68
+ **TypeScript**
69
+
70
+ ```ts
71
+ import { B3OS } from "@b3os/sdk";
72
+
73
+ const b3os = new B3OS();
74
+ const found = await b3os.vision.search({
75
+ query: "tokio select macro",
76
+ limit: 3,
77
+ scrape: { formats: ["markdown"], only_main_content: true },
78
+ });
79
+ for (const r of found.results) {
80
+ if (r.scrape) console.log(r.url, r.scrape.markdown?.slice(0, 200));
81
+ else console.log(r.url, "not scraped:", r.error?.code);
82
+ }
83
+ ```
84
+ **Python**
85
+
86
+ ```python
87
+ from b3os import B3OS
88
+
89
+ b3os = B3OS()
90
+ found = b3os.vision.search({
91
+ "query": "tokio select macro",
92
+ "limit": 3,
93
+ "scrape": {"formats": ["markdown"], "only_main_content": True},
94
+ })
95
+ for r in found["results"]:
96
+ if "scrape" in r:
97
+ print(r["url"], r["scrape"].get("markdown", "")[:200])
98
+ else:
99
+ print(r["url"], "not scraped:", r["error"]["code"])
100
+ ```
101
+
102
+ A result whose page could not be scraped has `error` instead of `scrape`: the same problem a scrape of that URL would answer, such as `upstream_error`, `egress_denied` or `scrape_timeout`. The search still answers `200`, with the warning `scrape_failed: <n> of <m> results could not be scraped; each has its error`.
103
+
104
+ A page the site answered whose Markdown comes back empty is a result, not an error. It has `scrape` with an empty `markdown`, the site's `status_code` and a `page_state` that can be `ok`. Its `warnings` holds `empty_page: the page came back with no text in its Markdown (status <code>, page_state <state>)`, and the search's own `warnings` holds `empty_page: <n> of <m> results came back with no text in their Markdown; each has its warning`. It bills one `vision.page` like any other scraped result. With `engine: "fetch"` no browser ran, and the warning adds that `auto` or `browser` may get more ([choose the engine](https://docs.beta.b3os.org/vision/scrape#choose-the-engine)). Tested by `an_empty_page_says_so_and_bills_as_a_page` (crates/b3os-vision/tests/e2e_search.rs).
105
+
106
+ One answer holds at most 64 MiB of pages. A result past that has the error `search_answer_too_large` and is not billed, which matters for raw HTML and full-page screenshots of 20 results: ask for fewer formats, or send the URLs to [`POST /v1/vision/batches`](https://docs.beta.b3os.org/vision/crawl#scrape-a-list-of-urls).
107
+
108
+ A search does not send its results what you would only send to sites you chose. These scrape options are refused with `400 invalid_request`, before anything is sent:
109
+
110
+ | Option | Why | Instead |
111
+ |---|---|---|
112
+ | `headers` | Cookies and tokens would go to sites a third party's index picked | Scrape the URLs you trust with [`POST /v1/vision/scrape`](https://docs.beta.b3os.org/vision/scrape) |
113
+ | `profile` | The same, for a signed-in browser state | The same |
114
+ | `actions` | Steps written for one page do not fit unknown pages | [`POST /v1/vision/batches`](https://docs.beta.b3os.org/vision/crawl#scrape-a-list-of-urls) with the URLs the search returned |
115
+ | `json` format | A model call for every result | The same |
116
+
117
+ ### Options
118
+
119
+ | Field | Default | What it does |
120
+ |---|---|---|
121
+ | `query` | required | What to search for: at most 400 characters and 50 words. Operators the provider supports pass through, such as `site:`, quotes and `-word`. |
122
+ | `limit` | 5 | Most results to return, 1 to 20. |
123
+ | `country` | the provider's | Two-letter country code to rank results for, like `us` or `de`. |
124
+ | `lang` | the provider's | Language of the results, like `en`, `de` or `pt-br`. |
125
+ | `freshness` | none | Only results from the past `day`, `week`, `month` or `year`. |
126
+ | `safe_search` | `moderate` | `off`, `moderate` or `strict` filtering of adult content. |
127
+ | `timeout_ms` | 30000 | Time for the whole search, the scrapes included, from 1,000 to 60,000. A scrape it cuts short is that result's `scrape_timeout` error. |
128
+ | `scrape` | none | Scrape every result with these [scrape options](https://docs.beta.b3os.org/vision/scrape), except the four above. |
129
+
130
+ ### What the provider sees
131
+
132
+ The provider gets the query and its options, sent from the node with the node's key. It gets nothing that identifies your organization, your API key or your users. The result sites are not contacted at all unless you ask for their pages with `scrape`. The node keeps the provider's key to itself: it is never logged, and no error or log line carries the query.
133
+
134
+ ### Billing and limits
135
+
136
+ A search that returns at least one result bills one `vision.page`, and each scraped result bills one `vision.page` as a scrape does. A search with no results, a refused request and a provider failure bill nothing. These pages count within the monthly page allowance, `vision.pages.monthly`, like any other.
137
+
138
+ | Limit | Default |
139
+ |---|---|
140
+ | `vision.search.monthly` | 1,000 searches per UTC calendar month, per organization |
141
+ | `vision.search.rpm` | 60 searches a minute |
142
+
143
+ Past either one, a search answers `429` (`quota_exceeded` with `Retry-After` until the month ends, or `rate_limited`) and sends nothing to the provider. See [limits](https://docs.beta.b3os.org/concepts/limits).
144
+
145
+ ### Errors
146
+
147
+ | Status | Code | When |
148
+ |---|---|---|
149
+ | 400 | `invalid_request` | A field is out of range, a scrape option a search refuses, or a value the provider does not take (such as a country it does not cover); `errors[].pointer` names the field |
150
+ | 429 | `quota_exceeded`, `rate_limited` | The month's searches or the minute's rate are used up |
151
+ | 502 | `search_failed` | The provider did not answer in time, was busy or failed. Retry after `retry_after_s` seconds |
152
+ | 503 | `search_unavailable` | The node has no key for its provider, or the provider refused the node's key, which the node logs for its operator |
153
+
154
+ The provider's own error text never reaches you. The same search serves Firecrawl's `POST /v1/search` and `/v2/search` under `/compat/firecrawl`: see [Firecrawl compatibility](https://docs.beta.b3os.org/compat/firecrawl#endpoints).
155
+
156
+ ## Map a site
157
+
158
+ `POST /v1/vision/map` lists a site's URLs from its sitemaps and from the links on the start page, without scraping each page. Use it to decide what to scrape or crawl. It bills one `vision.page` per call.
159
+
160
+ **curl**
161
+
162
+ ```bash
163
+ curl -s https://beta-api.b3os.org/v1/vision/map \
164
+ -H "Authorization: Bearer $B3OS_API_KEY" \
165
+ -H "Content-Type: application/json" \
166
+ -d '{"url": "https://docs.example.com", "search": "authentication", "limit": 100}'
167
+ ```
168
+ **TypeScript**
169
+
170
+ ```ts
171
+ import { B3OS } from "@b3os/sdk";
172
+
173
+ const b3os = new B3OS();
174
+ const map = await b3os.vision.map({ url: "https://docs.example.com", search: "authentication", limit: 100 });
175
+ for (const link of map.links) console.log(link.url, link.title);
176
+ ```
177
+ **Python**
178
+
179
+ ```python
180
+ from b3os import B3OS
181
+
182
+ b3os = B3OS()
183
+ site = b3os.vision.map({"url": "https://docs.example.com", "search": "authentication", "limit": 100})
184
+ for link in site["links"]:
185
+ print(link["url"], link.get("title"))
186
+ ```
187
+ **MCP**
188
+
189
+ ```text
190
+ Map https://docs.example.com and list the pages about authentication.
191
+ ```
192
+
193
+ The agent calls the `vision_map` tool with `url` and `search`, and gets back URLs and titles.
194
+
195
+ | Field | Default | Meaning |
196
+ |---|---|---|
197
+ | `search` | none | Order results by relevance to this phrase |
198
+ | `sitemap` | `include` | Use sitemaps alongside links (`include`), not at all (`skip`), or only sitemaps (`only`) |
199
+ | `include_subdomains` | `true` | Include URLs on subdomains |
200
+ | `ignore_query_parameters` | `true` | Treat URLs that differ only in their query string as one |
201
+ | `limit` | 1000 | At most 5000 |
202
+
203
+ ## Scrape a list of URLs
204
+
205
+ `POST /v1/vision/batches` scrapes up to 1,000 URLs with the same options, as one job. Each page bills one `vision.page`.
206
+
207
+ **curl**
208
+
209
+ ```bash
210
+ curl -s "https://beta-api.b3os.org/v1/vision/batches?wait=60" \
211
+ -H "Authorization: Bearer $B3OS_API_KEY" \
212
+ -H "Content-Type: application/json" \
213
+ -d '{"urls": ["https://example.com/blog/a", "https://example.com/blog/b"], "scrape": {"formats": ["markdown"]}}'
214
+ ```
215
+ **TypeScript**
216
+
217
+ ```ts
218
+ // .wait() resolves with the finished job
219
+ const batch = await b3os.vision
220
+ .createBatch({
221
+ urls: ["https://example.com/blog/a", "https://example.com/blog/b"],
222
+ scrape: { formats: ["markdown"] },
223
+ })
224
+ .wait();
225
+ // for await walks every page across result pages
226
+ for await (const page of b3os.vision.listBatchPages(batch.id, { status: "succeeded" })) {
227
+ console.log(page.url, page.scrape?.markdown?.length);
228
+ }
229
+ ```
230
+ **Python**
231
+
232
+ ```python
233
+ batch = b3os.vision.create_batch(
234
+ {"urls": ["https://example.com/blog/a", "https://example.com/blog/b"], "scrape": {"formats": ["markdown"]}},
235
+ wait=True, # returns the finished job
236
+ )
237
+ pages = b3os.vision.list_batch_pages(batch["id"], status="succeeded")
238
+ for page in pages.auto_paging_iter(): # every page across result pages
239
+ print(page["url"], len(page["scrape"]["markdown"]))
240
+ ```
241
+ **MCP**
242
+
243
+ ```text
244
+ Scrape these three blog posts and tell me which one mentions pricing: …
245
+ ```
246
+
247
+ The MCP server has no batch tool. For a handful of URLs the agent calls `vision_scrape` once per URL; for hundreds, call the batch endpoint from code.
248
+
249
+ - `scrape` takes the same options as a [single scrape](https://docs.beta.b3os.org/vision/scrape) (formats, engine, actions, profile, headers) and applies them to every URL.
250
+ - `ignore_invalid_urls: true` skips URLs that do not parse and lists them in `result.invalid_urls`, instead of rejecting the request.
251
+ - `max_concurrency` limits how many pages run at once; your concurrency limit caps it either way.
252
+
253
+ The finished job's `result` counts `pages_succeeded` and `pages_failed`. The pages themselves, failures included, are at `GET /v1/vision/batches/{batch_id}/pages` in the order they finished, and they are listed while the batch is still running.
254
+
255
+ ## Crawl a site
256
+
257
+ `POST /v1/vision/crawls` starts at `url`, discovers pages from links and sitemaps breadth first, and scrapes up to `limit` of them. One crawl runs at a time per organization. Each page bills one `vision.page`.
258
+
259
+ **curl**
260
+
261
+ ```bash
262
+ curl -s https://beta-api.b3os.org/v1/vision/crawls \
263
+ -H "Authorization: Bearer $B3OS_API_KEY" \
264
+ -H "Content-Type: application/json" \
265
+ -d '{"url": "https://docs.example.com", "limit": 200, "include_paths": ["^/guides/"],
266
+ "scrape": {"formats": ["markdown"]},
267
+ "webhook": {"url": "https://example.com/hooks/b3os"}}'
268
+ ```
269
+ **TypeScript**
270
+
271
+ ```ts
272
+ // .events() asks the creating request for an event stream; it resumes after a dropped connection
273
+ const events = b3os.vision
274
+ .createCrawl({
275
+ url: "https://docs.example.com",
276
+ limit: 200,
277
+ include_paths: ["^/guides/"],
278
+ scrape: { formats: ["markdown"] },
279
+ })
280
+ .events();
281
+ for await (const event of events) {
282
+ if (event.type === "page.succeeded") console.log(event.page?.url);
283
+ }
284
+ ```
285
+ **Python**
286
+
287
+ ```python
288
+ events = b3os.vision.create_crawl(
289
+ {
290
+ "url": "https://docs.example.com",
291
+ "limit": 200,
292
+ "include_paths": ["^/guides/"],
293
+ "scrape": {"formats": ["markdown"]},
294
+ },
295
+ stream=True, # the creating request answers with the job's event stream
296
+ )
297
+ for event in events:
298
+ if event["type"] == "page.succeeded":
299
+ print(event["page"]["url"])
300
+ ```
301
+ **MCP**
302
+
303
+ ```text
304
+ Crawl the guides on https://docs.example.com, at most 50 pages, and summarize what each guide covers.
305
+ ```
306
+
307
+ The agent calls `vision_crawl` with `url`, `limit` and `include_paths`. On the local MCP server the tool waits up to `wait_s` seconds and returns the pages as Markdown, or the crawl ID while it still runs, to pass back as `job_id`; on the remote server it takes the API body plus `wait` and returns the crawl job. For crawls of hundreds of pages, start them from code or a routine and let the agent read the pages afterwards.
308
+
309
+ | Field | Default | Meaning |
310
+ |---|---|---|
311
+ | `limit` | 100 | Most pages to scrape, at most 500 |
312
+ | `max_depth` | 5 | Most link hops from `url`, at most 20; sitemap URLs count as depth 0 |
313
+ | `include_paths`, `exclude_paths` | none | Regular expressions (RE2) a URL path must match, or must not match |
314
+ | `sitemap` | `include` | `include`, `skip` or `only` |
315
+ | `crawl_entire_domain` | `false` | Follow links to parent and sibling paths, not only below `url` |
316
+ | `allow_subdomains` | `false` | Follow links to subdomains |
317
+ | `allow_external_links` | `false` | Scrape pages on other sites the crawl links to, one hop only |
318
+ | `ignore_query_parameters` | `false` | Treat URLs that differ only in their query as one |
319
+ | `delay_ms` | 250 ms, or robots.txt's Crawl-delay with `respect_robots` | Least gap between this crawl's requests to one host. Whatever you set, job pages to one host start at least 250 ms apart node-wide |
320
+ | `scrape` | `{"formats": ["markdown"]}` | Options for every page, as in a single scrape |
321
+
322
+ A crawl with `respect_robots: true` checks robots.txt and skips what it disallows, listing those URLs in `result.robots_blocked`; without it robots.txt is not consulted. Pages, failures included, are at `GET /v1/vision/crawls/{crawl_id}/pages` with their `depth`, available while the crawl runs.
323
+
324
+ ## Follow, wait or cancel
325
+
326
+ Batches and crawls follow the [job contract](https://docs.beta.b3os.org/concepts/jobs):
327
+
328
+ - `?wait=<seconds>` (up to 60) on the create call returns the finished job if it ends in time, or `202` with the job and a `Location` to poll.
329
+ - `GET .../{id}/events` streams `job.*` lifecycle events plus `page.succeeded` and `page.failed` for each page. Reconnect with `Last-Event-ID` to resume. Events are kept with the job, so the stream reads the same after the node restarts; a job that was running then ends with `job.failed`.
330
+ - `webhook: {url, events}` on create delivers the job's events (the terminal ones unless `events` lists others, `["*"]` for all) to your endpoint, signed; see [webhooks](https://docs.beta.b3os.org/concepts/jobs#webhooks). Events not yet handed to the sender when the node stops are delivered after it restarts. Jobs created through the [Firecrawl surface](https://docs.beta.b3os.org/compat/firecrawl) do not deliver webhooks yet.
331
+ - `POST .../{id}/cancel` stops new pages. Pages already scraped stay listed and billed.
332
+
333
+ Batch and crawl records, with their pages, are kept for 7 days after they finish.
@@ -0,0 +1,152 @@
1
+ # Extract structured data
2
+
3
+ > Fill a JSON Schema from up to 10 pages or PDFs with the node's model, as a job, validated against your schema, with the pages each field came from.
4
+
5
+ Source: https://docs.beta.b3os.org/vision/extract.md
6
+
7
+ `POST /v1/vision/extracts` reads up to 10 URLs and has the model on the node fill your JSON Schema from them. It is a [job](https://docs.beta.b3os.org/concepts/jobs): it answers `202` with the job, or `200` with the finished job when it ends within `?wait=` seconds, and you can stream its events or get a webhook. The answer is validated against your schema before the job succeeds.
8
+
9
+ Note:
10
+ `result.field_sources` is in the SDKs' result types from SDK 0.2.2, the **next** release; the API returns it
11
+ either way.
12
+
13
+ ## Run an extract
14
+
15
+ **curl**
16
+
17
+ ```bash
18
+ curl -s "https://beta-api.b3os.org/v1/vision/extracts?wait=60" \
19
+ -H "Authorization: Bearer $B3OS_API_KEY" \
20
+ -H "Content-Type: application/json" \
21
+ -d '{
22
+ "urls": ["https://example.com/pricing"],
23
+ "prompt": "The price of each plan, per month.",
24
+ "schema": {
25
+ "type": "object",
26
+ "properties": {
27
+ "plans": {
28
+ "type": "array",
29
+ "items": {
30
+ "type": "object",
31
+ "properties": { "name": { "type": "string" }, "usd_per_month": { "type": "number" } },
32
+ "required": ["name", "usd_per_month"]
33
+ }
34
+ }
35
+ },
36
+ "required": ["plans"]
37
+ }
38
+ }'
39
+ ```
40
+ **TypeScript**
41
+
42
+ ```ts
43
+ import { B3OS } from "@b3os/sdk";
44
+
45
+ const b3os = new B3OS(); // reads B3OS_API_KEY
46
+ // .wait() resolves with the finished job
47
+ const job = await b3os.vision
48
+ .createExtract({
49
+ urls: ["https://example.com/pricing"],
50
+ prompt: "The price of each plan, per month.",
51
+ schema: {
52
+ type: "object",
53
+ properties: { plans: { type: "array", items: { type: "object" } } },
54
+ required: ["plans"],
55
+ },
56
+ })
57
+ .wait();
58
+ console.log(job.status, job.result?.data, job.result?.field_sources);
59
+ ```
60
+ **Python**
61
+
62
+ ```python
63
+ job = b3os.vision.create_extract(
64
+ {
65
+ "urls": ["https://example.com/pricing"],
66
+ "prompt": "The price of each plan, per month.",
67
+ "schema": {"type": "object", "properties": {"plans": {"type": "array"}}, "required": ["plans"]},
68
+ },
69
+ wait=True, # returns the finished job
70
+ )
71
+ print(job["status"], job["result"]["data"])
72
+ ```
73
+ **MCP**
74
+
75
+ ```text
76
+ What does each plan on https://example.com/pricing cost per month?
77
+ ```
78
+
79
+ The MCP server has no extract tool yet. The agent calls `vision_scrape` for the page and reads the prices from its Markdown; to get them validated against a schema, call the extract endpoint from code.
80
+
81
+ The request:
82
+
83
+ | Field | Meaning |
84
+ |---|---|
85
+ | `urls` | 1 to 10 URLs (`vision.extract.urls_max`). A URL given twice is read once. PDFs are read as a [scrape reads them](https://docs.beta.b3os.org/vision/scrape#read-a-pdf). |
86
+ | `schema` | The JSON Schema of the answer. At most 64 KiB and 32 levels deep, and its `$ref`s may only point inside it (`#/...`): nothing is ever fetched to resolve one. A draft-07 schema from zod works. |
87
+ | `prompt` | What to extract, in words. With `schema` it guides the model; without it the model answers one JSON object, which is not validated. One of the two is required. |
88
+ | `scrape` | The page options of a [batch](https://docs.beta.b3os.org/vision/crawl#scrape-a-list-of-urls), except that the only format is `markdown`. `only_main_content` is on by default. |
89
+ | `model` | A model from `GET /v1/infer/models`; the node's own model by default. |
90
+ | `webhook`, `metadata` | As for every [job](https://docs.beta.b3os.org/concepts/jobs). |
91
+
92
+ A schema that does not compile, uses a remote `$ref`, or is too large or deep answers `400` with a pointer under `/schema`, before anything runs or bills.
93
+
94
+ ## What comes back
95
+
96
+ ```json
97
+ {
98
+ "id": "job_01m5t3vh38hw2qyvr3fx3tx6vm",
99
+ "object": "job",
100
+ "kind": "vision.extract",
101
+ "status": "succeeded",
102
+ "result": {
103
+ "data": { "plans": [{ "name": "Free", "usd_per_month": 0 }, { "name": "Team", "usd_per_month": 49 }] },
104
+ "sources": ["https://example.com/pricing"],
105
+ "field_sources": { "plans": ["https://example.com/pricing"] },
106
+ "pages": [{ "url": "https://example.com/pricing", "status": "succeeded", "final_url": "https://example.com/pricing",
107
+ "content_type": "text/html", "chars": 18211, "truncated": false, "pdf_pages": null }],
108
+ "usage": { "pages_billed": 1, "input_tokens": 5120, "output_tokens": 61, "model_calls": 1 },
109
+ "warnings": []
110
+ },
111
+ "timing": { "scrape_ms": 51.0, "infer_ms": 3301.7, "total_ms": 3409.9 }
112
+ }
113
+ ```
114
+
115
+ The values above are the API reference's example, not a measurement.
116
+
117
+ - `data` is the filled object, valid against your schema.
118
+ - `field_sources` names, for each top-level field of `data`, the pages it came from; `sources` is every page that contributed.
119
+ - `pages` lists every URL with how it was read. A URL that could not be scraped has its error there, and the job goes on with the others.
120
+ - `usage` counts the pages billed and the model's tokens and calls.
121
+ - `warnings` has the pages' own warnings, pieces left out, and the conflicts the merge resolved.
122
+
123
+ ## How the model reads the pages
124
+
125
+ The pages' Markdown goes to the model in one call when it fits the model's context window, each page in a `<page url="…" title="…">` element. When it does not fit, each page goes alone, and a long page is cut at its headings, then at paragraphs, into pieces that fit; the answers are then merged: objects key by key, arrays added together without duplicates, and for a single value the first page's. When a later page says something else for that value, a warning names both (`/plans/0/usd_per_month: https://a.example says 49, https://b.example says 59; kept the first`). A job makes at most 24 model calls; pieces past that are left out, with a warning.
126
+
127
+ Each call constrains the model's output to your schema, with every field also allowed to be `null`, so it can say "not stated" instead of making a value up. In a call over several pages it also has to name, from your URLs only, the pages each field came from. The system prompt tells the model to use only what the pages state and never to follow instructions found in them. The data is still the model's reading of the pages: check the values that matter.
128
+
129
+ Then the answer is checked against your schema:
130
+
131
+ - A `null` your schema does not allow for an optional field, or in an array, is removed.
132
+ - A required field that is still `null` fails the job with [`extract_fields_missing`](https://docs.beta.b3os.org/errors#extract_fields_missing): `errors[]` has one item per missing field (`/plans/1/usd_per_month: not stated in any of the pages`) and `partial_data` the rest of the answer. This is never retried, since a retry could only invent the value.
133
+ - An answer that does not match the schema is asked again once, with the errors; a second miss fails with [`extraction_failed`](https://docs.beta.b3os.org/errors#extraction_failed) and `reason: invalid_answer`. An answer that is cut off or is not JSON is asked again once, shorter, then fails with `reason: answer_too_long`.
134
+
135
+ ## When it fails
136
+
137
+ | Code | Status | Meaning |
138
+ |---|---|---|
139
+ | [`invalid_request`](https://docs.beta.b3os.org/errors#invalid_request) | 400 | Neither `schema` nor `prompt`, a schema that is not one an extract can fill, or a format other than `markdown` in `scrape`. Nothing runs. |
140
+ | [`forbidden`](https://docs.beta.b3os.org/errors#forbidden) | 403 | The key lacks `infer:run`. An extract calls the model as you, so it needs `infer:run` as well as `vision:run`. Nothing runs. |
141
+ | [`product_unavailable`](https://docs.beta.b3os.org/errors#product_unavailable) | 503 | `reason: model`: this node serves no model. Nothing runs. |
142
+ | [`extract_fields_missing`](https://docs.beta.b3os.org/errors#extract_fields_missing) | 422 | In the job's `error`: required fields no page states. |
143
+ | [`extraction_failed`](https://docs.beta.b3os.org/errors#extraction_failed) | 502 | In the job's `error`: `reason` is `invalid_answer`, `answer_too_long`, `no_pages` (no URL could be scraped; each page's error is in `pages`) or `model_unavailable`. |
144
+ | [`scrape_timeout`](https://docs.beta.b3os.org/errors#scrape_timeout) | 504 | In the job's `error`: the pages were not all read within the job's 300 seconds. |
145
+
146
+ ## Billing and limits
147
+
148
+ Each page the job reads bills one `vision.page` (a PDF one per page read), as a batch page does, and every model call bills its tokens as `infer.input_tokens` and `infer.output_tokens` through [infer](https://docs.beta.b3os.org/infer), counted against your organization's per-minute token limit. A job that fails or is canceled after it read pages or called the model keeps those billed, `extract_fields_missing` included: the work was done. A request refused before the job starts bills nothing. Your current values for `vision.extract.urls_max`, `vision.pages.monthly` and the scrape concurrency the job's pages wait for are on [vision limits](https://docs.beta.b3os.org/vision/limits).
149
+
150
+ ## From Firecrawl and routines
151
+
152
+ Firecrawl's `POST /v1/extract` and `/v2/extract` run the same job; see [Firecrawl compatibility](https://docs.beta.b3os.org/compat/firecrawl). In a [routine](https://docs.beta.b3os.org/routines), the step `vision/extract@1` runs it and its outputs are the finished job, so `steps.<id>.outputs.result.data` is the filled object. Steps run as the key that published the routine version, so that key needs `infer:run` as well as `vision:run`; without it the step fails with `403 forbidden` and nothing runs ([Product steps](https://docs.beta.b3os.org/routines/callables)).
@@ -0,0 +1,15 @@
1
+ # The B3OS fetcher
2
+
3
+ > What the B3OS-Vision user agent is, when it visits a site, what it sends, and how a site operator reaches us.
4
+
5
+ Source: https://docs.beta.b3os.org/vision/fetcher.md
6
+
7
+ The B3OS fetcher is vision's fetch tier acting for one user's request: a B3OS customer asked to read the page. It does not crawl on its own, and it reads robots.txt only when that request asks.
8
+
9
+ It is used only after the fetch tier's first request, sent with Chrome's headers, gets a 403 bot challenge. It asks once, never after a 429 or a 503. If it gets the page, that customer's requests to the site start with it for up to an hour, then with Chrome's headers again. If it is refused too, it does not ask for that page again for up to an hour, nor for any page of the site once two pages refused it, and the browser tier may still read the page.
10
+
11
+ It sends `User-Agent: Mozilla/5.0 (compatible; B3OS-Vision/<version>; +https://docs.beta.b3os.org/vision/fetcher)`, a plain `Accept`, `Accept-Language` and `Accept-Encoding`, and no client hints or `Sec-Fetch-*` headers, from the node's own address.
12
+
13
+ A scrape's `fetch_identity` says which identity the fetch tier's last request used (`chrome` or `honest`), and `tier_reason` is `challenged` when the browser served the page because the site challenged the fetch tier.
14
+
15
+ Site operators: write to abuse@b3os.org with your domain, and we stop every request to it from B3OS, the fetcher's and the browser's.