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
- type Service
- func (s *Service) Close(context.Context) error
- func (s *Service) Confirm(ctx context.Context, raw []byte) (string, error)
- func (s *Service) Execute(ctx context.Context, e gateway.Execution) (contract.Outcome, error)
- func (s *Service) Materialize(_ context.Context, scope gateway.Scope, q gateway.ShowRequest) (gateway.Surface, error)
- func (s *Service) Mount(mux *http.ServeMux)
- func (s *Service) Select(ctx context.Context, surfaceID, itemID string) (contract.Envelope, error)
- func (s *Service) Show(ctx context.Context, q ShowRequest) (module.Card, contract.Envelope, error)
- func (s *Service) Tools() []kernel.BoundTool
- func (s *Service) WithFence(ctx context.Context, r gateway.Request, ...) error
- type ShowRequest
Constants ¶
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 (*Service) Confirm ¶
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 ¶
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 ¶
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 ¶
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) 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.