@ghostlytools/cli 1.10.5 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +27 -22
  2. package/SKILL.md +8 -5
  3. package/dist/assets/api-B-52sVYp.js +3 -0
  4. package/dist/assets/{api-DppWqAP3.js → api-CTqIcdu7.js} +532 -197
  5. package/dist/assets/api-CTqIcdu7.js.map +1 -0
  6. package/dist/assets/{apiKit-DFIho4Ev.js → apiKit-CZq4Lq4f.js} +97 -13
  7. package/dist/assets/apiKit-CZq4Lq4f.js.map +1 -0
  8. package/dist/assets/{apps-yBnbEtfV.js → apps-C_X0zgSG.js} +16 -4
  9. package/dist/assets/apps-C_X0zgSG.js.map +1 -0
  10. package/dist/assets/{apps-1MkGMH8m.js → apps-kRsY9S2S.js} +1 -1
  11. package/dist/assets/{arkade-bFAS6imn.js → arkade-_aaB7VbW.js} +2 -2
  12. package/dist/assets/{arkade-bFAS6imn.js.map → arkade-_aaB7VbW.js.map} +1 -1
  13. package/dist/assets/{backup-ejIX59o7.js → backup-DBg388Ke.js} +1 -1
  14. package/dist/assets/{backup-vj4J7M3e.js → backup-OTvrmk-w.js} +35 -7
  15. package/dist/assets/backup-OTvrmk-w.js.map +1 -0
  16. package/dist/assets/{blobFiles-XZ9PEXYy.js → blobFiles-BmsrvZc3.js} +3 -3
  17. package/dist/assets/{blobFiles-XZ9PEXYy.js.map → blobFiles-BmsrvZc3.js.map} +1 -1
  18. package/dist/assets/buttons-4EKtQl-7.js +2 -0
  19. package/dist/assets/{buttons-BoDMx3Ky.js → buttons-DUu7hxxT.js} +61 -30
  20. package/dist/assets/buttons-DUu7hxxT.js.map +1 -0
  21. package/dist/assets/{client-BQArefYa.js → client-DDpZP1R1.js} +55 -10
  22. package/dist/assets/client-DDpZP1R1.js.map +1 -0
  23. package/dist/assets/{codec-_MwTUz5E.js → codec-DrryGcPT.js} +2 -2
  24. package/dist/assets/{codec-_MwTUz5E.js.map → codec-DrryGcPT.js.map} +1 -1
  25. package/dist/assets/{envelope-CeZBNGX-.js → envelope-Q_rMgoE9.js} +2 -2
  26. package/dist/assets/{envelope-CeZBNGX-.js.map → envelope-Q_rMgoE9.js.map} +1 -1
  27. package/dist/assets/{irohWeb-C_Wnw7Q9.js → fedimintSdk-CqTeMdF0.js} +2 -354
  28. package/dist/assets/fedimintSdk-CqTeMdF0.js.map +1 -0
  29. package/dist/assets/{fileBytes-DqnfKIkj.js → fileBytes-B0z9A6Le.js} +2 -2
  30. package/dist/assets/{fileBytes-DqnfKIkj.js.map → fileBytes-B0z9A6Le.js.map} +1 -1
  31. package/dist/assets/{fileBytes-BABGEF13.js → fileBytes-BLPZq9YU.js} +3 -3
  32. package/dist/assets/{fileBytes-BABGEF13.js.map → fileBytes-BLPZq9YU.js.map} +1 -1
  33. package/dist/assets/{fileBytes-CQQK2uOh.js → fileBytes-BtIyoDF2.js} +1 -1
  34. package/dist/assets/{fileBytesIdb-DrXmDUSy.js → fileBytesIdb-Bmlrl9EO.js} +3 -3
  35. package/dist/assets/{fileBytesIdb-DrXmDUSy.js.map → fileBytesIdb-Bmlrl9EO.js.map} +1 -1
  36. package/dist/assets/fileBytesIdb-D8mAK4pF.js +2 -0
  37. package/dist/assets/{fileBytesOpfs-udKCzcLe.js → fileBytesOpfs-DBS0kbPT.js} +3 -3
  38. package/dist/assets/{fileBytesOpfs-udKCzcLe.js.map → fileBytesOpfs-DBS0kbPT.js.map} +1 -1
  39. package/dist/assets/{fixedHosts-B_2Rvyja.js → fixedHosts-BV5GDiTU.js} +3 -3
  40. package/dist/assets/{fixedHosts-B_2Rvyja.js.map → fixedHosts-BV5GDiTU.js.map} +1 -1
  41. package/dist/assets/{host-DFLzzKNr.js → host-BlUzZgQL.js} +336 -84
  42. package/dist/assets/host-BlUzZgQL.js.map +1 -0
  43. package/dist/assets/{hyperdhtRelay-CV6qMrom.js → hyperdhtRelay-BvI_uNZO.js} +2 -2
  44. package/dist/assets/{hyperdhtRelay-CV6qMrom.js.map → hyperdhtRelay-BvI_uNZO.js.map} +1 -1
  45. package/dist/assets/{idb-BHsAqENE.js → idb-CEuoNsTv.js} +16 -5
  46. package/dist/assets/idb-CEuoNsTv.js.map +1 -0
  47. package/dist/assets/{groupFiles-D-ZUUHrx.js → irohWeb-CqPN8VPY.js} +469 -16
  48. package/dist/assets/irohWeb-CqPN8VPY.js.map +1 -0
  49. package/dist/assets/{main-xO8MnXxD.js → main-vQjlgEnt.js} +409 -126
  50. package/dist/assets/main-vQjlgEnt.js.map +1 -0
  51. package/dist/assets/{mainline-Bx184Ixg.js → mainline-p6HOW7sb.js} +2 -2
  52. package/dist/assets/{mainline-Bx184Ixg.js.map → mainline-p6HOW7sb.js.map} +1 -1
  53. package/dist/assets/{networkReason-BlQhTbXk.js → networkReason-DMffkiJ6.js} +4 -4
  54. package/dist/assets/{networkReason-BlQhTbXk.js.map → networkReason-DMffkiJ6.js.map} +1 -1
  55. package/dist/assets/{nwc-B3-PHX0L.js → nwc-2vH18oNy.js} +4 -4
  56. package/dist/assets/nwc-2vH18oNy.js.map +1 -0
  57. package/dist/assets/{nwcProvider-BeQBPB2q.js → nwcProvider-DpeDy0bV.js} +11 -3
  58. package/dist/assets/nwcProvider-DpeDy0bV.js.map +1 -0
  59. package/dist/assets/{ownDid-DAzW-Urb.js → ownDid-iKz8u_fM.js} +2 -2
  60. package/dist/assets/{ownDid-DAzW-Urb.js.map → ownDid-iKz8u_fM.js.map} +1 -1
  61. package/dist/assets/{words-BvdNuw_v.js → ownStatus-BlRKnM5F.js} +56 -4
  62. package/dist/assets/ownStatus-BlRKnM5F.js.map +1 -0
  63. package/dist/assets/{profiles-Bg43mRXu.js → profiles-B5e0TyvS.js} +22 -12
  64. package/dist/assets/profiles-B5e0TyvS.js.map +1 -0
  65. package/dist/assets/{registry-CAk2-5BQ.js → registry-Cc_PQb3k.js} +1 -1
  66. package/dist/assets/{registry-BDnsZJBi.js → registry-CnFO2Pp5.js} +123 -99
  67. package/dist/assets/registry-CnFO2Pp5.js.map +1 -0
  68. package/dist/assets/{resolve-UAfshn6j.js → resolve-DI8uAM_Y.js} +2 -2
  69. package/dist/assets/{resolve-UAfshn6j.js.map → resolve-DI8uAM_Y.js.map} +1 -1
  70. package/dist/assets/{restoredRows-YhlbokEE.js → restoredRows-C3LcxmOw.js} +4 -4
  71. package/dist/assets/{restoredRows-YhlbokEE.js.map → restoredRows-C3LcxmOw.js.map} +1 -1
  72. package/dist/assets/{server-DYdR0_Fj.js → server-DdtPxkqI.js} +2057 -655
  73. package/dist/assets/server-DdtPxkqI.js.map +1 -0
  74. package/dist/assets/{src-BTRPAi5X.js → src-BnpEQqzk.js} +813 -144
  75. package/dist/assets/src-BnpEQqzk.js.map +1 -0
  76. package/dist/assets/{sshForges-KtHK5x1x.js → sshForges-cdIAraDw.js} +2 -2
  77. package/dist/assets/{sshForges-KtHK5x1x.js.map → sshForges-cdIAraDw.js.map} +1 -1
  78. package/dist/assets/{translate-CYuygrvA.js → translate-kNopA04L.js} +2 -2
  79. package/dist/assets/{translate-CYuygrvA.js.map → translate-kNopA04L.js.map} +1 -1
  80. package/dist/assets/{usdt-Dw9IENe_.js → usdt-CDaLhEYh.js} +3 -3
  81. package/dist/assets/{usdt-Dw9IENe_.js.map → usdt-CDaLhEYh.js.map} +1 -1
  82. package/dist/assets/{waitNotice-Ce3YCinu.js → waitNotice-Cn0WJ-He.js} +3 -1
  83. package/dist/assets/waitNotice-Cn0WJ-He.js.map +1 -0
  84. package/dist/ghostly.mjs +1 -1
  85. package/examples/claude-code-agent.sh +5 -0
  86. package/package.json +2 -2
  87. package/dist/assets/api-DppWqAP3.js.map +0 -1
  88. package/dist/assets/api-K-i5MrP-.js +0 -3
  89. package/dist/assets/apiKit-DFIho4Ev.js.map +0 -1
  90. package/dist/assets/apps-yBnbEtfV.js.map +0 -1
  91. package/dist/assets/backup-vj4J7M3e.js.map +0 -1
  92. package/dist/assets/buttons-BoDMx3Ky.js.map +0 -1
  93. package/dist/assets/buttons-DG1CKgAI.js +0 -2
  94. package/dist/assets/client-BQArefYa.js.map +0 -1
  95. package/dist/assets/fileBytesIdb-BtXATa7j.js +0 -2
  96. package/dist/assets/groupFiles-D-ZUUHrx.js.map +0 -1
  97. package/dist/assets/host-DFLzzKNr.js.map +0 -1
  98. package/dist/assets/idb-BHsAqENE.js.map +0 -1
  99. package/dist/assets/irohWeb-C_Wnw7Q9.js.map +0 -1
  100. package/dist/assets/main-xO8MnXxD.js.map +0 -1
  101. package/dist/assets/nwc-B3-PHX0L.js.map +0 -1
  102. package/dist/assets/nwcProvider-BeQBPB2q.js.map +0 -1
  103. package/dist/assets/profiles-Bg43mRXu.js.map +0 -1
  104. package/dist/assets/registry-BDnsZJBi.js.map +0 -1
  105. package/dist/assets/server-DYdR0_Fj.js.map +0 -1
  106. package/dist/assets/src-BTRPAi5X.js.map +0 -1
  107. package/dist/assets/waitNotice-Ce3YCinu.js.map +0 -1
  108. package/dist/assets/words-BvdNuw_v.js.map +0 -1
@@ -1,19 +1,19 @@
1
- import { Aa as VOICE_LIMITS, Co as cardLine, Do as statusCardBytes, _o as RUN_RESULTS, fo as CRON_LINE, go as ROUTINE_STATES, ho as PR_STATES, mo as PR_CHECKS, nr as GROUP_FILE_LIMITS, po as ITEM_STATES, vo as STATUS_CARD_LIMITS, wo as cardUrl, yo as TASK_STATUSES } from "./src-BTRPAi5X.js";
1
+ import { Co as PR_STATES, Do as TASK_STATUSES, Eo as STATUS_CARD_LIMITS, Fo as statusCardBytes, Mo as cardUrl, Ra as VOICE_LIMITS, So as PR_CHECKS, To as RUN_RESULTS, bo as CRON_LINE, jo as cardLine, nr as GROUP_FILE_LIMITS, qr as STATUS_AVAILABILITIES, wo as ROUTINE_STATES, xo as ITEM_STATES } from "./src-BnpEQqzk.js";
2
2
  import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-Dt-ZnyOX.js";
3
- 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, r as PAY_METHODS, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-BvdNuw_v.js";
4
- import { g as namedByThem, t as CONTACT_KEY } from "./apiKit-DFIho4Ev.js";
3
+ import { 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-BlRKnM5F.js";
4
+ import { t as CONTACT_KEY, v as nameKey, y as namedByThem } from "./apiKit-CZq4Lq4f.js";
5
5
  import { n as dropSecretEnv, t as childEnv } from "./childEnv-BVOQK9EA.js";
6
- import { a as checkShownName, b as ownProfile, c as ghostlyHome, f as noProfile, g as startingDaemon, h as selectProfile, i as checkProfileName, l as listProfiles, m as profilePaths, o as createProfile, p as profileExists, s as currentProfile, u as lockOwner, v as userPath } from "./profiles-Bg43mRXu.js";
7
- import { i as waitsFor, r as waitNotice } from "./waitNotice-Ce3YCinu.js";
8
- import { g as isCallRate, i as isNotTheDaemon, r as connectDaemon, t as DaemonClient, u as CALL_RATES } from "./client-BQArefYa.js";
6
+ import { i as waitsFor, r as waitNotice } from "./waitNotice-Cn0WJ-He.js";
7
+ import { _ as startingDaemon, c as currentProfile, d as lockOwner, g as selectProfile, h as profilePaths, i as checkProfileName, l as ghostlyHome, m as profileExists, o as checkShownNameOption, p as noProfile, s as createProfile, u as listProfiles, x as ownProfile, y as userPath } from "./profiles-B5e0TyvS.js";
8
+ import { _ as isCallRate, a as isNotTheDaemon, d as CALL_RATES, i as endedUnanswered, r as connectDaemon, t as DaemonClient } from "./client-DDpZP1R1.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
- import { dirname, resolve } from "node:path";
11
+ import { dirname, resolve, sep } from "node:path";
12
12
  import { connect } from "node:net";
13
13
  import { format } from "node:util";
14
14
  var package_default = {
15
15
  name: "@ghostlytools/cli",
16
- version: "1.10.5",
16
+ version: "1.11.0",
17
17
  type: "module",
18
18
  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
19
  license: "MIT",
@@ -60,7 +60,7 @@ var package_default = {
60
60
  "@secondts/bark": "0.25.0",
61
61
  "@serenity-kit/opaque": "1.1.0",
62
62
  "@synonymdev/pubky": "0.16.2",
63
- "@tetherto/wdk-wallet-evm": "1.0.0-beta.20",
63
+ "@tetherto/wdk-wallet-evm": "1.0.0-beta.24",
64
64
  "b4a": "1.9.0",
65
65
  "bittorrent-dht": "11.0.12",
66
66
  "ethers": "6.17.0",
@@ -87,6 +87,11 @@ var package_default = {
87
87
  //#endregion
88
88
  //#region src/args.ts
89
89
  /**
90
+ * A number as typed on the command line, in decimal digits only (`21`, `-5`, `12.5`); NaN for any other word.
91
+ * `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.
92
+ */
93
+ var decimalNumber = (value) => /^-?\d+(\.\d+)?$/.test(value) ? Number(value) : NaN;
94
+ /**
90
95
  * Options every command takes. They may come anywhere on the line.
91
96
  */
92
97
  var GLOBAL_OPTIONS = {
@@ -187,7 +192,7 @@ function parseArgs(argv, spec, idSlot = () => false, parsing) {
187
192
  value = argv[++i];
188
193
  }
189
194
  if (option.type === "number") {
190
- const number = value.trim() === "" ? NaN : Number(value);
195
+ const number = decimalNumber(value);
191
196
  if (!Number.isFinite(number)) throw new CliError("usage", `--${name} takes a number, not ${JSON.stringify(value)}`);
192
197
  options[name] = number;
193
198
  } else if (option.type === "list") options[name] = [...options[name] ?? [], value];
@@ -209,17 +214,24 @@ function parseArgs(argv, spec, idSlot = () => false, parsing) {
209
214
  * `Unknown option --wiat for ghostly send (did you mean --wait? ghostly help send)`. The `--` hint only where text comes
210
215
  * and for a word with one dash, which may be text (`-1`, `-x`): `version -x` has no text to put after `--`.
211
216
  */
212
- function unknownOption(arg, all, parsing) {
217
+ function unknownOption(arg, all, parsing, help = parsing ? `ghostly help ${parsing.command}` : void 0) {
213
218
  const names = Object.entries(all).flatMap(([name, o]) => o.type === "boolean" ? [name, `no-${name}`] : [name]);
214
219
  const near = nearest(arg.replace(/^--?/, ""), names);
215
220
  const hints = [
216
221
  ...near ? [`did you mean --${near}?`] : [],
217
222
  ...parsing?.text && /^-[^-]/.test(arg) ? ["put -- before text that starts with a dash;"] : [],
218
- ...parsing ? [`ghostly help ${parsing.command}`] : []
223
+ ...help ? [help] : []
219
224
  ];
220
225
  return new CliError("usage", `Unknown option ${arg}${parsing ? ` for ghostly ${parsing.command}` : ""}${hints.length ? ` (${hints.join(" ")})` : ""}`);
221
226
  }
222
227
  /**
228
+ * A first word that starts with a dash and is no global option (`ghostly --porfile bot send …`, `ghostly -x status`):
229
+ * `Unknown option --porfile (did you mean --profile? ghostly help)`, as after the command. Before, "Unknown command".
230
+ */
231
+ function unknownGlobalOption(arg) {
232
+ return unknownOption(arg.startsWith("--") ? arg.split("=")[0] : arg, GLOBAL_OPTIONS, void 0, "ghostly help");
233
+ }
234
+ /**
223
235
  * The word of `words` a typo most likely meant: the nearest by Damerau-Levenshtein distance (a letter added, dropped,
224
236
  * changed or two swapped), at most 2 and at most a third of the word's length (`wiat` one: `nope` is not `home`; `-x`
225
237
  * none), else undefined.
@@ -385,9 +397,9 @@ function refs(values, flag, what) {
385
397
  * number from 1 up, not -5`, a number as typed, other words quoted. Before: "Not an amount in sats: \"-5\"".
386
398
  */
387
399
  function sats(value) {
388
- const n = Number(value);
389
- if (!value || !Number.isSafeInteger(n) || n <= 0) {
390
- const shown = /^-?\d+(\.\d+)?$/.test(value ?? "") ? value : JSON.stringify(value);
400
+ const n = decimalNumber(value ?? "");
401
+ if (!Number.isSafeInteger(n) || n <= 0) {
402
+ const shown = Number.isNaN(n) ? JSON.stringify(value) : value;
391
403
  throw new CliError("usage", `<sats> takes a whole number from 1 up, not ${shown}`);
392
404
  }
393
405
  return n;
@@ -763,21 +775,24 @@ var MONTHS = [
763
775
  ];
764
776
  /** What `Date.parse` takes between a month's name and a number: `Apr 31`, `Apr-31`, `31/Apr`, `Apr.31`, `31 Apr,`. */
765
777
  var NAME_SEP = "[\\s,./-]*";
778
+ /** What `Date.parse` takes between two numbers of a date: `2026-4-31`, `2026/4/31`, `2026.4.31`, `2026, 4, 31`. */
779
+ var NUMBER_SEP = "[\\s,./-]+";
766
780
  var MONTH_DAY = new RegExp(`\\b(${MONTHS.join("|")})[a-z]*${NAME_SEP}(\\d{1,2})(?!\\d)`, "i");
767
781
  var DAY_MONTH = new RegExp(`(?<!\\d)(\\d{1,2})${NAME_SEP}(${MONTHS.join("|")})`, "i");
768
782
  /**
769
- * The year, month (1 to 12) and day a date is written with: `2026-04-31`, `2026/4/31`, `4/31/2026` (month first, as
770
- * `Date.parse` reads it, also with dashes or dots and a two-digit year), `Apr 31 2026`, `31-Apr-2026`. `Date.parse`
771
- * takes any day up to 31 and moves it past the month's end, so the day is checked here.
783
+ * The year, month (1 to 12) and day a date is written with: `2026-04-31`, `2026/4/31`, `2026.4.31`, `4/31/2026`
784
+ * (month first, as `Date.parse` reads it, also with a two-digit year), `Apr 31 2026`, `31-Apr-2026`. Between the numbers
785
+ * `Date.parse` takes dashes, slashes, dots, commas and spaces alike (`2026 4 31`), so these do too. `Date.parse` takes
786
+ * any day up to 31 and moves it past the month's end, so the day is checked here.
772
787
  */
773
788
  function writtenDay(text) {
774
- const numeric = /^([+-]\d{6}|\d{4})[-/](\d{1,2})[-/](\d{1,2})(?!\d)/.exec(text);
789
+ const numeric = new RegExp(`^([+-]\\d{6}|\\d{4})${NUMBER_SEP}(\\d{1,2})${NUMBER_SEP}(\\d{1,2})(?!\\d)`).exec(text);
775
790
  if (numeric) return [
776
791
  Number(numeric[1]),
777
792
  Number(numeric[2]),
778
793
  Number(numeric[3])
779
794
  ];
780
- const monthFirst = /^(\d{1,2})[-/.](\d{1,2})[-/.](\d{4}|\d{2})(?!\d)/.exec(text);
795
+ const monthFirst = new RegExp(`^(\\d{1,2})${NUMBER_SEP}(\\d{1,2})${NUMBER_SEP}(\\d{4}|\\d{2})(?!\\d)`).exec(text);
781
796
  const yy = (y) => y.length === 2 ? Number(y) + (Number(y) < 50 ? 2e3 : 1900) : Number(y);
782
797
  if (monthFirst) return [
783
798
  yy(monthFirst[3]),
@@ -1095,7 +1110,7 @@ var commands$8 = {
1095
1110
  description: "Replace the three files when they are there"
1096
1111
  }
1097
1112
  },
1098
- run: async ({ options }, a) => (await import("./apps-1MkGMH8m.js")).initApp(a.dir, {
1113
+ run: async ({ options }, a) => (await import("./apps-kRsY9S2S.js")).initApp(a.dir, {
1099
1114
  name: options.name,
1100
1115
  title: options.title,
1101
1116
  force: options.force === true
@@ -1135,7 +1150,7 @@ var commands$8 = {
1135
1150
  description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
1136
1151
  }
1137
1152
  },
1138
- run: async ({ options }, a) => (await import("./apps-1MkGMH8m.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1153
+ run: async ({ options }, a) => (await import("./apps-kRsY9S2S.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1139
1154
  },
1140
1155
  "app revoke": {
1141
1156
  method: "app.revoke",
@@ -1168,7 +1183,7 @@ var commands$8 = {
1168
1183
  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"
1169
1184
  }
1170
1185
  },
1171
- run: async ({ options }, a) => (await import("./apps-1MkGMH8m.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
1186
+ run: async ({ options }, a) => (await import("./apps-kRsY9S2S.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
1172
1187
  digests: options.digest,
1173
1188
  upTo: options["up-to"],
1174
1189
  reason: options.reason,
@@ -1229,7 +1244,7 @@ var commands$8 = {
1229
1244
  usage: "app verify <bundle|url>",
1230
1245
  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",
1231
1246
  args: ["bundle"],
1232
- run: async (_, a) => (await import("./apps-1MkGMH8m.js")).verifyApp(a.bundle)
1247
+ run: async (_, a) => (await import("./apps-kRsY9S2S.js")).verifyApp(a.bundle)
1233
1248
  },
1234
1249
  "store sign": {
1235
1250
  method: "store.sign",
@@ -1246,7 +1261,7 @@ var commands$8 = {
1246
1261
  description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
1247
1262
  }
1248
1263
  },
1249
- run: async ({ options }, a) => (await import("./apps-1MkGMH8m.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1264
+ run: async ({ options }, a) => (await import("./apps-kRsY9S2S.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1250
1265
  }
1251
1266
  };
1252
1267
  //#endregion
@@ -1617,7 +1632,7 @@ var commands$6 = {
1617
1632
  wait: {
1618
1633
  type: "string",
1619
1634
  choices: ["none", "sent"],
1620
- description: "none or sent: each text on its way (in a group, taken by an edge), each file's transfer done (default none)"
1635
+ description: "none or sent: each text on its way (in a group, taken by an edge), each file's transfer done (default none; without a daemon a group's waits for an edge)"
1621
1636
  },
1622
1637
  timeout: groupWait.timeout
1623
1638
  },
@@ -1661,7 +1676,7 @@ var commands$6 = {
1661
1676
  "message delete": {
1662
1677
  method: "chat.delete",
1663
1678
  usage: "message delete <chat|group> <message> [--everyone [--wait none|confirmed|sent] [--timeout s]]",
1664
- 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",
1679
+ summary: "Forget a message on this device (the contact keeps theirs; a waiting text of yours is cancelled, or deleted for everyone if a relay may have it); --everyone deletes one of yours, in a chat or a group, from every member's device",
1665
1680
  args: ["chat", "message"],
1666
1681
  options: {
1667
1682
  everyone: {
@@ -1712,7 +1727,7 @@ var commands$6 = {
1712
1727
  },
1713
1728
  "pin": {
1714
1729
  method: "chat.pin",
1715
- usage: "pin <chat|group> <message> | --remove [--wait none|confirmed] [--timeout s]",
1730
+ usage: "pin <chat|group> <message> | --remove [--wait none|confirmed|sent] [--timeout s]",
1716
1731
  summary: "Pin a message at the top of a chat or group (one per chat: it replaces the pinned one); --remove unpins",
1717
1732
  args: ["chat", "message...?"],
1718
1733
  options: {
@@ -1720,7 +1735,16 @@ var commands$6 = {
1720
1735
  type: "boolean",
1721
1736
  description: "Unpin the chat's pinned message (it names no message)"
1722
1737
  },
1723
- ...confirmWait
1738
+ wait: {
1739
+ type: "string",
1740
+ choices: [
1741
+ "none",
1742
+ "confirmed",
1743
+ "sent"
1744
+ ],
1745
+ description: "In a 1:1 chat none or confirmed, until the contact confirmed it; in a group none or sent, until a member's edge took it (default: none with a daemon, confirmed or sent without)"
1746
+ },
1747
+ timeout: groupWait.timeout
1724
1748
  },
1725
1749
  params: ({ options }, a) => {
1726
1750
  if (a.message === void 0 && options.remove !== true) throw new CliError("usage", "Missing <message>: ghostly pin <chat|group> <message> | --remove");
@@ -2060,11 +2084,12 @@ var commands$5 = {
2060
2084
  if (options.dir === "") throw new CliError("usage", "--dir needs a folder");
2061
2085
  if (options.dir !== void 0 && options.path !== void 0) throw new CliError("usage", "--path names the file: not with --dir");
2062
2086
  if (options.timeout !== void 0 && options.wait !== true) throw new CliError("usage", "--timeout is how long --wait waits: not without --wait");
2087
+ const path = here(options.path), folder = typeof options.path === "string" && (options.path.endsWith("/") || options.path.endsWith(sep)) && !path.endsWith(sep);
2063
2088
  return {
2064
2089
  chat: a.chat,
2065
2090
  file: a.file,
2066
2091
  dir: options.path === void 0 ? here(options.dir ?? ".") : void 0,
2067
- path: here(options.path),
2092
+ path: folder ? `${path}${sep}` : path,
2068
2093
  force: options.force === true,
2069
2094
  wait: options.wait === true ? true : void 0,
2070
2095
  timeout: timeout(options, LONG_WAIT_SECONDS)
@@ -2139,6 +2164,25 @@ var commands$5 = {
2139
2164
  };
2140
2165
  //#endregion
2141
2166
  //#region src/commands/general.ts
2167
+ /** `--until 30m`, `2h`, `1d`: that long from now. */
2168
+ var DURATION = /^(\d+)(m|h|d)$/;
2169
+ var UNIT_MS = {
2170
+ m: 6e4,
2171
+ h: 36e5,
2172
+ d: 864e5
2173
+ };
2174
+ /**
2175
+ * `status set --until`: a time to come, as long from now (30m, 2h, 1d) or as a card's time is written (milliseconds or a
2176
+ * date, local time when it names no zone), within a year. A time past is refused: the engine would take it as no status.
2177
+ */
2178
+ function statusUntil(value) {
2179
+ if (value === void 0) return void 0;
2180
+ const text = String(value).trim(), duration = DURATION.exec(text);
2181
+ const ms = duration ? Date.now() + Number(duration[1]) * UNIT_MS[duration[2]] : cardTime(text, "until");
2182
+ 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)}`);
2183
+ if (ms <= Date.now()) throw new CliError("usage", `--until takes a time to come, not ${JSON.stringify(value)}: a status that ended is none`);
2184
+ return ms;
2185
+ }
2142
2186
  /** The profile's status, its picture, the event journal: one entry per command, in alphabetical order (test/commands.test.ts checks). */
2143
2187
  var commands$4 = {
2144
2188
  "events": {
@@ -2176,6 +2220,53 @@ var commands$4 = {
2176
2220
  method: "status",
2177
2221
  usage: "status",
2178
2222
  summary: "The profile, its chats and whether a daemon runs it"
2223
+ },
2224
+ "status clear": {
2225
+ method: "status.clear",
2226
+ usage: "status clear",
2227
+ summary: "Take back the status contacts see (status set)"
2228
+ },
2229
+ "status set": {
2230
+ method: "status.set",
2231
+ usage: `status set [text...] [--emoji <emoji>] [--availability ${STATUS_AVAILABILITIES.join("|")}] [--until <time>] [--force]`,
2232
+ summary: "The status paired contacts see: a short text, one emoji, available, busy, away or dnd (Do not disturb), until a time; it replaces the one before",
2233
+ args: ["text...?"],
2234
+ options: {
2235
+ emoji: {
2236
+ type: "string",
2237
+ description: "One emoji, shown before the text"
2238
+ },
2239
+ availability: {
2240
+ type: "string",
2241
+ choices: STATUS_AVAILABILITIES,
2242
+ description: "available, busy, away or dnd (Do not disturb)"
2243
+ },
2244
+ until: {
2245
+ type: "string",
2246
+ description: `When it ends by itself, within a year: 30m, 2h or 1d from now, or milliseconds or a date: ${CARD_TIME_FORMS}`
2247
+ },
2248
+ force: {
2249
+ ...force,
2250
+ description: "Set a text that looks like a seed, a key or ecash"
2251
+ }
2252
+ },
2253
+ params: ({ options }, a) => {
2254
+ const input = {
2255
+ text: a.text,
2256
+ emoji: options.emoji,
2257
+ availability: options.availability,
2258
+ until: statusUntil(options.until)
2259
+ };
2260
+ return {
2261
+ ...checkOwnStatus(input, (field) => field === "text" ? "<text>" : `--${field}`, "usage"),
2262
+ ...options.force === true && { force: true }
2263
+ };
2264
+ }
2265
+ },
2266
+ "status show": {
2267
+ method: "status.get",
2268
+ usage: "status show",
2269
+ summary: "This profile's status (status set), or null when it has none"
2179
2270
  }
2180
2271
  };
2181
2272
  //#endregion
@@ -2206,6 +2297,27 @@ var commands$3 = {
2206
2297
  ...secret(options)
2207
2298
  })
2208
2299
  },
2300
+ "group auto": {
2301
+ method: "group.auto",
2302
+ usage: "group auto [on|off] [--from <chat>]...",
2303
+ summary: "Accept group invitations by themselves, only from the chats named (kept in the profile; the daemon accepts)",
2304
+ args: ["mode...?"],
2305
+ options: { from: {
2306
+ type: "list",
2307
+ 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)"
2308
+ } },
2309
+ params: ({ options }, a) => {
2310
+ 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>]...`);
2311
+ 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>");
2312
+ if (a.mode !== "on" && options.from !== void 0) throw new CliError("usage", "--from goes with on: ghostly group auto on --from <chat>");
2313
+ refs(options.from, "from", "chat");
2314
+ if (a.mode === void 0) return {};
2315
+ return a.mode === "on" ? {
2316
+ on: true,
2317
+ from: options.from
2318
+ } : { on: false };
2319
+ }
2320
+ },
2209
2321
  "group create": {
2210
2322
  method: "group.create",
2211
2323
  usage: "group create <name...> [--mesh] [--force]",
@@ -2366,7 +2478,7 @@ var commands$3 = {
2366
2478
  "group list": {
2367
2479
  method: "group.list",
2368
2480
  usage: "group list [--show-secret]",
2369
- summary: "Groups and invitations",
2481
+ summary: "Groups, invitations and auto-join",
2370
2482
  options: showSecret,
2371
2483
  params: ({ options }) => secret(options)
2372
2484
  },
@@ -2391,22 +2503,31 @@ var commands$3 = {
2391
2503
  },
2392
2504
  "group react": {
2393
2505
  method: "group.react",
2394
- usage: "group react <group> <message> <emoji> [--remove]",
2506
+ usage: "group react <group> <message> <emoji> [--remove] [--wait none|sent] [--timeout s]",
2395
2507
  summary: "React to a group's message with one emoji; --remove takes yours back",
2396
2508
  args: [
2397
2509
  "group",
2398
2510
  "message",
2399
2511
  "emoji...?"
2400
2512
  ],
2401
- options: { remove: {
2402
- type: "boolean",
2403
- description: "Take your reaction back"
2404
- } },
2513
+ options: {
2514
+ remove: {
2515
+ type: "boolean",
2516
+ description: "Take your reaction back"
2517
+ },
2518
+ wait: {
2519
+ ...groupWait.wait,
2520
+ description: "none or sent: until an edge took it (default: none with a daemon, sent without)"
2521
+ },
2522
+ timeout: groupWait.timeout
2523
+ },
2405
2524
  params: ({ options }, a) => ({
2406
2525
  group: a.group,
2407
2526
  message: a.message,
2408
2527
  emoji: a.emoji,
2409
- remove: options.remove === true
2528
+ remove: options.remove === true,
2529
+ wait: options.wait,
2530
+ timeout: timeout(options)
2410
2531
  })
2411
2532
  },
2412
2533
  "group remove": {
@@ -3341,7 +3462,7 @@ async function allowlist(from, groups, call, peerOf) {
3341
3462
  continue;
3342
3463
  }
3343
3464
  const chat = await otherFlag(call("chat.get", { chat: ref }), ref, "--from");
3344
- if (chat.id !== ref && chat.label?.toLowerCase() !== ref.toLowerCase()) throw namedByThem(ref, {
3465
+ if (chat.id !== ref && (!nameKey(ref) || nameKey(chat.label) !== nameKey(ref))) throw namedByThem(ref, {
3345
3466
  chat: chat.id,
3346
3467
  name: chat.peerName ?? null,
3347
3468
  contact: chat.peer
@@ -3365,12 +3486,20 @@ async function otherFlag(lookup, ref, flag) {
3365
3486
  throw new CliError("not_found", `${JSON.stringify(ref)} is a ${other}, not a ${flag === "--from" ? "chat" : "group"}: ghostly listen ${flag === "--from" ? "--group" : "--from"} ${shown}`, error.details);
3366
3487
  }
3367
3488
  }
3368
- /** The turn an event starts, or null: only a contact's message, and a group message that mentions this profile. */
3489
+ /**
3490
+ * Whether a group message is meant for this profile: it mentions it, or it presses a button of a question this profile
3491
+ * sent (`press` is set only on a press of mine, `buttonPress`). A press on another member's question is theirs to answer.
3492
+ */
3493
+ var forMe = (message) => !!message.mentioned || !!message.press;
3494
+ /**
3495
+ * The turn an event starts, or null: only a contact's message, and a group message that mentions this profile or
3496
+ * presses a button of its question.
3497
+ */
3369
3498
  function toTurn(event) {
3370
3499
  const message = event.message;
3371
3500
  if (!message || typeof message.text !== "string") return null;
3372
3501
  if (event.type === "message.received" && typeof event.chat === "string") return turn(event, "message.received", { chat: event.chat }, message);
3373
- if (event.type === "group.message" && typeof event.group === "string" && message.mentioned) return turn(event, "group.message", {
3502
+ if (event.type === "group.message" && typeof event.group === "string" && forMe(message)) return turn(event, "group.message", {
3374
3503
  group: event.group,
3375
3504
  ...message.member ? { member: message.member } : {}
3376
3505
  }, message);
@@ -3392,7 +3521,10 @@ function turn(event, source, where, message) {
3392
3521
  ...where,
3393
3522
  messageId,
3394
3523
  timestamp: message.timestamp,
3395
- ...message.press ? { press: message.press } : {},
3524
+ ...message.press ? { press: {
3525
+ ...message.press,
3526
+ by: where.chat ?? where.member ?? null
3527
+ } } : {},
3396
3528
  untrusted: {
3397
3529
  text: message.text,
3398
3530
  name: message.nick ?? null,
@@ -3570,28 +3702,72 @@ function checkTypes(types, warn) {
3570
3702
  function hookEnv(env) {
3571
3703
  return childEnv(env);
3572
3704
  }
3573
- /** Runs `command` through the shell with the event on stdin (never in its arguments); resolves with its exit code. */
3574
- function runExec(command, event) {
3575
- return new Promise((resolve) => {
3576
- const child = spawn(command, {
3577
- shell: true,
3578
- stdio: [
3579
- "pipe",
3580
- "inherit",
3581
- "inherit"
3582
- ],
3583
- env: {
3584
- ...hookEnv(process.env),
3585
- GHOSTLY_EVENT_TYPE: event.type,
3586
- GHOSTLY_EVENT_ID: event.id,
3587
- GHOSTLY_EVENT_SEQ: String(event.seq)
3705
+ /** How long a hook's stdout is still waited for once the hook exited: a process it left running may hold it open. */
3706
+ var HOOK_OUTPUT_GRACE_MS = 1e3;
3707
+ /**
3708
+ * Runs `command` through the shell with the event on stdin (never in its arguments).
3709
+ * `toStderr` (with `--print`, whose stdout is the JSON stream): the hook's stdout is streamed to listen's stderr, so a
3710
+ * hook that echoes never puts a line that is not an event into the stream. Piped as it comes, never held in memory.
3711
+ */
3712
+ function runExec(command, event, toStderr) {
3713
+ const group = process.platform !== "win32";
3714
+ const child = spawn(command, {
3715
+ shell: true,
3716
+ detached: group,
3717
+ stdio: [
3718
+ "pipe",
3719
+ toStderr ? "pipe" : "inherit",
3720
+ "inherit"
3721
+ ],
3722
+ env: {
3723
+ ...hookEnv(process.env),
3724
+ GHOSTLY_EVENT_TYPE: event.type,
3725
+ GHOSTLY_EVENT_ID: event.id,
3726
+ GHOSTLY_EVENT_SEQ: String(event.seq)
3727
+ }
3728
+ });
3729
+ const signal = (name) => {
3730
+ try {
3731
+ if (group && child.pid) process.kill(-child.pid, name);
3732
+ else child.kill(name);
3733
+ } catch {}
3734
+ };
3735
+ const orphaned = () => signal("SIGKILL");
3736
+ process.on("exit", orphaned);
3737
+ const ended = new Promise((resolve) => {
3738
+ let done = false;
3739
+ const finish = (end) => {
3740
+ if (!done) {
3741
+ done = true;
3742
+ resolve(end);
3588
3743
  }
3744
+ };
3745
+ child.on("error", () => finish({
3746
+ code: 127,
3747
+ signal: null
3748
+ }));
3749
+ child.on("exit", (code, name) => {
3750
+ const end = {
3751
+ code,
3752
+ signal: name
3753
+ };
3754
+ const output = child.stdout;
3755
+ if (!output || output.readableEnded || output.destroyed) return finish(end);
3756
+ const timer = setTimeout(() => finish(end), HOOK_OUTPUT_GRACE_MS);
3757
+ output.once("close", () => {
3758
+ clearTimeout(timer);
3759
+ finish(end);
3760
+ });
3589
3761
  });
3590
- child.on("error", () => resolve(127));
3591
- child.on("close", (code) => resolve(code ?? 1));
3592
- child.stdin.on("error", () => {});
3593
- child.stdin.end(JSON.stringify(event) + "\n");
3594
- });
3762
+ }).finally(() => process.off("exit", orphaned));
3763
+ child.stdout?.pipe(process.stderr, { end: false });
3764
+ child.stdin?.on("error", () => {});
3765
+ child.stdin?.end(JSON.stringify(event) + "\n");
3766
+ return {
3767
+ event,
3768
+ ended,
3769
+ signal
3770
+ };
3595
3771
  }
3596
3772
  /** The longest wait between two tries of a webhook that is not answering. */
3597
3773
  var RETRY_MAX_MS = 6e4;
@@ -3643,6 +3819,9 @@ function eventHandler(options) {
3643
3819
  let chain = Promise.resolve();
3644
3820
  let behind = 0;
3645
3821
  let stopped = false;
3822
+ /** The hook at work, if any. */
3823
+ let running = null;
3824
+ const slowMs = options.execSlowMs ?? 6e4, stopMs = options.stopMs ?? 5e3;
3646
3825
  /** The last event the cursor says, and the last one `--type` dropped while others were still being handled. */
3647
3826
  let kept = -1, dropped = -1;
3648
3827
  const keep = (seq) => {
@@ -3656,7 +3835,7 @@ function eventHandler(options) {
3656
3835
  };
3657
3836
  /** The cursor past events dropped meanwhile, once nothing before them is left to handle. */
3658
3837
  const keepDropped = () => {
3659
- if (behind > 0 || dropped <= kept) return;
3838
+ if (stopped || behind > 0 || dropped <= kept) return;
3660
3839
  try {
3661
3840
  keep(dropped);
3662
3841
  } catch (failed) {
@@ -3668,7 +3847,8 @@ function eventHandler(options) {
3668
3847
  const handle = (event) => {
3669
3848
  const seq = event.seq, type = event.type;
3670
3849
  if (stopped) return;
3671
- if (!matches(event, options.types)) {
3850
+ const gap = type === "events.gap";
3851
+ if (!gap && !matches(event, options.types)) {
3672
3852
  dropped = Math.max(dropped, seq);
3673
3853
  keepDropped();
3674
3854
  return;
@@ -3677,18 +3857,24 @@ function eventHandler(options) {
3677
3857
  chain = chain.then(async () => {
3678
3858
  if (stopped) return;
3679
3859
  const skip = () => keep(event.seq);
3680
- if (!matches(event, options.types)) return skip();
3681
3860
  if (options.allow && !await options.allow.allows(event)) return skip();
3682
3861
  if (options.translate) event = await options.translate(event);
3683
- if (options.turns) {
3862
+ if (options.turns && !gap) {
3684
3863
  const next = toTurn(event);
3685
3864
  if (!next) return skip();
3686
3865
  event = next;
3687
3866
  }
3688
3867
  const full = options.print && options.write(jsonOut(event)) === false;
3689
3868
  if (options.exec) {
3690
- const code = await runExec(options.exec, event);
3691
- if (code !== 0) process.stderr.write(`ghostly: --exec exited ${code} on event ${event.seq} (${event.type})\n`);
3869
+ const hook = running = runExec(options.exec, event, options.print);
3870
+ const slow = setTimeout(() => process.stderr.write(`ghostly: --exec still runs on event ${hook.event.seq} (${hook.event.type}) after ${Math.round(slowMs / 1e3)} s: the events after it wait for it\n`), slowMs);
3871
+ const { code, signal } = await hook.ended.finally(() => {
3872
+ clearTimeout(slow);
3873
+ running = null;
3874
+ });
3875
+ if (hook.stopped) return;
3876
+ if (signal) process.stderr.write(`ghostly: --exec was killed by ${signal} on event ${event.seq} (${event.type})\n`);
3877
+ else if (code !== 0) process.stderr.write(`ghostly: --exec exited ${code ?? 1} on event ${event.seq} (${event.type})\n`);
3692
3878
  }
3693
3879
  const answered = webhook ? await post(webhook, event, options.retryMs ?? 500) : true;
3694
3880
  if (webhook && answered !== true) process.stderr.write(`ghostly: the webhook at ${webhook.origin} answered ${answered}: event ${event.seq} (${event.type}) passed, not taken (a 4xx or a redirect is not tried again)\n`);
@@ -3710,9 +3896,27 @@ function eventHandler(options) {
3710
3896
  keepDropped();
3711
3897
  });
3712
3898
  };
3899
+ const within = (promise, ms) => Promise.race([promise.then(() => true), new Promise((resolve) => setTimeout(() => resolve(false), ms).unref())]);
3900
+ const stop = async () => {
3901
+ stopped = true;
3902
+ const hook = running;
3903
+ if (!hook) return;
3904
+ if (await within(hook.ended, stopMs)) {
3905
+ await within(chain, stopMs);
3906
+ return;
3907
+ }
3908
+ hook.stopped = true;
3909
+ process.stderr.write(`ghostly: stopped while --exec ran on event ${hook.event.seq} (${hook.event.type}): ended it, and the event is handed again at the next start\n`);
3910
+ hook.signal("SIGTERM");
3911
+ if (!await within(hook.ended, stopMs)) {
3912
+ hook.signal("SIGKILL");
3913
+ await hook.ended;
3914
+ }
3915
+ };
3713
3916
  return Object.assign(handle, {
3714
3917
  behind: () => behind,
3715
- idle: () => chain
3918
+ idle: () => chain,
3919
+ stop
3716
3920
  });
3717
3921
  }
3718
3922
  /**
@@ -4036,15 +4240,15 @@ var VERSION = package_default.version;
4036
4240
  * command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
4037
4241
  * cost every command ~100 ms before its socket was opened.
4038
4242
  */
4039
- var engineApi = () => import("./api-K-i5MrP-.js");
4040
- var engineHost = () => import("./host-DFLzzKNr.js");
4243
+ var engineApi = () => import("./api-B-52sVYp.js");
4244
+ var engineHost = () => import("./host-BlUzZgQL.js");
4041
4245
  /**
4042
4246
  * `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
4043
4247
  * asked: the app's message parser it reads costs every other command nothing.
4044
4248
  */
4045
4249
  async function translatorFor(value, home) {
4046
4250
  if (value === void 0) return null;
4047
- const { loadDetector, openTranslator, translateTarget } = await import("./translate-CYuygrvA.js");
4251
+ const { loadDetector, openTranslator, translateTarget } = await import("./translate-kNopA04L.js");
4048
4252
  return openTranslator({
4049
4253
  home,
4050
4254
  to: translateTarget(value),
@@ -4162,7 +4366,8 @@ function chatOnly(method, params) {
4162
4366
  /** A command whose `chat` may name a group as well: a one-shot for it starts the groups' sessions. */
4163
4367
  function chatOrGroup(method, params) {
4164
4368
  if (method.startsWith("task.") || method.startsWith("routine.") || method.startsWith("button.") || method === "usage.send") return true;
4165
- return method === "chat.delete" && params.everyone === true;
4369
+ if (method === "chat.delete" && params.everyone === true) return true;
4370
+ return method === "chat.pin" || method === "chat.forward";
4166
4371
  }
4167
4372
  /**
4168
4373
  * A command that makes a new chat and needs no other: a one-shot for it leaves the saved chats and the groups unstarted.
@@ -4213,18 +4418,20 @@ var READS = /* @__PURE__ */ new Set([
4213
4418
  "call.list",
4214
4419
  "app.served",
4215
4420
  "x401.credential.list",
4216
- "saved.list"
4421
+ "saved.list",
4422
+ "status.get"
4217
4423
  ]);
4218
4424
  /** Whether a one-shot for this call opens the profile offline; test/readOnlyCommands.test.ts names every table command. */
4219
4425
  function readOnly(method, params) {
4220
4426
  if (method === "engine.call") return typeof params.method === "string" && ENGINE_READS.includes(params.method);
4221
4427
  if (method === "call.auto") return params.on === void 0;
4428
+ if (method === "group.auto") return params.on === void 0;
4222
4429
  if (method === "chat.accept") return params.method === void 0;
4223
4430
  return READS.has(method);
4224
4431
  }
4225
4432
  /**
4226
4433
  * Calls whose change stays on this device: a chat's name here, a chat removed (nothing goes to the contact), auto-answer
4227
- * (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
4434
+ * (calls.json), auto-join (groups.json: a one-shot accepts nothing itself, the daemon does), 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
4228
4435
  * shared with a contact). Opened online, each put the profile's records on the relays and waited for them (6 PUT + 4
4229
4436
  * GET, 3.3 s with a relay that takes 1.5 s), and the contacts' apps saw this device come online. `message delete` stays
4230
4437
  * online: it settles a file offer already on the DHT.
@@ -4233,13 +4440,16 @@ var LOCAL_WRITES = /* @__PURE__ */ new Set([
4233
4440
  "chat.rename",
4234
4441
  "chat.remove",
4235
4442
  "call.auto",
4443
+ "group.auto",
4236
4444
  "identity.cancel",
4237
4445
  "service.add",
4238
4446
  "x401.key.new",
4239
4447
  "x401.credential.add",
4240
4448
  "x401.credential.remove",
4241
4449
  "saved.add",
4242
- "saved.remove"
4450
+ "saved.remove",
4451
+ "status.set",
4452
+ "status.clear"
4243
4453
  ]);
4244
4454
  /** Settings of this device only: no contact and no relay hears of them (nick, avatar and the relays' do). */
4245
4455
  var LOCAL_SETTINGS = /* @__PURE__ */ new Set([
@@ -4260,13 +4470,15 @@ function answerWithin(method, params) {
4260
4470
  if (waits !== void 0) return (waits + 10) * 1e3;
4261
4471
  if (readOnly(method, params)) return ANSWER_MS;
4262
4472
  }
4263
- async function session(g, options) {
4473
+ /** `again`: whether a read the daemon left unanswered as it stopped is asked once more (`throughDaemon`). */
4474
+ async function session(g, options, again = true) {
4264
4475
  requireProfile(g);
4476
+ const anew = again ? () => session(g, options, false) : void 0;
4265
4477
  const client = await connectDaemon(g.paths);
4266
- if (client) return throughDaemon(client);
4478
+ if (client) return throughDaemon(client, anew);
4267
4479
  const [, { callApi, startNamedChats }] = await Promise.all([engineHost(), engineApi()]);
4268
4480
  const host = await openOneShot(g, options);
4269
- if (host instanceof DaemonClient) return throughDaemon(host);
4481
+ if (host instanceof DaemonClient) return throughDaemon(host, anew);
4270
4482
  const call = (m, p) => {
4271
4483
  if (options.deferChats && p && typeof p === "object") startNamedChats(host.ctx, p);
4272
4484
  return callApi(host.ctx, m, p ?? {});
@@ -4278,9 +4490,31 @@ async function session(g, options) {
4278
4490
  abort: () => host.close()
4279
4491
  };
4280
4492
  }
4281
- function throughDaemon(client) {
4493
+ /**
4494
+ * Waits that change nothing (`chat wait`, `file wait`): one a daemon that stopped left unanswered is asked once more,
4495
+ * as a read is (`throughDaemon`), for the time it had left. They failed as a timeout told to check `ghostly chat
4496
+ * history` for a message (exit 4) when a restart came while they waited.
4497
+ */
4498
+ var READ_WAITS = /* @__PURE__ */ new Set(["chat.wait", "file.wait"]);
4499
+ /** `params` with the `timeout` (its own, or the daemon's default for `method`) less the `spentMs` already waited. */
4500
+ function waitLeft(method, params, spentMs) {
4501
+ const seconds = typeof params.timeout === "number" ? params.timeout : waitsFor(method, params);
4502
+ return seconds === void 0 ? params : {
4503
+ ...params,
4504
+ timeout: Math.max(1, Math.ceil(seconds - spentMs / 1e3))
4505
+ };
4506
+ }
4507
+ /**
4508
+ * `again`: a session of its own, for a read (`readOnly`, or one of `READ_WAITS`) whose connection ended unanswered
4509
+ * (`endedUnanswered`): the daemon stopped or restarted under it. The read is asked once more there, through the daemon
4510
+ * that answers now or on the profile itself, and so is every call after it. It failed as a timeout told to check
4511
+ * `ghostly chat history` for a message that was never sent (exit 4), as "The daemon went away" (exit 1), or refused as
4512
+ * a daemon of an older release (exit 1), while a command started a moment later answered.
4513
+ */
4514
+ function throughDaemon(client, again) {
4282
4515
  const warned = warnVersion(client);
4283
- const call = async (m, p) => {
4516
+ let next = null, aborted = false;
4517
+ const first = async (m, p) => {
4284
4518
  const timeoutMs = answerWithin(m, p ?? {});
4285
4519
  if (timeoutMs === void 0 && !await settlesWithin(warned, ANSWER_MS)) {
4286
4520
  client.destroy();
@@ -4288,15 +4522,38 @@ function throughDaemon(client) {
4288
4522
  }
4289
4523
  return client.call(m, p, { timeoutMs });
4290
4524
  };
4525
+ const call = async (m, p) => {
4526
+ if (next) return (await next).call(m, p);
4527
+ const from = performance.now();
4528
+ try {
4529
+ return await first(m, p);
4530
+ } catch (error) {
4531
+ const params = p ?? {};
4532
+ if (!again || aborted || !endedUnanswered(error) || !(readOnly(m, params) || READ_WAITS.has(m))) throw error;
4533
+ next ??= again();
4534
+ try {
4535
+ return await (await next).call(m, READ_WAITS.has(m) ? waitLeft(m, params, performance.now() - from) : p);
4536
+ } catch (failure) {
4537
+ if (endedUnanswered(failure) && !isNotTheDaemon(failure)) throw new CliError("unavailable", `The daemon went away before it answered ${m}, twice; a read changes nothing: run it again`, { method: m });
4538
+ throw failure;
4539
+ }
4540
+ }
4541
+ };
4542
+ const settled = async (then) => {
4543
+ if (next) await next.then(then, () => {});
4544
+ };
4291
4545
  return {
4292
4546
  mode: "daemon",
4293
4547
  call,
4294
4548
  close: async () => {
4295
4549
  await warned;
4296
4550
  client.close();
4551
+ await settled((s) => s.close());
4297
4552
  },
4298
4553
  abort: async () => {
4554
+ aborted = true;
4299
4555
  client.destroy();
4556
+ await settled((s) => s.abort());
4300
4557
  }
4301
4558
  };
4302
4559
  }
@@ -4315,7 +4572,7 @@ var STARTING_WAIT_MS = 3e4;
4315
4572
  */
4316
4573
  async function openOneShot(g, options = {}, mode = "one-shot") {
4317
4574
  const { openHost } = await engineHost();
4318
- const from = Date.now();
4575
+ const from = performance.now();
4319
4576
  for (;;) try {
4320
4577
  return await openHost(g.paths, mode, VERSION, options);
4321
4578
  } catch (error) {
@@ -4323,7 +4580,7 @@ async function openOneShot(g, options = {}, mode = "one-shot") {
4323
4580
  const starting = startingDaemon(g.paths);
4324
4581
  const client = await connectDaemon(g.paths);
4325
4582
  if (client) return client;
4326
- const left = from + (starting === null ? HOLDER_WAIT_MS : STARTING_WAIT_MS) - Date.now();
4583
+ const left = from + (starting === null ? HOLDER_WAIT_MS : STARTING_WAIT_MS) - performance.now();
4327
4584
  if (left <= 0) {
4328
4585
  if (starting !== null) throw new CliError("busy", `Profile ${g.profile} is in use by its daemon (process ${starting}), which was still starting after ${STARTING_WAIT_MS / 1e3} s: ghostly daemon status shows when it is up`, { pid: starting });
4329
4586
  const pid = error.details?.pid;
@@ -4548,7 +4805,7 @@ var SPECIAL = [
4548
4805
  ],
4549
4806
  [
4550
4807
  "settings get [--show-secret]",
4551
- "The profile's settings",
4808
+ "The profile's settings: each key settings set takes with its value in effect (unset: the default)",
4552
4809
  { "show-secret": o("boolean", "Show credentials too") }
4553
4810
  ],
4554
4811
  [
@@ -4819,7 +5076,7 @@ async function profileCommand(sub, argv) {
4819
5076
  const [name] = parsed.positionals;
4820
5077
  if (!name) throw new CliError("usage", "Missing <name>: ghostly profile create <name> [--use] [--name <shown name>] [--force]");
4821
5078
  noMoreThan(1, parsed.positionals, "profile create <name> [--use] [--name <shown name>] [--force]");
4822
- const shownName = parsed.options.name === void 0 ? void 0 : checkShownName(parsed.options.name);
5079
+ const shownName = parsed.options.name === void 0 ? void 0 : checkShownNameOption(parsed.options.name);
4823
5080
  const force = parsed.options.force === true;
4824
5081
  if (shownName) (await import("./secretGuard-DUr6bgKc.js")).guardText(shownName, force, "name", "set it");
4825
5082
  const paths = createProfile(g.home, name);
@@ -4877,7 +5134,10 @@ async function profileCommand(sub, argv) {
4877
5134
  case "set": {
4878
5135
  noMoreThan(0, parsed.positionals, "profile set [--name <name>] [--share-profile | --no-share-profile] [--force]");
4879
5136
  const params = {};
4880
- if (parsed.options.name !== void 0) params.name = parsed.options.name;
5137
+ if (parsed.options.name !== void 0) {
5138
+ checkShownNameOption(parsed.options.name);
5139
+ params.name = parsed.options.name;
5140
+ }
4881
5141
  if (parsed.options["share-profile"] !== void 0) params.shareProfile = parsed.options["share-profile"];
4882
5142
  if (!Object.keys(params).length) throw new CliError("usage", "Nothing to change: ghostly profile set [--name <name>] [--share-profile | --no-share-profile] [--force]");
4883
5143
  if (parsed.options.force === true) params.force = true;
@@ -4912,7 +5172,7 @@ async function profileCommand(sub, argv) {
4912
5172
  if (!given || !name) throw new CliError("usage", `Missing <${given ? "new profile" : "file"}>: ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]`);
4913
5173
  noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
4914
5174
  const file = here(given);
4915
- const { backupFileProtection, restoreProfile } = await import("./backup-ejIX59o7.js");
5175
+ const { backupFileProtection, restoreProfile } = await import("./backup-DBg388Ke.js");
4916
5176
  const protection = await backupFileProtection(file);
4917
5177
  const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
4918
5178
  if (parsed.options.use) selectProfile(g.home, name);
@@ -4986,16 +5246,17 @@ async function runDaemon(g, seconds) {
4986
5246
  delete process.env[DETACHED_CHILD];
4987
5247
  dropSecretEnv();
4988
5248
  const { keepServing, openHost, serve } = await engineHost();
4989
- const until = Date.now() + seconds * 1e3;
5249
+ const until = performance.now() + seconds * 1e3;
4990
5250
  let host;
4991
5251
  for (;;) {
4992
- if (await connectDaemon(g.paths)) throw new CliError("busy", `A daemon already runs profile ${g.profile}`);
5252
+ if (await connectDaemon(g.paths)) throw childAnswer(detached, new CliError("busy", `A daemon already runs profile ${g.profile}`));
4993
5253
  try {
4994
5254
  host = await openHost(g.paths, "daemon", VERSION);
4995
5255
  break;
4996
5256
  } catch (error) {
4997
- if (detached || !(error instanceof CliError) || error.code !== "busy" || Date.now() >= until) throw error;
4998
- await new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(100, until - Date.now()))));
5257
+ if (detached) throw childAnswer(detached, error);
5258
+ if (!(error instanceof CliError) || error.code !== "busy" || performance.now() >= until) throw error;
5259
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(100, until - performance.now()))));
4999
5260
  }
5000
5261
  }
5001
5262
  let served;
@@ -5003,7 +5264,7 @@ async function runDaemon(g, seconds) {
5003
5264
  served = await serve(host);
5004
5265
  } catch (error) {
5005
5266
  await host.close();
5006
- throw error;
5267
+ throw childAnswer(detached, error);
5007
5268
  }
5008
5269
  keepServing();
5009
5270
  const stop = stopper(async () => {
@@ -5024,6 +5285,18 @@ async function runDaemon(g, seconds) {
5024
5285
  lastSeq: host.ctx.hub.lastSeq
5025
5286
  });
5026
5287
  }
5288
+ /**
5289
+ * A detached child's answer carries its own pid (`child`): its parent reads it in `daemon.log`, where every daemon of
5290
+ * the profile writes, and another detach's child that lost the profile, or refused to start, writes there too.
5291
+ */
5292
+ function childAnswer(detached, error) {
5293
+ if (!detached) return error;
5294
+ const failure = asCliError(error);
5295
+ return new CliError(failure.code, failure.message, {
5296
+ ...failure.details,
5297
+ child: process.pid
5298
+ });
5299
+ }
5027
5300
  async function daemonCommand(argv) {
5028
5301
  const sub = argv[0] && !argv[0].startsWith("-") ? argv[0] : void 0;
5029
5302
  const parsed = parseArgs(sub ? argv.slice(1) : argv, {
@@ -5129,13 +5402,13 @@ async function daemonCommand(argv) {
5129
5402
  * failed busy and left the old code running.
5130
5403
  */
5131
5404
  async function startedDaemon(g, seconds) {
5132
- const until = Date.now() + seconds * 1e3;
5405
+ const until = performance.now() + seconds * 1e3;
5133
5406
  for (;;) {
5134
5407
  const pid = startingDaemon(g.paths);
5135
5408
  const client = await connectDaemon(g.paths);
5136
5409
  if (client) return client;
5137
5410
  if (pid === null) return null;
5138
- const left = until - Date.now();
5411
+ const left = until - performance.now();
5139
5412
  if (left <= 0) throw new CliError("timeout", `The daemon (process ${pid}) is still starting after ${seconds} s; ghostly daemon status shows when it is up`, { pid });
5140
5413
  await new Promise((resolve) => setTimeout(resolve, Math.min(100, left)));
5141
5414
  }
@@ -5171,9 +5444,9 @@ async function stopDaemon(g, client, seconds) {
5171
5444
  client.close();
5172
5445
  const running = () => lockOwner(g.paths) === pid || processAlive(pid);
5173
5446
  const gone = async () => {
5174
- const until = Date.now() + seconds * 1e3;
5447
+ const until = performance.now() + seconds * 1e3;
5175
5448
  while (running()) {
5176
- const left = until - Date.now();
5449
+ const left = until - performance.now();
5177
5450
  if (left <= 0) break;
5178
5451
  await new Promise((resolve) => setTimeout(resolve, Math.min(100, left)));
5179
5452
  }
@@ -5225,18 +5498,18 @@ function processAlive(pid) {
5225
5498
  async function startDetached(g, seconds) {
5226
5499
  requireProfile(g);
5227
5500
  ownProfile(g.paths.dir);
5228
- const until = Date.now() + seconds * 1e3;
5501
+ const until = performance.now() + seconds * 1e3;
5229
5502
  for (;;) {
5230
5503
  if (await connectDaemon(g.paths)) throw new CliError("busy", `A daemon already runs profile ${g.profile}`);
5231
5504
  if (lockOwner(g.paths) === null) {
5232
5505
  const started = await spawnDaemon(g, until);
5233
5506
  if (started) return started;
5234
5507
  }
5235
- if (Date.now() >= until) {
5508
+ if (performance.now() >= until) {
5236
5509
  heldBy(g);
5237
5510
  throw new CliError("engine", `The daemon did not start; see ${g.paths.log}`);
5238
5511
  }
5239
- await new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(100, until - Date.now()))));
5512
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(100, until - performance.now()))));
5240
5513
  }
5241
5514
  }
5242
5515
  /** `startDetached`'s child, or null when another process took the profile ahead of it and there is time to try again. */
@@ -5270,19 +5543,28 @@ async function spawnDaemon(g, until) {
5270
5543
  });
5271
5544
  let client = null;
5272
5545
  while (child.exitCode === null && child.signalCode === null && !spawned.error) {
5273
- const left = until - Date.now();
5546
+ const left = until - performance.now();
5274
5547
  if (left <= 0) break;
5275
5548
  client = await connectDaemon(g.paths, Math.min(500, left));
5276
5549
  if (client) break;
5277
- await new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(200, until - Date.now()))));
5550
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(200, until - performance.now()))));
5278
5551
  }
5279
5552
  if (!client) {
5280
- if (!spawned.error && (![null, child.pid].includes(lockOwner(g.paths)) || lostTheProfile(g.paths.log, logFrom)) && Date.now() < until) return null;
5553
+ const answer = !spawned.error && child.exitCode !== null && child.pid !== void 0 ? childAnswerIn(g.paths.log, logFrom, child.pid) : null;
5554
+ if (!spawned.error && child.exitCode === EXIT.busy && child.pid !== void 0 && (![null, child.pid].includes(lockOwner(g.paths)) || answer?.code === "busy") && performance.now() < until) return null;
5281
5555
  heldBy(g, child.pid);
5282
5556
  if (child.exitCode === null && child.signalCode === null && child.pid !== void 0 && processAlive(child.pid)) throw new CliError("timeout", `The daemon (process ${child.pid}) is still starting; ghostly daemon status shows when it is up`, {
5283
5557
  pid: child.pid,
5284
5558
  log: g.paths.log
5285
5559
  });
5560
+ if (answer) {
5561
+ const details = {
5562
+ ...answer.details,
5563
+ log: g.paths.log
5564
+ };
5565
+ delete details.child;
5566
+ throw new CliError(answer.code, answer.message, details);
5567
+ }
5286
5568
  throw new CliError("engine", spawned.error ? `The daemon could not be spawned: ${spawned.error.message}` : `The daemon did not start; see ${g.paths.log}`);
5287
5569
  }
5288
5570
  client.close();
@@ -5294,23 +5576,27 @@ async function spawnDaemon(g, until) {
5294
5576
  log: g.paths.log
5295
5577
  };
5296
5578
  }
5297
- /** Whether a daemon's answer written to the log from byte `from` on is `busy`: it found the profile taken. */
5298
- function lostTheProfile(log, from) {
5579
+ /**
5580
+ * The error the detached child `pid` answered with, as it wrote it to the log from byte `from` on: `busy` when it found
5581
+ * the profile taken, its refusal when it did not start. Another child's line (a detach started at the same time) is
5582
+ * not its own. Null when it wrote none (a crash, a signal).
5583
+ */
5584
+ function childAnswerIn(log, from, pid) {
5299
5585
  let fd;
5300
5586
  try {
5301
5587
  fd = openSync(log, "r");
5302
5588
  } catch {
5303
- return false;
5589
+ return null;
5304
5590
  }
5305
5591
  try {
5306
5592
  const buffer = Buffer.alloc(65536);
5307
- return buffer.subarray(0, readSync(fd, buffer, 0, buffer.length, from)).toString("utf8").split("\n").some((line) => {
5308
- try {
5309
- return JSON.parse(line).error?.code === "busy";
5310
- } catch {
5311
- return false;
5312
- }
5313
- });
5593
+ const text = buffer.subarray(0, readSync(fd, buffer, 0, buffer.length, from)).toString("utf8");
5594
+ for (const line of text.split("\n")) try {
5595
+ const { error } = JSON.parse(line);
5596
+ if (error?.details?.child !== pid || typeof error.code !== "string" || !Object.hasOwn(EXIT, error.code) || typeof error.message !== "string") continue;
5597
+ return new CliError(error.code, error.message, error.details);
5598
+ } catch {}
5599
+ return null;
5314
5600
  } finally {
5315
5601
  closeSync(fd);
5316
5602
  }
@@ -5441,10 +5727,10 @@ async function listenCommand(argv) {
5441
5727
  throw error;
5442
5728
  });
5443
5729
  const following = followDaemon(g.paths, client, handle, since$1, PAUSE_HOLD_MS, g.profile);
5444
- const stop = () => {
5730
+ const stop = stopper(async () => {
5445
5731
  following.close();
5446
- process.exit(0);
5447
- };
5732
+ await handle.stop();
5733
+ });
5448
5734
  quit = (code) => {
5449
5735
  following.close();
5450
5736
  process.exit(code);
@@ -5468,12 +5754,13 @@ async function listenCommand(argv) {
5468
5754
  });
5469
5755
  keepServing();
5470
5756
  const stop = stopper(async () => {
5757
+ await handle.stop();
5471
5758
  await served.close();
5472
5759
  await host.close();
5473
5760
  });
5474
5761
  quit = (code) => {
5475
5762
  setTimeout(() => process.exit(code), 2e4).unref();
5476
- served.close().then(() => host.close()).finally(() => process.exit(code));
5763
+ handle.stop().then(() => served.close()).then(() => host.close()).finally(() => process.exit(code));
5477
5764
  };
5478
5765
  host.ctx.listen = true;
5479
5766
  host.ctx.stop = () => {
@@ -5651,15 +5938,10 @@ async function textCommand(name, argv) {
5651
5938
  };
5652
5939
  if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
5653
5940
  if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
5654
- if (!spec.message) Object.assign(params, (await import("./buttons-DG1CKgAI.js")).buttonsOf(parsed.options));
5941
+ if (!spec.message) Object.assign(params, (await import("./buttons-4EKtQl-7.js")).buttonsOf(parsed.options));
5655
5942
  print(await withSession(g, (s) => {
5656
- if (spec.target === "chat") {
5657
- params.wait = parsed.options.wait ?? (s.mode === "one-shot" ? spec.message ? "confirmed" : "sent" : "none");
5658
- if (parsed.options.timeout !== void 0) params.timeout = parsed.options.timeout;
5659
- } else {
5660
- if (parsed.options.wait !== void 0) params.wait = parsed.options.wait;
5661
- if (parsed.options.timeout !== void 0) params.timeout = parsed.options.timeout;
5662
- }
5943
+ if (parsed.options.wait !== void 0) params.wait = parsed.options.wait;
5944
+ if (parsed.options.timeout !== void 0) params.timeout = parsed.options.timeout;
5663
5945
  return s.call(spec.method, params);
5664
5946
  }, {
5665
5947
  deferGroups: spec.target === "chat",
@@ -5700,7 +5982,7 @@ async function identityAddCommand(argv) {
5700
5982
  if (!provider) throw new CliError("usage", "Missing <provider>: ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]");
5701
5983
  inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
5702
5984
  const items = parsed.options.field ?? [];
5703
- const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-CAk2-5BQ.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
5985
+ const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-Cc_PQb3k.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
5704
5986
  if (known && parsed.options.days !== void 0) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
5705
5987
  const { fields, warning } = await identityFields(items, parsed.options.stdin === true, identitySecretFields(known, parsed.options.signer), readStdin, process.stdin.isTTY === true);
5706
5988
  if (warning) process.stderr.write(`ghostly: ${warning}\n`);
@@ -5811,7 +6093,7 @@ async function tableCommand(name, argv) {
5811
6093
  });
5812
6094
  if (translator) {
5813
6095
  try {
5814
- printAnswer(await (await import("./translate-CYuygrvA.js")).translateAnswer(result, translator));
6096
+ printAnswer(await (await import("./translate-kNopA04L.js")).translateAnswer(result, translator));
5815
6097
  } finally {
5816
6098
  translator.close();
5817
6099
  }
@@ -5968,6 +6250,7 @@ async function main(input) {
5968
6250
  await tableCommand(first, argv.slice(1));
5969
6251
  return 0;
5970
6252
  }
6253
+ if (first.startsWith("-") && first !== "-" && first !== "--") throw unknownGlobalOption(first);
5971
6254
  throw unknownCommand(first, two ? second : void 0, three ? third : void 0);
5972
6255
  }
5973
6256
  /**
@@ -6036,4 +6319,4 @@ async function run(argv) {
6036
6319
  //#endregion
6037
6320
  export { run };
6038
6321
 
6039
- //# sourceMappingURL=main-xO8MnXxD.js.map
6322
+ //# sourceMappingURL=main-vQjlgEnt.js.map