import {
  convertToOpenAICompatibleMessages,
  convertToOpenAICompatibleTools,
} from '../shared/openai-compatible/index.js';

import type { IToolSchema, TUniversalMessage } from '@robota-sdk/agent-core';
import type OpenAI from 'openai';

/**
 * Convert TUniversalMessage array to OpenAI chat completion message format.
 */
export function convertToOpenAIMessages(
  messages: TUniversalMessage[],
): OpenAI.Chat.ChatCompletionMessageParam[] {
  return convertToOpenAICompatibleMessages(messages);
}

/**
 * Convert tool schemas to OpenAI function tool format.
 */
export function convertToOpenAITools(tools: IToolSchema[]): OpenAI.Chat.ChatCompletionTool[] {
  return convertToOpenAICompatibleTools(tools);
}
