dispatchCanUseTool function
Invokes callback for an incoming agentSdk.canUseTool request and returns
its PermissionResult as wire JSON.
params carries toolName, input, and optional suggestions (plus the
routing streamId, unused here). The full payload is exposed to the
callback via CanUseToolContext so context.suggestions resolves.
Implementation
Future<Map<String, dynamic>> dispatchCanUseTool(
CanUseTool callback,
Map<String, dynamic> params,
) async {
final toolName = params['toolName'] as String? ?? '';
final input = (params['input'] as Map?)?.cast<String, dynamic>() ?? const {};
final result = await callback(toolName, input, CanUseToolContext(params));
return result.toJson();
}