BuiltInHooks class

Collection of pre-built hooks that implement common safety, auditing, and operational concerns.

These hooks are designed to be registered with a HookExecutor during application initialization. Each method returns a HookRegistration that can be customized before registration.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

auditLogHook({required void logEntry(String entry)}) HookRegistration
Hook that logs all tool operations for audit trail.
costTrackingHook({required void onUsage(int inputTokens, int outputTokens, double cost), double costPerInputToken = 0.000003, double costPerOutputToken = 0.000015}) HookRegistration
Hook that tracks token usage and estimated cost.
fileBackupHook({required Future<void> writeBackup(String path, String content)}) HookRegistration
Hook that creates backup files before modifications.
gitSafetyHook({List<String> protectedBranches = const ['main', 'master']}) HookRegistration
Hook that prevents dangerous git operations.
permissionCheckHook({required bool isPermitted(String toolName, Map<String, dynamic> input)}) HookRegistration
Hook that checks permission rules before tool execution.
rateLimitHook({required int maxCallsPerMinute}) HookRegistration
Hook that enforces rate limits on API calls.
registerAll(HookExecutor executor, {bool isPermitted(String, Map<String, dynamic>)?, bool isInSandbox(String)?, List<String>? allowedPaths, int maxCallsPerMinute = 60, void logEntry(String)?, void onUsage(int, int, double)?, Future<void> writeBackup(String, String)?, List<String>? protectedBranches, void onSecretWarning(String)?}) → void
Register all built-in hooks with the given executor.
sandboxEnforcementHook({required List<String> allowedPaths, required bool isInSandbox(String path)}) HookRegistration
Hook that enforces sandbox restrictions on file and shell operations.
secretDetectionHook({void onWarning(String warning)?}) HookRegistration
Hook that scans content for potential secrets and sensitive data.