@powerhousedao/reactor-mcp 6.2.3-dev.71 → 6.2.3-dev.73

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/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as logger, t as createServer$1 } from "./server-CT8k24iS.mjs";
1
+ import { n as logger, t as createServer$1 } from "./server-DF99fpy8.mjs";
2
2
  import { childLogger, documentModelDocumentModelModule } from "document-model";
3
3
  import { ReactorBuilder, ReactorClientBuilder } from "@powerhousedao/reactor";
4
4
  import { driveDocumentModelModule } from "@powerhousedao/shared/document-drive";
@@ -53,9 +53,10 @@ declare const createDocumentTool: {
53
53
  };
54
54
  declare const getDocumentTool: {
55
55
  readonly name: "getDocument";
56
- readonly description: "Retrieve a document by its ID";
56
+ readonly description: "Retrieve a document by its ID, passed as `id` (or `documentId`, as the other document tools name it)";
57
57
  readonly inputSchema: {
58
- readonly id: z.ZodString;
58
+ readonly id: z.ZodOptional<z.ZodString>;
59
+ readonly documentId: z.ZodOptional<z.ZodString>;
59
60
  };
60
61
  readonly outputSchema: {
61
62
  readonly document: z.ZodUnknown;
@@ -83,7 +84,7 @@ declare const deleteDocumentTool: {
83
84
  };
84
85
  declare const addActionsTool: {
85
86
  readonly name: "addActions";
86
- readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.";
87
+ readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps. Besides the document model's operations, accepts the base actions SET_NAME (scope global, input: the name), SET_PREFERRED_EDITOR (scope header, input: { preferredEditor }), UNDO and REDO (input: { count }) and NOOP.";
87
88
  readonly inputSchema: {
88
89
  readonly documentId: z.ZodString;
89
90
  readonly actions: z.ZodArray<z.ZodObject<{
@@ -200,9 +201,10 @@ type ToolRecord<T extends readonly ToolSchema[]> = { [K in T[number]["name"]]: T
200
201
  }>>; };
201
202
  declare const _allTools: readonly [{
202
203
  readonly name: "getDocument";
203
- readonly description: "Retrieve a document by its ID";
204
+ readonly description: "Retrieve a document by its ID, passed as `id` (or `documentId`, as the other document tools name it)";
204
205
  readonly inputSchema: {
205
- readonly id: z.ZodString;
206
+ readonly id: z.ZodOptional<z.ZodString>;
207
+ readonly documentId: z.ZodOptional<z.ZodString>;
206
208
  };
207
209
  readonly outputSchema: {
208
210
  readonly document: z.ZodUnknown;
@@ -241,7 +243,7 @@ declare const _allTools: readonly [{
241
243
  };
242
244
  }, {
243
245
  readonly name: "addActions";
244
- readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.";
246
+ readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps. Besides the document model's operations, accepts the base actions SET_NAME (scope global, input: the name), SET_PREFERRED_EDITOR (scope header, input: { preferredEditor }), UNDO and REDO (input: { count }) and NOOP.";
245
247
  readonly inputSchema: {
246
248
  readonly documentId: z.ZodString;
247
249
  readonly actions: z.ZodArray<z.ZodObject<{
@@ -351,16 +353,18 @@ declare function createReactorMcpProvider(options: ReactorMcpProviderOptions): P
351
353
  readonly tools: {
352
354
  readonly getDocument: {
353
355
  readonly name: "getDocument";
354
- readonly description: "Retrieve a document by its ID";
356
+ readonly description: "Retrieve a document by its ID, passed as `id` (or `documentId`, as the other document tools name it)";
355
357
  readonly inputSchema: {
356
- readonly id: z.ZodString;
358
+ readonly id: z.ZodOptional<z.ZodString>;
359
+ readonly documentId: z.ZodOptional<z.ZodString>;
357
360
  };
358
361
  readonly outputSchema: {
359
362
  readonly document: z.ZodUnknown;
360
363
  };
361
364
  } & {
362
365
  callback: (args: {
363
- id: string;
366
+ id?: string | undefined;
367
+ documentId?: string | undefined;
364
368
  }) => Promise<import("@modelcontextprotocol/sdk/types").CallToolResult>;
365
369
  };
366
370
  readonly createDocument: {
@@ -415,7 +419,7 @@ declare function createReactorMcpProvider(options: ReactorMcpProviderOptions): P
415
419
  };
416
420
  readonly addActions: {
417
421
  readonly name: "addActions";
418
- readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.";
422
+ readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps. Besides the document model's operations, accepts the base actions SET_NAME (scope global, input: the name), SET_PREFERRED_EDITOR (scope header, input: { preferredEditor }), UNDO and REDO (input: { count }) and NOOP.";
419
423
  readonly inputSchema: {
420
424
  readonly documentId: z.ZodString;
421
425
  readonly actions: z.ZodArray<z.ZodObject<{
@@ -610,7 +614,15 @@ declare function validateDocumentModelAction(documentModelModule: DocumentModelM
610
614
  isValid: boolean;
611
615
  errors: string[];
612
616
  };
617
+ /**
618
+ * Builds a document-model base action (SET_NAME, SET_PREFERRED_EDITOR, UNDO,
619
+ * REDO, NOOP) with its action creator. Returns `null` for any other type.
620
+ */
621
+ declare function createBaseAction(type: string, input: unknown, scope: string): {
622
+ action: Action | null;
623
+ errors: string[];
624
+ } | null;
613
625
  //#endregion
614
- export { ToolWithCallback as C, ToolSchema as S, getDriveTool as _, ReactorMcpTools as a, IMcpProvider as b, addRemoteDriveTool as c, deleteDocumentTool as d, deleteDriveTool as f, getDocumentsTool as g, getDocumentTool as h, ReactorMcpProviderOptions as i, createDocumentTool as l, getDocumentModelsTool as m, toolWithCallback as n, addActionsTool as o, getDocumentModelSchemaTool as p, validateDocumentModelAction as r, addDriveTool as s, InvalidToolOutputError as t, createReactorMcpProvider as u, getDrivesTool as v, ResolveZodSchema as x, ExtractCallbackFromTool as y };
626
+ export { ToolSchema as C, ResolveZodSchema as S, getDocumentsTool as _, ReactorMcpProviderOptions as a, ExtractCallbackFromTool as b, addDriveTool as c, createReactorMcpProvider as d, deleteDocumentTool as f, getDocumentTool as g, getDocumentModelsTool as h, validateDocumentModelAction as i, addRemoteDriveTool as l, getDocumentModelSchemaTool as m, createBaseAction as n, ReactorMcpTools as o, deleteDriveTool as p, toolWithCallback as r, addActionsTool as s, InvalidToolOutputError as t, createDocumentTool as u, getDriveTool as v, ToolWithCallback as w, IMcpProvider as x, getDrivesTool as y };
615
627
  export {};
616
- //# sourceMappingURL=index-CWO1xShX.d.mts.map
628
+ //# sourceMappingURL=index-BX9XmJWL.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BX9XmJWL.d.mts","names":[],"sources":["../src/tools/types.ts","../src/tools/reactor.ts","../src/tools/utils.ts"],"mappings":";;;;;;KAQY,wBAAwB,UAAU,cAAc;EAC1D,mBAAmB;IAEjB,aAAa,UAAU,cAAc,iBACrC;KAEQ,iBAAiB,UAAU,aAAa,cAAc;EAChE,UAAU,wBAAwB;;KAGxB,WACV,kBAAkB,cAAc,aAChC,mBAAmB,cAAc;EAEjC;EACA;EACA;EACA,cAAc;EACd,eAAe;EACf,cAAc;;KAGJ,iBAAiB,KAAK,UAAU,EAAE,cAC1C,EAAE,MAAM,EAAE,UAAU,MACpB;UAEa,aACf,UAAU,mBAAmB,kBAC7B,UAAU,WAAW,UACrB,UAAU,SAAS;EAEnB,OAAO,OAAO,WAAW,iBAAiB;EAC1C,WAAW,OAAO,WAAW;EAC7B,SAAS,OAAO,WAAW;;;;KCZjB;EACV,QAAQ;EACR,cAAc;;;;;;EAMd,UAAU;;cAGC;WACL;WACO;;;;aAIX,cAAY,EAAA;aACZ,MAAI,EAAA,YAAA,EAAA;aAMJ,SAAO,EAAA,YAAA,EAAA;aAMP,cAAY,EAAA,YAAA,EAAA;;;aAQZ,YAAU,EAAA;;;cAID;WACL;WAEJ;;aAEA,IAAE,EAAA,YAAA,EAAA;aACF,YAAU,EAAA,YAAA,EAAA;;;aAGV,UAAQ,EAAA;;;cAIC;WACL;WACO;;aAEX,UAAQ,EAAA;;;aAGR,aAAW,EAAA,SAAA,EAAA;;;cAIF;WACL;WACO;;aAEX,YAAU,EAAA;;;aAGV,SAAO,EAAA;;;cAIE;WACL;WAEJ;;aAEA,YAAU,EAAA;aACV,SAAO,EAAA,SAAA,EAAA;;;;;;;;aAiBP,SAAO,EAAA;;;cAoDE;WACL;WACO;;;aAGX,UAAQ,EAAA,SAAA,EAAA;;;cAIC;WACL;WACO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,MAAI,EAAA;;;iBAGJ,QAAM,EAAA;;;;;;;;;;;;;cCvTG,+BAA+B;EAC1C,YAAY,UAAU,EAAE;;;;;;;;;;iBAeV,iBAAiB,UAAU,YACzC,MAAM,GACN,eACE,MAAM,iBAAiB,sBAErB,iBAAiB,qBACjB,QAAQ,iBAAiB,sBAAmB;EAGxC,WAAA,MAAA,iBAAiB,sBACtB,QAAQ;;iBAgCG,4BACd,qBAAqB,qBACrB,QAAQ;EACL;EAAkB;;;;;;iBAkGP,iBACd,cACA,gBACA;EACG,QAAQ;EAAe"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ToolWithCallback, S as ToolSchema, _ as getDriveTool, a as ReactorMcpTools, b as IMcpProvider, c as addRemoteDriveTool, d as deleteDocumentTool, f as deleteDriveTool, g as getDocumentsTool, h as getDocumentTool, i as ReactorMcpProviderOptions, l as createDocumentTool, m as getDocumentModelsTool, n as toolWithCallback, o as addActionsTool, p as getDocumentModelSchemaTool, r as validateDocumentModelAction, s as addDriveTool, t as InvalidToolOutputError, u as createReactorMcpProvider, v as getDrivesTool, x as ResolveZodSchema, y as ExtractCallbackFromTool } from "./index-CWO1xShX.mjs";
1
+ import { C as ToolSchema, S as ResolveZodSchema, _ as getDocumentsTool, a as ReactorMcpProviderOptions, b as ExtractCallbackFromTool, c as addDriveTool, d as createReactorMcpProvider, f as deleteDocumentTool, g as getDocumentTool, h as getDocumentModelsTool, i as validateDocumentModelAction, l as addRemoteDriveTool, m as getDocumentModelSchemaTool, n as createBaseAction, o as ReactorMcpTools, p as deleteDriveTool, r as toolWithCallback, s as addActionsTool, t as InvalidToolOutputError, u as createDocumentTool, v as getDriveTool, w as ToolWithCallback, x as IMcpProvider, y as getDrivesTool } from "./index-BX9XmJWL.mjs";
2
2
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
3
3
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
  import { IReactorClient, ISyncManager } from "@powerhousedao/reactor";
@@ -47,6 +47,6 @@ interface CreateServerOptions {
47
47
  }
48
48
  export declare function createServer(options: CreateServerOptions): Promise<McpServer>;
49
49
  //#endregion
50
- export { type CreateServerOptions, ExtractCallbackFromTool, IMcpProvider, InvalidToolOutputError, type McpAuthorizationResult, type McpRequestAuthorizer, ReactorMcpProviderOptions, ReactorMcpTools, ResolveZodSchema, type SetupMcpServerOptions, ToolSchema, ToolWithCallback, addActionsTool, addDriveTool, addRemoteDriveTool, createDocumentTool, createReactorMcpProvider, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, toolWithCallback, validateDocumentModelAction };
50
+ export { type CreateServerOptions, ExtractCallbackFromTool, IMcpProvider, InvalidToolOutputError, type McpAuthorizationResult, type McpRequestAuthorizer, ReactorMcpProviderOptions, ReactorMcpTools, ResolveZodSchema, type SetupMcpServerOptions, ToolSchema, ToolWithCallback, addActionsTool, addDriveTool, addRemoteDriveTool, createBaseAction, createDocumentTool, createReactorMcpProvider, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, toolWithCallback, validateDocumentModelAction };
51
51
  export {};
52
52
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { n as logger, t as createServer } from "./server-CT8k24iS.mjs";
2
- import { a as createReactorMcpProvider, c as getDocumentModelSchemaTool, d as getDocumentsTool, f as getDriveTool, g as validateDocumentModelAction, h as toolWithCallback, i as createDocumentTool, l as getDocumentModelsTool, m as InvalidToolOutputError, n as addDriveTool, o as deleteDocumentTool, p as getDrivesTool, r as addRemoteDriveTool, s as deleteDriveTool, t as addActionsTool, u as getDocumentTool } from "./reactor-CYKTrGtF.mjs";
1
+ import { n as logger, t as createServer } from "./server-DF99fpy8.mjs";
2
+ import { _ as validateDocumentModelAction, a as createReactorMcpProvider, c as getDocumentModelSchemaTool, d as getDocumentsTool, f as getDriveTool, g as toolWithCallback, h as createBaseAction, i as createDocumentTool, l as getDocumentModelsTool, m as InvalidToolOutputError, n as addDriveTool, o as deleteDocumentTool, p as getDrivesTool, r as addRemoteDriveTool, s as deleteDriveTool, t as addActionsTool, u as getDocumentTool } from "./reactor-BqyjCnB2.mjs";
3
3
  import "./tools/index.mjs";
4
4
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
5
5
  //#region src/mcp-routes.ts
@@ -67,6 +67,6 @@ function setupMcpServer(options, httpAdapter, createTransport = (opts) => new St
67
67
  return Promise.resolve();
68
68
  }
69
69
  //#endregion
70
- export { InvalidToolOutputError, addActionsTool, addDriveTool, addRemoteDriveTool, createDocumentTool, createReactorMcpProvider, createServer, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, setupMcpServer, toolWithCallback, validateDocumentModelAction };
70
+ export { InvalidToolOutputError, addActionsTool, addDriveTool, addRemoteDriveTool, createBaseAction, createDocumentTool, createReactorMcpProvider, createServer, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, setupMcpServer, toolWithCallback, validateDocumentModelAction };
71
71
 
72
72
  //# sourceMappingURL=index.mjs.map
@@ -1,6 +1,6 @@
1
1
  import { DriveCollectionId } from "@powerhousedao/reactor";
2
- import { setAvailableOffline, setDriveIcon, setSharingType } from "@powerhousedao/shared/document-drive";
3
- import { createAction, withSignaturePolicy } from "@powerhousedao/shared/document-model";
2
+ import { setAvailableOffline, setDriveIcon, setDriveName, setSharingType } from "@powerhousedao/shared/document-drive";
3
+ import { baseActions, createAction, withSignaturePolicy } from "@powerhousedao/shared/document-model";
4
4
  import { z } from "zod";
5
5
  import { camelCase } from "change-case";
6
6
  //#region src/tools/utils.ts
@@ -93,6 +93,59 @@ function validateDocumentModelAction(documentModelModule, action) {
93
93
  errors
94
94
  };
95
95
  }
96
+ /** The scope each base action must carry; `null` means any scope of the document. */
97
+ const BASE_ACTION_SCOPES = {
98
+ SET_NAME: "global",
99
+ SET_PREFERRED_EDITOR: "header",
100
+ UNDO: null,
101
+ REDO: null,
102
+ NOOP: null
103
+ };
104
+ function countInput(input) {
105
+ if (typeof input === "number") return input;
106
+ if (typeof input === "object" && input !== null && "count" in input && typeof input.count === "number") return input.count;
107
+ }
108
+ /**
109
+ * Builds a document-model base action (SET_NAME, SET_PREFERRED_EDITOR, UNDO,
110
+ * REDO, NOOP) with its action creator. Returns `null` for any other type.
111
+ */
112
+ function createBaseAction(type, input, scope) {
113
+ if (!Object.hasOwn(BASE_ACTION_SCOPES, type)) return null;
114
+ const expectedScope = BASE_ACTION_SCOPES[type];
115
+ if (expectedScope !== null && scope !== expectedScope) return {
116
+ action: null,
117
+ errors: [`Action scope "${scope}" does not match operation scope "${expectedScope}"`]
118
+ };
119
+ try {
120
+ switch (type) {
121
+ case "SET_NAME": return {
122
+ action: baseActions.setName(input),
123
+ errors: []
124
+ };
125
+ case "SET_PREFERRED_EDITOR": return {
126
+ action: baseActions.setPreferredEditor(input),
127
+ errors: []
128
+ };
129
+ case "UNDO": return {
130
+ action: baseActions.undo(countInput(input), scope),
131
+ errors: []
132
+ };
133
+ case "REDO": return {
134
+ action: baseActions.redo(countInput(input), scope),
135
+ errors: []
136
+ };
137
+ default: return {
138
+ action: baseActions.noop(scope),
139
+ errors: []
140
+ };
141
+ }
142
+ } catch (e) {
143
+ return {
144
+ action: null,
145
+ errors: [`Input validation error: ${e instanceof Error ? e.message : JSON.stringify(e)}`]
146
+ };
147
+ }
148
+ }
96
149
  //#endregion
97
150
  //#region src/tools/reactor.ts
98
151
  const DRIVE_DOCUMENT_TYPE = "powerhouse/document-drive";
@@ -111,8 +164,11 @@ const createDocumentTool = {
111
164
  };
112
165
  const getDocumentTool = {
113
166
  name: "getDocument",
114
- description: "Retrieve a document by its ID",
115
- inputSchema: { id: z.string().describe("ID of the document to retrieve") },
167
+ description: "Retrieve a document by its ID, passed as `id` (or `documentId`, as the other document tools name it)",
168
+ inputSchema: {
169
+ id: z.string().optional().describe("ID of the document to retrieve"),
170
+ documentId: z.string().optional().describe("Alias of `id`")
171
+ },
116
172
  outputSchema: { document: z.unknown().describe("The retrieved Document") }
117
173
  };
118
174
  const getDocumentsTool = {
@@ -129,7 +185,7 @@ const deleteDocumentTool = {
129
185
  };
130
186
  const addActionsTool = {
131
187
  name: "addActions",
132
- description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.",
188
+ description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps. Besides the document model's operations, accepts the base actions SET_NAME (scope global, input: the name), SET_PREFERRED_EDITOR (scope header, input: { preferredEditor }), UNDO and REDO (input: { count }) and NOOP.",
133
189
  inputSchema: {
134
190
  documentId: z.string().describe("ID of the document"),
135
191
  actions: z.array(z.object({
@@ -227,7 +283,9 @@ function createReactorMcpProvider(options) {
227
283
  }
228
284
  const tools = {
229
285
  getDocument: toolWithCallback(getDocumentTool, async (params) => {
230
- const document = await client.get(params.id, view);
286
+ const id = params.id ?? params.documentId;
287
+ if (!id) throw new Error("getDocument needs the document's ID in `id` (or `documentId`)");
288
+ const document = await client.get(id, view);
231
289
  return { document: {
232
290
  header: document.header,
233
291
  state: document.state
@@ -261,6 +319,11 @@ function createReactorMcpProvider(options) {
261
319
  const documentModel = await getDocumentModelModule(document.header.documentType);
262
320
  if (!documentModel) throw new Error(`Document model for document type '${document.header.documentType}' not found`);
263
321
  const actions = params.actions.map((paramAction) => {
322
+ const baseAction = createBaseAction(paramAction.type, paramAction.input, paramAction.scope);
323
+ if (baseAction) {
324
+ if (!baseAction.action) throw new Error(`Invalid action ${JSON.stringify(paramAction)}: ${baseAction.errors.join(", ")}`);
325
+ return baseAction.action;
326
+ }
264
327
  const action = createAction(paramAction.type, paramAction.input ?? {}, void 0, void 0, paramAction.scope);
265
328
  const actionValidation = validateDocumentModelAction(documentModel, action);
266
329
  if (!actionValidation.isValid) throw new Error(`Invalid action ${JSON.stringify(action)}: ${actionValidation.errors.join(", ")}`);
@@ -275,9 +338,10 @@ function createReactorMcpProvider(options) {
275
338
  addDrive: toolWithCallback(addDriveTool, async (params) => {
276
339
  const { driveInput } = params;
277
340
  const driveId = (await client.createEmpty(DRIVE_DOCUMENT_TYPE, {})).header.id;
278
- if (driveInput.global.name) await client.rename(driveId, driveInput.global.name);
279
341
  if (driveInput.preferredEditor) await client.setPreferredEditor(driveId, driveInput.preferredEditor);
342
+ if (driveInput.global.name) await client.rename(driveId, driveInput.global.name);
280
343
  const actions = [];
344
+ if (driveInput.global.name) actions.push(setDriveName({ name: driveInput.global.name }));
281
345
  if (driveInput.global.icon) actions.push(setDriveIcon({ icon: driveInput.global.icon }));
282
346
  if (driveInput.local?.sharingType) actions.push(setSharingType({ type: driveInput.local.sharingType }));
283
347
  if (driveInput.local?.availableOffline !== void 0) actions.push(setAvailableOffline({ availableOffline: driveInput.local.availableOffline }));
@@ -340,6 +404,6 @@ function createReactorMcpProvider(options) {
340
404
  });
341
405
  }
342
406
  //#endregion
343
- export { createReactorMcpProvider as a, getDocumentModelSchemaTool as c, getDocumentsTool as d, getDriveTool as f, validateDocumentModelAction as g, toolWithCallback as h, createDocumentTool as i, getDocumentModelsTool as l, InvalidToolOutputError as m, addDriveTool as n, deleteDocumentTool as o, getDrivesTool as p, addRemoteDriveTool as r, deleteDriveTool as s, addActionsTool as t, getDocumentTool as u };
407
+ export { validateDocumentModelAction as _, createReactorMcpProvider as a, getDocumentModelSchemaTool as c, getDocumentsTool as d, getDriveTool as f, toolWithCallback as g, createBaseAction as h, createDocumentTool as i, getDocumentModelsTool as l, InvalidToolOutputError as m, addDriveTool as n, deleteDocumentTool as o, getDrivesTool as p, addRemoteDriveTool as r, deleteDriveTool as s, addActionsTool as t, getDocumentTool as u };
344
408
 
345
- //# sourceMappingURL=reactor-CYKTrGtF.mjs.map
409
+ //# sourceMappingURL=reactor-BqyjCnB2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactor-BqyjCnB2.mjs","names":[],"sources":["../src/tools/utils.ts","../src/tools/reactor.ts"],"sourcesContent":["import type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { camelCase } from \"change-case\";\nimport type {\n Action,\n DocumentModelModule,\n Operation,\n} from \"@powerhousedao/shared/document-model\";\nimport { baseActions } from \"@powerhousedao/shared/document-model\";\nimport type { z } from \"zod\";\nimport type { ResolveZodSchema, ToolSchema } from \"./types.js\";\n\nexport class InvalidToolOutputError extends Error {\n constructor(zodError: z.ZodError) {\n super(\"Invalid tool output\\n\" + zodError.message);\n this.name = \"InvalidToolOutputError\";\n this.cause = zodError;\n }\n}\n\n/**\n * Creates a tool with a callback function that handles the tool execution,\n * ensuring the output is valid and errors are handled and returned correctly.\n * @param tool The tool schema to wrap.\n * @param toolCallback The callback function to execute when the tool is called.\n * @returns A CallToolResult with structuredContent if OutputSchema is defined or content if undefined. If the\n * callback throws an error, the result will have isError set to true and the error message in the content.\n */\nexport function toolWithCallback<T extends ToolSchema>(\n tool: T,\n toolCallback: (\n args: ResolveZodSchema<T[\"inputSchema\"]>,\n ) =>\n | ResolveZodSchema<T[\"outputSchema\"]>\n | Promise<ResolveZodSchema<T[\"outputSchema\"]>>,\n) {\n const wrappedCallback = async (\n args: ResolveZodSchema<T[\"inputSchema\"]>,\n ): Promise<CallToolResult> => {\n try {\n const result = await toolCallback(args);\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(result),\n },\n ],\n structuredContent: result,\n } as const satisfies CallToolResult;\n } catch (error) {\n const errorString =\n error instanceof Error ? error.message : String(error);\n return {\n isError: true,\n content: [\n {\n type: \"text\",\n text: `Error: ${errorString}`,\n },\n ],\n } as const satisfies CallToolResult;\n }\n };\n return {\n ...tool,\n callback: wrappedCallback,\n };\n}\n\nexport function validateDocumentModelAction(\n documentModelModule: DocumentModelModule,\n action: Action,\n): { isValid: boolean; errors: string[] } {\n const errors: string[] = [];\n\n const globalState = documentModelModule.documentModel.global;\n\n // Get the latest specification\n if (!globalState.specifications || globalState.specifications.length === 0) {\n errors.push(\"Document model has no specifications\");\n return { isValid: false, errors };\n }\n\n const latestSpec =\n globalState.specifications[globalState.specifications.length - 1];\n\n // Search through modules to find the operation that matches the action type (in SCREAMING_SNAKE_CASE)\n let operation: (Operation & { scope: string }) | null = null;\n\n for (const module of latestSpec.modules) {\n const unsafeOperationOrActionOrSomething = module.operations.find(\n (op) => op.name === action.type,\n ) as unknown as Operation & { scope: string };\n if (unsafeOperationOrActionOrSomething) {\n operation = unsafeOperationOrActionOrSomething;\n break;\n }\n }\n\n if (!operation) {\n errors.push(\n `Operation \"${action.type}\" is not defined in any module of the document model`,\n );\n return { isValid: false, errors };\n }\n\n // Convert action type from SCREAMING_SNAKE_CASE to camelCase to match action creators\n const camelCaseActionType = camelCase(action.type);\n\n // Check if action creator exists in documentModelModule.actions\n const actionCreator = documentModelModule.actions[camelCaseActionType];\n\n if (!actionCreator) {\n errors.push(\n `Action creator \"${camelCaseActionType}\" for action type \"${action.type}\" is not defined in documentModelDocumentModelModule.actions`,\n );\n return { isValid: false, errors };\n }\n\n // Validate the operation using the action creator. TODO: Use document model exported validators directly\n let inputError: Error | null = null;\n try {\n actionCreator(action.input);\n } catch (e) {\n inputError = e instanceof Error ? e : new Error(JSON.stringify(e));\n }\n\n if (inputError) {\n errors.push(`Input validation error: ${inputError.message}`);\n }\n\n // Validate scope if operation defines one\n if (operation.scope && action.scope !== operation.scope) {\n errors.push(\n `Action scope \"${action.scope}\" does not match operation scope \"${operation.scope}\"`,\n );\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n };\n}\n\n/** The scope each base action must carry; `null` means any scope of the document. */\nconst BASE_ACTION_SCOPES: Record<string, string | null> = {\n SET_NAME: \"global\",\n SET_PREFERRED_EDITOR: \"header\",\n UNDO: null,\n REDO: null,\n NOOP: null,\n};\n\nfunction countInput(input: unknown): number | undefined {\n if (typeof input === \"number\") return input;\n if (\n typeof input === \"object\" &&\n input !== null &&\n \"count\" in input &&\n typeof input.count === \"number\"\n ) {\n return input.count;\n }\n return undefined;\n}\n\n/**\n * Builds a document-model base action (SET_NAME, SET_PREFERRED_EDITOR, UNDO,\n * REDO, NOOP) with its action creator. Returns `null` for any other type.\n */\nexport function createBaseAction(\n type: string,\n input: unknown,\n scope: string,\n): { action: Action | null; errors: string[] } | null {\n if (!Object.hasOwn(BASE_ACTION_SCOPES, type)) return null;\n\n const expectedScope = BASE_ACTION_SCOPES[type];\n if (expectedScope !== null && scope !== expectedScope) {\n return {\n action: null,\n errors: [\n `Action scope \"${scope}\" does not match operation scope \"${expectedScope}\"`,\n ],\n };\n }\n\n try {\n switch (type) {\n case \"SET_NAME\":\n return {\n action: baseActions.setName(input as string | { name: string }),\n errors: [],\n };\n case \"SET_PREFERRED_EDITOR\":\n return {\n action: baseActions.setPreferredEditor(\n input as string | null | { preferredEditor: string | null },\n ),\n errors: [],\n };\n case \"UNDO\":\n return {\n action: baseActions.undo(countInput(input), scope),\n errors: [],\n };\n case \"REDO\":\n return {\n action: baseActions.redo(countInput(input), scope),\n errors: [],\n };\n default:\n return { action: baseActions.noop(scope), errors: [] };\n }\n } catch (e) {\n const message = e instanceof Error ? e.message : JSON.stringify(e);\n return { action: null, errors: [`Input validation error: ${message}`] };\n }\n}\n","import type { IReactorClient, ISyncManager } from \"@powerhousedao/reactor\";\nimport { DriveCollectionId } from \"@powerhousedao/reactor\";\nimport type { DocumentDriveDocument } from \"@powerhousedao/shared/document-drive\";\nimport {\n setAvailableOffline,\n setDriveIcon,\n setDriveName,\n setSharingType,\n} from \"@powerhousedao/shared/document-drive\";\nimport type {\n Action,\n AuthSubject,\n DocumentModelModule,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport {\n createAction,\n withSignaturePolicy,\n} from \"@powerhousedao/shared/document-model\";\nimport { z } from \"zod\";\nimport type { ToolSchema, ToolWithCallback } from \"./types.js\";\nimport {\n createBaseAction,\n toolWithCallback,\n validateDocumentModelAction,\n} from \"./utils.js\";\n\nconst DRIVE_DOCUMENT_TYPE = \"powerhouse/document-drive\";\n\nexport type ReactorMcpProviderOptions = {\n client: IReactorClient;\n syncManager?: ISyncManager;\n /**\n * Who the tools read as. A server shared by many callers must set it, an\n * anonymous one to an empty subject. Omitted, reads fall back to the\n * client's signer, which only a single-user local reactor should rely on.\n */\n subject?: AuthSubject;\n};\n\nexport const createDocumentTool = {\n name: \"createDocument\",\n description: `Create a new document.\n Unless the user specifies otherwise, and a drive named \"vetra\" is available, add the document to that drive by providing the drive's ID in the \"driveId\" parameter.\n When \"driveId\" is provided, the document is created and added to the drive atomically — no separate \"addActions\" call with \"ADD_FILE\" is needed.`,\n inputSchema: {\n documentType: z.string().describe(\"Type of the document to create\"),\n name: z\n .string()\n .optional()\n .describe(\n \"Optional name for the document. Used as both the document name and the drive node name when driveId is provided.\",\n ),\n driveId: z\n .string()\n .optional()\n .describe(\n \"Optional drive ID or slug. When provided, the document is created and added to the drive atomically.\",\n ),\n parentFolder: z\n .string()\n .optional()\n .describe(\n \"Optional folder ID within the drive to place the document in. Only used when driveId is provided.\",\n ),\n },\n outputSchema: {\n documentId: z.string().describe(\"ID of the created document\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentTool = {\n name: \"getDocument\",\n description:\n \"Retrieve a document by its ID, passed as `id` (or `documentId`, as the other document tools name it)\",\n inputSchema: {\n id: z.string().optional().describe(\"ID of the document to retrieve\"),\n documentId: z.string().optional().describe(\"Alias of `id`\"),\n },\n outputSchema: {\n document: z.unknown().describe(\"The retrieved Document\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentsTool = {\n name: \"getDocuments\",\n description: \"List documents in a drive\",\n inputSchema: {\n parentId: z.string().describe(\"ID of the drive\"),\n },\n outputSchema: {\n documentIds: z.array(z.string()).describe(\"Array of document IDs\"),\n },\n} as const satisfies ToolSchema;\n\nexport const deleteDocumentTool = {\n name: \"deleteDocument\",\n description: \"Delete a document\",\n inputSchema: {\n documentId: z.string().describe(\"ID of the document to delete\"),\n },\n outputSchema: {\n success: z.boolean().describe(\"Whether the deletion was successful\"),\n },\n} as const satisfies ToolSchema;\n\nexport const addActionsTool = {\n name: \"addActions\",\n description:\n \"Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps. Besides the document model's operations, accepts the base actions SET_NAME (scope global, input: the name), SET_PREFERRED_EDITOR (scope header, input: { preferredEditor }), UNDO and REDO (input: { count }) and NOOP.\",\n inputSchema: {\n documentId: z.string().describe(\"ID of the document\"),\n actions: z\n .array(\n z\n .object({\n type: z.string().describe(\"The name of the action\"),\n input: z.unknown().describe(\"The payload of the action\"),\n scope: z.string().describe(\"The scope of the action\"),\n context: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\"Optional action context\"), // TODO: Define context schema\n })\n .strict(),\n )\n .describe(\"Action to add to the document\"),\n },\n outputSchema: {\n success: z.boolean().describe(\"Whether the actions were added\"),\n },\n} as const satisfies ToolSchema;\n\n// export const addOperationTool = {\n// name: \"addOperation\",\n// description: \"Add an operation to a document\",\n// inputSchema: {\n// documentId: z.string().describe(\"ID of the document\"),\n// operation: z\n// .object({\n// type: z.string().describe(\"The name of the action\"),\n// input: z.unknown().describe(\"The payload of the action\"),\n// scope: z.string().describe(\"The scope of the action\"),\n// index: z.number().describe(\"Position of the operation in the history\"),\n// timestampUtcMs: z\n// .string()\n// .describe(\"Timestamp of when the operation was added\"),\n// hash: z.string().describe(\"Hash of the resulting document data\"),\n// skip: z.number().describe(\"The number of operations skipped\"),\n// error: z\n// .string()\n// .optional()\n// .describe(\"Error message for a failed action\"),\n// id: z.string().optional().describe(\"Unique operation id\"),\n// context: z.object({}).optional().describe(\"Optional action context\"), // TODO: Define context schema\n// })\n// .strict()\n// .describe(\"Operation to add to the document\"),\n// },\n// outputSchema: {\n// result: z\n// .object({\n// status: z\n// .enum([\"SUCCESS\", \"CONFLICT\", \"MISSING\", \"ERROR\"])\n// .describe(\"Operation status\"),\n// error: z\n// .string()\n// .optional()\n// .describe(\"Error details if operation failed\"), // TODO: Define error schema\n// operations: z\n// .array(z.object({}))\n// .describe(\"Array of operations created\"), // TODO: Define operation schema\n// document: z.object({}).optional().describe(\"Updated document\"), // TODO: Define document schema\n// signals: z.array(z.object({})).describe(\"Array of signals generated\"), // TODO: Define signal schema\n// })\n// .describe(\"Operation result\"),\n// },\n// } as const satisfies ToolSchema;\n\n// Drive Operation Tools\n\nexport const getDrivesTool = {\n name: \"getDrives\",\n description: \"List all drives\",\n inputSchema: {},\n outputSchema: {\n driveIds: z.array(z.string()).describe(\"Array of drive IDs\"),\n },\n} as const satisfies ToolSchema;\n\nexport const addDriveTool = {\n name: \"addDrive\",\n description: \"Create a new drive\",\n inputSchema: {\n driveInput: z\n .object({\n global: z\n .object({\n name: z.string().describe(\"Name of the drive\"),\n icon: z\n .string()\n .nullable()\n .optional()\n .describe(\"Optional icon for the drive\"),\n })\n .describe(\"Global drive properties\"),\n preferredEditor: z\n .string()\n .optional()\n .describe(\n \"Optional app/editor module id recorded as the drive's preferred editor\",\n ),\n local: z\n .object({\n availableOffline: z\n .boolean()\n .optional()\n .describe(\"Whether drive is available offline\"),\n sharingType: z\n .string()\n .nullable()\n .optional()\n .describe(\"Sharing type\"),\n })\n .optional()\n .describe(\"Optional local state properties\"),\n })\n .describe(\"Drive configuration\"),\n },\n outputSchema: {\n driveId: z.string().describe(\"ID of the created drive\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDriveTool = {\n name: \"getDrive\",\n description: \"Get a specific drive\",\n inputSchema: {\n driveId: z.string().describe(\"ID of the drive to retrieve\"),\n options: z\n .object({\n revisions: z\n .record(z.string(), z.number())\n .optional()\n .describe(\"Optional revision filter\"),\n checkHashes: z.boolean().optional().describe(\"Whether to check hashes\"),\n // TODO: Add other ReducerOptions if needed\n })\n .optional()\n .describe(\"Optional get document options\"),\n },\n outputSchema: {\n drive: z.unknown().describe(\"Drive document\"), // TODO: Define DocumentDriveDocument schema\n },\n} as const satisfies ToolSchema;\n\nexport const deleteDriveTool = {\n name: \"deleteDrive\",\n description: \"Delete a drive\",\n inputSchema: {\n driveId: z.string().describe(\"ID of the drive to delete\"),\n },\n outputSchema: {\n success: z.boolean().describe(\"Whether the deletion was successful\"),\n },\n} as const satisfies ToolSchema;\n\nexport const addRemoteDriveTool = {\n name: \"addRemoteDrive\",\n description: \"Connect to a remote drive\",\n inputSchema: {\n url: z.string().describe(\"URL of the remote drive\"),\n options: z\n .object({\n availableOffline: z\n .boolean()\n .describe(\"Whether drive is available offline\"),\n sharingType: z.string().nullable().optional().describe(\"Sharing type\"),\n pullFilter: z\n .object({\n branch: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Branch filter\"),\n documentId: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Document ID filter\"),\n documentType: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Document type filter\"),\n scope: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Scope filter\"),\n })\n .optional()\n .describe(\"Optional pull filter\"),\n pullInterval: z\n .number()\n .optional()\n .describe(\"Pull interval in milliseconds\"),\n })\n .describe(\"Remote drive options\"),\n },\n outputSchema: {\n driveId: z.string().describe(\"ID of the added remote drive\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentModelSchemaTool = {\n name: \"getDocumentModelSchema\",\n description: \"Get the schema of a document model\",\n inputSchema: {\n type: z.string().describe(\"Type of the document model\"),\n },\n outputSchema: {\n schema: z.unknown().describe(\"Schema of the document model\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentModelsTool = {\n name: \"getDocumentModels\",\n description: \"Get the list of document models\",\n inputSchema: {},\n outputSchema: {\n documentModels: z\n .array(\n z.object({\n name: z.string().describe(\"Name of the document model\"),\n type: z.string().describe(\"Type of the document model\"),\n description: z.string().describe(\"Description of the document model\"),\n extension: z.string().describe(\"Extension of the document model\"),\n authorName: z.string().describe(\"Author name of the document model\"),\n authorWebsite: z\n .string()\n .describe(\"Author website of the document model\"),\n }),\n )\n .describe(\"List of available document models\"),\n },\n} as const satisfies ToolSchema;\n\ntype ToolRecord<T extends readonly ToolSchema[]> = {\n [K in T[number][\"name\"]]: ToolWithCallback<Extract<T[number], { name: K }>>;\n};\n\n// All tools array for type inference\nconst _allTools = [\n getDocumentTool,\n createDocumentTool,\n getDocumentsTool,\n deleteDocumentTool,\n addActionsTool,\n // addOperationTool,\n getDrivesTool,\n addDriveTool,\n getDriveTool,\n deleteDriveTool,\n addRemoteDriveTool,\n getDocumentModelSchemaTool,\n getDocumentModelsTool,\n] as const;\n\n// Inferred interface from tools\nexport type ReactorMcpTools = ToolRecord<typeof _allTools>;\n\nexport function createReactorMcpProvider(options: ReactorMcpProviderOptions) {\n const { client, syncManager, subject } = options;\n const view = subject ? { subject } : undefined;\n\n function getDocumentModelModule(documentType: string) {\n return client.getDocumentModelModule(documentType);\n }\n\n const tools = {\n getDocument: toolWithCallback(getDocumentTool, async (params) => {\n const id = params.id ?? params.documentId;\n if (!id) {\n throw new Error(\n \"getDocument needs the document's ID in `id` (or `documentId`)\",\n );\n }\n const document = await client.get<PHDocument>(id, view);\n return { document: { header: document.header, state: document.state } };\n }),\n\n createDocument: toolWithCallback(createDocumentTool, async (params) => {\n if (params.driveId) {\n const module = await getDocumentModelModule(params.documentType);\n if (!module) {\n throw new Error(\n `Document model for type '${params.documentType}' not found`,\n );\n }\n const document = withSignaturePolicy(\n module.utils.createDocument(),\n await client.getCreateSignaturePolicy(),\n );\n if (params.name) {\n document.header.name = params.name;\n }\n const created = await client.drives.addFile(\n params.driveId,\n document,\n params.parentFolder,\n );\n return { documentId: created.header.id };\n }\n\n const created = await client.createEmpty(params.documentType, {});\n return { documentId: created.header.id };\n }),\n\n getDocuments: toolWithCallback(getDocumentsTool, async (params) => {\n const result = await client.getOutgoingRelationships(\n params.parentId,\n \"child\",\n view,\n );\n const documentIds = result.results.map((doc) => doc.header.id);\n return { documentIds };\n }),\n\n deleteDocument: toolWithCallback(deleteDocumentTool, async (params) => {\n try {\n // Routes the delete through the drive; nothing read here is returned.\n const incoming = await client.getIncomingRelationships(\n params.documentId,\n \"child\",\n );\n const driveParent = incoming.results.find(\n (p) => p.header.documentType === DRIVE_DOCUMENT_TYPE,\n );\n if (driveParent) {\n await client.drives.removeNode(\n driveParent.header.id,\n params.documentId,\n );\n } else {\n await client.deleteDocument(params.documentId);\n }\n return { success: true };\n } catch {\n return { success: false };\n }\n }),\n\n addActions: toolWithCallback(addActionsTool, async (params) => {\n const document = await client.get<PHDocument>(params.documentId, view);\n const documentModel = await getDocumentModelModule(\n document.header.documentType,\n );\n if (!documentModel) {\n throw new Error(\n `Document model for document type '${document.header.documentType}' not found`,\n );\n }\n const actions: Action[] = params.actions.map((paramAction) => {\n const baseAction = createBaseAction(\n paramAction.type,\n paramAction.input,\n paramAction.scope,\n );\n if (baseAction) {\n if (!baseAction.action) {\n throw new Error(\n `Invalid action ${JSON.stringify(paramAction)}: ${baseAction.errors.join(\", \")}`,\n );\n }\n return baseAction.action;\n }\n const action: Action = createAction(\n paramAction.type,\n paramAction.input ?? {},\n undefined,\n undefined,\n paramAction.scope,\n );\n const actionValidation = validateDocumentModelAction(\n documentModel,\n action,\n );\n if (!actionValidation.isValid) {\n throw new Error(\n `Invalid action ${JSON.stringify(action)}: ${actionValidation.errors.join(\", \")}`,\n );\n }\n return action;\n });\n\n // Execute actions on the document using the \"main\" branch\n await client.execute(\n params.documentId,\n \"main\",\n actions,\n undefined,\n subject,\n );\n\n return {\n success: true,\n };\n }),\n\n // Drive operation implementations\n getDrives: toolWithCallback(getDrivesTool, async () => {\n // Find all documents of type \"powerhouse/document-drive\"\n const result = await client.find({ type: DRIVE_DOCUMENT_TYPE }, view);\n const driveIds = result.results.map((doc: PHDocument) => doc.header.id);\n return { driveIds };\n }),\n\n addDrive: toolWithCallback(addDriveTool, async (params) => {\n const { driveInput } = params;\n const drive = await client.createEmpty<DocumentDriveDocument>(\n DRIVE_DOCUMENT_TYPE,\n {},\n );\n const driveId = drive.header.id;\n\n // Before the rename, so reactors without the document-view name fix keep it.\n if (driveInput.preferredEditor) {\n await client.setPreferredEditor(driveId, driveInput.preferredEditor);\n }\n if (driveInput.global.name) {\n await client.rename(driveId, driveInput.global.name);\n }\n\n const actions: Action[] = [];\n if (driveInput.global.name) {\n actions.push(setDriveName({ name: driveInput.global.name }));\n }\n if (driveInput.global.icon) {\n actions.push(setDriveIcon({ icon: driveInput.global.icon }));\n }\n if (driveInput.local?.sharingType) {\n actions.push(setSharingType({ type: driveInput.local.sharingType }));\n }\n if (driveInput.local?.availableOffline !== undefined) {\n actions.push(\n setAvailableOffline({\n availableOffline: driveInput.local.availableOffline,\n }),\n );\n }\n if (actions.length > 0) {\n await client.execute(driveId, \"main\", actions, undefined, subject);\n }\n\n return { driveId };\n }),\n\n getDrive: toolWithCallback(getDriveTool, async (params) => {\n const drive = await client.get<DocumentDriveDocument>(\n params.driveId,\n view,\n );\n return { drive: { header: drive.header, state: drive.state } };\n }),\n\n deleteDrive: toolWithCallback(deleteDriveTool, async (params) => {\n try {\n // Use CASCADE to delete the drive and all its contents\n await client.deleteDocument(params.driveId);\n return { success: true };\n } catch {\n return { success: false };\n }\n }),\n\n addRemoteDrive: toolWithCallback(addRemoteDriveTool, async (params) => {\n if (!syncManager) {\n throw new Error(\n \"Remote drive management is not available. \" +\n \"SyncManager was not configured for this MCP server.\",\n );\n }\n\n // Fetch drive info from the REST endpoint to get both id and graphqlEndpoint\n const response = await fetch(params.url);\n if (!response.ok) {\n throw new Error(`Failed to resolve drive info from ${params.url}`);\n }\n const driveInfo = (await response.json()) as {\n id: string;\n graphqlEndpoint: string;\n };\n\n const resolvedDriveId = driveInfo.id;\n const collectionId = DriveCollectionId.forDrive(resolvedDriveId);\n\n // Check if remote already exists\n const existingRemote = syncManager\n .list()\n .find((remote) => remote.meta.collectionId.equals(collectionId));\n if (existingRemote) {\n return { driveId: resolvedDriveId };\n }\n\n // Add the remote via SyncManager\n const remoteName = `mcp-remote-${crypto.randomUUID()}`;\n await syncManager.add(remoteName, collectionId, {\n type: \"gql\",\n parameters: {\n url: driveInfo.graphqlEndpoint,\n },\n });\n\n return { driveId: resolvedDriveId };\n }),\n\n getDocumentModels: toolWithCallback(getDocumentModelsTool, async () => {\n const result = await client.getDocumentModelModules();\n return {\n documentModels: result.results.map((model: DocumentModelModule) => {\n const schemaGlobal = model.documentModel.global;\n return {\n name: schemaGlobal.name,\n type: schemaGlobal.id,\n description: schemaGlobal.description,\n extension: schemaGlobal.extension,\n authorName: schemaGlobal.author.name,\n authorWebsite: schemaGlobal.author.website ?? \"\",\n };\n }),\n };\n }),\n\n getDocumentModelSchema: toolWithCallback(\n getDocumentModelSchemaTool,\n async (params) => {\n const documentModel = await getDocumentModelModule(params.type);\n const schema = documentModel?.documentModel.global;\n if (!schema) {\n throw new Error(`Document model '${params.type}' not found`);\n }\n return { schema };\n },\n ),\n } as const;\n\n const resources = {};\n\n const prompts = {};\n\n return Promise.resolve({\n tools,\n resources,\n prompts,\n } as const);\n}\n"],"mappings":";;;;;;AAWA,IAAa,yBAAb,cAA4C,MAAM;CAChD,YAAY,UAAsB;EAChC,MAAM,0BAA0B,SAAS,OAAO;EAChD,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;;;;;;;;;AAUA,SAAgB,iBACd,MACA,cAKA;CACA,MAAM,kBAAkB,OACtB,SAC4B;EAC5B,IAAI;GACF,MAAM,SAAS,MAAM,aAAa,IAAI;GACtC,OAAO;IACL,SAAS,CACP;KACE,MAAM;KACN,MAAM,KAAK,UAAU,MAAM;IAC7B,CACF;IACA,mBAAmB;GACrB;EACF,SAAS,OAAO;GAGd,OAAO;IACL,SAAS;IACT,SAAS,CACP;KACE,MAAM;KACN,MAAM,UANV,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAOnD,CACF;GACF;EACF;CACF;CACA,OAAO;EACL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ACpC,CAAC;EAED,mBAAmB,iBAAiB,uBAAuB,YAAY;GAErE,OAAO,EACL,iBAAgB,MAFG,OAAO,wBAAwB,EAAA,CAE3B,QAAQ,KAAK,UAA+B;IACjE,MAAM,eAAe,MAAM,cAAc;IACzC,OAAO;KACL,MAAM,aAAa;KACnB,MAAM,aAAa;KACnB,aAAa,aAAa;KAC1B,WAAW,aAAa;KACxB,YAAY,aAAa,OAAO;KAChC,eAAe,aAAa,OAAO,WAAW;IAChD;GACF,CAAC,EACH;EACF,CAAC;EAED,wBAAwB,iBACtB,4BACA,OAAO,WAAW;GAEhB,MAAM,UAAS,MADa,uBAAuB,OAAO,IAAI,EAAA,EAChC,cAAc;GAC5C,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,mBAAmB,OAAO,KAAK,YAAY;GAE7D,OAAO,EAAE,OAAO;EAClB,CACF;CACF;CAMA,OAAO,QAAQ,QAAQ;EACrB;EACA,WAAA,CAAQ;EACR,SAAA,CAAM;CACR,CAAU;AACZ"}
@@ -1,4 +1,4 @@
1
- import { a as createReactorMcpProvider } from "./reactor-CYKTrGtF.mjs";
1
+ import { a as createReactorMcpProvider } from "./reactor-BqyjCnB2.mjs";
2
2
  import { childLogger } from "document-model";
3
3
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
  //#region src/logger.ts
@@ -55,4 +55,4 @@ async function createServer(options) {
55
55
  //#endregion
56
56
  export { logger as n, createServer as t };
57
57
 
58
- //# sourceMappingURL=server-CT8k24iS.mjs.map
58
+ //# sourceMappingURL=server-DF99fpy8.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-CT8k24iS.mjs","names":[],"sources":["../src/logger.ts","../src/server.ts"],"sourcesContent":["import { childLogger, type ILogger } from \"document-model\";\n\nexport const logger: ILogger = childLogger([\"reactor-mcp\"]);\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { IReactorClient, ISyncManager } from \"@powerhousedao/reactor\";\nimport type { AuthSubject } from \"@powerhousedao/shared/document-model\";\nimport { createReactorMcpProvider } from \"./tools/reactor.js\";\n\nexport interface CreateServerOptions {\n client: IReactorClient;\n syncManager?: ISyncManager;\n /** Who the tools read as; omitted, the client's signer. */\n subject?: AuthSubject;\n}\n\nexport const ReactorMcpInstructions = `MUST BE USED when handling documents or document-models for the Powerhouse/Vetra ecosystem.\nThere are 5 main concepts to know of: \n- Document Model: A template for creating documents. It defines the schema and allowed operations for a type of document.\n- Document: An instance of a document model. It contains actual data following the structure defined by the document model and can be changed using operations.\n- Drive: A document of type \"powerhouse/document-drive\" which represents a collection of documents and folders. To create a document inside a drive, use the \"createDocument\" tool with the \"driveId\" parameter — this handles everything atomically. Use \"addActions\" with \"ADD_FILE\" only when adding an existing document to a drive.\n- Action: A proposed change to a document. It is a JSON object with the action name and input that defines the action to be taken on the document. Should be dispatched by calling the \"addActions\" tool.\n- Operation: A change done to a document. It contains the action object plus additional metadata such as the index of the operation in the document history, the timestamp it was added, the hash of the resulting document data, the number of operations skipped, and the error message if the operation failed. Actions dispatched with \"addActions\" get converted into an operation.\n\nWhen planning to add multiple actions to a document, try to reduce the number of \"addActions\" calls to a minimum by adding multiple actions at once.\nUnless the user specifies otherwise, and a drive with slug \"vetra\" is available, create new documents inside it by passing its ID as the \"driveId\" parameter to \"createDocument\".\n\nExamples:\n<example>Context: User needs to create a new document model for their application. user: 'I need to create a user profile document model with fields for name, email, and preferences' assistant: 'I'll use the reactor-mcp-server to help you create this document model.' <commentary>Since the user is requesting document model creation, use the reactor-mcp-document-expert agent to ensure proper reactor-mcp tool usage.</commentary></example> <example>Context: User is building a content management system and needs create documents for certain types of document models. user: 'Can you help me create example documents for blog posts and categories document models?' assistant: 'Let me use the reactor-mcp-server to create these documents using the appropriate reactor-mcp tool calls.' <commentary>Document model creation requires the reactor-mcp-server tool calls to ensure compliance.</commentary></example>\n<example>Context: User needs to create a new document instance of a given document model. user: 'I need to create a demo user profile document' assistant: 'I'll use the reactor-mcp-server to help you create this document with example values.' <commentary>Since the user is requesting document model creation, use the reactor-mcp-document-expert agent to ensure proper reactor-mcp tool usage.</commentary></example> <example>Context: User is building a content management system and needs create documents for certain types of document models. user: 'Can you help me create example documents for blog posts and categories document models?' assistant: 'Let me use the reactor-mcp-server to create these documents using the appropriate reactor-mcp tool calls.' <commentary>Document creation requires the reactor-mcp-server tool calls to ensure compliance.</commentary></example>\n`;\n\nexport async function createServer(\n options: CreateServerOptions,\n): Promise<McpServer> {\n const { client, syncManager, subject } = options;\n const server = new McpServer(\n {\n name: \"reactor-mcp-server\",\n version: \"1.0.0\",\n description: ReactorMcpInstructions,\n },\n {\n capabilities: {\n tools: {},\n resources: {\n subscribe: true,\n listChanged: true,\n },\n prompts: {\n listChanged: true,\n },\n },\n },\n );\n\n server.registerResource(\n \"instructions\",\n \"reactor://instructions\",\n {\n title: \"Instructions\",\n description: \"General instructions on how to use the tools of this MCP\",\n mimeType: \"text/plain\",\n },\n (uri) => ({\n contents: [\n {\n uri: uri.href,\n text: ReactorMcpInstructions,\n },\n ],\n }),\n );\n\n const reactorProvider = await createReactorMcpProvider({\n client,\n syncManager,\n subject,\n });\n\n // const { callback, ...toolSchema } = reactorProvider.tools.getDocumentModels;\n // server.registerTool(\"getDocumentModels\", toolSchema, callback);\n Object.entries(reactorProvider.tools).forEach(\n ([toolName, { callback, ...schema }]) => {\n server.registerTool(toolName, schema as any, callback as any);\n },\n );\n\n return server;\n}\n"],"mappings":";;;;AAEA,MAAa,SAAkB,YAAY,CAAC,aAAa,CAAC;;;ACU1D,MAAa,yBAAyB;;;;;;;;;;;;;;;AAgBtC,eAAsB,aACpB,SACoB;CACpB,MAAM,EAAE,QAAQ,aAAa,YAAY;CACzC,MAAM,SAAS,IAAI,UACjB;EACE,MAAM;EACN,SAAS;EACT,aAAa;CACf,GACA,EACE,cAAc;EACZ,OAAO,CAAC;EACR,WAAW;GACT,WAAW;GACX,aAAa;EACf;EACA,SAAS,EACP,aAAa,KACf;CACF,EACF,CACF;CAEA,OAAO,iBACL,gBACA,0BACA;EACE,OAAO;EACP,aAAa;EACb,UAAU;CACZ,IACC,SAAS,EACR,UAAU,CACR;EACE,KAAK,IAAI;EACT,MAAM;CACR,CACF,EACF,EACF;CAEA,MAAM,kBAAkB,MAAM,yBAAyB;EACrD;EACA;EACA;CACF,CAAC;CAID,OAAO,QAAQ,gBAAgB,KAAK,CAAC,CAAC,SACnC,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc;EACvC,OAAO,aAAa,UAAU,QAAe,QAAe;CAC9D,CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"server-DF99fpy8.mjs","names":[],"sources":["../src/logger.ts","../src/server.ts"],"sourcesContent":["import { childLogger, type ILogger } from \"document-model\";\n\nexport const logger: ILogger = childLogger([\"reactor-mcp\"]);\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { IReactorClient, ISyncManager } from \"@powerhousedao/reactor\";\nimport type { AuthSubject } from \"@powerhousedao/shared/document-model\";\nimport { createReactorMcpProvider } from \"./tools/reactor.js\";\n\nexport interface CreateServerOptions {\n client: IReactorClient;\n syncManager?: ISyncManager;\n /** Who the tools read as; omitted, the client's signer. */\n subject?: AuthSubject;\n}\n\nexport const ReactorMcpInstructions = `MUST BE USED when handling documents or document-models for the Powerhouse/Vetra ecosystem.\nThere are 5 main concepts to know of: \n- Document Model: A template for creating documents. It defines the schema and allowed operations for a type of document.\n- Document: An instance of a document model. It contains actual data following the structure defined by the document model and can be changed using operations.\n- Drive: A document of type \"powerhouse/document-drive\" which represents a collection of documents and folders. To create a document inside a drive, use the \"createDocument\" tool with the \"driveId\" parameter — this handles everything atomically. Use \"addActions\" with \"ADD_FILE\" only when adding an existing document to a drive.\n- Action: A proposed change to a document. It is a JSON object with the action name and input that defines the action to be taken on the document. Should be dispatched by calling the \"addActions\" tool.\n- Operation: A change done to a document. It contains the action object plus additional metadata such as the index of the operation in the document history, the timestamp it was added, the hash of the resulting document data, the number of operations skipped, and the error message if the operation failed. Actions dispatched with \"addActions\" get converted into an operation.\n\nWhen planning to add multiple actions to a document, try to reduce the number of \"addActions\" calls to a minimum by adding multiple actions at once.\nUnless the user specifies otherwise, and a drive with slug \"vetra\" is available, create new documents inside it by passing its ID as the \"driveId\" parameter to \"createDocument\".\n\nExamples:\n<example>Context: User needs to create a new document model for their application. user: 'I need to create a user profile document model with fields for name, email, and preferences' assistant: 'I'll use the reactor-mcp-server to help you create this document model.' <commentary>Since the user is requesting document model creation, use the reactor-mcp-document-expert agent to ensure proper reactor-mcp tool usage.</commentary></example> <example>Context: User is building a content management system and needs create documents for certain types of document models. user: 'Can you help me create example documents for blog posts and categories document models?' assistant: 'Let me use the reactor-mcp-server to create these documents using the appropriate reactor-mcp tool calls.' <commentary>Document model creation requires the reactor-mcp-server tool calls to ensure compliance.</commentary></example>\n<example>Context: User needs to create a new document instance of a given document model. user: 'I need to create a demo user profile document' assistant: 'I'll use the reactor-mcp-server to help you create this document with example values.' <commentary>Since the user is requesting document model creation, use the reactor-mcp-document-expert agent to ensure proper reactor-mcp tool usage.</commentary></example> <example>Context: User is building a content management system and needs create documents for certain types of document models. user: 'Can you help me create example documents for blog posts and categories document models?' assistant: 'Let me use the reactor-mcp-server to create these documents using the appropriate reactor-mcp tool calls.' <commentary>Document creation requires the reactor-mcp-server tool calls to ensure compliance.</commentary></example>\n`;\n\nexport async function createServer(\n options: CreateServerOptions,\n): Promise<McpServer> {\n const { client, syncManager, subject } = options;\n const server = new McpServer(\n {\n name: \"reactor-mcp-server\",\n version: \"1.0.0\",\n description: ReactorMcpInstructions,\n },\n {\n capabilities: {\n tools: {},\n resources: {\n subscribe: true,\n listChanged: true,\n },\n prompts: {\n listChanged: true,\n },\n },\n },\n );\n\n server.registerResource(\n \"instructions\",\n \"reactor://instructions\",\n {\n title: \"Instructions\",\n description: \"General instructions on how to use the tools of this MCP\",\n mimeType: \"text/plain\",\n },\n (uri) => ({\n contents: [\n {\n uri: uri.href,\n text: ReactorMcpInstructions,\n },\n ],\n }),\n );\n\n const reactorProvider = await createReactorMcpProvider({\n client,\n syncManager,\n subject,\n });\n\n // const { callback, ...toolSchema } = reactorProvider.tools.getDocumentModels;\n // server.registerTool(\"getDocumentModels\", toolSchema, callback);\n Object.entries(reactorProvider.tools).forEach(\n ([toolName, { callback, ...schema }]) => {\n server.registerTool(toolName, schema as any, callback as any);\n },\n );\n\n return server;\n}\n"],"mappings":";;;;AAEA,MAAa,SAAkB,YAAY,CAAC,aAAa,CAAC;;;ACU1D,MAAa,yBAAyB;;;;;;;;;;;;;;;AAgBtC,eAAsB,aACpB,SACoB;CACpB,MAAM,EAAE,QAAQ,aAAa,YAAY;CACzC,MAAM,SAAS,IAAI,UACjB;EACE,MAAM;EACN,SAAS;EACT,aAAa;CACf,GACA,EACE,cAAc;EACZ,OAAO,CAAC;EACR,WAAW;GACT,WAAW;GACX,aAAa;EACf;EACA,SAAS,EACP,aAAa,KACf;CACF,EACF,CACF;CAEA,OAAO,iBACL,gBACA,0BACA;EACE,OAAO;EACP,aAAa;EACb,UAAU;CACZ,IACC,SAAS,EACR,UAAU,CACR;EACE,KAAK,IAAI;EACT,MAAM;CACR,CACF,EACF,EACF;CAEA,MAAM,kBAAkB,MAAM,yBAAyB;EACrD;EACA;EACA;CACF,CAAC;CAID,OAAO,QAAQ,gBAAgB,KAAK,CAAC,CAAC,SACnC,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc;EACvC,OAAO,aAAa,UAAU,QAAe,QAAe;CAC9D,CACF;CAEA,OAAO;AACT"}
@@ -1,3 +1,3 @@
1
- import { _ as getDriveTool, a as ReactorMcpTools, c as addRemoteDriveTool, d as deleteDocumentTool, f as deleteDriveTool, g as getDocumentsTool, h as getDocumentTool, i as ReactorMcpProviderOptions, l as createDocumentTool, m as getDocumentModelsTool, n as toolWithCallback, o as addActionsTool, p as getDocumentModelSchemaTool, r as validateDocumentModelAction, s as addDriveTool, t as InvalidToolOutputError, u as createReactorMcpProvider, v as getDrivesTool } from "../index-CWO1xShX.mjs";
2
- export { InvalidToolOutputError, ReactorMcpProviderOptions, ReactorMcpTools, addActionsTool, addDriveTool, addRemoteDriveTool, createDocumentTool, createReactorMcpProvider, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, toolWithCallback, validateDocumentModelAction };
1
+ import { _ as getDocumentsTool, a as ReactorMcpProviderOptions, c as addDriveTool, d as createReactorMcpProvider, f as deleteDocumentTool, g as getDocumentTool, h as getDocumentModelsTool, i as validateDocumentModelAction, l as addRemoteDriveTool, m as getDocumentModelSchemaTool, n as createBaseAction, o as ReactorMcpTools, p as deleteDriveTool, r as toolWithCallback, s as addActionsTool, t as InvalidToolOutputError, u as createDocumentTool, v as getDriveTool, y as getDrivesTool } from "../index-BX9XmJWL.mjs";
2
+ export { InvalidToolOutputError, ReactorMcpProviderOptions, ReactorMcpTools, addActionsTool, addDriveTool, addRemoteDriveTool, createBaseAction, createDocumentTool, createReactorMcpProvider, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, toolWithCallback, validateDocumentModelAction };
3
3
  export {};
@@ -1,2 +1,2 @@
1
- import { a as createReactorMcpProvider, c as getDocumentModelSchemaTool, d as getDocumentsTool, f as getDriveTool, g as validateDocumentModelAction, h as toolWithCallback, i as createDocumentTool, l as getDocumentModelsTool, m as InvalidToolOutputError, n as addDriveTool, o as deleteDocumentTool, p as getDrivesTool, r as addRemoteDriveTool, s as deleteDriveTool, t as addActionsTool, u as getDocumentTool } from "../reactor-CYKTrGtF.mjs";
2
- export { InvalidToolOutputError, addActionsTool, addDriveTool, addRemoteDriveTool, createDocumentTool, createReactorMcpProvider, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, toolWithCallback, validateDocumentModelAction };
1
+ import { _ as validateDocumentModelAction, a as createReactorMcpProvider, c as getDocumentModelSchemaTool, d as getDocumentsTool, f as getDriveTool, g as toolWithCallback, h as createBaseAction, i as createDocumentTool, l as getDocumentModelsTool, m as InvalidToolOutputError, n as addDriveTool, o as deleteDocumentTool, p as getDrivesTool, r as addRemoteDriveTool, s as deleteDriveTool, t as addActionsTool, u as getDocumentTool } from "../reactor-BqyjCnB2.mjs";
2
+ export { InvalidToolOutputError, addActionsTool, addDriveTool, addRemoteDriveTool, createBaseAction, createDocumentTool, createReactorMcpProvider, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, toolWithCallback, validateDocumentModelAction };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/reactor-mcp",
3
- "version": "6.2.3-dev.71",
3
+ "version": "6.2.3-dev.73",
4
4
  "description": "MCP server for the Powerhouse reactor — exposes document model operations and drive management to AI coding assistants via the Model Context Protocol.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -50,12 +50,12 @@
50
50
  "@modelcontextprotocol/sdk": "1.29.0",
51
51
  "@openfeature/env-var-provider": "0.3.1",
52
52
  "@openfeature/server-sdk": "1.19.0",
53
- "@powerhousedao/reactor": "6.2.3-dev.71",
54
- "@powerhousedao/reactor-drive": "6.2.3-dev.71",
55
- "@powerhousedao/reactor-group": "6.2.3-dev.71",
56
- "@powerhousedao/shared": "6.2.3-dev.71",
53
+ "@powerhousedao/reactor": "6.2.3-dev.73",
54
+ "@powerhousedao/reactor-drive": "6.2.3-dev.73",
55
+ "@powerhousedao/reactor-group": "6.2.3-dev.73",
56
+ "@powerhousedao/shared": "6.2.3-dev.73",
57
57
  "change-case": "5.4.4",
58
- "document-model": "6.2.3-dev.71",
58
+ "document-model": "6.2.3-dev.73",
59
59
  "vite": "8.3.4",
60
60
  "zod": "^4.5.4"
61
61
  },
@@ -1 +0,0 @@
1
- {"version":3,"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AiB,sBACtB,QAAQ;;iBAgCG,4BACd,qBAAqB,qBACrB,QAAQ;EACL;EAAkB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactor-CYKTrGtF.mjs","names":[],"sources":["../src/tools/utils.ts","../src/tools/reactor.ts"],"sourcesContent":["import type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { camelCase } from \"change-case\";\nimport type {\n Action,\n DocumentModelModule,\n Operation,\n} from \"@powerhousedao/shared/document-model\";\nimport type { z } from \"zod\";\nimport type { ResolveZodSchema, ToolSchema } from \"./types.js\";\n\nexport class InvalidToolOutputError extends Error {\n constructor(zodError: z.ZodError) {\n super(\"Invalid tool output\\n\" + zodError.message);\n this.name = \"InvalidToolOutputError\";\n this.cause = zodError;\n }\n}\n\n/**\n * Creates a tool with a callback function that handles the tool execution,\n * ensuring the output is valid and errors are handled and returned correctly.\n * @param tool The tool schema to wrap.\n * @param toolCallback The callback function to execute when the tool is called.\n * @returns A CallToolResult with structuredContent if OutputSchema is defined or content if undefined. If the\n * callback throws an error, the result will have isError set to true and the error message in the content.\n */\nexport function toolWithCallback<T extends ToolSchema>(\n tool: T,\n toolCallback: (\n args: ResolveZodSchema<T[\"inputSchema\"]>,\n ) =>\n | ResolveZodSchema<T[\"outputSchema\"]>\n | Promise<ResolveZodSchema<T[\"outputSchema\"]>>,\n) {\n const wrappedCallback = async (\n args: ResolveZodSchema<T[\"inputSchema\"]>,\n ): Promise<CallToolResult> => {\n try {\n const result = await toolCallback(args);\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(result),\n },\n ],\n structuredContent: result,\n } as const satisfies CallToolResult;\n } catch (error) {\n const errorString =\n error instanceof Error ? error.message : String(error);\n return {\n isError: true,\n content: [\n {\n type: \"text\",\n text: `Error: ${errorString}`,\n },\n ],\n } as const satisfies CallToolResult;\n }\n };\n return {\n ...tool,\n callback: wrappedCallback,\n };\n}\n\nexport function validateDocumentModelAction(\n documentModelModule: DocumentModelModule,\n action: Action,\n): { isValid: boolean; errors: string[] } {\n const errors: string[] = [];\n\n const globalState = documentModelModule.documentModel.global;\n\n // Get the latest specification\n if (!globalState.specifications || globalState.specifications.length === 0) {\n errors.push(\"Document model has no specifications\");\n return { isValid: false, errors };\n }\n\n const latestSpec =\n globalState.specifications[globalState.specifications.length - 1];\n\n // Search through modules to find the operation that matches the action type (in SCREAMING_SNAKE_CASE)\n let operation: (Operation & { scope: string }) | null = null;\n\n for (const module of latestSpec.modules) {\n const unsafeOperationOrActionOrSomething = module.operations.find(\n (op) => op.name === action.type,\n ) as unknown as Operation & { scope: string };\n if (unsafeOperationOrActionOrSomething) {\n operation = unsafeOperationOrActionOrSomething;\n break;\n }\n }\n\n if (!operation) {\n errors.push(\n `Operation \"${action.type}\" is not defined in any module of the document model`,\n );\n return { isValid: false, errors };\n }\n\n // Convert action type from SCREAMING_SNAKE_CASE to camelCase to match action creators\n const camelCaseActionType = camelCase(action.type);\n\n // Check if action creator exists in documentModelModule.actions\n const actionCreator = documentModelModule.actions[camelCaseActionType];\n\n if (!actionCreator) {\n errors.push(\n `Action creator \"${camelCaseActionType}\" for action type \"${action.type}\" is not defined in documentModelDocumentModelModule.actions`,\n );\n return { isValid: false, errors };\n }\n\n // Validate the operation using the action creator. TODO: Use document model exported validators directly\n let inputError: Error | null = null;\n try {\n actionCreator(action.input);\n } catch (e) {\n inputError = e instanceof Error ? e : new Error(JSON.stringify(e));\n }\n\n if (inputError) {\n errors.push(`Input validation error: ${inputError.message}`);\n }\n\n // Validate scope if operation defines one\n if (operation.scope && action.scope !== operation.scope) {\n errors.push(\n `Action scope \"${action.scope}\" does not match operation scope \"${operation.scope}\"`,\n );\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n };\n}\n","import type { IReactorClient, ISyncManager } from \"@powerhousedao/reactor\";\nimport { DriveCollectionId } from \"@powerhousedao/reactor\";\nimport type { DocumentDriveDocument } from \"@powerhousedao/shared/document-drive\";\nimport {\n setAvailableOffline,\n setDriveIcon,\n setSharingType,\n} from \"@powerhousedao/shared/document-drive\";\nimport type {\n Action,\n AuthSubject,\n DocumentModelModule,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport {\n createAction,\n withSignaturePolicy,\n} from \"@powerhousedao/shared/document-model\";\nimport { z } from \"zod\";\nimport type { ToolSchema, ToolWithCallback } from \"./types.js\";\nimport { toolWithCallback, validateDocumentModelAction } from \"./utils.js\";\n\nconst DRIVE_DOCUMENT_TYPE = \"powerhouse/document-drive\";\n\nexport type ReactorMcpProviderOptions = {\n client: IReactorClient;\n syncManager?: ISyncManager;\n /**\n * Who the tools read as. A server shared by many callers must set it, an\n * anonymous one to an empty subject. Omitted, reads fall back to the\n * client's signer, which only a single-user local reactor should rely on.\n */\n subject?: AuthSubject;\n};\n\nexport const createDocumentTool = {\n name: \"createDocument\",\n description: `Create a new document.\n Unless the user specifies otherwise, and a drive named \"vetra\" is available, add the document to that drive by providing the drive's ID in the \"driveId\" parameter.\n When \"driveId\" is provided, the document is created and added to the drive atomically — no separate \"addActions\" call with \"ADD_FILE\" is needed.`,\n inputSchema: {\n documentType: z.string().describe(\"Type of the document to create\"),\n name: z\n .string()\n .optional()\n .describe(\n \"Optional name for the document. Used as both the document name and the drive node name when driveId is provided.\",\n ),\n driveId: z\n .string()\n .optional()\n .describe(\n \"Optional drive ID or slug. When provided, the document is created and added to the drive atomically.\",\n ),\n parentFolder: z\n .string()\n .optional()\n .describe(\n \"Optional folder ID within the drive to place the document in. Only used when driveId is provided.\",\n ),\n },\n outputSchema: {\n documentId: z.string().describe(\"ID of the created document\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentTool = {\n name: \"getDocument\",\n description: \"Retrieve a document by its ID\",\n inputSchema: {\n id: z.string().describe(\"ID of the document to retrieve\"),\n },\n outputSchema: {\n document: z.unknown().describe(\"The retrieved Document\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentsTool = {\n name: \"getDocuments\",\n description: \"List documents in a drive\",\n inputSchema: {\n parentId: z.string().describe(\"ID of the drive\"),\n },\n outputSchema: {\n documentIds: z.array(z.string()).describe(\"Array of document IDs\"),\n },\n} as const satisfies ToolSchema;\n\nexport const deleteDocumentTool = {\n name: \"deleteDocument\",\n description: \"Delete a document\",\n inputSchema: {\n documentId: z.string().describe(\"ID of the document to delete\"),\n },\n outputSchema: {\n success: z.boolean().describe(\"Whether the deletion was successful\"),\n },\n} as const satisfies ToolSchema;\n\nexport const addActionsTool = {\n name: \"addActions\",\n description:\n \"Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.\",\n inputSchema: {\n documentId: z.string().describe(\"ID of the document\"),\n actions: z\n .array(\n z\n .object({\n type: z.string().describe(\"The name of the action\"),\n input: z.unknown().describe(\"The payload of the action\"),\n scope: z.string().describe(\"The scope of the action\"),\n context: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\"Optional action context\"), // TODO: Define context schema\n })\n .strict(),\n )\n .describe(\"Action to add to the document\"),\n },\n outputSchema: {\n success: z.boolean().describe(\"Whether the actions were added\"),\n },\n} as const satisfies ToolSchema;\n\n// export const addOperationTool = {\n// name: \"addOperation\",\n// description: \"Add an operation to a document\",\n// inputSchema: {\n// documentId: z.string().describe(\"ID of the document\"),\n// operation: z\n// .object({\n// type: z.string().describe(\"The name of the action\"),\n// input: z.unknown().describe(\"The payload of the action\"),\n// scope: z.string().describe(\"The scope of the action\"),\n// index: z.number().describe(\"Position of the operation in the history\"),\n// timestampUtcMs: z\n// .string()\n// .describe(\"Timestamp of when the operation was added\"),\n// hash: z.string().describe(\"Hash of the resulting document data\"),\n// skip: z.number().describe(\"The number of operations skipped\"),\n// error: z\n// .string()\n// .optional()\n// .describe(\"Error message for a failed action\"),\n// id: z.string().optional().describe(\"Unique operation id\"),\n// context: z.object({}).optional().describe(\"Optional action context\"), // TODO: Define context schema\n// })\n// .strict()\n// .describe(\"Operation to add to the document\"),\n// },\n// outputSchema: {\n// result: z\n// .object({\n// status: z\n// .enum([\"SUCCESS\", \"CONFLICT\", \"MISSING\", \"ERROR\"])\n// .describe(\"Operation status\"),\n// error: z\n// .string()\n// .optional()\n// .describe(\"Error details if operation failed\"), // TODO: Define error schema\n// operations: z\n// .array(z.object({}))\n// .describe(\"Array of operations created\"), // TODO: Define operation schema\n// document: z.object({}).optional().describe(\"Updated document\"), // TODO: Define document schema\n// signals: z.array(z.object({})).describe(\"Array of signals generated\"), // TODO: Define signal schema\n// })\n// .describe(\"Operation result\"),\n// },\n// } as const satisfies ToolSchema;\n\n// Drive Operation Tools\n\nexport const getDrivesTool = {\n name: \"getDrives\",\n description: \"List all drives\",\n inputSchema: {},\n outputSchema: {\n driveIds: z.array(z.string()).describe(\"Array of drive IDs\"),\n },\n} as const satisfies ToolSchema;\n\nexport const addDriveTool = {\n name: \"addDrive\",\n description: \"Create a new drive\",\n inputSchema: {\n driveInput: z\n .object({\n global: z\n .object({\n name: z.string().describe(\"Name of the drive\"),\n icon: z\n .string()\n .nullable()\n .optional()\n .describe(\"Optional icon for the drive\"),\n })\n .describe(\"Global drive properties\"),\n preferredEditor: z\n .string()\n .optional()\n .describe(\n \"Optional app/editor module id recorded as the drive's preferred editor\",\n ),\n local: z\n .object({\n availableOffline: z\n .boolean()\n .optional()\n .describe(\"Whether drive is available offline\"),\n sharingType: z\n .string()\n .nullable()\n .optional()\n .describe(\"Sharing type\"),\n })\n .optional()\n .describe(\"Optional local state properties\"),\n })\n .describe(\"Drive configuration\"),\n },\n outputSchema: {\n driveId: z.string().describe(\"ID of the created drive\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDriveTool = {\n name: \"getDrive\",\n description: \"Get a specific drive\",\n inputSchema: {\n driveId: z.string().describe(\"ID of the drive to retrieve\"),\n options: z\n .object({\n revisions: z\n .record(z.string(), z.number())\n .optional()\n .describe(\"Optional revision filter\"),\n checkHashes: z.boolean().optional().describe(\"Whether to check hashes\"),\n // TODO: Add other ReducerOptions if needed\n })\n .optional()\n .describe(\"Optional get document options\"),\n },\n outputSchema: {\n drive: z.unknown().describe(\"Drive document\"), // TODO: Define DocumentDriveDocument schema\n },\n} as const satisfies ToolSchema;\n\nexport const deleteDriveTool = {\n name: \"deleteDrive\",\n description: \"Delete a drive\",\n inputSchema: {\n driveId: z.string().describe(\"ID of the drive to delete\"),\n },\n outputSchema: {\n success: z.boolean().describe(\"Whether the deletion was successful\"),\n },\n} as const satisfies ToolSchema;\n\nexport const addRemoteDriveTool = {\n name: \"addRemoteDrive\",\n description: \"Connect to a remote drive\",\n inputSchema: {\n url: z.string().describe(\"URL of the remote drive\"),\n options: z\n .object({\n availableOffline: z\n .boolean()\n .describe(\"Whether drive is available offline\"),\n sharingType: z.string().nullable().optional().describe(\"Sharing type\"),\n pullFilter: z\n .object({\n branch: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Branch filter\"),\n documentId: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Document ID filter\"),\n documentType: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Document type filter\"),\n scope: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Scope filter\"),\n })\n .optional()\n .describe(\"Optional pull filter\"),\n pullInterval: z\n .number()\n .optional()\n .describe(\"Pull interval in milliseconds\"),\n })\n .describe(\"Remote drive options\"),\n },\n outputSchema: {\n driveId: z.string().describe(\"ID of the added remote drive\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentModelSchemaTool = {\n name: \"getDocumentModelSchema\",\n description: \"Get the schema of a document model\",\n inputSchema: {\n type: z.string().describe(\"Type of the document model\"),\n },\n outputSchema: {\n schema: z.unknown().describe(\"Schema of the document model\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentModelsTool = {\n name: \"getDocumentModels\",\n description: \"Get the list of document models\",\n inputSchema: {},\n outputSchema: {\n documentModels: z\n .array(\n z.object({\n name: z.string().describe(\"Name of the document model\"),\n type: z.string().describe(\"Type of the document model\"),\n description: z.string().describe(\"Description of the document model\"),\n extension: z.string().describe(\"Extension of the document model\"),\n authorName: z.string().describe(\"Author name of the document model\"),\n authorWebsite: z\n .string()\n .describe(\"Author website of the document model\"),\n }),\n )\n .describe(\"List of available document models\"),\n },\n} as const satisfies ToolSchema;\n\ntype ToolRecord<T extends readonly ToolSchema[]> = {\n [K in T[number][\"name\"]]: ToolWithCallback<Extract<T[number], { name: K }>>;\n};\n\n// All tools array for type inference\nconst _allTools = [\n getDocumentTool,\n createDocumentTool,\n getDocumentsTool,\n deleteDocumentTool,\n addActionsTool,\n // addOperationTool,\n getDrivesTool,\n addDriveTool,\n getDriveTool,\n deleteDriveTool,\n addRemoteDriveTool,\n getDocumentModelSchemaTool,\n getDocumentModelsTool,\n] as const;\n\n// Inferred interface from tools\nexport type ReactorMcpTools = ToolRecord<typeof _allTools>;\n\nexport function createReactorMcpProvider(options: ReactorMcpProviderOptions) {\n const { client, syncManager, subject } = options;\n const view = subject ? { subject } : undefined;\n\n function getDocumentModelModule(documentType: string) {\n return client.getDocumentModelModule(documentType);\n }\n\n const tools = {\n getDocument: toolWithCallback(getDocumentTool, async (params) => {\n const document = await client.get<PHDocument>(params.id, view);\n return { document: { header: document.header, state: document.state } };\n }),\n\n createDocument: toolWithCallback(createDocumentTool, async (params) => {\n if (params.driveId) {\n const module = await getDocumentModelModule(params.documentType);\n if (!module) {\n throw new Error(\n `Document model for type '${params.documentType}' not found`,\n );\n }\n const document = withSignaturePolicy(\n module.utils.createDocument(),\n await client.getCreateSignaturePolicy(),\n );\n if (params.name) {\n document.header.name = params.name;\n }\n const created = await client.drives.addFile(\n params.driveId,\n document,\n params.parentFolder,\n );\n return { documentId: created.header.id };\n }\n\n const created = await client.createEmpty(params.documentType, {});\n return { documentId: created.header.id };\n }),\n\n getDocuments: toolWithCallback(getDocumentsTool, async (params) => {\n const result = await client.getOutgoingRelationships(\n params.parentId,\n \"child\",\n view,\n );\n const documentIds = result.results.map((doc) => doc.header.id);\n return { documentIds };\n }),\n\n deleteDocument: toolWithCallback(deleteDocumentTool, async (params) => {\n try {\n // Routes the delete through the drive; nothing read here is returned.\n const incoming = await client.getIncomingRelationships(\n params.documentId,\n \"child\",\n );\n const driveParent = incoming.results.find(\n (p) => p.header.documentType === DRIVE_DOCUMENT_TYPE,\n );\n if (driveParent) {\n await client.drives.removeNode(\n driveParent.header.id,\n params.documentId,\n );\n } else {\n await client.deleteDocument(params.documentId);\n }\n return { success: true };\n } catch {\n return { success: false };\n }\n }),\n\n addActions: toolWithCallback(addActionsTool, async (params) => {\n const document = await client.get<PHDocument>(params.documentId, view);\n const documentModel = await getDocumentModelModule(\n document.header.documentType,\n );\n if (!documentModel) {\n throw new Error(\n `Document model for document type '${document.header.documentType}' not found`,\n );\n }\n const actions: Action[] = params.actions.map((paramAction) => {\n const action: Action = createAction(\n paramAction.type,\n paramAction.input ?? {},\n undefined,\n undefined,\n paramAction.scope,\n );\n const actionValidation = validateDocumentModelAction(\n documentModel,\n action,\n );\n if (!actionValidation.isValid) {\n throw new Error(\n `Invalid action ${JSON.stringify(action)}: ${actionValidation.errors.join(\", \")}`,\n );\n }\n return action;\n });\n\n // Execute actions on the document using the \"main\" branch\n await client.execute(\n params.documentId,\n \"main\",\n actions,\n undefined,\n subject,\n );\n\n return {\n success: true,\n };\n }),\n\n // Drive operation implementations\n getDrives: toolWithCallback(getDrivesTool, async () => {\n // Find all documents of type \"powerhouse/document-drive\"\n const result = await client.find({ type: DRIVE_DOCUMENT_TYPE }, view);\n const driveIds = result.results.map((doc: PHDocument) => doc.header.id);\n return { driveIds };\n }),\n\n addDrive: toolWithCallback(addDriveTool, async (params) => {\n const { driveInput } = params;\n const drive = await client.createEmpty<DocumentDriveDocument>(\n DRIVE_DOCUMENT_TYPE,\n {},\n );\n const driveId = drive.header.id;\n\n if (driveInput.global.name) {\n await client.rename(driveId, driveInput.global.name);\n }\n if (driveInput.preferredEditor) {\n await client.setPreferredEditor(driveId, driveInput.preferredEditor);\n }\n\n const actions: Action[] = [];\n if (driveInput.global.icon) {\n actions.push(setDriveIcon({ icon: driveInput.global.icon }));\n }\n if (driveInput.local?.sharingType) {\n actions.push(setSharingType({ type: driveInput.local.sharingType }));\n }\n if (driveInput.local?.availableOffline !== undefined) {\n actions.push(\n setAvailableOffline({\n availableOffline: driveInput.local.availableOffline,\n }),\n );\n }\n if (actions.length > 0) {\n await client.execute(driveId, \"main\", actions, undefined, subject);\n }\n\n return { driveId };\n }),\n\n getDrive: toolWithCallback(getDriveTool, async (params) => {\n const drive = await client.get<DocumentDriveDocument>(\n params.driveId,\n view,\n );\n return { drive: { header: drive.header, state: drive.state } };\n }),\n\n deleteDrive: toolWithCallback(deleteDriveTool, async (params) => {\n try {\n // Use CASCADE to delete the drive and all its contents\n await client.deleteDocument(params.driveId);\n return { success: true };\n } catch {\n return { success: false };\n }\n }),\n\n addRemoteDrive: toolWithCallback(addRemoteDriveTool, async (params) => {\n if (!syncManager) {\n throw new Error(\n \"Remote drive management is not available. \" +\n \"SyncManager was not configured for this MCP server.\",\n );\n }\n\n // Fetch drive info from the REST endpoint to get both id and graphqlEndpoint\n const response = await fetch(params.url);\n if (!response.ok) {\n throw new Error(`Failed to resolve drive info from ${params.url}`);\n }\n const driveInfo = (await response.json()) as {\n id: string;\n graphqlEndpoint: string;\n };\n\n const resolvedDriveId = driveInfo.id;\n const collectionId = DriveCollectionId.forDrive(resolvedDriveId);\n\n // Check if remote already exists\n const existingRemote = syncManager\n .list()\n .find((remote) => remote.meta.collectionId.equals(collectionId));\n if (existingRemote) {\n return { driveId: resolvedDriveId };\n }\n\n // Add the remote via SyncManager\n const remoteName = `mcp-remote-${crypto.randomUUID()}`;\n await syncManager.add(remoteName, collectionId, {\n type: \"gql\",\n parameters: {\n url: driveInfo.graphqlEndpoint,\n },\n });\n\n return { driveId: resolvedDriveId };\n }),\n\n getDocumentModels: toolWithCallback(getDocumentModelsTool, async () => {\n const result = await client.getDocumentModelModules();\n return {\n documentModels: result.results.map((model: DocumentModelModule) => {\n const schemaGlobal = model.documentModel.global;\n return {\n name: schemaGlobal.name,\n type: schemaGlobal.id,\n description: schemaGlobal.description,\n extension: schemaGlobal.extension,\n authorName: schemaGlobal.author.name,\n authorWebsite: schemaGlobal.author.website ?? \"\",\n };\n }),\n };\n }),\n\n getDocumentModelSchema: toolWithCallback(\n getDocumentModelSchemaTool,\n async (params) => {\n const documentModel = await getDocumentModelModule(params.type);\n const schema = documentModel?.documentModel.global;\n if (!schema) {\n throw new Error(`Document model '${params.type}' not found`);\n }\n return { schema };\n },\n ),\n } as const;\n\n const resources = {};\n\n const prompts = {};\n\n return Promise.resolve({\n tools,\n resources,\n prompts,\n } as const);\n}\n"],"mappings":";;;;;;AAUA,IAAa,yBAAb,cAA4C,MAAM;CAChD,YAAY,UAAsB;EAChC,MAAM,0BAA0B,SAAS,OAAO;EAChD,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;;;;;;;;;AAUA,SAAgB,iBACd,MACA,cAKA;CACA,MAAM,kBAAkB,OACtB,SAC4B;EAC5B,IAAI;GACF,MAAM,SAAS,MAAM,aAAa,IAAI;GACtC,OAAO;IACL,SAAS,CACP;KACE,MAAM;KACN,MAAM,KAAK,UAAU,MAAM;IAC7B,CACF;IACA,mBAAmB;GACrB;EACF,SAAS,OAAO;GAGd,OAAO;IACL,SAAS;IACT,SAAS,CACP;KACE,MAAM;KACN,MAAM,UANV,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAOnD,CACF;GACF;EACF;CACF;CACA,OAAO;EACL,GAAG;EACH,UAAU;CACZ;AACF;AAEA,SAAgB,4BACd,qBACA,QACwC;CACxC,MAAM,SAAmB,CAAC;CAE1B,MAAM,cAAc,oBAAoB,cAAc;CAGtD,IAAI,CAAC,YAAY,kBAAkB,YAAY,eAAe,WAAW,GAAG;EAC1E,OAAO,KAAK,sCAAsC;EAClD,OAAO;GAAE,SAAS;GAAO;EAAO;CAClC;CAEA,MAAM,aACJ,YAAY,eAAe,YAAY,eAAe,SAAS;CAGjE,IAAI,YAAoD;CAExD,KAAK,MAAM,UAAU,WAAW,SA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