Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

536 B
Raw Blame
import type { AgentHookMatcher } from '@lobechat/types';
import { isRecord } from '@lobechat/utils/object';

/** Match the combined tool name; registration/restoration validates the regex first. */
export function matchesHook(matcher: AgentHookMatcher | undefined, event: unknown): boolean {
  if (!matcher || matcher === '*') return true;
  if (!isRecord(event) || typeof event.identifier !== 'string' || typeof event.apiName !== 'string')
    return false;
  return new RegExp(matcher).test(`${event.identifier}/${event.apiName}`);
}