@b3os/sdk 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/core/util.d.ts +1 -1
- package/dist/cjs/core/util.js +1 -1
- package/dist/cjs/generated/client.d.ts +18 -0
- package/dist/cjs/generated/client.js +34 -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 +120 -0
- package/dist/cjs/generated/errors.js.map +1 -1
- package/dist/cjs/generated/ids.d.ts +89 -0
- package/dist/cjs/generated/ids.js +22 -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 +656 -0
- package/dist/cjs/generated/ns/agents.js +989 -0
- package/dist/cjs/generated/ns/agents.js.map +1 -0
- package/dist/cjs/generated/ns/images.d.ts +162 -0
- package/dist/cjs/generated/ns/images.js +246 -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 +163 -0
- package/dist/cjs/generated/ns/listeners.js +268 -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 +22 -4
- package/dist/cjs/generated/ns/routines.js +22 -4
- package/dist/cjs/generated/ns/routines.js.map +1 -1
- package/dist/cjs/generated/ns/sandboxes.d.ts +431 -7
- package/dist/cjs/generated/ns/sandboxes.js +633 -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 +113 -17
- package/dist/cjs/generated/ns/vision.js +152 -21
- package/dist/cjs/generated/ns/vision.js.map +1 -1
- package/dist/cjs/generated/ns/workspaces.d.ts +225 -0
- package/dist/cjs/generated/ns/workspaces.js +410 -0
- package/dist/cjs/generated/ns/workspaces.js.map +1 -0
- package/dist/cjs/generated/types.d.ts +5259 -605
- 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 +18 -0
- package/dist/esm/generated/client.js +34 -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 +120 -0
- package/dist/esm/generated/errors.js.map +1 -1
- package/dist/esm/generated/ids.d.ts +89 -0
- package/dist/esm/generated/ids.js +22 -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 +656 -0
- package/dist/esm/generated/ns/agents.js +985 -0
- package/dist/esm/generated/ns/agents.js.map +1 -0
- package/dist/esm/generated/ns/images.d.ts +162 -0
- package/dist/esm/generated/ns/images.js +242 -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 +163 -0
- package/dist/esm/generated/ns/listeners.js +264 -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 +22 -4
- package/dist/esm/generated/ns/routines.js +22 -4
- package/dist/esm/generated/ns/routines.js.map +1 -1
- package/dist/esm/generated/ns/sandboxes.d.ts +431 -7
- package/dist/esm/generated/ns/sandboxes.js +633 -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 +113 -17
- package/dist/esm/generated/ns/vision.js +152 -21
- package/dist/esm/generated/ns/vision.js.map +1 -1
- package/dist/esm/generated/ns/workspaces.d.ts +225 -0
- package/dist/esm/generated/ns/workspaces.js +406 -0
- package/dist/esm/generated/ns/workspaces.js.map +1 -0
- package/dist/esm/generated/types.d.ts +5259 -605
- 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 +38 -0
- package/src/generated/errors.ts +240 -0
- package/src/generated/ids.ts +22 -0
- package/src/generated/jobs.ts +4 -0
- package/src/generated/ns/actions.ts +403 -33
- package/src/generated/ns/agents.ts +1102 -0
- package/src/generated/ns/images.ts +256 -0
- package/src/generated/ns/infer.ts +100 -3
- package/src/generated/ns/keys.ts +3 -1
- package/src/generated/ns/listeners.ts +300 -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 +22 -4
- package/src/generated/ns/sandboxes.ts +694 -7
- package/src/generated/ns/usage.ts +1 -1
- package/src/generated/ns/vision.ts +159 -21
- package/src/generated/ns/workspaces.ts +448 -0
- package/src/generated/types.ts +5684 -601
- package/src/helpers/sandboxes.ts +31 -2
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Generated by packages/sdk/scripts/generate.mjs from packages/spec/dist. Do not edit; run `pnpm generate`.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.SandboxesAPI = exports.sandboxesOps = void 0;
|
|
5
|
+
const jobs_ts_1 = require("../../core/jobs.js");
|
|
5
6
|
const namespace_ts_1 = require("../../core/namespace.js");
|
|
6
7
|
const ws_ts_1 = require("../../core/ws.js");
|
|
7
8
|
const agents_ts_1 = require("../../helpers/agents.js");
|
|
@@ -23,6 +24,13 @@ const createSandboxOp = {
|
|
|
23
24
|
timeoutMs: 30000,
|
|
24
25
|
scope: "sandboxes:write",
|
|
25
26
|
};
|
|
27
|
+
const getCapacityOp = {
|
|
28
|
+
id: "sandboxesGetCapacity",
|
|
29
|
+
method: "GET",
|
|
30
|
+
path: "/v1/sandboxes/capacity",
|
|
31
|
+
timeoutMs: 10000,
|
|
32
|
+
scope: "sandboxes:read",
|
|
33
|
+
};
|
|
26
34
|
const listSnapshotsOp = {
|
|
27
35
|
id: "sandboxesListSnapshots",
|
|
28
36
|
method: "GET",
|
|
@@ -46,6 +54,46 @@ const getSnapshotOp = {
|
|
|
46
54
|
timeoutMs: 10000,
|
|
47
55
|
scope: "sandboxes:read",
|
|
48
56
|
};
|
|
57
|
+
const listSwarmsOp = {
|
|
58
|
+
id: "sandboxesListSwarms",
|
|
59
|
+
method: "GET",
|
|
60
|
+
path: "/v1/sandboxes/swarms",
|
|
61
|
+
timeoutMs: 10000,
|
|
62
|
+
scope: "sandboxes:read",
|
|
63
|
+
};
|
|
64
|
+
const getSwarmOp = {
|
|
65
|
+
id: "sandboxesGetSwarm",
|
|
66
|
+
method: "GET",
|
|
67
|
+
path: "/v1/sandboxes/swarms/{swarm_id}",
|
|
68
|
+
params: ["swarm_id"],
|
|
69
|
+
timeoutMs: 65000,
|
|
70
|
+
scope: "sandboxes:read",
|
|
71
|
+
};
|
|
72
|
+
const cancelSwarmOp = {
|
|
73
|
+
id: "sandboxesCancelSwarm",
|
|
74
|
+
method: "POST",
|
|
75
|
+
path: "/v1/sandboxes/swarms/{swarm_id}/cancel",
|
|
76
|
+
params: ["swarm_id"],
|
|
77
|
+
timeoutMs: 10000,
|
|
78
|
+
scope: "sandboxes:write",
|
|
79
|
+
};
|
|
80
|
+
const listSwarmChildrenOp = {
|
|
81
|
+
id: "sandboxesListSwarmChildren",
|
|
82
|
+
method: "GET",
|
|
83
|
+
path: "/v1/sandboxes/swarms/{swarm_id}/children",
|
|
84
|
+
params: ["swarm_id"],
|
|
85
|
+
timeoutMs: 10000,
|
|
86
|
+
scope: "sandboxes:read",
|
|
87
|
+
};
|
|
88
|
+
const swarmEventsOp = {
|
|
89
|
+
id: "sandboxesSwarmEvents",
|
|
90
|
+
method: "GET",
|
|
91
|
+
path: "/v1/sandboxes/swarms/{swarm_id}/events",
|
|
92
|
+
params: ["swarm_id"],
|
|
93
|
+
stream: "sse",
|
|
94
|
+
timeoutMs: 3600000,
|
|
95
|
+
scope: "sandboxes:read",
|
|
96
|
+
};
|
|
49
97
|
const listTemplatesOp = {
|
|
50
98
|
id: "sandboxesListTemplates",
|
|
51
99
|
method: "GET",
|
|
@@ -53,6 +101,14 @@ const listTemplatesOp = {
|
|
|
53
101
|
timeoutMs: 10000,
|
|
54
102
|
scope: "sandboxes:read",
|
|
55
103
|
};
|
|
104
|
+
const createTemplateOp = {
|
|
105
|
+
id: "sandboxesCreateTemplate",
|
|
106
|
+
method: "POST",
|
|
107
|
+
path: "/v1/sandboxes/templates",
|
|
108
|
+
body: "json",
|
|
109
|
+
timeoutMs: 30000,
|
|
110
|
+
scope: "sandboxes:write",
|
|
111
|
+
};
|
|
56
112
|
const getTemplateOp = {
|
|
57
113
|
id: "sandboxesGetTemplate",
|
|
58
114
|
method: "GET",
|
|
@@ -61,6 +117,63 @@ const getTemplateOp = {
|
|
|
61
117
|
timeoutMs: 10000,
|
|
62
118
|
scope: "sandboxes:read",
|
|
63
119
|
};
|
|
120
|
+
const listVolumesOp = {
|
|
121
|
+
id: "sandboxesListVolumes",
|
|
122
|
+
method: "GET",
|
|
123
|
+
path: "/v1/sandboxes/volumes",
|
|
124
|
+
timeoutMs: 10000,
|
|
125
|
+
scope: "sandboxes:read",
|
|
126
|
+
};
|
|
127
|
+
const createVolumeOp = {
|
|
128
|
+
id: "sandboxesCreateVolume",
|
|
129
|
+
method: "POST",
|
|
130
|
+
path: "/v1/sandboxes/volumes",
|
|
131
|
+
body: "json",
|
|
132
|
+
timeoutMs: 30000,
|
|
133
|
+
scope: "sandboxes:write",
|
|
134
|
+
};
|
|
135
|
+
const deleteVolumeOp = {
|
|
136
|
+
id: "sandboxesDeleteVolume",
|
|
137
|
+
method: "DELETE",
|
|
138
|
+
path: "/v1/sandboxes/volumes/{volume_id}",
|
|
139
|
+
params: ["volume_id"],
|
|
140
|
+
timeoutMs: 10000,
|
|
141
|
+
scope: "sandboxes:write",
|
|
142
|
+
};
|
|
143
|
+
const getVolumeOp = {
|
|
144
|
+
id: "sandboxesGetVolume",
|
|
145
|
+
method: "GET",
|
|
146
|
+
path: "/v1/sandboxes/volumes/{volume_id}",
|
|
147
|
+
params: ["volume_id"],
|
|
148
|
+
timeoutMs: 10000,
|
|
149
|
+
scope: "sandboxes:read",
|
|
150
|
+
};
|
|
151
|
+
const updateVolumeOp = {
|
|
152
|
+
id: "sandboxesUpdateVolume",
|
|
153
|
+
method: "PATCH",
|
|
154
|
+
path: "/v1/sandboxes/volumes/{volume_id}",
|
|
155
|
+
params: ["volume_id"],
|
|
156
|
+
body: "json",
|
|
157
|
+
timeoutMs: 30000,
|
|
158
|
+
scope: "sandboxes:write",
|
|
159
|
+
};
|
|
160
|
+
const purgeVolumeOp = {
|
|
161
|
+
id: "sandboxesPurgeVolume",
|
|
162
|
+
method: "POST",
|
|
163
|
+
path: "/v1/sandboxes/volumes/{volume_id}/purge",
|
|
164
|
+
params: ["volume_id"],
|
|
165
|
+
body: "json",
|
|
166
|
+
timeoutMs: 30000,
|
|
167
|
+
scope: "sandboxes:write",
|
|
168
|
+
};
|
|
169
|
+
const restoreVolumeOp = {
|
|
170
|
+
id: "sandboxesRestoreVolume",
|
|
171
|
+
method: "POST",
|
|
172
|
+
path: "/v1/sandboxes/volumes/{volume_id}/restore",
|
|
173
|
+
params: ["volume_id"],
|
|
174
|
+
timeoutMs: 10000,
|
|
175
|
+
scope: "sandboxes:write",
|
|
176
|
+
};
|
|
64
177
|
const deleteSandboxOp = {
|
|
65
178
|
id: "sandboxesDeleteSandbox",
|
|
66
179
|
method: "DELETE",
|
|
@@ -77,6 +190,31 @@ const getSandboxOp = {
|
|
|
77
190
|
timeoutMs: 10000,
|
|
78
191
|
scope: "sandboxes:read",
|
|
79
192
|
};
|
|
193
|
+
const getComputerOp = {
|
|
194
|
+
id: "sandboxesGetComputer",
|
|
195
|
+
method: "GET",
|
|
196
|
+
path: "/v1/sandboxes/{sandbox_id}/computer",
|
|
197
|
+
params: ["sandbox_id"],
|
|
198
|
+
timeoutMs: 15000,
|
|
199
|
+
scope: "sandboxes:read",
|
|
200
|
+
};
|
|
201
|
+
const computerActOp = {
|
|
202
|
+
id: "sandboxesComputerAct",
|
|
203
|
+
method: "POST",
|
|
204
|
+
path: "/v1/sandboxes/{sandbox_id}/computer/actions",
|
|
205
|
+
params: ["sandbox_id"],
|
|
206
|
+
body: "json",
|
|
207
|
+
timeoutMs: 65000,
|
|
208
|
+
scope: "sandboxes:run",
|
|
209
|
+
};
|
|
210
|
+
const computerScreenshotOp = {
|
|
211
|
+
id: "sandboxesComputerScreenshot",
|
|
212
|
+
method: "GET",
|
|
213
|
+
path: "/v1/sandboxes/{sandbox_id}/computer/screenshot",
|
|
214
|
+
params: ["sandbox_id"],
|
|
215
|
+
timeoutMs: 15000,
|
|
216
|
+
scope: "sandboxes:read",
|
|
217
|
+
};
|
|
80
218
|
const setEgressOp = {
|
|
81
219
|
id: "sandboxesSetEgress",
|
|
82
220
|
method: "POST",
|
|
@@ -163,6 +301,23 @@ const forkSandboxOp = {
|
|
|
163
301
|
timeoutMs: 30000,
|
|
164
302
|
scope: "sandboxes:write",
|
|
165
303
|
};
|
|
304
|
+
const releaseLeaseOp = {
|
|
305
|
+
id: "sandboxesReleaseLease",
|
|
306
|
+
method: "DELETE",
|
|
307
|
+
path: "/v1/sandboxes/{sandbox_id}/lease",
|
|
308
|
+
params: ["sandbox_id"],
|
|
309
|
+
timeoutMs: 10000,
|
|
310
|
+
scope: "sandboxes:write",
|
|
311
|
+
};
|
|
312
|
+
const holdLeaseOp = {
|
|
313
|
+
id: "sandboxesHoldLease",
|
|
314
|
+
method: "PUT",
|
|
315
|
+
path: "/v1/sandboxes/{sandbox_id}/lease",
|
|
316
|
+
params: ["sandbox_id"],
|
|
317
|
+
body: "json",
|
|
318
|
+
timeoutMs: 10000,
|
|
319
|
+
scope: "sandboxes:write",
|
|
320
|
+
};
|
|
166
321
|
const streamLogsOp = {
|
|
167
322
|
id: "sandboxesStreamLogs",
|
|
168
323
|
method: "GET",
|
|
@@ -180,6 +335,16 @@ const pauseSandboxOp = {
|
|
|
180
335
|
timeoutMs: 10000,
|
|
181
336
|
scope: "sandboxes:write",
|
|
182
337
|
};
|
|
338
|
+
const createPortHostOp = {
|
|
339
|
+
id: "platformCreatePortHost",
|
|
340
|
+
method: "POST",
|
|
341
|
+
path: "/v1/sandboxes/{sandbox_id}/ports/{port}/host",
|
|
342
|
+
params: ["sandbox_id", "port"],
|
|
343
|
+
body: "json",
|
|
344
|
+
edge: true,
|
|
345
|
+
timeoutMs: 15000,
|
|
346
|
+
scope: "sandboxes:run",
|
|
347
|
+
};
|
|
183
348
|
const createPortUrlOp = {
|
|
184
349
|
id: "sandboxesCreatePortUrl",
|
|
185
350
|
method: "POST",
|
|
@@ -284,17 +449,46 @@ const setTimeoutOp = {
|
|
|
284
449
|
timeoutMs: 10000,
|
|
285
450
|
scope: "sandboxes:write",
|
|
286
451
|
};
|
|
452
|
+
const createSwarmOp = {
|
|
453
|
+
id: "sandboxesCreateSwarm",
|
|
454
|
+
method: "POST",
|
|
455
|
+
path: "/v1/sandboxes/swarms",
|
|
456
|
+
body: "json",
|
|
457
|
+
idem: true,
|
|
458
|
+
stream: "sse",
|
|
459
|
+
timeoutMs: 3600000,
|
|
460
|
+
scope: "sandboxes:write",
|
|
461
|
+
job: { get: getSwarmOp, events: swarmEventsOp, cancel: cancelSwarmOp },
|
|
462
|
+
};
|
|
287
463
|
/** Descriptors of every sandboxes operation, keyed by method name (for tooling and custom clients). */
|
|
288
464
|
exports.sandboxesOps = {
|
|
289
465
|
listSandboxes: listSandboxesOp,
|
|
290
466
|
createSandbox: createSandboxOp,
|
|
467
|
+
getCapacity: getCapacityOp,
|
|
291
468
|
listSnapshots: listSnapshotsOp,
|
|
292
469
|
deleteSnapshot: deleteSnapshotOp,
|
|
293
470
|
getSnapshot: getSnapshotOp,
|
|
471
|
+
listSwarms: listSwarmsOp,
|
|
472
|
+
createSwarm: createSwarmOp,
|
|
473
|
+
getSwarm: getSwarmOp,
|
|
474
|
+
cancelSwarm: cancelSwarmOp,
|
|
475
|
+
listSwarmChildren: listSwarmChildrenOp,
|
|
476
|
+
swarmEvents: swarmEventsOp,
|
|
294
477
|
listTemplates: listTemplatesOp,
|
|
478
|
+
createTemplate: createTemplateOp,
|
|
295
479
|
getTemplate: getTemplateOp,
|
|
480
|
+
listVolumes: listVolumesOp,
|
|
481
|
+
createVolume: createVolumeOp,
|
|
482
|
+
deleteVolume: deleteVolumeOp,
|
|
483
|
+
getVolume: getVolumeOp,
|
|
484
|
+
updateVolume: updateVolumeOp,
|
|
485
|
+
purgeVolume: purgeVolumeOp,
|
|
486
|
+
restoreVolume: restoreVolumeOp,
|
|
296
487
|
deleteSandbox: deleteSandboxOp,
|
|
297
488
|
getSandbox: getSandboxOp,
|
|
489
|
+
getComputer: getComputerOp,
|
|
490
|
+
computerAct: computerActOp,
|
|
491
|
+
computerScreenshot: computerScreenshotOp,
|
|
298
492
|
setEgress: setEgressOp,
|
|
299
493
|
exec: execOp,
|
|
300
494
|
deleteFile: deleteFileOp,
|
|
@@ -304,8 +498,11 @@ exports.sandboxesOps = {
|
|
|
304
498
|
moveFile: moveFileOp,
|
|
305
499
|
statFile: statFileOp,
|
|
306
500
|
forkSandbox: forkSandboxOp,
|
|
501
|
+
releaseLease: releaseLeaseOp,
|
|
502
|
+
holdLease: holdLeaseOp,
|
|
307
503
|
streamLogs: streamLogsOp,
|
|
308
504
|
pauseSandbox: pauseSandboxOp,
|
|
505
|
+
createPortHost: createPortHostOp,
|
|
309
506
|
createPortUrl: createPortUrlOp,
|
|
310
507
|
listProcesses: listProcessesOp,
|
|
311
508
|
killProcess: killProcessOp,
|
|
@@ -329,6 +526,8 @@ class SandboxesAPI extends namespace_ts_1.Namespace {
|
|
|
329
526
|
* `metadata[<key>]=<value>` (up to 4 pairs) keeps only sandboxes whose `metadata` holds every pair given, with
|
|
330
527
|
* exactly that value: `GET /v1/sandboxes?metadata[customer]=acme&metadata[ticket]=ENG-1423`. A sandbox whose
|
|
331
528
|
* create lost its answer (a dropped connection) is found this way by a tag it was created with.
|
|
529
|
+
* `owner=project&created_by_key=<key_id>` lists the services a key deployed, and `root=<sandbox_id>` the
|
|
530
|
+
* sandboxes one of them started.
|
|
332
531
|
*
|
|
333
532
|
* `GET /v1/sandboxes` · scope `sandboxes:read` · served by the node
|
|
334
533
|
*/
|
|
@@ -411,6 +610,14 @@ class SandboxesAPI extends namespace_ts_1.Namespace {
|
|
|
411
610
|
* the daemon (streamed execs, PTY sessions, log streams, port preview connections, the sandbox's outbound
|
|
412
611
|
* connections and its calls to `http://127.0.0.1:7700`) drop at the restart and can be opened again.
|
|
413
612
|
*
|
|
613
|
+
* From an image (`image: "img_…"`, `POST /v1/images`): the sandbox restores the image's warm snapshot and
|
|
614
|
+
* has the image's size; a `vcpu` or `memory_mib` other than it answers `400 invalid_request`. `image` needs the
|
|
615
|
+
* `images.import` flag on for your organization (`404 feature_not_enabled` otherwise), answers `404
|
|
616
|
+
* image_not_found` for an image of another project and `409 image_not_ready` (with `current_status`) until the
|
|
617
|
+
* image is `ready`. `template: "tpl_…"` with the image's template ID works the same way without the flag (the
|
|
618
|
+
* template exists only once an import has run). Give `image` alone: with `template` or `snapshot` it answers
|
|
619
|
+
* `400 invalid_request`.
|
|
620
|
+
*
|
|
414
621
|
* Disk: a sandbox's disk is its own copy-on-write copy of the template's (or snapshot's) disk; it is deleted
|
|
415
622
|
* when the sandbox ends and never given to another sandbox. The disks of an organization's running and paused
|
|
416
623
|
* sandboxes on a node add up to at most `sandboxes.disk_total_max` (each sandbox counting its `disk_gib`;
|
|
@@ -418,6 +625,12 @@ class SandboxesAPI extends namespace_ts_1.Namespace {
|
|
|
418
625
|
* create the concurrency limit allows); past it a create is refused with `422 limit_exceeded`. While the
|
|
419
626
|
* node's disk store is nearly full, creates are refused with `503 capacity_unavailable` and `Retry-After`.
|
|
420
627
|
*
|
|
628
|
+
* Desktops: a sandbox of a template with the `computer` capability (`desktop`) also counts against
|
|
629
|
+
* `sandboxes.desktops_concurrent`, its running and paused sandboxes of such templates (forks included); past it
|
|
630
|
+
* a create or fork is refused with `429 concurrency_limited` and `Retry-After`, as past `sandboxes.concurrent`.
|
|
631
|
+
* Its environment has `DISPLAY=:1` (the desktop's X server) unless `env` sets `DISPLAY`, so commands reach the
|
|
632
|
+
* screen. `GET /v1/sandboxes/capacity` says how many more would be created now.
|
|
633
|
+
*
|
|
421
634
|
* Returns the sandbox object (`SandboxInfo`). `create()` sends the same request and returns a `Sandbox`
|
|
422
635
|
* handle instead (`exec`, `files`, `ports`), which `await using` deletes when the scope ends.
|
|
423
636
|
*
|
|
@@ -426,6 +639,35 @@ class SandboxesAPI extends namespace_ts_1.Namespace {
|
|
|
426
639
|
createSandbox(body, options) {
|
|
427
640
|
return (0, sandboxes_ts_1.createSandboxSafely)((b, o) => this._client._call(createSandboxOp, { body: b }, o), body, options, this._client.maxRetries);
|
|
428
641
|
}
|
|
642
|
+
/**
|
|
643
|
+
* Check room for more sandboxes
|
|
644
|
+
*
|
|
645
|
+
* How many more sandboxes of one template and size your organization could create on this node now, and
|
|
646
|
+
* which limit refuses the next one. Call it before a wave of creates instead of meeting `429` or `503`
|
|
647
|
+
* answers. The default shape is the `desktop` template at its default size; name another with `template`,
|
|
648
|
+
* `vcpu` and `memory_mib`.
|
|
649
|
+
*
|
|
650
|
+
* `room` is the least of three counts. `org` is `sandboxes.concurrent`: your running and paused sandboxes
|
|
651
|
+
* (and creates in flight) against the limit; paused sandboxes count, so delete the ones you are done with
|
|
652
|
+
* rather than leave them paused. `desktops` is `sandboxes.desktops_concurrent`, the running and paused
|
|
653
|
+
* sandboxes of templates with the `computer` capability; it counts toward `room` only when the template has
|
|
654
|
+
* that capability. `node` is this node: `parked` is how many sandboxes of the shape wait warm in its pool
|
|
655
|
+
* (a create claims one without a restore), and `room` is how many sandboxes of the shape the memory left
|
|
656
|
+
* under the node's microVM memory limit holds, each counting its `memory_mib` plus the node's per-microVM
|
|
657
|
+
* overhead, or `0` while the node's disk store is too full for new sandboxes. `node.room` is `null` when the
|
|
658
|
+
* node cannot read that limit, and then it does not count toward `room`.
|
|
659
|
+
*
|
|
660
|
+
* `binding` names the limit that refuses the next create (`org_concurrency`, `desktops` or `node`) when
|
|
661
|
+
* `room` is `0`, with `retry_after_s`, and is `null` while a create would pass. The answer is a reading, not
|
|
662
|
+
* a reservation: another create can take the room first. `sandboxes.disk_total_max` is left out (its beta
|
|
663
|
+
* default never refuses a create the concurrency limit allows). Behind the `sandboxes.desktop` feature flag:
|
|
664
|
+
* until it is on for your organization the operation answers `404 feature_not_enabled`.
|
|
665
|
+
*
|
|
666
|
+
* `GET /v1/sandboxes/capacity` · scope `sandboxes:read` · served by the node
|
|
667
|
+
*/
|
|
668
|
+
getCapacity(params, options) {
|
|
669
|
+
return this._client._call(getCapacityOp, { query: params }, options);
|
|
670
|
+
}
|
|
429
671
|
/**
|
|
430
672
|
* List snapshots
|
|
431
673
|
*
|
|
@@ -456,29 +698,244 @@ class SandboxesAPI extends namespace_ts_1.Namespace {
|
|
|
456
698
|
getSnapshot(snapshotId, options) {
|
|
457
699
|
return this._client._call(getSnapshotOp, { path: [snapshotId] }, options);
|
|
458
700
|
}
|
|
701
|
+
/**
|
|
702
|
+
* List swarms
|
|
703
|
+
*
|
|
704
|
+
* Lists swarms in this project, newest first, without their children (`GET /v1/sandboxes/swarms/{swarm_id}`
|
|
705
|
+
* returns them). Swarms are kept for 7 days after they finish.
|
|
706
|
+
*
|
|
707
|
+
* `GET /v1/sandboxes/swarms` · scope `sandboxes:read` · served by the node
|
|
708
|
+
*/
|
|
709
|
+
listSwarms(params, options) {
|
|
710
|
+
return this._client._list(listSwarmsOp, { query: params }, options);
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Start a swarm
|
|
714
|
+
*
|
|
715
|
+
* Forks one checkpoint into children, runs a command in each child, and gathers every child's exit code,
|
|
716
|
+
* output and timing. The checkpoint is a forkable sandbox (`from.sandbox`, running or paused) or a snapshot
|
|
717
|
+
* (`from.snapshot`). Each child is a new sandbox with a fresh identity, as a fork's or a restore's is: it keeps
|
|
718
|
+
* the checkpoint's environment, secrets, files, egress, ports and grant, and gets its own ID.
|
|
719
|
+
*
|
|
720
|
+
* Give the children one by one in `children` (at most `sandboxes.swarm_children_max`; a child's index is its
|
|
721
|
+
* position), or give `count` children that all run `defaults`. Each child's command runs as
|
|
722
|
+
* `POST /v1/sandboxes/{sandbox_id}/exec` would run it streamed, with `B3OS_SWARM_ID` and `B3OS_SWARM_INDEX`
|
|
723
|
+
* added to its environment, so one command can shard work by index. `env` is stored with the swarm's record
|
|
724
|
+
* for as long as it is kept: pass secrets as the checkpoint's `secrets`, never in `env`.
|
|
725
|
+
*
|
|
726
|
+
* A child whose sandbox would expire before its command's `timeout_ms` has passed gets a longer lifetime, the
|
|
727
|
+
* command's timeout plus 30 seconds, up to `sandboxes.timeout_max`.
|
|
728
|
+
*
|
|
729
|
+
* A child's non-zero exit is a result, not a failure of the swarm. The swarm `succeeded` once every child's
|
|
730
|
+
* command ended (exited, timed out, or could not run) or `stop_when` was met; it `failed` only when no child
|
|
731
|
+
* could start (the fork or restore failed) or the node restarted while it ran. With
|
|
732
|
+
* `stop_when: first_success`, the first child to exit 0 is `result.winner` and the other children's commands
|
|
733
|
+
* are killed (`canceled`). Each stream of output keeps its first `output_max_bytes` bytes, in the record and
|
|
734
|
+
* in the events.
|
|
735
|
+
*
|
|
736
|
+
* After its command ends a child is deleted, unless `keep` keeps it: `succeeded` keeps the children that
|
|
737
|
+
* exited 0, `all` keeps every child. A kept child is an ordinary sandbox that runs to its own `expires_at`,
|
|
738
|
+
* counts against `sandboxes.concurrent` and is billed until you delete it.
|
|
739
|
+
*
|
|
740
|
+
* All children are reserved at once, nothing started unless every one fits: past `sandboxes.concurrent` the
|
|
741
|
+
* answer is `429 concurrency_limited` with `Retry-After`, past `sandboxes.disk_total_max` `422 limit_exceeded`.
|
|
742
|
+
* 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
|
|
743
|
+
* hold no volume (`409 volume_attached`). Creating a swarm needs `sandboxes:write` and also `sandboxes:run`.
|
|
744
|
+
* Swarms are listed for 7 days after they finish. Behind the `sandboxes.swarms` feature flag: until it is on
|
|
745
|
+
* for your organization every swarm operation answers `404 feature_not_enabled`.
|
|
746
|
+
*
|
|
747
|
+
* `POST /v1/sandboxes/swarms` · scope `sandboxes:write` · served by the node
|
|
748
|
+
*/
|
|
749
|
+
createSwarm(body, options) {
|
|
750
|
+
return this._client._job(createSwarmOp, { body }, options);
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Get a swarm
|
|
754
|
+
*
|
|
755
|
+
* Returns the swarm with its status, progress, result, timing and every child with its exit code, output and
|
|
756
|
+
* timing. While it runs, children that have not ended show `queued` or `running`. `?wait=` holds the answer
|
|
757
|
+
* until the swarm ends or the wait runs out.
|
|
758
|
+
*
|
|
759
|
+
* `GET /v1/sandboxes/swarms/{swarm_id}` · scope `sandboxes:read` · served by the node
|
|
760
|
+
*/
|
|
761
|
+
getSwarm(swarmId, params, options) {
|
|
762
|
+
return this._client._call(getSwarmOp, { path: [swarmId], query: params }, options);
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Cancel a swarm
|
|
766
|
+
*
|
|
767
|
+
* Stops the swarm: commands still running are killed and those children end `canceled`; each child is then
|
|
768
|
+
* deleted unless the swarm's `keep` keeps it (`all` keeps every child, `succeeded` the ones that exited 0).
|
|
769
|
+
* Returns the swarm with status `canceled`.
|
|
770
|
+
*
|
|
771
|
+
* `POST /v1/sandboxes/swarms/{swarm_id}/cancel` · scope `sandboxes:write` · served by the node
|
|
772
|
+
*/
|
|
773
|
+
cancelSwarm(swarmId, options) {
|
|
774
|
+
return this._client._call(cancelSwarmOp, { path: [swarmId] }, options);
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* List a swarm's children
|
|
778
|
+
*
|
|
779
|
+
* Lists the swarm's children by index, with each child's exit code, output and timing. Available while the swarm runs.
|
|
780
|
+
*
|
|
781
|
+
* `GET /v1/sandboxes/swarms/{swarm_id}/children` · scope `sandboxes:read` · served by the node
|
|
782
|
+
*/
|
|
783
|
+
listSwarmChildren(swarmId, params, options) {
|
|
784
|
+
return this._client._list(listSwarmChildrenOp, { path: [swarmId], query: params }, options);
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Stream a swarm's events
|
|
788
|
+
*
|
|
789
|
+
* Server-sent events for the swarm: lifecycle events, `swarm.forked` with each child's sandbox ID, then
|
|
790
|
+
* `child.started`, `child.exited` or `child.failed` per child, and `child.stdout` and `child.stderr` when the
|
|
791
|
+
* swarm was created with `stream_output: true`. Ends after the terminal event. Reconnect with `Last-Event-ID`
|
|
792
|
+
* to resume. Events are kept with the swarm, so the stream reads the same, with the same `seq`, after the node
|
|
793
|
+
* restarts.
|
|
794
|
+
*
|
|
795
|
+
* `GET /v1/sandboxes/swarms/{swarm_id}/events` · scope `sandboxes:read` · served by the node
|
|
796
|
+
*/
|
|
797
|
+
swarmEvents(swarmId, options) {
|
|
798
|
+
return this._client._stream(swarmEventsOp, { path: [swarmId] }, options, {
|
|
799
|
+
terminal: jobs_ts_1.isTerminalJobEvent,
|
|
800
|
+
reconnectOnEnd: true,
|
|
801
|
+
});
|
|
802
|
+
}
|
|
459
803
|
/**
|
|
460
804
|
* List templates
|
|
461
805
|
*
|
|
462
806
|
* Lists the templates sandboxes can start from (`base`, `code-interpreter`, `agent`, and `browser` where a node
|
|
463
807
|
* builds it, which the beta node does not yet: Chrome already running in the snapshot, a VM-isolated browser
|
|
464
808
|
* with DevTools on port 9222) with their OS, runtimes, capabilities, defaults and `size_classes` (the sizes kept
|
|
465
|
-
* pre-warmed). It does not list a template's packages.
|
|
809
|
+
* pre-warmed). It does not list a template's packages. The node's templates have `owner: node`; your project's
|
|
810
|
+
* imported images add their templates with `owner: project` and `image` set (`POST /v1/images`). Other
|
|
811
|
+
* projects' image templates are never listed, and getting one answers `404 template_not_found`.
|
|
466
812
|
*
|
|
467
813
|
* `GET /v1/sandboxes/templates` · scope `sandboxes:read` · served by the node
|
|
468
814
|
*/
|
|
469
815
|
listTemplates(options) {
|
|
470
816
|
return this._client._call(listTemplatesOp, {}, options);
|
|
471
817
|
}
|
|
818
|
+
/**
|
|
819
|
+
* Create a template
|
|
820
|
+
*
|
|
821
|
+
* Makes a template for this project's sandboxes from a public OCI image (`image`, a reference) or from a
|
|
822
|
+
* Dockerfile build (`build`), with an optional `name` the project's creates start from:
|
|
823
|
+
* `POST /v1/sandboxes {"template": "py:3.11"}`. It takes the request `POST /v1/images` takes (with `image` in
|
|
824
|
+
* place of `ref`), and the template is that image's: one object, listed and deleted with `/v1/images`. The
|
|
825
|
+
* answer is the template's view: its `tpl_` ID (fixed from the start), `name`, `status` (the image's), `image`
|
|
826
|
+
* (the `img_` ID), `rootfs_sha256` once the image is flattened, and `key`. `202` for a new image, `200` for
|
|
827
|
+
* the project's image of the same request. Watch it with `GET /v1/images/{image_id}?wait=30` until `ready`;
|
|
828
|
+
* a create by name before then answers `409 image_not_ready`.
|
|
829
|
+
*
|
|
830
|
+
* A name is unique among the project's images (`409 image_name_taken`) and never a node template's
|
|
831
|
+
* (`422 image_name_reserved`). Another project's name answers `404 template_not_found`, as a template that
|
|
832
|
+
* does not exist. Behind the `images.build` flag (and `images.import`): until it is on for your organization
|
|
833
|
+
* the answer is `404 feature_not_enabled`. `503 product_unavailable` on a node without the images product.
|
|
834
|
+
*
|
|
835
|
+
* A private image names a registry connection in `auth`, as `POST /v1/images` does (`ImageRegistryAuth`): a
|
|
836
|
+
* vault connection of this project of type `basic` whose `hosts` list the registry and its token service.
|
|
837
|
+
* Using it also needs `vault:run` (`403` without it). Another project's connection, or one this credential may
|
|
838
|
+
* not use, answers `404 connection_not_found`; one that is not a registry connection for the image's registry,
|
|
839
|
+
* `422 image_auth_invalid`; a credential the registry refuses, `422 image_refused` with `reason: credentials`.
|
|
840
|
+
* The node reads the secret once, keeps it in memory for that one import and sends it only to the registry's
|
|
841
|
+
* token service: it is never logged, recorded or put in an error. A build takes no `auth`.
|
|
842
|
+
*
|
|
843
|
+
* `POST /v1/sandboxes/templates` · scope `sandboxes:write` · served by the node
|
|
844
|
+
*/
|
|
845
|
+
createTemplate(body, options) {
|
|
846
|
+
return this._client._call(createTemplateOp, { body }, options);
|
|
847
|
+
}
|
|
472
848
|
/**
|
|
473
849
|
* Get a template
|
|
474
850
|
*
|
|
475
|
-
* Returns one template by name (`base`) or ID (`tpl_…`)
|
|
851
|
+
* Returns one template by name (`base`) or ID (`tpl_…`): a node template, or one of your project's image templates, by its ID or its image's `name`. Another project's image template answers `404 template_not_found`.
|
|
476
852
|
*
|
|
477
853
|
* `GET /v1/sandboxes/templates/{template}` · scope `sandboxes:read` · served by the node
|
|
478
854
|
*/
|
|
479
855
|
getTemplate(template, options) {
|
|
480
856
|
return this._client._call(getTemplateOp, { path: [template] }, options);
|
|
481
857
|
}
|
|
858
|
+
/**
|
|
859
|
+
* List volumes
|
|
860
|
+
*
|
|
861
|
+
* Lists the project's volumes on this node, newest first. Deleted volumes are listed only with `status=deleted`.
|
|
862
|
+
*
|
|
863
|
+
* `GET /v1/sandboxes/volumes` · scope `sandboxes:read` · served by the node
|
|
864
|
+
*/
|
|
865
|
+
listVolumes(params, options) {
|
|
866
|
+
return this._client._list(listVolumesOp, { query: params }, options);
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Create a volume
|
|
870
|
+
*
|
|
871
|
+
* Creates an ext4 volume of `size_gib` on this node: data that outlives the sandboxes that mount it. Mount it
|
|
872
|
+
* in a sandbox with `volumes` on `POST /v1/sandboxes`; it is held by one running or paused sandbox at a time.
|
|
873
|
+
* Its blocks are allocated at once and reserved on the node's disk, so a full node disk cannot fail a write to
|
|
874
|
+
* it. Bills `sandboxes.volume_gib_h` (its size times the hours it exists, mounted or not) until it is deleted.
|
|
875
|
+
*
|
|
876
|
+
* In this beta a volume is one copy on the node's one drive: there is no backup, and it is not encrypted at
|
|
877
|
+
* rest, like every sandbox disk. Have the code that writes to it fsync what matters: what an app wrote and did
|
|
878
|
+
* not flush when its sandbox's microVM stopped without warning is lost.
|
|
879
|
+
*
|
|
880
|
+
* `POST /v1/sandboxes/volumes` · scope `sandboxes:write` · served by the node
|
|
881
|
+
*/
|
|
882
|
+
createVolume(body, options) {
|
|
883
|
+
return this._client._call(createVolumeOp, { body }, options);
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Delete a volume
|
|
887
|
+
*
|
|
888
|
+
* Marks the volume deleted: it is no longer listed or mounted, stops billing, and is purged (its data gone) at
|
|
889
|
+
* `purge_at`, 7 days later, unless you restore it first. Refused while a sandbox holds it (`409
|
|
890
|
+
* volume_attached`). Nothing else deletes a volume.
|
|
891
|
+
*
|
|
892
|
+
* `DELETE /v1/sandboxes/volumes/{volume_id}` · scope `sandboxes:write` · served by the node
|
|
893
|
+
*/
|
|
894
|
+
deleteVolume(volumeId, options) {
|
|
895
|
+
return this._client._call(deleteVolumeOp, { path: [volumeId] }, options);
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Get a volume
|
|
899
|
+
*
|
|
900
|
+
* Returns a volume, deleted ones in their grace included.
|
|
901
|
+
*
|
|
902
|
+
* `GET /v1/sandboxes/volumes/{volume_id}` · scope `sandboxes:read` · served by the node
|
|
903
|
+
*/
|
|
904
|
+
getVolume(volumeId, options) {
|
|
905
|
+
return this._client._call(getVolumeOp, { path: [volumeId] }, options);
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Grow a volume or change its metadata
|
|
909
|
+
*
|
|
910
|
+
* Replaces `metadata`, and grows the volume to `size_gib`. A volume grows only, and only while no sandbox
|
|
911
|
+
* holds it (`409 volume_attached`): its file system grows to the new size the next time a sandbox mounts it.
|
|
912
|
+
*
|
|
913
|
+
* `PATCH /v1/sandboxes/volumes/{volume_id}` · scope `sandboxes:write` · served by the node
|
|
914
|
+
*/
|
|
915
|
+
updateVolume(volumeId, body, options) {
|
|
916
|
+
return this._client._call(updateVolumeOp, { path: [volumeId], body }, options);
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Purge a volume now
|
|
920
|
+
*
|
|
921
|
+
* Removes the volume and its data now, deleted or not, without waiting for `purge_at`. `confirm` must be the
|
|
922
|
+
* volume's name. Refused while a sandbox holds it (`409 volume_attached`). This cannot be undone.
|
|
923
|
+
*
|
|
924
|
+
* `POST /v1/sandboxes/volumes/{volume_id}/purge` · scope `sandboxes:write` · served by the node
|
|
925
|
+
*/
|
|
926
|
+
purgeVolume(volumeId, body, options) {
|
|
927
|
+
return this._client._call(purgeVolumeOp, { path: [volumeId], body }, options);
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Restore a deleted volume
|
|
931
|
+
*
|
|
932
|
+
* 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.
|
|
933
|
+
*
|
|
934
|
+
* `POST /v1/sandboxes/volumes/{volume_id}/restore` · scope `sandboxes:write` · served by the node
|
|
935
|
+
*/
|
|
936
|
+
restoreVolume(volumeId, options) {
|
|
937
|
+
return this._client._call(restoreVolumeOp, { path: [volumeId] }, options);
|
|
938
|
+
}
|
|
482
939
|
/**
|
|
483
940
|
* Delete a sandbox
|
|
484
941
|
*
|
|
@@ -499,6 +956,85 @@ class SandboxesAPI extends namespace_ts_1.Namespace {
|
|
|
499
956
|
getSandbox(sandboxId, options) {
|
|
500
957
|
return this._client._call(getSandboxOp, { path: [sandboxId] }, options);
|
|
501
958
|
}
|
|
959
|
+
/**
|
|
960
|
+
* Read a desktop's screen size and pointer
|
|
961
|
+
*
|
|
962
|
+
* The screen size and the pointer position of a sandbox made from a template with the `computer`
|
|
963
|
+
* capability (`desktop`), and who controls its input. `controller` is always `agent` for now. A sandbox of
|
|
964
|
+
* another template answers `409 computer_unavailable`.
|
|
965
|
+
*
|
|
966
|
+
* A paused sandbox is resumed first when your key also has `sandboxes:write` (the scope of
|
|
967
|
+
* `POST /v1/sandboxes/{sandbox_id}/resume`); without it the answer is `409 sandbox_not_running`. A paused
|
|
968
|
+
* sandbox past its `expires_at` is not resumed: extend it with `POST /v1/sandboxes/{sandbox_id}/timeout` first.
|
|
969
|
+
* `503 desktop_unavailable` means the desktop's screen and input server in the sandbox did not answer; it is
|
|
970
|
+
* restarted within a few seconds of stopping. Behind the `sandboxes.desktop` feature flag: until it is on for
|
|
971
|
+
* your organization the operation answers `404 feature_not_enabled`.
|
|
972
|
+
*
|
|
973
|
+
* `GET /v1/sandboxes/{sandbox_id}/computer` · scope `sandboxes:read` · served by the node
|
|
974
|
+
*/
|
|
975
|
+
getComputer(sandboxId, options) {
|
|
976
|
+
return this._client._call(getComputerOp, { path: [sandboxId] }, options);
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Send mouse and keyboard actions to a desktop
|
|
980
|
+
*
|
|
981
|
+
* Runs 1 to 32 mouse and keyboard actions in order on a sandbox made from a template with the `computer`
|
|
982
|
+
* capability (`desktop`), then optionally waits for the screen to settle and takes a screenshot, all in one
|
|
983
|
+
* call. Action names follow Anthropic's computer-use actions, so a harness maps them one to one. Coordinates
|
|
984
|
+
* are screen pixels from the top left (`GET /v1/sandboxes/{sandbox_id}/computer` gives the screen size); an
|
|
985
|
+
* action without `x` and `y` acts at the pointer. `type` types up to 8,192 bytes of UTF-8 text (newline and
|
|
986
|
+
* tab included, other control characters refused); `key` presses a chord of xdotool key names
|
|
987
|
+
* (`ctrl+shift+t`, `Return`, `alt+F4`); `key_down` and `key_up` hold and release one key; `wait` waits; the
|
|
988
|
+
* waits of one call add up to at most 30,000 ms.
|
|
989
|
+
*
|
|
990
|
+
* The whole batch is checked before any input is sent: a bad action answers `400 invalid_request` naming it
|
|
991
|
+
* (`actions[2]`), and nothing ran. Then each action gets a result in `results`, in order: `delivery` says
|
|
992
|
+
* whether its input reached the X server (`delivered_unverified`: sent and synced; what the application did
|
|
993
|
+
* with it is not checked) and `retry` whether sending it again is safe (`unsafe` once a click, text or a key
|
|
994
|
+
* landed). An action that fails stops the batch; the actions after it are `not_delivered` with `retry:
|
|
995
|
+
* safe`. Held buttons and keys are released when a batch fails part way.
|
|
996
|
+
*
|
|
997
|
+
* `screenshot` adds a screenshot after the actions (`{format, quality}`, the same as the screenshot
|
|
998
|
+
* operation's query; `null` or left out: none). `settle` waits before the screenshot until the screen has
|
|
999
|
+
* not changed for `quiet_ms` (80 by default), at most `max_ms` (1,000 by default); `settled_by` says which
|
|
1000
|
+
* ended the wait. `cursor` is where the pointer ended, `null` when the desktop's X server went away during
|
|
1001
|
+
* the batch (then `screenshot` is `null` too). A failed screenshot after the actions also leaves `screenshot`
|
|
1002
|
+
* `null` with the results intact.
|
|
1003
|
+
*
|
|
1004
|
+
* A paused sandbox is resumed first when your key also has `sandboxes:write`, as for
|
|
1005
|
+
* `GET /v1/sandboxes/{sandbox_id}/computer`; without it the answer is `409 sandbox_not_running`. A sandbox of
|
|
1006
|
+
* another template answers `409 computer_unavailable`. A `503` or `504` after the batch was sent to the
|
|
1007
|
+
* sandbox says so in its detail: some actions may have run, so take a screenshot before you send them again.
|
|
1008
|
+
* The node logs each action's name, its coordinates and the batch's timing, never typed text (its length
|
|
1009
|
+
* only), keys or screenshots. Behind the `sandboxes.desktop` feature flag: until it is on for your
|
|
1010
|
+
* organization the operation answers `404 feature_not_enabled`.
|
|
1011
|
+
*
|
|
1012
|
+
* `POST /v1/sandboxes/{sandbox_id}/computer/actions` · scope `sandboxes:run` · served by the node
|
|
1013
|
+
*/
|
|
1014
|
+
computerAct(sandboxId, body, options) {
|
|
1015
|
+
return this._client._call(computerActOp, { path: [sandboxId], body }, options);
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Take a screenshot of a desktop
|
|
1019
|
+
*
|
|
1020
|
+
* Captures the whole screen of a sandbox made from a template with the `computer` capability (`desktop`).
|
|
1021
|
+
* With `Accept: image/png` or `image/jpeg` (or `image/*`, `*\/*`, or no `Accept`) the answer is the image
|
|
1022
|
+
* bytes; with `Accept: application/json` it is `{format, width, height, data_base64}`, the shape of a vision
|
|
1023
|
+
* screenshot. `format` is `jpeg` (at `quality`, 80 by default) unless the query or `Accept` asks for `png`;
|
|
1024
|
+
* `quality` applies to JPEG only. `Server-Timing` has `capture` and `encode` (the time inside the sandbox),
|
|
1025
|
+
* `desk` (the round trip to it) and `resume` when a paused sandbox was resumed first.
|
|
1026
|
+
*
|
|
1027
|
+
* A paused sandbox is resumed first when your key also has `sandboxes:write`, as for
|
|
1028
|
+
* `GET /v1/sandboxes/{sandbox_id}/computer`; without it the answer is `409 sandbox_not_running`. A sandbox of
|
|
1029
|
+
* another template answers `409 computer_unavailable`. Screenshots are never logged or stored by the node.
|
|
1030
|
+
* Behind the `sandboxes.desktop` feature flag: until it is on for your organization the operation answers
|
|
1031
|
+
* `404 feature_not_enabled`.
|
|
1032
|
+
*
|
|
1033
|
+
* `GET /v1/sandboxes/{sandbox_id}/computer/screenshot` · scope `sandboxes:read` · served by the node
|
|
1034
|
+
*/
|
|
1035
|
+
computerScreenshot(sandboxId, params, options) {
|
|
1036
|
+
return this._client._call(computerScreenshotOp, { path: [sandboxId], query: params }, options);
|
|
1037
|
+
}
|
|
502
1038
|
/**
|
|
503
1039
|
* Change a sandbox's egress policy
|
|
504
1040
|
*
|
|
@@ -611,7 +1147,8 @@ class SandboxesAPI extends namespace_ts_1.Namespace {
|
|
|
611
1147
|
* `forkable: true` (forkable sandboxes are restored for themselves rather than claimed from a pool, and track
|
|
612
1148
|
* the pages they change); forks are forkable too. The source pauses while its changed memory is written
|
|
613
1149
|
* (`pause`, `base`, `snapshot`, `export` phases in `Server-Timing`), then runs on; like a snapshot this resets
|
|
614
|
-
* its open connections to the outside.
|
|
1150
|
+
* its open connections to the outside. A paused source is resumed for the fork and paused again (`resume`
|
|
1151
|
+
* and `repause` phases), so a checkpoint can wait paused, billing neither meter, between forks.
|
|
615
1152
|
* Each fork counts against your sandbox concurrency and, with the source's `disk_gib`, against
|
|
616
1153
|
* `sandboxes.disk_total_max` (`422 limit_exceeded`). While the node's snapshot or disk store is nearly full,
|
|
617
1154
|
* forks are refused with `503 capacity_unavailable`.
|
|
@@ -621,6 +1158,60 @@ class SandboxesAPI extends namespace_ts_1.Namespace {
|
|
|
621
1158
|
forkSandbox(sandboxId, body, options) {
|
|
622
1159
|
return this._client._call(forkSandboxOp, { path: [sandboxId], body }, options);
|
|
623
1160
|
}
|
|
1161
|
+
/**
|
|
1162
|
+
* Release a sandbox's lease
|
|
1163
|
+
*
|
|
1164
|
+
* Ends the sandbox's lease (`end_reason: released`). The sandbox keeps running until its current `expires_at`,
|
|
1165
|
+
* which you can still move with `POST /v1/sandboxes/{sandbox_id}/timeout`. Releasing a sandbox that holds no
|
|
1166
|
+
* lease, or one that has stopped, changes nothing and answers the sandbox. A sandbox's own credential cannot
|
|
1167
|
+
* release a lease (`403 forbidden`, `reason: sandbox`).
|
|
1168
|
+
*
|
|
1169
|
+
* `DELETE /v1/sandboxes/{sandbox_id}/lease` · scope `sandboxes:write` · served by the node
|
|
1170
|
+
*/
|
|
1171
|
+
releaseLease(sandboxId, options) {
|
|
1172
|
+
return this._client._call(releaseLeaseOp, { path: [sandboxId] }, options);
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Keep a sandbox running under a lease
|
|
1176
|
+
*
|
|
1177
|
+
* Holds a lease on the sandbox under `key`, a name of your choosing (the deploy engine uses
|
|
1178
|
+
* `b3os:<app>/<service>`). While the lease is held and the sandbox runs, the node keeps it running past its
|
|
1179
|
+
* `timeout_s` and past `sandboxes.timeout_max`: whenever less than half of `sandboxes.lease_term` (900 s) is
|
|
1180
|
+
* left before `expires_at`, the node moves `expires_at` to `lease_term` from now. Nothing outside the node has
|
|
1181
|
+
* to renew it.
|
|
1182
|
+
*
|
|
1183
|
+
* One live sandbox in a project holds a key at a time. Holding a key on this sandbox takes it from the sandbox
|
|
1184
|
+
* that held it: that lease ends (`end_reason: replaced`) and that sandbox's `expires_at` moves to at most
|
|
1185
|
+
* `lease_term` from now, so it stops by then unless something extends it. A sandbox holds one lease; a call
|
|
1186
|
+
* with another key changes the key it holds. A call with the key it already holds changes nothing.
|
|
1187
|
+
*
|
|
1188
|
+
* `expect_holder` makes the call conditional on what you read: the sandbox you saw holding `key`, or `null` when
|
|
1189
|
+
* you saw none. The node takes the key only while that is still so; otherwise it answers `409
|
|
1190
|
+
* lease_holder_changed` with the sandbox that holds it now (`holder`), and changes nothing. A caller that read an
|
|
1191
|
+
* older state (a check that read the generation before a deploy handed the key to a newer one) then never takes
|
|
1192
|
+
* the key back from the sandbox that got it since. Without `expect_holder` the call takes the key from whichever
|
|
1193
|
+
* sandbox holds it.
|
|
1194
|
+
*
|
|
1195
|
+
* The lease ends when you release it (`DELETE …/lease`, `end_reason: released`; the sandbox then runs out its
|
|
1196
|
+
* current `expires_at`) and when the sandbox stops for any reason (`end_reason` is its `stop_reason`:
|
|
1197
|
+
* `deleted`, `timeout`, `failed`, `budget`, `revoked`). A paused sandbox is not renewed: it ends at
|
|
1198
|
+
* `expires_at` like any paused sandbox. An organization holds at most `sandboxes.leases_max` (5) leases on a
|
|
1199
|
+
* node; one more is `422 limit_exceeded`, and lowering the limit ends none already held. A sandbox's own
|
|
1200
|
+
* credential (the one its in-VM API holds) cannot hold or release a lease (`403 forbidden`, `reason: sandbox`),
|
|
1201
|
+
* so code can never keep its own sandbox, or another, running with it. A real API key you put into a sandbox (in
|
|
1202
|
+
* its `env` or `secrets`) is not the sandbox's own credential: code holding it can hold a lease as any caller
|
|
1203
|
+
* can, within `sandboxes.leases_max` and the organization's credits and spend caps.
|
|
1204
|
+
*
|
|
1205
|
+
* A leased sandbox is billed like any running one (`sandboxes.vcpu_ms`, `sandboxes.gib_ms`), so the call is
|
|
1206
|
+
* admitted like a create (credits, spend cap). The node checks a running sandbox's budget every 10 s and stops
|
|
1207
|
+
* a leased one, ending its lease, as it stops any other (`stop_reason: budget` or `revoked`; a project's service
|
|
1208
|
+
* never stops for its key's revoke or expiry, so not `revoked`).
|
|
1209
|
+
*
|
|
1210
|
+
* `PUT /v1/sandboxes/{sandbox_id}/lease` · scope `sandboxes:write` · served by the node
|
|
1211
|
+
*/
|
|
1212
|
+
holdLease(sandboxId, body, options) {
|
|
1213
|
+
return this._client._call(holdLeaseOp, { path: [sandboxId], body }, options);
|
|
1214
|
+
}
|
|
624
1215
|
/**
|
|
625
1216
|
* Stream process logs
|
|
626
1217
|
*
|
|
@@ -660,6 +1251,38 @@ class SandboxesAPI extends namespace_ts_1.Namespace {
|
|
|
660
1251
|
pauseSandbox(sandboxId, options) {
|
|
661
1252
|
return this._client._call(pauseSandboxOp, { path: [sandboxId] }, options);
|
|
662
1253
|
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Give a sandbox port its own host
|
|
1256
|
+
*
|
|
1257
|
+
* Gives `port` of the sandbox its own host, `https://<port>-sbx-<id>.b3os.io` (`<id>` is the sandbox ID without
|
|
1258
|
+
* `sbx_`), and returns a link to it. The app is served at `/` and keeps its cookies, as an application's
|
|
1259
|
+
* address does: it gets the request's whole path with no prefix, `Host` is the host, and the cookies it sets
|
|
1260
|
+
* stay on this host (`cookies`, `isolated` by default: the same rules as app addresses). Use it for apps that
|
|
1261
|
+
* need the root path or sign-in cookies. `POST /v1/sandboxes/{sandbox_id}/ports/{port}/url` keeps working as
|
|
1262
|
+
* before.
|
|
1263
|
+
*
|
|
1264
|
+
* Shared by link only, never public. The link (`url`) works for `ttl_s` seconds (10 minutes by default, at
|
|
1265
|
+
* most 24 hours); its first page load sets a cookie that keeps that browser in for 24 hours, and a program can
|
|
1266
|
+
* send the link's `b3os_link` value in `x-b3os-link` instead. Anyone else gets a 401 page, the same whether or
|
|
1267
|
+
* not the sandbox or the host exists. Each call returns a new link and leaves earlier ones working; `rotate:
|
|
1268
|
+
* true` first replaces the host's secret, so every earlier link and cookie of this host stops working within 6
|
|
1269
|
+
* seconds. `cookies` sets the host's cookie rule; left out, the host keeps the one it has.
|
|
1270
|
+
*
|
|
1271
|
+
* The port must be in the sandbox's `ports` and the sandbox running or paused (404 `port_not_exposed`, 409
|
|
1272
|
+
* `sandbox_not_running`, and 404 `sandbox_not_found` for a sandbox of another project). While the sandbox is
|
|
1273
|
+
* paused or stopped its host answers 503. The host is that sandbox's and port's for good and ends with the
|
|
1274
|
+
* sandbox; a fork or a restore has a new ID, so new hosts. A host with no call for 49 hours is forgotten: the
|
|
1275
|
+
* next call makes it again with a new secret. A dev server must accept the host (for Vite,
|
|
1276
|
+
* `server.allowedHosts: ['.b3os.io']`). Not yet available to code inside a sandbox (its API answers 421
|
|
1277
|
+
* `edge_only`). Port 49983 is kept for E2B's envd and gets no host (400). Hosts count toward no address limit.
|
|
1278
|
+
* B3 can block a sandbox's hosts (403 `app_host_blocked`). An organization may call this 60 times a minute
|
|
1279
|
+
* (429 `rate_limited` with `Retry-After` past that).
|
|
1280
|
+
*
|
|
1281
|
+
* `POST /v1/sandboxes/{sandbox_id}/ports/{port}/host` · scope `sandboxes:run` · served by beta-api.b3os.org
|
|
1282
|
+
*/
|
|
1283
|
+
createPortHost(sandboxId, port, body, options) {
|
|
1284
|
+
return this._client._call(createPortHostOp, { path: [sandboxId, port], body }, options);
|
|
1285
|
+
}
|
|
663
1286
|
/**
|
|
664
1287
|
* Get a URL for a port
|
|
665
1288
|
*
|
|
@@ -700,7 +1323,10 @@ class SandboxesAPI extends namespace_ts_1.Namespace {
|
|
|
700
1323
|
/**
|
|
701
1324
|
* Signal a background process
|
|
702
1325
|
*
|
|
703
|
-
* Sends a signal (default `TERM`) to a background process and its process group, and returns the process.
|
|
1326
|
+
* Sends a signal (default `TERM`) to a background process and its process group, and returns the process. On a
|
|
1327
|
+
* process the node supervises (an exec with `restart`), the call first ends the supervision (`state: stopped`
|
|
1328
|
+
* in the sandbox's `supervised`), so the process stays down; with `restart: true` it stays supervised and the
|
|
1329
|
+
* node starts it again once it exits, counted as a restart.
|
|
704
1330
|
*
|
|
705
1331
|
* `POST /v1/sandboxes/{sandbox_id}/processes/{pid}/kill` · scope `sandboxes:run` · served by the node
|
|
706
1332
|
*/
|
|
@@ -767,8 +1393,9 @@ class SandboxesAPI extends namespace_ts_1.Namespace {
|
|
|
767
1393
|
* searches and calls to other sandboxes), newest first, from the node's request log. These are the records
|
|
768
1394
|
* `GET /v1/requests?sandbox_id=` lists, for a caller that may read the sandbox: it needs only `sandboxes:read`,
|
|
769
1395
|
* not `platform:read`, and never returns another sandbox's records. It takes the same paging and the
|
|
770
|
-
* `product`, `operation_id`, `status`, `trace_id` and `
|
|
771
|
-
* `400 invalid_request`.
|
|
1396
|
+
* `product`, `operation_id`, `status`, `trace_id`, `since` and `pack` filters; any other query parameter is
|
|
1397
|
+
* `400 invalid_request`. `pack=io.b3os/wikipedia` lists the sandbox's calls of that pack's actions, through
|
|
1398
|
+
* `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
|
|
772
1399
|
* than 7 days ago is not found.
|
|
773
1400
|
*
|
|
774
1401
|
* `GET /v1/sandboxes/{sandbox_id}/requests` · scope `sandboxes:read` · served by the node
|