disk 0.8.22 → 0.9.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 +85 -0
- package/dist/cli.mjs +3 -2
- package/dist/{disk-DEqV3mtA.d.cts → disk-DseHuBL7.d.cts} +14 -5
- package/dist/{disk-DEqV3mtA.d.mts → disk-DseHuBL7.d.mts} +14 -5
- package/dist/index.cjs +378 -8
- package/dist/index.d.cts +203 -2
- package/dist/index.d.mts +203 -2
- package/dist/index.mjs +2 -2
- package/dist/internal/tools.d.cts +1 -1
- package/dist/internal/tools.d.mts +1 -1
- package/dist/{src-BepELcl6.mjs → src-CR3Ksi_s.mjs} +372 -9
- package/package.json +2 -2
|
@@ -111,7 +111,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
|
|
|
111
111
|
}
|
|
112
112
|
//#endregion
|
|
113
113
|
//#region src/version.ts
|
|
114
|
-
const VERSION = "0.
|
|
114
|
+
const VERSION = "0.9.0";
|
|
115
115
|
const USER_AGENT = `archil-js/${VERSION}`;
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/client.ts
|
|
@@ -151,6 +151,7 @@ async function unwrapPage(promise) {
|
|
|
151
151
|
*/
|
|
152
152
|
async function unwrapEmpty(promise) {
|
|
153
153
|
const { data: body, error, response } = await promise;
|
|
154
|
+
if (!error && response.status === 204) return;
|
|
154
155
|
if (error || !body) throw new ArchilApiError(error?.error ?? `API request failed with status ${response.status}`, response.status);
|
|
155
156
|
if (!body.success) throw new ArchilApiError(body.error ?? "Unknown API error", response.status);
|
|
156
157
|
}
|
|
@@ -166,6 +167,9 @@ var Disk = class {
|
|
|
166
167
|
createdAt;
|
|
167
168
|
fsHandlerStatus;
|
|
168
169
|
lastAccessed;
|
|
170
|
+
activeDataBytes;
|
|
171
|
+
totalDataBytes;
|
|
172
|
+
/** @deprecated Use {@link activeDataBytes}. */
|
|
169
173
|
dataSize;
|
|
170
174
|
monthlyUsage;
|
|
171
175
|
mounts;
|
|
@@ -192,7 +196,9 @@ var Disk = class {
|
|
|
192
196
|
this.createdAt = data.createdAt;
|
|
193
197
|
this.fsHandlerStatus = data.fsHandlerStatus;
|
|
194
198
|
this.lastAccessed = data.lastAccessed;
|
|
195
|
-
this.
|
|
199
|
+
this.activeDataBytes = data.activeDataBytes;
|
|
200
|
+
this.totalDataBytes = data.totalDataBytes;
|
|
201
|
+
this.dataSize = data.activeDataBytes;
|
|
196
202
|
this.monthlyUsage = data.monthlyUsage;
|
|
197
203
|
this.mounts = data.mounts;
|
|
198
204
|
this.metrics = data.metrics;
|
|
@@ -214,7 +220,8 @@ var Disk = class {
|
|
|
214
220
|
createdAt: this.createdAt,
|
|
215
221
|
fsHandlerStatus: this.fsHandlerStatus,
|
|
216
222
|
lastAccessed: this.lastAccessed,
|
|
217
|
-
|
|
223
|
+
activeDataBytes: this.activeDataBytes,
|
|
224
|
+
totalDataBytes: this.totalDataBytes,
|
|
218
225
|
monthlyUsage: this.monthlyUsage,
|
|
219
226
|
mounts: this.mounts,
|
|
220
227
|
metrics: this.metrics,
|
|
@@ -408,7 +415,10 @@ var Disk = class {
|
|
|
408
415
|
*
|
|
409
416
|
* Optional `mode` / `uid` / `gid` set the POSIX attributes of the published
|
|
410
417
|
* file (e.g. `{ mode: 0o644, uid: 1000, gid: 1000 }` for a non-root agent
|
|
411
|
-
* sandbox).
|
|
418
|
+
* sandbox). Missing parent directories inherit `uid` / `gid` with mode
|
|
419
|
+
* `0755`; existing directories remain unchanged. A key ending in `/` creates
|
|
420
|
+
* an explicit directory marker whose leaf uses the requested attributes.
|
|
421
|
+
* Defaults are `root:root 0644` for files and `root:root 0755` for directories.
|
|
412
422
|
*
|
|
413
423
|
* @param key Path on the disk (e.g. "reports/2026-01/data.json")
|
|
414
424
|
* @param body Contents as a string, Uint8Array/Buffer, or ArrayBuffer
|
|
@@ -480,7 +490,8 @@ var Disk = class {
|
|
|
480
490
|
*
|
|
481
491
|
* When the object does not yet exist, optional `mode` / `uid` / `gid` set the
|
|
482
492
|
* POSIX attributes of the newly created file (same headers as
|
|
483
|
-
* {@link putObject});
|
|
493
|
+
* {@link putObject}); missing parents inherit `uid` / `gid` with mode `0755`.
|
|
494
|
+
* Existing files and directories are unchanged.
|
|
484
495
|
*
|
|
485
496
|
* @param key Path on the disk (e.g. "logs/app.log")
|
|
486
497
|
* @param body Bytes to append (string, Uint8Array/Buffer, or ArrayBuffer)
|
|
@@ -676,7 +687,7 @@ var Disk = class {
|
|
|
676
687
|
({error, response} = await call(path, init));
|
|
677
688
|
} catch (transportError) {
|
|
678
689
|
if (attempt < maxRetries) {
|
|
679
|
-
await sleep(s3RetryDelayMs(attempt));
|
|
690
|
+
await sleep$1(s3RetryDelayMs(attempt));
|
|
680
691
|
continue;
|
|
681
692
|
}
|
|
682
693
|
throw transportError;
|
|
@@ -684,7 +695,7 @@ var Disk = class {
|
|
|
684
695
|
if (!response.ok) {
|
|
685
696
|
if (isTransientS3Status(response.status) && attempt < maxRetries) {
|
|
686
697
|
await response.body?.cancel().catch(() => {});
|
|
687
|
-
await sleep(s3RetryDelayMs(attempt));
|
|
698
|
+
await sleep$1(s3RetryDelayMs(attempt));
|
|
688
699
|
continue;
|
|
689
700
|
}
|
|
690
701
|
const message = typeof error === "string" ? error : error ? JSON.stringify(error) : "";
|
|
@@ -919,7 +930,7 @@ function s3RetryDelayMs(attempt) {
|
|
|
919
930
|
const ceiling = Math.min(S3_RETRY_CAP_MS, S3_RETRY_BASE_MS * 2 ** attempt);
|
|
920
931
|
return Math.random() * ceiling;
|
|
921
932
|
}
|
|
922
|
-
function sleep(ms) {
|
|
933
|
+
function sleep$1(ms) {
|
|
923
934
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
924
935
|
}
|
|
925
936
|
/** S3's minimum size for every multipart part but the last (5 MiB). */
|
|
@@ -1135,6 +1146,347 @@ var Disks = class {
|
|
|
1135
1146
|
}
|
|
1136
1147
|
};
|
|
1137
1148
|
//#endregion
|
|
1149
|
+
//#region src/sandbox.ts
|
|
1150
|
+
const POLL_INTERVAL_MS = 500;
|
|
1151
|
+
function sleep() {
|
|
1152
|
+
return new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
1153
|
+
}
|
|
1154
|
+
var SandboxExec = class {
|
|
1155
|
+
sandboxId;
|
|
1156
|
+
id;
|
|
1157
|
+
command;
|
|
1158
|
+
status;
|
|
1159
|
+
exitCode;
|
|
1160
|
+
stdout;
|
|
1161
|
+
stderr;
|
|
1162
|
+
exitReason;
|
|
1163
|
+
executeTimeMs;
|
|
1164
|
+
startedAt;
|
|
1165
|
+
finishedAt;
|
|
1166
|
+
/** @internal */
|
|
1167
|
+
_client;
|
|
1168
|
+
/** @internal */
|
|
1169
|
+
constructor(data, client) {
|
|
1170
|
+
this._client = client;
|
|
1171
|
+
this._apply(data);
|
|
1172
|
+
}
|
|
1173
|
+
/** @internal Overwrite this exec's fields in place from a fresh wire snapshot. */
|
|
1174
|
+
_apply(data) {
|
|
1175
|
+
this.sandboxId = data.sandbox_id;
|
|
1176
|
+
this.id = data.exec_id;
|
|
1177
|
+
this.command = data.command;
|
|
1178
|
+
this.status = data.status;
|
|
1179
|
+
this.exitCode = data.exit_code;
|
|
1180
|
+
this.stdout = data.stdout;
|
|
1181
|
+
this.stderr = data.stderr;
|
|
1182
|
+
this.exitReason = data.exit_reason;
|
|
1183
|
+
this.executeTimeMs = data.execute_time_ms;
|
|
1184
|
+
this.startedAt = new Date(data.started_at);
|
|
1185
|
+
this.finishedAt = data.finished_at ? new Date(data.finished_at) : void 0;
|
|
1186
|
+
return this;
|
|
1187
|
+
}
|
|
1188
|
+
toJSON() {
|
|
1189
|
+
return {
|
|
1190
|
+
sandboxId: this.sandboxId,
|
|
1191
|
+
id: this.id,
|
|
1192
|
+
command: this.command,
|
|
1193
|
+
status: this.status,
|
|
1194
|
+
exitCode: this.exitCode,
|
|
1195
|
+
stdout: this.stdout,
|
|
1196
|
+
stderr: this.stderr,
|
|
1197
|
+
exitReason: this.exitReason,
|
|
1198
|
+
executeTimeMs: this.executeTimeMs,
|
|
1199
|
+
startedAt: this.startedAt,
|
|
1200
|
+
finishedAt: this.finishedAt
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
/** Re-fetch this exec and update it in place, returning the same object. */
|
|
1204
|
+
async refresh() {
|
|
1205
|
+
const data = await unwrap(this._client.GET("/api/sandboxes/{sid}/execs/{eid}", { params: { path: {
|
|
1206
|
+
sid: this.sandboxId,
|
|
1207
|
+
eid: this.id
|
|
1208
|
+
} } }));
|
|
1209
|
+
return this._apply(data);
|
|
1210
|
+
}
|
|
1211
|
+
/** Cancel this exec and update it in place, returning the same object. */
|
|
1212
|
+
async cancel() {
|
|
1213
|
+
const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/execs/{eid}/cancel", { params: { path: {
|
|
1214
|
+
sid: this.sandboxId,
|
|
1215
|
+
eid: this.id
|
|
1216
|
+
} } }));
|
|
1217
|
+
return this._apply(data);
|
|
1218
|
+
}
|
|
1219
|
+
};
|
|
1220
|
+
var SandboxPty = class SandboxPty {
|
|
1221
|
+
_socket;
|
|
1222
|
+
_completion;
|
|
1223
|
+
/** @internal */
|
|
1224
|
+
constructor(socket, onData) {
|
|
1225
|
+
this._socket = socket;
|
|
1226
|
+
this._completion = new Promise((resolve) => {
|
|
1227
|
+
socket.addEventListener("message", (event) => {
|
|
1228
|
+
if (typeof event.data === "string") onData?.(event.data);
|
|
1229
|
+
});
|
|
1230
|
+
socket.addEventListener("close", (event) => {
|
|
1231
|
+
const match = /^process exited with code (-?\d+)$/.exec(event.reason);
|
|
1232
|
+
resolve({ exitCode: match ? Number(match[1]) : void 0 });
|
|
1233
|
+
}, { once: true });
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
/** @internal */
|
|
1237
|
+
static connect(url, command, options) {
|
|
1238
|
+
return new Promise((resolve, reject) => {
|
|
1239
|
+
const socket = new WebSocket(url);
|
|
1240
|
+
const handleError = () => reject(/* @__PURE__ */ new Error("Interactive exec connection failed"));
|
|
1241
|
+
socket.addEventListener("error", handleError, { once: true });
|
|
1242
|
+
socket.addEventListener("open", () => {
|
|
1243
|
+
socket.removeEventListener("error", handleError);
|
|
1244
|
+
const pty = new SandboxPty(socket, options.onData);
|
|
1245
|
+
pty._send({
|
|
1246
|
+
type: "resize",
|
|
1247
|
+
cols: options.cols ?? 80,
|
|
1248
|
+
rows: options.rows ?? 24
|
|
1249
|
+
});
|
|
1250
|
+
const quotedCommand = `'${command.replaceAll("'", `'"'"'`)}'`;
|
|
1251
|
+
pty._send({
|
|
1252
|
+
type: "input",
|
|
1253
|
+
data: `eval ${quotedCommand}; exit $?\n`
|
|
1254
|
+
});
|
|
1255
|
+
resolve(pty);
|
|
1256
|
+
}, { once: true });
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
async sendInput(data) {
|
|
1260
|
+
this._send({
|
|
1261
|
+
type: "input",
|
|
1262
|
+
data
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
async resize(size) {
|
|
1266
|
+
this._send({
|
|
1267
|
+
type: "resize",
|
|
1268
|
+
...size
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
wait() {
|
|
1272
|
+
return this._completion;
|
|
1273
|
+
}
|
|
1274
|
+
close() {
|
|
1275
|
+
this._socket.close();
|
|
1276
|
+
}
|
|
1277
|
+
_send(message) {
|
|
1278
|
+
this._socket.send(JSON.stringify(message));
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
var Sandbox = class Sandbox {
|
|
1282
|
+
id;
|
|
1283
|
+
name;
|
|
1284
|
+
status;
|
|
1285
|
+
vcpuCount;
|
|
1286
|
+
memSizeMiB;
|
|
1287
|
+
baseImage;
|
|
1288
|
+
platform;
|
|
1289
|
+
maxTtlSeconds;
|
|
1290
|
+
maxConcurrentExecs;
|
|
1291
|
+
endpoints;
|
|
1292
|
+
createdAt;
|
|
1293
|
+
runningAt;
|
|
1294
|
+
finishedAt;
|
|
1295
|
+
lastActiveAt;
|
|
1296
|
+
expiresAt;
|
|
1297
|
+
exitReason;
|
|
1298
|
+
/** @internal */
|
|
1299
|
+
_client;
|
|
1300
|
+
/** @internal */
|
|
1301
|
+
constructor(data, client) {
|
|
1302
|
+
this._client = client;
|
|
1303
|
+
this._apply(data);
|
|
1304
|
+
}
|
|
1305
|
+
/** @internal Overwrite this sandbox's fields in place from a fresh wire snapshot. */
|
|
1306
|
+
_apply(data) {
|
|
1307
|
+
this.id = data.sandbox_id;
|
|
1308
|
+
this.name = data.name;
|
|
1309
|
+
this.status = data.status;
|
|
1310
|
+
this.vcpuCount = data.vcpu_count;
|
|
1311
|
+
this.memSizeMiB = data.mem_size_mib;
|
|
1312
|
+
this.baseImage = data.base_image;
|
|
1313
|
+
this.platform = data.platform;
|
|
1314
|
+
this.maxTtlSeconds = data.max_ttl_seconds;
|
|
1315
|
+
this.maxConcurrentExecs = data.max_concurrent_execs;
|
|
1316
|
+
this.endpoints = data.endpoints?.map((endpoint) => ({ ...endpoint }));
|
|
1317
|
+
this.createdAt = new Date(data.created_at);
|
|
1318
|
+
this.runningAt = data.running_at ? new Date(data.running_at) : void 0;
|
|
1319
|
+
this.finishedAt = data.finished_at ? new Date(data.finished_at) : void 0;
|
|
1320
|
+
this.lastActiveAt = new Date(data.last_active_at);
|
|
1321
|
+
this.expiresAt = data.expires_at ? new Date(data.expires_at) : void 0;
|
|
1322
|
+
this.exitReason = data.exit_reason;
|
|
1323
|
+
return this;
|
|
1324
|
+
}
|
|
1325
|
+
toJSON() {
|
|
1326
|
+
return {
|
|
1327
|
+
id: this.id,
|
|
1328
|
+
name: this.name,
|
|
1329
|
+
status: this.status,
|
|
1330
|
+
vcpuCount: this.vcpuCount,
|
|
1331
|
+
memSizeMiB: this.memSizeMiB,
|
|
1332
|
+
baseImage: this.baseImage,
|
|
1333
|
+
platform: this.platform,
|
|
1334
|
+
maxTtlSeconds: this.maxTtlSeconds,
|
|
1335
|
+
maxConcurrentExecs: this.maxConcurrentExecs,
|
|
1336
|
+
endpoints: this.endpoints?.map((endpoint) => ({ ...endpoint })),
|
|
1337
|
+
createdAt: this.createdAt,
|
|
1338
|
+
runningAt: this.runningAt,
|
|
1339
|
+
finishedAt: this.finishedAt,
|
|
1340
|
+
lastActiveAt: this.lastActiveAt,
|
|
1341
|
+
expiresAt: this.expiresAt,
|
|
1342
|
+
exitReason: this.exitReason
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
/** Re-fetch this sandbox. */
|
|
1346
|
+
async refresh() {
|
|
1347
|
+
const data = await unwrap(this._client.GET("/api/sandboxes/{sid}", { params: { path: { sid: this.id } } }));
|
|
1348
|
+
return this._apply(data);
|
|
1349
|
+
}
|
|
1350
|
+
/** Start this sandbox. */
|
|
1351
|
+
async start(options = {}) {
|
|
1352
|
+
const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/start", { params: {
|
|
1353
|
+
path: { sid: this.id },
|
|
1354
|
+
query: { wait: options.wait ?? true }
|
|
1355
|
+
} }));
|
|
1356
|
+
this._apply(data);
|
|
1357
|
+
return options.wait === false ? this : waitForSandboxStart(this);
|
|
1358
|
+
}
|
|
1359
|
+
/** Stop this sandbox. */
|
|
1360
|
+
async stop(options = {}) {
|
|
1361
|
+
const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/stop", { params: { path: { sid: this.id } } }));
|
|
1362
|
+
this._apply(data);
|
|
1363
|
+
return options.wait === false ? this : waitWhileSandboxStatus(this, "stopping");
|
|
1364
|
+
}
|
|
1365
|
+
/** Pause this sandbox, preserving its CPU and memory state. */
|
|
1366
|
+
async pause(options = {}) {
|
|
1367
|
+
const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/pause", { params: { path: { sid: this.id } } }));
|
|
1368
|
+
this._apply(data);
|
|
1369
|
+
return options.wait === false ? this : waitWhileSandboxStatus(this, "pausing");
|
|
1370
|
+
}
|
|
1371
|
+
/** Resume this sandbox from its preserved CPU and memory state. */
|
|
1372
|
+
async resume(options = {}) {
|
|
1373
|
+
const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/resume", { params: {
|
|
1374
|
+
path: { sid: this.id },
|
|
1375
|
+
query: { wait: options.wait ?? true }
|
|
1376
|
+
} }));
|
|
1377
|
+
this._apply(data);
|
|
1378
|
+
return options.wait === false ? this : waitForSandboxStart(this);
|
|
1379
|
+
}
|
|
1380
|
+
/** Create an isolated writable branch from this sandbox's current state. */
|
|
1381
|
+
async fork(options = {}) {
|
|
1382
|
+
const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/fork", {
|
|
1383
|
+
params: {
|
|
1384
|
+
path: { sid: this.id },
|
|
1385
|
+
query: { wait: options.wait ?? true }
|
|
1386
|
+
},
|
|
1387
|
+
body: options.name === void 0 ? void 0 : { name: options.name }
|
|
1388
|
+
}));
|
|
1389
|
+
const fork = new Sandbox(data, this._client);
|
|
1390
|
+
return options.wait === false ? fork : waitForSandboxStart(fork);
|
|
1391
|
+
}
|
|
1392
|
+
/** Create a short-lived signed WebSocket URL for an interactive shell. */
|
|
1393
|
+
async createConnection() {
|
|
1394
|
+
const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/connections", { params: { path: { sid: this.id } } }));
|
|
1395
|
+
return {
|
|
1396
|
+
url: data.url,
|
|
1397
|
+
expiresAt: new Date(data.expires_at)
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
/** Delete this sandbox and its backing disk. */
|
|
1401
|
+
async delete() {
|
|
1402
|
+
await unwrapEmpty(this._client.DELETE("/api/sandboxes/{sid}", { params: { path: { sid: this.id } } }));
|
|
1403
|
+
}
|
|
1404
|
+
async exec(command, options = {}) {
|
|
1405
|
+
if ("pty" in options) {
|
|
1406
|
+
const connection = await this.createConnection();
|
|
1407
|
+
return SandboxPty.connect(connection.url, command, options);
|
|
1408
|
+
}
|
|
1409
|
+
const exec = new SandboxExec(await unwrap(this._client.POST("/api/sandboxes/{sid}/execs", {
|
|
1410
|
+
params: {
|
|
1411
|
+
path: { sid: this.id },
|
|
1412
|
+
query: { wait: options.wait ?? true }
|
|
1413
|
+
},
|
|
1414
|
+
body: {
|
|
1415
|
+
command,
|
|
1416
|
+
command_tty: options.commandTty,
|
|
1417
|
+
env: options.env,
|
|
1418
|
+
timeout_seconds: options.timeoutSeconds
|
|
1419
|
+
}
|
|
1420
|
+
})), this._client);
|
|
1421
|
+
if (options.wait === false) return exec;
|
|
1422
|
+
while (exec.status === "running") {
|
|
1423
|
+
await sleep();
|
|
1424
|
+
await exec.refresh();
|
|
1425
|
+
}
|
|
1426
|
+
return exec;
|
|
1427
|
+
}
|
|
1428
|
+
async listExecs() {
|
|
1429
|
+
return ((await unwrap(this._client.GET("/api/sandboxes/{sid}/execs", { params: { path: { sid: this.id } } })))?.execs ?? []).map((exec) => new SandboxExec(exec, this._client));
|
|
1430
|
+
}
|
|
1431
|
+
async getExec(execId) {
|
|
1432
|
+
return new SandboxExec(await unwrap(this._client.GET("/api/sandboxes/{sid}/execs/{eid}", { params: { path: {
|
|
1433
|
+
sid: this.id,
|
|
1434
|
+
eid: execId
|
|
1435
|
+
} } })), this._client);
|
|
1436
|
+
}
|
|
1437
|
+
async cancelExec(execId) {
|
|
1438
|
+
return new SandboxExec(await unwrap(this._client.POST("/api/sandboxes/{sid}/execs/{eid}/cancel", { params: { path: {
|
|
1439
|
+
sid: this.id,
|
|
1440
|
+
eid: execId
|
|
1441
|
+
} } })), this._client);
|
|
1442
|
+
}
|
|
1443
|
+
};
|
|
1444
|
+
/** @internal Continue waiting if the server returned before startup completed. */
|
|
1445
|
+
async function waitForSandboxStart(sandbox) {
|
|
1446
|
+
return waitWhileSandboxStatus(sandbox, "pending");
|
|
1447
|
+
}
|
|
1448
|
+
async function waitWhileSandboxStatus(sandbox, status) {
|
|
1449
|
+
while (sandbox.status === status) {
|
|
1450
|
+
await sleep();
|
|
1451
|
+
await sandbox.refresh();
|
|
1452
|
+
}
|
|
1453
|
+
return sandbox;
|
|
1454
|
+
}
|
|
1455
|
+
//#endregion
|
|
1456
|
+
//#region src/sandboxes.ts
|
|
1457
|
+
var Sandboxes = class {
|
|
1458
|
+
/** @internal */
|
|
1459
|
+
_client;
|
|
1460
|
+
/** @internal */
|
|
1461
|
+
constructor(client) {
|
|
1462
|
+
this._client = client;
|
|
1463
|
+
}
|
|
1464
|
+
/** List the account's sandboxes, oldest first. */
|
|
1465
|
+
async list(options = {}) {
|
|
1466
|
+
const filesystem = typeof options.disk === "string" ? options.disk : options.disk?.id;
|
|
1467
|
+
return ((await unwrap(this._client.GET("/api/sandboxes", { params: { query: { filesystem } } })))?.sandboxes ?? []).map((sandbox) => new Sandbox(sandbox, this._client));
|
|
1468
|
+
}
|
|
1469
|
+
async get(id) {
|
|
1470
|
+
return new Sandbox(await unwrap(this._client.GET("/api/sandboxes/{sid}", { params: { path: { sid: id } } })), this._client);
|
|
1471
|
+
}
|
|
1472
|
+
async create(request = {}, options = {}) {
|
|
1473
|
+
const body = {
|
|
1474
|
+
name: request.name,
|
|
1475
|
+
vcpu_count: request.vcpuCount,
|
|
1476
|
+
mem_size_mib: request.memSizeMiB,
|
|
1477
|
+
base_image: request.baseImage,
|
|
1478
|
+
env: request.env,
|
|
1479
|
+
max_ttl_seconds: request.maxTtlSeconds,
|
|
1480
|
+
max_concurrent_execs: request.maxConcurrentExecs
|
|
1481
|
+
};
|
|
1482
|
+
const sandbox = new Sandbox(await unwrap(this._client.POST("/api/sandboxes", {
|
|
1483
|
+
params: { query: { wait: options.wait ?? true } },
|
|
1484
|
+
body
|
|
1485
|
+
})), this._client);
|
|
1486
|
+
return options.wait === false ? sandbox : waitForSandboxStart(sandbox);
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
//#endregion
|
|
1138
1490
|
//#region src/tokens.ts
|
|
1139
1491
|
var Tokens = class {
|
|
1140
1492
|
/** @internal */
|
|
@@ -1416,6 +1768,7 @@ function diskIdFromMount(m) {
|
|
|
1416
1768
|
}
|
|
1417
1769
|
var Archil = class {
|
|
1418
1770
|
disks;
|
|
1771
|
+
sandboxes;
|
|
1419
1772
|
tokens;
|
|
1420
1773
|
/** @internal */
|
|
1421
1774
|
_client;
|
|
@@ -1433,6 +1786,7 @@ var Archil = class {
|
|
|
1433
1786
|
const s3BaseUrl = opts.s3BaseUrl ?? envVar("ARCHIL_S3_BASE_URL") ?? deriveS3BaseUrl(controlBaseUrl);
|
|
1434
1787
|
this._client = client;
|
|
1435
1788
|
this.disks = new Disks(client, region, s3BaseUrl);
|
|
1789
|
+
this.sandboxes = new Sandboxes(client);
|
|
1436
1790
|
this.tokens = new Tokens(client);
|
|
1437
1791
|
}
|
|
1438
1792
|
/**
|
|
@@ -1490,6 +1844,15 @@ function listDisks(opts) {
|
|
|
1490
1844
|
function getDisk(id) {
|
|
1491
1845
|
return archil().disks.get(id);
|
|
1492
1846
|
}
|
|
1847
|
+
function createSandbox(req = {}, opts = {}) {
|
|
1848
|
+
return archil().sandboxes.create(req, opts);
|
|
1849
|
+
}
|
|
1850
|
+
function listSandboxes(opts) {
|
|
1851
|
+
return archil().sandboxes.list(opts);
|
|
1852
|
+
}
|
|
1853
|
+
function getSandbox(id) {
|
|
1854
|
+
return archil().sandboxes.get(id);
|
|
1855
|
+
}
|
|
1493
1856
|
function listApiKeys(opts) {
|
|
1494
1857
|
return archil().tokens.list(opts);
|
|
1495
1858
|
}
|
|
@@ -1515,4 +1878,4 @@ function workspace(mounts) {
|
|
|
1515
1878
|
return archil().workspace(mounts);
|
|
1516
1879
|
}
|
|
1517
1880
|
//#endregion
|
|
1518
|
-
export {
|
|
1881
|
+
export { effectiveUploadPartSize as C, ArchilError as D, ArchilApiError as E, ArchilS3Error as O, DiskMultipart as S, VERSION as T, Sandbox as _, deleteApiKey as a, Disks as b, getSandbox as c, listSandboxes as d, workspace as f, Sandboxes as g, Tokens as h, createSandbox as i, 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, USER_AGENT as w, Disk as x, SandboxPty as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "disk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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.
|
|
41
|
+
"@archildata/api-types": "^0.0.16",
|
|
42
42
|
"commander": "^14.0.3",
|
|
43
43
|
"fast-xml-parser": "^5.7.0",
|
|
44
44
|
"openapi-fetch": "^0.13.5",
|