execute method
Execute the tool with the given input.
Implementation
@override
Future<ToolResult> execute(Map<String, dynamic> input) async {
final query = input['query'] as String?;
final maxResults = (input['max_results'] as num?)?.toInt() ?? 5;
if (query == null || query.isEmpty) {
return ToolResult.error('Missing required parameter: query');
}
final deferredTools = registry.all
.where((t) => _isDeferredTool(t))
.toList();
// Direct selection: "select:ToolName" or "select:A,B,C"
if (query.startsWith('select:')) {
return _handleDirectSelection(query.substring(7), deferredTools);
}
// Keyword search
return _handleKeywordSearch(query, deferredTools, maxResults);
}