@computesdk/cli 2.6.23 → 2.7.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.
package/cli-manifest.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "bin": "compute",
4
4
  "package": "@computesdk/cli",
5
- "version": "2.6.23",
5
+ "version": "2.7.0",
6
6
  "source": {
7
7
  "repo": "computesdk/computesdk",
8
8
  "released": false
@@ -1803,9 +1803,11 @@
1803
1803
  "--provider",
1804
1804
  "--byok",
1805
1805
  "--managed",
1806
+ "--strategy",
1807
+ "--ignore",
1806
1808
  "--size",
1807
- "--region-class",
1808
- "--region-only",
1809
+ "--region",
1810
+ "--region-prefer",
1809
1811
  "--label",
1810
1812
  "--image",
1811
1813
  "--snapshot-id",
@@ -1874,12 +1876,13 @@
1874
1876
  "--provider",
1875
1877
  "--byok",
1876
1878
  "--managed",
1879
+ "--strategy",
1880
+ "--ignore",
1877
1881
  "--cpus",
1878
1882
  "--memory-mb",
1879
1883
  "--disk-mb",
1880
1884
  "--region",
1881
- "--region-class",
1882
- "--region-only",
1885
+ "--region-prefer",
1883
1886
  "--timeout-ms",
1884
1887
  "--api-key",
1885
1888
  "--base-url",
@@ -2033,9 +2036,11 @@
2033
2036
  "--provider",
2034
2037
  "--byok",
2035
2038
  "--managed",
2039
+ "--strategy",
2040
+ "--ignore",
2036
2041
  "--size",
2037
- "--region-class",
2038
- "--region-only",
2042
+ "--region",
2043
+ "--region-prefer",
2039
2044
  "--label",
2040
2045
  "--image",
2041
2046
  "--snapshot-id",
@@ -2732,9 +2737,11 @@
2732
2737
  "--provider",
2733
2738
  "--byok",
2734
2739
  "--managed",
2740
+ "--strategy",
2741
+ "--ignore",
2735
2742
  "--size",
2736
- "--region-class",
2737
- "--region-only",
2743
+ "--region",
2744
+ "--region-prefer",
2738
2745
  "--label",
2739
2746
  "--image",
2740
2747
  "--snapshot-id",
@@ -2850,9 +2857,11 @@
2850
2857
  "--provider",
2851
2858
  "--byok",
2852
2859
  "--managed",
2860
+ "--strategy",
2861
+ "--ignore",
2853
2862
  "--size",
2854
- "--region-class",
2855
- "--region-only",
2863
+ "--region",
2864
+ "--region-prefer",
2856
2865
  "--label",
2857
2866
  "--image",
2858
2867
  "--snapshot-id",
package/dist/index.js CHANGED
@@ -4929,31 +4929,76 @@ function resolveTwoArgTarget(argId, resourceId, opts, label) {
4929
4929
  return { resolved: resolveSandbox(argId, opts), resource: resourceId };
4930
4930
  }
4931
4931
  function addCreateFlags(c) {
4932
- return c.option("--provider <names>", "place only on these providers, through your router (its BYOK mode and order), e.g. daytona or daytona,e2b").option("--byok", "use only your own keys for this create").option("--managed", "use only ComputeSDK managed accounts for this create").addOption(new Option3("--order <providers>").hideHelp()).option("--size <size>", "platform size: small (1 vCPU/2 GiB), medium, large, xlarge, 2xlarge (16/32 GiB), 3xlarge (32/64 GiB); default medium").option("--region-class <areas>", REGION_CLASS_HELP).option("--region-only", REGION_ONLY_HELP).option("--label <label>", "label for the sandbox").option("--image <image>", "container image to boot").option("--snapshot-id <id>", "provider snapshot to resume").option("--cpus <n>", "CPU cores (raw resources \u2014 mutually exclusive with --size)").option("--memory-mb <n>", "memory in MB (raw resources)").option("--disk-mb <n>", "ephemeral disk in MB (raw resources)").addOption(new Option3("--max-price <usd/unit>").hideHelp()).addOption(new Option3("--max-price-per <unit>").hideHelp()).addOption(new Option3("--market").hideHelp()).addOption(new Option3("--order-type <type>").hideHelp()).option("--timeout-ms <ms>", "sandbox timeout in ms (provider minimums apply, e.g. blaxel \u22655m)").option("--secret <name>", "vault secret name to inject (repeatable)", (v, a) => a.concat(v), []);
4932
+ return c.option("--provider <names>", "place only on these providers, through your router (its BYOK mode and order), e.g. daytona or daytona,e2b").option("--byok", "use only your own keys for this create").option("--managed", "use only ComputeSDK managed accounts for this create").option("--strategy <strategy>", "order managed accounts for this create: computesdk (recommended), cheapest, or custom (your saved order)").option("--ignore <names>", "never place on these providers for this create, e.g. e2b or e2b,modal").addOption(new Option3("--order <providers>").hideHelp()).option("--size <size>", "platform size: small (1 vCPU/2 GiB), medium, large, xlarge, 2xlarge (16/32 GiB), 3xlarge (32/64 GiB); default medium").option("--region <regions>", REGION_HELP).addOption(new Option3("--region-class <areas>").hideHelp()).option("--region-prefer", REGION_PREFER_HELP).addOption(new Option3("--region-only").hideHelp()).option("--label <label>", "label for the sandbox").option("--image <image>", "container image to boot").option("--snapshot-id <id>", "provider snapshot to resume").option("--cpus <n>", "CPU cores (raw resources \u2014 mutually exclusive with --size)").option("--memory-mb <n>", "memory in MB (raw resources)").option("--disk-mb <n>", "ephemeral disk in MB (raw resources)").addOption(new Option3("--max-price <usd/unit>").hideHelp()).addOption(new Option3("--max-price-per <unit>").hideHelp()).addOption(new Option3("--market").hideHelp()).addOption(new Option3("--order-type <type>").hideHelp()).option("--timeout-ms <ms>", "sandbox timeout in ms (provider minimums apply, e.g. blaxel \u22655m)").option("--secret <name>", "vault secret name to inject (repeatable)", (v, a) => a.concat(v), []);
4933
4933
  }
4934
- var REGION_CLASS_HELP = "standard areas to prefer, in order: us, us-east, us-central, us-south, us-west (e.g. us-west,us-east); default: your router's region rules";
4935
- var REGION_ONLY_HELP = "place only in the --region-class areas; fail if none fits";
4934
+ var REGION_HELP = "standard areas to place in, in order: us, us-east, us-central, us-south, us-west (e.g. us-west,us-east); fails if none fits unless --region-prefer; with one --provider, also its own region id (e.g. sfo1); default: your router's region rules";
4935
+ var REGION_PREFER_HELP = "try the --region areas first, then place anywhere if none fits";
4936
+ var REGION_AREAS = ["us", "us-east", "us-central", "us-south", "us-west"];
4936
4937
  function regionFields(opts) {
4937
- if (opts.regionClass === void 0) {
4938
- if (opts.regionOnly) throw new Error("--region-only needs --region-class.");
4938
+ if (opts.region !== void 0 && opts.regionClass !== void 0) throw new Error("--region-class is the old name of --region; pass one.");
4939
+ if (opts.regionOnly && opts.regionPrefer) throw new Error("--region-only and --region-prefer are opposites; pass one.");
4940
+ const modeFlag = opts.regionPrefer ? "--region-prefer" : "--region-only";
4941
+ const mode = opts.regionPrefer ? "prefer" : opts.regionOnly ? "only" : void 0;
4942
+ const raw = opts.region ?? opts.regionClass;
4943
+ if (raw === void 0) {
4944
+ if (mode !== void 0) throw new Error(`${modeFlag} needs --region.`);
4939
4945
  return {};
4940
4946
  }
4941
- const areas = opts.regionClass.split(",").map((area) => area.trim()).filter(Boolean);
4942
- if (areas.length === 0) throw new Error(`--region-class "${opts.regionClass}" names no areas.`);
4943
- return { regionClass: areas, ...opts.regionOnly ? { regionMode: "only" } : {} };
4947
+ const regions = raw.split(",").map((region) => region.trim()).filter(Boolean);
4948
+ if (regions.length === 0) throw new Error(`--region "${raw}" names no regions.`);
4949
+ const lowered = regions.map((region) => region.toLowerCase());
4950
+ if (lowered.every((area) => REGION_AREAS.includes(area))) {
4951
+ return { region: lowered, ...mode === void 0 ? {} : { regionMode: mode } };
4952
+ }
4953
+ const areas = REGION_AREAS.join(", ");
4954
+ if (regions.length > 1) throw new Error(`A --region list takes standard areas only: ${areas}.`);
4955
+ const providers = opts.provider === void 0 ? [] : providerNames(opts.provider);
4956
+ if (providers.length !== 1) {
4957
+ throw new Error(`--region ${regions[0]} isn't a standard area (${areas}); a provider's own region id needs exactly one --provider.`);
4958
+ }
4959
+ if (mode !== void 0) throw new Error(`${modeFlag} applies to standard areas, not a provider's own region id.`);
4960
+ return { region: regions[0], provider: providers[0] };
4944
4961
  }
4945
4962
  function regionParams(opts) {
4946
4963
  const fields = regionFields(opts);
4964
+ const mode = accountMode(opts);
4947
4965
  return {
4948
- ...fields.regionClass === void 0 ? {} : { regionClass: fields.regionClass.join(",") },
4966
+ only: opts.provider === void 0 || fields.provider !== void 0 ? void 0 : providerNames(opts.provider).join(","),
4967
+ byok: fields.provider === void 0 ? mode : void 0,
4968
+ ...fields.provider === void 0 ? {} : { provider: fields.provider, credentialSource: credentialSource(mode) },
4969
+ ...fields.region === void 0 ? {} : { region: Array.isArray(fields.region) ? fields.region.join(",") : fields.region },
4949
4970
  ...fields.regionMode === void 0 ? {} : { regionMode: fields.regionMode }
4950
4971
  };
4951
4972
  }
4952
- function providerNames(value) {
4973
+ function credentialSource(mode) {
4974
+ return mode === "only" ? "byok" : mode === "off" ? "house" : void 0;
4975
+ }
4976
+ function providerNames(value, flag = "--provider") {
4953
4977
  const names = value.split(",").map((name) => name.trim()).filter(Boolean);
4954
- if (names.length === 0) throw new Error(`--provider "${value}" names no providers.`);
4978
+ if (names.length === 0) throw new Error(`${flag} "${value}" names no providers.`);
4955
4979
  return names;
4956
4980
  }
4981
+ var STRATEGIES = ["computesdk", "cheapest", "custom"];
4982
+ function routerOverrides(opts) {
4983
+ const out = {};
4984
+ if (opts.strategy !== void 0) {
4985
+ if (!STRATEGIES.includes(opts.strategy)) {
4986
+ throw new Error(`--strategy must be one of ${STRATEGIES.join(", ")}`);
4987
+ }
4988
+ out.strategy = opts.strategy;
4989
+ }
4990
+ if (opts.ignore !== void 0) out.ignore = providerNames(opts.ignore, "--ignore");
4991
+ if (opts.order && (out.strategy || out.ignore)) throw new Error("--strategy/--ignore apply to your router; --order skips it.");
4992
+ if (opts.byok && out.strategy) throw new Error("--strategy orders managed accounts; --byok uses only your own keys.");
4993
+ if ((out.strategy || out.ignore) && regionFields(opts).provider !== void 0) {
4994
+ throw new Error("--strategy/--ignore apply to your router; a provider's own --region id names one provider exactly.");
4995
+ }
4996
+ return out;
4997
+ }
4998
+ function overrideParams(opts) {
4999
+ const { strategy, ignore: ignore2 } = routerOverrides(opts);
5000
+ return { strategy, ignore: ignore2?.join(",") };
5001
+ }
4957
5002
  function accountMode(opts) {
4958
5003
  if (opts.byok && opts.managed) throw new Error("--byok and --managed are mutually exclusive.");
4959
5004
  return opts.byok ? "only" : opts.managed ? "off" : void 0;
@@ -4967,15 +5012,19 @@ function buildCreateBody(opts) {
4967
5012
  if (opts.provider && opts.order) {
4968
5013
  throw new Error("--provider narrows your router; --order skips it. Pass one.");
4969
5014
  }
4970
- if (opts.provider) body.only = providerNames(opts.provider);
5015
+ const { provider, ...region } = regionFields(opts);
5016
+ if (provider !== void 0) body.provider = provider;
5017
+ else if (opts.provider) body.only = providerNames(opts.provider);
4971
5018
  const mode = accountMode(opts);
4972
5019
  if (mode !== void 0) {
4973
5020
  if (opts.order) throw new Error("--byok/--managed apply to your router; --order skips it.");
4974
- body.byok = mode;
5021
+ if (provider === void 0) body.byok = mode;
5022
+ else body.credentialSource = credentialSource(mode);
4975
5023
  }
5024
+ Object.assign(body, routerOverrides(opts));
4976
5025
  if (opts.order) body.providerOrder = opts.order.split(",").map((s) => s.trim());
4977
5026
  if (opts.size) body.size = opts.size;
4978
- Object.assign(body, regionFields(opts));
5027
+ Object.assign(body, region);
4979
5028
  if (opts.label) body.label = opts.label;
4980
5029
  if (opts.image) body.image = opts.image;
4981
5030
  if (opts.snapshotId) body.snapshotId = opts.snapshotId;
@@ -5128,16 +5177,14 @@ function registerCreate(command2, { providerShorthand = false } = {}) {
5128
5177
  }
5129
5178
  async function previewPlacement(c, opts) {
5130
5179
  if (opts.order || opts.market || opts.orderType || opts.maxPrice) return;
5131
- const mode = accountMode(opts);
5132
5180
  const params = {
5133
5181
  size: opts.size,
5134
5182
  cpus: opts.cpus,
5135
5183
  memoryMb: opts.memoryMb,
5136
5184
  ephemeralDiskMb: opts.diskMb,
5137
5185
  timeoutMs: opts.timeoutMs,
5138
- only: opts.provider === void 0 ? void 0 : providerNames(opts.provider).join(","),
5139
- byok: mode,
5140
- ...regionParams(opts)
5186
+ ...regionParams(opts),
5187
+ ...overrideParams(opts)
5141
5188
  };
5142
5189
  let quote;
5143
5190
  try {
@@ -5213,18 +5260,16 @@ function registerSandboxOperations(cmd) {
5213
5260
  }
5214
5261
  });
5215
5262
  for (const name of ["route", "quote"]) {
5216
- const command2 = cmd.command(name, { hidden: name === "quote" }).description("Show where a sandbox create would land, how it is billed, and the price \u2014 creates nothing").option("--size <size>", "platform size: small, medium (default), large, xlarge, 2xlarge (16/32 GiB), 3xlarge (32/64 GiB)").option("--provider <names>", "only these providers, through your router (e.g. daytona)").option("--byok", "only your own keys").option("--managed", "only ComputeSDK managed accounts").option("--cpus <n>", "CPU cores (raw resources instead of --size)").option("--memory-mb <n>", "memory in MB").option("--disk-mb <n>", "ephemeral disk in MB").option("--region <region>", "pin the placement region").option("--region-class <areas>", REGION_CLASS_HELP).option("--region-only", REGION_ONLY_HELP).option("--timeout-ms <ms>", "sandbox timeout in ms; a managed account holds credit for it").addOption(new Option3("--order-type <type>").hideHelp()).addOption(new Option3("--market").hideHelp()).addOption(new Option3("--max-price <usd/unit>").hideHelp()).addOption(new Option3("--max-price-per <unit>").hideHelp()).option("--api-key <key>").option("--base-url <url>").option("--allow-untrusted-host").option("--json", "print the raw response");
5263
+ const command2 = cmd.command(name, { hidden: name === "quote" }).description("Show where a sandbox create would land, how it is billed, and the price \u2014 creates nothing").option("--size <size>", "platform size: small, medium (default), large, xlarge, 2xlarge (16/32 GiB), 3xlarge (32/64 GiB)").option("--provider <names>", "only these providers, through your router (e.g. daytona)").option("--byok", "only your own keys").option("--managed", "only ComputeSDK managed accounts").option("--strategy <strategy>", "order managed accounts: computesdk (recommended), cheapest, or custom (your saved order)").option("--ignore <names>", "never these providers (e.g. e2b)").option("--cpus <n>", "CPU cores (raw resources instead of --size)").option("--memory-mb <n>", "memory in MB").option("--disk-mb <n>", "ephemeral disk in MB").option("--region <regions>", REGION_HELP).addOption(new Option3("--region-class <areas>").hideHelp()).option("--region-prefer", REGION_PREFER_HELP).addOption(new Option3("--region-only").hideHelp()).option("--timeout-ms <ms>", "sandbox timeout in ms; a managed account holds credit for it").addOption(new Option3("--order-type <type>").hideHelp()).addOption(new Option3("--market").hideHelp()).addOption(new Option3("--max-price <usd/unit>").hideHelp()).addOption(new Option3("--max-price-per <unit>").hideHelp()).option("--api-key <key>").option("--base-url <url>").option("--allow-untrusted-host").option("--json", "print the raw response");
5217
5264
  command2.action(async (opts) => {
5218
5265
  try {
5219
5266
  const c = await client(opts);
5220
5267
  const params = {
5221
5268
  size: opts.size,
5222
- only: opts.provider === void 0 ? void 0 : providerNames(opts.provider).join(","),
5223
- byok: accountMode(opts),
5269
+ ...overrideParams(opts),
5224
5270
  cpus: opts.cpus,
5225
5271
  memoryMb: opts.memoryMb,
5226
5272
  ephemeralDiskMb: opts.diskMb,
5227
- region: opts.region,
5228
5273
  ...regionParams(opts),
5229
5274
  timeoutMs: opts.timeoutMs,
5230
5275
  orderType: opts.market ? "market" : opts.orderType