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

Function createBaseHookInput

src/utils/hooks.ts:301–328  ·  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

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