disk 0.11.0 → 1.1.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 +67 -8
- package/dist/cli.mjs +16 -31
- package/dist/common-CIf8wLtI.mjs +306 -0
- package/dist/index.cjs +19 -111
- package/dist/index.d.cts +13 -57
- package/dist/index.d.mts +13 -57
- package/dist/index.mjs +2 -2
- package/dist/sandbox-cli.mjs +523 -0
- package/dist/{src-Cpv1TIWC.mjs → src-B_Vucedi.mjs} +20 -111
- package/package.json +8 -4
|
@@ -122,7 +122,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
|
|
|
122
122
|
}
|
|
123
123
|
//#endregion
|
|
124
124
|
//#region src/version.ts
|
|
125
|
-
const VERSION = "
|
|
125
|
+
const VERSION = "1.1.0";
|
|
126
126
|
const USER_AGENT = `archil-js/${VERSION}`;
|
|
127
127
|
//#endregion
|
|
128
128
|
//#region src/client.ts
|
|
@@ -1661,72 +1661,6 @@ const POLL_INTERVAL_MS = 500;
|
|
|
1661
1661
|
function sleep() {
|
|
1662
1662
|
return new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
1663
1663
|
}
|
|
1664
|
-
var SandboxExec = class {
|
|
1665
|
-
sandboxId;
|
|
1666
|
-
id;
|
|
1667
|
-
command;
|
|
1668
|
-
status;
|
|
1669
|
-
exitCode;
|
|
1670
|
-
stdout;
|
|
1671
|
-
stderr;
|
|
1672
|
-
exitReason;
|
|
1673
|
-
executeTimeMs;
|
|
1674
|
-
startedAt;
|
|
1675
|
-
finishedAt;
|
|
1676
|
-
/** @internal */
|
|
1677
|
-
_client;
|
|
1678
|
-
/** @internal */
|
|
1679
|
-
constructor(data, client) {
|
|
1680
|
-
this._client = client;
|
|
1681
|
-
this._apply(data);
|
|
1682
|
-
}
|
|
1683
|
-
/** @internal Overwrite this exec's fields in place from a fresh wire snapshot. */
|
|
1684
|
-
_apply(data) {
|
|
1685
|
-
this.sandboxId = data.sandbox_id;
|
|
1686
|
-
this.id = data.exec_id;
|
|
1687
|
-
this.command = data.command;
|
|
1688
|
-
this.status = data.status;
|
|
1689
|
-
this.exitCode = data.exit_code;
|
|
1690
|
-
this.stdout = data.stdout;
|
|
1691
|
-
this.stderr = data.stderr;
|
|
1692
|
-
this.exitReason = data.exit_reason;
|
|
1693
|
-
this.executeTimeMs = data.execute_time_ms;
|
|
1694
|
-
this.startedAt = new Date(data.started_at);
|
|
1695
|
-
this.finishedAt = data.finished_at ? new Date(data.finished_at) : void 0;
|
|
1696
|
-
return this;
|
|
1697
|
-
}
|
|
1698
|
-
toJSON() {
|
|
1699
|
-
return {
|
|
1700
|
-
sandboxId: this.sandboxId,
|
|
1701
|
-
id: this.id,
|
|
1702
|
-
command: this.command,
|
|
1703
|
-
status: this.status,
|
|
1704
|
-
exitCode: this.exitCode,
|
|
1705
|
-
stdout: this.stdout,
|
|
1706
|
-
stderr: this.stderr,
|
|
1707
|
-
exitReason: this.exitReason,
|
|
1708
|
-
executeTimeMs: this.executeTimeMs,
|
|
1709
|
-
startedAt: this.startedAt,
|
|
1710
|
-
finishedAt: this.finishedAt
|
|
1711
|
-
};
|
|
1712
|
-
}
|
|
1713
|
-
/** Re-fetch this exec and update it in place, returning the same object. */
|
|
1714
|
-
async refresh() {
|
|
1715
|
-
const data = await unwrap(this._client.GET("/api/sandboxes/{sid}/execs/{eid}", { params: { path: {
|
|
1716
|
-
sid: this.sandboxId,
|
|
1717
|
-
eid: this.id
|
|
1718
|
-
} } }));
|
|
1719
|
-
return this._apply(data);
|
|
1720
|
-
}
|
|
1721
|
-
/** Cancel this exec and update it in place, returning the same object. */
|
|
1722
|
-
async cancel() {
|
|
1723
|
-
const data = await unwrap(this._client.POST("/api/sandboxes/{sid}/execs/{eid}/cancel", { params: { path: {
|
|
1724
|
-
sid: this.sandboxId,
|
|
1725
|
-
eid: this.id
|
|
1726
|
-
} } }));
|
|
1727
|
-
return this._apply(data);
|
|
1728
|
-
}
|
|
1729
|
-
};
|
|
1730
1664
|
var Sandbox = class Sandbox {
|
|
1731
1665
|
id;
|
|
1732
1666
|
name;
|
|
@@ -1795,6 +1729,10 @@ var Sandbox = class Sandbox {
|
|
|
1795
1729
|
exitReason: this.exitReason
|
|
1796
1730
|
};
|
|
1797
1731
|
}
|
|
1732
|
+
/** Run a process and wait for it to exit. */
|
|
1733
|
+
async exec(command, options = {}) {
|
|
1734
|
+
return (await this.processes.start(command, options)).wait();
|
|
1735
|
+
}
|
|
1798
1736
|
/** Re-fetch this sandbox. */
|
|
1799
1737
|
async refresh() {
|
|
1800
1738
|
const data = await unwrap(this._client.GET("/api/sandboxes/{sid}", { params: { path: { sid: this.id } } }));
|
|
@@ -1842,53 +1780,23 @@ var Sandbox = class Sandbox {
|
|
|
1842
1780
|
const fork = new Sandbox(data, this._client);
|
|
1843
1781
|
return options.wait === false ? fork : waitForSandboxStart(fork);
|
|
1844
1782
|
}
|
|
1845
|
-
/**
|
|
1846
|
-
async
|
|
1847
|
-
const
|
|
1848
|
-
return {
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1783
|
+
/** Get this running sandbox's effective network policy. */
|
|
1784
|
+
async getNetwork() {
|
|
1785
|
+
const client = this._client;
|
|
1786
|
+
return unwrap(client.GET("/api/sandboxes/{sid}/network", { params: { path: { sid: this.id } } }));
|
|
1787
|
+
}
|
|
1788
|
+
/** Replace this running sandbox's complete network policy and return the effective policy. */
|
|
1789
|
+
async updateNetwork(network) {
|
|
1790
|
+
const client = this._client;
|
|
1791
|
+
return unwrap(client.PUT("/api/sandboxes/{sid}/network", {
|
|
1792
|
+
params: { path: { sid: this.id } },
|
|
1793
|
+
body: network
|
|
1794
|
+
}));
|
|
1852
1795
|
}
|
|
1853
1796
|
/** Delete this sandbox and its backing disk. */
|
|
1854
1797
|
async delete() {
|
|
1855
1798
|
await unwrapEmpty(this._client.DELETE("/api/sandboxes/{sid}", { params: { path: { sid: this.id } } }));
|
|
1856
1799
|
}
|
|
1857
|
-
async exec(command, options = {}) {
|
|
1858
|
-
const exec = new SandboxExec(await unwrap(this._client.POST("/api/sandboxes/{sid}/execs", {
|
|
1859
|
-
params: {
|
|
1860
|
-
path: { sid: this.id },
|
|
1861
|
-
query: { wait: options.wait ?? true }
|
|
1862
|
-
},
|
|
1863
|
-
body: {
|
|
1864
|
-
command,
|
|
1865
|
-
command_tty: options.commandTty,
|
|
1866
|
-
env: options.env,
|
|
1867
|
-
timeout_seconds: options.timeoutSeconds
|
|
1868
|
-
}
|
|
1869
|
-
})), this._client);
|
|
1870
|
-
if (options.wait === false) return exec;
|
|
1871
|
-
while (exec.status === "running") {
|
|
1872
|
-
await sleep();
|
|
1873
|
-
await exec.refresh();
|
|
1874
|
-
}
|
|
1875
|
-
return exec;
|
|
1876
|
-
}
|
|
1877
|
-
async listExecs() {
|
|
1878
|
-
return ((await unwrap(this._client.GET("/api/sandboxes/{sid}/execs", { params: { path: { sid: this.id } } })))?.execs ?? []).map((exec) => new SandboxExec(exec, this._client));
|
|
1879
|
-
}
|
|
1880
|
-
async getExec(execId) {
|
|
1881
|
-
return new SandboxExec(await unwrap(this._client.GET("/api/sandboxes/{sid}/execs/{eid}", { params: { path: {
|
|
1882
|
-
sid: this.id,
|
|
1883
|
-
eid: execId
|
|
1884
|
-
} } })), this._client);
|
|
1885
|
-
}
|
|
1886
|
-
async cancelExec(execId) {
|
|
1887
|
-
return new SandboxExec(await unwrap(this._client.POST("/api/sandboxes/{sid}/execs/{eid}/cancel", { params: { path: {
|
|
1888
|
-
sid: this.id,
|
|
1889
|
-
eid: execId
|
|
1890
|
-
} } })), this._client);
|
|
1891
|
-
}
|
|
1892
1800
|
};
|
|
1893
1801
|
/** @internal Continue waiting if the server returned before startup completed. */
|
|
1894
1802
|
async function waitForSandboxStart(sandbox) {
|
|
@@ -1926,7 +1834,8 @@ var Sandboxes = class {
|
|
|
1926
1834
|
base_image: request.baseImage,
|
|
1927
1835
|
env: request.env,
|
|
1928
1836
|
max_ttl_seconds: request.maxTtlSeconds,
|
|
1929
|
-
max_concurrent_execs: request.maxConcurrentExecs
|
|
1837
|
+
max_concurrent_execs: request.maxConcurrentExecs,
|
|
1838
|
+
network: request.network
|
|
1930
1839
|
};
|
|
1931
1840
|
const sandbox = new Sandbox(await unwrap(this._client.POST("/api/sandboxes", {
|
|
1932
1841
|
params: { query: { wait: options.wait ?? true } },
|
|
@@ -2327,4 +2236,4 @@ function workspace(mounts) {
|
|
|
2327
2236
|
return archil().workspace(mounts);
|
|
2328
2237
|
}
|
|
2329
2238
|
//#endregion
|
|
2330
|
-
export { ArchilS3Error as A,
|
|
2239
|
+
export { ArchilS3Error as A, DiskMultipart as C, REGION_URLS as D, VERSION as E, ArchilApiError as O, Disk as S, USER_AGENT as T, Sandbox as _, deleteApiKey as a, SandboxProcesses as b, getSandbox as c, listSandboxes as d, workspace as f, Sandboxes as g, Tokens as h, createSandbox as i, SandboxFileTransferError as j, ArchilError as k, listApiKeys as l, Workspace as m, createApiKey as n, exec as o, Archil as p, createDisk as r, getDisk as s, configure as t, listDisks as u, SandboxFiles as v, effectiveUploadPartSize as w, Disks as x, SandboxProcess as y };
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "disk",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Pure-JS client and
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Pure-JS client and CLIs for Archil disks and sandboxes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"archil",
|
|
7
7
|
"disk",
|
|
8
8
|
"filesystem",
|
|
9
|
+
"sandbox",
|
|
9
10
|
"cli"
|
|
10
11
|
],
|
|
11
12
|
"homepage": "https://archil.com",
|
|
@@ -30,7 +31,8 @@
|
|
|
30
31
|
}
|
|
31
32
|
},
|
|
32
33
|
"bin": {
|
|
33
|
-
"disk": "./dist/cli.mjs"
|
|
34
|
+
"disk": "./dist/cli.mjs",
|
|
35
|
+
"sandbox": "./dist/sandbox-cli.mjs"
|
|
34
36
|
},
|
|
35
37
|
"files": [
|
|
36
38
|
"dist",
|
|
@@ -38,10 +40,12 @@
|
|
|
38
40
|
"LICENSE"
|
|
39
41
|
],
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@archildata/api-types": "^0.0.
|
|
43
|
+
"@archildata/api-types": "^0.0.23",
|
|
44
|
+
"@clack/prompts": "^1.7.0",
|
|
42
45
|
"commander": "^14.0.3",
|
|
43
46
|
"fast-xml-parser": "^5.7.0",
|
|
44
47
|
"openapi-fetch": "^0.13.5",
|
|
48
|
+
"uuid": "^11.1.1",
|
|
45
49
|
"zod": "^4.4.3"
|
|
46
50
|
},
|
|
47
51
|
"devDependencies": {
|