claudehooks

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package claudehooks observes Claude Code's structured lifecycle hooks. It has no telemetry, enrollment, or remote control-plane dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capabilities

func Capabilities() bridge.InteractionCapabilities

func Report

func Report(ctx context.Context, configPath string, input io.Reader) error

Report forwards only whitelisted hook metadata to the local session observer. It never returns a Claude permission decision or writes anything to stdout.

func ReportTo added in v1.4.11

func ReportTo(ctx context.Context, configPath string, input io.Reader, out io.Writer) error

ReportTo is Report with a destination for the hook's stdout. Only in remote-approval mode, and only for an eligible Bash permission request, does it wait for a remote decision and write Claude's PermissionRequest decision JSON to out. Otherwise it writes nothing, so Claude's own dialog decides.

Types

type Event

type Event struct {
	SessionID     string `json:"session_id"`
	Name          string `json:"hook_event_name"`
	Tool          string `json:"tool_name,omitempty"`
	ToolID        string `json:"tool_use_id,omitempty"`
	ToolKey       string `json:"tool_key,omitempty"`
	AgentID       string `json:"agent_id,omitempty"`
	PromptID      string `json:"prompt_id,omitempty"`
	Source        string `json:"source,omitempty"`
	Notification  string `json:"notification_type,omitempty"`
	ElicitationID string `json:"elicitation_id,omitempty"`
	Server        string `json:"mcp_server_name,omitempty"`
}

Event deliberately excludes prompts, tool arguments/results, paths, and text. The short-lived helper removes those fields before contacting the observer.

type Observer

type Observer struct {
	SettingsPath string
	ConfigPath   string
	Updates      <-chan bridge.Interaction
	Done         <-chan struct{}
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, executable string) (*Observer, error)

New creates an authenticated loopback receiver and private, session-local settings. Cancellation closes the receiver and removes both temporary files.

func NewWithOptions added in v1.4.11

func NewWithOptions(ctx context.Context, executable string, opts Options) (*Observer, error)

NewWithOptions is New with optional behaviour such as remote approval.

func (*Observer) Decide added in v1.4.11

func (o *Observer) Decide(pendingID, decision string) error

Decide delivers a remote approval decision ("accept" or "cancel") to the hook helper waiting on pendingID. It fails with ErrPendingRequestMismatch when nothing is waiting: remote approval is off, the request was already answered (locally or remotely), or it timed out.

type Options added in v1.4.11

type Options struct {
	// RemoteApproval lets Bridge answer Bash permission requests. The hook
	// helper waits for a remote decision while Claude Code shows its own
	// dialog; whichever answers first wins (Claude kills the hook when the
	// person answers locally). Off by default.
	RemoteApproval bool
}

Options configures optional observer behaviour.

Jump to

Keyboard shortcuts

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