web

package
v0.11.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0, MIT Imports: 32 Imported by: 0

Documentation

Overview

Package web serves the Overkill browser UI: an embedded SPA over HTTP plus a WebSocket event channel for live agent streams. Same agent backend as the TUI; reads from the same session store.

Index

Constants

View Source
const (
	CanvasMaxRevision      int64 = 9007199254740991
	CatalogCanvasV1              = "overkill.canvas.v1"
	CanvasMaxComponents          = 128
	CanvasMaxDepth               = 16
	CanvasMaxTextBytes           = 16 * 1024
	CanvasMaxDataBytes           = 64 * 1024
	CanvasMaxStateBytes          = 256 * 1024
	CanvasMaxSurfaces            = 16
	CanvasMaxRenderedNodes       = 2048
)

Variables

View Source
var Assets embed.FS

Assets is the SPA bundle compiled into the binary. Listed explicitly so the build fails loudly if a file goes missing instead of silently shipping an empty page.

View Source
var ErrCanvasInvalid = errors.New("invalid canvas update")
View Source
var ErrCanvasSessionNotFound = errors.New("canvas session not found")
View Source
var ErrCanvasUnavailable = errors.New("canvas store unavailable")

Functions

This section is empty.

Types

type AgentSender

type AgentSender interface {
	Stream(ctx context.Context, userInput string) (<-chan agent.StreamEvent, error)
	Model() string
	SessionID() string
	SetSessionID(id string)
}

AgentSender is the slice of agent.Agent the web server actually needs. Defining it locally keeps the package mockable in tests.

type CanvasComponent

type CanvasComponent struct {
	ID       string   `json:"id"`
	Type     string   `json:"type"`
	Text     *string  `json:"text,omitempty"`
	TextPath string   `json:"textPath,omitempty"`
	Children []string `json:"children,omitempty"`
}

type CanvasEvent

type CanvasEvent struct {
	Type      string    `json:"type"` // always "a2ui"
	SessionID string    `json:"sessionId"`
	SurfaceID string    `json:"surfaceId,omitempty"`
	Action    string    `json:"action"` // "surfaceUpdate", "beginRendering", etc.
	JSONL     string    `json:"jsonl"`  // One line of A2UI JSON
	Timestamp time.Time `json:"timestamp"`
	Revision  int64     `json:"revision"`
}

CanvasEvent transports a committed custom-catalog update over the event bus. The action names are transport conventions, not full upstream A2UI support.

type CanvasState

type CanvasState struct {
	SessionID string          `json:"sessionId"`
	Revision  int64           `json:"revision"`
	Surfaces  []CanvasSurface `json:"surfaces"`
}

CanvasState is the durable overkill.canvas.v1 document, not upstream A2UI.

type CanvasStore

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

CanvasStore retains custom catalog documents. The caller owns the pool.

func NewCanvasStore

func NewCanvasStore(db *sql.DB) *CanvasStore

func (*CanvasStore) Apply

func (s *CanvasStore) Apply(ctx context.Context, sid, line string) (CanvasState, error)

func (*CanvasStore) Get

func (s *CanvasStore) Get(ctx context.Context, sid string) (CanvasState, error)

func (*CanvasStore) Migrate

func (s *CanvasStore) Migrate(ctx context.Context) error

func (*CanvasStore) Reset

func (s *CanvasStore) Reset(ctx context.Context, sid string) (CanvasState, error)

type CanvasSurface

type CanvasSurface struct {
	SurfaceID  string            `json:"surfaceId"`
	Catalog    string            `json:"catalog"`
	Root       string            `json:"root"`
	Components []CanvasComponent `json:"components"`
	Data       map[string]any    `json:"data"`
	Rendering  bool              `json:"rendering"`
}

type Config

type Config struct {
	Addr             string
	Token            string
	NoAuth           bool
	Agent            AgentSender            // required for /api/send to work
	Store            session.Store          // optional; persistence
	Flows            *FlowStore             // optional; durable managed workflow records
	Canvas           *CanvasStore           // optional; durable canvas state
	CanvasChromePath string                 // trusted administrator browser executable for snapshots
	Catalog          *providers.Catalog     // optional; powers the model picker
	PairingStore     *security.PairingStore // optional; powers the /api/pairing/* endpoints
	Provider         string
	Version          string
}

Config drives Server construction. Token is required unless NoAuth is true (only meaningful with a localhost listen address).

type FlowStore

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

FlowStore persists managed workflow records, separately from suspended agent continuation snapshots. Updating a record does not execute an agent.

func NewFlowStore

func NewFlowStore(db *sql.DB) *FlowStore

func (*FlowStore) Migrate

func (s *FlowStore) Migrate(ctx context.Context) error

Migrate is called after session migration by the web entry point.

type Server

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

Server is the HTTP front for the web UI.

func NewServer

func NewServer(cfg Config) *Server

NewServer wires the routes; Start binds the listener.

func (*Server) Addr

func (s *Server) Addr() string

Addr is the resolved listen address (useful when ":0" was requested).

func (*Server) Handler

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

Handler returns the http.Handler so tests can drive it without a TCP socket.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown stops the HTTP server and closes any active streams.

func (*Server) Start

func (s *Server) Start() error

Start binds and serves. Non-blocking: returns once the listener is up.

func (*Server) Token

func (s *Server) Token() string

Token returns the configured bearer token (empty when --no-auth).

Jump to

Keyboard shortcuts

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