agental 0.42.0 → 0.43.1

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 +413 -93
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -7403,7 +7403,7 @@ var init_cli_operator = __esm({
7403
7403
  });
7404
7404
 
7405
7405
  // ../src/cli.ts
7406
- import { randomUUID as randomUUID2 } from "node:crypto";
7406
+ import { randomUUID as randomUUID3 } from "node:crypto";
7407
7407
  import { readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "node:fs";
7408
7408
  import os7 from "node:os";
7409
7409
  import { readFile as readFile2 } from "node:fs/promises";
@@ -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.42.0" : "dev";
7414
+ var CLI_VERSION = true ? "0.43.1" : "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}`;
@@ -7990,6 +7990,9 @@ function canDoOf(key2, full) {
7990
7990
  return everything ? `${named}everything, and any action added later` : `${named}${key2.actions.join(", ")}`;
7991
7991
  }
7992
7992
  function reachOf(key2, full) {
7993
+ if (key2.madeOnly === true) {
7994
+ return full ? "only the sandboxes it made, and their snapshots" : "only what it made";
7995
+ }
7993
7996
  if (key2.sandboxIds.length === 0 && key2.templateIds.length === 0) {
7994
7997
  return key2.seesAll ? "every account" : "all of the account";
7995
7998
  }
@@ -8283,10 +8286,10 @@ async function whoIs(base, key2) {
8283
8286
  throw error;
8284
8287
  }
8285
8288
  }
8286
- async function pushRequest(base, ask11) {
8289
+ async function pushRequest(base, ask12) {
8287
8290
  let made;
8288
8291
  try {
8289
- made = await call(base, "POST", "/v1/cli-sign-ins", ask11);
8292
+ made = await call(base, "POST", "/v1/cli-sign-ins", ask12);
8290
8293
  } catch (error) {
8291
8294
  if (error instanceof Refused && (error.status === 401 || error.status === 404)) {
8292
8295
  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.`);
@@ -9408,6 +9411,7 @@ var COMMANDS = [
9408
9411
  flags: [
9409
9412
  ["-n, --name <name>", "what to call it; left out, it is made up as sbx-\u2026"],
9410
9413
  ["-t, --template <template>", "what it starts from (default: your default template)"],
9414
+ [" --snapshot <snapshot-id>", "start it from this snapshot's disk"],
9411
9415
  ["-s, --size <size>", "tiny, small, medium or large (default: the template's)"],
9412
9416
  [" --region <region>", "where it runs; agental regions lists them"],
9413
9417
  [" --ttl <time>", "stop it after this long, as 30m or 2h"],
@@ -9668,6 +9672,16 @@ var COMMANDS = [
9668
9672
  { name: "data-retention", summary: "Say how long your sandboxes' history is kept." },
9669
9673
  { name: "ci", summary: "Run GitHub Actions jobs on sandboxes: each repository's pool." },
9670
9674
  { name: "claude", summary: "Connect Claude Managed Agents environments, whose sessions run on sandboxes." },
9675
+ {
9676
+ name: "snapshot",
9677
+ summary: "Take, list, read, roll back to and delete snapshots: a sandbox's disk as it was at a moment.",
9678
+ examples: ["agental snapshot create review-41 before-migration", "agental snapshot list --sandbox review-41", "agental snapshot show before-migration", "agental snapshot restore snap_5c1d0a9e8b7f6e42"],
9679
+ flags: [
9680
+ ["--sandbox <sandbox>", "list: one sandbox's; show, restore, delete: look the name up among its snapshots"],
9681
+ ["--yes", "restore, delete: go on without asking"],
9682
+ ["--json", "print the API's answer as JSON"]
9683
+ ]
9684
+ },
9671
9685
  { name: "webhooks", summary: "List the addresses your account's events are sent to." },
9672
9686
  { 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"] },
9673
9687
  { name: "keys", summary: "List your account's API keys." },
@@ -9784,7 +9798,7 @@ var MAP = [
9784
9798
  ["metrics", "CPU, memory and disk over time"],
9785
9799
  ["email", "an email address of its own"],
9786
9800
  ["desktop, browser", "a screen and a Chrome in the sandbox"],
9787
- ["files", "list, send, fetch, move and delete its files"],
9801
+ ["files, snapshot", "its files, and its disk kept to roll back to"],
9788
9802
  ["scp, ssh-config", "files, and SSH from any tool"],
9789
9803
  ["bulk, region", "work on many at once, and where they run"]
9790
9804
  ]
@@ -10089,6 +10103,7 @@ function flagsOf(usages) {
10089
10103
  var SANDBOX = /^<sandbox-id>/;
10090
10104
  var SANDBOX_VERBS2 = /* @__PURE__ */ new Set(["list", "create", "start", "stop", "delete", "recover", "exec", "shell", "summary"]);
10091
10105
  var TEMPLATE = /^<template>/;
10106
+ var SNAPSHOT = /^<snapshot/;
10092
10107
  var JOB = /^<job>/;
10093
10108
  var KEPT_SHELL = /^<shell>/;
10094
10109
  var COMMAND_ID = /^<command-id>/;
@@ -10137,6 +10152,9 @@ async function complete(typed, reference, operator, fetchJson) {
10137
10152
  if (SANDBOX.test(valueOf)) {
10138
10153
  return starting(await sandboxes(fetchJson));
10139
10154
  }
10155
+ if (SNAPSHOT.test(valueOf)) {
10156
+ return starting(await snapshots(fetchJson));
10157
+ }
10140
10158
  if (KEPT_SHELL.test(valueOf)) {
10141
10159
  const sandbox2 = before.slice(1).find((word) => /^sbx_[A-Za-z0-9]+$/.test(word));
10142
10160
  return sandbox2 ? starting(await keptShells(fetchJson, sandbox2)) : [];
@@ -10160,6 +10178,7 @@ async function complete(typed, reference, operator, fetchJson) {
10160
10178
  let wantsSandbox = false;
10161
10179
  let wantsTemplate = false;
10162
10180
  let wantsJob = false;
10181
+ let wantsSnapshot = false;
10163
10182
  let wantsCommand = false;
10164
10183
  for (const usage of usages) {
10165
10184
  const parts = partsOf(usage).slice(1);
@@ -10182,6 +10201,7 @@ async function complete(typed, reference, operator, fetchJson) {
10182
10201
  wantsSandbox ||= SANDBOX.test(inner);
10183
10202
  wantsTemplate ||= TEMPLATE.test(inner);
10184
10203
  wantsJob ||= JOB.test(inner);
10204
+ wantsSnapshot ||= SNAPSHOT.test(inner);
10185
10205
  wantsCommand ||= COMMAND_ID.test(inner);
10186
10206
  }
10187
10207
  if (positionals.length === 0) {
@@ -10197,6 +10217,7 @@ async function complete(typed, reference, operator, fetchJson) {
10197
10217
  ...wantsSandbox ? await sandboxes(fetchJson) : [],
10198
10218
  ...wantsTemplate ? await templates(fetchJson) : [],
10199
10219
  ...wantsJob ? await jobs(fetchJson) : [],
10220
+ ...wantsSnapshot ? await snapshots(fetchJson) : [],
10200
10221
  ...wantsCommand && sandbox !== void 0 ? await commandsIn(fetchJson, sandbox) : []
10201
10222
  ];
10202
10223
  return starting([...candidates.values(), ...asked2]);
@@ -10231,6 +10252,11 @@ async function commandsIn(api2, sandbox) {
10231
10252
  return about ? { value: each["id"], about } : { value: each["id"] };
10232
10253
  });
10233
10254
  }
10255
+ async function snapshots(api2) {
10256
+ const body = await cached("snapshots", api2.as, () => api2.get("/v1/snapshots"));
10257
+ const listed = Array.isArray(body?.snapshots) ? body.snapshots : [];
10258
+ return listed.filter((each) => typeof each["id"] === "string").reverse().map((each) => ({ value: each["id"], about: [each["name"], each["sandboxName"]].filter((word) => typeof word === "string" && word).join(", ") }));
10259
+ }
10234
10260
  async function templates(api2) {
10235
10261
  const body = await cached("templates", api2.as, () => api2.get("/v1/templates"));
10236
10262
  const listed = Array.isArray(body) ? body : body?.templates ?? [];
@@ -10246,7 +10272,7 @@ async function jobs(api2) {
10246
10272
  });
10247
10273
  }
10248
10274
  var KEPT_MS = 3e4;
10249
- async function cached(what, as, ask11) {
10275
+ async function cached(what, as, ask12) {
10250
10276
  const folder = path5.join(process.env["XDG_CACHE_HOME"] || path5.join(os6.homedir(), ".cache"), "agental");
10251
10277
  const file = path5.join(folder, `complete-${what}-${createHash2("sha256").update(as).digest("hex").slice(0, 16)}.json`);
10252
10278
  try {
@@ -10258,7 +10284,7 @@ async function cached(what, as, ask11) {
10258
10284
  }
10259
10285
  let body = null;
10260
10286
  try {
10261
- body = await ask11();
10287
+ body = await ask12();
10262
10288
  } catch {
10263
10289
  return null;
10264
10290
  }
@@ -12539,8 +12565,338 @@ function needId(id, what) {
12539
12565
  return id;
12540
12566
  }
12541
12567
 
12568
+ // ../src/cli-snapshots.ts
12569
+ import { randomUUID as randomUUID2 } from "node:crypto";
12570
+
12571
+ // ../src/domain.ts
12572
+ var MACHINE_SIZES = {
12573
+ tiny: { vcpu: 1, memoryMb: 2048, diskGb: 20 },
12574
+ small: { vcpu: 2, memoryMb: 4096, diskGb: 40 },
12575
+ medium: { vcpu: 4, memoryMb: 8192, diskGb: 80 },
12576
+ large: { vcpu: 8, memoryMb: 16384, diskGb: 160 }
12577
+ };
12578
+ var MACHINE_SIZE_NAMES = ["tiny", "small", "medium", "large"];
12579
+ var LIST_PRICE_MICROS_PER_HOUR = {
12580
+ tiny: 13500,
12581
+ small: 27e3,
12582
+ medium: 54e3,
12583
+ large: 108e3
12584
+ };
12585
+ var SPOT_PRICE_MICROS_PER_HOUR = {
12586
+ tiny: LIST_PRICE_MICROS_PER_HOUR.tiny / 2,
12587
+ small: LIST_PRICE_MICROS_PER_HOUR.small / 2,
12588
+ medium: LIST_PRICE_MICROS_PER_HOUR.medium / 2,
12589
+ large: LIST_PRICE_MICROS_PER_HOUR.large / 2
12590
+ };
12591
+ var SPOT_ON_RECLAIM = ["delete", "stop"];
12592
+ var SPOT_ON_RECLAIM_READ = [...SPOT_ON_RECLAIM, "upgrade"];
12593
+ var SPOT_RUN_LIMIT_SECONDS = 24 * 60 * 60;
12594
+ var HOURS_PER_MONTH = 730;
12595
+ var STOPPED_MICROS_PER_GB_MONTH = 5e4;
12596
+ var BYTES_PER_GB = 1e9;
12597
+ var NEVER_PAID_MAX_STORED_BYTES = 20 * BYTES_PER_GB;
12598
+ var STOPPED_DELETION_NOTICE_MS = 3 * 864e5;
12599
+ function stoppedMicrosPerHour(storedBytes) {
12600
+ if (storedBytes <= 0) {
12601
+ return 0;
12602
+ }
12603
+ return Math.max(1, Math.round(storedBytes * STOPPED_MICROS_PER_GB_MONTH / (BYTES_PER_GB * HOURS_PER_MONTH)));
12604
+ }
12605
+ function wholeStoredBytes(size2, withMemory) {
12606
+ const resources = MACHINE_SIZES[size2];
12607
+ return resources.diskGb * 2 ** 30 + (withMemory ? resources.memoryMb * 2 ** 20 : 0);
12608
+ }
12609
+ var STOPPED_MAX_MICROS_PER_HOUR = {
12610
+ tiny: stoppedMicrosPerHour(wholeStoredBytes("tiny", false)),
12611
+ small: stoppedMicrosPerHour(wholeStoredBytes("small", false)),
12612
+ medium: stoppedMicrosPerHour(wholeStoredBytes("medium", false)),
12613
+ large: stoppedMicrosPerHour(wholeStoredBytes("large", false))
12614
+ };
12615
+ var STOPPED_WITH_MEMORY_MAX_MICROS_PER_HOUR = {
12616
+ tiny: stoppedMicrosPerHour(wholeStoredBytes("tiny", true)),
12617
+ small: stoppedMicrosPerHour(wholeStoredBytes("small", true)),
12618
+ medium: stoppedMicrosPerHour(wholeStoredBytes("medium", true)),
12619
+ large: stoppedMicrosPerHour(wholeStoredBytes("large", true))
12620
+ };
12621
+ var SANDBOX_STATUSES = ["creating", "running", "stopped", "error", "deleted"];
12622
+ var SHOWN_STATUSES = [...SANDBOX_STATUSES, "restoring", "migrating"];
12623
+ var OUTBOUND_MODES = ["open", "blocked", "allowlist"];
12624
+ function isMachineSize(value) {
12625
+ return Object.hasOwn(MACHINE_SIZES, value);
12626
+ }
12627
+
12628
+ // ../src/cli-snapshots.ts
12629
+ var KEPT_WORDS = {
12630
+ server_and_storage: "server and storage",
12631
+ storage: "storage only",
12632
+ server: "server only",
12633
+ your_server: "your server"
12634
+ };
12635
+ var USAGE7 = "snapshot takes list, show, create, restore or delete. agental snapshot --help shows each.";
12636
+ var STORAGE_ONLY = "storage";
12637
+ var NONE = "\u2014";
12638
+ async function ask9(client, method, pathname, init = {}) {
12639
+ const response = await client.request(pathname, {
12640
+ method,
12641
+ ...init.headers ? { headers: init.headers } : {},
12642
+ ...init.body === void 0 ? {} : { body: JSON.stringify(init.body) }
12643
+ });
12644
+ let answered = null;
12645
+ if (response.status !== 204) {
12646
+ try {
12647
+ answered = await response.json();
12648
+ } catch {
12649
+ answered = null;
12650
+ }
12651
+ }
12652
+ if (!response.ok) {
12653
+ client.fail(response.status, answered);
12654
+ }
12655
+ return answered;
12656
+ }
12657
+ function snapshotOf(body) {
12658
+ if (!body || typeof body !== "object" || typeof body.id !== "string") {
12659
+ throw new Error("The answer was not a snapshot.");
12660
+ }
12661
+ return body;
12662
+ }
12663
+ function snapshotsOf(body) {
12664
+ const listed = body?.snapshots;
12665
+ if (!Array.isArray(listed)) {
12666
+ throw new Error("The answer was missing snapshots.");
12667
+ }
12668
+ return listed.map(snapshotOf);
12669
+ }
12670
+ function keptOf(snapshot2) {
12671
+ if (typeof snapshot2.kept !== "string") {
12672
+ return NONE;
12673
+ }
12674
+ return KEPT_WORDS[snapshot2.kept] ?? snapshot2.kept.replaceAll("_", " ");
12675
+ }
12676
+ function sandboxOf2(snapshot2) {
12677
+ return snapshot2.sandboxName ?? snapshot2.sandboxId;
12678
+ }
12679
+ function takenOf(snapshot2, sandbox) {
12680
+ return snapshot2.sandboxId === sandbox || snapshot2.sandboxName === sandbox;
12681
+ }
12682
+ function utc(iso) {
12683
+ const moment2 = Date.parse(iso);
12684
+ return Number.isFinite(moment2) ? `${new Date(moment2).toISOString().slice(0, 16).replace("T", " ")} UTC` : iso;
12685
+ }
12686
+ function plural(count, noun) {
12687
+ return `${count} ${noun}${count === 1 ? "" : "s"}`;
12688
+ }
12689
+ async function sandboxIdOf(client, word) {
12690
+ const id = await sandboxIdOrNone(client, word);
12691
+ if (id === null) {
12692
+ throw new Error(`There is no sandbox named ${word}. agental list lists them.`);
12693
+ }
12694
+ return id;
12695
+ }
12696
+ async function sandboxIdOrNone(client, word) {
12697
+ if (word.startsWith("sbx_")) {
12698
+ return word;
12699
+ }
12700
+ const body = await ask9(client, "GET", `/v1/sandboxes?${new URLSearchParams({ q: word })}`);
12701
+ const listed = Array.isArray(body?.sandboxes) ? body.sandboxes : [];
12702
+ const named = listed.filter((one) => one.name === word && typeof one.id === "string");
12703
+ if (named.length > 1) {
12704
+ throw new Error(`${named.length} sandboxes are named ${word}. Give the id of the one you mean: ${named.map((one) => String(one.id)).join(", ")}.`);
12705
+ }
12706
+ return named.length === 1 ? named[0].id : null;
12707
+ }
12708
+ async function snapshotNamed(client, word, sandbox, what) {
12709
+ if (word === void 0) {
12710
+ throw new Error(`snapshot ${what} needs the snapshot's id or its name, as agental snapshot list lists them.`);
12711
+ }
12712
+ if (word.startsWith("snap_")) {
12713
+ const found = snapshotOf(await ask9(client, "GET", `/v1/snapshots/${encodeURIComponent(word)}`));
12714
+ if (sandbox !== void 0 && !takenOf(found, sandbox)) {
12715
+ throw new Error(`${word} is a snapshot of ${sandboxOf2(found)}, not of ${sandbox}.`);
12716
+ }
12717
+ return found;
12718
+ }
12719
+ const among = snapshotsOf(await ask9(client, "GET", "/v1/snapshots")).filter((one) => sandbox === void 0 || takenOf(one, sandbox));
12720
+ const named = among.filter((one) => one.name === word);
12721
+ const where = sandbox === void 0 ? "" : ` of ${sandbox}`;
12722
+ if (named.length === 0) {
12723
+ throw new Error(`There is no snapshot named ${word}${where}. agental snapshot list${sandbox === void 0 ? "" : ` --sandbox ${sandbox}`} lists them.`);
12724
+ }
12725
+ if (named.length > 1) {
12726
+ const each = named.map((one) => `${one.id} (of ${sandboxOf2(one)}, taken ${ago(one.createdAt) ?? utc(one.createdAt)})`);
12727
+ throw new Error(`${named.length} snapshots${where} are named ${word}. Give the id of the one you mean: ${each.join(", ")}.`);
12728
+ }
12729
+ return snapshotOf(await ask9(client, "GET", `/v1/snapshots/${encodeURIComponent(named[0].id)}`));
12730
+ }
12731
+ function describe4(snapshot2) {
12732
+ const status = snapshot2.sandboxStatus ?? (snapshot2.sandboxDeleted ? "deleted" : void 0);
12733
+ const disk = snapshot2.size !== null && isMachineSize(snapshot2.size) ? `, ${MACHINE_SIZES[snapshot2.size].diskGb} GB disk` : "";
12734
+ const copied = typeof snapshot2.copiedAt === "string" ? `, copied ${ago(snapshot2.copiedAt) ?? utc(snapshot2.copiedAt)}` : "";
12735
+ const facts = [
12736
+ ["Sandbox", `${sandboxOf2(snapshot2)}${status ? ` (${status})` : ""}`],
12737
+ ["Size", snapshot2.size === null ? NONE : `${snapshot2.size}${disk}`],
12738
+ ["Taken", `${utc(snapshot2.createdAt)}${ago(snapshot2.createdAt) ? `, ${ago(snapshot2.createdAt)}` : ""}`],
12739
+ ["Kept", `${keptOf(snapshot2)}${copied}`],
12740
+ ["State", snapshot2.state]
12741
+ ];
12742
+ const out = [`${strong(snapshot2.name)} ${faint(snapshot2.id)}`, "", ...fitted(facts, { paint: (cell, _row, column) => column === 0 ? faint(cell) : cell }).trimEnd().split("\n")];
12743
+ if (snapshot2.kept === STORAGE_ONLY) {
12744
+ out.push("", "Its server no longer holds it. Rolling back to it, or starting a sandbox from it, fetches it first: a few minutes.");
12745
+ }
12746
+ if (snapshot2.state !== "ready") {
12747
+ return `${out.join("\n")}
12748
+ `;
12749
+ }
12750
+ const next = [
12751
+ ...snapshot2.sandboxDeleted ? [] : [["Roll back", `agental snapshot restore ${snapshot2.id}`]],
12752
+ ["Start from", `agental sandbox create --snapshot ${snapshot2.id}`],
12753
+ ["Delete", `agental snapshot delete ${snapshot2.id}`]
12754
+ ];
12755
+ out.push("", ...fitted(next, { paint: (cell, _row, column) => column === 0 ? faint(cell) : cell }).trimEnd().split("\n"));
12756
+ return `${out.join("\n")}
12757
+ `;
12758
+ }
12759
+ async function snapshotsOfSandbox(client, word) {
12760
+ const id = await sandboxIdOrNone(client, word);
12761
+ if (id !== null) {
12762
+ const response = await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/snapshots`, { method: "GET" });
12763
+ if (response.status !== 404) {
12764
+ let answered = null;
12765
+ try {
12766
+ answered = await response.json();
12767
+ } catch {
12768
+ answered = null;
12769
+ }
12770
+ if (!response.ok) {
12771
+ client.fail(response.status, answered);
12772
+ }
12773
+ return answered;
12774
+ }
12775
+ }
12776
+ const kept2 = snapshotsOf(await ask9(client, "GET", "/v1/snapshots")).filter((one) => takenOf(one, word));
12777
+ if (kept2.length === 0 && id === null) {
12778
+ throw new Error(`There is no sandbox named ${word}. agental list lists them.`);
12779
+ }
12780
+ return { snapshots: kept2 };
12781
+ }
12782
+ async function listSnapshots(client, options) {
12783
+ const body = options.sandbox === void 0 ? await ask9(client, "GET", "/v1/snapshots") : await snapshotsOfSandbox(client, options.sandbox);
12784
+ if (options.json) {
12785
+ process.stdout.write(`${JSON.stringify(body, null, 2)}
12786
+ `);
12787
+ return;
12788
+ }
12789
+ const snapshots2 = snapshotsOf(body);
12790
+ if (snapshots2.length === 0) {
12791
+ process.stdout.write(`${options.sandbox === void 0 ? "No snapshots." : `${options.sandbox} has no snapshots.`} agental snapshot create <sandbox> <name> takes one.
12792
+ `);
12793
+ return;
12794
+ }
12795
+ const all = options.sandbox === void 0;
12796
+ const rows = [
12797
+ ["NAME", "ID", ...all ? ["SANDBOX"] : [], "SIZE", "TAKEN", "KEPT"],
12798
+ ...snapshots2.map((one) => [
12799
+ one.name,
12800
+ one.id,
12801
+ ...all ? [`${sandboxOf2(one)}${one.sandboxDeleted ? " (deleted)" : ""}`] : [],
12802
+ one.size ?? NONE,
12803
+ ago(one.createdAt) ?? utc(one.createdAt),
12804
+ keptOf(one)
12805
+ ])
12806
+ ];
12807
+ process.stdout.write(fitted(rows, { give: 0, paint: (cell, row) => row === 0 ? faint(cell) : cell }));
12808
+ if (snapshots2.some((one) => one.kept === STORAGE_ONLY)) {
12809
+ process.stdout.write(`
12810
+ ${plural(snapshots2.length, "snapshot")}. A storage-only one takes a few minutes to roll back to or start from.
12811
+ `);
12812
+ }
12813
+ }
12814
+ async function snapshot(client, positionals, options) {
12815
+ const [what, first, second, ...rest] = positionals;
12816
+ if (rest.length > 0 || second !== void 0 && what !== "create") {
12817
+ throw new Error(what === "create" ? "snapshot create takes the sandbox and one name: put a name with spaces in quotes." : USAGE7);
12818
+ }
12819
+ switch (what) {
12820
+ case "list": {
12821
+ if (first !== void 0) {
12822
+ throw new Error(`snapshot list takes the sandbox as --sandbox: agental snapshot list --sandbox ${first}`);
12823
+ }
12824
+ await listSnapshots(client, options);
12825
+ return;
12826
+ }
12827
+ case "show": {
12828
+ const found = await snapshotNamed(client, first, options.sandbox, "show");
12829
+ process.stdout.write(options.json ? `${JSON.stringify(found, null, 2)}
12830
+ ` : describe4(found));
12831
+ return;
12832
+ }
12833
+ case "create": {
12834
+ if (first === void 0 || second === void 0) {
12835
+ throw new Error("snapshot create needs the sandbox and a name for the snapshot, as agental snapshot create review-41 before-migration");
12836
+ }
12837
+ if (options.sandbox !== void 0) {
12838
+ throw new Error("snapshot create takes the sandbox as its first word, not --sandbox.");
12839
+ }
12840
+ const made = await ask9(client, "POST", `/v1/sandboxes/${encodeURIComponent(await sandboxIdOf(client, first))}/snapshots`, { body: { name: second } });
12841
+ process.stdout.write(options.json ? `${JSON.stringify(made, null, 2)}
12842
+ ` : describe4(snapshotOf(made)));
12843
+ return;
12844
+ }
12845
+ case "restore": {
12846
+ const found = await snapshotNamed(client, first, options.sandbox, "restore");
12847
+ const sandbox = sandboxOf2(found);
12848
+ if (found.sandboxDeleted) {
12849
+ throw new Error(`${sandbox} is deleted: there is nothing to roll back. agental sandbox create --snapshot ${found.id} starts a new sandbox from it.`);
12850
+ }
12851
+ const question = `Roll ${sandbox} back to ${found.name}, taken ${ago(found.createdAt) ?? utc(found.createdAt)}? What runs in it ends, its snapshots taken after this one are deleted, and its address and SSH port may change. It cannot be undone.`;
12852
+ if (!options.yes && !await client.confirmed(question)) {
12853
+ process.stderr.write("Nothing was rolled back. --yes goes on without asking.\n");
12854
+ process.exitCode = 1;
12855
+ return;
12856
+ }
12857
+ if (found.kept === STORAGE_ONLY) {
12858
+ process.stderr.write("Its server no longer holds it: it is fetched from storage first, which takes a few minutes.\n");
12859
+ }
12860
+ const answer3 = await ask9(client, "POST", `/v1/sandboxes/${encodeURIComponent(found.sandboxId)}/restore`, {
12861
+ headers: { "Idempotency-Key": options.idempotencyKey ?? `cli-${randomUUID2()}` },
12862
+ body: { snapshotId: found.id }
12863
+ });
12864
+ if (options.json) {
12865
+ process.stdout.write(`${JSON.stringify(answer3, null, 2)}
12866
+ `);
12867
+ return;
12868
+ }
12869
+ const read2 = answer3;
12870
+ const discarded = Array.isArray(read2?.discarded) ? read2.discarded.map(String) : [];
12871
+ const status = typeof read2?.sandbox?.status === "string" ? `, and ${read2.sandbox.status}` : "";
12872
+ process.stdout.write(`${sandbox} is as it was at ${found.name}${status}.
12873
+ `);
12874
+ if (discarded.length > 0) {
12875
+ process.stdout.write(`${plural(discarded.length, "later snapshot")} deleted: ${discarded.join(", ")}.
12876
+ `);
12877
+ }
12878
+ return;
12879
+ }
12880
+ case "delete": {
12881
+ const found = await snapshotNamed(client, first, options.sandbox, "delete");
12882
+ const question = `Delete ${found.name} (${found.id}), of ${sandboxOf2(found)}, taken ${ago(found.createdAt) ?? utc(found.createdAt)}? It cannot be undone.`;
12883
+ if (!options.yes && !await client.confirmed(question)) {
12884
+ process.stderr.write("Nothing was deleted. --yes goes on without asking.\n");
12885
+ process.exitCode = 1;
12886
+ return;
12887
+ }
12888
+ await ask9(client, "DELETE", `/v1/snapshots/${encodeURIComponent(found.id)}`);
12889
+ process.stdout.write(`Deleted ${found.name} (${found.id}). Sandboxes made from it are not affected.
12890
+ `);
12891
+ return;
12892
+ }
12893
+ default:
12894
+ throw new Error(USAGE7);
12895
+ }
12896
+ }
12897
+
12542
12898
  // ../src/cli-sites.ts
12543
- var USAGE7 = "site takes a sandbox, or list, add, rm, stats or analytics, then the sandbox. agental site --help shows each.";
12899
+ var USAGE8 = "site takes a sandbox, or list, add, rm, stats or analytics, then the sandbox. agental site --help shows each.";
12544
12900
  var ANALYTICS_USAGE = "site analytics takes on or off, then the sandbox and the site's id, or org, with on or off to change it.";
12545
12901
  var REPORT_ROWS = 5;
12546
12902
  async function bodyOf2(response) {
@@ -12550,7 +12906,7 @@ async function bodyOf2(response) {
12550
12906
  return null;
12551
12907
  }
12552
12908
  }
12553
- async function ask9(client, method, pathname, body) {
12909
+ async function ask10(client, method, pathname, body) {
12554
12910
  const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
12555
12911
  const answered = await bodyOf2(response);
12556
12912
  if (!response.ok) {
@@ -12566,7 +12922,7 @@ function routeOf(body) {
12566
12922
  }
12567
12923
  var isSite = (route) => route.public && !route.hidden;
12568
12924
  async function sitesOf(client, sandbox) {
12569
- const body = await ask9(client, "GET", `/v1/sandboxes/${encodeURIComponent(sandbox)}/host`);
12925
+ const body = await ask10(client, "GET", `/v1/sandboxes/${encodeURIComponent(sandbox)}/host`);
12570
12926
  return (Array.isArray(body?.routes) ? body.routes : []).map(routeOf).filter(isSite);
12571
12927
  }
12572
12928
  function stateOf3(route) {
@@ -12651,7 +13007,7 @@ async function siteSwitch(client, turn, words2, options) {
12651
13007
  process.exitCode = 1;
12652
13008
  return;
12653
13009
  }
12654
- const report = await ask9(client, "PUT", `/v1/host-routes/${encodeURIComponent(target)}/analytics`, { enabled: turn === "on" });
13010
+ const report = await ask10(client, "PUT", `/v1/host-routes/${encodeURIComponent(target)}/analytics`, { enabled: turn === "on" });
12655
13011
  if (options.json) {
12656
13012
  process.stdout.write(`${reportJson(report)}
12657
13013
  `);
@@ -12677,7 +13033,7 @@ async function organizationSwitch(client, words2, options) {
12677
13033
  }
12678
13034
  let setting;
12679
13035
  if (turn === void 0) {
12680
- setting = await ask9(client, "GET", "/v1/site-analytics");
13036
+ setting = await ask10(client, "GET", "/v1/site-analytics");
12681
13037
  } else {
12682
13038
  if (turn === "off" && !options.yes && !await client.confirmed("Turn site analytics off for this organization? Every site's figures are deleted now and cannot be brought back.")) {
12683
13039
  process.stderr.write("Nothing was changed. --yes goes on without asking.\n");
@@ -12729,13 +13085,13 @@ async function site(client, positionals, options) {
12729
13085
  const verb = positionals[0] === "list" || positionals[0] === "add" || positionals[0] === "rm" || positionals[0] === "stats" ? positionals[0] : null;
12730
13086
  const [sandbox, target, ...rest] = verb === null ? positionals : positionals.slice(1);
12731
13087
  if (sandbox === void 0) {
12732
- throw new Error(USAGE7);
13088
+ throw new Error(USAGE8);
12733
13089
  }
12734
13090
  switch (verb) {
12735
13091
  case null:
12736
13092
  case "list": {
12737
13093
  if (target !== void 0) {
12738
- throw new Error(USAGE7);
13094
+ throw new Error(USAGE8);
12739
13095
  }
12740
13096
  const sites = await sitesOf(client, sandbox);
12741
13097
  if (options.json) {
@@ -12755,10 +13111,10 @@ async function site(client, positionals, options) {
12755
13111
  }
12756
13112
  case "add": {
12757
13113
  if (rest.length > 0) {
12758
- throw new Error(USAGE7);
13114
+ throw new Error(USAGE8);
12759
13115
  }
12760
13116
  const port = portFrom(target);
12761
- const made = routeOf(await ask9(client, "POST", `/v1/sandboxes/${encodeURIComponent(sandbox)}/host`, { port, title: `port-${port}`, public: true }));
13117
+ const made = routeOf(await ask10(client, "POST", `/v1/sandboxes/${encodeURIComponent(sandbox)}/host`, { port, title: `port-${port}`, public: true }));
12762
13118
  if (options.json) {
12763
13119
  process.stdout.write(`${JSON.stringify(made, null, 2)}
12764
13120
  `);
@@ -12783,7 +13139,7 @@ async function site(client, positionals, options) {
12783
13139
  throw new Error(`site rm needs the sandbox and the site's id, as agental site ${sandbox} lists them.`);
12784
13140
  }
12785
13141
  const found = await siteOn(client, sandbox, target);
12786
- await ask9(client, "POST", `/v1/host-routes/${encodeURIComponent(target)}/hide`);
13142
+ await ask10(client, "POST", `/v1/host-routes/${encodeURIComponent(target)}/hide`);
12787
13143
  process.stdout.write(`Removed. ${found.url ?? `Port ${found.port}`} stops working now; adding port ${found.port} again gives a new link.
12788
13144
  `);
12789
13145
  return;
@@ -12797,7 +13153,7 @@ async function site(client, positionals, options) {
12797
13153
  throw new Error(`--range is 24h or 7d. It was given ${range}.`);
12798
13154
  }
12799
13155
  await siteOn(client, sandbox, target);
12800
- const report = await ask9(client, "GET", `/v1/host-routes/${encodeURIComponent(target)}/analytics?range=${range}`);
13156
+ const report = await ask10(client, "GET", `/v1/host-routes/${encodeURIComponent(target)}/analytics?range=${range}`);
12801
13157
  process.stdout.write(options.json ? `${reportJson(report)}
12802
13158
  ` : reportIn(report, sandbox, target));
12803
13159
  return;
@@ -12806,10 +13162,10 @@ async function site(client, positionals, options) {
12806
13162
  }
12807
13163
 
12808
13164
  // ../src/cli-claude.ts
12809
- var USAGE8 = "claude takes connect, show, update or disconnect. agental claude --help shows each.";
13165
+ var USAGE9 = "claude takes connect, show, update or disconnect. agental claude --help shows each.";
12810
13166
  var KEY_VARIABLE = "ANTHROPIC_ENVIRONMENT_KEY";
12811
13167
  var SECRET_VARIABLE = "ANTHROPIC_WEBHOOK_SIGNING_KEY";
12812
- async function ask10(client, method, pathname, body) {
13168
+ async function ask11(client, method, pathname, body) {
12813
13169
  const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
12814
13170
  let answered = null;
12815
13171
  if (response.status !== 204) {
@@ -12831,7 +13187,7 @@ function connectionOf(body) {
12831
13187
  }
12832
13188
  return connection;
12833
13189
  }
12834
- function describe4(connection) {
13190
+ function describe5(connection) {
12835
13191
  return [
12836
13192
  `id: ${connection.id}`,
12837
13193
  `environment: ${connection.environmentId}`,
@@ -12899,7 +13255,7 @@ async function hidden(question) {
12899
13255
  });
12900
13256
  }
12901
13257
  async function listClaude(client, asJson) {
12902
- const body = await ask10(client, "GET", "/v1/claude/connections");
13258
+ const body = await ask11(client, "GET", "/v1/claude/connections");
12903
13259
  if (asJson) {
12904
13260
  process.stdout.write(`${JSON.stringify(body, null, 2)}
12905
13261
  `);
@@ -12921,7 +13277,7 @@ async function listClaude(client, asJson) {
12921
13277
  async function claude(client, positionals, options) {
12922
13278
  const [what, target, ...rest] = positionals;
12923
13279
  if (rest.length > 0) {
12924
- throw new Error(USAGE8);
13280
+ throw new Error(USAGE9);
12925
13281
  }
12926
13282
  switch (what) {
12927
13283
  case "connect": {
@@ -12933,7 +13289,7 @@ async function claude(client, positionals, options) {
12933
13289
  const environmentKey = await secretFrom(KEY_VARIABLE, "environment key", true);
12934
13290
  const webhookSecret = await secretFrom(SECRET_VARIABLE, "webhook signing secret", false);
12935
13291
  const made = connectionOf(
12936
- await ask10(client, "POST", "/v1/claude/connections", {
13292
+ await ask11(client, "POST", "/v1/claude/connections", {
12937
13293
  environmentId: target,
12938
13294
  environmentKey,
12939
13295
  ...webhookSecret !== void 0 ? { webhookSecret } : {},
@@ -12946,7 +13302,7 @@ async function claude(client, positionals, options) {
12946
13302
  `);
12947
13303
  return;
12948
13304
  }
12949
- process.stdout.write(describe4(made));
13305
+ process.stdout.write(describe5(made));
12950
13306
  process.stderr.write(
12951
13307
  made.hasWebhookSecret ? `In the Claude Console, set ${made.webhookUrl} as a webhook for session.status_run_started.
12952
13308
  ` : `For a turn to start at once, add ${made.webhookUrl} as a webhook for session.status_run_started in the Claude Console, then: ${SECRET_VARIABLE}=whsec_... agental claude update ${made.id} --webhook-secret
@@ -12955,9 +13311,9 @@ async function claude(client, positionals, options) {
12955
13311
  return;
12956
13312
  }
12957
13313
  case "show": {
12958
- const found = connectionOf(await ask10(client, "GET", `/v1/claude/connections/${encodeURIComponent(needId2(target, "show"))}`));
13314
+ const found = connectionOf(await ask11(client, "GET", `/v1/claude/connections/${encodeURIComponent(needId2(target, "show"))}`));
12959
13315
  process.stdout.write(options.json ? `${JSON.stringify(found, null, 2)}
12960
- ` : describe4(found));
13316
+ ` : describe5(found));
12961
13317
  return;
12962
13318
  }
12963
13319
  case "update": {
@@ -12978,18 +13334,18 @@ async function claude(client, positionals, options) {
12978
13334
  if (Object.keys(patch).length === 0) {
12979
13335
  throw new Error("claude update changes --template, --keep-days, --new-key, --webhook-secret or --no-webhook-secret, and was given none of them.");
12980
13336
  }
12981
- const updated = connectionOf(await ask10(client, "PATCH", `/v1/claude/connections/${encodeURIComponent(id)}`, patch));
13337
+ const updated = connectionOf(await ask11(client, "PATCH", `/v1/claude/connections/${encodeURIComponent(id)}`, patch));
12982
13338
  process.stdout.write(options.json ? `${JSON.stringify(updated, null, 2)}
12983
- ` : describe4(updated));
13339
+ ` : describe5(updated));
12984
13340
  return;
12985
13341
  }
12986
13342
  case "disconnect": {
12987
- await ask10(client, "DELETE", `/v1/claude/connections/${encodeURIComponent(needId2(target, "disconnect"))}`);
13343
+ await ask11(client, "DELETE", `/v1/claude/connections/${encodeURIComponent(needId2(target, "disconnect"))}`);
12988
13344
  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");
12989
13345
  return;
12990
13346
  }
12991
13347
  default:
12992
- throw new Error(USAGE8);
13348
+ throw new Error(USAGE9);
12993
13349
  }
12994
13350
  }
12995
13351
  function needId2(id, what) {
@@ -13146,16 +13502,16 @@ async function shell(client, id, options = {}, streams = process) {
13146
13502
  const verifier = randomBytes4(32).toString("base64url");
13147
13503
  const challenge = createHash3("sha256").update(verifier).digest("base64url");
13148
13504
  const interactive = stdin.isTTY === true && typeof stdin.setRawMode === "function";
13149
- const ask11 = async (keep) => await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminal`, {
13505
+ const ask12 = async (keep) => await client.request(`/v1/sandboxes/${encodeURIComponent(id)}/terminal`, {
13150
13506
  method: "POST",
13151
13507
  body: JSON.stringify({ ...size2, challenge, ...again ? { terminal: again.id } : keep ? { keep: true } : {} })
13152
13508
  });
13153
- let response = await ask11(interactive);
13509
+ let response = await ask12(interactive);
13154
13510
  let body = await response.json().catch(() => null);
13155
13511
  if (!again && interactive && response.status === 409 && body?.error?.code === "terminal_unavailable" && /keeps \d+ terminals/.test(String(body.error.message ?? ""))) {
13156
13512
  stderr.write(`${String(body.error.message)} This one is not kept.
13157
13513
  `);
13158
- response = await ask11(false);
13514
+ response = await ask12(false);
13159
13515
  body = await response.json().catch(() => null);
13160
13516
  }
13161
13517
  if (!response.ok || typeof body?.ticket !== "string") {
@@ -13326,63 +13682,6 @@ ${whyClosed(event.code, event.reason, error)}${maybe}
13326
13682
  // left-out:cli-dev-key
13327
13683
  var DEV_KEY = null;
13328
13684
 
13329
- // ../src/domain.ts
13330
- var MACHINE_SIZES = {
13331
- tiny: { vcpu: 1, memoryMb: 2048, diskGb: 20 },
13332
- small: { vcpu: 2, memoryMb: 4096, diskGb: 40 },
13333
- medium: { vcpu: 4, memoryMb: 8192, diskGb: 80 },
13334
- large: { vcpu: 8, memoryMb: 16384, diskGb: 160 }
13335
- };
13336
- var MACHINE_SIZE_NAMES = ["tiny", "small", "medium", "large"];
13337
- var LIST_PRICE_MICROS_PER_HOUR = {
13338
- tiny: 13500,
13339
- small: 27e3,
13340
- medium: 54e3,
13341
- large: 108e3
13342
- };
13343
- var SPOT_PRICE_MICROS_PER_HOUR = {
13344
- tiny: LIST_PRICE_MICROS_PER_HOUR.tiny / 2,
13345
- small: LIST_PRICE_MICROS_PER_HOUR.small / 2,
13346
- medium: LIST_PRICE_MICROS_PER_HOUR.medium / 2,
13347
- large: LIST_PRICE_MICROS_PER_HOUR.large / 2
13348
- };
13349
- var SPOT_ON_RECLAIM = ["delete", "stop"];
13350
- var SPOT_ON_RECLAIM_READ = [...SPOT_ON_RECLAIM, "upgrade"];
13351
- var SPOT_RUN_LIMIT_SECONDS = 24 * 60 * 60;
13352
- var HOURS_PER_MONTH = 730;
13353
- var STOPPED_MICROS_PER_GB_MONTH = 5e4;
13354
- var BYTES_PER_GB = 1e9;
13355
- var NEVER_PAID_MAX_STORED_BYTES = 20 * BYTES_PER_GB;
13356
- var STOPPED_DELETION_NOTICE_MS = 3 * 864e5;
13357
- function stoppedMicrosPerHour(storedBytes) {
13358
- if (storedBytes <= 0) {
13359
- return 0;
13360
- }
13361
- return Math.max(1, Math.round(storedBytes * STOPPED_MICROS_PER_GB_MONTH / (BYTES_PER_GB * HOURS_PER_MONTH)));
13362
- }
13363
- function wholeStoredBytes(size2, withMemory) {
13364
- const resources = MACHINE_SIZES[size2];
13365
- return resources.diskGb * 2 ** 30 + (withMemory ? resources.memoryMb * 2 ** 20 : 0);
13366
- }
13367
- var STOPPED_MAX_MICROS_PER_HOUR = {
13368
- tiny: stoppedMicrosPerHour(wholeStoredBytes("tiny", false)),
13369
- small: stoppedMicrosPerHour(wholeStoredBytes("small", false)),
13370
- medium: stoppedMicrosPerHour(wholeStoredBytes("medium", false)),
13371
- large: stoppedMicrosPerHour(wholeStoredBytes("large", false))
13372
- };
13373
- var STOPPED_WITH_MEMORY_MAX_MICROS_PER_HOUR = {
13374
- tiny: stoppedMicrosPerHour(wholeStoredBytes("tiny", true)),
13375
- small: stoppedMicrosPerHour(wholeStoredBytes("small", true)),
13376
- medium: stoppedMicrosPerHour(wholeStoredBytes("medium", true)),
13377
- large: stoppedMicrosPerHour(wholeStoredBytes("large", true))
13378
- };
13379
- var SANDBOX_STATUSES = ["creating", "running", "stopped", "error", "deleted"];
13380
- var SHOWN_STATUSES = [...SANDBOX_STATUSES, "restoring", "migrating"];
13381
- var OUTBOUND_MODES = ["open", "blocked", "allowlist"];
13382
- function isMachineSize(value) {
13383
- return Object.hasOwn(MACHINE_SIZES, value);
13384
- }
13385
-
13386
13685
  // ../src/desktop-tree-text.ts
13387
13686
  function treeText(tree) {
13388
13687
  if (tree.windows.length === 0) {
@@ -14033,6 +14332,9 @@ async function main() {
14033
14332
  case "webhooks":
14034
14333
  await listWebhooks({ request, fail }, values.json);
14035
14334
  return;
14335
+ case "snapshot":
14336
+ await snapshot({ request, fail, confirmed }, positionals.slice(1), { json: values.json, sandbox: once(values.sandbox, "--sandbox"), yes: values.yes === true, ...values["idempotency-key"] === void 0 ? {} : { idempotencyKey: values["idempotency-key"] } });
14337
+ return;
14036
14338
  case "webhook":
14037
14339
  await webhook({ request, fail }, positionals.slice(1), values);
14038
14340
  return;
@@ -14123,7 +14425,7 @@ async function create(values) {
14123
14425
  const sshKeys2 = values["ssh-key"] === void 0 ? void 0 : publicKeysFrom(values["ssh-key"]);
14124
14426
  const box = boxNamed(values.box);
14125
14427
  const templateId = values.template === void 0 ? void 0 : (await templateNamed(values.template)).id;
14126
- const idempotencyKey = values["idempotency-key"] ?? `cli-${randomUUID2()}`;
14428
+ const idempotencyKey = values["idempotency-key"] ?? `cli-${randomUUID3()}`;
14127
14429
  const response = await request("/v1/sandboxes", {
14128
14430
  method: "POST",
14129
14431
  headers: { "Idempotency-Key": idempotencyKey, ...box ? { "X-Agental-Box": box } : {}, ...burstHeaders },
@@ -14131,6 +14433,7 @@ async function create(values) {
14131
14433
  ...values.name ? { name: values.name } : {},
14132
14434
  ...values.size ? { size: values.size } : {},
14133
14435
  ...templateId ? { templateId } : {},
14436
+ ...values.snapshot ? { snapshotId: values.snapshot } : {},
14134
14437
  ...regionsOption(values.region),
14135
14438
  ...allow ? { network: { allow } } : {},
14136
14439
  ...egressAsked ? { egress: egressAsked } : {},
@@ -16775,7 +17078,7 @@ Setting up
16775
17078
  agental completion zsh|bash|fish
16776
17079
 
16777
17080
  Usage
16778
- agental create [--name <name>] [--template <template>] [--size tiny|small|medium|large] [--region <region>[,<region>...]] [--ttl <time> | --ttl default] [--on-timeout delete|stop|stop-with-memory] [--idempotency-key <key>]
17081
+ agental create [--name <name>] [--template <template>] [--snapshot <snapshot-id>] [--size tiny|small|medium|large] [--region <region>[,<region>...]] [--ttl <time> | --ttl default] [--on-timeout delete|stop|stop-with-memory] [--idempotency-key <key>]
16779
17082
  [--spot [--on-reclaim delete|stop] [--warn-at <chance>]]
16780
17083
  ${operator ? "[--box <name-or-id>] " : ""}[--allow <address>[,<address>...]] [--egress box | residential:<country>[:sticky|rotating]] [--max-burst-fee <dollars>]
16781
17084
  [--ssh-key <public-key-or-file>]... [--tag <tag>[,<tag>...]]... [--meta <key>=<value>]...
@@ -16867,6 +17170,11 @@ Usage
16867
17170
  agental job trigger rotate <job> <trigger-id> [--json] a new secret; the old one stops at once
16868
17171
  agental job trigger delete <job> <trigger-id>
16869
17172
  agental job calls <job> [--json] calls of its addresses refused in the last 7 days, with why
17173
+ agental snapshot list [--sandbox <sandbox-id>] [--json]
17174
+ agental snapshot show <snapshot> [--sandbox <sandbox-id>] [--json]
17175
+ agental snapshot create <sandbox-id> <name> [--json]
17176
+ agental snapshot restore <snapshot> [--sandbox <sandbox-id>] [--yes] [--idempotency-key <key>] [--json] roll its sandbox back to it
17177
+ agental snapshot delete <snapshot> [--sandbox <sandbox-id>] [--yes]
16870
17178
  agental webhooks [--json]
16871
17179
  agental webhook add <url> (--events <kind>[,<kind>...] | --all) [--description <text>] [--json]
16872
17180
  agental webhook show <webhook-id> [--json]
@@ -16991,6 +17299,18 @@ lets out only them, and an allowlist lets out its addresses and them. That holds
16991
17299
  sandbox is not restarted, and what is sent to it, commands, files and SSH, is not affected.
16992
17300
  create --allow gives a new sandbox its own from its first boot. These work where GET
16993
17301
  /v1/policy says networkPolicy.
17302
+ snapshot create takes a snapshot of a sandbox's disk as it is now, running or stopped, and leaves
17303
+ the sandbox as it was; it is kept until it is deleted, after its sandbox too. snapshot list lists
17304
+ yours, or one sandbox's with --sandbox, with where each is kept: on its server, in storage or both.
17305
+ One kept in storage only is fetched first, which takes a few minutes, to roll back to or start
17306
+ from. snapshot show says one in words, with what to type next. A snapshot is named by its id, or
17307
+ by its name among yours, or among one sandbox's with --sandbox; a name two of them have is
17308
+ refused, naming each. A sandbox is named by its id or its name. snapshot restore rolls its
17309
+ sandbox back to it: what runs in it ends, as on a stop and a start, and its snapshots taken after
17310
+ that one are deleted; its address and SSH port may change. Run again with the same
17311
+ --idempotency-key after a lost answer, it rolls back once. create --snapshot <snapshot-id> makes
17312
+ a new sandbox from one. restore and delete cannot be undone, and ask first in a terminal: --yes
17313
+ goes on without asking, and without a terminal nothing is done unless it is given.
16994
17314
  A template is what a sandbox is made as and held to: its start (a size, and a snapshot or a new
16995
17315
  machine), its variables and files, and its outbound rule. Every account has one named default,
16996
17316
  which a sandbox is on when create names none. <template> is a template's id or its name. A
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agental",
3
- "version": "0.42.0",
3
+ "version": "0.43.1",
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",