api

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api serves Stormlight's domain over HTTP and WebSockets: a second head on the same internal/app.Service the dashboard drives, so a browser client and the TUI are peers over one set of rules rather than two implementations of them.

Two planes share the listener and never mix. The control plane is JSON over HTTP — roster, workspaces, dispatch, history — where a millisecond costs nothing. The data plane is one WebSocket per attached terminal, carrying raw bytes in both directions: keystrokes are never wrapped in JSON and never queued behind a request. That split is what keeps typing in a browser terminal feel like typing in a terminal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewToken

func NewToken() (string, error)

NewToken mints a fresh access token. One per run: nothing persists it, so a restart invalidates every URL that was handed out.

Types

type Assets added in v0.12.0

type Assets fs.FS

Assets is the built frontend, handed in by the command that has it embedded. Nil serves nothing: the API is complete without a page, and a build that skipped the frontend should say so honestly rather than serve a blank one.

type Option added in v0.15.0

type Option func(*Server)

Option adjusts how the server runs.

func WithActions added in v0.15.0

func WithActions(dispatcher *action.Dispatcher) Option

WithActions makes this server a dashboard that runs agents' action requests: the roster poll that feeds the event stream also feeds the dispatcher, and it polls whether or not a browser is connected, because the actions run here regardless of who is watching.

type Server

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

Server is the HTTP surface. It owns no state the dashboard does not already own — every route is a decode, one Service call, and an encode.

func New

func New(service *app.Service, token string, assets Assets, options ...Option) (*Server, error)

New builds the server. The token is required, not optional: these routes dispatch agents and stream terminals in every workspace the catalog knows, which is shell access to all of them. There is deliberately no unauthenticated mode to ship by accident. assets is the built web client, or nil to serve the API alone.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler is the server as an http.Handler, with authentication in front of every route.

func (*Server) Run

func (s *Server) Run() (stop func())

Run starts the background work the event stream needs and returns a stop function. Serving without it yields a working control plane and an event socket that never speaks.

Jump to

Keyboard shortcuts

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