codex

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentName   = agent.AgentCodex
	DisplayName = agent.DisplayCodex
)

Variables

View Source
var HookTypes = []string{
	"SessionStart",
	"PreToolUse",
	"PostToolUse",
	"UserPromptSubmit",
	"Stop",
}
View Source
var ToolNameMapping = map[string]events.ActionType{
	"Read":         events.ActionFileRead,
	"View":         events.ActionFileRead,
	"Write":        events.ActionFileWrite,
	"Edit":         events.ActionFileWrite,
	"NotebookEdit": events.ActionFileWrite,
	"Bash":         events.ActionCommandExec,
	"Execute":      events.ActionCommandExec,
	"WebSearch":    events.ActionToolUse,
	"WebFetch":     events.ActionToolUse,
	"Grep":         events.ActionFileRead,
	"Glob":         events.ActionFileRead,
	"LS":           events.ActionFileRead,
	"Task":         events.ActionToolUse,
	"TodoRead":     events.ActionToolUse,
	"TodoWrite":    events.ActionToolUse,
	"AskUser":      events.ActionToolUse,
}

Functions

func Detect

func Detect(ctx context.Context) (*agent.DetectionResult, error)

func GetHookStatus

func GetHookStatus(ctx context.Context) (*agent.HookStatus, error)

func InstallHooks

func InstallHooks(ctx context.Context, opts agent.InstallOptions) (*agent.InstallResult, error)

func Register

func Register(registry *agent.Registry, privacyChecker *events.PrivacyChecker, loggingLevel config.LoggingLevel, contentHash bool)

Types

type Adapter

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

func New

func New(privacyChecker *events.PrivacyChecker, loggingLevel config.LoggingLevel, contentHash bool) *Adapter

func (*Adapter) Detect

func (a *Adapter) Detect(ctx context.Context) (*agent.DetectionResult, error)

func (*Adapter) DisplayName

func (a *Adapter) DisplayName() string

func (*Adapter) Install

func (a *Adapter) Install(ctx context.Context, opts agent.InstallOptions) (*agent.InstallResult, error)

func (*Adapter) Name

func (a *Adapter) Name() string

func (*Adapter) ParseEvent

func (a *Adapter) ParseEvent(ctx context.Context, hookType string, rawData []byte) (*events.Event, error)

func (*Adapter) Status

func (a *Adapter) Status(ctx context.Context) (*agent.HookStatus, error)

func (*Adapter) Uninstall

type HookCommand

type HookCommand struct {
	Type    string `json:"type"`
	Command string `json:"command"`
	Timeout int    `json:"timeout,omitempty"`
}

type HookDecision

type HookDecision int
const (
	HookAllow HookDecision = iota
	HookBlock
	HookError
)

type HookInput

type HookInput struct {
	SessionID      string `json:"session_id"`
	TranscriptPath string `json:"transcript_path"`
	Cwd            string `json:"cwd"`
	HookEventName  string `json:"hook_event_name"`
	Model          string `json:"model"`
}

type HookMatcher

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

type HookResponse

type HookResponse struct {
	Decision HookDecision
	Message  string
}

func NewAllowResponse

func NewAllowResponse() *HookResponse

func NewBlockResponse

func NewBlockResponse(message string) *HookResponse

func NewErrorResponse

func NewErrorResponse(message string) *HookResponse

func (*HookResponse) ExitCode

func (r *HookResponse) ExitCode() int

func (*HookResponse) JSON

func (r *HookResponse) JSON() []byte

type HooksConfig

type HooksConfig struct {
	Hooks map[string][]HookMatcher `json:"hooks"`
}

func GenerateHooksConfig

func GenerateHooksConfig() *HooksConfig

type PostToolUseInput

type PostToolUseInput struct {
	HookInput
	TurnID       string                 `json:"turn_id"`
	ToolName     string                 `json:"tool_name"`
	ToolUseID    string                 `json:"tool_use_id"`
	ToolInput    map[string]interface{} `json:"tool_input"`
	ToolResponse json.RawMessage        `json:"tool_response"`
}

type PreToolUseInput

type PreToolUseInput struct {
	HookInput
	TurnID    string                 `json:"turn_id"`
	ToolName  string                 `json:"tool_name"`
	ToolUseID string                 `json:"tool_use_id"`
	ToolInput map[string]interface{} `json:"tool_input"`
}

type SessionStartInput

type SessionStartInput struct {
	HookInput
	Source string `json:"source"`
}

type StopInput

type StopInput struct {
	HookInput
	TurnID               string `json:"turn_id"`
	StopHookActive       bool   `json:"stop_hook_active"`
	LastAssistantMessage string `json:"last_assistant_message"`
}

type UserPromptSubmitInput

type UserPromptSubmitInput struct {
	HookInput
	TurnID string `json:"turn_id"`
	Prompt string `json:"prompt"`
}

Jump to

Keyboard shortcuts

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