sandbox 2.5.4 → 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,21 +11746,21 @@ 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
|
}),
|
|
11762
|
-
envVars: import_cjs$
|
|
11763
|
+
envVars: import_cjs$14.multioption({
|
|
11763
11764
|
long: "env",
|
|
11764
11765
|
short: "e",
|
|
11765
11766
|
type: ObjectFromKeyValue,
|
|
@@ -11768,7 +11769,7 @@ const args$2 = {
|
|
|
11768
11769
|
...networkPolicyArgs,
|
|
11769
11770
|
scope
|
|
11770
11771
|
};
|
|
11771
|
-
const create = import_cjs$
|
|
11772
|
+
const create = import_cjs$14.command({
|
|
11772
11773
|
name: "create",
|
|
11773
11774
|
description: "Create a sandbox in the specified account and project.",
|
|
11774
11775
|
args: args$2,
|
|
@@ -11776,16 +11777,18 @@ const create = import_cjs$11.command({
|
|
|
11776
11777
|
description: "Create and connect to a sandbox without a network access",
|
|
11777
11778
|
command: `sandbox run --network-policy=none --connect`
|
|
11778
11779
|
}],
|
|
11779
|
-
async handler({ 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 }) {
|
|
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 }) {
|
|
11780
11781
|
const networkPolicy$1 = buildNetworkPolicy({
|
|
11781
11782
|
networkPolicy: networkPolicyMode$1,
|
|
11782
11783
|
allowedDomains: allowedDomains$1,
|
|
11783
11784
|
allowedCIDRs: allowedCIDRs$1,
|
|
11784
11785
|
deniedCIDRs: deniedCIDRs$1
|
|
11785
11786
|
});
|
|
11787
|
+
const persistent = !nonPersistent;
|
|
11786
11788
|
const resources = vcpus$1 ? { vcpus: vcpus$1 } : void 0;
|
|
11787
11789
|
const spinner = silent ? void 0 : ora("Creating sandbox...").start();
|
|
11788
11790
|
const sandbox = snapshot$1 ? await sandboxClient.create({
|
|
11791
|
+
name,
|
|
11789
11792
|
source: {
|
|
11790
11793
|
type: "snapshot",
|
|
11791
11794
|
snapshotId: snapshot$1
|
|
@@ -11794,21 +11797,24 @@ const create = import_cjs$11.command({
|
|
|
11794
11797
|
projectId: scope$1.project,
|
|
11795
11798
|
token: scope$1.token,
|
|
11796
11799
|
ports,
|
|
11797
|
-
timeout: (0, import_ms$
|
|
11800
|
+
timeout: (0, import_ms$2.default)(timeout$1),
|
|
11798
11801
|
resources,
|
|
11799
11802
|
networkPolicy: networkPolicy$1,
|
|
11800
11803
|
env: envVars,
|
|
11804
|
+
persistent,
|
|
11801
11805
|
__interactive: true
|
|
11802
11806
|
}) : await sandboxClient.create({
|
|
11807
|
+
name,
|
|
11803
11808
|
teamId: scope$1.team,
|
|
11804
11809
|
projectId: scope$1.project,
|
|
11805
11810
|
token: scope$1.token,
|
|
11806
11811
|
ports,
|
|
11807
11812
|
runtime: runtime$1,
|
|
11808
|
-
timeout: (0, import_ms$
|
|
11813
|
+
timeout: (0, import_ms$2.default)(timeout$1),
|
|
11809
11814
|
resources,
|
|
11810
11815
|
networkPolicy: networkPolicy$1,
|
|
11811
11816
|
env: envVars,
|
|
11817
|
+
persistent,
|
|
11812
11818
|
__interactive: true
|
|
11813
11819
|
});
|
|
11814
11820
|
spinner?.stop();
|
|
@@ -11823,7 +11829,7 @@ const create = import_cjs$11.command({
|
|
|
11823
11829
|
const projectDisplay = scope$1.projectSlug ?? scope$1.project;
|
|
11824
11830
|
const hasPorts = routes.length > 0;
|
|
11825
11831
|
process.stderr.write("✅ Sandbox ");
|
|
11826
|
-
process.stdout.write(source_default.cyan(sandbox.
|
|
11832
|
+
process.stdout.write(source_default.cyan(sandbox.name));
|
|
11827
11833
|
process.stderr.write(" created.\n");
|
|
11828
11834
|
process.stderr.write(source_default.dim(" │ ") + "team: " + source_default.cyan(teamDisplay) + "\n");
|
|
11829
11835
|
if (hasPorts) {
|
|
@@ -11862,49 +11868,73 @@ function omit(obj, ...keys) {
|
|
|
11862
11868
|
|
|
11863
11869
|
//#endregion
|
|
11864
11870
|
//#region src/commands/run.ts
|
|
11865
|
-
var import_cjs$
|
|
11871
|
+
var import_cjs$13 = /* @__PURE__ */ __toESM(require_cjs());
|
|
11866
11872
|
const args$1 = {
|
|
11867
11873
|
...args$2,
|
|
11868
11874
|
...omit(args$3, "sandbox"),
|
|
11869
|
-
removeAfterUse: import_cjs$
|
|
11875
|
+
removeAfterUse: import_cjs$13.flag({
|
|
11870
11876
|
long: "rm",
|
|
11871
11877
|
description: "Automatically remove the sandbox when the command exits."
|
|
11872
11878
|
})
|
|
11873
11879
|
};
|
|
11874
|
-
const run = import_cjs$
|
|
11880
|
+
const run = import_cjs$13.command({
|
|
11875
11881
|
name: "run",
|
|
11876
11882
|
description: "Create and run a command in a sandbox",
|
|
11877
11883
|
args: args$1,
|
|
11878
11884
|
async handler({ removeAfterUse, ...rest$1 }) {
|
|
11879
|
-
|
|
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 });
|
|
11880
11900
|
try {
|
|
11881
11901
|
await exec.handler({
|
|
11882
11902
|
...rest$1,
|
|
11883
11903
|
sandbox
|
|
11884
11904
|
});
|
|
11885
11905
|
} finally {
|
|
11886
|
-
if (removeAfterUse) await sandbox.
|
|
11906
|
+
if (removeAfterUse) await sandbox.delete();
|
|
11887
11907
|
}
|
|
11888
11908
|
}
|
|
11889
11909
|
});
|
|
11890
11910
|
|
|
11891
11911
|
//#endregion
|
|
11892
11912
|
//#region src/commands/list.ts
|
|
11893
|
-
var import_cjs$
|
|
11913
|
+
var import_cjs$12 = /* @__PURE__ */ __toESM(require_cjs());
|
|
11894
11914
|
init_source();
|
|
11895
|
-
const list = import_cjs$
|
|
11915
|
+
const list = import_cjs$12.command({
|
|
11896
11916
|
name: "list",
|
|
11897
11917
|
aliases: ["ls"],
|
|
11898
11918
|
description: "List all sandboxes for the specified account and project.",
|
|
11899
11919
|
args: {
|
|
11900
|
-
all: import_cjs$
|
|
11920
|
+
all: import_cjs$12.flag({
|
|
11901
11921
|
long: "all",
|
|
11902
11922
|
short: "a",
|
|
11903
11923
|
description: "Show all sandboxes (default shows just running)"
|
|
11904
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
|
+
}),
|
|
11905
11935
|
scope
|
|
11906
11936
|
},
|
|
11907
|
-
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 }) {
|
|
11908
11938
|
const sandboxes = await (async () => {
|
|
11909
11939
|
try {
|
|
11910
11940
|
var _usingCtx$1 = _usingCtx();
|
|
@@ -11913,7 +11943,9 @@ const list = import_cjs$9.command({
|
|
|
11913
11943
|
token: token$1,
|
|
11914
11944
|
teamId: team$1,
|
|
11915
11945
|
projectId: project$1,
|
|
11916
|
-
limit: 100
|
|
11946
|
+
limit: 100,
|
|
11947
|
+
...namePrefix && { namePrefix },
|
|
11948
|
+
...sortBy && { sortBy }
|
|
11917
11949
|
});
|
|
11918
11950
|
let sandboxes$1 = json.sandboxes;
|
|
11919
11951
|
if (!all) sandboxes$1 = sandboxes$1.filter((x) => x.status === "running");
|
|
@@ -11929,7 +11961,7 @@ const list = import_cjs$9.command({
|
|
|
11929
11961
|
unit: "megabyte"
|
|
11930
11962
|
});
|
|
11931
11963
|
const columns = {
|
|
11932
|
-
|
|
11964
|
+
NAME: { value: (s$1) => s$1.name },
|
|
11933
11965
|
STATUS: {
|
|
11934
11966
|
value: (s$1) => s$1.status,
|
|
11935
11967
|
color: (s$1) => SandboxStatusColor[s$1.status] ?? source_default.reset
|
|
@@ -11939,11 +11971,11 @@ const list = import_cjs$9.command({
|
|
|
11939
11971
|
VCPUS: { value: (s$1) => s$1.vcpus },
|
|
11940
11972
|
RUNTIME: { value: (s$1) => s$1.runtime },
|
|
11941
11973
|
TIMEOUT: { value: (s$1) => timeAgo(s$1.createdAt + s$1.timeout) },
|
|
11942
|
-
SNAPSHOT: { value: (s$1) => s$1.
|
|
11974
|
+
SNAPSHOT: { value: (s$1) => s$1.currentSnapshotId ?? "-" }
|
|
11943
11975
|
};
|
|
11944
11976
|
if (all) {
|
|
11945
|
-
columns.CPU = { value: (s$1) => s$1.
|
|
11946
|
-
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)}` : "- / -" };
|
|
11947
11979
|
}
|
|
11948
11980
|
console.log(table({
|
|
11949
11981
|
rows: sandboxes,
|
|
@@ -11963,8 +11995,8 @@ const SandboxStatusColor = {
|
|
|
11963
11995
|
|
|
11964
11996
|
//#endregion
|
|
11965
11997
|
//#region src/commands/connect.ts
|
|
11966
|
-
var import_cjs$
|
|
11967
|
-
const connect = import_cjs$
|
|
11998
|
+
var import_cjs$11 = /* @__PURE__ */ __toESM(require_cjs());
|
|
11999
|
+
const connect = import_cjs$11.command({
|
|
11968
12000
|
name: "connect",
|
|
11969
12001
|
aliases: ["ssh", "shell"],
|
|
11970
12002
|
description: "Start an interactive shell in an existing sandbox",
|
|
@@ -14265,32 +14297,31 @@ var Listr = class {
|
|
|
14265
14297
|
|
|
14266
14298
|
//#endregion
|
|
14267
14299
|
//#region src/commands/stop.ts
|
|
14268
|
-
var import_cjs$
|
|
14269
|
-
const stop = import_cjs$
|
|
14300
|
+
var import_cjs$10 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14301
|
+
const stop = import_cjs$10.command({
|
|
14270
14302
|
name: "stop",
|
|
14271
|
-
|
|
14272
|
-
description: "Stop one or more running sandboxes",
|
|
14303
|
+
description: "Stop the current session of one or more sandboxes",
|
|
14273
14304
|
args: {
|
|
14274
|
-
|
|
14275
|
-
type:
|
|
14276
|
-
description: "
|
|
14305
|
+
sandboxName: import_cjs$10.positional({
|
|
14306
|
+
type: sandboxName,
|
|
14307
|
+
description: "A sandbox name to stop"
|
|
14277
14308
|
}),
|
|
14278
|
-
|
|
14279
|
-
type:
|
|
14280
|
-
description: "
|
|
14309
|
+
sandboxNames: import_cjs$10.restPositionals({
|
|
14310
|
+
type: sandboxName,
|
|
14311
|
+
description: "More sandboxes to stop"
|
|
14281
14312
|
}),
|
|
14282
14313
|
scope
|
|
14283
14314
|
},
|
|
14284
|
-
async handler({ scope: { token: token$1, team: team$1, project: project$1 },
|
|
14285
|
-
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) => {
|
|
14286
14317
|
return {
|
|
14287
|
-
title: `Stopping sandbox ${
|
|
14318
|
+
title: `Stopping sandbox ${sandboxName$2}`,
|
|
14288
14319
|
async task() {
|
|
14289
14320
|
await (await sandboxClient.get({
|
|
14290
14321
|
token: token$1,
|
|
14291
14322
|
teamId: team$1,
|
|
14292
14323
|
projectId: project$1,
|
|
14293
|
-
|
|
14324
|
+
name: sandboxName$2
|
|
14294
14325
|
})).stop();
|
|
14295
14326
|
}
|
|
14296
14327
|
};
|
|
@@ -14298,9 +14329,46 @@ const stop = import_cjs$7.command({
|
|
|
14298
14329
|
}
|
|
14299
14330
|
});
|
|
14300
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
|
+
|
|
14301
14369
|
//#endregion
|
|
14302
14370
|
//#region src/commands/cp.ts
|
|
14303
|
-
var import_cjs$
|
|
14371
|
+
var import_cjs$8 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14304
14372
|
init_source();
|
|
14305
14373
|
const parseLocalOrRemotePath = async (input) => {
|
|
14306
14374
|
const parts = input.split(":");
|
|
@@ -14308,12 +14376,12 @@ const parseLocalOrRemotePath = async (input) => {
|
|
|
14308
14376
|
const [id, path$1] = parts;
|
|
14309
14377
|
if (!id || !path$1) throw new Error([
|
|
14310
14378
|
`Invalid copy path format: "${input}".`,
|
|
14311
|
-
`${source_default.bold("hint:")} Expected format:
|
|
14379
|
+
`${source_default.bold("hint:")} Expected format: SANDBOX_NAME:PATH (e.g., my-sandbox:/home/user/file.txt).`,
|
|
14312
14380
|
"╰▶ Local paths should not contain colons."
|
|
14313
14381
|
].join("\n"));
|
|
14314
14382
|
return {
|
|
14315
14383
|
type: "remote",
|
|
14316
|
-
|
|
14384
|
+
sandboxName: await sandboxName.from(id),
|
|
14317
14385
|
path: path$1
|
|
14318
14386
|
};
|
|
14319
14387
|
}
|
|
@@ -14322,20 +14390,20 @@ const parseLocalOrRemotePath = async (input) => {
|
|
|
14322
14390
|
path: input
|
|
14323
14391
|
};
|
|
14324
14392
|
};
|
|
14325
|
-
const localOrRemote = import_cjs$
|
|
14326
|
-
const cp = import_cjs$
|
|
14393
|
+
const localOrRemote = import_cjs$8.extendType(import_cjs$8.string, { from: parseLocalOrRemotePath });
|
|
14394
|
+
const cp = import_cjs$8.command({
|
|
14327
14395
|
name: "copy",
|
|
14328
14396
|
description: "Copy files between your local filesystem and a remote sandbox",
|
|
14329
14397
|
aliases: ["cp"],
|
|
14330
14398
|
args: {
|
|
14331
|
-
source: import_cjs$
|
|
14399
|
+
source: import_cjs$8.positional({
|
|
14332
14400
|
displayName: `src`,
|
|
14333
|
-
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`,
|
|
14334
14402
|
type: localOrRemote
|
|
14335
14403
|
}),
|
|
14336
|
-
dest: import_cjs$
|
|
14404
|
+
dest: import_cjs$8.positional({
|
|
14337
14405
|
displayName: `dst`,
|
|
14338
|
-
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`,
|
|
14339
14407
|
type: localOrRemote
|
|
14340
14408
|
}),
|
|
14341
14409
|
scope
|
|
@@ -14349,7 +14417,7 @@ const cp = import_cjs$6.command({
|
|
|
14349
14417
|
});
|
|
14350
14418
|
else {
|
|
14351
14419
|
const file = await (await sandboxClient.get({
|
|
14352
|
-
|
|
14420
|
+
name: source.sandboxName,
|
|
14353
14421
|
teamId: scope$1.team,
|
|
14354
14422
|
token: scope$1.token,
|
|
14355
14423
|
projectId: scope$1.project
|
|
@@ -14359,14 +14427,14 @@ const cp = import_cjs$6.command({
|
|
|
14359
14427
|
if (!sourceFile) {
|
|
14360
14428
|
if (source.type === "remote") {
|
|
14361
14429
|
const dir = path.dirname(source.path);
|
|
14362
|
-
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"));
|
|
14363
14431
|
} else spinner.fail(`Source file (${source.path}) not found.`);
|
|
14364
14432
|
return;
|
|
14365
14433
|
}
|
|
14366
14434
|
spinner.text = `Writing to destination file (${dest.path})...`;
|
|
14367
14435
|
if (dest.type === "local") await fs.writeFile(dest.path, sourceFile);
|
|
14368
14436
|
else await (await sandboxClient.get({
|
|
14369
|
-
|
|
14437
|
+
name: dest.sandboxName,
|
|
14370
14438
|
teamId: scope$1.team,
|
|
14371
14439
|
projectId: scope$1.project,
|
|
14372
14440
|
token: scope$1.token
|
|
@@ -14380,10 +14448,10 @@ const cp = import_cjs$6.command({
|
|
|
14380
14448
|
|
|
14381
14449
|
//#endregion
|
|
14382
14450
|
//#region src/commands/logout.ts
|
|
14383
|
-
var import_cjs$
|
|
14451
|
+
var import_cjs$7 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14384
14452
|
init_source();
|
|
14385
14453
|
const debug = createDebugger("sandbox:logout");
|
|
14386
|
-
const logout = import_cjs$
|
|
14454
|
+
const logout = import_cjs$7.command({
|
|
14387
14455
|
name: "logout",
|
|
14388
14456
|
description: "Log out of the Sandbox CLI",
|
|
14389
14457
|
args: {},
|
|
@@ -14402,45 +14470,45 @@ const logout = import_cjs$5.command({
|
|
|
14402
14470
|
|
|
14403
14471
|
//#endregion
|
|
14404
14472
|
//#region src/commands/snapshot.ts
|
|
14405
|
-
var import_cjs$
|
|
14473
|
+
var import_cjs$6 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14406
14474
|
init_source();
|
|
14407
|
-
var import_ms = /* @__PURE__ */ __toESM(require_ms());
|
|
14475
|
+
var import_ms$1 = /* @__PURE__ */ __toESM(require_ms());
|
|
14408
14476
|
const args = {
|
|
14409
|
-
stop: import_cjs$
|
|
14477
|
+
stop: import_cjs$6.flag({
|
|
14410
14478
|
long: "stop",
|
|
14411
14479
|
description: "Confirm that the sandbox will be stopped when snapshotting"
|
|
14412
14480
|
}),
|
|
14413
|
-
silent: import_cjs$
|
|
14481
|
+
silent: import_cjs$6.flag({
|
|
14414
14482
|
long: "silent",
|
|
14415
14483
|
description: "Don't write snapshot ID to stdout"
|
|
14416
14484
|
}),
|
|
14417
|
-
expiration: import_cjs$
|
|
14485
|
+
expiration: import_cjs$6.option({
|
|
14418
14486
|
long: "expiration",
|
|
14419
|
-
type: import_cjs$
|
|
14487
|
+
type: import_cjs$6.optional(Duration),
|
|
14420
14488
|
description: "The expiration time of the snapshot. Use 0 for no expiration."
|
|
14421
14489
|
}),
|
|
14422
|
-
sandbox: import_cjs$
|
|
14490
|
+
sandbox: import_cjs$6.positional({ type: sandboxName }),
|
|
14423
14491
|
scope
|
|
14424
14492
|
};
|
|
14425
|
-
const snapshot = import_cjs$
|
|
14493
|
+
const snapshot = import_cjs$6.command({
|
|
14426
14494
|
name: "snapshot",
|
|
14427
14495
|
description: "Take a snapshot of the filesystem of a sandbox",
|
|
14428
14496
|
args,
|
|
14429
|
-
async handler({ sandbox:
|
|
14497
|
+
async handler({ sandbox: sandboxName$1, stop: stop$1, scope: { token: token$1, team: team$1, project: project$1 }, silent, expiration }) {
|
|
14430
14498
|
if (!stop$1) {
|
|
14431
|
-
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"));
|
|
14432
14500
|
process.exitCode = 1;
|
|
14433
14501
|
return;
|
|
14434
14502
|
}
|
|
14435
|
-
const sandbox = typeof
|
|
14436
|
-
|
|
14503
|
+
const sandbox = typeof sandboxName$1 !== "string" ? sandboxName$1 : await sandboxClient.get({
|
|
14504
|
+
name: sandboxName$1,
|
|
14437
14505
|
projectId: project$1,
|
|
14438
14506
|
teamId: team$1,
|
|
14439
14507
|
token: token$1
|
|
14440
14508
|
});
|
|
14441
14509
|
if (!["running"].includes(sandbox.status)) {
|
|
14442
14510
|
console.error([
|
|
14443
|
-
`Sandbox ${sandbox.
|
|
14511
|
+
`Sandbox ${sandbox.name} is not available (status: ${sandbox.status}).`,
|
|
14444
14512
|
`${source_default.bold("hint:")} Only 'running' sandboxes can be snapshotted.`,
|
|
14445
14513
|
"├▶ Use `sandbox list` to check sandbox status.",
|
|
14446
14514
|
"╰▶ Use `sandbox create` to create a new sandbox."
|
|
@@ -14449,17 +14517,17 @@ const snapshot = import_cjs$4.command({
|
|
|
14449
14517
|
return;
|
|
14450
14518
|
}
|
|
14451
14519
|
const spinner = silent ? void 0 : ora("Creating snapshot...").start();
|
|
14452
|
-
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) });
|
|
14453
14521
|
spinner?.succeed(`Snapshot ${snapshot$1.snapshotId} created.`);
|
|
14454
14522
|
}
|
|
14455
14523
|
});
|
|
14456
14524
|
|
|
14457
14525
|
//#endregion
|
|
14458
14526
|
//#region src/commands/snapshots.ts
|
|
14459
|
-
var import_cjs$
|
|
14460
|
-
var import_cjs$
|
|
14527
|
+
var import_cjs$4 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14528
|
+
var import_cjs$5 = require_cjs();
|
|
14461
14529
|
init_source();
|
|
14462
|
-
const list$
|
|
14530
|
+
const list$2 = import_cjs$4.command({
|
|
14463
14531
|
name: "list",
|
|
14464
14532
|
aliases: ["ls"],
|
|
14465
14533
|
description: "List snapshots for the specified account and project.",
|
|
@@ -14493,19 +14561,19 @@ const list$1 = import_cjs$2.command({
|
|
|
14493
14561
|
CREATED: { value: (s$1) => timeAgo(s$1.createdAt) },
|
|
14494
14562
|
EXPIRATION: { value: (s$1) => s$1.status === "deleted" ? source_default.gray.dim("deleted") : timeAgo(s$1.expiresAt) },
|
|
14495
14563
|
SIZE: { value: (s$1) => formatBytes(s$1.sizeBytes) },
|
|
14496
|
-
["SOURCE
|
|
14564
|
+
["SOURCE SESSION"]: { value: (s$1) => s$1.sourceSandboxId }
|
|
14497
14565
|
}
|
|
14498
14566
|
}));
|
|
14499
14567
|
}
|
|
14500
14568
|
});
|
|
14501
|
-
const get = import_cjs$
|
|
14569
|
+
const get = import_cjs$4.command({
|
|
14502
14570
|
name: "get",
|
|
14503
14571
|
description: "Get details of a snapshot.",
|
|
14504
14572
|
args: {
|
|
14505
14573
|
scope,
|
|
14506
|
-
snapshotId: import_cjs$
|
|
14574
|
+
snapshotId: import_cjs$4.positional({
|
|
14507
14575
|
type: snapshotId,
|
|
14508
|
-
description: "
|
|
14576
|
+
description: "Snapshot ID to retrieve"
|
|
14509
14577
|
})
|
|
14510
14578
|
},
|
|
14511
14579
|
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, snapshotId: id }) {
|
|
@@ -14536,21 +14604,21 @@ const get = import_cjs$2.command({
|
|
|
14536
14604
|
CREATED: { value: (s$1) => timeAgo(s$1.createdAt) },
|
|
14537
14605
|
EXPIRATION: { value: (s$1) => s$1.status === "deleted" ? source_default.gray.dim("deleted") : timeAgo(s$1.expiresAt) },
|
|
14538
14606
|
SIZE: { value: (s$1) => formatBytes(s$1.sizeBytes) },
|
|
14539
|
-
["SOURCE
|
|
14607
|
+
["SOURCE SESSION"]: { value: (s$1) => s$1.sourceSandboxId }
|
|
14540
14608
|
}
|
|
14541
14609
|
}));
|
|
14542
14610
|
}
|
|
14543
14611
|
});
|
|
14544
|
-
const remove = import_cjs$
|
|
14612
|
+
const remove$1 = import_cjs$4.command({
|
|
14545
14613
|
name: "delete",
|
|
14546
14614
|
aliases: ["rm", "remove"],
|
|
14547
14615
|
description: "Delete one or more snapshots.",
|
|
14548
14616
|
args: {
|
|
14549
|
-
snapshotId: import_cjs$
|
|
14617
|
+
snapshotId: import_cjs$4.positional({
|
|
14550
14618
|
type: snapshotId,
|
|
14551
|
-
description: "
|
|
14619
|
+
description: "Snapshot ID to delete"
|
|
14552
14620
|
}),
|
|
14553
|
-
snapshotIds: import_cjs$
|
|
14621
|
+
snapshotIds: import_cjs$4.restPositionals({
|
|
14554
14622
|
type: snapshotId,
|
|
14555
14623
|
description: "More snapshots IDs to delete"
|
|
14556
14624
|
}),
|
|
@@ -14574,13 +14642,13 @@ const remove = import_cjs$2.command({
|
|
|
14574
14642
|
}), { concurrent: true }).run();
|
|
14575
14643
|
}
|
|
14576
14644
|
});
|
|
14577
|
-
const snapshots = (0, import_cjs$
|
|
14645
|
+
const snapshots = (0, import_cjs$5.subcommands)({
|
|
14578
14646
|
name: "snapshots",
|
|
14579
14647
|
description: "Manage sandbox snapshots",
|
|
14580
14648
|
cmds: {
|
|
14581
|
-
list: list$
|
|
14649
|
+
list: list$2,
|
|
14582
14650
|
get,
|
|
14583
|
-
delete: remove
|
|
14651
|
+
delete: remove$1
|
|
14584
14652
|
}
|
|
14585
14653
|
});
|
|
14586
14654
|
const SnapshotStatusColor = new Map([
|
|
@@ -14589,16 +14657,201 @@ const SnapshotStatusColor = new Map([
|
|
|
14589
14657
|
["failed", source_default.red]
|
|
14590
14658
|
]);
|
|
14591
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
|
+
|
|
14592
14727
|
//#endregion
|
|
14593
14728
|
//#region src/commands/config.ts
|
|
14594
14729
|
var import_cjs$1 = /* @__PURE__ */ __toESM(require_cjs());
|
|
14595
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
|
+
});
|
|
14596
14849
|
const networkPolicyCommand = import_cjs$1.command({
|
|
14597
14850
|
name: "network-policy",
|
|
14598
14851
|
description: `Update the network policy of a sandbox.
|
|
14599
14852
|
This will fully override the previous configuration.`,
|
|
14600
14853
|
args: {
|
|
14601
|
-
sandbox: import_cjs$1.positional({ type:
|
|
14854
|
+
sandbox: import_cjs$1.positional({ type: sandboxName }),
|
|
14602
14855
|
...networkPolicyArgs,
|
|
14603
14856
|
mode: import_cjs$1.option({
|
|
14604
14857
|
long: "mode",
|
|
@@ -14607,7 +14860,8 @@ const networkPolicyCommand = import_cjs$1.command({
|
|
|
14607
14860
|
}),
|
|
14608
14861
|
scope
|
|
14609
14862
|
},
|
|
14610
|
-
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"));
|
|
14611
14865
|
const networkPolicyMode$1 = resolveMode(networkPolicyFlag, modeFlag);
|
|
14612
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.`);
|
|
14613
14867
|
const networkPolicy$1 = buildNetworkPolicy({
|
|
@@ -14616,27 +14870,17 @@ const networkPolicyCommand = import_cjs$1.command({
|
|
|
14616
14870
|
allowedCIDRs: allowedCIDRs$1,
|
|
14617
14871
|
deniedCIDRs: deniedCIDRs$1
|
|
14618
14872
|
});
|
|
14619
|
-
const sandbox = typeof
|
|
14620
|
-
|
|
14873
|
+
const sandbox = typeof sandboxName$1 !== "string" ? sandboxName$1 : await sandboxClient.get({
|
|
14874
|
+
name: sandboxName$1,
|
|
14621
14875
|
projectId: project$1,
|
|
14622
14876
|
teamId: team$1,
|
|
14623
14877
|
token: token$1
|
|
14624
14878
|
});
|
|
14625
|
-
if (!["pending", "running"].includes(sandbox.status)) {
|
|
14626
|
-
console.error([
|
|
14627
|
-
`Sandbox ${sandbox.sandboxId} is not available (status: ${sandbox.status}).`,
|
|
14628
|
-
`${source_default.bold("hint:")} Only 'pending' or 'running' sandboxes can execute commands.`,
|
|
14629
|
-
"├▶ Use `sandbox list` to check sandbox status.",
|
|
14630
|
-
"╰▶ Use `sandbox create` to create a new sandbox."
|
|
14631
|
-
].join("\n"));
|
|
14632
|
-
process.exitCode = 1;
|
|
14633
|
-
return;
|
|
14634
|
-
}
|
|
14635
14879
|
const spinner = ora("Updating network policy...").start();
|
|
14636
14880
|
try {
|
|
14637
14881
|
const response = await sandbox.updateNetworkPolicy(networkPolicy$1);
|
|
14638
14882
|
spinner.stop();
|
|
14639
|
-
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");
|
|
14640
14884
|
const mode = typeof response === "string" ? response : "restricted";
|
|
14641
14885
|
process.stderr.write(source_default.dim(" ╰ ") + "mode: " + source_default.cyan(mode) + "\n");
|
|
14642
14886
|
} catch (error) {
|
|
@@ -14647,8 +14891,12 @@ const networkPolicyCommand = import_cjs$1.command({
|
|
|
14647
14891
|
});
|
|
14648
14892
|
const config = import_cjs$1.subcommands({
|
|
14649
14893
|
name: "config",
|
|
14650
|
-
description: "
|
|
14651
|
-
cmds: {
|
|
14894
|
+
description: "View and update sandbox configuration",
|
|
14895
|
+
cmds: {
|
|
14896
|
+
set: setCommand,
|
|
14897
|
+
get: getCommand,
|
|
14898
|
+
"network-policy": networkPolicyCommand
|
|
14899
|
+
}
|
|
14652
14900
|
});
|
|
14653
14901
|
|
|
14654
14902
|
//#endregion
|
|
@@ -14666,9 +14914,11 @@ const app = (opts) => (0, import_cjs.subcommands)({
|
|
|
14666
14914
|
exec,
|
|
14667
14915
|
connect,
|
|
14668
14916
|
stop,
|
|
14917
|
+
remove,
|
|
14669
14918
|
run,
|
|
14670
14919
|
snapshot,
|
|
14671
14920
|
snapshots,
|
|
14921
|
+
sessions,
|
|
14672
14922
|
...!opts?.withoutAuth && {
|
|
14673
14923
|
login,
|
|
14674
14924
|
logout
|
|
@@ -14685,11 +14935,11 @@ const app = (opts) => (0, import_cjs.subcommands)({
|
|
|
14685
14935
|
},
|
|
14686
14936
|
{
|
|
14687
14937
|
description: "Execute command in an existing sandbox",
|
|
14688
|
-
command: `sandbox exec <
|
|
14938
|
+
command: `sandbox exec <name> -- npm test`
|
|
14689
14939
|
}
|
|
14690
14940
|
]
|
|
14691
14941
|
});
|
|
14692
14942
|
|
|
14693
14943
|
//#endregion
|
|
14694
14944
|
export { source_exports as a, init_source as i, StyledError as n, require_cjs as r, app as t };
|
|
14695
|
-
//# sourceMappingURL=app-
|
|
14945
|
+
//# sourceMappingURL=app-AqqXdE-N.mjs.map
|