@aerol-ai/aerolvm-sdk 0.8.1 → 0.8.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/dist/MicroVM.d.ts +133 -51
- package/dist/MicroVM.js +207 -99
- package/dist/errors.d.ts +52 -0
- package/dist/errors.js +89 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -1
- package/dist/internal/client.d.ts +253 -33
- package/dist/internal/client.js +1249 -91
- package/dist/internal/tar.d.ts +14 -0
- package/dist/internal/tar.js +79 -0
- package/dist/types.d.ts +448 -2
- package/package.json +1 -1
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { Image } from "../Image.js";
|
|
2
|
-
import type { AddCustomDomainOptions, APITokenList, BinaryLike, BuildImageOptions, BuildImageResult, CreateAPITokenOptions, CreatedAPIToken, CreateOptions, CreateSessionOptions, CreateTemplateOptions, CreateWasmModuleOptions, PushWasmModuleOptions, PushWasmModuleResult, CustomDomain, CloneGeneration, CustomDomainDNSRecords, ExecRequest, ExecResult, ExecStreamHandle, ExecStreamOptions, ExposedPort, ExposePortOptions, ExposeResult, Failover, HealthStatus, IngressTarget, Lifecycle, GetOptions, ListOptions, MountSpecRedacted, NetworkUsage, AuditOptions, AuditPage, EgressProfile, EgressProfileList, EgressProfileOptions, EgressProfileRef, EgressRule, ListEgressProfilesOptions, NetworkLearned, NetworkPolicy, NetworkPolicyCheckOptions, NetworkPolicyCheckResult, NetworkPolicyOptions, ListSnapshotsOptions, CreateSnapshotOptions, RegisterSnapshotOptions, SnapshotList, SetNetworkLimitsOptions, ResizeOptions, Sandbox, SandboxSnapshot, Session, SessionAttachHandle, SessionAttachOptions, Template, WasmModule, WhoAmI } from "../types.js";
|
|
2
|
+
import type { CallOptions, AddCustomDomainOptions, APITokenList, BinaryLike, BuildImageOptions, BuildImageResult, CreateAPITokenOptions, CreatedAPIToken, CreateOptions, CreateSandboxTokenOptions, RevokeSandboxTokensResult, SandboxToken, CreateSessionOptions, CreateTemplateOptions, CreateWasmModuleOptions, PushWasmModuleOptions, PushWasmModuleResult, CustomDomain, CloneGeneration, CustomDomainDNSRecords, ExecRequest, ExecResult, ExecStreamHandle, ExecStreamOptions, ExposedPort, ExposePortOptions, ExposeResult, Failover, FileEvent, FileWatchHandle, FileInfo, FileList, FileMatch, UploadFileOptions, DownloadFileOptions, ListFilesOptions, DeleteFileOptions, MakeDirOptions, MoveFileOptions, CopyFileOptions, HealthStatus, IngressTarget, Lifecycle, GetOptions, ListOptions, MountSpecRedacted, NetworkUsage, AuditOptions, AuditPage, EgressProfile, EgressProfileList, EgressProfileOptions, EgressProfileRef, TeamQuota, TeamQuotaOptions, IdentityRole, IdentityRoleList, IdentityRoleOptions, ListIdentityRolesOptions, SandboxIdentity, EgressRule, ListEgressProfilesOptions, WarmPool, WarmPoolOptions, NetworkLearned, NetworkPolicy, NetworkPolicyCheckOptions, NetworkPolicyCheckResult, NetworkPolicyOptions, ListSnapshotsOptions, CreateSnapshotOptions, RegisterSnapshotOptions, SnapshotList, SetNetworkLimitsOptions, ResizeOptions, Sandbox, SandboxSnapshot, Session, SessionAttachHandle, SessionAttachOptions, StatusReason, Template, WasmModule, WhoAmI, WatchFilesOptions } from "../types.js";
|
|
3
3
|
type FetchLike = typeof fetch;
|
|
4
4
|
/**
|
|
5
5
|
* The request header that selects which of a credential's teams a request
|
|
6
6
|
* acts for. Keep in sync with pkg/api.HeaderTeam on the server.
|
|
7
7
|
*/
|
|
8
8
|
export declare const TEAM_HEADER = "X-AerolVM-Team";
|
|
9
|
+
/**
|
|
10
|
+
* The response header a 421 carries when the sandbox lives in another cell
|
|
11
|
+
* (a separate AerolVM install in the same federation): that cell's base URL.
|
|
12
|
+
* Keep in sync with models.CellEndpointHeader on the server.
|
|
13
|
+
*/
|
|
14
|
+
export declare const CELL_ENDPOINT_HEADER = "X-Aerolvm-Cell-Endpoint";
|
|
9
15
|
/**
|
|
10
16
|
* Wire version of the v1-style sandbox endpoints (`/v1/sandboxes`, etc.) this
|
|
11
17
|
* client speaks. The SDK and the server version independently — bumping the
|
|
@@ -81,6 +87,8 @@ export interface APIClientConfig {
|
|
|
81
87
|
*/
|
|
82
88
|
signal?: AbortSignal;
|
|
83
89
|
}
|
|
90
|
+
/** The entry cap `listFiles` sends when the caller gives none. */
|
|
91
|
+
export declare const DEFAULT_LIST_LIMIT = 10000;
|
|
84
92
|
/**
|
|
85
93
|
* The header a sandbox create carries so the server can recognise a retry of
|
|
86
94
|
* it. Keep in sync with clustercreate.HeaderIdempotencyKey on the server.
|
|
@@ -121,6 +129,22 @@ export declare class APIClient {
|
|
|
121
129
|
private readonly versionPrefix;
|
|
122
130
|
private readonly retryConfig;
|
|
123
131
|
private readonly signal;
|
|
132
|
+
/** The client a {@link withSignal} view was made from; unset on a real client. */
|
|
133
|
+
private readonly root;
|
|
134
|
+
/**
|
|
135
|
+
* Features each sandbox's agent listed on /version (requireToolboxFeatures).
|
|
136
|
+
* Refreshed on a miss, because a restart can bring a newer agent.
|
|
137
|
+
*/
|
|
138
|
+
private readonly toolboxFeatures;
|
|
139
|
+
/**
|
|
140
|
+
* The base URL of the cell each sandbox in another cell lives in, learned
|
|
141
|
+
* from a 421 that named it, oldest first. Shared with {@link withSignal}
|
|
142
|
+
* views, so what one call learns routes the next. Entries are dropped only
|
|
143
|
+
* on a 404 from that cell (the sandbox may be gone) or past
|
|
144
|
+
* {@link MAX_REMEMBERED_CELLS}: the cell is minted into the ID, so it
|
|
145
|
+
* never changes.
|
|
146
|
+
*/
|
|
147
|
+
private readonly sandboxCells;
|
|
124
148
|
constructor(config: APIClientConfig);
|
|
125
149
|
/**
|
|
126
150
|
* Build a versioned API path. Pass the suffix beginning with "/" (e.g.
|
|
@@ -129,6 +153,15 @@ export declare class APIClient {
|
|
|
129
153
|
* apiVersion option without touching call sites.
|
|
130
154
|
*/
|
|
131
155
|
private versioned;
|
|
156
|
+
/**
|
|
157
|
+
* This client with `signal` added to its own: either one aborting ends a
|
|
158
|
+
* request and any retry wait. A per-call signal (plan S6) rides on a view
|
|
159
|
+
* like this rather than a parameter on every internal method. The view
|
|
160
|
+
* shares everything else, the per-sandbox feature cache included, and the
|
|
161
|
+
* sandboxes it returns hold the real client, so the call's signal never
|
|
162
|
+
* outlives the call. Without a signal it is this client.
|
|
163
|
+
*/
|
|
164
|
+
withSignal(signal: AbortSignal | undefined): APIClient;
|
|
132
165
|
create(options: CreateOptions): Promise<SandboxResource>;
|
|
133
166
|
/**
|
|
134
167
|
* Compile a fluent {@link Image} into a content-addressed image tag by
|
|
@@ -154,6 +187,16 @@ export declare class APIClient {
|
|
|
154
187
|
* the wrong sandbox.
|
|
155
188
|
*/
|
|
156
189
|
getByName(name: string, options?: GetOptions): Promise<SandboxResource | null>;
|
|
190
|
+
/**
|
|
191
|
+
* The caller's sandbox called `name`, created from `options` when there is
|
|
192
|
+
* none; `created` is true only when this call made it. Safe to retry and to
|
|
193
|
+
* run concurrently: names are unique per owner, so a caller that loses a
|
|
194
|
+
* race to create the name gets a 409 and reads the winner's sandbox.
|
|
195
|
+
*/
|
|
196
|
+
getOrCreate(name: string, options: CreateOptions): Promise<{
|
|
197
|
+
sandbox: SandboxResource;
|
|
198
|
+
created: boolean;
|
|
199
|
+
}>;
|
|
157
200
|
get(id: string, options?: GetOptions): Promise<SandboxResource>;
|
|
158
201
|
start(id: string): Promise<SandboxResource>;
|
|
159
202
|
stop(id: string): Promise<SandboxResource>;
|
|
@@ -164,10 +207,38 @@ export declare class APIClient {
|
|
|
164
207
|
listSnapshots(options?: ListSnapshotsOptions): Promise<SnapshotList>;
|
|
165
208
|
deleteSnapshot(name: string): Promise<void>;
|
|
166
209
|
destroy(id: string): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Deletes every sandbox carrying all of `tags`, one at a time, after
|
|
212
|
+
* listing every page; returns the IDs now gone. A 404 counts as deleted,
|
|
213
|
+
* so the call is safe to repeat. Any other failure stops it and is thrown.
|
|
214
|
+
*/
|
|
215
|
+
destroyAll(tags: Record<string, string>): Promise<string[]>;
|
|
167
216
|
resize(id: string, options: ResizeOptions): Promise<SandboxResource>;
|
|
168
217
|
updateLifecycle(id: string, lifecycle: Lifecycle): Promise<SandboxResource>;
|
|
218
|
+
/**
|
|
219
|
+
* Fails closed unless the sandbox's agent lists every feature. toolboxd
|
|
220
|
+
* ignores request options it does not know, so sending a newer option to an
|
|
221
|
+
* older agent would silently skip it.
|
|
222
|
+
*/
|
|
223
|
+
requireToolboxFeatures(id: string, ...features: string[]): Promise<void>;
|
|
169
224
|
exec(id: string, request: ExecRequest): Promise<ExecResult>;
|
|
170
225
|
execStream(id: string, options: ExecStreamOptions): ExecStreamHandle;
|
|
226
|
+
/**
|
|
227
|
+
* Watch a folder in the sandbox for changes. Resolves once the watch is in
|
|
228
|
+
* place, so a change made after it resolves is reported. gVisor and
|
|
229
|
+
* Firecracker sandboxes only: the others answer 501. Not retried: a stream
|
|
230
|
+
* is opened once.
|
|
231
|
+
*/
|
|
232
|
+
watchFiles(id: string, path: string, onEvent: (event: FileEvent) => void, options?: WatchFilesOptions): Promise<FileWatchHandle>;
|
|
233
|
+
/**
|
|
234
|
+
* Explains a watch whose WebSocket handshake failed. The WebSocket API
|
|
235
|
+
* hides a refused handshake's status and body, so the same request is sent
|
|
236
|
+
* again as plain HTTP: toolboxd checks the runtime, the path and its limits
|
|
237
|
+
* before the upgrade, so it answers with the real reason (501 on Docker or
|
|
238
|
+
* containerd, 404 for a missing folder, 429 at the watch limit). That GET
|
|
239
|
+
* is a diagnosis, sent once, never a retry of the stream.
|
|
240
|
+
*/
|
|
241
|
+
private fileWatchRefusal;
|
|
171
242
|
createSession(id: string, options: CreateSessionOptions): Promise<Session>;
|
|
172
243
|
listSessions(id: string): Promise<Session[]>;
|
|
173
244
|
getSession(id: string, sessionID: string): Promise<Session>;
|
|
@@ -177,8 +248,50 @@ export declare class APIClient {
|
|
|
177
248
|
sessionLog(id: string, sessionID: string): Promise<Uint8Array>;
|
|
178
249
|
sessionRecording(id: string, sessionID: string): Promise<Uint8Array>;
|
|
179
250
|
attachSession(id: string, sessionID: string, options?: SessionAttachOptions): SessionAttachHandle;
|
|
180
|
-
|
|
181
|
-
|
|
251
|
+
/**
|
|
252
|
+
* Plain and atomic uploads retry on 421/429/502/503/504; `append` and
|
|
253
|
+
* `createOnly` only on 429/503, because a second send would append twice
|
|
254
|
+
* or find the first one's file.
|
|
255
|
+
*/
|
|
256
|
+
uploadFile(id: string, targetPath: string, data: BinaryLike, options?: UploadFileOptions): Promise<void>;
|
|
257
|
+
/** The upload route with the write options as query, after the /version check they need. */
|
|
258
|
+
private uploadPath;
|
|
259
|
+
/**
|
|
260
|
+
* Upload from a stream a piece at a time, so a large file never sits in
|
|
261
|
+
* memory. The options are {@link uploadFile}'s. The data is read as it is
|
|
262
|
+
* sent, so the request is sent once and never retried. Needs a `fetch` that
|
|
263
|
+
* can send a streamed body (Node.js 18 and later).
|
|
264
|
+
*/
|
|
265
|
+
uploadFileStream(id: string, targetPath: string, data: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>, options?: UploadFileOptions): Promise<void>;
|
|
266
|
+
/**
|
|
267
|
+
* Copy the local folder `localDir` into `remoteDir` in the sandbox (made if
|
|
268
|
+
* missing). The folder is packed as a gzipped tar and the sandbox unpacks it
|
|
269
|
+
* safely: no entry can land outside `remoteDir`. Symlinks are sent as links,
|
|
270
|
+
* hard-linked files as separate files; devices, pipes and sockets are
|
|
271
|
+
* skipped. The archive is built in memory and sent once, never retried.
|
|
272
|
+
* Node.js only.
|
|
273
|
+
*/
|
|
274
|
+
uploadDir(id: string, localDir: string, remoteDir: string): Promise<void>;
|
|
275
|
+
downloadFile(id: string, targetPath: string, options?: DownloadFileOptions): Promise<Uint8Array>;
|
|
276
|
+
/**
|
|
277
|
+
* Open a file for reading a piece at a time, so a large file never sits in
|
|
278
|
+
* memory. With `maxBytes`, a larger file is refused before reading when the
|
|
279
|
+
* server states the size, and otherwise the stream errors as soon as more
|
|
280
|
+
* arrives. The request retries until the file starts to arrive.
|
|
281
|
+
*/
|
|
282
|
+
downloadFileStream(id: string, targetPath: string, options?: DownloadFileOptions): Promise<ReadableStream<Uint8Array>>;
|
|
283
|
+
private toolboxPath;
|
|
284
|
+
/** Sends a body-less file call and discards a success reply. */
|
|
285
|
+
private fileCall;
|
|
286
|
+
listFiles(id: string, path: string, options?: ListFilesOptions): Promise<FileList>;
|
|
287
|
+
getFileInfo(id: string, path: string): Promise<FileInfo>;
|
|
288
|
+
fileExists(id: string, path: string): Promise<boolean>;
|
|
289
|
+
deleteFile(id: string, path: string, options?: DeleteFileOptions): Promise<void>;
|
|
290
|
+
makeDir(id: string, path: string, options?: MakeDirOptions): Promise<void>;
|
|
291
|
+
moveFile(id: string, source: string, destination: string, options?: MoveFileOptions): Promise<void>;
|
|
292
|
+
copyFile(id: string, source: string, destination: string, options?: CopyFileOptions): Promise<void>;
|
|
293
|
+
searchFiles(id: string, path: string, pattern: string): Promise<string[]>;
|
|
294
|
+
findInFiles(id: string, path: string, text: string): Promise<FileMatch[]>;
|
|
182
295
|
/**
|
|
183
296
|
* Publish a sandbox container port. The chosen wire protocol is selected by
|
|
184
297
|
* `options.protocol` (defaults to `"http"`):
|
|
@@ -194,6 +307,20 @@ export declare class APIClient {
|
|
|
194
307
|
*/
|
|
195
308
|
exposePort(id: string, port: number, options?: ExposePortOptions): Promise<ExposeResult>;
|
|
196
309
|
unexposePort(id: string, port: number): Promise<void>;
|
|
310
|
+
/**
|
|
311
|
+
* Issue a signed token scoped to one sandbox (POST /v1/sandboxes/{id}/tokens).
|
|
312
|
+
* Not idempotent by nature: every call makes a new token, and the server
|
|
313
|
+
* stores none. It uses the normal retry tier: a retry after a lost answer
|
|
314
|
+
* makes a second token that nobody holds, which simply expires.
|
|
315
|
+
*/
|
|
316
|
+
createSandboxToken(id: string, options: CreateSandboxTokenOptions): Promise<SandboxToken>;
|
|
317
|
+
/**
|
|
318
|
+
* Make every token issued for one sandbox so far stop working
|
|
319
|
+
* (POST /v1/sandboxes/{id}/tokens/revoke). A token issued after it works.
|
|
320
|
+
* Safe to retry: a repeated call refuses the same tokens again (plus any
|
|
321
|
+
* issued in between), so it uses the normal retry tier.
|
|
322
|
+
*/
|
|
323
|
+
revokeSandboxTokens(id: string): Promise<RevokeSandboxTokensResult>;
|
|
197
324
|
/**
|
|
198
325
|
* Bind a custom hostname to a sandbox. The server lowercases the hostname
|
|
199
326
|
* and returns the post-add list of bindings (sorted by hostname). Calling
|
|
@@ -228,6 +355,19 @@ export declare class APIClient {
|
|
|
228
355
|
getEgressProfile(name: string): Promise<EgressProfile>;
|
|
229
356
|
listEgressProfiles(options?: ListEgressProfilesOptions): Promise<EgressProfileList>;
|
|
230
357
|
deleteEgressProfile(name: string): Promise<void>;
|
|
358
|
+
putWarmPool(image: string, options: WarmPoolOptions): Promise<WarmPool>;
|
|
359
|
+
getWarmPool(image: string): Promise<WarmPool>;
|
|
360
|
+
listWarmPools(): Promise<WarmPool[]>;
|
|
361
|
+
deleteWarmPool(image: string): Promise<void>;
|
|
362
|
+
putIdentityRole(tag: string, options: IdentityRoleOptions): Promise<IdentityRole>;
|
|
363
|
+
listIdentityRoles(options?: ListIdentityRolesOptions): Promise<IdentityRoleList>;
|
|
364
|
+
deleteIdentityRole(tag: string, options?: {
|
|
365
|
+
team?: string;
|
|
366
|
+
}): Promise<void>;
|
|
367
|
+
private identityRolePath;
|
|
368
|
+
putTeamQuota(team: string, options: TeamQuotaOptions): Promise<TeamQuota>;
|
|
369
|
+
getTeamQuota(team: string): Promise<TeamQuota>;
|
|
370
|
+
deleteTeamQuota(team: string): Promise<void>;
|
|
231
371
|
createTemplate(options: CreateTemplateOptions): Promise<Template>;
|
|
232
372
|
listTemplates(): Promise<Template[]>;
|
|
233
373
|
getTemplate(id: string): Promise<Template>;
|
|
@@ -245,6 +385,7 @@ export declare class APIClient {
|
|
|
245
385
|
private wrap;
|
|
246
386
|
private doJSON;
|
|
247
387
|
private doBytes;
|
|
388
|
+
private authHeaders;
|
|
248
389
|
/**
|
|
249
390
|
* Low-level HTTP request with automatic retry for transient failures.
|
|
250
391
|
*
|
|
@@ -263,8 +404,24 @@ export declare class APIClient {
|
|
|
263
404
|
* A 429 or 503 waits as long as its `Retry-After` asks (see
|
|
264
405
|
* {@link retryDelayMs}). The client's `signal` ends the request and any
|
|
265
406
|
* wait.
|
|
407
|
+
*
|
|
408
|
+
* A 421 that names another cell ({@link CELL_ENDPOINT_HEADER}) is not
|
|
409
|
+
* retried in place: the same request goes once to that cell instead, and
|
|
410
|
+
* later requests for that sandbox go straight there.
|
|
266
411
|
*/
|
|
267
412
|
private request;
|
|
413
|
+
/** Where requests for sandbox `id` go: the cell it was found in, else the configured server. */
|
|
414
|
+
private baseURLFor;
|
|
415
|
+
private rememberCell;
|
|
416
|
+
/**
|
|
417
|
+
* The cell base URL a 421 names, or `undefined` when it names none this
|
|
418
|
+
* client may send its token to: not an absolute http(s) URL, or plain http
|
|
419
|
+
* while the client was configured for https, which would let one bad
|
|
420
|
+
* answer move the token to clear text.
|
|
421
|
+
*/
|
|
422
|
+
private cellEndpoint;
|
|
423
|
+
/** One request to `url` with the retry loop described on {@link request}. */
|
|
424
|
+
private send;
|
|
268
425
|
}
|
|
269
426
|
export declare class SandboxResource implements Sandbox {
|
|
270
427
|
id: string;
|
|
@@ -294,35 +451,97 @@ export declare class SandboxResource implements Sandbox {
|
|
|
294
451
|
name?: string;
|
|
295
452
|
tags?: Record<string, string>;
|
|
296
453
|
lastError?: string;
|
|
454
|
+
statusReason?: StatusReason;
|
|
455
|
+
exitCode?: number;
|
|
297
456
|
containerCommand?: string[];
|
|
298
457
|
lifecycle: Lifecycle;
|
|
299
458
|
failover?: Failover;
|
|
300
459
|
runtime: Sandbox["runtime"];
|
|
460
|
+
identity?: SandboxIdentity;
|
|
301
461
|
protected readonly client: APIClient;
|
|
462
|
+
/**
|
|
463
|
+
* When true, leaving an `await using` block deletes the sandbox (see
|
|
464
|
+
* `[Symbol.asyncDispose]`). Off by default, so the block ends without
|
|
465
|
+
* touching it; set it here or with `destroyOnExit` on `create` and
|
|
466
|
+
* `getOrCreate`.
|
|
467
|
+
*/
|
|
468
|
+
destroyOnExit: boolean;
|
|
469
|
+
private disposed;
|
|
470
|
+
/** The client for one call: the real one, or a view carrying the call's signal. */
|
|
471
|
+
private api;
|
|
302
472
|
constructor(client: APIClient, sandbox: Sandbox);
|
|
303
|
-
|
|
304
|
-
|
|
473
|
+
/**
|
|
474
|
+
* Called when an `await using` block holding this sandbox ends. Deletes the
|
|
475
|
+
* sandbox only when {@link destroyOnExit} is true; otherwise does nothing.
|
|
476
|
+
* A sandbox that is already gone counts as deleted, and a second call does
|
|
477
|
+
* nothing.
|
|
478
|
+
*/
|
|
479
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
480
|
+
refresh(call?: CallOptions): Promise<this>;
|
|
481
|
+
exec(command: string | ExecRequest, call?: CallOptions): Promise<ExecResult>;
|
|
305
482
|
/**
|
|
306
483
|
* Read this sandbox's clone-generation token. The token changes whenever the
|
|
307
484
|
* sandbox is resumed from a snapshot. Use it to detect that a sandbox is a
|
|
308
485
|
* clone (e.g. to re-run setup). It does NOT reseed in-guest PRNGs — see the
|
|
309
486
|
* "Randomness in cloned sandboxes" docs page for the in-guest pattern.
|
|
310
487
|
*/
|
|
311
|
-
cloneGeneration(): Promise<CloneGeneration>;
|
|
488
|
+
cloneGeneration(call?: CallOptions): Promise<CloneGeneration>;
|
|
312
489
|
execStream(options: ExecStreamOptions): ExecStreamHandle;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
490
|
+
/**
|
|
491
|
+
* Watch a folder in this sandbox for changes; see
|
|
492
|
+
* {@link APIClient.watchFiles}. gVisor and Firecracker sandboxes only.
|
|
493
|
+
*/
|
|
494
|
+
watchFiles(path: string, onEvent: (event: FileEvent) => void, options?: WatchFilesOptions): Promise<FileWatchHandle>;
|
|
495
|
+
createSession(options: CreateSessionOptions, call?: CallOptions): Promise<Session>;
|
|
496
|
+
listSessions(call?: CallOptions): Promise<Session[]>;
|
|
497
|
+
getSession(sessionID: string, call?: CallOptions): Promise<Session>;
|
|
498
|
+
deleteSession(sessionID: string, call?: CallOptions): Promise<void>;
|
|
499
|
+
signalSession(sessionID: string, signal: string, call?: CallOptions): Promise<void>;
|
|
500
|
+
resizeSession(sessionID: string, cols: number, rows: number, call?: CallOptions): Promise<void>;
|
|
501
|
+
sessionLog(sessionID: string, call?: CallOptions): Promise<Uint8Array>;
|
|
502
|
+
sessionRecording(sessionID: string, call?: CallOptions): Promise<Uint8Array>;
|
|
321
503
|
attachSession(sessionID: string, options?: SessionAttachOptions): SessionAttachHandle;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
504
|
+
/** Copy a local folder into the sandbox (Node.js only). See {@link APIClient.uploadDir}. */
|
|
505
|
+
uploadDir(localDir: string, remoteDir: string, call?: CallOptions): Promise<void>;
|
|
506
|
+
/** Upload a file. See {@link UploadFileOptions} for append, create-only, atomic and mode. */
|
|
507
|
+
uploadFile(targetPath: string, data: BinaryLike, options?: UploadFileOptions, call?: CallOptions): Promise<void>;
|
|
508
|
+
downloadFile(targetPath: string, options?: DownloadFileOptions, call?: CallOptions): Promise<Uint8Array>;
|
|
509
|
+
/** Read a file as a stream. See {@link APIClient.downloadFileStream}. */
|
|
510
|
+
downloadFileStream(targetPath: string, options?: DownloadFileOptions, call?: CallOptions): Promise<ReadableStream<Uint8Array>>;
|
|
511
|
+
/** Upload from a stream, sent once. See {@link APIClient.uploadFileStream}. */
|
|
512
|
+
uploadFileStream(targetPath: string, data: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>, options?: UploadFileOptions, call?: CallOptions): Promise<void>;
|
|
513
|
+
/** List a folder. See {@link ListFilesOptions}; `truncated` means more entries exist. */
|
|
514
|
+
listFiles(path: string, options?: ListFilesOptions, call?: CallOptions): Promise<FileList>;
|
|
515
|
+
/** Describe one path. A symlink is followed. */
|
|
516
|
+
getFileInfo(path: string, call?: CallOptions): Promise<FileInfo>;
|
|
517
|
+
/** Whether a path exists. A missing sandbox throws; it is not `false`. */
|
|
518
|
+
fileExists(path: string, call?: CallOptions): Promise<boolean>;
|
|
519
|
+
/** Delete a file, or a folder and its contents with `recursive: true`. */
|
|
520
|
+
deleteFile(path: string, options?: DeleteFileOptions, call?: CallOptions): Promise<void>;
|
|
521
|
+
/** Make a folder; with `parents: true`, like `mkdir -p`. */
|
|
522
|
+
makeDir(path: string, options?: MakeDirOptions, call?: CallOptions): Promise<void>;
|
|
523
|
+
/** Move or rename a file or folder. Without `overwrite`, an existing destination is refused (409). */
|
|
524
|
+
moveFile(source: string, destination: string, options?: MoveFileOptions, call?: CallOptions): Promise<void>;
|
|
525
|
+
/** Copy a file, or a folder with `recursive: true`. */
|
|
526
|
+
copyFile(source: string, destination: string, options?: CopyFileOptions, call?: CallOptions): Promise<void>;
|
|
527
|
+
/** Paths under `path` whose name matches a glob such as `*.ts`. */
|
|
528
|
+
searchFiles(path: string, pattern: string, call?: CallOptions): Promise<string[]>;
|
|
529
|
+
/** Each line under `path` that contains `text` (plain text). */
|
|
530
|
+
findInFiles(path: string, text: string, call?: CallOptions): Promise<FileMatch[]>;
|
|
531
|
+
exposePort(port: number, options?: ExposePortOptions, call?: CallOptions): Promise<ExposeResult>;
|
|
532
|
+
unexposePort(port: number, call?: CallOptions): Promise<void>;
|
|
533
|
+
/**
|
|
534
|
+
* Issue a signed token for this sandbox only, to hand to a browser or an
|
|
535
|
+
* end user. See {@link CreateSandboxTokenOptions}. Each call makes a new
|
|
536
|
+
* token; the server keeps no copy.
|
|
537
|
+
*/
|
|
538
|
+
createToken(options: CreateSandboxTokenOptions, call?: CallOptions): Promise<SandboxToken>;
|
|
539
|
+
/**
|
|
540
|
+
* Make every token issued for this sandbox so far stop working, toolbox
|
|
541
|
+
* and port tokens alike. A token made after the call works. Safe to call
|
|
542
|
+
* again.
|
|
543
|
+
*/
|
|
544
|
+
revokeTokens(call?: CallOptions): Promise<RevokeSandboxTokensResult>;
|
|
326
545
|
/**
|
|
327
546
|
* Per-sandbox custom-hostname bindings. Exposed as a namespaced accessor
|
|
328
547
|
* (rather than `addCustomDomain`/`removeCustomDomain`/`listCustomDomains`
|
|
@@ -332,38 +551,39 @@ export declare class SandboxResource implements Sandbox {
|
|
|
332
551
|
* so the closures always see the current `id` even after `refresh()`.
|
|
333
552
|
*/
|
|
334
553
|
get customDomains(): {
|
|
335
|
-
add(hostname: string, options?: AddCustomDomainOptions): Promise<CustomDomain[]>;
|
|
336
|
-
remove(hostname: string): Promise<void>;
|
|
337
|
-
list(): Promise<CustomDomain[]>;
|
|
338
|
-
dns(): Promise<CustomDomainDNSRecords>;
|
|
554
|
+
add(hostname: string, options?: AddCustomDomainOptions, call?: CallOptions): Promise<CustomDomain[]>;
|
|
555
|
+
remove(hostname: string, call?: CallOptions): Promise<void>;
|
|
556
|
+
list(call?: CallOptions): Promise<CustomDomain[]>;
|
|
557
|
+
dns(call?: CallOptions): Promise<CustomDomainDNSRecords>;
|
|
339
558
|
};
|
|
340
|
-
createSnapshot(name: string, options?: CreateSnapshotOptions): Promise<SandboxSnapshot>;
|
|
341
|
-
start(): Promise<this>;
|
|
342
|
-
stop(): Promise<this>;
|
|
343
|
-
destroy(): Promise<void>;
|
|
344
|
-
resize(options: ResizeOptions): Promise<this>;
|
|
345
|
-
updateLifecycle(lifecycle: Lifecycle): Promise<this>;
|
|
346
|
-
getNetworkUsage(): Promise<NetworkUsage>;
|
|
347
|
-
setNetworkLimits(options: SetNetworkLimitsOptions): Promise<NetworkUsage>;
|
|
559
|
+
createSnapshot(name: string, options?: CreateSnapshotOptions, call?: CallOptions): Promise<SandboxSnapshot>;
|
|
560
|
+
start(call?: CallOptions): Promise<this>;
|
|
561
|
+
stop(call?: CallOptions): Promise<this>;
|
|
562
|
+
destroy(call?: CallOptions): Promise<void>;
|
|
563
|
+
resize(options: ResizeOptions, call?: CallOptions): Promise<this>;
|
|
564
|
+
updateLifecycle(lifecycle: Lifecycle, call?: CallOptions): Promise<this>;
|
|
565
|
+
getNetworkUsage(call?: CallOptions): Promise<NetworkUsage>;
|
|
566
|
+
setNetworkLimits(options: SetNetworkLimitsOptions, call?: CallOptions): Promise<NetworkUsage>;
|
|
348
567
|
/**
|
|
349
568
|
* Replaces this sandbox's egress policy while it runs. The call returns
|
|
350
569
|
* once the new policy is enforced; sending the same policy again is a
|
|
351
570
|
* no-op, so it is safe to retry.
|
|
352
571
|
*/
|
|
353
|
-
setNetworkPolicy(options: NetworkPolicyOptions): Promise<NetworkPolicy>;
|
|
572
|
+
setNetworkPolicy(options: NetworkPolicyOptions, call?: CallOptions): Promise<NetworkPolicy>;
|
|
354
573
|
/**
|
|
355
574
|
* Reads what this sandbox reached in learn mode and the allow list that
|
|
356
575
|
* would have allowed it. A recording stays readable after the sandbox
|
|
357
576
|
* switches to enforce, until it is destroyed.
|
|
358
577
|
*/
|
|
359
|
-
learned(): Promise<NetworkLearned>;
|
|
578
|
+
learned(call?: CallOptions): Promise<NetworkLearned>;
|
|
360
579
|
/**
|
|
361
580
|
* Reads this sandbox's audit log: outbound connections and egress denials
|
|
362
581
|
* (`kind: "egress"`), and secret reads. Denials carry `result: "failure"`
|
|
363
582
|
* and the policy `reason`.
|
|
364
583
|
*/
|
|
365
|
-
audit(options?: AuditOptions): Promise<AuditPage>;
|
|
584
|
+
audit(options?: AuditOptions, call?: CallOptions): Promise<AuditPage>;
|
|
366
585
|
toJSON(): Sandbox;
|
|
367
586
|
private apply;
|
|
368
587
|
}
|
|
588
|
+
export declare const WATCH_START_TIMEOUT_MS = 60000;
|
|
369
589
|
export {};
|