aios_agent/lib.rs
1//! # aios-agent — 决策路由与模型后端
2//!
3//! 接收 `StructuredContext`, 选择本地规则/本地模型/云端模型等后端,
4//! 并返回 `IntentBatch` 供 core 做最终审查。
5//!
6//! ## 模块结构
7//!
8//! - `DecisionBackend` trait — 统一的后端接口
9//! - `router` — DecisionRouter, RouterConfig, CircuitState, RoutingReason
10//! - `backends::rule_based` — 规则驱动的意图生成
11//! - `backends::fallback` — circuit breaker 熔断后的最终安全后端
12
13mod backends;
14mod router;
15
16pub use backends::fallback::FallbackNoOpBackend;
17pub use backends::rule_based::RuleBasedBackend;
18pub use router::{DecisionRouter, RouterConfig};
19
20use aios_spec::{DecisionBackendResult, StructuredContext};
21use uuid::Uuid;
22
23// ============================================================
24// DecisionBackend trait
25// ============================================================
26
27/// 统一的后端接口 — 接收 Context, 返回决策结果。
28///
29/// 所有后端(规则引擎、本地模型、云端 LLM、fallback)都实现此 trait。
30pub trait DecisionBackend {
31 fn evaluate(&self, context: &StructuredContext) -> DecisionBackendResult;
32}
33
34// ============================================================
35// Helpers
36// ============================================================
37
38fn new_id() -> String {
39 Uuid::new_v4().to_string()
40}