1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! 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
//!
//! ```no_run
//! 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()
//! }
//! ```
//!
//! [Phi]: https://github.com/pulseaiclub/phi