@khanglvm/relay 0.22.0 → 0.22.2
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 +4 -1
- package/package.json +2 -2
- package/src/cli/args.js +4 -2
- package/src/cli/ask.js +4 -3
- package/src/cli/boards.js +11 -7
- package/src/cli/git.js +5 -3
- package/src/cli/help.js +3 -1
- package/src/cli/io.js +21 -0
- package/src/cli/mcp.js +20 -1
- package/src/file-access.js +129 -0
- package/src/file-preview.js +1 -1
- package/src/mcp/boards.js +4 -3
- package/src/mcp/serve.js +4 -4
- package/src/mcp/store.js +2 -2
- package/src/mcp/tools.js +2 -1
- package/src/server/board.js +25 -13
- package/src/server/files.js +7 -0
- package/src/server/http.js +13 -4
- package/src/spec/blocks/a2ui.js +1 -1
- package/src/spec/blocks/chart.js +1 -1
- package/src/spec/blocks/code.js +4 -4
- package/src/spec/blocks/diagram.js +3 -3
- package/src/spec/blocks/git-conflict.js +2 -2
- package/src/spec/blocks/image.js +6 -5
- package/src/spec/blocks/markdown.js +2 -2
- package/src/spec/blocks/pdf.js +4 -10
- package/src/spec/blocks/table.js +5 -4
- package/src/spec/blocks/video.js +4 -10
- package/src/spec/blocks/widgets.js +6 -6
- package/src/spec/normalize.js +18 -11
- package/src/spec/pick.js +4 -4
- package/src/spec/sources.js +19 -24
- package/src/store.js +11 -1
- package/types/file-access.d.ts +68 -0
- package/types/mcp/boards.d.ts +2 -1
- package/types/mcp/serve.d.ts +5 -2
- package/types/mcp/store.d.ts +6 -3
- package/types/mcp/tools.d.ts +2 -0
- package/types/spec/blocks/a2ui.d.ts +1 -1
- package/types/spec/blocks/chart.d.ts +1 -1
- package/types/spec/blocks/code.d.ts +2 -2
- package/types/spec/blocks/diagram.d.ts +3 -3
- package/types/spec/blocks/git-conflict.d.ts +1 -1
- package/types/spec/blocks/image.d.ts +2 -2
- package/types/spec/blocks/markdown.d.ts +1 -1
- package/types/spec/blocks/pdf.d.ts +1 -1
- package/types/spec/blocks/table.d.ts +1 -1
- package/types/spec/blocks/video.d.ts +1 -1
- package/types/spec/blocks/widgets.d.ts +4 -4
- package/types/spec/normalize.d.ts +7 -1
- package/types/spec/pick.d.ts +1 -1
- package/types/spec/sources.d.ts +5 -4
- package/types/store.d.ts +10 -1
package/src/spec/blocks/a2ui.js
CHANGED
|
@@ -5,7 +5,7 @@ import { asStr, clampInt } from '../sources.js';
|
|
|
5
5
|
import { BLOCK_HEIGHT } from '../constants.js';
|
|
6
6
|
|
|
7
7
|
// Normalizes one a2ui block. `id` is the already-assigned block id.
|
|
8
|
-
export function normalizeA2uiBlock(rawBlock, id,
|
|
8
|
+
export function normalizeA2uiBlock(rawBlock, id, files, where, hasHeight) {
|
|
9
9
|
// A live A2UI v1.0 widget: Express text (compiled in assertSpecReady) or
|
|
10
10
|
// ready JSON components, checked against Relay's catalog either way.
|
|
11
11
|
const hasExpress = rawBlock.express !== undefined && rawBlock.express !== null;
|
package/src/spec/blocks/chart.js
CHANGED
|
@@ -7,7 +7,7 @@ import { BLOCK_HEIGHT, CHART_KINDS, CHART_KIND_FIELDS, CHART_SERIES_FIELDS } fro
|
|
|
7
7
|
const firstDefined = (raw, names) => raw[names.find((n) => raw[n] !== undefined)];
|
|
8
8
|
|
|
9
9
|
// Normalizes one chart block. `id` is the already-assigned block id.
|
|
10
|
-
export function normalizeChartBlock(raw, id,
|
|
10
|
+
export function normalizeChartBlock(raw, id, files, where, hasHeight) {
|
|
11
11
|
const rawBlock = { ...raw, kind: firstDefined(raw, CHART_KIND_FIELDS), series: firstDefined(raw, CHART_SERIES_FIELDS) };
|
|
12
12
|
const hasConfig = rawBlock.config && typeof rawBlock.config === 'object' && !Array.isArray(rawBlock.config);
|
|
13
13
|
const hasShorthand =
|
package/src/spec/blocks/code.js
CHANGED
|
@@ -5,8 +5,8 @@ import { asStr, clampInt, readTextSource } from '../sources.js';
|
|
|
5
5
|
import { BLOCK_HEIGHT } from '../constants.js';
|
|
6
6
|
|
|
7
7
|
// Normalizes one code block. `id` is the already-assigned block id.
|
|
8
|
-
export function normalizeCodeBlock(rawBlock, id,
|
|
9
|
-
const code = readTextSource(rawBlock, 'code', 'codeFile',
|
|
8
|
+
export function normalizeCodeBlock(rawBlock, id, files, where, hasHeight) {
|
|
9
|
+
const code = readTextSource(rawBlock, 'code', 'codeFile', files, where);
|
|
10
10
|
if (!code) throw new CliError(`${where}: code block needs a "code" string or a readable "codeFile".`);
|
|
11
11
|
const block = { id, type: 'code', code };
|
|
12
12
|
if (rawBlock.lang !== undefined) block.lang = asStr(rawBlock.lang);
|
|
@@ -21,8 +21,8 @@ export function normalizeCodeBlock(rawBlock, id, cwd, where, hasHeight) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Normalizes one diff block. `id` is the already-assigned block id.
|
|
24
|
-
export function normalizeDiffBlock(rawBlock, id,
|
|
25
|
-
const diff = readTextSource(rawBlock, 'diff', 'diffFile',
|
|
24
|
+
export function normalizeDiffBlock(rawBlock, id, files, where, hasHeight) {
|
|
25
|
+
const diff = readTextSource(rawBlock, 'diff', 'diffFile', files, where);
|
|
26
26
|
if (!diff.trim()) throw new CliError(`${where}: diff block needs a non-empty "diff" string (unified diff) or a readable "diffFile".`);
|
|
27
27
|
const block = { id, type: 'diff', diff };
|
|
28
28
|
if (rawBlock.lang !== undefined) block.lang = asStr(rawBlock.lang);
|
|
@@ -4,7 +4,7 @@ import { asStr, clampInt } from '../sources.js';
|
|
|
4
4
|
import { BLOCK_HEIGHT } from '../constants.js';
|
|
5
5
|
|
|
6
6
|
// Normalizes one mermaid block. `id` is the already-assigned block id.
|
|
7
|
-
export function normalizeMermaidBlock(rawBlock, id,
|
|
7
|
+
export function normalizeMermaidBlock(rawBlock, id, files, where, hasHeight) {
|
|
8
8
|
const code = asStr(rawBlock.code);
|
|
9
9
|
if (!code.trim()) throw new CliError(`${where}: mermaid block needs a non-empty "code" string.`);
|
|
10
10
|
const block = { id, type: 'mermaid', code };
|
|
@@ -14,7 +14,7 @@ export function normalizeMermaidBlock(rawBlock, id, cwd, where, hasHeight) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// Normalizes one graphviz block. `id` is the already-assigned block id.
|
|
17
|
-
export function normalizeGraphvizBlock(rawBlock, id,
|
|
17
|
+
export function normalizeGraphvizBlock(rawBlock, id, files, where, hasHeight) {
|
|
18
18
|
const dot = asStr(rawBlock.dot);
|
|
19
19
|
if (!dot.trim()) throw new CliError(`${where}: graphviz block needs a non-empty "dot" string.`);
|
|
20
20
|
const block = { id, type: 'graphviz', dot };
|
|
@@ -23,7 +23,7 @@ export function normalizeGraphvizBlock(rawBlock, id, cwd, where, hasHeight) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// Normalizes one plantuml block. `id` is the already-assigned block id.
|
|
26
|
-
export function normalizePlantumlBlock(rawBlock, id,
|
|
26
|
+
export function normalizePlantumlBlock(rawBlock, id, files, where, hasHeight) {
|
|
27
27
|
const code = asStr(rawBlock.code);
|
|
28
28
|
if (!code.trim()) throw new CliError(`${where}: plantuml block needs a non-empty "code" string.`);
|
|
29
29
|
const block = { id, type: 'plantuml', code };
|
|
@@ -80,8 +80,8 @@ function parseGitConflictContent(content, where) {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// Normalizes one git-conflict block. `id` is the already-assigned block id.
|
|
83
|
-
export function normalizeGitConflictBlock(rawBlock, id,
|
|
84
|
-
const src = readAnyTextSource(rawBlock, ['content', 'text'], ['file', 'path', 'src'],
|
|
83
|
+
export function normalizeGitConflictBlock(rawBlock, id, files, where, hasHeight) {
|
|
84
|
+
const src = readAnyTextSource(rawBlock, ['content', 'text'], ['file', 'path', 'src'], files, where, 'git conflict file');
|
|
85
85
|
if (!src.text.trim()) {
|
|
86
86
|
throw new CliError(`${where}: git-conflict block needs inline "content"/"text" or a readable local "file"/"path".`);
|
|
87
87
|
}
|
package/src/spec/blocks/image.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// The image block, and the image reader that compare blocks share.
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { resolveReadable } from '../../file-access.js';
|
|
4
5
|
import { CliError } from '../../util.js';
|
|
5
6
|
import { asStr, clampInt } from '../sources.js';
|
|
6
7
|
import { BLOCK_HEIGHT, IMAGE_MAX_BYTES, IMAGE_MIMES } from '../constants.js';
|
|
@@ -8,14 +9,14 @@ import { BLOCK_HEIGHT, IMAGE_MAX_BYTES, IMAGE_MIMES } from '../constants.js';
|
|
|
8
9
|
// Resolve an image source (shared by the `image` and `compare` blocks): an
|
|
9
10
|
// http(s)/data URL passes through; a local file is read + embedded as a data
|
|
10
11
|
// URI (capped) so the board stays self-contained offline.
|
|
11
|
-
export function resolveImageSrc(srcRaw,
|
|
12
|
+
export function resolveImageSrc(srcRaw, files, where, field) {
|
|
12
13
|
const src = asStr(srcRaw).trim();
|
|
13
14
|
if (!src) throw new CliError(`${where}: ${field} needs a "src" (http(s)/data URL or local file path).`);
|
|
14
15
|
if (/^(https?:|data:)/i.test(src)) return src;
|
|
15
|
-
const
|
|
16
|
-
const ext = path.extname(p).slice(1).toLowerCase();
|
|
16
|
+
const ext = path.extname(src).slice(1).toLowerCase();
|
|
17
17
|
const mime = IMAGE_MIMES[ext];
|
|
18
18
|
if (!mime) throw new CliError(`${where}: ${field}: unsupported image extension ".${ext}" — use ${Object.keys(IMAGE_MIMES).join('/')}, or an http(s)/data URL.`);
|
|
19
|
+
const { file: p } = resolveReadable(files, src, where, field);
|
|
19
20
|
let buf;
|
|
20
21
|
try { buf = fs.readFileSync(p); } catch { throw new CliError(`${where}: ${field}: cannot read image "${src}" (resolved: ${p})`); }
|
|
21
22
|
if (buf.length > IMAGE_MAX_BYTES) throw new CliError(`${where}: ${field}: image "${src}" is ${(buf.length / 1024 / 1024).toFixed(1)}MB — max ${IMAGE_MAX_BYTES / 1024 / 1024}MB.`);
|
|
@@ -23,9 +24,9 @@ export function resolveImageSrc(srcRaw, cwd, where, field) {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
// Normalizes one image block. `id` is the already-assigned block id.
|
|
26
|
-
export function normalizeImageBlock(rawBlock, id,
|
|
27
|
+
export function normalizeImageBlock(rawBlock, id, files, where, hasHeight) {
|
|
27
28
|
const block = { id, type: 'image' };
|
|
28
|
-
block.src = resolveImageSrc(rawBlock.src ?? rawBlock.file ?? rawBlock.url,
|
|
29
|
+
block.src = resolveImageSrc(rawBlock.src ?? rawBlock.file ?? rawBlock.url, files, where, 'image block');
|
|
29
30
|
if (rawBlock.alt !== undefined) block.alt = asStr(rawBlock.alt);
|
|
30
31
|
if (hasHeight) block.height = clampInt(rawBlock.height, BLOCK_HEIGHT.min, BLOCK_HEIGHT.max, undefined);
|
|
31
32
|
return block;
|
|
@@ -4,8 +4,8 @@ import { clampInt, readTextSource } from '../sources.js';
|
|
|
4
4
|
import { BLOCK_HEIGHT } from '../constants.js';
|
|
5
5
|
|
|
6
6
|
// Normalizes one markdown block. `id` is the already-assigned block id.
|
|
7
|
-
export function normalizeMarkdownBlock(rawBlock, id,
|
|
8
|
-
const md = readTextSource(rawBlock, 'md', 'mdFile',
|
|
7
|
+
export function normalizeMarkdownBlock(rawBlock, id, files, where, hasHeight) {
|
|
8
|
+
const md = readTextSource(rawBlock, 'md', 'mdFile', files, where);
|
|
9
9
|
if (!md.trim()) throw new CliError(`${where}: markdown block needs a non-empty "md" string or a readable "mdFile".`);
|
|
10
10
|
const block = { id, type: 'markdown', md };
|
|
11
11
|
if (hasHeight) block.height = clampInt(rawBlock.height, BLOCK_HEIGHT.min, BLOCK_HEIGHT.max, undefined);
|
package/src/spec/blocks/pdf.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// The pdf block.
|
|
2
|
-
import fs from 'node:fs';
|
|
3
2
|
import path from 'node:path';
|
|
3
|
+
import { resolveReadable } from '../../file-access.js';
|
|
4
4
|
import { CliError } from '../../util.js';
|
|
5
5
|
import { asStr, clampInt } from '../sources.js';
|
|
6
6
|
import { BLOCK_HEIGHT, PDF_MAX_BYTES, PDF_MIME } from '../constants.js';
|
|
7
7
|
|
|
8
8
|
// Normalizes one pdf block. `id` is the already-assigned block id.
|
|
9
|
-
export function normalizePdfBlock(rawBlock, id,
|
|
9
|
+
export function normalizePdfBlock(rawBlock, id, files, where, hasHeight) {
|
|
10
10
|
const src = asStr(rawBlock.src ?? rawBlock.file ?? rawBlock.url).trim();
|
|
11
11
|
if (!src) throw new CliError(`${where}: pdf block needs a "src" (http(s) PDF URL or local .pdf file path).`);
|
|
12
12
|
const block = { id, type: 'pdf' };
|
|
@@ -19,15 +19,9 @@ export function normalizePdfBlock(rawBlock, id, cwd, where, hasHeight) {
|
|
|
19
19
|
if (!block.title) block.title = path.basename(src.split(/[?#]/)[0]) || 'PDF';
|
|
20
20
|
return block;
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
const ext = path.extname(p).slice(1).toLowerCase();
|
|
22
|
+
const ext = path.extname(src).slice(1).toLowerCase();
|
|
24
23
|
if (ext !== 'pdf') throw new CliError(`${where}: unsupported pdf extension ".${ext}" — use a local .pdf file or an http(s) PDF URL.`);
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
stat = fs.statSync(p);
|
|
28
|
-
} catch {
|
|
29
|
-
throw new CliError(`${where}: cannot read pdf "${src}" (resolved: ${p})`);
|
|
30
|
-
}
|
|
24
|
+
const { file: p, stat } = resolveReadable(files, src, where, 'pdf');
|
|
31
25
|
if (stat.size > PDF_MAX_BYTES) {
|
|
32
26
|
throw new CliError(`${where}: pdf "${src}" is ${(stat.size / 1024 / 1024).toFixed(0)}MB — max ${PDF_MAX_BYTES / 1024 / 1024}MB.`);
|
|
33
27
|
}
|
package/src/spec/blocks/table.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// The table block: CSV, TSV and JSON row files, and normalization.
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { resolveReadable } from '../../file-access.js';
|
|
4
5
|
import { CliError } from '../../util.js';
|
|
5
6
|
import { BLOCK_HEIGHT, TEXT_FILE_MAX_BYTES } from '../constants.js';
|
|
6
7
|
import { asStr, clampInt } from '../sources.js';
|
|
@@ -38,8 +39,8 @@ function parseDelimited(text, delim) {
|
|
|
38
39
|
// Load table {columns, rows} from a local .csv/.tsv/.json file (rowsFile).
|
|
39
40
|
// CSV/TSV: first row = header → column keys. JSON: an array of objects (columns
|
|
40
41
|
// from the union of keys) or arrays (needs explicit "columns").
|
|
41
|
-
function loadRowsFile(file,
|
|
42
|
-
const p =
|
|
42
|
+
function loadRowsFile(file, files, where) {
|
|
43
|
+
const { file: p } = resolveReadable(files, file, where, 'rowsFile');
|
|
43
44
|
let buf;
|
|
44
45
|
try { buf = fs.readFileSync(p); } catch { throw new CliError(`${where}: cannot read rowsFile "${file}" (resolved: ${p})`); }
|
|
45
46
|
if (buf.length > TEXT_FILE_MAX_BYTES) {
|
|
@@ -71,12 +72,12 @@ function loadRowsFile(file, cwd, where) {
|
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
// Normalizes one table block. `id` is the already-assigned block id.
|
|
74
|
-
export function normalizeTableBlock(rawBlock, id,
|
|
75
|
+
export function normalizeTableBlock(rawBlock, id, files, where, hasHeight) {
|
|
75
76
|
// Rows/columns may come from a local .csv/.tsv/.json file instead of inline.
|
|
76
77
|
let rawColumns = rawBlock.columns;
|
|
77
78
|
let rawRows = rawBlock.rows;
|
|
78
79
|
if (typeof rawBlock.rowsFile === 'string' && rawBlock.rowsFile.trim() && !Array.isArray(rawRows)) {
|
|
79
|
-
const loaded = loadRowsFile(rawBlock.rowsFile,
|
|
80
|
+
const loaded = loadRowsFile(rawBlock.rowsFile, files, where);
|
|
80
81
|
rawRows = loaded.rows;
|
|
81
82
|
if (!Array.isArray(rawColumns) || !rawColumns.length) rawColumns = loaded.columns;
|
|
82
83
|
}
|
package/src/spec/blocks/video.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The video block: embed detection for YouTube and Vimeo, local and direct media.
|
|
2
|
-
import fs from 'node:fs';
|
|
3
2
|
import path from 'node:path';
|
|
3
|
+
import { resolveReadable } from '../../file-access.js';
|
|
4
4
|
import { CliError } from '../../util.js';
|
|
5
5
|
import { asStr, clampInt } from '../sources.js';
|
|
6
6
|
import { BLOCK_HEIGHT, VIDEO_MAX_BYTES, VIDEO_MIMES } from '../constants.js';
|
|
@@ -24,7 +24,7 @@ function parseVideoEmbed(src) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// Normalizes one video block. `id` is the already-assigned block id.
|
|
27
|
-
export function normalizeVideoBlock(rawBlock, id,
|
|
27
|
+
export function normalizeVideoBlock(rawBlock, id, files, where, hasHeight) {
|
|
28
28
|
const src = asStr(rawBlock.src ?? rawBlock.file ?? rawBlock.url).trim();
|
|
29
29
|
if (!src) throw new CliError(`${where}: video block needs a "src" (YouTube/Vimeo URL, http(s) media URL, or local file path).`);
|
|
30
30
|
const block = { id, type: 'video' };
|
|
@@ -46,18 +46,12 @@ export function normalizeVideoBlock(rawBlock, id, cwd, where, hasHeight) {
|
|
|
46
46
|
}
|
|
47
47
|
// local file — kept as an absolute path the server streams (never embedded
|
|
48
48
|
// in the payload). The client only learns a flag + mime via /video/b/<id>.
|
|
49
|
-
const
|
|
50
|
-
const ext = path.extname(p).slice(1).toLowerCase();
|
|
49
|
+
const ext = path.extname(src).slice(1).toLowerCase();
|
|
51
50
|
const mime = VIDEO_MIMES[ext];
|
|
52
51
|
if (!mime) {
|
|
53
52
|
throw new CliError(`${where}: unsupported video extension ".${ext}" — use ${Object.keys(VIDEO_MIMES).join('/')}, a YouTube/Vimeo URL, or an http(s) media URL.`);
|
|
54
53
|
}
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
stat = fs.statSync(p);
|
|
58
|
-
} catch {
|
|
59
|
-
throw new CliError(`${where}: cannot read video "${src}" (resolved: ${p})`);
|
|
60
|
-
}
|
|
54
|
+
const { file: p, stat } = resolveReadable(files, src, where, 'video');
|
|
61
55
|
if (stat.size > VIDEO_MAX_BYTES) {
|
|
62
56
|
throw new CliError(`${where}: video "${src}" is ${(stat.size / 1024 / 1024).toFixed(0)}MB — max ${VIDEO_MAX_BYTES / 1024 / 1024}MB.`);
|
|
63
57
|
}
|
|
@@ -5,7 +5,7 @@ import { resolveImageSrc } from './image.js';
|
|
|
5
5
|
import { BLOCK_HEIGHT } from '../constants.js';
|
|
6
6
|
|
|
7
7
|
// Normalizes one kpi block. `id` is the already-assigned block id.
|
|
8
|
-
export function normalizeKpiBlock(rawBlock, id,
|
|
8
|
+
export function normalizeKpiBlock(rawBlock, id, files, where, hasHeight) {
|
|
9
9
|
// Stat cards: a row of big-number metrics, each with an optional delta
|
|
10
10
|
// (up/down tinted) and sublabel. For "revenue ↑12%" at a glance, no chart.
|
|
11
11
|
const rawItems = Array.isArray(rawBlock.items) ? rawBlock.items : [];
|
|
@@ -25,7 +25,7 @@ export function normalizeKpiBlock(rawBlock, id, cwd, where, hasHeight) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Normalizes one typography block. `id` is the already-assigned block id.
|
|
28
|
-
export function normalizeTypographyBlock(rawBlock, id,
|
|
28
|
+
export function normalizeTypographyBlock(rawBlock, id, files, where, hasHeight) {
|
|
29
29
|
// Type specimens: render sample text at given size/weight/font so a designer
|
|
30
30
|
// can react to type choices the way they react to a palette.
|
|
31
31
|
const raw = Array.isArray(rawBlock.specimens) ? rawBlock.specimens : (Array.isArray(rawBlock.samples) ? rawBlock.samples : []);
|
|
@@ -50,14 +50,14 @@ export function normalizeTypographyBlock(rawBlock, id, cwd, where, hasHeight) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// Normalizes one compare block. `id` is the already-assigned block id.
|
|
53
|
-
export function normalizeCompareBlock(rawBlock, id,
|
|
53
|
+
export function normalizeCompareBlock(rawBlock, id, files, where, hasHeight) {
|
|
54
54
|
// Before/after: two images with a draggable divider to compare a redesign.
|
|
55
55
|
const beforeRaw = rawBlock.before && typeof rawBlock.before === 'object' ? rawBlock.before.src : (rawBlock.before ?? rawBlock.beforeSrc);
|
|
56
56
|
const afterRaw = rawBlock.after && typeof rawBlock.after === 'object' ? rawBlock.after.src : (rawBlock.after ?? rawBlock.afterSrc);
|
|
57
57
|
const block = {
|
|
58
58
|
id, type: 'compare',
|
|
59
|
-
before: resolveImageSrc(beforeRaw,
|
|
60
|
-
after: resolveImageSrc(afterRaw,
|
|
59
|
+
before: resolveImageSrc(beforeRaw, files, where, '"before"'),
|
|
60
|
+
after: resolveImageSrc(afterRaw, files, where, '"after"'),
|
|
61
61
|
};
|
|
62
62
|
block.beforeLabel = asStr(rawBlock.beforeLabel ?? (rawBlock.before && rawBlock.before.label) ?? 'Before') || 'Before';
|
|
63
63
|
block.afterLabel = asStr(rawBlock.afterLabel ?? (rawBlock.after && rawBlock.after.label) ?? 'After') || 'After';
|
|
@@ -66,7 +66,7 @@ export function normalizeCompareBlock(rawBlock, id, cwd, where, hasHeight) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// Normalizes one palette block. `id` is the already-assigned block id.
|
|
69
|
-
export function normalizePaletteBlock(rawBlock, id,
|
|
69
|
+
export function normalizePaletteBlock(rawBlock, id, files, where, hasHeight) {
|
|
70
70
|
// Accept either { palettes: [{name, colors:[…]}, …] } or a single-palette
|
|
71
71
|
// shorthand { name?, colors:[…] }. Each palette needs a non-empty colors
|
|
72
72
|
// array of CSS color strings (#rrggbb, rgb(), hsl(), named — kept as given).
|
package/src/spec/normalize.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Turns an agent-written spec into the normalized shape that boards,
|
|
2
2
|
// the server and the MCP App read.
|
|
3
|
+
import { createFileAccess } from '../file-access.js';
|
|
3
4
|
import { CliError } from '../util.js';
|
|
4
5
|
import { asStr, clampInt, readBlockHtml, readHtml } from './sources.js';
|
|
5
6
|
import { ALIASES, BLOCK_ALIASES, BLOCK_HEIGHT, BLOCK_TYPES, CHART_KINDS, HTML_HEIGHT, TYPES } from './constants.js';
|
|
@@ -8,7 +9,7 @@ import { normalizePick } from './pick.js';
|
|
|
8
9
|
|
|
9
10
|
// Normalizes one block object. `id` is the already-assigned block id.
|
|
10
11
|
// Returns the normalized block (with a guaranteed string `type` + `id`).
|
|
11
|
-
function normalizeBlock(rawBlock, id,
|
|
12
|
+
function normalizeBlock(rawBlock, id, files, where) {
|
|
12
13
|
if (rawBlock === null || typeof rawBlock !== 'object' || Array.isArray(rawBlock)) {
|
|
13
14
|
throw new CliError(`${where}: must be an object with a "type".`);
|
|
14
15
|
}
|
|
@@ -59,9 +60,9 @@ function normalizeBlock(rawBlock, id, cwd, where) {
|
|
|
59
60
|
|
|
60
61
|
// type === 'html'
|
|
61
62
|
const normalizer = BLOCK_NORMALIZERS[type];
|
|
62
|
-
if (normalizer) return normalizer(rawBlock, id,
|
|
63
|
+
if (normalizer) return normalizer(rawBlock, id, files, where, hasHeight);
|
|
63
64
|
|
|
64
|
-
const html = readBlockHtml(rawBlock,
|
|
65
|
+
const html = readBlockHtml(rawBlock, files, where);
|
|
65
66
|
if (!html) {
|
|
66
67
|
throw new CliError(`${where}: html block needs an "html" string or readable "htmlFile".`);
|
|
67
68
|
}
|
|
@@ -76,13 +77,13 @@ function normalizeBlock(rawBlock, id, cwd, where) {
|
|
|
76
77
|
// Builds the normalized block list for a scope (board or question).
|
|
77
78
|
// Legacy html/htmlFile become a PREPENDED html block; ids are assigned in
|
|
78
79
|
// final order with `prefix` ('' for board → b1,b2…; '<qid>-' for questions).
|
|
79
|
-
function buildBlocks(rawObj,
|
|
80
|
+
function buildBlocks(rawObj, files, where, prefix) {
|
|
80
81
|
const blocks = [];
|
|
81
82
|
let n = 0;
|
|
82
83
|
const nextId = () => `${prefix}b${++n}`;
|
|
83
84
|
|
|
84
85
|
// Legacy html/htmlFile → a single prepended html block. htmlHeight applies.
|
|
85
|
-
const legacyHtml = readHtml(rawObj,
|
|
86
|
+
const legacyHtml = readHtml(rawObj, files, where);
|
|
86
87
|
if (legacyHtml) {
|
|
87
88
|
const def = prefix ? HTML_HEIGHT.questionDefault : HTML_HEIGHT.boardDefault;
|
|
88
89
|
blocks.push({
|
|
@@ -96,7 +97,7 @@ function buildBlocks(rawObj, cwd, where, prefix) {
|
|
|
96
97
|
if (rawObj.blocks !== undefined && rawObj.blocks !== null) {
|
|
97
98
|
if (!Array.isArray(rawObj.blocks)) throw new CliError(`${where}.blocks: must be an array.`);
|
|
98
99
|
rawObj.blocks.forEach((b, i) => {
|
|
99
|
-
const nb = normalizeBlock(b, nextId(),
|
|
100
|
+
const nb = normalizeBlock(b, nextId(), files, `${where}.blocks[${i}]`);
|
|
100
101
|
// Cross-block fields handled uniformly so every block type supports them:
|
|
101
102
|
// `ref` = a stable name a markdown reference link can open in a modal;
|
|
102
103
|
// `pins` = enable coordinate pin-comments on an image.
|
|
@@ -110,14 +111,20 @@ function buildBlocks(rawObj, cwd, where, prefix) {
|
|
|
110
111
|
return blocks;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
/**
|
|
115
|
+
* @param {Record<string, any>} raw
|
|
116
|
+
* @param {{ cwd?: string, fileRoots?: string[] }} [options] `fileRoots` limits which local files the spec may read
|
|
117
|
+
* (default: `cwd` only); `[]` allows none, for a spec that came from a remote client.
|
|
118
|
+
*/
|
|
119
|
+
export function normalizeSpec(raw, { cwd = process.cwd(), fileRoots = [cwd] } = {}) {
|
|
120
|
+
const files = createFileAccess({ cwd, roots: fileRoots });
|
|
114
121
|
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
115
122
|
throw new CliError('Spec must be a JSON object. Run `rly agent` for the schema and examples.');
|
|
116
123
|
}
|
|
117
124
|
const spec = {
|
|
118
125
|
title: asStr(raw.title).trim() || 'Relay',
|
|
119
126
|
intro: asStr(raw.intro),
|
|
120
|
-
blocks: buildBlocks(raw,
|
|
127
|
+
blocks: buildBlocks(raw, files, 'board', ''),
|
|
121
128
|
allowPartial: raw.allowPartial !== false,
|
|
122
129
|
note: raw.note !== false,
|
|
123
130
|
autoClose: raw.autoClose !== false,
|
|
@@ -160,7 +167,7 @@ export function normalizeSpec(raw, { cwd = process.cwd() } = {}) {
|
|
|
160
167
|
note: rq.note === undefined
|
|
161
168
|
? (type === 'single' || type === 'rank' || type === 'checklist' || type === 'allocate')
|
|
162
169
|
: rq.note === true,
|
|
163
|
-
blocks: buildBlocks(rq,
|
|
170
|
+
blocks: buildBlocks(rq, files, where, `${id}-`),
|
|
164
171
|
placeholder: asStr(rq.placeholder),
|
|
165
172
|
};
|
|
166
173
|
|
|
@@ -179,7 +186,7 @@ export function normalizeSpec(raw, { cwd = process.cwd() } = {}) {
|
|
|
179
186
|
// Per-option visuals: any block type, rendered inside the option card
|
|
180
187
|
// (ids <qid>-o<n>-b<m>). Lets a choice show its example instead of
|
|
181
188
|
// making the user read-and-guess.
|
|
182
|
-
const oblocks = buildBlocks(o,
|
|
189
|
+
const oblocks = buildBlocks(o, files, `${where}.options[${j}]`, `${id}-o${j + 1}-`);
|
|
183
190
|
if (oblocks.length) out.blocks = oblocks;
|
|
184
191
|
return out;
|
|
185
192
|
}
|
|
@@ -198,7 +205,7 @@ export function normalizeSpec(raw, { cwd = process.cwd() } = {}) {
|
|
|
198
205
|
}
|
|
199
206
|
}
|
|
200
207
|
|
|
201
|
-
if (type === 'pick') normalizePick(q, rq, where,
|
|
208
|
+
if (type === 'pick') normalizePick(q, rq, where, files);
|
|
202
209
|
|
|
203
210
|
if (type === 'checklist') {
|
|
204
211
|
// Per-item status control. Default Pass / Fail / N/A; override with
|
package/src/spec/pick.js
CHANGED
|
@@ -15,7 +15,7 @@ function httpUrl(raw, where, field) {
|
|
|
15
15
|
return url;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function normalizeTile(raw, j, where,
|
|
18
|
+
function normalizeTile(raw, j, where, files) {
|
|
19
19
|
if (typeof raw === 'string' || typeof raw === 'number') return { id: String(raw), title: String(raw) };
|
|
20
20
|
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
21
21
|
throw new CliError(`${where}.items[${j}]: must be a string or {id, title, image?, video?, url?, caption?}.`);
|
|
@@ -28,7 +28,7 @@ function normalizeTile(raw, j, where, cwd) {
|
|
|
28
28
|
const caption = asStr(raw.caption ?? raw.description).trim();
|
|
29
29
|
if (caption) tile.caption = caption;
|
|
30
30
|
const image = raw.image ?? raw.src ?? raw.img;
|
|
31
|
-
if (image !== undefined && image !== null && image !== '') tile.image = resolveImageSrc(image,
|
|
31
|
+
if (image !== undefined && image !== null && image !== '') tile.image = resolveImageSrc(image, files, at, '"image"');
|
|
32
32
|
if (raw.video !== undefined && raw.video !== null && raw.video !== '') tile.video = httpUrl(raw.video, at, 'video');
|
|
33
33
|
if (raw.url !== undefined && raw.url !== null && raw.url !== '') tile.url = httpUrl(raw.url, at, 'url');
|
|
34
34
|
return tile;
|
|
@@ -40,11 +40,11 @@ function normalizeTile(raw, j, where, cwd) {
|
|
|
40
40
|
* @param {Record<string, any>} q the question being built
|
|
41
41
|
* @param {Record<string, any>} rq what the agent wrote
|
|
42
42
|
*/
|
|
43
|
-
export function normalizePick(q, rq, where,
|
|
43
|
+
export function normalizePick(q, rq, where, files) {
|
|
44
44
|
const rawItems = Array.isArray(rq.items) ? rq.items : Array.isArray(rq.options) ? rq.options : Array.isArray(rq.choices) ? rq.choices : [];
|
|
45
45
|
if (!rawItems.length) throw new CliError(`${where}: type "pick" needs "items", the tiles to choose among: [{id, title, image?, video?, url?, caption?}].`);
|
|
46
46
|
if (rawItems.length > PICK.maxItems) throw new CliError(`${where}: a pick takes at most ${PICK.maxItems} items.`);
|
|
47
|
-
q.items = rawItems.map((raw, j) => normalizeTile(raw, j, where,
|
|
47
|
+
q.items = rawItems.map((raw, j) => normalizeTile(raw, j, where, files));
|
|
48
48
|
const seen = new Set();
|
|
49
49
|
for (const tile of q.items) {
|
|
50
50
|
if (seen.has(tile.id)) throw new CliError(`${where}: duplicate item id "${tile.id}".`);
|
package/src/spec/sources.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Readers for text that a block takes inline or from a file next to the spec.
|
|
2
2
|
import fs from 'node:fs';
|
|
3
|
-
import
|
|
3
|
+
import { resolveReadable } from '../file-access.js';
|
|
4
4
|
import { CliError } from '../util.js';
|
|
5
5
|
import { TEXT_FILE_MAX_BYTES } from './constants.js';
|
|
6
6
|
|
|
@@ -12,40 +12,35 @@ export function clampInt(v, min, max, def) {
|
|
|
12
12
|
return Math.min(max, Math.max(min, n));
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
/** Reads `htmlFile` through the file roots; an inline `html` string wins. */
|
|
16
|
+
export function readHtml(obj, files, where) {
|
|
16
17
|
if (typeof obj.html === 'string' && obj.html.trim()) return obj.html;
|
|
17
|
-
|
|
18
|
-
const p = path.resolve(cwd, obj.htmlFile);
|
|
19
|
-
try {
|
|
20
|
-
return fs.readFileSync(p, 'utf8');
|
|
21
|
-
} catch {
|
|
22
|
-
throw new CliError(`${where}: cannot read htmlFile "${obj.htmlFile}" (resolved: ${p})`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return '';
|
|
18
|
+
return readHtmlFile(obj, files, where);
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
// Reads an html-block body from either an inline string or a file path.
|
|
29
|
-
export function readBlockHtml(block,
|
|
22
|
+
export function readBlockHtml(block, files, where) {
|
|
30
23
|
if (typeof block.html === 'string' && block.html) return block.html;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
return readHtmlFile(block, files, where);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function readHtmlFile(obj, files, where) {
|
|
28
|
+
if (typeof obj.htmlFile !== 'string' || !obj.htmlFile.trim()) return '';
|
|
29
|
+
const { file } = resolveReadable(files, obj.htmlFile, where, 'htmlFile');
|
|
30
|
+
try {
|
|
31
|
+
return fs.readFileSync(file, 'utf8');
|
|
32
|
+
} catch {
|
|
33
|
+
throw new CliError(`${where}: cannot read htmlFile "${obj.htmlFile}" (resolved: ${file})`);
|
|
38
34
|
}
|
|
39
|
-
return '';
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
// Reads a code/diff block body from an inline string field or a local file.
|
|
43
38
|
// `inlineKey` is the inline field (e.g. "code"/"diff"); `fileKey` its file
|
|
44
39
|
// twin (e.g. "codeFile"/"diffFile"). Returns '' when neither is present.
|
|
45
|
-
export function readTextSource(block, inlineKey, fileKey,
|
|
40
|
+
export function readTextSource(block, inlineKey, fileKey, files, where) {
|
|
46
41
|
if (typeof block[inlineKey] === 'string' && block[inlineKey] !== '') return block[inlineKey];
|
|
47
42
|
if (typeof block[fileKey] === 'string' && block[fileKey].trim()) {
|
|
48
|
-
const p =
|
|
43
|
+
const { file: p } = resolveReadable(files, block[fileKey], where, fileKey);
|
|
49
44
|
let buf;
|
|
50
45
|
try {
|
|
51
46
|
buf = fs.readFileSync(p);
|
|
@@ -60,13 +55,13 @@ export function readTextSource(block, inlineKey, fileKey, cwd, where) {
|
|
|
60
55
|
return '';
|
|
61
56
|
}
|
|
62
57
|
|
|
63
|
-
export function readAnyTextSource(block, inlineKeys, fileKeys,
|
|
58
|
+
export function readAnyTextSource(block, inlineKeys, fileKeys, files, where, label) {
|
|
64
59
|
for (const key of inlineKeys) {
|
|
65
60
|
if (typeof block[key] === 'string' && block[key] !== '') return { text: block[key], sourceKey: key };
|
|
66
61
|
}
|
|
67
62
|
for (const key of fileKeys) {
|
|
68
63
|
if (typeof block[key] === 'string' && block[key].trim()) {
|
|
69
|
-
const p =
|
|
64
|
+
const { file: p } = resolveReadable(files, block[key], where, label);
|
|
70
65
|
let buf;
|
|
71
66
|
try {
|
|
72
67
|
buf = fs.readFileSync(p);
|
package/src/store.js
CHANGED
|
@@ -36,7 +36,16 @@ export function saveBoardArtifact(id, bytes, ext = 'png') {
|
|
|
36
36
|
return target;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
/** The roots a stored board was created under; a board saved before roots existed keeps its authoring folder. */
|
|
40
|
+
export function boardFileRoots(record) {
|
|
41
|
+
return Array.isArray(record.fileRoots) ? record.fileRoots : [record.cwd || process.cwd()];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {any} spec a normalized spec
|
|
46
|
+
* @param {{ fileRoots?: string[] }} [options] the roots the spec was read under; the live server opens only files inside them
|
|
47
|
+
*/
|
|
48
|
+
export function createBoard(spec, { fileRoots } = {}) {
|
|
40
49
|
ensureDirs();
|
|
41
50
|
const record = {
|
|
42
51
|
id: newId(),
|
|
@@ -46,6 +55,7 @@ export function createBoard(spec) {
|
|
|
46
55
|
// writes into the spec (markdown links, ~/… paths) resolve against this, so
|
|
47
56
|
// the live server can open them in the user's default app (POST /api/open).
|
|
48
57
|
cwd: process.cwd(),
|
|
58
|
+
fileRoots: fileRoots ?? [process.cwd()],
|
|
49
59
|
spec,
|
|
50
60
|
draft: null,
|
|
51
61
|
result: null,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
export type FileAccess = {
|
|
3
|
+
/**
|
|
4
|
+
* Directory that relative spec paths resolve against.
|
|
5
|
+
*/
|
|
6
|
+
cwd: string;
|
|
7
|
+
/**
|
|
8
|
+
* Real paths a spec may read from; a root may be a single file.
|
|
9
|
+
*/
|
|
10
|
+
roots: string[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} FileAccess
|
|
14
|
+
* @property {string} cwd Directory that relative spec paths resolve against.
|
|
15
|
+
* @property {string[]} roots Real paths a spec may read from; a root may be a single file.
|
|
16
|
+
*/
|
|
17
|
+
/** Env var with extra roots, separated by the platform's path delimiter (":" on macOS and Linux). */
|
|
18
|
+
export declare const FILE_ROOTS_ENV = "RLY_FILE_ROOTS";
|
|
19
|
+
/** Expands a leading `~` to the home directory. */
|
|
20
|
+
export declare function expandHome(p: any): any;
|
|
21
|
+
/** Real paths of the roots that exist; a root that does not exist grants nothing. */
|
|
22
|
+
export declare function realRoots(list: any, cwd: any): any[];
|
|
23
|
+
/**
|
|
24
|
+
* True when `dir` is a filesystem root or the home directory. Such a folder is
|
|
25
|
+
* too wide to grant by default: a desktop host often starts a stdio server at
|
|
26
|
+
* `/`, which would let a spec read the whole disk. Passing it as `--root` still works.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isBroadRoot(dir: any): boolean;
|
|
29
|
+
/** Roots named by `RLY_FILE_ROOTS`. */
|
|
30
|
+
export declare function envFileRoots(env?: NodeJS.ProcessEnv): string[];
|
|
31
|
+
/**
|
|
32
|
+
* @param {{ cwd?: string, roots?: string[] }} [options] `roots` of `[]` means no local file may be read.
|
|
33
|
+
* @returns {FileAccess}
|
|
34
|
+
*/
|
|
35
|
+
export declare function createFileAccess({ cwd, roots }?: {
|
|
36
|
+
cwd?: string;
|
|
37
|
+
roots?: string[];
|
|
38
|
+
}): FileAccess;
|
|
39
|
+
/** True when `target` is a root or lies under one. Both are real paths. */
|
|
40
|
+
export declare function isInsideRoots(target: any, roots: any): any;
|
|
41
|
+
/**
|
|
42
|
+
* Resolves a path a spec names and says whether it may be read.
|
|
43
|
+
* @param {FileAccess} access
|
|
44
|
+
* @param {unknown} raw the path as written; `~` and relative paths are expanded
|
|
45
|
+
* @param {{ allowDirectory?: boolean }} [options] directories are refused unless a caller opens them in an app
|
|
46
|
+
* @returns {{ ok: boolean, file?: string, stat?: fs.Stats, reason?: 'invalid' | 'outside' | 'missing' | 'not-file', resolved?: string }} `file` and `stat` when ok; otherwise `reason` and the real path it was refused at
|
|
47
|
+
*/
|
|
48
|
+
export declare function checkReadable(access: FileAccess, raw: unknown, { allowDirectory }?: {
|
|
49
|
+
allowDirectory?: boolean;
|
|
50
|
+
}): {
|
|
51
|
+
ok: boolean;
|
|
52
|
+
file?: string;
|
|
53
|
+
stat?: fs.Stats;
|
|
54
|
+
reason?: 'invalid' | 'outside' | 'missing' | 'not-file';
|
|
55
|
+
resolved?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* The real path of a file a spec names, or a CliError worded for the agent.
|
|
59
|
+
* @param {FileAccess} access
|
|
60
|
+
* @param {unknown} raw
|
|
61
|
+
* @param {string} where which block, e.g. `board.blocks[0]`
|
|
62
|
+
* @param {string} field which field, e.g. `codeFile`
|
|
63
|
+
* @returns {{ file: string, stat: fs.Stats }}
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveReadable(access: FileAccess, raw: unknown, where: string, field: string): {
|
|
66
|
+
file: string;
|
|
67
|
+
stat: fs.Stats;
|
|
68
|
+
};
|
package/types/mcp/boards.d.ts
CHANGED
|
@@ -5,10 +5,11 @@ export declare const modeOf: (spec: any) => "ask" | "show";
|
|
|
5
5
|
* CliError so the tool can answer with an isError result the model can fix.
|
|
6
6
|
* @param {import('./store.js').RelayStore} store
|
|
7
7
|
* @param {Record<string, any>} args
|
|
8
|
-
* @param {{ displayOnly?: boolean }} [options]
|
|
8
|
+
* @param {{ displayOnly?: boolean, fileRoots?: string[] }} [options] `fileRoots` are the only places a spec may read local files from; none by default
|
|
9
9
|
*/
|
|
10
10
|
export declare function createMcpBoard(store: import('./store.js').RelayStore, args: Record<string, any>, options?: {
|
|
11
11
|
displayOnly?: boolean;
|
|
12
|
+
fileRoots?: string[];
|
|
12
13
|
}): Promise<{
|
|
13
14
|
record: import("./store.js").BoardRecord;
|
|
14
15
|
spec: {
|
package/types/mcp/serve.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Serves MCP over this process's stdin and stdout until the host closes stdin. */
|
|
2
|
-
export declare function runMcp(
|
|
2
|
+
export declare function runMcp({ fileRoots }?: {
|
|
3
|
+
fileRoots?: any[];
|
|
4
|
+
}): Promise<any>;
|
|
3
5
|
/** A browser Origin is trusted when it is local or the one the operator allowed. A client with no Origin is not a browser. */
|
|
4
6
|
export declare function originAllowed(origin: any, allowOrigin: any): boolean;
|
|
5
7
|
/** Constant-time string comparison for the bearer token. */
|
|
@@ -8,8 +10,9 @@ export declare function safeEqual(a: any, b: any): boolean;
|
|
|
8
10
|
* Serves MCP over Streamable HTTP. Localhost by default; a bearer token and an
|
|
9
11
|
* allowed Origin are the controls for anything wider.
|
|
10
12
|
*/
|
|
11
|
-
export declare function runMcpHttp({ port, host, token, allowOrigin }?: {
|
|
13
|
+
export declare function runMcpHttp({ port, host, token, allowOrigin, fileRoots }?: {
|
|
12
14
|
allowOrigin?: string;
|
|
15
|
+
fileRoots?: any[];
|
|
13
16
|
host?: string;
|
|
14
17
|
port?: number;
|
|
15
18
|
token?: string;
|