Skip to main content

astrid_runtime/
lib.rs

1//! Astrid Runtime - Agent orchestration and session management.
2//!
3//! This crate provides:
4//! - Agent runtime with LLM, MCP, and security integration
5//! - Session management with persistence
6//! - Context management with auto-summarization
7//!
8//! # Architecture
9//!
10//! The runtime coordinates:
11//! - LLM provider for language model interactions
12//! - MCP client for tool execution
13//! - Capability store for authorization
14//! - Audit log for security logging
15//!
16//! # Example
17//!
18//! ```rust,no_run
19//! use astrid_runtime::{AgentRuntime, RuntimeConfig, SessionStore};
20//! use astrid_llm::{ClaudeProvider, ProviderConfig};
21//! use astrid_mcp::McpClient;
22//! use astrid_audit::AuditLog;
23//! use astrid_crypto::KeyPair;
24//!
25//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
26//! // Create components
27//! let llm = ClaudeProvider::new(ProviderConfig::new("api-key", "claude-sonnet-4-20250514"));
28//! let mcp = McpClient::from_default_config()?;
29//! let audit_key = KeyPair::generate();
30//! let runtime_key = KeyPair::generate();
31//! let audit = AuditLog::in_memory(audit_key);
32//! let home = astrid_core::dirs::AstridHome::resolve()?;
33//! let sessions = SessionStore::from_home(&home);
34//!
35//! // Create runtime
36//! let runtime = AgentRuntime::new(
37//!     llm,
38//!     mcp,
39//!     audit,
40//!     sessions,
41//!     runtime_key,
42//!     RuntimeConfig::default(),
43//! );
44//!
45//! // Create a session
46//! let mut session = runtime.create_session(None);
47//!
48//! // Run a turn (would need a Frontend implementation)
49//! // runtime.run_turn_streaming(&mut session, "Hello!", &frontend).await?;
50//! # Ok(())
51//! # }
52//! ```
53
54#![deny(unsafe_code)]
55#![deny(missing_docs)]
56#![deny(clippy::all)]
57#![warn(unreachable_pub)]
58#![deny(clippy::unwrap_used)]
59#![cfg_attr(test, allow(clippy::unwrap_used))]
60
61pub mod config_bridge;
62pub mod prelude;
63
64mod context;
65mod error;
66mod runtime;
67mod session;
68mod store;
69pub mod subagent;
70pub mod subagent_executor;
71
72pub use context::{ContextManager, ContextStats, SummarizationResult};
73pub use error::{RuntimeError, RuntimeResult};
74pub use runtime::{AgentRuntime, RuntimeConfig};
75pub use session::{AgentSession, GitState, SerializableSession, SessionMetadata};
76pub use store::{SessionStore, SessionSummary};
77pub use subagent::{SubAgentHandle, SubAgentId, SubAgentPool, SubAgentPoolStats, SubAgentStatus};
78pub use subagent_executor::SubAgentExecutor;
79
80// Re-export workspace types for convenience
81pub use astrid_workspace::{self, WorkspaceBoundary, WorkspaceConfig, WorkspaceMode};
82
83// Re-export tools types for convenience
84pub use astrid_tools::{self, SparkConfig, ToolContext, ToolRegistry, build_system_prompt};