Documentation
¶
Overview ¶
Package web provides an embedded HTTP server for the initech web companion. It serves a single-page application from embedded static files and exposes a JSON API for pane information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LayoutInfo ¶ added in v1.6.0
type LayoutInfo struct {
Mode string `json:"mode"` // "focus", "grid", or "2col"
Cols int `json:"cols"`
Rows int `json:"rows"`
Focused string `json:"focused"` // Pane name.
}
LayoutInfo describes the current TUI layout.
type PaneInfo ¶
type PaneInfo struct {
Name string `json:"name"`
Host string `json:"host,omitempty"`
Activity string `json:"activity"`
Alive bool `json:"alive"`
Visible bool `json:"visible"`
}
PaneInfo describes a single managed pane. Mirrors tui.PaneInfo so the web package does not import tui directly.
type PaneLister ¶
PaneLister returns the current set of panes. The bool is false if the underlying system is shutting down and the data is unavailable.
type PaneState ¶ added in v1.6.0
type PaneState struct {
Name string `json:"name"`
Activity string `json:"activity"`
Alive bool `json:"alive"`
Visible bool `json:"visible"`
BeadID string `json:"bead_id,omitempty"`
Order int `json:"order"`
}
PaneState describes one agent's state for the web companion.
type PaneSubscriber ¶
type PaneSubscriber interface {
// SubscribePane registers a subscriber for the named pane's PTY output.
// Returns a channel of byte slices and true if the pane exists, or
// nil and false if the pane is not found.
SubscribePane(paneName, subscriberID string) (chan []byte, bool)
// UnsubscribePane removes a subscriber. Safe to call if the pane or
// subscriber does not exist.
UnsubscribePane(paneName, subscriberID string)
}
PaneSubscriber provides fan-out subscription to a pane's PTY byte stream. The returned channel receives copies of all bytes read from the pane's PTY. Callers must call UnsubscribePane when done.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an HTTP server that serves the SPA and pane API.
func NewServer ¶
func NewServer(port int, lister PaneLister, subscriber PaneSubscriber, stateProvider StateProvider, logger *slog.Logger) *Server
NewServer creates a Server bound to 0.0.0.0 on the given port, accessible from other machines on the network. The operator explicitly enables this with --web-port, so we bind all interfaces by default. If port is 0, the OS assigns a free port. The subscriber parameter is optional; if nil, the /ws/pane/{name} endpoint returns 501.
func (*Server) Addr ¶
Addr returns the address the server is bound to. Only meaningful after Start has been called (and the listener is active).
type StateProvider ¶ added in v1.6.0
type StateProvider interface {
CurrentState() (StateSnapshot, bool)
}
StateProvider returns the current TUI state snapshot. Called on a timer by the state broadcaster.
type StateSnapshot ¶ added in v1.6.0
type StateSnapshot struct {
Layout LayoutInfo `json:"layout"`
Panes []PaneState `json:"panes"`
}
StateSnapshot is the JSON payload sent over /ws/state. It combines layout information with per-agent status for the web companion SPA.