Crate turboclaudeagent

Crate turboclaudeagent 

Source
Expand description

Interactive Agent SDK for TurboClaude

This SDK enables interactive agent development within the Claude Code IDE, with features like permission callbacks, hooks, dynamic control, and more.

§Key Features

  • Bidirectional Protocol: Full two-way communication with Claude Code IDE
  • Permission Callbacks: Fine-grained control over tool execution
  • Hook System: React to key lifecycle events (PreToolUse, PostToolUse, etc.)
  • Interactive Sessions: Stateful conversations with runtime control
  • Dynamic Control: Interrupt, change model, or modify permissions mid-execution
  • Custom Agents: Define specialized agent personas
  • In-Process Tools: Simple function-based tools without subprocess overhead

§Architecture

The Agent SDK is built on three key layers:

  1. Protocol Layer (turboclaude-protocol): Shared message types
  2. Transport Layer (turboclaude-transport): Subprocess communication
  3. Agent Layer (this crate): High-level client API

§Usage Example

use turboclaudeagent::ClaudeAgentClient;
use turboclaude::types::Models;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = ClaudeAgentClient::builder()
        .api_key("sk-...")
        .model(Models::CLAUDE_SONNET_4_5)
        .build()?;

    let mut session = client.create_session().await?;
    let response = session.query("What is 2+2?").await?;

    println!("Response: {}", response);
    Ok(())
}

§IDE-Specific

This SDK is designed specifically for use within the Claude Code IDE. It requires the Claude CLI to be available and communicates via a bidirectional protocol over stdin/stdout.

Re-exports§

pub use agent::AgentDefinition;
pub use client::ClaudeAgentClient;
pub use config::ClaudeAgentClientConfig;
pub use config::SessionConfig;
pub use config::ToolsOption;
pub use config::ToolsPreset;
pub use error::AgentError;
pub use error::BackoffStrategy;
pub use error::ErrorRecovery;
pub use error::Result;
pub use hooks::HookRegistry;
pub use lifecycle::SessionEvent;
pub use lifecycle::SessionGuard;
pub use message_parser::MessageParseError;
pub use message_parser::ParsedMessage;
pub use message_parser::parse_message;
pub use message_parser::parse_message_str;
pub use plugin_resolver::DependencyResolver;
pub use plugin_resolver::PluginManifest;
pub use plugin_resolver::Version;
pub use plugins::Plugin;
pub use plugins::PluginLoader;
pub use plugins::PluginMetadata;
pub use plugins::SdkPluginConfig;
pub use retry::retry;
pub use retry::retry_with_recovery;
pub use routing::MessageRouter;
pub use sandbox::SandboxIgnoreViolations;
pub use sandbox::SandboxNetworkConfig;
pub use sandbox::SandboxSettings;
pub use session::AgentSession;
pub use session::QueryBuilder;
pub use session::SessionState;

Modules§

agent
Agent definitions
client
Main client for the Agent SDK
config
Agent SDK configuration
error
Error types for the Agent SDK
hooks
Hook system for agent event handling
lifecycle
Session lifecycle management with events and RAII cleanup
mcp
Model Context Protocol (MCP) integration for TurboClaude Agent.
message_parser
Message parsing for Claude Agent SDK protocol.
permissions
Permission evaluation for tool execution
plugin_resolver
Plugin dependency resolution and conflict detection
plugins
Plugin system for extending Claude Code with custom functionality
retry
Automatic retry logic with error recovery guidance
routing
Message router for protocol message handling
sandbox
Sandbox configuration types for agent isolation
session
Agent session for interactive conversations with Claude Code CLI
testing
Testing utilities for integration tests

Structs§

CompactionControl
Compaction control configuration
CompactionSummary
Summary of what was compacted
HookRequest
Hook event request from Claude Code CLI to client
HookResponse
Hook event response from client to Claude Code CLI
OutputConfig
Output configuration parameters
PermissionCheckRequest
Permission check request from Claude Code CLI to client
PermissionResponse
Permission response from client to Claude Code CLI

Enums§

CompactionResult
Result of a compaction operation
OutputEffort
Effort level for output generation