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
//! # Code Mesh Core
//!
//! **Code Mesh Core** is the foundational library for the Code Mesh AI coding assistant.
//! It provides a comprehensive set of abstractions and implementations for building
//! AI-powered development tools.
//!
//! ## Features
//!
//! - **🤖 Multi-LLM Support**: Unified interface for Anthropic Claude, OpenAI GPT, Google Gemini, and more
//! - **🛠️ Extensible Tool System**: Built-in tools for file operations, code execution, web search, and custom extensions
//! - **💾 Session Management**: Persistent conversation history with intelligent context management
//! - **🔐 Secure Authentication**: OAuth and API key support with encrypted credential storage
//! - **🌐 Cross-Platform**: Native performance with WebAssembly compatibility
//! - **🧠 Agent Orchestration**: Multi-agent coordination for complex coding workflows
//!
//! ## Quick Start
//!
//! ```rust
//! use code_mesh_core::{Session, LanguageModel, ProviderRegistry, ToolRegistry};
//! use tokio;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Initialize provider registry
//! let mut providers = ProviderRegistry::new();
//! providers.register_anthropic("your-api-key")?;
//!
//! // Create a new session
//! let mut session = Session::new();
//! session.add_user_message("Help me implement a binary search function");
//!
//! // Get a language model
//! let model = providers.get_model("anthropic/claude-3-opus")?;
//!
//! // Generate response
//! let response = model.complete(&session.build_prompt()).await?;
//! session.add_assistant_message(response);
//!
//! println!("Assistant: {}", session.last_message().content);
//! Ok(())
//! }
//! ```
//!
//! ## Architecture Overview
//!
//! Code Mesh Core is built around several key abstractions:
//!
//! ### Language Models ([`llm`] module)
//!
//! The [`LanguageModel`] trait provides a unified interface for interacting with different
//! AI providers. Implementations are available for major providers:
//!
//! - [`AnthropicProvider`] - Claude models via Anthropic API
//! - [`OpenAIProvider`] - GPT models via OpenAI API
//! - [`MistralProvider`] - Mistral models via Mistral AI API
//!
//! ### Tools ([`tool`] module)
//!
//! The [`Tool`] trait enables AI agents to interact with external systems:
//!
//! - [`FileTools`] - Read, write, and search files
//! - [`BashTool`] - Execute shell commands safely
//! - [`WebTool`] - Search the web and fetch documentation
//! - [`GitTool`] - Git operations and repository management
//!
//! ### Sessions ([`session`] module)
//!
//! Sessions manage conversation state and context:
//!
//! - [`Session`] - Core conversation management
//! - [`SessionManager`] - Persistence and retrieval
//! - [`Message`] - Individual conversation messages
//!
//! ### Authentication ([`auth`] module)
//!
//! Secure credential management for AI providers:
//!
//! - [`Auth`] - Authentication interface
//! - [`CredentialStore`] - Encrypted credential storage
//! - [`OAuthFlow`] - OAuth authentication flows
//!
//! ## Examples
//!
//! ### Multi-Provider Setup
//!
//! ```rust
//! use code_mesh_core::{ProviderRegistry, Provider};
//!
//! let mut registry = ProviderRegistry::new();
//!
//! // Add multiple providers
//! registry.register_anthropic("anthropic-key")?;
//! registry.register_openai("openai-key")?;
//! registry.register_mistral("mistral-key")?;
//!
//! // Use different models for different tasks
//! let planning_model = registry.get_model("anthropic/claude-3-opus")?;
//! let coding_model = registry.get_model("openai/gpt-4")?;
//! let testing_model = registry.get_model("mistral/mistral-large")?;
//! ```
//!
//! ### Tool Integration
//!
//! ```rust
//! use code_mesh_core::{ToolRegistry, FileTools, BashTool};
//!
//! let mut tools = ToolRegistry::new();
//! tools.register(Box::new(FileTools::new()));
//! tools.register(Box::new(BashTool::new()));
//!
//! // Tools can be used by AI agents
//! let context = ToolContext::new();
//! let result = tools.execute("read_file", &["src/main.rs"], &context).await?;
//! ```
//!
//! ### Session Persistence
//!
//! ```rust
//! use code_mesh_core::{SessionManager, Storage};
//!
//! let storage = Storage::new("./sessions")?;
//! let mut manager = SessionManager::new(storage);
//!
//! // Save session
//! let session_id = manager.save_session(&session).await?;
//!
//! // Load session later
//! let restored_session = manager.load_session(&session_id).await?;
//! ```
//!
//! ## Feature Flags
//!
//! Code Mesh Core supports conditional compilation based on target platform:
//!
//! - `native` (default): Full native functionality including file system access
//! - `wasm`: WebAssembly-compatible subset with browser APIs
//! - `openai`: OpenAI provider support
//! - `anthropic`: Anthropic provider support
//! - `mistral`: Mistral provider support
//!
//! ## Error Handling
//!
//! All public APIs use the [`Result`] type with [`Error`] for consistent error handling.
//! Errors are categorized by type and provide detailed context for debugging.
//!
//! ## Performance Considerations
//!
//! - **Async/Await**: All I/O operations are asynchronous for better performance
//! - **Connection Pooling**: HTTP clients use connection pooling for efficiency
//! - **Caching**: Intelligent caching of model responses and file contents
//! - **Memory Management**: Bounded memory usage with configurable limits
// Core modules
// Utility modules
// Generated prompts
// Re-export commonly used types
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// Error types
pub use ;
// Event system
pub use ;
// Synchronization primitives
pub use ;
// Version and build information
pub const VERSION: &str = env!;
/// Runtime compatibility layer