agental 0.46.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.
Files changed (2) hide show
  1. package/dist/cli.js +40 -9
  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.46.0" : "dev";
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", {
@@ -15499,8 +15504,8 @@ async function screenshot(id, file, options) {
15499
15504
  query.set("height", String(region[3]));
15500
15505
  }
15501
15506
  if (options.scale !== void 0) {
15502
- if (!/^(0(\.\d+)?|1(\.0+)?)$/.test(options.scale) || Number(options.scale) < 0.1) {
15503
- throw new Error("--scale is how much smaller the picture is made, from 0.1 to 1: 0.5 is half as wide and half as high");
15507
+ if (!/^(0(\.\d+)?|1(\.0+)?|2(\.0+)?)$/.test(options.scale) || Number(options.scale) < 0.1) {
15508
+ throw new Error("--scale is how large the picture is made, from 0.1 to 1, or 2 for every pixel of a desktop drawn at 2x: 0.5 is half as wide and half as high");
15504
15509
  }
15505
15510
  query.set("scale", options.scale);
15506
15511
  }
@@ -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 key2 = apiKey();
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
  });
@@ -17696,7 +17726,7 @@ ${FILES_USAGE.map((line) => ` ${line}`).join("\n")}
17696
17726
  [--reply-to <message-id>] [--idempotency-key <key>]
17697
17727
  agental email account [--json]
17698
17728
  agental desktop <sandbox-id> [--screen <width>x<height>] [--off] [--status]
17699
- agental desktop <sandbox-id> --screenshot <file> [--crop <x,y,width,height>] [--scale <0.1-1>]
17729
+ agental desktop <sandbox-id> --screenshot <file> [--crop <x,y,width,height>] [--scale <0.1-2>]
17700
17730
  [--quality <1-100>] [--no-cursor]
17701
17731
  agental desktop <sandbox-id> --click <x,y> | --move <x,y> | --drag <x,y,x,y>
17702
17732
  | --scroll <x,y,notches> | --type <text> | --key <keys>
@@ -18070,8 +18100,9 @@ it off, after which the url leads nowhere, and --status only reads it. On a desk
18070
18100
  --type and --key use its pointer and keyboard, one for each run: --click 640,400,right,2 is a
18071
18101
  double click of the right button, --scroll 640,400,-3 turns the wheel up three notches, and
18072
18102
  --key ctrl+l presses keys named as xdotool names them. The picture is a JPEG when the file is
18073
- named .jpg, of a part of the screen with --crop, smaller with --scale, and without the pointer
18074
- with --no-cursor: each makes it cheaper for a model to read. --clipboard prints the text on the
18103
+ named .jpg, of a part of the screen with --crop, smaller with --scale (2 is every pixel of a
18104
+ desktop drawn at 2x), and without the pointer with --no-cursor: each makes it cheaper for a
18105
+ model to read. --clipboard prints the text on the
18075
18106
  desktop's clipboard, and --set-clipboard puts text there, read from standard input with -, for
18076
18107
  --key ctrl+v to paste at once what --type would type a key at a time. --tree prints what is on
18077
18108
  the screen as its programs tell it: each window, then its buttons, fields and menus, each with
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agental",
3
- "version": "0.46.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",