feat: 添加多代理系统和 Task 子任务功能

Agent 模块:
- types.ts: Agent 类型定义 (AgentInfo, AgentPermission 等)
- permission-merger.ts: 三级权限合并逻辑 (系统->全局->Agent)
- config-loader.ts: 支持 YAML/JSON 配置文件加载
- registry.ts: Agent 注册表,管理预设和自定义 Agent
- executor.ts: Agent 执行器,支持工具过滤和权限控制
- presets/: 预设 Agent (general, explore, code-reviewer, build, plan)

Task 工具:
- task.ts: 执行子任务,委派给指定 Agent 处理
- 支持子会话创建和管理

会话扩展:
- 支持父子会话关系 (parentId, agentName)
- 新增 createChildSession, saveChildSession 方法

配置:
- 支持 .ai-assist/agents.yaml 用户自定义 Agent
- 支持通配符模式的 Bash 权限规则
This commit is contained in:
2025-12-11 11:21:08 +08:00
parent c6f8ba95ec
commit 82f0a0ccde
22 changed files with 1600 additions and 2 deletions
+5
View File
@@ -8,6 +8,9 @@ import { bashTool } from './shell/index.js';
import { toolSearchTool } from './tool-search.js';
import { todoReadTool, todoWriteTool } from './todo/index.js';
// Task 工具(Agent 子任务)
import { taskTool } from './task/index.js';
// 文件系统工具
import {
readFileTool,
@@ -47,6 +50,7 @@ const allToolsWithMetadata: ToolWithMetadata[] = [
bashTool,
todoReadTool,
todoWriteTool,
taskTool,
// 文件系统工具 (deferLoading: true)
readFileTool,
@@ -85,6 +89,7 @@ toolRegistry.registerAll(allToolsWithMetadata);
export { toolRegistry } from './registry.js';
export { toolSearchTool } from './tool-search.js';
export { todoManager } from './todo/index.js';
export { initTaskContext, updateTaskDescription } from './task/index.js';
export type { ToolWithMetadata, ToolMetadata, ToolCategory, ToolSearchResult } from './types.js';
// 兼容旧代码:导出所有工具数组(基础 Tool 类型)