
import { MarkdownString } from '../../../../../../base/common/htmlContent.js';
import { ToolDataSource, ToolInvocationPresentation } from '../languageModelToolsService.js';

const ConfirmationToolId = "vscode_get_confirmation";
const ConfirmationToolData = {
    id: ConfirmationToolId,
    displayName: "Confirmation Tool",
    modelDescription: "A tool that demonstrates different types of confirmations. Takes a title, message, and confirmation type (basic or terminal).",
    source: ToolDataSource.Internal,
    inputSchema: {
        type: "object",
        properties: {
            title: {
                type: "string",
                description: "Title for the confirmation dialog"
            },
            message: {
                type: "string",
                description: "Message to show in the confirmation dialog"
            },
            confirmationType: {
                type: "string",
                enum: ["basic", "terminal"],
                description: "Type of confirmation to show - basic for simple confirmation, terminal for terminal command confirmation"
            },
            terminalCommand: {
                type: "string",
                description: "Terminal command to show (only used when confirmationType is \"terminal\")"
            }
        },
        required: ["title", "message", "confirmationType"],
        additionalProperties: false
    }
};
class ConfirmationTool {
    async prepareToolInvocation(context, token) {
        const parameters = context.parameters;
        if (!parameters.title || !parameters.message) {
            throw ( new Error("Missing required parameters for ConfirmationTool"));
        }
        const confirmationType = parameters.confirmationType ?? "basic";
        let toolSpecificData;
        if (confirmationType === "terminal") {
            toolSpecificData = {
                kind: "terminal",
                commandLine: {
                    original: parameters.terminalCommand ?? ""
                },
                language: "bash"
            };
        } else {
            toolSpecificData = undefined;
        }
        return {
            confirmationMessages: {
                title: parameters.title,
                message: ( new MarkdownString(parameters.message)),
                allowAutoConfirm: true
            },
            toolSpecificData,
            presentation: ToolInvocationPresentation.HiddenAfterComplete
        };
    }
    async invoke(invocation, countTokens, progress, token) {
        return {
            content: [{
                kind: "text",
                value: "yes"
            }]
        };
    }
}

export { ConfirmationTool, ConfirmationToolData, ConfirmationToolId };
