// 远程执行系统 - 核心接口
export interface Device {
  id: string;
  name: string;
  userId: string;
  platform: 'macos' | 'windows' | 'linux';
  capabilities: string[];
  status: 'online' | 'offline' | 'busy';
  lastHeartbeat: Date;
}

export interface Task {
  id: string;
  userId: string;
  deviceId: string;
  channel: string;
  type: 'immediate' | 'scheduled';
  priority: 'high' | 'normal' | 'low';
  payload: any;
  status: TaskStatus;
  result?: any;
  createdAt: Date;
  startedAt?: Date;
  completedAt?: Date;
}

export type TaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';

export interface RemoteExecutionSystem {
  registerDevice(device: Device): Promise<void>;
  heartbeat(deviceId: string): Promise<DeviceStatus>;
  submitTask(task: Task): Promise<string>;
  cancelTask(taskId: string): Promise<void>;
  getStatus(taskId: string): Promise<TaskStatus>;
  subscribe(taskId: string, handler: StatusHandler): void;
  pushResult(taskId: string, result: Result): Promise<void>;
}

export type StatusHandler = (status: TaskStatus, progress?: number) => void;
export type DeviceStatus = 'online' | 'offline' | 'busy';
export interface Result {
  taskId: string;
  success: boolean;
  data?: any;
  error?: string;
}
