( appState: AppState | undefined, sessionId: string, hookEvent: HookEvent, hookInput: HookInput, tools?: Tools, )
| 1737 | * @returns Array of matched hooks with optional plugin context |
| 1738 | */ |
| 1739 | export async function getMatchingHooks( |
| 1740 | appState: AppState | undefined, |
| 1741 | sessionId: string, |
| 1742 | hookEvent: HookEvent, |
| 1743 | hookInput: HookInput, |
| 1744 | tools?: Tools, |
| 1745 | ): Promise<MatchedHook[]> { |
| 1746 | try { |
| 1747 | const hookMatchers = getHooksConfig(appState, sessionId, hookEvent) |
| 1748 | |
| 1749 | // If you change the criteria below, then you must change |
| 1750 | // src/utils/hooks/hooksConfigManager.ts as well. |
| 1751 | let matchQuery: string | undefined |
| 1752 | switch (hookInput.hook_event_name) { |
| 1753 | case 'PreToolUse': |
| 1754 | case 'PostToolUse': |
| 1755 | case 'PostToolUseFailure': |
| 1756 | case 'PermissionRequest': |
| 1757 | case 'PermissionDenied': |
| 1758 | matchQuery = hookInput.tool_name as string |
| 1759 | break |
| 1760 | case 'SessionStart': |
| 1761 | matchQuery = hookInput.source as string |
| 1762 | break |
| 1763 | case 'Setup': |
| 1764 | matchQuery = hookInput.trigger as string |
| 1765 | break |
| 1766 | case 'PreCompact': |
| 1767 | case 'PostCompact': |
| 1768 | matchQuery = hookInput.trigger as string |
| 1769 | break |
| 1770 | case 'Notification': |
| 1771 | matchQuery = hookInput.notification_type as string |
| 1772 | break |
| 1773 | case 'SessionEnd': |
| 1774 | matchQuery = hookInput.reason as string |
| 1775 | break |
| 1776 | case 'StopFailure': |
| 1777 | matchQuery = hookInput.error as string |
| 1778 | break |
| 1779 | case 'SubagentStart': |
| 1780 | matchQuery = hookInput.agent_type as string |
| 1781 | break |
| 1782 | case 'SubagentStop': |
| 1783 | matchQuery = hookInput.agent_type as string |
| 1784 | break |
| 1785 | case 'TeammateIdle': |
| 1786 | case 'TaskCreated': |
| 1787 | case 'TaskCompleted': |
| 1788 | break |
| 1789 | case 'Elicitation': |
| 1790 | matchQuery = hookInput.mcp_server_name as string |
| 1791 | break |
| 1792 | case 'ElicitationResult': |
| 1793 | matchQuery = hookInput.mcp_server_name as string |
| 1794 | break |
| 1795 | case 'ConfigChange': |
| 1796 | matchQuery = hookInput.source as string |
no test coverage detected