Skip to main content

atm_pi_adapter/
lib.rs

1//! pi adapter for ATM.
2//!
3//! All pi-specific knowledge — the event vocabulary, the wire payload
4//! shape, and the translation into vendor-neutral
5//! `atm_core::LifecycleEvent` — lives in this crate. Symmetric with
6//! `atm_claude_adapter`.
7//!
8//! Pi is a coding agent (<https://pi.dev/>, npm package
9//! `@mariozechner/pi-coding-agent`) that exposes a TypeScript extension
10//! API. ATM's pi adapter is a TypeScript extension (`pi-atm`,
11//! tracked by bead `agent-tmux-manager-6dx`) that subscribes to pi's
12//! `pi.on(eventName, handler)` events and forwards them to atmd over
13//! the existing Unix socket. The Rust types in this crate describe the
14//! wire payloads that extension produces and the translation into
15//! `LifecycleEvent`.
16//!
17//! ## Event vocabulary
18//!
19//! 28 pi events: 26 declared in pi's
20//! `dist/core/extensions/types.d.ts` plus 2 undeclared but real
21//! (`tool_call`, `tool_result`). See `event::PiEventType` for the
22//! enumeration and `translate.rs` for per-variant lifecycle mapping.
23//! Originally captured by the `agent-tmux-manager-9dn` spike under
24//! `extensions/pi-spike/`.
25//!
26//! ## Three-axis vendor model
27//!
28//! Pi is *provider-agnostic* — a single pi session can switch between
29//! Anthropic, OpenAI, and other providers via `model_select`. The
30//! three axes are:
31//!
32//! - **harness** = `pi`
33//! - **provider** = `anthropic` / `openai-codex` / etc.
34//! - **model** = `claude-sonnet-4-6` / `gpt-5.5` / etc.
35//!
36//! Provider+model changes ride [`atm_core::LifecycleEvent::ProviderModelChange`].
37//!
38//! ## NeedsInput is extension-mediated
39//!
40//! Pi has *no* dedicated permission-prompt event. Permission gating
41//! happens *inside* an extension's `tool_call` handler via
42//! `ctx.ui.select(...)`. ATM's pi adapter therefore registers a
43//! `tool_call` handler and synthesizes
44//! [`atm_core::NeedsInputReason::PermissionGate`] when the gate is
45//! reached. A passive observer cannot detect this state; only an active
46//! extension can.
47
48pub mod event;
49pub mod translate;
50pub mod wire;
51
52pub use event::PiEventType;
53pub use wire::RawPiEvent;