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

Normalized agent hook declaration.

Hooks are declared in user config as maps or keyword lists, then normalized
by `MingaAgent.Config.resolve/0` into this struct. The event field selects
the lifecycle point; `tool_pattern` is required only for tool-related events
(`:pre_tool_use`, `:post_tool_use`).

# `event`

```elixir
@type event() ::
  :pre_tool_use
  | :post_tool_use
  | :session_start
  | :session_end
  | :stop
  | :user_prompt_submit
  | :pre_compact
  | :notification
```

Supported hook event names.

# `hook_type`

```elixir
@type hook_type() :: :shell | :module
```

Hook type: shell command or in-process Elixir module.

# `t`

```elixir
@type t() :: %MingaAgent.Hooks.Hook{
  command: String.t() | nil,
  event: event(),
  extension_module: module() | nil,
  extension_source: atom() | nil,
  function: atom() | nil,
  module: module() | nil,
  timeout_ms: pos_integer(),
  tool_pattern: String.t() | nil,
  type: hook_type()
}
```

Normalized hook declaration.

# `default_timeout_ms`

```elixir
@spec default_timeout_ms() :: pos_integer()
```

Returns the default per-hook timeout in milliseconds.

# `event_label`

```elixir
@spec event_label(event()) :: String.t()
```

Returns the human-readable label for an event atom.

# `matches?`

```elixir
@spec matches?(t(), event()) :: boolean()
```

Returns true when this hook applies to the given non-tool event.

# `matches?`

```elixir
@spec matches?(t(), event(), String.t()) :: boolean()
```

Returns true when this hook applies to the event and tool name.

# `normalize`

```elixir
@spec normalize(term()) :: {:ok, t()} | {:error, String.t()}
```

Normalizes a user config hook declaration into a `%Hook{}`.

# `tool_event?`

```elixir
@spec tool_event?(event()) :: boolean()
```

Returns true if the event is tool-related and uses `tool_pattern` matching.

---

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