import type { z } from 'zod';
import type { Message } from '../types.js';

export type Model = {
  name: string;
  key: string;
};

export type ModelList = {
  embedding: Model[];
  chat: Model[];
};

export type ProviderMetadata = {
  name: string;
  key: string;
};

export type MinimalProvider = {
  id: string;
  name: string;
  chatModels: Model[];
  embeddingModels: Model[];
};

export type ModelWithProvider = {
  key: string;
  providerId: string;
};

export type GenerateOptions = {
  temperature?: number;
  maxTokens?: number;
  topP?: number;
  stopSequences?: string[];
  frequencyPenalty?: number;
  presencePenalty?: number;
};

export type Tool = {
  name: string;
  description: string;
  schema: z.ZodTypeAny;
};

export type ToolCall = {
  id: string;
  name: string;
  arguments: Record<string, unknown>;
};

export type GenerateTextInput = {
  messages: Message[];
  tools?: Tool[];
  options?: GenerateOptions;
};

export type GenerateTextOutput = {
  content: string;
  toolCalls: ToolCall[];
  additionalInfo?: Record<string, unknown>;
};

export type StreamTextOutput = {
  contentChunk: string;
  toolCallChunk: ToolCall[];
  additionalInfo?: Record<string, unknown>;
  done?: boolean;
};

export type GenerateObjectInput = {
  schema: z.ZodTypeAny;
  messages: Message[];
  options?: GenerateOptions;
};

export type GenerateObjectOutput<T> = {
  object: T;
  additionalInfo?: Record<string, unknown>;
};

export type StreamObjectOutput<T> = {
  objectChunk: Partial<T>;
  additionalInfo?: Record<string, unknown>;
  done?: boolean;
};
