export const TASK_TYPE = {
  NORMAL: 'task',
  REPO: 'repo',
} as const

export const TRIGGER_TYPE = {
  CRON: 'cron',
  TASKPOOL_STARTUP: 'taskpool_startup',
  /** 兼容存量任务 */
  LEGACY_STARTUP: 'baihu_startup',
} as const

export const TASK_STATUS = {
  RUNNING: 'running',
  SUCCESS: 'success',
  FAILED: 'failed',
  TIMEOUT: 'timeout',
  CANCELLED: 'cancelled',
} as const

export const TASK_STATUS_TEXT: Record<string, string> = {
  running: '运行中',
  success: '成功',
  failed: '失败',
  timeout: '超时',
  cancelled: '已取消',
}

export const AGENT_STATUS = {
  ONLINE: 'online',
  OFFLINE: 'offline',
} as const

export const PATHS = {
  SCRIPTS_DIR: 'data/scripts',
  SCRIPTS_DIR_PLACEHOLDER: '${scripts_dir}',
}

export const ENV_TYPE = {
  NORMAL: 'normal',
  SECRET: 'secret',
} as const

/** 任务实时事件（WebSocket） */
export const TASK_EVENTS = {
  SUCCESS: 'task_success',
  FAILED: 'task_failed',
  TIMEOUT: 'task_timeout',
  RUNNING: 'task_running',
  QUEUED: 'task_queued',
  CANCELLED: 'task_cancelled',
} as const

/** 系统日志事件 */
export const LOG_EVENTS = {
  ADDED: 'app_log_added',
} as const

/** 系统事件 */
export const SYSTEM_EVENTS = {
  INTERCONNECT_CHILD_STATUS: 'interconnect_child_status',
  INTERCONNECT_ROLE_CHANGED: 'interconnect-role-changed',
} as const

export const API_BASE =
  ((window as any).__BASE_URL__ || '') + ((window as any).__API_VERSION__ || '/api/v1')
