/* pic remote (remote.c): remote control over a relay, docs/design/remote-protocol.md. A phone is * one more sender and one more observer of the journal: pic remote dials out to the relay, speaks * a Noise session to each paired phone, turns each command into a journal row before anything acts * on it (an inbox row, or a keyed admission), and rebuilds events from committed rows as pic * attach does. It holds no lease and listens on no socket. Pairing (pic remote pair, and /rc * through it) makes the keys and the mailbox on first use and adds a device row after a yes at * the terminal; the rows are sealed in ~/.pic/pic.sqlite under the credential store's key. */ #ifndef PIC_REMOTE_H #define PIC_REMOTE_H struct pic_context_policy; typedef struct { const char *self; /* this pic, for the children a prompt starts */ /* Draws a QR code of TEXT on stdout (the composition root owns the drawing). */ void (*show_qr)(const char *text); /* Answers LINE, a component's journal-free command (get_available_models), for MODEL in * WORKSPACE as pic --mode rpc does: Pi's response object, malloc'd, or NULL. NULL: none. */ char *(*ask)(const char *workspace, const char *model, const char *line); /* The model a conversation starts on when nothing names one ("provider/id"), as a new one at the * terminal does; "" when none is known. NULL: none. */ void (*initial_model)(char *out, size_t cap); /* The context policy the journals are read with, for get_session_stats' context use. */ const struct pic_context_policy *policy; } pic_remote_options; /* pic remote [pair [--pipe] | devices | unpair ID | reset]: the process's exit status. */ int pic_remote_main(const pic_remote_options *o, int argc, char **argv); /* 1 when a pic remote is running for this user (its lock is held), else 0. No passphrase. */ int pic_remote_running(void); /* The phone page's address for the conversation SESSION (its id alone, no path): RELAY/#s=SESSION, * with &c=PHONE when one phone is paired (the page's id for this computer); RELAY/ alone, or * #c=PHONE, when SESSION is NULL or "". The page opens the conversation of that id from the list pic * remote sends it. The number of paired phones, or -1 when it does not fit in CAP. No passphrase. */ int pic_remote_link(const char *session, char *out, size_t cap); /* The relay a pairing names when the setting remote.relay is unset. */ #define PIC_REMOTE_RELAY "https://remote.zeitforge.app" #endif