iflow_cli_sdk_rust/
lib.rs

1//! iFlow CLI SDK for Rust
2//!
3//! A powerful SDK for interacting with iFlow using the Agent Communication Protocol (ACP).
4//! Built on top of the official agent-client-protocol crate.
5//!
6//! # Examples
7//!
8//! ## Basic usage with automatic process management
9//! ```no_run
10//! use iflow_cli_sdk_rust::IFlowClient;
11//! use futures::stream::StreamExt;
12//! use std::io::Write;
13//!
14//! #[tokio::main]
15//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
16//!     let mut client = IFlowClient::new(None);
17//!     client.connect().await?;
18//!     
19//!     client.send_message("Hello, iFlow!", None).await?;
20//!     
21//!     // Listen for messages
22//!     let mut message_stream = client.messages();
23//!     while let Some(message) = message_stream.next().await {
24//!         match message {
25//!             iflow_cli_sdk_rust::Message::Assistant { content } => {
26//!                 print!("{}", content);
27//!                 std::io::stdout().flush()?;
28//!             }
29//!             iflow_cli_sdk_rust::Message::TaskFinish { .. } => {
30//!                 break;
31//!             }
32//!             _ => {
33//!                 // Handle other message types
34//!             }
35//!         }
36//!     }
37//!     
38//!     client.disconnect().await?;
39//!     Ok(())
40//! }
41//! ```
42//!
43//! ## Simple query
44//! ```no_run
45//! use iflow_cli_sdk_rust::query;
46//!
47//! #[tokio::main]
48//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
49//!     let response = query("What is 2 + 2?").await?;
50//!     println!("{}", response);
51//!     Ok(())
52//! }
53//! ```
54
55pub mod acp_protocol;
56pub mod client;
57pub mod error;
58pub mod logger;
59pub mod process_manager;
60pub mod query;
61pub mod types;
62pub mod websocket_transport;
63
64// Re-export main types
65pub use client::IFlowClient;
66pub use error::{IFlowError, Result};
67pub use logger::{LoggerConfig, MessageLogger};
68pub use process_manager::IFlowProcessManager;
69pub use query::{
70    query, query_stream, query_stream_with_config, query_stream_with_timeout, query_with_config,
71    query_with_timeout,
72};
73pub use types::{IFlowOptions, Message};
74
75// Re-export types from agent-client-protocol that we actually use
76pub use agent_client_protocol::{EnvVariable, McpServer, SessionId, StopReason};
77
78// Version info
79pub const VERSION: &str = env!("CARGO_PKG_VERSION");
80pub const PROTOCOL_VERSION: u32 = 1;