@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,311 @@
1
+ # Browser sessions
2
+
3
+ > Claim a dedicated browser for your agent, drive it with batched browser actions in one round trip, or connect Playwright and Puppeteer over CDP.
4
+
5
+ Source: https://docs.beta.b3os.org/vision/sessions.md
6
+
7
+ A session is one whole browser process, yours alone, claimed from a warm pool and ready to drive. Use a session when your agent needs to click through an app, fill forms, or keep state across many steps. For a single page, a [scrape](https://docs.beta.b3os.org/vision/scrape) with `actions` is cheaper. Chrome runs with its own sandbox on; [vision](https://docs.beta.b3os.org/vision#browsers) explains what a session shares with others on the node.
8
+
9
+ ## Create a session
10
+
11
+ **curl**
12
+
13
+ ```bash
14
+ 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 '{"viewport": {"width": 1440, "height": 900}, "timeout_s": 600}'
18
+ ```
19
+ **TypeScript**
20
+
21
+ ```ts
22
+ import { B3OS } from "@b3os/sdk";
23
+
24
+ const b3os = new B3OS();
25
+ const session = await b3os.vision.createSession({ viewport: { width: 1440, height: 900 }, timeout_s: 600 });
26
+ console.log(session.id, session.cdp_url);
27
+ ```
28
+ **Python**
29
+
30
+ ```python
31
+ from b3os import B3OS
32
+
33
+ b3os = B3OS()
34
+ session = b3os.vision.create_session({"viewport": {"width": 1440, "height": 900}, "timeout_s": 600})
35
+ print(session["id"], session["cdp_url"])
36
+ ```
37
+ **MCP**
38
+
39
+ ```text
40
+ Open https://beta.b3os.org/demo/login/ in a browser, keep it open, and tell me what the page asks for.
41
+ ```
42
+
43
+ The agent calls `vision_act` with `url` and `keep_session: true`. Without `keep_session` the tool closes the session it created when the call ends; with it, the result carries the session ID for the next call. `vision_act` is on the local MCP server only. To start signed in, pass `profile` (a profile ID or name) and the tool loads it into the session it creates; the agent can then read that profile's cookies (see [what the export rules cover](https://docs.beta.b3os.org/vision/profiles#what-the-export-rules-cover)).
44
+
45
+ The session is `active` until you close it or `timeout_s` passes (300 seconds by default, at most 1,800). It bills `vision.browser_ms` from claim to close. Other fields: `browser` (`chrome`, full Chrome, by default; `headless-shell` starts a chrome-headless-shell cold), `profile` to start signed in, `persist_profile` to save cookies back when it closes, `locale` and `timezone` (the node's egress location, `en-US` and `America/Los_Angeles`, by default), `user_agent`, `block_ads` and `block_resources`. The session object says which `browser` it runs.
46
+
47
+ <a href="https://beta.b3os.org/gallery/docs-site/shot-vision/fdcf05813edd9954.webp"><img src="https://beta.b3os.org/gallery/docs-site/shot-vision/fdcf05813edd9954.webp" srcset="https://beta.b3os.org/gallery/docs-site/shot-vision/d0069476dfee2eaa.webp 640w, https://beta.b3os.org/gallery/docs-site/shot-vision/c29d8a34002884b4.webp 1080w, https://beta.b3os.org/gallery/docs-site/shot-vision/fdcf05813edd9954.webp 2910w" sizes="(max-width: 640px) calc(100vw - 60px), 760px" alt="Browser sessions in the dashboard: image from the capture docs-site/shot-vision" width="2910" height="2038" loading="lazy" /></a>
48
+
49
+ <sub>Captured 2026-11-15 from commit `2aac696d` on a GitHub Actions runner (colo MSP), one call, label `mock` (the dashboard in mock mode). Case `docs-site/shot-vision`.</sub>
50
+
51
+ ## Drive it with batched actions
52
+
53
+ `POST /v1/vision/sessions/{session_id}/act` runs a list of browser actions in order on one page and returns every result in one round trip, so an agent pays one call for a whole sequence:
54
+
55
+ **curl**
56
+
57
+ ```bash
58
+ curl -s "https://beta-api.b3os.org/v1/vision/sessions/$SESSION_ID/act" \
59
+ -H "Authorization: Bearer $B3OS_API_KEY" \
60
+ -H "Content-Type: application/json" \
61
+ -d '{"actions": [
62
+ {"kind": "navigate", "url": "https://beta.b3os.org/demo/login/"},
63
+ {"kind": "type", "target": {"selector": "#email"}, "text": "agent@example.com"},
64
+ {"kind": "type", "target": {"selector": "#password"}, "text": "any text"},
65
+ {"kind": "click", "target": {"role": "button", "name": "Sign in"}},
66
+ {"kind": "wait", "for": {"text": "Launch plan"}},
67
+ {"kind": "markdown"}
68
+ ]}'
69
+ ```
70
+ **TypeScript**
71
+
72
+ ```ts
73
+ const result = await b3os.vision.act(session.id, {
74
+ actions: [
75
+ { kind: "navigate", url: "https://beta.b3os.org/demo/login/" },
76
+ { kind: "type", target: { selector: "#email" }, text: "agent@example.com" },
77
+ { kind: "type", target: { selector: "#password" }, text: "any text" },
78
+ { kind: "click", target: { role: "button", name: "Sign in" } },
79
+ { kind: "wait", for: { text: "Launch plan" } },
80
+ { kind: "markdown" },
81
+ ],
82
+ });
83
+ console.log(result.ok, result.results.at(-1)?.markdown);
84
+ ```
85
+ **Python**
86
+
87
+ ```python
88
+ result = b3os.vision.act(session["id"], {"actions": [
89
+ {"kind": "navigate", "url": "https://beta.b3os.org/demo/login/"},
90
+ {"kind": "type", "target": {"selector": "#email"}, "text": "agent@example.com"},
91
+ {"kind": "type", "target": {"selector": "#password"}, "text": "any text"},
92
+ {"kind": "click", "target": {"role": "button", "name": "Sign in"}},
93
+ {"kind": "wait", "for": {"text": "Launch plan"}},
94
+ {"kind": "markdown"},
95
+ ]})
96
+ print(result["ok"], result["results"][-1].get("markdown"))
97
+ ```
98
+ **MCP**
99
+
100
+ ```text
101
+ In the open session, sign in to the demo app with agent@example.com and any password, wait for the Launch plan board and read it back to me.
102
+ ```
103
+
104
+ The agent calls `vision_act` with the session's `session_id` and the steps, which run as one batch.
105
+
106
+ Each result has its `kind`, `status` (`ok`, `failed` or `skipped`) and `duration_ms`, plus what the action produced: the URL and status code for `navigate`, the value for `evaluate`, the image for `screenshot`, the page for `markdown`. Execution stops at the first failed action unless `continue_on_error` is set; later actions are reported as `skipped`, and the failed one carries its error, such as [`target_not_found`](https://docs.beta.b3os.org/errors#target_not_found). A batch holds up to 100 actions and must finish within `timeout_ms` (30 seconds by default, 60 at most). JavaScript dialogs never stall a batch: `alert`, `confirm` and `prompt` are dismissed (so `confirm` returns false and `prompt` null; set `accept_confirm: true` to accept `confirm`), `beforeunload` is accepted so the navigation goes ahead, and each dialog is listed in the `dialogs` of the action that was running, as `{type, message, action}`. Scrape `actions` follow the same rules. Set `target_id` to act on a page other than the most recently active one; `GET` on the session lists its pages.
107
+
108
+ One act call as recorded, on a session created with a 1280x800 viewport: it opens a pinned copy of the docs page [Scrape a page](https://docs.beta.b3os.org/vision/scrape), clicks its Python tab by role and name and waits for the page to settle, takes a screenshot and reads the page as Markdown. The screenshot shows the tab the click selected:
109
+
110
+ **Response 200**
111
+
112
+ ```json
113
+ {
114
+ "object": "act_result",
115
+ "ok": true,
116
+ "results": [
117
+ {
118
+ "delivery": "delivered_verified",
119
+ "duration_ms": 192.169,
120
+ "kind": "navigate",
121
+ "retry": "safe",
122
+ "status": "ok",
123
+ "status_code": 200,
124
+ "url": "https://beta.b3os.org/fixtures/vision/docs-page"
125
+ },
126
+ {
127
+ "delivery": "delivered_unverified",
128
+ "duration_ms": 63.696,
129
+ "kind": "click",
130
+ "retry": "unsafe",
131
+ "settled_by": "quiet",
132
+ "settled_ms": 50.893,
133
+ "status": "ok"
134
+ },
135
+ {
136
+ "delivery": "not_delivered",
137
+ "duration_ms": 116.935,
138
+ "kind": "screenshot",
139
+ "retry": "safe",
140
+ "screenshot": {
141
+ "data_base64": "https://beta.b3os.org/gallery/vision/act-fixture/75b349a1cd41b665.jpg",
142
+ "format": "jpeg",
143
+ "height": 800,
144
+ "width": 1280
145
+ },
146
+ "status": "ok"
147
+ },
148
+ {
149
+ "delivery": "not_delivered",
150
+ "duration_ms": 3.056,
151
+ "kind": "markdown",
152
+ "markdown": "# Scrape a page\n\nFetch one URL and get it back as Markdown, HTML, text, links, metadata or a screenshot, in one synchronous call.\n\n## Scrape one page\n\nSend the URL and the formats you want. The response arrives when the page is done, within `timeout_ms` (30 seconds by default).\n\n```shell\ncurl -s https://beta-api.b3os.org/v1/vision/scrape \\\n -H \"Authorization: Bearer $B3OS_API_KEY\" \\\n -H \"Content…",
153
+ "retry": "safe",
154
+ "status": "ok"
155
+ }
156
+ ],
157
+ "session_id": "brs_01m6h0b5y2f6tayedzjgv1p283",
158
+ "timing": {
159
+ "actions_ms": 376.274,
160
+ "attach_ms": 0.501,
161
+ "total_ms": 376.928
162
+ }
163
+ }
164
+ ```
165
+
166
+ **Request**
167
+
168
+ ```bash
169
+ curl -s -X POST 'https://beta-api.b3os.org/v1/vision/sessions/brs_01m6h0b5y2f6tayedzjgv1p283/act' \
170
+ -H "Authorization: Bearer $B3OS_API_KEY" \
171
+ -H 'Content-Type: application/json' \
172
+ -d '{"actions":[{"kind":"navigate","url":"https://beta.b3os.org/fixtures/vision/docs-page.html"},{"kind":"click","target":{"role":"tab","name":"Python"},"settle":true},{"kind":"screenshot"},{"kind":"markdown"}]}'
173
+ ```
174
+
175
+ **Server-Timing**
176
+
177
+ ```http
178
+ server-timing: edge_auth;dur=0.000, edge_upstream;dur=391.000, attach;dur=0.501, actions;dur=376.274, total;dur=377.009
179
+ x-request-id: req_01m6h0b6df4jdw8jkpxw63yd42
180
+ ```
181
+
182
+ <img src="https://beta.b3os.org/gallery/vision/act-fixture/75b349a1cd41b665.jpg" alt="The jpeg the call returned (vision/act-fixture)" width="1280" height="800" loading="lazy" />
183
+
184
+ <sub>Captured 2026-11-03 from commit `794650bb` on the host the node runs on, one call, label `fixture` (recorded against a pinned fixture); long values abridged. Case `vision/act-fixture`.</sub>
185
+
186
+ ### Browser actions
187
+
188
+ | Kind | Fields | Does |
189
+ |---|---|---|
190
+ | `navigate` | `url`, `wait_until` (`load`, `domcontentloaded`, `networkidle`), `settle` | Load a URL |
191
+ | `click` | `target`, `button`, `count`, `modifiers`, `settle` | Click an element |
192
+ | `hover` | `target` | Move the pointer over an element |
193
+ | `type` | `text`, `target`, `clear`, `interval_ms`, `settle` | Type into the focused or targeted field |
194
+ | `key` | `key` (such as `Enter`), `modifiers`, `settle` | Press a key |
195
+ | `scroll` | `to`, `by` or `target` | Scroll to a point, by an amount, or until the target is in view |
196
+ | `select` | `target`, `value`, `settle` | Choose an option in a select |
197
+ | `wait` | `ms`, or `for` one of `selector`, `text`, `url`, `network_idle` | Wait a fixed time or for a condition |
198
+ | `evaluate` | `expression` | Run JavaScript in the page and return its JSON result |
199
+ | `screenshot` | `target`, `full_page`, `format`, `quality` | Capture the page or an element |
200
+ | `markdown` | `only_main_content` | Return the page as Markdown |
201
+ | `snapshot` | `mode` (`skeleton`, `full`), `root`, `max_tokens` | Return an outline of the page with a ref for each control and heading |
202
+
203
+ A `target` matches by CSS `selector`, visible `text` (`exact` for a whole match) or ARIA `role` plus accessible `name`, optionally `within` a scope; `nth` picks one of several matches. Actions that wait for a target take `timeout_ms` (10 seconds by default). Render scripts use the same kinds and fields, except `evaluate`, `screenshot`, `markdown`, `snapshot` and `settle`.
204
+
205
+ ### Wait for the page after an action
206
+
207
+ A click returns as soon as the browser has the input, which is usually before the page has answered it. Add `settle` to a `click`, `type`, `key`, `select` or `navigate` and the action returns once the page is quiet instead, so the next `snapshot` or `markdown` sees the result:
208
+
209
+ ```json
210
+ {"kind": "click", "target": {"role": "button", "name": "Add to cart"}, "settle": true}
211
+ ```
212
+
213
+ The page is settled when its document is at least interactive (loaded, if the action led to a new page), no page load and no `fetch` or XHR to the page's own site that started during the action is still running, and the DOM and those requests have been quiet for `quiet_ms` (50 by default). Analytics on other sites, images, scripts and event streams do not hold it. A change the page schedules on a timer more than `quiet_ms` after the last one is not waited for, so raise `quiet_ms` for a page that animates in steps. The result carries `settled_ms` (from the browser's acknowledgement of the input) and `settled_by`: `quiet`, `navigation` (the action led to a new page, which loaded and went quiet) or `deadline`. A page that never goes quiet, such as one with a ticker, returns after `timeout_ms` (5000 by default) with `settled_by: deadline`, and the action still succeeds. Set both with `"settle": {"quiet_ms": 100, "timeout_ms": 3000}`. The observer runs in an isolated world, so the page's scripts never see it. Tested by `act_settle_waits_for_the_page_to_go_quiet` (crates/b3os-vision/tests/e2e.rs).
214
+
215
+ `snapshot` gives an agent the page to choose from: one element per line, indented by container, each control and heading with a ref. On a settings page with a 30-post archive list:
216
+
217
+ ```text
218
+ - banner:
219
+ - link "Home" [ref=3f9a2c10:e1]
220
+ - navigation "Main":
221
+ - link "Docs" [ref=3f9a2c10:e2]
222
+ - link "Pricing" [ref=3f9a2c10:e3]
223
+ - main:
224
+ - heading "Settings" [level=1] [ref=3f9a2c10:e4]
225
+ - form "Profile":
226
+ - textbox "Display name": "Ada" [ref=3f9a2c10:e5]
227
+ - checkbox "Newsletter" [checked] [ref=3f9a2c10:e6]
228
+ - button "Save" [ref=3f9a2c10:e7]
229
+ - button "Cancel" [ref=3f9a2c10:e8]
230
+ - heading "Archive" [level=2] [ref=3f9a2c10:e9]
231
+ - link "Post 1" [ref=3f9a2c10:e10]
232
+ - link "Post 2" [ref=3f9a2c10:e11]
233
+ - link "Post 3" [ref=3f9a2c10:e12]
234
+ - link "Post 4" [ref=3f9a2c10:e13]
235
+ - link "Post 5" [ref=3f9a2c10:e14]
236
+ - link "Post 6" [ref=3f9a2c10:e15]
237
+ - link "Post 7" [ref=3f9a2c10:e16]
238
+ - link "Post 8" [ref=3f9a2c10:e17]
239
+ - link (22 more)
240
+ ```
241
+
242
+ The default `skeleton` mode lists landmarks, headings and controls and counts the controls of one role past the eighth in a container; `full` also lists text blocks and images. The outline stops at `max_tokens` (4,000 by default, counted as characters / 4) and says so with `truncated: true`; the step is still `ok`. Act on a listed element with `"target": {"ref": "3f9a2c10:e7"}`, in the same batch or a later one on the same page. A ref names that element and nothing else: if a re-render replaced it, even with an identical button, or the page navigated, the action fails with [`stale_ref`](https://docs.beta.b3os.org/errors#stale_ref) and nothing is clicked. Take a new snapshot then.
243
+
244
+ A click lands only where its target is what the page draws. Before pressing, vision checks the element at the target's centre: it must be the target, something inside it or one of its labels. A header or banner fixed or sticky to the window gets one scroll to clear the target. Any other cover, such as a cookie dialog or a modal, fails the click with [`target_covered`](https://docs.beta.b3os.org/errors#target_covered) after half a second, and no event reaches the page. The error's `detail` names the cover by tag, id, classes and its first 40 characters of text, so the next step can dismiss it, for example `{"kind": "click", "target": {"text": "Reject all"}}`. A checkbox or radio that a site hides and draws with its label is clicked through that label.
245
+
246
+ Every action's result says whether its input reached the page, in `delivery`, and whether sending it again is safe, in `retry`, so an agent that retries on its own knows when a second click would click twice:
247
+
248
+ | `delivery` | When | `retry` |
249
+ |---|---|---|
250
+ | `delivered_verified` | A `navigate` whose document loaded | `safe` |
251
+ | `delivered_unverified` | Input the browser acknowledged: a click, typed text, a key, a select, an `evaluate`; also `hover` and `scroll` (both `safe`) | `unsafe` |
252
+ | `delivery_uncertain` | Part of it may have landed: a `navigate` that timed out (`safe`, it is a GET), `type` with `interval_ms` cut off | `unknown` |
253
+ | `not_delivered` | Nothing was sent: the target was missing, covered or stale, a field or option check refused, the step was skipped, or the action sends no input (`wait`, `screenshot`, `markdown`, `snapshot`) | `safe` |
254
+ | `unknown` | The browser stopped answering, or the batch ran out of time, after the input was sent | `unknown` |
255
+
256
+ An `evaluate` that throws ran up to the throw: `delivered_unverified` with `retry: unknown`.
257
+
258
+ A result carries `warnings` only when something changed its answer, each starting with its code as a scrape's do: a `screenshot` with `full_page: true` of a page taller than 16,384 px (the screenshot limit) is cut there and says `screenshot_truncated: the page is <height> px tall and the full-page screenshot shows the top 16384 px ...`, and a `target` screenshot of a taller element says the same of the element; a `markdown` read says when main content was under a quarter of the page and the whole page came back, or when a markup limit or the extraction deadline shortened it. Scroll and take viewport screenshots for the rest of a tall page. Tested in crates/b3os-vision/tests/e2e.rs.
259
+
260
+ `wait` with `for: {network_idle: true}` holds once the document has loaded and no request has been in flight, sent or ended for half a second, counted from the start of the wait (the API reference gives the exact rule). Requests count from the moment they are sent, so a slow XHR keeps the wait going until it answers.
261
+
262
+ The scripts vision runs in the page to find targets, check fields, wait and take snapshots run in an isolated world, apart from the page's own scripts: they leave no global behind, and they still work on a page that replaced built-ins such as `querySelectorAll`. Only `evaluate` runs in the page's own JavaScript world, as your code.
263
+
264
+ ### Timeline
265
+
266
+ `GET /v1/vision/sessions/{session_id}/timeline` lists every action the session ran, one row per action (skipped ones included), with its `kind`, `status`, `error`, `started_at`, `at_ms` (milliseconds since the session was created), `duration_ms` and the `target` box it acted on, in viewport pixels. It also returns the cursor path: each pointer event with its position, `type` and button, from actions (`source: act`) and from `Input.dispatchMouseEvent` commands a CDP client sent over the session's socket (`source: cdp`). Create the session with `thumbnails: true` to give each row a JPEG of the viewport after the action, at most 320 px wide; each thumbnail adds a capture to the act call's time. The timeline is bounded (the caps are in the [API reference](https://docs.beta.b3os.org/api/get-v1-vision-sessions-session-id-timeline); `dropped` counts what did not fit). Thumbnails stay while the session is open and for a short time after it closes; a session closed by a node restart has an empty timeline.
267
+
268
+ ## Connect over CDP
269
+
270
+ Every session has a `cdp_url`, a WebSocket that speaks the Chrome DevTools Protocol for that session only. Point Playwright or Puppeteer at it with your key in the `Authorization` header:
271
+
272
+ **Playwright**
273
+
274
+ ```ts
275
+ import { chromium } from "playwright";
276
+
277
+ const browser = await chromium.connectOverCDP(session.cdp_url, {
278
+ headers: { Authorization: `Bearer ${process.env.B3OS_API_KEY}` },
279
+ });
280
+ const page = browser.contexts()[0].pages()[0] ?? (await browser.contexts()[0].newPage());
281
+ await page.goto("https://example.com");
282
+ console.log(await page.title());
283
+ ```
284
+ **Puppeteer**
285
+
286
+ ```ts
287
+ import puppeteer from "puppeteer-core";
288
+
289
+ const browser = await puppeteer.connect({
290
+ browserWSEndpoint: session.cdp_url,
291
+ headers: { Authorization: `Bearer ${process.env.B3OS_API_KEY}` },
292
+ });
293
+ const [page] = await browser.pages();
294
+ await page.goto("https://example.com");
295
+ console.log(await page.title());
296
+ ```
297
+
298
+ The CDP proxy exposes only the session's own pages. It refuses `SystemInfo.*`, `Tethering.*`, `Extensions.*` and `Cast.*`, and every `Browser.*` method except the ones Playwright and Puppeteer need to drive a browser (`Browser.getVersion`, the permission methods, window bounds, `Browser.setDownloadBehavior` and `Browser.cancelDownload`). It also refuses other sessions' targets, host file access (`DOM.setFileInputFiles` and file drags), downloads to host paths (downloads land in the session's own directory, wiped with the browser), and navigation to anything but `http:`, `https:` and `about:blank`. A refused call gets a CDP error whose `data` is the code, [`cdp_method_blocked`](https://docs.beta.b3os.org/errors#cdp_method_blocked), as a string the way Chrome's own errors carry it; `error.b3os` has the `code` and `status`. Creating a browser context with its own proxy (`proxyServer`, `proxyBypassList` or `originsWithUniversalNetworkAccess`, which Playwright's `newContext({proxy})` sends) is refused with `forbidden`: all of the session's traffic goes through its own egress route. From 2026-11-16, reading the browser's cookies and storage needs `vision:profiles:export` (see [what the export rules cover](https://docs.beta.b3os.org/vision/profiles#what-the-export-rules-cover)), so with a default key Playwright's `context.cookies()` and `storageState()` and Puppeteer's `page.cookies()` get `forbidden`. A client that falls more than a few megabytes behind the stream is disconnected, and so is one that sends a message over 32 MiB. A session takes at most 4 CDP clients at once (a driver, a reconnect and a tool beside them fit); the next gets [`429 concurrency_limited`](https://docs.beta.b3os.org/errors#concurrency_limited) until one disconnects. A message with a repeated member, such as two `method` fields, gets the JSON-RPC parse error `-32700`.
299
+
300
+ [agent-browser](https://docs.beta.b3os.org/vision/agent-browser) connects the same way, with the key in `AGENT_BROWSER_CDP_HEADERS`.
301
+
302
+ From a browser page, where you cannot set headers, get a single-use [stream ticket](https://docs.beta.b3os.org/concepts/auth#stream-tickets) with `POST /v1/vision/sessions/{session_id}/ticket` and open the socket within 30 seconds with `?ticket=tkt_...`.
303
+
304
+ ## Close the session
305
+
306
+ ```bash
307
+ curl -s -X DELETE "https://beta-api.b3os.org/v1/vision/sessions/$SESSION_ID" \
308
+ -H "Authorization: Bearer $B3OS_API_KEY"
309
+ ```
310
+
311
+ Closing destroys the browser and returns the session with its final `usage.browser_ms`. With `persist_profile`, cookies and storage are saved to the profile first. Closing a closed session returns it unchanged. Sessions that are closed or expired stay listed for 7 days, also across a restart of the node; calling `act` on one fails with [`session_closed`](https://docs.beta.b3os.org/errors#session_closed). `closed_reason` says why a session ended: `deleted`, `expired`, `browser_exited` (its browser stopped under it) or `node_restart` (the node stopped or restarted while it was open; browser time is billed up to the stop and not after it).