disk 1.1.2 → 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-DUyyWu2M.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 +87 -7
- package/dist/index.d.cts +25 -5
- package/dist/index.d.mts +25 -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-DXNLDPID.mjs → src-Crk5lxKW.mjs} +87 -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(() => {
|
|
@@ -1822,13 +1866,13 @@ var Sandbox = class Sandbox {
|
|
|
1822
1866
|
baseImage;
|
|
1823
1867
|
platform;
|
|
1824
1868
|
maxTtlSeconds;
|
|
1869
|
+
idleTtlSeconds;
|
|
1825
1870
|
maxConcurrentExecs;
|
|
1826
1871
|
endpoints;
|
|
1827
1872
|
createdAt;
|
|
1828
1873
|
runningAt;
|
|
1829
1874
|
finishedAt;
|
|
1830
1875
|
lastActiveAt;
|
|
1831
|
-
expiresAt;
|
|
1832
1876
|
exitReason;
|
|
1833
1877
|
processes;
|
|
1834
1878
|
files;
|
|
@@ -1851,13 +1895,13 @@ var Sandbox = class Sandbox {
|
|
|
1851
1895
|
this.baseImage = data.base_image;
|
|
1852
1896
|
this.platform = data.platform;
|
|
1853
1897
|
this.maxTtlSeconds = data.max_ttl_seconds;
|
|
1898
|
+
this.idleTtlSeconds = data.idle_ttl_seconds ?? 0;
|
|
1854
1899
|
this.maxConcurrentExecs = data.max_concurrent_execs;
|
|
1855
1900
|
this.endpoints = data.endpoints?.map((endpoint) => ({ ...endpoint }));
|
|
1856
1901
|
this.createdAt = new Date(data.created_at);
|
|
1857
1902
|
this.runningAt = data.running_at ? new Date(data.running_at) : void 0;
|
|
1858
1903
|
this.finishedAt = data.finished_at ? new Date(data.finished_at) : void 0;
|
|
1859
1904
|
this.lastActiveAt = new Date(data.last_active_at);
|
|
1860
|
-
this.expiresAt = data.expires_at ? new Date(data.expires_at) : void 0;
|
|
1861
1905
|
this.exitReason = data.exit_reason;
|
|
1862
1906
|
return this;
|
|
1863
1907
|
}
|
|
@@ -1871,13 +1915,13 @@ var Sandbox = class Sandbox {
|
|
|
1871
1915
|
baseImage: this.baseImage,
|
|
1872
1916
|
platform: this.platform,
|
|
1873
1917
|
maxTtlSeconds: this.maxTtlSeconds,
|
|
1918
|
+
idleTtlSeconds: this.idleTtlSeconds,
|
|
1874
1919
|
maxConcurrentExecs: this.maxConcurrentExecs,
|
|
1875
1920
|
endpoints: this.endpoints?.map((endpoint) => ({ ...endpoint })),
|
|
1876
1921
|
createdAt: this.createdAt,
|
|
1877
1922
|
runningAt: this.runningAt,
|
|
1878
1923
|
finishedAt: this.finishedAt,
|
|
1879
1924
|
lastActiveAt: this.lastActiveAt,
|
|
1880
|
-
expiresAt: this.expiresAt,
|
|
1881
1925
|
exitReason: this.exitReason
|
|
1882
1926
|
};
|
|
1883
1927
|
}
|
|
@@ -1932,6 +1976,27 @@ var Sandbox = class Sandbox {
|
|
|
1932
1976
|
const fork = new Sandbox(data, this._client);
|
|
1933
1977
|
return options.wait === false ? fork : waitForSandboxStart(fork);
|
|
1934
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
|
+
}
|
|
1935
2000
|
/** Get this running sandbox's effective network policy. */
|
|
1936
2001
|
async getNetwork() {
|
|
1937
2002
|
const client = this._client;
|
|
@@ -1945,6 +2010,19 @@ var Sandbox = class Sandbox {
|
|
|
1945
2010
|
body: network
|
|
1946
2011
|
}), "transient"));
|
|
1947
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
|
+
}
|
|
1948
2026
|
/** Delete this sandbox and its backing disk. */
|
|
1949
2027
|
async delete() {
|
|
1950
2028
|
await unwrapEmpty(retryApiRequest(() => this._client.DELETE("/api/sandboxes/{sid}", { params: { path: { sid: this.id } } }), "transient"));
|
|
@@ -1986,8 +2064,10 @@ var Sandboxes = class {
|
|
|
1986
2064
|
base_image: request.baseImage,
|
|
1987
2065
|
env: request.env,
|
|
1988
2066
|
max_ttl_seconds: request.maxTtlSeconds,
|
|
2067
|
+
idle_ttl_seconds: request.idleTtlSeconds,
|
|
1989
2068
|
max_concurrent_execs: request.maxConcurrentExecs,
|
|
1990
|
-
network: request.network
|
|
2069
|
+
network: request.network,
|
|
2070
|
+
ports: request.ports
|
|
1991
2071
|
};
|
|
1992
2072
|
const sandbox = new Sandbox(await unwrap(retryApiRequest(() => this._client.POST("/api/sandboxes", {
|
|
1993
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
|
|
@@ -201,7 +201,9 @@ type SandboxEgressRule = components["schemas"]["SandboxEgressRule"];
|
|
|
201
201
|
type SandboxEgressTransform = components["schemas"]["SandboxEgressTransform"];
|
|
202
202
|
type SandboxNetwork = components["schemas"]["SandboxNetwork"];
|
|
203
203
|
/** @internal */
|
|
204
|
-
type SandboxWire = components["schemas"]["Sandbox"]
|
|
204
|
+
type SandboxWire = components["schemas"]["Sandbox"] & {
|
|
205
|
+
idle_ttl_seconds?: number;
|
|
206
|
+
};
|
|
205
207
|
type SandboxStatus = components["schemas"]["SandboxState"];
|
|
206
208
|
interface SandboxEndpoint {
|
|
207
209
|
port: number;
|
|
@@ -216,6 +218,7 @@ interface SandboxResponse {
|
|
|
216
218
|
baseImage: string;
|
|
217
219
|
platform?: "arm64" | "amd64";
|
|
218
220
|
maxTtlSeconds: number;
|
|
221
|
+
idleTtlSeconds: number;
|
|
219
222
|
/** Maximum concurrently attached process sessions. Detached processes and one-shot controls do not count. */
|
|
220
223
|
maxConcurrentExecs: number;
|
|
221
224
|
endpoints?: SandboxEndpoint[];
|
|
@@ -223,7 +226,6 @@ interface SandboxResponse {
|
|
|
223
226
|
runningAt?: Date;
|
|
224
227
|
finishedAt?: Date;
|
|
225
228
|
lastActiveAt: Date;
|
|
226
|
-
expiresAt?: Date;
|
|
227
229
|
exitReason?: string;
|
|
228
230
|
}
|
|
229
231
|
interface SandboxWaitOptions {
|
|
@@ -237,6 +239,12 @@ interface SandboxForkOptions extends SandboxWaitOptions {
|
|
|
237
239
|
/** Name for the fork. The server generates one when omitted. */
|
|
238
240
|
name?: string;
|
|
239
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
|
+
}
|
|
240
248
|
declare class Sandbox {
|
|
241
249
|
id: string;
|
|
242
250
|
name: string;
|
|
@@ -246,13 +254,13 @@ declare class Sandbox {
|
|
|
246
254
|
baseImage: string;
|
|
247
255
|
platform?: "arm64" | "amd64";
|
|
248
256
|
maxTtlSeconds: number;
|
|
257
|
+
idleTtlSeconds: number;
|
|
249
258
|
maxConcurrentExecs: number;
|
|
250
259
|
endpoints?: SandboxEndpoint[];
|
|
251
260
|
createdAt: Date;
|
|
252
261
|
runningAt?: Date;
|
|
253
262
|
finishedAt?: Date;
|
|
254
263
|
lastActiveAt: Date;
|
|
255
|
-
expiresAt?: Date;
|
|
256
264
|
exitReason?: string;
|
|
257
265
|
readonly processes: SandboxProcesses;
|
|
258
266
|
readonly files: SandboxFiles;
|
|
@@ -277,10 +285,18 @@ declare class Sandbox {
|
|
|
277
285
|
resume(options?: SandboxWaitOptions): Promise<Sandbox | this>;
|
|
278
286
|
/** Create an isolated writable branch from this sandbox's current state. */
|
|
279
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>;
|
|
280
294
|
/** Get this running sandbox's effective network policy. */
|
|
281
295
|
getNetwork(): Promise<SandboxNetwork>;
|
|
282
296
|
/** Replace this running sandbox's complete network policy and return the effective policy. */
|
|
283
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>;
|
|
284
300
|
/** Delete this sandbox and its backing disk. */
|
|
285
301
|
delete(): Promise<void>;
|
|
286
302
|
}
|
|
@@ -305,10 +321,14 @@ interface CreateSandboxRequest {
|
|
|
305
321
|
baseImage?: string;
|
|
306
322
|
env?: Record<string, string>;
|
|
307
323
|
maxTtlSeconds?: number;
|
|
324
|
+
/** Seconds without a direct process connection before pausing. Omitted or zero disables idle expiry. */
|
|
325
|
+
idleTtlSeconds?: number;
|
|
308
326
|
/** Maximum concurrently attached exec sessions. Detached processes and one-shot controls do not count. */
|
|
309
327
|
maxConcurrentExecs?: number;
|
|
310
328
|
/** Creation-time network policy. Egress is unrestricted when omitted. */
|
|
311
329
|
network?: SandboxNetwork;
|
|
330
|
+
/** TCP ports to expose publicly, from 1 to 65535. */
|
|
331
|
+
ports?: number[];
|
|
312
332
|
}
|
|
313
333
|
interface ListSandboxesOptions {
|
|
314
334
|
/** Only return sandboxes that mount this disk. */
|
|
@@ -565,4 +585,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
565
585
|
*/
|
|
566
586
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
567
587
|
//#endregion
|
|
568
|
-
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
|
|
@@ -201,7 +201,9 @@ type SandboxEgressRule = components["schemas"]["SandboxEgressRule"];
|
|
|
201
201
|
type SandboxEgressTransform = components["schemas"]["SandboxEgressTransform"];
|
|
202
202
|
type SandboxNetwork = components["schemas"]["SandboxNetwork"];
|
|
203
203
|
/** @internal */
|
|
204
|
-
type SandboxWire = components["schemas"]["Sandbox"]
|
|
204
|
+
type SandboxWire = components["schemas"]["Sandbox"] & {
|
|
205
|
+
idle_ttl_seconds?: number;
|
|
206
|
+
};
|
|
205
207
|
type SandboxStatus = components["schemas"]["SandboxState"];
|
|
206
208
|
interface SandboxEndpoint {
|
|
207
209
|
port: number;
|
|
@@ -216,6 +218,7 @@ interface SandboxResponse {
|
|
|
216
218
|
baseImage: string;
|
|
217
219
|
platform?: "arm64" | "amd64";
|
|
218
220
|
maxTtlSeconds: number;
|
|
221
|
+
idleTtlSeconds: number;
|
|
219
222
|
/** Maximum concurrently attached process sessions. Detached processes and one-shot controls do not count. */
|
|
220
223
|
maxConcurrentExecs: number;
|
|
221
224
|
endpoints?: SandboxEndpoint[];
|
|
@@ -223,7 +226,6 @@ interface SandboxResponse {
|
|
|
223
226
|
runningAt?: Date;
|
|
224
227
|
finishedAt?: Date;
|
|
225
228
|
lastActiveAt: Date;
|
|
226
|
-
expiresAt?: Date;
|
|
227
229
|
exitReason?: string;
|
|
228
230
|
}
|
|
229
231
|
interface SandboxWaitOptions {
|
|
@@ -237,6 +239,12 @@ interface SandboxForkOptions extends SandboxWaitOptions {
|
|
|
237
239
|
/** Name for the fork. The server generates one when omitted. */
|
|
238
240
|
name?: string;
|
|
239
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
|
+
}
|
|
240
248
|
declare class Sandbox {
|
|
241
249
|
id: string;
|
|
242
250
|
name: string;
|
|
@@ -246,13 +254,13 @@ declare class Sandbox {
|
|
|
246
254
|
baseImage: string;
|
|
247
255
|
platform?: "arm64" | "amd64";
|
|
248
256
|
maxTtlSeconds: number;
|
|
257
|
+
idleTtlSeconds: number;
|
|
249
258
|
maxConcurrentExecs: number;
|
|
250
259
|
endpoints?: SandboxEndpoint[];
|
|
251
260
|
createdAt: Date;
|
|
252
261
|
runningAt?: Date;
|
|
253
262
|
finishedAt?: Date;
|
|
254
263
|
lastActiveAt: Date;
|
|
255
|
-
expiresAt?: Date;
|
|
256
264
|
exitReason?: string;
|
|
257
265
|
readonly processes: SandboxProcesses;
|
|
258
266
|
readonly files: SandboxFiles;
|
|
@@ -277,10 +285,18 @@ declare class Sandbox {
|
|
|
277
285
|
resume(options?: SandboxWaitOptions): Promise<Sandbox | this>;
|
|
278
286
|
/** Create an isolated writable branch from this sandbox's current state. */
|
|
279
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>;
|
|
280
294
|
/** Get this running sandbox's effective network policy. */
|
|
281
295
|
getNetwork(): Promise<SandboxNetwork>;
|
|
282
296
|
/** Replace this running sandbox's complete network policy and return the effective policy. */
|
|
283
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>;
|
|
284
300
|
/** Delete this sandbox and its backing disk. */
|
|
285
301
|
delete(): Promise<void>;
|
|
286
302
|
}
|
|
@@ -305,10 +321,14 @@ interface CreateSandboxRequest {
|
|
|
305
321
|
baseImage?: string;
|
|
306
322
|
env?: Record<string, string>;
|
|
307
323
|
maxTtlSeconds?: number;
|
|
324
|
+
/** Seconds without a direct process connection before pausing. Omitted or zero disables idle expiry. */
|
|
325
|
+
idleTtlSeconds?: number;
|
|
308
326
|
/** Maximum concurrently attached exec sessions. Detached processes and one-shot controls do not count. */
|
|
309
327
|
maxConcurrentExecs?: number;
|
|
310
328
|
/** Creation-time network policy. Egress is unrestricted when omitted. */
|
|
311
329
|
network?: SandboxNetwork;
|
|
330
|
+
/** TCP ports to expose publicly, from 1 to 65535. */
|
|
331
|
+
ports?: number[];
|
|
312
332
|
}
|
|
313
333
|
interface ListSandboxesOptions {
|
|
314
334
|
/** Only return sandboxes that mount this disk. */
|
|
@@ -565,4 +585,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
565
585
|
*/
|
|
566
586
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
567
587
|
//#endregion
|
|
568
|
-
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(() => {
|
|
@@ -1799,13 +1843,13 @@ var Sandbox = class Sandbox {
|
|
|
1799
1843
|
baseImage;
|
|
1800
1844
|
platform;
|
|
1801
1845
|
maxTtlSeconds;
|
|
1846
|
+
idleTtlSeconds;
|
|
1802
1847
|
maxConcurrentExecs;
|
|
1803
1848
|
endpoints;
|
|
1804
1849
|
createdAt;
|
|
1805
1850
|
runningAt;
|
|
1806
1851
|
finishedAt;
|
|
1807
1852
|
lastActiveAt;
|
|
1808
|
-
expiresAt;
|
|
1809
1853
|
exitReason;
|
|
1810
1854
|
processes;
|
|
1811
1855
|
files;
|
|
@@ -1828,13 +1872,13 @@ var Sandbox = class Sandbox {
|
|
|
1828
1872
|
this.baseImage = data.base_image;
|
|
1829
1873
|
this.platform = data.platform;
|
|
1830
1874
|
this.maxTtlSeconds = data.max_ttl_seconds;
|
|
1875
|
+
this.idleTtlSeconds = data.idle_ttl_seconds ?? 0;
|
|
1831
1876
|
this.maxConcurrentExecs = data.max_concurrent_execs;
|
|
1832
1877
|
this.endpoints = data.endpoints?.map((endpoint) => ({ ...endpoint }));
|
|
1833
1878
|
this.createdAt = new Date(data.created_at);
|
|
1834
1879
|
this.runningAt = data.running_at ? new Date(data.running_at) : void 0;
|
|
1835
1880
|
this.finishedAt = data.finished_at ? new Date(data.finished_at) : void 0;
|
|
1836
1881
|
this.lastActiveAt = new Date(data.last_active_at);
|
|
1837
|
-
this.expiresAt = data.expires_at ? new Date(data.expires_at) : void 0;
|
|
1838
1882
|
this.exitReason = data.exit_reason;
|
|
1839
1883
|
return this;
|
|
1840
1884
|
}
|
|
@@ -1848,13 +1892,13 @@ var Sandbox = class Sandbox {
|
|
|
1848
1892
|
baseImage: this.baseImage,
|
|
1849
1893
|
platform: this.platform,
|
|
1850
1894
|
maxTtlSeconds: this.maxTtlSeconds,
|
|
1895
|
+
idleTtlSeconds: this.idleTtlSeconds,
|
|
1851
1896
|
maxConcurrentExecs: this.maxConcurrentExecs,
|
|
1852
1897
|
endpoints: this.endpoints?.map((endpoint) => ({ ...endpoint })),
|
|
1853
1898
|
createdAt: this.createdAt,
|
|
1854
1899
|
runningAt: this.runningAt,
|
|
1855
1900
|
finishedAt: this.finishedAt,
|
|
1856
1901
|
lastActiveAt: this.lastActiveAt,
|
|
1857
|
-
expiresAt: this.expiresAt,
|
|
1858
1902
|
exitReason: this.exitReason
|
|
1859
1903
|
};
|
|
1860
1904
|
}
|
|
@@ -1909,6 +1953,27 @@ var Sandbox = class Sandbox {
|
|
|
1909
1953
|
const fork = new Sandbox(data, this._client);
|
|
1910
1954
|
return options.wait === false ? fork : waitForSandboxStart(fork);
|
|
1911
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
|
+
}
|
|
1912
1977
|
/** Get this running sandbox's effective network policy. */
|
|
1913
1978
|
async getNetwork() {
|
|
1914
1979
|
const client = this._client;
|
|
@@ -1922,6 +1987,19 @@ var Sandbox = class Sandbox {
|
|
|
1922
1987
|
body: network
|
|
1923
1988
|
}), "transient"));
|
|
1924
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
|
+
}
|
|
1925
2003
|
/** Delete this sandbox and its backing disk. */
|
|
1926
2004
|
async delete() {
|
|
1927
2005
|
await unwrapEmpty(retryApiRequest(() => this._client.DELETE("/api/sandboxes/{sid}", { params: { path: { sid: this.id } } }), "transient"));
|
|
@@ -1963,8 +2041,10 @@ var Sandboxes = class {
|
|
|
1963
2041
|
base_image: request.baseImage,
|
|
1964
2042
|
env: request.env,
|
|
1965
2043
|
max_ttl_seconds: request.maxTtlSeconds,
|
|
2044
|
+
idle_ttl_seconds: request.idleTtlSeconds,
|
|
1966
2045
|
max_concurrent_execs: request.maxConcurrentExecs,
|
|
1967
|
-
network: request.network
|
|
2046
|
+
network: request.network,
|
|
2047
|
+
ports: request.ports
|
|
1968
2048
|
};
|
|
1969
2049
|
const sandbox = new Sandbox(await unwrap(retryApiRequest(() => this._client.POST("/api/sandboxes", {
|
|
1970
2050
|
params: { query: { wait: options.wait ?? true } },
|