ppio-sandbox 2.1.4-a3 → 2.1.4-a5
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 +12 -0
- package/dist/{chunk-T7TQRJIF.mjs → chunk-AQHUBXNH.mjs} +71 -41
- package/dist/chunk-AQHUBXNH.mjs.map +1 -0
- package/dist/{chunk-IXTFKE4C.mjs → chunk-WKKDKXBR.mjs} +2 -2
- package/dist/{chunk-HZOFRVBE.mjs → chunk-WWSTWNMU.mjs} +2 -2
- package/dist/code-interpreter.d.mts +2 -2
- package/dist/code-interpreter.d.ts +2 -2
- package/dist/code-interpreter.js +68 -38
- 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 +68 -38
- package/dist/desktop.js.map +1 -1
- package/dist/desktop.mjs +2 -2
- package/dist/{index-DIHU8MXT.d.mts → index-DrRiUbkb.d.mts} +9 -7
- package/dist/{index-DIHU8MXT.d.ts → index-DrRiUbkb.d.ts} +9 -7
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +68 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/sandbox-JISSVQIL.mjs +8 -0
- package/dist/sandbox-KCRK5IJD.mjs +8 -0
- package/package.json +1 -1
- package/dist/chunk-T7TQRJIF.mjs.map +0 -1
- package/dist/sandbox-DVPEJQH5.mjs +0 -8
- package/dist/sandbox-KPV7FEKK.mjs +0 -8
- /package/dist/{chunk-IXTFKE4C.mjs.map → chunk-WKKDKXBR.mjs.map} +0 -0
- /package/dist/{chunk-HZOFRVBE.mjs.map → chunk-WWSTWNMU.mjs.map} +0 -0
- /package/dist/{sandbox-DVPEJQH5.mjs.map → sandbox-JISSVQIL.mjs.map} +0 -0
- /package/dist/{sandbox-KPV7FEKK.mjs.map → sandbox-KCRK5IJD.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -108,3 +108,15 @@ template.setEnvs({ PATH: "/app/bin:$PATH", APP_MODE: "worker" }, { runtime: true
|
|
|
108
108
|
Mutable image tags are refreshed for each serialization/build. Only successful
|
|
109
109
|
digest-pinned registry reads are cached, and failed reads are retryable on the
|
|
110
110
|
same builder. Explicit caller commands and settings override image defaults.
|
|
111
|
+
|
|
112
|
+
## Sandbox security options
|
|
113
|
+
|
|
114
|
+
The legacy `secure` and public traffic options are deprecated. Existing call sites
|
|
115
|
+
remain accepted, but the SDK warns and never sends these controls to the API.
|
|
116
|
+
Security policy is controlled by the backend. Python emits a `DeprecationWarning`;
|
|
117
|
+
JavaScript emits a console warning. Remove the deprecated options to silence it.
|
|
118
|
+
|
|
119
|
+
Network information returned by the backend still includes the public traffic state.
|
|
120
|
+
Use the sandbox's traffic access token in the `Sandbox-Traffic-Access-Token` header
|
|
121
|
+
when accessing a custom port. Instance connect/reset updates this token when one is
|
|
122
|
+
returned; reset does not issue an extra connect request to obtain a missing token.
|
|
@@ -60,7 +60,7 @@ import createClient from "openapi-fetch";
|
|
|
60
60
|
import platform2 from "platform";
|
|
61
61
|
|
|
62
62
|
// package.json
|
|
63
|
-
var version = "2.1.4-
|
|
63
|
+
var version = "2.1.4-a5";
|
|
64
64
|
|
|
65
65
|
// src/core/utils.ts
|
|
66
66
|
import platform from "platform";
|
|
@@ -440,7 +440,10 @@ var _ConnectionConfig = class _ConnectionConfig {
|
|
|
440
440
|
this.accessToken = (opts == null ? void 0 : opts.accessToken) || _ConnectionConfig.accessToken;
|
|
441
441
|
this.requestTimeoutMs = (_a3 = opts == null ? void 0 : opts.requestTimeoutMs) != null ? _a3 : this.isLegacyDomain ? LEGACY_REQUEST_TIMEOUT_MS : REQUEST_TIMEOUT_MS;
|
|
442
442
|
this.logger = opts == null ? void 0 : opts.logger;
|
|
443
|
-
this.headers = (
|
|
443
|
+
this.headers = __spreadValues({
|
|
444
|
+
"X-PPIO-SDK-Name": "sdk_js",
|
|
445
|
+
"X-PPIO-SDK-Version": version
|
|
446
|
+
}, opts == null ? void 0 : opts.headers);
|
|
444
447
|
this.headers["User-Agent"] = `ppio-sandbox-sdk-js/${version}`;
|
|
445
448
|
this.apiUrl = normalizeApiUrl(opts == null ? void 0 : opts.apiUrl) || normalizeApiUrl(_ConnectionConfig.apiUrl) || getDefaultApiUrl(this.domain, this.debug);
|
|
446
449
|
this.sandboxUrl = (opts == null ? void 0 : opts.sandboxUrl) || _ConnectionConfig.sandboxUrl;
|
|
@@ -2997,6 +3000,18 @@ function bindingFromJson(data) {
|
|
|
2997
3000
|
}
|
|
2998
3001
|
|
|
2999
3002
|
// src/core/sandbox/sandboxApi.ts
|
|
3003
|
+
function warnDeprecatedSecurityOptions(opts) {
|
|
3004
|
+
var _a3;
|
|
3005
|
+
if ((opts == null ? void 0 : opts.secure) !== void 0 || (opts == null ? void 0 : opts.allowPublicTraffic) !== void 0 || ((_a3 = opts == null ? void 0 : opts.network) == null ? void 0 : _a3.allowPublicTraffic) !== void 0) {
|
|
3006
|
+
console.warn("secure and allowPublicTraffic are deprecated and ignored; security is controlled by the backend.");
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
function stripPublicTraffic(network) {
|
|
3010
|
+
if (!network) return void 0;
|
|
3011
|
+
const rest = __spreadValues({}, network);
|
|
3012
|
+
delete rest.allowPublicTraffic;
|
|
3013
|
+
return rest;
|
|
3014
|
+
}
|
|
3000
3015
|
async function createRawApiError(response) {
|
|
3001
3016
|
var _a3, _b, _c;
|
|
3002
3017
|
let message = response.statusText;
|
|
@@ -3289,20 +3304,16 @@ var SandboxApi = class {
|
|
|
3289
3304
|
return resizeResultFromApi(await response.json());
|
|
3290
3305
|
}
|
|
3291
3306
|
static async reset(sandboxId, opts) {
|
|
3307
|
+
return (await this.resetSandbox(sandboxId, opts)).success;
|
|
3308
|
+
}
|
|
3309
|
+
static async resetSandbox(sandboxId, opts) {
|
|
3292
3310
|
var _a3;
|
|
3311
|
+
warnDeprecatedSecurityOptions(opts);
|
|
3293
3312
|
const config = new ConnectionConfig(opts);
|
|
3294
|
-
const
|
|
3313
|
+
const network = stripPublicTraffic(opts == null ? void 0 : opts.network);
|
|
3314
|
+
const body = __spreadValues(__spreadValues({
|
|
3295
3315
|
resume: (_a3 = opts == null ? void 0 : opts.resume) != null ? _a3 : true
|
|
3296
|
-
}, (opts == null ? void 0 : opts.timeoutMs) !== void 0 ? { timeout: timeoutToSeconds(opts.timeoutMs) } : {});
|
|
3297
|
-
if ((opts == null ? void 0 : opts.secure) !== void 0) {
|
|
3298
|
-
body.secure = opts.secure;
|
|
3299
|
-
}
|
|
3300
|
-
if ((opts == null ? void 0 : opts.allowPublicTraffic) !== void 0) {
|
|
3301
|
-
body.allowPublicTraffic = opts.allowPublicTraffic;
|
|
3302
|
-
}
|
|
3303
|
-
if (opts == null ? void 0 : opts.network) {
|
|
3304
|
-
body.network = opts.network;
|
|
3305
|
-
}
|
|
3316
|
+
}, (opts == null ? void 0 : opts.timeoutMs) !== void 0 ? { timeout: timeoutToSeconds(opts.timeoutMs) } : {}), network && Object.keys(network).length > 0 ? { network } : {});
|
|
3306
3317
|
const response = await fetch(
|
|
3307
3318
|
`${config.apiUrl}/sandboxes/${encodeURIComponent(sandboxId)}/reset`,
|
|
3308
3319
|
{
|
|
@@ -3318,12 +3329,16 @@ var SandboxApi = class {
|
|
|
3318
3329
|
throw new SandboxNotFoundError(`Sandbox ${sandboxId} not found`);
|
|
3319
3330
|
}
|
|
3320
3331
|
if (response.status === 409) {
|
|
3321
|
-
return false;
|
|
3332
|
+
return { success: false };
|
|
3322
3333
|
}
|
|
3323
3334
|
if (!response.ok) {
|
|
3324
3335
|
throw await createRawApiError(response);
|
|
3325
3336
|
}
|
|
3326
|
-
|
|
3337
|
+
const data = await response.json().catch(() => ({}));
|
|
3338
|
+
return {
|
|
3339
|
+
success: true,
|
|
3340
|
+
trafficAccessToken: typeof (data == null ? void 0 : data.trafficAccessToken) === "string" ? data.trafficAccessToken : void 0
|
|
3341
|
+
};
|
|
3327
3342
|
}
|
|
3328
3343
|
static async mountVolume(sandboxId, name, path3, opts) {
|
|
3329
3344
|
var _a3, _b;
|
|
@@ -3664,7 +3679,8 @@ var SandboxApi = class {
|
|
|
3664
3679
|
return true;
|
|
3665
3680
|
}
|
|
3666
3681
|
static async createSandbox(template, timeoutMs, opts) {
|
|
3667
|
-
var _a3, _b, _c, _d, _e
|
|
3682
|
+
var _a3, _b, _c, _d, _e;
|
|
3683
|
+
warnDeprecatedSecurityOptions(opts);
|
|
3668
3684
|
const config = new ConnectionConfig(opts);
|
|
3669
3685
|
const longRunning = ((_a3 = opts == null ? void 0 : opts.metadata) == null ? void 0 : _a3.long_running) === "true";
|
|
3670
3686
|
const metadata = longRunning ? __spreadValues({}, opts == null ? void 0 : opts.metadata) : opts == null ? void 0 : opts.metadata;
|
|
@@ -3676,12 +3692,10 @@ var SandboxApi = class {
|
|
|
3676
3692
|
if (opts == null ? void 0 : opts.mcp) {
|
|
3677
3693
|
raiseIfLegacy(config, "Sandbox.create mcp", SandboxError);
|
|
3678
3694
|
}
|
|
3679
|
-
const
|
|
3680
|
-
|
|
3681
|
-
);
|
|
3682
|
-
if (unsupportedNetworkOptions.length > 0) {
|
|
3695
|
+
const legacyNetwork = stripPublicTraffic(opts == null ? void 0 : opts.network);
|
|
3696
|
+
if (legacyNetwork && Object.keys(legacyNetwork).length > 0) {
|
|
3683
3697
|
throw new SandboxError(
|
|
3684
|
-
`Sandbox.create network
|
|
3698
|
+
`Sandbox.create network is not supported on legacy domains; unsupported options: ${Object.keys(legacyNetwork).join(", ")}`
|
|
3685
3699
|
);
|
|
3686
3700
|
}
|
|
3687
3701
|
if (opts == null ? void 0 : opts.volumeMounts) {
|
|
@@ -3693,14 +3707,13 @@ var SandboxApi = class {
|
|
|
3693
3707
|
if (opts == null ? void 0 : opts.resources) {
|
|
3694
3708
|
raiseIfLegacy(config, "Sandbox.create resources", SandboxError);
|
|
3695
3709
|
}
|
|
3696
|
-
const body2 = __spreadValues(
|
|
3710
|
+
const body2 = __spreadValues({
|
|
3697
3711
|
templateID: template,
|
|
3698
3712
|
timeout,
|
|
3699
3713
|
metadata: metadata != null ? metadata : {},
|
|
3700
|
-
envVars: (
|
|
3701
|
-
secure: (_e = opts == null ? void 0 : opts.secure) != null ? _e : false,
|
|
3714
|
+
envVars: (_c = opts == null ? void 0 : opts.envs) != null ? _c : {},
|
|
3702
3715
|
autoPause: autoPause != null ? autoPause : false
|
|
3703
|
-
}, (opts == null ? void 0 : opts.
|
|
3716
|
+
}, (opts == null ? void 0 : opts.nodeId) ? { nodeID: opts.nodeId } : {});
|
|
3704
3717
|
const response = await fetch(`${config.apiUrl}/sandboxes`, {
|
|
3705
3718
|
method: "POST",
|
|
3706
3719
|
headers: getRawApiHeaders(config, {
|
|
@@ -3728,16 +3741,15 @@ var SandboxApi = class {
|
|
|
3728
3741
|
};
|
|
3729
3742
|
}
|
|
3730
3743
|
const client = new ApiClient(config);
|
|
3731
|
-
const
|
|
3744
|
+
const network = stripPublicTraffic(opts == null ? void 0 : opts.network);
|
|
3745
|
+
const body = __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
3732
3746
|
templateID: template,
|
|
3733
3747
|
metadata,
|
|
3734
3748
|
mcp: opts == null ? void 0 : opts.mcp,
|
|
3735
3749
|
envVars: opts == null ? void 0 : opts.envs,
|
|
3736
3750
|
timeout,
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
network: opts == null ? void 0 : opts.network
|
|
3740
|
-
}, (opts == null ? void 0 : opts.nodeId) ? { nodeID: opts.nodeId } : {}), autoPause !== void 0 ? { autoPause } : {}), autoResumeEnabled !== void 0 ? { autoResume: { enabled: autoResumeEnabled } } : {});
|
|
3751
|
+
allow_internet_access: (_d = opts == null ? void 0 : opts.allowInternetAccess) != null ? _d : true
|
|
3752
|
+
}, network && Object.keys(network).length > 0 ? { network } : {}), (opts == null ? void 0 : opts.nodeId) ? { nodeID: opts.nodeId } : {}), autoPause !== void 0 ? { autoPause } : {}), autoResumeEnabled !== void 0 ? { autoResume: { enabled: autoResumeEnabled } } : {});
|
|
3741
3753
|
if (opts == null ? void 0 : opts.volumeMounts) {
|
|
3742
3754
|
body.volumeMounts = Object.entries(opts.volumeMounts).map(
|
|
3743
3755
|
([mountPath, vol]) => ({
|
|
@@ -3760,7 +3772,7 @@ var SandboxApi = class {
|
|
|
3760
3772
|
method: "POST",
|
|
3761
3773
|
headers: getRawApiHeaders(config, { "Content-Type": "application/json" }),
|
|
3762
3774
|
body: JSON.stringify(__spreadProps(__spreadValues({}, body), { resources: targets })),
|
|
3763
|
-
signal: config.getSignal((
|
|
3775
|
+
signal: config.getSignal((_e = opts == null ? void 0 : opts.requestTimeoutMs) != null ? _e : 36e4)
|
|
3764
3776
|
});
|
|
3765
3777
|
if (!response.ok) throw await createRawApiError(response);
|
|
3766
3778
|
const data = await response.json();
|
|
@@ -3803,7 +3815,9 @@ var SandboxApi = class {
|
|
|
3803
3815
|
static async connectSandbox(sandboxId, opts) {
|
|
3804
3816
|
var _a3, _b;
|
|
3805
3817
|
const timeoutMs = (_a3 = opts == null ? void 0 : opts.timeoutMs) != null ? _a3 : DEFAULT_SANDBOX_TIMEOUT_MS;
|
|
3818
|
+
warnDeprecatedSecurityOptions(opts);
|
|
3806
3819
|
const config = new ConnectionConfig(opts);
|
|
3820
|
+
const network = stripPublicTraffic(opts == null ? void 0 : opts.network);
|
|
3807
3821
|
if (config.isLegacyDomain) {
|
|
3808
3822
|
const response = await fetch(
|
|
3809
3823
|
`${config.apiUrl}/sandboxes/${encodeURIComponent(sandboxId)}/connect`,
|
|
@@ -3812,9 +3826,9 @@ var SandboxApi = class {
|
|
|
3812
3826
|
headers: getRawApiHeaders(config, {
|
|
3813
3827
|
"Content-Type": "application/json"
|
|
3814
3828
|
}),
|
|
3815
|
-
body: JSON.stringify(__spreadValues(
|
|
3829
|
+
body: JSON.stringify(__spreadValues({
|
|
3816
3830
|
timeout: timeoutToSeconds(timeoutMs)
|
|
3817
|
-
},
|
|
3831
|
+
}, network && Object.keys(network).length > 0 ? { network } : {})),
|
|
3818
3832
|
signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
|
|
3819
3833
|
}
|
|
3820
3834
|
);
|
|
@@ -3840,9 +3854,9 @@ var SandboxApi = class {
|
|
|
3840
3854
|
sandboxID: sandboxId
|
|
3841
3855
|
}
|
|
3842
3856
|
},
|
|
3843
|
-
body: __spreadValues(
|
|
3857
|
+
body: __spreadValues({
|
|
3844
3858
|
timeout: timeoutToSeconds(timeoutMs)
|
|
3845
|
-
},
|
|
3859
|
+
}, network && Object.keys(network).length > 0 ? { network } : {}),
|
|
3846
3860
|
signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
|
|
3847
3861
|
});
|
|
3848
3862
|
if (((_b = res.error) == null ? void 0 : _b.code) === 404) {
|
|
@@ -4142,7 +4156,7 @@ var Sandbox = class extends SandboxApi {
|
|
|
4142
4156
|
this.sandboxId = opts.sandboxId;
|
|
4143
4157
|
this.sandboxDomain = (_a3 = opts.sandboxDomain) != null ? _a3 : this.connectionConfig.domain;
|
|
4144
4158
|
this.envdAccessToken = opts.envdAccessToken;
|
|
4145
|
-
this.
|
|
4159
|
+
this._trafficAccessToken = opts.trafficAccessToken;
|
|
4146
4160
|
this.envdApiUrl = this.connectionConfig.getSandboxUrl(this.sandboxId, {
|
|
4147
4161
|
sandboxDomain: this.sandboxDomain,
|
|
4148
4162
|
envdPort: this.envdPort
|
|
@@ -4199,6 +4213,9 @@ var Sandbox = class extends SandboxApi {
|
|
|
4199
4213
|
});
|
|
4200
4214
|
this.git = new Git(this.commands);
|
|
4201
4215
|
}
|
|
4216
|
+
get trafficAccessToken() {
|
|
4217
|
+
return this._trafficAccessToken;
|
|
4218
|
+
}
|
|
4202
4219
|
/**
|
|
4203
4220
|
* List all sandboxes.
|
|
4204
4221
|
*
|
|
@@ -4424,7 +4441,13 @@ var Sandbox = class extends SandboxApi {
|
|
|
4424
4441
|
* ```
|
|
4425
4442
|
*/
|
|
4426
4443
|
async connect(opts) {
|
|
4427
|
-
await SandboxApi.connectSandbox(
|
|
4444
|
+
const sandbox = await SandboxApi.connectSandbox(
|
|
4445
|
+
this.sandboxId,
|
|
4446
|
+
this.resolveApiOpts(opts)
|
|
4447
|
+
);
|
|
4448
|
+
if (sandbox.trafficAccessToken !== void 0) {
|
|
4449
|
+
this._trafficAccessToken = sandbox.trafficAccessToken;
|
|
4450
|
+
}
|
|
4428
4451
|
return this;
|
|
4429
4452
|
}
|
|
4430
4453
|
/**
|
|
@@ -4506,7 +4529,14 @@ var Sandbox = class extends SandboxApi {
|
|
|
4506
4529
|
* @returns `true` if reset succeeded, `false` if the sandbox is in a conflicting state.
|
|
4507
4530
|
*/
|
|
4508
4531
|
async reset(opts) {
|
|
4509
|
-
|
|
4532
|
+
const result = await SandboxApi.resetSandbox(
|
|
4533
|
+
this.sandboxId,
|
|
4534
|
+
this.resolveApiOpts(opts)
|
|
4535
|
+
);
|
|
4536
|
+
if (result.trafficAccessToken !== void 0) {
|
|
4537
|
+
this._trafficAccessToken = result.trafficAccessToken;
|
|
4538
|
+
}
|
|
4539
|
+
return result.success;
|
|
4510
4540
|
}
|
|
4511
4541
|
/**
|
|
4512
4542
|
* Update network egress rules for this running sandbox.
|
|
@@ -8067,12 +8097,12 @@ var PPIO = class {
|
|
|
8067
8097
|
this.secret = new SecretNamespace(opts);
|
|
8068
8098
|
this.codeInterpreter = new RuntimeSandboxNamespace(
|
|
8069
8099
|
opts,
|
|
8070
|
-
() => import("./sandbox-
|
|
8100
|
+
() => import("./sandbox-JISSVQIL.mjs")
|
|
8071
8101
|
);
|
|
8072
8102
|
this.code_interpreter = this.codeInterpreter;
|
|
8073
8103
|
this.desktop = new RuntimeSandboxNamespace(
|
|
8074
8104
|
opts,
|
|
8075
|
-
() => import("./sandbox-
|
|
8105
|
+
() => import("./sandbox-KCRK5IJD.mjs")
|
|
8076
8106
|
);
|
|
8077
8107
|
}
|
|
8078
8108
|
async create(templateOrOpts, opts) {
|
|
@@ -8151,4 +8181,4 @@ export {
|
|
|
8151
8181
|
ALL_TRAFFIC,
|
|
8152
8182
|
core_default
|
|
8153
8183
|
};
|
|
8154
|
-
//# sourceMappingURL=chunk-
|
|
8184
|
+
//# sourceMappingURL=chunk-AQHUBXNH.mjs.map
|