/**
 * ACP Runtime type definitions.
 *
 * These mirror the OpenClaw plugin SDK AcpRuntime types.
 * Defined locally so the plugin compiles without hardcoded SDK paths.
 * The OC plugin loader provides the actual SDK at runtime.
 */

export interface AcpRuntimeCapabilities {
  controls: string[];
}

export interface AcpRuntimeEnsureInput {
  sessionKey: string;
  agent: string;
  mode: 'oneshot' | 'session';
  cwd?: string;
}

export interface AcpRuntimeHandle {
  sessionKey: string;
  backend: string;
  runtimeSessionName: string;
  cwd: string;
  backendSessionId: string;
  agentSessionId: string;
}

export interface AcpRuntimeEvent {
  type: 'text_delta' | 'status' | 'done' | 'error';
  text?: string;
  stream?: string;
  tag?: string;
  stopReason?: string;
  message?: string;
}

export interface AcpRuntimeTurnInput {
  handle: AcpRuntimeHandle;
  text: string;
  requestId: string;
  signal?: AbortSignal;
}

export interface AcpRuntimeStatus {
  summary: string;
  backendSessionId: string;
  agentSessionId: string;
  details?: Record<string, unknown>;
}

export interface AcpRuntimeDoctorReport {
  ok: boolean;
  code?: string;
  message: string;
  details?: string[];
  installCommand?: string;
}

export interface AcpRuntime {
  ensureSession(input: AcpRuntimeEnsureInput): Promise<AcpRuntimeHandle>;
  runTurn(input: AcpRuntimeTurnInput): AsyncIterable<AcpRuntimeEvent>;
  getCapabilities(): AcpRuntimeCapabilities;
  getStatus(input: { handle: AcpRuntimeHandle }): Promise<AcpRuntimeStatus>;
  doctor(): Promise<AcpRuntimeDoctorReport>;
  cancel(input: { handle: AcpRuntimeHandle; reason?: string }): Promise<void>;
  close(input: { handle: AcpRuntimeHandle; reason: string }): Promise<void>;
}
