import { ToolDef } from '../../../llm/openai-compat.js';
import type { ToolContext, ToolResult } from '../core.js';
import { resetSlides } from './state.js';

export const RESET_SLIDES_DEF: ToolDef = {
  type: 'function',
  function: {
    name: 'ResetSlides',
    description:
      'pptxgenjs スライドの slides[] を空にする (theme は維持)。全てやり直すときに呼ぶ。詳細は ReadToolDoc({ name: "ResetSlides" })。',
    parameters: { type: 'object', properties: {}, additionalProperties: false },
  },
};

export async function executeResetSlides(
  _input: Record<string, unknown>,
  ctx: ToolContext,
): Promise<ToolResult> {
  try {
    resetSlides(ctx.workspacePath);
  } catch (e) {
    return { output: `ResetSlides error: ${(e as Error).message}`, isError: true };
  }
  return { output: 'Slides cleared (theme preserved).', isError: false };
}
