Versions in this module Expand all Collapse all v2 v2.0.0 Oct 9, 2026 Changes in this version + const DefaultHookBudget + const DefaultMaxRuleInterrupts + const DefaultMaxTurns + const DefaultToolTimeout + const MetaReminder + const ToolDiscoveryThreshold + var ErrRuleInterrupt = llm.ErrRuleInterrupt + var ErrTurnTimeout = errors.New("loop: request exceeded its per-turn timeout") + func ConfigStamp(ws string) string + func HookContextBlock(context string) string + func UserPromptSubmit(ctx context.Context, h *hooks.Runner, msg Message) (Message, PromptVerdict, error) + type Boundary int + const BoundaryRetry + const BoundaryRun + const BoundaryTools + type Compactor interface + Compact func(ctx context.Context, history []Message, lastUsage *llm.TokenUsage, force bool) (out []Message, notes []string, changed bool) + type Env struct + Checker *permissions.Checker + CodeGraphSummary string + Files *checkpoints.FileTracker + GitSnapshot string + GrimoireContext string + Hooks *hooks.Runner + Indexer *codegraph.Indexer + MCP *mcp.Manager + Memories string + Mode Mode + ProjectContext string + Registry *tools.Registry + Rules *rules.Set + SandboxPolicy sandbox.Policy + Snapshots *checkpoints.SnapshotManager + ToolMode tools.RuntimeMode + Workspace string + func Setup(mode Mode, cfg *config.Config, workspace string, opts SetupOptions) (*Env, error) + func (e *Env) Close() + func (e *Env) Nested(opts NestedOptions) (*Env, error) + func (e *Env) PersistRules() + func (e *Env) RefreshDiscovery() + func (e *Env) RenderState() string + func (e *Env) SessionStartContext(ctx context.Context, source string) string + func (e *Env) StartSession(ctx context.Context, source string) + func (e *Env) SystemPrompt(o PromptOptions) prompts.Prompt + func (e *Env) Trust() + type Event struct + At time.Time + Call ToolCall + Elapsed time.Duration + Err error + History []Message + IsError bool + Kind EventKind + Metadata map[string]any + Msg Message + Result Result + Text string + ToolNames []string + Turn int + Usage *llm.TokenUsage + type EventKind int + const EventAssistant + const EventCallsRecorded + const EventCompacted + const EventDone + const EventNotice + const EventPromptBlocked + const EventPromptsChecked + const EventRule + const EventRuleInterrupt + const EventSteerBlocked + const EventSteered + const EventTextDelta + const EventThinking + const EventToolResult + const EventToolStart + const EventTurnEnd + const EventTurnStart + type Gate interface + Ask func(ctx context.Context, req tools.PermissionRequest) tools.PermissionResponse + func PromptGate(fn tools.PromptFunc) Gate + type GateFunc func(ctx context.Context, req tools.PermissionRequest) tools.PermissionResponse + func (f GateFunc) Ask(ctx context.Context, req tools.PermissionRequest) tools.PermissionResponse + type LLM interface + GetSkills func() []tui.SkillDefinition + SendMessageStreamEvents func(ctx context.Context, messages []tui.ChatMessage, tools []tui.SkillDefinition, ...) error + type Limits struct + HookBudget time.Duration + IdenticalCalls int + KeepToolMetadata bool + MaxCallsPerTurn int + MaxInvalidArgTurns int + MaxRuleInterrupts int + MaxTurns int + NoProgressTurns int + RequestTimeout time.Duration + SpillBytes int + TextToolCalls bool + ToolTimeout time.Duration + func DefaultLimits() Limits + type Loop struct + Advisor tools.AskAdvisor + CheckPrompt PromptCheck + Client LLM + Compact Compactor + Gate Gate + Limits Limits + Refuse func(name string) string + SessionID string + SpillCounter *atomic.Int64 + SpillDir string + Steering Steering + Tools *tools.Registry + func (l *Loop) Events() <-chan Event + func (l *Loop) Run(ctx context.Context, history []Message) (msgs []Message, res Result, err error) + func (l *Loop) Steer(msg string) + func (l *Loop) TakeSteers() []string + type Message = tui.ChatMessage + func ReminderMessage(r Reminder) Message + type Mode int + const ModeAgent + const ModeChat + const ModeMCPChat + func (m Mode) String() string + type NestedOptions struct + Notice func(string) + Warn func(string) + Workspace string + type Nester interface + Nested func(NestedOptions) (*Env, error) + type Parent struct + func NewParent(cfg *config.Config, workspace string, opts SetupOptions) *Parent + func (p *Parent) Close() + func (p *Parent) Nested(opts NestedOptions) (*Env, error) + type PromptCheck func(ctx context.Context, msg Message) (Message, PromptVerdict, error) + func HookPromptCheck(h *hooks.Runner) PromptCheck + type PromptOptions struct + Contract string + Level prompts.PersonaLevel + Session string + Sliders *config.SliderConfig + Window int + type PromptVerdict struct + Blocked bool + Reason string + type Reminder struct + Source string + Text string + type Result struct + FinalText string + HistoryEdited bool + NoToolTurns int + StopReason StopReason + ToolCalls int + ToolCallsLastTurn int + Turns int + type SetupOptions struct + Approve hooks.ApproveFunc + GlobalMCPOnly bool + Notice func(string) + SessionID string + Warn func(string) + type Steering interface + Calls func(turn int, calls []ToolCall) bool + Observe func(ev Event) bool + Reminders func(b Boundary) []Reminder + Request func(turn int, interrupt func()) + type StopReason string + const StopBlocked + const StopCap + const StopDone + const StopError + const StopIdentical + const StopInterrupted + const StopInvalidArgs + const StopProgress + type StreamEnder interface + EndStream func() bool + type ToolCall struct + ID string + Input map[string]any + Key string + Name string + type TurnTimeoutError struct + Err error + Timeout time.Duration + func (e *TurnTimeoutError) Error() string + func (e *TurnTimeoutError) Is(target error) bool + func (e *TurnTimeoutError) Unwrap() error