Documentation
¶
Overview ¶
Package hooks runs validated layered hook actions at agent lifecycle points.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type CommandInput ¶
type CommandInput struct {
Command string
Args []string
Environment map[string]string
WorkingDir string
Stdin []byte
MaxOutput int
}
CommandInput is the fully structured event a command action receives on stdin. Arguments are passed directly without a shell.
type CommandRunner ¶
type CommandRunner func(context.Context, CommandInput) ([]byte, error)
CommandRunner is a test seam around a direct executable invocation.
type ContextTokenCounter ¶
type ContextTokenCounter func(context.Context, Invocation) (int, error)
ContextTokenCounter estimates the active request's input tokens immediately before a command action runs. It is an estimate for local hook policy, not provider-reported billing usage.
type EventPublisher ¶
EventPublisher publishes hook notices through the runtime's durable event path when the host wires one.
type Invocation ¶
type Invocation struct {
Event harness.HookEvent `json:"event"`
SessionID uuid.UUID `json:"sessionId,omitempty"`
RequestID uuid.UUID `json:"requestId,omitempty"`
TurnID uuid.UUID `json:"turnId,omitempty"`
Tool string `json:"tool,omitempty"`
CallID string `json:"callId,omitempty"`
Workspace string `json:"workspace"`
Paths []string `json:"paths,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
// StateDirectory is a private, per-session directory available only to
// command actions. It is omitted when an invocation has no session.
StateDirectory string `json:"stateDirectory,omitempty"`
// ContextTokens is the estimated active request input token count at the
// command boundary. Zero means no counter was configured or the estimate
// itself was zero.
ContextTokens int `json:"contextTokens"`
// HasContextTokenEstimate is internal runner state. Callers that already
// hold an exact active-request estimate set it so Runner does not replace
// it with a broader lifecycle estimate.
HasContextTokenEstimate bool `json:"-"`
}
Invocation is one full lifecycle occurrence available to hook matching and command stdin. Paths are canonical host paths chosen by the tool adapter.
type Options ¶
type Options struct {
Snapshot harness.Snapshot
Workspace string
EnableWorkspaceHooks bool
CommandTimeout time.Duration
MaxCommandOutput int
Publisher EventPublisher
RunCommand CommandRunner
StateRoot string
ContextTokenCounter ContextTokenCounter
}
Options defines the execution policy for one turn's resolved hook list.
type Outcome ¶
type Outcome struct {
Injections []string
}
Outcome is the non-destructive effect of a hook invocation. A caller makes injected messages model-visible at its next safe protocol boundary.