@b3os/sdk 0.1.3 → 0.2.1
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 +4 -3
- package/dist/cjs/core/client.d.ts +21 -2
- package/dist/cjs/core/client.js +26 -1
- package/dist/cjs/core/client.js.map +1 -1
- package/dist/cjs/core/handle.d.ts +5 -0
- package/dist/cjs/core/handle.js +13 -2
- package/dist/cjs/core/handle.js.map +1 -1
- package/dist/cjs/core/index.d.ts +2 -0
- package/dist/cjs/core/index.js +7 -1
- package/dist/cjs/core/index.js.map +1 -1
- package/dist/cjs/core/sse.d.ts +2 -0
- package/dist/cjs/core/sse.js +17 -5
- package/dist/cjs/core/sse.js.map +1 -1
- package/dist/cjs/core/traces-api.d.ts +42 -0
- package/dist/cjs/core/traces-api.js +54 -0
- package/dist/cjs/core/traces-api.js.map +1 -0
- package/dist/cjs/core/traces.d.ts +120 -0
- package/dist/cjs/core/traces.js +306 -0
- package/dist/cjs/core/traces.js.map +1 -0
- package/dist/cjs/core/util.d.ts +1 -1
- package/dist/cjs/core/util.js +1 -1
- package/dist/cjs/generated/errors.d.ts +1 -1
- package/dist/cjs/generated/errors.js +32 -0
- package/dist/cjs/generated/errors.js.map +1 -1
- package/dist/cjs/generated/ids.d.ts +12 -0
- package/dist/cjs/generated/ids.js +3 -0
- package/dist/cjs/generated/ids.js.map +1 -1
- package/dist/cjs/generated/ns/actions.d.ts +66 -1
- package/dist/cjs/generated/ns/actions.js +101 -1
- package/dist/cjs/generated/ns/actions.js.map +1 -1
- package/dist/cjs/generated/ns/keys.d.ts +2 -1
- package/dist/cjs/generated/ns/keys.js +2 -1
- package/dist/cjs/generated/ns/keys.js.map +1 -1
- package/dist/cjs/generated/ns/render.d.ts +22 -2
- package/dist/cjs/generated/ns/render.js +13 -2
- package/dist/cjs/generated/ns/render.js.map +1 -1
- package/dist/cjs/generated/ns/sandboxes.d.ts +29 -0
- package/dist/cjs/generated/ns/sandboxes.js +49 -0
- package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
- package/dist/cjs/generated/types.d.ts +1038 -65
- package/dist/cjs/helpers/sandboxes.d.ts +26 -2
- package/dist/cjs/helpers/sandboxes.js +114 -13
- package/dist/cjs/helpers/sandboxes.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/core/client.d.ts +21 -2
- package/dist/esm/core/client.js +27 -2
- package/dist/esm/core/client.js.map +1 -1
- package/dist/esm/core/handle.d.ts +5 -0
- package/dist/esm/core/handle.js +13 -2
- package/dist/esm/core/handle.js.map +1 -1
- package/dist/esm/core/index.d.ts +2 -0
- package/dist/esm/core/index.js +2 -0
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/core/sse.d.ts +2 -0
- package/dist/esm/core/sse.js +17 -5
- package/dist/esm/core/sse.js.map +1 -1
- package/dist/esm/core/traces-api.d.ts +42 -0
- package/dist/esm/core/traces-api.js +50 -0
- package/dist/esm/core/traces-api.js.map +1 -0
- package/dist/esm/core/traces.d.ts +120 -0
- package/dist/esm/core/traces.js +295 -0
- package/dist/esm/core/traces.js.map +1 -0
- package/dist/esm/core/util.d.ts +1 -1
- package/dist/esm/core/util.js +1 -1
- package/dist/esm/generated/errors.d.ts +1 -1
- package/dist/esm/generated/errors.js +32 -0
- package/dist/esm/generated/errors.js.map +1 -1
- package/dist/esm/generated/ids.d.ts +12 -0
- package/dist/esm/generated/ids.js +3 -0
- package/dist/esm/generated/ids.js.map +1 -1
- package/dist/esm/generated/ns/actions.d.ts +66 -1
- package/dist/esm/generated/ns/actions.js +101 -1
- package/dist/esm/generated/ns/actions.js.map +1 -1
- package/dist/esm/generated/ns/keys.d.ts +2 -1
- package/dist/esm/generated/ns/keys.js +2 -1
- package/dist/esm/generated/ns/keys.js.map +1 -1
- package/dist/esm/generated/ns/render.d.ts +22 -2
- package/dist/esm/generated/ns/render.js +13 -2
- package/dist/esm/generated/ns/render.js.map +1 -1
- package/dist/esm/generated/ns/sandboxes.d.ts +29 -0
- package/dist/esm/generated/ns/sandboxes.js +49 -0
- package/dist/esm/generated/ns/sandboxes.js.map +1 -1
- package/dist/esm/generated/types.d.ts +1038 -65
- package/dist/esm/helpers/sandboxes.d.ts +26 -2
- package/dist/esm/helpers/sandboxes.js +113 -12
- package/dist/esm/helpers/sandboxes.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/client.ts +36 -4
- package/src/core/handle.ts +12 -2
- package/src/core/index.ts +10 -0
- package/src/core/sse.ts +17 -5
- package/src/core/traces-api.ts +80 -0
- package/src/core/traces.ts +375 -0
- package/src/core/util.ts +1 -1
- package/src/generated/errors.ts +64 -0
- package/src/generated/ids.ts +3 -0
- package/src/generated/ns/actions.ts +110 -1
- package/src/generated/ns/keys.ts +2 -1
- package/src/generated/ns/render.ts +22 -2
- package/src/generated/ns/sandboxes.ts +59 -0
- package/src/generated/types.ts +1057 -63
- package/src/helpers/sandboxes.ts +136 -12
- package/src/index.ts +1 -0
|
@@ -54,6 +54,35 @@ const getPackManifestOp: Op = {
|
|
|
54
54
|
timeoutMs: 10000,
|
|
55
55
|
scope: "actions:read",
|
|
56
56
|
};
|
|
57
|
+
const getRegistryBlobOp: Op = {
|
|
58
|
+
id: "platformGetRegistryBlob",
|
|
59
|
+
method: "GET",
|
|
60
|
+
path: "/v1/actions/registry/blobs/{digest}",
|
|
61
|
+
params: ["digest"],
|
|
62
|
+
edge: true,
|
|
63
|
+
timeoutMs: 10000,
|
|
64
|
+
scope: "actions:read",
|
|
65
|
+
};
|
|
66
|
+
const headRegistryBlobOp: Op = {
|
|
67
|
+
id: "platformHeadRegistryBlob",
|
|
68
|
+
method: "HEAD",
|
|
69
|
+
path: "/v1/actions/registry/blobs/{digest}",
|
|
70
|
+
params: ["digest"],
|
|
71
|
+
edge: true,
|
|
72
|
+
timeoutMs: 10000,
|
|
73
|
+
scope: "actions:tools:publish",
|
|
74
|
+
};
|
|
75
|
+
const putRegistryBlobOp: Op = {
|
|
76
|
+
id: "platformPutRegistryBlob",
|
|
77
|
+
method: "PUT",
|
|
78
|
+
path: "/v1/actions/registry/blobs/{digest}",
|
|
79
|
+
params: ["digest"],
|
|
80
|
+
body: "bytes",
|
|
81
|
+
contentType: "application/octet-stream",
|
|
82
|
+
edge: true,
|
|
83
|
+
timeoutMs: 60000,
|
|
84
|
+
scope: "actions:tools:publish",
|
|
85
|
+
};
|
|
57
86
|
const listRegistryPacksOp: Op = {
|
|
58
87
|
id: "platformListRegistryPacks",
|
|
59
88
|
method: "GET",
|
|
@@ -137,6 +166,9 @@ export const actionsOps = {
|
|
|
137
166
|
getPack: getPackOp,
|
|
138
167
|
getPackTools: getPackToolsOp,
|
|
139
168
|
getPackManifest: getPackManifestOp,
|
|
169
|
+
getRegistryBlob: getRegistryBlobOp,
|
|
170
|
+
headRegistryBlob: headRegistryBlobOp,
|
|
171
|
+
putRegistryBlob: putRegistryBlobOp,
|
|
140
172
|
listRegistryPacks: listRegistryPacksOp,
|
|
141
173
|
publishPack: publishPackOp,
|
|
142
174
|
getRegistryPack: getRegistryPackOp,
|
|
@@ -182,6 +214,25 @@ export class ActionsAPI extends Namespace {
|
|
|
182
214
|
* (response mapping and output schema) for declarative HTTP actions; `sidecar` for JavaScript actions.
|
|
183
215
|
* Bills one `actions.call` once the action ran.
|
|
184
216
|
*
|
|
217
|
+
* **Hosted tools** (a preview, on for every organization in the beta; without `actions.tools` a `vm` call is
|
|
218
|
+
* `404 feature_not_enabled` and nothing runs). A `vm` action runs its publisher's command in a fresh microVM
|
|
219
|
+
* with no network, made for this call only and deleted before the call answers. A file field of the input
|
|
220
|
+
* schema (`x-b3os-file`) takes a file value inline, `{"$bytes": "<base64>", "name": "<name>"}` with `name`
|
|
221
|
+
* matching `^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$` (`ToolFileInput`); an output file comes back as
|
|
222
|
+
* `{"$bytes", "name", "bytes", "contentType"}` (`ToolFileOutput`), 262144 bytes of files in all. The budget is
|
|
223
|
+
* the least of `timeout_ms`, the action's own timeout and 60 seconds; a priced action refuses a `timeout_ms`
|
|
224
|
+
* below its own (`400 invalid_request`) here, and runs to its own timeout when a routine step calls it. Every
|
|
225
|
+
* call is a fresh VM, and a call that finished is charged even if the client had stopped waiting: send
|
|
226
|
+
* `Idempotency-Key` with a priced call, so a retry with the same key gets the stored answer and is not charged
|
|
227
|
+
* again (a routine step's retry with its key gets the answer of the call it started). Per organization: 120 tool calls started a minute, 4 at once, and
|
|
228
|
+
* 20 USD of publisher prices a month, counted on each node (`429`); per node, a limit of tool VMs at once (`503 tool_unavailable`,
|
|
229
|
+
* `reason: node_busy`). The answer has `tier: vm`, `cost` in micro-USD, and the `timing` phases `validate`,
|
|
230
|
+
* `start`, `copy`, `unpack`, `run`, `collect`, `delete` and `cost`. A tool call bills `actions.tool_call` (the
|
|
231
|
+
* floor, once the command ran) instead of `actions.call`, the VM's `actions.vcpu_ms` and `actions.gib_ms`,
|
|
232
|
+
* and, once the tool answered, its output matched its schema and its output files were read, the publisher's
|
|
233
|
+
* price as `actions.publisher_microusd`. A failure
|
|
234
|
+
* before the command ran bills nothing; a failure of the tool bills compute and the floor and no price.
|
|
235
|
+
*
|
|
185
236
|
* `POST /v1/actions/call` · scope `actions:run` · served by the node
|
|
186
237
|
*/
|
|
187
238
|
call(body: T.ActionCallRequest, options?: RequestOptions): APIPromise<T.ActionResult> {
|
|
@@ -263,6 +314,56 @@ export class ActionsAPI extends Namespace {
|
|
|
263
314
|
return this._client._call<T.B3Pack>(getPackManifestOp, { path: [namespace, name, version] }, options);
|
|
264
315
|
}
|
|
265
316
|
|
|
317
|
+
/**
|
|
318
|
+
* Download a hosted tool's archive
|
|
319
|
+
*
|
|
320
|
+
* Redirects to a short-lived signed URL for the archive (`application/octet-stream`). Served to a node's
|
|
321
|
+
* registry sync (a node-signed read), to the organization the publisher list names for a namespace that
|
|
322
|
+
* published a pack naming this archive, and to B3's organizations; to anyone else it is `404`, as if it did
|
|
323
|
+
* not exist. Verify the sha256 before use.
|
|
324
|
+
*
|
|
325
|
+
* `GET /v1/actions/registry/blobs/{digest}` · scope `actions:read` · served by beta-api.b3os.org
|
|
326
|
+
*/
|
|
327
|
+
getRegistryBlob(digest: string, options?: RequestOptions): APIPromise<Uint8Array> {
|
|
328
|
+
return this._client._call<Uint8Array>(
|
|
329
|
+
getRegistryBlobOp,
|
|
330
|
+
{ path: [digest] },
|
|
331
|
+
options,
|
|
332
|
+
"application/gzip, application/octet-stream",
|
|
333
|
+
"bytes",
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Check for a hosted tool's archive
|
|
339
|
+
*
|
|
340
|
+
* Answers `200` with the archive's `Content-Length` when the blob store holds `digest`, else `404` (a HEAD
|
|
341
|
+
* answer carries no body). `b3os tool
|
|
342
|
+
* publish` asks before it uploads. Needs the `actions.tools` flag and the scope `actions:tools:publish`.
|
|
343
|
+
*
|
|
344
|
+
* `HEAD /v1/actions/registry/blobs/{digest}` · scope `actions:tools:publish` · served by beta-api.b3os.org
|
|
345
|
+
*/
|
|
346
|
+
headRegistryBlob(digest: string, options?: RequestOptions): APIPromise<void> {
|
|
347
|
+
return this._client._call<void>(headRegistryBlobOp, { path: [digest] }, options);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Upload a hosted tool's archive
|
|
352
|
+
*
|
|
353
|
+
* Stores a hosted tool's archive under its sha256, before the pack that names it is published
|
|
354
|
+
* (`platformPublishPack`). The body is the archive's bytes; `Content-Length` is required and at most
|
|
355
|
+
* 67108864 (64 MiB), and is checked before the body is read. The edge hashes the body as it streams it to
|
|
356
|
+
* storage: a body whose sha256 is not `digest`, or whose length is not `Content-Length`, is deleted and
|
|
357
|
+
* refused with `422 pack_invalid`. No `Content-Length` is `400 invalid_request`. A digest already stored answers `200` and stores nothing, so a retry is
|
|
358
|
+
* safe. Needs the `actions.tools` flag and the scope `actions:tools:publish`, which `*` and `actions:*` never
|
|
359
|
+
* grant; in the beta only B3's organizations may upload.
|
|
360
|
+
*
|
|
361
|
+
* `PUT /v1/actions/registry/blobs/{digest}` · scope `actions:tools:publish` · served by beta-api.b3os.org
|
|
362
|
+
*/
|
|
363
|
+
putRegistryBlob(digest: string, data: BinaryInput, options?: RequestOptions): APIPromise<T.RegistryBlob> {
|
|
364
|
+
return this._client._call<T.RegistryBlob>(putRegistryBlobOp, { path: [digest], body: data }, options);
|
|
365
|
+
}
|
|
366
|
+
|
|
266
367
|
/**
|
|
267
368
|
* List registry packs
|
|
268
369
|
*
|
|
@@ -284,7 +385,15 @@ export class ActionsAPI extends Namespace {
|
|
|
284
385
|
* most 2,000 files and 16 MiB once decompressed; other organizations are refused before the upload is read). The
|
|
285
386
|
* manifest's `signature` must verify: `sig` is Ed25519 over `b3pack-sig-v1\n<pack>\n<version>\n<contentHash>`
|
|
286
387
|
* with the publisher key `kid`, and `contentHash` covers the bundle with the signature removed. Versions are
|
|
287
|
-
* immutable. In the beta only
|
|
388
|
+
* immutable. In the beta only B3's organizations may publish, into `io.b3os` or a namespace the registry's
|
|
389
|
+
* publisher list names for the caller's organization.
|
|
390
|
+
*
|
|
391
|
+
* A pack with a `tool` block (a hosted tool) also needs: the `actions.tools` flag for the caller's
|
|
392
|
+
* organization (`404 feature_not_enabled`), the scope `actions:tools:publish`, which `*` and `actions:*` never
|
|
393
|
+
* grant (`403 forbidden` with `required_scope`), its archive already uploaded with the sha256 and size the
|
|
394
|
+
* manifest names (`PUT /v1/actions/registry/blobs/{digest}`; else `422 pack_invalid` with the pointer
|
|
395
|
+
* `/tool/bundle/archive`), and the hosted-tool and price rules of the b3pack publish checks (13 to 20). The
|
|
396
|
+
* version records who published it (`published_by`).
|
|
288
397
|
*
|
|
289
398
|
* `POST /v1/actions/registry/packs` · scope `actions:write` · served by beta-api.b3os.org
|
|
290
399
|
*/
|
package/src/generated/ns/keys.ts
CHANGED
|
@@ -125,7 +125,8 @@ export class KeysAPI extends Namespace {
|
|
|
125
125
|
* Describe the calling credential
|
|
126
126
|
*
|
|
127
127
|
* Returns who is calling: the key or CLI token (or dashboard session, or sandbox), its organization and
|
|
128
|
-
* project, scopes, spend cap and expiry. Any valid credential may call
|
|
128
|
+
* project, scopes, spend cap, what it has spent this billing period and expiry. Any valid credential may call
|
|
129
|
+
* it, whatever its scopes, so a key without `platform:read` can still see how much of its cap is used.
|
|
129
130
|
*
|
|
130
131
|
* `GET /v1/keys/current` · scope `authenticated` · served by beta-api.b3os.org
|
|
131
132
|
*/
|
|
@@ -204,11 +204,13 @@ export class RenderAPI extends Namespace {
|
|
|
204
204
|
*
|
|
205
205
|
* - `css`: drawn by the compositor from CSS gradient layers (no image file), recolorable through `tokens`.
|
|
206
206
|
* - `procedural`: the `studio` pack, our own soft meshes computed by the compositor (no image file, no
|
|
207
|
-
* tokens); the ones tagged `auto` are the set
|
|
207
|
+
* tokens); the ones tagged `auto` are the set a screenshot's `auto` background (and anything's `studio`)
|
|
208
|
+
* picks from.
|
|
208
209
|
* - `image`: a lossless WebP from ScreenFramed's curated library (decisions T9 and T10: Sean's grants as owner
|
|
209
210
|
* of the library), up to 3840 px on the long edge, with its measured tone in `image` (theme, luminance, hue,
|
|
210
211
|
* detail; how `"auto"` matches a page). `image.coverage` is `full-bleed` for backgrounds; the `gradients`
|
|
211
|
-
* group holds transparent shapes (`cutout`) drawn over a matte.
|
|
212
|
+
* group holds transparent shapes (`cutout`) drawn over a matte. The images tagged `video` are the set a video's
|
|
213
|
+
* `auto` background picks from.
|
|
212
214
|
*
|
|
213
215
|
* Rows are in `ref` order, paged by `limit` and `cursor`. A ref whose bytes equal an earlier one's still
|
|
214
216
|
* resolves but is not listed. Public: no API key, rate limited per client address, and answered from the
|
|
@@ -289,6 +291,15 @@ export class RenderAPI extends Namespace {
|
|
|
289
291
|
* `final_url` and `page_state` say what the site answered, and `warnings` what a caller should know: an error
|
|
290
292
|
* status, a main area that stayed blank, a page taken before its load event, overlays or a wall left in place.
|
|
291
293
|
*
|
|
294
|
+
* `profile` names a vision profile (ID or name) of the key's project: its cookies and storage load into the
|
|
295
|
+
* page's own browser context before the page loads, so the capture shows the page signed in. It needs
|
|
296
|
+
* `vision:profiles:use` (403 without it, 404 `profile_not_found` for a profile the project does not have),
|
|
297
|
+
* and the answer's `source.profile` is the profile's `prof_` ID. Render writes the state into no answer,
|
|
298
|
+
* stored record or log line, but the image shows whatever the signed-in page shows: treat it and its link as
|
|
299
|
+
* private. A page that is still signed out after the profile loads (a sign-in form, a 401 or 403, a move to a
|
|
300
|
+
* sign-in page, or a sign-in wall) fails with 422 `profile_expired` and bills nothing: sign in again and save
|
|
301
|
+
* the profile.
|
|
302
|
+
*
|
|
292
303
|
* `POST /v1/render/screenshots` · scope `render:run` · served by the node
|
|
293
304
|
*/
|
|
294
305
|
createScreenshot(
|
|
@@ -354,6 +365,15 @@ export class RenderAPI extends Namespace {
|
|
|
354
365
|
* (H.264, BT.709), GIF, poster and captions. Artifacts appear as they finish (`video.artifact` events, poster
|
|
355
366
|
* first). Bills `render.video_s` per second of output.
|
|
356
367
|
*
|
|
368
|
+
* `source.profile` names a vision profile (ID or name) of the key's project, found when the video is made
|
|
369
|
+
* (403 without `vision:profiles:use`, 404 `profile_not_found`). When the job runs, its state loads into the
|
|
370
|
+
* probe's browser context and every capture segment's, so the whole video is recorded signed in; the video,
|
|
371
|
+
* its timeline and its events name the profile by its `prof_` ID only, but the video shows whatever the
|
|
372
|
+
* signed-in pages show: treat it and its links as private. A page that opens still signed out (a sign-in form,
|
|
373
|
+
* a 401 or 403, or a move to a sign-in page) ends the job with `profile_expired` before any step runs, and
|
|
374
|
+
* nothing is billed. A recording made with a
|
|
375
|
+
* profile is reused (`recording.reuse`) only by videos with the same revision of the same profile.
|
|
376
|
+
*
|
|
357
377
|
* `POST /v1/render/videos` · scope `render:run` · served by the node
|
|
358
378
|
*/
|
|
359
379
|
createVideo(body: T.VideoCreateRequest, options?: RequestOptions): JobPromise<T.Video, T.VideoEvent> {
|
|
@@ -248,6 +248,14 @@ const waitReadyOp: Op = {
|
|
|
248
248
|
timeoutMs: 65000,
|
|
249
249
|
scope: "sandboxes:run",
|
|
250
250
|
};
|
|
251
|
+
const listRequestsOp: Op = {
|
|
252
|
+
id: "sandboxesListRequests",
|
|
253
|
+
method: "GET",
|
|
254
|
+
path: "/v1/sandboxes/{sandbox_id}/requests",
|
|
255
|
+
params: ["sandbox_id"],
|
|
256
|
+
timeoutMs: 15000,
|
|
257
|
+
scope: "sandboxes:read",
|
|
258
|
+
};
|
|
251
259
|
const resumeSandboxOp: Op = {
|
|
252
260
|
id: "sandboxesResumeSandbox",
|
|
253
261
|
method: "POST",
|
|
@@ -275,6 +283,14 @@ const createSnapshotOp: Op = {
|
|
|
275
283
|
timeoutMs: 65000,
|
|
276
284
|
scope: "sandboxes:write",
|
|
277
285
|
};
|
|
286
|
+
const getStatsOp: Op = {
|
|
287
|
+
id: "sandboxesGetStats",
|
|
288
|
+
method: "GET",
|
|
289
|
+
path: "/v1/sandboxes/{sandbox_id}/stats",
|
|
290
|
+
params: ["sandbox_id"],
|
|
291
|
+
timeoutMs: 10000,
|
|
292
|
+
scope: "sandboxes:read",
|
|
293
|
+
};
|
|
278
294
|
const createTicketOp: Op = {
|
|
279
295
|
id: "sandboxesCreateTicket",
|
|
280
296
|
method: "POST",
|
|
@@ -320,9 +336,11 @@ export const sandboxesOps = {
|
|
|
320
336
|
killProcess: killProcessOp,
|
|
321
337
|
openPty: openPtyOp,
|
|
322
338
|
waitReady: waitReadyOp,
|
|
339
|
+
listRequests: listRequestsOp,
|
|
323
340
|
resumeSandbox: resumeSandboxOp,
|
|
324
341
|
runCode: runCodeOp,
|
|
325
342
|
createSnapshot: createSnapshotOp,
|
|
343
|
+
getStats: getStatsOp,
|
|
326
344
|
createTicket: createTicketOp,
|
|
327
345
|
setTimeout: setTimeoutOp,
|
|
328
346
|
} as const;
|
|
@@ -917,6 +935,31 @@ export class SandboxesAPI extends Namespace {
|
|
|
917
935
|
return this._client._call<T.ReadinessResult>(waitReadyOp, { path: [sandboxId], body }, options);
|
|
918
936
|
}
|
|
919
937
|
|
|
938
|
+
/**
|
|
939
|
+
* List the requests a sandbox made
|
|
940
|
+
*
|
|
941
|
+
* Lists the requests code inside this sandbox made to B3OS in the last 7 days (its model calls, scrapes,
|
|
942
|
+
* searches and calls to other sandboxes), newest first, from the node's request log. These are the records
|
|
943
|
+
* `GET /v1/requests?sandbox_id=` lists, for a caller that may read the sandbox: it needs only `sandboxes:read`,
|
|
944
|
+
* 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 `since` filters; any other query parameter is
|
|
946
|
+
* `400 invalid_request`. Requests made to the sandbox's public ports are not listed. A sandbox stopped more
|
|
947
|
+
* than 7 days ago is not found.
|
|
948
|
+
*
|
|
949
|
+
* `GET /v1/sandboxes/{sandbox_id}/requests` · scope `sandboxes:read` · served by the node
|
|
950
|
+
*/
|
|
951
|
+
listRequests(
|
|
952
|
+
sandboxId: string,
|
|
953
|
+
params?: T.SandboxesListRequestsParams,
|
|
954
|
+
options?: RequestOptions,
|
|
955
|
+
): ListPromise<T.RequestRecordList, T.RequestRecord> {
|
|
956
|
+
return this._client._list<T.RequestRecordList, T.RequestRecord>(
|
|
957
|
+
listRequestsOp,
|
|
958
|
+
{ path: [sandboxId], query: params },
|
|
959
|
+
options,
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
|
|
920
963
|
/**
|
|
921
964
|
* Resume a sandbox
|
|
922
965
|
*
|
|
@@ -976,6 +1019,22 @@ export class SandboxesAPI extends Namespace {
|
|
|
976
1019
|
return this._client._call<T.Snapshot>(createSnapshotOp, { path: [sandboxId], body }, options);
|
|
977
1020
|
}
|
|
978
1021
|
|
|
1022
|
+
/**
|
|
1023
|
+
* Read what a sandbox uses now
|
|
1024
|
+
*
|
|
1025
|
+
* CPU, memory, disk and process counts of a running sandbox, read now and run no command in it. `cpu.percent`
|
|
1026
|
+
* is the share of all the sandbox's vCPUs that was busy over the last `cpu.interval_ms`: since your previous
|
|
1027
|
+
* stats read of this sandbox when that was 1 second to 5 minutes ago, else over 250 ms. Memory is the guest
|
|
1028
|
+
* kernel's own count (`MemTotal` and `MemAvailable`). `disk` (the root filesystem) and `processes.total` are
|
|
1029
|
+
* null in a sandbox whose image predates them. Poll it no faster than every 2 seconds. A paused or stopped
|
|
1030
|
+
* sandbox answers `409 sandbox_not_running`.
|
|
1031
|
+
*
|
|
1032
|
+
* `GET /v1/sandboxes/{sandbox_id}/stats` · scope `sandboxes:read` · served by the node
|
|
1033
|
+
*/
|
|
1034
|
+
getStats(sandboxId: string, options?: RequestOptions): APIPromise<T.SandboxStats> {
|
|
1035
|
+
return this._client._call<T.SandboxStats>(getStatsOp, { path: [sandboxId] }, options);
|
|
1036
|
+
}
|
|
1037
|
+
|
|
979
1038
|
/**
|
|
980
1039
|
* Create a stream ticket
|
|
981
1040
|
*
|