@powerhousedao/reactor-mcp 4.1.0-dev.3 → 4.1.0-dev.30
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 -10
- 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 +19 -0
- package/dist/src/sdk/chat.d.ts.map +1 -0
- package/dist/src/sdk/chat.js +60 -0
- package/dist/src/sdk/chat.js.map +1 -0
- package/dist/src/server.d.ts +3 -2
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +38 -762
- 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/tools/reactor.d.ts +847 -0
- package/dist/src/tools/reactor.d.ts.map +1 -0
- package/dist/src/{mcp → tools}/reactor.js +200 -146
- 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/{mcp → tools}/utils.d.ts +8 -21
- package/dist/src/tools/utils.d.ts.map +1 -0
- package/dist/src/{utils.js → tools/utils.js} +46 -3
- package/dist/src/tools/utils.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +17 -11
- package/dist/src/mcp/reactor.d.ts +0 -630
- 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 +0 -62
- package/dist/src/mcp/utils.js.map +0 -1
- package/dist/src/reactor.d.ts +0 -43
- package/dist/src/reactor.d.ts.map +0 -1
- package/dist/src/reactor.js +0 -142
- package/dist/src/reactor.js.map +0 -1
- package/dist/src/utils.d.ts +0 -10
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js.map +0 -1
- /package/dist/src/{mcp → tools}/types.d.ts +0 -0
- /package/dist/src/{mcp → tools}/types.js +0 -0
|
@@ -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,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG/D,eAAO,MAAM,kBAAkB;;;;;;;;;;CAWA,CAAC;AAEhC,eAAO,MAAM,eAAe;;;;;;;;;CASG,CAAC;AAEhC,eAAO,MAAM,gBAAgB;;;;;;;;;CASE,CAAC;AAEhC,eAAO,MAAM,kBAAkB;;;;;;;;;CASA,CAAC;AAEhC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;CAyBI,CAAC;AAkDhC,eAAO,MAAM,aAAa;;;;;;;CAOK,CAAC;AAEhC,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;EA8C1C,CAAC;AAGX,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE1D,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAnDnE,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;;;;;;;;;;GAqQnD"}
|
|
@@ -1,39 +1,27 @@
|
|
|
1
|
+
import { generateId } from "document-model";
|
|
2
|
+
import { DocumentModelStateSchema } from "document-model/document-model/gen/schema/zod";
|
|
1
3
|
import { z } from "zod";
|
|
2
|
-
import { toolWithCallback } from "./utils.js";
|
|
3
|
-
export const
|
|
4
|
-
name: "
|
|
5
|
-
description:
|
|
4
|
+
import { toolWithCallback, validateDocumentModelAction } from "./utils.js";
|
|
5
|
+
export const createDocumentTool = {
|
|
6
|
+
name: "createDocument",
|
|
7
|
+
description: `Create a new document.
|
|
8
|
+
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.`,
|
|
6
9
|
inputSchema: {
|
|
7
|
-
|
|
10
|
+
documentType: z.string().describe("Type of the document to create"),
|
|
11
|
+
documentId: z.string().optional().describe("Optional ID for the document"),
|
|
8
12
|
},
|
|
9
13
|
outputSchema: {
|
|
10
|
-
|
|
14
|
+
documentId: z.string().describe("ID of the created document"),
|
|
11
15
|
},
|
|
12
16
|
};
|
|
13
|
-
export const
|
|
14
|
-
name: "
|
|
15
|
-
description: "
|
|
17
|
+
export const getDocumentTool = {
|
|
18
|
+
name: "getDocument",
|
|
19
|
+
description: "Retrieve a document by its ID",
|
|
16
20
|
inputSchema: {
|
|
17
|
-
|
|
18
|
-
documentId: z.string().optional().describe("Optional ID for the document"),
|
|
21
|
+
id: z.string().describe("ID of the document to retrieve"),
|
|
19
22
|
},
|
|
20
23
|
outputSchema: {
|
|
21
|
-
|
|
22
|
-
.object({
|
|
23
|
-
status: z
|
|
24
|
-
.enum(["SUCCESS", "CONFLICT", "MISSING", "ERROR"])
|
|
25
|
-
.describe("Operation status"),
|
|
26
|
-
error: z
|
|
27
|
-
.string()
|
|
28
|
-
.optional()
|
|
29
|
-
.describe("Error details if operation failed"), // TODO: Define error schema
|
|
30
|
-
operations: z
|
|
31
|
-
.array(z.object({}))
|
|
32
|
-
.describe("Array of operations created"), // TODO: Define operation schema
|
|
33
|
-
document: z.object({}).optional().describe("Updated document"), // TODO: Define document schema
|
|
34
|
-
signals: z.array(z.object({})).describe("Array of signals generated"), // TODO: Define signal schema
|
|
35
|
-
})
|
|
36
|
-
.describe("Operation result"),
|
|
24
|
+
document: z.object({}).describe("The retrieved Document"),
|
|
37
25
|
},
|
|
38
26
|
};
|
|
39
27
|
export const getDocumentsTool = {
|
|
@@ -56,103 +44,74 @@ export const deleteDocumentTool = {
|
|
|
56
44
|
success: z.boolean().describe("Whether the deletion was successful"),
|
|
57
45
|
},
|
|
58
46
|
};
|
|
59
|
-
export const
|
|
60
|
-
name: "
|
|
61
|
-
description: "
|
|
47
|
+
export const addActionsTool = {
|
|
48
|
+
name: "addActions",
|
|
49
|
+
description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.",
|
|
62
50
|
inputSchema: {
|
|
63
51
|
documentId: z.string().describe("ID of the document"),
|
|
64
|
-
|
|
52
|
+
actions: z
|
|
53
|
+
.array(z
|
|
65
54
|
.object({
|
|
66
55
|
type: z.string().describe("The name of the action"),
|
|
67
|
-
input: z
|
|
68
|
-
.union([
|
|
69
|
-
z.string(),
|
|
70
|
-
z.number(),
|
|
71
|
-
z.boolean(),
|
|
72
|
-
z.object({}),
|
|
73
|
-
z.array(z.any()),
|
|
74
|
-
z.null(),
|
|
75
|
-
])
|
|
76
|
-
.describe("The payload of the action"),
|
|
56
|
+
input: z.unknown().describe("The payload of the action"),
|
|
77
57
|
scope: z.string().describe("The scope of the action"),
|
|
78
|
-
context: z
|
|
79
|
-
|
|
80
|
-
.strict()
|
|
81
|
-
.describe("Action to add to the document"),
|
|
82
|
-
},
|
|
83
|
-
outputSchema: {
|
|
84
|
-
result: z
|
|
85
|
-
.object({
|
|
86
|
-
status: z
|
|
87
|
-
.enum(["SUCCESS", "CONFLICT", "MISSING", "ERROR"])
|
|
88
|
-
.describe("Operation status"),
|
|
89
|
-
error: z
|
|
90
|
-
.string()
|
|
58
|
+
context: z
|
|
59
|
+
.object({})
|
|
91
60
|
.optional()
|
|
92
|
-
.describe("
|
|
93
|
-
operations: z
|
|
94
|
-
.array(z.object({}))
|
|
95
|
-
.describe("Array of operations created"), // TODO: Define operation schema
|
|
96
|
-
document: z.object({}).optional().describe("Updated document"), // TODO: Define document schema
|
|
97
|
-
signals: z.array(z.object({})).describe("Array of signals generated"), // TODO: Define signal schema
|
|
61
|
+
.describe("Optional action context"), // TODO: Define context schema
|
|
98
62
|
})
|
|
99
|
-
.
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
export const addOperationTool = {
|
|
103
|
-
name: "addOperation",
|
|
104
|
-
description: "Add an operation to a document",
|
|
105
|
-
inputSchema: {
|
|
106
|
-
documentId: z.string().describe("ID of the document"),
|
|
107
|
-
operation: z
|
|
108
|
-
.object({
|
|
109
|
-
type: z.string().describe("The name of the action"),
|
|
110
|
-
input: z
|
|
111
|
-
.union([
|
|
112
|
-
z.string(),
|
|
113
|
-
z.number(),
|
|
114
|
-
z.boolean(),
|
|
115
|
-
z.object({}),
|
|
116
|
-
z.array(z.any()),
|
|
117
|
-
z.null(),
|
|
118
|
-
])
|
|
119
|
-
.describe("The payload of the action"),
|
|
120
|
-
scope: z.string().describe("The scope of the action"),
|
|
121
|
-
index: z.number().describe("Position of the operation in the history"),
|
|
122
|
-
timestamp: z
|
|
123
|
-
.string()
|
|
124
|
-
.describe("Timestamp of when the operation was added"),
|
|
125
|
-
hash: z.string().describe("Hash of the resulting document data"),
|
|
126
|
-
skip: z.number().describe("The number of operations skipped"),
|
|
127
|
-
error: z
|
|
128
|
-
.string()
|
|
129
|
-
.optional()
|
|
130
|
-
.describe("Error message for a failed action"),
|
|
131
|
-
id: z.string().optional().describe("Unique operation id"),
|
|
132
|
-
context: z.object({}).optional().describe("Optional action context"), // TODO: Define context schema
|
|
133
|
-
})
|
|
134
|
-
.strict()
|
|
135
|
-
.describe("Operation to add to the document"),
|
|
63
|
+
.strict())
|
|
64
|
+
.describe("Action to add to the document"),
|
|
136
65
|
},
|
|
137
66
|
outputSchema: {
|
|
138
|
-
|
|
139
|
-
.object({
|
|
140
|
-
status: z
|
|
141
|
-
.enum(["SUCCESS", "CONFLICT", "MISSING", "ERROR"])
|
|
142
|
-
.describe("Operation status"),
|
|
143
|
-
error: z
|
|
144
|
-
.string()
|
|
145
|
-
.optional()
|
|
146
|
-
.describe("Error details if operation failed"), // TODO: Define error schema
|
|
147
|
-
operations: z
|
|
148
|
-
.array(z.object({}))
|
|
149
|
-
.describe("Array of operations created"), // TODO: Define operation schema
|
|
150
|
-
document: z.object({}).optional().describe("Updated document"), // TODO: Define document schema
|
|
151
|
-
signals: z.array(z.object({})).describe("Array of signals generated"), // TODO: Define signal schema
|
|
152
|
-
})
|
|
153
|
-
.describe("Operation result"),
|
|
67
|
+
success: z.boolean().describe("Whether the actions were added"),
|
|
154
68
|
},
|
|
155
69
|
};
|
|
70
|
+
// export const addOperationTool = {
|
|
71
|
+
// name: "addOperation",
|
|
72
|
+
// description: "Add an operation to a document",
|
|
73
|
+
// inputSchema: {
|
|
74
|
+
// documentId: z.string().describe("ID of the document"),
|
|
75
|
+
// operation: z
|
|
76
|
+
// .object({
|
|
77
|
+
// type: z.string().describe("The name of the action"),
|
|
78
|
+
// input: z.unknown().describe("The payload of the action"),
|
|
79
|
+
// scope: z.string().describe("The scope of the action"),
|
|
80
|
+
// index: z.number().describe("Position of the operation in the history"),
|
|
81
|
+
// timestampUtcMs: z
|
|
82
|
+
// .string()
|
|
83
|
+
// .describe("Timestamp of when the operation was added"),
|
|
84
|
+
// hash: z.string().describe("Hash of the resulting document data"),
|
|
85
|
+
// skip: z.number().describe("The number of operations skipped"),
|
|
86
|
+
// error: z
|
|
87
|
+
// .string()
|
|
88
|
+
// .optional()
|
|
89
|
+
// .describe("Error message for a failed action"),
|
|
90
|
+
// id: z.string().optional().describe("Unique operation id"),
|
|
91
|
+
// context: z.object({}).optional().describe("Optional action context"), // TODO: Define context schema
|
|
92
|
+
// })
|
|
93
|
+
// .strict()
|
|
94
|
+
// .describe("Operation to add to the document"),
|
|
95
|
+
// },
|
|
96
|
+
// outputSchema: {
|
|
97
|
+
// result: z
|
|
98
|
+
// .object({
|
|
99
|
+
// status: z
|
|
100
|
+
// .enum(["SUCCESS", "CONFLICT", "MISSING", "ERROR"])
|
|
101
|
+
// .describe("Operation status"),
|
|
102
|
+
// error: z
|
|
103
|
+
// .string()
|
|
104
|
+
// .optional()
|
|
105
|
+
// .describe("Error details if operation failed"), // TODO: Define error schema
|
|
106
|
+
// operations: z
|
|
107
|
+
// .array(z.object({}))
|
|
108
|
+
// .describe("Array of operations created"), // TODO: Define operation schema
|
|
109
|
+
// document: z.object({}).optional().describe("Updated document"), // TODO: Define document schema
|
|
110
|
+
// signals: z.array(z.object({})).describe("Array of signals generated"), // TODO: Define signal schema
|
|
111
|
+
// })
|
|
112
|
+
// .describe("Operation result"),
|
|
113
|
+
// },
|
|
114
|
+
// } as const satisfies ToolSchema;
|
|
156
115
|
// Drive Operation Tools
|
|
157
116
|
export const getDrivesTool = {
|
|
158
117
|
name: "getDrives",
|
|
@@ -202,7 +161,7 @@ export const addDriveTool = {
|
|
|
202
161
|
.describe("Drive configuration"),
|
|
203
162
|
},
|
|
204
163
|
outputSchema: {
|
|
205
|
-
|
|
164
|
+
driveId: z.string().describe("ID of the created drive"),
|
|
206
165
|
},
|
|
207
166
|
};
|
|
208
167
|
export const getDriveTool = {
|
|
@@ -280,7 +239,36 @@ export const addRemoteDriveTool = {
|
|
|
280
239
|
.describe("Remote drive options"),
|
|
281
240
|
},
|
|
282
241
|
outputSchema: {
|
|
283
|
-
|
|
242
|
+
driveId: z.string().describe("ID of the added remote drive"),
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
export const getDocumentModelSchemaTool = {
|
|
246
|
+
name: "getDocumentModelSchema",
|
|
247
|
+
description: "Get the schema of a document model",
|
|
248
|
+
inputSchema: {
|
|
249
|
+
type: z.string().describe("Type of the document model"),
|
|
250
|
+
},
|
|
251
|
+
outputSchema: {
|
|
252
|
+
schema: DocumentModelStateSchema().describe("Schema of the document model"),
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
export const getDocumentModelsTool = {
|
|
256
|
+
name: "getDocumentModels",
|
|
257
|
+
description: "Get the list of document models",
|
|
258
|
+
inputSchema: {},
|
|
259
|
+
outputSchema: {
|
|
260
|
+
documentModels: z
|
|
261
|
+
.array(z.object({
|
|
262
|
+
name: z.string().describe("Name of the document model"),
|
|
263
|
+
type: z.string().describe("Type of the document model"),
|
|
264
|
+
description: z.string().describe("Description of the document model"),
|
|
265
|
+
extension: z.string().describe("Extension of the document model"),
|
|
266
|
+
authorName: z.string().describe("Author name of the document model"),
|
|
267
|
+
authorWebsite: z
|
|
268
|
+
.string()
|
|
269
|
+
.describe("Author website of the document model"),
|
|
270
|
+
}))
|
|
271
|
+
.describe("List of available document models"),
|
|
284
272
|
},
|
|
285
273
|
};
|
|
286
274
|
// All tools array for type inference
|
|
@@ -290,33 +278,43 @@ const allTools = [
|
|
|
290
278
|
createDocumentTool,
|
|
291
279
|
getDocumentsTool,
|
|
292
280
|
deleteDocumentTool,
|
|
293
|
-
|
|
294
|
-
addOperationTool,
|
|
281
|
+
addActionsTool,
|
|
282
|
+
// addOperationTool,
|
|
295
283
|
getDrivesTool,
|
|
296
284
|
addDriveTool,
|
|
297
285
|
getDriveTool,
|
|
298
286
|
deleteDriveTool,
|
|
299
287
|
addRemoteDriveTool,
|
|
288
|
+
getDocumentModelSchemaTool,
|
|
289
|
+
getDocumentModelsTool,
|
|
300
290
|
];
|
|
301
291
|
export async function createReactorMcpProvider(reactor) {
|
|
302
292
|
await reactor.initialize();
|
|
293
|
+
function getDocumentModelModule(documentType) {
|
|
294
|
+
const documentModels = reactor.getDocumentModelModules();
|
|
295
|
+
const documentModel = documentModels.find((model) => model.documentModel.id === documentType);
|
|
296
|
+
return documentModel;
|
|
297
|
+
}
|
|
303
298
|
const tools = {
|
|
304
299
|
getDocument: toolWithCallback(getDocumentTool, async (params) => {
|
|
305
|
-
const
|
|
306
|
-
return { document:
|
|
300
|
+
const { header, state } = await reactor.getDocument(params.id);
|
|
301
|
+
return { document: { header, state } };
|
|
307
302
|
}),
|
|
308
303
|
createDocument: toolWithCallback(createDocumentTool, async (params) => {
|
|
309
304
|
// Create document input based on provided parameters
|
|
310
305
|
const createInput = {
|
|
311
306
|
documentType: params.documentType,
|
|
312
|
-
|
|
307
|
+
id: params.documentId ?? generateId(),
|
|
313
308
|
};
|
|
314
309
|
const result = await reactor.queueDocument(createInput);
|
|
310
|
+
if (result.status !== "SUCCESS") {
|
|
311
|
+
throw new Error(`${result.status}: ${result.error?.message}`);
|
|
312
|
+
}
|
|
313
|
+
if (!result.document?.header.id) {
|
|
314
|
+
throw new Error("Created document doesn't have an Id");
|
|
315
|
+
}
|
|
315
316
|
return {
|
|
316
|
-
|
|
317
|
-
...result,
|
|
318
|
-
error: result.error?.message,
|
|
319
|
-
},
|
|
317
|
+
documentId: result.document.header.id,
|
|
320
318
|
};
|
|
321
319
|
}),
|
|
322
320
|
getDocuments: toolWithCallback(getDocumentsTool, async (params) => {
|
|
@@ -332,26 +330,58 @@ export async function createReactorMcpProvider(reactor) {
|
|
|
332
330
|
return { success: false };
|
|
333
331
|
}
|
|
334
332
|
}),
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
333
|
+
addActions: toolWithCallback(addActionsTool, async (params) => {
|
|
334
|
+
const document = await reactor.getDocument(params.documentId);
|
|
335
|
+
const documentModel = getDocumentModelModule(document.header.documentType);
|
|
336
|
+
if (!documentModel) {
|
|
337
|
+
throw new Error(`Document model for document type '${document.header.documentType}' not found`);
|
|
338
|
+
}
|
|
339
|
+
const actions = params.actions.map((paramAction) => {
|
|
340
|
+
const action = {
|
|
341
|
+
id: generateId(),
|
|
342
|
+
timestampUtcMs: new Date().toISOString(),
|
|
343
|
+
...paramAction,
|
|
344
|
+
input: paramAction.input ?? {},
|
|
345
|
+
};
|
|
346
|
+
const actionValidation = validateDocumentModelAction(documentModel, action);
|
|
347
|
+
if (!actionValidation.isValid) {
|
|
348
|
+
throw new Error(`Invalid action ${JSON.stringify(action)}: ${actionValidation.errors.join(", ")}`);
|
|
349
|
+
}
|
|
350
|
+
return action;
|
|
351
|
+
});
|
|
352
|
+
const result = await reactor.addActions(params.documentId, actions);
|
|
353
|
+
if (result.status !== "SUCCESS") {
|
|
354
|
+
throw new Error(`${result.status}: ${result.error?.message}`);
|
|
355
|
+
}
|
|
356
|
+
const operationErrors = result.operations
|
|
357
|
+
.filter((operation) => operation.error !== undefined)
|
|
358
|
+
.map((operation) => ({
|
|
359
|
+
type: operation.action.type,
|
|
360
|
+
input: operation.action.input,
|
|
361
|
+
error: operation.error,
|
|
362
|
+
}));
|
|
363
|
+
if (operationErrors.length > 0) {
|
|
364
|
+
throw new Error(`Some of the actions failed: ${JSON.stringify(operationErrors)}`);
|
|
365
|
+
}
|
|
346
366
|
return {
|
|
347
|
-
|
|
348
|
-
...result,
|
|
349
|
-
error: typeof result.error === "string"
|
|
350
|
-
? result.error
|
|
351
|
-
: result.error?.message,
|
|
352
|
-
},
|
|
367
|
+
success: true,
|
|
353
368
|
};
|
|
354
369
|
}),
|
|
370
|
+
// addOperation: toolWithCallback(addOperationTool, async (params) => {
|
|
371
|
+
// const result = await reactor.addOperation(params.documentId, {
|
|
372
|
+
// ...params.operation,
|
|
373
|
+
// input: params.operation.input ?? {},
|
|
374
|
+
// });
|
|
375
|
+
// return {
|
|
376
|
+
// result: {
|
|
377
|
+
// ...result,
|
|
378
|
+
// error:
|
|
379
|
+
// typeof result.error === "string"
|
|
380
|
+
// ? result.error
|
|
381
|
+
// : result.error?.message,
|
|
382
|
+
// },
|
|
383
|
+
// };
|
|
384
|
+
// }),
|
|
355
385
|
// Drive operation implementations
|
|
356
386
|
getDrives: toolWithCallback(getDrivesTool, async () => {
|
|
357
387
|
const driveIds = await reactor.getDrives();
|
|
@@ -360,12 +390,12 @@ export async function createReactorMcpProvider(reactor) {
|
|
|
360
390
|
addDrive: toolWithCallback(addDriveTool, async (params) => {
|
|
361
391
|
// Extract preferredEditor and create proper DriveInput
|
|
362
392
|
const { preferredEditor, ...driveInput } = params.driveInput;
|
|
363
|
-
const
|
|
364
|
-
return {
|
|
393
|
+
const result = await reactor.addDrive(driveInput, preferredEditor);
|
|
394
|
+
return { driveId: result.header.id };
|
|
365
395
|
}),
|
|
366
396
|
getDrive: toolWithCallback(getDriveTool, async (params) => {
|
|
367
|
-
const
|
|
368
|
-
return { drive };
|
|
397
|
+
const { header, state } = await reactor.getDrive(params.driveId, params.options);
|
|
398
|
+
return { drive: { header, state } };
|
|
369
399
|
}),
|
|
370
400
|
deleteDrive: toolWithCallback(deleteDriveTool, async (params) => {
|
|
371
401
|
try {
|
|
@@ -394,7 +424,31 @@ export async function createReactorMcpProvider(reactor) {
|
|
|
394
424
|
},
|
|
395
425
|
}),
|
|
396
426
|
});
|
|
397
|
-
return { drive };
|
|
427
|
+
return { driveId: drive.header.id };
|
|
428
|
+
}),
|
|
429
|
+
getDocumentModels: toolWithCallback(getDocumentModelsTool, () => {
|
|
430
|
+
const documentModels = reactor.getDocumentModelModules();
|
|
431
|
+
return {
|
|
432
|
+
documentModels: documentModels.map((model) => {
|
|
433
|
+
const schema = model.documentModel;
|
|
434
|
+
return {
|
|
435
|
+
name: schema.name,
|
|
436
|
+
type: schema.id,
|
|
437
|
+
description: schema.description,
|
|
438
|
+
extension: schema.extension,
|
|
439
|
+
authorName: schema.author.name,
|
|
440
|
+
authorWebsite: schema.author.website ?? "",
|
|
441
|
+
};
|
|
442
|
+
}),
|
|
443
|
+
};
|
|
444
|
+
}),
|
|
445
|
+
getDocumentModelSchema: toolWithCallback(getDocumentModelSchemaTool, (params) => {
|
|
446
|
+
const documentModel = getDocumentModelModule(params.type);
|
|
447
|
+
const schema = documentModel?.documentModel;
|
|
448
|
+
if (!schema) {
|
|
449
|
+
throw new Error(`Document model '${params.type}' not found`);
|
|
450
|
+
}
|
|
451
|
+
return { schema };
|
|
398
452
|
}),
|
|
399
453
|
};
|
|
400
454
|
const resources = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactor.js","sourceRoot":"","sources":["../../../src/tools/reactor.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE;2MAC4L;IACzM,WAAW,EAAE;QACX,YAAY,EAAE,CA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MAAM,WAAW,YAAY,CAC3B,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,EAC7C,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,MAAM,GAAG,MAAM;IAEzB,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;CAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/tools/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { type Action, type DocumentModelModule } from "document-model";
|
|
3
|
+
import { type z } from "zod";
|
|
2
4
|
import type { ResolveZodSchema, ToolSchema } from "./types.js";
|
|
3
5
|
export declare class InvalidToolOutputError extends Error {
|
|
4
6
|
constructor(zodError: z.ZodError);
|
|
@@ -12,25 +14,10 @@ export declare class InvalidToolOutputError extends Error {
|
|
|
12
14
|
* callback throws an error, the result will have isError set to true and the error message in the content.
|
|
13
15
|
*/
|
|
14
16
|
export declare function toolWithCallback<T extends ToolSchema>(tool: T, toolCallback: (args: ResolveZodSchema<T["inputSchema"]>) => ResolveZodSchema<T["outputSchema"]> | Promise<ResolveZodSchema<T["outputSchema"]>>): T & {
|
|
15
|
-
callback: (args: ResolveZodSchema<T["inputSchema"]>) => Promise<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}[];
|
|
21
|
-
readonly structuredContent: {
|
|
22
|
-
[x: string]: any;
|
|
23
|
-
} | undefined;
|
|
24
|
-
isError?: undefined;
|
|
25
|
-
} | {
|
|
26
|
-
readonly isError: true;
|
|
27
|
-
readonly content: [{
|
|
28
|
-
readonly type: "text";
|
|
29
|
-
readonly text: `Error: ${string}`;
|
|
30
|
-
}];
|
|
31
|
-
readonly structuredContent: {
|
|
32
|
-
readonly error: string;
|
|
33
|
-
};
|
|
34
|
-
}>;
|
|
17
|
+
callback: (args: ResolveZodSchema<T["inputSchema"]>) => Promise<CallToolResult>;
|
|
18
|
+
};
|
|
19
|
+
export declare function validateDocumentModelAction(documentModelModule: DocumentModelModule, action: Action): {
|
|
20
|
+
isValid: boolean;
|
|
21
|
+
errors: string[];
|
|
35
22
|
};
|
|
36
23
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/D,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,QAAQ,EAAE,CAAC,CAAC,QAAQ;CAKjC;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,UAAU,EACnD,IAAI,EAAE,CAAC,EACP,YAAY,EAAE,CACZ,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,KAEtC,gBAAgB,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,GACnC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;qBAGxC,gBAAgB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,KACvC,OAAO,CAAC,cAAc,CAAC;EA8B3B;AAED,wBAAgB,2BAA2B,CACzC,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,MAAM,GACb;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAyExC"}
|
|
@@ -1,8 +1,51 @@
|
|
|
1
1
|
import { camelCase } from "change-case";
|
|
2
|
+
export class InvalidToolOutputError extends Error {
|
|
3
|
+
constructor(zodError) {
|
|
4
|
+
super("Invalid tool output\n" + zodError.message);
|
|
5
|
+
this.name = "InvalidToolOutputError";
|
|
6
|
+
this.cause = zodError;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
10
|
+
* Creates a tool with a callback function that handles the tool execution,
|
|
11
|
+
* ensuring the output is valid and errors are handled and returned correctly.
|
|
12
|
+
* @param tool The tool schema to wrap.
|
|
13
|
+
* @param toolCallback The callback function to execute when the tool is called.
|
|
14
|
+
* @returns A CallToolResult with structuredContent if OutputSchema is defined or content if undefined. If the
|
|
15
|
+
* callback throws an error, the result will have isError set to true and the error message in the content.
|
|
5
16
|
*/
|
|
17
|
+
export function toolWithCallback(tool, toolCallback) {
|
|
18
|
+
const wrappedCallback = async (args) => {
|
|
19
|
+
try {
|
|
20
|
+
const result = await toolCallback(args);
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: "text",
|
|
25
|
+
text: JSON.stringify(result),
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
structuredContent: result,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
const errorString = error instanceof Error ? error.message : String(error);
|
|
33
|
+
return {
|
|
34
|
+
isError: true,
|
|
35
|
+
content: [
|
|
36
|
+
{
|
|
37
|
+
type: "text",
|
|
38
|
+
text: `Error: ${errorString}`,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
...tool,
|
|
46
|
+
callback: wrappedCallback,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
6
49
|
export function validateDocumentModelAction(documentModelModule, action) {
|
|
7
50
|
const errors = [];
|
|
8
51
|
const documentModelState = documentModelModule.documentModel;
|
|
@@ -34,7 +77,7 @@ export function validateDocumentModelAction(documentModelModule, action) {
|
|
|
34
77
|
errors.push(`Action creator "${camelCaseActionType}" for action type "${action.type}" is not defined in documentModelDocumentModelModule.actions`);
|
|
35
78
|
return { isValid: false, errors };
|
|
36
79
|
}
|
|
37
|
-
// Validate the operation using the action creator
|
|
80
|
+
// Validate the operation using the action creator. TODO: Use document model exported validators directly
|
|
38
81
|
let inputError = null;
|
|
39
82
|
try {
|
|
40
83
|
actionCreator(action.input);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/tools/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,QAAoB;QAC9B,KAAK,CAAC,uBAAuB,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;IACxB,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAO,EACP,YAIgD;IAEhD,MAAM,eAAe,GAAG,KAAK,EAC3B,IAAwC,EACf,EAAE;QAC3B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;YACxC,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MA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