@b3os/cli 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/README.md +87 -8
  2. package/assets/b3os-run.py +137 -0
  3. package/assets/skill/b3os/SKILL.md +111 -0
  4. package/dist/commands/_agents.d.ts +14 -0
  5. package/dist/commands/_agents.js +33 -0
  6. package/dist/commands/_agents.js.map +1 -0
  7. package/dist/commands/_common.js +6 -2
  8. package/dist/commands/_common.js.map +1 -1
  9. package/dist/commands/_context.d.ts +49 -0
  10. package/dist/commands/_context.js +260 -0
  11. package/dist/commands/_context.js.map +1 -0
  12. package/dist/commands/_next.d.ts +39 -0
  13. package/dist/commands/_next.js +77 -0
  14. package/dist/commands/_next.js.map +1 -0
  15. package/dist/commands/agent.d.ts +42 -0
  16. package/dist/commands/agent.js +218 -0
  17. package/dist/commands/agent.js.map +1 -0
  18. package/dist/commands/app.d.ts +2 -5
  19. package/dist/commands/app.js +229 -69
  20. package/dist/commands/app.js.map +1 -1
  21. package/dist/commands/auth.d.ts +70 -2
  22. package/dist/commands/auth.js +308 -33
  23. package/dist/commands/auth.js.map +1 -1
  24. package/dist/commands/docs.d.ts +54 -0
  25. package/dist/commands/docs.js +202 -0
  26. package/dist/commands/docs.js.map +1 -0
  27. package/dist/commands/doctor.d.ts +23 -0
  28. package/dist/commands/doctor.js +313 -0
  29. package/dist/commands/doctor.js.map +1 -0
  30. package/dist/commands/init.d.ts +38 -1
  31. package/dist/commands/init.js +259 -60
  32. package/dist/commands/init.js.map +1 -1
  33. package/dist/commands/listen.d.ts +30 -0
  34. package/dist/commands/listen.js +194 -0
  35. package/dist/commands/listen.js.map +1 -0
  36. package/dist/commands/manifest.d.ts +13 -1
  37. package/dist/commands/manifest.js +59 -7
  38. package/dist/commands/manifest.js.map +1 -1
  39. package/dist/commands/mcp.d.ts +25 -2
  40. package/dist/commands/mcp.js +120 -11
  41. package/dist/commands/mcp.js.map +1 -1
  42. package/dist/commands/sandbox.d.ts +35 -6
  43. package/dist/commands/sandbox.js +208 -9
  44. package/dist/commands/sandbox.js.map +1 -1
  45. package/dist/commands/setup.d.ts +39 -0
  46. package/dist/commands/setup.js +203 -0
  47. package/dist/commands/setup.js.map +1 -0
  48. package/dist/commands/tool.d.ts +109 -1
  49. package/dist/commands/tool.js +635 -47
  50. package/dist/commands/tool.js.map +1 -1
  51. package/dist/config.d.ts +30 -6
  52. package/dist/config.js +39 -8
  53. package/dist/config.js.map +1 -1
  54. package/dist/ctx.d.ts +5 -45
  55. package/dist/ctx.js +25 -160
  56. package/dist/ctx.js.map +1 -1
  57. package/dist/docs/index.json +1 -0
  58. package/dist/docs/pages/actions/call.md +300 -0
  59. package/dist/docs/pages/actions/catalog/airtable.md +737 -0
  60. package/dist/docs/pages/actions/catalog/arxiv.md +166 -0
  61. package/dist/docs/pages/actions/catalog/chainalysis-sanctions.md +125 -0
  62. package/dist/docs/pages/actions/catalog/coingecko.md +1558 -0
  63. package/dist/docs/pages/actions/catalog/deps-dev.md +465 -0
  64. package/dist/docs/pages/actions/catalog/dexscreener.md +568 -0
  65. package/dist/docs/pages/actions/catalog/discord.md +784 -0
  66. package/dist/docs/pages/actions/catalog/finnhub.md +776 -0
  67. package/dist/docs/pages/actions/catalog/frankfurter.md +438 -0
  68. package/dist/docs/pages/actions/catalog/github.md +1853 -0
  69. package/dist/docs/pages/actions/catalog/gmail.md +575 -0
  70. package/dist/docs/pages/actions/catalog/google-calendar.md +654 -0
  71. package/dist/docs/pages/actions/catalog/google-drive.md +502 -0
  72. package/dist/docs/pages/actions/catalog/google-sheets.md +700 -0
  73. package/dist/docs/pages/actions/catalog/hacker-news.md +542 -0
  74. package/dist/docs/pages/actions/catalog/http.md +824 -0
  75. package/dist/docs/pages/actions/catalog/hyperliquid.md +942 -0
  76. package/dist/docs/pages/actions/catalog/jira.md +920 -0
  77. package/dist/docs/pages/actions/catalog/kalshi.md +917 -0
  78. package/dist/docs/pages/actions/catalog/linear.md +1030 -0
  79. package/dist/docs/pages/actions/catalog/markets.md +21 -0
  80. package/dist/docs/pages/actions/catalog/morpho.md +247 -0
  81. package/dist/docs/pages/actions/catalog/notion.md +1077 -0
  82. package/dist/docs/pages/actions/catalog/nws.md +485 -0
  83. package/dist/docs/pages/actions/catalog/open-meteo.md +559 -0
  84. package/dist/docs/pages/actions/catalog/polymarket.md +1523 -0
  85. package/dist/docs/pages/actions/catalog/pushbullet.md +220 -0
  86. package/dist/docs/pages/actions/catalog/resend.md +307 -0
  87. package/dist/docs/pages/actions/catalog/s3.md +513 -0
  88. package/dist/docs/pages/actions/catalog/sec-edgar.md +487 -0
  89. package/dist/docs/pages/actions/catalog/slack.md +2629 -0
  90. package/dist/docs/pages/actions/catalog/stripe.md +1405 -0
  91. package/dist/docs/pages/actions/catalog/wikipedia.md +379 -0
  92. package/dist/docs/pages/actions/catalog.md +46 -0
  93. package/dist/docs/pages/actions/limits.md +50 -0
  94. package/dist/docs/pages/actions/model-tools.md +225 -0
  95. package/dist/docs/pages/actions/packs.md +148 -0
  96. package/dist/docs/pages/actions/settings.md +69 -0
  97. package/dist/docs/pages/actions/tools.md +244 -0
  98. package/dist/docs/pages/actions/triggers.md +149 -0
  99. package/dist/docs/pages/actions.md +88 -0
  100. package/dist/docs/pages/compat/anthropic.md +168 -0
  101. package/dist/docs/pages/compat/e2b.md +194 -0
  102. package/dist/docs/pages/compat/firecrawl.md +138 -0
  103. package/dist/docs/pages/compat/openai.md +168 -0
  104. package/dist/docs/pages/concepts/auth.md +151 -0
  105. package/dist/docs/pages/concepts/beta.md +55 -0
  106. package/dist/docs/pages/concepts/glossary.md +71 -0
  107. package/dist/docs/pages/concepts/ids.md +98 -0
  108. package/dist/docs/pages/concepts/jobs.md +229 -0
  109. package/dist/docs/pages/concepts/latency.md +138 -0
  110. package/dist/docs/pages/concepts/limits.md +191 -0
  111. package/dist/docs/pages/concepts/stack.md +59 -0
  112. package/dist/docs/pages/concepts/timing.md +86 -0
  113. package/dist/docs/pages/concepts/usage.md +110 -0
  114. package/dist/docs/pages/design/b3os-yaml.md +370 -0
  115. package/dist/docs/pages/design/deploy-from-github.md +122 -0
  116. package/dist/docs/pages/design/observability.md +134 -0
  117. package/dist/docs/pages/errors.md +1824 -0
  118. package/dist/docs/pages/infer/chat.md +570 -0
  119. package/dist/docs/pages/infer/limits.md +55 -0
  120. package/dist/docs/pages/infer/messages.md +185 -0
  121. package/dist/docs/pages/infer/responses.md +173 -0
  122. package/dist/docs/pages/infer/settings.md +154 -0
  123. package/dist/docs/pages/infer/speech.md +323 -0
  124. package/dist/docs/pages/infer.md +154 -0
  125. package/dist/docs/pages/introduction.md +162 -0
  126. package/dist/docs/pages/platform/addresses.md +174 -0
  127. package/dist/docs/pages/platform/call-log.md +99 -0
  128. package/dist/docs/pages/platform/custom-domains.md +104 -0
  129. package/dist/docs/pages/platform/keys.md +79 -0
  130. package/dist/docs/pages/platform/limits.md +57 -0
  131. package/dist/docs/pages/platform/members.md +101 -0
  132. package/dist/docs/pages/platform/requests.md +116 -0
  133. package/dist/docs/pages/platform/settings.md +129 -0
  134. package/dist/docs/pages/platform/webhooks.md +68 -0
  135. package/dist/docs/pages/platform.md +67 -0
  136. package/dist/docs/pages/quickstart/mcp.md +94 -0
  137. package/dist/docs/pages/quickstart/sandbox-agent.md +205 -0
  138. package/dist/docs/pages/quickstart/scrape.md +134 -0
  139. package/dist/docs/pages/quickstart.md +45 -0
  140. package/dist/docs/pages/render/inspections.md +162 -0
  141. package/dist/docs/pages/render/limits.md +72 -0
  142. package/dist/docs/pages/render/screenshots.md +179 -0
  143. package/dist/docs/pages/render/settings.md +431 -0
  144. package/dist/docs/pages/render/styles.md +342 -0
  145. package/dist/docs/pages/render/videos.md +272 -0
  146. package/dist/docs/pages/render.md +118 -0
  147. package/dist/docs/pages/routines/callables.md +174 -0
  148. package/dist/docs/pages/routines/definitions.md +361 -0
  149. package/dist/docs/pages/routines/limits.md +117 -0
  150. package/dist/docs/pages/routines/runs.md +328 -0
  151. package/dist/docs/pages/routines/settings.md +104 -0
  152. package/dist/docs/pages/routines/triggers.md +339 -0
  153. package/dist/docs/pages/routines.md +216 -0
  154. package/dist/docs/pages/sandboxes/agents.md +217 -0
  155. package/dist/docs/pages/sandboxes/commands.md +272 -0
  156. package/dist/docs/pages/sandboxes/images.md +166 -0
  157. package/dist/docs/pages/sandboxes/limits.md +143 -0
  158. package/dist/docs/pages/sandboxes/ports.md +260 -0
  159. package/dist/docs/pages/sandboxes/settings.md +358 -0
  160. package/dist/docs/pages/sandboxes/snapshots.md +423 -0
  161. package/dist/docs/pages/sandboxes/swarms.md +146 -0
  162. package/dist/docs/pages/sandboxes/volumes.md +131 -0
  163. package/dist/docs/pages/sandboxes.md +231 -0
  164. package/dist/docs/pages/sdks/cli.md +121 -0
  165. package/dist/docs/pages/sdks/mcp.md +169 -0
  166. package/dist/docs/pages/sdks/python.md +146 -0
  167. package/dist/docs/pages/sdks/typescript.md +202 -0
  168. package/dist/docs/pages/sdks.md +282 -0
  169. package/dist/docs/pages/settings.md +33 -0
  170. package/dist/docs/pages/vault/limits.md +46 -0
  171. package/dist/docs/pages/vault.md +133 -0
  172. package/dist/docs/pages/vision/agent-browser.md +115 -0
  173. package/dist/docs/pages/vision/crawl.md +333 -0
  174. package/dist/docs/pages/vision/extract.md +152 -0
  175. package/dist/docs/pages/vision/fetcher.md +15 -0
  176. package/dist/docs/pages/vision/limits.md +79 -0
  177. package/dist/docs/pages/vision/profiles.md +111 -0
  178. package/dist/docs/pages/vision/proxy.md +131 -0
  179. package/dist/docs/pages/vision/scrape.md +356 -0
  180. package/dist/docs/pages/vision/sessions.md +311 -0
  181. package/dist/docs/pages/vision/settings.md +656 -0
  182. package/dist/docs/pages/vision.md +175 -0
  183. package/dist/errors.d.ts +129 -0
  184. package/dist/errors.js +326 -0
  185. package/dist/errors.js.map +1 -0
  186. package/dist/main.d.ts +1 -1
  187. package/dist/main.js +26 -13
  188. package/dist/main.js.map +1 -1
  189. package/dist/manifest/domains.d.ts +50 -0
  190. package/dist/manifest/domains.js +159 -0
  191. package/dist/manifest/domains.js.map +1 -0
  192. package/dist/manifest/link.d.ts +20 -0
  193. package/dist/manifest/link.js +24 -0
  194. package/dist/manifest/link.js.map +1 -0
  195. package/dist/manifest/record.d.ts +1 -1
  196. package/dist/tool/archive.d.ts +33 -0
  197. package/dist/tool/archive.js +174 -0
  198. package/dist/tool/archive.js.map +1 -0
  199. package/dist/tool/calls.d.ts +46 -0
  200. package/dist/tool/calls.js +274 -0
  201. package/dist/tool/calls.js.map +1 -0
  202. package/dist/tool/checks.d.ts +21 -0
  203. package/dist/tool/checks.js +145 -0
  204. package/dist/tool/checks.js.map +1 -0
  205. package/dist/tool/elf.d.ts +19 -0
  206. package/dist/tool/elf.js +107 -0
  207. package/dist/tool/elf.js.map +1 -0
  208. package/dist/tool/predict.d.ts +8 -0
  209. package/dist/tool/predict.js +38 -0
  210. package/dist/tool/predict.js.map +1 -0
  211. package/dist/tool/ustar.d.ts +5 -0
  212. package/dist/tool/ustar.js +220 -0
  213. package/dist/tool/ustar.js.map +1 -0
  214. package/package.json +6 -5
@@ -0,0 +1,174 @@
1
+ # Product steps
2
+
3
+ > Every product operation a routine step can call, with its with, outputs, effect class, kind and meter. Generated from the API spec.
4
+
5
+ Source: https://docs.beta.b3os.org/routines/callables.md
6
+
7
+ A routine step calls a product operation with `uses: <product>/<step>@<major>`. Its `with` is the operation's request body plus one field for each path or query parameter, and its outputs are the response body, or, for a job, the finished job record. This page is generated from the API spec, the same source the node builds its table from. Steps run as the key that published the routine version, so that key needs each operation's scope.
8
+
9
+ **Kind.** A `sync` step makes one request. A `job` step creates a job, waits for it without holding a step slot, and outputs the finished job; canceling the run cancels the job. **Effect.** `read` steps retry under `defaults.retry`; `write` steps retry only when the step sets its own `retry` ([Steps](https://docs.beta.b3os.org/routines/definitions#steps)). **Idempotency-Key.** Every product step sends `<run id>:<step id>`; the operations marked yes return the stored response to a repeat instead of running again ([FAQ](https://docs.beta.b3os.org/routines/limits#faq)).
10
+
11
+ | Step | Kind | Effect | Operation | Meter | Dedupes on Idempotency-Key |
12
+ |---|---|---|---|---|---|
13
+ | `vision/scrape@1` | sync | read | [`POST /v1/vision/scrape`](https://docs.beta.b3os.org/api/post-v1-vision-scrape) | `vision.page`, `vision.proxy_bytes` | no |
14
+ | `vision/map@1` | sync | read | [`POST /v1/vision/map`](https://docs.beta.b3os.org/api/post-v1-vision-map) | `vision.page` | no |
15
+ | `vision/crawl@1` | job | read | [`POST /v1/vision/crawls`](https://docs.beta.b3os.org/api/post-v1-vision-crawls) | `vision.page` | yes |
16
+ | `vision/batch@1` | job | read | [`POST /v1/vision/batches`](https://docs.beta.b3os.org/api/post-v1-vision-batches) | `vision.page` | yes |
17
+ | `vision/act@1` | sync | write | [`POST /v1/vision/sessions/{session_id}/act`](https://docs.beta.b3os.org/api/post-v1-vision-sessions-session-id-act) | none | no |
18
+ | `vision/extract@1` | job | read | [`POST /v1/vision/extracts`](https://docs.beta.b3os.org/api/post-v1-vision-extracts) | `vision.page`, `infer.input_tokens`, `infer.output_tokens` | yes |
19
+ | `render/screenshot@1` | sync | read | [`POST /v1/render/screenshots`](https://docs.beta.b3os.org/api/post-v1-render-screenshots) | `render.screenshot` | yes |
20
+ | `render/video@1` | job | read | [`POST /v1/render/videos`](https://docs.beta.b3os.org/api/post-v1-render-videos) | `render.video_s` | yes |
21
+ | `render/restyle@1` | job | read | [`POST /v1/render/videos/{video_id}/restyle`](https://docs.beta.b3os.org/api/post-v1-render-videos-video-id-restyle) | `render.video_s` | yes |
22
+ | `sandboxes/create@1` | sync | write | [`POST /v1/sandboxes`](https://docs.beta.b3os.org/api/post-v1-sandboxes) | `sandboxes.vcpu_ms`, `sandboxes.gib_ms` | yes |
23
+ | `sandboxes/exec@1` | sync | write | [`POST /v1/sandboxes/{sandbox_id}/exec`](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-exec) | none | yes |
24
+ | `sandboxes/read_file@1` | sync | read | [`GET /v1/sandboxes/{sandbox_id}/files`](https://docs.beta.b3os.org/api/get-v1-sandboxes-sandbox-id-files) | none | no |
25
+ | `sandboxes/write_file@1` | sync | write | [`PUT /v1/sandboxes/{sandbox_id}/files`](https://docs.beta.b3os.org/api/put-v1-sandboxes-sandbox-id-files) | none | no |
26
+ | `sandboxes/run_code@1` | sync | write | [`POST /v1/sandboxes/{sandbox_id}/run_code`](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-run-code) | none | no |
27
+ | `sandboxes/snapshot@1` | sync | write | [`POST /v1/sandboxes/{sandbox_id}/snapshot`](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-snapshot) | none | yes |
28
+ | `sandboxes/fork@1` | sync | write | [`POST /v1/sandboxes/{sandbox_id}/fork`](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-fork) | `sandboxes.vcpu_ms`, `sandboxes.gib_ms` | yes |
29
+ | `sandboxes/delete@1` | sync | write | [`DELETE /v1/sandboxes/{sandbox_id}`](https://docs.beta.b3os.org/api/delete-v1-sandboxes-sandbox-id-) | none | no |
30
+ | `infer/chat@1` | sync | read | [`POST /v1/infer/chat/completions`](https://docs.beta.b3os.org/api/post-v1-infer-chat-completions) | `infer.input_tokens`, `infer.output_tokens` | no |
31
+ | `infer/speech@1` | sync | read | [`POST /v1/infer/audio/speech`](https://docs.beta.b3os.org/api/post-v1-infer-audio-speech) | `infer.audio_chars` | no |
32
+ | `vision/search@1` | sync | read | [`POST /v1/vision/search`](https://docs.beta.b3os.org/api/post-v1-vision-search) | `vision.page` | no |
33
+ | `sandboxes/swarm@1` | job | write | [`POST /v1/sandboxes/swarms`](https://docs.beta.b3os.org/api/post-v1-sandboxes-swarms) | `sandboxes.vcpu_ms`, `sandboxes.gib_ms` | yes |
34
+ | `infer/embed@1` | sync | read | `POST /v1/infer/embeddings` (not in the API reference yet) | `infer.embed_tokens` | no |
35
+ | `infer/rerank@1` | sync | read | `POST /v1/infer/rerank` (not in the API reference yet) | `infer.rerank_tokens` | no |
36
+
37
+ ## Byte answers
38
+
39
+ `sandboxes/read_file@1` and `infer/speech@1` answer with bytes; each one's outputs are below. The step reads at most 768 KiB of bytes, three quarters of the 1 MiB step output limit (`max_step_output_bytes`, [limits](https://docs.beta.b3os.org/routines/limits)), so their base64 fits a step's output; a larger answer fails the step with `502 upstream_too_large`. A step reads the whole answer, so a `stream_format` in `with` fails the step with `400 invalid_request`.
40
+
41
+ ## Vision
42
+
43
+ What each operation does is on the [Vision](https://docs.beta.b3os.org/vision) pages and in its API reference.
44
+
45
+ **`vision/scrape@1`** calls [`POST /v1/vision/scrape`](https://docs.beta.b3os.org/api/post-v1-vision-scrape) (scope `vision:run`).
46
+
47
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-vision-scrape) (required: `url`).
48
+ - Outputs: the response body (`ScrapeResult`).
49
+
50
+ **`vision/map@1`** calls [`POST /v1/vision/map`](https://docs.beta.b3os.org/api/post-v1-vision-map) (scope `vision:run`).
51
+
52
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-vision-map) (required: `url`).
53
+ - Outputs: the response body (`MapResult`).
54
+
55
+ **`vision/crawl@1`** calls [`POST /v1/vision/crawls`](https://docs.beta.b3os.org/api/post-v1-vision-crawls) (scope `vision:run`).
56
+
57
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-vision-crawls) (required: `url`).
58
+ - Outputs: the finished job record, as `GET /v1/vision/crawls/{crawl_id}` returns it.
59
+
60
+ **`vision/batch@1`** calls [`POST /v1/vision/batches`](https://docs.beta.b3os.org/api/post-v1-vision-batches) (scope `vision:run`).
61
+
62
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-vision-batches) (required: `urls`).
63
+ - Outputs: the finished job record, as `GET /v1/vision/batches/{batch_id}` returns it.
64
+
65
+ **`vision/act@1`** calls [`POST /v1/vision/sessions/{session_id}/act`](https://docs.beta.b3os.org/api/post-v1-vision-sessions-session-id-act) (scope `vision:run`).
66
+
67
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-vision-sessions-session-id-act) (required: `actions`) and `session` for the path parameter `session_id` (optional).
68
+ - Outputs: the response body (`ActResult`).
69
+ - `session` is optional: without it the step acts in a browser session made for it and closed after it, also when it fails or times out, and `profile` loads a saved profile into that session.
70
+
71
+ **`vision/extract@1`** calls [`POST /v1/vision/extracts`](https://docs.beta.b3os.org/api/post-v1-vision-extracts) (scopes `vision:run` and `infer:run`).
72
+
73
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-vision-extracts) (required: `urls`).
74
+ - Outputs: the finished job record, as `GET /v1/vision/extracts/{job_id}` returns it.
75
+ - The routine's key needs `infer:run` as well as `vision:run`: the model reads the pages as that key, through Infer; without `infer:run` the step fails with `403 forbidden` before anything runs or bills.
76
+
77
+ **`vision/search@1`** calls [`POST /v1/vision/search`](https://docs.beta.b3os.org/api/post-v1-vision-search) (scope `vision:run`).
78
+
79
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-vision-search) (required: `query`).
80
+ - Outputs: the response body (`SearchResult`).
81
+ - Outputs are the whole answer: `steps.<id>.outputs.results` is the list, beside `warnings` and `timing`. The step waits the operation's 65 seconds, which covers a search's longest `with.timeout_ms` (60 seconds, its scrapes included), unless it sets its own `timeout_ms` or the routine writes `defaults.timeout_ms`: keep either a few seconds above `with.timeout_ms`. The search does not dedupe on the key: a retry searches and bills again.
82
+
83
+ ## Render
84
+
85
+ What each operation does is on the [Render](https://docs.beta.b3os.org/render) pages and in its API reference.
86
+
87
+ **`render/screenshot@1`** calls [`POST /v1/render/screenshots`](https://docs.beta.b3os.org/api/post-v1-render-screenshots) (scope `render:run`).
88
+
89
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-render-screenshots) (no field is required).
90
+ - Outputs: the response body (`Screenshot`).
91
+
92
+ **`render/video@1`** calls [`POST /v1/render/videos`](https://docs.beta.b3os.org/api/post-v1-render-videos) (scope `render:run`).
93
+
94
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-render-videos) (required: `source`).
95
+ - Outputs: the finished job record, as `GET /v1/render/videos/{video_id}` returns it.
96
+
97
+ **`render/restyle@1`** calls [`POST /v1/render/videos/{video_id}/restyle`](https://docs.beta.b3os.org/api/post-v1-render-videos-video-id-restyle) (scope `render:run`).
98
+
99
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-render-videos-video-id-restyle) (no field is required) and `video` for the path parameter `video_id`.
100
+ - Outputs: the finished job record, as `GET /v1/render/videos/{video_id}` returns it.
101
+
102
+ ## Sandboxes
103
+
104
+ What each operation does is on the [Sandboxes](https://docs.beta.b3os.org/sandboxes) pages and in its API reference.
105
+
106
+ **`sandboxes/create@1`** calls [`POST /v1/sandboxes`](https://docs.beta.b3os.org/api/post-v1-sandboxes) (scope `sandboxes:write`).
107
+
108
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-sandboxes) (no field is required).
109
+ - Outputs: the response body (`Sandbox`).
110
+
111
+ **`sandboxes/exec@1`** calls [`POST /v1/sandboxes/{sandbox_id}/exec`](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-exec) (scope `sandboxes:run`).
112
+
113
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-exec) (required: `cmd`) and `sandbox` for the path parameter `sandbox_id`.
114
+ - Outputs: the response body (`ExecResult`).
115
+ - Give `sandbox` to run in an existing sandbox, or `template` instead to run in a sandbox made for the step and deleted after it; `create` then takes the rest of that sandbox's create request. See [Steps](https://docs.beta.b3os.org/routines/definitions#steps).
116
+
117
+ **`sandboxes/read_file@1`** calls [`GET /v1/sandboxes/{sandbox_id}/files`](https://docs.beta.b3os.org/api/get-v1-sandboxes-sandbox-id-files) (scope `sandboxes:run`).
118
+
119
+ - `with`: `sandbox` for the path parameter `sandbox_id`, `path` for the query parameter `path` and `list` for the query parameter `list` (optional).
120
+ - Outputs: the answer's bytes as `content_type`, `size`, `sha256` and either `content` (text that is valid UTF-8) or `content_base64` (audio, images, video and anything else); an answer in JSON (`FileEntryList`) is the outputs as it is (see [byte answers](#byte-answers)).
121
+
122
+ **`sandboxes/write_file@1`** calls [`PUT /v1/sandboxes/{sandbox_id}/files`](https://docs.beta.b3os.org/api/put-v1-sandboxes-sandbox-id-files) (scope `sandboxes:run`).
123
+
124
+ - `with`: the bytes as exactly one of `content` (text, sent as UTF-8) or `content_base64` (decoded), `sandbox` for the path parameter `sandbox_id`, `path` for the query parameter `path`, `mode` for the query parameter `mode` (optional) and `mkdir` for the query parameter `mkdir` (optional).
125
+ - Outputs: the response body (`FileEntry`).
126
+
127
+ **`sandboxes/run_code@1`** calls [`POST /v1/sandboxes/{sandbox_id}/run_code`](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-run-code) (scope `sandboxes:run`).
128
+
129
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-run-code) (required: `code`) and `sandbox` for the path parameter `sandbox_id`.
130
+ - Outputs: the response body (`RunCodeResult`).
131
+
132
+ **`sandboxes/snapshot@1`** calls [`POST /v1/sandboxes/{sandbox_id}/snapshot`](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-snapshot) (scope `sandboxes:write`).
133
+
134
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-snapshot) (no field is required) and `sandbox` for the path parameter `sandbox_id`.
135
+ - Outputs: the response body (`Snapshot`).
136
+
137
+ **`sandboxes/fork@1`** calls [`POST /v1/sandboxes/{sandbox_id}/fork`](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-fork) (scope `sandboxes:write`).
138
+
139
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-fork) (no field is required) and `sandbox` for the path parameter `sandbox_id`.
140
+ - Outputs: the response body (`SandboxList`).
141
+
142
+ **`sandboxes/delete@1`** calls [`DELETE /v1/sandboxes/{sandbox_id}`](https://docs.beta.b3os.org/api/delete-v1-sandboxes-sandbox-id-) (scope `sandboxes:write`).
143
+
144
+ - `with`: `sandbox` for the path parameter `sandbox_id`.
145
+ - Outputs: the response body (`Sandbox`).
146
+
147
+ **`sandboxes/swarm@1`** calls [`POST /v1/sandboxes/swarms`](https://docs.beta.b3os.org/api/post-v1-sandboxes-swarms) (scope `sandboxes:write`).
148
+
149
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-sandboxes-swarms) (required: `from`).
150
+ - Outputs: the finished job record, as `GET /v1/sandboxes/swarms/{swarm_id}` returns it.
151
+
152
+ ## Infer
153
+
154
+ What each operation does is on the [Infer](https://docs.beta.b3os.org/infer) pages and in its API reference.
155
+
156
+ **`infer/chat@1`** calls [`POST /v1/infer/chat/completions`](https://docs.beta.b3os.org/api/post-v1-infer-chat-completions) (scope `infer:run`).
157
+
158
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-infer-chat-completions) (required: `model` and `messages`).
159
+ - Outputs: the response body (`ChatCompletion`).
160
+
161
+ **`infer/speech@1`** calls [`POST /v1/infer/audio/speech`](https://docs.beta.b3os.org/api/post-v1-infer-audio-speech) (scope `infer:run`).
162
+
163
+ - `with`: the [request body](https://docs.beta.b3os.org/api/post-v1-infer-audio-speech) (required: `model`, `input` and `voice`).
164
+ - Outputs: the answer's bytes as `content_type`, `size`, `sha256` and either `content` (text that is valid UTF-8) or `content_base64` (audio, images, video and anything else); an answer in JSON (`SpeechWithTimestamps`) is the outputs as it is (see [byte answers](#byte-answers)).
165
+
166
+ **`infer/embed@1`** calls `POST /v1/infer/embeddings` (not in the API reference yet) (scope `infer:run`).
167
+
168
+ - `with`: the request body (required: `model` and `input`).
169
+ - Outputs: the member at `/data` of the response body (`EmbeddingList`).
170
+
171
+ **`infer/rerank@1`** calls `POST /v1/infer/rerank` (not in the API reference yet) (scope `infer:run`).
172
+
173
+ - `with`: the request body (required: `model`, `query` and `documents`).
174
+ - Outputs: the member at `/results` of the response body (`RerankList`).
@@ -0,0 +1,361 @@
1
+ # Routine definitions
2
+
3
+ > Every field of a routine definition, how steps are ordered and connected, the CEL expressions between them, and how B3OS differs from GitHub Actions.
4
+
5
+ Source: https://docs.beta.b3os.org/routines/definitions.md
6
+
7
+ A routine definition is YAML or JSON. Publishing takes either; send YAML with `Content-Type: application/yaml`. To find mistakes before you publish, [check the definition](#check-a-definition) first.
8
+
9
+ ## Check a definition
10
+
11
+ `POST /v1/routines/validate` compiles a definition, sent as JSON, without publishing it. It always answers `200`: `valid` says whether it would publish, and `diagnostics` lists every problem with a JSON pointer into your definition.
12
+
13
+ **curl**
14
+
15
+ ```bash
16
+ curl -s https://beta-api.b3os.org/v1/routines/validate \
17
+ -H "Authorization: Bearer $B3OS_API_KEY" \
18
+ -H "Content-Type: application/json" \
19
+ -d '{"name": "check-status",
20
+ "steps": [{"id": "fetch", "uses": "core/http@1",
21
+ "with": {"method": "GET", "url": "https://status.example.com"}}]}'
22
+ ```
23
+ **TypeScript**
24
+
25
+ ```ts
26
+ import { B3OS } from "@b3os/sdk";
27
+
28
+ const b3os = new B3OS();
29
+ const check = await b3os.routines.validateRoutine({
30
+ name: "check-status",
31
+ steps: [{ id: "fetch", uses: "core/http@1", with: { method: "GET", url: "https://status.example.com" } }],
32
+ });
33
+ for (const d of check.diagnostics) console.log(d.severity, d.pointer, d.detail);
34
+ ```
35
+ **Python**
36
+
37
+ ```python
38
+ from b3os import B3OS
39
+
40
+ b3os = B3OS()
41
+ check = b3os.routines.validate_routine({
42
+ "name": "check-status",
43
+ "steps": [{"id": "fetch", "uses": "core/http@1", "with": {"method": "GET", "url": "https://status.example.com"}}],
44
+ })
45
+ for d in check["diagnostics"]:
46
+ print(d["severity"], d.get("pointer"), d["detail"])
47
+ ```
48
+ **MCP**
49
+
50
+ `routine_validate` checks a definition, given as JSON, without publishing it, and lists each problem with its pointer. It is in the routines toolset: `--toolsets routines` for the local server, `/mcp?toolsets=routines` for the remote one ([MCP](https://docs.beta.b3os.org/sdks/mcp)). No MCP tool publishes routines; agents run published routines with `routine_run`. From a terminal, `b3os routine deploy check-status.yaml` publishes a file; when the publish is refused it prints each problem with its JSON pointer.
51
+
52
+ Recorded from production: the definition above with a second step that reads `steps.fech`, a step ID that does not exist.
53
+
54
+ **Response 200**
55
+
56
+ ```json
57
+ {
58
+ "diagnostics": [
59
+ {
60
+ "code": "routine_invalid",
61
+ "detail": "steps.fech: no step with this id",
62
+ "pointer": "/steps/1/with/value",
63
+ "severity": "error"
64
+ }
65
+ ],
66
+ "object": "routine_validation",
67
+ "valid": false
68
+ }
69
+ ```
70
+
71
+ **Request**
72
+
73
+ ```bash
74
+ curl -s -X POST 'https://beta-api.b3os.org/v1/routines/validate' \
75
+ -H "Authorization: Bearer $B3OS_API_KEY" \
76
+ -H 'content-type: application/json' \
77
+ -d '{"name":"check-status","steps":[{"id":"fetch","uses":"core/http@1","with":{"method":"GET","url":"https://status.example.com"}},{"id":"report","uses":"core/transform@1","with":{"value":"${{ steps.fech.outputs.status }}"}}]}'
78
+ ```
79
+
80
+ **Server-Timing**
81
+
82
+ ```http
83
+ server-timing: edge_auth;dur=0.000, edge_upstream;dur=11.000, total;dur=0.267
84
+ x-request-id: req_01m6q3nb3q2kc1a14mt757pfd3
85
+ ```
86
+
87
+ <sub>Captured 2026-11-06 from commit `92bb000d` on the host the node runs on, one call, label `live-recorded` (recorded from production). Case `routines/validate`.</sub>
88
+
89
+ The call needs `routines:write`, like publishing.
90
+
91
+ ## Top level
92
+
93
+ | Field | Meaning |
94
+ |---|---|
95
+ | `name` | Required. Lowercase slug, unique in the project, up to 64 characters. `runs`, `hooks`, `validate` and `import` are reserved. |
96
+ | `description` | What the routine does, shown wherever the routine is listed. |
97
+ | `inputs` | A JSON Schema object for the run's input. Runs are validated against it and get its defaults. |
98
+ | `output` | Any JSON value; strings in it are templates. It becomes the run's `result`. |
99
+ | `env` | Strings evaluated once when the run starts, exposed as `env.<NAME>`. Not passed to sandboxes on their own; put what a step needs in its `with`. |
100
+ | `vars` | Constants exposed as `vars.<name>`. Their strings are never evaluated. |
101
+ | `triggers` | Up to 20 [triggers](https://docs.beta.b3os.org/routines/triggers): cron, interval, webhook or action. |
102
+ | `defaults` | `durability`, `timeout_ms` (at most 24 hours; unwritten, a product step waits its operation's timeout, a map its body's time per round of items (at least 30 seconds) and other steps 30 seconds), `retry`, `concurrency` and `pause_sandboxes` for the routine. [Routine settings](https://docs.beta.b3os.org/routines/settings) gives each one's default and values. |
103
+ | `steps` | Required. Up to 500 steps. |
104
+
105
+ ## Steps
106
+
107
+ Each step does exactly one of: call something (`uses` with `with`), fan out over a list (`map`), wait for a signal, an answer, an event or a time (`wait`), or pause (`sleep_ms`).
108
+
109
+ ```yaml
110
+ steps:
111
+ - id: fetch
112
+ uses: vision/scrape@1
113
+ with:
114
+ url: ${{ inputs.url }}
115
+ - id: notify
116
+ uses: core/http@1
117
+ if: contains(steps.fetch.outputs.markdown, 'outage')
118
+ with:
119
+ method: POST
120
+ url: https://hooks.example.com/ops
121
+ body:
122
+ text: "Outage mentioned on ${{ inputs.url }}"
123
+ retry:
124
+ max_attempts: 3
125
+ ```
126
+
127
+ `core/http@1` sends one request through the egress guard, with no credentials; call a [marketplace action](https://docs.beta.b3os.org/actions) when the request needs one. Its outputs are `status`, `headers` and `body`, and a status of 400 or more fails the step with `upstream_error` unless `fail_on_error_status` is false.
128
+
129
+ `sandboxes/exec@1` runs a command in an existing sandbox (`sandbox: sbx_…`) or in a sandbox made for the step and deleted after it (`template`). With `template`, `create` takes the rest of that sandbox's [create request](https://docs.beta.b3os.org/api/post-v1-sandboxes): `vcpu`, `memory_mib`, `disk_gib`, `env`, `secrets`, `egress`, `ports` and the other fields of `POST /v1/sandboxes`. The step sets `template` and the sandbox's lifetime itself (the step's `timeout_ms` plus 60 seconds, so a sandbox nobody could delete still ends soon), so `create` cannot set them. A literal `create` is checked against the create request when you publish. Give each entry of `secrets` (here and in `sandboxes/create@1`) as a vault reference, `{connection: conn_…, field: token}`: the definition is stored and returned by `GET /v1/routines/{routine}/versions/{version}`, so publishing refuses a secret written as a plain string. A `${{ }}` template is accepted too, and its value is then part of the run's data.
130
+
131
+ ```yaml
132
+ steps:
133
+ - id: test
134
+ uses: sandboxes/exec@1
135
+ timeout_ms: 600000
136
+ with:
137
+ template: node
138
+ create:
139
+ vcpu: 2
140
+ memory_mib: 4096
141
+ env:
142
+ CI: "1"
143
+ cmd: ["npm", "test"]
144
+ ```
145
+
146
+ `vision/act@1` runs browser actions in an existing session (`session: brs_…`) or, without `session`, in a session made for the step and closed after it, also when the actions fail, the step times out or the run is canceled. `profile` loads a saved profile into that session. A session made for the step lives at most the step's `timeout_ms` plus 60 seconds (30 minutes at most) and counts toward your organization's open sessions while the step runs. If the node restarts during the step, the next attempt closes the session the first one left before it opens its own.
147
+
148
+ ```yaml
149
+ steps:
150
+ - id: annual_prices
151
+ uses: vision/act@1
152
+ with:
153
+ profile: demo-signed-in
154
+ actions:
155
+ - kind: navigate
156
+ url: https://beta.b3os.org/demo/billing/
157
+ - kind: click
158
+ target: { role: button, name: Annual }
159
+ - kind: markdown
160
+ ```
161
+
162
+ This step opens the billing page of the [demo app](https://beta.b3os.org/demo/), switches it to annual prices and returns the page as Markdown. `demo-signed-in` is a [profile](https://docs.beta.b3os.org/vision/profiles) you save after signing in to the demo app, so the page loads signed in.
163
+
164
+ `infer/speech@1` and `sandboxes/read_file@1` answer with bytes, not JSON. Their outputs are `content_type`, `size`, `sha256` and either `content` (text that is valid UTF-8) or `content_base64` (audio, images and anything else). Speech with `timestamps: "word"` answers JSON instead, and its outputs are that JSON: `audio_base64`, `format`, `duration_ms` and `words`. The bytes count against a step's output limit after base64, so an answer over three quarters of `max_step_output_bytes` (1 MiB by default, [limits](https://docs.beta.b3os.org/routines/limits)) fails the step with `upstream_too_large`. A step reads the whole answer, so `stream_format` is refused. The dashboard's run page plays the audio.
165
+
166
+ ```yaml
167
+ steps:
168
+ - id: brief
169
+ uses: infer/chat@1
170
+ with:
171
+ model: b3os/qwen3.5-9b
172
+ messages:
173
+ - role: user
174
+ content: "One sentence on why durable workflows matter."
175
+ - id: voice
176
+ uses: infer/speech@1
177
+ with:
178
+ model: kokoro-82m
179
+ voice: af_heart
180
+ input: ${{ steps.brief.outputs.choices[0].message.content }}
181
+ ```
182
+
183
+ `sandboxes/write_file@1` sends bytes the other way. Its `with` is `sandbox`, `path`, the optional `mode` and `mkdir`, and exactly one of `content` (text, written as UTF-8) or `content_base64` (decoded, then written). `content_base64` is standard base64 with `=` padding and no line breaks. A field set to null counts as left out. The write replaces the whole file, so a retry, or the attempt a node restart sends again, leaves the same file. Its outputs are the file's entry: `name`, `path`, `type`, `size`, `mode` and `modified_at`.
184
+
185
+ The bytes come from a value in the definition or a run input (1 MiB at most for either), or from an earlier step's output (up to `max_step_output_bytes`, [limits](https://docs.beta.b3os.org/routines/limits)). A `with` written out in full that has both fields, neither, a `content` that is not a string or a `content_base64` that is not base64 is refused when you publish, with `422 routine_invalid`. When any field of the `with` is an expression, the same mistakes fail the step with `400 invalid_request` when it runs, and the step is not retried.
186
+
187
+ A read gives text as `content` and other bytes as `content_base64`, so a copy passes on the field the read gave. This copies any file byte for byte:
188
+
189
+ ```yaml
190
+ steps:
191
+ - id: read
192
+ uses: sandboxes/read_file@1
193
+ with:
194
+ sandbox: ${{ inputs.sandbox }}
195
+ path: /workspace/report.pdf
196
+ - id: copy
197
+ uses: sandboxes/write_file@1
198
+ with:
199
+ sandbox: ${{ inputs.sandbox }}
200
+ path: /workspace/backup/report.pdf
201
+ mkdir: 1
202
+ content: "${{ has(steps.read.outputs.content) ? steps.read.outputs.content : null }}"
203
+ content_base64: "${{ has(steps.read.outputs.content_base64) ? steps.read.outputs.content_base64 : null }}"
204
+ ```
205
+
206
+ On a sandbox a run paused while it waited ([`pause_sandboxes`](https://docs.beta.b3os.org/routines/settings#pause-sandboxes-while-waiting)), only an exec step resumes it: a write before the next exec fails with `409 sandbox_not_running`.
207
+
208
+ | Field | Meaning |
209
+ |---|---|
210
+ | `id` | Required. A CEL identifier (`fetch_page`, not `fetch-page`), unique across the routine |
211
+ | `name` | A display label |
212
+ | `uses`, `with` | The callable and its input. Product callables take their API request body as `with`. |
213
+ | `needs` | Earlier steps this one depends on. Without it, a step depends on the step before it; `needs: []` starts it at once. |
214
+ | `if` | A condition; the step is skipped when it is false |
215
+ | `retry` | `max_attempts`, `initial_ms` (200), `factor` (2), `max_ms` (30000), `jitter` (on) |
216
+ | `timeout_ms` | Overrides `defaults.timeout_ms`; at most 24 hours |
217
+ | `continue_on_error` | Let the run go on when this step fails |
218
+ | `connections` | Binds a pack action's connection keys to vault connections (`conn_`). A key left out uses the project's newest connection for that pack and key that has no `subject`; end users' connections are used only when bound here, or through the step's `subject`. |
219
+ | `subject` | Pack action steps only: the end user the call is made for, such as `${{ inputs.user_id }}`. Keys the step does not bind use that subject's newest connection for the pack and key, never another subject's or one without a subject; a subject with no connection fails the step with `connection_required`. 1 to 256 characters once evaluated. |
220
+
221
+ Steps run in array order unless `needs` says otherwise, so a list of steps reads top to bottom and `needs` creates fan-out and joins. A run succeeds when no step concluded `failure`.
222
+
223
+ ## Expressions
224
+
225
+ Expressions are [CEL](https://cel.dev) inside `${{ }}`. A string that is exactly one expression keeps the expression's type, so `${{ inputs.count }}` stays a number and `${{ steps.page.outputs.links }}` stays a list. A string with other text around the expression splices its text value in. An expression's result is never scanned for `${{` again, so input data cannot inject expressions.
226
+
227
+ What each place can read:
228
+
229
+ | Where | Variables |
230
+ |---|---|
231
+ | `env` values | `inputs`, `vars`, `trigger`, `run` |
232
+ | Step `with`, `connections`, `map.over`, `wait.until`, `wait.ms`, `sleep_ms` | `inputs`, `vars`, `env`, `trigger`, `run`, `steps` (this step's ancestors), and `item` and `index` inside a map |
233
+ | Step `if` | The same, plus `success()`, `failure()` and `always()` |
234
+ | `output` | `inputs`, `vars`, `env`, `trigger`, `run`, and every top-level step |
235
+ | Trigger `with`, `if` and `dedupe` | `trigger`, `vars` |
236
+
237
+ For an ancestor step `s`: `steps.s.outputs` is the callee's whole output (`{}` if it did not succeed), `steps.s.outcome` is `success`, `failure`, `skipped` or `canceled`, `steps.s.conclusion` is the same except `success` for a failure with `continue_on_error`, and `steps.s.error` is `null` or `{code, detail, status, retryable}`. `run` holds `id`, `routine_id`, `version_id`, `started_at`, `durability` and `idempotency_key`.
238
+
239
+ Besides the CEL standard functions and macros (`size`, `has`, `matches`, `map`, `filter`, `exists` and the rest), these GitHub-style functions are available: `contains`, `startsWith` and `endsWith` (case-insensitive), `format`, `join`, `toJSON`, `fromJSON`, and in `if` only, `success()`, `failure()` and `always()`. An `if` without a status function means `success() && (<your condition>)`.
240
+
241
+ Two CEL rules catch people out. A missing field is an error, not `null`: guard optional data with `has(x.field)` or `'key' in map`. And `int` and `double` do not mix in arithmetic: write `double(inputs.count) + 1.0`. Expressions are checked for syntax and names when you publish; type errors and missing fields at run time fail the step with [`expression_error`](https://docs.beta.b3os.org/errors#expression_error). There is no `now()`; use `run.started_at` or `trigger.fired_at`.
242
+
243
+ ## Map
244
+
245
+ ```yaml
246
+ - id: pages
247
+ map:
248
+ over: ${{ inputs.urls }}
249
+ concurrency: 8
250
+ steps:
251
+ - id: scrape_one
252
+ uses: vision/scrape@1
253
+ with:
254
+ url: ${{ item }}
255
+ ```
256
+
257
+ `map` runs its steps once per element of `over` (up to 10,000 elements), `concurrency` at a time (8 by default, 256 at most). Inside, `item` is the element and `index` its position. The map step's outputs are `items` (the last body step's outputs per element, `null` for failed or skipped ones) and `outcomes`, both in input order. The first failed item cancels the rest and fails the map unless the body steps continue on error. Maps nest up to 3 deep.
258
+
259
+ ## Wait and sleep
260
+
261
+ ```yaml
262
+ - id: approval
263
+ wait:
264
+ signal: approval
265
+ ms: 86400000 # give up after a day
266
+ - id: ship
267
+ if: steps.approval.outputs.payload.approved
268
+ uses: core/http@1
269
+ with: { method: POST, url: "https://deploy.example.com/hooks/release" }
270
+ ```
271
+
272
+ A `wait` step holds no resources while it waits. `{signal}` waits for [`POST /v1/routines/runs/{run_id}/signal`](https://docs.beta.b3os.org/routines/runs#signals) with that name; add `ms` or `until` for a deadline. Its outputs are `signal`, `payload`, `received_at` and `timed_out`; a deadline is not a failure, `timed_out` is just `true`. `{until}` waits for an RFC 3339 time. `sleep_ms` pauses for a fixed time.
273
+
274
+ ### Ask a person
275
+
276
+ `token: true` gives the wait a link a person can answer without an API key or a login. Any step can send it: it is `run.wait_urls.<step id>`.
277
+
278
+ ```yaml
279
+ - id: shot
280
+ uses: render/screenshot@1
281
+ with: { url: "https://example.com/pricing", viewport: { width: 1440, height: 900 } }
282
+ - id: ask
283
+ uses: io.b3os/slack/send-message@1
284
+ with:
285
+ channel: C0123LAUNCH
286
+ text: "Post the new pricing page? ${{ run.wait_urls.approve }}"
287
+ - id: approve
288
+ wait:
289
+ token: true
290
+ ms: 86400000
291
+ prompt:
292
+ title: Post the new pricing page to #launch?
293
+ body: Approve posts it; Reject stops here.
294
+ image: ${{ steps.shot.outputs.artifacts[0] }}
295
+ - id: post
296
+ if: ${{ steps.approve.outputs.payload.approved }}
297
+ uses: io.b3os/slack/send-message@1
298
+ with: { channel: C0123LAUNCH, text: "Pricing page is live." }
299
+ ```
300
+
301
+ Opening the link shows a page with the `prompt` (title, body, image and an optional `link`) and Approve and Reject buttons. Add `?decision=approve` or `?decision=reject` to the link for buttons in a message; the person still confirms, so link previews and mail scanners that open the URL answer nothing. The answer completes the step with `payload` `{decision, approved, comment, via: "link"}`, the same as a [signal](https://docs.beta.b3os.org/routines/runs#signals) with the step's id as its name (or `wait.signal`, if you name one).
302
+
303
+ The link is bound to this run and step and signed by the node. It works once: the first answer completes the step and every later one gets [`wait_already_answered`](https://docs.beta.b3os.org/errors#wait_already_answered). It stops working when the step stops waiting (its `ms` deadline, a signal through the API) or the run ends, and 7 days after the step started waiting at the latest. Programs can read and answer it too: `GET` and `POST` [`/v1/routines/waits/{token}`](https://docs.beta.b3os.org/api/post-v1-routines-waits-token-) with JSON. Token waits must be top-level steps (not inside a `map`), and no other wait in the routine may use the same signal name. While the step waits, the run's step shows `waiting_for.token` and the evaluated `waiting_for.prompt`, never the link itself. The step that sends the link can keep it in its outputs (Slack's answer repeats the message text), so a key without `routines:run`, which may read the run but not answer it, sees `[wait link]` in place of every link in the run, its steps, its events and the routine's run list. When `prompt.image` is a render artifact (`steps.shot.outputs.artifacts[0]`), the page signs a fresh URL for it each time it is served, as the run's principal, so the screenshot shows for as long as render keeps it (7 days, as long as a link works); the JSON names it in `prompt.image_artifact`. A plain URL is shown as given.
304
+
305
+ ### Wait for an event
306
+
307
+ `event` waits for something to happen elsewhere when the sender does not know the run's ID: a payment system reports an order as paid, and the run fulfilling that order continues.
308
+
309
+ ```yaml
310
+ - id: paid
311
+ wait:
312
+ event: order.paid
313
+ ms: 3600000 # give up after an hour
314
+ match:
315
+ order_id: ${{ inputs.order_id }}
316
+ - id: ship
317
+ if: ${{ !steps.paid.outputs.timed_out }}
318
+ uses: core/http@1
319
+ with: { method: POST, url: "https://warehouse.example.com/ship", body: { order: "${{ inputs.order_id }}" } }
320
+ ```
321
+
322
+ Send the event with [`POST /v1/routines/events`](https://docs.beta.b3os.org/api/post-v1-routines-events):
323
+
324
+ ```bash
325
+ curl -s https://beta-api.b3os.org/v1/routines/events \
326
+ -H "Authorization: Bearer $B3OS_API_KEY" \
327
+ -H "Content-Type: application/json" \
328
+ -d '{"name": "order.paid", "id": "evt_3PqZ8a2e", "data": {"order_id": "ord_7731", "amount": 4900}}'
329
+ ```
330
+
331
+ Every step of your project's active runs that waits for `order.paid` and whose `match` values are all in `data` (by dot path, `customer.id` for nested fields, compared as JSON) continues with outputs `{event, data, id, received_at, timed_out}`. The answer says how many it resumed (`delivered`) and which. `match` is evaluated when the step starts waiting; without it, any event of the name answers. Events are not buffered: a step that starts waiting after the event does not see it, so start the wait before the thing that sends the event. Runs in other projects never see your events. Each step it resumes journals the event with its run, so an event's JSON plus 256 bytes a step may add up to at most 4 MiB across them: 15 steps for an event at the 256 KiB body cap, about 7,500 for one of 300 bytes. Past that the event is refused whole with [`event_fan_out_too_large`](https://docs.beta.b3os.org/errors#event_fan_out_too_large) and no step continues; send an ID the step can look up rather than the whole document.
332
+
333
+ ## Retries
334
+
335
+ Attempt n starts `min(max_ms, initial_ms * factor^(n-2))` milliseconds after the previous one, and with `jitter` a random amount between half that and all of it, from a generator seeded by the run, step, item and attempt, so a replay makes the same choices. Only failures the callee marks retryable are retried, plus timeouts of `pure` and `read` steps. Every attempt of a step carries the same idempotency key.
336
+
337
+ `defaults.retry` applies only to `pure` and `read` steps. A `write` step retries only with its own `retry`, and an `irreversible` one cannot retry.
338
+
339
+ ## Concurrency
340
+
341
+ ```yaml
342
+ defaults:
343
+ concurrency:
344
+ limit: 1
345
+ group: ${{ inputs.customer_id }}
346
+ on_limit: queue
347
+ ```
348
+
349
+ At most `limit` runs are active per `group`. A new run in a full group waits (`queue`, the default), ends canceled (`skip`), or cancels the oldest active run first (`cancel_running`).
350
+
351
+ ## Differences from GitHub Actions
352
+
353
+ - One list of steps per routine; no jobs or runners. There is no `run:` shell step: run commands with `sandboxes/exec@1`.
354
+ - Steps take `needs` like GitHub jobs, and `needs` must name earlier steps.
355
+ - Expressions are CEL: missing fields are errors, `int` and `double` are distinct, strings may use `'` or `"`, there are no object filters such as `steps.*.outputs` (use `.map()` and `.filter()`), and `toJSON` is compact with sorted keys.
356
+ - Status functions look at the step's ancestors, not at every earlier step.
357
+ - Keys are snake_case and times are in milliseconds: `continue_on_error`, `timeout_ms`.
358
+ - `with` values are any JSON, and a step's outputs are the callee's whole output; the routine has one `output`.
359
+ - Contexts are `inputs`, `steps`, `env`, `vars`, `trigger`, `run`, and `item` and `index` in maps. There is no `secrets` context: credentials are bound through `connections` and injected at the egress proxy.
360
+ - `triggers` is a list with IDs instead of `on:`. Cron has six fields with seconds first and requires a catch-up policy.
361
+ - `map` replaces `strategy.matrix`; `wait`, `sleep_ms` and `retry` have no GitHub equivalent.