@computesdk/cli 2.6.7 → 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 +28 -1
- package/dist/index.js +76 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
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
|
@@ -3307,6 +3307,22 @@ function registerCreditsCommands(program2) {
|
|
|
3307
3307
|
});
|
|
3308
3308
|
}
|
|
3309
3309
|
|
|
3310
|
+
// src/option-inheritance.ts
|
|
3311
|
+
var GIVEN = /* @__PURE__ */ new Set(["cli", "env"]);
|
|
3312
|
+
function inheritParentOptions(program2) {
|
|
3313
|
+
return program2.hook("preAction", (_hooked, actionCommand) => {
|
|
3314
|
+
const declared = new Set(actionCommand.options.map((option) => option.attributeName()));
|
|
3315
|
+
for (let parent = actionCommand.parent; parent; parent = parent.parent) {
|
|
3316
|
+
for (const [key, value] of Object.entries(parent.opts())) {
|
|
3317
|
+
if (!declared.has(key) || value === void 0) continue;
|
|
3318
|
+
if (!GIVEN.has(parent.getOptionValueSource(key) ?? "")) continue;
|
|
3319
|
+
if (GIVEN.has(actionCommand.getOptionValueSource(key) ?? "")) continue;
|
|
3320
|
+
actionCommand.setOptionValueWithSource(key, value, parent.getOptionValueSource(key));
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
});
|
|
3324
|
+
}
|
|
3325
|
+
|
|
3310
3326
|
// src/sandboxes.ts
|
|
3311
3327
|
import * as fs from "fs";
|
|
3312
3328
|
import * as os from "os";
|
|
@@ -3769,11 +3785,62 @@ function listQuery(opts) {
|
|
|
3769
3785
|
cursor: opts.cursor
|
|
3770
3786
|
};
|
|
3771
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
|
+
}
|
|
3772
3832
|
function registerCreate(command2, { providerShorthand = false } = {}) {
|
|
3773
|
-
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")
|
|
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) => {
|
|
3774
3836
|
const operands = providerShorthand ? args[0] : [];
|
|
3775
3837
|
const opts = args[providerShorthand ? 1 : 0];
|
|
3776
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
|
+
}
|
|
3777
3844
|
checkQuietJson(opts);
|
|
3778
3845
|
const named = shorthandProviders(operands);
|
|
3779
3846
|
if (named.length > 0) {
|
|
@@ -3842,6 +3909,13 @@ function registerSandboxesCommands(program2) {
|
|
|
3842
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 }),
|
|
3843
3910
|
{ providerShorthand: true }
|
|
3844
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
|
+
});
|
|
3845
3919
|
for (const name of ["route", "quote"]) {
|
|
3846
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");
|
|
3847
3921
|
command2.action(async (opts) => {
|
|
@@ -5658,6 +5732,7 @@ process.stderr.on("error", (err) => {
|
|
|
5658
5732
|
throw err;
|
|
5659
5733
|
});
|
|
5660
5734
|
var program = new Command4();
|
|
5735
|
+
inheritParentOptions(program);
|
|
5661
5736
|
program.name("compute").description("ComputeSDK CLI").version(VERSION).enablePositionalOptions().passThroughOptions();
|
|
5662
5737
|
async function printSessionLine(options) {
|
|
5663
5738
|
try {
|