feat(agent): implement comprehensive agent architecture with knowledge base and persistence layer
- Add database migrations for agent checkpoints and tree node tracking
- Implement core agent execution framework with executor, state management, and message handling
- Create knowledge base system with framework-specific modules (Django, FastAPI, Flask, Express, React, Supabase)
- Add vulnerability knowledge modules covering authentication, cryptography, injection, XSS, XXE, SSRF, path traversal, deserialization, and race conditions
- Introduce new agent tools: thinking tool, reporting tool, and agent-specific utilities
- Implement LLM memory compression and prompt caching for improved performance
- Add agent registry and persistence layer for checkpoint management
- Refactor agent implementations (analysis, recon, verification, orchestrator) with enhanced capabilities
- Remove legacy agent implementations (analysis_v2, react_agent)
- Update API endpoints for agent task creation and project management
- Add frontend components for agent task creation and enhanced audit UI
- Consolidate agent service architecture with improved separation of concerns
- This refactoring provides a scalable foundation for multi-agent collaboration with knowledge-driven decision making and state persistence
2025-12-12 15:27:12 +08:00
|
|
|
|
"""
|
|
|
|
|
|
LLM 服务模块
|
|
|
|
|
|
|
|
|
|
|
|
提供统一的 LLM 调用接口,支持:
|
|
|
|
|
|
- 多提供商支持(OpenAI, Claude, Gemini, DeepSeek 等)
|
|
|
|
|
|
- Prompt Caching(减少 Token 消耗)
|
|
|
|
|
|
- Memory Compression(对话历史压缩)
|
|
|
|
|
|
- 流式输出
|
|
|
|
|
|
- 智能重试
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
from .service import LLMService
|
|
|
|
|
|
from .types import (
|
|
|
|
|
|
LLMConfig,
|
|
|
|
|
|
LLMProvider,
|
|
|
|
|
|
LLMMessage,
|
|
|
|
|
|
LLMRequest,
|
|
|
|
|
|
LLMResponse,
|
|
|
|
|
|
LLMUsage,
|
|
|
|
|
|
LLMError,
|
|
|
|
|
|
)
|
|
|
|
|
|
from .prompt_cache import (
|
|
|
|
|
|
PromptCacheManager,
|
|
|
|
|
|
CacheConfig,
|
|
|
|
|
|
CacheStrategy,
|
|
|
|
|
|
CacheStats,
|
|
|
|
|
|
prompt_cache_manager,
|
|
|
|
|
|
estimate_tokens,
|
|
|
|
|
|
)
|
|
|
|
|
|
from .memory_compressor import MemoryCompressor
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = [
|
|
|
|
|
|
# Service
|
|
|
|
|
|
"LLMService",
|
|
|
|
|
|
# Types
|
|
|
|
|
|
"LLMConfig",
|
|
|
|
|
|
"LLMProvider",
|
|
|
|
|
|
"LLMMessage",
|
|
|
|
|
|
"LLMRequest",
|
|
|
|
|
|
"LLMResponse",
|
|
|
|
|
|
"LLMUsage",
|
|
|
|
|
|
"LLMError",
|
|
|
|
|
|
# Prompt Cache
|
|
|
|
|
|
"PromptCacheManager",
|
|
|
|
|
|
"CacheConfig",
|
|
|
|
|
|
"CacheStrategy",
|
|
|
|
|
|
"CacheStats",
|
|
|
|
|
|
"prompt_cache_manager",
|
|
|
|
|
|
"estimate_tokens",
|
|
|
|
|
|
# Memory Compression
|
|
|
|
|
|
"MemoryCompressor",
|
|
|
|
|
|
]
|