disk 0.8.22 → 0.8.23

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 CHANGED
@@ -74,6 +74,33 @@ await d.removeUser("token", user.identifier!);
74
74
  await d.delete();
75
75
  ```
76
76
 
77
+ ### Sandboxes
78
+
79
+ Use `Archil.sandboxes` to manage persistent VMs:
80
+
81
+ ```ts
82
+ const client = new archil.Archil({
83
+ apiKey: process.env.ARCHIL_API_KEY,
84
+ region: "aws-us-east-1",
85
+ });
86
+ const sandbox = await client.sandboxes.create({ vcpuCount: 2, memSizeMiB: 4096 });
87
+
88
+ const result = await sandbox.exec("uname -a");
89
+ console.log(result.stdout);
90
+
91
+ await sandbox.stop();
92
+ await sandbox.start();
93
+ await sandbox.pause();
94
+ await sandbox.resume();
95
+
96
+ const all = await client.sandboxes.list();
97
+ const usingDisk = await client.sandboxes.list({ disk: "dsk-abc123" });
98
+ ```
99
+
100
+ `create`, `start`, `stop`, `pause`, `resume`, and `exec` wait up to 30 seconds by default.
101
+ Set `timeoutMs` to change the limit. A `SandboxWaitTimeoutError` includes the latest
102
+ resource state.
103
+
77
104
  API keys live at the account level, so those helpers are top-level:
78
105
 
79
106
  ```ts
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as listDisks, i as deleteApiKey, n as createApiKey, o as getDisk, r as createDisk, s as listApiKeys, t as configure, y as ArchilApiError } from "./src-BepELcl6.mjs";
2
+ import { D as ArchilApiError, a as deleteApiKey, l as listApiKeys, n as createApiKey, r as createDisk, s as getDisk, t as configure, u as listDisks } from "./src-DgL0HTS-.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { Command, Option } from "commander";
5
5
  //#region bin/cli.ts
package/dist/index.cjs CHANGED
@@ -134,7 +134,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
134
134
  }
135
135
  //#endregion
136
136
  //#region src/version.ts
137
- const VERSION = "0.8.22";
137
+ const VERSION = "0.8.23";
138
138
  const USER_AGENT = `archil-js/${VERSION}`;
139
139
  //#endregion
140
140
  //#region src/client.ts
@@ -1157,6 +1157,319 @@ var Disks = class {
1157
1157
  };
1158
1158
  }
1159
1159
  };
1160
+ const POLL_INTERVAL_MS = 500;
1161
+ /** @internal */
1162
+ function validateTimeoutMs(timeoutMs) {
1163
+ if (!Number.isFinite(timeoutMs) || timeoutMs < 0) throw new RangeError("timeoutMs must be a finite, non-negative number");
1164
+ }
1165
+ /**
1166
+ * The requested SDK-side wait expired. The remote sandbox operation continues;
1167
+ * `latest` is the same `Sandbox`/`SandboxExec` the operation was called on,
1168
+ * updated in place to the last state observed before the deadline.
1169
+ */
1170
+ var SandboxWaitTimeoutError = class extends ArchilError {
1171
+ operation;
1172
+ timeoutMs;
1173
+ latest;
1174
+ constructor(operation, timeoutMs, latest) {
1175
+ const subject = operation === "exec" ? "sandbox exec to complete" : `sandbox to ${operation}`;
1176
+ super(`Timed out after ${timeoutMs}ms waiting for ${subject}`, 408, "SANDBOX_WAIT_TIMEOUT");
1177
+ this.name = "SandboxWaitTimeoutError";
1178
+ this.operation = operation;
1179
+ this.timeoutMs = timeoutMs;
1180
+ this.latest = latest;
1181
+ }
1182
+ };
1183
+ /** The sandbox entered an inactive state before startup completed. */
1184
+ var SandboxStartError = class extends ArchilError {
1185
+ latest;
1186
+ constructor(sandbox) {
1187
+ const detail = sandbox.exitReason ? `: ${sandbox.exitReason}` : "";
1188
+ super(`Sandbox entered ${sandbox.status} before it started${detail}`, 409, "SANDBOX_START_FAILED");
1189
+ this.name = "SandboxStartError";
1190
+ this.latest = sandbox;
1191
+ }
1192
+ };
1193
+ var SandboxExec = class {
1194
+ sandboxId;
1195
+ id;
1196
+ command;
1197
+ status;
1198
+ exitCode;
1199
+ stdout;
1200
+ stderr;
1201
+ exitReason;
1202
+ executeTimeMs;
1203
+ startedAt;
1204
+ finishedAt;
1205
+ /** @internal */
1206
+ _client;
1207
+ /** @internal */
1208
+ constructor(data, client) {
1209
+ this._client = client;
1210
+ this._apply(data);
1211
+ }
1212
+ /** @internal Overwrite this exec's fields in place from a fresh wire snapshot. */
1213
+ _apply(data) {
1214
+ this.sandboxId = data.sandbox_id;
1215
+ this.id = data.exec_id;
1216
+ this.command = data.command;
1217
+ this.status = data.status;
1218
+ this.exitCode = data.exit_code;
1219
+ this.stdout = data.stdout;
1220
+ this.stderr = data.stderr;
1221
+ this.exitReason = data.exit_reason;
1222
+ this.executeTimeMs = data.execute_time_ms;
1223
+ this.startedAt = new Date(data.started_at);
1224
+ this.finishedAt = data.finished_at ? new Date(data.finished_at) : void 0;
1225
+ return this;
1226
+ }
1227
+ toJSON() {
1228
+ return {
1229
+ sandboxId: this.sandboxId,
1230
+ id: this.id,
1231
+ command: this.command,
1232
+ status: this.status,
1233
+ exitCode: this.exitCode,
1234
+ stdout: this.stdout,
1235
+ stderr: this.stderr,
1236
+ exitReason: this.exitReason,
1237
+ executeTimeMs: this.executeTimeMs,
1238
+ startedAt: this.startedAt,
1239
+ finishedAt: this.finishedAt
1240
+ };
1241
+ }
1242
+ /** Re-fetch this exec and update it in place, returning the same object. */
1243
+ async refresh() {
1244
+ const data = await unwrap(this._client.GET("/api/sandboxes/{sid}/execs/{eid}", { params: { path: {
1245
+ sid: this.sandboxId,
1246
+ eid: this.id
1247
+ } } }));
1248
+ return this._apply(data);
1249
+ }
1250
+ /** Cancel this exec and update it in place, returning the same object. */
1251
+ async cancel() {
1252
+ const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/execs/{eid}/cancel", { params: { path: {
1253
+ sid: this.sandboxId,
1254
+ eid: this.id
1255
+ } } }));
1256
+ return this._apply(data);
1257
+ }
1258
+ };
1259
+ var Sandbox = class {
1260
+ id;
1261
+ status;
1262
+ vcpuCount;
1263
+ memSizeMiB;
1264
+ maxTtlSeconds;
1265
+ maxConcurrentExecs;
1266
+ endpoints;
1267
+ createdAt;
1268
+ runningAt;
1269
+ finishedAt;
1270
+ lastActiveAt;
1271
+ expiresAt;
1272
+ exitReason;
1273
+ /** @internal */
1274
+ _client;
1275
+ /** @internal */
1276
+ constructor(data, client) {
1277
+ this._client = client;
1278
+ this._apply(data);
1279
+ }
1280
+ /** @internal Overwrite this sandbox's fields in place from a fresh wire snapshot. */
1281
+ _apply(data) {
1282
+ this.id = data.sandbox_id;
1283
+ this.status = data.status;
1284
+ this.vcpuCount = data.vcpu_count;
1285
+ this.memSizeMiB = data.mem_size_mib;
1286
+ this.maxTtlSeconds = data.max_ttl_seconds;
1287
+ this.maxConcurrentExecs = data.max_concurrent_execs;
1288
+ this.endpoints = data.endpoints?.map((endpoint) => ({ ...endpoint }));
1289
+ this.createdAt = new Date(data.created_at);
1290
+ this.runningAt = data.running_at ? new Date(data.running_at) : void 0;
1291
+ this.finishedAt = data.finished_at ? new Date(data.finished_at) : void 0;
1292
+ this.lastActiveAt = new Date(data.last_active_at);
1293
+ this.expiresAt = data.expires_at ? new Date(data.expires_at) : void 0;
1294
+ this.exitReason = data.exit_reason;
1295
+ return this;
1296
+ }
1297
+ toJSON() {
1298
+ return {
1299
+ id: this.id,
1300
+ status: this.status,
1301
+ vcpuCount: this.vcpuCount,
1302
+ memSizeMiB: this.memSizeMiB,
1303
+ maxTtlSeconds: this.maxTtlSeconds,
1304
+ maxConcurrentExecs: this.maxConcurrentExecs,
1305
+ endpoints: this.endpoints?.map((endpoint) => ({ ...endpoint })),
1306
+ createdAt: this.createdAt,
1307
+ runningAt: this.runningAt,
1308
+ finishedAt: this.finishedAt,
1309
+ lastActiveAt: this.lastActiveAt,
1310
+ expiresAt: this.expiresAt,
1311
+ exitReason: this.exitReason
1312
+ };
1313
+ }
1314
+ /** Re-fetch this sandbox. */
1315
+ async refresh() {
1316
+ const data = await unwrap(this._client.GET("/api/sandboxes/{sid}", { params: { path: { sid: this.id } } }));
1317
+ return this._apply(data);
1318
+ }
1319
+ /** Start this sandbox. */
1320
+ async start(options = {}) {
1321
+ const timeoutMs = options.timeoutMs ?? 3e4;
1322
+ validateTimeoutMs(timeoutMs);
1323
+ const deadline = Date.now() + timeoutMs;
1324
+ const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/start", { params: {
1325
+ path: { sid: this.id },
1326
+ query: { wait: false }
1327
+ } }));
1328
+ this._apply(data);
1329
+ return waitForSandboxStart(this, deadline, timeoutMs);
1330
+ }
1331
+ /** Stop this sandbox. */
1332
+ async stop(options = {}) {
1333
+ const timeoutMs = options.timeoutMs ?? 3e4;
1334
+ validateTimeoutMs(timeoutMs);
1335
+ const deadline = Date.now() + timeoutMs;
1336
+ const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/stop", { params: { path: { sid: this.id } } }));
1337
+ this._apply(data);
1338
+ for (;;) {
1339
+ if ([
1340
+ "stopped",
1341
+ "exited",
1342
+ "failed"
1343
+ ].includes(this.status)) return this;
1344
+ if (this.status !== "stopping") throw new ArchilError(`Sandbox entered ${this.status} before it stopped`, 409, "SANDBOX_STOP_FAILED");
1345
+ const remaining = deadline - Date.now();
1346
+ if (remaining <= 0) throw new SandboxWaitTimeoutError("stop", timeoutMs, this);
1347
+ await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_INTERVAL_MS, remaining)));
1348
+ await this.refresh();
1349
+ }
1350
+ }
1351
+ /** Pause this sandbox, preserving its CPU and memory state. */
1352
+ async pause(options = {}) {
1353
+ const timeoutMs = options.timeoutMs ?? 3e4;
1354
+ validateTimeoutMs(timeoutMs);
1355
+ const deadline = Date.now() + timeoutMs;
1356
+ const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/pause", { params: { path: { sid: this.id } } }));
1357
+ this._apply(data);
1358
+ for (;;) {
1359
+ if (this.status === "paused") return this;
1360
+ if (this.status !== "pausing") throw new ArchilError(`Sandbox entered ${this.status} before it paused`, 409, "SANDBOX_PAUSE_FAILED");
1361
+ const remaining = deadline - Date.now();
1362
+ if (remaining <= 0) throw new SandboxWaitTimeoutError("pause", timeoutMs, this);
1363
+ await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_INTERVAL_MS, remaining)));
1364
+ await this.refresh();
1365
+ }
1366
+ }
1367
+ /** Resume this sandbox from its preserved CPU and memory state. */
1368
+ async resume(options = {}) {
1369
+ const timeoutMs = options.timeoutMs ?? 3e4;
1370
+ validateTimeoutMs(timeoutMs);
1371
+ const deadline = Date.now() + timeoutMs;
1372
+ const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/resume", { params: {
1373
+ path: { sid: this.id },
1374
+ query: { wait: false }
1375
+ } }));
1376
+ this._apply(data);
1377
+ for (;;) {
1378
+ if (this.status === "running") return this;
1379
+ if (this.status !== "pending") throw new ArchilError(`Sandbox entered ${this.status} before it resumed`, 409, "SANDBOX_RESUME_FAILED");
1380
+ const remaining = deadline - Date.now();
1381
+ if (remaining <= 0) throw new SandboxWaitTimeoutError("resume", timeoutMs, this);
1382
+ await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_INTERVAL_MS, remaining)));
1383
+ await this.refresh();
1384
+ }
1385
+ }
1386
+ async exec(command, options = {}) {
1387
+ const timeoutMs = options.timeoutMs ?? 3e4;
1388
+ validateTimeoutMs(timeoutMs);
1389
+ const deadline = Date.now() + timeoutMs;
1390
+ const exec = new SandboxExec(await unwrap(this._client.POST("/api/sandboxes/{sid}/execs", {
1391
+ params: {
1392
+ path: { sid: this.id },
1393
+ query: { wait: false }
1394
+ },
1395
+ body: {
1396
+ command,
1397
+ command_tty: options.commandTty,
1398
+ env: options.env,
1399
+ timeout_seconds: options.timeoutSeconds
1400
+ }
1401
+ })), this._client);
1402
+ if (exec.status !== "running") return exec;
1403
+ for (;;) {
1404
+ const remaining = deadline - Date.now();
1405
+ if (remaining <= 0) throw new SandboxWaitTimeoutError("exec", timeoutMs, exec);
1406
+ await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_INTERVAL_MS, remaining)));
1407
+ await exec.refresh();
1408
+ if (exec.status !== "running") return exec;
1409
+ }
1410
+ }
1411
+ async listExecs() {
1412
+ return ((await unwrap(this._client.GET("/api/sandboxes/{sid}/execs", { params: { path: { sid: this.id } } })))?.execs ?? []).map((exec) => new SandboxExec(exec, this._client));
1413
+ }
1414
+ async getExec(execId) {
1415
+ return new SandboxExec(await unwrap(this._client.GET("/api/sandboxes/{sid}/execs/{eid}", { params: { path: {
1416
+ sid: this.id,
1417
+ eid: execId
1418
+ } } })), this._client);
1419
+ }
1420
+ async cancelExec(execId) {
1421
+ return new SandboxExec(await unwrap(this._client.POST("/api/sandboxes/{sid}/execs/{eid}/cancel", { params: { path: {
1422
+ sid: this.id,
1423
+ eid: execId
1424
+ } } })), this._client);
1425
+ }
1426
+ };
1427
+ /** @internal Poll `sandbox` in place until it is running (or the deadline passes). */
1428
+ async function waitForSandboxStart(sandbox, deadline, timeoutMs) {
1429
+ for (;;) {
1430
+ if (sandbox.status === "running") return sandbox;
1431
+ if (sandbox.status !== "pending") throw new SandboxStartError(sandbox);
1432
+ const remaining = deadline - Date.now();
1433
+ if (remaining <= 0) throw new SandboxWaitTimeoutError("start", timeoutMs, sandbox);
1434
+ await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_INTERVAL_MS, remaining)));
1435
+ await sandbox.refresh();
1436
+ }
1437
+ }
1438
+ //#endregion
1439
+ //#region src/sandboxes.ts
1440
+ var Sandboxes = class {
1441
+ /** @internal */
1442
+ _client;
1443
+ /** @internal */
1444
+ constructor(client) {
1445
+ this._client = client;
1446
+ }
1447
+ /** List the account's sandboxes, oldest first. */
1448
+ async list(options = {}) {
1449
+ const filesystem = typeof options.disk === "string" ? options.disk : options.disk?.id;
1450
+ return ((await unwrap(this._client.GET("/api/sandboxes", { params: { query: { filesystem } } })))?.sandboxes ?? []).map((sandbox) => new Sandbox(sandbox, this._client));
1451
+ }
1452
+ async get(id) {
1453
+ return new Sandbox(await unwrap(this._client.GET("/api/sandboxes/{sid}", { params: { path: { sid: id } } })), this._client);
1454
+ }
1455
+ async create(request = {}, options = {}) {
1456
+ const timeoutMs = options.timeoutMs ?? 3e4;
1457
+ validateTimeoutMs(timeoutMs);
1458
+ const deadline = Date.now() + timeoutMs;
1459
+ const body = {
1460
+ vcpu_count: request.vcpuCount,
1461
+ mem_size_mib: request.memSizeMiB,
1462
+ base_image: request.baseImage,
1463
+ env: request.env,
1464
+ max_ttl_seconds: request.maxTtlSeconds,
1465
+ max_concurrent_execs: request.maxConcurrentExecs
1466
+ };
1467
+ return waitForSandboxStart(new Sandbox(await unwrap(this._client.POST("/api/sandboxes", {
1468
+ params: { query: { wait: false } },
1469
+ body
1470
+ })), this._client), deadline, timeoutMs);
1471
+ }
1472
+ };
1160
1473
  //#endregion
1161
1474
  //#region src/tokens.ts
1162
1475
  var Tokens = class {
@@ -1439,6 +1752,7 @@ function diskIdFromMount(m) {
1439
1752
  }
1440
1753
  var Archil = class {
1441
1754
  disks;
1755
+ sandboxes;
1442
1756
  tokens;
1443
1757
  /** @internal */
1444
1758
  _client;
@@ -1456,6 +1770,7 @@ var Archil = class {
1456
1770
  const s3BaseUrl = opts.s3BaseUrl ?? envVar("ARCHIL_S3_BASE_URL") ?? deriveS3BaseUrl(controlBaseUrl);
1457
1771
  this._client = client;
1458
1772
  this.disks = new Disks(client, region, s3BaseUrl);
1773
+ this.sandboxes = new Sandboxes(client);
1459
1774
  this.tokens = new Tokens(client);
1460
1775
  }
1461
1776
  /**
@@ -1513,6 +1828,15 @@ function listDisks(opts) {
1513
1828
  function getDisk(id) {
1514
1829
  return archil().disks.get(id);
1515
1830
  }
1831
+ function createSandbox(req = {}, opts = {}) {
1832
+ return archil().sandboxes.create(req, opts);
1833
+ }
1834
+ function listSandboxes(opts) {
1835
+ return archil().sandboxes.list(opts);
1836
+ }
1837
+ function getSandbox(id) {
1838
+ return archil().sandboxes.get(id);
1839
+ }
1516
1840
  function listApiKeys(opts) {
1517
1841
  return archil().tokens.list(opts);
1518
1842
  }
@@ -1545,6 +1869,11 @@ exports.ArchilS3Error = ArchilS3Error;
1545
1869
  exports.Disk = Disk;
1546
1870
  exports.DiskMultipart = DiskMultipart;
1547
1871
  exports.Disks = Disks;
1872
+ exports.Sandbox = Sandbox;
1873
+ exports.SandboxExec = SandboxExec;
1874
+ exports.SandboxStartError = SandboxStartError;
1875
+ exports.SandboxWaitTimeoutError = SandboxWaitTimeoutError;
1876
+ exports.Sandboxes = Sandboxes;
1548
1877
  exports.Tokens = Tokens;
1549
1878
  exports.USER_AGENT = USER_AGENT;
1550
1879
  exports.VERSION = VERSION;
@@ -1552,10 +1881,13 @@ exports.Workspace = Workspace;
1552
1881
  exports.configure = configure;
1553
1882
  exports.createApiKey = createApiKey;
1554
1883
  exports.createDisk = createDisk;
1884
+ exports.createSandbox = createSandbox;
1555
1885
  exports.deleteApiKey = deleteApiKey;
1556
1886
  exports.effectiveUploadPartSize = effectiveUploadPartSize;
1557
1887
  exports.exec = exec;
1558
1888
  exports.getDisk = getDisk;
1889
+ exports.getSandbox = getSandbox;
1559
1890
  exports.listApiKeys = listApiKeys;
1560
1891
  exports.listDisks = listDisks;
1892
+ exports.listSandboxes = listSandboxes;
1561
1893
  exports.workspace = workspace;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { $ as TokenUser, A as ApiTokenResponse, B as DiskStatus, C as PutObjectOptions, D as ShareUrlResult, E as ShareUrlOptions, F as CreateApiTokenRequest, G as GrepMatch, H as ExecDiskResult, I as CreateDiskRequest, J as MountConfigResponse, K as GrepStoppedReason, L as Delegation, M as AwsStsUser, N as AzureBlobMount, O as UploadPart, P as ConnectedClient, Q as S3Mount, R as DiskMetrics, S as PosixCreateAttrs, T as S3Object, U as ExecRequest, V as DiskUser, W as GCSMount, X as R2Mount, Y as MountResponse, Z as S3CompatibleMount, _ as MultipartUploadListing, a as DeleteObjectsResult, b as PartInfo, c as ExecResult, d as ListMultipartUploadsOptions, et as FileSystem, f as ListObjectsOptions, g as MultipartUpload, h as MountOptions, i as DeleteObjectsOptions, j as AuthorizedUser, k as effectiveUploadPartSize, l as GrepOptions, m as ListPartsOptions, n as CompletedMultipartUpload, o as Disk, p as ListObjectsResult, q as MountConfig, r as DeleteObjectsError, s as DiskMultipart, t as AppendObjectOptions, tt as ApiClient, u as GrepResult, v as MultipartUploadSummary, w as PutObjectResult, x as PartListing, y as ObjectMetadata, z as DiskResponse } from "./disk-DEqV3mtA.cjs";
2
+ import { components } from "@archildata/api-types";
2
3
 
3
4
  //#region src/disks.d.ts
4
5
  interface ListDisksOptions {
@@ -53,6 +54,202 @@ declare class Disks {
53
54
  create(req: CreateDiskRequest): Promise<CreateDiskResult>;
54
55
  }
55
56
  //#endregion
57
+ //#region src/errors.d.ts
58
+ /**
59
+ * Base class for every error the SDK throws. Catch with `instanceof ArchilError`
60
+ * to handle control-plane and S3 failures uniformly; `status` is the HTTP status
61
+ * code and `code` a machine-readable error code when the server provided one.
62
+ */
63
+ declare class ArchilError extends Error {
64
+ /** HTTP status code associated with the failure. */
65
+ readonly status: number;
66
+ /** Machine-readable error code (e.g. an S3 code like "NoSuchKey"), if known. */
67
+ readonly code?: string;
68
+ constructor(message: string, status: number, code?: string);
69
+ }
70
+ /** Error from the control-plane REST API. */
71
+ declare class ArchilApiError extends ArchilError {
72
+ constructor(message: string, status: number, code?: string);
73
+ }
74
+ /**
75
+ * Error from the S3-compatible object API (getObject/putObject/deleteObject/
76
+ * headObject/listObjects). The gateway returns an S3-style XML `<Error>` body;
77
+ * this surfaces its parts as structured fields (`status`, `code`, `requestId`)
78
+ * rather than a raw blob, while keeping the full body on `raw` for debugging.
79
+ */
80
+ declare class ArchilS3Error extends ArchilError {
81
+ /** S3 request id, if the gateway returned one. */
82
+ readonly requestId?: string;
83
+ /** Raw response body (the XML document), for debugging. */
84
+ readonly raw: string;
85
+ constructor(opts: {
86
+ operation: string;
87
+ statusCode: number;
88
+ statusText?: string;
89
+ code?: string;
90
+ message?: string;
91
+ requestId?: string;
92
+ raw: string;
93
+ });
94
+ }
95
+ //#endregion
96
+ //#region src/sandbox.d.ts
97
+ /** @internal */
98
+ type SandboxWire = components["schemas"]["Sandbox"];
99
+ /** @internal */
100
+ type SandboxExecWire = components["schemas"]["SandboxExec"];
101
+ type SandboxStatus = components["schemas"]["SandboxState"];
102
+ type SandboxExecStatus = components["schemas"]["SandboxExecState"];
103
+ interface SandboxEndpoint {
104
+ port: number;
105
+ hostname: string;
106
+ }
107
+ interface SandboxResponse {
108
+ id: string;
109
+ status: SandboxStatus;
110
+ vcpuCount: number;
111
+ memSizeMiB: number;
112
+ maxTtlSeconds: number;
113
+ maxConcurrentExecs: number;
114
+ endpoints?: SandboxEndpoint[];
115
+ createdAt: Date;
116
+ runningAt?: Date;
117
+ finishedAt?: Date;
118
+ lastActiveAt: Date;
119
+ expiresAt?: Date;
120
+ exitReason?: string;
121
+ }
122
+ interface SandboxExecResponse {
123
+ sandboxId: string;
124
+ id: string;
125
+ command: string;
126
+ status: SandboxExecStatus;
127
+ exitCode?: number;
128
+ stdout?: string;
129
+ stderr?: string;
130
+ exitReason?: string;
131
+ executeTimeMs?: number;
132
+ startedAt: Date;
133
+ finishedAt?: Date;
134
+ }
135
+ interface SandboxWaitOptions {
136
+ timeoutMs?: number;
137
+ }
138
+ type SandboxExecOptions = {
139
+ commandTty?: boolean;
140
+ env?: Record<string, string>;
141
+ timeoutSeconds?: number;
142
+ } & SandboxWaitOptions;
143
+ /**
144
+ * The requested SDK-side wait expired. The remote sandbox operation continues;
145
+ * `latest` is the same `Sandbox`/`SandboxExec` the operation was called on,
146
+ * updated in place to the last state observed before the deadline.
147
+ */
148
+ declare class SandboxWaitTimeoutError extends ArchilError {
149
+ readonly operation: "start" | "stop" | "pause" | "resume" | "exec";
150
+ readonly timeoutMs: number;
151
+ readonly latest: Sandbox | SandboxExec;
152
+ constructor(operation: "start" | "stop" | "pause" | "resume" | "exec", timeoutMs: number, latest: Sandbox | SandboxExec);
153
+ }
154
+ /** The sandbox entered an inactive state before startup completed. */
155
+ declare class SandboxStartError extends ArchilError {
156
+ readonly latest: Sandbox;
157
+ constructor(sandbox: Sandbox);
158
+ }
159
+ declare class SandboxExec {
160
+ sandboxId: string;
161
+ id: string;
162
+ command: string;
163
+ status: SandboxExecStatus;
164
+ exitCode?: number;
165
+ stdout?: string;
166
+ stderr?: string;
167
+ exitReason?: string;
168
+ executeTimeMs?: number;
169
+ startedAt: Date;
170
+ finishedAt?: Date;
171
+ /** @internal */
172
+ private readonly _client;
173
+ /** @internal */
174
+ constructor(data: SandboxExecWire, client: ApiClient);
175
+ /** @internal Overwrite this exec's fields in place from a fresh wire snapshot. */
176
+ private _apply;
177
+ toJSON(): SandboxExecResponse;
178
+ /** Re-fetch this exec and update it in place, returning the same object. */
179
+ refresh(): Promise<SandboxExec>;
180
+ /** Cancel this exec and update it in place, returning the same object. */
181
+ cancel(): Promise<SandboxExec>;
182
+ }
183
+ declare class Sandbox {
184
+ id: string;
185
+ status: SandboxStatus;
186
+ vcpuCount: number;
187
+ memSizeMiB: number;
188
+ maxTtlSeconds: number;
189
+ maxConcurrentExecs: number;
190
+ endpoints?: SandboxEndpoint[];
191
+ createdAt: Date;
192
+ runningAt?: Date;
193
+ finishedAt?: Date;
194
+ lastActiveAt: Date;
195
+ expiresAt?: Date;
196
+ exitReason?: string;
197
+ /** @internal */
198
+ private readonly _client;
199
+ /** @internal */
200
+ constructor(data: SandboxWire, client: ApiClient);
201
+ /** @internal Overwrite this sandbox's fields in place from a fresh wire snapshot. */
202
+ private _apply;
203
+ toJSON(): SandboxResponse;
204
+ /** Re-fetch this sandbox. */
205
+ refresh(): Promise<this>;
206
+ /** Start this sandbox. */
207
+ start(options?: SandboxWaitOptions): Promise<Sandbox>;
208
+ /** Stop this sandbox. */
209
+ stop(options?: SandboxWaitOptions): Promise<this>;
210
+ /** Pause this sandbox, preserving its CPU and memory state. */
211
+ pause(options?: SandboxWaitOptions): Promise<this>;
212
+ /** Resume this sandbox from its preserved CPU and memory state. */
213
+ resume(options?: SandboxWaitOptions): Promise<this>;
214
+ exec(command: string, options?: SandboxExecOptions): Promise<SandboxExec>;
215
+ listExecs(): Promise<SandboxExec[]>;
216
+ getExec(execId: string): Promise<SandboxExec>;
217
+ cancelExec(execId: string): Promise<SandboxExec>;
218
+ }
219
+ //#endregion
220
+ //#region src/sandboxes.d.ts
221
+ interface CreateSandboxRequest {
222
+ vcpuCount?: number;
223
+ memSizeMiB?: number;
224
+ /**
225
+ * Public Linux OCI image reference for the sandbox's root filesystem.
226
+ * Docker Hub shorthand and any public registry are accepted; the tag
227
+ * defaults to `latest`, and mutable tags are pinned to immutable digests
228
+ * when the sandbox is created. Defaults to `ubuntu:26.04`.
229
+ *
230
+ * Examples: `ubuntu`, `node:24-bookworm`, `ghcr.io/owner/app:v2`,
231
+ * `alpine@sha256:<digest>`.
232
+ */
233
+ baseImage?: string;
234
+ env?: Record<string, string>;
235
+ maxTtlSeconds?: number;
236
+ maxConcurrentExecs?: number;
237
+ }
238
+ interface ListSandboxesOptions {
239
+ /** Only return sandboxes that mount this disk. */
240
+ disk?: Disk | string;
241
+ }
242
+ declare class Sandboxes {
243
+ /** @internal */
244
+ private readonly _client;
245
+ /** @internal */
246
+ constructor(client: ApiClient);
247
+ /** List the account's sandboxes, oldest first. */
248
+ list(options?: ListSandboxesOptions): Promise<Sandbox[]>;
249
+ get(id: string): Promise<Sandbox>;
250
+ create(request?: CreateSandboxRequest, options?: SandboxWaitOptions): Promise<Sandbox>;
251
+ }
252
+ //#endregion
56
253
  //#region src/tokens.d.ts
57
254
  interface ListTokensOptions {
58
255
  limit?: number;
@@ -199,6 +396,7 @@ interface ExecOptions {
199
396
  }
200
397
  declare class Archil {
201
398
  readonly disks: Disks;
399
+ readonly sandboxes: Sandboxes;
202
400
  readonly tokens: Tokens;
203
401
  /** @internal */
204
402
  private readonly _client;
@@ -219,45 +417,6 @@ declare class Archil {
219
417
  workspace(mounts: Record<string, ExecMount>): Workspace;
220
418
  }
221
419
  //#endregion
222
- //#region src/errors.d.ts
223
- /**
224
- * Base class for every error the SDK throws. Catch with `instanceof ArchilError`
225
- * to handle control-plane and S3 failures uniformly; `status` is the HTTP status
226
- * code and `code` a machine-readable error code when the server provided one.
227
- */
228
- declare class ArchilError extends Error {
229
- /** HTTP status code associated with the failure. */
230
- readonly status: number;
231
- /** Machine-readable error code (e.g. an S3 code like "NoSuchKey"), if known. */
232
- readonly code?: string;
233
- constructor(message: string, status: number, code?: string);
234
- }
235
- /** Error from the control-plane REST API. */
236
- declare class ArchilApiError extends ArchilError {
237
- constructor(message: string, status: number, code?: string);
238
- }
239
- /**
240
- * Error from the S3-compatible object API (getObject/putObject/deleteObject/
241
- * headObject/listObjects). The gateway returns an S3-style XML `<Error>` body;
242
- * this surfaces its parts as structured fields (`status`, `code`, `requestId`)
243
- * rather than a raw blob, while keeping the full body on `raw` for debugging.
244
- */
245
- declare class ArchilS3Error extends ArchilError {
246
- /** S3 request id, if the gateway returned one. */
247
- readonly requestId?: string;
248
- /** Raw response body (the XML document), for debugging. */
249
- readonly raw: string;
250
- constructor(opts: {
251
- operation: string;
252
- statusCode: number;
253
- statusText?: string;
254
- code?: string;
255
- message?: string;
256
- requestId?: string;
257
- raw: string;
258
- });
259
- }
260
- //#endregion
261
420
  //#region src/version.d.ts
262
421
  declare const VERSION: string;
263
422
  declare const USER_AGENT: string;
@@ -267,6 +426,9 @@ declare function configure(options: ArchilOptions): void;
267
426
  declare function createDisk(req: CreateDiskRequest): Promise<CreateDiskResult>;
268
427
  declare function listDisks(opts?: ListDisksOptions): Promise<Disk[]>;
269
428
  declare function getDisk(id: string): Promise<Disk>;
429
+ declare function createSandbox(req?: CreateSandboxRequest, opts?: SandboxWaitOptions): Promise<Sandbox>;
430
+ declare function listSandboxes(opts?: ListSandboxesOptions): Promise<Sandbox[]>;
431
+ declare function getSandbox(id: string): Promise<Sandbox>;
270
432
  declare function listApiKeys(opts?: ListTokensOptions): Promise<ApiTokenResponse[]>;
271
433
  declare function createApiKey(req: CreateApiTokenRequest): Promise<ApiTokenResponse & {
272
434
  token?: string;
@@ -284,4 +446,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
284
446
  */
285
447
  declare function workspace(mounts: Record<string, ExecMount>): Workspace;
286
448
  //#endregion
287
- export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, 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 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 S3CompatibleMount, type S3Mount, type S3Object, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
449
+ export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxRequest, 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 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 S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEndpoint, SandboxExec, type SandboxExecOptions, type SandboxExecResponse, type SandboxExecStatus, type SandboxResponse, SandboxStartError, type SandboxStatus, type SandboxWaitOptions, SandboxWaitTimeoutError, 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
@@ -1,4 +1,5 @@
1
1
  import { $ as TokenUser, A as ApiTokenResponse, B as DiskStatus, C as PutObjectOptions, D as ShareUrlResult, E as ShareUrlOptions, F as CreateApiTokenRequest, G as GrepMatch, H as ExecDiskResult, I as CreateDiskRequest, J as MountConfigResponse, K as GrepStoppedReason, L as Delegation, M as AwsStsUser, N as AzureBlobMount, O as UploadPart, P as ConnectedClient, Q as S3Mount, R as DiskMetrics, S as PosixCreateAttrs, T as S3Object, U as ExecRequest, V as DiskUser, W as GCSMount, X as R2Mount, Y as MountResponse, Z as S3CompatibleMount, _ as MultipartUploadListing, a as DeleteObjectsResult, b as PartInfo, c as ExecResult, d as ListMultipartUploadsOptions, et as FileSystem, f as ListObjectsOptions, g as MultipartUpload, h as MountOptions, i as DeleteObjectsOptions, j as AuthorizedUser, k as effectiveUploadPartSize, l as GrepOptions, m as ListPartsOptions, n as CompletedMultipartUpload, o as Disk, p as ListObjectsResult, q as MountConfig, r as DeleteObjectsError, s as DiskMultipart, t as AppendObjectOptions, tt as ApiClient, u as GrepResult, v as MultipartUploadSummary, w as PutObjectResult, x as PartListing, y as ObjectMetadata, z as DiskResponse } from "./disk-DEqV3mtA.mjs";
2
+ import { components } from "@archildata/api-types";
2
3
 
3
4
  //#region src/disks.d.ts
4
5
  interface ListDisksOptions {
@@ -53,6 +54,202 @@ declare class Disks {
53
54
  create(req: CreateDiskRequest): Promise<CreateDiskResult>;
54
55
  }
55
56
  //#endregion
57
+ //#region src/errors.d.ts
58
+ /**
59
+ * Base class for every error the SDK throws. Catch with `instanceof ArchilError`
60
+ * to handle control-plane and S3 failures uniformly; `status` is the HTTP status
61
+ * code and `code` a machine-readable error code when the server provided one.
62
+ */
63
+ declare class ArchilError extends Error {
64
+ /** HTTP status code associated with the failure. */
65
+ readonly status: number;
66
+ /** Machine-readable error code (e.g. an S3 code like "NoSuchKey"), if known. */
67
+ readonly code?: string;
68
+ constructor(message: string, status: number, code?: string);
69
+ }
70
+ /** Error from the control-plane REST API. */
71
+ declare class ArchilApiError extends ArchilError {
72
+ constructor(message: string, status: number, code?: string);
73
+ }
74
+ /**
75
+ * Error from the S3-compatible object API (getObject/putObject/deleteObject/
76
+ * headObject/listObjects). The gateway returns an S3-style XML `<Error>` body;
77
+ * this surfaces its parts as structured fields (`status`, `code`, `requestId`)
78
+ * rather than a raw blob, while keeping the full body on `raw` for debugging.
79
+ */
80
+ declare class ArchilS3Error extends ArchilError {
81
+ /** S3 request id, if the gateway returned one. */
82
+ readonly requestId?: string;
83
+ /** Raw response body (the XML document), for debugging. */
84
+ readonly raw: string;
85
+ constructor(opts: {
86
+ operation: string;
87
+ statusCode: number;
88
+ statusText?: string;
89
+ code?: string;
90
+ message?: string;
91
+ requestId?: string;
92
+ raw: string;
93
+ });
94
+ }
95
+ //#endregion
96
+ //#region src/sandbox.d.ts
97
+ /** @internal */
98
+ type SandboxWire = components["schemas"]["Sandbox"];
99
+ /** @internal */
100
+ type SandboxExecWire = components["schemas"]["SandboxExec"];
101
+ type SandboxStatus = components["schemas"]["SandboxState"];
102
+ type SandboxExecStatus = components["schemas"]["SandboxExecState"];
103
+ interface SandboxEndpoint {
104
+ port: number;
105
+ hostname: string;
106
+ }
107
+ interface SandboxResponse {
108
+ id: string;
109
+ status: SandboxStatus;
110
+ vcpuCount: number;
111
+ memSizeMiB: number;
112
+ maxTtlSeconds: number;
113
+ maxConcurrentExecs: number;
114
+ endpoints?: SandboxEndpoint[];
115
+ createdAt: Date;
116
+ runningAt?: Date;
117
+ finishedAt?: Date;
118
+ lastActiveAt: Date;
119
+ expiresAt?: Date;
120
+ exitReason?: string;
121
+ }
122
+ interface SandboxExecResponse {
123
+ sandboxId: string;
124
+ id: string;
125
+ command: string;
126
+ status: SandboxExecStatus;
127
+ exitCode?: number;
128
+ stdout?: string;
129
+ stderr?: string;
130
+ exitReason?: string;
131
+ executeTimeMs?: number;
132
+ startedAt: Date;
133
+ finishedAt?: Date;
134
+ }
135
+ interface SandboxWaitOptions {
136
+ timeoutMs?: number;
137
+ }
138
+ type SandboxExecOptions = {
139
+ commandTty?: boolean;
140
+ env?: Record<string, string>;
141
+ timeoutSeconds?: number;
142
+ } & SandboxWaitOptions;
143
+ /**
144
+ * The requested SDK-side wait expired. The remote sandbox operation continues;
145
+ * `latest` is the same `Sandbox`/`SandboxExec` the operation was called on,
146
+ * updated in place to the last state observed before the deadline.
147
+ */
148
+ declare class SandboxWaitTimeoutError extends ArchilError {
149
+ readonly operation: "start" | "stop" | "pause" | "resume" | "exec";
150
+ readonly timeoutMs: number;
151
+ readonly latest: Sandbox | SandboxExec;
152
+ constructor(operation: "start" | "stop" | "pause" | "resume" | "exec", timeoutMs: number, latest: Sandbox | SandboxExec);
153
+ }
154
+ /** The sandbox entered an inactive state before startup completed. */
155
+ declare class SandboxStartError extends ArchilError {
156
+ readonly latest: Sandbox;
157
+ constructor(sandbox: Sandbox);
158
+ }
159
+ declare class SandboxExec {
160
+ sandboxId: string;
161
+ id: string;
162
+ command: string;
163
+ status: SandboxExecStatus;
164
+ exitCode?: number;
165
+ stdout?: string;
166
+ stderr?: string;
167
+ exitReason?: string;
168
+ executeTimeMs?: number;
169
+ startedAt: Date;
170
+ finishedAt?: Date;
171
+ /** @internal */
172
+ private readonly _client;
173
+ /** @internal */
174
+ constructor(data: SandboxExecWire, client: ApiClient);
175
+ /** @internal Overwrite this exec's fields in place from a fresh wire snapshot. */
176
+ private _apply;
177
+ toJSON(): SandboxExecResponse;
178
+ /** Re-fetch this exec and update it in place, returning the same object. */
179
+ refresh(): Promise<SandboxExec>;
180
+ /** Cancel this exec and update it in place, returning the same object. */
181
+ cancel(): Promise<SandboxExec>;
182
+ }
183
+ declare class Sandbox {
184
+ id: string;
185
+ status: SandboxStatus;
186
+ vcpuCount: number;
187
+ memSizeMiB: number;
188
+ maxTtlSeconds: number;
189
+ maxConcurrentExecs: number;
190
+ endpoints?: SandboxEndpoint[];
191
+ createdAt: Date;
192
+ runningAt?: Date;
193
+ finishedAt?: Date;
194
+ lastActiveAt: Date;
195
+ expiresAt?: Date;
196
+ exitReason?: string;
197
+ /** @internal */
198
+ private readonly _client;
199
+ /** @internal */
200
+ constructor(data: SandboxWire, client: ApiClient);
201
+ /** @internal Overwrite this sandbox's fields in place from a fresh wire snapshot. */
202
+ private _apply;
203
+ toJSON(): SandboxResponse;
204
+ /** Re-fetch this sandbox. */
205
+ refresh(): Promise<this>;
206
+ /** Start this sandbox. */
207
+ start(options?: SandboxWaitOptions): Promise<Sandbox>;
208
+ /** Stop this sandbox. */
209
+ stop(options?: SandboxWaitOptions): Promise<this>;
210
+ /** Pause this sandbox, preserving its CPU and memory state. */
211
+ pause(options?: SandboxWaitOptions): Promise<this>;
212
+ /** Resume this sandbox from its preserved CPU and memory state. */
213
+ resume(options?: SandboxWaitOptions): Promise<this>;
214
+ exec(command: string, options?: SandboxExecOptions): Promise<SandboxExec>;
215
+ listExecs(): Promise<SandboxExec[]>;
216
+ getExec(execId: string): Promise<SandboxExec>;
217
+ cancelExec(execId: string): Promise<SandboxExec>;
218
+ }
219
+ //#endregion
220
+ //#region src/sandboxes.d.ts
221
+ interface CreateSandboxRequest {
222
+ vcpuCount?: number;
223
+ memSizeMiB?: number;
224
+ /**
225
+ * Public Linux OCI image reference for the sandbox's root filesystem.
226
+ * Docker Hub shorthand and any public registry are accepted; the tag
227
+ * defaults to `latest`, and mutable tags are pinned to immutable digests
228
+ * when the sandbox is created. Defaults to `ubuntu:26.04`.
229
+ *
230
+ * Examples: `ubuntu`, `node:24-bookworm`, `ghcr.io/owner/app:v2`,
231
+ * `alpine@sha256:<digest>`.
232
+ */
233
+ baseImage?: string;
234
+ env?: Record<string, string>;
235
+ maxTtlSeconds?: number;
236
+ maxConcurrentExecs?: number;
237
+ }
238
+ interface ListSandboxesOptions {
239
+ /** Only return sandboxes that mount this disk. */
240
+ disk?: Disk | string;
241
+ }
242
+ declare class Sandboxes {
243
+ /** @internal */
244
+ private readonly _client;
245
+ /** @internal */
246
+ constructor(client: ApiClient);
247
+ /** List the account's sandboxes, oldest first. */
248
+ list(options?: ListSandboxesOptions): Promise<Sandbox[]>;
249
+ get(id: string): Promise<Sandbox>;
250
+ create(request?: CreateSandboxRequest, options?: SandboxWaitOptions): Promise<Sandbox>;
251
+ }
252
+ //#endregion
56
253
  //#region src/tokens.d.ts
57
254
  interface ListTokensOptions {
58
255
  limit?: number;
@@ -199,6 +396,7 @@ interface ExecOptions {
199
396
  }
200
397
  declare class Archil {
201
398
  readonly disks: Disks;
399
+ readonly sandboxes: Sandboxes;
202
400
  readonly tokens: Tokens;
203
401
  /** @internal */
204
402
  private readonly _client;
@@ -219,45 +417,6 @@ declare class Archil {
219
417
  workspace(mounts: Record<string, ExecMount>): Workspace;
220
418
  }
221
419
  //#endregion
222
- //#region src/errors.d.ts
223
- /**
224
- * Base class for every error the SDK throws. Catch with `instanceof ArchilError`
225
- * to handle control-plane and S3 failures uniformly; `status` is the HTTP status
226
- * code and `code` a machine-readable error code when the server provided one.
227
- */
228
- declare class ArchilError extends Error {
229
- /** HTTP status code associated with the failure. */
230
- readonly status: number;
231
- /** Machine-readable error code (e.g. an S3 code like "NoSuchKey"), if known. */
232
- readonly code?: string;
233
- constructor(message: string, status: number, code?: string);
234
- }
235
- /** Error from the control-plane REST API. */
236
- declare class ArchilApiError extends ArchilError {
237
- constructor(message: string, status: number, code?: string);
238
- }
239
- /**
240
- * Error from the S3-compatible object API (getObject/putObject/deleteObject/
241
- * headObject/listObjects). The gateway returns an S3-style XML `<Error>` body;
242
- * this surfaces its parts as structured fields (`status`, `code`, `requestId`)
243
- * rather than a raw blob, while keeping the full body on `raw` for debugging.
244
- */
245
- declare class ArchilS3Error extends ArchilError {
246
- /** S3 request id, if the gateway returned one. */
247
- readonly requestId?: string;
248
- /** Raw response body (the XML document), for debugging. */
249
- readonly raw: string;
250
- constructor(opts: {
251
- operation: string;
252
- statusCode: number;
253
- statusText?: string;
254
- code?: string;
255
- message?: string;
256
- requestId?: string;
257
- raw: string;
258
- });
259
- }
260
- //#endregion
261
420
  //#region src/version.d.ts
262
421
  declare const VERSION: string;
263
422
  declare const USER_AGENT: string;
@@ -267,6 +426,9 @@ declare function configure(options: ArchilOptions): void;
267
426
  declare function createDisk(req: CreateDiskRequest): Promise<CreateDiskResult>;
268
427
  declare function listDisks(opts?: ListDisksOptions): Promise<Disk[]>;
269
428
  declare function getDisk(id: string): Promise<Disk>;
429
+ declare function createSandbox(req?: CreateSandboxRequest, opts?: SandboxWaitOptions): Promise<Sandbox>;
430
+ declare function listSandboxes(opts?: ListSandboxesOptions): Promise<Sandbox[]>;
431
+ declare function getSandbox(id: string): Promise<Sandbox>;
270
432
  declare function listApiKeys(opts?: ListTokensOptions): Promise<ApiTokenResponse[]>;
271
433
  declare function createApiKey(req: CreateApiTokenRequest): Promise<ApiTokenResponse & {
272
434
  token?: string;
@@ -284,4 +446,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
284
446
  */
285
447
  declare function workspace(mounts: Record<string, ExecMount>): Workspace;
286
448
  //#endregion
287
- export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, 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 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 S3CompatibleMount, type S3Mount, type S3Object, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
449
+ export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxRequest, 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 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 S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEndpoint, SandboxExec, type SandboxExecOptions, type SandboxExecResponse, type SandboxExecStatus, type SandboxResponse, SandboxStartError, type SandboxStatus, type SandboxWaitOptions, SandboxWaitTimeoutError, 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 { _ as USER_AGENT, a as exec, b as ArchilError, c as listDisks, d as Workspace, f as Tokens, g as effectiveUploadPartSize, h as DiskMultipart, i as deleteApiKey, l as workspace, m as Disk, n as createApiKey, o as getDisk, p as Disks, r as createDisk, s as listApiKeys, t as configure, u as Archil, v as VERSION, x as ArchilS3Error, y as ArchilApiError } from "./src-BepELcl6.mjs";
2
- export { Archil, ArchilApiError, ArchilError, ArchilS3Error, Disk, DiskMultipart, Disks, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
1
+ import { C as DiskMultipart, D as ArchilApiError, E as VERSION, O as ArchilError, S as Disk, T as USER_AGENT, _ as Sandbox, a as deleteApiKey, b as SandboxWaitTimeoutError, c as getSandbox, d as listSandboxes, f as workspace, g as Sandboxes, h as Tokens, i as createSandbox, k as ArchilS3Error, 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 SandboxExec, w as effectiveUploadPartSize, x as Disks, y as SandboxStartError } from "./src-DgL0HTS-.mjs";
2
+ export { Archil, ArchilApiError, ArchilError, ArchilS3Error, Disk, DiskMultipart, Disks, Sandbox, SandboxExec, SandboxStartError, SandboxWaitTimeoutError, Sandboxes, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
@@ -111,7 +111,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
111
111
  }
112
112
  //#endregion
113
113
  //#region src/version.ts
114
- const VERSION = "0.8.22";
114
+ const VERSION = "0.8.23";
115
115
  const USER_AGENT = `archil-js/${VERSION}`;
116
116
  //#endregion
117
117
  //#region src/client.ts
@@ -1134,6 +1134,319 @@ var Disks = class {
1134
1134
  };
1135
1135
  }
1136
1136
  };
1137
+ const POLL_INTERVAL_MS = 500;
1138
+ /** @internal */
1139
+ function validateTimeoutMs(timeoutMs) {
1140
+ if (!Number.isFinite(timeoutMs) || timeoutMs < 0) throw new RangeError("timeoutMs must be a finite, non-negative number");
1141
+ }
1142
+ /**
1143
+ * The requested SDK-side wait expired. The remote sandbox operation continues;
1144
+ * `latest` is the same `Sandbox`/`SandboxExec` the operation was called on,
1145
+ * updated in place to the last state observed before the deadline.
1146
+ */
1147
+ var SandboxWaitTimeoutError = class extends ArchilError {
1148
+ operation;
1149
+ timeoutMs;
1150
+ latest;
1151
+ constructor(operation, timeoutMs, latest) {
1152
+ const subject = operation === "exec" ? "sandbox exec to complete" : `sandbox to ${operation}`;
1153
+ super(`Timed out after ${timeoutMs}ms waiting for ${subject}`, 408, "SANDBOX_WAIT_TIMEOUT");
1154
+ this.name = "SandboxWaitTimeoutError";
1155
+ this.operation = operation;
1156
+ this.timeoutMs = timeoutMs;
1157
+ this.latest = latest;
1158
+ }
1159
+ };
1160
+ /** The sandbox entered an inactive state before startup completed. */
1161
+ var SandboxStartError = class extends ArchilError {
1162
+ latest;
1163
+ constructor(sandbox) {
1164
+ const detail = sandbox.exitReason ? `: ${sandbox.exitReason}` : "";
1165
+ super(`Sandbox entered ${sandbox.status} before it started${detail}`, 409, "SANDBOX_START_FAILED");
1166
+ this.name = "SandboxStartError";
1167
+ this.latest = sandbox;
1168
+ }
1169
+ };
1170
+ var SandboxExec = class {
1171
+ sandboxId;
1172
+ id;
1173
+ command;
1174
+ status;
1175
+ exitCode;
1176
+ stdout;
1177
+ stderr;
1178
+ exitReason;
1179
+ executeTimeMs;
1180
+ startedAt;
1181
+ finishedAt;
1182
+ /** @internal */
1183
+ _client;
1184
+ /** @internal */
1185
+ constructor(data, client) {
1186
+ this._client = client;
1187
+ this._apply(data);
1188
+ }
1189
+ /** @internal Overwrite this exec's fields in place from a fresh wire snapshot. */
1190
+ _apply(data) {
1191
+ this.sandboxId = data.sandbox_id;
1192
+ this.id = data.exec_id;
1193
+ this.command = data.command;
1194
+ this.status = data.status;
1195
+ this.exitCode = data.exit_code;
1196
+ this.stdout = data.stdout;
1197
+ this.stderr = data.stderr;
1198
+ this.exitReason = data.exit_reason;
1199
+ this.executeTimeMs = data.execute_time_ms;
1200
+ this.startedAt = new Date(data.started_at);
1201
+ this.finishedAt = data.finished_at ? new Date(data.finished_at) : void 0;
1202
+ return this;
1203
+ }
1204
+ toJSON() {
1205
+ return {
1206
+ sandboxId: this.sandboxId,
1207
+ id: this.id,
1208
+ command: this.command,
1209
+ status: this.status,
1210
+ exitCode: this.exitCode,
1211
+ stdout: this.stdout,
1212
+ stderr: this.stderr,
1213
+ exitReason: this.exitReason,
1214
+ executeTimeMs: this.executeTimeMs,
1215
+ startedAt: this.startedAt,
1216
+ finishedAt: this.finishedAt
1217
+ };
1218
+ }
1219
+ /** Re-fetch this exec and update it in place, returning the same object. */
1220
+ async refresh() {
1221
+ const data = await unwrap(this._client.GET("/api/sandboxes/{sid}/execs/{eid}", { params: { path: {
1222
+ sid: this.sandboxId,
1223
+ eid: this.id
1224
+ } } }));
1225
+ return this._apply(data);
1226
+ }
1227
+ /** Cancel this exec and update it in place, returning the same object. */
1228
+ async cancel() {
1229
+ const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/execs/{eid}/cancel", { params: { path: {
1230
+ sid: this.sandboxId,
1231
+ eid: this.id
1232
+ } } }));
1233
+ return this._apply(data);
1234
+ }
1235
+ };
1236
+ var Sandbox = class {
1237
+ id;
1238
+ status;
1239
+ vcpuCount;
1240
+ memSizeMiB;
1241
+ maxTtlSeconds;
1242
+ maxConcurrentExecs;
1243
+ endpoints;
1244
+ createdAt;
1245
+ runningAt;
1246
+ finishedAt;
1247
+ lastActiveAt;
1248
+ expiresAt;
1249
+ exitReason;
1250
+ /** @internal */
1251
+ _client;
1252
+ /** @internal */
1253
+ constructor(data, client) {
1254
+ this._client = client;
1255
+ this._apply(data);
1256
+ }
1257
+ /** @internal Overwrite this sandbox's fields in place from a fresh wire snapshot. */
1258
+ _apply(data) {
1259
+ this.id = data.sandbox_id;
1260
+ this.status = data.status;
1261
+ this.vcpuCount = data.vcpu_count;
1262
+ this.memSizeMiB = data.mem_size_mib;
1263
+ this.maxTtlSeconds = data.max_ttl_seconds;
1264
+ this.maxConcurrentExecs = data.max_concurrent_execs;
1265
+ this.endpoints = data.endpoints?.map((endpoint) => ({ ...endpoint }));
1266
+ this.createdAt = new Date(data.created_at);
1267
+ this.runningAt = data.running_at ? new Date(data.running_at) : void 0;
1268
+ this.finishedAt = data.finished_at ? new Date(data.finished_at) : void 0;
1269
+ this.lastActiveAt = new Date(data.last_active_at);
1270
+ this.expiresAt = data.expires_at ? new Date(data.expires_at) : void 0;
1271
+ this.exitReason = data.exit_reason;
1272
+ return this;
1273
+ }
1274
+ toJSON() {
1275
+ return {
1276
+ id: this.id,
1277
+ status: this.status,
1278
+ vcpuCount: this.vcpuCount,
1279
+ memSizeMiB: this.memSizeMiB,
1280
+ maxTtlSeconds: this.maxTtlSeconds,
1281
+ maxConcurrentExecs: this.maxConcurrentExecs,
1282
+ endpoints: this.endpoints?.map((endpoint) => ({ ...endpoint })),
1283
+ createdAt: this.createdAt,
1284
+ runningAt: this.runningAt,
1285
+ finishedAt: this.finishedAt,
1286
+ lastActiveAt: this.lastActiveAt,
1287
+ expiresAt: this.expiresAt,
1288
+ exitReason: this.exitReason
1289
+ };
1290
+ }
1291
+ /** Re-fetch this sandbox. */
1292
+ async refresh() {
1293
+ const data = await unwrap(this._client.GET("/api/sandboxes/{sid}", { params: { path: { sid: this.id } } }));
1294
+ return this._apply(data);
1295
+ }
1296
+ /** Start this sandbox. */
1297
+ async start(options = {}) {
1298
+ const timeoutMs = options.timeoutMs ?? 3e4;
1299
+ validateTimeoutMs(timeoutMs);
1300
+ const deadline = Date.now() + timeoutMs;
1301
+ const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/start", { params: {
1302
+ path: { sid: this.id },
1303
+ query: { wait: false }
1304
+ } }));
1305
+ this._apply(data);
1306
+ return waitForSandboxStart(this, deadline, timeoutMs);
1307
+ }
1308
+ /** Stop this sandbox. */
1309
+ async stop(options = {}) {
1310
+ const timeoutMs = options.timeoutMs ?? 3e4;
1311
+ validateTimeoutMs(timeoutMs);
1312
+ const deadline = Date.now() + timeoutMs;
1313
+ const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/stop", { params: { path: { sid: this.id } } }));
1314
+ this._apply(data);
1315
+ for (;;) {
1316
+ if ([
1317
+ "stopped",
1318
+ "exited",
1319
+ "failed"
1320
+ ].includes(this.status)) return this;
1321
+ if (this.status !== "stopping") throw new ArchilError(`Sandbox entered ${this.status} before it stopped`, 409, "SANDBOX_STOP_FAILED");
1322
+ const remaining = deadline - Date.now();
1323
+ if (remaining <= 0) throw new SandboxWaitTimeoutError("stop", timeoutMs, this);
1324
+ await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_INTERVAL_MS, remaining)));
1325
+ await this.refresh();
1326
+ }
1327
+ }
1328
+ /** Pause this sandbox, preserving its CPU and memory state. */
1329
+ async pause(options = {}) {
1330
+ const timeoutMs = options.timeoutMs ?? 3e4;
1331
+ validateTimeoutMs(timeoutMs);
1332
+ const deadline = Date.now() + timeoutMs;
1333
+ const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/pause", { params: { path: { sid: this.id } } }));
1334
+ this._apply(data);
1335
+ for (;;) {
1336
+ if (this.status === "paused") return this;
1337
+ if (this.status !== "pausing") throw new ArchilError(`Sandbox entered ${this.status} before it paused`, 409, "SANDBOX_PAUSE_FAILED");
1338
+ const remaining = deadline - Date.now();
1339
+ if (remaining <= 0) throw new SandboxWaitTimeoutError("pause", timeoutMs, this);
1340
+ await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_INTERVAL_MS, remaining)));
1341
+ await this.refresh();
1342
+ }
1343
+ }
1344
+ /** Resume this sandbox from its preserved CPU and memory state. */
1345
+ async resume(options = {}) {
1346
+ const timeoutMs = options.timeoutMs ?? 3e4;
1347
+ validateTimeoutMs(timeoutMs);
1348
+ const deadline = Date.now() + timeoutMs;
1349
+ const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/resume", { params: {
1350
+ path: { sid: this.id },
1351
+ query: { wait: false }
1352
+ } }));
1353
+ this._apply(data);
1354
+ for (;;) {
1355
+ if (this.status === "running") return this;
1356
+ if (this.status !== "pending") throw new ArchilError(`Sandbox entered ${this.status} before it resumed`, 409, "SANDBOX_RESUME_FAILED");
1357
+ const remaining = deadline - Date.now();
1358
+ if (remaining <= 0) throw new SandboxWaitTimeoutError("resume", timeoutMs, this);
1359
+ await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_INTERVAL_MS, remaining)));
1360
+ await this.refresh();
1361
+ }
1362
+ }
1363
+ async exec(command, options = {}) {
1364
+ const timeoutMs = options.timeoutMs ?? 3e4;
1365
+ validateTimeoutMs(timeoutMs);
1366
+ const deadline = Date.now() + timeoutMs;
1367
+ const exec = new SandboxExec(await unwrap(this._client.POST("/api/sandboxes/{sid}/execs", {
1368
+ params: {
1369
+ path: { sid: this.id },
1370
+ query: { wait: false }
1371
+ },
1372
+ body: {
1373
+ command,
1374
+ command_tty: options.commandTty,
1375
+ env: options.env,
1376
+ timeout_seconds: options.timeoutSeconds
1377
+ }
1378
+ })), this._client);
1379
+ if (exec.status !== "running") return exec;
1380
+ for (;;) {
1381
+ const remaining = deadline - Date.now();
1382
+ if (remaining <= 0) throw new SandboxWaitTimeoutError("exec", timeoutMs, exec);
1383
+ await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_INTERVAL_MS, remaining)));
1384
+ await exec.refresh();
1385
+ if (exec.status !== "running") return exec;
1386
+ }
1387
+ }
1388
+ async listExecs() {
1389
+ return ((await unwrap(this._client.GET("/api/sandboxes/{sid}/execs", { params: { path: { sid: this.id } } })))?.execs ?? []).map((exec) => new SandboxExec(exec, this._client));
1390
+ }
1391
+ async getExec(execId) {
1392
+ return new SandboxExec(await unwrap(this._client.GET("/api/sandboxes/{sid}/execs/{eid}", { params: { path: {
1393
+ sid: this.id,
1394
+ eid: execId
1395
+ } } })), this._client);
1396
+ }
1397
+ async cancelExec(execId) {
1398
+ return new SandboxExec(await unwrap(this._client.POST("/api/sandboxes/{sid}/execs/{eid}/cancel", { params: { path: {
1399
+ sid: this.id,
1400
+ eid: execId
1401
+ } } })), this._client);
1402
+ }
1403
+ };
1404
+ /** @internal Poll `sandbox` in place until it is running (or the deadline passes). */
1405
+ async function waitForSandboxStart(sandbox, deadline, timeoutMs) {
1406
+ for (;;) {
1407
+ if (sandbox.status === "running") return sandbox;
1408
+ if (sandbox.status !== "pending") throw new SandboxStartError(sandbox);
1409
+ const remaining = deadline - Date.now();
1410
+ if (remaining <= 0) throw new SandboxWaitTimeoutError("start", timeoutMs, sandbox);
1411
+ await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_INTERVAL_MS, remaining)));
1412
+ await sandbox.refresh();
1413
+ }
1414
+ }
1415
+ //#endregion
1416
+ //#region src/sandboxes.ts
1417
+ var Sandboxes = class {
1418
+ /** @internal */
1419
+ _client;
1420
+ /** @internal */
1421
+ constructor(client) {
1422
+ this._client = client;
1423
+ }
1424
+ /** List the account's sandboxes, oldest first. */
1425
+ async list(options = {}) {
1426
+ const filesystem = typeof options.disk === "string" ? options.disk : options.disk?.id;
1427
+ return ((await unwrap(this._client.GET("/api/sandboxes", { params: { query: { filesystem } } })))?.sandboxes ?? []).map((sandbox) => new Sandbox(sandbox, this._client));
1428
+ }
1429
+ async get(id) {
1430
+ return new Sandbox(await unwrap(this._client.GET("/api/sandboxes/{sid}", { params: { path: { sid: id } } })), this._client);
1431
+ }
1432
+ async create(request = {}, options = {}) {
1433
+ const timeoutMs = options.timeoutMs ?? 3e4;
1434
+ validateTimeoutMs(timeoutMs);
1435
+ const deadline = Date.now() + timeoutMs;
1436
+ const body = {
1437
+ vcpu_count: request.vcpuCount,
1438
+ mem_size_mib: request.memSizeMiB,
1439
+ base_image: request.baseImage,
1440
+ env: request.env,
1441
+ max_ttl_seconds: request.maxTtlSeconds,
1442
+ max_concurrent_execs: request.maxConcurrentExecs
1443
+ };
1444
+ return waitForSandboxStart(new Sandbox(await unwrap(this._client.POST("/api/sandboxes", {
1445
+ params: { query: { wait: false } },
1446
+ body
1447
+ })), this._client), deadline, timeoutMs);
1448
+ }
1449
+ };
1137
1450
  //#endregion
1138
1451
  //#region src/tokens.ts
1139
1452
  var Tokens = class {
@@ -1416,6 +1729,7 @@ function diskIdFromMount(m) {
1416
1729
  }
1417
1730
  var Archil = class {
1418
1731
  disks;
1732
+ sandboxes;
1419
1733
  tokens;
1420
1734
  /** @internal */
1421
1735
  _client;
@@ -1433,6 +1747,7 @@ var Archil = class {
1433
1747
  const s3BaseUrl = opts.s3BaseUrl ?? envVar("ARCHIL_S3_BASE_URL") ?? deriveS3BaseUrl(controlBaseUrl);
1434
1748
  this._client = client;
1435
1749
  this.disks = new Disks(client, region, s3BaseUrl);
1750
+ this.sandboxes = new Sandboxes(client);
1436
1751
  this.tokens = new Tokens(client);
1437
1752
  }
1438
1753
  /**
@@ -1490,6 +1805,15 @@ function listDisks(opts) {
1490
1805
  function getDisk(id) {
1491
1806
  return archil().disks.get(id);
1492
1807
  }
1808
+ function createSandbox(req = {}, opts = {}) {
1809
+ return archil().sandboxes.create(req, opts);
1810
+ }
1811
+ function listSandboxes(opts) {
1812
+ return archil().sandboxes.list(opts);
1813
+ }
1814
+ function getSandbox(id) {
1815
+ return archil().sandboxes.get(id);
1816
+ }
1493
1817
  function listApiKeys(opts) {
1494
1818
  return archil().tokens.list(opts);
1495
1819
  }
@@ -1515,4 +1839,4 @@ function workspace(mounts) {
1515
1839
  return archil().workspace(mounts);
1516
1840
  }
1517
1841
  //#endregion
1518
- export { USER_AGENT as _, exec as a, ArchilError as b, listDisks as c, Workspace as d, Tokens as f, effectiveUploadPartSize as g, DiskMultipart as h, deleteApiKey as i, workspace as l, Disk as m, createApiKey as n, getDisk as o, Disks as p, createDisk as r, listApiKeys as s, configure as t, Archil as u, VERSION as v, ArchilS3Error as x, ArchilApiError as y };
1842
+ export { DiskMultipart as C, ArchilApiError as D, VERSION as E, ArchilError as O, Disk as S, USER_AGENT as T, Sandbox as _, deleteApiKey as a, SandboxWaitTimeoutError as b, getSandbox as c, listSandboxes as d, workspace as f, Sandboxes as g, Tokens as h, createSandbox as i, ArchilS3Error as k, listApiKeys as l, Workspace as m, createApiKey as n, exec as o, Archil as p, createDisk as r, getDisk as s, configure as t, listDisks as u, SandboxExec as v, effectiveUploadPartSize as w, Disks as x, SandboxStartError as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disk",
3
- "version": "0.8.22",
3
+ "version": "0.8.23",
4
4
  "description": "Pure-JS client and CLI for Archil disks",
5
5
  "keywords": [
6
6
  "archil",
@@ -38,7 +38,7 @@
38
38
  "LICENSE"
39
39
  ],
40
40
  "dependencies": {
41
- "@archildata/api-types": "^0.0.4",
41
+ "@archildata/api-types": "^0.0.9",
42
42
  "commander": "^14.0.3",
43
43
  "fast-xml-parser": "^5.7.0",
44
44
  "openapi-fetch": "^0.13.5",