web

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package web is the official browser UI for the Human worker.

It is a stateless projection over a workerkit.Worker: every business rule, transcript, draft, and continuation lives in workerkit and its StateStore; the web layer renders snapshots and forwards commands. The host owns the listener and the worker daemon lifetime — browsers are disposable sessions that can open and close without losing any state.

Authentication is a single opaque session token chosen by the host. It is intended for loopback use or behind a host-owned TLS reverse proxy; the worker's transport credentials never reach the browser.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfig = errors.New("web: invalid configuration")
	ErrClosed        = errors.New("web: server is closed")
)

Functions

This section is empty.

Types

type CommandProfile

type CommandProfile struct {
	ID               string `json:"id"`
	ToolName         string `json:"tool_name"`
	CommandField     string `json:"command_field"`
	DescriptionField string `json:"description_field,omitempty"`
}

CommandProfile describes the safe subset needed by the reference Web command editor. It only constructs a caller-side tool call; Human never executes the command in the worker or browser environment.

func (CommandProfile) Validate

func (profile CommandProfile) Validate() error

type CommandProfileResolver

type CommandProfileResolver interface {
	ResolveCommandProfile(llm.TaskContext, llm.Request) (profile CommandProfile, ok bool)
}

CommandProfileResolver maps an exact authenticated harness request onto the reference Web command editor. It has the same borrowing/concurrency contract as PlanProfileResolver and fails closed by returning ok=false.

func OfficialCommandProfiles

func OfficialCommandProfiles() CommandProfileResolver

OfficialCommandProfiles returns the exact profiles exercised by the real client gates. Command tools use the Agent process's current workspace; the Human browser never receives or selects a caller filesystem path.

type CommandProfileResolverFunc

type CommandProfileResolverFunc func(llm.TaskContext, llm.Request) (CommandProfile, bool)

func (CommandProfileResolverFunc) ResolveCommandProfile

func (function CommandProfileResolverFunc) ResolveCommandProfile(
	task llm.TaskContext,
	request llm.Request,
) (CommandProfile, bool)

type Config

type Config struct {
	Worker       *workerkit.Worker
	SessionToken string
	// Heartbeat bounds SSE keep-alive comments. Zero selects 25 seconds.
	Heartbeat time.Duration
	// PlanProfiles selects the normalized Tasks/Plan panel from an exact harness
	// request. Nil installs OfficialPlanProfiles. A typed nil is rejected.
	PlanProfiles PlanProfileResolver
	// CommandProfiles selects the normalized command editor from an exact
	// harness request. Nil installs OfficialCommandProfiles. A typed nil is
	// rejected.
	CommandProfiles CommandProfileResolver
}

Config composes one Server. Worker is required and borrowed: the host shuts the Server down before the Worker. SessionToken is required and compared in constant time; generate it per daemon start and hand it to the operator as a login URL (http://host/?token=...).

type PlanKind

type PlanKind string

PlanKind identifies the interaction model rendered by the reference Web UI. List profiles replace the caller's complete plan in one tool call. Task lifecycle profiles create and update individually identified caller tasks.

const (
	PlanKindList          PlanKind = "list"
	PlanKindTaskLifecycle PlanKind = "task_lifecycle"
)

type PlanProfile

type PlanProfile struct {
	ID              string   `json:"id"`
	Kind            PlanKind `json:"kind"`
	ToolName        string   `json:"tool_name,omitempty"`
	ItemsField      string   `json:"items_field,omitempty"`
	ContentField    string   `json:"content_field,omitempty"`
	StatusField     string   `json:"status_field,omitempty"`
	PriorityField   string   `json:"priority_field,omitempty"`
	DefaultPriority string   `json:"default_priority,omitempty"`
	CreateTool      string   `json:"create_tool,omitempty"`
	UpdateTool      string   `json:"update_tool,omitempty"`
	ListTool        string   `json:"list_tool,omitempty"`
}

PlanProfile is the normalized browser contract selected from one exact harness request. It contains no authority: the HumanLLM core still checks the submitted call against the caller's declaration and ToolAuthorizer.

func (PlanProfile) Validate

func (profile PlanProfile) Validate() error

Validate rejects ambiguous UI profiles. A custom resolver may return only these closed, generic interaction shapes; products needing different task semantics can replace the Web human-side implementation entirely.

type PlanProfileResolver

type PlanProfileResolver interface {
	ResolvePlanProfile(llm.TaskContext, llm.Request) (profile PlanProfile, ok bool)
}

PlanProfileResolver maps an exact authenticated harness task plus its current caller-declared tools onto a normalized Web plan surface. Implementations are borrowed for the Server lifetime, called concurrently, and must not mutate or retain the input values. Returning ok=false makes the dedicated panel fail closed while leaving the generic declared-tool editor available.

func OfficialPlanProfiles

func OfficialPlanProfiles() PlanProfileResolver

OfficialPlanProfiles returns the exact profiles proven by the repository's real Claude Code, OpenCode, and Codex container gates. Behavioral JSON Schema is matched exactly after removing annotations such as descriptions; a new field, constraint, or enum value therefore fails closed until reviewed.

type PlanProfileResolverFunc

type PlanProfileResolverFunc func(llm.TaskContext, llm.Request) (PlanProfile, bool)

func (PlanProfileResolverFunc) ResolvePlanProfile

func (function PlanProfileResolverFunc) ResolvePlanProfile(
	task llm.TaskContext,
	request llm.Request,
) (PlanProfile, bool)

type Server

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

Server is an http.Handler serving the embedded UI, the JSON command API, and the SSE state stream. Construct with New; Shutdown stops the broadcast pump and closes every SSE session.

func New

func New(config Config) (*Server, error)

New validates the configuration and starts the notification broadcast pump.

func (*Server) ServeHTTP

func (server *Server) ServeHTTP(response http.ResponseWriter, request *http.Request)

func (*Server) Shutdown

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

Shutdown stops the broadcast pump and wakes every SSE session so their handlers can drain. It does not shut down the borrowed Worker.

Jump to

Keyboard shortcuts

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