agental 0.71.0 → 0.73.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 +136 -26
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7424,7 +7424,7 @@ function requestHeaders(given) {
|
|
|
7424
7424
|
|
|
7425
7425
|
// ../src/cli-build.ts
|
|
7426
7426
|
var PUBLISHED = true;
|
|
7427
|
-
var CLI_VERSION = true ? "0.
|
|
7427
|
+
var CLI_VERSION = true ? "0.73.0" : "dev";
|
|
7428
7428
|
var DEFAULT_API_URL = true ? "https://agental.io" : "http://127.0.0.1:8741";
|
|
7429
7429
|
var PACKAGE_NAME = "agental";
|
|
7430
7430
|
var USER_AGENT = `agental-cli/${CLI_VERSION}`;
|
|
@@ -9448,7 +9448,8 @@ var COMMANDS = [
|
|
|
9448
9448
|
[" --image <image>[@<build>]", "start it from your image: its newest ready build, or that build"],
|
|
9449
9449
|
["-s, --size <size>", "tiny, small, medium, large or xlarge (default: the template's)"],
|
|
9450
9450
|
[" --region <region>", "where it runs; agental regions lists them"],
|
|
9451
|
-
[" --ttl <time>", "
|
|
9451
|
+
[" --ttl <time>", "delete it after this long, as 30m or 2h"],
|
|
9452
|
+
[" --on-timeout <what>", "what the limit does: delete (default), stop (keeps its disk) or pause"],
|
|
9452
9453
|
[" --allow <addresses>", "reach only these addresses, comma-separated"],
|
|
9453
9454
|
[" --egress <egress>", "box, or residential:<country>[:sticky|rotating]"],
|
|
9454
9455
|
[" --tailnet <tags> | off", "join the tailnet tagged so (tag:ci), or off for none"],
|
|
@@ -9744,7 +9745,7 @@ var COMMANDS = [
|
|
|
9744
9745
|
["--snapshot <snapshot-id>", "start: start them from this snapshot"],
|
|
9745
9746
|
["--image <image>[@<build>]", "start: start them from your image, its newest ready build or that one"],
|
|
9746
9747
|
["--new-machine", "start: start them as a new machine of our own image, from no snapshot or image of yours"],
|
|
9747
|
-
["--ttl <time> | default", "start:
|
|
9748
|
+
["--ttl <time> | default", "start: delete them after this long, as 2h"],
|
|
9748
9749
|
["--tag <tag>, --meta <key>=<value>", "create: label it (may be given again)"],
|
|
9749
9750
|
["--pause-jobs", "delete: delete it even where jobs make their fresh sandboxes from it, and pause them"],
|
|
9750
9751
|
["--json", "print as JSON"]
|
|
@@ -12500,7 +12501,7 @@ async function writeStdin(client, sandbox, id, one) {
|
|
|
12500
12501
|
|
|
12501
12502
|
// ../src/cli-servers.ts
|
|
12502
12503
|
var SERVER_USAGE = "server takes list, add, show, readings, token, drain, open, gone or remove. agental server --help shows each.";
|
|
12503
|
-
var SERVERS_USAGE = "servers takes nothing to list them, offload [on|off] [--over <percent>], window [--day <day> --hour <0-23> --tz <zone> [--hours <1-12>] | --off],
|
|
12504
|
+
var SERVERS_USAGE = "servers takes nothing to list them, offload [on|off] [--over <percent>], window [--day <day> --hour <0-23> --tz <zone> [--hours <1-12>] | --off], core-days [--month <yyyy-mm>], or key-lost <key id>.";
|
|
12504
12505
|
var READING_MINUTES = ["1", "5", "15", "60"];
|
|
12505
12506
|
async function ask8(client, method, pathname, body) {
|
|
12506
12507
|
const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
|
|
@@ -12581,6 +12582,20 @@ function smtOf(server2) {
|
|
|
12581
12582
|
}
|
|
12582
12583
|
return smt.on ? "on" : "off (allowed on: the processor or the server has it off)";
|
|
12583
12584
|
}
|
|
12585
|
+
function bucketOf(server2) {
|
|
12586
|
+
const bucket = server2.ownBucket;
|
|
12587
|
+
if (bucket === void 0) {
|
|
12588
|
+
return "not said by this API";
|
|
12589
|
+
}
|
|
12590
|
+
if (bucket === null) {
|
|
12591
|
+
return "none: its sandboxes are not archived, and stay on it. sudo agental-agent bucket set, on the server, sets one";
|
|
12592
|
+
}
|
|
12593
|
+
const key2 = bucket.keyIds[0] === void 0 ? "no organization key: sudo agental-agent bucket key new makes one" : `sealed under key ${bucket.keyIds[0]}${bucket.keyIds.length > 1 ? ` (and holds ${bucket.keyIds.length - 1} more)` : ""}`;
|
|
12594
|
+
const checked = ago(bucket.checkedAt) ?? utc(bucket.checkedAt);
|
|
12595
|
+
const check = bucket.ok ? `works, checked ${checked}` : `did not work when checked ${checked}: nothing is archived or brought back`;
|
|
12596
|
+
return `${bucket.bucketId.slice(0, 12)}, ${key2}, ${check}${bucket.differs === null ? "" : `
|
|
12597
|
+
${bucket.differs}`}`;
|
|
12598
|
+
}
|
|
12584
12599
|
function describe3(server2) {
|
|
12585
12600
|
const rows = [
|
|
12586
12601
|
["id", server2.id],
|
|
@@ -12593,8 +12608,12 @@ function describe3(server2) {
|
|
|
12593
12608
|
["smt", smtOf(server2)],
|
|
12594
12609
|
["ksm", server2.ksm?.on === true ? "on: it takes no new sandbox until it is off" : server2.ksm?.on === false ? "off" : "not read yet"],
|
|
12595
12610
|
["holds", holdsOf(server2)],
|
|
12611
|
+
["bucket", bucketOf(server2)],
|
|
12596
12612
|
["added", utc(server2.addedAt)]
|
|
12597
12613
|
];
|
|
12614
|
+
for (const stays of server2.stays ?? []) {
|
|
12615
|
+
rows.push(["stays", `${stays.name} (${stays.sandboxId}): ${stays.why}`]);
|
|
12616
|
+
}
|
|
12598
12617
|
const update = server2.update;
|
|
12599
12618
|
if (update !== void 0 && update.wanted !== null && update.runs !== null && update.runs !== update.wanted) {
|
|
12600
12619
|
rows.push(["update", update.urgent ? `to ${update.wanted} now: a security release` : update.waitingFor !== null ? `${update.wanted} waits for your window, ${utc(update.waitingFor)}` : `to ${update.wanted} now`]);
|
|
@@ -12607,8 +12626,9 @@ function describe3(server2) {
|
|
|
12607
12626
|
}
|
|
12608
12627
|
function sayJoin(joined) {
|
|
12609
12628
|
process.stdout.write(describe3({ ...joined.server, agent: { ...joined.server.agent, joinTokenExpiresAt: null } }));
|
|
12629
|
+
const where = joined.join.installCommand.includes("/dev/DISK") ? ", with the disk for sandboxes in place of /dev/DISK" : ". The disk it names has to hold nothing: no partition, and nothing written on it";
|
|
12610
12630
|
process.stdout.write(`
|
|
12611
|
-
Run this as root on the server
|
|
12631
|
+
Run this as root on the server${where}:
|
|
12612
12632
|
|
|
12613
12633
|
${joined.join.installCommand}
|
|
12614
12634
|
|
|
@@ -12655,8 +12675,29 @@ async function servers(client, positionals, options) {
|
|
|
12655
12675
|
await coreDays(client, options);
|
|
12656
12676
|
return;
|
|
12657
12677
|
}
|
|
12678
|
+
if (what === "key-lost" && rest.length === 1) {
|
|
12679
|
+
await keyLost(client, rest[0], options);
|
|
12680
|
+
return;
|
|
12681
|
+
}
|
|
12658
12682
|
throw new Error(SERVERS_USAGE);
|
|
12659
12683
|
}
|
|
12684
|
+
async function keyLost(client, keyId, options) {
|
|
12685
|
+
if (!/^[0-9a-f]{32}$/.test(keyId)) {
|
|
12686
|
+
throw new Error("servers key-lost needs the key's id, 32 hex digits, as agental server show <server> gives it.");
|
|
12687
|
+
}
|
|
12688
|
+
process.stderr.write(`This says your organization's key ${keyId} is lost for good, and cannot be undone. Every sandbox archived under it is said lost: nobody, agental included, can open its archive.
|
|
12689
|
+
`);
|
|
12690
|
+
if (!options.yes && !await client.confirmed("Say the key is lost?")) {
|
|
12691
|
+
throw new Error("Nothing was changed.");
|
|
12692
|
+
}
|
|
12693
|
+
const said = await ask8(client, "POST", `/v1/own-bucket/keys/${keyId}/lost`, {});
|
|
12694
|
+
if (options.json) {
|
|
12695
|
+
printJson2(said);
|
|
12696
|
+
return;
|
|
12697
|
+
}
|
|
12698
|
+
process.stdout.write(said.sandboxesLost.length === 0 ? "No archive was sealed under it.\n" : `Said lost: ${said.sandboxesLost.join(", ")}. Delete them when you are ready.
|
|
12699
|
+
`);
|
|
12700
|
+
}
|
|
12660
12701
|
async function listServers(client, asJson) {
|
|
12661
12702
|
if (asJson) {
|
|
12662
12703
|
printJson2(await ask8(client, "GET", "/v1/servers"));
|
|
@@ -12764,6 +12805,9 @@ async function coreDays(client, options) {
|
|
|
12764
12805
|
process.stdout.write(`${body.coreDays} core-days in all, ${body.extraCoreDays} of them past the commitment.
|
|
12765
12806
|
`);
|
|
12766
12807
|
}
|
|
12808
|
+
function diskOf(options) {
|
|
12809
|
+
return options.disk === void 0 ? {} : { disk: options.disk };
|
|
12810
|
+
}
|
|
12767
12811
|
async function server(client, positionals, options) {
|
|
12768
12812
|
const [what, target, ...rest] = positionals;
|
|
12769
12813
|
if (rest.length > 0) {
|
|
@@ -12774,7 +12818,7 @@ async function server(client, positionals, options) {
|
|
|
12774
12818
|
if (target === void 0) {
|
|
12775
12819
|
throw new Error("server add needs your own name for the server, as agental server add rack-2-server-01.");
|
|
12776
12820
|
}
|
|
12777
|
-
const joined = await ask8(client, "POST", "/v1/servers", { label: target });
|
|
12821
|
+
const joined = await ask8(client, "POST", "/v1/servers", { label: target, ...diskOf(options) });
|
|
12778
12822
|
if (options.json) {
|
|
12779
12823
|
printJson2(joined);
|
|
12780
12824
|
process.stderr.write("join.token and join.installCommand are shown this once.\n");
|
|
@@ -12798,7 +12842,7 @@ async function server(client, positionals, options) {
|
|
|
12798
12842
|
}
|
|
12799
12843
|
case "token": {
|
|
12800
12844
|
const found = await serverNamed(client, target, "token");
|
|
12801
|
-
const joined = await ask8(client, "POST", `/v1/servers/${encodeURIComponent(found.id)}/join-token`,
|
|
12845
|
+
const joined = await ask8(client, "POST", `/v1/servers/${encodeURIComponent(found.id)}/join-token`, diskOf(options));
|
|
12802
12846
|
if (options.json) {
|
|
12803
12847
|
printJson2(joined);
|
|
12804
12848
|
process.stderr.write("join.token and join.installCommand are shown this once. The token it had stopped working just now.\n");
|
|
@@ -14941,6 +14985,33 @@ async function uploadContext(context, upload, bytes4) {
|
|
|
14941
14985
|
}
|
|
14942
14986
|
return { sha256: packed.sha256, etags };
|
|
14943
14987
|
}
|
|
14988
|
+
async function dropContext(client, contextPath) {
|
|
14989
|
+
try {
|
|
14990
|
+
const response = await client.request(contextPath, { method: "DELETE" });
|
|
14991
|
+
await response.body?.cancel();
|
|
14992
|
+
if (response.ok) {
|
|
14993
|
+
return "dropped";
|
|
14994
|
+
}
|
|
14995
|
+
if (response.status === 409) {
|
|
14996
|
+
return "taken";
|
|
14997
|
+
}
|
|
14998
|
+
process.stderr.write(`The uploaded context was not let go (HTTP ${response.status}): it is deleted a day after it was sent.
|
|
14999
|
+
`);
|
|
15000
|
+
} catch (error) {
|
|
15001
|
+
process.stderr.write(`The uploaded context was not let go (${causeOf(error)}): it is deleted a day after it was sent.
|
|
15002
|
+
`);
|
|
15003
|
+
}
|
|
15004
|
+
return "kept";
|
|
15005
|
+
}
|
|
15006
|
+
async function askOrDrop(client, drop, method, pathname, body) {
|
|
15007
|
+
const response = await client.request(pathname, { method, body: JSON.stringify(body) });
|
|
15008
|
+
const answered = await readJson(response);
|
|
15009
|
+
if (!response.ok) {
|
|
15010
|
+
await drop();
|
|
15011
|
+
client.fail(response.status, answered);
|
|
15012
|
+
}
|
|
15013
|
+
return answered;
|
|
15014
|
+
}
|
|
14944
15015
|
async function build(client, dir, options) {
|
|
14945
15016
|
const name = options.name;
|
|
14946
15017
|
if (name === void 0 || name === "") {
|
|
@@ -14997,24 +15068,55 @@ async function build(client, dir, options) {
|
|
|
14997
15068
|
const parts = upload.parts.length;
|
|
14998
15069
|
process.stderr.write(`Sending ${context.entries.length} files and folders, ${bytesInWords(bytes4)}${parts > 1 ? ` in ${parts} parts` : ""}.
|
|
14999
15070
|
`);
|
|
15000
|
-
|
|
15071
|
+
const contextPath = `${imagePath(name)}/contexts/${encodeURIComponent(upload.context.id)}`;
|
|
15072
|
+
let dropping = null;
|
|
15073
|
+
const drop = () => dropping ??= dropContext(client, contextPath);
|
|
15074
|
+
let stopped = false;
|
|
15075
|
+
const interrupted = () => {
|
|
15076
|
+
stopped = true;
|
|
15077
|
+
void drop().then((became) => {
|
|
15078
|
+
process.stderr.write(
|
|
15079
|
+
became === "taken" ? `
|
|
15080
|
+
Stopped, but the build had started already: agental image show ${name} shows it, and agental image cancel cancels it.
|
|
15081
|
+
` : "\nStopped. Nothing was built.\n"
|
|
15082
|
+
);
|
|
15083
|
+
process.exit(130);
|
|
15084
|
+
});
|
|
15085
|
+
};
|
|
15086
|
+
const unlessStopped = async () => {
|
|
15087
|
+
if (stopped) {
|
|
15088
|
+
await new Promise(() => void 0);
|
|
15089
|
+
}
|
|
15090
|
+
};
|
|
15091
|
+
process.once("SIGINT", interrupted);
|
|
15092
|
+
let started;
|
|
15001
15093
|
try {
|
|
15002
|
-
sent
|
|
15003
|
-
|
|
15004
|
-
|
|
15005
|
-
|
|
15094
|
+
let sent;
|
|
15095
|
+
try {
|
|
15096
|
+
sent = await uploadContext(context, upload, bytes4);
|
|
15097
|
+
} catch (error) {
|
|
15098
|
+
if (error instanceof ContextRefused) {
|
|
15099
|
+
throw new Error(`${error.message}. Nothing was built.`);
|
|
15100
|
+
}
|
|
15101
|
+
throw error;
|
|
15006
15102
|
}
|
|
15103
|
+
await unlessStopped();
|
|
15104
|
+
await askOrDrop(client, drop, "POST", `${contextPath}/complete`, { etags: sent.etags });
|
|
15105
|
+
await unlessStopped();
|
|
15106
|
+
started = await askOrDrop(client, drop, "POST", `${imagePath(name)}/builds`, {
|
|
15107
|
+
contextId: upload.context.id,
|
|
15108
|
+
contextHash: sent.sha256,
|
|
15109
|
+
dockerfile,
|
|
15110
|
+
...context.dockerfile === "Dockerfile" ? {} : { dockerfilePath: context.dockerfile },
|
|
15111
|
+
...Object.keys(args).length === 0 ? {} : { args },
|
|
15112
|
+
copyHashes
|
|
15113
|
+
});
|
|
15114
|
+
} catch (error) {
|
|
15115
|
+
await drop();
|
|
15007
15116
|
throw error;
|
|
15117
|
+
} finally {
|
|
15118
|
+
process.off("SIGINT", interrupted);
|
|
15008
15119
|
}
|
|
15009
|
-
await ask11(client, "POST", `${imagePath(name)}/contexts/${encodeURIComponent(upload.context.id)}/complete`, { etags: sent.etags });
|
|
15010
|
-
const started = await ask11(client, "POST", `${imagePath(name)}/builds`, {
|
|
15011
|
-
contextId: upload.context.id,
|
|
15012
|
-
contextHash: sent.sha256,
|
|
15013
|
-
dockerfile,
|
|
15014
|
-
...context.dockerfile === "Dockerfile" ? {} : { dockerfilePath: context.dockerfile },
|
|
15015
|
-
...Object.keys(args).length === 0 ? {} : { args },
|
|
15016
|
-
copyHashes
|
|
15017
|
-
});
|
|
15018
15120
|
if (options.detach) {
|
|
15019
15121
|
if (options.json) {
|
|
15020
15122
|
printJson3(started);
|
|
@@ -17994,6 +18096,8 @@ async function main() {
|
|
|
17994
18096
|
// agental servers offload: how used a server of the organization's own may be and still take a new sandbox. servers core-days: which month.
|
|
17995
18097
|
over: { type: "string" },
|
|
17996
18098
|
month: { type: "string" },
|
|
18099
|
+
// agental server add and token: the disk for sandboxes, put in the install line.
|
|
18100
|
+
disk: { type: "string" },
|
|
17997
18101
|
// agental servers window: the weekly window the organization's servers take a new agent in, with --tz and --off.
|
|
17998
18102
|
day: { type: "string" },
|
|
17999
18103
|
hour: { type: "string" },
|
|
@@ -21425,10 +21529,11 @@ Usage
|
|
|
21425
21529
|
agental servers offload [on|off] [--over <percent>] [--json]
|
|
21426
21530
|
agental servers window [--day <day> --hour <0-23> --tz <zone> [--hours <1-12>] | --off] [--json]
|
|
21427
21531
|
agental servers core-days [--month <yyyy-mm>] [--json]
|
|
21428
|
-
agental
|
|
21532
|
+
agental servers key-lost <key-id> [--yes] [--json] an organization key gone for good: its archives are lost
|
|
21533
|
+
agental server add <label> [--disk <device>] [--json] its install line and join token, shown once
|
|
21429
21534
|
agental server show <server> [--json]
|
|
21430
21535
|
agental server readings <server> [--since <date-time>] [--until <date-time>] [--every 1|5|15|60] [--json]
|
|
21431
|
-
agental server token <server> [--json]
|
|
21536
|
+
agental server token <server> [--disk <device>] [--json] a new join token; the old one stops at once
|
|
21432
21537
|
agental server drain <server> [--json]
|
|
21433
21538
|
agental server open <server> [--json] takes new sandboxes again after a drain
|
|
21434
21539
|
agental server gone <server> --reason <text> [--yes] [--json] cannot be undone
|
|
@@ -21521,7 +21626,7 @@ recover gets a sandbox that is stuck going again: what runs in it is killed, its
|
|
|
21521
21626
|
and it ends running. One that is stopped is started, and pays a burst fee as a start does.
|
|
21522
21627
|
Start of a sandbox that was archived is accepted and finished afterwards: list shows it as
|
|
21523
21628
|
restoring, and as running when it runs.
|
|
21524
|
-
A sandbox runs until it is stopped, unless it has a time limit: then
|
|
21629
|
+
A sandbox runs until it is stopped, unless it has a time limit: then its time limit runs out once it has
|
|
21525
21630
|
run that long since its last start. create --ttl and template start --ttl set one, as 45m, 2h or
|
|
21526
21631
|
1d, and --ttl default takes the deployment's, which is none unless it says otherwise. When the
|
|
21527
21632
|
time limit runs out the sandbox is deleted, with its disk, unless create --on-timeout stop said to
|
|
@@ -21728,11 +21833,13 @@ disconnect forgets the key and claims no more of its work.
|
|
|
21728
21833
|
servers lists your organization's own servers, on the Enterprise plan: each one's state, whether
|
|
21729
21834
|
its agent is heard from, its cores and the sandboxes on it. Only an owner or an admin manages them.
|
|
21730
21835
|
server add <label> adds one by your own name for it, and prints the line to run as root on it and
|
|
21731
|
-
the one-time token in that line, shown this once; it needs an Enterprise contract in force.
|
|
21836
|
+
the one-time token in that line, shown this once; it needs an Enterprise contract in force. --disk
|
|
21837
|
+
names the disk for sandboxes in the line, as /dev/nvme1n1, which has to hold nothing. token
|
|
21732
21838
|
gives a server that has not joined a new token, and the old one stops working. A <server> is its id
|
|
21733
21839
|
or its label. show says how it stands; readings is its memory, CPU and disk over the last day, a
|
|
21734
21840
|
line an hour unless --every says otherwise, noting the times it did not answer. drain takes it out
|
|
21735
|
-
of placement
|
|
21841
|
+
of placement; where the server has a bucket of your own set, its stopped sandboxes are archived to it, to come back on
|
|
21842
|
+
another of your servers, and show says which stay and why. open puts it back. remove removes one that holds nothing and prints the line
|
|
21736
21843
|
that takes its agent off. gone says a server is gone for good, once it is drained and its agent has
|
|
21737
21844
|
been away 24 hours: its sandboxes are said lost, and it cannot be undone, so it asks first unless
|
|
21738
21845
|
--yes, and --reason says why. servers offload says whether a new sandbox that names no region
|
|
@@ -21742,6 +21849,9 @@ one, from your credits. servers window says, and sets, the weekly window in whic
|
|
|
21742
21849
|
a new agent: --day, --hour on the clock of --tz (an IANA zone, as Europe/Berlin) and --hours (4 to
|
|
21743
21850
|
begin with); --off has them take one at once. A security release reaches them outside it too.
|
|
21744
21851
|
servers core-days is the month's cores as they are counted for billing, day by day.
|
|
21852
|
+
servers key-lost says an organization key of your own bucket is lost for good: every archive sealed under it
|
|
21853
|
+
is then said lost, since nobody, agental included, can open it. It asks first unless --yes, and is refused while
|
|
21854
|
+
a server of yours still holds the key.
|
|
21745
21855
|
org lists the organizations you are in, your own and your teams, and marks the one this command
|
|
21746
21856
|
acts in. A key acts in the organization it was made in, for good, so org use signs in again in
|
|
21747
21857
|
the browser for a key made in the one given, by its id or name, and deletes the key the command
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agental",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.73.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",
|