@ghostlytools/cli
v1.13.7
Published
Ghostly for bots and terminals: the app's own engine, headless on Node, behind a daemon and a `ghostly` command with JSON output.
Readme
ghostly: Ghostly for bots and terminals
ghostly runs the Ghostly app's own engine without a screen: the same chats, groups and protocol as the web app,
the extension and the Desktop, on Node. A bot keeps a profile online with ghostly daemon, reads what happens with
ghostly listen (JSON lines), and acts with the other commands (JSON answers). The contract behind it, and why it
is built this way, is WISP 1100. A guided tour: docs/CLI.md.
Status: phases 1 to 5 (profiles, pictures and backups, invites, one chat, private and community groups with their admin tools and hubs, the event stream, hooks and agent turns, wallets and payments, files and voice notes, identity proofs, shared services, voice calls, typing, replies, edits, reactions and forwards, Pkarr over the Mainline DHT; the npm package
@ghostlytools/cli, published since 1.0); every engine call is already reachable throughghostly engine <method>. The older Rustghostly-cli, the client for v0.4 chats, was removed after 1.0.
Install
Install: npm install -g @ghostlytools/cli, then ghostly --version. Or from this repository:
npm install
npm run build -w @ghostlytools/cli
npm pack -w @ghostlytools/cli # ghostlytools-cli-<version>.tgz: the bundle, its WebAssembly, examples/, README and SKILL.md
npm install -g ./ghostlytools-cli-*.tgz # the `ghostly` command, with its dependencies from npm
ghostly --versionNode 22.12 or newer. WebRTC comes from node-datachannel (a native
module with prebuilt binaries for Linux, macOS and Windows); without it the CLI still runs, over HyperDHT, Iroh and
the DHT, and groups are unavailable.
Tested in CI on Linux x64 and Linux arm64 (glibc); developed on macOS arm64. macOS x64 and Windows x64 get the same prebuilt modules but no CI run.
The bundle holds the app's engine (@ghostly/browser, @ghostly/core, Iroh's and Breez's WebAssembly); every other
package it imports is a dependency in package.json, which test/packageDeps.test.ts keeps true.
Five minutes
On a private network or a local test, point the profile at your own Pkarr relays before its first daemon: a new
profile publishes its records within seconds of starting (Private networks).
ghostly profile set --name "Echo bot" # the name contacts see
ghostly daemon --detach # keep the profile online
ghostly invite create --label alice # {"chat":"…","invite":"ghostly1…","link":"https://ghostly.tools/#ghostly1…","published":true}
ghostly chat wait alice --until live # once Alice joined (in the app, or another ghostly)
ghostly send alice "hello" # {"chat":"…","messageId":"me_…","delivery":"sending"}
ghostly listen # one JSON event per line, until stoppedWith no relay answering, invite create still gives a good invite: don't make another. It answers "published":false
with a reason and a note (and retryInMs when the relays' request budget holds it back), and the invite goes out by
itself once a relay answers, while a daemon runs for the profile.
An echo bot (examples/echo-bot.sh; the event arrives on the command's stdin, never in its arguments, so a contact's text cannot reach the shell):
ghostly listen --type message.received --cursor "${GHOSTLY_HOME:-$HOME/.ghostly}/echo.cursor" --exec '
event="$(cat)"
printf "echo: %s" "$(printf "%s" "$event" | jq -r .message.text)" | ghostly send "$(printf "%s" "$event" | jq -r .chat)" --stdin'The cursor file keeps the last event handled, so a restarted bot goes on where it stopped; it sits in the Ghostly
folder in use. With another folder, set GHOSTLY_HOME rather than --home: the cursor's path above reads it. The
hook's own ghostly send runs on the folder and profile listen runs on, given as a flag or in the environment
(listen sets GHOSTLY_HOME and GHOSTLY_PROFILE for it). The example script takes
ECHO_CURSOR for the cursor's path (default echo.cursor in GHOSTLY_HOME, else ~/.ghostly); give each bot and
profile its own.
The same bot on the socket, without jq: examples/echo-bot.mjs. A payment bot that takes
requests, tips and "balance" in a chat, with test coins: examples/payment-bot.mjs.
A Claude Code agent on listen --turns with an allowlist (it will not start without one), "thinking" while it works
and send --reply for its answer: examples/claude-code-agent.sh.
Agents: skills/ghostly is a skill for an AI coding agent (Claude Code first) that talks to its
owner over Ghostly: listen, say (with buttons), status and react, in sh, and only the owner's chat gives it
orders.
Profiles
Each profile is a folder, ~/.ghostly/profiles/<name>/ (0700; files 0600), with its own chats, keys and wallets.
--profile <name> (or GHOSTLY_PROFILE) picks one; ghostly profile use <name> sets the current one;
--home <dir> (or GHOSTLY_HOME) moves the whole folder. The default profile is made on first use, others with
ghostly profile create <name>. An empty --profile or --home (-p "$BOT" with BOT unset) is a usage error;
an empty GHOSTLY_PROFILE or GHOSTLY_HOME counts as unset.
The keys (the identity seed, each wallet's seed) are not encrypted on disk: any program running as your user can read them. To keep them from an agent's tools, run Ghostly as an OS user of its own: threat model.
Only one process opens a profile at a time. When a daemon runs it, every command goes through the daemon's socket.
When none does, a command runs the profile itself for as long as it needs (a one-shot) and leaves: send then
waits until the message went out (to a chat nobody joined yet it answers at once: the message goes once they join).
Bots should run the daemon: a one-shot is offline between commands.
Commands
Every command prints one JSON object on stdout. A failure prints {"error":{"code","message"}} (on stderr for call pipe,
whose stdout is the call's audio) and exits with:
1 failed (the engine or the network refused), 2 usage, 3 not found, 4 timed out, 5 needs a confirmation
(--force, --yes, --confirm-real), 130 stopped with Ctrl-C (interrupted: a one-shot closes its profile first,
and a line on stderr says what became of what it waited on). A daemon that does not answer a read or daemon status within 15 seconds, or
a command that waits (chat wait, file wait, --wait) within its --timeout plus 10, is a timeout too (4,
details.method); ghostly daemon restart is the way out (docs/CLI.md). On a
terminal, a command that waits says on stderr what it waits for once it has waited a second; nothing is said there on
a pipe. A <chat> is
its id, a unique prefix of it, or its name; a <group> too, each also as group:<ref> (every group command and
every command that takes a chat or a group; listen --group takes only the group's id, as is or after group:). A <group> that is one group's name and a prefix of
another's id is refused (exit 1, bad_request, both ids in details.matches): use its id.
The rows are in alphabetical order of their first command, and every command of ghostly help has one
(test/readme.test.ts checks both).
| Command | What it does |
|---|---|
| app init <dir> [--name <name>] [--title <title>] [--force] | Start an app (WISP 1200, Apps), run here with no profile or daemon: a small working one in <dir> (made when missing), which app publish <dir> signs as it is. It writes ghostly-app.json (view: chat, the chat permission), an index.html that says hello to the same app on the contact's side, typed against @ghostlytools/sdk/app, and a README.md with build, publish, verify and how to list it in a store. The name is --name (a lowercase letter, then up to 31 lowercase letters, digits or hyphens), else the folder's (My App gives my-app); the title is --title (one line, up to 40 characters), else the name's. When one of the three files is there nothing is written and it is refused (details.reason exists, details.files), unless --force, which replaces those three only. Answers {dir, name, title, files, replaced?, next} |
| app open <chat> <ref\|name> [--no-card], app close <chat> <ref\|name> | A served app in a chat, as a bot (WISP 1200, Apps; needs the daemon, and app serve first). app open says the app is open on this side, in the version served, and sends the contact the app's card ("opened Chess", with what their app needs to get the same app and check it), unless their app is open in that chat already or --no-card. The two sides talk once both opened it; while the app stays open here, the engine says so again on every session that comes back. It answers {chat, app, version, card, peer, live}: card is the card's message id or null, peer the version the contact has open or null. A card that cannot go leaves nothing open. app close ends it: {chat, app, closed}. What is open is kept in memory: a restarted daemon opens again. unavailable in a one-shot, or on a daemon that started before the first app was served (daemon restart); not_found for an app not served; refused, in the engine's words, for a chat that is not a paired 1:1 chat |
| app publish <dir> --key <file> [--out <file>] [--sequence n], app verify <bundle\|url> | The publisher tools of WISP 1200 (Apps), run here with no profile or daemon. app publish bundles and signs an app: <dir>/ghostly-app.json holds the manifest's fields but publisher, sequence and files, and every other file in <dir> goes in (dot files are left out and listed in skipped). It writes <dir>/app.ghostlyapp (or --out), its sequence one more than the bundle already there, which only the same key may follow (--sequence n sets it, refused unless higher); a sequence that <dir>/ghostly-revoke.json or the one beside --out already revokes is refused (details.reason revoked, details.sequence the first one it leaves alone). --key names the publisher key file, a PKCS #8 PEM: made owner-only on first use (back it up: an app is updated only with its key), refused when others may read it or when it is inside <dir>, never printed; a folder holding any private key file is refused (details.reason private-key). app verify checks a bundle from a file or an https URL as a client does (jsDelivr only at a full commit, 16 MiB at most) and answers its manifest and digest, or refused (exit 1) with the WISP's reason in details.reason |
| app revoke <dir> --key <file> (--digest <digest>… \| --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force] | Revoke versions of your app (WISP 1200 · Revocation): by digest (base64url, as app verify prints it; --digest again for each, up to 64) or every version up to a sequence, with an optional reason of one line of 1 to 200 characters (a bad or repeated --digest, or an empty or longer --reason, is a usage error naming the option). Clients keep a revocation for good, so --up-to past the bundle's own sequence asks for --force (confirm, exit 5; versions published from elsewhere), and app publish refuses a sequence that list already stops, naming the --sequence that clears it. The statement names the app of <dir>/app.ghostlyapp (or --bundle), is signed with that app's publisher key (any other key is refused, and none is made here), and is added to the ghostly-revoke.json beside that bundle, where app verify, app serve and a client read it and stop those versions (publish it beside the bundle). Answers {app, digests \| upTo, current, added, revocations, file}; current says whether that bundle is among them, file the list written |
| app send <chat> <ref\|name> <json\|-> | One message of a served app's own protocol to the same app on the contact's side (WISP 1200, Apps; needs the daemon): any JSON value, on the command line or - for stdin, at most 32 KiB, at most 48 a second. It goes on the live session only, while both sides have the app open, and is never kept for later: {chat, app, sent: true}, or an error whose details.reason is the WISP's name for why it did not go: not-open (refused: app open first), too-large (bad_request), offline and peer-closed (unavailable: the chat is not live, or the contact's app is not open; wait for app.opened), too-fast (refused). The contact's messages come as app.message events |
| app serve <bundle\|url> --grant chat [--grant name] [--url <url>], app served, app unserve <ref\|name> | Serve an app as a bot (WISP 1200, Apps): the profile speaks the app's messages in its chats itself, and no app runs here. app serve reads the signed bundle from a file or an https URL and checks it as app verify does (refused with the WISP's reason in details.reason). Each permission the manifest asks needs its --grant: chat (talk to the same app on the contact's side) and name (the profile's name in that chat); one left out is confirm (exit 5), naming it in details.missing. internet cannot be granted (no page runs here), a permission the app does not ask is bad_request, and an app that does not ask for chat is refused. A newer version replaces the one served; an older one, or another bundle under the same sequence, is refused. It answers {served: {ref, title, version, sequence, digest, url?, permissions, granted, servedAt}, offered, restart?}; url is where a contact's app reads the bundle, on raw.githubusercontent.com or cdn.jsdelivr.net at a full commit: --url (any other link is bad_request), else the first of the URL served from and the manifest's sources that a contact's app reads from, and none when there is no such link. The list is kept in the profile's folder (apps.json), and a profile backup carries it to the restored copy. A profile's engine offers apps/1 to contacts only while it serves an app, and reads the list when it starts: offered says whether it does now, and restart: true that daemon restart is needed for the offer to follow the list (the first app served, or the last one unserved). app served answers {apps, offered, restart?}; app unserve removes one by its reference or its name and answers {unserved, apps, offered, restart?}, and on a daemon closes it in every chat it was open in (the contact hears close) |
| button press <chat\|group> <message> <button> [--wait none\|sent\|delivered] [--timeout s] | Press a button of someone else's question, as a tap in the app does (WISP 406 · Message Buttons): the reply carries the button's label, and the asker hears button.pressed. <message> is the question's id (its event or chat history), <button> a button's id from its card. Refused (exit 1) like a tap: closed buttons, a second answer past --once, a second press within a second. A one-shot in a chat waits until it went out, as send. Answers {chat \| group, messageId, button, label, replyId, delivery \| edges} |
| button update <chat\|group> <message> [--chosen <button>] [--close] [--text <text>] [--force] [--wait none\|confirmed\|sent] [--timeout s] | Answer a question you sent with send --button (WISP 406 · Message Buttons): --chosen shows which button won, --close takes presses no more, --text changes the text (shown as edited; refused if blank, or if it looks like a secret, unless --force); the buttons and, unless given, the text stay. <message> is the messageId send gave. Answers {chat \| group, buttons, messageId, card, edits} |
| call auto [on\|off] [--from <chat>]… [--rate n] | Answer calls by themselves, from anyone or the chats named (kept in the profile) |
| call hangup [<chat\|call>], call list, call flush [<chat\|call>] | Hang up (or decline); calls on now; drop the audio queued and not played yet |
| call pipe [<chat\|call>] | A call's audio on stdin and stdout, for shell pipelines (sox, ffmpeg) |
| call start <chat> [--rate 48000], call answer [<chat\|call>] [--rate n] | Voice calls (daemon): the result names the call's audio socket (Calls) |
| chat accept <chat> [<method> [--off] [--networks mainnet,testnet]] | Which ways of paying the chat takes (no method: the ones it takes now, per network) |
| chat connect <chat>, chat disconnect <chat> [--hold <minutes>] | Reconnect now (ends a hold; a contact whose app is not there is unavailable, the dial's own words in details.reason); close the live session, or with --hold stay off the direct link that long (Staying off the direct link) |
| 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) |
| chat list [--show-secret], chat show <chat> [--show-secret] | Chats, and one chat's connection: transports, last attempt, comparison code. pairing is connecting, negotiating, confirm, waiting, ready or error, and connectionError says why it failed (null when nothing did). A pending chat's invite prints as <hidden> without --show-secret. lastMessageAt is null until the chat's first message, as every time not reached yet is |
| 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. It names its chat by the chat's id, its contact's key or a label given here, never only by the contact's own name or a prefix of its id |
| chat rename <chat> [name...], chat remove <chat> --yes [--force] | Name it here (up to 48 characters, counted as stored: a tab or a line break is a space and invisible characters go, so a name with nothing that shows is refused; counted in code points, so a joined emoji counts as several, and a name too long is refused with its count in details.length and details.max; no name, or an empty one, gives back the contact's own); delete it (keys and history) here, closing the contact's services opened from it (service open), refused (busy) while a call is on in it: hang the call up first; refused (confirm, the messages in details.messages) while a message you deleted for everyone has not reached the contact yet, as removing the chat would leave it on their device: --force removes it anyway |
| 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. With --method usdt the amount is in USDT, as the app reads it (5 is 5 USDT, 0.25 a quarter; on the socket API, amount as text: a number there is base units). The answer says the amount asked: amount and unit, and for USDT decimals (base units make one USDT), with the few base units the app adds so the payment can be told apart (5.000417 USDT); payment list carries decimals for USDT too. Refused as chat pay is when the contact offers no way of paying (contact_no_wallet too when it has no wallet of the --method or network asked, with the wallet create command it needs), or when chat request has no Cashu wallet of the network here (no_wallet). chat pay-request names its chat by the chat's id, its contact's key or a label given here, never only by the contact's own name or a prefix of its id |
| chat transport <chat> <auto\|dht\|webrtc\|iroh\|hyperdht> | What carries the chat |
| chat verify <chat> --code <code> | Mark the contact verified after comparing the codes out of band |
| 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. Paired answers at once for a chat that paired before, whether its contact is online or not |
| 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), 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), keeping the profile for the new daemon in between: other commands wait for its socket rather than open the profile. 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 |
| 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. In a chat on the DHT only, an edit past about 214 bytes once sealed is refused (an edit never waits for a live transport as a long text does) |
| 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, switchGroup, deviceRemove) needs --yes; clearProfileData answers what it removed and stops a daemon. removeLink, and setChatTransport or setDeliveryMode to dht, are refused (busy) while a call is on in the chat, as chat remove and chat transport dht are; removeLink while a delete for everyone has not reached the contact, as chat remove is, and clearProfileData while one has not in any chat, until --force; clearProfileData while a call is on in any chat. One that sends a text that looks like a secret (sendMessage, sendGroupMessage, editMessage, forwardMessages, a payment's memo or comment, a file's name, a group's name in createGroup or renameGroup, the nick in updateSettings) needs --force |
| events [--since seq] [--translate lang] | What the event journal holds, without following (Translation) |
| file list <chat\|group>, file accept\|decline\|pause\|resume\|cancel [<chat>] <file> | Transfers; a file over 25 MiB waits for file accept (files/3), and so does a group's file that did not come by itself (over 8 MiB): its row's transfer says stage: "asking", waitingFor: "me" (a file sent from here that the contact has not taken yet: waitingFor: "contact"; one sent while the contact is away: stage: "waiting", waitingFor: "contact"). A file's id names its chat or its group, so <chat> may be left out. One the contact paused (pausedBy: "peer") goes on only when they resume it: file resume, file request and file resend of it are refused, as are file pause, file resume and file request of one offered here that waits for file accept. file accept reads this device's room first: a file larger than the room left (beside the files still on their way) is not started and is refused with details.reason: "no_room" and details.room (bytes), and it keeps waiting, so free some space and accept it again |
| 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). One that ended (cancelled or declined, by either side) is refused by these and by file accept|decline|pause|resume|cancel and file save, naming the way out (file send it again; the receiver asks the contact), with details.reason (cancelled, declined, failed) and details.by (me, contact, null). A second file cancel or file decline of one this side ended answers as the first did |
| 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: a name taken in --dir is answered with the next free --path … (2) that keeps both; an unfinished one says how many bytes are here (exit 1), one that waits for you to take it answers 5 naming file accept, with or without --wait; --wait waits for a received one first (a sent one is all here) |
| file send <chat\|group> <path> [--name n] [--mime t] [--voice [ms] [--peaks …]] [--reply <message>] [--force] [--wait none\|sent] [--timeout s] | 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. Without a daemon, a file to a chat stays until the contact has all of it (--wait sent, the default there; --timeout, 300 s, then exit 4 with the messageId and the file's id in details, and it goes on with your next command; a file over 25 MiB waits for the contact's file accept meanwhile); --wait none answers at once, as a daemon does by default. To a group (group:<id> when a chat has the same name), up to 100 MiB (a larger one is refused with details.reason: "too_large", details.size and details.max; a 1:1 chat takes it): every member sees it at once and each member's app fetches it from a member who has it (WISP 503) |
| 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; details.reason and details.by as the actions' refusals carry them, the code still engine until the next minor), 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 |
| 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}]}, a group's with edges (how many edges took its copies so far, as for group send); 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; without a daemon a group's copies wait for an edge by default (--wait none answers at once). A wait that ends short (a timeout, exit 4) has the results in details too, next to the copy's messageId; a refusal comes first. A text past the 256 bytes the DHT carries, forwarded into a chat on the DHT only, waits for a live transport as send's does: that chat's result says so in a note, and a --wait sent timeout says the same, also as details.note |
| group auto [on\|off] [--from <chat>]… | Accept group invitations by themselves, only those over the chats named (their id, their contact's key or a label given here; on needs at least one, and names them all: a new on replaces the list): the daemon accepts them at once, and on start those that came while it was down; any other waits for group accept. Kept in the profile's groups.json with each chat's contact key: a removed chat, or one whose contact's key changed, leaves the list. When the 32 waiting invitations are full, one over a chat on the list takes the place of the oldest waiting from the chat that holds the most (its inviter is told no). An invitation over a chat on the list kept beside another contact's under the same group id (others) is the one taken, the other told no, while the group held is only an invitation not answered yet; beside a group joined or accepted it waits for you (a line in the log). With no argument, prints {autoJoin: {on, from}}; group list carries it too. Each accept is a line in the daemon's log |
| group call <group> --sfu <https origin> [--e2ee \| --no-e2ee] \| --e2ee \| --no-e2ee \| --clear | A community's admin names the node its calls go through (WISP 602), signed beside the name and picture, or --clear turns its calls off. --e2ee asks for sealed call media (§ End-to-end encryption), --no-e2ee turns it off, with --sfu or alone for the node already named; left out, the group keeps what it had. An https origin only, at most 200 characters, in one spelling (https://call.example.com: no path, query, trailing /, capitals or default port :443); anything else is refused before it is signed, with the origin to use when there is one, or the limit when the origin is longer. A member who is not the admin, one out of the group (removed, or left: with that reason), or a private group, is refused. Answers the group as group show does, whose call is {sfu, e2ee} or null |
| group create <name> [--mesh] [--force], group join [<link> \| -] | A community (anyone who has its link can join), 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. It answers {group, joined, stage}: without a daemon after waiting up to 60 s to be let in, through one at once (the daemon goes on knocking), with a warning naming the group show that follows it while not in yet. Until then group show says status: "invited" with invitation.viaLink: true and chat: null (no chat brought it), and invitation.note that it knocks at the link and that group decline stops it |
| 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 profile that is not a member any more (removed from the group) gets refused, with the reason, as does message delete <group> <message> --everyone. 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 |
| group hub <group> <member> [--pin \| --exclude \| --auto] | Past 16 members: pin a member as a hub, keep one from being a hub, or leave it to their app (a daemon offers itself). A private group only: a community chooses its hubs by itself, and is refused |
| group invite <group> <chat>, group remove <group> <member>, group admin <group> <member> | Membership, for the admin (each prints the group; --show-secret for its link). While the group's link is on, a member removed can join again with it: group remove says so on stderr, and group link <group> --reset keeps them out. group invite names its chat by the chat's id, its contact's key or a label given here, never only by the contact's own name or a prefix of its id; group admin (and group hub --pin) names its member by its key or a prefix of it, never only by the name the member gave itself |
| group leave <group> --yes, group forget <group> --yes, group accept\|decline <group> | Membership. Leaving deletes the group's history and files on this device, so it asks for --yes (confirm, exit 5, without it), as group forget does; forget also deletes a group you were removed from, which keeps its history. An admin's leave hands the role to a member who is online and names them: {left, admin: {key, name}}; with nobody else online it is refused until a member is, or until group admin <group> <member key> made one the admin. A group you are not in yet (an invitation, or a knock at its link) is left with group decline |
| group list [--show-secret], group show <group> [--show-secret], group history <group> | Groups (and autoJoin, as group auto prints it), members, history; a message names its author (member key, nick from the roster, or the name an author no longer in it had). A payment note's line (gpay:<id>) carries groupPay: {id, kind, from, to, by, claims, amount, decimals, unit, rail, state, test} (member keys as group show prints them, from * for a request to the whole group; state open, sent, paid or closed; by null when nobody can tell who paid), and the payment's own line on this profile (the request you made, a request that came to you) says twinOf: "gpay:<id>": the same payment, which the app draws once The entry link prints as <hidden> without --show-secret. lastMessageAt is null until the group's first message. others (only when there are some): other groups that came under the same id, kept beside it until you pick, each a contact's invitation (chat, name, members) or a link opened (link, hidden the same way); engine keepGroup '{"groupId":"<id>"}' keeps the one shown, engine switchGroup '{"groupId":"<id>","to":"<chat or link>"}' --yes takes another, leaving the one shown and deleting its history on this device |
| group react <group> <message> <emoji> [--remove] [--wait none\|sent] [--timeout s] | React to a group's message. An <emoji> that is not one emoji is a usage error (exit 2), as for react. refused when the profile is not a member any more. edges: how many took it (sent: whether one did). Without a daemon it waits by default until an edge took it (--wait sent, up to --timeout, 30 s): a timeout (exit 4) says it is kept and goes with the next command that opens the group |
| group rename <group> <name> [--force] | A new name, for the admin (up to 64 characters, cleaned and counted as a chat's name is; one that looks like a secret needs --force, as for group create); the picture stays. Members see it once it reaches them; until then, and on apps from before names, the group keeps the name it had when they got in |
| group rotate <group>, group link <group> [--off] [--reset], group picture <group> <jpeg> \| --clear | A fresh secret; the link (printed: asking for it is asking for the secret, and anyone who has it can join; a community's member asking for a link the admin turned off is refused, told only the admin can make a new one); the picture |
| group send <group> [text…] [--mention <member>]… [--reply <message>] [--button id:Label]… [--style id=primary\|neutral\|danger]… [--once] [--id id] [--wait none\|sent] [--timeout s] | Send; each mentioned member is written as @name in the text. --button puts buttons under it, as send --button. Answers {group, messageId, sent, edges}: the id --reply, group react and group edit take, how many edges took it so far, and sent, true once one did. A profile that is not a member any more (removed from the group) gets refused, with the reason, and nothing is sent. A group has no receipts: --wait sent waits until at least one edge took it (a member's in a private group, one of your hubs' in a community), and exits 4 after --timeout (default 30 s) if none did; the message still goes when an edge opens, while the profile is online. Use it for a one-shot send with no daemon. In a private group with nobody else in it (they all left, or nobody accepted yet), nobody gets the message, not even someone who joins later: the answer comes at once with sent: false and a note saying so. A profile removed while it was away learns it only once it is back: a wait that learns it ends at once as refused (exit 1) with the reason and the messageId, since nothing goes any more |
| group typing <group> [--kind typing\|recording\|thinking] [--status "<text>"] [--for s] [--stop] | typing in a private group: the members whose edge is open see "Ana is typing…" (or recording, thinking, or your status line), with the same rules, 6 s hold and --for (a one-shot without --for reaches nobody and says so in a note). Answers {group, typing, kind, status, reached, sendTyping} (reached: members with an open edge). A community does not carry typing yet (exit 1, unavailable) |
| identity add <provider> [subject] [--signer id] [--field name=value]… [--stdin] [--days n] [--timeout s] | A proof: an in-app signer (NIP-46 and the like) finishes here; a tool or a published record answers with the statement; --timeout is how long it waits for an approval (300 s, up to 3600; a NIP-46 signer waits as long), and one that does not come is timeout (exit 4); once the signer approved, a refusal of the proof keeps its own words and code, even when the check ends past it. Pubky waits at most 300 s, as long as its relay keeps the request: a longer --timeout is refused. With --stdin, fields come as name=value lines on stdin, out of ps and the shell's history; a --field the signer marks secret (a NIP-46 bunker:// link) is warned about |
| identity complete <draft> [--evidence-file f \| --stdin], identity cancel <draft> | Finish it with the tool's output, from a file, --stdin or piped to it (or nothing, for a published record); needs the daemon that began it. Cancel drops one not finished |
| identity providers, identity list | Kinds of proof and their signers; this profile's proofs |
| identity share\|withdraw <chat> <id>, identity contact <chat>, identity recheck <chat> <id>, identity remove <id> | Show a proof to a contact; what a contact showed, as checked here. identity share and identity withdraw name its chat by the chat's id, its contact's key or a label given here, never only by the contact's own name or a prefix of its id |
| invite create [--label <name>] | A new chat's ghostly1… invite and its link |
| invite join [<invite-or-link> \| -] [--label <name>] | Join a chat (your own invite is refused). The invite comes from stdin when none is given or -, out of ps and the shell's history; on the command line the CLI warns |
| lightning default <card>, lightning rename <card> <name> | Lightning cards: which receives by default |
| listen [--since seq] [--cursor file] [--type t]… [--turns] [--from <chat\|key>]… [--group <group>]… [--exec cmd] [--webhook url] [--print] [--translate lang] | The event stream; --from and --group an allowlist, --turns one agent.turn per message to answer, --translate a translation of received messages (Events, Translation) |
| message delete <chat\|group> <message> --everyone [--wait none\|confirmed\|sent] [--timeout s] [--purge] | Deletes a message of yours for everyone (a text, a card, a file or a voice message; never a payment): it goes from this device at once and from every member's as the message's last edit, once they are back if they are away. An app from before this shows "🗑 Message removed" in its place. In a chat, --wait confirmed waits for the contact's app to confirm (the default without a daemon, which is offline once the command ends), and the answer's confirmed says whether it did. In a group (no receipts), --wait sent waits until a member's edge (a hub's, in a community) took the removal, the default without a daemon, and the answer's edges and sent say how many did, as for group send. Either wait that times out (exit 4, timeout) still deleted it: the message is gone here and its removal goes on by itself, and the error's details carry deleted (and purged: true once --purge ran), so a retry is not needed. Without --everyone, only this device forgets it, except a text of yours still waiting (it never left this device): it is cancelled, as the app's Cancel sending, and the contact never gets it; if a retry had just handed it to a relay, it is deleted for everyone instead, and the answer's everyone is true. Answers the chat or group, the message's messageId and everyone (deleted says the same id, kept for callers that read it). What a deleted message said stays in the profile's store journal (db/journal.bin) until the store folds it, within the hour; --purge (with or without --everyone) takes its line out of the replies that quote it (and, in a private group, the copy the group kept for members who missed it) and folds the store before answering, so its text has left the profile's folder when the command returns, and the answer says purged: true (during a profile backup, once the backup has read the store; what it read, from before the delete, keeps the text: its copy of the store in db/ until the backup ends, and the backup itself). On a message no longer here (the contact deleted it for everyone, or a delete without --purge came first) or another member's group message, the delete still answers not found (exit 3), but the store folds all the same and the error says so (details.purged: true): a deleted copy of it leaves the folder too. One fold per call: for a secret pasted into a chat, not every delete |
| message retry\|delete\|details <chat> <message> | One message |
| pay <invoice\|address\|lnurl> [--amount sats] [--network n] [--max-fee sats] [--card <id>] [--comment t] [--chat <chat>] [--confirm-real] [--force] | Pay over Lightning (Testnet unless --network mainnet). --chat: the chat the invoice came from, whose contact is told a Testnet invoice was paid, named by the chat's id, its contact's key or a label given here, never only by the contact's own name or a prefix of its id |
| payment list [--chat c], payment check <chat> <payment>, payment reclaim <payment> | Payments and requests |
| pin <chat\|group> <message> \| --remove [--wait none\|confirmed\|sent] [--timeout s] | Pin a message at the top of a chat or group, for everyone in it: one per chat, a new pin replaces it; pin <chat\|group> --remove unpins (it names no message). In a community only the admin pins. A profile that is not a member of the group any more (removed from it) gets refused, with the reason, and nothing is pinned. A 1:1 pin reaches the contact on the next live session; without a daemon pin stays until the contact confirmed it (--wait confirmed, the default there; --timeout, 30 s), and confirmed says whether it has. A group has no receipts: without a daemon a group's pin stays until a member's edge (a hub's, in a community) took it (--wait sent, the default there), and the answer's edges and sent say how many did, as for group react. The other side hears chat.pinned or group.pinned. chat show, group show and group list say what is pinned now: pin: {messageId, ref, by, at} (messageId null when the message is not here), or pin: null |
| profile backup --out <file>, profile restore <file> <new profile> | A backup (WISP 05 envelope, written and read a piece at a time), encrypted with the passphrase from --passphrase-file (- reads it from stdin, e.g. a pipe from a password manager) or GHOSTLY_BACKUP_PASSPHRASE. One line break at the end of the file (or stdin) is left out, nothing else: a backup is refused for a passphrase that starts or ends with any other space, line break or byte order mark, or holds a NUL (a file saved as UTF-16), as the same passphrase typed or pasted would not open it. --no-passphrase makes one that is not encrypted: the file then holds the profile's keys and wallet secrets in the clear. Neither given, nothing is made. It holds the store, the files, the group auto and call auto settings and the chats' holds (chat disconnect --hold): the restored copy joins and answers by itself as the original did, and a held chat comes back to its live link when its hold ends (at its first start, when that time passed already). --light leaves out files over 1 MB (voice messages over 4 MB): their messages stay, and the restored copy says each one is not in this backup |
| profile create <name> [--use] [--name <shown>] [--force], profile list, profile use <name> | Profiles |
| profile picture <jpeg> \| --clear | The picture contacts see (a JPEG within 512 px; 128 px is what the app sends) |
| profile show, profile set [--name <name>] [--share-profile \| --no-share-profile] [--force] | The name contacts see (up to 64 characters, cleaned as a chat's or a group's name is, and counted once cleaned; empty is no name; a longer --name, or one with nothing that shows, is a usage error naming it, as for profile create --name; one that looks like a secret needs --force) |
| 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. Anything else as <emoji> (a word, two emoji) is a usage error (exit 2) before the profile opens. 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 |
| 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 within a year (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 |
| 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 under saved, 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 |
| 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). A text past the 256 bytes the DHT carries, in a chat on the DHT only, waits for a live transport: the answer says so at once in a note, and with --wait sent\|delivered its timeout (exit 4) says the same, also as details.note, as do the wait's notice on a terminal and its Ctrl-C line |
| 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 share names its chat by the chat's id, its contact's key or a label given here, never only by the contact's own name or a prefix of its id, and is refused past the 13 apps one contact can see. On the socket, service.share and service.enable take off: true, or the answer's own shared / enabled key (refused beside an off that says the opposite). service add answers the new one as service (the id the others take); its old key serviceId stays beside it for one release |
| 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). With Hide my IP from contacts on, service open fails with unavailable: a browser tab cannot keep the app's page off WebRTC |
| settings get [--show-secret], settings set <key> <json> [--force] | Relays, Iroh relays, the HyperDHT relay (kept for the apps: the CLI runs HyperDHT itself and dials through the relay only with Hide my IP from contacts, not settable yet, and the answer says so on stderr), ICE servers, sendTyping (false: contacts are never told you type), daemonPresence (true: while a daemon runs the profile, contacts see it online, WISP 401 § Presence and status; off by default, so a bot is never shown online unless you turn it on), … settings get shows every key settings set takes with its value in effect (one never set as its default: sendTyping: true, the default Iroh relays). <json> as -, or none on a pipe, is read from stdin: a TURN password stays out of ps |
| status | The profile, its chats, whether WebRTC and calls run, the last event seq |
| status set [text…] [--emoji <emoji>] [--availability available\|busy\|away\|dnd] [--until <time>] [--force], status show, status clear | The status your paired contacts see (WISP 401 § Presence and status): a text of up to 60 characters on one line (no links or markup), one emoji, an availability (dnd is Do not disturb) and when it ends by itself: --until 30m, 2h or 1d from now, or milliseconds or a date within a year, written as routine send --next takes it. A new set replaces the whole status. A text too long or with a link, a word that is not one emoji, or a time already past is a usage error (exit 2) that names it, before the profile opens. The socket's status.set takes until in milliseconds and holds it to the same year (bad_request). All three answer {"status": {"text", "emoji", "availability", "until"}} (a field not set is null) or {"status": null} when there is none. A daemon tells every contact whose app offers status/1 at once; without one the status is kept here and said on each chat's next live session. Plain status is unchanged. These commands never say presence (online or idle): only a daemon does, and only with settings set daemonPresence true; a profile restored from an app with "Share when I'm online" off (sharePresence: false, not a key settings set takes) says none even then |
| 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), or when a ghostly-store.json or ghostly-store.sig there does not read as a signed index (move them away, or name another --out), or when --key is inside the output folder, which is published (private-key: keep the store key outside it, and outside its repository) |
| 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 |
| 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 one-shot without it reaches nobody, so it answers at once with a note saying so); a new kind or status shows at once; a message to the chat or --stop ends it |
| 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 within a year (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 for where a bot gets its numbers |
| version | This CLI's version, {"version":"…"} (also ghostly --version) |
| 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 |
| wallet faucet <type>, wallet add-mint <url> [--primary] | Test coins; another Cashu mint. Refused (no_wallet) with no Testnet Cashu wallet to ask the test mint with |
| wallet list [--network n] | Wallets and balances, and what wallet create can make on each network |
| wallet receive <sats>, wallet address <type>, wallet redeem [<token> \| -], wallet history | Receive, and what came and went. wallet receive with no Cashu wallet (and no other Lightning source) of the network, and wallet address with no wallet of its type, are refused (no_wallet) naming the wallet create to run. wallet redeem reads the token from stdin when none is given or -, which keeps it out of ps and the shell's history |
| wallet remove <type> [--network n] [--card id] [--accept-loss] | Refused while it holds money or waits for some, unless --accept-loss |
| x401 credential add <file\|-> [--label name], x401 credential list [--show-secret], x401 credential remove <id> | x401 credentials (WISP 3xx, a draft: test credentials only): keep an issued SD-JWT VC bound to a key from x401 key new (a label is up to 80 characters on one line), list them (claim paths; values only with --show-secret), remove one with its key. Never shared with contacts |
| x401 key new | A fresh P-256 holder key, one per credential: give its public JWK to the issuer. The 8 newest keys wait for a credential; a ninth drops the oldest (dropped names it) |
Help: ghostly help lists every command; ghostly help file (or ghostly file --help) a group; ghostly help file
save (or ghostly file save --help) one command, with its options. -h works too, except after --.
Arguments: an option's value is taken as is, even when it starts with -. So is an id in a positional that takes
one (<chat>, <group>, <message>, <file>, <payment>, <draft>, <id>, …): drafts, payments and groups
are base64url, which starts with - one time in 64. Any other positional that starts with - is refused (a
mistyped flag must not reach a contact as text): put -- before a message that starts with a dash. Everything
after -- is text, options included: send bob -- -1 today --wait sent sends "-1 today --wait sent" and waits for
nothing, so put the options before -- (send bob --wait sent -- -1 today).
Voice notes
file send <chat> <path> --voice sends an audio file as a voice note. Its length (--voice <ms>, 1 to 900000) and
its 64 waveform bars (--peaks 0,40,…, 0-255, at most 128, only with --voice) may be given; whatever is not given is measured from the file with the
app's own meter (voicePeaksOf in packages/core voice.ts: a reading every 50 ms, the loudest per bar), so the
bars look like the app's recordings. WAV, Opus in WebM or Ogg and MP3 are decoded in the CLI (wasm, no native code);
AAC in MP4/M4A and other kinds need ffmpeg on the PATH (GHOSTLY_FFMPEG names another). When the sound cannot be
measured here (no ffmpeg for its kind), a note with a given length goes out flat with a warning on stderr (the socket
API answers warning), and one without is refused (bad_request). A file that is not a voice note is refused with or
without a length, naming why: empty, not audio (its type, or no sound a decoder finds in it), or longer than 15
minutes. --voice takes the next word only when it is a number.
Files a bot receives
message.received carries the file: message.file is {id, name, size, mime, voice?}, and a voice note's voice
is {duration, peaks?} (milliseconds, and the 0-255 bars; releases before this one said only voice: true). The
file.* events name the file's message and chat (messageId, chat). So a bot answers a voice note without polling:
ghostly listen --type message.received --exec '
file="$(jq -r ".message.file.id // empty")"
[ -n "$file" ] && ghostly file save "$file" --dir ./inbox --wait --timeout 120'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).
Staying off the direct link
chat disconnect <chat> closes the live session, but the contact's app dials again within seconds.
chat disconnect <chat> --hold <minutes> (up to a week) keeps the chat off its direct link for that long: it is the
chat's own "DHT only" choice (WISP 400: either side choosing it keeps both off the live link), taken back when the
time is up. Meanwhile text still goes over the DHT (a text of about 248 bytes at most once sealed, an edit about
214; a longer text is refused up to 256 bytes and waits past them, a longer edit is refused), files, calls and
typing wait, and the contact's app shows the chat as DHT only. A hold, or chat transport <chat> dht, while a call
is on in the chat is refused (busy): hang the call up first. chat connect, or --hold 0, ends it early. The
hold is kept in the profile folder, and a profile backup carries it: a daemon that restarts (or a restored copy
that starts) takes it back when its time is up, and a DHT only the chat had chosen itself (chat transport dht) is
never undone by it. A chat transport chosen during a hold ends the
hold (lifted) and stays as chosen, as does the engine's own setChatTransport or setDeliveryMode (ghostly
engine); chat remove, or engine removeLink, drops it with the chat. Several chats held at once each keep their
own hold. chat show answers heldUntil (a time in ms, or
null; hold there is the store-and-forward state, something else), and the stream says chat.held and
chat.released (reason: expired, connect or lifted).
settings set online false is different: the whole profile goes offline, every chat, DHT included, and nothing
arrives until it is back online.
After an upgrade
A daemon keeps running the code it started with. After upgrading the CLI, every command that goes through an older
(or newer) daemon still answers, and says on stderr ghostly: the daemon runs <version> and this command is
<version>, then what to do: an older daemon is restarted (ghostly daemon restart runs the new code); a newer one
means this command is the older CLI (a second install, a project's pinned copy), so it says to upgrade the CLI
(npm install -g @ghostlytools/cli) and gives no restart advice, since a restart from it would start the older
release. A daemon restart that does start an older release than the one it stopped says so on stderr. A daemon of a release before 1.5.0 cannot prove it is the profile's daemon (no
greeting): commands are refused after 2 s, exit 1, until ghostly daemon restart. A daemon of
this release that is slow to answer (busy on a long task) is waited for, under each command's own deadline. ghostly daemon restart stops the running daemon (if one runs) and starts this release's in the
background, as daemon --detach does. A daemon kept by a service manager (systemd, launchd) is restarted with the
service
