NewHookRegistry (runtime/hooks.go)

initializ/forge · forge-core/runtime/hooks.go · go · Apache-2.0
ai

Module exposing: NewHookRegistry, Register, Fire, WithProgressEmitter, ProgressEmitterFromContext, HookContext, HookRegistry, ProgressEvent

// Source: https://github.com/initializ/forge | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package runtime

import (
	"context"
	"time"

	"github.com/initializ/forge/forge-core/llm"
)

// HookPoint identifies when a hook fires in the agent loop.
type HookPoint int

const (
	BeforeLLMCall HookPoint = iota
	AfterLLMCall
	BeforeToolExec
	AfterToolExec
	OnError
)

// HookContext carries data available to hooks at each hook point.
//
// LLMCallDuration / ToolExecDuration / Provider / Model are populated
// at the call site (loop.go) before the After* hook fires, so audit
// emitters can tag llm_call and tool_exec events with wall-clock
// timing and provider attribution. See issue #

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key