agental 0.47.0 → 0.49.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 +34 -4
- 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.49.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}`;
|
|
@@ -7912,6 +7912,8 @@ var KEY_ACTIONS = [
|
|
|
7912
7912
|
"snapshot.write",
|
|
7913
7913
|
"template.read",
|
|
7914
7914
|
"template.write",
|
|
7915
|
+
"bucket.read",
|
|
7916
|
+
"bucket.write",
|
|
7915
7917
|
"key.manage",
|
|
7916
7918
|
"account.read",
|
|
7917
7919
|
"account.admin",
|
|
@@ -7935,7 +7937,7 @@ var FULL_SANDBOX = [
|
|
|
7935
7937
|
];
|
|
7936
7938
|
var PRESETS = {
|
|
7937
7939
|
// Every read, apart from secrets and mail, which are the two an agent should be given by name.
|
|
7938
|
-
"read-only": ["sandbox.read", "file.read", "job.read", "snapshot.read", "template.read", "account.read"],
|
|
7940
|
+
"read-only": ["sandbox.read", "file.read", "job.read", "snapshot.read", "template.read", "bucket.read", "account.read"],
|
|
7939
7941
|
"full-sandbox": [...FULL_SANDBOX, "job.read", "job.write", "job.run"],
|
|
7940
7942
|
// A CI system runs the jobs it is given and reads how they went; it does not make them.
|
|
7941
7943
|
ci: [...FULL_SANDBOX, "sandbox.create", "sandbox.fork", "sandbox.resume", "sandbox.delete-own", "job.read", "job.run"],
|
|
@@ -14801,6 +14803,9 @@ async function create(values) {
|
|
|
14801
14803
|
const egressAsked = values.egress === void 0 ? void 0 : egressFrom(values.egress.split(":"), "--egress takes box, or residential:<country>, as residential:de or residential:us:rotating.");
|
|
14802
14804
|
const sshKeys2 = values["ssh-key"] === void 0 ? void 0 : publicKeysFrom(values["ssh-key"]);
|
|
14803
14805
|
const box = boxNamed(values.box);
|
|
14806
|
+
if (box !== void 0 && PUBLISHED) {
|
|
14807
|
+
throw new Error("--box is for whoever runs agental, from its repository.");
|
|
14808
|
+
}
|
|
14804
14809
|
const templateId = values.template === void 0 ? void 0 : (await templateNamed(values.template)).id;
|
|
14805
14810
|
const idempotencyKey = values["idempotency-key"] ?? `cli-${randomUUID3()}`;
|
|
14806
14811
|
const response = await request("/v1/sandboxes", {
|
|
@@ -17025,7 +17030,8 @@ function usedParts(body) {
|
|
|
17025
17030
|
const parts = [
|
|
17026
17031
|
...(body.mailMicros ?? 0) > 0 ? [`${money(body.mailMicros ?? 0)} by email`] : [],
|
|
17027
17032
|
...(body.stoppedMicros ?? 0) > 0 ? [`${money(body.stoppedMicros ?? 0)} by stopped sandboxes`] : [],
|
|
17028
|
-
...(body.snapshotMicros ?? 0) > 0 ? [`${money(body.snapshotMicros ?? 0)} by snapshots past the free ones`] : []
|
|
17033
|
+
...(body.snapshotMicros ?? 0) > 0 ? [`${money(body.snapshotMicros ?? 0)} by snapshots past the free ones`] : [],
|
|
17034
|
+
...(body.bucketMicros ?? 0) > 0 ? [`${money(body.bucketMicros ?? 0)} by buckets`] : []
|
|
17029
17035
|
];
|
|
17030
17036
|
return parts.length > 0 ? `, ${parts.join(" and ")} of it` : "";
|
|
17031
17037
|
}
|
|
@@ -17445,17 +17451,41 @@ async function request(pathname, init) {
|
|
|
17445
17451
|
await new Promise((resolve) => setTimeout(resolve, seconds2 * 1e3));
|
|
17446
17452
|
}
|
|
17447
17453
|
}
|
|
17454
|
+
function adminKeyHere() {
|
|
17455
|
+
if (PUBLISHED) {
|
|
17456
|
+
return void 0;
|
|
17457
|
+
}
|
|
17458
|
+
const given = process.env["AGENTAL_ADMIN_KEY"]?.trim();
|
|
17459
|
+
if (given) {
|
|
17460
|
+
return given;
|
|
17461
|
+
}
|
|
17462
|
+
try {
|
|
17463
|
+
const saved = JSON.parse(readFileSync7(`${os7.homedir()}/.config/agental/admin-key.json`, "utf8"));
|
|
17464
|
+
const forHere = typeof saved.apiUrl === "string" && saved.apiUrl.replace(/\/$/, "") === apiBase().replace(/\/$/, "");
|
|
17465
|
+
if (forHere && typeof saved.key === "string" && !(typeof saved.expiresAt === "string" && Date.parse(saved.expiresAt) <= Date.now())) {
|
|
17466
|
+
return saved.key;
|
|
17467
|
+
}
|
|
17468
|
+
} catch {
|
|
17469
|
+
}
|
|
17470
|
+
return void 0;
|
|
17471
|
+
}
|
|
17448
17472
|
async function requestOnce(pathname, init) {
|
|
17449
17473
|
const base = apiBase();
|
|
17450
|
-
const
|
|
17474
|
+
const admin = adminKeyHere();
|
|
17475
|
+
const namesBox = new Headers(init.headers).has("x-agental-box");
|
|
17476
|
+
const key2 = admin && (pathname === "/v1/admin" || pathname.startsWith("/v1/admin/")) ? admin : apiKey();
|
|
17451
17477
|
try {
|
|
17478
|
+
const sendsAdmin = admin !== void 0 && (key2 === admin || namesBox);
|
|
17452
17479
|
return await fetch(`${base}${pathname}`, {
|
|
17453
17480
|
...init,
|
|
17481
|
+
// An admin key never follows a redirect: a custom header would go on to wherever it points.
|
|
17482
|
+
...sendsAdmin ? { redirect: "error" } : {},
|
|
17454
17483
|
headers: {
|
|
17455
17484
|
Authorization: `Bearer ${key2}`,
|
|
17456
17485
|
Accept: "application/json",
|
|
17457
17486
|
"User-Agent": USER_AGENT,
|
|
17458
17487
|
...init.body ? { "Content-Type": "application/json" } : {},
|
|
17488
|
+
...admin && namesBox ? { "X-Agental-Admin-Key": admin } : {},
|
|
17459
17489
|
...init.headers
|
|
17460
17490
|
}
|
|
17461
17491
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agental",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.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",
|