Dart Custom Tools
Register narrow Dart-backed Ansight tools for app-specific Flutter state and actions.
final registration = await Ansight.instance.registerTool(
const AnsightToolDefinition(
id: 'app.current_user',
name: 'Current user',
category: 'app',
scope: AnsightToolScope.read,
security: AnsightToolSecurity(
level: AnsightToolSecurityLevel.low,
),
),
(arguments, context) async => const AnsightToolResult.success(
result: <String, Object?>{'signedIn': true},
),
);
await registration.unregister();
Use stable ids, narrow structured results, explicit scopes, and the least-permissive tool guard. Register write or delete operations only inside a trusted development guard.
Native tool entries report dynamic runtime availability and remediation through the shared catalog. Dart-backed custom tools are advertised as available while registered; when one becomes unusable, unregister it or return a stable failure errorCode from the handler. The Dart registration API does not currently expose a pre-invocation availability callback.