hooks

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package hooks provides an event-based hook system for cross-cutting concerns.

Instead of individual callback fields on the executor, hooks allow multiple listeners to subscribe to events at various points in the execution lifecycle. This follows the middleware pattern from web frameworks: logging, telemetry, metrics, and other concerns register as hooks without modifying core logic.

Index

Constants

View Source
const (
	GoalStart        = "goal.start"
	GoalComplete     = "goal.complete"
	ToolCall         = "tool.call"
	ToolError        = "tool.error"
	LLMError         = "llm.error"
	SkillLoaded      = "skill.loaded"
	MCPToolCall      = "mcp.tool.call"
	SubAgentStart    = "subagent.start"
	SubAgentComplete = "subagent.complete"
	SupervisionEvent = "supervision.event"
)

Standard event types for the execution lifecycle.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type string
	Data map[string]any
}

Event carries data for a hook invocation.

type Hook

type Hook func(ctx context.Context, event Event)

Hook is a function called when an event fires.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds hooks organized by event type. It is safe for concurrent use.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty hook registry.

func (*Registry) Fire

func (r *Registry) Fire(ctx context.Context, eventType string, data map[string]any)

Fire invokes all hooks registered for the given event type. Hooks are called in registration order. A nil registry is safe to call.

func (*Registry) On

func (r *Registry) On(eventType string, hook Hook)

On registers a hook for the given event type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL