hooks

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(event string, he config.HookEntry) error

Types

type Decision

type Decision struct {
	AdditionalContext string
	UpdatedInput      json.RawMessage
}

Decision is what passing hooks add to a call or prompt; a block is returned as an error instead.

type EventType

type EventType string
const (
	PreToolUse         EventType = "PreToolUse"
	PostToolUse        EventType = "PostToolUse"
	Notification       EventType = "Notification"
	PostStopValidation EventType = "PostStopValidation"
	SessionStart       EventType = "SessionStart"
	SessionEnd         EventType = "SessionEnd"
	UserPromptSubmit   EventType = "UserPromptSubmit"
)

type Payload

type Payload struct {
	Event   EventType       `json:"event"`
	Tool    string          `json:"tool,omitempty"`
	Args    json.RawMessage `json:"args,omitempty"`
	Output  json.RawMessage `json:"output,omitempty"`
	IsError bool            `json:"is_error,omitempty"`
	Message string          `json:"message,omitempty"`
	Prompt  string          `json:"prompt,omitempty"` // UserPromptSubmit
}

Payload is the JSON written to the hook command's stdin.

type Runner

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

Runner runs hooks without asking: only hooks the user wrote or agreed to reach it.

func New

func New(sessionID string, model func() agentcore.Model) *Runner

New has no hooks until Set. Prompt hooks call model each time they run, so they follow model switches.

func (*Runner) PostToolUse

func (r *Runner) PostToolUse() agentcore.ToolMiddleware

PostToolUse passes the result text to the hooks as a JSON string.

func (*Runner) PreToolUse

func (r *Runner) PreToolUse() agentcore.ToolMiddleware

PreToolUse runs before the permission check, so rewritten arguments are what gets checked and run.

func (*Runner) RunNotification

func (r *Runner) RunNotification(message string)

func (*Runner) RunSessionEnd

func (r *Runner) RunSessionEnd()

func (*Runner) RunSessionStart

func (r *Runner) RunSessionStart()

func (*Runner) RunUserPromptSubmit

func (r *Runner) RunUserPromptSubmit(ctx context.Context, prompt string) (Decision, error)

func (*Runner) Set

func (r *Runner) Set(cfg config.HooksConfig)

type Validation

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

Validation runs the PostStopValidation hooks when a run that changed the repository would stop, and sends the agent back once to fix a failure.

func NewValidation

func NewValidation(r *Runner) *Validation

func (*Validation) Check

func (v *Validation) Check(ctx context.Context) string

Check is called when a run would stop; "" lets it stop.

func (*Validation) Track

Jump to

Keyboard shortcuts

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