agental 0.29.0 → 0.31.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 +51 -10
  2. 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.29.0" : "dev";
7414
+ var CLI_VERSION = true ? "0.31.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}`;
@@ -9433,7 +9433,7 @@ var COMMANDS = [
9433
9433
  { name: "org", summary: "List, switch and make the accounts you belong to." },
9434
9434
  { name: "members", summary: "List or remove the members of a team." },
9435
9435
  { name: "invite", summary: "Invite someone to your team by email." },
9436
- { 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"] },
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"] },
9437
9437
  { name: "headroom", summary: "How close you run to your plan's limits, and your burst budget." },
9438
9438
  { name: "account", summary: "Export everything agental keeps about your account and you." },
9439
9439
  { name: "login", summary: "Sign in through the browser, or with a key from standard input." },
@@ -12984,8 +12984,8 @@ async function create(values) {
12984
12984
  const burstHeaders = maxBurstFeeHeaders(values["max-burst-fee"]);
12985
12985
  const ttlSeconds = ttlOption(values.ttl);
12986
12986
  const onTimeout = values["on-timeout"];
12987
- if (onTimeout !== void 0 && onTimeout !== "delete" && onTimeout !== "stop") {
12988
- throw new Error("--on-timeout is delete or stop: what the sandbox's time limit does when it runs out");
12987
+ if (onTimeout !== void 0 && onTimeout !== "delete" && onTimeout !== "stop" && onTimeout !== "stop-with-memory" && onTimeout !== "stop_with_memory") {
12988
+ throw new Error("--on-timeout is delete, stop or stop-with-memory: what the sandbox's time limit does when it runs out");
12989
12989
  }
12990
12990
  if (values.size !== void 0 && !isMachineSize(values.size)) {
12991
12991
  throw new Error("--size must be tiny, small, medium or large");
@@ -13012,7 +13012,7 @@ async function create(values) {
13012
13012
  ...allow ? { network: { allow } } : {},
13013
13013
  ...egressAsked ? { egress: egressAsked } : {},
13014
13014
  ...ttlSeconds === void 0 ? {} : { ttlSeconds },
13015
- ...onTimeout === void 0 ? {} : { onTimeout },
13015
+ ...onTimeout === void 0 ? {} : { onTimeout: onTimeout.replaceAll("-", "_") },
13016
13016
  ...sshKeys2 === void 0 ? {} : { sshKeys: sshKeys2 },
13017
13017
  ...given
13018
13018
  })
@@ -14761,9 +14761,9 @@ async function telemetry(positionals, given, asJson) {
14761
14761
  }
14762
14762
  async function billing(positionals, asJson, limit) {
14763
14763
  const [what, amount, ...rest] = positionals;
14764
- const kinds = ["prices", "invoices", "card", "details", "top-up", "auto-reload"];
14764
+ const kinds = ["prices", "compare", "invoices", "card", "details", "top-up", "auto-reload"];
14765
14765
  const near = what !== void 0 && !kinds.includes(what) ? nearest(what, kinds) : null;
14766
- 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>`;
14767
14767
  if (rest.length > 0 || what !== "top-up" && what !== "auto-reload" && !(what === "card" && amount === "save") && amount !== void 0) {
14768
14768
  throw new Error(usage);
14769
14769
  }
@@ -14782,6 +14782,11 @@ async function billing(positionals, asJson, limit) {
14782
14782
  await invoices(asJson, limit);
14783
14783
  return;
14784
14784
  }
14785
+ case "compare": {
14786
+ const body = await asked("/v1/burst/replay", { method: "GET" });
14787
+ print4(body, () => describePlanReplay(body));
14788
+ return;
14789
+ }
14785
14790
  case "details": {
14786
14791
  const body = await asked("/v1/billing/details", { method: "GET" });
14787
14792
  print4(body, () => describeDetails(body.details));
@@ -14851,6 +14856,40 @@ function wholeOrCents(micros) {
14851
14856
  function money(micros) {
14852
14857
  return `$${(micros / 1e6).toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
14853
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
+ }
14854
14893
  function wholeMoney(micros) {
14855
14894
  return micros % 1e6 === 0 ? `$${(micros / 1e6).toLocaleString("en-US")}` : money(micros);
14856
14895
  }
@@ -15522,7 +15561,7 @@ Setting up
15522
15561
  agental completion zsh|bash|fish
15523
15562
 
15524
15563
  Usage
15525
- agental create [--name <name>] [--template <template>] [--size tiny|small|medium|large] [--region <region>[,<region>...]] [--ttl <time> | --ttl default] [--on-timeout delete|stop] [--idempotency-key <key>]
15564
+ agental create [--name <name>] [--template <template>] [--size tiny|small|medium|large] [--region <region>[,<region>...]] [--ttl <time> | --ttl default] [--on-timeout delete|stop|stop-with-memory] [--idempotency-key <key>]
15526
15565
  ${operator ? "[--box <name-or-id>] " : ""}[--allow <address>[,<address>...]] [--egress box | residential:<country>[:sticky|rotating]] [--max-burst-fee <dollars>]
15527
15566
  [--ssh-key <public-key-or-file>]... [--tag <tag>[,<tag>...]]... [--meta <key>=<value>]...
15528
15567
  agental summary [--where '<words>'] [--tag <tag>[,<tag>...]]... [--meta <key>=<value>]... [--facets <field>[,<field>...]] [--json]
@@ -15629,7 +15668,7 @@ Usage
15629
15668
  agental key show <key> [--json]
15630
15669
  agental key allow-from <key> (<address-or-range>... | --anywhere) [--json]
15631
15670
  agental key delete <key>
15632
- 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]
15633
15672
  agental billing invoices [--limit <n>] [--json]
15634
15673
  agental headroom [--from <day or date-time>] [--to <day or date-time>] [--step 10m|hour|day] [--json]
15635
15674
  agental headroom budget <dollars> | budget default [--json]
@@ -15698,7 +15737,9 @@ A sandbox runs until it is stopped, unless it has a time limit: then it is stopp
15698
15737
  run that long since its last start. create --ttl and template start --ttl set one, as 45m, 2h or
15699
15738
  1d, and --ttl default takes the deployment's, which is none unless it says otherwise. When the
15700
15739
  time limit runs out the sandbox is deleted, with its disk, unless create --on-timeout stop said to
15701
- stop it and keep its disk; agental stop always keeps the disk. auto-stop
15740
+ stop it and keep its disk, or --on-timeout stop-with-memory to keep its memory too, so its next
15741
+ start carries on where it was (after the account's first top-up: before it, refused with
15742
+ memory_needs_top_up); agental stop always keeps the disk. auto-stop
15702
15743
  says when a running sandbox is to be stopped, with --in or --at moves that stop, later or sooner,
15703
15744
  for the run under way, and with --never takes its time limit away, for this run and the next.
15704
15745
  ${operator ? operator.OPERATOR_HELP : ""}template network says what a sandbox on a template may reach outside itself, and with open,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agental",
3
- "version": "0.29.0",
3
+ "version": "0.31.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",