@b3os/sdk 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 (138) hide show
  1. package/dist/cjs/core/util.d.ts +1 -1
  2. package/dist/cjs/core/util.js +1 -1
  3. package/dist/cjs/generated/client.d.ts +13 -0
  4. package/dist/cjs/generated/client.js +25 -0
  5. package/dist/cjs/generated/client.js.map +1 -1
  6. package/dist/cjs/generated/errors.d.ts +1 -1
  7. package/dist/cjs/generated/errors.js +75 -0
  8. package/dist/cjs/generated/errors.js.map +1 -1
  9. package/dist/cjs/generated/ids.d.ts +61 -0
  10. package/dist/cjs/generated/ids.js +15 -0
  11. package/dist/cjs/generated/ids.js.map +1 -1
  12. package/dist/cjs/generated/jobs.js +4 -0
  13. package/dist/cjs/generated/jobs.js.map +1 -1
  14. package/dist/cjs/generated/ns/actions.d.ts +267 -33
  15. package/dist/cjs/generated/ns/actions.js +375 -33
  16. package/dist/cjs/generated/ns/actions.js.map +1 -1
  17. package/dist/cjs/generated/ns/agents.d.ts +229 -0
  18. package/dist/cjs/generated/ns/agents.js +402 -0
  19. package/dist/cjs/generated/ns/agents.js.map +1 -0
  20. package/dist/cjs/generated/ns/images.d.ts +81 -0
  21. package/dist/cjs/generated/ns/images.js +122 -0
  22. package/dist/cjs/generated/ns/images.js.map +1 -0
  23. package/dist/cjs/generated/ns/infer.d.ts +71 -3
  24. package/dist/cjs/generated/ns/infer.js +98 -3
  25. package/dist/cjs/generated/ns/infer.js.map +1 -1
  26. package/dist/cjs/generated/ns/keys.d.ts +3 -1
  27. package/dist/cjs/generated/ns/keys.js +3 -1
  28. package/dist/cjs/generated/ns/keys.js.map +1 -1
  29. package/dist/cjs/generated/ns/listeners.d.ts +159 -0
  30. package/dist/cjs/generated/ns/listeners.js +264 -0
  31. package/dist/cjs/generated/ns/listeners.js.map +1 -0
  32. package/dist/cjs/generated/ns/orgs.d.ts +10 -0
  33. package/dist/cjs/generated/ns/orgs.js +26 -1
  34. package/dist/cjs/generated/ns/orgs.js.map +1 -1
  35. package/dist/cjs/generated/ns/projects.d.ts +32 -0
  36. package/dist/cjs/generated/ns/projects.js +66 -0
  37. package/dist/cjs/generated/ns/projects.js.map +1 -1
  38. package/dist/cjs/generated/ns/render.d.ts +192 -21
  39. package/dist/cjs/generated/ns/render.js +267 -24
  40. package/dist/cjs/generated/ns/render.js.map +1 -1
  41. package/dist/cjs/generated/ns/requests.d.ts +3 -1
  42. package/dist/cjs/generated/ns/requests.js +3 -1
  43. package/dist/cjs/generated/ns/requests.js.map +1 -1
  44. package/dist/cjs/generated/ns/routines.d.ts +11 -4
  45. package/dist/cjs/generated/ns/routines.js +11 -4
  46. package/dist/cjs/generated/ns/routines.js.map +1 -1
  47. package/dist/cjs/generated/ns/sandboxes.d.ts +292 -7
  48. package/dist/cjs/generated/ns/sandboxes.js +444 -6
  49. package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
  50. package/dist/cjs/generated/ns/usage.d.ts +1 -1
  51. package/dist/cjs/generated/ns/usage.js +1 -1
  52. package/dist/cjs/generated/ns/vision.d.ts +59 -17
  53. package/dist/cjs/generated/ns/vision.js +59 -21
  54. package/dist/cjs/generated/ns/vision.js.map +1 -1
  55. package/dist/cjs/generated/types.d.ts +2564 -68
  56. package/dist/cjs/helpers/sandboxes.d.ts +20 -1
  57. package/dist/cjs/helpers/sandboxes.js +13 -1
  58. package/dist/cjs/helpers/sandboxes.js.map +1 -1
  59. package/dist/esm/core/util.d.ts +1 -1
  60. package/dist/esm/core/util.js +1 -1
  61. package/dist/esm/generated/client.d.ts +13 -0
  62. package/dist/esm/generated/client.js +25 -0
  63. package/dist/esm/generated/client.js.map +1 -1
  64. package/dist/esm/generated/errors.d.ts +1 -1
  65. package/dist/esm/generated/errors.js +75 -0
  66. package/dist/esm/generated/errors.js.map +1 -1
  67. package/dist/esm/generated/ids.d.ts +61 -0
  68. package/dist/esm/generated/ids.js +15 -0
  69. package/dist/esm/generated/ids.js.map +1 -1
  70. package/dist/esm/generated/jobs.js +4 -0
  71. package/dist/esm/generated/jobs.js.map +1 -1
  72. package/dist/esm/generated/ns/actions.d.ts +267 -33
  73. package/dist/esm/generated/ns/actions.js +375 -33
  74. package/dist/esm/generated/ns/actions.js.map +1 -1
  75. package/dist/esm/generated/ns/agents.d.ts +229 -0
  76. package/dist/esm/generated/ns/agents.js +398 -0
  77. package/dist/esm/generated/ns/agents.js.map +1 -0
  78. package/dist/esm/generated/ns/images.d.ts +81 -0
  79. package/dist/esm/generated/ns/images.js +118 -0
  80. package/dist/esm/generated/ns/images.js.map +1 -0
  81. package/dist/esm/generated/ns/infer.d.ts +71 -3
  82. package/dist/esm/generated/ns/infer.js +98 -3
  83. package/dist/esm/generated/ns/infer.js.map +1 -1
  84. package/dist/esm/generated/ns/keys.d.ts +3 -1
  85. package/dist/esm/generated/ns/keys.js +3 -1
  86. package/dist/esm/generated/ns/keys.js.map +1 -1
  87. package/dist/esm/generated/ns/listeners.d.ts +159 -0
  88. package/dist/esm/generated/ns/listeners.js +260 -0
  89. package/dist/esm/generated/ns/listeners.js.map +1 -0
  90. package/dist/esm/generated/ns/orgs.d.ts +10 -0
  91. package/dist/esm/generated/ns/orgs.js +26 -1
  92. package/dist/esm/generated/ns/orgs.js.map +1 -1
  93. package/dist/esm/generated/ns/projects.d.ts +32 -0
  94. package/dist/esm/generated/ns/projects.js +66 -0
  95. package/dist/esm/generated/ns/projects.js.map +1 -1
  96. package/dist/esm/generated/ns/render.d.ts +192 -21
  97. package/dist/esm/generated/ns/render.js +267 -24
  98. package/dist/esm/generated/ns/render.js.map +1 -1
  99. package/dist/esm/generated/ns/requests.d.ts +3 -1
  100. package/dist/esm/generated/ns/requests.js +3 -1
  101. package/dist/esm/generated/ns/requests.js.map +1 -1
  102. package/dist/esm/generated/ns/routines.d.ts +11 -4
  103. package/dist/esm/generated/ns/routines.js +11 -4
  104. package/dist/esm/generated/ns/routines.js.map +1 -1
  105. package/dist/esm/generated/ns/sandboxes.d.ts +292 -7
  106. package/dist/esm/generated/ns/sandboxes.js +444 -6
  107. package/dist/esm/generated/ns/sandboxes.js.map +1 -1
  108. package/dist/esm/generated/ns/usage.d.ts +1 -1
  109. package/dist/esm/generated/ns/usage.js +1 -1
  110. package/dist/esm/generated/ns/vision.d.ts +59 -17
  111. package/dist/esm/generated/ns/vision.js +59 -21
  112. package/dist/esm/generated/ns/vision.js.map +1 -1
  113. package/dist/esm/generated/types.d.ts +2564 -68
  114. package/dist/esm/helpers/sandboxes.d.ts +20 -1
  115. package/dist/esm/helpers/sandboxes.js +13 -1
  116. package/dist/esm/helpers/sandboxes.js.map +1 -1
  117. package/package.json +1 -1
  118. package/src/core/util.ts +1 -1
  119. package/src/generated/client.ts +28 -0
  120. package/src/generated/errors.ts +150 -0
  121. package/src/generated/ids.ts +15 -0
  122. package/src/generated/jobs.ts +4 -0
  123. package/src/generated/ns/actions.ts +403 -33
  124. package/src/generated/ns/agents.ts +461 -0
  125. package/src/generated/ns/images.ts +128 -0
  126. package/src/generated/ns/infer.ts +100 -3
  127. package/src/generated/ns/keys.ts +3 -1
  128. package/src/generated/ns/listeners.ts +296 -0
  129. package/src/generated/ns/orgs.ts +27 -1
  130. package/src/generated/ns/projects.ts +74 -0
  131. package/src/generated/ns/render.ts +277 -24
  132. package/src/generated/ns/requests.ts +3 -1
  133. package/src/generated/ns/routines.ts +11 -4
  134. package/src/generated/ns/sandboxes.ts +492 -7
  135. package/src/generated/ns/usage.ts +1 -1
  136. package/src/generated/ns/vision.ts +59 -21
  137. package/src/generated/types.ts +2907 -192
  138. package/src/helpers/sandboxes.ts +31 -2
@@ -1,7 +1,7 @@
1
1
  import type { BinaryInput, RequestOptions, StreamOptions } from "../../core/client.ts";
2
2
  import { Namespace } from "../../core/namespace.ts";
3
3
  import type { Op } from "../../core/op.ts";
4
- import type { APIPromise, ListPromise } from "../../core/promise.ts";
4
+ import type { APIPromise, JobPromise, ListPromise } from "../../core/promise.ts";
5
5
  import type { EventStream } from "../../core/sse.ts";
6
6
  import { PtySession } from "../../core/ws.ts";
7
7
  import { type CodexExecServerOptions, type Harness, type ManagedAgentsSessionOptions, type ManagedAgentsWorkerOptions } from "../../helpers/agents.ts";
@@ -14,8 +14,21 @@ export declare const sandboxesOps: {
14
14
  readonly listSnapshots: Op;
15
15
  readonly deleteSnapshot: Op;
16
16
  readonly getSnapshot: Op;
17
+ readonly listSwarms: Op;
18
+ readonly createSwarm: Op;
19
+ readonly getSwarm: Op;
20
+ readonly cancelSwarm: Op;
21
+ readonly listSwarmChildren: Op;
22
+ readonly swarmEvents: Op;
17
23
  readonly listTemplates: Op;
18
24
  readonly getTemplate: Op;
25
+ readonly listVolumes: Op;
26
+ readonly createVolume: Op;
27
+ readonly deleteVolume: Op;
28
+ readonly getVolume: Op;
29
+ readonly updateVolume: Op;
30
+ readonly purgeVolume: Op;
31
+ readonly restoreVolume: Op;
19
32
  readonly deleteSandbox: Op;
20
33
  readonly getSandbox: Op;
21
34
  readonly setEgress: Op;
@@ -27,8 +40,11 @@ export declare const sandboxesOps: {
27
40
  readonly moveFile: Op;
28
41
  readonly statFile: Op;
29
42
  readonly forkSandbox: Op;
43
+ readonly releaseLease: Op;
44
+ readonly holdLease: Op;
30
45
  readonly streamLogs: Op;
31
46
  readonly pauseSandbox: Op;
47
+ readonly createPortHost: Op;
32
48
  readonly createPortUrl: Op;
33
49
  readonly listProcesses: Op;
34
50
  readonly killProcess: Op;
@@ -52,6 +68,8 @@ export declare class SandboxesAPI extends Namespace {
52
68
  * `metadata[<key>]=<value>` (up to 4 pairs) keeps only sandboxes whose `metadata` holds every pair given, with
53
69
  * exactly that value: `GET /v1/sandboxes?metadata[customer]=acme&metadata[ticket]=ENG-1423`. A sandbox whose
54
70
  * create lost its answer (a dropped connection) is found this way by a tag it was created with.
71
+ * `owner=project&created_by_key=<key_id>` lists the services a key deployed, and `root=<sandbox_id>` the
72
+ * sandboxes one of them started.
55
73
  *
56
74
  * `GET /v1/sandboxes` · scope `sandboxes:read` · served by the node
57
75
  */
@@ -132,6 +150,14 @@ export declare class SandboxesAPI extends Namespace {
132
150
  * the daemon (streamed execs, PTY sessions, log streams, port preview connections, the sandbox's outbound
133
151
  * connections and its calls to `http://127.0.0.1:7700`) drop at the restart and can be opened again.
134
152
  *
153
+ * From an image (`image: "img_…"`, `POST /v1/images`): the sandbox restores the image's warm snapshot and
154
+ * has the image's size; a `vcpu` or `memory_mib` other than it answers `400 invalid_request`. `image` needs the
155
+ * `images.import` flag on for your organization (`404 feature_not_enabled` otherwise), answers `404
156
+ * image_not_found` for an image of another project and `409 image_not_ready` (with `current_status`) until the
157
+ * image is `ready`. `template: "tpl_…"` with the image's template ID works the same way without the flag (the
158
+ * template exists only once an import has run). Give `image` alone: with `template` or `snapshot` it answers
159
+ * `400 invalid_request`.
160
+ *
135
161
  * Disk: a sandbox's disk is its own copy-on-write copy of the template's (or snapshot's) disk; it is deleted
136
162
  * when the sandbox ends and never given to another sandbox. The disks of an organization's running and paused
137
163
  * sandboxes on a node add up to at most `sandboxes.disk_total_max` (each sandbox counting its `disk_gib`;
@@ -169,13 +195,102 @@ export declare class SandboxesAPI extends Namespace {
169
195
  * `GET /v1/sandboxes/snapshots/{snapshot_id}` · scope `sandboxes:read` · served by the node
170
196
  */
171
197
  getSnapshot(snapshotId: string, options?: RequestOptions): APIPromise<T.Snapshot>;
198
+ /**
199
+ * List swarms
200
+ *
201
+ * Lists swarms in this project, newest first, without their children (`GET /v1/sandboxes/swarms/{swarm_id}`
202
+ * returns them). Swarms are kept for 7 days after they finish.
203
+ *
204
+ * `GET /v1/sandboxes/swarms` · scope `sandboxes:read` · served by the node
205
+ */
206
+ listSwarms(params?: T.SandboxesListSwarmsParams, options?: RequestOptions): ListPromise<T.SwarmList, T.Swarm>;
207
+ /**
208
+ * Start a swarm
209
+ *
210
+ * Forks one checkpoint into children, runs a command in each child, and gathers every child's exit code,
211
+ * output and timing. The checkpoint is a forkable sandbox (`from.sandbox`, running or paused) or a snapshot
212
+ * (`from.snapshot`). Each child is a new sandbox with a fresh identity, as a fork's or a restore's is: it keeps
213
+ * the checkpoint's environment, secrets, files, egress, ports and grant, and gets its own ID.
214
+ *
215
+ * Give the children one by one in `children` (at most `sandboxes.swarm_children_max`; a child's index is its
216
+ * position), or give `count` children that all run `defaults`. Each child's command runs as
217
+ * `POST /v1/sandboxes/{sandbox_id}/exec` would run it streamed, with `B3OS_SWARM_ID` and `B3OS_SWARM_INDEX`
218
+ * added to its environment, so one command can shard work by index. `env` is stored with the swarm's record
219
+ * for as long as it is kept: pass secrets as the checkpoint's `secrets`, never in `env`.
220
+ *
221
+ * A child whose sandbox would expire before its command's `timeout_ms` has passed gets a longer lifetime, the
222
+ * command's timeout plus 30 seconds, up to `sandboxes.timeout_max`.
223
+ *
224
+ * A child's non-zero exit is a result, not a failure of the swarm. The swarm `succeeded` once every child's
225
+ * command ended (exited, timed out, or could not run) or `stop_when` was met; it `failed` only when no child
226
+ * could start (the fork or restore failed) or the node restarted while it ran. With
227
+ * `stop_when: first_success`, the first child to exit 0 is `result.winner` and the other children's commands
228
+ * are killed (`canceled`). Each stream of output keeps its first `output_max_bytes` bytes, in the record and
229
+ * in the events.
230
+ *
231
+ * After its command ends a child is deleted, unless `keep` keeps it: `succeeded` keeps the children that
232
+ * exited 0, `all` keeps every child. A kept child is an ordinary sandbox that runs to its own `expires_at`,
233
+ * counts against `sandboxes.concurrent` and is billed until you delete it.
234
+ *
235
+ * All children are reserved at once, nothing started unless every one fits: past `sandboxes.concurrent` the
236
+ * answer is `429 concurrency_limited` with `Retry-After`, past `sandboxes.disk_total_max` `422 limit_exceeded`.
237
+ * An organization runs at most `sandboxes.swarms_running` swarms at a time (`422 limit_exceeded`). A sandbox checkpoint must have been created with `forkable: true` (`409 fork_unavailable`) and
238
+ * hold no volume (`409 volume_attached`). Creating a swarm needs `sandboxes:write` and also `sandboxes:run`.
239
+ * Swarms are listed for 7 days after they finish. Behind the `sandboxes.swarms` feature flag: until it is on
240
+ * for your organization every swarm operation answers `404 feature_not_enabled`.
241
+ *
242
+ * `POST /v1/sandboxes/swarms` · scope `sandboxes:write` · served by the node
243
+ */
244
+ createSwarm(body: T.SwarmCreateRequest, options?: RequestOptions): JobPromise<T.Swarm, T.SwarmEvent>;
245
+ /**
246
+ * Get a swarm
247
+ *
248
+ * Returns the swarm with its status, progress, result, timing and every child with its exit code, output and
249
+ * timing. While it runs, children that have not ended show `queued` or `running`. `?wait=` holds the answer
250
+ * until the swarm ends or the wait runs out.
251
+ *
252
+ * `GET /v1/sandboxes/swarms/{swarm_id}` · scope `sandboxes:read` · served by the node
253
+ */
254
+ getSwarm(swarmId: string, params?: T.SandboxesGetSwarmParams, options?: RequestOptions): APIPromise<T.Swarm>;
255
+ /**
256
+ * Cancel a swarm
257
+ *
258
+ * Stops the swarm: commands still running are killed and those children end `canceled`; each child is then
259
+ * deleted unless the swarm's `keep` keeps it (`all` keeps every child, `succeeded` the ones that exited 0).
260
+ * Returns the swarm with status `canceled`.
261
+ *
262
+ * `POST /v1/sandboxes/swarms/{swarm_id}/cancel` · scope `sandboxes:write` · served by the node
263
+ */
264
+ cancelSwarm(swarmId: string, options?: RequestOptions): APIPromise<T.Swarm>;
265
+ /**
266
+ * List a swarm's children
267
+ *
268
+ * Lists the swarm's children by index, with each child's exit code, output and timing. Available while the swarm runs.
269
+ *
270
+ * `GET /v1/sandboxes/swarms/{swarm_id}/children` · scope `sandboxes:read` · served by the node
271
+ */
272
+ listSwarmChildren(swarmId: string, params?: T.SandboxesListSwarmChildrenParams, options?: RequestOptions): ListPromise<T.SwarmChildList, T.SwarmChild>;
273
+ /**
274
+ * Stream a swarm's events
275
+ *
276
+ * Server-sent events for the swarm: lifecycle events, `swarm.forked` with each child's sandbox ID, then
277
+ * `child.started`, `child.exited` or `child.failed` per child, and `child.stdout` and `child.stderr` when the
278
+ * swarm was created with `stream_output: true`. Ends after the terminal event. Reconnect with `Last-Event-ID`
279
+ * to resume. Events are kept with the swarm, so the stream reads the same, with the same `seq`, after the node
280
+ * restarts.
281
+ *
282
+ * `GET /v1/sandboxes/swarms/{swarm_id}/events` · scope `sandboxes:read` · served by the node
283
+ */
284
+ swarmEvents(swarmId: string, options?: StreamOptions): EventStream<T.SwarmEvent>;
172
285
  /**
173
286
  * List templates
174
287
  *
175
288
  * Lists the templates sandboxes can start from (`base`, `code-interpreter`, `agent`, and `browser` where a node
176
289
  * builds it, which the beta node does not yet: Chrome already running in the snapshot, a VM-isolated browser
177
290
  * with DevTools on port 9222) with their OS, runtimes, capabilities, defaults and `size_classes` (the sizes kept
178
- * pre-warmed). It does not list a template's packages.
291
+ * pre-warmed). It does not list a template's packages. The node's templates have `owner: node`; your project's
292
+ * imported images add their templates with `owner: project` and `image` set (`POST /v1/images`). Other
293
+ * projects' image templates are never listed, and getting one answers `404 template_not_found`.
179
294
  *
180
295
  * `GET /v1/sandboxes/templates` · scope `sandboxes:read` · served by the node
181
296
  */
@@ -183,11 +298,78 @@ export declare class SandboxesAPI extends Namespace {
183
298
  /**
184
299
  * Get a template
185
300
  *
186
- * Returns one template by name (`base`) or ID (`tpl_…`).
301
+ * Returns one template by name (`base`) or ID (`tpl_…`): a node template, or one of your project's image templates. Another project's image template answers `404 template_not_found`.
187
302
  *
188
303
  * `GET /v1/sandboxes/templates/{template}` · scope `sandboxes:read` · served by the node
189
304
  */
190
305
  getTemplate(template: string, options?: RequestOptions): APIPromise<T.Template>;
306
+ /**
307
+ * List volumes
308
+ *
309
+ * Lists the project's volumes on this node, newest first. Deleted volumes are listed only with `status=deleted`.
310
+ *
311
+ * `GET /v1/sandboxes/volumes` · scope `sandboxes:read` · served by the node
312
+ */
313
+ listVolumes(params?: T.SandboxesListVolumesParams, options?: RequestOptions): ListPromise<T.VolumeList, T.Volume>;
314
+ /**
315
+ * Create a volume
316
+ *
317
+ * Creates an ext4 volume of `size_gib` on this node: data that outlives the sandboxes that mount it. Mount it
318
+ * in a sandbox with `volumes` on `POST /v1/sandboxes`; it is held by one running or paused sandbox at a time.
319
+ * Its blocks are allocated at once and reserved on the node's disk, so a full node disk cannot fail a write to
320
+ * it. Bills `sandboxes.volume_gib_h` (its size times the hours it exists, mounted or not) until it is deleted.
321
+ *
322
+ * In this beta a volume is one copy on the node's one drive: there is no backup, and it is not encrypted at
323
+ * rest, like every sandbox disk. Have the code that writes to it fsync what matters: what an app wrote and did
324
+ * not flush when its sandbox's microVM stopped without warning is lost.
325
+ *
326
+ * `POST /v1/sandboxes/volumes` · scope `sandboxes:write` · served by the node
327
+ */
328
+ createVolume(body: T.VolumeCreateRequest, options?: RequestOptions): APIPromise<T.Volume>;
329
+ /**
330
+ * Delete a volume
331
+ *
332
+ * Marks the volume deleted: it is no longer listed or mounted, stops billing, and is purged (its data gone) at
333
+ * `purge_at`, 7 days later, unless you restore it first. Refused while a sandbox holds it (`409
334
+ * volume_attached`). Nothing else deletes a volume.
335
+ *
336
+ * `DELETE /v1/sandboxes/volumes/{volume_id}` · scope `sandboxes:write` · served by the node
337
+ */
338
+ deleteVolume(volumeId: string, options?: RequestOptions): APIPromise<T.Volume>;
339
+ /**
340
+ * Get a volume
341
+ *
342
+ * Returns a volume, deleted ones in their grace included.
343
+ *
344
+ * `GET /v1/sandboxes/volumes/{volume_id}` · scope `sandboxes:read` · served by the node
345
+ */
346
+ getVolume(volumeId: string, options?: RequestOptions): APIPromise<T.Volume>;
347
+ /**
348
+ * Grow a volume or change its metadata
349
+ *
350
+ * Replaces `metadata`, and grows the volume to `size_gib`. A volume grows only, and only while no sandbox
351
+ * holds it (`409 volume_attached`): its file system grows to the new size the next time a sandbox mounts it.
352
+ *
353
+ * `PATCH /v1/sandboxes/volumes/{volume_id}` · scope `sandboxes:write` · served by the node
354
+ */
355
+ updateVolume(volumeId: string, body?: T.VolumeUpdateRequest, options?: RequestOptions): APIPromise<T.Volume>;
356
+ /**
357
+ * Purge a volume now
358
+ *
359
+ * Removes the volume and its data now, deleted or not, without waiting for `purge_at`. `confirm` must be the
360
+ * volume's name. Refused while a sandbox holds it (`409 volume_attached`). This cannot be undone.
361
+ *
362
+ * `POST /v1/sandboxes/volumes/{volume_id}/purge` · scope `sandboxes:write` · served by the node
363
+ */
364
+ purgeVolume(volumeId: string, body: T.VolumePurgeRequest, options?: RequestOptions): APIPromise<T.Deleted>;
365
+ /**
366
+ * Restore a deleted volume
367
+ *
368
+ * A deleted volume whose `purge_at` has not passed is `available` again, with its data. A volume that is not deleted is returned as it is.
369
+ *
370
+ * `POST /v1/sandboxes/volumes/{volume_id}/restore` · scope `sandboxes:write` · served by the node
371
+ */
372
+ restoreVolume(volumeId: string, options?: RequestOptions): APIPromise<T.Volume>;
191
373
  /**
192
374
  * Delete a sandbox
193
375
  *
@@ -237,6 +419,24 @@ export declare class SandboxesAPI extends Namespace {
237
419
  * one delivers the events queued before the cut and then ends with an `exec.exit` event whose `error` has
238
420
  * `code: forbidden` and `reason: egress_escalation` and whose `duration_ms` runs to the cut.
239
421
  *
422
+ * With `background: true` and `restart`, the node supervises the process and starts the same command again in
423
+ * the same sandbox when it exits: `on-failure` after an exit with a non-zero code or by a signal, `always` after
424
+ * any exit. The first restart is at once; each further one in a row waits 1, 2, 4, 8, 16, 32 and then 60 s. A
425
+ * run of at least 60 s resets the wait. Five exits within 300 s put the process in `crash_loop`: the node goes
426
+ * on starting it, at most 60 s apart, for as long as the sandbox runs (a dependency that comes back heals it),
427
+ * and a run of 60 s ends `crash_loop`. When the node restarts the process it first kills what is left of its process
428
+ * group, for an exit it saw within 60 s of last seeing the process alive and while the pid is still that
429
+ * process's (after a restart of the node itself it leaves the group alone and only starts the command again). A
430
+ * signal sent from inside the sandbox (`kill -9`, `pkill`) counts as an exit and is restarted; a signal sent
431
+ * with `POST …/processes/{pid}/kill` stops the supervision unless it asks to restart. The sandbox's
432
+ * `supervised` list shows each supervised process: its current `pid`, `state`, `restarts` and `last_exit`.
433
+ * A sandbox supervises at most 8 processes; a ninth `restart` is `400 invalid_request`, as is `restart`
434
+ * without `background` or with `stdin`. The command, `cwd`, `env` and `user` are kept with the sandbox's
435
+ * record on the node's disk for its restarts: pass secrets with the create's `secrets`, not on the command
436
+ * line or in `env`. A fork, or a sandbox restored from a snapshot, supervises nothing: the processes it took
437
+ * over run on unsupervised. Restarts pause while the node's own service restarts; a process that exited
438
+ * then is started again once it is back.
439
+ *
240
440
  * `cmd` as a string runs through `/bin/sh -c`; as an array it is executed directly. Output is UTF-8 (invalid
241
441
  * bytes become U+FFFD) and each stream is capped at 1 MiB in a buffered response.
242
442
  *
@@ -347,7 +547,8 @@ export declare class SandboxesAPI extends Namespace {
347
547
  * `forkable: true` (forkable sandboxes are restored for themselves rather than claimed from a pool, and track
348
548
  * the pages they change); forks are forkable too. The source pauses while its changed memory is written
349
549
  * (`pause`, `base`, `snapshot`, `export` phases in `Server-Timing`), then runs on; like a snapshot this resets
350
- * its open connections to the outside.
550
+ * its open connections to the outside. A paused source is resumed for the fork and paused again (`resume`
551
+ * and `repause` phases), so a checkpoint can wait paused, billing neither meter, between forks.
351
552
  * Each fork counts against your sandbox concurrency and, with the source's `disk_gib`, against
352
553
  * `sandboxes.disk_total_max` (`422 limit_exceeded`). While the node's snapshot or disk store is nearly full,
353
554
  * forks are refused with `503 capacity_unavailable`.
@@ -355,6 +556,56 @@ export declare class SandboxesAPI extends Namespace {
355
556
  * `POST /v1/sandboxes/{sandbox_id}/fork` · scope `sandboxes:write` · served by the node
356
557
  */
357
558
  forkSandbox(sandboxId: string, body?: T.ForkRequest, options?: RequestOptions): APIPromise<T.SandboxList>;
559
+ /**
560
+ * Release a sandbox's lease
561
+ *
562
+ * Ends the sandbox's lease (`end_reason: released`). The sandbox keeps running until its current `expires_at`,
563
+ * which you can still move with `POST /v1/sandboxes/{sandbox_id}/timeout`. Releasing a sandbox that holds no
564
+ * lease, or one that has stopped, changes nothing and answers the sandbox. A sandbox's own credential cannot
565
+ * release a lease (`403 forbidden`, `reason: sandbox`).
566
+ *
567
+ * `DELETE /v1/sandboxes/{sandbox_id}/lease` · scope `sandboxes:write` · served by the node
568
+ */
569
+ releaseLease(sandboxId: string, options?: RequestOptions): APIPromise<T.Sandbox>;
570
+ /**
571
+ * Keep a sandbox running under a lease
572
+ *
573
+ * Holds a lease on the sandbox under `key`, a name of your choosing (the deploy engine uses
574
+ * `b3os:<app>/<service>`). While the lease is held and the sandbox runs, the node keeps it running past its
575
+ * `timeout_s` and past `sandboxes.timeout_max`: whenever less than half of `sandboxes.lease_term` (900 s) is
576
+ * left before `expires_at`, the node moves `expires_at` to `lease_term` from now. Nothing outside the node has
577
+ * to renew it.
578
+ *
579
+ * One live sandbox in a project holds a key at a time. Holding a key on this sandbox takes it from the sandbox
580
+ * that held it: that lease ends (`end_reason: replaced`) and that sandbox's `expires_at` moves to at most
581
+ * `lease_term` from now, so it stops by then unless something extends it. A sandbox holds one lease; a call
582
+ * with another key changes the key it holds. A call with the key it already holds changes nothing.
583
+ *
584
+ * `expect_holder` makes the call conditional on what you read: the sandbox you saw holding `key`, or `null` when
585
+ * you saw none. The node takes the key only while that is still so; otherwise it answers `409
586
+ * lease_holder_changed` with the sandbox that holds it now (`holder`), and changes nothing. A caller that read an
587
+ * older state (a check that read the generation before a deploy handed the key to a newer one) then never takes
588
+ * the key back from the sandbox that got it since. Without `expect_holder` the call takes the key from whichever
589
+ * sandbox holds it.
590
+ *
591
+ * The lease ends when you release it (`DELETE …/lease`, `end_reason: released`; the sandbox then runs out its
592
+ * current `expires_at`) and when the sandbox stops for any reason (`end_reason` is its `stop_reason`:
593
+ * `deleted`, `timeout`, `failed`, `budget`, `revoked`). A paused sandbox is not renewed: it ends at
594
+ * `expires_at` like any paused sandbox. An organization holds at most `sandboxes.leases_max` (5) leases on a
595
+ * node; one more is `422 limit_exceeded`, and lowering the limit ends none already held. A sandbox's own
596
+ * credential (the one its in-VM API holds) cannot hold or release a lease (`403 forbidden`, `reason: sandbox`),
597
+ * so code can never keep its own sandbox, or another, running with it. A real API key you put into a sandbox (in
598
+ * its `env` or `secrets`) is not the sandbox's own credential: code holding it can hold a lease as any caller
599
+ * can, within `sandboxes.leases_max` and the organization's credits and spend caps.
600
+ *
601
+ * A leased sandbox is billed like any running one (`sandboxes.vcpu_ms`, `sandboxes.gib_ms`), so the call is
602
+ * admitted like a create (credits, spend cap). The node checks a running sandbox's budget every 10 s and stops
603
+ * a leased one, ending its lease, as it stops any other (`stop_reason: budget` or `revoked`; a project's service
604
+ * never stops for its key's revoke or expiry, so not `revoked`).
605
+ *
606
+ * `PUT /v1/sandboxes/{sandbox_id}/lease` · scope `sandboxes:write` · served by the node
607
+ */
608
+ holdLease(sandboxId: string, body: T.LeaseRequest, options?: RequestOptions): APIPromise<T.Sandbox>;
358
609
  /**
359
610
  * Stream process logs
360
611
  *
@@ -387,6 +638,36 @@ export declare class SandboxesAPI extends Namespace {
387
638
  * `POST /v1/sandboxes/{sandbox_id}/pause` · scope `sandboxes:write` · served by the node
388
639
  */
389
640
  pauseSandbox(sandboxId: string, options?: RequestOptions): APIPromise<T.Sandbox>;
641
+ /**
642
+ * Give a sandbox port its own host
643
+ *
644
+ * Gives `port` of the sandbox its own host, `https://<port>-sbx-<id>.b3os.io` (`<id>` is the sandbox ID without
645
+ * `sbx_`), and returns a link to it. The app is served at `/` and keeps its cookies, as an application's
646
+ * address does: it gets the request's whole path with no prefix, `Host` is the host, and the cookies it sets
647
+ * stay on this host (`cookies`, `isolated` by default: the same rules as app addresses). Use it for apps that
648
+ * need the root path or sign-in cookies. `POST /v1/sandboxes/{sandbox_id}/ports/{port}/url` keeps working as
649
+ * before.
650
+ *
651
+ * Shared by link only, never public. The link (`url`) works for `ttl_s` seconds (10 minutes by default, at
652
+ * most 24 hours); its first page load sets a cookie that keeps that browser in for 24 hours, and a program can
653
+ * send the link's `b3os_link` value in `x-b3os-link` instead. Anyone else gets a 401 page, the same whether or
654
+ * not the sandbox or the host exists. Each call returns a new link and leaves earlier ones working; `rotate:
655
+ * true` first replaces the host's secret, so every earlier link and cookie of this host stops working within 6
656
+ * seconds. `cookies` sets the host's cookie rule; left out, the host keeps the one it has.
657
+ *
658
+ * The port must be in the sandbox's `ports` and the sandbox running or paused (404 `port_not_exposed`, 409
659
+ * `sandbox_not_running`, and 404 `sandbox_not_found` for a sandbox of another project). While the sandbox is
660
+ * paused or stopped its host answers 503. The host is that sandbox's and port's for good and ends with the
661
+ * sandbox; a fork or a restore has a new ID, so new hosts. A host with no call for 49 hours is forgotten: the
662
+ * next call makes it again with a new secret. A dev server must accept the host (for Vite,
663
+ * `server.allowedHosts: ['.b3os.io']`). Not yet available to code inside a sandbox (its API answers 421
664
+ * `edge_only`). Port 49983 is kept for E2B's envd and gets no host (400). Hosts count toward no address limit.
665
+ * B3 can block a sandbox's hosts (403 `app_host_blocked`). An organization may call this 60 times a minute
666
+ * (429 `rate_limited` with `Retry-After` past that).
667
+ *
668
+ * `POST /v1/sandboxes/{sandbox_id}/ports/{port}/host` · scope `sandboxes:run` · served by beta-api.b3os.org
669
+ */
670
+ createPortHost(sandboxId: string, port: number, body?: T.PortHostRequest, options?: RequestOptions): APIPromise<T.PortHost>;
390
671
  /**
391
672
  * Get a URL for a port
392
673
  *
@@ -423,7 +704,10 @@ export declare class SandboxesAPI extends Namespace {
423
704
  /**
424
705
  * Signal a background process
425
706
  *
426
- * Sends a signal (default `TERM`) to a background process and its process group, and returns the process.
707
+ * Sends a signal (default `TERM`) to a background process and its process group, and returns the process. On a
708
+ * process the node supervises (an exec with `restart`), the call first ends the supervision (`state: stopped`
709
+ * in the sandbox's `supervised`), so the process stays down; with `restart: true` it stays supervised and the
710
+ * node starts it again once it exits, counted as a restart.
427
711
  *
428
712
  * `POST /v1/sandboxes/{sandbox_id}/processes/{pid}/kill` · scope `sandboxes:run` · served by the node
429
713
  */
@@ -483,8 +767,9 @@ export declare class SandboxesAPI extends Namespace {
483
767
  * searches and calls to other sandboxes), newest first, from the node's request log. These are the records
484
768
  * `GET /v1/requests?sandbox_id=` lists, for a caller that may read the sandbox: it needs only `sandboxes:read`,
485
769
  * not `platform:read`, and never returns another sandbox's records. It takes the same paging and the
486
- * `product`, `operation_id`, `status`, `trace_id` and `since` filters; any other query parameter is
487
- * `400 invalid_request`. Requests made to the sandbox's public ports are not listed. A sandbox stopped more
770
+ * `product`, `operation_id`, `status`, `trace_id`, `since` and `pack` filters; any other query parameter is
771
+ * `400 invalid_request`. `pack=io.b3os/wikipedia` lists the sandbox's calls of that pack's actions, through
772
+ * `POST /v1/actions/call` or as tools over MCP (each record's `action`). Requests made to the sandbox's public ports are not listed. A sandbox stopped more
488
773
  * than 7 days ago is not found.
489
774
  *
490
775
  * `GET /v1/sandboxes/{sandbox_id}/requests` · scope `sandboxes:read` · served by the node