@computesdk/cli 2.6.8 → 2.6.10
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 +77 -4
- 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.10",
|
|
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
|
@@ -136,7 +136,7 @@ function conclusionLabel(conclusion) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
// src/settings.ts
|
|
139
|
-
var PLATFORM_SIZES = ["small", "medium", "large", "xlarge"];
|
|
139
|
+
var PLATFORM_SIZES = ["small", "medium", "large", "xlarge", "2xlarge", "3xlarge"];
|
|
140
140
|
function parseMaxPrice(value, per) {
|
|
141
141
|
if (value === void 0) {
|
|
142
142
|
if (per !== void 0) throw new Error("--max-price-per requires --max-price.");
|
|
@@ -3717,7 +3717,7 @@ function resolveTwoArgTarget(argId, resourceId, opts, label) {
|
|
|
3717
3717
|
return { resolved: resolveSandbox(argId, opts), resource: resourceId };
|
|
3718
3718
|
}
|
|
3719
3719
|
function addCreateFlags(c) {
|
|
3720
|
-
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
|
|
3720
|
+
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/128 GiB); default medium").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), []);
|
|
3721
3721
|
}
|
|
3722
3722
|
function providerNames(value) {
|
|
3723
3723
|
const names = value.split(",").map((name) => name.trim()).filter(Boolean);
|
|
@@ -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")
|
|
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) {
|
|
@@ -3807,6 +3858,7 @@ function registerCreate(command2, { providerShorthand = false } = {}) {
|
|
|
3807
3858
|
}
|
|
3808
3859
|
}
|
|
3809
3860
|
emitResult(opts, res.sandbox, (s) => s.id, (s) => printSandbox(s, opts.verbose));
|
|
3861
|
+
if (!opts.json && !opts.quiet) printNextSteps(res.sandbox.id, opts);
|
|
3810
3862
|
} catch (e) {
|
|
3811
3863
|
fail(e, opts);
|
|
3812
3864
|
}
|
|
@@ -3840,6 +3892,20 @@ async function previewPlacement(c, opts) {
|
|
|
3840
3892
|
pc11.dim(`\u2192 placing on ${provider} \xB7 ${placementLane(p2.source)} \xB7 ${p2.size ?? p2.box?.sizeName ?? "custom size"} (${billedBy(p2.source, provider)}) \u2026`)
|
|
3841
3893
|
);
|
|
3842
3894
|
}
|
|
3895
|
+
function printNextSteps(id, opts) {
|
|
3896
|
+
const context = `${opts.org ? ` --org ${opts.org}` : ""}${opts.baseUrl ? ` --base-url ${opts.baseUrl}` : ""}`;
|
|
3897
|
+
const steps = [
|
|
3898
|
+
[`compute sandboxes exec ${id}${context} -- node -v`, "run a command"],
|
|
3899
|
+
[`compute sandboxes spawn ${id}${context} -- npm run dev`, "start a server"],
|
|
3900
|
+
[`compute sandboxes url ${id}${context} --port 3000`, "get its public URL"],
|
|
3901
|
+
[`compute sandboxes destroy ${id}${context}`, "stop billing"]
|
|
3902
|
+
];
|
|
3903
|
+
const width = Math.max(...steps.map(([command2]) => command2.length));
|
|
3904
|
+
console.error("");
|
|
3905
|
+
console.error("Use it:");
|
|
3906
|
+
for (const [command2, does] of steps) console.error(` ${command2.padEnd(width)} ${pc11.dim(does)}`);
|
|
3907
|
+
console.error(pc11.dim("It runs and bills until it times out or is destroyed."));
|
|
3908
|
+
}
|
|
3843
3909
|
function shorthandProviders(operands) {
|
|
3844
3910
|
return operands.map((operand) => {
|
|
3845
3911
|
const name = operand.startsWith("--") ? operand.slice(2) : operand;
|
|
@@ -3858,8 +3924,15 @@ function registerSandboxesCommands(program2) {
|
|
|
3858
3924
|
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
3925
|
{ providerShorthand: true }
|
|
3860
3926
|
);
|
|
3927
|
+
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) => {
|
|
3928
|
+
try {
|
|
3929
|
+
await showSandboxOptions(opts);
|
|
3930
|
+
} catch (e) {
|
|
3931
|
+
fail(e, opts);
|
|
3932
|
+
}
|
|
3933
|
+
});
|
|
3861
3934
|
for (const name of ["route", "quote"]) {
|
|
3862
|
-
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");
|
|
3935
|
+
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/128 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("--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
3936
|
command2.action(async (opts) => {
|
|
3864
3937
|
try {
|
|
3865
3938
|
const c = await client(opts);
|