@ghostlytools/cli 1.7.2 → 1.7.3

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 (66) hide show
  1. package/README.md +22 -14
  2. package/SKILL.md +5 -1
  3. package/dist/assets/{api-CcuCtc1H.js → api-B42F9ytB.js} +2 -2
  4. package/dist/assets/{api-tSZELCPQ.js → api-tf-wAAnB.js} +214 -87
  5. package/dist/assets/api-tf-wAAnB.js.map +1 -0
  6. package/dist/assets/{apiKit-BFk7GAk9.js → apiKit-DJb9hulp.js} +33 -4
  7. package/dist/assets/{apiKit-BFk7GAk9.js.map → apiKit-DJb9hulp.js.map} +1 -1
  8. package/dist/assets/{apps-D6THreq_.js → apps-BfoDISRg.js} +1 -1
  9. package/dist/assets/{apps-C5Mi6x9Q.js → apps-DIrWmLgL.js} +3 -3
  10. package/dist/assets/{apps-C5Mi6x9Q.js.map → apps-DIrWmLgL.js.map} +1 -1
  11. package/dist/assets/{arkade-Cz0B9bJ0.js → arkade-CJAhhgPQ.js} +2 -2
  12. package/dist/assets/{arkade-Cz0B9bJ0.js.map → arkade-CJAhhgPQ.js.map} +1 -1
  13. package/dist/assets/{backup-A0hIa9GE.js → backup-BkUeeduy.js} +1 -1
  14. package/dist/assets/{backup-Wb2sm2dd.js → backup-Bko-AAm0.js} +4 -4
  15. package/dist/assets/{backup-Wb2sm2dd.js.map → backup-Bko-AAm0.js.map} +1 -1
  16. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
  17. package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
  18. package/dist/assets/buttons-Be7u0V5g.js +2 -0
  19. package/dist/assets/{buttons-Cf70NVYq.js → buttons-DeA6Yddq.js} +34 -8
  20. package/dist/assets/buttons-DeA6Yddq.js.map +1 -0
  21. package/dist/assets/{envelope-kQ5kYjVE.js → envelope-Cz5fc7BM.js} +2 -2
  22. package/dist/assets/{envelope-kQ5kYjVE.js.map → envelope-Cz5fc7BM.js.map} +1 -1
  23. package/dist/assets/{groupFiles-D9Ttlm3M.js → groupFiles-BlZRBWpt.js} +558 -4
  24. package/dist/assets/groupFiles-BlZRBWpt.js.map +1 -0
  25. package/dist/assets/{host-DpypH-fR.js → host-BX0DmKW6.js} +38 -15
  26. package/dist/assets/host-BX0DmKW6.js.map +1 -0
  27. package/dist/assets/{hyperdhtRelay-D1rj84v2.js → hyperdhtRelay-DitYDnXx.js} +2 -2
  28. package/dist/assets/{hyperdhtRelay-D1rj84v2.js.map → hyperdhtRelay-DitYDnXx.js.map} +1 -1
  29. package/dist/assets/{irohWeb-BTSlWgEX.js → irohWeb-R3bcd34h.js} +2 -2
  30. package/dist/assets/{irohWeb-BTSlWgEX.js.map → irohWeb-R3bcd34h.js.map} +1 -1
  31. package/dist/assets/{main-BwgoQZVu.js → main-6QOSvQ8b.js} +247 -102
  32. package/dist/assets/main-6QOSvQ8b.js.map +1 -0
  33. package/dist/assets/{mainline-B1urhbEZ.js → mainline-BfwezHWi.js} +2 -2
  34. package/dist/assets/{mainline-B1urhbEZ.js.map → mainline-BfwezHWi.js.map} +1 -1
  35. package/dist/assets/{networkReason-D2Z0BdIj.js → networkReason-Ba9415nn.js} +2 -2
  36. package/dist/assets/{networkReason-D2Z0BdIj.js.map → networkReason-Ba9415nn.js.map} +1 -1
  37. package/dist/assets/{nwc-T2aUK6bi.js → nwc-ovXSN2M2.js} +3 -3
  38. package/dist/assets/{nwc-T2aUK6bi.js.map → nwc-ovXSN2M2.js.map} +1 -1
  39. package/dist/assets/{nwcProvider-Dz-ty_DE.js → nwcProvider-BzZbfFP3.js} +2 -2
  40. package/dist/assets/{nwcProvider-Dz-ty_DE.js.map → nwcProvider-BzZbfFP3.js.map} +1 -1
  41. package/dist/assets/{registry-Bazitl0a.js → registry-B0Uv9yL6.js} +3 -3
  42. package/dist/assets/{registry-Bazitl0a.js.map → registry-B0Uv9yL6.js.map} +1 -1
  43. package/dist/assets/{registry-BlSTJlbv.js → registry-CFtlhWCI.js} +1 -1
  44. package/dist/assets/{resolve-Bx1Eeg-w.js → resolve-BzFG4WDU.js} +2 -2
  45. package/dist/assets/{resolve-Bx1Eeg-w.js.map → resolve-BzFG4WDU.js.map} +1 -1
  46. package/dist/assets/{server-CnPj9wWh.js → server-BGCuHbmQ.js} +266 -594
  47. package/dist/assets/server-BGCuHbmQ.js.map +1 -0
  48. package/dist/assets/{src-BsznF3XG.js → src-DWw2hUE5.js} +106 -38
  49. package/dist/assets/src-DWw2hUE5.js.map +1 -0
  50. package/dist/assets/{translate-cDBotA-b.js → translate-DObb-1tq.js} +2 -2
  51. package/dist/assets/{translate-cDBotA-b.js.map → translate-DObb-1tq.js.map} +1 -1
  52. package/dist/assets/{usdt-DxxLdG60.js → usdt-Bkva90Vo.js} +3 -3
  53. package/dist/assets/{usdt-DxxLdG60.js.map → usdt-Bkva90Vo.js.map} +1 -1
  54. package/dist/assets/{words-qH8gGtmc.js → words-odSAoasK.js} +4 -2
  55. package/dist/assets/words-odSAoasK.js.map +1 -0
  56. package/dist/ghostly.mjs +1 -1
  57. package/package.json +1 -1
  58. package/dist/assets/api-tSZELCPQ.js.map +0 -1
  59. package/dist/assets/buttons-Bxxu3lSk.js +0 -2
  60. package/dist/assets/buttons-Cf70NVYq.js.map +0 -1
  61. package/dist/assets/groupFiles-D9Ttlm3M.js.map +0 -1
  62. package/dist/assets/host-DpypH-fR.js.map +0 -1
  63. package/dist/assets/main-BwgoQZVu.js.map +0 -1
  64. package/dist/assets/server-CnPj9wWh.js.map +0 -1
  65. package/dist/assets/src-BsznF3XG.js.map +0 -1
  66. package/dist/assets/words-qH8gGtmc.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { Ga as CRON_LINE, Ja as PR_STATES, Ka as ITEM_STATES, Qa as TASK_STATUSES, Wn as GROUP_FILE_LIMITS, Xa as RUN_RESULTS, Ya as ROUTINE_STATES, Za as STATUS_CARD_LIMITS, ao as statusCardBytes, da as VOICE_LIMITS, no as cardUrl, qa as PR_CHECKS, to as cardLine } from "./src-BsznF3XG.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-qH8gGtmc.js";
1
+ import { Ga as CRON_LINE, Ja as PR_STATES, Ka as ITEM_STATES, Qa as TASK_STATUSES, Wn as GROUP_FILE_LIMITS, Xa as RUN_RESULTS, Ya as ROUTINE_STATES, Za as STATUS_CARD_LIMITS, ao as statusCardBytes, da as VOICE_LIMITS, no as cardUrl, qa as PR_CHECKS, to as cardLine } from "./src-DWw2hUE5.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-odSAoasK.js";
3
3
  import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-mnjSQlbX.js";
4
- import { p as namedByThem, t as CONTACT_KEY } from "./apiKit-BFk7GAk9.js";
4
+ import { m as namedByThem, t as CONTACT_KEY } from "./apiKit-DJb9hulp.js";
5
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-C6XWqre5.js";
6
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-Bp9lJDxf.js";
7
7
  import { accessSync, closeSync, constants, existsSync, fstatSync, openSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -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.2",
15
+ version: "1.7.3",
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",
@@ -131,6 +131,10 @@ function parseArgs(argv, spec, idSlot = () => false) {
131
131
  };
132
132
  const positionals = [];
133
133
  const options = {};
134
+ const setBoolean = (name, value) => {
135
+ if (all[name].eitherWay && options[name] !== void 0 && options[name] !== value) throw new CliError("usage", `--${name} or --no-${name}, not both`);
136
+ options[name] = value;
137
+ };
134
138
  for (let i = 0; i < argv.length; i++) {
135
139
  const arg = argv[i];
136
140
  if (arg === "--") {
@@ -153,14 +157,14 @@ function parseArgs(argv, spec, idSlot = () => false) {
153
157
  name = long;
154
158
  }
155
159
  if (name.startsWith("no-") && all[name.slice(3)]?.type === "boolean" && inline === void 0) {
156
- options[name.slice(3)] = false;
160
+ setBoolean(name.slice(3), false);
157
161
  continue;
158
162
  }
159
163
  const option = all[name];
160
164
  if (!option) throw new CliError("usage", `Unknown option --${name}`);
161
165
  if (option.type === "boolean") {
162
166
  if (inline !== void 0 && !["true", "false"].includes(inline)) throw new CliError("usage", `--${name} takes no value`);
163
- options[name] = inline === void 0 ? true : inline === "true";
167
+ setBoolean(name, inline === void 0 || inline === "true");
164
168
  continue;
165
169
  }
166
170
  let value = inline;
@@ -610,7 +614,10 @@ function typingFor(options) {
610
614
  if (options.stop === true) throw new CliError("usage", "--for keeps it on: not with --stop");
611
615
  return seconds;
612
616
  }
613
- /** The ranges the API takes (api.ts, files.ts): the most minutes of a `--hold` (a week, HOLD_MAX_MINUTES), seconds. */
617
+ /**
618
+ * The ranges the API takes (api.ts, files.ts): the most minutes of a `--hold` (a week, HOLD_MAX_MINUTES), seconds;
619
+ * `chat connect`'s, the chat link's own wait for a contact (CONNECT_MAX_SECONDS).
620
+ */
614
621
  var HOLD_MINUTES = 10080;
615
622
  var WAIT_SECONDS = 3600;
616
623
  var LONG_WAIT_SECONDS = 86400;
@@ -1150,7 +1157,7 @@ var commands$8 = {
1150
1157
  description: "Replace the three files when they are there"
1151
1158
  }
1152
1159
  },
1153
- run: async ({ options }, a) => (await import("./apps-D6THreq_.js")).initApp(a.dir, {
1160
+ run: async ({ options }, a) => (await import("./apps-BfoDISRg.js")).initApp(a.dir, {
1154
1161
  name: options.name,
1155
1162
  title: options.title,
1156
1163
  force: options.force === true
@@ -1190,7 +1197,7 @@ var commands$8 = {
1190
1197
  description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
1191
1198
  }
1192
1199
  },
1193
- run: async ({ options }, a) => (await import("./apps-D6THreq_.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1200
+ run: async ({ options }, a) => (await import("./apps-BfoDISRg.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1194
1201
  },
1195
1202
  "app revoke": {
1196
1203
  method: "app.revoke",
@@ -1223,7 +1230,7 @@ var commands$8 = {
1223
1230
  description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere)"
1224
1231
  }
1225
1232
  },
1226
- run: async ({ options }, a) => (await import("./apps-D6THreq_.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>]"), {
1233
+ run: async ({ options }, a) => (await import("./apps-BfoDISRg.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
1227
1234
  digests: options.digest,
1228
1235
  upTo: options["up-to"],
1229
1236
  reason: options.reason,
@@ -1284,7 +1291,7 @@ var commands$8 = {
1284
1291
  usage: "app verify <bundle|url>",
1285
1292
  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",
1286
1293
  args: ["bundle"],
1287
- run: async (_, a) => (await import("./apps-D6THreq_.js")).verifyApp(a.bundle)
1294
+ run: async (_, a) => (await import("./apps-BfoDISRg.js")).verifyApp(a.bundle)
1288
1295
  },
1289
1296
  "store sign": {
1290
1297
  method: "store.sign",
@@ -1301,7 +1308,7 @@ var commands$8 = {
1301
1308
  description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
1302
1309
  }
1303
1310
  },
1304
- run: async ({ options }, a) => (await import("./apps-D6THreq_.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1311
+ run: async ({ options }, a) => (await import("./apps-BfoDISRg.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1305
1312
  }
1306
1313
  };
1307
1314
  //#endregion
@@ -1341,7 +1348,7 @@ var commands$7 = {
1341
1348
  rate
1342
1349
  },
1343
1350
  params: ({ options }, a) => {
1344
- if (a.mode !== void 0 && a.mode !== "on" && a.mode !== "off") throw new CliError("usage", "ghostly call auto [on|off] [--from <chat>]... [--rate n]");
1351
+ if (a.mode !== void 0 && a.mode !== "on" && a.mode !== "off") throw new CliError("usage", `call auto takes on or off, not ${JSON.stringify(a.mode)}: ghostly call auto [on|off] [--from <chat>]... [--rate 48000]`);
1345
1352
  if (a.mode !== "on" && (options.from !== void 0 || options.rate !== void 0)) throw new CliError("usage", "--from and --rate go with on: ghostly call auto on --from <chat>");
1346
1353
  refs(options.from, "from", "chat");
1347
1354
  if (a.mode === void 0) return {};
@@ -1385,6 +1392,49 @@ var commands$7 = {
1385
1392
  };
1386
1393
  //#endregion
1387
1394
  //#region src/commands/chats.ts
1395
+ /** `react` and `pin` in a 1:1 chat: until the contact confirmed it, by default without a daemon (the process leaves). */
1396
+ var confirmWait = {
1397
+ wait: {
1398
+ type: "string",
1399
+ choices: ["none", "confirmed"],
1400
+ description: "none or confirmed: until the contact confirmed it, in a 1:1 chat (default: none with a daemon, confirmed without)"
1401
+ },
1402
+ timeout: groupWait.timeout
1403
+ };
1404
+ /** The card commands: in a chat a one-shot stays until the card went out, as `send` (a group has no receipts). */
1405
+ var ONE_SHOT_DEFAULT = (word) => `(default: none with a daemon; without one, ${word} in a chat and none in a group)`;
1406
+ var cardWait = {
1407
+ wait: {
1408
+ type: "string",
1409
+ choices: [
1410
+ "none",
1411
+ "sent",
1412
+ "delivered"
1413
+ ],
1414
+ description: `none, sent or delivered; in a group none or sent: until an edge took it ${ONE_SHOT_DEFAULT("sent")}`
1415
+ },
1416
+ timeout: groupWait.timeout
1417
+ };
1418
+ var cardUpdateWait = {
1419
+ wait: {
1420
+ type: "string",
1421
+ choices: [
1422
+ "none",
1423
+ "confirmed",
1424
+ "sent"
1425
+ ],
1426
+ description: `none, confirmed (a chat's contact took it) or sent (a group's edge took it) ${ONE_SHOT_DEFAULT("confirmed")}`
1427
+ },
1428
+ timeout: groupWait.timeout
1429
+ };
1430
+ var usageWait = {
1431
+ wait: {
1432
+ type: "string",
1433
+ choices: ["none", "sent"],
1434
+ description: `none or sent: until the contact has it in a chat, an edge took it in a group ${ONE_SHOT_DEFAULT("sent")}`
1435
+ },
1436
+ timeout: groupWait.timeout
1437
+ };
1388
1438
  var BUTTON_UPDATE = "button update <chat|group> <message> [--chosen <button>] [--close] [--text <text>] [--force] [--wait none|confirmed|sent] [--timeout s]";
1389
1439
  /** Invites, chats and messages: one entry per command, in alphabetical order (test/commands.test.ts checks). */
1390
1440
  var commands$6 = {
@@ -1463,10 +1513,17 @@ var commands$6 = {
1463
1513
  },
1464
1514
  "chat connect": {
1465
1515
  method: "chat.connect",
1466
- usage: "chat connect <chat>",
1516
+ usage: "chat connect <chat> [--timeout s]",
1467
1517
  summary: "Reconnect a chat now (ends a --hold)",
1468
1518
  args: ["chat"],
1469
- params: (_, { chat }) => ({ chat })
1519
+ options: { timeout: {
1520
+ type: "number",
1521
+ description: `Seconds to wait for the contact (default and at most 90)`
1522
+ } },
1523
+ params: ({ options }, { chat }) => ({
1524
+ chat,
1525
+ timeout: timeout(options, 90)
1526
+ })
1470
1527
  },
1471
1528
  "chat disconnect": {
1472
1529
  method: "chat.disconnect",
@@ -1665,22 +1722,35 @@ var commands$6 = {
1665
1722
  },
1666
1723
  "message delete": {
1667
1724
  method: "chat.delete",
1668
- usage: "message delete <chat|group> <message> [--everyone]",
1725
+ usage: "message delete <chat|group> <message> [--everyone [--wait none|confirmed] [--timeout s]]",
1669
1726
  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",
1670
1727
  args: ["chat", "message"],
1671
- options: { everyone: {
1672
- type: "boolean",
1673
- description: "Delete a message of yours for everyone (a chat or a group)"
1674
- } },
1675
- params: ({ options }, a) => ({
1676
- chat: a.chat,
1677
- message: a.message,
1678
- everyone: options.everyone === true
1679
- })
1728
+ options: {
1729
+ everyone: {
1730
+ type: "boolean",
1731
+ description: "Delete a message of yours for everyone (a chat or a group)"
1732
+ },
1733
+ wait: {
1734
+ type: "string",
1735
+ choices: ["none", "confirmed"],
1736
+ description: "With --everyone in a chat: none or confirmed, until the contact has it (default: none with a daemon, confirmed without)"
1737
+ },
1738
+ timeout: wait.timeout
1739
+ },
1740
+ params: ({ options }, a) => {
1741
+ for (const flag of ["wait", "timeout"]) if (options[flag] !== void 0 && options.everyone !== true) throw new CliError("usage", `--${flag} goes with --everyone`);
1742
+ return {
1743
+ chat: a.chat,
1744
+ message: a.message,
1745
+ everyone: options.everyone === true,
1746
+ wait: options.wait,
1747
+ timeout: timeout(options)
1748
+ };
1749
+ }
1680
1750
  },
1681
1751
  "message details": {
1682
1752
  method: "chat.details",
1683
- usage: "message details <chat> <message>",
1753
+ usage: "message details <chat|group> <message>",
1684
1754
  summary: "How a message travelled",
1685
1755
  args: ["chat", "message"],
1686
1756
  params: (_, a) => ({
@@ -1700,41 +1770,51 @@ var commands$6 = {
1700
1770
  },
1701
1771
  "pin": {
1702
1772
  method: "chat.pin",
1703
- usage: "pin <chat|group> <message> | --remove",
1773
+ usage: "pin <chat|group> <message> | --remove [--wait none|confirmed] [--timeout s]",
1704
1774
  summary: "Pin a message at the top of a chat or group (one per chat: it replaces the pinned one); --remove unpins",
1705
1775
  args: ["chat", "message...?"],
1706
- options: { remove: {
1707
- type: "boolean",
1708
- description: "Unpin the chat's pinned message (it names no message)"
1709
- } },
1776
+ options: {
1777
+ remove: {
1778
+ type: "boolean",
1779
+ description: "Unpin the chat's pinned message (it names no message)"
1780
+ },
1781
+ ...confirmWait
1782
+ },
1710
1783
  params: ({ options }, a) => {
1711
1784
  if (a.message === void 0 && options.remove !== true) throw new CliError("usage", "Missing <message>: ghostly pin <chat|group> <message> | --remove");
1712
1785
  if (a.message?.includes(" ")) throw new CliError("usage", "Too many arguments: ghostly pin <chat|group> <message> | --remove");
1713
1786
  return {
1714
1787
  chat: a.chat,
1715
1788
  message: a.message,
1716
- remove: options.remove === true
1789
+ remove: options.remove === true,
1790
+ wait: options.wait,
1791
+ timeout: timeout(options)
1717
1792
  };
1718
1793
  }
1719
1794
  },
1720
1795
  "react": {
1721
1796
  method: "chat.react",
1722
- usage: "react <chat> <message> <emoji> [--remove]",
1797
+ usage: "react <chat> <message> <emoji> [--remove] [--wait none|confirmed] [--timeout s]",
1723
1798
  summary: "React to a message with one emoji (it replaces yours); --remove takes yours back",
1724
1799
  args: [
1725
1800
  "chat",
1726
1801
  "message",
1727
1802
  "emoji...?"
1728
1803
  ],
1729
- options: { remove: {
1730
- type: "boolean",
1731
- description: "Take your reaction back"
1732
- } },
1804
+ options: {
1805
+ remove: {
1806
+ type: "boolean",
1807
+ description: "Take your reaction back"
1808
+ },
1809
+ ...confirmWait
1810
+ },
1733
1811
  params: ({ options }, a) => ({
1734
1812
  chat: a.chat,
1735
1813
  message: a.message,
1736
1814
  emoji: a.emoji,
1737
- remove: options.remove === true
1815
+ remove: options.remove === true,
1816
+ wait: options.wait,
1817
+ timeout: timeout(options)
1738
1818
  })
1739
1819
  },
1740
1820
  "routine send": {
@@ -1748,8 +1828,7 @@ var commands$6 = {
1748
1828
  description: "The routine's id, kept across updates (default: made up)"
1749
1829
  },
1750
1830
  ...routineOptions,
1751
- ...groupWait,
1752
- wait: wait.wait
1831
+ ...cardWait
1753
1832
  },
1754
1833
  params: ({ options }, { chat }) => ({
1755
1834
  chat,
@@ -1768,16 +1847,7 @@ var commands$6 = {
1768
1847
  args: ["chat", "routine"],
1769
1848
  options: {
1770
1849
  ...routineOptions,
1771
- wait: {
1772
- type: "string",
1773
- choices: [
1774
- "none",
1775
- "confirmed",
1776
- "sent"
1777
- ],
1778
- description: "none (default), confirmed (a chat's contact took it) or sent (a group's edge took it)"
1779
- },
1780
- timeout: groupWait.timeout
1850
+ ...cardUpdateWait
1781
1851
  },
1782
1852
  params: ({ options }, a) => ({
1783
1853
  chat: a.chat,
@@ -1826,8 +1896,7 @@ var commands$6 = {
1826
1896
  description: "The task's id, kept across updates (default: made up)"
1827
1897
  },
1828
1898
  ...taskOptions,
1829
- ...groupWait,
1830
- wait: wait.wait
1899
+ ...cardWait
1831
1900
  },
1832
1901
  params: ({ options }, { chat }) => ({
1833
1902
  chat,
@@ -1845,16 +1914,7 @@ var commands$6 = {
1845
1914
  args: ["chat", "task"],
1846
1915
  options: {
1847
1916
  ...taskOptions,
1848
- wait: {
1849
- type: "string",
1850
- choices: [
1851
- "none",
1852
- "confirmed",
1853
- "sent"
1854
- ],
1855
- description: "none (default), confirmed (a chat's contact took it) or sent (a group's edge took it)"
1856
- },
1857
- timeout: groupWait.timeout
1917
+ ...cardUpdateWait
1858
1918
  },
1859
1919
  params: ({ options }, a) => ({
1860
1920
  chat: a.chat,
@@ -1901,10 +1961,11 @@ var commands$6 = {
1901
1961
  args: ["chat?"],
1902
1962
  options: {
1903
1963
  ...usageOptions,
1904
- ...groupWait
1964
+ ...usageWait
1905
1965
  },
1906
1966
  params: ({ options }, { chat }) => {
1907
1967
  if (!chat && options.all !== true) throw new CliError("usage", "Name a chat or group, or give --all: ghostly usage send <chat|--all> --left <percent>");
1968
+ if (chat && options.all === true) throw new CliError("usage", "Name a chat or group or give --all, not both: ghostly usage send <chat|--all> --left <percent>");
1908
1969
  return {
1909
1970
  chat,
1910
1971
  all: options.all === true,
@@ -2479,7 +2540,7 @@ var commands$2 = {
2479
2540
  },
2480
2541
  stdin: {
2481
2542
  type: "boolean",
2482
- description: "The tool's output, from stdin"
2543
+ description: "The tool's output, from stdin (piped to it without the flag is read too)"
2483
2544
  }
2484
2545
  },
2485
2546
  params: ({ options }, a) => {
@@ -3839,6 +3900,28 @@ async function textFromStdin(read, command, asked, note) {
3839
3900
  as: "arguments"
3840
3901
  })).replace(/\n$/, "");
3841
3902
  }
3903
+ /**
3904
+ * `identity complete <draft>` with neither --evidence-file nor --stdin, stdin not a terminal: asked with nothing first,
3905
+ * since a published record takes none; a draft that answers it takes a tool's output (`details.needs`) is asked again
3906
+ * with what was piped, read as a send reads its text.
3907
+ */
3908
+ async function completeWithPipedEvidence(call, params, read, note) {
3909
+ try {
3910
+ return await call(params);
3911
+ } catch (error) {
3912
+ if (!(error instanceof CliError) || error.details?.needs !== "evidence") throw error;
3913
+ }
3914
+ const evidence = await readUnasked(read, note, {
3915
+ what: "what the tool printed",
3916
+ missing: "Missing what the tool printed",
3917
+ command: `identity complete ${String(params.draft)}`,
3918
+ as: "--evidence-file f"
3919
+ });
3920
+ return call({
3921
+ ...params,
3922
+ evidence
3923
+ });
3924
+ }
3842
3925
  async function readUnasked(read, note, ask) {
3843
3926
  let noteTimer, giveUpTimer;
3844
3927
  const stop = () => {
@@ -3856,6 +3939,39 @@ async function readUnasked(read, note, ask) {
3856
3939
  }
3857
3940
  }
3858
3941
  /**
3942
+ * `identity add`'s fields: each `--field name=value`, then with `--stdin` the `name=value` lines piped to it (a NIP-46
3943
+ * signer's bunker:// link holds the signer's secret). `secret`: the names the signer's form marks `kind: "secret"`
3944
+ * (`identitySecretFields`); one given as a `--field` still goes, with the warning. Neither error repeats a value.
3945
+ */
3946
+ async function identityFields(items, stdin, secret, read, tty = false) {
3947
+ const fields = {};
3948
+ for (const item of items) {
3949
+ const eq = item.indexOf("=");
3950
+ if (eq < 1) throw new CliError("usage", "--field takes name=value, and one has no name or no =");
3951
+ fields[item.slice(0, eq)] = item.slice(eq + 1);
3952
+ }
3953
+ const onLine = secret.filter((name) => fields[name] !== void 0);
3954
+ if (stdin) {
3955
+ if (tty) throw new CliError("usage", "--stdin takes the fields as name=value lines piped to it (… | ghostly identity add <provider> --signer id --stdin), not a terminal");
3956
+ for (const line of (await read()).split(/\r?\n/)) {
3957
+ if (!line.trim()) continue;
3958
+ const eq = line.indexOf("=");
3959
+ if (eq < 1) throw new CliError("usage", "--stdin takes name=value lines, and one has no name or no =");
3960
+ fields[line.slice(0, eq).trim()] = line.slice(eq + 1);
3961
+ }
3962
+ }
3963
+ if (!onLine.length) return { fields };
3964
+ return {
3965
+ fields,
3966
+ warning: `${onLine.map((name) => `--field ${name}`).join(", ")} on the command line shows in ps and the shell's history: give ${onLine.length > 1 ? "them" : "it"} on stdin instead (--stdin, name=value lines)`
3967
+ };
3968
+ }
3969
+ /** The fields a provider's signer marks `kind: "secret"`: the one `--signer` names, or any of its signers when none is. */
3970
+ function identitySecretFields(provider, signer) {
3971
+ const signers = (provider?.signers ?? []).filter((s) => signer === void 0 || s.id === signer);
3972
+ return [...new Set(signers.flatMap((s) => (s.fields ?? []).filter((f) => f.kind === "secret").map((f) => f.name)))];
3973
+ }
3974
+ /**
3859
3975
  * `wallet create --value`: the names given on the command line that the chosen source's form marks `kind: "secret"`
3860
3976
  * (an NWC URI, a macaroon, a rune, an RPC password), as a warning. `list`: a `wallet.list` answer, where the forms are.
3861
3977
  */
@@ -3875,15 +3991,15 @@ var VERSION = package_default.version;
3875
3991
  * command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
3876
3992
  * cost every command ~100 ms before its socket was opened.
3877
3993
  */
3878
- var engineApi = () => import("./api-CcuCtc1H.js");
3879
- var engineHost = () => import("./host-DpypH-fR.js");
3994
+ var engineApi = () => import("./api-B42F9ytB.js");
3995
+ var engineHost = () => import("./host-BX0DmKW6.js");
3880
3996
  /**
3881
3997
  * `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
3882
3998
  * asked: the app's message parser it reads costs every other command nothing.
3883
3999
  */
3884
4000
  async function translatorFor(value, home) {
3885
4001
  if (value === void 0) return null;
3886
- const { loadDetector, openTranslator, translateTarget } = await import("./translate-cDBotA-b.js");
4002
+ const { loadDetector, openTranslator, translateTarget } = await import("./translate-DObb-1tq.js");
3887
4003
  return openTranslator({
3888
4004
  home,
3889
4005
  to: translateTarget(value),
@@ -4252,7 +4368,7 @@ var SPECIAL = [
4252
4368
  "Keep the profile online (foreground; --detach runs it in the background)",
4253
4369
  {
4254
4370
  detach: o("boolean", "Run in the background (log in the profile folder)"),
4255
- timeout: o("number", "Seconds --detach waits for it to start (default 60)")
4371
+ timeout: o("number", "Seconds it waits for a command that holds the profile, and --detach for it to start (default 60)")
4256
4372
  }
4257
4373
  ],
4258
4374
  [
@@ -4309,11 +4425,12 @@ var SPECIAL = [
4309
4425
  ],
4310
4426
  ["call pipe [<chat|call>]", "A call's audio on stdin/stdout: raw s16le mono PCM at the call's rate (e.g. with sox or ffmpeg)"],
4311
4427
  [
4312
- "identity add <provider> [subject] [--signer id] [--field name=value]... [--days n]",
4428
+ "identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]",
4313
4429
  "Make an identity proof (a tool's or a published one finishes with identity complete)",
4314
4430
  {
4315
4431
  signer: o("string", "Which signer makes the proof (identity providers lists them)"),
4316
4432
  field: o("list", "A field of the provider's form, name=value"),
4433
+ stdin: o("boolean", "Take the fields as name=value lines on stdin (a signer's link: out of ps and the shell's history)"),
4317
4434
  days: o("number", "How long the proof holds"),
4318
4435
  timeout: o("number", "Seconds to wait for an approval")
4319
4436
  }
@@ -4403,7 +4520,7 @@ function commandHelp(words) {
4403
4520
  let rows = named(words);
4404
4521
  while (!rows.length && words.length > 1) rows = named(words = words.slice(0, -1));
4405
4522
  const asked = words.join(" ");
4406
- if (!rows.length) throw new CliError("usage", `Unknown command: ${asked} (ghostly help)`);
4523
+ if (!rows.length) throw new CliError("usage", `Unknown command: ${asked || "\"\""} (ghostly help)`);
4407
4524
  const exact = rows.filter((row) => commandWords(row.usage).join(" ") === asked);
4408
4525
  if (!exact.length && words.length < given.length) throw unknownCommand(given[0], given[1], given[2]);
4409
4526
  const lines = [];
@@ -4477,7 +4594,8 @@ async function profileCommand(sub, argv) {
4477
4594
  },
4478
4595
  "share-profile": {
4479
4596
  type: "boolean",
4480
- description: ""
4597
+ description: "",
4598
+ eitherWay: true
4481
4599
  }
4482
4600
  }
4483
4601
  }[sub ?? ""] ?? {});
@@ -4486,7 +4604,8 @@ async function profileCommand(sub, argv) {
4486
4604
  switch (sub) {
4487
4605
  case "create": {
4488
4606
  const [name] = parsed.positionals;
4489
- if (!name || parsed.positionals.length > 1) throw new CliError("usage", "ghostly profile create <name>");
4607
+ if (!name) throw new CliError("usage", "Missing <name>: ghostly profile create <name> [--use] [--name <shown name>]");
4608
+ noMoreThan(1, parsed.positionals, "profile create <name> [--use] [--name <shown name>]");
4490
4609
  const shownName = parsed.options.name === void 0 ? void 0 : checkShownName(parsed.options.name);
4491
4610
  const paths = createProfile(g.home, name);
4492
4611
  let shown = null;
@@ -4527,7 +4646,7 @@ async function profileCommand(sub, argv) {
4527
4646
  }
4528
4647
  case "use": {
4529
4648
  const [name] = parsed.positionals;
4530
- if (!name) throw new CliError("usage", "ghostly profile use <name>");
4649
+ if (!name) throw new CliError("usage", "Missing <name>: ghostly profile use <name>");
4531
4650
  noMoreThan(1, parsed.positionals, "profile use <name>");
4532
4651
  selectProfile(g.home, name);
4533
4652
  print({ current: name });
@@ -4542,14 +4661,14 @@ async function profileCommand(sub, argv) {
4542
4661
  const params = {};
4543
4662
  if (parsed.options.name !== void 0) params.name = parsed.options.name;
4544
4663
  if (parsed.options["share-profile"] !== void 0) params.shareProfile = parsed.options["share-profile"];
4545
- if (!Object.keys(params).length) throw new CliError("usage", "ghostly profile set [--name <name>] [--share-profile | --no-share-profile]");
4664
+ if (!Object.keys(params).length) throw new CliError("usage", "Nothing to change: ghostly profile set [--name <name>] [--share-profile | --no-share-profile]");
4546
4665
  print(await withSession(g, (s) => s.call("profile.set", params)));
4547
4666
  return;
4548
4667
  }
4549
4668
  case "backup": {
4550
4669
  noMoreThan(0, parsed.positionals, "profile backup --out <file> [--passphrase-file f | --no-passphrase] [--light]");
4551
4670
  const out = parsed.options.out;
4552
- if (typeof out !== "string") throw new CliError("usage", "ghostly profile backup --out <file> [--passphrase-file f | --no-passphrase] [--light] (or GHOSTLY_BACKUP_PASSPHRASE)");
4671
+ if (typeof out !== "string") throw new CliError("usage", "Missing --out: ghostly profile backup --out <file> [--passphrase-file f | --no-passphrase] [--light]");
4553
4672
  const unsealed = parsed.options.passphrase === false;
4554
4673
  if (parsed.options.passphrase === true) throw new CliError("usage", "The passphrase comes from --passphrase-file or GHOSTLY_BACKUP_PASSPHRASE, never the command line");
4555
4674
  if (unsealed && (parsed.options["passphrase-file"] !== void 0 || process.env.GHOSTLY_BACKUP_PASSPHRASE)) throw new CliError("usage", "A passphrase is set (--passphrase-file or GHOSTLY_BACKUP_PASSPHRASE) and --no-passphrase was given: choose one");
@@ -4571,10 +4690,10 @@ async function profileCommand(sub, argv) {
4571
4690
  }
4572
4691
  case "restore": {
4573
4692
  const [given, name] = parsed.positionals;
4574
- if (!given || !name) throw new CliError("usage", "ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]");
4693
+ if (!given || !name) throw new CliError("usage", `Missing <${given ? "new profile" : "file"}>: ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]`);
4575
4694
  noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
4576
4695
  const file = here(given);
4577
- const { backupFileProtection, restoreProfile } = await import("./backup-A0hIa9GE.js");
4696
+ const { backupFileProtection, restoreProfile } = await import("./backup-BkUeeduy.js");
4578
4697
  const protection = await backupFileProtection(file);
4579
4698
  const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
4580
4699
  if (parsed.options.use) selectProfile(g.home, name);
@@ -4635,11 +4754,30 @@ function backupPassphrase(file, missing = BACKUP_PASSPHRASE) {
4635
4754
  if (!value) throw new CliError("bad_request", `${file} is empty: it holds the backup's passphrase`);
4636
4755
  return value;
4637
4756
  }
4638
- async function runDaemon(g) {
4757
+ /** Set on `startDetached`'s child: its parent waits for the profile and starts it again, so the child does not wait too. */
4758
+ var DETACHED_CHILD = "GHOSTLY_DAEMON_DETACHED";
4759
+ /**
4760
+ * The daemon in this process. A one-shot command that holds the profile for a moment (a bot's `send` in the gap of a
4761
+ * service manager's restart) is waited for until `seconds`, as `daemon --detach` waits for it: the first look used to be
4762
+ * the answer, and the profile was left with no daemon. A daemon that comes up meanwhile is the answer instead.
4763
+ */
4764
+ async function runDaemon(g, seconds) {
4639
4765
  requireProfile(g);
4640
- if (await connectDaemon(g.paths)) throw new CliError("busy", `A daemon already runs profile ${g.profile}`);
4766
+ const detached = process.env[DETACHED_CHILD] === "1";
4767
+ delete process.env[DETACHED_CHILD];
4641
4768
  const { keepServing, openHost, serve } = await engineHost();
4642
- const host = await openHost(g.paths, "daemon", VERSION);
4769
+ const until = Date.now() + seconds * 1e3;
4770
+ let host;
4771
+ for (;;) {
4772
+ if (await connectDaemon(g.paths)) throw new CliError("busy", `A daemon already runs profile ${g.profile}`);
4773
+ try {
4774
+ host = await openHost(g.paths, "daemon", VERSION);
4775
+ break;
4776
+ } catch (error) {
4777
+ if (detached || !(error instanceof CliError) || error.code !== "busy" || Date.now() >= until) throw error;
4778
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(100, until - Date.now()))));
4779
+ }
4780
+ }
4643
4781
  let served;
4644
4782
  try {
4645
4783
  served = await serve(host);
@@ -4748,7 +4886,7 @@ async function daemonCommand(argv) {
4748
4886
  if (sub) throw unknownCommand("daemon", sub);
4749
4887
  const startFor = seconds(parsed, 60);
4750
4888
  if (!parsed.options.detach) {
4751
- await runDaemon(g);
4889
+ await runDaemon(g, startFor);
4752
4890
  return;
4753
4891
  }
4754
4892
  print(await startDetached(g, startFor));
@@ -4858,7 +4996,11 @@ async function spawnDaemon(g, until) {
4858
4996
  "ignore",
4859
4997
  log,
4860
4998
  log
4861
- ]
4999
+ ],
5000
+ env: {
5001
+ ...process.env,
5002
+ [DETACHED_CHILD]: "1"
5003
+ }
4862
5004
  });
4863
5005
  closeSync(log);
4864
5006
  child.unref();
@@ -5142,7 +5284,8 @@ async function engineCommand(argv) {
5142
5284
  return;
5143
5285
  }
5144
5286
  const [method, raw] = parsed.positionals;
5145
- if (!method || parsed.positionals.length > 2) throw new CliError("usage", "ghostly engine <method> [json-params | -]");
5287
+ if (!method) throw new CliError("usage", "Missing <method>: ghostly engine <method> [json-params | -] [--confirm-real] [--show-secret] [--yes] [--force]");
5288
+ noMoreThan(2, parsed.positionals, "engine <method> [json-params | -] [--confirm-real] [--show-secret] [--yes] [--force]");
5146
5289
  if (!ENGINE_METHODS.includes(method) && !ENGINE_READS.includes(method)) throw new CliError("not_found", `The engine has no call ${method} (ghostly engine --list)`);
5147
5290
  const showSecret = parsed.options["show-secret"] === true;
5148
5291
  if (SECRET_RESULTS.has(method) && !showSecret) throw new CliError("confirm", `${method} answers with secrets: add --show-secret to print them`);
@@ -5183,7 +5326,8 @@ async function settingsCommand(sub, argv) {
5183
5326
  }
5184
5327
  if (sub === "set") {
5185
5328
  const [key, value] = parsed.positionals;
5186
- if (!key || value === void 0 || parsed.positionals.length > 2) throw new CliError("usage", "ghostly settings set <key> <json-value>");
5329
+ if (!key || value === void 0) throw new CliError("usage", `Missing <${key ? "json-value" : "key"}>: ghostly settings set <key> <json-value>`);
5330
+ noMoreThan(2, parsed.positionals, "settings set <key> <json-value>");
5187
5331
  let parsedValue;
5188
5332
  try {
5189
5333
  parsedValue = JSON.parse(value);
@@ -5203,7 +5347,7 @@ async function textCommand(name, argv) {
5203
5347
  pretty = g.pretty;
5204
5348
  const [target, ...rest] = parsed.positionals;
5205
5349
  const [message, ...words] = spec.message ? rest : [void 0, ...rest];
5206
- if (!target || spec.message && !message) throw new CliError("usage", `ghostly ${spec.usage}`);
5350
+ if (!target || spec.message && !message) throw new CliError("usage", `Missing <${target ? "message" : spec.target}>: ghostly ${spec.usage}`);
5207
5351
  timeout(parsed.options);
5208
5352
  let text = words.join(" ");
5209
5353
  if (parsed.options.text !== void 0) {
@@ -5222,7 +5366,7 @@ async function textCommand(name, argv) {
5222
5366
  };
5223
5367
  if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
5224
5368
  if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
5225
- if (!spec.message) Object.assign(params, (await import("./buttons-Bxxu3lSk.js")).buttonsOf(parsed.options));
5369
+ if (!spec.message) Object.assign(params, (await import("./buttons-Be7u0V5g.js")).buttonsOf(parsed.options));
5226
5370
  print(await withSession(g, (s) => {
5227
5371
  if (spec.target === "chat") {
5228
5372
  params.wait = parsed.options.wait ?? (s.mode === "one-shot" ? spec.message ? "confirmed" : "sent" : "none");
@@ -5249,6 +5393,10 @@ async function identityAddCommand(argv) {
5249
5393
  type: "list",
5250
5394
  description: ""
5251
5395
  },
5396
+ stdin: {
5397
+ type: "boolean",
5398
+ description: ""
5399
+ },
5252
5400
  days: {
5253
5401
  type: "number",
5254
5402
  description: ""
@@ -5261,18 +5409,13 @@ async function identityAddCommand(argv) {
5261
5409
  const g = globals(parsed);
5262
5410
  pretty = g.pretty;
5263
5411
  const [provider, ...subject] = parsed.positionals;
5264
- if (!provider) throw new CliError("usage", "ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--days n]");
5265
- const fields = {};
5266
- for (const item of parsed.options.field ?? []) {
5267
- const eq = item.indexOf("=");
5268
- if (eq < 1) throw new CliError("usage", `--field takes name=value, not ${JSON.stringify(item)}`);
5269
- fields[item.slice(0, eq)] = item.slice(eq + 1);
5270
- }
5412
+ if (!provider) throw new CliError("usage", "Missing <provider>: ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]");
5271
5413
  inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
5272
- if (parsed.options.days !== void 0) {
5273
- const known = (await import("./registry-BlSTJlbv.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider);
5274
- if (known) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
5275
- }
5414
+ const items = parsed.options.field ?? [];
5415
+ const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-CFtlhWCI.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
5416
+ if (known && parsed.options.days !== void 0) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
5417
+ const { fields, warning } = await identityFields(items, parsed.options.stdin === true, identitySecretFields(known, parsed.options.signer), readStdin, process.stdin.isTTY === true);
5418
+ if (warning) process.stderr.write(`ghostly: ${warning}\n`);
5276
5419
  const params = {
5277
5420
  provider,
5278
5421
  subject: subject.join(" ") || void 0,
@@ -5326,6 +5469,7 @@ async function tableCommand(name, argv) {
5326
5469
  const params = command.params?.(parsed, args) ?? {};
5327
5470
  for (const key of Object.keys(params)) if (params[key] === void 0) delete params[key];
5328
5471
  const translator = await translatorFor(parsed.options.translate, g.home);
5472
+ const pipedEvidence = command.method === "identity.complete" && !params.evidenceFile && !params.stdin && process.stdin.isTTY !== true;
5329
5473
  if (command.method === "identity.complete") {
5330
5474
  if (params.evidenceFile) try {
5331
5475
  params.evidence = readFileSync(params.evidenceFile, "utf8");
@@ -5342,7 +5486,8 @@ async function tableCommand(name, argv) {
5342
5486
  } catch (error) {
5343
5487
  throw localFileError(error, params.file) ?? new CliError("usage", `Cannot read the credential: ${error instanceof Error ? error.message : String(error)}`);
5344
5488
  }
5345
- if (!params.credential) throw new CliError("bad_request", params.file === "-" ? "Nothing on stdin: give the SD-JWT VC the issuer sent" : `${params.file} is empty: it holds the SD-JWT VC the issuer sent`);
5489
+ if (!params.credential && params.file === "-") throw new CliError("usage", "Missing <file|->: give the SD-JWT VC on stdin (… | ghostly x401 credential add -) or as a file");
5490
+ if (!params.credential) throw new CliError("bad_request", `${params.file} is empty: it holds the SD-JWT VC the issuer sent`);
5346
5491
  delete params.file;
5347
5492
  }
5348
5493
  const lineValues = command.method === "wallet.create" ? Object.keys(params.values ?? {}) : [];
@@ -5353,7 +5498,7 @@ async function tableCommand(name, argv) {
5353
5498
  const warning = secretValuesWarning(await s.call("wallet.list", { network: params.network ?? "testnet" }).catch(() => void 0), params.type, params.provider, lineValues);
5354
5499
  if (warning) process.stderr.write(`ghostly: ${warning}\n`);
5355
5500
  }
5356
- const result = await s.call(command.method, params);
5501
+ const result = await (pipedEvidence ? completeWithPipedEvidence((p) => s.call(command.method, p), params, readStdin, (note) => process.stderr.write(`ghostly: ${note}\n`)) : s.call(command.method, params));
5357
5502
  if (command.method === "invite.join" && s.mode === "one-shot") {
5358
5503
  const joined = await oneShotJoinWait(s, result, typeof params.label === "string" ? params.label : void 0);
5359
5504
  if (joined.note) process.stderr.write(`ghostly: ${joined.note}\n`);
@@ -5367,7 +5512,7 @@ async function tableCommand(name, argv) {
5367
5512
  });
5368
5513
  if (translator) {
5369
5514
  try {
5370
- printAnswer(await (await import("./translate-cDBotA-b.js")).translateAnswer(result, translator));
5515
+ printAnswer(await (await import("./translate-DObb-1tq.js")).translateAnswer(result, translator));
5371
5516
  } finally {
5372
5517
  translator.close();
5373
5518
  }
@@ -5510,7 +5655,7 @@ function unknownCommand(first, second, third) {
5510
5655
  const list = `${subs.slice(0, -1).join(", ")}${subs.length > 1 ? " or " : ""}${subs.at(-1)}`;
5511
5656
  return new CliError("usage", extra ? `Unknown command: ${name} ${extra}: ghostly ${name} takes ${list} (ghostly help ${name})` : `ghostly ${name} takes a command: ${list} (ghostly help ${name})`);
5512
5657
  }
5513
- return new CliError("usage", `Unknown command: ${asked.slice(0, 2).join(" ")} (ghostly help)`);
5658
+ return new CliError("usage", `Unknown command: ${asked.slice(0, 2).join(" ") || "\"\""} (ghostly help)`);
5514
5659
  }
5515
5660
  /** Leaves once what was printed reached stdout (a pipe drains asynchronously). */
5516
5661
  function exit(code) {
@@ -5546,4 +5691,4 @@ async function run(argv) {
5546
5691
  //#endregion
5547
5692
  export { run };
5548
5693
 
5549
- //# sourceMappingURL=main-BwgoQZVu.js.map
5694
+ //# sourceMappingURL=main-6QOSvQ8b.js.map