@b3os/cli 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -7
- package/assets/b3os-run.py +137 -0
- package/assets/skill/b3os/SKILL.md +111 -0
- package/dist/commands/_agents.d.ts +14 -0
- package/dist/commands/_agents.js +33 -0
- package/dist/commands/_agents.js.map +1 -0
- package/dist/commands/_common.js +6 -2
- package/dist/commands/_common.js.map +1 -1
- package/dist/commands/_context.d.ts +49 -0
- package/dist/commands/_context.js +260 -0
- package/dist/commands/_context.js.map +1 -0
- package/dist/commands/_next.d.ts +39 -0
- package/dist/commands/_next.js +77 -0
- package/dist/commands/_next.js.map +1 -0
- package/dist/commands/agent.d.ts +42 -0
- package/dist/commands/agent.js +218 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/app.d.ts +2 -0
- package/dist/commands/app.js +559 -54
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/auth.d.ts +88 -2
- package/dist/commands/auth.js +354 -44
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/docs.d.ts +54 -0
- package/dist/commands/docs.js +202 -0
- package/dist/commands/docs.js.map +1 -0
- package/dist/commands/doctor.d.ts +23 -0
- package/dist/commands/doctor.js +313 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +38 -1
- package/dist/commands/init.js +259 -60
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/listen.d.ts +30 -0
- package/dist/commands/listen.js +194 -0
- package/dist/commands/listen.js.map +1 -0
- package/dist/commands/manifest.d.ts +13 -1
- package/dist/commands/manifest.js +81 -18
- package/dist/commands/manifest.js.map +1 -1
- package/dist/commands/mcp.d.ts +25 -2
- package/dist/commands/mcp.js +120 -11
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/sandbox.d.ts +35 -6
- package/dist/commands/sandbox.js +208 -9
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/commands/setup.d.ts +39 -0
- package/dist/commands/setup.js +203 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/tool.d.ts +154 -0
- package/dist/commands/tool.js +785 -0
- package/dist/commands/tool.js.map +1 -0
- package/dist/config.d.ts +30 -6
- package/dist/config.js +39 -8
- package/dist/config.js.map +1 -1
- package/dist/ctx.d.ts +5 -45
- package/dist/ctx.js +25 -160
- package/dist/ctx.js.map +1 -1
- package/dist/docs/index.json +1 -0
- package/dist/docs/pages/actions/call.md +300 -0
- package/dist/docs/pages/actions/catalog/airtable.md +737 -0
- package/dist/docs/pages/actions/catalog/arxiv.md +166 -0
- package/dist/docs/pages/actions/catalog/chainalysis-sanctions.md +125 -0
- package/dist/docs/pages/actions/catalog/coingecko.md +1558 -0
- package/dist/docs/pages/actions/catalog/deps-dev.md +465 -0
- package/dist/docs/pages/actions/catalog/dexscreener.md +568 -0
- package/dist/docs/pages/actions/catalog/discord.md +784 -0
- package/dist/docs/pages/actions/catalog/finnhub.md +776 -0
- package/dist/docs/pages/actions/catalog/frankfurter.md +438 -0
- package/dist/docs/pages/actions/catalog/github.md +1853 -0
- package/dist/docs/pages/actions/catalog/gmail.md +575 -0
- package/dist/docs/pages/actions/catalog/google-calendar.md +654 -0
- package/dist/docs/pages/actions/catalog/google-drive.md +502 -0
- package/dist/docs/pages/actions/catalog/google-sheets.md +700 -0
- package/dist/docs/pages/actions/catalog/hacker-news.md +542 -0
- package/dist/docs/pages/actions/catalog/http.md +824 -0
- package/dist/docs/pages/actions/catalog/hyperliquid.md +942 -0
- package/dist/docs/pages/actions/catalog/jira.md +920 -0
- package/dist/docs/pages/actions/catalog/kalshi.md +917 -0
- package/dist/docs/pages/actions/catalog/linear.md +1030 -0
- package/dist/docs/pages/actions/catalog/markets.md +21 -0
- package/dist/docs/pages/actions/catalog/morpho.md +247 -0
- package/dist/docs/pages/actions/catalog/notion.md +1077 -0
- package/dist/docs/pages/actions/catalog/nws.md +485 -0
- package/dist/docs/pages/actions/catalog/open-meteo.md +559 -0
- package/dist/docs/pages/actions/catalog/polymarket.md +1523 -0
- package/dist/docs/pages/actions/catalog/pushbullet.md +220 -0
- package/dist/docs/pages/actions/catalog/resend.md +307 -0
- package/dist/docs/pages/actions/catalog/s3.md +513 -0
- package/dist/docs/pages/actions/catalog/sec-edgar.md +487 -0
- package/dist/docs/pages/actions/catalog/slack.md +2629 -0
- package/dist/docs/pages/actions/catalog/stripe.md +1405 -0
- package/dist/docs/pages/actions/catalog/wikipedia.md +379 -0
- package/dist/docs/pages/actions/catalog.md +46 -0
- package/dist/docs/pages/actions/limits.md +50 -0
- package/dist/docs/pages/actions/model-tools.md +225 -0
- package/dist/docs/pages/actions/packs.md +148 -0
- package/dist/docs/pages/actions/settings.md +69 -0
- package/dist/docs/pages/actions/tools.md +244 -0
- package/dist/docs/pages/actions/triggers.md +149 -0
- package/dist/docs/pages/actions.md +88 -0
- package/dist/docs/pages/compat/anthropic.md +168 -0
- package/dist/docs/pages/compat/e2b.md +194 -0
- package/dist/docs/pages/compat/firecrawl.md +138 -0
- package/dist/docs/pages/compat/openai.md +168 -0
- package/dist/docs/pages/concepts/auth.md +151 -0
- package/dist/docs/pages/concepts/beta.md +55 -0
- package/dist/docs/pages/concepts/glossary.md +71 -0
- package/dist/docs/pages/concepts/ids.md +98 -0
- package/dist/docs/pages/concepts/jobs.md +229 -0
- package/dist/docs/pages/concepts/latency.md +138 -0
- package/dist/docs/pages/concepts/limits.md +191 -0
- package/dist/docs/pages/concepts/stack.md +59 -0
- package/dist/docs/pages/concepts/timing.md +86 -0
- package/dist/docs/pages/concepts/usage.md +110 -0
- package/dist/docs/pages/design/b3os-yaml.md +370 -0
- package/dist/docs/pages/design/deploy-from-github.md +122 -0
- package/dist/docs/pages/design/observability.md +134 -0
- package/dist/docs/pages/errors.md +1824 -0
- package/dist/docs/pages/infer/chat.md +570 -0
- package/dist/docs/pages/infer/limits.md +55 -0
- package/dist/docs/pages/infer/messages.md +185 -0
- package/dist/docs/pages/infer/responses.md +173 -0
- package/dist/docs/pages/infer/settings.md +154 -0
- package/dist/docs/pages/infer/speech.md +323 -0
- package/dist/docs/pages/infer.md +154 -0
- package/dist/docs/pages/introduction.md +162 -0
- package/dist/docs/pages/platform/addresses.md +174 -0
- package/dist/docs/pages/platform/call-log.md +99 -0
- package/dist/docs/pages/platform/custom-domains.md +104 -0
- package/dist/docs/pages/platform/keys.md +79 -0
- package/dist/docs/pages/platform/limits.md +57 -0
- package/dist/docs/pages/platform/members.md +101 -0
- package/dist/docs/pages/platform/requests.md +116 -0
- package/dist/docs/pages/platform/settings.md +129 -0
- package/dist/docs/pages/platform/webhooks.md +68 -0
- package/dist/docs/pages/platform.md +67 -0
- package/dist/docs/pages/quickstart/mcp.md +94 -0
- package/dist/docs/pages/quickstart/sandbox-agent.md +205 -0
- package/dist/docs/pages/quickstart/scrape.md +134 -0
- package/dist/docs/pages/quickstart.md +45 -0
- package/dist/docs/pages/render/inspections.md +162 -0
- package/dist/docs/pages/render/limits.md +72 -0
- package/dist/docs/pages/render/screenshots.md +179 -0
- package/dist/docs/pages/render/settings.md +431 -0
- package/dist/docs/pages/render/styles.md +342 -0
- package/dist/docs/pages/render/videos.md +272 -0
- package/dist/docs/pages/render.md +118 -0
- package/dist/docs/pages/routines/callables.md +174 -0
- package/dist/docs/pages/routines/definitions.md +361 -0
- package/dist/docs/pages/routines/limits.md +117 -0
- package/dist/docs/pages/routines/runs.md +328 -0
- package/dist/docs/pages/routines/settings.md +104 -0
- package/dist/docs/pages/routines/triggers.md +339 -0
- package/dist/docs/pages/routines.md +216 -0
- package/dist/docs/pages/sandboxes/agents.md +217 -0
- package/dist/docs/pages/sandboxes/commands.md +272 -0
- package/dist/docs/pages/sandboxes/images.md +166 -0
- package/dist/docs/pages/sandboxes/limits.md +143 -0
- package/dist/docs/pages/sandboxes/ports.md +260 -0
- package/dist/docs/pages/sandboxes/settings.md +358 -0
- package/dist/docs/pages/sandboxes/snapshots.md +423 -0
- package/dist/docs/pages/sandboxes/swarms.md +146 -0
- package/dist/docs/pages/sandboxes/volumes.md +131 -0
- package/dist/docs/pages/sandboxes.md +231 -0
- package/dist/docs/pages/sdks/cli.md +121 -0
- package/dist/docs/pages/sdks/mcp.md +169 -0
- package/dist/docs/pages/sdks/python.md +146 -0
- package/dist/docs/pages/sdks/typescript.md +202 -0
- package/dist/docs/pages/sdks.md +282 -0
- package/dist/docs/pages/settings.md +33 -0
- package/dist/docs/pages/vault/limits.md +46 -0
- package/dist/docs/pages/vault.md +133 -0
- package/dist/docs/pages/vision/agent-browser.md +115 -0
- package/dist/docs/pages/vision/crawl.md +333 -0
- package/dist/docs/pages/vision/extract.md +152 -0
- package/dist/docs/pages/vision/fetcher.md +15 -0
- package/dist/docs/pages/vision/limits.md +79 -0
- package/dist/docs/pages/vision/profiles.md +111 -0
- package/dist/docs/pages/vision/proxy.md +131 -0
- package/dist/docs/pages/vision/scrape.md +356 -0
- package/dist/docs/pages/vision/sessions.md +311 -0
- package/dist/docs/pages/vision/settings.md +656 -0
- package/dist/docs/pages/vision.md +175 -0
- package/dist/errors.d.ts +129 -0
- package/dist/errors.js +326 -0
- package/dist/errors.js.map +1 -0
- package/dist/main.d.ts +1 -1
- package/dist/main.js +26 -13
- package/dist/main.js.map +1 -1
- package/dist/manifest/apply.d.ts +4 -0
- package/dist/manifest/apply.js +2 -0
- package/dist/manifest/apply.js.map +1 -1
- package/dist/manifest/domains.d.ts +50 -0
- package/dist/manifest/domains.js +159 -0
- package/dist/manifest/domains.js.map +1 -0
- package/dist/manifest/link.d.ts +20 -0
- package/dist/manifest/link.js +24 -0
- package/dist/manifest/link.js.map +1 -0
- package/dist/manifest/record.d.ts +1 -1
- package/dist/tool/archive.d.ts +33 -0
- package/dist/tool/archive.js +174 -0
- package/dist/tool/archive.js.map +1 -0
- package/dist/tool/calls.d.ts +46 -0
- package/dist/tool/calls.js +274 -0
- package/dist/tool/calls.js.map +1 -0
- package/dist/tool/checks.d.ts +21 -0
- package/dist/tool/checks.js +145 -0
- package/dist/tool/checks.js.map +1 -0
- package/dist/tool/elf.d.ts +19 -0
- package/dist/tool/elf.js +107 -0
- package/dist/tool/elf.js.map +1 -0
- package/dist/tool/predict.d.ts +8 -0
- package/dist/tool/predict.js +38 -0
- package/dist/tool/predict.js.map +1 -0
- package/dist/tool/ustar.d.ts +5 -0
- package/dist/tool/ustar.js +220 -0
- package/dist/tool/ustar.js.map +1 -0
- package/package.json +6 -5
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Triggers
|
|
2
|
+
|
|
3
|
+
> Start routine runs on a cron schedule, at an interval, from signed webhooks, or from pack triggers such as a new GitHub issue or a paid Stripe invoice.
|
|
4
|
+
|
|
5
|
+
Source: https://docs.beta.b3os.org/routines/triggers.md
|
|
6
|
+
|
|
7
|
+
Besides `POST /v1/routines/{routine}/runs`, a routine starts runs from its `triggers`, up to 20 of them. Each trigger has an `id`, unique in the routine. Triggers switch atomically when you publish a new version, and pause together when you pause the routine.
|
|
8
|
+
|
|
9
|
+
Every trigger can take `with`, which builds the run's input from the trigger context (absent, the input is `{}` plus the input defaults), and `if`, a condition that must hold for a run to start.
|
|
10
|
+
|
|
11
|
+
## Cron
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
triggers:
|
|
15
|
+
- type: cron
|
|
16
|
+
id: nightly
|
|
17
|
+
cron: "0 30 6 * * MON-FRI" # 06:30:00 on weekdays
|
|
18
|
+
tz: America/Los_Angeles
|
|
19
|
+
catch_up: latest
|
|
20
|
+
overlap: skip
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- `cron` has six fields, seconds first: second, minute, hour, day of month, month, day of week. Numbers, names (`JAN`, `MON`), `*`, ranges, lists, steps (`*/5`) and `?` are accepted, plus `L`, `W` and `#` in the day fields.
|
|
24
|
+
- `tz` is an IANA time zone, UTC by default. A local time skipped by a daylight-saving change fires at the first instant after the gap; a local time that occurs twice fires once.
|
|
25
|
+
- `catch_up` is required. It decides what happens to occurrences missed while the node was down or the routine was paused, within `catch_up_window_s` (a day by default): `skip` runs none, `latest` runs only the newest, `all` runs each in order.
|
|
26
|
+
- `overlap` decides what happens when an occurrence fires while this trigger's previous run is still active: `skip` (the default) drops it, `buffer_one` keeps one pending occurrence, `allow` starts it anyway, `cancel_running` cancels the active run first.
|
|
27
|
+
|
|
28
|
+
Occurrences are scheduled ahead and deduplicated, so one occurrence never starts two runs. The target for firing lateness is p99 5 ms; see [benchmarks](https://docs.beta.b3os.org/benchmarks).
|
|
29
|
+
|
|
30
|
+
## Interval
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
- type: interval
|
|
34
|
+
id: every_five_minutes
|
|
35
|
+
every_ms: 300000
|
|
36
|
+
anchor: epoch
|
|
37
|
+
catch_up: skip
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`every_ms` is at least 1000. `anchor: epoch` (the default) fires on multiples of the period since the Unix epoch, aligned to the clock; `publish` fires one period after the version became active, then every period. `catch_up` and `overlap` work as for cron.
|
|
41
|
+
|
|
42
|
+
## Webhooks
|
|
43
|
+
|
|
44
|
+
```yaml
|
|
45
|
+
- type: webhook
|
|
46
|
+
id: inbound
|
|
47
|
+
verify:
|
|
48
|
+
scheme: b3os
|
|
49
|
+
with:
|
|
50
|
+
pr: ${{ trigger.body.number }}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Publishing gives the trigger a hook with an unguessable ID and the URL to hand to the sender:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
https://beta-api.b3os.org/v1/routines/hooks/hk_01m5t3r2qwz23751t0x74bhahz
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The routine's `triggers[].hook` shows the URL. Recorded from production, the publish answer of a routine with one `b3os` webhook trigger; the capture redacts the secret and the key ID in `run_as`, and the routine was deleted after the recording, so its hook no longer exists.
|
|
60
|
+
|
|
61
|
+
**Response 201**
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"created_at": "2026-11-06T00:20:42.718Z",
|
|
66
|
+
"description": "Started by a signed webhook delivery; reports the pull request number the delivery carries. The docs' webhook test (gallery case routines/hook-test) delivers to it.",
|
|
67
|
+
"id": "rtn_01m6q3nahzgsb10z99bk9a8b69",
|
|
68
|
+
"metadata": {},
|
|
69
|
+
"name": "docs-hook",
|
|
70
|
+
"object": "routine",
|
|
71
|
+
"paused_reason": null,
|
|
72
|
+
"run_as": {
|
|
73
|
+
"key": "[redacted:BENCH_KEY_ID]",
|
|
74
|
+
"scopes": [
|
|
75
|
+
"vision:read",
|
|
76
|
+
"vision:write",
|
|
77
|
+
"vision:run",
|
|
78
|
+
"vision:profiles:use",
|
|
79
|
+
"render:read",
|
|
80
|
+
"render:write",
|
|
81
|
+
"render:run",
|
|
82
|
+
"sandboxes:read",
|
|
83
|
+
"sandboxes:write",
|
|
84
|
+
"sandboxes:run",
|
|
85
|
+
"routines:read",
|
|
86
|
+
"routines:write",
|
|
87
|
+
"… 10 more"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"status": "active",
|
|
91
|
+
"triggers": [
|
|
92
|
+
{
|
|
93
|
+
"hook": {
|
|
94
|
+
"id": "hk_4kra8xz5ajxq9nh4xq3xc58yyn",
|
|
95
|
+
"secret": "[redacted:secret]",
|
|
96
|
+
"url": "https://beta-api.b3os.org/v1/routines/hooks/hk_4kra8xz5ajxq9nh4xq3xc58yyn",
|
|
97
|
+
"verify": "b3os"
|
|
98
|
+
},
|
|
99
|
+
"id": "inbound",
|
|
100
|
+
"next_fire_at": null,
|
|
101
|
+
"status": "active",
|
|
102
|
+
"subscription_id": null,
|
|
103
|
+
"type": "webhook"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"updated_at": "2026-11-06T00:20:42.718Z",
|
|
107
|
+
"version": {
|
|
108
|
+
"created_at": "2026-11-06T00:20:42.718Z",
|
|
109
|
+
"id": "ver_01m6q3najyby72z23abmmnrra1",
|
|
110
|
+
"number": 1
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Request**
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
curl -s -X PUT 'https://beta-api.b3os.org/v1/routines/docs-hook' \
|
|
119
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
120
|
+
-H 'content-type: application/json' \
|
|
121
|
+
-d '{"name":"docs-hook","description":"Started by a signed webhook delivery; reports the pull request number the delivery carries. The docs'\'' webhook test (gallery case routines/hook-test) delivers to it.","triggers":[{"type":"webhook","id":"inbound","verify":{"scheme":"b3os"},"with":{"pr":"${{ trigger.body.number }}"}}],"steps":[{"id":"note","uses":"core/transform@1","with":{"value":"Pull request ${{ inputs.pr }} received"}}],"output":{"summary":"${{ steps.note.outputs.value }}"}}'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Server-Timing**
|
|
125
|
+
|
|
126
|
+
```http
|
|
127
|
+
server-timing: edge_auth;dur=0.000, edge_upstream;dur=58.000, total;dur=46.208
|
|
128
|
+
x-request-id: req_01m6q3nahse86d20jmmnav2bzg
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
<sub>Captured 2026-11-06 from commit `92bb000d` on the host the node runs on, one call, label `live-recorded` (recorded from production); long values abridged. Case `routines/publish-hook`.</sub>
|
|
132
|
+
|
|
133
|
+
Every delivery must pass verification; there is no unverified webhook. `verify.scheme` is one of:
|
|
134
|
+
|
|
135
|
+
| Scheme | Verifies |
|
|
136
|
+
|---|---|
|
|
137
|
+
| `b3os` | `B3OS-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">`, with a secret B3OS generates. The secret is returned once, in the publish response. |
|
|
138
|
+
| `github`, `stripe`, `slack`, `standard_webhooks` | The provider's own signature scheme |
|
|
139
|
+
| `hmac_sha256` | A generic HMAC over `<timestamp>.<body>`: needs `header`, `timestamp_header` and a `dedupe` key on the trigger, and optionally `encoding` and `prefix` |
|
|
140
|
+
|
|
141
|
+
For every scheme except `b3os`, store the provider's signing secret as a verification-only [vault connection](https://docs.beta.b3os.org/vault) (type `api_key`, no pack and no hosts, so it is never injected anywhere) and name it in `verify.secret`. Naming a connection takes `vault:run` on top of `routines:write`, as everywhere else ([default keys](https://docs.beta.b3os.org/concepts/auth) have it): without it, publishing answers `403 forbidden` with `required_scope: vault:run`, and so does a rollback to such a version. A version published before this check by a key without `vault:run` verifies nothing: its deliveries answer `401 webhook_signature_invalid`, and the delivery log says why; publish it again with a key that has `vault:run`. Timestamped schemes refuse deliveries more than `tolerance_s` from the node's clock (300 seconds, the most allowed). A bad signature is [`webhook_signature_invalid`](https://docs.beta.b3os.org/errors#webhook_signature_invalid).
|
|
142
|
+
|
|
143
|
+
A delivery whose `if` is false is acknowledged with `202` and starts nothing. In expressions, `trigger` holds the request: `hook_id`, `delivery_id`, `received_at`, `method`, `headers` (lowercase), `query` and `body` (parsed when it is JSON). `trigger.headers` leaves out the headers of the path the delivery took: Cloudflare's (`cf-*` and the Access credentials), the edge's `x-b3os-*` and `authorization`, cookies, `x-forwarded-*` and other client-address headers, and hop-by-hop headers.
|
|
144
|
+
|
|
145
|
+
The signature is the authentication: a hook URL takes no API key, and the unguessable hook ID only finds the trigger. An unknown ID gets `404 hook_not_found` and nothing else; every answer about a known hook carries `x-b3os-hook-known: 1`. The abuse control sits at the edge: at most 1,200 deliveries per hook and minute (`429` beyond that), and while the node is down a queue of up to 10,000 deliveries or 64 MiB per known hook (10 deliveries or 1 MiB for any other ID), kept for 72 hours. Cloudflare's managed WAF rules are not applied to `/v1/routines/hooks/*` (a skip rule on the API host since 2026-10-30), so the body's content does not decide whether a delivery gets through; its signature does.
|
|
146
|
+
|
|
147
|
+
If the node is down, the edge stores deliveries durably, answers the sender `202` with `x-b3os-queued: true`, and replays them in order when the node returns. The edge signs the time it received each delivery, and on a replay the scheme's timestamp check runs against that time, so a delivery that waited out an outage is not refused as stale; `trigger.received_at` is the edge's time too. A replay the node cannot verify yet answers `503` [`hook_attestation_unverifiable`](https://docs.beta.b3os.org/errors#hook_attestation_unverifiable) with `Retry-After`, and the edge keeps it. Any `5xx` means retry later; `2xx` and `4xx` answers are final. A delivery whose trigger `with` fails to evaluate, or produces an input the routine's schema refuses, answers `422` (`expression_error` or `run_input_invalid`) and is not retried.
|
|
148
|
+
|
|
149
|
+
### Duplicate deliveries
|
|
150
|
+
|
|
151
|
+
Senders retry, so a webhook trigger drops repeats by a key. `dedupe` sets that key as one expression over `trigger` and `vars`, such as `${{ trigger.headers['x-delivery-id'] }}`. A second delivery with the same key within 24 hours gets the first delivery's response and starts nothing. Without `dedupe`, each scheme uses its own key:
|
|
152
|
+
|
|
153
|
+
| Scheme | Default key |
|
|
154
|
+
|---|---|
|
|
155
|
+
| `github` | The `X-GitHub-Delivery` header |
|
|
156
|
+
| `stripe` | The event's `id` in the body |
|
|
157
|
+
| `slack` | The `event_id` in the body |
|
|
158
|
+
| `standard_webhooks` | The `webhook-id` header |
|
|
159
|
+
| `b3os` | The `Idempotency-Key` header if the sender sends one, otherwise the `v1` signature |
|
|
160
|
+
| `hmac_sha256` | None: `dedupe` is required, and a definition without it does not publish |
|
|
161
|
+
|
|
162
|
+
```yaml
|
|
163
|
+
- type: webhook
|
|
164
|
+
id: orders
|
|
165
|
+
verify:
|
|
166
|
+
scheme: hmac_sha256
|
|
167
|
+
secret: conn_01m5t6cbgdjs1ketgcqwa2sne8
|
|
168
|
+
header: X-Shop-Signature
|
|
169
|
+
timestamp_header: X-Shop-Timestamp
|
|
170
|
+
dedupe: ${{ trigger.headers['x-shop-delivery'] }}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Send a test delivery
|
|
174
|
+
|
|
175
|
+
A `b3os` hook needs no API key: the hook ID and the signature authenticate the delivery. To try one, sign a body with the secret from the publish response and post it to the hook URL:
|
|
176
|
+
|
|
177
|
+
**curl**
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
BODY='{"number": 42}'
|
|
181
|
+
T=$(date +%s)
|
|
182
|
+
SIG=$(printf '%s.%s' "$T" "$BODY" | openssl dgst -sha256 -hmac "$HOOK_SECRET" | sed 's/^.* //')
|
|
183
|
+
curl -s "$HOOK_URL" \
|
|
184
|
+
-H "Content-Type: application/json" \
|
|
185
|
+
-H "B3OS-Signature: t=$T,v1=$SIG" \
|
|
186
|
+
-d "$BODY"
|
|
187
|
+
```
|
|
188
|
+
**TypeScript**
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
import { signWebhook } from "@b3os/sdk/webhooks";
|
|
192
|
+
|
|
193
|
+
const body = JSON.stringify({ number: 42 });
|
|
194
|
+
const response = await fetch(process.env.HOOK_URL ?? "", {
|
|
195
|
+
method: "POST",
|
|
196
|
+
headers: {
|
|
197
|
+
"Content-Type": "application/json",
|
|
198
|
+
"B3OS-Signature": await signWebhook(body, process.env.HOOK_SECRET ?? ""),
|
|
199
|
+
},
|
|
200
|
+
body,
|
|
201
|
+
});
|
|
202
|
+
console.log(response.status, await response.json());
|
|
203
|
+
```
|
|
204
|
+
**Python**
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
import json
|
|
208
|
+
import os
|
|
209
|
+
import urllib.request
|
|
210
|
+
from b3os import sign_webhook
|
|
211
|
+
|
|
212
|
+
body = json.dumps({"number": 42}).encode()
|
|
213
|
+
request = urllib.request.Request(os.environ["HOOK_URL"], data=body, method="POST", headers={
|
|
214
|
+
"Content-Type": "application/json",
|
|
215
|
+
"B3OS-Signature": sign_webhook(body, os.environ["HOOK_SECRET"]),
|
|
216
|
+
})
|
|
217
|
+
with urllib.request.urlopen(request) as response:
|
|
218
|
+
print(response.status, json.load(response))
|
|
219
|
+
```
|
|
220
|
+
**MCP**
|
|
221
|
+
|
|
222
|
+
Deliveries come from the sending service, not from an agent, and no MCP tool sends them.
|
|
223
|
+
|
|
224
|
+
The answer is `202` with a `hook_delivery`: its `run_id`, or `deduplicated: true` for a repeat. A delivery that fails verification gets [`webhook_signature_invalid`](https://docs.beta.b3os.org/errors#webhook_signature_invalid).
|
|
225
|
+
|
|
226
|
+
`POST /v1/routines/{routine}/hooks/{hook_id}/test` does the same from B3OS: it signs `body` (default `{"test": true, "sent_at": ...}`) with the current secret, delivers it through the hook like a sender would, and answers with the delivery's log entry. It needs `routines:write` and works for `b3os` hooks only; for other schemes, send a test from the provider. Recorded from production, a test delivery of `{"number": 42}` to the hook above:
|
|
227
|
+
|
|
228
|
+
**Response 200**
|
|
229
|
+
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"code": null,
|
|
233
|
+
"deduplicated": false,
|
|
234
|
+
"delivery_id": "evt_01m6q3nhmyq4gm6c67rkzfw5tm",
|
|
235
|
+
"detail": null,
|
|
236
|
+
"handshake": null,
|
|
237
|
+
"headers": {
|
|
238
|
+
"content-type": "application/json",
|
|
239
|
+
"idempotency-key": "evt_01m6q3nhmypk9jkmjmd8km33rn",
|
|
240
|
+
"user-agent": "b3os-hook-test/1"
|
|
241
|
+
},
|
|
242
|
+
"hook_id": "hk_4kra8xz5ajxq9nh4xq3xc58yyn",
|
|
243
|
+
"method": "POST",
|
|
244
|
+
"object": "hook_delivery_entry",
|
|
245
|
+
"outcome": "started",
|
|
246
|
+
"reason": null,
|
|
247
|
+
"received_at": "2026-11-06T00:20:49.950Z",
|
|
248
|
+
"run_id": "run_01m6q3nhmyn8jaynctsat7ezw5",
|
|
249
|
+
"size": 13,
|
|
250
|
+
"source": "test",
|
|
251
|
+
"status": 202
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**Request**
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
curl -s -X POST 'https://beta-api.b3os.org/v1/routines/docs-hook/hooks/hk_4kra8xz5ajxq9nh4xq3xc58yyn/test' \
|
|
259
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
260
|
+
-H 'content-type: application/json' \
|
|
261
|
+
-d '{"body":{"number":42}}'
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Server-Timing**
|
|
265
|
+
|
|
266
|
+
```http
|
|
267
|
+
server-timing: edge_auth;dur=21.000, edge_upstream;dur=57.000, total;dur=0.762
|
|
268
|
+
x-request-id: req_01m6q3nhjcc86hx0edqfn2bx0m
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
<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/hook-test`.</sub>
|
|
272
|
+
|
|
273
|
+
### Delivery log
|
|
274
|
+
|
|
275
|
+
```http
|
|
276
|
+
GET /v1/routines/{routine}/hooks/{hook_id}/deliveries
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
With `routines:read` it lists every request that reached the hook in the last 7 days, newest first, within a second of its answer: runs started, duplicates, deliveries whose `if` was false, handshakes, and refusals with their `code` and `reason`. Each entry has `status`, `outcome`, `run_id`, `received_at`, `size`, `source` (`provider`, `edge_replay` or `test`) and a fixed set of headers (`content-type`, `user-agent`, `idempotency-key`, the GitHub event and delivery headers, and a few more). The body, signatures, cookies, credentials and the headers the edge adds are never stored. A hook keeps at most its newest 10,000 entries, and the log takes at most 1,200 POST and 60 GET requests per hook and minute: requests past that are answered as usual but not listed.
|
|
280
|
+
|
|
281
|
+
### Provider handshakes
|
|
282
|
+
|
|
283
|
+
Some providers check the URL before they send events. Routines answers those checks itself, after the signature check, and starts no run, also while the routine is paused:
|
|
284
|
+
|
|
285
|
+
- `slack`: a `url_verification` body gets `200` with its `challenge` as `text/plain`, and an `ssl_check=1` form gets `200` with a `hook_handshake`.
|
|
286
|
+
- `github`: a `ping` (`X-GitHub-Event: ping`) gets `200` with a `hook_handshake`.
|
|
287
|
+
- A handshake that fails verification gets `401`, like any delivery.
|
|
288
|
+
|
|
289
|
+
Providers that verify with a GET, such as Meta (`hub.challenge` with `hub.verify_token`) or Dropbox (`challenge`), need `challenge` on the trigger:
|
|
290
|
+
|
|
291
|
+
```yaml
|
|
292
|
+
- type: webhook
|
|
293
|
+
id: meta
|
|
294
|
+
verify:
|
|
295
|
+
scheme: github # Meta signs X-Hub-Signature-256 over the body the way GitHub does
|
|
296
|
+
secret: conn_01m5t6cbgdjs1ketgcqwa2sne8
|
|
297
|
+
challenge:
|
|
298
|
+
param: hub.challenge
|
|
299
|
+
token_param: hub.verify_token
|
|
300
|
+
token_connection: conn_01m5t6dq3xkf7v2n8w4c9h0y5z
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
`token_connection` is an `api_key` connection whose `api_key` is the verify token you give the provider (store it without pack and without hosts, like the signing secret; naming it takes `vault:run` too). `GET <hook url>?hub.verify_token=<token>&hub.challenge=<value>` then answers `200` with `<value>` as `text/plain`. A missing or wrong token, or a GET to a trigger without `challenge`, gets `401 webhook_signature_invalid`; a challenge value that is not 1-1024 characters of `A-Z a-z 0-9 . _ ~ : + / = -` gets `400`. Without `token_param` and `token_connection` (Dropbox sends no token), any caller gets the echo. Use a verify token of at least 32 random characters; GET verifications are limited to 60 per hook and minute, and more get `429 rate_limited` with `Retry-After`. Events still arrive as signed POSTs and are checked with `verify`.
|
|
304
|
+
|
|
305
|
+
### Rotate the secret
|
|
306
|
+
|
|
307
|
+
```http
|
|
308
|
+
POST /v1/routines/{routine}/hooks/{hook_id}/rotate
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
This issues a new `b3os` secret and keeps the previous one valid for `grace_s` (a day by default) so the sender can switch. Hook IDs stay the same across versions for the same trigger ID.
|
|
312
|
+
|
|
313
|
+
## Pack triggers
|
|
314
|
+
|
|
315
|
+
A trigger of `type: action` subscribes the routine to a trigger a catalog pack provides, such as an issue being opened or an invoice being paid:
|
|
316
|
+
|
|
317
|
+
```yaml
|
|
318
|
+
- type: action
|
|
319
|
+
id: invoice_paid
|
|
320
|
+
uses: io.b3os/stripe/event@1
|
|
321
|
+
with:
|
|
322
|
+
types: [invoice.paid]
|
|
323
|
+
connections:
|
|
324
|
+
secret_key: conn_01m5t6cbgdjs1ketgcqwa2sne8
|
|
325
|
+
if: trigger.data.livemode
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
- `uses` names the pack trigger; a major version such as `@1` resolves to the newest matching release when you publish and is pinned there.
|
|
329
|
+
- `with` configures the trigger and is evaluated once, at publish, with `vars` only. `connections` binds the trigger's connection keys.
|
|
330
|
+
- Publishing creates or updates one trigger subscription (`tsub_`) per action trigger; a new version without the trigger, a rollback to a version without it, or deleting the routine removes it. Subscriptions are read-only at [`GET /v1/actions/subscriptions`](https://docs.beta.b3os.org/actions/triggers).
|
|
331
|
+
- If the actions product refuses the trigger (an unknown trigger, a `with` that fails its configuration schema, a missing connection), the publish fails with `422 routine_invalid` and an `errors[]` item at the trigger.
|
|
332
|
+
- If the actions product cannot take the subscription right now (it is not running on the node, or answers 5xx or 429), the version is still published. The routine then carries a `warnings` entry per action trigger, such as `{"severity": "warning", "code": "product_unavailable", "pointer": "/triggers/0", "detail": "..."}`, on the publish response and on `GET /v1/routines/{routine}`. The trigger starts no runs until it is subscribed. Routines retries every 10 seconds, and the warning goes away once the actions product holds the subscription.
|
|
333
|
+
- Each event that passes `if` starts a run as the publishing key, with the event in `trigger.data`: for this trigger the Stripe event, so `trigger.data.type` is `invoice.paid` and the `if` above skips test-mode events. `trigger.event_type` names the pack trigger, not the provider's event type. Delivery is at least once, and a repeated event ID starts nothing.
|
|
334
|
+
|
|
335
|
+
`GET /v1/actions/triggers` lists the triggers packs provide, with their configuration and event schemas.
|
|
336
|
+
|
|
337
|
+
## When triggers stop
|
|
338
|
+
|
|
339
|
+
Pausing the routine (`PATCH` with `{"paused": true}`) stops every trigger until you resume it. Revoking or expiring the key that published the active version pauses the triggers too, until you publish a new version with a valid key; pack trigger subscriptions show `paused` meanwhile and drop events.
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Routines
|
|
2
|
+
|
|
3
|
+
> Durable workflows written like GitHub Actions with CEL expressions, started by API, cron, webhooks or pack triggers, next to the tools they call.
|
|
4
|
+
|
|
5
|
+
Source: https://docs.beta.b3os.org/routines.md
|
|
6
|
+
|
|
7
|
+
A routine is a workflow you write once and run many times: a list of steps that call B3OS products, HTTP endpoints, marketplace actions and other routines, with expressions between them. It runs inside the B3OS daemon, next to the products it calls.
|
|
8
|
+
|
|
9
|
+
- **Browser, render, VM and model steps in one process.** A step that scrapes a page, takes a screenshot, runs a command in a sandbox or asks the model calls that product in memory, with no glue service between them. While one step waits on the network, a later `sandboxes/exec@1` step gets its sandbox created early ([look-ahead](https://docs.beta.b3os.org/routines/runs#start-a-run)).
|
|
10
|
+
- **Replay copies what did not change.** Replay a run from any step, on a new version or with a new input: the steps that did not change keep their outputs and do not run again, so their effects are not repeated ([replay](https://docs.beta.b3os.org/routines/runs#replay)).
|
|
11
|
+
- **Retries follow the step's effect.** Every callable declares an effect class. `pure` and `read` steps retry by default, a `write` step retries only when it says so, and an `irreversible` step never retries ([retries](https://docs.beta.b3os.org/routines/definitions#retries)).
|
|
12
|
+
|
|
13
|
+
Measured on the B3OS node, from the [benchmark board](https://docs.beta.b3os.org/benchmarks#headline-results). Each figure links its raw data; the board has the conditions.
|
|
14
|
+
|
|
15
|
+
- **Under 200 µs**: Durable workflow step, committed to disk (standard durability, p50 timed by the server, 2026-11-01). [Raw data](https://beta.b3os.org/raw/bench/bench/results/20261101T081324Z-w3q-idle/routines-durable-cross/routines.durable_step.b2b-c1.result.json)
|
|
16
|
+
- **0.349 ms**: Webhook in, signature checked, first durable step done (signed delivery with edge attestation, p50 timed by the server, 2026-11-03). [Raw data](https://beta.b3os.org/raw/bench/routines/results/20261103T080118Z-w3/w4-b3osd-gap100.result.json)
|
|
17
|
+
- **1 µs**: Pure step dispatch (50-step routine, p50 timed by the server, 2026-10-27). [Raw data](https://beta.b3os.org/raw/bench/bench/results/20261027T174857Z-w2d-mixed/routines-pure-mixed/routines.pure_dispatch.b2b-c1+bg.result.json)
|
|
18
|
+
- **1,500,000 steps/s**: Pure workflow steps a second (100-step pure routines, p50 timed by the server, 2026-11-03). [Raw data](https://beta.b3os.org/raw/bench/routines/results/20261103T084012Z-w3-placement/pure-2shards-open15k-core.result.json)
|
|
19
|
+
- **Under 35 µs**: Calling an action from a routine step (typed HTTP action, p50 timed by the server, 2026-11-03). [Raw data](https://beta.b3os.org/raw/bench/routines/results/20261103T080118Z-w3/w6-b3osd-typed-gap100.result.json)
|
|
20
|
+
|
|
21
|
+
Next to what others publish, each timed the same way, server or client, from the same kind of vantage point. A multiplier is the other provider's published figure divided by B3OS's p50, rounded down.
|
|
22
|
+
|
|
23
|
+
- **40x to 66x below Temporal Cloud's published p50**: Workflow start through the API, timed by the server. B3OS 0.303 to 0.49 ms (p50, 5 configurations, 2026-11-03); Temporal Cloud publishes 20 ms ([source](https://docs.temporal.io/cloud/slo)). [How it was measured](https://beta.b3os.org/benchmarks#routines)
|
|
24
|
+
|
|
25
|
+
```yaml nightly-digest.yaml
|
|
26
|
+
name: nightly-digest
|
|
27
|
+
description: Scrape the demo page and summarize it
|
|
28
|
+
triggers:
|
|
29
|
+
- type: cron
|
|
30
|
+
id: nightly
|
|
31
|
+
cron: "0 0 6 * * *" # seconds first: 06:00:00 every day
|
|
32
|
+
tz: America/Los_Angeles
|
|
33
|
+
catch_up: latest
|
|
34
|
+
steps:
|
|
35
|
+
- id: page
|
|
36
|
+
uses: vision/scrape@1
|
|
37
|
+
with:
|
|
38
|
+
url: https://demo.b3os.io/
|
|
39
|
+
formats: [markdown]
|
|
40
|
+
- id: summary
|
|
41
|
+
uses: infer/chat@1
|
|
42
|
+
with:
|
|
43
|
+
model: ${{ vars.model }}
|
|
44
|
+
messages:
|
|
45
|
+
- role: user
|
|
46
|
+
content: "Summarize: ${{ steps.page.outputs.markdown }}"
|
|
47
|
+
vars:
|
|
48
|
+
model: b3os/qwen3.5-9b # or another ID from GET /v1/infer/models
|
|
49
|
+
output:
|
|
50
|
+
summary: ${{ steps.summary.outputs.choices[0].message.content }}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Once published, the `nightly` trigger starts a run at 06:00 Los Angeles time every day until you pause the routine (`PATCH /v1/routines/nightly-digest` with `{"paused": true}`) or delete it.
|
|
54
|
+
|
|
55
|
+
## Settings
|
|
56
|
+
|
|
57
|
+
| Setting | Default |
|
|
58
|
+
|---|---|
|
|
59
|
+
| [Durability](https://docs.beta.b3os.org/routines/settings#durability): `defaults.durability` | `standard` ([per field](https://docs.beta.b3os.org/routines/settings#durability)) |
|
|
60
|
+
| [Pause sandboxes while waiting](https://docs.beta.b3os.org/routines/settings#pause-sandboxes-while-waiting): `defaults.pause_sandboxes` | `false` |
|
|
61
|
+
| [Step timeout](https://docs.beta.b3os.org/routines/settings#step-timeout): `defaults.timeout_ms` | 30,000 ms ([per field](https://docs.beta.b3os.org/routines/settings#step-timeout)) |
|
|
62
|
+
|
|
63
|
+
[Routine settings](https://docs.beta.b3os.org/routines/settings) has all 5, each with its values, what it changes and an example, and what is fixed in the beta.
|
|
64
|
+
|
|
65
|
+
## Publish and run
|
|
66
|
+
|
|
67
|
+
**curl**
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Publish: creates the routine on first use, a new version after that
|
|
71
|
+
curl -s -X PUT https://beta-api.b3os.org/v1/routines/nightly-digest \
|
|
72
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
73
|
+
-H "Content-Type: application/yaml" \
|
|
74
|
+
--data-binary @nightly-digest.yaml
|
|
75
|
+
|
|
76
|
+
# Run it now and wait up to 30 seconds for the result
|
|
77
|
+
curl -s "https://beta-api.b3os.org/v1/routines/nightly-digest/runs?wait=30" \
|
|
78
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
79
|
+
-H "Content-Type: application/json" \
|
|
80
|
+
-d '{"input": {}}'
|
|
81
|
+
```
|
|
82
|
+
**TypeScript**
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { readFile } from "node:fs/promises";
|
|
86
|
+
import { B3OS } from "@b3os/sdk";
|
|
87
|
+
|
|
88
|
+
const b3os = new B3OS();
|
|
89
|
+
// A string is sent as YAML; an object as JSON
|
|
90
|
+
await b3os.routines.publishRoutine("nightly-digest", await readFile("nightly-digest.yaml", "utf8"));
|
|
91
|
+
const done = await b3os.routines.createRun("nightly-digest", { input: {} }).wait();
|
|
92
|
+
console.log(done.status, done.result);
|
|
93
|
+
```
|
|
94
|
+
**Python**
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from b3os import B3OS
|
|
98
|
+
|
|
99
|
+
b3os = B3OS()
|
|
100
|
+
with open("nightly-digest.yaml") as f:
|
|
101
|
+
b3os.routines.publish_routine("nightly-digest", f.read()) # a str is sent as YAML, a dict as JSON
|
|
102
|
+
done = b3os.routines.create_run("nightly-digest", {"input": {}}, wait=True)
|
|
103
|
+
print(done["status"], done.get("result"))
|
|
104
|
+
```
|
|
105
|
+
**MCP**
|
|
106
|
+
|
|
107
|
+
An agent connected to the [B3OS MCP server](https://docs.beta.b3os.org/sdks/mcp) runs a published routine with the `routine_run` tool:
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
Run the nightly-digest routine now and show me the summary.
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The tool takes the routine's name and an `input` object and waits for the output; if the run is still going when the wait ends, it returns the run ID to ask about later.
|
|
114
|
+
|
|
115
|
+
The CLI does the same with `b3os routine deploy` and `b3os routine run`; `b3os routine logs` follows a run. To stop the daily trigger, run `b3os api PATCH /v1/routines/nightly-digest --data '{"paused": true}'`; `b3os api DELETE /v1/routines/nightly-digest` deletes the routine. CLI 0.1.3 has `routine pause` and `routine rm` for these, and names `routine deploy` `routine publish` (it takes both).
|
|
116
|
+
|
|
117
|
+
A sample run on demo data, with step times from recorded calls.
|
|
118
|
+
|
|
119
|
+
[Open the video](https://beta.b3os.org/gallery/docs-site/demo-routine-run/b5ae66319e9a1449.mp4) · [Transcript (WebVTT)](https://beta.b3os.org/gallery/docs-site/demo-routine-run/71f0de1ba2f62b7e.vtt)
|
|
120
|
+
|
|
121
|
+
<details>
|
|
122
|
+
<summary>Transcript</summary>
|
|
123
|
+
|
|
124
|
+
`0:00` Open a routine and press Run now.
|
|
125
|
+
|
|
126
|
+
`0:03` Each step shows how long a recorded call of its kind took.
|
|
127
|
+
|
|
128
|
+
`0:07` Click a step to see its output.
|
|
129
|
+
|
|
130
|
+
`0:10` The graph shows how the steps connect.
|
|
131
|
+
|
|
132
|
+
</details>
|
|
133
|
+
|
|
134
|
+
<sub>Captured 2026-11-15 from commit `2aac696d` on a GitHub Actions runner (colo MSP), one call, label `mock` (the dashboard in mock mode). Case `docs-site/demo-routine-run`.</sub>
|
|
135
|
+
|
|
136
|
+
## What a routine can call
|
|
137
|
+
|
|
138
|
+
A product step's `with` is the operation's request body plus a field for each path or query parameter, and its outputs are the response (for a job, the finished job). [Product steps](https://docs.beta.b3os.org/routines/callables) gives each one's fields, kind and meter. Every product step, from the engine's table:
|
|
139
|
+
|
|
140
|
+
| Step | Does | Effect class |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| `vision/scrape@1` | [Scrape a page](https://docs.beta.b3os.org/api/post-v1-vision-scrape) | read |
|
|
143
|
+
| `vision/map@1` | [Map a site's URLs](https://docs.beta.b3os.org/api/post-v1-vision-map) | read |
|
|
144
|
+
| `vision/crawl@1` | [Crawl a site](https://docs.beta.b3os.org/api/post-v1-vision-crawls), as a job the step waits for | read |
|
|
145
|
+
| `vision/batch@1` | [Scrape a list of URLs](https://docs.beta.b3os.org/api/post-v1-vision-batches), as a job the step waits for | read |
|
|
146
|
+
| `vision/act@1` | [Run browser actions](https://docs.beta.b3os.org/api/post-v1-vision-sessions-session-id-act) | write |
|
|
147
|
+
| `vision/extract@1` | [Extract structured data](https://docs.beta.b3os.org/api/post-v1-vision-extracts), as a job the step waits for | read |
|
|
148
|
+
| `render/screenshot@1` | [Take a screenshot](https://docs.beta.b3os.org/api/post-v1-render-screenshots) | read |
|
|
149
|
+
| `render/video@1` | [Record a video](https://docs.beta.b3os.org/api/post-v1-render-videos), as a job the step waits for | read |
|
|
150
|
+
| `render/restyle@1` | [Restyle a video](https://docs.beta.b3os.org/api/post-v1-render-videos-video-id-restyle), as a job the step waits for | read |
|
|
151
|
+
| `sandboxes/create@1` | [Create a sandbox](https://docs.beta.b3os.org/api/post-v1-sandboxes) | write |
|
|
152
|
+
| `sandboxes/exec@1` | [Run a command](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-exec) | write |
|
|
153
|
+
| `sandboxes/read_file@1` | [Read a file or list a directory](https://docs.beta.b3os.org/api/get-v1-sandboxes-sandbox-id-files) | read |
|
|
154
|
+
| `sandboxes/write_file@1` | [Write a file](https://docs.beta.b3os.org/api/put-v1-sandboxes-sandbox-id-files) | write |
|
|
155
|
+
| `sandboxes/run_code@1` | [Run code in a kernel](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-run-code) | write |
|
|
156
|
+
| `sandboxes/snapshot@1` | [Snapshot a sandbox](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-snapshot) | write |
|
|
157
|
+
| `sandboxes/fork@1` | [Fork a sandbox](https://docs.beta.b3os.org/api/post-v1-sandboxes-sandbox-id-fork) | write |
|
|
158
|
+
| `sandboxes/delete@1` | [Delete a sandbox](https://docs.beta.b3os.org/api/delete-v1-sandboxes-sandbox-id-) | write |
|
|
159
|
+
| `infer/chat@1` | [Create a chat completion](https://docs.beta.b3os.org/api/post-v1-infer-chat-completions) | read |
|
|
160
|
+
| `infer/speech@1` | [Create speech](https://docs.beta.b3os.org/api/post-v1-infer-audio-speech) | read |
|
|
161
|
+
| `vision/search@1` | [Search the web](https://docs.beta.b3os.org/api/post-v1-vision-search) | read |
|
|
162
|
+
| `sandboxes/swarm@1` | [Start a swarm](https://docs.beta.b3os.org/api/post-v1-sandboxes-swarms), as a job the step waits for | write |
|
|
163
|
+
| `infer/embed@1` | Create embeddings; planned: not served on the beta node yet | read |
|
|
164
|
+
| `infer/rerank@1` | Rerank documents; planned: not served on the beta node yet | read |
|
|
165
|
+
|
|
166
|
+
Besides the product steps:
|
|
167
|
+
|
|
168
|
+
| Callable | Does | Effect class |
|
|
169
|
+
|---|---|---|
|
|
170
|
+
| `core/http@1` | An HTTP request through the egress guard | read for `GET` and `HEAD`, otherwise write |
|
|
171
|
+
| `core/transform@1`, `core/log@1` | Reshape a value; write a line to the run's event stream | pure |
|
|
172
|
+
| `routine/<rtn_id>@<ver_id>` | Another routine, pinned to a version | the strictest of its steps |
|
|
173
|
+
| `<namespace>/<pack>/<action>@<version>` | A [marketplace action](https://docs.beta.b3os.org/actions) | the action's own |
|
|
174
|
+
|
|
175
|
+
`map`, `wait` and `sleep_ms` steps fan out over a list, wait for a signal or a time, and pause. [Definitions](https://docs.beta.b3os.org/routines/definitions) covers every field and expression.
|
|
176
|
+
|
|
177
|
+
## Versions
|
|
178
|
+
|
|
179
|
+
Publishing compiles the definition and stores it as an immutable version (`ver_`) that becomes active at once. Triggers switch to it atomically, and runs already in progress keep the version they started with. `POST /v1/routines/{routine}/rollback` makes an earlier version active again. `PUT` takes an ID or a name and creates the routine when the name is new, so deploying is idempotent.
|
|
180
|
+
|
|
181
|
+
A published routine can do no more than the key that published it: every run acts with that key's scopes, copied at publish time, and the effect class of each step (the table above) is fixed when the version is published. If the key is revoked or expires, the routine's triggers pause (`paused_reason: run_as_revoked`) until a new version is published with a valid key. Code inside a sandbox cannot publish a routine (`403 forbidden`, reason `scope_escalation`): the version would keep the sandbox's authority after the sandbox ended.
|
|
182
|
+
|
|
183
|
+
## Durability
|
|
184
|
+
|
|
185
|
+
Each run has a durability tier, set in `defaults.durability` or per run:
|
|
186
|
+
|
|
187
|
+
| Tier | Recorded | Use it for |
|
|
188
|
+
|---|---|---|
|
|
189
|
+
| `ephemeral` | No journal while it runs, so a crash loses a run in flight; once it ends only its summary is stored (status, timing, input, output, error), not its steps or events | Short tool-call routines an agent waits on |
|
|
190
|
+
| `standard` (default) | Each effect is durable before the steps after it run | Most workflows |
|
|
191
|
+
| `strict` | The intent and the result of every effect step | Steps whose effects must never repeat |
|
|
192
|
+
|
|
193
|
+
Durable runs are recovered after a process crash or restart by replaying the node's journal. They do not survive the loss of the node.
|
|
194
|
+
|
|
195
|
+
## Billing and scopes
|
|
196
|
+
|
|
197
|
+
A step bills its product's unit: a `vision/scrape@1` step bills `vision.page`. Only `core/http@1`, `wait` and `sleep_ms` steps bill `routines.effect_step`; other steps bill only what their product bills. A `core/http@1` step also records the bytes it sent and received as `egress.bytes`. The beta allows 50,000 steps a day per organization, and is free within its limits ([pricing](https://docs.beta.b3os.org/concepts/usage#pricing)).
|
|
198
|
+
|
|
199
|
+
| Scope | For |
|
|
200
|
+
|---|---|
|
|
201
|
+
| `routines:write` | Create, publish, validate, import, roll back, pause and delete routines |
|
|
202
|
+
| `routines:run` | Start, signal, cancel and replay runs |
|
|
203
|
+
| `routines:read` | List and read routines, versions, runs, steps and events |
|
|
204
|
+
|
|
205
|
+
## Guides
|
|
206
|
+
|
|
207
|
+
- [Definitions](https://docs.beta.b3os.org/routines/definitions)
|
|
208
|
+
Steps, expressions, contexts, map, wait and retries.
|
|
209
|
+
- [Runs](https://docs.beta.b3os.org/routines/runs)
|
|
210
|
+
Start, follow, signal, cancel and replay runs.
|
|
211
|
+
- [Triggers](https://docs.beta.b3os.org/routines/triggers)
|
|
212
|
+
Cron, interval, signed webhooks and pack triggers.
|
|
213
|
+
- [Limits and FAQ](https://docs.beta.b3os.org/routines/limits)
|
|
214
|
+
Caps, retention and common questions.
|
|
215
|
+
|
|
216
|
+
Moving from the original B3OS workflows? `POST /v1/routines/import` converts a workflow's JSON node tree into a routine definition and reports what did not map.
|