agental 0.53.0 → 0.54.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/dist/cli.js +297 -83
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7411,7 +7411,7 @@ import { parseArgs } from "node:util";
|
|
|
7411
7411
|
|
|
7412
7412
|
// ../src/cli-build.ts
|
|
7413
7413
|
var PUBLISHED = true;
|
|
7414
|
-
var CLI_VERSION = true ? "0.
|
|
7414
|
+
var CLI_VERSION = true ? "0.54.0" : "dev";
|
|
7415
7415
|
var DEFAULT_API_URL = true ? "https://agental.io" : "http://127.0.0.1:8741";
|
|
7416
7416
|
var PACKAGE_NAME = "agental";
|
|
7417
7417
|
var USER_AGENT = `agental-cli/${CLI_VERSION}`;
|
|
@@ -7916,6 +7916,9 @@ var KEY_ACTIONS = [
|
|
|
7916
7916
|
"template.write",
|
|
7917
7917
|
"bucket.read",
|
|
7918
7918
|
"bucket.write",
|
|
7919
|
+
"guild.read",
|
|
7920
|
+
"guild.write",
|
|
7921
|
+
"guild.join",
|
|
7919
7922
|
"key.manage",
|
|
7920
7923
|
"account.read",
|
|
7921
7924
|
"account.admin",
|
|
@@ -7939,7 +7942,7 @@ var FULL_SANDBOX = [
|
|
|
7939
7942
|
];
|
|
7940
7943
|
var PRESETS = {
|
|
7941
7944
|
// Every read, apart from secrets and mail, which are the two an agent should be given by name.
|
|
7942
|
-
"read-only": ["sandbox.read", "file.read", "job.read", "snapshot.read", "template.read", "bucket.read", "account.read"],
|
|
7945
|
+
"read-only": ["sandbox.read", "file.read", "job.read", "snapshot.read", "template.read", "bucket.read", "guild.read", "account.read"],
|
|
7943
7946
|
"full-sandbox": [...FULL_SANDBOX, "job.read", "job.write", "job.run"],
|
|
7944
7947
|
// A CI system runs the jobs it is given and reads how they went; it does not make them.
|
|
7945
7948
|
ci: [...FULL_SANDBOX, "sandbox.create", "sandbox.fork", "sandbox.resume", "sandbox.delete-own", "job.read", "job.run"],
|
|
@@ -8305,7 +8308,7 @@ async function pushRequest(base, ask13) {
|
|
|
8305
8308
|
async function listen() {
|
|
8306
8309
|
let arrived = () => {
|
|
8307
8310
|
};
|
|
8308
|
-
let
|
|
8311
|
+
let answer5 = () => {
|
|
8309
8312
|
};
|
|
8310
8313
|
const next = new Promise((resolve) => arrived = resolve);
|
|
8311
8314
|
let taken = false;
|
|
@@ -8320,7 +8323,7 @@ async function listen() {
|
|
|
8320
8323
|
return;
|
|
8321
8324
|
}
|
|
8322
8325
|
taken = true;
|
|
8323
|
-
|
|
8326
|
+
answer5 = (to) => response.writeHead(302, { location: to, "cache-control": "no-store" }).end();
|
|
8324
8327
|
arrived(url);
|
|
8325
8328
|
});
|
|
8326
8329
|
await new Promise((resolve, reject) => {
|
|
@@ -8328,7 +8331,7 @@ async function listen() {
|
|
|
8328
8331
|
server2.listen(0, "127.0.0.1", resolve);
|
|
8329
8332
|
});
|
|
8330
8333
|
const { port } = server2.address();
|
|
8331
|
-
return { server: server2, redirectUri: `http://127.0.0.1:${port}/callback`, next, answer: (to) =>
|
|
8334
|
+
return { server: server2, redirectUri: `http://127.0.0.1:${port}/callback`, next, answer: (to) => answer5(to) };
|
|
8332
8335
|
}
|
|
8333
8336
|
async function browserSignIn(base, term, organizationId) {
|
|
8334
8337
|
const verifier = randomBytes2(32).toString("base64url");
|
|
@@ -8643,9 +8646,9 @@ function addToToml(agent, folder, url) {
|
|
|
8643
8646
|
function run(command3, args, cwd) {
|
|
8644
8647
|
return new Promise((resolve) => {
|
|
8645
8648
|
execFile(command3, args, { encoding: "utf8", timeout: 6e4, cwd, shell: process.platform === "win32" }, (error, stdout, stderr) => {
|
|
8646
|
-
const
|
|
8647
|
-
const missing = error?.code === "ENOENT" || process.platform === "win32" && /is not recognized as an internal or external command/i.test(
|
|
8648
|
-
resolve({ ok: !error, out, missing });
|
|
8649
|
+
const out2 = `${stdout}${stderr}`.trim();
|
|
8650
|
+
const missing = error?.code === "ENOENT" || process.platform === "win32" && /is not recognized as an internal or external command/i.test(out2);
|
|
8651
|
+
resolve({ ok: !error, out: out2, missing });
|
|
8649
8652
|
});
|
|
8650
8653
|
});
|
|
8651
8654
|
}
|
|
@@ -8996,9 +8999,9 @@ async function api(base, key2, method, pathname, body, headers = {}) {
|
|
|
8996
8999
|
}
|
|
8997
9000
|
return { status: response.status, body: parsed && typeof parsed === "object" ? parsed : {} };
|
|
8998
9001
|
}
|
|
8999
|
-
function errorOf(
|
|
9000
|
-
const error =
|
|
9001
|
-
return { code: String(error["code"] ?? `http_${
|
|
9002
|
+
function errorOf(answer5) {
|
|
9003
|
+
const error = answer5.body["error"] && typeof answer5.body["error"] === "object" ? answer5.body["error"] : {};
|
|
9004
|
+
return { code: String(error["code"] ?? `http_${answer5.status}`), message: String(error["message"] ?? `HTTP ${answer5.status}`) };
|
|
9002
9005
|
}
|
|
9003
9006
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
9004
9007
|
function real(file) {
|
|
@@ -9421,6 +9424,7 @@ var COMMANDS = [
|
|
|
9421
9424
|
[" --ttl <time>", "stop it after this long, as 30m or 2h"],
|
|
9422
9425
|
[" --allow <addresses>", "reach only these addresses, comma-separated"],
|
|
9423
9426
|
[" --egress <egress>", "box, or residential:<country>[:sticky|rotating]"],
|
|
9427
|
+
[" --tailnet <tags> | off", "join the tailnet tagged so (tag:ci), or off for none"],
|
|
9424
9428
|
[" --spot", "half the price, in spare room taken back when needed"],
|
|
9425
9429
|
[" --on-reclaim <what>", "with --spot: stop (default) or delete"],
|
|
9426
9430
|
[" --warn-at <chance>", "with --spot: warn at this chance, as 0.5 or 50%"],
|
|
@@ -9583,6 +9587,29 @@ var COMMANDS = [
|
|
|
9583
9587
|
{ name: "regions", summary: "List where sandboxes run, and how much room each has now." },
|
|
9584
9588
|
{ name: "network", summary: "Say what a sandbox may reach outside itself.", examples: ["agental network sbx_2a9a47e50daec64a --allow github.com,registry.npmjs.org", "agental network sbx_2a9a47e50daec64a --none"] },
|
|
9585
9589
|
{ name: "egress", summary: "Say where a sandbox's web traffic leaves from, or read your residential egress.", examples: ["agental egress sbx_2a9a47e50daec64a residential de"] },
|
|
9590
|
+
{
|
|
9591
|
+
name: "tailscale",
|
|
9592
|
+
summary: "Connect the account's Tailscale OAuth client, its secret sealed on this machine, or say or disconnect it.",
|
|
9593
|
+
usage: ["agental tailscale [status] [--json]", "agental tailscale connect --client-id <id>", "agental tailscale disconnect [--yes]"],
|
|
9594
|
+
examples: ["agental tailscale connect --client-id kAbCdEf2CNTRL"],
|
|
9595
|
+
flags: [
|
|
9596
|
+
["--client-id <id>", "connect: the OAuth client's id (scopes auth_keys, devices:core); secret read hidden"],
|
|
9597
|
+
["--yes", "disconnect: without asking; every sandbox is taken off the tailnet"]
|
|
9598
|
+
]
|
|
9599
|
+
},
|
|
9600
|
+
{
|
|
9601
|
+
name: "tailnet",
|
|
9602
|
+
summary: "Join a sandbox to the account's tailnet as a node, change how, or take it off.",
|
|
9603
|
+
usage: ["agental tailnet <sandbox> [--json]", "agental tailnet <sandbox> join --tag <tag> [--accept <range>] [--exit-node <ip>] [--keep-address] [--node-name <name>]", "agental tailnet <sandbox> off"],
|
|
9604
|
+
examples: ["agental tailnet build join --tag tag:ci", "agental tailnet build join --tag tag:ci --accept 10.1.0.0/16 --keep-address"],
|
|
9605
|
+
flags: [
|
|
9606
|
+
["--tag <tag:name>", "join: a tag the OAuth client owns (may be given again)"],
|
|
9607
|
+
["--accept <range>", "join: a subnet route of the tailnet it takes, /8 or narrower (may be given again)"],
|
|
9608
|
+
["--exit-node <address>", "join: its other traffic leaves through this tailnet address"],
|
|
9609
|
+
["--keep-address", "join: keep its tailnet address across stops and moves"],
|
|
9610
|
+
["--node-name <name>", "join: its name on the tailnet; the sandbox's own by default"]
|
|
9611
|
+
]
|
|
9612
|
+
},
|
|
9586
9613
|
{
|
|
9587
9614
|
name: "spot",
|
|
9588
9615
|
summary: "Read a spot sandbox's chance of being stopped, change what a reclaim does to it, or turn off spot.",
|
|
@@ -10080,6 +10107,7 @@ var SUBCOMMANDS = {
|
|
|
10080
10107
|
job: ["list"],
|
|
10081
10108
|
limits: ["budget"],
|
|
10082
10109
|
egress: ["budget", "use-case"],
|
|
10110
|
+
tailscale: ["status", "connect", "disconnect"],
|
|
10083
10111
|
telemetry: ["set", "test", "unset"],
|
|
10084
10112
|
ci: ["jobs", "set", "reset"],
|
|
10085
10113
|
org: ["list", "use", "create"],
|
|
@@ -13119,12 +13147,12 @@ function describe5(snapshot2) {
|
|
|
13119
13147
|
["Kept", `${keptOf(snapshot2)}${copied}`],
|
|
13120
13148
|
["State", snapshot2.state]
|
|
13121
13149
|
];
|
|
13122
|
-
const
|
|
13150
|
+
const out2 = [`${strong(snapshot2.name)} ${faint(snapshot2.id)}`, "", ...fitted(facts, { paint: (cell, _row, column) => column === 0 ? faint(cell) : cell }).trimEnd().split("\n")];
|
|
13123
13151
|
if (snapshot2.kept === STORAGE_ONLY) {
|
|
13124
|
-
|
|
13152
|
+
out2.push("", "Its server no longer holds it. Rolling back to it, or starting a sandbox from it, fetches it first: a few minutes.");
|
|
13125
13153
|
}
|
|
13126
13154
|
if (snapshot2.state !== "ready") {
|
|
13127
|
-
return `${
|
|
13155
|
+
return `${out2.join("\n")}
|
|
13128
13156
|
`;
|
|
13129
13157
|
}
|
|
13130
13158
|
const next = [
|
|
@@ -13132,8 +13160,8 @@ function describe5(snapshot2) {
|
|
|
13132
13160
|
["Start from", `agental sandbox create --snapshot ${snapshot2.id}`],
|
|
13133
13161
|
["Delete", `agental snapshot delete ${snapshot2.id}`]
|
|
13134
13162
|
];
|
|
13135
|
-
|
|
13136
|
-
return `${
|
|
13163
|
+
out2.push("", ...fitted(next, { paint: (cell, _row, column) => column === 0 ? faint(cell) : cell }).trimEnd().split("\n"));
|
|
13164
|
+
return `${out2.join("\n")}
|
|
13137
13165
|
`;
|
|
13138
13166
|
}
|
|
13139
13167
|
async function snapshotsOfSandbox(client, word) {
|
|
@@ -13237,16 +13265,16 @@ async function snapshot(client, positionals, options) {
|
|
|
13237
13265
|
if (found.kept === STORAGE_ONLY) {
|
|
13238
13266
|
process.stderr.write("Its server no longer holds it: it is fetched from storage first, which takes a few minutes.\n");
|
|
13239
13267
|
}
|
|
13240
|
-
const
|
|
13268
|
+
const answer5 = await ask10(client, "POST", `/v1/sandboxes/${encodeURIComponent(found.sandboxId)}/restore`, {
|
|
13241
13269
|
headers: { "Idempotency-Key": options.idempotencyKey ?? `cli-${randomUUID2()}` },
|
|
13242
13270
|
body: { snapshotId: found.id }
|
|
13243
13271
|
});
|
|
13244
13272
|
if (options.json) {
|
|
13245
|
-
process.stdout.write(`${JSON.stringify(
|
|
13273
|
+
process.stdout.write(`${JSON.stringify(answer5, null, 2)}
|
|
13246
13274
|
`);
|
|
13247
13275
|
return;
|
|
13248
13276
|
}
|
|
13249
|
-
const read2 =
|
|
13277
|
+
const read2 = answer5;
|
|
13250
13278
|
const discarded = Array.isArray(read2?.discarded) ? read2.discarded.map(String) : [];
|
|
13251
13279
|
const status = typeof read2?.sandbox?.status === "string" ? `, and ${read2.sandbox.status}` : "";
|
|
13252
13280
|
process.stdout.write(`${sandbox} is as it was at ${found.name}${status}.
|
|
@@ -13396,14 +13424,14 @@ async function hkdfExtract(salt, ikm) {
|
|
|
13396
13424
|
return hmac(salt.length > 0 ? salt : new Uint8Array(32), ikm);
|
|
13397
13425
|
}
|
|
13398
13426
|
async function hkdfExpand(prk, info, length) {
|
|
13399
|
-
const
|
|
13427
|
+
const out2 = new Uint8Array(length);
|
|
13400
13428
|
let block = new Uint8Array();
|
|
13401
13429
|
for (let counter = 1, filled = 0; filled < length; counter++) {
|
|
13402
13430
|
block = await hmac(prk, concat(block, info, new Uint8Array([counter])));
|
|
13403
|
-
|
|
13431
|
+
out2.set(block.subarray(0, Math.min(block.length, length - filled)), filled);
|
|
13404
13432
|
filled += block.length;
|
|
13405
13433
|
}
|
|
13406
|
-
return
|
|
13434
|
+
return out2;
|
|
13407
13435
|
}
|
|
13408
13436
|
async function hmac(key2, data) {
|
|
13409
13437
|
const hmacKey = await subtle().importKey("raw", key2, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
@@ -13415,18 +13443,18 @@ function subtle() {
|
|
|
13415
13443
|
return webCrypto;
|
|
13416
13444
|
}
|
|
13417
13445
|
function i2osp(value, length) {
|
|
13418
|
-
const
|
|
13419
|
-
for (let i = length - 1, v = value; i >= 0; i--, v >>>= 8)
|
|
13420
|
-
return
|
|
13446
|
+
const out2 = new Uint8Array(length);
|
|
13447
|
+
for (let i = length - 1, v = value; i >= 0; i--, v >>>= 8) out2[i] = v & 255;
|
|
13448
|
+
return out2;
|
|
13421
13449
|
}
|
|
13422
13450
|
function concat(...parts) {
|
|
13423
|
-
const
|
|
13451
|
+
const out2 = new Uint8Array(parts.reduce((total, part) => total + part.length, 0));
|
|
13424
13452
|
let offset = 0;
|
|
13425
13453
|
for (const part of parts) {
|
|
13426
|
-
|
|
13454
|
+
out2.set(part, offset);
|
|
13427
13455
|
offset += part.length;
|
|
13428
13456
|
}
|
|
13429
|
-
return
|
|
13457
|
+
return out2;
|
|
13430
13458
|
}
|
|
13431
13459
|
function utf8(text) {
|
|
13432
13460
|
return new Uint8Array(new TextEncoder().encode(text));
|
|
@@ -13584,6 +13612,9 @@ async function toSeal(client, given, options, verb) {
|
|
|
13584
13612
|
return { name, value, hosts };
|
|
13585
13613
|
}
|
|
13586
13614
|
async function sealFor(client, name, value, hosts) {
|
|
13615
|
+
return await sealForAccount(client, name, value, hosts, "variable");
|
|
13616
|
+
}
|
|
13617
|
+
async function sealForAccount(client, name, value, hosts, purpose) {
|
|
13587
13618
|
const { keys } = await answer2(client, "/v1/secrets/key", { method: "GET" });
|
|
13588
13619
|
const org2 = String((await answer2(client, "/v1/me", { method: "GET" })).activeOrganizationId ?? "");
|
|
13589
13620
|
if (!org2) {
|
|
@@ -13596,7 +13627,7 @@ async function sealFor(client, name, value, hosts) {
|
|
|
13596
13627
|
for (const key2 of mine) {
|
|
13597
13628
|
await verifySealingKey(key2, client.roots ?? ROOT_KEYS);
|
|
13598
13629
|
}
|
|
13599
|
-
const sealed = await Promise.all(mine.map((key2) => seal(key2, { value, hosts, org: org2, name, purpose
|
|
13630
|
+
const sealed = await Promise.all(mine.map((key2) => seal(key2, { value, hosts, org: org2, name, purpose }, client.roots ?? ROOT_KEYS)));
|
|
13600
13631
|
return { sealed, org: org2 };
|
|
13601
13632
|
}
|
|
13602
13633
|
function nameOf2(given, verb) {
|
|
@@ -13653,6 +13684,148 @@ function refused(client, status, body) {
|
|
|
13653
13684
|
client.fail(status, body);
|
|
13654
13685
|
}
|
|
13655
13686
|
|
|
13687
|
+
// ../src/cli-tailscale.ts
|
|
13688
|
+
var SECRET_NAME = "TAILSCALE_OAUTH";
|
|
13689
|
+
var SECRET_HOST = "api.tailscale.com";
|
|
13690
|
+
async function answer3(client, pathname, init) {
|
|
13691
|
+
const response = await client.request(pathname, init);
|
|
13692
|
+
const text = await response.text();
|
|
13693
|
+
let body = text;
|
|
13694
|
+
try {
|
|
13695
|
+
body = text ? JSON.parse(text) : null;
|
|
13696
|
+
} catch {
|
|
13697
|
+
}
|
|
13698
|
+
if (!response.ok) {
|
|
13699
|
+
client.fail(response.status, body);
|
|
13700
|
+
}
|
|
13701
|
+
return body;
|
|
13702
|
+
}
|
|
13703
|
+
async function sandboxIdOf2(client, word) {
|
|
13704
|
+
if (word.startsWith("sbx_")) {
|
|
13705
|
+
return word;
|
|
13706
|
+
}
|
|
13707
|
+
const body = await answer3(client, `/v1/sandboxes?${new URLSearchParams({ q: word })}`, { method: "GET" });
|
|
13708
|
+
const listed2 = Array.isArray(body?.sandboxes) ? body.sandboxes : [];
|
|
13709
|
+
const named = listed2.filter((one) => one.name === word && typeof one.id === "string");
|
|
13710
|
+
if (named.length > 1) {
|
|
13711
|
+
throw new Error(`${named.length} sandboxes are named ${word}. Give the id of the one you mean: ${named.map((one) => String(one.id)).join(", ")}.`);
|
|
13712
|
+
}
|
|
13713
|
+
if (named.length === 0) {
|
|
13714
|
+
throw new Error(`There is no sandbox named ${word}. agental list lists them.`);
|
|
13715
|
+
}
|
|
13716
|
+
return named[0].id;
|
|
13717
|
+
}
|
|
13718
|
+
function out(flags2, body, words2) {
|
|
13719
|
+
process.stdout.write(flags2.json ? `${JSON.stringify(body, null, 2)}
|
|
13720
|
+
` : words2);
|
|
13721
|
+
}
|
|
13722
|
+
async function tailscale(client, positionals, flags2) {
|
|
13723
|
+
const [verb = "status", ...rest] = positionals;
|
|
13724
|
+
if (rest.length > 0) {
|
|
13725
|
+
throw new Error("tailscale takes connect, status or disconnect, and nothing after it.");
|
|
13726
|
+
}
|
|
13727
|
+
if (verb === "status") {
|
|
13728
|
+
const body = await answer3(client, "/v1/integrations/tailscale", { method: "GET" });
|
|
13729
|
+
out(flags2, body, body.connected ? `Tailscale: connected, OAuth client ${body.clientId}, since ${body.connectedAt}
|
|
13730
|
+
` : "Tailscale: not connected. agental tailscale connect --client-id <id> connects one.\n");
|
|
13731
|
+
return;
|
|
13732
|
+
}
|
|
13733
|
+
if (verb === "connect") {
|
|
13734
|
+
const clientId = flags2.clientId;
|
|
13735
|
+
if (!clientId) {
|
|
13736
|
+
throw new Error("tailscale connect takes --client-id, the OAuth client's id from Tailscale's admin console (Settings, Trust credentials), with the scopes auth_keys and devices:core.");
|
|
13737
|
+
}
|
|
13738
|
+
const secret2 = (await client.readValue("The OAuth client's secret (not shown): ")).trim();
|
|
13739
|
+
if (!secret2.startsWith("tskey-client-")) {
|
|
13740
|
+
throw new Error("That is not a Tailscale OAuth client's secret, which starts tskey-client-. Nothing was sent.");
|
|
13741
|
+
}
|
|
13742
|
+
if (!secret2.startsWith(`tskey-client-${clientId}-`)) {
|
|
13743
|
+
throw new Error(`That secret is not client ${clientId}'s. Nothing was sent.`);
|
|
13744
|
+
}
|
|
13745
|
+
const { sealed } = await sealForAccount(client, SECRET_NAME, secret2, [SECRET_HOST], "tailscale-oauth");
|
|
13746
|
+
const body = await answer3(client, "/v1/integrations/tailscale", { method: "PUT", body: JSON.stringify({ clientId, clientSecret: sealed }) });
|
|
13747
|
+
out(flags2, body, `Tailscale: connected, OAuth client ${body.clientId}. Its secret was sealed here; only agental's servers open it, to mint each node a key.
|
|
13748
|
+
`);
|
|
13749
|
+
return;
|
|
13750
|
+
}
|
|
13751
|
+
if (verb === "disconnect") {
|
|
13752
|
+
if (!flags2.yes && !await client.confirmed("Take every sandbox off the tailnet and forget the OAuth client?")) {
|
|
13753
|
+
throw new Error("Nothing was disconnected. --yes disconnects without asking.");
|
|
13754
|
+
}
|
|
13755
|
+
await answer3(client, "/v1/integrations/tailscale", { method: "DELETE" });
|
|
13756
|
+
out(flags2, { connected: false }, "Tailscale: disconnected. Every sandbox was taken off the tailnet.\n");
|
|
13757
|
+
return;
|
|
13758
|
+
}
|
|
13759
|
+
throw new Error("tailscale takes connect, status or disconnect.");
|
|
13760
|
+
}
|
|
13761
|
+
function joinBody(flags2, withName) {
|
|
13762
|
+
const tags = (flags2.tag ?? []).flatMap((each) => each.split(",")).map((each) => each.trim()).filter((each) => each !== "");
|
|
13763
|
+
if (tags.length === 0) {
|
|
13764
|
+
throw new Error("join takes --tag, one tag:name or more, which the connected OAuth client owns: --tag tag:agental.");
|
|
13765
|
+
}
|
|
13766
|
+
if (!withName && flags2.nodeName !== void 0) {
|
|
13767
|
+
throw new Error("A template's sandboxes are each named by their own sandbox: --node-name is for one sandbox.");
|
|
13768
|
+
}
|
|
13769
|
+
return {
|
|
13770
|
+
tags,
|
|
13771
|
+
...flags2.accept === void 0 ? {} : { acceptRoutes: flags2.accept.flatMap((each) => each.split(",")).map((each) => each.trim()).filter((each) => each !== "") },
|
|
13772
|
+
...flags2.exitNode === void 0 ? {} : { exitNode: flags2.exitNode },
|
|
13773
|
+
...flags2.keepAddress ? { keepAddress: true } : {},
|
|
13774
|
+
...withName && flags2.nodeName !== void 0 ? { name: flags2.nodeName } : {}
|
|
13775
|
+
};
|
|
13776
|
+
}
|
|
13777
|
+
function nodeInWords(node, whose) {
|
|
13778
|
+
if (!node.on) {
|
|
13779
|
+
return `${whose}: on no tailnet
|
|
13780
|
+
`;
|
|
13781
|
+
}
|
|
13782
|
+
return [
|
|
13783
|
+
`${whose}: on the tailnet${node.name ? ` as ${node.name}` : ""}, tagged ${node.tags.join(", ")}`,
|
|
13784
|
+
...node.acceptRoutes.length > 0 ? [` routes: ${node.acceptRoutes.join(", ")}`] : [],
|
|
13785
|
+
...node.exitNode !== null ? [` exit node: ${node.exitNode}`] : [],
|
|
13786
|
+
` address: ${node.keepAddress ? "kept across stops and moves" : "new at each start"}`
|
|
13787
|
+
].join("\n") + "\n";
|
|
13788
|
+
}
|
|
13789
|
+
async function tailnet(client, kind, positionals, flags2) {
|
|
13790
|
+
const [given, verb, ...rest] = positionals;
|
|
13791
|
+
if (given === void 0 || rest.length > 0) {
|
|
13792
|
+
throw new Error(`${kind === "sandbox" ? "tailnet" : "template tailnet"} takes <${kind}>, and then nothing, join with --tag, or off.`);
|
|
13793
|
+
}
|
|
13794
|
+
const id = kind === "sandbox" ? await sandboxIdOf2(client, given) : await client.templateId(given);
|
|
13795
|
+
const path6 = `/v1/${kind === "sandbox" ? "sandboxes" : "templates"}/${encodeURIComponent(id)}/tailnet`;
|
|
13796
|
+
const whose = kind === "sandbox" ? given : `${given}'s sandboxes from now on`;
|
|
13797
|
+
if (verb === void 0) {
|
|
13798
|
+
const node = await answer3(client, path6, { method: "GET" });
|
|
13799
|
+
out(flags2, node, nodeInWords(node, kind === "sandbox" ? given : `${given}'s sandboxes`));
|
|
13800
|
+
return;
|
|
13801
|
+
}
|
|
13802
|
+
if (verb === "join") {
|
|
13803
|
+
const node = await answer3(client, path6, { method: "PUT", body: JSON.stringify(joinBody(flags2, kind === "sandbox")) });
|
|
13804
|
+
out(flags2, node, nodeInWords(node, whose));
|
|
13805
|
+
return;
|
|
13806
|
+
}
|
|
13807
|
+
if (verb === "off") {
|
|
13808
|
+
await answer3(client, path6, { method: "DELETE" });
|
|
13809
|
+
out(flags2, { on: false }, `${whose}: on no tailnet
|
|
13810
|
+
`);
|
|
13811
|
+
return;
|
|
13812
|
+
}
|
|
13813
|
+
throw new Error(`${kind === "sandbox" ? "tailnet" : "template tailnet"} takes <${kind}>, and then nothing, join, or off.`);
|
|
13814
|
+
}
|
|
13815
|
+
function createTailnet(given, flags2 = {}) {
|
|
13816
|
+
const more = flags2.accept !== void 0 || flags2.exitNode !== void 0 || flags2.keepAddress === true || flags2.nodeName !== void 0;
|
|
13817
|
+
if (given === void 0) {
|
|
13818
|
+
if (more) {
|
|
13819
|
+
throw new Error("--accept, --exit-node, --keep-address and --node-name go with --tailnet <tags> on a create.");
|
|
13820
|
+
}
|
|
13821
|
+
return void 0;
|
|
13822
|
+
}
|
|
13823
|
+
if (given === "off") {
|
|
13824
|
+
return null;
|
|
13825
|
+
}
|
|
13826
|
+
return joinBody({ ...flags2, json: false, yes: false, tag: [given] }, true);
|
|
13827
|
+
}
|
|
13828
|
+
|
|
13656
13829
|
// ../src/cli-sites.ts
|
|
13657
13830
|
var USAGE9 = "site takes a sandbox, or list, add, rm, stats or analytics, then the sandbox. agental site --help shows each.";
|
|
13658
13831
|
var ANALYTICS_USAGE = "site analytics takes on or off, then the sandbox and the site's id, or org, with on or off to change it.";
|
|
@@ -14005,10 +14178,10 @@ async function hidden(question) {
|
|
|
14005
14178
|
const muted = lines;
|
|
14006
14179
|
process.stderr.write(question);
|
|
14007
14180
|
muted._writeToOutput = () => void 0;
|
|
14008
|
-
lines.question("", (
|
|
14181
|
+
lines.question("", (answer5) => {
|
|
14009
14182
|
lines.close();
|
|
14010
14183
|
process.stderr.write("\n");
|
|
14011
|
-
resolve(
|
|
14184
|
+
resolve(answer5.trim());
|
|
14012
14185
|
});
|
|
14013
14186
|
});
|
|
14014
14187
|
}
|
|
@@ -14154,7 +14327,7 @@ function whyClosed(code, reason2, error) {
|
|
|
14154
14327
|
return `The terminal was closed (${code})${said ? `: ${said}` : ""}.`;
|
|
14155
14328
|
}
|
|
14156
14329
|
}
|
|
14157
|
-
async function
|
|
14330
|
+
async function answer4(response) {
|
|
14158
14331
|
const body = await response.json().catch(() => null);
|
|
14159
14332
|
if (!response.ok) {
|
|
14160
14333
|
const error = body?.error;
|
|
@@ -14163,7 +14336,7 @@ async function answer3(response) {
|
|
|
14163
14336
|
return body;
|
|
14164
14337
|
}
|
|
14165
14338
|
async function keptShells2(client, id) {
|
|
14166
|
-
const body = await
|
|
14339
|
+
const body = await answer4(await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminals`, { method: "GET" }));
|
|
14167
14340
|
if (!body || !Array.isArray(body.terminals)) {
|
|
14168
14341
|
throw new Error("The list of kept shells was missing terminals.");
|
|
14169
14342
|
}
|
|
@@ -14217,7 +14390,7 @@ async function listShells(client, id, json3, stdout) {
|
|
|
14217
14390
|
}
|
|
14218
14391
|
async function closeShell(client, id, given, stdout) {
|
|
14219
14392
|
const found = await shellNamed(client, id, given, "--close");
|
|
14220
|
-
await
|
|
14393
|
+
await answer4(await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminals/${encodeURIComponent(found.id)}`, { method: "DELETE" }));
|
|
14221
14394
|
stdout.write(`Closed ${found.n === null ? "shell" : `shell ${found.n}`} (${found.id}).
|
|
14222
14395
|
`);
|
|
14223
14396
|
}
|
|
@@ -14298,16 +14471,16 @@ async function shell(client, id, options = {}, streams = process) {
|
|
|
14298
14471
|
let closedHere = false;
|
|
14299
14472
|
let detached = false;
|
|
14300
14473
|
const escaped = (chunk) => {
|
|
14301
|
-
const
|
|
14474
|
+
const out2 = [];
|
|
14302
14475
|
for (const byte of chunk) {
|
|
14303
|
-
const before =
|
|
14476
|
+
const before = out2.length > 0 ? out2[out2.length - 1] : lastSent;
|
|
14304
14477
|
const atLineStart = before === 13 || before === 10;
|
|
14305
14478
|
if (tilde) {
|
|
14306
14479
|
tilde = false;
|
|
14307
14480
|
if (byte === 46) {
|
|
14308
14481
|
closedHere = true;
|
|
14309
14482
|
socket.close(1e3, "closed");
|
|
14310
|
-
return Buffer.from(
|
|
14483
|
+
return Buffer.from(out2);
|
|
14311
14484
|
}
|
|
14312
14485
|
if (byte === 100) {
|
|
14313
14486
|
if (kept2 === null) {
|
|
@@ -14316,19 +14489,19 @@ async function shell(client, id, options = {}, streams = process) {
|
|
|
14316
14489
|
}
|
|
14317
14490
|
detached = true;
|
|
14318
14491
|
socket.close(1e3, "detached");
|
|
14319
|
-
return Buffer.from(
|
|
14492
|
+
return Buffer.from(out2);
|
|
14320
14493
|
}
|
|
14321
|
-
|
|
14494
|
+
out2.push(126);
|
|
14322
14495
|
if (byte !== 126) {
|
|
14323
|
-
|
|
14496
|
+
out2.push(byte);
|
|
14324
14497
|
}
|
|
14325
14498
|
} else if (byte === 126 && atLineStart) {
|
|
14326
14499
|
tilde = true;
|
|
14327
14500
|
} else {
|
|
14328
|
-
|
|
14501
|
+
out2.push(byte);
|
|
14329
14502
|
}
|
|
14330
14503
|
}
|
|
14331
|
-
return Buffer.from(
|
|
14504
|
+
return Buffer.from(out2);
|
|
14332
14505
|
};
|
|
14333
14506
|
const typed = (chunk) => {
|
|
14334
14507
|
const bytes4 = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
@@ -14886,6 +15059,13 @@ async function main() {
|
|
|
14886
15059
|
"allow-from": { type: "string", multiple: true },
|
|
14887
15060
|
// Tags as a sandbox or template is made with them, or as list finds them: given again, or with commas, for several. --tags is the same.
|
|
14888
15061
|
tag: { type: "string", multiple: true },
|
|
15062
|
+
// Tailscale (src/cli-tailscale.ts): the OAuth client's id, a node's routes, exit node, address and name, and a create's tags.
|
|
15063
|
+
"client-id": { type: "string" },
|
|
15064
|
+
accept: { type: "string", multiple: true },
|
|
15065
|
+
"exit-node": { type: "string" },
|
|
15066
|
+
"keep-address": { type: "boolean" },
|
|
15067
|
+
"node-name": { type: "string" },
|
|
15068
|
+
tailnet: { type: "string" },
|
|
14889
15069
|
tags: { type: "string", multiple: true },
|
|
14890
15070
|
// Metadata as <key>=<value>, given again for each key.
|
|
14891
15071
|
meta: { type: "string", multiple: true },
|
|
@@ -15050,6 +15230,12 @@ async function main() {
|
|
|
15050
15230
|
case "egress":
|
|
15051
15231
|
await egress(positionals.slice(1), values);
|
|
15052
15232
|
return;
|
|
15233
|
+
case "tailscale":
|
|
15234
|
+
await tailscale(tailscaleClient(), positionals.slice(1), tailnetFlags(values));
|
|
15235
|
+
return;
|
|
15236
|
+
case "tailnet":
|
|
15237
|
+
await tailnet(tailscaleClient(), "sandbox", positionals.slice(1), tailnetFlags(values));
|
|
15238
|
+
return;
|
|
15053
15239
|
case "spot":
|
|
15054
15240
|
await spot(positionals.slice(1), values);
|
|
15055
15241
|
return;
|
|
@@ -15201,6 +15387,12 @@ async function create(values) {
|
|
|
15201
15387
|
}
|
|
15202
15388
|
const allow = values.allow === void 0 ? void 0 : listedIn(values.allow);
|
|
15203
15389
|
const egressAsked = values.egress === void 0 ? void 0 : egressFrom(values.egress.split(":"), "--egress takes box, or residential:<country>, as residential:de or residential:us:rotating.");
|
|
15390
|
+
const tailnetAsked = createTailnet(values.tailnet, {
|
|
15391
|
+
...values.accept === void 0 ? {} : { accept: values.accept },
|
|
15392
|
+
...values["exit-node"] === void 0 ? {} : { exitNode: values["exit-node"] },
|
|
15393
|
+
...values["keep-address"] === void 0 ? {} : { keepAddress: values["keep-address"] },
|
|
15394
|
+
...values["node-name"] === void 0 ? {} : { nodeName: values["node-name"] }
|
|
15395
|
+
});
|
|
15204
15396
|
const sshKeys2 = values["ssh-key"] === void 0 ? void 0 : publicKeysFrom(values["ssh-key"]);
|
|
15205
15397
|
const box = boxNamed(values.box);
|
|
15206
15398
|
if (box !== void 0 && PUBLISHED) {
|
|
@@ -15219,6 +15411,7 @@ async function create(values) {
|
|
|
15219
15411
|
...regionsOption(values.region),
|
|
15220
15412
|
...allow ? { network: { allow } } : {},
|
|
15221
15413
|
...egressAsked ? { egress: egressAsked } : {},
|
|
15414
|
+
...tailnetAsked === void 0 ? {} : { tailnet: tailnetAsked },
|
|
15222
15415
|
...ttlSeconds === void 0 ? {} : { ttlSeconds },
|
|
15223
15416
|
...onTimeout === void 0 ? {} : { onTimeout: onTimeout.replaceAll("-", "_") },
|
|
15224
15417
|
...spotAsked === void 0 ? {} : { spot: spotAsked },
|
|
@@ -15476,6 +15669,21 @@ async function typedCount(count) {
|
|
|
15476
15669
|
lines.close();
|
|
15477
15670
|
}
|
|
15478
15671
|
}
|
|
15672
|
+
function tailscaleClient() {
|
|
15673
|
+
return { request, fail, confirmed, readValue: hiddenValue, templateId: async (given) => (await templateNamed(given)).id };
|
|
15674
|
+
}
|
|
15675
|
+
function tailnetFlags(values) {
|
|
15676
|
+
return {
|
|
15677
|
+
json: values.json,
|
|
15678
|
+
yes: values.yes,
|
|
15679
|
+
...values["client-id"] === void 0 ? {} : { clientId: values["client-id"] },
|
|
15680
|
+
...values.tag === void 0 ? {} : { tag: values.tag },
|
|
15681
|
+
...values.accept === void 0 ? {} : { accept: values.accept },
|
|
15682
|
+
...values["exit-node"] === void 0 ? {} : { exitNode: values["exit-node"] },
|
|
15683
|
+
...values["keep-address"] === void 0 ? {} : { keepAddress: values["keep-address"] },
|
|
15684
|
+
...values["node-name"] === void 0 ? {} : { nodeName: values["node-name"] }
|
|
15685
|
+
};
|
|
15686
|
+
}
|
|
15479
15687
|
async function hiddenValue(prompt) {
|
|
15480
15688
|
if (!process.stdin.isTTY) {
|
|
15481
15689
|
process.stderr.write(`${prompt.replace(/: $/, "")}: read from stdin
|
|
@@ -16465,7 +16673,7 @@ function showTemplate(each) {
|
|
|
16465
16673
|
}
|
|
16466
16674
|
async function template(positionals, values) {
|
|
16467
16675
|
const [action, first, ...rest] = positionals;
|
|
16468
|
-
const usage = "template takes create, show, rename, delete, start, network, egress, ssh, ssh-keys, tags, meta, sandboxes, apply, of or put. agental template --help says how.";
|
|
16676
|
+
const usage = "template takes create, show, rename, delete, start, network, egress, tailnet, ssh, ssh-keys, tags, meta, sandboxes, apply, of or put. agental template --help says how.";
|
|
16469
16677
|
const print4 = (body, words2) => {
|
|
16470
16678
|
process.stdout.write(values.json ? `${JSON.stringify(body, null, 2)}
|
|
16471
16679
|
` : words2);
|
|
@@ -16585,6 +16793,9 @@ ${mode === void 0 ? "" : "A sandbox on it takes this when it next starts, or now
|
|
|
16585
16793
|
);
|
|
16586
16794
|
return;
|
|
16587
16795
|
}
|
|
16796
|
+
case "tailnet":
|
|
16797
|
+
await tailnet(tailscaleClient(), "template", [need(first, "<template>"), ...rest], tailnetFlags(values));
|
|
16798
|
+
return;
|
|
16588
16799
|
case "egress": {
|
|
16589
16800
|
const found = await templateNamed(need(first, "<template>"));
|
|
16590
16801
|
const path6 = `/v1/templates/${encodeURIComponent(found.id)}/egress`;
|
|
@@ -16872,8 +17083,8 @@ async function metrics(id, asked2) {
|
|
|
16872
17083
|
if (!response.ok) {
|
|
16873
17084
|
fail(response.status, body);
|
|
16874
17085
|
}
|
|
16875
|
-
const
|
|
16876
|
-
const fromTo = typeof
|
|
17086
|
+
const answer5 = body && typeof body === "object" ? body : {};
|
|
17087
|
+
const fromTo = typeof answer5["since"] === "string" && typeof answer5["until"] === "string" ? ` from ${answer5["since"]} to ${answer5["until"]}` : "";
|
|
16877
17088
|
if (asked2.json) {
|
|
16878
17089
|
process.stdout.write(`${JSON.stringify(body, null, 2)}
|
|
16879
17090
|
`);
|
|
@@ -16898,26 +17109,26 @@ async function metrics(id, asked2) {
|
|
|
16898
17109
|
])
|
|
16899
17110
|
);
|
|
16900
17111
|
}
|
|
16901
|
-
if (
|
|
17112
|
+
if (answer5["complete"] === false) {
|
|
16902
17113
|
process.stderr.write(
|
|
16903
17114
|
id === void 0 ? "A server did not answer, so a sandbox on it has no reading here though it may have been running. Ask again in a minute.\n" : `A server did not answer, so readings may be missing: those from any time ${id} was on that server. Ask again in a minute.
|
|
16904
17115
|
`
|
|
16905
17116
|
);
|
|
16906
17117
|
}
|
|
16907
17118
|
}
|
|
16908
|
-
async function account2(positionals,
|
|
17119
|
+
async function account2(positionals, out2) {
|
|
16909
17120
|
if (positionals[0] !== "export" || positionals.length > 1) {
|
|
16910
17121
|
throw new Error("account takes export [--out <file>]. An account is closed from Settings in the console: a key cannot close one.");
|
|
16911
17122
|
}
|
|
16912
17123
|
const body = await asked("/v1/me/export", { method: "GET" });
|
|
16913
17124
|
const text = `${JSON.stringify(body, null, 2)}
|
|
16914
17125
|
`;
|
|
16915
|
-
if (
|
|
17126
|
+
if (out2 === void 0) {
|
|
16916
17127
|
process.stdout.write(text);
|
|
16917
17128
|
return;
|
|
16918
17129
|
}
|
|
16919
|
-
writeFileSync5(
|
|
16920
|
-
process.stdout.write(`Written to ${
|
|
17130
|
+
writeFileSync5(out2, text, { mode: 384 });
|
|
17131
|
+
process.stdout.write(`Written to ${out2}.
|
|
16921
17132
|
`);
|
|
16922
17133
|
}
|
|
16923
17134
|
async function dataRetention(positionals, asJson) {
|
|
@@ -16941,8 +17152,8 @@ async function dataRetention(positionals, asJson) {
|
|
|
16941
17152
|
`);
|
|
16942
17153
|
return;
|
|
16943
17154
|
}
|
|
16944
|
-
const
|
|
16945
|
-
const days =
|
|
17155
|
+
const answer5 = body ?? {};
|
|
17156
|
+
const days = answer5.keepDays ?? null;
|
|
16946
17157
|
const kept2 = days === null ? "until their sandbox is deleted" : days === 1 ? "1 day" : `${days} days`;
|
|
16947
17158
|
process.stdout.write(`${period === void 0 ? "" : "Saved. "}Command output, agent conversations and events are kept ${kept2}.
|
|
16948
17159
|
`);
|
|
@@ -16950,7 +17161,7 @@ async function dataRetention(positionals, asJson) {
|
|
|
16950
17161
|
process.stdout.write(`What is older is deleted within the hour, and cannot be brought back.
|
|
16951
17162
|
`);
|
|
16952
17163
|
}
|
|
16953
|
-
const last =
|
|
17164
|
+
const last = answer5.lastCleared;
|
|
16954
17165
|
if (period === void 0) {
|
|
16955
17166
|
process.stdout.write(
|
|
16956
17167
|
last ? `Last clean-up ${last.at}: ${last.commands} commands' output, ${last.conversations} conversations and ${last.events} events deleted.
|
|
@@ -17508,11 +17719,11 @@ function describeAutoReload(autoReload) {
|
|
|
17508
17719
|
return `${wholeMoney(autoReload.dollars * 1e6)}${adds} charged to your saved card when your credits run out, before anything is stopped. At most 3 times a day.`;
|
|
17509
17720
|
}
|
|
17510
17721
|
function pricesForPeople(body) {
|
|
17511
|
-
const
|
|
17722
|
+
const out2 = [];
|
|
17512
17723
|
const count = (value) => value === void 0 || value === null ? "" : value.toLocaleString("en-US");
|
|
17513
17724
|
const section = (title, rows, notes) => {
|
|
17514
17725
|
const table4 = fitted(rows, { paint: (cell, row) => row === 0 ? faint(cell) : cell }).trimEnd().split("\n");
|
|
17515
|
-
|
|
17726
|
+
out2.push(strong(title), ...table4.map((line) => ` ${line}`), ...notes.map((note) => ` ${faint(note)}`), "");
|
|
17516
17727
|
};
|
|
17517
17728
|
if (body.tiers?.length) {
|
|
17518
17729
|
section(
|
|
@@ -17567,68 +17778,68 @@ function pricesForPeople(body) {
|
|
|
17567
17778
|
also.push(["Snapshots", `the ${body.storage.freeSnapshots} oldest free, then $${(body.storage.snapshotMicrosPerHour * 730 / 1e6).toFixed(2)} a month each`]);
|
|
17568
17779
|
}
|
|
17569
17780
|
if (also.length > 0) {
|
|
17570
|
-
|
|
17781
|
+
out2.push(strong("Also"), ...fitted(also).trimEnd().split("\n").map((line) => ` ${line}`), "");
|
|
17571
17782
|
}
|
|
17572
|
-
|
|
17573
|
-
return `${
|
|
17783
|
+
out2.push(faint("agental billing top-up <dollars> \xB7 agental limits budget <dollars> \xB7 https://agental.io/pricing"));
|
|
17784
|
+
return `${out2.join("\n")}
|
|
17574
17785
|
`;
|
|
17575
17786
|
}
|
|
17576
17787
|
function describePrices(body) {
|
|
17577
|
-
const
|
|
17788
|
+
const out2 = [];
|
|
17578
17789
|
if (body.tiers?.length) {
|
|
17579
17790
|
const withSizes = body.tiers.some((tier) => tier.sizes !== void 0);
|
|
17580
|
-
|
|
17791
|
+
out2.push(withSizes ? "Plans, a month, and the sizes each makes" : "Plans, a month");
|
|
17581
17792
|
for (const tier of body.tiers) {
|
|
17582
17793
|
const sizes = tier.sizes === void 0 ? "" : tier.sizes.length === body.plans.length ? "every size" : tier.sizes.join(", ");
|
|
17583
17794
|
const speed = tier.runningUnits !== void 0 && tier.freeBurstUnits !== void 0 ? `${tier.runningUnits.toLocaleString("en-US")} running, ${tier.freeBurstUnits.toLocaleString("en-US")} free starts` : tier.burst ? `${(tier.burst.perQuarterMb / 1024).toLocaleString("en-US")} GiB per 15 minutes` : typeof tier.sandboxesAtOnce === "number" ? `${tier.sandboxesAtOnce.toLocaleString("en-US")} sandboxes at once` : "";
|
|
17584
17795
|
const price = tier.dollarsPerMonth === 0 ? "Free" : `$${tier.dollarsPerMonth.toLocaleString("en-US")}`;
|
|
17585
17796
|
const included = tier.dollarsPerMonth === 0 ? body.free ? `${wholeOrCents(body.free.allowanceMicros)} free, then as you go` : "pay as you go" : `${wholeMoney(tier.includedMicros)} of credits`;
|
|
17586
|
-
|
|
17797
|
+
out2.push(` ${price.padEnd(8)}${included.padEnd(28)}${speed.padEnd(34)}${sizes}`.trimEnd());
|
|
17587
17798
|
}
|
|
17588
17799
|
if (body.free) {
|
|
17589
|
-
|
|
17800
|
+
out2.push(
|
|
17590
17801
|
` Free needs a card saved, charged nothing. Each month's first ${wholeOrCents(body.free.allowanceMicros)} of use is free: 185 hours of a small sandbox, 370 of a tiny one, or 11,100 CI minutes on small. It runs ${body.free.unpaidUnits} units at once until you buy a top-up.`
|
|
17591
17802
|
);
|
|
17592
17803
|
}
|
|
17593
17804
|
if (body.tiers.some((tier) => tier.runningUnits !== void 0)) {
|
|
17594
|
-
|
|
17805
|
+
out2.push(" Counted in units: a tiny sandbox is 1, a small 2, a medium 4, a large 8. Free starts are in any 15 minutes.");
|
|
17595
17806
|
}
|
|
17596
17807
|
}
|
|
17597
17808
|
if (body.burstFee) {
|
|
17598
|
-
|
|
17809
|
+
out2.push(
|
|
17599
17810
|
`A start past your free starts in any ${body.burstFee.windowMinutes} minutes costs one hour of its price: $${body.burstFee.feeMicrosPerUnit / 1e6} a unit, $0.027 a small, $0.108 a large. At most ${wholeMoney(body.burstFee.defaultBudgetMicros)} a month unless you set another budget: agental limits budget <dollars>.`
|
|
17600
17811
|
);
|
|
17601
17812
|
}
|
|
17602
17813
|
if (body.topUps?.length) {
|
|
17603
17814
|
const range = body.topUpRange;
|
|
17604
|
-
|
|
17815
|
+
out2.push(
|
|
17605
17816
|
range ? `Top-ups, any whole number of dollars from ${wholeMoney(range.minDollars * 1e6)} to ${wholeMoney(range.maxDollars * 1e6)}, used after the plan's credits. They do not expire.` : "Top-ups, used after the plan's credits. They do not expire."
|
|
17606
17817
|
);
|
|
17607
17818
|
if (body.topUps.some((topUp) => topUp.micros !== void 0)) {
|
|
17608
17819
|
for (const topUp of body.topUps) {
|
|
17609
17820
|
const bonus = topUp.bonusPercent ? `+${topUp.bonusPercent}%` : "";
|
|
17610
|
-
|
|
17821
|
+
out2.push(` ${`$${topUp.dollars.toLocaleString("en-US")}`.padEnd(10)}${bonus.padEnd(10)}${`adds ${wholeMoney(topUp.micros ?? topUp.dollars * 1e6)}`}`);
|
|
17611
17822
|
}
|
|
17612
17823
|
} else {
|
|
17613
|
-
|
|
17824
|
+
out2.push(` ${body.topUps.map((topUp) => `$${topUp.dollars}`).join(" ")}`);
|
|
17614
17825
|
}
|
|
17615
17826
|
if (body.topUpBonus) {
|
|
17616
17827
|
const bonus = body.topUpBonus;
|
|
17617
|
-
|
|
17828
|
+
out2.push(
|
|
17618
17829
|
` From ${wholeMoney(bonus.fromDollars * 1e6)} a top-up adds a bonus: ${bonus.fromPercent}% there, growing evenly on a log scale to ${bonus.toPercent}% at ${wholeMoney(bonus.toDollars * 1e6)} and over.`
|
|
17619
17830
|
);
|
|
17620
17831
|
}
|
|
17621
17832
|
}
|
|
17622
|
-
|
|
17833
|
+
out2.push("Sizes, an hour at list price");
|
|
17623
17834
|
for (const size2 of body.plans) {
|
|
17624
|
-
|
|
17835
|
+
out2.push(` ${size2.size.padEnd(8)}${`${size2.vcpu} vCPU, ${size2.memoryMb / 1024} GiB`.padEnd(20)}$${size2.listPriceMicrosPerHour / 1e6}`);
|
|
17625
17836
|
}
|
|
17626
17837
|
if (body.storage) {
|
|
17627
17838
|
const month = body.storage.snapshotMicrosPerHour * 730 / 1e6;
|
|
17628
|
-
|
|
17629
|
-
|
|
17839
|
+
out2.push(stoppedWords(body.storage));
|
|
17840
|
+
out2.push(`Snapshots: the ${body.storage.freeSnapshots} oldest are free, and each one past them is $${month.toFixed(2)} a month, by the second.`);
|
|
17630
17841
|
}
|
|
17631
|
-
return `${
|
|
17842
|
+
return `${out2.join("\n")}
|
|
17632
17843
|
`;
|
|
17633
17844
|
}
|
|
17634
17845
|
function stoppedWords(storage) {
|
|
@@ -17651,10 +17862,10 @@ async function showLimits(positionals, options) {
|
|
|
17651
17862
|
`);
|
|
17652
17863
|
return;
|
|
17653
17864
|
}
|
|
17654
|
-
const
|
|
17655
|
-
const spent = typeof
|
|
17656
|
-
const budget = typeof
|
|
17657
|
-
process.stdout.write(`Budget for burst fees: ${money(budget)} a month${
|
|
17865
|
+
const answer5 = body2 && typeof body2 === "object" ? body2 : {};
|
|
17866
|
+
const spent = typeof answer5["spentMicros"] === "number" ? answer5["spentMicros"] : 0;
|
|
17867
|
+
const budget = typeof answer5["budgetMicros"] === "number" ? answer5["budgetMicros"] : 0;
|
|
17868
|
+
process.stdout.write(`Budget for burst fees: ${money(budget)} a month${answer5["budgetSet"] === true ? "" : " (the default)"}; ${money(spent)} spent this month.
|
|
17658
17869
|
`);
|
|
17659
17870
|
return;
|
|
17660
17871
|
}
|
|
@@ -17684,8 +17895,8 @@ async function showLimits(positionals, options) {
|
|
|
17684
17895
|
process.stdout.write(describeLimits(body, options.from === void 0 && options.to === void 0, options.to === void 0));
|
|
17685
17896
|
}
|
|
17686
17897
|
function describeLimits(body, today, endsNow) {
|
|
17687
|
-
const
|
|
17688
|
-
const now =
|
|
17898
|
+
const answer5 = body && typeof body === "object" ? body : {};
|
|
17899
|
+
const now = answer5["now"] && typeof answer5["now"] === "object" ? answer5["now"] : {};
|
|
17689
17900
|
const number = (from, name) => typeof from[name] === "number" ? from[name] : 0;
|
|
17690
17901
|
const units = (mb) => {
|
|
17691
17902
|
const value = mb / 2048;
|
|
@@ -17695,11 +17906,11 @@ function describeLimits(body, today, endsNow) {
|
|
|
17695
17906
|
const at4 = new Date(iso).toISOString();
|
|
17696
17907
|
return at4.slice(0, 10) === (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) ? `${at4.slice(11, 16)} UTC` : `${at4.slice(0, 10)} ${at4.slice(11, 16)} UTC`;
|
|
17697
17908
|
};
|
|
17698
|
-
const range = today ? "today (UTC)" : `from ${String(
|
|
17909
|
+
const range = today ? "today (UTC)" : `from ${String(answer5["from"] ?? "")} to ${String(answer5["to"] ?? "")}`;
|
|
17699
17910
|
const lines = [
|
|
17700
|
-
`running: ${units(number(now, "runningMb"))} of ${number(now, "runningUnits").toLocaleString("en-US")} units (a tiny is 1, a small 2, a medium 4, a large 8); at the running count ${duration(number(
|
|
17911
|
+
`running: ${units(number(now, "runningMb"))} of ${number(now, "runningUnits").toLocaleString("en-US")} units (a tiny is 1, a small 2, a medium 4, a large 8); at the running count ${duration(number(answer5, "atRunningCountMs"))} ${range}`
|
|
17701
17912
|
];
|
|
17702
|
-
const bursts = Array.isArray(
|
|
17913
|
+
const bursts = Array.isArray(answer5["bursts"]) ? answer5["bursts"] : [];
|
|
17703
17914
|
const open = endsNow ? bursts.find((one) => one["endedAt"] === null && typeof one["startedAt"] === "string") : void 0;
|
|
17704
17915
|
const over = number(now, "overMb") > 0;
|
|
17705
17916
|
const nextStart = Array.isArray(now["nextStart"]) ? now["nextStart"] : [];
|
|
@@ -17715,7 +17926,7 @@ function describeLimits(body, today, endsNow) {
|
|
|
17715
17926
|
const budgetMonth = now["budgetMonth"] && typeof now["budgetMonth"] === "object" ? now["budgetMonth"] : null;
|
|
17716
17927
|
const since = typeof budgetMonth?.start === "string" && budgetMonth.start.slice(8, 10) !== "01" ? ` (since ${shortDayOf(budgetMonth.start)})` : "";
|
|
17717
17928
|
lines.push(`fees: ${money(number(now, "spentMicros"))} this month${since} of a ${money(number(now, "budgetMicros"))} budget`);
|
|
17718
|
-
const refused2 =
|
|
17929
|
+
const refused2 = answer5["refused"] && typeof answer5["refused"] === "object" ? answer5["refused"] : {};
|
|
17719
17930
|
const total = number(refused2, "total");
|
|
17720
17931
|
const byReason = Array.isArray(refused2["byReason"]) ? refused2["byReason"] : [];
|
|
17721
17932
|
lines.push(
|
|
@@ -18064,6 +18275,8 @@ Usage
|
|
|
18064
18275
|
agental auto-stop <sandbox-id> [--in <time> | --at <date-time> | --never] [--json]
|
|
18065
18276
|
agental network <sandbox-id> [--allow <address-or-name>[,<address-or-name>...] | --none] [--json]
|
|
18066
18277
|
agental egress <sandbox-id> [box | residential <country> [sticky | rotating]] [--json]
|
|
18278
|
+
agental tailscale [status | connect --client-id <id> | disconnect [--yes]] [--json]
|
|
18279
|
+
agental tailnet <sandbox-id> [join --tag <tag>... [--accept <range>]... [--exit-node <ip>] [--keep-address] [--node-name <name>] | off] [--json]
|
|
18067
18280
|
agental spot <sandbox-id> [off] [--on-reclaim delete|stop] [--warn-at <chance>] [--json]
|
|
18068
18281
|
agental templates [--json]
|
|
18069
18282
|
agental template create <name> [--tag <tag>[,<tag>...]]... [--meta <key>=<value>]...
|
|
@@ -18073,6 +18286,7 @@ Usage
|
|
|
18073
18286
|
agental template start <template> [--size tiny|small|medium|large] [--snapshot <snapshot-id> | --new-machine] [--ttl <time> | --ttl default] [--region <region> | --region default] [--spot [--on-reclaim delete|stop] [--warn-at <chance>] | --standard]
|
|
18074
18287
|
agental template network <template> [open | blocked | allowlist <address-or-name>...] [--json]
|
|
18075
18288
|
agental template egress <template> [box | residential <country> [sticky | rotating]] [--json]
|
|
18289
|
+
agental template tailnet <template> [join --tag <tag>... [--accept <range>]... [--exit-node <ip>] [--keep-address] | off] [--json]
|
|
18076
18290
|
agental template ssh <template> [on | off] [--json]
|
|
18077
18291
|
agental template ssh-keys <template> [<public-key-or-file>... | --remove <key-id>] [--json]
|
|
18078
18292
|
agental template tags <template> [add|rm <tag>...] [--json]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agental",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "The agental command: Linux sandboxes for your agents, from the terminal. npx agental@latest signs you in and installs the agent skills.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "VERTIXER LTD",
|