sandbox 2.5.3 → 3.0.0-beta.1
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.
|
@@ -478,7 +478,7 @@ var init_source = __esm({ "../../node_modules/.pnpm/chalk@5.6.0/node_modules/cha
|
|
|
478
478
|
var require_didYouMean_1_2_1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/didyoumean@1.2.2/node_modules/didyoumean/didYouMean-1.2.1.js": ((exports, module) => {
|
|
479
479
|
(function() {
|
|
480
480
|
"use strict";
|
|
481
|
-
function didYouMean(str, list$
|
|
481
|
+
function didYouMean(str, list$3, key) {
|
|
482
482
|
if (!str) return null;
|
|
483
483
|
if (!didYouMean.caseSensitive) str = str.toLowerCase();
|
|
484
484
|
var thresholdRelative = didYouMean.threshold === null ? null : didYouMean.threshold * str.length, thresholdAbsolute = didYouMean.thresholdAbsolute, winningVal;
|
|
@@ -486,9 +486,9 @@ var require_didYouMean_1_2_1 = /* @__PURE__ */ __commonJS$1({ "../../node_module
|
|
|
486
486
|
else if (thresholdRelative !== null) winningVal = thresholdRelative;
|
|
487
487
|
else if (thresholdAbsolute !== null) winningVal = thresholdAbsolute;
|
|
488
488
|
else winningVal = null;
|
|
489
|
-
var winner, candidate, testCandidate, val, i, len = list$
|
|
489
|
+
var winner, candidate, testCandidate, val, i, len = list$3.length;
|
|
490
490
|
for (i = 0; i < len; i++) {
|
|
491
|
-
candidate = list$
|
|
491
|
+
candidate = list$3[i];
|
|
492
492
|
if (key) candidate = candidate[key];
|
|
493
493
|
if (!candidate) continue;
|
|
494
494
|
if (!didYouMean.caseSensitive) testCandidate = candidate.toLowerCase();
|
|
@@ -496,7 +496,7 @@ var require_didYouMean_1_2_1 = /* @__PURE__ */ __commonJS$1({ "../../node_module
|
|
|
496
496
|
val = getEditDistance(str, testCandidate, winningVal);
|
|
497
497
|
if (winningVal === null || val < winningVal) {
|
|
498
498
|
winningVal = val;
|
|
499
|
-
if (key && didYouMean.returnWinningObject) winner = list$
|
|
499
|
+
if (key && didYouMean.returnWinningObject) winner = list$3[i];
|
|
500
500
|
else winner = candidate;
|
|
501
501
|
if (didYouMean.returnFirstMatch) return winner;
|
|
502
502
|
}
|
|
@@ -1446,7 +1446,7 @@ var require_subcommands = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
1446
1446
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1447
1447
|
};
|
|
1448
1448
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1449
|
-
exports.subcommands = subcommands$
|
|
1449
|
+
exports.subcommands = subcommands$3;
|
|
1450
1450
|
const chalk_1$3 = __importDefault$4((init_source(), __toCommonJS$3(source_exports)));
|
|
1451
1451
|
const didyoumean_1 = __importDefault$4(require_didYouMean_1_2_1());
|
|
1452
1452
|
const Result$7 = __importStar$7(require_Result());
|
|
@@ -1456,7 +1456,7 @@ var require_subcommands = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
1456
1456
|
/**
|
|
1457
1457
|
* Combine multiple `command`s into one
|
|
1458
1458
|
*/
|
|
1459
|
-
function subcommands$
|
|
1459
|
+
function subcommands$3(config$1) {
|
|
1460
1460
|
const circuitbreaker = (0, circuitbreaker_1$1.createCircuitBreaker)(!!config$1.version);
|
|
1461
1461
|
const subcommand = (0, positional_1$1.positional)({
|
|
1462
1462
|
displayName: "subcommand",
|
|
@@ -2997,17 +2997,18 @@ var require_cjs = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cmd-t
|
|
|
2997
2997
|
|
|
2998
2998
|
//#endregion
|
|
2999
2999
|
//#region src/args/runtime.ts
|
|
3000
|
-
var import_cjs$
|
|
3001
|
-
const
|
|
3000
|
+
var import_cjs$26 = /* @__PURE__ */ __toESM(require_cjs());
|
|
3001
|
+
const runtimeType = {
|
|
3002
|
+
...import_cjs$26.oneOf([
|
|
3003
|
+
"node22",
|
|
3004
|
+
"node24",
|
|
3005
|
+
"python3.13"
|
|
3006
|
+
]),
|
|
3007
|
+
displayName: "runtime"
|
|
3008
|
+
};
|
|
3009
|
+
const runtime = import_cjs$26.option({
|
|
3002
3010
|
long: "runtime",
|
|
3003
|
-
type:
|
|
3004
|
-
...import_cjs$23.oneOf([
|
|
3005
|
-
"node22",
|
|
3006
|
-
"node24",
|
|
3007
|
-
"python3.13"
|
|
3008
|
-
]),
|
|
3009
|
-
displayName: "runtime"
|
|
3010
|
-
},
|
|
3011
|
+
type: runtimeType,
|
|
3011
3012
|
defaultValue: () => "node24",
|
|
3012
3013
|
defaultValueIsSerializable: true
|
|
3013
3014
|
});
|
|
@@ -3099,13 +3100,13 @@ var require_ms = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ms@2.1
|
|
|
3099
3100
|
* @return {String}
|
|
3100
3101
|
* @api private
|
|
3101
3102
|
*/
|
|
3102
|
-
function fmtShort(ms$
|
|
3103
|
-
var msAbs = Math.abs(ms$
|
|
3104
|
-
if (msAbs >= d) return Math.round(ms$
|
|
3105
|
-
if (msAbs >= h) return Math.round(ms$
|
|
3106
|
-
if (msAbs >= m) return Math.round(ms$
|
|
3107
|
-
if (msAbs >= s) return Math.round(ms$
|
|
3108
|
-
return ms$
|
|
3103
|
+
function fmtShort(ms$4) {
|
|
3104
|
+
var msAbs = Math.abs(ms$4);
|
|
3105
|
+
if (msAbs >= d) return Math.round(ms$4 / d) + "d";
|
|
3106
|
+
if (msAbs >= h) return Math.round(ms$4 / h) + "h";
|
|
3107
|
+
if (msAbs >= m) return Math.round(ms$4 / m) + "m";
|
|
3108
|
+
if (msAbs >= s) return Math.round(ms$4 / s) + "s";
|
|
3109
|
+
return ms$4 + "ms";
|
|
3109
3110
|
}
|
|
3110
3111
|
/**
|
|
3111
3112
|
* Long format for `ms`.
|
|
@@ -3114,28 +3115,28 @@ var require_ms = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ms@2.1
|
|
|
3114
3115
|
* @return {String}
|
|
3115
3116
|
* @api private
|
|
3116
3117
|
*/
|
|
3117
|
-
function fmtLong(ms$
|
|
3118
|
-
var msAbs = Math.abs(ms$
|
|
3119
|
-
if (msAbs >= d) return plural(ms$
|
|
3120
|
-
if (msAbs >= h) return plural(ms$
|
|
3121
|
-
if (msAbs >= m) return plural(ms$
|
|
3122
|
-
if (msAbs >= s) return plural(ms$
|
|
3123
|
-
return ms$
|
|
3118
|
+
function fmtLong(ms$4) {
|
|
3119
|
+
var msAbs = Math.abs(ms$4);
|
|
3120
|
+
if (msAbs >= d) return plural(ms$4, msAbs, d, "day");
|
|
3121
|
+
if (msAbs >= h) return plural(ms$4, msAbs, h, "hour");
|
|
3122
|
+
if (msAbs >= m) return plural(ms$4, msAbs, m, "minute");
|
|
3123
|
+
if (msAbs >= s) return plural(ms$4, msAbs, s, "second");
|
|
3124
|
+
return ms$4 + " ms";
|
|
3124
3125
|
}
|
|
3125
3126
|
/**
|
|
3126
3127
|
* Pluralization helper.
|
|
3127
3128
|
*/
|
|
3128
|
-
function plural(ms$
|
|
3129
|
+
function plural(ms$4, msAbs, n, name) {
|
|
3129
3130
|
var isPlural = msAbs >= n * 1.5;
|
|
3130
|
-
return Math.round(ms$
|
|
3131
|
+
return Math.round(ms$4 / n) + " " + name + (isPlural ? "s" : "");
|
|
3131
3132
|
}
|
|
3132
3133
|
}) });
|
|
3133
3134
|
|
|
3134
3135
|
//#endregion
|
|
3135
3136
|
//#region src/types/duration.ts
|
|
3136
|
-
var import_cjs$
|
|
3137
|
+
var import_cjs$25 = require_cjs();
|
|
3137
3138
|
init_source();
|
|
3138
|
-
const Duration = (0, import_cjs$
|
|
3139
|
+
const Duration = (0, import_cjs$25.extendType)(import_cjs$25.string, {
|
|
3139
3140
|
displayName: "num UNIT",
|
|
3140
3141
|
description: "A duration, e.g. 5m, 10s, 1h",
|
|
3141
3142
|
async from(string$1) {
|
|
@@ -3151,8 +3152,8 @@ const Duration = (0, import_cjs$22.extendType)(import_cjs$22.string, {
|
|
|
3151
3152
|
|
|
3152
3153
|
//#endregion
|
|
3153
3154
|
//#region src/args/timeout.ts
|
|
3154
|
-
var import_cjs$
|
|
3155
|
-
const timeout = import_cjs$
|
|
3155
|
+
var import_cjs$24 = /* @__PURE__ */ __toESM(require_cjs());
|
|
3156
|
+
const timeout = import_cjs$24.option({
|
|
3156
3157
|
long: "timeout",
|
|
3157
3158
|
type: Duration,
|
|
3158
3159
|
description: "The maximum duration a sandbox can run for. Example: 5m, 1h",
|
|
@@ -3162,10 +3163,10 @@ const timeout = import_cjs$21.option({
|
|
|
3162
3163
|
|
|
3163
3164
|
//#endregion
|
|
3164
3165
|
//#region src/args/vcpus.ts
|
|
3165
|
-
var import_cjs$
|
|
3166
|
-
const vcpus = import_cjs$
|
|
3166
|
+
var import_cjs$23 = /* @__PURE__ */ __toESM(require_cjs());
|
|
3167
|
+
const vcpus = import_cjs$23.option({
|
|
3167
3168
|
long: "vcpus",
|
|
3168
|
-
type: import_cjs$
|
|
3169
|
+
type: import_cjs$23.optional(import_cjs$23.extendType(import_cjs$23.number, {
|
|
3169
3170
|
displayName: "COUNT",
|
|
3170
3171
|
async from(n) {
|
|
3171
3172
|
if (!Number.isInteger(n) || n < 1) throw new Error(`Invalid vCPU count: ${n}. Must be a positive integer.`);
|
|
@@ -6950,10 +6951,10 @@ function _usingCtx() {
|
|
|
6950
6951
|
|
|
6951
6952
|
//#endregion
|
|
6952
6953
|
//#region src/commands/login.ts
|
|
6953
|
-
var import_cjs$
|
|
6954
|
+
var import_cjs$22 = /* @__PURE__ */ __toESM(require_cjs());
|
|
6954
6955
|
init_source();
|
|
6955
6956
|
const debug$5 = createDebugger("sandbox:login");
|
|
6956
|
-
const login = import_cjs$
|
|
6957
|
+
const login = import_cjs$22.command({
|
|
6957
6958
|
name: "login",
|
|
6958
6959
|
description: "Log in to the Sandbox CLI",
|
|
6959
6960
|
args: {},
|
|
@@ -7163,15 +7164,15 @@ var require_dist = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@ver
|
|
|
7163
7164
|
|
|
7164
7165
|
//#endregion
|
|
7165
7166
|
//#region src/args/auth.ts
|
|
7166
|
-
var import_cjs$
|
|
7167
|
+
var import_cjs$21 = /* @__PURE__ */ __toESM(require_cjs());
|
|
7167
7168
|
init_source();
|
|
7168
7169
|
var import_dist = require_dist();
|
|
7169
7170
|
const debug$4 = createDebugger("sandbox:args:auth");
|
|
7170
|
-
const token = import_cjs$
|
|
7171
|
+
const token = import_cjs$21.option({
|
|
7171
7172
|
long: "token",
|
|
7172
7173
|
description: "A Vercel authentication token. If not provided, will use the token stored in your system from `VERCEL_AUTH_TOKEN` or will start a log in process.",
|
|
7173
7174
|
type: {
|
|
7174
|
-
...import_cjs$
|
|
7175
|
+
...import_cjs$21.string,
|
|
7175
7176
|
displayName: "pat_or_oidc",
|
|
7176
7177
|
defaultValueIsSerializable: false,
|
|
7177
7178
|
onMissing: async () => {
|
|
@@ -7314,29 +7315,29 @@ async function inferFromToken(token$1, requestedTeam) {
|
|
|
7314
7315
|
|
|
7315
7316
|
//#endregion
|
|
7316
7317
|
//#region src/args/scope.ts
|
|
7317
|
-
var import_cjs$
|
|
7318
|
+
var import_cjs$20 = /* @__PURE__ */ __toESM(require_cjs());
|
|
7318
7319
|
init_source();
|
|
7319
|
-
const project = import_cjs$
|
|
7320
|
+
const project = import_cjs$20.option({
|
|
7320
7321
|
long: "project",
|
|
7321
7322
|
type: {
|
|
7322
|
-
...import_cjs$
|
|
7323
|
+
...import_cjs$20.optional(import_cjs$20.string),
|
|
7323
7324
|
displayName: "my-project"
|
|
7324
7325
|
},
|
|
7325
7326
|
description: "The project name or ID to associate with the command. Can be inferred from VERCEL_OIDC_TOKEN."
|
|
7326
7327
|
});
|
|
7327
7328
|
/** Parser for the `--team` option. */
|
|
7328
|
-
const teamParser = import_cjs$
|
|
7329
|
+
const teamParser = import_cjs$20.option({
|
|
7329
7330
|
long: "team",
|
|
7330
7331
|
type: {
|
|
7331
|
-
...import_cjs$
|
|
7332
|
+
...import_cjs$20.optional(import_cjs$20.string),
|
|
7332
7333
|
displayName: "my-team"
|
|
7333
7334
|
}
|
|
7334
7335
|
});
|
|
7335
7336
|
/** Parser for the `--scope` option. */
|
|
7336
|
-
const scopeParser = import_cjs$
|
|
7337
|
+
const scopeParser = import_cjs$20.option({
|
|
7337
7338
|
long: "scope",
|
|
7338
7339
|
type: {
|
|
7339
|
-
...import_cjs$
|
|
7340
|
+
...import_cjs$20.optional(import_cjs$20.string),
|
|
7340
7341
|
displayName: "my-team"
|
|
7341
7342
|
},
|
|
7342
7343
|
description: "The scope/team to associate with the command. Can be inferred from VERCEL_OIDC_TOKEN. [alias: --team]"
|
|
@@ -7425,7 +7426,7 @@ const scope = {
|
|
|
7425
7426
|
|
|
7426
7427
|
//#endregion
|
|
7427
7428
|
//#region package.json
|
|
7428
|
-
var version = "
|
|
7429
|
+
var version = "3.0.0-beta.1";
|
|
7429
7430
|
|
|
7430
7431
|
//#endregion
|
|
7431
7432
|
//#region src/error.ts
|
|
@@ -7446,6 +7447,7 @@ init_source();
|
|
|
7446
7447
|
const sandboxClient = {
|
|
7447
7448
|
get: (params) => withErrorHandling(Sandbox.get({
|
|
7448
7449
|
fetch: fetchWithUserAgent,
|
|
7450
|
+
resume: false,
|
|
7449
7451
|
...params
|
|
7450
7452
|
})),
|
|
7451
7453
|
create: (params) => withErrorHandling(Sandbox.create({
|
|
@@ -7515,9 +7517,9 @@ async function writeResponseToTemp({ response, text }) {
|
|
|
7515
7517
|
|
|
7516
7518
|
//#endregion
|
|
7517
7519
|
//#region src/args/snapshot-id.ts
|
|
7518
|
-
var import_cjs$
|
|
7520
|
+
var import_cjs$19 = /* @__PURE__ */ __toESM(require_cjs());
|
|
7519
7521
|
init_source();
|
|
7520
|
-
const snapshotId = import_cjs$
|
|
7522
|
+
const snapshotId = import_cjs$19.extendType(import_cjs$19.string, {
|
|
7521
7523
|
displayName: "snapshot_id",
|
|
7522
7524
|
description: "The ID of the snapshot",
|
|
7523
7525
|
async from(s$1) {
|
|
@@ -7527,16 +7529,16 @@ const snapshotId = import_cjs$16.extendType(import_cjs$16.string, {
|
|
|
7527
7529
|
});
|
|
7528
7530
|
|
|
7529
7531
|
//#endregion
|
|
7530
|
-
//#region src/args/sandbox-
|
|
7531
|
-
var import_cjs$
|
|
7532
|
+
//#region src/args/sandbox-name.ts
|
|
7533
|
+
var import_cjs$18 = /* @__PURE__ */ __toESM(require_cjs());
|
|
7532
7534
|
init_source();
|
|
7533
|
-
const
|
|
7534
|
-
displayName: "
|
|
7535
|
-
description: "The
|
|
7535
|
+
const sandboxName = import_cjs$18.extendType(import_cjs$18.string, {
|
|
7536
|
+
displayName: "name",
|
|
7537
|
+
description: "The name of the sandbox",
|
|
7536
7538
|
async from(s$1) {
|
|
7537
|
-
if (!s$1.
|
|
7538
|
-
`
|
|
7539
|
-
`${source_default.bold("hint:")}
|
|
7539
|
+
if (!s$1 || s$1.trim().length === 0) throw new Error([
|
|
7540
|
+
`Sandbox name cannot be empty.`,
|
|
7541
|
+
`${source_default.bold("hint:")} Provide a sandbox name.`,
|
|
7540
7542
|
"╰▶ run `sandbox list` to see available sandboxes."
|
|
7541
7543
|
].join("\n"));
|
|
7542
7544
|
return s$1;
|
|
@@ -7579,13 +7581,13 @@ var require_buffer_util = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
7579
7581
|
* @return {Buffer} The resulting buffer
|
|
7580
7582
|
* @public
|
|
7581
7583
|
*/
|
|
7582
|
-
function concat$1(list$
|
|
7583
|
-
if (list$
|
|
7584
|
-
if (list$
|
|
7584
|
+
function concat$1(list$3, totalLength) {
|
|
7585
|
+
if (list$3.length === 0) return EMPTY_BUFFER$3;
|
|
7586
|
+
if (list$3.length === 1) return list$3[0];
|
|
7585
7587
|
const target = Buffer.allocUnsafe(totalLength);
|
|
7586
7588
|
let offset = 0;
|
|
7587
|
-
for (let i = 0; i < list$
|
|
7588
|
-
const buf = list$
|
|
7589
|
+
for (let i = 0; i < list$3.length; i++) {
|
|
7590
|
+
const buf = list$3[i];
|
|
7589
7591
|
target.set(buf, offset);
|
|
7590
7592
|
offset += buf.length;
|
|
7591
7593
|
}
|
|
@@ -9154,13 +9156,13 @@ var require_sender = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ws
|
|
|
9154
9156
|
* @param {Function} [cb] Callback
|
|
9155
9157
|
* @private
|
|
9156
9158
|
*/
|
|
9157
|
-
sendFrame(list$
|
|
9158
|
-
if (list$
|
|
9159
|
+
sendFrame(list$3, cb) {
|
|
9160
|
+
if (list$3.length === 2) {
|
|
9159
9161
|
this._socket.cork();
|
|
9160
|
-
this._socket.write(list$
|
|
9161
|
-
this._socket.write(list$
|
|
9162
|
+
this._socket.write(list$3[0]);
|
|
9163
|
+
this._socket.write(list$3[1], cb);
|
|
9162
9164
|
this._socket.uncork();
|
|
9163
|
-
} else this._socket.write(list$
|
|
9165
|
+
} else this._socket.write(list$3[0], cb);
|
|
9164
9166
|
}
|
|
9165
9167
|
};
|
|
9166
9168
|
module.exports = Sender$2;
|
|
@@ -11244,9 +11246,9 @@ function printCommand(command$1, args$4) {
|
|
|
11244
11246
|
|
|
11245
11247
|
//#endregion
|
|
11246
11248
|
//#region src/interactive-shell/extend-sandbox-timeout.ts
|
|
11247
|
-
var import_ms$
|
|
11249
|
+
var import_ms$3 = /* @__PURE__ */ __toESM(require_ms());
|
|
11248
11250
|
const debug$2 = createDebugger("sandbox:timeout");
|
|
11249
|
-
const BUFFER = (0, import_ms$
|
|
11251
|
+
const BUFFER = (0, import_ms$3.default)("10 seconds");
|
|
11250
11252
|
async function extendSandboxTimeoutPeriodically(sandbox, signal) {
|
|
11251
11253
|
const nextTick = sandbox.createdAt.getTime() + sandbox.timeout;
|
|
11252
11254
|
debug$2(`next tick: ${new Date(nextTick).toISOString()}`);
|
|
@@ -11256,7 +11258,7 @@ async function extendSandboxTimeoutPeriodically(sandbox, signal) {
|
|
|
11256
11258
|
debug$2(`sleeping for ${timeout$1}ms until next timeout extension`);
|
|
11257
11259
|
await setTimeout$1(timeout$1, null, { signal });
|
|
11258
11260
|
}
|
|
11259
|
-
await sandbox.extendTimeout((0, import_ms$
|
|
11261
|
+
await sandbox.extendTimeout((0, import_ms$3.default)("5 minutes"));
|
|
11260
11262
|
const nextTick$1 = sandbox.createdAt.getTime() + sandbox.timeout;
|
|
11261
11263
|
debug$2(`extended sandbox timeout by 5 minutes. next tick: ${new Date(nextTick$1).toISOString()}`);
|
|
11262
11264
|
}
|
|
@@ -11455,7 +11457,7 @@ async function attach({ progress, listener, printCommand: printCommand$1, sandbo
|
|
|
11455
11457
|
});
|
|
11456
11458
|
extensionController.abort("client disconnected");
|
|
11457
11459
|
client.close();
|
|
11458
|
-
console.error(source_default.dim(`\n╰▶ connection to ▲ ${sandbox.
|
|
11460
|
+
console.error(source_default.dim(`\n╰▶ connection to ▲ ${sandbox.name} closed.`));
|
|
11459
11461
|
} catch (_) {
|
|
11460
11462
|
_usingCtx4.e = _;
|
|
11461
11463
|
} finally {
|
|
@@ -11522,9 +11524,9 @@ function getStderrStream() {
|
|
|
11522
11524
|
|
|
11523
11525
|
//#endregion
|
|
11524
11526
|
//#region src/args/key-value-pair.ts
|
|
11525
|
-
var import_cjs$
|
|
11527
|
+
var import_cjs$17 = /* @__PURE__ */ __toESM(require_cjs());
|
|
11526
11528
|
init_source();
|
|
11527
|
-
const KeyValuePair = import_cjs$
|
|
11529
|
+
const KeyValuePair = import_cjs$17.extendType(import_cjs$17.string, {
|
|
11528
11530
|
displayName: "key=value",
|
|
11529
11531
|
async from(input) {
|
|
11530
11532
|
if (!input.includes("=")) return {
|
|
@@ -11538,7 +11540,7 @@ const KeyValuePair = import_cjs$14.extendType(import_cjs$14.string, {
|
|
|
11538
11540
|
};
|
|
11539
11541
|
}
|
|
11540
11542
|
});
|
|
11541
|
-
const ObjectFromKeyValue = import_cjs$
|
|
11543
|
+
const ObjectFromKeyValue = import_cjs$17.extendType(import_cjs$17.array(KeyValuePair), { async from(input) {
|
|
11542
11544
|
const obj = Object.create(null);
|
|
11543
11545
|
const missingVars = [];
|
|
11544
11546
|
for (const { key, value } of input) if (value === void 0) missingVars.push(key);
|
|
@@ -11552,27 +11554,27 @@ const ObjectFromKeyValue = import_cjs$14.extendType(import_cjs$14.array(KeyValue
|
|
|
11552
11554
|
|
|
11553
11555
|
//#endregion
|
|
11554
11556
|
//#region src/commands/exec.ts
|
|
11555
|
-
var import_cjs$
|
|
11557
|
+
var import_cjs$16 = /* @__PURE__ */ __toESM(require_cjs());
|
|
11556
11558
|
init_source();
|
|
11557
11559
|
const args$3 = {
|
|
11558
|
-
sandbox: import_cjs$
|
|
11559
|
-
command: import_cjs$
|
|
11560
|
+
sandbox: import_cjs$16.positional({ type: sandboxName }),
|
|
11561
|
+
command: import_cjs$16.positional({
|
|
11560
11562
|
displayName: "command",
|
|
11561
11563
|
description: "The executable to invoke"
|
|
11562
11564
|
}),
|
|
11563
|
-
args: import_cjs$
|
|
11565
|
+
args: import_cjs$16.rest({
|
|
11564
11566
|
displayName: "args",
|
|
11565
11567
|
description: "arguments to pass to the command"
|
|
11566
11568
|
}),
|
|
11567
|
-
asSudo: import_cjs$
|
|
11569
|
+
asSudo: import_cjs$16.flag({
|
|
11568
11570
|
long: "sudo",
|
|
11569
11571
|
description: "Give extended privileges to the command."
|
|
11570
11572
|
}),
|
|
11571
|
-
interactive: import_cjs$
|
|
11573
|
+
interactive: import_cjs$16.flag({
|
|
11572
11574
|
long: "interactive",
|
|
11573
11575
|
short: "i",
|
|
11574
11576
|
description: "Run the command in a secure interactive shell",
|
|
11575
|
-
type: import_cjs$
|
|
11577
|
+
type: import_cjs$16.extendType(import_cjs$16.boolean, {
|
|
11576
11578
|
defaultValue() {
|
|
11577
11579
|
return false;
|
|
11578
11580
|
},
|
|
@@ -11582,22 +11584,22 @@ const args$3 = {
|
|
|
11582
11584
|
}
|
|
11583
11585
|
})
|
|
11584
11586
|
}),
|
|
11585
|
-
skipExtendingTimeout: import_cjs$
|
|
11587
|
+
skipExtendingTimeout: import_cjs$16.flag({
|
|
11586
11588
|
long: "no-extend-timeout",
|
|
11587
11589
|
description: "Do not extend the sandbox timeout while running an interactive command. Only affects interactive executions."
|
|
11588
11590
|
}),
|
|
11589
|
-
tty: import_cjs$
|
|
11591
|
+
tty: import_cjs$16.flag({
|
|
11590
11592
|
long: "tty",
|
|
11591
11593
|
short: "t",
|
|
11592
11594
|
description: "Allocate a tty for an interactive command. This is a no-op."
|
|
11593
11595
|
}),
|
|
11594
|
-
cwd: import_cjs$
|
|
11596
|
+
cwd: import_cjs$16.option({
|
|
11595
11597
|
long: "workdir",
|
|
11596
11598
|
short: "w",
|
|
11597
11599
|
description: "The working directory to run the command in",
|
|
11598
|
-
type: import_cjs$
|
|
11600
|
+
type: import_cjs$16.optional(import_cjs$16.string)
|
|
11599
11601
|
}),
|
|
11600
|
-
envVars: import_cjs$
|
|
11602
|
+
envVars: import_cjs$16.multioption({
|
|
11601
11603
|
long: "env",
|
|
11602
11604
|
short: "e",
|
|
11603
11605
|
type: ObjectFromKeyValue,
|
|
@@ -11605,28 +11607,18 @@ const args$3 = {
|
|
|
11605
11607
|
}),
|
|
11606
11608
|
scope
|
|
11607
11609
|
};
|
|
11608
|
-
const exec = import_cjs$
|
|
11610
|
+
const exec = import_cjs$16.command({
|
|
11609
11611
|
name: "exec",
|
|
11610
11612
|
description: "Execute a command in an existing sandbox",
|
|
11611
11613
|
args: args$3,
|
|
11612
|
-
async handler({ command: command$1, cwd, args: args$4, asSudo, sandbox:
|
|
11613
|
-
const sandbox = typeof
|
|
11614
|
-
|
|
11614
|
+
async handler({ command: command$1, cwd, args: args$4, asSudo, sandbox: sandboxName$1, scope: { token: token$1, team: team$1, project: project$1 }, interactive, envVars, skipExtendingTimeout }) {
|
|
11615
|
+
const sandbox = typeof sandboxName$1 !== "string" ? sandboxName$1 : await sandboxClient.get({
|
|
11616
|
+
name: sandboxName$1,
|
|
11615
11617
|
projectId: project$1,
|
|
11616
11618
|
teamId: team$1,
|
|
11617
11619
|
token: token$1,
|
|
11618
11620
|
__includeSystemRoutes: true
|
|
11619
11621
|
});
|
|
11620
|
-
if (!["pending", "running"].includes(sandbox.status)) {
|
|
11621
|
-
console.error([
|
|
11622
|
-
`Sandbox ${sandbox.sandboxId} is not available (status: ${sandbox.status}).`,
|
|
11623
|
-
`${source_default.bold("hint:")} Only 'pending' or 'running' sandboxes can execute commands.`,
|
|
11624
|
-
"├▶ Use `sandbox list` to check sandbox status.",
|
|
11625
|
-
"╰▶ Use `sandbox create` to create a new sandbox."
|
|
11626
|
-
].join("\n"));
|
|
11627
|
-
process.exitCode = 1;
|
|
11628
|
-
return;
|
|
11629
|
-
}
|
|
11630
11622
|
if (!interactive) {
|
|
11631
11623
|
console.error(printCommand(command$1, args$4));
|
|
11632
11624
|
const result = await sandbox.runCommand({
|
|
@@ -11652,9 +11644,9 @@ const exec = import_cjs$13.command({
|
|
|
11652
11644
|
|
|
11653
11645
|
//#endregion
|
|
11654
11646
|
//#region src/args/network-policy.ts
|
|
11655
|
-
var import_cjs$
|
|
11647
|
+
var import_cjs$15 = /* @__PURE__ */ __toESM(require_cjs());
|
|
11656
11648
|
init_source();
|
|
11657
|
-
const networkPolicyMode = import_cjs$
|
|
11649
|
+
const networkPolicyMode = import_cjs$15.extendType(import_cjs$15.string, {
|
|
11658
11650
|
displayName: "MODE",
|
|
11659
11651
|
async from(value) {
|
|
11660
11652
|
const validModes = ["allow-all", "deny-all"];
|
|
@@ -11662,28 +11654,28 @@ const networkPolicyMode = import_cjs$12.extendType(import_cjs$12.string, {
|
|
|
11662
11654
|
return value;
|
|
11663
11655
|
}
|
|
11664
11656
|
});
|
|
11665
|
-
const networkPolicy = import_cjs$
|
|
11657
|
+
const networkPolicy = import_cjs$15.option({
|
|
11666
11658
|
long: "network-policy",
|
|
11667
11659
|
description: `Network policy mode: "allow-all" or "deny-all"
|
|
11668
11660
|
- allow-all: sandbox can access any website/domain
|
|
11669
11661
|
- deny-all: sandbox has no network access
|
|
11670
11662
|
Omit this option and use --allowed-domain / --allowed-cidr / --denied-cidr for custom policies.`,
|
|
11671
|
-
type: import_cjs$
|
|
11663
|
+
type: import_cjs$15.optional(networkPolicyMode)
|
|
11672
11664
|
});
|
|
11673
|
-
const allowedDomains = import_cjs$
|
|
11665
|
+
const allowedDomains = import_cjs$15.multioption({
|
|
11674
11666
|
long: "allowed-domain",
|
|
11675
11667
|
description: `Domain to allow traffic to (creates a custom network policy). Supports "*" for wildcards for a segment (e.g. '*.vercel.com', 'www.*.com'). If used as the first segment, will match any subdomain.`,
|
|
11676
|
-
type: import_cjs$
|
|
11668
|
+
type: import_cjs$15.array(import_cjs$15.string)
|
|
11677
11669
|
});
|
|
11678
|
-
const allowedCIDRs = import_cjs$
|
|
11670
|
+
const allowedCIDRs = import_cjs$15.multioption({
|
|
11679
11671
|
long: "allowed-cidr",
|
|
11680
11672
|
description: `CIDR to allow traffic to (creates a custom network policy). Takes precedence over 'allowed-domain'.`,
|
|
11681
|
-
type: import_cjs$
|
|
11673
|
+
type: import_cjs$15.array(import_cjs$15.string)
|
|
11682
11674
|
});
|
|
11683
|
-
const deniedCIDRs = import_cjs$
|
|
11675
|
+
const deniedCIDRs = import_cjs$15.multioption({
|
|
11684
11676
|
long: "denied-cidr",
|
|
11685
11677
|
description: `CIDR to deny traffic to (creates a custom network policy). Takes precedence over allowed domains/CIDRs.`,
|
|
11686
|
-
type: import_cjs$
|
|
11678
|
+
type: import_cjs$15.array(import_cjs$15.string)
|
|
11687
11679
|
});
|
|
11688
11680
|
const networkPolicyArgs = {
|
|
11689
11681
|
networkPolicy,
|
|
@@ -11722,18 +11714,27 @@ function buildNetworkPolicy(args$4) {
|
|
|
11722
11714
|
|
|
11723
11715
|
//#endregion
|
|
11724
11716
|
//#region src/commands/create.ts
|
|
11725
|
-
var import_cjs$
|
|
11726
|
-
var import_ms$
|
|
11717
|
+
var import_cjs$14 = /* @__PURE__ */ __toESM(require_cjs());
|
|
11718
|
+
var import_ms$2 = /* @__PURE__ */ __toESM(require_ms());
|
|
11727
11719
|
init_source();
|
|
11728
11720
|
const args$2 = {
|
|
11721
|
+
name: import_cjs$14.option({
|
|
11722
|
+
long: "name",
|
|
11723
|
+
description: "A user-chosen name for the sandbox. It must be unique per project.",
|
|
11724
|
+
type: import_cjs$14.optional(import_cjs$14.string)
|
|
11725
|
+
}),
|
|
11726
|
+
nonPersistent: import_cjs$14.flag({
|
|
11727
|
+
long: "non-persistent",
|
|
11728
|
+
description: "Disable automatic restore of the filesystem between sessions."
|
|
11729
|
+
}),
|
|
11729
11730
|
runtime,
|
|
11730
11731
|
timeout,
|
|
11731
11732
|
vcpus,
|
|
11732
|
-
ports: import_cjs$
|
|
11733
|
+
ports: import_cjs$14.multioption({
|
|
11733
11734
|
long: "publish-port",
|
|
11734
11735
|
short: "p",
|
|
11735
11736
|
description: "Publish sandbox port(s) to DOMAIN.vercel.run",
|
|
11736
|
-
type: import_cjs$
|
|
11737
|
+
type: import_cjs$14.array(import_cjs$14.extendType(import_cjs$14.number, {
|
|
11737
11738
|
displayName: "PORT",
|
|
11738
11739
|
async from(number) {
|
|
11739
11740
|
if (number < 1024 || number > 65535) throw new Error([
|
|
@@ -11745,24 +11746,30 @@ const args$2 = {
|
|
|
11745
11746
|
}
|
|
11746
11747
|
}))
|
|
11747
11748
|
}),
|
|
11748
|
-
silent: import_cjs$
|
|
11749
|
+
silent: import_cjs$14.flag({
|
|
11749
11750
|
long: "silent",
|
|
11750
|
-
description: "Don't write sandbox
|
|
11751
|
+
description: "Don't write sandbox name to stdout"
|
|
11751
11752
|
}),
|
|
11752
|
-
snapshot: import_cjs$
|
|
11753
|
+
snapshot: import_cjs$14.option({
|
|
11753
11754
|
long: "snapshot",
|
|
11754
11755
|
short: "s",
|
|
11755
11756
|
description: "Start the sandbox from a snapshot ID",
|
|
11756
|
-
type: import_cjs$
|
|
11757
|
+
type: import_cjs$14.optional(snapshotId)
|
|
11757
11758
|
}),
|
|
11758
|
-
connect: import_cjs$
|
|
11759
|
+
connect: import_cjs$14.flag({
|
|
11759
11760
|
long: "connect",
|
|
11760
11761
|
description: "Start an interactive shell session after creating the sandbox"
|
|
11761
11762
|
}),
|
|
11763
|
+
envVars: import_cjs$14.multioption({
|
|
11764
|
+
long: "env",
|
|
11765
|
+
short: "e",
|
|
11766
|
+
type: ObjectFromKeyValue,
|
|
11767
|
+
description: "Default environment variables for sandbox commands"
|
|
11768
|
+
}),
|
|
11762
11769
|
...networkPolicyArgs,
|
|
11763
11770
|
scope
|
|
11764
11771
|
};
|
|
11765
|
-
const create = import_cjs$
|
|
11772
|
+
const create = import_cjs$14.command({
|
|
11766
11773
|
name: "create",
|
|
11767
11774
|
description: "Create a sandbox in the specified account and project.",
|
|
11768
11775
|
args: args$2,
|
|
@@ -11770,16 +11777,18 @@ const create = import_cjs$11.command({
|
|
|
11770
11777
|
description: "Create and connect to a sandbox without a network access",
|
|
11771
11778
|
command: `sandbox run --network-policy=none --connect`
|
|
11772
11779
|
}],
|
|
11773
|
-
async handler({ ports, scope: scope$1, runtime: runtime$1, timeout: timeout$1, vcpus: vcpus$1, silent, snapshot: snapshot$1, connect: connect$2, networkPolicy: networkPolicyMode$1, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 }) {
|
|
11780
|
+
async handler({ name, nonPersistent, ports, scope: scope$1, runtime: runtime$1, timeout: timeout$1, vcpus: vcpus$1, silent, snapshot: snapshot$1, connect: connect$2, envVars, networkPolicy: networkPolicyMode$1, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 }) {
|
|
11774
11781
|
const networkPolicy$1 = buildNetworkPolicy({
|
|
11775
11782
|
networkPolicy: networkPolicyMode$1,
|
|
11776
11783
|
allowedDomains: allowedDomains$1,
|
|
11777
11784
|
allowedCIDRs: allowedCIDRs$1,
|
|
11778
11785
|
deniedCIDRs: deniedCIDRs$1
|
|
11779
11786
|
});
|
|
11787
|
+
const persistent = !nonPersistent;
|
|
11780
11788
|
const resources = vcpus$1 ? { vcpus: vcpus$1 } : void 0;
|
|
11781
11789
|
const spinner = silent ? void 0 : ora("Creating sandbox...").start();
|
|
11782
11790
|
const sandbox = snapshot$1 ? await sandboxClient.create({
|
|
11791
|
+
name,
|
|
11783
11792
|
source: {
|
|
11784
11793
|
type: "snapshot",
|
|
11785
11794
|
snapshotId: snapshot$1
|
|
@@ -11788,19 +11797,24 @@ const create = import_cjs$11.command({
|
|
|
11788
11797
|
projectId: scope$1.project,
|
|
11789
11798
|
token: scope$1.token,
|
|
11790
11799
|
ports,
|
|
11791
|
-
timeout: (0, import_ms$
|
|
11800
|
+
timeout: (0, import_ms$2.default)(timeout$1),
|
|
11792
11801
|
resources,
|
|
11793
11802
|
networkPolicy: networkPolicy$1,
|
|
11803
|
+
env: envVars,
|
|
11804
|
+
persistent,
|
|
11794
11805
|
__interactive: true
|
|
11795
11806
|
}) : await sandboxClient.create({
|
|
11807
|
+
name,
|
|
11796
11808
|
teamId: scope$1.team,
|
|
11797
11809
|
projectId: scope$1.project,
|
|
11798
11810
|
token: scope$1.token,
|
|
11799
11811
|
ports,
|
|
11800
11812
|
runtime: runtime$1,
|
|
11801
|
-
timeout: (0, import_ms$
|
|
11813
|
+
timeout: (0, import_ms$2.default)(timeout$1),
|
|
11802
11814
|
resources,
|
|
11803
11815
|
networkPolicy: networkPolicy$1,
|
|
11816
|
+
env: envVars,
|
|
11817
|
+
persistent,
|
|
11804
11818
|
__interactive: true
|
|
11805
11819
|
});
|
|
11806
11820
|
spinner?.stop();
|
|
@@ -11815,7 +11829,7 @@ const create = import_cjs$11.command({
|
|
|
11815
11829
|
const projectDisplay = scope$1.projectSlug ?? scope$1.project;
|
|
11816
11830
|
const hasPorts = routes.length > 0;
|
|
11817
11831
|
process.stderr.write("✅ Sandbox ");
|
|
11818
|
-
process.stdout.write(source_default.cyan(sandbox.
|
|
11832
|
+
process.stdout.write(source_default.cyan(sandbox.name));
|
|
11819
11833
|
process.stderr.write(" created.\n");
|
|
11820
11834
|
process.stderr.write(source_default.dim(" │ ") + "team: " + source_default.cyan(teamDisplay) + "\n");
|
|
11821
11835
|
if (hasPorts) {
|
|
@@ -11854,49 +11868,73 @@ function omit(obj, ...keys) {
|
|
|
11854
11868
|
|
|
11855
11869
|
//#endregion
|
|
11856
11870
|
//#region src/commands/run.ts
|
|
11857
|
-
var import_cjs$
|
|
11871
|
+
var import_cjs$13 = /* @__PURE__ */ __toESM(require_cjs());
|
|
11858
11872
|
const args$1 = {
|
|
11859
11873
|
...args$2,
|
|
11860
11874
|
...omit(args$3, "sandbox"),
|
|
11861
|
-
removeAfterUse: import_cjs$
|
|
11875
|
+
removeAfterUse: import_cjs$13.flag({
|
|
11862
11876
|
long: "rm",
|
|
11863
11877
|
description: "Automatically remove the sandbox when the command exits."
|
|
11864
11878
|
})
|
|
11865
11879
|
};
|
|
11866
|
-
const run = import_cjs$
|
|
11880
|
+
const run = import_cjs$13.command({
|
|
11867
11881
|
name: "run",
|
|
11868
11882
|
description: "Create and run a command in a sandbox",
|
|
11869
11883
|
args: args$1,
|
|
11870
11884
|
async handler({ removeAfterUse, ...rest$1 }) {
|
|
11871
|
-
|
|
11885
|
+
let sandbox;
|
|
11886
|
+
if (rest$1.name) try {
|
|
11887
|
+
sandbox = await sandboxClient.get({
|
|
11888
|
+
name: rest$1.name,
|
|
11889
|
+
projectId: rest$1.scope.project,
|
|
11890
|
+
teamId: rest$1.scope.team,
|
|
11891
|
+
token: rest$1.scope.token,
|
|
11892
|
+
resume: true,
|
|
11893
|
+
__includeSystemRoutes: true
|
|
11894
|
+
});
|
|
11895
|
+
} catch (error) {
|
|
11896
|
+
if (error instanceof StyledError && error.cause instanceof APIError && error.cause.response.status === 404) sandbox = await create.handler({ ...rest$1 });
|
|
11897
|
+
else throw error;
|
|
11898
|
+
}
|
|
11899
|
+
else sandbox = await create.handler({ ...rest$1 });
|
|
11872
11900
|
try {
|
|
11873
11901
|
await exec.handler({
|
|
11874
11902
|
...rest$1,
|
|
11875
11903
|
sandbox
|
|
11876
11904
|
});
|
|
11877
11905
|
} finally {
|
|
11878
|
-
if (removeAfterUse) await sandbox.
|
|
11906
|
+
if (removeAfterUse) await sandbox.delete();
|
|
11879
11907
|
}
|
|
11880
11908
|
}
|
|
11881
11909
|
});
|
|
11882
11910
|
|
|
11883
11911
|
//#endregion
|
|
11884
11912
|
//#region src/commands/list.ts
|
|
11885
|
-
var import_cjs$
|
|
11913
|
+
var import_cjs$12 = /* @__PURE__ */ __toESM(require_cjs());
|
|
11886
11914
|
init_source();
|
|
11887
|
-
const list = import_cjs$
|
|
11915
|
+
const list = import_cjs$12.command({
|
|
11888
11916
|
name: "list",
|
|
11889
11917
|
aliases: ["ls"],
|
|
11890
11918
|
description: "List all sandboxes for the specified account and project.",
|
|
11891
11919
|
args: {
|
|
11892
|
-
all: import_cjs$
|
|
11920
|
+
all: import_cjs$12.flag({
|
|
11893
11921
|
long: "all",
|
|
11894
11922
|
short: "a",
|
|
11895
11923
|
description: "Show all sandboxes (default shows just running)"
|
|
11896
11924
|
}),
|
|
11925
|
+
namePrefix: import_cjs$12.option({
|
|
11926
|
+
long: "name-prefix",
|
|
11927
|
+
description: "Filter sandboxes by name prefix",
|
|
11928
|
+
type: import_cjs$12.optional(import_cjs$12.string)
|
|
11929
|
+
}),
|
|
11930
|
+
sortBy: import_cjs$12.option({
|
|
11931
|
+
long: "sort-by",
|
|
11932
|
+
description: "Sort sandboxes by field. Options: createdAt (default), name",
|
|
11933
|
+
type: import_cjs$12.optional(import_cjs$12.oneOf(["createdAt", "name"]))
|
|
11934
|
+
}),
|
|
11897
11935
|
scope
|
|
11898
11936
|
},
|
|
11899
|
-
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, all }) {
|
|
11937
|
+
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, all, namePrefix, sortBy }) {
|
|
11900
11938
|
const sandboxes = await (async () => {
|
|
11901
11939
|
try {
|
|
11902
11940
|
var _usingCtx$1 = _usingCtx();
|
|
@@ -11905,7 +11943,9 @@ const list = import_cjs$9.command({
|
|
|
11905
11943
|
token: token$1,
|
|
11906
11944
|
teamId: team$1,
|
|
11907
11945
|
projectId: project$1,
|
|
11908
|
-
limit: 100
|
|
11946
|
+
limit: 100,
|
|
11947
|
+
...namePrefix && { namePrefix },
|
|
11948
|
+
...sortBy && { sortBy }
|
|
11909
11949
|
});
|
|
11910
11950
|
let sandboxes$1 = json.sandboxes;
|
|
11911
11951
|
if (!all) sandboxes$1 = sandboxes$1.filter((x) => x.status === "running");
|
|
@@ -11921,7 +11961,7 @@ const list = import_cjs$9.command({
|
|
|
11921
11961
|
unit: "megabyte"
|
|
11922
11962
|
});
|
|
11923
11963
|
const columns = {
|
|
11924
|
-
|
|
11964
|
+
NAME: { value: (s$1) => s$1.name },
|
|
11925
11965
|
STATUS: {
|
|
11926
11966
|
value: (s$1) => s$1.status,
|
|
11927
11967
|
color: (s$1) => SandboxStatusColor[s$1.status] ?? source_default.reset
|
|
@@ -11931,11 +11971,11 @@ const list = import_cjs$9.command({
|
|
|
11931
11971
|
VCPUS: { value: (s$1) => s$1.vcpus },
|
|
11932
11972
|
RUNTIME: { value: (s$1) => s$1.runtime },
|
|
11933
11973
|
TIMEOUT: { value: (s$1) => timeAgo(s$1.createdAt + s$1.timeout) },
|
|
11934
|
-
SNAPSHOT: { value: (s$1) => s$1.
|
|
11974
|
+
SNAPSHOT: { value: (s$1) => s$1.currentSnapshotId ?? "-" }
|
|
11935
11975
|
};
|
|
11936
11976
|
if (all) {
|
|
11937
|
-
columns.CPU = { value: (s$1) => s$1.
|
|
11938
|
-
columns["NETWORK (OUT/IN)"] = { value: (s$1) => s$1.
|
|
11977
|
+
columns.CPU = { value: (s$1) => s$1.totalActiveCpuDurationMs ? formatRunDuration(s$1.totalActiveCpuDurationMs) : "-" };
|
|
11978
|
+
columns["NETWORK (OUT/IN)"] = { value: (s$1) => s$1.totalEgressBytes || s$1.totalIngressBytes ? `${formatBytes(s$1.totalEgressBytes ?? 0)} / ${formatBytes(s$1.totalIngressBytes ?? 0)}` : "- / -" };
|
|
11939
11979
|
}
|
|
11940
11980
|
console.log(table({
|
|
11941
11981
|
rows: sandboxes,
|
|
@@ -11955,8 +11995,8 @@ const SandboxStatusColor = {
|
|
|
11955
11995
|
|
|
11956
11996
|
//#endregion
|
|
11957
11997
|
//#region src/commands/connect.ts
|
|
11958
|
-
var import_cjs$
|
|
11959
|
-
const connect = import_cjs$
|
|
11998
|
+
var import_cjs$11 = /* @__PURE__ */ __toESM(require_cjs());
|
|
11999
|
+
const connect = import_cjs$11.command({
|
|
11960
12000
|
name: "connect",
|
|
11961
12001
|
aliases: ["ssh", "shell"],
|
|
11962
12002
|
description: "Start an interactive shell in an existing sandbox",
|
|
@@ -14257,32 +14297,31 @@ var Listr = class {
|
|
|
14257
14297
|
|
|
14258
14298
|
//#endregion
|
|
14259
14299
|
//#region src/commands/stop.ts
|
|
14260
|
-
var import_cjs$
|
|
14261
|
-
const stop = import_cjs$
|
|
14300
|
+
var import_cjs$10 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14301
|
+
const stop = import_cjs$10.command({
|
|
14262
14302
|
name: "stop",
|
|
14263
|
-
|
|
14264
|
-
description: "Stop one or more running sandboxes",
|
|
14303
|
+
description: "Stop the current session of one or more sandboxes",
|
|
14265
14304
|
args: {
|
|
14266
|
-
|
|
14267
|
-
type:
|
|
14268
|
-
description: "
|
|
14305
|
+
sandboxName: import_cjs$10.positional({
|
|
14306
|
+
type: sandboxName,
|
|
14307
|
+
description: "A sandbox name to stop"
|
|
14269
14308
|
}),
|
|
14270
|
-
|
|
14271
|
-
type:
|
|
14272
|
-
description: "
|
|
14309
|
+
sandboxNames: import_cjs$10.restPositionals({
|
|
14310
|
+
type: sandboxName,
|
|
14311
|
+
description: "More sandboxes to stop"
|
|
14273
14312
|
}),
|
|
14274
14313
|
scope
|
|
14275
14314
|
},
|
|
14276
|
-
async handler({ scope: { token: token$1, team: team$1, project: project$1 },
|
|
14277
|
-
await new Listr(Array.from(new Set([
|
|
14315
|
+
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandboxName: sandboxName$1, sandboxNames }) {
|
|
14316
|
+
await new Listr(Array.from(new Set([sandboxName$1, ...sandboxNames]), (sandboxName$2) => {
|
|
14278
14317
|
return {
|
|
14279
|
-
title: `Stopping sandbox ${
|
|
14318
|
+
title: `Stopping sandbox ${sandboxName$2}`,
|
|
14280
14319
|
async task() {
|
|
14281
14320
|
await (await sandboxClient.get({
|
|
14282
14321
|
token: token$1,
|
|
14283
14322
|
teamId: team$1,
|
|
14284
14323
|
projectId: project$1,
|
|
14285
|
-
|
|
14324
|
+
name: sandboxName$2
|
|
14286
14325
|
})).stop();
|
|
14287
14326
|
}
|
|
14288
14327
|
};
|
|
@@ -14290,9 +14329,46 @@ const stop = import_cjs$7.command({
|
|
|
14290
14329
|
}
|
|
14291
14330
|
});
|
|
14292
14331
|
|
|
14332
|
+
//#endregion
|
|
14333
|
+
//#region src/commands/remove.ts
|
|
14334
|
+
var import_cjs$9 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14335
|
+
const remove = import_cjs$9.command({
|
|
14336
|
+
name: "remove",
|
|
14337
|
+
aliases: ["rm"],
|
|
14338
|
+
description: "Permanently remove one or more sandboxes",
|
|
14339
|
+
args: {
|
|
14340
|
+
sandboxName: import_cjs$9.positional({
|
|
14341
|
+
type: sandboxName,
|
|
14342
|
+
description: "a sandbox name to remove"
|
|
14343
|
+
}),
|
|
14344
|
+
sandboxNames: import_cjs$9.restPositionals({
|
|
14345
|
+
type: sandboxName,
|
|
14346
|
+
description: "more sandboxes to remove"
|
|
14347
|
+
}),
|
|
14348
|
+
preserveSnapshots: import_cjs$9.flag({
|
|
14349
|
+
long: "preserve-snapshots",
|
|
14350
|
+
description: "Keep snapshots when removing the sandbox"
|
|
14351
|
+
}),
|
|
14352
|
+
scope
|
|
14353
|
+
},
|
|
14354
|
+
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandboxName: sandboxName$1, sandboxNames, preserveSnapshots }) {
|
|
14355
|
+
await new Listr(Array.from(new Set([sandboxName$1, ...sandboxNames]), (name) => ({
|
|
14356
|
+
title: `Removing sandbox ${name}`,
|
|
14357
|
+
async task() {
|
|
14358
|
+
await (await sandboxClient.get({
|
|
14359
|
+
token: token$1,
|
|
14360
|
+
teamId: team$1,
|
|
14361
|
+
projectId: project$1,
|
|
14362
|
+
name
|
|
14363
|
+
})).delete({ preserveSnapshots });
|
|
14364
|
+
}
|
|
14365
|
+
})), { concurrent: true }).run();
|
|
14366
|
+
}
|
|
14367
|
+
});
|
|
14368
|
+
|
|
14293
14369
|
//#endregion
|
|
14294
14370
|
//#region src/commands/cp.ts
|
|
14295
|
-
var import_cjs$
|
|
14371
|
+
var import_cjs$8 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14296
14372
|
init_source();
|
|
14297
14373
|
const parseLocalOrRemotePath = async (input) => {
|
|
14298
14374
|
const parts = input.split(":");
|
|
@@ -14300,12 +14376,12 @@ const parseLocalOrRemotePath = async (input) => {
|
|
|
14300
14376
|
const [id, path$1] = parts;
|
|
14301
14377
|
if (!id || !path$1) throw new Error([
|
|
14302
14378
|
`Invalid copy path format: "${input}".`,
|
|
14303
|
-
`${source_default.bold("hint:")} Expected format:
|
|
14379
|
+
`${source_default.bold("hint:")} Expected format: SANDBOX_NAME:PATH (e.g., my-sandbox:/home/user/file.txt).`,
|
|
14304
14380
|
"╰▶ Local paths should not contain colons."
|
|
14305
14381
|
].join("\n"));
|
|
14306
14382
|
return {
|
|
14307
14383
|
type: "remote",
|
|
14308
|
-
|
|
14384
|
+
sandboxName: await sandboxName.from(id),
|
|
14309
14385
|
path: path$1
|
|
14310
14386
|
};
|
|
14311
14387
|
}
|
|
@@ -14314,20 +14390,20 @@ const parseLocalOrRemotePath = async (input) => {
|
|
|
14314
14390
|
path: input
|
|
14315
14391
|
};
|
|
14316
14392
|
};
|
|
14317
|
-
const localOrRemote = import_cjs$
|
|
14318
|
-
const cp = import_cjs$
|
|
14393
|
+
const localOrRemote = import_cjs$8.extendType(import_cjs$8.string, { from: parseLocalOrRemotePath });
|
|
14394
|
+
const cp = import_cjs$8.command({
|
|
14319
14395
|
name: "copy",
|
|
14320
14396
|
description: "Copy files between your local filesystem and a remote sandbox",
|
|
14321
14397
|
aliases: ["cp"],
|
|
14322
14398
|
args: {
|
|
14323
|
-
source: import_cjs$
|
|
14399
|
+
source: import_cjs$8.positional({
|
|
14324
14400
|
displayName: `src`,
|
|
14325
|
-
description: `The source file to copy from local file system, or
|
|
14401
|
+
description: `The source file to copy from local file system, or a sandbox_name:path from a remote sandbox`,
|
|
14326
14402
|
type: localOrRemote
|
|
14327
14403
|
}),
|
|
14328
|
-
dest: import_cjs$
|
|
14404
|
+
dest: import_cjs$8.positional({
|
|
14329
14405
|
displayName: `dst`,
|
|
14330
|
-
description: `The destination file to copy to local file system, or
|
|
14406
|
+
description: `The destination file to copy to local file system, or a sandbox_name:path to a remote sandbox`,
|
|
14331
14407
|
type: localOrRemote
|
|
14332
14408
|
}),
|
|
14333
14409
|
scope
|
|
@@ -14341,7 +14417,7 @@ const cp = import_cjs$6.command({
|
|
|
14341
14417
|
});
|
|
14342
14418
|
else {
|
|
14343
14419
|
const file = await (await sandboxClient.get({
|
|
14344
|
-
|
|
14420
|
+
name: source.sandboxName,
|
|
14345
14421
|
teamId: scope$1.team,
|
|
14346
14422
|
token: scope$1.token,
|
|
14347
14423
|
projectId: scope$1.project
|
|
@@ -14351,14 +14427,14 @@ const cp = import_cjs$6.command({
|
|
|
14351
14427
|
if (!sourceFile) {
|
|
14352
14428
|
if (source.type === "remote") {
|
|
14353
14429
|
const dir = path.dirname(source.path);
|
|
14354
|
-
spinner.fail([`File not found: ${source.path} in sandbox ${source.
|
|
14430
|
+
spinner.fail([`File not found: ${source.path} in sandbox ${source.sandboxName}.`, `${source_default.bold("hint:")} Verify the file path exists using \`sandbox exec ${source.sandboxName} ls ${dir}\`.`].join("\n"));
|
|
14355
14431
|
} else spinner.fail(`Source file (${source.path}) not found.`);
|
|
14356
14432
|
return;
|
|
14357
14433
|
}
|
|
14358
14434
|
spinner.text = `Writing to destination file (${dest.path})...`;
|
|
14359
14435
|
if (dest.type === "local") await fs.writeFile(dest.path, sourceFile);
|
|
14360
14436
|
else await (await sandboxClient.get({
|
|
14361
|
-
|
|
14437
|
+
name: dest.sandboxName,
|
|
14362
14438
|
teamId: scope$1.team,
|
|
14363
14439
|
projectId: scope$1.project,
|
|
14364
14440
|
token: scope$1.token
|
|
@@ -14372,10 +14448,10 @@ const cp = import_cjs$6.command({
|
|
|
14372
14448
|
|
|
14373
14449
|
//#endregion
|
|
14374
14450
|
//#region src/commands/logout.ts
|
|
14375
|
-
var import_cjs$
|
|
14451
|
+
var import_cjs$7 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14376
14452
|
init_source();
|
|
14377
14453
|
const debug = createDebugger("sandbox:logout");
|
|
14378
|
-
const logout = import_cjs$
|
|
14454
|
+
const logout = import_cjs$7.command({
|
|
14379
14455
|
name: "logout",
|
|
14380
14456
|
description: "Log out of the Sandbox CLI",
|
|
14381
14457
|
args: {},
|
|
@@ -14394,45 +14470,45 @@ const logout = import_cjs$5.command({
|
|
|
14394
14470
|
|
|
14395
14471
|
//#endregion
|
|
14396
14472
|
//#region src/commands/snapshot.ts
|
|
14397
|
-
var import_cjs$
|
|
14473
|
+
var import_cjs$6 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14398
14474
|
init_source();
|
|
14399
|
-
var import_ms = /* @__PURE__ */ __toESM(require_ms());
|
|
14475
|
+
var import_ms$1 = /* @__PURE__ */ __toESM(require_ms());
|
|
14400
14476
|
const args = {
|
|
14401
|
-
stop: import_cjs$
|
|
14477
|
+
stop: import_cjs$6.flag({
|
|
14402
14478
|
long: "stop",
|
|
14403
14479
|
description: "Confirm that the sandbox will be stopped when snapshotting"
|
|
14404
14480
|
}),
|
|
14405
|
-
silent: import_cjs$
|
|
14481
|
+
silent: import_cjs$6.flag({
|
|
14406
14482
|
long: "silent",
|
|
14407
14483
|
description: "Don't write snapshot ID to stdout"
|
|
14408
14484
|
}),
|
|
14409
|
-
expiration: import_cjs$
|
|
14485
|
+
expiration: import_cjs$6.option({
|
|
14410
14486
|
long: "expiration",
|
|
14411
|
-
type: import_cjs$
|
|
14487
|
+
type: import_cjs$6.optional(Duration),
|
|
14412
14488
|
description: "The expiration time of the snapshot. Use 0 for no expiration."
|
|
14413
14489
|
}),
|
|
14414
|
-
sandbox: import_cjs$
|
|
14490
|
+
sandbox: import_cjs$6.positional({ type: sandboxName }),
|
|
14415
14491
|
scope
|
|
14416
14492
|
};
|
|
14417
|
-
const snapshot = import_cjs$
|
|
14493
|
+
const snapshot = import_cjs$6.command({
|
|
14418
14494
|
name: "snapshot",
|
|
14419
14495
|
description: "Take a snapshot of the filesystem of a sandbox",
|
|
14420
14496
|
args,
|
|
14421
|
-
async handler({ sandbox:
|
|
14497
|
+
async handler({ sandbox: sandboxName$1, stop: stop$1, scope: { token: token$1, team: team$1, project: project$1 }, silent, expiration }) {
|
|
14422
14498
|
if (!stop$1) {
|
|
14423
|
-
console.error(["Snapshotting
|
|
14499
|
+
console.error(["Snapshotting will stop the current session of this sandbox.", `${source_default.bold("hint:")} Confirm with --stop to continue.`].join("\n"));
|
|
14424
14500
|
process.exitCode = 1;
|
|
14425
14501
|
return;
|
|
14426
14502
|
}
|
|
14427
|
-
const sandbox = typeof
|
|
14428
|
-
|
|
14503
|
+
const sandbox = typeof sandboxName$1 !== "string" ? sandboxName$1 : await sandboxClient.get({
|
|
14504
|
+
name: sandboxName$1,
|
|
14429
14505
|
projectId: project$1,
|
|
14430
14506
|
teamId: team$1,
|
|
14431
14507
|
token: token$1
|
|
14432
14508
|
});
|
|
14433
14509
|
if (!["running"].includes(sandbox.status)) {
|
|
14434
14510
|
console.error([
|
|
14435
|
-
`Sandbox ${sandbox.
|
|
14511
|
+
`Sandbox ${sandbox.name} is not available (status: ${sandbox.status}).`,
|
|
14436
14512
|
`${source_default.bold("hint:")} Only 'running' sandboxes can be snapshotted.`,
|
|
14437
14513
|
"├▶ Use `sandbox list` to check sandbox status.",
|
|
14438
14514
|
"╰▶ Use `sandbox create` to create a new sandbox."
|
|
@@ -14441,17 +14517,17 @@ const snapshot = import_cjs$4.command({
|
|
|
14441
14517
|
return;
|
|
14442
14518
|
}
|
|
14443
14519
|
const spinner = silent ? void 0 : ora("Creating snapshot...").start();
|
|
14444
|
-
const snapshot$1 = await sandbox.snapshot({ expiration: expiration === void 0 ? void 0 : (0, import_ms.default)(expiration) });
|
|
14520
|
+
const snapshot$1 = await sandbox.snapshot({ expiration: expiration === void 0 ? void 0 : (0, import_ms$1.default)(expiration) });
|
|
14445
14521
|
spinner?.succeed(`Snapshot ${snapshot$1.snapshotId} created.`);
|
|
14446
14522
|
}
|
|
14447
14523
|
});
|
|
14448
14524
|
|
|
14449
14525
|
//#endregion
|
|
14450
14526
|
//#region src/commands/snapshots.ts
|
|
14451
|
-
var import_cjs$
|
|
14452
|
-
var import_cjs$
|
|
14527
|
+
var import_cjs$4 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14528
|
+
var import_cjs$5 = require_cjs();
|
|
14453
14529
|
init_source();
|
|
14454
|
-
const list$
|
|
14530
|
+
const list$2 = import_cjs$4.command({
|
|
14455
14531
|
name: "list",
|
|
14456
14532
|
aliases: ["ls"],
|
|
14457
14533
|
description: "List snapshots for the specified account and project.",
|
|
@@ -14485,19 +14561,19 @@ const list$1 = import_cjs$2.command({
|
|
|
14485
14561
|
CREATED: { value: (s$1) => timeAgo(s$1.createdAt) },
|
|
14486
14562
|
EXPIRATION: { value: (s$1) => s$1.status === "deleted" ? source_default.gray.dim("deleted") : timeAgo(s$1.expiresAt) },
|
|
14487
14563
|
SIZE: { value: (s$1) => formatBytes(s$1.sizeBytes) },
|
|
14488
|
-
["SOURCE
|
|
14564
|
+
["SOURCE SESSION"]: { value: (s$1) => s$1.sourceSandboxId }
|
|
14489
14565
|
}
|
|
14490
14566
|
}));
|
|
14491
14567
|
}
|
|
14492
14568
|
});
|
|
14493
|
-
const get = import_cjs$
|
|
14569
|
+
const get = import_cjs$4.command({
|
|
14494
14570
|
name: "get",
|
|
14495
14571
|
description: "Get details of a snapshot.",
|
|
14496
14572
|
args: {
|
|
14497
14573
|
scope,
|
|
14498
|
-
snapshotId: import_cjs$
|
|
14574
|
+
snapshotId: import_cjs$4.positional({
|
|
14499
14575
|
type: snapshotId,
|
|
14500
|
-
description: "
|
|
14576
|
+
description: "Snapshot ID to retrieve"
|
|
14501
14577
|
})
|
|
14502
14578
|
},
|
|
14503
14579
|
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, snapshotId: id }) {
|
|
@@ -14528,21 +14604,21 @@ const get = import_cjs$2.command({
|
|
|
14528
14604
|
CREATED: { value: (s$1) => timeAgo(s$1.createdAt) },
|
|
14529
14605
|
EXPIRATION: { value: (s$1) => s$1.status === "deleted" ? source_default.gray.dim("deleted") : timeAgo(s$1.expiresAt) },
|
|
14530
14606
|
SIZE: { value: (s$1) => formatBytes(s$1.sizeBytes) },
|
|
14531
|
-
["SOURCE
|
|
14607
|
+
["SOURCE SESSION"]: { value: (s$1) => s$1.sourceSandboxId }
|
|
14532
14608
|
}
|
|
14533
14609
|
}));
|
|
14534
14610
|
}
|
|
14535
14611
|
});
|
|
14536
|
-
const remove = import_cjs$
|
|
14612
|
+
const remove$1 = import_cjs$4.command({
|
|
14537
14613
|
name: "delete",
|
|
14538
14614
|
aliases: ["rm", "remove"],
|
|
14539
14615
|
description: "Delete one or more snapshots.",
|
|
14540
14616
|
args: {
|
|
14541
|
-
snapshotId: import_cjs$
|
|
14617
|
+
snapshotId: import_cjs$4.positional({
|
|
14542
14618
|
type: snapshotId,
|
|
14543
|
-
description: "
|
|
14619
|
+
description: "Snapshot ID to delete"
|
|
14544
14620
|
}),
|
|
14545
|
-
snapshotIds: import_cjs$
|
|
14621
|
+
snapshotIds: import_cjs$4.restPositionals({
|
|
14546
14622
|
type: snapshotId,
|
|
14547
14623
|
description: "More snapshots IDs to delete"
|
|
14548
14624
|
}),
|
|
@@ -14566,13 +14642,13 @@ const remove = import_cjs$2.command({
|
|
|
14566
14642
|
}), { concurrent: true }).run();
|
|
14567
14643
|
}
|
|
14568
14644
|
});
|
|
14569
|
-
const snapshots = (0, import_cjs$
|
|
14645
|
+
const snapshots = (0, import_cjs$5.subcommands)({
|
|
14570
14646
|
name: "snapshots",
|
|
14571
14647
|
description: "Manage sandbox snapshots",
|
|
14572
14648
|
cmds: {
|
|
14573
|
-
list: list$
|
|
14649
|
+
list: list$2,
|
|
14574
14650
|
get,
|
|
14575
|
-
delete: remove
|
|
14651
|
+
delete: remove$1
|
|
14576
14652
|
}
|
|
14577
14653
|
});
|
|
14578
14654
|
const SnapshotStatusColor = new Map([
|
|
@@ -14581,16 +14657,201 @@ const SnapshotStatusColor = new Map([
|
|
|
14581
14657
|
["failed", source_default.red]
|
|
14582
14658
|
]);
|
|
14583
14659
|
|
|
14660
|
+
//#endregion
|
|
14661
|
+
//#region src/commands/sessions.ts
|
|
14662
|
+
var import_cjs$2 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14663
|
+
var import_cjs$3 = require_cjs();
|
|
14664
|
+
init_source();
|
|
14665
|
+
const list$1 = import_cjs$2.command({
|
|
14666
|
+
name: "list",
|
|
14667
|
+
aliases: ["ls"],
|
|
14668
|
+
description: "List sessions from a sandbox",
|
|
14669
|
+
args: {
|
|
14670
|
+
sandbox: import_cjs$2.positional({
|
|
14671
|
+
type: sandboxName,
|
|
14672
|
+
description: "Sandbox name to list sessions for"
|
|
14673
|
+
}),
|
|
14674
|
+
scope
|
|
14675
|
+
},
|
|
14676
|
+
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandbox: name }) {
|
|
14677
|
+
const sandbox = await sandboxClient.get({
|
|
14678
|
+
name,
|
|
14679
|
+
projectId: project$1,
|
|
14680
|
+
teamId: team$1,
|
|
14681
|
+
token: token$1
|
|
14682
|
+
});
|
|
14683
|
+
const sessions$1 = (await (async () => {
|
|
14684
|
+
try {
|
|
14685
|
+
var _usingCtx$1 = _usingCtx();
|
|
14686
|
+
const _spinner$1 = _usingCtx$1.u(acquireRelease(() => ora("Fetching sessions...").start(), (s$1) => s$1.stop()));
|
|
14687
|
+
return sandbox.listSessions();
|
|
14688
|
+
} catch (_) {
|
|
14689
|
+
_usingCtx$1.e = _;
|
|
14690
|
+
} finally {
|
|
14691
|
+
_usingCtx$1.d();
|
|
14692
|
+
}
|
|
14693
|
+
})()).json.sandboxes;
|
|
14694
|
+
console.log(table({
|
|
14695
|
+
rows: sessions$1,
|
|
14696
|
+
columns: {
|
|
14697
|
+
ID: { value: (s$1) => s$1.id },
|
|
14698
|
+
STATUS: {
|
|
14699
|
+
value: (s$1) => s$1.status,
|
|
14700
|
+
color: (s$1) => SessionStatusColor[s$1.status] ?? source_default.reset
|
|
14701
|
+
},
|
|
14702
|
+
CREATED: { value: (s$1) => timeAgo(s$1.createdAt) },
|
|
14703
|
+
MEMORY: { value: (s$1) => s$1.memory },
|
|
14704
|
+
VCPUS: { value: (s$1) => s$1.vcpus },
|
|
14705
|
+
RUNTIME: { value: (s$1) => s$1.runtime },
|
|
14706
|
+
TIMEOUT: { value: (s$1) => timeAgo(s$1.createdAt + s$1.timeout) },
|
|
14707
|
+
DURATION: { value: (s$1) => s$1.duration ? formatRunDuration(s$1.duration) : "-" }
|
|
14708
|
+
}
|
|
14709
|
+
}));
|
|
14710
|
+
}
|
|
14711
|
+
});
|
|
14712
|
+
const sessions = (0, import_cjs$3.subcommands)({
|
|
14713
|
+
name: "sessions",
|
|
14714
|
+
description: "Manage sandbox sessions",
|
|
14715
|
+
cmds: { list: list$1 }
|
|
14716
|
+
});
|
|
14717
|
+
const SessionStatusColor = {
|
|
14718
|
+
running: source_default.cyan,
|
|
14719
|
+
failed: source_default.red,
|
|
14720
|
+
stopped: source_default.gray.dim,
|
|
14721
|
+
stopping: source_default.gray,
|
|
14722
|
+
pending: source_default.magenta,
|
|
14723
|
+
snapshotting: source_default.blue,
|
|
14724
|
+
aborted: source_default.gray.dim
|
|
14725
|
+
};
|
|
14726
|
+
|
|
14584
14727
|
//#endregion
|
|
14585
14728
|
//#region src/commands/config.ts
|
|
14586
14729
|
var import_cjs$1 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14587
14730
|
init_source();
|
|
14731
|
+
var import_ms = /* @__PURE__ */ __toESM(require_ms());
|
|
14732
|
+
const setCommand = import_cjs$1.command({
|
|
14733
|
+
name: "set",
|
|
14734
|
+
description: "Update the configuration of a sandbox",
|
|
14735
|
+
args: {
|
|
14736
|
+
sandbox: import_cjs$1.positional({
|
|
14737
|
+
type: sandboxName,
|
|
14738
|
+
description: "Sandbox name to update"
|
|
14739
|
+
}),
|
|
14740
|
+
vcpus,
|
|
14741
|
+
runtime: import_cjs$1.option({
|
|
14742
|
+
long: "runtime",
|
|
14743
|
+
type: import_cjs$1.optional(runtimeType),
|
|
14744
|
+
description: "Runtime to use: node22, node24, or python3.13"
|
|
14745
|
+
}),
|
|
14746
|
+
timeout: import_cjs$1.option({
|
|
14747
|
+
long: "timeout",
|
|
14748
|
+
type: import_cjs$1.optional(Duration),
|
|
14749
|
+
description: "The maximum duration a sandbox can run for. Example: 5m, 1h"
|
|
14750
|
+
}),
|
|
14751
|
+
...networkPolicyArgs,
|
|
14752
|
+
scope
|
|
14753
|
+
},
|
|
14754
|
+
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandbox: name, vcpus: vcpus$1, runtime: runtime$1, timeout: timeout$1, networkPolicy: networkPolicyMode$1, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 }) {
|
|
14755
|
+
const hasNetworkPolicyArgs = networkPolicyMode$1 !== void 0 || allowedDomains$1.length > 0 || allowedCIDRs$1.length > 0 || deniedCIDRs$1.length > 0;
|
|
14756
|
+
if (vcpus$1 === void 0 && runtime$1 === void 0 && timeout$1 === void 0 && !hasNetworkPolicyArgs) throw new Error([`At least one option must be provided.`, `${source_default.bold("hint:")} Use --vcpus, --runtime, --timeout, or --network-policy to update the sandbox configuration.`].join("\n"));
|
|
14757
|
+
const networkPolicy$1 = hasNetworkPolicyArgs ? buildNetworkPolicy({
|
|
14758
|
+
networkPolicy: networkPolicyMode$1,
|
|
14759
|
+
allowedDomains: allowedDomains$1,
|
|
14760
|
+
allowedCIDRs: allowedCIDRs$1,
|
|
14761
|
+
deniedCIDRs: deniedCIDRs$1
|
|
14762
|
+
}) : void 0;
|
|
14763
|
+
const sandbox = await sandboxClient.get({
|
|
14764
|
+
name,
|
|
14765
|
+
projectId: project$1,
|
|
14766
|
+
teamId: team$1,
|
|
14767
|
+
token: token$1
|
|
14768
|
+
});
|
|
14769
|
+
const spinner = ora("Updating sandbox configuration...").start();
|
|
14770
|
+
try {
|
|
14771
|
+
await sandbox.update({
|
|
14772
|
+
...vcpus$1 !== void 0 && { resources: { vcpus: vcpus$1 } },
|
|
14773
|
+
...runtime$1 !== void 0 && { runtime: runtime$1 },
|
|
14774
|
+
...timeout$1 !== void 0 && { timeout: (0, import_ms.default)(timeout$1) },
|
|
14775
|
+
...networkPolicy$1 !== void 0 && { networkPolicy: networkPolicy$1 }
|
|
14776
|
+
});
|
|
14777
|
+
spinner.succeed("Configuration updated for sandbox " + source_default.cyan(name));
|
|
14778
|
+
} catch (error) {
|
|
14779
|
+
spinner.stop();
|
|
14780
|
+
throw error;
|
|
14781
|
+
}
|
|
14782
|
+
}
|
|
14783
|
+
});
|
|
14784
|
+
const getCommand = import_cjs$1.command({
|
|
14785
|
+
name: "get",
|
|
14786
|
+
description: "Display the current configuration of a sandbox",
|
|
14787
|
+
args: {
|
|
14788
|
+
sandbox: import_cjs$1.positional({
|
|
14789
|
+
type: sandboxName,
|
|
14790
|
+
description: "Sandbox name to inspect"
|
|
14791
|
+
}),
|
|
14792
|
+
scope
|
|
14793
|
+
},
|
|
14794
|
+
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandbox: name }) {
|
|
14795
|
+
const sandbox = await (async () => {
|
|
14796
|
+
try {
|
|
14797
|
+
var _usingCtx$1 = _usingCtx();
|
|
14798
|
+
const _spinner$1 = _usingCtx$1.u(acquireRelease(() => ora("Fetching sandbox configuration...").start(), (s$1) => s$1.stop()));
|
|
14799
|
+
return sandboxClient.get({
|
|
14800
|
+
name,
|
|
14801
|
+
projectId: project$1,
|
|
14802
|
+
teamId: team$1,
|
|
14803
|
+
token: token$1
|
|
14804
|
+
});
|
|
14805
|
+
} catch (_) {
|
|
14806
|
+
_usingCtx$1.e = _;
|
|
14807
|
+
} finally {
|
|
14808
|
+
_usingCtx$1.d();
|
|
14809
|
+
}
|
|
14810
|
+
})();
|
|
14811
|
+
const memoryFormatter = new Intl.NumberFormat(void 0, {
|
|
14812
|
+
style: "unit",
|
|
14813
|
+
unit: "megabyte"
|
|
14814
|
+
});
|
|
14815
|
+
const rows = [
|
|
14816
|
+
{
|
|
14817
|
+
field: "Runtime",
|
|
14818
|
+
value: sandbox.runtime
|
|
14819
|
+
},
|
|
14820
|
+
{
|
|
14821
|
+
field: "vCPUs",
|
|
14822
|
+
value: String(sandbox.vcpus)
|
|
14823
|
+
},
|
|
14824
|
+
{
|
|
14825
|
+
field: "Memory",
|
|
14826
|
+
value: memoryFormatter.format(sandbox.memory)
|
|
14827
|
+
},
|
|
14828
|
+
{
|
|
14829
|
+
field: "Timeout",
|
|
14830
|
+
value: (0, import_ms.default)(sandbox.timeout, { long: true })
|
|
14831
|
+
},
|
|
14832
|
+
{
|
|
14833
|
+
field: "Region",
|
|
14834
|
+
value: sandbox.region
|
|
14835
|
+
}
|
|
14836
|
+
];
|
|
14837
|
+
console.log(table({
|
|
14838
|
+
rows,
|
|
14839
|
+
columns: {
|
|
14840
|
+
FIELD: {
|
|
14841
|
+
value: (r) => r.field,
|
|
14842
|
+
color: () => source_default.bold
|
|
14843
|
+
},
|
|
14844
|
+
VALUE: { value: (r) => r.value }
|
|
14845
|
+
}
|
|
14846
|
+
}));
|
|
14847
|
+
}
|
|
14848
|
+
});
|
|
14588
14849
|
const networkPolicyCommand = import_cjs$1.command({
|
|
14589
14850
|
name: "network-policy",
|
|
14590
14851
|
description: `Update the network policy of a sandbox.
|
|
14591
14852
|
This will fully override the previous configuration.`,
|
|
14592
14853
|
args: {
|
|
14593
|
-
sandbox: import_cjs$1.positional({ type:
|
|
14854
|
+
sandbox: import_cjs$1.positional({ type: sandboxName }),
|
|
14594
14855
|
...networkPolicyArgs,
|
|
14595
14856
|
mode: import_cjs$1.option({
|
|
14596
14857
|
long: "mode",
|
|
@@ -14599,7 +14860,8 @@ const networkPolicyCommand = import_cjs$1.command({
|
|
|
14599
14860
|
}),
|
|
14600
14861
|
scope
|
|
14601
14862
|
},
|
|
14602
|
-
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandbox:
|
|
14863
|
+
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandbox: sandboxName$1, networkPolicy: networkPolicyFlag, mode: modeFlag, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 }) {
|
|
14864
|
+
process.stderr.write(source_default.yellow("Warning: 'config network-policy' is deprecated. Use 'config set --network-policy=...' instead.\n"));
|
|
14603
14865
|
const networkPolicyMode$1 = resolveMode(networkPolicyFlag, modeFlag);
|
|
14604
14866
|
if (networkPolicyMode$1 === void 0 && allowedDomains$1.length === 0 && allowedCIDRs$1.length === 0 && deniedCIDRs$1.length === 0) throw new Error(`Network policy mode or custom rules must be set.`);
|
|
14605
14867
|
const networkPolicy$1 = buildNetworkPolicy({
|
|
@@ -14608,27 +14870,17 @@ const networkPolicyCommand = import_cjs$1.command({
|
|
|
14608
14870
|
allowedCIDRs: allowedCIDRs$1,
|
|
14609
14871
|
deniedCIDRs: deniedCIDRs$1
|
|
14610
14872
|
});
|
|
14611
|
-
const sandbox = typeof
|
|
14612
|
-
|
|
14873
|
+
const sandbox = typeof sandboxName$1 !== "string" ? sandboxName$1 : await sandboxClient.get({
|
|
14874
|
+
name: sandboxName$1,
|
|
14613
14875
|
projectId: project$1,
|
|
14614
14876
|
teamId: team$1,
|
|
14615
14877
|
token: token$1
|
|
14616
14878
|
});
|
|
14617
|
-
if (!["pending", "running"].includes(sandbox.status)) {
|
|
14618
|
-
console.error([
|
|
14619
|
-
`Sandbox ${sandbox.sandboxId} is not available (status: ${sandbox.status}).`,
|
|
14620
|
-
`${source_default.bold("hint:")} Only 'pending' or 'running' sandboxes can execute commands.`,
|
|
14621
|
-
"├▶ Use `sandbox list` to check sandbox status.",
|
|
14622
|
-
"╰▶ Use `sandbox create` to create a new sandbox."
|
|
14623
|
-
].join("\n"));
|
|
14624
|
-
process.exitCode = 1;
|
|
14625
|
-
return;
|
|
14626
|
-
}
|
|
14627
14879
|
const spinner = ora("Updating network policy...").start();
|
|
14628
14880
|
try {
|
|
14629
14881
|
const response = await sandbox.updateNetworkPolicy(networkPolicy$1);
|
|
14630
14882
|
spinner.stop();
|
|
14631
|
-
process.stderr.write("✅ Network policy updated for sandbox " + source_default.cyan(sandbox.
|
|
14883
|
+
process.stderr.write("✅ Network policy updated for sandbox " + source_default.cyan(sandbox.name) + "\n");
|
|
14632
14884
|
const mode = typeof response === "string" ? response : "restricted";
|
|
14633
14885
|
process.stderr.write(source_default.dim(" ╰ ") + "mode: " + source_default.cyan(mode) + "\n");
|
|
14634
14886
|
} catch (error) {
|
|
@@ -14639,8 +14891,12 @@ const networkPolicyCommand = import_cjs$1.command({
|
|
|
14639
14891
|
});
|
|
14640
14892
|
const config = import_cjs$1.subcommands({
|
|
14641
14893
|
name: "config",
|
|
14642
|
-
description: "
|
|
14643
|
-
cmds: {
|
|
14894
|
+
description: "View and update sandbox configuration",
|
|
14895
|
+
cmds: {
|
|
14896
|
+
set: setCommand,
|
|
14897
|
+
get: getCommand,
|
|
14898
|
+
"network-policy": networkPolicyCommand
|
|
14899
|
+
}
|
|
14644
14900
|
});
|
|
14645
14901
|
|
|
14646
14902
|
//#endregion
|
|
@@ -14658,9 +14914,11 @@ const app = (opts) => (0, import_cjs.subcommands)({
|
|
|
14658
14914
|
exec,
|
|
14659
14915
|
connect,
|
|
14660
14916
|
stop,
|
|
14917
|
+
remove,
|
|
14661
14918
|
run,
|
|
14662
14919
|
snapshot,
|
|
14663
14920
|
snapshots,
|
|
14921
|
+
sessions,
|
|
14664
14922
|
...!opts?.withoutAuth && {
|
|
14665
14923
|
login,
|
|
14666
14924
|
logout
|
|
@@ -14677,11 +14935,11 @@ const app = (opts) => (0, import_cjs.subcommands)({
|
|
|
14677
14935
|
},
|
|
14678
14936
|
{
|
|
14679
14937
|
description: "Execute command in an existing sandbox",
|
|
14680
|
-
command: `sandbox exec <
|
|
14938
|
+
command: `sandbox exec <name> -- npm test`
|
|
14681
14939
|
}
|
|
14682
14940
|
]
|
|
14683
14941
|
});
|
|
14684
14942
|
|
|
14685
14943
|
//#endregion
|
|
14686
14944
|
export { source_exports as a, init_source as i, StyledError as n, require_cjs as r, app as t };
|
|
14687
|
-
//# sourceMappingURL=app-
|
|
14945
|
+
//# sourceMappingURL=app-AqqXdE-N.mjs.map
|