( appState: AppState | undefined, sessionId: string, hookEvent: HookEvent, hookInput: HookInput, tools?: Tools, )
| 1683 | * @returns Array of matched hooks with optional plugin context |
| 1684 | */ |
| 1685 | export async function getMatchingHooks( |
| 1686 | appState: AppState | undefined, |
| 1687 | sessionId: string, |
| 1688 | hookEvent: HookEvent, |
| 1689 | hookInput: HookInput, |
| 1690 | tools?: Tools, |
| 1691 | ): Promise<MatchedHook[]> { |
| 1692 | try { |
| 1693 | const hookMatchers = getHooksConfig(appState, sessionId, hookEvent) |
| 1694 | |
| 1695 | // If you change the criteria below, then you must change |
| 1696 | // src/utils/hooks/hooksConfigManager.ts as well. |
| 1697 | let matchQuery: string | undefined = undefined |
| 1698 | switch (hookInput.hook_event_name) { |
| 1699 | case 'PreToolUse': |
| 1700 | case 'PostToolUse': |
| 1701 | case 'PostToolUseFailure': |
| 1702 | case 'PermissionRequest': |
| 1703 | case 'PermissionDenied': |
| 1704 | matchQuery = hookInput.tool_name as string |
| 1705 | break |
| 1706 | case 'SessionStart': |
| 1707 | matchQuery = hookInput.source as string |
| 1708 | break |
| 1709 | case 'Setup': |
| 1710 | matchQuery = hookInput.trigger as string |
| 1711 | break |
| 1712 | case 'PreCompact': |
| 1713 | case 'PostCompact': |
| 1714 | matchQuery = hookInput.trigger as string |
| 1715 | break |
| 1716 | case 'Notification': |
| 1717 | matchQuery = hookInput.notification_type as string |
| 1718 | break |
| 1719 | case 'SessionEnd': |
| 1720 | matchQuery = hookInput.reason as string |
| 1721 | break |
| 1722 | case 'StopFailure': |
| 1723 | matchQuery = hookInput.error as string |
| 1724 | break |
| 1725 | case 'SubagentStart': |
| 1726 | matchQuery = hookInput.agent_type as string |
| 1727 | break |
| 1728 | case 'SubagentStop': |
| 1729 | matchQuery = hookInput.agent_type as string |
| 1730 | break |
| 1731 | case 'TeammateIdle': |
| 1732 | case 'TaskCreated': |
| 1733 | case 'TaskCompleted': |
| 1734 | break |
| 1735 | case 'Elicitation': |
| 1736 | matchQuery = hookInput.mcp_server_name as string |
| 1737 | break |
| 1738 | case 'ElicitationResult': |
| 1739 | matchQuery = hookInput.mcp_server_name as string |
| 1740 | break |
| 1741 | case 'ConfigChange': |
| 1742 | matchQuery = hookInput.source as string |
no test coverage detected