@powerhousedao/reactor-mcp 4.1.0-dev.5 → 4.1.0-dev.50
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 +7 -3
- package/dist/src/cli.js.map +1 -1
- package/dist/src/express.d.ts +5 -0
- package/dist/src/express.d.ts.map +1 -0
- package/dist/src/express.js +59 -0
- package/dist/src/express.js.map +1 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -49
- package/dist/src/index.js.map +1 -1
- package/dist/src/logger.d.ts +3 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +3 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/sdk/chat.d.ts.map +1 -1
- package/dist/src/sdk/chat.js +3 -2
- package/dist/src/sdk/chat.js.map +1 -1
- package/dist/src/server.d.ts +1 -0
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +30 -4
- package/dist/src/server.js.map +1 -1
- package/dist/src/stdio/index.d.ts +7 -0
- package/dist/src/stdio/index.d.ts.map +1 -0
- package/dist/src/stdio/index.js +84 -0
- package/dist/src/stdio/index.js.map +1 -0
- package/dist/src/stdio/loader.d.ts +18 -0
- package/dist/src/stdio/loader.d.ts.map +1 -0
- package/dist/src/stdio/loader.js +86 -0
- package/dist/src/stdio/loader.js.map +1 -0
- package/dist/src/{mcp → tools}/reactor.d.ts +6 -6
- package/dist/src/tools/reactor.d.ts.map +1 -0
- package/dist/src/{mcp → tools}/reactor.js +8 -5
- package/dist/src/tools/reactor.js.map +1 -0
- package/dist/src/tools/types.d.ts.map +1 -0
- package/dist/src/{mcp → tools}/types.js.map +1 -1
- package/dist/src/tools/utils.d.ts.map +1 -0
- package/dist/src/tools/utils.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +13 -10
- package/dist/src/mcp/reactor.d.ts.map +0 -1
- package/dist/src/mcp/reactor.js.map +0 -1
- package/dist/src/mcp/types.d.ts.map +0 -1
- package/dist/src/mcp/utils.d.ts.map +0 -1
- package/dist/src/mcp/utils.js.map +0 -1
- /package/dist/src/{mcp → tools}/types.d.ts +0 -0
- /package/dist/src/{mcp → tools}/types.js +0 -0
- /package/dist/src/{mcp → tools}/utils.d.ts +0 -0
- /package/dist/src/{mcp → tools}/utils.js +0 -0
package/dist/src/cli.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { logger } from "./logger.js";
|
|
2
|
+
import { initStdioMcpServer } from "./stdio/index.js";
|
|
3
|
+
initStdioMcpServer({
|
|
4
|
+
remoteDrive: process.argv.at(2),
|
|
5
|
+
root: process.cwd(),
|
|
6
|
+
}).catch((error) => {
|
|
7
|
+
logger.error(error);
|
|
4
8
|
process.exit(1);
|
|
5
9
|
});
|
|
6
10
|
//# sourceMappingURL=cli.js.map
|
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,
|
|
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;IACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { type IDocumentDriveServer } from "document-drive";
|
|
3
|
+
import { type Express } from "express";
|
|
4
|
+
export declare function setupMcpServer(reactor: IDocumentDriveServer, app: Express): Promise<McpServer>;
|
|
5
|
+
//# sourceMappingURL=express.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/express.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,KAAK,OAAO,EAA+B,MAAM,SAAS,CAAC;AAIpE,wBAAsB,cAAc,CAClC,OAAO,EAAE,oBAAoB,EAC7B,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,SAAS,CAAC,CA6DpB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
2
|
+
import { logger } from "./logger.js";
|
|
3
|
+
import { createServer } from "./server.js";
|
|
4
|
+
export async function setupMcpServer(reactor, app) {
|
|
5
|
+
const server = await createServer(reactor);
|
|
6
|
+
app.post("/mcp", (req, res) => {
|
|
7
|
+
// In stateless mode, create a new instance of transport and server for each request
|
|
8
|
+
// to ensure complete isolation. A single instance would cause request ID collisions
|
|
9
|
+
// when multiple clients connect concurrently.
|
|
10
|
+
try {
|
|
11
|
+
const transport = new StreamableHTTPServerTransport({
|
|
12
|
+
sessionIdGenerator: undefined,
|
|
13
|
+
});
|
|
14
|
+
res.on("close", () => {
|
|
15
|
+
void transport.close();
|
|
16
|
+
void server.close();
|
|
17
|
+
});
|
|
18
|
+
void server.connect(transport);
|
|
19
|
+
void transport.handleRequest(req, res, req.body);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
logger.error("Error handling MCP request:", error);
|
|
23
|
+
if (!res.headersSent) {
|
|
24
|
+
res.status(500).json({
|
|
25
|
+
jsonrpc: "2.0",
|
|
26
|
+
error: {
|
|
27
|
+
code: -32603,
|
|
28
|
+
message: "Internal server error",
|
|
29
|
+
},
|
|
30
|
+
id: null,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
// SSE notifications not supported in stateless mode
|
|
36
|
+
app.get("/mcp", (req, res) => {
|
|
37
|
+
res.writeHead(405).end(JSON.stringify({
|
|
38
|
+
jsonrpc: "2.0",
|
|
39
|
+
error: {
|
|
40
|
+
code: -32000,
|
|
41
|
+
message: "Method not allowed.",
|
|
42
|
+
},
|
|
43
|
+
id: null,
|
|
44
|
+
}));
|
|
45
|
+
});
|
|
46
|
+
// Session termination not needed in stateless mode
|
|
47
|
+
app.delete("/mcp", (req, res) => {
|
|
48
|
+
res.writeHead(405).end(JSON.stringify({
|
|
49
|
+
jsonrpc: "2.0",
|
|
50
|
+
error: {
|
|
51
|
+
code: -32000,
|
|
52
|
+
message: "Method not allowed.",
|
|
53
|
+
},
|
|
54
|
+
id: null,
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
57
|
+
return server;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=express.js.map
|
|
@@ -0,0 +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;AAE3C,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAA6B,EAC7B,GAAY;IAEZ,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;IAC3C,GAAG,CAAC,IAAI,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,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,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { createServer } from "./server.js";
|
|
2
2
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { driveDocumentModelModule, ReactorBuilder } from "document-drive";
|
|
3
|
-
import { documentModelDocumentModelModule, generateId, } from "document-model";
|
|
4
|
-
import { createServer } from "./server.js";
|
|
5
|
-
async function createReactor() {
|
|
6
|
-
const builder = new ReactorBuilder([
|
|
7
|
-
documentModelDocumentModelModule,
|
|
8
|
-
driveDocumentModelModule,
|
|
9
|
-
]);
|
|
10
|
-
// .withStorage(
|
|
11
|
-
// new FilesystemStorage("./.ph/mcp/storage"),
|
|
12
|
-
// );
|
|
13
|
-
const reactor = builder.build();
|
|
14
|
-
await reactor.initialize();
|
|
15
|
-
return reactor;
|
|
16
|
-
}
|
|
17
|
-
export async function init(remoteDrive) {
|
|
18
|
-
const reactor = await createReactor();
|
|
19
|
-
const server = await createServer(reactor);
|
|
20
|
-
if (remoteDrive) {
|
|
21
|
-
await reactor.addRemoteDrive(remoteDrive, {
|
|
22
|
-
sharingType: "PUBLIC",
|
|
23
|
-
availableOffline: true,
|
|
24
|
-
listeners: [
|
|
25
|
-
{
|
|
26
|
-
block: true,
|
|
27
|
-
callInfo: {
|
|
28
|
-
data: remoteDrive,
|
|
29
|
-
name: "switchboard-push",
|
|
30
|
-
transmitterType: "SwitchboardPush",
|
|
31
|
-
},
|
|
32
|
-
filter: {
|
|
33
|
-
branch: ["main"],
|
|
34
|
-
documentId: ["*"],
|
|
35
|
-
documentType: ["*"],
|
|
36
|
-
scope: ["global"],
|
|
37
|
-
},
|
|
38
|
-
label: "Switchboard Sync",
|
|
39
|
-
listenerId: generateId(),
|
|
40
|
-
system: true,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
triggers: [],
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Start receiving messages on stdin and sending messages on stdout
|
|
47
|
-
const transport = new StdioServerTransport();
|
|
48
|
-
await server.connect(transport);
|
|
49
|
-
}
|
|
1
|
+
export { createServer } from "./server.js";
|
|
50
2
|
//# sourceMappingURL=index.js.map
|
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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE3D,eAAO,MAAM,MAAM,EAAE,OAAsC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,gBAAgB,CAAC;AAE3D,MAAM,CAAC,MAAM,MAAM,GAAY,WAAW,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../src/sdk/chat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../src/sdk/chat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,QAAQ,EAAE,MAAM,IAAI,CAAC;AAIjD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,YAAY,CAAS;gBAEjB,OAAO,GAAE,WAAgB;IAU/B,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAyBrD,aAAa,CACjB,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAC/B,OAAO,CAAC,IAAI,CAAC;CAqBjB"}
|
package/dist/src/sdk/chat.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
2
|
import { streamText } from "ai";
|
|
3
|
+
import { logger } from "../logger.js";
|
|
3
4
|
export class LLMChat {
|
|
4
5
|
provider;
|
|
5
6
|
model;
|
|
@@ -31,7 +32,7 @@ export class LLMChat {
|
|
|
31
32
|
return fullResponse;
|
|
32
33
|
}
|
|
33
34
|
catch (error) {
|
|
34
|
-
|
|
35
|
+
logger.error("Error sending message to LLM:", error);
|
|
35
36
|
throw error;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -51,7 +52,7 @@ export class LLMChat {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
catch (error) {
|
|
54
|
-
|
|
55
|
+
logger.error("Error streaming message from LLM:", error);
|
|
55
56
|
throw error;
|
|
56
57
|
}
|
|
57
58
|
}
|
package/dist/src/sdk/chat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../src/sdk/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../src/sdk/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAatC,MAAM,OAAO,OAAO;IACV,QAAQ,CAAW;IACnB,KAAK,CAAS;IACd,YAAY,CAAS;IAE7B,YAAY,UAAuB,EAAE;QACnC,IAAI,CAAC,QAAQ;YACX,OAAO,CAAC,QAAQ;gBAChB,YAAY,CAAC;oBACX,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE;iBACzC,CAAC,CAAC;QACL,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,aAAa,CAAC;QAC5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AAE,IAAI,CAAC,YAAY;gBACzB,QAAQ,EAAE,YAAY;aACvB,CAAC,CAAC;YAEH,IAAI,KAAK,EAAE,MAAM,QAAQ,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC/C,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;YACzD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
package/dist/src/server.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { type IDocumentDriveServer } from "document-drive";
|
|
3
|
+
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 add documents to a drive, use the \"addActions\" tool with an \"ADD_FILE\" action.\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, add newly created documents to it.\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";
|
|
3
4
|
export declare function createServer(reactor: IDocumentDriveServer): Promise<McpServer>;
|
|
4
5
|
//# 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":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,wBAAsB,YAAY,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,eAAO,MAAM,sBAAsB,+sGAclC,CAAC;AAEF,wBAAsB,YAAY,CAChC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,SAAS,CAAC,CAoDpB"}
|
package/dist/src/server.js
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import { createReactorMcpProvider } from "#
|
|
1
|
+
import { createReactorMcpProvider } from "#tools/reactor.js";
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
export const ReactorMcpInstructions = `MUST BE USED when handling documents or document-models for the Powerhouse/Vetra ecosystem.
|
|
4
|
+
There are 5 main concepts to know of:
|
|
5
|
+
- Document Model: A template for creating documents. It defines the schema and allowed operations for a type of document.
|
|
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 add documents to a drive, use the "addActions" tool with an "ADD_FILE" action.
|
|
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
|
+
- 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
|
+
|
|
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, add newly created documents to it.
|
|
13
|
+
|
|
14
|
+
Examples:
|
|
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
|
+
<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
|
+
`;
|
|
3
18
|
export async function createServer(reactor) {
|
|
4
|
-
// Create an MCP server for document model operations.
|
|
5
|
-
// For document model creation tasks, consider using the document-model-creator agent
|
|
6
|
-
// which provides a more guided experience.
|
|
7
19
|
const server = new McpServer({
|
|
8
20
|
name: "reactor-mcp-server",
|
|
9
21
|
version: "1.0.0",
|
|
22
|
+
description: ReactorMcpInstructions,
|
|
23
|
+
instructions: ReactorMcpInstructions,
|
|
10
24
|
}, {
|
|
11
25
|
capabilities: {
|
|
12
26
|
tools: {},
|
|
@@ -19,6 +33,18 @@ export async function createServer(reactor) {
|
|
|
19
33
|
},
|
|
20
34
|
},
|
|
21
35
|
});
|
|
36
|
+
server.registerResource("instructions", "reactor://instructions", {
|
|
37
|
+
title: "Instructions",
|
|
38
|
+
description: "General instructions on how to use the tools of this MCP",
|
|
39
|
+
mimeType: "text/plain",
|
|
40
|
+
}, (uri) => ({
|
|
41
|
+
contents: [
|
|
42
|
+
{
|
|
43
|
+
uri: uri.href,
|
|
44
|
+
text: ReactorMcpInstructions,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
}));
|
|
22
48
|
const reactorProvider = await createReactorMcpProvider(reactor);
|
|
23
49
|
const { callback, ...toolSchema } = reactorProvider.tools.getDocumentModels;
|
|
24
50
|
// server.registerTool("getDocumentModels", toolSchema, callback);
|
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,wBAAwB,EAAE,MAAM,
|
|
1
|
+
{"version":3,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AAE;QACtC,iEAAiE;QACjE,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAa,EAAE,QAAe,CAAC,CAAC;IAChE,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stdio/index.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAeD,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE,WAAW,iBAoF7D"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
2
|
+
import { driveDocumentModelModule, ReactorBuilder } from "document-drive";
|
|
3
|
+
import { documentModelDocumentModelModule, generateId, } from "document-model";
|
|
4
|
+
import { logger } from "../logger.js";
|
|
5
|
+
import { createServer } from "../server.js";
|
|
6
|
+
import { VitePackageLoader } from "./loader.js";
|
|
7
|
+
const baseDocumentModels = [
|
|
8
|
+
documentModelDocumentModelModule,
|
|
9
|
+
driveDocumentModelModule,
|
|
10
|
+
];
|
|
11
|
+
async function createReactor(documentModels = []) {
|
|
12
|
+
const builder = new ReactorBuilder(baseDocumentModels.concat(documentModels));
|
|
13
|
+
const reactor = builder.build();
|
|
14
|
+
await reactor.initialize();
|
|
15
|
+
return reactor;
|
|
16
|
+
}
|
|
17
|
+
export async function initStdioMcpServer(options) {
|
|
18
|
+
const { remoteDrive, root, documentModelsDir = "./document-models", } = options ?? {};
|
|
19
|
+
// if root of project is passed then loads local document models
|
|
20
|
+
let documentModelsLoader;
|
|
21
|
+
const documentModels = [];
|
|
22
|
+
if (root) {
|
|
23
|
+
documentModelsLoader = new VitePackageLoader(root, documentModelsDir);
|
|
24
|
+
try {
|
|
25
|
+
const loadedModels = await documentModelsLoader.load();
|
|
26
|
+
documentModels.push(...loadedModels);
|
|
27
|
+
logger.log("Loaded document models:", loadedModels.map((m) => m.documentModel.name).join(", "));
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
logger.error(e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// initializes reactor with loaded document models
|
|
34
|
+
const reactor = await createReactor(documentModels);
|
|
35
|
+
// listens for changes in the local document models to update the reactor
|
|
36
|
+
if (documentModelsLoader) {
|
|
37
|
+
const unsubscribe = await documentModelsLoader.onDocumentModelsChange((models) => {
|
|
38
|
+
reactor.setDocumentModelModules(baseDocumentModels.concat(models));
|
|
39
|
+
});
|
|
40
|
+
process.on("exit", () => {
|
|
41
|
+
unsubscribe();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// if a remote drive is passed then adds it to the reactor
|
|
45
|
+
if (remoteDrive) {
|
|
46
|
+
try {
|
|
47
|
+
await reactor.addRemoteDrive(remoteDrive, {
|
|
48
|
+
sharingType: "PUBLIC",
|
|
49
|
+
availableOffline: true,
|
|
50
|
+
listeners: [
|
|
51
|
+
{
|
|
52
|
+
block: true,
|
|
53
|
+
callInfo: {
|
|
54
|
+
data: remoteDrive,
|
|
55
|
+
name: "switchboard-push",
|
|
56
|
+
transmitterType: "SwitchboardPush",
|
|
57
|
+
},
|
|
58
|
+
filter: {
|
|
59
|
+
branch: ["main"],
|
|
60
|
+
documentId: ["*"],
|
|
61
|
+
documentType: ["*"],
|
|
62
|
+
scope: ["global"],
|
|
63
|
+
},
|
|
64
|
+
label: "Switchboard Sync",
|
|
65
|
+
listenerId: generateId(),
|
|
66
|
+
system: true,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
triggers: [],
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
throw new Error(`Failed to add remote drive "${remoteDrive}": ${e instanceof Error ? e.message : e}`, {
|
|
74
|
+
cause: e,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// starts the server
|
|
79
|
+
const server = await createServer(reactor);
|
|
80
|
+
// starts Stdio transport
|
|
81
|
+
const transport = new StdioServerTransport();
|
|
82
|
+
await server.connect(transport);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EACL,gCAAgC,EAChC,UAAU,GAEX,MAAM,gBAAgB,CAAC;AACxB,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,GAAG;IACzB,gCAAgC;IAChC,wBAAwB;CACW,CAAC;AAEtC,KAAK,UAAU,aAAa,CAAC,iBAAwC,EAAE;IACrE,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,kBAAkB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;IAC9E,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAChC,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;IAE3B,OAAO,OAAO,CAAC;AACjB,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,gEAAgE;IAChE,IAAI,oBAAmD,CAAC;IACxD,MAAM,cAAc,GAA0B,EAAE,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AkB;4BACxB,eAAe,EAAE,iBAAiB;yBACnC;wBACD,MAAM,EAAE;4BACN,MAAM,EAAE,CAAC,MAAM,CAAC;4BAChB,UAAU,EAAE,CAAC,GAAG,CAAC;4BACjB,YAAY,EAAE,CAAC,GAAG,CAAC;4BACnB,KAAK,EAAE,CAAC,QAAQ,CAAC;yBAClB;wBACD,KAAK,EAAE,kBAAkB;wBACzB,UAAU,EAAE,UAAU,EAAE;wBACxB,MAAM,EAAE,IAAI;qBACb;iBACF;gBACD,QAAQ,EAAE,EAAE;aACb,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CACb,+BAA+B,WAAW,MAAM,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,EACpF;gBACE,KAAK,EAAE,CAAC;aACT,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,oBAAoB;IACpB,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;IAE3C,yBAAyB;IACzB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type DocumentModelModule } from "document-model";
|
|
2
|
+
interface IPackageLoader {
|
|
3
|
+
load(): Promise<DocumentModelModule[]>;
|
|
4
|
+
onDocumentModelsChange(callback: (models: DocumentModelModule[]) => void): Promise<() => void>;
|
|
5
|
+
}
|
|
6
|
+
export declare class VitePackageLoader implements IPackageLoader {
|
|
7
|
+
private readonly logger;
|
|
8
|
+
private readonly root;
|
|
9
|
+
private readonly documentModelsDir;
|
|
10
|
+
private vite;
|
|
11
|
+
constructor(root: string, documentModelsDir: string);
|
|
12
|
+
private get fullPath();
|
|
13
|
+
private initVite;
|
|
14
|
+
load(): Promise<DocumentModelModule[]>;
|
|
15
|
+
onDocumentModelsChange(callback: (models: DocumentModelModule[]) => void): Promise<() => void>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/stdio/loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAK1D,UAAU,cAAc;IACtB,IAAI,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACvC,sBAAsB,CACpB,QAAQ,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,IAAI,GAChD,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;CACxB;AAaD,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiD;IAExE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAE3C,OAAO,CAAC,IAAI,CAA4B;gBAE5B,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;IAKnD,OAAO,KAAK,QAAQ,GAEnB;YAEa,QAAQ;IA4BhB,IAAI,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAqCtC,sBAAsB,CAC1B,QAAQ,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,IAAI;CAepD"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { childLogger } from "document-drive";
|
|
2
|
+
import { access } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { createServer } from "vite";
|
|
5
|
+
function debounce(func, delay = 100) {
|
|
6
|
+
let timeoutId;
|
|
7
|
+
return (...args) => {
|
|
8
|
+
clearTimeout(timeoutId);
|
|
9
|
+
timeoutId = setTimeout(() => func(...args), delay);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export class VitePackageLoader {
|
|
13
|
+
logger = childLogger(["reactor-local", "vite-loader"]);
|
|
14
|
+
root;
|
|
15
|
+
documentModelsDir;
|
|
16
|
+
vite;
|
|
17
|
+
constructor(root, documentModelsDir) {
|
|
18
|
+
this.root = root;
|
|
19
|
+
this.documentModelsDir = documentModelsDir;
|
|
20
|
+
}
|
|
21
|
+
get fullPath() {
|
|
22
|
+
return path.join(this.root, this.documentModelsDir);
|
|
23
|
+
}
|
|
24
|
+
async initVite() {
|
|
25
|
+
if (this.vite) {
|
|
26
|
+
return this.vite;
|
|
27
|
+
}
|
|
28
|
+
this.vite = await createServer({
|
|
29
|
+
root: this.root,
|
|
30
|
+
logLevel: "info",
|
|
31
|
+
server: {
|
|
32
|
+
hmr: false,
|
|
33
|
+
middlewareMode: true,
|
|
34
|
+
warmup: {
|
|
35
|
+
ssrFiles: [this.fullPath],
|
|
36
|
+
},
|
|
37
|
+
fs: {
|
|
38
|
+
allow: [this.fullPath],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
optimizeDeps: {
|
|
42
|
+
// It's recommended to disable deps optimization
|
|
43
|
+
noDiscovery: true,
|
|
44
|
+
include: [],
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return this.vite;
|
|
48
|
+
}
|
|
49
|
+
async load() {
|
|
50
|
+
const vite = await this.initVite();
|
|
51
|
+
await access(this.fullPath);
|
|
52
|
+
this.logger.verbose("Loading document models from", this.fullPath);
|
|
53
|
+
try {
|
|
54
|
+
const localDMs = (await vite.ssrLoadModule(this.fullPath));
|
|
55
|
+
const exports = Object.values(localDMs);
|
|
56
|
+
// duck type
|
|
57
|
+
const documentModels = [];
|
|
58
|
+
for (const dm of exports) {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
60
|
+
if (dm.documentModel) {
|
|
61
|
+
documentModels.push(dm);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
this.logger.verbose(` ➜ Loaded ${documentModels.length} Document Models from: ${this.fullPath}`);
|
|
65
|
+
return documentModels;
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
this.logger.verbose(` ➜ No Document Models found for: ${this.fullPath}${e ? `\n${JSON.stringify(e)}` : ""}`);
|
|
69
|
+
}
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
async onDocumentModelsChange(callback) {
|
|
73
|
+
const vite = await this.initVite();
|
|
74
|
+
const listener = debounce(async (changedPath) => {
|
|
75
|
+
if (path.matchesGlob(changedPath, path.join(this.fullPath, "**"))) {
|
|
76
|
+
const documentModels = await this.load();
|
|
77
|
+
callback(documentModels);
|
|
78
|
+
}
|
|
79
|
+
}, 100);
|
|
80
|
+
vite.watcher.on("change", listener);
|
|
81
|
+
return () => {
|
|
82
|
+
vite.watcher.off("change", listener);
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/stdio/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAsB,MAAM,MAAM,CAAC;AASxD,SAAS,QAAQ,CACf,IAAO,EACP,KAAK,GAAG,GAAG;IAEX,IAAI,SAAwC,CAAC;IAC7C,OAAO,CAAC,GAAG,IAAmB,EAAQ,EAAE;QACtC,YAAY,CAAC,SAAS,CAAC,CAAC;QACxB,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,iBAA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QACH,CAAC,EAAE,GAAG,CAAC,CAAC;QACR,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAEpC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -4,7 +4,7 @@ import { z } from "zod";
|
|
|
4
4
|
import type { ToolSchema, ToolWithCallback } from "./types.js";
|
|
5
5
|
export declare const createDocumentTool: {
|
|
6
6
|
readonly name: "createDocument";
|
|
7
|
-
readonly description: "Create a new document";
|
|
7
|
+
readonly description: "Create a new document.\n Unless the user specifies otherwise, and a drive named \"vetra\" is available, add the document after creating it to that drive using \"addActions\" tool with a \"ADD_FILE\" action to the drive document.";
|
|
8
8
|
readonly inputSchema: {
|
|
9
9
|
readonly documentType: z.ZodString;
|
|
10
10
|
readonly documentId: z.ZodOptional<z.ZodString>;
|
|
@@ -45,7 +45,7 @@ export declare const deleteDocumentTool: {
|
|
|
45
45
|
};
|
|
46
46
|
export declare const addActionsTool: {
|
|
47
47
|
readonly name: "addActions";
|
|
48
|
-
readonly description: "Adds actions to a document";
|
|
48
|
+
readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.";
|
|
49
49
|
readonly inputSchema: {
|
|
50
50
|
readonly documentId: z.ZodString;
|
|
51
51
|
readonly actions: z.ZodArray<z.ZodObject<{
|
|
@@ -274,7 +274,7 @@ declare const allTools: readonly [{
|
|
|
274
274
|
};
|
|
275
275
|
}, {
|
|
276
276
|
readonly name: "createDocument";
|
|
277
|
-
readonly description: "Create a new document";
|
|
277
|
+
readonly description: "Create a new document.\n Unless the user specifies otherwise, and a drive named \"vetra\" is available, add the document after creating it to that drive using \"addActions\" tool with a \"ADD_FILE\" action to the drive document.";
|
|
278
278
|
readonly inputSchema: {
|
|
279
279
|
readonly documentType: z.ZodString;
|
|
280
280
|
readonly documentId: z.ZodOptional<z.ZodString>;
|
|
@@ -302,7 +302,7 @@ declare const allTools: readonly [{
|
|
|
302
302
|
};
|
|
303
303
|
}, {
|
|
304
304
|
readonly name: "addActions";
|
|
305
|
-
readonly description: "Adds actions to a document";
|
|
305
|
+
readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.";
|
|
306
306
|
readonly inputSchema: {
|
|
307
307
|
readonly documentId: z.ZodString;
|
|
308
308
|
readonly actions: z.ZodArray<z.ZodObject<{
|
|
@@ -524,7 +524,7 @@ export declare function createReactorMcpProvider(reactor: IDocumentDriveServer):
|
|
|
524
524
|
};
|
|
525
525
|
readonly createDocument: {
|
|
526
526
|
readonly name: "createDocument";
|
|
527
|
-
readonly description: "Create a new document";
|
|
527
|
+
readonly description: "Create a new document.\n Unless the user specifies otherwise, and a drive named \"vetra\" is available, add the document after creating it to that drive using \"addActions\" tool with a \"ADD_FILE\" action to the drive document.";
|
|
528
528
|
readonly inputSchema: {
|
|
529
529
|
readonly documentType: z.ZodString;
|
|
530
530
|
readonly documentId: z.ZodOptional<z.ZodString>;
|
|
@@ -568,7 +568,7 @@ export declare function createReactorMcpProvider(reactor: IDocumentDriveServer):
|
|
|
568
568
|
};
|
|
569
569
|
readonly addActions: {
|
|
570
570
|
readonly name: "addActions";
|
|
571
|
-
readonly description: "Adds actions to a document";
|
|
571
|
+
readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.";
|
|
572
572
|
readonly inputSchema: {
|
|
573
573
|
readonly documentId: z.ZodString;
|
|
574
574
|
readonly actions: z.ZodArray<z.ZodObject<{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactor.d.ts","sourceRoot":"","sources":["../../../src/tools/reactor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,KAAK,kBAAkB,EAAc,MAAM,gBAAgB,CAAC;AAErE,O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