@computesdk/cli 2.6.8 → 2.6.9

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.8",
5
+ "version": "2.6.9",
6
6
  "source": {
7
7
  "repo": "computesdk/computesdk",
8
8
  "released": false
@@ -1803,6 +1803,32 @@
1803
1803
  ],
1804
1804
  "summary": "Create a sandbox through your Sandboxes router (`compute sandboxes route` shows where it lands)"
1805
1805
  },
1806
+ {
1807
+ "path": [
1808
+ "instances",
1809
+ "options"
1810
+ ],
1811
+ "aliases": [
1812
+ [
1813
+ "sandboxes",
1814
+ "options"
1815
+ ],
1816
+ [
1817
+ "sbx",
1818
+ "options"
1819
+ ]
1820
+ ],
1821
+ "args": [],
1822
+ "flags": [
1823
+ "--api-key",
1824
+ "--base-url",
1825
+ "--allow-untrusted-host",
1826
+ "--json",
1827
+ "--org",
1828
+ "--help"
1829
+ ],
1830
+ "summary": "List what you can create sandboxes on: managed accounts with prices per size, and your BYOK providers, in router order"
1831
+ },
1806
1832
  {
1807
1833
  "path": [
1808
1834
  "instances",
@@ -2690,6 +2716,7 @@
2690
2716
  "--base-url",
2691
2717
  "--allow-untrusted-host",
2692
2718
  "--json",
2719
+ "--list",
2693
2720
  "--help"
2694
2721
  ],
2695
2722
  "summary": "Create a sandbox (short for `compute sandboxes create`); `compute new vercel` or `--vercel` picks the provider"
package/dist/index.js CHANGED
@@ -3785,11 +3785,62 @@ function listQuery(opts) {
3785
3785
  cursor: opts.cursor
3786
3786
  };
3787
3787
  }
3788
+ var BYOK_MODE_LINE = {
3789
+ off: "managed accounts only",
3790
+ first: "your keys first, then managed accounts",
3791
+ fallback: "managed accounts first, then your keys",
3792
+ only: "your keys only"
3793
+ };
3794
+ function printSandboxOptions(o) {
3795
+ if (o.options.length === 0) {
3796
+ console.log("Nothing to create on yet: no managed account is live and no BYOK key is set up.");
3797
+ return;
3798
+ }
3799
+ const sizeNames = [...new Set(o.options.flatMap((row) => row.account === "managed" ? row.sizes.map((size) => size.name) : []))].filter((name) => name !== "default");
3800
+ const order = ["small", "medium", "large", "xlarge"];
3801
+ sizeNames.sort((a, b) => order.indexOf(a) - order.indexOf(b));
3802
+ const providerWidth = Math.max(8, ...o.options.map((row) => (row.account === "byok" && row.region ? `${row.provider}:${row.region}` : row.provider).length));
3803
+ const cell = (text) => text.padEnd(11);
3804
+ console.log(pc11.dim(`${"Provider".padEnd(providerWidth)} ${"Account".padEnd(8)} ${sizeNames.map(cell).join(" ")}`.trimEnd()));
3805
+ let first = null;
3806
+ for (const row of o.options) {
3807
+ const name = row.account === "byok" && row.region ? `${row.provider}:${row.region}` : row.provider;
3808
+ let detail;
3809
+ let usable;
3810
+ if (row.account === "managed") {
3811
+ const fixed = row.sizes.length === 1 && row.sizes[0].name === "default";
3812
+ usable = row.sizes.some((size) => size.rate !== null);
3813
+ detail = fixed ? row.sizes[0].rate ? `default size ${shortRate(row.sizes[0].rate)}` : pc11.dim("not priced yet") : sizeNames.map((size) => {
3814
+ const priced = row.sizes.find((entry) => entry.name === size)?.rate;
3815
+ return cell(priced ? shortRate(priced) : "\u2014");
3816
+ }).join(" ").trimEnd();
3817
+ } else {
3818
+ usable = row.ready;
3819
+ detail = row.ready ? pc11.dim(`billed by ${row.provider} to your account`) : pc11.dim("key not tested \u2014 compute byok verify " + row.provider);
3820
+ }
3821
+ if (usable && first === null) first = row.provider;
3822
+ console.log(`${name.padEnd(providerWidth)} ${(row.account === "managed" ? "managed" : "BYOK").padEnd(8)} ${detail}`);
3823
+ }
3824
+ console.log("");
3825
+ console.log(`Router: ${BYOK_MODE_LINE[o.byokMode]} (BYOK ${o.byokMode}).`);
3826
+ if (first !== null) console.log(pc11.dim(`A plain \`compute new\` lands on ${first}. Pick one: compute new --${first} --size <size>`));
3827
+ }
3828
+ async function showSandboxOptions(opts) {
3829
+ const c = await client(opts);
3830
+ output(opts, await c.get("/api/v1/sandboxes/options"), printSandboxOptions);
3831
+ }
3788
3832
  function registerCreate(command2, { providerShorthand = false } = {}) {
3789
- addCreateFlags(command2).option("--no-use", "do not mark the new instance as this directory's current instance").option("-q, --quiet", "print only the new instance ID").option("--verbose", "print the full instance details").option("--api-key <key>", "platform API key (or COMPUTE_API_KEY)").option("--base-url <url>", "platform base URL").option("--allow-untrusted-host", "allow non-computesdk.com base URLs").option("--json", "print the raw response").action(async (...args) => {
3833
+ addCreateFlags(command2).option("--no-use", "do not mark the new instance as this directory's current instance").option("-q, --quiet", "print only the new instance ID").option("--verbose", "print the full instance details").option("--api-key <key>", "platform API key (or COMPUTE_API_KEY)").option("--base-url <url>", "platform base URL").option("--allow-untrusted-host", "allow non-computesdk.com base URLs").option("--json", "print the raw response");
3834
+ if (providerShorthand) command2.option("--list", "list what you can create on, with prices, instead of creating (= compute sandboxes options)");
3835
+ command2.action(async (...args) => {
3790
3836
  const operands = providerShorthand ? args[0] : [];
3791
3837
  const opts = args[providerShorthand ? 1 : 0];
3792
3838
  try {
3839
+ if (opts.list) {
3840
+ if (operands.length > 0) throw new Error("--list shows every option; drop the provider names.");
3841
+ await showSandboxOptions(opts);
3842
+ return;
3843
+ }
3793
3844
  checkQuietJson(opts);
3794
3845
  const named = shorthandProviders(operands);
3795
3846
  if (named.length > 0) {
@@ -3858,6 +3909,13 @@ function registerSandboxesCommands(program2) {
3858
3909
  program2.command("new").description("Create a sandbox (short for `compute sandboxes create`); `compute new vercel` or `--vercel` picks the provider").argument("[providers...]", "only these providers, through your router (vercel, --vercel, e2b, \u2026)").allowUnknownOption().configureOutput({ outputError: usageErrorOutput }),
3859
3910
  { providerShorthand: true }
3860
3911
  );
3912
+ cmd.command("options").description("List what you can create sandboxes on: managed accounts with prices per size, and your BYOK providers, in router order").option("--api-key <key>", "platform API key (or COMPUTE_API_KEY)").option("--base-url <url>", "platform base URL").option("--allow-untrusted-host", "allow non-computesdk.com base URLs").option("--json", "print the raw response").action(async (opts) => {
3913
+ try {
3914
+ await showSandboxOptions(opts);
3915
+ } catch (e) {
3916
+ fail(e, opts);
3917
+ }
3918
+ });
3861
3919
  for (const name of ["route", "quote"]) {
3862
3920
  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").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("--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");
3863
3921
  command2.action(async (opts) => {