@khanglvm/relay 0.21.0 → 0.22.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.
Files changed (49) hide show
  1. package/docs/AGENT.md +14 -2
  2. package/package.json +6 -1
  3. package/schema/spec.v1.json +55 -3
  4. package/skills/relay/SKILL.md +2 -1
  5. package/src/a2ui/board-catalog.json +1004 -0
  6. package/src/a2ui/board-constants.js +35 -0
  7. package/src/a2ui/board.js +5 -0
  8. package/src/a2ui/from-a2ui.js +71 -0
  9. package/src/a2ui/negotiate.js +38 -0
  10. package/src/a2ui/to-a2ui.js +147 -0
  11. package/src/cli/args.js +1 -1
  12. package/src/cli/help.js +2 -1
  13. package/src/cli/mcp.js +19 -1
  14. package/src/mcp/boards.js +26 -4
  15. package/src/mcp/constants.js +3 -1
  16. package/src/mcp/schemas.js +5 -2
  17. package/src/mcp/server.js +2 -1
  18. package/src/mcp/token.js +33 -8
  19. package/src/mcp/tools.js +14 -6
  20. package/src/mcp-ui/board/normalize.js +12 -0
  21. package/src/mcp-ui/board/render.js +2 -1
  22. package/src/mcp-ui/board/state.js +3 -0
  23. package/src/server/board.js +12 -9
  24. package/src/server/http.js +19 -0
  25. package/src/server/page.js +4 -0
  26. package/src/spec/constants.js +13 -1
  27. package/src/spec/index.js +1 -0
  28. package/src/spec/lookup.js +1 -0
  29. package/src/spec/normalize.js +3 -0
  30. package/src/spec/pick.js +104 -0
  31. package/src/spec/schema.js +26 -3
  32. package/src/ui/app/drafts.js +3 -0
  33. package/src/ui/app/render.js +1 -0
  34. package/src/ui/app/submit.js +1 -1
  35. package/src/ui/manifest.js +2 -1
  36. package/src/ui/pick.css +32 -0
  37. package/src/ui/pick.js +246 -0
  38. package/types/a2ui/board-constants.d.ts +24 -0
  39. package/types/a2ui/from-a2ui.d.ts +16 -0
  40. package/types/a2ui/negotiate.d.ts +17 -0
  41. package/types/a2ui/to-a2ui.d.ts +12 -0
  42. package/types/mcp/boards.d.ts +11 -1
  43. package/types/mcp/schemas.d.ts +5 -2
  44. package/types/mcp/token.d.ts +5 -1
  45. package/types/spec/constants.d.ts +9 -0
  46. package/types/spec/index.d.ts +1 -0
  47. package/types/spec/lookup.d.ts +2 -1
  48. package/types/spec/pick.d.ts +25 -0
  49. package/types/spec/schema.d.ts +48 -0
package/docs/AGENT.md CHANGED
@@ -53,6 +53,7 @@ stderr. Exit codes: `0` submitted/acknowledged · `2` timeout · `3` cancelled
53
53
  {"id":"signoff","type":"checklist","label":"Sign off each area","options":["login","billing"]} // pass/fail/N-A per item: one checklist, not many yes/no
54
54
  {"id":"rank","type":"rank","label":"Priorities","options":["speed","a11y"]} {"id":"split","type":"allocate","label":"Budget","total":100,"options":["type","space"]}
55
55
  {"id":"c","type":"single","label":"Scheme?","options":[{"value":"warm","label":"Warm","blocks":[{"type":"html","html":"<div style='height:100%;background:#c2674b'></div>","height":140}]}]} // a visual per option
56
+ {"id":"hero","type":"pick","label":"Shortlist two","max":2,"items":[{"id":"a","title":"Warm","image":"/abs/a.png","caption":"Terracotta"},{"id":"b","title":"Demo","video":"https://example.com/b.mp4"},{"id":"c","title":"Ref","url":"https://example.com/c"}]} // media tiles; answer {picks:[{id,note?}],overall?}; max 1 = single, min/max bound a multi
56
57
  {"id":"s","type":"scale","label":"Rate","min":1,"max":5} {"id":"col","type":"color","label":"Brand color"} {"id":"ship","type":"yesno","label":"Ship?"}
57
58
  ```
58
59
  Buttons inside a2ui do not replace a question. Their clicks return in `blockEdits`.
@@ -147,7 +148,9 @@ Tools:
147
148
 
148
149
  The flow: call `relay_board`, tell the person the board is on screen, and carry on or wait. When they submit, the host posts a one-line message naming the board. Read the answers with `relay_result`. Do not ask the same questions again in chat.
149
150
 
150
- `rly mcp` speaks stdio to a local desktop host. `rly mcp --http [--port N] [--token SECRET] [--allow-origin ORIGIN]` serves Streamable HTTP at `/mcp` for hosts that connect over a network; `RLY_MCP_TOKEN` sets the bearer token. Boards are stored in the relay home of the machine that runs the server, so `codeFile` and local images resolve there and nowhere else. To add the tools to a server you already run, call `registerRelay(server, {store, assetUrl, linkUrl})` from `@khanglvm/relay/mcp`.
151
+ `rly mcp` speaks stdio to a local desktop host. `rly mcp --http [--port N] [--token-file PATH] [--allow-origin ORIGIN]` serves Streamable HTTP at `/mcp` for hosts that connect over a network. The bearer token comes from `--token-file`, `RLY_MCP_TOKEN` or `--token`; the flag shows in `ps`, so prefer the file or the variable. Boards are stored in the relay home of the machine that runs the server, so `codeFile` and local images resolve there and nowhere else. A host that draws A2UI can show the whole board natively instead of the iframe. It declares the board catalog, `https://github.com/khanglvm/relay/a2ui/catalog/board/v1`, under `extensions.a2ui["1.0"].supportedCatalogIds` when it connects, or per call in `_meta.a2ui`; the call wins over the connection. `relay_view` then returns the board as A2UI messages (`application/a2ui+json`, `application/json+a2ui` is accepted when declared) and the host sends button events to `a2ui_action` with the surface's data model. The catalog is `src/a2ui/board-catalog.json`; `toA2ui(spec)` and `fromA2ui(dataModel, spec)` from `@khanglvm/relay/a2ui-board` convert in both directions, and the result matches what the web board stores. Hosts that did not declare it keep the iframe.
152
+
153
+ To add the tools to a server you already run, call `registerRelay(server, {store, assetUrl, linkUrl})` from `@khanglvm/relay/mcp`.
151
154
 
152
155
  If the host streams the tool call as you write it, the board renders valid blocks and questions as they arrive and finishes when your call completes.
153
156
 
@@ -274,6 +277,7 @@ choices plus the full resolved file in `result.blockEdits[blockId]`:
274
277
  | `rank` | `["b","a","c"]` — ordered option values, highest priority first |
275
278
  | `checklist`| `{ "login":"pass", "checkout":"fail" }` — per-item status map |
276
279
  | `allocate` | `{ "eng":50, "design":30, "ops":20 }` — budget distributed across options |
280
+ | `pick` | `{ "picks":[{"id":"a","note":"why"}], "overall":"…" }` — tiles in the order picked |
277
281
 
278
282
  `rank` renders the `options` as a reorderable list (drag or ↑/↓ buttons); the
279
283
  user prioritizes them and the answer is the ordered array of values. Needs ≥2
@@ -287,10 +291,18 @@ distributes a budget (`"total"`, default 100) across the options with sliders +
287
291
  a live total bar; answer is `{optionValue: number}`. Both take per-option
288
292
  `description`/`blocks` like single/multi.
289
293
 
294
+ `pick` shows media tiles to choose from. `items` are tiles: a string, or
295
+ `{id, title, caption?, image?, video?, url?}`, where `image` is a path or an
296
+ https URL, `video` plays as a muted preview when it is a file and opens as a
297
+ link otherwise, and `url` opens the page. `max` caps the picks (1 makes it a
298
+ single choice), `min` above 0 makes it required, and `itemNote:false` or
299
+ `overall:false` hide the per-tile and overall notes. Unknown ids are dropped
300
+ and the list is cut to `max`. Up to 60 tiles.
301
+
290
302
  Aliases accepted: radio/choice/select→single, checkbox→multi,
291
303
  boolean/bool/yn→yesno, input→text, longtext→textarea, rating/likert→scale,
292
304
  colour/swatch→color, ranking/order/ordering/prioritize/sort→rank,
293
- signoff/qa→checklist, budget/distribute/points→allocate.
305
+ signoff/qa→checklist, budget/distribute/points→allocate, tiles/gallery/shortlist→pick.
294
306
 
295
307
  ### Result JSON (stdout)
296
308
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanglvm/relay",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
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",
@@ -57,6 +57,7 @@
57
57
  "prepack": "npm run build:types"
58
58
  },
59
59
  "devDependencies": {
60
+ "@a2ui/web_core": "^0.15.0",
60
61
  "@biomejs/biome": "^2.6.8",
61
62
  "@modelcontextprotocol/client": "^2.4.0",
62
63
  "@types/node": "^20.19.43",
@@ -75,6 +76,10 @@
75
76
  "types": "./types/a2ui/compile.d.ts",
76
77
  "default": "./src/a2ui/compile.js"
77
78
  },
79
+ "./a2ui-board": {
80
+ "types": "./types/a2ui/board.d.ts",
81
+ "default": "./src/a2ui/board.js"
82
+ },
78
83
  "./mcp": {
79
84
  "types": "./types/mcp/index.d.ts",
80
85
  "default": "./src/mcp/index.js"
@@ -454,7 +454,8 @@
454
454
  "color",
455
455
  "rank",
456
456
  "checklist",
457
- "allocate"
457
+ "allocate",
458
+ "pick"
458
459
  ],
459
460
  "default": "text"
460
461
  },
@@ -864,6 +865,57 @@
864
865
  ]
865
866
  }
866
867
  },
868
+ "items": {
869
+ "type": "array",
870
+ "description": "pick only: the tiles to choose among, 1 to 60. Strings, or {id, title, image?, video?, url?, caption?}. \"image\" is an https/data URL or a local file (embedded); \"video\" is an https YouTube/Vimeo link or media URL, shown as a link or a muted preview; \"url\" opens a page. The answer is {picks:[{id, note?}], overall?}: ids in the order picked, a note per tile, one overall note.",
871
+ "items": {
872
+ "anyOf": [
873
+ {
874
+ "type": "string"
875
+ },
876
+ {
877
+ "type": "object",
878
+ "required": [
879
+ "id"
880
+ ],
881
+ "properties": {
882
+ "id": {
883
+ "type": "string",
884
+ "description": "Answer key for this tile (default: its title)."
885
+ },
886
+ "title": {
887
+ "type": "string"
888
+ },
889
+ "caption": {
890
+ "type": "string"
891
+ },
892
+ "image": {
893
+ "type": "string",
894
+ "description": "https/data URL, or a local image file (embedded)."
895
+ },
896
+ "video": {
897
+ "type": "string",
898
+ "description": "https YouTube/Vimeo link or media file URL."
899
+ },
900
+ "url": {
901
+ "type": "string",
902
+ "description": "https page the tile links to."
903
+ }
904
+ }
905
+ }
906
+ ]
907
+ }
908
+ },
909
+ "itemNote": {
910
+ "type": "boolean",
911
+ "default": true,
912
+ "description": "pick only: a note field on each picked tile. Set false to hide it."
913
+ },
914
+ "overall": {
915
+ "type": "boolean",
916
+ "default": true,
917
+ "description": "pick only: one overall note under the tiles. Set false to hide it."
918
+ },
867
919
  "other": {
868
920
  "type": "boolean",
869
921
  "description": "Add a free-text \"Other\" option (a multi-line textarea); its text is returned verbatim as the value. Defaults ON for \"single\" (radio) questions so the user is never boxed in — set other:false to remove it; \"multi\" stays opt-in (other:true)."
@@ -882,13 +934,13 @@
882
934
  "min": {
883
935
  "type": "integer",
884
936
  "default": 1,
885
- "description": "scale only"
937
+ "description": "scale: lowest value. pick: fewest tiles to pick (default 0; 1 or more makes the question required)."
886
938
  },
887
939
  "max": {
888
940
  "type": "integer",
889
941
  "default": 5,
890
942
  "maximum": 10,
891
- "description": "scale only"
943
+ "description": "scale: highest value, at most 10. pick: most tiles to pick (default: all of them; 1 makes it a single choice)."
892
944
  },
893
945
  "minLabel": {
894
946
  "type": "string",
@@ -33,7 +33,7 @@ If Relay MCP tools are connected, call `relay_board` with the same spec (questio
33
33
  ]
34
34
  }
35
35
  ```
36
- - Question types: single multi yesno text textarea scale color rank checklist allocate.
36
+ - Question types: single multi yesno text textarea scale color rank checklist allocate pick.
37
37
  - Blocks: markdown(md|mdFile) code(codeFile) diff(diffFile) image compare chart table kpi mermaid graphviz html palette video pdf a2ui. Local files: pass absolute paths.
38
38
  - Blocks go at the board root, on a question, or on an option (visual choices).
39
39
  - Every id is stable and unique. `required:true` only for answers you cannot continue without.
@@ -52,6 +52,7 @@ If Relay MCP tools are connected, call `relay_board` with the same spec (questio
52
52
  {"id":"signoff","type":"checklist","label":"Sign off each area","options":["login","billing"]} // pass/fail/N-A per item: one checklist, not many yes/no
53
53
  {"id":"rank","type":"rank","label":"Priorities","options":["speed","a11y"]} {"id":"split","type":"allocate","label":"Budget","total":100,"options":["type","space"]}
54
54
  {"id":"c","type":"single","label":"Scheme?","options":[{"value":"warm","label":"Warm","blocks":[{"type":"html","html":"<div style='height:100%;background:#c2674b'></div>","height":140}]}]} // a visual per option
55
+ {"id":"hero","type":"pick","label":"Shortlist two","max":2,"items":[{"id":"a","title":"Warm","image":"/abs/a.png","caption":"Terracotta"},{"id":"b","title":"Demo","video":"https://example.com/b.mp4"},{"id":"c","title":"Ref","url":"https://example.com/c"}]} // media tiles; answer {picks:[{id,note?}],overall?}; max 1 = single, min/max bound a multi
55
56
  {"id":"s","type":"scale","label":"Rate","min":1,"max":5} {"id":"col","type":"color","label":"Brand color"} {"id":"ship","type":"yesno","label":"Ship?"}
56
57
  ```
57
58
  Buttons inside a2ui do not replace a question. Their clicks return in `blockEdits`.