/**
 * Crew 编排系统共享类型定义
 */

/** 委派执行结果 */
export interface DelegateResult {
  agent: string;
  status: 'completed' | 'failed';
  result: string;
  error?: string;
  duration: string;
  tokenUsage: { inputTokens: number; outputTokens: number };
}

/** 委派回调 */
export interface CrewCallbacks {
  onLog: (runId: number, taskId: number, agentName: string, level: string, message: string) => void;
  onTaskStatus: (runId: number, taskId: number, agentName: string, status: string, result?: any, error?: string) => void;
  onRunStatus: (runId: number, status: string, progress?: string) => void;
  onEscalation: (runId: number, taskId: number | undefined, reason: string, error?: string) => void;
}

/** 并行委派任务项 */
export interface ParallelTaskItem {
  agent_name: string;
  task_description: string;
  context?: string;
}

/** 集群运行上下文 */
export interface CrewRunContext {
  runId: number;
  crewId: number;
  masterAgentId: number;
  memberAgents: Array<{
    id: number;
    name: string;
    label: string;
    role: string;
    agent: any;
  }>;
  maxConcurrent: number;
  taskTimeout: number;
  callbacks: CrewCallbacks;
  getConversation?: () => any[];
}
