type PermissionProfileName = "default" | "read-only" | "trusted-dev"; type PermissionProfileDecision = "allow" | "ask" | "deny"; type PermissionProfileMode = "default" | "acceptEdits" | "bypassPermissions" | "auto"; interface PermissionProfile { schemaVersion: 1; name: PermissionProfileName; displayName: string; description: string; permissionMode: PermissionProfileMode; filesystem: { scope: "workspace" | "workspace-readonly" | "unrestricted"; read: PermissionProfileDecision; write: PermissionProfileDecision; allowedPaths: string[]; deniedPaths: string[]; }; shell: { default: PermissionProfileDecision; allowedCommands: string[]; deniedCommands: string[]; }; network: { default: PermissionProfileDecision; allowDomains: string[]; denyDomains: string[]; }; mcp: { remoteServers: PermissionProfileDecision; allowedServers: string[]; deniedServers: string[]; }; lsp: { enabled: boolean; diagnostics: PermissionProfileDecision; navigation: PermissionProfileDecision; startProcesses: PermissionProfileDecision; }; } declare const AGENT_PERMISSION_MODES: readonly [ "default", "plan", "acceptEdits", "auto", "dontAsk", "bypassPermissions" ]; type AgentPermissionMode = (typeof AGENT_PERMISSION_MODES)[number]; type HookEventName = "SessionStart" | "UserPromptSubmit" | "PermissionRequest" | "PreToolUse" | "PostToolUse" | "PreCompact" | "PostCompact" | "Stop" | "StopFailure" | "SubagentStart" | "SubagentStop"; type HookPermissionMode = AgentPermissionMode; interface HookInputBase { schemaVersion: 1; event: HookEventName; sessionId: string; runId: string; rootRunId: string; agentId: string; agentName?: string; agentColor?: string; parentAgentId?: string; cwd: string; transcriptPath?: string; permissionMode: HookPermissionMode; model: string; effort?: string; timestamp: string; } interface HookInvocationInput extends HookInputBase { prompt?: string; toolName?: string; toolInput?: Record; toolResult?: unknown; finalText?: string; metadata?: Record; } type HookDecision = { decision: "allow"; systemMessage?: string; context?: string; } | { decision: "block"; reason: string; systemMessage?: string; } | { decision: "ask"; reason: string; prompt: string; } | { decision: "modify"; patch: unknown; reason?: string; } | { decision: "continue"; context?: string; systemMessage?: string; }; interface BaseHookDefinition { name?: string; events?: HookEventName[]; timeoutMs?: number; maxOutputBytes?: number; failClosed?: boolean; async?: boolean; } interface CommandHookDefinition extends BaseHookDefinition { type: "command"; command: string; args?: string[]; cwd?: string; shell?: boolean; env?: Record; } interface HttpHookDefinition extends BaseHookDefinition { type: "http"; url: string; method?: "POST"; headers?: Record; } interface PromptHookDefinition extends BaseHookDefinition { type: "prompt"; prompt: string; } interface AgentHookDefinition extends BaseHookDefinition { type: "agent"; prompt: string; agent?: string; model?: string; } type HookDefinition = CommandHookDefinition | HttpHookDefinition | PromptHookDefinition | AgentHookDefinition; type HookInput = HookInvocationInput; interface HookConfig { hooks?: HookDefinition[]; events?: Partial>; } type HookModelExecutor = (definition: PromptHookDefinition | AgentHookDefinition, input: HookInvocationInput) => HookDecision | Promise; type HookExecutionStatus = "allowed" | "blocked" | "asked" | "modified" | "continued" | "errored" | "timed_out"; interface HookExecutionResult { hook: HookDefinition; status: HookExecutionStatus; decision?: HookDecision; exitCode?: number | null; signal?: NodeJS.Signals | null; stdout: string; stderr: string; stdoutTruncated: boolean; stderrTruncated: boolean; timedOut: boolean; durationMs: number; error?: string; } interface HookRunResult { decision: HookDecision; results: HookExecutionResult[]; context: string[]; systemMessages: string[]; } interface HookRuntimeOptions { defaultTimeoutMs?: number; defaultMaxOutputBytes?: number; env?: NodeJS.ProcessEnv; permissionProfile?: PermissionProfile; promptExecutor?: HookModelExecutor; agentExecutor?: HookModelExecutor; } declare function normalizeHookDecision(value: unknown): HookDecision; declare function buildHookEnvironment(input: HookInvocationInput, definition: CommandHookDefinition, sourceEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv; declare function hookResultStatus(decision: HookDecision | undefined): HookExecutionResult["status"]; declare function runCommandHook(definition: CommandHookDefinition, input: HookInvocationInput, options?: HookRuntimeOptions): Promise; declare function runHttpHook(definition: HttpHookDefinition, input: HookInvocationInput, options?: HookRuntimeOptions): Promise; declare function runPromptHook(definition: PromptHookDefinition, input: HookInvocationInput, options?: HookRuntimeOptions): Promise; declare function runAgentHook(definition: AgentHookDefinition, input: HookInvocationInput, options?: HookRuntimeOptions): Promise; declare class PromptHookRunner { private readonly executor; private readonly options; constructor(executor: HookModelExecutor, options?: HookRuntimeOptions); run(definition: PromptHookDefinition, input: HookInvocationInput): Promise; } declare class AgentHookRunner { private readonly executor; private readonly options; constructor(executor: HookModelExecutor, options?: HookRuntimeOptions); run(definition: AgentHookDefinition, input: HookInvocationInput): Promise; } declare function runHookDefinition(hook: HookDefinition, input: HookInvocationInput, options?: HookRuntimeOptions): Promise; declare function runHooks(hooks: readonly HookDefinition[], input: HookInvocationInput, options?: HookRuntimeOptions): Promise; declare class HookRunner { private readonly hooks; private readonly options; constructor(hooks: readonly HookDefinition[], options?: HookRuntimeOptions); run(input: HookInvocationInput): Promise; } declare class HookRuntime { private readonly config; private readonly options; constructor(config: HookConfig, options?: HookRuntimeOptions); run(input: HookInvocationInput): Promise; } declare class CommandHookRunner { private readonly options; constructor(options?: HookRuntimeOptions); run(definition: CommandHookDefinition, input: HookInvocationInput): Promise; } declare class HttpHookRunner { private readonly options; constructor(options?: HookRuntimeOptions); run(definition: HttpHookDefinition, input: HookInvocationInput): Promise; } export { type AgentHookDefinition, AgentHookRunner, type BaseHookDefinition, type CommandHookDefinition, CommandHookRunner, type HookConfig, type HookDecision, type HookDefinition, type HookEventName, type HookExecutionResult, type HookExecutionStatus, type HookInput, type HookInputBase, type HookInvocationInput, type HookModelExecutor, type HookPermissionMode, type HookRunResult, HookRunner, HookRuntime, type HookRuntimeOptions, type HttpHookDefinition, HttpHookRunner, type PromptHookDefinition, PromptHookRunner, buildHookEnvironment, hookResultStatus, normalizeHookDecision, runAgentHook, runCommandHook, runHookDefinition, runHooks, runHttpHook, runPromptHook };