@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.
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +137 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.mts +637 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +46 -0
- package/dist/index.mjs.map +1 -0
- package/dist/server-DlxQXYHz.mjs +389 -0
- package/dist/server-DlxQXYHz.mjs.map +1 -0
- package/package.json +16 -9
- package/dist/src/cli.d.ts +0 -2
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -10
- package/dist/src/cli.js.map +0 -1
- package/dist/src/feature-flags.d.ts +0 -2
- package/dist/src/feature-flags.d.ts.map +0 -1
- package/dist/src/feature-flags.js +0 -9
- package/dist/src/feature-flags.js.map +0 -1
- package/dist/src/index.d.ts +0 -5
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -5
- package/dist/src/index.js.map +0 -1
- package/dist/src/logger.d.ts +0 -3
- package/dist/src/logger.d.ts.map +0 -1
- package/dist/src/logger.js +0 -3
- package/dist/src/logger.js.map +0 -1
- package/dist/src/mcp-routes.d.ts +0 -19
- package/dist/src/mcp-routes.d.ts.map +0 -1
- package/dist/src/mcp-routes.js +0 -50
- package/dist/src/mcp-routes.js.map +0 -1
- package/dist/src/sdk/chat.d.ts +0 -19
- package/dist/src/sdk/chat.d.ts.map +0 -1
- package/dist/src/sdk/chat.js +0 -60
- package/dist/src/sdk/chat.js.map +0 -1
- package/dist/src/server.d.ts +0 -9
- package/dist/src/server.d.ts.map +0 -1
- package/dist/src/server.js +0 -59
- package/dist/src/server.js.map +0 -1
- package/dist/src/stdio/index.d.ts +0 -7
- package/dist/src/stdio/index.d.ts.map +0 -1
- package/dist/src/stdio/index.js +0 -64
- package/dist/src/stdio/index.js.map +0 -1
- package/dist/src/stdio/loader.d.ts +0 -19
- package/dist/src/stdio/loader.d.ts.map +0 -1
- package/dist/src/stdio/loader.js +0 -90
- package/dist/src/stdio/loader.js.map +0 -1
- package/dist/src/tools/index.d.ts +0 -3
- package/dist/src/tools/index.d.ts.map +0 -1
- package/dist/src/tools/index.js +0 -3
- package/dist/src/tools/index.js.map +0 -1
- package/dist/src/tools/reactor.d.ts +0 -567
- package/dist/src/tools/reactor.d.ts.map +0 -1
- package/dist/src/tools/reactor.js +0 -458
- package/dist/src/tools/reactor.js.map +0 -1
- package/dist/src/tools/types.d.ts +0 -24
- package/dist/src/tools/types.d.ts.map +0 -1
- package/dist/src/tools/types.js +0 -2
- package/dist/src/tools/types.js.map +0 -1
- package/dist/src/tools/utils.d.ts +0 -23
- package/dist/src/tools/utils.d.ts.map +0 -1
- package/dist/src/tools/utils.js +0 -99
- package/dist/src/tools/utils.js.map +0 -1
- package/dist/test/reactor.test.d.ts +0 -2
- package/dist/test/reactor.test.d.ts.map +0 -1
- package/dist/test/reactor.test.js +0 -458
- package/dist/test/reactor.test.js.map +0 -1
- package/dist/test/setup-mcp-server.test.d.ts +0 -10
- package/dist/test/setup-mcp-server.test.d.ts.map +0 -1
- package/dist/test/setup-mcp-server.test.js +0 -172
- package/dist/test/setup-mcp-server.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -9
- package/dist/vitest.config.js.map +0 -1
package/dist/src/mcp-routes.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
3
|
-
import type { IReactorClient, ISyncManager } from "@powerhousedao/reactor";
|
|
4
|
-
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
5
|
-
/** Minimal interface for an HTTP adapter that supports Node.js-style route handlers. */
|
|
6
|
-
interface NodeRouteAdapter {
|
|
7
|
-
mountNodeRoute(method: "DELETE" | "GET" | "POST", path: string, handler: (req: IncomingMessage, res: ServerResponse, body?: unknown) => void): void;
|
|
8
|
-
}
|
|
9
|
-
export interface SetupMcpServerOptions {
|
|
10
|
-
client: IReactorClient;
|
|
11
|
-
syncManager?: ISyncManager;
|
|
12
|
-
}
|
|
13
|
-
/** @internal Injected in tests to avoid relying on constructor mock semantics. */
|
|
14
|
-
type TransportFactory = (opts: {
|
|
15
|
-
sessionIdGenerator: undefined;
|
|
16
|
-
}) => InstanceType<typeof StreamableHTTPServerTransport>;
|
|
17
|
-
export declare function setupMcpServer(options: SetupMcpServerOptions, httpAdapter: NodeRouteAdapter, createTransport?: TransportFactory): Promise<McpServer>;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=mcp-routes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-routes.d.ts","sourceRoot":"","sources":["../../src/mcp-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,wFAAwF;AACxF,UAAU,gBAAgB;IACxB,cAAc,CACZ,MAAM,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,EACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CACP,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,CAAC,EAAE,OAAO,KACX,IAAI,GACR,IAAI,CAAC;CACT;AAID,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,cAAc,CAAC;IACvB,WAAW,CAAC,EAAE,YAAY,CAAC;CAC5B;AAQD,kFAAkF;AAClF,KAAK,gBAAgB,GAAG,CAAC,IAAI,EAAE;IAC7B,kBAAkB,EAAE,SAAS,CAAC;CAC/B,KAAK,YAAY,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEzD,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,EAC9B,WAAW,EAAE,gBAAgB,EAG7B,eAAe,GAAE,gBACwB,GACxC,OAAO,CAAC,SAAS,CAAC,CAsDpB"}
|
package/dist/src/mcp-routes.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
2
|
-
import { logger } from "./logger.js";
|
|
3
|
-
import { createServer } from "./server.js";
|
|
4
|
-
const METHOD_NOT_ALLOWED = JSON.stringify({
|
|
5
|
-
jsonrpc: "2.0",
|
|
6
|
-
error: { code: -32000, message: "Method not allowed." },
|
|
7
|
-
id: null,
|
|
8
|
-
});
|
|
9
|
-
export async function setupMcpServer(options, httpAdapter,
|
|
10
|
-
// Allow tests to inject a factory function instead of relying on `new vi.fn()`
|
|
11
|
-
// constructor semantics, which differ between macOS and Linux environments.
|
|
12
|
-
createTransport = (opts) => new StreamableHTTPServerTransport(opts)) {
|
|
13
|
-
const server = await createServer(options);
|
|
14
|
-
httpAdapter.mountNodeRoute("POST", "/mcp", (req, res, body) => {
|
|
15
|
-
// In stateless mode, create a new instance of transport and server for each
|
|
16
|
-
// request to ensure complete isolation. A single instance would cause request
|
|
17
|
-
// ID collisions when multiple clients connect concurrently.
|
|
18
|
-
try {
|
|
19
|
-
const transport = createTransport({
|
|
20
|
-
sessionIdGenerator: undefined,
|
|
21
|
-
});
|
|
22
|
-
res.on("close", () => {
|
|
23
|
-
void transport.close();
|
|
24
|
-
void server.close();
|
|
25
|
-
});
|
|
26
|
-
void server.connect(transport);
|
|
27
|
-
void transport.handleRequest(req, res, body);
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
logger.error("Error handling MCP request:", error);
|
|
31
|
-
if (!res.headersSent) {
|
|
32
|
-
res.writeHead(500, { "Content-Type": "application/json" }).end(JSON.stringify({
|
|
33
|
-
jsonrpc: "2.0",
|
|
34
|
-
error: { code: -32603, message: "Internal server error" },
|
|
35
|
-
id: null,
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
// SSE notifications not supported in stateless mode
|
|
41
|
-
httpAdapter.mountNodeRoute("GET", "/mcp", (_req, res) => {
|
|
42
|
-
res.writeHead(405).end(METHOD_NOT_ALLOWED);
|
|
43
|
-
});
|
|
44
|
-
// Session termination not needed in stateless mode
|
|
45
|
-
httpAdapter.mountNodeRoute("DELETE", "/mcp", (_req, res) => {
|
|
46
|
-
res.writeHead(405).end(METHOD_NOT_ALLOWED);
|
|
47
|
-
});
|
|
48
|
-
return server;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=mcp-routes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-routes.js","sourceRoot":"","sources":["../../src/mcp-routes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAgBnG,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC;IACxC,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,qBAAqB,EAAE;IACvD,EAAE,EAAE,IAAI;CACT,CAAC,CAAC;AAOH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAA8B,EAC9B,WAA6B;AAC7B,+EAA+E;AAC/E,4EAA4E;AAC5E,kBAAoC,CAAC,IAAI,EAAE,EAAE,CAC3C,IAAI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AC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC7C,CAAC,CACF,CAAC;IAEF,mDAAmD;IACnD,WAAW,CAAC,cAAc,CACxB,QAAQ,EACR,MAAM,EACN,CAAC,IAAqB,EAAE,GAAmB,EAAE,EAAE;QAC7C,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC7C,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/src/sdk/chat.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Provider } from "ai";
|
|
2
|
-
export interface ChatMessage {
|
|
3
|
-
role: "user" | "assistant" | "system";
|
|
4
|
-
content: string;
|
|
5
|
-
}
|
|
6
|
-
export interface ChatOptions {
|
|
7
|
-
provider?: Provider;
|
|
8
|
-
model?: string;
|
|
9
|
-
systemPrompt?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare class LLMChat {
|
|
12
|
-
private provider;
|
|
13
|
-
private model;
|
|
14
|
-
private systemPrompt;
|
|
15
|
-
constructor(options?: ChatOptions);
|
|
16
|
-
sendMessage(messages: ChatMessage[]): Promise<string>;
|
|
17
|
-
streamMessage(messages: ChatMessage[], onChunk: (chunk: string) => void): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { streamText } from "ai";
|
|
3
|
-
import { logger } from "../logger.js";
|
|
4
|
-
export class LLMChat {
|
|
5
|
-
provider;
|
|
6
|
-
model;
|
|
7
|
-
systemPrompt;
|
|
8
|
-
constructor(options = {}) {
|
|
9
|
-
this.provider =
|
|
10
|
-
options.provider ||
|
|
11
|
-
createOpenAI({
|
|
12
|
-
apiKey: process.env.OPENAI_API_KEY || "",
|
|
13
|
-
});
|
|
14
|
-
this.model = options.model || "gpt-4-turbo";
|
|
15
|
-
this.systemPrompt = options.systemPrompt || "You are a helpful assistant.";
|
|
16
|
-
}
|
|
17
|
-
async sendMessage(messages) {
|
|
18
|
-
try {
|
|
19
|
-
const coreMessages = messages.map((msg) => ({
|
|
20
|
-
role: msg.role,
|
|
21
|
-
content: msg.content,
|
|
22
|
-
}));
|
|
23
|
-
const result = streamText({
|
|
24
|
-
model: this.provider.languageModel(this.model),
|
|
25
|
-
system: this.systemPrompt,
|
|
26
|
-
messages: coreMessages,
|
|
27
|
-
});
|
|
28
|
-
let fullResponse = "";
|
|
29
|
-
for await (const textPart of result.textStream) {
|
|
30
|
-
fullResponse += textPart;
|
|
31
|
-
}
|
|
32
|
-
return fullResponse;
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
logger.error("Error sending message to LLM:", error);
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async streamMessage(messages, onChunk) {
|
|
40
|
-
try {
|
|
41
|
-
const coreMessages = messages.map((msg) => ({
|
|
42
|
-
role: msg.role,
|
|
43
|
-
content: msg.content,
|
|
44
|
-
}));
|
|
45
|
-
const result = streamText({
|
|
46
|
-
model: this.provider.languageModel(this.model),
|
|
47
|
-
system: this.systemPrompt,
|
|
48
|
-
messages: coreMessages,
|
|
49
|
-
});
|
|
50
|
-
for await (const textPart of result.textStream) {
|
|
51
|
-
onChunk(textPart);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
logger.error("Error streaming message from LLM:", error);
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=chat.js.map
|
package/dist/src/sdk/chat.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,a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gBAC9C,MAAM,EAAE,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
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type { IReactorClient, ISyncManager } from "@powerhousedao/reactor";
|
|
3
|
-
export interface CreateServerOptions {
|
|
4
|
-
client: IReactorClient;
|
|
5
|
-
syncManager?: ISyncManager;
|
|
6
|
-
}
|
|
7
|
-
export declare const ReactorMcpInstructions = "MUST BE USED when handling documents or document-models for the Powerhouse/Vetra ecosystem.\nThere are 5 main concepts to know of: \n- Document Model: A template for creating documents. It defines the schema and allowed operations for a type of document.\n- Document: An instance of a document model. It contains actual data following the structure defined by the document model and can be changed using operations.\n- Drive: A document of type \"powerhouse/document-drive\" which represents a collection of documents and folders. To create a document inside a drive, use the \"createDocument\" tool with the \"driveId\" parameter \u2014 this handles everything atomically. Use \"addActions\" with \"ADD_FILE\" only when adding an existing document to a drive.\n- Action: A proposed change to a document. It is a JSON object with the action name and input that defines the action to be taken on the document. Should be dispatched by calling the \"addActions\" tool.\n- Operation: A change done to a document. It contains the action object plus additional metadata such as the index of the operation in the document history, the timestamp it was added, the hash of the resulting document data, the number of operations skipped, and the error message if the operation failed. Actions dispatched with \"addActions\" get converted into an operation.\n\nWhen planning to add multiple actions to a document, try to reduce the number of \"addActions\" calls to a minimum by adding multiple actions at once.\nUnless the user specifies otherwise, and a drive with slug \"vetra\" is available, create new documents inside it by passing its ID as the \"driveId\" parameter to \"createDocument\".\n\nExamples:\n<example>Context: User needs to create a new document model for their application. user: 'I need to create a user profile document model with fields for name, email, and preferences' assistant: 'I'll use the reactor-mcp-server to help you create this document model.' <commentary>Since the user is requesting document model creation, use the reactor-mcp-document-expert agent to ensure proper reactor-mcp tool usage.</commentary></example> <example>Context: User is building a content management system and needs create documents for certain types of document models. user: 'Can you help me create example documents for blog posts and categories document models?' assistant: 'Let me use the reactor-mcp-server to create these documents using the appropriate reactor-mcp tool calls.' <commentary>Document model creation requires the reactor-mcp-server tool calls to ensure compliance.</commentary></example>\n<example>Context: User needs to create a new document instance of a given document model. user: 'I need to create a demo user profile document' assistant: 'I'll use the reactor-mcp-server to help you create this document with example values.' <commentary>Since the user is requesting document model creation, use the reactor-mcp-document-expert agent to ensure proper reactor-mcp tool usage.</commentary></example> <example>Context: User is building a content management system and needs create documents for certain types of document models. user: 'Can you help me create example documents for blog posts and categories document models?' assistant: 'Let me use the reactor-mcp-server to create these documents using the appropriate reactor-mcp tool calls.' <commentary>Document creation requires the reactor-mcp-server tool calls to ensure compliance.</commentary></example>\n";
|
|
8
|
-
export declare function createServer(options: CreateServerOptions): Promise<McpServer>;
|
|
9
|
-
//# sourceMappingURL=server.d.ts.map
|
package/dist/src/server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3E,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,cAAc,CAAC;IACvB,WAAW,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,eAAO,MAAM,sBAAsB,i6GAclC,CAAC;AAEF,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,SAAS,CAAC,CAsDpB"}
|
package/dist/src/server.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { createReactorMcpProvider } from "./tools/reactor.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 create a document inside a drive, use the "createDocument" tool with the "driveId" parameter — this handles everything atomically. Use "addActions" with "ADD_FILE" only when adding an existing document to a drive.
|
|
8
|
-
- 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, create new documents inside it by passing its ID as the "driveId" parameter to "createDocument".
|
|
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
|
-
`;
|
|
18
|
-
export async function createServer(options) {
|
|
19
|
-
const { client, syncManager } = options;
|
|
20
|
-
const server = new McpServer({
|
|
21
|
-
name: "reactor-mcp-server",
|
|
22
|
-
version: "1.0.0",
|
|
23
|
-
description: ReactorMcpInstructions,
|
|
24
|
-
}, {
|
|
25
|
-
capabilities: {
|
|
26
|
-
tools: {},
|
|
27
|
-
resources: {
|
|
28
|
-
subscribe: true,
|
|
29
|
-
listChanged: true,
|
|
30
|
-
},
|
|
31
|
-
prompts: {
|
|
32
|
-
listChanged: true,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
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
|
-
}));
|
|
48
|
-
const reactorProvider = await createReactorMcpProvider({
|
|
49
|
-
client,
|
|
50
|
-
syncManager,
|
|
51
|
-
});
|
|
52
|
-
const { callback, ...toolSchema } = reactorProvider.tools.getDocumentModels;
|
|
53
|
-
// server.registerTool("getDocumentModels", toolSchema, callback);
|
|
54
|
-
Object.entries(reactorProvider.tools).forEach(([toolName, { callback, ...schema }]) => {
|
|
55
|
-
server.registerTool(toolName, schema, callback);
|
|
56
|
-
});
|
|
57
|
-
return server;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=server.js.map
|
package/dist/src/server.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAO9D,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;CAcrC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAA4B;IAE5B,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,sBAAsB;KACpC,EACD;QACE,YAAY,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,SAAS,EAAE;gBACT,SAAS,EAAE,IAAI;gBACf,WAAW,EAAE,IAAI;aAClB;YACD,OAAO,EAAE;gBACP,WAAW,EAAE,IAAI;aAClB;SACF;KACF,CACF,CAAC;IAEF,MAAM,CAAC,gBAAgB,CACrB,cAAc,EACd,wBAAwB,EACxB;QACE,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,0DAA0D;QACvE,QAAQ,EAAE,YAAY;KACvB,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACR,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,GAAG,CAAC,IAAI;gBACb,IAAI,EAAE,sBAAsB;aAC7B;SACF;KACF,CAAC,CACH,CAAC;IAEF,MAAM,eAAe,GAAG,MAAM,wBAAwB,CAAC;QACrD,MAAM;QACN,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAC5E,kEAAkE;IAClE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,OAAO,CAC3C,CAAC,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAa,EAAE,QAAe,CAAC,CAAC;IAChE,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stdio/index.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAmBD,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE,WAAW,iBAgE7D"}
|
package/dist/src/stdio/index.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
2
|
-
import { ReactorBuilder, ReactorClientBuilder } from "@powerhousedao/reactor";
|
|
3
|
-
import { driveDocumentModelModule } from "@powerhousedao/shared/document-drive";
|
|
4
|
-
import { documentModelDocumentModelModule } from "document-model";
|
|
5
|
-
import { initFeatureFlags } from "../feature-flags.js";
|
|
6
|
-
import { logger } from "../logger.js";
|
|
7
|
-
import { createServer } from "../server.js";
|
|
8
|
-
import { VitePackageLoader } from "./loader.js";
|
|
9
|
-
const baseDocumentModels = [
|
|
10
|
-
documentModelDocumentModelModule,
|
|
11
|
-
driveDocumentModelModule,
|
|
12
|
-
];
|
|
13
|
-
async function createReactorClient(documentModels) {
|
|
14
|
-
const reactorBuilder = new ReactorBuilder().withDocumentModels(baseDocumentModels.concat(documentModels));
|
|
15
|
-
const module = await new ReactorClientBuilder()
|
|
16
|
-
.withReactorBuilder(reactorBuilder)
|
|
17
|
-
.buildModule();
|
|
18
|
-
return module;
|
|
19
|
-
}
|
|
20
|
-
export async function initStdioMcpServer(options) {
|
|
21
|
-
const { remoteDrive, root, documentModelsDir = "./document-models", } = options ?? {};
|
|
22
|
-
// initialize feature flags
|
|
23
|
-
await initFeatureFlags();
|
|
24
|
-
// if root of project is passed then loads local document models
|
|
25
|
-
let documentModelsLoader;
|
|
26
|
-
const documentModels = [];
|
|
27
|
-
if (root) {
|
|
28
|
-
documentModelsLoader = new VitePackageLoader(root, documentModelsDir);
|
|
29
|
-
try {
|
|
30
|
-
const loadedModels = await documentModelsLoader.load();
|
|
31
|
-
documentModels.push(...loadedModels);
|
|
32
|
-
logger.info("Loaded document models: @models", loadedModels.map((m) => m.documentModel.global.name).join(", "));
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
logger.error("@error", e);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
// initializes reactor client with loaded document models
|
|
39
|
-
const reactorModule = await createReactorClient(documentModels);
|
|
40
|
-
const { client, reactor, reactorModule: rModule } = reactorModule;
|
|
41
|
-
// listens for changes in the local document models to update the reactor
|
|
42
|
-
if (documentModelsLoader && rModule?.documentModelRegistry) {
|
|
43
|
-
const unsubscribe = await documentModelsLoader.onDocumentModelsChange((models) => {
|
|
44
|
-
rModule.documentModelRegistry.registerModules(...baseDocumentModels.concat(models));
|
|
45
|
-
});
|
|
46
|
-
process.on("exit", () => {
|
|
47
|
-
unsubscribe();
|
|
48
|
-
reactor.kill();
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
// if a remote drive is passed, log a warning since remote drives
|
|
52
|
-
// are now handled at a different level (SyncManager)
|
|
53
|
-
if (remoteDrive) {
|
|
54
|
-
logger.warn("Remote drive configuration via MCP is not supported in the new reactor. " +
|
|
55
|
-
"Remote drives should be configured at the server level.");
|
|
56
|
-
}
|
|
57
|
-
// starts the server
|
|
58
|
-
// Note: syncManager is not available in stdio mode currently
|
|
59
|
-
const server = await createServer({ client });
|
|
60
|
-
// starts Stdio transport
|
|
61
|
-
const transport = new StdioServerTransport();
|
|
62
|
-
await server.connect(transport);
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stdio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQhD,MAAM,kBAAkB,GAA+B;IACrD,gCAAgC;IAChC,wBAAwB;CACzB,CAAC;AAEF,KAAK,UAAU,mBAAmB,CAAC,cAAqC;IACtE,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC,kBAAkB,CAC5D,kBAAkB,CAAC,MAAM,CAAC,cAAc,CAAC,CAC1C,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,IAAI,oBAAoB,EAAE;SAC5C,kBAAkB,CAAC,cAAc,CAAC;SAClC,WAAW,EAAE,CAAC;IAEjB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAA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AAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YACtB,WAAW,EAAE,CAAC;YACd,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,iEAAiE;IACjE,qDAAqD;IACrD,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,CAAC,IAAI,CACT,0EAA0E;YACxE,yDAAyD,CAC5D,CAAC;IACJ,CAAC;IAED,oBAAoB;IACpB,6DAA6D;IAC7D,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAE9C,yBAAyB;IACzB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DocumentModelModule } from "@powerhousedao/shared/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
|
-
readonly name = "VitePackageLoader";
|
|
12
|
-
constructor(root: string, documentModelsDir: string);
|
|
13
|
-
private get fullPath();
|
|
14
|
-
private initVite;
|
|
15
|
-
load(): Promise<DocumentModelModule[]>;
|
|
16
|
-
onDocumentModelsChange(callback: (models: DocumentModelModule[]) => void): Promise<() => void>;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/stdio/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAOhF,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;AAkBD,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;IAExC,QAAQ,CAAC,IAAI,uBAAuB;gBAExB,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;IAKnD,OAAO,KAAK,QAAQ,GAEnB;YAEa,QAAQ;IA4BhB,IAAI,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAoCtC,sBAAsB,CAC1B,QAAQ,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,IAAI;CAepD"}
|
package/dist/src/stdio/loader.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { childLogger } from "document-model";
|
|
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
|
-
function isSubpath(parent, dir) {
|
|
13
|
-
const relative = path.relative(parent, dir);
|
|
14
|
-
return relative && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
15
|
-
}
|
|
16
|
-
export class VitePackageLoader {
|
|
17
|
-
logger = childLogger(["reactor-local", "vite-loader"]);
|
|
18
|
-
root;
|
|
19
|
-
documentModelsDir;
|
|
20
|
-
vite;
|
|
21
|
-
name = "VitePackageLoader";
|
|
22
|
-
constructor(root, documentModelsDir) {
|
|
23
|
-
this.root = root;
|
|
24
|
-
this.documentModelsDir = documentModelsDir;
|
|
25
|
-
}
|
|
26
|
-
get fullPath() {
|
|
27
|
-
return path.join(this.root, this.documentModelsDir);
|
|
28
|
-
}
|
|
29
|
-
async initVite() {
|
|
30
|
-
if (this.vite) {
|
|
31
|
-
return this.vite;
|
|
32
|
-
}
|
|
33
|
-
this.vite = await createServer({
|
|
34
|
-
root: this.root,
|
|
35
|
-
logLevel: "info",
|
|
36
|
-
server: {
|
|
37
|
-
hmr: false,
|
|
38
|
-
middlewareMode: true,
|
|
39
|
-
warmup: {
|
|
40
|
-
ssrFiles: [this.fullPath],
|
|
41
|
-
},
|
|
42
|
-
fs: {
|
|
43
|
-
allow: [this.fullPath],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
optimizeDeps: {
|
|
47
|
-
// It's recommended to disable deps optimization
|
|
48
|
-
noDiscovery: true,
|
|
49
|
-
include: [],
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
return this.vite;
|
|
53
|
-
}
|
|
54
|
-
async load() {
|
|
55
|
-
const vite = await this.initVite();
|
|
56
|
-
await access(this.fullPath);
|
|
57
|
-
this.logger.verbose("Loading document models from", this.fullPath);
|
|
58
|
-
try {
|
|
59
|
-
const localDMs = (await vite.ssrLoadModule(this.fullPath));
|
|
60
|
-
const exports = Object.values(localDMs);
|
|
61
|
-
// duck type
|
|
62
|
-
const documentModels = [];
|
|
63
|
-
for (const dm of exports) {
|
|
64
|
-
if (dm.documentModel) {
|
|
65
|
-
documentModels.push(dm);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
this.logger.verbose(` ➜ Loaded ${documentModels.length} Document Models from: ${this.fullPath}`);
|
|
69
|
-
return documentModels;
|
|
70
|
-
}
|
|
71
|
-
catch (e) {
|
|
72
|
-
this.logger.verbose(` ➜ No Document Models found for: ${this.fullPath}${e ? `\n${JSON.stringify(e)}` : ""}`);
|
|
73
|
-
}
|
|
74
|
-
return [];
|
|
75
|
-
}
|
|
76
|
-
async onDocumentModelsChange(callback) {
|
|
77
|
-
const vite = await this.initVite();
|
|
78
|
-
const listener = debounce(async (changedPath) => {
|
|
79
|
-
if (isSubpath(this.fullPath, changedPath)) {
|
|
80
|
-
const documentModels = await this.load();
|
|
81
|
-
callback(documentModels);
|
|
82
|
-
}
|
|
83
|
-
}, 100);
|
|
84
|
-
vite.watcher.on("change", listener);
|
|
85
|
-
return () => {
|
|
86
|
-
vite.watcher.off("change", listener);
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/stdio/loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AASpC,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,SAAS,SAAS,CAAC,MAAc,EAAE,GAAW;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC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,EAAE,CAAC;gBAC1C,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzC,QAAQ,CAAC,cAAc,CAAC,CAAC;YAC3B,CAAC;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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/src/tools/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|