hook

package
v0.16.9 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToolCallFromContext added in v0.12.9

func ToolCallFromContext(ctx context.Context) (tool.ToolCall, bool)

func WithRuntime added in v0.12.9

func WithRuntime(ctx context.Context, runtime Runtime) context.Context

func WithToolCall added in v0.12.9

func WithToolCall(ctx context.Context, call tool.ToolCall) context.Context

WithToolCall makes the active call available to permission hooks that fire from inside a tool while it asks the host for approval.

Types

type Hooks

type Hooks struct {
	PreToolUse        []PreToolUse
	PermissionRequest []PermissionRequest
	PostToolUse       []PostToolUse
	UserPromptSubmit  []UserPromptSubmit
	SessionStart      []SessionStart
	SessionEnd        []SessionEnd
	SubagentStart     []SubagentStart
	SubagentStop      []SubagentStop
	PreCompact        []PreCompact
	PostCompact       []PostCompact
	Stop              []Stop
}

func (*Hooks) Append added in v0.12.9

func (h *Hooks) Append(other Hooks)

type Outcome added in v0.12.9

type Outcome struct {
	// Block has event-specific Codex semantics: deny a tool/prompt, stop the
	// agentic loop, or continue a Stop/SubagentStop target.
	Block bool
	// Stop represents the universal {"continue": false} response.
	Stop              bool
	Reason            string
	AdditionalContext []string
	// UpdatedResult is an internal extension used by deterministic result
	// transforms such as truncation. Codex command hooks leave it nil.
	UpdatedResult *string
}

type PermissionBehavior added in v0.12.9

type PermissionBehavior string
const (
	PermissionUndecided PermissionBehavior = ""
	PermissionAllow     PermissionBehavior = "allow"
	PermissionDeny      PermissionBehavior = "deny"
)

type PermissionRequest added in v0.12.9

type PermissionRequest func(ctx context.Context, call tool.ToolCall) (PermissionRequestOutcome, error)

type PermissionRequestOutcome added in v0.12.9

type PermissionRequestOutcome struct {
	Behavior PermissionBehavior
	Message  string
}

type PostCompact added in v0.12.9

type PostCompact func(ctx context.Context, trigger string) (Outcome, error)

type PostToolUse

type PostToolUse func(ctx context.Context, call tool.ToolCall, result string) (Outcome, error)

type PreCompact added in v0.11.2

type PreCompact func(ctx context.Context, trigger string) (Outcome, error)

type PreToolUse

type PreToolUse func(ctx context.Context, call tool.ToolCall) (PreToolUseOutcome, error)

type PreToolUseOutcome added in v0.12.9

type PreToolUseOutcome struct {
	Outcome
	UpdatedInput json.RawMessage
}

type Runtime added in v0.12.9

type Runtime struct {
	SessionID      string
	TurnID         string
	TranscriptPath string
	CWD            string
	Model          string
	PermissionMode string
	StartSource    string
	AgentID        string
	AgentType      string
}

Runtime carries the Codex hook fields shared by lifecycle events. Callers may populate only the fields they know; the external hook adapter supplies Codex-compatible zero/null values for the rest.

func RuntimeFromContext added in v0.12.9

func RuntimeFromContext(ctx context.Context) Runtime

type SessionEnd added in v0.11.2

type SessionEnd func(ctx context.Context, reason string)

type SessionStart added in v0.11.2

type SessionStart func(ctx context.Context, source string) (Outcome, error)

type Stop added in v0.12.9

type Stop func(ctx context.Context, lastAssistantMessage string, active bool) (Outcome, error)

type SubagentStart added in v0.12.9

type SubagentStart func(ctx context.Context, agentID, agentType string) (Outcome, error)

type SubagentStop added in v0.11.2

type SubagentStop func(ctx context.Context, agentID, agentType, result string, active bool) (Outcome, error)

type UserPromptSubmit added in v0.11.2

type UserPromptSubmit func(ctx context.Context, prompt string) (Outcome, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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