MCPcopy Create free account
hub / github.com/Noumena-Network/code / getMatchingHooks

Function getMatchingHooks

src/utils/hooks.ts:1607–1878  ·  view source on GitHub ↗
(
  appState: AppState | undefined,
  sessionId: string,
  hookEvent: HookEvent,
  hookInput: HookInput,
  tools?: Tools,
)

Source from the content-addressed store, hash-verified

1605 * @returns Array of matched hooks with optional plugin context
1606 */
1607export async function getMatchingHooks(
1608 appState: AppState | undefined,
1609 sessionId: string,
1610 hookEvent: HookEvent,
1611 hookInput: HookInput,
1612 tools?: Tools,
1613): Promise<MatchedHook[]> {
1614 try {
1615 const hookMatchers = getHooksConfig(appState, sessionId, hookEvent)
1616
1617 // If you change the criteria below, then you must change
1618 // src/utils/hooks/hooksConfigManager.ts as well.
1619 let matchQuery: string | undefined = undefined
1620 switch (hookInput.hook_event_name) {
1621 case 'PreToolUse':
1622 case 'PostToolUse':
1623 case 'PostToolUseFailure':
1624 case 'PermissionRequest':
1625 case 'PermissionDenied':
1626 matchQuery = hookInput.tool_name
1627 break
1628 case 'SessionStart':
1629 matchQuery = hookInput.source
1630 break
1631 case 'Setup':
1632 matchQuery = hookInput.trigger
1633 break
1634 case 'PreCompact':
1635 case 'PostCompact':
1636 matchQuery = hookInput.trigger
1637 break
1638 case 'Notification':
1639 matchQuery = hookInput.notification_type
1640 break
1641 case 'SessionEnd':
1642 matchQuery = hookInput.reason
1643 break
1644 case 'StopFailure':
1645 matchQuery = hookInput.error
1646 break
1647 case 'SubagentStart':
1648 matchQuery = hookInput.agent_type
1649 break
1650 case 'SubagentStop':
1651 matchQuery = hookInput.agent_type
1652 break
1653 case 'TeammateIdle':
1654 case 'TaskCreated':
1655 case 'TaskCompleted':
1656 break
1657 case 'Elicitation':
1658 matchQuery = hookInput.mcp_server_name
1659 break
1660 case 'ElicitationResult':
1661 matchQuery = hookInput.mcp_server_name
1662 break
1663 case 'ConfigChange':
1664 matchQuery = hookInput.source

Callers 2

executeHooksFunction · 0.85
executeHooksOutsideREPLFunction · 0.85

Calls 6

getHooksConfigFunction · 0.85
matchesPatternFunction · 0.85
hookDedupKeyFunction · 0.85
getIfConditionFunction · 0.85
logForDebuggingFunction · 0.70

Tested by

no test coverage detected