SkillKit.Hooks (SkillKit v0.1.0)

Copy Markdown View Source

Dispatches lifecycle hooks at agent boundaries.

Two public functions:

  • call/4 — wraps a boundary in a telemetry span with pre/post hook dispatch. Blocks for a decision from pre-event hooks.
  • cast/3 — fires a single hook event, fire-and-forget.

Hook events are derived from boundary names: call(catalog, :tool_use, ...) fires :pre_tool_use before and :post_tool_use after the callback.

Summary

Functions

Wraps a boundary in a telemetry span with pre/post hook dispatch.

Fires a single hook event, fire-and-forget.

Types

decision()

@type decision() :: :ok | {:deny, term()} | {:pending, term()}

Functions

call(agent_or_catalog, boundary, context, func)

@spec call(GenServer.server() | SkillKit.Agent.t(), atom(), map(), (-> {term(), map()})) ::
  term()

Wraps a boundary in a telemetry span with pre/post hook dispatch.

Derives hook events from the boundary name: pre_<boundary> before executing func, post_<boundary> after. The telemetry span uses the boundary name directly.

func must return {result, post_context} where post_context is passed to post-event hooks.

cast(agent_or_catalog, event, context)

@spec cast(GenServer.server() | SkillKit.Agent.t(), SkillKit.Hook.event(), map()) ::
  :ok

Fires a single hook event, fire-and-forget.