refactor(agent): rename metadata fields and enhance task configuration

- Rename 'metadata' columns to 'event_metadata' and 'finding_metadata' for clarity in database schema.
- Update AgentRunner to construct task configuration from task fields, ensuring default values are applied.
- Improve UI to handle potential null values for progress percentage and security score, enhancing user experience.
This commit is contained in:
lintsinghua 2025-12-11 19:23:21 +08:00
parent a33f60bd44
commit 129112e4d7
3 changed files with 9 additions and 9 deletions

View File

@ -128,7 +128,7 @@ def upgrade() -> None:
sa.Column('tokens_used', sa.Integer(), default=0),
# 元数据
sa.Column('metadata', sa.JSON(), nullable=True),
sa.Column('event_metadata', sa.JSON(), nullable=True),
# 序号
sa.Column('sequence', sa.Integer(), default=0),
@ -211,7 +211,7 @@ def upgrade() -> None:
sa.Column('cvss_vector', sa.String(100), nullable=True),
# 元数据
sa.Column('metadata', sa.JSON(), nullable=True),
sa.Column('finding_metadata', sa.JSON(), nullable=True),
sa.Column('tags', sa.JSON(), nullable=True),
# 去重标识

View File

@ -98,8 +98,8 @@ class AgentRunner:
self.project_root = project_root
# 事件管理
self.event_manager = EventManager(db, task.id)
self.event_emitter = AgentEventEmitter(self.event_manager)
self.event_manager = EventManager()
self.event_emitter = AgentEventEmitter(task.id, self.event_manager)
# LLM 服务
self.llm_service = LLMService()

View File

@ -345,10 +345,10 @@ export default function AgentAuditPage() {
<div className="w-32 h-2 bg-gray-800 rounded-full overflow-hidden">
<div
className="h-full bg-gradient-to-r from-cyan-600 to-cyan-400 transition-all duration-300"
style={{ width: `${task.progress_percentage}%` }}
style={{ width: `${task.progress_percentage ?? 0}%` }}
/>
</div>
<span className="text-xs text-cyan-400">{task.progress_percentage.toFixed(0)}%</span>
<span className="text-xs text-cyan-400">{(task.progress_percentage ?? 0).toFixed(0)}%</span>
</div>
{/* Token 消耗 */}
@ -438,11 +438,11 @@ export default function AgentAuditPage() {
<div className="flex items-center justify-between text-xs">
<span className="text-gray-500"></span>
<span className={`font-bold ${
task.security_score >= 80 ? "text-green-400" :
task.security_score >= 60 ? "text-yellow-400" :
(task.security_score ?? 0) >= 80 ? "text-green-400" :
(task.security_score ?? 0) >= 60 ? "text-yellow-400" :
"text-red-400"
}`}>
{task.security_score.toFixed(0)}/100
{(task.security_score ?? 0).toFixed(0)}/100
</span>
</div>
<div className="flex items-center justify-between text-xs">