genui

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 20 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 genui is Surface's host for generated UI: the reviewed GenUI contract and gateway from Substrate, given this app's storage, policy and effects.

What generated UI is here: the agent (or a module) names one of three reviewed patterns (an approval, a form, a list with detail) and its parameters. It cannot send components, markup, code or addresses. The host turns the parameters into a validated surface, keeps it as an immutable snapshot, and shows it as a card. When the owner acts on it, the action goes through the gateway: checked against the snapshot, journaled, admitted by policy, executed once.

Surface is one person's app on the loopback interface, so there is one scope, the owner's. The only effect an action has is to answer whoever showed the surface; the answer is the choice taken and, for a form, the values entered. A high-risk choice needs the owner to confirm it as a second, separate step. That is an acknowledgment, not reauthentication.

The surface store and the action journal the GenUI gateway needs, in the core database. A surface is an immutable snapshot; an action's request and digest never change and a claim is never cleared. Adapted from the gateway's reference host.

Index

Constants

View Source
const (

	// CardKind is the kind of the card a surface is shown as.
	CardKind = "genui"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service is the host: the gateway's ports and the routes and tool on top of it.

func New

func New(ctx context.Context, k kernel.Kernel, cards module.Cards) (*Service, error)

New builds the host on the core database.

func (*Service) Close

func (s *Service) Close(context.Context) error

Close has nothing to release.

func (*Service) Confirm

func (s *Service) Confirm(ctx context.Context, raw []byte) (string, error)

Confirm is the owner's second step on a high-risk choice: it issues the proof the waiting action needs. The page calls it when the owner presses Confirm.

func (*Service) Execute

func (s *Service) Execute(ctx context.Context, e gateway.Execution) (contract.Outcome, error)

Execute is the one effect: the answer reaches whoever showed the surface, by closing the card it was shown as. The gateway has journaled a claim first, so this runs once.

func (*Service) Materialize

func (s *Service) Materialize(_ context.Context, scope gateway.Scope, q gateway.ShowRequest) (gateway.Surface, error)

Materialize turns a pattern's parameters into a surface. It is the gateway's catalog.

func (*Service) Mount

func (s *Service) Mount(mux *http.ServeMux)

Mount adds the routes the page's GenUI controller talks to. The app serves on the loopback interface to its one owner, which is the scope every route acts in.

func (*Service) Select

func (s *Service) Select(ctx context.Context, surfaceID, itemID string) (contract.Envelope, error)

Select answers a click on a list item: the host makes a new surface with that item's detail, which replaces the one shown. The page never invents the detail.

func (*Service) Show

Show validates a pattern's parameters into a surface, keeps it, and puts it in front of the owner as a card.

func (*Service) Tools

func (s *Service) Tools() []kernel.BoundTool

Tools is what the agent gets: one tool that shows a reviewed pattern.

func (*Service) WithFence

func (s *Service) WithFence(ctx context.Context, r gateway.Request, fn func(context.Context, gateway.Decision) error) error

WithFence is the gateway's policy. It re-reads the retained surface and decides: act, refuse, lapse, or ask the owner to confirm a high-risk choice first.

type ShowRequest

type ShowRequest struct {
	Pattern contract.Pattern `json:"pattern"`
	Params  json.RawMessage  `json:"params"`
	// Source is who shows it: "agent", or a module's id.
	Source string `json:"-"`
	// Blocking says the sender waits on the answer.
	Blocking bool `json:"-"`
}

ShowRequest is what the agent, a module or an outside client gives to show a surface.

Jump to

Keyboard shortcuts

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