web: split the task page into agent-to-agent and single-agent tasks with templates and run status

This commit is contained in:
justme committed 2026-10-22 07:02:31 +08:00
1 parent 3a9ea46d6f
commit 7ad226f29c
5 files changed
+401 -162

No files matched your search

+17
View File
@@ -69,3 +69,20 @@ export interface Page<T> {
/** 后端数字有时按 integer|string 声明:统一成 number。 */
export const n = (v: number | string | null | undefined): number => (v === null || v === undefined ? 0 : Number(v))
export interface TargetDto {
task_id: string
agent_id: string
agent_name: string
kind: string
target: string
status: 'running' | 'waiting' | 'stale' | 'rejected' | 'offline'
reason?: string | null
last_sample?: string | null
from: string
to: string
step: string
t: number[]
values: Record<string, (number | null)[]>
summary: { metrics: Record<string, number | null>; samples: Record<string, number>; coverage: number }
}
+20
View File
@@ -0,0 +1,20 @@
import type { TargetDto } from './api/types'
/** 单个 Agent 任务的状态:文字、颜色和一句说明。 */
export const TARGET_STATUS: Record<TargetDto['status'], { label: string; tone: 'ok' | 'warn' | 'bad' | ''; hint: string }> = {
running: { label: '运行中', tone: 'ok', hint: '最近 15 分钟内有数据' },
waiting: { label: '等待数据', tone: 'warn', hint: '任务已下发,Agent 还没上传第一批数据(每 10 秒一批)' },
stale: { label: '数据中断', tone: 'warn', hint: '以前有数据,最近 15 分钟没有新数据' },
rejected: { label: '被拒绝', tone: 'bad', hint: 'Agent 本机的限制不允许执行这个任务' },
offline: { label: 'Agent 离线', tone: '', hint: 'Agent 不在线,任务会在它回来后继续' },
}
/** Agent 拒绝任务的原因,翻成人话。 */
export const REJECT_REASONS: Record<string, string> = {
policy_denied: '本机不允许这个目标:把它所在的网段加进 agent.json 的 limits.allowed_target_cidrs',
budget_exceeded: '超出本机的速率预算',
unsupported: '这个 Agent 不支持这种采集方法',
invalid_params: '参数不合法',
}
export const rejectText = (reason?: string | null) => (reason ? (REJECT_REASONS[reason] ?? reason) : '')