Documentation
¶
Overview ¶
Package hook defines nil-safe lifecycle callbacks for observability. Hooks only observe; they cannot veto execution (authorization is a separate rbac concern). The core never imports a logging library; x/otel implements these callbacks to emit spans and metrics.
Index ¶
- type Hooks
- func (h *Hooks) FireAfterTool(ctx context.Context, name string, err error)
- func (h *Hooks) FireAuthorize(ctx context.Context, req rbac.Request, dec rbac.Decision)
- func (h *Hooks) FireBeforeTool(ctx context.Context, name string, input json.RawMessage) context.Context
- func (h *Hooks) FireCostGate(ctx context.Context, plan cost.Plan, score cost.Score, decision string)
- func (h *Hooks) FireOnError(ctx context.Context, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hooks ¶
type Hooks struct {
BeforeTool func(ctx context.Context, name string, input json.RawMessage) context.Context
AfterTool func(ctx context.Context, name string, err error)
OnError func(ctx context.Context, err error)
OnCostGate func(ctx context.Context, plan cost.Plan, score cost.Score, decision string)
OnAuthorize func(ctx context.Context, req rbac.Request, dec rbac.Decision)
}
Hooks holds optional lifecycle callbacks. Every Fire* method is nil-safe: a nil Hooks or nil field is a no-op.
func Join ¶ added in v0.1.6
Join composes hooks so independent consumers (tracing, metrics, ...) can observe the same lifecycle. Callbacks run in argument order; BeforeTool threads the context through the chain. Nil entries are skipped.
func (*Hooks) FireAfterTool ¶
FireAfterTool runs AfterTool if set.
func (*Hooks) FireAuthorize ¶
FireAuthorize runs OnAuthorize if set.
func (*Hooks) FireBeforeTool ¶
func (h *Hooks) FireBeforeTool(ctx context.Context, name string, input json.RawMessage) context.Context
FireBeforeTool runs BeforeTool or returns ctx unchanged.