disk 1.6.0 → 1.8.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/README.md +72 -9
- package/dist/cli.mjs +2 -2
- package/dist/{common-DglyXr-d.mjs → common-CCIBdgS1.mjs} +1 -1
- package/dist/index.cjs +206 -70
- package/dist/index.d.cts +128 -12
- package/dist/index.d.mts +128 -12
- package/dist/index.mjs +2 -2
- package/dist/sandbox-cli.mjs +4 -4
- package/dist/{src-CxdnwAiv.mjs → src-c7xI3gpo.mjs} +205 -71
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -65,6 +65,61 @@ declare class Disks {
|
|
|
65
65
|
exec(id: string, command: string): Promise<ExecResult>;
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
|
+
//#region src/images.d.ts
|
|
69
|
+
type ImageWire = components["schemas"]["Image"];
|
|
70
|
+
type ImageStatus = components["schemas"]["ImageState"];
|
|
71
|
+
/**
|
|
72
|
+
* Why a build failed. `invalid_source`: the registry reported the image missing
|
|
73
|
+
* or denied access, so retrying won't help. `interrupted`: the build did not
|
|
74
|
+
* finish; requesting it again starts a new build.
|
|
75
|
+
*/
|
|
76
|
+
type ImageFailureReason = NonNullable<ImageWire["failure_reason"]>;
|
|
77
|
+
interface Image {
|
|
78
|
+
/** 64-character hex id; pass it to `sandboxes.create({ imageId })`. */
|
|
79
|
+
imageId: string;
|
|
80
|
+
/** Normalized OCI reference. */
|
|
81
|
+
source: string;
|
|
82
|
+
private: boolean;
|
|
83
|
+
status: ImageStatus;
|
|
84
|
+
/** `sha256:` digest of the last successful build, kept while a tag rebuilds. */
|
|
85
|
+
digest?: string;
|
|
86
|
+
/** `repo@sha256:` reference of the last successful build. */
|
|
87
|
+
canonicalSource?: string;
|
|
88
|
+
/** Present only when `status` is `failed`. */
|
|
89
|
+
failureReason?: ImageFailureReason;
|
|
90
|
+
createdAt: Date;
|
|
91
|
+
updatedAt: Date;
|
|
92
|
+
}
|
|
93
|
+
/** Registry credentials for a private image. Archil never stores them. */
|
|
94
|
+
type RegistryAuth = components["schemas"]["RegistryAuth"];
|
|
95
|
+
interface BuildImageRequest {
|
|
96
|
+
/** OCI image reference, such as `node:24-bookworm` or `ghcr.io/owner/app@sha256:<digest>`. */
|
|
97
|
+
source: string;
|
|
98
|
+
/** Required for private images on every build request; without it `source` names the public image. */
|
|
99
|
+
registryAuth?: RegistryAuth;
|
|
100
|
+
}
|
|
101
|
+
interface BuildImageOptions {
|
|
102
|
+
/** Seconds to wait for the build. Defaults to 1800 (30 minutes). */
|
|
103
|
+
timeoutSeconds?: number;
|
|
104
|
+
}
|
|
105
|
+
declare class Images {
|
|
106
|
+
/** @internal */
|
|
107
|
+
private readonly _client;
|
|
108
|
+
/** @internal */
|
|
109
|
+
constructor(client: ApiClient);
|
|
110
|
+
get(imageId: string): Promise<Image>;
|
|
111
|
+
/**
|
|
112
|
+
* Build a sandbox image from an OCI reference and wait until it is ready.
|
|
113
|
+
* Returns at once when the image is already built from a digest reference
|
|
114
|
+
* and joins a build that is already running. A tag is rebuilt on each call
|
|
115
|
+
* in case it moved, so call this once and reuse `imageId`. Interrupted
|
|
116
|
+
* builds are requested again up to three times; other failures throw
|
|
117
|
+
* {@link ImageBuildError}.
|
|
118
|
+
*/
|
|
119
|
+
build(request: BuildImageRequest, options?: BuildImageOptions): Promise<Image>;
|
|
120
|
+
private _request;
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
68
123
|
//#region src/sandbox-process.d.ts
|
|
69
124
|
type SandboxProcessStatus = "running" | "completed" | "failed" | "cancelled" | "timed_out";
|
|
70
125
|
type SandboxProcessStream = "stdout" | "stderr";
|
|
@@ -85,6 +140,8 @@ interface SandboxProcessConnectOptions {
|
|
|
85
140
|
collectOutput?: boolean;
|
|
86
141
|
}
|
|
87
142
|
interface SandboxProcessStartOptions {
|
|
143
|
+
/** Absolute working directory inside the sandbox. */
|
|
144
|
+
cwd?: string;
|
|
88
145
|
/** Enables a PTY. PTY output is merged into stdout and stderr remains empty. */
|
|
89
146
|
terminal?: boolean | SandboxTerminalOptions;
|
|
90
147
|
env?: Record<string, string>;
|
|
@@ -103,6 +160,7 @@ interface SandboxProcessResult {
|
|
|
103
160
|
type ProcessConnectionRequest = {
|
|
104
161
|
type: "start";
|
|
105
162
|
command: string;
|
|
163
|
+
cwd?: string;
|
|
106
164
|
terminal?: boolean | {
|
|
107
165
|
cols: number;
|
|
108
166
|
rows: number;
|
|
@@ -123,15 +181,15 @@ type ProcessControlRequest = {
|
|
|
123
181
|
cols: number;
|
|
124
182
|
rows: number;
|
|
125
183
|
};
|
|
184
|
+
/** @deprecated Use Sandbox.run() and Sandbox.attach(). Removed in the next version. */
|
|
126
185
|
declare class SandboxProcesses {
|
|
127
|
-
private readonly
|
|
128
|
-
private readonly _client;
|
|
186
|
+
private readonly _sandbox;
|
|
129
187
|
/** @internal */
|
|
130
|
-
constructor(
|
|
188
|
+
constructor(_sandbox: Pick<Sandbox, "run" | "attach">);
|
|
189
|
+
/** @deprecated Use sandbox.run(). Removed in the next version. */
|
|
131
190
|
start(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcess>;
|
|
191
|
+
/** @deprecated Use sandbox.attach(). Removed in the next version. */
|
|
132
192
|
connect(processId: string, options?: SandboxProcessConnectOptions): Promise<SandboxProcess>;
|
|
133
|
-
private _connectionUrl;
|
|
134
|
-
private _control;
|
|
135
193
|
}
|
|
136
194
|
declare class SandboxProcess {
|
|
137
195
|
status: SandboxProcessStatus;
|
|
@@ -187,9 +245,9 @@ interface SandboxFileUploadOptions {
|
|
|
187
245
|
mode?: number;
|
|
188
246
|
}
|
|
189
247
|
declare class SandboxFiles {
|
|
190
|
-
private readonly
|
|
248
|
+
private readonly _sandbox;
|
|
191
249
|
/** @internal */
|
|
192
|
-
constructor(
|
|
250
|
+
constructor(sandbox: Pick<Sandbox, "run">);
|
|
193
251
|
uploadFile(source: SandboxFileSource, remotePath: string, options?: SandboxFileUploadOptions): Promise<void>;
|
|
194
252
|
downloadFile(remotePath: string, write: SandboxFileWriter): Promise<void>;
|
|
195
253
|
}
|
|
@@ -205,9 +263,31 @@ type SandboxNetwork = Omit<components["schemas"]["SandboxNetwork"], "egress"> &
|
|
|
205
263
|
egress?: SandboxEgressPolicy;
|
|
206
264
|
};
|
|
207
265
|
/** @internal */
|
|
208
|
-
type SandboxWire = components["schemas"]["Sandbox"]
|
|
209
|
-
|
|
210
|
-
|
|
266
|
+
type SandboxWire = components["schemas"]["Sandbox"];
|
|
267
|
+
/**
|
|
268
|
+
* One Archil disk to mount inside a sandbox. `path` is the absolute guest
|
|
269
|
+
* directory; it may be omitted only for a sole mount, which then lands at
|
|
270
|
+
* `/mnt/archil`. A plain mount is exclusive and `queueMs` bounds the wait for
|
|
271
|
+
* its root delegation; `readOnly` and `conditional` mounts never take it.
|
|
272
|
+
*/
|
|
273
|
+
interface SandboxMountSpec extends Omit<ExecMountSpec, "checkoutPaths" | "queueMs"> {
|
|
274
|
+
path?: string;
|
|
275
|
+
/**
|
|
276
|
+
* Milliseconds a plain mount waits for the disk's exclusive root delegation
|
|
277
|
+
* before the boot fails. Cannot be combined with `readOnly` or `conditional`.
|
|
278
|
+
*/
|
|
279
|
+
queueMs?: number;
|
|
280
|
+
}
|
|
281
|
+
/** An Archil disk mounted inside the sandbox, as currently configured. */
|
|
282
|
+
interface SandboxMount {
|
|
283
|
+
diskId: string;
|
|
284
|
+
/** Absolute guest directory the disk is mounted at. */
|
|
285
|
+
path: string;
|
|
286
|
+
subdirectory?: string;
|
|
287
|
+
readOnly: boolean;
|
|
288
|
+
conditional: boolean;
|
|
289
|
+
queueMs?: number;
|
|
290
|
+
}
|
|
211
291
|
type SandboxStatus = components["schemas"]["SandboxState"];
|
|
212
292
|
interface SandboxEndpoint {
|
|
213
293
|
port: number;
|
|
@@ -243,13 +323,18 @@ interface SandboxResponse {
|
|
|
243
323
|
status: SandboxStatus;
|
|
244
324
|
vcpuCount: number;
|
|
245
325
|
memSizeMiB: number;
|
|
326
|
+
/** Empty for sandboxes created from `imageId`. */
|
|
246
327
|
baseImage: string;
|
|
328
|
+
/** Digest of the image the sandbox was created from; may be empty. */
|
|
329
|
+
imageDigest: string;
|
|
247
330
|
platform?: "arm64" | "amd64";
|
|
248
331
|
maxTtlSeconds: number;
|
|
249
332
|
idleTtlSeconds: number;
|
|
250
333
|
/** Maximum concurrently attached process sessions. Detached processes and one-shot controls do not count. */
|
|
251
334
|
maxConcurrentExecs: number;
|
|
252
335
|
endpoints?: SandboxEndpoint[];
|
|
336
|
+
/** Disks mounted inside the guest on every boot. */
|
|
337
|
+
mounts: SandboxMount[];
|
|
253
338
|
createdAt: Date;
|
|
254
339
|
runningAt?: Date;
|
|
255
340
|
finishedAt?: Date;
|
|
@@ -265,6 +350,14 @@ interface SandboxWaitOptions {
|
|
|
265
350
|
*/
|
|
266
351
|
wait?: boolean;
|
|
267
352
|
}
|
|
353
|
+
interface SandboxStartOptions extends SandboxWaitOptions {
|
|
354
|
+
/**
|
|
355
|
+
* Replace the sandbox's disk mounts for this and later sessions. Omit to
|
|
356
|
+
* keep the current ones. A cold start only: resume keeps the paused
|
|
357
|
+
* session's mounts.
|
|
358
|
+
*/
|
|
359
|
+
mounts?: SandboxMountSpec[];
|
|
360
|
+
}
|
|
268
361
|
interface SandboxForkOptions extends SandboxWaitOptions {
|
|
269
362
|
/** Name for the fork. The server generates one when omitted. */
|
|
270
363
|
name?: string;
|
|
@@ -282,17 +375,20 @@ declare class Sandbox {
|
|
|
282
375
|
vcpuCount: number;
|
|
283
376
|
memSizeMiB: number;
|
|
284
377
|
baseImage: string;
|
|
378
|
+
imageDigest: string;
|
|
285
379
|
platform?: "arm64" | "amd64";
|
|
286
380
|
maxTtlSeconds: number;
|
|
287
381
|
idleTtlSeconds: number;
|
|
288
382
|
maxConcurrentExecs: number;
|
|
289
383
|
endpoints?: SandboxEndpoint[];
|
|
384
|
+
mounts: SandboxMount[];
|
|
290
385
|
createdAt: Date;
|
|
291
386
|
runningAt?: Date;
|
|
292
387
|
finishedAt?: Date;
|
|
293
388
|
lastActiveAt: Date;
|
|
294
389
|
exitReason?: string;
|
|
295
390
|
checkpoint?: string;
|
|
391
|
+
/** @deprecated Use run() and attach(). Removed in the next version. */
|
|
296
392
|
readonly processes: SandboxProcesses;
|
|
297
393
|
readonly files: SandboxFiles;
|
|
298
394
|
/** @internal */
|
|
@@ -302,12 +398,18 @@ declare class Sandbox {
|
|
|
302
398
|
/** @internal Overwrite this sandbox's fields in place from a fresh wire snapshot. */
|
|
303
399
|
private _apply;
|
|
304
400
|
toJSON(): SandboxResponse;
|
|
401
|
+
/** Start a process and return its handle without waiting for exit. */
|
|
402
|
+
run(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcess>;
|
|
403
|
+
/** Reattach to a process, optionally resuming output from a cursor. */
|
|
404
|
+
attach(processId: string, options?: SandboxProcessConnectOptions): Promise<SandboxProcess>;
|
|
405
|
+
private _connectionUrl;
|
|
406
|
+
private _control;
|
|
305
407
|
/** Run a process and wait for it to exit. */
|
|
306
408
|
exec(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcessResult>;
|
|
307
409
|
/** Re-fetch this sandbox. */
|
|
308
410
|
refresh(): Promise<this>;
|
|
309
411
|
/** Start this sandbox. */
|
|
310
|
-
start(options?:
|
|
412
|
+
start(options?: SandboxStartOptions): Promise<Sandbox | this>;
|
|
311
413
|
/** Stop this sandbox. */
|
|
312
414
|
stop(options?: SandboxWaitOptions): Promise<Sandbox | this>;
|
|
313
415
|
/** Pause this sandbox, preserving its CPU and memory state. */
|
|
@@ -368,6 +470,8 @@ interface CreateSandboxRequest {
|
|
|
368
470
|
* `alpine@sha256:<digest>`.
|
|
369
471
|
*/
|
|
370
472
|
baseImage?: string;
|
|
473
|
+
/** Ready image from `images.build()`. Cannot be combined with `baseImage`. */
|
|
474
|
+
imageId?: string;
|
|
371
475
|
env?: Record<string, string>;
|
|
372
476
|
maxTtlSeconds?: number;
|
|
373
477
|
/** Seconds without a direct process connection before pausing. Omitted or zero disables idle expiry. */
|
|
@@ -378,6 +482,12 @@ interface CreateSandboxRequest {
|
|
|
378
482
|
network?: SandboxNetwork;
|
|
379
483
|
/** TCP ports to expose publicly, from 1 to 65535. */
|
|
380
484
|
ports?: number[];
|
|
485
|
+
/**
|
|
486
|
+
* Disks mounted inside the guest for the first session; `sandbox.start()`
|
|
487
|
+
* can replace them later. A sandbox with mounts must be stopped before it
|
|
488
|
+
* is forked.
|
|
489
|
+
*/
|
|
490
|
+
mounts?: SandboxMountSpec[];
|
|
381
491
|
}
|
|
382
492
|
interface ListSandboxesOptions {
|
|
383
493
|
/** Only return sandboxes that mount this disk. */
|
|
@@ -542,6 +652,7 @@ interface ExecOptions {
|
|
|
542
652
|
}
|
|
543
653
|
declare class Archil {
|
|
544
654
|
readonly disks: Disks;
|
|
655
|
+
readonly images: Images;
|
|
545
656
|
readonly sandboxes: Sandboxes;
|
|
546
657
|
readonly tokens: Tokens;
|
|
547
658
|
/** @internal */
|
|
@@ -584,6 +695,11 @@ declare class SandboxPauseError extends ArchilError {
|
|
|
584
695
|
readonly latest: Sandbox;
|
|
585
696
|
constructor(latest: Sandbox);
|
|
586
697
|
}
|
|
698
|
+
declare class ImageBuildError extends ArchilError {
|
|
699
|
+
readonly latest: Image;
|
|
700
|
+
readonly reason?: ImageFailureReason;
|
|
701
|
+
constructor(latest: Image);
|
|
702
|
+
}
|
|
587
703
|
declare class SandboxFileTransferError extends ArchilError {
|
|
588
704
|
readonly operation: "upload" | "download";
|
|
589
705
|
readonly path: string;
|
|
@@ -640,4 +756,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
640
756
|
*/
|
|
641
757
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
642
758
|
//#endregion
|
|
643
|
-
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
|
759
|
+
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
package/dist/index.d.mts
CHANGED
|
@@ -65,6 +65,61 @@ declare class Disks {
|
|
|
65
65
|
exec(id: string, command: string): Promise<ExecResult>;
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
|
+
//#region src/images.d.ts
|
|
69
|
+
type ImageWire = components["schemas"]["Image"];
|
|
70
|
+
type ImageStatus = components["schemas"]["ImageState"];
|
|
71
|
+
/**
|
|
72
|
+
* Why a build failed. `invalid_source`: the registry reported the image missing
|
|
73
|
+
* or denied access, so retrying won't help. `interrupted`: the build did not
|
|
74
|
+
* finish; requesting it again starts a new build.
|
|
75
|
+
*/
|
|
76
|
+
type ImageFailureReason = NonNullable<ImageWire["failure_reason"]>;
|
|
77
|
+
interface Image {
|
|
78
|
+
/** 64-character hex id; pass it to `sandboxes.create({ imageId })`. */
|
|
79
|
+
imageId: string;
|
|
80
|
+
/** Normalized OCI reference. */
|
|
81
|
+
source: string;
|
|
82
|
+
private: boolean;
|
|
83
|
+
status: ImageStatus;
|
|
84
|
+
/** `sha256:` digest of the last successful build, kept while a tag rebuilds. */
|
|
85
|
+
digest?: string;
|
|
86
|
+
/** `repo@sha256:` reference of the last successful build. */
|
|
87
|
+
canonicalSource?: string;
|
|
88
|
+
/** Present only when `status` is `failed`. */
|
|
89
|
+
failureReason?: ImageFailureReason;
|
|
90
|
+
createdAt: Date;
|
|
91
|
+
updatedAt: Date;
|
|
92
|
+
}
|
|
93
|
+
/** Registry credentials for a private image. Archil never stores them. */
|
|
94
|
+
type RegistryAuth = components["schemas"]["RegistryAuth"];
|
|
95
|
+
interface BuildImageRequest {
|
|
96
|
+
/** OCI image reference, such as `node:24-bookworm` or `ghcr.io/owner/app@sha256:<digest>`. */
|
|
97
|
+
source: string;
|
|
98
|
+
/** Required for private images on every build request; without it `source` names the public image. */
|
|
99
|
+
registryAuth?: RegistryAuth;
|
|
100
|
+
}
|
|
101
|
+
interface BuildImageOptions {
|
|
102
|
+
/** Seconds to wait for the build. Defaults to 1800 (30 minutes). */
|
|
103
|
+
timeoutSeconds?: number;
|
|
104
|
+
}
|
|
105
|
+
declare class Images {
|
|
106
|
+
/** @internal */
|
|
107
|
+
private readonly _client;
|
|
108
|
+
/** @internal */
|
|
109
|
+
constructor(client: ApiClient);
|
|
110
|
+
get(imageId: string): Promise<Image>;
|
|
111
|
+
/**
|
|
112
|
+
* Build a sandbox image from an OCI reference and wait until it is ready.
|
|
113
|
+
* Returns at once when the image is already built from a digest reference
|
|
114
|
+
* and joins a build that is already running. A tag is rebuilt on each call
|
|
115
|
+
* in case it moved, so call this once and reuse `imageId`. Interrupted
|
|
116
|
+
* builds are requested again up to three times; other failures throw
|
|
117
|
+
* {@link ImageBuildError}.
|
|
118
|
+
*/
|
|
119
|
+
build(request: BuildImageRequest, options?: BuildImageOptions): Promise<Image>;
|
|
120
|
+
private _request;
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
68
123
|
//#region src/sandbox-process.d.ts
|
|
69
124
|
type SandboxProcessStatus = "running" | "completed" | "failed" | "cancelled" | "timed_out";
|
|
70
125
|
type SandboxProcessStream = "stdout" | "stderr";
|
|
@@ -85,6 +140,8 @@ interface SandboxProcessConnectOptions {
|
|
|
85
140
|
collectOutput?: boolean;
|
|
86
141
|
}
|
|
87
142
|
interface SandboxProcessStartOptions {
|
|
143
|
+
/** Absolute working directory inside the sandbox. */
|
|
144
|
+
cwd?: string;
|
|
88
145
|
/** Enables a PTY. PTY output is merged into stdout and stderr remains empty. */
|
|
89
146
|
terminal?: boolean | SandboxTerminalOptions;
|
|
90
147
|
env?: Record<string, string>;
|
|
@@ -103,6 +160,7 @@ interface SandboxProcessResult {
|
|
|
103
160
|
type ProcessConnectionRequest = {
|
|
104
161
|
type: "start";
|
|
105
162
|
command: string;
|
|
163
|
+
cwd?: string;
|
|
106
164
|
terminal?: boolean | {
|
|
107
165
|
cols: number;
|
|
108
166
|
rows: number;
|
|
@@ -123,15 +181,15 @@ type ProcessControlRequest = {
|
|
|
123
181
|
cols: number;
|
|
124
182
|
rows: number;
|
|
125
183
|
};
|
|
184
|
+
/** @deprecated Use Sandbox.run() and Sandbox.attach(). Removed in the next version. */
|
|
126
185
|
declare class SandboxProcesses {
|
|
127
|
-
private readonly
|
|
128
|
-
private readonly _client;
|
|
186
|
+
private readonly _sandbox;
|
|
129
187
|
/** @internal */
|
|
130
|
-
constructor(
|
|
188
|
+
constructor(_sandbox: Pick<Sandbox, "run" | "attach">);
|
|
189
|
+
/** @deprecated Use sandbox.run(). Removed in the next version. */
|
|
131
190
|
start(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcess>;
|
|
191
|
+
/** @deprecated Use sandbox.attach(). Removed in the next version. */
|
|
132
192
|
connect(processId: string, options?: SandboxProcessConnectOptions): Promise<SandboxProcess>;
|
|
133
|
-
private _connectionUrl;
|
|
134
|
-
private _control;
|
|
135
193
|
}
|
|
136
194
|
declare class SandboxProcess {
|
|
137
195
|
status: SandboxProcessStatus;
|
|
@@ -187,9 +245,9 @@ interface SandboxFileUploadOptions {
|
|
|
187
245
|
mode?: number;
|
|
188
246
|
}
|
|
189
247
|
declare class SandboxFiles {
|
|
190
|
-
private readonly
|
|
248
|
+
private readonly _sandbox;
|
|
191
249
|
/** @internal */
|
|
192
|
-
constructor(
|
|
250
|
+
constructor(sandbox: Pick<Sandbox, "run">);
|
|
193
251
|
uploadFile(source: SandboxFileSource, remotePath: string, options?: SandboxFileUploadOptions): Promise<void>;
|
|
194
252
|
downloadFile(remotePath: string, write: SandboxFileWriter): Promise<void>;
|
|
195
253
|
}
|
|
@@ -205,9 +263,31 @@ type SandboxNetwork = Omit<components["schemas"]["SandboxNetwork"], "egress"> &
|
|
|
205
263
|
egress?: SandboxEgressPolicy;
|
|
206
264
|
};
|
|
207
265
|
/** @internal */
|
|
208
|
-
type SandboxWire = components["schemas"]["Sandbox"]
|
|
209
|
-
|
|
210
|
-
|
|
266
|
+
type SandboxWire = components["schemas"]["Sandbox"];
|
|
267
|
+
/**
|
|
268
|
+
* One Archil disk to mount inside a sandbox. `path` is the absolute guest
|
|
269
|
+
* directory; it may be omitted only for a sole mount, which then lands at
|
|
270
|
+
* `/mnt/archil`. A plain mount is exclusive and `queueMs` bounds the wait for
|
|
271
|
+
* its root delegation; `readOnly` and `conditional` mounts never take it.
|
|
272
|
+
*/
|
|
273
|
+
interface SandboxMountSpec extends Omit<ExecMountSpec, "checkoutPaths" | "queueMs"> {
|
|
274
|
+
path?: string;
|
|
275
|
+
/**
|
|
276
|
+
* Milliseconds a plain mount waits for the disk's exclusive root delegation
|
|
277
|
+
* before the boot fails. Cannot be combined with `readOnly` or `conditional`.
|
|
278
|
+
*/
|
|
279
|
+
queueMs?: number;
|
|
280
|
+
}
|
|
281
|
+
/** An Archil disk mounted inside the sandbox, as currently configured. */
|
|
282
|
+
interface SandboxMount {
|
|
283
|
+
diskId: string;
|
|
284
|
+
/** Absolute guest directory the disk is mounted at. */
|
|
285
|
+
path: string;
|
|
286
|
+
subdirectory?: string;
|
|
287
|
+
readOnly: boolean;
|
|
288
|
+
conditional: boolean;
|
|
289
|
+
queueMs?: number;
|
|
290
|
+
}
|
|
211
291
|
type SandboxStatus = components["schemas"]["SandboxState"];
|
|
212
292
|
interface SandboxEndpoint {
|
|
213
293
|
port: number;
|
|
@@ -243,13 +323,18 @@ interface SandboxResponse {
|
|
|
243
323
|
status: SandboxStatus;
|
|
244
324
|
vcpuCount: number;
|
|
245
325
|
memSizeMiB: number;
|
|
326
|
+
/** Empty for sandboxes created from `imageId`. */
|
|
246
327
|
baseImage: string;
|
|
328
|
+
/** Digest of the image the sandbox was created from; may be empty. */
|
|
329
|
+
imageDigest: string;
|
|
247
330
|
platform?: "arm64" | "amd64";
|
|
248
331
|
maxTtlSeconds: number;
|
|
249
332
|
idleTtlSeconds: number;
|
|
250
333
|
/** Maximum concurrently attached process sessions. Detached processes and one-shot controls do not count. */
|
|
251
334
|
maxConcurrentExecs: number;
|
|
252
335
|
endpoints?: SandboxEndpoint[];
|
|
336
|
+
/** Disks mounted inside the guest on every boot. */
|
|
337
|
+
mounts: SandboxMount[];
|
|
253
338
|
createdAt: Date;
|
|
254
339
|
runningAt?: Date;
|
|
255
340
|
finishedAt?: Date;
|
|
@@ -265,6 +350,14 @@ interface SandboxWaitOptions {
|
|
|
265
350
|
*/
|
|
266
351
|
wait?: boolean;
|
|
267
352
|
}
|
|
353
|
+
interface SandboxStartOptions extends SandboxWaitOptions {
|
|
354
|
+
/**
|
|
355
|
+
* Replace the sandbox's disk mounts for this and later sessions. Omit to
|
|
356
|
+
* keep the current ones. A cold start only: resume keeps the paused
|
|
357
|
+
* session's mounts.
|
|
358
|
+
*/
|
|
359
|
+
mounts?: SandboxMountSpec[];
|
|
360
|
+
}
|
|
268
361
|
interface SandboxForkOptions extends SandboxWaitOptions {
|
|
269
362
|
/** Name for the fork. The server generates one when omitted. */
|
|
270
363
|
name?: string;
|
|
@@ -282,17 +375,20 @@ declare class Sandbox {
|
|
|
282
375
|
vcpuCount: number;
|
|
283
376
|
memSizeMiB: number;
|
|
284
377
|
baseImage: string;
|
|
378
|
+
imageDigest: string;
|
|
285
379
|
platform?: "arm64" | "amd64";
|
|
286
380
|
maxTtlSeconds: number;
|
|
287
381
|
idleTtlSeconds: number;
|
|
288
382
|
maxConcurrentExecs: number;
|
|
289
383
|
endpoints?: SandboxEndpoint[];
|
|
384
|
+
mounts: SandboxMount[];
|
|
290
385
|
createdAt: Date;
|
|
291
386
|
runningAt?: Date;
|
|
292
387
|
finishedAt?: Date;
|
|
293
388
|
lastActiveAt: Date;
|
|
294
389
|
exitReason?: string;
|
|
295
390
|
checkpoint?: string;
|
|
391
|
+
/** @deprecated Use run() and attach(). Removed in the next version. */
|
|
296
392
|
readonly processes: SandboxProcesses;
|
|
297
393
|
readonly files: SandboxFiles;
|
|
298
394
|
/** @internal */
|
|
@@ -302,12 +398,18 @@ declare class Sandbox {
|
|
|
302
398
|
/** @internal Overwrite this sandbox's fields in place from a fresh wire snapshot. */
|
|
303
399
|
private _apply;
|
|
304
400
|
toJSON(): SandboxResponse;
|
|
401
|
+
/** Start a process and return its handle without waiting for exit. */
|
|
402
|
+
run(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcess>;
|
|
403
|
+
/** Reattach to a process, optionally resuming output from a cursor. */
|
|
404
|
+
attach(processId: string, options?: SandboxProcessConnectOptions): Promise<SandboxProcess>;
|
|
405
|
+
private _connectionUrl;
|
|
406
|
+
private _control;
|
|
305
407
|
/** Run a process and wait for it to exit. */
|
|
306
408
|
exec(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcessResult>;
|
|
307
409
|
/** Re-fetch this sandbox. */
|
|
308
410
|
refresh(): Promise<this>;
|
|
309
411
|
/** Start this sandbox. */
|
|
310
|
-
start(options?:
|
|
412
|
+
start(options?: SandboxStartOptions): Promise<Sandbox | this>;
|
|
311
413
|
/** Stop this sandbox. */
|
|
312
414
|
stop(options?: SandboxWaitOptions): Promise<Sandbox | this>;
|
|
313
415
|
/** Pause this sandbox, preserving its CPU and memory state. */
|
|
@@ -368,6 +470,8 @@ interface CreateSandboxRequest {
|
|
|
368
470
|
* `alpine@sha256:<digest>`.
|
|
369
471
|
*/
|
|
370
472
|
baseImage?: string;
|
|
473
|
+
/** Ready image from `images.build()`. Cannot be combined with `baseImage`. */
|
|
474
|
+
imageId?: string;
|
|
371
475
|
env?: Record<string, string>;
|
|
372
476
|
maxTtlSeconds?: number;
|
|
373
477
|
/** Seconds without a direct process connection before pausing. Omitted or zero disables idle expiry. */
|
|
@@ -378,6 +482,12 @@ interface CreateSandboxRequest {
|
|
|
378
482
|
network?: SandboxNetwork;
|
|
379
483
|
/** TCP ports to expose publicly, from 1 to 65535. */
|
|
380
484
|
ports?: number[];
|
|
485
|
+
/**
|
|
486
|
+
* Disks mounted inside the guest for the first session; `sandbox.start()`
|
|
487
|
+
* can replace them later. A sandbox with mounts must be stopped before it
|
|
488
|
+
* is forked.
|
|
489
|
+
*/
|
|
490
|
+
mounts?: SandboxMountSpec[];
|
|
381
491
|
}
|
|
382
492
|
interface ListSandboxesOptions {
|
|
383
493
|
/** Only return sandboxes that mount this disk. */
|
|
@@ -542,6 +652,7 @@ interface ExecOptions {
|
|
|
542
652
|
}
|
|
543
653
|
declare class Archil {
|
|
544
654
|
readonly disks: Disks;
|
|
655
|
+
readonly images: Images;
|
|
545
656
|
readonly sandboxes: Sandboxes;
|
|
546
657
|
readonly tokens: Tokens;
|
|
547
658
|
/** @internal */
|
|
@@ -584,6 +695,11 @@ declare class SandboxPauseError extends ArchilError {
|
|
|
584
695
|
readonly latest: Sandbox;
|
|
585
696
|
constructor(latest: Sandbox);
|
|
586
697
|
}
|
|
698
|
+
declare class ImageBuildError extends ArchilError {
|
|
699
|
+
readonly latest: Image;
|
|
700
|
+
readonly reason?: ImageFailureReason;
|
|
701
|
+
constructor(latest: Image);
|
|
702
|
+
}
|
|
587
703
|
declare class SandboxFileTransferError extends ArchilError {
|
|
588
704
|
readonly operation: "upload" | "download";
|
|
589
705
|
readonly path: string;
|
|
@@ -640,4 +756,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
640
756
|
*/
|
|
641
757
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
642
758
|
//#endregion
|
|
643
|
-
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
|
759
|
+
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { Archil, ArchilApiError, ArchilError, ArchilS3Error, Disk, DiskMultipart, Disks, Sandbox, SandboxFileTransferError, SandboxFiles, SandboxPauseError, SandboxProcess, SandboxProcesses, Sandboxes, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
|
1
|
+
import { A as ArchilError, C as Disk, D as VERSION, E as USER_AGENT, M as ImageBuildError, N as SandboxFileTransferError, P as SandboxPauseError, S as Disks, T as effectiveUploadPartSize, _ as Sandbox, a as deleteApiKey, b as SandboxProcesses, c as getSandbox, d as listSandboxes, f as workspace, g as Sandboxes, h as Tokens, i as createSandbox, j as ArchilS3Error, k as ArchilApiError, l as listApiKeys, m as Workspace, n as createApiKey, o as exec, p as Archil, r as createDisk, s as getDisk, t as configure, u as listDisks, v as SandboxFiles, w as DiskMultipart, x as Images, y as SandboxProcess } from "./src-c7xI3gpo.mjs";
|
|
2
|
+
export { Archil, ArchilApiError, ArchilError, ArchilS3Error, Disk, DiskMultipart, Disks, ImageBuildError, Images, Sandbox, SandboxFileTransferError, SandboxFiles, SandboxPauseError, SandboxProcess, SandboxProcesses, Sandboxes, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
package/dist/sandbox-cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-
|
|
2
|
+
import { k as ArchilApiError, p as Archil } from "./src-c7xI3gpo.mjs";
|
|
3
|
+
import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-CCIBdgS1.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
import { spinner } from "@clack/prompts";
|
|
@@ -193,7 +193,7 @@ async function runSandboxShell(options) {
|
|
|
193
193
|
const onSighup = () => requestTermination("terminated by local signal", "SIGHUP");
|
|
194
194
|
const priorRaw = stdin.isRaw ?? false;
|
|
195
195
|
try {
|
|
196
|
-
remote = await options.sandbox.
|
|
196
|
+
remote = await options.sandbox.run("/bin/sh -l", {
|
|
197
197
|
terminal: {
|
|
198
198
|
cols: stdout.columns ?? 80,
|
|
199
199
|
rows: stdout.rows ?? 24
|
|
@@ -457,7 +457,7 @@ Use -- before the command so its flags are not parsed as sandbox options.
|
|
|
457
457
|
const onSighup = () => onSignal("SIGHUP");
|
|
458
458
|
try {
|
|
459
459
|
const shellCommand = command.map((argument) => argument === "" ? "''" : `'${argument.replaceAll("'", `'"'"'`)}'`).join(" ");
|
|
460
|
-
remote = await sandbox.
|
|
460
|
+
remote = await sandbox.run(shellCommand, {
|
|
461
461
|
...runOptions,
|
|
462
462
|
collectOutput: options.output === "json",
|
|
463
463
|
onOutput: options.output === "json" ? void 0 : ({ stream, data }) => {
|