ppio-sandbox 2.1.2 → 2.1.4-a2
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-3OWF5GCM.mjs → chunk-2B6TN3O4.mjs} +2 -2
- package/dist/{chunk-PQGBLWKQ.mjs → chunk-DKWK5NRD.mjs} +117 -53
- package/dist/chunk-DKWK5NRD.mjs.map +1 -0
- package/dist/{chunk-3L3K3WO3.mjs → chunk-MR23WSI2.mjs} +2 -2
- package/dist/code-interpreter.d.mts +2 -2
- package/dist/code-interpreter.d.ts +2 -2
- package/dist/code-interpreter.js +115 -51
- package/dist/code-interpreter.js.map +1 -1
- package/dist/code-interpreter.mjs +2 -2
- package/dist/desktop.d.mts +1 -1
- package/dist/desktop.d.ts +1 -1
- package/dist/desktop.js +115 -51
- package/dist/desktop.js.map +1 -1
- package/dist/desktop.mjs +2 -2
- package/dist/{index-CAD08VLb.d.mts → index-DIHU8MXT.d.mts} +164 -4
- package/dist/{index-CAD08VLb.d.ts → index-DIHU8MXT.d.ts} +164 -4
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +115 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/sandbox-3WKRVKUL.mjs +8 -0
- package/dist/sandbox-AGCVAX7T.mjs +8 -0
- package/package.json +1 -1
- package/dist/chunk-PQGBLWKQ.mjs.map +0 -1
- package/dist/sandbox-DMY2YDSO.mjs +0 -8
- package/dist/sandbox-TS3DDCSN.mjs +0 -8
- /package/dist/{chunk-3OWF5GCM.mjs.map → chunk-2B6TN3O4.mjs.map} +0 -0
- /package/dist/{chunk-3L3K3WO3.mjs.map → chunk-MR23WSI2.mjs.map} +0 -0
- /package/dist/{sandbox-DMY2YDSO.mjs.map → sandbox-3WKRVKUL.mjs.map} +0 -0
- /package/dist/{sandbox-TS3DDCSN.mjs.map → sandbox-AGCVAX7T.mjs.map} +0 -0
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
__forAwait,
|
|
10
10
|
__spreadProps,
|
|
11
11
|
__spreadValues
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-DKWK5NRD.mjs";
|
|
13
13
|
|
|
14
14
|
// src/code-interpreter/messaging.ts
|
|
15
15
|
async function extractError(res) {
|
|
@@ -465,4 +465,4 @@ Sandbox2.defaultTemplate = "code-interpreter-v1";
|
|
|
465
465
|
export {
|
|
466
466
|
Sandbox2 as Sandbox
|
|
467
467
|
};
|
|
468
|
-
//# sourceMappingURL=chunk-
|
|
468
|
+
//# sourceMappingURL=chunk-MR23WSI2.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { br as Sandbox } from './index-DIHU8MXT.mjs';
|
|
2
|
+
export { ak as ALL_TRAFFIC, A as ApiClient, b as AuthenticationError, bH as BarChart, bI as BarData, bL as BoxAndWhiskerChart, bM as BoxAndWhiskerData, B as BuildError, b7 as BuildInfo, b8 as BuildOptions, b9 as BuildStatusReason, bG as Chart, bE as ChartType, bF as ChartTypes, bv as CodeContextRequestOpts, an as CommandConnectOpts, u as CommandExitError, z as CommandHandle, am as CommandRequestOpts, v as CommandResult, ao as CommandStartOpts, ap as Commands, C as ConnectionConfig, a as ConnectionOpts, bs as Context, ba as CopyItem, bu as CreateCodeContextOpts, E as EntryInfo, bz as Execution, bx as ExecutionError, F as FileNotFoundError, m as FileType, i as FileUploadError, n as Filesystem, s as FilesystemEvent, r as FilesystemEventType, q as FilesystemReadOpts, o as FilesystemWriteOpts, bb as GetBuildStatusOptions, ar as Git, ax as GitAddOpts, G as GitAuthError, aE as GitBranches, at as GitCloneOpts, aw as GitCommitOpts, aC as GitConfigOpts, aD as GitConfigScope, aB as GitDangerouslyAuthenticateOpts, ay as GitDeleteBranchOpts, aF as GitFileStatus, au as GitInitOpts, aA as GitPullOpts, az as GitPushOpts, av as GitRemoteAddOpts, as as GitRequestOpts, aG as GitStatus, d as GitUpstreamError, aY as ImageConfig, j as ImageConfigError, bp as ImageConfigFailureMode, I as InvalidArgumentError, bJ as LineChart, aT as LogEntry, aV as LogEntryEnd, aW as LogEntryLevel, aU as LogEntryStart, L as Logger, bw as Logs, bA as MIMEType, aj as McpServer, bc as McpServerName, N as NotEnoughSpaceError, e as NotFoundError, bC as OutputMessage, P as PPIO, bN as PieChart, bO as PieData, bQ as PointData, al as ProcessInfo, aq as Pty, y as PtyOutput, R as RateLimitError, bB as RawData, aN as ReadyCmd, aZ as RegistryCredentials, bq as RegistryDispatcher, J as ResizeResult, H as Resources, by as Result, bt as RunCodeOpts, O as SandboxApiOpts, X as SandboxBetaCreateOpts, Z as SandboxCloneOpts, _ as SandboxCloneResult, $ as SandboxCommitOpts, a0 as SandboxCommitResult, Q as SandboxConnectOpts, f as SandboxError, ag as SandboxEventItem, ah as SandboxEventsOpts, ai as SandboxEventsResult, D as SandboxInfo, a8 as SandboxInfoLifecycle, a7 as SandboxLifecycle, a3 as SandboxListOpts, K as SandboxMetrics, Y as SandboxMetricsOpts, a5 as SandboxNetworkOpts, a6 as SandboxNetworkUpdateOpts, g as SandboxNotFoundError, M as SandboxOpts, a4 as SandboxPaginator, ac as SandboxQuota, ad as SandboxQuotaLimit, af as SandboxQuotaOpts, ae as SandboxQuotaUsage, a1 as SandboxResetOpts, a2 as SandboxState, bD as ScaleType, bK as ScatterChart, aK as Secret, aL as SecretBinding, k as SecretError, aM as SecretWriteParams, a9 as SnapshotInfo, aa as SnapshotListOpts, ab as SnapshotPaginator, x as Stderr, w as Stdout, bP as SuperChart, b6 as Template, b3 as TemplateApi, b5 as TemplateBase, be as TemplateBuildStatus, bf as TemplateBuildStatusResponse, bd as TemplateBuilder, bg as TemplateClass, bh as TemplateDeleteOpts, T as TemplateError, bi as TemplateInfo, bk as TemplateListOptions, bj as TemplateListOpts, bl as TemplateListResponse, b4 as TemplatePaginator, bm as TemplateTag, bn as TemplateTagInfo, bo as TemplateType, h as TimeoutError, U as Username, aH as Volume, aJ as VolumeAndToken, V as VolumeError, aI as VolumeInfo, t as WatchHandle, W as WriteInfo, a_ as clearImageConfigCache, c as components, aX as defaultBuildLogger, a$ as effectiveStartCmd, b0 as fetchImageConfig, l as getSignature, b1 as parseImageRef, p as paths, b2 as unsupportedBase, aR as waitForFile, aO as waitForPort, aQ as waitForProcess, aS as waitForTimeout, aP as waitForURL } from './index-DIHU8MXT.mjs';
|
|
3
3
|
import 'openapi-fetch';
|
|
4
4
|
import 'node:fs';
|
|
5
5
|
import '@connectrpc/connect';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { br as Sandbox } from './index-DIHU8MXT.js';
|
|
2
|
+
export { ak as ALL_TRAFFIC, A as ApiClient, b as AuthenticationError, bH as BarChart, bI as BarData, bL as BoxAndWhiskerChart, bM as BoxAndWhiskerData, B as BuildError, b7 as BuildInfo, b8 as BuildOptions, b9 as BuildStatusReason, bG as Chart, bE as ChartType, bF as ChartTypes, bv as CodeContextRequestOpts, an as CommandConnectOpts, u as CommandExitError, z as CommandHandle, am as CommandRequestOpts, v as CommandResult, ao as CommandStartOpts, ap as Commands, C as ConnectionConfig, a as ConnectionOpts, bs as Context, ba as CopyItem, bu as CreateCodeContextOpts, E as EntryInfo, bz as Execution, bx as ExecutionError, F as FileNotFoundError, m as FileType, i as FileUploadError, n as Filesystem, s as FilesystemEvent, r as FilesystemEventType, q as FilesystemReadOpts, o as FilesystemWriteOpts, bb as GetBuildStatusOptions, ar as Git, ax as GitAddOpts, G as GitAuthError, aE as GitBranches, at as GitCloneOpts, aw as GitCommitOpts, aC as GitConfigOpts, aD as GitConfigScope, aB as GitDangerouslyAuthenticateOpts, ay as GitDeleteBranchOpts, aF as GitFileStatus, au as GitInitOpts, aA as GitPullOpts, az as GitPushOpts, av as GitRemoteAddOpts, as as GitRequestOpts, aG as GitStatus, d as GitUpstreamError, aY as ImageConfig, j as ImageConfigError, bp as ImageConfigFailureMode, I as InvalidArgumentError, bJ as LineChart, aT as LogEntry, aV as LogEntryEnd, aW as LogEntryLevel, aU as LogEntryStart, L as Logger, bw as Logs, bA as MIMEType, aj as McpServer, bc as McpServerName, N as NotEnoughSpaceError, e as NotFoundError, bC as OutputMessage, P as PPIO, bN as PieChart, bO as PieData, bQ as PointData, al as ProcessInfo, aq as Pty, y as PtyOutput, R as RateLimitError, bB as RawData, aN as ReadyCmd, aZ as RegistryCredentials, bq as RegistryDispatcher, J as ResizeResult, H as Resources, by as Result, bt as RunCodeOpts, O as SandboxApiOpts, X as SandboxBetaCreateOpts, Z as SandboxCloneOpts, _ as SandboxCloneResult, $ as SandboxCommitOpts, a0 as SandboxCommitResult, Q as SandboxConnectOpts, f as SandboxError, ag as SandboxEventItem, ah as SandboxEventsOpts, ai as SandboxEventsResult, D as SandboxInfo, a8 as SandboxInfoLifecycle, a7 as SandboxLifecycle, a3 as SandboxListOpts, K as SandboxMetrics, Y as SandboxMetricsOpts, a5 as SandboxNetworkOpts, a6 as SandboxNetworkUpdateOpts, g as SandboxNotFoundError, M as SandboxOpts, a4 as SandboxPaginator, ac as SandboxQuota, ad as SandboxQuotaLimit, af as SandboxQuotaOpts, ae as SandboxQuotaUsage, a1 as SandboxResetOpts, a2 as SandboxState, bD as ScaleType, bK as ScatterChart, aK as Secret, aL as SecretBinding, k as SecretError, aM as SecretWriteParams, a9 as SnapshotInfo, aa as SnapshotListOpts, ab as SnapshotPaginator, x as Stderr, w as Stdout, bP as SuperChart, b6 as Template, b3 as TemplateApi, b5 as TemplateBase, be as TemplateBuildStatus, bf as TemplateBuildStatusResponse, bd as TemplateBuilder, bg as TemplateClass, bh as TemplateDeleteOpts, T as TemplateError, bi as TemplateInfo, bk as TemplateListOptions, bj as TemplateListOpts, bl as TemplateListResponse, b4 as TemplatePaginator, bm as TemplateTag, bn as TemplateTagInfo, bo as TemplateType, h as TimeoutError, U as Username, aH as Volume, aJ as VolumeAndToken, V as VolumeError, aI as VolumeInfo, t as WatchHandle, W as WriteInfo, a_ as clearImageConfigCache, c as components, aX as defaultBuildLogger, a$ as effectiveStartCmd, b0 as fetchImageConfig, l as getSignature, b1 as parseImageRef, p as paths, b2 as unsupportedBase, aR as waitForFile, aO as waitForPort, aQ as waitForProcess, aS as waitForTimeout, aP as waitForURL } from './index-DIHU8MXT.js';
|
|
3
3
|
import 'openapi-fetch';
|
|
4
4
|
import 'node:fs';
|
|
5
5
|
import '@connectrpc/connect';
|
package/dist/code-interpreter.js
CHANGED
|
@@ -80,7 +80,7 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
|
|
|
80
80
|
var version;
|
|
81
81
|
var init_package = __esm({
|
|
82
82
|
"package.json"() {
|
|
83
|
-
version = "2.1.
|
|
83
|
+
version = "2.1.4-a2";
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
|
|
@@ -3142,11 +3142,14 @@ var init_secret = __esm({
|
|
|
3142
3142
|
|
|
3143
3143
|
// src/core/sandbox/sandboxApi.ts
|
|
3144
3144
|
async function createRawApiError(response) {
|
|
3145
|
-
var _a3;
|
|
3145
|
+
var _a3, _b, _c;
|
|
3146
3146
|
let message = response.statusText;
|
|
3147
3147
|
try {
|
|
3148
3148
|
const body = await response.json();
|
|
3149
3149
|
message = (_a3 = body == null ? void 0 : body.message) != null ? _a3 : JSON.stringify(body);
|
|
3150
|
+
if ((body == null ? void 0 : body.item) || (body == null ? void 0 : body.reason)) {
|
|
3151
|
+
message = `${(_b = body.item) != null ? _b : "request"}: ${(_c = body.reason) != null ? _c : "error"}: ${message}`;
|
|
3152
|
+
}
|
|
3150
3153
|
} catch (e) {
|
|
3151
3154
|
try {
|
|
3152
3155
|
message = await response.text();
|
|
@@ -3168,6 +3171,50 @@ async function createRawApiError(response) {
|
|
|
3168
3171
|
function getRawApiHeaders(config, headers) {
|
|
3169
3172
|
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultHeaders), config.apiKey ? { "X-API-KEY": config.apiKey } : {}), config.accessToken ? { Authorization: `Bearer ${config.accessToken}` } : {}), config.headers), headers != null ? headers : {});
|
|
3170
3173
|
}
|
|
3174
|
+
function gibToMib(value, name) {
|
|
3175
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
3176
|
+
throw new SandboxError(`resource target ${name} must be a positive number`);
|
|
3177
|
+
}
|
|
3178
|
+
const mib = value * MIB_PER_GIB;
|
|
3179
|
+
if (!Number.isSafeInteger(mib)) {
|
|
3180
|
+
throw new SandboxError(`resource target ${name} must be an exact number of MiB`);
|
|
3181
|
+
}
|
|
3182
|
+
return mib;
|
|
3183
|
+
}
|
|
3184
|
+
function resourceTargetsToApi(resources) {
|
|
3185
|
+
const unknown = Object.keys(resources != null ? resources : {}).filter(
|
|
3186
|
+
(key) => !["cpu", "memoryGiB", "diskGiB"].includes(key)
|
|
3187
|
+
);
|
|
3188
|
+
if (unknown.length) throw new SandboxError(`unsupported resource field: ${unknown.join(", ")}`);
|
|
3189
|
+
const body = {};
|
|
3190
|
+
const { cpu, memoryGiB, diskGiB } = resources != null ? resources : {};
|
|
3191
|
+
if (cpu !== void 0) {
|
|
3192
|
+
if (!Number.isSafeInteger(cpu) || cpu <= 0) {
|
|
3193
|
+
throw new SandboxError("resource target cpu must be a positive whole number");
|
|
3194
|
+
}
|
|
3195
|
+
body.vcpu = cpu;
|
|
3196
|
+
}
|
|
3197
|
+
if (memoryGiB !== void 0) body.memory_mb = gibToMib(memoryGiB, "memoryGiB");
|
|
3198
|
+
if (diskGiB !== void 0) body.disk_size_mb = gibToMib(diskGiB, "diskGiB");
|
|
3199
|
+
if (!Object.keys(body).length) throw new SandboxError("at least one resource target is required");
|
|
3200
|
+
return body;
|
|
3201
|
+
}
|
|
3202
|
+
function resizeResultFromApi(data) {
|
|
3203
|
+
var _a3, _b, _c;
|
|
3204
|
+
const result = {};
|
|
3205
|
+
for (const key of ["cpu", "memory", "disk"]) {
|
|
3206
|
+
const item = data == null ? void 0 : data[key];
|
|
3207
|
+
if (!item) continue;
|
|
3208
|
+
const divisor = key === "cpu" ? 1 : 1024;
|
|
3209
|
+
result[key] = __spreadProps(__spreadValues({}, item), {
|
|
3210
|
+
requested: ((_a3 = item.requested) != null ? _a3 : 0) / divisor,
|
|
3211
|
+
previous: ((_b = item.previous) != null ? _b : 0) / divisor,
|
|
3212
|
+
current: ((_c = item.current) != null ? _c : 0) / divisor,
|
|
3213
|
+
unit: key === "cpu" ? "cores" : "GiB"
|
|
3214
|
+
});
|
|
3215
|
+
}
|
|
3216
|
+
return result;
|
|
3217
|
+
}
|
|
3171
3218
|
function getLifecycle(opts) {
|
|
3172
3219
|
if (opts == null ? void 0 : opts.lifecycle) {
|
|
3173
3220
|
return opts.lifecycle;
|
|
@@ -3183,7 +3230,7 @@ function getLifecycle(opts) {
|
|
|
3183
3230
|
autoResume: false
|
|
3184
3231
|
};
|
|
3185
3232
|
}
|
|
3186
|
-
var import_compare_versions4, SandboxApi, BasePaginator, SandboxPaginator, SnapshotPaginator;
|
|
3233
|
+
var import_compare_versions4, MIB_PER_GIB, SandboxApi, BasePaginator, SandboxPaginator, SnapshotPaginator;
|
|
3187
3234
|
var init_sandboxApi = __esm({
|
|
3188
3235
|
"src/core/sandbox/sandboxApi.ts"() {
|
|
3189
3236
|
"use strict";
|
|
@@ -3194,6 +3241,7 @@ var init_sandboxApi = __esm({
|
|
|
3194
3241
|
init_utils();
|
|
3195
3242
|
init_metadata();
|
|
3196
3243
|
init_secret();
|
|
3244
|
+
MIB_PER_GIB = 1024;
|
|
3197
3245
|
SandboxApi = class {
|
|
3198
3246
|
constructor() {
|
|
3199
3247
|
}
|
|
@@ -3376,28 +3424,24 @@ var init_sandboxApi = __esm({
|
|
|
3376
3424
|
templateType: "snapshot_template"
|
|
3377
3425
|
};
|
|
3378
3426
|
}
|
|
3379
|
-
static async
|
|
3427
|
+
static async resize(sandboxId, resources, opts) {
|
|
3428
|
+
const body = resourceTargetsToApi(resources);
|
|
3380
3429
|
const config = new ConnectionConfig(opts);
|
|
3381
|
-
raiseIfLegacy(config, "Sandbox.
|
|
3430
|
+
raiseIfLegacy(config, "Sandbox.resize", SandboxError);
|
|
3382
3431
|
const response = await fetch(
|
|
3383
|
-
`${config.apiUrl}/sandboxes/${encodeURIComponent(sandboxId)}/
|
|
3432
|
+
`${config.apiUrl}/sandboxes/${encodeURIComponent(sandboxId)}/resize`,
|
|
3384
3433
|
{
|
|
3385
3434
|
method: "POST",
|
|
3386
|
-
headers: getRawApiHeaders(config, {
|
|
3387
|
-
|
|
3388
|
-
}),
|
|
3389
|
-
body: JSON.stringify({
|
|
3390
|
-
requested_size_mib: requestedSizeMib
|
|
3391
|
-
}),
|
|
3435
|
+
headers: getRawApiHeaders(config, { "Content-Type": "application/json" }),
|
|
3436
|
+
body: JSON.stringify(body),
|
|
3392
3437
|
signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
|
|
3393
3438
|
}
|
|
3394
3439
|
);
|
|
3395
3440
|
if (response.status === 404) {
|
|
3396
3441
|
throw new SandboxNotFoundError(`Sandbox ${sandboxId} not found`);
|
|
3397
3442
|
}
|
|
3398
|
-
if (!response.ok)
|
|
3399
|
-
|
|
3400
|
-
}
|
|
3443
|
+
if (!response.ok) throw await createRawApiError(response);
|
|
3444
|
+
return resizeResultFromApi(await response.json());
|
|
3401
3445
|
}
|
|
3402
3446
|
static async reset(sandboxId, opts) {
|
|
3403
3447
|
var _a3;
|
|
@@ -3495,7 +3539,7 @@ var init_sandboxApi = __esm({
|
|
|
3495
3539
|
throw await createRawApiError(response);
|
|
3496
3540
|
}
|
|
3497
3541
|
const data = await response.json();
|
|
3498
|
-
return {
|
|
3542
|
+
return __spreadProps(__spreadValues({
|
|
3499
3543
|
sandboxId: data.sandboxID,
|
|
3500
3544
|
templateId: data.templateID,
|
|
3501
3545
|
name: data.name,
|
|
@@ -3504,10 +3548,11 @@ var init_sandboxApi = __esm({
|
|
|
3504
3548
|
endAt: new Date(data.endAt),
|
|
3505
3549
|
state: data.state,
|
|
3506
3550
|
cpuCount: data.cpuCount,
|
|
3507
|
-
memoryMB: data.memoryMB
|
|
3551
|
+
memoryMB: data.memoryMB
|
|
3552
|
+
}, data.diskSizeMB !== void 0 ? { diskSizeMB: data.diskSizeMB } : {}), {
|
|
3508
3553
|
envdVersion: data.envdVersion,
|
|
3509
3554
|
volumeMounts: (_b = data.volumeMounts) != null ? _b : []
|
|
3510
|
-
};
|
|
3555
|
+
});
|
|
3511
3556
|
}
|
|
3512
3557
|
static async setNetwork(sandboxId, opts) {
|
|
3513
3558
|
const config = new ConnectionConfig(opts);
|
|
@@ -3621,6 +3666,7 @@ var init_sandboxApi = __esm({
|
|
|
3621
3666
|
state: res.data.state,
|
|
3622
3667
|
cpuCount: res.data.cpuCount,
|
|
3623
3668
|
memoryMB: res.data.memoryMB,
|
|
3669
|
+
diskSizeMB: res.data.diskSizeMB,
|
|
3624
3670
|
network: res.data.network ? {
|
|
3625
3671
|
allowOut: res.data.network.allowOut,
|
|
3626
3672
|
denyOut: res.data.network.denyOut,
|
|
@@ -3773,7 +3819,7 @@ var init_sandboxApi = __esm({
|
|
|
3773
3819
|
return true;
|
|
3774
3820
|
}
|
|
3775
3821
|
static async createSandbox(template, timeoutMs, opts) {
|
|
3776
|
-
var _a3, _b, _c, _d, _e, _f, _g;
|
|
3822
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h;
|
|
3777
3823
|
const config = new ConnectionConfig(opts);
|
|
3778
3824
|
const longRunning = ((_a3 = opts == null ? void 0 : opts.metadata) == null ? void 0 : _a3.long_running) === "true";
|
|
3779
3825
|
const metadata = longRunning ? __spreadValues({}, opts == null ? void 0 : opts.metadata) : opts == null ? void 0 : opts.metadata;
|
|
@@ -3799,6 +3845,9 @@ var init_sandboxApi = __esm({
|
|
|
3799
3845
|
if (opts == null ? void 0 : opts.secretEnvs) {
|
|
3800
3846
|
raiseIfLegacy(config, "Sandbox.create secretEnvs", SandboxError);
|
|
3801
3847
|
}
|
|
3848
|
+
if (opts == null ? void 0 : opts.resources) {
|
|
3849
|
+
raiseIfLegacy(config, "Sandbox.create resources", SandboxError);
|
|
3850
|
+
}
|
|
3802
3851
|
const body2 = __spreadValues(__spreadValues({
|
|
3803
3852
|
templateID: template,
|
|
3804
3853
|
timeout,
|
|
@@ -3860,6 +3909,30 @@ var init_sandboxApi = __esm({
|
|
|
3860
3909
|
;
|
|
3861
3910
|
body.secrets = validatedSecretEnvs;
|
|
3862
3911
|
}
|
|
3912
|
+
if (opts == null ? void 0 : opts.resources) {
|
|
3913
|
+
const targets = resourceTargetsToApi(opts.resources);
|
|
3914
|
+
const response = await fetch(`${config.apiUrl}/sandboxes/custom`, {
|
|
3915
|
+
method: "POST",
|
|
3916
|
+
headers: getRawApiHeaders(config, { "Content-Type": "application/json" }),
|
|
3917
|
+
body: JSON.stringify(__spreadProps(__spreadValues({}, body), { resources: targets })),
|
|
3918
|
+
signal: config.getSignal((_h = opts == null ? void 0 : opts.requestTimeoutMs) != null ? _h : 36e4)
|
|
3919
|
+
});
|
|
3920
|
+
if (!response.ok) throw await createRawApiError(response);
|
|
3921
|
+
const data = await response.json();
|
|
3922
|
+
if ((0, import_compare_versions4.compareVersions)(data.envdVersion, "0.1.0") < 0) {
|
|
3923
|
+
await this.kill(data.sandboxID, opts);
|
|
3924
|
+
throw new TemplateError(
|
|
3925
|
+
"You need to update the template to use the new SDK. You can do this by running `ppio template build` in the directory with the template."
|
|
3926
|
+
);
|
|
3927
|
+
}
|
|
3928
|
+
return {
|
|
3929
|
+
sandboxId: data.sandboxID,
|
|
3930
|
+
sandboxDomain: data.domain || void 0,
|
|
3931
|
+
envdVersion: data.envdVersion,
|
|
3932
|
+
envdAccessToken: data.envdAccessToken,
|
|
3933
|
+
trafficAccessToken: data.trafficAccessToken || void 0
|
|
3934
|
+
};
|
|
3935
|
+
}
|
|
3863
3936
|
const res = await client.api.POST("/sandboxes", {
|
|
3864
3937
|
body,
|
|
3865
3938
|
signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
|
|
@@ -4081,7 +4154,7 @@ var init_sandboxApi = __esm({
|
|
|
4081
4154
|
const data = await response.json();
|
|
4082
4155
|
return (data != null ? data : []).map((sandbox) => {
|
|
4083
4156
|
var _a4, _b2;
|
|
4084
|
-
return __spreadProps(__spreadValues({
|
|
4157
|
+
return __spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
4085
4158
|
sandboxId: sandbox.clientID != null ? `${sandbox.sandboxID}-${sandbox.clientID}` : sandbox.sandboxID,
|
|
4086
4159
|
templateId: sandbox.templateID
|
|
4087
4160
|
}, sandbox.alias && { name: sandbox.alias }), {
|
|
@@ -4090,7 +4163,10 @@ var init_sandboxApi = __esm({
|
|
|
4090
4163
|
endAt: new Date(sandbox.endAt),
|
|
4091
4164
|
state: sandbox.state,
|
|
4092
4165
|
cpuCount: sandbox.cpuCount,
|
|
4093
|
-
memoryMB: sandbox.memoryMB
|
|
4166
|
+
memoryMB: sandbox.memoryMB
|
|
4167
|
+
}), sandbox.diskSizeMB !== void 0 && {
|
|
4168
|
+
diskSizeMB: sandbox.diskSizeMB
|
|
4169
|
+
}), {
|
|
4094
4170
|
envdVersion: sandbox.envdVersion,
|
|
4095
4171
|
volumeMounts: (_b2 = sandbox.volumeMounts) != null ? _b2 : []
|
|
4096
4172
|
});
|
|
@@ -4116,7 +4192,7 @@ var init_sandboxApi = __esm({
|
|
|
4116
4192
|
return ((_e = res.data) != null ? _e : []).map(
|
|
4117
4193
|
(sandbox) => {
|
|
4118
4194
|
var _a4, _b2;
|
|
4119
|
-
return __spreadProps(__spreadValues({
|
|
4195
|
+
return __spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
4120
4196
|
sandboxId: this.config.isLegacyDomain && sandbox.clientID != null ? `${sandbox.sandboxID}-${sandbox.clientID}` : sandbox.sandboxID,
|
|
4121
4197
|
templateId: sandbox.templateID
|
|
4122
4198
|
}, sandbox.alias && { name: sandbox.alias }), {
|
|
@@ -4125,7 +4201,10 @@ var init_sandboxApi = __esm({
|
|
|
4125
4201
|
endAt: new Date(sandbox.endAt),
|
|
4126
4202
|
state: sandbox.state,
|
|
4127
4203
|
cpuCount: sandbox.cpuCount,
|
|
4128
|
-
memoryMB: sandbox.memoryMB
|
|
4204
|
+
memoryMB: sandbox.memoryMB
|
|
4205
|
+
}), sandbox.diskSizeMB !== void 0 && {
|
|
4206
|
+
diskSizeMB: sandbox.diskSizeMB
|
|
4207
|
+
}), {
|
|
4129
4208
|
envdVersion: sandbox.envdVersion,
|
|
4130
4209
|
volumeMounts: (_b2 = sandbox.volumeMounts) != null ? _b2 : []
|
|
4131
4210
|
});
|
|
@@ -4373,19 +4452,6 @@ var init_sandbox = __esm({
|
|
|
4373
4452
|
snapshotTemplateId: cloneResult.snapshotTemplateId
|
|
4374
4453
|
};
|
|
4375
4454
|
}
|
|
4376
|
-
/**
|
|
4377
|
-
* Dynamically adjust the hotplugged memory on a running sandbox.
|
|
4378
|
-
*
|
|
4379
|
-
* The value represents the new *total* plugged size in MiB, not a delta.
|
|
4380
|
-
* Use `0` to unplug all hotplugged memory.
|
|
4381
|
-
*/
|
|
4382
|
-
static async hotplugMemory(sandboxId, requestedSizeMib, opts) {
|
|
4383
|
-
return await SandboxApi.hotplugMemory(
|
|
4384
|
-
sandboxId,
|
|
4385
|
-
requestedSizeMib,
|
|
4386
|
-
opts
|
|
4387
|
-
);
|
|
4388
|
-
}
|
|
4389
4455
|
/**
|
|
4390
4456
|
* Mount a volume to a sandbox.
|
|
4391
4457
|
*
|
|
@@ -4396,6 +4462,10 @@ var init_sandbox = __esm({
|
|
|
4396
4462
|
*
|
|
4397
4463
|
* @returns updated sandbox information.
|
|
4398
4464
|
*/
|
|
4465
|
+
/** Increase running sandbox resources to absolute CPU and GiB targets. */
|
|
4466
|
+
static async resize(sandboxId, resources, opts) {
|
|
4467
|
+
return await SandboxApi.resize(sandboxId, resources, opts);
|
|
4468
|
+
}
|
|
4399
4469
|
static async mountVolume(sandboxId, name, path3, opts) {
|
|
4400
4470
|
return await SandboxApi.mountVolume(sandboxId, name, path3, opts);
|
|
4401
4471
|
}
|
|
@@ -4680,21 +4750,9 @@ var init_sandbox = __esm({
|
|
|
4680
4750
|
}
|
|
4681
4751
|
await SandboxApi.kill(this.sandboxId, this.resolveApiOpts(opts));
|
|
4682
4752
|
}
|
|
4683
|
-
/**
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
* The value represents the new *total* plugged size in MiB, not a delta.
|
|
4687
|
-
* Use `0` to unplug all hotplugged memory.
|
|
4688
|
-
*
|
|
4689
|
-
* @param requestedSizeMib new total plugged memory size in MiB.
|
|
4690
|
-
* @param opts connection options.
|
|
4691
|
-
*/
|
|
4692
|
-
async hotplugMemory(requestedSizeMib, opts) {
|
|
4693
|
-
await SandboxApi.hotplugMemory(
|
|
4694
|
-
this.sandboxId,
|
|
4695
|
-
requestedSizeMib,
|
|
4696
|
-
this.resolveApiOpts(opts)
|
|
4697
|
-
);
|
|
4753
|
+
/** Increase this sandbox's resources to absolute CPU and GiB targets. */
|
|
4754
|
+
async resize(resources, opts) {
|
|
4755
|
+
return await SandboxApi.resize(this.sandboxId, resources, this.resolveApiOpts(opts));
|
|
4698
4756
|
}
|
|
4699
4757
|
/**
|
|
4700
4758
|
* Pause a sandbox by its ID.
|
|
@@ -9062,6 +9120,9 @@ var init_client = __esm({
|
|
|
9062
9120
|
getQuota(opts) {
|
|
9063
9121
|
return Sandbox.getQuota(mergeConnectionOpts(this.opts, opts));
|
|
9064
9122
|
}
|
|
9123
|
+
resize(sandboxId, resources, opts) {
|
|
9124
|
+
return Sandbox.resize(sandboxId, resources, mergeConnectionOpts(this.opts, opts));
|
|
9125
|
+
}
|
|
9065
9126
|
getEvents(opts) {
|
|
9066
9127
|
return Sandbox.getEvents(mergeConnectionOpts(this.opts, opts));
|
|
9067
9128
|
}
|
|
@@ -9149,6 +9210,9 @@ var init_client = __esm({
|
|
|
9149
9210
|
getQuota(opts) {
|
|
9150
9211
|
return Sandbox.getQuota(mergeConnectionOpts(this.opts, opts));
|
|
9151
9212
|
}
|
|
9213
|
+
resize(sandboxId, resources, opts) {
|
|
9214
|
+
return Sandbox.resize(sandboxId, resources, mergeConnectionOpts(this.opts, opts));
|
|
9215
|
+
}
|
|
9152
9216
|
getEvents(opts) {
|
|
9153
9217
|
return Sandbox.getEvents(mergeConnectionOpts(this.opts, opts));
|
|
9154
9218
|
}
|