Documentation
ΒΆ
Index ΒΆ
- type Engine
- func (r *Engine) CheckDanger(prompt string) (blocked bool, operation, reason string)
- func (r *Engine) CleanupSessionFiles(sessionID string) error
- func (r *Engine) Close() error
- func (r *Engine) Execute(ctx context.Context, cfg *types.Config, prompt string, callback event.Callback) error
- func (r *Engine) GetAllowedTools() []string
- func (r *Engine) GetCLIVersion() (string, error)
- func (r *Engine) GetDisallowedTools() []string
- func (r *Engine) GetSession(sessionID string) (*intengine.Session, bool)
- func (r *Engine) GetSessionStats(sessionID string) *SessionStats
- func (r *Engine) ResetSessionProvider(sessionID string)
- func (r *Engine) SetAllowedTools(tools []string)
- func (r *Engine) SetDangerAllowPaths(paths []string)
- func (r *Engine) SetDangerBypassEnabled(token string, enabled bool) error
- func (r *Engine) SetDisallowedTools(tools []string)
- func (r *Engine) StopSession(sessionID string, reason string) error
- func (r *Engine) ValidateConfig(cfg *types.Config) error
- type EngineOptions
- type SessionStats
- func (s *SessionStats) EndGeneration()
- func (s *SessionStats) EndThinking()
- func (s *SessionStats) FinalizeDuration() *SessionStats
- func (s *SessionStats) GetCurrentToolID() string
- func (s *SessionStats) GetCurrentToolName() string
- func (s *SessionStats) GetToolNameByToolID(toolID string) string
- func (s *SessionStats) RecordFileModification(filePath string)
- func (s *SessionStats) RecordTokens(input, output, cacheWrite, cacheRead int32)
- func (s *SessionStats) RecordToolResult(toolID string) (durationMs int64, toolName string)
- func (s *SessionStats) RecordToolUse(toolName, toolID string)
- func (s *SessionStats) StartGeneration()
- func (s *SessionStats) StartThinking()
- func (s *SessionStats) ToSummary() map[string]interface{}
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type Engine ΒΆ
type Engine struct {
// contains filtered or unexported fields
}
Engine is the core Control Plane for AI CLI agent integration. Configured as a long-lived Singleton, it transforms local CLI tools into production-ready services by managing a hot-multiplexed process pool, enforcing security WAF rules, and providing a unified event-driven SDK for application integration.
func NewEngine ΒΆ
func NewEngine(options EngineOptions) (*Engine, error)
NewEngine creates a new HotPlex Engine instance.
func (*Engine) CheckDanger ΒΆ added in v0.18.0
CheckDanger exposes the WAF danger detector to the chatapps layer. Returns blocked=true if the prompt matches dangerous patterns. chatapps uses this for pre-flight WAF checks before calling Execute.
func (*Engine) CleanupSessionFiles ΒΆ added in v0.17.0
CleanupSessionFiles deletes all session files associated with the provider session. This handles the complete removal of context on disk for commands like /reset.
func (*Engine) Close ΒΆ
Close terminates all active sessions managed by this runner and cleans up resources. It triggers Graceful Shutdown by cascading termination signals down to the SessionManager, which drops the entire process group (PGID) to prevent zombie processes.
func (*Engine) Execute ΒΆ
func (r *Engine) Execute(ctx context.Context, cfg *types.Config, prompt string, callback event.Callback) error
Execute runs Claude Code CLI with the given configuration and streams
func (*Engine) GetAllowedTools ΒΆ added in v0.11.0
GetAllowedTools returns the current allowed tools list. Thread-safe: uses internal mutex.
func (*Engine) GetCLIVersion ΒΆ
GetCLIVersion returns the Claude Code CLI version.
func (*Engine) GetDisallowedTools ΒΆ added in v0.11.0
GetDisallowedTools returns the current disallowed tools list. Thread-safe: uses internal mutex.
func (*Engine) GetSession ΒΆ added in v0.12.0
GetSession retrieves an active session by sessionID. Returns the session and true if found, or nil and false if not found.
func (*Engine) GetSessionStats ΒΆ
func (r *Engine) GetSessionStats(sessionID string) *SessionStats
GetSessionStats returns a copy of the accumulated session stats.
func (*Engine) ResetSessionProvider ΒΆ added in v0.13.0
ResetSessionProvider marks a session to get a new ProviderSessionID on restart. This is used for /clear command to force a fresh session with new context.
func (*Engine) SetAllowedTools ΒΆ added in v0.11.0
SetAllowedTools sets the allowed tools for the engine. This affects new sessions created after the call. Thread-safe: uses internal mutex.
func (*Engine) SetDangerAllowPaths ΒΆ
SetDangerAllowPaths sets the allowed safe paths for the danger detector.
func (*Engine) SetDangerBypassEnabled ΒΆ
SetDangerBypassEnabled enables or disables danger detection bypass. WARNING: Only use for Evolution mode (admin only).
func (*Engine) SetDisallowedTools ΒΆ added in v0.11.0
SetDisallowedTools sets the disallowed tools for the engine. This affects new sessions created after the call. Thread-safe: uses internal mutex.
func (*Engine) StopSession ΒΆ
StopSession terminates a running session by session ID. This is the implementation for session.stop from the spec.
type EngineOptions ΒΆ
type EngineOptions = intengine.EngineOptions
EngineOptions defines the configuration parameters for initializing a new HotPlex Engine. It allows customization of timeouts, logging, and foundational security boundaries that apply to all sessions managed by this engine instance.
type SessionStats ΒΆ
type SessionStats struct {
SessionID string `json:"session_id"`
StartTime time.Time `json:"-"` // Internal use only, use ToSummary() for JSON
TotalDurationMs int64 `json:"total_duration_ms"`
ThinkingDurationMs int64 `json:"thinking_duration_ms"`
ToolDurationMs int64 `json:"tool_duration_ms"`
GenerationDurationMs int64 `json:"generation_duration_ms"`
InputTokens int32 `json:"input_tokens"`
OutputTokens int32 `json:"output_tokens"`
CacheWriteTokens int32 `json:"cache_write_tokens"`
CacheReadTokens int32 `json:"cache_read_tokens"`
ToolCallCount int32 `json:"tool_call_count"`
ToolsUsed map[string]bool `json:"-"` // Internal set, use ToSummary() for array
FilesModified int32 `json:"files_modified"`
FilePaths []string `json:"file_paths"`
// contains filtered or unexported fields
}
SessionStats collects session-level statistics for Geek/Evolution modes.
func (*SessionStats) EndGeneration ΒΆ
func (s *SessionStats) EndGeneration()
EndGeneration marks the end of the generation phase and records its duration.
func (*SessionStats) EndThinking ΒΆ
func (s *SessionStats) EndThinking()
EndThinking marks the end of the thinking phase and records its duration.
func (*SessionStats) FinalizeDuration ΒΆ
func (s *SessionStats) FinalizeDuration() *SessionStats
FinalizeDuration finalizes any ongoing phase tracking and returns the final stats.
func (*SessionStats) GetCurrentToolID ΒΆ added in v0.13.0
func (s *SessionStats) GetCurrentToolID() string
GetCurrentToolID returns the current tool ID being tracked. Returns empty string if no tool is currently being tracked.
func (*SessionStats) GetCurrentToolName ΒΆ added in v0.13.0
func (s *SessionStats) GetCurrentToolName() string
GetCurrentToolName returns the current tool name being tracked. Returns empty string if no tool is currently being tracked.
func (*SessionStats) GetToolNameByToolID ΒΆ added in v0.15.0
func (s *SessionStats) GetToolNameByToolID(toolID string) string
GetToolNameByToolID returns the tool name for a given tool ID. This is useful when tool_result events don't include tool_name. Returns empty string if tool ID is not found.
func (*SessionStats) RecordFileModification ΒΆ
func (s *SessionStats) RecordFileModification(filePath string)
RecordFileModification records that a file was modified. Uses O(1) map lookup for deduplication instead of O(n) linear scan.
func (*SessionStats) RecordTokens ΒΆ
func (s *SessionStats) RecordTokens(input, output, cacheWrite, cacheRead int32)
RecordTokens records token usage.
func (*SessionStats) RecordToolResult ΒΆ
func (s *SessionStats) RecordToolResult(toolID string) (durationMs int64, toolName string)
RecordToolResult records the end of a tool call. If RecordToolUse was not called (e.g., Claude Code didn't send tool_use event), this will record a minimal duration (1ms) to indicate the tool completed.
func (*SessionStats) RecordToolUse ΒΆ
func (s *SessionStats) RecordToolUse(toolName, toolID string)
RecordToolUse records the start of a tool call.
func (*SessionStats) StartGeneration ΒΆ
func (s *SessionStats) StartGeneration()
StartGeneration marks the start of the generation phase.
func (*SessionStats) StartThinking ΒΆ
func (s *SessionStats) StartThinking()
StartThinking marks the start of the thinking phase.
func (*SessionStats) ToSummary ΒΆ
func (s *SessionStats) ToSummary() map[string]interface{}
ToSummary converts stats to a summary map for JSON serialization.