sandbox 3.0.0-beta.1 → 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.
@@ -3164,15 +3164,16 @@ const timeout = import_cjs$24.option({
3164
3164
  //#endregion
3165
3165
  //#region src/args/vcpus.ts
3166
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
+ });
3167
3174
  const vcpus = import_cjs$23.option({
3168
3175
  long: "vcpus",
3169
- type: import_cjs$23.optional(import_cjs$23.extendType(import_cjs$23.number, {
3170
- displayName: "COUNT",
3171
- async from(n) {
3172
- if (!Number.isInteger(n) || n < 1) throw new Error(`Invalid vCPU count: ${n}. Must be a positive integer.`);
3173
- return n;
3174
- }
3175
- })),
3176
+ type: import_cjs$23.optional(vcpusType),
3176
3177
  description: "Number of vCPUs to allocate (each vCPU includes 2048 MB of memory)"
3177
3178
  });
3178
3179
 
@@ -7426,7 +7427,7 @@ const scope = {
7426
7427
 
7427
7428
  //#endregion
7428
7429
  //#region package.json
7429
- var version = "3.0.0-beta.1";
7430
+ var version = "3.0.0-beta.2";
7430
7431
 
7431
7432
  //#endregion
7432
7433
  //#region src/error.ts
@@ -14729,37 +14730,54 @@ const SessionStatusColor = {
14729
14730
  var import_cjs$1 = /* @__PURE__ */ __toESM(require_cjs());
14730
14731
  init_source();
14731
14732
  var import_ms = /* @__PURE__ */ __toESM(require_ms());
14732
- const setCommand = import_cjs$1.command({
14733
- name: "set",
14734
- description: "Update the configuration of a sandbox",
14733
+ const vcpusCommand = import_cjs$1.command({
14734
+ name: "vcpus",
14735
+ description: "Update the vCPU count of a sandbox",
14735
14736
  args: {
14736
14737
  sandbox: import_cjs$1.positional({
14737
14738
  type: sandboxName,
14738
14739
  description: "Sandbox name to update"
14739
14740
  }),
14740
- vcpus,
14741
- runtime: import_cjs$1.option({
14742
- long: "runtime",
14743
- type: import_cjs$1.optional(runtimeType),
14744
- description: "Runtime to use: node22, node24, or python3.13"
14741
+ count: import_cjs$1.positional({
14742
+ type: vcpusType,
14743
+ description: "Number of vCPUs to allocate (each vCPU includes 2048 MB of memory)"
14745
14744
  }),
14746
- timeout: import_cjs$1.option({
14747
- long: "timeout",
14748
- type: import_cjs$1.optional(Duration),
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,
14749
14776
  description: "The maximum duration a sandbox can run for. Example: 5m, 1h"
14750
14777
  }),
14751
- ...networkPolicyArgs,
14752
14778
  scope
14753
14779
  },
14754
- async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandbox: name, vcpus: vcpus$1, runtime: runtime$1, timeout: timeout$1, networkPolicy: networkPolicyMode$1, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 }) {
14755
- const hasNetworkPolicyArgs = networkPolicyMode$1 !== void 0 || allowedDomains$1.length > 0 || allowedCIDRs$1.length > 0 || deniedCIDRs$1.length > 0;
14756
- if (vcpus$1 === void 0 && runtime$1 === void 0 && timeout$1 === void 0 && !hasNetworkPolicyArgs) throw new Error([`At least one option must be provided.`, `${source_default.bold("hint:")} Use --vcpus, --runtime, --timeout, or --network-policy to update the sandbox configuration.`].join("\n"));
14757
- const networkPolicy$1 = hasNetworkPolicyArgs ? buildNetworkPolicy({
14758
- networkPolicy: networkPolicyMode$1,
14759
- allowedDomains: allowedDomains$1,
14760
- allowedCIDRs: allowedCIDRs$1,
14761
- deniedCIDRs: deniedCIDRs$1
14762
- }) : void 0;
14780
+ async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandbox: name, duration }) {
14763
14781
  const sandbox = await sandboxClient.get({
14764
14782
  name,
14765
14783
  projectId: project$1,
@@ -14768,21 +14786,54 @@ const setCommand = import_cjs$1.command({
14768
14786
  });
14769
14787
  const spinner = ora("Updating sandbox configuration...").start();
14770
14788
  try {
14771
- await sandbox.update({
14772
- ...vcpus$1 !== void 0 && { resources: { vcpus: vcpus$1 } },
14773
- ...runtime$1 !== void 0 && { runtime: runtime$1 },
14774
- ...timeout$1 !== void 0 && { timeout: (0, import_ms.default)(timeout$1) },
14775
- ...networkPolicy$1 !== void 0 && { networkPolicy: networkPolicy$1 }
14776
- });
14777
- spinner.succeed("Configuration updated for sandbox " + source_default.cyan(name));
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");
14778
14793
  } catch (error) {
14779
14794
  spinner.stop();
14780
14795
  throw error;
14781
14796
  }
14782
14797
  }
14783
14798
  });
14784
- const getCommand = import_cjs$1.command({
14785
- name: "get",
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",
14786
14837
  description: "Display the current configuration of a sandbox",
14787
14838
  args: {
14788
14839
  sandbox: import_cjs$1.positional({
@@ -14808,30 +14859,23 @@ const getCommand = import_cjs$1.command({
14808
14859
  _usingCtx$1.d();
14809
14860
  }
14810
14861
  })();
14811
- const memoryFormatter = new Intl.NumberFormat(void 0, {
14812
- style: "unit",
14813
- unit: "megabyte"
14814
- });
14862
+ const networkPolicy$1 = typeof sandbox.networkPolicy === "string" ? sandbox.networkPolicy : "restricted";
14815
14863
  const rows = [
14816
- {
14817
- field: "Runtime",
14818
- value: sandbox.runtime
14819
- },
14820
14864
  {
14821
14865
  field: "vCPUs",
14822
14866
  value: String(sandbox.vcpus)
14823
14867
  },
14824
- {
14825
- field: "Memory",
14826
- value: memoryFormatter.format(sandbox.memory)
14827
- },
14828
14868
  {
14829
14869
  field: "Timeout",
14830
14870
  value: (0, import_ms.default)(sandbox.timeout, { long: true })
14831
14871
  },
14832
14872
  {
14833
- field: "Region",
14834
- value: sandbox.region
14873
+ field: "Persistent",
14874
+ value: String(sandbox.persistent)
14875
+ },
14876
+ {
14877
+ field: "Network policy",
14878
+ value: String(networkPolicy$1)
14835
14879
  }
14836
14880
  ];
14837
14881
  console.log(table({
@@ -14848,8 +14892,7 @@ const getCommand = import_cjs$1.command({
14848
14892
  });
14849
14893
  const networkPolicyCommand = import_cjs$1.command({
14850
14894
  name: "network-policy",
14851
- description: `Update the network policy of a sandbox.
14852
- This will fully override the previous configuration.`,
14895
+ description: `Update the network policy of a sandbox`,
14853
14896
  args: {
14854
14897
  sandbox: import_cjs$1.positional({ type: sandboxName }),
14855
14898
  ...networkPolicyArgs,
@@ -14861,7 +14904,6 @@ const networkPolicyCommand = import_cjs$1.command({
14861
14904
  scope
14862
14905
  },
14863
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 }) {
14864
- process.stderr.write(source_default.yellow("Warning: 'config network-policy' is deprecated. Use 'config set --network-policy=...' instead.\n"));
14865
14907
  const networkPolicyMode$1 = resolveMode(networkPolicyFlag, modeFlag);
14866
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.`);
14867
14909
  const networkPolicy$1 = buildNetworkPolicy({
@@ -14878,10 +14920,10 @@ const networkPolicyCommand = import_cjs$1.command({
14878
14920
  });
14879
14921
  const spinner = ora("Updating network policy...").start();
14880
14922
  try {
14881
- const response = await sandbox.updateNetworkPolicy(networkPolicy$1);
14923
+ await sandbox.update({ networkPolicy: networkPolicy$1 });
14882
14924
  spinner.stop();
14883
14925
  process.stderr.write("✅ Network policy updated for sandbox " + source_default.cyan(sandbox.name) + "\n");
14884
- const mode = typeof response === "string" ? response : "restricted";
14926
+ const mode = typeof networkPolicy$1 === "string" ? networkPolicy$1 : "restricted";
14885
14927
  process.stderr.write(source_default.dim(" ╰ ") + "mode: " + source_default.cyan(mode) + "\n");
14886
14928
  } catch (error) {
14887
14929
  spinner.stop();
@@ -14893,8 +14935,10 @@ const config = import_cjs$1.subcommands({
14893
14935
  name: "config",
14894
14936
  description: "View and update sandbox configuration",
14895
14937
  cmds: {
14896
- set: setCommand,
14897
- get: getCommand,
14938
+ list: listCommand,
14939
+ vcpus: vcpusCommand,
14940
+ timeout: timeoutCommand,
14941
+ persistent: persistentCommand,
14898
14942
  "network-policy": networkPolicyCommand
14899
14943
  }
14900
14944
  });
@@ -14942,4 +14986,4 @@ const app = (opts) => (0, import_cjs.subcommands)({
14942
14986
 
14943
14987
  //#endregion
14944
14988
  export { source_exports as a, init_source as i, StyledError as n, require_cjs as r, app as t };
14945
- //# sourceMappingURL=app-AqqXdE-N.mjs.map
14989
+ //# sourceMappingURL=app-BbpAiciu.mjs.map