agental 0.67.1 → 0.71.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 +292 -73
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -7424,7 +7424,7 @@ function requestHeaders(given) {
7424
7424
 
7425
7425
  // ../src/cli-build.ts
7426
7426
  var PUBLISHED = true;
7427
- var CLI_VERSION = true ? "0.67.1" : "dev";
7427
+ var CLI_VERSION = true ? "0.71.0" : "dev";
7428
7428
  var DEFAULT_API_URL = true ? "https://agental.io" : "http://127.0.0.1:8741";
7429
7429
  var PACKAGE_NAME = "agental";
7430
7430
  var USER_AGENT = `agental-cli/${CLI_VERSION}`;
@@ -9543,19 +9543,22 @@ var COMMANDS = [
9543
9543
  { name: "ssh-off", summary: "Turn SSH off for a sandbox and close its port." },
9544
9544
  {
9545
9545
  name: "site",
9546
- summary: "List, add and remove a sandbox's sites, public links to its ports, and see their visits.",
9546
+ summary: "List, add and remove a sandbox's sites, links to its ports, choose who may open each, and see their visits.",
9547
9547
  examples: [
9548
9548
  "agental site sbx_2a9a47e50daec64a",
9549
9549
  "agental site add sbx_2a9a47e50daec64a 3000",
9550
+ "agental site add sbx_2a9a47e50daec64a 5173 --private",
9551
+ "agental site access sbx_2a9a47e50daec64a rte_0123456789abcdef organization",
9550
9552
  "agental site rm sbx_2a9a47e50daec64a rte_0123456789abcdef",
9551
9553
  "agental site stats sbx_2a9a47e50daec64a rte_0123456789abcdef --range 24h",
9552
9554
  "agental site analytics off sbx_2a9a47e50daec64a rte_0123456789abcdef",
9553
9555
  "agental site analytics org"
9554
9556
  ],
9555
9557
  flags: [
9556
- ["--json", "list, add, stats, analytics: print as JSON"],
9558
+ ["--json", "list, add, access, stats, analytics: print as JSON"],
9559
+ ["--private", "add: only your organization's people, signed in, and keys with site.open may open it"],
9557
9560
  ["--range <24h|7d>", "stats: the last 24 hours, or 7 days, the default"],
9558
- ["--yes", "analytics off: delete the figures without asking"],
9561
+ ["--yes", "analytics off: delete the figures without asking; access anyone: open a private site without asking"],
9559
9562
  ["--informed", "analytics org on: you have read what is kept, on Enterprise or with your own server"]
9560
9563
  ]
9561
9564
  },
@@ -9573,13 +9576,31 @@ var COMMANDS = [
9573
9576
  {
9574
9577
  name: "stop",
9575
9578
  summary: "Stop a sandbox, or every one --where finds. Its disk is kept.",
9576
- examples: ["agental stop sbx_2a9a47e50daec64a", "agental stop sbx_2a9a47e50daec64a --keep-memory", "agental stop --where 'bench'"],
9579
+ examples: ["agental stop sbx_2a9a47e50daec64a", "agental stop --where 'bench'"],
9577
9580
  flags: [
9578
- ["--keep-memory", "keep what runs in memory too, so it carries on from where it was"],
9579
9581
  ["--where '<words>'", "every sandbox the words find, as one bulk action"],
9580
9582
  ["--yes", "with --where: stop them without asking"]
9581
9583
  ]
9582
9584
  },
9585
+ {
9586
+ name: "pause",
9587
+ summary: "Pause a sandbox, or every one --where finds: stop it with its memory kept, so resume carries on where it was. A spot sandbox never keeps its memory: with --where it is stopped with its disk only.",
9588
+ examples: ["agental pause sbx_2a9a47e50daec64a", "agental pause --where 'bench'"],
9589
+ flags: [
9590
+ ["--where '<words>'", "every sandbox the words find, as one bulk action"],
9591
+ ["--yes", "with --where: pause them without asking"]
9592
+ ]
9593
+ },
9594
+ {
9595
+ name: "resume",
9596
+ summary: "Resume a paused sandbox, or every paused one --where finds: every process carries on where it was.",
9597
+ examples: ["agental resume sbx_2a9a47e50daec64a", "agental resume --where 'bench'"],
9598
+ flags: [
9599
+ ["--where '<words>'", "every paused sandbox the words find, as one bulk action"],
9600
+ ["--yes", "with --where: resume them without asking"],
9601
+ ["--max-burst-fee <dollars>", "the most this resume of one sandbox may pay in burst fees"]
9602
+ ]
9603
+ },
9583
9604
  {
9584
9605
  name: "delete",
9585
9606
  summary: "Delete a sandbox, or every one --where finds. It cannot be undone.",
@@ -9630,7 +9651,8 @@ var COMMANDS = [
9630
9651
  summary: "Set up a guild, where agents work together under identities of its design, or join one as an agent.",
9631
9652
  usage: [
9632
9653
  "agental guild [list] | show <guild> | delete <guild> [--yes]",
9633
- "agental guild create <guild> --roles <name[:seats],...> [--brief <text>] [--form <file.json>]",
9654
+ "agental guild plan <guild> --roles <name[:seats],...> [--brief <text>] [--form <file.json>] [--template <template[:role,...]>]...",
9655
+ "agental guild create <guild> --roles <name[:seats],...> [--brief <text>] [--form <file.json>] [--template <template[:role,...]>]...",
9634
9656
  "agental guild attach <guild> <template|sandbox> [--roles <role,...>] | detach <guild> <template|sandbox>",
9635
9657
  "agental guild mine",
9636
9658
  "agental guild join <guild> --as <name> --role <role> [--answer <key=value>]...",
@@ -9643,6 +9665,7 @@ var COMMANDS = [
9643
9665
  "agental guild work <guild> --as <name> [--role <role>] [--parallel <n>] [--answer-chars <n>] [--once] -- <command> [args...]"
9644
9666
  ],
9645
9667
  examples: [
9668
+ 'agental guild plan marketing --roles "blog manager:1,reviewer:2" --brief "Reviewers answer pass or fail." --template writers:reviewer',
9646
9669
  'agental guild create marketing --roles "blog manager:1,reviewer:2" --brief "Reviewers answer pass or fail."',
9647
9670
  "agental guild attach marketing writers",
9648
9671
  "agental guild join marketing --as Atlas --role reviewer --answer model=claude",
@@ -9653,9 +9676,10 @@ var COMMANDS = [
9653
9676
  "agental guild work marketing --as builder-1 --once -- claude -p"
9654
9677
  ],
9655
9678
  flags: [
9656
- ["--roles <name[:seats],...>", "create: the roles, each with its seats; attach: the roles its sandboxes may take"],
9657
- ["--brief <text>", "create: what the guild is for, read by every member"],
9679
+ ["--roles <name[:seats],...>", "plan, create: the roles, each with its seats; attach: the roles its sandboxes may take"],
9680
+ ["--brief <text>", "plan, create: what the guild is for, read by every member"],
9658
9681
  ["--form <file.json>", "create: the fields an agent fills in to join, as the API takes them"],
9682
+ ["--template <template[:role,...]>", "plan, create: a template whose sandboxes may join, in those roles or any (may be given again)"],
9659
9683
  ["--as <name>", "join: the name you will be known by in the guild"],
9660
9684
  ["--role <role>", "join: one of the guild's roles with a free seat"],
9661
9685
  ["--answer <key=value>", "join: an answer to the guild's form (may be given again)"],
@@ -9779,7 +9803,7 @@ var COMMANDS = [
9779
9803
  ["--at <date-time>", "add, update: once, at that moment"],
9780
9804
  ["--timeout <time>", "how long a run may take (default 10m, at most 6h)"],
9781
9805
  ["--if-stopped start|skip", "start a stopped sandbox for the run and stop it after (start), or skip"],
9782
- ["--keep-memory", "when the run stops the sandbox again, keep its memory too"],
9806
+ ["--pause-after", "when the run started the sandbox, pause it again after, keeping its memory"],
9783
9807
  ["--delete-after", "with --at: delete the sandbox after a run that exits 0"],
9784
9808
  ["--disk-only", "update: stop it after keeping its disk, as by default"],
9785
9809
  ["--overlap skip|replace|parallel", "when the last run still goes: skip this one, stop that one, or run both"],
@@ -9889,7 +9913,7 @@ var COMMANDS = [
9889
9913
  usage: [
9890
9914
  "agental sandbox list [flags]",
9891
9915
  "agental sandbox create [--name <name>] [flags]",
9892
- "agental sandbox start|stop|delete|recover <sandbox-id> [flags]",
9916
+ "agental sandbox start|stop|pause|resume|delete|recover <sandbox-id> [flags]",
9893
9917
  "agental sandbox exec <sandbox-id> -- <command> [args...]",
9894
9918
  "agental sandbox shell <sandbox-id>",
9895
9919
  "agental sandbox summary [flags]"
@@ -10130,7 +10154,7 @@ ${faint("agental help lists every command.", stream)}
10130
10154
  `;
10131
10155
  }
10132
10156
  var LISTED = { template: "templates", key: "keys", webhook: "webhooks", job: "jobs", server: "servers" };
10133
- var SANDBOX_VERBS = /* @__PURE__ */ new Set(["list", "create", "start", "stop", "delete", "recover", "exec", "shell", "summary"]);
10157
+ var SANDBOX_VERBS = /* @__PURE__ */ new Set(["list", "create", "start", "stop", "pause", "resume", "delete", "recover", "exec", "shell", "summary"]);
10134
10158
  var SECRET_VERBS = /* @__PURE__ */ new Set(["list", "get", "set", "unset", "hosts", "get-file", "put-file", "rm-file"]);
10135
10159
  var ACCOUNT_SECRET_VERBS = /* @__PURE__ */ new Set(["use", "unuse", "seal", "delete"]);
10136
10160
  var ACCOUNT_SECRET_WORDS = /* @__PURE__ */ new Map([
@@ -10165,7 +10189,7 @@ function spelledOut(args, operator = false) {
10165
10189
  };
10166
10190
  switch (thing) {
10167
10191
  case "sandbox":
10168
- return verb !== void 0 && SANDBOX_VERBS.has(verb) ? [verb, ...rest] : wrong("list, create, start, stop, delete, recover, exec, shell or summary");
10192
+ return verb !== void 0 && SANDBOX_VERBS.has(verb) ? [verb, ...rest] : wrong("list, create, start, stop, pause, resume, delete, recover, exec, shell or summary");
10169
10193
  case "region":
10170
10194
  return verb === "list" ? ["regions", ...rest] : wrong("list");
10171
10195
  case "bulk":
@@ -10248,7 +10272,7 @@ var SUBCOMMANDS = {
10248
10272
  limits: ["budget"],
10249
10273
  egress: ["budget", "use-case"],
10250
10274
  tailscale: ["status", "connect", "disconnect"],
10251
- guild: ["list", "show", "create", "delete", "attach", "detach", "mine", "join", "members", "leave", "handover", "post", "read", "requests", "claim", "answer", "close", "notes", "pause", "resume", "work"],
10275
+ guild: ["list", "show", "plan", "create", "delete", "attach", "detach", "mine", "join", "members", "leave", "handover", "post", "read", "requests", "claim", "answer", "close", "notes", "pause", "resume", "work"],
10252
10276
  subscriptions: ["list", "sign-in", "delete"],
10253
10277
  telemetry: ["set", "test", "unset"],
10254
10278
  ci: ["jobs", "set", "reset"],
@@ -10301,7 +10325,7 @@ function flagsOf(usages) {
10301
10325
  return flags2;
10302
10326
  }
10303
10327
  var SANDBOX = /^<sandbox-id>/;
10304
- var SANDBOX_VERBS2 = /* @__PURE__ */ new Set(["list", "create", "start", "stop", "delete", "recover", "exec", "shell", "summary"]);
10328
+ var SANDBOX_VERBS2 = /* @__PURE__ */ new Set(["list", "create", "start", "stop", "pause", "resume", "delete", "recover", "exec", "shell", "summary"]);
10305
10329
  var TEMPLATE = /^<template>/;
10306
10330
  var SNAPSHOT = /^<snapshot/;
10307
10331
  var IMAGE = /^<image>/;
@@ -10948,7 +10972,6 @@ function afterOf(job2) {
10948
10972
  case "delete":
10949
10973
  return "deletes the sandbox, if the command exits 0";
10950
10974
  case "pause":
10951
- case "stop_with_memory":
10952
10975
  return "pauses it again if the run started it, keeping its memory";
10953
10976
  default:
10954
10977
  return "stops it again if the run started it, keeping its disk";
@@ -11045,8 +11068,8 @@ function targetOf(options) {
11045
11068
  throw new Error("--size is the size of each fresh sandbox, and goes with --template.");
11046
11069
  }
11047
11070
  if (template2 !== void 0) {
11048
- if ([options["if-stopped"], options["keep-memory"], options["delete-after"], options["disk-only"]].some((given) => given !== void 0 && given !== false)) {
11049
- throw new Error("--if-stopped, --keep-memory, --delete-after and --disk-only are for a sandbox you keep. A fresh sandbox is made running for each run, and deleted after a run that succeeds.");
11071
+ if ([options["if-stopped"], options["pause-after"], options["delete-after"], options["disk-only"]].some((given) => given !== void 0 && given !== false)) {
11072
+ throw new Error("--if-stopped, --pause-after, --delete-after and --disk-only are for a sandbox you keep. A fresh sandbox is made running for each run, and deleted after a run that succeeds.");
11050
11073
  }
11051
11074
  return { template: template2, ...options.size === void 0 ? {} : { size: options.size } };
11052
11075
  }
@@ -11164,8 +11187,8 @@ function fieldsOf(options) {
11164
11187
  if ([options.every, options.cron, options.at].filter((given) => given !== void 0).length > 1) {
11165
11188
  throw new Error("Give one of --every, --cron or --at.");
11166
11189
  }
11167
- if ([options["keep-memory"], options["delete-after"], options["disk-only"]].filter(Boolean).length > 1) {
11168
- throw new Error("Give one of --keep-memory, --delete-after or --disk-only.");
11190
+ if ([options["pause-after"], options["delete-after"], options["disk-only"]].filter(Boolean).length > 1) {
11191
+ throw new Error("Give one of --pause-after, --delete-after or --disk-only.");
11169
11192
  }
11170
11193
  if (options.overlap !== void 0 && !OVERLAPS.includes(options.overlap)) {
11171
11194
  throw new Error(`--overlap is skip, replace or parallel, not ${options.overlap}.`);
@@ -11193,7 +11216,7 @@ function fieldsOf(options) {
11193
11216
  ...options.timeout === void 0 ? {} : { timeoutMs: timeoutMsOf(options.timeout) },
11194
11217
  ...options.overlap === void 0 ? {} : { overlap: options.overlap },
11195
11218
  ...ifStopped === void 0 ? {} : { ifStopped },
11196
- ...options["keep-memory"] ? { after: "stop_with_memory" } : options["delete-after"] ? { after: "delete" } : options["disk-only"] ? { after: "stop" } : {},
11219
+ ...options["pause-after"] ? { after: "pause" } : options["delete-after"] ? { after: "delete" } : options["disk-only"] ? { after: "stop" } : {},
11197
11220
  ...options["keep-failed-for"] === void 0 ? {} : { keepFailedFor: options["keep-failed-for"] },
11198
11221
  ...options.retries === void 0 ? {} : { retries: Number(options.retries.trim()) },
11199
11222
  ...options.alerts === void 0 ? {} : { alerts: options.alerts },
@@ -11373,7 +11396,7 @@ async function job(client, positionals, command3, options) {
11373
11396
  const changes = { ...fieldsOf(options), ...options.name === void 0 ? {} : { name: options.name }, ...command3 !== null && command3.length > 0 ? { command: commandLine(command3) } : {} };
11374
11397
  if (Object.keys(changes).length === 0) {
11375
11398
  throw new Error(
11376
- "job update needs something to change: --sandbox, --template (and --size), --keep-failed-for, --every, --cron, --at, --tz, --timeout, --overlap, --if-stopped, --keep-memory, --delete-after or --disk-only, --retries, --alerts, --max-monthly-spend, --input or --secret-input, --after-job, --on-mail, --on-guild-request or --no-events, --name for a new name, or a new command after --."
11399
+ "job update needs something to change: --sandbox, --template (and --size), --keep-failed-for, --every, --cron, --at, --tz, --timeout, --overlap, --if-stopped, --pause-after, --delete-after or --disk-only, --retries, --alerts, --max-monthly-spend, --input or --secret-input, --after-job, --on-mail, --on-guild-request or --no-events, --name for a new name, or a new command after --."
11377
11400
  );
11378
11401
  }
11379
11402
  print3(await ask6(client, "PATCH", path9, changes), options.json);
@@ -12477,7 +12500,7 @@ async function writeStdin(client, sandbox, id, one) {
12477
12500
 
12478
12501
  // ../src/cli-servers.ts
12479
12502
  var SERVER_USAGE = "server takes list, add, show, readings, token, drain, open, gone or remove. agental server --help shows each.";
12480
- var SERVERS_USAGE = "servers takes nothing to list them, offload [on|off] [--over <percent>], or core-days [--month <yyyy-mm>].";
12503
+ var SERVERS_USAGE = "servers takes nothing to list them, offload [on|off] [--over <percent>], window [--day <day> --hour <0-23> --tz <zone> [--hours <1-12>] | --off], or core-days [--month <yyyy-mm>].";
12481
12504
  var READING_MINUTES = ["1", "5", "15", "60"];
12482
12505
  async function ask8(client, method, pathname, body) {
12483
12506
  const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
@@ -12572,6 +12595,10 @@ function describe3(server2) {
12572
12595
  ["holds", holdsOf(server2)],
12573
12596
  ["added", utc(server2.addedAt)]
12574
12597
  ];
12598
+ const update = server2.update;
12599
+ if (update !== void 0 && update.wanted !== null && update.runs !== null && update.runs !== update.wanted) {
12600
+ rows.push(["update", update.urgent ? `to ${update.wanted} now: a security release` : update.waitingFor !== null ? `${update.wanted} waits for your window, ${utc(update.waitingFor)}` : `to ${update.wanted} now`]);
12601
+ }
12575
12602
  if (server2.agent.state === "waiting" && server2.agent.joinTokenExpiresAt !== null) {
12576
12603
  rows.push(["token", `works once, until ${utc(server2.agent.joinTokenExpiresAt)}`]);
12577
12604
  }
@@ -12620,6 +12647,10 @@ async function servers(client, positionals, options) {
12620
12647
  await offload(client, rest, options);
12621
12648
  return;
12622
12649
  }
12650
+ if (what === "window" && rest.length === 0) {
12651
+ await updateWindow(client, options);
12652
+ return;
12653
+ }
12623
12654
  if (what === "core-days" && rest.length === 0) {
12624
12655
  await coreDays(client, options);
12625
12656
  return;
@@ -12671,6 +12702,47 @@ async function offload(client, words2, options) {
12671
12702
  sayOffload(set2);
12672
12703
  }
12673
12704
  }
12705
+ function sayWindow(set2) {
12706
+ if (set2.window === null) {
12707
+ process.stdout.write("No update window: your servers take a new agent as soon as agental releases one.\nagental servers window --day sunday --hour 2 --tz Europe/Berlin sets one.\n");
12708
+ return;
12709
+ }
12710
+ const { day, hour, timeZone, hours } = set2.window;
12711
+ process.stdout.write(
12712
+ `Your servers take a new agent on ${day}s from ${String(hour).padStart(2, "0")}:00 for ${hours} hour${hours === 1 ? "" : "s"}, ${timeZone} time.
12713
+ ` + (set2.nextStart === null ? "" : `It next opens ${utc(set2.nextStart)}.
12714
+ `) + "A security release reaches them outside it too. Their sandboxes run on while the agent updates.\n"
12715
+ );
12716
+ }
12717
+ async function updateWindow(client, options) {
12718
+ const setting = options.day !== void 0 || options.hour !== void 0 || options.tz !== void 0 || options.hours !== void 0;
12719
+ if (options.off === true && setting) {
12720
+ throw new Error("servers window takes --off alone, or --day, --hour and --tz with --hours.");
12721
+ }
12722
+ let answer6;
12723
+ if (options.off === true) {
12724
+ answer6 = await ask8(client, "PUT", "/v1/update-window", { window: null });
12725
+ } else if (setting) {
12726
+ if (options.day === void 0 || options.hour === void 0 || options.tz === void 0) {
12727
+ throw new Error("servers window needs --day, --hour and --tz together: as agental servers window --day sunday --hour 2 --tz Europe/Berlin.");
12728
+ }
12729
+ const whole = (flag, value) => {
12730
+ if (!/^\d{1,2}$/.test(value)) {
12731
+ throw new Error(`--${flag} is a whole number, as 2.`);
12732
+ }
12733
+ return Number.parseInt(value, 10);
12734
+ };
12735
+ const window = { day: options.day.toLowerCase(), hour: whole("hour", options.hour), timeZone: options.tz, ...options.hours === void 0 ? {} : { hours: whole("hours", options.hours) } };
12736
+ answer6 = await ask8(client, "PUT", "/v1/update-window", { window });
12737
+ } else {
12738
+ answer6 = await ask8(client, "GET", "/v1/update-window");
12739
+ }
12740
+ if (options.json) {
12741
+ printJson2(answer6);
12742
+ } else {
12743
+ sayWindow(answer6);
12744
+ }
12745
+ }
12674
12746
  async function coreDays(client, options) {
12675
12747
  const query = options.month === void 0 ? "" : `?month=${encodeURIComponent(options.month)}`;
12676
12748
  const body = await ask8(client, "GET", `/v1/core-days${query}`);
@@ -13267,8 +13339,6 @@ var STOPPED_WITH_MEMORY_MAX_MICROS_PER_HOUR = {
13267
13339
  var SANDBOX_STATUSES = ["creating", "running", "stopped", "error", "deleted"];
13268
13340
  var SHOWN_STATUSES = [...SANDBOX_STATUSES, "restoring", "migrating", "paused"];
13269
13341
  var OUTBOUND_MODES = ["open", "blocked", "allowlist"];
13270
- var ON_TIMEOUT = ["delete", "stop", "pause"];
13271
- var ON_TIMEOUT_SENT = [...ON_TIMEOUT, "stop_with_memory"];
13272
13342
  function isMachineSize(value) {
13273
13343
  return Object.hasOwn(MACHINE_SIZES, value);
13274
13344
  }
@@ -15137,7 +15207,7 @@ var AgentalError = class extends Error {
15137
15207
  // ../sdk/typescript/src/sealed.ts
15138
15208
  var SEALED_SUITE = "x25519-hkdf-sha256-aes256gcm";
15139
15209
  var ROOT_PUBLIC_KEYS = ["jNdFf3FKdbFQ5J-1e_NE7ZzuaNPRdci-mzlGj384Rmw"];
15140
- var SEALED_PURPOSES = ["variable", "tailscale-oauth", "sign-in-code"];
15210
+ var SEALED_PURPOSES = ["variable", "tailscale-oauth", "sign-in-code", "connection-app"];
15141
15211
  var KEM_ID = 32;
15142
15212
  var KDF_ID = 1;
15143
15213
  var AEAD_ID = 2;
@@ -16043,7 +16113,7 @@ async function work(options) {
16043
16113
  }
16044
16114
 
16045
16115
  // ../src/cli-guilds.ts
16046
- var USAGE10 = "guild takes list, show, create, delete, attach, detach, mine, join, members, leave, handover, post, read, requests, claim, answer, close, notes, pause, resume, mail or work. agental guild --help shows each.";
16116
+ var USAGE10 = "guild takes list, show, plan, create, delete, attach, detach, mine, join, members, leave, handover, post, read, requests, claim, answer, close, notes, pause, resume, mail or work. agental guild --help shows each.";
16047
16117
  async function ask12(client, method, pathname, body) {
16048
16118
  const response = await client.request(pathname, { method, ...body === void 0 ? {} : { body: JSON.stringify(body) } });
16049
16119
  let answered = null;
@@ -16113,6 +16183,45 @@ function formFrom(file) {
16113
16183
  throw new Error(`--form ${file} is not JSON. It is an array of fields: [{"key": "model", "label": "Which model are you?", "kind": "choice", "choices": ["claude", "codex"], "required": true}].`);
16114
16184
  }
16115
16185
  }
16186
+ function templateAsked(given) {
16187
+ const colon = given.indexOf(":");
16188
+ const named = (colon === -1 ? given : given.slice(0, colon)).trim();
16189
+ const roles = colon === -1 ? [] : given.slice(colon + 1).split(",").map((role) => role.trim()).filter((role) => role !== "");
16190
+ return { ...named.startsWith("tpl_") ? { templateId: named } : { templateName: named }, ...roles.length === 0 ? {} : { roles } };
16191
+ }
16192
+ function guildAsked(name, options, verb) {
16193
+ return {
16194
+ name: needed(name, `${verb} takes a guild's name`),
16195
+ roles: rolesOf(needed(options.roles, `${verb} takes --roles, such as "blog manager:1,reviewer:2"`)),
16196
+ ...options.brief === void 0 ? {} : { brief: options.brief },
16197
+ ...options.form === void 0 ? {} : { form: formFrom(options.form) }
16198
+ };
16199
+ }
16200
+ function problemLines(plan2) {
16201
+ return plan2.problems.map((problem) => ` ${problem.field} ${problem.code}: ${problem.message}
16202
+ `).join("");
16203
+ }
16204
+ function planWords(plan2) {
16205
+ const { guild: planned } = plan2;
16206
+ const rules = (role) => `, takes a request for ${String(role["claimMinutes"] ?? 30)} min, ${String(role["postsPerMinute"] ?? 6)} posts a minute, posts to ${role["postsTo"] === null ? "everyone" : role["postsTo"].join(", ") || "no one"}`;
16207
+ return [
16208
+ `${planned.name}, as it would be made
16209
+ `,
16210
+ planned.brief ? ` ${planned.brief}
16211
+ ` : "",
16212
+ `roles
16213
+ ${planned.roles.map((role) => ` ${roleLine(role)}${rules(role)}
16214
+ `).join("")}`,
16215
+ planned.form.length ? `form
16216
+ ${planned.form.map((field) => ` ${String(field["key"])}: ${String(field["label"])}${field["required"] ? " (required)" : ""}
16217
+ `).join("")}` : "",
16218
+ `templates
16219
+ ${planned.templates.map((one) => ` ${one.templateName} (${one.templateId})${one.roles ? ` as ${one.roles.join(", ")}` : ", any role"}
16220
+ `).join("") || " none\n"}`,
16221
+ plan2.ok ? "No problems: agental guild create with the same words makes it.\n" : `problems
16222
+ ${problemLines(plan2)}`
16223
+ ].join("");
16224
+ }
16116
16225
  function roleLine(role) {
16117
16226
  return `${String(role["name"])} (${role["seats"] === null ? "any number" : `${String(role["seats"])} seat${role["seats"] === 1 ? "" : "s"}`}, ${String(role["onDelete"])} at a delete)${role["address"] ? ` ${String(role["address"])}` : ""}`;
16118
16227
  }
@@ -16187,15 +16296,35 @@ ${members2.map((member) => ` ${memberLine(member)}`).join("") || " none\n"}`
16187
16296
  print4(options.json, { ...found, members: members2 }, words2);
16188
16297
  return;
16189
16298
  }
16299
+ case "plan": {
16300
+ const plan2 = await ask12(client, "POST", "/v1/guilds/plan", { ...guildAsked(name, options, "plan"), templates: (options.template ?? []).map(templateAsked) });
16301
+ print4(options.json, plan2, planWords(plan2));
16302
+ if (!plan2.ok) {
16303
+ process.exitCode = 1;
16304
+ }
16305
+ return;
16306
+ }
16190
16307
  case "create": {
16191
- const body = {
16192
- name: needed(name, "create takes a guild's name"),
16193
- roles: rolesOf(needed(options.roles, 'create takes --roles, such as "blog manager:1,reviewer:2"')),
16194
- ...options.brief === void 0 ? {} : { brief: options.brief },
16195
- ...options.form === void 0 ? {} : { form: formFrom(options.form) }
16196
- };
16308
+ const body = guildAsked(name, options, "create");
16309
+ let templates2 = [];
16310
+ if (options.template !== void 0 && options.template.length > 0) {
16311
+ const plan2 = await ask12(client, "POST", "/v1/guilds/plan", { ...body, templates: options.template.map(templateAsked) });
16312
+ if (!plan2.ok) {
16313
+ throw new Error(`Nothing was created:
16314
+ ${problemLines(plan2)}`);
16315
+ }
16316
+ templates2 = plan2.guild.templates;
16317
+ }
16197
16318
  const made = await ask12(client, "POST", "/v1/guilds", body);
16198
- print4(options.json, made, `Made guild ${String(made["name"])}. agental guild attach ${String(made["name"])} <template> lets that template's sandboxes join it.
16319
+ for (const template2 of templates2) {
16320
+ try {
16321
+ await ask12(client, "PUT", `${at4(String(made["name"]))}/templates/${encodeURIComponent(template2.templateId)}`, template2.roles === null ? {} : { roles: template2.roles });
16322
+ } catch (error) {
16323
+ throw new Error(`Made guild ${String(made["name"])}, but ${template2.templateName} could not be let in: ${error instanceof Error ? error.message : String(error)} Let it in with agental guild attach ${String(made["name"])} ${template2.templateName}.`);
16324
+ }
16325
+ }
16326
+ const joining = templates2.length === 0 ? ` agental guild attach ${String(made["name"])} <template> lets that template's sandboxes join it.` : ` Sandboxes of ${templates2.map((one) => one.templateName).join(", ")} may join it.`;
16327
+ print4(options.json, { ...made, templates: templates2 }, `Made guild ${String(made["name"])}.${joining}
16199
16328
  `);
16200
16329
  return;
16201
16330
  }
@@ -16569,7 +16698,7 @@ async function answer4(client, path9, init) {
16569
16698
  }
16570
16699
 
16571
16700
  // ../src/cli-sites.ts
16572
- var USAGE12 = "site takes a sandbox, or list, add, rm, stats or analytics, then the sandbox. agental site --help shows each.";
16701
+ var USAGE12 = "site takes a sandbox, or list, add, rm, access, stats or analytics, then the sandbox. agental site --help shows each.";
16573
16702
  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.";
16574
16703
  var REPORT_ROWS = 5;
16575
16704
  async function bodyOf2(response) {
@@ -16755,7 +16884,7 @@ async function site(client, positionals, options) {
16755
16884
  if (turn === "on" || turn === "off") return siteSwitch(client, turn, words2, options);
16756
16885
  throw new Error(ANALYTICS_USAGE);
16757
16886
  }
16758
- const verb = positionals[0] === "list" || positionals[0] === "add" || positionals[0] === "rm" || positionals[0] === "stats" ? positionals[0] : null;
16887
+ const verb = positionals[0] === "list" || positionals[0] === "add" || positionals[0] === "rm" || positionals[0] === "stats" || positionals[0] === "access" ? positionals[0] : null;
16759
16888
  const [sandbox, target, ...rest] = verb === null ? positionals : positionals.slice(1);
16760
16889
  if (sandbox === void 0) {
16761
16890
  throw new Error(USAGE12);
@@ -16777,7 +16906,7 @@ async function site(client, positionals, options) {
16777
16906
  `);
16778
16907
  return;
16779
16908
  }
16780
- const rows = [["ID", "ADDRESS", "PORT", "STATE"], ...sites.map((route) => [route.id, route.url ?? "no public address here", String(route.port), stateOf4(route)])];
16909
+ const rows = [["ID", "ADDRESS", "PORT", "WHO MAY OPEN", "STATE"], ...sites.map((route) => [route.id, route.url ?? "no public address here", String(route.port), route.access === "organization" ? "organization" : "anyone", stateOf4(route)])];
16781
16910
  const terminal2 = isTerminal(process.stdout);
16782
16911
  process.stdout.write(fitted(rows, { ...terminal2 ? { give: 1 } : { width: Number.MAX_SAFE_INTEGER }, paint: (cell, row) => row === 0 ? faint(cell) : cell }));
16783
16912
  return;
@@ -16787,7 +16916,18 @@ async function site(client, positionals, options) {
16787
16916
  throw new Error(USAGE12);
16788
16917
  }
16789
16918
  const port = portFrom(target);
16790
- const made = routeOf(await ask13(client, "POST", `/v1/sandboxes/${encodeURIComponent(sandbox)}/host`, { port, title: `port-${port}`, public: true }));
16919
+ const response = await client.request(`/v1/sandboxes/${encodeURIComponent(sandbox)}/host`, {
16920
+ method: "POST",
16921
+ body: JSON.stringify({ port, title: `port-${port}`, public: true, ...options.private ? { access: "organization" } : {} })
16922
+ });
16923
+ const answered = await bodyOf2(response);
16924
+ if (!response.ok) {
16925
+ if (response.status === 409 && answered?.error?.code === "port_private") {
16926
+ throw new Error(`Port ${port} has a private link already. Add this one with --private, or open the port to anyone first with agental site access ${sandbox} <site-id> anyone.`);
16927
+ }
16928
+ client.fail(response.status, answered);
16929
+ }
16930
+ const made = routeOf(answered);
16791
16931
  if (options.json) {
16792
16932
  process.stdout.write(`${JSON.stringify(made, null, 2)}
16793
16933
  `);
@@ -16802,7 +16942,31 @@ async function site(client, positionals, options) {
16802
16942
  process.stdout.write(`${made.url}
16803
16943
  `);
16804
16944
  process.stderr.write(
16805
- `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.
16945
+ made.access === "organization" ? `Only your organization's people, signed in to agental, and keys with site.open in X-Agental-Key can open port ${port}, at every link it has. The server must listen on 0.0.0.0. agental site rm ${sandbox} ${made.id} takes it away.
16946
+ ` : `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.
16947
+ `
16948
+ );
16949
+ return;
16950
+ }
16951
+ case "access": {
16952
+ const [who] = rest;
16953
+ if (target === void 0 || who !== "anyone" && who !== "organization" || rest.length > 1) {
16954
+ throw new Error(`site access needs the sandbox, the site's id, and anyone or organization: agental site access ${sandbox} rte_\u2026 organization.`);
16955
+ }
16956
+ const found = await siteOn(client, sandbox, target);
16957
+ if (who === "anyone" && found.access === "organization" && !options.yes && !await client.confirmed(`Open ${found.url ?? target} to anyone with the link? The app on port ${found.port} is then used with no sign-in, and everyone signed in to it is signed out.`)) {
16958
+ process.stdout.write("Nothing was changed.\n");
16959
+ return;
16960
+ }
16961
+ const changed = routeOf(await ask13(client, "PUT", `/v1/host-routes/${encodeURIComponent(target)}/access`, { access: who }));
16962
+ if (options.json) {
16963
+ process.stdout.write(`${JSON.stringify(changed, null, 2)}
16964
+ `);
16965
+ return;
16966
+ }
16967
+ process.stdout.write(
16968
+ who === "organization" ? `${changed.url ?? target} is private now, at every address of port ${changed.port}: only your organization's people, signed in, and keys with site.open open it.
16969
+ ` : `${changed.url ?? target} is open to anyone with the link now, at every address of port ${changed.port}.
16806
16970
  `
16807
16971
  );
16808
16972
  return;
@@ -17720,7 +17884,10 @@ async function main() {
17720
17884
  unlink: { type: "string" },
17721
17885
  expires: { type: "string" },
17722
17886
  "keep-streams": { type: "boolean" },
17887
+ // Pause's earlier spelling, on stop and on jobs: kept only to say what replaced it (docs/pause-resume.md, 4).
17723
17888
  "keep-memory": { type: "boolean" },
17889
+ // agental job create and job update: a run that started the sandbox pauses it again after.
17890
+ "pause-after": { type: "boolean" },
17724
17891
  "without-memory": { type: "boolean" },
17725
17892
  // agental delete and template delete: delete a sandbox that jobs run in, or a template they make their sandboxes from, and pause them.
17726
17893
  "pause-jobs": { type: "boolean" },
@@ -17827,10 +17994,16 @@ async function main() {
17827
17994
  // agental servers offload: how used a server of the organization's own may be and still take a new sandbox. servers core-days: which month.
17828
17995
  over: { type: "string" },
17829
17996
  month: { type: "string" },
17997
+ // agental servers window: the weekly window the organization's servers take a new agent in, with --tz and --off.
17998
+ day: { type: "string" },
17999
+ hour: { type: "string" },
18000
+ hours: { type: "string" },
17830
18001
  // agental site stats: 24h or 7d.
17831
18002
  range: { type: "string" },
17832
18003
  // agental site analytics org on: the person has read what is kept.
17833
18004
  informed: { type: "boolean", default: false },
18005
+ // agental site add: only the organization opens it.
18006
+ private: { type: "boolean", default: false },
17834
18007
  sort: { type: "string" },
17835
18008
  role: { type: "string" },
17836
18009
  // Guilds: the roles of a create or an attach, its brief and form, and who joins with what answers.
@@ -17869,6 +18042,11 @@ async function main() {
17869
18042
  }
17870
18043
  });
17871
18044
  const command3 = positionals[0];
18045
+ if (values["keep-memory"] !== void 0) {
18046
+ throw new Error(
18047
+ command3 === "job" ? "--keep-memory is now --pause-after: a run that started the sandbox pauses it again after, keeping its memory." : "--keep-memory is gone: agental pause <sandbox-id> keeps a sandbox's memory, and agental resume <sandbox-id> carries on from it."
18048
+ );
18049
+ }
17872
18050
  if (!command3) {
17873
18051
  process.stdout.write(isTerminal(process.stdout) ? shortHelp() : await helpText());
17874
18052
  return;
@@ -17931,10 +18109,30 @@ async function main() {
17931
18109
  return;
17932
18110
  case "stop":
17933
18111
  if (values.where !== void 0) {
17934
- await bulk("stop", whereQuery(values.where, labelsFilter(values)), values["keep-memory"] === true ? { keepMemory: true } : {}, values.yes === true, values.json);
18112
+ await bulk("stop", whereQuery(values.where, labelsFilter(values)), {}, values.yes === true, values.json);
18113
+ return;
18114
+ }
18115
+ await lifecycle("stop", positionals[1]);
18116
+ return;
18117
+ case "pause":
18118
+ if (values.where !== void 0 && positionals[1] !== void 0) {
18119
+ throw new Error("pause takes a sandbox's ID or --where, not both");
18120
+ }
18121
+ if (values.where !== void 0) {
18122
+ await bulk("stop", whereQuery(values.where, labelsFilter(values)), { keepMemory: true }, values.yes === true, values.json, void 0, "Pause");
17935
18123
  return;
17936
18124
  }
17937
- await lifecycle("stop", positionals[1], {}, values["keep-memory"] === true ? { keepMemory: true } : void 0);
18125
+ await lifecycle("pause", positionals[1]);
18126
+ return;
18127
+ case "resume":
18128
+ if (values.where !== void 0 && positionals[1] !== void 0) {
18129
+ throw new Error("resume takes a sandbox's ID or --where, not both");
18130
+ }
18131
+ if (values.where !== void 0) {
18132
+ await bulk("start", pausedOnly(whereQuery(values.where, labelsFilter(values))), {}, values.yes === true, values.json, void 0, "Resume");
18133
+ return;
18134
+ }
18135
+ await lifecycle("resume", positionals[1], maxBurstFeeHeaders(values["max-burst-fee"]));
17938
18136
  return;
17939
18137
  case "recover":
17940
18138
  await lifecycle("recover", positionals[1], maxBurstFeeHeaders(values["max-burst-fee"]));
@@ -17993,7 +18191,7 @@ async function main() {
17993
18191
  await browser(positionals[1], values.headless, values.headed, values.off, values.status);
17994
18192
  return;
17995
18193
  case "site":
17996
- await site({ request, fail, confirmed }, positionals.slice(1), { json: values.json, range: values.range, yes: values.yes === true, informed: values.informed === true });
18194
+ await site({ request, fail, confirmed }, positionals.slice(1), { json: values.json, range: values.range, yes: values.yes === true, informed: values.informed === true, private: values.private === true });
17997
18195
  return;
17998
18196
  case "network":
17999
18197
  await network(positionals.slice(1), values);
@@ -18022,6 +18220,7 @@ async function main() {
18022
18220
  ...values.role === void 0 ? {} : { role: values.role },
18023
18221
  ...values.brief === void 0 ? {} : { brief: values.brief },
18024
18222
  ...values.form === void 0 ? {} : { form: values.form },
18223
+ ...values.template === void 0 ? {} : { template: values.template },
18025
18224
  ...values.as === void 0 ? {} : { as: values.as },
18026
18225
  ...values.answer === void 0 ? {} : { answer: values.answer },
18027
18226
  ...values.to === void 0 ? {} : { to: values.to },
@@ -18196,8 +18395,8 @@ async function create(values) {
18196
18395
  const burstHeaders = maxBurstFeeHeaders(values["max-burst-fee"]);
18197
18396
  const ttlSeconds = ttlOption(values.ttl);
18198
18397
  const onTimeout = values["on-timeout"];
18199
- if (onTimeout !== void 0 && onTimeout !== "delete" && onTimeout !== "stop" && onTimeout !== "stop-with-memory" && onTimeout !== "stop_with_memory") {
18200
- throw new Error("--on-timeout is delete, stop or stop-with-memory: what the sandbox's time limit does when it runs out");
18398
+ if (onTimeout !== void 0 && onTimeout !== "delete" && onTimeout !== "stop" && onTimeout !== "pause") {
18399
+ throw new Error("--on-timeout is delete, stop or pause: what the sandbox's time limit does when it runs out");
18201
18400
  }
18202
18401
  if (values.size !== void 0 && !isMachineSize(values.size)) {
18203
18402
  throw new Error("--size must be tiny, small, medium, large or xlarge");
@@ -18248,9 +18447,9 @@ async function create(values) {
18248
18447
  ...allow ? { network: { allow } } : {},
18249
18448
  ...egressAsked ? { egress: egressAsked } : {},
18250
18449
  ...tailnetAsked === void 0 ? {} : { tailnet: tailnetAsked },
18251
- ...values.guild === void 0 ? {} : { guilds: values.guild.map(guildAsked) },
18450
+ ...values.guild === void 0 ? {} : { guilds: values.guild.map(guildAsked2) },
18252
18451
  ...ttlSeconds === void 0 ? {} : { ttlSeconds },
18253
- ...onTimeout === void 0 ? {} : { onTimeout: onTimeout.replaceAll("-", "_") },
18452
+ ...onTimeout === void 0 ? {} : { onTimeout },
18254
18453
  ...spotAsked === void 0 ? {} : { spot: spotAsked },
18255
18454
  ...sshKeys2 === void 0 ? {} : { sshKeys: sshKeys2 },
18256
18455
  ...given
@@ -18579,14 +18778,23 @@ async function confirmed(question) {
18579
18778
  lines.close();
18580
18779
  }
18581
18780
  }
18582
- async function bulk(action, filter, options, yes2, asJson, confirm) {
18781
+ function pausedOnly(filter) {
18782
+ const statuses = filter.getAll("status");
18783
+ if (statuses.some((status) => status !== "paused")) {
18784
+ throw new Error("resume --where finds the paused sandboxes its words name: leave other statuses out of the words, and say archived:true for the archived ones.");
18785
+ }
18786
+ filter.delete("status");
18787
+ filter.append("status", "paused");
18788
+ return filter;
18789
+ }
18790
+ async function bulk(action, filter, options, yes2, asJson, confirm, word) {
18583
18791
  const previewed = await request("/v1/bulk-actions/preview", { method: "POST", body: JSON.stringify({ action, options, select: { filter: filterOf(filter) } }) });
18584
18792
  const preview = await readBody(previewed);
18585
18793
  if (!previewed.ok) {
18586
18794
  fail(previewed.status, preview);
18587
18795
  }
18588
18796
  const read2 = preview;
18589
- process.stderr.write(`${action === "stop" ? "Stop" : action === "start" ? "Start" : "Delete"} ${read2.count} ${read2.count === 1 ? "sandbox" : "sandboxes"}: ${read2.sample.map((each) => each.name).join(", ")}${read2.count > read2.sample.length ? `, and ${read2.count - read2.sample.length} more` : ""}.
18797
+ process.stderr.write(`${word ?? (action === "stop" ? "Stop" : action === "start" ? "Start" : "Delete")} ${read2.count} ${read2.count === 1 ? "sandbox" : "sandboxes"}: ${read2.sample.map((each) => each.name).join(", ")}${read2.count > read2.sample.length ? `, and ${read2.count - read2.sample.length} more` : ""}.
18590
18798
  `);
18591
18799
  process.stderr.write(`They cost ${dollarsOf(read2.microsPerHour.now)} an hour now, and ${dollarsOf(read2.microsPerHour.after)} an hour after.
18592
18800
  `);
@@ -18731,8 +18939,8 @@ async function lifecycle(action, id, headers = {}, sent) {
18731
18939
  process.stderr.write(`Starting ${id} from its disk. The memory it was stopped with is let go for good: its files are kept, and the programs that ran in it are not.
18732
18940
  `);
18733
18941
  }
18734
- if (sent?.["keepMemory"] === true) {
18735
- process.stderr.write(`Stopping ${id} with its memory kept. It ends once the memory is written, about a second for every 2 to 3 GiB.
18942
+ if (action === "pause") {
18943
+ process.stderr.write(`Pausing ${id} with its memory kept. It ends once the memory is written, about a second for every 2 to 3 GiB.
18736
18944
  `);
18737
18945
  }
18738
18946
  const response = await request(`/v1/sandboxes/${encodeURIComponent(id)}/${action}`, { method: "POST", headers, ...sent === void 0 ? {} : { body: JSON.stringify(sent) } });
@@ -18741,21 +18949,21 @@ async function lifecycle(action, id, headers = {}, sent) {
18741
18949
  fail(response.status, body);
18742
18950
  }
18743
18951
  sayBurstFee(response);
18744
- if (action === "stop" && response.status === 202) {
18745
- body = await stoppedAfter(id, response.headers.get("operation-id"));
18952
+ if ((action === "stop" || action === "pause") && response.status === 202) {
18953
+ body = await stoppedAfter(id, response.headers.get("operation-id"), action === "pause" ? "pause" : "stop");
18746
18954
  }
18747
18955
  process.stdout.write(`${JSON.stringify(body, null, 2)}
18748
18956
  `);
18749
18957
  const memoryLost = Boolean(body) && typeof body === "object" ? body["memoryLost"] : null;
18750
- if (typeof memoryLost === "string" && memoryLost !== "" && (action === "start" || sent?.["keepMemory"] === true)) {
18958
+ if (typeof memoryLost === "string" && memoryLost !== "" && (action === "start" || action === "resume" || action === "pause")) {
18751
18959
  process.stderr.write(`${memoryLost}
18752
18960
  `);
18753
18961
  }
18754
- if (action === "start" && response.status === 202) {
18962
+ if ((action === "start" || action === "resume") && response.status === 202) {
18755
18963
  const archived = Boolean(body) && typeof body === "object" && body["archived"] === true;
18756
18964
  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";
18757
18965
  process.stderr.write(
18758
- `Start was accepted. ${id} is restoring: ${why2}. It is running when agental list says so. If list shows it stopped again, the start failed, and agental list --json has its error.
18966
+ `${action === "resume" ? "Resume" : "Start"} was accepted. ${id} is restoring: ${why2}. It is running when agental list says so. If list shows it ${action === "resume" ? "paused" : "stopped"} again, the ${action} failed, and agental list --json has its error.
18759
18967
  `
18760
18968
  );
18761
18969
  }
@@ -18817,8 +19025,10 @@ function sizeOf2(sandbox) {
18817
19025
  const size2 = typeof sandbox["size"] === "string" ? sandbox["size"] : "";
18818
19026
  return typeof sandbox["pendingSize"] === "string" ? `${size2} (${sandbox["pendingSize"]} from its next start)` : size2;
18819
19027
  }
18820
- async function stoppedAfter(id, operationId) {
18821
- process.stderr.write("Still writing its memory. Waiting until it has stopped.\n");
19028
+ async function stoppedAfter(id, operationId, word = "stop") {
19029
+ const done2 = word === "pause" ? "paused" : "stopped";
19030
+ process.stderr.write(`Still writing its memory. Waiting until it has ${done2}.
19031
+ `);
18822
19032
  const deadline = Date.now() + 6e5;
18823
19033
  for (; ; ) {
18824
19034
  const sandbox = await call2(`/v1/sandboxes/${encodeURIComponent(id)}`, { method: "GET" });
@@ -18828,11 +19038,11 @@ async function stoppedAfter(id, operationId) {
18828
19038
  if (operationId !== null) {
18829
19039
  const { operation } = await call2(`/v1/operations/${encodeURIComponent(operationId)}`, { method: "GET" });
18830
19040
  if (operation.status === "failed") {
18831
- throw new Error(`${id} was not stopped: ${operation.error ?? "the stop failed"}`);
19041
+ throw new Error(`${id} was not ${done2}: ${operation.error ?? `the ${word} failed`}`);
18832
19042
  }
18833
19043
  }
18834
19044
  if (Date.now() > deadline) {
18835
- throw new Error(`${id} was still writing its memory after ten minutes. The stop goes on: agental list says when it has stopped.`);
19045
+ throw new Error(`${id} was still writing its memory after ten minutes. The ${word} goes on: agental list says when it has ${done2}.`);
18836
19046
  }
18837
19047
  await new Promise((resolve) => setTimeout(resolve, 3e3));
18838
19048
  }
@@ -20949,7 +21159,7 @@ function boxNamed(value) {
20949
21159
  }
20950
21160
  return value?.trim();
20951
21161
  }
20952
- function guildAsked(given) {
21162
+ function guildAsked2(given) {
20953
21163
  const colon = given.indexOf(":");
20954
21164
  if (colon === -1) {
20955
21165
  return { guild: given.trim() };
@@ -21092,7 +21302,7 @@ Setting up
21092
21302
  agental completion zsh|bash|fish
21093
21303
 
21094
21304
  Usage
21095
- agental create [--name <name>] [--template <template>] [--snapshot <snapshot-id> | --image <image>] [--size tiny|small|medium|large|xlarge] [--region <region>[,<region>...]] [--ttl <time> | --ttl default] [--on-timeout delete|stop|stop-with-memory] [--idempotency-key <key>]
21305
+ agental create [--name <name>] [--template <template>] [--snapshot <snapshot-id> | --image <image>] [--size tiny|small|medium|large|xlarge] [--region <region>[,<region>...]] [--ttl <time> | --ttl default] [--on-timeout delete|stop|pause] [--idempotency-key <key>]
21096
21306
  [--spot [--on-reclaim delete|stop] [--warn-at <chance>] | --standard]
21097
21307
  ${operator ? "[--box <name-or-id>] " : ""}[--allow <address>[,<address>...]] [--egress box | residential:<country>[:sticky|rotating]] [--max-burst-fee <dollars>]
21098
21308
  [--ssh-key <public-key-or-file>]... [--tag <tag>[,<tag>...]]... [--meta <key>=<value>]...
@@ -21116,8 +21326,12 @@ Usage
21116
21326
  agental shell <sandbox-id> --close <shell> end a kept shell
21117
21327
  agental delete <sandbox-id>
21118
21328
  agental start <sandbox-id> [--max-burst-fee <dollars>] [--without-memory]
21119
- agental stop <sandbox-id> [--keep-memory]
21120
- agental stop --where '<words>' [--keep-memory] [--yes] every sandbox the words find, as one bulk action
21329
+ agental stop <sandbox-id>
21330
+ agental pause <sandbox-id> stop it with its memory kept, to resume where it was
21331
+ agental resume <sandbox-id> [--max-burst-fee <dollars>]
21332
+ agental pause --where '<words>' [--yes]
21333
+ agental resume --where '<words>' [--yes] the paused sandboxes the words find
21334
+ agental stop --where '<words>' [--yes] every sandbox the words find, as one bulk action
21121
21335
  agental start --where '<words>' [--yes]
21122
21336
  agental delete --where '<words>' [--confirm <count>] asks for the count to be typed
21123
21337
  agental bulk-actions [list | show <id> | cancel <id>] [--json]
@@ -21162,7 +21376,7 @@ Usage
21162
21376
  agental data-retention [1 | 7 | 30 | 90 | never] [--json]
21163
21377
  agental jobs [--sandbox <sandbox-id> | --template <template>] [--json]
21164
21378
  agental job add [<name>] --sandbox <sandbox-id> [--every 1m|15m|1h|1d | --cron "<m h dom mon dow>" [--tz <zone>] | --at <date-time>] [--timeout <time>]
21165
- [--if-stopped start|skip] [--keep-memory | --delete-after] [--overlap skip|replace|parallel] [--retries <0-5>] [--alerts email|webhook|both|none]
21379
+ [--if-stopped start|skip] [--pause-after | --delete-after] [--overlap skip|replace|parallel] [--retries <0-5>] [--alerts email|webhook|both|none]
21166
21380
  [--max-monthly-spend <dollars>]
21167
21381
  [--input <NAME>[=<default>]]... [--secret-input <NAME>[=<default>]]... [--after-job <job>[:succeeded|failed]]... [--on-mail <sandbox>]... [--on-guild-request <guild>:<identity>]...
21168
21382
  [--json] -- <command> [args...]
@@ -21173,7 +21387,7 @@ Usage
21173
21387
  agental job list [--sandbox <sandbox-id> | --template <template>] [--json]
21174
21388
  agental job get|delete|pause|resume <job> [--json]
21175
21389
  agental job update <job> [--sandbox <sandbox-id> | --template <template> [--size <size>]] [--keep-failed-for <time>] [--every <time> | --cron "<expr>" | --at <date-time>] [--tz <zone>]
21176
- [--name <name>] [--timeout <time>] [--if-stopped start|skip] [--keep-memory | --delete-after | --disk-only] [--overlap skip|replace|parallel]
21390
+ [--name <name>] [--timeout <time>] [--if-stopped start|skip] [--pause-after | --delete-after | --disk-only] [--overlap skip|replace|parallel]
21177
21391
  [--retries <0-5>] [--alerts email|webhook|both|none] [--max-monthly-spend <dollars>|none] [--input <NAME>[=<default>]]... [--secret-input <NAME>[=<default>]]...
21178
21392
  [--after-job <job>[:succeeded|failed]]... [--on-mail <sandbox>]... [--on-guild-request <guild>:<identity>]... [--no-events] [--json] [-- <command> [args...]]
21179
21393
  agental job run <job> [--input <NAME>=<value>]... [--wait[=<seconds>]] [--json]
@@ -21209,6 +21423,7 @@ Usage
21209
21423
  agental webhook delete <webhook-id>
21210
21424
  agental servers [--json]
21211
21425
  agental servers offload [on|off] [--over <percent>] [--json]
21426
+ agental servers window [--day <day> --hour <0-23> --tz <zone> [--hours <1-12>] | --off] [--json]
21212
21427
  agental servers core-days [--month <yyyy-mm>] [--json]
21213
21428
  agental server add <label> [--json] its install line and join token, shown once
21214
21429
  agental server show <server> [--json]
@@ -21249,10 +21464,11 @@ ${FILES_USAGE.map((line) => ` ${line}`).join("\n")}
21249
21464
  agental ssh-config <sandbox-id>
21250
21465
  agental ssh-keys <sandbox-id> [--remove <key-id>] [--json]
21251
21466
  agental ssh-off <sandbox-id>
21252
- agental site <sandbox-id> [--json] its sites: public links to its ports
21467
+ agental site <sandbox-id> [--json] its sites: links to its ports, and who may open each
21253
21468
  agental site list <sandbox-id> [--json]
21254
- agental site add <sandbox-id> <port> [--json] a public link to a port, printed
21469
+ agental site add <sandbox-id> <port> [--private] [--json] a link to a port, printed; --private: your organization only
21255
21470
  agental site rm <sandbox-id> <site-id> the link stops working, for good
21471
+ agental site access <sandbox-id> <site-id> anyone|organization [--json] who may open it
21256
21472
  agental site stats <sandbox-id> <site-id> [--range 24h|7d] [--json] its visits, pages, sources, countries
21257
21473
  agental site analytics on|off <sandbox-id> <site-id> [--yes] [--json] off deletes its figures
21258
21474
  agental site analytics org [on|off] [--informed] [--yes] [--json] the organization's switch
@@ -21300,7 +21516,7 @@ next start boots it at it. A running one keeps running, and paying, as its size
21300
21516
  stopped, and its next start gives it the new one, whoever starts it; --now stops it and starts it
21301
21517
  again at the new size now, and every process in it ends, as on a stop. --cancel takes a size that
21302
21518
  waits away. Memory a stop kept is let go: the next start boots from the disk. While a size waits,
21303
- stop --keep-memory is refused.
21519
+ pause is refused.
21304
21520
  recover gets a sandbox that is stuck going again: what runs in it is killed, its disk is kept,
21305
21521
  and it ends running. One that is stopped is started, and pays a burst fee as a start does.
21306
21522
  Start of a sandbox that was archived is accepted and finished afterwards: list shows it as
@@ -21309,8 +21525,8 @@ A sandbox runs until it is stopped, unless it has a time limit: then it is stopp
21309
21525
  run that long since its last start. create --ttl and template start --ttl set one, as 45m, 2h or
21310
21526
  1d, and --ttl default takes the deployment's, which is none unless it says otherwise. When the
21311
21527
  time limit runs out the sandbox is deleted, with its disk, unless create --on-timeout stop said to
21312
- stop it and keep its disk, or --on-timeout stop-with-memory to keep its memory too, so its next
21313
- start carries on where it was (after the account's first top-up: before it, refused with
21528
+ stop it and keep its disk, or --on-timeout pause to keep its memory too, so agental resume
21529
+ carries on where it was (after the account's first top-up: before it, refused with
21314
21530
  memory_needs_top_up); agental stop always keeps the disk. auto-stop
21315
21531
  says when a running sandbox is to be stopped, with --in or --at moves that stop, later or sooner,
21316
21532
  for the run under way, and with --never takes its time limit away, for this run and the next.
@@ -21424,8 +21640,8 @@ or 1d, counted from now, never more often than every minute, or --cron with five
21424
21640
  time zone --tz names, UTC unless it does, says when; --at a date and time runs it once. With none
21425
21641
  of them it runs only when asked, by job run. Its name is lower-case letters, digits and dashes,
21426
21642
  job-1, job-2 and so on when none is given. When a run finds the sandbox stopped it starts it,
21427
- runs, and stops it again when the command ends, keeping its disk, or its memory too with
21428
- --keep-memory; with --if-stopped skip it runs only while the sandbox runs. A sandbox someone
21643
+ runs, and stops it again when the command ends, keeping its disk, or pauses it with
21644
+ --pause-after; with --if-stopped skip it runs only while the sandbox runs. A sandbox someone
21429
21645
  started again, sent a command or moved the stop of meanwhile is left running. With --at,
21430
21646
  --delete-after deletes the sandbox after the run, if the command exits 0, with a key that may
21431
21647
  delete it; a run that fails leaves it to be looked at, and update --disk-only takes it back.
@@ -21522,7 +21738,10 @@ been away 24 hours: its sandboxes are said lost, and it cannot be undone, so it
21522
21738
  --yes, and --reason says why. servers offload says whether a new sandbox that names no region
21523
21739
  starts on agental's servers when none of yours has room under --over percent of its memory, CPU
21524
21740
  and disk (80 to begin with); on and off turn it on and off. Such a sandbox is a hosted one, billed as
21525
- one, from your credits. servers core-days is the month's cores as they are counted for billing, day by day.
21741
+ one, from your credits. servers window says, and sets, the weekly window in which your servers take
21742
+ a new agent: --day, --hour on the clock of --tz (an IANA zone, as Europe/Berlin) and --hours (4 to
21743
+ begin with); --off has them take one at once. A security release reaches them outside it too.
21744
+ servers core-days is the month's cores as they are counted for billing, day by day.
21526
21745
  org lists the organizations you are in, your own and your teams, and marks the one this command
21527
21746
  acts in. A key acts in the organization it was made in, for good, so org use signs in again in
21528
21747
  the browser for a key made in the one given, by its id or name, and deletes the key the command
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agental",
3
- "version": "0.67.1",
3
+ "version": "0.71.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",