/**
 * Cloud-agnostic LLM provider interfaces.
 *
 * Provides a unified chat completion API that works with
 * Azure OpenAI, OpenAI direct, or mock providers.
 */

export interface LLMProvider {
  /** Send a chat completion request. */
  chatCompletion(req: ChatCompletionRequest): Promise<ChatCompletionResponse>;

  /** Stream a chat completion response. */
  chatCompletionStream?(req: ChatCompletionRequest): AsyncIterable<string>;

  /** Check if the provider is configured with valid credentials. */
  isConfigured(): boolean;
}

export interface ChatCompletionRequest {
  messages: ChatMessage[];
  model?: string;
  temperature?: number;
  maxTokens?: number;
  topP?: number;
  stop?: string[];
  responseFormat?: { type: 'text' | 'json_object' };
}

export interface ChatMessage {
  role: 'system' | 'user' | 'assistant' | 'tool';
  content: string;
  name?: string;
}

export interface ChatCompletionResponse {
  content: string;
  model: string;
  usage: TokenUsage;
  finishReason: 'stop' | 'length' | 'content_filter' | 'tool_calls' | null;
}

export interface TokenUsage {
  promptTokens: number;
  completionTokens: number;
  totalTokens: number;
}

export type LLMProviderType = 'azure' | 'openai' | 'mock';
