@ghostlytools/cli 1.11.3 → 1.12.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 (218) hide show
  1. package/README.md +52 -30
  2. package/SKILL.md +4 -2
  3. package/dist/assets/{api-DBlaoz8i.js → api-DLzCtePC.js} +533 -195
  4. package/dist/assets/api-DLzCtePC.js.map +1 -0
  5. package/dist/assets/{api-DgU4MZPD.js → api-DYMKyb1k.js} +2 -2
  6. package/dist/assets/{apiKit-DesObIDf.js → apiKit-CVaEzKWQ.js} +104 -21
  7. package/dist/assets/apiKit-CVaEzKWQ.js.map +1 -0
  8. package/dist/assets/appFetch-D56GsYuq.js +602 -0
  9. package/dist/assets/appFetch-D56GsYuq.js.map +1 -0
  10. package/dist/assets/apps-BPFW19Wc.js +1 -0
  11. package/dist/assets/{apps-DkMjDHML.js → apps-XnZ8VEuj.js} +66 -38
  12. package/dist/assets/apps-XnZ8VEuj.js.map +1 -0
  13. package/dist/assets/{argon2id-088uQfnH.js → argon2id-B9wFdSj6.js} +2 -3
  14. package/dist/assets/{argon2id-088uQfnH.js.map → argon2id-B9wFdSj6.js.map} +1 -1
  15. package/dist/assets/{arkade-CarKONmH.js → arkade-DryM-q5n.js} +6 -7
  16. package/dist/assets/arkade-DryM-q5n.js.map +1 -0
  17. package/dist/assets/backup-COX6j1_W.js +1 -0
  18. package/dist/assets/{backup-C0OJCJlM.js → backup-DpyvT9Z6.js} +108 -50
  19. package/dist/assets/backup-DpyvT9Z6.js.map +1 -0
  20. package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js +5 -0
  21. package/dist/assets/{bark_ffi_wasm_bg-EY2uc0Bx.js.map → bark_ffi_wasm_bg-CcafsJla.js.map} +1 -1
  22. package/dist/assets/{bark_ffi_wasm_bg-Bxru_BVW.wasm → bark_ffi_wasm_bg-VNmaJsc9.wasm} +0 -0
  23. package/dist/assets/{bitcoind-CdSmvy2y.js → bitcoind-DTsrd7TF.js} +4 -5
  24. package/dist/assets/{bitcoind-CdSmvy2y.js.map → bitcoind-DTsrd7TF.js.map} +1 -1
  25. package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js +5 -0
  26. package/dist/assets/{bitcoindevkit_bg-B-iLWrmX.js.map → bitcoindevkit_bg-BWQHx7vd.js.map} +1 -1
  27. package/dist/assets/bitcoindevkit_bg-DXil67yS.wasm +0 -0
  28. package/dist/assets/{blobFiles-BmsrvZc3.js → blobFiles-DDs34n0r.js} +4 -5
  29. package/dist/assets/{blobFiles-BmsrvZc3.js.map → blobFiles-DDs34n0r.js.map} +1 -1
  30. package/dist/assets/breez_sdk_spark_wasm_bg.wasm +0 -0
  31. package/dist/assets/buttons-Bq7pTXqF.js +1 -0
  32. package/dist/assets/{buttons-fZTEa_2i.js → buttons-BvWqHJeh.js} +46 -23
  33. package/dist/assets/buttons-BvWqHJeh.js.map +1 -0
  34. package/dist/assets/bytes-C1DNGY18.js +132 -0
  35. package/dist/assets/bytes-C1DNGY18.js.map +1 -0
  36. package/dist/assets/{childEnv-K_IzUqQx.js → childEnv-C-99hdbL.js} +2 -3
  37. package/dist/assets/{childEnv-K_IzUqQx.js.map → childEnv-C-99hdbL.js.map} +1 -1
  38. package/dist/assets/{client-Ibk3-e60.js → client-kGZ3ZdUW.js} +30 -13
  39. package/dist/assets/client-kGZ3ZdUW.js.map +1 -0
  40. package/dist/assets/{codec-DMpQqVSt.js → codec-B2rH1mfx.js} +2 -4
  41. package/dist/assets/{codec-DMpQqVSt.js.map → codec-B2rH1mfx.js.map} +1 -1
  42. package/dist/assets/domainProofs-BDNP1dIy.js +280 -0
  43. package/dist/assets/domainProofs-BDNP1dIy.js.map +1 -0
  44. package/dist/assets/{endpoint-DarqblYE.js → endpoint-B0vE5ojY.js} +421 -420
  45. package/dist/assets/endpoint-B0vE5ojY.js.map +1 -0
  46. package/dist/assets/engineErrors--9hfgKlK.js +150 -0
  47. package/dist/assets/engineErrors--9hfgKlK.js.map +1 -0
  48. package/dist/assets/{envelope-CvQVCGdf.js → envelope-Bi2kMqbp.js} +3 -4
  49. package/dist/assets/{envelope-CvQVCGdf.js.map → envelope-Bi2kMqbp.js.map} +1 -1
  50. package/dist/assets/{errors-Dt-ZnyOX.js → errors-DDLFO4Gf.js} +31 -5
  51. package/dist/assets/errors-DDLFO4Gf.js.map +1 -0
  52. package/dist/assets/{fedimintSdk-zV_5Qdqz.js → fedimintSdk-D-6H9Pe7.js} +4 -5
  53. package/dist/assets/{fedimintSdk-zV_5Qdqz.js.map → fedimintSdk-D-6H9Pe7.js.map} +1 -1
  54. package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js +5 -0
  55. package/dist/assets/{fedimint_client_wasm_bg-BtHHlFpp.js.map → fedimint_client_wasm_bg-Cr5xGD-w.js.map} +1 -1
  56. package/dist/assets/fileBytes-CCKbwqG_.js +1 -0
  57. package/dist/assets/{fileBytes-BLPZq9YU.js → fileBytes-CfvUXdSy.js} +5 -7
  58. package/dist/assets/fileBytes-CfvUXdSy.js.map +1 -0
  59. package/dist/assets/{fileBytes-B0z9A6Le.js → fileBytes-tj6-VZcB.js} +3 -4
  60. package/dist/assets/{fileBytes-B0z9A6Le.js.map → fileBytes-tj6-VZcB.js.map} +1 -1
  61. package/dist/assets/fileBytesIdb-B0zzJ6p7.js +1 -0
  62. package/dist/assets/{fileBytesIdb-Bmlrl9EO.js → fileBytesIdb-BJirUAjI.js} +4 -5
  63. package/dist/assets/{fileBytesIdb-Bmlrl9EO.js.map → fileBytesIdb-BJirUAjI.js.map} +1 -1
  64. package/dist/assets/{fileBytesOpfs-DBS0kbPT.js → fileBytesOpfs-DRUYLER4.js} +4 -5
  65. package/dist/assets/{fileBytesOpfs-DBS0kbPT.js.map → fileBytesOpfs-DRUYLER4.js.map} +1 -1
  66. package/dist/assets/{fixedHosts-6gKn8dp2.js → fixedHosts-CPSsGOI2.js} +4 -5
  67. package/dist/assets/{fixedHosts-6gKn8dp2.js.map → fixedHosts-CPSsGOI2.js.map} +1 -1
  68. package/dist/assets/{ghostly_iroh_web-BzAXJUYH.js → ghostly_iroh_web-DIj5xGmR.js} +2 -3
  69. package/dist/assets/{ghostly_iroh_web-BzAXJUYH.js.map → ghostly_iroh_web-DIj5xGmR.js.map} +1 -1
  70. package/dist/assets/{src-DjVj2ynY.js → groupMeta-DTQAJG50.js} +4879 -23799
  71. package/dist/assets/groupMeta-DTQAJG50.js.map +1 -0
  72. package/dist/assets/{host-CYlIiY3r.js → host-z0FAHP9Z.js} +750 -245
  73. package/dist/assets/host-z0FAHP9Z.js.map +1 -0
  74. package/dist/assets/{hyperdhtRelay-CdsLcAhY.js → hyperdhtRelay-CvsAfQRQ.js} +5 -6
  75. package/dist/assets/hyperdhtRelay-CvsAfQRQ.js.map +1 -0
  76. package/dist/assets/hyperdhtRelay-bjNGacf5.js +32 -0
  77. package/dist/assets/hyperdhtRelay-bjNGacf5.js.map +1 -0
  78. package/dist/assets/{idb-CEuoNsTv.js → idb-ewvbqyDI.js} +2 -3
  79. package/dist/assets/{idb-CEuoNsTv.js.map → idb-ewvbqyDI.js.map} +1 -1
  80. package/dist/assets/identityProofs-Cksc_K7_.js +940 -0
  81. package/dist/assets/identityProofs-Cksc_K7_.js.map +1 -0
  82. package/dist/assets/{irohWeb-D2IuloLL.js → irohWeb-CLBx5MIv.js} +3061 -86
  83. package/dist/assets/irohWeb-CLBx5MIv.js.map +1 -0
  84. package/dist/assets/joinTrace-CBr1jbch.js +1 -0
  85. package/dist/assets/{joinTrace-CjRDFy85.js → joinTrace-xKBe73j9.js} +2 -3
  86. package/dist/assets/{joinTrace-CjRDFy85.js.map → joinTrace-xKBe73j9.js.map} +1 -1
  87. package/dist/assets/{legacy_ciphers-JJOu0JXL.js → legacy_ciphers-BnYATjxo.js} +2 -3
  88. package/dist/assets/{legacy_ciphers-JJOu0JXL.js.map → legacy_ciphers-BnYATjxo.js.map} +1 -1
  89. package/dist/assets/linkPreview-DdMf-YAc.js +252 -0
  90. package/dist/assets/linkPreview-DdMf-YAc.js.map +1 -0
  91. package/dist/assets/{main-C0PfjKTe.js → main-CVqkvuIo.js} +536 -173
  92. package/dist/assets/main-CVqkvuIo.js.map +1 -0
  93. package/dist/assets/{mainline-Cu61qcPS.js → mainline-CVrd0C1n.js} +72 -18
  94. package/dist/assets/mainline-CVrd0C1n.js.map +1 -0
  95. package/dist/assets/mints-BcBODVVW.js +1 -0
  96. package/dist/assets/{mints-j5XAOk4f.js → mints-CMDLbMeH.js} +8 -6
  97. package/dist/assets/mints-CMDLbMeH.js.map +1 -0
  98. package/dist/assets/{nacl-fast-CDhNCYHs.js → nacl-fast-B1ThWvuM.js} +2 -3
  99. package/dist/assets/{nacl-fast-CDhNCYHs.js.map → nacl-fast-B1ThWvuM.js.map} +1 -1
  100. package/dist/assets/{networkReason-Dt7Yx_n4.js → networkReason-Be-hMghr.js} +10 -14
  101. package/dist/assets/{networkReason-Dt7Yx_n4.js.map → networkReason-Be-hMghr.js.map} +1 -1
  102. package/dist/assets/{noble_curves-DDWn5AH0.js → noble_curves-DqpNlhAU.js} +3 -4
  103. package/dist/assets/{noble_curves-DDWn5AH0.js.map → noble_curves-DqpNlhAU.js.map} +1 -1
  104. package/dist/assets/{noble_hashes-B7AZyFyS.js → noble_hashes-LFe1N2xt.js} +3 -4
  105. package/dist/assets/{noble_hashes-B7AZyFyS.js.map → noble_hashes-LFe1N2xt.js.map} +1 -1
  106. package/dist/assets/{nwc-CtZypDcv.js → nwc-DKE2FXr6.js} +5 -6
  107. package/dist/assets/{nwc-CtZypDcv.js.map → nwc-DKE2FXr6.js.map} +1 -1
  108. package/dist/assets/nwcProvider-pL2XqSbW.js +208 -0
  109. package/dist/assets/nwcProvider-pL2XqSbW.js.map +1 -0
  110. package/dist/assets/{openpgp-BBFr-zHQ.js → openpgp-LkR_Zof0.js} +14 -15
  111. package/dist/assets/{openpgp-BBFr-zHQ.js.map → openpgp-LkR_Zof0.js.map} +1 -1
  112. package/dist/assets/ownDid-DY3rYqDI.js +862 -0
  113. package/dist/assets/ownDid-DY3rYqDI.js.map +1 -0
  114. package/dist/assets/{ownStatus-D4HC6tNR.js → ownStatus-DMEhrpkd.js} +81 -19
  115. package/dist/assets/ownStatus-DMEhrpkd.js.map +1 -0
  116. package/dist/assets/pairedTransports-BKmvlKz1.js +581 -0
  117. package/dist/assets/pairedTransports-BKmvlKz1.js.map +1 -0
  118. package/dist/assets/paymentIntent-DySU3Ajm.js +349 -0
  119. package/dist/assets/paymentIntent-DySU3Ajm.js.map +1 -0
  120. package/dist/assets/pkarr-BQo4PcCg.js +367 -0
  121. package/dist/assets/pkarr-BQo4PcCg.js.map +1 -0
  122. package/dist/assets/{profiles-Ccdq6Xf6.js → profiles-BFSGqDFC.js} +30 -16
  123. package/dist/assets/profiles-BFSGqDFC.js.map +1 -0
  124. package/dist/assets/registry-B15Yg_1C.js +1 -0
  125. package/dist/assets/{registry-LvxsLJ5S.js → registry-rXgaZeNn.js} +1273 -58
  126. package/dist/assets/registry-rXgaZeNn.js.map +1 -0
  127. package/dist/assets/relay-Cjfmdec0.js +2219 -0
  128. package/dist/assets/relay-Cjfmdec0.js.map +1 -0
  129. package/dist/assets/resolve-CIc3KZMV.js +970 -0
  130. package/dist/assets/resolve-CIc3KZMV.js.map +1 -0
  131. package/dist/assets/{restoredRows-C3LcxmOw.js → restoredRows-D_WSHE7H.js} +3 -4
  132. package/dist/assets/{restoredRows-C3LcxmOw.js.map → restoredRows-D_WSHE7H.js.map} +1 -1
  133. package/dist/assets/{secretGuard-B7Hj0Kvz.js → secretGuard-B4-LlMjv.js} +75 -16
  134. package/dist/assets/{secretGuard-B7Hj0Kvz.js.map → secretGuard-B4-LlMjv.js.map} +1 -1
  135. package/dist/assets/secretGuard-BmmnEbYf.js +1 -0
  136. package/dist/assets/{server-Q3VcNqGt.js → server-CQR7NLCz.js} +10200 -625
  137. package/dist/assets/server-CQR7NLCz.js.map +1 -0
  138. package/dist/assets/{sha512-BYId-G-T.js → sha512-DST9fbWH.js} +2 -3
  139. package/dist/assets/{sha512-BYId-G-T.js.map → sha512-DST9fbWH.js.map} +1 -1
  140. package/dist/assets/sshForges-BnvwmNj-.js +539 -0
  141. package/dist/assets/sshForges-BnvwmNj-.js.map +1 -0
  142. package/dist/assets/{storage-Bya5b2Xt.js → storage-BpjdxvO2.js} +243 -34
  143. package/dist/assets/storage-BpjdxvO2.js.map +1 -0
  144. package/dist/assets/text-li76pThX.js +106 -0
  145. package/dist/assets/text-li76pThX.js.map +1 -0
  146. package/dist/assets/{translate-iQZq4TnY.js → translate-BcbSWkuq.js} +21 -26
  147. package/dist/assets/{translate-iQZq4TnY.js.map → translate-BcbSWkuq.js.map} +1 -1
  148. package/dist/assets/{tree-store-N362nuzZ.js → tree-store-CAchkO_l.js} +22 -6
  149. package/dist/assets/tree-store-CAchkO_l.js.map +1 -0
  150. package/dist/assets/{types-Clyb52K2.js → types-CdWwgvyt.js} +2 -3
  151. package/dist/assets/{types-Clyb52K2.js.map → types-CdWwgvyt.js.map} +1 -1
  152. package/dist/assets/{unbzip2-stream-B1C-JX9L.js → unbzip2-stream-BtkYGpC5.js} +2 -3
  153. package/dist/assets/{unbzip2-stream-B1C-JX9L.js.map → unbzip2-stream-BtkYGpC5.js.map} +1 -1
  154. package/dist/assets/{usdt-DnyTGdTX.js → usdt-CBJ4Q5Ji.js} +7 -7
  155. package/dist/assets/usdt-CBJ4Q5Ji.js.map +1 -0
  156. package/dist/assets/{waitNotice-Cn0WJ-He.js → waitNotice-BGM0QOS2.js} +27 -4
  157. package/dist/assets/waitNotice-BGM0QOS2.js.map +1 -0
  158. package/dist/assets/{web-DwgdhfcY.js → web-68CYFCl9.js} +314 -91
  159. package/dist/assets/web-68CYFCl9.js.map +1 -0
  160. package/dist/ghostly.mjs +3 -5
  161. package/dist/ghostly.mjs.map +1 -1
  162. package/npm-shrinkwrap.json +225 -200
  163. package/package.json +16 -16
  164. package/dist/assets/api-DBlaoz8i.js.map +0 -1
  165. package/dist/assets/apiKit-DesObIDf.js.map +0 -1
  166. package/dist/assets/appFetch-C8yZIq1e.js +0 -194
  167. package/dist/assets/appFetch-C8yZIq1e.js.map +0 -1
  168. package/dist/assets/apps-DkMjDHML.js.map +0 -1
  169. package/dist/assets/apps-rzxsjfBV.js +0 -2
  170. package/dist/assets/arkade-CarKONmH.js.map +0 -1
  171. package/dist/assets/backup-C0OJCJlM.js.map +0 -1
  172. package/dist/assets/backup-CgWU7x0T.js +0 -2
  173. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js +0 -6
  174. package/dist/assets/bitcoindProvider-BvoRh0D5.js +0 -97
  175. package/dist/assets/bitcoindProvider-BvoRh0D5.js.map +0 -1
  176. package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js +0 -6
  177. package/dist/assets/bitcoindevkit_bg-CRkZTSbO.wasm +0 -0
  178. package/dist/assets/buttons-Cco0Agfa.js +0 -2
  179. package/dist/assets/buttons-fZTEa_2i.js.map +0 -1
  180. package/dist/assets/client-Ibk3-e60.js.map +0 -1
  181. package/dist/assets/endpoint-DarqblYE.js.map +0 -1
  182. package/dist/assets/errors-Dt-ZnyOX.js.map +0 -1
  183. package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js +0 -6
  184. package/dist/assets/fileBytes-BLPZq9YU.js.map +0 -1
  185. package/dist/assets/fileBytes-BtIyoDF2.js +0 -2
  186. package/dist/assets/fileBytesIdb-D8mAK4pF.js +0 -2
  187. package/dist/assets/host-CYlIiY3r.js.map +0 -1
  188. package/dist/assets/hyperdhtRelay-1wzya_0L.js +0 -25
  189. package/dist/assets/hyperdhtRelay-1wzya_0L.js.map +0 -1
  190. package/dist/assets/hyperdhtRelay-CdsLcAhY.js.map +0 -1
  191. package/dist/assets/irohWeb-D2IuloLL.js.map +0 -1
  192. package/dist/assets/joinTrace-D-fnt2p3.js +0 -2
  193. package/dist/assets/jsonOut-POtMBS_V.js +0 -16
  194. package/dist/assets/jsonOut-POtMBS_V.js.map +0 -1
  195. package/dist/assets/main-C0PfjKTe.js.map +0 -1
  196. package/dist/assets/mainline-Cu61qcPS.js.map +0 -1
  197. package/dist/assets/mints-BaOmx517.js +0 -2
  198. package/dist/assets/mints-j5XAOk4f.js.map +0 -1
  199. package/dist/assets/nwcProvider-DYHkd0iu.js +0 -88
  200. package/dist/assets/nwcProvider-DYHkd0iu.js.map +0 -1
  201. package/dist/assets/ownDid-CJ0ta8CL.js +0 -282
  202. package/dist/assets/ownDid-CJ0ta8CL.js.map +0 -1
  203. package/dist/assets/ownStatus-D4HC6tNR.js.map +0 -1
  204. package/dist/assets/profiles-Ccdq6Xf6.js.map +0 -1
  205. package/dist/assets/registry-CE0PpQAE.js +0 -2
  206. package/dist/assets/registry-LvxsLJ5S.js.map +0 -1
  207. package/dist/assets/resolve-6kVu2DE5.js +0 -400
  208. package/dist/assets/resolve-6kVu2DE5.js.map +0 -1
  209. package/dist/assets/secretGuard-DUr6bgKc.js +0 -2
  210. package/dist/assets/server-Q3VcNqGt.js.map +0 -1
  211. package/dist/assets/src-DjVj2ynY.js.map +0 -1
  212. package/dist/assets/sshForges-DeZ9cN9Q.js +0 -261
  213. package/dist/assets/sshForges-DeZ9cN9Q.js.map +0 -1
  214. package/dist/assets/storage-Bya5b2Xt.js.map +0 -1
  215. package/dist/assets/tree-store-N362nuzZ.js.map +0 -1
  216. package/dist/assets/usdt-DnyTGdTX.js.map +0 -1
  217. package/dist/assets/waitNotice-Cn0WJ-He.js.map +0 -1
  218. package/dist/assets/web-DwgdhfcY.js.map +0 -1
@@ -1,12 +1,11 @@
1
- import { Ao as ROUTINE_STATES, Do as ITEM_STATES, Eo as CRON_LINE, Lo as cardLine, Mo as STATUS_CARD_LIMITS, No as TASK_STATUSES, Oo as PR_CHECKS, Qr as STATUS_AVAILABILITIES, Ro as cardUrl, Ua as VOICE_LIMITS, Vo as statusCardBytes, jo as RUN_RESULTS, ko as PR_STATES, sr as GROUP_FILE_LIMITS } from "./src-DjVj2ynY.js";
2
- import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-Dt-ZnyOX.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-D4HC6tNR.js";
4
- import { a as contactKeyOf, v as nameKey, y as namedByThem } from "./apiKit-DesObIDf.js";
5
- import { n as dropSecretEnv, t as childEnv } from "./childEnv-K_IzUqQx.js";
6
- import { i as waitsFor, r as waitNotice } from "./waitNotice-Cn0WJ-He.js";
7
- import { C as ownProfile, _ as profilePaths, c as createProfile, d as ghostlyHome, f as listProfiles, g as profileExists, h as noProfile, i as checkProfileName, l as currentProfile, o as checkShownNameOption, p as lockOwner, s as claimForDaemon, u as daemonClaim, v as selectProfile, x as userPath, y as startingDaemon } from "./profiles-Ccdq6Xf6.js";
8
- import { t as jsonOut } from "./jsonOut-POtMBS_V.js";
9
- import { a as endedUnsent, f as CALL_RATES, i as endedUnanswered, o as isNotTheDaemon, r as connectDaemon, t as DaemonClient, v as isCallRate } from "./client-Ibk3-e60.js";
1
+ import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-DDLFO4Gf.js";
2
+ import { a as endedUnsent, i as endedUnanswered, o as isNotTheDaemon, p as CALL_RATES, r as connectDaemon, s as notTheDaemon, t as DaemonClient, y as isCallRate } from "./client-kGZ3ZdUW.js";
3
+ import { n as dropSecretEnv, t as childEnv } from "./childEnv-C-99hdbL.js";
4
+ import { Cr as cardUrl, D as GROUP_FILE_LIMITS, Dr as statusCardBytes, En as VOICE_LIMITS, Sr as cardLine, Zn as reactionEmoji, _r as TASK_STATUSES, bt as STATUS_AVAILABILITIES, dr as ITEM_STATES, fr as PR_CHECKS, gr as STATUS_CARD_LIMITS, hr as RUN_RESULTS, mr as ROUTINE_STATES, pr as PR_STATES, ur as CRON_LINE } from "./groupMeta-DTQAJG50.js";
5
+ import { S as userPath, _ as profileExists, b as startingDaemon, c as createProfile, d as daemonClaim, f as ghostlyHome, g as noProfile, i as checkProfileName, l as currentProfile, m as lockOwner, o as checkShownNameOption, p as listProfiles, s as claimForDaemon, u as currentProfileOrNone, v as profilePaths, w as ownProfile, y as selectProfile } from "./profiles-BFSGqDFC.js";
6
+ import { _ as hideSecretFields, a as PAY_METHODS, c as turnRef, d as ENGINE_METHODS, f as ENGINE_PARAMS, h as SECRET_RESULTS, i as CHAT_METHODS, m as READ_PARAMS, o as TRANSPORT_NAMES, p as ENGINE_READS, r as ADDRESS_TYPES, s as WALLET_TYPES, t as checkOwnStatus } from "./ownStatus-DMEhrpkd.js";
7
+ import { B as shellWord, V as jsonOut, a as contactKeyOf, b as namedByThem, y as nameKey } from "./apiKit-CVaEzKWQ.js";
8
+ import { i as waitsFor, r as waitNotice } from "./waitNotice-BGM0QOS2.js";
10
9
  import { spawn } from "node:child_process";
11
10
  import { accessSync, closeSync, constants, existsSync, fstatSync, openSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
12
11
  import { dirname, resolve, sep } from "node:path";
@@ -14,7 +13,7 @@ import { connect } from "node:net";
14
13
  import { format } from "node:util";
15
14
  var package_default = {
16
15
  name: "@ghostlytools/cli",
17
- version: "1.11.3",
16
+ version: "1.12.0",
18
17
  type: "module",
19
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.",
20
19
  license: "MIT",
@@ -42,12 +41,12 @@ var package_default = {
42
41
  "test": "vitest run"
43
42
  },
44
43
  dependencies: {
45
- "@arkade-os/sdk": "0.4.79",
44
+ "@arkade-os/sdk": "0.5.4",
46
45
  "@atproto/jwk-webcrypto": "^0.3.4",
47
- "@atproto/oauth-client": "^0.8.9",
48
- "@bitcoindevkit/bdk-wallet-web": "0.3.0",
49
- "@bitcoinerlab/descriptors-scure": "^3.2.0",
50
- "@cashu/cashu-ts": "^4.11.0",
46
+ "@atproto/oauth-client": "^0.9.3",
47
+ "@bitcoindevkit/bdk-wallet-web": "0.4.0",
48
+ "@bitcoinerlab/descriptors-scure": "^3.2.1",
49
+ "@cashu/cashu-ts": "^4.13.0",
51
50
  "@fedimint/core": "0.0.0-canary-eea6a3c98909fa8e736d6dadb1f1243fd3322b27",
52
51
  "@fedimint/fedimint-client-wasm-bundler": "0.0.0-canary-eea6a3c98909fa8e736d6dadb1f1243fd3322b27",
53
52
  "@fedimint/types": "0.0.0-canary-eea6a3c98909fa8e736d6dadb1f1243fd3322b27",
@@ -59,20 +58,20 @@ var package_default = {
59
58
  "@scure/bip32": "^2.4.0",
60
59
  "@scure/bip39": "2.4.0",
61
60
  "@scure/btc-signer": "2.4.1",
62
- "@secondts/bark": "0.25.0",
61
+ "@secondts/bark": "0.27.0",
63
62
  "@serenity-kit/opaque": "1.1.0",
64
- "@synonymdev/pubky": "0.16.2",
63
+ "@synonymdev/pubky": "0.18.0",
65
64
  "@tetherto/wdk-wallet-evm": "1.0.0-beta.24",
66
65
  "b4a": "1.9.0",
67
66
  "bittorrent-dht": "11.0.12",
68
67
  "ethers": "6.17.0",
69
- "eventsource": "^5.1.3",
70
- "fake-indexeddb": "6.2.5",
71
- "hyperdht": "6.34.1",
68
+ "eventsource": "^5.1.4",
69
+ "fake-indexeddb": "6.2.8",
70
+ "hyperdht": "6.36.0",
72
71
  "keet-identity-key": "3.2.0",
73
72
  "mpg123-decoder": "1.0.3",
74
- "node-datachannel": "^0.33.4",
75
- "nostr-tools": "2.25.2",
73
+ "node-datachannel": "^0.33.6",
74
+ "nostr-tools": "2.26.0",
76
75
  "opus-decoder": "0.7.12",
77
76
  "opusscript": "0.1.1",
78
77
  "ws": "8.22.1"
@@ -81,19 +80,28 @@ var package_default = {
81
80
  "@ghostly/browser": "*",
82
81
  "@ghostly/core": "*",
83
82
  "@ghostly/iroh-web": "*",
84
- "@types/node": "^26.6.5",
83
+ "@types/node": "^26.6.6",
85
84
  "typescript": "^5.9.3",
86
- "vite": "^8.3.4",
87
- "vitest": "^5.0.5"
85
+ "vite": "^8.3.6",
86
+ "vitest": "^5.1.0"
88
87
  }
89
88
  };
90
- //#endregion
91
- //#region src/args.ts
89
+ // src/args.ts
92
90
  /**
93
91
  * A number as typed on the command line, in decimal digits only (`21`, `-5`, `12.5`); NaN for any other word.
94
92
  * `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.
95
93
  */
96
94
  var decimalNumber = (value) => /^-?\d+(\.\d+)?$/.test(value) ? Number(value) : NaN;
95
+ var notANumber = (name, option, value) => new CliError("usage", `--${name} takes ${option.takes ?? "a number"}, not ${JSON.stringify(value)}`);
96
+ /**
97
+ * The word right after an option that stood alone because it was no number (`--voice 2s`), by the positionals a parse
98
+ * returned: should the line have one too many, that word was the option's value, and `strayValue` says so.
99
+ */
100
+ var lonelyValues = /* @__PURE__ */ new WeakMap();
101
+ /** The refusal of an option's value that was taken as a positional (`--voice 2s`), else undefined. */
102
+ function strayValue(values) {
103
+ return lonelyValues.get(values)?.find(({ index, word }) => values[index] === word)?.refusal;
104
+ }
97
105
  /**
98
106
  * Options every command takes. They may come anywhere on the line.
99
107
  */
@@ -143,6 +151,7 @@ function parseArgs(argv, spec, idSlot = () => false, parsing) {
143
151
  return Object.hasOwn(all, name) || name.startsWith("no-") && all[name.slice(3)]?.type === "boolean";
144
152
  };
145
153
  const positionals = [];
154
+ const lonely = [];
146
155
  const options = {};
147
156
  const setBoolean = (name, value) => {
148
157
  if (all[name].eitherWay && options[name] !== void 0 && options[name] !== value) throw new CliError("usage", `--${name} or --no-${name}, not both`);
@@ -186,8 +195,14 @@ function parseArgs(argv, spec, idSlot = () => false, parsing) {
186
195
  continue;
187
196
  }
188
197
  let value = inline;
189
- if (value === void 0 && option.optionalValue && !(i + 1 < argv.length && argv[i + 1] !== "" && Number.isFinite(Number(argv[i + 1])))) {
198
+ if (value === void 0 && option.optionalValue && !(i + 1 < argv.length && Number.isFinite(Number(argv[i + 1])))) {
190
199
  options[name] = true;
200
+ const next = argv[i + 1];
201
+ if (next && !next.startsWith("-")) lonely.push({
202
+ index: positionals.length,
203
+ word: next,
204
+ refusal: notANumber(name, option, next)
205
+ });
191
206
  continue;
192
207
  }
193
208
  if (value === void 0) {
@@ -196,7 +211,7 @@ function parseArgs(argv, spec, idSlot = () => false, parsing) {
196
211
  }
197
212
  if (option.type === "number") {
198
213
  const number = decimalNumber(value);
199
- if (!Number.isFinite(number)) throw new CliError("usage", `--${name} takes a number, not ${JSON.stringify(value)}`);
214
+ if (!Number.isFinite(number)) throw notANumber(name, option, value);
200
215
  options[name] = number;
201
216
  } else if (option.type === "list") options[name] = [...options[name] ?? [], value];
202
217
  else {
@@ -208,6 +223,7 @@ function parseArgs(argv, spec, idSlot = () => false, parsing) {
208
223
  if (arg.startsWith("-") && arg !== "-") throw unknownOption(arg, all, parsing);
209
224
  positionals.push(arg);
210
225
  }
226
+ if (lonely.length) lonelyValues.set(positionals, lonely);
211
227
  return {
212
228
  positionals,
213
229
  options
@@ -262,6 +278,24 @@ function distance(a, b) {
262
278
  }
263
279
  return d[a.length][b.length];
264
280
  }
281
+ var SETTINGS_SET = "ghostly settings set <key> <json-value> [--force]";
282
+ /**
283
+ * A key `settings set` does not take is a usage error that names the nearest one (whatever its case: `sendtyping`)
284
+ * and lists them, before stdin is read and the profile opens. Before, the API answered it once a one-shot was online
285
+ * (bad_request, exit 1), with no "did you mean". The API keeps its own check for a socket's callers.
286
+ */
287
+ function checkSettingKey(key, kinds) {
288
+ if (Object.hasOwn(kinds, key)) return kinds[key];
289
+ const byLower = new Map(Object.keys(kinds).map((name) => [name.toLowerCase(), name]));
290
+ const near = byLower.get(nearest(key.toLowerCase(), byLower.keys()) ?? "");
291
+ throw new CliError("usage", `${key} is not a setting the CLI changes${near ? ` (did you mean ${near}?)` : ""}: ghostly settings set takes ${Object.keys(kinds).join(", ")} (ghostly help settings set)`);
292
+ }
293
+ /** A value of another kind than its key takes (`online maybe`): a usage error too, before the profile opens. */
294
+ function checkSettingValue(key, kind, value, typed) {
295
+ if (kind === "boolean" && typeof value !== "boolean") throw new CliError("usage", `${key} takes true or false, not ${JSON.stringify(typed)}: ${SETTINGS_SET}`);
296
+ if (kind === "strings" && !(Array.isArray(value) && value.every((v) => typeof v === "string"))) throw new CliError("usage", `${key} takes a JSON list of strings: ${SETTINGS_SET}`);
297
+ if (kind === "ice" && !(Array.isArray(value) && value.every((v) => v && typeof v === "object"))) throw new CliError("usage", `${key} takes a JSON list of ICE servers: ${SETTINGS_SET}`);
298
+ }
265
299
  /** Words as a sentence lists them: "a", "a or b", "a, b or c". */
266
300
  var listed$1 = (words) => words.length > 1 ? `${words.slice(0, -1).join(", ")} or ${words.at(-1)}` : words[0];
267
301
  /** The global option a word names (`--profile`, `--profile=bot`, `-p`), else undefined. */
@@ -305,8 +339,7 @@ function liftGlobals(argv) {
305
339
  ...rest.slice(dash)
306
340
  ];
307
341
  }
308
- //#endregion
309
- //#region src/commands/shared.ts
342
+ // src/commands/shared.ts
310
343
  var wait = {
311
344
  wait: {
312
345
  type: "string",
@@ -364,6 +397,28 @@ function here(path) {
364
397
  if (path === "") throw new CliError("usage", "A path given as \"\" names no file");
365
398
  return typeof path === "string" ? userPath(path) : void 0;
366
399
  }
400
+ /**
401
+ * A path on this machine a command reads (`file send`, a picture, `profile backup --out`'s folder), looked at before the
402
+ * profile opens: one not there is not_found (`missing`, or "No such file or folder"), one not allowed refused. Before, a
403
+ * one-shot opened the profile and went online first (~1 s on a big profile) to say so. The API keeps its check for
404
+ * socket callers; through a daemon it reads the same path.
405
+ */
406
+ function localStat(path, missing) {
407
+ try {
408
+ return statSync(path);
409
+ } catch (error) {
410
+ const known = localFileError(error, path);
411
+ throw known?.code === "not_found" && missing ? new CliError("not_found", missing) : known ?? error;
412
+ }
413
+ }
414
+ /**
415
+ * A picture's file (`profile picture`, `group picture`), in the API's words (groupAdmin.ts) when it is not there or a
416
+ * folder. Only a folder is refused here: a pipe (`<(…)`) is read as a file.
417
+ */
418
+ function picture(path) {
419
+ if (path !== void 0 && localStat(path).isDirectory()) throw new CliError("bad_request", `${path} is a folder: name a file`);
420
+ return path;
421
+ }
367
422
  var STDIN_TOO_BIG = "More than 16 MiB came on stdin, more than any command takes (a long text goes as a file: ghostly file send <chat|group> <path>)";
368
423
  /**
369
424
  * A file's text, or stdin's (`0`), up to `INPUT_BYTES`: more is refused as it comes. `app send … -`, a card's `--json`
@@ -413,7 +468,7 @@ function pairs(values) {
413
468
  const out = {};
414
469
  for (const item of values) {
415
470
  const eq = item.indexOf("=");
416
- if (eq < 1) throw new CliError("usage", `--value takes name=value, not ${JSON.stringify(item)}`);
471
+ if (eq < 1) throw new CliError("usage", "--value takes name=value, and one has no name or no =");
417
472
  out[item.slice(0, eq)] = item.slice(eq + 1);
418
473
  }
419
474
  return out;
@@ -485,6 +540,18 @@ function typingFor(options) {
485
540
  return seconds;
486
541
  }
487
542
  /**
543
+ * The `<emoji>` of `react` and `group react`: one emoji (core's `reactionEmoji`), or none with `--remove`. Anything else
544
+ * is a usage error (exit 2) before the profile opens, as `status set --emoji` is. Before, a one-shot opened the profile
545
+ * and went online first, then the engine answered "A reaction is one emoji" (`bad_request`, exit 1), and a missing one
546
+ * "Give one emoji" (exit 2) only from there. The API keeps its checks for socket callers.
547
+ */
548
+ function reaction(options, emoji) {
549
+ if (options.remove === true) return emoji;
550
+ if (!emoji) throw new CliError("usage", "Give one emoji, or --remove to take yours back");
551
+ if (!reactionEmoji(emoji)) throw new CliError("usage", `<emoji> takes one emoji, not ${JSON.stringify(emoji)}`);
552
+ return emoji;
553
+ }
554
+ /**
488
555
  * The ranges the API takes (api.ts, files.ts): the most minutes of a `--hold` (a week, HOLD_MAX_MINUTES), seconds;
489
556
  * `chat connect`'s, the chat link's own wait for a contact (CONNECT_MAX_SECONDS).
490
557
  */
@@ -643,6 +710,13 @@ function cardBytes(fields, flags) {
643
710
  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}`);
644
711
  return fields;
645
712
  }
713
+ /**
714
+ * A card's `--id` given as "" (an unset variable in a script: `--id "$ID"`) is a usage error. Taken as not given, a new
715
+ * id was made, and a script meant to update its card posted a second one.
716
+ */
717
+ function cardId(options) {
718
+ if (options.id === "") throw new CliError("usage", "--id needs a card id");
719
+ }
646
720
  /** `--progress`, `--left`: a percent, or a usage error that names the flag. */
647
721
  function percent(options, flag) {
648
722
  const value = options[flag];
@@ -682,6 +756,7 @@ function taskFields(options) {
682
756
  ["pr-state", PR_STATES],
683
757
  ["pr-checks", PR_CHECKS]
684
758
  ]) oneWord(options, flag, words);
759
+ cardId(options);
685
760
  set("id", options.id);
686
761
  set("title", options.title);
687
762
  set("status", options.status);
@@ -860,6 +935,7 @@ function routineFields(options) {
860
935
  throw new CliError("usage", length > STATUS_CARD_LIMITS.cron ? `--cron takes at most ${STATUS_CARD_LIMITS.cron} characters, not ${length}` : `--cron takes a cron line of 0-9 A-Z a-z * , / ? # - and spaces, not ${JSON.stringify(options.cron)}`);
861
936
  }
862
937
  oneWord(options, "state", ROUTINE_STATES);
938
+ cardId(options);
863
939
  for (const key of [
864
940
  "id",
865
941
  "name",
@@ -998,6 +1074,7 @@ function usageFields(options) {
998
1074
  ["window", STATUS_CARD_LIMITS.usageWindow]
999
1075
  ]) cardText(`--${flag}`, options[flag], max);
1000
1076
  given("also", options.also, STATUS_CARD_LIMITS.usageWindows);
1077
+ cardId(options);
1001
1078
  for (const key of [
1002
1079
  "id",
1003
1080
  "left",
@@ -1058,13 +1135,20 @@ var usageOptions = {
1058
1135
  text: cardOptions.text,
1059
1136
  force: cardOptions.force
1060
1137
  };
1061
- //#endregion
1062
- //#region src/commands/apps.ts
1138
+ // src/commands/apps.ts
1063
1139
  /** The key file a command signs with: always named, never a default, never on the command line itself. */
1064
1140
  function keyFile(value, usage) {
1065
1141
  if (typeof value !== "string" || !value) throw new CliError("usage", `--key <file> is needed: ghostly ${usage}`);
1066
1142
  return value;
1067
1143
  }
1144
+ /**
1145
+ * `app serve`'s bundle file, in the API's words (apps.ts) when it is not there or a folder: said before the profile
1146
+ * opens. Before, a one-shot went online first (about 12 s with no daemon) to say the file was not there.
1147
+ */
1148
+ function bundleFile(path) {
1149
+ if (localStat(path).isDirectory()) throw new CliError("bad_request", `${path} is a folder: name a .ghostlyapp file`);
1150
+ return path;
1151
+ }
1068
1152
  /** `app send`'s message: JSON on the command line, or `-` for stdin. */
1069
1153
  function appData(value) {
1070
1154
  if (value === void 0) throw new CliError("usage", "The message is needed, as JSON or - for stdin: ghostly app send <chat> <ref|name> <json|->");
@@ -1114,7 +1198,7 @@ var commands$8 = {
1114
1198
  description: "Replace the three files when they are there"
1115
1199
  }
1116
1200
  },
1117
- run: async ({ options }, a) => (await import("./apps-rzxsjfBV.js")).initApp(a.dir, {
1201
+ run: async ({ options }, a) => (await import("./apps-BPFW19Wc.js")).initApp(a.dir, {
1118
1202
  name: options.name,
1119
1203
  title: options.title,
1120
1204
  force: options.force === true
@@ -1154,7 +1238,7 @@ var commands$8 = {
1154
1238
  description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
1155
1239
  }
1156
1240
  },
1157
- run: async ({ options }, a) => (await import("./apps-rzxsjfBV.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1241
+ run: async ({ options }, a) => (await import("./apps-BPFW19Wc.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1158
1242
  },
1159
1243
  "app revoke": {
1160
1244
  method: "app.revoke",
@@ -1187,7 +1271,7 @@ var commands$8 = {
1187
1271
  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"
1188
1272
  }
1189
1273
  },
1190
- run: async ({ options }, a) => (await import("./apps-rzxsjfBV.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
1274
+ run: async ({ options }, a) => (await import("./apps-BPFW19Wc.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
1191
1275
  digests: options.digest,
1192
1276
  upTo: options["up-to"],
1193
1277
  reason: options.reason,
@@ -1222,11 +1306,11 @@ var commands$8 = {
1222
1306
  },
1223
1307
  url: {
1224
1308
  type: "string",
1225
- description: "Where a contact's app reads the bundle, for the card (default: the URL it was served from, else the manifest's first source)"
1309
+ description: "Where a contact's app reads the bundle, for the card (raw.githubusercontent.com, or cdn.jsdelivr.net at a commit; default: the first of those it was served from or its manifest names)"
1226
1310
  }
1227
1311
  },
1228
1312
  params: ({ options }, a) => ({
1229
- bundle: /^[a-z][a-z0-9+.-]*:\/\//i.test(a.bundle ?? "") ? a.bundle : here(a.bundle),
1313
+ bundle: /^[a-z][a-z0-9+.-]*:\/\//i.test(a.bundle ?? "") ? a.bundle : bundleFile(here(a.bundle)),
1230
1314
  grant: options.grant,
1231
1315
  url: options.url
1232
1316
  })
@@ -1248,7 +1332,7 @@ var commands$8 = {
1248
1332
  usage: "app verify <bundle|url>",
1249
1333
  summary: "Check a .ghostlyapp as a client would, from a file or an https URL: its manifest and digest, or refused (exit 1) with the reason, revoked when the ghostly-revoke.json beside it (for a URL, or beside one of its sources) revokes this version",
1250
1334
  args: ["bundle"],
1251
- run: async (_, a) => (await import("./apps-rzxsjfBV.js")).verifyApp(a.bundle)
1335
+ run: async (_, a) => (await import("./apps-BPFW19Wc.js")).verifyApp(a.bundle)
1252
1336
  },
1253
1337
  "store sign": {
1254
1338
  method: "store.sign",
@@ -1265,11 +1349,10 @@ var commands$8 = {
1265
1349
  description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
1266
1350
  }
1267
1351
  },
1268
- run: async ({ options }, a) => (await import("./apps-rzxsjfBV.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1352
+ run: async ({ options }, a) => (await import("./apps-BPFW19Wc.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1269
1353
  }
1270
1354
  };
1271
- //#endregion
1272
- //#region src/commands/calls.ts
1355
+ // src/commands/calls.ts
1273
1356
  /**
1274
1357
  * `--rate`: one of the rates a call takes, or a usage error (exit 2) that names the flag before the profile opens.
1275
1358
  * Before, the API's own check answered it ("rate must be …", exit 1), and `call answer` only once a call rang.
@@ -1347,8 +1430,7 @@ var commands$7 = {
1347
1430
  })
1348
1431
  }
1349
1432
  };
1350
- //#endregion
1351
- //#region src/commands/chats.ts
1433
+ // src/commands/chats.ts
1352
1434
  /** `react` and `pin` in a 1:1 chat: until the contact confirmed it, by default without a daemon (the process leaves). */
1353
1435
  var confirmWait = {
1354
1436
  wait: {
@@ -1455,6 +1537,7 @@ var commands$6 = {
1455
1537
  timeout: groupWait.timeout
1456
1538
  },
1457
1539
  params: ({ options }, a) => {
1540
+ if (options.chosen === "") throw new CliError("usage", "--chosen needs a button id");
1458
1541
  if (!options.chosen && options.close !== true && !options.text) throw new CliError("usage", `Give --chosen, --close or --text: ghostly ${BUTTON_UPDATE}`);
1459
1542
  return {
1460
1543
  chat: a.chat,
@@ -1553,7 +1636,7 @@ var commands$6 = {
1553
1636
  },
1554
1637
  "chat rename": {
1555
1638
  method: "chat.rename",
1556
- usage: "chat rename <chat> <name...>",
1639
+ usage: "chat rename <chat> [name...]",
1557
1640
  summary: "Name a chat on this side (empty: the contact's name)",
1558
1641
  args: ["chat", "name...?"],
1559
1642
  params: (_, { chat, name }) => ({
@@ -1686,7 +1769,7 @@ var commands$6 = {
1686
1769
  },
1687
1770
  "message delete": {
1688
1771
  method: "chat.delete",
1689
- usage: "message delete <chat|group> <message> [--everyone [--wait none|confirmed|sent] [--timeout s]]",
1772
+ usage: "message delete <chat|group> <message> [--everyone [--wait none|confirmed|sent] [--timeout s]] [--purge]",
1690
1773
  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",
1691
1774
  args: ["chat", "message"],
1692
1775
  options: {
@@ -1703,7 +1786,11 @@ var commands$6 = {
1703
1786
  ],
1704
1787
  description: "With --everyone: in a chat none or confirmed, until the contact has it; in a group none or sent, until a member's edge took it (default: none with a daemon, confirmed or sent without)"
1705
1788
  },
1706
- timeout: wait.timeout
1789
+ timeout: wait.timeout,
1790
+ purge: {
1791
+ type: "boolean",
1792
+ description: "Take what it said out of the profile's folder now (the store folds at once), not within the hour: for a secret pasted into a chat"
1793
+ }
1707
1794
  },
1708
1795
  params: ({ options }, a) => {
1709
1796
  for (const flag of ["wait", "timeout"]) if (options[flag] !== void 0 && options.everyone !== true) throw new CliError("usage", `--${flag} goes with --everyone`);
@@ -1712,7 +1799,8 @@ var commands$6 = {
1712
1799
  message: a.message,
1713
1800
  everyone: options.everyone === true,
1714
1801
  wait: options.wait,
1715
- timeout: timeout(options)
1802
+ timeout: timeout(options),
1803
+ ...options.purge === true && { purge: true }
1716
1804
  };
1717
1805
  }
1718
1806
  },
@@ -1758,7 +1846,7 @@ var commands$6 = {
1758
1846
  timeout: groupWait.timeout
1759
1847
  },
1760
1848
  params: ({ options }, a) => {
1761
- if (a.message === void 0 && options.remove !== true) throw new CliError("usage", "Missing <message>: ghostly pin <chat|group> <message> | --remove");
1849
+ if (!a.message && options.remove !== true) throw new CliError("usage", "Missing <message>: ghostly pin <chat|group> <message> | --remove");
1762
1850
  if (a.message?.includes(" ")) throw new CliError("usage", "Too many arguments: ghostly pin <chat|group> <message> | --remove");
1763
1851
  return {
1764
1852
  chat: a.chat,
@@ -1788,7 +1876,7 @@ var commands$6 = {
1788
1876
  params: ({ options }, a) => ({
1789
1877
  chat: a.chat,
1790
1878
  message: a.message,
1791
- emoji: a.emoji,
1879
+ emoji: reaction(options, a.emoji),
1792
1880
  remove: options.remove === true,
1793
1881
  wait: options.wait,
1794
1882
  timeout: timeout(options)
@@ -1955,8 +2043,7 @@ var commands$6 = {
1955
2043
  }
1956
2044
  }
1957
2045
  };
1958
- //#endregion
1959
- //#region src/commands/files.ts
2046
+ // src/commands/files.ts
1960
2047
  /**
1961
2048
  * `--voice [ms]` and `--peaks`: a length and a waveform a voice note takes, or a usage error (exit 2) that names the flag
1962
2049
  * before the profile opens. Before, the API answered them once it had opened ("voice must be a number from 1 to
@@ -1977,6 +2064,11 @@ function voiceOf(options) {
1977
2064
  peaks: bars
1978
2065
  };
1979
2066
  }
2067
+ /** The file `file send` sends, in the API's words (files.ts) when it is not there or not a file. */
2068
+ function sendable(path) {
2069
+ if (!localStat(path, `No file ${path}`).isFile()) throw new CliError("bad_request", `${path} is not a file`);
2070
+ return path;
2071
+ }
1980
2072
  /** Files: one entry per command, in alphabetical order (test/commands.test.ts checks). */
1981
2073
  var commands$5 = {
1982
2074
  "file accept": {
@@ -2124,6 +2216,7 @@ var commands$5 = {
2124
2216
  voice: {
2125
2217
  type: "number",
2126
2218
  optionalValue: true,
2219
+ takes: "a length in milliseconds",
2127
2220
  description: "A voice note; its length in milliseconds (default: measured from the sound)"
2128
2221
  },
2129
2222
  peaks: {
@@ -2145,22 +2238,26 @@ var commands$5 = {
2145
2238
  description: "Send even if --name looks like a seed, a key or ecash"
2146
2239
  }
2147
2240
  },
2148
- params: ({ options }, a) => ({
2149
- chat: a.chat,
2150
- path: here(a.path),
2151
- name: options.name,
2152
- mime: options.mime,
2153
- ...voiceOf(options),
2154
- reply: options.reply,
2155
- force: options.force === true,
2156
- wait: options.wait,
2157
- timeout: timeout(options, LONG_WAIT_SECONDS)
2158
- })
2241
+ params: ({ options }, a) => {
2242
+ if (options.reply === "") throw new CliError("usage", "--reply needs a message id");
2243
+ const voice = voiceOf(options), seconds = timeout(options, LONG_WAIT_SECONDS);
2244
+ return {
2245
+ chat: a.chat,
2246
+ path: sendable(here(a.path)),
2247
+ name: options.name,
2248
+ mime: options.mime,
2249
+ ...voice,
2250
+ reply: options.reply,
2251
+ force: options.force === true,
2252
+ wait: options.wait,
2253
+ timeout: seconds
2254
+ };
2255
+ }
2159
2256
  },
2160
2257
  "file wait": {
2161
2258
  method: "file.wait",
2162
2259
  usage: "file wait [<chat>] <file> [--timeout s]",
2163
- summary: "Wait until a transfer is done (exit 0) or failed (exit 1, with its error)",
2260
+ summary: "Wait until a transfer is done (exit 0) or failed (exit 1, with its error); exit 4 on timeout, 5 at once when a received file waits for file accept",
2164
2261
  args: ["chat?", "file"],
2165
2262
  options: { timeout: {
2166
2263
  type: "number",
@@ -2173,8 +2270,7 @@ var commands$5 = {
2173
2270
  })
2174
2271
  }
2175
2272
  };
2176
- //#endregion
2177
- //#region src/commands/general.ts
2273
+ // src/commands/general.ts
2178
2274
  /** `--until 30m`, `2h`, `1d`: that long from now. */
2179
2275
  var DURATION = /^(\d+)(m|h|d)$/;
2180
2276
  var UNIT_MS = {
@@ -2223,7 +2319,7 @@ var commands$4 = {
2223
2319
  if (!a.path && options.clear !== true) throw new CliError("usage", "Missing <jpeg>: ghostly profile picture <jpeg> | --clear");
2224
2320
  if (a.path && options.clear === true) throw new CliError("usage", "--clear removes the picture: not with a <jpeg>");
2225
2321
  return {
2226
- path: here(a.path || void 0),
2322
+ path: picture(here(a.path || void 0)),
2227
2323
  clear: options.clear === true
2228
2324
  };
2229
2325
  }
@@ -2281,8 +2377,7 @@ var commands$4 = {
2281
2377
  summary: "This profile's status (status set), or null when it has none"
2282
2378
  }
2283
2379
  };
2284
- //#endregion
2285
- //#region src/commands/groups.ts
2380
+ // src/commands/groups.ts
2286
2381
  var nameForce = {
2287
2382
  type: "boolean",
2288
2383
  description: "Use the name even if it looks like a seed, a key or ecash"
@@ -2330,6 +2425,39 @@ var commands$3 = {
2330
2425
  } : { on: false };
2331
2426
  }
2332
2427
  },
2428
+ "group call": {
2429
+ method: "group.call",
2430
+ usage: "group call <group> --sfu <https origin> [--e2ee | --no-e2ee] | --e2ee | --no-e2ee | --clear [--show-secret]",
2431
+ summary: "Name the node a community group's calls go through, turn sealed call media on or off, or --clear (admin)",
2432
+ args: ["group"],
2433
+ options: {
2434
+ ...showSecret,
2435
+ sfu: {
2436
+ type: "string",
2437
+ description: "The node's https origin, e.g. https://call.example.com"
2438
+ },
2439
+ e2ee: {
2440
+ type: "boolean",
2441
+ eitherWay: true,
2442
+ description: "Seal the call media end to end (--no-e2ee: off); left out, the group keeps what it had"
2443
+ },
2444
+ clear: {
2445
+ type: "boolean",
2446
+ description: "The group has no calls"
2447
+ }
2448
+ },
2449
+ params: ({ options }, a) => {
2450
+ if (options.sfu === void 0 && options.clear !== true && options.e2ee === void 0) throw new CliError("usage", "Missing --sfu: ghostly group call <group> --sfu <https origin> | --clear");
2451
+ if (options.sfu !== void 0 && options.clear === true) throw new CliError("usage", "--clear removes the call node: not with --sfu");
2452
+ if (options.e2ee !== void 0 && options.clear === true) throw new CliError("usage", "--clear removes the call node: not with --e2ee or --no-e2ee");
2453
+ return {
2454
+ group: a.group,
2455
+ ...options.clear === true ? { clear: true } : options.sfu !== void 0 ? { sfu: options.sfu } : {},
2456
+ ...options.e2ee !== void 0 && { e2ee: options.e2ee === true },
2457
+ ...secret(options)
2458
+ };
2459
+ }
2460
+ },
2333
2461
  "group create": {
2334
2462
  method: "group.create",
2335
2463
  usage: "group create <name...> [--mesh] [--force]",
@@ -2508,7 +2636,7 @@ var commands$3 = {
2508
2636
  if (a.path && options.clear === true) throw new CliError("usage", "--clear removes the picture: not with a <jpeg>");
2509
2637
  return {
2510
2638
  group: a.group,
2511
- path: here(a.path || void 0),
2639
+ path: picture(here(a.path || void 0)),
2512
2640
  clear: options.clear === true
2513
2641
  };
2514
2642
  }
@@ -2536,7 +2664,7 @@ var commands$3 = {
2536
2664
  params: ({ options }, a) => ({
2537
2665
  group: a.group,
2538
2666
  message: a.message,
2539
- emoji: a.emoji,
2667
+ emoji: reaction(options, a.emoji),
2540
2668
  remove: options.remove === true,
2541
2669
  wait: options.wait,
2542
2670
  timeout: timeout(options)
@@ -2621,8 +2749,7 @@ var commands$3 = {
2621
2749
  })
2622
2750
  }
2623
2751
  };
2624
- //#endregion
2625
- //#region src/commands/identities.ts
2752
+ // src/commands/identities.ts
2626
2753
  /** Identity proofs and x401 credentials: one entry per command, in alphabetical order (test/commands.test.ts checks). */
2627
2754
  var commands$2 = {
2628
2755
  "identity cancel": {
@@ -2640,7 +2767,7 @@ var commands$2 = {
2640
2767
  options: {
2641
2768
  "evidence-file": {
2642
2769
  type: "string",
2643
- description: "The tool's output, from this file"
2770
+ description: "The tool's output, from this file (- for stdin)"
2644
2771
  },
2645
2772
  stdin: {
2646
2773
  type: "boolean",
@@ -2649,10 +2776,11 @@ var commands$2 = {
2649
2776
  },
2650
2777
  params: ({ options }, a) => {
2651
2778
  if (options["evidence-file"] !== void 0 && options.stdin === true) throw new CliError("usage", "--evidence-file or --stdin, not both");
2779
+ const piped = options["evidence-file"] === "-";
2652
2780
  return {
2653
2781
  draft: a.draft,
2654
- evidenceFile: here(options["evidence-file"]),
2655
- stdin: options.stdin === true
2782
+ evidenceFile: piped ? void 0 : here(options["evidence-file"]),
2783
+ stdin: piped || options.stdin === true
2656
2784
  };
2657
2785
  }
2658
2786
  },
@@ -2747,8 +2875,7 @@ var commands$2 = {
2747
2875
  summary: "A fresh P-256 holder key: its public JWK goes to the issuer (the 8 newest wait for a credential; past them, the oldest is dropped)"
2748
2876
  }
2749
2877
  };
2750
- //#endregion
2751
- //#region src/commands/payments.ts
2878
+ // src/commands/payments.ts
2752
2879
  /**
2753
2880
  * `chat accept`'s --networks: mainnet and/or testnet, comma-separated; any other word, or none (an unset variable), is a
2754
2881
  * usage error before the profile opens, as a word --network does not take is. Before, the API refused it after a
@@ -2760,6 +2887,15 @@ function networkList(value) {
2760
2887
  if (!networks.every((n) => n === "mainnet" || n === "testnet")) throw new CliError("usage", `--networks takes mainnet, testnet or mainnet,testnet, not ${JSON.stringify(value)}`);
2761
2888
  return networks;
2762
2889
  }
2890
+ /**
2891
+ * `chat request`'s amount: whole sats, or with --method usdt USDT as the app's composer reads it (5 is 5 USDT, 0.25 a
2892
+ * quarter), passed on as its text for the API to turn into base units with the wallet's decimals.
2893
+ */
2894
+ function requestAmount(value, method) {
2895
+ if (method !== "usdt") return sats(value);
2896
+ if (!/^\d+(\.\d+)?$/.test(value ?? "") || !/[1-9]/.test(value)) throw new CliError("usage", `<amount> with --method usdt takes USDT above 0 (5 or 0.25), not ${JSON.stringify(value)}`);
2897
+ return value;
2898
+ }
2763
2899
  /** Wallets and payments: one entry per command, in alphabetical order (test/commands.test.ts checks). */
2764
2900
  var commands$1 = {
2765
2901
  "chat accept": {
@@ -2839,14 +2975,14 @@ var commands$1 = {
2839
2975
  "chat request": {
2840
2976
  method: "chat.request",
2841
2977
  usage: "chat request <chat> <sats> [--memo t] [--method m] [--rail cashu|lightning] [--network testnet] [--card <id>] [--force]",
2842
- summary: "Ask a contact to pay",
2978
+ summary: "Ask a contact to pay (with --method usdt the amount is in USDT: 5 is 5 USDT)",
2843
2979
  args: ["chat", "amount"],
2844
2980
  options: {
2845
2981
  memo,
2846
2982
  method: {
2847
2983
  type: "string",
2848
2984
  choices: PAY_METHODS,
2849
- description: "cashu, arkade, usdt, bitcoin, spark, …"
2985
+ description: "cashu, arkade, usdt (amount in USDT), bitcoin, spark, …"
2850
2986
  },
2851
2987
  rail: {
2852
2988
  type: "string",
@@ -2859,7 +2995,7 @@ var commands$1 = {
2859
2995
  },
2860
2996
  params: ({ options }, a) => ({
2861
2997
  chat: a.chat,
2862
- amount: sats(a.amount),
2998
+ amount: requestAmount(a.amount, options.method),
2863
2999
  memo: options.memo,
2864
3000
  method: options.method,
2865
3001
  rail: options.rail,
@@ -2948,7 +3084,10 @@ var commands$1 = {
2948
3084
  type: "string",
2949
3085
  description: "Only this chat's"
2950
3086
  } },
2951
- params: ({ options }) => ({ chat: options.chat })
3087
+ params: ({ options }) => {
3088
+ if (options.chat === "") throw new CliError("usage", "--chat needs a chat");
3089
+ return { chat: options.chat };
3090
+ }
2952
3091
  },
2953
3092
  "payment reclaim": {
2954
3093
  method: "payment.reclaim",
@@ -3102,8 +3241,7 @@ var commands$1 = {
3102
3241
  })
3103
3242
  }
3104
3243
  };
3105
- //#endregion
3106
- //#region src/commands/services.ts
3244
+ // src/commands/services.ts
3107
3245
  /** Shared local services: one entry per command, in alphabetical order (test/commands.test.ts checks). */
3108
3246
  var commands = {
3109
3247
  "service add": {
@@ -3190,8 +3328,7 @@ var commands = {
3190
3328
  })
3191
3329
  }
3192
3330
  };
3193
- //#endregion
3194
- //#region src/commands/index.ts
3331
+ // src/commands/index.ts
3195
3332
  /**
3196
3333
  * The commands that are one API method each, one file per area of the app, each in alphabetical order. A new
3197
3334
  * command goes in its area's file at its place; a new area is a new file and its two lines here. The order here
@@ -3410,12 +3547,14 @@ function positionals(command, values) {
3410
3547
  noMoreThan(names.length, values, command.usage);
3411
3548
  return out;
3412
3549
  }
3413
- /** Words past a usage's arguments are refused, never dropped: `profile use my bot` would select `my`. */
3550
+ /**
3551
+ * Words past a usage's arguments are refused, never dropped: `profile use my bot` would select `my`. One of them right
3552
+ * after an option that stood alone (`file send bob v.wav --voice 2s`) is refused as that option's value.
3553
+ */
3414
3554
  function noMoreThan(count, values, usage) {
3415
- if (values.length > count) throw new CliError("usage", `Too many arguments: ghostly ${usage}`);
3555
+ if (values.length > count) throw strayValue(values) ?? new CliError("usage", `Too many arguments: ghostly ${usage}`);
3416
3556
  }
3417
- //#endregion
3418
- //#region src/listen.ts
3557
+ // src/listen.ts
3419
3558
  /** The cursor's own write failed, not the event's handling. */
3420
3559
  var CursorError = class extends Error {
3421
3560
  error;
@@ -3445,11 +3584,14 @@ var Allowlist = class {
3445
3584
  }
3446
3585
  async allows(event) {
3447
3586
  if ("group" in event) return typeof event.group === "string" && this.groups.has(event.group);
3587
+ const group = event.payment?.group;
3588
+ if (group !== void 0) return typeof group === "string" && this.groups.has(group);
3448
3589
  if (!("chat" in event)) return true;
3449
3590
  const chat = event.chat;
3450
3591
  if (typeof chat !== "string") return false;
3451
3592
  if (this.chats.has(chat)) return true;
3452
3593
  if (!this.keys.size) return false;
3594
+ if (event.type === "chat.removed" && typeof event.peer === "string") return this.keys.has(event.peer);
3453
3595
  let key = this.peers.get(chat);
3454
3596
  if (!key) {
3455
3597
  key = await this.peerOf(chat).catch(() => null) || void 0;
@@ -3485,7 +3627,8 @@ async function allowlist(from, groups, call, peerOf) {
3485
3627
  }
3486
3628
  /**
3487
3629
  * A `--from` that names a group, or a `--group` a chat: said with the flag that takes it. The lookup's own hint named
3488
- * `ghostly group show` (or `chat show`), which lists nothing.
3630
+ * `ghostly group show` (or `chat show`), which lists nothing. A chat is named by its id: `--from` refuses a prefix of it
3631
+ * or the name its contact chose, which `--group`'s lookup took.
3489
3632
  */
3490
3633
  async function otherFlag(lookup, ref, flag) {
3491
3634
  try {
@@ -3493,7 +3636,8 @@ async function otherFlag(lookup, ref, flag) {
3493
3636
  } catch (error) {
3494
3637
  const other = flag === "--from" ? "group" : "chat";
3495
3638
  if (!(error instanceof CliError) || error.code !== "not_found" || typeof error.details?.[other] !== "string") throw error;
3496
- const shown = /^[\w.:-]+$/.test(ref) ? ref : JSON.stringify(ref);
3639
+ const named = other === "chat" ? error.details.chat : ref;
3640
+ const shown = shellWord(named, error.details[other]);
3497
3641
  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);
3498
3642
  }
3499
3643
  }
@@ -3603,6 +3747,29 @@ function readCursor(path) {
3603
3747
  throw new CliError("bad_request", `${path} holds no event number (${shown}): fix or remove it, or give --since`);
3604
3748
  }
3605
3749
  /**
3750
+ * Where listen starts: after the event number the cursor file holds, else after `since` (--since: the first start's
3751
+ * place). Before, --since won without a word, and a unit with `--since 0 --cursor f` ran every handled event's hook
3752
+ * again at each restart. A cursor file that holds no number is refused unless --since is given, which starts it.
3753
+ * `known`, once the journal's last event is: says on stderr where it starts. A cursor past it (a profile restored from a
3754
+ * backup, a journal reset, a cursor copied from another profile) starts with new events; before, stderr said "starting
3755
+ * after it" (or nothing, without --since) and the next event wrote a lower number over the file.
3756
+ */
3757
+ function startAt(since, cursor, say) {
3758
+ let kept;
3759
+ if (since === void 0) kept = readCursor(cursor);
3760
+ else try {
3761
+ kept = readCursor(cursor);
3762
+ } catch {}
3763
+ return {
3764
+ from: kept ?? since,
3765
+ known: (lastSeq) => {
3766
+ if (kept === void 0) return;
3767
+ if (kept > lastSeq) say(`ghostly: ${cursor} holds event ${kept}, past this profile's last event (${lastSeq}): starting with new events`);
3768
+ else if (since !== void 0 && kept !== since) say(`ghostly: ${cursor} holds event ${kept}: starting after it, not after --since ${since}`);
3769
+ }
3770
+ };
3771
+ }
3772
+ /**
3606
3773
  * Whether a cursor can be kept at `path`, asked before anything starts: its folder is there and takes a file. Before, a
3607
3774
  * folder that was not there was found at the first event: the listener ran, said "event N failed: ENOENT" for each one
3608
3775
  * and never wrote the cursor, so the next start began at the journal's end and skipped what came while it was down.
@@ -3734,7 +3901,7 @@ var HOOK_OUTPUT_GRACE_MS = 1e3;
3734
3901
  * `toStderr` (with `--print`, whose stdout is the JSON stream): the hook's stdout is streamed to listen's stderr, so a
3735
3902
  * hook that echoes never puts a line that is not an event into the stream. Piped as it comes, never held in memory.
3736
3903
  */
3737
- function runExec(command, event, toStderr) {
3904
+ function runExec(command, event, toStderr, profile) {
3738
3905
  const group = process.platform !== "win32";
3739
3906
  const child = spawn(command, {
3740
3907
  shell: true,
@@ -3746,6 +3913,10 @@ function runExec(command, event, toStderr) {
3746
3913
  ],
3747
3914
  env: {
3748
3915
  ...hookEnv(process.env),
3916
+ ...profile ? {
3917
+ GHOSTLY_HOME: profile.home,
3918
+ GHOSTLY_PROFILE: profile.name
3919
+ } : {},
3749
3920
  GHOSTLY_EVENT_TYPE: event.type,
3750
3921
  GHOSTLY_EVENT_ID: event.id,
3751
3922
  GHOSTLY_EVENT_SEQ: String(event.seq)
@@ -3797,7 +3968,8 @@ function runExec(command, event, toStderr) {
3797
3968
  /** The longest wait between two tries of a webhook that is not answering. */
3798
3969
  var RETRY_MAX_MS = 6e4;
3799
3970
  /**
3800
- * Posts one event; resolves true once the bridge took it, or the status it refused it with (a 4xx or a redirect, three times).
3971
+ * Posts one event; resolves true once the bridge took it, or the status it refused it with (a 4xx or a redirect, posted
3972
+ * once: before, three times with backoff, three refusals in the bridge's log for an event stderr said was not tried again).
3801
3973
  * A bridge that is not there (refused connection, timeout, 5xx, 408, 429) has not handled the event: it is tried again,
3802
3974
  * waiting up to a minute between tries, for as long as it takes, so the cursor never moves past it. Before, three tries
3803
3975
  * in 3.5 s and the cursor moved on: a bridge restarting for longer lost every event of the time it was down, for good.
@@ -3826,7 +3998,7 @@ async function post(url, event, retryMs) {
3826
3998
  status = response.status;
3827
3999
  down = status >= 500 || status === 408 || status === 429;
3828
4000
  } catch {}
3829
- if (!down && attempt >= 2) return status;
4001
+ if (!down) return status;
3830
4002
  if (down && attempt >= 2 && !holding) {
3831
4003
  holding = true;
3832
4004
  process.stderr.write(`ghostly: the webhook at ${url.origin} is not answering: holding event ${event.seq} (${event.type}) until it does\n`);
@@ -3888,7 +4060,7 @@ function eventHandler(options) {
3888
4060
  if (options.turns && !gap) event = toTurn(event);
3889
4061
  const full = options.print && options.write(jsonOut(event)) === false;
3890
4062
  if (options.exec) {
3891
- const hook = running = runExec(options.exec, event, options.print);
4063
+ const hook = running = runExec(options.exec, event, options.print, options.profile);
3892
4064
  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);
3893
4065
  const { code, signal } = await hook.ended.finally(() => {
3894
4066
  clearTimeout(slow);
@@ -4034,14 +4206,17 @@ function followDaemon(address, client, handle, since, holdMs = PAUSE_HOLD_MS, pr
4034
4206
  if (current) current.resume();
4035
4207
  else reconnect(0);
4036
4208
  });
4037
- const follow = (c) => c.subscribe(feed.since, feed.take, () => {
4038
- if (current !== c) return;
4039
- current = null;
4040
- reconnect(1e3);
4041
- }).then((answer) => {
4042
- if (feed.since === void 0 && typeof answer?.lastSeq === "number") feed.since = answer.lastSeq;
4043
- return answer;
4044
- });
4209
+ const follow = (c) => {
4210
+ const asked = feed.since;
4211
+ return c.subscribe(asked, feed.take, () => {
4212
+ if (current !== c) return;
4213
+ current = null;
4214
+ reconnect(1e3);
4215
+ }).then((answer) => {
4216
+ if (typeof answer?.lastSeq === "number" && feed.since === asked && (asked === void 0 || asked > answer.lastSeq)) feed.since = answer.lastSeq;
4217
+ return answer;
4218
+ });
4219
+ };
4045
4220
  return {
4046
4221
  subscribed: follow(client),
4047
4222
  close: () => {
@@ -4050,8 +4225,7 @@ function followDaemon(address, client, handle, since, holdMs = PAUSE_HOLD_MS, pr
4050
4225
  }
4051
4226
  };
4052
4227
  }
4053
- //#endregion
4054
- //#region src/secretInput.ts
4228
+ // src/secretInput.ts
4055
4229
  /**
4056
4230
  * Secrets a command takes (a Cashu token, an API key, a card's form) come on stdin: on the command line they show in
4057
4231
  * `ps` to every user of the machine while the command runs, and stay in the shell's history. Still taken there, with
@@ -4113,6 +4287,7 @@ async function secretsFromStdin(method, params, read, tty = false, note = () =>
4113
4287
  if (method === "wallet.create") {
4114
4288
  const onLine = params.apiKey !== void 0;
4115
4289
  if (params.stdin === true) {
4290
+ if (tty) throw new CliError("usage", "--stdin takes the values as name=value lines piped to it (… | ghostly wallet create <type> --stdin), not a terminal");
4116
4291
  const values = { ...params.values };
4117
4292
  for (const line of (await read()).split(/\r?\n/)) {
4118
4293
  if (!line.trim()) continue;
@@ -4129,6 +4304,17 @@ async function secretsFromStdin(method, params, read, tty = false, note = () =>
4129
4304
  }
4130
4305
  }
4131
4306
  /**
4307
+ * `x401 credential add -`: the SD-JWT VC from stdin. Nothing there, or a terminal (a read that would wait on the
4308
+ * keyboard without a word), is the usage error a join gives.
4309
+ */
4310
+ async function credentialFromStdin(read, tty = false) {
4311
+ const missing = () => new CliError("usage", "Missing <file|->: give the SD-JWT VC on stdin (… | ghostly x401 credential add -) or as a file");
4312
+ if (tty) throw missing();
4313
+ const credential = await read();
4314
+ if (!credential) throw missing();
4315
+ return credential;
4316
+ }
4317
+ /**
4132
4318
  * `send`, `edit`, `group send` and `group edit` with no text words read it from stdin the same way: `command` is the
4133
4319
  * command line as given (`send bob`). `asked`: `--stdin`, which waits as long as it takes.
4134
4320
  */
@@ -4141,6 +4327,14 @@ async function textFromStdin(read, command, asked, note) {
4141
4327
  })).replace(/\n$/, "");
4142
4328
  }
4143
4329
  /**
4330
+ * `identity complete <draft> --stdin` (or `--evidence-file -`): what the tool printed, from stdin. A terminal (a read
4331
+ * that would wait on the keyboard without a word) is a usage error, as identity add --stdin's is.
4332
+ */
4333
+ async function evidenceFromStdin(read, draft, tty = false) {
4334
+ if (tty) throw new CliError("usage", `Missing what the tool printed: stdin is a terminal; pipe it in (… | ghostly identity complete ${draft}) or give --evidence-file f`);
4335
+ return read();
4336
+ }
4337
+ /**
4144
4338
  * `identity complete <draft>` with neither --evidence-file nor --stdin, stdin not a terminal: asked with nothing first,
4145
4339
  * since a published record takes none; a draft that answers it takes a tool's output (`details.needs`) is asked again
4146
4340
  * with what was piped, read as a send reads its text.
@@ -4254,23 +4448,22 @@ function secretValuesWarning(list, type, provider, names) {
4254
4448
  if (!secret.length) return void 0;
4255
4449
  return `${secret.map((name) => `--value ${name}`).join(", ")} on the command line shows in ps and the shell's history: give ${secret.length > 1 ? "them" : "it"} on stdin instead (--stdin, name=value lines)`;
4256
4450
  }
4257
- //#endregion
4258
- //#region src/main.ts
4451
+ // src/main.ts
4259
4452
  var VERSION = package_default.version;
4260
4453
  /**
4261
4454
  * The engine's modules (the API, the host, the backup, the buttons) are loaded only where a command needs them here: a
4262
4455
  * command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
4263
4456
  * cost every command ~100 ms before its socket was opened.
4264
4457
  */
4265
- var engineApi = () => import("./api-DgU4MZPD.js");
4266
- var engineHost = () => import("./host-CYlIiY3r.js");
4458
+ var engineApi = () => import("./api-DYMKyb1k.js");
4459
+ var engineHost = () => import("./host-z0FAHP9Z.js");
4267
4460
  /**
4268
4461
  * `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
4269
4462
  * asked: the app's message parser it reads costs every other command nothing.
4270
4463
  */
4271
4464
  async function translatorFor(value, home) {
4272
4465
  if (value === void 0) return null;
4273
- const { loadDetector, openTranslator, translateTarget } = await import("./translate-iQZq4TnY.js");
4466
+ const { loadDetector, openTranslator, translateTarget } = await import("./translate-BcbSWkuq.js");
4274
4467
  return openTranslator({
4275
4468
  home,
4276
4469
  to: translateTarget(value),
@@ -4282,6 +4475,11 @@ var pretty = false;
4282
4475
  function print(value) {
4283
4476
  process.stdout.write(jsonOut(value, pretty ? 2 : void 0) + "\n");
4284
4477
  }
4478
+ /**
4479
+ * Where `run` writes a failure: stdout, unless stdout is the call's audio (`call pipe`). There the error was played as
4480
+ * a click (`call pipe | aplay …`) and the terminal said nothing.
4481
+ */
4482
+ var failures = process.stdout;
4285
4483
  /** Done, with something to know (a voice note sent without its waveform): said on stderr, the JSON stays the answer. */
4286
4484
  function printAnswer(result) {
4287
4485
  if (typeof result?.warning === "string") {
@@ -4290,9 +4488,11 @@ function printAnswer(result) {
4290
4488
  }
4291
4489
  print(result);
4292
4490
  }
4293
- function globals(parsed) {
4491
+ /** `ownProfile`: the command names its profile, or none (`profile create`, `use`): a bad `<home>/current` is not read. */
4492
+ function globals(parsed, { ownProfile = false } = {}) {
4294
4493
  const home = ghostlyHome(parsed.options.home);
4295
- const profile = currentProfile(home, parsed.options.profile);
4494
+ const option = parsed.options.profile;
4495
+ const profile = ownProfile ? currentProfileOrNone(home, option) ?? "default" : currentProfile(home, option);
4296
4496
  return {
4297
4497
  home,
4298
4498
  profile,
@@ -4389,6 +4589,7 @@ function chatOnly(method, params) {
4389
4589
  function chatOrGroup(method, params) {
4390
4590
  if (method.startsWith("task.") || method.startsWith("routine.") || method.startsWith("button.") || method === "usage.send") return true;
4391
4591
  if (method === "chat.delete" && params.everyone === true) return true;
4592
+ if (method.startsWith("file.") && typeof params.file === "string" && params.file.startsWith("group-")) return true;
4392
4593
  return method === "chat.pin" || method === "chat.forward";
4393
4594
  }
4394
4595
  /**
@@ -4410,18 +4611,28 @@ function newChatOnly(method) {
4410
4611
  function oneChatOnly(method, params) {
4411
4612
  return newChatOnly(method) || (chatOnly(method, params) || chatOrGroup(method, params)) && typeof params.chat === "string";
4412
4613
  }
4413
- /** What a member says in one group, over that group's own edges: no 1:1 chat carries any of it. */
4614
+ /**
4615
+ * What a member says in one group, over that group's own edges: no 1:1 chat carries any of it. The admin's name,
4616
+ * picture, call node, hubs and fresh secret too (the group's metadata or a commit). Not `group.remove` (the one removed hears it
4617
+ * over the chat that invited them) nor `group.admin` (the new admin takes back the invitations still out).
4618
+ */
4414
4619
  var GROUP_EDGES_ONLY = /* @__PURE__ */ new Set([
4415
4620
  "group.send",
4416
4621
  "group.edit",
4417
4622
  "group.react",
4418
- "group.typing"
4623
+ "group.typing",
4624
+ "group.rename",
4625
+ "group.picture",
4626
+ "group.call",
4627
+ "group.hub",
4628
+ "group.rotate"
4419
4629
  ]);
4420
4630
  /**
4421
4631
  * A command about one group that goes over its edges only (`GROUP_EDGES_ONLY`): a one-shot for it leaves the saved 1:1
4422
- * chats unstarted (`deferChats`); the groups start, and their edges are never deferred. Started, each saved chat put its
4423
- * records and its leave packet on the relays: with 12 invites saved, one `group send` asked the relay 32 times (3 with
4424
- * none), its whole minute, and a text to an away contact, or the next one-shot, waited behind them.
4632
+ * chats and the other groups' edges unstarted (`deferChats`), and starts the group's own (`startNamedChats`). Started,
4633
+ * each saved chat put its records and its leave packet on the relays: with 12 invites saved, one `group send` asked the
4634
+ * relay 32 times (3 with none), its whole minute, and a text to an away contact, or the next one-shot, waited behind
4635
+ * them. Each other group's edges did the same: with six more groups shared with one member, 31 to 47 times.
4425
4636
  */
4426
4637
  function oneGroupOnly(method) {
4427
4638
  return GROUP_EDGES_ONLY.has(method);
@@ -4429,18 +4640,56 @@ function oneGroupOnly(method) {
4429
4640
  /**
4430
4641
  * Reads that need nothing of a chat's history: a one-shot for one leaves every saved chat unstarted too (`deferChats`),
4431
4642
  * so its start reads each chat's newest row (its place in `chat list`) and no history. It read every 1:1 chat whole:
4432
- * `profile show` took 0.8 s and 243 MB instead of 0.45 s and 162 MB with 53,800 messages in the profile.
4643
+ * `profile show` took 0.8 s and 243 MB instead of 0.45 s and 162 MB with 53,800 messages in the profile, and
4644
+ * `group list` 0.89 s and 220 MB instead of 0.42 s and 154 MB with 50,000. A group's own reads need its history only,
4645
+ * which its start reads whatever this says. The wallet's reads come from its own stores (proofs, wallet history,
4646
+ * payments), none from a chat's history: `wallet list` took 1.3 s and 239 MB instead of 0.48 s and 146 MB with 50,000
4647
+ * messages; `payment list --chat` starts the chat it names. `identity providers` reads nothing of the profile, and
4648
+ * `call auto` and `group auto` with no on|off what it keeps: each took 1.6 s and 211 MB instead of 0.8 s and 152 MB
4649
+ * with 50,000.
4433
4650
  */
4434
4651
  var NO_HISTORY_READS = /* @__PURE__ */ new Set([
4435
4652
  "status",
4436
4653
  "profile.get",
4437
4654
  "settings.get",
4438
4655
  "status.get",
4439
- "chat.list"
4656
+ "chat.list",
4657
+ "group.list",
4658
+ "group.get",
4659
+ "group.history",
4660
+ "call.list",
4661
+ "service.list",
4662
+ "identity.list",
4663
+ "x401.credential.list",
4664
+ "app.served",
4665
+ "wallet.list",
4666
+ "wallet.history",
4667
+ "payment.list",
4668
+ "identity.providers"
4440
4669
  ]);
4441
- /** Whether a one-shot for this call leaves every saved chat unstarted, its history unread (`NO_HISTORY_READS`). */
4442
- function readsNoHistory(method) {
4443
- return NO_HISTORY_READS.has(method);
4670
+ /**
4671
+ * Changes kept outside any chat (this profile's status, which each chat says on its next session; x401 keys and
4672
+ * credentials; a service; a draft; a served app), and `call answer` and `call flush`, which a one-shot refuses whatever
4673
+ * the chats say: a one-shot for one leaves every saved chat unstarted too. Each read every 1:1 chat whole first: with
4674
+ * 30,000 messages in the profile, about 0.95 s and 200 MB instead of 0.45 s and 140 MB.
4675
+ */
4676
+ var NO_HISTORY_WRITES = /* @__PURE__ */ new Set([
4677
+ "status.set",
4678
+ "status.clear",
4679
+ "x401.key.new",
4680
+ "x401.credential.add",
4681
+ "x401.credential.remove",
4682
+ "service.add",
4683
+ "identity.cancel",
4684
+ "app.serve",
4685
+ "app.unserve",
4686
+ "call.answer",
4687
+ "call.flush"
4688
+ ]);
4689
+ /** Whether a one-shot for this call leaves every saved chat unstarted, its history unread (`NO_HISTORY_READS`, `NO_HISTORY_WRITES`). */
4690
+ function readsNoHistory(method, params = {}) {
4691
+ if (method === "call.auto" || method === "group.auto") return params.on === void 0;
4692
+ return NO_HISTORY_READS.has(method) || NO_HISTORY_WRITES.has(method);
4444
4693
  }
4445
4694
  /**
4446
4695
  * Calls that only read what the profile stores: a one-shot for one opens it offline (`RuntimeOptions.offline`).
@@ -4486,7 +4735,7 @@ function readOnly(method, params) {
4486
4735
  /**
4487
4736
  * Calls whose change stays on this device: a chat's name here, a chat removed (nothing goes to the contact), auto-answer
4488
4737
  * (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
4489
- * shared with a contact). Opened online, each put the profile's records on the relays and waited for them (6 PUT + 4
4738
+ * shared with a contact), an app served or unserved (served.json: an engine reads it as it starts). Opened online, each put the profile's records on the relays and waited for them (6 PUT + 4
4490
4739
  * GET, 3.3 s with a relay that takes 1.5 s), and the contacts' apps saw this device come online. `message delete` stays
4491
4740
  * online: it settles a file offer already on the DHT.
4492
4741
  */
@@ -4502,6 +4751,8 @@ var LOCAL_WRITES = /* @__PURE__ */ new Set([
4502
4751
  "x401.credential.remove",
4503
4752
  "saved.add",
4504
4753
  "saved.remove",
4754
+ "app.serve",
4755
+ "app.unserve",
4505
4756
  "status.set",
4506
4757
  "status.clear"
4507
4758
  ]);
@@ -4522,9 +4773,26 @@ var LOCAL_SETTINGS = /* @__PURE__ */ new Set([
4522
4773
  * to be live (`keepOneShot`), so that one stays online.
4523
4774
  */
4524
4775
  var LIVE_ONLY = /* @__PURE__ */ new Set(["chat.typing", "group.typing"]);
4525
- /** Whether a one-shot for this call opens the profile offline: a read, a change that stays on this device, or typing. */
4776
+ /**
4777
+ * Done only by a daemon (a call placed, a contact's app opened on a port, a served app open in a chat): a one-shot
4778
+ * refuses them whatever the network says. Online, it said "start `ghostly daemon --detach`" only once its leave packet
4779
+ * was taken: 3.4 s with a relay that takes 1.5 s, 10 s with one that does not answer. A one-shot answers no call, queues
4780
+ * no audio to flush and has no service open to close: those said "not found" after 6-12 s online. `call hangup` stays
4781
+ * online: a call may ring while a one-shot runs, and be declined.
4782
+ */
4783
+ var DAEMON_ONLY = /* @__PURE__ */ new Set([
4784
+ "call.start",
4785
+ "call.answer",
4786
+ "call.flush",
4787
+ "service.open",
4788
+ "service.close",
4789
+ "app.open",
4790
+ "app.close",
4791
+ "app.send"
4792
+ ]);
4793
+ /** Whether a one-shot for this call opens the profile offline: a read, a change that stays on this device, typing, or what only a daemon does. */
4526
4794
  function offlineCall(method, params) {
4527
- return readOnly(method, params) || LOCAL_WRITES.has(method) || LIVE_ONLY.has(method) && params.for === void 0;
4795
+ return readOnly(method, params) || LOCAL_WRITES.has(method) || DAEMON_ONLY.has(method) || LIVE_ONLY.has(method) && params.for === void 0;
4528
4796
  }
4529
4797
  /** How long a daemon gets to answer before a command gives up: a read is in memory (15 s); a call that waits for the
4530
4798
  * contact carries its own `--timeout` (or the daemon's default for it), plus a margin; anything else may take as long
@@ -4786,9 +5054,10 @@ async function oneShotJoinWait(s, result, label) {
4786
5054
  stage
4787
5055
  };
4788
5056
  if (view.paired) return { answer };
5057
+ const typed = label?.trim();
4789
5058
  return {
4790
5059
  answer,
4791
- note: `Not paired yet: the inviter's app is offline. It pairs when both are online: keep this profile running (ghostly daemon --detach), then ghostly chat wait ${label?.trim() && !/\s/.test(label.trim()) ? label.trim() : String(result.chat)} --until paired`
5060
+ note: `Not paired yet: the inviter's app is offline. It pairs when both are online: keep this profile running (ghostly daemon --detach), then ghostly chat wait ${!!typed && shellWord(typed, "") === typed && await s.call("chat.get", { chat: typed }).then((chat) => chat?.id === result.chat, () => false) ? typed : String(result.chat)} --until paired`
4792
5061
  };
4793
5062
  }
4794
5063
  /**
@@ -4840,7 +5109,7 @@ var SPECIAL = [
4840
5109
  "A backup of the profile, encrypted with a passphrase (from a file or GHOSTLY_BACKUP_PASSPHRASE); --no-passphrase makes one anyone can read",
4841
5110
  {
4842
5111
  out: o("string", "The backup file to write"),
4843
- "passphrase-file": o("string", "The passphrase, from this file (else GHOSTLY_BACKUP_PASSPHRASE)"),
5112
+ "passphrase-file": o("string", "The passphrase, from this file, or stdin for - (else GHOSTLY_BACKUP_PASSPHRASE). One line break at its end is left out; any other space or line break at an end is refused"),
4844
5113
  passphrase: {
4845
5114
  ...o("boolean", "Do not encrypt. The file then holds the profile's keys and wallet secrets in the clear"),
4846
5115
  negatedOnly: true
@@ -4852,7 +5121,7 @@ var SPECIAL = [
4852
5121
  "profile restore <file> <new profile> [--passphrase-file f] [--use]",
4853
5122
  "A backup into a new profile (a backup made with --no-passphrase needs none)",
4854
5123
  {
4855
- "passphrase-file": o("string", "The passphrase, from this file (else GHOSTLY_BACKUP_PASSPHRASE)"),
5124
+ "passphrase-file": o("string", "The passphrase, from this file, or stdin for - (else GHOSTLY_BACKUP_PASSPHRASE). One line break at its end is left out"),
4856
5125
  use: o("boolean", "Make it the current profile")
4857
5126
  }
4858
5127
  ],
@@ -4883,8 +5152,8 @@ var SPECIAL = [
4883
5152
  "listen [--since seq] [--cursor file] [--type t]... [--turns] [--from <chat|key>]... [--group <group>]... [--exec cmd] [--webhook url] [--print] [--translate lang]",
4884
5153
  "Stream events as JSON lines (starts the profile here if no daemon runs it)",
4885
5154
  {
4886
- since: o("number", "Replay events after this seq first"),
4887
- cursor: o("string", "A file that keeps the last seq handled (read at start, written after each event)"),
5155
+ since: o("number", "Replay events after this seq first (with --cursor: only while its file holds no seq yet)"),
5156
+ cursor: o("string", "A file that keeps the last seq handled (read at start, written after each event); its seq wins over --since"),
4888
5157
  type: o("list", "Only events of this type (message.received) or family (message, or group.typing.); repeat for more"),
4889
5158
  turns: o("boolean", "Only agent turns: each message received, and each group message that mentions you, as one agent.turn event"),
4890
5159
  from: o("list", "Only this chat's events (id, a label given here or the contact's key; again for more)"),
@@ -5002,14 +5271,15 @@ function helpRow(label, text, at, columns) {
5002
5271
  }
5003
5272
  /**
5004
5273
  * What `ghostly` says first in a Ghostly folder with no profile yet: where to start, as the README's "Five minutes"
5005
- * does, before the whole list. `$ ` keeps the lines apart from the list's commands.
5274
+ * does, before the whole list. `$ ` keeps the lines apart from the list's commands. The join pipes the invite in, as
5275
+ * docs/CLI.md does: `invite join -` waits for stdin a pipe gives, and a terminal is refused it.
5006
5276
  */
5007
5277
  var FIRST_STEPS = [
5008
5278
  "First steps:",
5009
- " $ ghostly invite create --label alice make an invite for a contact",
5010
- " $ ghostly invite join - join one (pasted on stdin)",
5011
- " $ ghostly daemon --detach keep the profile online",
5012
- " $ ghostly help <command> one command and its options"
5279
+ " $ ghostly invite create --label alice make an invite for a contact",
5280
+ " $ printf '%s' \"$INVITE\" | ghostly invite join join one, from stdin",
5281
+ " $ ghostly daemon --detach keep the profile online",
5282
+ " $ ghostly help <command> one command and its options"
5013
5283
  ];
5014
5284
  function help(firstSteps = false) {
5015
5285
  const columns = helpColumns();
@@ -5114,7 +5384,7 @@ function commandHelp(words) {
5114
5384
  return lines.join("\n");
5115
5385
  }
5116
5386
  async function profileCommand(sub, argv) {
5117
- const parsed = parseArgs(argv, {
5387
+ const specs = {
5118
5388
  create: {
5119
5389
  use: {
5120
5390
  type: "boolean",
@@ -5172,8 +5442,20 @@ async function profileCommand(sub, argv) {
5172
5442
  description: ""
5173
5443
  }
5174
5444
  }
5175
- }[sub ?? ""] ?? {}, void 0, { command: commandOf("profile", sub) });
5176
- const g = globals(parsed);
5445
+ };
5446
+ let parsed;
5447
+ try {
5448
+ parsed = parseArgs(argv, specs[sub ?? ""] ?? {}, void 0, { command: commandOf("profile", sub) });
5449
+ } catch (e) {
5450
+ if ((sub === "backup" || sub === "restore") && passphraseOnLine(argv)) throw new CliError("usage", PASSPHRASE_ON_LINE);
5451
+ throw e;
5452
+ }
5453
+ const g = globals(parsed, { ownProfile: [
5454
+ "create",
5455
+ "list",
5456
+ "use",
5457
+ "restore"
5458
+ ].includes(sub ?? "") });
5177
5459
  pretty = g.pretty;
5178
5460
  switch (sub) {
5179
5461
  case "create": {
@@ -5182,7 +5464,7 @@ async function profileCommand(sub, argv) {
5182
5464
  noMoreThan(1, parsed.positionals, "profile create <name> [--use] [--name <shown name>] [--force]");
5183
5465
  const shownName = parsed.options.name === void 0 ? void 0 : checkShownNameOption(parsed.options.name);
5184
5466
  const force = parsed.options.force === true;
5185
- if (shownName) (await import("./secretGuard-DUr6bgKc.js")).guardText(shownName, force, "name", "set it");
5467
+ if (shownName) (await import("./secretGuard-BmmnEbYf.js")).guardText(shownName, force, "name", "set it");
5186
5468
  const paths = createProfile(g.home, name);
5187
5469
  let shown = null;
5188
5470
  if (shownName !== void 0) try {
@@ -5205,14 +5487,14 @@ async function profileCommand(sub, argv) {
5205
5487
  print({
5206
5488
  created: name,
5207
5489
  folder: paths.dir,
5208
- current: currentProfile(g.home) === name,
5490
+ current: currentProfileOrNone(g.home) === name,
5209
5491
  ...shown ? { profile: shown } : {}
5210
5492
  });
5211
5493
  return;
5212
5494
  }
5213
5495
  case "list": {
5214
5496
  noMoreThan(0, parsed.positionals, "profile list");
5215
- const current = currentProfile(g.home);
5497
+ const current = currentProfileOrNone(g.home);
5216
5498
  print({
5217
5499
  profiles: listProfiles(g.home).map((name) => ({
5218
5500
  name,
@@ -5228,7 +5510,9 @@ async function profileCommand(sub, argv) {
5228
5510
  if (!name) throw new CliError("usage", "Missing <name>: ghostly profile use <name>");
5229
5511
  noMoreThan(1, parsed.positionals, "profile use <name>");
5230
5512
  selectProfile(g.home, name);
5231
- print({ current: name });
5513
+ const current = currentProfile(g.home);
5514
+ if (current !== name) process.stderr.write(`ghostly: GHOSTLY_PROFILE=${current} still picks the profile in this shell: unset it to use ${name}.\n`);
5515
+ print({ current });
5232
5516
  return;
5233
5517
  }
5234
5518
  case "show":
@@ -5252,21 +5536,22 @@ async function profileCommand(sub, argv) {
5252
5536
  return;
5253
5537
  }
5254
5538
  case "backup": {
5539
+ if (parsed.options.passphrase === true) throw new CliError("usage", PASSPHRASE_ON_LINE);
5255
5540
  noMoreThan(0, parsed.positionals, "profile backup --out <file> [--passphrase-file f | --no-passphrase] [--light]");
5256
5541
  const out = parsed.options.out;
5257
5542
  if (typeof out !== "string") throw new CliError("usage", "Missing --out: ghostly profile backup --out <file> [--passphrase-file f | --no-passphrase] [--light]");
5258
5543
  const unsealed = parsed.options.passphrase === false;
5259
- if (parsed.options.passphrase === true) throw new CliError("usage", "The passphrase comes from --passphrase-file or GHOSTLY_BACKUP_PASSPHRASE, never the command line");
5260
5544
  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");
5261
5545
  const light = parsed.options.light === true ? { light: true } : {};
5262
5546
  const resolved = here(out), path = (out.endsWith("/") || out.endsWith(sep)) && !resolved.endsWith(sep) ? `${resolved}${sep}` : resolved;
5547
+ if (!path.endsWith(sep) && !localStat(dirname(path)).isDirectory()) throw new CliError("not_found", `No such file or folder: ${dirname(path)}`);
5263
5548
  const params = unsealed ? {
5264
5549
  path,
5265
5550
  noPassphrase: true,
5266
5551
  ...light
5267
5552
  } : {
5268
5553
  path,
5269
- passphrase: backupPassphrase(parsed.options["passphrase-file"]),
5554
+ passphrase: cleanEnds(await backupPassphrase(parsed.options["passphrase-file"]), parsed.options["passphrase-file"]),
5270
5555
  ...light
5271
5556
  };
5272
5557
  const made = await withSession(g, (s) => s.call("profile.backup", params), { offline: true });
@@ -5279,15 +5564,15 @@ async function profileCommand(sub, argv) {
5279
5564
  if (!given || !name) throw new CliError("usage", `Missing <${given ? "new profile" : "file"}>: ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]`);
5280
5565
  noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
5281
5566
  const file = here(given);
5282
- const { backupFileProtection, restoreProfile } = await import("./backup-CgWU7x0T.js");
5567
+ const { backupFileProtection, restoreProfile } = await import("./backup-COX6j1_W.js");
5283
5568
  const protection = await backupFileProtection(file);
5284
- const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
5569
+ const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : await backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
5285
5570
  if (parsed.options.use) selectProfile(g.home, name);
5286
5571
  print({
5287
5572
  restored: name,
5288
5573
  folder: paths.dir,
5289
5574
  protection,
5290
- current: currentProfile(g.home) === name
5575
+ current: currentProfileOrNone(g.home) === name
5291
5576
  });
5292
5577
  return;
5293
5578
  }
@@ -5321,26 +5606,61 @@ function onStopSignals(stop) {
5321
5606
  var BACKUP_PASSPHRASE = "The backup passphrase comes from --passphrase-file or GHOSTLY_BACKUP_PASSPHRASE (at least 12 characters). For a backup that is not encrypted, say so with --no-passphrase";
5322
5607
  /** Restore takes no --no-passphrase: a backup made without one says so itself. */
5323
5608
  var RESTORE_PASSPHRASE = "This backup is encrypted: its passphrase comes from --passphrase-file or GHOSTLY_BACKUP_PASSPHRASE";
5609
+ var PASSPHRASE_ON_LINE = "The passphrase comes from --passphrase-file or GHOSTLY_BACKUP_PASSPHRASE, never the command line";
5610
+ /**
5611
+ * `--passphrase` or `--passphrase=<value>` before any `--` (after it, words are positionals), or a typo of it
5612
+ * (`--pasphrase=<value>`): before, that was "did you mean --passphrase?", the one form refused here.
5613
+ */
5614
+ var passphraseOnLine = (argv) => {
5615
+ const end = argv.indexOf("--");
5616
+ return (end === -1 ? argv : argv.slice(0, end)).some((arg) => arg.startsWith("--") && nearest(arg.slice(2).split("=")[0], ["passphrase"]) === "passphrase");
5617
+ };
5324
5618
  /**
5325
5619
  * The backup passphrase: from a file or the environment, never the command line (it would sit in shell history). The
5326
5620
  * file is said as every other file the CLI reads: "" names none, a folder is named, and an empty one is called that,
5327
- * not "comes from --passphrase-file" to someone who gave it.
5621
+ * not "comes from --passphrase-file" to someone who gave it. "-" is stdin, as for every other secret the CLI takes (a
5622
+ * pipe from a password manager); a terminal is refused, as it would show the passphrase as it is typed.
5328
5623
  */
5329
- function backupPassphrase(file, missing = BACKUP_PASSPHRASE) {
5624
+ async function backupPassphrase(file, missing = BACKUP_PASSPHRASE) {
5330
5625
  if (typeof file !== "string") {
5331
5626
  const value = process.env.GHOSTLY_BACKUP_PASSPHRASE;
5332
5627
  if (!value) throw new CliError("usage", missing);
5333
5628
  return value;
5334
5629
  }
5630
+ if (file === "-" && process.stdin.isTTY) throw new CliError("usage", "--passphrase-file - reads stdin: pipe the passphrase in (… | ghostly profile …), or name a file");
5335
5631
  let value;
5336
- try {
5632
+ if (file === "-") value = (await readStdin()).replace(/\r?\n$/, "");
5633
+ else try {
5337
5634
  value = readFileSync(here(file), "utf8").replace(/\r?\n$/, "");
5338
5635
  } catch (error) {
5339
5636
  throw localFileError(error, file) ?? error;
5340
5637
  }
5341
- if (!value) throw new CliError("bad_request", `${file} is empty: it holds the backup's passphrase`);
5638
+ if (!value) throw new CliError("bad_request", `${file === "-" ? "Stdin" : file} is empty: it holds the backup's passphrase`);
5342
5639
  return value;
5343
5640
  }
5641
+ var END_NAMES = {
5642
+ " ": "a space",
5643
+ " ": "a tab",
5644
+ "\r": "a carriage return",
5645
+ "\n": "a line break",
5646
+ "": "a byte order mark"
5647
+ };
5648
+ var endName = (char) => END_NAMES[char] ?? `U+${char.codePointAt(0).toString(16).toUpperCase().padStart(4, "0")} (a space)`;
5649
+ /**
5650
+ * A new backup's passphrase, refused when it starts or ends with whitespace or a byte order mark, or holds a NUL (a
5651
+ * file saved as UTF-16): only the one line break at a file's end is left out, so the same passphrase typed, pasted or
5652
+ * held by a password manager would open nothing ("Wrong passphrase"). Restore takes any passphrase: old backups open.
5653
+ */
5654
+ function cleanEnds(passphrase, file) {
5655
+ const source = typeof file !== "string" ? "GHOSTLY_BACKUP_PASSPHRASE" : file === "-" ? "stdin" : file;
5656
+ if (passphrase.includes("\0")) throw new CliError("bad_request", `${source} holds a NUL: a file saved as UTF-16? Save the passphrase as UTF-8 text`);
5657
+ const trimmed = passphrase.trim();
5658
+ if (trimmed === passphrase) return passphrase;
5659
+ const at = trimmed && passphrase.startsWith(trimmed) ? "ends" : "starts";
5660
+ const char = at === "ends" ? passphrase.at(-1) : passphrase[0];
5661
+ const fileRule = typeof file === "string" ? " (one line break at its end is left out already)" : "";
5662
+ throw new CliError("bad_request", `The passphrase in ${source} ${at} with ${endName(char)}${fileRule}: the same passphrase typed or pasted would not open the backup. Take it out`);
5663
+ }
5344
5664
  /** Set on `startDetached`'s child: its parent waits for the profile and starts it again, so the child does not wait too. */
5345
5665
  var DETACHED_CHILD = "GHOSTLY_DAEMON_DETACHED";
5346
5666
  /**
@@ -5357,7 +5677,7 @@ async function runDaemon(g, seconds) {
5357
5677
  const until = performance.now() + seconds * 1e3;
5358
5678
  let host;
5359
5679
  for (;;) {
5360
- if (await connectDaemon(g.paths)) throw childAnswer(detached, new CliError("busy", `A daemon already runs profile ${g.profile}`));
5680
+ await noDaemonAnswers(g, detached);
5361
5681
  try {
5362
5682
  host = await openHost(g.paths, "daemon", VERSION);
5363
5683
  break;
@@ -5394,6 +5714,16 @@ async function runDaemon(g, seconds) {
5394
5714
  });
5395
5715
  }
5396
5716
  /**
5717
+ * Throws busy when something answers on the profile's socket while a process holds the profile (a daemon starts only
5718
+ * then). With nobody holding it, what answers is no daemon: the start said one ran, and the refusal names the way out.
5719
+ */
5720
+ async function noDaemonAnswers(g, detached = false) {
5721
+ const client = await connectDaemon(g.paths);
5722
+ if (!client) return;
5723
+ client.close();
5724
+ throw childAnswer(detached, lockOwner(g.paths) === null ? notTheDaemon(g.paths, false) : new CliError("busy", `A daemon already runs profile ${g.profile}`));
5725
+ }
5726
+ /**
5397
5727
  * A detached child's answer carries its own pid (`child`): its parent reads it in `daemon.log`, where every daemon of
5398
5728
  * the profile writes, and another detach's child that lost the profile, or refused to start, writes there too.
5399
5729
  */
@@ -5554,7 +5884,7 @@ async function stopDaemon(g, client, seconds) {
5554
5884
  const refused = isNotTheDaemon(error);
5555
5885
  if (!(error instanceof CliError && error.code === "timeout") && !refused) throw error;
5556
5886
  const holder = lockOwner(g.paths);
5557
- if (holder === null) throw error;
5887
+ if (holder === null) throw refused ? notTheDaemon(g.paths, false) : error;
5558
5888
  process.stderr.write(refused ? `ghostly: what answers on the socket did not prove it is this profile's daemon (an older release's cannot): stopping the process that holds the profile (${holder}) with SIGTERM\n` : `ghostly: the daemon (process ${holder}) did not answer daemon.stop in ${seconds} s: stopping it with SIGTERM\n`);
5559
5889
  pid = holder;
5560
5890
  answered = false;
@@ -5621,7 +5951,7 @@ async function startDetached(g, seconds) {
5621
5951
  try {
5622
5952
  const until = performance.now() + seconds * 1e3;
5623
5953
  for (;;) {
5624
- if (await connectDaemon(g.paths)) throw new CliError("busy", `A daemon already runs profile ${g.profile}`);
5954
+ await noDaemonAnswers(g);
5625
5955
  if (lockOwner(g.paths) === null) {
5626
5956
  const started = await spawnDaemon(g, until);
5627
5957
  if (started) return started;
@@ -5807,7 +6137,7 @@ async function listenCommand(argv) {
5807
6137
  const from = parsed.options.from ?? [], groups = parsed.options.group ?? [];
5808
6138
  const cursor = here(parsed.options.cursor);
5809
6139
  checkCursor(cursor);
5810
- const since$1 = since(parsed.options) ?? readCursor(cursor);
6140
+ const starting = startAt(since(parsed.options), cursor, (line) => process.stderr.write(line + "\n")), since$1 = starting.from;
5811
6141
  const translator = await translatorFor(parsed.options.translate, g.home);
5812
6142
  let quit = (code) => {
5813
6143
  process.exit(code);
@@ -5824,6 +6154,10 @@ async function listenCommand(argv) {
5824
6154
  turns,
5825
6155
  translate: translator?.event,
5826
6156
  exec: parsed.options.exec,
6157
+ profile: {
6158
+ home: g.home,
6159
+ name: g.profile
6160
+ },
5827
6161
  webhook,
5828
6162
  cursor,
5829
6163
  cursorFailed,
@@ -5868,8 +6202,9 @@ async function listenCommand(argv) {
5868
6202
  process.exit(code);
5869
6203
  };
5870
6204
  onReaderGone(stop);
5871
- await following.subscribed;
5872
6205
  onStopSignals(stop);
6206
+ const answer = await following.subscribed;
6207
+ if (typeof answer?.lastSeq === "number") starting.known(answer.lastSeq);
5873
6208
  return;
5874
6209
  }
5875
6210
  const [{ keepServing, serve }, { callApi }] = await Promise.all([engineHost(), engineApi()]);
@@ -5923,6 +6258,7 @@ async function listenCommand(argv) {
5923
6258
  off?.();
5924
6259
  off = null;
5925
6260
  }, open);
6261
+ starting.known(host.ctx.hub.lastSeq);
5926
6262
  open(since$1);
5927
6263
  host.ctx.hub.emit("daemon.started", `daemon.started:${process.pid}:${Date.now()}`, {
5928
6264
  pid: process.pid,
@@ -5995,7 +6331,7 @@ async function engineCommand(argv) {
5995
6331
  const { hideStateSecrets } = await engineApi();
5996
6332
  result = hideStateSecrets(result);
5997
6333
  }
5998
- print(result);
6334
+ print(hideSecretFields(method, result, showSecret));
5999
6335
  }
6000
6336
  async function settingsCommand(sub, argv) {
6001
6337
  const parsed = parseArgs(argv, {
@@ -6025,6 +6361,7 @@ async function settingsCommand(sub, argv) {
6025
6361
  const [key, given] = parsed.positionals;
6026
6362
  if (!key) throw new CliError("usage", "Missing <key>: ghostly settings set <key> <json-value> [--force]");
6027
6363
  noMoreThan(2, parsed.positionals, "settings set <key> <json-value> [--force]");
6364
+ const kind = key === "readRelays" ? void 0 : checkSettingKey(key, (await engineApi()).SETTABLE);
6028
6365
  const { value, warning } = await settingValue(key, given, readStdin, process.stdin.isTTY === true, (note) => process.stderr.write(`ghostly: ${note}\n`));
6029
6366
  if (warning) process.stderr.write(`ghostly: ${warning}\n`);
6030
6367
  let parsedValue;
@@ -6033,7 +6370,8 @@ async function settingsCommand(sub, argv) {
6033
6370
  } catch {
6034
6371
  parsedValue = value;
6035
6372
  }
6036
- if ((await engineApi()).SETTABLE[key] === "string" && typeof parsedValue !== "string") parsedValue = value;
6373
+ if (kind === "string" && typeof parsedValue !== "string") parsedValue = value;
6374
+ if (kind) checkSettingValue(key, kind, parsedValue, value);
6037
6375
  const force = parsed.options.force === true ? { force: true } : {};
6038
6376
  printAnswer(await withSession(g, (s) => s.call("settings.set", {
6039
6377
  [key]: parsedValue,
@@ -6055,6 +6393,7 @@ async function textCommand(name, argv) {
6055
6393
  const [message, ...words] = spec.message ? rest : [void 0, ...rest];
6056
6394
  if (!target || spec.message && !message) throw new CliError("usage", `Missing <${target ? "message" : spec.target}>: ghostly ${spec.usage}`);
6057
6395
  timeout(parsed.options);
6396
+ if (parsed.options.reply === "") throw new CliError("usage", "--reply needs a message id");
6058
6397
  let text = words.join(" ");
6059
6398
  if (parsed.options.text !== void 0) {
6060
6399
  if (text || parsed.options.stdin) throw new CliError("usage", "Give the text once: as arguments, --text or stdin");
@@ -6072,7 +6411,7 @@ async function textCommand(name, argv) {
6072
6411
  };
6073
6412
  if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
6074
6413
  if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
6075
- if (!spec.message) Object.assign(params, (await import("./buttons-Cco0Agfa.js")).buttonsOf(parsed.options));
6414
+ if (!spec.message) Object.assign(params, (await import("./buttons-Bq7pTXqF.js")).buttonsOf(parsed.options));
6076
6415
  print(await withSession(g, (s) => {
6077
6416
  if (parsed.options.wait !== void 0) params.wait = parsed.options.wait;
6078
6417
  if (parsed.options.timeout !== void 0) params.timeout = parsed.options.timeout;
@@ -6116,7 +6455,7 @@ async function identityAddCommand(argv) {
6116
6455
  if (!provider) throw new CliError("usage", "Missing <provider>: ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]");
6117
6456
  inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
6118
6457
  const items = parsed.options.field ?? [];
6119
- const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-CE0PpQAE.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
6458
+ const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-B15Yg_1C.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
6120
6459
  if (known && parsed.options.days !== void 0) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
6121
6460
  const { fields, warning } = await identityFields(items, parsed.options.stdin === true, identitySecretFields(known, parsed.options.signer), readStdin, process.stdin.isTTY === true);
6122
6461
  if (warning) process.stderr.write(`ghostly: ${warning}\n`);
@@ -6191,17 +6530,16 @@ async function tableCommand(name, argv) {
6191
6530
  } catch (error) {
6192
6531
  throw localFileError(error, params.evidenceFile) ?? error;
6193
6532
  }
6194
- else if (params.stdin) params.evidence = await readStdin();
6533
+ else if (params.stdin) params.evidence = await evidenceFromStdin(readStdin, String(params.draft), process.stdin.isTTY === true);
6195
6534
  delete params.evidenceFile;
6196
6535
  delete params.stdin;
6197
6536
  }
6198
6537
  if (command.method === "x401.credential.add") {
6199
6538
  try {
6200
- params.credential = params.file === "-" ? await readStdin() : readInput(params.file);
6539
+ params.credential = params.file === "-" ? await credentialFromStdin(readStdin, process.stdin.isTTY === true) : readInput(params.file);
6201
6540
  } catch (error) {
6202
6541
  throw error instanceof CliError && error || localFileError(error, params.file) || new CliError("usage", `Cannot read the credential: ${error instanceof Error ? error.message : String(error)}`);
6203
6542
  }
6204
- 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");
6205
6543
  if (!params.credential) throw new CliError("bad_request", `${params.file} is empty: it holds the SD-JWT VC the issuer sent`);
6206
6544
  delete params.file;
6207
6545
  }
@@ -6222,12 +6560,12 @@ async function tableCommand(name, argv) {
6222
6560
  return result;
6223
6561
  }, {
6224
6562
  deferGroups: chatOnly(command.method, params) || newChatOnly(command.method),
6225
- deferChats: oneChatOnly(command.method, params) || oneGroupOnly(command.method) || readsNoHistory(command.method),
6563
+ deferChats: oneChatOnly(command.method, params) || oneGroupOnly(command.method) || readsNoHistory(command.method, params),
6226
6564
  offline: offlineCall(command.method, params)
6227
6565
  });
6228
6566
  if (translator) {
6229
6567
  try {
6230
- printAnswer(await (await import("./translate-iQZq4TnY.js")).translateAnswer(result, translator));
6568
+ printAnswer(await (await import("./translate-BcbSWkuq.js")).translateAnswer(result, translator));
6231
6569
  } finally {
6232
6570
  translator.close();
6233
6571
  }
@@ -6240,19 +6578,28 @@ async function tableCommand(name, argv) {
6240
6578
  * contact's, raw PCM); what the command says goes to stderr. It ends when the call does.
6241
6579
  */
6242
6580
  async function callPipeCommand(argv) {
6581
+ failures = process.stderr;
6243
6582
  const parsed = parseArgs(argv, {}, idSlot({ args: ["call...?"] }), { command: "call pipe" });
6244
6583
  const g = globals(parsed);
6245
6584
  const ref = parsed.positionals.join(" ") || void 0;
6246
6585
  const client = await connectDaemon(g.paths);
6247
6586
  if (!client) throw new CliError("unavailable", `No daemon runs profile ${g.profile}: calls need one (ghostly daemon --detach)`);
6248
6587
  let call;
6588
+ let reason = null, heard = null;
6249
6589
  try {
6250
6590
  call = await client.call("call.get", ref ? { call: ref } : {}, { timeoutMs: ANSWER_MS });
6251
- } finally {
6591
+ if (!call.audio) throw new CliError("unavailable", "That call has no audio yet: answer it first");
6592
+ const id = call.call;
6593
+ await client.subscribe(void 0, (event) => {
6594
+ if (event.type !== "call.ended" || event.call !== id) return;
6595
+ reason = String(event.reason);
6596
+ heard?.();
6597
+ }, () => heard?.());
6598
+ } catch (error) {
6252
6599
  client.close();
6600
+ throw error;
6253
6601
  }
6254
6602
  const audio = call.audio;
6255
- if (!audio) throw new CliError("unavailable", "That call has no audio yet: answer it first");
6256
6603
  const socket = connect(audio.socket);
6257
6604
  await new Promise((resolve, reject) => {
6258
6605
  socket.once("connect", resolve);
@@ -6261,13 +6608,30 @@ async function callPipeCommand(argv) {
6261
6608
  socket.write(`${audio.token}\n`);
6262
6609
  process.stderr.write(`ghostly: call ${call.call}: s16le mono ${audio.rate} Hz on stdin/stdout\n`);
6263
6610
  process.stdin.pipe(socket, { end: false });
6611
+ let readerGone = false;
6264
6612
  onReaderGone(() => {
6613
+ readerGone = true;
6265
6614
  process.stderr.write(`ghostly: call ${call.call}: nothing reads its audio any more; the call goes on\n`);
6266
6615
  socket.destroy();
6267
6616
  });
6268
6617
  socket.pipe(process.stdout);
6269
- socket.on("close", () => exit(0));
6618
+ socket.on("close", () => void (async () => {
6619
+ if (!readerGone) process.stderr.write(`ghostly: call ${call.call}: ${await whyClosed()}\n`);
6620
+ client.close();
6621
+ exit(0);
6622
+ })());
6270
6623
  socket.on("error", () => exit(1));
6624
+ /** Why the daemon closed the call's socket: a call still on gave it to another program; one gone ended. */
6625
+ async function whyClosed() {
6626
+ if (reason === null) {
6627
+ if (await client.call("call.get", { call: call.call }, { timeoutMs: 5e3 }).then(() => true, () => false) && reason === null) return "another program took its audio; the call goes on";
6628
+ if (reason === null) await new Promise((resolve) => {
6629
+ heard = resolve;
6630
+ setTimeout(resolve, 3e3).unref();
6631
+ });
6632
+ }
6633
+ return reason === null ? "the call ended" : `the call ended (${reason})`;
6634
+ }
6271
6635
  }
6272
6636
  /**
6273
6637
  * The command's words when the line asks for help (`help <words>`, or `--help`/`--help=true`/`-h` before any `--`), else
@@ -6447,11 +6811,10 @@ async function run(argv) {
6447
6811
  if (code >= 0) exit(code);
6448
6812
  } catch (error) {
6449
6813
  const failure = asCliError(error);
6450
- print({ error: failure.toJSON() });
6814
+ failures.write(jsonOut({ error: failure.toJSON() }, pretty ? 2 : void 0) + "\n");
6451
6815
  exit(EXIT[failure.code]);
6452
6816
  }
6453
6817
  }
6454
- //#endregion
6455
6818
  export { run };
6456
6819
 
6457
- //# sourceMappingURL=main-C0PfjKTe.js.map
6820
+ //# sourceMappingURL=main-CVqkvuIo.js.map