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