Expand description
Author-facing SDK for a Phi PXB extension binary — a Rust port of
ext/go/phi.
Build an Extension, register tools / slash commands / event handlers,
then call Extension::run to speak PXB on stdin/stdout until shutdown:
use phi_ext::{phi, pxb};
fn main() -> Result<(), phi::Error> {
let mut m = phi::Extension::new("hello", "0.1.0");
m.register_command("hello", phi::Command::new("Say hi", |_args, ctx| {
ctx.notify("info", "Hello!");
Ok(())
}));
m.subscribe(pxb::Event::SessionStart, |_ev| {});
m.run()
}The run loop is single-threaded. Command handlers receive a Context
whose methods (notify, confirm, submit, …) forward to the host over
the same pipe — the borrow checker enforces at compile time what the Go
SDK’s mutexes enforce at runtime.
Re-exports§
pub use crate::pxb::Error;
Structs§
- Before
Agent Start Event - Before
Agent Start Result - Command
- A slash command. The handler receives the raw argument string and a
Contextfor host interaction (notify / confirm / submit / …). - Confirm
Reply - The user’s choice for a
ConfirmRequest. - Confirm
Request - Modal yes/no dialog shown by the host.
- Context
- Interaction surface handed to command handlers. All host traffic goes
over the same PXB pipe the run loop owns — a handler may block the loop
(e.g.
confirmreads nested frames). - Extension
- The author-facing registration surface for a PXB extension binary.
- Host
Info - Host metadata filled by the hello handshake (and refreshed by
SessionMetapushes). - Schema
- JSON Schema body for an LLM tool’s parameters
(
type/properties/required/ …). - Session
Before Switch Event - Session
Before Switch Result - Tool
- An LLM-callable tool.
schemais a typed JSON Schema for parameters (same role as Go’sParameters/ Codex’s schemars-generated input schema). - Tool
Call Event - Tool
Call Result - Tool
Result - Outcome of a
Toolexecution. - Tool
Result Event - Tool
Result Result - Turn
Stopping Event - Turn
Stopping Result - User
Input Event - User
Input Result