@powerhousedao/reactor-mcp 6.0.0-dev.9 → 6.0.0-dev.91
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/src/cli.js +1 -1
- package/dist/src/cli.js.map +1 -1
- package/dist/src/express.d.ts +6 -2
- package/dist/src/express.d.ts.map +1 -1
- package/dist/src/express.js +2 -2
- package/dist/src/express.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/server.d.ts +7 -3
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +8 -5
- package/dist/src/server.js.map +1 -1
- package/dist/src/stdio/index.d.ts.map +1 -1
- package/dist/src/stdio/index.js +22 -51
- package/dist/src/stdio/index.js.map +1 -1
- package/dist/src/tools/reactor.d.ts +83 -363
- package/dist/src/tools/reactor.d.ts.map +1 -1
- package/dist/src/tools/reactor.js +98 -95
- package/dist/src/tools/reactor.js.map +1 -1
- package/dist/src/tools/types.d.ts +1 -1
- package/dist/src/tools/types.d.ts.map +1 -1
- package/dist/test/reactor.test.js +204 -247
- package/dist/test/reactor.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -18
package/dist/src/cli.js
CHANGED
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;CACpB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC1B,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;CACpB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC1B,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC9B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/src/express.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IReactorClient, ISyncManager } from "@powerhousedao/reactor";
|
|
3
3
|
import type { Express } from "express";
|
|
4
|
-
export
|
|
4
|
+
export interface SetupMcpServerOptions {
|
|
5
|
+
client: IReactorClient;
|
|
6
|
+
syncManager?: ISyncManager;
|
|
7
|
+
}
|
|
8
|
+
export declare function setupMcpServer(options: SetupMcpServerOptions, app: Express): Promise<McpServer>;
|
|
5
9
|
//# sourceMappingURL=express.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/express.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/express.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAI1D,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,cAAc,CAAC;IACvB,WAAW,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,EAC9B,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,SAAS,CAAC,CA6DpB"}
|
package/dist/src/express.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
2
2
|
import { logger } from "./logger.js";
|
|
3
3
|
import { createServer } from "./server.js";
|
|
4
|
-
export async function setupMcpServer(
|
|
5
|
-
const server = await createServer(
|
|
4
|
+
export async function setupMcpServer(options, app) {
|
|
5
|
+
const server = await createServer(options);
|
|
6
6
|
app.post("/mcp", (req, res) => {
|
|
7
7
|
// In stateless mode, create a new instance of transport and server for each request
|
|
8
8
|
// to ensure complete isolation. A single instance would cause request ID collisions
|
package/dist/src/express.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/express.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAGnG,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/express.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAGnG,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;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,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACL,IAAI,EAAE,CAAC,KAAK;gBACZ,OAAO,EAAE,qBAAqB;aAC/B;YACD,EAAE,EAAE,IAAI;SACT,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,mDAAmD;IACnD,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;QACjD,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CACpB,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACL,IAAI,EAAE,CAAC,KAAK;gBACZ,OAAO,EAAE,qBAAqB;aAC/B;YACD,EAAE,EAAE,IAAI;SACT,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { setupMcpServer } from "./express.js";
|
|
2
|
-
export { createServer } from "./server.js";
|
|
1
|
+
export { setupMcpServer, type SetupMcpServerOptions } from "./express.js";
|
|
2
|
+
export { createServer, type CreateServerOptions } from "./server.js";
|
|
3
3
|
export * from "./tools/index.js";
|
|
4
4
|
export * from "./tools/types.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACrE,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA8B,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,YAAY,EAA4B,MAAM,aAAa,CAAC;AACrE,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
package/dist/src/server.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type {
|
|
3
|
-
export
|
|
4
|
-
|
|
2
|
+
import type { IReactorClient, ISyncManager } from "@powerhousedao/reactor";
|
|
3
|
+
export interface CreateServerOptions {
|
|
4
|
+
client: IReactorClient;
|
|
5
|
+
syncManager?: ISyncManager;
|
|
6
|
+
}
|
|
7
|
+
export declare 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 \u2014 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";
|
|
8
|
+
export declare function createServer(options: CreateServerOptions): Promise<McpServer>;
|
|
5
9
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/src/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3E,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,cAAc,CAAC;IACvB,WAAW,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,eAAO,MAAM,sBAAsB,i6GAclC,CAAC;AAEF,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,SAAS,CAAC,CAsDpB"}
|
package/dist/src/server.js
CHANGED
|
@@ -4,23 +4,23 @@ export const ReactorMcpInstructions = `MUST BE USED when handling documents or d
|
|
|
4
4
|
There are 5 main concepts to know of:
|
|
5
5
|
- Document Model: A template for creating documents. It defines the schema and allowed operations for a type of document.
|
|
6
6
|
- 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.
|
|
7
|
-
- Drive: A document of type "powerhouse/document-drive" which represents a collection of documents and folders. To
|
|
7
|
+
- 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.
|
|
8
8
|
- 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.
|
|
9
9
|
- 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.
|
|
10
10
|
|
|
11
11
|
When 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.
|
|
12
|
-
Unless the user specifies otherwise, and a drive with slug "vetra" is available,
|
|
12
|
+
Unless 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".
|
|
13
13
|
|
|
14
14
|
Examples:
|
|
15
15
|
<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>
|
|
16
16
|
<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>
|
|
17
17
|
`;
|
|
18
|
-
export async function createServer(
|
|
18
|
+
export async function createServer(options) {
|
|
19
|
+
const { client, syncManager } = options;
|
|
19
20
|
const server = new McpServer({
|
|
20
21
|
name: "reactor-mcp-server",
|
|
21
22
|
version: "1.0.0",
|
|
22
23
|
description: ReactorMcpInstructions,
|
|
23
|
-
instructions: ReactorMcpInstructions,
|
|
24
24
|
}, {
|
|
25
25
|
capabilities: {
|
|
26
26
|
tools: {},
|
|
@@ -45,7 +45,10 @@ export async function createServer(reactor) {
|
|
|
45
45
|
},
|
|
46
46
|
],
|
|
47
47
|
}));
|
|
48
|
-
const reactorProvider = await createReactorMcpProvider(
|
|
48
|
+
const reactorProvider = await createReactorMcpProvider({
|
|
49
|
+
client,
|
|
50
|
+
syncManager,
|
|
51
|
+
});
|
|
49
52
|
const { callback, ...toolSchema } = reactorProvider.tools.getDocumentModels;
|
|
50
53
|
// server.registerTool("getDocumentModels", toolSchema, callback);
|
|
51
54
|
Object.entries(reactorProvider.tools).forEach(([toolName, { callback, ...schema }]) => {
|
package/dist/src/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAO9D,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;CAcrC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAA4B;IAE5B,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,sBAAsB;KACpC,EACD;QACE,YAAY,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,SAAS,EAAE;gBACT,SAAS,EAAE,IAAI;gBACf,WAAW,EAAE,IAAI;aAClB;YACD,OAAO,EAAE;gBACP,WAAW,EAAE,IAAI;aAClB;SACF;KACF,CACF,CAAC;IAEF,MAAM,CAAC,gBAAgB,CACrB,cAAc,EACd,wBAAwB,EACxB;QACE,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,0DAA0D;QACvE,QAAQ,EAAE,YAAY;KACvB,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACR,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,GAAG,CAAC,IAAI;gBACb,IAAI,EAAE,sBAAsB;aAC7B;SACF;KACF,CAAC,CACH,CAAC;IAEF,MAAM,eAAe,GAAG,MAAM,wBAAwB,CAAC;QACrD,MAAM;QACN,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAC5E,kEAAkE;IAClE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,OAAO,CAC3C,CAAC,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAa,EAAE,QAAe,CAAC,CAAC;IAChE,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stdio/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stdio/index.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAmBD,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE,WAAW,iBAgE7D"}
|
package/dist/src/stdio/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ReactorBuilder, ReactorClientBuilder } from "@powerhousedao/reactor";
|
|
3
|
+
import { driveDocumentModelModule } from "document-drive";
|
|
3
4
|
import { documentModelDocumentModelModule } from "document-model";
|
|
4
|
-
import { generateId } from "document-model/core";
|
|
5
5
|
import { initFeatureFlags } from "../feature-flags.js";
|
|
6
6
|
import { logger } from "../logger.js";
|
|
7
7
|
import { createServer } from "../server.js";
|
|
@@ -10,12 +10,12 @@ const baseDocumentModels = [
|
|
|
10
10
|
documentModelDocumentModelModule,
|
|
11
11
|
driveDocumentModelModule,
|
|
12
12
|
];
|
|
13
|
-
async function
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
return
|
|
13
|
+
async function createReactorClient(documentModels) {
|
|
14
|
+
const reactorBuilder = new ReactorBuilder().withDocumentModels(baseDocumentModels.concat(documentModels));
|
|
15
|
+
const module = await new ReactorClientBuilder()
|
|
16
|
+
.withReactorBuilder(reactorBuilder)
|
|
17
|
+
.buildModule();
|
|
18
|
+
return module;
|
|
19
19
|
}
|
|
20
20
|
export async function initStdioMcpServer(options) {
|
|
21
21
|
const { remoteDrive, root, documentModelsDir = "./document-models", } = options ?? {};
|
|
@@ -29,63 +29,34 @@ export async function initStdioMcpServer(options) {
|
|
|
29
29
|
try {
|
|
30
30
|
const loadedModels = await documentModelsLoader.load();
|
|
31
31
|
documentModels.push(...loadedModels);
|
|
32
|
-
logger.
|
|
32
|
+
logger.info("Loaded document models: @models", loadedModels.map((m) => m.documentModel.global.name).join(", "));
|
|
33
33
|
}
|
|
34
34
|
catch (e) {
|
|
35
|
-
logger.error(e);
|
|
35
|
+
logger.error("@error", e);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
// initializes reactor with loaded document models
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
enableDualActionCreate: true,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
38
|
+
// initializes reactor client with loaded document models
|
|
39
|
+
const reactorModule = await createReactorClient(documentModels);
|
|
40
|
+
const { client, reactor, reactorModule: rModule } = reactorModule;
|
|
44
41
|
// listens for changes in the local document models to update the reactor
|
|
45
|
-
if (documentModelsLoader) {
|
|
42
|
+
if (documentModelsLoader && rModule?.documentModelRegistry) {
|
|
46
43
|
const unsubscribe = await documentModelsLoader.onDocumentModelsChange((models) => {
|
|
47
|
-
|
|
44
|
+
rModule.documentModelRegistry.registerModules(...baseDocumentModels.concat(models));
|
|
48
45
|
});
|
|
49
46
|
process.on("exit", () => {
|
|
50
47
|
unsubscribe();
|
|
48
|
+
reactor.kill();
|
|
51
49
|
});
|
|
52
50
|
}
|
|
53
|
-
// if a remote drive is passed
|
|
51
|
+
// if a remote drive is passed, log a warning since remote drives
|
|
52
|
+
// are now handled at a different level (SyncManager)
|
|
54
53
|
if (remoteDrive) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
sharingType: "PUBLIC",
|
|
58
|
-
availableOffline: true,
|
|
59
|
-
listeners: [
|
|
60
|
-
{
|
|
61
|
-
block: true,
|
|
62
|
-
callInfo: {
|
|
63
|
-
data: remoteDrive,
|
|
64
|
-
name: "switchboard-push",
|
|
65
|
-
transmitterType: "SwitchboardPush",
|
|
66
|
-
},
|
|
67
|
-
filter: {
|
|
68
|
-
branch: ["main"],
|
|
69
|
-
documentId: ["*"],
|
|
70
|
-
documentType: ["*"],
|
|
71
|
-
scope: ["global"],
|
|
72
|
-
},
|
|
73
|
-
label: "Switchboard Sync",
|
|
74
|
-
listenerId: generateId(),
|
|
75
|
-
system: true,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
triggers: [],
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
catch (e) {
|
|
82
|
-
throw new Error(`Failed to add remote drive "${remoteDrive}": ${e instanceof Error ? e.message : e}`, {
|
|
83
|
-
cause: e,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
54
|
+
logger.warn("Remote drive configuration via MCP is not supported in the new reactor. " +
|
|
55
|
+
"Remote drives should be configured at the server level.");
|
|
86
56
|
}
|
|
87
57
|
// starts the server
|
|
88
|
-
|
|
58
|
+
// Note: syncManager is not available in stdio mode currently
|
|
59
|
+
const server = await createServer({ client });
|
|
89
60
|
// starts Stdio transport
|
|
90
61
|
const transport = new StdioServerTransport();
|
|
91
62
|
await server.connect(transport);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stdio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stdio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQhD,MAAM,kBAAkB,GAA+B;IACrD,gCAAgC;IAChC,wBAAwB;CACzB,CAAC;AAEF,KAAK,UAAU,mBAAmB,CAAC,cAAqC;IACtE,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC,kBAAkB,CAC5D,kBAAkB,CAAC,MAAM,CAAC,cAAc,CAAC,CAC1C,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,IAAI,oBAAoB,EAAE;SAC5C,kBAAkB,CAAC,cAAc,CAAC;SAClC,WAAW,EAAE,CAAC;IAEjB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAAqB;IAC5D,MAAM,EACJ,WAAW,EACX,IAAI,EACJ,iBAAiB,GAAG,mBAAmB,GACxC,GAAG,OAAO,IAAI,EAAE,CAAC;IAElB,2BAA2B;IAC3B,MAAM,gBAAgB,EAAE,CAAC;IAEzB,gEAAgE;IAChE,IAAI,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