feat(runtime): DeerFlow 模式中间件链 Phase 1-4 全部完成
借鉴 DeerFlow 架构,实现完整中间件链系统: Phase 1 - Agent 中间件链基础设施 - MiddlewareChain Clone 支持 - LoopRunner 双路径集成 (middleware/legacy) - Kernel create_middleware_chain() 工厂方法 Phase 2 - 技能按需注入 - SkillIndexMiddleware (priority 200) - SkillLoadTool 工具 - SkillDetail/SkillIndexEntry 结构体 - KernelSkillExecutor trait 扩展 Phase 3 - Guardrail 安全护栏 - GuardrailMiddleware (priority 400, fail_open) - ShellExecRule / FileWriteRule / WebFetchRule Phase 4 - 记忆闭环统一 - MemoryMiddleware (priority 150, 30s 防抖) - after_completion 双路径调用 中间件注册顺序: 100 Compaction | 150 Memory | 200 SkillIndex 400 Guardrail | 500 LoopGuard | 700 TokenCalibration 向后兼容:Option<MiddlewareChain> 默认 None 走旧路径
This commit is contained in:
@@ -37,6 +37,39 @@ pub trait SkillExecutor: Send + Sync {
|
||||
session_id: &str,
|
||||
input: Value,
|
||||
) -> Result<Value>;
|
||||
|
||||
/// Return metadata for on-demand skill loading.
|
||||
/// Default returns `None` (skill detail not available).
|
||||
fn get_skill_detail(&self, skill_id: &str) -> Option<SkillDetail> {
|
||||
let _ = skill_id;
|
||||
None
|
||||
}
|
||||
|
||||
/// Return lightweight index of all available skills.
|
||||
/// Default returns empty (no index available).
|
||||
fn list_skill_index(&self) -> Vec<SkillIndexEntry> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
/// Lightweight skill index entry for system prompt injection.
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
pub struct SkillIndexEntry {
|
||||
pub id: String,
|
||||
pub description: String,
|
||||
pub triggers: Vec<String>,
|
||||
}
|
||||
|
||||
/// Full skill detail returned by `skill_load` tool.
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
pub struct SkillDetail {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub category: Option<String>,
|
||||
pub input_schema: Option<Value>,
|
||||
pub triggers: Vec<String>,
|
||||
pub capabilities: Vec<String>,
|
||||
}
|
||||
|
||||
/// Context provided to tool execution
|
||||
|
||||
Reference in New Issue
Block a user