gatewaybridge

package
v0.0.98 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package gatewaybridge manages the local lifecycle of the klaus-gateway service (and optionally the upstream agentgateway it can run behind). It mirrors the shape of pkg/musterbridge: klausctl spawns the processes, tracks their PID/port, registers the HTTP MCP endpoint into mcpservers.yaml, and auto-starts on `klaus create` when a personality/instance declares `requires.gateway: true`.

Index

Constants

View Source
const (
	// BridgeName is the name used when registering klaus-gateway in the
	// MCP server store.
	BridgeName = "klaus-gateway"

	// DefaultKlausGatewayPort is the default port for klaus-gateway.
	DefaultKlausGatewayPort = 8080
	// DefaultAgentGatewayPort is the default port for the optional agentgateway.
	DefaultAgentGatewayPort = 8090
)

Variables

This section is empty.

Functions

func Stop

func Stop(ctx context.Context, paths *config.Paths) error

Stop terminates klaus-gateway first, then agentgateway if running, cleans up PID/port files, and removes the klaus-gateway entry from mcpservers.yaml.

Types

type AgentGatewayState

type AgentGatewayState struct {
	Running bool   `json:"running"`
	PID     int    `json:"pid,omitempty"`
	Port    int    `json:"port,omitempty"`
	URL     string `json:"url,omitempty"`
	Healthy bool   `json:"healthy"`
	Mode    string `json:"mode,omitempty"`
}

AgentGatewayState describes the agentgateway process state as a sub-status.

type Options

type Options struct {
	// WithAgentGateway, when true, also starts the agentgateway process
	// before starting klaus-gateway.
	WithAgentGateway bool

	// Port overrides the klaus-gateway listen port.
	Port int

	// AgentGatewayPort overrides the agentgateway listen port.
	AgentGatewayPort int

	// KlausGatewayBin overrides the klaus-gateway host binary path.
	// If empty, the KLAUS_GATEWAY_BIN env var is consulted, then PATH.
	KlausGatewayBin string

	// AgentGatewayBin overrides the agentgateway host binary path.
	// If empty, the KLAUS_AGENTGATEWAY_BIN env var is consulted, then PATH.
	AgentGatewayBin string

	// LogLevel overrides the gateway log level (defaults to "info").
	LogLevel string
}

Options configures the bridge lifecycle. All fields are optional; zero values fall back to defaults or values read from gateway/config.yaml.

type Status

type Status struct {
	Running          bool               `json:"running"`
	PID              int                `json:"pid,omitempty"`
	Port             int                `json:"port,omitempty"`
	URL              string             `json:"url,omitempty"`
	Healthy          bool               `json:"healthy"`
	Mode             string             `json:"mode,omitempty"`
	Adapters         []string           `json:"adapters,omitempty"`
	WithAgentGateway bool               `json:"withAgentGateway,omitempty"`
	AgentGateway     *AgentGatewayState `json:"agentGateway,omitempty"`
}

Status represents the state of the gateway bridge.

func EnsureRunning

func EnsureRunning(ctx context.Context, paths *config.Paths, opts Options) (*Status, error)

EnsureRunning starts the bridge if it is not already running, otherwise ensures the bridge entry exists in the MCP server store. Used by the auto-start integration in the instance start flow.

func GetStatus

func GetStatus(paths *config.Paths) *Status

GetStatus returns the current bridge status without mutating any state.

func Restart

func Restart(ctx context.Context, paths *config.Paths, opts Options) (*Status, error)

Restart stops and re-starts the bridge. Useful after config changes.

func Start

func Start(ctx context.Context, paths *config.Paths, opts Options) (*Status, error)

Start launches the klaus-gateway process (and optionally agentgateway) in the background. It is idempotent: if klaus-gateway is already running and healthy, it returns the existing status.

Jump to

Keyboard shortcuts

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