This directory contains several examples demonstrating different ways to use the iFlow CLI SDK for Rust.
Demonstrates the simplest way to interact with iFlow using the query convenience function.
cargo run --example queryThis example shows how to send a single query to iFlow and receive a complete response.
Demonstrates how to use the query_with_config function with custom configuration options.
cargo run --example query_with_configThis example shows how to configure the timeout and other options for a query.
Demonstrates full bidirectional communication with iFlow, handling multiple message types.
cargo run --example basic_clientThis example shows how to:
- Establish a connection with iFlow
- Send messages
- Handle different message types (Assistant, ToolCall, Plan, etc.)
- Process streaming responses
Shows how to use WebSocket communication instead of stdio.
cargo run --example websocket_clientThis example demonstrates:
- Connecting to iFlow via WebSocket
- Configuring WebSocket-specific options
- Handling the same message types as the basic client
Demonstrates how to configure MCP servers for extended capabilities.
cargo run --example mcp_exampleThis example shows:
- Configuring MCP servers with commands and environment variables
- Using filesystem MCP server for directory listing
- Handling MCP-related tool calls
Demonstrates how to control tool call permissions.
cargo run --example permission_modesThis example shows:
- Different permission modes (Auto, Manual, Selective)
- How to handle tool call requests
- Implementing custom permission logic
Tests response handling with detailed output.
cargo run --example test_responseShows how to use the built-in logging functionality.
cargo run --example logging_exampleThis example demonstrates:
- Configuring logging options
- Writing logs to files
- Using different log levels
- Make sure iFlow CLI is installed and available in your PATH, or use the auto-start feature
- For WebSocket examples, ensure iFlow is running with WebSocket support
- Most examples use
LocalSetfor proper async runtime compatibility - All examples follow the pattern of connecting, sending messages, handling responses, and disconnecting
To run any example, use:
cargo run --example <example_name>Replace <example_name> with the name of the example you want to run (without the .rs extension).