📄 types.ts  •  2337 bytes
/**
 * 执行计划 - 数据类型定义
 * Phase 2: 计划数据结构
 */

/** 计划步骤状态 */
export type StepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped'

/** 工具调用参数 */
export interface ToolParams {
  [key: string]: any
}

/** 执行计划步骤 */
export interface PlanStep {
  id: number           // 步骤ID(从1开始)
  action: string       // 动作描述(中文)
  tool: string         // 工具名称
  params: ToolParams   // 工具参数
  expected: string     // 预期结果
  status: StepStatus   // 当前状态
  result?: string      // 执行结果
  error?: string        // 错误信息
  retryCount: number   // 重试次数
}

/** 风险评估 */
export interface Risk评估 {
  level: 'low' | 'medium' | 'high'
  description: string
  mitigation?: string  // 缓解措施
}

/** 执行计划 */
export interface ExecutionPlan {
  id: string           // 计划ID
  title: string        // 计划标题
  description: string  // 任务描述
  steps: PlanStep[]   // 步骤列表
  estimatedSteps: number // 预估步骤数
  estimatedTime?: number // 预估时间(秒)
  risks: Risk评估[]    // 风险列表
  createdAt: string    // 创建时间
  status: 'pending' | 'approved' | 'executing' | 'completed' | 'cancelled'
  currentStep: number  // 当前执行步骤
}

/** 用户确认选项 */
export interface ConfirmOption {
  id: string
  label: string
  description: string
  icon: string
}

/** 确认选项预设 */
export const CONFIRM_OPTIONS: ConfirmOption[] = [
  { id: 'execute', label: '确认执行', description: '按计划执行所有步骤', icon: '▶️' },
  { id: 'modify', label: '修改计划', description: '修改后再执行', icon: '✏️' },
  { id: 'partial', label: '部分执行', description: '只执行选中的步骤', icon: '🔲' },
  { id: 'cancel', label: '取消', description: '不执行此计划', icon: '❌' },
]

/** 步骤状态显示 */
export const STATUS_LABELS: Record<StepStatus, string> = {
  pending: '⏳ 待执行',
  running: '🔄 执行中',
  completed: '✅ 完成',
  failed: '❌ 失败',
  skipped: '⏭️ 跳过',
}

/** 风险等级显示 */
export const RISK_LABELS: Record<Risk评估['level'], string> = {
  low: '🟢 低风险',
  medium: '🟡 中风险',
  high: '🔴 高风险',
}