Skip to main content

Crate phi_ext

Crate phi_ext 

Source
Expand description

Rust author SDK for Phi PXB extensions — a faithful port of the Go SDK under ext/go.

Two layers, mirroring the Go module:

  • pxb: the binary wire protocol (frames, tagged fields, message codecs)
  • phi: the author-facing API (phi::Extension) that speaks PXB over stdin/stdout

The only external dependencies are serde/serde_json at the JSON edges (tool schemas, confirm payloads) plus tokio (rt feature) to drive async tool handlers; the wire format itself needs no reflection, so the PXB codecs stay hand-rolled and lean.

§Example

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()
}

Modules§

phi
Author-facing SDK for a Phi PXB extension binary — a Rust port of ext/go/phi.
pxb
The Phi eXtension Binary wire protocol — a Rust port of ext/go/pxb.