Versions in this module Expand all Collapse all v1 v1.5.0 Oct 12, 2026 Changes in this version + var GetCurrentTime = func() time.Time + func DetectTurnStage(messages []types.Message, turnID types.TurnID) prompt.ExecutionStage + type CompactionSnapshot struct + BoundaryVersion int + FirstPreservedMessageID types.MessageID + LastPreservedMessageID types.MessageID + PostCompactionTokenCount int + PreCompactionTokenCount int + PreservedTailHash string + type Config struct + AppendSystemPrompt string + AutoCompact bool + BrowserManager browsercore.Manager + BudgetContinuationLimit int + CompactSummaryModel types.ModelIdentifier + ContinuationNudgeLimit int + DisableStreaming bool + EnableMemory bool + EnableMonitoring bool + MCPServers []mcp.ServerConfig + ManagedInstructions string + MaxConsecutiveDenials int + MaxIterations int + MaxTokens int + MaxTurns int + Model types.ModelIdentifier + PermissionMode types.PermissionMode + PromptStage prompt.ExecutionStage + PromptStageOverrides map[prompt.ExecutionStage]string + PromptToolHints map[string]string + StopHooks []StopHook + SystemPromptTemplate string + TitleModel types.ModelIdentifier + TrustProjectInstructions func(path string, content []byte) bool + TurnTokenBudget int + WorkingDirectory string + func DefaultConfig() *Config + type ContinueTransition struct + Reason string + RecoveryType RecoveryType + func (c ContinueTransition) IsContinue() bool + func (c ContinueTransition) IsTerminal() bool + type Engine struct + func NewEngine(apiClient *providers.Client, orchestrator *execution.Orchestrator, ...) *Engine + func NewEngineWithRegistry(ctx context.Context, apiClient *providers.Client, toolRegistry *tool.Registry, ...) (*Engine, error) + func (e *Engine) AutoModeAvailable() bool + func (e *Engine) Fork(systemPrompt, modelStr string) *Engine + func (e *Engine) GetMonitoring() *monitoring.System + func (e *Engine) HookExecutor() *hooks.Executor + func (e *Engine) HookRegistry() *hooks.Registry + func (e *Engine) NewSession(ctx context.Context) (*Session, error) + func (e *Engine) NewSessionFromState(ctx context.Context, sessionID types.SessionID, ...) (*Session, error) + func (e *Engine) OpenSession(ctx context.Context, sessionID types.SessionID) (*Session, error) + func (e *Engine) SetAPIClient(apiClient *providers.Client) + func (e *Engine) SetOnSessionTitled(fn func(types.SessionID, string)) + func (e *Engine) SetPromptFn(fn types.PromptFn) + func (e *Engine) SetTitleAPIClient(apiClient *providers.Client) + func (e *Engine) SetTitleGenerator(generator TitleGenerator) + type Loop struct + func NewLoop(apiClient *providers.Client, orchestrator *execution.Orchestrator, ...) *Loop + func (l *Loop) Run(ctx context.Context, req RunRequest) RunResult + type LoopConfig struct + AutoCompact bool + BudgetCompletionThreshold float64 + BudgetContinuationLimit int + BudgetDiminishingThreshold int + ContinuationNudgeLimit int + EnableStreaming bool + MaxIterations int + MaxOutputTokensRecoveryLimit int + MaxRecoveryAttempts int + MaxTurns int + RecoveryBackoffMaxDelay int + RecoveryBackoffMultiplier int + StopHookContinueOnError bool + StopHookMode string + StopHookTimeout int + StopHooks []StopHook + TurnTokenBudget int + func DefaultLoopConfig() *LoopConfig + type MutableState struct + AutoCompactFailureCount int + BudgetContinuationCount int + CompactPostTokens int + CompactPreTokens int + Compacted bool + ContinuationNudgeCount int + CurrentStage prompt.ExecutionStage + DiscoveredDeferred []string + HasAttemptedReactiveCompact bool + Iterations int + LastBudgetCheckTokens int + LastBudgetDelta int + MaxOutputTokensOverride int + MaxOutputTokensRecoveryCount int + Messages []types.Message + PermissionContext *types.PermissionContext + PermissionMode types.PermissionMode + PreviousResponseID string + PreviousResponseMessageCount int + RecoveryContext *RecoveryContext + StopHookActive *bool + StopReason string + ToolResults []tool.CallResult + ToolUses []types.ToolUseContent + TotalTurnTokens int + Transition Transition + TurnCount int + Usage *types.TokenUsage + func NewMutableState(initialMessages []types.Message) *MutableState + func (s *MutableState) Clone() *MutableState + type PromptRefresh struct + SystemPrompt string + SystemPromptBlocks []types.SystemPromptBlock + type RecoveryContext struct + CompactionSnapshot *CompactionSnapshot + LastRecoveryType RecoveryType + LastStopReason string + LastTransitionReason string + TurnProgress *TurnProgress + type RecoveryType string + const RecoveryTypeAPIRetry + const RecoveryTypeContinuationNudge + const RecoveryTypeMaxOutputTokens + const RecoveryTypeNone + const RecoveryTypePromptTooLong + const RecoveryTypeStopHook + const RecoveryTypeTokenBudget + type RunRequest struct + AutoCompactFailureCount int + AutoDetectStage bool + DenialTracking *types.DenialTrackingState + EventQueue *execution.EventQueue + MaxTokens int + Messages []types.Message + Model types.ModelIdentifier + OutputSchema *schema.StructuredOutputInfo + PermissionCheck types.CanUseToolFn + PermissionContext *types.PermissionContext + PermissionMode types.PermissionMode + ProgressCallback func(types.ToolProgress) + ProviderTools []types.APIToolDefinition + RefreshSystemPrompt func(ctx context.Context, tools map[string]tool.Tool, pendingDeferred []string, ...) (PromptRefresh, error) + ResponseChunkCallback func(types.APIResponseChunk) + SessionID types.SessionID + SystemPrompt string + SystemPromptBlocks []types.SystemPromptBlock + ToolRegistry *tool.Registry + Tools map[string]tool.Tool + Toolsets []tool.Toolset + TurnID types.TurnID + TurnTokenBudget int + WorkingDirectory string + type RunResult struct + AutoCompactFailureCount int + CompactPostTokens int + CompactPreTokens int + Compacted bool + DiscoveredDeferred []string + Error error + Iterations int + Messages []types.Message + PermissionContext *types.PermissionContext + RecoveryContext *RecoveryContext + StopReason string + ToolResults []tool.CallResult + ToolUses []types.ToolUseContent + Usage *types.TokenUsage + type Runner struct + func NewRunner(apiClient *providers.Client, orchestrator *execution.Orchestrator, ...) *Runner + func (r *Runner) Run(ctx context.Context, req RunnerRequest) (RunnerResult, error) + type RunnerConfig struct + AutoCompact bool + MaxIterations int + MaxTurns int + func DefaultRunnerConfig() *RunnerConfig + type RunnerRequest struct + DenialTracking *types.DenialTrackingState + MaxTokens int + Messages []types.Message + Model types.ModelIdentifier + PermissionCheck types.CanUseToolFn + PermissionMode types.PermissionMode + ProgressCallback func(types.ToolProgress) + PromptVariables map[string]string + SessionID types.SessionID + SystemPrompt string + Tools map[string]tool.Tool + TurnID types.TurnID + type RunnerResult struct + CompactPostTokens int + CompactPreTokens int + Compacted bool + Iterations int + Messages []types.Message + StopReason string + ToolResults []tool.CallResult + ToolUses []types.ToolUseContent + Usage *types.TokenUsage + type Session struct + func (s *Session) ClearPlanMode() + func (s *Session) Close() error + func (s *Session) ForcePlanMode() + func (s *Session) GetEventQueue() *execution.EventQueue + func (s *Session) GetExecutionMode() string + func (s *Session) GetMessages() []types.Message + func (s *Session) GetMetadata() *types.SessionMetadata + func (s *Session) GetPermissionContext() *types.PermissionContext + func (s *Session) GetPermissionMode() types.PermissionMode + func (s *Session) GetRuntimeEventQueue() *execution.RuntimeEventQueue + func (s *Session) GetSessionID() types.SessionID + func (s *Session) GetToolNames() []string + func (s *Session) GetTotalTokens() int + func (s *Session) GetTurnNumber() int + func (s *Session) Interrupt() error + func (s *Session) RegisterTool(t tool.Tool) error + func (s *Session) RegisterTools(tools []tool.Tool) error + func (s *Session) SetAppendSystemPrompt(text string) + func (s *Session) SetPermissionMode(mode types.PermissionMode) + func (s *Session) SetProgressCallback(fn func(types.ToolProgress)) + func (s *Session) SetResponseChunkCallback(fn func(types.APIResponseChunk)) + func (s *Session) SetRuntimeEventCallback(fn func(types.RuntimeEvent)) + func (s *Session) SetSystemPromptTemplate(text string) + func (s *Session) SetWorkingDirectory(path string) + func (s *Session) SubmitMessage(ctx context.Context, content string) (*SessionResponse, error) + func (s *Session) SubmitMessageWithContent(ctx context.Context, text string, images []types.ImageContent) (*SessionResponse, error) + func (s *Session) UnregisterTool(name string) error + type SessionResponse struct + CompactPostTokens int + CompactPreTokens int + Compacted bool + Messages []types.Message + StopReason string + ToolResults []tool.CallResult + ToolUses []types.ToolUseContent + TotalTokens int + TurnNumber int + Usage *types.TokenUsage + func (r *SessionResponse) GetLastAssistantMessage() (types.Message, bool) + func (r *SessionResponse) GetLastToolResults() []tool.CallResult + func (r *SessionResponse) IsComplete() bool + type SessionState struct + AutoCompactFailureCount int + CanonicalTranscript int + CompactionCount int + DenialTracking *types.DenialTrackingState + DiscoveredDeferred []string + LastCompaction *types.CompactionMetadata + Messages []types.Message + Metadata *types.SessionMetadata + PermissionContext *types.PermissionContext + SessionID types.SessionID + Tools map[string]tool.Tool + TotalTokens int + TurnID types.TurnID + TurnNumber int + func NewSessionState(sessionID types.SessionID, turnID types.TurnID, messages []types.Message, ...) *SessionState + func (s *SessionState) AdvanceTurn(usage *types.TokenUsage, updatedMessages []types.Message) + func (s *SessionState) CloneMessages() []types.Message + func (s *SessionState) CurrentExecutionMode() string + func (s *SessionState) CurrentPermissionMode() types.PermissionMode + func (s *SessionState) DenialTrackingState() *types.DenialTrackingState + func (s *SessionState) EffectiveToolSurface(reg *tool.Registry) map[string]tool.Tool + func (s *SessionState) GetLastRecoveryContext() *RecoveryContext + func (s *SessionState) MarkClosed() + func (s *SessionState) MarkInterrupted() + func (s *SessionState) MetadataSnapshot() *types.SessionMetadata + func (s *SessionState) PendingDeferredToolNames(reg *tool.Registry) []string + func (s *SessionState) PermissionContextSnapshot() *types.PermissionContext + func (s *SessionState) RegisterDiscoveredDeferredTools(names []string) + func (s *SessionState) ReplaceMessages(messages []types.Message) + func (s *SessionState) SetPermissionContext(permissionContext *types.PermissionContext) + func (s *SessionState) StoreRecoveryContext(ctx *RecoveryContext) + func (s *SessionState) ToolSurface() map[string]tool.Tool + type SessionStore interface + SaveSessionState func(sessionID types.SessionID, metadata *types.SessionMetadata, ...) error + type StopHook interface + Execute func(ctx context.Context, input StopHookInput) (StopHookResult, error) + Name func() string + Priority func() int + type StopHookConfig struct + ContinueOnError bool + Mode string + Timeout int + type StopHookInput struct + Compacted bool + Iterations int + Messages []types.Message + Model types.ModelIdentifier + RecoveryContext *RecoveryContext + SessionID types.SessionID + StopReason string + ToolUses []types.ToolUseContent + TotalTurnTokens int + TurnID types.TurnID + Usage *types.TokenUsage + type StopHookResult struct + Continue bool + Error error + Messages []types.Message + type TerminalTransition struct + Reason string + StopReason string + func (t TerminalTransition) IsContinue() bool + func (t TerminalTransition) IsTerminal() bool + type TitleGenerator interface + GenerateTitle func(ctx context.Context, firstUserMsg string) (string, error) + type Transition interface + IsContinue func() bool + IsTerminal func() bool + func Continue(reason string) Transition + func ContinueWithRecovery(reason string, recoveryType RecoveryType) Transition + func Terminate(reason string, stopReason string) Transition + type TurnProgress struct + IterationsCompleted int + LastAssistantMessageID types.MessageID + PendingToolResults []tool.CallResult + PendingToolUses []types.ToolUseContent + TotalTokensUsed int