@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.
- package/docs/AGENT.md +14 -2
- package/package.json +6 -1
- package/schema/spec.v1.json +55 -3
- package/skills/relay/SKILL.md +2 -1
- 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 +19 -1
- package/src/mcp/boards.js +26 -4
- package/src/mcp/constants.js +3 -1
- package/src/mcp/schemas.js +5 -2
- package/src/mcp/server.js +2 -1
- package/src/mcp/token.js +33 -8
- package/src/mcp/tools.js +14 -6
- package/src/mcp-ui/board/normalize.js +12 -0
- package/src/mcp-ui/board/render.js +2 -1
- package/src/mcp-ui/board/state.js +3 -0
- 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 +2 -1
- 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/mcp/boards.d.ts +11 -1
- package/types/mcp/schemas.d.ts +5 -2
- package/types/mcp/token.d.ts +5 -1
- 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/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>>;
|
package/types/mcp/boards.d.ts
CHANGED
|
@@ -142,7 +142,7 @@ export declare function specError(err: any): {
|
|
|
142
142
|
isError?: boolean;
|
|
143
143
|
};
|
|
144
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): Promise<any>;
|
|
145
|
+
export declare function saveDraft(store: any, id: any, draft: any, spec: any): Promise<any>;
|
|
146
146
|
/**
|
|
147
147
|
* Stores the final answers. A second submit is refused so a stray click cannot
|
|
148
148
|
* overwrite what the agent may already have read.
|
|
@@ -163,6 +163,16 @@ export declare function recordEvent(store: any, record: any, event: any): Promis
|
|
|
163
163
|
entry?: object;
|
|
164
164
|
error?: string;
|
|
165
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
|
+
}>;
|
|
166
176
|
/** What relay_result reports for a board right now. */
|
|
167
177
|
export declare function resultOf(record: any): any;
|
|
168
178
|
export declare const isFinal: (record: any) => boolean;
|
package/types/mcp/schemas.d.ts
CHANGED
|
@@ -23,12 +23,15 @@ export declare const submitInput: z.ZodObject<{
|
|
|
23
23
|
token: z.ZodString;
|
|
24
24
|
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
25
25
|
}, z.core.$strip>;
|
|
26
|
+
/** A widget button click (`blockId`, `name`, `context`), or a renderer event (`action`, plus the surface's `dataModel`). */
|
|
26
27
|
export declare const actionInput: z.ZodObject<{
|
|
27
28
|
boardId: z.ZodString;
|
|
28
29
|
token: z.ZodString;
|
|
29
|
-
blockId: z.ZodString
|
|
30
|
-
name: z.ZodString
|
|
30
|
+
blockId: z.ZodOptional<z.ZodString>;
|
|
31
|
+
name: z.ZodOptional<z.ZodString>;
|
|
31
32
|
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
33
|
+
action: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
34
|
+
dataModel: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
32
35
|
}, z.core.$strip>;
|
|
33
36
|
export declare const assetInput: z.ZodObject<{
|
|
34
37
|
name: z.ZodString;
|
package/types/mcp/token.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* The server's HMAC key: a random value kept in the relay home, created on first use.
|
|
3
|
+
* Two servers starting together both try to create it; the exclusive create lets one
|
|
4
|
+
* win and the other read what the winner wrote, so they never hold different keys.
|
|
5
|
+
*/
|
|
2
6
|
export declare function loadServerKey(file?: string): string;
|
|
3
7
|
export declare const boardToken: (key: any, boardId: any) => string;
|
|
4
8
|
/** Constant-time comparison, so a wrong token leaks nothing about the right one. */
|
|
@@ -28,6 +28,9 @@ export declare const ALIASES: {
|
|
|
28
28
|
budget: string;
|
|
29
29
|
distribute: string;
|
|
30
30
|
points: string;
|
|
31
|
+
tiles: string;
|
|
32
|
+
gallery: string;
|
|
33
|
+
shortlist: string;
|
|
31
34
|
};
|
|
32
35
|
export declare const BLOCK_ALIASES: {
|
|
33
36
|
md: string;
|
|
@@ -79,3 +82,9 @@ export declare const IMAGE_MIMES: {
|
|
|
79
82
|
bmp: string;
|
|
80
83
|
};
|
|
81
84
|
export declare const IMAGE_MAX_BYTES: number;
|
|
85
|
+
export declare const PICK: {
|
|
86
|
+
maxItems: number;
|
|
87
|
+
maxImageBytes: number;
|
|
88
|
+
maxNoteChars: number;
|
|
89
|
+
maxOverallChars: number;
|
|
90
|
+
};
|
package/types/spec/index.d.ts
CHANGED
package/types/spec/lookup.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare const QUESTION_FIELDS: {
|
|
|
29
29
|
rank: string[];
|
|
30
30
|
checklist: string[];
|
|
31
31
|
allocate: string[];
|
|
32
|
+
pick: string[];
|
|
32
33
|
};
|
|
33
34
|
/** The property names the schema defines for blocks and for questions. */
|
|
34
35
|
export declare function schemaFieldNames(): {
|
|
@@ -41,12 +42,12 @@ export declare function schemaFieldNames(): {
|
|
|
41
42
|
* collides today; a block wins if one ever does.
|
|
42
43
|
*/
|
|
43
44
|
export declare function lookupSchema(name: any): {
|
|
45
|
+
required?: undefined;
|
|
44
46
|
kind: string;
|
|
45
47
|
type: string;
|
|
46
48
|
fields: {
|
|
47
49
|
[k: string]: any;
|
|
48
50
|
};
|
|
49
|
-
required?: undefined;
|
|
50
51
|
} | {
|
|
51
52
|
kind: string;
|
|
52
53
|
type: string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds the pick fields to a normalized question: `items`, `min`, `max`, `itemNote`, `overall`.
|
|
3
|
+
* The generic per-question note stays off: a pick carries its own notes.
|
|
4
|
+
* @param {Record<string, any>} q the question being built
|
|
5
|
+
* @param {Record<string, any>} rq what the agent wrote
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizePick(q: Record<string, any>, rq: Record<string, any>, where: any, cwd: any): void;
|
|
8
|
+
/**
|
|
9
|
+
* The answer to a pick question, cut down to what the question allows: known ids
|
|
10
|
+
* once each, at most `max` of them in the order picked, notes only when the tiles
|
|
11
|
+
* take them. Returns undefined when nothing is left, which reads as skipped.
|
|
12
|
+
* @returns {{ picks: Array<{ id: string, note?: string }>, overall?: string } | undefined}
|
|
13
|
+
*/
|
|
14
|
+
export declare function cleanPick(q: any, value: any): {
|
|
15
|
+
picks: Array<{
|
|
16
|
+
id: string;
|
|
17
|
+
note?: string;
|
|
18
|
+
}>;
|
|
19
|
+
overall?: string;
|
|
20
|
+
} | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* A copy of a board's answers in which every pick answer is cleaned. Other
|
|
23
|
+
* answers pass through as sent, which is how every board already treats them.
|
|
24
|
+
*/
|
|
25
|
+
export declare function cleanAnswers(spec: any, answers: any): any;
|
package/types/spec/schema.d.ts
CHANGED
|
@@ -747,6 +747,54 @@ export declare const SPEC_SCHEMA: {
|
|
|
747
747
|
})[];
|
|
748
748
|
};
|
|
749
749
|
};
|
|
750
|
+
items: {
|
|
751
|
+
type: string;
|
|
752
|
+
description: string;
|
|
753
|
+
items: {
|
|
754
|
+
anyOf: ({
|
|
755
|
+
properties?: undefined;
|
|
756
|
+
type: string;
|
|
757
|
+
required?: undefined;
|
|
758
|
+
} | {
|
|
759
|
+
type: string;
|
|
760
|
+
required: string[];
|
|
761
|
+
properties: {
|
|
762
|
+
id: {
|
|
763
|
+
type: string;
|
|
764
|
+
description: string;
|
|
765
|
+
};
|
|
766
|
+
title: {
|
|
767
|
+
type: string;
|
|
768
|
+
};
|
|
769
|
+
caption: {
|
|
770
|
+
type: string;
|
|
771
|
+
};
|
|
772
|
+
image: {
|
|
773
|
+
type: string;
|
|
774
|
+
description: string;
|
|
775
|
+
};
|
|
776
|
+
video: {
|
|
777
|
+
type: string;
|
|
778
|
+
description: string;
|
|
779
|
+
};
|
|
780
|
+
url: {
|
|
781
|
+
type: string;
|
|
782
|
+
description: string;
|
|
783
|
+
};
|
|
784
|
+
};
|
|
785
|
+
})[];
|
|
786
|
+
};
|
|
787
|
+
};
|
|
788
|
+
itemNote: {
|
|
789
|
+
type: string;
|
|
790
|
+
default: boolean;
|
|
791
|
+
description: string;
|
|
792
|
+
};
|
|
793
|
+
overall: {
|
|
794
|
+
type: string;
|
|
795
|
+
default: boolean;
|
|
796
|
+
description: string;
|
|
797
|
+
};
|
|
750
798
|
other: {
|
|
751
799
|
type: string;
|
|
752
800
|
description: string;
|