Files
justme fee236fe56
ci/woodpecker/push/web-build Pipeline was successful
ci/woodpecker/push/verify Pipeline was successful
ci/woodpecker/push/dev-image Pipeline was successful
ci/woodpecker/push/dev-backend-image Pipeline was successful
web: explain the public-only default when an agent refuses a target [CI]
2026-10-22 07:36:29 +08:00

21 lines
1.3 KiB
TypeScript

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) : '')