import type { RunRecord, TaskRecord, TraceEvent } from "../types/accountingAgent";

export interface RuntimeAdapter {
  startRun(input: {
    sessionId?: string;
    initiator?: string;
    source?: string;
    metadata?: Record<string, unknown>;
    idempotencyKey?: string;
  }): RunRecord;
  finishRun(input: {
    runId: string;
    status: "DONE" | "ERROR" | "CANCELLED";
    source?: string;
    reason?: string;
    metadata?: Record<string, unknown>;
    idempotencyKey?: string;
  }): RunRecord;
  listRuns(): RunRecord[];
  getRun(runId: string): RunRecord | null;
  enqueueTask(input: {
    runId: string;
    payload: Record<string, unknown>;
    source?: string;
    idempotencyKey?: string;
  }): TaskRecord;
  claimTask(): TaskRecord | null;
  completeTask(input: {
    taskId: string;
    result: Record<string, unknown>;
    source?: string;
    idempotencyKey?: string;
  }): TaskRecord;
  failTask(input: {
    taskId: string;
    error: { code: string; message: string; details?: unknown };
    source?: string;
    idempotencyKey?: string;
  }): TaskRecord;
  getResults(): TaskRecord[];
  getRunTrace(runId: string): TraceEvent[];
  health(): { ok: boolean; queueDepth: number; runsTotal: number };
}
