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

Function createBaseHookInput

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

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