@b3os/cli 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +87 -7
  2. package/assets/b3os-run.py +137 -0
  3. package/assets/skill/b3os/SKILL.md +111 -0
  4. package/dist/commands/_agents.d.ts +14 -0
  5. package/dist/commands/_agents.js +33 -0
  6. package/dist/commands/_agents.js.map +1 -0
  7. package/dist/commands/_common.js +6 -2
  8. package/dist/commands/_common.js.map +1 -1
  9. package/dist/commands/_context.d.ts +49 -0
  10. package/dist/commands/_context.js +260 -0
  11. package/dist/commands/_context.js.map +1 -0
  12. package/dist/commands/_next.d.ts +39 -0
  13. package/dist/commands/_next.js +77 -0
  14. package/dist/commands/_next.js.map +1 -0
  15. package/dist/commands/agent.d.ts +42 -0
  16. package/dist/commands/agent.js +218 -0
  17. package/dist/commands/agent.js.map +1 -0
  18. package/dist/commands/app.d.ts +2 -0
  19. package/dist/commands/app.js +559 -54
  20. package/dist/commands/app.js.map +1 -1
  21. package/dist/commands/auth.d.ts +88 -2
  22. package/dist/commands/auth.js +354 -44
  23. package/dist/commands/auth.js.map +1 -1
  24. package/dist/commands/docs.d.ts +54 -0
  25. package/dist/commands/docs.js +202 -0
  26. package/dist/commands/docs.js.map +1 -0
  27. package/dist/commands/doctor.d.ts +23 -0
  28. package/dist/commands/doctor.js +313 -0
  29. package/dist/commands/doctor.js.map +1 -0
  30. package/dist/commands/init.d.ts +38 -1
  31. package/dist/commands/init.js +259 -60
  32. package/dist/commands/init.js.map +1 -1
  33. package/dist/commands/listen.d.ts +30 -0
  34. package/dist/commands/listen.js +194 -0
  35. package/dist/commands/listen.js.map +1 -0
  36. package/dist/commands/manifest.d.ts +13 -1
  37. package/dist/commands/manifest.js +81 -18
  38. package/dist/commands/manifest.js.map +1 -1
  39. package/dist/commands/mcp.d.ts +25 -2
  40. package/dist/commands/mcp.js +120 -11
  41. package/dist/commands/mcp.js.map +1 -1
  42. package/dist/commands/sandbox.d.ts +35 -6
  43. package/dist/commands/sandbox.js +208 -9
  44. package/dist/commands/sandbox.js.map +1 -1
  45. package/dist/commands/setup.d.ts +39 -0
  46. package/dist/commands/setup.js +203 -0
  47. package/dist/commands/setup.js.map +1 -0
  48. package/dist/commands/tool.d.ts +154 -0
  49. package/dist/commands/tool.js +785 -0
  50. package/dist/commands/tool.js.map +1 -0
  51. package/dist/config.d.ts +30 -6
  52. package/dist/config.js +39 -8
  53. package/dist/config.js.map +1 -1
  54. package/dist/ctx.d.ts +5 -45
  55. package/dist/ctx.js +25 -160
  56. package/dist/ctx.js.map +1 -1
  57. package/dist/docs/index.json +1 -0
  58. package/dist/docs/pages/actions/call.md +300 -0
  59. package/dist/docs/pages/actions/catalog/airtable.md +737 -0
  60. package/dist/docs/pages/actions/catalog/arxiv.md +166 -0
  61. package/dist/docs/pages/actions/catalog/chainalysis-sanctions.md +125 -0
  62. package/dist/docs/pages/actions/catalog/coingecko.md +1558 -0
  63. package/dist/docs/pages/actions/catalog/deps-dev.md +465 -0
  64. package/dist/docs/pages/actions/catalog/dexscreener.md +568 -0
  65. package/dist/docs/pages/actions/catalog/discord.md +784 -0
  66. package/dist/docs/pages/actions/catalog/finnhub.md +776 -0
  67. package/dist/docs/pages/actions/catalog/frankfurter.md +438 -0
  68. package/dist/docs/pages/actions/catalog/github.md +1853 -0
  69. package/dist/docs/pages/actions/catalog/gmail.md +575 -0
  70. package/dist/docs/pages/actions/catalog/google-calendar.md +654 -0
  71. package/dist/docs/pages/actions/catalog/google-drive.md +502 -0
  72. package/dist/docs/pages/actions/catalog/google-sheets.md +700 -0
  73. package/dist/docs/pages/actions/catalog/hacker-news.md +542 -0
  74. package/dist/docs/pages/actions/catalog/http.md +824 -0
  75. package/dist/docs/pages/actions/catalog/hyperliquid.md +942 -0
  76. package/dist/docs/pages/actions/catalog/jira.md +920 -0
  77. package/dist/docs/pages/actions/catalog/kalshi.md +917 -0
  78. package/dist/docs/pages/actions/catalog/linear.md +1030 -0
  79. package/dist/docs/pages/actions/catalog/markets.md +21 -0
  80. package/dist/docs/pages/actions/catalog/morpho.md +247 -0
  81. package/dist/docs/pages/actions/catalog/notion.md +1077 -0
  82. package/dist/docs/pages/actions/catalog/nws.md +485 -0
  83. package/dist/docs/pages/actions/catalog/open-meteo.md +559 -0
  84. package/dist/docs/pages/actions/catalog/polymarket.md +1523 -0
  85. package/dist/docs/pages/actions/catalog/pushbullet.md +220 -0
  86. package/dist/docs/pages/actions/catalog/resend.md +307 -0
  87. package/dist/docs/pages/actions/catalog/s3.md +513 -0
  88. package/dist/docs/pages/actions/catalog/sec-edgar.md +487 -0
  89. package/dist/docs/pages/actions/catalog/slack.md +2629 -0
  90. package/dist/docs/pages/actions/catalog/stripe.md +1405 -0
  91. package/dist/docs/pages/actions/catalog/wikipedia.md +379 -0
  92. package/dist/docs/pages/actions/catalog.md +46 -0
  93. package/dist/docs/pages/actions/limits.md +50 -0
  94. package/dist/docs/pages/actions/model-tools.md +225 -0
  95. package/dist/docs/pages/actions/packs.md +148 -0
  96. package/dist/docs/pages/actions/settings.md +69 -0
  97. package/dist/docs/pages/actions/tools.md +244 -0
  98. package/dist/docs/pages/actions/triggers.md +149 -0
  99. package/dist/docs/pages/actions.md +88 -0
  100. package/dist/docs/pages/compat/anthropic.md +168 -0
  101. package/dist/docs/pages/compat/e2b.md +194 -0
  102. package/dist/docs/pages/compat/firecrawl.md +138 -0
  103. package/dist/docs/pages/compat/openai.md +168 -0
  104. package/dist/docs/pages/concepts/auth.md +151 -0
  105. package/dist/docs/pages/concepts/beta.md +55 -0
  106. package/dist/docs/pages/concepts/glossary.md +71 -0
  107. package/dist/docs/pages/concepts/ids.md +98 -0
  108. package/dist/docs/pages/concepts/jobs.md +229 -0
  109. package/dist/docs/pages/concepts/latency.md +138 -0
  110. package/dist/docs/pages/concepts/limits.md +191 -0
  111. package/dist/docs/pages/concepts/stack.md +59 -0
  112. package/dist/docs/pages/concepts/timing.md +86 -0
  113. package/dist/docs/pages/concepts/usage.md +110 -0
  114. package/dist/docs/pages/design/b3os-yaml.md +370 -0
  115. package/dist/docs/pages/design/deploy-from-github.md +122 -0
  116. package/dist/docs/pages/design/observability.md +134 -0
  117. package/dist/docs/pages/errors.md +1824 -0
  118. package/dist/docs/pages/infer/chat.md +570 -0
  119. package/dist/docs/pages/infer/limits.md +55 -0
  120. package/dist/docs/pages/infer/messages.md +185 -0
  121. package/dist/docs/pages/infer/responses.md +173 -0
  122. package/dist/docs/pages/infer/settings.md +154 -0
  123. package/dist/docs/pages/infer/speech.md +323 -0
  124. package/dist/docs/pages/infer.md +154 -0
  125. package/dist/docs/pages/introduction.md +162 -0
  126. package/dist/docs/pages/platform/addresses.md +174 -0
  127. package/dist/docs/pages/platform/call-log.md +99 -0
  128. package/dist/docs/pages/platform/custom-domains.md +104 -0
  129. package/dist/docs/pages/platform/keys.md +79 -0
  130. package/dist/docs/pages/platform/limits.md +57 -0
  131. package/dist/docs/pages/platform/members.md +101 -0
  132. package/dist/docs/pages/platform/requests.md +116 -0
  133. package/dist/docs/pages/platform/settings.md +129 -0
  134. package/dist/docs/pages/platform/webhooks.md +68 -0
  135. package/dist/docs/pages/platform.md +67 -0
  136. package/dist/docs/pages/quickstart/mcp.md +94 -0
  137. package/dist/docs/pages/quickstart/sandbox-agent.md +205 -0
  138. package/dist/docs/pages/quickstart/scrape.md +134 -0
  139. package/dist/docs/pages/quickstart.md +45 -0
  140. package/dist/docs/pages/render/inspections.md +162 -0
  141. package/dist/docs/pages/render/limits.md +72 -0
  142. package/dist/docs/pages/render/screenshots.md +179 -0
  143. package/dist/docs/pages/render/settings.md +431 -0
  144. package/dist/docs/pages/render/styles.md +342 -0
  145. package/dist/docs/pages/render/videos.md +272 -0
  146. package/dist/docs/pages/render.md +118 -0
  147. package/dist/docs/pages/routines/callables.md +174 -0
  148. package/dist/docs/pages/routines/definitions.md +361 -0
  149. package/dist/docs/pages/routines/limits.md +117 -0
  150. package/dist/docs/pages/routines/runs.md +328 -0
  151. package/dist/docs/pages/routines/settings.md +104 -0
  152. package/dist/docs/pages/routines/triggers.md +339 -0
  153. package/dist/docs/pages/routines.md +216 -0
  154. package/dist/docs/pages/sandboxes/agents.md +217 -0
  155. package/dist/docs/pages/sandboxes/commands.md +272 -0
  156. package/dist/docs/pages/sandboxes/images.md +166 -0
  157. package/dist/docs/pages/sandboxes/limits.md +143 -0
  158. package/dist/docs/pages/sandboxes/ports.md +260 -0
  159. package/dist/docs/pages/sandboxes/settings.md +358 -0
  160. package/dist/docs/pages/sandboxes/snapshots.md +423 -0
  161. package/dist/docs/pages/sandboxes/swarms.md +146 -0
  162. package/dist/docs/pages/sandboxes/volumes.md +131 -0
  163. package/dist/docs/pages/sandboxes.md +231 -0
  164. package/dist/docs/pages/sdks/cli.md +121 -0
  165. package/dist/docs/pages/sdks/mcp.md +169 -0
  166. package/dist/docs/pages/sdks/python.md +146 -0
  167. package/dist/docs/pages/sdks/typescript.md +202 -0
  168. package/dist/docs/pages/sdks.md +282 -0
  169. package/dist/docs/pages/settings.md +33 -0
  170. package/dist/docs/pages/vault/limits.md +46 -0
  171. package/dist/docs/pages/vault.md +133 -0
  172. package/dist/docs/pages/vision/agent-browser.md +115 -0
  173. package/dist/docs/pages/vision/crawl.md +333 -0
  174. package/dist/docs/pages/vision/extract.md +152 -0
  175. package/dist/docs/pages/vision/fetcher.md +15 -0
  176. package/dist/docs/pages/vision/limits.md +79 -0
  177. package/dist/docs/pages/vision/profiles.md +111 -0
  178. package/dist/docs/pages/vision/proxy.md +131 -0
  179. package/dist/docs/pages/vision/scrape.md +356 -0
  180. package/dist/docs/pages/vision/sessions.md +311 -0
  181. package/dist/docs/pages/vision/settings.md +656 -0
  182. package/dist/docs/pages/vision.md +175 -0
  183. package/dist/errors.d.ts +129 -0
  184. package/dist/errors.js +326 -0
  185. package/dist/errors.js.map +1 -0
  186. package/dist/main.d.ts +1 -1
  187. package/dist/main.js +26 -13
  188. package/dist/main.js.map +1 -1
  189. package/dist/manifest/apply.d.ts +4 -0
  190. package/dist/manifest/apply.js +2 -0
  191. package/dist/manifest/apply.js.map +1 -1
  192. package/dist/manifest/domains.d.ts +50 -0
  193. package/dist/manifest/domains.js +159 -0
  194. package/dist/manifest/domains.js.map +1 -0
  195. package/dist/manifest/link.d.ts +20 -0
  196. package/dist/manifest/link.js +24 -0
  197. package/dist/manifest/link.js.map +1 -0
  198. package/dist/manifest/record.d.ts +1 -1
  199. package/dist/tool/archive.d.ts +33 -0
  200. package/dist/tool/archive.js +174 -0
  201. package/dist/tool/archive.js.map +1 -0
  202. package/dist/tool/calls.d.ts +46 -0
  203. package/dist/tool/calls.js +274 -0
  204. package/dist/tool/calls.js.map +1 -0
  205. package/dist/tool/checks.d.ts +21 -0
  206. package/dist/tool/checks.js +145 -0
  207. package/dist/tool/checks.js.map +1 -0
  208. package/dist/tool/elf.d.ts +19 -0
  209. package/dist/tool/elf.js +107 -0
  210. package/dist/tool/elf.js.map +1 -0
  211. package/dist/tool/predict.d.ts +8 -0
  212. package/dist/tool/predict.js +38 -0
  213. package/dist/tool/predict.js.map +1 -0
  214. package/dist/tool/ustar.d.ts +5 -0
  215. package/dist/tool/ustar.js +220 -0
  216. package/dist/tool/ustar.js.map +1 -0
  217. package/package.json +6 -5
@@ -0,0 +1,370 @@
1
+ # b3os.yaml
2
+
3
+ > Declare the models, packs, sandboxes, browsers, routines, services and resources a repository's agents use. Version 0 plans; version 1 deploys with b3os apply.
4
+
5
+ Source: https://docs.beta.b3os.org/design/b3os-yaml.md
6
+
7
+ Warning:
8
+ Both versions of the format are drafts and can change without notice. A version 0 file only plans: the CLI checks it, prints what an apply would do, and changes nothing. A version 1 file deploys: `b3os apply` in CLI 0.2.0 (on npm since 2026-11-12) and the [B3OS Deploy app](https://docs.beta.b3os.org/design/deploy-from-github#with-the-b3os-deploy-app) on GitHub read it, plan, build and run its services ([below](#version-1-draft-deploy-with-b3os-apply)).
9
+
10
+ A repository that runs agents on B3OS uses several building blocks at once: a model, a few packs and their connections, sandboxes of a given size, browsers, the routines that tie them together, and services B3OS does not run, such as a database. Today each one is set up by its own API call or CLI command. `b3os.yaml` writes all of it down in one file in the repository, so a reviewer can read the architecture and a tool can compare it with what the project holds.
11
+
12
+ ## What the file declares
13
+
14
+ | Block | What an entry names | What the dry run checks, and where it reads |
15
+ |---|---|---|
16
+ | `infer.models` | a model ID, its kind, the capabilities the code relies on (`tools`, `json_schema`, `image_input`) and the smallest context it works with | that the node serves the model with those capabilities (`GET /v1/infer/models`) |
17
+ | `actions.packs` | a pack, optionally an exact version, and which stored connection each of its connection keys uses | that the version is on the node and that every connection key has a stored connection (`GET /v1/actions/packs/{namespace}/{name}`, `GET /v1/vault/connections`) |
18
+ | `sandboxes` | a sandbox shape: template, size, ports | that the template exists, the size is within your limits, and whether it is a size the node keeps started (`GET /v1/sandboxes/templates`, `GET /v1/limits`) |
19
+ | `vision.pools`, `render.pools` | how many browsers to keep started, and a saved profile | the profile, for vision (`GET /v1/vision/profiles`); pool sizes are not declarable in the beta |
20
+ | `render.auto_background` | `pin` (a library image `background: auto` draws for the project, on pages whose edges it clears) and `vision` (`false`: pick with the color rules, without the vision model) | that `pin` is an image `auto` may pick (`GET /v1/render/backgrounds`); in the beta the node operator applies it (`[render.auto_background.projects.<id>]`) |
21
+ | `routines` | a routine definition file in the repository | that it compiles (`POST /v1/routines/validate`), and whether the routine is new, changed or unchanged against its active version (`GET /v1/routines/{routine}`) |
22
+ | `resources` | a service B3OS does not run (`postgres`, `mysql`, `redis`, `vector`, `object_store`, `http`), its hosts, the vault connection that holds its credential, and which routines and sandboxes use it | that the connection is stored (`GET /v1/vault/connections`) |
23
+
24
+ The beta has no API object for a sandbox shape: your code creates sandboxes when it needs them. A `sandboxes` entry records the shape the code asks for, so the dry run can check it and a reader can see it.
25
+
26
+ ## An example
27
+
28
+ The sample declares a weekday market brief: a routine reads a page, summarizes it with the node's model and posts it to Slack, a sandbox draws charts, and the briefs go to a Postgres database.
29
+
30
+ ```yaml b3os.yaml
31
+ version: 0
32
+ name: market-brief
33
+ description: Each weekday morning, read a markets page, summarize it with the node's model, post it to Slack and
34
+ keep a copy in Postgres.
35
+
36
+ infer:
37
+ models:
38
+ - id: b3os/default
39
+ kind: chat
40
+ needs: [tools, json_schema]
41
+
42
+ actions:
43
+ packs:
44
+ - id: io.b3os/slack
45
+ connections:
46
+ token: slack-bot # the label of a stored vault connection
47
+
48
+ sandboxes:
49
+ - name: charts
50
+ template: code-interpreter
51
+ vcpu: 2
52
+ memory_mib: 2048
53
+ ports: [8000]
54
+ warm: 1
55
+
56
+ vision:
57
+ pools:
58
+ - name: readers
59
+ browsers: 2
60
+
61
+ routines:
62
+ - file: routines/brief.yaml
63
+
64
+ resources:
65
+ - name: briefs-db
66
+ kind: postgres
67
+ connection: briefs-db
68
+ hosts: [db.example.com:5432]
69
+ used_by: [routine/market-brief, sandbox/charts]
70
+ ```
71
+
72
+ `routines/brief.yaml` is an ordinary [routine definition](https://docs.beta.b3os.org/routines); its `name` is the routine's name. The file is the one `b3os routine deploy` takes today.
73
+
74
+ ## Check the file
75
+
76
+ ```bash
77
+ b3os manifest validate # ./b3os.yaml
78
+ b3os manifest validate path/to/b3os.yaml --json
79
+ b3os manifest schema # the JSON Schema
80
+ ```
81
+
82
+ `validate` works offline. It checks the file against the JSON Schema and reports each finding with its line and column, then checks what a schema cannot: names declared twice, routine files that are missing or do not parse, `used_by` entries that name nothing declared, and packs a routine's steps or action triggers use, or models its steps call, that the file does not declare (a warning). It exits 0 when the file is valid and 5 when it is not.
83
+
84
+ ## Print the plan
85
+
86
+ ```bash
87
+ b3os apply --dry-run # ./b3os.yaml
88
+ b3os apply --dry-run -f path/to/b3os.yaml --json
89
+ ```
90
+
91
+ The dry run reads the project the key belongs to and prints one line per declared item:
92
+
93
+ | Mark | Meaning |
94
+ |---|---|
95
+ | `+` | an apply would create it (a routine that does not exist yet) |
96
+ | `~` | an apply would change it (a routine whose definition differs from its active version; the changed fields are listed) |
97
+ | `=` | it is in place, or there is nothing to apply (models, packs, sandbox shapes, external services whose credential is stored) |
98
+ | `?` | not declarable in the beta (warm sandbox and browser pool sizes) |
99
+ | `!` | a problem an apply would hit (a model the node does not serve, a missing or expired connection, a routine that does not compile) |
100
+ | `-` | not checked, or only partly: the key may not read it, or one of the item's reads (its connections, limits, profile or compile) answered 403, and the line says which |
101
+ | `o` | `b3os apply --keepalive` only: a service someone took down on purpose (`b3os app down`), which keepalive leaves down and `b3os apply` recreates |
102
+
103
+ A pack connection key the file leaves out is checked against the steps and action triggers of the file's routines that need it (the keys the pack lists for each action and trigger), the way a run or a publish resolves it ([Call actions](https://docs.beta.b3os.org/actions/call#connections), [Pack triggers](https://docs.beta.b3os.org/routines/triggers#pack-triggers)). A step that names no `subject` and does not bind the key itself uses the project's newest connection for that pack and key without a `subject`; an end user's connection (one with a `subject`) counts for it only when the file names it. An action trigger takes no `subject`: the publish binds each key the trigger does not bind itself to that same connection. So when such a step or trigger needs the key, a missing or expired connection without a `subject` is a problem (an optional key may have none): a run of the step fails, and so does the publish of the routine with the trigger (`422 routine_invalid`). The line names the step or trigger. A step that names a `subject` uses that end user's newest connection instead, so when every step that needs the key names one or binds it, and every trigger that needs it binds it, the plan flags nothing. It notes how many end users' connections are stored for the key, or, when every one of those steps and triggers binds the key, that the bindings are not checked here. The dry run does not look up a connection that a step or trigger binds in its own `connections`, so a deleted or expired one shows only when a run of the step fails, or the publish of the routine with the trigger does. When no step or trigger in the file needs the key, the plan notes which connection a call without a `subject` would use and flags nothing. A key whose scopes include `*` or `routines:*` can publish a routine; the plan says so when the key cannot.
104
+
105
+ It only reads. Every request is a `GET`, except `POST /v1/routines/validate`, which compiles a definition and stores nothing. It exits 5 when the plan has a problem or an unchecked item and 0 when it has neither; an API error, such as a key that is not valid, exits with the CLI's usual code. For a version 0 file, `b3os apply` without `--dry-run` stops with a usage error and sends nothing.
106
+
107
+ This is the dry run of the example above against `beta-api.b3os.org`, recorded on 2026-11-06 at 01:43 UTC with a project key from a source checkout of the CLI. The project stores neither connection the file names, so the plan has two problems and the command exited 5:
108
+
109
+ ```text b3os apply --dry-run
110
+ b3os.yaml v0 design preview: dry run of market-brief (examples/b3os-yaml/market-brief/b3os.yaml) against https://beta-api.b3os.org, project prj_01m69ww39f6nq8w30vh3xkmsh8
111
+ Nothing was created or changed.
112
+
113
+ infer
114
+ = b3os/default served: chat (alias of b3os/qwen3.5-9b), context 32768 tokens, tools, json_schema, image_input
115
+
116
+ actions
117
+ ! io.b3os/slack 1.0.0 (latest) on the node, 27 actions; packs need no install step
118
+ connection token: no stored io.b3os/slack connection labelled slack-bot
119
+
120
+ sandboxes
121
+ = charts code-interpreter, 2 vCPU, 2048 MiB, 4 GiB; created by your code at run time, nothing to apply
122
+ a size this node keeps started: a create claims a waiting microVM
123
+ ? charts warm warm: 1 is not declarable in this beta; the node sizes its warm pools
124
+
125
+ vision
126
+ ? readers 2 browsers is not declarable in this beta; the node sizes its browser pools
127
+
128
+ routines
129
+ + market-brief new routine from routines/brief.yaml, version 1
130
+ compiles: 3 steps
131
+
132
+ resources
133
+ ! briefs-db external postgres: B3OS does not run it (db.example.com:5432)
134
+ connection briefs-db: not stored in this project
135
+ sandbox/charts would get the credential as a sandbox secret from the connection
136
+
137
+ Plan: 1 to create, 2 in place, 2 not declarable yet, 2 problems.
138
+ + create ~ update = in place ? not declarable in this beta ! problem - not checked
139
+ ```
140
+
141
+ ## Version 1 (draft): deploy with b3os apply
142
+
143
+ Version 1 keeps every version 0 block with the same meaning and adds:
144
+
145
+ - **`services`**: a process B3OS keeps running on the node, such as an agent harness. Each deploy of a service is a new sandbox (a *generation*) started from its build, given the service's source, its environment, secrets from vault connections, a B3OS grant derived from what it `uses`, and an egress policy. Each pack in `uses` (`pack/io.b3os/wikipedia`) is also the only pack the service may call, at the version `actions.packs` gives, and one of its model's tools over MCP at `B3OS_MCP_URL` ([Your model's tools](https://docs.beta.b3os.org/actions/model-tools)). So is each B3OS product it names (node release 1119): `browser` grants `vision:run` and `vision:write` and gives the model the `browser_*` tools (Playwright MCP's names, one browser per sandbox, so each replica has its own), `vision` gives `vision_scrape`, `vision_extract` and `vision_screenshot`, and `render` gives `render_screenshot`, `render_video` and `render_inspect`, each call billed and limited as the product's own API call ([Product tools](https://docs.beta.b3os.org/actions/model-tools#product-tools-browser-vision-render)). A service's environment gets `PYTHONUNBUFFERED=1` unless `env` sets it, so a Python service's `print()` output reaches `b3os app logs` as it is printed.
146
+ - **`services[].restart`**: `on-failure` (the default) has B3OS restart the command in place, in the same sandbox and at the same address, when it exits for any reason B3OS did not cause, with a backoff from 0 to 60 seconds and `crash_loop` after 5 exits in 5 minutes; a converge makes a new generation only when the sandbox itself is lost. `never`: neither happens, and the service is reported (CLI 0.2.2, the **next** release).
147
+ - **`services[].always_on`**: `true` (the default) has the deploy hand each new generation the service's lease, so the node keeps it running with no keepalive and no schedule. `false` keeps the older behavior: the service lives while converges renew its `timeout_s`. Changing either key never replaces a running generation (CLI 0.2.2, the **next** release).
148
+ - **`services[].build`**: the service's dependencies. Apply copies only the `lockfiles` into a sandbox of the build's template, installs the system packages in `apt` as root, runs `install` there with no secrets and no grant, and snapshots it. The snapshot is reused while the template, the size, `apt`, `install`, the build's `env` and the lockfiles' bytes stay the same.
149
+ - **`volumes`** and **`services[].mounts`**: disks that outlive a service's generations, so a database or a service's files survive every deploy, rollback and restart. A deploy of a service with a volume stops the old generation first (node release 1118, on production since 2026-11-20, and CLI 0.2.2, the **next** release; see [Volumes](#volumes)).
150
+ - **`tools`**: programs and MCP servers in the repository that a service runs inside its own sandbox.
151
+ - **`resources[].env`**: how an external resource's credential reaches a service, as a sandbox secret from a connection field (the vault has no URL field: store a `postgres://` URL as a bearer connection's token).
152
+
153
+ The schema is `b3os manifest schema --version 1`. A version 1 example with an agent harness on the node's model, a routine, a pack and an external Postgres is in the repository under `examples/b3os-yaml/research-agent/`. To deploy one from GitHub, start from the template in [Deploy an agent from GitHub](https://docs.beta.b3os.org/design/deploy-from-github).
154
+
155
+ ```bash
156
+ b3os apply --dry-run # the plan; changes nothing
157
+ b3os apply --yes # deploy the checked-out commit
158
+ b3os apply --keepalive --yes # recreate a lost service from the commit it ran (optional: the node keeps services up)
159
+ b3os app status # the tagged objects; per running service its address, process (down when it exited), last call, lease and logs command
160
+ b3os app link research-agent # a link to its address that works 7 days; --rotate ends every link first
161
+ b3os app logs research-agent --follow # a running service's output, each line with its time
162
+ b3os app requests research-agent --failed # the calls a service made to B3OS that failed; sandboxes:read is enough
163
+ b3os app rollback research-agent --yes # deploy the previous commit that went live again, without a checkout
164
+ b3os app down --app research-agent --yes # delete them; its volumes are kept
165
+ ```
166
+
167
+ `b3os app link` comes with CLI 0.2.1, on npm since 2026-11-15.
168
+
169
+ **What the plan says about a service.** Before you confirm, the plan says under each service how it starts, when it counts as ready, who can reach its ports, and what its egress leaves it; under a build that will run, which hosts the install reaches. A service with a public port and an egress allowlist with no hosts, as [GPT Researcher](https://github.com/b3-fun/gpt-researcher/tree/b3os) deployed before addresses:
170
+
171
+ ```text
172
+ services
173
+ + researcher first generation; from build 25f1e2375c37 (base, 2 vCPU, 2048 MiB, 4 GiB)
174
+ command .venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000 --workers 1 (in /workspace/app)
175
+ ready when GET / on port 8000 answers 200-399, up to 180 s
176
+ port 8000 is public: anyone with its URL can use the service, and the B3OS calls it makes count against its $5 spend cap
177
+ the page is served under a path prefix (/sbx/.../), so absolute asset paths 404 and cookies are not kept; see https://docs.beta.b3os.org/sandboxes/ports#base-paths
178
+ grant infer:read infer:run vision:run; spend cap $5
179
+ egress allowlist; kept up by the node (lease); restarted in place when it exits
180
+ no egress hosts: nothing outside B3OS resolves, not even DNS; B3OS is at http://127.0.0.1:7700
181
+
182
+ builds
183
+ + researcher install in base at 2 vCPU / 2048 MiB / 4 GiB, then snapshot (counts 6 GiB of 40); key 25f1e2375c37
184
+ lockfiles requirements.txt, multi_agents/requirements.txt, b3os/requirements-b3os.txt; no secrets and no B3OS grant in the build
185
+ install reaches pypi.org, files.pythonhosted.org, openaipublic.blob.core.windows.net (egress allowlist)
186
+ ```
187
+
188
+ A private port says `reached only through a URL minted for it` instead, and a port that sets `first_byte_s` says how long its preview waits. With addresses, a port with `access` or `public: true`, or the application's default address, is named by its address, `+ address https://gpt-researcher.b3os.io (free now)` before the first apply claims it and `= address https://gpt-researcher.b3os.io` after, and the path-prefix line prints only for an organization without addresses ([App addresses](https://docs.beta.b3os.org/platform/addresses#in-b3osyaml)). Under a service whose new generation replaces a running one, the first lines say what changed since that one's commit: `env + NEW_KEY, ~ CHANGED_KEY, - GONE_KEY` (names only, never a value), the same for `secrets`, `the command changed`, and `source: 4 files changed (caebec0..ee70e90)`, counted in your clone under the service's root (a deploy from GitHub names the two commits instead). `b3os apply --keepalive` leaves out the command, readiness and port lines, since it changes nothing you decide. After a deploy that failed and was undone, the next plan does not count the undone generation as one that served: with nothing running it plans a first generation since the deleted one.
189
+
190
+ **Egress with no hosts.** `egress: { mode: allowlist }` with nothing in `allow`, or `mode: deny`, leaves a service nothing outside B3OS: no connection and no DNS. A program that looks a host up gets a name-resolution failure (Python: `[Errno -3] Temporary failure in name resolution`), not a refused connection, so a library that checks a URL by resolving its host first skips every URL. B3OS itself stays at `http://127.0.0.1:7700`: the model, search and page reads go through it, and the URLs you hand vision are fetched by B3OS, not by the sandbox. List a host in `allow` when the service must reach it directly.
191
+
192
+ What `b3os apply` does, in order, after it prints the plan and you confirm it (`--yes` in CI, where it never prompts):
193
+
194
+ 1. Checks each generation it keeps (its process runs and its probe passes). One the node keeps under its lease needs nothing more (`kept sbx_…: the node holds its lease`); one without a lease gets it, and one with `always_on: false`, or on a node from before leases, has its timeout renewed at once. A generation whose command is restarting in place passes; one in `crash_loop` is reported and kept, since a new generation would run the same commit on an empty disk; one that fails the check otherwise, or stopped before the renewal, gets a new generation.
195
+ 2. Publishes each new or changed routine (`PUT /v1/routines/{name}`) and tags it.
196
+ 3. Builds each service whose lockfiles changed, deletes that service's spare build snapshot, and snapshots the new build. The build sandbox is deleted whatever happens.
197
+ 4. Starts every new generation, its command restarted in place when it exits, and waits for each one's readiness probe; a service with a volume [stops its old generation first](#volumes), after every other service's new generation is ready. Once the new generations serve, it hands each one its service's lease (`lease held by sbx_…: the node keeps it up`), then sends `TERM` to the previous generations, gives them `drain_s` to exit and deletes them. A previous generation lost its lease at the handoff, so it stops within 15 minutes even if its delete fails.
198
+
199
+ Each object apply makes carries `b3os.*` metadata: the application (`b3os.app`, the file's `name`), the item, the deploy id and the git revision. A routine or service the file no longer declares is shown as `x` and removed only with `--prune`; without it, the service's generation gives up its lease and stops within 15 minutes. A routine tagged with another application's name is never changed.
200
+
201
+ If a step fails before the cutover, apply undoes this run: it deletes the generations it started and puts each routine back on the version it had (a routine this run created is deleted), so the previous generations keep serving the previous routines. It exits 10 and the summary lists what it did and what it undid. Ctrl-C or `SIGTERM` (a cancelled CI job) stops it after the call in flight and undoes the run the same way, exiting 130. In GitHub Actions the signals reach the CLI only when the step starts it with `exec` (`exec b3os apply --yes`), as the template does: the runner signals the step's shell alone, and the shell does not pass the signals on. A plan with a problem changes nothing and exits 5.
202
+
203
+ The source a service gets is the tracked files of its folder at the checked-out commit (`git archive`), so ignored files such as `.env` never leave your machine; uncommitted changes are not deployed. `b3os.yaml` and the routine files it names deploy only as committed too: with uncommitted changes to any of them the plan stops, and you commit first. A service's source over 64 MiB compressed (the file write limit) stops the plan as well.
204
+
205
+ **Files that look like credentials.** A tracked file under a service's folder whose name starts with `.env` (`.env`, `.env.local`, `.envrc`) or ends in `.pem` stops the plan, with three exceptions:
206
+
207
+ - A template is uploaded: a name that ends in `.example`, `.sample`, `.template`, `.dist` or `.defaults`, in any case, such as `.env.example`, when no value in it looks like a real credential. A value looks like one when it is a known key prefix (`sk-`, `ghp_`, `gho_`, `github_pat_`, `xoxb-`, `xoxp-`, `AKIA`, `AIza`, `b3os_`) with a key after it, a PEM block (`-----BEGIN`), or a random-looking string of 24 or more characters that is not a URL, a path or a sentence. Placeholders such as `sk-...` or `your-key-here` pass, and so do comments without a key. A template that holds a credential stays a problem: the plan names the file and the line, never the value.
208
+ - A path listed in the service's `source.allow_secret_files` is uploaded whatever it holds. Entries are exact tracked paths relative to the service's folder, as the plan names them, with no globs. The list is reviewed with the rest of `b3os.yaml`, and the GitHub App reads it from the commit as `b3os apply` does.
209
+ - `b3os apply --allow-secret-files` uploads every such file. Keepalive checks the commit it recreates a service from the same way, so if your deploy step passes the flag, pass it to the keepalive step too. A path in `b3os.yaml` needs no flag on either step.
210
+
211
+ ```yaml
212
+ services:
213
+ - name: harness
214
+ source:
215
+ allow_secret_files: [.env.production] # uploaded, and listed by the plan as allowed by b3os.yaml
216
+ ```
217
+
218
+ **How long a service lives.** The deploy hands each new generation its service's lease on the node (`PUT /v1/sandboxes/{id}/lease`, key `b3os:<app>/<service>`), and the node keeps the sandbox running from then on, renewing it itself, with no keepalive and no schedule. The lease ends when `b3os app down` deletes the generation, when a newer deploy or a rollback hands it to a newer generation (the old one then stops within 15 minutes, its retire's delete aside), when an apply finds the service gone from the file (released, unless `--prune` removes it at once), or when your organization's credits or the service's own spend cap stop the sandbox. The deploying key's expiry, revoke or spend cap does not: a service belongs to its project (`owner: "project"`, with deploys from GitHub and CLI 0.2.2). A service deployed before that moves to its project at its next deploy, through one new generation. An organization holds 5 leases per node (`sandboxes.leases_max`); past that a deploy says `no lease: sandboxes.leases_max 5 reached; renewed by converges`, and that service lives while converges renew its timeout, at most 3,600 seconds at a time, as with `always_on: false`. When the service's command exits, the node starts it again in place; `b3os app status` shows `restarting` while it waits and `crash loop` after 5 exits in 5 minutes. The workflow template in `examples/b3os-yaml/github-actions/b3os.yml` deploys on every push to `main`, with a project key stored as the `B3OS_API_KEY` secret, and keeps an optional keepalive every 10 minutes, which matters only when a sandbox is lost (a reboot of the node) or for `always_on: false`. Keepalive never publishes a routine and never deploys a newer commit: it recreates a lost generation from the commit it recorded, so it cannot undo a rollback. It does not recreate a generation that was deleted on purpose (`b3os app down`, `--prune`). A keepalive that recreates a service records a deploy of its own when its key holds `sandboxes:write`: why (`process 466 killed by TERM at 01:15:37 UTC`, `the lease ended at 20:24:07 UTC`) and the last 20 lines the lost process printed, which its deleted sandbox no longer serves. The console lists it as Recreated after a crash, or after the lease ended. A keepalive that only renews records nothing. The lease handoff and the restart in place come with CLI 0.2.2, the **next** release; with CLI 0.2.1 a service lives while converges renew its timeout.
219
+
220
+ **Addresses.** Addresses are on for every organization since 2026-11-16: a port with `access` (or `public: true`) gets one address on `b3os.io` that never changes, shared by link unless it says `access: public`; `host`, `primary` and `cookies` shape it. When no port sets either, the application's primary port gets one by default (from a deploy from GitHub now, and from `b3os apply` with CLI 0.2.2, the **next** release), and `address: false` on a port opts it out. [App addresses](https://docs.beta.b3os.org/platform/addresses) has the keys, the cookie rules and the limits. Any other port keeps its preview URL, new for each generation.
221
+
222
+ **What version 1 does not do yet.** There are no replicas, no previews per pull request, no organization-private packs from a folder and no tools from another repository; the plan marks those `?`. A database runs as a service on a [volume](#volumes); a managed `kind: postgres` comes later, and until private networking between an application's services ships, another service cannot reach it.
223
+
224
+ ### Volumes
225
+
226
+ A volume keeps a service's files across every deploy, rollback, restart and keepalive. Declare it with its size, and mount it in the one service that writes it, at one or more paths, each from a folder of the volume (`subpath`) or its root:
227
+
228
+ ```yaml b3os.yaml
229
+ version: 1
230
+ name: notes
231
+ volumes:
232
+ data:
233
+ size_gib: 2
234
+ description: the notes and their index
235
+ services:
236
+ - name: web
237
+ command: [python3, app.py]
238
+ mounts:
239
+ - { volume: data, path: /workspace/app/data, subpath: data }
240
+ - { volume: data, path: /workspace/app/outputs, subpath: outputs }
241
+ ports: [{ port: 8080 }]
242
+ readiness: { http: { port: 8080, path: /healthz } }
243
+ ```
244
+
245
+ ```python app.py
246
+ print("notes")
247
+ ```
248
+
249
+ The deploy names the volume `<name>.<volume>` in your project (`notes.data`), creates it at the first apply, and mounts it in every new generation before its source is unpacked and its command starts. Files the commit tracks under a mount path inside the service's folder are left out of the upload, and the plan names them, so a deploy never writes over the volume's data.
250
+
251
+ - **One volume per service, one service per volume.** A volume has one writer. Mount several of its folders with `subpath`. `replicas` stays at 1 for a service with a volume.
252
+ - **Paths.** A mount path is absolute, not a system folder or under one (mount under `/workspace`, `/data`, `/home`, `/srv`, `/opt` or `/var/lib`), not the service's `cwd` or a folder above it (the source unpacks there), and two never overlap.
253
+ - **Limits in this beta.** 16 GiB a volume, 10 volumes and 32 GiB for an organization on a node. `size_gib` grows (at the service's next generation) and never shrinks.
254
+ - **One copy, no backup, not encrypted at rest.** A volume is one file on the node's one drive, like every sandbox disk unencrypted. Keep your own copy of what you cannot lose, and have your code fsync what matters: a flushed write survives a crash, an unflushed one may not. [Volumes](https://docs.beta.b3os.org/sandboxes/volumes#said-plainly) says more.
255
+
256
+ **Stop first.** A volume has one writer, so a deploy that gives the service a new generation stops the old one before the new one starts: its addresses stop, it gets `TERM` and up to `drain_s` to exit, it is deleted, and the new generation is created once the node has freed the volume (when the old microVM has exited). The service serves nothing in between. The plan says so under the service, with the gap the last such deploy measured:
257
+
258
+ ```text
259
+ volumes
260
+ = data keep vol_01kfz… 2 GiB, 214 MiB used, attached to sbx_01kfz… (web)
261
+ survives every deploy, restart and keepalive of web: what it writes under /workspace/app/data and /workspace/app/outputs; the rest of its disk starts again from the build at each new generation
262
+ never rolled back with the code: b3os app rollback leaves its data as it is
263
+
264
+ services
265
+ ~ web new generation replaces sbx_01kfz…: spec 3f1c… → 9a0e…; from template base (base, 1 vCPU, 512 MiB, 4 GiB)
266
+ stop first (volume data has one writer): the old generation stops, then the new one starts: a gap of about 9 s (the last deploy's, measured from the release of the old generation to the switch); web serves nothing in between
267
+ ```
268
+
269
+ Its first stop-first deploy has no measurement yet, and says the bounds instead: from the old generation's `TERM` (up to `drain_s`) until the new one is ready (up to its readiness `timeout_s`). The deploy keeps the measured gap on the volume, and `b3os app status` shows it. Every other service's new generation is ready before a service with a volume stops, so a failure elsewhere never stops it. If the new generation fails to start, apply puts the old one back: it makes it again from the revision it ran, on the same volume, starts it and switches its addresses back, and the run exits 10 as any failed deploy does.
270
+
271
+ On production (2026-11-20, GPT Researcher with a volume), a client polling the address got `503` for a few seconds longer than the gap the deploy reports, since the address stops before the old generation's `TERM` and the switch reaches clients a little after the deploy makes it: plan for the longer one. A Postgres service on a volume (`examples/deploy/postgres-volume`, ten deploys the same day) refused connections, seen from inside its sandbox, for a little less than the gap its deploy reported, and how long Postgres took to shut down after `TERM` made most of the difference between one deploy and the next. Every new generation started from a clean shutdown.
272
+
273
+ **What survives a deploy.** What the service wrote under its mount paths. The rest of its sandbox's disk starts again from the build at each new generation, as before.
274
+
275
+ **Data is never rolled back.** `b3os app rollback` deploys an earlier commit's code onto the volume as it is: a schema migration the current code ran stays. A rollback to a commit whose `b3os.yaml` mounts no volume where a generation holds one now is a plan problem, so rolled-back code never runs without its data.
276
+
277
+ **What the plan shows.** `+` creates a volume, `=` keeps one, `~` grows one (now when nothing holds it, else at the service's next generation), and `!` stops the plan for a smaller `size_gib` than the volume has (a volume never shrinks), a volume another application's tag names, or one a sandbox outside the service holds. A volume the application made that the file no longer declares is listed as orphaned: kept, and billed, until you delete it (`b3os sandbox volumes rm notes.data`); `--prune` never removes one. A deleted volume in its 7-day grace keeps its name: the plan asks you to restore it, to keep its data, or purge it, to start empty. Against a node without volumes (before release 1118) the plan shows one line, `? volumes this node has none`, and the service deploys as before, its files on its own disk, which the next deploy empties.
278
+
279
+ **What b3os app down keeps.** Its volumes, with their data, listed at the end. `b3os app down --app notes --yes --delete-volumes notes`, with the application's name typed again, deletes them too, each restorable for 7 days with `b3os sandbox volumes restore notes.data`. A project that keeps a volume, or a deleted one still restorable, is not deleted until its volumes are purged.
280
+
281
+ `examples/deploy/postgres-volume/` in the repository runs Postgres 16 with pgvector, from Ubuntu's packages installed by the build's `apt` step on the `base` template, as a plain service on a volume.
282
+
283
+ ### System packages
284
+
285
+ A build can install Ubuntu packages before `install`, for the libraries a Python or Node dependency loads at run time (WeasyPrint needs Pango and Cairo, a browser scraper needs its browser's libraries):
286
+
287
+ ```yaml
288
+ services:
289
+ - name: harness
290
+ build:
291
+ template: base
292
+ lockfiles: [requirements.txt]
293
+ apt: [libpango-1.0-0, libpangoft2-1.0-0, libcairo2, fonts-dejavu-core]
294
+ install: pip install --no-cache-dir --target /workspace/deps -r requirements.txt
295
+ egress: { mode: allowlist, allow: [pypi.org, files.pythonhosted.org] }
296
+ ```
297
+
298
+ The build runs `apt-get update` and `apt-get install -y --no-install-recommends` with the listed names, as root and non-interactive, after the lockfiles are copied and before `install`. Packages that ship a service do not start it in the build. Ubuntu's mirrors, `archive.ubuntu.com` and `security.ubuntu.com`, are added to the build's egress for that step only, and the build has its own `egress` again when `install` starts. An entry is a Debian package name or `name=version`, at most 64 of them; options and anything else are refused by the schema. The list is part of the build key, in any order, so a new package builds again and a reorder does not. A failed step fails the build with its last lines, and the plan shows the step. A deploy the GitHub App runs keeps the step's output on its record (`output`, step `apt`), and the application's Deployments tab shows it as it arrives, before the install's. Every generation starts from the build's snapshot, so the packages are there for `prepare` and `command` too.
299
+
300
+ ### Size
301
+
302
+ A service's `vcpu`, `memory_mib` and `disk_gib` default to its template's. Memory goes up to your plan's `sandboxes.memory_max`, 4096 MiB in the beta, and the plan refuses more with the limit's name. The disk is the template's at most: in the beta no sandbox gets a larger disk than its template, and the plan says so with the real maximum and the templates that have a larger disk (`GET /v1/sandboxes/templates` lists each one's `defaults.disk_gib`). After `install`, the build prints what the disk holds, used and free, in the log and at the end of its line in the deploy's summary (`built: install <t> s, …; disk <used> used, <free> free of <size>`), and says so when less than a tenth is free. A generation starts from that disk with the source on top, so that is the room the service has for its own files. Once a new generation passes its readiness probe, the summary also says how much memory it has left (`started sbx_… (…); memory <available> MiB available of <total> MiB`), with a warning under a tenth; `GET /v1/sandboxes/{sandbox_id}/stats` reads the same while it runs ([what it uses now](https://docs.beta.b3os.org/sandboxes#what-it-uses-now)).
303
+
304
+ ### Slow responses
305
+
306
+ A service's port preview waits 65 seconds for a response to start, then answers [`504 upstream_first_byte_timeout`](https://docs.beta.b3os.org/errors#upstream_first_byte_timeout). A port can wait up to 95 seconds with `first_byte_s`:
307
+
308
+ ```yaml
309
+ services:
310
+ - name: harness
311
+ ports: [{ port: 8000, public: true, first_byte_s: 95 }]
312
+ ```
313
+
314
+ Past that, an endpoint that runs for minutes before it answers needs to stream its answer, or to start the work and let the client poll: [slow responses](https://docs.beta.b3os.org/sandboxes/ports#slow-responses) has an example. A changed `first_byte_s` gives the service a new generation.
315
+
316
+ ### Head and hands: where model-written code runs
317
+
318
+ Make an agent's service its head. It holds the secrets (`secrets` and `resources[].env`), the packs' connections and the B3OS grant, and runs only code from the repository. A connection in `secrets` or `resources[].env` reaches the service as an environment variable, so deploying it takes a key with `vault:connections:reveal` (a deploy by the GitHub App holds it for the connections the linked branch's file names), and a connection bound to `hosts`, such as a pack's, is refused there: name it in the service's `actions` or `uses` instead, where B3OS adds it at the egress proxy. The code the model writes runs in a hands sandbox the head creates for each task, with egress `deny` (or a short allowlist) and without `secrets`, `env` or `api`. Any code in a sandbox can read that sandbox's environment variables and send them wherever its egress and grant reach, and vision fetches any URL it is given. In the head, hostile code that a page talked the model into writing would be one call away from the database URL.
319
+
320
+ ```yaml
321
+ sandboxes:
322
+ - name: hands
323
+ template: code-interpreter # the head creates these at run time; apply creates nothing
324
+
325
+ services:
326
+ - name: harness # the head
327
+ uses: [model/b3os/default, vision, pack/io.b3os/github, sandbox/hands]
328
+ egress: { mode: allowlist } # apply adds the database's host and port
329
+ ```
330
+
331
+ - `sandbox/hands` grants the head `sandboxes:read`, `sandboxes:run` and `sandboxes:write`. A grant gets `sandboxes:write` only when `uses` names it ([Sandboxes that create sandboxes](https://docs.beta.b3os.org/sandboxes/agents#sandboxes-that-create-sandboxes)).
332
+ - The node keeps the hands within the head. A child sandbox whose egress reaches further than its parent's is refused with `egress_escalation`, and the head can send commands, `run_code` and files only into a sandbox whose grant holds nothing its own lacks. Hands that need a package registry need it in the head's `egress.allow` too.
333
+ - Version 1 declares the shape's template and size, and the plan checks both. It cannot declare the shape's egress, or that it gets no secrets: the head's code sets both when it creates the sandbox.
334
+ - Give each hands sandbox a timeout a little past the task's own limit, and delete it when the task ends. A head lost before the delete leaves it running until that timeout and no longer.
335
+ - Hands count against the organization's sandboxes: 10 running or paused in the beta.
336
+
337
+ The [deploy template](https://docs.beta.b3os.org/design/deploy-from-github) works this way. Its `run_python` tool sends the model's Python to a `code-interpreter` sandbox made for the question, and the harness deletes that sandbox when the question ends.
338
+
339
+ ### Settings, evals and alerts (version 1)
340
+
341
+ Three more top-level blocks, each optional:
342
+
343
+ ```yaml
344
+ settings:
345
+ platform.capture_content: model # prompt logging on for this project (off by default)
346
+ evals:
347
+ - name: answers
348
+ service: harness # runs this service's code at the commit under test
349
+ cases: evals/answers.jsonl # one JSON object per line: input, expected, metadata
350
+ call: { port: 8080, method: POST, path: /answer } # or { command: "python3 answer_one.py" }
351
+ scorers:
352
+ - { name: correct, contains: "$.expected.answer" }
353
+ - { name: grounded, judge: evals/rubrics/grounded.md, pass: 0.7 }
354
+ pull_requests: { sample: 20 }
355
+ gate: { pass_rate_drop_max: 0.05, min_failed_cases: 2, block: false }
356
+ observe:
357
+ notify: [ops-slack] # where deploy, service and eval-gate alerts go
358
+ ```
359
+
360
+ - **`settings`** holds project settings by option id. For an option this node serves (`platform.capture_content`, [prompt logging](https://docs.beta.b3os.org/platform/call-log)) the plan reads `GET /v1/settings` and prints `~ settings platform.capture_content off -> model`, or `=` when the project already sets that value, and apply writes it with `PUT /v1/projects/{project_id}/settings/{option}`, which needs `settings:write` (the plan marks a key without it `!`; CLI 0.2.2, the **next** release: CLI 0.2.1 lists every option with `?`). A deploy B3OS runs from a linked repository writes settings only when it was asked for by a credential that could write them (linking the repository, a redeploy or a rollback); a push names no credential, so its plan marks a change `!` and the deploy stops until the project already holds the value. A setting the project sets that the file no longer names is unset only with `--prune`, under the same scope. Every other option is listed with `?`: nothing applies it in this beta. An export that would send prompts (`platform.export_otlp` with `content: true`) is a plan problem, because only an owner's or admin's session may turn one on.
361
+ - **`evals`** declares suites. With the GitHub App linked, each pull request whose author can write to the repository runs a sample of the cases against the pull request's code, and each push to the linked branch runs all of them. The result is a `b3os/evals (<app>/<suite>)` check with the pass rate and cost against the base branch. A drop is reported as `neutral` unless the gate says `block: true`. Suites run in a project of their own, `<app>-evals`, under the grant, secrets, connections and egress the linked branch's file gives the service and the suite, so a pull request cannot widen them; it changes only how the service is built and run. Every suite posts its check on every pull request (`skipped` when nothing it reads changed), so a repository can require it. Scorers: `equals`, `contains`, `regex`, `json_schema`, `numeric`, `code` (a command that reads `{input, expected, output}` on stdin and prints `{score}`) and `judge` (a rubric file, scored by the node's model).
362
+ - **`observe.notify`** names alert destinations stored in the project (a Slack incoming webhook or a signed webhook, `PUT /v1/alerts/destinations/{name}`). The file names a destination and never holds its URL. `observe.alerts` and `observe.judges` are accepted and marked `?`: metric alerts and online judges come later.
363
+
364
+ ## What version 0 leaves out
365
+
366
+ - **Apply.** Nothing creates, publishes or deletes from a version 0 file. The design question that blocked it is ownership: which objects a file owns, so that removing an entry can remove the object without touching ones created by hand. Version 1 answers it with the `b3os.app` tag.
367
+ - **Pools.** Warm sandbox and browser pool sizes are set by the node in the beta. The fields exist so a file can say what it needs.
368
+ - **Secrets.** The file names stored connections by ID or label and never holds a credential.
369
+ - **Environments.** A file describes one project; version 0 has no per-environment overrides.
370
+ - **Builds.** Custom sandbox templates do not exist in the beta, so a sandbox entry names one of the node's templates.
@@ -0,0 +1,122 @@
1
+ # Deploy an agent from GitHub
2
+
3
+ > Install the B3OS Deploy app and each push deploys the repository's b3os.yaml. Or run b3os apply from a GitHub Actions workflow.
4
+
5
+ Source: https://docs.beta.b3os.org/design/deploy-from-github.md
6
+
7
+ Warning:
8
+ Version 1 of [b3os.yaml](https://docs.beta.b3os.org/design/b3os-yaml#version-1-draft-deploy-with-b3os-apply) is a draft and can change. The research-agent template below has been deployed only against a test double of the B3OS API; against beta-api.b3os.org only its dry run has run.
9
+
10
+ There are two ways in. The [B3OS Deploy](https://github.com/apps/b3os-deploy) app deploys a repository's `b3os.yaml` on each push, with no workflow file and no key in the repository. Or a GitHub Actions workflow runs `b3os apply` with a project key, as the template below does.
11
+
12
+ ## With the B3OS Deploy app
13
+
14
+ **Install the app**
15
+
16
+ On GitHub, install [B3OS Deploy](https://github.com/apps/b3os-deploy) on the account that owns the repository, for the repositories you choose. It asks to read members and metadata, and to read and write checks, code and pull requests. It reads their files and posts the plan. It writes code only for a change you ask for in B3OS: it pushes a new branch and opens a pull request into the linked branch. It never pushes to the linked branch itself; merging the pull request, on GitHub or with Merge and deploy in the console, is what changes it. Installing it on an organization asks the organization's owner to confirm with GitHub. In B3OS, only an owner or an admin of the organization can connect it.
17
+
18
+ **Link the repository**
19
+
20
+ Open [Deploy from GitHub](https://beta.b3os.org/app/deploy) in the console and pick the repository. Then choose the branch, the `b3os.yaml` to deploy (its path from the repository's root) and the application's name, the name in the file. Linking deploys the branch as it is now.
21
+
22
+ **Push**
23
+
24
+ Each push to the branch deploys. B3OS reads the commit through the app, plans it and posts the plan as a check, then builds, starts the new generation and cuts over once its readiness probe passes. A plan with a problem deploys nothing. The application's Deployments tab in the console shows each step as it runs.
25
+
26
+ **Open a pull request**
27
+
28
+ A pull request gets the plan as a check and a comment. Nothing deploys.
29
+
30
+ The node keeps the live deploy's services running itself, under a lease the deploy hands each new generation, and starts a service's command again in place when it exits, so no schedule runs in the repository. B3OS still checks the live deploy every 10 minutes, which recreates a service only when its sandbox was lost. Redeploy and roll back from the application in the console.
31
+
32
+ To take the application down, use Take down in its Settings in the console (or `b3os app down`): its addresses stop, then its services, routines and build snapshots are deleted, and the 10-minute check leaves it down. The next push to the linked branch deploys it again; Unlink the repository first to stop that. Unlink alone stops pushes deploying and keeps what runs running.
33
+
34
+ ## With a GitHub Actions workflow
35
+
36
+ The template is a whole repository for a research agent. Its harness, a small TypeScript service, runs in a sandbox on the B3OS node and calls the model served there, vision and a pack through the sandbox's grant, with no API key inside the sandbox. The Python the model writes runs in a second sandbox made for each question, which holds no credential and has no network ([head and hands](https://docs.beta.b3os.org/design/b3os-yaml#head-and-hands-where-model-written-code-runs)). A file in the repository, `b3os.yaml`, declares all of it. A GitHub Actions workflow runs `b3os apply` on every push to `main`. The node keeps the harness running and restarts it in place when it exits; the workflow's optional `b3os apply --keepalive` schedule only recreates a harness whose sandbox was lost, such as after the node itself reboots.
37
+
38
+ The template is not yet published as a public repository. Its own `README.md` shows the plan and the deploy output, recorded against the test double.
39
+
40
+ ## What the agent does
41
+
42
+ You add a question to a table in your Postgres database. The harness claims it, and the agent reads pages with [vision](https://docs.beta.b3os.org/vision), runs a routine that reads several pages at once, lists a page's links with a program that ships in the repository, works things out in Python it writes, and answers with the node's model. When the question names a GitHub repository, the harness files the answer there as an issue through the [GitHub pack](https://docs.beta.b3os.org/actions/catalog/github).
43
+
44
+ | In `b3os.yaml` | In the template |
45
+ |---|---|
46
+ | a model | `b3os/default`, reached through the OpenAI SDK at `B3OS_API_URL` plus `/v1/infer` with a placeholder key, as [agents in sandboxes](https://docs.beta.b3os.org/sandboxes/agents#call-b3os-from-inside) describes |
47
+ | a service | `harness`: built with `npm ci` from `agent/package-lock.json`, started as `node src/main.ts`, checked with `GET /healthz` on port 8080 |
48
+ | B3OS products | `vision`, and the routine `gather-sources` |
49
+ | a pack | `io.b3os/github`, with the stored connection labelled `github-bot` |
50
+ | a tool | `extract-links`, a program in `agent/tools/` that runs inside the harness's sandbox |
51
+ | a sandbox shape | `hands`: a `code-interpreter` sandbox the harness creates for each question that runs code, with egress `deny` and without secrets or a grant, and deletes when the question ends |
52
+ | an external resource | `research-db`, your Postgres; its URL reaches the harness as the secret `DATABASE_URL` |
53
+
54
+ The harness's sandbox gets only the scopes these entries imply. Its egress allows the database's host and port and nothing else on the internet: the model, vision, the routine and the pack are reached through B3OS. The hands get no B3OS access and egress `deny`. A host that is not in the allowlist does not resolve either: with no hosts at all, nothing outside B3OS resolves, not even in DNS ([egress with no hosts](https://docs.beta.b3os.org/design/b3os-yaml#version-1-draft-deploy-with-b3os-apply)).
55
+
56
+ ## Before you start
57
+
58
+ - A project key with `routines:read`, `routines:write`, `routines:run`, `sandboxes:read`, `sandboxes:write`, `sandboxes:run`, `vault:read`, `vault:run`, `vault:connections:reveal`, `actions:read`, `actions:run`, `infer:read`, `infer:run` and `vision:run`. `vault:connections:reveal` puts the `research-db` connection's token into the harness as `DATABASE_URL`; only owners and admins can create a key that holds it. Give it a spend cap and an expiry ([keys](https://docs.beta.b3os.org/platform/keys)). The services it deploys belong to the project, so its expiry or revoke does not stop them ([services belong to their project](https://docs.beta.b3os.org/concepts/auth#services-belong-to-their-project)).
59
+ - A Postgres database the internet can reach.
60
+ - Two [connections](https://docs.beta.b3os.org/vault) in the same project. The repository never holds a credential; it names these by label:
61
+
62
+ ```bash
63
+ printf %s "$DATABASE_URL" | b3os connect new --type bearer --label research-db
64
+ b3os connect io.b3os/github --label github-bot
65
+ ```
66
+
67
+ The vault has no URL field, so the `postgres://` URL is stored as a bearer connection's token. A connection with no hosts is never added to any request; it reaches the harness only as the sandbox secret `b3os.yaml` names.
68
+
69
+ ## Deploy it
70
+
71
+ **Copy the template**
72
+
73
+ Make a repository of your own from the template. A public template repository is not published yet; once it is, choose **Use this template** on its GitHub page rather than forking it. GitHub runs no workflow in a new fork until you turn workflows on, and in a fork of a public repository it keeps scheduled workflows off, so the keepalive would not run. In `b3os.yaml`, set `resources[0].hosts` to your database's host and port, such as `db.example.com:5432`. Keep the port: `b3os apply` copies the entry into the harness's egress allowlist, and an entry without a port opens only ports 80 and 443. The harness can reach that host and port directly and nothing else.
74
+
75
+ The keepalive schedule is optional: the node keeps the harness running without it. It runs as a scheduled GitHub Actions job, free in a public repository and billed in runner minutes in a private one (the workflow file's header has the arithmetic), so delete the `schedule:` block from a private repository if you do not want it.
76
+
77
+ **Add the secret**
78
+
79
+ In the repository's settings, add a repository secret named `B3OS_API_KEY` holding the project key. Add it as a repository secret, not an environment secret: the keepalive job uses no environment, so it could not read one. It is the only secret the workflow reads.
80
+
81
+ **Check that the workflow is on**
82
+
83
+ Open the repository's Actions tab. If GitHub asks you to enable workflows, enable them. Then choose the `b3os` workflow and, if GitHub shows **Enable workflow**, choose it. A workflow that is off fails silently: nothing deploys. A harness that already runs keeps running.
84
+
85
+ **Push**
86
+
87
+ Commit and push to `main`. The `deploy` job checks out the commit and runs `b3os apply --yes`.
88
+
89
+ **Watch it deploy**
90
+
91
+ The job prints the plan, then one line per step: the routine published, the dependencies installed with `npm ci` and snapshotted, a new generation of the harness started with the commit's tracked files of `agent/`, and its readiness probe passed. Then a summary. If any step fails before the new generation is ready, the deploy is undone and the previous generation keeps running.
92
+
93
+ If you kept the schedule, the same workflow shows its first scheduled `keepalive` run soon after. GitHub can start scheduled runs some minutes late, but if none has appeared after 30 minutes, the schedule is off.
94
+
95
+ **Open the console**
96
+
97
+ Open Applications in the [console](https://beta.b3os.org/app) and choose `research-agent`. The canvas shows the harness, its routine, the model, vision, sandboxes (the hands), the pack and the database. Ask a question with an `INSERT INTO questions (question, repo) VALUES (...)`; the harness's calls appear in the request log.
98
+
99
+ ## Check the plan before you push
100
+
101
+ From a clone, with the key in `B3OS_API_KEY`:
102
+
103
+ ```bash
104
+ b3os manifest validate # offline: the file, its schema and its references
105
+ b3os apply --dry-run # reads the project; changes nothing
106
+ ```
107
+
108
+ The dry run, like the deploy, uses what is committed: commit `b3os.yaml` and the routine file first. Its marks are those of [the plan](https://docs.beta.b3os.org/design/b3os-yaml#print-the-plan).
109
+
110
+ ## How the harness stays up
111
+
112
+ Each deploy starts a new generation: a sandbox restored from the build snapshot, given the source and the environment, and started. The build is reused until `package.json` or `package-lock.json` changes. Once the new generation serves, the deploy hands it the harness's lease (`PUT /v1/sandboxes/{id}/lease`), and the node keeps it running from then on, renewing it itself, until `b3os app down`, the next deploy or a rollback hands the lease to a newer generation, or your organization's credits or spend cap stop it ([sandbox limits](https://docs.beta.b3os.org/sandboxes/limits)). The generation that lost the lease stops within 15 minutes even if its retire fails. When the harness's process exits, the node starts it again in the same sandbox, at the same address and with the same disk. Without the schedule, nothing recreates a harness whose sandbox was lost when the node rebooted until the next `b3os apply`.
113
+
114
+ When a new generation is ready, the old one gets `SIGTERM`. The template's harness then stops the agent, puts its question back in the queue, closes the database and exits. Its `GET /healthz` answers 200 only while its work loop is moving, and each keepalive runs that probe, so a harness whose loop is stuck gets a new generation.
115
+
116
+ To roll back, run the workflow by hand with `ref` set to an older commit. From a clone, `b3os app rollback` does the same without a checkout: it deploys the commit of the previous deploy that went live (or of `--to dep_...`), says in its plan and its deploy that it is a rollback, and leaves your working tree and HEAD as they are; a commit the clone lacks is an error that names the fetch to run. Keepalive recreates a lost harness from the commit it ran, never from the newest one on `main`, so it does not undo a rollback, and it says so: `running caebec0 by rollback; HEAD is ee70e90`. The next `b3os apply` deploys HEAD again.
117
+
118
+ ## What the template leaves out
119
+
120
+ - **An address.** The harness takes its work from the database; it gets no stable URL in this design. A service you give a public port is served at its preview URL under a path prefix (`/sbx/.../`), so absolute asset paths 404 and cookies are not kept; the plan says so in one line under the service, with a link to [ports](https://docs.beta.b3os.org/sandboxes/ports#base-paths).
121
+ - **Previews.** Pull requests do not deploy.
122
+ - **More than one copy.** One generation serves at a time, apart from the overlap during a cutover.