ppio-sandbox 1.0.3-b1 → 1.0.3
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/dist/{chunk-MMBQNTJE.mjs → chunk-XBFDVBYI.mjs} +45 -115
- package/dist/chunk-XBFDVBYI.mjs.map +1 -0
- package/dist/code-interpreter.d.mts +2 -2
- package/dist/code-interpreter.d.ts +2 -2
- package/dist/code-interpreter.js +44 -114
- package/dist/code-interpreter.js.map +1 -1
- package/dist/code-interpreter.mjs +1 -1
- package/dist/desktop.d.mts +2 -2
- package/dist/desktop.d.ts +2 -2
- package/dist/desktop.js +44 -114
- package/dist/desktop.js.map +1 -1
- package/dist/desktop.mjs +1 -1
- package/dist/{index-CDYfIQCY.d.mts → index-DVtYWWe-.d.mts} +63 -74
- package/dist/{index-CDYfIQCY.d.ts → index-DVtYWWe-.d.ts} +63 -74
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +44 -114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-MMBQNTJE.mjs.map +0 -1
|
@@ -48,7 +48,7 @@ import createClient from "openapi-fetch";
|
|
|
48
48
|
import platform from "platform";
|
|
49
49
|
|
|
50
50
|
// package.json
|
|
51
|
-
var version = "1.0.3
|
|
51
|
+
var version = "1.0.3";
|
|
52
52
|
|
|
53
53
|
// src/core/api/metadata.ts
|
|
54
54
|
function getRuntime() {
|
|
@@ -258,7 +258,6 @@ var ApiClient = class {
|
|
|
258
258
|
|
|
259
259
|
// src/core/connectionConfig.ts
|
|
260
260
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
261
|
-
var REQUEST_LONG_TIMEOUT_MS = 3e5;
|
|
262
261
|
var DEFAULT_SANDBOX_TIMEOUT_MS = 3e5;
|
|
263
262
|
var KEEPALIVE_PING_INTERVAL_SEC = 50;
|
|
264
263
|
var KEEPALIVE_PING_HEADER = "Keepalive-Ping-Interval";
|
|
@@ -628,6 +627,9 @@ var Filesystem2 = class {
|
|
|
628
627
|
return new Uint8Array(res.data);
|
|
629
628
|
}
|
|
630
629
|
if (res.response.headers.get("content-length") === "0") {
|
|
630
|
+
if (format === "blob") {
|
|
631
|
+
return new Blob([]);
|
|
632
|
+
}
|
|
631
633
|
return "";
|
|
632
634
|
}
|
|
633
635
|
return res.data;
|
|
@@ -1666,7 +1668,7 @@ var SandboxApi = class {
|
|
|
1666
1668
|
* @returns `true` if the sandbox got paused, `false` if the sandbox was already paused.
|
|
1667
1669
|
*/
|
|
1668
1670
|
static async betaPause(sandboxId, opts) {
|
|
1669
|
-
var _a2, _b
|
|
1671
|
+
var _a2, _b;
|
|
1670
1672
|
const config = new ConnectionConfig(opts);
|
|
1671
1673
|
const client = new ApiClient(config);
|
|
1672
1674
|
const res = await client.api.POST("/sandboxes/{sandboxID}/pause", {
|
|
@@ -1675,15 +1677,12 @@ var SandboxApi = class {
|
|
|
1675
1677
|
sandboxID: sandboxId
|
|
1676
1678
|
}
|
|
1677
1679
|
},
|
|
1678
|
-
body: {
|
|
1679
|
-
sync: (_a2 = opts == null ? void 0 : opts.sync) != null ? _a2 : false
|
|
1680
|
-
},
|
|
1681
1680
|
signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
|
|
1682
1681
|
});
|
|
1683
|
-
if (((
|
|
1682
|
+
if (((_a2 = res.error) == null ? void 0 : _a2.code) === 404) {
|
|
1684
1683
|
throw new NotFoundError(`Sandbox ${sandboxId} not found`);
|
|
1685
1684
|
}
|
|
1686
|
-
if (((
|
|
1685
|
+
if (((_b = res.error) == null ? void 0 : _b.code) === 409) {
|
|
1687
1686
|
return false;
|
|
1688
1687
|
}
|
|
1689
1688
|
const err = handleApiError(res);
|
|
@@ -1692,56 +1691,6 @@ var SandboxApi = class {
|
|
|
1692
1691
|
}
|
|
1693
1692
|
return true;
|
|
1694
1693
|
}
|
|
1695
|
-
/**
|
|
1696
|
-
* Clone a sandbox to create multiple identical sandboxes.
|
|
1697
|
-
*
|
|
1698
|
-
* Note: This low-level API returns raw identifiers required to construct SDK instances.
|
|
1699
|
-
*
|
|
1700
|
-
* @param sandboxId sandbox ID.
|
|
1701
|
-
* @param opts clone options including count.
|
|
1702
|
-
*
|
|
1703
|
-
* @returns clone response with count and list of cloned sandboxes.
|
|
1704
|
-
*/
|
|
1705
|
-
static async cloneSandboxes(sandboxId, opts) {
|
|
1706
|
-
var _a2, _b, _c, _d;
|
|
1707
|
-
const config = new ConnectionConfig(opts);
|
|
1708
|
-
const client = new ApiClient(config);
|
|
1709
|
-
const res = await client.api.POST("/sandboxes/{sandboxID}/clone", {
|
|
1710
|
-
params: {
|
|
1711
|
-
path: {
|
|
1712
|
-
sandboxID: sandboxId
|
|
1713
|
-
}
|
|
1714
|
-
},
|
|
1715
|
-
body: __spreadValues({
|
|
1716
|
-
count: (_a2 = opts.count) != null ? _a2 : 1,
|
|
1717
|
-
nodeID: opts.nodeID,
|
|
1718
|
-
strict: (_b = opts.strict) != null ? _b : false
|
|
1719
|
-
}, typeof opts.timeoutMs === "number" ? { timeout: timeoutToSeconds(opts.timeoutMs) } : {}),
|
|
1720
|
-
// Use an extended timeout for clone operation by default
|
|
1721
|
-
signal: config.getSignal(
|
|
1722
|
-
(_c = opts == null ? void 0 : opts.requestTimeoutMs) != null ? _c : REQUEST_LONG_TIMEOUT_MS
|
|
1723
|
-
)
|
|
1724
|
-
});
|
|
1725
|
-
if (((_d = res.error) == null ? void 0 : _d.code) === 404) {
|
|
1726
|
-
throw new NotFoundError(`Sandbox ${sandboxId} not found`);
|
|
1727
|
-
}
|
|
1728
|
-
const err = handleApiError(res);
|
|
1729
|
-
if (err) {
|
|
1730
|
-
throw err;
|
|
1731
|
-
}
|
|
1732
|
-
if (!res.data) {
|
|
1733
|
-
throw new Error("Clone response data is missing");
|
|
1734
|
-
}
|
|
1735
|
-
const sandboxes = (res.data.sandboxes || []).map((sb) => ({
|
|
1736
|
-
sandboxId: `${sb.sandboxID}-${sb.clientID}`,
|
|
1737
|
-
envdVersion: sb.envdVersion,
|
|
1738
|
-
envdAccessToken: sb.envdAccessToken
|
|
1739
|
-
}));
|
|
1740
|
-
return {
|
|
1741
|
-
count: res.data.count,
|
|
1742
|
-
sandboxes
|
|
1743
|
-
};
|
|
1744
|
-
}
|
|
1745
1694
|
static async createSandbox(template, timeoutMs, opts) {
|
|
1746
1695
|
var _a2, _b;
|
|
1747
1696
|
const config = new ConnectionConfig(opts);
|
|
@@ -1755,8 +1704,7 @@ var SandboxApi = class {
|
|
|
1755
1704
|
timeout: timeoutToSeconds(timeoutMs),
|
|
1756
1705
|
secure: (_b = opts == null ? void 0 : opts.secure) != null ? _b : false,
|
|
1757
1706
|
// allow_internet_access: opts?.allowInternetAccess ?? true,
|
|
1758
|
-
allow_internet_access: true
|
|
1759
|
-
nodeID: opts == null ? void 0 : opts.nodeID
|
|
1707
|
+
allow_internet_access: true
|
|
1760
1708
|
},
|
|
1761
1709
|
signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
|
|
1762
1710
|
});
|
|
@@ -1807,6 +1755,39 @@ var SandboxApi = class {
|
|
|
1807
1755
|
}
|
|
1808
1756
|
return true;
|
|
1809
1757
|
}
|
|
1758
|
+
static async connectSandbox(sandboxId, opts) {
|
|
1759
|
+
var _a2, _b;
|
|
1760
|
+
const timeoutMs = (_a2 = opts == null ? void 0 : opts.timeoutMs) != null ? _a2 : DEFAULT_SANDBOX_TIMEOUT_MS;
|
|
1761
|
+
const config = new ConnectionConfig(opts);
|
|
1762
|
+
const client = new ApiClient(config);
|
|
1763
|
+
const res = await client.api.POST("/sandboxes/{sandboxID}/connect", {
|
|
1764
|
+
params: {
|
|
1765
|
+
path: {
|
|
1766
|
+
sandboxID: sandboxId
|
|
1767
|
+
}
|
|
1768
|
+
},
|
|
1769
|
+
body: {
|
|
1770
|
+
timeout: timeoutToSeconds(timeoutMs)
|
|
1771
|
+
},
|
|
1772
|
+
signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
|
|
1773
|
+
});
|
|
1774
|
+
if (((_b = res.error) == null ? void 0 : _b.code) === 404) {
|
|
1775
|
+
throw new NotFoundError(`Sandbox ${sandboxId} not found`);
|
|
1776
|
+
}
|
|
1777
|
+
const err = handleApiError(res);
|
|
1778
|
+
if (err) {
|
|
1779
|
+
throw err;
|
|
1780
|
+
}
|
|
1781
|
+
if (!res.data) {
|
|
1782
|
+
throw new Error("Sandbox not found");
|
|
1783
|
+
}
|
|
1784
|
+
return {
|
|
1785
|
+
sandboxId: `${res.data.sandboxID}-${res.data.clientID}`,
|
|
1786
|
+
envdVersion: res.data.envdVersion,
|
|
1787
|
+
envdAccessToken: res.data.envdAccessToken,
|
|
1788
|
+
sandboxDomain: void 0
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1810
1791
|
};
|
|
1811
1792
|
var SandboxPaginator = class {
|
|
1812
1793
|
constructor(opts) {
|
|
@@ -2011,58 +1992,15 @@ var Sandbox = class extends SandboxApi {
|
|
|
2011
1992
|
* ```
|
|
2012
1993
|
*/
|
|
2013
1994
|
static async connect(sandboxId, opts) {
|
|
2014
|
-
|
|
2015
|
-
await SandboxApi.setTimeout(
|
|
2016
|
-
sandboxId,
|
|
2017
|
-
(opts == null ? void 0 : opts.timeoutMs) || DEFAULT_SANDBOX_TIMEOUT_MS,
|
|
2018
|
-
opts
|
|
2019
|
-
);
|
|
2020
|
-
} catch (e) {
|
|
2021
|
-
if (e instanceof SandboxError) {
|
|
2022
|
-
await SandboxApi.resumeSandbox(sandboxId, opts);
|
|
2023
|
-
} else {
|
|
2024
|
-
throw e;
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
|
-
const info = await SandboxApi.getFullInfo(sandboxId, opts);
|
|
1995
|
+
const info = await SandboxApi.connectSandbox(sandboxId, opts);
|
|
2028
1996
|
const config = new ConnectionConfig(opts);
|
|
2029
1997
|
return new this(__spreadValues({
|
|
2030
|
-
sandboxId,
|
|
1998
|
+
sandboxId: info.sandboxId,
|
|
2031
1999
|
sandboxDomain: info.sandboxDomain,
|
|
2032
2000
|
envdAccessToken: info.envdAccessToken,
|
|
2033
2001
|
envdVersion: info.envdVersion
|
|
2034
2002
|
}, config));
|
|
2035
2003
|
}
|
|
2036
|
-
/**
|
|
2037
|
-
* Clone a sandbox to create multiple identical sandboxes.
|
|
2038
|
-
*
|
|
2039
|
-
* @param sandboxId sandbox ID.
|
|
2040
|
-
* @param count number of sandboxes to clone.
|
|
2041
|
-
* @param opts clone options.
|
|
2042
|
-
*
|
|
2043
|
-
* @returns clone response with count and list of cloned sandboxes.
|
|
2044
|
-
*
|
|
2045
|
-
* @example
|
|
2046
|
-
* ```ts
|
|
2047
|
-
* const cloneResponse = await Sandbox.clone('sandbox-id', {
|
|
2048
|
-
* count: 3,
|
|
2049
|
-
* strict: false
|
|
2050
|
-
* })
|
|
2051
|
-
* console.log(`Cloned ${cloneResponse.count} sandboxes`)
|
|
2052
|
-
* ```
|
|
2053
|
-
*/
|
|
2054
|
-
static async clone(sandboxId, opts) {
|
|
2055
|
-
const res = await SandboxApi.cloneSandboxes(sandboxId, opts);
|
|
2056
|
-
const instances = res.sandboxes.map((sb) => {
|
|
2057
|
-
const config = new ConnectionConfig(opts);
|
|
2058
|
-
return new this(__spreadValues({
|
|
2059
|
-
sandboxId: sb.sandboxId,
|
|
2060
|
-
envdVersion: sb.envdVersion,
|
|
2061
|
-
envdAccessToken: sb.envdAccessToken
|
|
2062
|
-
}, config));
|
|
2063
|
-
});
|
|
2064
|
-
return instances;
|
|
2065
|
-
}
|
|
2066
2004
|
/**
|
|
2067
2005
|
* Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.
|
|
2068
2006
|
* Sandbox must be either running or be paused.
|
|
@@ -2083,15 +2021,7 @@ var Sandbox = class extends SandboxApi {
|
|
|
2083
2021
|
* ```
|
|
2084
2022
|
*/
|
|
2085
2023
|
async connect(opts) {
|
|
2086
|
-
|
|
2087
|
-
await SandboxApi.setTimeout(
|
|
2088
|
-
this.sandboxId,
|
|
2089
|
-
(opts == null ? void 0 : opts.timeoutMs) || DEFAULT_SANDBOX_TIMEOUT_MS,
|
|
2090
|
-
opts
|
|
2091
|
-
);
|
|
2092
|
-
} catch (e) {
|
|
2093
|
-
await SandboxApi.resumeSandbox(this.sandboxId, opts);
|
|
2094
|
-
}
|
|
2024
|
+
await SandboxApi.connectSandbox(this.sandboxId, opts);
|
|
2095
2025
|
return this;
|
|
2096
2026
|
}
|
|
2097
2027
|
/**
|
|
@@ -2333,4 +2263,4 @@ export {
|
|
|
2333
2263
|
Sandbox,
|
|
2334
2264
|
core_default
|
|
2335
2265
|
};
|
|
2336
|
-
//# sourceMappingURL=chunk-
|
|
2266
|
+
//# sourceMappingURL=chunk-XBFDVBYI.mjs.map
|