# `MingaAgent.Hooks.Dispatcher`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_agent/hooks/dispatcher.ex#L1)

Dispatches normalized agent hooks for lifecycle events.

The dispatcher is intentionally stateless. It receives a list of hooks from
`MingaAgent.Config`, filters matching hooks in registration order, and asks a
runner to execute each hook. For veto-capable events the first veto
short-circuits later hooks; for notification-only events vetoes are
broadcast as events and logged as warnings but do not block.

# `runner`

```elixir
@type runner() :: (MingaAgent.Hooks.Hook.t(), map() -&gt; MingaAgent.Hooks.Result.t())
```

Hook runner used by tests and production command execution.

# `dispatch`

```elixir
@spec dispatch(
  MingaAgent.Hooks.Hook.event(),
  [MingaAgent.Hooks.Hook.t()],
  map(),
  keyword()
) ::
  :ok | {:error, MingaAgent.Hooks.Result.t()}
```

Runs all matching hooks for an event in registration order.

# `notification`

```elixir
@spec notification([MingaAgent.Hooks.Hook.t()], map(), keyword()) :: :ok
```

Runs all matching `Notification` hooks (notification-only).

# `post_tool_use`

```elixir
@spec post_tool_use([MingaAgent.Hooks.Hook.t()], map(), keyword()) :: :ok
```

Runs all matching `PostToolUse` hooks (notification-only).

# `pre_compact`

```elixir
@spec pre_compact([MingaAgent.Hooks.Hook.t()], map(), keyword()) ::
  :ok | {:error, MingaAgent.Hooks.Result.t()}
```

Runs all matching `PreCompact` hooks (veto-capable).

# `pre_tool_use`

```elixir
@spec pre_tool_use(
  [MingaAgent.Hooks.Hook.t()],
  MingaAgent.Hooks.PreToolUsePayload.t()
) ::
  :ok | {:error, MingaAgent.Hooks.Result.t()}
```

Runs all matching `PreToolUse` hooks in registration order.

# `pre_tool_use`

```elixir
@spec pre_tool_use(
  [MingaAgent.Hooks.Hook.t()],
  MingaAgent.Hooks.PreToolUsePayload.t(),
  keyword()
) ::
  :ok | {:error, MingaAgent.Hooks.Result.t()}
```

Runs matching `PreToolUse` hooks with an injected runner.

# `session_end`

```elixir
@spec session_end([MingaAgent.Hooks.Hook.t()], map(), keyword()) :: :ok
```

Runs all matching `SessionEnd` hooks (notification-only).

# `session_start`

```elixir
@spec session_start([MingaAgent.Hooks.Hook.t()], map(), keyword()) :: :ok
```

Runs all matching `SessionStart` hooks (notification-only).

# `stop`

```elixir
@spec stop([MingaAgent.Hooks.Hook.t()], map(), keyword()) :: :ok
```

Runs all matching `Stop` hooks (notification-only).

# `user_prompt_submit`

```elixir
@spec user_prompt_submit([MingaAgent.Hooks.Hook.t()], map(), keyword()) ::
  :ok | {:error, MingaAgent.Hooks.Result.t()}
```

Runs all matching `UserPromptSubmit` hooks (veto-capable).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
