@b3os/sdk 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/README.md +172 -42
  2. package/dist/cjs/core/bytes.d.ts +30 -0
  3. package/dist/cjs/core/bytes.js +115 -0
  4. package/dist/cjs/core/bytes.js.map +1 -0
  5. package/dist/cjs/core/client.d.ts +80 -3
  6. package/dist/cjs/core/client.js +236 -33
  7. package/dist/cjs/core/client.js.map +1 -1
  8. package/dist/cjs/core/errors.d.ts +16 -4
  9. package/dist/cjs/core/errors.js +9 -6
  10. package/dist/cjs/core/errors.js.map +1 -1
  11. package/dist/cjs/core/handle.d.ts +36 -0
  12. package/dist/cjs/core/handle.js +97 -0
  13. package/dist/cjs/core/handle.js.map +1 -0
  14. package/dist/cjs/core/index.d.ts +8 -4
  15. package/dist/cjs/core/index.js +14 -1
  16. package/dist/cjs/core/index.js.map +1 -1
  17. package/dist/cjs/core/login.d.ts +24 -0
  18. package/dist/cjs/core/login.js +93 -0
  19. package/dist/cjs/core/login.js.map +1 -0
  20. package/dist/cjs/core/namespace.d.ts +1 -1
  21. package/dist/cjs/core/namespace.js +1 -1
  22. package/dist/cjs/core/op.d.ts +11 -1
  23. package/dist/cjs/core/timing.d.ts +1 -1
  24. package/dist/cjs/core/timing.js +8 -1
  25. package/dist/cjs/core/timing.js.map +1 -1
  26. package/dist/cjs/core/traces-api.d.ts +42 -0
  27. package/dist/cjs/core/traces-api.js +54 -0
  28. package/dist/cjs/core/traces-api.js.map +1 -0
  29. package/dist/cjs/core/traces.d.ts +120 -0
  30. package/dist/cjs/core/traces.js +306 -0
  31. package/dist/cjs/core/traces.js.map +1 -0
  32. package/dist/cjs/core/transport.js +1 -1
  33. package/dist/cjs/core/transport.js.map +1 -1
  34. package/dist/cjs/core/util.d.ts +15 -3
  35. package/dist/cjs/core/util.js +54 -2
  36. package/dist/cjs/core/util.js.map +1 -1
  37. package/dist/cjs/core/ws.d.ts +4 -0
  38. package/dist/cjs/core/ws.js +7 -4
  39. package/dist/cjs/core/ws.js.map +1 -1
  40. package/dist/cjs/generated/client.d.ts +2 -2
  41. package/dist/cjs/generated/client.js +2 -2
  42. package/dist/cjs/generated/errors.d.ts +1 -1
  43. package/dist/cjs/generated/errors.js +42 -0
  44. package/dist/cjs/generated/errors.js.map +1 -1
  45. package/dist/cjs/generated/ids.d.ts +12 -0
  46. package/dist/cjs/generated/ids.js +3 -0
  47. package/dist/cjs/generated/ids.js.map +1 -1
  48. package/dist/cjs/generated/jobs.js +1 -1
  49. package/dist/cjs/generated/ns/actions.d.ts +48 -6
  50. package/dist/cjs/generated/ns/actions.js +59 -6
  51. package/dist/cjs/generated/ns/actions.js.map +1 -1
  52. package/dist/cjs/generated/ns/infer.d.ts +185 -54
  53. package/dist/cjs/generated/ns/infer.js +28 -74
  54. package/dist/cjs/generated/ns/infer.js.map +1 -1
  55. package/dist/cjs/generated/ns/keys.d.ts +14 -1
  56. package/dist/cjs/generated/ns/keys.js +24 -1
  57. package/dist/cjs/generated/ns/keys.js.map +1 -1
  58. package/dist/cjs/generated/ns/render.d.ts +115 -6
  59. package/dist/cjs/generated/ns/render.js +135 -7
  60. package/dist/cjs/generated/ns/render.js.map +1 -1
  61. package/dist/cjs/generated/ns/requests.d.ts +3 -1
  62. package/dist/cjs/generated/ns/requests.js +3 -1
  63. package/dist/cjs/generated/ns/requests.js.map +1 -1
  64. package/dist/cjs/generated/ns/routines.d.ts +131 -9
  65. package/dist/cjs/generated/ns/routines.js +186 -9
  66. package/dist/cjs/generated/ns/routines.js.map +1 -1
  67. package/dist/cjs/generated/ns/sandboxes.d.ts +327 -31
  68. package/dist/cjs/generated/ns/sandboxes.js +417 -29
  69. package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
  70. package/dist/cjs/generated/ns/vision.d.ts +133 -14
  71. package/dist/cjs/generated/ns/vision.js +158 -12
  72. package/dist/cjs/generated/ns/vision.js.map +1 -1
  73. package/dist/cjs/generated/ns/webhooks.d.ts +8 -5
  74. package/dist/cjs/generated/ns/webhooks.js +8 -5
  75. package/dist/cjs/generated/ns/webhooks.js.map +1 -1
  76. package/dist/cjs/generated/types.d.ts +2750 -328
  77. package/dist/cjs/helpers/agents.d.ts +95 -0
  78. package/dist/cjs/helpers/agents.js +205 -0
  79. package/dist/cjs/helpers/agents.js.map +1 -0
  80. package/dist/cjs/helpers/render.d.ts +15 -0
  81. package/dist/cjs/helpers/render.js +74 -0
  82. package/dist/cjs/helpers/render.js.map +1 -0
  83. package/dist/cjs/helpers/routines.d.ts +61 -0
  84. package/dist/cjs/helpers/routines.js +234 -0
  85. package/dist/cjs/helpers/routines.js.map +1 -0
  86. package/dist/cjs/helpers/sandboxes.d.ts +237 -0
  87. package/dist/cjs/helpers/sandboxes.js +608 -0
  88. package/dist/cjs/helpers/sandboxes.js.map +1 -0
  89. package/dist/cjs/index.d.ts +4 -1
  90. package/dist/cjs/index.js +8 -5
  91. package/dist/cjs/index.js.map +1 -1
  92. package/dist/cjs/routines.d.ts +1 -0
  93. package/dist/cjs/routines.js +21 -0
  94. package/dist/cjs/routines.js.map +1 -0
  95. package/dist/cjs/webhooks.js.map +1 -1
  96. package/dist/esm/core/bytes.d.ts +30 -0
  97. package/dist/esm/core/bytes.js +111 -0
  98. package/dist/esm/core/bytes.js.map +1 -0
  99. package/dist/esm/core/client.d.ts +80 -3
  100. package/dist/esm/core/client.js +233 -31
  101. package/dist/esm/core/client.js.map +1 -1
  102. package/dist/esm/core/errors.d.ts +16 -4
  103. package/dist/esm/core/errors.js +9 -6
  104. package/dist/esm/core/errors.js.map +1 -1
  105. package/dist/esm/core/handle.d.ts +36 -0
  106. package/dist/esm/core/handle.js +93 -0
  107. package/dist/esm/core/handle.js.map +1 -0
  108. package/dist/esm/core/index.d.ts +8 -4
  109. package/dist/esm/core/index.js +6 -2
  110. package/dist/esm/core/index.js.map +1 -1
  111. package/dist/esm/core/login.d.ts +24 -0
  112. package/dist/esm/core/login.js +85 -0
  113. package/dist/esm/core/login.js.map +1 -0
  114. package/dist/esm/core/namespace.d.ts +1 -1
  115. package/dist/esm/core/namespace.js +1 -1
  116. package/dist/esm/core/op.d.ts +11 -1
  117. package/dist/esm/core/timing.d.ts +1 -1
  118. package/dist/esm/core/timing.js +8 -1
  119. package/dist/esm/core/timing.js.map +1 -1
  120. package/dist/esm/core/traces-api.d.ts +42 -0
  121. package/dist/esm/core/traces-api.js +50 -0
  122. package/dist/esm/core/traces-api.js.map +1 -0
  123. package/dist/esm/core/traces.d.ts +120 -0
  124. package/dist/esm/core/traces.js +295 -0
  125. package/dist/esm/core/traces.js.map +1 -0
  126. package/dist/esm/core/transport.js +1 -1
  127. package/dist/esm/core/transport.js.map +1 -1
  128. package/dist/esm/core/util.d.ts +15 -3
  129. package/dist/esm/core/util.js +48 -1
  130. package/dist/esm/core/util.js.map +1 -1
  131. package/dist/esm/core/ws.d.ts +4 -0
  132. package/dist/esm/core/ws.js +7 -4
  133. package/dist/esm/core/ws.js.map +1 -1
  134. package/dist/esm/generated/client.d.ts +2 -2
  135. package/dist/esm/generated/client.js +2 -2
  136. package/dist/esm/generated/errors.d.ts +1 -1
  137. package/dist/esm/generated/errors.js +42 -0
  138. package/dist/esm/generated/errors.js.map +1 -1
  139. package/dist/esm/generated/ids.d.ts +12 -0
  140. package/dist/esm/generated/ids.js +3 -0
  141. package/dist/esm/generated/ids.js.map +1 -1
  142. package/dist/esm/generated/jobs.js +1 -1
  143. package/dist/esm/generated/ns/actions.d.ts +48 -6
  144. package/dist/esm/generated/ns/actions.js +59 -6
  145. package/dist/esm/generated/ns/actions.js.map +1 -1
  146. package/dist/esm/generated/ns/infer.d.ts +185 -54
  147. package/dist/esm/generated/ns/infer.js +28 -74
  148. package/dist/esm/generated/ns/infer.js.map +1 -1
  149. package/dist/esm/generated/ns/keys.d.ts +14 -1
  150. package/dist/esm/generated/ns/keys.js +24 -1
  151. package/dist/esm/generated/ns/keys.js.map +1 -1
  152. package/dist/esm/generated/ns/render.d.ts +115 -6
  153. package/dist/esm/generated/ns/render.js +135 -7
  154. package/dist/esm/generated/ns/render.js.map +1 -1
  155. package/dist/esm/generated/ns/requests.d.ts +3 -1
  156. package/dist/esm/generated/ns/requests.js +3 -1
  157. package/dist/esm/generated/ns/requests.js.map +1 -1
  158. package/dist/esm/generated/ns/routines.d.ts +131 -9
  159. package/dist/esm/generated/ns/routines.js +186 -9
  160. package/dist/esm/generated/ns/routines.js.map +1 -1
  161. package/dist/esm/generated/ns/sandboxes.d.ts +327 -31
  162. package/dist/esm/generated/ns/sandboxes.js +417 -29
  163. package/dist/esm/generated/ns/sandboxes.js.map +1 -1
  164. package/dist/esm/generated/ns/vision.d.ts +133 -14
  165. package/dist/esm/generated/ns/vision.js +158 -12
  166. package/dist/esm/generated/ns/vision.js.map +1 -1
  167. package/dist/esm/generated/ns/webhooks.d.ts +8 -5
  168. package/dist/esm/generated/ns/webhooks.js +8 -5
  169. package/dist/esm/generated/ns/webhooks.js.map +1 -1
  170. package/dist/esm/generated/types.d.ts +2750 -328
  171. package/dist/esm/helpers/agents.d.ts +95 -0
  172. package/dist/esm/helpers/agents.js +199 -0
  173. package/dist/esm/helpers/agents.js.map +1 -0
  174. package/dist/esm/helpers/render.d.ts +15 -0
  175. package/dist/esm/helpers/render.js +70 -0
  176. package/dist/esm/helpers/render.js.map +1 -0
  177. package/dist/esm/helpers/routines.d.ts +61 -0
  178. package/dist/esm/helpers/routines.js +226 -0
  179. package/dist/esm/helpers/routines.js.map +1 -0
  180. package/dist/esm/helpers/sandboxes.d.ts +237 -0
  181. package/dist/esm/helpers/sandboxes.js +600 -0
  182. package/dist/esm/helpers/sandboxes.js.map +1 -0
  183. package/dist/esm/index.d.ts +4 -1
  184. package/dist/esm/index.js +6 -5
  185. package/dist/esm/index.js.map +1 -1
  186. package/dist/esm/routines.d.ts +1 -0
  187. package/dist/esm/routines.js +5 -0
  188. package/dist/esm/routines.js.map +1 -0
  189. package/dist/esm/webhooks.js.map +1 -1
  190. package/package.json +14 -3
  191. package/src/core/bytes.ts +112 -0
  192. package/src/core/client.ts +285 -33
  193. package/src/core/errors.ts +27 -10
  194. package/src/core/handle.ts +107 -0
  195. package/src/core/index.ts +17 -2
  196. package/src/core/login.ts +98 -0
  197. package/src/core/namespace.ts +1 -1
  198. package/src/core/op.ts +11 -1
  199. package/src/core/timing.ts +7 -2
  200. package/src/core/traces-api.ts +80 -0
  201. package/src/core/traces.ts +375 -0
  202. package/src/core/transport.ts +1 -1
  203. package/src/core/util.ts +53 -3
  204. package/src/core/ws.ts +11 -4
  205. package/src/generated/client.ts +2 -2
  206. package/src/generated/errors.ts +84 -0
  207. package/src/generated/ids.ts +3 -0
  208. package/src/generated/jobs.ts +1 -1
  209. package/src/generated/ns/actions.ts +69 -6
  210. package/src/generated/ns/infer.ts +229 -61
  211. package/src/generated/ns/keys.ts +25 -1
  212. package/src/generated/ns/render.ts +172 -7
  213. package/src/generated/ns/requests.ts +3 -1
  214. package/src/generated/ns/routines.ts +205 -9
  215. package/src/generated/ns/sandboxes.ts +493 -34
  216. package/src/generated/ns/vision.ts +168 -14
  217. package/src/generated/ns/webhooks.ts +8 -5
  218. package/src/generated/types.ts +3034 -472
  219. package/src/helpers/agents.ts +300 -0
  220. package/src/helpers/render.ts +91 -0
  221. package/src/helpers/routines.ts +278 -0
  222. package/src/helpers/sandboxes.ts +788 -0
  223. package/src/index.ts +29 -5
  224. package/src/routines.ts +5 -0
  225. package/src/webhooks.ts +5 -1
@@ -125,6 +125,14 @@ const mapOp: Op = {
125
125
  timeoutMs: 65000,
126
126
  scope: "vision:run",
127
127
  };
128
+ const prepareOp: Op = {
129
+ id: "visionPrepare",
130
+ method: "POST",
131
+ path: "/v1/vision/prepare",
132
+ body: "json",
133
+ timeoutMs: 15000,
134
+ scope: "vision:run",
135
+ };
128
136
  const listProfilesOp: Op = {
129
137
  id: "visionListProfiles",
130
138
  method: "GET",
@@ -187,6 +195,8 @@ const readUrlOp: Op = {
187
195
  max_age_ms: "X-B3OS-Max-Age-Ms",
188
196
  only_main_content: "X-B3OS-Only-Main-Content",
189
197
  wait_for_ms: "X-B3OS-Wait-For-Ms",
198
+ respect_robots: "X-B3OS-Respect-Robots",
199
+ walls: "X-B3OS-Walls",
190
200
  },
191
201
  timeoutMs: 65000,
192
202
  scope: "vision:run",
@@ -199,6 +209,14 @@ const scrapeOp: Op = {
199
209
  timeoutMs: 65000,
200
210
  scope: "vision:run",
201
211
  };
212
+ const searchOp: Op = {
213
+ id: "visionSearch",
214
+ method: "POST",
215
+ path: "/v1/vision/search",
216
+ body: "json",
217
+ timeoutMs: 65000,
218
+ scope: "vision:run",
219
+ };
202
220
  const listSessionsOp: Op = {
203
221
  id: "visionListSessions",
204
222
  method: "GET",
@@ -266,6 +284,14 @@ const createSessionTicketOp: Op = {
266
284
  timeoutMs: 5000,
267
285
  scope: "vision:read",
268
286
  };
287
+ const getSessionTimelineOp: Op = {
288
+ id: "visionGetSessionTimeline",
289
+ method: "GET",
290
+ path: "/v1/vision/sessions/{session_id}/timeline",
291
+ params: ["session_id"],
292
+ timeoutMs: 5000,
293
+ scope: "vision:read",
294
+ };
269
295
  const createBatchOp: Op = {
270
296
  id: "visionCreateBatch",
271
297
  method: "POST",
@@ -320,6 +346,7 @@ export const visionOps = {
320
346
  cancelExtract: cancelExtractOp,
321
347
  extractEvents: extractEventsOp,
322
348
  map: mapOp,
349
+ prepare: prepareOp,
323
350
  listProfiles: listProfilesOp,
324
351
  createProfile: createProfileOp,
325
352
  deleteProfile: deleteProfileOp,
@@ -328,6 +355,7 @@ export const visionOps = {
328
355
  exportProfileState: exportProfileStateOp,
329
356
  readUrl: readUrlOp,
330
357
  scrape: scrapeOp,
358
+ search: searchOp,
331
359
  listSessions: listSessionsOp,
332
360
  createSession: createSessionOp,
333
361
  closeSession: closeSessionOp,
@@ -336,6 +364,7 @@ export const visionOps = {
336
364
  connectCdp: connectCdpOp,
337
365
  saveSessionProfile: saveSessionProfileOp,
338
366
  createSessionTicket: createSessionTicketOp,
367
+ getSessionTimeline: getSessionTimelineOp,
339
368
  } as const;
340
369
 
341
370
  /**
@@ -359,7 +388,9 @@ export class VisionAPI extends Namespace {
359
388
  /**
360
389
  * Scrape a list of URLs
361
390
  *
362
- * Starts a job that scrapes up to 1,000 URLs with the same options. Each page bills one `vision.page`.
391
+ * Starts a job that scrapes up to 1,000 URLs with the same options. Each delivered page bills one
392
+ * `vision.page`, except a wall, which is free and carries only its state, status and final URL
393
+ * (`content_withheld`) unless the page options set `walls: "bill"`, as for a single scrape (visionScrape).
363
394
  * Results are listed with `GET /v1/vision/batches/{batch_id}/pages`; `?wait=`, the events stream and
364
395
  * `webhook` report progress.
365
396
  *
@@ -395,7 +426,9 @@ export class VisionAPI extends Namespace {
395
426
  * Stream a batch's events
396
427
  *
397
428
  * Server-sent events for the batch: lifecycle events plus `page.succeeded` and `page.failed` per URL. Ends
398
- * after the terminal event. Reconnect with `Last-Event-ID` to resume.
429
+ * after the terminal event. Reconnect with `Last-Event-ID` to resume. Events are kept with the batch, so the
430
+ * stream reads the same, with the same `seq`, after the node restarts; a batch that was running then ends
431
+ * with `job.failed`.
399
432
  *
400
433
  * `GET /v1/vision/batches/{batch_id}/events` · scope `vision:read` · served by the node
401
434
  */
@@ -440,8 +473,14 @@ export class VisionAPI extends Namespace {
440
473
  * Crawl a site
441
474
  *
442
475
  * Starts a job that discovers pages from `url` (links and sitemaps), breadth first, and scrapes up to `limit`
443
- * pages (at most 500). robots.txt is honored and requests to one host are spaced politely. One crawl runs
444
- * at a time per organization. Each page bills one `vision.page`.
476
+ * pages (at most 500). Requests to one host are spaced politely (`delay_ms`). robots.txt rules apply only
477
+ * with `respect_robots: true`: disallowed pages are skipped (listed in `result.robots_blocked`), a robots.txt
478
+ * that cannot be read stops the crawl's pages (RFC 9309), and its Crawl-delay is used when `delay_ms` is not
479
+ * set; its `Sitemap:` lines then point sitemap discovery. Without it no robots.txt is fetched at all and
480
+ * sitemap discovery starts from `/sitemap.xml`. One crawl runs at a time per organization.
481
+ * Each delivered page bills one `vision.page`, except a wall, which is free and carries only its state, status
482
+ * and final URL (`content_withheld`; its links are not followed) unless the page options set
483
+ * `walls: "bill"`, as for a single scrape (visionScrape).
445
484
  *
446
485
  * `POST /v1/vision/crawls` · scope `vision:run` · served by the node
447
486
  */
@@ -475,7 +514,9 @@ export class VisionAPI extends Namespace {
475
514
  * Stream a crawl's events
476
515
  *
477
516
  * Server-sent events for the crawl: lifecycle events plus `page.succeeded` and `page.failed` per page. Ends
478
- * after the terminal event. Reconnect with `Last-Event-ID` to resume.
517
+ * after the terminal event. Reconnect with `Last-Event-ID` to resume. Events are kept with the crawl, so the
518
+ * stream reads the same, with the same `seq`, after the node restarts; a crawl that was running then ends
519
+ * with `job.failed`.
479
520
  *
480
521
  * `GET /v1/vision/crawls/{crawl_id}/events` · scope `vision:read` · served by the node
481
522
  */
@@ -567,7 +608,9 @@ export class VisionAPI extends Namespace {
567
608
  *
568
609
  * Lists URLs on a site from its sitemaps and from links on the start page, without scraping each page. Use it
569
610
  * to choose what to scrape or crawl. `search` orders the results by relevance to a phrase. Bills one
570
- * `vision.page` per call.
611
+ * `vision.page` per call that returns at least one link (a map that found nothing is free). A start page
612
+ * that is a wall (`page_state` `blocked` or `captcha`) gives no links, not even its own URL, so a map of a
613
+ * wall finds only what the sitemaps list.
571
614
  *
572
615
  * `POST /v1/vision/map` · scope `vision:run` · served by the node
573
616
  */
@@ -575,6 +618,28 @@ export class VisionAPI extends Namespace {
575
618
  return this._client._call<T.MapResult>(mapOp, { body }, options);
576
619
  }
577
620
 
621
+ /**
622
+ * Prepare a coming scrape
623
+ *
624
+ * Warms what a scrape of `url` will need, so it is off the scrape's critical path: the destination resolved
625
+ * and checked by the egress guard, and a keep-alive connection to the origin that the scrape's HTTP fetch
626
+ * reuses (opened with a `HEAD` of the URL, whose answer is not used, carrying the request headers the
627
+ * scrape's navigation sends: Chrome's for that URL). Routines call it for the next step
628
+ * while the current one runs. Bills nothing. With `respect_robots: true` it fetches and caches the origin's
629
+ * robots.txt instead of the `HEAD`, and `robots` says whether robots.txt allows the URL (`unreachable`: a
630
+ * scrape still proceeds, a crawl does not); otherwise `robots` is `not_checked`.
631
+ *
632
+ * It sends the target at most one `HEAD` per origin per 60 seconds for your organization: a prepare of an
633
+ * origin you prepared within the last 60 seconds finds the connection pooled and sends nothing (its
634
+ * `timing` then has no `connect_ms`). Each request a prepare does send (the `HEAD`, or a robots.txt this node
635
+ * does not hold yet) counts against `vision.scrape.rpm` like a scrape: `429 rate_limited` when it is used up.
636
+ *
637
+ * `POST /v1/vision/prepare` · scope `vision:run` · served by the node
638
+ */
639
+ prepare(body: T.PrepareRequest, options?: RequestOptions): APIPromise<T.PrepareResult> {
640
+ return this._client._call<T.PrepareResult>(prepareOp, { body }, options);
641
+ }
642
+
578
643
  /**
579
644
  * List profiles
580
645
  *
@@ -639,7 +704,12 @@ export class VisionAPI extends Namespace {
639
704
  *
640
705
  * Returns the current revision's storage state (Playwright `storageState` JSON) so you can load it into your
641
706
  * own browser or move it to another project. It contains live session cookies: treat the response like a
642
- * password. Requires `vision:write`, the same scope that can replace the state.
707
+ * password. Requires `vision:profiles:export` as well as `vision:write`. Export is an explicit grant: default
708
+ * keys, `*` and `vision:*` do not include it, so a key that exports state names the scope. Until the end of the
709
+ * 14-day kept window (plan 3.18), a key with `vision:write` and without `vision:profiles:export` still exports,
710
+ * and the response carries `Sunset` with the date that stops. A profile whose state a B3OS session saved
711
+ * (`exportable: false`) is never exported: 403 `profile_not_exportable`, with any scope, once the kept window
712
+ * ends (inside it, it exports with `Sunset`).
643
713
  *
644
714
  * `GET /v1/vision/profiles/{profile_id}/state` · scope `vision:write` · served by the node
645
715
  */
@@ -651,8 +721,13 @@ export class VisionAPI extends Namespace {
651
721
  * Read a URL as Markdown
652
722
  *
653
723
  * The shortest way to read a page: put the target URL after `/v1/vision/r/`, unencoded, for example
654
- * `GET /v1/vision/r/https://example.com/pricing`. Returns `text/markdown` by default. Options go in
655
- * `X-B3OS-*` headers so the target URL stays untouched. Same tiers, cache and billing as `scrape`.
724
+ * `GET /v1/vision/r/https://example.com/pricing`. Returns `text/markdown` by default (`X-B3OS-Format`:
725
+ * `text/html` for `html`, `text/plain` for `text`, a scrape result as JSON for `json`). Options go in
726
+ * `X-B3OS-*` headers so the target URL stays untouched. Same tiers, cache and billing as `scrape`: a wall is
727
+ * free and its body is empty (`X-B3OS-Content-Withheld: true`; the `json` format returns the withheld result)
728
+ * unless `X-B3OS-Walls: bill`. `X-B3OS-Page-State` names the page's state. A path with
729
+ * a `.` or `..` segment (also percent-encoded) answers `400 invalid_url` instead of being resolved: clients and
730
+ * proxies resolve dot segments differently, so resolve them first or `POST /v1/vision/scrape`.
656
731
  *
657
732
  * `GET /v1/vision/r/{url}` · scope `vision:run` · served by the node
658
733
  */
@@ -689,20 +764,64 @@ export class VisionAPI extends Namespace {
689
764
  * Scrape a page
690
765
  *
691
766
  * Fetches one URL and returns the formats you ask for. With `engine: "auto"` (the default) vision answers
692
- * from the cache when a fresh copy exists (`max_age_ms`, default 2 days), otherwise fetches over HTTP and
693
- * switches to a warm browser only when the page needs JavaScript. Custom `headers`, a `profile` or `actions`
767
+ * from the cache when a fresh copy exists (`max_age_ms`, default 2 days), otherwise fetches over HTTP and uses a
768
+ * warm browser when the page needs JavaScript, when the fetch came back thin or mostly script, and when the
769
+ * fetch failed in a way a browser may not. Custom `headers`, a `profile` or `actions`
694
770
  * bypass the cache; a page that sets cookies (by a response or a script) is cached for your organization
695
771
  * only. The response's `cache.state` and `tier` say what served it.
696
772
  *
697
773
  * Synchronous: the response arrives when the page is done, within `timeout_ms` (at most 60 seconds). For
698
774
  * many pages use a batch scrape or a crawl.
699
775
  *
776
+ * Billing: one `vision.page` for a page that is returned, whichever tier served it. A free scrape never
777
+ * carries page content. A scrape that returns no page (an error answer: upstream error, timeout, blocked
778
+ * target, egress denial, extraction failure, a cache-only miss) bills nothing and does not count against the
779
+ * monthly allowance. A page vision judges a wall (`page_state` `blocked` or `captcha`: a refusal or
780
+ * challenge page, see PageState) is free too, and its content is withheld: the result has only `page_state`
781
+ * (with its `signal`), `status_code`, `final_url` and `content_withheld: true`, and none of the formats,
782
+ * `links`, `metadata`, the screenshot or `json`. The judgement is a heuristic and can take a page for a wall
783
+ * that is not one; such a page then comes back without its content, never with it for free, so it errs
784
+ * toward `ok`: a wall needs little text and an interstitial signal or a 403 or 429 status. With
785
+ * `walls: "bill"` a wall bills like any page and its content is returned. A scrape with `actions` bills
786
+ * whatever the page is and returns everything (its steps ran, and a step can send what it reads out through
787
+ * the page's own requests). A 403 or 429 that carries the page's content as text is not a wall (`page_state`
788
+ * `error`) and is billed like any page, whatever `include_tags`, `exclude_tags` or `only_main_content` keep
789
+ * of it. The same holds for batch and crawl pages and for cache hits. Once the organization has used its
790
+ * `vision.pages.monthly` allowance, scrapes answer `429 quota_exceeded` until the next UTC month.
791
+ *
792
+ * A browser that goes away during the render (the node's Chrome launcher stopped or restarted) answers `503
793
+ * product_unavailable` with `Retry-After`: retry, the node reconnects to the launcher by itself.
794
+ *
700
795
  * `POST /v1/vision/scrape` · scope `vision:run` · served by the node
701
796
  */
702
797
  scrape(body: T.ScrapeRequest, options?: RequestOptions): APIPromise<T.ScrapeResult> {
703
798
  return this._client._call<T.ScrapeResult>(scrapeOp, { body }, options);
704
799
  }
705
800
 
801
+ /**
802
+ * Search the web
803
+ *
804
+ * Searches the web for `query` and returns up to `limit` results in the provider's order, each with its URL,
805
+ * title and description. The node sends the query to its search provider (the Brave Search API) with the
806
+ * node's key and nothing that identifies your organization; the result sites are not contacted unless you ask
807
+ * for their pages. With `scrape`, every result is also scraped with those options, through the same egress
808
+ * guard and politeness as a scrape, and its document is in the result's `scrape`; a result whose scrape fails
809
+ * has `error` instead, and the search still answers 200 with a `scrape_failed` warning. One answer holds at
810
+ * most 64 MiB of pages; a result past that has `error` `search_answer_too_large` and is not billed. A search's
811
+ * results get no custom `headers`, `profile`, `actions` or `json` format: scrape the URLs you trust with those.
812
+ *
813
+ * Bills one `vision.page` per search that returns at least one result, plus one `vision.page` per scraped
814
+ * result (as a scrape bills). A search with no results bills nothing. Each search counts against
815
+ * `vision.search.monthly` (searches per UTC calendar month) and `vision.search.rpm`; it answers 429
816
+ * `quota_exceeded` or `rate_limited` when they are used up. A node without a search key answers 503
817
+ * `search_unavailable`.
818
+ *
819
+ * `POST /v1/vision/search` · scope `vision:run` · served by the node
820
+ */
821
+ search(body: T.SearchRequest, options?: RequestOptions): APIPromise<T.SearchResult> {
822
+ return this._client._call<T.SearchResult>(searchOp, { body }, options);
823
+ }
824
+
706
825
  /**
707
826
  * List browser sessions
708
827
  *
@@ -723,7 +842,8 @@ export class VisionAPI extends Namespace {
723
842
  * Claims a warm, dedicated browser for your organization and returns it ready to drive. Load a `profile` to
724
843
  * start signed in; set `persist_profile` to save cookies and storage back when the session closes. The
725
844
  * session closes after `timeout_s` (at most 1,800) or on `DELETE`. Bills `vision.browser_ms` from claim to
726
- * close.
845
+ * close. A node whose Chrome runs without its own sandbox (`chrome_sandbox: off` in `/readyz`) answers
846
+ * `503 product_unavailable`: one browser per session, with a renderer sandbox.
727
847
  *
728
848
  * `POST /v1/vision/sessions` · scope `vision:write` · served by the node
729
849
  */
@@ -763,7 +883,13 @@ export class VisionAPI extends Namespace {
763
883
  * `navigate`, `click`, `hover`, `type`, `key`, `scroll`, `select` and `wait` (the same kinds and fields as
764
884
  * render scripts), plus `evaluate`, `screenshot` and `markdown`. Execution stops at the first failed action
765
885
  * unless `continue_on_error` is set; the failed action's result carries the error (for example
766
- * `target_not_found`) and later actions are reported as `skipped`. The batch must finish within `timeout_ms`.
886
+ * `target_not_found`, or `target_covered` for a click whose target another element covers) and later actions
887
+ * are reported as `skipped`. The batch must finish within `timeout_ms`. The scripts vision runs in the page to
888
+ * find targets and wait run in an isolated world: they add nothing the page's own scripts can see. Only
889
+ * `evaluate` runs in the page's own JavaScript world.
890
+ * JavaScript dialogs never stall a batch: `alert`, `confirm` and `prompt` are dismissed (`confirm` returns
891
+ * false and `prompt` null; `accept_confirm: true` accepts `confirm`), `beforeunload` is accepted, and each
892
+ * dialog is listed in the `dialogs` of the action that was running.
767
893
  *
768
894
  * `POST /v1/vision/sessions/{session_id}/act` · scope `vision:run` · served by the node
769
895
  */
@@ -784,7 +910,15 @@ export class VisionAPI extends Namespace {
784
910
  * `about:blank` (`file:`, `chrome:`, `chrome-extension:`, `view-source:`, `devtools:`, `data:`). These
785
911
  * answer `cdp_method_blocked` in the CDP error (`error.data.code`). `Target.createBrowserContext` with
786
912
  * `proxyServer`, `proxyBypassList` or `originsWithUniversalNetworkAccess` answers `forbidden` (403):
787
- * every context of a session uses the session's egress. Authenticate with the `Authorization` header or a
913
+ * every context of a session uses the session's egress. Reading the browser's cookies and storage, which
914
+ * hold any profile the session loaded, needs `vision:profiles:export`, as exporting a profile's state does
915
+ * (default keys, `*` and `vision:*` leave it out): without it, `Network.getAllCookies`,
916
+ * `Network.getCookies`, `Storage.getCookies`, `Storage.getSharedStorageEntries`, `DOMStorage.*`,
917
+ * `IndexedDB.*` and `CacheStorage.*` answer `forbidden` (403) with `required_scope` in `error.data`, and
918
+ * network events reach the client without `Cookie` and `Set-Cookie` headers, raw header text or cookie
919
+ * lists. Until the profile scopes' kept window ends (2026-11-16) these reads still work. Scripts in the page
920
+ * are not filtered: `Runtime.evaluate` reads what the page's own scripts can, such as `document.cookie`
921
+ * (without HttpOnly cookies) and `localStorage`. Authenticate with the `Authorization` header or a
788
922
  * ticket from `POST /v1/vision/sessions/{session_id}/ticket`. A client that falls more than a few MB
789
923
  * behind is disconnected, and so is one that sends a message over 32 MiB. A message with a repeated member
790
924
  * (two `method`s, say) answers the JSON-RPC parse error `-32700`.
@@ -833,4 +967,24 @@ export class VisionAPI extends Namespace {
833
967
  createSessionTicket(sessionId: string, options?: RequestOptions): APIPromise<T.StreamTicket> {
834
968
  return this._client._call<T.StreamTicket>(createSessionTicketOp, { path: [sessionId] }, options);
835
969
  }
970
+
971
+ /**
972
+ * Get a session's timeline
973
+ *
974
+ * The session's act steps in order, one row per step (skipped steps included): kind, start, duration,
975
+ * status, error, the target's box in the viewport, and a JPEG thumbnail when the session was created with
976
+ * `thumbnails: true`. Also the cursor path: every pointer event, from act steps and from
977
+ * `Input.dispatchMouseEvent` commands a CDP client sent over the session's socket, with its time since the
978
+ * session was created. Kept with the session (at most 1,000 steps, 20,000 points and 8 MiB of thumbnails;
979
+ * `dropped` counts what did not fit); a row's `url` and its error's `detail` are cut to 2,048 characters, and
980
+ * a CDP command whose `type` or `button` is not one of the documented values adds no point. Thumbnails are
981
+ * dropped 15 minutes after the session closes. The closed sessions of one organization keep at most 64 MiB of
982
+ * timelines together: the most recently closed keep theirs, older ones read empty, with what they held
983
+ * counted in `dropped`. The timeline is empty for a session closed by a node restart.
984
+ *
985
+ * `GET /v1/vision/sessions/{session_id}/timeline` · scope `vision:read` · served by the node
986
+ */
987
+ getSessionTimeline(sessionId: string, options?: RequestOptions): APIPromise<T.SessionTimeline> {
988
+ return this._client._call<T.SessionTimeline>(getSessionTimelineOp, { path: [sessionId] }, options);
989
+ }
836
990
  }
@@ -65,9 +65,11 @@ export class WebhooksAPI extends Namespace {
65
65
  /**
66
66
  * Get an endpoint's signing secret
67
67
  *
68
- * Returns the signing secret for one endpoint URL in this project, creating it on first use. Call it when you
69
- * set up your receiver; the same URL always gets the same secret until you rotate it. URLs are compared after
70
- * lowercasing the scheme and host and removing a default port.
68
+ * Returns the signing secret for one endpoint URL in this project, creating it on first use. The secret is in
69
+ * the response only once: the first call for a URL returns it, later calls return the same object with
70
+ * `secret: null` and `secret_hint` (B3OS never returns a stored secret). Store it when you get it; if you lose
71
+ * it, rotate (`POST /v1/webhooks/secret/rotate`) to get a new one. The same URL keeps its secret until you
72
+ * rotate it. URLs are compared after lowercasing the scheme and host and removing a default port.
71
73
  *
72
74
  * `POST /v1/webhooks/secret` · scope `platform:write` · served by the node
73
75
  */
@@ -78,8 +80,9 @@ export class WebhooksAPI extends Namespace {
78
80
  /**
79
81
  * Rotate an endpoint's signing secret
80
82
  *
81
- * Replaces the endpoint's secret. For `grace_s` seconds (default one day) deliveries carry two `v1` signatures,
82
- * one per secret, so receivers can switch without dropping events.
83
+ * Replaces the endpoint's secret and returns the new one (this response is the only one that contains it).
84
+ * For `grace_s` seconds (default one day) deliveries carry two `v1` signatures, one per secret, so receivers
85
+ * can switch without dropping events.
83
86
  *
84
87
  * `POST /v1/webhooks/secret/rotate` · scope `platform:write` · served by the node
85
88
  */