engine

package
v0.0.0-...-331a2dd Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvalCondition

func EvalCondition(cond dsl.Condition, ctx *EvalContext) bool

EvalCondition evaluates a condition against the given context. Returns true if the condition is met (actions should fire).

func GetDenyList

func GetDenyList(name string) []string

GetDenyList returns the patterns for a named deny list.

func ListDenyLists

func ListDenyLists() []string

ListDenyLists returns the names of all available deny lists.

func LoadDenyLists

func LoadDenyLists() map[string][]string

LoadDenyLists loads all deny lists: built-in embedded + custom from disk.

func MatchesDenyList

func MatchesDenyList(command string, lists map[string][]string, listName string) bool

MatchesDenyList checks if the command matches any pattern in the named deny list.

Types

type ActionContext

type ActionContext struct {
	DB         *state.DB
	GetAdapter func(name string) (adapters.Adapter, error)
	SessionID  string
	HookEvent  string
	RuleID     string
	Input      *hookio.HookInput
	PrunerFunc func(tier string) error
}

ActionContext provides dependencies for action execution.

type ActionResult

type ActionResult struct {
	Output      *hookio.HookOutput
	ActionTaken string
	ShouldBlock bool
	Error       error
}

ActionResult is the outcome of executing an action.

func ExecuteAction

func ExecuteAction(ctx context.Context, action dsl.Action, actx *ActionContext) *ActionResult

ExecuteAction runs a single action and returns the result.

type EvalContext

type EvalContext struct {
	Input        *hookio.HookInput
	SessionStart time.Time // when the session started
	LastPrompt   time.Time // last user interaction time
	Now          time.Time
	DenyLists    map[string][]string // deny list name → patterns
	BurnRate     float64             // current token burn rate (tokens/min)
	Model        string              // model identifier for the current session
	ContextSize  int                 // current context token count
	ContextUsage float64             // percentage of context window filled (0–100)
	ErrorType    string              // error_type from StopFailure events
	TaskStatus   string              // task_status from TaskCompleted events
}

EvalContext provides the data needed to evaluate conditions.

type ExecResult

type ExecResult struct {
	Output       *hookio.HookOutput
	ActionsTaken []string
	Blocked      bool
	Error        error
	DurationMs   int
}

ExecResult is the outcome of executing a rule.

type Executor

type Executor struct {
	DB         *state.DB
	GetAdapter func(name string) (adapters.Adapter, error)
	DenyLists  map[string][]string
}

Executor orchestrates the full hook execution pipeline.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, rule *state.Rule, input *hookio.HookInput) *ExecResult

Execute runs a rule against hook input.

func (*Executor) ExecuteSystemHook

func (e *Executor) ExecuteSystemHook(name string, input *hookio.HookInput) *ExecResult

ExecuteSystemHook handles system hooks (session tracking, prompt tracking).

Jump to

Keyboard shortcuts

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