// E2B Sandbox 执行结果类型定义

export interface SandboxExecutionResult {
  // 执行ID
  executionId: string;
  
  // 执行状态
  status: 'running' | 'success' | 'error' | 'timeout' | 'cancelled';
  
  // 执行的Agent类型
  agentType: 'manager' | 'marketing' | 'product' | 'service' | 'finance';
  
  // 任务描述
  taskDescription: string;
  
  // 代码类型
  codeType?: 'python' | 'javascript' | 'shell';
  
  // 执行的代码（可选，用于调试）
  code?: string;
  
  // 文本输出
  stdout?: string;
  stderr?: string;
  
  // 结构化数据输出
  data?: Record<string, any>;
  
  // 生成的文件
  files?: SandboxFile[];
  
  // 生成的图表/可视化
  charts?: SandboxChart[];
  
  // 执行统计
  stats?: {
    startTime: string;
    endTime?: string;
    durationMs?: number;
    memoryUsedMb?: number;
    cpuTimeMs?: number;
  };
  
  // 错误信息
  error?: {
    type: string;
    message: string;
    traceback?: string;
  };
}

export interface SandboxFile {
  id: string;
  name: string;
  type: 'image' | 'pdf' | 'csv' | 'excel' | 'json' | 'text' | 'other';
  size: number;
  url?: string;
  base64?: string;
  mimeType: string;
}

export interface SandboxChart {
  id: string;
  type: 'line' | 'bar' | 'pie' | 'scatter' | 'area' | 'heatmap' | 'custom';
  title: string;
  data: any[];
  config?: Record<string, any>;
  imageUrl?: string;
}

// 沙盒执行请求
export interface SandboxExecutionRequest {
  agentType: string;
  taskId?: string;
  taskDescription: string;
  code: string;
  codeType: 'python' | 'javascript' | 'shell';
  timeout?: number;
  env?: Record<string, string>;
}

// 沙盒状态更新事件
export interface SandboxStatusEvent {
  executionId: string;
  status: SandboxExecutionResult['status'];
  progress?: number;
  message?: string;
  partialOutput?: string;
}
