/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { BaseDeclarativeTool, BaseToolInvocation, Kind, } from '../tools/tools.js';
import { vi } from 'vitest';
class MockToolInvocation extends BaseToolInvocation {
    tool;
    constructor(tool, params) {
        super(params);
        this.tool = tool;
    }
    execute(signal, updateOutput) {
        return this.tool.executeFn(this.params, signal, updateOutput);
    }
    shouldConfirmExecute(abortSignal) {
        return this.tool.shouldConfirmExecute(this.params, abortSignal);
    }
    getDescription() {
        return `A mock tool invocation for ${this.tool.name}`;
    }
}
function createExecuteFn(impl, _fallbackName) {
    return vi.fn(impl);
}
export class MockTool extends BaseDeclarativeTool {
    shouldConfirm = false;
    executeFn;
    shouldConfirmExecute;
    constructor(optionsOrName = { name: 'mock-tool' }) {
        const options = typeof optionsOrName === 'string'
            ? { name: optionsOrName }
            : optionsOrName;
        super(options.name, options.displayName ?? options.name, options.description ?? options.name, Kind.Other, options.params ??
            {
                type: 'object',
                properties: { param: { type: 'string' } },
            }, options.isOutputMarkdown ?? false, options.canUpdateOutput ?? false);
        const defaultExecute = async () => ({
            llmContent: `Tool ${this.name} executed successfully.`,
            returnDisplay: `Tool ${this.name} executed successfully.`,
        });
        const executeImpl = options.execute ?? defaultExecute;
        this.executeFn = createExecuteFn(executeImpl, options.name);
        if (options.shouldConfirmExecute) {
            this.shouldConfirmExecute = (params, signal) => options.shouldConfirmExecute(params, signal);
        }
        else {
            this.shouldConfirmExecute = async () => {
                if (!this.shouldConfirm) {
                    return false;
                }
                return {
                    type: 'exec',
                    title: `Confirm ${this.displayName}`,
                    command: this.name,
                    rootCommand: this.name,
                    onConfirm: async () => { },
                };
            };
        }
    }
    createInvocation(params) {
        return new MockToolInvocation(this, params);
    }
}
//# sourceMappingURL=mock-tool.js.map