Skip to main content

sage_runtime/
lib.rs

1//! Runtime library for compiled Sage programs.
2//!
3//! This crate provides the types and functions that generated Rust code
4//! depends on. It handles:
5//!
6//! - Agent spawning and lifecycle
7//! - Message passing between agents
8//! - LLM inference calls
9//! - RFC-0011: Tool execution (Http, Fs, etc.)
10//! - RFC-0012: Mock infrastructure for testing
11//! - Tracing and observability
12//! - Error handling
13//! - v2.0: Persistence for @persistent agent beliefs
14//! - v2.0: Supervision trees for agent lifecycle management
15//! - Phase 3: Session types for protocol verification
16
17#![forbid(unsafe_code)]
18
19mod agent;
20mod error;
21mod llm;
22pub mod mock;
23pub mod persistence;
24pub mod session;
25pub mod stdlib;
26pub mod supervisor;
27pub mod tools;
28pub mod tracing;
29
30pub use agent::{spawn, spawn_with_llm_config, AgentContext, AgentHandle, Message};
31pub use error::{ErrorKind, SageError, SageResult};
32pub use llm::{LlmClient, LlmConfig};
33pub use mock::{try_get_mock, with_mock_tools, MockLlmClient, MockQueue, MockResponse, MockToolRegistry};
34pub use persistence::{CheckpointStore, Persisted};
35pub use session::{
36    ProtocolStateMachine, ProtocolViolation, SenderHandle, SessionId, SessionRegistry,
37    SessionState, SharedSessionRegistry,
38};
39pub use supervisor::{RestartConfig, RestartPolicy, Strategy, Supervisor};
40pub use tools::{DatabaseClient, DbRow, FsClient, HttpClient, HttpResponse, ShellClient, ShellResult};
41pub use tracing as trace;
42
43/// Prelude for generated code.
44pub mod prelude {
45    pub use crate::agent::{spawn, spawn_with_llm_config, AgentContext, AgentHandle, Message};
46    pub use crate::error::{ErrorKind, SageError, SageResult};
47    pub use crate::llm::{LlmClient, LlmConfig};
48    pub use crate::mock::{try_get_mock, with_mock_tools, MockLlmClient, MockQueue, MockResponse, MockToolRegistry};
49    pub use crate::persistence::{CheckpointStore, Persisted};
50    pub use crate::session::{
51        ProtocolStateMachine, ProtocolViolation, SenderHandle, SessionId, SessionRegistry,
52        SessionState, SharedSessionRegistry,
53    };
54    pub use crate::supervisor::{RestartConfig, RestartPolicy, Strategy, Supervisor};
55    pub use crate::tools::{DatabaseClient, DbRow, FsClient, HttpClient, HttpResponse, ShellClient, ShellResult};
56    pub use crate::tracing as trace;
57}