Skip to main content

ralph_adapters/
lib.rs

1//! # ralph-adapters
2//!
3//! Agent adapters for the Ralph Orchestrator framework.
4//!
5//! This crate provides implementations for various AI agent backends:
6//! - Claude (Anthropic)
7//! - Gemini (Google)
8//! - Codex (OpenAI)
9//! - Pi (pi-coding-agent)
10//! - Roo (Roo Code)
11//! - Amp
12//! - Custom commands
13//!
14//! Each adapter implements the common CLI executor interface.
15//!
16//! ## Auto-Detection
17//!
18//! When config specifies `agent: auto`, the `auto_detect` module handles
19//! detecting which backends are available in the system PATH.
20//!
21//! ## PTY Mode
22//!
23//! The `pty_executor` module provides PTY-based execution for Claude CLI,
24//! preserving rich terminal UI features (colors, spinners, animations) while
25//! allowing Ralph to orchestrate iterations. Supports interactive mode (user
26//! input forwarded) and observe mode (output-only).
27
28mod acp_executor;
29mod auto_detect;
30mod claude_stream;
31mod cli_backend;
32mod cli_executor;
33mod copilot_stream;
34mod json_rpc_handler;
35mod pi_stream;
36mod pty_executor;
37pub mod pty_handle;
38mod stream_handler;
39
40pub use acp_executor::AcpExecutor;
41pub use auto_detect::{
42    DEFAULT_PRIORITY, NoBackendError, detect_backend, detect_backend_default, is_backend_available,
43};
44pub use claude_stream::{
45    AssistantMessage, ClaudeStreamEvent, ClaudeStreamParser, ContentBlock, Usage, UserContentBlock,
46    UserMessage,
47};
48pub use cli_backend::{CliBackend, CustomBackendError, OutputFormat, PromptMode};
49pub use cli_executor::{CliExecutor, ExecutionResult};
50pub use copilot_stream::{CopilotAssistantMessage, CopilotStreamEvent, CopilotStreamParser};
51pub use json_rpc_handler::{JsonRpcStreamHandler, stdout_json_rpc_handler};
52pub use pi_stream::{
53    PiAssistantEvent, PiContentBlock, PiCost, PiSessionState, PiStreamEvent, PiStreamParser,
54    PiToolResult, PiTurnMessage, PiUsage, dispatch_pi_stream_event,
55};
56pub use pty_executor::{
57    CtrlCAction, CtrlCState, PtyConfig, PtyExecutionResult, PtyExecutor, TerminationType,
58};
59pub use pty_handle::{ControlCommand, PtyHandle};
60pub use stream_handler::{
61    ConsoleStreamHandler, PrettyStreamHandler, QuietStreamHandler, SessionResult, StreamHandler,
62    TuiStreamHandler,
63};