hotplex

package module
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 5 Imported by: 0

README

HotPlex

HotPlex

AI Agent Control Plane — Turn AI CLIs into Production-Ready Services

Release Go Reference Go Report License Stars

Quick StartFeaturesDocsSlack Guide简体中文


⚡ Quick Start

Prerequisites

Install & Run

# 1. One-click install
curl -sL https://raw.githubusercontent.com/hrygo/hotplex/main/install.sh | bash

# 2. Start your first session
hotplexd --config chatapps/configs

💎 Visual Showcase

HotPlex Features


🎯 Our Focus: AI Agent "Control Plane"

Existing AI agents are powerful but often lack the runtime stability required by production services. HotPlex fills this gap by providing:

  1. Process Life-support: Turns ephemeral CLI turns into persistent, stateful sessions.
  2. Safety Interception: A programmable regex-based firewall for shell instruction.
  3. High-Efficiency Multiplexing: Scale to hundreds of concurrent AI sessions through optimal process reuse.

💡 Standard Use Cases

Scenario How HotPlex Helps
AI Coding Assistant Embed AI directly into your VS Code / IDE terminal with persistent turn history.
Autopilot Ops Feed system logs to HotPlex and let it execute remediation scripts with manual approval.
Multi-Agent Bus Centralize multiple AI CLI tools behind a single unified WebSocket/SSE gateway.
Enterprise ChatOps Connect local AI agents to Slack/Feishu with enterprise-grade stability.

🚀 Features

Feature Description
Session Pooling Long-lived CLI processes with instant reconnection
Full-Duplex Streaming Sub-second token delivery via Go channels
Regex WAF Block destructive commands (rm -rf /, mkfs, etc.)
PGID Isolation Clean process termination, no zombie processes
ChatApps Slack (Block Kit, Streaming, Assistant Status), Telegram, Feishu, DingTalk
Go SDK Embed directly in your Go application with zero overhead
WebSocket Gateway Language-agnostic access via hotplexd daemon
OpenTelemetry Built-in metrics and tracing support

🏛 Architecture & Security

HotPlex employs a defense-in-depth security model alongside a high-concurrency session topology.

HotPlex Security Architecture

HotPlex Topology

Layer Implementation Protection
Tool Governance AllowedTools config Restrict agent capabilities
Danger WAF Regex interception Block rm -rf /, mkfs, dd
Process Isolation PGID-based termination No orphaned processes
Filesystem Jail WorkDir lockdown Confined to project root
Container Sandbox Docker (BaaC) OS-level isolation & limits

🛠 Usage Examples

Go SDK

import "github.com/hrygo/hotplex"

engine, _ := hotplex.NewEngine(hotplex.EngineOptions{
    Timeout: 5 * time.Minute,
})

engine.Execute(ctx, cfg, "Refactor this function", func(event Event) {
    fmt.Println(event.Content)
})

ChatApps (Slack)

# chatapps/configs/slack.yaml
platform: slack
mode: socket
bot_user_id: ${HOTPLEX_SLACK_BOT_USER_ID}
system_prompt: |
  You are a helpful coding assistant.
export HOTPLEX_SLACK_BOT_USER_ID=B12345
export HOTPLEX_SLACK_BOT_TOKEN=xoxb-...
export HOTPLEX_SLACK_APP_TOKEN=xapp-...
hotplexd --config chatapps/configs

📚 Documentation

Resource Description
Architecture Deep Dive System design, security protocols, session management
SDK Developer Guide Complete Go SDK reference
ChatApps Manual Multi-platform integration (Slack, DingTalk, Feishu)
Docker Multi-Bot Run multiple bots with one command

🤝 Community & Contributing

  • Bugs/Features: Please use GitHub Issues.
  • Discussions: Ask questions or share ideas in GitHub Discussions.
  • Contributing: We welcome contributions! Please ensure CI passes (make lint, make test). See CONTRIBUTING.md for guidelines.

📄 License

Released under the MIT License.


HotPlex Mascot
Built for the AI Engineering community.

Documentation

Overview

Package hotplex provides a production-ready execution environment for AI CLI agents.

Index

Constants

View Source
const (
	Version      = "0.18.1"
	VersionMajor = 0
	VersionMinor = 18
	VersionPatch = 1
)
View Source
const (
	ProviderTypeClaudeCode = provider.ProviderTypeClaudeCode
	ProviderTypeOpenCode   = provider.ProviderTypeOpenCode
)

Provider constants

Variables

View Source
var (
	// ErrDangerBlocked is returned when a dangerous operation is blocked by the WAF.
	ErrDangerBlocked = types.ErrDangerBlocked
	// ErrInvalidConfig is returned when the configuration is invalid.
	ErrInvalidConfig = types.ErrInvalidConfig
	// ErrSessionNotFound is returned when the requested session does not exist.
	ErrSessionNotFound = types.ErrSessionNotFound
	// ErrSessionDead is returned when the session is no longer alive.
	ErrSessionDead = types.ErrSessionDead
	// ErrTimeout is returned when an operation times out.
	ErrTimeout = types.ErrTimeout
	// ErrInputTooLarge is returned when input exceeds maximum size.
	ErrInputTooLarge = types.ErrInputTooLarge
	// ErrProcessStart is returned when the CLI process fails to start.
	ErrProcessStart = types.ErrProcessStart
	// ErrPipeClosed is returned when the pipe is closed.
	ErrPipeClosed = types.ErrPipeClosed
)
View Source
var (
	// NewEngine creates a new HotPlex Engine instance.
	NewEngine = engine.NewEngine
	// WrapSafe wraps a callback to make it safe for concurrent use.
	WrapSafe = event.WrapSafe
	// NewEventWithMeta creates a new EventWithMeta.
	NewEventWithMeta = event.NewEventWithMeta
	// TruncateString truncates a string to the given length.
	TruncateString = types.TruncateString
	// SummarizeInput creates a summary of input data.
	SummarizeInput = types.SummarizeInput
	// NewClaudeCodeProvider creates a new Claude Code provider instance.
	NewClaudeCodeProvider = provider.NewClaudeCodeProvider
	// NewOpenCodeProvider creates a new OpenCode provider instance.
	NewOpenCodeProvider = provider.NewOpenCodeProvider
)

Functions

This section is empty.

Types

type AssistantMessage

type AssistantMessage = types.AssistantMessage

AssistantMessage represents a message from the assistant.

type Callback

type Callback = event.Callback

Callback is the function signature for event streaming.

type ClaudeCodeProvider added in v0.7.0

type ClaudeCodeProvider = provider.ClaudeCodeProvider

ClaudeCodeProvider implements the Provider interface for Claude Code CLI.

type Config

type Config = types.Config

Config represents the configuration for a single HotPlex execution session.

type ContentBlock

type ContentBlock = types.ContentBlock

ContentBlock represents a content block in a message.

type Engine

type Engine = engine.Engine

Engine is the core Control Plane for AI CLI agent integration.

type EngineOptions

type EngineOptions = engine.EngineOptions

EngineOptions defines the configuration parameters for initializing a new HotPlex Engine.

type EventMeta

type EventMeta = event.EventMeta

EventMeta contains metadata for stream events.

type EventWithMeta

type EventWithMeta = event.EventWithMeta

EventWithMeta wraps event data with metadata.

type Executor added in v0.7.0

type Executor interface {
	// Execute runs a command or prompt and streams normalized events.
	Execute(ctx context.Context, cfg *types.Config, prompt string, callback event.Callback) error

	// ValidateConfig checks if the session configuration is secure and valid.
	ValidateConfig(cfg *types.Config) error
}

Executor handles the core execution logic and configuration validation.

type HotPlexClient

type HotPlexClient interface {
	Executor
	SessionController
	SafetyManager

	// Close gracefully terminates all managed sessions and releases resources.
	Close() error
}

HotPlexClient defines the comprehensive public API for the HotPlex engine. It integrates execution, session management, and safety configuration.

type OpenCodeConfig added in v0.8.0

type OpenCodeConfig = provider.OpenCodeConfig

OpenCodeConfig contains OpenCode-specific configuration.

type Provider added in v0.7.0

type Provider = provider.Provider

Provider defines the interface for AI CLI agent providers.

type ProviderConfig added in v0.7.0

type ProviderConfig = provider.ProviderConfig

ProviderConfig defines the configuration for a specific provider instance.

type ProviderEvent added in v0.7.0

type ProviderEvent = provider.ProviderEvent

ProviderEvent represents a normalized event from any AI CLI provider.

type ProviderFeatures added in v0.7.0

type ProviderFeatures = provider.ProviderFeatures

ProviderFeatures describes the capabilities of a provider.

type ProviderMeta added in v0.7.0

type ProviderMeta = provider.ProviderMeta

ProviderMeta contains metadata about a provider.

type ProviderSessionOptions added in v0.7.0

type ProviderSessionOptions = provider.ProviderSessionOptions

ProviderSessionOptions configures a provider session.

type ProviderType added in v0.7.0

type ProviderType = provider.ProviderType

ProviderType defines the type of AI CLI provider.

type SafetyManager added in v0.7.0

type SafetyManager interface {
	// SetDangerAllowPaths configures the whitelist of safe directories for file I/O.
	SetDangerAllowPaths(paths []string)

	// SetDangerBypassEnabled toggles the regex WAF (requires valid admin token).
	SetDangerBypassEnabled(token string, enabled bool) error
}

SafetyManager controls the security boundaries and WAF settings.

type SessionController added in v0.7.0

type SessionController interface {
	// GetSessionStats returns telemetry and token usage for the given sessionID.
	// Note: Use the business-side sessionID provided during execution, not the internal
	// CLI-level session identifier. This sessionID maps to a specific background process.
	GetSessionStats(sessionID string) *SessionStats

	// StopSession forcibly terminates a persistent session and its underlying OS process group.
	// Note: Use the business-side sessionID (provided by the user) to identify which
	// specific agent instance to terminate.
	StopSession(sessionID string, reason string) error

	// GetCLIVersion returns the version string of the underlying AI CLI tool.
	GetCLIVersion() (string, error)
}

SessionController provides administrative control over persistent sessions.

type SessionStats

type SessionStats = engine.SessionStats

SessionStats collects session-level statistics.

type SessionStatsData

type SessionStatsData = event.SessionStatsData

SessionStatsData contains comprehensive session statistics.

type StreamMessage

type StreamMessage = types.StreamMessage

StreamMessage represents a message from the CLI stream.

type UsageStats

type UsageStats = types.UsageStats

UsageStats represents token usage statistics.

Directories

Path Synopsis
_examples
dingtalk_hook command
go_claude_basic command
Package brain provides intelligent orchestration capabilities for HotPlex.
Package brain provides intelligent orchestration capabilities for HotPlex.
llm
Package cache provides a pluggable caching layer for HotPlex.
Package cache provides a pluggable caching layer for HotPlex.
slack
Package slack provides a high-performance, AI-native Slack adapter for the HotPlex engine.
Package slack provides a high-performance, AI-native Slack adapter for the HotPlex engine.
cmd
hotplexd command
internal
engine
Package engine provides the core session management and process pool for HotPlex.
Package engine provides the core session management and process pool for HotPlex.
panicx
Package panicx provides panic recovery utilities for goroutine safety.
Package panicx provides panic recovery utilities for goroutine safety.
persistence
Package persistence provides session marker storage abstractions.
Package persistence provides session marker storage abstractions.
security
Package security provides WAF-like protection for the HotPlex engine.
Package security provides WAF-like protection for the HotPlex engine.
sys
Package sys provides cross-platform process management utilities.
Package sys provides cross-platform process management utilities.
plugins

Jump to

Keyboard shortcuts

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