MCPcopy Create free account
hub / github.com/codeaashu/claude-code / getSessionHookCallback

Function getSessionHookCallback

src/utils/hooks/sessionHooks.ts:397–430  ·  view source on GitHub ↗
(
  appState: AppState,
  sessionId: string,
  event: HookEvent,
  matcher: string,
  hook: HookCommand | FunctionHook,
)

Source from the content-addressed store, hash-verified

395 * Get the full hook entry (including callbacks) for a specific session hook
396 */
397export function getSessionHookCallback(
398 appState: AppState,
399 sessionId: string,
400 event: HookEvent,
401 matcher: string,
402 hook: HookCommand | FunctionHook,
403):
404 | {
405 hook: HookCommand | FunctionHook
406 onHookSuccess?: OnHookSuccess
407 }
408 | undefined {
409 const store = appState.sessionHooks.get(sessionId)
410 if (!store) {
411 return undefined
412 }
413
414 const eventMatchers = store.hooks[event]
415 if (!eventMatchers) {
416 return undefined
417 }
418
419 // Find the hook in the matchers
420 for (const matcherEntry of eventMatchers) {
421 if (matcherEntry.matcher === matcher || matcher === '') {
422 const hookEntry = matcherEntry.hooks.find(h => isHookEqual(h.hook, hook))
423 if (hookEntry) {
424 return hookEntry
425 }
426 }
427 }
428
429 return undefined
430}
431
432/**
433 * Clear all session hooks for a specific session

Callers 1

executeHooksFunction · 0.85

Calls 2

isHookEqualFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected