external

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: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildOptions added in v0.12.9

type BuildOptions struct {
	Gate        *Gate
	Environment map[string]string
}

BuildOptions supplies source-specific trust and environment settings.

type Config

type Config struct {
	Description string `json:"description,omitempty"`
	Hooks       Events `json:"hooks"`
}

Config is the Codex hooks.json shape. HTTP is a Wingman extension whose request and successful response bodies use the same wire schema as command hooks.

func Load

func Load(paths ...string) (*Config, error)

func Parse added in v0.12.9

func Parse(name string, data []byte) (*Config, error)

Parse reads one named hooks.json document. The name is used only in errors, which also makes this suitable for inline plugin hook declarations.

func (*Config) Build added in v0.12.9

func (c *Config) Build(workDir string, gate *Gate) hook.Hooks

Build compiles all matching handlers for each event into one native hook so handlers within a Codex event can execute concurrently and aggregate their decisions before the agent continues.

func (*Config) BuildWithOptions added in v0.12.9

func (c *Config) BuildWithOptions(workDir string, options BuildOptions) hook.Hooks

BuildWithOptions compiles hooks and injects source-specific environment variables into command handlers. HTTP handlers intentionally do not inherit these values into headers unless the process environment explicitly exposes them through allowedEnvVars.

func (*Config) Merge added in v0.12.9

func (c *Config) Merge(other *Config)

Merge appends another hook source while preserving source order.

func (*Config) RuleCount added in v0.11.2

func (c *Config) RuleCount() int

type Events added in v0.12.9

type Events struct {
	PreToolUse        []MatcherGroup `json:"PreToolUse,omitempty"`
	PermissionRequest []MatcherGroup `json:"PermissionRequest,omitempty"`
	PostToolUse       []MatcherGroup `json:"PostToolUse,omitempty"`
	PreCompact        []MatcherGroup `json:"PreCompact,omitempty"`
	PostCompact       []MatcherGroup `json:"PostCompact,omitempty"`
	SessionStart      []MatcherGroup `json:"SessionStart,omitempty"`
	SessionEnd        []MatcherGroup `json:"SessionEnd,omitempty"`
	UserPromptSubmit  []MatcherGroup `json:"UserPromptSubmit,omitempty"`
	SubagentStart     []MatcherGroup `json:"SubagentStart,omitempty"`
	SubagentStop      []MatcherGroup `json:"SubagentStop,omitempty"`
	Stop              []MatcherGroup `json:"Stop,omitempty"`
}

type Gate

type Gate struct {
	Confirm func(ctx context.Context, message string) (bool, error)
	Message string
	// contains filtered or unexported fields
}

Gate defers a workspace trust decision until the first matching hook fires.

func (*Gate) Allowed

func (g *Gate) Allowed(ctx context.Context) bool

type Handler added in v0.12.9

type Handler struct {
	Type                   string            `json:"type"`
	Command                string            `json:"command,omitempty"`
	CommandWindows         string            `json:"commandWindows,omitempty"`
	CommandWindowsSnake    string            `json:"command_windows,omitempty"`
	Server                 string            `json:"server,omitempty"`
	Tool                   string            `json:"tool,omitempty"`
	Input                  map[string]any    `json:"input,omitempty"`
	Prompt                 string            `json:"prompt,omitempty"`
	Model                  string            `json:"model,omitempty"`
	URL                    string            `json:"url,omitempty"`
	Headers                map[string]string `json:"headers,omitempty"`
	AllowedEnvVars         []string          `json:"allowedEnvVars,omitempty"`
	Timeout                *int              `json:"timeout,omitempty"`
	Async                  bool              `json:"async,omitempty"`
	StatusMessage          string            `json:"statusMessage,omitempty"`
	AdditionalContextLimit *int              `json:"additionalContextLimit,omitempty"`
}

type MatcherGroup added in v0.12.9

type MatcherGroup struct {
	Matcher string    `json:"matcher,omitempty"`
	Hooks   []Handler `json:"hooks"`
}

Jump to

Keyboard shortcuts

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