@ghostlytools/cli 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +15 -8
  2. package/dist/assets/{api-BIqr8SpM.js → api-CD9JbPuA.js} +99 -28
  3. package/dist/assets/api-CD9JbPuA.js.map +1 -0
  4. package/dist/assets/{api-BnCmJLiQ.js → api-CJM3R93b.js} +2 -2
  5. package/dist/assets/{apiKit-CWalYh1t.js → apiKit-BmnROpCN.js} +8 -4
  6. package/dist/assets/{apiKit-CWalYh1t.js.map → apiKit-BmnROpCN.js.map} +1 -1
  7. package/dist/assets/{apps-_hVUaHIT.js → apps-CJ2dvKSz.js} +1 -1
  8. package/dist/assets/{apps-Bx3tXbJ9.js → apps-DVA60Tg6.js} +34 -11
  9. package/dist/assets/apps-DVA60Tg6.js.map +1 -0
  10. package/dist/assets/{arkade-AxrcyS1C.js → arkade-CHqwEHFd.js} +2 -2
  11. package/dist/assets/{arkade-AxrcyS1C.js.map → arkade-CHqwEHFd.js.map} +1 -1
  12. package/dist/assets/{backup-Y1V1Yxqr.js → backup-B4dSNvzb.js} +5 -5
  13. package/dist/assets/{backup-Y1V1Yxqr.js.map → backup-B4dSNvzb.js.map} +1 -1
  14. package/dist/assets/{backup-d_XvXpEK.js → backup-C4CbTEcj.js} +1 -1
  15. package/dist/assets/{blobFiles-B6nf0gCG.js → blobFiles-Bckz9fjp.js} +2 -2
  16. package/dist/assets/{blobFiles-B6nf0gCG.js.map → blobFiles-Bckz9fjp.js.map} +1 -1
  17. package/dist/assets/buttons-BMVGYXpR.js +2 -0
  18. package/dist/assets/{buttons-BiQyQBb0.js → buttons-C13rK2mH.js} +3 -3
  19. package/dist/assets/{buttons-BiQyQBb0.js.map → buttons-C13rK2mH.js.map} +1 -1
  20. package/dist/assets/{daemonProof-ui8jtIw0.js → daemonProof-B41oSfon.js} +2 -2
  21. package/dist/assets/{daemonProof-ui8jtIw0.js.map → daemonProof-B41oSfon.js.map} +1 -1
  22. package/dist/assets/{envelope-D3oeVhv8.js → envelope-4TXDx3vD.js} +2 -2
  23. package/dist/assets/{envelope-D3oeVhv8.js.map → envelope-4TXDx3vD.js.map} +1 -1
  24. package/dist/assets/{fileBytes-BMEBas7S.js → fileBytes-BD0v3rRG.js} +10 -2
  25. package/dist/assets/{fileBytes-BMEBas7S.js.map → fileBytes-BD0v3rRG.js.map} +1 -1
  26. package/dist/assets/{fileBytes-CtwagJ8h.js → fileBytes-OolN5cSY.js} +1 -1
  27. package/dist/assets/{fileBytes-CFNrRfcl.js → fileBytes-_fd-2JRY.js} +2 -2
  28. package/dist/assets/{fileBytes-CFNrRfcl.js.map → fileBytes-_fd-2JRY.js.map} +1 -1
  29. package/dist/assets/fileBytesIdb-CsSQcSxD.js +2 -0
  30. package/dist/assets/{fileBytesIdb-BXAN7i-N.js → fileBytesIdb-NtA8r9EM.js} +2 -2
  31. package/dist/assets/{fileBytesIdb-BXAN7i-N.js.map → fileBytesIdb-NtA8r9EM.js.map} +1 -1
  32. package/dist/assets/{fileBytesOpfs-Do1Vpkis.js → fileBytesOpfs-B8fJwkwM.js} +3 -3
  33. package/dist/assets/{fileBytesOpfs-Do1Vpkis.js.map → fileBytesOpfs-B8fJwkwM.js.map} +1 -1
  34. package/dist/assets/{ghostly_iroh_web-BXCsSxxo.js → ghostly_iroh_web-CO0onry8.js} +33 -27
  35. package/dist/assets/ghostly_iroh_web-CO0onry8.js.map +1 -0
  36. package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
  37. package/dist/assets/{groupFiles-DU1wMGI9.js → groupFiles-ajZgZ6P8.js} +41 -25
  38. package/dist/assets/groupFiles-ajZgZ6P8.js.map +1 -0
  39. package/dist/assets/{host-DDMQfR7B.js → host-CVeNtA2_.js} +43 -20
  40. package/dist/assets/host-CVeNtA2_.js.map +1 -0
  41. package/dist/assets/{hyperdhtRelay-B2v8eqRd.js → hyperdhtRelay-CI2ISE-g.js} +2 -2
  42. package/dist/assets/{hyperdhtRelay-B2v8eqRd.js.map → hyperdhtRelay-CI2ISE-g.js.map} +1 -1
  43. package/dist/assets/{irohWeb-9RVIbF_l.js → irohWeb-DcRJdhce.js} +3 -3
  44. package/dist/assets/{irohWeb-9RVIbF_l.js.map → irohWeb-DcRJdhce.js.map} +1 -1
  45. package/dist/assets/{main-BNwNEPEy.js → main-CjO0KGiF.js} +218 -70
  46. package/dist/assets/main-CjO0KGiF.js.map +1 -0
  47. package/dist/assets/{mainline-RXv5_Fby.js → mainline-WM-WItCV.js} +27 -8
  48. package/dist/assets/mainline-WM-WItCV.js.map +1 -0
  49. package/dist/assets/{networkReason-CIn4yN9h.js → networkReason-380j5yMs.js} +2 -2
  50. package/dist/assets/{networkReason-CIn4yN9h.js.map → networkReason-380j5yMs.js.map} +1 -1
  51. package/dist/assets/{nwc-BNPzuT-6.js → nwc-D5dkC1xg.js} +3 -3
  52. package/dist/assets/{nwc-BNPzuT-6.js.map → nwc-D5dkC1xg.js.map} +1 -1
  53. package/dist/assets/{nwcProvider-C9Y6PUNC.js → nwcProvider-p_rMwtDv.js} +2 -2
  54. package/dist/assets/{nwcProvider-C9Y6PUNC.js.map → nwcProvider-p_rMwtDv.js.map} +1 -1
  55. package/dist/assets/{profiles-CEnZfN78.js → profiles-BFd0tpCZ.js} +91 -19
  56. package/dist/assets/profiles-BFd0tpCZ.js.map +1 -0
  57. package/dist/assets/{registry-DOkDhUAu.js → registry-BKffx4ZU.js} +1 -1
  58. package/dist/assets/{registry-B9aYHNNf.js → registry-BfNcA6kF.js} +3 -3
  59. package/dist/assets/{registry-B9aYHNNf.js.map → registry-BfNcA6kF.js.map} +1 -1
  60. package/dist/assets/{resolve-imkCgogd.js → resolve-hUsgRkmm.js} +2 -2
  61. package/dist/assets/{resolve-imkCgogd.js.map → resolve-hUsgRkmm.js.map} +1 -1
  62. package/dist/assets/{server-CB9_JuWZ.js → server-C3tJZFnv.js} +422 -149
  63. package/dist/assets/server-C3tJZFnv.js.map +1 -0
  64. package/dist/assets/{src-BBG_NwMc.js → src-BMHgbkli.js} +219 -62
  65. package/dist/assets/src-BMHgbkli.js.map +1 -0
  66. package/dist/assets/{translate-BcP139SV.js → translate-DJUutSis.js} +2 -2
  67. package/dist/assets/{translate-BcP139SV.js.map → translate-DJUutSis.js.map} +1 -1
  68. package/dist/assets/types-C4_KafL_.js.map +1 -1
  69. package/dist/assets/{usdt-C5Gf9-IC.js → usdt-glkUxsDe.js} +3 -3
  70. package/dist/assets/{usdt-C5Gf9-IC.js.map → usdt-glkUxsDe.js.map} +1 -1
  71. package/dist/assets/{words-ZUiQo4yo.js → words-DyW9b27T.js} +2 -2
  72. package/dist/assets/{words-ZUiQo4yo.js.map → words-DyW9b27T.js.map} +1 -1
  73. package/dist/ghostly.mjs +1 -1
  74. package/package.json +1 -1
  75. package/dist/assets/api-BIqr8SpM.js.map +0 -1
  76. package/dist/assets/apps-Bx3tXbJ9.js.map +0 -1
  77. package/dist/assets/buttons-LO3Ql1Hd.js +0 -2
  78. package/dist/assets/fileBytesIdb-C20oXDdr.js +0 -2
  79. package/dist/assets/ghostly_iroh_web-BXCsSxxo.js.map +0 -1
  80. package/dist/assets/groupFiles-DU1wMGI9.js.map +0 -1
  81. package/dist/assets/host-DDMQfR7B.js.map +0 -1
  82. package/dist/assets/main-BNwNEPEy.js.map +0 -1
  83. package/dist/assets/mainline-RXv5_Fby.js.map +0 -1
  84. package/dist/assets/profiles-CEnZfN78.js.map +0 -1
  85. package/dist/assets/server-CB9_JuWZ.js.map +0 -1
  86. package/dist/assets/src-BBG_NwMc.js.map +0 -1
@@ -1,9 +1,9 @@
1
- import { Ga as ITEM_STATES, Ja as ROUTINE_STATES, Ka as PR_CHECKS, Wa as CRON_LINE, Wn as GROUP_FILE_LIMITS, Xa as STATUS_CARD_LIMITS, Ya as RUN_RESULTS, Za as TASK_STATUSES, da as VOICE_LIMITS, eo as cardLine, qa as PR_STATES, to as cardUrl } from "./src-BBG_NwMc.js";
2
- import { a as WALLET_TYPES, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, n as CHAT_METHODS, o as turnRef, p as SECRET_RESULTS, r as PAY_METHODS, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-ZUiQo4yo.js";
1
+ import { Ga as ITEM_STATES, Ja as ROUTINE_STATES, Ka as PR_CHECKS, Wa as CRON_LINE, Wn as GROUP_FILE_LIMITS, Xa as STATUS_CARD_LIMITS, Ya as RUN_RESULTS, Za as TASK_STATUSES, da as VOICE_LIMITS, eo as cardLine, io as statusCardBytes, qa as PR_STATES, to as cardUrl } from "./src-BMHgbkli.js";
2
+ import { a as WALLET_TYPES, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, n as CHAT_METHODS, o as turnRef, p as SECRET_RESULTS, r as PAY_METHODS, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-DyW9b27T.js";
3
3
  import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-CzXgR8Cc.js";
4
- import { t as CONTACT_KEY } from "./apiKit-CWalYh1t.js";
5
- import { _ as ownSocket, a as checkShownName, c as ghostlyHome, f as profileExists, h as userPath, i as checkProfileName, l as listProfiles, m as selectProfile, o as createProfile, p as profilePaths, s as currentProfile, u as lockOwner } from "./profiles-CEnZfN78.js";
6
- import { _ as isCallRate, a as newNonce, c as provesGreeting, d as CALL_RATES, l as readDaemonSecret, n as daemonOfThisRelease, s as provesDaemon, t as HELLO } from "./daemonProof-ui8jtIw0.js";
4
+ import { p as namedByThem, t as CONTACT_KEY } from "./apiKit-BmnROpCN.js";
5
+ import { _ as ownSocket, a as checkShownName, c as ghostlyHome, f as profileExists, h as userPath, i as checkProfileName, l as listProfiles, m as selectProfile, o as createProfile, p as profilePaths, s as currentProfile, u as lockOwner } from "./profiles-BFd0tpCZ.js";
6
+ import { _ as isCallRate, a as newNonce, c as provesGreeting, d as CALL_RATES, l as readDaemonSecret, n as daemonOfThisRelease, s as provesDaemon, t as HELLO } from "./daemonProof-B41oSfon.js";
7
7
  import { accessSync, closeSync, constants, existsSync, fstatSync, openSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
8
8
  import { dirname, resolve } from "node:path";
9
9
  import { spawn } from "node:child_process";
@@ -12,7 +12,7 @@ import { createInterface } from "node:readline";
12
12
  import { format } from "node:util";
13
13
  var package_default = {
14
14
  name: "@ghostlytools/cli",
15
- version: "1.7.0",
15
+ version: "1.7.1",
16
16
  type: "module",
17
17
  description: "Ghostly for bots and terminals: the app's own engine, headless on Node, behind a daemon and a `ghostly` command with JSON output.",
18
18
  license: "MIT",
@@ -597,6 +597,32 @@ function typingFor(options) {
597
597
  if (options.stop === true) throw new CliError("usage", "--for keeps it on: not with --stop");
598
598
  return seconds;
599
599
  }
600
+ /** The ranges the API takes (api.ts, files.ts): the most minutes of a `--hold` (a week, HOLD_MAX_MINUTES), seconds. */
601
+ var HOLD_MINUTES = 10080;
602
+ var WAIT_SECONDS = 3600;
603
+ var LONG_WAIT_SECONDS = 86400;
604
+ var HISTORY_LIMIT = 1e4;
605
+ /**
606
+ * A number flag out of the range the API takes: a usage error (exit 2) that names the flag, before the profile opens.
607
+ * Before, the API's own check answered once it had opened (a one-shot went online first), in its parameter's words
608
+ * ("hold must be a number from 0 to 10080", exit 1). The API keeps its check for socket callers.
609
+ */
610
+ function inRange(options, flag, what, min, max, whole = false) {
611
+ const value = options[flag];
612
+ if (value === void 0) return void 0;
613
+ 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)}`);
614
+ return value;
615
+ }
616
+ /** `--timeout` of a command that waits: seconds, up to an hour (a send, a card, a button) or a day (`chat wait`, a file). */
617
+ var timeout = (options, max = WAIT_SECONDS) => inRange(options, "timeout", "a number of seconds", 1, max);
618
+ /** `--limit` of a history: messages per page. */
619
+ var pageLimit = (options) => inRange(options, "limit", "a whole number", 1, HISTORY_LIMIT, true);
620
+ /** `--since` of `events` and `listen`: a seq, a whole number from 0 (a negative one replayed a made-up gap first). */
621
+ function since(options) {
622
+ const value = options.since;
623
+ if (value !== void 0 && !(Number.isSafeInteger(value) && value >= 0)) throw new CliError("usage", `--since takes a seq from 0 up, not ${JSON.stringify(value)}`);
624
+ return value;
625
+ }
600
626
  /**
601
627
  * A time given as digits: milliseconds. Unix seconds (from 1e9, 2001, up to 1e11, which as milliseconds would be 1970
602
628
  * to 1973) are refused with the milliseconds they mean: before, they were read as January 1970 without a word.
@@ -717,6 +743,16 @@ function itemOf(value) {
717
743
  text
718
744
  };
719
745
  }
746
+ /**
747
+ * A card's fields past the bytes a card takes in all (`STATUS_CARD_LIMITS.bytes`, its JSON as UTF-8): a usage error
748
+ * (exit 2) with its size and what to cut. Every flag can be within its own bound and the card not: 20 items of 200
749
+ * characters past Latin (3 bytes each) take 12 KiB. Before, it failed as `bad_request` (exit 1), the whole card in it.
750
+ */
751
+ function cardBytes(fields, flags) {
752
+ const bytes = statusCardBytes(fields);
753
+ if (bytes > STATUS_CARD_LIMITS.bytes) throw new CliError("usage", `The card takes ${bytes} bytes, and holds at most ${STATUS_CARD_LIMITS.bytes} in all (a character past Latin takes 2 to 4): give shorter or fewer ${flags}`);
754
+ return fields;
755
+ }
720
756
  /** `--progress`, `--left`: a percent, or a usage error that names the flag. */
721
757
  function percent(options, flag) {
722
758
  const value = options[flag];
@@ -788,7 +824,7 @@ function taskFields(options) {
788
824
  set("parent", options.parent);
789
825
  const links = cardLinks(options.link);
790
826
  if (links) fields.links = links;
791
- return fields;
827
+ return cardBytes(fields, "--item, --step, --link or --json");
792
828
  }
793
829
  /**
794
830
  * The fields a new card cannot go without, given as a flag or in `--json`: a usage error (exit 2) that names the
@@ -860,7 +896,7 @@ function routineFields(options) {
860
896
  if (next !== void 0) fields.nextRunAt = next;
861
897
  const links = cardLinks(options.link);
862
898
  if (links) fields.links = links;
863
- return fields;
899
+ return cardBytes(fields, "--name, --schedule, --link or --json");
864
900
  }
865
901
  /** Options a routine command takes, beside `cardOptions`. */
866
902
  var routineOptions = {
@@ -914,7 +950,7 @@ var taskOptions = {
914
950
  },
915
951
  item: {
916
952
  type: "list",
917
- description: "A step or log line, state:text with state pending, running, done, failed or skipped (text alone: pending). A lowercase word before the first colon must be one of them; pending:fix: x keeps the colon. The list replaces the card's (up to 20)"
953
+ description: "A step or log line, state:text with state pending, running, done, failed or skipped (text alone: pending). A lowercase word before the first colon must be one of them; pending:fix: x keeps the colon. The list replaces the card's (up to 20; the card holds at most 8 KiB in all, and a character past Latin takes 2 to 4 bytes)"
918
954
  },
919
955
  branch: {
920
956
  type: "string",
@@ -997,7 +1033,7 @@ function usageFields(options) {
997
1033
  const resets = cardTime(options.resets, "resets");
998
1034
  if (resets !== void 0) fields.resetsAt = resets;
999
1035
  if (Array.isArray(options.also) && options.also.length) fields.windows = options.also.map(usageWindowOf);
1000
- return fields;
1036
+ return cardBytes(fields, "--json");
1001
1037
  }
1002
1038
  /** Options `usage send` takes. */
1003
1039
  var usageOptions = {
@@ -1101,7 +1137,7 @@ var commands$8 = {
1101
1137
  description: "Replace the three files when they are there"
1102
1138
  }
1103
1139
  },
1104
- run: async ({ options }, a) => (await import("./apps-_hVUaHIT.js")).initApp(a.dir, {
1140
+ run: async ({ options }, a) => (await import("./apps-CJ2dvKSz.js")).initApp(a.dir, {
1105
1141
  name: options.name,
1106
1142
  title: options.title,
1107
1143
  force: options.force === true
@@ -1141,7 +1177,7 @@ var commands$8 = {
1141
1177
  description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
1142
1178
  }
1143
1179
  },
1144
- run: async ({ options }, a) => (await import("./apps-_hVUaHIT.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1180
+ run: async ({ options }, a) => (await import("./apps-CJ2dvKSz.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1145
1181
  },
1146
1182
  "app revoke": {
1147
1183
  method: "app.revoke",
@@ -1174,7 +1210,7 @@ var commands$8 = {
1174
1210
  description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere)"
1175
1211
  }
1176
1212
  },
1177
- run: async ({ options }, a) => (await import("./apps-_hVUaHIT.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>]"), {
1213
+ run: async ({ options }, a) => (await import("./apps-CJ2dvKSz.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>]"), {
1178
1214
  digests: options.digest,
1179
1215
  upTo: options["up-to"],
1180
1216
  reason: options.reason,
@@ -1235,7 +1271,7 @@ var commands$8 = {
1235
1271
  usage: "app verify <bundle|url>",
1236
1272
  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",
1237
1273
  args: ["bundle"],
1238
- run: async (_, a) => (await import("./apps-_hVUaHIT.js")).verifyApp(a.bundle)
1274
+ run: async (_, a) => (await import("./apps-CJ2dvKSz.js")).verifyApp(a.bundle)
1239
1275
  },
1240
1276
  "store sign": {
1241
1277
  method: "store.sign",
@@ -1252,7 +1288,7 @@ var commands$8 = {
1252
1288
  description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
1253
1289
  }
1254
1290
  },
1255
- run: async ({ options }, a) => (await import("./apps-_hVUaHIT.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1291
+ run: async ({ options }, a) => (await import("./apps-CJ2dvKSz.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1256
1292
  }
1257
1293
  };
1258
1294
  //#endregion
@@ -1365,7 +1401,7 @@ var commands$6 = {
1365
1401
  message: a.message,
1366
1402
  button: a.button,
1367
1403
  wait: options.wait,
1368
- timeout: options.timeout
1404
+ timeout: timeout(options)
1369
1405
  })
1370
1406
  },
1371
1407
  "button update": {
@@ -1408,7 +1444,7 @@ var commands$6 = {
1408
1444
  text: options.text,
1409
1445
  force: options.force === true,
1410
1446
  wait: options.wait,
1411
- timeout: options.timeout
1447
+ timeout: timeout(options)
1412
1448
  };
1413
1449
  }
1414
1450
  },
@@ -1430,7 +1466,7 @@ var commands$6 = {
1430
1466
  } },
1431
1467
  params: ({ options }, { chat }) => ({
1432
1468
  chat,
1433
- hold: options.hold
1469
+ hold: inRange(options, "hold", "a number of minutes", 0, HOLD_MINUTES)
1434
1470
  })
1435
1471
  },
1436
1472
  "chat history": {
@@ -1455,7 +1491,7 @@ var commands$6 = {
1455
1491
  },
1456
1492
  params: ({ options }, { chat }) => ({
1457
1493
  chat,
1458
- limit: options.limit,
1494
+ limit: pageLimit(options),
1459
1495
  before: cursor(options.before, "before"),
1460
1496
  after: cursor(options.after, "after")
1461
1497
  })
@@ -1553,7 +1589,7 @@ var commands$6 = {
1553
1589
  params: ({ options }, { chat }) => ({
1554
1590
  chat,
1555
1591
  until: options.until,
1556
- timeout: options.timeout
1592
+ timeout: timeout(options, LONG_WAIT_SECONDS)
1557
1593
  })
1558
1594
  },
1559
1595
  "forward": {
@@ -1586,7 +1622,7 @@ var commands$6 = {
1586
1622
  to: options.to,
1587
1623
  force: options.force === true,
1588
1624
  wait: options.wait,
1589
- timeout: options.timeout
1625
+ timeout: timeout(options)
1590
1626
  };
1591
1627
  }
1592
1628
  },
@@ -1709,7 +1745,7 @@ var commands$6 = {
1709
1745
  text: options.text,
1710
1746
  force: options.force === true,
1711
1747
  wait: options.wait,
1712
- timeout: options.timeout
1748
+ timeout: timeout(options)
1713
1749
  })
1714
1750
  },
1715
1751
  "routine update": {
@@ -1738,7 +1774,7 @@ var commands$6 = {
1738
1774
  text: options.text,
1739
1775
  force: options.force === true,
1740
1776
  wait: options.wait,
1741
- timeout: options.timeout
1777
+ timeout: timeout(options)
1742
1778
  })
1743
1779
  },
1744
1780
  "saved add": {
@@ -1786,7 +1822,7 @@ var commands$6 = {
1786
1822
  text: options.text,
1787
1823
  force: options.force === true,
1788
1824
  wait: options.wait,
1789
- timeout: options.timeout
1825
+ timeout: timeout(options)
1790
1826
  })
1791
1827
  },
1792
1828
  "task update": {
@@ -1814,7 +1850,7 @@ var commands$6 = {
1814
1850
  text: options.text,
1815
1851
  force: options.force === true,
1816
1852
  wait: options.wait,
1817
- timeout: options.timeout
1853
+ timeout: timeout(options)
1818
1854
  })
1819
1855
  },
1820
1856
  "typing": {
@@ -1866,7 +1902,7 @@ var commands$6 = {
1866
1902
  text: options.text,
1867
1903
  force: options.force === true,
1868
1904
  wait: options.wait,
1869
- timeout: options.timeout
1905
+ timeout: timeout(options)
1870
1906
  };
1871
1907
  }
1872
1908
  }
@@ -1987,7 +2023,7 @@ var commands$5 = {
1987
2023
  options: {
1988
2024
  dir: {
1989
2025
  type: "string",
1990
- description: "Into this folder, under its own name"
2026
+ description: "Into this folder, under its own name (a voice message: the name Ghostly makes for it, \"(2)\" when taken)"
1991
2027
  },
1992
2028
  path: {
1993
2029
  type: "string",
@@ -2018,7 +2054,7 @@ var commands$5 = {
2018
2054
  path: here(options.path),
2019
2055
  force: options.force === true,
2020
2056
  wait: options.wait === true ? true : void 0,
2021
- timeout: options.timeout
2057
+ timeout: timeout(options, LONG_WAIT_SECONDS)
2022
2058
  };
2023
2059
  }
2024
2060
  },
@@ -2068,7 +2104,7 @@ var commands$5 = {
2068
2104
  params: ({ options }, a) => ({
2069
2105
  chat: a.chat,
2070
2106
  file: a.file,
2071
- timeout: options.timeout
2107
+ timeout: timeout(options, LONG_WAIT_SECONDS)
2072
2108
  })
2073
2109
  }
2074
2110
  };
@@ -2087,7 +2123,7 @@ var commands$4 = {
2087
2123
  },
2088
2124
  translate
2089
2125
  },
2090
- params: ({ options }) => ({ since: options.since ?? 0 })
2126
+ params: ({ options }) => ({ since: since(options) ?? 0 })
2091
2127
  },
2092
2128
  "profile picture": {
2093
2129
  method: "profile.picture",
@@ -2192,7 +2228,7 @@ var commands$3 = {
2192
2228
  },
2193
2229
  params: ({ options }, { group }) => ({
2194
2230
  group,
2195
- limit: options.limit,
2231
+ limit: pageLimit(options),
2196
2232
  before: cursor(options.before, "before"),
2197
2233
  after: cursor(options.after, "after")
2198
2234
  })
@@ -2545,9 +2581,9 @@ var commands$2 = {
2545
2581
  var commands$1 = {
2546
2582
  "chat accept": {
2547
2583
  method: "chat.accept",
2548
- usage: "chat accept <chat> <method> [--off] [--networks mainnet,testnet]",
2549
- summary: "Which ways of paying a chat takes",
2550
- args: ["chat", "method"],
2584
+ usage: "chat accept <chat> [<method> [--off] [--networks mainnet,testnet]]",
2585
+ summary: "Which ways of paying a chat takes (no method: the ones it takes now)",
2586
+ args: ["chat", "method?"],
2551
2587
  words: { method: CHAT_METHODS },
2552
2588
  options: {
2553
2589
  off: {
@@ -2559,12 +2595,16 @@ var commands$1 = {
2559
2595
  description: "Comma-separated networks it is taken on"
2560
2596
  }
2561
2597
  },
2562
- params: ({ options }, a) => ({
2563
- chat: a.chat,
2564
- method: a.method,
2565
- on: options.off !== true,
2566
- networks: typeof options.networks === "string" ? options.networks.split(",").map((n) => n.trim()).filter(Boolean) : void 0
2567
- })
2598
+ params: ({ options }, a) => {
2599
+ if (a.method === void 0 && (options.off !== void 0 || options.networks !== void 0)) throw new CliError("usage", "--off and --networks change one method: ghostly chat accept <chat> <method> [--off] [--networks mainnet,testnet]");
2600
+ if (a.method === void 0) return { chat: a.chat };
2601
+ return {
2602
+ chat: a.chat,
2603
+ method: a.method,
2604
+ on: options.off !== true,
2605
+ networks: typeof options.networks === "string" ? options.networks.split(",").map((n) => n.trim()).filter(Boolean) : void 0
2606
+ };
2607
+ }
2568
2608
  },
2569
2609
  "chat pay": {
2570
2610
  method: "chat.pay",
@@ -2820,7 +2860,7 @@ var commands$1 = {
2820
2860
  },
2821
2861
  params: ({ options }) => ({
2822
2862
  network: options.network,
2823
- limit: options.limit
2863
+ limit: pageLimit(options)
2824
2864
  })
2825
2865
  },
2826
2866
  "wallet list": {
@@ -3097,15 +3137,18 @@ var ID_ARGS = /* @__PURE__ */ new Set([
3097
3137
  "service",
3098
3138
  "call"
3099
3139
  ]);
3100
- /** A leading positional that may be left out (`name?`); a trailing one that may (`text...?`) shifts nothing. */
3101
- var leadingOptional = (name) => name.endsWith("?") && !name.endsWith("...?");
3140
+ /**
3141
+ * The positionals that may be left out ahead of a required one (`chat?` in `[<chat>] <file>`): left out, they shift the
3142
+ * others. One with no required one after it (`<chat> [<method>]`, `text...?`) is simply missing at the end: it shifts nothing.
3143
+ */
3144
+ var leadingOptionals = (names) => names.filter((name, i) => name.endsWith("?") && !name.endsWith("...?") && names.slice(i + 1).some((after) => !after.endsWith("?")));
3102
3145
  /**
3103
3146
  * Which of a command's positionals take an id, by index (a trailing `...` one covers the rest). An optional `name?`
3104
3147
  * shifts the others, so it counts only where it and what may come in its place are all ids.
3105
3148
  */
3106
3149
  function idSlot(command) {
3107
3150
  const names = (command.args ?? []).map((name) => name.replace(/\?$/, ""));
3108
- const shift = (command.args ?? []).filter(leadingOptional).length;
3151
+ const shift = leadingOptionals(command.args ?? []).length;
3109
3152
  const rest = names.findIndex((name) => name.endsWith("..."));
3110
3153
  const at = (index) => {
3111
3154
  const name = rest !== -1 && index >= rest ? names[rest].slice(0, -3) : names[index];
@@ -3136,11 +3179,11 @@ function usageNames(usage) {
3136
3179
  */
3137
3180
  function positionals(command, values) {
3138
3181
  let names = command.args ?? [];
3139
- const optional = names.filter(leadingOptional);
3182
+ const optional = leadingOptionals(names);
3140
3183
  let skip = 0;
3141
3184
  if (optional.length) {
3142
3185
  skip = Math.max(0, optional.length - Math.max(0, values.length - (names.length - optional.length)));
3143
- names = [...optional.slice(skip).map((name) => name.slice(0, -1)), ...names.filter((name) => !leadingOptional(name))];
3186
+ names = [...optional.slice(skip).map((name) => name.slice(0, -1)), ...names.filter((name) => !optional.includes(name))];
3144
3187
  }
3145
3188
  const shown = usageNames(command.usage);
3146
3189
  const missing = (i, name) => new CliError("usage", `Missing <${shown[i + skip] ?? name}>: ghostly ${command.usage}`);
@@ -3153,6 +3196,7 @@ function positionals(command, values) {
3153
3196
  out[name.slice(0, -3)] = rest.length ? rest.join(" ") : void 0;
3154
3197
  return out;
3155
3198
  }
3199
+ if (values[i] === void 0 && names[i].endsWith("?")) continue;
3156
3200
  if (values[i] === void 0 || values[i] === "") throw missing(i, name);
3157
3201
  const words = command.words?.[name];
3158
3202
  if (words && !words.includes(values[i])) {
@@ -3214,13 +3258,25 @@ var Allowlist = class {
3214
3258
  };
3215
3259
  /**
3216
3260
  * `--from` and `--group` as ids, resolved once at start: a contact key as that key (whatever any chat is named), else a
3217
- * chat by id, prefix or name (`findChat`); a group by id, prefix or name. A name that later changes (or a contact who
3218
- * renames themselves) moves nothing.
3261
+ * chat by its id or a label this side gave it, as `call auto on --from` (`findOwnNamedChat`): a prefix of its id or the
3262
+ * name its contact gave itself is refused, since another contact could call itself that; a group by id, prefix or name.
3263
+ * A name that later changes (or a contact who renames themselves) moves nothing.
3219
3264
  */
3220
3265
  async function allowlist(from, groups, call, peerOf) {
3221
3266
  const chats = /* @__PURE__ */ new Set(), keys = /* @__PURE__ */ new Set(), groupIds = /* @__PURE__ */ new Set();
3222
- for (const ref of from) if (CONTACT_KEY.test(ref)) keys.add(ref);
3223
- else chats.add((await call("chat.get", { chat: ref })).id);
3267
+ for (const ref of from) {
3268
+ if (CONTACT_KEY.test(ref)) {
3269
+ keys.add(ref);
3270
+ continue;
3271
+ }
3272
+ const chat = await call("chat.get", { chat: ref });
3273
+ if (chat.id !== ref && chat.label?.toLowerCase() !== ref.toLowerCase()) throw namedByThem(ref, {
3274
+ chat: chat.id,
3275
+ name: chat.peerName ?? null,
3276
+ contact: chat.peer
3277
+ });
3278
+ chats.add(chat.id);
3279
+ }
3224
3280
  for (const ref of groups) groupIds.add((await call("group.get", { group: ref })).id);
3225
3281
  return new Allowlist(chats, keys, groupIds, peerOf);
3226
3282
  }
@@ -3495,6 +3551,8 @@ function eventHandler(options) {
3495
3551
  let chain = Promise.resolve();
3496
3552
  let behind = 0;
3497
3553
  let stopped = false;
3554
+ /** The last event the cursor says, and the last one `--type` dropped while others were still being handled. */
3555
+ let kept = -1, dropped = -1;
3498
3556
  const keep = (seq) => {
3499
3557
  if (!options.cursor) return;
3500
3558
  try {
@@ -3502,10 +3560,27 @@ function eventHandler(options) {
3502
3560
  } catch (error) {
3503
3561
  throw new CursorError(error);
3504
3562
  }
3563
+ kept = Math.max(kept, seq);
3564
+ };
3565
+ /** The cursor past events dropped meanwhile, once nothing before them is left to handle. */
3566
+ const keepDropped = () => {
3567
+ if (behind > 0 || dropped <= kept) return;
3568
+ try {
3569
+ keep(dropped);
3570
+ } catch (failed) {
3571
+ if (!(failed instanceof CursorError) || !options.cursorFailed) return;
3572
+ stopped = true;
3573
+ options.cursorFailed(failed.error);
3574
+ }
3505
3575
  };
3506
3576
  const handle = (event) => {
3507
3577
  const seq = event.seq, type = event.type;
3508
3578
  if (stopped) return;
3579
+ if (!matches(event, options.types)) {
3580
+ dropped = Math.max(dropped, seq);
3581
+ keepDropped();
3582
+ return;
3583
+ }
3509
3584
  behind++;
3510
3585
  chain = chain.then(async () => {
3511
3586
  if (stopped) return;
@@ -3540,6 +3615,7 @@ function eventHandler(options) {
3540
3615
  }
3541
3616
  }).finally(() => {
3542
3617
  behind--;
3618
+ keepDropped();
3543
3619
  });
3544
3620
  };
3545
3621
  return Object.assign(handle, {
@@ -3779,15 +3855,15 @@ var VERSION = package_default.version;
3779
3855
  * command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
3780
3856
  * cost every command ~100 ms before its socket was opened.
3781
3857
  */
3782
- var engineApi = () => import("./api-BnCmJLiQ.js");
3783
- var engineHost = () => import("./host-DDMQfR7B.js");
3858
+ var engineApi = () => import("./api-CJM3R93b.js");
3859
+ var engineHost = () => import("./host-CVeNtA2_.js");
3784
3860
  /**
3785
3861
  * `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
3786
3862
  * asked: the app's message parser it reads costs every other command nothing.
3787
3863
  */
3788
3864
  async function translatorFor(value, home) {
3789
3865
  if (value === void 0) return null;
3790
- const { loadDetector, openTranslator, translateTarget } = await import("./translate-BcP139SV.js");
3866
+ const { loadDetector, openTranslator, translateTarget } = await import("./translate-DJUutSis.js");
3791
3867
  return openTranslator({
3792
3868
  home,
3793
3869
  to: translateTarget(value),
@@ -3833,10 +3909,45 @@ function noProfile(g) {
3833
3909
  function knownProfile(g) {
3834
3910
  if (g.profile !== "default" && !profileExists(g.home, g.profile)) throw noProfile(g);
3835
3911
  }
3836
- /** Said on stderr when the daemon runs another release than this command (it started before an upgrade). */
3912
+ /** `1.2.3`, with an optional `v`, an optional `-beta.1` prerelease and an optional `+build` that never orders. */
3913
+ var RELEASE = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
3914
+ /** Semver order: negative when `a` is the older release, positive when it is the newer, 0 the same; null when either is not one. */
3915
+ function compareReleases(a, b) {
3916
+ const left = RELEASE.exec(a.trim()), right = RELEASE.exec(b.trim());
3917
+ if (!left || !right) return null;
3918
+ for (let i = 1; i <= 3; i++) {
3919
+ const order = Number(left[i]) - Number(right[i]);
3920
+ if (order !== 0) return order;
3921
+ }
3922
+ if (left[4] === void 0 || right[4] === void 0) return (left[4] === void 0 ? 1 : 0) - (right[4] === void 0 ? 1 : 0);
3923
+ const l = left[4].split("."), r = right[4].split(".");
3924
+ for (let i = 0; i < Math.min(l.length, r.length); i++) {
3925
+ if (l[i] === r[i]) continue;
3926
+ const ln = /^\d+$/.test(l[i]), rn = /^\d+$/.test(r[i]);
3927
+ if (ln && rn) return Number(l[i]) - Number(r[i]);
3928
+ if (ln !== rn) return ln ? -1 : 1;
3929
+ return l[i] < r[i] ? -1 : 1;
3930
+ }
3931
+ return l.length - r.length;
3932
+ }
3933
+ /**
3934
+ * Said on stderr when the daemon runs another release than this command. An older daemon started before an upgrade:
3935
+ * `daemon restart` runs this release. A newer one means this command is the old one (a second install, a project's
3936
+ * pinned copy): a restart from it would start the older release, so it is told to upgrade instead.
3937
+ */
3837
3938
  function versionWarning(daemon, cli) {
3838
3939
  if (typeof daemon !== "string" || daemon === cli) return null;
3839
- return `ghostly: the daemon runs ${daemon} and this command is ${cli}: \`ghostly daemon restart\` runs the new code`;
3940
+ const order = compareReleases(daemon, cli);
3941
+ if (order === 0) return null;
3942
+ const both = `ghostly: the daemon runs ${daemon} and this command is ${cli}`;
3943
+ if (order === null) return `${both}: \`ghostly daemon restart\` runs this command's release`;
3944
+ if (order > 0) return `${both}, older than the daemon: upgrade the CLI (\`npm install -g @ghostlytools/cli\`)`;
3945
+ return `${both}: \`ghostly daemon restart\` runs the new code`;
3946
+ }
3947
+ /** Said on stderr when `daemon restart` stopped a newer release than the one it started (an older CLI ran it). */
3948
+ function restartWarning(before, version) {
3949
+ if (typeof before !== "string" || !((compareReleases(before, version) ?? 0) > 0)) return null;
3950
+ return `ghostly: the daemon ran ${before} and this restart started ${version}, an older release: upgrade the CLI (\`npm install -g @ghostlytools/cli\`) and run \`ghostly daemon restart\` again to go back`;
3840
3951
  }
3841
3952
  /**
3842
3953
  * Never fails, and has no deadline of its own: a daemon that does not answer is the command's own call to find out,
@@ -3871,6 +3982,15 @@ function chatOnly(method, params) {
3871
3982
  return method.startsWith("chat.") || params.chat !== void 0 && params.group === void 0 && !method.startsWith("group.");
3872
3983
  }
3873
3984
  /**
3985
+ * A command that makes a new chat and needs no other: a one-shot for it leaves the saved chats and the groups unstarted.
3986
+ * Started, each saved chat put its records and its leave packet on the relays: from about ten that was the relays' 30
3987
+ * requests a minute, and the new chat's waited behind them. A new invite took 21 s instead of under one, unpublished;
3988
+ * a join waited its whole 60 s and left unpaired. A join of a saved chat starts that chat (the engine's `joinLink`).
3989
+ */
3990
+ function newChatOnly(method) {
3991
+ return method === "invite.create" || method === "invite.join";
3992
+ }
3993
+ /**
3874
3994
  * Calls that only read what the profile stores: a one-shot for one opens it offline (`RuntimeOptions.offline`).
3875
3995
  * Opened online, `status` or `chat list` started every chat, put the profile's records on the relays again and waited
3876
3996
  * for its leave packet to be taken: 0.25 s became 3.3 s with a relay that takes 1.5 s, and 10 s with one that does not
@@ -3906,6 +4026,7 @@ var READS = /* @__PURE__ */ new Set([
3906
4026
  function readOnly(method, params) {
3907
4027
  if (method === "engine.call") return typeof params.method === "string" && ENGINE_READS.includes(params.method);
3908
4028
  if (method === "call.auto") return params.on === void 0;
4029
+ if (method === "chat.accept") return params.method === void 0;
3909
4030
  return READS.has(method);
3910
4031
  }
3911
4032
  /**
@@ -3978,17 +4099,40 @@ async function session(g, options) {
3978
4099
  }
3979
4100
  };
3980
4101
  }
3981
- const [{ openHost }, { callApi }] = await Promise.all([engineHost(), engineApi()]);
3982
- const host = await openHost(g.paths, "one-shot", VERSION, options);
4102
+ const [, { callApi }] = await Promise.all([engineHost(), engineApi()]);
4103
+ const host = await openOneShot(g, options);
3983
4104
  return {
3984
4105
  mode: "one-shot",
3985
4106
  call: (m, p) => callApi(host.ctx, m, p ?? {}),
3986
4107
  close: () => host.close()
3987
4108
  };
3988
4109
  }
4110
+ /** How long a one-shot waits for another process to let go of the profile: a one-shot leaves in well under a second. */
4111
+ var HOLDER_WAIT_MS = 5e3;
4112
+ /**
4113
+ * Opens the profile in this process for a one-shot command. Another one that holds it (a script's `&`, a second
4114
+ * terminal) is waited for: both used to fail at once, and a backgrounded send was lost unless the script checked its
4115
+ * exit code. One still holding it after HOLDER_WAIT_MS is answered with the next step.
4116
+ */
4117
+ async function openOneShot(g, options = {}) {
4118
+ const { openHost } = await engineHost();
4119
+ const until = Date.now() + HOLDER_WAIT_MS;
4120
+ for (;;) try {
4121
+ return await openHost(g.paths, "one-shot", VERSION, options);
4122
+ } catch (error) {
4123
+ if (!(error instanceof CliError) || error.code !== "busy") throw error;
4124
+ const left = until - Date.now();
4125
+ if (left <= 0) {
4126
+ const pid = error.details?.pid;
4127
+ throw new CliError("busy", `Profile ${g.profile} is in use by ${pid ? `process ${pid}, another ghostly command,` : "another ghostly command"} and was not free after ${HOLDER_WAIT_MS / 1e3} s: run the commands one after another, or start \`ghostly daemon --detach\` so they can run at once`, error.details);
4128
+ }
4129
+ await new Promise((resolve) => setTimeout(resolve, Math.min(50 + Math.random() * 50, left)));
4130
+ }
4131
+ }
3989
4132
  /**
3990
4133
  * How a one-shot opens the profile: `deferGroups` when the command is about one 1:1 chat (`chatOnly`) and needs
3991
- * nothing of the groups, `offline` when it only reads or changes only this device (`offlineCall`).
4134
+ * nothing of the groups, `deferChats` too when it makes a new chat (`newChatOnly`), `offline` when it only reads or
4135
+ * changes only this device (`offlineCall`).
3992
4136
  */
3993
4137
  async function withSession(g, work, options = {}) {
3994
4138
  const s = await session(g, options);
@@ -4127,7 +4271,7 @@ var SPECIAL = [
4127
4271
  "The profile's settings",
4128
4272
  { "show-secret": o("boolean", "Show credentials too") }
4129
4273
  ],
4130
- ["settings set <key> <json-value>", "Change one: relays, irohRelays, hyperdhtRelay, readRelays, iceServers, publicProfiles, online, shareProfile, sendTyping, autoDownloads, serveFiles, nick"],
4274
+ ["settings set <key> <json-value>", "Change one: relays, irohRelays, hyperdhtRelay, iceServers, publicProfiles, online, shareProfile, sendTyping, autoDownloads, serveFiles, nick"],
4131
4275
  [
4132
4276
  "engine <method> [json-params | -] [--confirm-real] [--show-secret] [--yes] [--force]",
4133
4277
  "Any call of the app's engine, with its own parameters (engine --list --verbose names them)",
@@ -4410,7 +4554,7 @@ async function profileCommand(sub, argv) {
4410
4554
  if (!given || !name) throw new CliError("usage", "ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]");
4411
4555
  noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
4412
4556
  const file = here(given);
4413
- const { backupFileProtection, restoreProfile } = await import("./backup-d_XvXpEK.js");
4557
+ const { backupFileProtection, restoreProfile } = await import("./backup-C4CbTEcj.js");
4414
4558
  const protection = await backupFileProtection(file);
4415
4559
  const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
4416
4560
  if (parsed.options.use) selectProfile(g.home, name);
@@ -4570,6 +4714,8 @@ async function daemonCommand(argv) {
4570
4714
  stopped
4571
4715
  });
4572
4716
  }
4717
+ const older = restartWarning(before, VERSION);
4718
+ if (older) process.stderr.write(older + "\n");
4573
4719
  print({
4574
4720
  restarted: true,
4575
4721
  stopped,
@@ -4821,8 +4967,8 @@ async function listenCommand(argv) {
4821
4967
  const from = parsed.options.from ?? [], groups = parsed.options.group ?? [];
4822
4968
  const cursor = here(parsed.options.cursor);
4823
4969
  checkCursor(cursor);
4970
+ const since$1 = since(parsed.options) ?? readCursor(cursor);
4824
4971
  const translator = await translatorFor(parsed.options.translate, g.home);
4825
- const since = parsed.options.since ?? readCursor(cursor);
4826
4972
  let quit = (code) => {
4827
4973
  process.exit(code);
4828
4974
  };
@@ -4871,7 +5017,7 @@ async function listenCommand(argv) {
4871
5017
  client.close();
4872
5018
  throw error;
4873
5019
  });
4874
- const following = followDaemon(g.paths, client, handle, since, PAUSE_HOLD_MS, g.profile);
5020
+ const following = followDaemon(g.paths, client, handle, since$1, PAUSE_HOLD_MS, g.profile);
4875
5021
  const stop = () => {
4876
5022
  following.close();
4877
5023
  process.exit(0);
@@ -4926,11 +5072,11 @@ async function listenCommand(argv) {
4926
5072
  }
4927
5073
  off = host.ctx.hub.onEvent(feed.take);
4928
5074
  };
4929
- const feed = new Feed(handle, since, () => {
5075
+ const feed = new Feed(handle, since$1, () => {
4930
5076
  off?.();
4931
5077
  off = null;
4932
5078
  }, open);
4933
- open(since);
5079
+ open(since$1);
4934
5080
  host.ctx.hub.emit("daemon.started", `daemon.started:${process.pid}:${Date.now()}`, {
4935
5081
  pid: process.pid,
4936
5082
  version: VERSION,
@@ -5038,6 +5184,7 @@ async function textCommand(name, argv) {
5038
5184
  const [target, ...rest] = parsed.positionals;
5039
5185
  const [message, ...words] = spec.message ? rest : [void 0, ...rest];
5040
5186
  if (!target || spec.message && !message) throw new CliError("usage", `ghostly ${spec.usage}`);
5187
+ timeout(parsed.options);
5041
5188
  let text = words.join(" ");
5042
5189
  if (parsed.options.text !== void 0) {
5043
5190
  if (text || parsed.options.stdin) throw new CliError("usage", "Give the text once: as arguments, --text or stdin");
@@ -5055,7 +5202,7 @@ async function textCommand(name, argv) {
5055
5202
  };
5056
5203
  if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
5057
5204
  if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
5058
- if (!spec.message) Object.assign(params, (await import("./buttons-LO3Ql1Hd.js")).buttonsOf(parsed.options));
5205
+ if (!spec.message) Object.assign(params, (await import("./buttons-BMVGYXpR.js")).buttonsOf(parsed.options));
5059
5206
  print(await withSession(g, (s) => {
5060
5207
  if (spec.target === "chat") {
5061
5208
  params.wait = parsed.options.wait ?? (s.mode === "one-shot" ? spec.message ? "confirmed" : "sent" : "none");
@@ -5126,8 +5273,8 @@ async function identityAddCommand(argv) {
5126
5273
  }
5127
5274
  return;
5128
5275
  }
5129
- const [{ openHost }, { callApi }] = await Promise.all([engineHost(), engineApi()]);
5130
- const host = await openHost(g.paths, "one-shot", VERSION);
5276
+ const [, { callApi }] = await Promise.all([engineHost(), engineApi()]);
5277
+ const host = await openOneShot(g);
5131
5278
  const off = host.ctx.hub.onEvent(tell);
5132
5279
  try {
5133
5280
  const result = await callApi(host.ctx, "identity.add", params);
@@ -5189,12 +5336,13 @@ async function tableCommand(name, argv) {
5189
5336
  }
5190
5337
  return result;
5191
5338
  }, {
5192
- deferGroups: chatOnly(command.method, params),
5339
+ deferGroups: chatOnly(command.method, params) || newChatOnly(command.method),
5340
+ deferChats: newChatOnly(command.method),
5193
5341
  offline: offlineCall(command.method, params)
5194
5342
  });
5195
5343
  if (translator) {
5196
5344
  try {
5197
- printAnswer(await (await import("./translate-BcP139SV.js")).translateAnswer(result, translator));
5345
+ printAnswer(await (await import("./translate-DJUutSis.js")).translateAnswer(result, translator));
5198
5346
  } finally {
5199
5347
  translator.close();
5200
5348
  }
@@ -5373,4 +5521,4 @@ async function run(argv) {
5373
5521
  //#endregion
5374
5522
  export { run };
5375
5523
 
5376
- //# sourceMappingURL=main-BNwNEPEy.js.map
5524
+ //# sourceMappingURL=main-CjO0KGiF.js.map