agental 0.57.0 → 0.59.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 +48 -11
  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.57.0" : "dev";
7414
+ var CLI_VERSION = true ? "0.59.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}`;
@@ -9790,6 +9790,7 @@ var COMMANDS = [
9790
9790
  ["--json", "print the API's answer as JSON"]
9791
9791
  ]
9792
9792
  },
9793
+ { name: "insights", summary: "See what needs your attention now, and where to put it right: a CI pool too small, a webhook failing, credits running low." },
9793
9794
  { name: "webhooks", summary: "List the addresses your account's events are sent to." },
9794
9795
  { name: "webhook", summary: "Add, change, turn off and remove the addresses your account's events are sent to.", examples: ["agental webhook add https://example.com/agental --all"] },
9795
9796
  { name: "servers", summary: "List your organization's own servers, and say whether new sandboxes go to agental's when they are full.", examples: ["agental servers", "agental servers offload on --over 80"] },
@@ -12708,6 +12709,31 @@ async function readings(client, found, options) {
12708
12709
  }
12709
12710
  }
12710
12711
 
12712
+ // ../src/cli-insights.ts
12713
+ var AREAS = { ci_runners: "CI runners", webhooks: "Webhooks", billing: "Billing" };
12714
+ async function listInsights(client, asJson) {
12715
+ const response = await client.request("/v1/insights", { method: "GET" });
12716
+ const body = await response.json().catch(() => null);
12717
+ if (!response.ok) {
12718
+ client.fail(response.status, body);
12719
+ }
12720
+ if (asJson) {
12721
+ process.stdout.write(`${JSON.stringify(body, null, 2)}
12722
+ `);
12723
+ return;
12724
+ }
12725
+ const insights = Array.isArray(body?.insights) ? body.insights : [];
12726
+ if (insights.length === 0) {
12727
+ process.stdout.write("Nothing needs your attention.\n");
12728
+ return;
12729
+ }
12730
+ const blocks = insights.map(
12731
+ (insight) => [`\u25CF ${AREAS[insight.area] ?? insight.area} \xB7 ${insight.subject.name}`, ` ${insight.title}`, ` ${insight.detail}`, ` ${insight.action.label}: ${insight.action.url}`].join("\n")
12732
+ );
12733
+ process.stdout.write(`${blocks.join("\n\n")}
12734
+ `);
12735
+ }
12736
+
12711
12737
  // ../src/event-kinds.ts
12712
12738
  var LIFECYCLE_EVENTS = [
12713
12739
  "sandbox.created",
@@ -12738,7 +12764,8 @@ var HEADROOM_EVENTS = [
12738
12764
  ];
12739
12765
  var JOB_EVENTS = ["job.created", "job.updated", "job.deleted", "job.run_started", "job.run_finished", "job.run_failed", "job.recovered", "job.paused"];
12740
12766
  var TAILSCALE_EVENTS = ["tailscale.node_down", "tailscale.disconnected"];
12741
- var WEBHOOK_KINDS = [...WEBHOOK_EVENTS, ...EMAIL_EVENTS, ...MEMBER_EVENTS, ...TEMPLATE_EVENTS, ...HEADROOM_EVENTS, ...JOB_EVENTS, ...TAILSCALE_EVENTS];
12767
+ var GUILD_EVENTS = ["guild.message", "guild.request_open", "guild.member_joined", "guild.member_left", "guild.paused", "guild.resumed"];
12768
+ var WEBHOOK_KINDS = [...WEBHOOK_EVENTS, ...EMAIL_EVENTS, ...MEMBER_EVENTS, ...TEMPLATE_EVENTS, ...HEADROOM_EVENTS, ...JOB_EVENTS, ...TAILSCALE_EVENTS, ...GUILD_EVENTS];
12742
12769
  var WEBHOOK_GROUPS = [...new Set(WEBHOOK_KINDS.map((kind) => kind.slice(0, kind.indexOf("."))))];
12743
12770
  function closestEvent(asked2) {
12744
12771
  if (asked2.length > 64) {
@@ -15817,7 +15844,7 @@ async function main() {
15817
15844
  await telemetry(positionals.slice(1), values.header, values.json);
15818
15845
  return;
15819
15846
  case "ci":
15820
- await ci(positionals.slice(1), { pool: values.pool, template: once(values.template, "--template"), limit: values.limit, json: values.json });
15847
+ await ci(positionals.slice(1), { pool: values.pool, template: once(values.template, "--template"), size: values.size, limit: values.limit, json: values.json });
15821
15848
  return;
15822
15849
  case "data-retention":
15823
15850
  await dataRetention(positionals.slice(1), values.json);
@@ -15840,6 +15867,9 @@ async function main() {
15840
15867
  await command2({ request, fail }, positionals.slice(1, positionals.length - (argv?.length ?? 0)), argv, values);
15841
15868
  return;
15842
15869
  }
15870
+ case "insights":
15871
+ await listInsights({ request, fail }, values.json === true);
15872
+ return;
15843
15873
  case "webhooks":
15844
15874
  await listWebhooks({ request, fail }, values.json);
15845
15875
  return;
@@ -17726,12 +17756,12 @@ async function dataRetention(positionals, asJson) {
17726
17756
  }
17727
17757
  async function ci(positionals, options) {
17728
17758
  const [what, repo, ...rest] = positionals;
17729
- const usage = "ci takes nothing, jobs [<owner/repo>] [--limit <n>], set <owner/repo> [--pool <n> | --pool default] [--template <template> | --template default], or reset <owner/repo>";
17759
+ const usage = "ci takes nothing, jobs [<owner/repo>] [--limit <n>], set <owner/repo> [--size tiny|small|medium|large | --size default] [--pool <n> | --pool default] [--template <template> | --template default], or reset <owner/repo>";
17730
17760
  if (rest.length > 0 || what === void 0 && repo !== void 0 || what !== void 0 && what !== "set" && what !== "reset" && what !== "jobs") {
17731
17761
  throw new Error(usage);
17732
17762
  }
17733
- if (what !== "set" && (options.pool !== void 0 || options.template !== void 0)) {
17734
- throw new Error("--pool and --template are for ci set.");
17763
+ if (what !== "set" && (options.pool !== void 0 || options.template !== void 0 || options.size !== void 0)) {
17764
+ throw new Error("--size, --pool and --template are for ci set.");
17735
17765
  }
17736
17766
  if (what !== "jobs" && options.limit !== void 0) {
17737
17767
  throw new Error("--limit is for ci jobs.");
@@ -17801,21 +17831,28 @@ async function ci(positionals, options) {
17801
17831
  let poolMax = before?.poolMax ?? null;
17802
17832
  if (options.pool !== void 0) {
17803
17833
  poolMax = options.pool === "default" ? null : Number(options.pool);
17804
- if (poolMax !== null && (!Number.isInteger(poolMax) || poolMax < 1 || poolMax > 50)) {
17805
- throw new Error("--pool is 1 to 50 sandboxes of each size, or default.");
17834
+ if (poolMax !== null && (!Number.isInteger(poolMax) || poolMax < 1 || poolMax > 100)) {
17835
+ throw new Error("--pool is 1 to 100 sandboxes of each size, or default.");
17836
+ }
17837
+ }
17838
+ let size2;
17839
+ if (options.size !== void 0) {
17840
+ size2 = options.size === "default" ? null : options.size;
17841
+ if (size2 !== null && !["tiny", "small", "medium", "large"].includes(size2)) {
17842
+ throw new Error("--size is tiny, small, medium or large, or default.");
17806
17843
  }
17807
17844
  }
17808
17845
  let templateId = before?.templateId ?? null;
17809
17846
  if (options.template !== void 0) {
17810
17847
  templateId = options.template === "default" ? null : (await templateNamed(options.template)).id;
17811
17848
  }
17812
- const saved = await asked(path6, { method: "PUT", body: JSON.stringify({ poolMax, templateId }) });
17849
+ const saved = await asked(path6, { method: "PUT", body: JSON.stringify({ poolMax, templateId, ...size2 === void 0 ? {} : { size: size2 } }) });
17813
17850
  if (options.json) {
17814
17851
  process.stdout.write(`${JSON.stringify(saved, null, 2)}
17815
17852
  `);
17816
17853
  return;
17817
17854
  }
17818
- process.stdout.write(`${repo}: pool ${poolMax ?? "default"}, template ${templateId ?? "runs-on (empty)"}. Sandboxes made from now on take it; a fork's job always gets the empty template.
17855
+ process.stdout.write(`${repo}: runs-on: agental is ${saved.size ?? "medium"}${saved.sizeSet ? "" : " (default)"}, pool ${poolMax ?? "default"}, template ${templateId ?? "runs-on (empty)"}. Sandboxes made from now on take it; a fork's job always gets the empty template.
17819
17856
  `);
17820
17857
  }
17821
17858
  function ciWaitWords(reason2) {
@@ -18861,7 +18898,7 @@ Usage
18861
18898
  agental metrics <sandbox-id> [--since <date-time>] [--until <date-time>] [--step <seconds>] [--json]
18862
18899
  agental metrics --running [--since <date-time>] [--until <date-time>] [--step <seconds>] [--json]
18863
18900
  agental telemetry [set <endpoint> [-H <name>=<value>]... | test | unset] [--json]
18864
- agental ci [jobs [<owner/repo>] [--limit <n>] | set <owner/repo> [--pool <n> | --pool default] [--template <template> | --template default] | reset <owner/repo>] [--json]
18901
+ agental ci [jobs [<owner/repo>] [--limit <n>] | set <owner/repo> [--size tiny|small|medium|large | --size default] [--pool <n> | --pool default] [--template <template> | --template default] | reset <owner/repo>] [--json]
18865
18902
  agental data-retention [1 | 7 | 30 | 90 | never] [--json]
18866
18903
  agental jobs [--sandbox <sandbox-id> | --template <template>] [--json]
18867
18904
  agental job add [<name>] --sandbox <sandbox-id> [--every 1m|15m|1h|1d | --cron "<m h dom mon dow>" [--tz <zone>] | --at <date-time>] [--timeout <time>]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agental",
3
- "version": "0.57.0",
3
+ "version": "0.59.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",