@b3os/sdk 0.0.0-stage → 0.1.0
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/LICENSE +202 -0
- package/README.md +233 -2
- package/dist/cjs/core/client.d.ts +165 -0
- package/dist/cjs/core/client.js +825 -0
- package/dist/cjs/core/client.js.map +1 -0
- package/dist/cjs/core/errors.d.ts +101 -0
- package/dist/cjs/core/errors.js +249 -0
- package/dist/cjs/core/errors.js.map +1 -0
- package/dist/cjs/core/index.d.ts +12 -0
- package/dist/cjs/core/index.js +42 -0
- package/dist/cjs/core/index.js.map +1 -0
- package/dist/cjs/core/jobs.d.ts +31 -0
- package/dist/cjs/core/jobs.js +72 -0
- package/dist/cjs/core/jobs.js.map +1 -0
- package/dist/cjs/core/namespace.d.ts +7 -0
- package/dist/cjs/core/namespace.js +13 -0
- package/dist/cjs/core/namespace.js.map +1 -0
- package/dist/cjs/core/op.d.ts +47 -0
- package/dist/cjs/core/op.js +5 -0
- package/dist/cjs/core/op.js.map +1 -0
- package/dist/cjs/core/promise.d.ts +106 -0
- package/dist/cjs/core/promise.js +200 -0
- package/dist/cjs/core/promise.js.map +1 -0
- package/dist/cjs/core/response.d.ts +54 -0
- package/dist/cjs/core/response.js +92 -0
- package/dist/cjs/core/response.js.map +1 -0
- package/dist/cjs/core/sse.d.ts +79 -0
- package/dist/cjs/core/sse.js +291 -0
- package/dist/cjs/core/sse.js.map +1 -0
- package/dist/cjs/core/timing.d.ts +20 -0
- package/dist/cjs/core/timing.js +96 -0
- package/dist/cjs/core/timing.js.map +1 -0
- package/dist/cjs/core/transport.d.ts +80 -0
- package/dist/cjs/core/transport.js +472 -0
- package/dist/cjs/core/transport.js.map +1 -0
- package/dist/cjs/core/util.d.ts +25 -0
- package/dist/cjs/core/util.js +142 -0
- package/dist/cjs/core/util.js.map +1 -0
- package/dist/cjs/core/ws.d.ts +52 -0
- package/dist/cjs/core/ws.js +181 -0
- package/dist/cjs/core/ws.js.map +1 -0
- package/dist/cjs/generated/client.d.ts +62 -0
- package/dist/cjs/generated/client.js +130 -0
- package/dist/cjs/generated/client.js.map +1 -0
- package/dist/cjs/generated/errors.d.ts +4 -0
- package/dist/cjs/generated/errors.js +160 -0
- package/dist/cjs/generated/errors.js.map +1 -0
- package/dist/cjs/generated/ids.d.ts +114 -0
- package/dist/cjs/generated/ids.js +47 -0
- package/dist/cjs/generated/ids.js.map +1 -0
- package/dist/cjs/generated/jobs.d.ts +10 -0
- package/dist/cjs/generated/jobs.js +24 -0
- package/dist/cjs/generated/jobs.js.map +1 -0
- package/dist/cjs/generated/ns/actions.d.ts +161 -0
- package/dist/cjs/generated/ns/actions.js +304 -0
- package/dist/cjs/generated/ns/actions.js.map +1 -0
- package/dist/cjs/generated/ns/infer.d.ts +190 -0
- package/dist/cjs/generated/ns/infer.js +253 -0
- package/dist/cjs/generated/ns/infer.js.map +1 -0
- package/dist/cjs/generated/ns/keys.d.ts +76 -0
- package/dist/cjs/generated/ns/keys.js +144 -0
- package/dist/cjs/generated/ns/keys.js.map +1 -0
- package/dist/cjs/generated/ns/limits.d.ts +22 -0
- package/dist/cjs/generated/ns/limits.js +32 -0
- package/dist/cjs/generated/ns/limits.js.map +1 -0
- package/dist/cjs/generated/ns/orgs.d.ts +38 -0
- package/dist/cjs/generated/ns/orgs.js +68 -0
- package/dist/cjs/generated/ns/orgs.js.map +1 -0
- package/dist/cjs/generated/ns/projects.d.ts +57 -0
- package/dist/cjs/generated/ns/projects.js +115 -0
- package/dist/cjs/generated/ns/projects.js.map +1 -0
- package/dist/cjs/generated/ns/render.d.ts +159 -0
- package/dist/cjs/generated/ns/render.js +299 -0
- package/dist/cjs/generated/ns/render.js.map +1 -0
- package/dist/cjs/generated/ns/requests.d.ts +36 -0
- package/dist/cjs/generated/ns/requests.js +54 -0
- package/dist/cjs/generated/ns/requests.js.map +1 -0
- package/dist/cjs/generated/ns/routines.d.ts +212 -0
- package/dist/cjs/generated/ns/routines.js +419 -0
- package/dist/cjs/generated/ns/routines.js.map +1 -0
- package/dist/cjs/generated/ns/sandboxes.d.ts +318 -0
- package/dist/cjs/generated/ns/sandboxes.js +549 -0
- package/dist/cjs/generated/ns/sandboxes.js.map +1 -0
- package/dist/cjs/generated/ns/usage.d.ts +30 -0
- package/dist/cjs/generated/ns/usage.js +49 -0
- package/dist/cjs/generated/ns/usage.js.map +1 -0
- package/dist/cjs/generated/ns/vault.d.ts +69 -0
- package/dist/cjs/generated/ns/vault.js +122 -0
- package/dist/cjs/generated/ns/vault.js.map +1 -0
- package/dist/cjs/generated/ns/vision.d.ts +376 -0
- package/dist/cjs/generated/ns/vision.js +736 -0
- package/dist/cjs/generated/ns/vision.js.map +1 -0
- package/dist/cjs/generated/ns/webhooks.d.ts +50 -0
- package/dist/cjs/generated/ns/webhooks.js +91 -0
- package/dist/cjs/generated/ns/webhooks.js.map +1 -0
- package/dist/cjs/generated/types.d.ts +4613 -0
- package/dist/cjs/generated/types.js +4 -0
- package/dist/cjs/generated/types.js.map +1 -0
- package/dist/cjs/index.d.ts +22 -0
- package/dist/cjs/index.js +81 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/webhooks.d.ts +19 -0
- package/dist/cjs/webhooks.js +85 -0
- package/dist/cjs/webhooks.js.map +1 -0
- package/dist/esm/core/client.d.ts +165 -0
- package/dist/esm/core/client.js +821 -0
- package/dist/esm/core/client.js.map +1 -0
- package/dist/esm/core/errors.d.ts +101 -0
- package/dist/esm/core/errors.js +239 -0
- package/dist/esm/core/errors.js.map +1 -0
- package/dist/esm/core/index.d.ts +12 -0
- package/dist/esm/core/index.js +15 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/core/jobs.d.ts +31 -0
- package/dist/esm/core/jobs.js +66 -0
- package/dist/esm/core/jobs.js.map +1 -0
- package/dist/esm/core/namespace.d.ts +7 -0
- package/dist/esm/core/namespace.js +9 -0
- package/dist/esm/core/namespace.js.map +1 -0
- package/dist/esm/core/op.d.ts +47 -0
- package/dist/esm/core/op.js +4 -0
- package/dist/esm/core/op.js.map +1 -0
- package/dist/esm/core/promise.d.ts +106 -0
- package/dist/esm/core/promise.js +193 -0
- package/dist/esm/core/promise.js.map +1 -0
- package/dist/esm/core/response.d.ts +54 -0
- package/dist/esm/core/response.js +86 -0
- package/dist/esm/core/response.js.map +1 -0
- package/dist/esm/core/sse.d.ts +79 -0
- package/dist/esm/core/sse.js +286 -0
- package/dist/esm/core/sse.js.map +1 -0
- package/dist/esm/core/timing.d.ts +20 -0
- package/dist/esm/core/timing.js +92 -0
- package/dist/esm/core/timing.js.map +1 -0
- package/dist/esm/core/transport.d.ts +80 -0
- package/dist/esm/core/transport.js +465 -0
- package/dist/esm/core/transport.js.map +1 -0
- package/dist/esm/core/util.d.ts +25 -0
- package/dist/esm/core/util.js +128 -0
- package/dist/esm/core/util.js.map +1 -0
- package/dist/esm/core/ws.d.ts +52 -0
- package/dist/esm/core/ws.js +175 -0
- package/dist/esm/core/ws.js.map +1 -0
- package/dist/esm/generated/client.d.ts +62 -0
- package/dist/esm/generated/client.js +126 -0
- package/dist/esm/generated/client.js.map +1 -0
- package/dist/esm/generated/errors.d.ts +4 -0
- package/dist/esm/generated/errors.js +157 -0
- package/dist/esm/generated/errors.js.map +1 -0
- package/dist/esm/generated/ids.d.ts +114 -0
- package/dist/esm/generated/ids.js +42 -0
- package/dist/esm/generated/ids.js.map +1 -0
- package/dist/esm/generated/jobs.d.ts +10 -0
- package/dist/esm/generated/jobs.js +21 -0
- package/dist/esm/generated/jobs.js.map +1 -0
- package/dist/esm/generated/ns/actions.d.ts +161 -0
- package/dist/esm/generated/ns/actions.js +300 -0
- package/dist/esm/generated/ns/actions.js.map +1 -0
- package/dist/esm/generated/ns/infer.d.ts +190 -0
- package/dist/esm/generated/ns/infer.js +249 -0
- package/dist/esm/generated/ns/infer.js.map +1 -0
- package/dist/esm/generated/ns/keys.d.ts +76 -0
- package/dist/esm/generated/ns/keys.js +140 -0
- package/dist/esm/generated/ns/keys.js.map +1 -0
- package/dist/esm/generated/ns/limits.d.ts +22 -0
- package/dist/esm/generated/ns/limits.js +28 -0
- package/dist/esm/generated/ns/limits.js.map +1 -0
- package/dist/esm/generated/ns/orgs.d.ts +38 -0
- package/dist/esm/generated/ns/orgs.js +64 -0
- package/dist/esm/generated/ns/orgs.js.map +1 -0
- package/dist/esm/generated/ns/projects.d.ts +57 -0
- package/dist/esm/generated/ns/projects.js +111 -0
- package/dist/esm/generated/ns/projects.js.map +1 -0
- package/dist/esm/generated/ns/render.d.ts +159 -0
- package/dist/esm/generated/ns/render.js +295 -0
- package/dist/esm/generated/ns/render.js.map +1 -0
- package/dist/esm/generated/ns/requests.d.ts +36 -0
- package/dist/esm/generated/ns/requests.js +50 -0
- package/dist/esm/generated/ns/requests.js.map +1 -0
- package/dist/esm/generated/ns/routines.d.ts +212 -0
- package/dist/esm/generated/ns/routines.js +415 -0
- package/dist/esm/generated/ns/routines.js.map +1 -0
- package/dist/esm/generated/ns/sandboxes.d.ts +318 -0
- package/dist/esm/generated/ns/sandboxes.js +545 -0
- package/dist/esm/generated/ns/sandboxes.js.map +1 -0
- package/dist/esm/generated/ns/usage.d.ts +30 -0
- package/dist/esm/generated/ns/usage.js +45 -0
- package/dist/esm/generated/ns/usage.js.map +1 -0
- package/dist/esm/generated/ns/vault.d.ts +69 -0
- package/dist/esm/generated/ns/vault.js +118 -0
- package/dist/esm/generated/ns/vault.js.map +1 -0
- package/dist/esm/generated/ns/vision.d.ts +376 -0
- package/dist/esm/generated/ns/vision.js +732 -0
- package/dist/esm/generated/ns/vision.js.map +1 -0
- package/dist/esm/generated/ns/webhooks.d.ts +50 -0
- package/dist/esm/generated/ns/webhooks.js +87 -0
- package/dist/esm/generated/ns/webhooks.js.map +1 -0
- package/dist/esm/generated/types.d.ts +4613 -0
- package/dist/esm/generated/types.js +3 -0
- package/dist/esm/generated/types.js.map +1 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.js +28 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/webhooks.d.ts +19 -0
- package/dist/esm/webhooks.js +79 -0
- package/dist/esm/webhooks.js.map +1 -0
- package/package.json +97 -3
- package/src/core/client.ts +1022 -0
- package/src/core/errors.ts +296 -0
- package/src/core/index.ts +45 -0
- package/src/core/jobs.ts +94 -0
- package/src/core/namespace.ts +10 -0
- package/src/core/op.ts +53 -0
- package/src/core/promise.ts +268 -0
- package/src/core/response.ts +115 -0
- package/src/core/sse.ts +305 -0
- package/src/core/timing.ts +106 -0
- package/src/core/transport.ts +489 -0
- package/src/core/util.ts +138 -0
- package/src/core/ws.ts +215 -0
- package/src/generated/client.ts +143 -0
- package/src/generated/errors.ts +313 -0
- package/src/generated/ids.ts +47 -0
- package/src/generated/jobs.ts +25 -0
- package/src/generated/ns/actions.ts +353 -0
- package/src/generated/ns/infer.ts +332 -0
- package/src/generated/ns/keys.ts +152 -0
- package/src/generated/ns/limits.ts +35 -0
- package/src/generated/ns/orgs.ts +77 -0
- package/src/generated/ns/projects.ts +122 -0
- package/src/generated/ns/render.ts +348 -0
- package/src/generated/ns/requests.ts +61 -0
- package/src/generated/ns/routines.ts +474 -0
- package/src/generated/ns/sandboxes.ts +671 -0
- package/src/generated/ns/usage.ts +56 -0
- package/src/generated/ns/vault.ts +136 -0
- package/src/generated/ns/vision.ts +836 -0
- package/src/generated/ns/webhooks.ts +100 -0
- package/src/generated/types.ts +5131 -0
- package/src/index.ts +30 -0
- package/src/webhooks.ts +100 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import type { BinaryInput, RequestOptions, StreamOptions } from "../../core/client.ts";
|
|
2
|
+
import { Namespace } from "../../core/namespace.ts";
|
|
3
|
+
import type { Op } from "../../core/op.ts";
|
|
4
|
+
import type { APIPromise, ListPromise } from "../../core/promise.ts";
|
|
5
|
+
import type { EventStream } from "../../core/sse.ts";
|
|
6
|
+
import { PtySession } from "../../core/ws.ts";
|
|
7
|
+
import type * as T from "../types.ts";
|
|
8
|
+
/** Descriptors of every sandboxes operation, keyed by method name (for tooling and custom clients). */
|
|
9
|
+
export declare const sandboxesOps: {
|
|
10
|
+
readonly listSandboxes: Op;
|
|
11
|
+
readonly createSandbox: Op;
|
|
12
|
+
readonly listSnapshots: Op;
|
|
13
|
+
readonly deleteSnapshot: Op;
|
|
14
|
+
readonly getSnapshot: Op;
|
|
15
|
+
readonly listTemplates: Op;
|
|
16
|
+
readonly getTemplate: Op;
|
|
17
|
+
readonly deleteSandbox: Op;
|
|
18
|
+
readonly getSandbox: Op;
|
|
19
|
+
readonly exec: Op;
|
|
20
|
+
readonly readFile: Op;
|
|
21
|
+
readonly writeFile: Op;
|
|
22
|
+
readonly forkSandbox: Op;
|
|
23
|
+
readonly streamLogs: Op;
|
|
24
|
+
readonly pauseSandbox: Op;
|
|
25
|
+
readonly createPortUrl: Op;
|
|
26
|
+
readonly listProcesses: Op;
|
|
27
|
+
readonly killProcess: Op;
|
|
28
|
+
readonly openPty: Op;
|
|
29
|
+
readonly resumeSandbox: Op;
|
|
30
|
+
readonly runCode: Op;
|
|
31
|
+
readonly createSnapshot: Op;
|
|
32
|
+
readonly createTicket: Op;
|
|
33
|
+
readonly setTimeout: Op;
|
|
34
|
+
};
|
|
35
|
+
/** Firecracker microVM sandboxes: exec, files, terminals, ports, snapshots (`/v1/sandboxes`). */
|
|
36
|
+
export declare class SandboxesAPI extends Namespace {
|
|
37
|
+
/**
|
|
38
|
+
* List sandboxes
|
|
39
|
+
*
|
|
40
|
+
* Lists sandboxes in this project, newest first, including stopped ones from the last 7 days.
|
|
41
|
+
*
|
|
42
|
+
* `GET /v1/sandboxes` · scope `sandboxes:read` · served by the node
|
|
43
|
+
*/
|
|
44
|
+
listSandboxes(params?: T.SandboxesListSandboxesParams, options?: RequestOptions): ListPromise<T.SandboxList, T.Sandbox>;
|
|
45
|
+
/**
|
|
46
|
+
* Create a sandbox
|
|
47
|
+
*
|
|
48
|
+
* Claims a pre-warmed microVM from the template's pool (or restores a snapshot), binds a fresh identity to it
|
|
49
|
+
* (new entropy, machine ID and clock) and returns it running. The sandbox stops when `timeout_s` passes unless
|
|
50
|
+
* you extend it, and `on_idle: pause` pauses it instead. It bills `sandboxes.vcpu_ms` (CPU used) and
|
|
51
|
+
* `sandboxes.gib_ms` (memory allocated) while running.
|
|
52
|
+
*
|
|
53
|
+
* `api` grants code inside the sandbox access to B3OS (`http://127.0.0.1:7700`) with scopes that must be a
|
|
54
|
+
* subset of yours; `sandboxes:write`, every `vault:*` and every `platform:*` scope are never granted unless named
|
|
55
|
+
* explicitly. `api.spend_cap_usd` may not exceed your own spend cap, and `null` means your cap applies; scopes
|
|
56
|
+
* or a cap beyond yours are refused with `403 forbidden`, `reason: scope_escalation`.
|
|
57
|
+
*
|
|
58
|
+
* Inside the sandbox the environment also has `B3OS_API_URL=http://127.0.0.1:7700`, `B3OS_SANDBOX_ID`,
|
|
59
|
+
* `B3OS_PROJECT` and `B3OS_PORT_BASE_PATH=/sbx/<host_id>`. `B3OS_PORT_BASE_PATH` is only the fixed start of
|
|
60
|
+
* every port preview path on `usercontent.b3os.org`, not a full base path: the full prefix of a request,
|
|
61
|
+
* `/sbx/<host_id>/<port>/<token>`, arrives with it in `X-Forwarded-Prefix` (`sandboxesProxyPortGet`).
|
|
62
|
+
*
|
|
63
|
+
* `timing` phases: `validate_ms`, then `claim_ms` and `resume_ms` for a pre-warmed microVM from the pool, or
|
|
64
|
+
* `restore_ms` when none was parked (a restore on demand, or from a snapshot), then `bind_ms` (the identity
|
|
65
|
+
* and environment reach the guest agent), and `total_ms`.
|
|
66
|
+
*
|
|
67
|
+
* A create that has started finishes even if the client disconnects before the response: the sandbox then
|
|
68
|
+
* runs (and is billed) until its timeout or a delete, and `GET /v1/sandboxes` lists it with the `metadata`
|
|
69
|
+
* it was created with. After a disconnect, look for it there before you retry: a retry is a new create, also
|
|
70
|
+
* with the same `Idempotency-Key`, because the key is released when the client goes away before the
|
|
71
|
+
* response. Fork, snapshot, pause and resume also finish after a disconnect.
|
|
72
|
+
*
|
|
73
|
+
* `POST /v1/sandboxes` · scope `sandboxes:write` · served by the node
|
|
74
|
+
*/
|
|
75
|
+
createSandbox(body?: T.SandboxCreateRequest, options?: RequestOptions): APIPromise<T.Sandbox>;
|
|
76
|
+
/**
|
|
77
|
+
* List snapshots
|
|
78
|
+
*
|
|
79
|
+
* Lists snapshots in this project, newest first.
|
|
80
|
+
*
|
|
81
|
+
* `GET /v1/sandboxes/snapshots` · scope `sandboxes:read` · served by the node
|
|
82
|
+
*/
|
|
83
|
+
listSnapshots(params?: T.SandboxesListSnapshotsParams, options?: RequestOptions): ListPromise<T.SnapshotList, T.Snapshot>;
|
|
84
|
+
/**
|
|
85
|
+
* Delete a snapshot
|
|
86
|
+
*
|
|
87
|
+
* Deletes the snapshot. Sandboxes already restored from it keep running.
|
|
88
|
+
*
|
|
89
|
+
* `DELETE /v1/sandboxes/snapshots/{snapshot_id}` · scope `sandboxes:write` · served by the node
|
|
90
|
+
*/
|
|
91
|
+
deleteSnapshot(snapshotId: string, options?: RequestOptions): APIPromise<T.Deleted>;
|
|
92
|
+
/**
|
|
93
|
+
* Get a snapshot
|
|
94
|
+
*
|
|
95
|
+
* Returns a snapshot's metadata and status.
|
|
96
|
+
*
|
|
97
|
+
* `GET /v1/sandboxes/snapshots/{snapshot_id}` · scope `sandboxes:read` · served by the node
|
|
98
|
+
*/
|
|
99
|
+
getSnapshot(snapshotId: string, options?: RequestOptions): APIPromise<T.Snapshot>;
|
|
100
|
+
/**
|
|
101
|
+
* List templates
|
|
102
|
+
*
|
|
103
|
+
* Lists the templates sandboxes can start from (`base`, `code-interpreter`, `agent`, and on nodes that build it
|
|
104
|
+
* `browser`: Chrome already running in the snapshot, a VM-isolated browser with DevTools on port 9222) with their
|
|
105
|
+
* contents and defaults.
|
|
106
|
+
*
|
|
107
|
+
* `GET /v1/sandboxes/templates` · scope `sandboxes:read` · served by the node
|
|
108
|
+
*/
|
|
109
|
+
listTemplates(options?: RequestOptions): APIPromise<T.TemplateList>;
|
|
110
|
+
/**
|
|
111
|
+
* Get a template
|
|
112
|
+
*
|
|
113
|
+
* Returns one template by name (`base`) or ID (`tpl_…`).
|
|
114
|
+
*
|
|
115
|
+
* `GET /v1/sandboxes/templates/{template}` · scope `sandboxes:read` · served by the node
|
|
116
|
+
*/
|
|
117
|
+
getTemplate(template: string, options?: RequestOptions): APIPromise<T.Template>;
|
|
118
|
+
/**
|
|
119
|
+
* Delete a sandbox
|
|
120
|
+
*
|
|
121
|
+
* Stops the sandbox and destroys its memory and disk. Snapshots taken from it are kept. Returns the stopped sandbox with its final usage.
|
|
122
|
+
*
|
|
123
|
+
* `DELETE /v1/sandboxes/{sandbox_id}` · scope `sandboxes:write` · served by the node
|
|
124
|
+
*/
|
|
125
|
+
deleteSandbox(sandboxId: string, options?: RequestOptions): APIPromise<T.Sandbox>;
|
|
126
|
+
/**
|
|
127
|
+
* Get a sandbox
|
|
128
|
+
*
|
|
129
|
+
* Returns the sandbox with its status, expiry, ports and usage so far.
|
|
130
|
+
*
|
|
131
|
+
* `GET /v1/sandboxes/{sandbox_id}` · scope `sandboxes:read` · served by the node
|
|
132
|
+
*/
|
|
133
|
+
getSandbox(sandboxId: string, options?: RequestOptions): APIPromise<T.Sandbox>;
|
|
134
|
+
/**
|
|
135
|
+
* Run a command
|
|
136
|
+
*
|
|
137
|
+
* Runs a command in the sandbox. By default the response waits for it to exit (at most `timeout_ms`, up to 60
|
|
138
|
+
* seconds) and returns its exit code and output. With `?stream=true` (or `Accept: text/event-stream`) output
|
|
139
|
+
* arrives as `exec.stdout` and `exec.stderr` events while it runs, ending with `exec.exit`; streamed commands
|
|
140
|
+
* may run up to an hour. With `background: true` the response returns at once with the process, whose output
|
|
141
|
+
* you read from `GET /v1/sandboxes/{sandbox_id}/logs`.
|
|
142
|
+
*
|
|
143
|
+
* `cmd` as a string runs through `/bin/sh -c`; as an array it is executed directly. Output is UTF-8 (invalid
|
|
144
|
+
* bytes become U+FFFD) and each stream is capped at 1 MiB in a buffered response.
|
|
145
|
+
*
|
|
146
|
+
* `POST /v1/sandboxes/{sandbox_id}/exec` · scope `sandboxes:run` · served by the node
|
|
147
|
+
*/
|
|
148
|
+
exec(sandboxId: string, body: T.ExecRequest & {
|
|
149
|
+
background: true;
|
|
150
|
+
}, options?: RequestOptions): APIPromise<T.SandboxProcess>;
|
|
151
|
+
exec(sandboxId: string, body: T.ExecRequest, options: StreamOptions & {
|
|
152
|
+
stream: true;
|
|
153
|
+
}): EventStream<T.ExecEvent>;
|
|
154
|
+
exec(sandboxId: string, body: T.ExecRequest, options?: RequestOptions & {
|
|
155
|
+
stream?: false;
|
|
156
|
+
}): APIPromise<T.ExecResult>;
|
|
157
|
+
/**
|
|
158
|
+
* Read a file or list a directory
|
|
159
|
+
*
|
|
160
|
+
* Returns the file at `path` as bytes. With `list=1` returns the directory's entries (or the single entry
|
|
161
|
+
* when `path` is a file) as JSON instead. Transfers are capped at 64 MiB.
|
|
162
|
+
*
|
|
163
|
+
* `GET /v1/sandboxes/{sandbox_id}/files` · scope `sandboxes:run` · served by the node
|
|
164
|
+
*/
|
|
165
|
+
readFile(sandboxId: string, params: T.SandboxesReadFileParams & {
|
|
166
|
+
list: 1;
|
|
167
|
+
}, options?: RequestOptions): APIPromise<T.FileEntryList>;
|
|
168
|
+
readFile(sandboxId: string, params: T.SandboxesReadFileParams & {
|
|
169
|
+
list?: 0;
|
|
170
|
+
}, options?: RequestOptions): APIPromise<Uint8Array>;
|
|
171
|
+
/**
|
|
172
|
+
* Write a file
|
|
173
|
+
*
|
|
174
|
+
* Writes the request body to `path`, replacing any existing file, creating parent directories with `mkdir=1`.
|
|
175
|
+
* Returns the file's entry. Up to 64 MiB per request.
|
|
176
|
+
*
|
|
177
|
+
* `PUT /v1/sandboxes/{sandbox_id}/files` · scope `sandboxes:run` · served by the node
|
|
178
|
+
*/
|
|
179
|
+
writeFile(sandboxId: string, params: T.SandboxesWriteFileParams, data: BinaryInput, options?: RequestOptions): APIPromise<T.FileEntry>;
|
|
180
|
+
/**
|
|
181
|
+
* Fork a sandbox
|
|
182
|
+
*
|
|
183
|
+
* Creates `count` new running sandboxes that share the source's memory and disk copy-on-write, each with a fresh
|
|
184
|
+
* identity (its own id, entropy, machine ID and clock; the source's environment, secrets, files and running
|
|
185
|
+
* processes carry over). The source must have been created with `forkable: true` (forkable sandboxes are
|
|
186
|
+
* restored for themselves rather than claimed from a pool, and track the pages they change); forks are
|
|
187
|
+
* forkable too. The source pauses while its changed memory is written (`pause`, `base`, `snapshot`, `export`
|
|
188
|
+
* phases in `Server-Timing`), then runs on; like a snapshot this resets its open connections to the outside.
|
|
189
|
+
* Each fork counts against your sandbox concurrency.
|
|
190
|
+
*
|
|
191
|
+
* `POST /v1/sandboxes/{sandbox_id}/fork` · scope `sandboxes:write` · served by the node
|
|
192
|
+
*
|
|
193
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
194
|
+
*/
|
|
195
|
+
forkSandbox(sandboxId: string, body?: T.ForkRequest, options?: RequestOptions): APIPromise<T.SandboxList>;
|
|
196
|
+
/**
|
|
197
|
+
* Stream process logs
|
|
198
|
+
*
|
|
199
|
+
* Server-sent events with the output of background processes: `log.stdout` and `log.stderr` per chunk and
|
|
200
|
+
* `process.exited` when one ends. Starts with up to 1 MiB of buffered output per process, then follows new
|
|
201
|
+
* output until the sandbox stops (or immediately ends with `follow=false`). Filter to one process with `pid`.
|
|
202
|
+
* Authenticate with the `Authorization` header or a ticket from `POST /v1/sandboxes/{sandbox_id}/ticket`
|
|
203
|
+
* (`?ticket=`, for `EventSource`).
|
|
204
|
+
*
|
|
205
|
+
* `GET /v1/sandboxes/{sandbox_id}/logs` · scope `sandboxes:run` · served by the node
|
|
206
|
+
*/
|
|
207
|
+
streamLogs(sandboxId: string, params?: T.SandboxesStreamLogsParams, options?: StreamOptions): EventStream<T.LogEvent>;
|
|
208
|
+
/**
|
|
209
|
+
* Pause a sandbox
|
|
210
|
+
*
|
|
211
|
+
* Freezes the sandbox's vCPUs and keeps its memory and disk on the node. A paused sandbox bills no CPU time
|
|
212
|
+
* and still counts allocated memory; it still expires at `expires_at`. Resume continues exactly where it
|
|
213
|
+
* stopped. Pausing a paused sandbox returns it unchanged.
|
|
214
|
+
*
|
|
215
|
+
* `POST /v1/sandboxes/{sandbox_id}/pause` · scope `sandboxes:write` · served by the node
|
|
216
|
+
*/
|
|
217
|
+
pauseSandbox(sandboxId: string, options?: RequestOptions): APIPromise<T.Sandbox>;
|
|
218
|
+
/**
|
|
219
|
+
* Get a URL for a port
|
|
220
|
+
*
|
|
221
|
+
* Returns a URL that reaches `port` inside the sandbox:
|
|
222
|
+
* `https://usercontent.b3os.org/sbx/<host_id>/<port>/<token>/`. The token in the path is signed by the node and
|
|
223
|
+
* expires after `ttl_s` (10 minutes by default, at most 24 hours); anyone with the URL reaches the port until
|
|
224
|
+
* then, with no cookie or other credential. For a public port the response is the sandbox's long-lived URL
|
|
225
|
+
* (`ports[].url`) and `ttl_s` is ignored. The port must be declared in `ports` when the sandbox is created. The
|
|
226
|
+
* app sees the URL's base path in `X-Forwarded-Prefix` on every request (token format and forwarding:
|
|
227
|
+
* `sandboxesProxyPortGet`).
|
|
228
|
+
*
|
|
229
|
+
* `POST /v1/sandboxes/{sandbox_id}/ports/{port}/url` · scope `sandboxes:run` · served by the node
|
|
230
|
+
*/
|
|
231
|
+
createPortUrl(sandboxId: string, port: number, body?: T.PortUrlRequest, options?: RequestOptions): APIPromise<T.PortUrl>;
|
|
232
|
+
/**
|
|
233
|
+
* List background processes
|
|
234
|
+
*
|
|
235
|
+
* Lists processes started with `background: true`, running or exited, newest first.
|
|
236
|
+
*
|
|
237
|
+
* `GET /v1/sandboxes/{sandbox_id}/processes` · scope `sandboxes:run` · served by the node
|
|
238
|
+
*/
|
|
239
|
+
listProcesses(sandboxId: string, options?: RequestOptions): APIPromise<T.SandboxProcessList>;
|
|
240
|
+
/**
|
|
241
|
+
* Signal a background process
|
|
242
|
+
*
|
|
243
|
+
* Sends a signal (default `TERM`) to a background process and its process group, and returns the process.
|
|
244
|
+
*
|
|
245
|
+
* `POST /v1/sandboxes/{sandbox_id}/processes/{pid}/kill` · scope `sandboxes:run` · served by the node
|
|
246
|
+
*/
|
|
247
|
+
killProcess(sandboxId: string, pid: number, body?: T.KillRequest, options?: RequestOptions): APIPromise<T.SandboxProcess>;
|
|
248
|
+
/**
|
|
249
|
+
* Open a terminal
|
|
250
|
+
*
|
|
251
|
+
* Opens a WebSocket attached to a new pseudo-terminal running the user's login shell (or `cmd`). Binary frames
|
|
252
|
+
* carry terminal bytes in both directions. Text frames carry JSON control messages: send
|
|
253
|
+
* `{"type": "resize", "cols": 120, "rows": 40}`; the server sends `{"type": "exit", "code": 0}` before it closes.
|
|
254
|
+
* Authenticate with the `Authorization` header or a ticket from `POST /v1/sandboxes/{sandbox_id}/ticket`.
|
|
255
|
+
*
|
|
256
|
+
* `GET /v1/sandboxes/{sandbox_id}/pty` · scope `sandboxes:run` · served by the node
|
|
257
|
+
*/
|
|
258
|
+
openPty(sandboxId: string, params?: T.SandboxesOpenPtyParams, options?: RequestOptions): Promise<PtySession>;
|
|
259
|
+
/**
|
|
260
|
+
* Resume a sandbox
|
|
261
|
+
*
|
|
262
|
+
* Resumes a paused sandbox. Processes continue where they were, and the guest clock is corrected. Resuming a
|
|
263
|
+
* running sandbox returns it unchanged. A resumed sandbox is billed again (`sandboxes.gib_ms`), so a resume is
|
|
264
|
+
* admitted like a create (credits, spend cap).
|
|
265
|
+
*
|
|
266
|
+
* `POST /v1/sandboxes/{sandbox_id}/resume` · scope `sandboxes:write` · served by the node
|
|
267
|
+
*/
|
|
268
|
+
resumeSandbox(sandboxId: string, options?: RequestOptions): APIPromise<T.Sandbox>;
|
|
269
|
+
/**
|
|
270
|
+
* Run code in a kernel
|
|
271
|
+
*
|
|
272
|
+
* Runs code in the sandbox's Jupyter kernel and returns its rich results (text, images, HTML, JSON), output
|
|
273
|
+
* and any error. State persists between calls, like cells in a notebook. Needs a sandbox created from the
|
|
274
|
+
* `code-interpreter` template.
|
|
275
|
+
*
|
|
276
|
+
* `POST /v1/sandboxes/{sandbox_id}/run_code` · scope `sandboxes:run` · served by the node
|
|
277
|
+
*/
|
|
278
|
+
runCode(sandboxId: string, body: T.RunCodeRequest, options?: RequestOptions): APIPromise<T.RunCodeResult>;
|
|
279
|
+
/**
|
|
280
|
+
* Snapshot a sandbox
|
|
281
|
+
*
|
|
282
|
+
* Saves the sandbox's memory and disk as a snapshot you can create new sandboxes from. The sandbox keeps
|
|
283
|
+
* running (it pauses for the copy). New sandboxes restored from a snapshot get a fresh identity, so two of them
|
|
284
|
+
* never share random state. Writing the snapshot resets the sandbox's open connections to the outside (open
|
|
285
|
+
* PTY sessions, streaming execs and log streams, port preview connections, outbound TCP connections); new
|
|
286
|
+
* ones work as soon as the call returns.
|
|
287
|
+
*
|
|
288
|
+
* Snapshots are kept 7 days. An organization keeps at most `sandboxes.snapshots_max` snapshots (beta: 20)
|
|
289
|
+
* per node, counting at most `sandboxes.snapshot_storage_max` (beta: 40 GiB). Each snapshot counts its
|
|
290
|
+
* sandbox's memory plus its disk size: the memory is stored whole, and the disk copy comes to hold every
|
|
291
|
+
* block the sandbox rewrites after the snapshot. Past either limit the snapshot is refused with
|
|
292
|
+
* `422 limit_exceeded` until you delete some. While the node's snapshot store is nearly full, snapshots and
|
|
293
|
+
* forks are refused with `503 capacity_unavailable`.
|
|
294
|
+
*
|
|
295
|
+
* `POST /v1/sandboxes/{sandbox_id}/snapshot` · scope `sandboxes:write` · served by the node
|
|
296
|
+
*/
|
|
297
|
+
createSnapshot(sandboxId: string, body?: T.SnapshotCreateRequest, options?: RequestOptions): APIPromise<T.Snapshot>;
|
|
298
|
+
/**
|
|
299
|
+
* Create a stream ticket
|
|
300
|
+
*
|
|
301
|
+
* Returns a single-use ticket, valid for 30 seconds, that opens one stream under this sandbox (the terminal
|
|
302
|
+
* WebSocket or the logs event stream) without a bearer header. Pass it as `?ticket=` or in
|
|
303
|
+
* `Sec-WebSocket-Protocol: b3os.v1, b3os.ticket.<ticket>`. The stream runs with this caller's scopes.
|
|
304
|
+
*
|
|
305
|
+
* `POST /v1/sandboxes/{sandbox_id}/ticket` · scope `sandboxes:read` · served by the node
|
|
306
|
+
*/
|
|
307
|
+
createTicket(sandboxId: string, options?: RequestOptions): APIPromise<T.StreamTicket>;
|
|
308
|
+
/**
|
|
309
|
+
* Extend a sandbox's timeout
|
|
310
|
+
*
|
|
311
|
+
* Sets the sandbox to expire `timeout_s` seconds from now (up to your plan's maximum lifetime). Works on running
|
|
312
|
+
* and paused sandboxes. A longer life is billed (`sandboxes.vcpu_ms`, `sandboxes.gib_ms`), so the call is
|
|
313
|
+
* admitted like a create (credits, spend cap).
|
|
314
|
+
*
|
|
315
|
+
* `POST /v1/sandboxes/{sandbox_id}/timeout` · scope `sandboxes:write` · served by the node
|
|
316
|
+
*/
|
|
317
|
+
setTimeout(sandboxId: string, body: T.TimeoutRequest, options?: RequestOptions): APIPromise<T.Sandbox>;
|
|
318
|
+
}
|