/**
 * [CORE_AUTO_01] 自治流水线核心类型定义
 */

export enum StepStatus {
  PENDING = 'PENDING',
  RUNNING = 'RUNNING',
  COMPLETED = 'COMPLETED',
  FAILED = 'FAILED',
  AWAITING_DECISION = 'AWAITING_DECISION'
}

export interface PipelineContext {
  tenantId: string;
  shopId: string;
  traceId: string;
  userId: string;
  variables: Record<string, any>;
}

export interface PipelineStep {
  id: string;
  type: string;
  config: Record<string, any>;
  status: StepStatus;
  dependsOn?: string[]; // 依赖的前置步骤 ID
  output?: any;
  error?: string;
}

export interface PipelineDefinition {
  id: string;
  name: string;
  steps: PipelineStep[];
}

export interface PipelineInstance {
  id: string;
  definitionId: string;
  context: PipelineContext;
  status: StepStatus;
  currentStepId?: string;
  createdAt: Date;
  updatedAt: Date;
}

export interface StepResult {
  status: StepStatus;
  output?: any;
  error?: string;
  nextStepId?: string; // AI 决策的下一步
}
