import snakeCase from 'lodash/snakeCase';
import { assertAvailable, createMcpToolResultBuilders, defaultAgentToModelOutput, resolveDescription, } from './toolDefinitionUtils';
export class ToolDefinitionWithMcpOutputImpl {
    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 resolveDescription(this.descriptionConfig, this.name);
    }
    buildAgentView() {
        const base = {
            name: this.name,
            title: this.title,
            description: this.description,
            inputSchema: this.inputSchema,
            toModelOutput: this.agentConfig?.toModelOutput ?? defaultAgentToModelOutput,
        };
        if (this.agentConfig?.outputSchema) {
            return {
                ...base,
                outputSchema: this.agentConfig.outputSchema,
            };
        }
        return base;
    }
    get outputSchema() {
        return this.mcpConfig.structuredContentSchema;
    }
    for(runtime) {
        assertAvailable(this.name, this.availability, runtime);
        if (runtime === 'agent') {
            return this.buildAgentView();
        }
        const mcpName = this.mcpConfig.name ?? snakeCase(this.name);
        return {
            name: mcpName,
            canonicalName: this.name,
            title: this.title,
            description: resolveDescription(this.descriptionConfig, mcpName),
            inputSchema: this.inputSchema,
            annotations: this.mcpConfig.annotations,
            outputSchema: this.outputSchema,
            meta: this.mcpConfig.meta,
            result: createMcpToolResultBuilders(),
        };
    }
}
//# sourceMappingURL=toolDefinitionWithMcpOutput.js.map