@ghostlytools/cli 1.13.0 → 1.13.2

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 (113) hide show
  1. package/README.md +13 -10
  2. package/dist/assets/api-DV52o7A8.js +3 -0
  3. package/dist/assets/{api-CjOaoG-v.js → api-O57SNJcb.js} +495 -99
  4. package/dist/assets/api-O57SNJcb.js.map +1 -0
  5. package/dist/assets/{apiKit-BAGvlQtm.js → apiKit-CPTFJHA7.js} +40 -8
  6. package/dist/assets/{apiKit-BAGvlQtm.js.map → apiKit-CPTFJHA7.js.map} +1 -1
  7. package/dist/assets/{appFetch-BwJd-kNq.js → appFetch-Ca9DNQQ2.js} +2 -2
  8. package/dist/assets/{appFetch-BwJd-kNq.js.map → appFetch-Ca9DNQQ2.js.map} +1 -1
  9. package/dist/assets/{apps-Cuk45sz5.js → apps-gXpGFPiv.js} +16 -14
  10. package/dist/assets/apps-gXpGFPiv.js.map +1 -0
  11. package/dist/assets/{apps-DjY095Af.js → apps-uZTu5FlR.js} +1 -1
  12. package/dist/assets/{arkade-DryM-q5n.js → arkade-B6UNf5HI.js} +2 -2
  13. package/dist/assets/{arkade-DryM-q5n.js.map → arkade-B6UNf5HI.js.map} +1 -1
  14. package/dist/assets/{backup-DekVCDWv.js → backup-CxH3auHB.js} +9 -7
  15. package/dist/assets/backup-CxH3auHB.js.map +1 -0
  16. package/dist/assets/{backup-B56sQqoQ.js → backup-Di2U6QVH.js} +1 -1
  17. package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js.map +1 -1
  18. package/dist/assets/{bitcoind-B2bbVSzh.js → bitcoind-BpZn3bRN.js} +2 -2
  19. package/dist/assets/{bitcoind-B2bbVSzh.js.map → bitcoind-BpZn3bRN.js.map} +1 -1
  20. package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js.map +1 -1
  21. package/dist/assets/{buttons-BGxzOtrq.js → buttons-D4udKEvT.js} +8 -8
  22. package/dist/assets/buttons-D4udKEvT.js.map +1 -0
  23. package/dist/assets/buttons-YTYEqvGC.js +1 -0
  24. package/dist/assets/{client-DcQAfc3h.js → client-DGx7E8b3.js} +3 -3
  25. package/dist/assets/{client-DcQAfc3h.js.map → client-DGx7E8b3.js.map} +1 -1
  26. package/dist/assets/{domainProofs-BDNP1dIy.js → domainProofs-b3Y1Gj9g.js} +6 -2
  27. package/dist/assets/{domainProofs-BDNP1dIy.js.map → domainProofs-b3Y1Gj9g.js.map} +1 -1
  28. package/dist/assets/{engineErrors--9hfgKlK.js → engineErrors-wWlLy54D.js} +11 -3
  29. package/dist/assets/engineErrors-wWlLy54D.js.map +1 -0
  30. package/dist/assets/{errors-DDLFO4Gf.js → errors-JVJsO8Iu.js} +18 -2
  31. package/dist/assets/errors-JVJsO8Iu.js.map +1 -0
  32. package/dist/assets/{fixedHosts-C3hBliM9.js → fixedHosts-CODN2pTL.js} +3 -3
  33. package/dist/assets/{fixedHosts-C3hBliM9.js.map → fixedHosts-CODN2pTL.js.map} +1 -1
  34. package/dist/assets/{ghostly_iroh_web-DIj5xGmR.js → ghostly_iroh_web-9VOwZcJQ.js} +30 -35
  35. package/dist/assets/ghostly_iroh_web-9VOwZcJQ.js.map +1 -0
  36. package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
  37. package/dist/assets/{groupMeta-goASqzOt.js → groupMeta-CeZpqVVC.js} +174 -37
  38. package/dist/assets/groupMeta-CeZpqVVC.js.map +1 -0
  39. package/dist/assets/{host-C2WRKj3g.js → host-CRA7h5A2.js} +270 -64
  40. package/dist/assets/host-CRA7h5A2.js.map +1 -0
  41. package/dist/assets/{hyperdhtRelay-DLUiwfnt.js → hyperdhtRelay-B34Zhz4P.js} +2 -2
  42. package/dist/assets/{hyperdhtRelay-DLUiwfnt.js.map → hyperdhtRelay-B34Zhz4P.js.map} +1 -1
  43. package/dist/assets/{hyperdhtRelay-bjNGacf5.js → hyperdhtRelay-DDwU5b4P.js} +2 -2
  44. package/dist/assets/{hyperdhtRelay-bjNGacf5.js.map → hyperdhtRelay-DDwU5b4P.js.map} +1 -1
  45. package/dist/assets/{identityProofs-Cksc_K7_.js → identityProofs-B8zCp5_0.js} +140 -27
  46. package/dist/assets/identityProofs-B8zCp5_0.js.map +1 -0
  47. package/dist/assets/{irohWeb-NfthOL98.js → irohWeb-mnOi2Jp7.js} +10838 -4837
  48. package/dist/assets/irohWeb-mnOi2Jp7.js.map +1 -0
  49. package/dist/assets/{linkPreview-DdMf-YAc.js → linkPreview-5kHmKUTN.js} +20 -8
  50. package/dist/assets/linkPreview-5kHmKUTN.js.map +1 -0
  51. package/dist/assets/{main-Dh7fePd8.js → main-Chc871HV.js} +119 -81
  52. package/dist/assets/main-Chc871HV.js.map +1 -0
  53. package/dist/assets/{mainline-DY95WbuK.js → mainline-CDUXtV-I.js} +2 -2
  54. package/dist/assets/{mainline-DY95WbuK.js.map → mainline-CDUXtV-I.js.map} +1 -1
  55. package/dist/assets/{networkReason-Be-hMghr.js → networkReason-DYlPZS5M.js} +2 -2
  56. package/dist/assets/{networkReason-Be-hMghr.js.map → networkReason-DYlPZS5M.js.map} +1 -1
  57. package/dist/assets/{ownDid-BErplN7N.js → ownDid-BOuSlDv-.js} +10 -6
  58. package/dist/assets/ownDid-BOuSlDv-.js.map +1 -0
  59. package/dist/assets/{ownStatus-ClrFjd7h.js → ownStatus-CLA1VPkL.js} +6 -6
  60. package/dist/assets/{ownStatus-ClrFjd7h.js.map → ownStatus-CLA1VPkL.js.map} +1 -1
  61. package/dist/assets/{pairedTransports-BKmvlKz1.js → pairedTransports-DAzupLYo.js} +23 -17
  62. package/dist/assets/pairedTransports-DAzupLYo.js.map +1 -0
  63. package/dist/assets/{paymentIntent-DySU3Ajm.js → paymentIntent-Cr3uZa_0.js} +2 -2
  64. package/dist/assets/{paymentIntent-DySU3Ajm.js.map → paymentIntent-Cr3uZa_0.js.map} +1 -1
  65. package/dist/assets/{profiles-B8xO8-oj.js → profiles-BH1bH9aE.js} +3 -3
  66. package/dist/assets/{profiles-B8xO8-oj.js.map → profiles-BH1bH9aE.js.map} +1 -1
  67. package/dist/assets/{registry--Rg2YvOH.js → registry-DAq16T-V.js} +1 -1
  68. package/dist/assets/{registry-CU8PevhI.js → registry-DP_-RA-v.js} +11 -7
  69. package/dist/assets/registry-DP_-RA-v.js.map +1 -0
  70. package/dist/assets/{relay-CHWg5hpZ.js → relay-gJTOYQJZ.js} +93 -7
  71. package/dist/assets/relay-gJTOYQJZ.js.map +1 -0
  72. package/dist/assets/{resolve-B1upovPM.js → resolve-B1eQ4dVQ.js} +10 -5
  73. package/dist/assets/resolve-B1eQ4dVQ.js.map +1 -0
  74. package/dist/assets/secretGuard-Bh11MPdI.js +1 -0
  75. package/dist/assets/{secretGuard-BrATm_gl.js → secretGuard-oz_3hBfW.js} +19 -2
  76. package/dist/assets/{secretGuard-BrATm_gl.js.map → secretGuard-oz_3hBfW.js.map} +1 -1
  77. package/dist/assets/{server-Dgxx_DaN.js → server-Bd2ofxc1.js} +1283 -6628
  78. package/dist/assets/server-Bd2ofxc1.js.map +1 -0
  79. package/dist/assets/{sshForges-BnvwmNj-.js → sshForges-As7dbGXM.js} +2 -2
  80. package/dist/assets/{sshForges-BnvwmNj-.js.map → sshForges-As7dbGXM.js.map} +1 -1
  81. package/dist/assets/{translate-BcbSWkuq.js → translate-DnuQMfj0.js} +22 -11
  82. package/dist/assets/translate-DnuQMfj0.js.map +1 -0
  83. package/dist/assets/{usdt-CBJ4Q5Ji.js → usdt-DLmtf8F9.js} +4 -4
  84. package/dist/assets/{usdt-CBJ4Q5Ji.js.map → usdt-DLmtf8F9.js.map} +1 -1
  85. package/dist/assets/{waitNotice-ylU3XwjO.js → waitNotice-BHuMofaH.js} +57 -3
  86. package/dist/assets/waitNotice-BHuMofaH.js.map +1 -0
  87. package/dist/ghostly.mjs +1 -1
  88. package/npm-shrinkwrap.json +2 -2
  89. package/package.json +1 -1
  90. package/dist/assets/api-CVtg7MpI.js +0 -3
  91. package/dist/assets/api-CjOaoG-v.js.map +0 -1
  92. package/dist/assets/apps-Cuk45sz5.js.map +0 -1
  93. package/dist/assets/backup-DekVCDWv.js.map +0 -1
  94. package/dist/assets/buttons-BGxzOtrq.js.map +0 -1
  95. package/dist/assets/buttons-CsN2WJOf.js +0 -1
  96. package/dist/assets/engineErrors--9hfgKlK.js.map +0 -1
  97. package/dist/assets/errors-DDLFO4Gf.js.map +0 -1
  98. package/dist/assets/ghostly_iroh_web-DIj5xGmR.js.map +0 -1
  99. package/dist/assets/groupMeta-goASqzOt.js.map +0 -1
  100. package/dist/assets/host-C2WRKj3g.js.map +0 -1
  101. package/dist/assets/identityProofs-Cksc_K7_.js.map +0 -1
  102. package/dist/assets/irohWeb-NfthOL98.js.map +0 -1
  103. package/dist/assets/linkPreview-DdMf-YAc.js.map +0 -1
  104. package/dist/assets/main-Dh7fePd8.js.map +0 -1
  105. package/dist/assets/ownDid-BErplN7N.js.map +0 -1
  106. package/dist/assets/pairedTransports-BKmvlKz1.js.map +0 -1
  107. package/dist/assets/registry-CU8PevhI.js.map +0 -1
  108. package/dist/assets/relay-CHWg5hpZ.js.map +0 -1
  109. package/dist/assets/resolve-B1upovPM.js.map +0 -1
  110. package/dist/assets/secretGuard-Bm6nci0I.js +0 -1
  111. package/dist/assets/server-Dgxx_DaN.js.map +0 -1
  112. package/dist/assets/translate-BcbSWkuq.js.map +0 -1
  113. package/dist/assets/waitNotice-ylU3XwjO.js.map +0 -1
@@ -1,19 +1,20 @@
1
- import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-DDLFO4Gf.js";
2
- import { a as endedUnsent, i as endedUnanswered, o as isNotTheDaemon, p as CALL_RATES, r as connectDaemon, s as notTheDaemon, t as DaemonClient, y as isCallRate } from "./client-DcQAfc3h.js";
1
+ import { a as secretValue, i as localFileError, n as EXIT, o as shownValue, r as asCliError, t as CliError } from "./errors-JVJsO8Iu.js";
2
+ import { a as endedUnsent, i as endedUnanswered, o as isNotTheDaemon, p as CALL_RATES, r as connectDaemon, s as notTheDaemon, t as DaemonClient, y as isCallRate } from "./client-DGx7E8b3.js";
3
3
  import { n as dropSecretEnv, t as childEnv } from "./childEnv-C-99hdbL.js";
4
- import { Cr as cardUrl, D as GROUP_FILE_LIMITS, Dr as statusCardBytes, En as VOICE_LIMITS, Sr as cardLine, Zn as reactionEmoji, _r as TASK_STATUSES, bt as STATUS_AVAILABILITIES, dr as ITEM_STATES, fr as PR_CHECKS, gr as STATUS_CARD_LIMITS, hr as RUN_RESULTS, mr as ROUTINE_STATES, pr as PR_STATES, ur as CRON_LINE } from "./groupMeta-goASqzOt.js";
5
- import { S as userPath, _ as profileExists, b as startingDaemon, c as createProfile, d as daemonClaim, f as ghostlyHome, g as noProfile, i as checkProfileName, l as currentProfile, m as lockOwner, o as checkShownNameOption, p as listProfiles, s as claimForDaemon, u as currentProfileOrNone, v as profilePaths, w as ownProfile, y as selectProfile } from "./profiles-B8xO8-oj.js";
6
- import { _ as hideSecretFields, a as PAY_METHODS, c as turnRef, d as ENGINE_METHODS, f as ENGINE_PARAMS, h as SECRET_RESULTS, i as CHAT_METHODS, m as READ_PARAMS, o as TRANSPORT_NAMES, p as ENGINE_READS, r as ADDRESS_TYPES, s as WALLET_TYPES, t as checkOwnStatus } from "./ownStatus-ClrFjd7h.js";
7
- import { B as shellWord, V as jsonOut, a as contactKeyOf, b as namedByThem, y as nameKey } from "./apiKit-BAGvlQtm.js";
8
- import { i as waitsFor, r as waitNotice } from "./waitNotice-ylU3XwjO.js";
4
+ import { $n as reactionEmoji, O as GROUP_FILE_LIMITS, On as VOICE_LIMITS, Tr as cardUrl, _r as RUN_RESULTS, fr as CRON_LINE, gr as ROUTINE_STATES, hr as PR_STATES, kr as statusCardBytes, mr as PR_CHECKS, pr as ITEM_STATES, vr as STATUS_CARD_LIMITS, wr as cardLine, xt as STATUS_AVAILABILITIES, yr as TASK_STATUSES } from "./groupMeta-CeZpqVVC.js";
5
+ import { S as userPath, _ as profileExists, b as startingDaemon, c as createProfile, d as daemonClaim, f as ghostlyHome, g as noProfile, i as checkProfileName, l as currentProfile, m as lockOwner, o as checkShownNameOption, p as listProfiles, s as claimForDaemon, u as currentProfileOrNone, v as profilePaths, w as ownProfile, y as selectProfile } from "./profiles-BH1bH9aE.js";
6
+ import { _ as hideSecretFields, a as PAY_METHODS, c as turnRef, d as ENGINE_METHODS, f as ENGINE_PARAMS, h as SECRET_RESULTS, i as CHAT_METHODS, m as READ_PARAMS, o as TRANSPORT_NAMES, p as ENGINE_READS, r as ADDRESS_TYPES, s as WALLET_TYPES, t as checkOwnStatus } from "./ownStatus-CLA1VPkL.js";
7
+ import { U as shellWord, W as jsonOut, a as contactKeyOf, b as nameKey, x as namedByThem } from "./apiKit-CPTFJHA7.js";
8
+ import { c as waitsFor, o as longTextChat, r as dhtOnlyNotice, s as waitNotice } from "./waitNotice-BHuMofaH.js";
9
9
  import { spawn } from "node:child_process";
10
10
  import { accessSync, closeSync, constants, existsSync, fstatSync, openSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
11
11
  import { dirname, resolve, sep } from "node:path";
12
+ import { randomUUID } from "node:crypto";
12
13
  import { connect } from "node:net";
13
14
  import { format } from "node:util";
14
15
  var package_default = {
15
16
  name: "@ghostlytools/cli",
16
- version: "1.13.0",
17
+ version: "1.13.2",
17
18
  type: "module",
18
19
  description: "Ghostly for bots and terminals: the app's own engine, headless on Node, behind a daemon and a `ghostly` command with JSON output.",
19
20
  license: "MIT",
@@ -92,7 +93,7 @@ var package_default = {
92
93
  * `Number()` alone read `1e3` as 1,000, `0x10` as 16 and `" 21"` as 21: `chat pay bob 2e3`, a typo of 23, paid 2,000.
93
94
  */
94
95
  var decimalNumber = (value) => /^-?\d+(\.\d+)?$/.test(value) ? Number(value) : NaN;
95
- var notANumber = (name, option, value) => new CliError("usage", `--${name} takes ${option.takes ?? "a number"}, not ${JSON.stringify(value)}`);
96
+ var notANumber = (name, option, value) => new CliError("usage", `--${name} takes ${option.takes ?? "a number"}, not ${shownValue(value)}`);
96
97
  /**
97
98
  * The word right after an option that stood alone because it was no number (`--voice 2s`), by the positionals a parse
98
99
  * returned: should the line have one too many, that word was the option's value, and `strayValue` says so.
@@ -215,7 +216,7 @@ function parseArgs(argv, spec, idSlot = () => false, parsing) {
215
216
  options[name] = number;
216
217
  } else if (option.type === "list") options[name] = [...options[name] ?? [], value];
217
218
  else {
218
- if (option.choices && !option.choices.includes(value)) throw new CliError("usage", `--${name} takes ${listed$1(option.choices)}, not ${JSON.stringify(value)}`);
219
+ if (option.choices && !option.choices.includes(value)) throw new CliError("usage", `--${name} takes ${listed$1(option.choices)}, not ${shownValue(value)}`);
219
220
  options[name] = value;
220
221
  }
221
222
  continue;
@@ -252,7 +253,7 @@ function unknownOption(arg, all, parsing, help = parsing ? `ghostly help ${parsi
252
253
  */
253
254
  function shownOption(arg, privateKey) {
254
255
  if (privateKey) return "(a private key)";
255
- return arg.length > 40 || /[\r\n]/.test(arg) ? `(a ${arg.length}-character word)` : arg;
256
+ return secretValue(arg) ?? arg;
256
257
  }
257
258
  /**
258
259
  * A first word that starts with a dash and is no global option (`ghostly --porfile bot send …`, `ghostly -x status`):
@@ -303,7 +304,7 @@ function checkSettingKey(key, kinds) {
303
304
  }
304
305
  /** A value of another kind than its key takes (`online maybe`): a usage error too, before the profile opens. */
305
306
  function checkSettingValue(key, kind, value, typed) {
306
- if (kind === "boolean" && typeof value !== "boolean") throw new CliError("usage", `${key} takes true or false, not ${JSON.stringify(typed)}: ${SETTINGS_SET}`);
307
+ if (kind === "boolean" && typeof value !== "boolean") throw new CliError("usage", `${key} takes true or false, not ${shownValue(typed)}: ${SETTINGS_SET}`);
307
308
  if (kind === "strings" && !(Array.isArray(value) && value.every((v) => typeof v === "string"))) throw new CliError("usage", `${key} takes a JSON list of strings: ${SETTINGS_SET}`);
308
309
  if (kind === "ice" && !(Array.isArray(value) && value.every((v) => v && typeof v === "object"))) throw new CliError("usage", `${key} takes a JSON list of ICE servers: ${SETTINGS_SET}`);
309
310
  }
@@ -463,12 +464,13 @@ function refs(values, flag, what) {
463
464
  }
464
465
  /**
465
466
  * A whole number of sats from the command line (`<sats>`), refused in a number flag's words: `<sats> takes a whole
466
- * number from 1 up, not -5`, a number as typed, other words quoted. Before: "Not an amount in sats: \"-5\"".
467
+ * number from 1 up, not -5`, a number as typed, other words quoted, or described when long or secret-looking (a Cashu
468
+ * token pasted after `wallet receive`). Before: "Not an amount in sats: \"-5\"".
467
469
  */
468
470
  function sats(value) {
469
471
  const n = decimalNumber(value ?? "");
470
472
  if (!Number.isSafeInteger(n) || n <= 0) {
471
- const shown = Number.isNaN(n) ? JSON.stringify(value) : value;
473
+ const shown = Number.isNaN(n) ? shownValue(value) : value;
472
474
  throw new CliError("usage", `<sats> takes a whole number from 1 up, not ${shown}`);
473
475
  }
474
476
  return n;
@@ -546,7 +548,7 @@ var typingKind = {
546
548
  function typingFor(options) {
547
549
  const seconds = options.for;
548
550
  if (seconds === void 0) return void 0;
549
- if (typeof seconds !== "number" || !(seconds >= 1 && seconds <= 600)) throw new CliError("usage", `--for takes a number of seconds from 1 to 600, not ${JSON.stringify(seconds)}`);
551
+ if (typeof seconds !== "number" || !(seconds >= 1 && seconds <= 600)) throw new CliError("usage", `--for takes a number of seconds from 1 to 600, not ${shownValue(seconds)}`);
550
552
  if (options.stop === true) throw new CliError("usage", "--for keeps it on: not with --stop");
551
553
  return seconds;
552
554
  }
@@ -559,7 +561,7 @@ function typingFor(options) {
559
561
  function reaction(options, emoji) {
560
562
  if (options.remove === true) return emoji;
561
563
  if (!emoji) throw new CliError("usage", "Give one emoji, or --remove to take yours back");
562
- if (!reactionEmoji(emoji)) throw new CliError("usage", `<emoji> takes one emoji, not ${JSON.stringify(emoji)}`);
564
+ if (!reactionEmoji(emoji)) throw new CliError("usage", `<emoji> takes one emoji, not ${shownValue(emoji)}`);
563
565
  return emoji;
564
566
  }
565
567
  /**
@@ -578,7 +580,7 @@ var HISTORY_LIMIT = 1e4;
578
580
  function inRange(options, flag, what, min, max, whole = false) {
579
581
  const value = options[flag];
580
582
  if (value === void 0) return void 0;
581
- if (typeof value !== "number" || !(value >= min && value <= max) || whole && !Number.isInteger(value)) throw new CliError("usage", `--${flag} takes ${what} from ${min} to ${max}, not ${JSON.stringify(value)}`);
583
+ if (typeof value !== "number" || !(value >= min && value <= max) || whole && !Number.isInteger(value)) throw new CliError("usage", `--${flag} takes ${what} from ${min} to ${max}, not ${shownValue(value)}`);
582
584
  return value;
583
585
  }
584
586
  /** `--timeout` of a command that waits: seconds, up to an hour (a send, a card, a button) or a day (`chat wait`, a file). */
@@ -588,7 +590,7 @@ var pageLimit = (options) => inRange(options, "limit", "a whole number", 1, HIST
588
590
  /** `--since` of `events` and `listen`: a seq, a whole number from 0 (a negative one replayed a made-up gap first). */
589
591
  function since(options) {
590
592
  const value = options.since;
591
- if (value !== void 0 && !(Number.isSafeInteger(value) && value >= 0)) throw new CliError("usage", `--since takes a seq from 0 up, not ${JSON.stringify(value)}`);
593
+ if (value !== void 0 && !(Number.isSafeInteger(value) && value >= 0)) throw new CliError("usage", `--since takes a seq from 0 up, not ${shownValue(value)}`);
592
594
  return value;
593
595
  }
594
596
  /**
@@ -661,7 +663,7 @@ function cardLinks(values) {
661
663
  label: value.slice(0, eq),
662
664
  url: value.slice(eq + 1)
663
665
  } : { url: value };
664
- 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)}`);
666
+ 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 ${shownValue(value)}`);
665
667
  cardText("--link's label", link.label, STATUS_CARD_LIMITS.linkLabel, value);
666
668
  return link;
667
669
  });
@@ -675,13 +677,13 @@ var listed = (words) => `${words.slice(0, -1).join(", ")} or ${words.at(-1)}`;
675
677
  function cardText(flag, value, max, shown = value) {
676
678
  if (value === void 0) return;
677
679
  const line = cardLine(String(value), Infinity);
678
- if (!line) throw new CliError("usage", `${flag} takes text, not ${JSON.stringify(shown)}`);
680
+ if (!line) throw new CliError("usage", `${flag} takes text, not ${shownValue(shown)}`);
679
681
  const length = [...line].length;
680
682
  if (length > max) throw new CliError("usage", `${flag} takes at most ${max} characters, not ${length}`);
681
683
  }
682
684
  /** `--status`, `--state`, `--pr-state`, `--pr-checks`: one of their words, or a usage error that lists them. */
683
685
  function oneWord(options, flag, words) {
684
- if (options[flag] !== void 0 && !words.includes(options[flag])) throw new CliError("usage", `--${flag} takes ${listed(words)}, not ${JSON.stringify(options[flag])}`);
686
+ if (options[flag] !== void 0 && !words.includes(options[flag])) throw new CliError("usage", `--${flag} takes ${listed(words)}, not ${shownValue(options[flag])}`);
685
687
  }
686
688
  /** A flag given more times than the card holds: a usage error that says how many it takes. */
687
689
  function given(flag, values, max) {
@@ -703,7 +705,7 @@ function itemOf(value) {
703
705
  text: value
704
706
  };
705
707
  }
706
- 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)}`);
708
+ if (!ITEM_STATES.includes(word)) throw new CliError("usage", `--item takes state:text, and ${shownValue(word)} is not a state: use ${listed(ITEM_STATES)} (pending:<text> keeps a colon in the text), not ${shownValue(value)}`);
707
709
  const text = value.slice(colon + 1).trim();
708
710
  cardText("--item's text", text, STATUS_CARD_LIMITS.line, value);
709
711
  return {
@@ -731,7 +733,7 @@ function cardId(options) {
731
733
  /** `--progress`, `--left`: a percent, or a usage error that names the flag. */
732
734
  function percent(options, flag) {
733
735
  const value = options[flag];
734
- if (value !== void 0 && !(typeof value === "number" && value >= 0 && value <= 100)) throw new CliError("usage", `--${flag} takes a percent from 0 to 100, not ${JSON.stringify(value)}`);
736
+ if (value !== void 0 && !(typeof value === "number" && value >= 0 && value <= 100)) throw new CliError("usage", `--${flag} takes a percent from 0 to 100, not ${shownValue(value)}`);
735
737
  }
736
738
  /**
737
739
  * `--pr-number`, `--additions`, `--used`, `--limit`…: a count as the card takes it, a whole number from `min` up to
@@ -778,13 +780,13 @@ function taskFields(options) {
778
780
  set("branch", options.branch);
779
781
  if (options.steps !== void 0) {
780
782
  const match = /^(\d+)\s*\/\s*(\d+)$/.exec(String(options.steps));
781
- if (!match) throw new CliError("usage", `--steps takes done/total, like 2/5, not ${JSON.stringify(options.steps)}`);
783
+ if (!match) throw new CliError("usage", `--steps takes done/total, like 2/5, not ${shownValue(options.steps)}`);
782
784
  fields.done = Number(match[1]);
783
785
  fields.total = Number(match[2]);
784
- if (Number(match[2]) > STATUS_CARD_LIMITS.count) throw new CliError("usage", `--steps takes done/total of at most ${STATUS_CARD_LIMITS.count} steps, like 2/5, not ${JSON.stringify(options.steps)}`);
785
- 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)}`);
786
+ if (Number(match[2]) > STATUS_CARD_LIMITS.count) throw new CliError("usage", `--steps takes done/total of at most ${STATUS_CARD_LIMITS.count} steps, like 2/5, not ${shownValue(options.steps)}`);
787
+ 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 ${shownValue(options.steps)}`);
786
788
  }
787
- 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"])}`);
789
+ 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 ${shownValue(options["pr-url"])}`);
788
790
  for (const flag of [
789
791
  "pr-number",
790
792
  "additions",
@@ -910,17 +912,17 @@ function cardTime(value, flag, forms = `a time in milliseconds or a date: ${CARD
910
912
  const text = String(value).trim();
911
913
  const day = ISO_DAY.exec(text);
912
914
  const ms = /^\d+$/.test(text) ? milliseconds(text, flag) : Date.parse(day ? `${text}${day[1] ? "" : "-01"}T00:00` : text);
913
- if (!Number.isSafeInteger(ms) || ms <= 0) throw new CliError("usage", `--${flag} takes ${forms}, not ${JSON.stringify(value)}`);
915
+ if (!Number.isSafeInteger(ms) || ms <= 0) throw new CliError("usage", `--${flag} takes ${forms}, not ${shownValue(value)}`);
914
916
  const written = writtenDay(text);
915
917
  if (written) {
916
918
  const [year, month, date] = written, days = new Date(Date.UTC(year, month, 0)).getUTCDate();
917
- if (date > days) throw new CliError("usage", `--${flag} takes a day the month has (${year}-${String(month).padStart(2, "0")} has ${days}), not ${JSON.stringify(value)}`);
919
+ if (date > days) throw new CliError("usage", `--${flag} takes a day the month has (${year}-${String(month).padStart(2, "0")} has ${days}), not ${shownValue(value)}`);
918
920
  }
919
921
  const last = new Date(Date.now() + STATUS_CARD_LIMITS.nextRunMs);
920
922
  if (ms > last.getTime()) {
921
923
  const two = (n) => String(n).padStart(2, "0");
922
924
  const shown = `${last.getFullYear()}-${two(last.getMonth() + 1)}-${two(last.getDate())} ${two(last.getHours())}:${two(last.getMinutes())}`;
923
- throw new CliError("usage", `--${flag} takes a time within a year from now (until ${shown}), not ${JSON.stringify(value)}`);
925
+ throw new CliError("usage", `--${flag} takes a time within a year from now (until ${shown}), not ${shownValue(value)}`);
924
926
  }
925
927
  return ms;
926
928
  }
@@ -929,7 +931,7 @@ function runOf(value) {
929
931
  if (value === void 0) return void 0;
930
932
  const text = String(value), colon = text.indexOf(":");
931
933
  const result = colon === -1 ? text : text.slice(0, colon), summary = colon === -1 ? "" : text.slice(colon + 1).trim();
932
- 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)}`);
934
+ if (!RUN_RESULTS.includes(result)) throw new CliError("usage", `--run takes ok, failed or skipped, and :a summary after it if you like, not ${shownValue(value)}`);
933
935
  if (summary) cardText("--run's summary", summary, STATUS_CARD_LIMITS.line);
934
936
  return {
935
937
  result,
@@ -943,7 +945,7 @@ function routineFields(options) {
943
945
  cardText("--schedule", options.schedule, STATUS_CARD_LIMITS.schedule);
944
946
  if (options.cron !== void 0 && !CRON_LINE.test(String(options.cron).trim())) {
945
947
  const length = [...String(options.cron).trim()].length;
946
- 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)}`);
948
+ 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 ${shownValue(options.cron)}`);
947
949
  }
948
950
  oneWord(options, "state", ROUTINE_STATES);
949
951
  cardId(options);
@@ -1062,7 +1064,7 @@ var taskOptions = {
1062
1064
  */
1063
1065
  function usageWindowOf(value) {
1064
1066
  const match = /^([^=]+)=(\d+(?:\.\d+)?)(?:@(.+))?$/.exec(value.trim());
1065
- 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)}`);
1067
+ if (!match) throw new CliError("usage", `--also takes window=percent or window=percent@time, like week=80@2026-10-10T00:00:00Z, not ${shownValue(value)}`);
1066
1068
  cardText("--also's window", match[1], STATUS_CARD_LIMITS.usageWindow, value);
1067
1069
  if (Number(match[2]) > 100) throw new CliError("usage", `--also takes a percent from 0 to 100, not ${match[2]}`);
1068
1070
  const resetsAt = cardTime(match[3], "also");
@@ -1209,7 +1211,7 @@ var commands$8 = {
1209
1211
  description: "Replace the three files when they are there"
1210
1212
  }
1211
1213
  },
1212
- run: async ({ options }, a) => (await import("./apps-DjY095Af.js")).initApp(a.dir, {
1214
+ run: async ({ options }, a) => (await import("./apps-uZTu5FlR.js")).initApp(a.dir, {
1213
1215
  name: options.name,
1214
1216
  title: options.title,
1215
1217
  force: options.force === true
@@ -1249,7 +1251,7 @@ var commands$8 = {
1249
1251
  description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
1250
1252
  }
1251
1253
  },
1252
- run: async ({ options }, a) => (await import("./apps-DjY095Af.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1254
+ run: async ({ options }, a) => (await import("./apps-uZTu5FlR.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1253
1255
  },
1254
1256
  "app revoke": {
1255
1257
  method: "app.revoke",
@@ -1282,7 +1284,7 @@ var commands$8 = {
1282
1284
  description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere), and a --reason that looks like a seed, a key or ecash"
1283
1285
  }
1284
1286
  },
1285
- run: async ({ options }, a) => (await import("./apps-DjY095Af.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
1287
+ run: async ({ options }, a) => (await import("./apps-uZTu5FlR.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
1286
1288
  digests: options.digest,
1287
1289
  upTo: options["up-to"],
1288
1290
  reason: options.reason,
@@ -1343,7 +1345,7 @@ var commands$8 = {
1343
1345
  usage: "app verify <bundle|url>",
1344
1346
  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 (for a URL, or beside one of its sources) revokes this version",
1345
1347
  args: ["bundle"],
1346
- run: async (_, a) => (await import("./apps-DjY095Af.js")).verifyApp(a.bundle)
1348
+ run: async (_, a) => (await import("./apps-uZTu5FlR.js")).verifyApp(a.bundle)
1347
1349
  },
1348
1350
  "store sign": {
1349
1351
  method: "store.sign",
@@ -1360,7 +1362,7 @@ var commands$8 = {
1360
1362
  description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
1361
1363
  }
1362
1364
  },
1363
- run: async ({ options }, a) => (await import("./apps-DjY095Af.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1365
+ run: async ({ options }, a) => (await import("./apps-uZTu5FlR.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1364
1366
  }
1365
1367
  };
1366
1368
  // src/commands/calls.ts
@@ -1370,7 +1372,7 @@ var commands$8 = {
1370
1372
  */
1371
1373
  function rateOf(options) {
1372
1374
  const value = options.rate;
1373
- 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)}`);
1375
+ if (value !== void 0 && !isCallRate(value)) throw new CliError("usage", `--rate takes ${CALL_RATES.slice(0, -1).join(", ")} or ${CALL_RATES.at(-1)}, not ${shownValue(value)}`);
1374
1376
  return value;
1375
1377
  }
1376
1378
  /** Voice calls: one entry per command, in alphabetical order (test/commands.test.ts checks). */
@@ -1399,7 +1401,7 @@ var commands$7 = {
1399
1401
  rate
1400
1402
  },
1401
1403
  params: ({ options }, a) => {
1402
- if (a.mode !== void 0 && a.mode !== "on" && a.mode !== "off") throw new CliError("usage", `call auto takes on or off, not ${JSON.stringify(a.mode)}: ghostly call auto [on|off] [--from <chat>]... [--rate 48000]`);
1404
+ if (a.mode !== void 0 && a.mode !== "on" && a.mode !== "off") throw new CliError("usage", `call auto takes on or off, not ${shownValue(a.mode)}: ghostly call auto [on|off] [--from <chat>]... [--rate 48000]`);
1403
1405
  if (a.mode !== "on" && (options.from !== void 0 || options.rate !== void 0)) throw new CliError("usage", "--from and --rate go with on: ghostly call auto on --from <chat>");
1404
1406
  refs(options.from, "from", "chat");
1405
1407
  if (a.mode === void 0) return {};
@@ -2069,7 +2071,7 @@ function voiceOf(options) {
2069
2071
  };
2070
2072
  if (voice === void 0) throw new CliError("usage", "--peaks is a voice note's waveform: not without --voice");
2071
2073
  const bars = peaks.split(",");
2072
- if (bars.length > VOICE_LIMITS.maxBars || !bars.every((bar) => /^\d{1,3}$/.test(bar.trim()) && Number(bar) <= 255)) throw new CliError("usage", `--peaks takes up to ${VOICE_LIMITS.maxBars} numbers from 0 to 255, comma-separated, not ${JSON.stringify(peaks)}`);
2074
+ if (bars.length > VOICE_LIMITS.maxBars || !bars.every((bar) => /^\d{1,3}$/.test(bar.trim()) && Number(bar) <= 255)) throw new CliError("usage", `--peaks takes up to ${VOICE_LIMITS.maxBars} numbers from 0 to 255, comma-separated, not ${shownValue(peaks)}`);
2073
2075
  return {
2074
2076
  voice,
2075
2077
  peaks: bars
@@ -2085,7 +2087,7 @@ var commands$5 = {
2085
2087
  "file accept": {
2086
2088
  method: "file.action",
2087
2089
  usage: "file accept [<chat>] <file>",
2088
- summary: "Take a file the contact offers, or download a group's file that did not come by itself (<chat> may be the group)",
2090
+ summary: "Take a file the contact offers, or download a group's file that did not come by itself (<chat> may be the group); refused when it does not fit in the room left on this device, and it keeps waiting",
2089
2091
  args: ["chat?", "file"],
2090
2092
  params: (_, a) => ({
2091
2093
  chat: a.chat,
@@ -2298,8 +2300,8 @@ function statusUntil(value) {
2298
2300
  if (value === void 0) return void 0;
2299
2301
  const text = String(value).trim(), duration = DURATION.exec(text);
2300
2302
  const ms = duration ? Date.now() + Number(duration[1]) * UNIT_MS[duration[2]] : cardTime(text, "until", `30m, 2h or 1d from now (whole minutes, hours or days), milliseconds or a date: ${CARD_TIME_FORMS}`);
2301
- if (duration && !(ms <= Date.now() + STATUS_CARD_LIMITS.nextRunMs)) throw new CliError("usage", `--until takes a time within a year from now, not ${JSON.stringify(value)}`);
2302
- if (ms <= Date.now()) throw new CliError("usage", `--until takes a time to come, not ${JSON.stringify(value)}: a status that ended is none`);
2303
+ if (duration && !(ms <= Date.now() + STATUS_CARD_LIMITS.nextRunMs)) throw new CliError("usage", `--until takes a time within a year from now, not ${shownValue(value)}`);
2304
+ if (ms <= Date.now()) throw new CliError("usage", `--until takes a time to come, not ${shownValue(value)}: a status that ended is none`);
2303
2305
  return ms;
2304
2306
  }
2305
2307
  /** The profile's status, its picture, the event journal: one entry per command, in alphabetical order (test/commands.test.ts checks). */
@@ -2425,7 +2427,7 @@ var commands$3 = {
2425
2427
  description: "Invitations from this chat: its id, its contact's key or a label given here with chat rename (again for more: a new on replaces the list)"
2426
2428
  } },
2427
2429
  params: ({ options }, a) => {
2428
- if (a.mode !== void 0 && a.mode !== "on" && a.mode !== "off") throw new CliError("usage", `group auto takes on or off, not ${JSON.stringify(a.mode)}: ghostly group auto [on|off] [--from <chat>]...`);
2430
+ if (a.mode !== void 0 && a.mode !== "on" && a.mode !== "off") throw new CliError("usage", `group auto takes on or off, not ${shownValue(a.mode)}: ghostly group auto [on|off] [--from <chat>]...`);
2429
2431
  if (a.mode === "on" && options.from === void 0) throw new CliError("usage", "group auto on needs the chats whose invitations it accepts: ghostly group auto on --from <chat>");
2430
2432
  if (a.mode !== "on" && options.from !== void 0) throw new CliError("usage", "--from goes with on: ghostly group auto on --from <chat>");
2431
2433
  refs(options.from, "from", "chat");
@@ -2894,8 +2896,8 @@ var commands$2 = {
2894
2896
  */
2895
2897
  function networkList(value) {
2896
2898
  const networks = value.split(",").map((n) => n.trim()).filter(Boolean);
2897
- if (!networks.length) throw new CliError("usage", `--networks takes mainnet, testnet or mainnet,testnet (to stop taking it: --off), not ${JSON.stringify(value)}`);
2898
- if (!networks.every((n) => n === "mainnet" || n === "testnet")) throw new CliError("usage", `--networks takes mainnet, testnet or mainnet,testnet, not ${JSON.stringify(value)}`);
2899
+ if (!networks.length) throw new CliError("usage", `--networks takes mainnet, testnet or mainnet,testnet (to stop taking it: --off), not ${shownValue(value)}`);
2900
+ if (!networks.every((n) => n === "mainnet" || n === "testnet")) throw new CliError("usage", `--networks takes mainnet, testnet or mainnet,testnet, not ${shownValue(value)}`);
2899
2901
  return networks;
2900
2902
  }
2901
2903
  /**
@@ -2904,7 +2906,7 @@ function networkList(value) {
2904
2906
  */
2905
2907
  function requestAmount(value, method) {
2906
2908
  if (method !== "usdt") return sats(value);
2907
- if (!/^\d+(\.\d+)?$/.test(value ?? "") || !/[1-9]/.test(value)) throw new CliError("usage", `<amount> with --method usdt takes USDT above 0 (5 or 0.25), not ${JSON.stringify(value)}`);
2909
+ if (!/^\d+(\.\d+)?$/.test(value ?? "") || !/[1-9]/.test(value)) throw new CliError("usage", `<amount> with --method usdt takes USDT above 0 (5 or 0.25), not ${shownValue(value)}`);
2908
2910
  return value;
2909
2911
  }
2910
2912
  /** Wallets and payments: one entry per command, in alphabetical order (test/commands.test.ts checks). */
@@ -3041,7 +3043,7 @@ var commands$1 = {
3041
3043
  "pay": {
3042
3044
  method: "pay",
3043
3045
  usage: "pay <invoice|lightning-address|lnurl> [--amount sats] [--network n] [--max-fee sats] [--card <id>] [--comment t] [--chat <chat>] [--confirm-real] [--force]",
3044
- summary: "Pay over Lightning from Testnet, or --network mainnet with --confirm-real",
3046
+ summary: "Pay over Lightning from Testnet, or --network mainnet with --confirm-real. paid false: not settled yet (pending at the mint or the card's source, or its answer lost); it settles by itself, is never paid twice, and its note says what is set aside and where to look",
3045
3047
  args: ["target"],
3046
3048
  options: {
3047
3049
  amount: {
@@ -3226,7 +3228,7 @@ var commands$1 = {
3226
3228
  "wallet redeem": {
3227
3229
  method: "wallet.redeem",
3228
3230
  usage: "wallet redeem [<cashu-token> | -]",
3229
- summary: "Take the ecash of a Cashu token (its mint must be one of yours); the token on stdin keeps it out of ps",
3231
+ summary: "Take the ecash of a Cashu token (its mint must be one of yours: wallet add-mint <url>); the token on stdin keeps it out of ps",
3230
3232
  args: ["token?"],
3231
3233
  params: (_, { token }) => ({ token })
3232
3234
  },
@@ -3278,7 +3280,7 @@ var commands = {
3278
3280
  "service enable": {
3279
3281
  method: "service.enable",
3280
3282
  usage: "service enable <service> [--off]",
3281
- summary: "Turn a shared app on or off",
3283
+ summary: "Turn a shared app on or off; <service> is its id, as service add and service list show it",
3282
3284
  args: ["service"],
3283
3285
  options: { off: {
3284
3286
  type: "boolean",
@@ -3319,14 +3321,14 @@ var commands = {
3319
3321
  "service remove": {
3320
3322
  method: "service.remove",
3321
3323
  usage: "service remove <service>",
3322
- summary: "Stop sharing a web app with anyone",
3324
+ summary: "Stop sharing a web app with anyone; <service> is its id, as service add and service list show it",
3323
3325
  args: ["service"],
3324
3326
  params: (_, a) => ({ service: a.service })
3325
3327
  },
3326
3328
  "service share": {
3327
3329
  method: "service.share",
3328
3330
  usage: "service share <service> <chat> [--off]",
3329
- summary: "Give (or take back) a contact access to a web app",
3331
+ summary: "Give (or take back) a contact access to a web app; <service> is its id, as service add and service list show it",
3330
3332
  args: ["service", "chat"],
3331
3333
  options: { off: {
3332
3334
  type: "boolean",
@@ -3551,7 +3553,7 @@ function positionals(command, values) {
3551
3553
  const words = command.words?.[name];
3552
3554
  if (words && !words.includes(values[i])) {
3553
3555
  const placeholder = shown[i + skip] && !shown[i + skip].includes("|") ? shown[i + skip] : name;
3554
- throw new CliError("usage", `<${placeholder}> takes ${listed(words)}, not ${JSON.stringify(values[i])}`);
3556
+ throw new CliError("usage", `<${placeholder}> takes ${listed(words)}, not ${shownValue(values[i])}`);
3555
3557
  }
3556
3558
  out[name] = values[i];
3557
3559
  }
@@ -3565,6 +3567,22 @@ function positionals(command, values) {
3565
3567
  function noMoreThan(count, values, usage) {
3566
3568
  if (values.length > count) throw strayValue(values) ?? new CliError("usage", `Too many arguments: ghostly ${usage}`);
3567
3569
  }
3570
+ // src/identityWait.ts
3571
+ /**
3572
+ * What `identity add` writes on stderr while an in-app signer waits: only the events of its own call (`request`, the
3573
+ * id it gave `identity.add`), never another proof's waiting on the same daemon. On a terminal in words, as every
3574
+ * other wait (`ghostly: …`), the link or code on its own line; on a pipe the event's JSON line.
3575
+ */
3576
+ function identityWaitLines(event, request, terminal) {
3577
+ if (event.type !== "identity.approval" && event.type !== "identity.progress" || event.request !== request) return "";
3578
+ if (!terminal) return JSON.stringify(event) + "\n";
3579
+ if (event.type === "identity.progress") return `ghostly: ${String(event.message)}\n`;
3580
+ const lines = [];
3581
+ if (typeof event.url === "string") lines.push("ghostly: Approve the request at this link:", event.url);
3582
+ if (typeof event.qr === "string") lines.push(`ghostly: Approve the request with this code${typeof event.label === "string" ? ` (${event.label.replace(/^Or (\w)/, (_, c) => c.toUpperCase())})` : ""}:`, event.qr);
3583
+ for (const note of Array.isArray(event.notes) ? event.notes : []) lines.push(`ghostly: ${String(note)}`);
3584
+ return lines.map((line) => line + "\n").join("");
3585
+ }
3568
3586
  // src/listen.ts
3569
3587
  /** The cursor's own write failed, not the event's handling. */
3570
3588
  var CursorError = class extends Error {
@@ -3745,7 +3763,7 @@ function checkWebhook(url, from = "--webhook") {
3745
3763
  }
3746
3764
  /**
3747
3765
  * The event number a cursor file holds, or undefined when there is no file (a first start: live events). A file that is
3748
- * there and holds no whole number (empty, half-written, edited by hand) is refused, naming the file and what it holds:
3766
+ * there and holds no whole number (empty, half-written, edited by hand) is refused, naming the file and how much it holds:
3749
3767
  * taken as no cursor, the listener started at the journal's end and skipped every event since the last one handled,
3750
3768
  * without a word, and its next write replaced the file.
3751
3769
  */
@@ -3760,7 +3778,8 @@ function readCursor(path) {
3760
3778
  const trimmed = text.trim();
3761
3779
  const value = trimmed === "" ? NaN : Number(trimmed);
3762
3780
  if (Number.isSafeInteger(value) && value >= 0 && /^\d+$/.test(trimmed)) return value;
3763
- const shown = trimmed === "" ? "nothing" : JSON.stringify(trimmed.length > 32 ? `${trimmed.slice(0, 32)}…` : trimmed);
3781
+ const words = trimmed.split(/\s+/).length, bytes = Buffer.byteLength(trimmed);
3782
+ const shown = trimmed === "" ? "nothing" : `${words} ${words === 1 ? "word" : "words"}, ${bytes} ${bytes === 1 ? "byte" : "bytes"}`;
3764
3783
  throw new CliError("bad_request", `${path} holds no event number (${shown}): fix or remove it, or give --since`);
3765
3784
  }
3766
3785
  /**
@@ -4472,15 +4491,15 @@ var VERSION = package_default.version;
4472
4491
  * command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
4473
4492
  * cost every command ~100 ms before its socket was opened.
4474
4493
  */
4475
- var engineApi = () => import("./api-CVtg7MpI.js");
4476
- var engineHost = () => import("./host-C2WRKj3g.js");
4494
+ var engineApi = () => import("./api-DV52o7A8.js");
4495
+ var engineHost = () => import("./host-CRA7h5A2.js");
4477
4496
  /**
4478
4497
  * `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
4479
4498
  * asked: the app's message parser it reads costs every other command nothing.
4480
4499
  */
4481
4500
  async function translatorFor(value, home) {
4482
4501
  if (value === void 0) return null;
4483
- const { loadDetector, openTranslator, translateTarget } = await import("./translate-BcbSWkuq.js");
4502
+ const { loadDetector, openTranslator, translateTarget } = await import("./translate-DnuQMfj0.js");
4484
4503
  return openTranslator({
4485
4504
  home,
4486
4505
  to: translateTarget(value),
@@ -4663,7 +4682,8 @@ function oneGroupOnly(method) {
4663
4682
  * payments), none from a chat's history: `wallet list` took 1.3 s and 239 MB instead of 0.48 s and 146 MB with 50,000
4664
4683
  * messages; `payment list --chat` starts the chat it names. `identity providers` reads nothing of the profile, and
4665
4684
  * `call auto` and `group auto` with no on|off what it keeps: each took 1.6 s and 211 MB instead of 0.8 s and 152 MB
4666
- * with 50,000.
4685
+ * with 50,000. `saved list` reads each saved row by its key, a quoted original by its id and the contact's name from
4686
+ * the chat's record: 1.2 s instead of 0.7 s with 30,000 messages, nothing saved.
4667
4687
  */
4668
4688
  var NO_HISTORY_READS = /* @__PURE__ */ new Set([
4669
4689
  "status",
@@ -4682,7 +4702,8 @@ var NO_HISTORY_READS = /* @__PURE__ */ new Set([
4682
4702
  "wallet.list",
4683
4703
  "wallet.history",
4684
4704
  "payment.list",
4685
- "identity.providers"
4705
+ "identity.providers",
4706
+ "saved.list"
4686
4707
  ]);
4687
4708
  /**
4688
4709
  * Changes kept outside any chat (this profile's status, which each chat says on its next session; x401 keys and
@@ -4820,13 +4841,18 @@ function answerWithin(method, params) {
4820
4841
  if (waits !== void 0) return (waits + 10) * 1e3;
4821
4842
  if (readOnly(method, params)) return ANSWER_MS;
4822
4843
  }
4823
- /** `again`: whether a read the daemon left unanswered as it stopped is asked once more (`throughDaemon`). */
4824
- async function session(g, options, again = true) {
4844
+ /**
4845
+ * `again`: whether a read the daemon left unanswered as it stopped is asked once more (`throughDaemon`). `first`: the
4846
+ * call a one-shot makes, whose own words are checked before the profile opens (api.ts `refuseBeforeStart`): a malformed
4847
+ * one opened it online and started every saved chat to be refused (with 10 chats, 20 relay requests and 0.4 s more).
4848
+ */
4849
+ async function session(g, options, again = true, first) {
4825
4850
  requireProfile(g);
4826
4851
  const anew = again ? () => session(g, options, false) : void 0;
4827
4852
  const client = await connectDaemon(g.paths);
4828
4853
  if (client) return throughDaemon(client, anew);
4829
- const [, { callApi, startNamedChats }] = await Promise.all([engineHost(), engineApi()]);
4854
+ const [, { callApi, refuseBeforeStart, startNamedChats }] = await Promise.all([engineHost(), engineApi()]);
4855
+ if (first) await refuseBeforeStart(first.method, first.params);
4830
4856
  const host = await openOneShot(g, options);
4831
4857
  if (host instanceof DaemonClient) return throughDaemon(host, anew);
4832
4858
  const call = async (m, p) => {
@@ -4971,8 +4997,8 @@ async function openOneShot(g, options = {}, mode = "one-shot") {
4971
4997
  * nothing of the groups, `deferChats` too when it names that chat or makes or joins a new one (`oneChatOnly`), `offline`
4972
4998
  * when it only reads or changes only this device (`offlineCall`).
4973
4999
  */
4974
- async function withSession(g, work, options = {}) {
4975
- const s = await session(g, options);
5000
+ async function withSession(g, work, options = {}, first) {
5001
+ const s = await session(g, options, true, first);
4976
5002
  const stops = interruptible(s);
4977
5003
  try {
4978
5004
  return await stops.run(work);
@@ -5021,13 +5047,17 @@ function interruptible(s) {
5021
5047
  });
5022
5048
  });
5023
5049
  const call = (method, params) => {
5050
+ const given = params ?? {};
5024
5051
  const entry = {
5025
5052
  method,
5026
- notice: waitNotice(method, params ?? {}, s.mode)
5053
+ notice: waitNotice(method, given, s.mode)
5027
5054
  };
5028
5055
  pending.add(entry);
5029
- const notice = entry.notice;
5030
- const timer = notice && process.stderr.isTTY ? setTimeout(() => process.stderr.write(`ghostly: ${notice.waiting}\n`), WAIT_NOTICE_MS) : void 0;
5056
+ const chat = entry.notice && longTextChat(method, given);
5057
+ if (chat) s.call("chat.get", { chat }).then((view) => {
5058
+ if (entry.notice) entry.notice = dhtOnlyNotice(entry.notice, given, view, s.mode);
5059
+ }, () => {});
5060
+ const timer = entry.notice && process.stderr.isTTY ? setTimeout(() => process.stderr.write(`ghostly: ${entry.notice.waiting}\n`), WAIT_NOTICE_MS) : void 0;
5031
5061
  return held(s.call(method, params).finally(() => {
5032
5062
  clearTimeout(timer);
5033
5063
  pending.delete(entry);
@@ -5215,7 +5245,7 @@ var SPECIAL = [
5215
5245
  field: o("list", "A field of the provider's form, name=value"),
5216
5246
  stdin: o("boolean", "Take the fields as name=value lines on stdin (a signer's link: out of ps and the shell's history)"),
5217
5247
  days: o("number", "How long the proof holds"),
5218
- timeout: o("number", "Seconds to wait for an approval")
5248
+ timeout: o("number", "Seconds to wait for an approval (default 300, 5 to 3600; Pubky at most 300)")
5219
5249
  }
5220
5250
  ],
5221
5251
  ["version", "This CLI's version (also ghostly --version)"]
@@ -5481,7 +5511,7 @@ async function profileCommand(sub, argv) {
5481
5511
  noMoreThan(1, parsed.positionals, "profile create <name> [--use] [--name <shown name>] [--force]");
5482
5512
  const shownName = parsed.options.name === void 0 ? void 0 : checkShownNameOption(parsed.options.name);
5483
5513
  const force = parsed.options.force === true;
5484
- if (shownName) (await import("./secretGuard-Bm6nci0I.js")).guardText(shownName, force, "name", "set it");
5514
+ if (shownName) (await import("./secretGuard-Bh11MPdI.js")).guardText(shownName, force, "name", "set it");
5485
5515
  const paths = createProfile(g.home, name);
5486
5516
  let shown = null;
5487
5517
  if (shownName !== void 0) try {
@@ -5581,7 +5611,7 @@ async function profileCommand(sub, argv) {
5581
5611
  if (!given || !name) throw new CliError("usage", `Missing <${given ? "new profile" : "file"}>: ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]`);
5582
5612
  noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
5583
5613
  const file = here(given);
5584
- const { backupFileProtection, restoreProfile } = await import("./backup-B56sQqoQ.js");
5614
+ const { backupFileProtection, restoreProfile } = await import("./backup-Di2U6QVH.js");
5585
5615
  const protection = await backupFileProtection(file);
5586
5616
  const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : await backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
5587
5617
  if (parsed.options.use) selectProfile(g.home, name);
@@ -6254,13 +6284,14 @@ async function listenCommand(argv) {
6254
6284
  };
6255
6285
  onStopSignals(stop);
6256
6286
  onReaderGone(stop);
6257
- let off = null, left = [];
6287
+ let off = null, left = [], gap;
6258
6288
  const open = (from) => {
6259
6289
  for (;;) {
6260
- const events = left.length ? left : host.ctx.hub.replay(from ?? host.ctx.hub.lastSeq);
6290
+ const events = (left.length ? left : host.ctx.hub.replay(from ?? host.ctx.hub.lastSeq)).filter((e) => e.type !== "events.gap" || e.id !== gap);
6261
6291
  left = [];
6262
6292
  if (!events.length) break;
6263
6293
  for (let i = 0; i < events.length; i++) {
6294
+ if (events[i].type === "events.gap") gap = events[i].id;
6264
6295
  feed.take(events[i]);
6265
6296
  if (feed.paused) {
6266
6297
  left = events.slice(i + 1);
@@ -6428,7 +6459,7 @@ async function textCommand(name, argv) {
6428
6459
  };
6429
6460
  if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
6430
6461
  if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
6431
- if (!spec.message) Object.assign(params, (await import("./buttons-CsN2WJOf.js")).buttonsOf(parsed.options));
6462
+ if (!spec.message) Object.assign(params, (await import("./buttons-YTYEqvGC.js")).buttonsOf(parsed.options));
6432
6463
  print(await withSession(g, (s) => {
6433
6464
  if (parsed.options.wait !== void 0) params.wait = parsed.options.wait;
6434
6465
  if (parsed.options.timeout !== void 0) params.timeout = parsed.options.timeout;
@@ -6472,20 +6503,23 @@ async function identityAddCommand(argv) {
6472
6503
  if (!provider) throw new CliError("usage", "Missing <provider>: ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]");
6473
6504
  inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
6474
6505
  const items = parsed.options.field ?? [];
6475
- const known = parsed.options.days !== void 0 || items.length ? (await import("./registry--Rg2YvOH.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
6506
+ const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-DAq16T-V.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
6476
6507
  if (known && parsed.options.days !== void 0) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
6477
6508
  const { fields, warning } = await identityFields(items, parsed.options.stdin === true, identitySecretFields(known, parsed.options.signer), readStdin, process.stdin.isTTY === true);
6478
6509
  if (warning) process.stderr.write(`ghostly: ${warning}\n`);
6510
+ const request = randomUUID();
6479
6511
  const params = {
6480
6512
  provider,
6481
6513
  subject: subject.join(" ") || void 0,
6482
6514
  signer: parsed.options.signer,
6483
6515
  fields,
6484
6516
  days: parsed.options.days,
6485
- timeout: parsed.options.timeout
6517
+ timeout: parsed.options.timeout,
6518
+ request
6486
6519
  };
6487
6520
  const tell = (event) => {
6488
- if (event.type === "identity.approval" || event.type === "identity.progress") process.stderr.write(JSON.stringify(event) + "\n");
6521
+ const lines = identityWaitLines(event, request, process.stderr.isTTY === true);
6522
+ if (lines) process.stderr.write(lines);
6489
6523
  };
6490
6524
  const addThroughDaemon = async (client) => {
6491
6525
  await warnVersion(client);
@@ -6504,7 +6538,8 @@ async function identityAddCommand(argv) {
6504
6538
  await addThroughDaemon(client);
6505
6539
  return;
6506
6540
  }
6507
- const [, { callApi }] = await Promise.all([engineHost(), engineApi()]);
6541
+ const [, { callApi, identityProvider }] = await Promise.all([engineHost(), engineApi()]);
6542
+ identityProvider(provider);
6508
6543
  const host = await openOneShot(g);
6509
6544
  if (host instanceof DaemonClient) {
6510
6545
  await addThroughDaemon(host);
@@ -6579,10 +6614,13 @@ async function tableCommand(name, argv) {
6579
6614
  deferGroups: chatOnly(command.method, params) || newChatOnly(command.method),
6580
6615
  deferChats: oneChatOnly(command.method, params) || oneGroupOnly(command.method) || readsNoHistory(command.method, params),
6581
6616
  offline: offlineCall(command.method, params)
6617
+ }, {
6618
+ method: command.method,
6619
+ params
6582
6620
  });
6583
6621
  if (translator) {
6584
6622
  try {
6585
- printAnswer(await (await import("./translate-BcbSWkuq.js")).translateAnswer(result, translator));
6623
+ printAnswer(await (await import("./translate-DnuQMfj0.js")).translateAnswer(result, translator));
6586
6624
  } finally {
6587
6625
  translator.close();
6588
6626
  }
@@ -6834,4 +6872,4 @@ async function run(argv) {
6834
6872
  }
6835
6873
  export { run };
6836
6874
 
6837
- //# sourceMappingURL=main-Dh7fePd8.js.map
6875
+ //# sourceMappingURL=main-Chc871HV.js.map