agental 0.28.0 → 0.30.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 +197 -30
- 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.30.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}`;
|
|
@@ -8283,10 +8283,10 @@ async function whoIs(base, key2) {
|
|
|
8283
8283
|
throw error;
|
|
8284
8284
|
}
|
|
8285
8285
|
}
|
|
8286
|
-
async function pushRequest(base,
|
|
8286
|
+
async function pushRequest(base, ask10) {
|
|
8287
8287
|
let made;
|
|
8288
8288
|
try {
|
|
8289
|
-
made = await call(base, "POST", "/v1/cli-sign-ins",
|
|
8289
|
+
made = await call(base, "POST", "/v1/cli-sign-ins", ask10);
|
|
8290
8290
|
} catch (error) {
|
|
8291
8291
|
if (error instanceof Refused && (error.status === 401 || error.status === 404)) {
|
|
8292
8292
|
throw new Error(`${base} does not sign the command in through the browser. Make a key in its console, under API keys, and run agental login --key.`);
|
|
@@ -8901,27 +8901,27 @@ function codingAgentHere(env = process.env) {
|
|
|
8901
8901
|
...[env["CLAUDE_CONFIG_DIR"], env["CODEX_HOME"]].filter((folder) => Boolean(folder?.trim()))
|
|
8902
8902
|
].some((folder) => existsSync2(folder));
|
|
8903
8903
|
}
|
|
8904
|
-
async function ensureSkills(options,
|
|
8904
|
+
async function ensureSkills(options, site2) {
|
|
8905
8905
|
if (!options.installSkills) {
|
|
8906
8906
|
return null;
|
|
8907
8907
|
}
|
|
8908
8908
|
if (!codingAgentHere()) {
|
|
8909
|
-
return `${dim("no coding agent found on this computer, so no agent skills installed \xB7 once there is one:")} npx skills add ${
|
|
8909
|
+
return `${dim("no coding agent found on this computer, so no agent skills installed \xB7 once there is one:")} npx skills add ${site2} -g`;
|
|
8910
8910
|
}
|
|
8911
8911
|
const env = Object.fromEntries(Object.entries(process.env).filter(([name]) => !/^npm_(config_package|config_call|command|execpath|lifecycle_)/i.test(name)));
|
|
8912
8912
|
const ran = await new Promise((resolve) => {
|
|
8913
8913
|
execFile(
|
|
8914
8914
|
process.platform === "win32" ? "npx.cmd" : "npx",
|
|
8915
|
-
["--yes", `--package=${SKILLS_CLI}`, "--", "skills", "add",
|
|
8915
|
+
["--yes", `--package=${SKILLS_CLI}`, "--", "skills", "add", site2, "-g", "-y"],
|
|
8916
8916
|
{ encoding: "utf8", timeout: 5 * 6e4, shell: process.platform === "win32", env },
|
|
8917
8917
|
(error, stdout, stderr) => resolve({ ok: !error, out: `${stdout}${stderr}`.trim() })
|
|
8918
8918
|
);
|
|
8919
8919
|
});
|
|
8920
8920
|
if (!ran.ok) {
|
|
8921
8921
|
const last = ran.out.split("\n").filter((line) => line.trim()).pop() ?? "it failed";
|
|
8922
|
-
return `${bold("!")} The agent skills were not installed (${last.slice(0, 160)}). Run ${bold(`npx skills add ${
|
|
8922
|
+
return `${bold("!")} The agent skills were not installed (${last.slice(0, 160)}). Run ${bold(`npx skills add ${site2} -g`)} to install them.`;
|
|
8923
8923
|
}
|
|
8924
|
-
return done(`agent skills installed for the coding agents on this computer ${dim(`\xB7 again with npx skills add ${
|
|
8924
|
+
return done(`agent skills installed for the coding agents on this computer ${dim(`\xB7 again with npx skills add ${site2} -g`)}`);
|
|
8925
8925
|
}
|
|
8926
8926
|
function ordered(sandboxes2) {
|
|
8927
8927
|
return sandboxes2.filter((sandbox) => sandbox["status"] !== "deleted").sort((a, b) => Number(b["status"] === "running") - Number(a["status"] === "running") || String(b["createdAt"]).localeCompare(String(a["createdAt"])));
|
|
@@ -9091,8 +9091,8 @@ async function onboard(base, options) {
|
|
|
9091
9091
|
account3 = credentials.account;
|
|
9092
9092
|
term.say(` ${dim("signed in as")} ${bold(describe2(account3))} ${dim(`\xB7 with the key ${credentials.keyName ?? "pasted in"} \xB7 not you?`)} agental logout`);
|
|
9093
9093
|
}
|
|
9094
|
-
const
|
|
9095
|
-
const installs = (async () => [await ensureCommand(options), await ensureSkills(options,
|
|
9094
|
+
const site2 = new URL(base).origin;
|
|
9095
|
+
const installs = (async () => [await ensureCommand(options), await ensureSkills(options, site2)])();
|
|
9096
9096
|
const report = async () => {
|
|
9097
9097
|
for (const line of await installs) {
|
|
9098
9098
|
if (line) {
|
|
@@ -9263,6 +9263,12 @@ var COMMANDS = [
|
|
|
9263
9263
|
{ name: "ssh-connect", summary: "Reach a sandbox for ssh: what the Host block ssh-config prints runs. It is not typed by hand." },
|
|
9264
9264
|
{ name: "ssh-keys", summary: "List or remove the SSH keys a sandbox lets in." },
|
|
9265
9265
|
{ name: "ssh-off", summary: "Turn SSH off for a sandbox and close its port." },
|
|
9266
|
+
{
|
|
9267
|
+
name: "site",
|
|
9268
|
+
summary: "List, add and remove a sandbox's sites: public links to its ports that anyone can open while it runs.",
|
|
9269
|
+
examples: ["agental site sbx_2a9a47e50daec64a", "agental site add sbx_2a9a47e50daec64a 3000", "agental site rm sbx_2a9a47e50daec64a rte_0123456789abcdef"],
|
|
9270
|
+
flags: [["--json", "list, add: print as JSON"]]
|
|
9271
|
+
},
|
|
9266
9272
|
{
|
|
9267
9273
|
name: "start",
|
|
9268
9274
|
summary: "Start a stopped sandbox, or every one --where finds.",
|
|
@@ -9427,7 +9433,7 @@ var COMMANDS = [
|
|
|
9427
9433
|
{ name: "org", summary: "List, switch and make the accounts you belong to." },
|
|
9428
9434
|
{ name: "members", summary: "List or remove the members of a team." },
|
|
9429
9435
|
{ name: "invite", summary: "Invite someone to your team by email." },
|
|
9430
|
-
{ name: "billing", summary: "Your plan, credits, invoices and card, and buying credits.", examples: ["agental billing", "agental billing
|
|
9436
|
+
{ name: "billing", summary: "Your plan, credits, invoices and card, and buying credits.", examples: ["agental billing", "agental billing compare", "agental billing invoices", "agental billing top-up 500"] },
|
|
9431
9437
|
{ name: "headroom", summary: "How close you run to your plan's limits, and your burst budget." },
|
|
9432
9438
|
{ name: "account", summary: "Export everything agental keeps about your account and you." },
|
|
9433
9439
|
{ name: "login", summary: "Sign in through the browser, or with a key from standard input." },
|
|
@@ -9516,6 +9522,7 @@ var MAP = [
|
|
|
9516
9522
|
["resize", "a larger size, now or at its next start"],
|
|
9517
9523
|
["job", "run a command on a timer"],
|
|
9518
9524
|
["secret", "values and files kept out of the sandbox"],
|
|
9525
|
+
["site", "share a port on a public link"],
|
|
9519
9526
|
["network, egress", "what it may reach, and the address it leaves from"],
|
|
9520
9527
|
["tag, meta, summary", "label sandboxes and find them again"],
|
|
9521
9528
|
["metrics", "CPU, memory and disk over time"],
|
|
@@ -9961,7 +9968,7 @@ async function jobs(api2) {
|
|
|
9961
9968
|
});
|
|
9962
9969
|
}
|
|
9963
9970
|
var KEPT_MS = 3e4;
|
|
9964
|
-
async function cached(what, as,
|
|
9971
|
+
async function cached(what, as, ask10) {
|
|
9965
9972
|
const folder = path4.join(process.env["XDG_CACHE_HOME"] || path4.join(os5.homedir(), ".cache"), "agental");
|
|
9966
9973
|
const file = path4.join(folder, `complete-${what}-${createHash2("sha256").update(as).digest("hex").slice(0, 16)}.json`);
|
|
9967
9974
|
try {
|
|
@@ -9973,7 +9980,7 @@ async function cached(what, as, ask9) {
|
|
|
9973
9980
|
}
|
|
9974
9981
|
let body = null;
|
|
9975
9982
|
try {
|
|
9976
|
-
body = await
|
|
9983
|
+
body = await ask10();
|
|
9977
9984
|
} catch {
|
|
9978
9985
|
return null;
|
|
9979
9986
|
}
|
|
@@ -11618,11 +11625,119 @@ function needId(id, what) {
|
|
|
11618
11625
|
return id;
|
|
11619
11626
|
}
|
|
11620
11627
|
|
|
11628
|
+
// ../src/cli-sites.ts
|
|
11629
|
+
var USAGE6 = "site takes a sandbox, or list, add or rm, then the sandbox. agental site --help shows each.";
|
|
11630
|
+
async function ask8(client, method, pathname, body) {
|
|
11631
|
+
const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
|
|
11632
|
+
let answered = null;
|
|
11633
|
+
try {
|
|
11634
|
+
answered = await response.json();
|
|
11635
|
+
} catch {
|
|
11636
|
+
answered = null;
|
|
11637
|
+
}
|
|
11638
|
+
if (!response.ok) {
|
|
11639
|
+
client.fail(response.status, answered);
|
|
11640
|
+
}
|
|
11641
|
+
return answered;
|
|
11642
|
+
}
|
|
11643
|
+
function routeOf(body) {
|
|
11644
|
+
if (!body || typeof body !== "object" || typeof body.id !== "string") {
|
|
11645
|
+
throw new Error("The answer was not a host route.");
|
|
11646
|
+
}
|
|
11647
|
+
return body;
|
|
11648
|
+
}
|
|
11649
|
+
var isSite = (route) => route.public && !route.hidden;
|
|
11650
|
+
async function sitesOf(client, sandbox) {
|
|
11651
|
+
const body = await ask8(client, "GET", `/v1/sandboxes/${encodeURIComponent(sandbox)}/host`);
|
|
11652
|
+
return (Array.isArray(body?.routes) ? body.routes : []).map(routeOf).filter(isSite);
|
|
11653
|
+
}
|
|
11654
|
+
function stateOf2(route) {
|
|
11655
|
+
if (route.proxy !== "available") {
|
|
11656
|
+
return "not reachable: is the sandbox running?";
|
|
11657
|
+
}
|
|
11658
|
+
return route.listening ? "live" : `nothing listening on ${route.port}`;
|
|
11659
|
+
}
|
|
11660
|
+
function portFrom(given) {
|
|
11661
|
+
const port = Number(given);
|
|
11662
|
+
if (given === void 0 || !/^\d+$/.test(given) || port < 1 || port > 65535) {
|
|
11663
|
+
throw new Error(`site add needs the port a server listens on in the sandbox, 1 to 65535, as agental site add <sandbox-id> 3000${given === void 0 ? "" : `. It was given ${given}`}.`);
|
|
11664
|
+
}
|
|
11665
|
+
return port;
|
|
11666
|
+
}
|
|
11667
|
+
async function site(client, positionals, options) {
|
|
11668
|
+
const verb = positionals[0] === "list" || positionals[0] === "add" || positionals[0] === "rm" ? positionals[0] : null;
|
|
11669
|
+
const [sandbox, target, ...rest] = verb === null ? positionals : positionals.slice(1);
|
|
11670
|
+
if (sandbox === void 0) {
|
|
11671
|
+
throw new Error(USAGE6);
|
|
11672
|
+
}
|
|
11673
|
+
switch (verb) {
|
|
11674
|
+
case null:
|
|
11675
|
+
case "list": {
|
|
11676
|
+
if (target !== void 0) {
|
|
11677
|
+
throw new Error(USAGE6);
|
|
11678
|
+
}
|
|
11679
|
+
const sites = await sitesOf(client, sandbox);
|
|
11680
|
+
if (options.json) {
|
|
11681
|
+
process.stdout.write(`${JSON.stringify({ sites }, null, 2)}
|
|
11682
|
+
`);
|
|
11683
|
+
return;
|
|
11684
|
+
}
|
|
11685
|
+
if (sites.length === 0) {
|
|
11686
|
+
process.stdout.write(`${sandbox} has no sites. agental site add ${sandbox} <port> gives a port a public link.
|
|
11687
|
+
`);
|
|
11688
|
+
return;
|
|
11689
|
+
}
|
|
11690
|
+
const rows = [["ID", "ADDRESS", "PORT", "STATE"], ...sites.map((route) => [route.id, route.url ?? "no public address here", String(route.port), stateOf2(route)])];
|
|
11691
|
+
const terminal2 = isTerminal(process.stdout);
|
|
11692
|
+
process.stdout.write(fitted(rows, { ...terminal2 ? { give: 1 } : { width: Number.MAX_SAFE_INTEGER }, paint: (cell, row) => row === 0 ? faint(cell) : cell }));
|
|
11693
|
+
return;
|
|
11694
|
+
}
|
|
11695
|
+
case "add": {
|
|
11696
|
+
if (rest.length > 0) {
|
|
11697
|
+
throw new Error(USAGE6);
|
|
11698
|
+
}
|
|
11699
|
+
const port = portFrom(target);
|
|
11700
|
+
const made = routeOf(await ask8(client, "POST", `/v1/sandboxes/${encodeURIComponent(sandbox)}/host`, { port, title: `port-${port}`, public: true }));
|
|
11701
|
+
if (options.json) {
|
|
11702
|
+
process.stdout.write(`${JSON.stringify(made, null, 2)}
|
|
11703
|
+
`);
|
|
11704
|
+
return;
|
|
11705
|
+
}
|
|
11706
|
+
if (made.url === null) {
|
|
11707
|
+
process.stdout.write(`${made.id}
|
|
11708
|
+
`);
|
|
11709
|
+
process.stderr.write("Public links are not switched on here, so this port has none. It is reached through the API with a key, at its proxyPath (--json shows it).\n");
|
|
11710
|
+
return;
|
|
11711
|
+
}
|
|
11712
|
+
process.stdout.write(`${made.url}
|
|
11713
|
+
`);
|
|
11714
|
+
process.stderr.write(
|
|
11715
|
+
`Anyone with the link can open port ${port} while the sandbox runs. The server must listen on 0.0.0.0. agental site rm ${sandbox} ${made.id} takes it away.
|
|
11716
|
+
`
|
|
11717
|
+
);
|
|
11718
|
+
return;
|
|
11719
|
+
}
|
|
11720
|
+
case "rm": {
|
|
11721
|
+
if (target === void 0 || rest.length > 0) {
|
|
11722
|
+
throw new Error(`site rm needs the sandbox and the site's id, as agental site ${sandbox} lists them.`);
|
|
11723
|
+
}
|
|
11724
|
+
const found = (await sitesOf(client, sandbox)).find((route) => route.id === target);
|
|
11725
|
+
if (!found) {
|
|
11726
|
+
throw new Error(`${sandbox} has no site ${target}. agental site ${sandbox} lists its sites.`);
|
|
11727
|
+
}
|
|
11728
|
+
await ask8(client, "POST", `/v1/host-routes/${encodeURIComponent(target)}/hide`);
|
|
11729
|
+
process.stdout.write(`Removed. ${found.url ?? `Port ${found.port}`} stops working now; adding port ${found.port} again gives a new link.
|
|
11730
|
+
`);
|
|
11731
|
+
return;
|
|
11732
|
+
}
|
|
11733
|
+
}
|
|
11734
|
+
}
|
|
11735
|
+
|
|
11621
11736
|
// ../src/cli-claude.ts
|
|
11622
|
-
var
|
|
11737
|
+
var USAGE7 = "claude takes connect, show, update or disconnect. agental claude --help shows each.";
|
|
11623
11738
|
var KEY_VARIABLE = "ANTHROPIC_ENVIRONMENT_KEY";
|
|
11624
11739
|
var SECRET_VARIABLE = "ANTHROPIC_WEBHOOK_SIGNING_KEY";
|
|
11625
|
-
async function
|
|
11740
|
+
async function ask9(client, method, pathname, body) {
|
|
11626
11741
|
const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
|
|
11627
11742
|
let answered = null;
|
|
11628
11743
|
if (response.status !== 204) {
|
|
@@ -11712,7 +11827,7 @@ async function hidden(question) {
|
|
|
11712
11827
|
});
|
|
11713
11828
|
}
|
|
11714
11829
|
async function listClaude(client, asJson) {
|
|
11715
|
-
const body = await
|
|
11830
|
+
const body = await ask9(client, "GET", "/v1/claude/connections");
|
|
11716
11831
|
if (asJson) {
|
|
11717
11832
|
process.stdout.write(`${JSON.stringify(body, null, 2)}
|
|
11718
11833
|
`);
|
|
@@ -11734,7 +11849,7 @@ async function listClaude(client, asJson) {
|
|
|
11734
11849
|
async function claude(client, positionals, options) {
|
|
11735
11850
|
const [what, target, ...rest] = positionals;
|
|
11736
11851
|
if (rest.length > 0) {
|
|
11737
|
-
throw new Error(
|
|
11852
|
+
throw new Error(USAGE7);
|
|
11738
11853
|
}
|
|
11739
11854
|
switch (what) {
|
|
11740
11855
|
case "connect": {
|
|
@@ -11746,7 +11861,7 @@ async function claude(client, positionals, options) {
|
|
|
11746
11861
|
const environmentKey = await secretFrom(KEY_VARIABLE, "environment key", true);
|
|
11747
11862
|
const webhookSecret = await secretFrom(SECRET_VARIABLE, "webhook signing secret", false);
|
|
11748
11863
|
const made = connectionOf(
|
|
11749
|
-
await
|
|
11864
|
+
await ask9(client, "POST", "/v1/claude/connections", {
|
|
11750
11865
|
environmentId: target,
|
|
11751
11866
|
environmentKey,
|
|
11752
11867
|
...webhookSecret !== void 0 ? { webhookSecret } : {},
|
|
@@ -11768,7 +11883,7 @@ async function claude(client, positionals, options) {
|
|
|
11768
11883
|
return;
|
|
11769
11884
|
}
|
|
11770
11885
|
case "show": {
|
|
11771
|
-
const found = connectionOf(await
|
|
11886
|
+
const found = connectionOf(await ask9(client, "GET", `/v1/claude/connections/${encodeURIComponent(needId2(target, "show"))}`));
|
|
11772
11887
|
process.stdout.write(options.json ? `${JSON.stringify(found, null, 2)}
|
|
11773
11888
|
` : describe4(found));
|
|
11774
11889
|
return;
|
|
@@ -11791,18 +11906,18 @@ async function claude(client, positionals, options) {
|
|
|
11791
11906
|
if (Object.keys(patch).length === 0) {
|
|
11792
11907
|
throw new Error("claude update changes --template, --keep-days, --new-key, --webhook-secret or --no-webhook-secret, and was given none of them.");
|
|
11793
11908
|
}
|
|
11794
|
-
const updated = connectionOf(await
|
|
11909
|
+
const updated = connectionOf(await ask9(client, "PATCH", `/v1/claude/connections/${encodeURIComponent(id)}`, patch));
|
|
11795
11910
|
process.stdout.write(options.json ? `${JSON.stringify(updated, null, 2)}
|
|
11796
11911
|
` : describe4(updated));
|
|
11797
11912
|
return;
|
|
11798
11913
|
}
|
|
11799
11914
|
case "disconnect": {
|
|
11800
|
-
await
|
|
11915
|
+
await ask9(client, "DELETE", `/v1/claude/connections/${encodeURIComponent(needId2(target, "disconnect"))}`);
|
|
11801
11916
|
process.stdout.write("Disconnected: its key and signing secret are forgotten, and no more of its work is claimed. Its sessions' sandboxes are left as they are.\n");
|
|
11802
11917
|
return;
|
|
11803
11918
|
}
|
|
11804
11919
|
default:
|
|
11805
|
-
throw new Error(
|
|
11920
|
+
throw new Error(USAGE7);
|
|
11806
11921
|
}
|
|
11807
11922
|
}
|
|
11808
11923
|
function needId2(id, what) {
|
|
@@ -11890,7 +12005,7 @@ async function shellNamed(client, id, given, flag) {
|
|
|
11890
12005
|
}
|
|
11891
12006
|
throw new Error(`Sandbox ${id} keeps no shell ${given}${listed.length > 0 ? `; it keeps ${listed.map((each) => each.n).join(", ")}` : ""}. agental shell ${id} --list lists them.`);
|
|
11892
12007
|
}
|
|
11893
|
-
function
|
|
12008
|
+
function stateOf3(each) {
|
|
11894
12009
|
if (each.exit) {
|
|
11895
12010
|
return each.exit.signal > 0 ? `ended by signal ${each.exit.signal}` : `exited ${each.exit.code}`;
|
|
11896
12011
|
}
|
|
@@ -11910,7 +12025,7 @@ async function listShells(client, id, json2, stdout) {
|
|
|
11910
12025
|
}
|
|
11911
12026
|
const rows = [
|
|
11912
12027
|
["N", "ID", "RUNNING", "CWD", "ATTACHED", "STARTED"],
|
|
11913
|
-
...listed.map((each) => [String(each.n), each.id,
|
|
12028
|
+
...listed.map((each) => [String(each.n), each.id, stateOf3(each), each.cwd ?? "", each.attached ? "yes" : "no", ago(each.startedAt) ?? each.startedAt])
|
|
11914
12029
|
];
|
|
11915
12030
|
stdout.write(fitted(rows, { give: 2, paint: (cell, row) => row === 0 ? faint(cell, stdout) : cell }));
|
|
11916
12031
|
}
|
|
@@ -11959,16 +12074,16 @@ async function shell(client, id, options = {}, streams = process) {
|
|
|
11959
12074
|
const verifier = randomBytes4(32).toString("base64url");
|
|
11960
12075
|
const challenge = createHash3("sha256").update(verifier).digest("base64url");
|
|
11961
12076
|
const interactive = stdin.isTTY === true && typeof stdin.setRawMode === "function";
|
|
11962
|
-
const
|
|
12077
|
+
const ask10 = async (keep) => await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminal`, {
|
|
11963
12078
|
method: "POST",
|
|
11964
12079
|
body: JSON.stringify({ ...size2, challenge, ...again ? { terminal: again.id } : keep ? { keep: true } : {} })
|
|
11965
12080
|
});
|
|
11966
|
-
let response = await
|
|
12081
|
+
let response = await ask10(interactive);
|
|
11967
12082
|
let body = await response.json().catch(() => null);
|
|
11968
12083
|
if (!again && interactive && response.status === 409 && body?.error?.code === "terminal_unavailable" && /keeps \d+ terminals/.test(String(body.error.message ?? ""))) {
|
|
11969
12084
|
stderr.write(`${String(body.error.message)} This one is not kept.
|
|
11970
12085
|
`);
|
|
11971
|
-
response = await
|
|
12086
|
+
response = await ask10(false);
|
|
11972
12087
|
body = await response.json().catch(() => null);
|
|
11973
12088
|
}
|
|
11974
12089
|
if (!response.ok || typeof body?.ticket !== "string") {
|
|
@@ -12754,6 +12869,9 @@ async function main() {
|
|
|
12754
12869
|
case "browser":
|
|
12755
12870
|
await browser(positionals[1], values.headless, values.headed, values.off, values.status);
|
|
12756
12871
|
return;
|
|
12872
|
+
case "site":
|
|
12873
|
+
await site({ request, fail }, positionals.slice(1), { json: values.json });
|
|
12874
|
+
return;
|
|
12757
12875
|
case "network":
|
|
12758
12876
|
await network(positionals.slice(1), values);
|
|
12759
12877
|
return;
|
|
@@ -14643,9 +14761,9 @@ async function telemetry(positionals, given, asJson) {
|
|
|
14643
14761
|
}
|
|
14644
14762
|
async function billing(positionals, asJson, limit) {
|
|
14645
14763
|
const [what, amount, ...rest] = positionals;
|
|
14646
|
-
const kinds = ["prices", "invoices", "card", "details", "top-up", "auto-reload"];
|
|
14764
|
+
const kinds = ["prices", "compare", "invoices", "card", "details", "top-up", "auto-reload"];
|
|
14647
14765
|
const near = what !== void 0 && !kinds.includes(what) ? nearest(what, kinds) : null;
|
|
14648
|
-
const usage = `${near ? `billing has no ${what}: did you mean billing ${near}? ` : ""}billing takes nothing, prices, invoices, card, card save, details, top-up <dollars>, or auto-reload <dollars | off>`;
|
|
14766
|
+
const usage = `${near ? `billing has no ${what}: did you mean billing ${near}? ` : ""}billing takes nothing, prices, compare, invoices, card, card save, details, top-up <dollars>, or auto-reload <dollars | off>`;
|
|
14649
14767
|
if (rest.length > 0 || what !== "top-up" && what !== "auto-reload" && !(what === "card" && amount === "save") && amount !== void 0) {
|
|
14650
14768
|
throw new Error(usage);
|
|
14651
14769
|
}
|
|
@@ -14664,6 +14782,11 @@ async function billing(positionals, asJson, limit) {
|
|
|
14664
14782
|
await invoices(asJson, limit);
|
|
14665
14783
|
return;
|
|
14666
14784
|
}
|
|
14785
|
+
case "compare": {
|
|
14786
|
+
const body = await asked("/v1/burst/replay", { method: "GET" });
|
|
14787
|
+
print4(body, () => describePlanReplay(body));
|
|
14788
|
+
return;
|
|
14789
|
+
}
|
|
14667
14790
|
case "details": {
|
|
14668
14791
|
const body = await asked("/v1/billing/details", { method: "GET" });
|
|
14669
14792
|
print4(body, () => describeDetails(body.details));
|
|
@@ -14733,6 +14856,40 @@ function wholeOrCents(micros) {
|
|
|
14733
14856
|
function money(micros) {
|
|
14734
14857
|
return `$${(micros / 1e6).toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
14735
14858
|
}
|
|
14859
|
+
var REPLAY_WHY = {
|
|
14860
|
+
size: "it does not make a size you ran",
|
|
14861
|
+
running_count: "more ran at once than it allows",
|
|
14862
|
+
members: "your members started sandboxes, and it takes none",
|
|
14863
|
+
budget: "its burst fees would have passed your budget",
|
|
14864
|
+
refused: "creates or starts were refused that month, so what they would have used is not known"
|
|
14865
|
+
};
|
|
14866
|
+
function describePlanReplay(body) {
|
|
14867
|
+
if (body.period === null) {
|
|
14868
|
+
return "No full month to compare yet: the account is younger than a month, or its current month began mid-month.\n";
|
|
14869
|
+
}
|
|
14870
|
+
const lastDay = new Date(Date.parse(body.period.end) - 1).toISOString();
|
|
14871
|
+
const month = `The month from ${dayOf(body.period.start)} to ${dayOf(lastDay)}`;
|
|
14872
|
+
if (body.plans.some((plan2) => plan2.why === "refused")) {
|
|
14873
|
+
return `${month}: creates or starts were refused in it, so what they would have used on another plan is not known, and no plan is priced.
|
|
14874
|
+
`;
|
|
14875
|
+
}
|
|
14876
|
+
const lines = [`${month}, on each plan (before tax):`];
|
|
14877
|
+
const yours = body.plans.find((plan2) => plan2.planId === body.yours);
|
|
14878
|
+
const inOrder = [...yours ? [yours] : [], ...body.plans.filter((plan2) => plan2 !== yours)];
|
|
14879
|
+
for (const plan2 of inOrder) {
|
|
14880
|
+
const name = PLAN_NAMES[plan2.planId] ?? plan2.planId;
|
|
14881
|
+
const mark = plan2.planId === body.yours ? " (yours, as charged)" : "";
|
|
14882
|
+
if (plan2.outcome !== "worked" || plan2.billMicros === null) {
|
|
14883
|
+
lines.push(` ${name}${mark}: no amount: ${REPLAY_WHY[plan2.why ?? ""] ?? plan2.why ?? "not known"}`);
|
|
14884
|
+
continue;
|
|
14885
|
+
}
|
|
14886
|
+
const by = yours?.billMicros !== null && yours?.billMicros !== void 0 && plan2.planId !== body.yours ? plan2.billMicros - yours.billMicros : null;
|
|
14887
|
+
const versus = by === null || Math.abs(by) < 1e6 ? "" : by < 0 ? `, ${money(-by)} less` : `, ${money(by)} more`;
|
|
14888
|
+
lines.push(` ${name}${mark}: ${money(plan2.billMicros)}, burst fees ${money(plan2.burstFeesMicros ?? 0)}${versus}`);
|
|
14889
|
+
}
|
|
14890
|
+
return `${lines.join("\n")}
|
|
14891
|
+
`;
|
|
14892
|
+
}
|
|
14736
14893
|
function wholeMoney(micros) {
|
|
14737
14894
|
return micros % 1e6 === 0 ? `$${(micros / 1e6).toLocaleString("en-US")}` : money(micros);
|
|
14738
14895
|
}
|
|
@@ -15511,7 +15668,7 @@ Usage
|
|
|
15511
15668
|
agental key show <key> [--json]
|
|
15512
15669
|
agental key allow-from <key> (<address-or-range>... | --anywhere) [--json]
|
|
15513
15670
|
agental key delete <key>
|
|
15514
|
-
agental billing [prices | card [save] | details | top-up <dollars> | auto-reload <dollars | off>] [--json]
|
|
15671
|
+
agental billing [prices | compare | card [save] | details | top-up <dollars> | auto-reload <dollars | off>] [--json]
|
|
15515
15672
|
agental billing invoices [--limit <n>] [--json]
|
|
15516
15673
|
agental headroom [--from <day or date-time>] [--to <day or date-time>] [--step 10m|hour|day] [--json]
|
|
15517
15674
|
agental headroom budget <dollars> | budget default [--json]
|
|
@@ -15524,6 +15681,10 @@ ${FILES_USAGE.map((line) => ` ${line}`).join("\n")}
|
|
|
15524
15681
|
agental ssh-config <sandbox-id>
|
|
15525
15682
|
agental ssh-keys <sandbox-id> [--remove <key-id>] [--json]
|
|
15526
15683
|
agental ssh-off <sandbox-id>
|
|
15684
|
+
agental site <sandbox-id> [--json] its sites: public links to its ports
|
|
15685
|
+
agental site list <sandbox-id> [--json]
|
|
15686
|
+
agental site add <sandbox-id> <port> [--json] a public link to a port, printed
|
|
15687
|
+
agental site rm <sandbox-id> <site-id> the link stops working, for good
|
|
15527
15688
|
agental email <sandbox-id> [--json]
|
|
15528
15689
|
agental email on|off <sandbox-id>
|
|
15529
15690
|
agental email list <sandbox-id> [--limit <n>] [--json]
|
|
@@ -15811,6 +15972,12 @@ create --ssh-key lets a key in as the sandbox is made, given as its line or its
|
|
|
15811
15972
|
a template from now on, and template ssh on turns SSH on as each is made, so that ssh reaches
|
|
15812
15973
|
it at once. A sandbox made already keeps what it was given.
|
|
15813
15974
|
ssh-off turns SSH off for a sandbox: its port is closed, which cuts whoever is connected.
|
|
15975
|
+
site lists a sandbox's sites: its ports that have a public link, which anyone with the link can
|
|
15976
|
+
open, with no key, while the sandbox runs. Each shows its id, its address, its port and whether
|
|
15977
|
+
something listens there now. site add gives a port a link and prints it; the server in the
|
|
15978
|
+
sandbox must listen on 0.0.0.0. site rm takes a site away for good: its link stops working at
|
|
15979
|
+
once, and adding the port again gives a new one. They are the API's host routes with public
|
|
15980
|
+
true, and site rm is POST /v1/host-routes/{id}/hide.
|
|
15814
15981
|
email says whether mail is on for a sandbox, and the domain its addresses end in: any name
|
|
15815
15982
|
before the @ of that domain reaches the sandbox. Mail is off until email on turns it on, for
|
|
15816
15983
|
receiving and for sending both, and each message is charged to the account from then on. email
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agental",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.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",
|