@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/types/mcp/store.d.ts
CHANGED
|
@@ -18,7 +18,9 @@ export type BoardRecord = {
|
|
|
18
18
|
events?: any[];
|
|
19
19
|
};
|
|
20
20
|
export type RelayStore = {
|
|
21
|
-
create: (spec: any
|
|
21
|
+
create: (spec: any, options?: {
|
|
22
|
+
fileRoots?: string[];
|
|
23
|
+
}) => BoardRecord | Promise<BoardRecord>;
|
|
22
24
|
get: (id: string) => BoardRecord | null | Promise<BoardRecord | null>;
|
|
23
25
|
update: (id: string, patch: Partial<BoardRecord>) => BoardRecord | null | Promise<BoardRecord | null>;
|
|
24
26
|
};
|
|
@@ -32,17 +34,18 @@ export type RelayStore = {
|
|
|
32
34
|
*/
|
|
33
35
|
/**
|
|
34
36
|
* @typedef {object} RelayStore
|
|
35
|
-
* @property {(spec: any) => BoardRecord | Promise<BoardRecord>} create
|
|
37
|
+
* @property {(spec: any, options?: { fileRoots?: string[] }) => BoardRecord | Promise<BoardRecord>} create
|
|
36
38
|
* @property {(id: string) => BoardRecord | null | Promise<BoardRecord | null>} get
|
|
37
39
|
* @property {(id: string, patch: Partial<BoardRecord>) => BoardRecord | null | Promise<BoardRecord | null>} update
|
|
38
40
|
*/
|
|
39
41
|
/** The default store: one JSON file per board under the relay home, shared with the CLI. */
|
|
40
42
|
export declare function fileStore(): {
|
|
41
|
-
create: (spec: any) => {
|
|
43
|
+
create: (spec: any, options: any) => {
|
|
42
44
|
id: string;
|
|
43
45
|
createdAt: string;
|
|
44
46
|
title: any;
|
|
45
47
|
cwd: string;
|
|
48
|
+
fileRoots: string[];
|
|
46
49
|
spec: any;
|
|
47
50
|
draft: any;
|
|
48
51
|
result: any;
|
package/types/mcp/tools.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @param {any} server an McpServer
|
|
5
5
|
* @param {object} [options]
|
|
6
6
|
* @param {import('./store.js').RelayStore} [options.store] where boards live; defaults to the relay home on disk
|
|
7
|
+
* @param {string[]} [options.fileRoots] folders a spec may read local files from (`codeFile`, images, `rowsFile`...); none by default, so a remote client cannot read the server's disk
|
|
7
8
|
* @param {string | Buffer} [options.tokenKey] the secret behind board tokens; defaults to a key file in the relay home
|
|
8
9
|
* @param {(name: string) => string} [options.assetUrl] URL of a vendor file, for hosts that can fetch it
|
|
9
10
|
* @param {(boardId: string) => string} [options.linkUrl] a URL where a person can open the board outside the host
|
|
@@ -11,6 +12,7 @@
|
|
|
11
12
|
*/
|
|
12
13
|
export declare function registerRelay(server: any, options?: {
|
|
13
14
|
store?: import('./store.js').RelayStore;
|
|
15
|
+
fileRoots?: string[];
|
|
14
16
|
tokenKey?: string | Buffer;
|
|
15
17
|
assetUrl?: (name: string) => string;
|
|
16
18
|
linkUrl?: (boardId: string) => string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export declare function normalizeCodeBlock(rawBlock: any, id: any,
|
|
1
|
+
export declare function normalizeCodeBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
2
2
|
id: any;
|
|
3
3
|
type: string;
|
|
4
4
|
code: any;
|
|
5
5
|
};
|
|
6
|
-
export declare function normalizeDiffBlock(rawBlock: any, id: any,
|
|
6
|
+
export declare function normalizeDiffBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
7
7
|
id: any;
|
|
8
8
|
type: string;
|
|
9
9
|
diff: any;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export declare function normalizeMermaidBlock(rawBlock: any, id: any,
|
|
1
|
+
export declare function normalizeMermaidBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
2
2
|
id: any;
|
|
3
3
|
type: string;
|
|
4
4
|
code: string;
|
|
5
5
|
};
|
|
6
|
-
export declare function normalizeGraphvizBlock(rawBlock: any, id: any,
|
|
6
|
+
export declare function normalizeGraphvizBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
7
7
|
id: any;
|
|
8
8
|
type: string;
|
|
9
9
|
dot: string;
|
|
10
10
|
};
|
|
11
|
-
export declare function normalizePlantumlBlock(rawBlock: any, id: any,
|
|
11
|
+
export declare function normalizePlantumlBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
12
12
|
id: any;
|
|
13
13
|
type: string;
|
|
14
14
|
code: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function normalizeGitConflictBlock(rawBlock: any, id: any,
|
|
1
|
+
export declare function normalizeGitConflictBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
2
2
|
id: any;
|
|
3
3
|
type: string;
|
|
4
4
|
filename: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare function resolveImageSrc(srcRaw: any,
|
|
2
|
-
export declare function normalizeImageBlock(rawBlock: any, id: any,
|
|
1
|
+
export declare function resolveImageSrc(srcRaw: any, files: any, where: any, field: any): string;
|
|
2
|
+
export declare function normalizeImageBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
3
3
|
id: any;
|
|
4
4
|
type: string;
|
|
5
5
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export declare function normalizeKpiBlock(rawBlock: any, id: any,
|
|
1
|
+
export declare function normalizeKpiBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
2
2
|
id: any;
|
|
3
3
|
type: string;
|
|
4
4
|
items: any;
|
|
5
5
|
};
|
|
6
|
-
export declare function normalizeTypographyBlock(rawBlock: any, id: any,
|
|
6
|
+
export declare function normalizeTypographyBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
7
7
|
id: any;
|
|
8
8
|
type: string;
|
|
9
9
|
specimens: any;
|
|
10
10
|
};
|
|
11
|
-
export declare function normalizeCompareBlock(rawBlock: any, id: any,
|
|
11
|
+
export declare function normalizeCompareBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
12
12
|
id: any;
|
|
13
13
|
type: string;
|
|
14
14
|
before: string;
|
|
15
15
|
after: string;
|
|
16
16
|
};
|
|
17
|
-
export declare function normalizePaletteBlock(rawBlock: any, id: any,
|
|
17
|
+
export declare function normalizePaletteBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
18
18
|
id: any;
|
|
19
19
|
type: string;
|
|
20
20
|
palettes: any;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @param {Record<string, any>} raw
|
|
3
|
+
* @param {{ cwd?: string, fileRoots?: string[] }} [options] `fileRoots` limits which local files the spec may read
|
|
4
|
+
* (default: `cwd` only); `[]` allows none, for a spec that came from a remote client.
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeSpec(raw: Record<string, any>, { cwd, fileRoots }?: {
|
|
2
7
|
cwd?: string;
|
|
8
|
+
fileRoots?: string[];
|
|
3
9
|
}): {
|
|
4
10
|
title: string;
|
|
5
11
|
intro: string;
|
package/types/spec/pick.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @param {Record<string, any>} q the question being built
|
|
5
5
|
* @param {Record<string, any>} rq what the agent wrote
|
|
6
6
|
*/
|
|
7
|
-
export declare function normalizePick(q: Record<string, any>, rq: Record<string, any>, where: any,
|
|
7
|
+
export declare function normalizePick(q: Record<string, any>, rq: Record<string, any>, where: any, files: any): void;
|
|
8
8
|
/**
|
|
9
9
|
* The answer to a pick question, cut down to what the question allows: known ids
|
|
10
10
|
* once each, at most `max` of them in the order picked, notes only when the tiles
|
package/types/spec/sources.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export declare const asStr: (v: any) => string;
|
|
2
2
|
export declare function clampInt(v: any, min: any, max: any, def: any): any;
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
3
|
+
/** Reads `htmlFile` through the file roots; an inline `html` string wins. */
|
|
4
|
+
export declare function readHtml(obj: any, files: any, where: any): any;
|
|
5
|
+
export declare function readBlockHtml(block: any, files: any, where: any): any;
|
|
6
|
+
export declare function readTextSource(block: any, inlineKey: any, fileKey: any, files: any, where: any): any;
|
|
7
|
+
export declare function readAnyTextSource(block: any, inlineKeys: any, fileKeys: any, files: any, where: any, label: any): {
|
|
7
8
|
text: string;
|
|
8
9
|
sourceKey: any;
|
|
9
10
|
file?: undefined;
|
package/types/store.d.ts
CHANGED
|
@@ -5,11 +5,20 @@ export declare function ensureDirs(): void;
|
|
|
5
5
|
export declare function newId(): string;
|
|
6
6
|
export declare const artifactDirPath: (id: any) => string;
|
|
7
7
|
export declare function saveBoardArtifact(id: any, bytes: any, ext?: string): string;
|
|
8
|
-
|
|
8
|
+
/** The roots a stored board was created under; a board saved before roots existed keeps its authoring folder. */
|
|
9
|
+
export declare function boardFileRoots(record: any): any;
|
|
10
|
+
/**
|
|
11
|
+
* @param {any} spec a normalized spec
|
|
12
|
+
* @param {{ fileRoots?: string[] }} [options] the roots the spec was read under; the live server opens only files inside them
|
|
13
|
+
*/
|
|
14
|
+
export declare function createBoard(spec: any, { fileRoots }?: {
|
|
15
|
+
fileRoots?: string[];
|
|
16
|
+
}): {
|
|
9
17
|
id: string;
|
|
10
18
|
createdAt: string;
|
|
11
19
|
title: any;
|
|
12
20
|
cwd: string;
|
|
21
|
+
fileRoots: string[];
|
|
13
22
|
spec: any;
|
|
14
23
|
draft: any;
|
|
15
24
|
result: any;
|