server

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DistAssets embed.FS

DistAssets embeds the production single-page application bundle. If empty (e.g. in test environments), the server provides a helpful fallback.

Functions

func DefaultConfigPath

func DefaultConfigPath() (string, error)

DefaultConfigPath resolves the default config file location.

func RunServe

func RunServe(arguments []string, _ io.Writer, diagnostics io.Writer) error

RunServe parses arguments and launches the Relayer Web Gateway.

func Serve

func Serve(ctx context.Context, opts Options) error

Serve initializes and runs the Relayer Web Gateway until context cancellation.

func StaticFileSystem

func StaticFileSystem() http.FileSystem

StaticFileSystem returns an http.FileSystem rooted at the embedded dist directory, stripping the "dist" prefix so that index.html is served at the root.

Types

type AgentCatalogEntry

type AgentCatalogEntry struct {
	ID                 string   `json:"id"`
	Name               string   `json:"name"`
	Description        string   `json:"description"`
	InstallStatus      string   `json:"installStatus"`
	Installed          bool     `json:"installed"`
	Adapter            string   `json:"adapter"`
	AdapterStatus      string   `json:"adapterStatus"`
	DefaultArgv        []string `json:"defaultArgv"`
	RequiresCustomArgv bool     `json:"requiresCustomArgv"`
	MinimumArguments   int      `json:"minimumArguments"`
	ArgumentPrefix     []string `json:"argumentPrefix"`
}

type AgentProfile

type AgentProfile struct {
	ID              string   `json:"id"`
	Name            string   `json:"name"`
	PresetID        string   `json:"presetID"`
	Cwd             string   `json:"cwd"`
	Backend         string   `json:"backend"`
	Adapter         string   `json:"adapter"`
	Argv            []string `json:"argv,omitempty"`
	ExecutableLabel string   `json:"executableLabel"`
	ArgumentCount   int      `json:"argumentCount"`
	Locked          bool     `json:"locked"`
	ReadOnlyReason  string   `json:"readOnlyReason,omitempty"`
	PreserveOnSave  bool     `json:"preserveOnSave"`
}

type AgentProfileInput

type AgentProfileInput struct {
	ID             string   `json:"id"`
	Name           string   `json:"name"`
	PresetID       string   `json:"presetID,omitempty"`
	Cwd            string   `json:"cwd,omitempty"`
	Backend        string   `json:"backend,omitempty"`
	Adapter        string   `json:"adapter,omitempty"`
	Argv           []string `json:"argv,omitempty"`
	PreserveOnSave bool     `json:"preserveOnSave,omitempty"`
}

type AgentProfilesView

type AgentProfilesView struct {
	ConfigPath      string              `json:"configPath"`
	Revision        string              `json:"revision"`
	Catalog         []AgentCatalogEntry `json:"catalog"`
	Profiles        []AgentProfile      `json:"profiles"`
	MinProfiles     int                 `json:"minProfiles"`
	MaxProfiles     int                 `json:"maxProfiles"`
	RestartRequired bool                `json:"restartRequired"`
	Editable        bool                `json:"editable"`
	ReadOnlyReason  string              `json:"readOnlyReason,omitempty"`
}

type AgentState

type AgentState struct {
	SessionID      string `json:"sessionID"`
	AgentID        string `json:"agentID"`
	Name           string `json:"name"`
	DisplayCommand string `json:"displayCommand"`
	Backend        string `json:"backend"`
	Adapter        string `json:"adapter"`
	Status         string `json:"status"`
	Output         string `json:"output"`
	Revision       uint64 `json:"revision"`
	Running        bool   `json:"running"`
	Attached       bool   `json:"attached"`
	InputFrozen    bool   `json:"inputFrozen"`
	Simulated      bool   `json:"simulated"`
	ExitCode       *int   `json:"exitCode,omitempty"`
}

type AppState

type AppState struct {
	RunID         string             `json:"runID"`
	RunStatus     string             `json:"runStatus"`
	StartedAt     string             `json:"startedAt,omitempty"`
	Policy        PolicyState        `json:"policy"`
	Audit         AuditState         `json:"audit"`
	Agents        []AgentState       `json:"agents"`
	PendingEvents []SupervisionEvent `json:"pendingEvents"`
	Notices       []string           `json:"notices"`
}

type AuditEntryView

type AuditEntryView struct {
	Sequence   uint64            `json:"sequence"`
	Timestamp  string            `json:"timestamp"`
	EntryID    string            `json:"entryID"`
	RunID      string            `json:"runID"`
	Kind       string            `json:"kind"`
	SessionID  string            `json:"sessionID,omitempty"`
	AgentID    string            `json:"agentID,omitempty"`
	Backend    string            `json:"backend,omitempty"`
	Adapter    string            `json:"adapter,omitempty"`
	EventType  string            `json:"eventType,omitempty"`
	Risk       string            `json:"risk,omitempty"`
	Rule       string            `json:"rule,omitempty"`
	Decision   string            `json:"decision,omitempty"`
	DecisionBy string            `json:"decisionBy,omitempty"`
	Operator   string            `json:"operator,omitempty"`
	Outcome    string            `json:"outcome,omitempty"`
	Reason     string            `json:"reason,omitempty"`
	Summary    string            `json:"summary,omitempty"`
	Sensitive  bool              `json:"sensitive"`
	Metadata   map[string]string `json:"metadata,omitempty"`
}

type AuditFilterInput

type AuditFilterInput struct {
	AgentID   string `json:"agentID,omitempty"`
	SessionID string `json:"sessionID,omitempty"`
	RunID     string `json:"runID,omitempty"`
	Kind      string `json:"kind,omitempty"`
	Limit     int    `json:"limit,omitempty"`
}

type AuditState

type AuditState struct {
	Enabled bool   `json:"enabled"`
	Mode    string `json:"mode"`
	Status  string `json:"status"`
	Path    string `json:"path,omitempty"`
}

type AuditSummaryView

type AuditSummaryView struct {
	Path           string         `json:"path"`
	TotalEntries   int            `json:"totalEntries"`
	RunsCount      int            `json:"runsCount"`
	SessionsCount  int            `json:"sessionsCount"`
	AgentCounts    map[string]int `json:"agentCounts"`
	KindCounts     map[string]int `json:"kindCounts"`
	DecisionsCount map[string]int `json:"decisionsCount"`
	ActorsCount    map[string]int `json:"actorsCount"`
	OutcomesCount  map[string]int `json:"outcomesCount"`
	SensitiveCount int            `json:"sensitiveCount"`
	FirstTimestamp string         `json:"firstTimestamp,omitempty"`
	LastTimestamp  string         `json:"lastTimestamp,omitempty"`
}

type AuditVerificationIssueView

type AuditVerificationIssueView struct {
	Line    int    `json:"line"`
	EntryID string `json:"entryID,omitempty"`
	Message string `json:"message"`
}

type AuditVerificationView

type AuditVerificationView struct {
	Path       string                       `json:"path"`
	TotalLines int                          `json:"totalLines"`
	TotalRuns  int                          `json:"totalRuns"`
	ValidLines int                          `json:"validLines"`
	Issues     []AuditVerificationIssueView `json:"issues"`
	Passed     bool                         `json:"passed"`
}

type AuthIdentity added in v0.6.0

type AuthIdentity struct {
	Identity string
	Role     UserRole
}

type Controller

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

Controller owns the headless supervisor runtime and provides thread-safe query and mutation methods mirroring the RelayerBridge interface.

func NewController

func NewController(configPath string, diagnostics io.Writer) (*Controller, error)

NewController creates an unstarted supervisor controller.

func (*Controller) Close

func (c *Controller) Close(ctx context.Context) error

Close gracefully stops the running supervisor and all agent processes.

func (*Controller) ExportAuditReport

func (c *Controller) ExportAuditReport(format string) (string, error)

func (*Controller) GetAgentProfiles

func (c *Controller) GetAgentProfiles() (AgentProfilesView, error)

func (*Controller) GetAuditEntries

func (c *Controller) GetAuditEntries(filter AuditFilterInput) ([]AuditEntryView, error)

func (*Controller) GetAuditSummary

func (c *Controller) GetAuditSummary() (AuditSummaryView, error)

func (*Controller) GetFullSettings

func (c *Controller) GetFullSettings() (FullSettingsView, error)

func (*Controller) GetState

func (c *Controller) GetState() AppState

func (*Controller) GetTelemetrySnapshot

func (c *Controller) GetTelemetrySnapshot() TelemetrySnapshotView

func (*Controller) ResizeSession

func (c *Controller) ResizeSession(runID, sessionID string, columns, rows int) error

func (*Controller) RestartSession

func (c *Controller) RestartSession(runID, sessionID string) error

func (*Controller) RunPreflight

func (c *Controller) RunPreflight(ctx context.Context) (PreflightReport, error)

func (*Controller) SaveAgentProfiles

func (c *Controller) SaveAgentProfiles(runID string, req SaveAgentProfilesRequest) (AgentProfilesView, error)

func (*Controller) SaveAgentProfilesAndRestart

func (c *Controller) SaveAgentProfilesAndRestart(req SaveAgentProfilesAndRestartRequest) (LifecycleResult, error)

func (*Controller) SaveFullSettings

func (c *Controller) SaveFullSettings(runID string, req SaveFullSettingsRequest) (FullSettingsView, error)

func (*Controller) SendTerminalInput added in v0.6.0

func (c *Controller) SendTerminalInput(runID, sessionID string, data []byte, operator string) error

SendTerminalInput delivers raw terminal input bytes directly to the session backend. Used by the web interactive terminal (full PTY mode) to stream keystrokes and signals.

func (*Controller) SetInteractiveSession added in v0.6.0

func (c *Controller) SetInteractiveSession(runID, sessionID string, active bool, operator string) error

SetInteractiveSession toggles an agent's interactive attachment state and logs audit tracking.

func (*Controller) Start

func (c *Controller) Start(ctx context.Context) error

Start boots the supervisor runtime and begins event processing.

func (*Controller) StartSession

func (c *Controller) StartSession(runID, sessionID string) error

func (*Controller) StopRun

func (c *Controller) StopRun(runID string) (AppState, error)

func (*Controller) StopSession

func (c *Controller) StopSession(runID, sessionID string) error

func (*Controller) SubmitAutomaticDecision

func (c *Controller) SubmitAutomaticDecision(runID, sessionID, eventID, decision string) error

func (*Controller) SubmitDecision

func (c *Controller) SubmitDecision(runID, sessionID, eventID, value string) error

func (*Controller) SubmitDecisionWithOperator added in v0.6.0

func (c *Controller) SubmitDecisionWithOperator(runID, sessionID, eventID, value, operator string) error

func (*Controller) SubmitLine

func (c *Controller) SubmitLine(runID, sessionID, line string) error

func (*Controller) SubmitLineWithOperator added in v0.6.0

func (c *Controller) SubmitLineWithOperator(runID, sessionID, line, operator string) error

func (*Controller) Subscribe

func (c *Controller) Subscribe(listener func(event string, payload any)) func()

Subscribe registers an event listener called on each broadcast. Returns an unsubscribe function.

func (*Controller) TestNotification

func (c *Controller) TestNotification() error

func (*Controller) VerifyAuditJournal

func (c *Controller) VerifyAuditJournal() (AuditVerificationView, error)

type DecisionBreakdown

type DecisionBreakdown struct {
	Allow     int64 `json:"allow"`
	Deny      int64 `json:"deny"`
	AutoAllow int64 `json:"autoAllow"`
	AutoDeny  int64 `json:"autoDeny"`
	Custom    int64 `json:"custom"`
}

type FullSettingsView

type FullSettingsView struct {
	AgentProfilesView
	Security      SecuritySettings     `json:"security"`
	Notifications NotificationSettings `json:"notifications"`
}

type LatencyBucketView

type LatencyBucketView struct {
	Le    float64 `json:"le"`
	Label string  `json:"label"`
	Count uint64  `json:"count"`
}

type LifecycleResult

type LifecycleResult struct {
	Outcome  string            `json:"outcome"`
	State    AppState          `json:"state"`
	Profiles AgentProfilesView `json:"profiles"`
}

type NotificationEvent

type NotificationEvent struct {
	Title     string `json:"title"`
	Body      string `json:"body"`
	AgentName string `json:"agentName,omitempty"`
	SessionID string `json:"sessionID,omitempty"`
	EventID   string `json:"eventID,omitempty"`
	Kind      string `json:"kind"`
	Severity  string `json:"severity"`
	Reason    string `json:"reason,omitempty"`
	Timestamp string `json:"timestamp"`
}

NotificationEvent is broadcast to WebSocket clients when an operator alert fires.

type NotificationSettings

type NotificationSettings struct {
	Enabled     bool                         `json:"enabled"`
	Bell        bool                         `json:"bell"`
	Desktop     bool                         `json:"desktop"`
	MinSeverity string                       `json:"minSeverity"`
	Webhooks    []NotificationWebhookSetting `json:"webhooks"`
}

type NotificationWebhookSetting

type NotificationWebhookSetting struct {
	Name        string `json:"name"`
	URL         string `json:"url"`
	Format      string `json:"format"`
	MinSeverity string `json:"minSeverity"`
	Timeout     string `json:"timeout"`
}

type Options

type Options struct {
	Bind        string
	Port        int
	Token       string
	ViewerToken string
	ConfigPath  string
	StaticDir   string
	Diagnostics io.Writer
	OnReady     func(serverURL string, token string)
}

Options configures the headless Relayer web server.

type PolicyEvaluation

type PolicyEvaluation struct {
	Action         string `json:"action"`
	ProposedAction string `json:"proposedAction"`
	RuleName       string `json:"ruleName,omitempty"`
	Reason         string `json:"reason"`
	Automatic      bool   `json:"automatic"`
	DryRun         bool   `json:"dryRun"`
}

type PolicyState

type PolicyState struct {
	DefaultAction string `json:"defaultAction"`
	DryRun        bool   `json:"dryRun"`
}

type PreflightAgent

type PreflightAgent struct {
	Ordinal         int    `json:"ordinal"`
	Source          string `json:"source"`
	Command         string `json:"command"`
	Installation    string `json:"installation"`
	Adapter         string `json:"adapter,omitempty"`
	AdapterMaturity string `json:"adapterMaturity,omitempty"`
	Backend         string `json:"backend,omitempty"`
}

type PreflightAudit

type PreflightAudit struct {
	Enabled       bool   `json:"enabled"`
	Mode          string `json:"mode"`
	Location      string `json:"location"`
	MaxFileSizeMB int    `json:"maxFileSizeMB"`
	MaxFiles      int    `json:"maxFiles"`
}

type PreflightCheck

type PreflightCheck struct {
	ID          string `json:"id"`
	Scope       string `json:"scope"`
	Status      string `json:"status"`
	Summary     string `json:"summary"`
	Remediation string `json:"remediation,omitempty"`
}

type PreflightConfiguration

type PreflightConfiguration struct {
	Version         int  `json:"version"`
	Legacy          bool `json:"legacy"`
	AgentCount      int  `json:"agentCount"`
	PolicyRuleCount int  `json:"policyRuleCount"`
}

type PreflightPlatform

type PreflightPlatform struct {
	OS        string `json:"os"`
	Arch      string `json:"arch"`
	Supported bool   `json:"supported"`
}

type PreflightReport

type PreflightReport struct {
	SchemaVersion int                    `json:"schemaVersion"`
	Status        string                 `json:"status"`
	Platform      PreflightPlatform      `json:"platform"`
	Configuration PreflightConfiguration `json:"configuration"`
	Audit         PreflightAudit         `json:"audit"`
	Tools         []PreflightTool        `json:"tools"`
	Agents        []PreflightAgent       `json:"agents"`
	Checks        []PreflightCheck       `json:"checks"`
}

type PreflightTool

type PreflightTool struct {
	ProfileID    string `json:"profileID"`
	Installation string `json:"installation"`
}

type SafeErrorEvent

type SafeErrorEvent struct {
	RunID     string `json:"runID"`
	Code      string `json:"code"`
	Message   string `json:"message"`
	SessionID string `json:"sessionID,omitempty"`
	Timestamp string `json:"timestamp"`
}

type SaveAgentProfilesAndRestartRequest

type SaveAgentProfilesAndRestartRequest struct {
	ExpectedRunID    string              `json:"expectedRunID,omitempty"`
	ExpectedRevision string              `json:"expectedRevision"`
	Profiles         []AgentProfileInput `json:"profiles"`
}

type SaveAgentProfilesRequest

type SaveAgentProfilesRequest struct {
	ExpectedRevision string              `json:"expectedRevision"`
	Profiles         []AgentProfileInput `json:"profiles"`
}

type SaveFullSettingsRequest

type SaveFullSettingsRequest struct {
	ExpectedRevision string                `json:"expectedRevision"`
	Profiles         []AgentProfileInput   `json:"profiles,omitempty"`
	Security         *SecuritySettings     `json:"security,omitempty"`
	Notifications    *NotificationSettings `json:"notifications,omitempty"`
}

type SecuritySettings

type SecuritySettings struct {
	Profile                     string `json:"profile"`
	DefaultAction               string `json:"defaultAction"`
	DryRun                      bool   `json:"dryRun"`
	BlockDestructive            bool   `json:"blockDestructive"`
	BlockExfiltration           bool   `json:"blockExfiltration"`
	BlockSensitivePaths         bool   `json:"blockSensitivePaths"`
	BlockOutsideWorkspace       bool   `json:"blockOutsideWorkspace"`
	WorkspaceRoot               string `json:"workspaceRoot"`
	RateLimitPerMinute          int    `json:"rateLimitPerMinute"`
	MaxConsecutiveAutoDecisions int    `json:"maxConsecutiveAutoDecisions"`
}

type SnapshotEvent

type SnapshotEvent struct {
	RunID       string `json:"runID"`
	SessionID   string `json:"sessionID"`
	Revision    uint64 `json:"revision"`
	Output      string `json:"output"`
	Status      string `json:"status"`
	Running     bool   `json:"running"`
	Attached    bool   `json:"attached"`
	InputFrozen bool   `json:"inputFrozen"`
	ExitCode    *int   `json:"exitCode,omitempty"`
}

type StatusEvent

type StatusEvent struct {
	RunID     string `json:"runID"`
	Scope     string `json:"scope"`
	Status    string `json:"status"`
	SessionID string `json:"sessionID,omitempty"`
}

type SupervisionEvent

type SupervisionEvent struct {
	RunID          string           `json:"runID"`
	ID             string           `json:"id"`
	SessionID      string           `json:"sessionID"`
	AgentID        string           `json:"agentID"`
	Adapter        string           `json:"adapter"`
	Type           string           `json:"type"`
	Summary        string           `json:"summary"`
	Sensitive      bool             `json:"sensitive"`
	Risk           string           `json:"risk"`
	Timestamp      string           `json:"timestamp"`
	Evaluation     PolicyEvaluation `json:"evaluation"`
	DeliveryStatus string           `json:"deliveryStatus"`
	Decisions      []string         `json:"decisions"`
}

type TelemetrySnapshotView

type TelemetrySnapshotView struct {
	Timestamp            string              `json:"timestamp"`
	Enabled              bool                `json:"enabled"`
	PrometheusEnabled    bool                `json:"prometheusEnabled"`
	PrometheusAddress    string              `json:"prometheusAddress,omitempty"`
	OTLPEnabled          bool                `json:"otlpEnabled"`
	OTLPEndpoint         string              `json:"otlpEndpoint,omitempty"`
	SessionsActive       int64               `json:"sessionsActive"`
	EventsPending        int64               `json:"eventsPending"`
	SessionsTotal        int64               `json:"sessionsTotal"`
	EventsDetectedTotal  int64               `json:"eventsDetectedTotal"`
	EventsWithdrawnTotal int64               `json:"eventsWithdrawnTotal"`
	DecisionsTotal       int64               `json:"decisionsTotal"`
	DecisionsBreakdown   DecisionBreakdown   `json:"decisionsBreakdown"`
	OperatorInputsTotal  int64               `json:"operatorInputsTotal"`
	GuardrailsTotal      int64               `json:"guardrailsTotal"`
	GuardrailsBreakdown  map[string]int64    `json:"guardrailsBreakdown"`
	AverageReactionTime  float64             `json:"averageReactionTime"`
	DecisionDurations    []LatencyBucketView `json:"decisionDurations"`
}

type UserInfo added in v0.6.0

type UserInfo struct {
	Identity string `json:"identity"`
	Role     string `json:"role"`
	ReadOnly bool   `json:"readOnly"`
}

type UserRole added in v0.6.0

type UserRole string

UserRole defines the privilege level of an authenticated client.

const (
	RoleOperator UserRole = "operator"
	RoleViewer   UserRole = "viewer"
)

Jump to

Keyboard shortcuts

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