Documentation
¶
Overview ¶
Package widgets defines the versioned output contract of the in-app agent: a response is an ordered list of typed widgets any client (the admin SPA or a third-party renderer) can render consistently. The set is closed — agents never emit free-form markup — and validation degrades anything malformed to a markdown widget, so a bad payload can never break a response. See docs/_reference/agent-widgets.md for the contract with examples.
Index ¶
Constants ¶
const SchemaVersion = 1
SchemaVersion is the contract version carried on every response. Clients should render unknown widget types of future versions as markdown.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Response ¶
Response is what the in-app agent returns for a turn: widgets in render order.
func Parse ¶
Parse turns an agent's raw output into a valid Response. It accepts the contract JSON (optionally wrapped in a markdown code fence, which models sometimes add) and degrades gracefully: output that isn't contract JSON becomes one markdown widget, and any individual widget that fails validation is replaced by a markdown widget carrying its raw JSON. Parse never fails and never returns an empty response for non-empty input.
type Widget ¶
type Widget struct {
Type Type `json:"type"`
// Markdown carries the body of a markdown widget.
Markdown string `json:"markdown,omitempty"`
// Title captions a table, list, or card.
Title string `json:"title,omitempty"`
// Columns and Rows shape a table; every row has one cell per column.
Columns []string `json:"columns,omitempty"`
Rows [][]string `json:"rows,omitempty"`
// Items are the entries of a list widget.
Items []string `json:"items,omitempty"`
// Body, URL, and Fields belong to a card widget.
Body string `json:"body,omitempty"`
URL string `json:"url,omitempty"`
Fields []Field `json:"fields,omitempty"`
}
Widget is one renderable block. Only the fields for its Type are set.