Skip to main content

echo_agent/
lib.rs

1#![doc = include_str!("../README.md")]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3
4extern crate self as echo_agent;
5
6// ── Core modules (always compiled) ──────────────────────────────────────────
7
8pub mod agent;
9pub mod audit;
10pub mod compression;
11pub mod config;
12pub mod error;
13pub mod guard;
14pub mod llm;
15pub mod memory;
16pub mod retry;
17pub mod sandbox;
18pub mod skills;
19#[cfg(any(test, feature = "testing"))]
20pub mod testing;
21pub mod tokenizer;
22pub mod tools;
23pub mod utils;
24pub mod workflow;
25
26// ── Optional modules (feature-gated) ────────────────────────────────────────
27
28#[cfg(feature = "a2a")]
29#[cfg_attr(docsrs, doc(cfg(feature = "a2a")))]
30pub mod a2a;
31
32#[cfg(feature = "channels")]
33#[cfg_attr(docsrs, doc(cfg(feature = "channels")))]
34pub mod channels;
35
36#[cfg(feature = "handoff")]
37#[cfg_attr(docsrs, doc(cfg(feature = "handoff")))]
38pub mod handoff;
39
40#[cfg(feature = "human-loop")]
41#[cfg_attr(docsrs, doc(cfg(feature = "human-loop")))]
42pub mod human_loop;
43
44#[cfg(feature = "mcp")]
45#[cfg_attr(docsrs, doc(cfg(feature = "mcp")))]
46pub mod mcp;
47
48#[cfg(feature = "tasks")]
49#[cfg_attr(docsrs, doc(cfg(feature = "tasks")))]
50pub mod tasks;
51
52#[cfg(feature = "telemetry")]
53#[cfg_attr(docsrs, doc(cfg(feature = "telemetry")))]
54pub mod telemetry;
55
56#[cfg(feature = "topology")]
57#[cfg_attr(docsrs, doc(cfg(feature = "topology")))]
58pub mod topology;
59
60#[cfg(feature = "project-rules")]
61pub use echo_core::project_rules;
62
63// ── Declarative macros ──────────────────────────────────────────────────────
64
65mod macros;
66
67// ── Procedural macro re-exports ─────────────────────────────────────────────
68
69pub use echo_macros::{
70    audit_logger, callback, compressor, guard, handler, permission_policy, tool,
71};
72
73/// Direct access to split workspace crates during migration.
74///
75/// This keeps `echo_agent` usable as a facade while still giving callers an
76/// explicit path to the underlying crate APIs when they need to avoid facade
77/// drift or migrate imports incrementally.
78pub mod workspace {
79    pub use echo_core as core;
80    pub use echo_execution as execution;
81    pub use echo_integration as integration;
82    pub use echo_orchestration as orchestration;
83    pub use echo_state as state;
84}
85
86// ── Prelude ─────────────────────────────────────────────────────────────────
87
88/// Common type re-exports.
89///
90/// Import everything with `use echo_agent::prelude::*`.
91pub mod prelude {
92    // Agent
93    pub use crate::agent::{
94        Agent, AgentCallback, AgentConfig, AgentEvent, AgentRole, CancellationToken, ReactAgent,
95        ReactAgentBuilder, Runner, StepType, StructuredAgent,
96    };
97    // Config
98    pub use crate::config::AppConfig;
99
100    /// Alias for backward compatibility.
101    #[allow(deprecated)]
102    pub type AgentBuilder = ReactAgentBuilder;
103
104    // LLM
105    pub use crate::llm::types::{ContentPart, ImageUrl, Message, MessageContent, ToolCall};
106    pub use crate::llm::{
107        AnthropicClient, ChatChunk, ChatRequest, ChatResponse, JsonSchemaSpec, LlmClient,
108        LlmConfig, LlmProvider, OllamaClient, OpenAiClient, ProviderFactory, ResponseFormat,
109        ToolDefinition,
110    };
111
112    // Tools
113    pub use crate::tools::builtin::think::ThinkTool;
114    pub use crate::tools::permission::{
115        DefaultPermissionPolicy, PermissionDecision, PermissionPolicy, ToolPermission,
116    };
117    pub use crate::tools::{Tool, ToolExecutionConfig, ToolParameters, ToolResult};
118
119    // Web Tools
120    #[cfg(feature = "web")]
121    #[cfg_attr(docsrs, doc(cfg(feature = "web")))]
122    pub use crate::tools::web::{WebFetchTool, WebSearchTool};
123
124    // Media Tools
125    #[cfg(feature = "media")]
126    #[cfg_attr(docsrs, doc(cfg(feature = "media")))]
127    pub use crate::tools::media::{ImageFetchTool, WebFetchToolEnhanced};
128
129    // Compression
130    pub use crate::compression::compressor::{
131        HybridCompressor, SlidingWindowCompressor, SummaryCompressor, default_summary_prompt,
132    };
133    pub use crate::compression::{
134        CompressionInput, CompressionOutput, ContextCompressor, ContextManager, ForceCompressStats,
135        PrepareResult,
136    };
137
138    // Tokenizer
139    pub use crate::tokenizer::{HeuristicTokenizer, SimpleTokenizer, Tokenizer};
140
141    // Memory
142    #[cfg(feature = "sqlite")]
143    #[cfg_attr(docsrs, doc(cfg(feature = "sqlite")))]
144    pub use crate::memory::SqliteStore;
145    pub use crate::memory::{
146        Checkpointer, Embedder, EmbeddingStore, FileCheckpointer, FileStore, HttpEmbedder,
147        InMemoryCheckpointer, InMemoryStore, SnapshotManager, SnapshotPolicy, StateSnapshot, Store,
148        StoreItem,
149    };
150
151    // Skills
152    pub use crate::skills::{
153        Skill, SkillInfo, SkillRegistry,
154        builtin::{FileSystemSkill, ShellSkill},
155        external::{
156            ActivateSkillTool, DiscoveryScope, PromptContext, ReadSkillResourceTool,
157            RunSkillScriptTool, SkillContent, SkillDescriptor, SkillLoader, SkillResourceEntry,
158            SkillResourceKind, SkillSource,
159        },
160        hooks::{HookAction, HookEvent, HookRegistry, HookResult, HookRule, HooksDefinition},
161    };
162
163    // Guard
164    #[cfg(feature = "content-guard")]
165    pub use crate::guard::llm::LlmGuard;
166    #[cfg(feature = "content-guard")]
167    pub use crate::guard::rule::{RuleGuard, RuleGuardBuilder};
168    pub use crate::guard::{Guard, GuardDirection, GuardManager, GuardResult};
169
170    // Audit
171    pub use crate::audit::{
172        AuditCallback, AuditEvent, AuditEventType, AuditFilter, AuditLogger, FileAuditLogger,
173        InMemoryAuditLogger,
174    };
175
176    // Workflow
177    pub use crate::workflow::{
178        ConcurrentWorkflow, DagWorkflow, Graph, GraphBuilder, GraphResult, SequentialWorkflow,
179        SharedAgent, SharedState, StepOutput, Workflow, WorkflowDefinition, WorkflowEvent,
180        WorkflowOutput, shared_agent,
181    };
182
183    // Sandbox
184    pub use crate::sandbox::{
185        DockerSandbox, ExecutionResult as SandboxResult, IsolationLevel, K8sSandbox, LocalSandbox,
186        ResourceLimits, SandboxCommand, SandboxExecutor, SandboxManager, SandboxPolicy,
187        SecurityLevel,
188    };
189
190    // Circuit Breaker
191    pub use echo_core::circuit_breaker::{CircuitBreaker, CircuitBreakerConfig};
192
193    // Retry
194    pub use crate::retry::{RetryPolicy, with_retry, with_retry_if};
195
196    // Error
197    pub use crate::error::Result;
198
199    // Testing
200    #[cfg(any(test, feature = "testing"))]
201    pub use crate::testing::{FailingMockAgent, MockAgent, MockEmbedder, MockLlmClient, MockTool};
202}
203
204/// Advanced type re-exports for optional modules (requires corresponding features).
205pub mod advanced {
206    #[cfg(feature = "human-loop")]
207    #[cfg_attr(docsrs, doc(cfg(feature = "human-loop")))]
208    pub use crate::human_loop::{
209        ApprovalDecision, ApprovalResponder, ConsoleHumanLoopProvider, HumanLoopEvent,
210        HumanLoopHandler, HumanLoopManager, HumanLoopProvider, HumanLoopRequest, HumanLoopResponse,
211        InputResponder, WebSocketHumanLoopProvider, WebhookHumanLoopProvider, dispatch_event,
212    };
213
214    #[cfg(feature = "mcp")]
215    #[cfg_attr(docsrs, doc(cfg(feature = "mcp")))]
216    pub use crate::mcp::{McpManager, McpServerConfig, McpTool, TransportConfig};
217
218    #[cfg(feature = "channels")]
219    #[cfg_attr(docsrs, doc(cfg(feature = "channels")))]
220    pub use crate::channels::AgentChannelHandler;
221
222    #[cfg(feature = "telemetry")]
223    #[cfg_attr(docsrs, doc(cfg(feature = "telemetry")))]
224    pub use crate::telemetry::{Metrics, TelemetryConfig, init_telemetry, shutdown_telemetry};
225
226    #[cfg(feature = "handoff")]
227    #[cfg_attr(docsrs, doc(cfg(feature = "handoff")))]
228    pub use crate::handoff::{
229        HandoffContext, HandoffManager, HandoffResult, HandoffTarget, HandoffTool,
230    };
231
232    #[cfg(feature = "plan-execute")]
233    #[cfg_attr(docsrs, doc(cfg(feature = "plan-execute")))]
234    pub use crate::agent::plan_execute::{
235        ExecutionMode, Executor, LlmPlanner, Plan, PlanExecuteAgent, PlanStep, Planner,
236        ReactExecutor, SimpleExecutor, StaticPlanner, StepResult, StepStatus,
237    };
238
239    #[cfg(feature = "a2a")]
240    #[cfg_attr(docsrs, doc(cfg(feature = "a2a")))]
241    pub use crate::a2a::{
242        A2AClient, A2AServer, A2AStreamEvent, AgentCapabilities, AgentCard, AgentProvider,
243        AgentSkill, JwtClaims, JwtConfig, TaskState, get_claims, serve, serve_from_config,
244        serve_from_config_with_auth, serve_with_auth,
245    };
246
247    #[cfg(feature = "topology")]
248    #[cfg_attr(docsrs, doc(cfg(feature = "topology")))]
249    pub use crate::topology::{
250        NodeType, TopologyCallback, TopologyData, TopologyEdge, TopologyNode, TopologyStats,
251        TopologyTracker,
252    };
253
254    #[cfg(feature = "tasks")]
255    #[cfg_attr(docsrs, doc(cfg(feature = "tasks")))]
256    pub use crate::tasks::{Task, TaskManager, TaskStatus};
257
258    #[cfg(feature = "self-reflection")]
259    #[cfg_attr(docsrs, doc(cfg(feature = "self-reflection")))]
260    pub use crate::agent::self_reflection::{
261        CompositeCritic, CompositeStrategy, Critic, Critique, CritiqueOutput,
262        InMemoryReflectionStore, LlmCritic, ReflectionExperience, ReflectionRecord,
263        ReflectionStore, SelfReflectionAgent, StaticCritic, ThresholdCritic,
264        critique_output_schema, default_refinement_prompt, default_reflection_prompt,
265    };
266
267    #[cfg(all(feature = "self-reflection", feature = "plan-execute"))]
268    pub use crate::agent::self_reflection::ReflectiveExecutor;
269}