@ghostlytools/cli 1.7.3 → 1.7.4
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.
- package/README.md +18 -13
- package/SKILL.md +5 -3
- package/dist/assets/{api-B42F9ytB.js → api-Chhvpwok.js} +2 -2
- package/dist/assets/{api-tf-wAAnB.js → api-D3i2hwy0.js} +142 -84
- package/dist/assets/api-D3i2hwy0.js.map +1 -0
- package/dist/assets/{apiKit-DJb9hulp.js → apiKit-BtsHrnoo.js} +30 -7
- package/dist/assets/apiKit-BtsHrnoo.js.map +1 -0
- package/dist/assets/{apps-BfoDISRg.js → apps-BFJTqvAt.js} +1 -1
- package/dist/assets/{apps-DIrWmLgL.js → apps-BHl97rHs.js} +10 -8
- package/dist/assets/apps-BHl97rHs.js.map +1 -0
- package/dist/assets/{arkade-CJAhhgPQ.js → arkade-BFE8KkEE.js} +2 -2
- package/dist/assets/{arkade-CJAhhgPQ.js.map → arkade-BFE8KkEE.js.map} +1 -1
- package/dist/assets/{backup-BkUeeduy.js → backup-Bbsr6nDi.js} +1 -1
- package/dist/assets/{backup-Bko-AAm0.js → backup-CxACdtQX.js} +7 -7
- package/dist/assets/{backup-Bko-AAm0.js.map → backup-CxACdtQX.js.map} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
- package/dist/assets/{blobFiles-Bckz9fjp.js → blobFiles-DOQDRdDI.js} +3 -3
- package/dist/assets/{blobFiles-Bckz9fjp.js.map → blobFiles-DOQDRdDI.js.map} +1 -1
- package/dist/assets/{buttons-DeA6Yddq.js → buttons-CieBtXEO.js} +4 -4
- package/dist/assets/{buttons-DeA6Yddq.js.map → buttons-CieBtXEO.js.map} +1 -1
- package/dist/assets/buttons-YtAj3R_E.js +2 -0
- package/dist/assets/{daemonProof-Bp9lJDxf.js → daemonProof-QmtwDj-N.js} +2 -2
- package/dist/assets/{daemonProof-Bp9lJDxf.js.map → daemonProof-QmtwDj-N.js.map} +1 -1
- package/dist/assets/{envelope-Cz5fc7BM.js → envelope-DYiGwzq_.js} +2 -2
- package/dist/assets/{envelope-Cz5fc7BM.js.map → envelope-DYiGwzq_.js.map} +1 -1
- package/dist/assets/{errors-mnjSQlbX.js → errors-QUGP-jIF.js} +2 -2
- package/dist/assets/errors-QUGP-jIF.js.map +1 -0
- package/dist/assets/{fileBytes-OolN5cSY.js → fileBytes-BPDKufla.js} +1 -1
- package/dist/assets/{fileBytes-BD0v3rRG.js → fileBytes-DNgrRL0R.js} +3 -3
- package/dist/assets/{fileBytes-BD0v3rRG.js.map → fileBytes-DNgrRL0R.js.map} +1 -1
- package/dist/assets/{fileBytes-_fd-2JRY.js → fileBytes-Q3ehcEr8.js} +2 -2
- package/dist/assets/{fileBytes-_fd-2JRY.js.map → fileBytes-Q3ehcEr8.js.map} +1 -1
- package/dist/assets/fileBytesIdb-DZcESfTt.js +2 -0
- package/dist/assets/{fileBytesIdb-NtA8r9EM.js → fileBytesIdb-Dm1EyEbT.js} +3 -3
- package/dist/assets/{fileBytesIdb-NtA8r9EM.js.map → fileBytesIdb-Dm1EyEbT.js.map} +1 -1
- package/dist/assets/{fileBytesOpfs-B8fJwkwM.js → fileBytesOpfs-ZGD21c4Q.js} +3 -3
- package/dist/assets/{fileBytesOpfs-B8fJwkwM.js.map → fileBytesOpfs-ZGD21c4Q.js.map} +1 -1
- package/dist/assets/{groupFiles-BlZRBWpt.js → groupFiles-CBJIEvCE.js} +22 -10
- package/dist/assets/groupFiles-CBJIEvCE.js.map +1 -0
- package/dist/assets/{host-BX0DmKW6.js → host-Va-r_KJz.js} +54 -16
- package/dist/assets/host-Va-r_KJz.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-DitYDnXx.js → hyperdhtRelay-B2uK9tJv.js} +2 -2
- package/dist/assets/{hyperdhtRelay-DitYDnXx.js.map → hyperdhtRelay-B2uK9tJv.js.map} +1 -1
- package/dist/assets/{idb-BlH8-O3R.js → idb-BkOJES5_.js} +5 -3
- package/dist/assets/idb-BkOJES5_.js.map +1 -0
- package/dist/assets/{irohWeb-R3bcd34h.js → irohWeb-DxeEgQ-W.js} +2 -2
- package/dist/assets/{irohWeb-R3bcd34h.js.map → irohWeb-DxeEgQ-W.js.map} +1 -1
- package/dist/assets/{main-6QOSvQ8b.js → main-BX4oPWCJ.js} +362 -110
- package/dist/assets/main-BX4oPWCJ.js.map +1 -0
- package/dist/assets/{mainline-BfwezHWi.js → mainline-IfWQOB-J.js} +39 -12
- package/dist/assets/mainline-IfWQOB-J.js.map +1 -0
- package/dist/assets/{networkReason-Ba9415nn.js → networkReason-N2vAaoth.js} +3 -3
- package/dist/assets/{networkReason-Ba9415nn.js.map → networkReason-N2vAaoth.js.map} +1 -1
- package/dist/assets/{nwc-ovXSN2M2.js → nwc-CzyCtNK2.js} +3 -3
- package/dist/assets/{nwc-ovXSN2M2.js.map → nwc-CzyCtNK2.js.map} +1 -1
- package/dist/assets/{nwcProvider-BzZbfFP3.js → nwcProvider-DjWmEn3j.js} +2 -2
- package/dist/assets/{nwcProvider-BzZbfFP3.js.map → nwcProvider-DjWmEn3j.js.map} +1 -1
- package/dist/assets/{profiles-C6XWqre5.js → profiles-DcCeOi7J.js} +104 -10
- package/dist/assets/profiles-DcCeOi7J.js.map +1 -0
- package/dist/assets/{registry-CFtlhWCI.js → registry-BmS02J5h.js} +1 -1
- package/dist/assets/{registry-B0Uv9yL6.js → registry-CeW8XEQc.js} +45 -14
- package/dist/assets/registry-CeW8XEQc.js.map +1 -0
- package/dist/assets/{resolve-BzFG4WDU.js → resolve-BvHkAhDH.js} +66 -29
- package/dist/assets/resolve-BvHkAhDH.js.map +1 -0
- package/dist/assets/{restoredRows-Fv-MuY45.js → restoredRows-mTTp3XNs.js} +2 -2
- package/dist/assets/{restoredRows-Fv-MuY45.js.map → restoredRows-mTTp3XNs.js.map} +1 -1
- package/dist/assets/{server-BGCuHbmQ.js → server-BUcJo4vz.js} +779 -239
- package/dist/assets/server-BUcJo4vz.js.map +1 -0
- package/dist/assets/{src-DWw2hUE5.js → src-BB5-5P3s.js} +540 -159
- package/dist/assets/src-BB5-5P3s.js.map +1 -0
- package/dist/assets/{translate-DObb-1tq.js → translate-2WyaRVCr.js} +11 -9
- package/dist/assets/translate-2WyaRVCr.js.map +1 -0
- package/dist/assets/{usdt-Bkva90Vo.js → usdt-BLazHiaP.js} +3 -3
- package/dist/assets/{usdt-Bkva90Vo.js.map → usdt-BLazHiaP.js.map} +1 -1
- package/dist/assets/{words-odSAoasK.js → words-BaumxjXe.js} +3 -3
- package/dist/assets/words-BaumxjXe.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/api-tf-wAAnB.js.map +0 -1
- package/dist/assets/apiKit-DJb9hulp.js.map +0 -1
- package/dist/assets/apps-DIrWmLgL.js.map +0 -1
- package/dist/assets/buttons-Be7u0V5g.js +0 -2
- package/dist/assets/errors-mnjSQlbX.js.map +0 -1
- package/dist/assets/fileBytesIdb-CsSQcSxD.js +0 -2
- package/dist/assets/groupFiles-BlZRBWpt.js.map +0 -1
- package/dist/assets/host-BX0DmKW6.js.map +0 -1
- package/dist/assets/idb-BlH8-O3R.js.map +0 -1
- package/dist/assets/main-6QOSvQ8b.js.map +0 -1
- package/dist/assets/mainline-BfwezHWi.js.map +0 -1
- package/dist/assets/profiles-C6XWqre5.js.map +0 -1
- package/dist/assets/registry-B0Uv9yL6.js.map +0 -1
- package/dist/assets/resolve-BzFG4WDU.js.map +0 -1
- package/dist/assets/server-BGCuHbmQ.js.map +0 -1
- package/dist/assets/src-DWw2hUE5.js.map +0 -1
- package/dist/assets/translate-DObb-1tq.js.map +0 -1
- package/dist/assets/words-odSAoasK.js.map +0 -1
package/README.md
CHANGED
|
@@ -118,13 +118,13 @@ The rows are in alphabetical order of their first command, and every command of
|
|
|
118
118
|
| `chat connect <chat>`, `chat disconnect <chat> [--hold <minutes>]` | Reconnect now (ends a hold); close the live session, or with `--hold` stay off the direct link that long ([Staying off the direct link](#staying-off-the-direct-link)) |
|
|
119
119
|
| `chat history <chat> [--limit n] [--before x] [--after x] [--translate lang]` | Messages, oldest first; `x` is a message id or a time in ms ([Translation](#translation)) |
|
|
120
120
|
| `chat list [--show-secret]`, `chat show <chat> [--show-secret]` | Chats, and one chat's connection: transports, last attempt, comparison code. A pending chat's `invite` prints as `<hidden>` without `--show-secret` |
|
|
121
|
-
| `chat pay <chat> <sats> [--memo t] [--network n] [--confirm-real]` | Ecash to a contact. A contact that offers no way of paying is `refused`: `details.reason` `contact_no_wallet` (it has no wallet yet) or `contact_payments_off` (it has payments off in this chat, or an older app) |
|
|
122
|
-
| `chat rename <chat> <name>`, `chat remove <chat> --yes` | Name it here; delete it (keys and history) here |
|
|
123
|
-
| `chat request <chat> <sats> [--memo t] [--method m] [--rail r]`, `chat pay-request <chat> <payment>` | Ask a contact to pay; pay the contact's request. Refused as `chat pay` is when the contact offers no way of paying |
|
|
121
|
+
| `chat pay <chat> <sats> [--memo t] [--network n] [--confirm-real]` | Ecash to a contact. A contact that offers no way of paying is `refused`: `details.reason` `contact_no_wallet` (it has no wallet yet) or `contact_payments_off` (it has payments off in this chat, or an older app). With no Cashu wallet of the network on this side, `refused` with `details.reason` `no_wallet` and the `wallet create` command to run; with one too short of sats, `refused` |
|
|
122
|
+
| `chat rename <chat> <name>`, `chat remove <chat> --yes` | Name it here; delete it (keys and history) here, refused (`busy`) while a call is on in it: hang the call up first |
|
|
123
|
+
| `chat request <chat> <sats> [--memo t] [--method m] [--rail r]`, `chat pay-request <chat> <payment>` | Ask a contact to pay; pay the contact's request. Refused as `chat pay` is when the contact offers no way of paying, or when `chat request` has no Cashu wallet of the network here (`no_wallet`) |
|
|
124
124
|
| `chat transport <chat> <auto\|dht\|webrtc\|iroh\|hyperdht>` | What carries the chat |
|
|
125
125
|
| `chat verify <chat> --code <code>` | Mark the contact verified after comparing the codes out of band |
|
|
126
126
|
| `chat wait <chat> [--until live\|text\|paired] [--timeout s]` | Wait for a chat to go live, carry text, or see its contact. Live means a session that exists now, in this run of the daemon: a chat that was live before a restart counts once its contact answers again |
|
|
127
|
-
| `daemon [--detach] [--timeout s]`, `daemon status [--timeout s]`, `daemon stop [--timeout s]`, `daemon restart [--timeout s]` | Keep the profile online; `status` names its version and its socket (`socket`, for the [socket API](#the-socket-api)); `restart` stops it and starts this release's code in the background ([After an upgrade](#after-an-upgrade)). Ctrl-C, SIGTERM and the terminal closing (SIGHUP) stop it cleanly. A command that holds the profile for a moment (a bot's `send` while a service manager restarts it) is waited for, up to `--timeout` (60 s): still held then, `busy` with its pid |
|
|
127
|
+
| `daemon [--detach] [--timeout s]`, `daemon status [--timeout s]`, `daemon stop [--timeout s]`, `daemon restart [--timeout s]` | Keep the profile online; `status` names its version and its socket (`socket`, for the [socket API](#the-socket-api)), or says `"starting": true` with the `pid` of a daemon whose socket does not listen yet (`stop` and `restart` wait up to `--timeout` for that socket, then stop it); `restart` stops it and starts this release's code in the background ([After an upgrade](#after-an-upgrade)). Ctrl-C, SIGTERM and the terminal closing (SIGHUP) stop it cleanly. A command that holds the profile for a moment (a bot's `send` while a service manager restarts it) is waited for, up to `--timeout` (60 s): still held then, `busy` with its pid |
|
|
128
128
|
| `edit <chat> <message> [text… \| --text <text> \| --stdin] [--force] [--wait none\|confirmed] [--timeout s]` | Replace the text of a message you sent (1:1 chats, `group edit` for a group; `<message>` is the `messageId` `send` gave, or its wire id). The contact sees it in place, marked edited; `--wait confirmed` waits for its app to confirm (the default without a daemon). At most 100 edits a message, no time limit; an older contact app gets it once it shows edits |
|
|
129
129
|
| `engine <method> [json \| -] [--confirm-real] [--show-secret] [--yes] [--force]`, `engine --list [--verbose]` | Any call of the app's engine; `--verbose` lists what each takes (`{ linkId, label }`, `?` for an optional key). A call given less than it takes is refused as `bad_request`. One that deletes chats or groups (`clearProfileData`, `removeLink`, `leaveGroup`, `forgetGroup`, `deviceRemove`) needs `--yes`; `clearProfileData` answers what it removed and stops a daemon. One that sends a text that looks like a secret (`sendMessage`, `sendGroupMessage`, `editMessage`, `forwardMessages`) needs `--force` |
|
|
130
130
|
| `events [--since seq] [--translate lang]` | What the event journal holds, without following ([Translation](#translation)) |
|
|
@@ -132,7 +132,7 @@ The rows are in alphabetical order of their first command, and every command of
|
|
|
132
132
|
| `file resend [<chat>] <file>`, `file request [<chat>] <file>` | A file that stopped moving: sent again from here, or asked for again from the contact (a group's file: from whoever holds it); either goes on from the bytes the receiver holds (files/3) |
|
|
133
133
|
| `file save [<chat>] <file> [--dir d \| --path p] [--force] [--wait [--timeout s]]` | Write a received file to disk: to `--path`, or into `--dir` under the name its sender gave it, with a `_` first when that name starts with `-`, so no tool run in the folder takes it for an option; a voice message goes in under the name Ghostly makes for it (`Ghostly voice <date time>`), and when that name is taken (two of one second) under a free `… (2)` (the answer's `path` is what was written). Never over a file without `--force`; an unfinished one says how many bytes are here; `--wait` waits for it first |
|
|
134
134
|
| `file send <chat\|group> <path> [--name n] [--mime t] [--voice [ms] [--peaks …]] [--reply <message>]` | A file, or a voice note (its length and waveform measured from the file unless given); `--reply` quotes a message, as `send --reply` does. Answers the message's `messageId` (what `message delete`, `react` and `pin` take) and the file's id. To a group (`group:<id>` when a chat has the same name), up to 100 MiB: every member sees it at once and each member's app fetches it from a member who has it (WISP 503) |
|
|
135
|
-
| `file wait [<chat>] <file> [--timeout s]` | Wait until a transfer ends: exit `0` when the file is all here, `1` with the transfer's error when it failed (`details.retry`: `file resend` can go on), `4` on timeout (default 300 s) |
|
|
135
|
+
| `file wait [<chat>] <file> [--timeout s]` | Wait until a transfer ends: exit `0` when the file is all here, `1` with the transfer's error when it failed (`details.retry`: `file resend` can go on), `4` on timeout (default 300 s), `5` at once when a received file waits for you to take it (over 25 MiB, or a group's file that did not come by itself): the message names `file accept` |
|
|
136
136
|
| `forward <chat\|group> <message>… --to <chat\|group>… [--force] [--wait none\|sent] [--timeout s]` | Forward messages to up to 5 chats and groups (`--to` again for each; `group:<id>` names a group when a chat has the same name; an id that starts with a dash is taken as it is, `--to -Ab…` or `--to=-Ab…`). Each is a new message of yours that says it was forwarded (`forwarded`, the hop count) and nothing of who wrote it. Files go from the bytes this profile holds, never fetched again; a group takes texts only. A text that looks like a seed, a key or ecash needs `--force`. Answers `{from, results: [{to, kind, messageIds, error}]}`; any refusal fails the command (exit 1) with the results in `details`. `--wait sent`: each text on its way (a group's taken by an edge), each file's transfer done |
|
|
137
137
|
| `group create <name> [--mesh]`, `group join [<link> \| -]` | A community (a link anyone can open), or a private mesh. `group join` reads the link from stdin when none is given or `-` (on the command line it shows in `ps` and the shell's history, and the CLI warns). `group join` with the link of a community the profile was removed from asks to be let in again, and keeps its history |
|
|
138
138
|
| `group edit <group> <message> [text… \| --text <text> \| --stdin] [--mention <member>]… [--force]` | Replace the text of a message you sent to the group (`<message>` is the `messageId` `group send` gave). Every member sees it in place, marked edited; mentions whose `@name` is still in the text stay, `--mention` adds more. Answers `{group, messageId, edits, sent, edges}`: `edges` and `sent` as for `group send` (`sent: false` while no edge took this edit, also while it waits for the pace); `--wait sent` and `--timeout` as for `group send`. The text the message already has is no edit: `sent: false, unchanged: true`. A private group's members whose edge is down get it when it opens, a community's with the catch-up; a member on an older app keeps the old text |
|
|
@@ -163,17 +163,17 @@ The rows are in alphabetical order of their first command, and every command of
|
|
|
163
163
|
| `profile picture <jpeg> \| --clear` | The picture contacts see (a JPEG within 512 px; 128 px is what the app sends) |
|
|
164
164
|
| `profile show`, `profile set [--name <name>] [--share-profile \| --no-share-profile]` | The name contacts see |
|
|
165
165
|
| `react <chat> <message> <emoji> [--remove] [--wait none\|confirmed] [--timeout s]` | React to a message with one emoji; a new one replaces yours, `--remove` takes it back. Without a daemon it stays until the contact confirmed it (`--wait confirmed`, the default there; `--timeout`, 30 s): a one-shot that left at once took the reaction along unsaid. `confirmed` says whether the contact has it |
|
|
166
|
-
| `routine send <chat\|group> --name <name> --schedule "every day 01:00" [--cron "0 1 * * *"] [--state active\|paused] [--next <time>] [--run ok\|failed\|skipped[:summary]] [--link url]… [--id id] [--text <text>] [--json json\|-\|file] [--force]`, `routine update <chat\|group> <routine> [fields…]` | A routine card for something a bot runs on a schedule (WISP 405 · Status Cards): its name, schedule (and cron line, shown only), state, last run and result, next run and up to 10 recent runs. `--run` records a run now as the last one; `--next` takes milliseconds or a date. Updates merge and are paced as `task update`'s, and wait as `task send` and `task update` do. The app shows it, and runs nothing |
|
|
166
|
+
| `routine send <chat\|group> --name <name> --schedule "every day 01:00" [--cron "0 1 * * *"] [--state active\|paused] [--next <time>] [--run ok\|failed\|skipped[:summary]] [--link url]… [--id id] [--text <text>] [--json json\|-\|file] [--force]`, `routine update <chat\|group> <routine> [fields…]` | A routine card for something a bot runs on a schedule (WISP 405 · Status Cards): its name, schedule (and cron line, shown only), state, last run and result, next run and up to 10 recent runs. `--run` records a run now as the last one; `--next` takes milliseconds or a date (no zone: local time, a bare `2026-09-30` local midnight; `Z` or `+02:00` as given). Updates merge and are paced as `task update`'s, and wait as `task send` and `task update` do. The app shows it, and runs nothing |
|
|
167
167
|
| `saved add\|remove <chat\|group> <message>`, `saved list` | Saved messages: mark a message of a chat or a group to find it again, kept for this profile on this device and never sent (the app shows the same list in its Saved view). `saved list` gives them the last saved first, each as it is now (an edit shows its latest text) with its `chat` or `group` and `savedAt`; a deleted message drops out |
|
|
168
168
|
| `send <chat> [text…] [--reply <message>] [--button id:Label]… [--style id=primary\|neutral\|danger]… [--once] [--id id] [--stdin] [--force] [--wait none\|sent\|delivered] [--timeout s]` | Send text (arguments, or stdin); `--reply` quotes a message of the chat. `--button yes:Yes` (1 to 6; the id ends at the first colon; no two labels alike ignoring case and spaces, and no label that is another button's id, else exit 2) puts buttons under the text, which is the question and what older apps show, so say how to answer in words. `--once`: one answer a person. A question that goes on the DHT floor or into a hold (the contact's app closed) reaches them as text alone; the engine sends its buttons again once the chat is live, as an edit of the buttons alone (no `message.edited` for it). The answer adds `buttons` (the question's id, `ask-…` unless `--id`), `card`, and `pressable`: whether the contact's app shows buttons (null until it says). A press comes back as `button.pressed` ([Events](#events)) |
|
|
169
169
|
| `service add <name> <http://127.0.0.1:port>`, `service share <service> <chat> [--off]`, `service list`, `service remove\|enable` | Share a web app on this machine, per contact. `service add` answers the new one as `service` (the id the others take); its old key `serviceId` stays beside it for one release |
|
|
170
170
|
| `service peer <chat>`, `service open <chat> <service> [--port p]`, `service close <chat> <service>` | A contact's app on a loopback port here (daemon). `url` is a link for your browser, `http://<random>.localhost:<port>/.ghostly-open/<token>`: it sets the service's cookie and shows the app on a host name of its own; any other host name, or a request without that cookie, gets 404. Chrome, Edge and curl reach `*.localhost` names by themselves; Safari and Node's `fetch` on macOS may not (add the name to `/etc/hosts` for them) |
|
|
171
|
-
| `settings get [--show-secret]`, `settings set <key> <json>` | Relays, Iroh relays, the HyperDHT relay, ICE servers, `sendTyping` (false: contacts are never told you type), … |
|
|
171
|
+
| `settings get [--show-secret]`, `settings set <key> <json>` | Relays, Iroh relays, the HyperDHT relay, ICE servers, `sendTyping` (false: contacts are never told you type), … `<json>` as `-`, or none on a pipe, is read from stdin: a TURN password stays out of `ps` |
|
|
172
172
|
| `status` | The profile, its chats, whether WebRTC and calls run, the last event seq |
|
|
173
173
|
| `store sign <index> --key <file> [--out <dir>]` | Sign a store index (WISP 1200 · Stores) with the store key file (kept offline; made when missing, the index names no `key` and no signed index is in the output folder): writes `ghostly-store.json`, canonical, and `ghostly-store.sig` beside the index or in `--out`. Refused, with the reason, when a client would refuse the index (`expires` more than 90 days ahead, a bad field), or when the index already there has a higher `sequence` (`rollback`), the same one with other content (`equivocation`), or is signed by another key (`store-key`: another store is another `--out`) |
|
|
174
174
|
| `task send <chat\|group> --title <title> [--status s] [--progress n \| --steps a/b] [--step "…"] [--item state:text]… [--pr-url url --pr-number n --additions n --deletions n --files n --pr-state s --pr-checks c] [--branch b] [--tag label]… [--parent task] [--link url]… [--id id] [--text <text>] [--json json\|-\|file] [--force]`, `task update <chat\|group> <task> [fields…]` | A task card for a bot's work (WISP 405 · Status Cards): a title, a status (queued, running, blocked, done, failed, cancelled), progress, the step it is on, up to 20 steps or log lines (`--item done:Codec`; the card holds at most 8 KiB in all, so 20 long items of non-Latin text are past it; a lowercase word before the colon must be an item state: pending, running, done, failed or skipped) and its pull request, shown as a small card that apps without cards read as text. Optional, and ignored by apps from before them: where the pull request stands (`--pr-state draft`, `open`, `merged` or `closed`; an open one puts the task in the board's Review column) and its checks (`--pr-checks passing`, `failing` or `pending`), up to 3 tags of 24 characters (`--tag core --tag web`; an update's tags replace the card's), and `--parent <task>`, a task of yours in the same chat that this one is a part of (sent first; its parts stack under it on the board). `send` prints the task's id and message; `update` merges the fields given over the card (an update's `--item` list replaces the card's: give all of them) and edits its message, at most once per 2.5 s (sooner updates merge into the next). `--json` takes the whole card; `null` in it removes a field. Without a daemon a card in a chat stays until it went out: `send` until it is sent (`--wait sent`), `update` until the contact confirmed it (`--wait confirmed`), up to `--timeout` (30 s, then exit 4: it goes with the next command); `--wait none` answers at once, as a daemon and a group do by default. Only the CLI sends cards: the app shows them |
|
|
175
175
|
| `typing <chat> [--kind typing\|recording\|thinking] [--status "<text>"] [--for s] [--stop]` | Show the contact you are writing, recording or thinking, or a short status line in its place ("Transcribing your audio…", 40 characters, no links): live chats only, it holds 6 s there; `--for s` keeps it on that long (up to 600 s; a one-shot stays that long once the chat is live, and stops with `live: false` when it is not live within 15 s); a new kind or status shows at once; a message to the chat or `--stop` ends it |
|
|
176
|
-
| `usage send [<chat\|group>] [--all] --left <percent> [--window "5 h"] [--resets <time>] [--label Claude] [--account <name>] [--also week=80@<time>]… [--used n --limit n] [--id id] [--text <text>] [--json json\|-\|file] [--force]` | How much of a quota the bot has left (WISP 405 § Usage): the percent (or `--used` of `--limit`), what it is of, the account, the window, when it resets, and up to 3 other windows (`--also week=80@2026-10-10T00:00:00Z`). The app shows a small meter on the chat's row and in its header, amber under 20%, red under 5%, muted once 6 h old or past the reset. One card per chat: the first report sends it, later ones edit it in place (quiet, paced as `task update`'s); each report is whole, so a field it leaves out goes. Without a daemon a report in a chat stays until it went out (`--wait sent`: the first sent, a later one confirmed by the contact), up to `--timeout`; `--wait none` answers at once. `--all` reports to every 1:1 chat with a contact. See [docs/AI-AGENTS.md](../../docs/AI-AGENTS.md#reporting-usage) for where a bot gets its numbers |
|
|
176
|
+
| `usage send [<chat\|group>] [--all] --left <percent> [--window "5 h"] [--resets <time>] [--label Claude] [--account <name>] [--also week=80@<time>]… [--used n --limit n] [--id id] [--text <text>] [--json json\|-\|file] [--force]` | How much of a quota the bot has left (WISP 405 § Usage): the percent (or `--used` of `--limit`), what it is of, the account, the window, when it resets, and up to 3 other windows (`--also week=80@2026-10-10T00:00:00Z`); `--resets` and `@` take milliseconds or a date (no zone: local time, a bare date local midnight). The app shows a small meter on the chat's row and in its header, amber under 20%, red under 5%, muted once 6 h old or past the reset. One card per chat: the first report sends it, later ones edit it in place (quiet, paced as `task update`'s); each report is whole, so a field it leaves out goes. Without a daemon a report in a chat stays until it went out (`--wait sent`: the first sent, a later one confirmed by the contact), up to `--timeout`; `--wait none` answers at once. `--all` reports to every 1:1 chat with a contact. See [docs/AI-AGENTS.md](../../docs/AI-AGENTS.md#reporting-usage) for where a bot gets its numbers |
|
|
177
177
|
| `version` | This CLI's version, `{"version":"…"}` (also `ghostly --version`) |
|
|
178
178
|
| `wallet create <type> [--network testnet] [--provider id] [--value name=value]… [--stdin] [--invite code] [--api-key key]` | A wallet: `cashu`, `lightning` (a card: its source's form in `--value`), `arkade`, `spark` (on Mainnet, `--api-key` is your Breez API key), `bitcoin` (BDK), `fedimint` (`--invite` is the federation's invite code), `usdt`. With `--stdin`, secret fields come as `name=value` lines on stdin (`api-key=…` too), out of `ps` and the shell's history; a `--value` the source's form marks secret (an NWC URI, a macaroon, a rune, an RPC password) is warned about |
|
|
179
179
|
| `wallet faucet <type>`, `wallet add-mint <url> [--primary]` | Test coins; another Cashu mint |
|
|
@@ -217,7 +217,7 @@ ghostly listen --type message.received --exec '
|
|
|
217
217
|
[ -n "$file" ] && ghostly file save "$file" --dir ./inbox --wait --timeout 120'
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
`file wait <file>` alone does the waiting: exit `0` when done, `1` with the error when it failed, `4` on timeout.
|
|
220
|
+
`file wait <file>` alone does the waiting: exit `0` when done, `1` with the error when it failed, `4` on timeout, `5` at once when the file waits for `file accept` (over 25 MiB).
|
|
221
221
|
|
|
222
222
|
### Staying off the direct link
|
|
223
223
|
|
|
@@ -309,7 +309,9 @@ chat (`chat list`, `chat show`, `chat rename`, …) and `engine getState` print
|
|
|
309
309
|
- A message's `from` is `me`, `peer`, or `system` for a group's own line in `group history` (`event`: created, joined,
|
|
310
310
|
renamed, …; the stream says it as `group.event`): nobody wrote it, whatever `member` key it carries.
|
|
311
311
|
- `seq` grows by one per event in the profile, across restarts; `id` is the same whenever the same fact is reported.
|
|
312
|
-
Dedupe by `id`; resume with `--since <seq>`, or let `--cursor <file>` remember the last event handled.
|
|
312
|
+
Dedupe by `id`; resume with `--since <seq>`, or let `--cursor <file>` remember the last event handled. A cursor
|
|
313
|
+
file that holds no event number (empty, edited by hand) is refused at start (`bad_request`, naming the file): fix or
|
|
314
|
+
remove it, or give `--since`.
|
|
313
315
|
- Types: `daemon.started`, `chat.created`, `chat.removed`, `chat.renamed`, `chat.pairing` (`stage`: publishing,
|
|
314
316
|
waiting, resolving, on-dht, live, …), `chat.connection` (`live`, `transport`), `typing.started` (with `kind` and, when given, `status`; again when either changes) and `typing.stopped` (the contact is writing, or stopped: a message, a stop, or 6 s of silence), `chat.joined` (the contact's app
|
|
315
317
|
announced itself; not a message), `chat.announced`, `message.received` (`message.nick`: the name the contact gave), `message.sent`, `message.delivery`
|
|
@@ -377,6 +379,8 @@ chat (`chat list`, `chat show`, `chat rename`, …) and `engine getState` print
|
|
|
377
379
|
apart, and the cursor stays before it until the bridge takes it. A 4xx or a redirect (not followed) passes the event
|
|
378
380
|
as not taken.
|
|
379
381
|
- With no daemon running, `listen` becomes the daemon (socket included), so a hook can answer with `ghostly send`.
|
|
382
|
+
`daemon stop` or `daemon restart` then ends that listen too: it exits 1 (`unavailable`) with a line on stderr, and
|
|
383
|
+
the stop's answer carries `listen: true`, as `daemon status` does while it runs. Start `ghostly daemon --detach` first for a listen that follows a restart.
|
|
380
384
|
- `--translate <lang>`: received messages carry a translation, once the CLI has a language detector ([Translation](#translation)).
|
|
381
385
|
|
|
382
386
|
As the app's chat screen does, the side that joined a chat says `👋 <name> joined` once it first goes live, and the
|
|
@@ -506,9 +510,10 @@ default route (seen with NordVPN on the same Mac as the CLI) makes the app send
|
|
|
506
510
|
nothing on that machine can answer: allow local network traffic in the VPN, or pause it.
|
|
507
511
|
|
|
508
512
|
**A TURN relay.** Calls use the apps' STUN servers, then the profile's own ICE servers:
|
|
509
|
-
|
|
510
|
-
same setting chats use).
|
|
511
|
-
|
|
513
|
+
`… | ghostly settings set iceServers -` with `[{"urls":"turn:turn.example.org:3478","username":"…","credential":"…"}]`
|
|
514
|
+
on stdin (the same setting chats use). On stdin, the password stays out of `ps` and the shell's history; given as an
|
|
515
|
+
argument it is still taken, with a warning. A relay connects the calls no direct path can: a VPN that takes every
|
|
516
|
+
packet through its tunnel, a NAT that maps each destination apart. The media stays encrypted end to end; the relay sees both
|
|
512
517
|
addresses and when and how much is sent. The CLI (libdatachannel) reaches TURN over UDP only: a `turns:` or
|
|
513
518
|
`?transport=tcp` address stays in the setting for the apps, which use it, and `settings set` warns that the CLI does
|
|
514
519
|
not. Behind a network that blocks UDP, the CLI has no relay. libdatachannel never gives a relay back when a call
|
package/SKILL.md
CHANGED
|
@@ -272,7 +272,8 @@ ghostly routine update owner nightly --state paused
|
|
|
272
272
|
```
|
|
273
273
|
|
|
274
274
|
`--schedule` is words people read (80 characters) and `--cron` is only shown. `--run ok|failed|skipped[:summary]`
|
|
275
|
-
records a run as the last one (the card keeps 10); `--next` takes a date or milliseconds, up to a year ahead
|
|
275
|
+
records a run as the last one (the card keeps 10); `--next` takes a date or milliseconds, up to a year ahead: `2026-10-01` and
|
|
276
|
+
`2026-10-01 01:00` are local time (a date alone is local midnight), `2026-10-01T01:00:00Z` or `+02:00` keep their zone.
|
|
276
277
|
|
|
277
278
|
### 11. Safety
|
|
278
279
|
|
|
@@ -296,8 +297,9 @@ records a run as the last one (the card keeps 10); `--next` takes a date or mill
|
|
|
296
297
|
|
|
297
298
|
- **No daemon, and `listen` takes the profile.** With no daemon running, `listen` opens the profile itself and serves
|
|
298
299
|
its socket, so it becomes the daemon: `daemon --detach` then fails ("A daemon already runs profile …"), and when
|
|
299
|
-
that listener stops, the profile goes offline with it.
|
|
300
|
-
|
|
300
|
+
that listener stops, the profile goes offline with it. `daemon stop` and `daemon restart` (the advice after an
|
|
301
|
+
upgrade) end such a listener: it exits 1 with a line on stderr, and the restarted daemon has no reader. Start
|
|
302
|
+
`ghostly daemon --detach` first, so `listen` only subscribes and follows a restart. Any other command with no daemon runs the profile for that one command and exits.
|
|
301
303
|
- **A headless session is not woken later.** An agent whose session ends (a `-p` run, a closed chat) hears nothing
|
|
302
304
|
when a message arrives. Keep a listener process running (`ghostly listen --turns … --exec`) under something that
|
|
303
305
|
outlives the session, and let it start the agent once per turn.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { c as findGroup, o as findChat } from "./apiKit-
|
|
2
|
-
import { a as hideStateSecrets, i as groupSendRefused, n as SETTABLE, o as mentionsFor, r as callApi, s as redactSettings, t as API_METHODS } from "./api-
|
|
1
|
+
import { c as findGroup, o as findChat } from "./apiKit-BtsHrnoo.js";
|
|
2
|
+
import { a as hideStateSecrets, i as groupSendRefused, n as SETTABLE, o as mentionsFor, r as callApi, s as redactSettings, t as API_METHODS } from "./api-D3i2hwy0.js";
|
|
3
3
|
export { API_METHODS, SETTABLE, callApi, findChat, findGroup, groupSendRefused, hideStateSecrets, mentionsFor, redactSettings };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { u as fileStore } from "./idb-
|
|
3
|
-
import { J as iceServerProblem, O as waitingGroupFile, T as removeStored, Y as iceServerSetting, i as groupOfFile, k as IDENTITY_DRAFT_TTL_MS, l as replyRef, n as groupFileId, v as paymentNetwork } from "./groupFiles-
|
|
4
|
-
import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-
|
|
5
|
-
import { t as IDENTITY_PROVIDERS } from "./registry-
|
|
6
|
-
import { a as waitForConfirmed, c as waitForMessage, i as pressable, l as waitForRemoval, n as buttonsCard, o as waitForEdit, s as waitForGroupFrame, t as BUTTON_METHODS, u as findSecret } from "./buttons-
|
|
7
|
-
import { a as WALLET_TYPES, c as DESTRUCTIVE_CALLS, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, m as engineParamsProblem, n as CHAT_METHODS, r as PAY_METHODS, s as withStoredIds, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-
|
|
8
|
-
import { i as localFileError, r as asCliError, t as CliError } from "./errors-
|
|
9
|
-
import { _ as oneOf, a as dhtOnly, b as str, c as findGroup, d as inviteTaken, f as list, g as num, h as node, i as chatOrGroup, n as bool, o as findChat, p as messageOf, r as chatOf, s as findChatOrGroup, u as groupOf, v as sentAt, x as
|
|
10
|
-
import { a as checkShownName } from "./profiles-
|
|
11
|
-
import { t as BACKUP_METHODS } from "./backup-
|
|
12
|
-
import { o as checkedBundle } from "./apps-
|
|
1
|
+
import { Cu as randomBytes$1, Eo as AWAITING_PEER_MS, Fr as TYPING_REFRESH_MS, Ga as replySnippet, Gc as appRef, Gi as identityStatement, Gn as GROUP_FILE_LIMITS, Io as LIMITS, Lc as isAppUrl, Lr as sanitizeTypingStatus, Mc as APP_PERMISSIONS, Mo as GhostlyHttpError, Po as parseLocalTarget, Pr as TYPING_KINDS, X as groupName, Yc as isAppRef, _a as parseVoiceMeta, _u as MAX_AVATAR_LENGTH, co as statusCardBytes, da as PLAYABLE_AUDIO, do as claimedTime, eo as STATUS_CARD_LIMITS, fa as VOICE_LIMITS, gl as inviteLink, ha as downsamplePeaks, io as cardLine, la as sanitizeFileName, ma as baseMime, nl as readImageMeta, no as appCardId, oo as checkStatusCard, pa as VOICE_METER, ri as APP_DATA_MAX_BYTES, ua as sanitizeMime, va as voiceDownloadName, vl as ownInviteRefusal, vu as sanitizeAvatar, wu as toBase64Url, ya as voiceLevel } from "./src-BB5-5P3s.js";
|
|
2
|
+
import { u as fileStore } from "./idb-BkOJES5_.js";
|
|
3
|
+
import { J as iceServerProblem, O as waitingGroupFile, T as removeStored, Y as iceServerSetting, i as groupOfFile, k as IDENTITY_DRAFT_TTL_MS, l as replyRef, n as groupFileId, v as paymentNetwork } from "./groupFiles-CBJIEvCE.js";
|
|
4
|
+
import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-DNgrRL0R.js";
|
|
5
|
+
import { t as IDENTITY_PROVIDERS } from "./registry-CeW8XEQc.js";
|
|
6
|
+
import { a as waitForConfirmed, c as waitForMessage, i as pressable, l as waitForRemoval, n as buttonsCard, o as waitForEdit, s as waitForGroupFrame, t as BUTTON_METHODS, u as findSecret } from "./buttons-CieBtXEO.js";
|
|
7
|
+
import { a as WALLET_TYPES, c as DESTRUCTIVE_CALLS, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, m as engineParamsProblem, n as CHAT_METHODS, r as PAY_METHODS, s as withStoredIds, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-BaumxjXe.js";
|
|
8
|
+
import { i as localFileError, r as asCliError, t as CliError } from "./errors-QUGP-jIF.js";
|
|
9
|
+
import { S as waitForState, _ as oneOf, a as dhtOnly, b as str, c as findGroup, d as inviteTaken, f as list, g as num, h as node, i as chatOrGroup, n as bool, o as findChat, p as messageOf, r as chatOf, s as findChatOrGroup, u as groupOf, v as sentAt, x as transportOffered, y as state } from "./apiKit-BtsHrnoo.js";
|
|
10
|
+
import { a as checkShownName } from "./profiles-DcCeOi7J.js";
|
|
11
|
+
import { t as BACKUP_METHODS } from "./backup-CxACdtQX.js";
|
|
12
|
+
import { o as checkedBundle } from "./apps-BHl97rHs.js";
|
|
13
13
|
import { generateMnemonic } from "@scure/bip39";
|
|
14
14
|
import { wordlist } from "@scure/bip39/wordlists/english.js";
|
|
15
15
|
import { openAsBlob, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
16
|
-
import { access, constants as constants$1, open, readFile, rm, stat } from "node:fs/promises";
|
|
16
|
+
import { access, constants as constants$1, copyFile, link, open, readFile, rename, rm, stat } from "node:fs/promises";
|
|
17
17
|
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
18
18
|
import { spawn } from "node:child_process";
|
|
19
19
|
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
@@ -749,6 +749,8 @@ function filesOf(messages, transferOf) {
|
|
|
749
749
|
transfer: transferOf(m.file.id) ?? null
|
|
750
750
|
}));
|
|
751
751
|
}
|
|
752
|
+
/** A file's size as a person reads it: "40 MB", "26.2 MB". */
|
|
753
|
+
var megabytes = (size) => `${Math.round(size / 1e5) / 10} MB`;
|
|
752
754
|
/** The chat or the group a file command names (`findChatOrGroup`). */
|
|
753
755
|
var chatOrGroupOf = (ctx, params) => findChatOrGroup(state(ctx).links, state(ctx).groups, str(params, "chat", true));
|
|
754
756
|
/**
|
|
@@ -904,6 +906,24 @@ function saveName(name) {
|
|
|
904
906
|
const clean = sanitizeFileName(name);
|
|
905
907
|
return fitName(clean.startsWith("-") ? `_${clean}` : clean);
|
|
906
908
|
}
|
|
909
|
+
/**
|
|
910
|
+
* Gives the whole file at `partial` the name `target`: over a file there when `force`, else never (EEXIST). Where the
|
|
911
|
+
* file system has no hard links (exFAT, some network shares), it is copied under the name, still never over a file.
|
|
912
|
+
*/
|
|
913
|
+
async function place(partial, target, force) {
|
|
914
|
+
if (force) return rename(partial, target);
|
|
915
|
+
try {
|
|
916
|
+
await link(partial, target);
|
|
917
|
+
} catch (error) {
|
|
918
|
+
if (![
|
|
919
|
+
"EPERM",
|
|
920
|
+
"ENOTSUP",
|
|
921
|
+
"EOPNOTSUPP",
|
|
922
|
+
"ENOSYS"
|
|
923
|
+
].includes(error.code ?? "")) throw error;
|
|
924
|
+
await copyFile(partial, target, constants$1.COPYFILE_EXCL);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
907
927
|
var ACTIONS = [
|
|
908
928
|
"accept",
|
|
909
929
|
"decline",
|
|
@@ -1059,7 +1079,13 @@ var FILE_METHODS = {
|
|
|
1059
1079
|
const transfer = state(ctx).transfers[fileId];
|
|
1060
1080
|
if (!transfer || transfer.state === "done") throw new CliError("refused", outgoing ? "Nothing to send again: it arrived whole" : "Nothing to ask for: the file is all here");
|
|
1061
1081
|
if (transfer.state === "failed" && (!outgoing || !transfer.retry)) throw new CliError("refused", `It ended: ${transfer.error ?? "failed"}`);
|
|
1062
|
-
} else
|
|
1082
|
+
} else {
|
|
1083
|
+
const outgoing = fileId.startsWith(`${linkId}-out-`);
|
|
1084
|
+
if (outgoing && (action === "accept" || action === "decline")) throw new CliError("bad_request", "A file sent from here is not accepted or declined: file cancel stops it");
|
|
1085
|
+
await refuseAllHere();
|
|
1086
|
+
const transfer = state(ctx).transfers[fileId] ?? (await fileStore.get(fileId).catch(() => void 0))?.transfer;
|
|
1087
|
+
if (transfer?.state === "failed") throw new CliError("refused", `It ended: ${transfer.error ?? "failed"}${outgoing && transfer.retry ? " (file resend sends it again)" : ""}`);
|
|
1088
|
+
}
|
|
1063
1089
|
await node(ctx).fileAction({
|
|
1064
1090
|
linkId,
|
|
1065
1091
|
fileId,
|
|
@@ -1087,7 +1113,7 @@ var FILE_METHODS = {
|
|
|
1087
1113
|
}) * 1e3;
|
|
1088
1114
|
const transfer = await waitForState(ctx, (s) => {
|
|
1089
1115
|
const now = s.transfers[fileId] ?? stored?.transfer;
|
|
1090
|
-
return now && (now.state === "done" || now.state === "failed") ? now : void 0;
|
|
1116
|
+
return now && (now.state === "done" || now.state === "failed" || now.stage === "asking" && now.direction === "in") ? now : void 0;
|
|
1091
1117
|
}, ms, `file ${fileId} to arrive`).catch((error) => {
|
|
1092
1118
|
const now = state(ctx).transfers[fileId];
|
|
1093
1119
|
if (error instanceof CliError && error.code === "timeout" && now) throw new CliError("timeout", `${error.message} (${now.transferred} of ${now.size} bytes${now.stage ? `, ${now.stage}` : ""})`, {
|
|
@@ -1103,6 +1129,15 @@ var FILE_METHODS = {
|
|
|
1103
1129
|
...where,
|
|
1104
1130
|
retry: !!transfer.retry
|
|
1105
1131
|
});
|
|
1132
|
+
if (transfer.state !== "done") {
|
|
1133
|
+
const name = (stored ?? await fileStore.get(fileId).catch(() => void 0))?.metadata?.name ?? "The file";
|
|
1134
|
+
throw new CliError("confirm", `${name} (${megabytes(transfer.size)}) waits for you to take it: ghostly file accept ${fileId} (or file decline)`, {
|
|
1135
|
+
file: fileId,
|
|
1136
|
+
...where,
|
|
1137
|
+
size: transfer.size,
|
|
1138
|
+
stage: "asking"
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1106
1141
|
return {
|
|
1107
1142
|
...where,
|
|
1108
1143
|
file: fileId,
|
|
@@ -1126,22 +1161,28 @@ var FILE_METHODS = {
|
|
|
1126
1161
|
if (!stored?.metadata) throw new CliError("not_found", `No file ${fileId}`);
|
|
1127
1162
|
if (stored.leftOut) throw new CliError("not_found", "Not in this backup: the light backup this profile was restored from left the file out");
|
|
1128
1163
|
const transfer = stored.direction === "out" ? void 0 : state(ctx).transfers[fileId] ?? stored.transfer;
|
|
1164
|
+
if (transfer?.state === "failed") throw new CliError("refused", `It ended: ${transfer.error ?? "failed"}`);
|
|
1129
1165
|
if (transfer && transfer.state !== "done") throw new CliError("unavailable", `The file is not all here yet (${transfer.transferred} of ${transfer.size} bytes)`);
|
|
1130
1166
|
const named = str(params, "path") ? resolve(str(params, "path", true)) : join(resolve(str(params, "dir") ?? "."), saveName(stored.metadata.voice ? voiceDownloadName(stored.metadata.mime, await voiceTime(ctx, stored)) : stored.metadata.name));
|
|
1131
1167
|
const force = bool(params, "force");
|
|
1132
1168
|
const free = !force && !str(params, "path") && !!stored.metadata.voice;
|
|
1133
1169
|
const ext = extname(named), stem = named.slice(0, named.length - ext.length);
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1170
|
+
const taken = async (target, code) => {
|
|
1171
|
+
const there = await stat(target).catch(() => void 0);
|
|
1172
|
+
if (there?.isDirectory()) return new CliError("bad_request", `${target} is a folder: name a file, or use --dir ${target} (dir over the socket)`);
|
|
1173
|
+
if (there && !force || code === "EEXIST") return new CliError("confirm", `${target} exists: pass --force (force: true over the socket) to replace it`);
|
|
1174
|
+
};
|
|
1175
|
+
let target = named;
|
|
1176
|
+
for (let n = 2, refused = await taken(target); refused; n += 1, refused = await taken(target)) {
|
|
1177
|
+
if (!free || refused.code !== "confirm" || n > 1e3) throw refused;
|
|
1178
|
+
target = `${stem} (${n})${ext}`;
|
|
1179
|
+
}
|
|
1180
|
+
const partial = join(dirname(target), `.ghostly-save-${process.pid}-${toBase64Url(randomBytes$1(6))}.partial`);
|
|
1181
|
+
let out;
|
|
1182
|
+
try {
|
|
1183
|
+
out = await open(partial, "wx", 384);
|
|
1137
1184
|
} catch (error) {
|
|
1138
1185
|
const code = error.code;
|
|
1139
|
-
if (free && code === "EEXIST" && n <= 1e3) {
|
|
1140
|
-
target = `${stem} (${n})${ext}`;
|
|
1141
|
-
continue;
|
|
1142
|
-
}
|
|
1143
|
-
if ((code === "EEXIST" || code === "EISDIR") && (await stat(target).catch(() => void 0))?.isDirectory()) throw new CliError("bad_request", `${target} is a folder: name a file, or use dir (--dir ${target})`);
|
|
1144
|
-
if (code === "EEXIST") throw new CliError("confirm", `${target} exists: pass force (--force) to replace it`);
|
|
1145
1186
|
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
1146
1187
|
const folder = dirname(target), there = await stat(folder).catch(() => void 0);
|
|
1147
1188
|
if (!there) throw new CliError("not_found", `No such file or folder: ${folder}`);
|
|
@@ -1165,10 +1206,23 @@ var FILE_METHODS = {
|
|
|
1165
1206
|
await out.write(chunk);
|
|
1166
1207
|
written = chunk.length;
|
|
1167
1208
|
} else throw new CliError("not_found", "The file's bytes are not on this device");
|
|
1168
|
-
complete = true;
|
|
1169
|
-
} finally {
|
|
1170
1209
|
await out.close();
|
|
1171
|
-
|
|
1210
|
+
out = null;
|
|
1211
|
+
for (let n = 2; !complete; n += 1) try {
|
|
1212
|
+
await place(partial, target, force);
|
|
1213
|
+
complete = true;
|
|
1214
|
+
} catch (error) {
|
|
1215
|
+
const code = error.code;
|
|
1216
|
+
const refused = code === "EEXIST" || code === "EISDIR" || code === "ENOTEMPTY" ? await taken(target, code) : void 0;
|
|
1217
|
+
if (free && refused?.code === "confirm" && n <= 1e3) {
|
|
1218
|
+
target = `${stem} (${n})${ext}`;
|
|
1219
|
+
continue;
|
|
1220
|
+
}
|
|
1221
|
+
throw refused ?? error;
|
|
1222
|
+
}
|
|
1223
|
+
} finally {
|
|
1224
|
+
await out?.close();
|
|
1225
|
+
await rm(partial, { force: true });
|
|
1172
1226
|
}
|
|
1173
1227
|
return {
|
|
1174
1228
|
file: fileId,
|
|
@@ -2438,7 +2492,10 @@ var nodeLocalFetch = async (request) => {
|
|
|
2438
2492
|
})() : null
|
|
2439
2493
|
};
|
|
2440
2494
|
};
|
|
2441
|
-
/**
|
|
2495
|
+
/**
|
|
2496
|
+
* Contact services open on loopback ports, by `<peer>/<service>`, while this process runs: each as soon as it starts
|
|
2497
|
+
* opening, so a second `service open` meanwhile answers the same one. A server that could not open is taken out.
|
|
2498
|
+
*/
|
|
2442
2499
|
var open$1 = /* @__PURE__ */ new Map();
|
|
2443
2500
|
var MAX_RESPONSE_BYTES = 33554432;
|
|
2444
2501
|
/** Cookie names an opened service may set and have passed back (browsers keep about 180 per host). */
|
|
@@ -2713,7 +2770,7 @@ var SERVICE_METHODS = {
|
|
|
2713
2770
|
max: 65535,
|
|
2714
2771
|
whole: true
|
|
2715
2772
|
});
|
|
2716
|
-
const already = open$1.get(key);
|
|
2773
|
+
const already = await open$1.get(key)?.catch(() => void 0);
|
|
2717
2774
|
if (already) {
|
|
2718
2775
|
const on = already.server.address().port;
|
|
2719
2776
|
if (port && port !== on) throw new CliError("busy", `That service is open here on port ${on}: ghostly service close ${link.id} ${service} first, or leave out --port`);
|
|
@@ -2725,10 +2782,13 @@ var SERVICE_METHODS = {
|
|
|
2725
2782
|
}
|
|
2726
2783
|
if (!link.peerServices?.some((s) => s.id === service)) throw new CliError("not_found", `The contact shares no service ${service} (or is not live)`);
|
|
2727
2784
|
const peer = link.peerPubKeyZ32;
|
|
2728
|
-
|
|
2785
|
+
if (open$1.has(key)) return SERVICE_METHODS["service.open"](ctx, params);
|
|
2786
|
+
const opening = openServiceServer((request) => node(ctx).request(peer, service, request), port).catch((error) => {
|
|
2787
|
+
if (open$1.get(key) === opening) open$1.delete(key);
|
|
2729
2788
|
throw portError(error, port);
|
|
2730
2789
|
});
|
|
2731
|
-
open$1.set(key,
|
|
2790
|
+
open$1.set(key, opening);
|
|
2791
|
+
const opened = await opening;
|
|
2732
2792
|
return {
|
|
2733
2793
|
chat: link.id,
|
|
2734
2794
|
service,
|
|
@@ -2737,9 +2797,10 @@ var SERVICE_METHODS = {
|
|
|
2737
2797
|
},
|
|
2738
2798
|
async "service.close"(ctx, params) {
|
|
2739
2799
|
const key = `${chatOf(ctx, params).peerPubKeyZ32}/${str(params, "service", true)}`;
|
|
2740
|
-
const
|
|
2741
|
-
if (!entry) throw new CliError("not_found", "That service is not open here");
|
|
2800
|
+
const pending = open$1.get(key);
|
|
2742
2801
|
open$1.delete(key);
|
|
2802
|
+
const entry = await pending?.catch(() => void 0);
|
|
2803
|
+
if (!entry) throw new CliError("not_found", "That service is not open here");
|
|
2743
2804
|
await new Promise((resolve) => {
|
|
2744
2805
|
entry.server.close(() => resolve());
|
|
2745
2806
|
entry.server.closeAllConnections();
|
|
@@ -3233,6 +3294,18 @@ var WALLET_REFUSALS = [
|
|
|
3233
3294
|
[/^The faucet did not pay: This wallet has no test mint\b/, "unavailable"],
|
|
3234
3295
|
[/^Ghostly cannot ask this wallet's faucet by itself\b/, "unavailable"]
|
|
3235
3296
|
];
|
|
3297
|
+
/**
|
|
3298
|
+
* `chat pay` or `chat request` refused for want of a Cashu wallet of that network at all: the engine says the wallet
|
|
3299
|
+
* is short of sats, or that no mint could make an invoice, and names nothing to do. `refused` with the command that
|
|
3300
|
+
* makes one, as a contact with no wallet is told; `details.reason` `no_wallet`. With a wallet, the engine's own words.
|
|
3301
|
+
*/
|
|
3302
|
+
function noWalletOf(ctx, n, error) {
|
|
3303
|
+
if ((state(ctx).wallet.wallets ?? []).some((w) => w.type === "cashu" && w.network === n)) return error;
|
|
3304
|
+
return new CliError("refused", `You have no ${n === "mainnet" ? "Mainnet" : "Testnet"} Cashu wallet: ghostly wallet create cashu${n === "mainnet" ? " --network mainnet" : ""}`, { reason: "no_wallet" });
|
|
3305
|
+
}
|
|
3306
|
+
var engineCode = (error) => error instanceof Error ? error.engineCode : void 0;
|
|
3307
|
+
/** What the engine says to a Cashu request it has no mint for: no mint for the invoice, or none to name for ecash. */
|
|
3308
|
+
var NO_MINT = /^(No mint could create an invoice: No mint configured|You have no (Mainnet|Testnet) Cashu wallet: create one in Wallet → New)$/;
|
|
3236
3309
|
function walletRefusal(error) {
|
|
3237
3310
|
if (!(error instanceof Error) || error instanceof CliError) return error;
|
|
3238
3311
|
const code = WALLET_REFUSALS.find(([pattern]) => pattern.test(error.message))?.[1];
|
|
@@ -3475,6 +3548,8 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
3475
3548
|
network: n,
|
|
3476
3549
|
...memo ? { memo } : {},
|
|
3477
3550
|
...real(params)
|
|
3551
|
+
}).catch((error) => {
|
|
3552
|
+
throw engineCode(error) === "notEnoughSats" ? noWalletOf(ctx, n, error) : error;
|
|
3478
3553
|
});
|
|
3479
3554
|
return {
|
|
3480
3555
|
chat: link.id,
|
|
@@ -3490,15 +3565,18 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
3490
3565
|
const method = params.method === void 0 ? void 0 : oneOf(params, "method", PAY_METHODS, "cashu");
|
|
3491
3566
|
const rail = params.rail === void 0 ? void 0 : oneOf(params, "rail", ["cashu", "lightning"], "cashu");
|
|
3492
3567
|
await federationsOpen(ctx);
|
|
3568
|
+
const n = network(params);
|
|
3493
3569
|
const { paymentId } = await node(ctx).requestPayment({
|
|
3494
3570
|
linkId: link.id,
|
|
3495
3571
|
amount,
|
|
3496
3572
|
timestamp: sentAt(),
|
|
3497
|
-
network:
|
|
3573
|
+
network: n,
|
|
3498
3574
|
...memo ? { memo } : {},
|
|
3499
3575
|
...method ? { method } : {},
|
|
3500
3576
|
...rail ? { rail } : {},
|
|
3501
3577
|
...str(params, "card") ? { card: str(params, "card") } : {}
|
|
3578
|
+
}).catch((error) => {
|
|
3579
|
+
throw (!method || method === "cashu") && error instanceof Error && NO_MINT.test(error.message) ? noWalletOf(ctx, n, error) : error;
|
|
3502
3580
|
});
|
|
3503
3581
|
return {
|
|
3504
3582
|
chat: link.id,
|
|
@@ -3714,7 +3792,8 @@ var inviteShown = /* @__PURE__ */ new WeakMap();
|
|
|
3714
3792
|
/**
|
|
3715
3793
|
* Refuses DHT only (a hold, `chat transport dht`) while a call is on in the chat. A call's signals cross the live
|
|
3716
3794
|
* link: off it, the call talked on over its own connection, and a hang-up from either side never reached the other
|
|
3717
|
-
* (that call ended only when its media stalled out, 16 s later).
|
|
3795
|
+
* (that call ended only when its media stalled out, 16 s later). Removing the chat (`chat remove`) is refused the same
|
|
3796
|
+
* way: the call talked on in a chat gone from this device, and its hang-up had no chat left to cross.
|
|
3718
3797
|
*/
|
|
3719
3798
|
function noCallOn(ctx, linkId, then) {
|
|
3720
3799
|
const call = ctx.calls.list().find((c) => c.chat === linkId);
|
|
@@ -3784,7 +3863,8 @@ var METHODS = {
|
|
|
3784
3863
|
protocol: s.transport.protocol,
|
|
3785
3864
|
relays: s.transport.relays
|
|
3786
3865
|
},
|
|
3787
|
-
events: { lastSeq: ctx.hub.lastSeq }
|
|
3866
|
+
events: { lastSeq: ctx.hub.lastSeq },
|
|
3867
|
+
...ctx.listen && { listen: true }
|
|
3788
3868
|
};
|
|
3789
3869
|
},
|
|
3790
3870
|
async "profile.get"(ctx) {
|
|
@@ -4255,8 +4335,10 @@ var METHODS = {
|
|
|
4255
4335
|
},
|
|
4256
4336
|
async "chat.remove"(ctx, params) {
|
|
4257
4337
|
const link = chatNotGroup(ctx, params, "group forget", "--yes");
|
|
4258
|
-
if (!bool(params, "yes")) throw new CliError("confirm", "Removing a chat deletes its keys and history on this device; pass yes (
|
|
4338
|
+
if (!bool(params, "yes")) throw new CliError("confirm", "Removing a chat deletes its keys and history on this device; pass --yes (yes: true over the socket) to go on");
|
|
4339
|
+
noCallOn(ctx, link.id, "remove the chat");
|
|
4259
4340
|
await node(ctx).removeLink({ linkId: link.id });
|
|
4341
|
+
ctx.calls.forgetChat(link.id);
|
|
4260
4342
|
return { removed: link.id };
|
|
4261
4343
|
},
|
|
4262
4344
|
async "chat.transport"(ctx, params) {
|
|
@@ -4265,6 +4347,7 @@ var METHODS = {
|
|
|
4265
4347
|
const transport = Object.hasOwn(TRANSPORT_NAMES, name) ? TRANSPORT_NAMES[name] : void 0;
|
|
4266
4348
|
if (!transport) throw new CliError("bad_request", `transport must be one of auto, dht, webrtc, iroh, hyperdht`);
|
|
4267
4349
|
if (transport === "dht") noCallOn(ctx, link.id, "put the chat on DHT only");
|
|
4350
|
+
else if (transport !== "auto") transportOffered(link, transport);
|
|
4268
4351
|
await node(ctx).setChatTransport({
|
|
4269
4352
|
linkId: link.id,
|
|
4270
4353
|
transport
|
|
@@ -4487,7 +4570,7 @@ var METHODS = {
|
|
|
4487
4570
|
max: 600
|
|
4488
4571
|
});
|
|
4489
4572
|
if (!typing && seconds) throw new CliError("bad_request", "for keeps typing on: not with stop");
|
|
4490
|
-
if (typing && group.status !== "active") throw new CliError("
|
|
4573
|
+
if (typing && group.status !== "active") throw new CliError("refused", group.statusReason ?? "You are not in this group");
|
|
4491
4574
|
const target = { groupId: group.id };
|
|
4492
4575
|
endTyping(ctx, target, false);
|
|
4493
4576
|
sayTyping(ctx, target, typing, word);
|
|
@@ -4507,7 +4590,7 @@ var METHODS = {
|
|
|
4507
4590
|
},
|
|
4508
4591
|
async "group.leave"(ctx, params) {
|
|
4509
4592
|
const group = groupOf(ctx, params);
|
|
4510
|
-
if (!bool(params, "yes")) throw new CliError("confirm", "Leaving a group deletes its history and files on this device; pass yes (
|
|
4593
|
+
if (!bool(params, "yes")) throw new CliError("confirm", "Leaving a group deletes its history and files on this device; pass --yes (yes: true over the socket) to go on");
|
|
4511
4594
|
const { admin } = await node(ctx).leaveGroup({ groupId: group.id });
|
|
4512
4595
|
const next = admin ? group.members.find((m) => m.key === admin) : void 0;
|
|
4513
4596
|
return {
|
|
@@ -4520,7 +4603,7 @@ var METHODS = {
|
|
|
4520
4603
|
},
|
|
4521
4604
|
async "group.forget"(ctx, params) {
|
|
4522
4605
|
const group = groupOf(ctx, params, "chat remove <chat> --yes");
|
|
4523
|
-
if (!bool(params, "yes")) throw new CliError("confirm", "Forgetting a group deletes its history on this device; pass yes (
|
|
4606
|
+
if (!bool(params, "yes")) throw new CliError("confirm", "Forgetting a group deletes its history on this device; pass --yes (yes: true over the socket) to go on");
|
|
4524
4607
|
await node(ctx).forgetGroup({ groupId: group.id });
|
|
4525
4608
|
return { forgotten: group.id };
|
|
4526
4609
|
},
|
|
@@ -4545,7 +4628,8 @@ var METHODS = {
|
|
|
4545
4628
|
setTimeout(() => ctx.stop(), 10);
|
|
4546
4629
|
return {
|
|
4547
4630
|
stopping: true,
|
|
4548
|
-
pid: process.pid
|
|
4631
|
+
pid: process.pid,
|
|
4632
|
+
...ctx.listen && { listen: true }
|
|
4549
4633
|
};
|
|
4550
4634
|
},
|
|
4551
4635
|
async "engine.call"(ctx, params) {
|
|
@@ -4573,7 +4657,9 @@ var METHODS = {
|
|
|
4573
4657
|
const target = node(ctx)[method];
|
|
4574
4658
|
if (typeof target !== "function") throw new CliError("not_found", `The engine has no call ${method}`);
|
|
4575
4659
|
try {
|
|
4576
|
-
|
|
4660
|
+
const result = await target.call(node(ctx), args) ?? null;
|
|
4661
|
+
if (method === "removeLink") ctx.calls.forgetChat(str(args ?? {}, "linkId", true));
|
|
4662
|
+
return result;
|
|
4577
4663
|
} catch (error) {
|
|
4578
4664
|
if (error instanceof TypeError && BAD_VALUE.test(error.message)) throw wrong("a parameter of the wrong kind", error.message);
|
|
4579
4665
|
throw error;
|
|
@@ -4755,10 +4841,6 @@ async function connectWithin(ctx, link, ms) {
|
|
|
4755
4841
|
const shown = /^[\w.:-]+$/.test(link.label ?? "") ? link.label : link.id;
|
|
4756
4842
|
throw new CliError("timeout", `Timed out after ${Math.round(ms / 1e3)} s: the contact did not answer. ${ctx.mode === "one-shot" ? "Try again later, or keep this profile online with `ghostly daemon --detach`: it reconnects by itself" : `It reconnects by itself while this profile is online; ghostly chat wait ${shown} --until live waits for it`}`, { chat: link.id });
|
|
4757
4843
|
}
|
|
4758
|
-
/**
|
|
4759
|
-
* A page of a chat's or a group's history. Without `after` only that page is read from the store (the newest, or those
|
|
4760
|
-
* before `before`), so a long chat's is as quick as a short one's; with `after` the whole history is read and cut.
|
|
4761
|
-
*/
|
|
4762
4844
|
async function saveMark(ctx, params, remove) {
|
|
4763
4845
|
const target = chatOrGroup(ctx, str(params, "chat", true)), messageId = str(params, "message", true);
|
|
4764
4846
|
const result = await node(ctx).saveMessage({
|
|
@@ -4774,28 +4856,29 @@ async function saveMark(ctx, params, remove) {
|
|
|
4774
4856
|
saved: !remove
|
|
4775
4857
|
};
|
|
4776
4858
|
}
|
|
4859
|
+
/**
|
|
4860
|
+
* A page of a chat's or a group's history: only that page is read from the store (the newest, those before `before`,
|
|
4861
|
+
* or the oldest after `after`), so a long chat's is as quick as a short one's.
|
|
4862
|
+
*/
|
|
4777
4863
|
async function historyOf(ctx, chat, params, json = messageJson) {
|
|
4778
|
-
if (params.after !== void 0 && params.after !== null) {
|
|
4779
|
-
const whole = await node(ctx).getMessages(chat), { messages, more } = history(whole, params);
|
|
4780
|
-
const originals = await originalsNow(ctx, chat, messages, whole);
|
|
4781
|
-
return {
|
|
4782
|
-
messages: messages.map((m) => quoteChecked(json(m), m, originals)),
|
|
4783
|
-
more
|
|
4784
|
-
};
|
|
4785
|
-
}
|
|
4786
4864
|
const limit = num(params, "limit", 50, {
|
|
4787
4865
|
min: 1,
|
|
4788
4866
|
max: 1e4,
|
|
4789
4867
|
whole: true
|
|
4790
4868
|
});
|
|
4791
|
-
const
|
|
4792
|
-
|
|
4869
|
+
const bound = (side) => {
|
|
4870
|
+
const value = params[side] ?? void 0;
|
|
4871
|
+
if (value !== void 0 && typeof value !== "number" && typeof value !== "string") throw new CliError("bad_request", `${side} must be a timestamp or a message id`);
|
|
4872
|
+
return value;
|
|
4873
|
+
};
|
|
4874
|
+
const before = bound("before"), after = bound("after");
|
|
4793
4875
|
const page = await node(ctx).messagePage({
|
|
4794
4876
|
linkId: chat,
|
|
4795
4877
|
limit,
|
|
4796
|
-
before
|
|
4878
|
+
before,
|
|
4879
|
+
...after !== void 0 && { after }
|
|
4797
4880
|
}).catch((error) => {
|
|
4798
|
-
throw error instanceof Error && error.message === `No message ${
|
|
4881
|
+
throw error instanceof Error && [before, after].some((id) => error.message === `No message ${id}`) ? new CliError("not_found", error.message) : error;
|
|
4799
4882
|
});
|
|
4800
4883
|
const originals = await originalsNow(ctx, chat, page.messages);
|
|
4801
4884
|
return {
|
|
@@ -4847,31 +4930,6 @@ function quoteChecked(json, message, originals) {
|
|
|
4847
4930
|
}
|
|
4848
4931
|
};
|
|
4849
4932
|
}
|
|
4850
|
-
function history(messages, params) {
|
|
4851
|
-
const limit = num(params, "limit", 50, {
|
|
4852
|
-
min: 1,
|
|
4853
|
-
max: 1e4,
|
|
4854
|
-
whole: true
|
|
4855
|
-
});
|
|
4856
|
-
const before = params.before;
|
|
4857
|
-
const after = params.after;
|
|
4858
|
-
const sorted = messages.slice().sort((a, b) => a.timestamp - b.timestamp);
|
|
4859
|
-
const bound = (value, side) => {
|
|
4860
|
-
if (value === void 0 || value === null) return;
|
|
4861
|
-
if (typeof value === "number") return (m) => side === "before" ? m.timestamp < value : m.timestamp > value;
|
|
4862
|
-
if (typeof value !== "string") throw new CliError("bad_request", `${side} must be a timestamp or a message id`);
|
|
4863
|
-
const index = sorted.findIndex((m) => m.id === value);
|
|
4864
|
-
if (index === -1) throw new CliError("not_found", `No message ${value}`);
|
|
4865
|
-
return (_, at) => side === "before" ? at < index : at > index;
|
|
4866
|
-
};
|
|
4867
|
-
const bounds = [bound(before, "before"), bound(after, "after")].filter((b) => b !== void 0);
|
|
4868
|
-
const list = sorted.filter((m, at) => bounds.every((within) => within(m, at)));
|
|
4869
|
-
const more = after !== void 0 && after !== null ? list.length > limit : list.length > limit;
|
|
4870
|
-
return {
|
|
4871
|
-
messages: after !== void 0 && after !== null ? list.slice(0, limit) : list.slice(-limit),
|
|
4872
|
-
more
|
|
4873
|
-
};
|
|
4874
|
-
}
|
|
4875
4933
|
var API_METHODS = Object.keys(METHODS);
|
|
4876
4934
|
/** Runs one method of the API: one the table lists itself (`constructor`, which every object has, is none). */
|
|
4877
4935
|
async function callApi(ctx, method, params = {}) {
|
|
@@ -4883,4 +4941,4 @@ async function callApi(ctx, method, params = {}) {
|
|
|
4883
4941
|
//#endregion
|
|
4884
4942
|
export { flushCardUpdates as _, hideStateSecrets as a, paymentJson as c, nodeLocalFetch as d, chatJson as f, resumeHolds as g, groupMessageJson as h, groupSendRefused as i, reportAppFrames as l, groupJson as m, SETTABLE as n, mentionsFor as o, chatMessageJson as p, callApi as r, redactSettings as s, API_METHODS as t, servedApps as u };
|
|
4885
4943
|
|
|
4886
|
-
//# sourceMappingURL=api-
|
|
4944
|
+
//# sourceMappingURL=api-D3i2hwy0.js.map
|