agental 0.52.0 → 0.54.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 +299 -84
  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.52.0" : "dev";
7414
+ var CLI_VERSION = true ? "0.54.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}`;
@@ -7916,6 +7916,9 @@ var KEY_ACTIONS = [
7916
7916
  "template.write",
7917
7917
  "bucket.read",
7918
7918
  "bucket.write",
7919
+ "guild.read",
7920
+ "guild.write",
7921
+ "guild.join",
7919
7922
  "key.manage",
7920
7923
  "account.read",
7921
7924
  "account.admin",
@@ -7939,7 +7942,7 @@ var FULL_SANDBOX = [
7939
7942
  ];
7940
7943
  var PRESETS = {
7941
7944
  // Every read, apart from secrets and mail, which are the two an agent should be given by name.
7942
- "read-only": ["sandbox.read", "file.read", "job.read", "snapshot.read", "template.read", "bucket.read", "account.read"],
7945
+ "read-only": ["sandbox.read", "file.read", "job.read", "snapshot.read", "template.read", "bucket.read", "guild.read", "account.read"],
7943
7946
  "full-sandbox": [...FULL_SANDBOX, "job.read", "job.write", "job.run"],
7944
7947
  // A CI system runs the jobs it is given and reads how they went; it does not make them.
7945
7948
  ci: [...FULL_SANDBOX, "sandbox.create", "sandbox.fork", "sandbox.resume", "sandbox.delete-own", "job.read", "job.run"],
@@ -8305,7 +8308,7 @@ async function pushRequest(base, ask13) {
8305
8308
  async function listen() {
8306
8309
  let arrived = () => {
8307
8310
  };
8308
- let answer4 = () => {
8311
+ let answer5 = () => {
8309
8312
  };
8310
8313
  const next = new Promise((resolve) => arrived = resolve);
8311
8314
  let taken = false;
@@ -8320,7 +8323,7 @@ async function listen() {
8320
8323
  return;
8321
8324
  }
8322
8325
  taken = true;
8323
- answer4 = (to) => response.writeHead(302, { location: to, "cache-control": "no-store" }).end();
8326
+ answer5 = (to) => response.writeHead(302, { location: to, "cache-control": "no-store" }).end();
8324
8327
  arrived(url);
8325
8328
  });
8326
8329
  await new Promise((resolve, reject) => {
@@ -8328,7 +8331,7 @@ async function listen() {
8328
8331
  server2.listen(0, "127.0.0.1", resolve);
8329
8332
  });
8330
8333
  const { port } = server2.address();
8331
- return { server: server2, redirectUri: `http://127.0.0.1:${port}/callback`, next, answer: (to) => answer4(to) };
8334
+ return { server: server2, redirectUri: `http://127.0.0.1:${port}/callback`, next, answer: (to) => answer5(to) };
8332
8335
  }
8333
8336
  async function browserSignIn(base, term, organizationId) {
8334
8337
  const verifier = randomBytes2(32).toString("base64url");
@@ -8643,9 +8646,9 @@ function addToToml(agent, folder, url) {
8643
8646
  function run(command3, args, cwd) {
8644
8647
  return new Promise((resolve) => {
8645
8648
  execFile(command3, args, { encoding: "utf8", timeout: 6e4, cwd, shell: process.platform === "win32" }, (error, stdout, stderr) => {
8646
- const out = `${stdout}${stderr}`.trim();
8647
- const missing = error?.code === "ENOENT" || process.platform === "win32" && /is not recognized as an internal or external command/i.test(out);
8648
- resolve({ ok: !error, out, missing });
8649
+ const out2 = `${stdout}${stderr}`.trim();
8650
+ const missing = error?.code === "ENOENT" || process.platform === "win32" && /is not recognized as an internal or external command/i.test(out2);
8651
+ resolve({ ok: !error, out: out2, missing });
8649
8652
  });
8650
8653
  });
8651
8654
  }
@@ -8996,9 +8999,9 @@ async function api(base, key2, method, pathname, body, headers = {}) {
8996
8999
  }
8997
9000
  return { status: response.status, body: parsed && typeof parsed === "object" ? parsed : {} };
8998
9001
  }
8999
- function errorOf(answer4) {
9000
- const error = answer4.body["error"] && typeof answer4.body["error"] === "object" ? answer4.body["error"] : {};
9001
- return { code: String(error["code"] ?? `http_${answer4.status}`), message: String(error["message"] ?? `HTTP ${answer4.status}`) };
9002
+ function errorOf(answer5) {
9003
+ const error = answer5.body["error"] && typeof answer5.body["error"] === "object" ? answer5.body["error"] : {};
9004
+ return { code: String(error["code"] ?? `http_${answer5.status}`), message: String(error["message"] ?? `HTTP ${answer5.status}`) };
9002
9005
  }
9003
9006
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
9004
9007
  function real(file) {
@@ -9421,6 +9424,7 @@ var COMMANDS = [
9421
9424
  [" --ttl <time>", "stop it after this long, as 30m or 2h"],
9422
9425
  [" --allow <addresses>", "reach only these addresses, comma-separated"],
9423
9426
  [" --egress <egress>", "box, or residential:<country>[:sticky|rotating]"],
9427
+ [" --tailnet <tags> | off", "join the tailnet tagged so (tag:ci), or off for none"],
9424
9428
  [" --spot", "half the price, in spare room taken back when needed"],
9425
9429
  [" --on-reclaim <what>", "with --spot: stop (default) or delete"],
9426
9430
  [" --warn-at <chance>", "with --spot: warn at this chance, as 0.5 or 50%"],
@@ -9583,6 +9587,29 @@ var COMMANDS = [
9583
9587
  { name: "regions", summary: "List where sandboxes run, and how much room each has now." },
9584
9588
  { name: "network", summary: "Say what a sandbox may reach outside itself.", examples: ["agental network sbx_2a9a47e50daec64a --allow github.com,registry.npmjs.org", "agental network sbx_2a9a47e50daec64a --none"] },
9585
9589
  { name: "egress", summary: "Say where a sandbox's web traffic leaves from, or read your residential egress.", examples: ["agental egress sbx_2a9a47e50daec64a residential de"] },
9590
+ {
9591
+ name: "tailscale",
9592
+ summary: "Connect the account's Tailscale OAuth client, its secret sealed on this machine, or say or disconnect it.",
9593
+ usage: ["agental tailscale [status] [--json]", "agental tailscale connect --client-id <id>", "agental tailscale disconnect [--yes]"],
9594
+ examples: ["agental tailscale connect --client-id kAbCdEf2CNTRL"],
9595
+ flags: [
9596
+ ["--client-id <id>", "connect: the OAuth client's id (scopes auth_keys, devices:core); secret read hidden"],
9597
+ ["--yes", "disconnect: without asking; every sandbox is taken off the tailnet"]
9598
+ ]
9599
+ },
9600
+ {
9601
+ name: "tailnet",
9602
+ summary: "Join a sandbox to the account's tailnet as a node, change how, or take it off.",
9603
+ usage: ["agental tailnet <sandbox> [--json]", "agental tailnet <sandbox> join --tag <tag> [--accept <range>] [--exit-node <ip>] [--keep-address] [--node-name <name>]", "agental tailnet <sandbox> off"],
9604
+ examples: ["agental tailnet build join --tag tag:ci", "agental tailnet build join --tag tag:ci --accept 10.1.0.0/16 --keep-address"],
9605
+ flags: [
9606
+ ["--tag <tag:name>", "join: a tag the OAuth client owns (may be given again)"],
9607
+ ["--accept <range>", "join: a subnet route of the tailnet it takes, /8 or narrower (may be given again)"],
9608
+ ["--exit-node <address>", "join: its other traffic leaves through this tailnet address"],
9609
+ ["--keep-address", "join: keep its tailnet address across stops and moves"],
9610
+ ["--node-name <name>", "join: its name on the tailnet; the sandbox's own by default"]
9611
+ ]
9612
+ },
9586
9613
  {
9587
9614
  name: "spot",
9588
9615
  summary: "Read a spot sandbox's chance of being stopped, change what a reclaim does to it, or turn off spot.",
@@ -10080,6 +10107,7 @@ var SUBCOMMANDS = {
10080
10107
  job: ["list"],
10081
10108
  limits: ["budget"],
10082
10109
  egress: ["budget", "use-case"],
10110
+ tailscale: ["status", "connect", "disconnect"],
10083
10111
  telemetry: ["set", "test", "unset"],
10084
10112
  ci: ["jobs", "set", "reset"],
10085
10113
  org: ["list", "use", "create"],
@@ -12642,7 +12670,8 @@ var HEADROOM_EVENTS = [
12642
12670
  "limits.budget_reached"
12643
12671
  ];
12644
12672
  var JOB_EVENTS = ["job.created", "job.updated", "job.deleted", "job.run_started", "job.run_finished", "job.run_failed", "job.recovered", "job.paused"];
12645
- var WEBHOOK_KINDS = [...WEBHOOK_EVENTS, ...EMAIL_EVENTS, ...MEMBER_EVENTS, ...TEMPLATE_EVENTS, ...HEADROOM_EVENTS, ...JOB_EVENTS];
12673
+ var TAILSCALE_EVENTS = ["tailscale.node_down", "tailscale.disconnected"];
12674
+ var WEBHOOK_KINDS = [...WEBHOOK_EVENTS, ...EMAIL_EVENTS, ...MEMBER_EVENTS, ...TEMPLATE_EVENTS, ...HEADROOM_EVENTS, ...JOB_EVENTS, ...TAILSCALE_EVENTS];
12646
12675
  var WEBHOOK_GROUPS = [...new Set(WEBHOOK_KINDS.map((kind) => kind.slice(0, kind.indexOf("."))))];
12647
12676
  function closestEvent(asked2) {
12648
12677
  if (asked2.length > 64) {
@@ -13118,12 +13147,12 @@ function describe5(snapshot2) {
13118
13147
  ["Kept", `${keptOf(snapshot2)}${copied}`],
13119
13148
  ["State", snapshot2.state]
13120
13149
  ];
13121
- const out = [`${strong(snapshot2.name)} ${faint(snapshot2.id)}`, "", ...fitted(facts, { paint: (cell, _row, column) => column === 0 ? faint(cell) : cell }).trimEnd().split("\n")];
13150
+ const out2 = [`${strong(snapshot2.name)} ${faint(snapshot2.id)}`, "", ...fitted(facts, { paint: (cell, _row, column) => column === 0 ? faint(cell) : cell }).trimEnd().split("\n")];
13122
13151
  if (snapshot2.kept === STORAGE_ONLY) {
13123
- out.push("", "Its server no longer holds it. Rolling back to it, or starting a sandbox from it, fetches it first: a few minutes.");
13152
+ out2.push("", "Its server no longer holds it. Rolling back to it, or starting a sandbox from it, fetches it first: a few minutes.");
13124
13153
  }
13125
13154
  if (snapshot2.state !== "ready") {
13126
- return `${out.join("\n")}
13155
+ return `${out2.join("\n")}
13127
13156
  `;
13128
13157
  }
13129
13158
  const next = [
@@ -13131,8 +13160,8 @@ function describe5(snapshot2) {
13131
13160
  ["Start from", `agental sandbox create --snapshot ${snapshot2.id}`],
13132
13161
  ["Delete", `agental snapshot delete ${snapshot2.id}`]
13133
13162
  ];
13134
- out.push("", ...fitted(next, { paint: (cell, _row, column) => column === 0 ? faint(cell) : cell }).trimEnd().split("\n"));
13135
- return `${out.join("\n")}
13163
+ out2.push("", ...fitted(next, { paint: (cell, _row, column) => column === 0 ? faint(cell) : cell }).trimEnd().split("\n"));
13164
+ return `${out2.join("\n")}
13136
13165
  `;
13137
13166
  }
13138
13167
  async function snapshotsOfSandbox(client, word) {
@@ -13236,16 +13265,16 @@ async function snapshot(client, positionals, options) {
13236
13265
  if (found.kept === STORAGE_ONLY) {
13237
13266
  process.stderr.write("Its server no longer holds it: it is fetched from storage first, which takes a few minutes.\n");
13238
13267
  }
13239
- const answer4 = await ask10(client, "POST", `/v1/sandboxes/${encodeURIComponent(found.sandboxId)}/restore`, {
13268
+ const answer5 = await ask10(client, "POST", `/v1/sandboxes/${encodeURIComponent(found.sandboxId)}/restore`, {
13240
13269
  headers: { "Idempotency-Key": options.idempotencyKey ?? `cli-${randomUUID2()}` },
13241
13270
  body: { snapshotId: found.id }
13242
13271
  });
13243
13272
  if (options.json) {
13244
- process.stdout.write(`${JSON.stringify(answer4, null, 2)}
13273
+ process.stdout.write(`${JSON.stringify(answer5, null, 2)}
13245
13274
  `);
13246
13275
  return;
13247
13276
  }
13248
- const read2 = answer4;
13277
+ const read2 = answer5;
13249
13278
  const discarded = Array.isArray(read2?.discarded) ? read2.discarded.map(String) : [];
13250
13279
  const status = typeof read2?.sandbox?.status === "string" ? `, and ${read2.sandbox.status}` : "";
13251
13280
  process.stdout.write(`${sandbox} is as it was at ${found.name}${status}.
@@ -13395,14 +13424,14 @@ async function hkdfExtract(salt, ikm) {
13395
13424
  return hmac(salt.length > 0 ? salt : new Uint8Array(32), ikm);
13396
13425
  }
13397
13426
  async function hkdfExpand(prk, info, length) {
13398
- const out = new Uint8Array(length);
13427
+ const out2 = new Uint8Array(length);
13399
13428
  let block = new Uint8Array();
13400
13429
  for (let counter = 1, filled = 0; filled < length; counter++) {
13401
13430
  block = await hmac(prk, concat(block, info, new Uint8Array([counter])));
13402
- out.set(block.subarray(0, Math.min(block.length, length - filled)), filled);
13431
+ out2.set(block.subarray(0, Math.min(block.length, length - filled)), filled);
13403
13432
  filled += block.length;
13404
13433
  }
13405
- return out;
13434
+ return out2;
13406
13435
  }
13407
13436
  async function hmac(key2, data) {
13408
13437
  const hmacKey = await subtle().importKey("raw", key2, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
@@ -13414,18 +13443,18 @@ function subtle() {
13414
13443
  return webCrypto;
13415
13444
  }
13416
13445
  function i2osp(value, length) {
13417
- const out = new Uint8Array(length);
13418
- for (let i = length - 1, v = value; i >= 0; i--, v >>>= 8) out[i] = v & 255;
13419
- return out;
13446
+ const out2 = new Uint8Array(length);
13447
+ for (let i = length - 1, v = value; i >= 0; i--, v >>>= 8) out2[i] = v & 255;
13448
+ return out2;
13420
13449
  }
13421
13450
  function concat(...parts) {
13422
- const out = new Uint8Array(parts.reduce((total, part) => total + part.length, 0));
13451
+ const out2 = new Uint8Array(parts.reduce((total, part) => total + part.length, 0));
13423
13452
  let offset = 0;
13424
13453
  for (const part of parts) {
13425
- out.set(part, offset);
13454
+ out2.set(part, offset);
13426
13455
  offset += part.length;
13427
13456
  }
13428
- return out;
13457
+ return out2;
13429
13458
  }
13430
13459
  function utf8(text) {
13431
13460
  return new Uint8Array(new TextEncoder().encode(text));
@@ -13583,6 +13612,9 @@ async function toSeal(client, given, options, verb) {
13583
13612
  return { name, value, hosts };
13584
13613
  }
13585
13614
  async function sealFor(client, name, value, hosts) {
13615
+ return await sealForAccount(client, name, value, hosts, "variable");
13616
+ }
13617
+ async function sealForAccount(client, name, value, hosts, purpose) {
13586
13618
  const { keys } = await answer2(client, "/v1/secrets/key", { method: "GET" });
13587
13619
  const org2 = String((await answer2(client, "/v1/me", { method: "GET" })).activeOrganizationId ?? "");
13588
13620
  if (!org2) {
@@ -13595,7 +13627,7 @@ async function sealFor(client, name, value, hosts) {
13595
13627
  for (const key2 of mine) {
13596
13628
  await verifySealingKey(key2, client.roots ?? ROOT_KEYS);
13597
13629
  }
13598
- const sealed = await Promise.all(mine.map((key2) => seal(key2, { value, hosts, org: org2, name, purpose: "variable" }, client.roots ?? ROOT_KEYS)));
13630
+ const sealed = await Promise.all(mine.map((key2) => seal(key2, { value, hosts, org: org2, name, purpose }, client.roots ?? ROOT_KEYS)));
13599
13631
  return { sealed, org: org2 };
13600
13632
  }
13601
13633
  function nameOf2(given, verb) {
@@ -13652,6 +13684,148 @@ function refused(client, status, body) {
13652
13684
  client.fail(status, body);
13653
13685
  }
13654
13686
 
13687
+ // ../src/cli-tailscale.ts
13688
+ var SECRET_NAME = "TAILSCALE_OAUTH";
13689
+ var SECRET_HOST = "api.tailscale.com";
13690
+ async function answer3(client, pathname, init) {
13691
+ const response = await client.request(pathname, init);
13692
+ const text = await response.text();
13693
+ let body = text;
13694
+ try {
13695
+ body = text ? JSON.parse(text) : null;
13696
+ } catch {
13697
+ }
13698
+ if (!response.ok) {
13699
+ client.fail(response.status, body);
13700
+ }
13701
+ return body;
13702
+ }
13703
+ async function sandboxIdOf2(client, word) {
13704
+ if (word.startsWith("sbx_")) {
13705
+ return word;
13706
+ }
13707
+ const body = await answer3(client, `/v1/sandboxes?${new URLSearchParams({ q: word })}`, { method: "GET" });
13708
+ const listed2 = Array.isArray(body?.sandboxes) ? body.sandboxes : [];
13709
+ const named = listed2.filter((one) => one.name === word && typeof one.id === "string");
13710
+ if (named.length > 1) {
13711
+ throw new Error(`${named.length} sandboxes are named ${word}. Give the id of the one you mean: ${named.map((one) => String(one.id)).join(", ")}.`);
13712
+ }
13713
+ if (named.length === 0) {
13714
+ throw new Error(`There is no sandbox named ${word}. agental list lists them.`);
13715
+ }
13716
+ return named[0].id;
13717
+ }
13718
+ function out(flags2, body, words2) {
13719
+ process.stdout.write(flags2.json ? `${JSON.stringify(body, null, 2)}
13720
+ ` : words2);
13721
+ }
13722
+ async function tailscale(client, positionals, flags2) {
13723
+ const [verb = "status", ...rest] = positionals;
13724
+ if (rest.length > 0) {
13725
+ throw new Error("tailscale takes connect, status or disconnect, and nothing after it.");
13726
+ }
13727
+ if (verb === "status") {
13728
+ const body = await answer3(client, "/v1/integrations/tailscale", { method: "GET" });
13729
+ out(flags2, body, body.connected ? `Tailscale: connected, OAuth client ${body.clientId}, since ${body.connectedAt}
13730
+ ` : "Tailscale: not connected. agental tailscale connect --client-id <id> connects one.\n");
13731
+ return;
13732
+ }
13733
+ if (verb === "connect") {
13734
+ const clientId = flags2.clientId;
13735
+ if (!clientId) {
13736
+ throw new Error("tailscale connect takes --client-id, the OAuth client's id from Tailscale's admin console (Settings, Trust credentials), with the scopes auth_keys and devices:core.");
13737
+ }
13738
+ const secret2 = (await client.readValue("The OAuth client's secret (not shown): ")).trim();
13739
+ if (!secret2.startsWith("tskey-client-")) {
13740
+ throw new Error("That is not a Tailscale OAuth client's secret, which starts tskey-client-. Nothing was sent.");
13741
+ }
13742
+ if (!secret2.startsWith(`tskey-client-${clientId}-`)) {
13743
+ throw new Error(`That secret is not client ${clientId}'s. Nothing was sent.`);
13744
+ }
13745
+ const { sealed } = await sealForAccount(client, SECRET_NAME, secret2, [SECRET_HOST], "tailscale-oauth");
13746
+ const body = await answer3(client, "/v1/integrations/tailscale", { method: "PUT", body: JSON.stringify({ clientId, clientSecret: sealed }) });
13747
+ out(flags2, body, `Tailscale: connected, OAuth client ${body.clientId}. Its secret was sealed here; only agental's servers open it, to mint each node a key.
13748
+ `);
13749
+ return;
13750
+ }
13751
+ if (verb === "disconnect") {
13752
+ if (!flags2.yes && !await client.confirmed("Take every sandbox off the tailnet and forget the OAuth client?")) {
13753
+ throw new Error("Nothing was disconnected. --yes disconnects without asking.");
13754
+ }
13755
+ await answer3(client, "/v1/integrations/tailscale", { method: "DELETE" });
13756
+ out(flags2, { connected: false }, "Tailscale: disconnected. Every sandbox was taken off the tailnet.\n");
13757
+ return;
13758
+ }
13759
+ throw new Error("tailscale takes connect, status or disconnect.");
13760
+ }
13761
+ function joinBody(flags2, withName) {
13762
+ const tags = (flags2.tag ?? []).flatMap((each) => each.split(",")).map((each) => each.trim()).filter((each) => each !== "");
13763
+ if (tags.length === 0) {
13764
+ throw new Error("join takes --tag, one tag:name or more, which the connected OAuth client owns: --tag tag:agental.");
13765
+ }
13766
+ if (!withName && flags2.nodeName !== void 0) {
13767
+ throw new Error("A template's sandboxes are each named by their own sandbox: --node-name is for one sandbox.");
13768
+ }
13769
+ return {
13770
+ tags,
13771
+ ...flags2.accept === void 0 ? {} : { acceptRoutes: flags2.accept.flatMap((each) => each.split(",")).map((each) => each.trim()).filter((each) => each !== "") },
13772
+ ...flags2.exitNode === void 0 ? {} : { exitNode: flags2.exitNode },
13773
+ ...flags2.keepAddress ? { keepAddress: true } : {},
13774
+ ...withName && flags2.nodeName !== void 0 ? { name: flags2.nodeName } : {}
13775
+ };
13776
+ }
13777
+ function nodeInWords(node, whose) {
13778
+ if (!node.on) {
13779
+ return `${whose}: on no tailnet
13780
+ `;
13781
+ }
13782
+ return [
13783
+ `${whose}: on the tailnet${node.name ? ` as ${node.name}` : ""}, tagged ${node.tags.join(", ")}`,
13784
+ ...node.acceptRoutes.length > 0 ? [` routes: ${node.acceptRoutes.join(", ")}`] : [],
13785
+ ...node.exitNode !== null ? [` exit node: ${node.exitNode}`] : [],
13786
+ ` address: ${node.keepAddress ? "kept across stops and moves" : "new at each start"}`
13787
+ ].join("\n") + "\n";
13788
+ }
13789
+ async function tailnet(client, kind, positionals, flags2) {
13790
+ const [given, verb, ...rest] = positionals;
13791
+ if (given === void 0 || rest.length > 0) {
13792
+ throw new Error(`${kind === "sandbox" ? "tailnet" : "template tailnet"} takes <${kind}>, and then nothing, join with --tag, or off.`);
13793
+ }
13794
+ const id = kind === "sandbox" ? await sandboxIdOf2(client, given) : await client.templateId(given);
13795
+ const path6 = `/v1/${kind === "sandbox" ? "sandboxes" : "templates"}/${encodeURIComponent(id)}/tailnet`;
13796
+ const whose = kind === "sandbox" ? given : `${given}'s sandboxes from now on`;
13797
+ if (verb === void 0) {
13798
+ const node = await answer3(client, path6, { method: "GET" });
13799
+ out(flags2, node, nodeInWords(node, kind === "sandbox" ? given : `${given}'s sandboxes`));
13800
+ return;
13801
+ }
13802
+ if (verb === "join") {
13803
+ const node = await answer3(client, path6, { method: "PUT", body: JSON.stringify(joinBody(flags2, kind === "sandbox")) });
13804
+ out(flags2, node, nodeInWords(node, whose));
13805
+ return;
13806
+ }
13807
+ if (verb === "off") {
13808
+ await answer3(client, path6, { method: "DELETE" });
13809
+ out(flags2, { on: false }, `${whose}: on no tailnet
13810
+ `);
13811
+ return;
13812
+ }
13813
+ throw new Error(`${kind === "sandbox" ? "tailnet" : "template tailnet"} takes <${kind}>, and then nothing, join, or off.`);
13814
+ }
13815
+ function createTailnet(given, flags2 = {}) {
13816
+ const more = flags2.accept !== void 0 || flags2.exitNode !== void 0 || flags2.keepAddress === true || flags2.nodeName !== void 0;
13817
+ if (given === void 0) {
13818
+ if (more) {
13819
+ throw new Error("--accept, --exit-node, --keep-address and --node-name go with --tailnet <tags> on a create.");
13820
+ }
13821
+ return void 0;
13822
+ }
13823
+ if (given === "off") {
13824
+ return null;
13825
+ }
13826
+ return joinBody({ ...flags2, json: false, yes: false, tag: [given] }, true);
13827
+ }
13828
+
13655
13829
  // ../src/cli-sites.ts
13656
13830
  var USAGE9 = "site takes a sandbox, or list, add, rm, stats or analytics, then the sandbox. agental site --help shows each.";
13657
13831
  var ANALYTICS_USAGE = "site analytics takes on or off, then the sandbox and the site's id, or org, with on or off to change it.";
@@ -14004,10 +14178,10 @@ async function hidden(question) {
14004
14178
  const muted = lines;
14005
14179
  process.stderr.write(question);
14006
14180
  muted._writeToOutput = () => void 0;
14007
- lines.question("", (answer4) => {
14181
+ lines.question("", (answer5) => {
14008
14182
  lines.close();
14009
14183
  process.stderr.write("\n");
14010
- resolve(answer4.trim());
14184
+ resolve(answer5.trim());
14011
14185
  });
14012
14186
  });
14013
14187
  }
@@ -14153,7 +14327,7 @@ function whyClosed(code, reason2, error) {
14153
14327
  return `The terminal was closed (${code})${said ? `: ${said}` : ""}.`;
14154
14328
  }
14155
14329
  }
14156
- async function answer3(response) {
14330
+ async function answer4(response) {
14157
14331
  const body = await response.json().catch(() => null);
14158
14332
  if (!response.ok) {
14159
14333
  const error = body?.error;
@@ -14162,7 +14336,7 @@ async function answer3(response) {
14162
14336
  return body;
14163
14337
  }
14164
14338
  async function keptShells2(client, id) {
14165
- const body = await answer3(await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminals`, { method: "GET" }));
14339
+ const body = await answer4(await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminals`, { method: "GET" }));
14166
14340
  if (!body || !Array.isArray(body.terminals)) {
14167
14341
  throw new Error("The list of kept shells was missing terminals.");
14168
14342
  }
@@ -14216,7 +14390,7 @@ async function listShells(client, id, json3, stdout) {
14216
14390
  }
14217
14391
  async function closeShell(client, id, given, stdout) {
14218
14392
  const found = await shellNamed(client, id, given, "--close");
14219
- await answer3(await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminals/${encodeURIComponent(found.id)}`, { method: "DELETE" }));
14393
+ await answer4(await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminals/${encodeURIComponent(found.id)}`, { method: "DELETE" }));
14220
14394
  stdout.write(`Closed ${found.n === null ? "shell" : `shell ${found.n}`} (${found.id}).
14221
14395
  `);
14222
14396
  }
@@ -14297,16 +14471,16 @@ async function shell(client, id, options = {}, streams = process) {
14297
14471
  let closedHere = false;
14298
14472
  let detached = false;
14299
14473
  const escaped = (chunk) => {
14300
- const out = [];
14474
+ const out2 = [];
14301
14475
  for (const byte of chunk) {
14302
- const before = out.length > 0 ? out[out.length - 1] : lastSent;
14476
+ const before = out2.length > 0 ? out2[out2.length - 1] : lastSent;
14303
14477
  const atLineStart = before === 13 || before === 10;
14304
14478
  if (tilde) {
14305
14479
  tilde = false;
14306
14480
  if (byte === 46) {
14307
14481
  closedHere = true;
14308
14482
  socket.close(1e3, "closed");
14309
- return Buffer.from(out);
14483
+ return Buffer.from(out2);
14310
14484
  }
14311
14485
  if (byte === 100) {
14312
14486
  if (kept2 === null) {
@@ -14315,19 +14489,19 @@ async function shell(client, id, options = {}, streams = process) {
14315
14489
  }
14316
14490
  detached = true;
14317
14491
  socket.close(1e3, "detached");
14318
- return Buffer.from(out);
14492
+ return Buffer.from(out2);
14319
14493
  }
14320
- out.push(126);
14494
+ out2.push(126);
14321
14495
  if (byte !== 126) {
14322
- out.push(byte);
14496
+ out2.push(byte);
14323
14497
  }
14324
14498
  } else if (byte === 126 && atLineStart) {
14325
14499
  tilde = true;
14326
14500
  } else {
14327
- out.push(byte);
14501
+ out2.push(byte);
14328
14502
  }
14329
14503
  }
14330
- return Buffer.from(out);
14504
+ return Buffer.from(out2);
14331
14505
  };
14332
14506
  const typed = (chunk) => {
14333
14507
  const bytes4 = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
@@ -14885,6 +15059,13 @@ async function main() {
14885
15059
  "allow-from": { type: "string", multiple: true },
14886
15060
  // Tags as a sandbox or template is made with them, or as list finds them: given again, or with commas, for several. --tags is the same.
14887
15061
  tag: { type: "string", multiple: true },
15062
+ // Tailscale (src/cli-tailscale.ts): the OAuth client's id, a node's routes, exit node, address and name, and a create's tags.
15063
+ "client-id": { type: "string" },
15064
+ accept: { type: "string", multiple: true },
15065
+ "exit-node": { type: "string" },
15066
+ "keep-address": { type: "boolean" },
15067
+ "node-name": { type: "string" },
15068
+ tailnet: { type: "string" },
14888
15069
  tags: { type: "string", multiple: true },
14889
15070
  // Metadata as <key>=<value>, given again for each key.
14890
15071
  meta: { type: "string", multiple: true },
@@ -15049,6 +15230,12 @@ async function main() {
15049
15230
  case "egress":
15050
15231
  await egress(positionals.slice(1), values);
15051
15232
  return;
15233
+ case "tailscale":
15234
+ await tailscale(tailscaleClient(), positionals.slice(1), tailnetFlags(values));
15235
+ return;
15236
+ case "tailnet":
15237
+ await tailnet(tailscaleClient(), "sandbox", positionals.slice(1), tailnetFlags(values));
15238
+ return;
15052
15239
  case "spot":
15053
15240
  await spot(positionals.slice(1), values);
15054
15241
  return;
@@ -15200,6 +15387,12 @@ async function create(values) {
15200
15387
  }
15201
15388
  const allow = values.allow === void 0 ? void 0 : listedIn(values.allow);
15202
15389
  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.");
15390
+ const tailnetAsked = createTailnet(values.tailnet, {
15391
+ ...values.accept === void 0 ? {} : { accept: values.accept },
15392
+ ...values["exit-node"] === void 0 ? {} : { exitNode: values["exit-node"] },
15393
+ ...values["keep-address"] === void 0 ? {} : { keepAddress: values["keep-address"] },
15394
+ ...values["node-name"] === void 0 ? {} : { nodeName: values["node-name"] }
15395
+ });
15203
15396
  const sshKeys2 = values["ssh-key"] === void 0 ? void 0 : publicKeysFrom(values["ssh-key"]);
15204
15397
  const box = boxNamed(values.box);
15205
15398
  if (box !== void 0 && PUBLISHED) {
@@ -15218,6 +15411,7 @@ async function create(values) {
15218
15411
  ...regionsOption(values.region),
15219
15412
  ...allow ? { network: { allow } } : {},
15220
15413
  ...egressAsked ? { egress: egressAsked } : {},
15414
+ ...tailnetAsked === void 0 ? {} : { tailnet: tailnetAsked },
15221
15415
  ...ttlSeconds === void 0 ? {} : { ttlSeconds },
15222
15416
  ...onTimeout === void 0 ? {} : { onTimeout: onTimeout.replaceAll("-", "_") },
15223
15417
  ...spotAsked === void 0 ? {} : { spot: spotAsked },
@@ -15475,6 +15669,21 @@ async function typedCount(count) {
15475
15669
  lines.close();
15476
15670
  }
15477
15671
  }
15672
+ function tailscaleClient() {
15673
+ return { request, fail, confirmed, readValue: hiddenValue, templateId: async (given) => (await templateNamed(given)).id };
15674
+ }
15675
+ function tailnetFlags(values) {
15676
+ return {
15677
+ json: values.json,
15678
+ yes: values.yes,
15679
+ ...values["client-id"] === void 0 ? {} : { clientId: values["client-id"] },
15680
+ ...values.tag === void 0 ? {} : { tag: values.tag },
15681
+ ...values.accept === void 0 ? {} : { accept: values.accept },
15682
+ ...values["exit-node"] === void 0 ? {} : { exitNode: values["exit-node"] },
15683
+ ...values["keep-address"] === void 0 ? {} : { keepAddress: values["keep-address"] },
15684
+ ...values["node-name"] === void 0 ? {} : { nodeName: values["node-name"] }
15685
+ };
15686
+ }
15478
15687
  async function hiddenValue(prompt) {
15479
15688
  if (!process.stdin.isTTY) {
15480
15689
  process.stderr.write(`${prompt.replace(/: $/, "")}: read from stdin
@@ -16464,7 +16673,7 @@ function showTemplate(each) {
16464
16673
  }
16465
16674
  async function template(positionals, values) {
16466
16675
  const [action, first, ...rest] = positionals;
16467
- const usage = "template takes create, show, rename, delete, start, network, egress, ssh, ssh-keys, tags, meta, sandboxes, apply, of or put. agental template --help says how.";
16676
+ const usage = "template takes create, show, rename, delete, start, network, egress, tailnet, ssh, ssh-keys, tags, meta, sandboxes, apply, of or put. agental template --help says how.";
16468
16677
  const print4 = (body, words2) => {
16469
16678
  process.stdout.write(values.json ? `${JSON.stringify(body, null, 2)}
16470
16679
  ` : words2);
@@ -16584,6 +16793,9 @@ ${mode === void 0 ? "" : "A sandbox on it takes this when it next starts, or now
16584
16793
  );
16585
16794
  return;
16586
16795
  }
16796
+ case "tailnet":
16797
+ await tailnet(tailscaleClient(), "template", [need(first, "<template>"), ...rest], tailnetFlags(values));
16798
+ return;
16587
16799
  case "egress": {
16588
16800
  const found = await templateNamed(need(first, "<template>"));
16589
16801
  const path6 = `/v1/templates/${encodeURIComponent(found.id)}/egress`;
@@ -16871,8 +17083,8 @@ async function metrics(id, asked2) {
16871
17083
  if (!response.ok) {
16872
17084
  fail(response.status, body);
16873
17085
  }
16874
- const answer4 = body && typeof body === "object" ? body : {};
16875
- const fromTo = typeof answer4["since"] === "string" && typeof answer4["until"] === "string" ? ` from ${answer4["since"]} to ${answer4["until"]}` : "";
17086
+ const answer5 = body && typeof body === "object" ? body : {};
17087
+ const fromTo = typeof answer5["since"] === "string" && typeof answer5["until"] === "string" ? ` from ${answer5["since"]} to ${answer5["until"]}` : "";
16876
17088
  if (asked2.json) {
16877
17089
  process.stdout.write(`${JSON.stringify(body, null, 2)}
16878
17090
  `);
@@ -16897,26 +17109,26 @@ async function metrics(id, asked2) {
16897
17109
  ])
16898
17110
  );
16899
17111
  }
16900
- if (answer4["complete"] === false) {
17112
+ if (answer5["complete"] === false) {
16901
17113
  process.stderr.write(
16902
17114
  id === void 0 ? "A server did not answer, so a sandbox on it has no reading here though it may have been running. Ask again in a minute.\n" : `A server did not answer, so readings may be missing: those from any time ${id} was on that server. Ask again in a minute.
16903
17115
  `
16904
17116
  );
16905
17117
  }
16906
17118
  }
16907
- async function account2(positionals, out) {
17119
+ async function account2(positionals, out2) {
16908
17120
  if (positionals[0] !== "export" || positionals.length > 1) {
16909
17121
  throw new Error("account takes export [--out <file>]. An account is closed from Settings in the console: a key cannot close one.");
16910
17122
  }
16911
17123
  const body = await asked("/v1/me/export", { method: "GET" });
16912
17124
  const text = `${JSON.stringify(body, null, 2)}
16913
17125
  `;
16914
- if (out === void 0) {
17126
+ if (out2 === void 0) {
16915
17127
  process.stdout.write(text);
16916
17128
  return;
16917
17129
  }
16918
- writeFileSync5(out, text, { mode: 384 });
16919
- process.stdout.write(`Written to ${out}.
17130
+ writeFileSync5(out2, text, { mode: 384 });
17131
+ process.stdout.write(`Written to ${out2}.
16920
17132
  `);
16921
17133
  }
16922
17134
  async function dataRetention(positionals, asJson) {
@@ -16940,8 +17152,8 @@ async function dataRetention(positionals, asJson) {
16940
17152
  `);
16941
17153
  return;
16942
17154
  }
16943
- const answer4 = body ?? {};
16944
- const days = answer4.keepDays ?? null;
17155
+ const answer5 = body ?? {};
17156
+ const days = answer5.keepDays ?? null;
16945
17157
  const kept2 = days === null ? "until their sandbox is deleted" : days === 1 ? "1 day" : `${days} days`;
16946
17158
  process.stdout.write(`${period === void 0 ? "" : "Saved. "}Command output, agent conversations and events are kept ${kept2}.
16947
17159
  `);
@@ -16949,7 +17161,7 @@ async function dataRetention(positionals, asJson) {
16949
17161
  process.stdout.write(`What is older is deleted within the hour, and cannot be brought back.
16950
17162
  `);
16951
17163
  }
16952
- const last = answer4.lastCleared;
17164
+ const last = answer5.lastCleared;
16953
17165
  if (period === void 0) {
16954
17166
  process.stdout.write(
16955
17167
  last ? `Last clean-up ${last.at}: ${last.commands} commands' output, ${last.conversations} conversations and ${last.events} events deleted.
@@ -17507,11 +17719,11 @@ function describeAutoReload(autoReload) {
17507
17719
  return `${wholeMoney(autoReload.dollars * 1e6)}${adds} charged to your saved card when your credits run out, before anything is stopped. At most 3 times a day.`;
17508
17720
  }
17509
17721
  function pricesForPeople(body) {
17510
- const out = [];
17722
+ const out2 = [];
17511
17723
  const count = (value) => value === void 0 || value === null ? "" : value.toLocaleString("en-US");
17512
17724
  const section = (title, rows, notes) => {
17513
17725
  const table4 = fitted(rows, { paint: (cell, row) => row === 0 ? faint(cell) : cell }).trimEnd().split("\n");
17514
- out.push(strong(title), ...table4.map((line) => ` ${line}`), ...notes.map((note) => ` ${faint(note)}`), "");
17726
+ out2.push(strong(title), ...table4.map((line) => ` ${line}`), ...notes.map((note) => ` ${faint(note)}`), "");
17515
17727
  };
17516
17728
  if (body.tiers?.length) {
17517
17729
  section(
@@ -17566,68 +17778,68 @@ function pricesForPeople(body) {
17566
17778
  also.push(["Snapshots", `the ${body.storage.freeSnapshots} oldest free, then $${(body.storage.snapshotMicrosPerHour * 730 / 1e6).toFixed(2)} a month each`]);
17567
17779
  }
17568
17780
  if (also.length > 0) {
17569
- out.push(strong("Also"), ...fitted(also).trimEnd().split("\n").map((line) => ` ${line}`), "");
17781
+ out2.push(strong("Also"), ...fitted(also).trimEnd().split("\n").map((line) => ` ${line}`), "");
17570
17782
  }
17571
- out.push(faint("agental billing top-up <dollars> \xB7 agental limits budget <dollars> \xB7 https://agental.io/pricing"));
17572
- return `${out.join("\n")}
17783
+ out2.push(faint("agental billing top-up <dollars> \xB7 agental limits budget <dollars> \xB7 https://agental.io/pricing"));
17784
+ return `${out2.join("\n")}
17573
17785
  `;
17574
17786
  }
17575
17787
  function describePrices(body) {
17576
- const out = [];
17788
+ const out2 = [];
17577
17789
  if (body.tiers?.length) {
17578
17790
  const withSizes = body.tiers.some((tier) => tier.sizes !== void 0);
17579
- out.push(withSizes ? "Plans, a month, and the sizes each makes" : "Plans, a month");
17791
+ out2.push(withSizes ? "Plans, a month, and the sizes each makes" : "Plans, a month");
17580
17792
  for (const tier of body.tiers) {
17581
17793
  const sizes = tier.sizes === void 0 ? "" : tier.sizes.length === body.plans.length ? "every size" : tier.sizes.join(", ");
17582
17794
  const speed = tier.runningUnits !== void 0 && tier.freeBurstUnits !== void 0 ? `${tier.runningUnits.toLocaleString("en-US")} running, ${tier.freeBurstUnits.toLocaleString("en-US")} free starts` : tier.burst ? `${(tier.burst.perQuarterMb / 1024).toLocaleString("en-US")} GiB per 15 minutes` : typeof tier.sandboxesAtOnce === "number" ? `${tier.sandboxesAtOnce.toLocaleString("en-US")} sandboxes at once` : "";
17583
17795
  const price = tier.dollarsPerMonth === 0 ? "Free" : `$${tier.dollarsPerMonth.toLocaleString("en-US")}`;
17584
17796
  const included = tier.dollarsPerMonth === 0 ? body.free ? `${wholeOrCents(body.free.allowanceMicros)} free, then as you go` : "pay as you go" : `${wholeMoney(tier.includedMicros)} of credits`;
17585
- out.push(` ${price.padEnd(8)}${included.padEnd(28)}${speed.padEnd(34)}${sizes}`.trimEnd());
17797
+ out2.push(` ${price.padEnd(8)}${included.padEnd(28)}${speed.padEnd(34)}${sizes}`.trimEnd());
17586
17798
  }
17587
17799
  if (body.free) {
17588
- out.push(
17800
+ out2.push(
17589
17801
  ` Free needs a card saved, charged nothing. Each month's first ${wholeOrCents(body.free.allowanceMicros)} of use is free: 185 hours of a small sandbox, 370 of a tiny one, or 11,100 CI minutes on small. It runs ${body.free.unpaidUnits} units at once until you buy a top-up.`
17590
17802
  );
17591
17803
  }
17592
17804
  if (body.tiers.some((tier) => tier.runningUnits !== void 0)) {
17593
- out.push(" Counted in units: a tiny sandbox is 1, a small 2, a medium 4, a large 8. Free starts are in any 15 minutes.");
17805
+ out2.push(" Counted in units: a tiny sandbox is 1, a small 2, a medium 4, a large 8. Free starts are in any 15 minutes.");
17594
17806
  }
17595
17807
  }
17596
17808
  if (body.burstFee) {
17597
- out.push(
17809
+ out2.push(
17598
17810
  `A start past your free starts in any ${body.burstFee.windowMinutes} minutes costs one hour of its price: $${body.burstFee.feeMicrosPerUnit / 1e6} a unit, $0.027 a small, $0.108 a large. At most ${wholeMoney(body.burstFee.defaultBudgetMicros)} a month unless you set another budget: agental limits budget <dollars>.`
17599
17811
  );
17600
17812
  }
17601
17813
  if (body.topUps?.length) {
17602
17814
  const range = body.topUpRange;
17603
- out.push(
17815
+ out2.push(
17604
17816
  range ? `Top-ups, any whole number of dollars from ${wholeMoney(range.minDollars * 1e6)} to ${wholeMoney(range.maxDollars * 1e6)}, used after the plan's credits. They do not expire.` : "Top-ups, used after the plan's credits. They do not expire."
17605
17817
  );
17606
17818
  if (body.topUps.some((topUp) => topUp.micros !== void 0)) {
17607
17819
  for (const topUp of body.topUps) {
17608
17820
  const bonus = topUp.bonusPercent ? `+${topUp.bonusPercent}%` : "";
17609
- out.push(` ${`$${topUp.dollars.toLocaleString("en-US")}`.padEnd(10)}${bonus.padEnd(10)}${`adds ${wholeMoney(topUp.micros ?? topUp.dollars * 1e6)}`}`);
17821
+ out2.push(` ${`$${topUp.dollars.toLocaleString("en-US")}`.padEnd(10)}${bonus.padEnd(10)}${`adds ${wholeMoney(topUp.micros ?? topUp.dollars * 1e6)}`}`);
17610
17822
  }
17611
17823
  } else {
17612
- out.push(` ${body.topUps.map((topUp) => `$${topUp.dollars}`).join(" ")}`);
17824
+ out2.push(` ${body.topUps.map((topUp) => `$${topUp.dollars}`).join(" ")}`);
17613
17825
  }
17614
17826
  if (body.topUpBonus) {
17615
17827
  const bonus = body.topUpBonus;
17616
- out.push(
17828
+ out2.push(
17617
17829
  ` From ${wholeMoney(bonus.fromDollars * 1e6)} a top-up adds a bonus: ${bonus.fromPercent}% there, growing evenly on a log scale to ${bonus.toPercent}% at ${wholeMoney(bonus.toDollars * 1e6)} and over.`
17618
17830
  );
17619
17831
  }
17620
17832
  }
17621
- out.push("Sizes, an hour at list price");
17833
+ out2.push("Sizes, an hour at list price");
17622
17834
  for (const size2 of body.plans) {
17623
- out.push(` ${size2.size.padEnd(8)}${`${size2.vcpu} vCPU, ${size2.memoryMb / 1024} GiB`.padEnd(20)}$${size2.listPriceMicrosPerHour / 1e6}`);
17835
+ out2.push(` ${size2.size.padEnd(8)}${`${size2.vcpu} vCPU, ${size2.memoryMb / 1024} GiB`.padEnd(20)}$${size2.listPriceMicrosPerHour / 1e6}`);
17624
17836
  }
17625
17837
  if (body.storage) {
17626
17838
  const month = body.storage.snapshotMicrosPerHour * 730 / 1e6;
17627
- out.push(stoppedWords(body.storage));
17628
- out.push(`Snapshots: the ${body.storage.freeSnapshots} oldest are free, and each one past them is $${month.toFixed(2)} a month, by the second.`);
17839
+ out2.push(stoppedWords(body.storage));
17840
+ out2.push(`Snapshots: the ${body.storage.freeSnapshots} oldest are free, and each one past them is $${month.toFixed(2)} a month, by the second.`);
17629
17841
  }
17630
- return `${out.join("\n")}
17842
+ return `${out2.join("\n")}
17631
17843
  `;
17632
17844
  }
17633
17845
  function stoppedWords(storage) {
@@ -17650,10 +17862,10 @@ async function showLimits(positionals, options) {
17650
17862
  `);
17651
17863
  return;
17652
17864
  }
17653
- const answer4 = body2 && typeof body2 === "object" ? body2 : {};
17654
- const spent = typeof answer4["spentMicros"] === "number" ? answer4["spentMicros"] : 0;
17655
- const budget = typeof answer4["budgetMicros"] === "number" ? answer4["budgetMicros"] : 0;
17656
- process.stdout.write(`Budget for burst fees: ${money(budget)} a month${answer4["budgetSet"] === true ? "" : " (the default)"}; ${money(spent)} spent this month.
17865
+ const answer5 = body2 && typeof body2 === "object" ? body2 : {};
17866
+ const spent = typeof answer5["spentMicros"] === "number" ? answer5["spentMicros"] : 0;
17867
+ const budget = typeof answer5["budgetMicros"] === "number" ? answer5["budgetMicros"] : 0;
17868
+ process.stdout.write(`Budget for burst fees: ${money(budget)} a month${answer5["budgetSet"] === true ? "" : " (the default)"}; ${money(spent)} spent this month.
17657
17869
  `);
17658
17870
  return;
17659
17871
  }
@@ -17683,8 +17895,8 @@ async function showLimits(positionals, options) {
17683
17895
  process.stdout.write(describeLimits(body, options.from === void 0 && options.to === void 0, options.to === void 0));
17684
17896
  }
17685
17897
  function describeLimits(body, today, endsNow) {
17686
- const answer4 = body && typeof body === "object" ? body : {};
17687
- const now = answer4["now"] && typeof answer4["now"] === "object" ? answer4["now"] : {};
17898
+ const answer5 = body && typeof body === "object" ? body : {};
17899
+ const now = answer5["now"] && typeof answer5["now"] === "object" ? answer5["now"] : {};
17688
17900
  const number = (from, name) => typeof from[name] === "number" ? from[name] : 0;
17689
17901
  const units = (mb) => {
17690
17902
  const value = mb / 2048;
@@ -17694,11 +17906,11 @@ function describeLimits(body, today, endsNow) {
17694
17906
  const at4 = new Date(iso).toISOString();
17695
17907
  return at4.slice(0, 10) === (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) ? `${at4.slice(11, 16)} UTC` : `${at4.slice(0, 10)} ${at4.slice(11, 16)} UTC`;
17696
17908
  };
17697
- const range = today ? "today (UTC)" : `from ${String(answer4["from"] ?? "")} to ${String(answer4["to"] ?? "")}`;
17909
+ const range = today ? "today (UTC)" : `from ${String(answer5["from"] ?? "")} to ${String(answer5["to"] ?? "")}`;
17698
17910
  const lines = [
17699
- `running: ${units(number(now, "runningMb"))} of ${number(now, "runningUnits").toLocaleString("en-US")} units (a tiny is 1, a small 2, a medium 4, a large 8); at the running count ${duration(number(answer4, "atRunningCountMs"))} ${range}`
17911
+ `running: ${units(number(now, "runningMb"))} of ${number(now, "runningUnits").toLocaleString("en-US")} units (a tiny is 1, a small 2, a medium 4, a large 8); at the running count ${duration(number(answer5, "atRunningCountMs"))} ${range}`
17700
17912
  ];
17701
- const bursts = Array.isArray(answer4["bursts"]) ? answer4["bursts"] : [];
17913
+ const bursts = Array.isArray(answer5["bursts"]) ? answer5["bursts"] : [];
17702
17914
  const open = endsNow ? bursts.find((one) => one["endedAt"] === null && typeof one["startedAt"] === "string") : void 0;
17703
17915
  const over = number(now, "overMb") > 0;
17704
17916
  const nextStart = Array.isArray(now["nextStart"]) ? now["nextStart"] : [];
@@ -17714,7 +17926,7 @@ function describeLimits(body, today, endsNow) {
17714
17926
  const budgetMonth = now["budgetMonth"] && typeof now["budgetMonth"] === "object" ? now["budgetMonth"] : null;
17715
17927
  const since = typeof budgetMonth?.start === "string" && budgetMonth.start.slice(8, 10) !== "01" ? ` (since ${shortDayOf(budgetMonth.start)})` : "";
17716
17928
  lines.push(`fees: ${money(number(now, "spentMicros"))} this month${since} of a ${money(number(now, "budgetMicros"))} budget`);
17717
- const refused2 = answer4["refused"] && typeof answer4["refused"] === "object" ? answer4["refused"] : {};
17929
+ const refused2 = answer5["refused"] && typeof answer5["refused"] === "object" ? answer5["refused"] : {};
17718
17930
  const total = number(refused2, "total");
17719
17931
  const byReason = Array.isArray(refused2["byReason"]) ? refused2["byReason"] : [];
17720
17932
  lines.push(
@@ -18063,6 +18275,8 @@ Usage
18063
18275
  agental auto-stop <sandbox-id> [--in <time> | --at <date-time> | --never] [--json]
18064
18276
  agental network <sandbox-id> [--allow <address-or-name>[,<address-or-name>...] | --none] [--json]
18065
18277
  agental egress <sandbox-id> [box | residential <country> [sticky | rotating]] [--json]
18278
+ agental tailscale [status | connect --client-id <id> | disconnect [--yes]] [--json]
18279
+ agental tailnet <sandbox-id> [join --tag <tag>... [--accept <range>]... [--exit-node <ip>] [--keep-address] [--node-name <name>] | off] [--json]
18066
18280
  agental spot <sandbox-id> [off] [--on-reclaim delete|stop] [--warn-at <chance>] [--json]
18067
18281
  agental templates [--json]
18068
18282
  agental template create <name> [--tag <tag>[,<tag>...]]... [--meta <key>=<value>]...
@@ -18072,6 +18286,7 @@ Usage
18072
18286
  agental template start <template> [--size tiny|small|medium|large] [--snapshot <snapshot-id> | --new-machine] [--ttl <time> | --ttl default] [--region <region> | --region default] [--spot [--on-reclaim delete|stop] [--warn-at <chance>] | --standard]
18073
18287
  agental template network <template> [open | blocked | allowlist <address-or-name>...] [--json]
18074
18288
  agental template egress <template> [box | residential <country> [sticky | rotating]] [--json]
18289
+ agental template tailnet <template> [join --tag <tag>... [--accept <range>]... [--exit-node <ip>] [--keep-address] | off] [--json]
18075
18290
  agental template ssh <template> [on | off] [--json]
18076
18291
  agental template ssh-keys <template> [<public-key-or-file>... | --remove <key-id>] [--json]
18077
18292
  agental template tags <template> [add|rm <tag>...] [--json]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agental",
3
- "version": "0.52.0",
3
+ "version": "0.54.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",