@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/src/ui/a2ui.js ADDED
@@ -0,0 +1,289 @@
1
+ // a2ui.js — window.RelayA2ui.render(block, ctx, blockId): draws one `a2ui`
2
+ // block (A2UI v1.0 components from Relay's catalog) as plain DOM. Every string
3
+ // goes in through textContent and every link is https-only, so agent text can
4
+ // never become markup. State and event logging live in a2ui-state.js.
5
+ (() => {
6
+ 'use strict';
7
+
8
+ const SVG_NS = 'http://www.w3.org/2000/svg';
9
+ const TONES = ['info', 'ok', 'warn', 'error', 'needs'];
10
+ const TONE_WORDS = { info: 'Info', ok: 'OK', warn: 'Warning', error: 'Failed', needs: 'Needs you' };
11
+ const HTTPS = /^https:\/\//i;
12
+
13
+ // Lucide-style 24x24 stroke paths for the catalog's Icon set.
14
+ const ICONS = {
15
+ check: 'M20 6 9 17l-5-5',
16
+ alert: 'M12 9v4M12 17h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z',
17
+ info: 'M12 16v-4M12 8h.01M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0Z',
18
+ x: 'M18 6 6 18M6 6l12 12',
19
+ clock: 'M12 6v6l4 2M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0Z',
20
+ file: 'M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6',
21
+ folder: 'M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.7-.9l-.8-1.2A2 2 0 0 0 7.9 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z',
22
+ 'git-branch': 'M6 3v12M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM18 9a9 9 0 0 1-9 9',
23
+ play: 'm6 3 14 9-14 9z',
24
+ star: 'm12 2 3.1 6.3 6.9 1-5 4.9 1.2 6.8L12 17.8 5.8 21l1.2-6.8-5-4.9 6.9-1z',
25
+ 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',
26
+ user: 'M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z',
27
+ bell: 'M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.9 1.9 0 0 0 3.4 0',
28
+ lock: 'M7 11V7a5 5 0 0 1 10 0v4M5 11h14a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-8a1 1 0 0 1 1-1Z',
29
+ 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',
30
+ };
31
+
32
+ function el(tag, cls, text) {
33
+ const n = document.createElement(tag);
34
+ if (cls) n.className = cls;
35
+ if (text !== undefined && text !== null) n.textContent = String(text);
36
+ return n;
37
+ }
38
+
39
+ function icon(name, label) {
40
+ const svg = document.createElementNS(SVG_NS, 'svg');
41
+ svg.setAttribute('viewBox', '0 0 24 24');
42
+ svg.setAttribute('class', 'a2-icon');
43
+ for (const [k, v] of Object.entries({ fill: 'none', stroke: 'currentColor', 'stroke-width': '2', 'stroke-linecap': 'round', 'stroke-linejoin': 'round' })) svg.setAttribute(k, v);
44
+ if (label) { svg.setAttribute('role', 'img'); svg.setAttribute('aria-label', label); } else svg.setAttribute('aria-hidden', 'true');
45
+ const path = document.createElementNS(SVG_NS, 'path');
46
+ path.setAttribute('d', ICONS[name] || ICONS.info);
47
+ svg.append(path);
48
+ return svg;
49
+ }
50
+
51
+ const text = (v) => (v === undefined || v === null ? '' : typeof v === 'object' ? JSON.stringify(v) : String(v));
52
+ const toneOf = (v) => (TONES.includes(v) ? v : '');
53
+
54
+ function pill(label, tone) {
55
+ return el('span', 'a2-pill' + (toneOf(tone) ? ' a2-tone-' + tone : ''), label);
56
+ }
57
+
58
+ // Runs `paint` now and again after every state change, so bound props stay live.
59
+ function live(store, paint) {
60
+ paint();
61
+ store.subscribe(paint);
62
+ }
63
+
64
+ function renderList(c, store) {
65
+ const wrap = el('div', 'a2-list');
66
+ live(store, () => {
67
+ const rows = store.resolve(c.items);
68
+ const list = Array.isArray(rows) ? rows.filter((r) => r && typeof r === 'object') : [];
69
+ const max = c.max || list.length;
70
+ wrap.replaceChildren();
71
+ for (const row of list.slice(0, max)) {
72
+ const item = el('div', 'a2-item');
73
+ const main = el('div', 'a2-row-main');
74
+ const title = HTTPS.test(text(row.url)) ? Object.assign(el('a', 'a2-row-title', text(row.title)), { href: row.url, target: '_blank', rel: 'noopener noreferrer' }) : el('div', 'a2-row-title', text(row.title));
75
+ main.append(title);
76
+ if (row.subtitle) main.append(el('div', 'a2-row-sub', text(row.subtitle)));
77
+ item.append(main);
78
+ const tone = toneOf(row.tone);
79
+ if (tone) item.append(pill(row.trailing ? text(row.trailing) : TONE_WORDS[tone], tone));
80
+ else if (row.trailing) item.append(el('div', 'a2-row-trail', text(row.trailing)));
81
+ wrap.append(item);
82
+ }
83
+ if (list.length > max) wrap.append(el('div', 'a2-row-more', `${list.length - max} more`));
84
+ if (!list.length) wrap.append(el('div', 'a2-row-more', 'Nothing here yet'));
85
+ });
86
+ return wrap;
87
+ }
88
+
89
+ function renderTable(c, store) {
90
+ const scroller = el('div', 'a2-table-wrap');
91
+ const table = el('table', 'a2-table');
92
+ scroller.append(table);
93
+ live(store, () => {
94
+ const rows = store.resolve(c.rows);
95
+ const list = Array.isArray(rows) ? rows.filter((r) => r && typeof r === 'object') : [];
96
+ table.replaceChildren();
97
+ const head = el('tr');
98
+ for (const col of c.columns) head.append(el('th', '', col.label));
99
+ const thead = el('thead');
100
+ thead.append(head);
101
+ table.append(thead);
102
+ const body = el('tbody');
103
+ for (const row of list.slice(0, c.max || list.length)) {
104
+ const tr = el('tr');
105
+ for (const col of c.columns) tr.append(el('td', '', Object.hasOwn(row, col.key) ? text(row[col.key]) : ''));
106
+ body.append(tr);
107
+ }
108
+ table.append(body);
109
+ });
110
+ return scroller;
111
+ }
112
+
113
+ function renderProgress(c, store) {
114
+ const wrap = el('div', 'a2-progress');
115
+ const head = el('div', 'a2-progress-head');
116
+ const label = el('span', '');
117
+ const figure = el('span', 'a2-muted');
118
+ head.append(label, figure);
119
+ const bar = el('div', 'a2-bar');
120
+ bar.setAttribute('role', 'progressbar');
121
+ const fill = el('div', 'a2-bar-fill');
122
+ bar.append(fill);
123
+ const note = el('div', 'a2-muted');
124
+ wrap.append(head, bar, note);
125
+ live(store, () => {
126
+ const value = Number(store.resolve(c.value)) || 0;
127
+ const total = Number(store.resolve(c.total)) || 0;
128
+ const pct = total > 0 ? Math.max(0, Math.min(100, (value / total) * 100)) : 0;
129
+ label.textContent = text(store.resolve(c.label));
130
+ figure.textContent = `${value} of ${total}`;
131
+ fill.style.width = pct + '%';
132
+ bar.className = 'a2-bar' + (toneOf(c.tone) ? ' a2-tone-' + c.tone : '');
133
+ bar.setAttribute('aria-valuenow', String(Math.round(pct)));
134
+ bar.setAttribute('aria-valuemin', '0');
135
+ bar.setAttribute('aria-valuemax', '100');
136
+ bar.setAttribute('aria-label', text(store.resolve(c.label)));
137
+ note.textContent = text(store.resolve(c.note));
138
+ note.hidden = !note.textContent;
139
+ });
140
+ return wrap;
141
+ }
142
+
143
+ // A labelled input bound to `c.path`; `read` and `write` adapt the control's value.
144
+ function field(c, store, control, { read, write, event = 'input' }) {
145
+ const wrap = el('label', 'a2-field');
146
+ const caption = el('span', 'a2-field-label');
147
+ wrap.append(caption, control);
148
+ live(store, () => {
149
+ caption.textContent = text(store.resolve(c.label));
150
+ const value = store.get(c.path);
151
+ if (document.activeElement !== control) write(control, value);
152
+ });
153
+ control.addEventListener(event, () => store.set(c.path, read(control)));
154
+ return wrap;
155
+ }
156
+
157
+ function renderInput(c, store, interactive) {
158
+ let wrap;
159
+ if (c.component === 'TextField') {
160
+ const input = c.multiline ? el('textarea', 'a2-input') : Object.assign(el('input', 'a2-input'), { type: 'text' });
161
+ if (c.multiline) input.rows = 3;
162
+ if (c.placeholder) input.placeholder = text(store.resolve(c.placeholder));
163
+ wrap = field(c, store, input, { read: (n) => n.value, write: (n, v) => { n.value = text(v); } });
164
+ } else if (c.component === 'Toggle') {
165
+ const box = Object.assign(el('input', 'a2-check'), { type: 'checkbox' });
166
+ wrap = field(c, store, box, { read: (n) => n.checked, write: (n, v) => { n.checked = v === true; }, event: 'change' });
167
+ wrap.classList.add('a2-field-inline');
168
+ } else if (c.component === 'Select') {
169
+ const select = el('select', 'a2-input');
170
+ for (const o of c.options) select.append(Object.assign(el('option', '', o.label), { value: o.key }));
171
+ // An untouched Select still answers with its first option, as the control shows it.
172
+ if (store.get(c.path) === undefined) window.RelayA2uiState.set(store.data, c.path, c.options[0].key);
173
+ wrap = field(c, store, select, { read: (n) => n.value, write: (n, v) => { n.value = text(v); }, event: 'change' });
174
+ } else {
175
+ const range = Object.assign(el('input', 'a2-range'), { type: 'range', min: c.min, max: c.max, step: c.step || 'any' });
176
+ const readout = el('span', 'a2-muted');
177
+ wrap = field(c, store, range, { read: (n) => Number(n.value), write: (n, v) => { n.value = typeof v === 'number' ? v : c.min; readout.textContent = n.value; } });
178
+ wrap.append(readout);
179
+ range.addEventListener('input', () => { readout.textContent = range.value; });
180
+ }
181
+ wrap.querySelectorAll('input,select,textarea').forEach((n) => { n.disabled = !interactive; });
182
+ return wrap;
183
+ }
184
+
185
+ function renderButton(c, store, interactive, onFired) {
186
+ const button = el('button', 'a2-btn' + (c.style === 'primary' ? ' a2-btn-primary' : ''));
187
+ button.type = 'button';
188
+ live(store, () => { button.textContent = text(store.resolve(c.label)); });
189
+ const call = c.action.functionCall;
190
+ if (call) {
191
+ button.addEventListener('click', () => { if (HTTPS.test(call.args.url)) window.open(call.args.url, '_blank', 'noopener,noreferrer'); });
192
+ button.prepend(icon('external'));
193
+ return button;
194
+ }
195
+ button.disabled = !interactive;
196
+ button.addEventListener('click', () => {
197
+ store.fire(c.action.event.name, c.action.event.context);
198
+ onFired(button);
199
+ });
200
+ return button;
201
+ }
202
+
203
+ const GAPS = { xs: '4px', sm: '8px', md: '12px', lg: '16px' };
204
+
205
+ function build(c, byId, store, env) {
206
+ const kids = () => (c.children || []).map((id) => byId.has(id) ? build(byId.get(id), byId, store, env) : null).filter(Boolean);
207
+ switch (c.component) {
208
+ case 'Card': {
209
+ const card = el('div', 'a2-card');
210
+ if (c.title) { const t = el('div', 'a2-card-title'); live(store, () => { t.textContent = text(store.resolve(c.title)); }); card.append(t); }
211
+ card.append(...kids());
212
+ return card;
213
+ }
214
+ case 'Stack': {
215
+ const s = el('div', 'a2-stack a2-' + (c.direction === 'row' ? 'row' : 'col'));
216
+ s.style.gap = GAPS[c.gap] || GAPS.sm;
217
+ if (c.align) s.style.alignItems = { start: 'flex-start', end: 'flex-end', center: 'center', stretch: 'stretch' }[c.align];
218
+ s.append(...kids());
219
+ return s;
220
+ }
221
+ case 'Grid': {
222
+ const g = el('div', 'a2-grid a2-cols-' + c.columns);
223
+ g.style.gap = GAPS[c.gap] || GAPS.sm;
224
+ g.append(...kids());
225
+ return g;
226
+ }
227
+ case 'Text': {
228
+ const t = el('div', 'a2-text a2-text-' + (['title', 'muted'].includes(c.variant) ? c.variant : 'body'));
229
+ live(store, () => { t.textContent = text(store.resolve(c.text)); });
230
+ return t;
231
+ }
232
+ case 'Pill': {
233
+ const p = pill('', c.tone);
234
+ live(store, () => { p.textContent = text(store.resolve(c.text)); });
235
+ return p;
236
+ }
237
+ case 'Metric': {
238
+ const m = el('div', 'a2-metric');
239
+ const [l, v, n] = [el('div', 'a2-metric-label'), el('div', 'a2-metric-value'), el('div', 'a2-muted')];
240
+ m.append(l, v, n);
241
+ live(store, () => { l.textContent = text(store.resolve(c.label)); v.textContent = text(store.resolve(c.value)); n.textContent = text(store.resolve(c.note)); n.hidden = !n.textContent; });
242
+ return m;
243
+ }
244
+ case 'List': return renderList(c, store);
245
+ case 'Table': return renderTable(c, store);
246
+ case 'Progress': return renderProgress(c, store);
247
+ case 'Code': {
248
+ const pre = el('pre', 'a2-code');
249
+ const code = el('code');
250
+ pre.append(code);
251
+ live(store, () => { code.textContent = text(store.resolve(c.code)); });
252
+ return pre;
253
+ }
254
+ case 'Image': {
255
+ const img = el('img', 'a2-image');
256
+ img.loading = 'lazy';
257
+ img.alt = text(store.resolve(c.alt));
258
+ if (HTTPS.test(c.url)) img.src = c.url;
259
+ return img;
260
+ }
261
+ case 'Icon': { const i = icon(c.name, text(store.resolve(c.label))); if (toneOf(c.tone)) i.classList.add('a2-tone-' + c.tone); return i; }
262
+ case 'Divider': return el('hr', 'a2-divider');
263
+ case 'Button': return renderButton(c, store, env.interactive, env.onFired);
264
+ default: return renderInput(c, store, env.interactive);
265
+ }
266
+ }
267
+
268
+ function render(block, ctx, blockId) {
269
+ const wrap = el('div', 'blk-a2ui a2');
270
+ const components = Array.isArray(block.components) ? block.components : [];
271
+ const byId = new Map(components.map((c) => [c.id, c]));
272
+ const root = byId.get('root');
273
+ if (!root) { wrap.append(el('div', 'blk-error', 'This A2UI widget has no root.')); return wrap; }
274
+ const prior = ctx.edits && ctx.edits[blockId] && ctx.edits[blockId].type === 'a2ui' ? ctx.edits[blockId] : null;
275
+ const store = window.RelayA2uiState.createStore(block.dataModel || {}, prior, (snapshot) => ctx.onBlockEdit(blockId, snapshot));
276
+ const interactive = ctx.canEditBlocks !== false && ctx.canComment !== false;
277
+ const status = el('div', 'a2-status a2-muted');
278
+ status.setAttribute('role', 'status');
279
+ const showSent = () => { status.textContent = 'Recorded. It goes back with your answer when you submit.'; };
280
+ if (store.eventCount()) showSent();
281
+ const onFired = (button) => { showSent(); button.classList.add('a2-btn-sent'); setTimeout(() => button.classList.remove('a2-btn-sent'), 1200); };
282
+ const card = build(root, byId, store, { interactive, onFired });
283
+ wrap.append(card, status);
284
+ if (ctx.annotate) ctx.annotate.register(card, { blockId, questionId: ctx.questionId, target: { kind: 'html-element', label: text(block.title || root.title || 'A2UI widget') } });
285
+ return wrap;
286
+ }
287
+
288
+ window.RelayA2ui = { render };
289
+ })();
package/src/ui/blocks.js CHANGED
@@ -3042,6 +3042,10 @@
3042
3042
  inner = renderCompare(block, ctx, blockId);
3043
3043
  wrapper.append(inner);
3044
3044
  break;
3045
+ case 'a2ui':
3046
+ inner = window.RelayA2ui ? window.RelayA2ui.render(block, ctx, blockId) : el('div', { class: 'blk-error' }, 'A2UI renderer is not loaded.');
3047
+ wrapper.append(inner);
3048
+ break;
3045
3049
  default:
3046
3050
  wrapper.append(el('div', { class: 'blk-error' }, 'Unknown block type: ' + esc(String(block.type))));
3047
3051
  }
@@ -0,0 +1,40 @@
1
+ export declare const CATALOG_FILE: string;
2
+ export declare const A2UI_LIMITS: {
3
+ expressChars: number;
4
+ components: number;
5
+ componentsBytes: number;
6
+ dataBytes: number;
7
+ depth: number;
8
+ eventContextBytes: number;
9
+ };
10
+ /** Relay's catalog: component name -> JSON-schema-style definition. */
11
+ export declare function loadCatalog(): any;
12
+ /** Refuses prototype-polluting keys anywhere in a JSON-like value, and runaway nesting. */
13
+ export declare function assertSafeJson(value: any, where: any, depth?: number): void;
14
+ /** Size and path checks that run before the SDK sees the text. */
15
+ export declare function guardExpress(text: any, where: any): string;
16
+ /** Agents paste the block with or without its `<a2ui>` tags, and sometimes inside a Markdown fence. */
17
+ export declare function wrapExpress(source: any): any;
18
+ /** Compiles one Express block into flat components (root first) and the data model its `$/path = value` lines set. */
19
+ export declare function compileExpress(source: any, where?: string): Promise<{
20
+ components: any;
21
+ dataModel?: any;
22
+ }>;
23
+ /**
24
+ * Validates a flat surface against Relay's catalog and returns it as plain data.
25
+ * Throws a CliError worded for the agent that wrote it.
26
+ * @param {{ components: any, dataModel?: any }} surface
27
+ * @param {string} [where]
28
+ */
29
+ export declare function validateSurface({ components, dataModel }: {
30
+ components: any;
31
+ dataModel?: any;
32
+ }, where?: string): {
33
+ components: any[];
34
+ dataModel?: any;
35
+ };
36
+ /**
37
+ * Compiles a block's `express` in place into `components` and `dataModel`, then
38
+ * validates the result. Blocks that already hold components are left alone.
39
+ */
40
+ export declare function resolveA2uiBlock(block: any, where?: string): Promise<any>;
@@ -0,0 +1,181 @@
1
+ import { normalizeSpec } from './spec.js';
2
+ export type RelaySpec = {
3
+ /**
4
+ * Spec version; a spec without it is read as version 1.
5
+ */
6
+ version?: 1;
7
+ /**
8
+ * Schema URL, ignored by Relay.
9
+ */
10
+ $schema?: string;
11
+ title?: string;
12
+ intro?: string;
13
+ /**
14
+ * Board-level blocks.
15
+ */
16
+ blocks?: Array<Record<string, unknown>>;
17
+ questions?: Array<Record<string, unknown>>;
18
+ /**
19
+ * Let the user submit with unanswered questions.
20
+ */
21
+ allowPartial?: boolean;
22
+ /**
23
+ * Show the free-text "Anything else?" box.
24
+ */
25
+ note?: boolean;
26
+ /**
27
+ * Close the browser tab after submit.
28
+ */
29
+ autoClose?: boolean;
30
+ /**
31
+ * False for a display-only board.
32
+ */
33
+ responseRequired?: boolean;
34
+ submitLabel?: string;
35
+ };
36
+ export type Annotation = {
37
+ id: string;
38
+ questionId: string | null;
39
+ blockId: string | null;
40
+ /**
41
+ * What the comment points at.
42
+ */
43
+ target: {
44
+ kind: string;
45
+ } & Record<string, unknown>;
46
+ text: string;
47
+ /**
48
+ * ISO timestamp.
49
+ */
50
+ createdAt: string;
51
+ };
52
+ export type RelayResult = {
53
+ /**
54
+ * Answer per question id.
55
+ */
56
+ answers: Record<string, unknown>;
57
+ /**
58
+ * Per-question note text.
59
+ */
60
+ notes?: Record<string, string>;
61
+ /**
62
+ * The "Anything else?" text.
63
+ */
64
+ comment?: string;
65
+ /**
66
+ * Question ids left unanswered.
67
+ */
68
+ skipped?: string[];
69
+ annotations?: Annotation[];
70
+ /**
71
+ * Edited block payloads by block id.
72
+ */
73
+ blockEdits?: Record<string, unknown> | null;
74
+ };
75
+ export type BoardRecord = {
76
+ id: string;
77
+ /**
78
+ * ISO timestamp.
79
+ */
80
+ createdAt: string;
81
+ title: string;
82
+ /**
83
+ * Directory the board was authored in.
84
+ */
85
+ cwd: string;
86
+ /**
87
+ * The normalized spec.
88
+ */
89
+ spec: Record<string, unknown>;
90
+ draft: unknown;
91
+ result: RelayResult | null;
92
+ };
93
+ export type A2uiSurface = {
94
+ components: Array<Record<string, unknown>>;
95
+ dataModel?: Record<string, unknown>;
96
+ };
97
+ /**
98
+ * A board spec as an agent writes it: `questions`, `blocks`, or both. Run
99
+ * `rly agent` or read schema/spec.v1.json for every field.
100
+ * @typedef {object} RelaySpec
101
+ * @property {1} [version] Spec version; a spec without it is read as version 1.
102
+ * @property {string} [$schema] Schema URL, ignored by Relay.
103
+ * @property {string} [title]
104
+ * @property {string} [intro]
105
+ * @property {Array<Record<string, unknown>>} [blocks] Board-level blocks.
106
+ * @property {Array<Record<string, unknown>>} [questions]
107
+ * @property {boolean} [allowPartial] Let the user submit with unanswered questions.
108
+ * @property {boolean} [note] Show the free-text "Anything else?" box.
109
+ * @property {boolean} [autoClose] Close the browser tab after submit.
110
+ * @property {boolean} [responseRequired] False for a display-only board.
111
+ * @property {string} [submitLabel]
112
+ */
113
+ /**
114
+ * A comment the user attached to one element of a block.
115
+ * @typedef {object} Annotation
116
+ * @property {string} id
117
+ * @property {string | null} questionId
118
+ * @property {string | null} blockId
119
+ * @property {{ kind: string } & Record<string, unknown>} target What the comment points at.
120
+ * @property {string} text
121
+ * @property {string} createdAt ISO timestamp.
122
+ */
123
+ /**
124
+ * What `rly result` prints once the user submits.
125
+ * @typedef {object} RelayResult
126
+ * @property {Record<string, unknown>} answers Answer per question id.
127
+ * @property {Record<string, string>} [notes] Per-question note text.
128
+ * @property {string} [comment] The "Anything else?" text.
129
+ * @property {string[]} [skipped] Question ids left unanswered.
130
+ * @property {Annotation[]} [annotations]
131
+ * @property {Record<string, unknown> | null} [blockEdits] Edited block payloads by block id.
132
+ */
133
+ /**
134
+ * A board stored on disk under RLY_HOME (default ~/.relay).
135
+ * @typedef {object} BoardRecord
136
+ * @property {string} id
137
+ * @property {string} createdAt ISO timestamp.
138
+ * @property {string} title
139
+ * @property {string} cwd Directory the board was authored in.
140
+ * @property {Record<string, unknown>} spec The normalized spec.
141
+ * @property {unknown} draft
142
+ * @property {RelayResult | null} result
143
+ */
144
+ /**
145
+ * A validated A2UI surface: a flat component list plus an optional data model.
146
+ * @typedef {object} A2uiSurface
147
+ * @property {Array<Record<string, unknown>>} components
148
+ * @property {Record<string, unknown>} [dataModel]
149
+ */
150
+ /**
151
+ * Checks a spec without throwing. Reads the files a spec names (`mdFile`,
152
+ * `rowsFile`) relative to `cwd`. Mermaid syntax and A2UI Express are checked
153
+ * later, when a board opens.
154
+ * @param {unknown} raw
155
+ * @param {{ cwd?: string }} [options]
156
+ * @returns {{ ok: boolean, errors: string[] }}
157
+ */
158
+ export declare function validateSpec(raw: unknown, options?: {
159
+ cwd?: string;
160
+ }): {
161
+ ok: boolean;
162
+ errors: string[];
163
+ };
164
+ /**
165
+ * Normalizes a spec and stores it as a new board, the way `rly ask` does
166
+ * before it opens one. Throws when the spec is invalid.
167
+ * @param {unknown} raw
168
+ * @param {{ cwd?: string }} [options]
169
+ * @returns {BoardRecord}
170
+ */
171
+ export declare function createBoard(raw: unknown, options?: {
172
+ cwd?: string;
173
+ }): BoardRecord;
174
+ /**
175
+ * Compiles A2UI Express text, or checks ready components, into a surface that
176
+ * the board draws.
177
+ * @param {string | A2uiSurface} source
178
+ * @returns {Promise<A2uiSurface>}
179
+ */
180
+ export declare function compileA2ui(source: string | A2uiSurface): Promise<A2uiSurface>;
181
+ export { normalizeSpec };
package/types/mcp.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ export declare function runMcp(): Promise<any>;
2
+ export declare function runMcpHttp({ port, host, token, allowOrigin }?: {
3
+ allowOrigin?: string;
4
+ host?: string;
5
+ port?: number;
6
+ token?: string;
7
+ }): Promise<any>;
8
+ export declare function mcpConfig({ command, httpPort }?: {
9
+ command?: string;
10
+ httpPort?: number;
11
+ }): {
12
+ command: string;
13
+ args: string[];
14
+ httpPort: number;
15
+ httpUrl: string;
16
+ json: {
17
+ mcpServers: {
18
+ relay: {
19
+ command: string;
20
+ args: string[];
21
+ };
22
+ };
23
+ };
24
+ toml: string;
25
+ http: {
26
+ run: string;
27
+ url: string;
28
+ deploy: string;
29
+ note: string;
30
+ };
31
+ };