/**
 * LLM adapter types — ported from the extension.
 */

import type { ContentBlock, Message } from '../types';

export interface LlmTool {
  name: string;
  description: string;
  input_schema: {
    type: 'object';
    properties: Record<string, unknown>;
    required?: string[];
  };
}

export interface LlmCallbacks {
  onTextDelta: (delta: string) => void;
  onToolUse: (block: { id: string; name: string; input: unknown }) => void;
}

export type StopReason = 'end_turn' | 'tool_use' | 'max_tokens' | 'refusal' | 'error' | 'other';

export interface LlmTurnResult {
  stopReason: StopReason;
  content: ContentBlock[];
}

export interface LlmRequest {
  provider: 'anthropic' | 'openai';
  apiKey: string;
  baseUrl: string;
  model: string;
  system: string;
  history: Message[];
  tools: LlmTool[];
  maxTokens: number;
}

export interface LlmAdapter {
  stream(req: LlmRequest, cb: LlmCallbacks): Promise<LlmTurnResult>;
}
