agental 0.43.3 → 0.44.1

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 +65 -15
  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.43.3" : "dev";
7414
+ var CLI_VERSION = true ? "0.44.1" : "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}`;
@@ -10051,7 +10051,7 @@ var SUBCOMMANDS = {
10051
10051
  limits: ["budget"],
10052
10052
  egress: ["budget", "use-case"],
10053
10053
  telemetry: ["set", "test", "unset"],
10054
- ci: ["set", "reset"],
10054
+ ci: ["jobs", "set", "reset"],
10055
10055
  org: ["list", "use", "create"],
10056
10056
  members: ["list", "remove"],
10057
10057
  "bulk-actions": ["list", "show", "cancel"],
@@ -14305,7 +14305,7 @@ async function main() {
14305
14305
  await telemetry(positionals.slice(1), values.header, values.json);
14306
14306
  return;
14307
14307
  case "ci":
14308
- await ci(positionals.slice(1), { pool: values.pool, template: once(values.template, "--template"), json: values.json });
14308
+ await ci(positionals.slice(1), { pool: values.pool, template: once(values.template, "--template"), limit: values.limit, json: values.json });
14309
14309
  return;
14310
14310
  case "data-retention":
14311
14311
  await dataRetention(positionals.slice(1), values.json);
@@ -15726,10 +15726,10 @@ async function template(positionals, values) {
15726
15726
  }
15727
15727
  const listed = listedIn(addresses);
15728
15728
  if (mode !== "allowlist" && addresses.length > 0) {
15729
- throw new Error(`Addresses are for allowlist. With ${mode}, leave them out.`);
15729
+ throw new Error(`Addresses and names are for allowlist. With ${mode}, leave them out.`);
15730
15730
  }
15731
15731
  if (mode === "allowlist" && listed.length === 0) {
15732
- throw new Error(`allowlist needs at least one address, as agental template network ${first ?? ""} allowlist 203.0.113.7 198.51.100.0/24`);
15732
+ throw new Error(`allowlist needs at least one address or name, as agental template network ${first ?? ""} allowlist github.com 203.0.113.7`);
15733
15733
  }
15734
15734
  rule = await call2(path6, { method: "PUT", body: JSON.stringify(mode === "allowlist" ? { outbound: mode, allow: listed } : { outbound: mode }) });
15735
15735
  }
@@ -16115,13 +16115,20 @@ async function dataRetention(positionals, asJson) {
16115
16115
  }
16116
16116
  async function ci(positionals, options) {
16117
16117
  const [what, repo, ...rest] = positionals;
16118
- const usage = "ci takes nothing, set <owner/repo> [--pool <n> | --pool default] [--template <template> | --template default], or reset <owner/repo>";
16119
- if (rest.length > 0 || what === void 0 && repo !== void 0 || what !== void 0 && what !== "set" && what !== "reset") {
16118
+ 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>";
16119
+ if (rest.length > 0 || what === void 0 && repo !== void 0 || what !== void 0 && what !== "set" && what !== "reset" && what !== "jobs") {
16120
16120
  throw new Error(usage);
16121
16121
  }
16122
16122
  if (what !== "set" && (options.pool !== void 0 || options.template !== void 0)) {
16123
16123
  throw new Error("--pool and --template are for ci set.");
16124
16124
  }
16125
+ if (what !== "jobs" && options.limit !== void 0) {
16126
+ throw new Error("--limit is for ci jobs.");
16127
+ }
16128
+ if (what === "jobs") {
16129
+ await ciJobs(repo, options.limit, options.json);
16130
+ return;
16131
+ }
16125
16132
  if (what === void 0) {
16126
16133
  const body = await asked("/v1/runs-on/repositories", { method: "GET" });
16127
16134
  if (options.json) {
@@ -16134,7 +16141,7 @@ async function ci(positionals, options) {
16134
16141
  return;
16135
16142
  }
16136
16143
  if (body.repositories.length === 0) {
16137
- process.stdout.write(`No repository has a pool yet. Connect GitHub in the console (Settings, GitHub), then ask for runs-on: agental (its template's size, medium with none) or agental-<size> in a workflow. Each pool keeps ${body.defaultPoolMax} sandboxes of each size.
16144
+ process.stdout.write(`No repository has a pool yet. Connect GitHub in the console (CI runners), then ask for runs-on: agental (its template's size, medium with none) or agental-<size> in a workflow. Each pool keeps ${body.defaultPoolMax} sandboxes of each size.
16138
16145
  `);
16139
16146
  return;
16140
16147
  }
@@ -16191,6 +16198,42 @@ async function ci(positionals, options) {
16191
16198
  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.
16192
16199
  `);
16193
16200
  }
16201
+ async function ciJobs(repo, limit, asJson) {
16202
+ if (repo !== void 0 && !/^[^/\s]+\/[^/\s]+$/.test(repo)) {
16203
+ throw new Error("ci jobs takes a repository as owner/name, as agental ci jobs acme/app");
16204
+ }
16205
+ const query = new URLSearchParams();
16206
+ if (repo !== void 0) query.set("repository", repo);
16207
+ if (limit !== void 0) {
16208
+ const count = Number(limit);
16209
+ if (!Number.isInteger(count) || count < 1 || count > 500) {
16210
+ throw new Error("--limit is 1 to 500 jobs.");
16211
+ }
16212
+ query.set("limit", String(count));
16213
+ }
16214
+ const body = await asked(`/v1/runs-on/jobs${query.size > 0 ? `?${query}` : ""}`, { method: "GET" });
16215
+ if (asJson) {
16216
+ process.stdout.write(`${JSON.stringify(body, null, 2)}
16217
+ `);
16218
+ return;
16219
+ }
16220
+ if (!body.available) {
16221
+ process.stdout.write("GitHub Actions jobs do not run on sandboxes here.\n");
16222
+ return;
16223
+ }
16224
+ if (body.jobs.length === 0) {
16225
+ process.stdout.write(`No job${repo ? ` of ${repo}` : ""} asked for agental within the history kept. A workflow asks with runs-on: agental.
16226
+ `);
16227
+ return;
16228
+ }
16229
+ for (const job2 of body.jobs) {
16230
+ const title = [job2.workflow, job2.name].filter(Boolean).join(" / ") || `job ${job2.jobId}`;
16231
+ const took = job2.startedAt && job2.endedAt ? `${Math.round((Date.parse(job2.endedAt) - Date.parse(job2.startedAt)) / 1e3)}s` : "";
16232
+ const detail = [job2.repository, job2.branch, job2.size, took, job2.sandboxId, job2.error].filter(Boolean).join(" ");
16233
+ process.stdout.write(`${job2.state.padEnd(9)} ${title} ${detail}
16234
+ `);
16235
+ }
16236
+ }
16194
16237
  async function telemetry(positionals, given, asJson) {
16195
16238
  const [what, endpoint, ...rest] = positionals;
16196
16239
  const usage = "telemetry takes nothing, set <endpoint> [-H name=value]..., test, or unset";
@@ -16758,7 +16801,11 @@ async function showLimits(positionals, options) {
16758
16801
  throw new Error(`--step is 10m, hour or day. It was given ${options.step}.`);
16759
16802
  }
16760
16803
  const query = new URLSearchParams();
16761
- for (const [name, value] of [["from", options.from], ["to", options.to], ["step", options.step]]) {
16804
+ const month = options.from === "month";
16805
+ if (month) {
16806
+ query.set("range", "month");
16807
+ }
16808
+ for (const [name, value] of [["from", month ? void 0 : options.from], ["to", options.to], ["step", options.step]]) {
16762
16809
  if (value !== void 0) {
16763
16810
  query.set(name, name !== "step" && /^\d{4}-\d{2}-\d{2}$/.test(value) ? `${value}T00:00:00Z` : value);
16764
16811
  }
@@ -16801,7 +16848,9 @@ function describeLimits(body, today, endsNow) {
16801
16848
  } else {
16802
16849
  lines.push(`free starts: ${units(number(now, "meterMb"))} of ${number(now, "freeBurstUnits").toLocaleString("en-US")} units used in the last 15 min`);
16803
16850
  }
16804
- lines.push(`fees: ${money(number(now, "spentMicros"))} this month of a ${money(number(now, "budgetMicros"))} budget`);
16851
+ const budgetMonth = now["budgetMonth"] && typeof now["budgetMonth"] === "object" ? now["budgetMonth"] : null;
16852
+ const since = typeof budgetMonth?.start === "string" && budgetMonth.start.slice(8, 10) !== "01" ? ` (since ${shortDayOf(budgetMonth.start)})` : "";
16853
+ lines.push(`fees: ${money(number(now, "spentMicros"))} this month${since} of a ${money(number(now, "budgetMicros"))} budget`);
16805
16854
  const refused = answer3["refused"] && typeof answer3["refused"] === "object" ? answer3["refused"] : {};
16806
16855
  const total = number(refused, "total");
16807
16856
  const byReason = Array.isArray(refused["byReason"]) ? refused["byReason"] : [];
@@ -17110,7 +17159,7 @@ Usage
17110
17159
  agental resize <sandbox-id> tiny|small|medium|large [--now] [--max-burst-fee <dollars>] [--json]
17111
17160
  agental resize <sandbox-id> --cancel [--json] a size that waits for its next start, taken away
17112
17161
  agental auto-stop <sandbox-id> [--in <time> | --at <date-time> | --never] [--json]
17113
- agental network <sandbox-id> [--allow <address>[,<address>...] | --none] [--json]
17162
+ agental network <sandbox-id> [--allow <address-or-name>[,<address-or-name>...] | --none] [--json]
17114
17163
  agental egress <sandbox-id> [box | residential <country> [sticky | rotating]] [--json]
17115
17164
  agental spot <sandbox-id> [off] [--on-reclaim delete|stop] [--warn-at <chance>] [--json]
17116
17165
  agental templates [--json]
@@ -17119,7 +17168,7 @@ Usage
17119
17168
  agental template rename <template> <new-name>
17120
17169
  agental template delete <template> [--pause-jobs]
17121
17170
  agental template start <template> [--size tiny|small|medium|large] [--snapshot <snapshot-id> | --new-machine] [--ttl <time> | --ttl default]
17122
- agental template network <template> [open | blocked | allowlist <address>...] [--json]
17171
+ agental template network <template> [open | blocked | allowlist <address-or-name>...] [--json]
17123
17172
  agental template egress <template> [box | residential <country> [sticky | rotating]] [--json]
17124
17173
  agental template ssh <template> [on | off] [--json]
17125
17174
  agental template ssh-keys <template> [<public-key-or-file>... | --remove <key-id>] [--json]
@@ -17138,7 +17187,7 @@ Usage
17138
17187
  agental metrics <sandbox-id> [--since <date-time>] [--until <date-time>] [--step <seconds>] [--json]
17139
17188
  agental metrics --running [--since <date-time>] [--until <date-time>] [--step <seconds>] [--json]
17140
17189
  agental telemetry [set <endpoint> [-H <name>=<value>]... | test | unset] [--json]
17141
- agental ci [set <owner/repo> [--pool <n> | --pool default] [--template <template> | --template default] | reset <owner/repo>] [--json]
17190
+ agental ci [jobs [<owner/repo>] [--limit <n>] | set <owner/repo> [--pool <n> | --pool default] [--template <template> | --template default] | reset <owner/repo>] [--json]
17142
17191
  agental data-retention [1 | 7 | 30 | 90 | never] [--json]
17143
17192
  agental jobs [--sandbox <sandbox-id> | --template <template>] [--json]
17144
17193
  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>]
@@ -17201,7 +17250,7 @@ Usage
17201
17250
  agental key delete <key>
17202
17251
  agental billing [prices | compare | card [save] | details | top-up <dollars> | auto-reload <dollars | off> | email-copy] [--json]
17203
17252
  agental billing invoices [--limit <n>] [--json]
17204
- agental limits [--from <day or date-time>] [--to <day or date-time>] [--step 10m|hour|day] [--json]
17253
+ agental limits [--from <day, date-time or month>] [--to <day or date-time>] [--step 10m|hour|day] [--json]
17205
17254
  agental limits budget <dollars> | budget default [--json]
17206
17255
  agental egress [budget <dollars> | budget default] [--json]
17207
17256
  agental egress use-case "<what your sandboxes will use it for>" [--json]
@@ -17286,7 +17335,8 @@ hint and not a promise, and with --warn-at sets the chance at which sandbox.recl
17286
17335
  (0.5 when left out); agental spot <sandbox-id> off turns off spot: a standard sandbox from then on.
17287
17336
  ${operator ? operator.OPERATOR_HELP : ""}template network says what a sandbox on a template may reach outside itself, and with open,
17288
17337
  blocked or allowlist sets it: everything, nothing, or only the addresses that follow, which are
17289
- IPv4 addresses and ranges such as 203.0.113.7 and 198.51.100.0/24. The rule that is given takes
17338
+ IPv4 addresses and ranges such as 203.0.113.7 and 198.51.100.0/24, over any protocol and port,
17339
+ and names such as github.com and *.pythonhosted.org, over HTTPS on port 443 alone. The rule that is given takes
17290
17340
  the place of the one it had, so an allowlist names every address each time. A sandbox on the
17291
17341
  template takes it when it next starts, or now when template apply names it, and one made from
17292
17342
  it is held to it from its first boot. network says what a sandbox is held to, its template's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agental",
3
- "version": "0.43.3",
3
+ "version": "0.44.1",
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",