Artifact b0196c64608fcd2a550fc4cdf0be30065a96419eb60707c039aa2ebda0fc11b4:
- File docs/manual/rpc.md — part of check-in [4b2c1d57cf] at 2026-11-23 11:33:52 on branch ux-p0 — Stored keys where no terminal can ask: attach -i hands the key to its requests, a locked store with no terminal fails at once with the ways out and journals nothing, RPC sends credential_locked and takes unlock instead of prompting, and pic auth reset forgets a store whose passphrase is lost. Fix the garbled TLS error text, retries that went on after Stop, and an early sign-in refresh that failed a request whose token was still valid. (user: dmestas, size: 1924) [annotate] [blame] [check-ins using] [more...]
RPC mode
pic --mode rpc speaks Pi's RPC protocol (Pi's docs/rpc.md and docs/rpc-commands.md): one JSON
command per line on stdin, each answered by a response line with its id, command, success
and data or error, with Pi's JSON events in between. -c (or --continue) continues the latest
conversation and --session ID that one; otherwise a new one starts. --model and --thinking set
where it starts. Closing stdin ends the process; SIGTERM, SIGHUP and SIGINT cancel what runs first.
Every Pi command is there with Pi's fields, responses and errors: the RPC command reference lists them, and differences from Pi says where pic's answers differ.
RPC mode never asks for the credential store's passphrase on a terminal, since the client owns
stdin and the terminal. When the model's key is sealed and the store is locked, a prompt fails at
once after a credential_locked event naming the provider; the client asks its user and sends
unlock with the passphrase, then the prompt again.
The journal
The process holds the journal only while it works: for one command when idle, and for the length of
a request, a compaction or a bash command, so other pic commands can use the journal in between.
While a request runs, steering, queries and setting changes are answered at once; compact,
new_session, switch_session, fork and clone abort the request first (journaled as Ctrl-C's
cancel is) and run once it has stopped; anything else waits its turn. compact then compacts at
once, outside any request: the compaction and its summary request belong to the conversation's
latest request and commit together, so a crash leaves either the compaction or a failed attempt. A
crash mid-request recovers as any pic run's (pic run, or the next request). Steering sent while
idle is held for the next prompt, as Pi's is.