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:
parent
a33f60bd44
commit
129112e4d7
|
|
@ -128,7 +128,7 @@ def upgrade() -> None:
|
||||||
sa.Column('tokens_used', sa.Integer(), default=0),
|
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),
|
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('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),
|
sa.Column('tags', sa.JSON(), nullable=True),
|
||||||
|
|
||||||
# 去重标识
|
# 去重标识
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,8 @@ class AgentRunner:
|
||||||
self.project_root = project_root
|
self.project_root = project_root
|
||||||
|
|
||||||
# 事件管理
|
# 事件管理
|
||||||
self.event_manager = EventManager(db, task.id)
|
self.event_manager = EventManager()
|
||||||
self.event_emitter = AgentEventEmitter(self.event_manager)
|
self.event_emitter = AgentEventEmitter(task.id, self.event_manager)
|
||||||
|
|
||||||
# LLM 服务
|
# LLM 服务
|
||||||
self.llm_service = LLMService()
|
self.llm_service = LLMService()
|
||||||
|
|
|
||||||
|
|
@ -345,10 +345,10 @@ export default function AgentAuditPage() {
|
||||||
<div className="w-32 h-2 bg-gray-800 rounded-full overflow-hidden">
|
<div className="w-32 h-2 bg-gray-800 rounded-full overflow-hidden">
|
||||||
<div
|
<div
|
||||||
className="h-full bg-gradient-to-r from-cyan-600 to-cyan-400 transition-all duration-300"
|
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>
|
</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>
|
</div>
|
||||||
|
|
||||||
{/* Token 消耗 */}
|
{/* Token 消耗 */}
|
||||||
|
|
@ -438,11 +438,11 @@ export default function AgentAuditPage() {
|
||||||
<div className="flex items-center justify-between text-xs">
|
<div className="flex items-center justify-between text-xs">
|
||||||
<span className="text-gray-500">安全评分</span>
|
<span className="text-gray-500">安全评分</span>
|
||||||
<span className={`font-bold ${
|
<span className={`font-bold ${
|
||||||
task.security_score >= 80 ? "text-green-400" :
|
(task.security_score ?? 0) >= 80 ? "text-green-400" :
|
||||||
task.security_score >= 60 ? "text-yellow-400" :
|
(task.security_score ?? 0) >= 60 ? "text-yellow-400" :
|
||||||
"text-red-400"
|
"text-red-400"
|
||||||
}`}>
|
}`}>
|
||||||
{task.security_score.toFixed(0)}/100
|
{(task.security_score ?? 0).toFixed(0)}/100
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center justify-between text-xs">
|
<div className="flex items-center justify-between text-xs">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue