web

package
v1.34.0 Latest Latest
Warning

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

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

Documentation

Overview

Package web serves the single-file session viewer on loopback and bridges it to internal/sessions/live: the browser gets whole events over SSE and writes back through POST /send, while credentials and transport stay in this process.

web.go is the entry point (Serve), server.go the HTTP routes and their guards, and hub.go the fan-out of live updates to connected pages. viewer/README.md says where the bundle and its wire protocol come from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

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

Serve serves the viewer for session on a loopback port until ctx is done.

Types

type Options

type Options struct {
	// ConsoleURL is the session's page in the web Console, for the header link.
	ConsoleURL string
	// OpenURL is called with the page's address once the server is listening;
	// nil just prints it via Logf.
	OpenURL func(string) error
	// Logf reports the viewer URL and browser-open failures to the user; required.
	Logf func(format string, args ...any)
}

Options configures Serve.

type Session

type Session interface {
	Updates() <-chan live.ThreadUpdate
	Snapshot() (threads []live.Thread, logs []live.ThreadLog)
	Events(id live.ThreadID) []live.Event
	Session() *anthropic.BetaManagedAgentsSession
	SendMessage(ctx context.Context, text string) error
	Interrupt(ctx context.Context) error
	Confirm(ctx context.Context, toolUseID string, allow bool, denyMessage string) error
}

Session is what the server needs from an attached session; *live.Threads is one.

Jump to

Keyboard shortcuts

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