agental 0.23.0 → 0.24.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 +36 -6
- 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.24.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}`;
|
|
@@ -10348,6 +10348,27 @@ function freshAfterOf(job2) {
|
|
|
10348
10348
|
const keep = job2.keepFailedFor ?? "24h";
|
|
10349
10349
|
return keep === "0" ? "deletes the sandbox, whether the command exits 0 or not" : `deletes the sandbox if the command exits 0; else keeps it stopped for ${keep}`;
|
|
10350
10350
|
}
|
|
10351
|
+
function monthlySpendOf(given) {
|
|
10352
|
+
if (given === void 0) {
|
|
10353
|
+
return void 0;
|
|
10354
|
+
}
|
|
10355
|
+
const spelled = given.trim().replace(/^\$/, "");
|
|
10356
|
+
if (spelled === "none") {
|
|
10357
|
+
return null;
|
|
10358
|
+
}
|
|
10359
|
+
if (!/^[0-9]+(\.[0-9]{1,2})?$/.test(spelled) || Number(spelled) < 0.01 || Number(spelled) > 1e5) {
|
|
10360
|
+
throw new Error(`--max-monthly-spend is the most a job's runs may cost in a month, in dollars from 0.01 to 100000, as 25 or 25.50, or none: not ${given}.`);
|
|
10361
|
+
}
|
|
10362
|
+
return Math.round(Number(spelled) * 100) * 1e4;
|
|
10363
|
+
}
|
|
10364
|
+
function spendLimitOf(job2) {
|
|
10365
|
+
const limit = job2.maxMonthlySpendMicros ?? null;
|
|
10366
|
+
if (limit === null) {
|
|
10367
|
+
return "no limit";
|
|
10368
|
+
}
|
|
10369
|
+
const cents = (micros) => `$${(Math.ceil(micros / 1e4) / 100).toFixed(2)}`;
|
|
10370
|
+
return `${cents(job2.spentThisMonthMicros ?? 0)} of ${cents(limit)} this month`;
|
|
10371
|
+
}
|
|
10351
10372
|
function retriesOf(job2) {
|
|
10352
10373
|
const retries = job2.retries ?? 0;
|
|
10353
10374
|
return retries === 0 ? "none: a run that fails is not tried again" : `${retries}, after ${RETRY_WAITS.slice(0, retries).join(", ")}`;
|
|
@@ -10586,6 +10607,7 @@ function fieldsOf(options) {
|
|
|
10586
10607
|
if (options.alerts !== void 0 && !ALERTS.includes(options.alerts)) {
|
|
10587
10608
|
throw new Error(`--alerts is email, webhook, both or none, not ${options.alerts}.`);
|
|
10588
10609
|
}
|
|
10610
|
+
const spend = monthlySpendOf(options["max-monthly-spend"]);
|
|
10589
10611
|
const target = targetOf(options);
|
|
10590
10612
|
const inputs = jobInputsOf(options);
|
|
10591
10613
|
const events = eventsOf(options);
|
|
@@ -10602,6 +10624,7 @@ function fieldsOf(options) {
|
|
|
10602
10624
|
...options["keep-failed-for"] === void 0 ? {} : { keepFailedFor: options["keep-failed-for"] },
|
|
10603
10625
|
...options.retries === void 0 ? {} : { retries: Number(options.retries.trim()) },
|
|
10604
10626
|
...options.alerts === void 0 ? {} : { alerts: options.alerts },
|
|
10627
|
+
...spend === void 0 ? {} : { maxMonthlySpendMicros: spend },
|
|
10605
10628
|
...inputs === void 0 ? {} : { inputs },
|
|
10606
10629
|
...events === void 0 ? {} : { events }
|
|
10607
10630
|
};
|
|
@@ -10634,6 +10657,7 @@ function print3(job2, asJson) {
|
|
|
10634
10657
|
["timeout", `${Math.round(job2.timeoutMs / 1e3)}s`],
|
|
10635
10658
|
["retries", retriesOf(job2)],
|
|
10636
10659
|
["alerts", alertsOf(job2)],
|
|
10660
|
+
["spending", spendLimitOf(job2)],
|
|
10637
10661
|
...inputsOfJob(job2) === null ? [] : [["inputs", inputsOfJob(job2)]],
|
|
10638
10662
|
...eventsOfJob(job2) === null ? [] : [["events", eventsOfJob(job2)]],
|
|
10639
10663
|
["next", nextOf(job2, false)],
|
|
@@ -10776,7 +10800,7 @@ async function job(client, positionals, command2, options) {
|
|
|
10776
10800
|
const changes = { ...fieldsOf(options), ...options.name === void 0 ? {} : { name: options.name }, ...command2 !== null && command2.length > 0 ? { command: commandLine(command2) } : {} };
|
|
10777
10801
|
if (Object.keys(changes).length === 0) {
|
|
10778
10802
|
throw new Error(
|
|
10779
|
-
"job update needs something to change: --sandbox, --template (and --size), --keep-failed-for, --every, --cron, --at, --tz, --timeout, --overlap, --if-stopped, --keep-memory, --delete-after or --disk-only, --retries, --alerts, --input or --secret-input, --after-job, --on-mail or --no-events, --name for a new name, or a new command after --."
|
|
10803
|
+
"job update needs something to change: --sandbox, --template (and --size), --keep-failed-for, --every, --cron, --at, --tz, --timeout, --overlap, --if-stopped, --keep-memory, --delete-after or --disk-only, --retries, --alerts, --max-monthly-spend, --input or --secret-input, --after-job, --on-mail or --no-events, --name for a new name, or a new command after --."
|
|
10780
10804
|
);
|
|
10781
10805
|
}
|
|
10782
10806
|
print3(await ask6(client, "PATCH", path5, changes), options.json);
|
|
@@ -11091,7 +11115,7 @@ async function refusedCalls(client, name, options) {
|
|
|
11091
11115
|
}
|
|
11092
11116
|
table2([["AT", "STATUS", "TRIGGER", "FROM", "WHY"], ...calls.map((call3) => [past(call3.at), String(call3.status), call3.triggerId, call3.from ?? "-", call3.reason])]);
|
|
11093
11117
|
}
|
|
11094
|
-
var FILE_KEYS = ["name", "sandbox", "template", "size", "command", "every", "cron", "at", "timeZone", "timeoutMs", "overlap", "ifStopped", "after", "keepFailedFor", "retries", "alerts", "inputs", "events", "enabled"];
|
|
11118
|
+
var FILE_KEYS = ["name", "sandbox", "template", "size", "command", "every", "cron", "at", "timeZone", "timeoutMs", "overlap", "ifStopped", "after", "keepFailedFor", "retries", "alerts", "maxMonthlySpendMicros", "inputs", "events", "enabled"];
|
|
11095
11119
|
function fileJobOf(item, index) {
|
|
11096
11120
|
const where = `jobs[${index}]`;
|
|
11097
11121
|
if (item === null || typeof item !== "object" || Array.isArray(item)) {
|
|
@@ -12488,6 +12512,8 @@ async function main() {
|
|
|
12488
12512
|
// agental job add and update: how many times a failed run is tried again, and who is told when one fails for good.
|
|
12489
12513
|
retries: { type: "string" },
|
|
12490
12514
|
alerts: { type: "string" },
|
|
12515
|
+
// agental job add and update: the most a job's runs may cost in a month, in dollars, or none.
|
|
12516
|
+
"max-monthly-spend": { type: "string" },
|
|
12491
12517
|
wait: { type: "boolean", default: false },
|
|
12492
12518
|
// job run and again: --wait 30 or --wait=30, as waitSecondsSpelled gives it.
|
|
12493
12519
|
"wait-seconds": { type: "string" },
|
|
@@ -15375,17 +15401,18 @@ Usage
|
|
|
15375
15401
|
agental jobs [--sandbox <sandbox-id> | --template <template>] [--json]
|
|
15376
15402
|
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>]
|
|
15377
15403
|
[--if-stopped start|skip] [--keep-memory | --delete-after] [--overlap skip|replace|parallel] [--retries <0-5>] [--alerts email|webhook|both|none]
|
|
15404
|
+
[--max-monthly-spend <dollars>]
|
|
15378
15405
|
[--input <NAME>[=<default>]]... [--secret-input <NAME>[=<default>]]... [--after-job <job>[:succeeded|failed]]... [--on-mail <sandbox>]...
|
|
15379
15406
|
[--json] -- <command> [args...]
|
|
15380
15407
|
agental job add [<name>] --template <template> [--size tiny|small|medium|large] [--keep-failed-for 0|30m|24h|7d] [--every 1m|15m|1h|1d | --cron "<m h dom mon dow>" [--tz <zone>] | --at <date-time>]
|
|
15381
|
-
[--timeout <time>] [--overlap skip|replace|parallel] [--retries <0-5>] [--alerts email|webhook|both|none]
|
|
15408
|
+
[--timeout <time>] [--overlap skip|replace|parallel] [--retries <0-5>] [--alerts email|webhook|both|none] [--max-monthly-spend <dollars>]
|
|
15382
15409
|
[--input <NAME>[=<default>]]... [--secret-input <NAME>[=<default>]]... [--after-job <job>[:succeeded|failed]]... [--on-mail <sandbox>]...
|
|
15383
15410
|
[--json] -- <command> [args...] a fresh sandbox for each run
|
|
15384
15411
|
agental job list [--sandbox <sandbox-id> | --template <template>] [--json]
|
|
15385
15412
|
agental job get|delete|pause|resume <job> [--json]
|
|
15386
15413
|
agental job update <job> [--sandbox <sandbox-id> | --template <template> [--size <size>]] [--keep-failed-for <time>] [--every <time> | --cron "<expr>" | --at <date-time>] [--tz <zone>]
|
|
15387
15414
|
[--name <name>] [--timeout <time>] [--if-stopped start|skip] [--keep-memory | --delete-after | --disk-only] [--overlap skip|replace|parallel]
|
|
15388
|
-
[--retries <0-5>] [--alerts email|webhook|both|none] [--input <NAME>[=<default>]]... [--secret-input <NAME>[=<default>]]...
|
|
15415
|
+
[--retries <0-5>] [--alerts email|webhook|both|none] [--max-monthly-spend <dollars>|none] [--input <NAME>[=<default>]]... [--secret-input <NAME>[=<default>]]...
|
|
15389
15416
|
[--after-job <job>[:succeeded|failed]]... [--on-mail <sandbox>]... [--no-events] [--json] [-- <command> [args...]]
|
|
15390
15417
|
agental job run <job> [--input <NAME>=<value>]... [--wait[=<seconds>]] [--json]
|
|
15391
15418
|
agental job again <job> <run-id> [--wait[=<seconds>]] [--json] run it again with what that run was given
|
|
@@ -15588,13 +15615,16 @@ what started it: AGENTAL_TRIGGER_JOB, AGENTAL_TRIGGER_RUN and AGENTAL_TRIGGER_OU
|
|
|
15588
15615
|
AGENTAL_TRIGGER_SANDBOX and AGENTAL_TRIGGER_EMAIL, the message's id. Given to update, they replace
|
|
15589
15616
|
the events the job had; --no-events takes them all away. A chain that comes back to the job is
|
|
15590
15617
|
refused, and events that start 60 runs of a job in a minute pause it.
|
|
15618
|
+
--max-monthly-spend 25 gives a job a spending limit in dollars: once its runs this calendar month
|
|
15619
|
+
(UTC) cost that much, at the list price of the running time they caused, it pauses itself, says
|
|
15620
|
+
so, and mails as its alerts say; a run under way goes on to its end. none takes the limit away.
|
|
15591
15621
|
job apply puts the jobs a file lists, each by its name: one not there is made, and one that is
|
|
15592
15622
|
is changed to exactly what the file says, whatever it leaves out going back to its default; each
|
|
15593
15623
|
is said to be made, changed or unchanged. --prune deletes the jobs the file does not name;
|
|
15594
15624
|
--dry-run changes nothing, and says which would be made, put or deleted. The file is YAML, or
|
|
15595
15625
|
JSON, a map whose jobs: lists each job: its name, command, sandbox: for a sandbox you keep or
|
|
15596
15626
|
template: (and size:) for a fresh sandbox at each run, and any of every, cron, at, timeZone,
|
|
15597
|
-
timeoutMs, overlap, ifStopped, after, keepFailedFor, retries, alerts, inputs, events and enabled,
|
|
15627
|
+
timeoutMs, overlap, ifStopped, after, keepFailedFor, retries, alerts, maxMonthlySpendMicros, inputs, events and enabled,
|
|
15598
15628
|
as POST /v1/jobs takes them; a job named in another's events is listed before it:
|
|
15599
15629
|
jobs:
|
|
15600
15630
|
- name: nightly
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agental",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.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",
|