Skip to main content

oxi_agent/
lib.rs

1#![allow(unused_doc_comments)]
2#![warn(missing_docs)]
3#![warn(clippy::unwrap_used)]
4#![allow(unknown_lints)]
5
6//! oxi-agent: Agent runtime for oxi
7//!
8//! Provides the core agent loop, tool execution, state management,
9//! and streaming event pipeline for the oxi coding agent.
10
11/// Core agent implementation.
12pub mod agent;
13/// Agent loop – the main request/response cycle driver.
14pub mod agent_loop;
15/// Context compaction strategies and data types.
16pub mod compaction;
17/// Agent configuration types.
18pub mod config;
19/// Error types for agent operations.
20pub mod error;
21/// Event types emitted during the agent loop.
22pub mod events;
23/// MCP (Model Context Protocol) integration.
24pub mod mcp;
25/// Model identifier constants and helpers.
26pub mod model_id;
27/// Fault-recovery primitives (circuit breaker, fallback chains).
28pub mod recovery;
29/// Agent state machine and shared mutable state.
30pub mod state;
31/// Shared streaming retry logic.
32pub mod stream_retry;
33pub mod structured_output;
34/// Built-in tool implementations and registry.
35pub mod tools;
36/// Shared type aliases and helpers.
37pub mod types;
38
39pub use agent::Agent;
40pub use agent::ProviderResolver;
41pub use agent_loop::{AgentLoop, AgentLoopConfig};
42
43/// Agent configuration, hooks, and tool execution mode.
44pub use config::{
45    AfterToolCallContext, AfterToolCallResult, AgentConfig, AgentHooks, BeforeToolCallContext,
46    BeforeToolCallResult, ShouldStopAfterTurnContext, ToolExecutionMode,
47};
48pub use error::AgentError;
49pub use events::AgentEvent;
50
51pub use compaction::{CompactedContext, CompactionEvent};
52pub use oxi_ai::{CompactionManager, CompactionStrategy};
53/// Fault-recovery primitives for resilient agent execution.
54pub use recovery::{
55    CircuitBreaker, CircuitBreakerConfig, CircuitOpenError as CircuitOpenErrorFromAi,
56    FallbackChain, PartialResponse,
57};
58// Also export the local circuit error type used by CircuitBreaker
59pub use recovery::CircuitOpenErrorLocal;
60pub use state::{AgentState, SharedState};
61pub use structured_output::{OutputMode, StructuredOutput, StructuredOutputError};
62
63pub use mcp::{McpConfig, McpManager, McpTool};
64pub use tools::context7::{Context7QueryDocsTool, Context7ResolveLibraryIdTool};
65pub use tools::github::GitHubTool;
66pub use tools::github_search::GitHubSearchTool;
67pub use tools::questionnaire::{QuestionnaireBridge, QuestionnaireTool};
68pub use tools::search_cache::{GetSearchResultsTool, SearchCache};
69pub use tools::subagent::SubagentTool;
70pub use tools::web_search::WebSearchTool;
71/// Built-in tool implementations and registry.
72pub use tools::{
73    AgentTool, AgentToolResult, BashTool, EditTool, FindTool, GrepTool, LsTool, ReadTool,
74    ToolContext, ToolError, ToolRegistry, WriteTool,
75};
76
77/// Standard imports for oxi-agent usage.
78pub mod prelude {
79    pub use crate::agent::Agent;
80    pub use crate::agent_loop::{AgentLoop, AgentLoopConfig, ToolExecutionMode};
81    pub use crate::compaction::{CompactedContext, CompactionEvent};
82    pub use crate::config::AgentConfig;
83    pub use crate::events::AgentEvent;
84    pub use crate::mcp::{McpConfig, McpManager, McpTool};
85    pub use crate::state::{AgentState, SharedState};
86    pub use crate::tools::context7::{Context7QueryDocsTool, Context7ResolveLibraryIdTool};
87    pub use crate::tools::github::GitHubTool;
88    pub use crate::tools::github_search::GitHubSearchTool;
89    pub use crate::tools::questionnaire::{QuestionnaireBridge, QuestionnaireTool};
90    pub use crate::tools::search_cache::{GetSearchResultsTool, SearchCache};
91    pub use crate::tools::subagent::SubagentTool;
92    pub use crate::tools::web_search::WebSearchTool;
93    pub use crate::tools::{
94        AgentTool, AgentToolResult, BashTool, EditTool, FindTool, GrepTool, LsTool, ReadTool,
95        ToolContext, ToolRegistry, WriteTool,
96    };
97}
98
99#[cfg(test)]
100mod tests;