@roam-research/roam-tools-core 0.6.5 → 0.6.7
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/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/operations/blocks.d.ts +8 -8
- package/dist/operations/blocks.d.ts.map +1 -1
- package/dist/operations/blocks.js +4 -1
- package/dist/operations/datalog.d.ts.map +1 -1
- package/dist/operations/datalog.js +2 -0
- package/dist/operations/pages.d.ts +4 -4
- package/dist/operations/pages.d.ts.map +1 -1
- package/dist/operations/pages.js +4 -1
- package/dist/tools.d.ts +27 -5
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +177 -47
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type { CallToolResult, TextContent, ImageContent, GraphType, AccessLevel, GraphConfig, RoamMcpConfig, ToolGraph, ResolvedGraph, RoamActionClient, ErrorCode, RoamApiError, RoamResponse, Block, Page, BlockLocation, WindowType, SidebarWindow, SidebarWindowInfo, FocusedBlock, SelectedBlock, MainWindowViewType, MainWindowView, SearchResultPath, SearchResult, SearchResponse, RecentlyOpenedBlock, RecentlyOpenedItem, DailyNotePagesViewItem, RecentlyEditedPage, SearchSuggestionsResponse, SearchTemplatesResponse, GetPageResponse, GetBlockResponse, Template, QueryResult, QueryResponse, TokenInfoResponse, TokenInfoResult, } from "./types.js";
|
|
1
|
+
export type { CallToolResult, TextContent, ImageContent, GraphType, AccessLevel, GraphConfig, RoamMcpConfig, ToolGraph, ResolvedGraph, RoamActionClient, ErrorCode, RoamApiError, RoamResponse, Block, Page, BlockLocation, WindowType, SidebarWindow, SidebarWindowInfo, FocusedBlock, SelectedBlock, MainWindowViewType, MainWindowView, SearchResultPath, SearchResult, SearchResponse, RecentlyOpenedBlock, RecentlyOpenedItem, DailyNotePagesViewItem, RecentlyEditedPage, SearchSuggestionsResponse, SearchTemplatesResponse, GetPageResponse, GetBlockResponse, Template, QueryResult, QueryResponse, TokenInfoResponse, TokenInfoResult, ToolAnnotations, } from "./types.js";
|
|
2
2
|
export { GraphConfigSchema, RoamMcpConfigSchema, ErrorCodes, RoamError, CONFIG_VERSION, EXPECTED_API_VERSION, textResult, imageResult, errorResult, getErrorMessage, } from "./types.js";
|
|
3
|
-
export { tools, findTool, routeToolCall, contentTools, dataTools, desktopUiTools, defineTool, defineStandaloneTool, } from "./tools.js";
|
|
3
|
+
export { tools, findTool, routeToolCall, stripUndeclaredStructuredContent, contentTools, dataTools, desktopUiTools, defineTool, defineStandaloneTool, } from "./tools.js";
|
|
4
4
|
export type { ToolDefinition, ClientToolDefinition, StandaloneToolDefinition, RouteToolCallOptions, } from "./tools.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,YAAY,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,IAAI,EACJ,aAAa,EACb,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,KAAK,EACL,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,EACV,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,YAAY,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,IAAI,EACJ,aAAa,EACb,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,KAAK,EACL,QAAQ,EACR,aAAa,EACb,gCAAgC,EAChC,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,EACV,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
// routeToolCall's options.
|
|
8
8
|
export { GraphConfigSchema, RoamMcpConfigSchema, ErrorCodes, RoamError, CONFIG_VERSION, EXPECTED_API_VERSION, textResult, imageResult, errorResult, getErrorMessage, } from "./types.js";
|
|
9
9
|
// Tool definitions, helpers, and routing
|
|
10
|
-
export { tools, findTool, routeToolCall, contentTools, dataTools, desktopUiTools, defineTool, defineStandaloneTool, } from "./tools.js";
|
|
10
|
+
export { tools, findTool, routeToolCall, stripUndeclaredStructuredContent, contentTools, dataTools, desktopUiTools, defineTool, defineStandaloneTool, } from "./tools.js";
|
|
@@ -42,14 +42,14 @@ export declare const UpdateBlockSchema: z.ZodObject<{
|
|
|
42
42
|
}, "strip", z.ZodTypeAny, {
|
|
43
43
|
uid: string;
|
|
44
44
|
string?: string | undefined;
|
|
45
|
-
childrenViewType?: "
|
|
45
|
+
childrenViewType?: "document" | "bullet" | "numbered" | undefined;
|
|
46
46
|
open?: boolean | undefined;
|
|
47
47
|
heading?: number | undefined;
|
|
48
48
|
textAlign?: "left" | "center" | "right" | "justify" | undefined;
|
|
49
49
|
}, {
|
|
50
50
|
uid: string;
|
|
51
51
|
string?: string | undefined;
|
|
52
|
-
childrenViewType?: "
|
|
52
|
+
childrenViewType?: "document" | "bullet" | "numbered" | undefined;
|
|
53
53
|
open?: boolean | undefined;
|
|
54
54
|
heading?: number | undefined;
|
|
55
55
|
textAlign?: "left" | "center" | "right" | "justify" | undefined;
|
|
@@ -86,24 +86,24 @@ export declare const GetBacklinksSchema: z.ZodObject<{
|
|
|
86
86
|
maxDepth: z.ZodOptional<z.ZodNumber>;
|
|
87
87
|
}, "strip", z.ZodTypeAny, {
|
|
88
88
|
title?: string | undefined;
|
|
89
|
-
sort?: "created-date" | "edited-date" | "daily-note-date" | undefined;
|
|
90
|
-
search?: string | undefined;
|
|
91
89
|
uid?: string | undefined;
|
|
90
|
+
sort?: "created-date" | "edited-date" | "daily-note-date" | undefined;
|
|
92
91
|
maxDepth?: number | undefined;
|
|
92
|
+
search?: string | undefined;
|
|
93
93
|
offset?: number | undefined;
|
|
94
94
|
limit?: number | undefined;
|
|
95
|
-
sortOrder?: "asc" | "desc" | undefined;
|
|
96
95
|
includePath?: boolean | undefined;
|
|
96
|
+
sortOrder?: "asc" | "desc" | undefined;
|
|
97
97
|
}, {
|
|
98
98
|
title?: string | undefined;
|
|
99
|
-
sort?: "created-date" | "edited-date" | "daily-note-date" | undefined;
|
|
100
|
-
search?: string | undefined;
|
|
101
99
|
uid?: string | undefined;
|
|
100
|
+
sort?: "created-date" | "edited-date" | "daily-note-date" | undefined;
|
|
102
101
|
maxDepth?: number | undefined;
|
|
102
|
+
search?: string | undefined;
|
|
103
103
|
offset?: number | undefined;
|
|
104
104
|
limit?: number | undefined;
|
|
105
|
-
sortOrder?: "asc" | "desc" | undefined;
|
|
106
105
|
includePath?: boolean | undefined;
|
|
106
|
+
sortOrder?: "asc" | "desc" | undefined;
|
|
107
107
|
}>;
|
|
108
108
|
export type CreateBlockParams = z.infer<typeof CreateBlockSchema>;
|
|
109
109
|
export type GetBlockParams = z.infer<typeof GetBlockSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/operations/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAoB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAItF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EA+B5B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;EAMzB,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EAe5B,CA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AW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,cAAc,CAAC,CA0BzB;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,cAAc,CAAC,CAMzB"}
|
|
@@ -113,7 +113,10 @@ export async function getBlock(client, params) {
|
|
|
113
113
|
if (params.maxDepth !== undefined)
|
|
114
114
|
apiParams.maxDepth = params.maxDepth;
|
|
115
115
|
const response = await client.call("data.ai.getBlock", [apiParams]);
|
|
116
|
-
|
|
116
|
+
// Not-found: a found block always has a `uid`, so treat a nullish/uid-less result
|
|
117
|
+
// (incl. `{}`) as a miss and return an explicit { found: false } signal — clearer
|
|
118
|
+
// than an empty object that reads as a successful empty block.
|
|
119
|
+
return textResult(response.result?.uid ? response.result : { found: false });
|
|
117
120
|
}
|
|
118
121
|
export async function updateBlock(client, params) {
|
|
119
122
|
const block = { uid: params.uid };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datalog.d.ts","sourceRoot":"","sources":["../../src/operations/datalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpE,eAAO,MAAM,kBAAkB;;;;;;;;;EAQ7B,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,wBAAsB,YAAY,CAChC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"datalog.d.ts","sourceRoot":"","sources":["../../src/operations/datalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpE,eAAO,MAAM,kBAAkB;;;;;;;;;EAQ7B,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,wBAAsB,YAAY,CAChC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,cAAc,CAAC,CAMzB"}
|
|
@@ -12,5 +12,7 @@ export const DatalogQuerySchema = z.object({
|
|
|
12
12
|
export async function datalogQuery(client, params) {
|
|
13
13
|
const args = params.inputs ? [params.query, ...params.inputs] : [params.query];
|
|
14
14
|
const response = await client.call("q", args);
|
|
15
|
+
// Content-only read (no outputSchema): the raw scalar/tuple/collection/relation
|
|
16
|
+
// goes on the text channel as-is.
|
|
15
17
|
return textResult(response.result ?? []);
|
|
16
18
|
}
|
|
@@ -9,12 +9,12 @@ export declare const CreatePageSchema: z.ZodObject<{
|
|
|
9
9
|
title: string;
|
|
10
10
|
markdown?: string | undefined;
|
|
11
11
|
uid?: string | undefined;
|
|
12
|
-
childrenViewType?: "
|
|
12
|
+
childrenViewType?: "document" | "bullet" | "numbered" | undefined;
|
|
13
13
|
}, {
|
|
14
14
|
title: string;
|
|
15
15
|
markdown?: string | undefined;
|
|
16
16
|
uid?: string | undefined;
|
|
17
|
-
childrenViewType?: "
|
|
17
|
+
childrenViewType?: "document" | "bullet" | "numbered" | undefined;
|
|
18
18
|
}>;
|
|
19
19
|
export declare const GetPageSchema: z.ZodObject<{
|
|
20
20
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -44,12 +44,12 @@ export declare const UpdatePageSchema: z.ZodObject<{
|
|
|
44
44
|
}, "strip", z.ZodTypeAny, {
|
|
45
45
|
uid: string;
|
|
46
46
|
title?: string | undefined;
|
|
47
|
-
childrenViewType?: "
|
|
47
|
+
childrenViewType?: "document" | "bullet" | "numbered" | undefined;
|
|
48
48
|
mergePages?: boolean | undefined;
|
|
49
49
|
}, {
|
|
50
50
|
uid: string;
|
|
51
51
|
title?: string | undefined;
|
|
52
|
-
childrenViewType?: "
|
|
52
|
+
childrenViewType?: "document" | "bullet" | "numbered" | undefined;
|
|
53
53
|
mergePages?: boolean | undefined;
|
|
54
54
|
}>;
|
|
55
55
|
export declare const GetGuidelinesSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../src/operations/pages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAmB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIrF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAa3B,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;EAOxB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;EAE3B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAa3B,CAAC;AAEH,eAAO,MAAM,mBAAmB,gDAAe,CAAC;AAGhD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAA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gBAAgB,EACxB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,cAAc,CAAC,CASzB;AAED,wBAAsB,OAAO,CAC3B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,cAAc,CAAC,CAWzB;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,cAAc,CAAC,CAGzB;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,cAAc,CAAC,CAUzB;AAED,wBAAsB,aAAa,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,CA0BrF"}
|
package/dist/operations/pages.js
CHANGED
|
@@ -55,7 +55,10 @@ export async function getPage(client, params) {
|
|
|
55
55
|
if (params.maxDepth !== undefined)
|
|
56
56
|
apiParams.maxDepth = params.maxDepth;
|
|
57
57
|
const response = await client.call("data.ai.getPage", [apiParams]);
|
|
58
|
-
|
|
58
|
+
// Not-found: a found page always has a `uid`, so treat a nullish/uid-less result
|
|
59
|
+
// (incl. `{}`) as a miss and return an explicit { found: false } signal — clearer
|
|
60
|
+
// than an empty object that reads as a successful empty page.
|
|
61
|
+
return textResult(response.result?.uid ? response.result : { found: false });
|
|
59
62
|
}
|
|
60
63
|
export async function deletePage(client, params) {
|
|
61
64
|
await client.call("data.page.delete", [{ page: { uid: params.uid } }]);
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type { CallToolResult, AccessLevel, RoamActionClient, ToolGraph } from "./types.js";
|
|
2
|
+
import type { CallToolResult, AccessLevel, RoamActionClient, ToolGraph, ToolAnnotations } from "./types.js";
|
|
3
3
|
export interface ClientToolDefinition {
|
|
4
4
|
name: string;
|
|
5
5
|
description: string;
|
|
6
6
|
schema: z.ZodObject<z.ZodRawShape>;
|
|
7
7
|
action: (client: RoamActionClient, args: unknown) => Promise<CallToolResult>;
|
|
8
8
|
type: "client";
|
|
9
|
+
title?: string;
|
|
10
|
+
annotations?: ToolAnnotations;
|
|
11
|
+
outputSchema?: z.AnyZodObject;
|
|
9
12
|
}
|
|
10
13
|
export interface StandaloneToolDefinition {
|
|
11
14
|
name: string;
|
|
@@ -13,15 +16,33 @@ export interface StandaloneToolDefinition {
|
|
|
13
16
|
schema: z.ZodObject<z.ZodRawShape>;
|
|
14
17
|
action: (args: unknown) => Promise<CallToolResult>;
|
|
15
18
|
type: "standalone";
|
|
19
|
+
title?: string;
|
|
20
|
+
annotations?: ToolAnnotations;
|
|
21
|
+
outputSchema?: z.AnyZodObject;
|
|
16
22
|
}
|
|
17
23
|
export type ToolDefinition = ClientToolDefinition | StandaloneToolDefinition;
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
type ToolMetaArg = {
|
|
25
|
+
title?: string;
|
|
26
|
+
annotations?: ToolAnnotations;
|
|
27
|
+
outputSchema?: z.AnyZodObject;
|
|
28
|
+
};
|
|
29
|
+
export declare function defineTool<T extends z.ZodRawShape>(name: string, description: string, schema: z.ZodObject<T>, action: (client: RoamActionClient, args: z.infer<z.ZodObject<T>>) => Promise<CallToolResult>, meta?: ToolMetaArg): ClientToolDefinition;
|
|
30
|
+
export declare function defineStandaloneTool<T extends z.ZodRawShape>(name: string, description: string, schema: z.ZodObject<T>, action: (args: z.infer<z.ZodObject<T>>) => Promise<CallToolResult>, meta?: ToolMetaArg): StandaloneToolDefinition;
|
|
20
31
|
export declare const dataTools: ClientToolDefinition[];
|
|
21
32
|
export declare const desktopUiTools: ClientToolDefinition[];
|
|
22
33
|
export declare const contentTools: ClientToolDefinition[];
|
|
23
34
|
export declare const tools: ToolDefinition[];
|
|
24
35
|
export declare function findTool(name: string): ToolDefinition | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Drop `structuredContent` when the tool declares no `outputSchema`. structuredContent
|
|
38
|
+
* is only meaningful (and SDK-validated) when a schema is declared; for content-only
|
|
39
|
+
* tools (all reads + file/nav) it would just duplicate the text channel (e.g. a large
|
|
40
|
+
* file_get payload). Shared by both transports so the "schema-less ⇒ content-only"
|
|
41
|
+
* invariant can't drift between them.
|
|
42
|
+
*/
|
|
43
|
+
export declare function stripUndeclaredStructuredContent(result: CallToolResult, tool: {
|
|
44
|
+
outputSchema?: unknown;
|
|
45
|
+
}): CallToolResult;
|
|
25
46
|
export interface RouteToolCallOptions {
|
|
26
47
|
/**
|
|
27
48
|
* Resolve a graph identifier (nickname/name) to a ToolGraph. Required.
|
|
@@ -38,8 +59,8 @@ export interface RouteToolCallOptions {
|
|
|
38
59
|
/**
|
|
39
60
|
* "local-sync" runs the desktop token-info side-flow on get_graph_guidelines:
|
|
40
61
|
* parallel getTokenInfo, access-level validation, status writes, and result
|
|
41
|
-
* enrichment. "skip" (default) disables that side-flow entirely.
|
|
42
|
-
*
|
|
62
|
+
* enrichment. "skip" (default) disables that side-flow entirely. The graph
|
|
63
|
+
* field (withGraphField) is unaffected by this mode and runs in both.
|
|
43
64
|
*/
|
|
44
65
|
tokenInfoMode?: "local-sync" | "skip";
|
|
45
66
|
/**
|
|
@@ -52,4 +73,5 @@ export interface RouteToolCallOptions {
|
|
|
52
73
|
}) => Promise<void>;
|
|
53
74
|
}
|
|
54
75
|
export declare function routeToolCall(toolName: string, args: Record<string, unknown>, options: RouteToolCallOptions): Promise<CallToolResult>;
|
|
76
|
+
export {};
|
|
55
77
|
//# sourceMappingURL=tools.d.ts.map
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EACV,cAAc,EAEd,WAAW,EACX,gBAAgB,EAChB,SAAS,
|
|
1
|
+
{"version":3,"file":"tools.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MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7D;;;;OAIG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;IACjF;;;;;OAKG;IACH,aAAa,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IACtC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CACpB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE;QAAE,WAAW,CAAC,EAAE,WAAW,CAAC;QAAC,oBAAoB,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;KAAE,KAC9E,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,cAAc,CAAC,CAqIzB"}
|
package/dist/tools.js
CHANGED
|
@@ -19,70 +19,162 @@ function withGraph(schema) {
|
|
|
19
19
|
return schema.extend(GraphSchema.shape);
|
|
20
20
|
}
|
|
21
21
|
// Helper to create tool with graph parameter
|
|
22
|
-
export function defineTool(name, description, schema, action) {
|
|
22
|
+
export function defineTool(name, description, schema, action, meta) {
|
|
23
23
|
return {
|
|
24
24
|
name,
|
|
25
25
|
description,
|
|
26
26
|
schema: withGraph(schema),
|
|
27
27
|
action: (client, args) => action(client, args),
|
|
28
28
|
type: "client",
|
|
29
|
+
title: meta?.title,
|
|
30
|
+
annotations: meta?.annotations,
|
|
31
|
+
outputSchema: meta?.outputSchema,
|
|
29
32
|
};
|
|
30
33
|
}
|
|
31
34
|
// Helper to create standalone tool (no graph parameter, handles its own resolution)
|
|
32
|
-
export function defineStandaloneTool(name, description, schema, action) {
|
|
35
|
+
export function defineStandaloneTool(name, description, schema, action, meta) {
|
|
33
36
|
return {
|
|
34
37
|
name,
|
|
35
38
|
description,
|
|
36
39
|
schema: schema,
|
|
37
40
|
action: (args) => action(args),
|
|
38
41
|
type: "standalone",
|
|
42
|
+
title: meta?.title,
|
|
43
|
+
annotations: meta?.annotations,
|
|
44
|
+
outputSchema: meta?.outputSchema,
|
|
39
45
|
};
|
|
40
46
|
}
|
|
41
47
|
// Note appended to all client tool descriptions
|
|
42
48
|
const GUIDELINES_NOTE = "\n\n(If you haven't fetched this graph's guidelines yet, call get_graph_guidelines — they may change how to handle this operation.)";
|
|
49
|
+
// ----------------------------------------------------------------------------
|
|
50
|
+
// Annotation presets (MCP tools/list hints), applied inline at each defineTool
|
|
51
|
+
// call below. They help clients label/gate tools correctly (e.g. ChatGPT dev
|
|
52
|
+
// mode, which otherwise defaults every tool to destructive + open-world) and
|
|
53
|
+
// mirror the backend's read/append/edit/delete classification. Hints only — NOT
|
|
54
|
+
// a security boundary; the backend still enforces authorization.
|
|
55
|
+
//
|
|
56
|
+
// readOnlyHint describes effects on the user's GRAPH CONTENT. We keep it true for a
|
|
57
|
+
// few tools that do idempotent orientation scaffolding rather than a real write:
|
|
58
|
+
// get_graph_guidelines syncs local token status (~/.roam-tools.json, local-sync) and,
|
|
59
|
+
// on the hosted backend under an append/full grant, may auto-create today's daily note
|
|
60
|
+
// page + provision the "<name> (AI)" display page. These never fire for a read-only
|
|
61
|
+
// grant and are idempotent, so flipping to readOnlyHint:false would only make clients
|
|
62
|
+
// gate the very orientation tool they're told to call first. Contrast setup_new_graph,
|
|
63
|
+
// whose config write IS its purpose, so it is not read-only.
|
|
64
|
+
//
|
|
65
|
+
// openWorldHint is false for every tool except file_upload (its url path fetches
|
|
66
|
+
// an arbitrary external host server-side).
|
|
67
|
+
// ----------------------------------------------------------------------------
|
|
68
|
+
const READ = {
|
|
69
|
+
readOnlyHint: true,
|
|
70
|
+
destructiveHint: false,
|
|
71
|
+
idempotentHint: true,
|
|
72
|
+
openWorldHint: false,
|
|
73
|
+
};
|
|
74
|
+
const APPEND = {
|
|
75
|
+
readOnlyHint: false,
|
|
76
|
+
destructiveHint: false,
|
|
77
|
+
idempotentHint: false,
|
|
78
|
+
openWorldHint: false,
|
|
79
|
+
};
|
|
80
|
+
// Edits and moves overwrite/relocate existing structure — not "only additive" —
|
|
81
|
+
// so they are destructive; both are idempotent (same args → same end state).
|
|
82
|
+
const EDIT = {
|
|
83
|
+
readOnlyHint: false,
|
|
84
|
+
destructiveHint: true,
|
|
85
|
+
idempotentHint: true,
|
|
86
|
+
openWorldHint: false,
|
|
87
|
+
};
|
|
88
|
+
const DELETE = {
|
|
89
|
+
readOnlyHint: false,
|
|
90
|
+
destructiveHint: true,
|
|
91
|
+
idempotentHint: false,
|
|
92
|
+
openWorldHint: false,
|
|
93
|
+
};
|
|
94
|
+
// open_main_window replaces the main view (idempotent). open_sidebar overrides
|
|
95
|
+
// idempotentHint:false at its call site — ui.rightSidebar.addWindow can add
|
|
96
|
+
// another sidebar pane on repeat. Neither mutates graph data.
|
|
97
|
+
const NAV = {
|
|
98
|
+
readOnlyHint: false,
|
|
99
|
+
destructiveHint: false,
|
|
100
|
+
idempotentHint: true,
|
|
101
|
+
openWorldHint: false,
|
|
102
|
+
};
|
|
103
|
+
// file_upload's url path does a server-side fetch of an arbitrary host.
|
|
104
|
+
const UPLOAD = { ...APPEND, openWorldHint: true };
|
|
105
|
+
// ----------------------------------------------------------------------------
|
|
106
|
+
// Output schemas (MCP tools/list structured-result hints) — WRITE TOOLS ONLY.
|
|
107
|
+
// The 8 write tools declare a schema (and emit structuredContent); the 9 read
|
|
108
|
+
// tools are content-only. Why write-only:
|
|
109
|
+
// - structuredContent duplicates the whole result into the text channel
|
|
110
|
+
// (textResult already JSON-stringifies it), so a schema on big reads
|
|
111
|
+
// (get_page/search) just doubles the payload for no gain.
|
|
112
|
+
// - read output shapes still evolve; write shapes ({success}/{uids}/{uid}) are
|
|
113
|
+
// small and finalized.
|
|
114
|
+
// CACHE HAZARD (drives the additive-only rule): ChatGPT caches the tools/list
|
|
115
|
+
// descriptor ~1 day and validates live responses against that STALE cached
|
|
116
|
+
// outputSchema. With .passthrough() + all-optional, additive changes survive a
|
|
117
|
+
// stale cache; a NON-additive change to a declared field (retype/rename/remove)
|
|
118
|
+
// can break the tool for ~a day. To change a declared field: new tool name, or
|
|
119
|
+
// expand-contract (add new field → wait out the cache → drop the old). See the
|
|
120
|
+
// chatgpt-mcp-annotations-and-tool-cache finding. NOTE: .optional() accepts
|
|
121
|
+
// absent/undefined but REJECTS null — a declared field whose producer can emit
|
|
122
|
+
// null needs .nullable(). `graph` is injected by withGraphField (canonical name).
|
|
123
|
+
// ----------------------------------------------------------------------------
|
|
124
|
+
const SuccessOutput = z
|
|
125
|
+
.object({ success: z.boolean().optional(), graph: z.string().optional() })
|
|
126
|
+
.passthrough();
|
|
127
|
+
const UidOutput = z
|
|
128
|
+
.object({ uid: z.string().optional(), graph: z.string().optional() })
|
|
129
|
+
.passthrough();
|
|
130
|
+
const UidsOutput = z
|
|
131
|
+
.object({ uids: z.array(z.string()).optional(), graph: z.string().optional() })
|
|
132
|
+
.passthrough();
|
|
43
133
|
// Data Tools (require graph/client; reusable across local + hosted MCP transports)
|
|
44
134
|
export const dataTools = [
|
|
45
|
-
defineTool("get_graph_guidelines", "Returns this graph's agent-facing setup: naming conventions, structural preferences, orientation actions, and any constraints the user has explicitly recorded for AI agents. Call once per graph per session before reading or writing content — skipping it means operating on assumptions the user has already overridden, so your work will likely need to be redone. The `nextSteps` field in the response lists orientation actions to take before proceeding.", GetGuidelinesSchema, getGuidelines),
|
|
46
|
-
defineTool("create_page", "Create a new page in Roam, optionally with markdown content." + GUIDELINES_NOTE, CreatePageSchema, createPage),
|
|
135
|
+
defineTool("get_graph_guidelines", "Returns this graph's agent-facing setup: naming conventions, structural preferences, orientation actions, and any constraints the user has explicitly recorded for AI agents. Call once per graph per session before reading or writing content — skipping it means operating on assumptions the user has already overridden, so your work will likely need to be redone. The `nextSteps` field in the response lists orientation actions to take before proceeding.", GetGuidelinesSchema, getGuidelines, { title: "Get graph guidelines", annotations: READ }),
|
|
136
|
+
defineTool("create_page", "Create a new page in Roam, optionally with markdown content." + GUIDELINES_NOTE, CreatePageSchema, createPage, { title: "Create page", annotations: APPEND, outputSchema: UidOutput }),
|
|
47
137
|
defineTool("create_block", "Create blocks from markdown content. Target by parentUid, pageTitle, or dailyNotePage (page created if needed). Use nestUnder to insert under a specific child block. Supports nested bulleted lists via markdown indentation." +
|
|
48
|
-
GUIDELINES_NOTE, CreateBlockSchema, createBlock),
|
|
138
|
+
GUIDELINES_NOTE, CreateBlockSchema, createBlock, { title: "Create blocks", annotations: APPEND, outputSchema: UidsOutput }),
|
|
49
139
|
defineTool("update_block", "Update a single existing block's text and display properties (heading, collapse, alignment, children view type). Affects only the block with `uid`: `string` sets that block's literal text — it is NOT expanded into child blocks (unlike create_block/create_page), and the block's existing children are left untouched. To add or restructure children, use create_block / move_block / delete_block." +
|
|
50
|
-
GUIDELINES_NOTE, UpdateBlockSchema, updateBlock),
|
|
51
|
-
defineTool("delete_block",
|
|
52
|
-
|
|
140
|
+
GUIDELINES_NOTE, UpdateBlockSchema, updateBlock, { title: "Update block", annotations: EDIT, outputSchema: SuccessOutput }),
|
|
141
|
+
defineTool("delete_block", 'Delete a block and all its descendants — irreversible. If the block is referenced elsewhere, deletion REPLACES those ((uid)) refs with its text (graph surgery, not string removal — on approval you can instead delete the referencing blocks). Inspect with get_block first: its markdown flags referenced blocks with `refs="N"` (and `hiddenChildren="N"` for subtrees beyond maxDepth), and comments count as refs. If anything shows `refs`, or the subtree is large (~20+ blocks / 500+ words), check get_backlinks and confirm with the user before deleting. For cleanup, only delete blocks created this task or named by the user.' +
|
|
142
|
+
GUIDELINES_NOTE, DeleteBlockSchema, deleteBlock, { title: "Delete block", annotations: DELETE, outputSchema: SuccessOutput }),
|
|
143
|
+
defineTool("move_block", "Move a block to a new location." + GUIDELINES_NOTE, MoveBlockSchema, moveBlock, { title: "Move block", annotations: EDIT, outputSchema: SuccessOutput }),
|
|
53
144
|
defineTool("add_comment", "Add a comment to a block (comment thread, NOT a child block). Prefer `comment` for simple text; use `commentMarkdown` for structured content. Same-day calls on the same block append to your existing comment." +
|
|
54
|
-
GUIDELINES_NOTE, AddCommentSchema, addComment),
|
|
145
|
+
GUIDELINES_NOTE, AddCommentSchema, addComment, { title: "Add comment", annotations: APPEND, outputSchema: UidsOutput }),
|
|
55
146
|
defineTool("get_comments", "Get comments on a block with author, timestamps, and edit info. If singleEditableUid is set, the comment can be edited with update_block. Only works for blocks, not pages." +
|
|
56
|
-
GUIDELINES_NOTE, GetCommentsSchema, getComments),
|
|
57
|
-
defineTool("delete_page", "Delete a page and all its
|
|
147
|
+
GUIDELINES_NOTE, GetCommentsSchema, getComments, { title: "Get comments", annotations: READ }),
|
|
148
|
+
defineTool("delete_page", "Delete a page and all its blocks — irreversible. If the page is referenced elsewhere, deleting it also edits every block that links to it — those `[[page]]` references are removed (graph surgery, not just removing the page). Inspect with get_page first: its header shows the page's `refs:` count (how many blocks link to it). If `refs:` is non-zero, or the page has substantial content, confirm with the user before deleting. For cleanup, only delete pages created this task or named by the user." +
|
|
149
|
+
GUIDELINES_NOTE, DeletePageSchema, deletePage, { title: "Delete page", annotations: DELETE, outputSchema: SuccessOutput }),
|
|
58
150
|
defineTool("update_page", "Update a page's title or children view type. Set mergePages to true if renaming to a title that already exists." +
|
|
59
|
-
GUIDELINES_NOTE, UpdatePageSchema, updatePage),
|
|
151
|
+
GUIDELINES_NOTE, UpdatePageSchema, updatePage, { title: "Update page", annotations: EDIT, outputSchema: SuccessOutput }),
|
|
60
152
|
defineTool("search", "Search for pages and blocks by text. Returns paginated results with markdown content and optional breadcrumb paths. Call with an empty query to get recently edited and viewed content — useful for understanding what the user is currently working on." +
|
|
61
|
-
GUIDELINES_NOTE, SearchSchema, search),
|
|
153
|
+
GUIDELINES_NOTE, SearchSchema, search, { title: "Search", annotations: READ }),
|
|
62
154
|
defineTool("search_templates", "Search Roam templates by name. When the user mentions 'my X template' or 'the X template', use this tool to find it. Templates are user-created reusable content blocks tagged with [[roam/templates]]. Returns template name, uid, and content as markdown." +
|
|
63
|
-
GUIDELINES_NOTE, SearchTemplatesSchema, searchTemplates),
|
|
155
|
+
GUIDELINES_NOTE, SearchTemplatesSchema, searchTemplates, { title: "Search templates", annotations: READ }),
|
|
64
156
|
defineTool("roam_query", 'Execute a Roam query ({{query: }} or {{[[query]]: }} blocks, NOT Datalog). Two modes: (1) UID mode - pass a block UID containing a query component to run it with saved settings/filters; (2) Query mode - pass a raw query string like "{and: [[TODO]] {not: [[DONE]]}}". Returns paginated results with markdown content.' +
|
|
65
|
-
GUIDELINES_NOTE, QuerySchema, query),
|
|
157
|
+
GUIDELINES_NOTE, QuerySchema, query, { title: "Run Roam query", annotations: READ }),
|
|
66
158
|
defineTool("datalog_query", "Execute a datomic-style datalog query against the graph's datascript database. Supported clauses: :find, :where, :in, and :timeout (ms). Inputs are positional parameters bound to :in variables after $. Write specific :where clauses to keep results bounded." +
|
|
67
|
-
GUIDELINES_NOTE, DatalogQuerySchema, datalogQuery),
|
|
159
|
+
GUIDELINES_NOTE, DatalogQuerySchema, datalogQuery, { title: "Run datalog query", annotations: READ }),
|
|
68
160
|
defineTool("get_page", "Get a page's content as markdown. Returns content with <roam> metadata tags containing UIDs - use these for follow-up operations but strip them when showing content to the user. Show remaining content verbatim, never paraphrase. Use maxDepth for large pages." +
|
|
69
|
-
GUIDELINES_NOTE, GetPageSchema, getPage),
|
|
161
|
+
GUIDELINES_NOTE, GetPageSchema, getPage, { title: "Get page", annotations: READ }),
|
|
70
162
|
defineTool("get_block", "Get a block's content as markdown. Returns content with <roam> metadata tags containing UIDs - use these for follow-up operations but strip them when showing content to the user. Show remaining content verbatim, never paraphrase. Use maxDepth for large blocks." +
|
|
71
|
-
GUIDELINES_NOTE, GetBlockSchema, getBlock),
|
|
163
|
+
GUIDELINES_NOTE, GetBlockSchema, getBlock, { title: "Get block", annotations: READ }),
|
|
72
164
|
defineTool("get_backlinks", "Get paginated backlinks (linked references) for a page or block, formatted as markdown. Returns total count and results with optional breadcrumb paths." +
|
|
73
|
-
GUIDELINES_NOTE, GetBacklinksSchema, getBacklinks),
|
|
165
|
+
GUIDELINES_NOTE, GetBacklinksSchema, getBacklinks, { title: "Get backlinks", annotations: READ }),
|
|
74
166
|
];
|
|
75
167
|
// Desktop UI Tools (require local Roam Desktop — file ops + window/selection introspection;
|
|
76
168
|
// hosted MCP omits these because the parameters/effects assume a local environment).
|
|
77
169
|
export const desktopUiTools = [
|
|
78
|
-
defineTool("get_open_windows", "Get the current view in the main window and all open sidebar windows." + GUIDELINES_NOTE, GetOpenWindowsSchema, getOpenWindows),
|
|
79
|
-
defineTool("get_selection", "Get the currently focused block and any multi-selected blocks." + GUIDELINES_NOTE, GetSelectionSchema, getSelection),
|
|
80
|
-
defineTool("open_main_window", "Navigate to a page or block in the main window." + GUIDELINES_NOTE, OpenMainWindowSchema, openMainWindow),
|
|
81
|
-
defineTool("open_sidebar", "Open a page or block in the right sidebar." + GUIDELINES_NOTE, OpenSidebarSchema, openSidebar),
|
|
82
|
-
defineTool("file_get", "Fetch a file hosted on Roam (handles decryption for encrypted graphs)." + GUIDELINES_NOTE, FileGetSchema, getFile),
|
|
170
|
+
defineTool("get_open_windows", "Get the current view in the main window and all open sidebar windows." + GUIDELINES_NOTE, GetOpenWindowsSchema, getOpenWindows, { title: "Get open windows", annotations: READ }),
|
|
171
|
+
defineTool("get_selection", "Get the currently focused block and any multi-selected blocks." + GUIDELINES_NOTE, GetSelectionSchema, getSelection, { title: "Get selection", annotations: READ }),
|
|
172
|
+
defineTool("open_main_window", "Navigate to a page or block in the main window." + GUIDELINES_NOTE, OpenMainWindowSchema, openMainWindow, { title: "Open in main window", annotations: NAV }),
|
|
173
|
+
defineTool("open_sidebar", "Open a page or block in the right sidebar." + GUIDELINES_NOTE, OpenSidebarSchema, openSidebar, { title: "Open in sidebar", annotations: { ...NAV, idempotentHint: false } }),
|
|
174
|
+
defineTool("file_get", "Fetch a file hosted on Roam (handles decryption for encrypted graphs)." + GUIDELINES_NOTE, FileGetSchema, getFile, { title: "Get file", annotations: READ }),
|
|
83
175
|
defineTool("file_upload", "Upload a file to Roam. Returns the Firebase storage URL. Usually you'll want to create a new block with the file as markdown: ``. Provide ONE of: filePath (preferred - local file, server reads directly), url (remote URL, server fetches), or base64 (raw data, fallback for sandboxed clients)." +
|
|
84
|
-
GUIDELINES_NOTE, FileUploadSchema, uploadFile),
|
|
85
|
-
defineTool("file_delete", "Delete a file hosted on Roam." + GUIDELINES_NOTE, FileDeleteSchema, deleteFile),
|
|
176
|
+
GUIDELINES_NOTE, FileUploadSchema, uploadFile, { title: "Upload file", annotations: UPLOAD }),
|
|
177
|
+
defineTool("file_delete", "Delete a file hosted on Roam." + GUIDELINES_NOTE, FileDeleteSchema, deleteFile, { title: "Delete file", annotations: DELETE }),
|
|
86
178
|
];
|
|
87
179
|
// Backwards-compatible aggregate of all client tools.
|
|
88
180
|
export const contentTools = [...dataTools, ...desktopUiTools];
|
|
@@ -94,25 +186,54 @@ export function findTool(name) {
|
|
|
94
186
|
return tools.find((t) => t.name === name);
|
|
95
187
|
}
|
|
96
188
|
/**
|
|
97
|
-
*
|
|
189
|
+
* Drop `structuredContent` when the tool declares no `outputSchema`. structuredContent
|
|
190
|
+
* is only meaningful (and SDK-validated) when a schema is declared; for content-only
|
|
191
|
+
* tools (all reads + file/nav) it would just duplicate the text channel (e.g. a large
|
|
192
|
+
* file_get payload). Shared by both transports so the "schema-less ⇒ content-only"
|
|
193
|
+
* invariant can't drift between them.
|
|
98
194
|
*/
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
const content = result.content;
|
|
102
|
-
if (!content || content.length === 0)
|
|
195
|
+
export function stripUndeclaredStructuredContent(result, tool) {
|
|
196
|
+
if (tool.outputSchema || result.structuredContent === undefined)
|
|
103
197
|
return result;
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
198
|
+
const stripped = { ...result };
|
|
199
|
+
delete stripped.structuredContent;
|
|
200
|
+
return stripped;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Carry the resolved graph identity as a structured `graph` field rather than a
|
|
204
|
+
* "Roam graph: <name>" text prefix (which read as block content and made a read's
|
|
205
|
+
* JSON text non-parseable). Injects the canonical graph name into
|
|
206
|
+
* structuredContent (write tools) and into content[0].text when it parses to a
|
|
207
|
+
* plain JSON object (the only channel for content-only reads). Bare arrays/scalars
|
|
208
|
+
* (datalog raw text), images, non-JSON prose, and isError results are left
|
|
209
|
+
* untouched. Mirrors enrichResultWithTokenInfo's parse-and-rewrite.
|
|
210
|
+
*/
|
|
211
|
+
function withGraphField(result, graphName) {
|
|
212
|
+
let out = result;
|
|
213
|
+
const sc = result.structuredContent;
|
|
214
|
+
if (sc && typeof sc === "object" && !Array.isArray(sc)) {
|
|
215
|
+
// canonical resolved graph wins over any `graph` key the backend included
|
|
216
|
+
out = { ...out, structuredContent: { ...sc, graph: graphName } };
|
|
110
217
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
218
|
+
const first = out.content?.[0];
|
|
219
|
+
if (first && first.type === "text") {
|
|
220
|
+
try {
|
|
221
|
+
const parsed = JSON.parse(first.text);
|
|
222
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
223
|
+
out = {
|
|
224
|
+
...out,
|
|
225
|
+
content: [
|
|
226
|
+
{ ...first, text: JSON.stringify({ ...parsed, graph: graphName }, null, 2) },
|
|
227
|
+
...out.content.slice(1),
|
|
228
|
+
],
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
// not a JSON object (datalog raw array, prose) — leave the text untouched
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return out;
|
|
116
237
|
}
|
|
117
238
|
/**
|
|
118
239
|
* Enrich a JSON text result with token info (accessLevel + scopes).
|
|
@@ -125,10 +246,19 @@ function enrichResultWithTokenInfo(result, info) {
|
|
|
125
246
|
const parsed = JSON.parse(first.text);
|
|
126
247
|
parsed.accessLevel = info.grantedAccessLevel;
|
|
127
248
|
parsed.scopes = info.grantedScopes;
|
|
128
|
-
|
|
249
|
+
const enriched = {
|
|
129
250
|
...result,
|
|
130
251
|
content: [{ ...first, text: JSON.stringify(parsed, null, 2) }, ...result.content.slice(1)],
|
|
131
252
|
};
|
|
253
|
+
// Keep structuredContent in sync with the enriched text (local-sync path).
|
|
254
|
+
if (result.structuredContent && typeof result.structuredContent === "object") {
|
|
255
|
+
enriched.structuredContent = {
|
|
256
|
+
...result.structuredContent,
|
|
257
|
+
accessLevel: info.grantedAccessLevel,
|
|
258
|
+
scopes: info.grantedScopes,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return enriched;
|
|
132
262
|
}
|
|
133
263
|
catch {
|
|
134
264
|
return result;
|
|
@@ -255,7 +385,7 @@ export async function routeToolCall(toolName, args, options) {
|
|
|
255
385
|
}
|
|
256
386
|
if (!result.isError) {
|
|
257
387
|
const enriched = enrichResultWithTokenInfo(result, info);
|
|
258
|
-
return
|
|
388
|
+
return withGraphField(enriched, resolvedGraph.name);
|
|
259
389
|
}
|
|
260
390
|
return result;
|
|
261
391
|
}
|
|
@@ -269,15 +399,15 @@ export async function routeToolCall(toolName, args, options) {
|
|
|
269
399
|
}
|
|
270
400
|
}
|
|
271
401
|
if (!result.isError) {
|
|
272
|
-
return
|
|
402
|
+
return withGraphField(result, resolvedGraph.name);
|
|
273
403
|
}
|
|
274
404
|
return result;
|
|
275
405
|
}
|
|
276
406
|
// Normal flow for all other tools (and get_graph_guidelines when token-info
|
|
277
|
-
// sync is skipped or unavailable).
|
|
407
|
+
// sync is skipped or unavailable). The graph field runs in both modes.
|
|
278
408
|
const result = await tool.action(client, restArgs);
|
|
279
409
|
if (!result.isError) {
|
|
280
|
-
return
|
|
410
|
+
return withGraphField(result, graph.name);
|
|
281
411
|
}
|
|
282
412
|
return result;
|
|
283
413
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { CallToolResult, TextContent, ImageContent } from "@modelcontextprotocol/sdk/types.js";
|
|
1
|
+
export type { CallToolResult, TextContent, ImageContent, ToolAnnotations, } from "@modelcontextprotocol/sdk/types.js";
|
|
2
2
|
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
export declare function textResult(value: unknown): CallToolResult;
|
|
@@ -252,7 +252,7 @@ export interface GetPageResponse {
|
|
|
252
252
|
export interface GetBlockResponse {
|
|
253
253
|
uid: string;
|
|
254
254
|
markdown: string;
|
|
255
|
-
path: string;
|
|
255
|
+
path: string[];
|
|
256
256
|
queriedAt: string;
|
|
257
257
|
}
|
|
258
258
|
export interface QueryResult {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,YAAY,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,YAAY,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,eAAe,GAChB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAYzD;AAGD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAE1E;AAGD,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAE3D;AAOD,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAG7C,MAAM,MAAM,WAAW,GA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O,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,YAAY,CAAC,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CAC3C"}
|
package/dist/types.js
CHANGED
|
@@ -2,7 +2,16 @@ import { z } from "zod";
|
|
|
2
2
|
// Helper to create a text result
|
|
3
3
|
export function textResult(value) {
|
|
4
4
|
const text = typeof value === "string" ? value : JSON.stringify(value, null, 2);
|
|
5
|
-
|
|
5
|
+
const result = { content: [{ type: "text", text }] };
|
|
6
|
+
// Additive structured output: when value is a plain object, also expose it as
|
|
7
|
+
// structuredContent so tools that declare an outputSchema satisfy the SDK's
|
|
8
|
+
// validation (it requires structuredContent on success). The text block above
|
|
9
|
+
// is unchanged. Arrays/strings/null get text only — tools returning those declare
|
|
10
|
+
// no outputSchema, so the registration strip-gate keeps them content-only.
|
|
11
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
12
|
+
result.structuredContent = value;
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
6
15
|
}
|
|
7
16
|
// Helper to create an image result
|
|
8
17
|
export function imageResult(data, mimeType) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roam-research/roam-tools-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Official transport-agnostic core for Roam Research MCP and CLI tools",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test": "vitest run"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@modelcontextprotocol/sdk": "
|
|
35
|
+
"@modelcontextprotocol/sdk": ">=1.26.0 <2.0.0",
|
|
36
36
|
"zod": "^3.25.76"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|