import type { ToolDefinition, ToolFunction } from '@conveniencepro/ctp-core';
// 1. Define the tool's result type
interface UppercaseResult {
result: string;
originalLength: number;
}
// 2. Create the tool definition
export const uppercaseDefinition: ToolDefinition = {
id: 'uppercase-converter',
name: 'Uppercase Converter',
description: 'Convert text to uppercase.',
category: 'converters',
tags: ['uppercase', 'text', 'convert'],
method: 'POST',
parameters: [
{
name: 'text',
type: 'textarea',
label: 'Input Text',
description: 'Text to convert to uppercase',
required: true,
},
],
outputDescription: 'Uppercase version of the input text',
example: {
input: { text: 'hello world' },
output: { result: 'HELLO WORLD', originalLength: 11 },
},
executionMode: 'client',
};
// 3. Implement the tool function
export const uppercaseFn: ToolFunction<UppercaseResult> = (params) => {
const text = params.text as string;
if (!text) {
return {
success: false,
error: 'Text is required',
errorCode: 'MISSING_REQUIRED',
};
}
return {
success: true,
data: {
result: text.toUpperCase(),
originalLength: text.length,
},
};
};
export default { definition: uppercaseDefinition, fn: uppercaseFn };