hooks

package
v0.107.13 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionStart       = "SessionStart"
	UserPromptSubmit   = "UserPromptSubmit"
	PreToolUse         = "PreToolUse"
	PostToolUse        = "PostToolUse"
	PostToolUseFailure = "PostToolUseFailure"
	PreCompact         = "PreCompact"
	PostCompact        = "PostCompact"
	Stop               = "Stop"
	SessionEnd         = "SessionEnd"
)

Event names. config.HookEvents lists the same set for validation.

Variables

This section is empty.

Functions

func Parse

func Parse(data []byte) (map[string][]config.Hook, error)

Types

type DeniedError added in v0.107.13

type DeniedError struct {
	Reason string
}

DeniedError is a PreToolUse hook's structured refusal: it exited 0 and printed {"decision":"deny","reason":"..."} as its output or as the last output line.

func (*DeniedError) Error added in v0.107.13

func (e *DeniedError) Error() string

type Event

type Event struct {
	Name       string `json:"event"`
	SessionID  string `json:"sessionId,omitempty"`
	CWD        string `json:"cwd,omitempty"`
	Prompt     string `json:"prompt,omitempty"`
	ToolID     string `json:"toolId,omitempty"`
	ToolName   string `json:"toolName,omitempty"`
	ToolArgs   string `json:"toolArgs,omitempty"`
	ToolResult string `json:"toolResult,omitempty"`

	// Trigger is "auto" or "manual" for PreCompact and PostCompact.
	Trigger string `json:"trigger,omitempty"`
	// MessagesBefore and TokensBefore describe the context PreCompact and
	// PostCompact compact; MessagesAfter and TokensAfter the result (PostCompact).
	// Tokens are the agent's estimate.
	MessagesBefore int `json:"messagesBefore,omitempty"`
	TokensBefore   int `json:"tokensBefore,omitempty"`
	MessagesAfter  int `json:"messagesAfter,omitempty"`
	TokensAfter    int `json:"tokensAfter,omitempty"`
	// Summary is the new compaction summary (PostCompact).
	Summary string `json:"summary,omitempty"`
	// Reason says why a session ended (SessionEnd): "exit", "close" or "switch".
	Reason string `json:"reason,omitempty"`
}

type Runner

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

func New

func New(items map[string][]config.Hook) *Runner

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, event Event) error

Jump to

Keyboard shortcuts

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