@khanglvm/relay 0.17.1 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,6 +37,8 @@ rly diff --staged
37
37
  - Source files and diffs, including commit choices and merge conflicts.
38
38
  - Questions with choices, notes, and other form controls.
39
39
 
40
+ - Small live widgets such as status lists, numbers, progress bars and buttons, written in [A2UI](docs/A2UI.md).
41
+
40
42
  Answers and comments autosave. To stop a board, run `rly list` to find its
41
43
  ID, then `rly stop <board-id>`.
42
44
 
@@ -60,9 +62,17 @@ to collect answers. On timeout, check `rly result <board-id>` before continuing.
60
62
  To make this a standing preference, `rly install --target codex` adds Relay
61
63
  rules to Codex's instruction file. Run `rly install` to see other targets.
62
64
 
65
+ ## Open a board on your phone
66
+
67
+ If the `devlink` command is installed, `rly ask --file spec.json --detach --devlink`
68
+ prints a private https URL that works on other devices. Any https URL that reaches the
69
+ board works too: `--public-url 'https://host:{port}'`. Run `rly config link devlink` to make
70
+ it the default. The details are in the [agent guide](docs/AGENT.md).
71
+
63
72
  ## More help
64
73
 
65
74
  - [Setup and MCP Apps](docs/SETUP.md): agent configuration, in-chat boards, sharing, and updates.
75
+ - [A2UI widgets](docs/A2UI.md): the `a2ui` block, also available as `rly a2ui`.
66
76
  - [Agent guide](docs/AGENT.md): board examples, block types, and JSON schemas; also available as `rly agent`.
67
77
  - `rly help` lists commands. `rly upgrade` updates the CLI and skill.
68
78
  - [Changelog](CHANGELOG.md) · [MIT license](LICENSE)
package/docs/A2UI.md ADDED
@@ -0,0 +1,221 @@
1
+ # A2UI widgets in Relay
2
+
3
+ An `a2ui` block puts a small live widget on a board: a status list, a few numbers, a progress bar, or a short form with buttons. Write it in A2UI Express. Relay compiles the text with the official A2UI agent SDK against Relay's own catalog and draws it with its own renderer.
4
+
5
+ Use a widget for state and quick actions. Use the board's question blocks (`single`, `multi`, `text`) for any answer you depend on, because those come back in `result.answers` with notes and comments. A widget never replaces a question you must have answered.
6
+
7
+ ## Add one to a board
8
+
9
+ ```json
10
+ {
11
+ "title": "Release checks",
12
+ "blocks": [
13
+ {
14
+ "id": "checks",
15
+ "type": "a2ui",
16
+ "title": "Release checks",
17
+ "express": "$/runs = [{title: \"Build\", trailing: \"2m\", tone: \"ok\"}, {title: \"E2E\", trailing: \"failed\", tone: \"error\"}]\nroot = Card(\"Release checks\", [List($/runs), Button(\"Retry E2E\", action=Event(\"retry\", {job: \"e2e\"}))])"
18
+ }
19
+ ],
20
+ "questions": [
21
+ { "id": "go", "type": "yesno", "label": "Ship after the retry?" }
22
+ ]
23
+ }
24
+ ```
25
+
26
+ Send `components` (a flat A2UI v1.0 component list with a `dataModel`) instead of `express` when you already hold JSON. Give exactly one of the two. `height` (pixels) limits the block's height.
27
+
28
+ ## What comes back
29
+
30
+ The person's clicks and input values are part of the board result, under `result.blockEdits[blockId]`:
31
+
32
+ ```json
33
+ { "type": "a2ui", "data": { "note": "via phone" }, "events": [{ "name": "retry", "context": { "job": "e2e" }, "at": "2026-11-22T10:15:00.000Z" }] }
34
+ ```
35
+
36
+ - `data` is the widget's data model with the current value of every input.
37
+ - `events` lists each button press in order. Name an event for what the person decided (`approve`, `retry`), and put the values you need into its context.
38
+ - Clicks are recorded in the draft and sent with the board when the person submits. A button does not submit the board.
39
+
40
+ ## Rules for good widgets
41
+
42
+ - One widget, one purpose. At most 60 components, 64 KB of data, 12 levels deep. Put the state first.
43
+ - The root is a `Card`. State is a tone: `ok`, `info`, `warn`, `error` or `needs` (the person has to act). Never name a colour.
44
+ - Text is drawn as text. Markup, HTML and script in a string are shown as written, never run. Links open only when they are https URLs.
45
+ - Bind with `$/path`. Paths with `__proto__`, `constructor` or `prototype` segments are refused at compile time.
46
+ - The grammar below says to wrap Express in `<a2ui>` tags. In a Relay spec, leave the tags out: the `express` field holds the Express text alone.
47
+ - Run `rly ask --file spec.json --detach` as usual: a spec with an invalid widget fails before the board opens, with the compiler's message.
48
+
49
+
50
+ The rest of this page comes from the A2UI agent SDK, generated from Relay's catalog (`src/a2ui/catalog.json`) and examples (`src/a2ui/examples.json`).
51
+
52
+ # A2UI Express DSL Output Contract
53
+
54
+ You must output the user interface using A2UI Express.
55
+
56
+ IMPORTANT: You MUST always surround the entire A2UI Express block with the literal sentinel tags `<a2ui>` and `</a2ui>` (always include both the opening and closing tags; do NOT wrap the tags in backticks or replace the opening tag with a markdown code fence such as ```a2ui).
57
+
58
+ The host compiler will compile your A2UI Express output into the correct JSON envelopes automatically.
59
+
60
+ ## Grammar Rules
61
+
62
+ 1. Component constructors can be assigned to variables or nested inline inside parent component arguments:
63
+ header = ComponentA(prop1="val1")
64
+ root = ComponentB([header, ComponentC("Click", action=Event("submit"))])
65
+
66
+ Keyword arguments (`param=value`) and positional arguments with `_` placeholders are supported.
67
+
68
+ Variable names MUST start with a letter or underscore, and only contain letters, digits, and underscores.
69
+
70
+ 2. The interface tree must have a single entry point assigned to the reserved variable 'root'.
71
+
72
+ 3. Primitives:
73
+ - Strings: Quoted with `"` or `"""`. Support for `\n`, `\t`, `\\`, and `\"` escapes.
74
+ Raw Strings: Prefaced by `r` (e.g., `r"..."` or `r"""..."""`), with no escape processing.
75
+ - Numbers: write as integers or decimals, e.g., 42
76
+ - Booleans: write true or false
77
+ - Null values: write null
78
+ - Dates & Times: Values for date-time inputs (e.g. in DateTimeInput) must strictly use RFC 3339 format with a timezone offset (e.g. "2026-03-14T00:00:00Z").
79
+
80
+ 4. Lists: represent as arrays, e.g., [child1, child2].
81
+
82
+ 5. Maps: represent as key-value blocks, e.g., {title: "Overview", child: contentCol}. Map keys are always literal strings (dynamic variable resolution is not supported for keys).
83
+
84
+ 6. Data bindings: prefix absolute paths in the data model with '$', e.g., $/user/firstName.
85
+ Prefix relative list scopes with '$', e.g., $firstName.
86
+ A lone '$' represents an empty relative path which resolves to the root of the current context (e.g. inside a template, representing the entire item itself).
87
+
88
+ 7. Logic and validation: prefix client check rules with '?', e.g., ?required or ?regex("^[0-9]{5}$"). To specify a custom error message for validation failures, append it as an extra string argument, e.g. ?regex("^[0-9]{5}$", "Postal code must be 5 digits").
89
+
90
+ 8. Action events: represent server-side actions using the Event helper:
91
+ Event("save_deal", {rep: $/form/rep})
92
+
93
+ 9. Nested functions: call client functions directly using catalog signatures, for example myFunction("value").
94
+
95
+ 10. Data model population: Assign a value directly to an absolute data path (e.g. $/path/to/key = "value") to populate or initialize values inside the shared dataModel. The value can be a primitive, array, or map.
96
+
97
+ 11. Dynamic list templates: If a component expects a template child list, represent it using the _template helper:
98
+ _template($/path/to/list, itemTemplate)
99
+ And define the template component variable on another line, utilizing relative path references prefixed with $:
100
+ itemTemplate = Image($url)
101
+
102
+ 12. To delete a user interface surface, output the standalone `deleteSurface(surfaceId)` command (no variable assignment):
103
+ deleteSurface("dashboard-surface-1")
104
+
105
+ 13. Static properties: Arguments annotated with '(static)' in the signatures below MUST be defined as literal values or arrays inline. You CANNOT use a dynamic data binding path (prefixed by $) for these arguments.
106
+
107
+ 14. Required actions: Parameters named 'action' (or annotated in component signatures) are strictly required. You must pass a valid Event (e.g. Event("click")) or function call. If no specific action is described in the user request, you must provide a dummy click event like Event("click") instead of passing null or omitting the parameter.
108
+
109
+ 15. Surface targeting: Output `surface(surfaceId)` to specify or target a user interface surface:
110
+ surface("dashboard-surface-1")
111
+ root = Card(...)
112
+
113
+ ## Positional Component Signatures
114
+
115
+ Use these exact positional signatures to instantiate components. Do not output property keys:
116
+ • Button(label, action (static), style? (static))
117
+ - Description: A button. `Event(name, context)` sends the click back to the agent in the board's answer, with the current values of the inputs on the card; `openUrl` opens an https link.
118
+ - style: Must be one of: 'primary', 'plain'
119
+ • Card(title, children)
120
+ - Description: The root of a board widget (id `root`): an optional title and its children. Use it for the one widget a board shows.
121
+ • Code(code, language? (static))
122
+ - Description: A code block, shown as text.
123
+ • Divider()
124
+ - Description: A hairline between sections.
125
+ • Grid(columns (static), children, gap? (static))
126
+ - Description: Equal-width columns, filled row by row. On a phone, 3 or 4 columns drop to 2.
127
+ - gap: Must be one of: 'xs', 'sm', 'md', 'lg'
128
+ • Icon(name (static), label, tone? (static))
129
+ - Description: One icon from a fixed set. `label` is what a screen reader says.
130
+ - name: Must be one of: 'check', 'alert', 'info', 'x', 'clock', 'file', 'folder', 'git-branch', 'play', 'star', 'link', 'user', 'bell', 'lock'
131
+ - tone: Must be one of: 'info', 'ok', 'warn', 'error', 'needs'
132
+ • Image(url (static), alt)
133
+ - Description: A picture from an https address.
134
+ • List(items, max? (static))
135
+ - Description: Rows of things with a state: a title, an optional subtitle and trailing value, a tone pill and an optional https link.
136
+ - items: Array of {title, subtitle?, trailing?, tone?, url?}, usually bound to a data-model path.
137
+ - max: Rows shown before `N more`.
138
+ • Metric(label, value, note?)
139
+ - Description: One number with a label and an optional note.
140
+ • Pill(text, tone (static))
141
+ - Description: A short state word in a tone.
142
+ - tone: `ok` done or healthy, `info` in progress, `warn` slipping, `error` failed, `needs` the person must act. Must be one of: 'info', 'ok', 'warn', 'error', 'needs'
143
+ • Progress(label, value, total, note?, tone? (static))
144
+ - Description: A bar with `value` of `total`, a label and an optional note.
145
+ - tone: Must be one of: 'info', 'ok', 'warn', 'error'
146
+ • Select(label, path (static), options (static))
147
+ - Description: A pick-one input bound to `path`; the value is the picked option's `key`.
148
+ - options: List of maps with keys:
149
+ * key
150
+ * label
151
+ • Slider(label, path (static), min (static), max (static), step? (static))
152
+ - Description: A number input bound to `path` between `min` and `max`.
153
+ • Stack(direction (static), children, gap? (static), align? (static))
154
+ - Description: Lays children out in a row or a column.
155
+ - direction: Must be one of: 'row', 'column'
156
+ - gap: Space between children: xs 4, sm 8 (default), md 12 or lg 16 pixels. Must be one of: 'xs', 'sm', 'md', 'lg'
157
+ - align: Must be one of: 'start', 'center', 'end', 'stretch'
158
+ • Table(columns (static), rows, max? (static))
159
+ - Description: Rows under typed columns.
160
+ - columns: List of maps with keys:
161
+ * key
162
+ * label
163
+ - rows: Array of objects keyed by column `key`.
164
+ • Text(text, variant? (static))
165
+ - Description: Plain prose, never markup. `title` is a heading for the widget's sections, `muted` a quiet note.
166
+ - variant: Must be one of: 'body', 'title', 'muted'
167
+ • TextField(label, path (static), placeholder?, multiline? (static))
168
+ - Description: A text input bound to the data model at `path`. Its value comes back in the board's answer.
169
+ • Toggle(label, path (static))
170
+ - Description: An on/off input bound to `path`.
171
+
172
+ ## Positional Function Signatures
173
+
174
+ Use these exact positional signatures to instantiate check rules or logic functions:
175
+ • openUrl(url)
176
+ - Description: Opens an https link in a new tab.
177
+
178
+ ## Catalog Instructions
179
+
180
+ One surface is one widget. The root is always a Card (id `root`). Keep it small: at most 60 components, one question per widget. State is a tone (`ok`, `info`, `warn`, `error`, `needs`), never a colour word. Put values in the data model with `$/path = value` lines and bind components to them. A Button's `Event(name, {key: value})` comes back to you in `result.blockEdits[blockId]`, with the values of every input on the card, so name the events for what the person decided (`approve`, `retry`). Use `openUrl` for links. Never put markup in a string: text is drawn as text. Use the board's own question blocks for anything the answer depends on; an A2UI widget is for state, quick actions and small forms.
181
+
182
+ ### Examples:
183
+
184
+ Status list: things with a state, one row each. The tone carries the state, `trailing` the short word, `url` opens the thing. Rows that need the person come first; the Button reports the decision.
185
+
186
+ <a2ui>
187
+ surface("example")
188
+ $/runs = [{title: "Deploy staging", subtitle: "waiting on your approval", tone: "needs"}, {title: "Build 412", subtitle: "main, 2 minutes ago", trailing: "Passed", tone: "ok", url: "https://ci.example.com/runs/412"}, {title: "Lint", trailing: "3 warnings", tone: "warn"}]
189
+ root = Card("Release checks", [root_children_0, root_children_1])
190
+ root_children_0 = List($/runs, 5)
191
+ root_children_1 = Stack("row", [root_children_1_children_0, root_children_1_children_1])
192
+ root_children_1_children_0 = Button("Approve", Event("approve"), "primary")
193
+ root_children_1_children_1 = Button("Hold", Event("hold"))
194
+ </a2ui>
195
+
196
+ Numbers and progress: two headline numbers side by side, then one bar against a goal.
197
+
198
+ <a2ui>
199
+ surface("example")
200
+ $/shipped = 31
201
+ $/target = 50
202
+ root = Card("Orders this week", [root_children_0, root_children_1])
203
+ root_children_0 = Grid(2, [root_children_0_children_0, root_children_0_children_1])
204
+ root_children_0_children_0 = Metric("Shipped", "31")
205
+ root_children_0_children_1 = Metric("Late", "4", "was 1")
206
+ root_children_1 = Progress("Shipped", $/shipped, $/target, "8 packing")
207
+ </a2ui>
208
+
209
+ Small form: inputs bound to the data model; the Button sends their values back with the event.
210
+
211
+ <a2ui>
212
+ surface("example")
213
+ $/dry = true
214
+ $/env = "staging"
215
+ $/note = ""
216
+ root = Card("Deploy", [root_children_0, root_children_1, root_children_2, root_children_3])
217
+ root_children_0 = Select("Environment", "/env", [{key: "staging", label: "Staging"}, {key: "prod", label: "Production"}])
218
+ root_children_1 = Toggle("Dry run", "/dry")
219
+ root_children_2 = TextField("Note", "/note", _, true)
220
+ root_children_3 = Button("Deploy", Event("deploy", {env: $/env, dry: $/dry, note: $/note}), "primary")
221
+ </a2ui>
package/docs/AGENT.md CHANGED
@@ -87,6 +87,39 @@ links, or submit. Collaborators retain owner-authorized edit/comment/final-submi
87
87
  permission. Active links keep the same token across a same-port
88
88
  `rly reopen`/`rly rescue` until revoked.
89
89
 
90
+ ## A private URL for other devices
91
+
92
+ A board listens on this machine. To open it from a phone or another computer
93
+ without Wi-Fi sharing, give it a link setting. `rly ask`, `rly show`, `rly view`
94
+ and `rly diff` accept:
95
+
96
+ ```sh
97
+ rly ask --file spec.json --detach --devlink # publish through devlink
98
+ rly ask --file spec.json --detach --public-url 'https://boards.example.com:{port}'
99
+ rly config link devlink # make it the default (also: auto, off, or a URL)
100
+ ```
101
+
102
+ - `--devlink` runs `devlink --json internal PORT`, requires a private https URL
103
+ back, and prints it as the board `url` (with a collaborator token). It stops
104
+ with an error if `devlink` is missing or fails. Relay finds it through
105
+ `RLY_DEVLINK_BIN`, then `PATH`, then `~/.local/bin/devlink`.
106
+ - `auto` does the same when `devlink` is installed and keeps the board local when
107
+ it is not. `off` (the default) never publishes.
108
+ - `--public-url` takes any https URL that reaches the board's port, such as a
109
+ reverse proxy or tunnel you run. `{port}` becomes the board port. Loopback
110
+ hosts are refused. `RLY_PUBLIC_URL` and `RLY_LINK` set the same from the
111
+ environment; `--no-devlink` turns it off for one run.
112
+ - Precedence: `--no-devlink`, `--devlink`, `--public-url`, `RLY_PUBLIC_URL`,
113
+ `RLY_LINK`, `rly config link`, then off.
114
+ - Answers return as usual: `rly wait <id>` and `rly result <id>`.
115
+ - When the board closes, Relay removes the devlink route again.
116
+
117
+ Report the printed URL to the user and never a `localhost`, `127.0.0.1` or
118
+ `0.0.0.0` address. A published board is reachable by whoever can reach the
119
+ link, and devlink's gateway makes every request look local to the board, so the
120
+ token in the URL and the network behind the link (Tailscale for devlink) are the
121
+ access control. Use `rly share <id> --revoke --all` to cut access.
122
+
90
123
  ## Inline mode — relay as an MCP App (Claude & Codex apps)
91
124
 
92
125
  Everything above is the **CLI** surface (you run `rly` in a terminal and read
@@ -543,6 +576,7 @@ the question-types section above.
543
576
  | `kpi` | big-number metric cards (`items:[{label,value,delta?,dir?,sub?}]`) with up/down/flat-tinted deltas — at-a-glance numbers without a chart |
544
577
  | `typography` | type specimens (`specimens:[{label?,size?,weight?,font?,text?}]`) — react to type choices like a palette |
545
578
  | `compare` | before/after images with a draggable divider (`before`/`after` = url/path/`{src,label}`); area comments preserve which side was selected |
579
+ | `a2ui` | a small live widget: status list, numbers, progress, quick-action buttons, a short form. Written in A2UI Express; the clicks and input values come back in `result.blockEdits[blockId]`. Full grammar and examples: `rly a2ui` (docs/A2UI.md) |
546
580
  | `html` | anything else — pixel-perfect mockups, custom widgets, embeds |
547
581
 
548
582
  Two cross-block fields work on **any** block: `"ref":"name"` makes it openable in
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@khanglvm/relay",
3
- "version": "0.17.1",
4
- "description": "Question boards with rich blocks (markdown, charts, mermaid, tables, code, diffs, video, sandboxed HTML), clickable local file-links, and element-level annotations for AI coding agents (Claude Code, Codex, …): ask users structured questions, present interactive visuals, collect inline comments, read answers as JSON — in a local browser board OR rendered INLINE inside the Claude & Codex apps as an MCP App (SEP-1865).",
3
+ "version": "0.19.0",
4
+ "description": "Question boards with rich blocks (markdown, charts, mermaid, tables, code, diffs, video, sandboxed HTML), clickable local file-links, and element-level annotations for AI coding agents (Claude Code, Codex, \u2026): ask users structured questions, present interactive visuals, collect inline comments, read answers as JSON \u2014 in a local browser board OR rendered INLINE inside the Claude & Codex apps as an MCP App (SEP-1865).",
5
5
  "keywords": [
6
6
  "ai-agents",
7
7
  "claude-code",
@@ -39,6 +39,8 @@
39
39
  "skills",
40
40
  "docs",
41
41
  "!docs/assets",
42
+ "schema",
43
+ "types",
42
44
  "README.md",
43
45
  "LICENSE"
44
46
  ],
@@ -46,6 +48,39 @@
46
48
  "node": ">=18.3"
47
49
  },
48
50
  "scripts": {
49
- "test": "node test/smoke.mjs"
50
- }
51
+ "check": "tsc -p tsconfig.json",
52
+ "lint": "biome ci --diagnostic-level=error .",
53
+ "gen:schema": "node scripts/gen-schema.mjs --write",
54
+ "build:types": "tsc -p tsconfig.build.json",
55
+ "test": "node test/smoke.mjs && node --test test/link.test.mjs test/a2ui.test.mjs test/unit/*.test.mjs",
56
+ "smoke:pack": "node scripts/smoke-pack.mjs",
57
+ "prepack": "npm run build:types"
58
+ },
59
+ "devDependencies": {
60
+ "@biomejs/biome": "^2.6.8",
61
+ "@types/node": "^20.19.43",
62
+ "typescript": "^7.0.2"
63
+ },
64
+ "exports": {
65
+ ".": {
66
+ "types": "./types/index.d.ts",
67
+ "default": "./src/index.js"
68
+ },
69
+ "./spec": {
70
+ "types": "./types/spec.d.ts",
71
+ "default": "./src/spec.js"
72
+ },
73
+ "./a2ui": {
74
+ "types": "./types/a2ui/compile.d.ts",
75
+ "default": "./src/a2ui/compile.js"
76
+ },
77
+ "./mcp": {
78
+ "types": "./types/mcp.d.ts",
79
+ "default": "./src/mcp.js"
80
+ },
81
+ "./schema.json": "./schema/spec.v1.json",
82
+ "./package.json": "./package.json"
83
+ },
84
+ "main": "./src/index.js",
85
+ "types": "./types/index.d.ts"
51
86
  }