@computesdk/cli 2.6.9 → 2.6.11
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 +1 -1
- package/dist/index.js +40 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/cli-manifest.json
CHANGED
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.");
|
|
@@ -237,13 +237,20 @@ var BYOK_MODE_HELP = {
|
|
|
237
237
|
fallback: "managed accounts first, then your keys",
|
|
238
238
|
only: "your keys only, never managed accounts"
|
|
239
239
|
};
|
|
240
|
+
var MANAGED_STRATEGIES = ["computesdk", "cheapest"];
|
|
241
|
+
var STRATEGY_LABEL = {
|
|
242
|
+
computesdk: "ComputeSDK (recommended)",
|
|
243
|
+
cheapest: "Cheapest",
|
|
244
|
+
custom: "Custom"
|
|
245
|
+
};
|
|
240
246
|
var arrow = (list) => list.join(" \u2192 ");
|
|
241
247
|
function printLaneRouting(r, lane) {
|
|
242
248
|
const label = (text) => text.padEnd(12);
|
|
243
249
|
const managed = r.managed.length > 0 ? arrow(r.managed) : pc2.dim("no managed account is live");
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
);
|
|
250
|
+
const strategy = r.strategy ?? (r.routing === "default" ? "computesdk" : "custom");
|
|
251
|
+
const size = r.size !== void 0 && strategy === "cheapest" ? pc2.dim(` (priced at ${r.size})`) : "";
|
|
252
|
+
console.log(`${label("Routing")}${STRATEGY_LABEL[strategy]}`);
|
|
253
|
+
console.log(`${label("Order")}${managed}${size}`);
|
|
247
254
|
console.log(`${label("BYOK")}${r.byok.mode} ${pc2.dim(`(${BYOK_MODE_HELP[r.byok.mode]})`)}`);
|
|
248
255
|
if (r.byok.mode !== "off") {
|
|
249
256
|
const list = r.byok.order.length > 0 ? arrow(r.byok.order) : "\u2014";
|
|
@@ -329,8 +336,8 @@ function registerSettingsCommands(group, lane, common2, deps) {
|
|
|
329
336
|
});
|
|
330
337
|
const set = common2(
|
|
331
338
|
settings.command("set").description(`Change the ${routerName} router (owner/admin)`).option(
|
|
332
|
-
"--routing <
|
|
333
|
-
|
|
339
|
+
"--routing <strategy|providers>",
|
|
340
|
+
"managed routing: computesdk (default) | cheapest | your own managed-account order (e.g. daytona,e2b)"
|
|
334
341
|
).option("--byok <mode>", `use your own keys: ${BYOK_MODES.join(" | ")}`).option(
|
|
335
342
|
"--byok-order <providers>",
|
|
336
343
|
lane === "sandboxes" ? 'your own providers in order (e.g. tensorlake,blaxel); "inherit" uses the Actions BYOK order' : "your own providers in order (e.g. tensorlake,blaxel)"
|
|
@@ -360,7 +367,7 @@ function registerSettingsCommands(group, lane, common2, deps) {
|
|
|
360
367
|
try {
|
|
361
368
|
const routing = {};
|
|
362
369
|
if (opts.routing !== void 0) {
|
|
363
|
-
routing.routing = opts.routing === "default" ?
|
|
370
|
+
routing.routing = opts.routing === "default" || MANAGED_STRATEGIES.includes(opts.routing) ? opts.routing : providerList("--routing", opts.routing);
|
|
364
371
|
}
|
|
365
372
|
if (opts.byok !== void 0) {
|
|
366
373
|
if (!BYOK_MODES.includes(opts.byok)) {
|
|
@@ -3717,7 +3724,7 @@ function resolveTwoArgTarget(argId, resourceId, opts, label) {
|
|
|
3717
3724
|
return { resolved: resolveSandbox(argId, opts), resource: resourceId };
|
|
3718
3725
|
}
|
|
3719
3726
|
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
|
|
3727
|
+
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
3728
|
}
|
|
3722
3729
|
function providerNames(value) {
|
|
3723
3730
|
const names = value.split(",").map((name) => name.trim()).filter(Boolean);
|
|
@@ -3785,6 +3792,11 @@ function listQuery(opts) {
|
|
|
3785
3792
|
cursor: opts.cursor
|
|
3786
3793
|
};
|
|
3787
3794
|
}
|
|
3795
|
+
var STRATEGY_LINE = {
|
|
3796
|
+
computesdk: "ComputeSDK's recommended order",
|
|
3797
|
+
cheapest: "cheapest first",
|
|
3798
|
+
custom: "your own order"
|
|
3799
|
+
};
|
|
3788
3800
|
var BYOK_MODE_LINE = {
|
|
3789
3801
|
off: "managed accounts only",
|
|
3790
3802
|
first: "your keys first, then managed accounts",
|
|
@@ -3823,6 +3835,10 @@ function printSandboxOptions(o) {
|
|
|
3823
3835
|
}
|
|
3824
3836
|
console.log("");
|
|
3825
3837
|
console.log(`Router: ${BYOK_MODE_LINE[o.byokMode]} (BYOK ${o.byokMode}).`);
|
|
3838
|
+
if (o.strategy !== void 0 && o.byokMode !== "only") {
|
|
3839
|
+
const size = o.strategy === "cheapest" && o.size !== void 0 ? ` at ${o.size}` : "";
|
|
3840
|
+
console.log(`Managed accounts: ${STRATEGY_LINE[o.strategy]}${size} \u2014 change with compute sandboxes settings set --routing <computesdk|cheapest|providers>.`);
|
|
3841
|
+
}
|
|
3826
3842
|
if (first !== null) console.log(pc11.dim(`A plain \`compute new\` lands on ${first}. Pick one: compute new --${first} --size <size>`));
|
|
3827
3843
|
}
|
|
3828
3844
|
async function showSandboxOptions(opts) {
|
|
@@ -3858,6 +3874,7 @@ function registerCreate(command2, { providerShorthand = false } = {}) {
|
|
|
3858
3874
|
}
|
|
3859
3875
|
}
|
|
3860
3876
|
emitResult(opts, res.sandbox, (s) => s.id, (s) => printSandbox(s, opts.verbose));
|
|
3877
|
+
if (!opts.json && !opts.quiet) printNextSteps(res.sandbox.id, opts);
|
|
3861
3878
|
} catch (e) {
|
|
3862
3879
|
fail(e, opts);
|
|
3863
3880
|
}
|
|
@@ -3891,6 +3908,20 @@ async function previewPlacement(c, opts) {
|
|
|
3891
3908
|
pc11.dim(`\u2192 placing on ${provider} \xB7 ${placementLane(p2.source)} \xB7 ${p2.size ?? p2.box?.sizeName ?? "custom size"} (${billedBy(p2.source, provider)}) \u2026`)
|
|
3892
3909
|
);
|
|
3893
3910
|
}
|
|
3911
|
+
function printNextSteps(id, opts) {
|
|
3912
|
+
const context = `${opts.org ? ` --org ${opts.org}` : ""}${opts.baseUrl ? ` --base-url ${opts.baseUrl}` : ""}`;
|
|
3913
|
+
const steps = [
|
|
3914
|
+
[`compute sandboxes exec ${id}${context} -- node -v`, "run a command"],
|
|
3915
|
+
[`compute sandboxes spawn ${id}${context} -- npm run dev`, "start a server"],
|
|
3916
|
+
[`compute sandboxes url ${id}${context} --port 3000`, "get its public URL"],
|
|
3917
|
+
[`compute sandboxes destroy ${id}${context}`, "stop billing"]
|
|
3918
|
+
];
|
|
3919
|
+
const width = Math.max(...steps.map(([command2]) => command2.length));
|
|
3920
|
+
console.error("");
|
|
3921
|
+
console.error("Use it:");
|
|
3922
|
+
for (const [command2, does] of steps) console.error(` ${command2.padEnd(width)} ${pc11.dim(does)}`);
|
|
3923
|
+
console.error(pc11.dim("It runs and bills until it times out or is destroyed."));
|
|
3924
|
+
}
|
|
3894
3925
|
function shorthandProviders(operands) {
|
|
3895
3926
|
return operands.map((operand) => {
|
|
3896
3927
|
const name = operand.startsWith("--") ? operand.slice(2) : operand;
|
|
@@ -3917,7 +3948,7 @@ function registerSandboxesCommands(program2) {
|
|
|
3917
3948
|
}
|
|
3918
3949
|
});
|
|
3919
3950
|
for (const name of ["route", "quote"]) {
|
|
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");
|
|
3951
|
+
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");
|
|
3921
3952
|
command2.action(async (opts) => {
|
|
3922
3953
|
try {
|
|
3923
3954
|
const c = await client(opts);
|