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

Function createBaseHookInput

source code/utils/hooks.ts:303–330  ·  view source on GitHub ↗
(
  permissionMode?: string,
  sessionId?: string,
  // Typed narrowly (not ToolUseContext) so callers can pass toolUseContext
  // directly via structural typing without this function depending on Tool.ts.
  agentInfo?: { agentId?: string; agentType?: string },
)

Source from the content-addressed store, hash-verified

301 * Creates the base hook input that's common to all hook types
302 */
303export function createBaseHookInput(
304 permissionMode?: string,
305 sessionId?: string,
306 // Typed narrowly (not ToolUseContext) so callers can pass toolUseContext
307 // directly via structural typing without this function depending on Tool.ts.
308 agentInfo?: { agentId?: string; agentType?: string },
309): {
310 session_id: string
311 transcript_path: string
312 cwd: string
313 permission_mode?: string
314 agent_id?: string
315 agent_type?: string
316} {
317 const resolvedSessionId = sessionId ?? getSessionId()
318 // agent_type: subagent's type (from toolUseContext) takes precedence over
319 // the session's --agent flag. Hooks use agent_id presence to distinguish
320 // subagent calls from main-thread calls in a --agent session.
321 const resolvedAgentType = agentInfo?.agentType ?? getMainThreadAgentType()
322 return {
323 session_id: resolvedSessionId,
324 transcript_path: getTranscriptPathForSession(resolvedSessionId),
325 cwd: getCwd(),
326 permission_mode: permissionMode,
327 agent_id: agentInfo?.agentId,
328 agent_type: resolvedAgentType,
329 }
330}
331
332export interface HookBlockingError {
333 blockingError: string

Callers 15

executePreToolHooksFunction · 0.85
executePostToolHooksFunction · 0.85
executeNotificationHooksFunction · 0.85
executeStopFailureHooksFunction · 0.85
executeStopHooksFunction · 0.85
executeTeammateIdleHooksFunction · 0.85
executeTaskCreatedHooksFunction · 0.85

Calls 4

getSessionIdFunction · 0.85
getMainThreadAgentTypeFunction · 0.85
getCwdFunction · 0.85

Tested by

no test coverage detected