standalone

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package standalone provides a standalone HTTP server platform for omniagent.

The standalone platform runs a local HTTP server with:

  • WebSocket control plane for real-time client connections
  • Webhook endpoints for receiving messages from external services
  • Health check endpoint for monitoring
  • Graceful shutdown handling

Example Usage

p, _ := standalone.New(standalone.Config{
    Address: ":8080",
    WebhookHandlers: map[string]http.Handler{
        "/webhook/twilio/sms": twilioHandler,
    },
})

ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()

if err := p.Run(ctx, myAgent); err != nil {
    log.Fatal(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Address is the HTTP server listen address (default: ":8080").
	Address string

	// ReadTimeout is the HTTP read timeout (default: 30s).
	ReadTimeout time.Duration

	// WriteTimeout is the HTTP write timeout (default: 30s).
	WriteTimeout time.Duration

	// ShutdownTimeout is the graceful shutdown timeout (default: 10s).
	ShutdownTimeout time.Duration

	// Logger for platform logging.
	Logger *slog.Logger

	// WebhookHandlers maps paths to HTTP handlers for incoming webhooks.
	// Example: {"/webhook/twilio/sms": twilioHandler}
	WebhookHandlers map[string]http.Handler

	// EnableWebSocket enables the WebSocket control plane (default: true).
	EnableWebSocket bool

	// EnableHealthCheck enables the /health endpoint (default: true).
	EnableHealthCheck bool

	// TLS configures TLS for the HTTP server.
	TLS *TLSConfig
}

Config configures the standalone platform.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with default values.

type Platform

type Platform struct {
	// contains filtered or unexported fields
}

Platform is a standalone HTTP server platform.

func New

func New(config Config) (*Platform, error)

New creates a new standalone platform.

func (*Platform) Address

func (p *Platform) Address() string

Address returns the configured listen address.

func (*Platform) Gateway

func (p *Platform) Gateway() *gateway.Gateway

Gateway returns the underlying gateway, if WebSocket is enabled.

func (*Platform) Health

func (p *Platform) Health(_ context.Context) platform.Health

Health implements platform.HealthChecker.

func (*Platform) Name

func (p *Platform) Name() string

Name implements platform.Platform.

func (*Platform) Run

func (p *Platform) Run(ctx context.Context, a *agent.Agent) error

Run implements platform.Platform. It starts the HTTP server and blocks until context is cancelled.

type TLSConfig

type TLSConfig struct {
	CertFile string
	KeyFile  string
}

TLSConfig configures TLS for the HTTP server.

Jump to

Keyboard shortcuts

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