Versions in this module Expand all Collapse all v0 v0.4.0 Jul 27, 2026 v0.3.0 Jul 24, 2026 v0.2.1 Jul 23, 2026 v0.2.0 Jul 23, 2026 v0.1.0 Jul 4, 2026 Changes in this version + const DefaultContinuationCap + var ErrLossyUpdate = errors.New("agenthooks: updated input removes keys; provider merge is shallow (lossy)") + var ErrUnsupportedDecision = errors.New("agenthooks: decision unsupported by provider") + func CompileMatcher(p Provider, m ToolMatcher) (expr string, ok bool) + func Logger(ctx context.Context) *slog.Logger + func Main(r *Runner) + func SynthesizeToolID(sessionID, turnID, toolName string, input []byte) string + type AgentInfo struct + ID string + Type string + type AskFallback int + const FallbackDeny + const FallbackNoDecision + type CanonicalTool string + const ToolFetch + const ToolFileEdit + const ToolFileRead + const ToolFileWrite + const ToolMCP + const ToolOther + const ToolSearch + const ToolShell + const ToolTask + func CanonicalToolFor(name string) CanonicalTool + type CapSet map[Capability]bool + func Capabilities(p Provider, v Variant, k EventKind) CapSet + func (s CapSet) Has(c Capability) bool + type Capability string + const CapAddContext + const CapAllow + const CapAsk + const CapContinueAgent + const CapDeny + const CapReplaceOutput + const CapStopAgent + const CapSystemMessage + const CapUpdateInput + type CompactEvent struct + Instructions string + Trigger string + type DegradeMode int + const Degrade + const Strict + type DetectionConfidence string + const DetectionConfig + const DetectionEnv + const DetectionShape + type Event struct + Agent *AgentInfo + Backfilled bool + DetectionConfidence DetectionConfidence + Kind EventKind + NativeName string + Provider Provider + Raw json.RawMessage + Session SessionInfo + Time time.Time + Variant Variant + func EventOf(typed any) *Event + func (e *Event) Can(c Capability) bool + func (e *Event) RawField(path string) json.RawMessage + type EventKind string + const KindCompactPost + const KindCompactPre + const KindFileEdited + const KindModelRequest + const KindModelResponse + const KindNotification + const KindOther + const KindPermission + const KindPromptSubmitted + const KindSessionEnd + const KindSessionStart + const KindStop + const KindSubagentStart + const KindSubagentStop + const KindToolError + const KindToolPost + const KindToolPre + type FailMode int + const FailClosed + const FailOpen + type FileEditedEvent struct + Path string + type MCPCall struct + Command string + FromConfig bool + Server string + Tool string + URL string + func ParseMCPName(name string) *MCPCall + type ModelEvent struct + type NotificationEvent struct + Message string + type Option func(*Runner) + func WithDedupDir(dir string) Option + func WithLogger(l *slog.Logger) Option + func WithPolicy(p Policy) Option + func WithPolicyFunc(f PolicyFunc) Option + func WithoutBackfill() Option + func WithoutDedup() Option + func WithoutMCPListFallback() Option + func WithoutMCPResolution() Option + type PermissionEvent struct + Tool ToolCall + type Policy struct + AskFallback AskFallback + ContinuationCap int + Fail FailMode + Timeout time.Duration + Unsupported DegradeMode + type PolicyFunc func(*Event) Policy + type PromptDecision struct + func AcceptPrompt() PromptDecision + func BlockPrompt(reason string) PromptDecision + func (d PromptDecision) StopAgent(reason string) PromptDecision + func (d PromptDecision) WithContext(s string) PromptDecision + func (d PromptDecision) WithSystemMessage(s string) PromptDecision + type PromptEvent struct + Prompt string + type Provider string + const ProviderClaudeCode + const ProviderCodex + const ProviderCursor + const ProviderGemini + const ProviderKimi + const ProviderOpenCode + type Quirk struct + Behavior string + Capability Capability + Event EventKind + ID int + Mitigation string + Provider Provider + Reference string + Versions string + func Quirks() []Quirk + func QuirksFor(p Provider) []Quirk + type Runner struct + func New(opts ...Option) *Runner + func (r *Runner) OnAny(fn func(context.Context, *Event) error) + func (r *Runner) OnCompactPost(fn func(context.Context, *CompactEvent) error) + func (r *Runner) OnCompactPre(fn func(context.Context, *CompactEvent) error) + func (r *Runner) OnFileEdited(fn func(context.Context, *FileEditedEvent) error) + func (r *Runner) OnModelRequest(fn func(context.Context, *ModelEvent) error) + func (r *Runner) OnModelResponse(fn func(context.Context, *ModelEvent) error) + func (r *Runner) OnNotification(fn func(context.Context, *NotificationEvent) error) + func (r *Runner) OnOther(nativeName string, fn func(context.Context, *Event) error) + func (r *Runner) OnPermission(fn func(context.Context, *PermissionEvent) (ToolPreDecision, error)) + func (r *Runner) OnPromptSubmitted(fn func(context.Context, *PromptEvent) (PromptDecision, error)) + func (r *Runner) OnSessionEnd(fn func(context.Context, *SessionEndEvent) error) + func (r *Runner) OnSessionStart(fn func(context.Context, *SessionStartEvent) (SessionStartDecision, error)) + func (r *Runner) OnStop(fn func(context.Context, *StopEvent) (StopDecision, error)) + func (r *Runner) OnSubagentStart(fn func(context.Context, *SubagentStartEvent) error) + func (r *Runner) OnSubagentStop(fn func(context.Context, *StopEvent) (StopDecision, error)) + func (r *Runner) OnToolError(fn func(context.Context, *ToolPostEvent) (ToolPostDecision, error)) + func (r *Runner) OnToolPost(fn func(context.Context, *ToolPostEvent) (ToolPostDecision, error)) + func (r *Runner) OnToolPre(fn func(context.Context, *ToolPreEvent) (ToolPreDecision, error)) + func (r *Runner) Run(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) int + type SessionEndEvent struct + Reason string + type SessionInfo struct + CWD string + ID string + Model string + PermissionMode string + TranscriptPath string + TurnID string + UserEmail string + WorkspaceRoots []string + type SessionStartDecision struct + func ContinueSession() SessionStartDecision + func (d SessionStartDecision) WithContext(s string) SessionStartDecision + func (d SessionStartDecision) WithSystemMessage(s string) SessionStartDecision + type SessionStartEvent struct + Source string + type StopDecision struct + func ContinueWith(instruction string) StopDecision + func Finish() StopDecision + func (d StopDecision) WithSystemMessage(s string) StopDecision + type StopEvent struct + FinalMessage string + LoopCount int + PreviouslyContinued bool + Usage *Usage + type SubagentStartEvent struct + type ToolCall struct + Canonical CanonicalTool + ID string + Input json.RawMessage + MCP *MCPCall + Name string + RawInput json.RawMessage + Synthesized bool + type ToolMatcher struct + Canonical []CanonicalTool + MCP []string + Names []string + func ParseToolMatcher(s string) (ToolMatcher, error) + func (m ToolMatcher) Encode() string + func (m ToolMatcher) IsEmpty() bool + func (m ToolMatcher) Matches(t ToolCall) bool + type ToolPostDecision struct + func FlagOutput(reason string) ToolPostDecision + func Observed() ToolPostDecision + func ReplaceOutput(v any) ToolPostDecision + func (d ToolPostDecision) StopAgent(reason string) ToolPostDecision + func (d ToolPostDecision) WithContext(s string) ToolPostDecision + func (d ToolPostDecision) WithSystemMessage(s string) ToolPostDecision + type ToolPostEvent struct + DurationMS *float64 + Error string + Failed bool + Output json.RawMessage + Tool ToolCall + type ToolPreDecision struct + func Allow() ToolPreDecision + func AskUser(reason string) ToolPreDecision + func Deny(reason string) ToolPreDecision + func NoDecision() ToolPreDecision + func (d ToolPreDecision) StopAgent(reason string) ToolPreDecision + func (d ToolPreDecision) WithContext(s string) ToolPreDecision + func (d ToolPreDecision) WithSystemMessage(s string) ToolPreDecision + func (d ToolPreDecision) WithUpdatedInput(v any) ToolPreDecision + type ToolPreEvent struct + Tool ToolCall + type Usage struct + CacheReadTokens *int + CacheWriteTokens *int + Cost *float64 + InputTokens *int + LoopCount *int + OutputTokens *int + Status string + type Variant string + const VariantCLI + const VariantCloud + const VariantCowork + const VariantIDE + const VariantRemote + const VariantUnknown