This guide gets a new Arky consumer from cargo add to a runnable agent with
provider selection, streaming, and provider examples you can compile locally.
- Rust
1.94.0or newer - A supported provider binary:
- Claude Code CLI for
arky-claude-code - Codex app server for
arky-codex
- Claude Code CLI for
- A Tokio-based application if you plan to drive the SDK asynchronously
Add the facade crate and opt into the features you need:
[dependencies]
arky = { path = "../arky/crates/arky", features = ["claude-code", "codex"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }Use the full feature if you want the bundled server and SQLite session
support in addition to both providers.
use arky::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let provider = ClaudeCodeProvider::new();
let agent = Agent::builder()
.provider(provider)
.model("sonnet")
.build()?;
let response = agent.prompt("Summarize the repository layout.").await?;
println!("{:?}", response.message);
Ok(())
}Use ClaudeCodeProvider when you want Claude CLI features such as nested tools
and Claude-native session resume.
let provider = ClaudeCodeProvider::with_config(ClaudeCodeProviderConfig {
binary: "claude".to_owned(),
..ClaudeCodeProviderConfig::default()
});Claude-compatible gateway and cloud wrappers are also available when you want a
first-class provider identity with the same Claude CLI harness underneath:
BedrockProvider, ZaiProvider, OpenRouterProvider, VercelProvider,
MoonshotProvider, MinimaxProvider, VertexProvider, and OllamaProvider.
let provider = BedrockProvider::with_config(BedrockProviderConfig {
selected_model: Some("anthropic.claude-3-7-sonnet-v1:0".to_owned()),
region: Some("us-west-2".to_owned()),
..BedrockProviderConfig::default()
});Use CodexProvider when you want JSON-RPC app-server integration and
thread-aware routing.
let provider = CodexProvider::with_config(CodexProviderConfig {
binary: "codex".to_owned(),
..CodexProviderConfig::default()
});Agent::stream exposes the same turn as a stream of structured events:
let mut stream = agent.stream("Plan a release checklist.").await?;
while let Some(event) = stream.next().await {
match event? {
AgentEvent::MessageUpdate { delta, .. } => println!("{delta:?}"),
AgentEvent::ToolExecutionStart { tool_name, .. } => {
println!("tool: {tool_name}");
}
_ => {}
}
}- Use
Agent::new_sessionto force a fresh session identity. - Use
Agent::resumewith a persistedSessionIdto continue prior work. - Pick
InMemorySessionStorefor tests or short-lived processes. - Enable the
sqlitefeature and useSqliteSessionStorefor durable replay.
- Register local tools with
ToolRegistry. - Expose or import MCP tools through
arky-mcp. - Keep canonical tool identity stable:
mcp/<server>/<tool>.
The workspace includes a live provider-validation suite under
examples/. These scenarios are self-checking and intentionally
target real provider behavior rather than local mock demos.
cargo run --example 01_claude_basic -p arkycargo run --example 10_claude_mcp -p arkycargo run --example 11_claude_runtime_config -p arkycargo run --example 04_codex_basic -p arkycargo run --example 12_codex_metadata_compaction -p arkycargo run --example 09_live_matrix -p arky -- all
Use make test-live to run the grouped suite locally.
Use the same commands locally that CI enforces:
cargo +nightly fmt --all --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo test --workspace
cargo test --workspace --all-features
RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --workspace
cargo build --examples
cargo bench --no-run
./scripts/check-deps.sh- Read
docs/architecture.mdfor the crate layout and runtime boundaries. - Start from
arky::prelude::*unless you explicitly need a lower-level crate. - Use the fixture-backed provider tests when changing protocol parsing or stream normalization logic.
- Use the live examples when you need to confirm that Claude Code or Codex still work against real binaries and credentials.