MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / processHookJSONOutput

Function processHookJSONOutput

source code/utils/hooks.ts:491–739  ·  view source on GitHub ↗
({
  json,
  command,
  hookName,
  toolUseID,
  hookEvent,
  expectedHookEvent,
  stdout,
  stderr,
  exitCode,
  durationMs,
}: {
  json: SyncHookJSONOutput
  command: string
  hookName: string
  toolUseID: string
  hookEvent: HookEvent
  expectedHookEvent?: HookEvent
  stdout?: string
  stderr?: string
  exitCode?: number
  durationMs?: number
})

Source from the content-addressed store, hash-verified

489}
490
491function processHookJSONOutput({
492 json,
493 command,
494 hookName,
495 toolUseID,
496 hookEvent,
497 expectedHookEvent,
498 stdout,
499 stderr,
500 exitCode,
501 durationMs,
502}: {
503 json: SyncHookJSONOutput
504 command: string
505 hookName: string
506 toolUseID: string
507 hookEvent: HookEvent
508 expectedHookEvent?: HookEvent
509 stdout?: string
510 stderr?: string
511 exitCode?: number
512 durationMs?: number
513}): Partial<HookResult> {
514 const result: Partial<HookResult> = {}
515
516 // At this point we know it's a sync response
517 const syncJson = json
518
519 // Handle common elements
520 if (syncJson.continue === false) {
521 result.preventContinuation = true
522 if (syncJson.stopReason) {
523 result.stopReason = syncJson.stopReason
524 }
525 }
526
527 if (json.decision) {
528 switch (json.decision) {
529 case 'approve':
530 result.permissionBehavior = 'allow'
531 break
532 case 'block':
533 result.permissionBehavior = 'deny'
534 result.blockingError = {
535 blockingError: json.reason || 'Blocked by hook',
536 command,
537 }
538 break
539 default:
540 // Handle unknown decision types as errors
541 throw new Error(
542 `Unknown hook decision type: ${json.decision}. Valid types are: approve, block`,
543 )
544 }
545 }
546
547 // Handle systemMessage field
548 if (json.systemMessage) {

Callers 2

executeHooksFunction · 0.85
executeHookCallbackFunction · 0.85

Calls 2

jsonStringifyFunction · 0.85
createAttachmentMessageFunction · 0.85

Tested by

no test coverage detected