@khanglvm/relay 0.24.0 → 0.25.1
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 +3 -3
- package/package.json +1 -1
- package/skills/relay/SKILL.md +1 -1
- package/src/mcp/boards.js +1 -1
- package/src/mcp/constants.js +6 -3
- package/src/mcp/schemas.js +1 -1
- package/src/mcp/tools.js +44 -7
- package/src/mcp-ui/board/controls.js +54 -32
- package/src/mcp-ui/board/lifecycle.js +1 -1
- package/src/mcp-ui/board/render.js +28 -9
- package/src/mcp-ui/index.html +3 -1
- package/types/mcp/constants.d.ts +1 -1
package/docs/AGENT.md
CHANGED
|
@@ -142,11 +142,11 @@ Everything outside this section is the CLI surface: you run `rly` and read JSON
|
|
|
142
142
|
|
|
143
143
|
Tools:
|
|
144
144
|
- `relay_board`: takes the spec this guide describes. A spec with `questions` collects answers; one without is display-only. The result is a short summary with the `boardId`, never the spec.
|
|
145
|
-
- `relay_result {boardId, wait_seconds}`: the answers, notes, comment, annotations and blockEdits, or the draft while the person is still filling the board in. `wait_seconds` blocks until they submit, up to
|
|
145
|
+
- `relay_result {boardId, wait_seconds}`: the answers, notes, comment, annotations and blockEdits, or the draft while the person is still filling the board in. `wait_seconds` blocks until they submit, up to 50, which stays under the roughly 60-second tool timeout of MCP clients. A status of `open` is not an answer: call it again.
|
|
146
146
|
- `relay_help {topic}` or `relay_help {schema}`: a part of this guide, or the exact fields of one block or question type.
|
|
147
147
|
- `relay_ask` and `relay_show`: the old names, kept as aliases for one more minor version. Use `relay_board`.
|
|
148
148
|
|
|
149
|
-
The flow: call `relay_board`, tell the person the board is on screen, and
|
|
149
|
+
The flow: call `relay_board`, tell the person the board is on screen, then call `relay_result {boardId, wait_seconds: 50}` and call it again while it says `open`. When an agent is waiting like this, the board hands it the answers directly. Otherwise the board posts a one-line message naming the board to wake the agent, and some hosts (T3 Code) ask the person to confirm that message. Do not ask the same questions again in chat.
|
|
150
150
|
|
|
151
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, and only under the server's file roots: none over HTTP unless the operator passes `--root PATH` (repeatable) or `RLY_FILE_ROOTS`, the working directory over stdio (but not when it is `/` or the home directory, where desktop hosts often start it). `--retention-days N` (or `RLY_RETENTION_DAYS`, `off` to keep every board) sets how long unchanged boards stay in the relay home; the default is 30. 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
152
|
|
|
@@ -756,7 +756,7 @@ file write alone starts a new model turn.
|
|
|
756
756
|
|
|
757
757
|
| Client/surface | Recommended Relay return path |
|
|
758
758
|
|---|---|
|
|
759
|
-
| MCP App (`relay_board` with questions) | No CLI wait.
|
|
759
|
+
| MCP App (`relay_board` with questions) | No CLI wait. Keep a `relay_result` wait open; on submit it returns the answers. With no wait open, the board posts a one-line message instead. |
|
|
760
760
|
| MCP App (`relay_board`, display-only) | Present it and continue immediately; no acknowledgement is requested. |
|
|
761
761
|
| Claude Code | Run `rly wait <id> --timeout 0` as a [background Bash task](https://docs.anthropic.com/en/docs/claude-code/interactive-mode#background-bash-commands); retain its task id/output rather than opening a second board. |
|
|
762
762
|
| Gemini CLI | Run the waiter in the background and set [`tools.shell.backgroundCompletionBehavior` to `"inject"`](https://geminicli.com/docs/reference/configuration/) so completion is returned to the agent; `"notify"` only informs the chat UI. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanglvm/relay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.1",
|
|
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, …): ask users structured questions, present interactive visuals, collect inline comments, read answers as JSON — in a local browser board OR rendered INLINE inside the Claude & Codex apps as an MCP App (SEP-1865).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-agents",
|
package/skills/relay/SKILL.md
CHANGED
|
@@ -15,7 +15,7 @@ If your host app has its own way to ask the user or show results (native questio
|
|
|
15
15
|
3. Give the person the url. To get the result: `rly wait <boardId> --timeout 1800 --while-active --idle-grace 300` (blocks until submit) or `rly result <boardId>` (now). A timeout is not an answer: run `rly result` before you decide.
|
|
16
16
|
4. Read `answers`, `notes`, `comment`, `annotations` and `blockEdits` together; any of them can qualify an answer. When stdout is cut short, read the `resultFile` it names.
|
|
17
17
|
|
|
18
|
-
If Relay MCP tools are connected, call `relay_board` with the same spec (questions make it collect answers, none make it display-only) and the board renders inline.
|
|
18
|
+
If Relay MCP tools are connected, call `relay_board` with the same spec (questions make it collect answers, none make it display-only) and the board renders inline. Then call `relay_result {boardId, wait_seconds: 50}` and repeat while it says `open`: answers collected that way need no chat message, which some hosts make the person confirm; `relay_help` gives exact fields. Embed file content with `mdFile`, `codeFile` or an image block, because inline boards cannot open local file links.
|
|
19
19
|
|
|
20
20
|
## Spec in one screen
|
|
21
21
|
```json
|
package/src/mcp/boards.js
CHANGED
|
@@ -53,7 +53,7 @@ export function questionList(spec, labelMax = 80) {
|
|
|
53
53
|
export function boardResult(record, spec, mode) {
|
|
54
54
|
const title = limit(spec.title, 120);
|
|
55
55
|
const text = mode === 'ask'
|
|
56
|
-
? `Board "${title}" (${record.id}) is on screen${spec.questions.length ? ` with ${spec.questions.length} question${spec.questions.length === 1 ? '' : 's'}` : ' for the person to acknowledge'}. They answer there.
|
|
56
|
+
? `Board "${title}" (${record.id}) is on screen${spec.questions.length ? ` with ${spec.questions.length} question${spec.questions.length === 1 ? '' : 's'}` : ' for the person to acknowledge'}. They answer there. Call relay_result {boardId, wait_seconds: 50} now and again while it says open: answers collected that way arrive without a chat message the person must confirm. Do not re-ask them in chat.`
|
|
57
57
|
: `Board "${title}" (${record.id}) is on screen, display-only. Continue without waiting.`;
|
|
58
58
|
for (const labelMax of [80, 40, 20, 0]) {
|
|
59
59
|
const structuredContent = { boardId: record.id, mode, title, questions: questionList(spec, labelMax) };
|
package/src/mcp/constants.js
CHANGED
|
@@ -12,9 +12,12 @@ export const DEFAULT_HTTP_PORT = 4319;
|
|
|
12
12
|
// well under the size a host will pass to an iframe.
|
|
13
13
|
export const VENDOR_CHUNK_BYTES = 768 * 1024;
|
|
14
14
|
|
|
15
|
-
// The longest relay_result may block.
|
|
16
|
-
//
|
|
17
|
-
|
|
15
|
+
// The longest relay_result may block. MCP clients give up on a tool call after
|
|
16
|
+
// about 60 seconds (Claude Code and the Agent SDK measured on M6; Codex's
|
|
17
|
+
// default tool_timeout_sec is 60), and a wait the client abandoned fails the
|
|
18
|
+
// agent and could count as a pickup. 50 seconds returns "open" in time for the
|
|
19
|
+
// agent to call again.
|
|
20
|
+
export const MAX_WAIT_SECONDS = 50;
|
|
18
21
|
|
|
19
22
|
// relay_board results stay under this size so a model reading it pays for a summary, not the spec.
|
|
20
23
|
export const RESULT_BUDGET_BYTES = 2048;
|
package/src/mcp/schemas.js
CHANGED
|
@@ -41,5 +41,5 @@ export const helpInput = z.object({
|
|
|
41
41
|
|
|
42
42
|
export const resultInput = z.object({
|
|
43
43
|
boardId,
|
|
44
|
-
wait_seconds: z.number().min(0).optional().describe('Block up to this
|
|
44
|
+
wait_seconds: z.number().min(0).optional().describe('Block up to this many seconds (at most 50) for the submission; default 0 returns now. Call again while the status is open.'),
|
|
45
45
|
});
|
package/src/mcp/tools.js
CHANGED
|
@@ -65,6 +65,31 @@ function oneAtATime(boardId, task) {
|
|
|
65
65
|
return run;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// Boards whose final answers a waiting relay_result call has handed to an agent,
|
|
69
|
+
// with the time. Module level because a stateless HTTP host builds a fresh server
|
|
70
|
+
// per request. relay_submit reads it to tell the board whether the agent already
|
|
71
|
+
// has the answers, so the board can skip the chat message that wakes the agent.
|
|
72
|
+
// Hosts such as T3 Code confirm every such message with the person. A wrong
|
|
73
|
+
// "delivered" strands the answers, so only a waiter whose request is still open
|
|
74
|
+
// counts, and only a pickup made after this submit began.
|
|
75
|
+
const pickedUp = new Map();
|
|
76
|
+
const PICKUP_GRACE_MS = 2500;
|
|
77
|
+
function notePickup(boardId) {
|
|
78
|
+
const now = Date.now();
|
|
79
|
+
for (const [id, at] of pickedUp) if (now - at > 60_000) pickedUp.delete(id);
|
|
80
|
+
pickedUp.set(String(boardId), now);
|
|
81
|
+
}
|
|
82
|
+
/** Waits briefly for an agent that is blocked in relay_result to collect a board submitted at `since`. */
|
|
83
|
+
async function waitForPickup(boardId, since) {
|
|
84
|
+
const picked = () => (pickedUp.get(String(boardId)) ?? -1) >= since;
|
|
85
|
+
const until = Date.now() + PICKUP_GRACE_MS;
|
|
86
|
+
while (Date.now() < until) {
|
|
87
|
+
if (picked()) return true;
|
|
88
|
+
await sleep(100);
|
|
89
|
+
}
|
|
90
|
+
return picked();
|
|
91
|
+
}
|
|
92
|
+
|
|
68
93
|
const appMeta = (visibility) => ({ ui: { resourceUri: BOARD_URI, visibility } });
|
|
69
94
|
const modelMeta = { ...appMeta(['model', 'app']), 'openai/outputTemplate': BOARD_URI };
|
|
70
95
|
|
|
@@ -109,8 +134,12 @@ function registerReadTools({ server, store }) {
|
|
|
109
134
|
for (;;) {
|
|
110
135
|
const record = await store.get(boardId);
|
|
111
136
|
if (!record) return errorResult(`relay: no board "${boardId}"`);
|
|
112
|
-
|
|
137
|
+
const aborted = Boolean(ctx?.mcpReq?.signal?.aborted);
|
|
138
|
+
if (isFinal(record) || Date.now() >= deadline || aborted) {
|
|
113
139
|
const out = resultOf(record);
|
|
140
|
+
// A disconnected client never gets this result (the SDK drops it), and a
|
|
141
|
+
// plain status read is not an agent waiting for the answers.
|
|
142
|
+
if (isFinal(record) && wait_seconds > 0 && !aborted) notePickup(boardId);
|
|
114
143
|
return json(out, { boardId, status: out.status });
|
|
115
144
|
}
|
|
116
145
|
await sleep(500);
|
|
@@ -161,12 +190,20 @@ function registerAppTools({ server, options, store, key }) {
|
|
|
161
190
|
const outcome = await handleSurfaceAction(store, record, args);
|
|
162
191
|
return outcome.ok ? text('recorded') : errorResult(`relay: ${outcome.error}`);
|
|
163
192
|
}));
|
|
164
|
-
appTool(TOOL.submit, { description: 'Stores the final answers.', inputSchema: submitInput },
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
193
|
+
appTool(TOOL.submit, { description: 'Stores the final answers and says whether a waiting agent already collected them.', inputSchema: submitInput }, async (args) => {
|
|
194
|
+
let since = 0;
|
|
195
|
+
const outcome = await oneAtATime(args.boardId, async () => {
|
|
196
|
+
const { record, error } = await guard(args);
|
|
197
|
+
if (error) return { error };
|
|
198
|
+
since = Date.now();
|
|
199
|
+
return submitBoard(store, record, args.payload);
|
|
200
|
+
});
|
|
201
|
+
if (outcome.error && typeof outcome.error === 'object') return outcome.error;
|
|
202
|
+
if (!outcome.ok) return errorResult(`relay: ${outcome.error}`);
|
|
203
|
+
// Outside the board queue, so a relay_result for this board is not held up.
|
|
204
|
+
const delivered = await waitForPickup(args.boardId, since);
|
|
205
|
+
return json({ status: outcome.status, delivered }, { status: outcome.status, delivered });
|
|
206
|
+
});
|
|
170
207
|
appTool(TOOL.asset, { description: 'One chunk of a vendored library, for hosts that refuse resources/read.', inputSchema: assetInput }, ({ name, index }) => {
|
|
171
208
|
const chunk = vendorChunk(name, index);
|
|
172
209
|
return chunk ? json({ name, index, count: chunk.count }, chunk) : errorResult(`relay: no asset "${name}" chunk ${index}`);
|
|
@@ -9,10 +9,35 @@
|
|
|
9
9
|
function requiredMark() {
|
|
10
10
|
return el('span', { class: 'req' }, el('span', { 'aria-hidden': 'true' }, ' *'), el('span', { class: 'sr-only' }, ' (required)'));
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
let uidSeq = 0;
|
|
13
|
+
const uid = (prefix) => prefix + '-' + (++uidSeq);
|
|
14
|
+
/**
|
|
15
|
+
* Gives a row of single-choice buttons radio semantics: each says whether it
|
|
16
|
+
* is checked, Tab enters at the chosen one (or the first), and the arrow keys
|
|
17
|
+
* move to and choose the next. Returns a function that repaints the state.
|
|
18
|
+
* The caller puts role=radiogroup and a label on the buttons' container.
|
|
19
|
+
*/
|
|
20
|
+
function radioButtons(buttons, isOn) {
|
|
21
|
+
const sync = () => {
|
|
22
|
+
const on = buttons.map((btn, i) => isOn(i));
|
|
23
|
+
const entry = Math.max(0, on.indexOf(true));
|
|
24
|
+
buttons.forEach((btn, i) => {
|
|
25
|
+
btn.setAttribute('role', 'radio');
|
|
26
|
+
btn.setAttribute('aria-checked', on[i] ? 'true' : 'false');
|
|
27
|
+
btn.classList.toggle('sel', on[i]);
|
|
28
|
+
btn.tabIndex = i === entry ? 0 : -1;
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
buttons.forEach((btn, i) => btn.addEventListener('keydown', (ev) => {
|
|
32
|
+
const step = { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 }[ev.key];
|
|
33
|
+
if (!step) return;
|
|
34
|
+
ev.preventDefault();
|
|
35
|
+
const next = buttons[(i + step + buttons.length) % buttons.length];
|
|
36
|
+
next.focus();
|
|
37
|
+
if (next.getAttribute('aria-checked') !== 'true') next.click();
|
|
38
|
+
}));
|
|
39
|
+
sync();
|
|
40
|
+
return sync;
|
|
16
41
|
}
|
|
17
42
|
|
|
18
43
|
function syncOptSel(group) {
|
|
@@ -110,19 +135,17 @@
|
|
|
110
135
|
}
|
|
111
136
|
|
|
112
137
|
function segButtons(q, values, labels) {
|
|
113
|
-
const seg = el('div', { class: q.type === 'scale' ? 'scale' : 'seg' });
|
|
114
|
-
const buttons = [];
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
for (const x of buttons) setPressed(x, state.answers[q.id] === values[buttons.indexOf(x)]);
|
|
138
|
+
const seg = el('div', { class: q.type === 'scale' ? 'scale' : 'seg', role: 'radiogroup' });
|
|
139
|
+
const buttons = values.map((v, i) => el('button', { type: 'button' }, labels[i]));
|
|
140
|
+
const sync = radioButtons(buttons, (i) => state.answers[q.id] === values[i]);
|
|
141
|
+
buttons.forEach((btn, i) => {
|
|
142
|
+
btn.addEventListener('click', () => {
|
|
143
|
+
if (state.answers[q.id] === values[i]) delete state.answers[q.id];
|
|
144
|
+
else state.answers[q.id] = values[i];
|
|
145
|
+
sync();
|
|
122
146
|
clearErr(q.id);
|
|
123
147
|
});
|
|
124
|
-
|
|
125
|
-
seg.append(b);
|
|
148
|
+
seg.append(btn);
|
|
126
149
|
});
|
|
127
150
|
return seg;
|
|
128
151
|
}
|
|
@@ -133,13 +156,13 @@
|
|
|
133
156
|
// Up to 11 steps fit one even row on a phone; the end labels move under it
|
|
134
157
|
// so they do not squeeze the buttons. Longer scales keep the wrapping row.
|
|
135
158
|
if (values.length <= 11) {
|
|
136
|
-
const steps = '--n:' + values.length;
|
|
137
|
-
const grid = el('div', { class: 'scale scale-fit', style: steps }, ...seg.children);
|
|
159
|
+
const steps = '--n:' + values.length + ';--half:' + Math.ceil(values.length / 2);
|
|
160
|
+
const grid = el('div', { class: 'scale scale-fit' + (values.length >= 8 ? ' scale-long' : ''), style: steps, role: 'radiogroup' }, ...seg.children);
|
|
138
161
|
if (!q.minLabel && !q.maxLabel) return grid;
|
|
139
162
|
return el('div', {}, grid, el('div', { class: 'scale-ends', style: steps },
|
|
140
163
|
el('span', {}, q.minLabel || ''), el('span', {}, q.maxLabel || '')));
|
|
141
164
|
}
|
|
142
|
-
const row = el('div', { class: 'scale' });
|
|
165
|
+
const row = el('div', { class: 'scale', role: 'radiogroup' });
|
|
143
166
|
if (q.minLabel) row.append(el('span', { class: 'slabel' }, q.minLabel));
|
|
144
167
|
row.append(...seg.children);
|
|
145
168
|
if (q.maxLabel) row.append(el('span', { class: 'slabel' }, q.maxLabel));
|
|
@@ -159,23 +182,22 @@
|
|
|
159
182
|
const cur = () => (state.answers[q.id] && typeof state.answers[q.id] === 'object' && !Array.isArray(state.answers[q.id])
|
|
160
183
|
? state.answers[q.id] : (state.answers[q.id] = {}));
|
|
161
184
|
for (const o of q.options) {
|
|
162
|
-
const
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
185
|
+
const labelId = uid('chk');
|
|
186
|
+
const seg = el('div', { class: 'chk-seg', role: 'radiogroup', 'aria-labelledby': labelId });
|
|
187
|
+
const buttons = q.statuses.map((st) => el('button', { type: 'button', class: 'chk-status' + (st.tone ? ' tone-' + st.tone : '') }, st.label));
|
|
188
|
+
const sync = radioButtons(buttons, (i) => cur()[o.value] === q.statuses[i].value);
|
|
189
|
+
buttons.forEach((btn, i) => {
|
|
190
|
+
btn.addEventListener('click', () => {
|
|
168
191
|
const m = cur();
|
|
169
|
-
if (m[o.value] ===
|
|
170
|
-
else m[o.value] =
|
|
171
|
-
|
|
192
|
+
if (m[o.value] === q.statuses[i].value) delete m[o.value];
|
|
193
|
+
else m[o.value] = q.statuses[i].value;
|
|
194
|
+
sync();
|
|
172
195
|
clearErr(q.id);
|
|
173
196
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
el('div', { class: 'chk-body' }, el('div', { class: 'ol' }, o.label), o.description ? el('div', { class: 'od' }, o.description) : null),
|
|
197
|
+
seg.append(btn);
|
|
198
|
+
});
|
|
199
|
+
wrap.append(el('div', { class: 'chk-row' },
|
|
200
|
+
el('div', { class: 'chk-body' }, el('div', { class: 'ol', id: labelId }, o.label), o.description ? el('div', { class: 'od' }, o.description) : null),
|
|
179
201
|
seg));
|
|
180
202
|
}
|
|
181
203
|
return wrap;
|
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
// A free-text answer is named by its question, not by its placeholder.
|
|
44
44
|
const field = control.querySelector(':scope > input[type="text"], :scope > textarea');
|
|
45
45
|
if (field) field.setAttribute('aria-labelledby', labelId);
|
|
46
|
+
const radios = control.querySelector('[role="radiogroup"]:not([aria-labelledby])');
|
|
47
|
+
if (radios) radios.setAttribute('aria-labelledby', labelId);
|
|
46
48
|
card.append(control);
|
|
47
49
|
if (q.note) {
|
|
48
50
|
const noteInput = el('textarea', { class: 'qnote', rows: 2, placeholder: 'optional note about this answer…', 'aria-label': 'Note about this answer' });
|
|
@@ -145,7 +147,15 @@
|
|
|
145
147
|
submitBtn.disabled = true;
|
|
146
148
|
submitBtn.textContent = 'Submitting…';
|
|
147
149
|
const data = payload();
|
|
148
|
-
const
|
|
150
|
+
const outcome = BOARD.token ? await storeSubmission(data) : { stored: false, delivered: false };
|
|
151
|
+
const stored = outcome.stored;
|
|
152
|
+
// An agent already waiting in relay_result has the answers, so no message is
|
|
153
|
+
// needed to wake it, and the host does not ask the person to confirm one.
|
|
154
|
+
if (outcome.delivered) {
|
|
155
|
+
submitted = true;
|
|
156
|
+
showDone('delivered');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
149
159
|
const text = stored
|
|
150
160
|
? 'Relay board ' + BOARD.id + ' submitted. Read it with relay_result {"boardId":"' + BOARD.id + '"}.'
|
|
151
161
|
: summarize(data);
|
|
@@ -159,15 +169,16 @@
|
|
|
159
169
|
}
|
|
160
170
|
const messageDelivered = await sendUserMessage(content, text);
|
|
161
171
|
submitted = true;
|
|
162
|
-
showDone(messageDelivered
|
|
172
|
+
showDone(messageDelivered ? 'delivered' : stored ? 'stored' : 'local');
|
|
163
173
|
}
|
|
164
174
|
|
|
175
|
+
/** Stores the answers; `delivered` says a waiting agent already collected them. */
|
|
165
176
|
async function storeSubmission(data) {
|
|
166
177
|
try {
|
|
167
|
-
await callServerTool('relay_submit', { boardId: BOARD.id, token: BOARD.token, payload: data });
|
|
168
|
-
return true;
|
|
178
|
+
const res = await callServerTool('relay_submit', { boardId: BOARD.id, token: BOARD.token, payload: data }, 15000);
|
|
179
|
+
return { stored: true, delivered: res.delivered === true };
|
|
169
180
|
} catch {
|
|
170
|
-
return false;
|
|
181
|
+
return { stored: false, delivered: false };
|
|
171
182
|
}
|
|
172
183
|
}
|
|
173
184
|
|
|
@@ -187,17 +198,25 @@
|
|
|
187
198
|
return false;
|
|
188
199
|
}
|
|
189
200
|
|
|
190
|
-
|
|
201
|
+
// delivery: 'delivered' (the agent has the answers), 'stored' (saved, the agent
|
|
202
|
+
// still needs a nudge) or 'local' (nothing reached the server).
|
|
203
|
+
/** Lucide "check" icon for the done line. */
|
|
204
|
+
function doneMark() {
|
|
205
|
+
const mark = el('span', { class: 'mark', 'aria-hidden': 'true' });
|
|
206
|
+
mark.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="display:block"><path d="M20 6 9 17l-5-5"/></svg>';
|
|
207
|
+
return mark;
|
|
208
|
+
}
|
|
209
|
+
function showDone(delivery) {
|
|
191
210
|
// Collapse: leave fullscreen, drop the whole form for a one-line confirmation
|
|
192
211
|
// so the host shrinks the iframe to a small footprint in the transcript.
|
|
193
212
|
if (Annotate) { try { Annotate.teardown(); } catch { /* nothing to tear down */ } }
|
|
194
213
|
document.documentElement.classList.remove('mcp-fullscreen');
|
|
195
214
|
app.replaceChildren(el('div', { class: 'mcp-done' },
|
|
196
|
-
|
|
215
|
+
doneMark(),
|
|
197
216
|
el('span', { class: 'lead' }, QS.length ? 'Submitted' : 'Acknowledged'),
|
|
198
|
-
el('span', { class: 'sub' },
|
|
217
|
+
el('span', { class: 'sub' }, delivery === 'delivered'
|
|
199
218
|
? '· sent back to the agent'
|
|
200
|
-
:
|
|
219
|
+
: delivery === 'stored'
|
|
201
220
|
? '· saved; send the agent a message to continue'
|
|
202
221
|
: '· tell the agent you’ve responded')));
|
|
203
222
|
// Report the small height immediately, then again next frame / after layout
|
package/src/mcp-ui/index.html
CHANGED
|
@@ -22,7 +22,7 @@ body{ margin:0; }
|
|
|
22
22
|
.mcp-status{ font:13px/1.5 var(--sans, -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif); color:var(--muted,#8a8580); padding:18px 16px; }
|
|
23
23
|
/* post-submit: a slim one-line confirmation so the iframe collapses small */
|
|
24
24
|
.mcp-done{ display:flex; align-items:center; gap:8px; padding:11px 16px; font:14px/1.4 var(--sans, -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif); color:var(--fg,#1c1b19); }
|
|
25
|
-
.mcp-done .mark{
|
|
25
|
+
.mcp-done .mark{ display:inline-flex; color:var(--ok,#4d8a66); }
|
|
26
26
|
.mcp-done .lead{ font-weight:600; }
|
|
27
27
|
.mcp-done .sub{ color:var(--muted,#8a8580); }
|
|
28
28
|
/* Inline in a chat thread the host frames the board and caps its height, so
|
|
@@ -59,6 +59,8 @@ body{ margin:0; }
|
|
|
59
59
|
:root:not(.mcp-fullscreen) .submit{ padding:8px 22px; font-size:.95rem; }
|
|
60
60
|
:root:not(.mcp-fullscreen) .scale-fit{ display:grid; grid-template-columns:repeat(var(--n),minmax(0,1fr)); gap:4px; }
|
|
61
61
|
:root:not(.mcp-fullscreen) .scale-fit button{ width:auto; height:40px; border-radius:8px; }
|
|
62
|
+
/* 8+ steps on a phone narrower than 400px: two even rows keep each step near 44px wide */
|
|
63
|
+
@media (max-width: 400px){ :root:not(.mcp-fullscreen) .scale-long{ grid-template-columns:repeat(var(--half),minmax(0,1fr)); } }
|
|
62
64
|
.scale-ends{ display:flex; justify-content:space-between; gap:12px; margin-top:4px; color:var(--muted); font-size:.8rem; }
|
|
63
65
|
/* Fullscreen keeps 44px steps, so the end labels span the buttons, not the whole column. */
|
|
64
66
|
.mcp-fullscreen .scale-fit{ display:grid; grid-template-columns:repeat(var(--n),44px); gap:8px; }
|
package/types/mcp/constants.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const VENDOR_URI_PREFIX = "ui://relay/vendor/";
|
|
|
5
5
|
export declare const HTTP_PATH = "/mcp";
|
|
6
6
|
export declare const DEFAULT_HTTP_PORT = 4319;
|
|
7
7
|
export declare const VENDOR_CHUNK_BYTES: number;
|
|
8
|
-
export declare const MAX_WAIT_SECONDS =
|
|
8
|
+
export declare const MAX_WAIT_SECONDS = 50;
|
|
9
9
|
export declare const RESULT_BUDGET_BYTES = 2048;
|
|
10
10
|
export declare const TOOL: {
|
|
11
11
|
board: string;
|