@roam-research/roam-tools-core 0.4.2 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +6 -8
- package/dist/graph-resolver.d.ts.map +1 -1
- package/dist/graph-resolver.js +4 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/operations/blocks.d.ts +59 -3
- package/dist/operations/blocks.d.ts.map +1 -1
- package/dist/operations/blocks.js +122 -16
- package/dist/operations/datalog.d.ts +16 -0
- package/dist/operations/datalog.d.ts.map +1 -0
- package/dist/operations/datalog.js +16 -0
- package/dist/operations/files.d.ts.map +1 -1
- package/dist/operations/files.js +18 -5
- package/dist/operations/graphs.d.ts.map +1 -1
- package/dist/operations/graphs.js +3 -4
- package/dist/operations/navigation.d.ts.map +1 -1
- package/dist/operations/navigation.js +4 -1
- package/dist/operations/pages.d.ts +3 -0
- package/dist/operations/pages.d.ts.map +1 -1
- package/dist/operations/pages.js +42 -10
- package/dist/operations/query.d.ts.map +1 -1
- package/dist/operations/query.js +24 -6
- package/dist/operations/search.d.ts.map +1 -1
- package/dist/operations/search.js +23 -7
- package/dist/roam-api.d.ts.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +49 -31
- package/dist/types.d.ts +52 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +25 -6
- package/package.json +1 -1
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAGhB,eAAe,EAEhB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAGhB,eAAe,EAEhB,MAAM,YAAY,CAAC;AAGpB,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,IAAI,CAAuB;gBAEvB,MAAM,EAAE,gBAAgB;YAoBtB,OAAO;YAeP,gBAAgB;YAKhB,KAAK;IAInB,OAAO,CAAC,iBAAiB;IAuBzB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,qBAAqB;IAwB7B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgC5B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAiBlC;;OAEG;IACH,OAAO,CAAC,cAAc;IAsCtB,OAAO,CAAC,aAAa;IAMrB;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,eAAe,CAAC;IAsCxC,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAuExF"}
|
package/dist/client.js
CHANGED
|
@@ -4,7 +4,7 @@ import { readFile } from "fs/promises";
|
|
|
4
4
|
import { homedir } from "os";
|
|
5
5
|
import { join } from "path";
|
|
6
6
|
import open from "open";
|
|
7
|
-
import { EXPECTED_API_VERSION, getErrorMessage, RoamError, ErrorCodes
|
|
7
|
+
import { EXPECTED_API_VERSION, getErrorMessage, RoamError, ErrorCodes } from "./types.js";
|
|
8
8
|
export class RoamClient {
|
|
9
9
|
graphName;
|
|
10
10
|
graphType;
|
package/dist/connect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AA0CD,wBAAsB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4gBzE"}
|
package/dist/connect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { search, select, input } from "@inquirer/prompts";
|
|
2
2
|
import { getPort, getConfiguredGraphsSafe, saveGraphToConfig, removeGraphFromConfig, } from "./graph-resolver.js";
|
|
3
|
-
import { fetchAvailableGraphs, requestToken, sleep, openRoamApp, slugify
|
|
3
|
+
import { fetchAvailableGraphs, requestToken, sleep, openRoamApp, slugify } from "./roam-api.js";
|
|
4
4
|
// ============================================================================
|
|
5
5
|
// API Functions
|
|
6
6
|
// ============================================================================
|
|
@@ -121,7 +121,7 @@ export async function connect(options = {}) {
|
|
|
121
121
|
try {
|
|
122
122
|
availableGraphs = await fetchAvailableGraphs(port);
|
|
123
123
|
}
|
|
124
|
-
catch
|
|
124
|
+
catch {
|
|
125
125
|
console.error("\nCould not connect to Roam Desktop.");
|
|
126
126
|
console.error("Please make sure Roam is running and try again.");
|
|
127
127
|
process.exit(1);
|
|
@@ -171,8 +171,7 @@ export async function connect(options = {}) {
|
|
|
171
171
|
else {
|
|
172
172
|
// Match against available graphs
|
|
173
173
|
const graphType = options.type;
|
|
174
|
-
const match = availableGraphs.find((g) => g.name === options.graph &&
|
|
175
|
-
(!graphType || g.type === graphType));
|
|
174
|
+
const match = availableGraphs.find((g) => g.name === options.graph && (!graphType || g.type === graphType));
|
|
176
175
|
if (!match) {
|
|
177
176
|
console.error(`Error: Graph "${options.graph}" not found in available graphs.`);
|
|
178
177
|
if (availableGraphs.length > 0) {
|
|
@@ -243,8 +242,7 @@ export async function connect(options = {}) {
|
|
|
243
242
|
source: async (input) => {
|
|
244
243
|
// Filter available graphs (exclude custom option placeholder)
|
|
245
244
|
const filtered = input
|
|
246
|
-
? choices.filter((g) => !g.isCustomOption &&
|
|
247
|
-
g.name.toLowerCase().includes(input.toLowerCase()))
|
|
245
|
+
? choices.filter((g) => !g.isCustomOption && g.name.toLowerCase().includes(input.toLowerCase()))
|
|
248
246
|
: choices.filter((g) => !g.isCustomOption);
|
|
249
247
|
// Build results with custom option
|
|
250
248
|
const results = filtered.map((g) => {
|
|
@@ -280,7 +278,7 @@ export async function connect(options = {}) {
|
|
|
280
278
|
const customName = await input({
|
|
281
279
|
message: "Enter the graph name:",
|
|
282
280
|
default: defaultName,
|
|
283
|
-
validate: (value) => value.trim() ? true : "Graph name cannot be empty",
|
|
281
|
+
validate: (value) => (value.trim() ? true : "Graph name cannot be empty"),
|
|
284
282
|
});
|
|
285
283
|
// Public graphs are always hosted
|
|
286
284
|
const customType = "hosted";
|
|
@@ -370,7 +368,7 @@ export async function connect(options = {}) {
|
|
|
370
368
|
console.log("\nTo change this token's permissions:");
|
|
371
369
|
console.log(" 1. Open Roam Desktop and open the graph");
|
|
372
370
|
console.log(" 2. Go to Settings > Graph > Local API Tokens");
|
|
373
|
-
console.log(
|
|
371
|
+
console.log(" 3. Find the token and adjust its permissions");
|
|
374
372
|
// Permission changes are synced when get_graph_guidelines calls getTokenInfo()
|
|
375
373
|
console.log("\nChanges will be synced automatically next time the MCP is started.");
|
|
376
374
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-resolver.d.ts","sourceRoot":"","sources":["../src/graph-resolver.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,aAAa,EACb,WAAW,EACX,aAAa,EAGb,WAAW,EAEZ,MAAM,YAAY,CAAC;AAyBpB,wBAAsB,OAAO,IAAI,OAAO,CAA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MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAkDjF;AAiBD;;;;GAIG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAgBpF"}
|
package/dist/graph-resolver.js
CHANGED
|
@@ -223,7 +223,8 @@ export async function updateGraphTokenStatus(nickname, updates) {
|
|
|
223
223
|
graph.accessLevel = updates.accessLevel;
|
|
224
224
|
changed = true;
|
|
225
225
|
}
|
|
226
|
-
if (updates.lastKnownTokenStatus !== undefined &&
|
|
226
|
+
if (updates.lastKnownTokenStatus !== undefined &&
|
|
227
|
+
graph.lastKnownTokenStatus !== updates.lastKnownTokenStatus) {
|
|
227
228
|
graph.lastKnownTokenStatus = updates.lastKnownTokenStatus;
|
|
228
229
|
changed = true;
|
|
229
230
|
}
|
|
@@ -288,7 +289,7 @@ export async function resolveGraph(providedGraph) {
|
|
|
288
289
|
if (!graphConfig) {
|
|
289
290
|
throw new RoamError(`Graph "${providedGraph}" not found in config. Available graph nicknames are listed below.`, ErrorCodes.GRAPH_NOT_CONFIGURED, {
|
|
290
291
|
available_graphs: await getConfiguredGraphs(),
|
|
291
|
-
instruction: "Pass the 'nickname' value as the graph parameter.
|
|
292
|
+
instruction: "Pass the 'nickname' value as the graph parameter. After identifying which graph to use, ALWAYS call get_graph_guidelines next — it returns essential context and orientation for the session.",
|
|
292
293
|
});
|
|
293
294
|
}
|
|
294
295
|
return {
|
|
@@ -315,7 +316,7 @@ export async function resolveGraph(providedGraph) {
|
|
|
315
316
|
// 3. Multiple graphs - require explicit selection
|
|
316
317
|
throw new RoamError("Multiple graphs configured. Pass a graph nickname as the graph parameter to specify which graph to use.", ErrorCodes.GRAPH_NOT_SELECTED, {
|
|
317
318
|
available_graphs: await getConfiguredGraphs(),
|
|
318
|
-
instruction: "Pass the 'nickname' value as the graph parameter.
|
|
319
|
+
instruction: "Pass the 'nickname' value as the graph parameter. After identifying which graph to use, ALWAYS call get_graph_guidelines next — it returns essential context and orientation for the session.",
|
|
319
320
|
});
|
|
320
321
|
}
|
|
321
322
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type { CallToolResult, TextContent, ImageContent, GraphType, AccessLevel, GraphConfig, RoamMcpConfig, ResolvedGraph, ErrorCode, RoamApiError, RoamResponse, RoamClientConfig, Block, Page, BlockLocation, WindowType, SidebarWindow, SidebarWindowInfo, FocusedBlock, SelectedBlock, MainWindowViewType, MainWindowView, SearchResultPath, SearchResult, SearchResponse, Template, QueryResult, QueryResponse, TokenInfoResponse, TokenInfoResult, } from "./types.js";
|
|
1
|
+
export type { CallToolResult, TextContent, ImageContent, GraphType, AccessLevel, GraphConfig, RoamMcpConfig, ResolvedGraph, ErrorCode, RoamApiError, RoamResponse, RoamClientConfig, 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";
|
|
2
2
|
export { GraphConfigSchema, RoamMcpConfigSchema, ErrorCodes, RoamError, CONFIG_VERSION, EXPECTED_API_VERSION, textResult, imageResult, errorResult, getErrorMessage, } from "./types.js";
|
|
3
3
|
export { RoamClient } from "./client.js";
|
|
4
4
|
export { getPort, resolveGraph, saveGraphToConfig, removeGraphFromConfig, updateGraphTokenStatus, getConfiguredGraphsSafe, getConfiguredGraphs, findGraphConfig, getMcpConfig, getOpenGraphs, } from "./graph-resolver.js";
|
|
5
|
-
export { fetchAvailableGraphs, requestToken, sleep, openRoamApp, slugify
|
|
6
|
-
export type { AvailableGraph, GraphsResponse, TokenExchangeResponse
|
|
5
|
+
export { fetchAvailableGraphs, requestToken, sleep, openRoamApp, slugify } from "./roam-api.js";
|
|
6
|
+
export type { AvailableGraph, GraphsResponse, TokenExchangeResponse } from "./roam-api.js";
|
|
7
7
|
export { tools, findTool, routeToolCall } from "./tools.js";
|
|
8
|
-
export type { ToolDefinition, ClientToolDefinition, StandaloneToolDefinition
|
|
8
|
+
export type { ToolDefinition, ClientToolDefinition, StandaloneToolDefinition } from "./tools.js";
|
|
9
9
|
//# 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":"AAGA,YAAY,EACV,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,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,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EACL,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,aAAa,GACd,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAChG,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAG3F,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,6 @@ export { RoamClient } from "./client.js";
|
|
|
5
5
|
// Graph resolution and config management
|
|
6
6
|
export { getPort, resolveGraph, saveGraphToConfig, removeGraphFromConfig, updateGraphTokenStatus, getConfiguredGraphsSafe, getConfiguredGraphs, findGraphConfig, getMcpConfig, getOpenGraphs, } from "./graph-resolver.js";
|
|
7
7
|
// Shared Roam API functions
|
|
8
|
-
export { fetchAvailableGraphs, requestToken, sleep, openRoamApp, slugify
|
|
8
|
+
export { fetchAvailableGraphs, requestToken, sleep, openRoamApp, slugify } from "./roam-api.js";
|
|
9
9
|
// Tool definitions and routing
|
|
10
10
|
export { tools, findTool, routeToolCall } from "./tools.js";
|
|
@@ -2,16 +2,25 @@ import { z } from "zod";
|
|
|
2
2
|
import type { RoamClient } from "../client.js";
|
|
3
3
|
import type { CallToolResult } from "../types.js";
|
|
4
4
|
export declare const CreateBlockSchema: z.ZodObject<{
|
|
5
|
-
parentUid: z.ZodString
|
|
5
|
+
parentUid: z.ZodOptional<z.ZodString>;
|
|
6
|
+
pageTitle: z.ZodOptional<z.ZodString>;
|
|
7
|
+
dailyNotePage: z.ZodOptional<z.ZodString>;
|
|
8
|
+
nestUnder: z.ZodOptional<z.ZodString>;
|
|
6
9
|
markdown: z.ZodString;
|
|
7
10
|
order: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodEnum<["first", "last"]>]>>;
|
|
8
11
|
}, "strip", z.ZodTypeAny, {
|
|
9
12
|
markdown: string;
|
|
10
|
-
parentUid
|
|
13
|
+
parentUid?: string | undefined;
|
|
14
|
+
pageTitle?: string | undefined;
|
|
15
|
+
dailyNotePage?: string | undefined;
|
|
16
|
+
nestUnder?: string | undefined;
|
|
11
17
|
order?: number | "first" | "last" | undefined;
|
|
12
18
|
}, {
|
|
13
19
|
markdown: string;
|
|
14
|
-
parentUid
|
|
20
|
+
parentUid?: string | undefined;
|
|
21
|
+
pageTitle?: string | undefined;
|
|
22
|
+
dailyNotePage?: string | undefined;
|
|
23
|
+
nestUnder?: string | undefined;
|
|
15
24
|
order?: number | "first" | "last" | undefined;
|
|
16
25
|
}>;
|
|
17
26
|
export declare const GetBlockSchema: z.ZodObject<{
|
|
@@ -29,16 +38,22 @@ export declare const UpdateBlockSchema: z.ZodObject<{
|
|
|
29
38
|
string: z.ZodOptional<z.ZodString>;
|
|
30
39
|
open: z.ZodOptional<z.ZodBoolean>;
|
|
31
40
|
heading: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
childrenViewType: z.ZodOptional<z.ZodEnum<["bullet", "numbered", "document"]>>;
|
|
42
|
+
textAlign: z.ZodOptional<z.ZodEnum<["left", "center", "right", "justify"]>>;
|
|
32
43
|
}, "strip", z.ZodTypeAny, {
|
|
33
44
|
uid: string;
|
|
34
45
|
string?: string | undefined;
|
|
46
|
+
childrenViewType?: "bullet" | "numbered" | "document" | undefined;
|
|
35
47
|
open?: boolean | undefined;
|
|
36
48
|
heading?: number | undefined;
|
|
49
|
+
textAlign?: "left" | "center" | "right" | "justify" | undefined;
|
|
37
50
|
}, {
|
|
38
51
|
uid: string;
|
|
39
52
|
string?: string | undefined;
|
|
53
|
+
childrenViewType?: "bullet" | "numbered" | "document" | undefined;
|
|
40
54
|
open?: boolean | undefined;
|
|
41
55
|
heading?: number | undefined;
|
|
56
|
+
textAlign?: "left" | "center" | "right" | "justify" | undefined;
|
|
42
57
|
}>;
|
|
43
58
|
export declare const DeleteBlockSchema: z.ZodObject<{
|
|
44
59
|
uid: z.ZodString;
|
|
@@ -108,6 +123,7 @@ export interface BacklinkResult {
|
|
|
108
123
|
}>;
|
|
109
124
|
}
|
|
110
125
|
export interface GetBacklinksResponse {
|
|
126
|
+
queriedAt?: string;
|
|
111
127
|
total: number;
|
|
112
128
|
results: BacklinkResult[];
|
|
113
129
|
}
|
|
@@ -117,4 +133,44 @@ export declare function updateBlock(client: RoamClient, params: UpdateBlockParam
|
|
|
117
133
|
export declare function deleteBlock(client: RoamClient, params: DeleteBlockParams): Promise<CallToolResult>;
|
|
118
134
|
export declare function moveBlock(client: RoamClient, params: MoveBlockParams): Promise<CallToolResult>;
|
|
119
135
|
export declare function getBacklinks(client: RoamClient, params: GetBacklinksParams): Promise<CallToolResult>;
|
|
136
|
+
export declare const AddCommentSchema: z.ZodObject<{
|
|
137
|
+
blockUid: z.ZodString;
|
|
138
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
139
|
+
commentMarkdown: z.ZodOptional<z.ZodString>;
|
|
140
|
+
}, "strip", z.ZodTypeAny, {
|
|
141
|
+
blockUid: string;
|
|
142
|
+
comment?: string | undefined;
|
|
143
|
+
commentMarkdown?: string | undefined;
|
|
144
|
+
}, {
|
|
145
|
+
blockUid: string;
|
|
146
|
+
comment?: string | undefined;
|
|
147
|
+
commentMarkdown?: string | undefined;
|
|
148
|
+
}>;
|
|
149
|
+
export declare const GetCommentsSchema: z.ZodObject<{
|
|
150
|
+
blockUid: z.ZodString;
|
|
151
|
+
maxDepth: z.ZodOptional<z.ZodNumber>;
|
|
152
|
+
}, "strip", z.ZodTypeAny, {
|
|
153
|
+
blockUid: string;
|
|
154
|
+
maxDepth?: number | undefined;
|
|
155
|
+
}, {
|
|
156
|
+
blockUid: string;
|
|
157
|
+
maxDepth?: number | undefined;
|
|
158
|
+
}>;
|
|
159
|
+
export type AddCommentParams = z.infer<typeof AddCommentSchema>;
|
|
160
|
+
export type GetCommentsParams = z.infer<typeof GetCommentsSchema>;
|
|
161
|
+
export interface CommentResult {
|
|
162
|
+
parentUid: string;
|
|
163
|
+
author: string;
|
|
164
|
+
createdTime: string;
|
|
165
|
+
editedTime: string;
|
|
166
|
+
markdown: string;
|
|
167
|
+
singleEditableUid: string | null;
|
|
168
|
+
}
|
|
169
|
+
export interface GetCommentsResponse {
|
|
170
|
+
queriedAt?: string;
|
|
171
|
+
total: number;
|
|
172
|
+
comments: CommentResult[];
|
|
173
|
+
}
|
|
174
|
+
export declare function addComment(client: RoamClient, params: AddCommentParams): Promise<CallToolResult>;
|
|
175
|
+
export declare function getComments(client: RoamClient, params: GetCommentsParams): Promise<CallToolResult>;
|
|
120
176
|
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -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,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,
|
|
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,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,aAAa,CAAC;AAIpE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EA+B5B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;EAMzB,CAAC;AAEH,eAAO,MAAM,iBAAiB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ACvB,OAAO,CAAC,cAAc,CAAC,CA0BzB;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,cAAc,CAAC,CAMzB"}
|
|
@@ -1,20 +1,47 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { textResult } from "../types.js";
|
|
2
|
+
import { textResult, RoamError, ErrorCodes } from "../types.js";
|
|
3
3
|
// Schemas
|
|
4
4
|
export const CreateBlockSchema = z.object({
|
|
5
|
-
parentUid: z
|
|
5
|
+
parentUid: z
|
|
6
|
+
.string()
|
|
7
|
+
.optional()
|
|
8
|
+
.describe("UID of parent block or page. Exactly one of parentUid, pageTitle, or dailyNotePage is required."),
|
|
9
|
+
pageTitle: z
|
|
10
|
+
.string()
|
|
11
|
+
.optional()
|
|
12
|
+
.describe("Page title to create block under (creates the page if it doesn't exist). Exactly one of parentUid, pageTitle, or dailyNotePage is required."),
|
|
13
|
+
dailyNotePage: z
|
|
14
|
+
.string()
|
|
15
|
+
.regex(/^\d{2}-\d{2}-\d{4}$/, "Must be MM-DD-YYYY format (e.g. '03-17-2026')")
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Daily note date in MM-DD-YYYY format (e.g. '03-17-2026'). Targets that day's daily note page, creating it if needed. Exactly one of parentUid, pageTitle, or dailyNotePage is required."),
|
|
18
|
+
nestUnder: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Insert under a direct child block matching this string (matches on the block's string field, including markup like **bold** or [[links]]). If no match exists, creates a new child block with this text first, then inserts under it. Works with parentUid, pageTitle, or dailyNotePage."),
|
|
6
22
|
markdown: z.string().describe("Markdown content for the block"),
|
|
7
|
-
order: z
|
|
23
|
+
order: z
|
|
24
|
+
.union([z.coerce.number(), z.enum(["first", "last"])])
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Position (number, 'first', or 'last'). Defaults to 'last'"),
|
|
8
27
|
});
|
|
9
28
|
export const GetBlockSchema = z.object({
|
|
10
29
|
uid: z.string().describe("Block UID"),
|
|
11
|
-
maxDepth: z.coerce
|
|
30
|
+
maxDepth: z.coerce
|
|
31
|
+
.number()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Max depth of children to include in markdown (omit for full tree)"),
|
|
12
34
|
});
|
|
13
35
|
export const UpdateBlockSchema = z.object({
|
|
14
36
|
uid: z.string().describe("Block UID"),
|
|
15
37
|
string: z.string().optional().describe("New text content"),
|
|
16
38
|
open: z.boolean().optional().describe("Collapse state"),
|
|
17
39
|
heading: z.coerce.number().optional().describe("Heading level (0-3)"),
|
|
40
|
+
childrenViewType: z
|
|
41
|
+
.enum(["bullet", "numbered", "document"])
|
|
42
|
+
.optional()
|
|
43
|
+
.describe("How children are displayed (bullet, numbered, or document)"),
|
|
44
|
+
textAlign: z.enum(["left", "center", "right", "justify"]).optional().describe("Text alignment"),
|
|
18
45
|
});
|
|
19
46
|
export const DeleteBlockSchema = z.object({
|
|
20
47
|
uid: z.string().describe("Block UID to delete"),
|
|
@@ -22,28 +49,59 @@ export const DeleteBlockSchema = z.object({
|
|
|
22
49
|
export const MoveBlockSchema = z.object({
|
|
23
50
|
uid: z.string().describe("Block UID to move"),
|
|
24
51
|
parentUid: z.string().describe("UID of the new parent block or page"),
|
|
25
|
-
order: z
|
|
52
|
+
order: z
|
|
53
|
+
.union([z.coerce.number(), z.enum(["first", "last"])])
|
|
54
|
+
.describe("Position in the new parent (number, 'first', or 'last')"),
|
|
26
55
|
});
|
|
27
56
|
export const GetBacklinksSchema = z.object({
|
|
28
57
|
uid: z.string().optional().describe("UID of page or block (required if no title)"),
|
|
29
58
|
title: z.string().optional().describe("Page title (required if no uid)"),
|
|
30
59
|
offset: z.coerce.number().optional().describe("Skip first N results (default: 0)"),
|
|
31
60
|
limit: z.coerce.number().optional().describe("Max results to return (default: 20)"),
|
|
32
|
-
sort: z
|
|
61
|
+
sort: z
|
|
62
|
+
.enum(["created-date", "edited-date", "daily-note-date"])
|
|
63
|
+
.optional()
|
|
64
|
+
.describe("Sort order (default: created-date)"),
|
|
33
65
|
sortOrder: z.enum(["asc", "desc"]).optional().describe("Sort direction (default: desc)"),
|
|
34
|
-
search: z
|
|
35
|
-
|
|
36
|
-
|
|
66
|
+
search: z
|
|
67
|
+
.string()
|
|
68
|
+
.optional()
|
|
69
|
+
.describe("Filter results by text match (searches block, parents, children, page title)"),
|
|
70
|
+
includePath: z
|
|
71
|
+
.boolean()
|
|
72
|
+
.optional()
|
|
73
|
+
.describe("Include breadcrumb path to each result (default: true)"),
|
|
74
|
+
maxDepth: z.coerce
|
|
75
|
+
.number()
|
|
76
|
+
.optional()
|
|
77
|
+
.describe("Max depth of children to include in markdown (default: 2)"),
|
|
37
78
|
});
|
|
38
79
|
export async function createBlock(client, params) {
|
|
80
|
+
// Validate: exactly one of parentUid, pageTitle, or dailyNotePage
|
|
81
|
+
const targets = [params.parentUid, params.pageTitle, params.dailyNotePage].filter((v) => v !== undefined);
|
|
82
|
+
if (targets.length === 0) {
|
|
83
|
+
throw new RoamError("Either 'parentUid', 'pageTitle', or 'dailyNotePage' is required to specify where to create the block", ErrorCodes.VALIDATION_ERROR);
|
|
84
|
+
}
|
|
85
|
+
if (targets.length > 1) {
|
|
86
|
+
throw new RoamError("Provide only one of 'parentUid', 'pageTitle', or 'dailyNotePage'", ErrorCodes.VALIDATION_ERROR);
|
|
87
|
+
}
|
|
88
|
+
const location = {
|
|
89
|
+
order: params.order ?? "last",
|
|
90
|
+
};
|
|
91
|
+
if (params.parentUid !== undefined) {
|
|
92
|
+
location["parent-uid"] = params.parentUid;
|
|
93
|
+
}
|
|
94
|
+
else if (params.dailyNotePage !== undefined) {
|
|
95
|
+
location["page-title"] = { "daily-note-page": params.dailyNotePage };
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
location["page-title"] = params.pageTitle;
|
|
99
|
+
}
|
|
100
|
+
if (params.nestUnder !== undefined) {
|
|
101
|
+
location["nest-under-str"] = params.nestUnder;
|
|
102
|
+
}
|
|
39
103
|
const response = await client.call("data.block.fromMarkdown", [
|
|
40
|
-
{
|
|
41
|
-
location: {
|
|
42
|
-
"parent-uid": params.parentUid,
|
|
43
|
-
order: params.order ?? "last",
|
|
44
|
-
},
|
|
45
|
-
"markdown-string": params.markdown,
|
|
46
|
-
},
|
|
104
|
+
{ location, "markdown-string": params.markdown },
|
|
47
105
|
]);
|
|
48
106
|
return textResult(response.result ?? { uids: [] });
|
|
49
107
|
}
|
|
@@ -62,6 +120,10 @@ export async function updateBlock(client, params) {
|
|
|
62
120
|
block.open = params.open;
|
|
63
121
|
if (params.heading !== undefined)
|
|
64
122
|
block.heading = params.heading;
|
|
123
|
+
if (params.childrenViewType !== undefined)
|
|
124
|
+
block["children-view-type"] = params.childrenViewType;
|
|
125
|
+
if (params.textAlign !== undefined)
|
|
126
|
+
block["text-align"] = params.textAlign;
|
|
65
127
|
await client.call("data.block.update", [{ block }]);
|
|
66
128
|
return textResult({ success: true });
|
|
67
129
|
}
|
|
@@ -106,3 +168,47 @@ export async function getBacklinks(client, params) {
|
|
|
106
168
|
const response = await client.call("data.ai.getBacklinks", [apiParams]);
|
|
107
169
|
return textResult(response.result ?? { total: 0, results: [] });
|
|
108
170
|
}
|
|
171
|
+
// --- Comments ---
|
|
172
|
+
export const AddCommentSchema = z.object({
|
|
173
|
+
blockUid: z.string().describe("UID of the block to comment on"),
|
|
174
|
+
comment: z
|
|
175
|
+
.string()
|
|
176
|
+
.optional()
|
|
177
|
+
.describe("Plain text comment (single block, editable later via update_block). Required if commentMarkdown not provided. Preferred for simple comments."),
|
|
178
|
+
commentMarkdown: z
|
|
179
|
+
.string()
|
|
180
|
+
.optional()
|
|
181
|
+
.describe("Markdown comment parsed into multiple blocks. Required if comment not provided. Use only when you need structure (lists, headings). Harder to edit later."),
|
|
182
|
+
});
|
|
183
|
+
export const GetCommentsSchema = z.object({
|
|
184
|
+
blockUid: z.string().describe("UID of the block to get comments for"),
|
|
185
|
+
maxDepth: z.coerce
|
|
186
|
+
.number()
|
|
187
|
+
.optional()
|
|
188
|
+
.describe("Max depth of children to include in each comment's markdown (omit for full tree)"),
|
|
189
|
+
});
|
|
190
|
+
export async function addComment(client, params) {
|
|
191
|
+
// Validate: exactly one of comment or commentMarkdown must be provided
|
|
192
|
+
const hasComment = params.comment !== undefined;
|
|
193
|
+
const hasCommentMarkdown = params.commentMarkdown !== undefined;
|
|
194
|
+
if (!hasComment && !hasCommentMarkdown) {
|
|
195
|
+
throw new RoamError("Provide one of 'comment' or 'commentMarkdown'", ErrorCodes.VALIDATION_ERROR);
|
|
196
|
+
}
|
|
197
|
+
if (hasComment && hasCommentMarkdown) {
|
|
198
|
+
throw new RoamError("Provide 'comment' or 'commentMarkdown', not both", ErrorCodes.VALIDATION_ERROR);
|
|
199
|
+
}
|
|
200
|
+
const apiParams = { "block-uid": params.blockUid };
|
|
201
|
+
if (hasComment)
|
|
202
|
+
apiParams["reply-string"] = params.comment;
|
|
203
|
+
if (hasCommentMarkdown)
|
|
204
|
+
apiParams["reply-markdown"] = params.commentMarkdown;
|
|
205
|
+
const response = await client.call("data.block.addComment", [apiParams]);
|
|
206
|
+
return textResult(response.result ?? { uids: [] });
|
|
207
|
+
}
|
|
208
|
+
export async function getComments(client, params) {
|
|
209
|
+
const apiParams = { uid: params.blockUid };
|
|
210
|
+
if (params.maxDepth !== undefined)
|
|
211
|
+
apiParams.maxDepth = params.maxDepth;
|
|
212
|
+
const response = await client.call("data.ai.getComments", [apiParams]);
|
|
213
|
+
return textResult(response.result ?? { total: 0, comments: [] });
|
|
214
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RoamClient } from "../client.js";
|
|
3
|
+
import type { CallToolResult } from "../types.js";
|
|
4
|
+
export declare const DatalogQuerySchema: z.ZodObject<{
|
|
5
|
+
query: z.ZodString;
|
|
6
|
+
inputs: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
query: string;
|
|
9
|
+
inputs?: unknown[] | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
query: string;
|
|
12
|
+
inputs?: unknown[] | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
export type DatalogQueryParams = z.infer<typeof DatalogQuerySchema>;
|
|
15
|
+
export declare function datalogQuery(client: RoamClient, params: DatalogQueryParams): Promise<CallToolResult>;
|
|
16
|
+
//# sourceMappingURL=datalog.d.ts.map
|
|
@@ -0,0 +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,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,eAAO,MAAM,kBAAkB;;;;;;;;;EAQ7B,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,wBAAsB,YAAY,CAChC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,cAAc,CAAC,CAIzB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { textResult } from "../types.js";
|
|
3
|
+
export const DatalogQuerySchema = z.object({
|
|
4
|
+
query: z
|
|
5
|
+
.string()
|
|
6
|
+
.describe("Datalog query string (e.g., '[:find ?title :where [?e :node/title ?title]]')"),
|
|
7
|
+
inputs: z
|
|
8
|
+
.array(z.unknown())
|
|
9
|
+
.optional()
|
|
10
|
+
.describe("Input parameters for the query, corresponding to :in clause bindings after $"),
|
|
11
|
+
});
|
|
12
|
+
export async function datalogQuery(client, params) {
|
|
13
|
+
const args = params.inputs ? [params.query, ...params.inputs] : [params.query];
|
|
14
|
+
const response = await client.call("q", args);
|
|
15
|
+
return textResult(response.result ?? []);
|
|
16
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/operations/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,eAAO,MAAM,aAAa;;;;;;EAExB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/operations/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,eAAO,MAAM,aAAa;;;;;;EAExB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;EAkB3B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;EAE3B,CAAC;AAGH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAC1D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AA+GhE,wBAAsB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAkBhG;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,cAAc,CAAC,CAiDzB;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,cAAc,CAAC,CAGzB"}
|
package/dist/operations/files.js
CHANGED
|
@@ -7,11 +7,23 @@ export const FileGetSchema = z.object({
|
|
|
7
7
|
url: z.string().describe("Firebase storage URL of the file"),
|
|
8
8
|
});
|
|
9
9
|
export const FileUploadSchema = z.object({
|
|
10
|
-
filePath: z
|
|
10
|
+
filePath: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Local file path (preferred) - server reads the file directly"),
|
|
11
14
|
url: z.string().optional().describe("Remote URL to fetch the file from"),
|
|
12
|
-
base64: z
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
base64: z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Base64-encoded file data (fallback for sandboxed clients)"),
|
|
19
|
+
mimetype: z
|
|
20
|
+
.string()
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("MIME type (e.g., image/png, image/jpeg) - auto-detected if not provided"),
|
|
23
|
+
filename: z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Original filename for reference - derived from path/url if not provided"),
|
|
15
27
|
});
|
|
16
28
|
export const FileDeleteSchema = z.object({
|
|
17
29
|
url: z.string().describe("Firebase storage URL of the file to delete"),
|
|
@@ -102,7 +114,8 @@ async function fetchRemoteFile(url) {
|
|
|
102
114
|
// Try Content-Type header first, then extension, then magic bytes
|
|
103
115
|
let mimetype = response.headers.get("content-type")?.split(";")[0];
|
|
104
116
|
if (!mimetype || mimetype === "application/octet-stream") {
|
|
105
|
-
mimetype =
|
|
117
|
+
mimetype =
|
|
118
|
+
detectMimeTypeFromExtension(urlPath) || detectMimeTypeFromBase64(base64) || undefined;
|
|
106
119
|
}
|
|
107
120
|
if (!mimetype) {
|
|
108
121
|
throw new Error(`Could not detect MIME type for URL: ${url}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphs.d.ts","sourceRoot":"","sources":["../../src/operations/graphs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"graphs.d.ts","sourceRoot":"","sources":["../../src/operations/graphs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAgBlD,eAAO,MAAM,gBAAgB,gDAAe,CAAC;AAE7C,eAAO,MAAM,mBAAmB;;;;;;;;;EAkB9B,CAAC;AAMH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAMtE;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,cAAc,CAAC,CAqB1D;AAkDD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CA0JtF"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { textResult, RoamError, ErrorCodes } from "../types.js";
|
|
5
5
|
import { getConfiguredGraphs, getConfiguredGraphsSafe, getPort, saveGraphToConfig, } from "../graph-resolver.js";
|
|
6
|
-
import { fetchAvailableGraphs, requestToken, sleep, openRoamApp, slugify
|
|
6
|
+
import { fetchAvailableGraphs, requestToken, sleep, openRoamApp, slugify } from "../roam-api.js";
|
|
7
7
|
// ============================================================================
|
|
8
8
|
// Schemas
|
|
9
9
|
// ============================================================================
|
|
@@ -33,7 +33,7 @@ export async function listGraphs() {
|
|
|
33
33
|
const graphs = await getConfiguredGraphs();
|
|
34
34
|
return textResult({
|
|
35
35
|
graphs,
|
|
36
|
-
instruction: "Pass the 'nickname' value as the graph parameter.
|
|
36
|
+
instruction: "Pass the 'nickname' value as the graph parameter. After identifying which graph to use, ALWAYS call get_graph_guidelines next — it returns essential context and orientation for the session.",
|
|
37
37
|
setup: "To connect additional graphs, use the setup_new_graph tool (call it without arguments to see available graphs).",
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -78,8 +78,7 @@ async function fetchAvailableGraphsWithRetry(port) {
|
|
|
78
78
|
}
|
|
79
79
|
catch (error) {
|
|
80
80
|
const err = error;
|
|
81
|
-
const isConnectionError = err.cause?.code === "ECONNREFUSED" ||
|
|
82
|
-
err.message?.includes("fetch failed");
|
|
81
|
+
const isConnectionError = err.cause?.code === "ECONNREFUSED" || err.message?.includes("fetch failed");
|
|
83
82
|
if (!isConnectionError) {
|
|
84
83
|
throw error;
|
|
85
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/operations/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/operations/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAKV,cAAc,EACf,MAAM,aAAa,CAAC;AAIrB,eAAO,MAAM,oBAAoB,gDAAe,CAAC;AAEjD,eAAO,MAAM,kBAAkB,gDAAe,CAAC;AAE/C,eAAO,MAAM,oBAAoB;;;;;;;;;EAG/B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;EAM5B,CAAC;AAGH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACxE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,wBAAsB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAShF;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAS9E;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,cAAc,CAAC,CAQzB;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,cAAc,CAAC,CAUzB"}
|
|
@@ -9,7 +9,10 @@ export const OpenMainWindowSchema = z.object({
|
|
|
9
9
|
});
|
|
10
10
|
export const OpenSidebarSchema = z.object({
|
|
11
11
|
uid: z.string().describe("UID of page or block"),
|
|
12
|
-
type: z
|
|
12
|
+
type: z
|
|
13
|
+
.enum(["block", "outline", "mentions"])
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("View type (default: outline)"),
|
|
13
16
|
});
|
|
14
17
|
export async function getOpenWindows(client) {
|
|
15
18
|
const [mainResponse, sidebarResponse] = await Promise.all([
|
|
@@ -5,14 +5,17 @@ export declare const CreatePageSchema: z.ZodObject<{
|
|
|
5
5
|
title: z.ZodString;
|
|
6
6
|
markdown: z.ZodOptional<z.ZodString>;
|
|
7
7
|
uid: z.ZodOptional<z.ZodString>;
|
|
8
|
+
childrenViewType: z.ZodOptional<z.ZodEnum<["document", "bullet", "numbered"]>>;
|
|
8
9
|
}, "strip", z.ZodTypeAny, {
|
|
9
10
|
title: string;
|
|
10
11
|
markdown?: string | undefined;
|
|
11
12
|
uid?: string | undefined;
|
|
13
|
+
childrenViewType?: "bullet" | "numbered" | "document" | undefined;
|
|
12
14
|
}, {
|
|
13
15
|
title: string;
|
|
14
16
|
markdown?: string | undefined;
|
|
15
17
|
uid?: string | undefined;
|
|
18
|
+
childrenViewType?: "bullet" | "numbered" | "document" | undefined;
|
|
16
19
|
}>;
|
|
17
20
|
export declare const GetPageSchema: z.ZodObject<{
|
|
18
21
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -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,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,
|
|
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,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,aAAa,CAAC;AAInE,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,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAC1D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,wBAAsB,UAAU,CAC9B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,cAAc,CAAC,CASzB;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAQhG;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,cAAc,CAAC,CAGzB;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,cAAc,CAAC,CAUzB;AAED,wBAAsB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CA0B/E"}
|
package/dist/operations/pages.js
CHANGED
|
@@ -4,12 +4,22 @@ import { textResult } from "../types.js";
|
|
|
4
4
|
export const CreatePageSchema = z.object({
|
|
5
5
|
title: z.string().describe("Page title"),
|
|
6
6
|
markdown: z.string().optional().describe("Markdown content for the page"),
|
|
7
|
-
uid: z
|
|
7
|
+
uid: z
|
|
8
|
+
.string()
|
|
9
|
+
.optional()
|
|
10
|
+
.describe("Custom UID to assign to the new page. Omit to let Roam auto-generate one (recommended)"),
|
|
11
|
+
childrenViewType: z
|
|
12
|
+
.enum(["document", "bullet", "numbered"])
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("How children are displayed (document, bullet, or numbered)"),
|
|
8
15
|
});
|
|
9
16
|
export const GetPageSchema = z.object({
|
|
10
17
|
title: z.string().optional().describe("Page title (alternative to uid)"),
|
|
11
18
|
uid: z.string().optional().describe("Page UID"),
|
|
12
|
-
maxDepth: z.coerce
|
|
19
|
+
maxDepth: z.coerce
|
|
20
|
+
.number()
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Max depth of children to include in markdown (omit for full tree)"),
|
|
13
23
|
});
|
|
14
24
|
export const DeletePageSchema = z.object({
|
|
15
25
|
uid: z.string().describe("Page UID to delete"),
|
|
@@ -17,21 +27,31 @@ export const DeletePageSchema = z.object({
|
|
|
17
27
|
export const UpdatePageSchema = z.object({
|
|
18
28
|
uid: z.string().describe("Page UID"),
|
|
19
29
|
title: z.string().optional().describe("New page title"),
|
|
20
|
-
childrenViewType: z
|
|
21
|
-
|
|
30
|
+
childrenViewType: z
|
|
31
|
+
.enum(["document", "bullet", "numbered"])
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("How children are displayed (document, bullet, or numbered)"),
|
|
34
|
+
mergePages: z
|
|
35
|
+
.boolean()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe("If true, merge with existing page when renaming to a title that already exists (default: false)"),
|
|
22
38
|
});
|
|
23
39
|
export const GetGuidelinesSchema = z.object({});
|
|
24
40
|
export async function createPage(client, params) {
|
|
41
|
+
const page = { title: params.title };
|
|
42
|
+
if (params.uid !== undefined)
|
|
43
|
+
page.uid = params.uid;
|
|
44
|
+
if (params.childrenViewType !== undefined)
|
|
45
|
+
page["children-view-type"] = params.childrenViewType;
|
|
25
46
|
const response = await client.call("data.page.fromMarkdown", [
|
|
26
|
-
{
|
|
27
|
-
page: { title: params.title, uid: params.uid },
|
|
28
|
-
"markdown-string": params.markdown,
|
|
29
|
-
},
|
|
47
|
+
{ page, "markdown-string": params.markdown },
|
|
30
48
|
]);
|
|
31
49
|
return textResult(response.result ?? { uid: "" });
|
|
32
50
|
}
|
|
33
51
|
export async function getPage(client, params) {
|
|
34
|
-
const apiParams = params.uid
|
|
52
|
+
const apiParams = params.uid
|
|
53
|
+
? { uid: params.uid }
|
|
54
|
+
: { title: params.title };
|
|
35
55
|
if (params.maxDepth !== undefined)
|
|
36
56
|
apiParams.maxDepth = params.maxDepth;
|
|
37
57
|
const response = await client.call("data.ai.getPage", [apiParams]);
|
|
@@ -55,5 +75,17 @@ export async function updatePage(client, params) {
|
|
|
55
75
|
}
|
|
56
76
|
export async function getGuidelines(client) {
|
|
57
77
|
const response = await client.call("data.ai.getGraphGuidelines", []);
|
|
58
|
-
|
|
78
|
+
const result = response.result ?? {
|
|
79
|
+
guidelines: null,
|
|
80
|
+
starredPages: [],
|
|
81
|
+
todaysDailyNotePage: null,
|
|
82
|
+
};
|
|
83
|
+
const dnpTitle = result.todaysDailyNotePage;
|
|
84
|
+
const nextSteps = dnpTitle
|
|
85
|
+
? `Start by reading today's daily note page ("${dnpTitle}") with get_page — this is the user's primary workspace for the day. If you need more context, call search with an empty query for recently edited and viewed content. Skip these orientation steps only when the user has already given you a specific task to execute (e.g. "create a page called X").`
|
|
86
|
+
: `Start by calling search with an empty query to see recently edited and viewed content. Skip this only when the user has already given you a specific task to execute.`;
|
|
87
|
+
return textResult({
|
|
88
|
+
...result,
|
|
89
|
+
nextSteps,
|
|
90
|
+
});
|
|
59
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/operations/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,aAAa,CAAC;AAKjE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/operations/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,aAAa,CAAC;AAKjE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BtB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,wBAAsB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CA2B5F"}
|
package/dist/operations/query.js
CHANGED
|
@@ -3,14 +3,32 @@ import { textResult } from "../types.js";
|
|
|
3
3
|
// Schema for executing Roam queries ({{query: }} or {{[[query]]: }} blocks, NOT Datalog)
|
|
4
4
|
// Supports two modes: UID mode (execute existing query block) or Query mode (raw query string)
|
|
5
5
|
export const QuerySchema = z.object({
|
|
6
|
-
uid: z
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
uid: z
|
|
7
|
+
.string()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("UID of a block containing {{query: ...}} or {{[[query]]: ...}} - uses the block's saved display settings and filters"),
|
|
10
|
+
query: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('Raw Roam query string (e.g., "{and: [[TODO]] {not: [[DONE]]}}") - NOT Datalog - results are flat list, no user filters applied'),
|
|
14
|
+
sort: z
|
|
15
|
+
.enum(["created-date", "edited-date", "daily-note-date"])
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Sort order (only for query mode, default: created-date)"),
|
|
18
|
+
sortOrder: z
|
|
19
|
+
.enum(["asc", "desc"])
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Sort direction (only for query mode, default: desc)"),
|
|
22
|
+
includePath: z
|
|
23
|
+
.boolean()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Include breadcrumb path in results (only for query mode, default: true)"),
|
|
11
26
|
offset: z.coerce.number().optional().describe("Skip first N results (default: 0)"),
|
|
12
27
|
limit: z.coerce.number().optional().describe("Max results to return (default: 20)"),
|
|
13
|
-
maxDepth: z.coerce
|
|
28
|
+
maxDepth: z.coerce
|
|
29
|
+
.number()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("Max depth of children to include in markdown (default: 1)"),
|
|
14
32
|
});
|
|
15
33
|
export async function query(client, params) {
|
|
16
34
|
// Validate: exactly one of uid or query must be provided
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/operations/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/operations/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,aAAa,CAAC;AAIrB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;EAoBvB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;EAOhC,CAAC;AAGH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AACxD,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,wBAAsB,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAc9F;AAED,wBAAsB,eAAe,CACnC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,cAAc,CAAC,CAKzB"}
|
|
@@ -2,15 +2,29 @@ import { z } from "zod";
|
|
|
2
2
|
import { textResult } from "../types.js";
|
|
3
3
|
// Schemas
|
|
4
4
|
export const SearchSchema = z.object({
|
|
5
|
-
query: z
|
|
6
|
-
|
|
5
|
+
query: z
|
|
6
|
+
.string()
|
|
7
|
+
.describe("Search query — use empty string to get recently edited and viewed content"),
|
|
8
|
+
scope: z
|
|
9
|
+
.enum(["pages", "blocks", "all"])
|
|
10
|
+
.optional()
|
|
11
|
+
.describe("Search scope: 'pages' for page titles only, 'blocks' for block content only, 'all' for both (default: 'all')"),
|
|
7
12
|
offset: z.coerce.number().optional().describe("Skip first N results (default: 0)"),
|
|
8
13
|
limit: z.coerce.number().optional().describe("Max results (default: 20)"),
|
|
9
|
-
includePath: z
|
|
10
|
-
|
|
14
|
+
includePath: z
|
|
15
|
+
.boolean()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Include breadcrumb path to each result (default: true)"),
|
|
18
|
+
maxDepth: z.coerce
|
|
19
|
+
.number()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Max depth of children to include in markdown (default: 0)"),
|
|
11
22
|
});
|
|
12
23
|
export const SearchTemplatesSchema = z.object({
|
|
13
|
-
query: z
|
|
24
|
+
query: z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Keywords to filter templates by name (case-insensitive). Try relevant keywords first before listing all."),
|
|
14
28
|
});
|
|
15
29
|
export async function search(client, params) {
|
|
16
30
|
const apiParams = {
|
|
@@ -22,12 +36,14 @@ export async function search(client, params) {
|
|
|
22
36
|
};
|
|
23
37
|
if (params.maxDepth !== undefined)
|
|
24
38
|
apiParams.maxDepth = params.maxDepth;
|
|
25
|
-
const response = await client.call("data.ai.search", [
|
|
39
|
+
const response = await client.call("data.ai.search", [
|
|
40
|
+
apiParams,
|
|
41
|
+
]);
|
|
26
42
|
return textResult(response.result ?? { total: 0, results: [] });
|
|
27
43
|
}
|
|
28
44
|
export async function searchTemplates(client, params) {
|
|
29
45
|
const response = await client.call("data.ai.searchTemplates", [
|
|
30
46
|
{ query: params.query },
|
|
31
47
|
]);
|
|
32
|
-
return textResult(response.result ?? []);
|
|
48
|
+
return textResult(response.result ?? { results: [] });
|
|
33
49
|
}
|
package/dist/roam-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roam-api.d.ts","sourceRoot":"","sources":["../src/roam-api.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAM5C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACrE,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC;CACtD;AAMD,wBAAsB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"roam-api.d.ts","sourceRoot":"","sources":["../src/roam-api.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAM5C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,cAA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MAAM,aAAa,CAAC;
|
|
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,EAAE,cAAc,EAAkC,MAAM,YAAY,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA+EzC,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACnC,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACvE,IAAI,EAAE,QAAQ,CAAC;CAChB;AAGD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACnC,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACnD,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,wBAAwB,CAAC;AAsN7E,eAAO,MAAM,KAAK,EAAE,cAAc,EAA+C,CAAC;AAElF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAEjE;AAuFD,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,cAAc,CAAC,CAyIzB"}
|
package/dist/tools.js
CHANGED
|
@@ -3,15 +3,19 @@ import { RoamError } from "./types.js";
|
|
|
3
3
|
import { RoamClient } from "./client.js";
|
|
4
4
|
import { resolveGraph, getPort, updateGraphTokenStatus } from "./graph-resolver.js";
|
|
5
5
|
import { CreatePageSchema, GetPageSchema, DeletePageSchema, UpdatePageSchema, GetGuidelinesSchema, createPage, getPage, deletePage, updatePage, getGuidelines, } from "./operations/pages.js";
|
|
6
|
-
import { CreateBlockSchema, GetBlockSchema, UpdateBlockSchema, DeleteBlockSchema, MoveBlockSchema, GetBacklinksSchema, createBlock, getBlock, updateBlock, deleteBlock, moveBlock, getBacklinks, } from "./operations/blocks.js";
|
|
7
|
-
import { SearchSchema, SearchTemplatesSchema, search, searchTemplates } from "./operations/search.js";
|
|
6
|
+
import { CreateBlockSchema, GetBlockSchema, UpdateBlockSchema, DeleteBlockSchema, MoveBlockSchema, GetBacklinksSchema, AddCommentSchema, GetCommentsSchema, createBlock, getBlock, updateBlock, deleteBlock, moveBlock, getBacklinks, addComment, getComments, } from "./operations/blocks.js";
|
|
7
|
+
import { SearchSchema, SearchTemplatesSchema, search, searchTemplates, } from "./operations/search.js";
|
|
8
8
|
import { QuerySchema, query } from "./operations/query.js";
|
|
9
|
+
import { DatalogQuerySchema, datalogQuery } from "./operations/datalog.js";
|
|
9
10
|
import { GetOpenWindowsSchema, GetSelectionSchema, OpenMainWindowSchema, OpenSidebarSchema, getOpenWindows, getSelection, openMainWindow, openSidebar, } from "./operations/navigation.js";
|
|
10
|
-
import { FileGetSchema, FileUploadSchema, FileDeleteSchema, getFile, uploadFile, deleteFile } from "./operations/files.js";
|
|
11
|
-
import { ListGraphsSchema, SetupNewGraphSchema, listGraphs, setupNewGraph } from "./operations/graphs.js";
|
|
11
|
+
import { FileGetSchema, FileUploadSchema, FileDeleteSchema, getFile, uploadFile, deleteFile, } from "./operations/files.js";
|
|
12
|
+
import { ListGraphsSchema, SetupNewGraphSchema, listGraphs, setupNewGraph, } from "./operations/graphs.js";
|
|
12
13
|
// Common schema for graph parameter (used by most tools)
|
|
13
14
|
const GraphSchema = z.object({
|
|
14
|
-
graph: z
|
|
15
|
+
graph: z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Graph nickname or name (optional - auto-selects if only one graph is configured)"),
|
|
15
19
|
});
|
|
16
20
|
// Helper to extend any schema with graph parameter
|
|
17
21
|
function withGraph(schema) {
|
|
@@ -46,32 +50,44 @@ const graphManagementTools = [
|
|
|
46
50
|
const GUIDELINES_NOTE = "\n\nNote: Call get_graph_guidelines first when starting to work with a graph.";
|
|
47
51
|
// Content Tools (require graph/client)
|
|
48
52
|
const contentTools = [
|
|
49
|
-
defineTool("get_graph_guidelines", "IMPORTANT: Call this tool first when starting to work with a graph, before performing any other operations. Returns user-defined instructions and preferences for AI agents. The user may have specified naming conventions, preferred structures, or constraints that should guide your behavior.", GetGuidelinesSchema, getGuidelines),
|
|
53
|
+
defineTool("get_graph_guidelines", "IMPORTANT: Call this tool first when starting to work with a graph, before performing any other operations. Returns user-defined instructions and preferences for AI agents. The user may have specified naming conventions, preferred structures, or constraints that should guide your behavior. After receiving the response, follow the nextSteps field — it contains orientation actions you should take before proceeding.", GetGuidelinesSchema, getGuidelines),
|
|
50
54
|
defineTool("create_page", "Create a new page in Roam, optionally with markdown content." + GUIDELINES_NOTE, CreatePageSchema, createPage),
|
|
51
|
-
defineTool("create_block", "Create
|
|
55
|
+
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." +
|
|
56
|
+
GUIDELINES_NOTE, CreateBlockSchema, createBlock),
|
|
52
57
|
defineTool("update_block", "Update an existing block's content or properties." + GUIDELINES_NOTE, UpdateBlockSchema, updateBlock),
|
|
53
58
|
defineTool("delete_block", "Delete a block and all its children." + GUIDELINES_NOTE, DeleteBlockSchema, deleteBlock),
|
|
54
59
|
defineTool("move_block", "Move a block to a new location." + GUIDELINES_NOTE, MoveBlockSchema, moveBlock),
|
|
60
|
+
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." +
|
|
61
|
+
GUIDELINES_NOTE, AddCommentSchema, addComment),
|
|
62
|
+
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." +
|
|
63
|
+
GUIDELINES_NOTE, GetCommentsSchema, getComments),
|
|
55
64
|
defineTool("delete_page", "Delete a page and all its contents." + GUIDELINES_NOTE, DeletePageSchema, deletePage),
|
|
56
|
-
defineTool("update_page", "Update a page's title or children view type. Set mergePages to true if renaming to a title that already exists." +
|
|
57
|
-
|
|
58
|
-
defineTool("
|
|
59
|
-
|
|
60
|
-
defineTool("
|
|
61
|
-
|
|
62
|
-
defineTool("
|
|
65
|
+
defineTool("update_page", "Update a page's title or children view type. Set mergePages to true if renaming to a title that already exists." +
|
|
66
|
+
GUIDELINES_NOTE, UpdatePageSchema, updatePage),
|
|
67
|
+
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." +
|
|
68
|
+
GUIDELINES_NOTE, SearchSchema, search),
|
|
69
|
+
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." +
|
|
70
|
+
GUIDELINES_NOTE, SearchTemplatesSchema, searchTemplates),
|
|
71
|
+
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.' +
|
|
72
|
+
GUIDELINES_NOTE, QuerySchema, query),
|
|
73
|
+
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." +
|
|
74
|
+
GUIDELINES_NOTE, DatalogQuerySchema, datalogQuery),
|
|
75
|
+
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." +
|
|
76
|
+
GUIDELINES_NOTE, GetPageSchema, getPage),
|
|
77
|
+
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." +
|
|
78
|
+
GUIDELINES_NOTE, GetBlockSchema, getBlock),
|
|
79
|
+
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." +
|
|
80
|
+
GUIDELINES_NOTE, GetBacklinksSchema, getBacklinks),
|
|
63
81
|
defineTool("get_open_windows", "Get the current view in the main window and all open sidebar windows." + GUIDELINES_NOTE, GetOpenWindowsSchema, getOpenWindows),
|
|
64
82
|
defineTool("get_selection", "Get the currently focused block and any multi-selected blocks." + GUIDELINES_NOTE, GetSelectionSchema, getSelection),
|
|
65
83
|
defineTool("open_main_window", "Navigate to a page or block in the main window." + GUIDELINES_NOTE, OpenMainWindowSchema, openMainWindow),
|
|
66
84
|
defineTool("open_sidebar", "Open a page or block in the right sidebar." + GUIDELINES_NOTE, OpenSidebarSchema, openSidebar),
|
|
67
85
|
defineTool("file_get", "Fetch a file hosted on Roam (handles decryption for encrypted graphs)." + GUIDELINES_NOTE, FileGetSchema, getFile),
|
|
68
|
-
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)." +
|
|
86
|
+
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)." +
|
|
87
|
+
GUIDELINES_NOTE, FileUploadSchema, uploadFile),
|
|
69
88
|
defineTool("file_delete", "Delete a file hosted on Roam." + GUIDELINES_NOTE, FileDeleteSchema, deleteFile),
|
|
70
89
|
];
|
|
71
|
-
export const tools = [
|
|
72
|
-
...graphManagementTools,
|
|
73
|
-
...contentTools,
|
|
74
|
-
];
|
|
90
|
+
export const tools = [...graphManagementTools, ...contentTools];
|
|
75
91
|
export function findTool(name) {
|
|
76
92
|
return tools.find((t) => t.name === name);
|
|
77
93
|
}
|
|
@@ -87,19 +103,13 @@ function prependGraphInfo(result, nickname) {
|
|
|
87
103
|
if (first.type === "text") {
|
|
88
104
|
return {
|
|
89
105
|
...result,
|
|
90
|
-
content: [
|
|
91
|
-
{ ...first, text: `${prefix}\n\n${first.text}` },
|
|
92
|
-
...content.slice(1),
|
|
93
|
-
],
|
|
106
|
+
content: [{ ...first, text: `${prefix}\n\n${first.text}` }, ...content.slice(1)],
|
|
94
107
|
};
|
|
95
108
|
}
|
|
96
109
|
// For image or other content types, prepend a text block
|
|
97
110
|
return {
|
|
98
111
|
...result,
|
|
99
|
-
content: [
|
|
100
|
-
{ type: "text", text: prefix },
|
|
101
|
-
...content,
|
|
102
|
-
],
|
|
112
|
+
content: [{ type: "text", text: prefix }, ...content],
|
|
103
113
|
};
|
|
104
114
|
}
|
|
105
115
|
/**
|
|
@@ -206,9 +216,13 @@ export async function routeToolCall(toolName, args) {
|
|
|
206
216
|
if (tokenInfoResult.status === "revoked") {
|
|
207
217
|
if (resolvedGraph.lastKnownTokenStatus !== "revoked") {
|
|
208
218
|
try {
|
|
209
|
-
await updateGraphTokenStatus(resolvedGraph.nickname, {
|
|
219
|
+
await updateGraphTokenStatus(resolvedGraph.nickname, {
|
|
220
|
+
lastKnownTokenStatus: "revoked",
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
// best-effort status update
|
|
210
225
|
}
|
|
211
|
-
catch { }
|
|
212
226
|
}
|
|
213
227
|
const baseResult = actionSettled.status === "fulfilled"
|
|
214
228
|
? actionSettled.value
|
|
@@ -239,7 +253,9 @@ export async function routeToolCall(toolName, args) {
|
|
|
239
253
|
lastKnownTokenStatus: "active",
|
|
240
254
|
});
|
|
241
255
|
}
|
|
242
|
-
catch {
|
|
256
|
+
catch {
|
|
257
|
+
// best-effort status update
|
|
258
|
+
}
|
|
243
259
|
}
|
|
244
260
|
if (!result.isError) {
|
|
245
261
|
const enriched = enrichResultWithTokenInfo(result, info);
|
|
@@ -252,7 +268,9 @@ export async function routeToolCall(toolName, args) {
|
|
|
252
268
|
try {
|
|
253
269
|
await updateGraphTokenStatus(resolvedGraph.nickname, { lastKnownTokenStatus: "active" });
|
|
254
270
|
}
|
|
255
|
-
catch {
|
|
271
|
+
catch {
|
|
272
|
+
// best-effort status update
|
|
273
|
+
}
|
|
256
274
|
}
|
|
257
275
|
if (!result.isError) {
|
|
258
276
|
return prependGraphInfo(result, resolvedGraph.nickname);
|
package/dist/types.d.ts
CHANGED
|
@@ -112,7 +112,7 @@ export declare class RoamError extends Error {
|
|
|
112
112
|
constructor(message: string, code?: ErrorCode | undefined, context?: Record<string, unknown> | undefined);
|
|
113
113
|
}
|
|
114
114
|
export declare const CONFIG_VERSION = 1;
|
|
115
|
-
export declare const EXPECTED_API_VERSION = "1.1.
|
|
115
|
+
export declare const EXPECTED_API_VERSION = "1.1.2";
|
|
116
116
|
export interface RoamApiError {
|
|
117
117
|
message: string;
|
|
118
118
|
code?: string;
|
|
@@ -188,14 +188,64 @@ export interface SearchResult {
|
|
|
188
188
|
type?: "page";
|
|
189
189
|
}
|
|
190
190
|
export interface SearchResponse {
|
|
191
|
+
queriedAt?: string;
|
|
191
192
|
total: number;
|
|
192
193
|
results: SearchResult[];
|
|
193
194
|
}
|
|
195
|
+
export interface RecentlyOpenedBlock {
|
|
196
|
+
uid: string;
|
|
197
|
+
string: string;
|
|
198
|
+
openedAt: string;
|
|
199
|
+
path?: string;
|
|
200
|
+
}
|
|
201
|
+
export interface RecentlyOpenedItem {
|
|
202
|
+
uid: string;
|
|
203
|
+
title: string;
|
|
204
|
+
type: "page";
|
|
205
|
+
openedAt: string;
|
|
206
|
+
visitCount: number;
|
|
207
|
+
totalDurationMs: number;
|
|
208
|
+
currentlyOpen?: boolean;
|
|
209
|
+
blocks?: RecentlyOpenedBlock[];
|
|
210
|
+
}
|
|
211
|
+
export interface DailyNotePagesViewItem {
|
|
212
|
+
type: "dailyNotePagesView";
|
|
213
|
+
totalDurationMs: number;
|
|
214
|
+
currentlyOpen: boolean;
|
|
215
|
+
}
|
|
216
|
+
export interface RecentlyEditedPage {
|
|
217
|
+
uid: string;
|
|
218
|
+
title: string;
|
|
219
|
+
editedBy: string;
|
|
220
|
+
editedAt: string;
|
|
221
|
+
}
|
|
222
|
+
export interface SearchSuggestionsResponse {
|
|
223
|
+
queriedAt?: string;
|
|
224
|
+
suggestions: {
|
|
225
|
+
recentlyOpenedByUser: (RecentlyOpenedItem | DailyNotePagesViewItem)[];
|
|
226
|
+
recentlyEditedPages: RecentlyEditedPage[];
|
|
227
|
+
};
|
|
228
|
+
}
|
|
194
229
|
export interface Template {
|
|
195
230
|
name: string;
|
|
196
231
|
uid: string;
|
|
197
232
|
content: string;
|
|
198
233
|
}
|
|
234
|
+
export interface SearchTemplatesResponse {
|
|
235
|
+
queriedAt?: string;
|
|
236
|
+
results: Template[];
|
|
237
|
+
}
|
|
238
|
+
export interface GetPageResponse {
|
|
239
|
+
uid: string;
|
|
240
|
+
markdown: string;
|
|
241
|
+
queriedAt: string;
|
|
242
|
+
}
|
|
243
|
+
export interface GetBlockResponse {
|
|
244
|
+
uid: string;
|
|
245
|
+
markdown: string;
|
|
246
|
+
path: string;
|
|
247
|
+
queriedAt: string;
|
|
248
|
+
}
|
|
199
249
|
export interface QueryResult {
|
|
200
250
|
uid: string;
|
|
201
251
|
markdown: string;
|
|
@@ -203,6 +253,7 @@ export interface QueryResult {
|
|
|
203
253
|
type?: "page";
|
|
204
254
|
}
|
|
205
255
|
export interface QueryResponse {
|
|
256
|
+
queriedAt?: string;
|
|
206
257
|
total: number;
|
|
207
258
|
results: QueryResult[];
|
|
208
259
|
}
|
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,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACpG,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,CAGzD;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,GAAG,WAAW,GAAG,aAAa,GAAG,MAAM,CAAC;AAM/D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACpG,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,CAGzD;AAGD,wBAAgB,WAAW,CAAC,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,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
package/dist/types.js
CHANGED
|
@@ -16,14 +16,24 @@ export function errorResult(message) {
|
|
|
16
16
|
// Graph names can only contain alphanumeric characters, hyphens, and underscores
|
|
17
17
|
const GRAPH_NAME_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
18
18
|
export const GraphConfigSchema = z.object({
|
|
19
|
-
name: z
|
|
19
|
+
name: z
|
|
20
|
+
.string()
|
|
21
|
+
.regex(GRAPH_NAME_PATTERN, "Graph name can only contain letters, numbers, hyphens, and underscores")
|
|
22
|
+
.describe("Actual graph name in Roam"),
|
|
20
23
|
type: z.enum(["hosted", "offline"]).default("hosted").describe("Graph type"),
|
|
21
24
|
token: z.string().startsWith("roam-graph-local-token-").describe("Local API token"),
|
|
22
|
-
nickname: z
|
|
25
|
+
nickname: z
|
|
26
|
+
.string()
|
|
23
27
|
.regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, "Nickname must be lowercase letters, numbers, and hyphens")
|
|
24
28
|
.describe("Short identifier for the graph (lowercase, hyphens, no spaces)"),
|
|
25
|
-
accessLevel: z
|
|
26
|
-
|
|
29
|
+
accessLevel: z
|
|
30
|
+
.enum(["read-only", "read-append", "full"])
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("Token access level"),
|
|
33
|
+
lastKnownTokenStatus: z
|
|
34
|
+
.enum(["active", "revoked"])
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Token validity status from last sync with Roam"),
|
|
27
37
|
});
|
|
28
38
|
export const RoamMcpConfigSchema = z.object({
|
|
29
39
|
version: z.number().int().positive().optional(),
|
|
@@ -81,8 +91,17 @@ export class RoamError extends Error {
|
|
|
81
91
|
// so a newer version may write a config that an older version can't parse.
|
|
82
92
|
// Bump this when the config schema changes in a breaking way.
|
|
83
93
|
export const CONFIG_VERSION = 1;
|
|
84
|
-
// API version this client expects
|
|
85
|
-
|
|
94
|
+
// API version this client expects. Sent as `expectedApiVersion` in every request.
|
|
95
|
+
// Roam's compatibility check compares major.minor ONLY — patch is ignored.
|
|
96
|
+
// So 1.1.0, 1.1.1, 1.1.2 are all compatible; 1.1.x and 1.2.x are NOT.
|
|
97
|
+
//
|
|
98
|
+
// When to bump:
|
|
99
|
+
// - Patch bump on Roam side (e.g. 1.1.1 → 1.1.2): no change needed here, but
|
|
100
|
+
// you can bump for cosmetic alignment.
|
|
101
|
+
// - Minor bump on Roam side (e.g. 1.1.x → 1.2.0): MUST bump here too, or all
|
|
102
|
+
// requests will fail with VERSION_MISMATCH.
|
|
103
|
+
// - This is independent of the npm package version (0.x.y in package.json).
|
|
104
|
+
export const EXPECTED_API_VERSION = "1.1.2";
|
|
86
105
|
// Helper to extract error message from RoamResponse
|
|
87
106
|
export function getErrorMessage(error) {
|
|
88
107
|
if (!error)
|