MCPcopy Index your code
hub / github.com/codeaashu/claude-code / checkForAsyncHookResponses

Function checkForAsyncHookResponses

src/utils/hooks/AsyncHookRegistry.ts:113–268  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111}
112
113export async function checkForAsyncHookResponses(): Promise<
114 Array<{
115 processId: string
116 response: SyncHookJSONOutput
117 hookName: string
118 hookEvent: HookEvent | 'StatusLine' | 'FileSuggestion'
119 toolName?: string
120 pluginId?: string
121 stdout: string
122 stderr: string
123 exitCode?: number
124 }>
125> {
126 const responses: {
127 processId: string
128 response: SyncHookJSONOutput
129 hookName: string
130 hookEvent: HookEvent | 'StatusLine' | 'FileSuggestion'
131 toolName?: string
132 pluginId?: string
133 stdout: string
134 stderr: string
135 exitCode?: number
136 }[] = []
137
138 const pendingCount = pendingHooks.size
139 logForDebugging(`Hooks: Found ${pendingCount} total hooks in registry`)
140
141 // Snapshot hooks before processing — we'll mutate the map after.
142 const hooks = Array.from(pendingHooks.values())
143
144 const settled = await Promise.allSettled(
145 hooks.map(async hook => {
146 const stdout = (await hook.shellCommand?.taskOutput.getStdout()) ?? ''
147 const stderr = hook.shellCommand?.taskOutput.getStderr() ?? ''
148 logForDebugging(
149 `Hooks: Checking hook ${hook.processId} (${hook.hookName}) - attachmentSent: ${hook.responseAttachmentSent}, stdout length: ${stdout.length}`,
150 )
151
152 if (!hook.shellCommand) {
153 logForDebugging(
154 `Hooks: Hook ${hook.processId} has no shell command, removing from registry`,
155 )
156 hook.stopProgressInterval()
157 return { type: 'remove' as const, processId: hook.processId }
158 }
159
160 logForDebugging(`Hooks: Hook shell status ${hook.shellCommand.status}`)
161
162 if (hook.shellCommand.status === 'killed') {
163 logForDebugging(
164 `Hooks: Hook ${hook.processId} is ${hook.shellCommand.status}, removing from registry`,
165 )
166 hook.stopProgressInterval()
167 hook.shellCommand.cleanup()
168 return { type: 'remove' as const, processId: hook.processId }
169 }
170

Callers 1

Calls 11

logForDebuggingFunction · 0.85
jsonParseFunction · 0.85
jsonStringifyFunction · 0.85
finalizeHookFunction · 0.85
valuesMethod · 0.80
getStdoutMethod · 0.80
getStderrMethod · 0.80
deleteMethod · 0.65
cleanupMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected