// ── Extraction types (shared across consumers) ─────────────────

export interface ExtractionEntity {
  extraction_class: string;
  extraction_text: string;
  attributes?: Record<string, string>;
  start_offset?: number;
  end_offset?: number;
}

export interface ExtractionExample {
  text: string;
  extractions: ExtractionEntity[];
}

export interface ExtractionTask {
  id: string;
  name: string;
  description?: string;
  prompt: string;
  classes: string[];
  examples?: ExtractionExample[];
  defaultModelId?: string;
  builtIn: boolean;
  productId: string;
  createdAt?: string;
  updatedAt?: string;
}

// ── Request / Response types ────────────────────────────────────

export interface ExtractRequest {
  text: string;
  taskId?: string;
  taskPrompt?: string;
  examples?: ExtractionExample[];
  modelId?: string;
  options?: {
    extractionPasses?: number;
    maxWorkers?: number;
    maxCharBuffer?: number;
  };
  productId?: string;
}

export interface ExtractResponse {
  extractions: ExtractionEntity[];
  metadata: {
    modelId: string;
    durationMs: number;
    tokenCount?: number;
    charCount: number;
  };
  requestId?: string;
}

export interface BatchExtractRequest {
  inputs: Array<{
    text: string;
    taskId?: string;
    taskPrompt?: string;
  }>;
  examples?: ExtractionExample[];
  modelId?: string;
  productId?: string;
}

export interface BatchExtractResponse {
  results: ExtractResponse[];
  requestId?: string;
}

// ── Client config ───────────────────────────────────────────────

export interface ExtractionClientConfig {
  baseUrl: string;
  getToken?: () => string | null;
}
