disk 1.1.1 → 1.2.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 +45 -1
- package/dist/cli.mjs +2 -2
- package/dist/{common-CgI3t0XZ.mjs → common-DQS29KQU.mjs} +1 -1
- package/dist/{disk-DqGdJGsu.d.cts → disk-CiLNoFCd.d.cts} +0 -1
- package/dist/{disk-DqGdJGsu.d.mts → disk-CiLNoFCd.d.mts} +0 -1
- package/dist/index.cjs +98 -7
- package/dist/index.d.cts +31 -5
- package/dist/index.d.mts +31 -5
- package/dist/index.mjs +1 -1
- package/dist/internal/tools.d.cts +1 -1
- package/dist/internal/tools.d.mts +1 -1
- package/dist/sandbox-cli.mjs +7 -8
- package/dist/{src-DHkfjGLy.mjs → src-Crk5lxKW.mjs} +98 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -151,6 +151,27 @@ const all = await client.sandboxes.list();
|
|
|
151
151
|
const usingDisk = await client.sandboxes.list({ disk: "dsk-abc123" });
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
+
Expose TCP ports publicly when creating a sandbox or later with `exposePort`:
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
const web = await client.sandboxes.create({ baseImage: "python:3.12-slim", ports: [8080] });
|
|
158
|
+
const server = await web.processes.start("python -m http.server 8080 --bind 0.0.0.0");
|
|
159
|
+
await server.disconnect(); // The server keeps running.
|
|
160
|
+
|
|
161
|
+
const hostname = await web.exposePort(8080); // Returns the hostname, including if already public.
|
|
162
|
+
console.log(`https://${hostname}`); // Available once the server is listening.
|
|
163
|
+
console.log(await web.listPorts()); // [{ port: 8080, hostname: "..." }]
|
|
164
|
+
await web.unexposePort(8080);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Ports must be between 1 and 65535. Exposing a port makes it publicly accessible
|
|
168
|
+
without authentication; your application must listen on that port. HTTP services
|
|
169
|
+
are reached through HTTPS on the returned hostname.
|
|
170
|
+
`listPorts()` returns only explicitly exposed ports; `sandbox.endpoints` contains
|
|
171
|
+
service-published ports. Deleting explicit exposure leaves a service publishing
|
|
172
|
+
the same port reachable and does not stop the listening process. Routing changes
|
|
173
|
+
may take a few seconds to propagate, and existing connections remain open.
|
|
174
|
+
|
|
154
175
|
Network egress can optionally be restricted when creating a sandbox:
|
|
155
176
|
|
|
156
177
|
```ts
|
|
@@ -194,8 +215,31 @@ console.log(effective, await restricted.getNetwork());
|
|
|
194
215
|
await restricted.updateNetwork({}); // Restore unrestricted egress.
|
|
195
216
|
```
|
|
196
217
|
|
|
218
|
+
Set hard and idle TTLs at creation or edit them while running. All values are
|
|
219
|
+
seconds, matching the Python SDK:
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
const timed = await archil.sandboxes.create({ maxTtlSeconds: 3600, idleTtlSeconds: 300 });
|
|
223
|
+
await timed.setTimeout(7200);
|
|
224
|
+
await timed.setTimeout({ idleTtlSeconds: 60 });
|
|
225
|
+
await timed.setTimeout({ timeoutSeconds: 3600, idleTtlSeconds: 300 });
|
|
226
|
+
await timed.setTimeout({ idleTtlSeconds: 0 });
|
|
227
|
+
console.log(timed.maxTtlSeconds, timed.idleTtlSeconds);
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Omitted settings stay unchanged on edits. Updating the hard TTL resets its
|
|
231
|
+
deadline from now; an idle-only edit does not. Changes made while inactive apply
|
|
232
|
+
to the next powered-on session. Idle TTL accepts 0–86,400 seconds; omitted or
|
|
233
|
+
zero at creation disables it, and zero on edits disables it again.
|
|
234
|
+
|
|
235
|
+
Both TTLs pause the sandbox, preserving memory and processes. Open direct
|
|
236
|
+
process connections prevent idle expiry, but not hard expiry. The idle countdown
|
|
237
|
+
starts when the last connection closes; detached processes and service-port
|
|
238
|
+
traffic do not keep it alive. Disable idle TTL for unattended jobs.
|
|
239
|
+
|
|
197
240
|
Sandboxes support 1–32 vCPUs and 256–65,536 MiB of memory. When omitted,
|
|
198
|
-
`vcpuCount` defaults to 1 and `memSizeMiB` defaults to 2,048 MiB.
|
|
241
|
+
`vcpuCount` defaults to 1 and `memSizeMiB` defaults to 2,048 MiB. Sandbox
|
|
242
|
+
timeouts default to 24 hours and can be reset up to 24 hours from now.
|
|
199
243
|
|
|
200
244
|
`sandbox.processes.start()` always returns a runtime-owned process immediately.
|
|
201
245
|
Pass `terminal: true` when the command needs terminal behavior, or provide
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { O 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-
|
|
3
|
-
import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-
|
|
2
|
+
import { O 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-Crk5lxKW.mjs";
|
|
3
|
+
import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-DQS29KQU.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
//#region bin/cli.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as REGION_URLS, p as Archil } from "./src-
|
|
1
|
+
import { D as REGION_URLS, p as Archil } from "./src-Crk5lxKW.mjs";
|
|
2
2
|
import { Option } from "commander";
|
|
3
3
|
import { isCancel, password, spinner } from "@clack/prompts";
|
|
4
4
|
import { chmod, mkdir, open, readFile, rename, rm, stat } from "node:fs/promises";
|
package/dist/index.cjs
CHANGED
|
@@ -145,7 +145,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
|
|
|
145
145
|
}
|
|
146
146
|
//#endregion
|
|
147
147
|
//#region src/version.ts
|
|
148
|
-
const VERSION = "1.
|
|
148
|
+
const VERSION = "1.2.0";
|
|
149
149
|
const USER_AGENT = `archil-js/${VERSION}`;
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/client.ts
|
|
@@ -154,6 +154,49 @@ function isNodeRuntime() {
|
|
|
154
154
|
return typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
155
155
|
}
|
|
156
156
|
const undiciModule = isNodeRuntime() ? import("undici") : void 0;
|
|
157
|
+
const CONTROL_PLANE_CONNECTIONS = 1;
|
|
158
|
+
const CONTROL_PLANE_CONCURRENT_STREAMS = 100;
|
|
159
|
+
function isAsyncIterableBody(body) {
|
|
160
|
+
return body != null && typeof body === "object" && Symbol.asyncIterator in body;
|
|
161
|
+
}
|
|
162
|
+
async function bufferBody(body) {
|
|
163
|
+
const chunks = [];
|
|
164
|
+
for await (const chunk of body) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
165
|
+
return Buffer.concat(chunks);
|
|
166
|
+
}
|
|
167
|
+
const multiplexHttp2Requests = (dispatch) => (options, handler) => {
|
|
168
|
+
let requestStarted = false;
|
|
169
|
+
const guardedHandler = {
|
|
170
|
+
onRequestStart(controller, context) {
|
|
171
|
+
if (requestStarted) {
|
|
172
|
+
controller.abort(/* @__PURE__ */ new Error("Archil control-plane requests are not replayed after a connection failure"));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
requestStarted = true;
|
|
176
|
+
handler.onRequestStart?.(controller, context);
|
|
177
|
+
},
|
|
178
|
+
onRequestUpgrade: handler.onRequestUpgrade?.bind(handler),
|
|
179
|
+
onResponseStart: handler.onResponseStart?.bind(handler),
|
|
180
|
+
onResponseData: handler.onResponseData?.bind(handler),
|
|
181
|
+
onResponseEnd: handler.onResponseEnd?.bind(handler),
|
|
182
|
+
onResponseError: handler.onResponseError?.bind(handler)
|
|
183
|
+
};
|
|
184
|
+
const dispatchBody = (body) => dispatch({
|
|
185
|
+
...options,
|
|
186
|
+
body,
|
|
187
|
+
idempotent: true
|
|
188
|
+
}, guardedHandler);
|
|
189
|
+
if (!isAsyncIterableBody(options.body)) return dispatchBody(options.body);
|
|
190
|
+
bufferBody(options.body).then(dispatchBody, (error) => handler.onResponseError?.({
|
|
191
|
+
aborted: false,
|
|
192
|
+
paused: false,
|
|
193
|
+
reason: null,
|
|
194
|
+
abort() {},
|
|
195
|
+
pause() {},
|
|
196
|
+
resume() {}
|
|
197
|
+
}, error instanceof Error ? error : new Error(String(error))));
|
|
198
|
+
return true;
|
|
199
|
+
};
|
|
157
200
|
const sharedDispatchers = /* @__PURE__ */ new Map();
|
|
158
201
|
function dispatcherKey(baseUrl, apiKey) {
|
|
159
202
|
return `${new URL(baseUrl).origin}\0${apiKey}`;
|
|
@@ -167,10 +210,11 @@ function getSharedDispatcher(baseUrl, apiKey) {
|
|
|
167
210
|
const { Agent } = await undiciModule;
|
|
168
211
|
return new Agent({
|
|
169
212
|
allowH2: true,
|
|
170
|
-
connections:
|
|
213
|
+
connections: CONTROL_PLANE_CONNECTIONS,
|
|
214
|
+
pipelining: CONTROL_PLANE_CONCURRENT_STREAMS,
|
|
171
215
|
keepAliveTimeout: 6e4,
|
|
172
216
|
keepAliveMaxTimeout: 6e5
|
|
173
|
-
});
|
|
217
|
+
}).compose(multiplexHttp2Requests);
|
|
174
218
|
})();
|
|
175
219
|
sharedDispatchers.set(key, dispatcher);
|
|
176
220
|
dispatcher.catch(() => {
|
|
@@ -1264,6 +1308,17 @@ var Disks = class {
|
|
|
1264
1308
|
authorizedUsers
|
|
1265
1309
|
};
|
|
1266
1310
|
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Execute a command on a disk that is already known to exist. Accepts the
|
|
1313
|
+
* disk ID directly so callers that do not need its metadata can execute
|
|
1314
|
+
* without fetching the disk first.
|
|
1315
|
+
*/
|
|
1316
|
+
async exec(id, command) {
|
|
1317
|
+
return unwrap(this._client.POST("/api/disks/{id}/exec", {
|
|
1318
|
+
params: { path: { id } },
|
|
1319
|
+
body: { command }
|
|
1320
|
+
}));
|
|
1321
|
+
}
|
|
1267
1322
|
};
|
|
1268
1323
|
//#endregion
|
|
1269
1324
|
//#region src/sandbox-process.ts
|
|
@@ -1811,13 +1866,13 @@ var Sandbox = class Sandbox {
|
|
|
1811
1866
|
baseImage;
|
|
1812
1867
|
platform;
|
|
1813
1868
|
maxTtlSeconds;
|
|
1869
|
+
idleTtlSeconds;
|
|
1814
1870
|
maxConcurrentExecs;
|
|
1815
1871
|
endpoints;
|
|
1816
1872
|
createdAt;
|
|
1817
1873
|
runningAt;
|
|
1818
1874
|
finishedAt;
|
|
1819
1875
|
lastActiveAt;
|
|
1820
|
-
expiresAt;
|
|
1821
1876
|
exitReason;
|
|
1822
1877
|
processes;
|
|
1823
1878
|
files;
|
|
@@ -1840,13 +1895,13 @@ var Sandbox = class Sandbox {
|
|
|
1840
1895
|
this.baseImage = data.base_image;
|
|
1841
1896
|
this.platform = data.platform;
|
|
1842
1897
|
this.maxTtlSeconds = data.max_ttl_seconds;
|
|
1898
|
+
this.idleTtlSeconds = data.idle_ttl_seconds ?? 0;
|
|
1843
1899
|
this.maxConcurrentExecs = data.max_concurrent_execs;
|
|
1844
1900
|
this.endpoints = data.endpoints?.map((endpoint) => ({ ...endpoint }));
|
|
1845
1901
|
this.createdAt = new Date(data.created_at);
|
|
1846
1902
|
this.runningAt = data.running_at ? new Date(data.running_at) : void 0;
|
|
1847
1903
|
this.finishedAt = data.finished_at ? new Date(data.finished_at) : void 0;
|
|
1848
1904
|
this.lastActiveAt = new Date(data.last_active_at);
|
|
1849
|
-
this.expiresAt = data.expires_at ? new Date(data.expires_at) : void 0;
|
|
1850
1905
|
this.exitReason = data.exit_reason;
|
|
1851
1906
|
return this;
|
|
1852
1907
|
}
|
|
@@ -1860,13 +1915,13 @@ var Sandbox = class Sandbox {
|
|
|
1860
1915
|
baseImage: this.baseImage,
|
|
1861
1916
|
platform: this.platform,
|
|
1862
1917
|
maxTtlSeconds: this.maxTtlSeconds,
|
|
1918
|
+
idleTtlSeconds: this.idleTtlSeconds,
|
|
1863
1919
|
maxConcurrentExecs: this.maxConcurrentExecs,
|
|
1864
1920
|
endpoints: this.endpoints?.map((endpoint) => ({ ...endpoint })),
|
|
1865
1921
|
createdAt: this.createdAt,
|
|
1866
1922
|
runningAt: this.runningAt,
|
|
1867
1923
|
finishedAt: this.finishedAt,
|
|
1868
1924
|
lastActiveAt: this.lastActiveAt,
|
|
1869
|
-
expiresAt: this.expiresAt,
|
|
1870
1925
|
exitReason: this.exitReason
|
|
1871
1926
|
};
|
|
1872
1927
|
}
|
|
@@ -1921,6 +1976,27 @@ var Sandbox = class Sandbox {
|
|
|
1921
1976
|
const fork = new Sandbox(data, this._client);
|
|
1922
1977
|
return options.wait === false ? fork : waitForSandboxStart(fork);
|
|
1923
1978
|
}
|
|
1979
|
+
/** Expose a TCP port publicly (1–65535), returning its hostname. */
|
|
1980
|
+
async exposePort(port) {
|
|
1981
|
+
const client = this._client;
|
|
1982
|
+
return (await unwrap(retryApiRequest(() => client.PUT("/api/sandboxes/{sid}/ports/{port}", { params: { path: {
|
|
1983
|
+
sid: this.id,
|
|
1984
|
+
port
|
|
1985
|
+
} } }), "transient"))).hostname;
|
|
1986
|
+
}
|
|
1987
|
+
/** List explicitly exposed public ports. Service-published ports are in `endpoints`. */
|
|
1988
|
+
async listPorts() {
|
|
1989
|
+
const client = this._client;
|
|
1990
|
+
return (await unwrap(retryApiRequest(() => client.GET("/api/sandboxes/{sid}/ports", { params: { path: { sid: this.id } } }), "transient"))).ports;
|
|
1991
|
+
}
|
|
1992
|
+
/** Remove explicit public exposure. A service publishing the same port remains reachable. */
|
|
1993
|
+
async unexposePort(port) {
|
|
1994
|
+
const client = this._client;
|
|
1995
|
+
await unwrapEmpty(retryApiRequest(() => client.DELETE("/api/sandboxes/{sid}/ports/{port}", { params: { path: {
|
|
1996
|
+
sid: this.id,
|
|
1997
|
+
port
|
|
1998
|
+
} } }), "transient"));
|
|
1999
|
+
}
|
|
1924
2000
|
/** Get this running sandbox's effective network policy. */
|
|
1925
2001
|
async getNetwork() {
|
|
1926
2002
|
const client = this._client;
|
|
@@ -1934,6 +2010,19 @@ var Sandbox = class Sandbox {
|
|
|
1934
2010
|
body: network
|
|
1935
2011
|
}), "transient"));
|
|
1936
2012
|
}
|
|
2013
|
+
/** Update either or both TTLs in seconds. Omitted settings remain unchanged. */
|
|
2014
|
+
async setTimeout(timeout) {
|
|
2015
|
+
const options = typeof timeout === "number" ? { timeoutSeconds: timeout } : timeout;
|
|
2016
|
+
const client = this._client;
|
|
2017
|
+
const data = await unwrap(retryApiRequest(() => client.POST("/api/sandboxes/{sid}/timeout", {
|
|
2018
|
+
params: { path: { sid: this.id } },
|
|
2019
|
+
body: {
|
|
2020
|
+
timeout: options.timeoutSeconds,
|
|
2021
|
+
idle_ttl_seconds: options.idleTtlSeconds
|
|
2022
|
+
}
|
|
2023
|
+
}), "transient"));
|
|
2024
|
+
return this._apply(data);
|
|
2025
|
+
}
|
|
1937
2026
|
/** Delete this sandbox and its backing disk. */
|
|
1938
2027
|
async delete() {
|
|
1939
2028
|
await unwrapEmpty(retryApiRequest(() => this._client.DELETE("/api/sandboxes/{sid}", { params: { path: { sid: this.id } } }), "transient"));
|
|
@@ -1975,8 +2064,10 @@ var Sandboxes = class {
|
|
|
1975
2064
|
base_image: request.baseImage,
|
|
1976
2065
|
env: request.env,
|
|
1977
2066
|
max_ttl_seconds: request.maxTtlSeconds,
|
|
2067
|
+
idle_ttl_seconds: request.idleTtlSeconds,
|
|
1978
2068
|
max_concurrent_execs: request.maxConcurrentExecs,
|
|
1979
|
-
network: request.network
|
|
2069
|
+
network: request.network,
|
|
2070
|
+
ports: request.ports
|
|
1980
2071
|
};
|
|
1981
2072
|
const sandbox = new Sandbox(await unwrap(retryApiRequest(() => this._client.POST("/api/sandboxes", {
|
|
1982
2073
|
params: { query: { wait: options.wait ?? true } },
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as S3Mount, 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 S3CompatibleMount, 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 RootAttrs, _ as MultipartUploadListing, a as DeleteObjectsResult, b as PartInfo, c as ExecResult, d as ListMultipartUploadsOptions, et as TokenUser, 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, nt as ApiClient, o as Disk, p as ListObjectsResult, q as MountConfig, r as DeleteObjectsError, s as DiskMultipart, t as AppendObjectOptions, tt as FileSystem, u as GrepResult, v as MultipartUploadSummary, w as PutObjectResult, x as PartListing, y as ObjectMetadata, z as DiskResponse } from "./disk-
|
|
1
|
+
import { $ as S3Mount, 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 S3CompatibleMount, 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 RootAttrs, _ as MultipartUploadListing, a as DeleteObjectsResult, b as PartInfo, c as ExecResult, d as ListMultipartUploadsOptions, et as TokenUser, 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, nt as ApiClient, o as Disk, p as ListObjectsResult, q as MountConfig, r as DeleteObjectsError, s as DiskMultipart, t as AppendObjectOptions, tt as FileSystem, u as GrepResult, v as MultipartUploadSummary, w as PutObjectResult, x as PartListing, y as ObjectMetadata, z as DiskResponse } from "./disk-CiLNoFCd.cjs";
|
|
2
2
|
import { components } from "@archildata/api-types";
|
|
3
3
|
|
|
4
4
|
//#region src/disks.d.ts
|
|
@@ -57,6 +57,12 @@ declare class Disks {
|
|
|
57
57
|
* Creation-time only.
|
|
58
58
|
*/
|
|
59
59
|
create(req: CreateDiskRequest): Promise<CreateDiskResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Execute a command on a disk that is already known to exist. Accepts the
|
|
62
|
+
* disk ID directly so callers that do not need its metadata can execute
|
|
63
|
+
* without fetching the disk first.
|
|
64
|
+
*/
|
|
65
|
+
exec(id: string, command: string): Promise<ExecResult>;
|
|
60
66
|
}
|
|
61
67
|
//#endregion
|
|
62
68
|
//#region src/sandbox-process.d.ts
|
|
@@ -195,7 +201,9 @@ type SandboxEgressRule = components["schemas"]["SandboxEgressRule"];
|
|
|
195
201
|
type SandboxEgressTransform = components["schemas"]["SandboxEgressTransform"];
|
|
196
202
|
type SandboxNetwork = components["schemas"]["SandboxNetwork"];
|
|
197
203
|
/** @internal */
|
|
198
|
-
type SandboxWire = components["schemas"]["Sandbox"]
|
|
204
|
+
type SandboxWire = components["schemas"]["Sandbox"] & {
|
|
205
|
+
idle_ttl_seconds?: number;
|
|
206
|
+
};
|
|
199
207
|
type SandboxStatus = components["schemas"]["SandboxState"];
|
|
200
208
|
interface SandboxEndpoint {
|
|
201
209
|
port: number;
|
|
@@ -210,6 +218,7 @@ interface SandboxResponse {
|
|
|
210
218
|
baseImage: string;
|
|
211
219
|
platform?: "arm64" | "amd64";
|
|
212
220
|
maxTtlSeconds: number;
|
|
221
|
+
idleTtlSeconds: number;
|
|
213
222
|
/** Maximum concurrently attached process sessions. Detached processes and one-shot controls do not count. */
|
|
214
223
|
maxConcurrentExecs: number;
|
|
215
224
|
endpoints?: SandboxEndpoint[];
|
|
@@ -217,7 +226,6 @@ interface SandboxResponse {
|
|
|
217
226
|
runningAt?: Date;
|
|
218
227
|
finishedAt?: Date;
|
|
219
228
|
lastActiveAt: Date;
|
|
220
|
-
expiresAt?: Date;
|
|
221
229
|
exitReason?: string;
|
|
222
230
|
}
|
|
223
231
|
interface SandboxWaitOptions {
|
|
@@ -231,6 +239,12 @@ interface SandboxForkOptions extends SandboxWaitOptions {
|
|
|
231
239
|
/** Name for the fork. The server generates one when omitted. */
|
|
232
240
|
name?: string;
|
|
233
241
|
}
|
|
242
|
+
interface SandboxTimeoutOptions {
|
|
243
|
+
/** Hard lifetime in seconds. Omit to leave its deadline unchanged. */
|
|
244
|
+
timeoutSeconds?: number;
|
|
245
|
+
/** Seconds without a direct process connection. Zero disables idle expiry; omit to leave unchanged. */
|
|
246
|
+
idleTtlSeconds?: number;
|
|
247
|
+
}
|
|
234
248
|
declare class Sandbox {
|
|
235
249
|
id: string;
|
|
236
250
|
name: string;
|
|
@@ -240,13 +254,13 @@ declare class Sandbox {
|
|
|
240
254
|
baseImage: string;
|
|
241
255
|
platform?: "arm64" | "amd64";
|
|
242
256
|
maxTtlSeconds: number;
|
|
257
|
+
idleTtlSeconds: number;
|
|
243
258
|
maxConcurrentExecs: number;
|
|
244
259
|
endpoints?: SandboxEndpoint[];
|
|
245
260
|
createdAt: Date;
|
|
246
261
|
runningAt?: Date;
|
|
247
262
|
finishedAt?: Date;
|
|
248
263
|
lastActiveAt: Date;
|
|
249
|
-
expiresAt?: Date;
|
|
250
264
|
exitReason?: string;
|
|
251
265
|
readonly processes: SandboxProcesses;
|
|
252
266
|
readonly files: SandboxFiles;
|
|
@@ -271,10 +285,18 @@ declare class Sandbox {
|
|
|
271
285
|
resume(options?: SandboxWaitOptions): Promise<Sandbox | this>;
|
|
272
286
|
/** Create an isolated writable branch from this sandbox's current state. */
|
|
273
287
|
fork(options?: SandboxForkOptions): Promise<Sandbox>;
|
|
288
|
+
/** Expose a TCP port publicly (1–65535), returning its hostname. */
|
|
289
|
+
exposePort(port: number): Promise<string>;
|
|
290
|
+
/** List explicitly exposed public ports. Service-published ports are in `endpoints`. */
|
|
291
|
+
listPorts(): Promise<SandboxEndpoint[]>;
|
|
292
|
+
/** Remove explicit public exposure. A service publishing the same port remains reachable. */
|
|
293
|
+
unexposePort(port: number): Promise<void>;
|
|
274
294
|
/** Get this running sandbox's effective network policy. */
|
|
275
295
|
getNetwork(): Promise<SandboxNetwork>;
|
|
276
296
|
/** Replace this running sandbox's complete network policy and return the effective policy. */
|
|
277
297
|
updateNetwork(network: SandboxNetwork): Promise<SandboxNetwork>;
|
|
298
|
+
/** Update either or both TTLs in seconds. Omitted settings remain unchanged. */
|
|
299
|
+
setTimeout(timeout: number | SandboxTimeoutOptions): Promise<this>;
|
|
278
300
|
/** Delete this sandbox and its backing disk. */
|
|
279
301
|
delete(): Promise<void>;
|
|
280
302
|
}
|
|
@@ -299,10 +321,14 @@ interface CreateSandboxRequest {
|
|
|
299
321
|
baseImage?: string;
|
|
300
322
|
env?: Record<string, string>;
|
|
301
323
|
maxTtlSeconds?: number;
|
|
324
|
+
/** Seconds without a direct process connection before pausing. Omitted or zero disables idle expiry. */
|
|
325
|
+
idleTtlSeconds?: number;
|
|
302
326
|
/** Maximum concurrently attached exec sessions. Detached processes and one-shot controls do not count. */
|
|
303
327
|
maxConcurrentExecs?: number;
|
|
304
328
|
/** Creation-time network policy. Egress is unrestricted when omitted. */
|
|
305
329
|
network?: SandboxNetwork;
|
|
330
|
+
/** TCP ports to expose publicly, from 1 to 65535. */
|
|
331
|
+
ports?: number[];
|
|
306
332
|
}
|
|
307
333
|
interface ListSandboxesOptions {
|
|
308
334
|
/** Only return sandboxes that mount this disk. */
|
|
@@ -559,4 +585,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
559
585
|
*/
|
|
560
586
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
561
587
|
//#endregion
|
|
562
|
-
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 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, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStatus, type SandboxTerminalOptions, 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 };
|
|
588
|
+
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 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, 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 };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as S3Mount, 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 S3CompatibleMount, 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 RootAttrs, _ as MultipartUploadListing, a as DeleteObjectsResult, b as PartInfo, c as ExecResult, d as ListMultipartUploadsOptions, et as TokenUser, 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, nt as ApiClient, o as Disk, p as ListObjectsResult, q as MountConfig, r as DeleteObjectsError, s as DiskMultipart, t as AppendObjectOptions, tt as FileSystem, u as GrepResult, v as MultipartUploadSummary, w as PutObjectResult, x as PartListing, y as ObjectMetadata, z as DiskResponse } from "./disk-
|
|
1
|
+
import { $ as S3Mount, 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 S3CompatibleMount, 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 RootAttrs, _ as MultipartUploadListing, a as DeleteObjectsResult, b as PartInfo, c as ExecResult, d as ListMultipartUploadsOptions, et as TokenUser, 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, nt as ApiClient, o as Disk, p as ListObjectsResult, q as MountConfig, r as DeleteObjectsError, s as DiskMultipart, t as AppendObjectOptions, tt as FileSystem, u as GrepResult, v as MultipartUploadSummary, w as PutObjectResult, x as PartListing, y as ObjectMetadata, z as DiskResponse } from "./disk-CiLNoFCd.mjs";
|
|
2
2
|
import { components } from "@archildata/api-types";
|
|
3
3
|
|
|
4
4
|
//#region src/disks.d.ts
|
|
@@ -57,6 +57,12 @@ declare class Disks {
|
|
|
57
57
|
* Creation-time only.
|
|
58
58
|
*/
|
|
59
59
|
create(req: CreateDiskRequest): Promise<CreateDiskResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Execute a command on a disk that is already known to exist. Accepts the
|
|
62
|
+
* disk ID directly so callers that do not need its metadata can execute
|
|
63
|
+
* without fetching the disk first.
|
|
64
|
+
*/
|
|
65
|
+
exec(id: string, command: string): Promise<ExecResult>;
|
|
60
66
|
}
|
|
61
67
|
//#endregion
|
|
62
68
|
//#region src/sandbox-process.d.ts
|
|
@@ -195,7 +201,9 @@ type SandboxEgressRule = components["schemas"]["SandboxEgressRule"];
|
|
|
195
201
|
type SandboxEgressTransform = components["schemas"]["SandboxEgressTransform"];
|
|
196
202
|
type SandboxNetwork = components["schemas"]["SandboxNetwork"];
|
|
197
203
|
/** @internal */
|
|
198
|
-
type SandboxWire = components["schemas"]["Sandbox"]
|
|
204
|
+
type SandboxWire = components["schemas"]["Sandbox"] & {
|
|
205
|
+
idle_ttl_seconds?: number;
|
|
206
|
+
};
|
|
199
207
|
type SandboxStatus = components["schemas"]["SandboxState"];
|
|
200
208
|
interface SandboxEndpoint {
|
|
201
209
|
port: number;
|
|
@@ -210,6 +218,7 @@ interface SandboxResponse {
|
|
|
210
218
|
baseImage: string;
|
|
211
219
|
platform?: "arm64" | "amd64";
|
|
212
220
|
maxTtlSeconds: number;
|
|
221
|
+
idleTtlSeconds: number;
|
|
213
222
|
/** Maximum concurrently attached process sessions. Detached processes and one-shot controls do not count. */
|
|
214
223
|
maxConcurrentExecs: number;
|
|
215
224
|
endpoints?: SandboxEndpoint[];
|
|
@@ -217,7 +226,6 @@ interface SandboxResponse {
|
|
|
217
226
|
runningAt?: Date;
|
|
218
227
|
finishedAt?: Date;
|
|
219
228
|
lastActiveAt: Date;
|
|
220
|
-
expiresAt?: Date;
|
|
221
229
|
exitReason?: string;
|
|
222
230
|
}
|
|
223
231
|
interface SandboxWaitOptions {
|
|
@@ -231,6 +239,12 @@ interface SandboxForkOptions extends SandboxWaitOptions {
|
|
|
231
239
|
/** Name for the fork. The server generates one when omitted. */
|
|
232
240
|
name?: string;
|
|
233
241
|
}
|
|
242
|
+
interface SandboxTimeoutOptions {
|
|
243
|
+
/** Hard lifetime in seconds. Omit to leave its deadline unchanged. */
|
|
244
|
+
timeoutSeconds?: number;
|
|
245
|
+
/** Seconds without a direct process connection. Zero disables idle expiry; omit to leave unchanged. */
|
|
246
|
+
idleTtlSeconds?: number;
|
|
247
|
+
}
|
|
234
248
|
declare class Sandbox {
|
|
235
249
|
id: string;
|
|
236
250
|
name: string;
|
|
@@ -240,13 +254,13 @@ declare class Sandbox {
|
|
|
240
254
|
baseImage: string;
|
|
241
255
|
platform?: "arm64" | "amd64";
|
|
242
256
|
maxTtlSeconds: number;
|
|
257
|
+
idleTtlSeconds: number;
|
|
243
258
|
maxConcurrentExecs: number;
|
|
244
259
|
endpoints?: SandboxEndpoint[];
|
|
245
260
|
createdAt: Date;
|
|
246
261
|
runningAt?: Date;
|
|
247
262
|
finishedAt?: Date;
|
|
248
263
|
lastActiveAt: Date;
|
|
249
|
-
expiresAt?: Date;
|
|
250
264
|
exitReason?: string;
|
|
251
265
|
readonly processes: SandboxProcesses;
|
|
252
266
|
readonly files: SandboxFiles;
|
|
@@ -271,10 +285,18 @@ declare class Sandbox {
|
|
|
271
285
|
resume(options?: SandboxWaitOptions): Promise<Sandbox | this>;
|
|
272
286
|
/** Create an isolated writable branch from this sandbox's current state. */
|
|
273
287
|
fork(options?: SandboxForkOptions): Promise<Sandbox>;
|
|
288
|
+
/** Expose a TCP port publicly (1–65535), returning its hostname. */
|
|
289
|
+
exposePort(port: number): Promise<string>;
|
|
290
|
+
/** List explicitly exposed public ports. Service-published ports are in `endpoints`. */
|
|
291
|
+
listPorts(): Promise<SandboxEndpoint[]>;
|
|
292
|
+
/** Remove explicit public exposure. A service publishing the same port remains reachable. */
|
|
293
|
+
unexposePort(port: number): Promise<void>;
|
|
274
294
|
/** Get this running sandbox's effective network policy. */
|
|
275
295
|
getNetwork(): Promise<SandboxNetwork>;
|
|
276
296
|
/** Replace this running sandbox's complete network policy and return the effective policy. */
|
|
277
297
|
updateNetwork(network: SandboxNetwork): Promise<SandboxNetwork>;
|
|
298
|
+
/** Update either or both TTLs in seconds. Omitted settings remain unchanged. */
|
|
299
|
+
setTimeout(timeout: number | SandboxTimeoutOptions): Promise<this>;
|
|
278
300
|
/** Delete this sandbox and its backing disk. */
|
|
279
301
|
delete(): Promise<void>;
|
|
280
302
|
}
|
|
@@ -299,10 +321,14 @@ interface CreateSandboxRequest {
|
|
|
299
321
|
baseImage?: string;
|
|
300
322
|
env?: Record<string, string>;
|
|
301
323
|
maxTtlSeconds?: number;
|
|
324
|
+
/** Seconds without a direct process connection before pausing. Omitted or zero disables idle expiry. */
|
|
325
|
+
idleTtlSeconds?: number;
|
|
302
326
|
/** Maximum concurrently attached exec sessions. Detached processes and one-shot controls do not count. */
|
|
303
327
|
maxConcurrentExecs?: number;
|
|
304
328
|
/** Creation-time network policy. Egress is unrestricted when omitted. */
|
|
305
329
|
network?: SandboxNetwork;
|
|
330
|
+
/** TCP ports to expose publicly, from 1 to 65535. */
|
|
331
|
+
ports?: number[];
|
|
306
332
|
}
|
|
307
333
|
interface ListSandboxesOptions {
|
|
308
334
|
/** Only return sandboxes that mount this disk. */
|
|
@@ -559,4 +585,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
559
585
|
*/
|
|
560
586
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
561
587
|
//#endregion
|
|
562
|
-
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 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, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStatus, type SandboxTerminalOptions, 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 };
|
|
588
|
+
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 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, 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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as ArchilS3Error, C as DiskMultipart, E as VERSION, O as ArchilApiError, S as Disk, T as USER_AGENT, _ 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 SandboxFileTransferError, k as ArchilError, 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 effectiveUploadPartSize, x as Disks, y as SandboxProcess } from "./src-
|
|
1
|
+
import { A as ArchilS3Error, C as DiskMultipart, E as VERSION, O as ArchilApiError, S as Disk, T as USER_AGENT, _ 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 SandboxFileTransferError, k as ArchilError, 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 effectiveUploadPartSize, x as Disks, y as SandboxProcess } from "./src-Crk5lxKW.mjs";
|
|
2
2
|
export { Archil, ArchilApiError, ArchilError, ArchilS3Error, Disk, DiskMultipart, Disks, Sandbox, SandboxFileTransferError, SandboxFiles, 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 { O as ArchilApiError, p as Archil } from "./src-
|
|
3
|
-
import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-
|
|
2
|
+
import { O as ArchilApiError, p as Archil } from "./src-Crk5lxKW.mjs";
|
|
3
|
+
import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-DQS29KQU.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
import { spinner } from "@clack/prompts";
|
|
@@ -30,8 +30,7 @@ function formatSandboxList(sandboxes, format) {
|
|
|
30
30
|
String(sandbox.vcpuCount),
|
|
31
31
|
`${sandbox.memSizeMiB} MiB`,
|
|
32
32
|
sandbox.baseImage,
|
|
33
|
-
date(sandbox.lastActiveAt)
|
|
34
|
-
date(sandbox.expiresAt)
|
|
33
|
+
date(sandbox.lastActiveAt)
|
|
35
34
|
]), [
|
|
36
35
|
"id",
|
|
37
36
|
"name",
|
|
@@ -39,8 +38,7 @@ function formatSandboxList(sandboxes, format) {
|
|
|
39
38
|
"cpu",
|
|
40
39
|
"memory",
|
|
41
40
|
"image",
|
|
42
|
-
"last active"
|
|
43
|
-
"expires"
|
|
41
|
+
"last active"
|
|
44
42
|
]);
|
|
45
43
|
}
|
|
46
44
|
function formatSandbox(sandbox, format) {
|
|
@@ -54,12 +52,12 @@ function formatSandbox(sandbox, format) {
|
|
|
54
52
|
["image", sandbox.baseImage],
|
|
55
53
|
["platform", sandbox.platform ?? ""],
|
|
56
54
|
["max TTL", `${sandbox.maxTtlSeconds} seconds`],
|
|
55
|
+
["idle TTL", sandbox.idleTtlSeconds === 0 ? "disabled" : `${sandbox.idleTtlSeconds} seconds`],
|
|
57
56
|
["max concurrent processes", String(sandbox.maxConcurrentExecs)],
|
|
58
57
|
["created", date(sandbox.createdAt)],
|
|
59
58
|
["running", date(sandbox.runningAt)],
|
|
60
59
|
["finished", date(sandbox.finishedAt)],
|
|
61
60
|
["last active", date(sandbox.lastActiveAt)],
|
|
62
|
-
["expires", date(sandbox.expiresAt)],
|
|
63
61
|
["exit reason", sandbox.exitReason ?? ""]
|
|
64
62
|
];
|
|
65
63
|
for (const endpoint of sandbox.endpoints ?? []) rows.push([`endpoint ${endpoint.port}`, endpoint.hostname]);
|
|
@@ -98,6 +96,7 @@ function parseCreateSandboxOptions(name, options) {
|
|
|
98
96
|
memSizeMiB: optionalInteger(options.memSizeMib, "Memory", 256, 65536),
|
|
99
97
|
baseImage: options.baseImage,
|
|
100
98
|
maxTtlSeconds: optionalInteger(options.maxTtlSeconds, "Max TTL", 1, 2147483647),
|
|
99
|
+
idleTtlSeconds: optionalInteger(options.idleTtlSeconds, "Idle TTL", 0, 86400),
|
|
101
100
|
maxConcurrentExecs: optionalInteger(options.maxConcurrentProcesses, "Max concurrent processes", 1, 1024),
|
|
102
101
|
env: parseEnvironment(options.env)
|
|
103
102
|
};
|
|
@@ -332,7 +331,7 @@ function createSandboxProgram(dependencies) {
|
|
|
332
331
|
formatOption(program.command("get <id|name>").description("Show sandbox details")).action(async (target, options) => {
|
|
333
332
|
output(formatSandbox(await resolveSandbox(requireService(), target), options.output));
|
|
334
333
|
});
|
|
335
|
-
waitOption(formatOption(program.command("create [name]").description("Create a sandbox"))).option("--vcpu-count <count>", "Virtual CPU count (1-32)").option("--mem-size-mib <mib>", "Memory in MiB (256-65536)").option("--base-image <image>", "Public OCI image", "ubuntu:26.04").option("--max-ttl-seconds <seconds>", "Maximum sandbox lifetime").option("--max-concurrent-processes <count>", "Maximum attached processes").option("--env <name=value>", "Set an environment variable (repeatable)", (value, previous) => [...previous, value], []).action(async (name, options) => {
|
|
334
|
+
waitOption(formatOption(program.command("create [name]").description("Create a sandbox"))).option("--vcpu-count <count>", "Virtual CPU count (1-32)").option("--mem-size-mib <mib>", "Memory in MiB (256-65536)").option("--base-image <image>", "Public OCI image", "ubuntu:26.04").option("--max-ttl-seconds <seconds>", "Maximum sandbox lifetime").option("--idle-ttl-seconds <seconds>", "Seconds without a process connection before pausing (0 disables)").option("--max-concurrent-processes <count>", "Maximum attached processes").option("--env <name=value>", "Set an environment variable (repeatable)", (value, previous) => [...previous, value], []).action(async (name, options) => {
|
|
336
335
|
const sandbox = await withSpinner("Creating sandbox", options.wait, () => requireService().create(parseCreateSandboxOptions(name, options), { wait: options.wait }));
|
|
337
336
|
output(formatSandbox(sandbox, options.output));
|
|
338
337
|
});
|
|
@@ -122,7 +122,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
|
|
|
122
122
|
}
|
|
123
123
|
//#endregion
|
|
124
124
|
//#region src/version.ts
|
|
125
|
-
const VERSION = "1.
|
|
125
|
+
const VERSION = "1.2.0";
|
|
126
126
|
const USER_AGENT = `archil-js/${VERSION}`;
|
|
127
127
|
//#endregion
|
|
128
128
|
//#region src/client.ts
|
|
@@ -131,6 +131,49 @@ function isNodeRuntime() {
|
|
|
131
131
|
return typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
132
132
|
}
|
|
133
133
|
const undiciModule = isNodeRuntime() ? import("undici") : void 0;
|
|
134
|
+
const CONTROL_PLANE_CONNECTIONS = 1;
|
|
135
|
+
const CONTROL_PLANE_CONCURRENT_STREAMS = 100;
|
|
136
|
+
function isAsyncIterableBody(body) {
|
|
137
|
+
return body != null && typeof body === "object" && Symbol.asyncIterator in body;
|
|
138
|
+
}
|
|
139
|
+
async function bufferBody(body) {
|
|
140
|
+
const chunks = [];
|
|
141
|
+
for await (const chunk of body) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
142
|
+
return Buffer.concat(chunks);
|
|
143
|
+
}
|
|
144
|
+
const multiplexHttp2Requests = (dispatch) => (options, handler) => {
|
|
145
|
+
let requestStarted = false;
|
|
146
|
+
const guardedHandler = {
|
|
147
|
+
onRequestStart(controller, context) {
|
|
148
|
+
if (requestStarted) {
|
|
149
|
+
controller.abort(/* @__PURE__ */ new Error("Archil control-plane requests are not replayed after a connection failure"));
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
requestStarted = true;
|
|
153
|
+
handler.onRequestStart?.(controller, context);
|
|
154
|
+
},
|
|
155
|
+
onRequestUpgrade: handler.onRequestUpgrade?.bind(handler),
|
|
156
|
+
onResponseStart: handler.onResponseStart?.bind(handler),
|
|
157
|
+
onResponseData: handler.onResponseData?.bind(handler),
|
|
158
|
+
onResponseEnd: handler.onResponseEnd?.bind(handler),
|
|
159
|
+
onResponseError: handler.onResponseError?.bind(handler)
|
|
160
|
+
};
|
|
161
|
+
const dispatchBody = (body) => dispatch({
|
|
162
|
+
...options,
|
|
163
|
+
body,
|
|
164
|
+
idempotent: true
|
|
165
|
+
}, guardedHandler);
|
|
166
|
+
if (!isAsyncIterableBody(options.body)) return dispatchBody(options.body);
|
|
167
|
+
bufferBody(options.body).then(dispatchBody, (error) => handler.onResponseError?.({
|
|
168
|
+
aborted: false,
|
|
169
|
+
paused: false,
|
|
170
|
+
reason: null,
|
|
171
|
+
abort() {},
|
|
172
|
+
pause() {},
|
|
173
|
+
resume() {}
|
|
174
|
+
}, error instanceof Error ? error : new Error(String(error))));
|
|
175
|
+
return true;
|
|
176
|
+
};
|
|
134
177
|
const sharedDispatchers = /* @__PURE__ */ new Map();
|
|
135
178
|
function dispatcherKey(baseUrl, apiKey) {
|
|
136
179
|
return `${new URL(baseUrl).origin}\0${apiKey}`;
|
|
@@ -144,10 +187,11 @@ function getSharedDispatcher(baseUrl, apiKey) {
|
|
|
144
187
|
const { Agent } = await undiciModule;
|
|
145
188
|
return new Agent({
|
|
146
189
|
allowH2: true,
|
|
147
|
-
connections:
|
|
190
|
+
connections: CONTROL_PLANE_CONNECTIONS,
|
|
191
|
+
pipelining: CONTROL_PLANE_CONCURRENT_STREAMS,
|
|
148
192
|
keepAliveTimeout: 6e4,
|
|
149
193
|
keepAliveMaxTimeout: 6e5
|
|
150
|
-
});
|
|
194
|
+
}).compose(multiplexHttp2Requests);
|
|
151
195
|
})();
|
|
152
196
|
sharedDispatchers.set(key, dispatcher);
|
|
153
197
|
dispatcher.catch(() => {
|
|
@@ -1241,6 +1285,17 @@ var Disks = class {
|
|
|
1241
1285
|
authorizedUsers
|
|
1242
1286
|
};
|
|
1243
1287
|
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Execute a command on a disk that is already known to exist. Accepts the
|
|
1290
|
+
* disk ID directly so callers that do not need its metadata can execute
|
|
1291
|
+
* without fetching the disk first.
|
|
1292
|
+
*/
|
|
1293
|
+
async exec(id, command) {
|
|
1294
|
+
return unwrap(this._client.POST("/api/disks/{id}/exec", {
|
|
1295
|
+
params: { path: { id } },
|
|
1296
|
+
body: { command }
|
|
1297
|
+
}));
|
|
1298
|
+
}
|
|
1244
1299
|
};
|
|
1245
1300
|
//#endregion
|
|
1246
1301
|
//#region src/sandbox-process.ts
|
|
@@ -1788,13 +1843,13 @@ var Sandbox = class Sandbox {
|
|
|
1788
1843
|
baseImage;
|
|
1789
1844
|
platform;
|
|
1790
1845
|
maxTtlSeconds;
|
|
1846
|
+
idleTtlSeconds;
|
|
1791
1847
|
maxConcurrentExecs;
|
|
1792
1848
|
endpoints;
|
|
1793
1849
|
createdAt;
|
|
1794
1850
|
runningAt;
|
|
1795
1851
|
finishedAt;
|
|
1796
1852
|
lastActiveAt;
|
|
1797
|
-
expiresAt;
|
|
1798
1853
|
exitReason;
|
|
1799
1854
|
processes;
|
|
1800
1855
|
files;
|
|
@@ -1817,13 +1872,13 @@ var Sandbox = class Sandbox {
|
|
|
1817
1872
|
this.baseImage = data.base_image;
|
|
1818
1873
|
this.platform = data.platform;
|
|
1819
1874
|
this.maxTtlSeconds = data.max_ttl_seconds;
|
|
1875
|
+
this.idleTtlSeconds = data.idle_ttl_seconds ?? 0;
|
|
1820
1876
|
this.maxConcurrentExecs = data.max_concurrent_execs;
|
|
1821
1877
|
this.endpoints = data.endpoints?.map((endpoint) => ({ ...endpoint }));
|
|
1822
1878
|
this.createdAt = new Date(data.created_at);
|
|
1823
1879
|
this.runningAt = data.running_at ? new Date(data.running_at) : void 0;
|
|
1824
1880
|
this.finishedAt = data.finished_at ? new Date(data.finished_at) : void 0;
|
|
1825
1881
|
this.lastActiveAt = new Date(data.last_active_at);
|
|
1826
|
-
this.expiresAt = data.expires_at ? new Date(data.expires_at) : void 0;
|
|
1827
1882
|
this.exitReason = data.exit_reason;
|
|
1828
1883
|
return this;
|
|
1829
1884
|
}
|
|
@@ -1837,13 +1892,13 @@ var Sandbox = class Sandbox {
|
|
|
1837
1892
|
baseImage: this.baseImage,
|
|
1838
1893
|
platform: this.platform,
|
|
1839
1894
|
maxTtlSeconds: this.maxTtlSeconds,
|
|
1895
|
+
idleTtlSeconds: this.idleTtlSeconds,
|
|
1840
1896
|
maxConcurrentExecs: this.maxConcurrentExecs,
|
|
1841
1897
|
endpoints: this.endpoints?.map((endpoint) => ({ ...endpoint })),
|
|
1842
1898
|
createdAt: this.createdAt,
|
|
1843
1899
|
runningAt: this.runningAt,
|
|
1844
1900
|
finishedAt: this.finishedAt,
|
|
1845
1901
|
lastActiveAt: this.lastActiveAt,
|
|
1846
|
-
expiresAt: this.expiresAt,
|
|
1847
1902
|
exitReason: this.exitReason
|
|
1848
1903
|
};
|
|
1849
1904
|
}
|
|
@@ -1898,6 +1953,27 @@ var Sandbox = class Sandbox {
|
|
|
1898
1953
|
const fork = new Sandbox(data, this._client);
|
|
1899
1954
|
return options.wait === false ? fork : waitForSandboxStart(fork);
|
|
1900
1955
|
}
|
|
1956
|
+
/** Expose a TCP port publicly (1–65535), returning its hostname. */
|
|
1957
|
+
async exposePort(port) {
|
|
1958
|
+
const client = this._client;
|
|
1959
|
+
return (await unwrap(retryApiRequest(() => client.PUT("/api/sandboxes/{sid}/ports/{port}", { params: { path: {
|
|
1960
|
+
sid: this.id,
|
|
1961
|
+
port
|
|
1962
|
+
} } }), "transient"))).hostname;
|
|
1963
|
+
}
|
|
1964
|
+
/** List explicitly exposed public ports. Service-published ports are in `endpoints`. */
|
|
1965
|
+
async listPorts() {
|
|
1966
|
+
const client = this._client;
|
|
1967
|
+
return (await unwrap(retryApiRequest(() => client.GET("/api/sandboxes/{sid}/ports", { params: { path: { sid: this.id } } }), "transient"))).ports;
|
|
1968
|
+
}
|
|
1969
|
+
/** Remove explicit public exposure. A service publishing the same port remains reachable. */
|
|
1970
|
+
async unexposePort(port) {
|
|
1971
|
+
const client = this._client;
|
|
1972
|
+
await unwrapEmpty(retryApiRequest(() => client.DELETE("/api/sandboxes/{sid}/ports/{port}", { params: { path: {
|
|
1973
|
+
sid: this.id,
|
|
1974
|
+
port
|
|
1975
|
+
} } }), "transient"));
|
|
1976
|
+
}
|
|
1901
1977
|
/** Get this running sandbox's effective network policy. */
|
|
1902
1978
|
async getNetwork() {
|
|
1903
1979
|
const client = this._client;
|
|
@@ -1911,6 +1987,19 @@ var Sandbox = class Sandbox {
|
|
|
1911
1987
|
body: network
|
|
1912
1988
|
}), "transient"));
|
|
1913
1989
|
}
|
|
1990
|
+
/** Update either or both TTLs in seconds. Omitted settings remain unchanged. */
|
|
1991
|
+
async setTimeout(timeout) {
|
|
1992
|
+
const options = typeof timeout === "number" ? { timeoutSeconds: timeout } : timeout;
|
|
1993
|
+
const client = this._client;
|
|
1994
|
+
const data = await unwrap(retryApiRequest(() => client.POST("/api/sandboxes/{sid}/timeout", {
|
|
1995
|
+
params: { path: { sid: this.id } },
|
|
1996
|
+
body: {
|
|
1997
|
+
timeout: options.timeoutSeconds,
|
|
1998
|
+
idle_ttl_seconds: options.idleTtlSeconds
|
|
1999
|
+
}
|
|
2000
|
+
}), "transient"));
|
|
2001
|
+
return this._apply(data);
|
|
2002
|
+
}
|
|
1914
2003
|
/** Delete this sandbox and its backing disk. */
|
|
1915
2004
|
async delete() {
|
|
1916
2005
|
await unwrapEmpty(retryApiRequest(() => this._client.DELETE("/api/sandboxes/{sid}", { params: { path: { sid: this.id } } }), "transient"));
|
|
@@ -1952,8 +2041,10 @@ var Sandboxes = class {
|
|
|
1952
2041
|
base_image: request.baseImage,
|
|
1953
2042
|
env: request.env,
|
|
1954
2043
|
max_ttl_seconds: request.maxTtlSeconds,
|
|
2044
|
+
idle_ttl_seconds: request.idleTtlSeconds,
|
|
1955
2045
|
max_concurrent_execs: request.maxConcurrentExecs,
|
|
1956
|
-
network: request.network
|
|
2046
|
+
network: request.network,
|
|
2047
|
+
ports: request.ports
|
|
1957
2048
|
};
|
|
1958
2049
|
const sandbox = new Sandbox(await unwrap(retryApiRequest(() => this._client.POST("/api/sandboxes", {
|
|
1959
2050
|
params: { query: { wait: options.wait ?? true } },
|