agental 0.15.0 → 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.
- package/dist/cli.js +544 -122
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -41,12 +41,12 @@ var init_cli_operator = __esm({
|
|
|
41
41
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
42
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.
|
|
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,
|
|
151
|
-
if (value >=
|
|
152
|
-
return `${Number((value /
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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." :
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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,
|
|
897
|
+
async function pushRequest(base, ask9) {
|
|
767
898
|
let made;
|
|
768
899
|
try {
|
|
769
|
-
made = await call(base, "POST", "/v1/cli-sign-ins",
|
|
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
|
|
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
|
-
|
|
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) =>
|
|
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");
|
|
@@ -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
|
|
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
|
|
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
|
|
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(
|
|
1262
|
-
const error =
|
|
1263
|
-
return { code: String(error["code"] ?? `http_${
|
|
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,10 +1648,10 @@ 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,
|
|
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"] ===
|
|
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`;
|
|
@@ -1712,7 +1843,18 @@ var COMMANDS = [
|
|
|
1712
1843
|
["-- <command> [args...]", "what to run; everything after -- is the command's own"]
|
|
1713
1844
|
]
|
|
1714
1845
|
},
|
|
1715
|
-
{
|
|
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
|
+
},
|
|
1716
1858
|
{
|
|
1717
1859
|
name: "ssh",
|
|
1718
1860
|
summary: "Open a shell in a sandbox, or run a command there, over SSH.",
|
|
@@ -1723,6 +1865,11 @@ var COMMANDS = [
|
|
|
1723
1865
|
]
|
|
1724
1866
|
},
|
|
1725
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
|
+
},
|
|
1726
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"] },
|
|
1727
1874
|
{ name: "ssh-connect", summary: "Reach a sandbox for ssh: what the Host block ssh-config prints runs. It is not typed by hand." },
|
|
1728
1875
|
{ name: "ssh-keys", summary: "List or remove the SSH keys a sandbox lets in." },
|
|
@@ -1757,6 +1904,17 @@ var COMMANDS = [
|
|
|
1757
1904
|
]
|
|
1758
1905
|
},
|
|
1759
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
|
+
},
|
|
1760
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"] },
|
|
1761
1919
|
{ name: "jobs", summary: "Follow or cancel the work started on many sandboxes at once." },
|
|
1762
1920
|
{ name: "tags", summary: "Read, add or remove a sandbox's tags.", examples: ["agental tags sbx_2a9a47e50daec64a add ci"] },
|
|
@@ -1931,6 +2089,7 @@ var MAP = [
|
|
|
1931
2089
|
[
|
|
1932
2090
|
["start, stop, delete", "one sandbox, or every one --where finds"],
|
|
1933
2091
|
["recover, auto-stop", "get a stuck one going, say when one stops"],
|
|
2092
|
+
["resize", "a larger size, now or at its next start"],
|
|
1934
2093
|
["schedule", "run a command on a timer"],
|
|
1935
2094
|
["secret", "values and files kept out of the sandbox"],
|
|
1936
2095
|
["network, egress", "what it may reach, and the address it leaves from"],
|
|
@@ -1938,6 +2097,7 @@ var MAP = [
|
|
|
1938
2097
|
["metrics", "CPU, memory and disk over time"],
|
|
1939
2098
|
["email", "an email address of its own"],
|
|
1940
2099
|
["desktop, browser", "a screen and a Chrome in the sandbox"],
|
|
2100
|
+
["files", "list, send, fetch, move and delete its files"],
|
|
1941
2101
|
["scp, ssh-config", "files, and SSH from any tool"],
|
|
1942
2102
|
["job, region", "work on many at once, and where they run"]
|
|
1943
2103
|
]
|
|
@@ -2243,6 +2403,7 @@ function flagsOf(usages) {
|
|
|
2243
2403
|
var SANDBOX = /^<sandbox-id>/;
|
|
2244
2404
|
var SANDBOX_VERBS2 = /* @__PURE__ */ new Set(["list", "create", "start", "stop", "delete", "recover", "exec", "shell", "summary"]);
|
|
2245
2405
|
var TEMPLATE = /^<template>/;
|
|
2406
|
+
var KEPT_SHELL = /^<shell>/;
|
|
2246
2407
|
async function complete(typed, reference, operator, fetchJson) {
|
|
2247
2408
|
if (typed[0] === "sandbox" && typed.length > 2 && SANDBOX_VERBS2.has(typed[1])) {
|
|
2248
2409
|
return complete(typed.slice(1), reference, operator, fetchJson);
|
|
@@ -2288,6 +2449,10 @@ async function complete(typed, reference, operator, fetchJson) {
|
|
|
2288
2449
|
if (SANDBOX.test(valueOf)) {
|
|
2289
2450
|
return starting(await sandboxes(fetchJson));
|
|
2290
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
|
+
}
|
|
2291
2456
|
const choices = valueOf.split("|").filter((word) => /^[a-z0-9][a-z0-9.-]*$/i.test(word));
|
|
2292
2457
|
return starting(choices.map((value) => ({ value })));
|
|
2293
2458
|
}
|
|
@@ -2342,13 +2507,26 @@ async function sandboxes(api2) {
|
|
|
2342
2507
|
const body = await cached("sandboxes", api2.as, () => api2.get("/v1/sandboxes?limit=200"));
|
|
2343
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(", ") }));
|
|
2344
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
|
+
}
|
|
2345
2523
|
async function templates(api2) {
|
|
2346
2524
|
const body = await cached("templates", api2.as, () => api2.get("/v1/templates"));
|
|
2347
2525
|
const listed = Array.isArray(body) ? body : body?.templates ?? [];
|
|
2348
2526
|
return listed.filter((each) => typeof each["name"] === "string").map((each) => ({ value: each["name"], about: each["default"] === true ? "the default" : void 0 }));
|
|
2349
2527
|
}
|
|
2350
2528
|
var KEPT_MS = 3e4;
|
|
2351
|
-
async function cached(what, as,
|
|
2529
|
+
async function cached(what, as, ask9) {
|
|
2352
2530
|
const folder = path4.join(process.env["XDG_CACHE_HOME"] || path4.join(os5.homedir(), ".cache"), "agental");
|
|
2353
2531
|
const file = path4.join(folder, `complete-${what}-${createHash2("sha256").update(as).digest("hex").slice(0, 16)}.json`);
|
|
2354
2532
|
try {
|
|
@@ -2360,7 +2538,7 @@ async function cached(what, as, ask8) {
|
|
|
2360
2538
|
}
|
|
2361
2539
|
let body = null;
|
|
2362
2540
|
try {
|
|
2363
|
-
body = await
|
|
2541
|
+
body = await ask9();
|
|
2364
2542
|
} catch {
|
|
2365
2543
|
return null;
|
|
2366
2544
|
}
|
|
@@ -2497,7 +2675,7 @@ function span(ms) {
|
|
|
2497
2675
|
var ORG_USAGE = "org takes list, use <organization> or create <name>. agental org --help shows each.";
|
|
2498
2676
|
var MEMBERS_USAGE = "members takes list, or remove <member> [--revoke-keys]. agental members --help shows each.";
|
|
2499
2677
|
var ROLES = ["member", "admin"];
|
|
2500
|
-
async function
|
|
2678
|
+
async function ask5(client, method, pathname, body) {
|
|
2501
2679
|
const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
|
|
2502
2680
|
let answered = null;
|
|
2503
2681
|
if (response.status !== 204) {
|
|
@@ -2520,8 +2698,8 @@ function print2(json, body, words2) {
|
|
|
2520
2698
|
` : words2);
|
|
2521
2699
|
}
|
|
2522
2700
|
async function organizations(client) {
|
|
2523
|
-
const listed = (await
|
|
2524
|
-
const me = await
|
|
2701
|
+
const listed = (await ask5(client, "GET", "/v1/organizations"))["organizations"];
|
|
2702
|
+
const me = await ask5(client, "GET", "/v1/me");
|
|
2525
2703
|
return { organizations: Array.isArray(listed) ? listed : [], acting: String(me["activeOrganizationId"] ?? "") };
|
|
2526
2704
|
}
|
|
2527
2705
|
function organizationNamed(list3, given) {
|
|
@@ -2577,7 +2755,7 @@ async function org(client, positionals, options, signInTo) {
|
|
|
2577
2755
|
if (!name) {
|
|
2578
2756
|
throw new Error("org create takes the team's name: agental org create Acme.");
|
|
2579
2757
|
}
|
|
2580
|
-
const made = await
|
|
2758
|
+
const made = await ask5(client, "POST", "/v1/organizations", { kind: "team", name });
|
|
2581
2759
|
const organization = made["organization"] ?? {};
|
|
2582
2760
|
print2(
|
|
2583
2761
|
options.json,
|
|
@@ -2610,7 +2788,7 @@ function memberNamed(list3, given) {
|
|
|
2610
2788
|
async function members(client, positionals, options) {
|
|
2611
2789
|
const [verb = "list", target] = positionals;
|
|
2612
2790
|
const team = await actingTeam(client);
|
|
2613
|
-
const listed = await
|
|
2791
|
+
const listed = await ask5(client, "GET", `/v1/organizations/${encodeURIComponent(team.id)}/members`);
|
|
2614
2792
|
const list3 = Array.isArray(listed["members"]) ? listed["members"] : [];
|
|
2615
2793
|
switch (verb) {
|
|
2616
2794
|
case "list": {
|
|
@@ -2635,7 +2813,7 @@ async function members(client, positionals, options) {
|
|
|
2635
2813
|
}
|
|
2636
2814
|
const member = memberNamed(list3, target);
|
|
2637
2815
|
const query = options.revokeKeys ? "?revokeKeys=true" : "";
|
|
2638
|
-
const removed = await
|
|
2816
|
+
const removed = await ask5(client, "DELETE", `/v1/organizations/${encodeURIComponent(team.id)}/members/${encodeURIComponent(member.userId)}${query}`);
|
|
2639
2817
|
const revoked = Number(removed["revokedKeys"] ?? 0);
|
|
2640
2818
|
print2(
|
|
2641
2819
|
options.json,
|
|
@@ -2660,7 +2838,7 @@ async function invite(client, positionals, options) {
|
|
|
2660
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.`);
|
|
2661
2839
|
}
|
|
2662
2840
|
const team = await actingTeam(client);
|
|
2663
|
-
const sent = await
|
|
2841
|
+
const sent = await ask5(client, "POST", "/v1/invites", { email: email2, role });
|
|
2664
2842
|
const link = `/join?invite=${String(sent["id"] ?? "")}`;
|
|
2665
2843
|
print2(
|
|
2666
2844
|
options.json,
|
|
@@ -2672,9 +2850,9 @@ async function invite(client, positionals, options) {
|
|
|
2672
2850
|
}
|
|
2673
2851
|
|
|
2674
2852
|
// ../src/cli-schedules.ts
|
|
2675
|
-
var
|
|
2853
|
+
var USAGE4 = "schedule takes add, show, runs, run, pause, resume, update or delete. agental schedule --help shows each.";
|
|
2676
2854
|
var OVERLAPS = ["skip", "replace", "parallel"];
|
|
2677
|
-
async function
|
|
2855
|
+
async function ask6(client, method, pathname, body) {
|
|
2678
2856
|
const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
|
|
2679
2857
|
let answered = null;
|
|
2680
2858
|
if (response.status !== 204) {
|
|
@@ -2792,7 +2970,7 @@ function table2(rows) {
|
|
|
2792
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";
|
|
2793
2971
|
}
|
|
2794
2972
|
async function listOf(client, sandboxId) {
|
|
2795
|
-
const body = await
|
|
2973
|
+
const body = await ask6(client, "GET", `/v1/sandboxes/${encodeURIComponent(sandboxId)}/schedules`);
|
|
2796
2974
|
return body?.schedules ?? [];
|
|
2797
2975
|
}
|
|
2798
2976
|
async function idOf2(client, sandboxId, given, verb) {
|
|
@@ -2833,7 +3011,7 @@ async function listSchedules(client, sandboxId, json) {
|
|
|
2833
3011
|
async function schedule(client, positionals, options) {
|
|
2834
3012
|
const [what, sandboxId, ...rest] = positionals;
|
|
2835
3013
|
if (what === void 0) {
|
|
2836
|
-
throw new Error(
|
|
3014
|
+
throw new Error(USAGE4);
|
|
2837
3015
|
}
|
|
2838
3016
|
if (sandboxId === void 0) {
|
|
2839
3017
|
throw new Error(`schedule ${what} needs the sandbox: agental schedule ${what} <sandbox-id>${what === "add" ? " --every 1h -- <command>" : " <schedule>"}`);
|
|
@@ -2847,7 +3025,7 @@ async function schedule(client, positionals, options) {
|
|
|
2847
3025
|
if (options.every === void 0 && options.cron === void 0 && options.at === void 0) {
|
|
2848
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.');
|
|
2849
3027
|
}
|
|
2850
|
-
const made = await
|
|
3028
|
+
const made = await ask6(client, "POST", base, { command: commandLine(rest), ...fieldsOf(options) });
|
|
2851
3029
|
print3(made, options.json);
|
|
2852
3030
|
return;
|
|
2853
3031
|
}
|
|
@@ -2860,15 +3038,15 @@ async function schedule(client, positionals, options) {
|
|
|
2860
3038
|
case "update": {
|
|
2861
3039
|
const [target, ...command2] = rest;
|
|
2862
3040
|
if (command2.length > 0 && what !== "update") {
|
|
2863
|
-
throw new Error(
|
|
3041
|
+
throw new Error(USAGE4);
|
|
2864
3042
|
}
|
|
2865
3043
|
const id = await idOf2(client, sandboxId, target, what);
|
|
2866
3044
|
const path5 = `${base}/${encodeURIComponent(id)}`;
|
|
2867
3045
|
if (what === "show") {
|
|
2868
|
-
print3(await
|
|
3046
|
+
print3(await ask6(client, "GET", path5), options.json);
|
|
2869
3047
|
} else if (what === "runs") {
|
|
2870
3048
|
const limit = options.limit === void 0 ? "" : `?limit=${encodeURIComponent(options.limit)}`;
|
|
2871
|
-
const runs = (await
|
|
3049
|
+
const runs = (await ask6(client, "GET", `${path5}/runs${limit}`))?.runs ?? [];
|
|
2872
3050
|
if (options.json) {
|
|
2873
3051
|
process.stdout.write(`${JSON.stringify(runs, null, 2)}
|
|
2874
3052
|
`);
|
|
@@ -2890,7 +3068,7 @@ async function schedule(client, positionals, options) {
|
|
|
2890
3068
|
);
|
|
2891
3069
|
}
|
|
2892
3070
|
} else if (what === "run") {
|
|
2893
|
-
const run2 = await
|
|
3071
|
+
const run2 = await ask6(client, "POST", `${path5}/run`);
|
|
2894
3072
|
if (options.json) {
|
|
2895
3073
|
process.stdout.write(`${JSON.stringify(run2, null, 2)}
|
|
2896
3074
|
`);
|
|
@@ -2900,9 +3078,9 @@ async function schedule(client, positionals, options) {
|
|
|
2900
3078
|
`);
|
|
2901
3079
|
}
|
|
2902
3080
|
} else if (what === "pause" || what === "resume") {
|
|
2903
|
-
print3(await
|
|
3081
|
+
print3(await ask6(client, "PATCH", path5, { enabled: what === "resume" }), options.json);
|
|
2904
3082
|
} else if (what === "delete") {
|
|
2905
|
-
await
|
|
3083
|
+
await ask6(client, "DELETE", path5);
|
|
2906
3084
|
process.stdout.write(`Deleted ${id}, with its runs.
|
|
2907
3085
|
`);
|
|
2908
3086
|
} else {
|
|
@@ -2910,12 +3088,12 @@ async function schedule(client, positionals, options) {
|
|
|
2910
3088
|
if (Object.keys(changes).length === 0) {
|
|
2911
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 --.");
|
|
2912
3090
|
}
|
|
2913
|
-
print3(await
|
|
3091
|
+
print3(await ask6(client, "PATCH", path5, changes), options.json);
|
|
2914
3092
|
}
|
|
2915
3093
|
return;
|
|
2916
3094
|
}
|
|
2917
3095
|
default:
|
|
2918
|
-
throw new Error(
|
|
3096
|
+
throw new Error(USAGE4);
|
|
2919
3097
|
}
|
|
2920
3098
|
}
|
|
2921
3099
|
|
|
@@ -2951,10 +3129,10 @@ var WEBHOOK_GROUPS = [...new Set(WEBHOOK_KINDS.map((kind) => kind.slice(0, kind.
|
|
|
2951
3129
|
var WEBHOOK_RETRY_AFTER_MS = [6e4, 5 * 6e4, 15 * 6e4, 60 * 6e4, 3 * 36e5, 6 * 36e5, 12 * 36e5];
|
|
2952
3130
|
|
|
2953
3131
|
// ../src/cli-webhooks.ts
|
|
2954
|
-
var
|
|
3132
|
+
var USAGE5 = "webhook takes add, show, update, rotate or delete. agental webhook --help shows each.";
|
|
2955
3133
|
var EVERY = "*";
|
|
2956
3134
|
var TRIES = WEBHOOK_RETRY_AFTER_MS.length + 1;
|
|
2957
|
-
async function
|
|
3135
|
+
async function ask7(client, method, pathname, body) {
|
|
2958
3136
|
const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
|
|
2959
3137
|
let answered = null;
|
|
2960
3138
|
if (response.status !== 204) {
|
|
@@ -3078,7 +3256,7 @@ function saySecret(secret) {
|
|
|
3078
3256
|
}
|
|
3079
3257
|
}
|
|
3080
3258
|
async function listWebhooks(client, asJson) {
|
|
3081
|
-
const body = await
|
|
3259
|
+
const body = await ask7(client, "GET", "/v1/webhooks");
|
|
3082
3260
|
if (asJson) {
|
|
3083
3261
|
process.stdout.write(`${JSON.stringify(body, null, 2)}
|
|
3084
3262
|
`);
|
|
@@ -3102,7 +3280,7 @@ async function listWebhooks(client, asJson) {
|
|
|
3102
3280
|
async function webhook(client, positionals, options) {
|
|
3103
3281
|
const [what, target, ...rest] = positionals;
|
|
3104
3282
|
if (rest.length > 0) {
|
|
3105
|
-
throw new Error(
|
|
3283
|
+
throw new Error(USAGE5);
|
|
3106
3284
|
}
|
|
3107
3285
|
switch (what) {
|
|
3108
3286
|
case "add": {
|
|
@@ -3114,7 +3292,7 @@ async function webhook(client, positionals, options) {
|
|
|
3114
3292
|
}
|
|
3115
3293
|
const events = eventsFrom(options, true);
|
|
3116
3294
|
const made = webhookOf(
|
|
3117
|
-
await
|
|
3295
|
+
await ask7(client, "POST", "/v1/webhooks", { url: target, events, ...options.description !== void 0 ? { description: options.description } : {} })
|
|
3118
3296
|
);
|
|
3119
3297
|
if (options.json) {
|
|
3120
3298
|
process.stdout.write(`${JSON.stringify(made, null, 2)}
|
|
@@ -3127,7 +3305,7 @@ async function webhook(client, positionals, options) {
|
|
|
3127
3305
|
return;
|
|
3128
3306
|
}
|
|
3129
3307
|
case "show": {
|
|
3130
|
-
const found = webhookOf(await
|
|
3308
|
+
const found = webhookOf(await ask7(client, "GET", `/v1/webhooks/${encodeURIComponent(needId(target, "show"))}`));
|
|
3131
3309
|
if (options.json) {
|
|
3132
3310
|
process.stdout.write(`${JSON.stringify(found, null, 2)}
|
|
3133
3311
|
`);
|
|
@@ -3161,13 +3339,13 @@ async function webhook(client, positionals, options) {
|
|
|
3161
3339
|
if (Object.keys(patch).length === 0) {
|
|
3162
3340
|
throw new Error("webhook update changes --url, --events (or --all) and --description, and was given none of them.");
|
|
3163
3341
|
}
|
|
3164
|
-
const updated = webhookOf(await
|
|
3342
|
+
const updated = webhookOf(await ask7(client, "PATCH", `/v1/webhooks/${encodeURIComponent(id)}`, patch));
|
|
3165
3343
|
process.stdout.write(options.json ? `${JSON.stringify(updated, null, 2)}
|
|
3166
3344
|
` : describe3(updated));
|
|
3167
3345
|
return;
|
|
3168
3346
|
}
|
|
3169
3347
|
case "rotate": {
|
|
3170
|
-
const rotated = webhookOf(await
|
|
3348
|
+
const rotated = webhookOf(await ask7(client, "POST", `/v1/webhooks/${encodeURIComponent(needId(target, "rotate"))}/rotate`));
|
|
3171
3349
|
if (options.json) {
|
|
3172
3350
|
process.stdout.write(`${JSON.stringify(rotated, null, 2)}
|
|
3173
3351
|
`);
|
|
@@ -3178,12 +3356,12 @@ async function webhook(client, positionals, options) {
|
|
|
3178
3356
|
return;
|
|
3179
3357
|
}
|
|
3180
3358
|
case "delete": {
|
|
3181
|
-
await
|
|
3359
|
+
await ask7(client, "DELETE", `/v1/webhooks/${encodeURIComponent(needId(target, "delete"))}`);
|
|
3182
3360
|
process.stdout.write("Deleted. Nothing more is posted to it, and its tries are gone.\n");
|
|
3183
3361
|
return;
|
|
3184
3362
|
}
|
|
3185
3363
|
default:
|
|
3186
|
-
throw new Error(
|
|
3364
|
+
throw new Error(USAGE5);
|
|
3187
3365
|
}
|
|
3188
3366
|
}
|
|
3189
3367
|
function needId(id, what) {
|
|
@@ -3194,10 +3372,10 @@ function needId(id, what) {
|
|
|
3194
3372
|
}
|
|
3195
3373
|
|
|
3196
3374
|
// ../src/cli-claude.ts
|
|
3197
|
-
var
|
|
3375
|
+
var USAGE6 = "claude takes connect, show, update or disconnect. agental claude --help shows each.";
|
|
3198
3376
|
var KEY_VARIABLE = "ANTHROPIC_ENVIRONMENT_KEY";
|
|
3199
3377
|
var SECRET_VARIABLE = "ANTHROPIC_WEBHOOK_SIGNING_KEY";
|
|
3200
|
-
async function
|
|
3378
|
+
async function ask8(client, method, pathname, body) {
|
|
3201
3379
|
const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
|
|
3202
3380
|
let answered = null;
|
|
3203
3381
|
if (response.status !== 204) {
|
|
@@ -3279,15 +3457,15 @@ async function hidden(question) {
|
|
|
3279
3457
|
const muted = lines;
|
|
3280
3458
|
process.stderr.write(question);
|
|
3281
3459
|
muted._writeToOutput = () => void 0;
|
|
3282
|
-
lines.question("", (
|
|
3460
|
+
lines.question("", (answer2) => {
|
|
3283
3461
|
lines.close();
|
|
3284
3462
|
process.stderr.write("\n");
|
|
3285
|
-
resolve(
|
|
3463
|
+
resolve(answer2.trim());
|
|
3286
3464
|
});
|
|
3287
3465
|
});
|
|
3288
3466
|
}
|
|
3289
3467
|
async function listClaude(client, asJson) {
|
|
3290
|
-
const body = await
|
|
3468
|
+
const body = await ask8(client, "GET", "/v1/claude/connections");
|
|
3291
3469
|
if (asJson) {
|
|
3292
3470
|
process.stdout.write(`${JSON.stringify(body, null, 2)}
|
|
3293
3471
|
`);
|
|
@@ -3309,7 +3487,7 @@ async function listClaude(client, asJson) {
|
|
|
3309
3487
|
async function claude(client, positionals, options) {
|
|
3310
3488
|
const [what, target, ...rest] = positionals;
|
|
3311
3489
|
if (rest.length > 0) {
|
|
3312
|
-
throw new Error(
|
|
3490
|
+
throw new Error(USAGE6);
|
|
3313
3491
|
}
|
|
3314
3492
|
switch (what) {
|
|
3315
3493
|
case "connect": {
|
|
@@ -3321,7 +3499,7 @@ async function claude(client, positionals, options) {
|
|
|
3321
3499
|
const environmentKey = await secretFrom(KEY_VARIABLE, "environment key", true);
|
|
3322
3500
|
const webhookSecret = await secretFrom(SECRET_VARIABLE, "webhook signing secret", false);
|
|
3323
3501
|
const made = connectionOf(
|
|
3324
|
-
await
|
|
3502
|
+
await ask8(client, "POST", "/v1/claude/connections", {
|
|
3325
3503
|
environmentId: target,
|
|
3326
3504
|
environmentKey,
|
|
3327
3505
|
...webhookSecret !== void 0 ? { webhookSecret } : {},
|
|
@@ -3343,7 +3521,7 @@ async function claude(client, positionals, options) {
|
|
|
3343
3521
|
return;
|
|
3344
3522
|
}
|
|
3345
3523
|
case "show": {
|
|
3346
|
-
const found = connectionOf(await
|
|
3524
|
+
const found = connectionOf(await ask8(client, "GET", `/v1/claude/connections/${encodeURIComponent(needId2(target, "show"))}`));
|
|
3347
3525
|
process.stdout.write(options.json ? `${JSON.stringify(found, null, 2)}
|
|
3348
3526
|
` : describe4(found));
|
|
3349
3527
|
return;
|
|
@@ -3366,18 +3544,18 @@ async function claude(client, positionals, options) {
|
|
|
3366
3544
|
if (Object.keys(patch).length === 0) {
|
|
3367
3545
|
throw new Error("claude update changes --template, --keep-days, --new-key, --webhook-secret or --no-webhook-secret, and was given none of them.");
|
|
3368
3546
|
}
|
|
3369
|
-
const updated = connectionOf(await
|
|
3547
|
+
const updated = connectionOf(await ask8(client, "PATCH", `/v1/claude/connections/${encodeURIComponent(id)}`, patch));
|
|
3370
3548
|
process.stdout.write(options.json ? `${JSON.stringify(updated, null, 2)}
|
|
3371
3549
|
` : describe4(updated));
|
|
3372
3550
|
return;
|
|
3373
3551
|
}
|
|
3374
3552
|
case "disconnect": {
|
|
3375
|
-
await
|
|
3553
|
+
await ask8(client, "DELETE", `/v1/claude/connections/${encodeURIComponent(needId2(target, "disconnect"))}`);
|
|
3376
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");
|
|
3377
3555
|
return;
|
|
3378
3556
|
}
|
|
3379
3557
|
default:
|
|
3380
|
-
throw new Error(
|
|
3558
|
+
throw new Error(USAGE6);
|
|
3381
3559
|
}
|
|
3382
3560
|
}
|
|
3383
3561
|
function needId2(id, what) {
|
|
@@ -3394,6 +3572,7 @@ var TICKET_PROTOCOL_PREFIX = "ticket.";
|
|
|
3394
3572
|
var VERIFIER_PROTOCOL_PREFIX = "verifier.";
|
|
3395
3573
|
var MAX_INPUT_BYTES = 64 * 1024;
|
|
3396
3574
|
var LOST = 255;
|
|
3575
|
+
var PTY_ID = /^pty_[0-9a-f]{16}$/;
|
|
3397
3576
|
function clamp(value, fallback) {
|
|
3398
3577
|
return Number.isInteger(value) && value > 0 ? Math.min(value, 1e3) : fallback;
|
|
3399
3578
|
}
|
|
@@ -3417,6 +3596,8 @@ function whyClosed(code, reason, error) {
|
|
|
3417
3596
|
return `The terminal was closed: what let it be opened no longer does${said ? ` (${said})` : ""}.`;
|
|
3418
3597
|
case 4008:
|
|
3419
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.";
|
|
3420
3601
|
case 4011:
|
|
3421
3602
|
return `The terminal was closed: ${said || "its sandbox stopped answering"}.`;
|
|
3422
3603
|
case 1006:
|
|
@@ -3425,20 +3606,124 @@ function whyClosed(code, reason, error) {
|
|
|
3425
3606
|
return `The terminal was closed (${code})${said ? `: ${said}` : ""}.`;
|
|
3426
3607
|
}
|
|
3427
3608
|
}
|
|
3428
|
-
async function
|
|
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) {
|
|
3429
3691
|
if (!id) {
|
|
3430
3692
|
throw new Error("shell requires <sandbox-id>");
|
|
3431
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
|
+
}
|
|
3432
3705
|
const WebSocket = globalThis.WebSocket;
|
|
3433
3706
|
if (!WebSocket) {
|
|
3434
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.`);
|
|
3435
3708
|
}
|
|
3709
|
+
const again = options.attach !== void 0 ? await shellNamed(client, id, options.attach, "--attach") : null;
|
|
3436
3710
|
const { stdin, stdout, stderr } = streams;
|
|
3437
|
-
const
|
|
3711
|
+
const size2 = sizeOf(stdout);
|
|
3438
3712
|
const verifier = randomBytes4(32).toString("base64url");
|
|
3439
3713
|
const challenge = createHash3("sha256").update(verifier).digest("base64url");
|
|
3440
|
-
const
|
|
3441
|
-
const
|
|
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
|
+
}
|
|
3442
3727
|
if (!response.ok || typeof body?.ticket !== "string") {
|
|
3443
3728
|
const error2 = body?.error;
|
|
3444
3729
|
throw new Error(error2 && typeof error2.code === "string" ? `${error2.code}: ${String(error2.message ?? "")}` : `The API answered the terminal with HTTP ${response.status}.`);
|
|
@@ -3448,6 +3733,8 @@ async function shell(client, id, streams = process) {
|
|
|
3448
3733
|
let exit = null;
|
|
3449
3734
|
let error = null;
|
|
3450
3735
|
let opened = false;
|
|
3736
|
+
let kept2 = null;
|
|
3737
|
+
const back = (n) => `agental shell ${id} --attach ${n}`;
|
|
3451
3738
|
const raw = stdin.isTTY === true && typeof stdin.setRawMode === "function";
|
|
3452
3739
|
let lastSent = 10;
|
|
3453
3740
|
const send2 = (chunk) => {
|
|
@@ -3461,28 +3748,39 @@ async function shell(client, id, streams = process) {
|
|
|
3461
3748
|
};
|
|
3462
3749
|
let tilde = false;
|
|
3463
3750
|
let closedHere = false;
|
|
3751
|
+
let detached = false;
|
|
3464
3752
|
const escaped = (chunk) => {
|
|
3465
|
-
const
|
|
3753
|
+
const out = [];
|
|
3466
3754
|
for (const byte of chunk) {
|
|
3467
|
-
const
|
|
3755
|
+
const before = out.length > 0 ? out[out.length - 1] : lastSent;
|
|
3756
|
+
const atLineStart = before === 13 || before === 10;
|
|
3468
3757
|
if (tilde) {
|
|
3469
3758
|
tilde = false;
|
|
3470
3759
|
if (byte === 46) {
|
|
3471
3760
|
closedHere = true;
|
|
3472
3761
|
socket.close(1e3, "closed");
|
|
3473
|
-
return Buffer.from(
|
|
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);
|
|
3474
3772
|
}
|
|
3475
|
-
|
|
3773
|
+
out.push(126);
|
|
3476
3774
|
if (byte !== 126) {
|
|
3477
|
-
|
|
3775
|
+
out.push(byte);
|
|
3478
3776
|
}
|
|
3479
3777
|
} else if (byte === 126 && atLineStart) {
|
|
3480
3778
|
tilde = true;
|
|
3481
3779
|
} else {
|
|
3482
|
-
|
|
3780
|
+
out.push(byte);
|
|
3483
3781
|
}
|
|
3484
3782
|
}
|
|
3485
|
-
return Buffer.from(
|
|
3783
|
+
return Buffer.from(out);
|
|
3486
3784
|
};
|
|
3487
3785
|
const typed = (chunk) => {
|
|
3488
3786
|
const bytes3 = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
@@ -3522,6 +3820,17 @@ async function shell(client, id, streams = process) {
|
|
|
3522
3820
|
return;
|
|
3523
3821
|
}
|
|
3524
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
|
+
}
|
|
3525
3834
|
started();
|
|
3526
3835
|
} else if (message["type"] === "exit") {
|
|
3527
3836
|
exit = { code: Number(message["code"] ?? 0), signal: Number(message["signal"] ?? 0) };
|
|
@@ -3545,19 +3854,35 @@ async function shell(client, id, streams = process) {
|
|
|
3545
3854
|
resolve(LOST);
|
|
3546
3855
|
return;
|
|
3547
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
|
+
}
|
|
3548
3865
|
if (closedHere) {
|
|
3549
|
-
stderr.write(
|
|
3866
|
+
stderr.write(`\r
|
|
3867
|
+
The terminal was closed from here.${held ? ` Shell ${held.n} runs on: ${back(held.n)} opens it again.` : ""}
|
|
3868
|
+
`);
|
|
3550
3869
|
resolve(LOST);
|
|
3551
3870
|
return;
|
|
3552
3871
|
}
|
|
3553
3872
|
const shellExit = exit;
|
|
3554
3873
|
if (event.code === 1e3 && shellExit) {
|
|
3555
3874
|
const code = shellExit.signal > 0 ? 128 + shellExit.signal : shellExit.code;
|
|
3556
|
-
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
|
+
}
|
|
3557
3881
|
return;
|
|
3558
3882
|
}
|
|
3883
|
+
const maybe = held && event.code !== 4009 && event.code !== 4003 ? ` If it still runs, ${back(held.n)} opens it again.` : "";
|
|
3559
3884
|
stderr.write(`\r
|
|
3560
|
-
${whyClosed(event.code, event.reason, error)}
|
|
3885
|
+
${whyClosed(event.code, event.reason, error)}${maybe}
|
|
3561
3886
|
`);
|
|
3562
3887
|
resolve(LOST);
|
|
3563
3888
|
});
|
|
@@ -3892,6 +4217,7 @@ async function main() {
|
|
|
3892
4217
|
region: { type: "string" },
|
|
3893
4218
|
"idempotency-key": { type: "string" },
|
|
3894
4219
|
json: { type: "boolean", default: false },
|
|
4220
|
+
recursive: { type: "boolean", short: "r", default: false },
|
|
3895
4221
|
keep: { type: "boolean", default: false },
|
|
3896
4222
|
"await-reply": { type: "boolean", default: false },
|
|
3897
4223
|
"private-link": { type: "string" },
|
|
@@ -3931,6 +4257,9 @@ async function main() {
|
|
|
3931
4257
|
expires: { type: "string" },
|
|
3932
4258
|
"keep-streams": { type: "boolean" },
|
|
3933
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 },
|
|
3934
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.
|
|
3935
4264
|
every: { type: "string" },
|
|
3936
4265
|
cron: { type: "string" },
|
|
@@ -3962,6 +4291,10 @@ async function main() {
|
|
|
3962
4291
|
out: { type: "string" },
|
|
3963
4292
|
events: { type: "string" },
|
|
3964
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" },
|
|
3965
4298
|
description: { type: "string" },
|
|
3966
4299
|
url: { type: "string" },
|
|
3967
4300
|
// agental claude: a connection's days, and which of its secrets to read anew.
|
|
@@ -4022,7 +4355,12 @@ async function main() {
|
|
|
4022
4355
|
await exec(positionals.slice(1));
|
|
4023
4356
|
return;
|
|
4024
4357
|
case "shell":
|
|
4025
|
-
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
|
+
});
|
|
4026
4364
|
return;
|
|
4027
4365
|
case "delete":
|
|
4028
4366
|
if (values.where !== void 0 && positionals[1] !== void 0) {
|
|
@@ -4054,6 +4392,9 @@ async function main() {
|
|
|
4054
4392
|
case "recover":
|
|
4055
4393
|
await lifecycle("recover", positionals[1], maxBurstFeeHeaders(values["max-burst-fee"]));
|
|
4056
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;
|
|
4057
4398
|
case "ssh-off": {
|
|
4058
4399
|
const id = positionals[1];
|
|
4059
4400
|
if (!id) {
|
|
@@ -4069,6 +4410,9 @@ async function main() {
|
|
|
4069
4410
|
case "email":
|
|
4070
4411
|
await email({ request, fail }, positionals.slice(1), values);
|
|
4071
4412
|
return;
|
|
4413
|
+
case "files":
|
|
4414
|
+
await files({ request, fail }, positionals.slice(1), { json: values.json, recursive: values.recursive === true });
|
|
4415
|
+
return;
|
|
4072
4416
|
case "desktop": {
|
|
4073
4417
|
const use = DESKTOP_USES.filter((name) => values[name] !== void 0);
|
|
4074
4418
|
const shotOptions = { crop: values.crop, scale: values.scale, quality: values.quality, cursor: values["no-cursor"] === true ? false : void 0 };
|
|
@@ -4647,6 +4991,63 @@ async function lifecycle(action, id, headers = {}, sent) {
|
|
|
4647
4991
|
);
|
|
4648
4992
|
}
|
|
4649
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
|
+
}
|
|
4650
5051
|
async function stoppedAfter(id, operationId) {
|
|
4651
5052
|
process.stderr.write("Still writing its memory. Waiting until it has stopped.\n");
|
|
4652
5053
|
const deadline = Date.now() + 6e5;
|
|
@@ -4674,13 +5075,13 @@ async function desktop(id, screen, off, status) {
|
|
|
4674
5075
|
if (off && status) {
|
|
4675
5076
|
throw new Error("desktop takes --off or --status, not both");
|
|
4676
5077
|
}
|
|
4677
|
-
const
|
|
4678
|
-
if (screen !== void 0 && (
|
|
4679
|
-
throw new Error(
|
|
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");
|
|
4680
5081
|
}
|
|
4681
5082
|
const response = await request(`/v1/sandboxes/${encodeURIComponent(id)}/desktop`, {
|
|
4682
5083
|
method: off ? "DELETE" : status ? "GET" : "PUT",
|
|
4683
|
-
...
|
|
5084
|
+
...size2 ? { body: JSON.stringify({ width: Number(size2[1]), height: Number(size2[2]) }) } : {}
|
|
4684
5085
|
});
|
|
4685
5086
|
const body = await readBody(response);
|
|
4686
5087
|
if (!response.ok) {
|
|
@@ -4846,8 +5247,8 @@ async function screenshot(id, file, options) {
|
|
|
4846
5247
|
}
|
|
4847
5248
|
const picture = Buffer.from(await response.arrayBuffer());
|
|
4848
5249
|
writeFileSync4(file, picture);
|
|
4849
|
-
const
|
|
4850
|
-
process.stderr.write(`A picture of the screen of ${id} is in ${file}: ${
|
|
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.
|
|
4851
5252
|
`);
|
|
4852
5253
|
}
|
|
4853
5254
|
function pictureSize(bytes3) {
|
|
@@ -5586,7 +5987,7 @@ async function secrets(positionals, values) {
|
|
|
5586
5987
|
if (!path5 || local === void 0 === (values.text === void 0)) {
|
|
5587
5988
|
throw new Error("secrets put-file requires <path>, and then a local file to read it from or --text with what it holds");
|
|
5588
5989
|
}
|
|
5589
|
-
const text = values.text ?? await
|
|
5990
|
+
const text = values.text ?? await readFile2(local ?? "", "utf8");
|
|
5590
5991
|
const body = await call2(`${base}/files`, { method: "PUT", body: JSON.stringify({ path: path5, text }) });
|
|
5591
5992
|
process.stdout.write(`put ${body.path}
|
|
5592
5993
|
`);
|
|
@@ -5629,8 +6030,8 @@ async function metrics(id, asked2) {
|
|
|
5629
6030
|
if (!response.ok) {
|
|
5630
6031
|
fail(response.status, body);
|
|
5631
6032
|
}
|
|
5632
|
-
const
|
|
5633
|
-
const fromTo = typeof
|
|
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"]}` : "";
|
|
5634
6035
|
if (asked2.json) {
|
|
5635
6036
|
process.stdout.write(`${JSON.stringify(body, null, 2)}
|
|
5636
6037
|
`);
|
|
@@ -5655,7 +6056,7 @@ async function metrics(id, asked2) {
|
|
|
5655
6056
|
])
|
|
5656
6057
|
);
|
|
5657
6058
|
}
|
|
5658
|
-
if (
|
|
6059
|
+
if (answer2["complete"] === false) {
|
|
5659
6060
|
process.stderr.write(
|
|
5660
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.
|
|
5661
6062
|
`
|
|
@@ -5698,8 +6099,8 @@ async function dataRetention(positionals, asJson) {
|
|
|
5698
6099
|
`);
|
|
5699
6100
|
return;
|
|
5700
6101
|
}
|
|
5701
|
-
const
|
|
5702
|
-
const days =
|
|
6102
|
+
const answer2 = body ?? {};
|
|
6103
|
+
const days = answer2.keepDays ?? null;
|
|
5703
6104
|
const kept2 = days === null ? "until their sandbox is deleted" : days === 1 ? "1 day" : `${days} days`;
|
|
5704
6105
|
process.stdout.write(`${period === void 0 ? "" : "Saved. "}Command output, agent conversations and events are kept ${kept2}.
|
|
5705
6106
|
`);
|
|
@@ -5707,7 +6108,7 @@ async function dataRetention(positionals, asJson) {
|
|
|
5707
6108
|
process.stdout.write(`What is older is deleted within the hour, and cannot be brought back.
|
|
5708
6109
|
`);
|
|
5709
6110
|
}
|
|
5710
|
-
const last =
|
|
6111
|
+
const last = answer2.lastCleared;
|
|
5711
6112
|
if (period === void 0) {
|
|
5712
6113
|
process.stdout.write(
|
|
5713
6114
|
last ? `Last clean-up ${last.at}: ${last.commands} commands' output, ${last.conversations} conversations and ${last.events} events deleted.
|
|
@@ -6165,12 +6566,12 @@ function pricesForPeople(body) {
|
|
|
6165
6566
|
"Sizes",
|
|
6166
6567
|
[
|
|
6167
6568
|
["", "VCPU", "MEMORY", "AN HOUR", ...body.storage ? ["STOPPED, AN HOUR"] : []],
|
|
6168
|
-
...body.plans.map((
|
|
6169
|
-
|
|
6170
|
-
String(
|
|
6171
|
-
`${
|
|
6172
|
-
`$${
|
|
6173
|
-
...body.storage ? [
|
|
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}`] : []
|
|
6174
6575
|
])
|
|
6175
6576
|
],
|
|
6176
6577
|
[`Charged by the second.${body.storage ? ` Stopped, a sandbox costs ${body.storage.stoppedPercent}% while its disk is kept.` : ""}`]
|
|
@@ -6253,9 +6654,9 @@ function describePrices(body) {
|
|
|
6253
6654
|
}
|
|
6254
6655
|
}
|
|
6255
6656
|
out.push(body.storage ? "Sizes, an hour at list price, running and stopped" : "Sizes, an hour at list price");
|
|
6256
|
-
for (const
|
|
6257
|
-
const stopped = body.storage &&
|
|
6258
|
-
out.push(` ${
|
|
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());
|
|
6259
6660
|
}
|
|
6260
6661
|
if (body.storage) {
|
|
6261
6662
|
const month = body.storage.snapshotMicrosPerHour * 730 / 1e6;
|
|
@@ -6282,10 +6683,10 @@ async function headroom(positionals, options) {
|
|
|
6282
6683
|
`);
|
|
6283
6684
|
return;
|
|
6284
6685
|
}
|
|
6285
|
-
const
|
|
6286
|
-
const spent = typeof
|
|
6287
|
-
const budget = typeof
|
|
6288
|
-
process.stdout.write(`Budget for burst fees: ${money(budget)} a 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.
|
|
6289
6690
|
`);
|
|
6290
6691
|
return;
|
|
6291
6692
|
}
|
|
@@ -6311,8 +6712,8 @@ async function headroom(positionals, options) {
|
|
|
6311
6712
|
process.stdout.write(describeHeadroom(body, options.from === void 0 && options.to === void 0, options.to === void 0));
|
|
6312
6713
|
}
|
|
6313
6714
|
function describeHeadroom(body, today, endsNow) {
|
|
6314
|
-
const
|
|
6315
|
-
const now =
|
|
6715
|
+
const answer2 = body && typeof body === "object" ? body : {};
|
|
6716
|
+
const now = answer2["now"] && typeof answer2["now"] === "object" ? answer2["now"] : {};
|
|
6316
6717
|
const number = (from, name) => typeof from[name] === "number" ? from[name] : 0;
|
|
6317
6718
|
const smalls = (mb) => {
|
|
6318
6719
|
const value = mb / 4096;
|
|
@@ -6322,11 +6723,11 @@ function describeHeadroom(body, today, endsNow) {
|
|
|
6322
6723
|
const at4 = new Date(iso).toISOString();
|
|
6323
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`;
|
|
6324
6725
|
};
|
|
6325
|
-
const range = today ? "today (UTC)" : `from ${String(
|
|
6726
|
+
const range = today ? "today (UTC)" : `from ${String(answer2["from"] ?? "")} to ${String(answer2["to"] ?? "")}`;
|
|
6326
6727
|
const lines = [
|
|
6327
|
-
`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(
|
|
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}`
|
|
6328
6729
|
];
|
|
6329
|
-
const bursts = Array.isArray(
|
|
6730
|
+
const bursts = Array.isArray(answer2["bursts"]) ? answer2["bursts"] : [];
|
|
6330
6731
|
const open = endsNow ? bursts.find((one) => one["endedAt"] === null && typeof one["startedAt"] === "string") : void 0;
|
|
6331
6732
|
const meterMb = number(now, "meterMb");
|
|
6332
6733
|
const freeMb = number(now, "freeMb");
|
|
@@ -6342,7 +6743,7 @@ function describeHeadroom(body, today, endsNow) {
|
|
|
6342
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`);
|
|
6343
6744
|
}
|
|
6344
6745
|
lines.push(`fees: ${money(number(now, "spentMicros"))} this month of a ${money(number(now, "budgetMicros"))} budget`);
|
|
6345
|
-
const refused =
|
|
6746
|
+
const refused = answer2["refused"] && typeof answer2["refused"] === "object" ? answer2["refused"] : {};
|
|
6346
6747
|
const total = number(refused, "total");
|
|
6347
6748
|
const byReason = Array.isArray(refused["byReason"]) ? refused["byReason"] : [];
|
|
6348
6749
|
lines.push(
|
|
@@ -6468,7 +6869,7 @@ function sandboxesForPeople(sandboxes2, names, sorted) {
|
|
|
6468
6869
|
ACTIVE.has(text(sandbox["status"])) ? "\u25CF" : "\u25CB",
|
|
6469
6870
|
text(sandbox["id"]),
|
|
6470
6871
|
text(sandbox["name"]),
|
|
6471
|
-
|
|
6872
|
+
sizeOf2(sandbox),
|
|
6472
6873
|
templateId ? names.get(templateId) ?? templateId : "-",
|
|
6473
6874
|
status(sandbox),
|
|
6474
6875
|
...showVm ? [sandbox["vmIsolation"] === true ? "yes" : "no"] : [],
|
|
@@ -6617,7 +7018,10 @@ Usage
|
|
|
6617
7018
|
agental meta <sandbox-id> [set <key>=<value>... | unset <key>...] [--json]
|
|
6618
7019
|
agental regions [--json]
|
|
6619
7020
|
agental exec <sandbox-id> -- <command> [args...]
|
|
6620
|
-
agental shell <sandbox-id> a login shell in it, in this terminal:
|
|
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
|
|
6621
7025
|
agental delete <sandbox-id>
|
|
6622
7026
|
agental start <sandbox-id> [--max-burst-fee <dollars>]
|
|
6623
7027
|
agental stop <sandbox-id> [--keep-memory]
|
|
@@ -6626,6 +7030,8 @@ Usage
|
|
|
6626
7030
|
agental delete --where '<words>' [--confirm <count>] asks for the count to be typed
|
|
6627
7031
|
agental jobs [list | show <job-id> | cancel <job-id>] [--json]
|
|
6628
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
|
|
6629
7035
|
agental auto-stop <sandbox-id> [--in <time> | --at <date-time> | --never] [--json]
|
|
6630
7036
|
agental network <sandbox-id> [--allow <address>[,<address>...] | --none] [--json]
|
|
6631
7037
|
agental egress <sandbox-id> [box | residential <country> [sticky | rotating]] [--json]
|
|
@@ -6697,6 +7103,7 @@ Usage
|
|
|
6697
7103
|
agental account export [--out <file>]
|
|
6698
7104
|
agental ssh <sandbox-id> [--tmux] [ssh options] [command...]
|
|
6699
7105
|
agental scp [scp options] <source>... <target>
|
|
7106
|
+
${FILES_USAGE.map((line) => ` ${line}`).join("\n")}
|
|
6700
7107
|
agental ssh-config <sandbox-id>
|
|
6701
7108
|
agental ssh-keys <sandbox-id> [--remove <key-id>] [--json]
|
|
6702
7109
|
agental ssh-off <sandbox-id>
|
|
@@ -6735,6 +7142,13 @@ The key is kept in ~/.config/agental/credentials.json, readable by you alone. lo
|
|
|
6735
7142
|
key from your account and that file. whoami says who the command is signed in as, and with which
|
|
6736
7143
|
key. AGENTAL_API_KEY, when it is set, is used in place of what is kept.
|
|
6737
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.
|
|
6738
7152
|
recover gets a sandbox that is stuck going again: what runs in it is killed, its disk is kept,
|
|
6739
7153
|
and it ends running. One that is stopped is started, and pays a burst fee as a start does.
|
|
6740
7154
|
Start of a sandbox that was archived is accepted and finished afterwards: list shows it as
|
|
@@ -6902,6 +7316,14 @@ account export prints everything agental keeps about your account and you, as JS
|
|
|
6902
7316
|
account, its sessions with the address and browser each began from, its keys by name, billing,
|
|
6903
7317
|
payments, usage, and what it has made. Secrets are named, never given. --out writes it to a file
|
|
6904
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.
|
|
6905
7327
|
ssh opens a shell in a running sandbox, or runs a command there, with the ssh that is installed
|
|
6906
7328
|
here. It turns SSH on for the sandbox, which opens a port of the server the sandbox is on, lets
|
|
6907
7329
|
in a key of its own, ~/.ssh/agental_ed25519, which it makes when there is none, and connects
|