beforeToolCall method

Future<HookDecision> beforeToolCall(
  1. ToolCallContext ctx
)

Runs beforeToolCall on each enabled hook in order. Returns the first non-allow decision; if all allow, returns HookDecisionAllow.

Implementation

Future<HookDecision> beforeToolCall(ToolCallContext ctx) async {
  for (final hook in _hooks) {
    if (!hook.enabled) continue;
    final decision = await hook.beforeToolCall(ctx);
    if (decision is! HookDecisionAllow) {
      return decision;
    }
  }
  return const HookDecisionAllow();
}