@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
@@ -18,6 +18,8 @@ export type Scope =
18
18
  | "vision:read"
19
19
  | "vision:write"
20
20
  | "vision:run"
21
+ | "vision:profiles:use"
22
+ | "vision:profiles:export"
21
23
  | "render:read"
22
24
  | "render:write"
23
25
  | "render:run"
@@ -58,6 +60,17 @@ export interface Timing {
58
60
  [key: string]: unknown;
59
61
  }
60
62
 
63
+ /**
64
+ * What kind of page the scrape returned (the page your `actions` left, when there are any), from heuristics on the HTML, the status and the amount of text (no model call): `ok` (the page), `blocked` (a bot-management interstitial or refusal), `captcha` (a challenge for a person), `cookie_wall` (consent before content), `login` (a sign-in form instead of content), `error` (an error status, or a 200 whose title says the page is missing) or `loading` (an unfinished shell). `blocked` and `captcha` are walls, and when the signals are unclear the state is `ok`, since a wall's content is withheld. A wall has little text (under about 2,500 bytes of visible text, counted outside the head whether or not the document has a `<body>` tag, and under 2,000 bytes of Markdown of the default main content, whatever `include_tags`, `exclude_tags` or `only_main_content` ask for) and either a 403 or 429 status or an interstitial signal: a challenge or refusal title (whole words, such as "Just a moment" or "Access denied"), a resource only a vendor's challenge loads (such as Cloudflare's `/cdn-cgi/challenge-platform/.../orchestrate/` or DataDome's `captcha-delivery.com`), an element only a vendor's challenge or block page has (Cloudflare's `cf-error-details` only with a 403 or 429 status or its "you have been blocked" headline: its 5xx origin-error pages, 520 to 526, use the same template and are `error`), or a CAPTCHA widget (`g-recaptcha`, `h-captcha`, `cf-turnstile`, or a rendered Turnstile widget's frame) on a page without a form field to fill in. Scripts that sites load on every page are not signals (reCAPTCHA v3, Cloudflare's JavaScript detections, PerimeterX, Kasada or Imperva loaders), so a small page that carries one is `ok`; vendor names count only in markup (classes, ids, resource URLs, inline scripts, comments), never in visible text; and a body that is not HTML (JSON, text) is judged by its status alone. Without an error status a wall is also small, at most 16 KiB of markup: a thin page with more keeps its content in scripts (a single-page app's inline state) and is not a wall. A marker or refusal word that the requested or final URL also carries (percent-decoded, in any case, a slug's words included) does not count: a page that echoes its own address, such as a search page with the query in its title or a tag page titled after its slug, is not refusing it. The markup judged is the document as served or, in a browser, the whole DOM with its scripts when the page shows fewer than 6,000 characters of text (counted in the DOM itself, the same whatever `formats` asks for); a page that shows more is judged by that text, and no rule that reads markup applies to it. So `formats` does not change the state, and neither does which copy of a page the cache holds for the same tier; a `cache_only` scrape with `engine: "auto"` reads whichever tier's copy is cached, and the fetch tier and the browser can judge the same page differently. A page whose content is visible text is not a wall, whatever its status or markers: with a consent banner or a CAPTCHA widget it is `ok`, answered with 403 or 429 it is `error`. A thin page that keeps its content in scripts and is answered with 403 or 429 is a wall, so its content is withheld unless `walls: "bill"`. Your own `actions` can make a wall (an `evaluate` step that empties the page), and the state then says so. A wall is free (no `vision.page`, not counted against the allowance; Firecrawl's `creditsUsed` is 0) and its content withheld (`content_withheld`), unless the request sets `walls: "bill"` or runs `actions`, which bill like any page. The other states are billed: they are the site's answer.
65
+ */
66
+ export interface PageState {
67
+ state: "ok" | "blocked" | "captcha" | "cookie_wall" | "login" | "error" | "loading";
68
+ /**
69
+ * What decided it, such as `cloudflare_challenge`, `recaptcha`, `onetrust`, `password_form`, `status`, `title` or `empty_spa_root`.
70
+ */
71
+ signal?: string;
72
+ }
73
+
61
74
  /** One validation problem. */
62
75
  export interface ProblemItem {
63
76
  /**
@@ -126,6 +139,16 @@ export interface Problem {
126
139
  message: string;
127
140
  retryable: boolean;
128
141
  };
142
+ /**
143
+ * The option a request value was refused for, by its id (`option_not_allowed`), e.g. `sandboxes.clone_reset`.
144
+ */
145
+ option?: string;
146
+ /** The value the request asked for (`option_not_allowed`). */
147
+ value?: unknown;
148
+ /** The values the request may ask for (`option_not_allowed`, an option with a closed list of values). */
149
+ allowed?: unknown[];
150
+ /** What set the bound a refused value is outside (`option_not_allowed`); `node` is the node's policy. */
151
+ bound_by?: "node" | "org" | "flag" | "limit";
129
152
  [key: string]: unknown;
130
153
  }
131
154
 
@@ -329,12 +352,23 @@ export interface StreamTicket {
329
352
  export type ScrapeFormat = "markdown" | "html" | "raw_html" | "text" | "links" | "metadata" | "screenshot" | "json";
330
353
 
331
354
  /**
332
- * Which tier may serve the page. `auto` (default): cache, then HTTP fetch, then a browser when the page needs
333
- * JavaScript. `fetch`: never start a browser. `browser`: always render in Chrome (needed for `actions`,
334
- * `screenshot` and profiles; implied by them).
355
+ * Which tier may serve the page. `auto` (default): cache, then HTTP fetch, then a browser when the fetch may not
356
+ * be enough. `fetch`: never start a browser. `browser`: always render in Chrome (needed for `actions`,
357
+ * `screenshot` and profiles; implied by them). With `auto`, a browser runs when the page needs JavaScript, when
358
+ * the fetch came back thin or mostly script, and when the fetch failed in a way a browser may not.
335
359
  */
336
360
  export type ScrapeEngine = "auto" | "fetch" | "browser";
337
361
 
362
+ /**
363
+ * Which browser renders the page: `chrome` (full Chrome in its new headless mode) or `headless-shell`
364
+ * (chrome-headless-shell, which starts faster and uses less memory but has no `window.chrome` and no
365
+ * plugins). Both run the same launch profile: a current Chrome user agent without `HeadlessChrome`,
366
+ * `navigator.webdriver` false, and the time zone and locale of the node's egress location unless the
367
+ * request sets them. Sessions and pages in a browser of their own have WebGL on SwiftShader; pages in the
368
+ * shared scrape pool, whose browsers serve several organizations at once, have no WebGL.
369
+ */
370
+ export type BrowserEngine = "chrome" | "headless-shell";
371
+
338
372
  /** Options for the `screenshot` format. */
339
373
  export interface ScreenshotOptions {
340
374
  /** @default false */
@@ -370,39 +404,59 @@ export interface ScrapeOptions {
370
404
  /** CSS selectors to drop. */
371
405
  exclude_tags?: string[];
372
406
  engine?: ScrapeEngine;
407
+ /**
408
+ * Which browser renders the page when the browser tier runs (`engine: browser`, or an `auto` scrape that renders); not allowed with `engine: fetch`. The scrape pool runs `headless-shell`. `chrome` renders in a browser of its own, which counts toward `vision.sessions.concurrent` while it runs, as a scrape with a `profile` does.
409
+ * @default "headless-shell"
410
+ */
411
+ browser?: BrowserEngine;
373
412
  /**
374
413
  * Extra wait after the page is ready, before capture.
375
414
  * @default 0
376
415
  */
377
416
  wait_for_ms?: number;
378
- /** @default 30000 */
417
+ /**
418
+ * Time for the whole scrape, `wait_for_ms` and a browser render included. A scrape that runs out answers `504 scrape_timeout` and is not billed. In a batch or crawl, each page gets this long.
419
+ * @default 30000
420
+ */
379
421
  timeout_ms?: number;
380
422
  /**
381
423
  * Accept a cached copy up to this old (default 2 days). `0` always fetches.
382
424
  * @default 172800000
383
425
  */
384
426
  max_age_ms?: number;
427
+ /**
428
+ * Answer from the page cache only, with no outbound request at all (with `respect_robots`, only a robots.txt this node already holds is checked): a cached copy (within `max_age_ms` when it is given) or `404 scrape_no_cached_data`, which is not billed. Cannot be combined with `headers`, `profile`, `actions` or a screenshot, which never use the cache. The share of pages the cache serves is the `b3os_vision_cache_served_ratio` metric.
429
+ * @default false
430
+ */
431
+ cache_only?: boolean;
385
432
  /**
386
433
  * Store the result in the cache. Requests with headers, a profile or actions are never shared across organizations.
387
434
  * @default true
388
435
  */
389
436
  store_in_cache?: boolean;
390
437
  /**
391
- * Extra request headers. A request with custom headers bypasses the shared cache. In a browser, a `Cookie` header becomes cookies for the page's host (path `/`), so it reaches the origin as on an HTTP fetch and is not sent to the other hosts the page loads from.
438
+ * Check the site's robots.txt (RFC 9309, product token `B3OSBot`) and Content Signals before fetching: a URL they disallow (or `ai-input=no`) answers `403 robots_disallowed`, which is not billed. Off by default: vision does not consult robots.txt unless asked. In a crawl's `scrape` options it means the same as the crawl's own `respect_robots`.
439
+ * @default false
440
+ */
441
+ respect_robots?: boolean;
442
+ /**
443
+ * Extra request headers, sent only to the target URL's origin (scheme, host and port): in a browser to the page and its same-origin subresources and fetches, never to the other hosts the page loads from, and on both tiers never along a redirect to another origin. A header you set replaces the browser's header of the same name (one value is sent, yours). A request with custom headers bypasses the cache. In a browser, a `Cookie` header becomes cookies for the page's host (path `/`), so it reaches the origin as on an HTTP fetch.
392
444
  */
393
445
  headers?: Record<string, string>;
394
446
  /**
395
- * A profile ID or name to load cookies and storage from. Implies `engine: browser`. The page renders in a browser of its own (never one shared with other organizations), which counts toward `vision.sessions.concurrent` while it runs.
447
+ * A profile ID or name to load cookies and storage from. Implies `engine: browser`. The page renders in a browser of its own (never one shared with other organizations), which counts toward `vision.sessions.concurrent` while it runs: a single scrape answers 429 when no slot is free, a batch or crawl page waits for one. Not served (503 `product_unavailable`) on a node whose Chrome runs without its own sandbox.
396
448
  */
397
449
  profile?: string;
398
450
  /** Browser actions to run before capture. Implies `engine: browser`. */
399
451
  actions?: ActStep[];
400
452
  /**
401
- * BCP 47 locale for `Accept-Language` and the browser.
453
+ * BCP 47 locale for `Accept-Language` and the browser. Defaults to the locale of the node's egress location (`en-US` on every node today).
402
454
  * @default "en-US"
403
455
  */
404
456
  locale?: string;
405
- /** IANA time zone for the browser, such as `America/Los_Angeles`. */
457
+ /**
458
+ * IANA time zone for the browser, such as `Europe/Berlin`. Defaults to the time zone of the node's egress location (`America/Los_Angeles` on every node today).
459
+ */
406
460
  timezone?: string;
407
461
  /**
408
462
  * Emulate a phone (viewport, user agent, touch).
@@ -421,6 +475,11 @@ export interface ScrapeOptions {
421
475
  block_resources?: Array<"image" | "media" | "font" | "stylesheet">;
422
476
  screenshot?: ScreenshotOptions;
423
477
  json?: JsonExtractOptions;
478
+ /**
479
+ * What a wall (`page_state` `blocked` or `captcha`) costs. `free`: no `vision.page`, and the result carries no page content, only `page_state`, `status_code`, `final_url` and `content_withheld: true`. `bill`: the wall bills like any page and its content is returned. A scrape with `actions` bills either way.
480
+ * @default "free"
481
+ */
482
+ walls?: "free" | "bill";
424
483
  }
425
484
 
426
485
  /** A URL plus scrape options. */
@@ -464,9 +523,13 @@ export interface ScrapeResult {
464
523
  object: "scrape";
465
524
  /** The requested URL. */
466
525
  url: string;
467
- /** The URL after redirects. */
526
+ /**
527
+ * The URL of the page the answer was read from: the URL after redirects or, for a page the browser rendered, the page the browser read. When a script moved the browser to another host or path after the load, or changed the address to another path with `history.pushState` or `replaceState`, it is that address. A change of query or fragment alone after the load leaves it at the URL after redirects.
528
+ */
468
529
  final_url: string;
469
- /** The HTTP status the site returned. A 404 page is still a successful scrape. */
530
+ /**
531
+ * The HTTP status the site returned. A 404 page is still a successful scrape. For a page the browser rendered, it is the status the browser got when it loaded the page, so after a script moved the browser to another page (see `final_url`) it can be the status of the page before the move.
532
+ */
470
533
  status_code: number;
471
534
  content_type?: string;
472
535
  /** What served the page. */
@@ -483,11 +546,34 @@ export interface ScrapeResult {
483
546
  metadata?: PageMetadata;
484
547
  /** Results of `actions`, in order. */
485
548
  actions?: ActStepResult[];
549
+ page_state?: PageState;
550
+ /**
551
+ * Present (`true`) when the page is a wall and the scrape was free (`walls: free`): the result then has no `markdown`, `html`, `raw_html`, `text`, `links`, `metadata`, `screenshot`, `json`, `actions` or `content_type`, only the state, `status_code` and `final_url`.
552
+ */
553
+ content_withheld?: boolean;
486
554
  /** Non-fatal problems, such as a format that could not be produced. */
487
555
  warnings: string[];
488
556
  timing: Timing;
489
557
  }
490
558
 
559
+ export interface PrepareRequest {
560
+ /** The page a coming scrape will fetch. */
561
+ url: string;
562
+ /**
563
+ * Fetch and cache the origin's robots.txt and say whether it allows `url` (the scrape itself checks only when it sets `respect_robots`).
564
+ * @default false
565
+ */
566
+ respect_robots?: boolean;
567
+ }
568
+
569
+ export interface PrepareResult {
570
+ object: "prepare";
571
+ url: string;
572
+ /** `not_checked` unless the request set `respect_robots`. */
573
+ robots: "allowed" | "disallowed" | "unreachable" | "not_checked";
574
+ timing: Timing;
575
+ }
576
+
491
577
  export interface MapRequest {
492
578
  url: string;
493
579
  /** Order results by relevance to this phrase. */
@@ -506,8 +592,16 @@ export interface MapRequest {
506
592
  ignore_query_parameters?: boolean;
507
593
  /** @default 1000 */
508
594
  limit?: number;
509
- /** @default 30000 */
595
+ /**
596
+ * Time for the whole map, the start page and its sitemaps included.
597
+ * @default 30000
598
+ */
510
599
  timeout_ms?: number;
600
+ /**
601
+ * Refuse a start URL the site's robots.txt or Content Signals disallow (`403 robots_disallowed`), and use its `Sitemap:` lines for sitemap discovery. Off by default: then no robots.txt is fetched at all and sitemaps are looked for at `/sitemap.xml`.
602
+ * @default false
603
+ */
604
+ respect_robots?: boolean;
511
605
  }
512
606
 
513
607
  export interface MapResult {
@@ -521,6 +615,62 @@ export interface MapResult {
521
615
  timing: Timing;
522
616
  }
523
617
 
618
+ export interface SearchRequest {
619
+ /**
620
+ * What to search for, at most 50 words. Operators the provider supports pass through: `site:`, quotes, `-word`.
621
+ */
622
+ query: string;
623
+ /**
624
+ * Most results to return.
625
+ * @default 5
626
+ */
627
+ limit?: number;
628
+ /**
629
+ * Two-letter country code to rank results for, like `us` or `de`. Default the provider's. A code the provider does not cover answers `400 invalid_request` on this field.
630
+ */
631
+ country?: string;
632
+ /** Language of the results, like `en`, `de` or `pt-br`. */
633
+ lang?: string;
634
+ /** Only results the provider found within this past period. */
635
+ freshness?: "day" | "week" | "month" | "year";
636
+ /**
637
+ * Filter adult content.
638
+ * @default "moderate"
639
+ */
640
+ safe_search?: "off" | "moderate" | "strict";
641
+ /**
642
+ * Time for the whole search, the results' scrapes included. A scrape it cuts short is that result's `scrape_timeout` error.
643
+ * @default 30000
644
+ */
645
+ timeout_ms?: number;
646
+ /**
647
+ * Scrape every result with these options. `headers`, `profile`, `actions` and the `json` format are refused (`400 invalid_request`): results are pages a third party's index chose.
648
+ */
649
+ scrape?: NestedScrapeOptions;
650
+ }
651
+
652
+ export interface SearchResult {
653
+ object: "search";
654
+ query: string;
655
+ results: {
656
+ /** Rank in the provider's order, from 1. */
657
+ position: number;
658
+ url: string;
659
+ title: string;
660
+ description?: string;
661
+ scrape?: ScrapeResult;
662
+ error?: Problem;
663
+ }[];
664
+ /**
665
+ * `scrape_failed: <n> of <m> results could not be scraped; each has its error`, and `empty_page: <n> of <m> results came back with no text in their Markdown; each has its warning`.
666
+ */
667
+ warnings?: string[];
668
+ /**
669
+ * `search_ms` and `total_ms`, and `scrape_ms` when the request has `scrape` and the search found results.
670
+ */
671
+ timing: Timing;
672
+ }
673
+
524
674
  /** Scrape options applied to every page. */
525
675
  export type NestedScrapeOptions = ScrapeOptions;
526
676
 
@@ -571,9 +721,19 @@ export interface CrawlCreateRequest {
571
721
  allow_external_links?: boolean;
572
722
  /** @default false */
573
723
  ignore_query_parameters?: boolean;
574
- /** Minimum gap between requests to the same host. */
724
+ /**
725
+ * Minimum gap between this crawl's requests to one host. Default 250 ms (or robots.txt's Crawl-delay with
726
+ * `respect_robots: true`). Whatever the value, job pages to one host start at least 250 ms apart
727
+ * node-wide, with at most 2 in flight to it per organization and 2 for all organizations together, and a
728
+ * 429 or 503 from the host pauses them for its `Retry-After`.
729
+ */
575
730
  delay_ms?: number;
576
731
  max_concurrency?: number;
732
+ /**
733
+ * Apply robots.txt: skip pages it disallows (`result.robots_blocked`), skip every page when it cannot be read (RFC 9309), and use its Crawl-delay when `delay_ms` is not set. Off by default.
734
+ * @default false
735
+ */
736
+ respect_robots?: boolean;
577
737
  scrape?: NestedScrapeOptions;
578
738
  webhook?: WebhookConfig;
579
739
  metadata?: Metadata;
@@ -619,7 +779,7 @@ export type Crawl = Omit<Job, "id" | "object" | "result"> & {
619
779
  result?: {
620
780
  pages_succeeded: number;
621
781
  pages_failed: number;
622
- /** URLs skipped because robots.txt disallows them. */
782
+ /** URLs skipped because robots.txt disallows them (empty unless the crawl set `respect_robots`). */
623
783
  robots_blocked: string[];
624
784
  };
625
785
  };
@@ -664,10 +824,17 @@ export type ExtractJob = Omit<Job, "id" | "object" | "result"> & {
664
824
  };
665
825
  };
666
826
 
667
- /** `active` until closed by `DELETE` (`closed`) or by its timeout (`expired`). */
827
+ /**
828
+ * `active` until closed by its timeout (`expired`) or otherwise (`closed`: `DELETE`, its browser stopped, or the node restarted; `closed_reason` says which).
829
+ */
668
830
  export type SessionStatus = "active" | "closed" | "expired";
669
831
 
670
832
  export interface SessionCreateRequest {
833
+ /**
834
+ * The session's browser. A session that asks for `headless-shell` starts its browser cold.
835
+ * @default "chrome"
836
+ */
837
+ browser?: BrowserEngine;
671
838
  /** A profile ID or name to load. */
672
839
  profile?: string;
673
840
  /**
@@ -681,8 +848,14 @@ export interface SessionCreateRequest {
681
848
  */
682
849
  overwrite_profile?: boolean;
683
850
  viewport?: Viewport;
684
- /** @default "en-US" */
851
+ /**
852
+ * BCP 47 locale for `Accept-Language` and the browser. Defaults to the locale of the node's egress location (`en-US` on every node today).
853
+ * @default "en-US"
854
+ */
685
855
  locale?: string;
856
+ /**
857
+ * IANA time zone for the browser. Defaults to the time zone of the node's egress location (`America/Los_Angeles` on every node today).
858
+ */
686
859
  timezone?: string;
687
860
  user_agent?: string;
688
861
  /**
@@ -694,6 +867,89 @@ export interface SessionCreateRequest {
694
867
  block_ads?: boolean;
695
868
  block_resources?: Array<"image" | "media" | "font" | "stylesheet">;
696
869
  metadata?: Metadata;
870
+ /**
871
+ * Give each act step's row in the session timeline a JPEG thumbnail of the viewport, at most 320 px wide,
872
+ * taken after the step. Each thumbnail adds a capture to the act call's time.
873
+ * @default false
874
+ */
875
+ thumbnails?: boolean;
876
+ }
877
+
878
+ export interface SessionTimeline {
879
+ object: "session_timeline";
880
+ session_id: string;
881
+ viewport: Viewport;
882
+ steps: TimelineStep[];
883
+ cursor: CursorPoint[];
884
+ /** What did not fit in the session's timeline. */
885
+ dropped: {
886
+ steps: number;
887
+ points: number;
888
+ thumbnails: number;
889
+ };
890
+ }
891
+
892
+ export interface TimelineStep {
893
+ /** Which act call on the session (1, 2, ...). */
894
+ act: number;
895
+ /** The step's position in that call's `actions`. */
896
+ index: number;
897
+ kind:
898
+ | "navigate"
899
+ | "click"
900
+ | "hover"
901
+ | "type"
902
+ | "key"
903
+ | "scroll"
904
+ | "select"
905
+ | "wait"
906
+ | "evaluate"
907
+ | "screenshot"
908
+ | "markdown";
909
+ started_at: string;
910
+ /** Milliseconds from the session's creation to the step's start. */
911
+ at_ms: number;
912
+ duration_ms: number;
913
+ status: "ok" | "failed" | "skipped";
914
+ /**
915
+ * The target's box in the viewport (CSS pixels, after it was scrolled into view), or `null` for a step without a target.
916
+ */
917
+ target: null | TimelineBox;
918
+ /** The URL a `navigate` step reached. */
919
+ url: string | null;
920
+ /** The step's problem; only on a step that failed. */
921
+ error?: Problem;
922
+ /** A JPEG of the viewport after the step, or `null` (thumbnails off, skipped step, budget spent). */
923
+ thumbnail: null | TimelineThumbnail;
924
+ }
925
+
926
+ /** Target box */
927
+ export interface TimelineBox {
928
+ x: number;
929
+ y: number;
930
+ width: number;
931
+ height: number;
932
+ }
933
+
934
+ /** Thumbnail */
935
+ export interface TimelineThumbnail {
936
+ format: "jpeg";
937
+ width: number;
938
+ height: number;
939
+ data_base64: string;
940
+ }
941
+
942
+ export interface CursorPoint {
943
+ /** Milliseconds from the session's creation. */
944
+ at_ms: number;
945
+ x: number;
946
+ y: number;
947
+ /** `Input.dispatchMouseEvent` type: `mouseMoved`, `mousePressed`, `mouseReleased` or `mouseWheel`. */
948
+ type: string;
949
+ /** The button of a press or release (`left`, `middle`, `right`, `back`, `forward`). */
950
+ button?: string;
951
+ /** `act`: an act step. `cdp`: a CDP client on the session socket. */
952
+ source: "act" | "cdp";
697
953
  }
698
954
 
699
955
  export interface SessionPage {
@@ -720,8 +976,16 @@ export interface BrowserSession {
720
976
  created_at: string;
721
977
  expires_at: string;
722
978
  closed_at: string | null;
979
+ /**
980
+ * Why the session closed; `null` while it is active. `deleted`: `DELETE`. `expired`: its timeout.
981
+ * `browser_exited`: its browser stopped under it. `node_restart`: the node stopped or restarted while the
982
+ * session was open; browser time is billed up to the stop and not after it (nothing when the node did not
983
+ * stop cleanly, since it cannot tell when the browser stopped). Closed sessions stay readable for 7 days.
984
+ */
985
+ closed_reason?: "deleted" | "expired" | "browser_exited" | "node_restart" | null;
723
986
  timeout_s: number;
724
987
  viewport: Viewport;
988
+ browser: BrowserEngine;
725
989
  /** The loaded profile, or `null`. */
726
990
  profile: null | SessionProfileRef;
727
991
  /** WebSocket URL of the session's CDP endpoint. */
@@ -741,8 +1005,9 @@ export type BrowserSessionList = Omit<ListEnvelope, "data"> & {
741
1005
 
742
1006
  /**
743
1007
  * One browser action; `kind` selects it. The kinds and their fields match render timeline actions
744
- * (`navigate`, `click`, `hover`, `type`, `key`, `scroll`, `select`, `wait`) plus `evaluate`, `screenshot` and
745
- * `markdown`, which only `act` and scrape `actions` offer.
1008
+ * (`navigate`, `click`, `hover`, `type`, `key`, `scroll`, `select`, `wait`) plus `evaluate`, `screenshot`,
1009
+ * `markdown` and `snapshot`, which only `act` and scrape `actions` offer, as is `settle` on `navigate`,
1010
+ * `click`, `type`, `key` and `select`.
746
1011
  */
747
1012
  export type ActStep =
748
1013
  | ActNavigate
@@ -755,8 +1020,10 @@ export type ActStep =
755
1020
  | ActWait
756
1021
  | ActEvaluate
757
1022
  | ActScreenshot
758
- | ActMarkdown;
1023
+ | ActMarkdown
1024
+ | ActSnapshot;
759
1025
 
1026
+ /** Navigate */
760
1027
  export interface ActNavigate {
761
1028
  kind: "navigate";
762
1029
  url: string;
@@ -764,11 +1031,30 @@ export interface ActNavigate {
764
1031
  wait_until?: "load" | "domcontentloaded" | "networkidle";
765
1032
  /** @default 10000 */
766
1033
  timeout_ms?: number;
1034
+ settle?: ActSettle;
767
1035
  }
768
1036
 
1037
+ /**
1038
+ * After the action's input, wait until the page settles, and report how long that took (`settled_ms`, from the browser's acknowledgement of the input) and how it ended (`settled_by`). The page is settled when the document is at least interactive (loaded, when the input led to a new document), no document load and no `fetch` or XHR to the page's own site (sent since the action began) is in flight, and no DOM mutation and no such request has started or ended for `quiet_ms`. Third-party requests, images, scripts and streams do not hold it. Reaching `timeout_ms` is not an error: the action succeeds with `settled_by: deadline`. `true` takes the defaults. A click that changes nothing settles in about `quiet_ms`. The observer runs in an isolated world, so the page's scripts never see it.
1039
+ */
1040
+ export type ActSettle =
1041
+ | boolean
1042
+ | {
1043
+ /** @default 50 */
1044
+ quiet_ms?: number;
1045
+ /**
1046
+ * The longest the settle waits (within the batch's own time).
1047
+ * @default 5000
1048
+ */
1049
+ timeout_ms?: number;
1050
+ };
1051
+
1052
+ /**
1053
+ * Click the target with trusted mouse events at its centre. Before pressing, vision checks that the target (or an element inside it, or one of its labels) is what the page draws at that point. A band fixed or sticky to the window that covers it gets one scroll to clear the target; any cover still there after half a second fails the click with `target_covered`, naming the cover, and no event is sent. A visually hidden checkbox or radio is clicked through its label.
1054
+ */
769
1055
  export interface ActClick {
770
1056
  kind: "click";
771
- target: Target;
1057
+ target: ActTarget;
772
1058
  /** @default "left" */
773
1059
  button?: "left" | "right" | "middle";
774
1060
  /** @default 1 */
@@ -779,18 +1065,23 @@ export interface ActClick {
779
1065
  * @default 10000
780
1066
  */
781
1067
  timeout_ms?: number;
1068
+ settle?: ActSettle;
782
1069
  }
783
1070
 
1071
+ /** Hover */
784
1072
  export interface ActHover {
785
1073
  kind: "hover";
786
- target: Target;
1074
+ target: ActTarget;
787
1075
  /** @default 10000 */
788
1076
  timeout_ms?: number;
789
1077
  }
790
1078
 
1079
+ /**
1080
+ * Types `text` into `target` (focused first) or, without a target, into the element that has focus. The target must lead to one field that takes text: an input whose type is not checkbox, radio, button, submit, reset, image, file, color, range or hidden, a textarea, or an editable element; a label, which stands for its control (its `for` target or the field inside it, so `{"text": "Email"}` types into the Email field); or any other element that holds exactly one such field. Anything else fails the step (`act_step_failed`) and nothing is typed. The detail says what to do instead: a `select` step for a select element, a `click` for a checkbox, radio or button, an `evaluate` step for a color or range input; a file or hidden input takes no typed text; an element holding several fields needs a target that names one.
1081
+ */
791
1082
  export interface ActType {
792
1083
  kind: "type";
793
- target?: Target;
1084
+ target?: ActTarget;
794
1085
  text: string;
795
1086
  /**
796
1087
  * Clear the field before typing.
@@ -804,31 +1095,38 @@ export interface ActType {
804
1095
  interval_ms?: number;
805
1096
  /** @default 10000 */
806
1097
  timeout_ms?: number;
1098
+ settle?: ActSettle;
807
1099
  }
808
1100
 
1101
+ /** Key */
809
1102
  export interface ActKey {
810
1103
  kind: "key";
811
1104
  /** `KeyboardEvent.key`, such as `Enter`, `Tab` or `a`. */
812
1105
  key: string;
813
1106
  modifiers?: KeyModifiers;
1107
+ settle?: ActSettle;
814
1108
  }
815
1109
 
816
1110
  /** Scroll to an offset (`to`), by a delta (`by`), or until `target` is in view. */
817
1111
  export interface ActScroll {
818
1112
  kind: "scroll";
819
- target?: Target;
1113
+ target?: ActTarget;
820
1114
  to?: Point;
821
1115
  by?: Point;
822
1116
  }
823
1117
 
1118
+ /** Select */
824
1119
  export interface ActSelect {
825
1120
  kind: "select";
826
- target: Target;
1121
+ target: ActTarget;
827
1122
  /** The option value to select. */
828
1123
  value: string;
1124
+ settle?: ActSettle;
829
1125
  }
830
1126
 
831
- /** Wait a fixed time (`ms`) or until a condition holds (`for`). */
1127
+ /**
1128
+ * Wait a fixed time (`ms`) or until a condition holds (`for`). `network_idle` holds once the document has loaded and no request has been in flight, sent or ended for 500 ms, counted from the start of the wait; requests count from the moment they are sent (long polls older than 30 seconds are ignored).
1129
+ */
832
1130
  export interface ActWait {
833
1131
  kind: "wait";
834
1132
  ms?: number;
@@ -837,6 +1135,7 @@ export interface ActWait {
837
1135
  timeout_ms?: number;
838
1136
  }
839
1137
 
1138
+ /** Evaluate */
840
1139
  export interface ActEvaluate {
841
1140
  kind: "evaluate";
842
1141
  /**
@@ -845,9 +1144,10 @@ export interface ActEvaluate {
845
1144
  expression: string;
846
1145
  }
847
1146
 
1147
+ /** Screenshot */
848
1148
  export interface ActScreenshot {
849
1149
  kind: "screenshot";
850
- target?: Target;
1150
+ target?: ActTarget;
851
1151
  /** @default false */
852
1152
  full_page?: boolean;
853
1153
  /** @default "jpeg" */
@@ -856,12 +1156,56 @@ export interface ActScreenshot {
856
1156
  quality?: number;
857
1157
  }
858
1158
 
1159
+ /** Markdown */
859
1160
  export interface ActMarkdown {
860
1161
  kind: "markdown";
861
1162
  /** @default true */
862
1163
  only_main_content?: boolean;
863
1164
  }
864
1165
 
1166
+ /**
1167
+ * An outline of the page for choosing what to act on: one element per line, indented by container, in Playwright's aria-snapshot shape (`- button "Sign in" [ref=3f9a2c10:e4]`). Controls and headings carry a `ref`; a later step targets one with `target: {ref}`, in this batch or a later `act` on the same page. `skeleton` lists landmarks, headings and controls, cuts names at 80 characters and counts the controls of one role past the eighth in a container (`- link (42 more)`) instead of listing them; `full` also lists text blocks and images, and every control. The outline stops at `max_tokens` (tokens counted as characters / 4): the step is still `ok`, with `truncated: true` and `complete: false`. Frames are listed, not entered.
1168
+ */
1169
+ export interface ActSnapshot {
1170
+ kind: "snapshot";
1171
+ /** @default "skeleton" */
1172
+ mode?: "skeleton" | "full";
1173
+ /** CSS selector of the element to outline (the body by default). */
1174
+ root?: string;
1175
+ /** @default 4000 */
1176
+ max_tokens?: number;
1177
+ }
1178
+
1179
+ /**
1180
+ * The element an action works on: a `Target` (found by selector, text or role when the step runs), or a `ref` from a `snapshot` step, which names the element that snapshot listed and nothing else.
1181
+ */
1182
+ export type ActTarget = Target | SnapshotRef;
1183
+
1184
+ /**
1185
+ * A ref from a `snapshot` step's outline (`<snapshot id>:e<n>`). It is bound to that element of that document: once the element is removed, or the page has navigated, or the ref comes from another page, the step fails with `stale_ref`, and vision never looks for a look-alike by text or role. A ref is used as it is, alone.
1186
+ */
1187
+ export interface SnapshotRef {
1188
+ ref: string;
1189
+ }
1190
+
1191
+ export interface SnapshotData {
1192
+ /** The snapshot's id, the first part of its refs. */
1193
+ id: string;
1194
+ mode: "skeleton" | "full";
1195
+ /** The outline, one element per line; controls and headings end in `[ref=<id>:e<n>]`. */
1196
+ text: string;
1197
+ /** How many refs the outline holds. */
1198
+ refs: number;
1199
+ /** How many elements the outline lists. */
1200
+ nodes: number;
1201
+ /** The outline's size in tokens, counted as characters / 4. */
1202
+ tokens: number;
1203
+ /** Every element of the mode's kinds is listed (none counted instead, nothing cut by the budget). */
1204
+ complete: boolean;
1205
+ /** The budget (`max_tokens`) cut the outline. */
1206
+ truncated: boolean;
1207
+ }
1208
+
865
1209
  export interface ActRequest {
866
1210
  actions: ActStep[];
867
1211
  /** The page to act on (from `pages`); defaults to the most recently active page. */
@@ -870,6 +1214,11 @@ export interface ActRequest {
870
1214
  continue_on_error?: boolean;
871
1215
  /** @default 30000 */
872
1216
  timeout_ms?: number;
1217
+ /**
1218
+ * Accept `confirm` dialogs (they are dismissed by default, so `confirm` returns false).
1219
+ * @default false
1220
+ */
1221
+ accept_confirm?: boolean;
873
1222
  }
874
1223
 
875
1224
  export interface ActStepResult {
@@ -884,7 +1233,8 @@ export interface ActStepResult {
884
1233
  | "wait"
885
1234
  | "evaluate"
886
1235
  | "screenshot"
887
- | "markdown";
1236
+ | "markdown"
1237
+ | "snapshot";
888
1238
  status: "ok" | "failed" | "skipped";
889
1239
  duration_ms: number;
890
1240
  /** `navigate`: the URL after redirects. */
@@ -896,7 +1246,56 @@ export interface ActStepResult {
896
1246
  screenshot?: ScreenshotData;
897
1247
  /** `markdown`: the page as Markdown. */
898
1248
  markdown?: string;
1249
+ snapshot?: SnapshotData;
899
1250
  error?: Problem;
1251
+ /** JavaScript dialogs the page opened while the action ran, in order. Left out when there were none. */
1252
+ dialogs?: ActDialog[];
1253
+ delivery: ActDelivery;
1254
+ retry: ActRetry;
1255
+ /**
1256
+ * With `settle`: milliseconds from the browser's acknowledgement of the input until the page settled (or the settle's deadline). Left out without `settle`.
1257
+ */
1258
+ settled_ms?: number;
1259
+ /**
1260
+ * With `settle`: `quiet` (the page went quiet), `navigation` (the input led to a new document, which loaded and went quiet; a `navigate` always ends this way) or `deadline` (`timeout_ms` came first; the action still succeeded).
1261
+ */
1262
+ settled_by?: "quiet" | "navigation" | "deadline";
1263
+ /**
1264
+ * What changed this action's answer, each starting with its code as a scrape's `warnings` do: a `screenshot` cut at the 16,384 px screenshot limit (`screenshot_truncated:` with the page's or the element's real size), a `markdown` read that returned the whole page because main content was under a quarter of it, or one that a markup limit or the extraction deadline shortened. Left out when there is nothing to say.
1265
+ */
1266
+ warnings?: string[];
1267
+ }
1268
+
1269
+ /**
1270
+ * Whether the action's input reached the page, on every result, failed and skipped ones included.
1271
+ * `delivered_verified`: sent, and the page's answer was seen (a `navigate` whose document loaded).
1272
+ * `delivered_unverified`: sent and acknowledged by the browser (a click, typed text, a key, a select, an
1273
+ * `evaluate`); what the page did with it is not checked. `delivery_uncertain`: part of it may have reached the
1274
+ * page (a `navigate` that timed out, `type` with `interval_ms` cut off). `not_delivered`: nothing was sent:
1275
+ * the target was missing, covered (`target_covered`) or stale (`stale_ref`), a field or option check refused,
1276
+ * the step was skipped, or the action sends no input (`wait`, `screenshot`, `markdown`, `snapshot`).
1277
+ * `unknown`: the browser stopped answering, or the batch ran out of time, after the input was sent.
1278
+ */
1279
+ export type ActDelivery =
1280
+ | "delivered_verified"
1281
+ | "delivered_unverified"
1282
+ | "delivery_uncertain"
1283
+ | "not_delivered"
1284
+ | "unknown";
1285
+
1286
+ /**
1287
+ * Whether sending the action again is safe. `safe`: nothing was sent, or the action does the same thing
1288
+ * twice (`navigate`, `hover`, `scroll`, the read actions). `unsafe`: its input landed and a second send repeats
1289
+ * it (a second click, the text typed twice). `unknown`: whether its input landed cannot be told (`delivery`
1290
+ * `unknown`, or an `evaluate` that threw part way).
1291
+ */
1292
+ export type ActRetry = "safe" | "unsafe" | "unknown";
1293
+
1294
+ export interface ActDialog {
1295
+ type: "alert" | "confirm" | "prompt" | "beforeunload";
1296
+ /** The dialog's text (cut at 1,000 characters). */
1297
+ message: string;
1298
+ action: "accepted" | "dismissed";
900
1299
  }
901
1300
 
902
1301
  export interface ActResult {
@@ -923,6 +1322,10 @@ export interface Profile {
923
1322
  expires_at?: ProfileTimestamp | null;
924
1323
  metadata: ProfileMetadata;
925
1324
  name: string;
1325
+ /**
1326
+ * Whether GET /v1/vision/profiles/{id}/state exports the state. True when the current state was uploaded; false when a B3OS browser session saved it: such state still loads into the organization's sessions, scrapes and render jobs, but the state route answers 403 profile_not_exportable. The flag governs that route only: a session's CDP client with vision:profiles:export reads the cookies of a profile the session loaded, and scripts in its pages read what the page's own scripts can. An upload makes a profile exportable again.
1327
+ */
1328
+ exportable: boolean;
926
1329
  /** Owning org. Returned to the owner only; tenancy is checked on every access. */
927
1330
  org?: string;
928
1331
  project?: string;
@@ -973,7 +1376,9 @@ export type ProfileMetadata = Record<string, string>;
973
1376
  export interface ProfileCookie {
974
1377
  name: string;
975
1378
  value: string;
976
- /** Host or .domain the cookie belongs to. */
1379
+ /**
1380
+ * Host or .domain the cookie belongs to: a name of two or more labels, or an IPv4 address. Single-label hosts such as localhost are refused (B3OS browsers reach only public hosts).
1381
+ */
977
1382
  domain: string;
978
1383
  path: string;
979
1384
  /** Unix time in seconds; -1 for a session cookie. */
@@ -1031,7 +1436,9 @@ export interface ProfileOpfsEntry {
1031
1436
  }
1032
1437
 
1033
1438
  export interface ProfileOrigin {
1034
- /** Serialized origin: scheme://host[:port], no path. */
1439
+ /**
1440
+ * Serialized origin: scheme://host[:port], no path. The host has two or more labels or is an IPv4 address.
1441
+ */
1035
1442
  origin: string;
1036
1443
  localStorage: ProfileNameValue[];
1037
1444
  indexedDB?: ProfileIndexedDBDatabase[];
@@ -1050,7 +1457,11 @@ export interface ProfileCreateRequest {
1050
1457
  /** Unique per project. */
1051
1458
  name: string;
1052
1459
  state: ProfileStorageState;
1053
- /** Registrable domains the profile may hold state for. Derived from `state` when omitted. */
1460
+ /**
1461
+ * Registrable domains the profile may hold state for. Derived from `state` when omitted. Each is a name of
1462
+ * two or more labels or an IPv4 address; a leading dot and capitals are dropped (spellings of one domain
1463
+ * count once); anything else answers 400 `invalid_request` with the item's pointer.
1464
+ */
1054
1465
  domains?: string[];
1055
1466
  /** Delete the profile automatically at this time. */
1056
1467
  expires_at?: string;
@@ -1084,66 +1495,542 @@ export type PresetRef = string;
1084
1495
 
1085
1496
  export type PresetKind = "background" | "frame" | "cursor" | "captions" | "click_effect";
1086
1497
 
1498
+ /** A background preset (`GET /v1/render/presets?kind=background` has a preview of each). */
1499
+ export type BackgroundPreset =
1500
+ | "b3os-light"
1501
+ | "b3os-dark"
1502
+ | "b3os-blue"
1503
+ | "midnight"
1504
+ | "aurora"
1505
+ | "sunset"
1506
+ | "ocean"
1507
+ | "arctic"
1508
+ | "dusk"
1509
+ | "forest"
1510
+ | "ember"
1511
+ | "graphite"
1512
+ | "paper";
1513
+
1514
+ /**
1515
+ * A window frame preset (`GET /v1/render/presets?kind=frame` has a preview of each). `window` is a macOS window whose 28 px bar (at 1080p) holds the traffic lights and nothing else, in the page's own top color, so it reads as the page's toolbar. `mac` adds a centered title (or the host), `browser` an address pill with the host, `windows` caption buttons; the `-dark` ones keep a dark bar whatever the page. A video has no frame by default: the bare rounded window.
1516
+ */
1517
+ export type FramePreset =
1518
+ | "window"
1519
+ | "window-dark"
1520
+ | "mac"
1521
+ | "mac-dark"
1522
+ | "browser"
1523
+ | "browser-dark"
1524
+ | "windows"
1525
+ | "windows-dark"
1526
+ | "phone"
1527
+ | "tablet"
1528
+ | "laptop"
1529
+ | "laptop-dark"
1530
+ | "desktop";
1531
+
1532
+ /** A cursor preset (`GET /v1/render/presets?kind=cursor` has a preview of each). */
1533
+ export type CursorPreset = "arrow" | "arrow-light" | "dot";
1534
+
1535
+ /**
1536
+ * A caption style preset (`GET /v1/render/presets?kind=captions` has a preview of each): `default`, a small
1537
+ * neutral near-black pill that never takes on the background's hue (where the darkest 30% of what it covers is
1538
+ * darker than luma 24, its fill is lifted 18 levels above that and its edge brightened, so it still reads as a
1539
+ * pill), whose
1540
+ * karaoke shows the spoken words white,
1541
+ * the word being spoken in a light B3 blue and the words to come dimmed; `bold`, a large dark pill with a yellow
1542
+ * karaoke word; `minimal`, outlined text with no box; `light`, dark text on a white box.
1543
+ */
1544
+ export type CaptionsPreset = "default" | "bold" | "minimal" | "light";
1545
+
1546
+ /** A click effect preset (`GET /v1/render/presets?kind=click_effect` has a preview of each). */
1547
+ export type ClickEffectPreset = "ripple" | "ring";
1548
+
1087
1549
  /**
1088
- * Style presets plus overrides, the same object as a timeline's `style` (restyle replaces exactly this). Field
1089
- * values inside `overrides` follow the compositor's style type (padding, corner radius, shadow, colors,
1090
- * gradients); strings are escaped before they reach any HTML or CSS.
1550
+ * One preset for each part plus `overrides`, the same object as a timeline's `style` (restyle replaces exactly
1551
+ * this). Every field is optional. The per-kind enums (`BackgroundPreset`, `FramePreset`, `CursorPreset`,
1552
+ * `CaptionsPreset`, `ClickEffectPreset`) list today's presets; the schema also takes any preset ID so a preset
1553
+ * added later needs no client update, and the node refuses an ID that is not a preset of that kind with
1554
+ * `style_invalid`. `none` draws nothing for that part; `auto` is the default background. On a video and on a
1555
+ * styled screenshot it draws one of the library images tagged `video` (the node's set, by default 24: macOS-style
1556
+ * waves, calm cool, warm and pastel gradient fields, deep dark fields, a grey grain and five soft photographs),
1557
+ * picked from the page (a video's first frame, a screenshot's capture). Only images at least 12 L* from the page
1558
+ * all along just outside the window's edges compete (a dark page: 20 L* lighter outside its dark edges). Among
1559
+ * them a small vision model (`b3os/qwen3.5-9b`, run by the node, not billed to you) picks the one that best
1560
+ * matches the app's look and brand, from the page and one labelled sheet of the candidates. Without the model,
1561
+ * when it does not answer within 4 s, or when one image clears, the color rules pick: the image whose hue suits
1562
+ * the page's accent color and whose tone sits behind the page (deeper behind a light page, airier behind a dark
1563
+ * one), ties broken by the page's host. The first pick for a site (the page's registrable domain, such as
1564
+ * `linear.app`; the host for `localhost` and IP addresses) is kept for your organization, so later videos and
1565
+ * screenshots of the site draw the same image while it clears their page's edges; `auto_background` pins an
1566
+ * image, picks again or turns the model off. The studio pick when no image clears the edges (or the node has no
1567
+ * set). The pick reads the page in CSS pixels, so it does not depend on the device scale; the result's
1568
+ * `auto_background` says which image was drawn and how it was chosen. On a video the timeline's `style` then
1569
+ * names the image in `overrides.background_ref`, and its `look` records it as the `auto` pick with how it was
1570
+ * chosen. If the node cannot load it in time (2 s for a file it has, 0.5 s for one it must fetch,
1571
+ * none while the image store is failing: a minute after it fails, or its Retry-After, 1 s to 10 min), the video
1572
+ * draws the studio pick and `warnings` says so
1573
+ * (`background_fallback`). `studio` is the studio pick by name, on screenshots and videos (what `auto` drew
1574
+ * before 2026-11-11, and what a restyle without a style draws for a timeline from before then: the mesh it
1575
+ * drew, read from the first frame's own pixels as production read it). `transparent` leaves
1576
+ * the background transparent.
1577
+ * Strings are drawn by the compositor and escaped before they reach any HTML or CSS.
1091
1578
  */
1092
1579
  export interface RenderStyle {
1093
- background?: PresetRef;
1094
- frame?: PresetRef;
1095
- cursor?: PresetRef;
1096
- captions?: PresetRef;
1097
- click_effect?: PresetRef;
1098
- /** Style fields that override the presets. */
1099
- overrides?: Record<string, unknown>;
1580
+ /** A background preset, or `auto`, `studio`, `transparent` or `none`. */
1581
+ background?: BackgroundPreset | "auto" | "studio" | "transparent" | "none" | (string & {});
1582
+ /** A window frame preset, or `none`. */
1583
+ frame?: FramePreset | "none" | (string & {});
1584
+ /** A cursor preset, or `none`. */
1585
+ cursor?: CursorPreset | "none" | (string & {});
1586
+ /** A caption style preset, or `none`. */
1587
+ captions?: CaptionsPreset | "none" | (string & {});
1588
+ /** A click effect preset, or `none`. */
1589
+ click_effect?: ClickEffectPreset | "none" | (string & {});
1590
+ overrides?: RenderStyleOverrides;
1100
1591
  }
1101
1592
 
1102
- /** Give `url` or `html`. */
1103
- export type ScreenshotCreateRequest = {
1104
- /** Page to load (`http` or `https`). */
1105
- url?: string;
1106
- /** HTML to render instead of loading a URL. Rendered with no network access. */
1107
- html?: string;
1108
- /** A vision profile ID or name to load before navigating (with `url` only). */
1109
- profile?: string;
1110
- viewport?: Viewport;
1593
+ /**
1594
+ * A color: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb(r,g,b)`, `rgba(r,g,b,a)`, `rgb(r g b / a)` (channels
1595
+ * 0-255 or percentages, alpha 0-1 or a percentage), a CSS color name such as `orange` or `rebeccapurple` (any
1596
+ * of the 148), or `transparent`. A value that is none of these is refused with an error that names it.
1597
+ */
1598
+ export type RenderColor = string;
1599
+
1600
+ /** One shadow, in CSS pixels; a field left out is 0, and the color defaults to black at 25% alpha. */
1601
+ export interface RenderShadow {
1602
+ x?: number;
1603
+ y?: number;
1604
+ blur?: number;
1605
+ spread?: number;
1606
+ color?: RenderColor;
1607
+ }
1608
+
1609
+ export type RenderGradientStop =
1610
+ | RenderColor
1611
+ | {
1612
+ color: RenderColor;
1613
+ /**
1614
+ * Position along the gradient, 0 to 1, never less than the stop before. Left out, stops are spaced evenly.
1615
+ */
1616
+ at?: number;
1617
+ };
1618
+
1619
+ /**
1620
+ * Style fields that override the presets; a closed set, so any other key is refused with `style_invalid`.
1621
+ * Lengths are CSS pixels, scaled with the device pixel ratio for screenshots and with the output size for
1622
+ * videos (relative to 1080p).
1623
+ */
1624
+ export interface RenderStyleOverrides {
1111
1625
  /**
1112
- * Device pixel ratio of the capture.
1113
- * @default 1
1626
+ * Space around the page, the same on every side or `{x, y}`. Left out, 6% of the canvas's long edge on a
1627
+ * screenshot (48 to 160 pixels), and on a video what `window_shape` gives: by default 8% of the frame's
1628
+ * height above and below the window and 6.5% of its width at each side on a landscape frame (86 and 126
1629
+ * pixels at 1920x1080, the window on even pixels), with room under the window for burned-in captions.
1114
1630
  */
1115
- dpr?: 1 | 2 | 3;
1116
- /** @default false */
1117
- full_page?: boolean;
1118
- target?: Target;
1119
- /** @default "load" */
1120
- wait_until?: "load" | "domcontentloaded" | "networkidle";
1631
+ padding?:
1632
+ | number
1633
+ | {
1634
+ x?: number;
1635
+ y?: number;
1636
+ };
1121
1637
  /**
1122
- * Extra settle time after the page is ready.
1123
- * @default 0
1638
+ * The window's corner radius in style px. Left out, 14 on a screenshot and 22 at 1080p on a video (2% of the output's short edge, scaled with it).
1124
1639
  */
1125
- wait_for_ms?: number;
1126
- /** @default 30000 */
1127
- timeout_ms?: number;
1640
+ corner_radius?: number;
1128
1641
  /**
1129
- * Emulated `prefers-color-scheme`; `auto` leaves the page default.
1130
- * @default "auto"
1642
+ * A shadow preset, one shadow, or a list of up to 6 drawn together. Left out, the default look's shadow, tinted with the background's own hue: on a video the `soft` one, on a screenshot a contact and an ambient shadow fading out 48-64 px below the window, which `classic` names (a video's before 2026-11-11). `subtle`, `soft` and `deep` are a directional layered shadow (a main shadow, a key light and a contact shadow), tinted the same way, deeper and stronger where the background under the window is deep: `soft` is 0 44 120 -12 at 30%, 0 14 36 -6 at 10% and 0 1 2 0 at 7% at 1080p on a light background, as screen recorders draw a window, deep below and faint above; `subtle` is about two thirds as deep and wide, `deep` about a quarter more. `none` draws none; `float`, `hard` and `glow` are black (glow blue) and untinted.
1131
1643
  */
1132
- theme?: "light" | "dark" | "auto";
1133
- /** CSS selectors to hide before capture (cookie banners, chat widgets). */
1134
- hide?: string[];
1135
- /** @default true */
1136
- block_ads?: boolean;
1137
- style?: RenderStyle;
1138
- /** @default "webp" */
1139
- format?: "webp" | "png" | "jpeg";
1644
+ shadow?: "none" | "subtle" | "soft" | "deep" | "classic" | "float" | "hard" | "glow" | RenderShadow | RenderShadow[];
1140
1645
  /**
1141
- * WebP and JPEG quality.
1142
- * @default 90
1646
+ * `none`, or a border of `width` (default 1) and `color`. Left out, a hairline matched to the background.
1647
+ */
1648
+ border?:
1649
+ | "none"
1650
+ | {
1651
+ width?: number;
1652
+ color?: RenderColor;
1653
+ };
1654
+ background_color?: RenderColor;
1655
+ /** A linear gradient at `angle` degrees (135 by default), or a radial one with `kind` radial. */
1656
+ background_gradient?: {
1657
+ kind?: "linear" | "radial";
1658
+ angle?: number;
1659
+ stops: RenderGradientStop[];
1660
+ };
1661
+ /**
1662
+ * A library background, `<pack>/<slug>` (`GET /v1/render/backgrounds` lists them; ScreenFramed's
1663
+ * `gradients/<pack>/<slug>` names the same entry of that group). It replaces the preset's background and
1664
+ * cannot be combined with `background_color` or `background_gradient`. An unknown ref is refused with
1665
+ * `style_invalid` at `/overrides/background_ref`. An image background is fetched by the render node on its
1666
+ * first use there and cached; if it cannot be loaded the request fails with `background_unavailable` (503,
1667
+ * retry).
1668
+ *
1669
+ * `"auto"` picks a library image that fits the captured page (a video's first frame): one of the quiet,
1670
+ * bold or soft-photo backgrounds (quiet ones first), in the page's light or dark theme (or `theme`'s), so a
1671
+ * light page gets a light, soft background and a dark page a dark one, with clear lightness separation, a
1672
+ * hue analogous or complementary to the page's accent, little detail where it shows around the window, and
1673
+ * enough pixels for the output. The same page gets the same background; the screenshot's `background_ref`
1674
+ * names the one drawn, a video's timeline `style` does. If the chosen image cannot be loaded within 2 s, the
1675
+ * screenshot or video keeps the style's own background (the `auto` background preset unless `background`
1676
+ * names another) and `warnings` says so (`background_fallback`). The default `auto` background already
1677
+ * draws a library image, on videos and styled screenshots; this picks from the whole library instead of
1678
+ * the video set.
1679
+ */
1680
+ background_ref?: string;
1681
+ /**
1682
+ * A text block set by the compositor above or below the window of a screenshot (Geist; never parsed as
1683
+ * HTML): an optional badge pill, a title (up to `title_lines` lines, 3 by default) and a subtitle (up to 4
1684
+ * lines), wrapped at `max_width` (the window's width by default); a line that does not fit ends with an
1685
+ * ellipsis. With `autofit` the title shrinks to fit instead. It needs a title, a subtitle or a badge. The
1686
+ * canvas grows to hold it, or on a fixed `canvas` the page shrinks. Screenshots only: a video with `text`
1687
+ * is refused with `style_invalid` at `/overrides/text`.
1688
+ */
1689
+ text?: {
1690
+ title?: string;
1691
+ subtitle?: string;
1692
+ badge?: string;
1693
+ /** Above (the default) or below the window. */
1694
+ position?: "above" | "below";
1695
+ /** Center (the default), left or right; left and right line up with the window's edge. */
1696
+ align?: "left" | "center" | "right";
1697
+ color?: RenderColor;
1698
+ badge_color?: RenderColor;
1699
+ /** Title size in CSS pixels, 48 by default (the subtitle's is 22). */
1700
+ title_size?: number;
1701
+ subtitle_size?: number;
1702
+ /** Wrapping width in CSS pixels; the window's width by default. */
1703
+ max_width?: number;
1704
+ /** Space between the text and the window, 40 by default. */
1705
+ gap?: number;
1706
+ /** The most lines the title wraps to, 3 by default. */
1707
+ title_lines?: number;
1708
+ /**
1709
+ * Sets the title at the largest size from `title_size` down to `fit_min` (in steps of 0.25 px) at
1710
+ * which it fits in `title_lines` lines with no word broken or cut; the subtitle and the badge keep
1711
+ * their ratio to it. A title that does not fit even at `fit_min` is set at `fit_min` with an ellipsis.
1712
+ * False by default.
1713
+ */
1714
+ autofit?: boolean;
1715
+ /**
1716
+ * The smallest title size `autofit` may use, in CSS pixels: half of `title_size` by default, at least
1717
+ * 12. A value above `title_size` counts as `title_size`; without `autofit` it is unused.
1718
+ */
1719
+ fit_min?: number;
1720
+ };
1721
+ /**
1722
+ * Tilts the window in 3D (ScreenFramed's presets; CSS `perspective: 1000px` about the canvas center),
1723
+ * scaled by `perspective_intensity`. Screenshots only, like every camera field below.
1724
+ */
1725
+ perspective?:
1726
+ | "none"
1727
+ | "tilt-left"
1728
+ | "tilt-right"
1729
+ | "tilt-up"
1730
+ | "tilt-down"
1731
+ | "tilt-left-strong"
1732
+ | "tilt-right-strong"
1733
+ | "iso-left"
1734
+ | "iso-right";
1735
+ /** How much of the `perspective` preset to apply, 50 by default. */
1736
+ perspective_intensity?: number;
1737
+ /**
1738
+ * A camera preset (tilt, roll, offset, frame scale and depth blur): `hero` 6/-6 degrees, offset 160,80,
1739
+ * 1.25x; `dashboard` 4/5, offset 10,70, 1.1x; `flat`; `cinematic` 25/0, 1.1x; `detail` 18/-9, offset
1740
+ * -30,0, 1.95x. Not with `perspective`; the single fields below override it, and `depth_blur` lists the
1741
+ * blur each one brings.
1742
+ */
1743
+ camera?: "hero" | "dashboard" | "flat" | "cinematic" | "detail";
1744
+ /** Degrees about the horizontal axis; positive tips the top away. */
1745
+ tilt_x?: number;
1746
+ /** Degrees about the vertical axis; positive turns the right side away. */
1747
+ tilt_y?: number;
1748
+ /** Degrees in the picture plane, clockwise. */
1749
+ roll?: number;
1750
+ /** Moves the tilted window, in CSS pixels. */
1751
+ camera_offset?: {
1752
+ x?: number;
1753
+ y?: number;
1754
+ };
1755
+ /** Scales the window about its center before the tilt; above 1 it may run past the canvas edges. */
1756
+ frame_scale?: number;
1757
+ /**
1758
+ * Depth of field over the whole composed screenshot (background, window, shadows and text): a Gaussian
1759
+ * blur whose sigma, in CSS pixels, is this value where the blur is full, mixed over the sharp image by
1760
+ * the `depth_blur_type` mask. The `hero` and `dashboard` cameras bring 6 from position 0.7, `cinematic`
1761
+ * 38 from 0.45 and `detail` 4 from 0.3 (ScreenFramed's presets); 0 turns the blur off. Screenshots only:
1762
+ * a video with a depth blur is refused with `style_invalid` at `/overrides/depth_blur`.
1763
+ */
1764
+ depth_blur?: number;
1765
+ /**
1766
+ * `dir` (the default) stays sharp up to `depth_blur_position` along `depth_blur_angle` and blurs toward
1767
+ * the far edge; `tilt` keeps a sharp band `depth_blur_band` wide centered at `depth_blur_position` and
1768
+ * blurs both sides; `radial` keeps the center sharp (18% of the half-diagonal) and blurs toward the
1769
+ * corners; `lens` is radial with a sharp circle of radius `depth_blur_width`. Needs `depth_blur`.
1770
+ */
1771
+ depth_blur_type?: "dir" | "radial" | "tilt" | "lens";
1772
+ /**
1773
+ * `dir` and `tilt`: the direction the blur grows toward (or the axis across the band), in degrees: 0 up,
1774
+ * 90 right, 180 down (the default), 270 left.
1775
+ */
1776
+ depth_blur_angle?: number;
1777
+ /**
1778
+ * `dir`: where the blur starts along the axis, 0.35 by default; `tilt`: the sharp band's center, 0.5 by
1779
+ * default.
1780
+ */
1781
+ depth_blur_position?: number;
1782
+ /** `tilt` only: the sharp band's width as a fraction of the axis, 0.25 by default. */
1783
+ depth_blur_band?: number;
1784
+ /** `lens` only: the sharp circle's radius as a fraction of the half-diagonal, 0.3 by default. */
1785
+ depth_blur_width?: number;
1786
+ /**
1787
+ * New colors for the library background's color tokens (each row of `GET /v1/render/backgrounds` lists its
1788
+ * `tokens`), for example `{"accent": "#2f43ff"}`. Needs `background_ref`; an unknown token is refused at
1789
+ * `/overrides/background_tokens/<token>`.
1790
+ */
1791
+ background_tokens?: Record<string, RenderColor>;
1792
+ /** The canvas aspect ratio; a screenshot's canvas grows to it. */
1793
+ aspect_ratio?: "auto" | "16:9" | "16:10" | "4:3" | "3:2" | "1:1" | "4:5" | "3:4" | "9:16" | "21:9";
1794
+ /** A fixed screenshot size; the page is fitted into it by `fit`. */
1795
+ canvas?: {
1796
+ width: number;
1797
+ height: number;
1798
+ };
1799
+ /** `contain` (the default) fits the whole page; `cover` fills the width and crops the bottom. */
1800
+ fit?: "contain" | "cover";
1801
+ /**
1802
+ * Where the window sits (ScreenFramed's `layout`). `default` centers it with `padding` around it.
1803
+ * `bottom-cropped` is a hero: the window is 80% of the canvas wide with equal sides and runs off the
1804
+ * bottom edge, so the top of the page shows and no bottom corner does. With `text` its top edge is at 28%
1805
+ * to 34% of the height and the text block is centered above it (the block shrinks as one until it fits,
1806
+ * and the title defaults to `title_lines` 2 with `autofit`); without text the top margin equals the
1807
+ * sides. On a fixed `canvas` the page is scaled to the window and the text sizes scale with it; without
1808
+ * one the page keeps its pixels and the canvas is the window's width / 0.8 wide at `aspect_ratio` (16:9
1809
+ * by default). `padding` and `fit` do not apply to it, nor does `text.position` `below`, and it does not
1810
+ * combine with a camera or perspective. Screenshots only: a video with it is refused with
1811
+ * `style_invalid` at `/overrides/layout`.
1812
+ */
1813
+ layout?: "default" | "bottom-cropped";
1814
+ /** Text for the window's title bar, drawn by the compositor and never parsed as HTML. */
1815
+ frame_title?: string;
1816
+ /**
1817
+ * Text for the address pill of a browser frame, and for a `mac` title bar that has no title (a video's
1818
+ * never does), drawn by the compositor and never parsed as HTML.
1819
+ */
1820
+ frame_url?: string;
1821
+ /** Flips the frame and the `auto` background. */
1822
+ theme?: "light" | "dark";
1823
+ /**
1824
+ * Cursor scale, 1 by default. On a video, 1 is an arrow 48 px tall on a 1080p frame (4.4% of the frame's
1825
+ * short side), about twice a system cursor against the page, as in Screen Studio; it grows with the camera's
1826
+ * zoom. On a screenshot, and with `look: 1`, 1 is the 22 px arrow on the page's scale.
1827
+ */
1828
+ cursor_size?: number;
1829
+ /** `false` keeps the cursor's size while the camera zooms. */
1830
+ cursor_zoom?: boolean;
1831
+ /**
1832
+ * How small the cursor gets when it clicks: it shrinks to this over 70 ms and springs back over 220 ms
1833
+ * after the release, with no overshoot. 0.8 by default; 1 turns it off. A video's only.
1834
+ */
1835
+ cursor_press_scale?: number;
1836
+ /**
1837
+ * The click effect's color. Left out, B3 blue (#2F43FF), and on a video white at 45% where the page under
1838
+ * the click is darker than luma 100 or more saturated than 0.6, such as a blue button, so the ring shows
1839
+ * there (not with `look: 1`). Set, it is that color on every page.
1840
+ */
1841
+ click_color?: RenderColor;
1842
+ /** How long the click effect lasts, 450 by default. */
1843
+ click_duration_ms?: number;
1844
+ /**
1845
+ * Caption text size in pixels at 1080p, 34 by default. Each captions preset starts at its own size: 34 for
1846
+ * `default`, 42 for `bold`, 40 for `minimal` and 44 for `light`. A caption's box keeps at least 48 px (at
1847
+ * 1080p) from each side of a video's frame: a cue too wide for that wraps between its words, and a word too
1848
+ * wide for it alone draws that cue smaller (not with `look: 1`).
1849
+ */
1850
+ caption_size?: number;
1851
+ caption_color?: RenderColor;
1852
+ /**
1853
+ * The karaoke word being spoken: a color (`RenderColor`: hex, `rgb()` or a CSS color name), or `auto`, the
1854
+ * `default` captions' setting. `auto` takes the color from the video's background: a preset background
1855
+ * of the video set carries its own accent (the image's most characteristic color), any other image or a
1856
+ * gradient gives the most saturated color covering at least 5% of it, and a flat or grey one gives
1857
+ * #9CB0FF. That color is then lightened or darkened, its hue kept, until it reads at 4.5:1 or more
1858
+ * against the caption's box (or the background under the caption when the box is clear), stands 12
1859
+ * or more (CIELAB Delta E) from `caption_color` and, where the words to come are dimmer than the spoken
1860
+ * ones (`caption_upcoming` under 1), is 10 or more points of CIELAB lightness further from the box than
1861
+ * they are, so the word being spoken always stands apart from the words already spoken and is never the
1862
+ * dimmest word in the caption. A color set here is drawn as it is. The color chosen is the same for the whole video and is recorded in the
1863
+ * timeline's `captions.highlight`, so a restyle without a style and a re-export repeat it; a restyle
1864
+ * that brings a style takes the word from that style, `auto` fitted to the background it draws. `bold` lights it in yellow; with `look: 1` the `default` captions light it in
1865
+ * #8B97FF, as before.
1866
+ */
1867
+ caption_highlight?: RenderColor | "auto";
1868
+ caption_background?: RenderColor;
1869
+ /**
1870
+ * Where burned-in captions sit for the whole video: `bottom` (the default) or `top`, centred in the caption
1871
+ * band beside the window. A cue never moves; the camera keeps every target it frames, and the cursor, at
1872
+ * least 24 px (at 1080p) clear of the pill instead. With `look: 1` a cue still moves to the other edge when a
1873
+ * step's target sits under it.
1874
+ */
1875
+ caption_position?: "bottom" | "top";
1876
+ /**
1877
+ * Karaoke: how bright the words still to come are, as an opacity of `caption_color`; the words already
1878
+ * spoken are `caption_color` and the word being spoken `caption_highlight`. 0.55 for the `default`
1879
+ * captions; 1 for the other presets, which draw the words to come like the spoken ones.
1880
+ */
1881
+ caption_upcoming?: number;
1882
+ /**
1883
+ * Karaoke: how long a word takes to light, from the shade of the words to come to `caption_highlight`,
1884
+ * while the word before it settles to `caption_color`, so the light passes from one word to the next with
1885
+ * no frame where none is lit. Only colors change: the line never moves as words light. 80 for the
1886
+ * `default` captions; 0 (at once) for the other presets.
1887
+ */
1888
+ caption_fade_ms?: number;
1889
+ /**
1890
+ * What a video draws around the caption where the window lies under it: when the camera zooms in until
1891
+ * the page fills the frame, or when the captions sit over the page. `blur`, the default on every preset,
1892
+ * blurs the window's pixels from 120 px (at 1080p) above the caption's box to the frame's edge,
1893
+ * progressively, from nothing to a 16 px blur (a Gaussian's standard deviation, as CSS `blur(16px)`) at
1894
+ * the box's edge and past it, and darkens light content there by up to 6% (dark content not at all), so
1895
+ * text beside, above and below the caption dissolves and is never cut by its edge. The wallpaper, the
1896
+ * caption and the cursor stay sharp; where the caption lies on the wallpaper, as at rest, nothing changes.
1897
+ * The blur keeps its own time: it stays through the pause between two lines on one page when the pause
1898
+ * is 1 s or less and the page lies under the caption at both of its ends, while only the caption fades,
1899
+ * and it fades in and out over 200 ms before the first line, after the last, at a page change and across
1900
+ * a longer pause (the timeline's `captions.backdrop`). `none` leaves the page around the caption as it is.
1901
+ * With `look: 1` there is none.
1902
+ */
1903
+ caption_backdrop?: "blur" | "none";
1904
+ /**
1905
+ * A video's window proportions under the default `padding`. `tall` (the default) gives the window the
1906
+ * height screen recorders give it and the width a desktop page needs: 8% of the frame's height above and
1907
+ * below the window (more on the captions' side when they need it) and, on a landscape frame, 6.5% of the
1908
+ * width at each side, the window never wider than 2:1; at 1920x1080 a 1668x864 window, 80% of the frame's
1909
+ * height, over a 1440x746 default viewport, the page drawn 1.16 times its CSS size. `wide` is the first look
1910
+ * v2 shape: 9% of the frame's long edge on every side, the window as wide as that leaves (1568x734 at
1911
+ * 1920x1080 over a 1440x674 viewport, 2.14:1).
1912
+ */
1913
+ window_shape?: "tall" | "wide";
1914
+ /**
1915
+ * Smear what moves over each frame's shutter, as a camera would: the window, page and background on every
1916
+ * frame of a zoom or pan that moves faster than `motion_blur_onset`, by its motion past it over half a
1917
+ * frame. On by default. Held frames, and frames the camera moves through slowly, stay sharp, exactly as
1918
+ * without it. At the default 60 fps the fastest frames of the default zoom-in soften and a paused one still
1919
+ * reads. A moving cursor stays
1920
+ * a sharp arrow on every frame, over a faint trail behind it of its motion across the shutter, at most three
1921
+ * quarters of the arrow long. With `look: 1` only the cursor's trail shows, as its smear did before.
1922
+ */
1923
+ motion_blur?: boolean;
1924
+ /**
1925
+ * How long the shutter stays open, in frames, centered on each frame's time: 0.5 by default (half a frame at the
1926
+ * default 60 fps). 1 is Screen Studio's whole frame (1/60 s at 60 fps), twice as long a smear.
1927
+ */
1928
+ motion_blur_shutter?: number;
1929
+ /**
1930
+ * How fast what the camera shows must move at the frame's edge, on average and with the zoom's own rate,
1931
+ * before the window, page and background smear, in the frame's short sides a second, whatever the frame
1932
+ * rate: 0.45 by default, about 8 px a frame at 1080p and 60 fps, so slower frames stay sharp and a faster one
1933
+ * smears by `motion_blur_shutter` of the motion past it, up to `motion_blur_max`. Read at the edge, a zoom
1934
+ * about the middle of the frame blurs like a zoom into a corner. 0 smears every frame of a move from its first
1935
+ * pixel. The cursor's trail shows its own motion whatever this is.
1936
+ */
1937
+ motion_blur_onset?: number;
1938
+ /**
1939
+ * The longest smear a camera move leaves at the frame's edge, on average, in pixels at 1080p: 6.5 by
1940
+ * default, so the fastest frames of every zoom soften alike (to about a quarter of the sharpness at rest)
1941
+ * and a paused one still reads. 200 lifts the limit.
1942
+ */
1943
+ motion_blur_max?: number;
1944
+ /**
1945
+ * How close to its camera move's top speed a frame must be to smear: 0 by default, no such gate. 0.9 smears
1946
+ * only the two or three fastest frames of a move, as before 11-10.
1947
+ * `{"motion_blur_shutter": 1, "motion_blur_onset": 0, "motion_blur_max": 200}` smears every camera move by the
1948
+ * whole frame, as Screen Studio does.
1949
+ */
1950
+ motion_blur_peak?: number;
1951
+ matte?: RenderColor;
1952
+ /**
1953
+ * `1` draws a video in production's look from before 2026-11-11: its frame and layout (`padding`, 64 px at
1954
+ * 1080p by default, on every side, and the default viewport of then, 1440x730 at 1920x1080 in the browser
1955
+ * frame), the captions over the page near the window's foot, the 60% black caption pill, `bold` as 52 px
1956
+ * outlined text, the studio background for `auto`, 14 pixel corners, the old default shadow and a cursor
1957
+ * shown from the start. A new video gets a page-only camera, which zooms the page inside a window that
1958
+ * stands still, capped at 1.6x by default (`max_zoom` sets another; no `background_motion` or
1959
+ * `background_blur`), with today's move timings, and makes the poster the whole window after the last
1960
+ * step. Send it with `"frame": "browser"` to keep a video's old look. With it, `shadow: "soft"` is the old
1961
+ * black two-layer shadow, on a screenshot too. A restyle keeps the camera its video was recorded with, and
1962
+ * draws today's cursor, a sharp arrow over a faint trail, where production stamped copies of it. `2`, the
1963
+ * default, is the current look.
1964
+ */
1965
+ look?: 1 | 2;
1966
+ }
1967
+
1968
+ /** Give `url` or `html`. */
1969
+ export type ScreenshotCreateRequest = {
1970
+ /** Page to load (`http` or `https`). */
1971
+ url?: string;
1972
+ /** HTML to render instead of loading a URL. Rendered with no network access. */
1973
+ html?: string;
1974
+ /**
1975
+ * A vision profile ID or name of this project to load before the page loads, to capture it signed in (with `url` only; needs `vision:profiles:use`). A page that is still signed out fails with `profile_expired`.
1976
+ */
1977
+ profile?: string;
1978
+ viewport?: Viewport;
1979
+ /**
1980
+ * Device pixel ratio of the capture.
1981
+ * @default 1
1982
+ */
1983
+ dpr?: 1 | 2 | 3;
1984
+ /** @default false */
1985
+ full_page?: boolean;
1986
+ target?: Target;
1987
+ /**
1988
+ * When the page counts as loaded. `auto` takes the load event, or, from 2 s after the navigation started, a first screen that has painted with its web fonts, the images in view and any large video in view loaded and has stayed that way for 0.3 s, whichever comes first; from 6 s a painted page is taken with media in view still loading. A page taken before its load event gets a `load_incomplete` warning. `load` waits for the load event up to `timeout_ms`, `domcontentloaded` for DOMContentLoaded, `networkidle` for the load event and then 500 ms without a request.
1989
+ * @default "auto"
1990
+ */
1991
+ wait_until?: "auto" | "load" | "domcontentloaded" | "networkidle";
1992
+ /**
1993
+ * Extra settle time after the page is ready.
1994
+ * @default 0
1995
+ */
1996
+ wait_for_ms?: number;
1997
+ /** @default 30000 */
1998
+ timeout_ms?: number;
1999
+ /**
2000
+ * Emulated `prefers-color-scheme`; `auto` leaves the page default.
2001
+ * @default "auto"
2002
+ */
2003
+ theme?: "light" | "dark" | "auto";
2004
+ /**
2005
+ * CSS selectors to hide before capture, for anything `overlays` does not find on its own (a site's own sticky promotion, a notice you do not want in the image).
2006
+ */
2007
+ hide?: string[];
2008
+ /**
2009
+ * Block requests to ad and tracker hosts, and collapse the ad slots they leave empty (listed as `ad_slot` in `overlays_removed`), so no blank band is left where an ad was.
2010
+ * @default true
2011
+ */
2012
+ block_ads?: boolean;
2013
+ /**
2014
+ * `remove` hides what covers a page loaded from `url`: consent walls and banners (known consent managers by their markup, others by their text; a layer that fills the viewport counts as consent only with a consent wall's shape, a dim or blurred ground, dialog semantics, a consent manager's markup or a consent answer button), sign-up, discount and app dialogs, the dim layer behind a dialog, and chat widgets, and lifts the scroll lock a dialog left. Nothing is clicked. It runs after the page is ready and again right before the capture. The page's own header, navigation, hero video and an app shell that fills the viewport stay, and so does a paywall or registration wall with no close control (with its dim layer and the scroll lock): `page_state` reports it. `keep` leaves the page as it loaded and lists the overlays in view in `warnings`. Inline `html` is never changed.
2015
+ * @default "remove"
2016
+ */
2017
+ overlays?: "remove" | "keep";
2018
+ /**
2019
+ * `auto` finishes the page's entrance animations (finite CSS and Web Animations, never endless ones), waits up to 1.5 s for the first screen to fill in (a large video in view to show its first frame, skeleton blocks to give way to content, a large image or video player in view to show something), and when the capture's main area is still blank while the page is loading or fading in, captures again every 100 ms for up to 1.5 s. `fast` captures as soon as the readiness rule (`wait_until`, then a short network quiet window) is met. Applies to `url` captures of the viewport; element and full-page shots finish animations only.
2020
+ * @default "auto"
2021
+ */
2022
+ settle?: "auto" | "fast";
2023
+ style?: RenderStyle;
2024
+ /** @default "webp" */
2025
+ format?: "webp" | "png" | "jpeg";
2026
+ /**
2027
+ * WebP and JPEG quality.
2028
+ * @default 90
1143
2029
  */
1144
2030
  quality?: number;
1145
2031
  /** Extra encodings of the same capture, each an artifact. */
1146
2032
  variants?: ScreenshotVariant[];
2033
+ auto_background?: AutoBackgroundOptions;
1147
2034
  metadata?: Metadata;
1148
2035
  };
1149
2036
 
@@ -1174,8 +2061,48 @@ export interface Screenshot {
1174
2061
  artifacts: Artifact[];
1175
2062
  created_at: string;
1176
2063
  expires_at: string;
2064
+ /**
2065
+ * The HTTP status the site answered for the page (absent for `html`). A 404 page is still a successful screenshot of the site's error page; `page_state` and `warnings` say so.
2066
+ */
2067
+ status_code?: number;
2068
+ /** The URL after redirects (absent for `html`). */
2069
+ final_url?: string;
2070
+ page_state?: ScreenshotPageState;
2071
+ /**
2072
+ * Non-fatal problems, each starting with a code and a colon: `http_status` (the site answered an error, or a 200 whose title says the page is missing), `blank_main_area` (the main area was still one color after the readiness wait), `still_animating` (content was still fading in when the wait ended), `login_form` (a sign-in form instead of the content), `video_not_shown` (a video or video player in view had no frame to show and its box is empty in the image: a format this browser cannot play, or still loading), `image_not_shown` (a large image in view had not loaded and its box is empty in the image), `content_placeholder` (loading placeholders, the gray skeleton blocks a site draws while its content loads, were still in view), `partial_page` (when the wait ended, the lower part of the first screen was empty or a loading indicator stood alone above the page's footer, and the site had answered 202 or the page still had work under way: the page may not have finished drawing, or may have finished with a spinner left in view), `overlays_kept` (overlays in view with `overlays: "keep"`), `paywall` (a subscription wall covers the content and was left in place), `login_wall` (a registration or sign-in wall covers the content and was left in place), `load_incomplete` (`wait_until: "auto"` took the page before its load event, with how many images and videos in view had not arrived), `text_glyph_missing` (characters of the style's text, frame title or host that no font on the node has, or in a script the compositor does not shape yet, such as Devanagari and Thai; they are left blank), `background_fallback` (the library image the `auto` background or `background_ref: "auto"` chose could not be loaded within 2 s; the style's own background was drawn), `auto_background_pin` (the project's, organization's or node's `auto_background` pin does not clear the page's edges, so `auto` picked another image; it names both).
2073
+ */
2074
+ warnings?: string[];
2075
+ /** What the clean capture hid, by kind and signal, with how many (`overlays`, `block_ads`). */
2076
+ overlays_removed?: OverlayRemoved[];
1177
2077
  timing?: Timing;
1178
2078
  metadata: Metadata;
2079
+ /**
2080
+ * The library background drawn: the style's `overrides.background_ref`, or the image `"auto"` chose for
2081
+ * this page. Absent when the style draws no library background.
2082
+ */
2083
+ background_ref?: string;
2084
+ auto_background?: AutoBackgroundChoice;
2085
+ }
2086
+
2087
+ /**
2088
+ * What kind of page the screenshot captured, with vision's `PageState` field names: `ok`; `error` (an error status, signal `status`, or a 200 whose title says the page is missing, signal `title`); `loading` (the main area stayed blank, signal `blank_main_area`, or images or videos in view had not arrived when `wait_until: "auto"` took the page, signal `images_pending`, or skeleton blocks were still in view, signal `placeholders`, or, when the wait ended, the lower part of the first screen was empty or a loading indicator stood alone above the page's footer while the site had answered 202 or the page still had work under way, signal `partial_page`); `login` (a sign-in form instead of the content, signal `password_form`, or a registration or sign-in wall over it, signal `login_wall`); `paywall` (a subscription wall over the content, signal `paywall`; render's own state, as vision reads the HTML and has none); `cookie_wall` (a consent overlay left in view with `overlays: "keep"`). A wall is kept in the image, never hidden. A challenge or block page is not a screenshot: it fails with 502 `capture_failed` and reason `bot_challenge`.
2089
+ */
2090
+ export interface ScreenshotPageState {
2091
+ state: "ok" | "error" | "loading" | "login" | "paywall" | "cookie_wall";
2092
+ /** What decided it. */
2093
+ signal?: string;
2094
+ }
2095
+
2096
+ export interface OverlayRemoved {
2097
+ /**
2098
+ * `consent` a consent wall or banner, `dialog` a sign-up, discount or app dialog, `backdrop` the dim layer behind one, `banner` a promotion strip or corner box, `chat` a chat launcher or messenger, `ad_slot` an ad slot left empty by `block_ads`.
2099
+ */
2100
+ kind: "consent" | "dialog" | "backdrop" | "banner" | "chat" | "ad_slot";
2101
+ /**
2102
+ * How it was recognized: a consent manager's name (`onetrust`, `sourcepoint`, `trustarc`...), `markup`, `text`, `banner`, `dialog`, `dim`, `promo`, `widget`, or `empty` for ad slots.
2103
+ */
2104
+ signal: string;
2105
+ count: number;
1179
2106
  }
1180
2107
 
1181
2108
  export type ScreenshotList = Omit<ListEnvelope, "data"> & {
@@ -1185,7 +2112,10 @@ export type ScreenshotList = Omit<ListEnvelope, "data"> & {
1185
2112
  export interface Artifact {
1186
2113
  id: string;
1187
2114
  object: "artifact";
1188
- kind: "image" | "mp4" | "gif" | "poster" | "vtt" | "srt";
2115
+ /**
2116
+ * `vtt` and `srt` are the captions; `chapters` is a WebVTT chapters file (`chapters.vtt`, text/vtt) with one cue per beat that has a `title`, starting where that beat starts, written for every video with a titled beat. `share` is a video's share page (`share.html`, text/html, `renderShareVideo`).
2117
+ */
2118
+ kind: "image" | "mp4" | "gif" | "poster" | "vtt" | "srt" | "chapters" | "share";
1189
2119
  content_type: string;
1190
2120
  bytes?: number;
1191
2121
  width?: number;
@@ -1238,8 +2168,9 @@ export interface StepType {
1238
2168
  target?: Target;
1239
2169
  text: string;
1240
2170
  /**
1241
- * Delay between characters on the video's clock.
1242
- * @default 80
2171
+ * Delay between characters on the video's clock. Left out, 35 ms: quick, steady typing, which reads well
2172
+ * on screen. The camera holds one shot on the field for the whole burst (`camera.typing_zoom`).
2173
+ * @default 35
1243
2174
  */
1244
2175
  interval_ms?: number;
1245
2176
  }
@@ -1290,7 +2221,9 @@ export interface Beat {
1290
2221
  export interface VideoSource {
1291
2222
  /** Where the recording starts. */
1292
2223
  url: string;
1293
- /** A vision profile ID or name to start signed in. Responses show the resolved `prof_` ID. */
2224
+ /**
2225
+ * A vision profile ID or name of this project to record signed in: loaded into the probe and every capture segment (needs `vision:profiles:use`). Responses show the resolved `prof_` ID. A page that opens still signed out fails the video with `profile_expired`.
2226
+ */
1294
2227
  profile?: string;
1295
2228
  }
1296
2229
 
@@ -1305,8 +2238,7 @@ export interface VoiceSpec {
1305
2238
 
1306
2239
  export interface CaptionOptions {
1307
2240
  /**
1308
- * `none`: sidecar files only. `static`: draw each cue. `karaoke`: also highlight the spoken word.
1309
- * @default "none"
2241
+ * `none`: sidecar files only. `static`: draw each cue as a small pill in the margin under the window, which grows to hold it, on one line when that fits and `max_chars_per_line` and `max_lines` are left out. When the captions are too large for the margin, every cue sits over the page near its foot instead, and moves to the top while a step clicks what it would cover. `karaoke`: the same, with the words in step with the narration: on the default pill the words already spoken are white, the word being spoken is lit in a light B3 blue and the words to come are dimmed, each word lighting over 80 ms. A cue stays up until 0.2 s after its last word and 0.3 s after the last step of its beat is done; one still up when a click loads a new page ends 0.1 s after that page first shows, or 0.2 s after its last word when that is later. Left out: `karaoke` when the video is narrated, `static` when it is silent (`voice: null`, or a key without `infer:run`), whose word times are only estimated.
1310
2242
  */
1311
2243
  burn_in?: "none" | "static" | "karaoke";
1312
2244
  /** @default ["vtt"] */
@@ -1322,6 +2254,11 @@ export interface CaptionOptions {
1322
2254
  export interface VideoOutput {
1323
2255
  width: number;
1324
2256
  height: number;
2257
+ /**
2258
+ * Frames per second of the video. The page is captured at 30 frames a second and the camera, cursor and
2259
+ * captions are drawn at this rate; while the page scrolls, a 60 fps video captures it at 60, once per output
2260
+ * frame (the timeline's `capture.stride` and `capture.full_rate`).
2261
+ */
1325
2262
  fps: 24 | 25 | 30 | 50 | 60;
1326
2263
  }
1327
2264
 
@@ -1330,39 +2267,323 @@ export type VideoFormat = "mp4" | "gif" | "poster";
1330
2267
  export interface VideoCreateRequest {
1331
2268
  source: VideoSource;
1332
2269
  beats: Beat[];
1333
- voice?: VoiceSpec;
2270
+ /**
2271
+ * The narration voice. Leave it out and every beat with `say` is narrated in the node's default voice,
2272
+ * `kokoro-82m` `af_heart`, normalized to -16 LUFS. Narration is speech made as the caller, so it needs
2273
+ * `infer:run` in the key's scopes as well as `render:run`; a key without it gets a silent video with a
2274
+ * `narration_scope` warning. `null` makes a silent video: word times are then estimated from the text, so
2275
+ * steps and captions still follow the lines.
2276
+ */
2277
+ voice?: VoiceSpec | null;
1334
2278
  captions?: CaptionOptions;
2279
+ /**
2280
+ * The look. Leave it out, or send `{}`, for the B3OS look on the bare rounded window, with no bar;
2281
+ * `{"frame": "window"}` adds the traffic lights on a slim bar in the page's top color, and `{"frame":
2282
+ * "browser"}` an address pill.
2283
+ */
1335
2284
  style?: RenderStyle;
2285
+ /**
2286
+ * How the camera follows the steps. The camera moves over the whole frame: as it zooms in, the window, its
2287
+ * shadow and the page grow together and the background and the window's edges leave the frame, while
2288
+ * captions stay where they are. By default (`framing: subject`) each page is held in one of three
2289
+ * compositions: the whole window, the page's main content area, or one panel (see `framing`). With
2290
+ * `framing: point`, before a click, select or typing step it zooms in on the element and stays in through
2291
+ * the whole step (a type until its last key), for 1.5 s at least; it stays in for the next step when that
2292
+ * one starts within 2.5 s, or is close by, and pans only when the next element nears the edge of the frame,
2293
+ * and only as far as brings it back in. Every move is one quick, damped spring with no overshoot:
2294
+ * a zoom in or out takes 0.6 s (the first zoom-in less when the first step comes in under 1.1 s); a move to
2295
+ * the next element sets off with the cursor, never before it, and takes longer the farther it goes, so the
2296
+ * middle of the frame moves at most 60 px a frame at 60 fps, or faster where that keeps the cursor 8% of
2297
+ * the frame inside its edges. An element near an edge of the window zooms with that edge held in place, so
2298
+ * the margin beside it stays in view, and where the whole window or page fits the frame, it stays whole,
2299
+ * with the room beside it split evenly when there is little to spare. The camera rests 1.5 s at least on
2300
+ * what it shows last before it zooms out, when the video has room before its end, and the last zoom holds
2301
+ * until the narration line about it has nearly ended. The video opens on the whole window
2302
+ * for half a second at least and ends on it for a second at least, so it can run a little past the last
2303
+ * beat.
2304
+ */
1336
2305
  camera?: {
1337
2306
  /**
1338
- * Zoom toward the element each step acts on.
1339
- * @default true
2307
+ * `auto` moves the camera. With `framing: subject`, the default, its zooms are its compositions' (see
2308
+ * `framing`) and what follows holds where it says so. With `framing: point` it zooms so the element and a
2309
+ * little around it fill about 45% of the frame width, from 1.25x up to `max_zoom`, and 1.25x on an
2310
+ * element in a nav, aside or header bar, where the change it causes is
2311
+ * usually elsewhere on the page. A zoom under 1.4x is not worth the move: the camera stays wide for it
2312
+ * (a nav element starting a session, a typing shot under 1.4x), and an element inside a zoomed session
2313
+ * that would zoom less is framed at the session's zoom. After a move lands, the next waits 1.2 s at
2314
+ * least: an element that comes sooner is framed with the one before it when both fit one view at 1.4x
2315
+ * or more, else the camera stays where it is for the earlier one and moves once, to the later one. With
2316
+ * `scroll: comfortable` the view changes (camera moves and page scrolls together) at most once per 2.5 s
2317
+ * on average over the video: over that, the move with the least change of zoom whose element was
2318
+ * already in view is left out, and the element is framed where the camera stands. A
2319
+ * re-centre under 96 px at 1080p is left out. A click that loads a new page ends the zoom: the camera
2320
+ * starts going wide 0.1 s after the new page first shows, also when the page's address changes only by
2321
+ * the next step. On a portrait frame the camera zooms at most as far as keeps the whole window across the
2322
+ * frame, and the 1.4x floor applies after that, so a portrait video stays on the whole window and only
2323
+ * its page scrolls. Held against one window edge, a view keeps a window edge on the other axis that shows
2324
+ * in the frame at its resting margin. With burned-in captions every element the camera frames, and the
2325
+ * cursor resting by it, stays at least 24 px (at 1080p) clear of the caption pill, and a zoomed hold keeps
2326
+ * the window's bottom edge where it rests, so the pill sits on the background under it, whenever the
2327
+ * element ends at least 20 px above that edge and starts at least 120 px below the frame's top; otherwise
2328
+ * the pill lies over the page. A hold never leaves the window's bottom edge between y 960 and 1080 at
2329
+ * 1080p: it moves it to 950 or below the frame. With both framings the 1.2 s between moves, the 2.5 s
2330
+ * budget, the click that loads a new page and the portrait limit hold. The pill never moves. `subtle` makes the same moves at 1.25x (its zooms
2331
+ * are kept, under 1.4x). `off` keeps the whole window in view.
2332
+ * @default "auto"
2333
+ */
2334
+ style?: "auto" | "subtle" | "off";
2335
+ /**
2336
+ * The older spelling of `style`: `false` is `off`, `true` is `auto`. Send `style` instead. A request
2337
+ * whose `auto_zoom` and `style` disagree is refused with `invalid_request`.
2338
+ * @deprecated
1340
2339
  */
1341
2340
  auto_zoom?: boolean;
1342
- /** @default 2 */
2341
+ /**
2342
+ * The most the camera zooms, never exceeded. A small button reaches it; a wide element zooms less, so it
2343
+ * fits. Left out, the camera zooms up to 1.7x, or to the zoom within 10% of it where one captured pixel
2344
+ * lands on one output pixel (1.73x on the default canvas and viewport, two output pixels per CSS pixel;
2345
+ * 1.84x with `window_shape: wide`), so zoomed text is as sharp as the page. Left out, it never magnifies
2346
+ * the page past three output pixels per CSS pixel at 1080p, so a phone layout on a portrait video, drawn
2347
+ * at about twice its size, zooms about 1.4x. Above that the zoom enlarges the capture, and text is a
2348
+ * little softer. The zoom magnifies the whole frame, window and page alike. With `look: 1`, left out
2349
+ * it is 1.6, production's cap, which lands at 1.61x, one to one, on that look's default canvas, and
2350
+ * the zoom magnifies the page inside the window.
2351
+ * @default 1.7
2352
+ */
1343
2353
  max_zoom?: number;
2354
+ /**
2355
+ * How far the background follows the window as the camera moves: 0 holds it still, 1 moves and zooms
2356
+ * it with the window, so the whole frame zooms as one. At the default it moves and zooms a tenth as
2357
+ * much, a slight depth behind the window.
2358
+ * @default 0.1
2359
+ */
2360
+ background_motion?: number;
2361
+ /**
2362
+ * Blur the background: an image background is drawn 4 px soft on the whole window (at 1080p, scaled
2363
+ * with the frame), so the window stays the busiest thing in the frame, and softens further as the camera
2364
+ * zooms in, about 7 px at 1.6x on a 1080p video, at most 16 px. `false` keeps it sharp throughout, and
2365
+ * `overrides.look: 1` draws it sharp at rest. Left out, it is on for an image background (the default
2366
+ * look's library images among them) and off for gradients, solid colors and patterns, where a blur shows
2367
+ * little or erases the pattern. Gradients, solid colors and patterns are never blurred at rest. It is
2368
+ * decided before the first frame, so a default video drawn on its studio fallback (no library image
2369
+ * clears the page's edges, or the image could not be loaded) blurs that mesh as the camera zooms; send
2370
+ * `false` to keep it sharp.
2371
+ */
2372
+ background_blur?: boolean;
2373
+ /**
2374
+ * The zoom of a typing shot: a field typed into (a `type` step, or a click a `type` without a target
2375
+ * follows) is framed from its start at this zoom, reached by the first key (the cursor gets there half a
2376
+ * second early) and held for the whole
2377
+ * burst, with no move per key; a click right after it on something already in view stays in the
2378
+ * same shot.
2379
+ * It is never less than the camera's least zoom, 1.25x, which is what 1 gives, never more than
2380
+ * `max_zoom`, nor more than the zoom where the page is as sharp as captured (1.73x on the default
2381
+ * canvas), so the default types at 1.73x. `style: subtle` keeps its own ceiling, and a field in a nav,
2382
+ * aside or header bar its own zoom. With `framing: subject` a field typed into is a DETAIL when it
2383
+ * qualifies (see `framing`), at this zoom at most, and otherwise held in the page's main content area.
2384
+ * @default 2
2385
+ */
2386
+ typing_zoom?: number;
2387
+ /**
2388
+ * What the camera holds. `subject` (the default) holds each page in one of three compositions. The
2389
+ * whole window. MAIN, the page's main content area across the frame: the content box of its `main` (or
2390
+ * `role="main"`) element when that is wider than half the viewport, else the viewport less a fixed or
2391
+ * sticky sidebar or header bar, with 24 CSS px each side, from 1.25x up to `max_zoom` (1.42x on the B3OS
2392
+ * console); a page with neither has no MAIN and is held on the whole window, where the first element a
2393
+ * step acts on or the narration names is a DETAIL whatever the length of its line (an element with no
2394
+ * enclosing panel framed by its own box), an element that DETAIL shows stays in it, and a page's DETAILs
2395
+ * come at most one per 4 s. DETAIL, one panel or control:
2396
+ * the nearest enclosing element that draws a box of its own (a background, a border, a shadow or
2397
+ * rounded corners) or is a section, article, main, form, table, list, dialog or region, at least 240 x
2398
+ * 120 CSS px or 1.3 times the element on both axes, or the element's own row when that panel is too wide
2399
+ * for 1.4x, at up to `max_zoom`, only when it is narrower than 45% of MAIN's view, its narration line (or
2400
+ * its typing) lasts 2 s or more from the step, it zooms at least 1.1x MAIN's zoom, and its view keeps the
2401
+ * window's bottom edge where it rests or holds the element above the caption band. A page opens on the
2402
+ * whole window, goes to MAIN at its first step or narrated element, may go to a DETAIL (held through its
2403
+ * line) and back, goes from one DETAIL to another only within 40% of the frame's width, and goes wide
2404
+ * again only at a click that loads a new page or at the end; an element outside MAIN across, such as a
2405
+ * sidebar link, is reached wide. MAIN keeps the window's bottom edge where it rests, the caption pill on
2406
+ * the background under it; for a beat whose element lies above that view, or whose label starts less than
2407
+ * 24 CSS px under that view's top edge, its top is the window's top,
2408
+ * the pill over the page, and a page moves between the two at most once, in one 0.4 s vertical move (it
2409
+ * stays top-anchored when its elements would need more). A click that loads a new path starts a new page,
2410
+ * which takes its own position as it first shows: where the camera holds MAIN across the click at one
2411
+ * zoom, it cuts there with the page, with no move. Where page content lies under the captions, no
2412
+ * element the camera frames, no typed text and no resting cursor sits within 120 px (at 1080p) above the
2413
+ * pill's top. A DETAIL's view is placed by its panel, never by the click: centred on it, or from 24 px
2414
+ * left of its left edge when it is wider than the view, with the element and the cursor kept 24 px
2415
+ * inside, and an edge that would cut a neighbouring panel moves to the gap beside it when that is within
2416
+ * 20% of the frame's width. A hover the narration speaks over, and an element a `wait` step waits for (by
2417
+ * `for.selector` or `for.text`) while a line is spoken, are followed too, a wait only when no click,
2418
+ * hover, select or typing follows it in its beat; the first such element of a line is in view from 0.3 s
2419
+ * before the line starts, and so is an element waited for after clicks in its line that all land inside
2420
+ * it, once a scroll before it has landed. A click that opens a beat after the first lands 0.3 s after its
2421
+ * line starts, the cursor setting off in the pause before the line, and an element waited for after it is
2422
+ * that line's element; a `wait` for a heading names its section's first panel. The closing zoom-out starts
2423
+ * at least 1.2 s after the last narrated element is shown. After a click that loads a new page, the first
2424
+ * element waited
2425
+ * for or hovered on it is the new page's subject: the camera zooms in to the new page's MAIN 0.3 s after
2426
+ * the new page first shows, or, still in MAIN on the page the click left at the same zoom, cuts to it as
2427
+ * it first shows, and holds until 0.8 s after its line ends, and the video leaves
2428
+ * room for that; without one, the camera goes wide 0.1 s after the new page first shows. The recorder measures each element's panels and the
2429
+ * page's main content box as its step runs (`observed.subject` in the timeline). `point` frames the click
2430
+ * point, at the zoom that fits the element, and leaves hovers and waits to the cursor, as before. With
2431
+ * `look: 1` the camera frames the point.
2432
+ * @default "subject"
2433
+ */
2434
+ framing?: "subject" | "point";
2435
+ };
2436
+ /**
2437
+ * How the page scrolls to what a step acts on or waits for. `comfortable`: an element outside the middle of
2438
+ * the viewport (8% to 85% of its height) scrolls its panel (see `camera.framing`) to the middle, its top at
2439
+ * 20% when the panel is taller than 40% of the viewport, else centred at 45%, the element kept in that band,
2440
+ * and up to 24 px further so the viewport's edges fall between lines of text: before the cursor sets off
2441
+ * for it (the scroll lasts 300 ms plus 0.6 ms per CSS px, from 0.45 s to 0.9 s, starts and stops gently
2442
+ * with its fastest moment at its middle, and lands 0.3 s before), and as a waited-for element appears. A
2443
+ * 60 fps video captures its page once per output frame while it scrolls (at 30 fps elsewhere), so the page
2444
+ * moves a little every frame. A scroll always runs its whole length: the step and the rest of its beat wait
2445
+ * for it. A scroll that brings in the element a narration line names runs in the pause before the line and
2446
+ * ends by its start (0.3 s before it when there is room); when the pause is shorter than the scroll, the line
2447
+ * and everything after it wait for it, 0.8 s at most. Before the scrolls are planned step by step, a page
2448
+ * whose elements all show in the camera's view at one scroll position scrolls once, to that position, in the
2449
+ * pause before the first line that needs it, and never again. A scroll that serves a later beat runs before
2450
+ * that beat. An element already in
2451
+ * the band never scrolls the page, and while the camera is zoomed, an element whose panel the viewport
2452
+ * shows whole is reached by moving the camera (`framing: "point"`); with the default framing the camera
2453
+ * holds the page's view instead, so the scroll is left out only when that view already shows the panel
2454
+ * whole above the caption. The page never goes up and back down: of two scrolls in
2455
+ * opposite directions within 4 s that move it on by less than 25% of their total, one or both are left out
2456
+ * whenever the steps they serve stay in the viewport without them, or the two become one scroll to a position
2457
+ * that keeps them all in view (a step's element is never left out of the viewport); when neither works, both
2458
+ * run at their whole length, and `result.warnings` and the timeline's `warnings` have `scroll_round_trip`. A
2459
+ * scroll for an element in a sticky box is left out when it can be. A scroll never runs
2460
+ * during a camera move (it ends 0.1 s before one starts, or starts 0.1 s after one lands; a zoom-out waits
2461
+ * for the scroll that brings a waited-for element), a scrolled result stays put 1.2 s, and a narration line
2462
+ * scrolls the page once. Before the closing zoom-out a scrolled page goes back to the top whenever the last
2463
+ * 0.9 s or more before it have no caption and no step, and otherwise as the zoom-out starts. So name a step's
2464
+ * result with a `wait` step
2465
+ * (`for.selector` or `for.text`) and the camera brings it into view. `minimal` scrolls only an
2466
+ * element outside the viewport, to its middle, as before. `off` moves the page only by the script's own
2467
+ * `scroll` steps: a step whose element is outside the viewport fails as one whose element is not found. With
2468
+ * `look: 1` the page scrolls as `minimal`.
2469
+ * @default "comfortable"
2470
+ */
2471
+ scroll?: "comfortable" | "minimal" | "off";
2472
+ /**
2473
+ * How the cursor moves. It shows from the first frame, with no fade-in, parked on the first of six spots
2474
+ * that is plain on the video's first frame and on its frame just before the cursor first moves, as
2475
+ * captured, and clear of text, controls and images on the page just before the first step: right of
2476
+ * and below the middle of the page (62% across, 68% down), near its bottom right (88%, 88%), low in the
2477
+ * middle (50%, 92%), at its right edge (92%, 50%), in its bottom-right corner (96%, 96%) or at the middle
2478
+ * of its bottom edge (50%, 97%); the page gets no pointer event until the cursor's first move has ended, so
2479
+ * nothing on it is hovered from the first frame or on the cursor's way to its first target. Each move settles smoothly, the way Screen Studio's smoothed cursor
2480
+ * does, and lands when it would have; after a click, a select or the first key typed into a field, the
2481
+ * cursor moves just off the element, so it never covers its label or the text being typed while the camera
2482
+ * holds. After a hover, and while typing, it rests where its arrow covers no text, badge or control and
2483
+ * stays at least 8 px inside the page: below and right of the hovered label's own text (of the hovered
2484
+ * point on a target wider than 400 px whose text runs as wide, such as a table row), else right of it,
2485
+ * else another spot that keeps the arrow's tip within 24 px of the label (a table's header cells count as
2486
+ * text); while typing, under the field, beside
2487
+ * it or above it, else another spot within 24 px of it, else inside it past the end of the typed text. A
2488
+ * hover's rest is checked again on the captured page as the cursor sets off for it: where its arrow would
2489
+ * lie on text there, it rests at the first clear spot beside, below or above the element (or on the
2490
+ * element itself), the least busy one when none is clear.
2491
+ * When the page scrolls under the resting cursor, it stands still while the page moves, then, 150 ms
2492
+ * after the scroll ends, moves once off what it landed on, across it (under or above a label, beside a
2493
+ * tall box) up to 64 px, else up to 40 px to the nearest spot clear of what scrolled there; it stays when
2494
+ * that spot is under 24 px away. Still for 2 s, it fades out, and it fades back in before its next move. It never tilts. A restyle keeps the path its video was recorded with; `look: 1`
2495
+ * moves it as before (hidden until it fades in at the middle before its first move).
2496
+ */
2497
+ cursor?: {
2498
+ /**
2499
+ * How long each move takes to settle: the remaining distance falls to about a third of itself every
2500
+ * 100 ms near the end at the default. 0 keeps the eased path without smoothing.
2501
+ * @default 100
2502
+ */
2503
+ smoothing_ms?: number;
2504
+ /**
2505
+ * Still this long, the cursor fades out over 0.4 s, and it fades back in over 0.3 s before its next
2506
+ * move; still to the end of the video, it stays hidden. 0 never hides it; under 500 counts as 500.
2507
+ * @default 2000
2508
+ */
2509
+ hide_after_ms?: number;
2510
+ /**
2511
+ * After a click, a select or the first key typed into a field, move the cursor just below the element
2512
+ * (above it near the bottom of the page) when the next move can wait for it. A hover never moves off.
2513
+ * @default true
2514
+ */
2515
+ move_aside?: boolean;
1344
2516
  };
2517
+ /**
2518
+ * The page's CSS size. Left out, 1440 px wide on a landscape frame and 430 on a portrait one, as tall as the
2519
+ * window's shape; a square or near-square frame (no wider than 4:3) gets about its window's width, so its page
2520
+ * is drawn at least one pixel per CSS pixel at rest.
2521
+ */
1345
2522
  viewport?: Viewport;
1346
2523
  output?: VideoOutput;
1347
2524
  /** @default ["mp4","poster"] */
1348
2525
  formats?: VideoFormat[];
1349
2526
  /** Seeds the page's randomness so a re-render is identical. */
1350
2527
  seed?: number;
1351
- /** The page's `Date` at the start of the video; the clock then advances with the video. */
2528
+ /**
2529
+ * The page's `Date` at the start of the video; the clock then advances with the video. Left out, it is the job's creation time, the same as `created_at`, so the page shows when the video was made. `result.start_time` gives the value used. Send it back in the same request with `recording.reuse` to replay the same recording on the same clock while it is kept; without `recording.reuse` the site is loaded again, so a page that changed shows the change.
2530
+ */
1352
2531
  start_time?: string;
1353
2532
  recording?: RecordingOptions;
2533
+ auto_background?: AutoBackgroundOptions;
1354
2534
  webhook?: WebhookConfig;
1355
2535
  metadata?: Metadata;
1356
2536
  }
1357
2537
 
2538
+ /**
2539
+ * How the default `background: auto` picks its library image, for this request. Each field overrides the
2540
+ * project's, then the organization's, then the node's setting. By default the node keeps one pick per
2541
+ * organization and site (the page's registrable domain, such as `linear.app` for `app.linear.app`; the host for
2542
+ * `localhost` and IP addresses): the vision model's first pick for a site is kept, and later videos and
2543
+ * screenshots of the site draw the same image while it clears their page's edges. A color-rules pick is not
2544
+ * kept, so the site's next video or screenshot asks the model again.
2545
+ */
2546
+ export interface AutoBackgroundOptions {
2547
+ /**
2548
+ * Draw this library image instead of picking one (an image `auto` could pick: in an auto pack, as `GET /v1/render/backgrounds` lists them), on any page. Another value is refused with 422 `invalid_request` at `/auto_background/pin`. A project's, organization's or node's pin is drawn on pages whose edges its image clears; on another page `auto` picks instead and `warnings` names the pin (`auto_background_pin`), and when no image of the set clears that page either, the pin is drawn after all.
2549
+ */
2550
+ pin?: string;
2551
+ /**
2552
+ * Ask the model again for this site and keep its answer in place of the one kept. Where the vision model is off (the node's setting, or `vision: false`), it makes no call and the color rules pick.
2553
+ * @default false
2554
+ */
2555
+ repick?: boolean;
2556
+ /**
2557
+ * `false`: pick with the color rules alone, without the vision model or the site's kept pick. Default: the project's, the organization's or the node's setting (on where the node has the model). `true` does not turn the model on where the node has turned it off.
2558
+ */
2559
+ vision?: boolean;
2560
+ }
2561
+
2562
+ /**
2563
+ * The library image the default `background: auto` drew and how it was chosen. Absent when the style draws another background, or when the image could not be loaded in time (`background_fallback`).
2564
+ */
2565
+ export interface AutoBackgroundChoice {
2566
+ ref: string;
2567
+ /**
2568
+ * `vision`: the vision model chose it among the images that clear the page's edges. `heuristic`: the color rules chose it (vision off or unavailable, an `html` source, the model did not answer in time, or one image clears); it is not kept. `pinned`: `auto_background.pin` named it, or a project, organization or node setting did, where its image clears the page's edges or no image of the set clears them. `stored`: the pick kept for this site.
2569
+ */
2570
+ chosen_by: "vision" | "heuristic" | "pinned" | "stored";
2571
+ /** The site the pick is kept under. Absent for an `html` source. */
2572
+ key?: string;
2573
+ /** The model's one-line reason (`vision`), or why the color rules chose (`heuristic`). */
2574
+ reason?: string;
2575
+ }
2576
+
1358
2577
  /**
1359
2578
  * Where the page's network traffic comes from. By default every video loads the site live and records that
1360
2579
  * load (its capture segments replay the recording, so they all see the same content). With `reuse: true` the
1361
2580
  * video replays the newest recording another video of this project made of the same source URL, steps,
1362
2581
  * viewport, seed and start time within `max_age_s`, instead of loading the site again: faster, and the
1363
- * content is what the site served then. When no such recording exists the site is loaded and recorded as
1364
- * usual. `result.recording` says which happened. Recordings hold the page's responses; they are deleted
1365
- * 24 hours after they were made, or earlier with the last video that used them.
2582
+ * content is what the site served then. Videos without `start_time` match each other, and the replay runs on
2583
+ * the clock the recording was made on, so the page shows that time. A video that sends back such a video's
2584
+ * `result.start_time` replays that recording too. When no such recording exists the site is loaded and
2585
+ * recorded as usual. `result.recording` says which happened. Recordings hold the page's
2586
+ * responses; they are deleted 24 hours after they were made, or earlier with the last video that used them.
1366
2587
  */
1367
2588
  export interface RecordingOptions {
1368
2589
  /** @default false */
@@ -1390,13 +2611,63 @@ export interface VideoRestyleRequest {
1390
2611
  metadata?: Metadata;
1391
2612
  }
1392
2613
 
2614
+ export interface VideoShareRequest {
2615
+ /** The page title and preview title. Default the first beat's `title`, else "Video". */
2616
+ title?: string;
2617
+ }
2618
+
2619
+ export interface VideoShare {
2620
+ object: "video_share";
2621
+ video_id: string;
2622
+ /** The share page's artifact (kind `share`, `share.html`). */
2623
+ artifact_id: string;
2624
+ title: string;
2625
+ /** The share page, a signed `usercontent.b3os.org` URL valid until `expires_at`. */
2626
+ url: string;
2627
+ /** An `<iframe>` of the page, 960 wide at the video's aspect ratio, ready to paste. */
2628
+ embed_html: string;
2629
+ /** The video's width in pixels. */
2630
+ width: number;
2631
+ /** The video's height in pixels. */
2632
+ height: number;
2633
+ created_at: string;
2634
+ /** When the page and its link end (the MP4's own expiry). */
2635
+ expires_at: string;
2636
+ }
2637
+
1393
2638
  export interface VideoResult {
1394
2639
  duration_ms: number;
1395
2640
  width: number;
1396
2641
  height: number;
1397
2642
  fps: number;
2643
+ /**
2644
+ * The page's clock at the start of the video: the request's `start_time`, or the job's `created_at` when it had none (with `recording.reuse`, a replayed recording's own clock). Sent back as `start_time` with `recording.reuse`, the same request replays a recording made on that clock while one is kept, so the content and clock are the same; without `recording.reuse` the site is loaded again. A restyle repeats its source's. Absent on videos made before this field, and on a restyle of one whose `start_time` is not an RFC 3339 date and time.
2645
+ */
2646
+ start_time?: string;
2647
+ /**
2648
+ * The MP4 first (when asked for), then the poster, the caption files, the GIF and, when a beat has a title, the chapters file.
2649
+ */
1398
2650
  artifacts: Artifact[];
1399
2651
  recording?: RecordingInfo;
2652
+ narration?: NarrationInfo;
2653
+ /**
2654
+ * Non-fatal problems, each starting with a code and a colon: `narration_scope` (the beats' `say` lines were not spoken because the key lacks `infer:run`, which narration needs; the video has no narration track); `page_requests` (requests for the page's code, styles or fonts, or for its own site's data, made while the video was captured, were not in the network recording made when it loaded, so they failed and the video can show a page that did not finish loading; up to three are named, without their query; trackers, beacons and prefetches that fail the same way are not counted); `zoom_soft` (the page drew differently between two parts of the capture and the video could not be captured again whole, so from the time it names on the video comes from a lower device scale and its zooms are softer than the page); `background_fallback` (the library image the `auto` background or `background_ref: "auto"` chose could not be loaded in time; the video was drawn on the studio pick, or the style's own background, and a restyle tries again); `scroll_round_trip` (the steps make the page scroll down and back up, or up and back down, within 4 s and no one scroll position shows every element they act on, so the video runs both scrolls; the timeline's `warnings` has the code too); `auto_background_pin` (the project's, organization's or node's `auto_background` pin does not clear the first frame's edges, so `auto` picked another image; it names both). A restyle repeats its source's, except `background_fallback`, which it decides again, and `auto_background_pin`, which it repeats only when it draws the source's image again (a restyle that picks the background again says its own, and one that draws another background says none). Absent when there is nothing to say.
2655
+ */
2656
+ warnings?: string[];
2657
+ auto_background?: AutoBackgroundChoice;
2658
+ }
2659
+
2660
+ /**
2661
+ * Present when the request has `voice` and at least one beat has `say` (a restyle repeats its source's).
2662
+ * `spoken: false` means the narration was not spoken for at least one beat: the key lacks `infer:run`
2663
+ * (`reason` names the scope) or speech synthesis was unavailable. The video still succeeds, has no narration
2664
+ * track, and its word times (step placement, captions) are estimated from the text.
2665
+ */
2666
+ export interface NarrationInfo {
2667
+ /** True when every beat's narration was synthesized and is in the video's audio. */
2668
+ spoken: boolean;
2669
+ /** Why the narration was not spoken (only when `spoken` is false). */
2670
+ reason?: string;
1400
2671
  }
1401
2672
 
1402
2673
  /** A video job (`vid_…`). `progress` counts phases (voice, plan, capture, compose, encode, upload). */
@@ -1406,6 +2677,12 @@ export type Video = Omit<Job, "id" | "object" | "result"> & {
1406
2677
  source: VideoSource;
1407
2678
  /** The source video when this video is a restyle. */
1408
2679
  restyled_from: string | null;
2680
+ /**
2681
+ * Only while `status` is `queued` and the video waits for one of the node's video slots: its place in
2682
+ * the node's queue, `1` for the next video to start. It moves up as videos ahead start or are
2683
+ * canceled, and the field is gone once the video runs.
2684
+ */
2685
+ queue_position?: number;
1409
2686
  result?: VideoResult;
1410
2687
  };
1411
2688
 
@@ -1414,10 +2691,12 @@ export type VideoList = Omit<ListEnvelope, "data"> & {
1414
2691
  };
1415
2692
 
1416
2693
  /**
1417
- * An event of a video's stream. `video.phase` carries `phase`; `video.artifact` carries `artifact` (without a
1418
- * signed URL; fetch the artifact or the video for one).
2694
+ * An event of a video's stream. `job.queued` carries `queue_position` when the video waits for a slot (its
2695
+ * place when it was created; the video itself has the current one); `video.phase` carries `phase`;
2696
+ * `video.artifact` carries `artifact` (without a signed URL; fetch the artifact or the video for one).
1419
2697
  */
1420
2698
  export type VideoEvent = JobEvent & {
2699
+ queue_position?: number;
1421
2700
  phase?: "voice" | "plan" | "capture" | "compose" | "encode" | "upload";
1422
2701
  artifact?: Artifact;
1423
2702
  };
@@ -1442,7 +2721,7 @@ export interface RenderTimeline {
1442
2721
  };
1443
2722
  capture: {
1444
2723
  /**
1445
- * Page capture rate. Capture frame seq is taken at virtual time t(seq) = round(seq * 1e6 / fps) us.
2724
+ * Page capture clock. Capture frame seq is taken at virtual time t(seq) = round(seq * 1e6 / fps) us (with stride, only the seqs it takes).
1446
2725
  * @default 30
1447
2726
  */
1448
2727
  fps: number;
@@ -1463,6 +2742,23 @@ export interface RenderTimeline {
1463
2742
  * @default 1
1464
2743
  */
1465
2744
  segments?: number;
2745
+ /**
2746
+ * Device scale factor of the capture (ARCHITECTURE 5.2, orchestrator decision D1): 1 or 2 for every segment, or auto: segments whose zoom plan goes past about 1.2x are captured at 2, the rest at 1, or, in look v2, at the video's rest scale (its page layer's output pixels per CSS pixel rounded up to a thousandth, 1.159 on the default 1920x1080 canvas), so the whole window is the capture drawn one to one, and a zoom at 2 (a node may capture a zoom at the least of 1.5, 1.75 and 2 that its frames need, never enlarged); a closing shot on the whole window shorter than 2 s right after a zoom is captured with it. segment_dsf records what each segment got.
2747
+ * @default "auto"
2748
+ */
2749
+ dsf?: 1 | 2 | "auto";
2750
+ /**
2751
+ * The device scale factor each segment was captured at (index = segment number), written when the capture is planned; a restyle from the archived capture reads it instead of inferring it from image sizes. 1 or 2, or a scale between them in thousandths: a rest scale (1.159) for the segments of a look v2 video that do not zoom, 1.5 or 1.75 for a look v2 zoom that needs no more where the node captures zooms at a mid scale; timelines written before 2026-11-11 hold only 1 and 2. A page image larger than the page layer by more than 4/3 is box-halved by the compositor before resampling; one up to 3 pixels larger (a rest-scale capture) is cut to the layer and drawn one to one.
2752
+ */
2753
+ segment_dsf?: number[];
2754
+ /**
2755
+ * Look v2 (2026-11-11): outside full_rate, only the capture seqs that are a multiple of stride are taken (captured and drawn); every output frame shows the latest taken seq at or before its time. A video whose page scrolls runs its capture clock (fps) at the output rate with stride 2 (60 over the node's 30), so its scrolls are captured once per output frame and the rest of it at 30 fps as before. Absent: every seq is taken.
2756
+ */
2757
+ stride?: number;
2758
+ /**
2759
+ * Capture seq ranges [from, to) taken at the full fps whatever the stride: each page scroll from one frame before it starts to one after it lands.
2760
+ */
2761
+ full_rate?: number[][];
1466
2762
  };
1467
2763
  /** Composed video. Output frame index i is presented at t = round(i * 1e6 / fps) us. */
1468
2764
  output: {
@@ -1488,10 +2784,29 @@ export interface RenderTimeline {
1488
2784
  captions?: RenderTimelinePresetRef;
1489
2785
  click_effect?: RenderTimelinePresetRef;
1490
2786
  /**
1491
- * Style fields that override the presets, validated by b3os-compose against its Style type (NOTES/render-compose.md 1.1): padding, corner_radius, shadow, border, background_color, background_gradient, aspect_ratio, canvas, fit, frame_title, frame_url, theme, cursor_size, cursor_zoom, click_color, click_duration_ms, caption_size, caption_color, caption_highlight, caption_background, caption_position, motion_blur, matte. Unknown keys and bad values are refused with 422 style_invalid.
2787
+ * Style fields that override the presets, validated by b3os-compose against its Style type (NOTES/render-compose.md 1.1): padding, corner_radius, shadow, border, background_color, background_gradient, background_ref, background_tokens, aspect_ratio, canvas, fit, frame_title, frame_url, theme, cursor_size, cursor_zoom, cursor_press_scale, click_color, click_duration_ms, caption_size, caption_color, caption_highlight, caption_background, caption_position, caption_upcoming, caption_fade_ms, caption_backdrop, window_shape, motion_blur, motion_blur_shutter, motion_blur_onset, motion_blur_peak, matte, text, perspective, perspective_intensity, camera, tilt_x, tilt_y, roll, camera_offset, frame_scale, depth_blur, depth_blur_type, depth_blur_angle, depth_blur_position, depth_blur_band, depth_blur_width, layout (these sixteen for screenshots only), look. Unknown keys and bad values are refused with 422 style_invalid.
1492
2788
  */
1493
2789
  overrides?: Record<string, unknown>;
1494
2790
  };
2791
+ /**
2792
+ * The default look the video was drawn in: version 2 (2026-11-11: a library image behind the page, the bare rounded window with no bar, 22 px corners on 1080p, the layered shadow, the tall window: 8% of the frame's height above and below it and 6.5% of a landscape frame's width at each side). Absent on a timeline from before it, whose restyle without a style draws production's look of then: its style (`{"frame": "browser"}` when it names none), a 64 px margin at 1080p, the captions over the page, the 60% black pill, the studio mesh it drew, 14 px corners and the contact and ambient shadow pair; the cursor is today's, a sharp arrow over a faint trail.
2793
+ */
2794
+ look?: {
2795
+ version: 2;
2796
+ /**
2797
+ * The library image `background: auto` picked from the first frame (also in `style.overrides.background_ref`). A restyle without a style loads it again the way `auto` does: if it cannot be had in time, the studio pick and a `background_fallback` warning, never a failed job.
2798
+ */
2799
+ background_pick?: string;
2800
+ /**
2801
+ * How the first frame chose the image `background: auto` drew: by the vision model among the images that clear the page's edges, by the color rules, pinned by an option, or the pick kept for the site (`key`, the page's registrable domain).
2802
+ */
2803
+ background_choice?: {
2804
+ ref: string;
2805
+ chosen_by: "vision" | "heuristic" | "pinned" | "stored";
2806
+ key?: string;
2807
+ reason?: string;
2808
+ };
2809
+ };
1495
2810
  /**
1496
2811
  * Where the page layer lands in the output frame, computed by b3os-compose from style and output size and recorded for reproducibility.
1497
2812
  */
@@ -1516,7 +2831,7 @@ export interface RenderTimeline {
1516
2831
  */
1517
2832
  actions: RenderTimelineAction[];
1518
2833
  /**
1519
- * Composited cursor (not drawn in the page). Position is linear between consecutive points; pressed and visible keep their last value until a point changes them. Before the first point and after the last, the nearest point applies.
2834
+ * Composited cursor (not drawn in the page). Position is linear between consecutive points; pressed and visible keep their last value until a point changes them. Before the first point and after the last, the nearest point applies. The director hides the cursor until it fades in over 300 ms before its first move, where that move starts.
1520
2835
  */
1521
2836
  cursor?: {
1522
2837
  points: {
@@ -1525,12 +2840,34 @@ export interface RenderTimeline {
1525
2840
  y: number;
1526
2841
  pressed?: boolean;
1527
2842
  visible?: boolean;
2843
+ /**
2844
+ * On a point that changes visible: turning it true, the cursor's opacity rises from 0 to 1 over this long from t_us; turning it false (the idle hide), it falls from 1 to 0 and the cursor is drawn until t_us + fade_us (smoothstep).
2845
+ */
2846
+ fade_us?: RenderTimelineUs;
1528
2847
  }[];
2848
+ /**
2849
+ * The page gets the pointer from this time on: the end of the cursor's first move (look v2; round 4 gave it from that move's start). Before it the recorder sends the page no pointer event, so nothing under the parked cursor, or on its way to its first target, is hovered, and the capture's frame 0 may park the cursor again. A look v2 cursor parks at the first of (62%, 68%), (88%, 88%), (50%, 92%), (92%, 50%), (96%, 96%) and (50%, 97%) of the viewport whose 96 px box (output px) is plain on the capture's frame 0 and that the probe found clear of text, controls and media; the timeline's path is parked there. Absent: the pointer follows the cursor from frame 0, as before.
2850
+ */
2851
+ pointer_from_us?: RenderTimelineUs;
1529
2852
  };
1530
2853
  /**
1531
- * Camera keyframes. For t between keyframes k-1 and k: u = (t - t[k-1]) / (t[k] - t[k-1]), e = easing[k](u), zoom = zoom[k-1] * (zoom[k] / zoom[k-1])^e, center = center[k-1] + (center[k] - center[k-1]) * e. Before the first keyframe and after the last, the nearest keyframe holds. The camera rect is width = viewport.width / zoom, height = viewport.height / zoom, x = clamp(center.x - width / 2, 0, viewport.width - width), y likewise. Absent: zoom 1 centered.
2854
+ * Camera keyframes. For t between keyframes k-1 and k: u = (t - t[k-1]) / (t[k] - t[k-1]), e = easing[k](u), zoom = zoom[k-1] * (zoom[k] / zoom[k-1])^e, center = center[k-1] + (center[k] - center[k-1]) * e. Before the first keyframe and after the last, the nearest keyframe holds. Page space (space absent or page): the camera rect is width = viewport.width / zoom, height = viewport.height / zoom, x = clamp(center.x - width / 2, 0, viewport.width - width), y likewise; the page is cropped and scaled inside a fixed window. Canvas space: the camera moves over the whole composition (output px, canvas W x H = output size, page rect P = layout.page, s = P.size / viewport). center is the zoom's focus, the point that keeps its place on the frame: F = P.xy + center * s on the canvas; the card's view (frame_state view.card) is width = W / zoom, height = H / zoom, x = clamp(F.x * (1 - 1 / zoom), 0, W - width), y likewise, and every card layer (window, shadow, page, border, cursor, click effects) shows it scaled to the frame; zoom keeps its meaning (output px per CSS px = s * zoom). The background's view has zoom zb = 1 + p * (zoom - 1) (p = background_motion) about (W / 2 + p * (cx - W / 2), H / 2 + p * (cy - H / 2)), (cx, cy) the card view's center, clamped likewise, and blurs by a Gaussian of sigma = min(7 / 0.6 * (zoom - 1), 16) * min(W, H) / 1080 output px when background_blur is on (drawn at the nearest whole multiple of min(W, H) / 1080 px; frame_state view.blur gives sigma unrounded). Captions stay fixed on the frame. Absent: zoom 1 centered.
1532
2855
  */
1533
2856
  camera?: {
2857
+ /**
2858
+ * What the keyframes move: the page inside a fixed window (page; every timeline from before look v2), or the whole composition (canvas).
2859
+ * @default "page"
2860
+ */
2861
+ space?: "page" | "canvas";
2862
+ /**
2863
+ * Canvas space: how far the background follows the card, 0 (still) to 1 (zooms with it: the whole composition zooms as one).
2864
+ * @default 0.1
2865
+ */
2866
+ background_motion?: number;
2867
+ /**
2868
+ * Canvas space: whether the background blurs as the card zooms in, as the request's camera.background_blur set it. Absent, the request left it out, and the background the video draws decides: on for an image, the default look's library images among them, off for gradients, solid colors and patterns. A restyle decides again for the background it draws.
2869
+ */
2870
+ background_blur?: boolean;
1534
2871
  keyframes: {
1535
2872
  t_us: RenderTimelineUs;
1536
2873
  center: RenderTimelinePoint;
@@ -1551,13 +2888,37 @@ export interface RenderTimeline {
1551
2888
  /** @default 20 */
1552
2889
  max_chars_per_second?: number;
1553
2890
  cues: RenderTimelineCue[];
2891
+ /**
2892
+ * Look v2 round 4f: the karaoke word's color the frames drew and where it came from, so a restyle and a re-export repeat it. Written by the node for karaoke captions in the new look; absent on a timeline from before, with look 1 and without karaoke.
2893
+ */
2894
+ highlight?: {
2895
+ /** The word's color, #rrggbb. */
2896
+ color: string;
2897
+ /**
2898
+ * auto: from the background's pixels (an image outside the presets, a gradient; a flat or grey one gives #9cb0ff), fitted to the caption. preset: a preset background's own accent, fitted. request: the request's caption_highlight or its captions preset's own color.
2899
+ */
2900
+ source: "auto" | "preset" | "request";
2901
+ };
2902
+ /**
2903
+ * Look v2: when the caption backdrop's band (the blur under the pill where page content lies under the captions) holds, as runs it is drawn at full strength in; it fades in over 200 ms before each run and out over 200 ms after it, and only the pill fades between the cues of a run. The node decides the runs from the final cues, pages and camera: two cues share a run when their gap is 1.0 s or less, no new page paints in it and page content lies under the band at both of its ends (abutting cues always do). Written by the node and decided again by a restyle; absent (a timeline from before, look 1, no burned-in captions): the band fades with the pill.
2904
+ */
2905
+ backdrop?: {
2906
+ /** The run's first cue's start. */
2907
+ start_us: number;
2908
+ /** The run's last cue's end. */
2909
+ end_us: number;
2910
+ }[];
1554
2911
  };
1555
2912
  /**
1556
2913
  * Per capture frame: the viewport region to capture. Sent to the recorder for each segment. Frames not listed are not captured.
1557
2914
  */
1558
2915
  capture_plan?: RenderTimelineCaptureFrame[];
1559
- /** Optional FrameState dump (debugging, tests, GET .../timeline?frames=1). */
2916
+ /** Optional FrameState dump (debugging, tests, GET .../timeline?frames=true). */
1560
2917
  frames?: RenderTimelineFrameState[];
2918
+ /**
2919
+ * What the planner rendered as the script asked although the look would do it otherwise, as codes (look v2). `scroll_round_trip`: the script's own steps scroll the page one way and back within 4 s and no one position shows them all, so both scrolls run. Absent when there are none.
2920
+ */
2921
+ warnings?: string[];
1561
2922
  }
1562
2923
 
1563
2924
  /** Microseconds on the virtual timeline. */
@@ -1630,38 +2991,110 @@ export interface RenderTimelineObservation {
1630
2991
  scroll?: RenderTimelinePoint;
1631
2992
  /** Virtual time at which a navigate or wait finished. */
1632
2993
  settled_us?: RenderTimelineUs;
1633
- error?: {
1634
- code: string;
1635
- detail?: string;
1636
- };
1637
- }
1638
-
1639
- export type RenderTimelineModifiers = Array<"Alt" | "Control" | "Meta" | "Shift">;
1640
-
1641
- export type RenderTimelineAction = {
1642
- id: RenderTimelineLocalId;
1643
- kind: "navigate" | "click" | "hover" | "type" | "key" | "scroll" | "select" | "wait";
1644
- /** When the action starts. */
1645
- at_us: RenderTimelineUs;
1646
- beat?: RenderTimelineLocalId;
1647
- target?: RenderTimelineTarget;
1648
- url?: string;
1649
- /** @default "load" */
1650
- wait_until?: "load" | "domcontentloaded" | "networkidle";
1651
- /** @default "left" */
1652
- button?: "left" | "right" | "middle";
1653
- /** @default 1 */
1654
- count?: number;
1655
2994
  /**
1656
- * click: time between mouse down and mouse up.
1657
- * @default 60000
2995
+ * The target sits inside nav, aside or a header bar (or their landmark roles); the camera zooms less there (1.25x).
1658
2996
  */
1659
- press_us?: number;
1660
- modifiers?: RenderTimelineModifiers;
1661
- text?: string;
2997
+ landmark?: "nav" | "aside" | "header";
1662
2998
  /**
1663
- * type: delay between characters; character i (a Unicode scalar value) is inserted at at_us + i * interval_us.
1664
- * @default 80000
2999
+ * Look v2 round 4e: the least height (CSS px) the document had in the probe from the step before this one up to this one. The planner gives a page no offset a later step's page could not keep (a list that empties while a filter loads shortens the page and the browser scrolls it back).
3000
+ */
3001
+ doc_min?: number;
3002
+ /**
3003
+ * Look v2 round 4f: after the step, the rows where the page draws ink as [top, bottom, left, right] in page CSS px (text lines, media, fields, buttons, fills and borders that stand off the page's background; columns apart; a sticky element where it stood when the probe read it). The planner puts the top edge of a held view in a gap between them, so no line is cut by the frame's edge.
3004
+ */
3005
+ ink?: number[][];
3006
+ /** Look v2 round 4f: the same rows for what fixed elements draw, in viewport CSS px. */
3007
+ ink_fixed?: number[][];
3008
+ /**
3009
+ * Page time the action ran the page clock ahead of the timeline, off camera: a client-side route its click opened drawing (its code, its data, a Suspense delay), or a wait whose condition held after a timer. Capture passes run exactly as far ahead. Absent when 0.
3010
+ */
3011
+ ahead_us?: RenderTimelineUs;
3012
+ /**
3013
+ * Look v2 round 4 (a new video's camera.framing and scroll): what the camera frames the target by, measured in the page in the same evaluate as the target when the action ran, in CSS px in page coordinates (the viewport position plus scroll), so a restyle can frame it again. For a wait: its element (the one for.selector matches, or the first visible element showing for.text), whose viewport box is then also rect and point.
3014
+ */
3015
+ subject?: {
3016
+ /** The document's scroll offset when the boxes were measured. */
3017
+ scroll: RenderTimelinePoint;
3018
+ /**
3019
+ * The scroll offset before the recorder scrolled the page to the target (scroll: comfortable); absent when it did not.
3020
+ */
3021
+ from?: RenderTimelinePoint;
3022
+ target: RenderTimelineRect;
3023
+ /** The target's ancestors with a box, nearest first, up to the body (left out). */
3024
+ ancestors?: {
3025
+ rect: RenderTimelineRect;
3026
+ tag?: string;
3027
+ role?: string;
3028
+ /** It draws a box of its own: a background, a border, a shadow or rounded corners. */
3029
+ panel?: boolean;
3030
+ /**
3031
+ * A sectioning or grouping element or role: table, form, section, article, main, dialog, fieldset, figure, a list, a region, group, tab panel or grid.
3032
+ */
3033
+ group?: boolean;
3034
+ /** A row or list item: tr, li, row, listitem, option, treeitem. */
3035
+ row?: boolean;
3036
+ }[];
3037
+ /**
3038
+ * The index in ancestors of the target's subject as the recorder chose it: the nearest panel or group that holds the target and is at least 240 x 120 CSS px or 1.3 times the target on both axes. The camera chooses again by the same rule.
3039
+ */
3040
+ panel?: number;
3041
+ /**
3042
+ * The boxes of that subject's siblings: a held view's edge never rests inside one when a gap beside it is near.
3043
+ */
3044
+ siblings?: RenderTimelineRect[];
3045
+ /**
3046
+ * Look v2 round 4b: the rows in the viewport (lines of text and table rows). No longer written or read since round 4c, when the camera's three compositions and the blur band under the caption pill replaced the shift that kept the pill's edges off them; accepted on a timeline from before.
3047
+ */
3048
+ rows?: RenderTimelineRect[];
3049
+ /**
3050
+ * Look v2 round 4c: the page's main content box, which the camera's MAIN view frames with 24 CSS px each side across the frame: the content box (padding and border left out) of the main or [role=main] element when that is wider than half the viewport, else the viewport less the fixed or sticky elements that span a full edge of it (a sidebar, a header bar), 24 px in from them. Absent on a page with neither: its MAIN is the whole window. The camera reads the first one measured on each page.
3051
+ */
3052
+ main?: RenderTimelineRect;
3053
+ /**
3054
+ * Look v2 round 4c: the target or one of its ancestors is position: sticky; the page does not scroll for it when what the scroll served stays in the viewport without it.
3055
+ */
3056
+ sticky?: boolean;
3057
+ };
3058
+ /**
3059
+ * Where the cursor's tip can rest after a hover or a type, viewport space at at_us (look v2, round 4): its arrow's box at least 8 px inside the viewport and over no text, badge, control or media, as the probe found it with elementFromPoint: below and right of the hovered label's own text (of the hovered point on a target wider than 400 px whose text runs as wide or that has none), right of it plus 16 px, or (round 4b) another spot within 24 px of it (round 4c: with the arrow's tip within 24 px, so never above it, where round 4's spot put the tip an arrow's height over the label; a table's header cells count as text); for a field typed into, under it, beside it, above it, another spot within 24 px of it, or inside it 12 px from its right end when the typed text ends at least 24 px before the arrow. A type without a target is probed on the focused field, and the click into that field carries the type's rest. Absent when no spot was clear, or the probe was not asked.
3060
+ */
3061
+ rest?: RenderTimelinePoint;
3062
+ /**
3063
+ * Look v2 round 4b: after the probe's framing scrolled the page for this action, the boxes (viewport space after the scroll) of the text lines, badges, controls, fields and media near where the cursor rests after the last pointer action. The resting cursor stands still while the scroll plays, then (round 4c) moves once, 150 ms after it ends, up to 40 px to a spot clear of them; it stays when that spot is under 24 px away. Absent when the page did not scroll for the action, nothing was near, or the probe was not asked.
3064
+ */
3065
+ busy?: RenderTimelineRect[];
3066
+ error?: {
3067
+ code: string;
3068
+ detail?: string;
3069
+ };
3070
+ }
3071
+
3072
+ export type RenderTimelineModifiers = Array<"Alt" | "Control" | "Meta" | "Shift">;
3073
+
3074
+ export type RenderTimelineAction = {
3075
+ id: RenderTimelineLocalId;
3076
+ kind: "navigate" | "click" | "hover" | "type" | "key" | "scroll" | "select" | "wait";
3077
+ /** When the action starts. */
3078
+ at_us: RenderTimelineUs;
3079
+ beat?: RenderTimelineLocalId;
3080
+ target?: RenderTimelineTarget;
3081
+ url?: string;
3082
+ /** @default "load" */
3083
+ wait_until?: "load" | "domcontentloaded" | "networkidle";
3084
+ /** @default "left" */
3085
+ button?: "left" | "right" | "middle";
3086
+ /** @default 1 */
3087
+ count?: number;
3088
+ /**
3089
+ * click: time between mouse down and mouse up.
3090
+ * @default 60000
3091
+ */
3092
+ press_us?: number;
3093
+ modifiers?: RenderTimelineModifiers;
3094
+ text?: string;
3095
+ /**
3096
+ * type: delay between characters; character i (a Unicode scalar value) is inserted at at_us + i * interval_us.
3097
+ * @default 80000
1665
3098
  */
1666
3099
  interval_us?: number;
1667
3100
  /** KeyboardEvent.key, e.g. Enter, Tab, a. */
@@ -1671,8 +3104,7 @@ export type RenderTimelineAction = {
1671
3104
  /** scroll: delta from the current offset. */
1672
3105
  by?: RenderTimelinePoint;
1673
3106
  /**
1674
- * scroll: animation length on the virtual clock.
1675
- * @default 600000
3107
+ * scroll: animation length on the virtual clock, at most 10 s, 600000 (0.6 s) when absent. type: how long the typing runs, its characters times interval_us, at most the video's length (the director writes it; the recorder times each key from interval_us, and a type without it lasts that long all the same).
1676
3108
  */
1677
3109
  duration_us?: number;
1678
3110
  easing?: RenderTimelineEasing;
@@ -1747,6 +3179,10 @@ export interface RenderTimelineCue {
1747
3179
  byte_start: number;
1748
3180
  byte_end: number;
1749
3181
  }[];
3182
+ /**
3183
+ * Where this cue is drawn when it is not where the caption style puts it: the director moves a cue off the target a step clicks while it shows.
3184
+ */
3185
+ position?: "top" | "bottom";
1750
3186
  }
1751
3187
 
1752
3188
  /**
@@ -1779,6 +3215,16 @@ export interface RenderTimelineFrameState {
1779
3215
  y: number;
1780
3216
  visible: boolean;
1781
3217
  pressed: boolean;
3218
+ /**
3219
+ * Below 1 while the cursor fades in or out (a point's fade_us).
3220
+ * @default 1
3221
+ */
3222
+ opacity?: number;
3223
+ /**
3224
+ * How far the last press has shrunk the cursor: from the press it rises to 1 over 70 ms (a critically damped spring from rest), and from the release it falls back to 0 over 220 ms. The style's cursor_press_scale is the cursor's size at 1.
3225
+ * @default 0
3226
+ */
3227
+ press?: number;
1782
3228
  };
1783
3229
  effects: {
1784
3230
  kind: "click";
@@ -1790,10 +3236,39 @@ export interface RenderTimelineFrameState {
1790
3236
  caption: null | {
1791
3237
  cue: RenderTimelineLocalId;
1792
3238
  lines: string[];
3239
+ /**
3240
+ * Karaoke: the word being spoken, the last whose start is at or before t_us (look v2: at or before t_us plus half of caption_fade_ms, so its fade is centred on the word's start). The style draws the words before it in the caption color, it in caption_highlight and the words after it at caption_upcoming of the caption color; over caption_fade_ms from its start it lights from that shade while the previous word settles from caption_highlight to the caption color (ease-out cubic).
3241
+ */
1793
3242
  highlight?: {
1794
3243
  line: number;
1795
3244
  byte_start: number;
1796
3245
  byte_end: number;
3246
+ /** How long ago the word started, at most 1 s. Absent: lit in full. */
3247
+ since_us?: number;
3248
+ /** The word before it in the cue. */
3249
+ previous?: {
3250
+ line: number;
3251
+ byte_start: number;
3252
+ byte_end: number;
3253
+ };
3254
+ };
3255
+ /** The cue's own position, over the caption style's. */
3256
+ position?: "top" | "bottom";
3257
+ /**
3258
+ * Look v2: below 1 while the caption fades in over the 150 ms before its cue starts (as much of them as the cue before leaves) or out over its last 150 ms (a cue that abuts the one before or after it does not fade on that side).
3259
+ * @default 1
3260
+ */
3261
+ opacity?: number;
3262
+ /**
3263
+ * Look v2: the cue before it, which this one abuts, while the text crossfades from it (120 ms) and the box resizes from its size (200 ms), both ease-out cubic from the boundary.
3264
+ */
3265
+ from?: {
3266
+ lines: string[];
3267
+ position?: "top" | "bottom";
3268
+ /** How far the text has crossfaded to this cue. */
3269
+ text: number;
3270
+ /** How far the box has moved from the old cue's size to this one's. */
3271
+ size: number;
1797
3272
  };
1798
3273
  };
1799
3274
  /**
@@ -1810,6 +3285,60 @@ export interface RenderTimelineFrameState {
1810
3285
  cursor_dx?: number;
1811
3286
  cursor_dy?: number;
1812
3287
  };
3288
+ /**
3289
+ * Canvas-space camera only: what the frame shows of the composition, in canvas px (output px at zoom 1). camera is then the part of the viewport in view (view.card cut to layout.page), the whole viewport at zoom 1. A view of the whole canvas composes as a frame without a camera.
3290
+ */
3291
+ view?: {
3292
+ /**
3293
+ * The card's view: the window, its shadow, the page, the cursor and click effects show this rect scaled to the frame.
3294
+ */
3295
+ card: RenderTimelineRect;
3296
+ /** The background's own view. Absent: the background moves with the card, unblurred. */
3297
+ background?: RenderTimelineRect;
3298
+ /**
3299
+ * The background's Gaussian blur, sigma in output px.
3300
+ * @default 0
3301
+ */
3302
+ blur?: number;
3303
+ };
3304
+ /**
3305
+ * Where the camera and the cursor are when the frame's shutter opens and closes, half an output frame before and after t_us ([open, close]); present when either moves over it. With the style's motion_blur, a zoomed canvas frame whose card moves faster than motion_blur_onset and than motion_blur_peak of move_reach is the average of the composition over motion_blur_shutter of it, shortened by that onset (the card, its background at its own views), and the cursor is smeared along its own motion over motion_blur_shutter and along the camera's by the card's share.
3306
+ */
3307
+ shutter?: {
3308
+ /** Canvas space: view.card at open and close, when the camera moves. */
3309
+ card?: RenderTimelineRect[];
3310
+ /** Canvas space: view.background at open and close, when the frame has one. */
3311
+ background?: RenderTimelineRect[];
3312
+ /** The cursor's position (viewport px) at open and close. */
3313
+ cursor: RenderTimelinePoint[];
3314
+ /**
3315
+ * How long the shutter is open (µs): a whole output frame. The style's motion_blur_onset is a speed, so the compositor needs it; 0 or absent (a frame state written before it) counts as a 60 fps frame.
3316
+ */
3317
+ length_us?: number;
3318
+ /**
3319
+ * Output px: the most the card's far corner moves over such a shutter at any frame of the camera move (keyframe segment) this frame is in. The style's motion_blur_peak keeps frames under that share of it sharp; 0 or absent: no such floor.
3320
+ */
3321
+ move_reach?: number;
3322
+ };
3323
+ /**
3324
+ * Look v2: the caption backdrop's band on this frame, from captions.backdrop: its own opacity (the pill's fades do not fade it) and, when it is not the caption's, the cue whose caption box it lies under. Absent: no band, or, from a timeline without captions.backdrop, the band at the caption's own opacity.
3325
+ */
3326
+ backdrop?: {
3327
+ /** How much of the band shows (smoothstep over its 200 ms fades). */
3328
+ opacity: number;
3329
+ /**
3330
+ * The cue the band's box comes from: while no caption is drawn (a gap its run holds across, the fade after its last cue or before its first), or the cue before a held gap while the band's box moves from its box to the caption's.
3331
+ */
3332
+ under?: {
3333
+ lines: string[];
3334
+ position?: "top" | "bottom";
3335
+ /**
3336
+ * With a caption drawn: how far the band's box has moved from this cue's box to the caption's (0 to 1, ease-out cubic over 200 ms from when the caption starts to show).
3337
+ * @default 0
3338
+ */
3339
+ size?: number;
3340
+ };
3341
+ };
1813
3342
  }
1814
3343
 
1815
3344
  export interface Preset {
@@ -1828,6 +3357,124 @@ export type PresetList = Omit<ListEnvelope, "data"> & {
1828
3357
  data: Preset[];
1829
3358
  };
1830
3359
 
3360
+ /** A library background. Name it in a style with `overrides.background_ref` (as `style` shows). */
3361
+ export interface RenderBackground {
3362
+ /** `<pack>/<slug>`, the value of `overrides.background_ref`. */
3363
+ ref: string;
3364
+ object: "render.background";
3365
+ /**
3366
+ * `css`: drawn by the compositor from gradient layers. `procedural`: one of our own studio meshes (pack `studio`), computed in float, dithered, with 1% grain on stills; the set the studio pick chooses from (`background: "studio"`) carries the tag `auto`. `image`: a stored WebP (see `image`).
3367
+ */
3368
+ kind: "css" | "procedural" | "image";
3369
+ pack: string;
3370
+ slug: string;
3371
+ name: string;
3372
+ description?: string;
3373
+ theme: "light" | "dark";
3374
+ tags: string[];
3375
+ /** The main colors, as the source lists them (images, the five most common, most common first). */
3376
+ palette: string[];
3377
+ /**
3378
+ * Color tokens and their defaults; `overrides.background_tokens` sets new colors for them. Empty for images.
3379
+ */
3380
+ tokens: Record<string, string>;
3381
+ /**
3382
+ * `MIT`, `own` (B3OS's own work) or a written grant recorded in B3OS's decisions, such as `grant: Sean, decision T9 (2026-11-02)`.
3383
+ */
3384
+ license: string;
3385
+ /**
3386
+ * Where the background comes from. `name` says it in text; `url`, `path` and `commit` are there only for a
3387
+ * public upstream (Pattern Craft's repository). Sean Geng's own projects (littledemo, ScreenFramed) are
3388
+ * named, never linked. `id` is the entry's id at the source.
3389
+ */
3390
+ source: {
3391
+ name: string;
3392
+ url?: string;
3393
+ path?: string;
3394
+ commit?: string;
3395
+ id?: string;
3396
+ };
3397
+ /**
3398
+ * A 360x200 WebP on B3OS's own host: drawn by the compositor for CSS backgrounds
3399
+ * (`https://beta.b3os.org/assets/presets/library/`), a cover crop of the stored file for images
3400
+ * (`https://beta.b3os.org/gallery/_library/thumbs/`).
3401
+ */
3402
+ thumbnail_url: string;
3403
+ image?: RenderBackgroundImage;
3404
+ /** The `style` value that draws this background. */
3405
+ style: {
3406
+ overrides: {
3407
+ background_ref: string;
3408
+ };
3409
+ };
3410
+ }
3411
+
3412
+ /**
3413
+ * An image background's file and measured tone (CSS backgrounds have none). Tone is measured on a 16:9 cover
3414
+ * crop, over the matte for transparent shapes: `luminance` is the mean WCAG relative luminance, `hue` and
3415
+ * `chroma` OKLCH (no `hue` for grey or many-hued images), `detail` the mean Sobel edge strength (0 to 1; quiet
3416
+ * gradients are about 0.015, busy textures above 0.07).
3417
+ */
3418
+ export interface RenderBackgroundImage {
3419
+ /** The lossless WebP on B3OS's own host, named by its sha256 (cached as immutable). */
3420
+ url: string;
3421
+ width: number;
3422
+ height: number;
3423
+ bytes: number;
3424
+ sha256: string;
3425
+ group: "backgrounds" | "gradients";
3426
+ coverage: "full-bleed" | "partial" | "cutout" | "sliver";
3427
+ /** Mean color of the crop, `#rrggbb`. */
3428
+ mean: string;
3429
+ luminance: number;
3430
+ /** Absent for grey or many-hued images. */
3431
+ hue?: number;
3432
+ chroma: number;
3433
+ detail: number;
3434
+ /** Whether `background_ref: "auto"` may pick it. */
3435
+ auto: boolean;
3436
+ /** One of the hand-picked images, with its label, collection and place in the picked order. */
3437
+ featured?: {
3438
+ label: string;
3439
+ collection: string;
3440
+ rank: number;
3441
+ };
3442
+ }
3443
+
3444
+ export type RenderBackgroundList = Omit<ListEnvelope, "data"> & {
3445
+ data: RenderBackground[];
3446
+ };
3447
+
3448
+ export interface RenderBackgroundPack {
3449
+ pack: string;
3450
+ object: "render.background_pack";
3451
+ name: string;
3452
+ kind: "css" | "procedural" | "image";
3453
+ count: number;
3454
+ themes: Array<"light" | "dark">;
3455
+ license: string;
3456
+ /** The attribution the license asks for. */
3457
+ notice?: string;
3458
+ /**
3459
+ * The upstream's public URL, or text naming the source when it has none (Sean Geng's own projects are named, never linked).
3460
+ */
3461
+ source: string;
3462
+ cover_thumbnail_url: string;
3463
+ /** Image packs, the `ref` the cover shows. */
3464
+ cover?: string;
3465
+ /** Image packs, ScreenFramed's group. */
3466
+ group?: "backgrounds" | "gradients";
3467
+ /** Image packs, how the pack reads behind a screenshot (a hand review). */
3468
+ look?: "quiet" | "bold" | "soft-photo" | "texture" | "scenic" | "loud" | "cutout";
3469
+ /** Image packs, whether `background_ref: "auto"` may pick from it. */
3470
+ auto?: boolean;
3471
+ note?: string;
3472
+ }
3473
+
3474
+ export type RenderBackgroundPackList = Omit<ListEnvelope, "data"> & {
3475
+ data: RenderBackgroundPack[];
3476
+ };
3477
+
1831
3478
  /**
1832
3479
  * `running` → `paused` ↔ `running` → `stopped`. `failed` means the microVM crashed; its usage is final.
1833
3480
  */
@@ -1856,6 +3503,14 @@ export interface SandboxPort {
1856
3503
  * @default false
1857
3504
  */
1858
3505
  public?: boolean;
3506
+ /**
3507
+ * How long a request through the port's preview waits for the app to start its response (status and
3508
+ * headers), counted from when the node lets the request in. Past it the request answers `504
3509
+ * upstream_first_byte_timeout`. A response that has started may stream for up to an hour. At most 95: the
3510
+ * path in front of the node gives up on a response that has not started after 100 seconds.
3511
+ * @default 65
3512
+ */
3513
+ first_byte_s?: number;
1859
3514
  }
1860
3515
 
1861
3516
  /**
@@ -1880,7 +3535,10 @@ export interface SandboxApiGrant {
1880
3535
  /**
1881
3536
  * Where sandbox traffic may go, enforced by the node's egress guard. `public` (default): any public internet
1882
3537
  * address. `allowlist`: only hosts matching `allow` (exact hosts or `*.` wildcards). `deny`: no outbound
1883
- * network at all. Private, loopback, tailnet and metadata addresses are always refused. A sandbox has at most
3538
+ * network at all. Private, loopback, tailnet and metadata addresses are always refused. Without `egress`, a
3539
+ * sandbox created by code in another sandbox gets that sandbox's policy, and a policy within it is the most
3540
+ * such code can ask for (`403 forbidden`, `reason: egress_escalation`), and it gets no public port unless that
3541
+ * sandbox's egress is `public`. A sandbox has at most
1884
3542
  * 512 outbound connections open and 64 DNS queries in flight at once; past that, new connections are refused
1885
3543
  * (`egress_unavailable`) and queries answered `SERVFAIL`. When the sandbox stops, its outbound connections
1886
3544
  * and its connections to `http://127.0.0.1:7700` close at once.
@@ -1900,11 +3558,20 @@ export interface SandboxCreateRequest {
1900
3558
  /** Restore this snapshot instead of starting from a template. */
1901
3559
  snapshot?: string;
1902
3560
  /**
1903
- * Virtual CPUs (plan maximum in `GET /v1/limits`).
1904
- * @default 1
3561
+ * Virtual CPUs; defaults to the template's (`defaults.vcpu`), at most your plan's `sandboxes.vcpu_max`.
3562
+ * A microVM cannot change its vCPU count, so sandboxes come from pools per size: a create at one of the
3563
+ * template's `size_classes` claims a pre-warmed microVM, any other size is restored on demand (a pool
3564
+ * miss: tens of milliseconds, plus about two seconds the first time a node sees that size). A node
3565
+ * builds at most 4 new off-class sizes per organization and hour; past that, a create at a size the node
3566
+ * has not built yet is refused with `429 rate_limited` (`limit.id` `sandboxes.offclass_builds`,
3567
+ * `Retry-After`), while sizes it has built and the size classes are not.
1905
3568
  */
1906
3569
  vcpu?: number;
1907
- /** @default 512 */
3570
+ /**
3571
+ * Memory; defaults to the template's (`defaults.memory_mib`), at most your plan's `sandboxes.memory_max`.
3572
+ * Rounded up to 128 MiB or a multiple of 256 MiB (the sandbox's `memory_mib` says what it got, and
3573
+ * memory is billed at that size). See `vcpu` for size classes.
3574
+ */
1908
3575
  memory_mib?: number;
1909
3576
  /** Disk size; defaults to the template's. */
1910
3577
  disk_gib?: number;
@@ -1920,7 +3587,14 @@ export interface SandboxCreateRequest {
1920
3587
  on_idle?: "stop" | "pause";
1921
3588
  /** Environment variables. Returned as given; put credentials in `secrets`. */
1922
3589
  env?: Record<string, string>;
1923
- /** Environment variables whose values are never returned or logged. */
3590
+ /**
3591
+ * Environment variables whose values are never returned by the API and never logged (the sandbox object
3592
+ * lists only their names in `secret_names`). They are not hidden from the sandbox itself: every process
3593
+ * in it gets them in its environment, so any code you run there can read them, and so can anything that
3594
+ * code sends them to. Give a sandbox only secrets the code you run in it may hold. (Injecting a
3595
+ * credential at the node's egress proxy, so that the value never enters the sandbox, is planned, not
3596
+ * available.)
3597
+ */
1924
3598
  secrets?: Record<string, SecretValue>;
1925
3599
  ports?: SandboxPort[];
1926
3600
  api?: SandboxApiGrant;
@@ -1930,9 +3604,89 @@ export interface SandboxCreateRequest {
1930
3604
  * @default false
1931
3605
  */
1932
3606
  forkable?: boolean;
3607
+ readiness?: ReadinessProbe;
3608
+ /**
3609
+ * Read only when `snapshot` is set; a create from a template ignores it and resets the template's Chrome
3610
+ * only where the node's image of that template has the reset. What happens to the random state of processes
3611
+ * that were running when the snapshot was taken, at the start of this sandbox (the option
3612
+ * `sandboxes.clone_reset`). A restored sandbox gets a fresh identity
3613
+ * and the kernel's random pool is reseeded, but a process running at the snapshot keeps its own
3614
+ * generators' state, which every sandbox started from that snapshot shares with the others and with the
3615
+ * source. The `browser` template's Chrome is the process this covers:
3616
+ * - `full`: its renderers and network service are replaced at the start, so `Math.random`,
3617
+ * `crypto.getRandomValues` and WebSocket keys are fresh. The tabs that were open at the snapshot are
3618
+ * closed and their connections dropped; the sandbox's Chrome has one new `about:blank` page.
3619
+ * - `none`: Chrome runs on as the snapshot had it, tabs and page state kept, its generators shared with the
3620
+ * source.
3621
+ *
3622
+ * Other processes running at the snapshot (a browser you started yourself, an interpreter) keep their
3623
+ * state either way; reseed or restart them. The code-interpreter kernel is reseeded on every start.
3624
+ * Default: the node's (`full` on the beta node). A value the node does not allow is refused with `422
3625
+ * option_not_allowed`. The reset runs in the snapshot's guest agent, and `full` is reported only when the
3626
+ * agent says it replaced Chrome: when this node's image of the template or the snapshot's agent predates
3627
+ * the option, `full` is refused with `409 guest_outdated` before the sandbox starts, and a start at which
3628
+ * the agent replaced none of Chrome's processes fails with `500 internal` and leaves no sandbox (retry, or
3629
+ * ask for `none`). The sandbox's `options` reports the value and where it came from, as does the
3630
+ * `X-B3OS-Options` header.
3631
+ */
3632
+ clone_reset?: "full" | "none";
1933
3633
  metadata?: Metadata;
1934
3634
  }
1935
3635
 
3636
+ /**
3637
+ * When the sandbox counts as ready: a TCP port inside it accepting connections (`port`), or a command that
3638
+ * exits 0 (`cmd`, run as `user` with a 5 s limit per try). Set exactly one. The node tries it every
3639
+ * `interval_ms` from the moment it is set until it passes or `timeout_s` runs out; the sandbox's `readiness`
3640
+ * reports the result and `POST /v1/sandboxes/{sandbox_id}/ready` waits for it. Probing goes on across a
3641
+ * restart of the node's daemon, within the same `timeout_s`; `attempts` counts the tries since the daemon
3642
+ * last recorded a change of `status`, so it can start again from a lower number after such a restart.
3643
+ */
3644
+ export interface ReadinessProbe {
3645
+ port?: number;
3646
+ /** A shell command line (run with `/bin/sh -c`) or an argv array. */
3647
+ cmd?: string | string[];
3648
+ /** @default 10 */
3649
+ interval_ms?: number;
3650
+ /** @default 60 */
3651
+ timeout_s?: number;
3652
+ }
3653
+
3654
+ export interface Readiness {
3655
+ /** `failed`: the probe did not pass within its `timeout_s`, or the sandbox stopped first. */
3656
+ status: "pending" | "ready" | "failed";
3657
+ probe: ReadinessProbe;
3658
+ attempts: number;
3659
+ ready_at: string | null;
3660
+ /** From the create's start (or from when the probe was set) to the first passing try. */
3661
+ time_to_ready_ms: number | null;
3662
+ /** Why the last failing try failed. */
3663
+ last_error: string | null;
3664
+ }
3665
+
3666
+ /** Optionally a new probe for the sandbox (replacing its earlier one), and how long to wait. */
3667
+ export interface ReadinessWaitRequest {
3668
+ /** @default 30000 */
3669
+ wait_ms?: number;
3670
+ port?: number;
3671
+ cmd?: string | string[];
3672
+ interval_ms?: number;
3673
+ timeout_s?: number;
3674
+ }
3675
+
3676
+ export interface ReadinessResult {
3677
+ object: "readiness";
3678
+ sandbox_id: string;
3679
+ /** `pending`: `wait_ms` passed first; ask again. */
3680
+ status: "pending" | "ready" | "failed";
3681
+ probe: ReadinessProbe;
3682
+ attempts: number;
3683
+ ready_at: string | null;
3684
+ time_to_ready_ms: number | null;
3685
+ last_error: string | null;
3686
+ /** How long this call waited. */
3687
+ waited_ms: number;
3688
+ }
3689
+
1936
3690
  export interface TemplateRef {
1937
3691
  id: string;
1938
3692
  name: string;
@@ -1961,9 +3715,14 @@ export interface Sandbox {
1961
3715
  public: boolean;
1962
3716
  /**
1963
3717
  * Public ports: the long-lived preview URL, token included. Private ports: `null`; mint a URL with
1964
- * `POST /v1/sandboxes/{sandbox_id}/ports/{port}/url`.
3718
+ * `POST /v1/sandboxes/{sandbox_id}/ports/{port}/url`. Also `null` when code in another sandbox reads
3719
+ * this sandbox and this sandbox is not within that sandbox's reach (`sandboxesCreateSandbox`).
1965
3720
  */
1966
3721
  url: string | null;
3722
+ /**
3723
+ * How long a preview request waits for the app to start its response, seconds (65 unless the create said otherwise).
3724
+ */
3725
+ first_byte_s?: number;
1967
3726
  }[];
1968
3727
  api: {
1969
3728
  scopes: string[];
@@ -1980,16 +3739,42 @@ export interface Sandbox {
1980
3739
  started_at: string;
1981
3740
  paused_at: string | null;
1982
3741
  stopped_at: string | null;
1983
- /** Why the sandbox stopped. */
1984
- stop_reason: "deleted" | "timeout" | "failed" | null;
3742
+ /**
3743
+ * Why the sandbox stopped: `deleted`, `timeout` (it reached `expires_at`), `failed` (the microVM crashed),
3744
+ * `budget` (while it ran, its organization was suspended or ran out of credits, or the creating key or
3745
+ * the sandbox's own `api.spend_cap_usd` reached its cap; the node checks every 10 s) or `revoked` (the key
3746
+ * that created it was revoked).
3747
+ */
3748
+ stop_reason: "deleted" | "timeout" | "failed" | "budget" | "revoked" | null;
1985
3749
  usage: {
1986
3750
  vcpu_ms: number;
1987
3751
  gib_ms: number;
3752
+ /**
3753
+ * Present, and `true`, when `vcpu_ms` is short of the CPU the sandbox used: the node could not read
3754
+ * the microVM's CPU counter when metering began or at its last sample. What was not read is not
3755
+ * billed. Absent when the figure is whole.
3756
+ */
3757
+ vcpu_unmetered?: boolean;
1988
3758
  };
3759
+ /** The readiness probe and what it found; `null` when the sandbox has none. */
3760
+ readiness?: null | Readiness;
3761
+ options: SandboxOptions;
1989
3762
  timing?: Timing;
1990
3763
  metadata: Metadata;
1991
3764
  }
1992
3765
 
3766
+ /**
3767
+ * The options this sandbox started with, each with its `value` and the level it came from (`from`: `request`
3768
+ * when the create or fork asked for it, `node` for the node's default). Always present; `{}` for a sandbox
3769
+ * started from a template, which reads none. A fork reports its own value, not its source's.
3770
+ */
3771
+ export interface SandboxOptions {
3772
+ "sandboxes.clone_reset"?: {
3773
+ value: "full" | "none";
3774
+ from: "request" | "node";
3775
+ };
3776
+ }
3777
+
1993
3778
  export type SandboxList = Omit<ListEnvelope, "data"> & {
1994
3779
  data: Sandbox[];
1995
3780
  };
@@ -2001,6 +3786,29 @@ export interface TimeoutRequest {
2001
3786
  export interface ForkRequest {
2002
3787
  /** @default 1 */
2003
3788
  count?: number;
3789
+ /**
3790
+ * What happens to the random state of processes that were running when the snapshot was taken, at the
3791
+ * start of each fork (the option `sandboxes.clone_reset`). A restored sandbox gets a fresh identity
3792
+ * and the kernel's random pool is reseeded, but a process running at the snapshot keeps its own
3793
+ * generators' state, which every fork of the call shares with the others and with the source (the
3794
+ * source itself is never reset). The `browser` template's Chrome is the process this covers:
3795
+ * - `full`: its renderers and network service are replaced at the start, so `Math.random`,
3796
+ * `crypto.getRandomValues` and WebSocket keys are fresh. The tabs that were open at the snapshot are
3797
+ * closed and their connections dropped; the sandbox's Chrome has one new `about:blank` page.
3798
+ * - `none`: Chrome runs on as the snapshot had it, tabs and page state kept, its generators shared with the
3799
+ * source.
3800
+ *
3801
+ * Other processes running at the snapshot (a browser you started yourself, an interpreter) keep their
3802
+ * state either way; reseed or restart them. The code-interpreter kernel is reseeded on every start.
3803
+ * Default: the node's (`full` on the beta node), not the source's. A value the node does not allow is
3804
+ * refused with `422 option_not_allowed`. The reset runs in each fork's guest agent, the source's copied,
3805
+ * and `full` is reported only when the agent says it replaced Chrome: when this node's image of the
3806
+ * template or the source's agent predates the option, `full` is refused with `409 guest_outdated` before
3807
+ * the source is paused, and a fork whose agent replaced none of Chrome's processes fails the call with
3808
+ * `500 internal`, no fork left (retry, or ask for `none`). Each fork's `options` reports the value and
3809
+ * where it came from, as does the `X-B3OS-Options` header.
3810
+ */
3811
+ clone_reset?: "full" | "none";
2004
3812
  metadata?: Metadata;
2005
3813
  }
2006
3814
 
@@ -2014,8 +3822,7 @@ export interface ExecRequest {
2014
3822
  /** Written to the command's standard input, which is then closed. */
2015
3823
  stdin?: string;
2016
3824
  /**
2017
- * Kill the command after this long. At most 60000 unless the output is streamed or the command runs in the background.
2018
- * @default 30000
3825
+ * Kill the command after this long. Default 30000, or none in the background. At most 60000 unless the output is streamed or the command runs in the background.
2019
3826
  */
2020
3827
  timeout_ms?: number;
2021
3828
  /**
@@ -2044,7 +3851,7 @@ export interface ExecResult {
2044
3851
  }
2045
3852
 
2046
3853
  /**
2047
- * `exec.stdout` and `exec.stderr` carry `data`; `exec.exit` carries `exit_code`, `signal`, `timed_out` and `duration_ms`.
3854
+ * `exec.stdout` and `exec.stderr` carry `data`; `exec.exit` carries `exit_code`, `signal`, `timed_out` and `duration_ms`, and `error` (`code`, `detail`; `reason: egress_escalation` for a command cut because the sandbox left the reach of the sandbox the call came from) when the command could not run to its end.
2048
3855
  */
2049
3856
  export type ExecEvent = JobEvent & {
2050
3857
  data?: string;
@@ -2067,6 +3874,45 @@ export interface SandboxProcess {
2067
3874
  exited_at: string | null;
2068
3875
  }
2069
3876
 
3877
+ /** What a running sandbox uses now (`GET /v1/sandboxes/{sandbox_id}/stats`). */
3878
+ export interface SandboxStats {
3879
+ object: "sandbox_stats";
3880
+ sandbox_id: string;
3881
+ /** When the node read it. */
3882
+ taken_at: string;
3883
+ cpu: {
3884
+ /**
3885
+ * The share of all the sandbox's vCPUs that was busy over `interval_ms`, one decimal (100 is every vCPU busy). Null when the node could not read the sandbox's CPU counter.
3886
+ */
3887
+ percent: number | null;
3888
+ /** The sandbox's vCPUs. */
3889
+ vcpu: number;
3890
+ /** The window `percent` covers. */
3891
+ interval_ms: number | null;
3892
+ };
3893
+ memory: {
3894
+ /** `total_bytes` minus `available_bytes`. */
3895
+ used_bytes: number;
3896
+ /** What the guest kernel can still give programs (`MemAvailable`). */
3897
+ available_bytes: number;
3898
+ /** The memory the guest kernel manages (`MemTotal`), a little under the sandbox's `memory_mib`. */
3899
+ total_bytes: number;
3900
+ };
3901
+ /** The root filesystem, or null in a sandbox whose image does not report it. */
3902
+ disk: null | {
3903
+ used_bytes: number;
3904
+ total_bytes: number;
3905
+ };
3906
+ processes: {
3907
+ /** Background processes started with exec that still run (as `GET …/processes` lists them). */
3908
+ running: number;
3909
+ /**
3910
+ * Every user process in the sandbox, kernel threads left out; null in a sandbox whose image does not report it.
3911
+ */
3912
+ total: number | null;
3913
+ };
3914
+ }
3915
+
2070
3916
  export type SandboxProcessList = Omit<ListEnvelope, "data"> & {
2071
3917
  data: SandboxProcess[];
2072
3918
  };
@@ -2132,6 +3978,36 @@ export interface FileEntry {
2132
3978
  target?: string;
2133
3979
  }
2134
3980
 
3981
+ export interface FileDeleted {
3982
+ /** The path as the request gave it. */
3983
+ path: string;
3984
+ /** What was at the path. */
3985
+ type: "file" | "directory" | "symlink";
3986
+ deleted: true;
3987
+ }
3988
+
3989
+ export interface MoveFileRequest {
3990
+ /** Absolute path of the file or directory to move. */
3991
+ from: string;
3992
+ /** Absolute path it moves to. */
3993
+ to: string;
3994
+ /**
3995
+ * Replace an existing file at `to` (or an empty directory, when `from` is a directory).
3996
+ * @default false
3997
+ */
3998
+ overwrite?: boolean;
3999
+ }
4000
+
4001
+ export interface MakeDirectoryRequest {
4002
+ /** Absolute path of the directory. */
4003
+ path: string;
4004
+ /**
4005
+ * Octal mode of the directory (the umask does not apply). Parents it creates get `0755`.
4006
+ * @default "0755"
4007
+ */
4008
+ mode?: string;
4009
+ }
4010
+
2135
4011
  export type FileEntryList = Omit<ListEnvelope, "data"> & {
2136
4012
  data: FileEntry[];
2137
4013
  };
@@ -2163,6 +4039,9 @@ export interface Snapshot {
2163
4039
  id: string;
2164
4040
  object: "snapshot";
2165
4041
  name?: string | null;
4042
+ /**
4043
+ * `ready` once the snapshot's files are on the node's disk. `failed` after a restore found them damaged (`409 snapshot_damaged`); a failed snapshot cannot be restored.
4044
+ */
2166
4045
  status: "creating" | "ready" | "failed";
2167
4046
  sandbox_id: string;
2168
4047
  template: TemplateRef;
@@ -2198,6 +4077,15 @@ export interface Template {
2198
4077
  memory_mib: number;
2199
4078
  disk_gib: number;
2200
4079
  };
4080
+ /**
4081
+ * The sizes this node keeps pre-warmed microVMs of: the template's default size first, then at most one
4082
+ * larger class. A create at one of them claims a parked microVM; any other size (within your plan) is
4083
+ * restored on demand, a pool miss.
4084
+ */
4085
+ size_classes: {
4086
+ vcpu: number;
4087
+ memory_mib: number;
4088
+ }[];
2201
4089
  created_at: string;
2202
4090
  }
2203
4091
 
@@ -2212,7 +4100,7 @@ export interface RoutineDefinition {
2212
4100
  /** Optional pointer to this schema for editors. */
2213
4101
  $schema?: string;
2214
4102
  /**
2215
- * Routine slug, unique within the project. Used by the CLI (b3os routine deploy); an MCP server that lists routines as tools names the tool routine_<name> with - mapped to _. runs, hooks, validate and import are reserved: they are API paths under /v1/routines.
4103
+ * Routine slug, unique within the project. Used by the CLI (b3os routine deploy); an MCP server that lists routines as tools names the tool routine_<name> with - mapped to _. runs, hooks, waits, events, validate and import are reserved: they are API paths under /v1/routines.
2216
4104
  */
2217
4105
  name: string;
2218
4106
  /** What the routine does; an MCP server that lists routines as tools uses it as the tool description. */
@@ -2239,12 +4127,12 @@ export interface RoutineDefinition {
2239
4127
  triggers?: RoutineDefinitionTrigger[];
2240
4128
  defaults?: {
2241
4129
  /**
2242
- * ephemeral: memory only, nothing journaled (the agent tool-call fast path; a crash loses the run). standard: group-commit journal, effects durable before dependents run. strict: intent and result commits for every effect step (ARCHITECTURE 4.9, 5.4). A run may request a different tier at start.
4130
+ * ephemeral: nothing journaled while it runs (the agent tool-call fast path; a crash loses the run), and once it ends only its summary is stored (status, timing, input, result, error; no step history). standard: group-commit journal, effects durable before dependents run. strict: intent and result commits for every effect step (ARCHITECTURE 4.9, 5.4). A run may request a different tier at start.
2243
4131
  * @default "standard"
2244
4132
  */
2245
4133
  durability?: "ephemeral" | "standard" | "strict";
2246
4134
  /**
2247
- * Default timeout for uses and map steps that do not set timeout_ms. Wait and sleep steps are not affected.
4135
+ * Default timeout for uses and map steps that do not set timeout_ms. Wait and sleep steps are not affected. A job step (a product callable of kind job, such as render/video@1) that sets neither gets its operation's timeout instead (one hour for every job callable today).
2248
4136
  * @default 30000
2249
4137
  */
2250
4138
  timeout_ms?: number;
@@ -2267,6 +4155,11 @@ export interface RoutineDefinition {
2267
4155
  */
2268
4156
  on_limit?: "queue" | "skip" | "cancel_running";
2269
4157
  };
4158
+ /**
4159
+ * Pause the existing sandboxes a run execs in (sandboxes/exec@1 with sandbox) while it waits long (a wait or sleep of at least the node's pause_sandboxes_after_ms, 30 s by default, or a signal wait without a deadline) and nothing else of it runs: a paused sandbox bills no CPU. The run's next exec there resumes it first, and the end of the run resumes it. A sandbox another active run on the node execs in is not paused, and another run's exec resumes it first; anything else using the sandbox (your own processes or agents in it, other clients) is frozen while it is paused, so set this only for sandboxes the routine's runs have to themselves. Needs sandboxes:write on the publishing key.
4160
+ * @default false
4161
+ */
4162
+ pause_sandboxes?: boolean;
2270
4163
  };
2271
4164
  steps: RoutineDefinitionStep[];
2272
4165
  }
@@ -2345,6 +4238,10 @@ export type RoutineDefinitionStep = {
2345
4238
  * Pack action steps only: binds the pack's connection keys to vault connections. A key left out is resolved when the step runs with SecretStore::find_connection (the most recently created connection for that pack the run's principal may use); when there is none the step fails with connection_required. Bind explicitly when a project holds several.
2346
4239
  */
2347
4240
  connections?: Record<string, RoutineDefinitionConnectionRef>;
4241
+ /**
4242
+ * Pack action steps only: the end user the call is made for (ARCHITECTURE 5.5), a literal or a ${{ }} template such as ${{ inputs.user_id }}. Connection keys the step does not bind resolve to that subject's most recent connection for the pack and key, never to another subject's or to one without a subject; a subject with no connection fails the step with connection_required. The evaluated subject is 1 to 256 characters. Without subject, an end user's connection is used only when bound in connections.
4243
+ */
4244
+ subject?: string;
2348
4245
  /**
2349
4246
  * Runs steps once per element of over. Inside the body, item is the element and index its position; steps.<id> of a body step refers to the current item. outputs of the map step: {items: [the last body step's outputs per element, null for failed or skipped items], outcomes: [outcome per element]}, both in input order. An item fails when a body step fails without continue_on_error; the first failed item cancels in-flight items and fails the map.
2350
4247
  */
@@ -2356,14 +4253,35 @@ export type RoutineDefinitionStep = {
2356
4253
  steps: RoutineDefinitionStep[];
2357
4254
  };
2358
4255
  /**
2359
- * Blocks the step without holding resources. {signal}: wait for POST /v1/routines/runs/{run_id}/signal with that name (signals sent before the step starts are buffered, at most 16 per signal name per run, and consumed in order). {signal, ms} or {signal, until}: give up at the deadline. {until}: wait for a time. outputs for signal waits: {signal, payload, received_at, timed_out}; a deadline is not a failure: timed_out is true and signal, payload and received_at are null. outputs for {until}: {fired_at}.
4256
+ * Blocks the step without holding resources. {signal}: wait for POST /v1/routines/runs/{run_id}/signal with that name (signals sent before the step starts are buffered, at most 16 per signal name per run, and consumed in order). {signal, ms} or {signal, until}: give up at the deadline. {until}: wait for a time. {token: true}: a person answers through a signed link, run.wait_urls.<step id>, with no key or login (the signal is the step id unless signal names another). {event, match}: wait for an event sent with POST /v1/routines/events, from anywhere and without the run's ID, whose data holds the match values (not buffered: an event sent before the step waits does not count). outputs for signal waits: {signal, payload, received_at, timed_out}; a deadline is not a failure: timed_out is true and signal, payload and received_at are null. A link answer's payload is {decision: approve or reject, comment, via: link}. outputs for event waits: {event, data, id, received_at, timed_out}. outputs for {until}: {fired_at}.
2360
4257
  */
2361
4258
  wait?: {
2362
4259
  signal?: string;
2363
4260
  /** RFC 3339 timestamp, literal or produced by an expression. */
2364
4261
  until?: RoutineDefinitionTemplateString;
2365
- /** Signal waits only: maximum wait. */
4262
+ /** Signal, token and event waits only: maximum wait. */
2366
4263
  ms?: RoutineDefinitionDurationMs;
4264
+ /**
4265
+ * Wait for an event of this name (POST /v1/routines/events) in the run's project whose data holds every match value. Takes ms for a deadline; not with signal, until or token.
4266
+ */
4267
+ event?: string;
4268
+ /**
4269
+ * Event waits only: values the event's data must hold, by dot path into data (customer.id), compared as JSON. Templates are evaluated when the step starts waiting. Without match, any event of the name answers.
4270
+ */
4271
+ match?: Record<string, RoutineDefinitionTemplateValue>;
4272
+ /**
4273
+ * Give the wait a signed link a person can answer without a key: run.wait_urls.<step id> in any step's with (send it by Slack, email or a pack action). GET on the link shows a page with the prompt and Approve and Reject; the answer completes the step. The link is bound to this run and step, works once, stops working when the step stops waiting or the run ends, and expires 7 days after the step started waiting. Top-level steps only, and no other wait of the routine may use the same signal name.
4274
+ */
4275
+ token?: boolean;
4276
+ /**
4277
+ * What the person is asked, shown on the link's page and the run page while the step waits. Evaluated when the step starts waiting (context as for with). title at most 200 characters, body at most 4,000 (plain text, line breaks kept), image an https URL or an object with one (a render artifact such as steps.shot.outputs.artifacts[0]), link an https URL.
4278
+ */
4279
+ prompt?: {
4280
+ title?: RoutineDefinitionTemplateString;
4281
+ body?: RoutineDefinitionTemplateString;
4282
+ image?: RoutineDefinitionTemplateValue;
4283
+ link?: RoutineDefinitionTemplateString;
4284
+ };
2367
4285
  };
2368
4286
  /** Durable delay; outputs {}. */
2369
4287
  sleep_ms?: RoutineDefinitionDurationMs;
@@ -2371,7 +4289,9 @@ export type RoutineDefinitionStep = {
2371
4289
  needs?: RoutineDefinitionIdent[];
2372
4290
  if?: RoutineDefinitionCondition;
2373
4291
  retry?: RoutineDefinitionRetry;
2374
- /** uses steps: per attempt. map steps: the whole map. */
4292
+ /**
4293
+ * uses steps: per attempt; a job step's attempt is its job's create and the wait for its end, and a job still running when it runs out is canceled. map steps: the whole map.
4294
+ */
2375
4295
  timeout_ms?: number;
2376
4296
  /**
2377
4297
  * When the step fails, its outcome is failure but its conclusion is success, so dependents run and the run can still succeed.
@@ -2461,19 +4381,34 @@ export type RoutineDefinitionTrigger = {
2461
4381
  catch_up_window_s?: number;
2462
4382
  overlap?: RoutineDefinitionOverlap;
2463
4383
  verify?: RoutineDefinitionWebhookVerify;
4384
+ challenge?: RoutineDefinitionWebhookChallenge;
2464
4385
  /**
2465
4386
  * webhook: string key; a second delivery with the same key within 24 h returns the first delivery's response and starts nothing. Default per scheme: github X-GitHub-Delivery, stripe body.id, slack body.event_id, standard_webhooks webhook-id, b3os the Idempotency-Key header or else the v1 signature, hmac_sha256 none (then dedupe is required).
2466
4387
  */
2467
4388
  dedupe?: RoutineDefinitionCelExpression;
2468
4389
  };
2469
4390
 
4391
+ /**
4392
+ * webhook only: answer a provider's GET verification request, such as Meta's hub.challenge with hub.verify_token or Dropbox's challenge. GET /v1/routines/hooks/{hk_id}?<param>=<value>&<token_param>=<verify token> answers 200 text/plain with <value> and starts no run; a missing or wrong token answers 401 webhook_signature_invalid. <value> must be 1-1024 characters of A-Z a-z 0-9 and . _ ~ : + / = -. Without token_param and token_connection any caller gets the echo; the POST deliveries are verified by verify either way.
4393
+ */
4394
+ export interface RoutineDefinitionWebhookChallenge {
4395
+ /** The query parameter whose value is echoed (hub.challenge, challenge). */
4396
+ param: string;
4397
+ /** The query parameter that carries the verify token (hub.verify_token). */
4398
+ token_param?: string;
4399
+ /**
4400
+ * An api_key vault connection whose api_key field holds the verify token you gave the provider (store it without pack and without hosts, like verify.secret). The token is read from the vault and never appears in the definition. Naming one needs vault:run on top of routines:write.
4401
+ */
4402
+ token_connection?: string;
4403
+ }
4404
+
2470
4405
  /**
2471
4406
  * Mandatory verification for POST /v1/routines/hooks/{hk_id} (ARCHITECTURE 4.3); the hk_ id is created when the version is published. b3os: B3OS-Signature 't=<unix>,v1=<hex HMAC-SHA256(secret, "<t>.<body>")>' with a per-hook secret B3OS generates (shown once by the API). github, stripe, slack, standard_webhooks: the provider's scheme as in b3pack verify. hmac_sha256: generic, and always timestamped: the signature covers '<value of timestamp_header>.<body>', and a delivery whose timestamp header is missing or not a Unix time is refused. Timestamped schemes reject deliveries more than tolerance_s (at most 300 s) from the node clock. Secrets never appear in the URL.
2472
4407
  */
2473
4408
  export type RoutineDefinitionWebhookVerify = {
2474
4409
  scheme: "b3os" | "github" | "stripe" | "slack" | "standard_webhooks" | "hmac_sha256";
2475
4410
  /**
2476
- * An api_key vault connection whose api_key field holds the provider's signing secret (vault.yaml field names). Store it as a verification-only connection, without pack and without hosts: B3OS reads it to check signatures, and a connection with no hosts is never injected into any request. Not used with b3os.
4411
+ * An api_key vault connection whose api_key field holds the provider's signing secret (vault.yaml field names). Store it as a verification-only connection, without pack and without hosts: B3OS reads it to check signatures, and a connection with no hosts is never injected into any request. Naming one needs vault:run on top of routines:write. Not used with b3os.
2477
4412
  */
2478
4413
  secret?: string;
2479
4414
  header?: string;
@@ -2538,6 +4473,10 @@ export interface Routine {
2538
4473
  created_at: string;
2539
4474
  updated_at: string;
2540
4475
  metadata: Metadata;
4476
+ /**
4477
+ * Present only when something about the active version needs attention. Today: a `product_unavailable` warning at `/triggers/<i>` for each action trigger whose subscription the actions product does not hold yet (it was not running, or answered 5xx or 429, when the version was published). The publish stands, the trigger starts no runs until it is subscribed, and routines retries the subscription every 10 seconds until the actions product takes it; the warning then goes away. A 4xx from the actions product fails the publish with `routine_invalid` instead.
4478
+ */
4479
+ warnings?: Diagnostic[];
2541
4480
  }
2542
4481
 
2543
4482
  export type RoutineList = Omit<ListEnvelope, "data"> & {
@@ -2601,6 +4540,45 @@ export interface RoutineImport {
2601
4540
  diagnostics: Diagnostic[];
2602
4541
  }
2603
4542
 
4543
+ export interface HookTestRequest {
4544
+ /** The JSON body to deliver; `trigger.body` of the run it starts. */
4545
+ body?: Record<string, unknown>;
4546
+ }
4547
+
4548
+ /** One request to a known hook, as its delivery log keeps it. */
4549
+ export interface HookDeliveryEntry {
4550
+ object: "hook_delivery_entry";
4551
+ hook_id: string;
4552
+ received_at: string;
4553
+ method: "POST" | "GET";
4554
+ /** `edge_replay`: replayed from the edge's queue after the node was down; `test`: `POST …/test`. */
4555
+ source: "provider" | "edge_replay" | "test";
4556
+ /** The HTTP status the hook answered. */
4557
+ status: number;
4558
+ /**
4559
+ * `not_started`: accepted without a run (`if` was false, or the routine is paused); `rejected`: a 4xx; `unavailable`: a 5xx (the edge retries).
4560
+ */
4561
+ outcome: "started" | "deduplicated" | "not_started" | "handshake" | "rejected" | "unavailable";
4562
+ /** The error code of a 4xx or 5xx. */
4563
+ code: string | null;
4564
+ /** The `reason` of a `webhook_signature_invalid` (`signature` or `timestamp`). */
4565
+ reason: string | null;
4566
+ /** The error's detail (at most 500 characters). */
4567
+ detail: string | null;
4568
+ run_id: string | null;
4569
+ delivery_id: string | null;
4570
+ deduplicated: boolean;
4571
+ handshake: "slack_url_verification" | "slack_ssl_check" | "github_ping" | "get_challenge" | null;
4572
+ /** Body bytes (the body itself is not kept). */
4573
+ size: number;
4574
+ /** The allowlisted request headers it had (values up to 256 characters). */
4575
+ headers: Record<string, string>;
4576
+ }
4577
+
4578
+ export type HookDeliveryEntryList = Omit<ListEnvelope, "data"> & {
4579
+ data: HookDeliveryEntry[];
4580
+ };
4581
+
2604
4582
  export interface HookRotateRequest {
2605
4583
  /** @default 86400 */
2606
4584
  grace_s?: number;
@@ -2615,7 +4593,7 @@ export interface HookSecret {
2615
4593
 
2616
4594
  /** How the run started (the `trigger` context of its expressions). */
2617
4595
  export interface RunTrigger {
2618
- type: "api" | "cron" | "interval" | "webhook" | "action" | "routine";
4596
+ type: "api" | "cron" | "interval" | "webhook" | "action" | "routine" | "replay";
2619
4597
  /** The trigger ID (cron, interval, webhook, action). */
2620
4598
  id?: string;
2621
4599
  /** Cron and interval occurrence, used to deduplicate fires. */
@@ -2627,9 +4605,11 @@ export interface RunTrigger {
2627
4605
  subscription_id?: string;
2628
4606
  /** The pack trigger event's ID (action triggers). */
2629
4607
  event_id?: string;
2630
- /** For sub-routine runs. */
4608
+ /** For sub-routine runs, the calling run; for replays, the source run. */
2631
4609
  parent_run_id?: string;
2632
4610
  parent_step_id?: string;
4611
+ /** For replays started with `from_step`, that step. */
4612
+ from_step?: string;
2633
4613
  }
2634
4614
 
2635
4615
  export interface StepRun {
@@ -2639,6 +4619,9 @@ export interface StepRun {
2639
4619
  /** Position in the map's list, for steps inside a map body. */
2640
4620
  item_index?: number;
2641
4621
  status: "pending" | "running" | "waiting" | "retrying" | "succeeded" | "failed" | "skipped" | "canceled";
4622
+ /**
4623
+ * The attempt this execution is. Retries add one; so does a node restart while the step ran (the earlier attempt's result, should it arrive, is discarded).
4624
+ */
2642
4625
  attempt: number;
2643
4626
  started_at?: string;
2644
4627
  finished_at?: string;
@@ -2653,11 +4636,22 @@ export interface StepRun {
2653
4636
  failed?: number;
2654
4637
  running?: number;
2655
4638
  };
2656
- /** What a waiting step waits for. */
4639
+ /**
4640
+ * What a waiting step waits for. `token` and `prompt` show in the run's current state (`GET /v1/routines/runs/{run_id}`), not in event snapshots.
4641
+ */
2657
4642
  waiting_for?: {
2658
4643
  signal?: string;
2659
4644
  until?: string;
4645
+ /** The step has a wait link (`token: true`); the link itself is only in `run.wait_urls`. */
4646
+ token?: true;
4647
+ prompt?: WaitPrompt;
4648
+ /** An event wait's event name (`POST /v1/routines/events`). */
4649
+ event?: string;
4650
+ /** An event wait's evaluated match values, by dot path into the event's data. */
4651
+ match?: Record<string, unknown>;
2660
4652
  };
4653
+ /** A replay copied this step's outputs from its source run; the step did not run. Absent otherwise. */
4654
+ replayed?: true;
2661
4655
  }
2662
4656
 
2663
4657
  export type StepRunList = Omit<ListEnvelope, "data"> & {
@@ -2675,18 +4669,50 @@ export interface RunCreateRequest {
2675
4669
  metadata?: Metadata;
2676
4670
  }
2677
4671
 
2678
- /** A routine run (`run_…`); `result` is the routine's `output`. */
2679
- export type RoutineRun = Omit<Job, "id" | "object"> & {
2680
- id: string;
2681
- object: "routine_run";
2682
- routine_id: string;
4672
+ export interface RunReplayRequest {
4673
+ /**
4674
+ * Run this top-level step and every step downstream of it again. Absent: only the steps that did not succeed, and those downstream of them, run again.
4675
+ */
4676
+ from_step?: string;
4677
+ /**
4678
+ * The new run's input instead of the source run's; validated against the version's `inputs`. When it differs from the source's, the steps that read it (directly or through `env`) and the steps that wait for a signal run again, with every step downstream of them.
4679
+ */
4680
+ input?: Record<string, unknown>;
4681
+ /**
4682
+ * Replay with this version instead of the source run's (`ver_` ID or number). The steps it adds or changes and the steps that wait for a signal run again, with every step downstream of them.
4683
+ */
4684
+ version?: string | number;
4685
+ /** Override the version's default durability for the new run. */
4686
+ durability?: "ephemeral" | "standard" | "strict";
4687
+ webhook?: WebhookConfig;
4688
+ metadata?: Metadata;
4689
+ }
4690
+
4691
+ /** A routine run (`run_…`); `result` is the routine's `output`. */
4692
+ export type RoutineRun = Omit<Job, "id" | "object"> & {
4693
+ id: string;
4694
+ object: "routine_run";
4695
+ routine_id: string;
2683
4696
  version_id: string;
2684
4697
  version_number: number;
2685
4698
  durability: "ephemeral" | "standard" | "strict";
2686
4699
  trigger: RunTrigger;
2687
4700
  input: Record<string, unknown>;
2688
- /** Top-level steps in definition order. */
4701
+ /**
4702
+ * The run's outcome line: when the routine's `output` is an object with a non-empty `summary` string,
4703
+ * that string on one line, cut to 140 characters (an ellipsis marks the cut). Absent otherwise. Run
4704
+ * lists, the run's terminal event and its webhook carry it, so a list of runs says what each one did.
4705
+ */
4706
+ summary?: string;
4707
+ /** Top-level steps in definition order (empty when `steps_kept` is `false`). */
2689
4708
  steps: StepRun[];
4709
+ /**
4710
+ * `false` on an `ephemeral` run read after it ended: only its summary was kept (status, timing,
4711
+ * `input`, `result`, `error` and its IDs), so `steps` is empty, `…/steps` and a replay answer 410
4712
+ * `run_steps_not_kept`, and `…/events` sends its terminal event alone. The `?wait=` answer, the event
4713
+ * stream and the webhook carried its steps as it ended. Absent on every other run.
4714
+ */
4715
+ steps_kept?: false;
2690
4716
  };
2691
4717
 
2692
4718
  export type RoutineRunList = Omit<ListEnvelope, "data"> & {
@@ -2701,6 +4727,75 @@ export type RunEvent = JobEvent & {
2701
4727
  message?: string;
2702
4728
  };
2703
4729
 
4730
+ export interface RoutineEventRequest {
4731
+ /** The event name `wait.event` names. */
4732
+ name: string;
4733
+ /** What `wait.match` is checked against, and the step's `data` output. */
4734
+ data?: unknown;
4735
+ /** Your ID for the event, passed to the step's `id` output. */
4736
+ id?: string;
4737
+ }
4738
+
4739
+ export interface RoutineEvent {
4740
+ object: "routine_event";
4741
+ name: string;
4742
+ id?: string | null;
4743
+ /** How many waiting steps the event resumed. */
4744
+ delivered: number;
4745
+ /** The runs and steps it resumed (the first 100). */
4746
+ runs: {
4747
+ run_id: string;
4748
+ step_id: string;
4749
+ }[];
4750
+ }
4751
+
4752
+ /**
4753
+ * A wait's `prompt` as evaluated when the step started waiting. `dropped` names fields left out because they were not https URLs.
4754
+ */
4755
+ export interface WaitPrompt {
4756
+ title?: string;
4757
+ body?: string;
4758
+ image?: string;
4759
+ /**
4760
+ * The render artifact the image came from, when `image` was one (`steps.shot.outputs.artifacts[0]`). Its URL is signed for a day; the link's page signs a fresh one, as the run's principal, each time it is served.
4761
+ */
4762
+ image_artifact?: string;
4763
+ link?: string;
4764
+ dropped?: Array<"image" | "link">;
4765
+ }
4766
+
4767
+ /** A wait link's step. */
4768
+ export interface RoutineWait {
4769
+ object: "routine_wait";
4770
+ /**
4771
+ * waiting: it takes an answer. pending: the step has not started waiting. answered: through a link or a signal. timed_out: its deadline passed. expired: 7 days after it started waiting. ended: the run ended, or the step was skipped or canceled, before an answer.
4772
+ */
4773
+ status: "waiting" | "pending" | "answered" | "timed_out" | "expired" | "ended";
4774
+ run_id: string;
4775
+ run_status: "queued" | "running" | "succeeded" | "failed" | "canceled";
4776
+ routine_id: string;
4777
+ routine_name?: string | null;
4778
+ step_id: string;
4779
+ step_name?: string | null;
4780
+ /**
4781
+ * The step's evaluated prompt while it waits, and after an answer while the node still holds the run (null once the run is only in the run store).
4782
+ */
4783
+ prompt: WaitPrompt | null;
4784
+ waiting_since?: string | null;
4785
+ /**
4786
+ * While the step waits, when the link stops taking an answer: 7 days after the step started waiting, or the step's own deadline (`wait.ms`, `wait.until`) when that is sooner.
4787
+ */
4788
+ expires_at?: string | null;
4789
+ /** Once answered. `decision` is null for a signal sent through the API without one. */
4790
+ answer: {
4791
+ decision?: "approve" | "reject" | null;
4792
+ approved?: boolean | null;
4793
+ comment?: string | null;
4794
+ via?: "link" | "signal";
4795
+ answered_at?: string | null;
4796
+ } | null;
4797
+ }
4798
+
2704
4799
  export interface SignalRequest {
2705
4800
  /** The `wait.signal` name the run waits for (routine.schema.json). */
2706
4801
  name: string;
@@ -2766,6 +4861,10 @@ export interface B3Pack {
2766
4861
  legacyIds?: Record<string, string>;
2767
4862
  };
2768
4863
  signature?: B3PackSignature;
4864
+ /**
4865
+ * Search terms for the whole pack: what it is called and what it is for (email, inbox). A query that contains every word of one names the pack, and search then looks only at the packs it names.
4866
+ */
4867
+ aliases?: B3PackSearchPhrases;
2769
4868
  }
2770
4869
 
2771
4870
  /**
@@ -2789,6 +4888,11 @@ export type B3PackKebabKey = string;
2789
4888
  /** Connection key, a CEL identifier so templates can write connections.<key>. */
2790
4889
  export type B3PackConnectionKey = string;
2791
4890
 
4891
+ /**
4892
+ * Lowercase words or short phrases search matches, as a person or an agent would ask (read my latest emails). Each phrase's words count like title words.
4893
+ */
4894
+ export type B3PackSearchPhrases = string[];
4895
+
2792
4896
  export type B3PackFacetList = string[];
2793
4897
 
2794
4898
  /**
@@ -2804,7 +4908,7 @@ export interface B3PackEgressEntry {
2804
4908
  */
2805
4909
  ports?: number[];
2806
4910
  /**
2807
- * Allowed URL schemes. Default ["https"]; plain http must be listed explicitly.
4911
+ * Allowed URL schemes. Default ["https"]; plain http must be listed explicitly. Credentials are injected only into https requests: a request to an http URL whose host a required connection binds is refused (403 egress_denied, reason scheme) and nothing is sent, in T0 and T1 alike (ARCHITECTURE 4.4).
2808
4912
  * @default ["https"]
2809
4913
  */
2810
4914
  schemes?: Array<"https" | "http">;
@@ -2831,7 +4935,7 @@ export type B3PackTemplateString = string;
2831
4935
  export type B3PackTemplateValue = unknown;
2832
4936
 
2833
4937
  /**
2834
- * A connection definition. Secret fields the vault stores per type (the public names of vault.yaml ConnectionSecret), and how the egress proxy injects them (b3os-core egress::Injection): api_key {api_key}, injected as inject says (Header {name, prefix} or Query {name}); basic {username, password}, injected as Authorization: Basic base64(username:password); bearer {token}, injected as Authorization: Bearer <token>; oauth2 {access_token, refresh_token?, expires_at?, client_id?, client_secret?}, injected as Authorization: Bearer <access_token> (the refresh fields are never injected); none {} (configuration only). Each entry of hosts becomes one credential binding: credentials are injected only into requests to that host, after the egress guard validated and pinned the destination (ARCHITECTURE 4.4).
4938
+ * A connection definition. Secret fields the vault stores per type (the public names of vault.yaml ConnectionSecret), and how the egress proxy injects them (b3os-core egress::Injection): api_key {api_key}, injected as inject says (Header {name, prefix} or Query {name}); basic {username, password}, injected as Authorization: Basic base64(username:password); bearer {token}, injected as Authorization: Bearer <token>; oauth2 {access_token, refresh_token?, expires_at?, client_id?, client_secret?}, injected as Authorization: Bearer <access_token> (the refresh fields are never injected); none {} (configuration only). Each entry of hosts becomes one credential binding: credentials are injected only into https requests to that host, after the egress guard validated and pinned the destination (ARCHITECTURE 4.4), and only when the customer's vault connection is bound to the host as well (a pack connection is bound to the hosts its pack version declared when it was created). An upstream answer that echoes a credential value reaches templates with the value replaced by * characters, also where the answer writes it with JSON string or percent escapes (nested too); T1 code reads it the same way through the built-in capability proxy, while the platform egress proxy replaces only values written as is (b3osd searches T1 outputs and errors again).
2835
4939
  */
2836
4940
  export type B3PackConnection = {
2837
4941
  type: "api_key" | "basic" | "bearer" | "oauth2" | "none";
@@ -2839,7 +4943,7 @@ export type B3PackConnection = {
2839
4943
  description?: string;
2840
4944
  docsUrl?: string;
2841
4945
  /**
2842
- * Hosts that receive the injected credential. Each entry must also be covered by the pack egress list. * is not allowed.
4946
+ * Hosts that receive the injected credential. Each entry must also be covered by the pack egress list. * is not allowed. A wildcard entry (*.atlassian.net) binds the credential to the first host it is sent to: after a redirect to another host under the wildcard (another customer's site) the credential is not attached (T0: back at the host the request started at it is; T1 through the built-in capability proxy: only that first host within one invocation). The platform egress proxy, which serves T1 on production nodes, does not keep such a credential on one host yet: there an invocation whose credential would be bound only through a wildcard (declared here and in the vault connection's hosts) is refused with 501 not_implemented before anything runs.
2843
4947
  */
2844
4948
  hosts?: B3PackHostPattern[];
2845
4949
  /**
@@ -3017,6 +5121,8 @@ export type B3PackAction = {
3017
5121
  */
3018
5122
  expose?: boolean;
3019
5123
  };
5124
+ /** Task phrases for this action (read my latest emails). */
5125
+ aliases?: B3PackSearchPhrases;
3020
5126
  };
3021
5127
 
3022
5128
  /**
@@ -3028,7 +5134,7 @@ export type B3PackCron = string;
3028
5134
  export type B3PackTimezone = string;
3029
5135
 
3030
5136
  /**
3031
- * Mandatory delivery verification (ARCHITECTURE 4.3). Signatures are compared in constant time over the raw request body bytes. Schemes: github: X-Hub-Signature-256 'sha256=<hex HMAC-SHA256(secret, body)>'. stripe: Stripe-Signature 't=<unix>,v1=<hex>' over '<t>.<body>' (any v1 may match). slack: X-Slack-Signature 'v0=<hex>' over 'v0:<X-Slack-Request-Timestamp>:<body>'. standard_webhooks: webhook-signature 'v1,<base64>' entries over '<webhook-id>.<webhook-timestamp>.<body>', secret is base64 after the whsec_ prefix. hmac_sha256: generic, and always timestamped: the header value is prefix plus the HMAC-SHA256 (hex or base64, per encoding) of '<value of timestampHeader>.<body>', and a delivery whose timestamp header is missing or not a Unix time is refused. Timestamped schemes (stripe, slack, standard_webhooks, hmac_sha256) reject deliveries more than toleranceS (at most 300 s, the same rule as routine webhooks) from the node clock. The node also remembers the verified signature of each accepted delivery with its dedupe key (73 h, up to 10,000 per subscription), so a delivery replayed with a different unsigned header (for example X-GitHub-Delivery, which github's dedupe key reads) is still a duplicate; github signs no timestamp, so outside that window such a replay is not refused.
5137
+ * Mandatory delivery verification (ARCHITECTURE 4.3). Signatures are compared in constant time over the raw request body bytes. Schemes: github: X-Hub-Signature-256 'sha256=<hex HMAC-SHA256(secret, body)>'. stripe: Stripe-Signature 't=<unix>,v1=<hex>' over '<t>.<body>' (any v1 may match). slack: X-Slack-Signature 'v0=<hex>' over 'v0:<X-Slack-Request-Timestamp>:<body>'. standard_webhooks: webhook-signature 'v1,<base64>' entries over '<webhook-id>.<webhook-timestamp>.<body>', secret is base64 after the whsec_ prefix. hmac_sha256: generic, and always timestamped: the header value is prefix plus the HMAC-SHA256 (hex or base64, per encoding) of '<value of timestampHeader>.<body>', and a delivery whose timestamp header is missing or not a Unix time is refused. Timestamped schemes (stripe, slack, standard_webhooks, hmac_sha256) reject deliveries more than toleranceS (at most 300 s, the same rule as routine webhooks) from the node clock. The node also remembers the verified signature of each accepted delivery with its dedupe key (73 h, up to 10,000 per subscription), so a delivery replayed with a different unsigned header (for example X-GitHub-Delivery, which github's dedupe key reads) is still a duplicate; github signs no timestamp, so outside that window such a replay is not refused. Because github's signature covers the body alone, two distinct deliveries with byte-identical bodies within the window are one event (the second is a duplicate).
3032
5138
  */
3033
5139
  export type B3PackVerify = {
3034
5140
  scheme: "github" | "stripe" | "slack" | "standard_webhooks" | "hmac_sha256";
@@ -3161,6 +5267,8 @@ export type B3PackTrigger = {
3161
5267
  action?: B3PackKebabKey;
3162
5268
  with?: B3PackTemplateValue;
3163
5269
  };
5270
+ /** Task phrases for this trigger (when an issue is opened). */
5271
+ aliases?: B3PackSearchPhrases;
3164
5272
  };
3165
5273
 
3166
5274
  /**
@@ -3248,12 +5356,53 @@ export interface ActionSummary {
3248
5356
  mcp_name: string;
3249
5357
  /** Search relevance from 0 to 1 (search results only). */
3250
5358
  score?: number;
5359
+ /** Set in search results when the search asked for `kind=any`. */
5360
+ kind?: "action";
5361
+ }
5362
+
5363
+ /** A trigger in search results (`kind=trigger` or `kind=any`). */
5364
+ export interface TriggerSearchHit {
5365
+ kind: "trigger";
5366
+ /** Exact reference with the resolved version, for a routine's `type: action` trigger. */
5367
+ ref: string;
5368
+ pack: string;
5369
+ key: string;
5370
+ title: string;
5371
+ description: string;
5372
+ trigger_kind: "webhook" | "poll" | "schedule";
5373
+ /** The connection keys a subscription binds, as in `TriggerSummary`. */
5374
+ connections: string[];
5375
+ /** Search relevance from 0 to 1. */
5376
+ score: number;
3251
5377
  }
3252
5378
 
3253
5379
  export type ActionSearchResult = Omit<ListEnvelope, "data"> & {
3254
- data: ActionSummary[];
5380
+ data: Array<ActionSummary | TriggerSearchHit>;
5381
+ /**
5382
+ * `found` when `data` has results; `none` when nothing in the catalog (or under the `pack` and `effects` filters) does what the query asks.
5383
+ */
5384
+ match: "found" | "none";
5385
+ /**
5386
+ * With `match: none`: the query's words no pack in the catalog knows, lowercase, such as `telegram`. Empty when every word is known but no one action carries them all, or when a filter left nothing.
5387
+ */
5388
+ unmatched?: string[];
5389
+ fallback?: ActionSearchFallback;
3255
5390
  };
3256
5391
 
5392
+ /** With `match: none`, what to do instead of using an unrelated action. */
5393
+ export interface ActionSearchFallback {
5394
+ /** The answer in a sentence an agent can act on. */
5395
+ detail: string;
5396
+ /**
5397
+ * The generic HTTP actions, for a public API or a URL that carries its own authorization (they attach no credential).
5398
+ */
5399
+ refs: string[];
5400
+ /** The routine step that calls any HTTP API. */
5401
+ routine_step: string;
5402
+ /** The HTTP pack's page. */
5403
+ docs_url: string;
5404
+ }
5405
+
3257
5406
  export interface ConnectionRequirement {
3258
5407
  /** The connection key in the pack. */
3259
5408
  key: string;
@@ -3263,6 +5412,19 @@ export interface ConnectionRequirement {
3263
5412
  required?: boolean;
3264
5413
  }
3265
5414
 
5415
+ /**
5416
+ * One example call from the pack's fixtures: an input and the output the pack maps from the service's
5417
+ * response. `fixture` marks a fixture shipped in the signed bundle (a documented response shape or a recorded
5418
+ * one; its `title` says which), never a call this node made.
5419
+ */
5420
+ export interface ActionExample {
5421
+ title: string;
5422
+ input: Record<string, unknown>;
5423
+ /** What `actions.call` returns as `output` for this input. */
5424
+ output: unknown;
5425
+ label: "fixture" | "live-recorded";
5426
+ }
5427
+
3266
5428
  export interface ActionDescription {
3267
5429
  object: "action";
3268
5430
  ref: string;
@@ -3290,6 +5452,11 @@ export interface ActionDescription {
3290
5452
  inputSchema: JsonSchemaDocument;
3291
5453
  outputSchema?: JsonSchemaDocument;
3292
5454
  };
5455
+ /**
5456
+ * Example calls from the bundle's fixtures that succeed (error fixtures are left out), at most 5, read once
5457
+ * when the node loads the pack. Their inputs also appear as `examples` in `mcp.inputSchema`.
5458
+ */
5459
+ examples: ActionExample[];
3293
5460
  }
3294
5461
 
3295
5462
  export interface ActionCallRequest {
@@ -3297,9 +5464,13 @@ export interface ActionCallRequest {
3297
5464
  /** Validated against the action's input schema. */
3298
5465
  input?: Record<string, unknown>;
3299
5466
  /**
3300
- * Pack connection key to vault connection ID. Omit a key to use your project's most recently created connection for it (refused with `422 connection_required` when that connection belongs to an end user).
5467
+ * Pack connection key to vault connection ID. Omit a key to use your project's most recently created connection for it that has no `subject` (an end user's connection is used only when named; `422 connection_required` when there is none), or with `subject`, that subject's most recently created connection for it.
3301
5468
  */
3302
5469
  connections?: Record<string, string>;
5470
+ /**
5471
+ * Your end user's ID, as stored on their connections. Each connection key you do not name in `connections` resolves to this subject's most recently created connection for the pack and key (`422 connection_required` when the subject has none); keys you name are used as named. Leave it out to resolve unnamed keys to connections without a `subject`.
5472
+ */
5473
+ subject?: string;
3303
5474
  /** Overall time limit; defaults to the action's own. */
3304
5475
  timeout_ms?: number;
3305
5476
  }
@@ -3324,6 +5495,12 @@ export interface TriggerSummary {
3324
5495
  kind: "webhook" | "poll" | "schedule";
3325
5496
  config_schema: JsonSchemaDocument;
3326
5497
  event_schema: JsonSchemaDocument;
5498
+ /**
5499
+ * The connection keys a subscription binds (`connections` on a routine's action trigger): the pack
5500
+ * connections the trigger needs, plus `webhook_secret` when the provider's signing secret comes from you.
5501
+ * `webhook_secret` names an `api_key` connection that holds that secret (Stripe's endpoint signing secret,
5502
+ * Slack's signing secret); it is used only to verify deliveries and is never sent anywhere.
5503
+ */
3327
5504
  connections: string[];
3328
5505
  }
3329
5506
 
@@ -3338,6 +5515,10 @@ export interface PackPublisher {
3338
5515
  verified: boolean;
3339
5516
  }
3340
5517
 
5518
+ /**
5519
+ * Nodes from this release on always send `facets`, `connection_types`, `keyless` and `icons`. Nodes deployed
5520
+ * before it do not, so clients should not require them.
5521
+ */
3341
5522
  export interface PackSummaryFields {
3342
5523
  /** `<namespace>/<name>`. */
3343
5524
  id: string;
@@ -3348,11 +5529,57 @@ export interface PackSummaryFields {
3348
5529
  latest_version: string;
3349
5530
  action_count: number;
3350
5531
  trigger_count: number;
5532
+ /** The manifest's browse facets (`domain`, `assetClass`, `chains`); empty when it has none. */
5533
+ facets?: {
5534
+ domain?: string[];
5535
+ assetClass?: string[];
5536
+ chains?: string[];
5537
+ };
5538
+ /** The types of the pack's connections, sorted, each once; empty for a pack with none. */
5539
+ connection_types?: Array<"api_key" | "basic" | "bearer" | "oauth2" | "none">;
5540
+ /** True when the pack needs no stored credential (no connections, or only `none` connections). */
5541
+ keyless?: boolean;
5542
+ /**
5543
+ * The manifest's icons that are 4 KiB or smaller, as `data:` URIs read from the signed bundle; larger icons
5544
+ * are left out.
5545
+ */
5546
+ icons?: {
5547
+ src: string;
5548
+ mimeType: "image/svg+xml" | "image/png" | "image/webp";
5549
+ sizes?: string[];
5550
+ }[];
3351
5551
  }
3352
5552
 
3353
5553
  /** A pack in a list. */
3354
5554
  export type PackSummary = PackSummaryFields;
3355
5555
 
5556
+ /** A pack version's MCP tools (`GET /v1/actions/packs/{namespace}/{name}/tools`). */
5557
+ export interface PackTools {
5558
+ object: "pack_tools";
5559
+ pack: string;
5560
+ version: string;
5561
+ content_hash: string;
5562
+ /** How long to cache this list, in milliseconds. */
5563
+ ttlMs: number;
5564
+ tools: {
5565
+ /** The MCP tool name (`mcp_name`). */
5566
+ name: string;
5567
+ title: string;
5568
+ description: string;
5569
+ inputSchema: JsonSchemaDocument;
5570
+ outputSchema?: JsonSchemaDocument;
5571
+ annotations: {
5572
+ title?: string;
5573
+ readOnlyHint?: boolean;
5574
+ destructiveHint?: boolean;
5575
+ idempotentHint?: boolean;
5576
+ openWorldHint?: boolean;
5577
+ };
5578
+ ref: string;
5579
+ effects: EffectClass;
5580
+ }[];
5581
+ }
5582
+
3356
5583
  export type PackList = Omit<ListEnvelope, "data"> & {
3357
5584
  data: PackSummary[];
3358
5585
  };
@@ -3362,10 +5589,32 @@ export type Pack = PackSummaryFields & {
3362
5589
  version: string;
3363
5590
  /** Every published version, newest first. */
3364
5591
  versions: string[];
5592
+ /**
5593
+ * The pack's connections, with what creating one needs. Nodes from this release on send `optional`;
5594
+ * `description`, `docs_url`, `params_schema` and `defaults` when the manifest has them. Nodes deployed
5595
+ * before it send only `key`, `type` and `label`.
5596
+ */
3365
5597
  connections: {
3366
5598
  key: string;
3367
5599
  type: "api_key" | "basic" | "bearer" | "oauth2" | "none";
3368
5600
  label: string;
5601
+ /** What the connection is for and where to get the credential. */
5602
+ description?: string;
5603
+ /** The provider's page about the credential. */
5604
+ docs_url?: string;
5605
+ /**
5606
+ * JSON Schema of the connection's non-secret parameters (`params` on `POST
5607
+ * /v1/vault/connections`), such as a Jira site name or SEC EDGAR's User-Agent. Absent when the
5608
+ * connection has none.
5609
+ */
5610
+ params_schema?: JsonSchemaDocument;
5611
+ /**
5612
+ * True when a call that names no connection for this key and finds none stored still runs, with
5613
+ * `defaults` as its params (a `none` connection whose parameters all have defaults).
5614
+ */
5615
+ optional?: boolean;
5616
+ /** With `optional`, the params a call sends when no connection is stored. */
5617
+ defaults?: Record<string, unknown>;
3369
5618
  }[];
3370
5619
  /** Hosts the pack may reach. */
3371
5620
  egress: string[];
@@ -3485,20 +5734,27 @@ export interface ToolCall {
3485
5734
 
3486
5735
  /**
3487
5736
  * A message. `content` may be a string or a list of parts (images only in `user` messages); only `assistant`
3488
- * messages may have `null` content (`400 invalid_request` with the pointer otherwise). Members not listed
3489
- * here (such as `annotations` or `audio` echoed from an earlier response) are ignored.
5737
+ * messages may leave `content` out or set it to `null` (`400 invalid_request` with the pointer otherwise).
5738
+ * Members not listed here (such as `annotations` or `audio` echoed from an earlier response) are ignored.
3490
5739
  */
3491
- export interface ChatMessage {
3492
- role: "system" | "developer" | "user" | "assistant" | "tool";
3493
- content?: string | null | ContentPart[];
3494
- name?: string | null;
3495
- tool_calls?: ToolCall[] | null;
3496
- /** For `tool` messages, the call this is the result of. */
3497
- tool_call_id?: string | null;
3498
- refusal?: string | null;
3499
- /** B3OS extension. The reasoning of an earlier assistant turn, passed back to the model's template. */
3500
- reasoning_content?: string | null;
3501
- }
5740
+ export type ChatMessage =
5741
+ | ({
5742
+ role: "system" | "developer" | "user" | "assistant" | "tool";
5743
+ content?: string | null | ContentPart[];
5744
+ name?: string | null;
5745
+ tool_calls?: ToolCall[] | null;
5746
+ /** For `tool` messages, the call this is the result of. */
5747
+ tool_call_id?: string | null;
5748
+ refusal?: string | null;
5749
+ /** B3OS extension. The reasoning of an earlier assistant turn, passed back to the model's template. */
5750
+ reasoning_content?: string | null;
5751
+ } & {
5752
+ role?: "assistant";
5753
+ })
5754
+ | {
5755
+ role?: "system" | "developer" | "user" | "tool";
5756
+ content: string | ContentPart[];
5757
+ };
3502
5758
 
3503
5759
  export interface FunctionTool {
3504
5760
  type: "function";
@@ -3508,6 +5764,10 @@ export interface FunctionTool {
3508
5764
  /** A JSON Schema object (at most 64 KiB serialized and 32 levels deep), as OpenAI requires. */
3509
5765
  parameters?: Record<string, unknown>;
3510
5766
  strict?: boolean;
5767
+ /**
5768
+ * Accepted and ignored, with any value; never sent to the model. Evaluation harnesses such as BFCL leave a function's response schema here.
5769
+ */
5770
+ response?: unknown;
3511
5771
  };
3512
5772
  }
3513
5773
 
@@ -3557,6 +5817,9 @@ export interface ChatCompletionRequest {
3557
5817
  * Nucleus sampling. `0` keeps only the most probable token (passed to the runtime as 1e-9, the same thing, since vLLM takes values above 0 only).
3558
5818
  */
3559
5819
  top_p?: number | null;
5820
+ /**
5821
+ * The most tokens to generate. Unset (with `max_completion_tokens` unset too), the model's default output cap applies where the node sets one (`b3os.default_max_tokens` in the model list); where that is `null`, the generation can run to the end of the context.
5822
+ */
3560
5823
  max_tokens?: number | null;
3561
5824
  /** Wins over `max_tokens` when both are set. */
3562
5825
  max_completion_tokens?: number | null;
@@ -3576,7 +5839,9 @@ export interface ChatCompletionRequest {
3576
5839
  } | null;
3577
5840
  /**
3578
5841
  * B3OS extension. `gateway` sends the request to the B3IQ gateway when this node does not serve the model
3579
- * (models it serves stay local); without it an unknown model is `404 model_not_available`.
5842
+ * (models it serves stay local); without it an unknown model is `404 model_not_available`. The production
5843
+ * node (beta-api.b3os.org) has no gateway route configured yet (no B3IQ gateway key or model list), so
5844
+ * there `gateway` answers `404 model_not_available` as well.
3580
5845
  * @default "local"
3581
5846
  */
3582
5847
  route?: "local" | "gateway" | null;
@@ -3588,9 +5853,24 @@ export interface ChatCompletionRequest {
3588
5853
  repetition_penalty?: number | null;
3589
5854
  /** Token ID to bias added to its logit. */
3590
5855
  logit_bias?: Record<string, number> | null;
5856
+ /**
5857
+ * How much the model may reason before it answers. `none` and `minimal`: no reasoning phase (the
5858
+ * default). `low`, `medium`, `high`, `xhigh`: a reasoning phase of at most 256, 1,024, 4,096 and 8,192
5859
+ * tokens; at the budget the node closes the reasoning and the answer starts in the same request, so
5860
+ * `usage.completion_tokens_details.reasoning_tokens` stays within it. Without `max_tokens` the default
5861
+ * output cap grows by the budget, so the answer keeps the cap's room; with a `max_tokens` below the
5862
+ * budget the reasoning can use all of it, and the answer is empty with `finish_reason: "length"`. The
5863
+ * same levels and budgets apply to Responses' `reasoning.effort` and Messages' adaptive `thinking`
5864
+ * (`output_config.effort`). With `chat_template_kwargs.enable_thinking` set the other way, the request
5865
+ * is `400 invalid_request`. A `gateway` model takes it as its provider does.
5866
+ */
5867
+ reasoning_effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | null;
3591
5868
  /** Runtime extension. Only `enable_thinking` is taken. */
3592
5869
  chat_template_kwargs?: {
3593
- /** Let the model reason before answering; the reasoning arrives in `reasoning_content`. */
5870
+ /**
5871
+ * Let the model reason before answering; the reasoning arrives in `reasoning_content`. There is no
5872
+ * ceiling on the reasoning this way; `reasoning_effort` sets one.
5873
+ */
3594
5874
  enable_thinking?: boolean;
3595
5875
  } | null;
3596
5876
  /** Accepted and ignored. */
@@ -3599,12 +5879,35 @@ export interface ChatCompletionRequest {
3599
5879
  store?: boolean | null;
3600
5880
  /** Accepted and ignored. */
3601
5881
  service_tier?: string | null;
5882
+ /**
5883
+ * Accepted and ignored. The node caches prompt prefixes per organization on its own; this key never changes which requests share a cache.
5884
+ */
5885
+ prompt_cache_key?: string | null;
5886
+ /** Accepted and ignored (the runtime keeps cached prefixes while it has room). */
5887
+ prompt_cache_retention?: string | null;
5888
+ /** Accepted and ignored. */
5889
+ safety_identifier?: string | null;
5890
+ /** Accepted and ignored; set `max_tokens` to bound the answer. */
5891
+ verbosity?: string | null;
3602
5892
  }
3603
5893
 
3604
5894
  export interface Usage {
3605
5895
  prompt_tokens: number;
3606
5896
  completion_tokens: number;
3607
5897
  total_tokens: number;
5898
+ /**
5899
+ * `cached_tokens`: the prompt tokens the runtime's prefix cache served, from this organization's earlier
5900
+ * requests (whole 1,056-token blocks on b3os/qwen3.5-9b); they are part of `prompt_tokens` and metered
5901
+ * like the rest. `multimodal_tokens` counts image tokens per modality when the prompt has images.
5902
+ */
5903
+ prompt_tokens_details?: {
5904
+ cached_tokens?: number;
5905
+ [key: string]: unknown;
5906
+ };
5907
+ completion_tokens_details?: {
5908
+ reasoning_tokens?: number;
5909
+ [key: string]: unknown;
5910
+ };
3608
5911
  [key: string]: unknown;
3609
5912
  }
3610
5913
 
@@ -3679,15 +5982,28 @@ export interface ChatCompletionChunk {
3679
5982
 
3680
5983
  /** B3OS extension with what the model supports and your limits on it. */
3681
5984
  export interface ModelInfo {
5985
+ /**
5986
+ * On `b3os/default` only: the chat model it names, whose limits apply. A request for the alias is served, limited and metered as that model, and its response names that model.
5987
+ */
5988
+ alias_of?: string;
3682
5989
  kind: "chat" | "embedding" | "speech";
3683
5990
  context_length: number | null;
5991
+ /**
5992
+ * The output cap of a chat request that sets no `max_tokens` (or `max_completion_tokens`, or Responses'
5993
+ * `max_output_tokens`): the generation stops there with `finish_reason: "length"`. Set `max_tokens` to go
5994
+ * higher. A node setting: `null` where the node has no cap (such a request then runs to the end of the
5995
+ * context) and for speech and embedding models.
5996
+ */
5997
+ default_max_tokens?: number | null;
3684
5998
  quantization: string | null;
3685
5999
  tools: boolean;
3686
6000
  json_schema: boolean;
3687
6001
  image_input: boolean;
3688
6002
  max_request_bytes: number;
3689
6003
  limits: {
3690
- /** Tokens per minute for your organization. */
6004
+ /**
6005
+ * Tokens per minute for your organization (its own value from the node's budget snapshot, else the node's default).
6006
+ */
3691
6007
  tpm: number | null;
3692
6008
  rpm: number | null;
3693
6009
  };
@@ -3735,7 +6051,9 @@ export interface SpeechRequest {
3735
6051
  /** A speech model, such as `kokoro-82m`. */
3736
6052
  model: string;
3737
6053
  input: string;
3738
- /** A voice ID from `GET /v1/infer/audio/voices`. */
6054
+ /**
6055
+ * A voice ID from `GET /v1/infer/audio/voices`, or one of OpenAI's voice names (`alloy`, `ash`, `ballad`, `cedar`, `coral`, `echo`, `fable`, `marin`, `nova`, `onyx`, `sage`, `shimmer`, `verse`), which resolve to Kokoro voices as the operation describes. A voice the model has by that exact ID wins.
6056
+ */
3739
6057
  voice: string;
3740
6058
  /** @default "mp3" */
3741
6059
  response_format?: "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm" | null;
@@ -3753,11 +6071,47 @@ export interface SpeechRequest {
3753
6071
  * @default "none"
3754
6072
  */
3755
6073
  timestamps?: "none" | "word" | null;
6074
+ /**
6075
+ * B3OS extension. The language to read `input` in, as a BCP 47 tag (case does not matter): one of the `language` values of the model's voices in `GET /v1/infer/audio/voices` (for `kokoro-82m`: `en-US`, `en-GB`, `es-ES`, `fr-FR`, `it-IT`, `pt-BR`). Unset, a voice reads in its own language. In a language other than English the word timings come from the forced aligner. Any other value is `400 unsupported_parameter`.
6076
+ */
6077
+ language?: string | null;
6078
+ /**
6079
+ * OpenAI's streaming. Unset, the clip comes in one piece. `audio` streams the bytes of `response_format` as they are made; `sse` streams `speech.audio.delta` events, then `speech.audio.done`. Either way the head carries `Server-Timing` `ttfa`. Word timings stream only with `sse`, in the done event.
6080
+ */
6081
+ stream_format?: "audio" | "sse" | null;
6082
+ }
6083
+
6084
+ /**
6085
+ * One event of a speech stream (`stream_format: "sse"`), named by its `type` (the SSE `event:` field carries
6086
+ * the same name): `speech.audio.delta` with a piece of the audio (`audio`, base64, in `response_format`; the
6087
+ * pieces joined are the whole clip), then `speech.audio.done` with the clip's `format`, `sample_rate`,
6088
+ * `duration_ms`, `words` when `timestamps` is `word`, and `b3os` (route, node, and timing in milliseconds:
6089
+ * the voice service's `voice_queue_ms` and `voice_run_ms`, and `total_ms`). A failure after audio is an
6090
+ * `error` event (`error`, OpenAI's error object) and ends the stream. There is no `usage`: speech bills
6091
+ * characters (`infer.audio_chars`), not tokens.
6092
+ */
6093
+ export interface SpeechStreamEvent {
6094
+ type: "speech.audio.delta" | "speech.audio.done" | "error";
6095
+ audio?: string;
6096
+ model?: string;
6097
+ voice?: string;
6098
+ format?: "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm";
6099
+ sample_rate?: number;
6100
+ duration_ms?: number;
6101
+ /** As in `SpeechWithTimestamps`, from the start of the clip. */
6102
+ words?: {
6103
+ text: string;
6104
+ start_ms: number;
6105
+ end_ms: number;
6106
+ }[];
6107
+ b3os?: Record<string, unknown>;
6108
+ error?: Record<string, unknown>;
3756
6109
  }
3757
6110
 
3758
6111
  export interface SpeechWithTimestamps {
3759
6112
  object: "speech";
3760
6113
  model: string;
6114
+ /** The voice that spoke, after an OpenAI voice name resolved (as `x-b3os-voice`). */
3761
6115
  voice: string;
3762
6116
  format: "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm";
3763
6117
  sample_rate: number;
@@ -3775,8 +6129,24 @@ export interface Voice {
3775
6129
  object: "voice";
3776
6130
  model: string;
3777
6131
  name: string;
3778
- /** BCP 47 tag. */
6132
+ /** BCP 47 tag, the language the voice reads in unless a request sets `language`. */
3779
6133
  language: string;
6134
+ /** The voice's gender as the model's authors label it; `null` when the voice service does not say. */
6135
+ gender?: "female" | "male" | null;
6136
+ /**
6137
+ * Where the voice's word timings come from: `model` (the speech model's own durations) or `aligner` (a forced aligner run on the synthesized audio, in 80 ms steps); `null` when the voice service does not say.
6138
+ */
6139
+ word_timings?: "model" | "aligner" | null;
6140
+ /**
6141
+ * Where the voice sits in the catalog: `featured` voices are a short list picked to start with and come first in this list, `limited` ones (the voices the model's authors grade lowest for their training data, and novelty voices) belong behind an "All voices" control; every voice can be used by its id. `null` when the voice service does not say.
6142
+ */
6143
+ tier?: "featured" | "standard" | "limited" | null;
6144
+ /**
6145
+ * What a featured voice was picked for: `narration` (demos, explainers, read-alouds), `conversation` (assistants and agents that answer) or `character` (a voice in a role); `null` for voices nobody picked for one.
6146
+ */
6147
+ use_case?: "narration" | "conversation" | "character" | null;
6148
+ /** True for one voice per language, the one to start with in that language. */
6149
+ default?: boolean;
3780
6150
  /**
3781
6151
  * A short audio sample of the voice, a B3OS static asset: `https://beta.b3os.org/assets/voices/<voice>.<ext>`
3782
6152
  * (B3OS's own media are never served from `usercontent.b3os.org`, which holds customer bytes only).
@@ -3788,286 +6158,50 @@ export type VoiceList = Omit<ListEnvelope, "data"> & {
3788
6158
  data: Voice[];
3789
6159
  };
3790
6160
 
3791
- /** Accepted and ignored. */
3792
- export type AnthropicCacheControl = {
3793
- type?: string;
3794
- ttl?: string;
3795
- } | null;
3796
-
3797
- export interface AnthropicTextBlock {
3798
- type: "text";
6161
+ export interface ResponsesInputText {
6162
+ type: "input_text";
3799
6163
  text: string;
3800
- cache_control?: AnthropicCacheControl;
3801
- /** Accepted and ignored. */
3802
- citations?: Record<string, unknown>[] | null;
6164
+ prompt_cache_breakpoint?: ResponsesCacheBreakpoint;
3803
6165
  }
3804
6166
 
3805
- export interface AnthropicImageBlock {
3806
- type: "image";
3807
- source:
3808
- | {
3809
- type: "base64";
3810
- media_type: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
3811
- /** The image file, which must be a PNG, JPEG, WebP or GIF. */
3812
- data: string;
3813
- }
3814
- | {
3815
- type: "url";
3816
- /** Fetched by the node through its egress guard (PNG, JPEG, WebP or GIF, at most 10 MiB). */
3817
- url: string;
3818
- };
3819
- cache_control?: AnthropicCacheControl;
3820
- }
6167
+ /** Accepted and ignored; the runtime caches prompt prefixes on its own. */
6168
+ export type ResponsesCacheBreakpoint = {
6169
+ mode?: "explicit" | null;
6170
+ } | null;
3821
6171
 
3822
- export interface AnthropicToolUseBlock {
3823
- type: "tool_use";
3824
- id: string;
3825
- name: string;
3826
- input: Record<string, unknown>;
3827
- cache_control?: AnthropicCacheControl;
6172
+ export interface ResponsesInputImage {
6173
+ type: "input_image";
6174
+ /** `https://` (fetched by the node through its egress guard) or a base64 `data:` URL. */
6175
+ image_url: string;
6176
+ /** Accepted and ignored; images are resized to about 1 MP. */
6177
+ detail?: "auto" | "low" | "high" | "original" | null;
6178
+ /** The Files API is not available on this node (null only). */
6179
+ file_id?: null;
6180
+ prompt_cache_breakpoint?: ResponsesCacheBreakpoint;
3828
6181
  }
3829
6182
 
3830
- export interface AnthropicToolResultBlock {
3831
- type: "tool_result";
3832
- tool_use_id: string;
3833
- content?: null | string | Array<AnthropicTextBlock | AnthropicImageBlock>;
3834
- /** The result is an error; the model sees it prefixed with `Error:`. */
3835
- is_error?: boolean | null;
3836
- cache_control?: AnthropicCacheControl;
6183
+ export interface ResponsesOutputText {
6184
+ type: "output_text";
6185
+ text: string;
6186
+ annotations?: Record<string, unknown>[] | null;
6187
+ logprobs?: Record<string, unknown>[] | null;
3837
6188
  }
3838
6189
 
3839
- export interface AnthropicThinkingBlock {
3840
- type: "thinking";
3841
- thinking: string;
3842
- /** Opaque; this node does not check it. */
3843
- signature?: string | null;
6190
+ export interface ResponsesRefusal {
6191
+ type: "refusal";
6192
+ refusal: string;
3844
6193
  }
3845
6194
 
3846
- /** Accepted in assistant turns and left out of the prompt. */
3847
- export interface AnthropicRedactedThinkingBlock {
3848
- type: "redacted_thinking";
3849
- data: string;
3850
- }
3851
-
3852
- export interface AnthropicUserMessage {
3853
- role: "user";
3854
- content: string | Array<AnthropicTextBlock | AnthropicImageBlock | AnthropicToolResultBlock>;
3855
- }
3856
-
3857
- /** An earlier answer; as the last message, the start of the answer, which the model continues. */
3858
- export interface AnthropicAssistantMessage {
3859
- role: "assistant";
3860
- content:
3861
- | string
3862
- | Array<AnthropicTextBlock | AnthropicToolUseBlock | AnthropicThinkingBlock | AnthropicRedactedThinkingBlock>;
3863
- }
3864
-
3865
- export type AnthropicInputMessage = AnthropicUserMessage | AnthropicAssistantMessage;
3866
-
3867
- /**
3868
- * A custom tool. Tools Anthropic defines or runs (a `type` other than `custom`) are `unsupported_parameter`.
3869
- */
3870
- export interface AnthropicTool {
3871
- type?: "custom" | null;
3872
- /** Unique within `tools`. */
3873
- name: string;
3874
- description?: string | null;
3875
- /** A JSON Schema object (at most 64 KiB serialized and 32 levels deep). */
3876
- input_schema: Record<string, unknown>;
3877
- strict?: boolean | null;
3878
- cache_control?: AnthropicCacheControl;
3879
- }
3880
-
3881
- export type AnthropicToolChoice =
3882
- | (Record<string, unknown> & {
3883
- /** `any` makes the model call a tool (it needs `tools`). */
3884
- type: "auto" | "any";
3885
- disable_parallel_tool_use?: boolean | null;
3886
- })
3887
- | {
3888
- type: "tool";
3889
- /** One of `tools`. */
3890
- name: string;
3891
- disable_parallel_tool_use?: boolean | null;
3892
- }
3893
- | {
3894
- type: "none";
3895
- };
3896
-
3897
- /**
3898
- * `enabled` (with `budget_tokens`, at least 1024 and less than `max_tokens`) and `adaptive` let the model
3899
- * reason first, in `thinking` blocks; `disabled`, the default, does not. `display` is accepted and ignored.
3900
- */
3901
- export type AnthropicThinking =
3902
- | (Record<string, unknown> & {
3903
- type: "enabled";
3904
- budget_tokens: number;
3905
- display?: "summarized" | "omitted" | "updates" | null;
3906
- })
3907
- | {
3908
- type: "adaptive";
3909
- display?: "summarized" | "omitted" | "updates" | null;
3910
- }
3911
- | {
3912
- type: "disabled";
3913
- };
3914
-
3915
- /**
3916
- * Anthropic Messages parameters. Any other parameter is `400 unsupported_parameter`; `null` means unset.
3917
- */
3918
- export interface AnthropicMessagesRequest {
3919
- model: string;
3920
- messages: AnthropicInputMessage[];
3921
- max_tokens: number;
3922
- /** The system prompt; text blocks are joined with blank lines. */
3923
- system?: null | string | AnthropicTextBlock[];
3924
- tools?: AnthropicTool[] | null;
3925
- tool_choice?: null | AnthropicToolChoice;
3926
- thinking?: null | AnthropicThinking;
3927
- output_config?: {
3928
- /** The answer is JSON matching `schema` (at most 64 KiB serialized and 32 levels deep). */
3929
- format?: {
3930
- type: "json_schema";
3931
- /** A JSON Schema object, as Anthropic requires. */
3932
- schema: Record<string, unknown>;
3933
- } | null;
3934
- /** Accepted and ignored. */
3935
- effort?: "low" | "medium" | "high" | "xhigh" | "max" | null;
3936
- } | null;
3937
- stop_sequences?: string[] | null;
3938
- stream?: boolean | null;
3939
- temperature?: number | null;
3940
- /**
3941
- * Nucleus sampling. `0` keeps only the most probable token (passed to the runtime as 1e-9, the same thing, since vLLM takes values above 0 only).
3942
- */
3943
- top_p?: number | null;
3944
- top_k?: number | null;
3945
- /** Accepted and ignored. */
3946
- metadata?: {
3947
- user_id?: string | null;
3948
- } | null;
3949
- /** Accepted and ignored. */
3950
- service_tier?: string | null;
3951
- }
3952
-
3953
- /** The input of a Messages request. Any other parameter is `400 unsupported_parameter`. */
3954
- export interface AnthropicCountTokensRequest {
3955
- model: string;
3956
- messages: AnthropicInputMessage[];
3957
- /** The system prompt; text blocks are joined with blank lines. */
3958
- system?: null | string | AnthropicTextBlock[];
3959
- tools?: AnthropicTool[] | null;
3960
- tool_choice?: null | AnthropicToolChoice;
3961
- thinking?: null | AnthropicThinking;
3962
- }
3963
-
3964
- export interface AnthropicCountTokens {
3965
- input_tokens: number;
3966
- }
3967
-
3968
- export interface AnthropicUsage {
3969
- input_tokens: number;
3970
- output_tokens: number;
3971
- }
3972
-
3973
- /**
3974
- * A block of the answer, `text`, `tool_use` (with `id`, `name`, `input`) or `thinking` (with `signature`).
3975
- */
3976
- export interface AnthropicOutputBlock {
3977
- type: "text" | "tool_use" | "thinking";
3978
- text?: string;
3979
- id?: string;
3980
- name?: string;
3981
- input?: Record<string, unknown>;
3982
- thinking?: string;
3983
- signature?: string;
3984
- }
3985
-
3986
- export interface AnthropicMessage {
3987
- id: string;
3988
- type: "message";
3989
- role: "assistant";
3990
- content: AnthropicOutputBlock[];
3991
- model: string;
3992
- stop_reason: "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | "refusal";
3993
- /** The stop sequence that ended the answer. */
3994
- stop_sequence: string | null;
3995
- usage: AnthropicUsage;
3996
- b3os?: InferMeta;
3997
- }
3998
-
3999
- /**
4000
- * One event of a stream, named by its `type` (the SSE `event:` field carries the same name):
4001
- * `message_start` (`message`, with empty `content` and the input tokens), `content_block_start` (`index`,
4002
- * `content_block`), `content_block_delta` (`index`, and a `delta` of type `text_delta`, `input_json_delta`,
4003
- * `thinking_delta` or `signature_delta`), `content_block_stop` (`index`), `message_delta` (`delta` with
4004
- * `stop_reason` and `stop_sequence`, and `usage`), `message_stop` (with the `b3os` metadata), or `error`.
4005
- */
4006
- export interface AnthropicStreamEvent {
4007
- type:
4008
- | "message_start"
4009
- | "content_block_start"
4010
- | "content_block_delta"
4011
- | "content_block_stop"
4012
- | "message_delta"
4013
- | "message_stop"
4014
- | "error";
4015
- message?: Record<string, unknown>;
4016
- index?: number;
4017
- content_block?: Record<string, unknown>;
4018
- delta?: Record<string, unknown>;
4019
- usage?: Record<string, unknown>;
4020
- error?: {
4021
- type?: string;
4022
- message?: string;
4023
- };
4024
- b3os?: InferMeta;
4025
- }
4026
-
4027
- export interface ResponsesInputText {
4028
- type: "input_text";
4029
- text: string;
4030
- prompt_cache_breakpoint?: ResponsesCacheBreakpoint;
4031
- }
4032
-
4033
- /** Accepted and ignored; the runtime caches prompt prefixes on its own. */
4034
- export type ResponsesCacheBreakpoint = {
4035
- mode?: "explicit" | null;
4036
- } | null;
4037
-
4038
- export interface ResponsesInputImage {
4039
- type: "input_image";
4040
- /** `https://` (fetched by the node through its egress guard) or a base64 `data:` URL. */
4041
- image_url: string;
4042
- /** Accepted and ignored; images are resized to about 1 MP. */
4043
- detail?: "auto" | "low" | "high" | "original" | null;
4044
- /** The Files API is not available on this node (null only). */
4045
- file_id?: null;
4046
- prompt_cache_breakpoint?: ResponsesCacheBreakpoint;
4047
- }
4048
-
4049
- export interface ResponsesOutputText {
4050
- type: "output_text";
4051
- text: string;
4052
- annotations?: Record<string, unknown>[] | null;
4053
- logprobs?: Record<string, unknown>[] | null;
4054
- }
4055
-
4056
- export interface ResponsesRefusal {
4057
- type: "refusal";
4058
- refusal: string;
4059
- }
4060
-
4061
- /**
4062
- * A message. `user` messages take `input_text` and `input_image` parts, `system` and `developer` messages `input_text` parts (both become the system prompt, after `instructions`), `assistant` messages `output_text` and `refusal` parts. A string is one text part.
4063
- */
4064
- export interface ResponsesInputMessage {
4065
- type?: "message" | null;
4066
- role: "user" | "assistant" | "system" | "developer";
4067
- content: string | Array<ResponsesInputText | ResponsesInputImage | ResponsesOutputText | ResponsesRefusal>;
4068
- id?: string | null;
4069
- status?: string | null;
4070
- phase?: string | null;
6195
+ /**
6196
+ * A message. `user` messages take `input_text` and `input_image` parts, `system` and `developer` messages `input_text` parts (both become the system prompt, after `instructions`), `assistant` messages `output_text` and `refusal` parts. A string is one text part.
6197
+ */
6198
+ export interface ResponsesInputMessage {
6199
+ type?: "message" | null;
6200
+ role: "user" | "assistant" | "system" | "developer";
6201
+ content: string | Array<ResponsesInputText | ResponsesInputImage | ResponsesOutputText | ResponsesRefusal>;
6202
+ id?: string | null;
6203
+ status?: string | null;
6204
+ phase?: string | null;
4071
6205
  }
4072
6206
 
4073
6207
  /** A function call the model made in an earlier turn. */
@@ -4128,6 +6262,7 @@ export interface ResponsesFunctionTool {
4128
6262
  description?: string | null;
4129
6263
  /** A JSON Schema object (at most 64 KiB serialized and 32 levels deep); absent means no arguments. */
4130
6264
  parameters?: Record<string, unknown> | null;
6265
+ /** Passed to the runtime when set; the response echoes the value sent, or `null` when unset. */
4131
6266
  strict?: boolean | null;
4132
6267
  allowed_callers?: "direct"[] | null;
4133
6268
  defer_loading?: false | null;
@@ -4175,7 +6310,11 @@ export interface ResponsesRequest {
4175
6310
  verbosity?: "low" | "medium" | "high" | null;
4176
6311
  } | null;
4177
6312
  reasoning?: {
4178
- /** `low` and above turn the reasoning phase on; unset, `none` and `minimal` leave it off. */
6313
+ /**
6314
+ * `low` and above turn the reasoning phase on with chat's `reasoning_effort` budgets (256, 1,024,
6315
+ * 4,096 and 8,192 reasoning tokens for `low`, `medium`, `high`, `xhigh`; the node closes the
6316
+ * reasoning at the budget and the answer follows); unset, `none` and `minimal` leave it off.
6317
+ */
4179
6318
  effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | null;
4180
6319
  /** Accepted and ignored. */
4181
6320
  summary?: "auto" | "concise" | "detailed" | null;
@@ -4194,6 +6333,7 @@ export interface ResponsesRequest {
4194
6333
  user?: string | null;
4195
6334
  safety_identifier?: string | null;
4196
6335
  prompt_cache_key?: string | null;
6336
+ prompt_cache_retention?: string | null;
4197
6337
  service_tier?: string | null;
4198
6338
  /** `auto` is refused: the node never drops input items. */
4199
6339
  truncation?: "disabled" | null;
@@ -4341,7 +6481,13 @@ export interface WebhookSecret {
4341
6481
  object: "webhook_secret";
4342
6482
  /** The normalized endpoint URL. */
4343
6483
  url: string;
4344
- secret: string;
6484
+ /**
6485
+ * The signing secret. Present only in the response that hands it out (the first `POST
6486
+ * /v1/webhooks/secret` for the URL, or a rotation); `null` otherwise.
6487
+ */
6488
+ secret: string | null;
6489
+ /** The secret's last four characters, so you can tell which secret you stored. */
6490
+ secret_hint: string;
4345
6491
  /** Until when the previous secret still signs deliveries, after a rotation. */
4346
6492
  previous_valid_until: string | null;
4347
6493
  created_at: string;
@@ -4447,6 +6593,12 @@ export interface CurrentPrincipal {
4447
6593
  project_id: string;
4448
6594
  scopes: Scope[];
4449
6595
  spend_cap_usd: number | null;
6596
+ /**
6597
+ * What the key has spent this billing period (the UTC calendar month, from `spend_period_start`): its usage at the configured unit prices, the number a metered call's `402 spend_cap_exceeded` check compares with `spend_cap_usd`. Up to 10 seconds old. The free beta prices no usage yet, so it reads 0. Null for a dashboard session or a sandbox, which have no key of their own.
6598
+ */
6599
+ spend_usd?: number | null;
6600
+ /** Start of the billing period `spend_usd` covers. */
6601
+ spend_period_start?: string;
4450
6602
  expires_at: string | null;
4451
6603
  }
4452
6604
 
@@ -4609,6 +6761,15 @@ export interface RegistryPackVersion {
4609
6761
  */
4610
6762
  export type RequestConnection = "edge" | "uds" | "tcp" | "sandbox";
4611
6763
 
6764
+ /**
6765
+ * Who made the request: `api_key` (an API key), `cli_token` (the CLI's device-login token), `dashboard` (a
6766
+ * signed-in dashboard session; its successful reads are not logged, its changes and errors are), `sandbox` (code
6767
+ * inside a sandbox, as its creating key), `routine` (a routine run, as the key that published its version),
6768
+ * `local` (a host-local caller on the node's Unix socket) or `public` (no credential: a webhook or signed
6769
+ * callback to a public route, or a request refused before authentication).
6770
+ */
6771
+ export type RequestSource = "api_key" | "cli_token" | "dashboard" | "sandbox" | "routine" | "local" | "public";
6772
+
4612
6773
  export interface RequestPhase {
4613
6774
  name: string;
4614
6775
  source: "edge" | "node";
@@ -4625,6 +6786,12 @@ export interface RequestRecord {
4625
6786
  product: string | null;
4626
6787
  status_code: number;
4627
6788
  error_code: string | null;
6789
+ /**
6790
+ * Why a 4xx or 5xx answer failed, in the server's own words: the first 200 characters of its problem's
6791
+ * `detail` (or a compatibility surface's message). `null` for a success, or when the server recorded none;
6792
+ * absent from records written before it was recorded.
6793
+ */
6794
+ error_detail?: string | null;
4628
6795
  org_id: string;
4629
6796
  project_id: string;
4630
6797
  /** The API key behind the request (for sandbox calls, the key that created the sandbox). */
@@ -4647,32 +6814,301 @@ export interface RequestRecord {
4647
6814
  /** The W3C trace ID from `traceparent`, when sent. */
4648
6815
  trace_id: string | null;
4649
6816
  user_agent: string | null;
6817
+ source: RequestSource;
4650
6818
  }
4651
6819
 
4652
6820
  export type RequestRecordList = Omit<ListEnvelope, "data"> & {
4653
6821
  data: RequestRecord[];
4654
6822
  };
4655
6823
 
4656
- // ---------------------------------------------------------------- operation parameters and inline shapes
6824
+ /** Accepted and ignored. */
6825
+ export type AnthropicCacheControl = {
6826
+ type?: string;
6827
+ ttl?: string;
6828
+ } | null;
4657
6829
 
4658
- /** Parameters of `listBatches`. */
4659
- export interface VisionListBatchesParams {
4660
- /**
4661
- * Page size, from 1 to 100.
4662
- * @default 20
4663
- */
4664
- limit?: number;
4665
- /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
4666
- cursor?: string;
4667
- /** Only jobs with this status. */
4668
- status?: JobStatus;
4669
- }
6830
+ /**
6831
+ * Anthropic's context-editing beta (Claude Code and the Claude Agent SDK send it). Accepted and ignored: the
6832
+ * node clears nothing, so the model sees every turn you send and a conversation past the context window gets
6833
+ * `400 context_length_exceeded`. Only the shape is checked: an object whose `edits`, if present, are objects
6834
+ * with a string `type`.
6835
+ */
6836
+ export type AnthropicContextManagement = {
6837
+ edits?:
6838
+ | {
6839
+ type: string;
6840
+ }[]
6841
+ | null;
6842
+ } | null;
4670
6843
 
4671
- /** Parameters of `listBatchPages`. */
4672
- export interface VisionListBatchPagesParams {
4673
- /**
4674
- * Page size, from 1 to 100.
4675
- * @default 20
6844
+ export interface AnthropicTextBlock {
6845
+ type: "text";
6846
+ text: string;
6847
+ cache_control?: AnthropicCacheControl;
6848
+ /** Accepted and ignored. */
6849
+ citations?: Record<string, unknown>[] | null;
6850
+ }
6851
+
6852
+ export interface AnthropicImageBlock {
6853
+ type: "image";
6854
+ source:
6855
+ | {
6856
+ type: "base64";
6857
+ media_type: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
6858
+ /** The image file, which must be a PNG, JPEG, WebP or GIF. */
6859
+ data: string;
6860
+ }
6861
+ | {
6862
+ type: "url";
6863
+ /** Fetched by the node through its egress guard (PNG, JPEG, WebP or GIF, at most 10 MiB). */
6864
+ url: string;
6865
+ };
6866
+ cache_control?: AnthropicCacheControl;
6867
+ }
6868
+
6869
+ export interface AnthropicToolUseBlock {
6870
+ type: "tool_use";
6871
+ id: string;
6872
+ name: string;
6873
+ input: Record<string, unknown>;
6874
+ cache_control?: AnthropicCacheControl;
6875
+ }
6876
+
6877
+ export interface AnthropicToolResultBlock {
6878
+ type: "tool_result";
6879
+ tool_use_id: string;
6880
+ content?: null | string | Array<AnthropicTextBlock | AnthropicImageBlock>;
6881
+ /** The result is an error; the model sees it prefixed with `Error:`. */
6882
+ is_error?: boolean | null;
6883
+ cache_control?: AnthropicCacheControl;
6884
+ }
6885
+
6886
+ export interface AnthropicThinkingBlock {
6887
+ type: "thinking";
6888
+ thinking: string;
6889
+ /** Opaque; this node does not check it. */
6890
+ signature?: string | null;
6891
+ }
6892
+
6893
+ /** Accepted in assistant turns and left out of the prompt. */
6894
+ export interface AnthropicRedactedThinkingBlock {
6895
+ type: "redacted_thinking";
6896
+ data: string;
6897
+ }
6898
+
6899
+ export interface AnthropicUserMessage {
6900
+ role: "user";
6901
+ content: string | Array<AnthropicTextBlock | AnthropicImageBlock | AnthropicToolResultBlock>;
6902
+ }
6903
+
6904
+ /** An earlier answer; as the last message, the start of the answer, which the model continues. */
6905
+ export interface AnthropicAssistantMessage {
6906
+ role: "assistant";
6907
+ content:
6908
+ | string
6909
+ | Array<AnthropicTextBlock | AnthropicToolUseBlock | AnthropicThinkingBlock | AnthropicRedactedThinkingBlock>;
6910
+ }
6911
+
6912
+ export type AnthropicInputMessage = AnthropicUserMessage | AnthropicAssistantMessage;
6913
+
6914
+ /**
6915
+ * A custom tool. Tools Anthropic defines or runs (a `type` other than `custom`) are `unsupported_parameter`.
6916
+ */
6917
+ export interface AnthropicTool {
6918
+ type?: "custom" | null;
6919
+ /** Unique within `tools`. */
6920
+ name: string;
6921
+ description?: string | null;
6922
+ /** A JSON Schema object (at most 64 KiB serialized and 32 levels deep). */
6923
+ input_schema: Record<string, unknown>;
6924
+ strict?: boolean | null;
6925
+ cache_control?: AnthropicCacheControl;
6926
+ }
6927
+
6928
+ export type AnthropicToolChoice =
6929
+ | (Record<string, unknown> & {
6930
+ /** `any` makes the model call a tool (it needs `tools`). */
6931
+ type: "auto" | "any";
6932
+ disable_parallel_tool_use?: boolean | null;
6933
+ })
6934
+ | {
6935
+ type: "tool";
6936
+ /** One of `tools`. */
6937
+ name: string;
6938
+ disable_parallel_tool_use?: boolean | null;
6939
+ }
6940
+ | {
6941
+ type: "none";
6942
+ };
6943
+
6944
+ /**
6945
+ * `enabled` (with `budget_tokens`, at least 1024 and less than `max_tokens`) and `adaptive` let the model
6946
+ * reason first, in `thinking` blocks; `disabled`, the default, does not. The node closes the reasoning at
6947
+ * the budget and the answer follows in the same request: `budget_tokens`, or for `adaptive` the budget of
6948
+ * `output_config.effort` (`low` 256, `medium` 1,024, `high` 4,096, `xhigh` and `max` 8,192; `high` when
6949
+ * unset). `display` is accepted and ignored.
6950
+ */
6951
+ export type AnthropicThinking =
6952
+ | (Record<string, unknown> & {
6953
+ type: "enabled";
6954
+ budget_tokens: number;
6955
+ display?: "summarized" | "omitted" | "updates" | null;
6956
+ })
6957
+ | {
6958
+ type: "adaptive";
6959
+ display?: "summarized" | "omitted" | "updates" | null;
6960
+ }
6961
+ | {
6962
+ type: "disabled";
6963
+ };
6964
+
6965
+ /**
6966
+ * Anthropic Messages parameters. Any other parameter is `400 unsupported_parameter`; `null` means unset.
6967
+ */
6968
+ export interface AnthropicMessagesRequest {
6969
+ model: string;
6970
+ messages: AnthropicInputMessage[];
6971
+ max_tokens: number;
6972
+ /** The system prompt; text blocks are joined with blank lines. */
6973
+ system?: null | string | AnthropicTextBlock[];
6974
+ tools?: AnthropicTool[] | null;
6975
+ tool_choice?: null | AnthropicToolChoice;
6976
+ thinking?: null | AnthropicThinking;
6977
+ output_config?: {
6978
+ /** The answer is JSON matching `schema` (at most 64 KiB serialized and 32 levels deep). */
6979
+ format?: {
6980
+ type: "json_schema";
6981
+ /** A JSON Schema object, as Anthropic requires. */
6982
+ schema: Record<string, unknown>;
6983
+ } | null;
6984
+ /**
6985
+ * The reasoning budget of adaptive `thinking` (256, 1,024, 4,096 and 8,192 tokens for `low`, `medium`, `high`, `xhigh` and `max`); no effect without it.
6986
+ */
6987
+ effort?: "low" | "medium" | "high" | "xhigh" | "max" | null;
6988
+ } | null;
6989
+ stop_sequences?: string[] | null;
6990
+ stream?: boolean | null;
6991
+ temperature?: number | null;
6992
+ /**
6993
+ * Nucleus sampling. `0` keeps only the most probable token (passed to the runtime as 1e-9, the same thing, since vLLM takes values above 0 only).
6994
+ */
6995
+ top_p?: number | null;
6996
+ top_k?: number | null;
6997
+ /** Accepted and ignored. */
6998
+ metadata?: {
6999
+ user_id?: string | null;
7000
+ } | null;
7001
+ /** Accepted and ignored. */
7002
+ service_tier?: string | null;
7003
+ context_management?: AnthropicContextManagement;
7004
+ }
7005
+
7006
+ /** The input of a Messages request. Any other parameter is `400 unsupported_parameter`. */
7007
+ export interface AnthropicCountTokensRequest {
7008
+ model: string;
7009
+ messages: AnthropicInputMessage[];
7010
+ /** The system prompt; text blocks are joined with blank lines. */
7011
+ system?: null | string | AnthropicTextBlock[];
7012
+ tools?: AnthropicTool[] | null;
7013
+ tool_choice?: null | AnthropicToolChoice;
7014
+ thinking?: null | AnthropicThinking;
7015
+ context_management?: AnthropicContextManagement;
7016
+ }
7017
+
7018
+ export interface AnthropicCountTokens {
7019
+ input_tokens: number;
7020
+ }
7021
+
7022
+ export interface AnthropicUsage {
7023
+ /** Prompt tokens the prefix cache did not serve (all of them when the cache fields are absent). */
7024
+ input_tokens: number;
7025
+ output_tokens: number;
7026
+ /**
7027
+ * Always 0 when present. The runtime caches prompt prefixes on its own; nothing is written on request.
7028
+ */
7029
+ cache_creation_input_tokens?: number;
7030
+ /**
7031
+ * Prompt tokens the runtime's prefix cache served, from this organization's earlier requests (whole
7032
+ * 1,056-token blocks on b3os/qwen3.5-9b). The prompt's size is input_tokens plus the two cache fields.
7033
+ * Metering charges every prompt token.
7034
+ */
7035
+ cache_read_input_tokens?: number;
7036
+ }
7037
+
7038
+ /**
7039
+ * A block of the answer, `text`, `tool_use` (with `id`, `name`, `input`) or `thinking` (with `signature`).
7040
+ */
7041
+ export interface AnthropicOutputBlock {
7042
+ type: "text" | "tool_use" | "thinking";
7043
+ text?: string;
7044
+ id?: string;
7045
+ name?: string;
7046
+ input?: Record<string, unknown>;
7047
+ thinking?: string;
7048
+ signature?: string;
7049
+ }
7050
+
7051
+ export interface AnthropicMessage {
7052
+ id: string;
7053
+ type: "message";
7054
+ role: "assistant";
7055
+ content: AnthropicOutputBlock[];
7056
+ model: string;
7057
+ stop_reason: "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | "refusal";
7058
+ /** The stop sequence that ended the answer. */
7059
+ stop_sequence: string | null;
7060
+ usage: AnthropicUsage;
7061
+ b3os?: InferMeta;
7062
+ }
7063
+
7064
+ /**
7065
+ * One event of a stream, named by its `type` (the SSE `event:` field carries the same name):
7066
+ * `message_start` (`message`, with empty `content` and the input tokens), `content_block_start` (`index`,
7067
+ * `content_block`), `content_block_delta` (`index`, and a `delta` of type `text_delta`, `input_json_delta`,
7068
+ * `thinking_delta` or `signature_delta`), `content_block_stop` (`index`), `message_delta` (`delta` with
7069
+ * `stop_reason` and `stop_sequence`, and `usage`), `message_stop` (with the `b3os` metadata), or `error`.
7070
+ */
7071
+ export interface AnthropicStreamEvent {
7072
+ type:
7073
+ | "message_start"
7074
+ | "content_block_start"
7075
+ | "content_block_delta"
7076
+ | "content_block_stop"
7077
+ | "message_delta"
7078
+ | "message_stop"
7079
+ | "error";
7080
+ message?: Record<string, unknown>;
7081
+ index?: number;
7082
+ content_block?: Record<string, unknown>;
7083
+ delta?: Record<string, unknown>;
7084
+ usage?: Record<string, unknown>;
7085
+ error?: {
7086
+ type?: string;
7087
+ message?: string;
7088
+ };
7089
+ b3os?: InferMeta;
7090
+ }
7091
+
7092
+ // ---------------------------------------------------------------- operation parameters and inline shapes
7093
+
7094
+ /** Parameters of `listBatches`. */
7095
+ export interface VisionListBatchesParams {
7096
+ /**
7097
+ * Page size, from 1 to 100.
7098
+ * @default 20
7099
+ */
7100
+ limit?: number;
7101
+ /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
7102
+ cursor?: string;
7103
+ /** Only jobs with this status. */
7104
+ status?: JobStatus;
7105
+ }
7106
+
7107
+ /** Parameters of `listBatchPages`. */
7108
+ export interface VisionListBatchPagesParams {
7109
+ /**
7110
+ * Page size, from 1 to 100.
7111
+ * @default 20
4676
7112
  */
4677
7113
  limit?: number;
4678
7114
  /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
@@ -4747,6 +7183,16 @@ export interface VisionReadUrlParams {
4747
7183
  * @default 0
4748
7184
  */
4749
7185
  wait_for_ms?: number;
7186
+ /**
7187
+ * `true` checks robots.txt and Content Signals first (see `respect_robots` on scrape).
7188
+ * @default false
7189
+ */
7190
+ respect_robots?: boolean;
7191
+ /**
7192
+ * `bill` returns a wall's content and bills it like any page (see `walls` on scrape); by default a wall is free and the body is empty.
7193
+ * @default "free"
7194
+ */
7195
+ walls?: "free" | "bill";
4750
7196
  }
4751
7197
 
4752
7198
  /** Parameters of `listSessions`. */
@@ -4762,6 +7208,35 @@ export interface VisionListSessionsParams {
4762
7208
  status?: SessionStatus;
4763
7209
  }
4764
7210
 
7211
+ /** Parameters of `listBackgrounds`. */
7212
+ export interface RenderListBackgroundsParams {
7213
+ /** Only this pack's backgrounds (`GET /v1/render/backgrounds/packs` lists the packs). */
7214
+ pack?: string;
7215
+ /** Only light or only dark backgrounds (measured per image, not per pack). */
7216
+ theme?: "light" | "dark";
7217
+ /** Only CSS, only procedural (the studio pack) or only image backgrounds. */
7218
+ kind?: "css" | "procedural" | "image";
7219
+ /**
7220
+ * Only backgrounds with this tag (case-insensitive, whole tag). `video` lists the images the `auto` background picks from, on videos and styled screenshots; `auto` the studio meshes of the studio pick (`background: "studio"`, and `auto` when no image clears the page's edges).
7221
+ */
7222
+ tag?: string;
7223
+ /**
7224
+ * Only full-bleed backgrounds, or only transparent shapes (`cutout`, `partial`, `sliver`). CSS backgrounds are full-bleed.
7225
+ */
7226
+ coverage?: "full-bleed" | "partial" | "cutout" | "sliver";
7227
+ /** `true`: only the hand-picked images (`image.featured`); `false`: everything else. */
7228
+ featured?: boolean;
7229
+ /** Only backgrounds whose name, slug or tags contain this text (case-insensitive). */
7230
+ q?: string;
7231
+ /**
7232
+ * Page size, from 1 to 500.
7233
+ * @default 100
7234
+ */
7235
+ limit?: number;
7236
+ /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
7237
+ cursor?: string;
7238
+ }
7239
+
4765
7240
  /** Parameters of `listPresets`. */
4766
7241
  export interface RenderListPresetsParams {
4767
7242
  /** Only presets of this kind. */
@@ -4812,6 +7287,11 @@ export interface SandboxesListSandboxesParams {
4812
7287
  cursor?: string;
4813
7288
  /** Only sandboxes with this status. */
4814
7289
  status?: SandboxStatus;
7290
+ /**
7291
+ * Only sandboxes whose `metadata` holds each of these pairs, as `metadata[<key>]=<value>`: up to 4, all of
7292
+ * which must match exactly. Keys follow the `metadata` key rule (1 to 40 of `A-Z a-z 0-9 _ . : -`).
7293
+ */
7294
+ metadata?: Record<string, string>;
4815
7295
  }
4816
7296
 
4817
7297
  /** Parameters of `listSnapshots`. */
@@ -4825,15 +7305,26 @@ export interface SandboxesListSnapshotsParams {
4825
7305
  cursor?: string;
4826
7306
  }
4827
7307
 
7308
+ /** Parameters of `deleteFile`. */
7309
+ export interface SandboxesDeleteFileParams {
7310
+ /** Absolute path inside the sandbox. */
7311
+ path: string;
7312
+ /**
7313
+ * `1` deletes a directory and everything in it. `true` and `false` are sent as `1` and `0`.
7314
+ * @default 0
7315
+ */
7316
+ recursive?: boolean | 0 | 1;
7317
+ }
7318
+
4828
7319
  /** Parameters of `readFile`. */
4829
7320
  export interface SandboxesReadFileParams {
4830
7321
  /** Absolute path inside the sandbox. */
4831
7322
  path: string;
4832
7323
  /**
4833
- * `1` lists the directory instead of reading a file.
7324
+ * `1` lists the directory instead of reading a file. `true` and `false` are sent as `1` and `0`.
4834
7325
  * @default 0
4835
7326
  */
4836
- list?: 0 | 1;
7327
+ list?: boolean | 0 | 1;
4837
7328
  }
4838
7329
 
4839
7330
  /** Parameters of `writeFile`. */
@@ -4846,10 +7337,16 @@ export interface SandboxesWriteFileParams {
4846
7337
  */
4847
7338
  mode?: string;
4848
7339
  /**
4849
- * `1` creates missing parent directories.
7340
+ * `1` creates missing parent directories. `true` and `false` are sent as `1` and `0`.
4850
7341
  * @default 0
4851
7342
  */
4852
- mkdir?: 0 | 1;
7343
+ mkdir?: boolean | 0 | 1;
7344
+ }
7345
+
7346
+ /** Parameters of `statFile`. */
7347
+ export interface SandboxesStatFileParams {
7348
+ /** Absolute path inside the sandbox. */
7349
+ path: string;
4853
7350
  }
4854
7351
 
4855
7352
  /** Parameters of `streamLogs`. */
@@ -4872,6 +7369,29 @@ export interface SandboxesOpenPtyParams {
4872
7369
  /** Command to run instead of the login shell. */
4873
7370
  cmd?: string;
4874
7371
  cwd?: string;
7372
+ /**
7373
+ * `new` for a terminal that can be reattached, or the id of one (`pts_...`) to attach to again. `cmd` and
7374
+ * `cwd` apply only to a new terminal.
7375
+ */
7376
+ session?: string;
7377
+ }
7378
+
7379
+ /** Parameters of `listRequests`. */
7380
+ export interface SandboxesListRequestsParams {
7381
+ /**
7382
+ * Page size, from 1 to 100.
7383
+ * @default 20
7384
+ */
7385
+ limit?: number;
7386
+ /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
7387
+ cursor?: string;
7388
+ product?: string;
7389
+ operation_id?: string;
7390
+ /** Only requests that succeeded (`2xx`) or failed (`4xx`, `5xx`). */
7391
+ status?: "2xx" | "4xx" | "5xx";
7392
+ /** Only requests of this W3C trace (the trace id of their `traceparent`). */
7393
+ trace_id?: string;
7394
+ since?: string;
4875
7395
  }
4876
7396
 
4877
7397
  /** Parameters of `listRoutines`. */
@@ -4896,6 +7416,23 @@ export interface RoutinesListRunStepsParams {
4896
7416
  cursor?: string;
4897
7417
  }
4898
7418
 
7419
+ /** Parameters of `getWait`. */
7420
+ export interface RoutinesGetWaitParams {
7421
+ /** Preselect a decision on the page (HTML only); nothing is answered until the person confirms. */
7422
+ decision?: "approve" | "reject";
7423
+ }
7424
+
7425
+ /** Parameters of `listHookDeliveries`. */
7426
+ export interface RoutinesListHookDeliveriesParams {
7427
+ /**
7428
+ * Page size, from 1 to 100.
7429
+ * @default 20
7430
+ */
7431
+ limit?: number;
7432
+ /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
7433
+ cursor?: string;
7434
+ }
7435
+
4899
7436
  /** Parameters of `listRuns`. */
4900
7437
  export interface RoutinesListRunsParams {
4901
7438
  /**
@@ -4922,7 +7459,7 @@ export interface RoutinesListVersionsParams {
4922
7459
 
4923
7460
  /** Parameters of `describe`. */
4924
7461
  export interface ActionsDescribeParams {
4925
- /** `<namespace>/<name>/<action>@<version>`; the version may be exact (`1.2.0`) or a major (`1`). */
7462
+ /** `<namespace>/<name>/<action>@<version>`; the version may be exact (`1.0.0`) or a major (`1`). */
4926
7463
  ref: ActionRef;
4927
7464
  }
4928
7465
 
@@ -4945,6 +7482,18 @@ export interface ActionsGetPackParams {
4945
7482
  version?: string;
4946
7483
  }
4947
7484
 
7485
+ /** Parameters of `getPackTools` (header parameters are sent as their `X-B3OS-*` headers). */
7486
+ export interface ActionsGetPackToolsParams {
7487
+ /** An exact version or a range such as `1` or `^1.2`; the latest by default. */
7488
+ version?: string;
7489
+ /** The most a listed tool may do. `read` lists `pure` and `read` actions only. */
7490
+ effects?: EffectClass;
7491
+ /** Only these action keys, comma-separated (`post-message,list-channels`). An unknown key is a 400. */
7492
+ actions?: string;
7493
+ /** The `ETag` of a response you hold. */
7494
+ if_none_match?: string;
7495
+ }
7496
+
4948
7497
  /** Parameters of `listRegistryPacks`. */
4949
7498
  export interface PlatformListRegistryPacksParams {
4950
7499
  /**
@@ -4964,8 +7513,13 @@ export interface ActionsSearchParams {
4964
7513
  q: string;
4965
7514
  /** Only actions of this pack (`io.b3os/github`). */
4966
7515
  pack?: string;
4967
- /** Only actions with this effect class. */
7516
+ /** Only actions with this effect class. Triggers have no effect class, so it never removes one. */
4968
7517
  effects?: EffectClass;
7518
+ /**
7519
+ * `action` (the default), `trigger`, or `any` for both.
7520
+ * @default "action"
7521
+ */
7522
+ kind?: "action" | "trigger" | "any";
4969
7523
  /**
4970
7524
  * Results to return, from 1 to 50.
4971
7525
  * @default 10
@@ -5087,8 +7641,16 @@ export interface PlatformListRequestsParams {
5087
7641
  key_id?: string;
5088
7642
  /** Only requests that arrived this way. */
5089
7643
  connection?: RequestConnection;
7644
+ /**
7645
+ * Only requests from this source, or from any of a comma-separated list of them (`api_key,cli_token`), each a `RequestSource` value at most once. Leave `dashboard` out of the list to hide what the dashboard did.
7646
+ */
7647
+ source?: string;
5090
7648
  /** Only requests made from inside this sandbox. */
5091
7649
  sandbox_id?: string;
7650
+ /**
7651
+ * Only requests of this W3C trace (the trace id of their `traceparent`): one chain of calls, such as a scrape, then a render, then a sandbox exec, made with one traceparent.
7652
+ */
7653
+ trace_id?: string;
5092
7654
  since?: string;
5093
7655
  }
5094
7656