import { ToolDef } from '../../llm/openai-compat.js';
import type { ToolContext, ToolResult } from './core.js';
import { SET_THEME_DEF, executeSetTheme } from './slide/set-theme.js';
import { ADD_SLIDE_DEF, executeAddSlide } from './slide/add-slide.js';
import { BUILD_PPTX_DEF, executeBuildPptx } from './slide/build-pptx.js';
import { RESET_SLIDES_DEF, executeResetSlides } from './slide/reset-slides.js';

export const TOOL_DEFS: Record<string, ToolDef> = {
  SetTheme: SET_THEME_DEF,
  AddSlide: ADD_SLIDE_DEF,
  BuildPptx: BUILD_PPTX_DEF,
  ResetSlides: RESET_SLIDES_DEF,
};

export async function executeTool(
  name: string,
  input: Record<string, unknown>,
  ctx: ToolContext,
): Promise<ToolResult | null> {
  switch (name) {
    case 'SetTheme':    return executeSetTheme(input, ctx);
    case 'AddSlide':    return executeAddSlide(input, ctx);
    case 'BuildPptx':   return executeBuildPptx(input, ctx);
    case 'ResetSlides': return executeResetSlides(input, ctx);
    default: return null;
  }
}
