MCPcopy
hub / github.com/codeaashu/claude-code / addFunctionHook

Function addFunctionHook

src/utils/hooks/sessionHooks.ts:93–115  ·  view source on GitHub ↗
(
  setAppState: (updater: (prev: AppState) => AppState) => void,
  sessionId: string,
  event: HookEvent,
  matcher: string,
  callback: FunctionHookCallback,
  errorMessage: string,
  options?: {
    timeout?: number
    id?: string
  },
)

Source from the content-addressed store, hash-verified

91 * @returns The hook ID (for removal)
92 */
93export function addFunctionHook(
94 setAppState: (updater: (prev: AppState) => AppState) => void,
95 sessionId: string,
96 event: HookEvent,
97 matcher: string,
98 callback: FunctionHookCallback,
99 errorMessage: string,
100 options?: {
101 timeout?: number
102 id?: string
103 },
104): string {
105 const id = options?.id || `function-hook-${Date.now()}-${Math.random()}`
106 const hook: FunctionHook = {
107 type: 'function',
108 id,
109 timeout: options?.timeout || 5000,
110 callback,
111 errorMessage,
112 }
113 addHookToSession(setAppState, sessionId, event, matcher, hook)
114 return id
115}
116
117/**
118 * Remove a function hook by ID from the session.

Callers 2

initializeTeammateHooksFunction · 0.85

Calls 1

addHookToSessionFunction · 0.85

Tested by

no test coverage detected