agental 0.27.0 → 0.29.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 +191 -30
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -7411,7 +7411,7 @@ import { parseArgs } from "node:util";
7411
7411
 
7412
7412
  // ../src/cli-build.ts
7413
7413
  var PUBLISHED = true;
7414
- var CLI_VERSION = true ? "0.27.0" : "dev";
7414
+ var CLI_VERSION = true ? "0.29.0" : "dev";
7415
7415
  var DEFAULT_API_URL = true ? "https://agental.io" : "http://127.0.0.1:8741";
7416
7416
  var PACKAGE_NAME = "agental";
7417
7417
  var USER_AGENT = `agental-cli/${CLI_VERSION}`;
@@ -8283,10 +8283,10 @@ async function whoIs(base, key2) {
8283
8283
  throw error;
8284
8284
  }
8285
8285
  }
8286
- async function pushRequest(base, ask9) {
8286
+ async function pushRequest(base, ask10) {
8287
8287
  let made;
8288
8288
  try {
8289
- made = await call(base, "POST", "/v1/cli-sign-ins", ask9);
8289
+ made = await call(base, "POST", "/v1/cli-sign-ins", ask10);
8290
8290
  } catch (error) {
8291
8291
  if (error instanceof Refused && (error.status === 401 || error.status === 404)) {
8292
8292
  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.`);
@@ -8901,27 +8901,27 @@ function codingAgentHere(env = process.env) {
8901
8901
  ...[env["CLAUDE_CONFIG_DIR"], env["CODEX_HOME"]].filter((folder) => Boolean(folder?.trim()))
8902
8902
  ].some((folder) => existsSync2(folder));
8903
8903
  }
8904
- async function ensureSkills(options, site) {
8904
+ async function ensureSkills(options, site2) {
8905
8905
  if (!options.installSkills) {
8906
8906
  return null;
8907
8907
  }
8908
8908
  if (!codingAgentHere()) {
8909
- return `${dim("no coding agent found on this computer, so no agent skills installed \xB7 once there is one:")} npx skills add ${site} -g`;
8909
+ return `${dim("no coding agent found on this computer, so no agent skills installed \xB7 once there is one:")} npx skills add ${site2} -g`;
8910
8910
  }
8911
8911
  const env = Object.fromEntries(Object.entries(process.env).filter(([name]) => !/^npm_(config_package|config_call|command|execpath|lifecycle_)/i.test(name)));
8912
8912
  const ran = await new Promise((resolve) => {
8913
8913
  execFile(
8914
8914
  process.platform === "win32" ? "npx.cmd" : "npx",
8915
- ["--yes", `--package=${SKILLS_CLI}`, "--", "skills", "add", site, "-g", "-y"],
8915
+ ["--yes", `--package=${SKILLS_CLI}`, "--", "skills", "add", site2, "-g", "-y"],
8916
8916
  { encoding: "utf8", timeout: 5 * 6e4, shell: process.platform === "win32", env },
8917
8917
  (error, stdout, stderr) => resolve({ ok: !error, out: `${stdout}${stderr}`.trim() })
8918
8918
  );
8919
8919
  });
8920
8920
  if (!ran.ok) {
8921
8921
  const last = ran.out.split("\n").filter((line) => line.trim()).pop() ?? "it failed";
8922
- return `${bold("!")} The agent skills were not installed (${last.slice(0, 160)}). Run ${bold(`npx skills add ${site} -g`)} to install them.`;
8922
+ return `${bold("!")} The agent skills were not installed (${last.slice(0, 160)}). Run ${bold(`npx skills add ${site2} -g`)} to install them.`;
8923
8923
  }
8924
- return done(`agent skills installed for the coding agents on this computer ${dim(`\xB7 again with npx skills add ${site} -g`)}`);
8924
+ return done(`agent skills installed for the coding agents on this computer ${dim(`\xB7 again with npx skills add ${site2} -g`)}`);
8925
8925
  }
8926
8926
  function ordered(sandboxes2) {
8927
8927
  return sandboxes2.filter((sandbox) => sandbox["status"] !== "deleted").sort((a, b) => Number(b["status"] === "running") - Number(a["status"] === "running") || String(b["createdAt"]).localeCompare(String(a["createdAt"])));
@@ -9091,8 +9091,8 @@ async function onboard(base, options) {
9091
9091
  account3 = credentials.account;
9092
9092
  term.say(` ${dim("signed in as")} ${bold(describe2(account3))} ${dim(`\xB7 with the key ${credentials.keyName ?? "pasted in"} \xB7 not you?`)} agental logout`);
9093
9093
  }
9094
- const site = new URL(base).origin;
9095
- const installs = (async () => [await ensureCommand(options), await ensureSkills(options, site)])();
9094
+ const site2 = new URL(base).origin;
9095
+ const installs = (async () => [await ensureCommand(options), await ensureSkills(options, site2)])();
9096
9096
  const report = async () => {
9097
9097
  for (const line of await installs) {
9098
9098
  if (line) {
@@ -9263,6 +9263,12 @@ var COMMANDS = [
9263
9263
  { name: "ssh-connect", summary: "Reach a sandbox for ssh: what the Host block ssh-config prints runs. It is not typed by hand." },
9264
9264
  { name: "ssh-keys", summary: "List or remove the SSH keys a sandbox lets in." },
9265
9265
  { name: "ssh-off", summary: "Turn SSH off for a sandbox and close its port." },
9266
+ {
9267
+ name: "site",
9268
+ summary: "List, add and remove a sandbox's sites: public links to its ports that anyone can open while it runs.",
9269
+ examples: ["agental site sbx_2a9a47e50daec64a", "agental site add sbx_2a9a47e50daec64a 3000", "agental site rm sbx_2a9a47e50daec64a rte_0123456789abcdef"],
9270
+ flags: [["--json", "list, add: print as JSON"]]
9271
+ },
9266
9272
  {
9267
9273
  name: "start",
9268
9274
  summary: "Start a stopped sandbox, or every one --where finds.",
@@ -9407,7 +9413,7 @@ var COMMANDS = [
9407
9413
  { name: "ci", summary: "Run GitHub Actions jobs on sandboxes: each repository's pool." },
9408
9414
  { name: "claude", summary: "Connect Claude Managed Agents environments, whose sessions run on sandboxes." },
9409
9415
  { name: "webhooks", summary: "List the addresses your account's events are sent to." },
9410
- { name: "webhook", summary: "Add, change and remove the addresses your account's events are sent to.", examples: ["agental webhook add https://example.com/agental --all"] },
9416
+ { name: "webhook", summary: "Add, change, turn off and remove the addresses your account's events are sent to.", examples: ["agental webhook add https://example.com/agental --all"] },
9411
9417
  { name: "keys", summary: "List your account's API keys." },
9412
9418
  {
9413
9419
  name: "key",
@@ -9516,6 +9522,7 @@ var MAP = [
9516
9522
  ["resize", "a larger size, now or at its next start"],
9517
9523
  ["job", "run a command on a timer"],
9518
9524
  ["secret", "values and files kept out of the sandbox"],
9525
+ ["site", "share a port on a public link"],
9519
9526
  ["network, egress", "what it may reach, and the address it leaves from"],
9520
9527
  ["tag, meta, summary", "label sandboxes and find them again"],
9521
9528
  ["metrics", "CPU, memory and disk over time"],
@@ -9961,7 +9968,7 @@ async function jobs(api2) {
9961
9968
  });
9962
9969
  }
9963
9970
  var KEPT_MS = 3e4;
9964
- async function cached(what, as, ask9) {
9971
+ async function cached(what, as, ask10) {
9965
9972
  const folder = path4.join(process.env["XDG_CACHE_HOME"] || path4.join(os5.homedir(), ".cache"), "agental");
9966
9973
  const file = path4.join(folder, `complete-${what}-${createHash2("sha256").update(as).digest("hex").slice(0, 16)}.json`);
9967
9974
  try {
@@ -9973,7 +9980,7 @@ async function cached(what, as, ask9) {
9973
9980
  }
9974
9981
  let body = null;
9975
9982
  try {
9976
- body = await ask9();
9983
+ body = await ask10();
9977
9984
  } catch {
9978
9985
  return null;
9979
9986
  }
@@ -11350,9 +11357,10 @@ function namedWithClosest(unknown) {
11350
11357
  }).join(", ");
11351
11358
  }
11352
11359
  var WEBHOOK_RETRY_AFTER_MS = [6e4, 5 * 6e4, 15 * 6e4, 60 * 6e4, 3 * 36e5, 6 * 36e5, 12 * 36e5];
11360
+ var WEBHOOK_OFF_AFTER_MS = 3 * 864e5;
11353
11361
 
11354
11362
  // ../src/cli-webhooks.ts
11355
- var USAGE5 = "webhook takes add, show, update, rotate or delete. agental webhook --help shows each.";
11363
+ var USAGE5 = "webhook takes add, show, update, on, off, rotate or delete. agental webhook --help shows each.";
11356
11364
  var EVERY = "*";
11357
11365
  var TRIES = WEBHOOK_RETRY_AFTER_MS.length + 1;
11358
11366
  async function ask7(client, method, pathname, body) {
@@ -11438,6 +11446,13 @@ function standingOf(events) {
11438
11446
  }
11439
11447
  return `given up (${answerOf(latest.tries[latest.tries.length - 1])}) ${at3(latest.lastAt)}`;
11440
11448
  }
11449
+ function stateOf(webhook2) {
11450
+ if (webhook2.enabled !== false) {
11451
+ return "on";
11452
+ }
11453
+ const since = webhook2.disabledAt ? ` since ${at3(webhook2.disabledAt)}` : "";
11454
+ return `off${since}${webhook2.disabledReason ? `: ${webhook2.disabledReason}` : ""}`;
11455
+ }
11441
11456
  function eventsFrom(options, needed) {
11442
11457
  if (options.all && options.events !== void 0) {
11443
11458
  throw new Error("Give --events or --all, not both.");
@@ -11467,6 +11482,7 @@ function describe3(webhook2) {
11467
11482
  `url: ${webhook2.url}`,
11468
11483
  `sent: ${sentOf(webhook2.events)}`,
11469
11484
  `added: ${at3(webhook2.createdAt)}`,
11485
+ `state: ${stateOf(webhook2)}`,
11470
11486
  `last post: ${standingOf(eventsOf2(webhook2.deliveries))}`,
11471
11487
  ""
11472
11488
  ].join("\n");
@@ -11496,7 +11512,8 @@ async function listWebhooks(client, asJson) {
11496
11512
  for (const webhook2 of webhooks) {
11497
11513
  const listed = webhook2.events.join(",");
11498
11514
  const sent = webhook2.events.includes(EVERY) ? "every event" : listed.length <= 33 ? listed : `${webhook2.events.length} kinds`;
11499
- process.stdout.write(`${[pad3(webhook2.id, 22), pad3(nameOf(webhook2), 18), pad3(sent, 34), standingOf(eventsOf2(webhook2.deliveries))].join(" ")}
11515
+ const standing = webhook2.enabled === false ? stateOf(webhook2) : standingOf(eventsOf2(webhook2.deliveries));
11516
+ process.stdout.write(`${[pad3(webhook2.id, 22), pad3(nameOf(webhook2), 18), pad3(sent, 34), standing].join(" ")}
11500
11517
  `);
11501
11518
  }
11502
11519
  }
@@ -11567,6 +11584,20 @@ async function webhook(client, positionals, options) {
11567
11584
  ` : describe3(updated));
11568
11585
  return;
11569
11586
  }
11587
+ case "on":
11588
+ case "off": {
11589
+ const turned = webhookOf(await ask7(client, "PATCH", `/v1/webhooks/${encodeURIComponent(needId(target, what))}`, { enabled: what === "on" }));
11590
+ if (options.json) {
11591
+ process.stdout.write(`${JSON.stringify(turned, null, 2)}
11592
+ `);
11593
+ return;
11594
+ }
11595
+ process.stdout.write(describe3(turned));
11596
+ process.stderr.write(
11597
+ what === "on" ? "On. It is posted the events made from now on; none given up while it was off is sent.\n" : "Off. Nothing is posted to it, and the events still owed to it are given up. agental webhook on turns it on again.\n"
11598
+ );
11599
+ return;
11600
+ }
11570
11601
  case "rotate": {
11571
11602
  const rotated = webhookOf(await ask7(client, "POST", `/v1/webhooks/${encodeURIComponent(needId(target, "rotate"))}/rotate`));
11572
11603
  if (options.json) {
@@ -11594,11 +11625,119 @@ function needId(id, what) {
11594
11625
  return id;
11595
11626
  }
11596
11627
 
11628
+ // ../src/cli-sites.ts
11629
+ var USAGE6 = "site takes a sandbox, or list, add or rm, then the sandbox. agental site --help shows each.";
11630
+ async function ask8(client, method, pathname, body) {
11631
+ const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
11632
+ let answered = null;
11633
+ try {
11634
+ answered = await response.json();
11635
+ } catch {
11636
+ answered = null;
11637
+ }
11638
+ if (!response.ok) {
11639
+ client.fail(response.status, answered);
11640
+ }
11641
+ return answered;
11642
+ }
11643
+ function routeOf(body) {
11644
+ if (!body || typeof body !== "object" || typeof body.id !== "string") {
11645
+ throw new Error("The answer was not a host route.");
11646
+ }
11647
+ return body;
11648
+ }
11649
+ var isSite = (route) => route.public && !route.hidden;
11650
+ async function sitesOf(client, sandbox) {
11651
+ const body = await ask8(client, "GET", `/v1/sandboxes/${encodeURIComponent(sandbox)}/host`);
11652
+ return (Array.isArray(body?.routes) ? body.routes : []).map(routeOf).filter(isSite);
11653
+ }
11654
+ function stateOf2(route) {
11655
+ if (route.proxy !== "available") {
11656
+ return "not reachable: is the sandbox running?";
11657
+ }
11658
+ return route.listening ? "live" : `nothing listening on ${route.port}`;
11659
+ }
11660
+ function portFrom(given) {
11661
+ const port = Number(given);
11662
+ if (given === void 0 || !/^\d+$/.test(given) || port < 1 || port > 65535) {
11663
+ throw new Error(`site add needs the port a server listens on in the sandbox, 1 to 65535, as agental site add <sandbox-id> 3000${given === void 0 ? "" : `. It was given ${given}`}.`);
11664
+ }
11665
+ return port;
11666
+ }
11667
+ async function site(client, positionals, options) {
11668
+ const verb = positionals[0] === "list" || positionals[0] === "add" || positionals[0] === "rm" ? positionals[0] : null;
11669
+ const [sandbox, target, ...rest] = verb === null ? positionals : positionals.slice(1);
11670
+ if (sandbox === void 0) {
11671
+ throw new Error(USAGE6);
11672
+ }
11673
+ switch (verb) {
11674
+ case null:
11675
+ case "list": {
11676
+ if (target !== void 0) {
11677
+ throw new Error(USAGE6);
11678
+ }
11679
+ const sites = await sitesOf(client, sandbox);
11680
+ if (options.json) {
11681
+ process.stdout.write(`${JSON.stringify({ sites }, null, 2)}
11682
+ `);
11683
+ return;
11684
+ }
11685
+ if (sites.length === 0) {
11686
+ process.stdout.write(`${sandbox} has no sites. agental site add ${sandbox} <port> gives a port a public link.
11687
+ `);
11688
+ return;
11689
+ }
11690
+ const rows = [["ID", "ADDRESS", "PORT", "STATE"], ...sites.map((route) => [route.id, route.url ?? "no public address here", String(route.port), stateOf2(route)])];
11691
+ const terminal2 = isTerminal(process.stdout);
11692
+ process.stdout.write(fitted(rows, { ...terminal2 ? { give: 1 } : { width: Number.MAX_SAFE_INTEGER }, paint: (cell, row) => row === 0 ? faint(cell) : cell }));
11693
+ return;
11694
+ }
11695
+ case "add": {
11696
+ if (rest.length > 0) {
11697
+ throw new Error(USAGE6);
11698
+ }
11699
+ const port = portFrom(target);
11700
+ const made = routeOf(await ask8(client, "POST", `/v1/sandboxes/${encodeURIComponent(sandbox)}/host`, { port, title: `port-${port}`, public: true }));
11701
+ if (options.json) {
11702
+ process.stdout.write(`${JSON.stringify(made, null, 2)}
11703
+ `);
11704
+ return;
11705
+ }
11706
+ if (made.url === null) {
11707
+ process.stdout.write(`${made.id}
11708
+ `);
11709
+ process.stderr.write("Public links are not switched on here, so this port has none. It is reached through the API with a key, at its proxyPath (--json shows it).\n");
11710
+ return;
11711
+ }
11712
+ process.stdout.write(`${made.url}
11713
+ `);
11714
+ process.stderr.write(
11715
+ `Anyone with the link can open port ${port} while the sandbox runs. The server must listen on 0.0.0.0. agental site rm ${sandbox} ${made.id} takes it away.
11716
+ `
11717
+ );
11718
+ return;
11719
+ }
11720
+ case "rm": {
11721
+ if (target === void 0 || rest.length > 0) {
11722
+ throw new Error(`site rm needs the sandbox and the site's id, as agental site ${sandbox} lists them.`);
11723
+ }
11724
+ const found = (await sitesOf(client, sandbox)).find((route) => route.id === target);
11725
+ if (!found) {
11726
+ throw new Error(`${sandbox} has no site ${target}. agental site ${sandbox} lists its sites.`);
11727
+ }
11728
+ await ask8(client, "POST", `/v1/host-routes/${encodeURIComponent(target)}/hide`);
11729
+ process.stdout.write(`Removed. ${found.url ?? `Port ${found.port}`} stops working now; adding port ${found.port} again gives a new link.
11730
+ `);
11731
+ return;
11732
+ }
11733
+ }
11734
+ }
11735
+
11597
11736
  // ../src/cli-claude.ts
11598
- var USAGE6 = "claude takes connect, show, update or disconnect. agental claude --help shows each.";
11737
+ var USAGE7 = "claude takes connect, show, update or disconnect. agental claude --help shows each.";
11599
11738
  var KEY_VARIABLE = "ANTHROPIC_ENVIRONMENT_KEY";
11600
11739
  var SECRET_VARIABLE = "ANTHROPIC_WEBHOOK_SIGNING_KEY";
11601
- async function ask8(client, method, pathname, body) {
11740
+ async function ask9(client, method, pathname, body) {
11602
11741
  const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
11603
11742
  let answered = null;
11604
11743
  if (response.status !== 204) {
@@ -11688,7 +11827,7 @@ async function hidden(question) {
11688
11827
  });
11689
11828
  }
11690
11829
  async function listClaude(client, asJson) {
11691
- const body = await ask8(client, "GET", "/v1/claude/connections");
11830
+ const body = await ask9(client, "GET", "/v1/claude/connections");
11692
11831
  if (asJson) {
11693
11832
  process.stdout.write(`${JSON.stringify(body, null, 2)}
11694
11833
  `);
@@ -11710,7 +11849,7 @@ async function listClaude(client, asJson) {
11710
11849
  async function claude(client, positionals, options) {
11711
11850
  const [what, target, ...rest] = positionals;
11712
11851
  if (rest.length > 0) {
11713
- throw new Error(USAGE6);
11852
+ throw new Error(USAGE7);
11714
11853
  }
11715
11854
  switch (what) {
11716
11855
  case "connect": {
@@ -11722,7 +11861,7 @@ async function claude(client, positionals, options) {
11722
11861
  const environmentKey = await secretFrom(KEY_VARIABLE, "environment key", true);
11723
11862
  const webhookSecret = await secretFrom(SECRET_VARIABLE, "webhook signing secret", false);
11724
11863
  const made = connectionOf(
11725
- await ask8(client, "POST", "/v1/claude/connections", {
11864
+ await ask9(client, "POST", "/v1/claude/connections", {
11726
11865
  environmentId: target,
11727
11866
  environmentKey,
11728
11867
  ...webhookSecret !== void 0 ? { webhookSecret } : {},
@@ -11744,7 +11883,7 @@ async function claude(client, positionals, options) {
11744
11883
  return;
11745
11884
  }
11746
11885
  case "show": {
11747
- const found = connectionOf(await ask8(client, "GET", `/v1/claude/connections/${encodeURIComponent(needId2(target, "show"))}`));
11886
+ const found = connectionOf(await ask9(client, "GET", `/v1/claude/connections/${encodeURIComponent(needId2(target, "show"))}`));
11748
11887
  process.stdout.write(options.json ? `${JSON.stringify(found, null, 2)}
11749
11888
  ` : describe4(found));
11750
11889
  return;
@@ -11767,18 +11906,18 @@ async function claude(client, positionals, options) {
11767
11906
  if (Object.keys(patch).length === 0) {
11768
11907
  throw new Error("claude update changes --template, --keep-days, --new-key, --webhook-secret or --no-webhook-secret, and was given none of them.");
11769
11908
  }
11770
- const updated = connectionOf(await ask8(client, "PATCH", `/v1/claude/connections/${encodeURIComponent(id)}`, patch));
11909
+ const updated = connectionOf(await ask9(client, "PATCH", `/v1/claude/connections/${encodeURIComponent(id)}`, patch));
11771
11910
  process.stdout.write(options.json ? `${JSON.stringify(updated, null, 2)}
11772
11911
  ` : describe4(updated));
11773
11912
  return;
11774
11913
  }
11775
11914
  case "disconnect": {
11776
- await ask8(client, "DELETE", `/v1/claude/connections/${encodeURIComponent(needId2(target, "disconnect"))}`);
11915
+ await ask9(client, "DELETE", `/v1/claude/connections/${encodeURIComponent(needId2(target, "disconnect"))}`);
11777
11916
  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");
11778
11917
  return;
11779
11918
  }
11780
11919
  default:
11781
- throw new Error(USAGE6);
11920
+ throw new Error(USAGE7);
11782
11921
  }
11783
11922
  }
11784
11923
  function needId2(id, what) {
@@ -11866,7 +12005,7 @@ async function shellNamed(client, id, given, flag) {
11866
12005
  }
11867
12006
  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.`);
11868
12007
  }
11869
- function stateOf(each) {
12008
+ function stateOf3(each) {
11870
12009
  if (each.exit) {
11871
12010
  return each.exit.signal > 0 ? `ended by signal ${each.exit.signal}` : `exited ${each.exit.code}`;
11872
12011
  }
@@ -11886,7 +12025,7 @@ async function listShells(client, id, json2, stdout) {
11886
12025
  }
11887
12026
  const rows = [
11888
12027
  ["N", "ID", "RUNNING", "CWD", "ATTACHED", "STARTED"],
11889
- ...listed.map((each) => [String(each.n), each.id, stateOf(each), each.cwd ?? "", each.attached ? "yes" : "no", ago(each.startedAt) ?? each.startedAt])
12028
+ ...listed.map((each) => [String(each.n), each.id, stateOf3(each), each.cwd ?? "", each.attached ? "yes" : "no", ago(each.startedAt) ?? each.startedAt])
11890
12029
  ];
11891
12030
  stdout.write(fitted(rows, { give: 2, paint: (cell, row) => row === 0 ? faint(cell, stdout) : cell }));
11892
12031
  }
@@ -11935,16 +12074,16 @@ async function shell(client, id, options = {}, streams = process) {
11935
12074
  const verifier = randomBytes4(32).toString("base64url");
11936
12075
  const challenge = createHash3("sha256").update(verifier).digest("base64url");
11937
12076
  const interactive = stdin.isTTY === true && typeof stdin.setRawMode === "function";
11938
- const ask9 = async (keep) => await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminal`, {
12077
+ const ask10 = async (keep) => await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminal`, {
11939
12078
  method: "POST",
11940
12079
  body: JSON.stringify({ ...size2, challenge, ...again ? { terminal: again.id } : keep ? { keep: true } : {} })
11941
12080
  });
11942
- let response = await ask9(interactive);
12081
+ let response = await ask10(interactive);
11943
12082
  let body = await response.json().catch(() => null);
11944
12083
  if (!again && interactive && response.status === 409 && body?.error?.code === "terminal_unavailable" && /keeps \d+ terminals/.test(String(body.error.message ?? ""))) {
11945
12084
  stderr.write(`${String(body.error.message)} This one is not kept.
11946
12085
  `);
11947
- response = await ask9(false);
12086
+ response = await ask10(false);
11948
12087
  body = await response.json().catch(() => null);
11949
12088
  }
11950
12089
  if (!response.ok || typeof body?.ticket !== "string") {
@@ -12730,6 +12869,9 @@ async function main() {
12730
12869
  case "browser":
12731
12870
  await browser(positionals[1], values.headless, values.headed, values.off, values.status);
12732
12871
  return;
12872
+ case "site":
12873
+ await site({ request, fail }, positionals.slice(1), { json: values.json });
12874
+ return;
12733
12875
  case "network":
12734
12876
  await network(positionals.slice(1), values);
12735
12877
  return;
@@ -13300,6 +13442,11 @@ async function lifecycle(action, id, headers = {}, sent) {
13300
13442
  }
13301
13443
  process.stdout.write(`${JSON.stringify(body, null, 2)}
13302
13444
  `);
13445
+ const memoryLost = Boolean(body) && typeof body === "object" ? body["memoryLost"] : null;
13446
+ if (typeof memoryLost === "string" && memoryLost !== "" && (action === "start" || sent?.["keepMemory"] === true)) {
13447
+ process.stderr.write(`${memoryLost}
13448
+ `);
13449
+ }
13303
13450
  if (action === "start" && response.status === 202) {
13304
13451
  const archived = Boolean(body) && typeof body === "object" && body["archived"] === true;
13305
13452
  const why2 = archived ? "it is archived and is being brought back, which takes as long as its disk is large" : "its machine was being archived, and is started as soon as that has ended";
@@ -15461,6 +15608,7 @@ Usage
15461
15608
  agental webhook add <url> (--events <kind>[,<kind>...] | --all) [--description <text>] [--json]
15462
15609
  agental webhook show <webhook-id> [--json]
15463
15610
  agental webhook update <webhook-id> [--url <url>] [--events <kind>[,<kind>...] | --all] [--description <text>] [--json]
15611
+ agental webhook on|off <webhook-id> [--json]
15464
15612
  agental webhook rotate <webhook-id> [--json]
15465
15613
  agental webhook delete <webhook-id>
15466
15614
  agental claude [--json]
@@ -15494,6 +15642,10 @@ ${FILES_USAGE.map((line) => ` ${line}`).join("\n")}
15494
15642
  agental ssh-config <sandbox-id>
15495
15643
  agental ssh-keys <sandbox-id> [--remove <key-id>] [--json]
15496
15644
  agental ssh-off <sandbox-id>
15645
+ agental site <sandbox-id> [--json] its sites: public links to its ports
15646
+ agental site list <sandbox-id> [--json]
15647
+ agental site add <sandbox-id> <port> [--json] a public link to a port, printed
15648
+ agental site rm <sandbox-id> <site-id> the link stops working, for good
15497
15649
  agental email <sandbox-id> [--json]
15498
15650
  agental email on|off <sandbox-id>
15499
15651
  agental email list <sandbox-id> [--limit <n>] [--json]
@@ -15685,7 +15837,10 @@ X-Agental-Signature, the HMAC-SHA256 of its body under that secret. show says wh
15685
15837
  how its last post went, and each event it did not take at the first try, with the answer to
15686
15838
  every try. A post that is not answered with a 2xx is made again after 1, 5 and 15 minutes and
15687
15839
  1, 3, 6 and 12 hours, eight tries in all, under the same event id. update changes its address,
15688
- its kinds or its description, and keeps what it is not given. rotate gives it a new secret,
15840
+ its kinds or its description, and keeps what it is not given. off turns it off: nothing is
15841
+ posted to it, and the events still owed to it are given up. A webhook turns itself off when an
15842
+ event fails its last try and none of its tries has been taken for 3 days. on turns it on again,
15843
+ for the events made from then on. rotate gives it a new secret,
15689
15844
  and the old one stops working at once. delete removes it, the events still owed to it, and its
15690
15845
  tries.
15691
15846
  claude lists the Claude Managed Agents environments connected to this account: each session of a
@@ -15778,6 +15933,12 @@ create --ssh-key lets a key in as the sandbox is made, given as its line or its
15778
15933
  a template from now on, and template ssh on turns SSH on as each is made, so that ssh reaches
15779
15934
  it at once. A sandbox made already keeps what it was given.
15780
15935
  ssh-off turns SSH off for a sandbox: its port is closed, which cuts whoever is connected.
15936
+ site lists a sandbox's sites: its ports that have a public link, which anyone with the link can
15937
+ open, with no key, while the sandbox runs. Each shows its id, its address, its port and whether
15938
+ something listens there now. site add gives a port a link and prints it; the server in the
15939
+ sandbox must listen on 0.0.0.0. site rm takes a site away for good: its link stops working at
15940
+ once, and adding the port again gives a new one. They are the API's host routes with public
15941
+ true, and site rm is POST /v1/host-routes/{id}/hide.
15781
15942
  email says whether mail is on for a sandbox, and the domain its addresses end in: any name
15782
15943
  before the @ of that domain reaches the sandbox. Mail is off until email on turns it on, for
15783
15944
  receiving and for sending both, and each message is charged to the account from then on. email
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agental",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "The agental command: Linux sandboxes for your agents, from the terminal. npx agental@latest signs you in and installs the agent skills.",
5
5
  "license": "MIT",
6
6
  "author": "VERTIXER LTD",