@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.
- package/dist/cjs/core/util.d.ts +1 -1
- package/dist/cjs/core/util.js +1 -1
- package/dist/cjs/generated/client.d.ts +13 -0
- package/dist/cjs/generated/client.js +25 -0
- package/dist/cjs/generated/client.js.map +1 -1
- package/dist/cjs/generated/errors.d.ts +1 -1
- package/dist/cjs/generated/errors.js +75 -0
- package/dist/cjs/generated/errors.js.map +1 -1
- package/dist/cjs/generated/ids.d.ts +61 -0
- package/dist/cjs/generated/ids.js +15 -0
- package/dist/cjs/generated/ids.js.map +1 -1
- package/dist/cjs/generated/jobs.js +4 -0
- package/dist/cjs/generated/jobs.js.map +1 -1
- package/dist/cjs/generated/ns/actions.d.ts +267 -33
- package/dist/cjs/generated/ns/actions.js +375 -33
- package/dist/cjs/generated/ns/actions.js.map +1 -1
- package/dist/cjs/generated/ns/agents.d.ts +229 -0
- package/dist/cjs/generated/ns/agents.js +402 -0
- package/dist/cjs/generated/ns/agents.js.map +1 -0
- package/dist/cjs/generated/ns/images.d.ts +81 -0
- package/dist/cjs/generated/ns/images.js +122 -0
- package/dist/cjs/generated/ns/images.js.map +1 -0
- package/dist/cjs/generated/ns/infer.d.ts +71 -3
- package/dist/cjs/generated/ns/infer.js +98 -3
- package/dist/cjs/generated/ns/infer.js.map +1 -1
- package/dist/cjs/generated/ns/keys.d.ts +3 -1
- package/dist/cjs/generated/ns/keys.js +3 -1
- package/dist/cjs/generated/ns/keys.js.map +1 -1
- package/dist/cjs/generated/ns/listeners.d.ts +159 -0
- package/dist/cjs/generated/ns/listeners.js +264 -0
- package/dist/cjs/generated/ns/listeners.js.map +1 -0
- package/dist/cjs/generated/ns/orgs.d.ts +10 -0
- package/dist/cjs/generated/ns/orgs.js +26 -1
- package/dist/cjs/generated/ns/orgs.js.map +1 -1
- package/dist/cjs/generated/ns/projects.d.ts +32 -0
- package/dist/cjs/generated/ns/projects.js +66 -0
- package/dist/cjs/generated/ns/projects.js.map +1 -1
- package/dist/cjs/generated/ns/render.d.ts +192 -21
- package/dist/cjs/generated/ns/render.js +267 -24
- package/dist/cjs/generated/ns/render.js.map +1 -1
- package/dist/cjs/generated/ns/requests.d.ts +3 -1
- package/dist/cjs/generated/ns/requests.js +3 -1
- package/dist/cjs/generated/ns/requests.js.map +1 -1
- package/dist/cjs/generated/ns/routines.d.ts +11 -4
- package/dist/cjs/generated/ns/routines.js +11 -4
- package/dist/cjs/generated/ns/routines.js.map +1 -1
- package/dist/cjs/generated/ns/sandboxes.d.ts +292 -7
- package/dist/cjs/generated/ns/sandboxes.js +444 -6
- package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
- package/dist/cjs/generated/ns/usage.d.ts +1 -1
- package/dist/cjs/generated/ns/usage.js +1 -1
- package/dist/cjs/generated/ns/vision.d.ts +59 -17
- package/dist/cjs/generated/ns/vision.js +59 -21
- package/dist/cjs/generated/ns/vision.js.map +1 -1
- package/dist/cjs/generated/types.d.ts +2564 -68
- package/dist/cjs/helpers/sandboxes.d.ts +20 -1
- package/dist/cjs/helpers/sandboxes.js +13 -1
- package/dist/cjs/helpers/sandboxes.js.map +1 -1
- package/dist/esm/core/util.d.ts +1 -1
- package/dist/esm/core/util.js +1 -1
- package/dist/esm/generated/client.d.ts +13 -0
- package/dist/esm/generated/client.js +25 -0
- package/dist/esm/generated/client.js.map +1 -1
- package/dist/esm/generated/errors.d.ts +1 -1
- package/dist/esm/generated/errors.js +75 -0
- package/dist/esm/generated/errors.js.map +1 -1
- package/dist/esm/generated/ids.d.ts +61 -0
- package/dist/esm/generated/ids.js +15 -0
- package/dist/esm/generated/ids.js.map +1 -1
- package/dist/esm/generated/jobs.js +4 -0
- package/dist/esm/generated/jobs.js.map +1 -1
- package/dist/esm/generated/ns/actions.d.ts +267 -33
- package/dist/esm/generated/ns/actions.js +375 -33
- package/dist/esm/generated/ns/actions.js.map +1 -1
- package/dist/esm/generated/ns/agents.d.ts +229 -0
- package/dist/esm/generated/ns/agents.js +398 -0
- package/dist/esm/generated/ns/agents.js.map +1 -0
- package/dist/esm/generated/ns/images.d.ts +81 -0
- package/dist/esm/generated/ns/images.js +118 -0
- package/dist/esm/generated/ns/images.js.map +1 -0
- package/dist/esm/generated/ns/infer.d.ts +71 -3
- package/dist/esm/generated/ns/infer.js +98 -3
- package/dist/esm/generated/ns/infer.js.map +1 -1
- package/dist/esm/generated/ns/keys.d.ts +3 -1
- package/dist/esm/generated/ns/keys.js +3 -1
- package/dist/esm/generated/ns/keys.js.map +1 -1
- package/dist/esm/generated/ns/listeners.d.ts +159 -0
- package/dist/esm/generated/ns/listeners.js +260 -0
- package/dist/esm/generated/ns/listeners.js.map +1 -0
- package/dist/esm/generated/ns/orgs.d.ts +10 -0
- package/dist/esm/generated/ns/orgs.js +26 -1
- package/dist/esm/generated/ns/orgs.js.map +1 -1
- package/dist/esm/generated/ns/projects.d.ts +32 -0
- package/dist/esm/generated/ns/projects.js +66 -0
- package/dist/esm/generated/ns/projects.js.map +1 -1
- package/dist/esm/generated/ns/render.d.ts +192 -21
- package/dist/esm/generated/ns/render.js +267 -24
- package/dist/esm/generated/ns/render.js.map +1 -1
- package/dist/esm/generated/ns/requests.d.ts +3 -1
- package/dist/esm/generated/ns/requests.js +3 -1
- package/dist/esm/generated/ns/requests.js.map +1 -1
- package/dist/esm/generated/ns/routines.d.ts +11 -4
- package/dist/esm/generated/ns/routines.js +11 -4
- package/dist/esm/generated/ns/routines.js.map +1 -1
- package/dist/esm/generated/ns/sandboxes.d.ts +292 -7
- package/dist/esm/generated/ns/sandboxes.js +444 -6
- package/dist/esm/generated/ns/sandboxes.js.map +1 -1
- package/dist/esm/generated/ns/usage.d.ts +1 -1
- package/dist/esm/generated/ns/usage.js +1 -1
- package/dist/esm/generated/ns/vision.d.ts +59 -17
- package/dist/esm/generated/ns/vision.js +59 -21
- package/dist/esm/generated/ns/vision.js.map +1 -1
- package/dist/esm/generated/types.d.ts +2564 -68
- package/dist/esm/helpers/sandboxes.d.ts +20 -1
- package/dist/esm/helpers/sandboxes.js +13 -1
- package/dist/esm/helpers/sandboxes.js.map +1 -1
- package/package.json +1 -1
- package/src/core/util.ts +1 -1
- package/src/generated/client.ts +28 -0
- package/src/generated/errors.ts +150 -0
- package/src/generated/ids.ts +15 -0
- package/src/generated/jobs.ts +4 -0
- package/src/generated/ns/actions.ts +403 -33
- package/src/generated/ns/agents.ts +461 -0
- package/src/generated/ns/images.ts +128 -0
- package/src/generated/ns/infer.ts +100 -3
- package/src/generated/ns/keys.ts +3 -1
- package/src/generated/ns/listeners.ts +296 -0
- package/src/generated/ns/orgs.ts +27 -1
- package/src/generated/ns/projects.ts +74 -0
- package/src/generated/ns/render.ts +277 -24
- package/src/generated/ns/requests.ts +3 -1
- package/src/generated/ns/routines.ts +11 -4
- package/src/generated/ns/sandboxes.ts +492 -7
- package/src/generated/ns/usage.ts +1 -1
- package/src/generated/ns/vision.ts +59 -21
- package/src/generated/types.ts +2907 -192
- package/src/helpers/sandboxes.ts +31 -2
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Generated by packages/sdk/scripts/generate.mjs from packages/spec/dist. Do not edit; run `pnpm generate`.
|
|
2
2
|
|
|
3
3
|
import type { BinaryInput, RequestOptions, StreamOptions } from "../../core/client.ts";
|
|
4
|
+
import { isTerminalJobEvent } from "../../core/jobs.ts";
|
|
4
5
|
import { Namespace } from "../../core/namespace.ts";
|
|
5
6
|
import type { Op } from "../../core/op.ts";
|
|
6
|
-
import type { APIPromise, ListPromise } from "../../core/promise.ts";
|
|
7
|
+
import type { APIPromise, JobPromise, ListPromise } from "../../core/promise.ts";
|
|
7
8
|
import type { EventStream } from "../../core/sse.ts";
|
|
8
9
|
import { openSocket, PtySession, ticketedUrl } from "../../core/ws.ts";
|
|
9
10
|
import {
|
|
@@ -70,6 +71,46 @@ const getSnapshotOp: Op = {
|
|
|
70
71
|
timeoutMs: 10000,
|
|
71
72
|
scope: "sandboxes:read",
|
|
72
73
|
};
|
|
74
|
+
const listSwarmsOp: Op = {
|
|
75
|
+
id: "sandboxesListSwarms",
|
|
76
|
+
method: "GET",
|
|
77
|
+
path: "/v1/sandboxes/swarms",
|
|
78
|
+
timeoutMs: 10000,
|
|
79
|
+
scope: "sandboxes:read",
|
|
80
|
+
};
|
|
81
|
+
const getSwarmOp: Op = {
|
|
82
|
+
id: "sandboxesGetSwarm",
|
|
83
|
+
method: "GET",
|
|
84
|
+
path: "/v1/sandboxes/swarms/{swarm_id}",
|
|
85
|
+
params: ["swarm_id"],
|
|
86
|
+
timeoutMs: 65000,
|
|
87
|
+
scope: "sandboxes:read",
|
|
88
|
+
};
|
|
89
|
+
const cancelSwarmOp: Op = {
|
|
90
|
+
id: "sandboxesCancelSwarm",
|
|
91
|
+
method: "POST",
|
|
92
|
+
path: "/v1/sandboxes/swarms/{swarm_id}/cancel",
|
|
93
|
+
params: ["swarm_id"],
|
|
94
|
+
timeoutMs: 10000,
|
|
95
|
+
scope: "sandboxes:write",
|
|
96
|
+
};
|
|
97
|
+
const listSwarmChildrenOp: Op = {
|
|
98
|
+
id: "sandboxesListSwarmChildren",
|
|
99
|
+
method: "GET",
|
|
100
|
+
path: "/v1/sandboxes/swarms/{swarm_id}/children",
|
|
101
|
+
params: ["swarm_id"],
|
|
102
|
+
timeoutMs: 10000,
|
|
103
|
+
scope: "sandboxes:read",
|
|
104
|
+
};
|
|
105
|
+
const swarmEventsOp: Op = {
|
|
106
|
+
id: "sandboxesSwarmEvents",
|
|
107
|
+
method: "GET",
|
|
108
|
+
path: "/v1/sandboxes/swarms/{swarm_id}/events",
|
|
109
|
+
params: ["swarm_id"],
|
|
110
|
+
stream: "sse",
|
|
111
|
+
timeoutMs: 3600000,
|
|
112
|
+
scope: "sandboxes:read",
|
|
113
|
+
};
|
|
73
114
|
const listTemplatesOp: Op = {
|
|
74
115
|
id: "sandboxesListTemplates",
|
|
75
116
|
method: "GET",
|
|
@@ -85,6 +126,63 @@ const getTemplateOp: Op = {
|
|
|
85
126
|
timeoutMs: 10000,
|
|
86
127
|
scope: "sandboxes:read",
|
|
87
128
|
};
|
|
129
|
+
const listVolumesOp: Op = {
|
|
130
|
+
id: "sandboxesListVolumes",
|
|
131
|
+
method: "GET",
|
|
132
|
+
path: "/v1/sandboxes/volumes",
|
|
133
|
+
timeoutMs: 10000,
|
|
134
|
+
scope: "sandboxes:read",
|
|
135
|
+
};
|
|
136
|
+
const createVolumeOp: Op = {
|
|
137
|
+
id: "sandboxesCreateVolume",
|
|
138
|
+
method: "POST",
|
|
139
|
+
path: "/v1/sandboxes/volumes",
|
|
140
|
+
body: "json",
|
|
141
|
+
timeoutMs: 30000,
|
|
142
|
+
scope: "sandboxes:write",
|
|
143
|
+
};
|
|
144
|
+
const deleteVolumeOp: Op = {
|
|
145
|
+
id: "sandboxesDeleteVolume",
|
|
146
|
+
method: "DELETE",
|
|
147
|
+
path: "/v1/sandboxes/volumes/{volume_id}",
|
|
148
|
+
params: ["volume_id"],
|
|
149
|
+
timeoutMs: 10000,
|
|
150
|
+
scope: "sandboxes:write",
|
|
151
|
+
};
|
|
152
|
+
const getVolumeOp: Op = {
|
|
153
|
+
id: "sandboxesGetVolume",
|
|
154
|
+
method: "GET",
|
|
155
|
+
path: "/v1/sandboxes/volumes/{volume_id}",
|
|
156
|
+
params: ["volume_id"],
|
|
157
|
+
timeoutMs: 10000,
|
|
158
|
+
scope: "sandboxes:read",
|
|
159
|
+
};
|
|
160
|
+
const updateVolumeOp: Op = {
|
|
161
|
+
id: "sandboxesUpdateVolume",
|
|
162
|
+
method: "PATCH",
|
|
163
|
+
path: "/v1/sandboxes/volumes/{volume_id}",
|
|
164
|
+
params: ["volume_id"],
|
|
165
|
+
body: "json",
|
|
166
|
+
timeoutMs: 30000,
|
|
167
|
+
scope: "sandboxes:write",
|
|
168
|
+
};
|
|
169
|
+
const purgeVolumeOp: Op = {
|
|
170
|
+
id: "sandboxesPurgeVolume",
|
|
171
|
+
method: "POST",
|
|
172
|
+
path: "/v1/sandboxes/volumes/{volume_id}/purge",
|
|
173
|
+
params: ["volume_id"],
|
|
174
|
+
body: "json",
|
|
175
|
+
timeoutMs: 30000,
|
|
176
|
+
scope: "sandboxes:write",
|
|
177
|
+
};
|
|
178
|
+
const restoreVolumeOp: Op = {
|
|
179
|
+
id: "sandboxesRestoreVolume",
|
|
180
|
+
method: "POST",
|
|
181
|
+
path: "/v1/sandboxes/volumes/{volume_id}/restore",
|
|
182
|
+
params: ["volume_id"],
|
|
183
|
+
timeoutMs: 10000,
|
|
184
|
+
scope: "sandboxes:write",
|
|
185
|
+
};
|
|
88
186
|
const deleteSandboxOp: Op = {
|
|
89
187
|
id: "sandboxesDeleteSandbox",
|
|
90
188
|
method: "DELETE",
|
|
@@ -187,6 +285,23 @@ const forkSandboxOp: Op = {
|
|
|
187
285
|
timeoutMs: 30000,
|
|
188
286
|
scope: "sandboxes:write",
|
|
189
287
|
};
|
|
288
|
+
const releaseLeaseOp: Op = {
|
|
289
|
+
id: "sandboxesReleaseLease",
|
|
290
|
+
method: "DELETE",
|
|
291
|
+
path: "/v1/sandboxes/{sandbox_id}/lease",
|
|
292
|
+
params: ["sandbox_id"],
|
|
293
|
+
timeoutMs: 10000,
|
|
294
|
+
scope: "sandboxes:write",
|
|
295
|
+
};
|
|
296
|
+
const holdLeaseOp: Op = {
|
|
297
|
+
id: "sandboxesHoldLease",
|
|
298
|
+
method: "PUT",
|
|
299
|
+
path: "/v1/sandboxes/{sandbox_id}/lease",
|
|
300
|
+
params: ["sandbox_id"],
|
|
301
|
+
body: "json",
|
|
302
|
+
timeoutMs: 10000,
|
|
303
|
+
scope: "sandboxes:write",
|
|
304
|
+
};
|
|
190
305
|
const streamLogsOp: Op = {
|
|
191
306
|
id: "sandboxesStreamLogs",
|
|
192
307
|
method: "GET",
|
|
@@ -204,6 +319,16 @@ const pauseSandboxOp: Op = {
|
|
|
204
319
|
timeoutMs: 10000,
|
|
205
320
|
scope: "sandboxes:write",
|
|
206
321
|
};
|
|
322
|
+
const createPortHostOp: Op = {
|
|
323
|
+
id: "platformCreatePortHost",
|
|
324
|
+
method: "POST",
|
|
325
|
+
path: "/v1/sandboxes/{sandbox_id}/ports/{port}/host",
|
|
326
|
+
params: ["sandbox_id", "port"],
|
|
327
|
+
body: "json",
|
|
328
|
+
edge: true,
|
|
329
|
+
timeoutMs: 15000,
|
|
330
|
+
scope: "sandboxes:run",
|
|
331
|
+
};
|
|
207
332
|
const createPortUrlOp: Op = {
|
|
208
333
|
id: "sandboxesCreatePortUrl",
|
|
209
334
|
method: "POST",
|
|
@@ -308,6 +433,17 @@ const setTimeoutOp: Op = {
|
|
|
308
433
|
timeoutMs: 10000,
|
|
309
434
|
scope: "sandboxes:write",
|
|
310
435
|
};
|
|
436
|
+
const createSwarmOp: Op = {
|
|
437
|
+
id: "sandboxesCreateSwarm",
|
|
438
|
+
method: "POST",
|
|
439
|
+
path: "/v1/sandboxes/swarms",
|
|
440
|
+
body: "json",
|
|
441
|
+
idem: true,
|
|
442
|
+
stream: "sse",
|
|
443
|
+
timeoutMs: 3600000,
|
|
444
|
+
scope: "sandboxes:write",
|
|
445
|
+
job: { get: getSwarmOp, events: swarmEventsOp, cancel: cancelSwarmOp },
|
|
446
|
+
};
|
|
311
447
|
|
|
312
448
|
/** Descriptors of every sandboxes operation, keyed by method name (for tooling and custom clients). */
|
|
313
449
|
export const sandboxesOps = {
|
|
@@ -316,8 +452,21 @@ export const sandboxesOps = {
|
|
|
316
452
|
listSnapshots: listSnapshotsOp,
|
|
317
453
|
deleteSnapshot: deleteSnapshotOp,
|
|
318
454
|
getSnapshot: getSnapshotOp,
|
|
455
|
+
listSwarms: listSwarmsOp,
|
|
456
|
+
createSwarm: createSwarmOp,
|
|
457
|
+
getSwarm: getSwarmOp,
|
|
458
|
+
cancelSwarm: cancelSwarmOp,
|
|
459
|
+
listSwarmChildren: listSwarmChildrenOp,
|
|
460
|
+
swarmEvents: swarmEventsOp,
|
|
319
461
|
listTemplates: listTemplatesOp,
|
|
320
462
|
getTemplate: getTemplateOp,
|
|
463
|
+
listVolumes: listVolumesOp,
|
|
464
|
+
createVolume: createVolumeOp,
|
|
465
|
+
deleteVolume: deleteVolumeOp,
|
|
466
|
+
getVolume: getVolumeOp,
|
|
467
|
+
updateVolume: updateVolumeOp,
|
|
468
|
+
purgeVolume: purgeVolumeOp,
|
|
469
|
+
restoreVolume: restoreVolumeOp,
|
|
321
470
|
deleteSandbox: deleteSandboxOp,
|
|
322
471
|
getSandbox: getSandboxOp,
|
|
323
472
|
setEgress: setEgressOp,
|
|
@@ -329,8 +478,11 @@ export const sandboxesOps = {
|
|
|
329
478
|
moveFile: moveFileOp,
|
|
330
479
|
statFile: statFileOp,
|
|
331
480
|
forkSandbox: forkSandboxOp,
|
|
481
|
+
releaseLease: releaseLeaseOp,
|
|
482
|
+
holdLease: holdLeaseOp,
|
|
332
483
|
streamLogs: streamLogsOp,
|
|
333
484
|
pauseSandbox: pauseSandboxOp,
|
|
485
|
+
createPortHost: createPortHostOp,
|
|
334
486
|
createPortUrl: createPortUrlOp,
|
|
335
487
|
listProcesses: listProcessesOp,
|
|
336
488
|
killProcess: killProcessOp,
|
|
@@ -355,6 +507,8 @@ export class SandboxesAPI extends Namespace {
|
|
|
355
507
|
* `metadata[<key>]=<value>` (up to 4 pairs) keeps only sandboxes whose `metadata` holds every pair given, with
|
|
356
508
|
* exactly that value: `GET /v1/sandboxes?metadata[customer]=acme&metadata[ticket]=ENG-1423`. A sandbox whose
|
|
357
509
|
* create lost its answer (a dropped connection) is found this way by a tag it was created with.
|
|
510
|
+
* `owner=project&created_by_key=<key_id>` lists the services a key deployed, and `root=<sandbox_id>` the
|
|
511
|
+
* sandboxes one of them started.
|
|
358
512
|
*
|
|
359
513
|
* `GET /v1/sandboxes` · scope `sandboxes:read` · served by the node
|
|
360
514
|
*/
|
|
@@ -441,6 +595,14 @@ export class SandboxesAPI extends Namespace {
|
|
|
441
595
|
* the daemon (streamed execs, PTY sessions, log streams, port preview connections, the sandbox's outbound
|
|
442
596
|
* connections and its calls to `http://127.0.0.1:7700`) drop at the restart and can be opened again.
|
|
443
597
|
*
|
|
598
|
+
* From an image (`image: "img_…"`, `POST /v1/images`): the sandbox restores the image's warm snapshot and
|
|
599
|
+
* has the image's size; a `vcpu` or `memory_mib` other than it answers `400 invalid_request`. `image` needs the
|
|
600
|
+
* `images.import` flag on for your organization (`404 feature_not_enabled` otherwise), answers `404
|
|
601
|
+
* image_not_found` for an image of another project and `409 image_not_ready` (with `current_status`) until the
|
|
602
|
+
* image is `ready`. `template: "tpl_…"` with the image's template ID works the same way without the flag (the
|
|
603
|
+
* template exists only once an import has run). Give `image` alone: with `template` or `snapshot` it answers
|
|
604
|
+
* `400 invalid_request`.
|
|
605
|
+
*
|
|
444
606
|
* Disk: a sandbox's disk is its own copy-on-write copy of the template's (or snapshot's) disk; it is deleted
|
|
445
607
|
* when the sandbox ends and never given to another sandbox. The disks of an organization's running and paused
|
|
446
608
|
* sandboxes on a node add up to at most `sandboxes.disk_total_max` (each sandbox counting its `disk_gib`;
|
|
@@ -498,13 +660,131 @@ export class SandboxesAPI extends Namespace {
|
|
|
498
660
|
return this._client._call<T.Snapshot>(getSnapshotOp, { path: [snapshotId] }, options);
|
|
499
661
|
}
|
|
500
662
|
|
|
663
|
+
/**
|
|
664
|
+
* List swarms
|
|
665
|
+
*
|
|
666
|
+
* Lists swarms in this project, newest first, without their children (`GET /v1/sandboxes/swarms/{swarm_id}`
|
|
667
|
+
* returns them). Swarms are kept for 7 days after they finish.
|
|
668
|
+
*
|
|
669
|
+
* `GET /v1/sandboxes/swarms` · scope `sandboxes:read` · served by the node
|
|
670
|
+
*/
|
|
671
|
+
listSwarms(params?: T.SandboxesListSwarmsParams, options?: RequestOptions): ListPromise<T.SwarmList, T.Swarm> {
|
|
672
|
+
return this._client._list<T.SwarmList, T.Swarm>(listSwarmsOp, { query: params }, options);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Start a swarm
|
|
677
|
+
*
|
|
678
|
+
* Forks one checkpoint into children, runs a command in each child, and gathers every child's exit code,
|
|
679
|
+
* output and timing. The checkpoint is a forkable sandbox (`from.sandbox`, running or paused) or a snapshot
|
|
680
|
+
* (`from.snapshot`). Each child is a new sandbox with a fresh identity, as a fork's or a restore's is: it keeps
|
|
681
|
+
* the checkpoint's environment, secrets, files, egress, ports and grant, and gets its own ID.
|
|
682
|
+
*
|
|
683
|
+
* Give the children one by one in `children` (at most `sandboxes.swarm_children_max`; a child's index is its
|
|
684
|
+
* position), or give `count` children that all run `defaults`. Each child's command runs as
|
|
685
|
+
* `POST /v1/sandboxes/{sandbox_id}/exec` would run it streamed, with `B3OS_SWARM_ID` and `B3OS_SWARM_INDEX`
|
|
686
|
+
* added to its environment, so one command can shard work by index. `env` is stored with the swarm's record
|
|
687
|
+
* for as long as it is kept: pass secrets as the checkpoint's `secrets`, never in `env`.
|
|
688
|
+
*
|
|
689
|
+
* A child whose sandbox would expire before its command's `timeout_ms` has passed gets a longer lifetime, the
|
|
690
|
+
* command's timeout plus 30 seconds, up to `sandboxes.timeout_max`.
|
|
691
|
+
*
|
|
692
|
+
* A child's non-zero exit is a result, not a failure of the swarm. The swarm `succeeded` once every child's
|
|
693
|
+
* command ended (exited, timed out, or could not run) or `stop_when` was met; it `failed` only when no child
|
|
694
|
+
* could start (the fork or restore failed) or the node restarted while it ran. With
|
|
695
|
+
* `stop_when: first_success`, the first child to exit 0 is `result.winner` and the other children's commands
|
|
696
|
+
* are killed (`canceled`). Each stream of output keeps its first `output_max_bytes` bytes, in the record and
|
|
697
|
+
* in the events.
|
|
698
|
+
*
|
|
699
|
+
* After its command ends a child is deleted, unless `keep` keeps it: `succeeded` keeps the children that
|
|
700
|
+
* exited 0, `all` keeps every child. A kept child is an ordinary sandbox that runs to its own `expires_at`,
|
|
701
|
+
* counts against `sandboxes.concurrent` and is billed until you delete it.
|
|
702
|
+
*
|
|
703
|
+
* All children are reserved at once, nothing started unless every one fits: past `sandboxes.concurrent` the
|
|
704
|
+
* answer is `429 concurrency_limited` with `Retry-After`, past `sandboxes.disk_total_max` `422 limit_exceeded`.
|
|
705
|
+
* 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
|
|
706
|
+
* hold no volume (`409 volume_attached`). Creating a swarm needs `sandboxes:write` and also `sandboxes:run`.
|
|
707
|
+
* Swarms are listed for 7 days after they finish. Behind the `sandboxes.swarms` feature flag: until it is on
|
|
708
|
+
* for your organization every swarm operation answers `404 feature_not_enabled`.
|
|
709
|
+
*
|
|
710
|
+
* `POST /v1/sandboxes/swarms` · scope `sandboxes:write` · served by the node
|
|
711
|
+
*/
|
|
712
|
+
createSwarm(body: T.SwarmCreateRequest, options?: RequestOptions): JobPromise<T.Swarm, T.SwarmEvent> {
|
|
713
|
+
return this._client._job<T.Swarm, T.SwarmEvent>(createSwarmOp, { body }, options);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Get a swarm
|
|
718
|
+
*
|
|
719
|
+
* Returns the swarm with its status, progress, result, timing and every child with its exit code, output and
|
|
720
|
+
* timing. While it runs, children that have not ended show `queued` or `running`. `?wait=` holds the answer
|
|
721
|
+
* until the swarm ends or the wait runs out.
|
|
722
|
+
*
|
|
723
|
+
* `GET /v1/sandboxes/swarms/{swarm_id}` · scope `sandboxes:read` · served by the node
|
|
724
|
+
*/
|
|
725
|
+
getSwarm(swarmId: string, params?: T.SandboxesGetSwarmParams, options?: RequestOptions): APIPromise<T.Swarm> {
|
|
726
|
+
return this._client._call<T.Swarm>(getSwarmOp, { path: [swarmId], query: params }, options);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Cancel a swarm
|
|
731
|
+
*
|
|
732
|
+
* Stops the swarm: commands still running are killed and those children end `canceled`; each child is then
|
|
733
|
+
* deleted unless the swarm's `keep` keeps it (`all` keeps every child, `succeeded` the ones that exited 0).
|
|
734
|
+
* Returns the swarm with status `canceled`.
|
|
735
|
+
*
|
|
736
|
+
* `POST /v1/sandboxes/swarms/{swarm_id}/cancel` · scope `sandboxes:write` · served by the node
|
|
737
|
+
*/
|
|
738
|
+
cancelSwarm(swarmId: string, options?: RequestOptions): APIPromise<T.Swarm> {
|
|
739
|
+
return this._client._call<T.Swarm>(cancelSwarmOp, { path: [swarmId] }, options);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* List a swarm's children
|
|
744
|
+
*
|
|
745
|
+
* Lists the swarm's children by index, with each child's exit code, output and timing. Available while the swarm runs.
|
|
746
|
+
*
|
|
747
|
+
* `GET /v1/sandboxes/swarms/{swarm_id}/children` · scope `sandboxes:read` · served by the node
|
|
748
|
+
*/
|
|
749
|
+
listSwarmChildren(
|
|
750
|
+
swarmId: string,
|
|
751
|
+
params?: T.SandboxesListSwarmChildrenParams,
|
|
752
|
+
options?: RequestOptions,
|
|
753
|
+
): ListPromise<T.SwarmChildList, T.SwarmChild> {
|
|
754
|
+
return this._client._list<T.SwarmChildList, T.SwarmChild>(
|
|
755
|
+
listSwarmChildrenOp,
|
|
756
|
+
{ path: [swarmId], query: params },
|
|
757
|
+
options,
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Stream a swarm's events
|
|
763
|
+
*
|
|
764
|
+
* Server-sent events for the swarm: lifecycle events, `swarm.forked` with each child's sandbox ID, then
|
|
765
|
+
* `child.started`, `child.exited` or `child.failed` per child, and `child.stdout` and `child.stderr` when the
|
|
766
|
+
* swarm was created with `stream_output: true`. Ends after the terminal event. Reconnect with `Last-Event-ID`
|
|
767
|
+
* to resume. Events are kept with the swarm, so the stream reads the same, with the same `seq`, after the node
|
|
768
|
+
* restarts.
|
|
769
|
+
*
|
|
770
|
+
* `GET /v1/sandboxes/swarms/{swarm_id}/events` · scope `sandboxes:read` · served by the node
|
|
771
|
+
*/
|
|
772
|
+
swarmEvents(swarmId: string, options?: StreamOptions): EventStream<T.SwarmEvent> {
|
|
773
|
+
return this._client._stream<T.SwarmEvent>(swarmEventsOp, { path: [swarmId] }, options, {
|
|
774
|
+
terminal: isTerminalJobEvent,
|
|
775
|
+
reconnectOnEnd: true,
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
|
|
501
779
|
/**
|
|
502
780
|
* List templates
|
|
503
781
|
*
|
|
504
782
|
* Lists the templates sandboxes can start from (`base`, `code-interpreter`, `agent`, and `browser` where a node
|
|
505
783
|
* builds it, which the beta node does not yet: Chrome already running in the snapshot, a VM-isolated browser
|
|
506
784
|
* with DevTools on port 9222) with their OS, runtimes, capabilities, defaults and `size_classes` (the sizes kept
|
|
507
|
-
* pre-warmed). It does not list a template's packages.
|
|
785
|
+
* pre-warmed). It does not list a template's packages. The node's templates have `owner: node`; your project's
|
|
786
|
+
* imported images add their templates with `owner: project` and `image` set (`POST /v1/images`). Other
|
|
787
|
+
* projects' image templates are never listed, and getting one answers `404 template_not_found`.
|
|
508
788
|
*
|
|
509
789
|
* `GET /v1/sandboxes/templates` · scope `sandboxes:read` · served by the node
|
|
510
790
|
*/
|
|
@@ -515,7 +795,7 @@ export class SandboxesAPI extends Namespace {
|
|
|
515
795
|
/**
|
|
516
796
|
* Get a template
|
|
517
797
|
*
|
|
518
|
-
* Returns one template by name (`base`) or ID (`tpl_…`).
|
|
798
|
+
* 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`.
|
|
519
799
|
*
|
|
520
800
|
* `GET /v1/sandboxes/templates/{template}` · scope `sandboxes:read` · served by the node
|
|
521
801
|
*/
|
|
@@ -523,6 +803,94 @@ export class SandboxesAPI extends Namespace {
|
|
|
523
803
|
return this._client._call<T.Template>(getTemplateOp, { path: [template] }, options);
|
|
524
804
|
}
|
|
525
805
|
|
|
806
|
+
/**
|
|
807
|
+
* List volumes
|
|
808
|
+
*
|
|
809
|
+
* Lists the project's volumes on this node, newest first. Deleted volumes are listed only with `status=deleted`.
|
|
810
|
+
*
|
|
811
|
+
* `GET /v1/sandboxes/volumes` · scope `sandboxes:read` · served by the node
|
|
812
|
+
*/
|
|
813
|
+
listVolumes(params?: T.SandboxesListVolumesParams, options?: RequestOptions): ListPromise<T.VolumeList, T.Volume> {
|
|
814
|
+
return this._client._list<T.VolumeList, T.Volume>(listVolumesOp, { query: params }, options);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Create a volume
|
|
819
|
+
*
|
|
820
|
+
* Creates an ext4 volume of `size_gib` on this node: data that outlives the sandboxes that mount it. Mount it
|
|
821
|
+
* in a sandbox with `volumes` on `POST /v1/sandboxes`; it is held by one running or paused sandbox at a time.
|
|
822
|
+
* Its blocks are allocated at once and reserved on the node's disk, so a full node disk cannot fail a write to
|
|
823
|
+
* it. Bills `sandboxes.volume_gib_h` (its size times the hours it exists, mounted or not) until it is deleted.
|
|
824
|
+
*
|
|
825
|
+
* In this beta a volume is one copy on the node's one drive: there is no backup, and it is not encrypted at
|
|
826
|
+
* rest, like every sandbox disk. Have the code that writes to it fsync what matters: what an app wrote and did
|
|
827
|
+
* not flush when its sandbox's microVM stopped without warning is lost.
|
|
828
|
+
*
|
|
829
|
+
* `POST /v1/sandboxes/volumes` · scope `sandboxes:write` · served by the node
|
|
830
|
+
*/
|
|
831
|
+
createVolume(body: T.VolumeCreateRequest, options?: RequestOptions): APIPromise<T.Volume> {
|
|
832
|
+
return this._client._call<T.Volume>(createVolumeOp, { body }, options);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Delete a volume
|
|
837
|
+
*
|
|
838
|
+
* Marks the volume deleted: it is no longer listed or mounted, stops billing, and is purged (its data gone) at
|
|
839
|
+
* `purge_at`, 7 days later, unless you restore it first. Refused while a sandbox holds it (`409
|
|
840
|
+
* volume_attached`). Nothing else deletes a volume.
|
|
841
|
+
*
|
|
842
|
+
* `DELETE /v1/sandboxes/volumes/{volume_id}` · scope `sandboxes:write` · served by the node
|
|
843
|
+
*/
|
|
844
|
+
deleteVolume(volumeId: string, options?: RequestOptions): APIPromise<T.Volume> {
|
|
845
|
+
return this._client._call<T.Volume>(deleteVolumeOp, { path: [volumeId] }, options);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Get a volume
|
|
850
|
+
*
|
|
851
|
+
* Returns a volume, deleted ones in their grace included.
|
|
852
|
+
*
|
|
853
|
+
* `GET /v1/sandboxes/volumes/{volume_id}` · scope `sandboxes:read` · served by the node
|
|
854
|
+
*/
|
|
855
|
+
getVolume(volumeId: string, options?: RequestOptions): APIPromise<T.Volume> {
|
|
856
|
+
return this._client._call<T.Volume>(getVolumeOp, { path: [volumeId] }, options);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Grow a volume or change its metadata
|
|
861
|
+
*
|
|
862
|
+
* Replaces `metadata`, and grows the volume to `size_gib`. A volume grows only, and only while no sandbox
|
|
863
|
+
* holds it (`409 volume_attached`): its file system grows to the new size the next time a sandbox mounts it.
|
|
864
|
+
*
|
|
865
|
+
* `PATCH /v1/sandboxes/volumes/{volume_id}` · scope `sandboxes:write` · served by the node
|
|
866
|
+
*/
|
|
867
|
+
updateVolume(volumeId: string, body?: T.VolumeUpdateRequest, options?: RequestOptions): APIPromise<T.Volume> {
|
|
868
|
+
return this._client._call<T.Volume>(updateVolumeOp, { path: [volumeId], body }, options);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Purge a volume now
|
|
873
|
+
*
|
|
874
|
+
* Removes the volume and its data now, deleted or not, without waiting for `purge_at`. `confirm` must be the
|
|
875
|
+
* volume's name. Refused while a sandbox holds it (`409 volume_attached`). This cannot be undone.
|
|
876
|
+
*
|
|
877
|
+
* `POST /v1/sandboxes/volumes/{volume_id}/purge` · scope `sandboxes:write` · served by the node
|
|
878
|
+
*/
|
|
879
|
+
purgeVolume(volumeId: string, body: T.VolumePurgeRequest, options?: RequestOptions): APIPromise<T.Deleted> {
|
|
880
|
+
return this._client._call<T.Deleted>(purgeVolumeOp, { path: [volumeId], body }, options);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Restore a deleted volume
|
|
885
|
+
*
|
|
886
|
+
* 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.
|
|
887
|
+
*
|
|
888
|
+
* `POST /v1/sandboxes/volumes/{volume_id}/restore` · scope `sandboxes:write` · served by the node
|
|
889
|
+
*/
|
|
890
|
+
restoreVolume(volumeId: string, options?: RequestOptions): APIPromise<T.Volume> {
|
|
891
|
+
return this._client._call<T.Volume>(restoreVolumeOp, { path: [volumeId] }, options);
|
|
892
|
+
}
|
|
893
|
+
|
|
526
894
|
/**
|
|
527
895
|
* Delete a sandbox
|
|
528
896
|
*
|
|
@@ -581,6 +949,24 @@ export class SandboxesAPI extends Namespace {
|
|
|
581
949
|
* one delivers the events queued before the cut and then ends with an `exec.exit` event whose `error` has
|
|
582
950
|
* `code: forbidden` and `reason: egress_escalation` and whose `duration_ms` runs to the cut.
|
|
583
951
|
*
|
|
952
|
+
* With `background: true` and `restart`, the node supervises the process and starts the same command again in
|
|
953
|
+
* the same sandbox when it exits: `on-failure` after an exit with a non-zero code or by a signal, `always` after
|
|
954
|
+
* 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
|
|
955
|
+
* run of at least 60 s resets the wait. Five exits within 300 s put the process in `crash_loop`: the node goes
|
|
956
|
+
* on starting it, at most 60 s apart, for as long as the sandbox runs (a dependency that comes back heals it),
|
|
957
|
+
* and a run of 60 s ends `crash_loop`. When the node restarts the process it first kills what is left of its process
|
|
958
|
+
* group, for an exit it saw within 60 s of last seeing the process alive and while the pid is still that
|
|
959
|
+
* process's (after a restart of the node itself it leaves the group alone and only starts the command again). A
|
|
960
|
+
* signal sent from inside the sandbox (`kill -9`, `pkill`) counts as an exit and is restarted; a signal sent
|
|
961
|
+
* with `POST …/processes/{pid}/kill` stops the supervision unless it asks to restart. The sandbox's
|
|
962
|
+
* `supervised` list shows each supervised process: its current `pid`, `state`, `restarts` and `last_exit`.
|
|
963
|
+
* A sandbox supervises at most 8 processes; a ninth `restart` is `400 invalid_request`, as is `restart`
|
|
964
|
+
* without `background` or with `stdin`. The command, `cwd`, `env` and `user` are kept with the sandbox's
|
|
965
|
+
* record on the node's disk for its restarts: pass secrets with the create's `secrets`, not on the command
|
|
966
|
+
* line or in `env`. A fork, or a sandbox restored from a snapshot, supervises nothing: the processes it took
|
|
967
|
+
* over run on unsupervised. Restarts pause while the node's own service restarts; a process that exited
|
|
968
|
+
* then is started again once it is back.
|
|
969
|
+
*
|
|
584
970
|
* `cmd` as a string runs through `/bin/sh -c`; as an array it is executed directly. Output is UTF-8 (invalid
|
|
585
971
|
* bytes become U+FFFD) and each stream is capped at 1 MiB in a buffered response.
|
|
586
972
|
*
|
|
@@ -753,7 +1139,8 @@ export class SandboxesAPI extends Namespace {
|
|
|
753
1139
|
* `forkable: true` (forkable sandboxes are restored for themselves rather than claimed from a pool, and track
|
|
754
1140
|
* the pages they change); forks are forkable too. The source pauses while its changed memory is written
|
|
755
1141
|
* (`pause`, `base`, `snapshot`, `export` phases in `Server-Timing`), then runs on; like a snapshot this resets
|
|
756
|
-
* its open connections to the outside.
|
|
1142
|
+
* its open connections to the outside. A paused source is resumed for the fork and paused again (`resume`
|
|
1143
|
+
* and `repause` phases), so a checkpoint can wait paused, billing neither meter, between forks.
|
|
757
1144
|
* Each fork counts against your sandbox concurrency and, with the source's `disk_gib`, against
|
|
758
1145
|
* `sandboxes.disk_total_max` (`422 limit_exceeded`). While the node's snapshot or disk store is nearly full,
|
|
759
1146
|
* forks are refused with `503 capacity_unavailable`.
|
|
@@ -764,6 +1151,62 @@ export class SandboxesAPI extends Namespace {
|
|
|
764
1151
|
return this._client._call<T.SandboxList>(forkSandboxOp, { path: [sandboxId], body }, options);
|
|
765
1152
|
}
|
|
766
1153
|
|
|
1154
|
+
/**
|
|
1155
|
+
* Release a sandbox's lease
|
|
1156
|
+
*
|
|
1157
|
+
* Ends the sandbox's lease (`end_reason: released`). The sandbox keeps running until its current `expires_at`,
|
|
1158
|
+
* which you can still move with `POST /v1/sandboxes/{sandbox_id}/timeout`. Releasing a sandbox that holds no
|
|
1159
|
+
* lease, or one that has stopped, changes nothing and answers the sandbox. A sandbox's own credential cannot
|
|
1160
|
+
* release a lease (`403 forbidden`, `reason: sandbox`).
|
|
1161
|
+
*
|
|
1162
|
+
* `DELETE /v1/sandboxes/{sandbox_id}/lease` · scope `sandboxes:write` · served by the node
|
|
1163
|
+
*/
|
|
1164
|
+
releaseLease(sandboxId: string, options?: RequestOptions): APIPromise<T.Sandbox> {
|
|
1165
|
+
return this._client._call<T.Sandbox>(releaseLeaseOp, { path: [sandboxId] }, options);
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Keep a sandbox running under a lease
|
|
1170
|
+
*
|
|
1171
|
+
* Holds a lease on the sandbox under `key`, a name of your choosing (the deploy engine uses
|
|
1172
|
+
* `b3os:<app>/<service>`). While the lease is held and the sandbox runs, the node keeps it running past its
|
|
1173
|
+
* `timeout_s` and past `sandboxes.timeout_max`: whenever less than half of `sandboxes.lease_term` (900 s) is
|
|
1174
|
+
* left before `expires_at`, the node moves `expires_at` to `lease_term` from now. Nothing outside the node has
|
|
1175
|
+
* to renew it.
|
|
1176
|
+
*
|
|
1177
|
+
* One live sandbox in a project holds a key at a time. Holding a key on this sandbox takes it from the sandbox
|
|
1178
|
+
* that held it: that lease ends (`end_reason: replaced`) and that sandbox's `expires_at` moves to at most
|
|
1179
|
+
* `lease_term` from now, so it stops by then unless something extends it. A sandbox holds one lease; a call
|
|
1180
|
+
* with another key changes the key it holds. A call with the key it already holds changes nothing.
|
|
1181
|
+
*
|
|
1182
|
+
* `expect_holder` makes the call conditional on what you read: the sandbox you saw holding `key`, or `null` when
|
|
1183
|
+
* you saw none. The node takes the key only while that is still so; otherwise it answers `409
|
|
1184
|
+
* lease_holder_changed` with the sandbox that holds it now (`holder`), and changes nothing. A caller that read an
|
|
1185
|
+
* older state (a check that read the generation before a deploy handed the key to a newer one) then never takes
|
|
1186
|
+
* the key back from the sandbox that got it since. Without `expect_holder` the call takes the key from whichever
|
|
1187
|
+
* sandbox holds it.
|
|
1188
|
+
*
|
|
1189
|
+
* The lease ends when you release it (`DELETE …/lease`, `end_reason: released`; the sandbox then runs out its
|
|
1190
|
+
* current `expires_at`) and when the sandbox stops for any reason (`end_reason` is its `stop_reason`:
|
|
1191
|
+
* `deleted`, `timeout`, `failed`, `budget`, `revoked`). A paused sandbox is not renewed: it ends at
|
|
1192
|
+
* `expires_at` like any paused sandbox. An organization holds at most `sandboxes.leases_max` (5) leases on a
|
|
1193
|
+
* node; one more is `422 limit_exceeded`, and lowering the limit ends none already held. A sandbox's own
|
|
1194
|
+
* credential (the one its in-VM API holds) cannot hold or release a lease (`403 forbidden`, `reason: sandbox`),
|
|
1195
|
+
* so code can never keep its own sandbox, or another, running with it. A real API key you put into a sandbox (in
|
|
1196
|
+
* its `env` or `secrets`) is not the sandbox's own credential: code holding it can hold a lease as any caller
|
|
1197
|
+
* can, within `sandboxes.leases_max` and the organization's credits and spend caps.
|
|
1198
|
+
*
|
|
1199
|
+
* A leased sandbox is billed like any running one (`sandboxes.vcpu_ms`, `sandboxes.gib_ms`), so the call is
|
|
1200
|
+
* admitted like a create (credits, spend cap). The node checks a running sandbox's budget every 10 s and stops
|
|
1201
|
+
* a leased one, ending its lease, as it stops any other (`stop_reason: budget` or `revoked`; a project's service
|
|
1202
|
+
* never stops for its key's revoke or expiry, so not `revoked`).
|
|
1203
|
+
*
|
|
1204
|
+
* `PUT /v1/sandboxes/{sandbox_id}/lease` · scope `sandboxes:write` · served by the node
|
|
1205
|
+
*/
|
|
1206
|
+
holdLease(sandboxId: string, body: T.LeaseRequest, options?: RequestOptions): APIPromise<T.Sandbox> {
|
|
1207
|
+
return this._client._call<T.Sandbox>(holdLeaseOp, { path: [sandboxId], body }, options);
|
|
1208
|
+
}
|
|
1209
|
+
|
|
767
1210
|
/**
|
|
768
1211
|
* Stream process logs
|
|
769
1212
|
*
|
|
@@ -809,6 +1252,44 @@ export class SandboxesAPI extends Namespace {
|
|
|
809
1252
|
return this._client._call<T.Sandbox>(pauseSandboxOp, { path: [sandboxId] }, options);
|
|
810
1253
|
}
|
|
811
1254
|
|
|
1255
|
+
/**
|
|
1256
|
+
* Give a sandbox port its own host
|
|
1257
|
+
*
|
|
1258
|
+
* Gives `port` of the sandbox its own host, `https://<port>-sbx-<id>.b3os.io` (`<id>` is the sandbox ID without
|
|
1259
|
+
* `sbx_`), and returns a link to it. The app is served at `/` and keeps its cookies, as an application's
|
|
1260
|
+
* address does: it gets the request's whole path with no prefix, `Host` is the host, and the cookies it sets
|
|
1261
|
+
* stay on this host (`cookies`, `isolated` by default: the same rules as app addresses). Use it for apps that
|
|
1262
|
+
* need the root path or sign-in cookies. `POST /v1/sandboxes/{sandbox_id}/ports/{port}/url` keeps working as
|
|
1263
|
+
* before.
|
|
1264
|
+
*
|
|
1265
|
+
* Shared by link only, never public. The link (`url`) works for `ttl_s` seconds (10 minutes by default, at
|
|
1266
|
+
* most 24 hours); its first page load sets a cookie that keeps that browser in for 24 hours, and a program can
|
|
1267
|
+
* send the link's `b3os_link` value in `x-b3os-link` instead. Anyone else gets a 401 page, the same whether or
|
|
1268
|
+
* not the sandbox or the host exists. Each call returns a new link and leaves earlier ones working; `rotate:
|
|
1269
|
+
* true` first replaces the host's secret, so every earlier link and cookie of this host stops working within 6
|
|
1270
|
+
* seconds. `cookies` sets the host's cookie rule; left out, the host keeps the one it has.
|
|
1271
|
+
*
|
|
1272
|
+
* The port must be in the sandbox's `ports` and the sandbox running or paused (404 `port_not_exposed`, 409
|
|
1273
|
+
* `sandbox_not_running`, and 404 `sandbox_not_found` for a sandbox of another project). While the sandbox is
|
|
1274
|
+
* paused or stopped its host answers 503. The host is that sandbox's and port's for good and ends with the
|
|
1275
|
+
* sandbox; a fork or a restore has a new ID, so new hosts. A host with no call for 49 hours is forgotten: the
|
|
1276
|
+
* next call makes it again with a new secret. A dev server must accept the host (for Vite,
|
|
1277
|
+
* `server.allowedHosts: ['.b3os.io']`). Not yet available to code inside a sandbox (its API answers 421
|
|
1278
|
+
* `edge_only`). Port 49983 is kept for E2B's envd and gets no host (400). Hosts count toward no address limit.
|
|
1279
|
+
* B3 can block a sandbox's hosts (403 `app_host_blocked`). An organization may call this 60 times a minute
|
|
1280
|
+
* (429 `rate_limited` with `Retry-After` past that).
|
|
1281
|
+
*
|
|
1282
|
+
* `POST /v1/sandboxes/{sandbox_id}/ports/{port}/host` · scope `sandboxes:run` · served by beta-api.b3os.org
|
|
1283
|
+
*/
|
|
1284
|
+
createPortHost(
|
|
1285
|
+
sandboxId: string,
|
|
1286
|
+
port: number,
|
|
1287
|
+
body?: T.PortHostRequest,
|
|
1288
|
+
options?: RequestOptions,
|
|
1289
|
+
): APIPromise<T.PortHost> {
|
|
1290
|
+
return this._client._call<T.PortHost>(createPortHostOp, { path: [sandboxId, port], body }, options);
|
|
1291
|
+
}
|
|
1292
|
+
|
|
812
1293
|
/**
|
|
813
1294
|
* Get a URL for a port
|
|
814
1295
|
*
|
|
@@ -856,7 +1337,10 @@ export class SandboxesAPI extends Namespace {
|
|
|
856
1337
|
/**
|
|
857
1338
|
* Signal a background process
|
|
858
1339
|
*
|
|
859
|
-
* Sends a signal (default `TERM`) to a background process and its process group, and returns the process.
|
|
1340
|
+
* Sends a signal (default `TERM`) to a background process and its process group, and returns the process. On a
|
|
1341
|
+
* process the node supervises (an exec with `restart`), the call first ends the supervision (`state: stopped`
|
|
1342
|
+
* in the sandbox's `supervised`), so the process stays down; with `restart: true` it stays supervised and the
|
|
1343
|
+
* node starts it again once it exits, counted as a restart.
|
|
860
1344
|
*
|
|
861
1345
|
* `POST /v1/sandboxes/{sandbox_id}/processes/{pid}/kill` · scope `sandboxes:run` · served by the node
|
|
862
1346
|
*/
|
|
@@ -942,8 +1426,9 @@ export class SandboxesAPI extends Namespace {
|
|
|
942
1426
|
* searches and calls to other sandboxes), newest first, from the node's request log. These are the records
|
|
943
1427
|
* `GET /v1/requests?sandbox_id=` lists, for a caller that may read the sandbox: it needs only `sandboxes:read`,
|
|
944
1428
|
* not `platform:read`, and never returns another sandbox's records. It takes the same paging and the
|
|
945
|
-
* `product`, `operation_id`, `status`, `trace_id` and `
|
|
946
|
-
* `400 invalid_request`.
|
|
1429
|
+
* `product`, `operation_id`, `status`, `trace_id`, `since` and `pack` filters; any other query parameter is
|
|
1430
|
+
* `400 invalid_request`. `pack=io.b3os/wikipedia` lists the sandbox's calls of that pack's actions, through
|
|
1431
|
+
* `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
|
|
947
1432
|
* than 7 days ago is not found.
|
|
948
1433
|
*
|
|
949
1434
|
* `GET /v1/sandboxes/{sandbox_id}/requests` · scope `sandboxes:read` · served by the node
|
|
@@ -43,7 +43,7 @@ export class UsageAPI extends Namespace {
|
|
|
43
43
|
/**
|
|
44
44
|
* List usage records
|
|
45
45
|
*
|
|
46
|
-
* Lists individual usage records as nodes reported them, newest first, filterable by product, unit, key and request.
|
|
46
|
+
* Lists individual usage records as nodes reported them, newest first, filterable by product, unit, key, sandbox and request.
|
|
47
47
|
*
|
|
48
48
|
* `GET /v1/usage/records` · scope `platform:read` · served by beta-api.b3os.org
|
|
49
49
|
*/
|