@danypops/pi-rpc-protocol
v0.0.1
Published
A small, dependency-free parser/encoder for the subset of Pi's documented RPC protocol needed by clients speaking to a pi --mode rpc process.
Maintainers
Readme
@danypops/pi-rpc-protocol
Dependency-free parsing and encoding for the subset of Pi's documented RPC protocol needed by clients speaking to a pi --mode rpc process.
Usage
import { encodeRpcCommand, parseRpcLine } from "@danypops/pi-rpc-protocol";
childProcess.stdin.write(encodeRpcCommand({ type: "prompt", message: "hello" }));
for (const line of stdoutLines) {
const event = parseRpcLine(line);
if (event?.type === "tool_execution_end") {
console.log(event.toolName, event.result, event.isError);
}
}Scope
- Encodes
prompt,abort, andextension_ui_responsecommands. - Parses lifecycle, response, message, tool-execution, and extension UI events.
- Preserves unrecognized valid events as
unknown-eventvalues. - Extracts plain text from Pi message content.
Process spawning and session management belong in @danypops/pi-process-harness and Epi.
License
MIT
