hotplex

package module
v0.24.2 Latest Latest
Warning

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

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

README ยถ

HotPlex

HotPlex

Turn AI CLIs into Production-Ready Services

Bridge powerful AI CLIs (Claude Code, OpenCode) into persistent, secure, production-grade interactive services.

Release Go Reference Go Report Tests Coverage License Stars

Quick Start ยท Features ยท Architecture ยท Docs ยท Discussions ยท ็ฎ€ไฝ“ไธญๆ–‡


โšก Quick Start

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

# Or build from source
make build

# Start with Slack or Feishu
export HOTPLEX_SLACK_PRIMARY_OWNER=U...
export HOTPLEX_SLACK_BOT_TOKEN=xoxb-...
export HOTPLEX_SLACK_APP_TOKEN=xapp-...
./hotplexd --config configs/chatapps/slack.yaml
Requirements
Component Version
Go 1.25+
AI CLI Claude Code or OpenCode

โœจ Features

๐Ÿ”„ 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 zombies
๐Ÿ’ฌ Multi-Platform Slack ยท Feishu
๐Ÿ“ฆ Go SDK Embed directly in your Go app with zero overhead
๐Ÿ”Œ WebSocket Gateway Language-agnostic access via hotplexd daemon
๐Ÿ“Š OpenTelemetry Built-in metrics and tracing support
๐Ÿณ Docker Ready Run multiple isolated bots with one command

๐ŸŽฏ Why HotPlex?

The missing control plane for AI agents in production

Challenge HotPlex Solution
AI agents spin up fresh each request Persistent sessions - CLI stays alive, reuses context
No safety for destructive commands Regex WAF - Programmable firewall for shell instructions
Hard to scale AI interactions Process multiplexing - Hundreds of concurrent sessions
Integration complexity ChatApps - One codebase, Slack / Feishu support
Enterprise-grade security PGID isolation + filesystem jail + container sandbox

๐Ÿ› Architecture

โ”‚                        ChatApps Layer                           โ”‚
โ”‚                       Slack ยท Feishu                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      WebSocket Gateway                          โ”‚
โ”‚                  (hotplexd daemon / Go SDK)                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Engine / Runner                            โ”‚
โ”‚         I/O Multiplexing ยท Session Pool ยท Events               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ                    โ–ผ                    โ–ผ
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚ Claude  โ”‚         โ”‚ OpenCodeโ”‚         โ”‚ Custom  โ”‚
   โ”‚   CLI   โ”‚         โ”‚   CLI   โ”‚         โ”‚ Providerโ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Security Layers
Layer Implementation
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 (BaaS) - OS-level isolation & limits

๐Ÿ“– Usage Examples

Go SDK
import (
    "context"
    "fmt"
    "time"

    "github.com/hrygo/hotplex"
    "github.com/hrygo/hotplex/types"
)

engine, err := hotplex.NewEngine(hotplex.EngineOptions{
    Timeout:     5 * time.Minute,
    IdleTimeout: 30 * time.Minute,
})
if err != nil {
    panic(err)
}
defer engine.Close()

cfg := &types.Config{
    WorkDir:   "/path/to/project",
    SessionID: "user-session-123",
}

engine.Execute(context.Background(), cfg, "Refactor this function", func(eventType string, data any) error {
    if msg, ok := data.(*types.StreamMessage); ok {
        fmt.Print(msg.Content) // Streaming response
    }
    return nil
})
Slack Bot
# configs/chatapps/slack.yaml
platform: slack
mode: socket

provider:
  type: claude-code
  default_model: sonnet

engine:
  work_dir: ~/projects/hotplex
  timeout: 30m
  idle_timeout: 1h

security:
  owner:
    primary: ${HOTPLEX_SLACK_PRIMARY_OWNER}
    policy: trusted

assistant:
  bot_user_id: ${HOTPLEX_SLACK_BOT_USER_ID}
  dm_policy: allow
  group_policy: multibot
export HOTPLEX_SLACK_BOT_USER_ID=B12345
export HOTPLEX_SLACK_BOT_TOKEN=xoxb-...
export HOTPLEX_SLACK_APP_TOKEN=xapp-...
./hotplexd --config configs/chatapps/slack.yaml
WebSocket API
const ws = new WebSocket('ws://localhost:8080/ws/v1/agent');

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log(data.type, data.content);
};

ws.send(JSON.stringify({
  type: 'execute',
  prompt: 'Hello, AI!'
}));

๐Ÿ“š Documentation

๐Ÿš€ Deployment Guide Docker, production setup
๐Ÿ’ฌ ChatApps Manual Slack & Feishu integration
๐Ÿ›  Go SDK Reference Complete SDK documentation
๐Ÿ”’ Security Guide WAF, isolation, best practices
๐Ÿ“Š Observability Metrics, tracing, logging

๐Ÿค Contributing

Contributions are welcome! Please read our Contributing Guide for details.

# Development setup
go mod download   # Install dependencies
make test         # Run tests
make lint         # Run linter
make build        # Build binary

# Submit a PR
git checkout -b feat/your-feature
git commit -m "feat: add awesome feature"
gh pr create --fill

๐Ÿ“„ License

MIT License ยฉ 2024-present HotPlex Contributors


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
chatapps_slack 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.
slack/apphome
Package apphome provides Slack App Home capability center functionality.
Package apphome provides Slack App Home capability center functionality.
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