@khanglvm/relay 0.22.1 → 0.23.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/README.md +7 -0
- package/docs/AGENT.md +7 -2
- package/docs/SETUP.md +7 -0
- package/package.json +2 -2
- package/src/cli/args.js +1 -1
- package/src/cli/boards.js +5 -4
- package/src/cli/help.js +3 -1
- package/src/cli/mcp.js +19 -2
- package/src/file-access.js +91 -12
- package/src/file-preview.js +9 -7
- package/src/mcp/boards.js +1 -0
- package/src/mcp/serve.js +9 -5
- package/src/mcp/server.js +5 -1
- package/src/mcp/store.js +6 -3
- package/src/mcp/tools.js +2 -1
- package/src/mcp-ui/board/draft.js +30 -0
- package/src/mcp-ui/board/lifecycle.js +4 -3
- package/src/mcp-ui/board/state.js +4 -0
- package/src/retention.js +116 -0
- package/src/server/board.js +21 -27
- package/src/server/files.js +50 -20
- package/src/server/http.js +13 -4
- package/src/spec/blocks/image.js +2 -5
- package/src/spec/blocks/table.js +2 -5
- package/src/spec/sources.js +4 -22
- package/src/store.js +48 -6
- package/src/ui/manifest.js +1 -0
- package/types/file-access.d.ts +43 -3
- package/types/mcp/serve.d.ts +13 -7
- package/types/mcp/store.d.ts +7 -2
- package/types/mcp/tools.d.ts +2 -0
- package/types/retention.d.ts +33 -0
- package/types/spec/blocks/code.d.ts +2 -2
- package/types/spec/blocks/markdown.d.ts +1 -1
- package/types/spec/sources.d.ts +2 -2
- package/types/store.d.ts +13 -2
package/types/mcp/serve.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Serves MCP over this process's stdin and stdout until the host closes stdin.
|
|
3
|
+
* @param {{ fileRoots?: string[], retentionDays?: string | number }} [options]
|
|
4
|
+
*/
|
|
5
|
+
export declare function runMcp({ fileRoots, retentionDays }?: {
|
|
6
|
+
fileRoots?: string[];
|
|
7
|
+
retentionDays?: string | number;
|
|
4
8
|
}): Promise<any>;
|
|
5
9
|
/** A browser Origin is trusted when it is local or the one the operator allowed. A client with no Origin is not a browser. */
|
|
6
10
|
export declare function originAllowed(origin: any, allowOrigin: any): boolean;
|
|
@@ -9,11 +13,13 @@ export declare function safeEqual(a: any, b: any): boolean;
|
|
|
9
13
|
/**
|
|
10
14
|
* Serves MCP over Streamable HTTP. Localhost by default; a bearer token and an
|
|
11
15
|
* allowed Origin are the controls for anything wider.
|
|
16
|
+
* @param {{ port?: number, host?: string, token?: string, allowOrigin?: string, fileRoots?: string[], retentionDays?: string | number }} [options]
|
|
12
17
|
*/
|
|
13
|
-
export declare function runMcpHttp({ port, host, token, allowOrigin, fileRoots }?: {
|
|
14
|
-
allowOrigin?: string;
|
|
15
|
-
fileRoots?: any[];
|
|
16
|
-
host?: string;
|
|
18
|
+
export declare function runMcpHttp({ port, host, token, allowOrigin, fileRoots, retentionDays }?: {
|
|
17
19
|
port?: number;
|
|
20
|
+
host?: string;
|
|
18
21
|
token?: string;
|
|
22
|
+
allowOrigin?: string;
|
|
23
|
+
fileRoots?: string[];
|
|
24
|
+
retentionDays?: string | number;
|
|
19
25
|
}): Promise<any>;
|
package/types/mcp/store.d.ts
CHANGED
|
@@ -38,8 +38,13 @@ export type RelayStore = {
|
|
|
38
38
|
* @property {(id: string) => BoardRecord | null | Promise<BoardRecord | null>} get
|
|
39
39
|
* @property {(id: string, patch: Partial<BoardRecord>) => BoardRecord | null | Promise<BoardRecord | null>} update
|
|
40
40
|
*/
|
|
41
|
-
/**
|
|
42
|
-
|
|
41
|
+
/**
|
|
42
|
+
* The default store: one JSON file per board under the relay home, shared with the CLI.
|
|
43
|
+
* @param {{ retentionDays?: number | string | boolean }} [options] how long old boards stay; see `resolveRetentionDays`
|
|
44
|
+
*/
|
|
45
|
+
export declare function fileStore({ retentionDays }?: {
|
|
46
|
+
retentionDays?: number | string | boolean;
|
|
47
|
+
}): {
|
|
43
48
|
create: (spec: any, options: any) => {
|
|
44
49
|
id: string;
|
|
45
50
|
createdAt: string;
|
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 {number | string | boolean} [options.retentionDays] with the default store, boards unchanged for this many days are removed when a new board is made (default 30; `0`, `false` or "off" keeps every board). `RLY_RETENTION_DAYS` sets it when the option is absent. A custom `store` does its own cleanup
|
|
7
8
|
* @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
|
|
8
9
|
* @param {string | Buffer} [options.tokenKey] the secret behind board tokens; defaults to a key file in the relay home
|
|
9
10
|
* @param {(name: string) => string} [options.assetUrl] URL of a vendor file, for hosts that can fetch it
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
*/
|
|
13
14
|
export declare function registerRelay(server: any, options?: {
|
|
14
15
|
store?: import('./store.js').RelayStore;
|
|
16
|
+
retentionDays?: number | string | boolean;
|
|
15
17
|
fileRoots?: string[];
|
|
16
18
|
tokenKey?: string | Buffer;
|
|
17
19
|
assetUrl?: (name: string) => string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const RETENTION_ENV = "RLY_RETENTION_DAYS";
|
|
2
|
+
export declare const DEFAULT_RETENTION_DAYS = 30;
|
|
3
|
+
/**
|
|
4
|
+
* The retention window in days; 0 means boards are kept forever.
|
|
5
|
+
* The option wins over `RLY_RETENTION_DAYS`, which wins over the 30-day default.
|
|
6
|
+
* @param {unknown} [option] a number of days, a numeric string, or `0`, `false` or "off" to keep every board
|
|
7
|
+
* @param {Record<string, string | undefined>} [env]
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveRetentionDays(option?: unknown, env?: Record<string, string | undefined>): number;
|
|
10
|
+
/**
|
|
11
|
+
* Removes boards whose files have not changed for `days`. Several processes can
|
|
12
|
+
* share one relay home: a lock directory keeps two sweeps apart, and a stamp
|
|
13
|
+
* file keeps a busy home from sweeping on every new board. A board a running
|
|
14
|
+
* server still serves, and any board younger than the window, stays.
|
|
15
|
+
* @param {object} options
|
|
16
|
+
* @param {string} options.home the relay home; holds the lock and the stamp
|
|
17
|
+
* @param {string} options.boardsDir
|
|
18
|
+
* @param {number} options.days window in days; 0 or less does nothing
|
|
19
|
+
* @param {Set<string>} [options.keep] ids that must stay, such as boards with a live server
|
|
20
|
+
* @param {(id: string) => boolean} options.remove deletes one board and its sidecar files
|
|
21
|
+
* @param {number} [options.now] ms since the epoch
|
|
22
|
+
* @param {boolean} [options.force] sweep even when one ran in the last hour
|
|
23
|
+
* @returns {string[]} the ids removed
|
|
24
|
+
*/
|
|
25
|
+
export declare function pruneBoards({ home, boardsDir, days, keep, remove, now, force }: {
|
|
26
|
+
home: string;
|
|
27
|
+
boardsDir: string;
|
|
28
|
+
days: number;
|
|
29
|
+
keep?: Set<string>;
|
|
30
|
+
remove: (id: string) => boolean;
|
|
31
|
+
now?: number;
|
|
32
|
+
force?: boolean;
|
|
33
|
+
}): string[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare function normalizeCodeBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
2
2
|
id: any;
|
|
3
3
|
type: string;
|
|
4
|
-
code:
|
|
4
|
+
code: string;
|
|
5
5
|
};
|
|
6
6
|
export declare function normalizeDiffBlock(rawBlock: any, id: any, files: any, where: any, hasHeight: any): {
|
|
7
7
|
id: any;
|
|
8
8
|
type: string;
|
|
9
|
-
diff:
|
|
9
|
+
diff: string;
|
|
10
10
|
};
|
package/types/spec/sources.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ export declare function clampInt(v: any, min: any, max: any, def: any): any;
|
|
|
3
3
|
/** Reads `htmlFile` through the file roots; an inline `html` string wins. */
|
|
4
4
|
export declare function readHtml(obj: any, files: any, where: any): any;
|
|
5
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):
|
|
6
|
+
export declare function readTextSource(block: any, inlineKey: any, fileKey: any, files: any, where: any): string;
|
|
7
7
|
export declare function readAnyTextSource(block: any, inlineKeys: any, fileKeys: any, files: any, where: any, label: any): {
|
|
8
8
|
text: string;
|
|
9
9
|
sourceKey: any;
|
|
10
10
|
file?: undefined;
|
|
11
11
|
} | {
|
|
12
|
-
text:
|
|
12
|
+
text: string;
|
|
13
13
|
sourceKey: any;
|
|
14
14
|
file: string;
|
|
15
15
|
};
|
package/types/store.d.ts
CHANGED
|
@@ -5,12 +5,15 @@ 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
|
+
/** 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;
|
|
8
10
|
/**
|
|
9
11
|
* @param {any} spec a normalized spec
|
|
10
|
-
* @param {{ fileRoots?: string[] }} [options] the roots the spec was read under; the live server opens only files inside them
|
|
12
|
+
* @param {{ fileRoots?: string[], retentionDays?: number | string | boolean }} [options] `fileRoots`: the roots the spec was read under; the live server opens only files inside them. `retentionDays`: how long old boards stay (see `resolveRetentionDays`)
|
|
11
13
|
*/
|
|
12
|
-
export declare function createBoard(spec: any, { fileRoots }?: {
|
|
14
|
+
export declare function createBoard(spec: any, { fileRoots, retentionDays }?: {
|
|
13
15
|
fileRoots?: string[];
|
|
16
|
+
retentionDays?: number | string | boolean;
|
|
14
17
|
}): {
|
|
15
18
|
id: string;
|
|
16
19
|
createdAt: string;
|
|
@@ -21,6 +24,14 @@ export declare function createBoard(spec: any, { fileRoots }?: {
|
|
|
21
24
|
draft: any;
|
|
22
25
|
result: any;
|
|
23
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Removes boards unchanged for `days`, except those a live server still serves.
|
|
29
|
+
* A failed sweep never blocks the board being created, so errors stay here.
|
|
30
|
+
* @returns {string[]} the ids removed
|
|
31
|
+
*/
|
|
32
|
+
export declare function pruneOldBoards(days: any, { force }?: {
|
|
33
|
+
force?: boolean;
|
|
34
|
+
}): string[];
|
|
24
35
|
export declare function saveBoard(record: any): void;
|
|
25
36
|
export declare function loadBoard(id: any): any;
|
|
26
37
|
export declare function saveResultFile(id: any, result: any): string;
|