agental 0.57.0 → 0.60.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 +75 -13
- 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.60.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,6 +9433,7 @@ var COMMANDS = [
|
|
|
9433
9433
|
[" --allow <addresses>", "reach only these addresses, comma-separated"],
|
|
9434
9434
|
[" --egress <egress>", "box, or residential:<country>[:sticky|rotating]"],
|
|
9435
9435
|
[" --tailnet <tags> | off", "join the tailnet tagged so (tag:ci), or off for none"],
|
|
9436
|
+
[" --guild <g[:roles]>", "a guild it may join, in roles or any (repeatable)"],
|
|
9436
9437
|
[" --spot", "half the price, in spare room taken back when needed"],
|
|
9437
9438
|
[" --on-reclaim <what>", "with --spot: stop (default) or delete"],
|
|
9438
9439
|
[" --warn-at <chance>", "with --spot: warn at this chance, as 0.5 or 50%"],
|
|
@@ -9611,7 +9612,7 @@ var COMMANDS = [
|
|
|
9611
9612
|
usage: [
|
|
9612
9613
|
"agental guild [list] | show <guild> | delete <guild> [--yes]",
|
|
9613
9614
|
"agental guild create <guild> --roles <name[:seats],...> [--brief <text>] [--form <file.json>]",
|
|
9614
|
-
"agental guild attach <guild> <template> [--roles <role,...>] | detach <guild> <template>",
|
|
9615
|
+
"agental guild attach <guild> <template|sandbox> [--roles <role,...>] | detach <guild> <template|sandbox>",
|
|
9615
9616
|
"agental guild mine",
|
|
9616
9617
|
"agental guild join <guild> --as <name> --role <role> [--answer <key=value>]...",
|
|
9617
9618
|
"agental guild members <guild> | leave <guild> <identity> | handover <guild> <identity> <sandbox>",
|
|
@@ -9790,6 +9791,7 @@ var COMMANDS = [
|
|
|
9790
9791
|
["--json", "print the API's answer as JSON"]
|
|
9791
9792
|
]
|
|
9792
9793
|
},
|
|
9794
|
+
{ 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
9795
|
{ name: "webhooks", summary: "List the addresses your account's events are sent to." },
|
|
9794
9796
|
{ 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
9797
|
{ 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 +12710,31 @@ async function readings(client, found, options) {
|
|
|
12708
12710
|
}
|
|
12709
12711
|
}
|
|
12710
12712
|
|
|
12713
|
+
// ../src/cli-insights.ts
|
|
12714
|
+
var AREAS = { ci_runners: "CI runners", webhooks: "Webhooks", billing: "Billing" };
|
|
12715
|
+
async function listInsights(client, asJson) {
|
|
12716
|
+
const response = await client.request("/v1/insights", { method: "GET" });
|
|
12717
|
+
const body = await response.json().catch(() => null);
|
|
12718
|
+
if (!response.ok) {
|
|
12719
|
+
client.fail(response.status, body);
|
|
12720
|
+
}
|
|
12721
|
+
if (asJson) {
|
|
12722
|
+
process.stdout.write(`${JSON.stringify(body, null, 2)}
|
|
12723
|
+
`);
|
|
12724
|
+
return;
|
|
12725
|
+
}
|
|
12726
|
+
const insights = Array.isArray(body?.insights) ? body.insights : [];
|
|
12727
|
+
if (insights.length === 0) {
|
|
12728
|
+
process.stdout.write("Nothing needs your attention.\n");
|
|
12729
|
+
return;
|
|
12730
|
+
}
|
|
12731
|
+
const blocks = insights.map(
|
|
12732
|
+
(insight) => [`\u25CF ${AREAS[insight.area] ?? insight.area} \xB7 ${insight.subject.name}`, ` ${insight.title}`, ` ${insight.detail}`, ` ${insight.action.label}: ${insight.action.url}`].join("\n")
|
|
12733
|
+
);
|
|
12734
|
+
process.stdout.write(`${blocks.join("\n\n")}
|
|
12735
|
+
`);
|
|
12736
|
+
}
|
|
12737
|
+
|
|
12711
12738
|
// ../src/event-kinds.ts
|
|
12712
12739
|
var LIFECYCLE_EVENTS = [
|
|
12713
12740
|
"sandbox.created",
|
|
@@ -12738,7 +12765,8 @@ var HEADROOM_EVENTS = [
|
|
|
12738
12765
|
];
|
|
12739
12766
|
var JOB_EVENTS = ["job.created", "job.updated", "job.deleted", "job.run_started", "job.run_finished", "job.run_failed", "job.recovered", "job.paused"];
|
|
12740
12767
|
var TAILSCALE_EVENTS = ["tailscale.node_down", "tailscale.disconnected"];
|
|
12741
|
-
var
|
|
12768
|
+
var GUILD_EVENTS = ["guild.message", "guild.request_open", "guild.member_joined", "guild.member_left", "guild.paused", "guild.resumed"];
|
|
12769
|
+
var WEBHOOK_KINDS = [...WEBHOOK_EVENTS, ...EMAIL_EVENTS, ...MEMBER_EVENTS, ...TEMPLATE_EVENTS, ...HEADROOM_EVENTS, ...JOB_EVENTS, ...TAILSCALE_EVENTS, ...GUILD_EVENTS];
|
|
12742
12770
|
var WEBHOOK_GROUPS = [...new Set(WEBHOOK_KINDS.map((kind) => kind.slice(0, kind.indexOf("."))))];
|
|
12743
12771
|
function closestEvent(asked2) {
|
|
12744
12772
|
if (asked2.length > 64) {
|
|
@@ -14050,6 +14078,13 @@ ${members2.map((member) => ` ${memberLine(member)}`).join("") || " none\n"}`
|
|
|
14050
14078
|
return;
|
|
14051
14079
|
}
|
|
14052
14080
|
case "attach": {
|
|
14081
|
+
if (third?.startsWith("sbx_")) {
|
|
14082
|
+
const roles2 = options.roles === void 0 ? {} : { roles: rolesOf(options.roles).map((role) => role.name) };
|
|
14083
|
+
const opened = await ask11(client, "PUT", `${at4(needed(name, "attach takes a guild"))}/sandboxes/${encodeURIComponent(third)}`, roles2);
|
|
14084
|
+
print4(options.json, opened, `Sandbox ${third} may join ${String(name)}${opened["roles"] ? ` as ${opened["roles"].join(" or ")}` : ", in any role"}.
|
|
14085
|
+
`);
|
|
14086
|
+
return;
|
|
14087
|
+
}
|
|
14053
14088
|
const template2 = await client.templateId(needed(third, "attach takes a guild and a template"));
|
|
14054
14089
|
const roles = options.roles === void 0 ? {} : { roles: rolesOf(options.roles).map((role) => role.name) };
|
|
14055
14090
|
const attached = await ask11(client, "PUT", `${at4(needed(name, "attach takes a guild"))}/templates/${encodeURIComponent(template2)}`, roles);
|
|
@@ -14058,6 +14093,12 @@ ${members2.map((member) => ` ${memberLine(member)}`).join("") || " none\n"}`
|
|
|
14058
14093
|
return;
|
|
14059
14094
|
}
|
|
14060
14095
|
case "detach": {
|
|
14096
|
+
if (third?.startsWith("sbx_")) {
|
|
14097
|
+
await ask11(client, "DELETE", `${at4(needed(name, "detach takes a guild"))}/sandboxes/${encodeURIComponent(third)}`);
|
|
14098
|
+
print4(options.json, { detached: third }, `Sandbox ${third} may no longer join ${String(name)}, but for identities it holds.
|
|
14099
|
+
`);
|
|
14100
|
+
return;
|
|
14101
|
+
}
|
|
14061
14102
|
const template2 = await client.templateId(needed(third, "detach takes a guild and a template"));
|
|
14062
14103
|
await ask11(client, "DELETE", `${at4(needed(name, "detach takes a guild"))}/templates/${encodeURIComponent(template2)}`);
|
|
14063
14104
|
print4(options.json, { detached: template2 }, `Sandboxes of ${template2} may no longer join ${String(name)}.
|
|
@@ -15591,6 +15632,8 @@ async function main() {
|
|
|
15591
15632
|
brief: { type: "string" },
|
|
15592
15633
|
form: { type: "string" },
|
|
15593
15634
|
as: { type: "string" },
|
|
15635
|
+
// create: a guild it may join beside its template's, as name or name:role,role (may be given again).
|
|
15636
|
+
guild: { type: "string", multiple: true },
|
|
15594
15637
|
answer: { type: "string", multiple: true },
|
|
15595
15638
|
// Guild messages: a role it is to, a request, the request it answers, the channel, a retry key, where to read from, and a place confirmed.
|
|
15596
15639
|
"to-role": { type: "string" },
|
|
@@ -15817,7 +15860,7 @@ async function main() {
|
|
|
15817
15860
|
await telemetry(positionals.slice(1), values.header, values.json);
|
|
15818
15861
|
return;
|
|
15819
15862
|
case "ci":
|
|
15820
|
-
await ci(positionals.slice(1), { pool: values.pool, template: once(values.template, "--template"), limit: values.limit, json: values.json });
|
|
15863
|
+
await ci(positionals.slice(1), { pool: values.pool, template: once(values.template, "--template"), size: values.size, limit: values.limit, json: values.json });
|
|
15821
15864
|
return;
|
|
15822
15865
|
case "data-retention":
|
|
15823
15866
|
await dataRetention(positionals.slice(1), values.json);
|
|
@@ -15840,6 +15883,9 @@ async function main() {
|
|
|
15840
15883
|
await command2({ request, fail }, positionals.slice(1, positionals.length - (argv?.length ?? 0)), argv, values);
|
|
15841
15884
|
return;
|
|
15842
15885
|
}
|
|
15886
|
+
case "insights":
|
|
15887
|
+
await listInsights({ request, fail }, values.json === true);
|
|
15888
|
+
return;
|
|
15843
15889
|
case "webhooks":
|
|
15844
15890
|
await listWebhooks({ request, fail }, values.json);
|
|
15845
15891
|
return;
|
|
@@ -15967,6 +16013,7 @@ async function create(values) {
|
|
|
15967
16013
|
...allow ? { network: { allow } } : {},
|
|
15968
16014
|
...egressAsked ? { egress: egressAsked } : {},
|
|
15969
16015
|
...tailnetAsked === void 0 ? {} : { tailnet: tailnetAsked },
|
|
16016
|
+
...values.guild === void 0 ? {} : { guilds: values.guild.map(guildAsked) },
|
|
15970
16017
|
...ttlSeconds === void 0 ? {} : { ttlSeconds },
|
|
15971
16018
|
...onTimeout === void 0 ? {} : { onTimeout: onTimeout.replaceAll("-", "_") },
|
|
15972
16019
|
...spotAsked === void 0 ? {} : { spot: spotAsked },
|
|
@@ -17726,12 +17773,12 @@ async function dataRetention(positionals, asJson) {
|
|
|
17726
17773
|
}
|
|
17727
17774
|
async function ci(positionals, options) {
|
|
17728
17775
|
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>";
|
|
17776
|
+
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
17777
|
if (rest.length > 0 || what === void 0 && repo !== void 0 || what !== void 0 && what !== "set" && what !== "reset" && what !== "jobs") {
|
|
17731
17778
|
throw new Error(usage);
|
|
17732
17779
|
}
|
|
17733
|
-
if (what !== "set" && (options.pool !== void 0 || options.template !== void 0)) {
|
|
17734
|
-
throw new Error("--pool and --template are for ci set.");
|
|
17780
|
+
if (what !== "set" && (options.pool !== void 0 || options.template !== void 0 || options.size !== void 0)) {
|
|
17781
|
+
throw new Error("--size, --pool and --template are for ci set.");
|
|
17735
17782
|
}
|
|
17736
17783
|
if (what !== "jobs" && options.limit !== void 0) {
|
|
17737
17784
|
throw new Error("--limit is for ci jobs.");
|
|
@@ -17801,21 +17848,28 @@ async function ci(positionals, options) {
|
|
|
17801
17848
|
let poolMax = before?.poolMax ?? null;
|
|
17802
17849
|
if (options.pool !== void 0) {
|
|
17803
17850
|
poolMax = options.pool === "default" ? null : Number(options.pool);
|
|
17804
|
-
if (poolMax !== null && (!Number.isInteger(poolMax) || poolMax < 1 || poolMax >
|
|
17805
|
-
throw new Error("--pool is 1 to
|
|
17851
|
+
if (poolMax !== null && (!Number.isInteger(poolMax) || poolMax < 1 || poolMax > 100)) {
|
|
17852
|
+
throw new Error("--pool is 1 to 100 sandboxes of each size, or default.");
|
|
17853
|
+
}
|
|
17854
|
+
}
|
|
17855
|
+
let size2;
|
|
17856
|
+
if (options.size !== void 0) {
|
|
17857
|
+
size2 = options.size === "default" ? null : options.size;
|
|
17858
|
+
if (size2 !== null && !["tiny", "small", "medium", "large"].includes(size2)) {
|
|
17859
|
+
throw new Error("--size is tiny, small, medium or large, or default.");
|
|
17806
17860
|
}
|
|
17807
17861
|
}
|
|
17808
17862
|
let templateId = before?.templateId ?? null;
|
|
17809
17863
|
if (options.template !== void 0) {
|
|
17810
17864
|
templateId = options.template === "default" ? null : (await templateNamed(options.template)).id;
|
|
17811
17865
|
}
|
|
17812
|
-
const saved = await asked(path6, { method: "PUT", body: JSON.stringify({ poolMax, templateId }) });
|
|
17866
|
+
const saved = await asked(path6, { method: "PUT", body: JSON.stringify({ poolMax, templateId, ...size2 === void 0 ? {} : { size: size2 } }) });
|
|
17813
17867
|
if (options.json) {
|
|
17814
17868
|
process.stdout.write(`${JSON.stringify(saved, null, 2)}
|
|
17815
17869
|
`);
|
|
17816
17870
|
return;
|
|
17817
17871
|
}
|
|
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.
|
|
17872
|
+
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
17873
|
`);
|
|
17820
17874
|
}
|
|
17821
17875
|
function ciWaitWords(reason2) {
|
|
@@ -17858,7 +17912,7 @@ async function ciJobs(repo, limit, asJson) {
|
|
|
17858
17912
|
for (const job2 of body.jobs) {
|
|
17859
17913
|
const title = [job2.workflow, job2.name].filter(Boolean).join(" / ") || `job ${job2.jobId}`;
|
|
17860
17914
|
const took = job2.startedAt && job2.endedAt ? `${Math.round((Date.parse(job2.endedAt) - Date.parse(job2.startedAt)) / 1e3)}s` : "";
|
|
17861
|
-
const detail = [job2.repository, job2.branch, job2.size, took, job2.sandboxId, job2.error].filter(Boolean).join(" ");
|
|
17915
|
+
const detail = [job2.repository, job2.branch, job2.event?.replaceAll("_", " "), job2.size, took, job2.sandboxId, job2.error].filter(Boolean).join(" ");
|
|
17862
17916
|
process.stdout.write(`${job2.state.padEnd(9)} ${title} ${detail}
|
|
17863
17917
|
`);
|
|
17864
17918
|
}
|
|
@@ -18653,6 +18707,14 @@ function boxNamed(value) {
|
|
|
18653
18707
|
}
|
|
18654
18708
|
return value?.trim();
|
|
18655
18709
|
}
|
|
18710
|
+
function guildAsked(given) {
|
|
18711
|
+
const colon = given.indexOf(":");
|
|
18712
|
+
if (colon === -1) {
|
|
18713
|
+
return { guild: given.trim() };
|
|
18714
|
+
}
|
|
18715
|
+
const roles = given.slice(colon + 1).split(",").map((role) => role.trim()).filter((role) => role !== "");
|
|
18716
|
+
return { guild: given.slice(0, colon).trim(), ...roles.length === 0 ? {} : { roles } };
|
|
18717
|
+
}
|
|
18656
18718
|
function apiBase() {
|
|
18657
18719
|
return resolveApi(DEFAULT_URL, DEV_KEY).base;
|
|
18658
18720
|
}
|
|
@@ -18861,7 +18923,7 @@ Usage
|
|
|
18861
18923
|
agental metrics <sandbox-id> [--since <date-time>] [--until <date-time>] [--step <seconds>] [--json]
|
|
18862
18924
|
agental metrics --running [--since <date-time>] [--until <date-time>] [--step <seconds>] [--json]
|
|
18863
18925
|
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]
|
|
18926
|
+
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
18927
|
agental data-retention [1 | 7 | 30 | 90 | never] [--json]
|
|
18866
18928
|
agental jobs [--sandbox <sandbox-id> | --template <template>] [--json]
|
|
18867
18929
|
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.
|
|
3
|
+
"version": "0.60.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",
|