export interface FunctionDefinition {
  id: string;
  name: string;
  description?: string;
  runtime: RuntimeType;
  code: string;
  status: 'active' | 'inactive';
  createdAt: string;
  updatedAt: string;
  tags?: string[];
  timeout?: number;
  memoryLimit?: number;
  image?: string;
  env_vars?: Record<string, string>;
}

export interface FunctionExecution {
  id: string;
  function_id: string;
  input?: any;
  output?: any;
  error?: string;
  status: 'pending' | 'running' | 'completed' | 'failed' | 'timeout' | 'canceled';
  duration: number; // Duration in nanoseconds
  memory_used: number;
  container_id?: string;
  executor_id: string;
  created_at: string;
  started_at?: string;
  completed_at?: string;
}

export type RuntimeType = 'nodejs18' | 'python3.9' | 'go1.20';

export interface CreateFunctionRequest {
  name: string;
  description?: string;
  runtime: RuntimeType;
  code: string;
  image?: string;
  timeout?: number;
  memory_limit?: number;
  env_vars?: Record<string, string>;
  tags?: string[];
}

export interface UpdateFunctionRequest extends Partial<CreateFunctionRequest> {}

export interface ExecuteFunctionRequest {
  function_id: string;
  input?: any;
  async?: boolean;
}

export interface ExecuteFunctionResponse {
  execution_id: string;
  output?: any;
  error?: string;
  status: 'pending' | 'running' | 'completed' | 'failed';
  duration?: number;
}

export interface RuntimeInfo {
  runtime: RuntimeType;
  image: string;
  version: string;
  available: boolean;
}