sandbox 2.0.4 → 2.2.0

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.
@@ -622,8 +622,8 @@ var require_effects = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/c
622
622
  * with a command line, and again, to mock `stdout` and `stderr` it if we want to test it.
623
623
  */
624
624
  var Exit = class {
625
- constructor(config) {
626
- this.config = config;
625
+ constructor(config$1) {
626
+ this.config = config$1;
627
627
  }
628
628
  run() {
629
629
  this.output()(this.config.message);
@@ -867,65 +867,65 @@ var require_flag = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cmd-
867
867
  displayName: "true/false",
868
868
  defaultValue: () => false
869
869
  };
870
- function fullFlag(config) {
870
+ function fullFlag(config$1) {
871
871
  var _a;
872
- const decoder = (0, type_1$2.extendType)(exports.boolean, config.type);
872
+ const decoder = (0, type_1$2.extendType)(exports.boolean, config$1.type);
873
873
  return {
874
- description: (_a = config.description) !== null && _a !== void 0 ? _a : config.type.description,
874
+ description: (_a = config$1.description) !== null && _a !== void 0 ? _a : config$1.type.description,
875
875
  helpTopics() {
876
876
  var _a$1, _b;
877
- let usage = `--${config.long}`;
878
- if (config.short) usage += `, -${config.short}`;
877
+ let usage = `--${config$1.long}`;
878
+ if (config$1.short) usage += `, -${config$1.short}`;
879
879
  const defaults = [];
880
- if (config.env) {
881
- const env$2 = process.env[config.env] === void 0 ? "" : `=${chalk_1$6.default.italic(process.env[config.env])}`;
882
- defaults.push(`env: ${config.env}${env$2}`);
880
+ if (config$1.env) {
881
+ const env$2 = process.env[config$1.env] === void 0 ? "" : `=${chalk_1$6.default.italic(process.env[config$1.env])}`;
882
+ defaults.push(`env: ${config$1.env}${env$2}`);
883
883
  }
884
- if (config.defaultValue) try {
885
- const defaultValue = config.defaultValue();
886
- if (config.defaultValueIsSerializable) defaults.push(`default: ${chalk_1$6.default.italic(defaultValue)}`);
884
+ if (config$1.defaultValue) try {
885
+ const defaultValue = config$1.defaultValue();
886
+ if (config$1.defaultValueIsSerializable) defaults.push(`default: ${chalk_1$6.default.italic(defaultValue)}`);
887
887
  else defaults.push("optional");
888
888
  } catch (e) {}
889
- else if (config.type.defaultValue) try {
890
- const defaultValue = config.type.defaultValue();
891
- if (config.type.defaultValueIsSerializable) defaults.push(`default: ${chalk_1$6.default.italic(defaultValue)}`);
889
+ else if (config$1.type.defaultValue) try {
890
+ const defaultValue = config$1.type.defaultValue();
891
+ if (config$1.type.defaultValueIsSerializable) defaults.push(`default: ${chalk_1$6.default.italic(defaultValue)}`);
892
892
  else defaults.push("optional");
893
893
  } catch (e) {}
894
- else if (config.onMissing || config.type.onMissing) defaults.push("optional");
894
+ else if (config$1.onMissing || config$1.type.onMissing) defaults.push("optional");
895
895
  return [{
896
896
  category: "flags",
897
897
  usage,
898
898
  defaults,
899
- description: (_b = (_a$1 = config.description) !== null && _a$1 !== void 0 ? _a$1 : config.type.description) !== null && _b !== void 0 ? _b : "self explanatory"
899
+ description: (_b = (_a$1 = config$1.description) !== null && _a$1 !== void 0 ? _a$1 : config$1.type.description) !== null && _b !== void 0 ? _b : "self explanatory"
900
900
  }];
901
901
  },
902
902
  register(opts) {
903
- opts.forceFlagLongNames.add(config.long);
904
- if (config.short) opts.forceFlagShortNames.add(config.short);
903
+ opts.forceFlagLongNames.add(config$1.long);
904
+ if (config$1.short) opts.forceFlagShortNames.add(config$1.short);
905
905
  },
906
906
  async parse({ nodes, visitedNodes }) {
907
907
  var _a$1, _b;
908
908
  const options = (0, findOption_1$3.findOption)(nodes, {
909
- longNames: [config.long],
910
- shortNames: config.short ? [config.short] : []
909
+ longNames: [config$1.long],
910
+ shortNames: config$1.short ? [config$1.short] : []
911
911
  }).filter((x) => !visitedNodes.has(x));
912
912
  options.forEach((opt) => visitedNodes.add(opt));
913
913
  if (options.length > 1) return Result$10.err({ errors: [{
914
914
  nodes: options,
915
915
  message: `Expected 1 occurence, got ${options.length}`
916
916
  }] });
917
- const valueFromEnv = config.env ? process.env[config.env] : void 0;
918
- const onMissingFn = config.onMissing || config.type.onMissing;
917
+ const valueFromEnv = config$1.env ? process.env[config$1.env] : void 0;
918
+ const onMissingFn = config$1.onMissing || config$1.type.onMissing;
919
919
  let rawValue;
920
920
  let envPrefix = "";
921
921
  if (options.length === 0 && valueFromEnv !== void 0) {
922
922
  rawValue = valueFromEnv;
923
- envPrefix = `env[${chalk_1$6.default.italic(config.env)}]: `;
924
- } else if (options.length === 0 && config.defaultValue) try {
925
- const defaultValue = config.defaultValue();
923
+ envPrefix = `env[${chalk_1$6.default.italic(config$1.env)}]: `;
924
+ } else if (options.length === 0 && config$1.defaultValue) try {
925
+ const defaultValue = config$1.defaultValue();
926
926
  return Result$10.ok(defaultValue);
927
927
  } catch (e) {
928
- const message = `Default value not found for '--${config.long}': ${e.message}`;
928
+ const message = `Default value not found for '--${config$1.long}': ${e.message}`;
929
929
  return Result$10.err({ errors: [{
930
930
  message,
931
931
  nodes: []
@@ -935,17 +935,17 @@ var require_flag = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cmd-
935
935
  const missingValue = await onMissingFn();
936
936
  return Result$10.ok(missingValue);
937
937
  } catch (e) {
938
- const message = `Failed to get missing value for '--${config.long}': ${e.message}`;
938
+ const message = `Failed to get missing value for '--${config$1.long}': ${e.message}`;
939
939
  return Result$10.err({ errors: [{
940
940
  message,
941
941
  nodes: []
942
942
  }] });
943
943
  }
944
- else if (options.length === 0 && config.type.defaultValue) try {
945
- const defaultValue = config.type.defaultValue();
944
+ else if (options.length === 0 && config$1.type.defaultValue) try {
945
+ const defaultValue = config$1.type.defaultValue();
946
946
  return Result$10.ok(defaultValue);
947
947
  } catch (e) {
948
- const message = `Default value not found for '--${config.long}': ${e.message}`;
948
+ const message = `Default value not found for '--${config$1.long}': ${e.message}`;
949
949
  return Result$10.err({ errors: [{
950
950
  message,
951
951
  nodes: []
@@ -954,7 +954,7 @@ var require_flag = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cmd-
954
954
  else if (options.length === 1) rawValue = (_b = (_a$1 = options[0].value) === null || _a$1 === void 0 ? void 0 : _a$1.node.raw) !== null && _b !== void 0 ? _b : "true";
955
955
  else return Result$10.err({ errors: [{
956
956
  nodes: [],
957
- message: `No value provided for --${config.long}`
957
+ message: `No value provided for --${config$1.long}`
958
958
  }] });
959
959
  const decoded = await Result$10.safeAsync(decoder.from(rawValue));
960
960
  if (Result$10.isErr(decoded)) return Result$10.err({ errors: [{
@@ -965,10 +965,10 @@ var require_flag = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cmd-
965
965
  }
966
966
  };
967
967
  }
968
- function flag(config) {
968
+ function flag(config$1) {
969
969
  return fullFlag({
970
970
  type: types_1$4.boolean,
971
- ...config
971
+ ...config$1
972
972
  });
973
973
  }
974
974
  }) });
@@ -1146,24 +1146,24 @@ var require_positional = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
1146
1146
  const chalk_1$5 = __importDefault$8((init_source(), __toCommonJS$3(source_exports)));
1147
1147
  const Result$8 = __importStar$8(require_Result());
1148
1148
  const types_1$2 = require_types();
1149
- function fullPositional(config) {
1149
+ function fullPositional(config$1) {
1150
1150
  var _a, _b, _c;
1151
- const displayName = (_b = (_a = config.displayName) !== null && _a !== void 0 ? _a : config.type.displayName) !== null && _b !== void 0 ? _b : "arg";
1151
+ const displayName = (_b = (_a = config$1.displayName) !== null && _a !== void 0 ? _a : config$1.type.displayName) !== null && _b !== void 0 ? _b : "arg";
1152
1152
  return {
1153
- description: (_c = config.description) !== null && _c !== void 0 ? _c : config.type.description,
1153
+ description: (_c = config$1.description) !== null && _c !== void 0 ? _c : config$1.type.description,
1154
1154
  helpTopics() {
1155
1155
  var _a$1, _b$1, _c$1, _d;
1156
1156
  const defaults = [];
1157
- const defaultValueFn = (_a$1 = config.defaultValue) !== null && _a$1 !== void 0 ? _a$1 : config.type.defaultValue;
1157
+ const defaultValueFn = (_a$1 = config$1.defaultValue) !== null && _a$1 !== void 0 ? _a$1 : config$1.type.defaultValue;
1158
1158
  if (defaultValueFn) try {
1159
1159
  const defaultValue = defaultValueFn();
1160
- if ((_b$1 = config.defaultValueIsSerializable) !== null && _b$1 !== void 0 ? _b$1 : config.type.defaultValueIsSerializable) defaults.push(`default: ${chalk_1$5.default.italic(defaultValue)}`);
1160
+ if ((_b$1 = config$1.defaultValueIsSerializable) !== null && _b$1 !== void 0 ? _b$1 : config$1.type.defaultValueIsSerializable) defaults.push(`default: ${chalk_1$5.default.italic(defaultValue)}`);
1161
1161
  else defaults.push("optional");
1162
1162
  } catch (e) {}
1163
1163
  return [{
1164
1164
  category: "arguments",
1165
1165
  usage: defaults.length > 0 ? `[${displayName}]` : `<${displayName}>`,
1166
- description: (_d = (_c$1 = config.description) !== null && _c$1 !== void 0 ? _c$1 : config.type.description) !== null && _d !== void 0 ? _d : "self explanatory",
1166
+ description: (_d = (_c$1 = config$1.description) !== null && _c$1 !== void 0 ? _c$1 : config$1.type.description) !== null && _d !== void 0 ? _d : "self explanatory",
1167
1167
  defaults
1168
1168
  }];
1169
1169
  },
@@ -1171,7 +1171,7 @@ var require_positional = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
1171
1171
  async parse({ nodes, visitedNodes }) {
1172
1172
  var _a$1;
1173
1173
  const positionals = nodes.filter((node) => node.type === "positionalArgument" && !visitedNodes.has(node));
1174
- const defaultValueFn = (_a$1 = config.defaultValue) !== null && _a$1 !== void 0 ? _a$1 : config.type.defaultValue;
1174
+ const defaultValueFn = (_a$1 = config$1.defaultValue) !== null && _a$1 !== void 0 ? _a$1 : config$1.type.defaultValue;
1175
1175
  const positional$1 = positionals[0];
1176
1176
  if (!positional$1) {
1177
1177
  if (defaultValueFn) return Result$8.ok(defaultValueFn());
@@ -1181,7 +1181,7 @@ var require_positional = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
1181
1181
  }] });
1182
1182
  }
1183
1183
  visitedNodes.add(positional$1);
1184
- const decoded = await Result$8.safeAsync(config.type.from(positional$1.raw));
1184
+ const decoded = await Result$8.safeAsync(config$1.type.from(positional$1.raw));
1185
1185
  if (Result$8.isErr(decoded)) return Result$8.err({ errors: [{
1186
1186
  nodes: [positional$1],
1187
1187
  message: decoded.error.message
@@ -1190,10 +1190,10 @@ var require_positional = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
1190
1190
  }
1191
1191
  };
1192
1192
  }
1193
- function positional(config) {
1193
+ function positional(config$1) {
1194
1194
  return fullPositional({
1195
1195
  type: types_1$2.string,
1196
- ...config
1196
+ ...config$1
1197
1197
  });
1198
1198
  }
1199
1199
  }) });
@@ -1255,13 +1255,13 @@ var require_subcommands = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
1255
1255
  /**
1256
1256
  * Combine multiple `command`s into one
1257
1257
  */
1258
- function subcommands$2(config) {
1259
- const circuitbreaker = (0, circuitbreaker_1$1.createCircuitBreaker)(!!config.version);
1258
+ function subcommands$2(config$1) {
1259
+ const circuitbreaker = (0, circuitbreaker_1$1.createCircuitBreaker)(!!config$1.version);
1260
1260
  const subcommand = (0, positional_1$1.positional)({
1261
1261
  displayName: "subcommand",
1262
- description: `one of ${Object.keys(config.cmds).join(", ")}`,
1262
+ description: `one of ${Object.keys(config$1.cmds).join(", ")}`,
1263
1263
  type: { async from(str) {
1264
- const commands = Object.entries(config.cmds).map(([name, cmd$1]) => {
1264
+ const commands = Object.entries(config$1.cmds).map(([name, cmd$1]) => {
1265
1265
  var _a;
1266
1266
  return {
1267
1267
  cmdName: name,
@@ -1281,7 +1281,7 @@ var require_subcommands = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
1281
1281
  });
1282
1282
  function normalizeContext(context) {
1283
1283
  var _a;
1284
- if (((_a = context.hotPath) === null || _a === void 0 ? void 0 : _a.length) === 0) context.hotPath.push(config.name);
1284
+ if (((_a = context.hotPath) === null || _a === void 0 ? void 0 : _a.length) === 0) context.hotPath.push(config$1.name);
1285
1285
  if (!context.nodes.some((n) => !context.visitedNodes.has(n))) context.nodes.push({
1286
1286
  type: "longOption",
1287
1287
  index: 0,
@@ -1290,14 +1290,14 @@ var require_subcommands = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
1290
1290
  });
1291
1291
  }
1292
1292
  return {
1293
- version: config.version,
1294
- description: config.description,
1295
- name: config.name,
1293
+ version: config$1.version,
1294
+ description: config$1.description,
1295
+ name: config$1.name,
1296
1296
  handler: (value) => {
1297
- return config.cmds[value.command].handler(value.args);
1297
+ return config$1.cmds[value.command].handler(value.args);
1298
1298
  },
1299
1299
  register(opts) {
1300
- for (const cmd of Object.values(config.cmds)) cmd.register(opts);
1300
+ for (const cmd of Object.values(config$1.cmds)) cmd.register(opts);
1301
1301
  circuitbreaker.register(opts);
1302
1302
  },
1303
1303
  printHelp(context) {
@@ -1305,12 +1305,12 @@ var require_subcommands = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
1305
1305
  const lines = [];
1306
1306
  const argsSoFar = (_b = (_a = context.hotPath) === null || _a === void 0 ? void 0 : _a.join(" ")) !== null && _b !== void 0 ? _b : "cli";
1307
1307
  lines.push(chalk_1$4.default.bold(argsSoFar + chalk_1$4.default.italic(" <subcommand>")));
1308
- if (config.description) lines.push(chalk_1$4.default.dim("> ") + config.description);
1308
+ if (config$1.description) lines.push(chalk_1$4.default.dim("> ") + config$1.description);
1309
1309
  lines.push("");
1310
1310
  lines.push(`where ${chalk_1$4.default.italic("<subcommand>")} can be one of:`);
1311
1311
  lines.push("");
1312
- for (const key of Object.keys(config.cmds)) {
1313
- const cmd = config.cmds[key];
1312
+ for (const key of Object.keys(config$1.cmds)) {
1313
+ const cmd = config$1.cmds[key];
1314
1314
  let description = (_c = cmd.description) !== null && _c !== void 0 ? _c : "";
1315
1315
  description = description && ` - ${description} `;
1316
1316
  if ((_d = cmd.aliases) === null || _d === void 0 ? void 0 : _d.length) {
@@ -1335,7 +1335,7 @@ var require_subcommands = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
1335
1335
  partialValue: {}
1336
1336
  });
1337
1337
  (_a = context.hotPath) === null || _a === void 0 || _a.push(parsed.value);
1338
- const parsedCommand = await config.cmds[parsed.value].parse(context);
1338
+ const parsedCommand = await config$1.cmds[parsed.value].parse(context);
1339
1339
  if (Result$7.isErr(parsedCommand)) return Result$7.err({
1340
1340
  errors: parsedCommand.error.errors,
1341
1341
  partialValue: {
@@ -1361,7 +1361,7 @@ var require_subcommands = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
1361
1361
  });
1362
1362
  }
1363
1363
  (_a = context.hotPath) === null || _a === void 0 || _a.push(parsedSubcommand.value);
1364
- const commandRun = await config.cmds[parsedSubcommand.value].run(context);
1364
+ const commandRun = await config$1.cmds[parsedSubcommand.value].run(context);
1365
1365
  if (Result$7.isOk(commandRun)) return Result$7.ok({
1366
1366
  command: parsedSubcommand.value,
1367
1367
  value: commandRun.value
@@ -1545,17 +1545,17 @@ var require_command = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/c
1545
1545
  * A combination of multiple flags, options and arguments
1546
1546
  * with a common name and a handler that expects them as input.
1547
1547
  */
1548
- function command(config) {
1549
- const argEntries = (0, utils_1$2.entries)(config.args);
1550
- const circuitbreaker = (0, circuitbreaker_1.createCircuitBreaker)(!!config.version);
1548
+ function command(config$1) {
1549
+ const argEntries = (0, utils_1$2.entries)(config$1.args);
1550
+ const circuitbreaker = (0, circuitbreaker_1.createCircuitBreaker)(!!config$1.version);
1551
1551
  return {
1552
- name: config.name,
1553
- aliases: config.aliases,
1554
- handler: config.handler,
1555
- description: config.description,
1556
- version: config.version,
1552
+ name: config$1.name,
1553
+ aliases: config$1.aliases,
1554
+ handler: config$1.handler,
1555
+ description: config$1.description,
1556
+ version: config$1.version,
1557
1557
  helpTopics() {
1558
- return (0, utils_1$2.flatMap)(Object.values(config.args).concat([circuitbreaker]), (x) => {
1558
+ return (0, utils_1$2.flatMap)(Object.values(config$1.args).concat([circuitbreaker]), (x) => {
1559
1559
  var _a, _b;
1560
1560
  return (_b = (_a = x.helpTopics) === null || _a === void 0 ? void 0 : _a.call(x)) !== null && _b !== void 0 ? _b : [];
1561
1561
  });
@@ -1564,11 +1564,11 @@ var require_command = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/c
1564
1564
  var _a, _b;
1565
1565
  const lines = [];
1566
1566
  let name = (_b = (_a = context.hotPath) === null || _a === void 0 ? void 0 : _a.join(" ")) !== null && _b !== void 0 ? _b : "";
1567
- if (!name) name = config.name;
1567
+ if (!name) name = config$1.name;
1568
1568
  name = chalk_1$3.default.bold(name);
1569
- if (config.version) name += ` ${chalk_1$3.default.dim(config.version)}`;
1569
+ if (config$1.version) name += ` ${chalk_1$3.default.dim(config$1.version)}`;
1570
1570
  lines.push(name);
1571
- if (config.description) lines.push(chalk_1$3.default.dim("> ") + config.description);
1571
+ if (config$1.description) lines.push(chalk_1$3.default.dim("> ") + config$1.description);
1572
1572
  const usageBreakdown = (0, utils_1$2.groupBy)(this.helpTopics(), (x) => x.category);
1573
1573
  for (const [category, helpTopics] of (0, utils_1$2.entries)(usageBreakdown)) {
1574
1574
  lines.push("");
@@ -1593,7 +1593,7 @@ var require_command = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/c
1593
1593
  },
1594
1594
  async parse(context) {
1595
1595
  var _a;
1596
- if (((_a = context.hotPath) === null || _a === void 0 ? void 0 : _a.length) === 0) context.hotPath.push(config.name);
1596
+ if (((_a = context.hotPath) === null || _a === void 0 ? void 0 : _a.length) === 0) context.hotPath.push(config$1.name);
1597
1597
  const resultObject = {};
1598
1598
  const errors = [];
1599
1599
  for (const [argName, arg] of argEntries) {
@@ -1684,47 +1684,47 @@ var require_option = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cm
1684
1684
  const Result$5 = __importStar$5(require_Result());
1685
1685
  const findOption_1$2 = require_findOption();
1686
1686
  const types_1$1 = require_types();
1687
- function fullOption(config) {
1687
+ function fullOption(config$1) {
1688
1688
  var _a;
1689
1689
  return {
1690
- description: (_a = config.description) !== null && _a !== void 0 ? _a : config.type.description,
1690
+ description: (_a = config$1.description) !== null && _a !== void 0 ? _a : config$1.type.description,
1691
1691
  helpTopics() {
1692
1692
  var _a$1, _b, _c;
1693
- const displayName = (_a$1 = config.type.displayName) !== null && _a$1 !== void 0 ? _a$1 : "value";
1694
- let usage = `--${config.long}`;
1695
- if (config.short) usage += `, -${config.short}`;
1693
+ const displayName = (_a$1 = config$1.type.displayName) !== null && _a$1 !== void 0 ? _a$1 : "value";
1694
+ let usage = `--${config$1.long}`;
1695
+ if (config$1.short) usage += `, -${config$1.short}`;
1696
1696
  usage += ` <${displayName}>`;
1697
1697
  const defaults = [];
1698
- if (config.env) {
1699
- const env$2 = process.env[config.env] === void 0 ? "" : `=${chalk_1$2.default.italic(process.env[config.env])}`;
1700
- defaults.push(`env: ${config.env}${env$2}`);
1698
+ if (config$1.env) {
1699
+ const env$2 = process.env[config$1.env] === void 0 ? "" : `=${chalk_1$2.default.italic(process.env[config$1.env])}`;
1700
+ defaults.push(`env: ${config$1.env}${env$2}`);
1701
1701
  }
1702
- if (config.defaultValue) try {
1703
- const defaultValue = config.defaultValue();
1704
- if (config.defaultValueIsSerializable) defaults.push(`default: ${chalk_1$2.default.italic(defaultValue)}`);
1702
+ if (config$1.defaultValue) try {
1703
+ const defaultValue = config$1.defaultValue();
1704
+ if (config$1.defaultValueIsSerializable) defaults.push(`default: ${chalk_1$2.default.italic(defaultValue)}`);
1705
1705
  else defaults.push("optional");
1706
1706
  } catch (e) {}
1707
- else if (config.type.defaultValue) try {
1708
- const defaultValue = config.type.defaultValue();
1709
- if (config.type.defaultValueIsSerializable) defaults.push(`default: ${chalk_1$2.default.italic(defaultValue)}`);
1707
+ else if (config$1.type.defaultValue) try {
1708
+ const defaultValue = config$1.type.defaultValue();
1709
+ if (config$1.type.defaultValueIsSerializable) defaults.push(`default: ${chalk_1$2.default.italic(defaultValue)}`);
1710
1710
  else defaults.push("optional");
1711
1711
  } catch (e) {}
1712
- else if (config.onMissing || config.type.onMissing) defaults.push("optional");
1712
+ else if (config$1.onMissing || config$1.type.onMissing) defaults.push("optional");
1713
1713
  return [{
1714
1714
  category: "options",
1715
1715
  usage,
1716
1716
  defaults,
1717
- description: (_c = (_b = config.description) !== null && _b !== void 0 ? _b : config.type.description) !== null && _c !== void 0 ? _c : "self explanatory"
1717
+ description: (_c = (_b = config$1.description) !== null && _b !== void 0 ? _b : config$1.type.description) !== null && _c !== void 0 ? _c : "self explanatory"
1718
1718
  }];
1719
1719
  },
1720
1720
  register(opts) {
1721
- opts.forceOptionLongNames.add(config.long);
1722
- if (config.short) opts.forceOptionShortNames.add(config.short);
1721
+ opts.forceOptionLongNames.add(config$1.long);
1722
+ if (config$1.short) opts.forceOptionShortNames.add(config$1.short);
1723
1723
  },
1724
1724
  async parse({ nodes, visitedNodes }) {
1725
1725
  const options = (0, findOption_1$2.findOption)(nodes, {
1726
- longNames: [config.long],
1727
- shortNames: config.short ? [config.short] : []
1726
+ longNames: [config$1.long],
1727
+ shortNames: config$1.short ? [config$1.short] : []
1728
1728
  }).filter((x) => !visitedNodes.has(x));
1729
1729
  options.forEach((opt) => visitedNodes.add(opt));
1730
1730
  if (options.length > 1) {
@@ -1734,21 +1734,21 @@ var require_option = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cm
1734
1734
  };
1735
1735
  return Result$5.err({ errors: [error] });
1736
1736
  }
1737
- const valueFromEnv = config.env ? process.env[config.env] : void 0;
1738
- const defaultValueFn = config.defaultValue || config.type.defaultValue;
1739
- const onMissingFn = config.onMissing || config.type.onMissing;
1737
+ const valueFromEnv = config$1.env ? process.env[config$1.env] : void 0;
1738
+ const defaultValueFn = config$1.defaultValue || config$1.type.defaultValue;
1739
+ const onMissingFn = config$1.onMissing || config$1.type.onMissing;
1740
1740
  const option$1 = options[0];
1741
1741
  let rawValue;
1742
1742
  let envPrefix = "";
1743
1743
  if (option$1 === null || option$1 === void 0 ? void 0 : option$1.value) rawValue = option$1.value.node.raw;
1744
1744
  else if (valueFromEnv !== void 0) {
1745
1745
  rawValue = valueFromEnv;
1746
- envPrefix = `env[${chalk_1$2.default.italic(config.env)}]: `;
1746
+ envPrefix = `env[${chalk_1$2.default.italic(config$1.env)}]: `;
1747
1747
  } else if (defaultValueFn) try {
1748
1748
  const defaultValue = defaultValueFn();
1749
1749
  return Result$5.ok(defaultValue);
1750
1750
  } catch (e) {
1751
- const message = `Default value not found for '--${config.long}': ${e.message}`;
1751
+ const message = `Default value not found for '--${config$1.long}': ${e.message}`;
1752
1752
  return Result$5.err({ errors: [{
1753
1753
  nodes: [],
1754
1754
  message
@@ -1758,20 +1758,20 @@ var require_option = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cm
1758
1758
  const missingValue = await onMissingFn();
1759
1759
  return Result$5.ok(missingValue);
1760
1760
  } catch (e) {
1761
- const message = `Failed to get missing value for '--${config.long}': ${e.message}`;
1761
+ const message = `Failed to get missing value for '--${config$1.long}': ${e.message}`;
1762
1762
  return Result$5.err({ errors: [{
1763
1763
  nodes: [],
1764
1764
  message
1765
1765
  }] });
1766
1766
  }
1767
1767
  else {
1768
- const raw = (option$1 === null || option$1 === void 0 ? void 0 : option$1.type) === "shortOption" ? `-${option$1 === null || option$1 === void 0 ? void 0 : option$1.key}` : `--${config.long}`;
1768
+ const raw = (option$1 === null || option$1 === void 0 ? void 0 : option$1.type) === "shortOption" ? `-${option$1 === null || option$1 === void 0 ? void 0 : option$1.key}` : `--${config$1.long}`;
1769
1769
  return Result$5.err({ errors: [{
1770
1770
  nodes: options,
1771
1771
  message: `No value provided for ${raw}`
1772
1772
  }] });
1773
1773
  }
1774
- const decoded = await Result$5.safeAsync(config.type.from(rawValue));
1774
+ const decoded = await Result$5.safeAsync(config$1.type.from(rawValue));
1775
1775
  if (Result$5.isErr(decoded)) return Result$5.err({ errors: [{
1776
1776
  nodes: options,
1777
1777
  message: envPrefix + decoded.error.message
@@ -1780,10 +1780,10 @@ var require_option = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cm
1780
1780
  }
1781
1781
  };
1782
1782
  }
1783
- function option(config) {
1783
+ function option(config$1) {
1784
1784
  return fullOption({
1785
1785
  type: types_1$1.string,
1786
- ...config
1786
+ ...config$1
1787
1787
  });
1788
1788
  }
1789
1789
  }) });
@@ -2255,15 +2255,15 @@ var require_restPositionals = /* @__PURE__ */ __commonJS$1({ "../../node_modules
2255
2255
  * Works best when it is the last item on the `command` construct, to be
2256
2256
  * used like the `...rest` operator in JS and TypeScript.
2257
2257
  */
2258
- function fullRestPositionals(config) {
2258
+ function fullRestPositionals(config$1) {
2259
2259
  return {
2260
2260
  helpTopics() {
2261
2261
  var _a, _b, _c, _d;
2262
2262
  return [{
2263
- usage: `[...${(_b = (_a = config.displayName) !== null && _a !== void 0 ? _a : config.type.displayName) !== null && _b !== void 0 ? _b : "arg"}]`,
2263
+ usage: `[...${(_b = (_a = config$1.displayName) !== null && _a !== void 0 ? _a : config$1.type.displayName) !== null && _b !== void 0 ? _b : "arg"}]`,
2264
2264
  category: "arguments",
2265
2265
  defaults: [],
2266
- description: (_d = (_c = config.description) !== null && _c !== void 0 ? _c : config.type.description) !== null && _d !== void 0 ? _d : ""
2266
+ description: (_d = (_c = config$1.description) !== null && _c !== void 0 ? _c : config$1.type.description) !== null && _d !== void 0 ? _d : ""
2267
2267
  }];
2268
2268
  },
2269
2269
  register(_opts) {},
@@ -2273,7 +2273,7 @@ var require_restPositionals = /* @__PURE__ */ __commonJS$1({ "../../node_modules
2273
2273
  const errors = [];
2274
2274
  for (const positional$1 of positionals) {
2275
2275
  visitedNodes.add(positional$1);
2276
- const decoded = await Result$4.safeAsync(config.type.from(positional$1.raw));
2276
+ const decoded = await Result$4.safeAsync(config$1.type.from(positional$1.raw));
2277
2277
  if (Result$4.isOk(decoded)) results.push(decoded.value);
2278
2278
  else errors.push({
2279
2279
  nodes: [positional$1],
@@ -2285,10 +2285,10 @@ var require_restPositionals = /* @__PURE__ */ __commonJS$1({ "../../node_modules
2285
2285
  }
2286
2286
  };
2287
2287
  }
2288
- function restPositionals(config) {
2288
+ function restPositionals(config$1) {
2289
2289
  return fullRestPositionals({
2290
2290
  type: types_1.string,
2291
- ...config
2291
+ ...config$1
2292
2292
  });
2293
2293
  }
2294
2294
  }) });
@@ -2346,28 +2346,28 @@ var require_multiflag = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
2346
2346
  * Like `option`, but can accept multiple options, and expects a decoder from a list of strings.
2347
2347
  * An error will highlight all option occurences.
2348
2348
  */
2349
- function multiflag(config) {
2349
+ function multiflag(config$1) {
2350
2350
  return {
2351
2351
  helpTopics() {
2352
2352
  var _a;
2353
- let usage = `--${config.long}`;
2354
- if (config.short) usage += `, -${config.short}`;
2353
+ let usage = `--${config$1.long}`;
2354
+ if (config$1.short) usage += `, -${config$1.short}`;
2355
2355
  return [{
2356
2356
  category: "flags",
2357
2357
  usage,
2358
2358
  defaults: [],
2359
- description: (_a = config.description) !== null && _a !== void 0 ? _a : "self explanatory"
2359
+ description: (_a = config$1.description) !== null && _a !== void 0 ? _a : "self explanatory"
2360
2360
  }];
2361
2361
  },
2362
2362
  register(opts) {
2363
- opts.forceFlagLongNames.add(config.long);
2364
- if (config.short) opts.forceFlagShortNames.add(config.short);
2363
+ opts.forceFlagLongNames.add(config$1.long);
2364
+ if (config$1.short) opts.forceFlagShortNames.add(config$1.short);
2365
2365
  },
2366
2366
  async parse({ nodes, visitedNodes }) {
2367
2367
  var _a, _b;
2368
2368
  const options = (0, findOption_1$1.findOption)(nodes, {
2369
- longNames: [config.long],
2370
- shortNames: config.short ? [config.short] : []
2369
+ longNames: [config$1.long],
2370
+ shortNames: config$1.short ? [config$1.short] : []
2371
2371
  }).filter((x) => !visitedNodes.has(x));
2372
2372
  for (const option$1 of options) visitedNodes.add(option$1);
2373
2373
  const optionValues = [];
@@ -2381,7 +2381,7 @@ var require_multiflag = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
2381
2381
  else optionValues.push(decoded.value);
2382
2382
  }
2383
2383
  if (errors.length > 0) return Result$3.err({ errors });
2384
- const multiDecoded = await Result$3.safeAsync(config.type.from(optionValues));
2384
+ const multiDecoded = await Result$3.safeAsync(config$1.type.from(optionValues));
2385
2385
  if (Result$3.isErr(multiDecoded)) return Result$3.err({ errors: [{
2386
2386
  nodes: options,
2387
2387
  message: multiDecoded.error.message
@@ -2448,49 +2448,49 @@ var require_multioption = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
2448
2448
  * Like `option`, but can accept multiple options, and expects a decoder from a list of strings.
2449
2449
  * An error will highlight all option occurences.
2450
2450
  */
2451
- function multioption(config) {
2451
+ function multioption(config$1) {
2452
2452
  return {
2453
2453
  helpTopics() {
2454
2454
  var _a, _b;
2455
- const displayName = (_a = config.type.displayName) !== null && _a !== void 0 ? _a : "value";
2456
- let usage = `--${config.long} <${displayName}>`;
2457
- if (config.short) usage += `, -${config.short}=<${displayName}>`;
2455
+ const displayName = (_a = config$1.type.displayName) !== null && _a !== void 0 ? _a : "value";
2456
+ let usage = `--${config$1.long} <${displayName}>`;
2457
+ if (config$1.short) usage += `, -${config$1.short}=<${displayName}>`;
2458
2458
  const defaults = [];
2459
- if (config.defaultValue) try {
2460
- const defaultValue = config.defaultValue();
2461
- if (config.defaultValueIsSerializable) defaults.push(`default: ${chalk_1.default.italic(defaultValue)}`);
2459
+ if (config$1.defaultValue) try {
2460
+ const defaultValue = config$1.defaultValue();
2461
+ if (config$1.defaultValueIsSerializable) defaults.push(`default: ${chalk_1.default.italic(defaultValue)}`);
2462
2462
  else defaults.push("[...optional]");
2463
2463
  } catch (e) {}
2464
- else if (config.type.defaultValue) try {
2465
- const defaultValue = config.type.defaultValue();
2466
- if (config.type.defaultValueIsSerializable) defaults.push(`default: ${chalk_1.default.italic(defaultValue)}`);
2464
+ else if (config$1.type.defaultValue) try {
2465
+ const defaultValue = config$1.type.defaultValue();
2466
+ if (config$1.type.defaultValueIsSerializable) defaults.push(`default: ${chalk_1.default.italic(defaultValue)}`);
2467
2467
  else defaults.push("[...optional]");
2468
2468
  } catch (e) {}
2469
- else if (config.onMissing || config.type.onMissing) defaults.push("[...optional]");
2469
+ else if (config$1.onMissing || config$1.type.onMissing) defaults.push("[...optional]");
2470
2470
  return [{
2471
2471
  category: "options",
2472
2472
  usage,
2473
2473
  defaults,
2474
- description: (_b = config.description) !== null && _b !== void 0 ? _b : "self explanatory"
2474
+ description: (_b = config$1.description) !== null && _b !== void 0 ? _b : "self explanatory"
2475
2475
  }];
2476
2476
  },
2477
2477
  register(opts) {
2478
- opts.forceOptionLongNames.add(config.long);
2479
- if (config.short) opts.forceOptionShortNames.add(config.short);
2478
+ opts.forceOptionLongNames.add(config$1.long);
2479
+ if (config$1.short) opts.forceOptionShortNames.add(config$1.short);
2480
2480
  },
2481
2481
  async parse({ nodes, visitedNodes }) {
2482
2482
  var _a;
2483
2483
  const options = (0, findOption_1.findOption)(nodes, {
2484
- longNames: [config.long],
2485
- shortNames: config.short ? [config.short] : []
2484
+ longNames: [config$1.long],
2485
+ shortNames: config$1.short ? [config$1.short] : []
2486
2486
  }).filter((x) => !visitedNodes.has(x));
2487
- const defaultValueFn = config.defaultValue || config.type.defaultValue;
2488
- const onMissingFn = config.onMissing || config.type.onMissing;
2487
+ const defaultValueFn = config$1.defaultValue || config$1.type.defaultValue;
2488
+ const onMissingFn = config$1.onMissing || config$1.type.onMissing;
2489
2489
  if (options.length === 0 && defaultValueFn) try {
2490
2490
  const defaultValue = defaultValueFn();
2491
2491
  return Result$2.ok(defaultValue);
2492
2492
  } catch (e) {
2493
- const message = `Failed to resolve default value for '--${config.long}': ${e.message}`;
2493
+ const message = `Failed to resolve default value for '--${config$1.long}': ${e.message}`;
2494
2494
  return Result$2.err({ errors: [{
2495
2495
  nodes: [],
2496
2496
  message
@@ -2500,7 +2500,7 @@ var require_multioption = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
2500
2500
  const missingValue = await onMissingFn();
2501
2501
  return Result$2.ok(missingValue);
2502
2502
  } catch (e) {
2503
- const message = `Failed to get missing value for '--${config.long}': ${e.message}`;
2503
+ const message = `Failed to get missing value for '--${config$1.long}': ${e.message}`;
2504
2504
  return Result$2.err({ errors: [{
2505
2505
  nodes: [],
2506
2506
  message
@@ -2523,7 +2523,7 @@ var require_multioption = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
2523
2523
  message: "Expected to get a value, found a flag"
2524
2524
  });
2525
2525
  if (errors.length > 0) return Result$2.err({ errors });
2526
- const multiDecoded = await Result$2.safeAsync(config.type.from(optionValues));
2526
+ const multiDecoded = await Result$2.safeAsync(config$1.type.from(optionValues));
2527
2527
  if (Result$2.isErr(multiDecoded)) return Result$2.err({ errors: [{
2528
2528
  nodes: options,
2529
2529
  message: multiDecoded.error.message
@@ -2671,15 +2671,15 @@ var require_rest = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cmd-
2671
2671
  Object.defineProperty(exports, "__esModule", { value: true });
2672
2672
  exports.rest = rest;
2673
2673
  const Result = __importStar(require_Result());
2674
- function rest(config) {
2674
+ function rest(config$1) {
2675
2675
  return {
2676
2676
  helpTopics() {
2677
2677
  var _a, _b;
2678
2678
  return [{
2679
- usage: `[...${(_a = config === null || config === void 0 ? void 0 : config.displayName) !== null && _a !== void 0 ? _a : "arg"}]`,
2679
+ usage: `[...${(_a = config$1 === null || config$1 === void 0 ? void 0 : config$1.displayName) !== null && _a !== void 0 ? _a : "arg"}]`,
2680
2680
  category: "arguments",
2681
2681
  defaults: [],
2682
- description: (_b = config === null || config === void 0 ? void 0 : config.description) !== null && _b !== void 0 ? _b : "catches the rest of the values"
2682
+ description: (_b = config$1 === null || config$1 === void 0 ? void 0 : config$1.description) !== null && _b !== void 0 ? _b : "catches the rest of the values"
2683
2683
  }];
2684
2684
  },
2685
2685
  register() {},
@@ -2874,11 +2874,11 @@ var require_cjs = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cmd-t
2874
2874
 
2875
2875
  //#endregion
2876
2876
  //#region src/args/runtime.ts
2877
- var import_cjs$20 = /* @__PURE__ */ __toESM(require_cjs());
2878
- const runtime = import_cjs$20.option({
2877
+ var import_cjs$22 = /* @__PURE__ */ __toESM(require_cjs());
2878
+ const runtime = import_cjs$22.option({
2879
2879
  long: "runtime",
2880
2880
  type: {
2881
- ...import_cjs$20.oneOf([
2881
+ ...import_cjs$22.oneOf([
2882
2882
  "node22",
2883
2883
  "node24",
2884
2884
  "python3.13"
@@ -3010,9 +3010,9 @@ var require_ms = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ms@2.1
3010
3010
 
3011
3011
  //#endregion
3012
3012
  //#region src/types/duration.ts
3013
- var import_cjs$19 = require_cjs();
3013
+ var import_cjs$21 = require_cjs();
3014
3014
  init_source();
3015
- const Duration = (0, import_cjs$19.extendType)(import_cjs$19.string, {
3015
+ const Duration = (0, import_cjs$21.extendType)(import_cjs$21.string, {
3016
3016
  displayName: "num UNIT",
3017
3017
  description: "A duration, e.g. 5m, 10s, 1h",
3018
3018
  async from(string$1) {
@@ -3028,8 +3028,8 @@ const Duration = (0, import_cjs$19.extendType)(import_cjs$19.string, {
3028
3028
 
3029
3029
  //#endregion
3030
3030
  //#region src/args/timeout.ts
3031
- var import_cjs$18 = /* @__PURE__ */ __toESM(require_cjs());
3032
- const timeout = import_cjs$18.option({
3031
+ var import_cjs$20 = /* @__PURE__ */ __toESM(require_cjs());
3032
+ const timeout = import_cjs$20.option({
3033
3033
  long: "timeout",
3034
3034
  type: Duration,
3035
3035
  description: "The maximum duration a sandbox can run for. Example: 5m, 1h",
@@ -6802,10 +6802,10 @@ function _usingCtx() {
6802
6802
 
6803
6803
  //#endregion
6804
6804
  //#region src/commands/login.ts
6805
- var import_cjs$17 = /* @__PURE__ */ __toESM(require_cjs());
6805
+ var import_cjs$19 = /* @__PURE__ */ __toESM(require_cjs());
6806
6806
  init_source();
6807
6807
  const debug$5 = createDebugger("sandbox:login");
6808
- const login = import_cjs$17.command({
6808
+ const login = import_cjs$19.command({
6809
6809
  name: "login",
6810
6810
  description: "Log in to the Sandbox CLI",
6811
6811
  args: {},
@@ -7010,15 +7010,15 @@ var require_dist = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@ver
7010
7010
 
7011
7011
  //#endregion
7012
7012
  //#region src/args/auth.ts
7013
- var import_cjs$16 = /* @__PURE__ */ __toESM(require_cjs());
7013
+ var import_cjs$18 = /* @__PURE__ */ __toESM(require_cjs());
7014
7014
  init_source();
7015
7015
  var import_dist = require_dist();
7016
7016
  const debug$4 = createDebugger("sandbox:args:auth");
7017
- const token = import_cjs$16.option({
7017
+ const token = import_cjs$18.option({
7018
7018
  long: "token",
7019
7019
  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.",
7020
7020
  type: {
7021
- ...import_cjs$16.string,
7021
+ ...import_cjs$18.string,
7022
7022
  displayName: "pat_or_oidc",
7023
7023
  defaultValueIsSerializable: false,
7024
7024
  onMissing: async () => {
@@ -7046,7 +7046,7 @@ const token = import_cjs$16.option({
7046
7046
  if (!auth || !auth.token) throw new Error([
7047
7047
  `Failed to retrieve authentication token.`,
7048
7048
  `${source_default.bold("hint:")} Try logging in again with \`sandbox login\`.`,
7049
- "╰▶ Docs: https://vercel.com/docs/sandbox"
7049
+ "╰▶ Docs: https://vercel.com/docs/vercel-sandbox/cli-reference#authentication"
7050
7050
  ].join("\n"));
7051
7051
  return auth.token;
7052
7052
  }
@@ -7184,29 +7184,29 @@ async function inferFromToken(token$1, requestedTeam) {
7184
7184
 
7185
7185
  //#endregion
7186
7186
  //#region src/args/scope.ts
7187
- var import_cjs$15 = /* @__PURE__ */ __toESM(require_cjs());
7187
+ var import_cjs$17 = /* @__PURE__ */ __toESM(require_cjs());
7188
7188
  init_source();
7189
- const project = import_cjs$15.option({
7189
+ const project = import_cjs$17.option({
7190
7190
  long: "project",
7191
7191
  type: {
7192
- ...import_cjs$15.optional(import_cjs$15.string),
7192
+ ...import_cjs$17.optional(import_cjs$17.string),
7193
7193
  displayName: "my-project"
7194
7194
  },
7195
7195
  description: "The project name or ID to associate with the command. Can be inferred from VERCEL_OIDC_TOKEN."
7196
7196
  });
7197
7197
  /** Parser for the `--team` option. */
7198
- const teamParser = import_cjs$15.option({
7198
+ const teamParser = import_cjs$17.option({
7199
7199
  long: "team",
7200
7200
  type: {
7201
- ...import_cjs$15.optional(import_cjs$15.string),
7201
+ ...import_cjs$17.optional(import_cjs$17.string),
7202
7202
  displayName: "my-team"
7203
7203
  }
7204
7204
  });
7205
7205
  /** Parser for the `--scope` option. */
7206
- const scopeParser = import_cjs$15.option({
7206
+ const scopeParser = import_cjs$17.option({
7207
7207
  long: "scope",
7208
7208
  type: {
7209
- ...import_cjs$15.optional(import_cjs$15.string),
7209
+ ...import_cjs$17.optional(import_cjs$17.string),
7210
7210
  displayName: "my-team"
7211
7211
  },
7212
7212
  description: "The scope/team to associate with the command. Can be inferred from VERCEL_OIDC_TOKEN. [alias: --team]"
@@ -7292,7 +7292,7 @@ const scope = {
7292
7292
 
7293
7293
  //#endregion
7294
7294
  //#region package.json
7295
- var version = "2.0.4";
7295
+ var version = "2.2.0";
7296
7296
 
7297
7297
  //#endregion
7298
7298
  //#region src/error.ts
@@ -7354,12 +7354,13 @@ async function handleApiError(error) {
7354
7354
  const tmpPath = await writeResponseToTemp(error);
7355
7355
  const status = error.response.status;
7356
7356
  throw new StyledError([
7357
- getErrorMessage(status),
7357
+ ApiErrorResponse.safeParse(error.json).data?.error.message ?? getErrorMessage(status),
7358
7358
  `├▶ requested url: ${error.response.url}`,
7359
7359
  `├▶ status code: ${status} ${error.response.statusText}`,
7360
7360
  `╰▶ ${source_default.bold("hint:")} the full response buffer is stored in ${source_default.italic(tmpPath)}`
7361
7361
  ].join("\n"), error);
7362
7362
  }
7363
+ const ApiErrorResponse = z$1.object({ error: z$1.object({ message: z$1.string() }) });
7363
7364
  function getErrorMessage(status) {
7364
7365
  if (status === 401 || status === 403) return "Sandbox API request failed due to authentication. Check your token or run `sandbox login`.";
7365
7366
  if (status === 404) return "Sandbox API request failed: resource not found.";
@@ -7381,9 +7382,9 @@ async function writeResponseToTemp({ response, text }) {
7381
7382
 
7382
7383
  //#endregion
7383
7384
  //#region src/args/snapshot-id.ts
7384
- var import_cjs$14 = /* @__PURE__ */ __toESM(require_cjs());
7385
+ var import_cjs$16 = /* @__PURE__ */ __toESM(require_cjs());
7385
7386
  init_source();
7386
- const snapshotId = import_cjs$14.extendType(import_cjs$14.string, {
7387
+ const snapshotId = import_cjs$16.extendType(import_cjs$16.string, {
7387
7388
  displayName: "snapshot_id",
7388
7389
  description: "The ID of the snapshot",
7389
7390
  async from(s$1) {
@@ -7392,102 +7393,11 @@ const snapshotId = import_cjs$14.extendType(import_cjs$14.string, {
7392
7393
  }
7393
7394
  });
7394
7395
 
7395
- //#endregion
7396
- //#region src/commands/create.ts
7397
- var import_cjs$13 = /* @__PURE__ */ __toESM(require_cjs());
7398
- var import_ms$1 = /* @__PURE__ */ __toESM(require_ms());
7399
- init_source();
7400
- const args$3 = {
7401
- scope,
7402
- runtime,
7403
- timeout,
7404
- ports: import_cjs$13.multioption({
7405
- long: "publish-port",
7406
- short: "p",
7407
- description: "Publish sandbox port(s) to DOMAIN.vercel.run",
7408
- type: import_cjs$13.array(import_cjs$13.extendType(import_cjs$13.number, {
7409
- displayName: "PORT",
7410
- async from(number) {
7411
- if (number < 1024 || number > 65535) throw new Error([
7412
- `Invalid port: ${number}.`,
7413
- `${source_default.bold("hint:")} Ports must be between 1024-65535 (privileged ports 0-1023 are reserved).`,
7414
- "╰▶ Examples: 3000, 8080, 8443"
7415
- ].join("\n"));
7416
- return number;
7417
- }
7418
- }))
7419
- }),
7420
- silent: import_cjs$13.flag({
7421
- long: "silent",
7422
- description: "Don't write sandbox ID to stdout"
7423
- }),
7424
- snapshot: import_cjs$13.option({
7425
- long: "snapshot",
7426
- short: "s",
7427
- description: "Start the sandbox from a snapshot ID",
7428
- type: import_cjs$13.optional(snapshotId)
7429
- })
7430
- };
7431
- const create = import_cjs$13.command({
7432
- name: "create",
7433
- description: "Create a sandbox in the specified account and project.",
7434
- args: args$3,
7435
- async handler({ ports, scope: scope$1, runtime: runtime$1, timeout: timeout$1, silent, snapshot: snapshot$1 }) {
7436
- const spinner = silent ? void 0 : ora("Creating sandbox...").start();
7437
- const sandbox = snapshot$1 ? await sandboxClient.create({
7438
- source: {
7439
- type: "snapshot",
7440
- snapshotId: snapshot$1
7441
- },
7442
- teamId: scope$1.team,
7443
- projectId: scope$1.project,
7444
- token: scope$1.token,
7445
- ports,
7446
- timeout: (0, import_ms$1.default)(timeout$1),
7447
- __interactive: true
7448
- }) : await sandboxClient.create({
7449
- teamId: scope$1.team,
7450
- projectId: scope$1.project,
7451
- token: scope$1.token,
7452
- ports,
7453
- runtime: runtime$1,
7454
- timeout: (0, import_ms$1.default)(timeout$1),
7455
- __interactive: true
7456
- });
7457
- spinner?.stop();
7458
- if (!sandbox.interactivePort) throw new Error([
7459
- `Sandbox created but interactive port is missing.`,
7460
- `${source_default.bold("hint:")} This is an internal error. Please try again.`,
7461
- "╰▶ Report this issue: https://github.com/vercel/sandbox/issues"
7462
- ].join("\n"));
7463
- const routes = sandbox.routes.filter((x) => x.port !== sandbox.interactivePort);
7464
- if (!silent) {
7465
- const teamDisplay = scope$1.teamSlug ?? scope$1.team;
7466
- const projectDisplay = scope$1.projectSlug ?? scope$1.project;
7467
- const hasPorts = routes.length > 0;
7468
- process.stderr.write("✅ Sandbox ");
7469
- process.stdout.write(source_default.cyan(sandbox.sandboxId));
7470
- process.stderr.write(" created.\n");
7471
- process.stderr.write(source_default.dim(" │ ") + "team: " + source_default.cyan(teamDisplay) + "\n");
7472
- if (hasPorts) {
7473
- process.stderr.write(source_default.dim(" │ ") + "project: " + source_default.cyan(projectDisplay) + "\n");
7474
- process.stderr.write(source_default.dim(" │ ") + "ports:\n");
7475
- for (let i = 0; i < routes.length; i++) {
7476
- const route = routes[i];
7477
- const prefix$1 = i === routes.length - 1 ? source_default.dim(" ╰ ") : source_default.dim(" │ ");
7478
- process.stderr.write(prefix$1 + "• " + route.port + " -> " + source_default.cyan(route.url) + "\n");
7479
- }
7480
- } else process.stderr.write(source_default.dim(" ╰ ") + "project: " + source_default.cyan(projectDisplay) + "\n");
7481
- }
7482
- return sandbox;
7483
- }
7484
- });
7485
-
7486
7396
  //#endregion
7487
7397
  //#region src/args/sandbox-id.ts
7488
- var import_cjs$12 = /* @__PURE__ */ __toESM(require_cjs());
7398
+ var import_cjs$15 = /* @__PURE__ */ __toESM(require_cjs());
7489
7399
  init_source();
7490
- const sandboxId = import_cjs$12.extendType(import_cjs$12.string, {
7400
+ const sandboxId = import_cjs$15.extendType(import_cjs$15.string, {
7491
7401
  displayName: "sandbox_id",
7492
7402
  description: "The ID of the sandbox to execute the command in",
7493
7403
  async from(s$1) {
@@ -11201,9 +11111,9 @@ function printCommand(command$1, args$4) {
11201
11111
 
11202
11112
  //#endregion
11203
11113
  //#region src/interactive-shell/extend-sandbox-timeout.ts
11204
- var import_ms = /* @__PURE__ */ __toESM(require_ms());
11114
+ var import_ms$1 = /* @__PURE__ */ __toESM(require_ms());
11205
11115
  const debug$2 = createDebugger("sandbox:timeout");
11206
- const BUFFER = (0, import_ms.default)("10 seconds");
11116
+ const BUFFER = (0, import_ms$1.default)("10 seconds");
11207
11117
  async function extendSandboxTimeoutPeriodically(sandbox, signal) {
11208
11118
  const nextTick = sandbox.createdAt.getTime() + sandbox.timeout;
11209
11119
  debug$2(`next tick: ${new Date(nextTick).toISOString()}`);
@@ -11213,7 +11123,7 @@ async function extendSandboxTimeoutPeriodically(sandbox, signal) {
11213
11123
  debug$2(`sleeping for ${timeout$1}ms until next timeout extension`);
11214
11124
  await setTimeout$1(timeout$1, null, { signal });
11215
11125
  }
11216
- await sandbox.extendTimeout((0, import_ms.default)("5 minutes"));
11126
+ await sandbox.extendTimeout((0, import_ms$1.default)("5 minutes"));
11217
11127
  const nextTick$1 = sandbox.createdAt.getTime() + sandbox.timeout;
11218
11128
  debug$2(`extended sandbox timeout by 5 minutes. next tick: ${new Date(nextTick$1).toISOString()}`);
11219
11129
  }
@@ -11346,7 +11256,7 @@ async function startInteractiveShell(options) {
11346
11256
  listener.connection.then(() => {
11347
11257
  waitForProcess.abort();
11348
11258
  });
11349
- connect(command$1, listener, waitForProcess.signal).catch(waitForProcess.ignoreInterruptions);
11259
+ connect$1(command$1, listener, waitForProcess.signal).catch(waitForProcess.ignoreInterruptions);
11350
11260
  await Promise.all([throwIfCommandPrematurelyExited(command$1, waitForProcess.signal), attach({
11351
11261
  sandbox: options.sandbox,
11352
11262
  progress,
@@ -11442,7 +11352,7 @@ async function* messageReader(stream) {
11442
11352
  /**
11443
11353
  * Connects the command's logs to the listener's stdout and stderr streams.
11444
11354
  */
11445
- async function connect(command$1, listener, signal) {
11355
+ async function connect$1(command$1, listener, signal) {
11446
11356
  try {
11447
11357
  var _usingCtx5 = _usingCtx();
11448
11358
  const logs = _usingCtx5.u(command$1.logs({ signal }));
@@ -11479,9 +11389,9 @@ function getStderrStream() {
11479
11389
 
11480
11390
  //#endregion
11481
11391
  //#region src/args/key-value-pair.ts
11482
- var import_cjs$11 = /* @__PURE__ */ __toESM(require_cjs());
11392
+ var import_cjs$14 = /* @__PURE__ */ __toESM(require_cjs());
11483
11393
  init_source();
11484
- const KeyValuePair = import_cjs$11.extendType(import_cjs$11.string, {
11394
+ const KeyValuePair = import_cjs$14.extendType(import_cjs$14.string, {
11485
11395
  displayName: "key=value",
11486
11396
  async from(input) {
11487
11397
  if (!input.includes("=")) return {
@@ -11495,7 +11405,7 @@ const KeyValuePair = import_cjs$11.extendType(import_cjs$11.string, {
11495
11405
  };
11496
11406
  }
11497
11407
  });
11498
- const ObjectFromKeyValue = import_cjs$11.extendType(import_cjs$11.array(KeyValuePair), { async from(input) {
11408
+ const ObjectFromKeyValue = import_cjs$14.extendType(import_cjs$14.array(KeyValuePair), { async from(input) {
11499
11409
  const obj = Object.create(null);
11500
11410
  const missingVars = [];
11501
11411
  for (const { key, value } of input) if (value === void 0) missingVars.push(key);
@@ -11509,34 +11419,34 @@ const ObjectFromKeyValue = import_cjs$11.extendType(import_cjs$11.array(KeyValue
11509
11419
 
11510
11420
  //#endregion
11511
11421
  //#region src/commands/exec.ts
11512
- var import_cjs$10 = /* @__PURE__ */ __toESM(require_cjs());
11422
+ var import_cjs$13 = /* @__PURE__ */ __toESM(require_cjs());
11513
11423
  init_source();
11514
- const args$2 = {
11424
+ const args$3 = {
11515
11425
  scope,
11516
- sandbox: import_cjs$10.positional({ type: sandboxId }),
11517
- asSudo: import_cjs$10.flag({
11426
+ sandbox: import_cjs$13.positional({ type: sandboxId }),
11427
+ asSudo: import_cjs$13.flag({
11518
11428
  long: "sudo",
11519
11429
  description: "Give extended privileges to the command."
11520
11430
  }),
11521
- command: import_cjs$10.positional({
11431
+ command: import_cjs$13.positional({
11522
11432
  displayName: "command",
11523
11433
  description: "The executable to invoke"
11524
11434
  }),
11525
- args: import_cjs$10.rest({
11435
+ args: import_cjs$13.rest({
11526
11436
  displayName: "args",
11527
11437
  description: "arguments to pass to the command"
11528
11438
  }),
11529
- cwd: import_cjs$10.option({
11439
+ cwd: import_cjs$13.option({
11530
11440
  long: "workdir",
11531
11441
  short: "w",
11532
11442
  description: "The working directory to run the command in",
11533
- type: import_cjs$10.optional(import_cjs$10.string)
11443
+ type: import_cjs$13.optional(import_cjs$13.string)
11534
11444
  }),
11535
- interactive: import_cjs$10.flag({
11445
+ interactive: import_cjs$13.flag({
11536
11446
  long: "interactive",
11537
11447
  short: "i",
11538
11448
  description: "Run the command in a secure interactive shell",
11539
- type: import_cjs$10.extendType(import_cjs$10.boolean, {
11449
+ type: import_cjs$13.extendType(import_cjs$13.boolean, {
11540
11450
  defaultValue() {
11541
11451
  return false;
11542
11452
  },
@@ -11546,26 +11456,26 @@ const args$2 = {
11546
11456
  }
11547
11457
  })
11548
11458
  }),
11549
- skipExtendingTimeout: import_cjs$10.flag({
11459
+ skipExtendingTimeout: import_cjs$13.flag({
11550
11460
  long: "no-extend-timeout",
11551
11461
  description: "Do not extend the sandbox timeout while running an interactive command. Only affects interactive executions."
11552
11462
  }),
11553
- envVars: import_cjs$10.multioption({
11463
+ envVars: import_cjs$13.multioption({
11554
11464
  long: "env",
11555
11465
  short: "e",
11556
11466
  type: ObjectFromKeyValue,
11557
11467
  description: "Environment variables to set for the command"
11558
11468
  }),
11559
- tty: import_cjs$10.flag({
11469
+ tty: import_cjs$13.flag({
11560
11470
  long: "tty",
11561
11471
  short: "t",
11562
11472
  description: "Allocate a tty for an interactive command. This is a no-op."
11563
11473
  })
11564
11474
  };
11565
- const exec = import_cjs$10.command({
11475
+ const exec = import_cjs$13.command({
11566
11476
  name: "exec",
11567
11477
  description: "Execute a command in an existing sandbox",
11568
- args: args$2,
11478
+ args: args$3,
11569
11479
  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 }) {
11570
11480
  const sandbox = typeof sandboxId$1 !== "string" ? sandboxId$1 : await sandboxClient.get({
11571
11481
  sandboxId: sandboxId$1,
@@ -11607,6 +11517,201 @@ const exec = import_cjs$10.command({
11607
11517
  }
11608
11518
  });
11609
11519
 
11520
+ //#endregion
11521
+ //#region src/args/network-policy.ts
11522
+ var import_cjs$12 = /* @__PURE__ */ __toESM(require_cjs());
11523
+ init_source();
11524
+ const networkPolicyMode = import_cjs$12.extendType(import_cjs$12.string, {
11525
+ displayName: "MODE",
11526
+ async from(value) {
11527
+ const validModes = [
11528
+ "internet-access",
11529
+ "no-access",
11530
+ "restricted"
11531
+ ];
11532
+ if (!validModes.includes(value)) throw new Error([`Invalid network policy mode: ${value}.`, `${source_default.bold("hint:")} Valid modes are: ${validModes.join(", ")}`].join("\n"));
11533
+ return value;
11534
+ }
11535
+ });
11536
+ const networkPolicy = import_cjs$12.option({
11537
+ long: "network-policy",
11538
+ description: `Network policy mode: "internet-access", "no-access", or "restricted"
11539
+
11540
+ internet-access: sandbox can access any website/domain
11541
+ no-access: sandbox has no network access
11542
+ restricted: sandbox can only access websites and domains explicitly allowed`,
11543
+ type: import_cjs$12.optional(networkPolicyMode)
11544
+ });
11545
+ const allowedDomains = import_cjs$12.multioption({
11546
+ long: "allowed-domain",
11547
+ description: `Domain to allow traffic to (requires --network-policy=restricted)
11548
+
11549
+ Supports "*" for wildcards for a segment (e.g. '*.vercel.com', 'www.*.com')
11550
+ If used as the first segment, will match any subdomain.`,
11551
+ type: import_cjs$12.array(import_cjs$12.string)
11552
+ });
11553
+ const allowedCIDRs = import_cjs$12.multioption({
11554
+ long: "allowed-cidr",
11555
+ description: `CIDR to allow traffic to (requires --network-policy=restricted)
11556
+
11557
+ Takes precedence over 'allowed-domain'.
11558
+ `,
11559
+ type: import_cjs$12.array(import_cjs$12.string)
11560
+ });
11561
+ const deniedCIDRs = import_cjs$12.multioption({
11562
+ long: "denied-cidr",
11563
+ description: `CIDR to deny traffic to (requires --network-policy=restricted)
11564
+
11565
+ Takes precedence over allowed domains/CIDRs.`,
11566
+ type: import_cjs$12.array(import_cjs$12.string)
11567
+ });
11568
+ const networkPolicyArgs = {
11569
+ networkPolicy,
11570
+ allowedDomains,
11571
+ allowedCIDRs,
11572
+ deniedCIDRs
11573
+ };
11574
+
11575
+ //#endregion
11576
+ //#region src/util/network-policy.ts
11577
+ init_source();
11578
+ /**
11579
+ * Builds a NetworkPolicy from CLI arguments (optional mode for create).
11580
+ */
11581
+ function buildNetworkPolicy(args$4) {
11582
+ const { networkPolicy: networkPolicy$1, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 } = args$4;
11583
+ if (!networkPolicy$1 || networkPolicy$1 !== "restricted") {
11584
+ if (allowedDomains$1.length > 0 || allowedCIDRs$1.length > 0 || deniedCIDRs$1.length > 0) throw new Error(["Network policy options require --network-policy to be set to restricted.", `${source_default.bold("hint:")} Use --network-policy=restricted to allow/deny specific domains or CIDRs.`].join("\n"));
11585
+ }
11586
+ switch (networkPolicy$1) {
11587
+ case void 0:
11588
+ case "internet-access": return { type: "internet-access" };
11589
+ case "no-access": return { type: "no-access" };
11590
+ case "restricted": return {
11591
+ type: "restricted",
11592
+ allowedDomains: allowedDomains$1.length > 0 ? allowedDomains$1 : void 0,
11593
+ allowedCIDRs: allowedCIDRs$1.length > 0 ? allowedCIDRs$1 : void 0,
11594
+ deniedCIDRs: deniedCIDRs$1.length > 0 ? deniedCIDRs$1 : void 0
11595
+ };
11596
+ }
11597
+ }
11598
+
11599
+ //#endregion
11600
+ //#region src/commands/create.ts
11601
+ var import_cjs$11 = /* @__PURE__ */ __toESM(require_cjs());
11602
+ var import_ms = /* @__PURE__ */ __toESM(require_ms());
11603
+ init_source();
11604
+ const args$2 = {
11605
+ scope,
11606
+ runtime,
11607
+ timeout,
11608
+ ports: import_cjs$11.multioption({
11609
+ long: "publish-port",
11610
+ short: "p",
11611
+ description: "Publish sandbox port(s) to DOMAIN.vercel.run",
11612
+ type: import_cjs$11.array(import_cjs$11.extendType(import_cjs$11.number, {
11613
+ displayName: "PORT",
11614
+ async from(number) {
11615
+ if (number < 1024 || number > 65535) throw new Error([
11616
+ `Invalid port: ${number}.`,
11617
+ `${source_default.bold("hint:")} Ports must be between 1024-65535 (privileged ports 0-1023 are reserved).`,
11618
+ "╰▶ Examples: 3000, 8080, 8443"
11619
+ ].join("\n"));
11620
+ return number;
11621
+ }
11622
+ }))
11623
+ }),
11624
+ silent: import_cjs$11.flag({
11625
+ long: "silent",
11626
+ description: "Don't write sandbox ID to stdout"
11627
+ }),
11628
+ snapshot: import_cjs$11.option({
11629
+ long: "snapshot",
11630
+ short: "s",
11631
+ description: "Start the sandbox from a snapshot ID",
11632
+ type: import_cjs$11.optional(snapshotId)
11633
+ }),
11634
+ connect: import_cjs$11.flag({
11635
+ long: "connect",
11636
+ description: "Start an interactive shell session after creating the sandbox"
11637
+ }),
11638
+ ...networkPolicyArgs
11639
+ };
11640
+ const create = import_cjs$11.command({
11641
+ name: "create",
11642
+ description: "Create a sandbox in the specified account and project.",
11643
+ args: args$2,
11644
+ async handler({ ports, scope: scope$1, runtime: runtime$1, timeout: timeout$1, silent, snapshot: snapshot$1, connect: connect$2, networkPolicy: networkPolicyMode$1, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 }) {
11645
+ const networkPolicy$1 = buildNetworkPolicy({
11646
+ networkPolicy: networkPolicyMode$1,
11647
+ allowedDomains: allowedDomains$1,
11648
+ allowedCIDRs: allowedCIDRs$1,
11649
+ deniedCIDRs: deniedCIDRs$1
11650
+ });
11651
+ const spinner = silent ? void 0 : ora("Creating sandbox...").start();
11652
+ const sandbox = snapshot$1 ? await sandboxClient.create({
11653
+ source: {
11654
+ type: "snapshot",
11655
+ snapshotId: snapshot$1
11656
+ },
11657
+ teamId: scope$1.team,
11658
+ projectId: scope$1.project,
11659
+ token: scope$1.token,
11660
+ ports,
11661
+ timeout: (0, import_ms.default)(timeout$1),
11662
+ networkPolicy: networkPolicy$1,
11663
+ __interactive: true
11664
+ }) : await sandboxClient.create({
11665
+ teamId: scope$1.team,
11666
+ projectId: scope$1.project,
11667
+ token: scope$1.token,
11668
+ ports,
11669
+ runtime: runtime$1,
11670
+ timeout: (0, import_ms.default)(timeout$1),
11671
+ networkPolicy: networkPolicy$1,
11672
+ __interactive: true
11673
+ });
11674
+ spinner?.stop();
11675
+ if (!sandbox.interactivePort) throw new Error([
11676
+ `Sandbox created but interactive port is missing.`,
11677
+ `${source_default.bold("hint:")} This is an internal error. Please try again.`,
11678
+ "╰▶ Report this issue: https://github.com/vercel/sandbox/issues"
11679
+ ].join("\n"));
11680
+ const routes = sandbox.routes.filter((x) => x.port !== sandbox.interactivePort);
11681
+ if (!silent) {
11682
+ const teamDisplay = scope$1.teamSlug ?? scope$1.team;
11683
+ const projectDisplay = scope$1.projectSlug ?? scope$1.project;
11684
+ const hasPorts = routes.length > 0;
11685
+ process.stderr.write("✅ Sandbox ");
11686
+ process.stdout.write(source_default.cyan(sandbox.sandboxId));
11687
+ process.stderr.write(" created.\n");
11688
+ process.stderr.write(source_default.dim(" │ ") + "team: " + source_default.cyan(teamDisplay) + "\n");
11689
+ if (hasPorts) {
11690
+ process.stderr.write(source_default.dim(" │ ") + "project: " + source_default.cyan(projectDisplay) + "\n");
11691
+ process.stderr.write(source_default.dim(" │ ") + "ports:\n");
11692
+ for (let i = 0; i < routes.length; i++) {
11693
+ const route = routes[i];
11694
+ const prefix$1 = i === routes.length - 1 ? source_default.dim(" ╰ ") : source_default.dim(" │ ");
11695
+ process.stderr.write(prefix$1 + "• " + route.port + " -> " + source_default.cyan(route.url) + "\n");
11696
+ }
11697
+ } else process.stderr.write(source_default.dim(" ╰ ") + "project: " + source_default.cyan(projectDisplay) + "\n");
11698
+ }
11699
+ if (connect$2) await exec.handler({
11700
+ scope: scope$1,
11701
+ asSudo: false,
11702
+ args: [],
11703
+ cwd: void 0,
11704
+ skipExtendingTimeout: false,
11705
+ envVars: {},
11706
+ command: "sh",
11707
+ interactive: true,
11708
+ tty: true,
11709
+ sandbox
11710
+ });
11711
+ return sandbox;
11712
+ }
11713
+ });
11714
+
11610
11715
  //#endregion
11611
11716
  //#region src/util/omit.ts
11612
11717
  function omit(obj, ...keys) {
@@ -11617,16 +11722,16 @@ function omit(obj, ...keys) {
11617
11722
 
11618
11723
  //#endregion
11619
11724
  //#region src/commands/run.ts
11620
- var import_cjs$9 = /* @__PURE__ */ __toESM(require_cjs());
11725
+ var import_cjs$10 = /* @__PURE__ */ __toESM(require_cjs());
11621
11726
  const args$1 = {
11622
- ...args$3,
11623
- ...omit(args$2, "sandbox"),
11624
- removeAfterUse: import_cjs$9.flag({
11727
+ ...args$2,
11728
+ ...omit(args$3, "sandbox"),
11729
+ removeAfterUse: import_cjs$10.flag({
11625
11730
  long: "rm",
11626
11731
  description: "Automatically remove the sandbox when the command exits."
11627
11732
  })
11628
11733
  };
11629
- const run = import_cjs$9.command({
11734
+ const run = import_cjs$10.command({
11630
11735
  name: "run",
11631
11736
  description: "Create and run a command in a sandbox",
11632
11737
  args: args$1,
@@ -11642,32 +11747,18 @@ const run = import_cjs$9.command({
11642
11747
  }
11643
11748
  }
11644
11749
  });
11645
- const sh = import_cjs$9.command({
11646
- name: "sh",
11647
- description: "Create a sandbox and run an interactive shell.",
11648
- aliases: ["shell"],
11649
- args: omit(args$1, "command", "interactive", "tty"),
11650
- async handler(args$4) {
11651
- return run.handler({
11652
- command: "sh",
11653
- interactive: true,
11654
- tty: true,
11655
- ...args$4
11656
- });
11657
- }
11658
- });
11659
11750
 
11660
11751
  //#endregion
11661
11752
  //#region src/commands/list.ts
11662
- var import_cjs$8 = /* @__PURE__ */ __toESM(require_cjs());
11753
+ var import_cjs$9 = /* @__PURE__ */ __toESM(require_cjs());
11663
11754
  init_source();
11664
- const list = import_cjs$8.command({
11755
+ const list = import_cjs$9.command({
11665
11756
  name: "list",
11666
11757
  aliases: ["ls"],
11667
11758
  description: "List all sandboxes for the specified account and project.",
11668
11759
  args: {
11669
11760
  scope,
11670
- all: import_cjs$8.flag({
11761
+ all: import_cjs$9.flag({
11671
11762
  long: "all",
11672
11763
  short: "a",
11673
11764
  description: "Show all sandboxes (default shows just running)"
@@ -11724,12 +11815,13 @@ const SandboxStatusColor = new Map([
11724
11815
  ]);
11725
11816
 
11726
11817
  //#endregion
11727
- //#region src/commands/ssh.ts
11728
- var import_cjs$7 = /* @__PURE__ */ __toESM(require_cjs());
11729
- const ssh = import_cjs$7.command({
11730
- name: "ssh",
11818
+ //#region src/commands/connect.ts
11819
+ var import_cjs$8 = /* @__PURE__ */ __toESM(require_cjs());
11820
+ const connect = import_cjs$8.command({
11821
+ name: "connect",
11822
+ aliases: ["ssh", "shell"],
11731
11823
  description: "Start an interactive shell in an existing sandbox",
11732
- args: omit(args$2, "command", "args", "interactive", "tty"),
11824
+ args: omit(args$3, "command", "args", "interactive", "tty"),
11733
11825
  async handler(args$4) {
11734
11826
  return exec.handler({
11735
11827
  command: "sh",
@@ -14026,18 +14118,18 @@ var Listr = class {
14026
14118
 
14027
14119
  //#endregion
14028
14120
  //#region src/commands/stop.ts
14029
- var import_cjs$6 = /* @__PURE__ */ __toESM(require_cjs());
14030
- const stop = import_cjs$6.command({
14121
+ var import_cjs$7 = /* @__PURE__ */ __toESM(require_cjs());
14122
+ const stop = import_cjs$7.command({
14031
14123
  name: "stop",
14032
14124
  aliases: ["rm", "remove"],
14033
14125
  description: "Stop one or more running sandboxes",
14034
14126
  args: {
14035
14127
  scope,
14036
- sandboxId: import_cjs$6.positional({
14128
+ sandboxId: import_cjs$7.positional({
14037
14129
  type: sandboxId,
14038
14130
  description: "a sandbox ID to stop"
14039
14131
  }),
14040
- sandboxIds: import_cjs$6.restPositionals({
14132
+ sandboxIds: import_cjs$7.restPositionals({
14041
14133
  type: sandboxId,
14042
14134
  description: "more sandboxes to stop"
14043
14135
  })
@@ -14110,10 +14202,10 @@ var require_fs = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cmd-ts
14110
14202
 
14111
14203
  //#endregion
14112
14204
  //#region src/commands/cp.ts
14113
- var import_cjs$5 = /* @__PURE__ */ __toESM(require_cjs());
14205
+ var import_cjs$6 = /* @__PURE__ */ __toESM(require_cjs());
14114
14206
  var import_fs = /* @__PURE__ */ __toESM(require_fs());
14115
14207
  init_source();
14116
- const localOrRemote = import_cjs$5.extendType(import_cjs$5.string, { async from(input) {
14208
+ const localOrRemote = import_cjs$6.extendType(import_cjs$6.string, { async from(input) {
14117
14209
  const parts = input.split(":");
14118
14210
  if (parts.length === 2) {
14119
14211
  const [id, path$1] = parts;
@@ -14133,18 +14225,18 @@ const localOrRemote = import_cjs$5.extendType(import_cjs$5.string, { async from(
14133
14225
  file: await import_fs.File.from(input)
14134
14226
  };
14135
14227
  } });
14136
- const cp = import_cjs$5.command({
14228
+ const cp = import_cjs$6.command({
14137
14229
  name: "copy",
14138
14230
  description: "Copy files between your local filesystem and a remote sandbox",
14139
14231
  aliases: ["cp"],
14140
14232
  args: {
14141
14233
  scope,
14142
- source: import_cjs$5.positional({
14234
+ source: import_cjs$6.positional({
14143
14235
  displayName: `SANDBOX_ID:PATH`,
14144
14236
  description: `The source file to copy from local file system, or or a sandbox_id:path from a remote sandbox`,
14145
14237
  type: localOrRemote
14146
14238
  }),
14147
- dest: import_cjs$5.positional({
14239
+ dest: import_cjs$6.positional({
14148
14240
  displayName: `SANDBOX_ID:PATH`,
14149
14241
  description: `The destination file to copy to local file system, or or a sandbox_id:path to a remote sandbox`,
14150
14242
  type: localOrRemote
@@ -14186,10 +14278,10 @@ const cp = import_cjs$5.command({
14186
14278
 
14187
14279
  //#endregion
14188
14280
  //#region src/commands/logout.ts
14189
- var import_cjs$4 = /* @__PURE__ */ __toESM(require_cjs());
14281
+ var import_cjs$5 = /* @__PURE__ */ __toESM(require_cjs());
14190
14282
  init_source();
14191
14283
  const debug = createDebugger("sandbox:logout");
14192
- const logout = import_cjs$4.command({
14284
+ const logout = import_cjs$5.command({
14193
14285
  name: "logout",
14194
14286
  description: "Log out of the Sandbox CLI",
14195
14287
  args: {},
@@ -14208,21 +14300,21 @@ const logout = import_cjs$4.command({
14208
14300
 
14209
14301
  //#endregion
14210
14302
  //#region src/commands/snapshot.ts
14211
- var import_cjs$3 = /* @__PURE__ */ __toESM(require_cjs());
14303
+ var import_cjs$4 = /* @__PURE__ */ __toESM(require_cjs());
14212
14304
  init_source();
14213
14305
  const args = {
14214
14306
  scope,
14215
- stop: import_cjs$3.flag({
14307
+ stop: import_cjs$4.flag({
14216
14308
  long: "stop",
14217
14309
  description: "Confirm that the sandbox will be stopped when snapshotting"
14218
14310
  }),
14219
- silent: import_cjs$3.flag({
14311
+ silent: import_cjs$4.flag({
14220
14312
  long: "silent",
14221
14313
  description: "Don't write snapshot ID to stdout"
14222
14314
  }),
14223
- sandbox: import_cjs$3.positional({ type: sandboxId })
14315
+ sandbox: import_cjs$4.positional({ type: sandboxId })
14224
14316
  };
14225
- const snapshot = import_cjs$3.command({
14317
+ const snapshot = import_cjs$4.command({
14226
14318
  name: "snapshot",
14227
14319
  description: "Take a snapshot of the filesystem of a sandbox",
14228
14320
  args,
@@ -14256,10 +14348,10 @@ const snapshot = import_cjs$3.command({
14256
14348
 
14257
14349
  //#endregion
14258
14350
  //#region src/commands/snapshots.ts
14259
- var import_cjs$1 = /* @__PURE__ */ __toESM(require_cjs());
14260
- var import_cjs$2 = require_cjs();
14351
+ var import_cjs$2 = /* @__PURE__ */ __toESM(require_cjs());
14352
+ var import_cjs$3 = require_cjs();
14261
14353
  init_source();
14262
- const list$1 = import_cjs$1.command({
14354
+ const list$1 = import_cjs$2.command({
14263
14355
  name: "list",
14264
14356
  aliases: ["ls"],
14265
14357
  description: "List snapshots for the specified account and project.",
@@ -14298,17 +14390,17 @@ const list$1 = import_cjs$1.command({
14298
14390
  }));
14299
14391
  }
14300
14392
  });
14301
- const remove = import_cjs$1.command({
14393
+ const remove = import_cjs$2.command({
14302
14394
  name: "delete",
14303
14395
  aliases: ["rm", "remove"],
14304
14396
  description: "Delete one or more snapshots.",
14305
14397
  args: {
14306
14398
  scope,
14307
- snapshotId: import_cjs$1.positional({
14399
+ snapshotId: import_cjs$2.positional({
14308
14400
  type: snapshotId,
14309
14401
  description: "snapshot ID to delete"
14310
14402
  }),
14311
- snapshotIds: import_cjs$1.restPositionals({
14403
+ snapshotIds: import_cjs$2.restPositionals({
14312
14404
  type: snapshotId,
14313
14405
  description: "More snapshots IDs to delete"
14314
14406
  })
@@ -14331,7 +14423,7 @@ const remove = import_cjs$1.command({
14331
14423
  }), { concurrent: true }).run();
14332
14424
  }
14333
14425
  });
14334
- const snapshots = (0, import_cjs$2.subcommands)({
14426
+ const snapshots = (0, import_cjs$3.subcommands)({
14335
14427
  name: "snapshots",
14336
14428
  description: "Manage sandbox snapshots",
14337
14429
  cmds: {
@@ -14345,6 +14437,62 @@ const SnapshotStatusColor = new Map([
14345
14437
  ["failed", source_default.red]
14346
14438
  ]);
14347
14439
 
14440
+ //#endregion
14441
+ //#region src/commands/config.ts
14442
+ var import_cjs$1 = /* @__PURE__ */ __toESM(require_cjs());
14443
+ init_source();
14444
+ const networkPolicyCommand = import_cjs$1.command({
14445
+ name: "network-policy",
14446
+ description: `Update the network policy of a sandbox
14447
+
14448
+ This is a full update, fully overriding the pre-existing configuration.`,
14449
+ args: {
14450
+ scope,
14451
+ sandbox: import_cjs$1.positional({ type: sandboxId }),
14452
+ ...networkPolicyArgs
14453
+ },
14454
+ async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandbox: sandboxId$1, networkPolicy: networkPolicyMode$1, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 }) {
14455
+ if (networkPolicyMode$1 === void 0) throw new Error(`Network policy mode must be set.`);
14456
+ const networkPolicy$1 = buildNetworkPolicy({
14457
+ networkPolicy: networkPolicyMode$1,
14458
+ allowedDomains: allowedDomains$1,
14459
+ allowedCIDRs: allowedCIDRs$1,
14460
+ deniedCIDRs: deniedCIDRs$1
14461
+ });
14462
+ const sandbox = typeof sandboxId$1 !== "string" ? sandboxId$1 : await sandboxClient.get({
14463
+ sandboxId: sandboxId$1,
14464
+ projectId: project$1,
14465
+ teamId: team$1,
14466
+ token: token$1
14467
+ });
14468
+ if (!["pending", "running"].includes(sandbox.status)) {
14469
+ console.error([
14470
+ `Sandbox ${sandbox.sandboxId} is not available (status: ${sandbox.status}).`,
14471
+ `${source_default.bold("hint:")} Only 'pending' or 'running' sandboxes can execute commands.`,
14472
+ "├▶ Use `sandbox list` to check sandbox status.",
14473
+ "╰▶ Use `sandbox create` to create a new sandbox."
14474
+ ].join("\n"));
14475
+ process.exitCode = 1;
14476
+ return;
14477
+ }
14478
+ const spinner = ora("Updating network policy...").start();
14479
+ try {
14480
+ await sandbox.updateNetworkPolicy(networkPolicy$1);
14481
+ spinner.stop();
14482
+ process.stderr.write("✅ Network policy updated for sandbox " + source_default.cyan(sandbox.sandboxId) + "\n");
14483
+ process.stderr.write(source_default.dim(" ╰ ") + "mode: " + source_default.cyan(networkPolicy$1.type) + "\n");
14484
+ } catch (error) {
14485
+ spinner.stop();
14486
+ throw error;
14487
+ }
14488
+ }
14489
+ });
14490
+ const config = import_cjs$1.subcommands({
14491
+ name: "config",
14492
+ description: "Update a sandbox configuration",
14493
+ cmds: { "network-policy": networkPolicyCommand }
14494
+ });
14495
+
14348
14496
  //#endregion
14349
14497
  //#region src/app.ts
14350
14498
  var import_cjs = require_cjs();
@@ -14355,12 +14503,12 @@ const app = (opts) => (0, import_cjs.subcommands)({
14355
14503
  cmds: {
14356
14504
  list,
14357
14505
  create,
14506
+ config,
14358
14507
  copy: cp,
14359
14508
  exec,
14360
- ssh,
14509
+ connect,
14361
14510
  stop,
14362
14511
  run,
14363
- sh,
14364
14512
  snapshot,
14365
14513
  snapshots,
14366
14514
  ...!opts?.withoutAuth && {
@@ -14372,4 +14520,4 @@ const app = (opts) => (0, import_cjs.subcommands)({
14372
14520
 
14373
14521
  //#endregion
14374
14522
  export { StyledError as n, require_cjs as r, app as t };
14375
- //# sourceMappingURL=app-Be0xsoIH.mjs.map
14523
+ //# sourceMappingURL=app-BNIol84k.mjs.map