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

Function runHooks

src/hooks/toolPermission/PermissionContext.ts:216–263  ·  view source on GitHub ↗
(
      permissionMode: string | undefined,
      suggestions: PermissionUpdate[] | undefined,
      updatedInput?: Record<string, unknown>,
      permissionPromptStartTimeMs?: number,
    )

Source from the content-addressed store, hash-verified

214 }
215 : {}),
216 async runHooks(
217 permissionMode: string | undefined,
218 suggestions: PermissionUpdate[] | undefined,
219 updatedInput?: Record<string, unknown>,
220 permissionPromptStartTimeMs?: number,
221 ): Promise<PermissionDecision | null> {
222 for await (const hookResult of executePermissionRequestHooks(
223 tool.name,
224 toolUseID,
225 input,
226 toolUseContext,
227 permissionMode,
228 suggestions,
229 toolUseContext.abortController.signal,
230 )) {
231 if (hookResult.permissionRequestResult) {
232 const decision = hookResult.permissionRequestResult
233 if (decision.behavior === 'allow') {
234 const finalInput = decision.updatedInput ?? updatedInput ?? input
235 return await this.handleHookAllow(
236 finalInput,
237 decision.updatedPermissions ?? [],
238 permissionPromptStartTimeMs,
239 )
240 } else if (decision.behavior === 'deny') {
241 this.logDecision(
242 { decision: 'reject', source: { type: 'hook' } },
243 { permissionPromptStartTimeMs },
244 )
245 if (decision.interrupt) {
246 logForDebugging(
247 `Hook interrupt: tool=${tool.name} hookMessage=${decision.message}`,
248 )
249 toolUseContext.abortController.abort()
250 }
251 return this.buildDeny(
252 decision.message || 'Permission denied by hook',
253 {
254 type: 'hook',
255 hookName: 'PermissionRequest',
256 reason: decision.message,
257 },
258 )
259 }
260 }
261 }
262 return null
263 },
264 buildAllow(
265 updatedInput: Record<string, unknown>,
266 opts?: {

Callers

nothing calls this directly

Calls 2

logForDebuggingFunction · 0.85

Tested by

no test coverage detected