/**
 * SSH Client Types
 * Used for direct SSH connections from Hub to client servers
 */

export interface SSHConnectionConfig {
  host: string
  port?: number
  username: string
  password?: string
  privateKey?: string | Buffer
  passphrase?: string
  timeout?: number // Connection timeout in ms
}

export interface SSHResult {
  success: boolean
  exitCode: number
  stdout: string
  stderr: string
  duration: number // Execution time in ms
}

export interface SSHStreamEvent {
  type: 'stdout' | 'stderr' | 'exit' | 'error' | 'close'
  data?: string
  exitCode?: number
  error?: string
  timestamp: Date
}

export type SSHStreamCallback = (event: SSHStreamEvent) => void

export interface SCPOptions {
  localPath: string
  remotePath: string
  recursive?: boolean
}

export interface SSHExecOptions {
  timeout?: number // Command execution timeout in ms
  cwd?: string // Working directory on remote
  env?: Record<string, string> // Environment variables
}

export interface SSHClientOptions {
  keepaliveInterval?: number // Keep-alive interval in ms
  keepaliveCountMax?: number // Max keep-alive failures before disconnect
  debug?: boolean // Enable debug logging
}

export class SSHError extends Error {
  constructor(
    message: string,
    public code?: string,
    public level?: string
  ) {
    super(message)
    this.name = 'SSHError'
  }
}
