@powerhousedao/reactor-mcp 6.0.0-dev.153 → 6.0.0-dev.154

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.
Files changed (75) hide show
  1. package/dist/cli.d.mts +1 -0
  2. package/dist/cli.mjs +137 -0
  3. package/dist/cli.mjs.map +1 -0
  4. package/dist/index.d.mts +637 -0
  5. package/dist/index.d.mts.map +1 -0
  6. package/dist/index.mjs +46 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/server-DlxQXYHz.mjs +389 -0
  9. package/dist/server-DlxQXYHz.mjs.map +1 -0
  10. package/package.json +16 -9
  11. package/dist/src/cli.d.ts +0 -2
  12. package/dist/src/cli.d.ts.map +0 -1
  13. package/dist/src/cli.js +0 -10
  14. package/dist/src/cli.js.map +0 -1
  15. package/dist/src/feature-flags.d.ts +0 -2
  16. package/dist/src/feature-flags.d.ts.map +0 -1
  17. package/dist/src/feature-flags.js +0 -9
  18. package/dist/src/feature-flags.js.map +0 -1
  19. package/dist/src/index.d.ts +0 -5
  20. package/dist/src/index.d.ts.map +0 -1
  21. package/dist/src/index.js +0 -5
  22. package/dist/src/index.js.map +0 -1
  23. package/dist/src/logger.d.ts +0 -3
  24. package/dist/src/logger.d.ts.map +0 -1
  25. package/dist/src/logger.js +0 -3
  26. package/dist/src/logger.js.map +0 -1
  27. package/dist/src/mcp-routes.d.ts +0 -19
  28. package/dist/src/mcp-routes.d.ts.map +0 -1
  29. package/dist/src/mcp-routes.js +0 -50
  30. package/dist/src/mcp-routes.js.map +0 -1
  31. package/dist/src/sdk/chat.d.ts +0 -19
  32. package/dist/src/sdk/chat.d.ts.map +0 -1
  33. package/dist/src/sdk/chat.js +0 -60
  34. package/dist/src/sdk/chat.js.map +0 -1
  35. package/dist/src/server.d.ts +0 -9
  36. package/dist/src/server.d.ts.map +0 -1
  37. package/dist/src/server.js +0 -59
  38. package/dist/src/server.js.map +0 -1
  39. package/dist/src/stdio/index.d.ts +0 -7
  40. package/dist/src/stdio/index.d.ts.map +0 -1
  41. package/dist/src/stdio/index.js +0 -64
  42. package/dist/src/stdio/index.js.map +0 -1
  43. package/dist/src/stdio/loader.d.ts +0 -19
  44. package/dist/src/stdio/loader.d.ts.map +0 -1
  45. package/dist/src/stdio/loader.js +0 -90
  46. package/dist/src/stdio/loader.js.map +0 -1
  47. package/dist/src/tools/index.d.ts +0 -3
  48. package/dist/src/tools/index.d.ts.map +0 -1
  49. package/dist/src/tools/index.js +0 -3
  50. package/dist/src/tools/index.js.map +0 -1
  51. package/dist/src/tools/reactor.d.ts +0 -567
  52. package/dist/src/tools/reactor.d.ts.map +0 -1
  53. package/dist/src/tools/reactor.js +0 -458
  54. package/dist/src/tools/reactor.js.map +0 -1
  55. package/dist/src/tools/types.d.ts +0 -24
  56. package/dist/src/tools/types.d.ts.map +0 -1
  57. package/dist/src/tools/types.js +0 -2
  58. package/dist/src/tools/types.js.map +0 -1
  59. package/dist/src/tools/utils.d.ts +0 -23
  60. package/dist/src/tools/utils.d.ts.map +0 -1
  61. package/dist/src/tools/utils.js +0 -99
  62. package/dist/src/tools/utils.js.map +0 -1
  63. package/dist/test/reactor.test.d.ts +0 -2
  64. package/dist/test/reactor.test.d.ts.map +0 -1
  65. package/dist/test/reactor.test.js +0 -458
  66. package/dist/test/reactor.test.js.map +0 -1
  67. package/dist/test/setup-mcp-server.test.d.ts +0 -10
  68. package/dist/test/setup-mcp-server.test.d.ts.map +0 -1
  69. package/dist/test/setup-mcp-server.test.js +0 -172
  70. package/dist/test/setup-mcp-server.test.js.map +0 -1
  71. package/dist/tsconfig.tsbuildinfo +0 -1
  72. package/dist/vitest.config.d.ts +0 -3
  73. package/dist/vitest.config.d.ts.map +0 -1
  74. package/dist/vitest.config.js +0 -9
  75. package/dist/vitest.config.js.map +0 -1
@@ -1,458 +0,0 @@
1
- import { driveCollectionId } from "@powerhousedao/reactor";
2
- import { createAction } from "@powerhousedao/shared/document-model";
3
- import { z } from "zod";
4
- import { toolWithCallback, validateDocumentModelAction } from "./utils.js";
5
- const DRIVE_DOCUMENT_TYPE = "powerhouse/document-drive";
6
- export const createDocumentTool = {
7
- name: "createDocument",
8
- description: `Create a new document.
9
- 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.
10
- When "driveId" is provided, the document is created and added to the drive atomically — no separate "addActions" call with "ADD_FILE" is needed.`,
11
- inputSchema: {
12
- documentType: z.string().describe("Type of the document to create"),
13
- name: z
14
- .string()
15
- .optional()
16
- .describe("Optional name for the document. Used as both the document name and the drive node name when driveId is provided."),
17
- driveId: z
18
- .string()
19
- .optional()
20
- .describe("Optional drive ID or slug. When provided, the document is created and added to the drive atomically."),
21
- parentFolder: z
22
- .string()
23
- .optional()
24
- .describe("Optional folder ID within the drive to place the document in. Only used when driveId is provided."),
25
- },
26
- outputSchema: {
27
- documentId: z.string().describe("ID of the created document"),
28
- },
29
- };
30
- export const getDocumentTool = {
31
- name: "getDocument",
32
- description: "Retrieve a document by its ID",
33
- inputSchema: {
34
- id: z.string().describe("ID of the document to retrieve"),
35
- },
36
- outputSchema: {
37
- document: z.unknown().describe("The retrieved Document"),
38
- },
39
- };
40
- export const getDocumentsTool = {
41
- name: "getDocuments",
42
- description: "List documents in a drive",
43
- inputSchema: {
44
- parentId: z.string().describe("ID of the drive"),
45
- },
46
- outputSchema: {
47
- documentIds: z.array(z.string()).describe("Array of document IDs"),
48
- },
49
- };
50
- export const deleteDocumentTool = {
51
- name: "deleteDocument",
52
- description: "Delete a document",
53
- inputSchema: {
54
- documentId: z.string().describe("ID of the document to delete"),
55
- },
56
- outputSchema: {
57
- success: z.boolean().describe("Whether the deletion was successful"),
58
- },
59
- };
60
- export const addActionsTool = {
61
- name: "addActions",
62
- description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.",
63
- inputSchema: {
64
- documentId: z.string().describe("ID of the document"),
65
- actions: z
66
- .array(z
67
- .object({
68
- type: z.string().describe("The name of the action"),
69
- input: z.unknown().describe("The payload of the action"),
70
- scope: z.string().describe("The scope of the action"),
71
- context: z
72
- .record(z.string(), z.unknown())
73
- .optional()
74
- .describe("Optional action context"), // TODO: Define context schema
75
- })
76
- .strict())
77
- .describe("Action to add to the document"),
78
- },
79
- outputSchema: {
80
- success: z.boolean().describe("Whether the actions were added"),
81
- },
82
- };
83
- // export const addOperationTool = {
84
- // name: "addOperation",
85
- // description: "Add an operation to a document",
86
- // inputSchema: {
87
- // documentId: z.string().describe("ID of the document"),
88
- // operation: z
89
- // .object({
90
- // type: z.string().describe("The name of the action"),
91
- // input: z.unknown().describe("The payload of the action"),
92
- // scope: z.string().describe("The scope of the action"),
93
- // index: z.number().describe("Position of the operation in the history"),
94
- // timestampUtcMs: z
95
- // .string()
96
- // .describe("Timestamp of when the operation was added"),
97
- // hash: z.string().describe("Hash of the resulting document data"),
98
- // skip: z.number().describe("The number of operations skipped"),
99
- // error: z
100
- // .string()
101
- // .optional()
102
- // .describe("Error message for a failed action"),
103
- // id: z.string().optional().describe("Unique operation id"),
104
- // context: z.object({}).optional().describe("Optional action context"), // TODO: Define context schema
105
- // })
106
- // .strict()
107
- // .describe("Operation to add to the document"),
108
- // },
109
- // outputSchema: {
110
- // result: z
111
- // .object({
112
- // status: z
113
- // .enum(["SUCCESS", "CONFLICT", "MISSING", "ERROR"])
114
- // .describe("Operation status"),
115
- // error: z
116
- // .string()
117
- // .optional()
118
- // .describe("Error details if operation failed"), // TODO: Define error schema
119
- // operations: z
120
- // .array(z.object({}))
121
- // .describe("Array of operations created"), // TODO: Define operation schema
122
- // document: z.object({}).optional().describe("Updated document"), // TODO: Define document schema
123
- // signals: z.array(z.object({})).describe("Array of signals generated"), // TODO: Define signal schema
124
- // })
125
- // .describe("Operation result"),
126
- // },
127
- // } as const satisfies ToolSchema;
128
- // Drive Operation Tools
129
- export const getDrivesTool = {
130
- name: "getDrives",
131
- description: "List all drives",
132
- inputSchema: {},
133
- outputSchema: {
134
- driveIds: z.array(z.string()).describe("Array of drive IDs"),
135
- },
136
- };
137
- export const addDriveTool = {
138
- name: "addDrive",
139
- description: "Create a new drive",
140
- inputSchema: {
141
- driveInput: z
142
- .object({
143
- global: z
144
- .object({
145
- name: z.string().describe("Name of the drive"),
146
- icon: z
147
- .string()
148
- .nullable()
149
- .optional()
150
- .describe("Optional icon for the drive"),
151
- })
152
- .describe("Global drive properties"),
153
- id: z.string().optional().describe("Optional drive ID"),
154
- slug: z.string().optional().describe("Optional drive slug"),
155
- preferredEditor: z
156
- .string()
157
- .optional()
158
- .describe("Optional preferred editor"),
159
- local: z
160
- .object({
161
- availableOffline: z
162
- .boolean()
163
- .optional()
164
- .describe("Whether drive is available offline"),
165
- sharingType: z
166
- .string()
167
- .nullable()
168
- .optional()
169
- .describe("Sharing type"),
170
- })
171
- .optional()
172
- .describe("Optional local state properties"),
173
- })
174
- .describe("Drive configuration"),
175
- },
176
- outputSchema: {
177
- driveId: z.string().describe("ID of the created drive"),
178
- },
179
- };
180
- export const getDriveTool = {
181
- name: "getDrive",
182
- description: "Get a specific drive",
183
- inputSchema: {
184
- driveId: z.string().describe("ID of the drive to retrieve"),
185
- options: z
186
- .object({
187
- revisions: z
188
- .record(z.string(), z.number())
189
- .optional()
190
- .describe("Optional revision filter"),
191
- checkHashes: z.boolean().optional().describe("Whether to check hashes"),
192
- // TODO: Add other ReducerOptions if needed
193
- })
194
- .optional()
195
- .describe("Optional get document options"),
196
- },
197
- outputSchema: {
198
- drive: z.unknown().describe("Drive document"), // TODO: Define DocumentDriveDocument schema
199
- },
200
- };
201
- export const deleteDriveTool = {
202
- name: "deleteDrive",
203
- description: "Delete a drive",
204
- inputSchema: {
205
- driveId: z.string().describe("ID of the drive to delete"),
206
- },
207
- outputSchema: {
208
- success: z.boolean().describe("Whether the deletion was successful"),
209
- },
210
- };
211
- export const addRemoteDriveTool = {
212
- name: "addRemoteDrive",
213
- description: "Connect to a remote drive",
214
- inputSchema: {
215
- url: z.string().describe("URL of the remote drive"),
216
- options: z
217
- .object({
218
- availableOffline: z
219
- .boolean()
220
- .describe("Whether drive is available offline"),
221
- sharingType: z.string().nullable().optional().describe("Sharing type"),
222
- pullFilter: z
223
- .object({
224
- branch: z
225
- .array(z.string())
226
- .nullable()
227
- .optional()
228
- .describe("Branch filter"),
229
- documentId: z
230
- .array(z.string())
231
- .nullable()
232
- .optional()
233
- .describe("Document ID filter"),
234
- documentType: z
235
- .array(z.string())
236
- .nullable()
237
- .optional()
238
- .describe("Document type filter"),
239
- scope: z
240
- .array(z.string())
241
- .nullable()
242
- .optional()
243
- .describe("Scope filter"),
244
- })
245
- .optional()
246
- .describe("Optional pull filter"),
247
- pullInterval: z
248
- .number()
249
- .optional()
250
- .describe("Pull interval in milliseconds"),
251
- })
252
- .describe("Remote drive options"),
253
- },
254
- outputSchema: {
255
- driveId: z.string().describe("ID of the added remote drive"),
256
- },
257
- };
258
- export const getDocumentModelSchemaTool = {
259
- name: "getDocumentModelSchema",
260
- description: "Get the schema of a document model",
261
- inputSchema: {
262
- type: z.string().describe("Type of the document model"),
263
- },
264
- outputSchema: {
265
- schema: z.unknown().describe("Schema of the document model"),
266
- },
267
- };
268
- export const getDocumentModelsTool = {
269
- name: "getDocumentModels",
270
- description: "Get the list of document models",
271
- inputSchema: {},
272
- outputSchema: {
273
- documentModels: z
274
- .array(z.object({
275
- name: z.string().describe("Name of the document model"),
276
- type: z.string().describe("Type of the document model"),
277
- description: z.string().describe("Description of the document model"),
278
- extension: z.string().describe("Extension of the document model"),
279
- authorName: z.string().describe("Author name of the document model"),
280
- authorWebsite: z
281
- .string()
282
- .describe("Author website of the document model"),
283
- }))
284
- .describe("List of available document models"),
285
- },
286
- };
287
- // All tools array for type inference
288
- const allTools = [
289
- getDocumentTool,
290
- createDocumentTool,
291
- getDocumentsTool,
292
- deleteDocumentTool,
293
- addActionsTool,
294
- // addOperationTool,
295
- getDrivesTool,
296
- addDriveTool,
297
- getDriveTool,
298
- deleteDriveTool,
299
- addRemoteDriveTool,
300
- getDocumentModelSchemaTool,
301
- getDocumentModelsTool,
302
- ];
303
- export async function createReactorMcpProvider(options) {
304
- const { client, syncManager } = options;
305
- // No initialization needed - client is already initialized
306
- async function getDocumentModelModule(documentType) {
307
- return client.getDocumentModelModule(documentType);
308
- }
309
- const tools = {
310
- getDocument: toolWithCallback(getDocumentTool, async (params) => {
311
- const document = await client.get(params.id);
312
- return { document: { header: document.header, state: document.state } };
313
- }),
314
- createDocument: toolWithCallback(createDocumentTool, async (params) => {
315
- if (params.driveId) {
316
- const module = await getDocumentModelModule(params.documentType);
317
- if (!module) {
318
- throw new Error(`Document model for type '${params.documentType}' not found`);
319
- }
320
- const document = module.utils.createDocument();
321
- if (params.name) {
322
- document.header.name = params.name;
323
- }
324
- const created = await client.createDocumentInDrive(params.driveId, document, params.parentFolder);
325
- return { documentId: created.header.id };
326
- }
327
- const created = await client.createEmpty(params.documentType, {});
328
- return { documentId: created.header.id };
329
- }),
330
- getDocuments: toolWithCallback(getDocumentsTool, async (params) => {
331
- // Use getChildren to get documents under a parent (drive)
332
- const result = await client.getChildren(params.parentId);
333
- const documentIds = result.results.map((doc) => doc.header.id);
334
- return { documentIds };
335
- }),
336
- deleteDocument: toolWithCallback(deleteDocumentTool, async (params) => {
337
- try {
338
- await client.deleteDocument(params.documentId);
339
- return { success: true };
340
- }
341
- catch {
342
- return { success: false };
343
- }
344
- }),
345
- addActions: toolWithCallback(addActionsTool, async (params) => {
346
- const document = await client.get(params.documentId);
347
- const documentModel = await getDocumentModelModule(document.header.documentType);
348
- if (!documentModel) {
349
- throw new Error(`Document model for document type '${document.header.documentType}' not found`);
350
- }
351
- const actions = params.actions.map((paramAction) => {
352
- const action = createAction(paramAction.type, paramAction.input ?? {}, undefined, undefined, paramAction.scope);
353
- const actionValidation = validateDocumentModelAction(documentModel, action);
354
- if (!actionValidation.isValid) {
355
- throw new Error(`Invalid action ${JSON.stringify(action)}: ${actionValidation.errors.join(", ")}`);
356
- }
357
- return action;
358
- });
359
- // Execute actions on the document using the "main" branch
360
- await client.execute(params.documentId, "main", actions);
361
- return {
362
- success: true,
363
- };
364
- }),
365
- // Drive operation implementations
366
- getDrives: toolWithCallback(getDrivesTool, async () => {
367
- // Find all documents of type "powerhouse/document-drive"
368
- const result = await client.find({ type: DRIVE_DOCUMENT_TYPE });
369
- const driveIds = result.results.map((doc) => doc.header.id);
370
- return { driveIds };
371
- }),
372
- addDrive: toolWithCallback(addDriveTool, async (params) => {
373
- // Create an empty drive document
374
- const drive = await client.createEmpty(DRIVE_DOCUMENT_TYPE, {});
375
- // If name is provided, set it using an action
376
- if (params.driveInput.global?.name) {
377
- await client.rename(drive.header.id, params.driveInput.global.name);
378
- }
379
- return { driveId: drive.header.id };
380
- }),
381
- getDrive: toolWithCallback(getDriveTool, async (params) => {
382
- const drive = await client.get(params.driveId);
383
- return { drive: { header: drive.header, state: drive.state } };
384
- }),
385
- deleteDrive: toolWithCallback(deleteDriveTool, async (params) => {
386
- try {
387
- // Use CASCADE to delete the drive and all its contents
388
- await client.deleteDocument(params.driveId);
389
- return { success: true };
390
- }
391
- catch {
392
- return { success: false };
393
- }
394
- }),
395
- addRemoteDrive: toolWithCallback(addRemoteDriveTool, async (params) => {
396
- if (!syncManager) {
397
- throw new Error("Remote drive management is not available. " +
398
- "SyncManager was not configured for this MCP server.");
399
- }
400
- // Fetch drive info from the REST endpoint to get both id and graphqlEndpoint
401
- const response = await fetch(params.url);
402
- if (!response.ok) {
403
- throw new Error(`Failed to resolve drive info from ${params.url}`);
404
- }
405
- const driveInfo = (await response.json());
406
- const resolvedDriveId = driveInfo.id;
407
- const collectionId = driveCollectionId("main", resolvedDriveId);
408
- // Check if remote already exists
409
- const existingRemote = syncManager
410
- .list()
411
- .find((remote) => remote.collectionId === collectionId);
412
- if (existingRemote) {
413
- return { driveId: resolvedDriveId };
414
- }
415
- // Add the remote via SyncManager
416
- const remoteName = `mcp-remote-${crypto.randomUUID()}`;
417
- await syncManager.add(remoteName, collectionId, {
418
- type: "gql",
419
- parameters: {
420
- url: driveInfo.graphqlEndpoint,
421
- },
422
- });
423
- return { driveId: resolvedDriveId };
424
- }),
425
- getDocumentModels: toolWithCallback(getDocumentModelsTool, async () => {
426
- const result = await client.getDocumentModelModules();
427
- return {
428
- documentModels: result.results.map((model) => {
429
- const schemaGlobal = model.documentModel.global;
430
- return {
431
- name: schemaGlobal.name,
432
- type: schemaGlobal.id,
433
- description: schemaGlobal.description,
434
- extension: schemaGlobal.extension,
435
- authorName: schemaGlobal.author.name,
436
- authorWebsite: schemaGlobal.author.website ?? "",
437
- };
438
- }),
439
- };
440
- }),
441
- getDocumentModelSchema: toolWithCallback(getDocumentModelSchemaTool, async (params) => {
442
- const documentModel = await getDocumentModelModule(params.type);
443
- const schema = documentModel?.documentModel.global;
444
- if (!schema) {
445
- throw new Error(`Document model '${params.type}' not found`);
446
- }
447
- return { schema };
448
- }),
449
- };
450
- const resources = {};
451
- const prompts = {};
452
- return {
453
- tools,
454
- resources,
455
- prompts,
456
- };
457
- }
458
- //# sourceMappingURL=reactor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactor.js","sourceRoot":"","sources":["../../../src/tools/reactor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAO3D,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAOxD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE;;sJAEuI;IACpJ,WAAW,EAAE;QACX,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;QACnE,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR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pB,CAAC,CACF;KACO,CAAC;IAEX,MAAM,SAAS,GAAG,EAAE,CAAC;IAErB,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,OAAO;QACL,KAAK;QACL,SAAS;QACT,OAAO;KACC,CAAC;AACb,CAAC"}
@@ -1,24 +0,0 @@
1
- import type { ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import type { Prompt, Resource, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
3
- import type { z, ZodRawShape } from "zod";
4
- export type ExtractCallbackFromTool<T extends ToolSchema> = T extends {
5
- inputSchema: infer S;
6
- } ? ToolCallback<S extends ZodRawShape ? S : undefined> : ToolCallback;
7
- export type ToolWithCallback<T extends ToolSchema = ToolSchema> = T & {
8
- callback: ExtractCallbackFromTool<T>;
9
- };
10
- export type ToolSchema<InputArgs extends ZodRawShape = ZodRawShape, OutputArgs extends ZodRawShape = ZodRawShape> = {
11
- name: string;
12
- title?: string;
13
- description?: string;
14
- inputSchema?: InputArgs;
15
- outputSchema?: OutputArgs;
16
- annotations?: ToolAnnotations;
17
- };
18
- export type ResolveZodSchema<T> = T extends z.ZodRawShape ? z.infer<z.ZodObject<T>> : T;
19
- export interface IMcpProvider<T extends ToolWithCallback = ToolWithCallback, R extends Resource = Resource, P extends Prompt = Prompt> {
20
- tools: Record<T["name"], ToolWithCallback<T>>;
21
- resources: Record<R["name"], R>;
22
- prompts: Record<P["name"], P>;
23
- }
24
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,KAAK,EACV,MAAM,EACN,QAAQ,EACR,eAAe,EAChB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAE1C,MAAM,MAAM,u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0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/tools/types.ts"],"names":[],"mappings":""}
@@ -1,23 +0,0 @@
1
- import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
- import type { Action, DocumentModelModule } from "@powerhousedao/shared/document-model";
3
- import type { z } from "zod";
4
- import type { ResolveZodSchema, ToolSchema } from "./types.js";
5
- export declare class InvalidToolOutputError extends Error {
6
- constructor(zodError: z.ZodError);
7
- }
8
- /**
9
- * Creates a tool with a callback function that handles the tool execution,
10
- * ensuring the output is valid and errors are handled and returned correctly.
11
- * @param tool The tool schema to wrap.
12
- * @param toolCallback The callback function to execute when the tool is called.
13
- * @returns A CallToolResult with structuredContent if OutputSchema is defined or content if undefined. If the
14
- * callback throws an error, the result will have isError set to true and the error message in the content.
15
- */
16
- export declare function toolWithCallback<T extends ToolSchema>(tool: T, toolCallback: (args: ResolveZodSchema<T["inputSchema"]>) => ResolveZodSchema<T["outputSchema"]> | Promise<ResolveZodSchema<T["outputSchema"]>>): T & {
17
- callback: (args: ResolveZodSchema<T["inputSchema"]>) => Promise<CallToolResult>;
18
- };
19
- export declare function validateDocumentModelAction(documentModelModule: DocumentModelModule, action: Action): {
20
- isValid: boolean;
21
- errors: string[];
22
- };
23
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EAEpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,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,CAsExC"}
@@ -1,99 +0,0 @@
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
- }
9
- /**
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.
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
- }
49
- export function validateDocumentModelAction(documentModelModule, action) {
50
- const errors = [];
51
- const globalState = documentModelModule.documentModel.global;
52
- // Get the latest specification
53
- if (!globalState.specifications || globalState.specifications.length === 0) {
54
- errors.push("Document model has no specifications");
55
- return { isValid: false, errors };
56
- }
57
- const latestSpec = globalState.specifications[globalState.specifications.length - 1];
58
- // Search through modules to find the operation that matches the action type (in SCREAMING_SNAKE_CASE)
59
- let operation = null;
60
- for (const module of latestSpec.modules) {
61
- const unsafeOperationOrActionOrSomething = module.operations.find((op) => op.name === action.type);
62
- if (unsafeOperationOrActionOrSomething) {
63
- operation = unsafeOperationOrActionOrSomething;
64
- break;
65
- }
66
- }
67
- if (!operation) {
68
- errors.push(`Operation "${action.type}" is not defined in any module of the document model`);
69
- return { isValid: false, errors };
70
- }
71
- // Convert action type from SCREAMING_SNAKE_CASE to camelCase to match action creators
72
- const camelCaseActionType = camelCase(action.type);
73
- // Check if action creator exists in documentModelModule.actions
74
- const actionCreator = documentModelModule.actions[camelCaseActionType];
75
- if (!actionCreator) {
76
- errors.push(`Action creator "${camelCaseActionType}" for action type "${action.type}" is not defined in documentModelDocumentModelModule.actions`);
77
- return { isValid: false, errors };
78
- }
79
- // Validate the operation using the action creator. TODO: Use document model exported validators directly
80
- let inputError = null;
81
- try {
82
- actionCreator(action.input);
83
- }
84
- catch (e) {
85
- inputError = e instanceof Error ? e : new Error(JSON.stringify(e));
86
- }
87
- if (inputError) {
88
- errors.push(`Input validation error: ${inputError.message}`);
89
- }
90
- // Validate scope if operation defines one
91
- if (operation.scope && action.scope !== operation.scope) {
92
- errors.push(`Action scope "${action.scope}" does not match operation scope "${operation.scope}"`);
93
- }
94
- return {
95
- isValid: errors.length === 0,
96
- errors,
97
- };
98
- }
99
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","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,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACpC,CAAC;IAED,yGAAyG;IACzG,IAAI,UAAU,GAAiB,IAAI,CAAC;IACpC,IAAI,CAAC;QACH,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,UAAU,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,2BAA2B,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,0CAA0C;IAC1C,IAAI,SAAS,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK,EAAE,CAAC;QACxD,MAAM,CAAC,IAAI,CACT,iBAAiB,MAAM,CAAC,KAAK,qCAAqC,SAAS,CAAC,KAAK,GAAG,CACrF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC5B,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=reactor.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactor.test.d.ts","sourceRoot":"","sources":["../../test/reactor.test.ts"],"names":[],"mappings":""}