"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolDefinitionWithoutMcpOutputImpl = void 0;
const tslib_1 = require("tslib");
const snakeCase_1 = tslib_1.__importDefault(require("lodash/snakeCase"));
const toolDefinitionUtils_1 = require("./toolDefinitionUtils");
class ToolDefinitionWithoutMcpOutputImpl {
    constructor(args) {
        this.name = args.name;
        this.title = args.title;
        this.descriptionConfig = args.description;
        this.availability = args.availability;
        this.inputSchema = args.inputSchema;
        this.inputSchemaTransformed = args.inputSchemaTransformed;
        this.agentConfig = args.agentConfig;
        this.mcpConfig = args.mcpConfig;
    }
    get description() {
        return (0, toolDefinitionUtils_1.resolveDescription)(this.descriptionConfig, this.name);
    }
    buildAgentView() {
        const base = {
            name: this.name,
            title: this.title,
            description: this.description,
            inputSchema: this.inputSchema,
            toModelOutput: this.agentConfig?.toModelOutput ?? toolDefinitionUtils_1.defaultAgentToModelOutput,
        };
        if (this.agentConfig?.outputSchema) {
            return {
                ...base,
                outputSchema: this.agentConfig.outputSchema,
            };
        }
        return base;
    }
    for(runtime) {
        (0, toolDefinitionUtils_1.assertAvailable)(this.name, this.availability, runtime);
        if (runtime === 'agent') {
            return this.buildAgentView();
        }
        if (this.mcpConfig === null) {
            throw new Error(`Tool "${this.name}" is missing MCP config`);
        }
        const mcpName = this.mcpConfig.name ?? (0, snakeCase_1.default)(this.name);
        return {
            name: mcpName,
            canonicalName: this.name,
            title: this.title,
            description: (0, toolDefinitionUtils_1.resolveDescription)(this.descriptionConfig, mcpName),
            inputSchema: this.inputSchema,
            annotations: this.mcpConfig.annotations,
            meta: this.mcpConfig.meta,
            result: (0, toolDefinitionUtils_1.createMcpToolResultBuilders)(),
        };
    }
}
exports.ToolDefinitionWithoutMcpOutputImpl = ToolDefinitionWithoutMcpOutputImpl;
//# sourceMappingURL=toolDefinitionWithoutMcpOutput.js.map