@khanglvm/relay 0.20.3 → 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.
- package/README.md +1 -1
- package/docs/AGENT.md +35 -62
- package/docs/SETUP.md +3 -2
- package/package.json +17 -5
- package/schema/spec.v1.json +55 -3
- package/skills/relay/SKILL.md +5 -2
- package/src/a2ui/board-catalog.json +1004 -0
- package/src/a2ui/board-constants.js +35 -0
- package/src/a2ui/board.js +5 -0
- package/src/a2ui/from-a2ui.js +71 -0
- package/src/a2ui/negotiate.js +38 -0
- package/src/a2ui/to-a2ui.js +147 -0
- package/src/cli/args.js +1 -1
- package/src/cli/help.js +2 -1
- package/src/cli/mcp.js +23 -3
- package/src/mcp/boards.js +195 -0
- package/src/mcp/config.js +20 -0
- package/src/mcp/constants.js +33 -0
- package/src/mcp/index.js +5 -0
- package/src/mcp/page.js +59 -0
- package/src/mcp/schemas.js +45 -0
- package/src/mcp/serve.js +116 -0
- package/src/mcp/server.js +24 -0
- package/src/mcp/store.js +35 -0
- package/src/mcp/token.js +56 -0
- package/src/mcp/tools.js +179 -0
- package/src/mcp-ui/board/block-ctx.js +22 -0
- package/src/mcp-ui/board/bridge.js +12 -2
- package/src/mcp-ui/board/core.js +2 -0
- package/src/mcp-ui/board/lifecycle.js +47 -9
- package/src/mcp-ui/board/normalize.js +12 -0
- package/src/mcp-ui/board/render.js +38 -45
- package/src/mcp-ui/board/state.js +3 -0
- package/src/mcp-ui/board/vendors.js +56 -11
- package/src/server/board.js +12 -9
- package/src/server/http.js +19 -0
- package/src/server/page.js +4 -0
- package/src/spec/constants.js +13 -1
- package/src/spec/index.js +1 -0
- package/src/spec/lookup.js +1 -0
- package/src/spec/normalize.js +3 -0
- package/src/spec/pick.js +104 -0
- package/src/spec/schema.js +26 -3
- package/src/ui/app/drafts.js +3 -0
- package/src/ui/app/render.js +1 -0
- package/src/ui/app/submit.js +1 -1
- package/src/ui/manifest.js +3 -2
- package/src/ui/pick.css +32 -0
- package/src/ui/pick.js +246 -0
- package/types/a2ui/board-constants.d.ts +24 -0
- package/types/a2ui/from-a2ui.d.ts +16 -0
- package/types/a2ui/negotiate.d.ts +17 -0
- package/types/a2ui/to-a2ui.d.ts +12 -0
- package/types/cli/agent-topics.d.ts +46 -0
- package/types/mcp/boards.d.ts +178 -0
- package/types/{mcp.d.ts → mcp/config.d.ts} +1 -8
- package/types/mcp/constants.d.ts +21 -0
- package/types/mcp/index.d.ts +4 -0
- package/types/mcp/page.d.ts +27 -0
- package/types/mcp/schemas.d.ts +49 -0
- package/types/mcp/serve.d.ts +16 -0
- package/types/mcp/server.d.ts +4 -0
- package/types/mcp/store.d.ts +52 -0
- package/types/mcp/token.d.ts +9 -0
- package/types/mcp/tools.d.ts +17 -0
- package/types/server/result.d.ts +10 -0
- package/types/server/sanitize.d.ts +6 -0
- package/types/spec/constants.d.ts +9 -0
- package/types/spec/index.d.ts +1 -0
- package/types/spec/lookup.d.ts +2 -1
- package/types/spec/pick.d.ts +25 -0
- package/types/spec/schema.d.ts +48 -0
- package/src/mcp.js +0 -483
package/src/ui/app/render.js
CHANGED
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
else if (q.type === 'rank') control.append(controlRank(q));
|
|
90
90
|
else if (q.type === 'checklist') control.append(controlChecklist(q));
|
|
91
91
|
else if (q.type === 'allocate') control.append(controlAllocate(q));
|
|
92
|
+
else if (q.type === 'pick') control.append(window.RelayPick.control(q, state, { canEdit: access.canEditAnswers, onChange: () => { clearErr(q.id); scheduleSave(); } }));
|
|
92
93
|
else control.append(controlText(q, q.type === 'textarea'));
|
|
93
94
|
card.append(control);
|
|
94
95
|
if (q.note) {
|
package/src/ui/app/submit.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
let firstBad = null;
|
|
4
4
|
for (const q of QS) {
|
|
5
5
|
const required = q.required || !spec.allowPartial;
|
|
6
|
-
const bad = required && getValue(q) === undefined;
|
|
6
|
+
const bad = required && (getValue(q) === undefined || (q.type === 'pick' && window.RelayPick.short(q, state.answers[q.id])));
|
|
7
7
|
cards[q.id].classList.toggle('error', bad);
|
|
8
8
|
if (bad && !firstBad) firstBad = cards[q.id];
|
|
9
9
|
}
|
package/src/ui/manifest.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The browser files of each page, in the order they run. The web board
|
|
2
|
-
// (src/server/page.js) and the MCP App page (src/mcp.js) both assemble their
|
|
2
|
+
// (src/server/page.js) and the MCP App page (src/mcp/page.js) both assemble their
|
|
3
3
|
// scripts and styles from this list, so a file added here reaches both pages.
|
|
4
4
|
//
|
|
5
5
|
// Browser scripts share one scope per page. A bundle part holds files that read
|
|
@@ -25,12 +25,13 @@ const plain = (file) => ({ open: '', files: [file], close: '' });
|
|
|
25
25
|
const iife = (open, files) => ({ open, files, close: IIFE_CLOSE });
|
|
26
26
|
|
|
27
27
|
export const STYLE_PARTS = [plain('ui/style.css')];
|
|
28
|
-
export const BLOCKS_STYLE_PARTS = [plain('ui/blocks.css'), plain('ui/a2ui.css')];
|
|
28
|
+
export const BLOCKS_STYLE_PARTS = [plain('ui/blocks.css'), plain('ui/a2ui.css'), plain('ui/pick.css')];
|
|
29
29
|
export const ANNOTATE_STYLE_PARTS = [plain('ui/annotate.css')];
|
|
30
30
|
|
|
31
31
|
export const BLOCKS_SCRIPT_PARTS = [
|
|
32
32
|
plain('ui/a2ui-state.js'),
|
|
33
33
|
plain('ui/a2ui.js'),
|
|
34
|
+
plain('ui/pick.js'),
|
|
34
35
|
iife(BLOCKS_OPEN, [
|
|
35
36
|
'ui/blocks/core.js',
|
|
36
37
|
'ui/blocks/markdown.js',
|
package/src/ui/pick.css
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* pick question: a grid of media tiles. Used by the web board and the MCP App page. */
|
|
2
|
+
.pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; }
|
|
3
|
+
.pk-tile { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 8px; border: 1px solid var(--border, #ece9e4); border-radius: 12px; background: var(--card, #fff); transition: border-color 0.15s var(--ease, ease), background 0.15s var(--ease, ease); }
|
|
4
|
+
.pk-tile:hover { border-color: var(--accent, #c2674b); }
|
|
5
|
+
.pk-tile.sel { border-color: var(--accent, #c2674b); background: var(--accent-soft, #f5e9e3); }
|
|
6
|
+
.pk-pick { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 0; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
7
|
+
.pk-pick:disabled { cursor: default; }
|
|
8
|
+
.pk-pick:focus-visible, .pk-open:focus-visible { outline: 2px solid var(--accent, #c2674b); outline-offset: 2px; }
|
|
9
|
+
.pk-pick[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
|
|
10
|
+
.pk-media { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 8px; background: var(--bg-sunken, #f6f4f0); color: var(--muted, #8a8580); }
|
|
11
|
+
.pk-img { width: 100%; height: 100%; object-fit: cover; }
|
|
12
|
+
.pk-nomedia .pk-icon { width: 28px; height: 28px; }
|
|
13
|
+
.pk-badge { position: absolute; right: 8px; bottom: 8px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: rgba(28, 27, 25, 0.62); color: #fff; }
|
|
14
|
+
.pk-badge .pk-icon { width: 14px; height: 14px; }
|
|
15
|
+
.pk-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
|
|
16
|
+
.pk-title { min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
|
|
17
|
+
.pk-caption { color: var(--muted, #8a8580); font-size: 0.85rem; overflow-wrap: anywhere; }
|
|
18
|
+
.pk-check { position: relative; flex: none; display: grid; place-items: center; width: 22px; height: 22px; border: 1.5px solid var(--border-strong, #e0dcd5); border-radius: 50%; color: transparent; }
|
|
19
|
+
.pk-tile.sel .pk-check { border-color: var(--accent, #c2674b); background: var(--accent, #c2674b); color: var(--accent-fg, #fcfaf7); }
|
|
20
|
+
.pk-check .pk-icon { width: 13px; height: 13px; }
|
|
21
|
+
.pk-order { position: absolute; top: -8px; right: -8px; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--fg, #1c1b19); color: var(--bg, #fcfbf9); font-size: 0.7rem; line-height: 16px; text-align: center; }
|
|
22
|
+
.pk-order:empty { display: none; }
|
|
23
|
+
.pk-open { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; color: var(--fg-2, #57534e); font-size: 0.82rem; text-decoration: none; }
|
|
24
|
+
.pk-open:hover { color: var(--accent, #c2674b); text-decoration: underline; }
|
|
25
|
+
.pk-open .pk-icon { width: 13px; height: 13px; }
|
|
26
|
+
.pk-notewrap[hidden] { display: none; }
|
|
27
|
+
.pk-note, .pk-overall { width: 100%; box-sizing: border-box; font-size: 0.88rem; resize: vertical; }
|
|
28
|
+
.pk-note { padding: 8px 10px; min-height: 52px; }
|
|
29
|
+
.pk-overall { margin-top: 10px; padding: 8px 12px; min-height: 64px; }
|
|
30
|
+
.pk-status { margin: 10px 0 0; color: var(--muted, #8a8580); font-size: 0.85rem; }
|
|
31
|
+
@media (max-width: 480px) { .pk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }
|
|
32
|
+
@media (prefers-reduced-motion: reduce) { .pk-tile { transition: none; } }
|
package/src/ui/pick.js
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
// pick.js — window.RelayPick: the `pick` question for both pages (web board and MCP App).
|
|
2
|
+
// A grid of media tiles; a tile is one button (Tab to reach it, Space or Enter to pick),
|
|
3
|
+
// with an optional note under each picked tile and one overall note under the grid.
|
|
4
|
+
// The answer is {picks:[{id, note?}], overall?}, ids in the order picked. Every string is
|
|
5
|
+
// set through textContent and every link is http(s) only, so agent text never becomes markup.
|
|
6
|
+
(() => {
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
10
|
+
const HTTP = /^https?:\/\//i;
|
|
11
|
+
const MEDIA_FILE = /\.(mp4|webm|mov|m4v|ogv)(\?|#|$)/i;
|
|
12
|
+
const NOTE_MAX = 2000;
|
|
13
|
+
const OVERALL_MAX = 5000;
|
|
14
|
+
const PATHS = {
|
|
15
|
+
check: 'M20 6 9 17l-5-5',
|
|
16
|
+
external: 'M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6',
|
|
17
|
+
play: 'm6 3 14 9-14 9z',
|
|
18
|
+
link: 'M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function h(tag, cls, text) {
|
|
22
|
+
const n = document.createElement(tag);
|
|
23
|
+
if (cls) n.className = cls;
|
|
24
|
+
if (text !== undefined && text !== null) n.textContent = String(text);
|
|
25
|
+
return n;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function icon(name) {
|
|
29
|
+
const svg = document.createElementNS(SVG_NS, 'svg');
|
|
30
|
+
svg.setAttribute('viewBox', '0 0 24 24');
|
|
31
|
+
svg.setAttribute('class', 'pk-icon');
|
|
32
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
33
|
+
svg.setAttribute('fill', 'none');
|
|
34
|
+
svg.setAttribute('stroke', 'currentColor');
|
|
35
|
+
svg.setAttribute('stroke-width', '2');
|
|
36
|
+
svg.setAttribute('stroke-linecap', 'round');
|
|
37
|
+
svg.setAttribute('stroke-linejoin', 'round');
|
|
38
|
+
const path = document.createElementNS(SVG_NS, 'path');
|
|
39
|
+
path.setAttribute('d', PATHS[name]);
|
|
40
|
+
svg.append(path);
|
|
41
|
+
return svg;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const asObject = (v) => (v && typeof v === 'object' && !Array.isArray(v) ? v : {});
|
|
45
|
+
const clip = (v, max) => (typeof v === 'string' ? v.trim().slice(0, max) : '');
|
|
46
|
+
const limitOf = (q) => (Number.isInteger(q.max) && q.max > 0 ? q.max : (q.items || []).length);
|
|
47
|
+
|
|
48
|
+
/** Cuts a stored or default answer down to what the question allows. */
|
|
49
|
+
function seed(q, prior) {
|
|
50
|
+
const raw = asObject(prior);
|
|
51
|
+
const known = new Set((q.items || []).map((t) => t.id));
|
|
52
|
+
const seen = new Set();
|
|
53
|
+
const picks = [];
|
|
54
|
+
for (const entry of Array.isArray(raw.picks) ? raw.picks : []) {
|
|
55
|
+
const id = typeof entry === 'string' ? entry : asObject(entry).id;
|
|
56
|
+
if (typeof id !== 'string' || !known.has(id) || seen.has(id) || picks.length >= limitOf(q)) continue;
|
|
57
|
+
seen.add(id);
|
|
58
|
+
picks.push({ id, note: typeof entry === 'string' || q.itemNote === false ? '' : clip(entry.note, NOTE_MAX) });
|
|
59
|
+
}
|
|
60
|
+
return { picks, overall: q.overall === false ? '' : clip(raw.overall, OVERALL_MAX) };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The answer to submit, or undefined while the question counts as unanswered. */
|
|
64
|
+
function value(q, stored) {
|
|
65
|
+
const s = seed(q, stored);
|
|
66
|
+
if (!s.picks.length && !s.overall) return undefined;
|
|
67
|
+
const out = { picks: s.picks.map((p) => (p.note ? { id: p.id, note: p.note } : { id: p.id })) };
|
|
68
|
+
if (s.overall) out.overall = s.overall;
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** True while fewer tiles are picked than the question asks for. */
|
|
73
|
+
function short(q, stored) {
|
|
74
|
+
return seed(q, stored).picks.length < (q.min || 0);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const safeUrl = (u) => (typeof u === 'string' && HTTP.test(u) ? u : '');
|
|
78
|
+
|
|
79
|
+
function mediaOf(q, tile) {
|
|
80
|
+
const wrap = h('span', 'pk-media');
|
|
81
|
+
const src = tile.image || (tile.hasImage ? `/img/p/${encodeURIComponent(q.id)}/${encodeURIComponent(tile.id)}` : '');
|
|
82
|
+
if (src) {
|
|
83
|
+
const img = h('img', 'pk-img');
|
|
84
|
+
img.loading = 'lazy';
|
|
85
|
+
img.decoding = 'async';
|
|
86
|
+
img.alt = '';
|
|
87
|
+
img.src = src;
|
|
88
|
+
wrap.append(img);
|
|
89
|
+
} else if (tile.video && MEDIA_FILE.test(tile.video)) {
|
|
90
|
+
const vid = h('video', 'pk-img');
|
|
91
|
+
vid.muted = true;
|
|
92
|
+
vid.loop = true;
|
|
93
|
+
vid.playsInline = true;
|
|
94
|
+
vid.preload = 'metadata';
|
|
95
|
+
vid.src = safeUrl(tile.video);
|
|
96
|
+
vid.setAttribute('aria-hidden', 'true');
|
|
97
|
+
wrap.append(vid);
|
|
98
|
+
const badge = h('span', 'pk-badge');
|
|
99
|
+
badge.append(icon('play'));
|
|
100
|
+
wrap.append(badge);
|
|
101
|
+
wrap.addEventListener('mouseenter', () => vid.play().catch(() => {}));
|
|
102
|
+
wrap.addEventListener('mouseleave', () => vid.pause());
|
|
103
|
+
} else {
|
|
104
|
+
wrap.classList.add('pk-nomedia');
|
|
105
|
+
wrap.append(icon(tile.video ? 'play' : 'link'));
|
|
106
|
+
}
|
|
107
|
+
return wrap;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function openLink(tile) {
|
|
111
|
+
const href = safeUrl(tile.url) || safeUrl(tile.video);
|
|
112
|
+
if (!href) return null;
|
|
113
|
+
const a = h('a', 'pk-open');
|
|
114
|
+
a.href = href;
|
|
115
|
+
a.target = '_blank';
|
|
116
|
+
a.rel = 'noopener noreferrer';
|
|
117
|
+
a.setAttribute('aria-label', `Open ${tile.title} in a new tab`);
|
|
118
|
+
a.append(h('span', null, tile.url ? 'Open page' : 'Watch'), icon('external'));
|
|
119
|
+
return a;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** One tile: the pick button, its link, and the note that shows while it is picked. */
|
|
123
|
+
function tileCell(q, tile, { cur, canEdit, toggle, onChange }) {
|
|
124
|
+
const btn = h('button', 'pk-pick');
|
|
125
|
+
btn.type = 'button';
|
|
126
|
+
btn.disabled = !canEdit;
|
|
127
|
+
btn.setAttribute('aria-pressed', 'false');
|
|
128
|
+
const order = h('span', 'pk-order');
|
|
129
|
+
order.setAttribute('aria-hidden', 'true');
|
|
130
|
+
const check = h('span', 'pk-check');
|
|
131
|
+
check.append(icon('check'));
|
|
132
|
+
check.append(order);
|
|
133
|
+
const head = h('span', 'pk-head');
|
|
134
|
+
head.append(h('span', 'pk-title', tile.title), check);
|
|
135
|
+
btn.append(mediaOf(q, tile), head);
|
|
136
|
+
if (tile.caption) btn.append(h('span', 'pk-caption', tile.caption));
|
|
137
|
+
btn.addEventListener('click', () => toggle(tile.id));
|
|
138
|
+
|
|
139
|
+
const noteWrap = h('div', 'pk-notewrap');
|
|
140
|
+
const note = h('textarea', 'pk-note');
|
|
141
|
+
note.rows = 2;
|
|
142
|
+
note.placeholder = 'Why this one? (optional)';
|
|
143
|
+
note.setAttribute('aria-label', `Note on ${tile.title}`);
|
|
144
|
+
const pickOf = () => cur().picks.find((p) => p.id === tile.id);
|
|
145
|
+
note.value = (pickOf() && pickOf().note) || '';
|
|
146
|
+
note.disabled = !canEdit;
|
|
147
|
+
note.addEventListener('input', () => {
|
|
148
|
+
const p = pickOf();
|
|
149
|
+
if (!p) return;
|
|
150
|
+
p.note = note.value;
|
|
151
|
+
if (onChange) onChange();
|
|
152
|
+
});
|
|
153
|
+
noteWrap.append(note);
|
|
154
|
+
|
|
155
|
+
const root = h('div', 'pk-tile');
|
|
156
|
+
root.append(btn);
|
|
157
|
+
const link = openLink(tile);
|
|
158
|
+
if (link) root.append(link);
|
|
159
|
+
root.append(noteWrap);
|
|
160
|
+
return { root, btn, order, noteWrap, note };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Builds the control for one pick question.
|
|
165
|
+
* @param {object} q normalized question
|
|
166
|
+
* @param {{ answers: Record<string, any> }} state the page's answer state; this control owns state.answers[q.id]
|
|
167
|
+
* @param {{ canEdit?: boolean, onChange?: () => void }} [hooks]
|
|
168
|
+
*/
|
|
169
|
+
function control(q, state, hooks = {}) {
|
|
170
|
+
const canEdit = hooks.canEdit !== false;
|
|
171
|
+
const limit = limitOf(q);
|
|
172
|
+
const items = q.items || [];
|
|
173
|
+
state.answers[q.id] = seed(q, state.answers[q.id]);
|
|
174
|
+
const cur = () => state.answers[q.id];
|
|
175
|
+
|
|
176
|
+
const root = h('div', 'pk');
|
|
177
|
+
const status = h('p', 'pk-status');
|
|
178
|
+
status.setAttribute('role', 'status');
|
|
179
|
+
status.setAttribute('aria-live', 'polite');
|
|
180
|
+
const grid = h('div', 'pk-grid');
|
|
181
|
+
grid.setAttribute('role', 'group');
|
|
182
|
+
grid.setAttribute('aria-label', q.label || 'Choices');
|
|
183
|
+
const cells = new Map();
|
|
184
|
+
|
|
185
|
+
const rule = () => {
|
|
186
|
+
const min = q.min || 0;
|
|
187
|
+
if (limit === 1) return 'Pick one.';
|
|
188
|
+
if (min && min === limit) return `Pick ${min}.`;
|
|
189
|
+
if (min) return `Pick ${min} to ${limit}.`;
|
|
190
|
+
return limit < items.length ? `Pick up to ${limit}.` : 'Pick any number.';
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
function paint() {
|
|
194
|
+
const picks = cur().picks;
|
|
195
|
+
const full = picks.length >= limit && limit > 1;
|
|
196
|
+
for (const [id, cell] of cells) {
|
|
197
|
+
const at = picks.findIndex((p) => p.id === id);
|
|
198
|
+
const on = at >= 0;
|
|
199
|
+
cell.root.classList.toggle('sel', on);
|
|
200
|
+
cell.btn.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
201
|
+
cell.btn.setAttribute('aria-disabled', !on && full ? 'true' : 'false');
|
|
202
|
+
cell.order.textContent = on && limit > 1 ? String(at + 1) : '';
|
|
203
|
+
cell.noteWrap.hidden = !(on && q.itemNote !== false);
|
|
204
|
+
if (!on) cell.note.value = '';
|
|
205
|
+
}
|
|
206
|
+
status.textContent = `${picks.length} picked. ${rule()}`;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function toggle(id) {
|
|
210
|
+
if (!canEdit) return;
|
|
211
|
+
const picks = cur().picks;
|
|
212
|
+
const at = picks.findIndex((p) => p.id === id);
|
|
213
|
+
if (at >= 0) picks.splice(at, 1);
|
|
214
|
+
else if (limit === 1) picks.splice(0, picks.length, { id, note: '' });
|
|
215
|
+
else if (picks.length < limit) picks.push({ id, note: '' });
|
|
216
|
+
else return;
|
|
217
|
+
paint();
|
|
218
|
+
if (hooks.onChange) hooks.onChange();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
for (const tile of items) {
|
|
222
|
+
const cell = tileCell(q, tile, { cur, canEdit, toggle, onChange: hooks.onChange });
|
|
223
|
+
cells.set(tile.id, cell);
|
|
224
|
+
grid.append(cell.root);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
root.append(grid, status);
|
|
228
|
+
if (q.overall !== false) {
|
|
229
|
+
const overall = h('textarea', 'pk-overall');
|
|
230
|
+
overall.rows = 3;
|
|
231
|
+
overall.placeholder = 'Anything to add about the whole set? (optional)';
|
|
232
|
+
overall.setAttribute('aria-label', 'Overall note');
|
|
233
|
+
overall.value = cur().overall || '';
|
|
234
|
+
overall.disabled = !canEdit;
|
|
235
|
+
overall.addEventListener('input', () => {
|
|
236
|
+
cur().overall = overall.value;
|
|
237
|
+
if (hooks.onChange) hooks.onChange();
|
|
238
|
+
});
|
|
239
|
+
root.append(overall);
|
|
240
|
+
}
|
|
241
|
+
paint();
|
|
242
|
+
return root;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
window.RelayPick = { control, seed, value, short };
|
|
246
|
+
})();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Relay's own id for the board catalog; a renderer lists it in `supportedCatalogIds`. */
|
|
2
|
+
export declare const BOARD_CATALOG_ID = "https://github.com/khanglvm/relay/a2ui/catalog/board/v1";
|
|
3
|
+
export declare const A2UI_PROTOCOL_VERSION = "1.0";
|
|
4
|
+
/** The MIME a surface is sent as, then the other spelling a host may declare it under. */
|
|
5
|
+
export declare const A2UI_MIME = "application/a2ui+json";
|
|
6
|
+
export declare const A2UI_MIMES: string[];
|
|
7
|
+
/** The tool a host calls with a renderer event. */
|
|
8
|
+
export declare const A2UI_ACTION_TOOL = "a2ui_action";
|
|
9
|
+
export declare const ACTION_SUBMIT = "relay.submit";
|
|
10
|
+
export declare const ACTION_DRAFT = "relay.draft";
|
|
11
|
+
/** Where the person's input lives in the surface's data model. */
|
|
12
|
+
export declare const DATA_ROOT: {
|
|
13
|
+
answers: string;
|
|
14
|
+
notes: string;
|
|
15
|
+
comment: string;
|
|
16
|
+
annotations: string;
|
|
17
|
+
blockEdits: string;
|
|
18
|
+
};
|
|
19
|
+
/** Ids that would reach Object.prototype if used as a data-model key. */
|
|
20
|
+
export declare const UNSAFE_KEYS: string[];
|
|
21
|
+
/** Escapes one data-model path segment (RFC 6901). */
|
|
22
|
+
export declare const pointerSegment: (key: any) => string;
|
|
23
|
+
/** The data-model pointer for one entry under a root: `/answers/q1`. */
|
|
24
|
+
export declare const dataPath: (root: any, key: any) => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** The value to submit for one answer, or undefined while the question counts as unanswered. */
|
|
2
|
+
export declare function answeredValue(q: any, raw: any): any;
|
|
3
|
+
/**
|
|
4
|
+
* @param {Record<string, any>} dataModel the surface's data model: /answers, /notes, /comment, /annotations, /blockEdits
|
|
5
|
+
* @param {Record<string, any>} spec the normalized spec the surface was made from
|
|
6
|
+
* @returns {{ answers: Record<string, unknown>, comment: string, notes: Record<string, string>, annotations: object[], blockEdits: Record<string, unknown> }}
|
|
7
|
+
*/
|
|
8
|
+
export declare function fromA2ui(dataModel: Record<string, any>, spec: Record<string, any>, { now }?: {
|
|
9
|
+
now?: string;
|
|
10
|
+
}): {
|
|
11
|
+
answers: Record<string, unknown>;
|
|
12
|
+
comment: string;
|
|
13
|
+
notes: Record<string, string>;
|
|
14
|
+
annotations: object[];
|
|
15
|
+
blockEdits: Record<string, unknown>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** True when the client declared the board catalog when it connected. */
|
|
2
|
+
export declare const capabilitiesDeclareBoardCatalog: (capabilities: any) => boolean;
|
|
3
|
+
/**
|
|
4
|
+
* True when a declaration lists the board catalog for protocol 1.0:
|
|
5
|
+
* `{"1.0": {supportedCatalogIds: [...]}}`. A declaration that names the MIME
|
|
6
|
+
* types it accepts must include one Relay sends.
|
|
7
|
+
*/
|
|
8
|
+
export declare function declaresBoardCatalog(declaration: any): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether a call should get A2UI messages: the call's own `_meta.a2ui` decides first,
|
|
11
|
+
* then the capabilities the client declared when it connected.
|
|
12
|
+
* @param {{ capabilities?: any, meta?: any }} caller
|
|
13
|
+
*/
|
|
14
|
+
export declare function wantsA2ui({ capabilities, meta }: {
|
|
15
|
+
capabilities?: any;
|
|
16
|
+
meta?: any;
|
|
17
|
+
}): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The plain text a renderer shows for a block it cannot draw. */
|
|
2
|
+
export declare function fallbackText(block: any): string;
|
|
3
|
+
/**
|
|
4
|
+
* The three messages that make up a board's surface: createSurface, updateComponents, updateDataModel.
|
|
5
|
+
* @param {Record<string, any>} spec a normalized spec
|
|
6
|
+
* @param {{ surfaceId?: string, draft?: Record<string, any> | null }} [options]
|
|
7
|
+
* @returns {Array<Record<string, any>>}
|
|
8
|
+
*/
|
|
9
|
+
export declare function toA2ui(spec: Record<string, any>, { surfaceId, draft }?: {
|
|
10
|
+
surfaceId?: string;
|
|
11
|
+
draft?: Record<string, any> | null;
|
|
12
|
+
}): Array<Record<string, any>>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const AGENT_TOPICS: {
|
|
2
|
+
questions: {
|
|
3
|
+
summary: string;
|
|
4
|
+
headings: string[];
|
|
5
|
+
};
|
|
6
|
+
blocks: {
|
|
7
|
+
summary: string;
|
|
8
|
+
headings: string[];
|
|
9
|
+
};
|
|
10
|
+
annotate: {
|
|
11
|
+
summary: string;
|
|
12
|
+
headings: string[];
|
|
13
|
+
};
|
|
14
|
+
lifecycle: {
|
|
15
|
+
summary: string;
|
|
16
|
+
headings: string[];
|
|
17
|
+
preamble: boolean;
|
|
18
|
+
};
|
|
19
|
+
sharing: {
|
|
20
|
+
summary: string;
|
|
21
|
+
headings: string[];
|
|
22
|
+
};
|
|
23
|
+
mcp: {
|
|
24
|
+
summary: string;
|
|
25
|
+
headings: string[];
|
|
26
|
+
};
|
|
27
|
+
a2ui: {
|
|
28
|
+
summary: string;
|
|
29
|
+
file: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/** Splits a markdown guide into its text before the first H2 and its H2 sections. Headings inside code fences are text. */
|
|
33
|
+
export declare function splitSections(md: any): {
|
|
34
|
+
preamble: string;
|
|
35
|
+
sections: {
|
|
36
|
+
title: any;
|
|
37
|
+
text: any;
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
/** The topic list `rly agent` prints for an unknown topic. */
|
|
41
|
+
export declare function topicIndex(): string;
|
|
42
|
+
/**
|
|
43
|
+
* The text of one topic. `readDoc(file)` returns a docs/ file as text; the
|
|
44
|
+
* caller owns the filesystem so this stays testable.
|
|
45
|
+
*/
|
|
46
|
+
export declare function renderAgentTopic(topic: any, readDoc: any): any;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/** One board call's mode: a board that wants a reply is `ask`, anything else `show`. Questions always want a reply. */
|
|
2
|
+
export declare const modeOf: (spec: any) => "ask" | "show";
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes the tool arguments into a stored board. Spec errors come back as
|
|
5
|
+
* CliError so the tool can answer with an isError result the model can fix.
|
|
6
|
+
* @param {import('./store.js').RelayStore} store
|
|
7
|
+
* @param {Record<string, any>} args
|
|
8
|
+
* @param {{ displayOnly?: boolean }} [options]
|
|
9
|
+
*/
|
|
10
|
+
export declare function createMcpBoard(store: import('./store.js').RelayStore, args: Record<string, any>, options?: {
|
|
11
|
+
displayOnly?: boolean;
|
|
12
|
+
}): Promise<{
|
|
13
|
+
record: import("./store.js").BoardRecord;
|
|
14
|
+
spec: {
|
|
15
|
+
title: string;
|
|
16
|
+
intro: string;
|
|
17
|
+
blocks: any[];
|
|
18
|
+
allowPartial: boolean;
|
|
19
|
+
note: boolean;
|
|
20
|
+
autoClose: boolean;
|
|
21
|
+
responseRequired: boolean;
|
|
22
|
+
questions: any[];
|
|
23
|
+
submitLabel: string;
|
|
24
|
+
};
|
|
25
|
+
mode: string;
|
|
26
|
+
}>;
|
|
27
|
+
/** The compact list of questions a model sees in the relay_board result: id, type, label. */
|
|
28
|
+
export declare function questionList(spec: any, labelMax?: number): any;
|
|
29
|
+
/**
|
|
30
|
+
* The relay_board result: a summary and structuredContent, never the spec.
|
|
31
|
+
* The question list shrinks until the whole result fits RESULT_BUDGET_BYTES.
|
|
32
|
+
* @returns {ToolResult}
|
|
33
|
+
*/
|
|
34
|
+
export declare function boardResult(record: any, spec: any, mode: any): ToolResult;
|
|
35
|
+
export type ToolResult = import('@modelcontextprotocol/server').CallToolResult;
|
|
36
|
+
/** @typedef {import('@modelcontextprotocol/server').CallToolResult} ToolResult */
|
|
37
|
+
/** @returns {ToolResult} */
|
|
38
|
+
export declare const errorResult: (message: any) => ToolResult;
|
|
39
|
+
/** An invalid spec as a tool error; anything else is a server bug and rethrows. */
|
|
40
|
+
export declare function specError(err: any): {
|
|
41
|
+
[x: string]: unknown;
|
|
42
|
+
_meta?: {
|
|
43
|
+
[x: string]: unknown;
|
|
44
|
+
"io.modelcontextprotocol/serverInfo"?: {
|
|
45
|
+
version: string;
|
|
46
|
+
websiteUrl?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
icons?: {
|
|
49
|
+
src: string;
|
|
50
|
+
mimeType?: string;
|
|
51
|
+
sizes?: string[];
|
|
52
|
+
theme?: "dark" | "light";
|
|
53
|
+
}[];
|
|
54
|
+
name: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
content: ({
|
|
59
|
+
type: "text";
|
|
60
|
+
text: string;
|
|
61
|
+
annotations?: {
|
|
62
|
+
audience?: ("assistant" | "user")[];
|
|
63
|
+
priority?: number;
|
|
64
|
+
lastModified?: string;
|
|
65
|
+
};
|
|
66
|
+
_meta?: {
|
|
67
|
+
[x: string]: unknown;
|
|
68
|
+
};
|
|
69
|
+
} | {
|
|
70
|
+
type: "image";
|
|
71
|
+
data: string;
|
|
72
|
+
mimeType: string;
|
|
73
|
+
annotations?: {
|
|
74
|
+
audience?: ("assistant" | "user")[];
|
|
75
|
+
priority?: number;
|
|
76
|
+
lastModified?: string;
|
|
77
|
+
};
|
|
78
|
+
_meta?: {
|
|
79
|
+
[x: string]: unknown;
|
|
80
|
+
};
|
|
81
|
+
} | {
|
|
82
|
+
type: "audio";
|
|
83
|
+
data: string;
|
|
84
|
+
mimeType: string;
|
|
85
|
+
annotations?: {
|
|
86
|
+
audience?: ("assistant" | "user")[];
|
|
87
|
+
priority?: number;
|
|
88
|
+
lastModified?: string;
|
|
89
|
+
};
|
|
90
|
+
_meta?: {
|
|
91
|
+
[x: string]: unknown;
|
|
92
|
+
};
|
|
93
|
+
} | {
|
|
94
|
+
uri: string;
|
|
95
|
+
description?: string;
|
|
96
|
+
mimeType?: string;
|
|
97
|
+
size?: number;
|
|
98
|
+
annotations?: {
|
|
99
|
+
audience?: ("assistant" | "user")[];
|
|
100
|
+
priority?: number;
|
|
101
|
+
lastModified?: string;
|
|
102
|
+
};
|
|
103
|
+
_meta?: {
|
|
104
|
+
[x: string]: unknown;
|
|
105
|
+
};
|
|
106
|
+
icons?: {
|
|
107
|
+
src: string;
|
|
108
|
+
mimeType?: string;
|
|
109
|
+
sizes?: string[];
|
|
110
|
+
theme?: "dark" | "light";
|
|
111
|
+
}[];
|
|
112
|
+
name: string;
|
|
113
|
+
title?: string;
|
|
114
|
+
type: "resource_link";
|
|
115
|
+
} | {
|
|
116
|
+
type: "resource";
|
|
117
|
+
resource?: {
|
|
118
|
+
uri: string;
|
|
119
|
+
mimeType?: string;
|
|
120
|
+
_meta?: {
|
|
121
|
+
[x: string]: unknown;
|
|
122
|
+
};
|
|
123
|
+
text: string;
|
|
124
|
+
} | {
|
|
125
|
+
uri: string;
|
|
126
|
+
mimeType?: string;
|
|
127
|
+
_meta?: {
|
|
128
|
+
[x: string]: unknown;
|
|
129
|
+
};
|
|
130
|
+
blob: string;
|
|
131
|
+
};
|
|
132
|
+
annotations?: {
|
|
133
|
+
audience?: ("assistant" | "user")[];
|
|
134
|
+
priority?: number;
|
|
135
|
+
lastModified?: string;
|
|
136
|
+
};
|
|
137
|
+
_meta?: {
|
|
138
|
+
[x: string]: unknown;
|
|
139
|
+
};
|
|
140
|
+
})[];
|
|
141
|
+
structuredContent?: unknown;
|
|
142
|
+
isError?: boolean;
|
|
143
|
+
};
|
|
144
|
+
/** Saves the person's answers so far, so relay_result can show them before the final submit. */
|
|
145
|
+
export declare function saveDraft(store: any, id: any, draft: any, spec: any): Promise<any>;
|
|
146
|
+
/**
|
|
147
|
+
* Stores the final answers. A second submit is refused so a stray click cannot
|
|
148
|
+
* overwrite what the agent may already have read.
|
|
149
|
+
* @returns {Promise<{ ok: boolean, status?: string, error?: string }>}
|
|
150
|
+
*/
|
|
151
|
+
export declare function submitBoard(store: any, record: any, body: any): Promise<{
|
|
152
|
+
ok: boolean;
|
|
153
|
+
status?: string;
|
|
154
|
+
error?: string;
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* Appends one a2ui button click for relay_result to report. The click must name
|
|
158
|
+
* an a2ui block on this board and pass the checks the browser board applies to a2ui state.
|
|
159
|
+
* @returns {Promise<{ ok: boolean, entry?: object, error?: string }>}
|
|
160
|
+
*/
|
|
161
|
+
export declare function recordEvent(store: any, record: any, event: any): Promise<{
|
|
162
|
+
ok: boolean;
|
|
163
|
+
entry?: object;
|
|
164
|
+
error?: string;
|
|
165
|
+
}>;
|
|
166
|
+
/**
|
|
167
|
+
* A renderer event from an A2UI surface. `relay.submit` and `relay.draft` carry the surface's
|
|
168
|
+
* data model and store it as a submit or a draft; any other name is a widget button click.
|
|
169
|
+
* @returns {Promise<{ ok: boolean, status?: string, error?: string }>}
|
|
170
|
+
*/
|
|
171
|
+
export declare function handleSurfaceAction(store: any, record: any, args: any): Promise<{
|
|
172
|
+
ok: boolean;
|
|
173
|
+
status?: string;
|
|
174
|
+
error?: string;
|
|
175
|
+
}>;
|
|
176
|
+
/** What relay_result reports for a board right now. */
|
|
177
|
+
export declare function resultOf(record: any): any;
|
|
178
|
+
export declare const isFinal: (record: any) => boolean;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function runMcpHttp({ port, host, token, allowOrigin }?: {
|
|
3
|
-
allowOrigin?: string;
|
|
4
|
-
host?: string;
|
|
5
|
-
port?: number;
|
|
6
|
-
token?: string;
|
|
7
|
-
}): Promise<any>;
|
|
1
|
+
/** Setup for each host: a JSON entry, a Codex TOML block, and how to run the HTTP transport. */
|
|
8
2
|
export declare function mcpConfig({ command, httpPort }?: {
|
|
9
3
|
command?: string;
|
|
10
4
|
httpPort?: number;
|
|
@@ -25,7 +19,6 @@ export declare function mcpConfig({ command, httpPort }?: {
|
|
|
25
19
|
http: {
|
|
26
20
|
run: string;
|
|
27
21
|
url: string;
|
|
28
|
-
deploy: string;
|
|
29
22
|
note: string;
|
|
30
23
|
};
|
|
31
24
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const UI_EXT = "io.modelcontextprotocol/ui";
|
|
2
|
+
export declare const UI_MIME = "text/html;profile=mcp-app";
|
|
3
|
+
export declare const BOARD_URI = "ui://relay/board";
|
|
4
|
+
export declare const VENDOR_URI_PREFIX = "ui://relay/vendor/";
|
|
5
|
+
export declare const HTTP_PATH = "/mcp";
|
|
6
|
+
export declare const DEFAULT_HTTP_PORT = 4319;
|
|
7
|
+
export declare const VENDOR_CHUNK_BYTES: number;
|
|
8
|
+
export declare const MAX_WAIT_SECONDS = 600;
|
|
9
|
+
export declare const RESULT_BUDGET_BYTES = 2048;
|
|
10
|
+
export declare const TOOL: {
|
|
11
|
+
board: string;
|
|
12
|
+
help: string;
|
|
13
|
+
result: string;
|
|
14
|
+
view: string;
|
|
15
|
+
draft: string;
|
|
16
|
+
submit: string;
|
|
17
|
+
asset: string;
|
|
18
|
+
a2uiAction: string;
|
|
19
|
+
ask: string;
|
|
20
|
+
show: string;
|
|
21
|
+
};
|