import { toErrorMessage } from '../utils/error.js';
export function defineTool(options) {
    return {
        name: options.name,
        description: options.description,
        inputSchema: options.inputSchema,
        tier: options.tier,
        category: options.category,
        permissions: options.permissions,
        isReadOnly: () => options.readOnly,
        isDestructive: typeof options.destructive === 'function'
            ? options.destructive
            : () => options.destructive,
        isConcurrencySafe: () => options.concurrencySafe,
        async execute(input, context) {
            try {
                return await options.execute(input, context);
            }
            catch (err) {
                const message = toErrorMessage(err);
                return {
                    success: false,
                    output: '',
                    error: `${options.name} failed: ${message}`,
                };
            }
        },
    };
}
//# sourceMappingURL=defineTool.js.map