Expand description
iFlow CLI SDK for Rust
A powerful SDK for interacting with iFlow using the Agent Client Protocol (ACP). Built on top of the official agent-client-protocol crate.
§Examples
§Basic usage with automatic process management
use iflow_cli_sdk_rust::IFlowClient;
use futures::stream::StreamExt;
use std::io::Write;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut client = IFlowClient::new(None);
client.connect().await?;
client.send_message("Hello, iFlow!", None).await?;
// Listen for messages
let mut message_stream = client.messages();
while let Some(message) = message_stream.next().await {
match message {
iflow_cli_sdk_rust::Message::Assistant { content } => {
print!("{}", content);
std::io::stdout().flush()?;
}
iflow_cli_sdk_rust::Message::TaskFinish { .. } => {
break;
}
_ => {
// Handle other message types
}
}
}
client.disconnect().await?;
Ok(())
}§Simple query
use iflow_cli_sdk_rust::query;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let response = query("What is 2 + 2?").await?;
println!("{}", response);
Ok(())
}Re-exports§
pub use client::IFlowClient;pub use error::IFlowError;pub use error::Result;pub use logger::LoggerConfig;pub use logger::MessageLogger;pub use process_manager::IFlowProcessManager;pub use query::query;pub use query::query_stream;pub use query::query_stream_with_config;pub use query::query_stream_with_timeout;pub use query::query_with_config;pub use query::query_with_timeout;pub use types::IFlowOptions;pub use types::Message;
Modules§
- acp_
protocol - Agent Client Protocol (ACP) implementation for iFlow SDK
- client
- Main client implementation for iFlow SDK
- error
- Error types for iFlow SDK
- logger
- Logger module for recording iFlow messages
- process_
manager - Process manager for iFlow CLI
- query
- types
- Type definitions for iFlow SDK
- websocket_
transport - WebSocket transport implementation for iFlow SDK
Structs§
- EnvVariable
- An environment variable to set when launching an MCP server.
- Session
Id - A unique identifier for a conversation session between a client and agent.
Enums§
- McpServer
- Configuration for connecting to an MCP (Model Context Protocol) server.
- Stop
Reason - Reasons why an agent stops processing a prompt turn.