agental 0.14.1 → 0.16.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 +599 -137
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -39,14 +39,14 @@ var init_cli_operator = __esm({
39
39
 
40
40
  // ../src/cli.ts
41
41
  import { randomUUID as randomUUID2 } from "node:crypto";
42
- import { readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
42
+ import { readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
43
43
  import os6 from "node:os";
44
- import { readFile } from "node:fs/promises";
44
+ import { readFile as readFile2 } from "node:fs/promises";
45
45
  import { parseArgs } from "node:util";
46
46
 
47
47
  // ../src/cli-build.ts
48
48
  var PUBLISHED = true;
49
- var CLI_VERSION = true ? "0.14.1" : "dev";
49
+ var CLI_VERSION = true ? "0.16.0" : "dev";
50
50
  var DEFAULT_API_URL = true ? "https://agental.io" : "http://127.0.0.1:8741";
51
51
  var PACKAGE_NAME = "agental";
52
52
  var USER_AGENT = `agental-cli/${CLI_VERSION}`;
@@ -147,9 +147,9 @@ function plain(value, lines = false) {
147
147
  }
148
148
  function bytes(count) {
149
149
  const value = typeof count === "number" ? count : 0;
150
- for (const [unit, size] of [["GB", 1024 ** 3], ["MB", 1024 ** 2], ["KB", 1024]]) {
151
- if (value >= size) {
152
- return `${Number((value / size).toFixed(1))} ${unit}`;
150
+ for (const [unit, size2] of [["GB", 1024 ** 3], ["MB", 1024 ** 2], ["KB", 1024]]) {
151
+ if (value >= size2) {
152
+ return `${Number((value / size2).toFixed(1))} ${unit}`;
153
153
  }
154
154
  }
155
155
  return `${value} bytes`;
@@ -365,6 +365,137 @@ async function email(client, positionals, options) {
365
365
  }
366
366
  }
367
367
 
368
+ // ../src/cli-files.ts
369
+ import { readFile, writeFile } from "node:fs/promises";
370
+ var FILES_USAGE = [
371
+ "agental files <sandbox-id> ls [<folder>] [--json]",
372
+ "agental files <sandbox-id> cat <path>",
373
+ "agental files <sandbox-id> put <local-file> <path>",
374
+ "agental files <sandbox-id> get <path> [<local-file>]",
375
+ "agental files <sandbox-id> mkdir <folder>",
376
+ "agental files <sandbox-id> mv <from> <to>",
377
+ "agental files <sandbox-id> rm <path> [--recursive]"
378
+ ];
379
+ var USAGE2 = `files takes a sandbox's id and one of ls, cat, put, get, mkdir, mv and rm:
380
+ ${FILES_USAGE.join("\n ")}`;
381
+ var LIMIT = 1e7;
382
+ async function readObject2(response) {
383
+ try {
384
+ const body = await response.json();
385
+ return body && typeof body === "object" ? body : null;
386
+ } catch {
387
+ return null;
388
+ }
389
+ }
390
+ async function ask2(client, method, pathname, body) {
391
+ const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
392
+ if (response.status === 204) {
393
+ return {};
394
+ }
395
+ const answered = await readObject2(response);
396
+ if (!response.ok) {
397
+ client.fail(response.status, answered);
398
+ }
399
+ return answered ?? {};
400
+ }
401
+ function size(bytes3) {
402
+ if (bytes3 < 1e3) return `${bytes3} B`;
403
+ if (bytes3 < 1e6) return `${(bytes3 / 1e3).toFixed(1)} kB`;
404
+ return `${(bytes3 / 1e6).toFixed(1)} MB`;
405
+ }
406
+ async function files(client, args, options) {
407
+ const [sandboxId, verb, first, second] = args;
408
+ if (!sandboxId || !verb) {
409
+ throw new Error(USAGE2);
410
+ }
411
+ const base = `/v1/sandboxes/${encodeURIComponent(sandboxId)}`;
412
+ const need = (value, what) => {
413
+ if (!value) throw new Error(`files ${verb} needs ${what}.
414
+ ${USAGE2}`);
415
+ return value;
416
+ };
417
+ switch (verb) {
418
+ case "ls": {
419
+ const folder = first ?? "/opt/agental";
420
+ const body = await ask2(client, "GET", `${base}/folders?path=${encodeURIComponent(folder)}`);
421
+ if (options.json) {
422
+ process.stdout.write(`${JSON.stringify(body, null, 2)}
423
+ `);
424
+ return;
425
+ }
426
+ const entries = Array.isArray(body["entries"]) ? body["entries"] : [];
427
+ const width = Math.max(0, ...entries.map((entry) => (entry["kind"] === "folder" ? "" : size(Number(entry["bytes"]))).length));
428
+ for (const entry of entries) {
429
+ const name = String(entry["name"]) + (entry["kind"] === "folder" ? "/" : "") + (entry["kind"] === "link" ? ` -> ${String(entry["target"] ?? "")}` : "");
430
+ const bytes3 = entry["kind"] === "folder" ? "" : size(Number(entry["bytes"]));
431
+ process.stdout.write(`${bytes3.padStart(width)} ${String(entry["modifiedAt"] ?? "").slice(0, 16).replace("T", " ")} ${name}
432
+ `);
433
+ }
434
+ if (body["truncated"] === true) {
435
+ process.stderr.write("The folder holds more than the first 10,000 entries listed.\n");
436
+ }
437
+ return;
438
+ }
439
+ case "cat": {
440
+ const path5 = need(first, "a path");
441
+ const body = await ask2(client, "GET", `${base}/files?path=${encodeURIComponent(path5)}&encoding=base64`);
442
+ process.stdout.write(Buffer.from(String(body["base64"] ?? ""), "base64"));
443
+ return;
444
+ }
445
+ case "put": {
446
+ const local = need(first, "a local file and a path in the sandbox");
447
+ const path5 = need(second, "a path in the sandbox");
448
+ const bytes3 = await readFile(local);
449
+ if (bytes3.length > LIMIT) {
450
+ throw new Error(`${local} is ${size(bytes3.length)}, over the 10 MB files put sends. agental scp copies bigger ones.`);
451
+ }
452
+ const body = await ask2(client, "PUT", `${base}/files`, { path: path5, base64: bytes3.toString("base64") });
453
+ process.stdout.write(options.json ? `${JSON.stringify(body, null, 2)}
454
+ ` : `${String(body["path"])}: ${size(Number(body["bytes"]))}
455
+ `);
456
+ return;
457
+ }
458
+ case "get": {
459
+ const path5 = need(first, "a path");
460
+ const response = await client.request(`${base}/artifacts?path=${encodeURIComponent(path5)}`, { method: "GET", headers: { Accept: "application/octet-stream" } });
461
+ if (!response.ok) {
462
+ client.fail(response.status, await readObject2(response));
463
+ }
464
+ const bytes3 = Buffer.from(await response.arrayBuffer());
465
+ if (second) {
466
+ await writeFile(second, bytes3);
467
+ process.stderr.write(`${second}: ${size(bytes3.length)}
468
+ `);
469
+ } else {
470
+ process.stdout.write(bytes3);
471
+ }
472
+ return;
473
+ }
474
+ case "mkdir": {
475
+ const body = await ask2(client, "POST", `${base}/folders`, { path: need(first, "a folder") });
476
+ process.stdout.write(options.json ? `${JSON.stringify(body, null, 2)}
477
+ ` : `${String(body["path"])}
478
+ `);
479
+ return;
480
+ }
481
+ case "mv": {
482
+ const body = await ask2(client, "POST", `${base}/files/move`, { from: need(first, "where from and where to"), to: need(second, "where to") });
483
+ process.stdout.write(options.json ? `${JSON.stringify(body, null, 2)}
484
+ ` : `${String(body["from"])} -> ${String(body["to"])}
485
+ `);
486
+ return;
487
+ }
488
+ case "rm": {
489
+ const path5 = need(first, "a path");
490
+ await ask2(client, "DELETE", `${base}/files?path=${encodeURIComponent(path5)}${options.recursive ? "&recursive=true" : ""}`);
491
+ return;
492
+ }
493
+ default:
494
+ throw new Error(`files does not ${verb}.
495
+ ${USAGE2}`);
496
+ }
497
+ }
498
+
368
499
  // ../src/key-actions.ts
369
500
  var KEY_ACTIONS = [
370
501
  "sandbox.read",
@@ -424,10 +555,10 @@ var PRESETS = {
424
555
  var PRESET_NAMES = Object.keys(PRESETS);
425
556
 
426
557
  // ../src/cli-keys.ts
427
- var USAGE2 = "key takes add, show, allow-from or delete. agental key --help shows each.";
558
+ var USAGE3 = "key takes add, show, allow-from or delete. agental key --help shows each.";
428
559
  var HOUR_MS = 36e5;
429
560
  var SHOWN_ONCE = "is shown this once: only its hash is kept. Use it as AGENTAL_API_KEY, or as the Bearer token of each request.";
430
- async function ask2(client, method, pathname, body) {
561
+ async function ask3(client, method, pathname, body) {
431
562
  const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
432
563
  let answered = null;
433
564
  if (response.status !== 204) {
@@ -564,7 +695,7 @@ async function templateIdsOf(client, words2) {
564
695
  if (words2.every((word) => word.startsWith("tpl_"))) {
565
696
  return words2;
566
697
  }
567
- const body = await ask2(client, "GET", "/v1/templates");
698
+ const body = await ask3(client, "GET", "/v1/templates");
568
699
  const templates2 = Array.isArray(body?.templates) ? body.templates : [];
569
700
  return words2.map((word) => {
570
701
  if (word.startsWith("tpl_")) {
@@ -584,7 +715,7 @@ async function idOf(client, word, what) {
584
715
  if (word.startsWith("key_")) {
585
716
  return word;
586
717
  }
587
- const named = keysOf(await ask2(client, "GET", "/v1/api-keys")).filter((one) => one.name === word);
718
+ const named = keysOf(await ask3(client, "GET", "/v1/api-keys")).filter((one) => one.name === word);
588
719
  if (named.length === 0) {
589
720
  throw new Error(`There is no key named ${word}. agental keys lists them.`);
590
721
  }
@@ -594,7 +725,7 @@ async function idOf(client, word, what) {
594
725
  return named[0].id;
595
726
  }
596
727
  async function listKeys(client, asJson) {
597
- const body = await ask2(client, "GET", "/v1/api-keys");
728
+ const body = await ask3(client, "GET", "/v1/api-keys");
598
729
  if (asJson) {
599
730
  process.stdout.write(`${JSON.stringify(body, null, 2)}
600
731
  `);
@@ -611,7 +742,7 @@ async function listKeys(client, asJson) {
611
742
  async function key(client, positionals, options) {
612
743
  const [what, target, ...rest] = positionals;
613
744
  if (rest.length > 0 && what !== "allow-from") {
614
- throw new Error(what === "add" ? "key add takes one name: put a name with spaces in quotes." : USAGE2);
745
+ throw new Error(what === "add" ? "key add takes one name: put a name with spaces in quotes." : USAGE3);
615
746
  }
616
747
  switch (what) {
617
748
  case "add": {
@@ -627,7 +758,7 @@ async function key(client, positionals, options) {
627
758
  const allowFrom = listIn(options["allow-from"]);
628
759
  const templateIds = await templateIdsOf(client, listIn(options.template));
629
760
  const made = keyOf(
630
- await ask2(client, "POST", "/v1/api-keys", {
761
+ await ask3(client, "POST", "/v1/api-keys", {
631
762
  name: target,
632
763
  ...grant,
633
764
  ...sandboxIds.length > 0 ? { sandboxIds } : {},
@@ -653,7 +784,7 @@ async function key(client, positionals, options) {
653
784
  return;
654
785
  }
655
786
  case "show": {
656
- const found = keyOf(await ask2(client, "GET", `/v1/api-keys/${encodeURIComponent(await idOf(client, target, "show"))}`));
787
+ const found = keyOf(await ask3(client, "GET", `/v1/api-keys/${encodeURIComponent(await idOf(client, target, "show"))}`));
657
788
  process.stdout.write(options.json ? `${JSON.stringify(found, null, 2)}
658
789
  ` : describe(found));
659
790
  return;
@@ -670,7 +801,7 @@ async function key(client, positionals, options) {
670
801
  throw new Error(`key allow-from replaces the addresses a key may be used from: give each one, as agental key allow-from ${target} 203.0.113.0/24, or --anywhere to lift the limit.`);
671
802
  }
672
803
  const id = await idOf(client, target, "allow-from");
673
- const updated = keyOf(await ask2(client, "PUT", `/v1/api-keys/${encodeURIComponent(id)}/allow-from`, { allowFrom: options.anywhere ? [] : given }));
804
+ const updated = keyOf(await ask3(client, "PUT", `/v1/api-keys/${encodeURIComponent(id)}/allow-from`, { allowFrom: options.anywhere ? [] : given }));
674
805
  process.stdout.write(options.json ? `${JSON.stringify(updated, null, 2)}
675
806
  ` : `addresses: ${addressesOf(updated.allowFrom, true)}
676
807
  `);
@@ -680,12 +811,12 @@ async function key(client, positionals, options) {
680
811
  return;
681
812
  }
682
813
  case "delete": {
683
- await ask2(client, "DELETE", `/v1/api-keys/${encodeURIComponent(await idOf(client, target, "delete"))}`);
814
+ await ask3(client, "DELETE", `/v1/api-keys/${encodeURIComponent(await idOf(client, target, "delete"))}`);
684
815
  process.stdout.write("Deleted. Whatever holds the key is refused from its next request, and the sandboxes it made stay.\n");
685
816
  return;
686
817
  }
687
818
  default:
688
- throw new Error(USAGE2);
819
+ throw new Error(USAGE3);
689
820
  }
690
821
  }
691
822
 
@@ -763,10 +894,10 @@ async function whoIs(base, key2) {
763
894
  throw error;
764
895
  }
765
896
  }
766
- async function pushRequest(base, ask8) {
897
+ async function pushRequest(base, ask9) {
767
898
  let made;
768
899
  try {
769
- made = await call(base, "POST", "/v1/cli-sign-ins", ask8);
900
+ made = await call(base, "POST", "/v1/cli-sign-ins", ask9);
770
901
  } catch (error) {
771
902
  if (error instanceof Refused && (error.status === 401 || error.status === 404)) {
772
903
  throw new Error(`${base} does not sign the command in through the browser. Make a key in its console, under API keys, and run agental login --key.`);
@@ -778,7 +909,7 @@ async function pushRequest(base, ask8) {
778
909
  async function listen() {
779
910
  let arrived = () => {
780
911
  };
781
- let answer = () => {
912
+ let answer2 = () => {
782
913
  };
783
914
  const next = new Promise((resolve) => arrived = resolve);
784
915
  let taken = false;
@@ -793,7 +924,7 @@ async function listen() {
793
924
  return;
794
925
  }
795
926
  taken = true;
796
- answer = (to) => response.writeHead(302, { location: to, "cache-control": "no-store" }).end();
927
+ answer2 = (to) => response.writeHead(302, { location: to, "cache-control": "no-store" }).end();
797
928
  arrived(url);
798
929
  });
799
930
  await new Promise((resolve, reject) => {
@@ -801,7 +932,7 @@ async function listen() {
801
932
  server.listen(0, "127.0.0.1", resolve);
802
933
  });
803
934
  const { port } = server.address();
804
- return { server, redirectUri: `http://127.0.0.1:${port}/callback`, next, answer: (to) => answer(to) };
935
+ return { server, redirectUri: `http://127.0.0.1:${port}/callback`, next, answer: (to) => answer2(to) };
805
936
  }
806
937
  async function browserSignIn(base, term, organizationId) {
807
938
  const verifier = randomBytes2(32).toString("base64url");
@@ -1001,7 +1132,7 @@ async function readAll(stream) {
1001
1132
  // ../src/cli-onboard.ts
1002
1133
  import { execFile, spawnSync as spawnSync3 } from "node:child_process";
1003
1134
  import { randomUUID, randomBytes as randomBytes3 } from "node:crypto";
1004
- import { existsSync as existsSync2, realpathSync, statSync } from "node:fs";
1135
+ import { existsSync as existsSync2, readFileSync as readFileSync3, realpathSync, statSync } from "node:fs";
1005
1136
  import os4 from "node:os";
1006
1137
  import path3 from "node:path";
1007
1138
  import { createInterface } from "node:readline/promises";
@@ -1050,7 +1181,7 @@ function publicKey() {
1050
1181
  throw new Error(`${key2}.pub could not be read. It is the public half of the key the CLI logs in with.`);
1051
1182
  }
1052
1183
  }
1053
- async function ask3(client, method, sandboxId, rest, body) {
1184
+ async function ask4(client, method, sandboxId, rest, body) {
1054
1185
  if (!SANDBOX_ID.test(sandboxId)) {
1055
1186
  throw new Error(`${sandboxId} is not a sandbox id. One looks like sbx_0123456789abcdef.`);
1056
1187
  }
@@ -1075,7 +1206,7 @@ async function reach(client, sandboxId, waitMs = 0) {
1075
1206
  const until2 = Date.now() + waitMs;
1076
1207
  for (; ; ) {
1077
1208
  try {
1078
- const access = accessIn(await ask3(client, "GET", sandboxId, "")) ?? accessIn(await ask3(client, "PUT", sandboxId, ""));
1209
+ const access = accessIn(await ask4(client, "GET", sandboxId, "")) ?? accessIn(await ask4(client, "PUT", sandboxId, ""));
1079
1210
  if (access) {
1080
1211
  pin(sandboxId, access.hostKey);
1081
1212
  return access;
@@ -1090,7 +1221,7 @@ async function reach(client, sandboxId, waitMs = 0) {
1090
1221
  }
1091
1222
  }
1092
1223
  async function letIn(client, sandboxId) {
1093
- await ask3(client, "POST", sandboxId, "/keys", { publicKey: publicKey() });
1224
+ await ask4(client, "POST", sandboxId, "/keys", { publicKey: publicKey() });
1094
1225
  }
1095
1226
  function pin(sandboxId, hostKey) {
1096
1227
  const file = knownHostsPath();
@@ -1258,9 +1389,9 @@ async function api(base, key2, method, pathname, body, headers = {}) {
1258
1389
  }
1259
1390
  return { status: response.status, body: parsed && typeof parsed === "object" ? parsed : {} };
1260
1391
  }
1261
- function errorOf(answer) {
1262
- const error = answer.body["error"] && typeof answer.body["error"] === "object" ? answer.body["error"] : {};
1263
- return { code: String(error["code"] ?? `http_${answer.status}`), message: String(error["message"] ?? `HTTP ${answer.status}`) };
1392
+ function errorOf(answer2) {
1393
+ const error = answer2.body["error"] && typeof answer2.body["error"] === "object" ? answer2.body["error"] : {};
1394
+ return { code: String(error["code"] ?? `http_${answer2.status}`), message: String(error["message"] ?? `HTTP ${answer2.status}`) };
1264
1395
  }
1265
1396
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1266
1397
  function real(file) {
@@ -1517,13 +1648,28 @@ async function newSandbox(base, key2, term) {
1517
1648
  }
1518
1649
  return { id, name, size: String(made.body["size"]) };
1519
1650
  }
1520
- async function hourly(base, key2, size) {
1651
+ async function hourly(base, key2, size2) {
1521
1652
  const prices = await api(base, key2, "GET", "/v1/billing/plans").catch(() => null);
1522
1653
  const plans = prices && Array.isArray(prices.body["plans"]) ? prices.body["plans"] : [];
1523
- const micros = plans.find((plan2) => plan2["size"] === size)?.["listPriceMicrosPerHour"];
1654
+ const micros = plans.find((plan2) => plan2["size"] === size2)?.["listPriceMicrosPerHour"];
1524
1655
  return typeof micros === "number" ? micros : null;
1525
1656
  }
1526
1657
  var perHour = (micros) => `$${(micros / 1e6).toFixed(micros < 1e5 ? 4 : 3)} an hour`;
1658
+ function completionStep(shell2 = process.env["SHELL"], home = os4.homedir()) {
1659
+ const name = path3.basename(shell2 ?? "");
1660
+ const config = name === "zsh" ? ".zshrc" : name === "bash" ? ".bashrc" : name === "fish" ? ".config/fish/config.fish" : null;
1661
+ if (config === null) {
1662
+ return null;
1663
+ }
1664
+ try {
1665
+ if (readFileSync3(path3.join(home, config), "utf8").includes("agental completion")) {
1666
+ return null;
1667
+ }
1668
+ } catch {
1669
+ }
1670
+ const line = name === "fish" ? "agental completion fish | source" : `source <(agental completion ${name})`;
1671
+ return [`echo '${line}' >> ~/${config}`, "Tab completion, from your next terminal"];
1672
+ }
1527
1673
  function nextSteps(term, rows) {
1528
1674
  const width = Math.max(...rows.map(([command2]) => command2.length));
1529
1675
  term.say(`
@@ -1567,11 +1713,13 @@ async function onboard(base, options) {
1567
1713
  };
1568
1714
  if (!options.sandbox) {
1569
1715
  await report();
1716
+ const completion = term.interactive ? completionStep() : null;
1570
1717
  nextSteps(term, [
1571
1718
  ["npx agental@latest sh", "make a sandbox and open a shell in it"],
1572
1719
  ["agental list", "your sandboxes"],
1573
1720
  ["agental ssh <id>", "a shell in one; add a command to run just that"],
1574
- ["agental help", "everything else"]
1721
+ ["agental help", "everything else; agental <command> --help for one"],
1722
+ ...completion ? [completion] : []
1575
1723
  ]);
1576
1724
  return;
1577
1725
  }
@@ -1634,7 +1782,7 @@ async function onboard(base, options) {
1634
1782
 
1635
1783
  // ../src/cli-completion.ts
1636
1784
  import { createHash as createHash2 } from "node:crypto";
1637
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "node:fs";
1785
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
1638
1786
  import os5 from "node:os";
1639
1787
  import path4 from "node:path";
1640
1788
 
@@ -1695,7 +1843,18 @@ var COMMANDS = [
1695
1843
  ["-- <command> [args...]", "what to run; everything after -- is the command's own"]
1696
1844
  ]
1697
1845
  },
1698
- { name: "shell", summary: "Open a login shell in a sandbox, in this terminal, with no SSH key or port.", examples: ["agental shell sbx_2a9a47e50daec64a"] },
1846
+ {
1847
+ name: "shell",
1848
+ summary: "Open a login shell in a sandbox, in this terminal, with no SSH key or port. It is kept: ~d leaves it running.",
1849
+ examples: ["agental shell sbx_2a9a47e50daec64a", "agental shell sbx_2a9a47e50daec64a --list", "agental shell sbx_2a9a47e50daec64a --attach 2"],
1850
+ flags: [
1851
+ ["--attach <shell>", "open a kept shell again, by its number or id, with what it printed meanwhile"],
1852
+ ["--list", "list the shells kept in the sandbox (--json for JSON)"],
1853
+ ["--close <shell>", "end a kept shell: what runs in it is sent SIGHUP"],
1854
+ ["~d", "typed at the start of a line: leave the shell running and exit"],
1855
+ ["~.", "typed at the start of a line: close the connection from here"]
1856
+ ]
1857
+ },
1699
1858
  {
1700
1859
  name: "ssh",
1701
1860
  summary: "Open a shell in a sandbox, or run a command there, over SSH.",
@@ -1706,6 +1865,11 @@ var COMMANDS = [
1706
1865
  ]
1707
1866
  },
1708
1867
  { name: "scp", summary: "Copy files to or from a sandbox over SSH.", examples: ["agental scp ./build.tar.gz sbx_2a9a47e50daec64a:/tmp/"] },
1868
+ {
1869
+ name: "files",
1870
+ summary: "List, print, send, fetch, move and delete a sandbox's files, anywhere on its machine, with no SSH.",
1871
+ examples: ["agental files sbx_2a9a47e50daec64a ls /etc", "agental files sbx_2a9a47e50daec64a put ./app.py app/app.py", "agental files sbx_2a9a47e50daec64a rm /tmp/build --recursive"]
1872
+ },
1709
1873
  { name: "ssh-config", summary: "Print a Host block for ~/.ssh/config, so anything that speaks SSH reaches a sandbox by its id.", examples: ["agental ssh-config sbx_2a9a47e50daec64a >> ~/.ssh/config"] },
1710
1874
  { name: "ssh-connect", summary: "Reach a sandbox for ssh: what the Host block ssh-config prints runs. It is not typed by hand." },
1711
1875
  { name: "ssh-keys", summary: "List or remove the SSH keys a sandbox lets in." },
@@ -1740,6 +1904,17 @@ var COMMANDS = [
1740
1904
  ]
1741
1905
  },
1742
1906
  { name: "recover", summary: "Get a stuck sandbox going again: what runs in it is killed, its disk is kept." },
1907
+ {
1908
+ name: "resize",
1909
+ summary: "Give a sandbox a larger size. A stopped one takes it at once; a running one at its next start, or now with --now. --cancel takes a waiting size away.",
1910
+ examples: ["agental resize sbx_2a9a47e50daec64a medium", "agental resize sbx_2a9a47e50daec64a medium --now", "agental resize sbx_2a9a47e50daec64a --cancel"],
1911
+ flags: [
1912
+ ["--now", "a running sandbox: restart it at the new size now, and every process in it ends"],
1913
+ ["--max-burst-fee <dollars>", "with --now: the most the restart's start may pay in burst fees"],
1914
+ ["--cancel", "take away a size that waits for its next start"],
1915
+ ["--json", "print the sandbox as JSON"]
1916
+ ]
1917
+ },
1743
1918
  { name: "auto-stop", summary: "Say when a running sandbox stops by itself, or that it never does.", examples: ["agental auto-stop sbx_2a9a47e50daec64a --in 2h", "agental auto-stop sbx_2a9a47e50daec64a --never"] },
1744
1919
  { name: "jobs", summary: "Follow or cancel the work started on many sandboxes at once." },
1745
1920
  { name: "tags", summary: "Read, add or remove a sandbox's tags.", examples: ["agental tags sbx_2a9a47e50daec64a add ci"] },
@@ -1828,7 +2003,7 @@ var COMMANDS = [
1828
2003
  { name: "org", summary: "List, switch and make the accounts you belong to." },
1829
2004
  { name: "members", summary: "List or remove the members of a team." },
1830
2005
  { name: "invite", summary: "Invite someone to your team by email." },
1831
- { name: "billing", summary: "Your plan, credits, invoices and card, and buying credits.", examples: ["agental billing", "agental billing invoices", "agental billing top-up 500"] },
2006
+ { name: "billing", summary: "Your plan, credits, invoices and card, and buying credits.", examples: ["agental billing", "agental billing invoices", "agental billing details", "agental billing top-up 500"] },
1832
2007
  { name: "headroom", summary: "How close you run to your plan's limits, and your burst budget." },
1833
2008
  { name: "account", summary: "Export everything agental keeps about your account and you." },
1834
2009
  { name: "login", summary: "Sign in through the browser, or with a key from standard input." },
@@ -1914,6 +2089,7 @@ var MAP = [
1914
2089
  [
1915
2090
  ["start, stop, delete", "one sandbox, or every one --where finds"],
1916
2091
  ["recover, auto-stop", "get a stuck one going, say when one stops"],
2092
+ ["resize", "a larger size, now or at its next start"],
1917
2093
  ["schedule", "run a command on a timer"],
1918
2094
  ["secret", "values and files kept out of the sandbox"],
1919
2095
  ["network, egress", "what it may reach, and the address it leaves from"],
@@ -1921,6 +2097,7 @@ var MAP = [
1921
2097
  ["metrics", "CPU, memory and disk over time"],
1922
2098
  ["email", "an email address of its own"],
1923
2099
  ["desktop, browser", "a screen and a Chrome in the sandbox"],
2100
+ ["files", "list, send, fetch, move and delete its files"],
1924
2101
  ["scp, ssh-config", "files, and SSH from any tool"],
1925
2102
  ["job, region", "work on many at once, and where they run"]
1926
2103
  ]
@@ -2165,7 +2342,7 @@ function sandboxIn(words2, valued = []) {
2165
2342
  // ../src/cli-completion.ts
2166
2343
  var SHELLS = ["zsh", "bash", "fish"];
2167
2344
  var SUBCOMMANDS = {
2168
- billing: ["prices", "invoices", "card", "top-up", "auto-reload"],
2345
+ billing: ["prices", "invoices", "card", "details", "top-up", "auto-reload"],
2169
2346
  // Each thing that lists as its plural lists as itself too.
2170
2347
  template: ["list"],
2171
2348
  key: ["list"],
@@ -2226,6 +2403,7 @@ function flagsOf(usages) {
2226
2403
  var SANDBOX = /^<sandbox-id>/;
2227
2404
  var SANDBOX_VERBS2 = /* @__PURE__ */ new Set(["list", "create", "start", "stop", "delete", "recover", "exec", "shell", "summary"]);
2228
2405
  var TEMPLATE = /^<template>/;
2406
+ var KEPT_SHELL = /^<shell>/;
2229
2407
  async function complete(typed, reference, operator, fetchJson) {
2230
2408
  if (typed[0] === "sandbox" && typed.length > 2 && SANDBOX_VERBS2.has(typed[1])) {
2231
2409
  return complete(typed.slice(1), reference, operator, fetchJson);
@@ -2271,6 +2449,10 @@ async function complete(typed, reference, operator, fetchJson) {
2271
2449
  if (SANDBOX.test(valueOf)) {
2272
2450
  return starting(await sandboxes(fetchJson));
2273
2451
  }
2452
+ if (KEPT_SHELL.test(valueOf)) {
2453
+ const sandbox = before.slice(1).find((word) => /^sbx_[A-Za-z0-9]+$/.test(word));
2454
+ return sandbox ? starting(await keptShells(fetchJson, sandbox)) : [];
2455
+ }
2274
2456
  const choices = valueOf.split("|").filter((word) => /^[a-z0-9][a-z0-9.-]*$/i.test(word));
2275
2457
  return starting(choices.map((value) => ({ value })));
2276
2458
  }
@@ -2325,17 +2507,30 @@ async function sandboxes(api2) {
2325
2507
  const body = await cached("sandboxes", api2.as, () => api2.get("/v1/sandboxes?limit=200"));
2326
2508
  return (body?.sandboxes ?? []).filter((each) => typeof each["id"] === "string").sort((a, b) => Number(b["status"] === "running") - Number(a["status"] === "running")).map((each) => ({ value: each["id"], about: [each["name"], each["status"]].filter((word) => typeof word === "string" && word).join(", ") }));
2327
2509
  }
2510
+ async function keptShells(api2, sandbox) {
2511
+ let listed;
2512
+ try {
2513
+ const body = await api2.get(`/v1/sandboxes/${encodeURIComponent(sandbox)}/terminals`);
2514
+ listed = Array.isArray(body?.terminals) ? body.terminals : [];
2515
+ } catch {
2516
+ return [];
2517
+ }
2518
+ return listed.filter((each) => Number.isInteger(each["n"])).map((each) => {
2519
+ const about = [typeof each["running"] === "string" ? each["running"] : each["exit"] ? "ended" : "", typeof each["cwd"] === "string" ? each["cwd"] : ""].filter(Boolean).join(", ");
2520
+ return about ? { value: String(each["n"]), about } : { value: String(each["n"]) };
2521
+ });
2522
+ }
2328
2523
  async function templates(api2) {
2329
2524
  const body = await cached("templates", api2.as, () => api2.get("/v1/templates"));
2330
2525
  const listed = Array.isArray(body) ? body : body?.templates ?? [];
2331
2526
  return listed.filter((each) => typeof each["name"] === "string").map((each) => ({ value: each["name"], about: each["default"] === true ? "the default" : void 0 }));
2332
2527
  }
2333
2528
  var KEPT_MS = 3e4;
2334
- async function cached(what, as, ask8) {
2529
+ async function cached(what, as, ask9) {
2335
2530
  const folder = path4.join(process.env["XDG_CACHE_HOME"] || path4.join(os5.homedir(), ".cache"), "agental");
2336
2531
  const file = path4.join(folder, `complete-${what}-${createHash2("sha256").update(as).digest("hex").slice(0, 16)}.json`);
2337
2532
  try {
2338
- const kept2 = JSON.parse(readFileSync3(file, "utf8"));
2533
+ const kept2 = JSON.parse(readFileSync4(file, "utf8"));
2339
2534
  if (Date.now() - kept2.at < KEPT_MS) {
2340
2535
  return kept2.body;
2341
2536
  }
@@ -2343,7 +2538,7 @@ async function cached(what, as, ask8) {
2343
2538
  }
2344
2539
  let body = null;
2345
2540
  try {
2346
- body = await ask8();
2541
+ body = await ask9();
2347
2542
  } catch {
2348
2543
  return null;
2349
2544
  }
@@ -2480,7 +2675,7 @@ function span(ms) {
2480
2675
  var ORG_USAGE = "org takes list, use <organization> or create <name>. agental org --help shows each.";
2481
2676
  var MEMBERS_USAGE = "members takes list, or remove <member> [--revoke-keys]. agental members --help shows each.";
2482
2677
  var ROLES = ["member", "admin"];
2483
- async function ask4(client, method, pathname, body) {
2678
+ async function ask5(client, method, pathname, body) {
2484
2679
  const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
2485
2680
  let answered = null;
2486
2681
  if (response.status !== 204) {
@@ -2503,8 +2698,8 @@ function print2(json, body, words2) {
2503
2698
  ` : words2);
2504
2699
  }
2505
2700
  async function organizations(client) {
2506
- const listed = (await ask4(client, "GET", "/v1/organizations"))["organizations"];
2507
- const me = await ask4(client, "GET", "/v1/me");
2701
+ const listed = (await ask5(client, "GET", "/v1/organizations"))["organizations"];
2702
+ const me = await ask5(client, "GET", "/v1/me");
2508
2703
  return { organizations: Array.isArray(listed) ? listed : [], acting: String(me["activeOrganizationId"] ?? "") };
2509
2704
  }
2510
2705
  function organizationNamed(list3, given) {
@@ -2560,7 +2755,7 @@ async function org(client, positionals, options, signInTo) {
2560
2755
  if (!name) {
2561
2756
  throw new Error("org create takes the team's name: agental org create Acme.");
2562
2757
  }
2563
- const made = await ask4(client, "POST", "/v1/organizations", { kind: "team", name });
2758
+ const made = await ask5(client, "POST", "/v1/organizations", { kind: "team", name });
2564
2759
  const organization = made["organization"] ?? {};
2565
2760
  print2(
2566
2761
  options.json,
@@ -2593,7 +2788,7 @@ function memberNamed(list3, given) {
2593
2788
  async function members(client, positionals, options) {
2594
2789
  const [verb = "list", target] = positionals;
2595
2790
  const team = await actingTeam(client);
2596
- const listed = await ask4(client, "GET", `/v1/organizations/${encodeURIComponent(team.id)}/members`);
2791
+ const listed = await ask5(client, "GET", `/v1/organizations/${encodeURIComponent(team.id)}/members`);
2597
2792
  const list3 = Array.isArray(listed["members"]) ? listed["members"] : [];
2598
2793
  switch (verb) {
2599
2794
  case "list": {
@@ -2618,7 +2813,7 @@ async function members(client, positionals, options) {
2618
2813
  }
2619
2814
  const member = memberNamed(list3, target);
2620
2815
  const query = options.revokeKeys ? "?revokeKeys=true" : "";
2621
- const removed = await ask4(client, "DELETE", `/v1/organizations/${encodeURIComponent(team.id)}/members/${encodeURIComponent(member.userId)}${query}`);
2816
+ const removed = await ask5(client, "DELETE", `/v1/organizations/${encodeURIComponent(team.id)}/members/${encodeURIComponent(member.userId)}${query}`);
2622
2817
  const revoked = Number(removed["revokedKeys"] ?? 0);
2623
2818
  print2(
2624
2819
  options.json,
@@ -2643,7 +2838,7 @@ async function invite(client, positionals, options) {
2643
2838
  throw new Error(`--role is member or admin, not ${role}. An owner is made from a member, in the console or with the API.`);
2644
2839
  }
2645
2840
  const team = await actingTeam(client);
2646
- const sent = await ask4(client, "POST", "/v1/invites", { email: email2, role });
2841
+ const sent = await ask5(client, "POST", "/v1/invites", { email: email2, role });
2647
2842
  const link = `/join?invite=${String(sent["id"] ?? "")}`;
2648
2843
  print2(
2649
2844
  options.json,
@@ -2655,9 +2850,9 @@ async function invite(client, positionals, options) {
2655
2850
  }
2656
2851
 
2657
2852
  // ../src/cli-schedules.ts
2658
- var USAGE3 = "schedule takes add, show, runs, run, pause, resume, update or delete. agental schedule --help shows each.";
2853
+ var USAGE4 = "schedule takes add, show, runs, run, pause, resume, update or delete. agental schedule --help shows each.";
2659
2854
  var OVERLAPS = ["skip", "replace", "parallel"];
2660
- async function ask5(client, method, pathname, body) {
2855
+ async function ask6(client, method, pathname, body) {
2661
2856
  const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
2662
2857
  let answered = null;
2663
2858
  if (response.status !== 204) {
@@ -2775,7 +2970,7 @@ function table2(rows) {
2775
2970
  return rows.map((row) => row.map((cell, column) => column === row.length - 1 ? cell : cell.padEnd((widths[column] ?? 0) + 2)).join("").trimEnd()).join("\n") + "\n";
2776
2971
  }
2777
2972
  async function listOf(client, sandboxId) {
2778
- const body = await ask5(client, "GET", `/v1/sandboxes/${encodeURIComponent(sandboxId)}/schedules`);
2973
+ const body = await ask6(client, "GET", `/v1/sandboxes/${encodeURIComponent(sandboxId)}/schedules`);
2779
2974
  return body?.schedules ?? [];
2780
2975
  }
2781
2976
  async function idOf2(client, sandboxId, given, verb) {
@@ -2816,7 +3011,7 @@ async function listSchedules(client, sandboxId, json) {
2816
3011
  async function schedule(client, positionals, options) {
2817
3012
  const [what, sandboxId, ...rest] = positionals;
2818
3013
  if (what === void 0) {
2819
- throw new Error(USAGE3);
3014
+ throw new Error(USAGE4);
2820
3015
  }
2821
3016
  if (sandboxId === void 0) {
2822
3017
  throw new Error(`schedule ${what} needs the sandbox: agental schedule ${what} <sandbox-id>${what === "add" ? " --every 1h -- <command>" : " <schedule>"}`);
@@ -2830,7 +3025,7 @@ async function schedule(client, positionals, options) {
2830
3025
  if (options.every === void 0 && options.cron === void 0 && options.at === void 0) {
2831
3026
  throw new Error('Say when it runs: --every 15m, 1h or 1d; --cron "0 7 * * 1-5" with --tz for its time zone; or --at 2026-11-04T09:00:00Z, once.');
2832
3027
  }
2833
- const made = await ask5(client, "POST", base, { command: commandLine(rest), ...fieldsOf(options) });
3028
+ const made = await ask6(client, "POST", base, { command: commandLine(rest), ...fieldsOf(options) });
2834
3029
  print3(made, options.json);
2835
3030
  return;
2836
3031
  }
@@ -2843,15 +3038,15 @@ async function schedule(client, positionals, options) {
2843
3038
  case "update": {
2844
3039
  const [target, ...command2] = rest;
2845
3040
  if (command2.length > 0 && what !== "update") {
2846
- throw new Error(USAGE3);
3041
+ throw new Error(USAGE4);
2847
3042
  }
2848
3043
  const id = await idOf2(client, sandboxId, target, what);
2849
3044
  const path5 = `${base}/${encodeURIComponent(id)}`;
2850
3045
  if (what === "show") {
2851
- print3(await ask5(client, "GET", path5), options.json);
3046
+ print3(await ask6(client, "GET", path5), options.json);
2852
3047
  } else if (what === "runs") {
2853
3048
  const limit = options.limit === void 0 ? "" : `?limit=${encodeURIComponent(options.limit)}`;
2854
- const runs = (await ask5(client, "GET", `${path5}/runs${limit}`))?.runs ?? [];
3049
+ const runs = (await ask6(client, "GET", `${path5}/runs${limit}`))?.runs ?? [];
2855
3050
  if (options.json) {
2856
3051
  process.stdout.write(`${JSON.stringify(runs, null, 2)}
2857
3052
  `);
@@ -2873,7 +3068,7 @@ async function schedule(client, positionals, options) {
2873
3068
  );
2874
3069
  }
2875
3070
  } else if (what === "run") {
2876
- const run2 = await ask5(client, "POST", `${path5}/run`);
3071
+ const run2 = await ask6(client, "POST", `${path5}/run`);
2877
3072
  if (options.json) {
2878
3073
  process.stdout.write(`${JSON.stringify(run2, null, 2)}
2879
3074
  `);
@@ -2883,9 +3078,9 @@ async function schedule(client, positionals, options) {
2883
3078
  `);
2884
3079
  }
2885
3080
  } else if (what === "pause" || what === "resume") {
2886
- print3(await ask5(client, "PATCH", path5, { enabled: what === "resume" }), options.json);
3081
+ print3(await ask6(client, "PATCH", path5, { enabled: what === "resume" }), options.json);
2887
3082
  } else if (what === "delete") {
2888
- await ask5(client, "DELETE", path5);
3083
+ await ask6(client, "DELETE", path5);
2889
3084
  process.stdout.write(`Deleted ${id}, with its runs.
2890
3085
  `);
2891
3086
  } else {
@@ -2893,12 +3088,12 @@ async function schedule(client, positionals, options) {
2893
3088
  if (Object.keys(changes).length === 0) {
2894
3089
  throw new Error("schedule update needs something to change: --every, --cron, --at, --tz, --name, --timeout, --overlap, --if-stopped, --keep-memory or --disk-only, --delete-after or --keep-sandbox, or a new command after --.");
2895
3090
  }
2896
- print3(await ask5(client, "PATCH", path5, changes), options.json);
3091
+ print3(await ask6(client, "PATCH", path5, changes), options.json);
2897
3092
  }
2898
3093
  return;
2899
3094
  }
2900
3095
  default:
2901
- throw new Error(USAGE3);
3096
+ throw new Error(USAGE4);
2902
3097
  }
2903
3098
  }
2904
3099
 
@@ -2934,10 +3129,10 @@ var WEBHOOK_GROUPS = [...new Set(WEBHOOK_KINDS.map((kind) => kind.slice(0, kind.
2934
3129
  var WEBHOOK_RETRY_AFTER_MS = [6e4, 5 * 6e4, 15 * 6e4, 60 * 6e4, 3 * 36e5, 6 * 36e5, 12 * 36e5];
2935
3130
 
2936
3131
  // ../src/cli-webhooks.ts
2937
- var USAGE4 = "webhook takes add, show, update, rotate or delete. agental webhook --help shows each.";
3132
+ var USAGE5 = "webhook takes add, show, update, rotate or delete. agental webhook --help shows each.";
2938
3133
  var EVERY = "*";
2939
3134
  var TRIES = WEBHOOK_RETRY_AFTER_MS.length + 1;
2940
- async function ask6(client, method, pathname, body) {
3135
+ async function ask7(client, method, pathname, body) {
2941
3136
  const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
2942
3137
  let answered = null;
2943
3138
  if (response.status !== 204) {
@@ -3061,7 +3256,7 @@ function saySecret(secret) {
3061
3256
  }
3062
3257
  }
3063
3258
  async function listWebhooks(client, asJson) {
3064
- const body = await ask6(client, "GET", "/v1/webhooks");
3259
+ const body = await ask7(client, "GET", "/v1/webhooks");
3065
3260
  if (asJson) {
3066
3261
  process.stdout.write(`${JSON.stringify(body, null, 2)}
3067
3262
  `);
@@ -3085,7 +3280,7 @@ async function listWebhooks(client, asJson) {
3085
3280
  async function webhook(client, positionals, options) {
3086
3281
  const [what, target, ...rest] = positionals;
3087
3282
  if (rest.length > 0) {
3088
- throw new Error(USAGE4);
3283
+ throw new Error(USAGE5);
3089
3284
  }
3090
3285
  switch (what) {
3091
3286
  case "add": {
@@ -3097,7 +3292,7 @@ async function webhook(client, positionals, options) {
3097
3292
  }
3098
3293
  const events = eventsFrom(options, true);
3099
3294
  const made = webhookOf(
3100
- await ask6(client, "POST", "/v1/webhooks", { url: target, events, ...options.description !== void 0 ? { description: options.description } : {} })
3295
+ await ask7(client, "POST", "/v1/webhooks", { url: target, events, ...options.description !== void 0 ? { description: options.description } : {} })
3101
3296
  );
3102
3297
  if (options.json) {
3103
3298
  process.stdout.write(`${JSON.stringify(made, null, 2)}
@@ -3110,7 +3305,7 @@ async function webhook(client, positionals, options) {
3110
3305
  return;
3111
3306
  }
3112
3307
  case "show": {
3113
- const found = webhookOf(await ask6(client, "GET", `/v1/webhooks/${encodeURIComponent(needId(target, "show"))}`));
3308
+ const found = webhookOf(await ask7(client, "GET", `/v1/webhooks/${encodeURIComponent(needId(target, "show"))}`));
3114
3309
  if (options.json) {
3115
3310
  process.stdout.write(`${JSON.stringify(found, null, 2)}
3116
3311
  `);
@@ -3144,13 +3339,13 @@ async function webhook(client, positionals, options) {
3144
3339
  if (Object.keys(patch).length === 0) {
3145
3340
  throw new Error("webhook update changes --url, --events (or --all) and --description, and was given none of them.");
3146
3341
  }
3147
- const updated = webhookOf(await ask6(client, "PATCH", `/v1/webhooks/${encodeURIComponent(id)}`, patch));
3342
+ const updated = webhookOf(await ask7(client, "PATCH", `/v1/webhooks/${encodeURIComponent(id)}`, patch));
3148
3343
  process.stdout.write(options.json ? `${JSON.stringify(updated, null, 2)}
3149
3344
  ` : describe3(updated));
3150
3345
  return;
3151
3346
  }
3152
3347
  case "rotate": {
3153
- const rotated = webhookOf(await ask6(client, "POST", `/v1/webhooks/${encodeURIComponent(needId(target, "rotate"))}/rotate`));
3348
+ const rotated = webhookOf(await ask7(client, "POST", `/v1/webhooks/${encodeURIComponent(needId(target, "rotate"))}/rotate`));
3154
3349
  if (options.json) {
3155
3350
  process.stdout.write(`${JSON.stringify(rotated, null, 2)}
3156
3351
  `);
@@ -3161,12 +3356,12 @@ async function webhook(client, positionals, options) {
3161
3356
  return;
3162
3357
  }
3163
3358
  case "delete": {
3164
- await ask6(client, "DELETE", `/v1/webhooks/${encodeURIComponent(needId(target, "delete"))}`);
3359
+ await ask7(client, "DELETE", `/v1/webhooks/${encodeURIComponent(needId(target, "delete"))}`);
3165
3360
  process.stdout.write("Deleted. Nothing more is posted to it, and its tries are gone.\n");
3166
3361
  return;
3167
3362
  }
3168
3363
  default:
3169
- throw new Error(USAGE4);
3364
+ throw new Error(USAGE5);
3170
3365
  }
3171
3366
  }
3172
3367
  function needId(id, what) {
@@ -3177,10 +3372,10 @@ function needId(id, what) {
3177
3372
  }
3178
3373
 
3179
3374
  // ../src/cli-claude.ts
3180
- var USAGE5 = "claude takes connect, show, update or disconnect. agental claude --help shows each.";
3375
+ var USAGE6 = "claude takes connect, show, update or disconnect. agental claude --help shows each.";
3181
3376
  var KEY_VARIABLE = "ANTHROPIC_ENVIRONMENT_KEY";
3182
3377
  var SECRET_VARIABLE = "ANTHROPIC_WEBHOOK_SIGNING_KEY";
3183
- async function ask7(client, method, pathname, body) {
3378
+ async function ask8(client, method, pathname, body) {
3184
3379
  const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
3185
3380
  let answered = null;
3186
3381
  if (response.status !== 204) {
@@ -3262,15 +3457,15 @@ async function hidden(question) {
3262
3457
  const muted = lines;
3263
3458
  process.stderr.write(question);
3264
3459
  muted._writeToOutput = () => void 0;
3265
- lines.question("", (answer) => {
3460
+ lines.question("", (answer2) => {
3266
3461
  lines.close();
3267
3462
  process.stderr.write("\n");
3268
- resolve(answer.trim());
3463
+ resolve(answer2.trim());
3269
3464
  });
3270
3465
  });
3271
3466
  }
3272
3467
  async function listClaude(client, asJson) {
3273
- const body = await ask7(client, "GET", "/v1/claude/connections");
3468
+ const body = await ask8(client, "GET", "/v1/claude/connections");
3274
3469
  if (asJson) {
3275
3470
  process.stdout.write(`${JSON.stringify(body, null, 2)}
3276
3471
  `);
@@ -3292,7 +3487,7 @@ async function listClaude(client, asJson) {
3292
3487
  async function claude(client, positionals, options) {
3293
3488
  const [what, target, ...rest] = positionals;
3294
3489
  if (rest.length > 0) {
3295
- throw new Error(USAGE5);
3490
+ throw new Error(USAGE6);
3296
3491
  }
3297
3492
  switch (what) {
3298
3493
  case "connect": {
@@ -3304,7 +3499,7 @@ async function claude(client, positionals, options) {
3304
3499
  const environmentKey = await secretFrom(KEY_VARIABLE, "environment key", true);
3305
3500
  const webhookSecret = await secretFrom(SECRET_VARIABLE, "webhook signing secret", false);
3306
3501
  const made = connectionOf(
3307
- await ask7(client, "POST", "/v1/claude/connections", {
3502
+ await ask8(client, "POST", "/v1/claude/connections", {
3308
3503
  environmentId: target,
3309
3504
  environmentKey,
3310
3505
  ...webhookSecret !== void 0 ? { webhookSecret } : {},
@@ -3326,7 +3521,7 @@ async function claude(client, positionals, options) {
3326
3521
  return;
3327
3522
  }
3328
3523
  case "show": {
3329
- const found = connectionOf(await ask7(client, "GET", `/v1/claude/connections/${encodeURIComponent(needId2(target, "show"))}`));
3524
+ const found = connectionOf(await ask8(client, "GET", `/v1/claude/connections/${encodeURIComponent(needId2(target, "show"))}`));
3330
3525
  process.stdout.write(options.json ? `${JSON.stringify(found, null, 2)}
3331
3526
  ` : describe4(found));
3332
3527
  return;
@@ -3349,18 +3544,18 @@ async function claude(client, positionals, options) {
3349
3544
  if (Object.keys(patch).length === 0) {
3350
3545
  throw new Error("claude update changes --template, --keep-days, --new-key, --webhook-secret or --no-webhook-secret, and was given none of them.");
3351
3546
  }
3352
- const updated = connectionOf(await ask7(client, "PATCH", `/v1/claude/connections/${encodeURIComponent(id)}`, patch));
3547
+ const updated = connectionOf(await ask8(client, "PATCH", `/v1/claude/connections/${encodeURIComponent(id)}`, patch));
3353
3548
  process.stdout.write(options.json ? `${JSON.stringify(updated, null, 2)}
3354
3549
  ` : describe4(updated));
3355
3550
  return;
3356
3551
  }
3357
3552
  case "disconnect": {
3358
- await ask7(client, "DELETE", `/v1/claude/connections/${encodeURIComponent(needId2(target, "disconnect"))}`);
3553
+ await ask8(client, "DELETE", `/v1/claude/connections/${encodeURIComponent(needId2(target, "disconnect"))}`);
3359
3554
  process.stdout.write("Disconnected: its key and signing secret are forgotten, and no more of its work is claimed. Its sessions' sandboxes are left as they are.\n");
3360
3555
  return;
3361
3556
  }
3362
3557
  default:
3363
- throw new Error(USAGE5);
3558
+ throw new Error(USAGE6);
3364
3559
  }
3365
3560
  }
3366
3561
  function needId2(id, what) {
@@ -3377,6 +3572,7 @@ var TICKET_PROTOCOL_PREFIX = "ticket.";
3377
3572
  var VERIFIER_PROTOCOL_PREFIX = "verifier.";
3378
3573
  var MAX_INPUT_BYTES = 64 * 1024;
3379
3574
  var LOST = 255;
3575
+ var PTY_ID = /^pty_[0-9a-f]{16}$/;
3380
3576
  function clamp(value, fallback) {
3381
3577
  return Number.isInteger(value) && value > 0 ? Math.min(value, 1e3) : fallback;
3382
3578
  }
@@ -3400,6 +3596,8 @@ function whyClosed(code, reason, error) {
3400
3596
  return `The terminal was closed: what let it be opened no longer does${said ? ` (${said})` : ""}.`;
3401
3597
  case 4008:
3402
3598
  return "The terminal was closed after 30 minutes with nothing typed.";
3599
+ case 4009:
3600
+ return "The terminal was opened elsewhere; it runs on there.";
3403
3601
  case 4011:
3404
3602
  return `The terminal was closed: ${said || "its sandbox stopped answering"}.`;
3405
3603
  case 1006:
@@ -3408,20 +3606,124 @@ function whyClosed(code, reason, error) {
3408
3606
  return `The terminal was closed (${code})${said ? `: ${said}` : ""}.`;
3409
3607
  }
3410
3608
  }
3411
- async function shell(client, id, streams = process) {
3609
+ async function answer(response) {
3610
+ const body = await response.json().catch(() => null);
3611
+ if (!response.ok) {
3612
+ const error = body?.error;
3613
+ throw new Error(error && typeof error.code === "string" ? `${error.code}: ${String(error.message ?? "")}` : `The API answered with HTTP ${response.status}.`);
3614
+ }
3615
+ return body;
3616
+ }
3617
+ async function keptShells2(client, id) {
3618
+ const body = await answer(await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminals`, { method: "GET" }));
3619
+ if (!body || !Array.isArray(body.terminals)) {
3620
+ throw new Error("The list of kept shells was missing terminals.");
3621
+ }
3622
+ return body.terminals;
3623
+ }
3624
+ async function shellNamed(client, id, given, flag) {
3625
+ const byId = PTY_ID.test(given);
3626
+ if (!byId && !/^[1-9]\d{0,9}$/.test(given)) {
3627
+ throw new Error(`${flag} takes a kept shell's number or its id, as ${flag} 2 or ${flag} pty_0123456789abcdef: agental shell ${id} --list lists them.`);
3628
+ }
3629
+ if (byId) {
3630
+ const listed2 = await keptShells2(client, id).catch(() => []);
3631
+ return { id: given, n: listed2.find((each) => each.id === given)?.n ?? null };
3632
+ }
3633
+ const listed = await keptShells2(client, id);
3634
+ const found = listed.find((each) => each.n === Number(given));
3635
+ if (found) {
3636
+ if (typeof found.id !== "string" || !PTY_ID.test(found.id)) {
3637
+ throw new Error(`The list of kept shells named shell ${given} with an id that is not one.`);
3638
+ }
3639
+ return { id: found.id, n: found.n };
3640
+ }
3641
+ if (byId) {
3642
+ return { id: given, n: null };
3643
+ }
3644
+ throw new Error(`Sandbox ${id} keeps no shell ${given}${listed.length > 0 ? `; it keeps ${listed.map((each) => each.n).join(", ")}` : ""}. agental shell ${id} --list lists them.`);
3645
+ }
3646
+ function stateOf(each) {
3647
+ if (each.exit) {
3648
+ return each.exit.signal > 0 ? `ended by signal ${each.exit.signal}` : `exited ${each.exit.code}`;
3649
+ }
3650
+ return each.running ?? "";
3651
+ }
3652
+ async function listShells(client, id, json, stdout) {
3653
+ const listed = await keptShells2(client, id);
3654
+ if (json) {
3655
+ stdout.write(`${JSON.stringify(listed, null, 2)}
3656
+ `);
3657
+ return;
3658
+ }
3659
+ if (listed.length === 0) {
3660
+ stdout.write(`No kept shells. agental shell ${id} opens one.
3661
+ `);
3662
+ return;
3663
+ }
3664
+ const rows = [
3665
+ ["N", "ID", "RUNNING", "CWD", "ATTACHED", "STARTED"],
3666
+ ...listed.map((each) => [String(each.n), each.id, stateOf(each), each.cwd ?? "", each.attached ? "yes" : "no", ago(each.startedAt) ?? each.startedAt])
3667
+ ];
3668
+ stdout.write(fitted(rows, { give: 2, paint: (cell, row) => row === 0 ? faint(cell, stdout) : cell }));
3669
+ }
3670
+ async function closeShell(client, id, given, stdout) {
3671
+ const found = await shellNamed(client, id, given, "--close");
3672
+ await answer(await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminals/${encodeURIComponent(found.id)}`, { method: "DELETE" }));
3673
+ stdout.write(`Closed ${found.n === null ? "shell" : `shell ${found.n}`} (${found.id}).
3674
+ `);
3675
+ }
3676
+ async function forget(client, id, terminal2) {
3677
+ let timer;
3678
+ try {
3679
+ await Promise.race([
3680
+ client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminals/${terminal2}`, { method: "DELETE" }).then((response) => response.body?.cancel()),
3681
+ new Promise((resolve) => {
3682
+ timer = setTimeout(resolve, 3e3);
3683
+ })
3684
+ ]);
3685
+ } catch {
3686
+ } finally {
3687
+ clearTimeout(timer);
3688
+ }
3689
+ }
3690
+ async function shell(client, id, options = {}, streams = process) {
3412
3691
  if (!id) {
3413
3692
  throw new Error("shell requires <sandbox-id>");
3414
3693
  }
3694
+ if ([options.attach !== void 0, options.list === true, options.close !== void 0].filter(Boolean).length > 1) {
3695
+ throw new Error("shell takes one of --attach, --list and --close");
3696
+ }
3697
+ if (options.list === true) {
3698
+ await listShells(client, id, options.json === true, streams.stdout);
3699
+ return 0;
3700
+ }
3701
+ if (options.close !== void 0) {
3702
+ await closeShell(client, id, options.close, streams.stdout);
3703
+ return 0;
3704
+ }
3415
3705
  const WebSocket = globalThis.WebSocket;
3416
3706
  if (!WebSocket) {
3417
3707
  throw new Error(`agental shell needs Node 22 or later, which has WebSocket; this is Node ${process.versions.node}. agental ssh ${id} works here.`);
3418
3708
  }
3709
+ const again = options.attach !== void 0 ? await shellNamed(client, id, options.attach, "--attach") : null;
3419
3710
  const { stdin, stdout, stderr } = streams;
3420
- const size = sizeOf(stdout);
3711
+ const size2 = sizeOf(stdout);
3421
3712
  const verifier = randomBytes4(32).toString("base64url");
3422
3713
  const challenge = createHash3("sha256").update(verifier).digest("base64url");
3423
- const response = await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminal`, { method: "POST", body: JSON.stringify({ ...size, challenge }) });
3424
- const body = await response.json().catch(() => null);
3714
+ const interactive = stdin.isTTY === true && typeof stdin.setRawMode === "function";
3715
+ const ask9 = async (keep) => await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminal`, {
3716
+ method: "POST",
3717
+ body: JSON.stringify({ ...size2, challenge, ...again ? { terminal: again.id } : keep ? { keep: true } : {} })
3718
+ });
3719
+ let response = await ask9(interactive);
3720
+ let body = await response.json().catch(() => null);
3721
+ if (!again && interactive && response.status === 409 && body?.error?.code === "terminal_unavailable" && /keeps \d+ terminals/.test(String(body.error.message ?? ""))) {
3722
+ stderr.write(`${String(body.error.message)} This one is not kept.
3723
+ `);
3724
+ response = await ask9(false);
3725
+ body = await response.json().catch(() => null);
3726
+ }
3425
3727
  if (!response.ok || typeof body?.ticket !== "string") {
3426
3728
  const error2 = body?.error;
3427
3729
  throw new Error(error2 && typeof error2.code === "string" ? `${error2.code}: ${String(error2.message ?? "")}` : `The API answered the terminal with HTTP ${response.status}.`);
@@ -3431,6 +3733,8 @@ async function shell(client, id, streams = process) {
3431
3733
  let exit = null;
3432
3734
  let error = null;
3433
3735
  let opened = false;
3736
+ let kept2 = null;
3737
+ const back = (n) => `agental shell ${id} --attach ${n}`;
3434
3738
  const raw = stdin.isTTY === true && typeof stdin.setRawMode === "function";
3435
3739
  let lastSent = 10;
3436
3740
  const send2 = (chunk) => {
@@ -3444,28 +3748,39 @@ async function shell(client, id, streams = process) {
3444
3748
  };
3445
3749
  let tilde = false;
3446
3750
  let closedHere = false;
3751
+ let detached = false;
3447
3752
  const escaped = (chunk) => {
3448
- const kept2 = [];
3753
+ const out = [];
3449
3754
  for (const byte of chunk) {
3450
- const atLineStart = (kept2.length > 0 ? kept2[kept2.length - 1] : lastSent) === 13 || (kept2.length > 0 ? kept2[kept2.length - 1] : lastSent) === 10;
3755
+ const before = out.length > 0 ? out[out.length - 1] : lastSent;
3756
+ const atLineStart = before === 13 || before === 10;
3451
3757
  if (tilde) {
3452
3758
  tilde = false;
3453
3759
  if (byte === 46) {
3454
3760
  closedHere = true;
3455
3761
  socket.close(1e3, "closed");
3456
- return Buffer.from(kept2);
3762
+ return Buffer.from(out);
3763
+ }
3764
+ if (byte === 100) {
3765
+ if (kept2 === null) {
3766
+ stderr.write("\r\nThis shell is not kept, so it cannot be left running: ~. closes it, and exit ends it.\r\n");
3767
+ continue;
3768
+ }
3769
+ detached = true;
3770
+ socket.close(1e3, "detached");
3771
+ return Buffer.from(out);
3457
3772
  }
3458
- kept2.push(126);
3773
+ out.push(126);
3459
3774
  if (byte !== 126) {
3460
- kept2.push(byte);
3775
+ out.push(byte);
3461
3776
  }
3462
3777
  } else if (byte === 126 && atLineStart) {
3463
3778
  tilde = true;
3464
3779
  } else {
3465
- kept2.push(byte);
3780
+ out.push(byte);
3466
3781
  }
3467
3782
  }
3468
- return Buffer.from(kept2);
3783
+ return Buffer.from(out);
3469
3784
  };
3470
3785
  const typed = (chunk) => {
3471
3786
  const bytes3 = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
@@ -3505,6 +3820,17 @@ async function shell(client, id, streams = process) {
3505
3820
  return;
3506
3821
  }
3507
3822
  if (message["type"] === "started") {
3823
+ const terminal2 = message["terminal"];
3824
+ const n = message["n"];
3825
+ if (typeof terminal2 === "string" && PTY_ID.test(terminal2) && typeof n === "number" && Number.isInteger(n) && n >= 1) {
3826
+ kept2 = { terminal: terminal2, n };
3827
+ }
3828
+ if (raw) {
3829
+ stderr.write(
3830
+ kept2 ? `Shell ${kept2.n} (${kept2.terminal})${again ? ", opened again" : ""}. ~d leaves it running; exit ends it.\r
3831
+ ` : "This shell is not kept: the sandbox's agent is from before kept shells, so it ends when this closes.\r\n"
3832
+ );
3833
+ }
3508
3834
  started();
3509
3835
  } else if (message["type"] === "exit") {
3510
3836
  exit = { code: Number(message["code"] ?? 0), signal: Number(message["signal"] ?? 0) };
@@ -3528,19 +3854,35 @@ async function shell(client, id, streams = process) {
3528
3854
  resolve(LOST);
3529
3855
  return;
3530
3856
  }
3857
+ const held = kept2;
3858
+ if (detached && held) {
3859
+ stderr.write(`\r
3860
+ Shell ${held.n} runs on in ${id}. ${back(held.n)} opens it again.
3861
+ `);
3862
+ resolve(0);
3863
+ return;
3864
+ }
3531
3865
  if (closedHere) {
3532
- stderr.write("\r\nThe terminal was closed from here.\n");
3866
+ stderr.write(`\r
3867
+ The terminal was closed from here.${held ? ` Shell ${held.n} runs on: ${back(held.n)} opens it again.` : ""}
3868
+ `);
3533
3869
  resolve(LOST);
3534
3870
  return;
3535
3871
  }
3536
3872
  const shellExit = exit;
3537
3873
  if (event.code === 1e3 && shellExit) {
3538
3874
  const code = shellExit.signal > 0 ? 128 + shellExit.signal : shellExit.code;
3539
- resolve(Number.isInteger(code) && code >= 0 && code <= 255 ? code : LOST);
3875
+ const done2 = () => resolve(Number.isInteger(code) && code >= 0 && code <= 255 ? code : LOST);
3876
+ if (held) {
3877
+ void forget(client, id, held.terminal).then(done2);
3878
+ } else {
3879
+ done2();
3880
+ }
3540
3881
  return;
3541
3882
  }
3883
+ const maybe = held && event.code !== 4009 && event.code !== 4003 ? ` If it still runs, ${back(held.n)} opens it again.` : "";
3542
3884
  stderr.write(`\r
3543
- ${whyClosed(event.code, event.reason, error)}
3885
+ ${whyClosed(event.code, event.reason, error)}${maybe}
3544
3886
  `);
3545
3887
  resolve(LOST);
3546
3888
  });
@@ -3875,6 +4217,7 @@ async function main() {
3875
4217
  region: { type: "string" },
3876
4218
  "idempotency-key": { type: "string" },
3877
4219
  json: { type: "boolean", default: false },
4220
+ recursive: { type: "boolean", short: "r", default: false },
3878
4221
  keep: { type: "boolean", default: false },
3879
4222
  "await-reply": { type: "boolean", default: false },
3880
4223
  "private-link": { type: "string" },
@@ -3914,6 +4257,9 @@ async function main() {
3914
4257
  expires: { type: "string" },
3915
4258
  "keep-streams": { type: "boolean" },
3916
4259
  "keep-memory": { type: "boolean" },
4260
+ // agental resize: the size now, with a restart, or a waiting size taken away.
4261
+ now: { type: "boolean", default: false },
4262
+ cancel: { type: "boolean", default: false },
3917
4263
  // agental schedule: when it runs, in what time zone, how long a run may take, what it does when it is stopped or the last still runs, and whether a one-off deletes its sandbox after.
3918
4264
  every: { type: "string" },
3919
4265
  cron: { type: "string" },
@@ -3945,6 +4291,10 @@ async function main() {
3945
4291
  out: { type: "string" },
3946
4292
  events: { type: "string" },
3947
4293
  all: { type: "boolean", default: false },
4294
+ // agental shell: a kept shell opened again, the kept ones listed, or one ended, by its number or id.
4295
+ attach: { type: "string" },
4296
+ list: { type: "boolean", default: false },
4297
+ close: { type: "string" },
3948
4298
  description: { type: "string" },
3949
4299
  url: { type: "string" },
3950
4300
  // agental claude: a connection's days, and which of its secrets to read anew.
@@ -4005,7 +4355,12 @@ async function main() {
4005
4355
  await exec(positionals.slice(1));
4006
4356
  return;
4007
4357
  case "shell":
4008
- process.exitCode = await shell({ base: apiBase(), request }, positionals[1]);
4358
+ process.exitCode = await shell({ base: apiBase(), request }, positionals[1], {
4359
+ ...values.attach !== void 0 ? { attach: values.attach } : {},
4360
+ ...values.close !== void 0 ? { close: values.close } : {},
4361
+ list: values.list === true,
4362
+ json: values.json === true
4363
+ });
4009
4364
  return;
4010
4365
  case "delete":
4011
4366
  if (values.where !== void 0 && positionals[1] !== void 0) {
@@ -4037,6 +4392,9 @@ async function main() {
4037
4392
  case "recover":
4038
4393
  await lifecycle("recover", positionals[1], maxBurstFeeHeaders(values["max-burst-fee"]));
4039
4394
  return;
4395
+ case "resize":
4396
+ await resize(positionals[1], positionals[2], values.now === true, values.cancel === true, values["max-burst-fee"], values.json);
4397
+ return;
4040
4398
  case "ssh-off": {
4041
4399
  const id = positionals[1];
4042
4400
  if (!id) {
@@ -4052,6 +4410,9 @@ async function main() {
4052
4410
  case "email":
4053
4411
  await email({ request, fail }, positionals.slice(1), values);
4054
4412
  return;
4413
+ case "files":
4414
+ await files({ request, fail }, positionals.slice(1), { json: values.json, recursive: values.recursive === true });
4415
+ return;
4055
4416
  case "desktop": {
4056
4417
  const use = DESKTOP_USES.filter((name) => values[name] !== void 0);
4057
4418
  const shotOptions = { crop: values.crop, scale: values.scale, quality: values.quality, cursor: values["no-cursor"] === true ? false : void 0 };
@@ -4288,7 +4649,7 @@ function publicKeysFrom(given) {
4288
4649
  const file = each.startsWith("~/") ? `${os6.homedir()}${each.slice(1)}` : each;
4289
4650
  let text;
4290
4651
  try {
4291
- text = readFileSync4(file, "utf8");
4652
+ text = readFileSync5(file, "utf8");
4292
4653
  } catch {
4293
4654
  throw new Error(`${each} is neither a public key nor a file that can be read. Give a key line, as ssh-ed25519 AAAA... you@laptop, or its file, as ~/.ssh/id_ed25519.pub.`);
4294
4655
  }
@@ -4630,6 +4991,63 @@ async function lifecycle(action, id, headers = {}, sent) {
4630
4991
  );
4631
4992
  }
4632
4993
  }
4994
+ async function resize(id, size2, now, cancel, maxBurstFee, asJson) {
4995
+ if (!id) {
4996
+ throw new Error("resize requires <sandbox-id> and its new size: tiny, small, medium or large");
4997
+ }
4998
+ if (cancel && (size2 !== void 0 || now)) {
4999
+ throw new Error("--cancel takes away a size that waits for the next start, and goes with no size and no --now");
5000
+ }
5001
+ if (!cancel && (size2 === void 0 || !isMachineSize(size2))) {
5002
+ throw new Error("resize takes the new size: tiny, small, medium or large");
5003
+ }
5004
+ if (maxBurstFee !== void 0 && !now) {
5005
+ throw new Error("--max-burst-fee goes with --now: it caps what the restart's start pays in burst fees");
5006
+ }
5007
+ const headers = maxBurstFeeHeaders(maxBurstFee);
5008
+ const path5 = `/v1/sandboxes/${encodeURIComponent(id)}`;
5009
+ const before = await call2(path5, { method: "GET" });
5010
+ const name = before.name || id;
5011
+ const print4 = (sandbox, line) => process.stdout.write(asJson ? `${JSON.stringify(sandbox, null, 2)}
5012
+ ` : `${line}
5013
+ `);
5014
+ if (cancel && !before.pendingSize) {
5015
+ print4(before, `${name} has no size waiting: it stays a ${before.size}.`);
5016
+ return;
5017
+ }
5018
+ const to = cancel ? before.size : size2;
5019
+ const larger = MACHINE_SIZE_NAMES.indexOf(to) > MACHINE_SIZE_NAMES.indexOf(before.size);
5020
+ const restart = now && before.status === "running" && larger;
5021
+ if (restart) {
5022
+ process.stderr.write(`Restarting ${name} as a ${to}: every process in it ends, as on a stop. Its files stay.
5023
+ `);
5024
+ }
5025
+ const response = await request(`${path5}/resize`, { method: "POST", headers: restart ? headers : {}, body: JSON.stringify({ size: to, ...restart ? { restart: true } : {} }) });
5026
+ const body = await readBody(response);
5027
+ if (!response.ok) {
5028
+ if (cancel && response.status === 409 && isApiError(body) && body.error.code === "size_smaller") {
5029
+ const read2 = await call2(path5, { method: "GET" });
5030
+ print4(read2, `${read2.name || id} is already a ${read2.size}; nothing was waiting.`);
5031
+ return;
5032
+ }
5033
+ fail(response.status, body);
5034
+ }
5035
+ sayBurstFee(response);
5036
+ const after = body;
5037
+ if (restart && after.status !== "running") {
5038
+ print4(after, `${name} is a ${after.size} now, but ${after.status ?? "not running"}, not running again${after.error ? `: ${after.error}` : ""}. agental start ${id} starts it.`);
5039
+ process.exitCode = 1;
5040
+ return;
5041
+ }
5042
+ print4(
5043
+ after,
5044
+ after.pendingSize ? `${name} becomes a ${after.pendingSize} at its next start; it runs as a ${after.size} until it is stopped.` : after.size === before.size ? `${name} stays a ${after.size}.` : restart ? `${name} is a ${after.size} now, running again.` : `${name} is a ${after.size} now; its next start boots it as one.`
5045
+ );
5046
+ }
5047
+ function sizeOf2(sandbox) {
5048
+ const size2 = typeof sandbox["size"] === "string" ? sandbox["size"] : "";
5049
+ return typeof sandbox["pendingSize"] === "string" ? `${size2} (${sandbox["pendingSize"]} from its next start)` : size2;
5050
+ }
4633
5051
  async function stoppedAfter(id, operationId) {
4634
5052
  process.stderr.write("Still writing its memory. Waiting until it has stopped.\n");
4635
5053
  const deadline = Date.now() + 6e5;
@@ -4657,13 +5075,13 @@ async function desktop(id, screen, off, status) {
4657
5075
  if (off && status) {
4658
5076
  throw new Error("desktop takes --off or --status, not both");
4659
5077
  }
4660
- const size = screen === void 0 ? null : /^(\d{3,4})x(\d{3,4})$/.exec(screen);
4661
- if (screen !== void 0 && (size === null || off || status)) {
4662
- throw new Error(size === null ? "--screen is a width and a height in pixels with an x between: 1280x800" : "--screen is for turning the desktop on, and goes with neither --off nor --status");
5078
+ const size2 = screen === void 0 ? null : /^(\d{3,4})x(\d{3,4})$/.exec(screen);
5079
+ if (screen !== void 0 && (size2 === null || off || status)) {
5080
+ throw new Error(size2 === null ? "--screen is a width and a height in pixels with an x between: 1280x800" : "--screen is for turning the desktop on, and goes with neither --off nor --status");
4663
5081
  }
4664
5082
  const response = await request(`/v1/sandboxes/${encodeURIComponent(id)}/desktop`, {
4665
5083
  method: off ? "DELETE" : status ? "GET" : "PUT",
4666
- ...size ? { body: JSON.stringify({ width: Number(size[1]), height: Number(size[2]) }) } : {}
5084
+ ...size2 ? { body: JSON.stringify({ width: Number(size2[1]), height: Number(size2[2]) }) } : {}
4667
5085
  });
4668
5086
  const body = await readBody(response);
4669
5087
  if (!response.ok) {
@@ -4829,8 +5247,8 @@ async function screenshot(id, file, options) {
4829
5247
  }
4830
5248
  const picture = Buffer.from(await response.arrayBuffer());
4831
5249
  writeFileSync4(file, picture);
4832
- const size = pictureSize(picture);
4833
- process.stderr.write(`A picture of the screen of ${id} is in ${file}: ${size ? `${size.width} by ${size.height}, ` : ""}${picture.length} bytes.
5250
+ const size2 = pictureSize(picture);
5251
+ process.stderr.write(`A picture of the screen of ${id} is in ${file}: ${size2 ? `${size2.width} by ${size2.height}, ` : ""}${picture.length} bytes.
4834
5252
  `);
4835
5253
  }
4836
5254
  function pictureSize(bytes3) {
@@ -4863,7 +5281,7 @@ async function clipboard(id, text) {
4863
5281
  process.stdout.write(String(body.text ?? ""));
4864
5282
  return;
4865
5283
  }
4866
- const given = text === "-" ? readFileSync4(0, "utf8") : text;
5284
+ const given = text === "-" ? readFileSync5(0, "utf8") : text;
4867
5285
  const response = await request(at4, { method: "PUT", body: JSON.stringify({ text: given }) });
4868
5286
  if (!response.ok) {
4869
5287
  fail(response.status, await readBody(response));
@@ -5569,7 +5987,7 @@ async function secrets(positionals, values) {
5569
5987
  if (!path5 || local === void 0 === (values.text === void 0)) {
5570
5988
  throw new Error("secrets put-file requires <path>, and then a local file to read it from or --text with what it holds");
5571
5989
  }
5572
- const text = values.text ?? await readFile(local ?? "", "utf8");
5990
+ const text = values.text ?? await readFile2(local ?? "", "utf8");
5573
5991
  const body = await call2(`${base}/files`, { method: "PUT", body: JSON.stringify({ path: path5, text }) });
5574
5992
  process.stdout.write(`put ${body.path}
5575
5993
  `);
@@ -5612,8 +6030,8 @@ async function metrics(id, asked2) {
5612
6030
  if (!response.ok) {
5613
6031
  fail(response.status, body);
5614
6032
  }
5615
- const answer = body && typeof body === "object" ? body : {};
5616
- const fromTo = typeof answer["since"] === "string" && typeof answer["until"] === "string" ? ` from ${answer["since"]} to ${answer["until"]}` : "";
6033
+ const answer2 = body && typeof body === "object" ? body : {};
6034
+ const fromTo = typeof answer2["since"] === "string" && typeof answer2["until"] === "string" ? ` from ${answer2["since"]} to ${answer2["until"]}` : "";
5617
6035
  if (asked2.json) {
5618
6036
  process.stdout.write(`${JSON.stringify(body, null, 2)}
5619
6037
  `);
@@ -5638,7 +6056,7 @@ async function metrics(id, asked2) {
5638
6056
  ])
5639
6057
  );
5640
6058
  }
5641
- if (answer["complete"] === false) {
6059
+ if (answer2["complete"] === false) {
5642
6060
  process.stderr.write(
5643
6061
  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.
5644
6062
  `
@@ -5681,8 +6099,8 @@ async function dataRetention(positionals, asJson) {
5681
6099
  `);
5682
6100
  return;
5683
6101
  }
5684
- const answer = body ?? {};
5685
- const days = answer.keepDays ?? null;
6102
+ const answer2 = body ?? {};
6103
+ const days = answer2.keepDays ?? null;
5686
6104
  const kept2 = days === null ? "until their sandbox is deleted" : days === 1 ? "1 day" : `${days} days`;
5687
6105
  process.stdout.write(`${period === void 0 ? "" : "Saved. "}Command output, agent conversations and events are kept ${kept2}.
5688
6106
  `);
@@ -5690,7 +6108,7 @@ async function dataRetention(positionals, asJson) {
5690
6108
  process.stdout.write(`What is older is deleted within the hour, and cannot be brought back.
5691
6109
  `);
5692
6110
  }
5693
- const last = answer.lastCleared;
6111
+ const last = answer2.lastCleared;
5694
6112
  if (period === void 0) {
5695
6113
  process.stdout.write(
5696
6114
  last ? `Last clean-up ${last.at}: ${last.commands} commands' output, ${last.conversations} conversations and ${last.events} events deleted.
@@ -5836,9 +6254,9 @@ async function telemetry(positionals, given, asJson) {
5836
6254
  }
5837
6255
  async function billing(positionals, asJson, limit) {
5838
6256
  const [what, amount, ...rest] = positionals;
5839
- const kinds = ["prices", "invoices", "card", "top-up", "auto-reload"];
6257
+ const kinds = ["prices", "invoices", "card", "details", "top-up", "auto-reload"];
5840
6258
  const near = what !== void 0 && !kinds.includes(what) ? nearest(what, kinds) : null;
5841
- const usage = `${near ? `billing has no ${what}: did you mean billing ${near}? ` : ""}billing takes nothing, prices, invoices, card, card save, top-up <dollars>, or auto-reload <dollars | off>`;
6259
+ const usage = `${near ? `billing has no ${what}: did you mean billing ${near}? ` : ""}billing takes nothing, prices, invoices, card, card save, details, top-up <dollars>, or auto-reload <dollars | off>`;
5842
6260
  if (rest.length > 0 || what !== "top-up" && what !== "auto-reload" && !(what === "card" && amount === "save") && amount !== void 0) {
5843
6261
  throw new Error(usage);
5844
6262
  }
@@ -5857,6 +6275,11 @@ async function billing(positionals, asJson, limit) {
5857
6275
  await invoices(asJson, limit);
5858
6276
  return;
5859
6277
  }
6278
+ case "details": {
6279
+ const body = await asked("/v1/billing/details", { method: "GET" });
6280
+ print4(body, () => describeDetails(body.details));
6281
+ return;
6282
+ }
5860
6283
  case "prices": {
5861
6284
  const body = await asked("/v1/billing/plans", { method: "GET" });
5862
6285
  print4(body, () => isTerminal(process.stdout) ? pricesForPeople(body) : describePrices(body));
@@ -6019,6 +6442,23 @@ function describeCard(card) {
6019
6442
  const wallet = card.wallet ? `, through ${WALLETS[card.wallet] ?? card.wallet}` : "";
6020
6443
  return `${brand}${ending}${expires}${wallet}. It is changed in the console, under Billing.`;
6021
6444
  }
6445
+ function describeDetails(details) {
6446
+ if (!details) {
6447
+ return "No billing details yet: they are kept once you save a card or pay, and changed in the console, under Billing.\n";
6448
+ }
6449
+ const where = details.address;
6450
+ const address = where ? [where.line1, where.line2, [where.postalCode, where.city].filter(Boolean).join(" "), where.state, where.country].filter((part) => part).join(", ") : "";
6451
+ const lines = [
6452
+ ["Invoices to", details.email ?? "not set"],
6453
+ // With no name, the address is what they are billed to.
6454
+ ["Billed to", details.name ?? (address || "not set")],
6455
+ ...details.name && address ? [["", address]] : [],
6456
+ ...details.taxIds.length > 0 ? details.taxIds.map((id, index) => [index === 0 ? "Tax ID" : "", `${id.value}${id.verification ? ` (${id.verification})` : ""}`]) : [["Tax ID", "not set"]]
6457
+ ];
6458
+ return `${lines.filter(([label, value]) => label !== "" || value !== "").map(([label, value]) => `${label.padEnd(14)}${value}
6459
+ `).join("")}They are changed in the console, under Billing, and the next invoice carries them.
6460
+ `;
6461
+ }
6022
6462
  async function invoices(asJson, limit) {
6023
6463
  if (limit !== void 0 && (!/^\d+$/.test(limit) || Number(limit) < 1 || Number(limit) > 100)) {
6024
6464
  throw new Error("billing invoices --limit takes how many of the newest invoices to list, a whole number from 1 to 100.");
@@ -6126,12 +6566,12 @@ function pricesForPeople(body) {
6126
6566
  "Sizes",
6127
6567
  [
6128
6568
  ["", "VCPU", "MEMORY", "AN HOUR", ...body.storage ? ["STOPPED, AN HOUR"] : []],
6129
- ...body.plans.map((size) => [
6130
- size.size,
6131
- String(size.vcpu),
6132
- `${size.memoryMb / 1024} GiB`,
6133
- `$${size.listPriceMicrosPerHour / 1e6}`,
6134
- ...body.storage ? [size.stoppedMicrosPerHour === void 0 ? "" : `$${size.stoppedMicrosPerHour / 1e6}`] : []
6569
+ ...body.plans.map((size2) => [
6570
+ size2.size,
6571
+ String(size2.vcpu),
6572
+ `${size2.memoryMb / 1024} GiB`,
6573
+ `$${size2.listPriceMicrosPerHour / 1e6}`,
6574
+ ...body.storage ? [size2.stoppedMicrosPerHour === void 0 ? "" : `$${size2.stoppedMicrosPerHour / 1e6}`] : []
6135
6575
  ])
6136
6576
  ],
6137
6577
  [`Charged by the second.${body.storage ? ` Stopped, a sandbox costs ${body.storage.stoppedPercent}% while its disk is kept.` : ""}`]
@@ -6214,9 +6654,9 @@ function describePrices(body) {
6214
6654
  }
6215
6655
  }
6216
6656
  out.push(body.storage ? "Sizes, an hour at list price, running and stopped" : "Sizes, an hour at list price");
6217
- for (const size of body.plans) {
6218
- const stopped = body.storage && size.stoppedMicrosPerHour !== void 0 ? `$${size.stoppedMicrosPerHour / 1e6} stopped` : "";
6219
- out.push(` ${size.size.padEnd(8)}${`${size.vcpu} vCPU, ${size.memoryMb / 1024} GiB`.padEnd(20)}${`$${size.listPriceMicrosPerHour / 1e6}`.padEnd(12)}${stopped}`.trimEnd());
6657
+ for (const size2 of body.plans) {
6658
+ const stopped = body.storage && size2.stoppedMicrosPerHour !== void 0 ? `$${size2.stoppedMicrosPerHour / 1e6} stopped` : "";
6659
+ out.push(` ${size2.size.padEnd(8)}${`${size2.vcpu} vCPU, ${size2.memoryMb / 1024} GiB`.padEnd(20)}${`$${size2.listPriceMicrosPerHour / 1e6}`.padEnd(12)}${stopped}`.trimEnd());
6220
6660
  }
6221
6661
  if (body.storage) {
6222
6662
  const month = body.storage.snapshotMicrosPerHour * 730 / 1e6;
@@ -6243,10 +6683,10 @@ async function headroom(positionals, options) {
6243
6683
  `);
6244
6684
  return;
6245
6685
  }
6246
- const answer = body2 && typeof body2 === "object" ? body2 : {};
6247
- const spent = typeof answer["spentMicros"] === "number" ? answer["spentMicros"] : 0;
6248
- const budget = typeof answer["budgetMicros"] === "number" ? answer["budgetMicros"] : 0;
6249
- process.stdout.write(`Budget for burst fees: ${money(budget)} a month${answer["budgetSet"] === true ? "" : " (the default)"}; ${money(spent)} spent this month.
6686
+ const answer2 = body2 && typeof body2 === "object" ? body2 : {};
6687
+ const spent = typeof answer2["spentMicros"] === "number" ? answer2["spentMicros"] : 0;
6688
+ const budget = typeof answer2["budgetMicros"] === "number" ? answer2["budgetMicros"] : 0;
6689
+ process.stdout.write(`Budget for burst fees: ${money(budget)} a month${answer2["budgetSet"] === true ? "" : " (the default)"}; ${money(spent)} spent this month.
6250
6690
  `);
6251
6691
  return;
6252
6692
  }
@@ -6272,8 +6712,8 @@ async function headroom(positionals, options) {
6272
6712
  process.stdout.write(describeHeadroom(body, options.from === void 0 && options.to === void 0, options.to === void 0));
6273
6713
  }
6274
6714
  function describeHeadroom(body, today, endsNow) {
6275
- const answer = body && typeof body === "object" ? body : {};
6276
- const now = answer["now"] && typeof answer["now"] === "object" ? answer["now"] : {};
6715
+ const answer2 = body && typeof body === "object" ? body : {};
6716
+ const now = answer2["now"] && typeof answer2["now"] === "object" ? answer2["now"] : {};
6277
6717
  const number = (from, name) => typeof from[name] === "number" ? from[name] : 0;
6278
6718
  const smalls = (mb) => {
6279
6719
  const value = mb / 4096;
@@ -6283,11 +6723,11 @@ function describeHeadroom(body, today, endsNow) {
6283
6723
  const at4 = new Date(iso).toISOString();
6284
6724
  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`;
6285
6725
  };
6286
- const range = today ? "today (UTC)" : `from ${String(answer["from"] ?? "")} to ${String(answer["to"] ?? "")}`;
6726
+ const range = today ? "today (UTC)" : `from ${String(answer2["from"] ?? "")} to ${String(answer2["to"] ?? "")}`;
6287
6727
  const lines = [
6288
- `running: ${smalls(number(now, "runningMb"))} of ${number(now, "runningUnits").toLocaleString("en-US")} small sandboxes (a medium is 2, a large 4, a tiny half); at the running count ${duration(number(answer, "atRunningCountMs"))} ${range}`
6728
+ `running: ${smalls(number(now, "runningMb"))} of ${number(now, "runningUnits").toLocaleString("en-US")} small sandboxes (a medium is 2, a large 4, a tiny half); at the running count ${duration(number(answer2, "atRunningCountMs"))} ${range}`
6289
6729
  ];
6290
- const bursts = Array.isArray(answer["bursts"]) ? answer["bursts"] : [];
6730
+ const bursts = Array.isArray(answer2["bursts"]) ? answer2["bursts"] : [];
6291
6731
  const open = endsNow ? bursts.find((one) => one["endedAt"] === null && typeof one["startedAt"] === "string") : void 0;
6292
6732
  const meterMb = number(now, "meterMb");
6293
6733
  const freeMb = number(now, "freeMb");
@@ -6303,7 +6743,7 @@ function describeHeadroom(body, today, endsNow) {
6303
6743
  lines.push(`burst: free burst ${smalls(number(now, "freeNowMb"))} of ${number(now, "freeBurstUnits").toLocaleString("en-US")} small free now; the meter falls by half every ${halfLife} minutes`);
6304
6744
  }
6305
6745
  lines.push(`fees: ${money(number(now, "spentMicros"))} this month of a ${money(number(now, "budgetMicros"))} budget`);
6306
- const refused = answer["refused"] && typeof answer["refused"] === "object" ? answer["refused"] : {};
6746
+ const refused = answer2["refused"] && typeof answer2["refused"] === "object" ? answer2["refused"] : {};
6307
6747
  const total = number(refused, "total");
6308
6748
  const byReason = Array.isArray(refused["byReason"]) ? refused["byReason"] : [];
6309
6749
  lines.push(
@@ -6429,7 +6869,7 @@ function sandboxesForPeople(sandboxes2, names, sorted) {
6429
6869
  ACTIVE.has(text(sandbox["status"])) ? "\u25CF" : "\u25CB",
6430
6870
  text(sandbox["id"]),
6431
6871
  text(sandbox["name"]),
6432
- text(sandbox["size"]),
6872
+ sizeOf2(sandbox),
6433
6873
  templateId ? names.get(templateId) ?? templateId : "-",
6434
6874
  status(sandbox),
6435
6875
  ...showVm ? [sandbox["vmIsolation"] === true ? "yes" : "no"] : [],
@@ -6578,7 +7018,10 @@ Usage
6578
7018
  agental meta <sandbox-id> [set <key>=<value>... | unset <key>...] [--json]
6579
7019
  agental regions [--json]
6580
7020
  agental exec <sandbox-id> -- <command> [args...]
6581
- agental shell <sandbox-id> a login shell in it, in this terminal: no SSH key or port
7021
+ agental shell <sandbox-id> a login shell in it, in this terminal, kept: ~d leaves it running
7022
+ agental shell <sandbox-id> --attach <shell> a kept shell again, by its number or id
7023
+ agental shell <sandbox-id> --list [--json] the shells kept in it
7024
+ agental shell <sandbox-id> --close <shell> end a kept shell
6582
7025
  agental delete <sandbox-id>
6583
7026
  agental start <sandbox-id> [--max-burst-fee <dollars>]
6584
7027
  agental stop <sandbox-id> [--keep-memory]
@@ -6587,6 +7030,8 @@ Usage
6587
7030
  agental delete --where '<words>' [--confirm <count>] asks for the count to be typed
6588
7031
  agental jobs [list | show <job-id> | cancel <job-id>] [--json]
6589
7032
  agental recover <sandbox-id> [--max-burst-fee <dollars>]
7033
+ agental resize <sandbox-id> tiny|small|medium|large [--now] [--max-burst-fee <dollars>] [--json]
7034
+ agental resize <sandbox-id> --cancel [--json] a size that waits for its next start, taken away
6590
7035
  agental auto-stop <sandbox-id> [--in <time> | --at <date-time> | --never] [--json]
6591
7036
  agental network <sandbox-id> [--allow <address>[,<address>...] | --none] [--json]
6592
7037
  agental egress <sandbox-id> [box | residential <country> [sticky | rotating]] [--json]
@@ -6649,7 +7094,7 @@ Usage
6649
7094
  agental key show <key> [--json]
6650
7095
  agental key allow-from <key> (<address-or-range>... | --anywhere) [--json]
6651
7096
  agental key delete <key>
6652
- agental billing [prices | card [save] | top-up <dollars> | auto-reload <dollars | off>] [--json]
7097
+ agental billing [prices | card [save] | details | top-up <dollars> | auto-reload <dollars | off>] [--json]
6653
7098
  agental billing invoices [--limit <n>] [--json]
6654
7099
  agental headroom [--from <day or date-time>] [--to <day or date-time>] [--step 10m|hour|day] [--json]
6655
7100
  agental headroom budget <dollars> | budget default [--json]
@@ -6658,6 +7103,7 @@ Usage
6658
7103
  agental account export [--out <file>]
6659
7104
  agental ssh <sandbox-id> [--tmux] [ssh options] [command...]
6660
7105
  agental scp [scp options] <source>... <target>
7106
+ ${FILES_USAGE.map((line) => ` ${line}`).join("\n")}
6661
7107
  agental ssh-config <sandbox-id>
6662
7108
  agental ssh-keys <sandbox-id> [--remove <key-id>] [--json]
6663
7109
  agental ssh-off <sandbox-id>
@@ -6696,6 +7142,13 @@ The key is kept in ~/.config/agental/credentials.json, readable by you alone. lo
6696
7142
  key from your account and that file. whoami says who the command is signed in as, and with which
6697
7143
  key. AGENTAL_API_KEY, when it is set, is used in place of what is kept.
6698
7144
  Stop keeps the sandbox filesystem, and a stopped sandbox costs 5% of its running price. Processes do not survive a stop.
7145
+ resize gives a sandbox a larger size, with more vCPUs, memory and disk, and its files in place; a
7146
+ smaller one is refused, as its disk is not made smaller. A stopped sandbox takes it at once, and its
7147
+ next start boots it at it. A running one keeps running, and paying, as its size until it is
7148
+ stopped, and its next start gives it the new one, whoever starts it; --now stops it and starts it
7149
+ again at the new size now, and every process in it ends, as on a stop. --cancel takes a size that
7150
+ waits away. Memory a stop kept is let go: the next start boots from the disk. While a size waits,
7151
+ stop --keep-memory is refused.
6699
7152
  recover gets a sandbox that is stuck going again: what runs in it is killed, its disk is kept,
6700
7153
  and it ends running. One that is stopped is started, and pays a burst fee as a start does.
6701
7154
  Start of a sandbox that was archived is accepted and finished afterwards: list shows it as
@@ -6846,10 +7299,11 @@ what is left of the month's credits, what is left of the top-ups, which are used
6846
7299
  after it and do not expire, and the card it pays with. invoices lists the account's invoices,
6847
7300
  newest first, each with its day, number, state, total and what it was for, and where to pay
6848
7301
  one that is not paid yet; --limit lists that many of the newest, and --json gives each one's
6849
- page and PDF to the account's owner. The free plan costs nothing a month and pays for what runs from
7302
+ page and PDF to the account's owner. details says who the invoices are made out to: the email
7303
+ they go to, the name, address and tax ids on them, to the account's owner alone. The free plan costs nothing a month and pays for what runs from
6850
7304
  credits alone; it makes tiny and small sandboxes. prices lists the plans with the sizes each
6851
- makes, the top-ups with their bonus and the hourly price of each size. card prints the address
6852
- of a page to save a card for the free plan: nothing is charged, and once it is saved the account
7305
+ makes, the top-ups with their bonus and the hourly price of each size. card names the card the account
7306
+ pays with, and card save prints the address of a page to save one for the free plan: nothing is charged, and once it is saved the account
6853
7307
  is given $10 of credit, once. Until it buys a top-up it runs 2 small sandboxes at once, then 20.
6854
7308
  top-up <dollars> starts buying credits for
6855
7309
  any whole number of dollars from 15 to 100,000, and prints the address of the page to pay on.
@@ -6862,6 +7316,14 @@ account export prints everything agental keeps about your account and you, as JS
6862
7316
  account, its sessions with the address and browser each began from, its keys by name, billing,
6863
7317
  payments, usage, and what it has made. Secrets are named, never given. --out writes it to a file
6864
7318
  only you can read. An account is closed from Settings in the console: a key cannot close one.
7319
+ shell opens a login shell in a running sandbox, in this terminal, over the API: no SSH key or
7320
+ port. It exits with what the shell exits with, or 255 when the connection ends first. The shell
7321
+ is kept: it runs on in the sandbox when the connection closes, until it exits, is closed, or the
7322
+ sandbox stops. At the start of a line, ~d leaves it running and exits 0, ~. closes the
7323
+ connection from here, for one that has stopped answering, and ~~ types a ~. --attach opens a
7324
+ kept shell again, by its number or id, with what it printed meanwhile; it is closed wherever
7325
+ else it was open. --list lists the kept shells, what runs in each and where, and --close ends
7326
+ one: what runs in it is sent SIGHUP. A shell that exits here is no longer listed.
6865
7327
  ssh opens a shell in a running sandbox, or runs a command there, with the ssh that is installed
6866
7328
  here. It turns SSH on for the sandbox, which opens a port of the server the sandbox is on, lets
6867
7329
  in a key of its own, ~/.ssh/agental_ed25519, which it makes when there is none, and connects