feat(agents): Phase 6 tool system refactoring

Phase 6.1: ToolRegistry infrastructure
- Add ToolManifest with ToolCategory, PermissionClass, SideEffectScope
- Add ToolRegistry singleton with register/get/unregister/list/search
- Add BaseTool abstract class with ReadTool/WriteTool/DBWriteTool/ExternalTool/NetworkTool subclasses
- Add migration layer for backward compatibility

Phase 6.2: Hook interception system
- Add HookType (PRE_TOOL_USE, POST_TOOL_USE, TOOL_ERROR, TOOL_SKIP)
- Add HookManager with singleton for hook registration
- Add HookExecutor for pre/post/error hook execution

Phase 6.3: Streaming execution
- Add StreamingToolExecutor with batch execution support

Phase 6.4: New builtin tools
- Add file_tools: GlobTool, GrepTool, ReadFileTool, WriteFileTool
- Add system_tools: BashTool, PowerShellTool
- Add dev_tools: LSPTools, GitTool
- Add collaboration_tools: TeamAgentTool, TaskBroadcastTool

Tests: 29 passed
This commit is contained in:
2026-04-04 22:47:48 +08:00
parent a7b6b5eb90
commit e5bd492d74
16 changed files with 2541 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
from app.agents.tools.search import (
search_knowledge, get_knowledge_graph_context,
build_knowledge_graph, hybrid_search, web_search,
search_knowledge,
get_knowledge_graph_context,
build_knowledge_graph,
hybrid_search,
web_search,
)
from app.agents.tools.task import get_tasks, create_task, update_task_status
from app.agents.tools.forum import get_forum_posts, create_forum_post, scan_forum_for_instructions
@@ -13,6 +16,58 @@ from app.agents.tools.schedule import (
)
from app.agents.tools.time_reasoning import resolve_time_expression
# Phase 6.1: Tool Registry exports
from app.agents.tools.registry import (
ToolRegistry,
get_tool_registry,
reset_tool_registry,
)
from app.agents.tools.manifest import (
HookConfig,
PermissionClass,
SideEffectScope,
ToolCategory,
ToolManifest,
)
from app.agents.tools.migration import (
migrate_tool,
migrate_all_tools,
get_tool_executor,
BackwardCompatTool,
)
# Phase 6.2: Hook System exports
from app.agents.tools.hooks import (
HookManager,
HookExecutor,
HookType,
HookDefinition,
HookResult,
ExecutionContext,
get_hook_manager,
get_hook_executor,
)
# Phase 6.3: Streaming Executor exports
from app.agents.tools.streaming import (
StreamingToolExecutor,
get_streaming_executor,
)
# Phase 6.4: Builtin Tools exports
from app.agents.tools.builtins import (
GlobTool,
GrepTool,
ReadFileTool,
WriteFileTool,
BashTool,
PowerShellTool,
LSPTools,
GitTool,
TeamAgentTool,
TaskBroadcastTool,
)
TASK_TOOLS = [
get_tasks,
create_task,