agental 0.14.1 → 0.15.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.
Files changed (2) hide show
  1. package/dist/cli.js +56 -16
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -39,14 +39,14 @@ var init_cli_operator = __esm({
39
39
 
40
40
  // ../src/cli.ts
41
41
  import { randomUUID as randomUUID2 } from "node:crypto";
42
- import { readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
42
+ import { readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
43
43
  import os6 from "node:os";
44
44
  import { readFile } from "node:fs/promises";
45
45
  import { parseArgs } from "node:util";
46
46
 
47
47
  // ../src/cli-build.ts
48
48
  var PUBLISHED = true;
49
- var CLI_VERSION = true ? "0.14.1" : "dev";
49
+ var CLI_VERSION = true ? "0.15.0" : "dev";
50
50
  var DEFAULT_API_URL = true ? "https://agental.io" : "http://127.0.0.1:8741";
51
51
  var PACKAGE_NAME = "agental";
52
52
  var USER_AGENT = `agental-cli/${CLI_VERSION}`;
@@ -1001,7 +1001,7 @@ async function readAll(stream) {
1001
1001
  // ../src/cli-onboard.ts
1002
1002
  import { execFile, spawnSync as spawnSync3 } from "node:child_process";
1003
1003
  import { randomUUID, randomBytes as randomBytes3 } from "node:crypto";
1004
- import { existsSync as existsSync2, realpathSync, statSync } from "node:fs";
1004
+ import { existsSync as existsSync2, readFileSync as readFileSync3, realpathSync, statSync } from "node:fs";
1005
1005
  import os4 from "node:os";
1006
1006
  import path3 from "node:path";
1007
1007
  import { createInterface } from "node:readline/promises";
@@ -1524,6 +1524,21 @@ async function hourly(base, key2, size) {
1524
1524
  return typeof micros === "number" ? micros : null;
1525
1525
  }
1526
1526
  var perHour = (micros) => `$${(micros / 1e6).toFixed(micros < 1e5 ? 4 : 3)} an hour`;
1527
+ function completionStep(shell2 = process.env["SHELL"], home = os4.homedir()) {
1528
+ const name = path3.basename(shell2 ?? "");
1529
+ const config = name === "zsh" ? ".zshrc" : name === "bash" ? ".bashrc" : name === "fish" ? ".config/fish/config.fish" : null;
1530
+ if (config === null) {
1531
+ return null;
1532
+ }
1533
+ try {
1534
+ if (readFileSync3(path3.join(home, config), "utf8").includes("agental completion")) {
1535
+ return null;
1536
+ }
1537
+ } catch {
1538
+ }
1539
+ const line = name === "fish" ? "agental completion fish | source" : `source <(agental completion ${name})`;
1540
+ return [`echo '${line}' >> ~/${config}`, "Tab completion, from your next terminal"];
1541
+ }
1527
1542
  function nextSteps(term, rows) {
1528
1543
  const width = Math.max(...rows.map(([command2]) => command2.length));
1529
1544
  term.say(`
@@ -1567,11 +1582,13 @@ async function onboard(base, options) {
1567
1582
  };
1568
1583
  if (!options.sandbox) {
1569
1584
  await report();
1585
+ const completion = term.interactive ? completionStep() : null;
1570
1586
  nextSteps(term, [
1571
1587
  ["npx agental@latest sh", "make a sandbox and open a shell in it"],
1572
1588
  ["agental list", "your sandboxes"],
1573
1589
  ["agental ssh <id>", "a shell in one; add a command to run just that"],
1574
- ["agental help", "everything else"]
1590
+ ["agental help", "everything else; agental <command> --help for one"],
1591
+ ...completion ? [completion] : []
1575
1592
  ]);
1576
1593
  return;
1577
1594
  }
@@ -1634,7 +1651,7 @@ async function onboard(base, options) {
1634
1651
 
1635
1652
  // ../src/cli-completion.ts
1636
1653
  import { createHash as createHash2 } from "node:crypto";
1637
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "node:fs";
1654
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
1638
1655
  import os5 from "node:os";
1639
1656
  import path4 from "node:path";
1640
1657
 
@@ -1828,7 +1845,7 @@ var COMMANDS = [
1828
1845
  { name: "org", summary: "List, switch and make the accounts you belong to." },
1829
1846
  { name: "members", summary: "List or remove the members of a team." },
1830
1847
  { name: "invite", summary: "Invite someone to your team by email." },
1831
- { name: "billing", summary: "Your plan, credits, invoices and card, and buying credits.", examples: ["agental billing", "agental billing invoices", "agental billing top-up 500"] },
1848
+ { name: "billing", summary: "Your plan, credits, invoices and card, and buying credits.", examples: ["agental billing", "agental billing invoices", "agental billing details", "agental billing top-up 500"] },
1832
1849
  { name: "headroom", summary: "How close you run to your plan's limits, and your burst budget." },
1833
1850
  { name: "account", summary: "Export everything agental keeps about your account and you." },
1834
1851
  { name: "login", summary: "Sign in through the browser, or with a key from standard input." },
@@ -2165,7 +2182,7 @@ function sandboxIn(words2, valued = []) {
2165
2182
  // ../src/cli-completion.ts
2166
2183
  var SHELLS = ["zsh", "bash", "fish"];
2167
2184
  var SUBCOMMANDS = {
2168
- billing: ["prices", "invoices", "card", "top-up", "auto-reload"],
2185
+ billing: ["prices", "invoices", "card", "details", "top-up", "auto-reload"],
2169
2186
  // Each thing that lists as its plural lists as itself too.
2170
2187
  template: ["list"],
2171
2188
  key: ["list"],
@@ -2335,7 +2352,7 @@ async function cached(what, as, ask8) {
2335
2352
  const folder = path4.join(process.env["XDG_CACHE_HOME"] || path4.join(os5.homedir(), ".cache"), "agental");
2336
2353
  const file = path4.join(folder, `complete-${what}-${createHash2("sha256").update(as).digest("hex").slice(0, 16)}.json`);
2337
2354
  try {
2338
- const kept2 = JSON.parse(readFileSync3(file, "utf8"));
2355
+ const kept2 = JSON.parse(readFileSync4(file, "utf8"));
2339
2356
  if (Date.now() - kept2.at < KEPT_MS) {
2340
2357
  return kept2.body;
2341
2358
  }
@@ -4288,7 +4305,7 @@ function publicKeysFrom(given) {
4288
4305
  const file = each.startsWith("~/") ? `${os6.homedir()}${each.slice(1)}` : each;
4289
4306
  let text;
4290
4307
  try {
4291
- text = readFileSync4(file, "utf8");
4308
+ text = readFileSync5(file, "utf8");
4292
4309
  } catch {
4293
4310
  throw new Error(`${each} is neither a public key nor a file that can be read. Give a key line, as ssh-ed25519 AAAA... you@laptop, or its file, as ~/.ssh/id_ed25519.pub.`);
4294
4311
  }
@@ -4863,7 +4880,7 @@ async function clipboard(id, text) {
4863
4880
  process.stdout.write(String(body.text ?? ""));
4864
4881
  return;
4865
4882
  }
4866
- const given = text === "-" ? readFileSync4(0, "utf8") : text;
4883
+ const given = text === "-" ? readFileSync5(0, "utf8") : text;
4867
4884
  const response = await request(at4, { method: "PUT", body: JSON.stringify({ text: given }) });
4868
4885
  if (!response.ok) {
4869
4886
  fail(response.status, await readBody(response));
@@ -5836,9 +5853,9 @@ async function telemetry(positionals, given, asJson) {
5836
5853
  }
5837
5854
  async function billing(positionals, asJson, limit) {
5838
5855
  const [what, amount, ...rest] = positionals;
5839
- const kinds = ["prices", "invoices", "card", "top-up", "auto-reload"];
5856
+ const kinds = ["prices", "invoices", "card", "details", "top-up", "auto-reload"];
5840
5857
  const near = what !== void 0 && !kinds.includes(what) ? nearest(what, kinds) : null;
5841
- const usage = `${near ? `billing has no ${what}: did you mean billing ${near}? ` : ""}billing takes nothing, prices, invoices, card, card save, top-up <dollars>, or auto-reload <dollars | off>`;
5858
+ 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>`;
5842
5859
  if (rest.length > 0 || what !== "top-up" && what !== "auto-reload" && !(what === "card" && amount === "save") && amount !== void 0) {
5843
5860
  throw new Error(usage);
5844
5861
  }
@@ -5857,6 +5874,11 @@ async function billing(positionals, asJson, limit) {
5857
5874
  await invoices(asJson, limit);
5858
5875
  return;
5859
5876
  }
5877
+ case "details": {
5878
+ const body = await asked("/v1/billing/details", { method: "GET" });
5879
+ print4(body, () => describeDetails(body.details));
5880
+ return;
5881
+ }
5860
5882
  case "prices": {
5861
5883
  const body = await asked("/v1/billing/plans", { method: "GET" });
5862
5884
  print4(body, () => isTerminal(process.stdout) ? pricesForPeople(body) : describePrices(body));
@@ -6019,6 +6041,23 @@ function describeCard(card) {
6019
6041
  const wallet = card.wallet ? `, through ${WALLETS[card.wallet] ?? card.wallet}` : "";
6020
6042
  return `${brand}${ending}${expires}${wallet}. It is changed in the console, under Billing.`;
6021
6043
  }
6044
+ function describeDetails(details) {
6045
+ if (!details) {
6046
+ return "No billing details yet: they are kept once you save a card or pay, and changed in the console, under Billing.\n";
6047
+ }
6048
+ const where = details.address;
6049
+ const address = where ? [where.line1, where.line2, [where.postalCode, where.city].filter(Boolean).join(" "), where.state, where.country].filter((part) => part).join(", ") : "";
6050
+ const lines = [
6051
+ ["Invoices to", details.email ?? "not set"],
6052
+ // With no name, the address is what they are billed to.
6053
+ ["Billed to", details.name ?? (address || "not set")],
6054
+ ...details.name && address ? [["", address]] : [],
6055
+ ...details.taxIds.length > 0 ? details.taxIds.map((id, index) => [index === 0 ? "Tax ID" : "", `${id.value}${id.verification ? ` (${id.verification})` : ""}`]) : [["Tax ID", "not set"]]
6056
+ ];
6057
+ return `${lines.filter(([label, value]) => label !== "" || value !== "").map(([label, value]) => `${label.padEnd(14)}${value}
6058
+ `).join("")}They are changed in the console, under Billing, and the next invoice carries them.
6059
+ `;
6060
+ }
6022
6061
  async function invoices(asJson, limit) {
6023
6062
  if (limit !== void 0 && (!/^\d+$/.test(limit) || Number(limit) < 1 || Number(limit) > 100)) {
6024
6063
  throw new Error("billing invoices --limit takes how many of the newest invoices to list, a whole number from 1 to 100.");
@@ -6649,7 +6688,7 @@ Usage
6649
6688
  agental key show <key> [--json]
6650
6689
  agental key allow-from <key> (<address-or-range>... | --anywhere) [--json]
6651
6690
  agental key delete <key>
6652
- agental billing [prices | card [save] | top-up <dollars> | auto-reload <dollars | off>] [--json]
6691
+ agental billing [prices | card [save] | details | top-up <dollars> | auto-reload <dollars | off>] [--json]
6653
6692
  agental billing invoices [--limit <n>] [--json]
6654
6693
  agental headroom [--from <day or date-time>] [--to <day or date-time>] [--step 10m|hour|day] [--json]
6655
6694
  agental headroom budget <dollars> | budget default [--json]
@@ -6846,10 +6885,11 @@ what is left of the month's credits, what is left of the top-ups, which are used
6846
6885
  after it and do not expire, and the card it pays with. invoices lists the account's invoices,
6847
6886
  newest first, each with its day, number, state, total and what it was for, and where to pay
6848
6887
  one that is not paid yet; --limit lists that many of the newest, and --json gives each one's
6849
- page and PDF to the account's owner. The free plan costs nothing a month and pays for what runs from
6888
+ page and PDF to the account's owner. details says who the invoices are made out to: the email
6889
+ they go to, the name, address and tax ids on them, to the account's owner alone. The free plan costs nothing a month and pays for what runs from
6850
6890
  credits alone; it makes tiny and small sandboxes. prices lists the plans with the sizes each
6851
- makes, the top-ups with their bonus and the hourly price of each size. card prints the address
6852
- of a page to save a card for the free plan: nothing is charged, and once it is saved the account
6891
+ makes, the top-ups with their bonus and the hourly price of each size. card names the card the account
6892
+ pays with, and card save prints the address of a page to save one for the free plan: nothing is charged, and once it is saved the account
6853
6893
  is given $10 of credit, once. Until it buys a top-up it runs 2 small sandboxes at once, then 20.
6854
6894
  top-up <dollars> starts buying credits for
6855
6895
  any whole number of dollars from 15 to 100,000, and prints the address of the page to pay on.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agental",
3
- "version": "0.14.1",
3
+ "version": "0.15.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",