1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
//! # Composio Rust SDK
//!
//! A minimal, type-safe Rust SDK for the Composio Tool Router REST API.
//!
//! This SDK enables ZeroClaw and other Rust applications to interact with external services
//! through Composio's Tool Router API, providing session management, tool execution,
//! and authentication handling with a minimal memory footprint (~2 MB).
//!
//! ## Features
//!
//! - **Session Management**: Create and manage Tool Router sessions for users
//! - **Tool Execution**: Execute tools and meta tools with automatic retry logic
//! - **Type Safety**: Comprehensive type definitions for all API requests and responses
//! - **Error Handling**: Detailed error types with actionable error messages
//! - **Async/Await**: Built on tokio for efficient async operations
//! - **Memory Efficient**: Minimal memory footprint suitable for resource-constrained environments
//!
//! ## Quick Start
//!
//! ```no_run
//! use composio_sdk::{ComposioClient, MetaToolSlug};
//! use serde_json::json;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Initialize client with API key
//! let client = ComposioClient::builder()
//! .api_key(std::env::var("COMPOSIO_API_KEY")?)
//! .build()?;
//!
//! // Create a session for a user
//! let session = client
//! .create_session("user_123")
//! .toolkits(vec!["github", "gmail"])
//! .manage_connections(true)
//! .send()
//! .await?;
//!
//! println!("Session ID: {}", session.session_id());
//! println!("MCP URL: {}", session.mcp_url());
//!
//! // Execute a tool
//! let result = session
//! .execute_tool(
//! "GITHUB_CREATE_ISSUE",
//! json!({
//! "owner": "composio",
//! "repo": "composio",
//! "title": "Test issue",
//! "body": "Created via Rust SDK"
//! })
//! )
//! .await?;
//!
//! println!("Result: {:?}", result.data);
//!
//! // Execute a meta tool
//! let search_result = session
//! .execute_meta_tool(
//! MetaToolSlug::ComposioSearchTools,
//! json!({
//! "query": "create a GitHub issue"
//! })
//! )
//! .await?;
//!
//! println!("Search result: {:?}", search_result.data);
//!
//! Ok(())
//! }
//! ```
//!
//! ## Session Configuration
//!
//! Sessions can be configured with various options:
//!
//! ```no_run
//! # use composio_sdk::ComposioClient;
//! # async fn example(client: ComposioClient) -> Result<(), Box<dyn std::error::Error>> {
//! let session = client
//! .create_session("user_123")
//! .toolkits(vec!["github", "gmail"]) // Enable specific toolkits
//! .disable_toolkits(vec!["exa", "firecrawl"]) // Or disable specific toolkits
//! .auth_config("github", "ac_custom_config") // Use custom auth config
//! .connected_account("gmail", "ca_work_email") // Select specific account
//! .manage_connections(true) // Enable in-chat auth
//! .send()
//! .await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Error Handling
//!
//! The SDK provides comprehensive error handling:
//!
//! ```no_run
//! # use composio_sdk::{ComposioClient, ComposioError};
//! # use serde_json::json;
//! # async fn example(client: ComposioClient) -> Result<(), Box<dyn std::error::Error>> {
//! # let session = client.create_session("user_123").send().await?;
//! match session.execute_tool("INVALID_TOOL", json!({})).await {
//! Ok(result) => println!("Success: {:?}", result),
//! Err(ComposioError::ApiError { status, message, suggested_fix, .. }) => {
//! eprintln!("API error ({}): {}", status, message);
//! if let Some(fix) = suggested_fix {
//! eprintln!("Suggested fix: {}", fix);
//! }
//! }
//! Err(ComposioError::NetworkError(e)) => {
//! eprintln!("Network error: {}", e);
//! }
//! Err(e) => {
//! eprintln!("Other error: {}", e);
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Configuration
//!
//! Customize SDK behavior with [`ComposioConfig`]:
//!
//! ```no_run
//! use composio_sdk::ComposioClient;
//! use std::time::Duration;
//!
//! let client = ComposioClient::builder()
//! .api_key("your-api-key")
//! .base_url("https://backend.composio.dev/api/v3")
//! .timeout(Duration::from_secs(60))
//! .max_retries(5)
//! .build()?;
//! # Ok::<(), composio_sdk::ComposioError>(())
//! ```
// ============================================================================
// Module Declarations
// ============================================================================
/// Client implementation for the Composio API
/// Configuration types for the SDK
/// Error types and error handling utilities
/// Data models for API requests and responses
/// Retry logic and exponential backoff utilities
/// Session management and tool execution
/// Wizard instruction generation from Composio Skills
/// Skills integration for copying and managing Composio Skills
/// Meta tools - Native Rust implementations
// ============================================================================
// Core Client and Configuration
// ============================================================================
/// Main client for interacting with the Composio API
pub use ComposioClient;
/// Builder for constructing a [`ComposioClient`] with custom configuration
pub use ComposioClientBuilder;
/// Configuration for the Composio SDK
pub use ComposioConfig;
// ============================================================================
// Session Management
// ============================================================================
/// A Tool Router session for a specific user
pub use Session;
/// Builder for constructing a session with custom configuration
pub use SessionBuilder;
// ============================================================================
// Error Types
// ============================================================================
/// Main error type for the SDK
pub use ComposioError;
/// Detailed error information from API error responses
pub use ErrorDetail;
// ============================================================================
// Request Models
// ============================================================================
/// Configuration for creating a Tool Router session
pub use SessionConfig;
/// Toolkit filter for enabling or disabling specific toolkits
pub use ToolkitFilter;
/// Configuration for per-toolkit tool filtering
pub use ToolsConfig;
/// Tool filter for a specific toolkit
pub use ToolFilter;
/// Configuration for tag-based tool filtering
pub use TagsConfig;
/// Configuration for workbench execution
pub use WorkbenchConfig;
/// Request to execute a tool
pub use ToolExecutionRequest;
/// Request to execute a meta tool
pub use MetaToolExecutionRequest;
/// Request to create an authentication link
pub use LinkRequest;
// ============================================================================
// Response Models
// ============================================================================
/// Response from session creation
pub use SessionResponse;
/// MCP server information
pub use McpInfo;
/// Tool schema information
pub use ToolSchema;
/// Response from tool execution
pub use ToolExecutionResponse;
/// Response from meta tool execution
pub use MetaToolExecutionResponse;
/// Response from listing toolkits
pub use ToolkitListResponse;
/// Information about a toolkit
pub use ToolkitInfo;
/// Metadata about a toolkit
pub use ToolkitMeta;
/// Information about a connected account
pub use ConnectedAccountInfo;
/// Response from creating an auth link
pub use LinkResponse;
/// Error response from API
pub use ErrorResponse;
// ============================================================================
// Enums
// ============================================================================
/// Meta tool slugs for the 5 core Composio meta tools
pub use MetaToolSlug;
/// Tag types for filtering tools by behavior hints
pub use TagType;
/// Authentication schemes supported by toolkits
pub use AuthScheme;
// ============================================================================
// Wizard Module (Skills Integration)
// ============================================================================
/// Wizard instruction generation utilities
///
/// This module provides tools for extracting Composio Skills content and
/// generating wizard instructions for AI agents based on official best practices.
///
/// See the [`wizard`] module documentation for detailed usage examples.
pub use ;
// ============================================================================
// Skills Integration Module
// ============================================================================
/// Skills integration error types and utilities
///
/// This module provides error handling for Skills integration operations,
/// including file I/O errors, YAML parsing errors, validation failures,
/// and security violations.
///
/// See the [`skills_integration`] module documentation for detailed usage examples.
pub use ;