Complete type definitions for the widget system.
Widget (Container)
The root container for all widgets.
typescript
1interface Widget {2 type: "ui" | "html";3 interactive?: boolean;4 title?: string;5 html?: string; // For type="html"6 json?: string; // Original JSON for reference7 children?: WidgetNode[];8 actions?: WidgetActionButton[];9}Properties
| Name | Type | Description | Default |
|---|---|---|---|
type | "ui" | "html" | Widget type - structured UI or raw HTML | required |
interactive | boolean | Whether the widget accepts user input | false |
title | string | Optional title displayed above the widget | - |
html | string | Raw HTML content (for type="html") | - |
children | WidgetNode[] | Child nodes to render (for type="ui") | - |
actions | WidgetActionButton[] | Action buttons in the footer | - |
WidgetNode
A single UI component within a widget.
typescript
1interface WidgetNode {2 type: WidgetNodeType;3 4 // Content5 value?: string;6 label?: string;7 8 // Image9 src?: string;10 alt?: string;11 12 // Form fields13 name?: string;14 placeholder?: string;15 defaultValue?: string;16 defaultChecked?: boolean;17 options?: WidgetSelectOption[];18 19 // Styling20 variant?: string;21 gap?: number;22 23 // Layout24 children?: WidgetNode[];25 26 // Actions27 action?: WidgetAction;28 29 // Data binding (advanced)30 dataKey?: string;31}Node Types
Primitive Types (render literal values)
| Type | Description |
|---|---|
text | Plain text display |
markdown | Markdown-formatted text |
image | Image display |
badge | Small label for status/metadata |
button | Action button |
input | Text input field |
select | Dropdown select |
checkbox | Binary checkbox |
row | Horizontal layout container |
col | Vertical layout container |
Data-Bound Types (read from ToolInvocation.Data)
| Type | Description |
|---|---|
plan-list | Renders plan steps from Data |
key-value | Renders key-value pairs from Data |
status-badge | Renders status badge from Data |
WidgetAction
Represents an action triggered by user interaction.
typescript
1interface WidgetAction {2 type: string;3 payload?: Record<string, any>;4}Properties
| Name | Type | Description |
|---|---|---|
type | string | Action type identifier (e.g., "confirm", "cancel", "submit") |
payload | object | Optional data to send with the action |
WidgetActionButton
A button in the widget's action bar.
typescript
1interface WidgetActionButton {2 label: string;3 action: WidgetAction;4 variant?: "default" | "secondary" | "outline" | "ghost" | "destructive";5}Properties
| Name | Type | Description | Default |
|---|---|---|---|
label | string | Button text | required |
action | WidgetAction | Action to trigger on click | required |
variant | string | Visual style variant | "default" |
WidgetSelectOption
An option in a select dropdown.
typescript
1interface WidgetSelectOption {2 label: string;3 value: string;4}Go Types
The Go SDK provides equivalent types in inference.sh/common-go/pkg/models:
go
1// Widget types2const (3 WidgetTypeUI = "ui"4 WidgetTypeHTML = "html"5)6 7// Node types8const (9 WidgetNodeTypeText WidgetNodeType = "text"10 WidgetNodeTypeMarkdown WidgetNodeType = "markdown"11 WidgetNodeTypeImage WidgetNodeType = "image"12 WidgetNodeTypeBadge WidgetNodeType = "badge"13 WidgetNodeTypeButton WidgetNodeType = "button"14 WidgetNodeTypeInput WidgetNodeType = "input"15 WidgetNodeTypeSelect WidgetNodeType = "select"16 WidgetNodeTypeCheckbox WidgetNodeType = "checkbox"17 WidgetNodeTypeRow WidgetNodeType = "row"18 WidgetNodeTypeCol WidgetNodeType = "col"19)