sandbox 2.5.4 → 3.0.0-beta.2

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