@b3os/cli 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/README.md +87 -8
  2. package/assets/b3os-run.py +137 -0
  3. package/assets/skill/b3os/SKILL.md +111 -0
  4. package/dist/commands/_agents.d.ts +14 -0
  5. package/dist/commands/_agents.js +33 -0
  6. package/dist/commands/_agents.js.map +1 -0
  7. package/dist/commands/_common.js +6 -2
  8. package/dist/commands/_common.js.map +1 -1
  9. package/dist/commands/_context.d.ts +49 -0
  10. package/dist/commands/_context.js +260 -0
  11. package/dist/commands/_context.js.map +1 -0
  12. package/dist/commands/_next.d.ts +39 -0
  13. package/dist/commands/_next.js +77 -0
  14. package/dist/commands/_next.js.map +1 -0
  15. package/dist/commands/agent.d.ts +42 -0
  16. package/dist/commands/agent.js +218 -0
  17. package/dist/commands/agent.js.map +1 -0
  18. package/dist/commands/app.d.ts +2 -5
  19. package/dist/commands/app.js +229 -69
  20. package/dist/commands/app.js.map +1 -1
  21. package/dist/commands/auth.d.ts +70 -2
  22. package/dist/commands/auth.js +308 -33
  23. package/dist/commands/auth.js.map +1 -1
  24. package/dist/commands/docs.d.ts +54 -0
  25. package/dist/commands/docs.js +202 -0
  26. package/dist/commands/docs.js.map +1 -0
  27. package/dist/commands/doctor.d.ts +23 -0
  28. package/dist/commands/doctor.js +313 -0
  29. package/dist/commands/doctor.js.map +1 -0
  30. package/dist/commands/init.d.ts +38 -1
  31. package/dist/commands/init.js +259 -60
  32. package/dist/commands/init.js.map +1 -1
  33. package/dist/commands/listen.d.ts +30 -0
  34. package/dist/commands/listen.js +194 -0
  35. package/dist/commands/listen.js.map +1 -0
  36. package/dist/commands/manifest.d.ts +13 -1
  37. package/dist/commands/manifest.js +59 -7
  38. package/dist/commands/manifest.js.map +1 -1
  39. package/dist/commands/mcp.d.ts +25 -2
  40. package/dist/commands/mcp.js +120 -11
  41. package/dist/commands/mcp.js.map +1 -1
  42. package/dist/commands/sandbox.d.ts +35 -6
  43. package/dist/commands/sandbox.js +208 -9
  44. package/dist/commands/sandbox.js.map +1 -1
  45. package/dist/commands/setup.d.ts +39 -0
  46. package/dist/commands/setup.js +203 -0
  47. package/dist/commands/setup.js.map +1 -0
  48. package/dist/commands/tool.d.ts +109 -1
  49. package/dist/commands/tool.js +635 -47
  50. package/dist/commands/tool.js.map +1 -1
  51. package/dist/config.d.ts +30 -6
  52. package/dist/config.js +39 -8
  53. package/dist/config.js.map +1 -1
  54. package/dist/ctx.d.ts +5 -45
  55. package/dist/ctx.js +25 -160
  56. package/dist/ctx.js.map +1 -1
  57. package/dist/docs/index.json +1 -0
  58. package/dist/docs/pages/actions/call.md +300 -0
  59. package/dist/docs/pages/actions/catalog/airtable.md +737 -0
  60. package/dist/docs/pages/actions/catalog/arxiv.md +166 -0
  61. package/dist/docs/pages/actions/catalog/chainalysis-sanctions.md +125 -0
  62. package/dist/docs/pages/actions/catalog/coingecko.md +1558 -0
  63. package/dist/docs/pages/actions/catalog/deps-dev.md +465 -0
  64. package/dist/docs/pages/actions/catalog/dexscreener.md +568 -0
  65. package/dist/docs/pages/actions/catalog/discord.md +784 -0
  66. package/dist/docs/pages/actions/catalog/finnhub.md +776 -0
  67. package/dist/docs/pages/actions/catalog/frankfurter.md +438 -0
  68. package/dist/docs/pages/actions/catalog/github.md +1853 -0
  69. package/dist/docs/pages/actions/catalog/gmail.md +575 -0
  70. package/dist/docs/pages/actions/catalog/google-calendar.md +654 -0
  71. package/dist/docs/pages/actions/catalog/google-drive.md +502 -0
  72. package/dist/docs/pages/actions/catalog/google-sheets.md +700 -0
  73. package/dist/docs/pages/actions/catalog/hacker-news.md +542 -0
  74. package/dist/docs/pages/actions/catalog/http.md +824 -0
  75. package/dist/docs/pages/actions/catalog/hyperliquid.md +942 -0
  76. package/dist/docs/pages/actions/catalog/jira.md +920 -0
  77. package/dist/docs/pages/actions/catalog/kalshi.md +917 -0
  78. package/dist/docs/pages/actions/catalog/linear.md +1030 -0
  79. package/dist/docs/pages/actions/catalog/markets.md +21 -0
  80. package/dist/docs/pages/actions/catalog/morpho.md +247 -0
  81. package/dist/docs/pages/actions/catalog/notion.md +1077 -0
  82. package/dist/docs/pages/actions/catalog/nws.md +485 -0
  83. package/dist/docs/pages/actions/catalog/open-meteo.md +559 -0
  84. package/dist/docs/pages/actions/catalog/polymarket.md +1523 -0
  85. package/dist/docs/pages/actions/catalog/pushbullet.md +220 -0
  86. package/dist/docs/pages/actions/catalog/resend.md +307 -0
  87. package/dist/docs/pages/actions/catalog/s3.md +513 -0
  88. package/dist/docs/pages/actions/catalog/sec-edgar.md +487 -0
  89. package/dist/docs/pages/actions/catalog/slack.md +2629 -0
  90. package/dist/docs/pages/actions/catalog/stripe.md +1405 -0
  91. package/dist/docs/pages/actions/catalog/wikipedia.md +379 -0
  92. package/dist/docs/pages/actions/catalog.md +46 -0
  93. package/dist/docs/pages/actions/limits.md +50 -0
  94. package/dist/docs/pages/actions/model-tools.md +225 -0
  95. package/dist/docs/pages/actions/packs.md +148 -0
  96. package/dist/docs/pages/actions/settings.md +69 -0
  97. package/dist/docs/pages/actions/tools.md +244 -0
  98. package/dist/docs/pages/actions/triggers.md +149 -0
  99. package/dist/docs/pages/actions.md +88 -0
  100. package/dist/docs/pages/compat/anthropic.md +168 -0
  101. package/dist/docs/pages/compat/e2b.md +194 -0
  102. package/dist/docs/pages/compat/firecrawl.md +138 -0
  103. package/dist/docs/pages/compat/openai.md +168 -0
  104. package/dist/docs/pages/concepts/auth.md +151 -0
  105. package/dist/docs/pages/concepts/beta.md +55 -0
  106. package/dist/docs/pages/concepts/glossary.md +71 -0
  107. package/dist/docs/pages/concepts/ids.md +98 -0
  108. package/dist/docs/pages/concepts/jobs.md +229 -0
  109. package/dist/docs/pages/concepts/latency.md +138 -0
  110. package/dist/docs/pages/concepts/limits.md +191 -0
  111. package/dist/docs/pages/concepts/stack.md +59 -0
  112. package/dist/docs/pages/concepts/timing.md +86 -0
  113. package/dist/docs/pages/concepts/usage.md +110 -0
  114. package/dist/docs/pages/design/b3os-yaml.md +370 -0
  115. package/dist/docs/pages/design/deploy-from-github.md +122 -0
  116. package/dist/docs/pages/design/observability.md +134 -0
  117. package/dist/docs/pages/errors.md +1824 -0
  118. package/dist/docs/pages/infer/chat.md +570 -0
  119. package/dist/docs/pages/infer/limits.md +55 -0
  120. package/dist/docs/pages/infer/messages.md +185 -0
  121. package/dist/docs/pages/infer/responses.md +173 -0
  122. package/dist/docs/pages/infer/settings.md +154 -0
  123. package/dist/docs/pages/infer/speech.md +323 -0
  124. package/dist/docs/pages/infer.md +154 -0
  125. package/dist/docs/pages/introduction.md +162 -0
  126. package/dist/docs/pages/platform/addresses.md +174 -0
  127. package/dist/docs/pages/platform/call-log.md +99 -0
  128. package/dist/docs/pages/platform/custom-domains.md +104 -0
  129. package/dist/docs/pages/platform/keys.md +79 -0
  130. package/dist/docs/pages/platform/limits.md +57 -0
  131. package/dist/docs/pages/platform/members.md +101 -0
  132. package/dist/docs/pages/platform/requests.md +116 -0
  133. package/dist/docs/pages/platform/settings.md +129 -0
  134. package/dist/docs/pages/platform/webhooks.md +68 -0
  135. package/dist/docs/pages/platform.md +67 -0
  136. package/dist/docs/pages/quickstart/mcp.md +94 -0
  137. package/dist/docs/pages/quickstart/sandbox-agent.md +205 -0
  138. package/dist/docs/pages/quickstart/scrape.md +134 -0
  139. package/dist/docs/pages/quickstart.md +45 -0
  140. package/dist/docs/pages/render/inspections.md +162 -0
  141. package/dist/docs/pages/render/limits.md +72 -0
  142. package/dist/docs/pages/render/screenshots.md +179 -0
  143. package/dist/docs/pages/render/settings.md +431 -0
  144. package/dist/docs/pages/render/styles.md +342 -0
  145. package/dist/docs/pages/render/videos.md +272 -0
  146. package/dist/docs/pages/render.md +118 -0
  147. package/dist/docs/pages/routines/callables.md +174 -0
  148. package/dist/docs/pages/routines/definitions.md +361 -0
  149. package/dist/docs/pages/routines/limits.md +117 -0
  150. package/dist/docs/pages/routines/runs.md +328 -0
  151. package/dist/docs/pages/routines/settings.md +104 -0
  152. package/dist/docs/pages/routines/triggers.md +339 -0
  153. package/dist/docs/pages/routines.md +216 -0
  154. package/dist/docs/pages/sandboxes/agents.md +217 -0
  155. package/dist/docs/pages/sandboxes/commands.md +272 -0
  156. package/dist/docs/pages/sandboxes/images.md +166 -0
  157. package/dist/docs/pages/sandboxes/limits.md +143 -0
  158. package/dist/docs/pages/sandboxes/ports.md +260 -0
  159. package/dist/docs/pages/sandboxes/settings.md +358 -0
  160. package/dist/docs/pages/sandboxes/snapshots.md +423 -0
  161. package/dist/docs/pages/sandboxes/swarms.md +146 -0
  162. package/dist/docs/pages/sandboxes/volumes.md +131 -0
  163. package/dist/docs/pages/sandboxes.md +231 -0
  164. package/dist/docs/pages/sdks/cli.md +121 -0
  165. package/dist/docs/pages/sdks/mcp.md +169 -0
  166. package/dist/docs/pages/sdks/python.md +146 -0
  167. package/dist/docs/pages/sdks/typescript.md +202 -0
  168. package/dist/docs/pages/sdks.md +282 -0
  169. package/dist/docs/pages/settings.md +33 -0
  170. package/dist/docs/pages/vault/limits.md +46 -0
  171. package/dist/docs/pages/vault.md +133 -0
  172. package/dist/docs/pages/vision/agent-browser.md +115 -0
  173. package/dist/docs/pages/vision/crawl.md +333 -0
  174. package/dist/docs/pages/vision/extract.md +152 -0
  175. package/dist/docs/pages/vision/fetcher.md +15 -0
  176. package/dist/docs/pages/vision/limits.md +79 -0
  177. package/dist/docs/pages/vision/profiles.md +111 -0
  178. package/dist/docs/pages/vision/proxy.md +131 -0
  179. package/dist/docs/pages/vision/scrape.md +356 -0
  180. package/dist/docs/pages/vision/sessions.md +311 -0
  181. package/dist/docs/pages/vision/settings.md +656 -0
  182. package/dist/docs/pages/vision.md +175 -0
  183. package/dist/errors.d.ts +129 -0
  184. package/dist/errors.js +326 -0
  185. package/dist/errors.js.map +1 -0
  186. package/dist/main.d.ts +1 -1
  187. package/dist/main.js +26 -13
  188. package/dist/main.js.map +1 -1
  189. package/dist/manifest/domains.d.ts +50 -0
  190. package/dist/manifest/domains.js +159 -0
  191. package/dist/manifest/domains.js.map +1 -0
  192. package/dist/manifest/link.d.ts +20 -0
  193. package/dist/manifest/link.js +24 -0
  194. package/dist/manifest/link.js.map +1 -0
  195. package/dist/manifest/record.d.ts +1 -1
  196. package/dist/tool/archive.d.ts +33 -0
  197. package/dist/tool/archive.js +174 -0
  198. package/dist/tool/archive.js.map +1 -0
  199. package/dist/tool/calls.d.ts +46 -0
  200. package/dist/tool/calls.js +274 -0
  201. package/dist/tool/calls.js.map +1 -0
  202. package/dist/tool/checks.d.ts +21 -0
  203. package/dist/tool/checks.js +145 -0
  204. package/dist/tool/checks.js.map +1 -0
  205. package/dist/tool/elf.d.ts +19 -0
  206. package/dist/tool/elf.js +107 -0
  207. package/dist/tool/elf.js.map +1 -0
  208. package/dist/tool/predict.d.ts +8 -0
  209. package/dist/tool/predict.js +38 -0
  210. package/dist/tool/predict.js.map +1 -0
  211. package/dist/tool/ustar.d.ts +5 -0
  212. package/dist/tool/ustar.js +220 -0
  213. package/dist/tool/ustar.js.map +1 -0
  214. package/package.json +6 -5
@@ -0,0 +1,423 @@
1
+ # Snapshots, pausing and forks
2
+
3
+ > Pause and resume a sandbox in place, save its memory and disk as a snapshot, start new sandboxes from it, and fork a running sandbox into copies.
4
+
5
+ Source: https://docs.beta.b3os.org/sandboxes/snapshots.md
6
+
7
+ ## Pause and resume
8
+
9
+ `POST /v1/sandboxes/{sandbox_id}/pause` freezes the sandbox's vCPUs and keeps its memory and disk on the node. `POST /v1/sandboxes/{sandbox_id}/resume` continues exactly where it stopped: processes carry on, open files stay open, and the guest clock is corrected. Pausing a paused sandbox, or resuming a running one, returns it unchanged.
10
+
11
+ ```bash
12
+ curl -s -X POST "https://beta-api.b3os.org/v1/sandboxes/$SBX/pause" -H "Authorization: Bearer $B3OS_API_KEY"
13
+ curl -s -X POST "https://beta-api.b3os.org/v1/sandboxes/$SBX/resume" -H "Authorization: Bearer $B3OS_API_KEY"
14
+ ```
15
+
16
+ Recorded from production, a pause and then a resume of a running `base` sandbox:
17
+
18
+ **Response 200**
19
+
20
+ ```json
21
+ {
22
+ "api": {
23
+ "connections": [],
24
+ "scopes": [],
25
+ "spend_cap_usd": null
26
+ },
27
+ "created_at": "2026-11-06T00:22:16.910Z",
28
+ "disk_gib": 4,
29
+ "egress": {
30
+ "allow": [],
31
+ "mode": "public"
32
+ },
33
+ "env": {},
34
+ "expires_at": "2026-11-06T00:25:16.910Z",
35
+ "forkable": false,
36
+ "host_id": "sbx-01m6q3r6jbjdvp4z7gkxscsnhv",
37
+ "id": "sbx_01m6q3r6jbjdvp4z7gkxscsnhv",
38
+ "memory_mib": 512,
39
+ "metadata": {
40
+ "gallery": "docs"
41
+ },
42
+ "object": "sandbox",
43
+ "on_idle": "stop",
44
+ "paused_at": "2026-11-06T00:22:16.988Z",
45
+ "ports": [],
46
+ "readiness": null,
47
+ "secret_names": [],
48
+ "snapshot": null,
49
+ "started_at": "2026-11-06T00:22:16.910Z",
50
+ "status": "paused",
51
+ "stop_reason": null,
52
+ "stopped_at": null,
53
+ "template": {
54
+ "id": "tpl_01m5t59b2ps0djyzdf082s18bz",
55
+ "name": "base"
56
+ },
57
+ "timeout_s": 180,
58
+ "timing": {
59
+ "admit_ms": 0.315,
60
+ "pause_ms": 0.2,
61
+ "record_ms": 0.033,
62
+ "total_ms": 0.561
63
+ },
64
+ "usage": {
65
+ "gib_ms": 39,
66
+ "vcpu_ms": 0
67
+ },
68
+ "vcpu": 1
69
+ }
70
+ ```
71
+
72
+ **Request**
73
+
74
+ ```bash
75
+ curl -s -X POST 'https://beta-api.b3os.org/v1/sandboxes/sbx_01m6q3r6jbjdvp4z7gkxscsnhv/pause' \
76
+ -H "Authorization: Bearer $B3OS_API_KEY"
77
+ ```
78
+
79
+ **Server-Timing**
80
+
81
+ ```http
82
+ server-timing: edge_auth;dur=4.000, edge_upstream;dur=25.000, total;dur=0.666
83
+ x-request-id: req_01m6q3r6m3rg9d5kr49rgcqbvv
84
+ ```
85
+
86
+ <sub>Captured 2026-11-06 from commit `9fd4273e` on the host the node runs on, one call, label `live-recorded` (recorded from production). Case `sandboxes/pause`.</sub>
87
+
88
+ **Response 200**
89
+
90
+ ```json
91
+ {
92
+ "api": {
93
+ "connections": [],
94
+ "scopes": [],
95
+ "spend_cap_usd": null
96
+ },
97
+ "created_at": "2026-11-06T00:22:16.910Z",
98
+ "disk_gib": 4,
99
+ "egress": {
100
+ "allow": [],
101
+ "mode": "public"
102
+ },
103
+ "env": {},
104
+ "expires_at": "2026-11-06T00:25:16.910Z",
105
+ "forkable": false,
106
+ "host_id": "sbx-01m6q3r6jbjdvp4z7gkxscsnhv",
107
+ "id": "sbx_01m6q3r6jbjdvp4z7gkxscsnhv",
108
+ "memory_mib": 512,
109
+ "metadata": {
110
+ "gallery": "docs"
111
+ },
112
+ "object": "sandbox",
113
+ "on_idle": "stop",
114
+ "paused_at": null,
115
+ "ports": [],
116
+ "readiness": null,
117
+ "secret_names": [],
118
+ "snapshot": null,
119
+ "started_at": "2026-11-06T00:22:16.910Z",
120
+ "status": "running",
121
+ "stop_reason": null,
122
+ "stopped_at": null,
123
+ "template": {
124
+ "id": "tpl_01m5t59b2ps0djyzdf082s18bz",
125
+ "name": "base"
126
+ },
127
+ "timeout_s": 180,
128
+ "timing": {
129
+ "admit_ms": 0.123,
130
+ "record_ms": 0.024,
131
+ "resume_ms": 0.162,
132
+ "total_ms": 0.311
133
+ },
134
+ "usage": {
135
+ "gib_ms": 39,
136
+ "vcpu_ms": 0
137
+ },
138
+ "vcpu": 1
139
+ }
140
+ ```
141
+
142
+ **Request**
143
+
144
+ ```bash
145
+ curl -s -X POST 'https://beta-api.b3os.org/v1/sandboxes/sbx_01m6q3r6jbjdvp4z7gkxscsnhv/resume' \
146
+ -H "Authorization: Bearer $B3OS_API_KEY"
147
+ ```
148
+
149
+ **Server-Timing**
150
+
151
+ ```http
152
+ server-timing: edge_auth;dur=0.000, edge_upstream;dur=15.000, total;dur=0.368
153
+ x-request-id: req_01m6q3r6nrw99kjfyphn48tf77
154
+ ```
155
+
156
+ <sub>Captured 2026-11-06 from commit `9fd4273e` on the host the node runs on, one call, label `live-recorded` (recorded from production). Case `sandboxes/resume`.</sub>
157
+
158
+ A paused sandbox bills neither meter (no CPU time, no memory) and still expires at `expires_at`. Create a sandbox with `on_idle: "pause"` to have it pause instead of stopping when its time runs out; extend the timeout, then resume it. A sandbox paused that way is kept for one hour, then stopped.
159
+
160
+ The target for pause and for resume is 0.5 ms each; see [benchmarks](https://docs.beta.b3os.org/benchmarks). A resume is admitted like a create (spend cap, organization status), because the sandbox bills again once it runs.
161
+
162
+ ## Save a snapshot
163
+
164
+ `POST /v1/sandboxes/{sandbox_id}/snapshot` saves the sandbox's memory and disk. The sandbox pauses for the copy, then keeps running:
165
+
166
+ **curl**
167
+
168
+ ```bash
169
+ curl -s -X POST "https://beta-api.b3os.org/v1/sandboxes/$SBX/snapshot" \
170
+ -H "Authorization: Bearer $B3OS_API_KEY" \
171
+ -H "Content-Type: application/json" \
172
+ -d '{"name": "deps-installed"}'
173
+ ```
174
+ **TypeScript**
175
+
176
+ ```ts
177
+ const snapshot = await b3os.sandboxes.createSnapshot(sbx, { name: "deps-installed" });
178
+ console.log(snapshot.id, snapshot.status, snapshot.size_bytes);
179
+ ```
180
+ **Python**
181
+
182
+ ```python
183
+ snapshot = b3os.sandboxes.create_snapshot(sbx, {"name": "deps-installed"})
184
+ print(snapshot["id"], snapshot["status"], snapshot["size_bytes"])
185
+ ```
186
+ **MCP**
187
+
188
+ ```text
189
+ Install the project's dependencies in my sandbox with npm ci, then snapshot it as deps-installed.
190
+ ```
191
+
192
+ The agent runs the install with `sandbox_exec` and takes the snapshot with `sandbox_snapshot`. `sandbox_snapshot` is in the `sandboxes` toolset: start the local server with `npx -y @b3os/mcp@0.2 --toolsets sandboxes`, or connect to the remote one at `https://beta-api.b3os.org/mcp?toolsets=sandboxes`.
193
+
194
+ Recorded from production, a snapshot of a running `base` sandbox at its default size:
195
+
196
+ **Response 201**
197
+
198
+ ```json
199
+ {
200
+ "created_at": "2026-11-06T00:20:49.793Z",
201
+ "disk_gib": 4,
202
+ "expires_at": "2026-11-13T00:20:49.793Z",
203
+ "id": "snap_01m6q3nbt97f6bw1vh6er6gcwx",
204
+ "memory_mib": 512,
205
+ "metadata": {},
206
+ "name": "gallery-docs",
207
+ "object": "snapshot",
208
+ "sandbox_id": "sbx_01m6q3naemvk1zxgst0992ejrr",
209
+ "size_bytes": 4831850391,
210
+ "status": "ready",
211
+ "template": {
212
+ "id": "tpl_01m5t59b2ps0djyzdf082s18bz",
213
+ "name": "base"
214
+ },
215
+ "timing": {
216
+ "pause_ms": 0.236,
217
+ "sync_ms": 51.674,
218
+ "total_ms": 5816.143,
219
+ "write_ms": 5763.976
220
+ },
221
+ "vcpu": 1
222
+ }
223
+ ```
224
+
225
+ **Request**
226
+
227
+ ```bash
228
+ curl -s -X POST 'https://beta-api.b3os.org/v1/sandboxes/sbx_01m6q3naemvk1zxgst0992ejrr/snapshot' \
229
+ -H "Authorization: Bearer $B3OS_API_KEY" \
230
+ -H 'content-type: application/json' \
231
+ -d '{"name":"gallery-docs"}'
232
+ ```
233
+
234
+ **Server-Timing**
235
+
236
+ ```http
237
+ server-timing: edge_auth;dur=0.000, edge_upstream;dur=5830.000, total;dur=5816.232
238
+ x-request-id: req_01m6q3nbt1vzeb95h64bf44f9y
239
+ ```
240
+
241
+ <sub>Captured 2026-11-06 from commit `92bb000d` on the host the node runs on, one call, label `live-recorded` (recorded from production). Case `sandboxes/snapshot`.</sub>
242
+
243
+ A snapshot keeps the template, sizes and contents of its sandbox. The call answers once the snapshot's files are written to the node's disk, and from then on the snapshot is listed with `status: ready`; the sandbox itself runs again before that write finishes (`sync` in the response's `timing`). If writing fails, the call answers `500` [`snapshot_failed`](https://docs.beta.b3os.org/errors#snapshot_failed) and the sandbox keeps running unchanged; retry it. Snapshots are kept for 7 days in the beta.
244
+
245
+ Writing a snapshot resets the sandbox's open connections to the outside: open terminals, streamed commands and log streams, port preview connections and the sandbox's outbound TCP connections. New ones work as soon as the call returns, so reconnect after it.
246
+
247
+ The node takes snapshots itself, from the host; nothing the guest reports decides their size or where they are stored. A snapshot belongs to the project that took it, and only that project can start sandboxes from it.
248
+
249
+ What a snapshot carries, and what it cannot undo:
250
+
251
+ - **Secrets and memory.** A snapshot holds the sandbox's whole memory and disk: its environment with every `secrets` value, tokens and keys its processes loaded, and files it wrote. Anyone in the project who can create sandboxes can restore it and read them.
252
+ - **Effects outside the sandbox.** Restoring or forking rewinds the sandbox, not the world: emails sent, API calls made and payments taken before the snapshot stay done, and code that runs again from the snapshot may repeat them.
253
+ - **Keyed calls are not repeated for 24 hours.** A call the sandbox made to B3OS with an `Idempotency-Key` belongs to that sandbox: a fork or a restored sandbox that sends the same key gets `409` [`idempotency_key_conflict`](https://docs.beta.b3os.org/errors#idempotency_key_conflict), and the call does not run again. After 24 hours, or for a call made without a key, it runs again. Snapshots are kept 7 days, so a restore days later can repeat a call its key no longer guards.
254
+ - **Old software.** A snapshot keeps the packages and the CA certificate store it was taken with. When a template image is updated (a new trust store, a security fix), sandboxes restored from older snapshots do not get it; take the snapshot again from a fresh sandbox.
255
+
256
+ Per organization and node, the beta keeps at most 20 snapshots (`sandboxes.snapshots_max`) and 40 GiB of them (`sandboxes.snapshot_storage_max`). Each snapshot counts its sandbox's memory plus its disk size: the memory is stored whole, and the disk copy comes to hold every block the sandbox rewrites after the snapshot. Past either limit a snapshot is refused with `422` [`limit_exceeded`](https://docs.beta.b3os.org/errors#limit_exceeded) until you delete some. While the node's snapshot store is nearly full, snapshots and forks are refused with `503` [`capacity_unavailable`](https://docs.beta.b3os.org/errors#capacity_unavailable).
257
+
258
+ ## Start from a snapshot
259
+
260
+ Pass the snapshot instead of a template:
261
+
262
+ ```bash
263
+ curl -s https://beta-api.b3os.org/v1/sandboxes \
264
+ -H "Authorization: Bearer $B3OS_API_KEY" \
265
+ -H "Content-Type: application/json" \
266
+ -d '{"snapshot": "snap_01m5t5mnvax7tp9peav8jajw3y"}'
267
+ ```
268
+
269
+ The new sandbox starts with the snapshot's processes and files in memory, already running, and the same snapshot can start many sandboxes. Use this to install dependencies once and start every later sandbox warm. Each restore gets an identity of its own, but the processes it brings back are copies, random state included: [what a restore or fork keeps](#what-a-restore-or-fork-keeps) says what that means for the processes you leave running.
270
+
271
+ ### Random state on restore and fork
272
+
273
+ A restored sandbox, or a fork, starts from a copy of the source's memory, so every process that was running at the snapshot carries the state of its own random generators with it. A sandbox from an [imported image](https://docs.beta.b3os.org/sandboxes/images) starts the same way, from the image's warm snapshot, shared only within your project; its warm-up commands run to their end before that snapshot, so it holds no process of yours. Two sandboxes from one snapshot would draw the same numbers from such a process, and so would the source. The guest kernel gets fresh entropy on every start, and the `code-interpreter` kernel's Python `random` module and NumPy global generator are reseeded ([what a restore or fork keeps](#what-a-restore-or-fork-keeps) has the rest). For the `browser` template's Chrome, running in your sandbox when you took the snapshot or forked it, `clone_reset` on the create (with `snapshot`) or on the fork decides:
274
+
275
+ | `clone_reset` | Chrome in the new sandbox | `Math.random`, `crypto.getRandomValues`, WebSocket keys |
276
+ |---|---|---|
277
+ | `full` (default) | Its renderers and network service are replaced when the sandbox starts. The tabs that were open at the snapshot are closed and their connections dropped; Chrome has one new `about:blank` page | fresh in every sandbox |
278
+ | `none` | Runs on as the snapshot had it: the same tabs, pages and page state | shared with the source and with every other sandbox from that snapshot or fork |
279
+
280
+ ```bash
281
+ curl -s https://beta-api.b3os.org/v1/sandboxes \
282
+ -H "Authorization: Bearer $B3OS_API_KEY" \
283
+ -H "Content-Type: application/json" \
284
+ -d '{"snapshot": "snap_01m5t5mnvax7tp9peav8jajw3y", "clone_reset": "none"}'
285
+ ```
286
+
287
+ Leave it out to get the node's default, `full` on the beta node. A value the node does not allow is refused with `422` [`option_not_allowed`](https://docs.beta.b3os.org/errors#option_not_allowed), never replaced. The sandbox's `options` says what applied and where it came from (`request` or `node`), and so does the `X-B3OS-Options` response header:
288
+
289
+ ```json
290
+ "options": { "sandboxes.clone_reset": { "value": "full", "from": "node" } }
291
+ ```
292
+
293
+ The reset runs in the guest agent that was in the snapshot (or in the source of a fork), and `full` is reported only when that agent says it replaced Chrome. An agent from before `clone_reset` cannot do it, so with a snapshot of a sandbox that had one, `full` (including the default) is refused with `409` [`guest_outdated`](https://docs.beta.b3os.org/errors#guest_outdated) instead of starting a sandbox whose Chrome shares the source's random state. A fork is refused before the source is paused. Ask for `"clone_reset": "none"` to keep Chrome as it is. A snapshot taken before the node's image of the template changed cannot be restored after it (`409` `conflict`). If the agent replaced none of Chrome's processes when the new sandbox started (Chrome restarting at that moment, say), the create or fork fails with `500` [`internal`](https://docs.beta.b3os.org/errors#internal) and leaves no sandbox; retry it.
294
+
295
+ A restored VM runs from the moment it is restored, its copied Chrome included, until its `bind` resets Chrome. In that time its outbound connections, DNS lookups and calls to the API from inside it are refused, so with `full` no connection leaves through the copied network service. A process of yours that read values from Chrome in that time keeps them, as it keeps the rest of its own state.
296
+
297
+ A create from a template ignores `clone_reset`, and its `options` is `{}`: its Chrome is not a copy of anything, B3OS starts a new one in it ([what a restore or fork keeps](#what-a-restore-or-fork-keeps)). Only the template's own Chrome is covered. A browser you start yourself inside the sandbox, and any other process of yours, keeps its state either way: restart it, or reseed it, after a restore or a fork. Use `none` when you fork a browser to continue the same pages in several copies and do not rely on their random values being independent.
298
+
299
+ `GET /v1/sandboxes/snapshots` lists your snapshots, `GET /v1/sandboxes/snapshots/{snapshot_id}` returns one, and `DELETE` removes one; sandboxes already restored from it keep running.
300
+
301
+ The node records the size of each of a snapshot's files when it takes it and restores a file only at that size. A snapshot whose files no longer match (cut off on the node's disk) is not restored: the create answers `409` [`snapshot_damaged`](https://docs.beta.b3os.org/errors#snapshot_damaged), the snapshot's `status` turns `failed`, and every later restore of it gets the same answer. Delete it and take a new one.
302
+
303
+ ## Templates are snapshots too
304
+
305
+ Templates (`base`, `code-interpreter`, `agent`) are snapshots B3OS prepares and keeps resident on the node. Creating a sandbox from a template claims one of a pool of microVMs already restored from it, which is why creation does not wait for a boot. `GET /v1/sandboxes/templates` lists them.
306
+
307
+ ## Fork
308
+
309
+ `POST /v1/sandboxes/{sandbox_id}/fork` copies a running sandbox into 1 to 10 new ones (`count`), each with the source's memory, disk, running processes, environment and secrets, and an identity of its own: its own ID, kernel entropy, machine ID, hostname and clock. The running processes are copies, so each fork starts them with the source's random state ([what a restore or fork keeps](#what-a-restore-or-fork-keeps)). Use it to try several next steps from one state, or to hand each of several agents the same prepared machine.
310
+
311
+ ```bash
312
+ curl -s -X POST "https://beta-api.b3os.org/v1/sandboxes/$SBX/fork" \
313
+ -H "Authorization: Bearer $B3OS_API_KEY" \
314
+ -H "Content-Type: application/json" \
315
+ -d '{"count": 2}'
316
+ ```
317
+
318
+ The response lists the new sandboxes. Recorded from production, the first fork of a forkable `base` sandbox at its default size, with `count` 1; the Server-Timing tab has the phases below:
319
+
320
+ **Response 201**
321
+
322
+ ```json
323
+ {
324
+ "data": [
325
+ {
326
+ "api": {
327
+ "connections": [],
328
+ "scopes": [],
329
+ "spend_cap_usd": null
330
+ },
331
+ "created_at": "2026-11-06T00:20:43.658Z",
332
+ "disk_gib": 4,
333
+ "egress": {
334
+ "allow": [],
335
+ "mode": "public"
336
+ },
337
+ "env": {},
338
+ "expires_at": "2026-11-06T00:23:43.658Z",
339
+ "forkable": true,
340
+ "host_id": "sbx-01m6q3nbg57ay5s19wrbg6te6v",
341
+ "id": "sbx_01m6q3nbg57ay5s19wrbg6te6v",
342
+ "memory_mib": 512,
343
+ "metadata": {
344
+ "gallery": "docs"
345
+ },
346
+ "object": "sandbox",
347
+ "on_idle": "stop",
348
+ "paused_at": null,
349
+ "ports": [],
350
+ "readiness": null,
351
+ "secret_names": [],
352
+ "snapshot": null,
353
+ "started_at": "2026-11-06T00:20:43.658Z",
354
+ "status": "running",
355
+ "stop_reason": null,
356
+ "stopped_at": null,
357
+ "template": {
358
+ "id": "tpl_01m5t59b2ps0djyzdf082s18bz",
359
+ "name": "base"
360
+ },
361
+ "timeout_s": 180,
362
+ "usage": {
363
+ "gib_ms": 0,
364
+ "vcpu_ms": 0
365
+ },
366
+ "vcpu": 1
367
+ }
368
+ ],
369
+ "next_cursor": null,
370
+ "object": "list"
371
+ }
372
+ ```
373
+
374
+ **Request**
375
+
376
+ ```bash
377
+ curl -s -X POST 'https://beta-api.b3os.org/v1/sandboxes/sbx_01m6q3nabpnmysscwgz6ydxxj0/fork' \
378
+ -H "Authorization: Bearer $B3OS_API_KEY" \
379
+ -H 'content-type: application/json' \
380
+ -d '{"count":1}'
381
+ ```
382
+
383
+ **Server-Timing**
384
+
385
+ ```http
386
+ server-timing: edge_auth;dur=0.000, edge_upstream;dur=188.000, pause;dur=0.272, base;dur=0.001, snapshot;dur=91.092, export;dur=3.132, resume;dur=0.123, restore;dur=76.612, restore_wait;dur=0.001, restore_vmm;dur=1.495, restore_load;dur=33.767, restore_ready;dur=41.303, bind;dur=4.624, bind_guest;dur=4.486, total;dur=176.048
387
+ x-request-id: req_01m6q3nbaneabmn5q8f0b1741q
388
+ ```
389
+
390
+ <sub>Captured 2026-11-06 from commit `92bb000d` on the host the node runs on, one call, label `live-recorded` (recorded from production). Case `sandboxes/fork`.</sub>
391
+
392
+ - Only a sandbox created with `forkable: true` can be forked; others answer `409` [`fork_unavailable`](https://docs.beta.b3os.org/errors#fork_unavailable). A forkable sandbox tracks the memory it changes. At a template's default size it is claimed from a pool of forkable slots (two per template on each NUMA node of the beta node), so its create is as fast as any pooled create; when that pool is empty, or at another size, it is restored on demand (`restore_ms` in its `timing`). Forks are forkable too.
393
+ - The source pauses while its changed memory is written (the `pause`, `base`, `snapshot` and `export` phases in `Server-Timing`), then runs on. `base` copies the memory file the changes go onto; the node prepares that copy in the background after a forkable create and after each fork, so `base` is near 0 unless a fork comes right after the last one or after a snapshot. Like a snapshot, a fork resets the source's open connections to the outside.
394
+ - The forks then start: `restore` in `Server-Timing`, broken down into `restore_wait` (waiting for a restore slot on the node), `restore_vmm` (the VM process and its files; `restore_cold` appears when no prespawned process was free or one refused its files, and then `restore_refused` gives that attempt's time), `restore_load` (the memory snapshot loaded) and `restore_ready` (the in-VM agent's first connection). Each part is the largest value among the forks. They are inside `restore`, not extra time: for one fork they add up to about `restore`, and for several their sum can be larger, since the largest values may come from different forks. `bind` gives each fork its own identity; `bind_guest` is the part spent inside the forks (their agents applying it), summed over the forks. A fork's memory starts out on disk, so the node reads ahead the pages the forks of your organization's sandboxes of that template and size read when they start; `restore_ready`, `bind` and the fork's first command are the parts this shortens. It learns those pages from a fork of a sandbox that has forked before (a sandbox's first fork carries everything that sandbox changed since it started, which later forks no longer do), and again from time to time: that fork's `Server-Timing` has a `learn` phase, in which the node notes which pages the write itself left cached, so that it counts only the pages the forks read. Once it knows them, the node reads them into the copy it prepares for the source's next fork, between forks, and that fork's `Server-Timing` has `prefetch_bg` (the time spent queueing those reads, before the fork); a fork whose copy was not prepared that way queues them as its own memory is written, and shows `prefetch`. A fork that writes the whole memory (the first fork of a sandbox after the node restarted, or after a failed fork) neither learns nor reads ahead, since the write leaves all of its memory cached.
395
+ - Each fork's `browser` Chrome is reset unless the request says `"clone_reset": "none"` ([random state](#random-state-on-restore-and-fork)); the source's own Chrome is never touched. The reset runs in each fork's `bind`.
396
+ - Each fork counts against your sandbox concurrency and bills like any sandbox.
397
+
398
+ The target for a fork of a sandbox with up to 128 MiB of memory and 64 MiB of it changed is 50 ms. The fork runs measured so far, and their cost against that target, are on [benchmarks](https://docs.beta.b3os.org/benchmarks); they come from a dev node and are labelled that way until the locked runs are published.
399
+
400
+ ## What a restore or fork keeps
401
+
402
+ A sandbox started from a snapshot, or forked, gets these before your first command runs:
403
+
404
+ - fresh entropy for the guest kernel's random generator, so `/dev/urandom`, `getrandom()` and the calls that read them each time (Python's `os.urandom` and `secrets`, for example) give different bytes in every sandbox;
405
+ - a new machine ID (`/etc/machine-id`) and hostname;
406
+ - the current time;
407
+ - its own `B3OS_SANDBOX_ID` in the environment of the commands you run in it.
408
+
409
+ Everything else comes from the snapshot or from the fork's source: memory, files and the processes that were running. A running process keeps its memory, so every random generator it holds there is copied, in the same state, into every sandbox made from it. Some libraries mix in fresh entropy from the kernel later; many never do. When the process was already running at the snapshot or fork, treat these as shared:
410
+
411
+ - a browser's `Math.random`, `crypto.getRandomValues` and the random values its network stack uses, such as WebSocket keys and TLS;
412
+ - `Math.random` and `crypto.randomBytes` in a Node.js process;
413
+ - the `random` module, `random.Random` objects and NumPy generators in a Python process;
414
+ - the TLS library (OpenSSL, BoringSSL) of any server or client.
415
+
416
+ Values such a process made before the snapshot (keys, tokens, session and browser IDs, UUIDs) are the same in every copy, and so is the environment it started with, including the `B3OS_SANDBOX_ID` of the sandbox it started in. Files carry over the same way: a key written to disk before the snapshot is in every sandbox made from it.
417
+
418
+ So start a process that makes keys, tokens, IDs or TLS connections after the restore or fork, from a command in the new sandbox, or restart it there before it does. A browser or Node.js process cannot reseed `Math.random`, so restart it. In a Python process you can reseed in place: `random.seed()` with no argument reseeds the module's generator from the kernel, and `numpy.random.default_rng()` makes a new generator from it.
419
+
420
+ Nothing of yours runs in a template's snapshot, so in a sandbox created from a template everything you start, starts after the claim. Of B3OS's own processes, the guest agent is in every template's snapshot; besides it:
421
+
422
+ - **`browser`** has nothing else of B3OS's in its snapshot. Its Chrome (`/opt/chrome/chrome`, which runs as `user`, the account your commands run as by default) is started in each sandbox created from the template, after the guest kernel's generator gets fresh entropy and before you get the sandbox, with a new profile directory, `/tmp/chrome-profile`. So no Chrome process, no profile file and no browser generator of one sandbox is in another. A fork, or a restore of your snapshot, starts from a copy of the Chrome that was running in the source: B3OS still replaces its renderers and network service when the new sandbox starts, unless you ask for `"clone_reset": "none"` ([random state on restore and fork](#random-state-on-restore-and-fork)). The browser process itself, and the profile directory, are the source's copies there. For a wholly new Chrome after a fork or a restore, end its process; the guest agent starts it again with DevTools on the same port, on the same profile directory.
423
+ - **`code-interpreter`** has the code kernel that `run_code` uses. At every start, snapshot restores and forks included, B3OS asks it to reseed its Python `random` module and NumPy's global generator, and your first `run_code` waits for that request to finish. It does not reseed `random.Random` or NumPy `Generator` objects you made, or the JavaScript runner. The runner starts with your first JavaScript `run_code`, so a sandbox created from the template gets a new one, but a snapshot or fork taken after JavaScript ran shares its `Math.random`.
@@ -0,0 +1,146 @@
1
+ # Swarms
2
+
3
+ > Fork one checkpoint into up to 32 children, run a command in each, and get every child's exit code, output and timing back from one call.
4
+
5
+ Source: https://docs.beta.b3os.org/sandboxes/swarms.md
6
+
7
+ A swarm forks one checkpoint into children and runs a command in each. The checkpoint is a sandbox you prepared
8
+ once (code checked out, dependencies installed, a server warmed up) or a snapshot of one. Every child starts from
9
+ that state with its own identity, runs its own command, and reports its exit code, output and timing. The swarm
10
+ gathers them, so one call fans work out and brings the answers back: test shards, several attempts at one fix,
11
+ an agent trying five approaches at once.
12
+
13
+ Note:
14
+ Swarms are behind the `sandboxes.swarms` feature flag, turned on for B3's own organization first. Until it is on
15
+ for yours, every swarm call answers `404` [`feature_not_enabled`](https://docs.beta.b3os.org/errors#feature_not_enabled). The SDK methods,
16
+ `b3os sandbox swarm` and the MCP tools come with client 0.2.2, the **next** release.
17
+
18
+ ## Start a swarm
19
+
20
+ Make the checkpoint a forkable sandbox (`forkable: true` at create), get it ready, then start the swarm. Give each
21
+ child its own command in `children`, or give `count` and one command in `defaults`: every child's command gets
22
+ `B3OS_SWARM_ID` and `B3OS_SWARM_INDEX` (0 to count - 1), so one command can pick its share by index.
23
+
24
+ **curl**
25
+
26
+ ```bash
27
+ curl -s "https://beta-api.b3os.org/v1/sandboxes/swarms?wait=60" \
28
+ -H "Authorization: Bearer $B3OS_API_KEY" \
29
+ -H "Content-Type: application/json" \
30
+ -d "{\"from\": {\"sandbox\": \"$SBX\"}, \"count\": 4,
31
+ \"defaults\": {\"cmd\": \"pytest --shard-id=\$B3OS_SWARM_INDEX --num-shards=4\"}}"
32
+ ```
33
+ **TypeScript**
34
+
35
+ ```ts
36
+ import { B3OS } from "@b3os/sdk";
37
+
38
+ const b3os = new B3OS();
39
+ const sbx = process.env.SBX!; // a forkable sandbox, sbx_...
40
+ const swarm = await b3os.sandboxes
41
+ .createSwarm({
42
+ from: { sandbox: sbx },
43
+ count: 4,
44
+ defaults: { cmd: "pytest --shard-id=$B3OS_SWARM_INDEX --num-shards=4" },
45
+ })
46
+ .wait();
47
+ for (const child of swarm.children ?? []) {
48
+ console.log(child.index, child.status, child.exit_code);
49
+ }
50
+ ```
51
+ **Python**
52
+
53
+ ```python
54
+ import os
55
+ from b3os import B3OS
56
+
57
+ b3os = B3OS()
58
+ sbx = os.environ["SBX"] # a forkable sandbox, sbx_...
59
+ swarm = b3os.sandboxes.create_swarm(
60
+ {
61
+ "from": {"sandbox": sbx},
62
+ "count": 4,
63
+ "defaults": {"cmd": "pytest --shard-id=$B3OS_SWARM_INDEX --num-shards=4"},
64
+ },
65
+ wait=True,
66
+ )
67
+ for child in swarm.get("children", []):
68
+ print(child["index"], child["status"], child["exit_code"])
69
+ ```
70
+ **MCP**
71
+
72
+ ```text
73
+ Fork my prepared sandbox four ways, run one test shard in each, and tell me which shards failed.
74
+ ```
75
+
76
+ The agent calls `sandbox_swarm` with `from`, `count` and `defaults`, and reads each child's `exit_code`,
77
+ `stdout` and `stderr`.
78
+
79
+ The same from the CLI:
80
+
81
+ ```bash
82
+ b3os sandbox swarm "$SBX" --count 4 -- sh -c 'pytest --shard-id=$B3OS_SWARM_INDEX --num-shards=4'
83
+ ```
84
+
85
+ It prints one line per child (index, status, exit code, sandbox ID) and exits 0 only when every child exited 0.
86
+
87
+ ## What comes back
88
+
89
+ A swarm is a job: `?wait=` (up to 60 seconds) answers `200` once it ended, or `202` with the swarm as it is and a
90
+ `Location` to poll. `GET /v1/sandboxes/swarms/{swarm_id}` returns the swarm with every child,
91
+ `GET …/children` pages through them, and `GET …/events` streams the swarm's events.
92
+
93
+ - **`status`**: `succeeded` once every child's command ended, whatever their exit codes. A non-zero exit is a
94
+ result, not a failure of the swarm. `failed` means no child could start, or the node restarted while it ran.
95
+ - **`children`**: per child, its `sandbox_id`, `status` (`exited`, `timed_out`, `failed` when the command could not
96
+ run, `canceled`), `exit_code`, `signal`, `stdout` and `stderr` (the first `output_max_bytes` of each, 64 KiB
97
+ unless you ask for up to 256 KiB, with `stdout_truncated` and `stderr_truncated`), and `timing` (`start_ms`,
98
+ `run_ms`, `total_ms`).
99
+ - **`result`**: how many children exited 0, exited non-zero, timed out, failed or were canceled, and the `winner`.
100
+ - **`timing`**: `fork_ms` (making the children), `first_exit_ms`, `last_exit_ms` and `total_ms`.
101
+
102
+ ## Stop at the first success
103
+
104
+ With `"stop_when": "first_success"`, the first child to exit 0 wins (`result.winner`) and the other children's
105
+ commands are killed. That suits several attempts at one problem, where the first that passes is the answer. The
106
+ [best-of-N fix](https://docs.beta.b3os.org/cookbook/sandbox-fork-best-of-n-fixes) recipe does this by hand with forks.
107
+
108
+ ## Keep the children
109
+
110
+ A child is deleted once its command ends, unless `keep` says otherwise: `"succeeded"` keeps the children that
111
+ exited 0 (the winner, with `first_success`), `"all"` keeps every child. A kept child is an ordinary sandbox: it
112
+ runs to its own `expires_at`, counts against your sandbox limit and is billed until you delete it.
113
+
114
+ ## Watch it run
115
+
116
+ `GET /v1/sandboxes/swarms/{swarm_id}/events` (or `Accept: text/event-stream` on the create) streams
117
+ `swarm.forked` (each child's sandbox ID), then `child.started` and `child.exited` or `child.failed` per child, and
118
+ `job.succeeded`, `job.failed` or `job.canceled` with the final swarm. Create it with `"stream_output": true` to also
119
+ get `child.stdout` and `child.stderr` as the commands write. Reconnect with `Last-Event-ID` to resume.
120
+ `POST …/cancel` stops a running swarm.
121
+
122
+ ## From a snapshot or a paused sandbox
123
+
124
+ `from` takes `{"sandbox": "sbx_…"}` or `{"snapshot": "snap_…"}`. A paused forkable sandbox works too: it is
125
+ resumed for the fork and paused again, so a checkpoint can wait paused, billing nothing, between swarms. A
126
+ snapshot restores every child from it, so the checkpoint need not be running at all.
127
+
128
+ ## Limits
129
+
130
+ | Limit | Default |
131
+ |---|---|
132
+ | Children per swarm (`sandboxes.swarm_children_max`) | 32 |
133
+ | Swarms running at once, per organization (`sandboxes.swarms_running`) | 4 |
134
+
135
+ Every child also counts against your [sandbox limits](https://docs.beta.b3os.org/sandboxes/limits), reserved all at once before anything
136
+ starts: past the number of sandboxes you may run the create answers `429`
137
+ [`concurrency_limited`](https://docs.beta.b3os.org/errors#concurrency_limited), and nothing is forked.
138
+
139
+ ## Said plainly
140
+
141
+ - **Every child shares the checkpoint's memory.** Its environment, secrets and the in-memory state of its
142
+ processes are copied, so put per-child values in `env`, and never secrets: `env` is kept with the swarm's
143
+ record for 7 days. Secrets go in the checkpoint's `secrets`.
144
+ - **A checkpoint with a volume cannot be forked** (`409` [`volume_attached`](https://docs.beta.b3os.org/errors#volume_attached)): each child
145
+ would write to it too.
146
+ - **Children run on one node.** A swarm is as wide as one node allows.