a2ui

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 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 a2ui is the part of A2UI v0.9 (https://a2ui.org) a workflow's human task uses, on the service's side (spec_043_workflows WF-18): a form as the standard server-to-client messages any A2UI renderer can draw, and an answer (the client-to-server action message) checked against the form before a run goes on, so no client is trusted to have checked it. Nothing in a form runs as code: its functions are this package's catalog, by name.

Index

Constants

View Source
const CatalogID = "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json"

CatalogID is the basic catalog's, whose components and functions forms use.

View Source
const Version = "v0.9"

Version is the A2UI version the messages carry.

Variables

This section is empty.

Functions

func GetPath

func GetPath(data any, path string) any

GetPath is the value at a JSON Pointer path, or nil.

func Resolve

func Resolve(v any, data map[string]any, scope string) any

Resolve is a dynamic value: a literal, {path} in the data (relative to a template's item), or {call} of one of the catalog's functions.

func Scoped

func Scoped(path, scope string) string

Scoped is a path relative to a template's item (name in the item at /items/2 is /items/2/name); an absolute path stays as it is.

func SetPath

func SetPath(data map[string]any, path string, value any) map[string]any

SetPath is data with value at path (copied along the way).

Types

type Action

type Action struct {
	Name              string         `json:"name"`
	SurfaceID         string         `json:"surfaceId"`
	SourceComponentID string         `json:"sourceComponentId"`
	Timestamp         string         `json:"timestamp"`
	Context           map[string]any `json:"context"`
}

Action is a client's answer: A2UI's action message, from a button.

func ParseAction

func ParseAction(raw []byte) (Action, error)

ParseAction reads a client-to-server message ({"version": "v0.9", "action": {...}}); an error message, or anything else, is an error.

type Form

type Form struct {
	Components []map[string]any `json:"components" yaml:"components"`
	Data       map[string]any   `json:"data,omitempty" yaml:"data,omitempty"`
}

Form is a surface's components (a flat list, one with the id root) and its data model.

func FormOf

func FormOf(messages []map[string]any) (Form, string, error)

FormOf reads a surface's form back from its messages (the last components and the whole model they set; a path's update is applied). It is test support: the round-trip check of Messages, here and in pkg/service/server's tests (the page parses forms itself).

func (Form) Answer

func (f Form) Answer(a Action, data map[string]any) (map[string]any, []Problem)

Answer checks an action against the form it answers and returns the answer a run gets: the action's name as "action", with its context's values. data is the surface's data model as the client had it (nil: the form's own, with the context's bound values put back): every component's checks must pass on it, the button's context must be what it resolves to, and the button must be one of the form's, with that action, and its own checks passing.

func (Form) HasRoot

func (f Form) HasRoot() bool

HasRoot reports whether a component has the id root.

func (Form) Messages

func (f Form) Messages(surfaceID string) []map[string]any

Messages is the form as A2UI's server-to-client messages for a surface: createSurface, updateComponents and updateDataModel (the whole model).

func (Form) Problems

func (f Form) Problems(data map[string]any) []Problem

Problems is every failing check of the components shown (from root, templates over the data's lists included), in the order they're drawn.

type Problem

type Problem struct {
	Component string `json:"component,omitempty"`
	Message   string `json:"message"`
}

Problem is why an answer isn't accepted: a component's failing check, or what's wrong with the action itself (Component empty).

func (Problem) String

func (p Problem) String() string

String is the problem as a line: the component, then the message.

Jump to

Keyboard shortcuts

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