MingaAgent.Hooks.Hook (Minga v0.1.0)

Copy Markdown View Source

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).

Summary

Types

Supported hook event names.

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

t()

Normalized hook declaration.

Functions

Returns the default per-hook timeout in milliseconds.

Returns the human-readable label for an event atom.

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

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

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

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

Types

event()

@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()

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

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

t()

@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.

Functions

default_timeout_ms()

@spec default_timeout_ms() :: pos_integer()

Returns the default per-hook timeout in milliseconds.

event_label(atom)

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

Returns the human-readable label for an event atom.

matches?(hook, event)

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

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

matches?(hook, event, tool_name)

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

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

normalize(raw)

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

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

tool_event?(event)

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

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