@ghostlytools/cli 1.4.5 → 1.5.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 (89) hide show
  1. package/README.md +14 -7
  2. package/dist/assets/{api-D70he3-A.js → api-Dy_05gaq.js} +93 -62
  3. package/dist/assets/api-Dy_05gaq.js.map +1 -0
  4. package/dist/assets/{api-XX7bbtTZ.js → api-oUpBfryK.js} +2 -2
  5. package/dist/assets/{apiKit-CpsEqF-1.js → apiKit-B-PUYkXH.js} +2 -2
  6. package/dist/assets/{apiKit-CpsEqF-1.js.map → apiKit-B-PUYkXH.js.map} +1 -1
  7. package/dist/assets/{apps-DVMnlwGF.js → apps-C6MBfO-I.js} +1 -1
  8. package/dist/assets/{apps-VA8W_YCQ.js → apps-ejb6H1lT.js} +2 -2
  9. package/dist/assets/{apps-VA8W_YCQ.js.map → apps-ejb6H1lT.js.map} +1 -1
  10. package/dist/assets/{arkade-DxgW4-dK.js → arkade-DXyOeKEI.js} +2 -2
  11. package/dist/assets/{arkade-DxgW4-dK.js.map → arkade-DXyOeKEI.js.map} +1 -1
  12. package/dist/assets/{backup-BRTH1y3-.js → backup-Bt6UjCiM.js} +1 -1
  13. package/dist/assets/{backup-c9xvXgCS.js → backup-DRIIguzE.js} +6 -6
  14. package/dist/assets/{backup-c9xvXgCS.js.map → backup-DRIIguzE.js.map} +1 -1
  15. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
  16. package/dist/assets/{blobFiles-B0rNnHlO.js → blobFiles-1wUBd8ZD.js} +3 -3
  17. package/dist/assets/{blobFiles-B0rNnHlO.js.map → blobFiles-1wUBd8ZD.js.map} +1 -1
  18. package/dist/assets/buttons-B3bi6p_d.js +2 -0
  19. package/dist/assets/{buttons-D31LBftz.js → buttons-DoccJ_cK.js} +3 -3
  20. package/dist/assets/{buttons-D31LBftz.js.map → buttons-DoccJ_cK.js.map} +1 -1
  21. package/dist/assets/daemonProof-CWTVNUmr.js +254 -0
  22. package/dist/assets/daemonProof-CWTVNUmr.js.map +1 -0
  23. package/dist/assets/{envelope-hAl4pblf.js → envelope-hJ0SfbAh.js} +2 -2
  24. package/dist/assets/{envelope-hAl4pblf.js.map → envelope-hJ0SfbAh.js.map} +1 -1
  25. package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
  26. package/dist/assets/{fileBytes-B-fqGdEd.js → fileBytes-B8eTZfAT.js} +3 -3
  27. package/dist/assets/{fileBytes-B-fqGdEd.js.map → fileBytes-B8eTZfAT.js.map} +1 -1
  28. package/dist/assets/{fileBytes-C2jycN_7.js → fileBytes-gTd_8l-P.js} +1 -1
  29. package/dist/assets/{fileBytes-D6fqFQEX.js → fileBytes-uRqLyxa0.js} +2 -2
  30. package/dist/assets/{fileBytes-D6fqFQEX.js.map → fileBytes-uRqLyxa0.js.map} +1 -1
  31. package/dist/assets/{fileBytesIdb-_HnxdacI.js → fileBytesIdb-BIFKtgln.js} +3 -3
  32. package/dist/assets/{fileBytesIdb-_HnxdacI.js.map → fileBytesIdb-BIFKtgln.js.map} +1 -1
  33. package/dist/assets/fileBytesIdb-BVVr_rWX.js +2 -0
  34. package/dist/assets/{fileBytesOpfs-p_CANncD.js → fileBytesOpfs-ChrHcCVV.js} +3 -3
  35. package/dist/assets/{fileBytesOpfs-p_CANncD.js.map → fileBytesOpfs-ChrHcCVV.js.map} +1 -1
  36. package/dist/assets/{groupFiles-gQ8_792r.js → groupFiles-BXPINkVJ.js} +60 -14
  37. package/dist/assets/groupFiles-BXPINkVJ.js.map +1 -0
  38. package/dist/assets/{host-Dmo6m7So.js → host-CzgYwupN.js} +15 -122
  39. package/dist/assets/host-CzgYwupN.js.map +1 -0
  40. package/dist/assets/{hyperdhtRelay-DwkZ8vpt.js → hyperdhtRelay-CJBqsS_e.js} +2 -2
  41. package/dist/assets/{hyperdhtRelay-DwkZ8vpt.js.map → hyperdhtRelay-CJBqsS_e.js.map} +1 -1
  42. package/dist/assets/{idb-CMVgtn2k.js → idb-BJARz3Qi.js} +5 -3
  43. package/dist/assets/idb-BJARz3Qi.js.map +1 -0
  44. package/dist/assets/{irohWeb-DKJhESuV.js → irohWeb-CrGOD-OD.js} +2 -2
  45. package/dist/assets/{irohWeb-DKJhESuV.js.map → irohWeb-CrGOD-OD.js.map} +1 -1
  46. package/dist/assets/{main-DgXvK9Cr.js → main-BDOIJ_ls.js} +240 -53
  47. package/dist/assets/main-BDOIJ_ls.js.map +1 -0
  48. package/dist/assets/{mainline-9j_FqcJe.js → mainline-Cw7rnEWM.js} +2 -2
  49. package/dist/assets/{mainline-9j_FqcJe.js.map → mainline-Cw7rnEWM.js.map} +1 -1
  50. package/dist/assets/{networkReason-Bp8Huk9Z.js → networkReason-C0VY94cG.js} +3 -3
  51. package/dist/assets/{networkReason-Bp8Huk9Z.js.map → networkReason-C0VY94cG.js.map} +1 -1
  52. package/dist/assets/{nwc-DxIjNmYz.js → nwc-lpGWvzYU.js} +3 -3
  53. package/dist/assets/{nwc-DxIjNmYz.js.map → nwc-lpGWvzYU.js.map} +1 -1
  54. package/dist/assets/{nwcProvider-CyGVe35t.js → nwcProvider-CAGRn2ly.js} +2 -2
  55. package/dist/assets/{nwcProvider-CyGVe35t.js.map → nwcProvider-CAGRn2ly.js.map} +1 -1
  56. package/dist/assets/{profiles-ClRPr6y8.js → profiles-BehWURA9.js} +7 -3
  57. package/dist/assets/profiles-BehWURA9.js.map +1 -0
  58. package/dist/assets/{registry-siqMiD8L.js → registry-D2bK-k1T.js} +1 -1
  59. package/dist/assets/{registry-BTIRr7gH.js → registry-DWkkBN57.js} +3 -3
  60. package/dist/assets/registry-DWkkBN57.js.map +1 -0
  61. package/dist/assets/{resolve-CZ4yb7wp.js → resolve-CvYK0Lbt.js} +2 -2
  62. package/dist/assets/{resolve-CZ4yb7wp.js.map → resolve-CvYK0Lbt.js.map} +1 -1
  63. package/dist/assets/{restoredRows-DeBImGRd.js → restoredRows-DGuKtIBz.js} +2 -2
  64. package/dist/assets/{restoredRows-DeBImGRd.js.map → restoredRows-DGuKtIBz.js.map} +1 -1
  65. package/dist/assets/{server-ZrkwMbFo.js → server-BktMmp7L.js} +1141 -310
  66. package/dist/assets/server-BktMmp7L.js.map +1 -0
  67. package/dist/assets/{src-CxEO33Hb.js → src-Bpy99Z2K.js} +828 -57
  68. package/dist/assets/src-Bpy99Z2K.js.map +1 -0
  69. package/dist/assets/{usdt-exH8dIZK.js → usdt-DFusiw8x.js} +3 -3
  70. package/dist/assets/{usdt-exH8dIZK.js.map → usdt-DFusiw8x.js.map} +1 -1
  71. package/dist/assets/{turnRefs-Dndxqyxk.js → words-Z-izzDBN.js} +61 -3
  72. package/dist/assets/words-Z-izzDBN.js.map +1 -0
  73. package/dist/ghostly.mjs +1 -1
  74. package/package.json +1 -1
  75. package/skills/ghostly/scripts/status +3 -2
  76. package/dist/assets/api-D70he3-A.js.map +0 -1
  77. package/dist/assets/buttons-CtGCix-8.js +0 -2
  78. package/dist/assets/daemonProof-B53VnZ1Z.js +0 -100
  79. package/dist/assets/daemonProof-B53VnZ1Z.js.map +0 -1
  80. package/dist/assets/fileBytesIdb-DOxm_BKt.js +0 -2
  81. package/dist/assets/groupFiles-gQ8_792r.js.map +0 -1
  82. package/dist/assets/host-Dmo6m7So.js.map +0 -1
  83. package/dist/assets/idb-CMVgtn2k.js.map +0 -1
  84. package/dist/assets/main-DgXvK9Cr.js.map +0 -1
  85. package/dist/assets/profiles-ClRPr6y8.js.map +0 -1
  86. package/dist/assets/registry-BTIRr7gH.js.map +0 -1
  87. package/dist/assets/server-ZrkwMbFo.js.map +0 -1
  88. package/dist/assets/src-CxEO33Hb.js.map +0 -1
  89. package/dist/assets/turnRefs-Dndxqyxk.js.map +0 -1
@@ -1,9 +1,9 @@
1
- import { Fa as ITEM_STATES, Ia as PR_CHECKS, La as PR_STATES, Ra as RUN_RESULTS, Ua as cardUrl, Un as GROUP_FILE_LIMITS, za as STATUS_CARD_LIMITS } from "./src-CxEO33Hb.js";
2
- import { a as ENGINE_PARAMS, c as SECRET_RESULTS, i as ENGINE_METHODS, o as ENGINE_READS, s as READ_PARAMS, t as turnRef } from "./turnRefs-Dndxqyxk.js";
1
+ import { Ba as CRON_LINE, Ga as RUN_RESULTS, Ha as PR_CHECKS, Ka as STATUS_CARD_LIMITS, Ua as PR_STATES, Un as GROUP_FILE_LIMITS, Va as ITEM_STATES, Wa as ROUTINE_STATES, Xa as cardLine, Za as cardUrl, qa as TASK_STATUSES } from "./src-Bpy99Z2K.js";
2
+ import { a as WALLET_TYPES, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, n as CHAT_METHODS, o as turnRef, p as SECRET_RESULTS, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-Z-izzDBN.js";
3
3
  import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-BLSPp0tK.js";
4
- import { t as CONTACT_KEY } from "./apiKit-CpsEqF-1.js";
5
- import { a as checkShownName, c as ghostlyHome, d as profileExists, f as profilePaths, i as checkProfileName, l as listProfiles, m as userPath, o as createProfile, p as selectProfile, s as currentProfile, u as lockOwner } from "./profiles-ClRPr6y8.js";
6
- import { a as provesDaemon, c as ownSocket, o as readDaemonSecret, r as newNonce, t as HELLO } from "./daemonProof-B53VnZ1Z.js";
4
+ import { t as CONTACT_KEY } from "./apiKit-B-PUYkXH.js";
5
+ import { a as checkShownName, c as ghostlyHome, f as profileExists, h as userPath, i as checkProfileName, l as listProfiles, m as selectProfile, o as createProfile, p as profilePaths, s as currentProfile, u as lockOwner } from "./profiles-BehWURA9.js";
6
+ import { c as readDaemonSecret, g as isCallRate, i as newNonce, o as provesDaemon, s as provesGreeting, t as HELLO, u as CALL_RATES, v as ownSocket } from "./daemonProof-CWTVNUmr.js";
7
7
  import { accessSync, constants, existsSync, openSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
8
8
  import { dirname, resolve } from "node:path";
9
9
  import { spawn } from "node:child_process";
@@ -12,7 +12,7 @@ import { createInterface } from "node:readline";
12
12
  import { format } from "node:util";
13
13
  var package_default = {
14
14
  name: "@ghostlytools/cli",
15
- version: "1.4.5",
15
+ version: "1.5.1",
16
16
  type: "module",
17
17
  description: "Ghostly for bots and terminals: the app's own engine, headless on Node, behind a daemon and a `ghostly` command with JSON output.",
18
18
  license: "MIT",
@@ -177,7 +177,10 @@ function parseArgs(argv, spec, idSlot = () => false) {
177
177
  if (!Number.isFinite(number)) throw new CliError("usage", `--${name} takes a number, not ${JSON.stringify(value)}`);
178
178
  options[name] = number;
179
179
  } else if (option.type === "list") options[name] = [...options[name] ?? [], value];
180
- else options[name] = value;
180
+ else {
181
+ if (option.choices && !option.choices.includes(value)) throw new CliError("usage", `--${name} takes ${listed$1(option.choices)}, not ${JSON.stringify(value)}`);
182
+ options[name] = value;
183
+ }
181
184
  continue;
182
185
  }
183
186
  if (arg.startsWith("-") && arg !== "-") throw new CliError("usage", `Unknown option ${arg} (put -- before text that starts with a dash)`);
@@ -188,6 +191,8 @@ function parseArgs(argv, spec, idSlot = () => false) {
188
191
  options
189
192
  };
190
193
  }
194
+ /** Words as a sentence lists them: "a", "a or b", "a, b or c". */
195
+ var listed$1 = (words) => words.length > 1 ? `${words.slice(0, -1).join(", ")} or ${words.at(-1)}` : words[0];
191
196
  /** The global option a word names (`--profile`, `--profile=bot`, `-p`), else undefined. */
192
197
  function globalOption(arg) {
193
198
  const name = globalName(arg);
@@ -233,6 +238,11 @@ function liftGlobals(argv) {
233
238
  //#region src/client.ts
234
239
  /** The id of the hello on every connection: a string, so it is never one of the calls' numbers. */
235
240
  var HELLO_ID = "hello";
241
+ /**
242
+ * How long a client waits for the daemon's greeting before it refuses what answers: a daemon greets as it accepts the
243
+ * connection, and one of an older release (before the greeting) never does. `daemon stop` waits less (`connectDaemon`).
244
+ */
245
+ var GREETING_MS = 1e4;
236
246
  /** The refusal of a listener that did not prove it is the profile's daemon (`isNotTheDaemon` tells it apart). */
237
247
  function notTheDaemon(socket) {
238
248
  return new CliError("refused", `What answers on ${socket} did not prove it is this profile's daemon, so nothing was sent to it. A daemon of an older release cannot: \`ghostly daemon restart\` starts this one's`, { reason: "not-the-daemon" });
@@ -244,10 +254,12 @@ function isNotTheDaemon(error) {
244
254
  * A connection to a profile's daemon over its socket (WISP 1100 § Local control API). `null` from `connectDaemon`
245
255
  * means no daemon answers there: a one-shot command runs the profile itself.
246
256
  *
247
- * The first line on it is a `daemon.hello`, and no call is written until its answer proves the other end read the
248
- * profile's daemon secret (`daemonProof.ts`): until then every call waits, under its own deadline, and a listener
249
- * that does not prove it gets every call refused (`refused`, `isNotTheDaemon`) having read nothing but the hello.
250
- * Nothing it writes before that is read either.
257
+ * The client writes nothing on it until the daemon's greeting, its first line, proves the other end read the
258
+ * profile's daemon secret and holds the profile's lock (`provesGreeting`): a listener that cannot prove it has read
259
+ * nothing from this client, so it cannot impersonate it either (`daemonProof.ts`). Then the first line written is a
260
+ * `daemon.hello`, and no call is written until its answer proves the same over the client's own nonce. Until then
261
+ * every call waits, under its own deadline, and a listener that does not prove both gets every call refused
262
+ * (`refused`, `isNotTheDaemon`). Nothing it writes before that is read either.
251
263
  */
252
264
  var DaemonClient = class {
253
265
  socket;
@@ -258,11 +270,12 @@ var DaemonClient = class {
258
270
  closedListener = null;
259
271
  /** While paused: the events of the chunk already read, given to the listener on resume. */
260
272
  held = null;
273
+ greeted = false;
261
274
  verified = false;
262
275
  refusal = null;
263
276
  ready;
264
277
  settle;
265
- constructor(socket, address) {
278
+ constructor(socket, address, greetingMs = GREETING_MS) {
266
279
  this.socket = socket;
267
280
  this.address = address;
268
281
  this.ready = new Promise((resolve, reject) => {
@@ -273,6 +286,10 @@ var DaemonClient = class {
273
286
  });
274
287
  this.ready.catch(() => {});
275
288
  const nonce = newNonce();
289
+ const waitedTooLong = setTimeout(() => {
290
+ if (!this.greeted && !this.refusal) this.refuse();
291
+ }, greetingMs);
292
+ waitedTooLong.unref?.();
276
293
  const lines = createInterface({
277
294
  input: socket,
278
295
  crlfDelay: Infinity
@@ -285,8 +302,25 @@ var DaemonClient = class {
285
302
  } catch {
286
303
  return;
287
304
  }
305
+ if (this.refusal) return;
306
+ if (!this.greeted) {
307
+ clearTimeout(waitedTooLong);
308
+ const secret = readDaemonSecret(this.address.dir);
309
+ if (!secret || !provesGreeting(secret, this.address.dir, message)) {
310
+ this.refuse();
311
+ return;
312
+ }
313
+ this.greeted = true;
314
+ if (socket.writableEnded || socket.destroyed) return;
315
+ socket.write(JSON.stringify({
316
+ id: HELLO_ID,
317
+ method: HELLO,
318
+ params: { nonce }
319
+ }) + "\n");
320
+ return;
321
+ }
288
322
  if (!this.verified) {
289
- if (this.refusal || message?.id !== HELLO_ID) return;
323
+ if (message?.id !== HELLO_ID) return;
290
324
  const secret = readDaemonSecret(this.address.dir);
291
325
  if (!message.error && secret && provesDaemon(secret, nonce, message.result)) {
292
326
  this.verified = true;
@@ -308,6 +342,7 @@ var DaemonClient = class {
308
342
  else waiting.resolve(message.result);
309
343
  });
310
344
  socket.on("close", () => {
345
+ clearTimeout(waitedTooLong);
311
346
  const why = this.refusal ?? new CliError("unavailable", "The daemon went away");
312
347
  if (!this.verified) this.settle.reject(why);
313
348
  for (const waiting of this.pending.values()) waiting.reject(why);
@@ -315,11 +350,6 @@ var DaemonClient = class {
315
350
  this.closedListener?.();
316
351
  });
317
352
  socket.on("error", () => {});
318
- socket.write(JSON.stringify({
319
- id: HELLO_ID,
320
- method: HELLO,
321
- params: { nonce }
322
- }) + "\n");
323
353
  }
324
354
  refuse() {
325
355
  this.refusal = notTheDaemon(this.address.socket);
@@ -404,10 +434,10 @@ var DaemonClient = class {
404
434
  }
405
435
  };
406
436
  /**
407
- * `timeoutMs` bounds the connect only. The client it gives has sent its hello; whether the listener is the daemon is
408
- * known at the first call (above).
437
+ * `timeoutMs` bounds the connect only; `greetingMs`, the wait for the daemon's greeting (above). The client it gives
438
+ * has written nothing yet; whether the listener is the daemon is known at the first call.
409
439
  */
410
- function connectDaemon(address, timeoutMs = 2e3) {
440
+ function connectDaemon(address, timeoutMs = 2e3, { greetingMs = GREETING_MS } = {}) {
411
441
  const path = address.socket;
412
442
  if (!ownSocket(path)) return Promise.resolve(null);
413
443
  return new Promise((resolve) => {
@@ -418,7 +448,7 @@ function connectDaemon(address, timeoutMs = 2e3) {
418
448
  }, timeoutMs);
419
449
  socket.once("connect", () => {
420
450
  clearTimeout(timer);
421
- resolve(new DaemonClient(socket, address));
451
+ resolve(new DaemonClient(socket, address, greetingMs));
422
452
  });
423
453
  socket.once("error", () => {
424
454
  clearTimeout(timer);
@@ -431,6 +461,11 @@ function connectDaemon(address, timeoutMs = 2e3) {
431
461
  var wait = {
432
462
  wait: {
433
463
  type: "string",
464
+ choices: [
465
+ "none",
466
+ "sent",
467
+ "delivered"
468
+ ],
434
469
  description: "none, sent or delivered (default: none with a daemon, sent without)"
435
470
  },
436
471
  timeout: {
@@ -442,6 +477,7 @@ var wait = {
442
477
  var groupWait = {
443
478
  wait: {
444
479
  type: "string",
480
+ choices: ["none", "sent"],
445
481
  description: "none or sent: until an edge took it (default none)"
446
482
  },
447
483
  timeout: {
@@ -451,6 +487,7 @@ var groupWait = {
451
487
  };
452
488
  var net = {
453
489
  type: "string",
490
+ choices: ["mainnet", "testnet"],
454
491
  description: "mainnet or testnet (default testnet)"
455
492
  };
456
493
  var card = {
@@ -614,16 +651,40 @@ var cardOptions = {
614
651
  /** `--link label=https://…` or a bare link, as a card's links. */
615
652
  function cardLinks(values) {
616
653
  if (!Array.isArray(values) || !values.length) return void 0;
654
+ given("link", values, STATUS_CARD_LIMITS.links);
617
655
  return values.map((value) => {
618
656
  const eq = value.indexOf("=");
619
- return eq > 0 && !value.slice(0, eq).includes(":") ? {
657
+ const link = eq > 0 && !value.slice(0, eq).includes(":") ? {
620
658
  label: value.slice(0, eq),
621
659
  url: value.slice(eq + 1)
622
660
  } : { url: value };
661
+ if (!cardUrl(link.url)) throw new CliError("usage", `--link takes an https link of at most ${STATUS_CARD_LIMITS.url} characters, or label=link, not ${JSON.stringify(value)}`);
662
+ cardText("--link's label", link.label, STATUS_CARD_LIMITS.linkLabel, value);
663
+ return link;
623
664
  });
624
665
  }
625
666
  var listed = (words) => `${words.slice(0, -1).join(", ")} or ${words.at(-1)}`;
626
667
  /**
668
+ * A text flag as the card counts it (one line, the display rules): blank, or longer than `max`, is a usage error (exit 2)
669
+ * that names the flag. Before, it reached the card's own check and failed as `bad_request` (exit 1) in the card's words
670
+ * ("Status card: title is at most 120 characters"), the whole card in its details. `shown` is what the flag was given.
671
+ */
672
+ function cardText(flag, value, max, shown = value) {
673
+ if (value === void 0) return;
674
+ const line = cardLine(String(value), Infinity);
675
+ if (!line) throw new CliError("usage", `${flag} takes text, not ${JSON.stringify(shown)}`);
676
+ const length = [...line].length;
677
+ if (length > max) throw new CliError("usage", `${flag} takes at most ${max} characters, not ${length}`);
678
+ }
679
+ /** `--status`, `--state`, `--pr-state`, `--pr-checks`: one of their words, or a usage error that lists them. */
680
+ function oneWord(options, flag, words) {
681
+ if (options[flag] !== void 0 && !words.includes(options[flag])) throw new CliError("usage", `--${flag} takes ${listed(words)}, not ${JSON.stringify(options[flag])}`);
682
+ }
683
+ /** A flag given more times than the card holds: a usage error that says how many it takes. */
684
+ function given(flag, values, max) {
685
+ if (Array.isArray(values) && values.length > max) throw new CliError("usage", `--${flag} is given at most ${max} times, not ${values.length}`);
686
+ }
687
+ /**
627
688
  * `--item state:text` as a task's item. The word before the first colon is the state when it is one lowercase word (and
628
689
  * the colon does not start `://`): one of `ITEM_STATES`, or a usage error that lists them, so `queued:Publishing` is
629
690
  * refused rather than shown as that text. Anything else (`Step 2: build`, `Note: x`, a link, no colon) is the whole
@@ -632,14 +693,19 @@ var listed = (words) => `${words.slice(0, -1).join(", ")} or ${words.at(-1)}`;
632
693
  function itemOf(value) {
633
694
  const colon = value.indexOf(":");
634
695
  const word = colon > 0 ? value.slice(0, colon) : "";
635
- if (!/^[a-z]+$/.test(word) || value.startsWith("//", colon + 1)) return {
636
- state: "pending",
637
- text: value
638
- };
696
+ if (!/^[a-z]+$/.test(word) || value.startsWith("//", colon + 1)) {
697
+ cardText("--item's text", value, STATUS_CARD_LIMITS.line);
698
+ return {
699
+ state: "pending",
700
+ text: value
701
+ };
702
+ }
639
703
  if (!ITEM_STATES.includes(word)) throw new CliError("usage", `--item takes state:text, and ${JSON.stringify(word)} is not a state: use ${listed(ITEM_STATES)} (pending:<text> keeps a colon in the text), not ${JSON.stringify(value)}`);
704
+ const text = value.slice(colon + 1).trim();
705
+ cardText("--item's text", text, STATUS_CARD_LIMITS.line, value);
640
706
  return {
641
707
  state: word,
642
- text: value.slice(colon + 1).trim()
708
+ text
643
709
  };
644
710
  }
645
711
  /** `--progress`, `--left`: a percent, or a usage error that names the flag. */
@@ -667,6 +733,14 @@ function taskFields(options) {
667
733
  const set = (key, value) => {
668
734
  if (value !== void 0) fields[key] = value;
669
735
  };
736
+ cardText("--title", options.title, STATUS_CARD_LIMITS.title);
737
+ cardText("--step", options.step, STATUS_CARD_LIMITS.line);
738
+ cardText("--branch", options.branch, STATUS_CARD_LIMITS.branch);
739
+ for (const [flag, words] of [
740
+ ["status", TASK_STATUSES],
741
+ ["pr-state", PR_STATES],
742
+ ["pr-checks", PR_CHECKS]
743
+ ]) oneWord(options, flag, words);
670
744
  set("id", options.id);
671
745
  set("title", options.title);
672
746
  set("status", options.status);
@@ -683,16 +757,25 @@ function taskFields(options) {
683
757
  if (Number(match[2]) < 1 || Number(match[1]) > Number(match[2])) throw new CliError("usage", `--steps takes done/total with done at most total, like 2/5, not ${JSON.stringify(options.steps)}`);
684
758
  }
685
759
  if (options["pr-url"] !== void 0 && !cardUrl(options["pr-url"])) throw new CliError("usage", `--pr-url takes an https link of at most ${STATUS_CARD_LIMITS.url} characters, not ${JSON.stringify(options["pr-url"])}`);
686
- for (const [flag, words] of [["pr-state", PR_STATES], ["pr-checks", PR_CHECKS]]) if (options[flag] !== void 0 && !words.includes(options[flag])) throw new CliError("usage", `--${flag} takes ${listed(words)}, not ${JSON.stringify(options[flag])}`);
687
760
  const pr = {};
688
761
  for (const [flag, key] of PR_FLAGS) if (options[flag] !== void 0) pr[key] = options[flag];
689
762
  if (Object.keys(pr).length) fields.pr = {
690
763
  ...fields.pr && typeof fields.pr === "object" ? fields.pr : {},
691
764
  ...pr
692
765
  };
766
+ given("item", options.item, STATUS_CARD_LIMITS.items);
693
767
  if (Array.isArray(options.item) && options.item.length) fields.items = options.item.map(itemOf);
694
- if (Array.isArray(options.tag) && options.tag.length > STATUS_CARD_LIMITS.tags) throw new CliError("usage", `--tag is given at most ${STATUS_CARD_LIMITS.tags} times, not ${options.tag.length}`);
695
- if (Array.isArray(options.tag) && options.tag.length) fields.tags = options.tag;
768
+ given("tag", options.tag, STATUS_CARD_LIMITS.tags);
769
+ if (Array.isArray(options.tag) && options.tag.length) {
770
+ const seen = /* @__PURE__ */ new Set();
771
+ for (const tag of options.tag) {
772
+ cardText("--tag", tag, STATUS_CARD_LIMITS.tag);
773
+ const clean = cardLine(tag, Infinity);
774
+ if (seen.has(clean)) throw new CliError("usage", `--tag ${JSON.stringify(clean)} is given twice`);
775
+ seen.add(clean);
776
+ }
777
+ fields.tags = options.tag;
778
+ }
696
779
  set("parent", options.parent);
697
780
  const links = cardLinks(options.link);
698
781
  if (links) fields.links = links;
@@ -741,6 +824,7 @@ function runOf(value) {
741
824
  const text = String(value), colon = text.indexOf(":");
742
825
  const result = colon === -1 ? text : text.slice(0, colon), summary = colon === -1 ? "" : text.slice(colon + 1).trim();
743
826
  if (!RUN_RESULTS.includes(result)) throw new CliError("usage", `--run takes ok, failed or skipped, and :a summary after it if you like, not ${JSON.stringify(value)}`);
827
+ if (summary) cardText("--run's summary", summary, STATUS_CARD_LIMITS.line);
744
828
  return {
745
829
  result,
746
830
  ...summary && { summary }
@@ -749,6 +833,13 @@ function runOf(value) {
749
833
  /** A routine's fields from its flags; what was not given is left out. */
750
834
  function routineFields(options) {
751
835
  const fields = { ...cardJson(options.json) };
836
+ cardText("--name", options.name, STATUS_CARD_LIMITS.title);
837
+ cardText("--schedule", options.schedule, STATUS_CARD_LIMITS.schedule);
838
+ if (options.cron !== void 0 && !CRON_LINE.test(String(options.cron).trim())) {
839
+ const length = [...String(options.cron).trim()].length;
840
+ throw new CliError("usage", length > STATUS_CARD_LIMITS.cron ? `--cron takes at most ${STATUS_CARD_LIMITS.cron} characters, not ${length}` : `--cron takes a cron line of 0-9 A-Z a-z * , / ? # - and spaces, not ${JSON.stringify(options.cron)}`);
841
+ }
842
+ oneWord(options, "state", ROUTINE_STATES);
752
843
  for (const key of [
753
844
  "id",
754
845
  "name",
@@ -865,6 +956,8 @@ var taskOptions = {
865
956
  function usageWindowOf(value) {
866
957
  const match = /^([^=]+)=(\d+(?:\.\d+)?)(?:@(.+))?$/.exec(value.trim());
867
958
  if (!match) throw new CliError("usage", `--also takes window=percent or window=percent@time, like week=80@2026-10-10T00:00:00Z, not ${JSON.stringify(value)}`);
959
+ cardText("--also's window", match[1], STATUS_CARD_LIMITS.usageWindow, value);
960
+ if (Number(match[2]) > 100) throw new CliError("usage", `--also takes a percent from 0 to 100, not ${match[2]}`);
868
961
  const resetsAt = cardTime(match[3], "also");
869
962
  return {
870
963
  window: match[1].trim(),
@@ -877,6 +970,12 @@ function usageFields(options) {
877
970
  const fields = { ...cardJson(options.json) };
878
971
  percent(options, "left");
879
972
  if (options.left !== void 0 && (options.used !== void 0 || options.limit !== void 0)) throw new CliError("usage", "--left or --used with --limit, not both");
973
+ for (const [flag, max] of [
974
+ ["label", STATUS_CARD_LIMITS.usageLabel],
975
+ ["account", STATUS_CARD_LIMITS.usageLabel],
976
+ ["window", STATUS_CARD_LIMITS.usageWindow]
977
+ ]) cardText(`--${flag}`, options[flag], max);
978
+ given("also", options.also, STATUS_CARD_LIMITS.usageWindows);
880
979
  for (const key of [
881
980
  "id",
882
981
  "left",
@@ -993,7 +1092,7 @@ var commands$8 = {
993
1092
  description: "Replace the three files when they are there"
994
1093
  }
995
1094
  },
996
- run: async ({ options }, a) => (await import("./apps-DVMnlwGF.js")).initApp(a.dir, {
1095
+ run: async ({ options }, a) => (await import("./apps-C6MBfO-I.js")).initApp(a.dir, {
997
1096
  name: options.name,
998
1097
  title: options.title,
999
1098
  force: options.force === true
@@ -1033,7 +1132,7 @@ var commands$8 = {
1033
1132
  description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
1034
1133
  }
1035
1134
  },
1036
- run: async ({ options }, a) => (await import("./apps-DVMnlwGF.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1135
+ run: async ({ options }, a) => (await import("./apps-C6MBfO-I.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1037
1136
  },
1038
1137
  "app revoke": {
1039
1138
  method: "app.revoke",
@@ -1066,7 +1165,7 @@ var commands$8 = {
1066
1165
  description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere)"
1067
1166
  }
1068
1167
  },
1069
- run: async ({ options }, a) => (await import("./apps-DVMnlwGF.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>]"), {
1168
+ run: async ({ options }, a) => (await import("./apps-C6MBfO-I.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>]"), {
1070
1169
  digests: options.digest,
1071
1170
  upTo: options["up-to"],
1072
1171
  reason: options.reason,
@@ -1127,7 +1226,7 @@ var commands$8 = {
1127
1226
  usage: "app verify <bundle|url>",
1128
1227
  summary: "Check a .ghostlyapp as a client would, from a file or an https URL: its manifest and digest, or refused (exit 1) with the reason, revoked when the ghostly-revoke.json beside it revokes this version",
1129
1228
  args: ["bundle"],
1130
- run: async (_, a) => (await import("./apps-DVMnlwGF.js")).verifyApp(a.bundle)
1229
+ run: async (_, a) => (await import("./apps-C6MBfO-I.js")).verifyApp(a.bundle)
1131
1230
  },
1132
1231
  "store sign": {
1133
1232
  method: "store.sign",
@@ -1144,11 +1243,20 @@ var commands$8 = {
1144
1243
  description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
1145
1244
  }
1146
1245
  },
1147
- run: async ({ options }, a) => (await import("./apps-DVMnlwGF.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1246
+ run: async ({ options }, a) => (await import("./apps-C6MBfO-I.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1148
1247
  }
1149
1248
  };
1150
1249
  //#endregion
1151
1250
  //#region src/commands/calls.ts
1251
+ /**
1252
+ * `--rate`: one of the rates a call takes, or a usage error (exit 2) that names the flag before the profile opens.
1253
+ * Before, the API's own check answered it ("rate must be …", exit 1), and `call answer` only once a call rang.
1254
+ */
1255
+ function rateOf(options) {
1256
+ const value = options.rate;
1257
+ if (value !== void 0 && !isCallRate(value)) throw new CliError("usage", `--rate takes ${CALL_RATES.slice(0, -1).join(", ")} or ${CALL_RATES.at(-1)}, not ${JSON.stringify(value)}`);
1258
+ return value;
1259
+ }
1152
1260
  /** Voice calls: one entry per command, in alphabetical order (test/commands.test.ts checks). */
1153
1261
  var commands$7 = {
1154
1262
  "call answer": {
@@ -1159,7 +1267,7 @@ var commands$7 = {
1159
1267
  options: { rate },
1160
1268
  params: ({ options }, a) => ({
1161
1269
  call: a.call,
1162
- rate: options.rate
1270
+ rate: rateOf(options)
1163
1271
  })
1164
1272
  },
1165
1273
  "call auto": {
@@ -1182,7 +1290,7 @@ var commands$7 = {
1182
1290
  return a.mode === "on" ? {
1183
1291
  on: true,
1184
1292
  from: options.from,
1185
- rate: options.rate
1293
+ rate: rateOf(options)
1186
1294
  } : { on: false };
1187
1295
  }
1188
1296
  },
@@ -1213,7 +1321,7 @@ var commands$7 = {
1213
1321
  options: { rate },
1214
1322
  params: ({ options }, a) => ({
1215
1323
  chat: a.chat,
1216
- rate: options.rate
1324
+ rate: rateOf(options)
1217
1325
  })
1218
1326
  }
1219
1327
  };
@@ -1234,6 +1342,11 @@ var commands$6 = {
1234
1342
  options: {
1235
1343
  wait: {
1236
1344
  type: "string",
1345
+ choices: [
1346
+ "none",
1347
+ "sent",
1348
+ "delivered"
1349
+ ],
1237
1350
  description: "none, sent (a one-shot's default in a chat) or delivered; a group takes none or sent"
1238
1351
  },
1239
1352
  timeout: groupWait.timeout
@@ -1267,6 +1380,11 @@ var commands$6 = {
1267
1380
  force,
1268
1381
  wait: {
1269
1382
  type: "string",
1383
+ choices: [
1384
+ "none",
1385
+ "confirmed",
1386
+ "sent"
1387
+ ],
1270
1388
  description: "none (default), confirmed (a chat's contact took it) or sent (a group's edge took it)"
1271
1389
  },
1272
1390
  timeout: groupWait.timeout
@@ -1379,6 +1497,7 @@ var commands$6 = {
1379
1497
  usage: "chat transport <chat> <auto|dht|webrtc|iroh|hyperdht>",
1380
1498
  summary: "Choose what carries a chat",
1381
1499
  args: ["chat", "transport"],
1500
+ words: { transport: Object.keys(TRANSPORT_NAMES) },
1382
1501
  params: (_, a) => ({
1383
1502
  chat: a.chat,
1384
1503
  transport: a.transport
@@ -1409,6 +1528,11 @@ var commands$6 = {
1409
1528
  options: {
1410
1529
  until: {
1411
1530
  type: "string",
1531
+ choices: [
1532
+ "live",
1533
+ "text",
1534
+ "paired"
1535
+ ],
1412
1536
  description: "live (default), text or paired"
1413
1537
  },
1414
1538
  timeout: {
@@ -1438,6 +1562,7 @@ var commands$6 = {
1438
1562
  },
1439
1563
  wait: {
1440
1564
  type: "string",
1565
+ choices: ["none", "sent"],
1441
1566
  description: "none or sent: each text on its way (in a group, taken by an edge), each file's transfer done (default none)"
1442
1567
  },
1443
1568
  timeout: groupWait.timeout
@@ -1481,12 +1606,17 @@ var commands$6 = {
1481
1606
  },
1482
1607
  "message delete": {
1483
1608
  method: "chat.delete",
1484
- usage: "message delete <chat> <message>",
1485
- summary: "Forget a message on this device (the contact keeps theirs)",
1609
+ usage: "message delete <chat|group> <message> [--everyone]",
1610
+ summary: "Forget a message on this device (the contact keeps theirs); --everyone deletes one of yours, in a chat or a group, from every member's device",
1486
1611
  args: ["chat", "message"],
1487
- params: (_, a) => ({
1612
+ options: { everyone: {
1613
+ type: "boolean",
1614
+ description: "Delete a message of yours for everyone (a chat or a group)"
1615
+ } },
1616
+ params: ({ options }, a) => ({
1488
1617
  chat: a.chat,
1489
- message: a.message
1618
+ message: a.message,
1619
+ everyone: options.everyone === true
1490
1620
  })
1491
1621
  },
1492
1622
  "message details": {
@@ -1581,6 +1711,11 @@ var commands$6 = {
1581
1711
  ...routineOptions,
1582
1712
  wait: {
1583
1713
  type: "string",
1714
+ choices: [
1715
+ "none",
1716
+ "confirmed",
1717
+ "sent"
1718
+ ],
1584
1719
  description: "none (default), confirmed (a chat's contact took it) or sent (a group's edge took it)"
1585
1720
  },
1586
1721
  timeout: groupWait.timeout
@@ -1596,6 +1731,31 @@ var commands$6 = {
1596
1731
  timeout: options.timeout
1597
1732
  })
1598
1733
  },
1734
+ "saved add": {
1735
+ method: "saved.add",
1736
+ usage: "saved add <chat|group> <message>",
1737
+ summary: "Save a message on this device, to find it again in `saved list` (nothing is sent)",
1738
+ args: ["chat", "message"],
1739
+ params: (_, a) => ({
1740
+ chat: a.chat,
1741
+ message: a.message
1742
+ })
1743
+ },
1744
+ "saved list": {
1745
+ method: "saved.list",
1746
+ usage: "saved list",
1747
+ summary: "Saved messages of every chat and group, the last saved first"
1748
+ },
1749
+ "saved remove": {
1750
+ method: "saved.remove",
1751
+ usage: "saved remove <chat|group> <message>",
1752
+ summary: "Unsave a message",
1753
+ args: ["chat", "message"],
1754
+ params: (_, a) => ({
1755
+ chat: a.chat,
1756
+ message: a.message
1757
+ })
1758
+ },
1599
1759
  "task send": {
1600
1760
  method: "task.send",
1601
1761
  usage: "task send <chat|group> --title <title> [--status s] [--progress n | --steps a/b] [--step \"...\"] [--item state:text]... [--pr-url url --pr-number n --additions n --deletions n --files n --pr-state s --pr-checks c] [--branch b] [--tag label]... [--parent task] [--link url]... [--id id] [--json json|-|file] [--force] [--wait none|sent|delivered] [--timeout s]",
@@ -1628,6 +1788,11 @@ var commands$6 = {
1628
1788
  ...taskOptions,
1629
1789
  wait: {
1630
1790
  type: "string",
1791
+ choices: [
1792
+ "none",
1793
+ "confirmed",
1794
+ "sent"
1795
+ ],
1631
1796
  description: "none (default), confirmed (a chat's contact took it) or sent (a group's edge took it)"
1632
1797
  },
1633
1798
  timeout: groupWait.timeout
@@ -2351,6 +2516,7 @@ var commands$1 = {
2351
2516
  usage: "chat accept <chat> <method> [--off] [--networks mainnet,testnet]",
2352
2517
  summary: "Which ways of paying a chat takes",
2353
2518
  args: ["chat", "method"],
2519
+ words: { method: CHAT_METHODS },
2354
2520
  options: {
2355
2521
  off: {
2356
2522
  type: "boolean",
@@ -2396,6 +2562,7 @@ var commands$1 = {
2396
2562
  options: {
2397
2563
  via: {
2398
2564
  type: "string",
2565
+ choices: ["lightning"],
2399
2566
  description: "lightning: pay its invoice instead of ecash"
2400
2567
  },
2401
2568
  "max-fee": {
@@ -2427,6 +2594,7 @@ var commands$1 = {
2427
2594
  },
2428
2595
  rail: {
2429
2596
  type: "string",
2597
+ choices: ["cashu", "lightning"],
2430
2598
  description: "cashu or lightning"
2431
2599
  },
2432
2600
  network: net,
@@ -2545,6 +2713,7 @@ var commands$1 = {
2545
2713
  usage: "wallet address <bitcoin|arkade|spark|usdt> [--network testnet]",
2546
2714
  summary: "An address to be paid on",
2547
2715
  args: ["type"],
2716
+ words: { type: ADDRESS_TYPES },
2548
2717
  options: { network: net },
2549
2718
  params: ({ options }, { type }) => ({
2550
2719
  type,
@@ -2556,6 +2725,7 @@ var commands$1 = {
2556
2725
  usage: "wallet create <type> [--network testnet] [--provider <id>] [--value name=value]... [--stdin] [--invite <code>] [--api-key <key>]",
2557
2726
  summary: "A wallet: cashu, lightning, arkade, spark, bitcoin, fedimint, usdt (bark: app only)",
2558
2727
  args: ["type"],
2728
+ words: { type: WALLET_TYPES },
2559
2729
  options: {
2560
2730
  network: net,
2561
2731
  provider: {
@@ -2594,6 +2764,7 @@ var commands$1 = {
2594
2764
  usage: "wallet faucet <type> [--card <id>]",
2595
2765
  summary: "Test coins from a Testnet wallet's faucet",
2596
2766
  args: ["type"],
2767
+ words: { type: WALLET_TYPES },
2597
2768
  options: { card },
2598
2769
  params: ({ options }, { type }) => ({
2599
2770
  type,
@@ -2651,6 +2822,7 @@ var commands$1 = {
2651
2822
  usage: "wallet remove <type> [--network testnet] [--card <id>] [--accept-loss]",
2652
2823
  summary: "Remove a wallet; refused while it holds money or waits for some, unless --accept-loss",
2653
2824
  args: ["type"],
2825
+ words: { type: WALLET_TYPES },
2654
2826
  options: {
2655
2827
  network: net,
2656
2828
  card,
@@ -2815,6 +2987,7 @@ var TEXT_COMMANDS = {
2815
2987
  force,
2816
2988
  wait: {
2817
2989
  type: "string",
2990
+ choices: ["none", "confirmed"],
2818
2991
  description: "none or confirmed (default: none with a daemon, confirmed without)"
2819
2992
  },
2820
2993
  timeout: wait.timeout
@@ -2924,6 +3097,7 @@ function usageNames(usage) {
2924
3097
  * unset variable in a script), before the profile opens. A leading `name?` is optional: it is given only when every
2925
3098
  * required one is there too (`file accept [<chat>] <file>`). A trailing `name...` takes the rest and needs at least
2926
3099
  * one word that is not ""; `name...?` may take none (text from stdin, `chat rename`'s name back to the contact's).
3100
+ * One that takes a few words (`words`) is refused any other the same way, named as the usage shows it (`<type>`).
2927
3101
  */
2928
3102
  function positionals(command, values) {
2929
3103
  let names = command.args ?? [];
@@ -2945,6 +3119,11 @@ function positionals(command, values) {
2945
3119
  return out;
2946
3120
  }
2947
3121
  if (values[i] === void 0 || values[i] === "") throw missing(i, name);
3122
+ const words = command.words?.[name];
3123
+ if (words && !words.includes(values[i])) {
3124
+ const placeholder = shown[i + skip] && !shown[i + skip].includes("|") ? shown[i + skip] : name;
3125
+ throw new CliError("usage", `<${placeholder}> takes ${listed(words)}, not ${JSON.stringify(values[i])}`);
3126
+ }
2948
3127
  out[name] = values[i];
2949
3128
  }
2950
3129
  noMoreThan(names.length, values, command.usage);
@@ -3524,8 +3703,8 @@ var VERSION = package_default.version;
3524
3703
  * command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
3525
3704
  * cost every command ~100 ms before its socket was opened.
3526
3705
  */
3527
- var engineApi = () => import("./api-XX7bbtTZ.js");
3528
- var engineHost = () => import("./host-Dmo6m7So.js");
3706
+ var engineApi = () => import("./api-oUpBfryK.js");
3707
+ var engineHost = () => import("./host-CzgYwupN.js");
3529
3708
  var pretty = false;
3530
3709
  function print(value) {
3531
3710
  process.stdout.write(JSON.stringify(value, null, pretty ? 2 : void 0) + "\n");
@@ -3617,7 +3796,8 @@ var READS = /* @__PURE__ */ new Set([
3617
3796
  "service.peer",
3618
3797
  "call.list",
3619
3798
  "app.served",
3620
- "x401.credential.list"
3799
+ "x401.credential.list",
3800
+ "saved.list"
3621
3801
  ]);
3622
3802
  /** Whether a one-shot for this call opens the profile offline; test/readOnlyCommands.test.ts names every table command. */
3623
3803
  function readOnly(method, params) {
@@ -3627,7 +3807,7 @@ function readOnly(method, params) {
3627
3807
  }
3628
3808
  /**
3629
3809
  * Calls whose change stays on this device: a chat's name here, a chat removed (nothing goes to the contact), auto-answer
3630
- * (calls.json), a proof dropped, a web app added (shared with no one yet), an x401 key or credential (WISP 3xx: never
3810
+ * (calls.json), a proof dropped, a web app added (shared with no one yet), a message saved or unsaved, an x401 key or credential (WISP 3xx: never
3631
3811
  * shared with a contact). Opened online, each put the profile's records on the relays and waited for them (6 PUT + 4
3632
3812
  * GET, 3.3 s with a relay that takes 1.5 s), and the contacts' apps saw this device come online. `message delete` stays
3633
3813
  * online: it settles a file offer already on the DHT.
@@ -3640,7 +3820,9 @@ var LOCAL_WRITES = /* @__PURE__ */ new Set([
3640
3820
  "service.add",
3641
3821
  "x401.key.new",
3642
3822
  "x401.credential.add",
3643
- "x401.credential.remove"
3823
+ "x401.credential.remove",
3824
+ "saved.add",
3825
+ "saved.remove"
3644
3826
  ]);
3645
3827
  /** Settings of this device only: no contact and no relay hears of them (nick, avatar and the relays' do). */
3646
3828
  var LOCAL_SETTINGS = /* @__PURE__ */ new Set([
@@ -4100,7 +4282,7 @@ async function profileCommand(sub, argv) {
4100
4282
  if (!given || !name) throw new CliError("usage", "ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]");
4101
4283
  noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
4102
4284
  const file = here(given);
4103
- const { backupFileProtection, restoreProfile } = await import("./backup-BRTH1y3-.js");
4285
+ const { backupFileProtection, restoreProfile } = await import("./backup-Bt6UjCiM.js");
4104
4286
  const protection = await backupFileProtection(file);
4105
4287
  const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
4106
4288
  if (parsed.options.use) selectProfile(g.home, name);
@@ -4192,6 +4374,11 @@ async function runDaemon(g) {
4192
4374
  lastSeq: host.ctx.hub.lastSeq
4193
4375
  });
4194
4376
  }
4377
+ /**
4378
+ * `daemon stop` and `restart` wait this long for the daemon's greeting: a daemon of an older release never greets, and
4379
+ * what does not prove itself is stopped as the process that holds the profile (`stopDaemon`), as the stop asked.
4380
+ */
4381
+ var STOP_GREETING_MS = 2e3;
4195
4382
  async function daemonCommand(argv) {
4196
4383
  const sub = argv[0] && !argv[0].startsWith("-") ? argv[0] : void 0;
4197
4384
  const parsed = parseArgs(sub ? argv.slice(1) : argv, {
@@ -4236,7 +4423,7 @@ async function daemonCommand(argv) {
4236
4423
  if (sub === "stop") {
4237
4424
  knownProfile(g);
4238
4425
  const stopFor = seconds(parsed, 20);
4239
- const client = await connectDaemon(g.paths);
4426
+ const client = await connectDaemon(g.paths, void 0, { greetingMs: STOP_GREETING_MS });
4240
4427
  if (!client) throw new CliError("not_found", `No daemon runs profile ${g.profile}`);
4241
4428
  print({
4242
4429
  stopped: true,
@@ -4246,7 +4433,7 @@ async function daemonCommand(argv) {
4246
4433
  }
4247
4434
  if (sub === "restart") {
4248
4435
  const stopFor = seconds(parsed, 20), startFor = seconds(parsed, 60);
4249
- const client = await connectDaemon(g.paths);
4436
+ const client = await connectDaemon(g.paths, void 0, { greetingMs: STOP_GREETING_MS });
4250
4437
  const probe = client ? client.call("status").catch(() => null) : null;
4251
4438
  print({
4252
4439
  restarted: true,
@@ -4668,7 +4855,7 @@ async function textCommand(name, argv) {
4668
4855
  };
4669
4856
  if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
4670
4857
  if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
4671
- if (!spec.message) Object.assign(params, (await import("./buttons-CtGCix-8.js")).buttonsOf(parsed.options));
4858
+ if (!spec.message) Object.assign(params, (await import("./buttons-B3bi6p_d.js")).buttonsOf(parsed.options));
4672
4859
  print(await withSession(g, (s) => {
4673
4860
  if (spec.target === "chat") {
4674
4861
  params.wait = parsed.options.wait ?? (s.mode === "one-shot" ? spec.message ? "confirmed" : "sent" : "none");
@@ -4976,4 +5163,4 @@ async function run(argv) {
4976
5163
  //#endregion
4977
5164
  export { run };
4978
5165
 
4979
- //# sourceMappingURL=main-DgXvK9Cr.js.map
5166
+ //# sourceMappingURL=main-BDOIJ_ls.js.map