@powerhousedao/reactor-mcp 6.2.3-dev.95 → 6.2.3-dev.97
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/admin-tools.mjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/{server-BowYtdoY.mjs → server-C20v0OSn.mjs} +2 -2
- package/dist/{server-BowYtdoY.mjs.map → server-C20v0OSn.mjs.map} +1 -1
- package/dist/tools/index.d.mts +12 -0
- package/dist/tools/index.d.mts.map +1 -1
- package/dist/tools/index.mjs +2 -2
- package/dist/{tools-BrIw7TkA.mjs → tools-UCPB56U4.mjs} +72 -58
- package/dist/tools-UCPB56U4.mjs.map +1 -0
- package/package.json +6 -6
- package/dist/tools-BrIw7TkA.mjs.map +0 -1
package/dist/admin-tools.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as DRIVE_DOCUMENT_TYPE, _t as toReactorToolError, m as targetParam, mt as ReactorToolError, n as aliasParam, p as targetId, v as executeBuiltActions, y as getDocument } from "./tools-UCPB56U4.mjs";
|
|
2
2
|
import { DEFAULT_DRIVE_CONTAINER_TYPES, DriveCollectionId } from "@powerhousedao/reactor";
|
|
3
3
|
import { setAvailableOffline, setDriveIcon, setDriveName, setSharingType } from "@powerhousedao/shared/document-drive";
|
|
4
4
|
import { z } from "zod";
|
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as logger, t as createServer$1 } from "./server-
|
|
1
|
+
import { o as logger, t as createServer$1 } from "./server-C20v0OSn.mjs";
|
|
2
2
|
import { childLogger, documentModelDocumentModelModule } from "document-model";
|
|
3
3
|
import { ReactorBuilder, ReactorClientBuilder } from "@powerhousedao/reactor";
|
|
4
4
|
import { driveDocumentModelModule } from "@powerhousedao/shared/document-drive";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ANY_SCOPE, ActionError, ActionFailure, ActionInput, ActionResult, AiSdkTool, AiSdkToolSet, AnyToolDefinition, BASE_OPERATIONS, CompactDocumentModelSchema, CreateDocumentInput, CreatedDocument, DEFAULT_BRANCH, DEFAULT_TRIM_LIMITS, DRIVE_DOCUMENT_TYPE, DRIVE_DOCUMENT_TYPES, DocumentModelInfo, DocumentModelSummary, DocumentSummary, DocumentView, DocumentViewOptions, ExecuteActionsOptions, ExecutedActions, GetDocumentOptions, JsonPathError, MAX_FILTERED_CHARS, McpToolRecord, ModelOperation, OperationSlice, REACTOR_TOOL_ERROR_CODES, ReactorTool, ReactorToolAnnotations, ReactorToolClient, ReactorToolError, ReactorToolErrorCode, ReactorToolReadClient, ReactorToolReadMethods, ReactorToolWriteClient, ReactorToolWriteMethods, ReactorToolsOptions, Revision, StateSlice, ToolContext, ToolDefinition, TrimLimits, ValidateActionsOptions, ValidatedActions, actionFailuresError, actionInputSchema, actionOperations, addActionsTool, aliasParam, applyJsonPath, codegenHint, codegenStatusTool, compactDocumentModelSchema, compactDocumentModelSchemaSchema, createAddActionsTool, createDocument, createDocumentTool, defineTool, deleteDocument, deleteDocumentTool, documentModelInfo, documentModelInfoSchema, documentModelSummary, documentModelSummarySchema, documentName, documentSummary, documentSummarySchema, documentView, documentViewSchema, executeActions, executeBuiltActions, formatActionFailures, formatToolError, getDocument, getDocumentModel, getDocumentModelForDocument, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, isReactorToolError, isWriteTool, latestSpecification, modelOperationSchema, modelOperations, notFound, operationSchemaSlice, operationSliceSchema, parseJsonPath, queryJsonPath, reactorTools, stateSchemaSlice, stateSliceSchema, suggestNames, targetId, targetParam, toAiSdkTools, toMcpTool, toReactorToolError, trimValue, unknownValueMessage, validateActions } from "./tools/index.mjs";
|
|
1
|
+
import { ANY_SCOPE, ActionError, ActionFailure, ActionInput, ActionResult, AiSdkTool, AiSdkToolSet, AnyToolDefinition, BASE_OPERATIONS, CompactDocumentModelSchema, CreateDocumentInput, CreatedDocument, DEFAULT_BRANCH, DEFAULT_TRIM_LIMITS, DRIVE_DOCUMENT_TYPE, DRIVE_DOCUMENT_TYPES, DocumentModelInfo, DocumentModelSummary, DocumentSummary, DocumentView, DocumentViewOptions, ExecuteActionsOptions, ExecutedActions, GetDocumentOptions, JsonPathError, MAX_FILTERED_CHARS, McpToolRecord, ModelOperation, OperationSlice, REACTOR_TOOL_ERROR_CODES, ReactorTool, ReactorToolAnnotations, ReactorToolClient, ReactorToolError, ReactorToolErrorCode, ReactorToolReadClient, ReactorToolReadMethods, ReactorToolWriteClient, ReactorToolWriteMethods, ReactorToolsOptions, ResolvedOperation, Revision, StateSlice, ToolContext, ToolDefinition, TrimLimits, ValidateActionsOptions, ValidatedActions, actionFailuresError, actionInputSchema, actionOperations, addActionsTool, aliasParam, applyJsonPath, codegenHint, codegenStatusTool, compactDocumentModelSchema, compactDocumentModelSchemaSchema, createAddActionsTool, createDocument, createDocumentTool, defineTool, deleteDocument, deleteDocumentTool, documentModelInfo, documentModelInfoSchema, documentModelSummary, documentModelSummarySchema, documentName, documentSummary, documentSummarySchema, documentView, documentViewSchema, executeActions, executeBuiltActions, formatActionFailures, formatToolError, getDocument, getDocumentModel, getDocumentModelForDocument, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, isReactorToolError, isWriteTool, latestSpecification, modelOperationSchema, modelOperations, notFound, operationSchemaSlice, operationSliceSchema, parseJsonPath, queryJsonPath, reactorTools, resolveOperation, stateSchemaSlice, stateSliceSchema, suggestNames, targetId, targetParam, toAiSdkTools, toMcpTool, toReactorToolError, trimValue, unknownValueMessage, validateActions } from "./tools/index.mjs";
|
|
2
2
|
import { a as HostAccessClient, c as HostAccessIdentity, i as reactorAdminTools, l as McpAccess, n as RemoteDriveAllowlist, o as HostAccessDeniedError, r as isRemoteDriveUrlAllowed, s as HostAccessGate, t as ReactorAdminToolsOptions } from "./admin-tools-B-ZmrfuR.mjs";
|
|
3
3
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
4
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -78,6 +78,6 @@ export declare class SubjectScopedClient implements ReactorToolClient {
|
|
|
78
78
|
newDocument<T extends PHDocument = PHDocument>(documentType: string, options?: NewDocumentOptions, signal?: AbortSignal): Promise<T>;
|
|
79
79
|
}
|
|
80
80
|
//#endregion
|
|
81
|
-
export { ANY_SCOPE, ActionError, ActionFailure, ActionInput, ActionResult, AiSdkTool, AiSdkToolSet, AnyToolDefinition, BASE_OPERATIONS, CompactDocumentModelSchema, CreateDocumentInput, type CreateServerOptions, CreatedDocument, DEFAULT_BRANCH, DEFAULT_TRIM_LIMITS, DRIVE_DOCUMENT_TYPE, DRIVE_DOCUMENT_TYPES, DocumentModelInfo, DocumentModelSummary, DocumentSummary, DocumentView, DocumentViewOptions, ExecuteActionsOptions, ExecutedActions, GetDocumentOptions, HostAccessClient, HostAccessDeniedError, HostAccessGate, type HostAccessIdentity, JsonPathError, MAX_FILTERED_CHARS, type McpAccess, type McpAuthorizationResult, type McpRequestAuthorizer, McpToolRecord, ModelOperation, OperationSlice, REACTOR_TOOL_ERROR_CODES, type ReactorAdminToolsOptions, ReactorTool, ReactorToolAnnotations, ReactorToolClient, ReactorToolError, ReactorToolErrorCode, ReactorToolReadClient, ReactorToolReadMethods, ReactorToolWriteClient, ReactorToolWriteMethods, ReactorToolsOptions, type RemoteDriveAllowlist, Revision, type SetupMcpServerOptions, StateSlice, ToolContext, ToolDefinition, TrimLimits, ValidateActionsOptions, ValidatedActions, actionFailuresError, actionInputSchema, actionOperations, addActionsTool, aliasParam, applyJsonPath, codegenHint, codegenStatusTool, compactDocumentModelSchema, compactDocumentModelSchemaSchema, createAddActionsTool, createDocument, createDocumentTool, defineTool, deleteDocument, deleteDocumentTool, documentModelInfo, documentModelInfoSchema, documentModelSummary, documentModelSummarySchema, documentName, documentSummary, documentSummarySchema, documentView, documentViewSchema, executeActions, executeBuiltActions, formatActionFailures, formatToolError, getDocument, getDocumentModel, getDocumentModelForDocument, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, isReactorToolError, isRemoteDriveUrlAllowed, isWriteTool, latestSpecification, modelOperationSchema, modelOperations, notFound, operationSchemaSlice, operationSliceSchema, parseJsonPath, queryJsonPath, reactorAdminTools, reactorTools, stateSchemaSlice, stateSliceSchema, suggestNames, targetId, targetParam, toAiSdkTools, toMcpTool, toReactorToolError, trimValue, unknownValueMessage, validateActions };
|
|
81
|
+
export { ANY_SCOPE, ActionError, ActionFailure, ActionInput, ActionResult, AiSdkTool, AiSdkToolSet, AnyToolDefinition, BASE_OPERATIONS, CompactDocumentModelSchema, CreateDocumentInput, type CreateServerOptions, CreatedDocument, DEFAULT_BRANCH, DEFAULT_TRIM_LIMITS, DRIVE_DOCUMENT_TYPE, DRIVE_DOCUMENT_TYPES, DocumentModelInfo, DocumentModelSummary, DocumentSummary, DocumentView, DocumentViewOptions, ExecuteActionsOptions, ExecutedActions, GetDocumentOptions, HostAccessClient, HostAccessDeniedError, HostAccessGate, type HostAccessIdentity, JsonPathError, MAX_FILTERED_CHARS, type McpAccess, type McpAuthorizationResult, type McpRequestAuthorizer, McpToolRecord, ModelOperation, OperationSlice, REACTOR_TOOL_ERROR_CODES, type ReactorAdminToolsOptions, ReactorTool, ReactorToolAnnotations, ReactorToolClient, ReactorToolError, ReactorToolErrorCode, ReactorToolReadClient, ReactorToolReadMethods, ReactorToolWriteClient, ReactorToolWriteMethods, ReactorToolsOptions, type RemoteDriveAllowlist, ResolvedOperation, Revision, type SetupMcpServerOptions, StateSlice, ToolContext, ToolDefinition, TrimLimits, ValidateActionsOptions, ValidatedActions, actionFailuresError, actionInputSchema, actionOperations, addActionsTool, aliasParam, applyJsonPath, codegenHint, codegenStatusTool, compactDocumentModelSchema, compactDocumentModelSchemaSchema, createAddActionsTool, createDocument, createDocumentTool, defineTool, deleteDocument, deleteDocumentTool, documentModelInfo, documentModelInfoSchema, documentModelSummary, documentModelSummarySchema, documentName, documentSummary, documentSummarySchema, documentView, documentViewSchema, executeActions, executeBuiltActions, formatActionFailures, formatToolError, getDocument, getDocumentModel, getDocumentModelForDocument, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, isReactorToolError, isRemoteDriveUrlAllowed, isWriteTool, latestSpecification, modelOperationSchema, modelOperations, notFound, operationSchemaSlice, operationSliceSchema, parseJsonPath, queryJsonPath, reactorAdminTools, reactorTools, resolveOperation, stateSchemaSlice, stateSliceSchema, suggestNames, targetId, targetParam, toAiSdkTools, toMcpTool, toReactorToolError, trimValue, unknownValueMessage, validateActions };
|
|
82
82
|
export {};
|
|
83
83
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as HostAccessGate, i as HostAccessDeniedError, n as SubjectScopedClient, o as logger, r as HostAccessClient, t as createServer } from "./server-
|
|
2
|
-
import { $ as
|
|
1
|
+
import { a as HostAccessGate, i as HostAccessDeniedError, n as SubjectScopedClient, o as logger, r as HostAccessClient, t as createServer } from "./server-C20v0OSn.mjs";
|
|
2
|
+
import { $ as trimValue, A as documentModelInfoSchema, B as stateSliceSchema, C as actionInputSchema, D as BASE_OPERATIONS, E as ANY_SCOPE, F as modelOperations, G as DRIVE_DOCUMENT_TYPE, H as unknownValueMessage, I as operationSchemaSlice, J as documentName, K as DRIVE_DOCUMENT_TYPES, L as operationSliceSchema, M as documentModelSummarySchema, N as latestSpecification, O as actionOperations, P as modelOperationSchema, Q as documentViewSchema, R as resolveOperation, S as actionFailuresError, T as validateActions, U as DEFAULT_BRANCH, V as suggestNames, W as DEFAULT_TRIM_LIMITS, X as documentSummarySchema, Y as documentSummary, Z as documentView, _ as executeActions, _t as toReactorToolError, a as deleteDocumentTool, at as compactDocumentModelSchemaSchema, b as getDocumentModel, c as getDocumentTool, ct as defineTool, d as getDrivesTool, dt as toAiSdkTools, et as JsonPathError, f as reactorTools, ft as toMcpTool, g as deleteDocument, gt as notFound, h as createDocument, ht as isReactorToolError, i as createDocumentTool, it as compactDocumentModelSchema, j as documentModelSummary, k as documentModelInfo, l as getDocumentsTool, lt as formatToolError, m as targetParam, mt as ReactorToolError, n as aliasParam, nt as parseJsonPath, o as getDocumentModelSchemaTool, ot as codegenHint, p as targetId, pt as REACTOR_TOOL_ERROR_CODES, q as MAX_FILTERED_CHARS, r as createAddActionsTool, rt as queryJsonPath, s as getDocumentModelsTool, st as codegenStatusTool, t as addActionsTool, tt as applyJsonPath, u as getDriveTool, ut as isWriteTool, v as executeBuiltActions, w as formatActionFailures, x as getDocumentModelForDocument, y as getDocument, z as stateSchemaSlice } from "./tools-UCPB56U4.mjs";
|
|
3
3
|
import { isRemoteDriveUrlAllowed, reactorAdminTools } from "./admin-tools.mjs";
|
|
4
4
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
5
5
|
//#region src/mcp-routes.ts
|
|
@@ -69,6 +69,6 @@ function setupMcpServer(options, httpAdapter, createTransport = (opts) => new St
|
|
|
69
69
|
return Promise.resolve();
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
72
|
-
export { ANY_SCOPE, BASE_OPERATIONS, DEFAULT_BRANCH, DEFAULT_TRIM_LIMITS, DRIVE_DOCUMENT_TYPE, DRIVE_DOCUMENT_TYPES, HostAccessClient, HostAccessDeniedError, HostAccessGate, JsonPathError, MAX_FILTERED_CHARS, REACTOR_TOOL_ERROR_CODES, ReactorToolError, SubjectScopedClient, actionFailuresError, actionInputSchema, actionOperations, addActionsTool, aliasParam, applyJsonPath, codegenHint, codegenStatusTool, compactDocumentModelSchema, compactDocumentModelSchemaSchema, createAddActionsTool, createDocument, createDocumentTool, createServer, defineTool, deleteDocument, deleteDocumentTool, documentModelInfo, documentModelInfoSchema, documentModelSummary, documentModelSummarySchema, documentName, documentSummary, documentSummarySchema, documentView, documentViewSchema, executeActions, executeBuiltActions, formatActionFailures, formatToolError, getDocument, getDocumentModel, getDocumentModelForDocument, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, isReactorToolError, isRemoteDriveUrlAllowed, isWriteTool, latestSpecification, modelOperationSchema, modelOperations, notFound, operationSchemaSlice, operationSliceSchema, parseJsonPath, queryJsonPath, reactorAdminTools, reactorTools, setupMcpServer, stateSchemaSlice, stateSliceSchema, suggestNames, targetId, targetParam, toAiSdkTools, toMcpTool, toReactorToolError, trimValue, unknownValueMessage, validateActions };
|
|
72
|
+
export { ANY_SCOPE, BASE_OPERATIONS, DEFAULT_BRANCH, DEFAULT_TRIM_LIMITS, DRIVE_DOCUMENT_TYPE, DRIVE_DOCUMENT_TYPES, HostAccessClient, HostAccessDeniedError, HostAccessGate, JsonPathError, MAX_FILTERED_CHARS, REACTOR_TOOL_ERROR_CODES, ReactorToolError, SubjectScopedClient, actionFailuresError, actionInputSchema, actionOperations, addActionsTool, aliasParam, applyJsonPath, codegenHint, codegenStatusTool, compactDocumentModelSchema, compactDocumentModelSchemaSchema, createAddActionsTool, createDocument, createDocumentTool, createServer, defineTool, deleteDocument, deleteDocumentTool, documentModelInfo, documentModelInfoSchema, documentModelSummary, documentModelSummarySchema, documentName, documentSummary, documentSummarySchema, documentView, documentViewSchema, executeActions, executeBuiltActions, formatActionFailures, formatToolError, getDocument, getDocumentModel, getDocumentModelForDocument, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, isReactorToolError, isRemoteDriveUrlAllowed, isWriteTool, latestSpecification, modelOperationSchema, modelOperations, notFound, operationSchemaSlice, operationSliceSchema, parseJsonPath, queryJsonPath, reactorAdminTools, reactorTools, resolveOperation, setupMcpServer, stateSchemaSlice, stateSliceSchema, suggestNames, targetId, targetParam, toAiSdkTools, toMcpTool, toReactorToolError, trimValue, unknownValueMessage, validateActions };
|
|
73
73
|
|
|
74
74
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as reactorTools, ft as toMcpTool, mt as ReactorToolError, st as codegenStatusTool } from "./tools-UCPB56U4.mjs";
|
|
2
2
|
import { reactorAdminTools } from "./admin-tools.mjs";
|
|
3
3
|
import { childLogger } from "document-model";
|
|
4
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -326,4 +326,4 @@ function createServer(options) {
|
|
|
326
326
|
//#endregion
|
|
327
327
|
export { HostAccessGate as a, HostAccessDeniedError as i, SubjectScopedClient as n, logger as o, HostAccessClient as r, createServer as t };
|
|
328
328
|
|
|
329
|
-
//# sourceMappingURL=server-
|
|
329
|
+
//# sourceMappingURL=server-C20v0OSn.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-BowYtdoY.mjs","names":[],"sources":["../src/logger.ts","../src/host-access.ts","../src/subject-client.ts","../src/server.ts"],"sourcesContent":["import { childLogger, type ILogger } from \"document-model\";\n\nexport const logger: ILogger = childLogger([\"reactor-mcp\"]);\n","import type {\n ConsistencyToken,\n IReactorClient,\n NewDocumentOptions,\n OperationFilter,\n PagedResults,\n PagingOptions,\n SearchFilter,\n ViewFilter,\n} from \"@powerhousedao/reactor\";\nimport type { Action, PHDocument } from \"@powerhousedao/shared/document-model\";\nimport {\n DRIVE_DOCUMENT_TYPE,\n ReactorToolError,\n type ReactorToolClient,\n type ReactorToolWriteClient,\n} from \"./tools/index.js\";\n\n/** The host's access decisions for one caller, as its GraphQL API makes them; ids are canonical. */\nexport interface McpAccess {\n /** Policy-wide access (OPEN or a supreme admin): per-document checks are skipped. */\n readonly unrestricted: boolean;\n /** Whether the caller is authenticated; a refused create says which. */\n readonly authenticated: boolean;\n canRead(documentId: string): Promise<boolean>;\n canWrite(documentId: string): Promise<boolean>;\n canMutate(documentId: string, operationType: string): Promise<boolean>;\n canCreate(): boolean | Promise<boolean>;\n /** Called after the caller created a document, so the host records its owner. */\n created?(documentId: string): Promise<void>;\n}\n\n/** Resolves identifiers the way the host's GraphQL checks do. */\nexport type HostAccessIdentity = Pick<IReactorClient, \"resolveIdOrSlug\"> & {\n readonly write: Pick<IReactorClient[\"write\"], \"describe\">;\n};\n\ntype DeniedAction = { index: number; type: string; reason: string };\n\n/** A batch the host's ACL refused, by action index; nothing in it was written. */\nexport class HostAccessDeniedError extends Error {\n readonly denied: DeniedAction[];\n\n constructor(denied: DeniedAction[]) {\n super(denied[0]?.reason ?? \"Forbidden\");\n this.name = \"HostAccessDeniedError\";\n this.denied = denied;\n }\n}\n\nconst forbidden = (what: string) =>\n new ReactorToolError(\"FORBIDDEN\", `Forbidden: you may not ${what}`);\n\ntype DriveNodes = { global?: { nodes?: { id: string }[] } };\n\n/** The checks GraphQL's resolvers apply, for one caller. */\nexport class HostAccessGate {\n constructor(\n private readonly access: McpAccess,\n private readonly ids: HostAccessIdentity,\n ) {}\n\n get unrestricted(): boolean {\n return this.access.unrestricted;\n }\n\n // An unresolvable id is refused without saying whether it exists.\n private async canonical(\n identifier: string,\n side: \"read\" | \"write\",\n what: string,\n signal?: AbortSignal,\n ): Promise<string> {\n try {\n return side === \"read\"\n ? await this.ids.resolveIdOrSlug(identifier, undefined, signal)\n : (await this.ids.write.describe(identifier, undefined, signal))\n .documentId;\n } catch {\n throw forbidden(what);\n }\n }\n\n /** GraphQL's assertCanRead: the id to fetch, or FORBIDDEN. */\n async read(identifier: string, signal?: AbortSignal): Promise<string> {\n if (this.access.unrestricted) return identifier;\n const what = `read ${identifier}`;\n const id = await this.canonical(identifier, \"read\", what, signal);\n if (!(await this.access.canRead(id))) throw forbidden(what);\n return id;\n }\n\n /** GraphQL's assertCanWrite: the id to write, or FORBIDDEN. */\n async write(identifier: string, signal?: AbortSignal): Promise<string> {\n if (this.access.unrestricted) return identifier;\n const what = `write to ${identifier}`;\n const id = await this.canonical(identifier, \"write\", what, signal);\n if (!(await this.access.canWrite(id))) throw forbidden(what);\n return id;\n }\n\n /** GraphQL's assertCanExecuteOperations: canMutate per action type. */\n async mutate(\n identifier: string,\n actions: readonly Pick<Action, \"type\">[],\n signal?: AbortSignal,\n ): Promise<string> {\n if (this.access.unrestricted) return identifier;\n const id = await this.canonical(\n identifier,\n \"write\",\n `change ${identifier}`,\n signal,\n );\n const decisions = new Map<string, boolean>();\n for (const { type } of actions) {\n if (!decisions.has(type)) {\n decisions.set(type, await this.access.canMutate(id, type));\n }\n }\n const denied = actions.flatMap(({ type }, index): DeniedAction[] =>\n decisions.get(type)\n ? []\n : [{ index, type, reason: `Forbidden: you may not execute ${type}` }],\n );\n if (denied.length > 0) throw new HostAccessDeniedError(denied);\n return id;\n }\n\n /** GraphQL's create rule: write on the parent, else canCreate. */\n async create(parent?: string, signal?: AbortSignal): Promise<void> {\n if (parent) {\n await this.write(parent, signal);\n return;\n }\n if (this.access.unrestricted || (await this.access.canCreate())) return;\n throw new ReactorToolError(\n \"FORBIDDEN\",\n this.access.authenticated\n ? \"Forbidden: you may not create documents\"\n : \"Authentication required to create documents\",\n );\n }\n\n async created(documentId: string): Promise<void> {\n await this.access.created?.(documentId);\n }\n\n async readable<T>(items: readonly T[], idOf: (item: T) => string) {\n if (this.access.unrestricted) return [...items];\n const decisions = new Map<string, boolean>();\n const out: T[] = [];\n for (const item of items) {\n const id = idOf(item);\n let allowed = decisions.get(id);\n if (allowed === undefined) {\n allowed = await this.access.canRead(id);\n decisions.set(id, allowed);\n }\n if (allowed) out.push(item);\n }\n return out;\n }\n\n /** The readable part of a page; an emptied page moves on, so a listing does not stop early. */\n async readablePage<T>(\n page: PagedResults<T>,\n idOf: (item: T) => string,\n ): Promise<PagedResults<T>> {\n if (this.access.unrestricted) return page;\n const results = await this.readable(page.results, idOf);\n const next = page.next;\n if (results.length === 0 && next && page.results.length > 0) {\n return this.readablePage(await next(), idOf);\n }\n return {\n ...page,\n results,\n next: next && (async () => this.readablePage(await next(), idOf)),\n };\n }\n}\n\nconst documentId = (document: PHDocument) => document.header.id;\n\ntype EvaluateActions = IReactorClient[\"write\"][\"evaluateActions\"];\n\n/** The tool client behind the host's ACL as GraphQL applies it. */\nexport class HostAccessClient implements ReactorToolClient {\n readonly write: ReactorToolWriteClient & {\n evaluateActions: EvaluateActions;\n /** Checked before deleteDocument changes anything. */\n authorizeDelete(id: string, signal?: AbortSignal): Promise<void>;\n };\n\n constructor(\n private readonly inner: ReactorToolClient & {\n readonly write: { evaluateActions: EvaluateActions };\n },\n private readonly gate: HostAccessGate,\n ) {\n const write = inner.write;\n this.write = {\n create: async (document, parentIdentifier, signal) => {\n await gate.create(parentIdentifier, signal);\n const handle = await write.create(document, parentIdentifier, signal);\n await handle.readable;\n await gate.created(handle.documentId);\n return handle;\n },\n createEmpty: async (documentType, options, signal) => {\n await gate.create(options?.parentIdentifier, signal);\n const handle = await write.createEmpty(documentType, options, signal);\n await handle.readable;\n await gate.created(handle.documentId);\n return handle;\n },\n execute: async (id, branch, actions, signal) =>\n write.execute(\n await gate.mutate(id, actions, signal),\n branch,\n actions,\n signal,\n ),\n deleteDocument: async (id, propagate, signal) =>\n write.deleteDocument(await gate.write(id, signal), propagate, signal),\n drives: {\n // GraphQL's createDocument under a drive: write on the drive.\n addFile: async (driveId, document, parentFolder, signal) => {\n const drive = await gate.write(driveId, signal);\n const handle = await write.drives.addFile(\n drive,\n document,\n parentFolder,\n signal,\n );\n await handle.readable;\n await gate.created(document.header.id);\n return handle;\n },\n },\n evaluateActions: async (id, branch, candidates, subject, signal) =>\n write.evaluateActions(\n await gate.read(id, signal),\n branch,\n candidates,\n subject,\n signal,\n ),\n authorizeDelete: (id, signal) => this.authorizeDelete(id, signal),\n };\n }\n\n // GraphQL's deleteDocument check, plus DELETE_NODE on each drive filing it,\n // up front so a refusal leaves every drive as it was.\n private async authorizeDelete(id: string, signal?: AbortSignal) {\n if (this.gate.unrestricted) return;\n const canonical = await this.gate.write(id, signal);\n const parents = await this.inner.getIncomingRelationships(\n canonical,\n \"child\",\n undefined,\n undefined,\n signal,\n );\n for (const parent of parents.results) {\n if (parent.header.documentType !== DRIVE_DOCUMENT_TYPE) continue;\n const nodes = (parent.state as DriveNodes).global?.nodes;\n if (Array.isArray(nodes) && !nodes.some((n) => n.id === canonical)) {\n continue;\n }\n try {\n await this.gate.mutate(parent.header.id, [{ type: \"DELETE_NODE\" }]);\n } catch {\n throw new ReactorToolError(\n \"FORBIDDEN\",\n `Document ${canonical} is filed in drive ${parent.header.id}, which you cannot change; it was not deleted`,\n );\n }\n }\n }\n\n async get<T extends PHDocument>(\n id: string,\n view?: ViewFilter,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.get<T>(\n await this.gate.read(id, signal),\n view,\n signal,\n consistencyToken,\n );\n }\n\n async resolveIdOrSlug(\n id: string,\n view?: ViewFilter,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.resolveIdOrSlug(\n await this.gate.read(id, signal),\n view,\n signal,\n consistencyToken,\n );\n }\n\n async find(\n search: SearchFilter,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.gate.readablePage(\n await this.inner.find(search, view, paging, signal, consistencyToken),\n documentId,\n );\n }\n\n async getOperations(\n id: string,\n view?: ViewFilter,\n filter?: OperationFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.getOperations(\n await this.gate.read(id, signal),\n view,\n filter,\n paging,\n signal,\n );\n }\n\n async getOutgoingRelationships(\n id: string,\n type: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.gate.readablePage(\n await this.inner.getOutgoingRelationships(\n await this.gate.read(id, signal),\n type,\n view,\n paging,\n signal,\n consistencyToken,\n ),\n documentId,\n );\n }\n\n async getIncomingRelationships(\n id: string,\n type: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.gate.readablePage(\n await this.inner.getIncomingRelationships(\n await this.gate.read(id, signal),\n type,\n view,\n paging,\n signal,\n consistencyToken,\n ),\n documentId,\n );\n }\n\n async getOutgoingRelationshipEdges(\n id: string,\n type?: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.gate.readablePage(\n await this.inner.getOutgoingRelationshipEdges(\n await this.gate.read(id, signal),\n type,\n view,\n paging,\n signal,\n consistencyToken,\n ),\n (edge) => edge.targetId,\n );\n }\n\n async getIncomingRelationshipEdges(\n id: string,\n type?: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.gate.readablePage(\n await this.inner.getIncomingRelationshipEdges(\n await this.gate.read(id, signal),\n type,\n view,\n paging,\n signal,\n consistencyToken,\n ),\n (edge) => edge.sourceId,\n );\n }\n\n getDocumentModelModules(\n namespace?: string,\n paging?: PagingOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.getDocumentModelModules(namespace, paging, signal);\n }\n\n getDocumentModelModule(documentType: string) {\n return this.inner.getDocumentModelModule(documentType);\n }\n\n getDocumentModelModuleForDocument(document: PHDocument) {\n return this.inner.getDocumentModelModuleForDocument(document);\n }\n\n newDocument<T extends PHDocument = PHDocument>(\n documentType: string,\n options?: NewDocumentOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.newDocument<T>(documentType, options, signal);\n }\n}\n","import type {\n ConsistencyToken,\n IReactorClient,\n NewDocumentOptions,\n OperationFilter,\n PagingOptions,\n SearchFilter,\n ViewFilter,\n} from \"@powerhousedao/reactor\";\nimport type {\n AuthSubject,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport {\n DRIVE_DOCUMENT_TYPE,\n ReactorToolError,\n type ReactorToolClient,\n type ReactorToolWriteClient,\n} from \"./tools/index.js\";\n\ntype DriveNodes = { global?: { nodes?: { id: string }[] } };\n\n// The tool subset over a full client, reading as `subject`. Writes go through\n// the write half and are judged as the client's signer.\nexport class SubjectScopedClient implements ReactorToolClient {\n readonly write: ReactorToolWriteClient & {\n evaluateActions: IReactorClient[\"write\"][\"evaluateActions\"];\n };\n\n constructor(\n private readonly inner: IReactorClient,\n private readonly subject?: AuthSubject,\n ) {\n const write = inner.write;\n this.write = {\n create: (document, parentIdentifier, signal) =>\n write.create(document, parentIdentifier, signal),\n createEmpty: (documentType, options, signal) =>\n write.createEmpty(documentType, options, signal),\n execute: (id, branch, actions, signal) =>\n write.execute(id, branch, actions, signal),\n deleteDocument: async (id, propagate, signal) => {\n await this.assertNoHiddenFiling(id, signal);\n return write.deleteDocument(id, propagate, signal);\n },\n drives: {\n addFile: (driveId, document, parentFolder, signal) =>\n write.drives.addFile(driveId, document, parentFolder, signal),\n },\n evaluateActions: (id, branch, candidates, subject, signal) =>\n write.evaluateActions(id, branch, candidates, subject, signal),\n };\n }\n\n private view(view?: ViewFilter): ViewFilter | undefined {\n return this.subject ? { ...view, subject: this.subject } : view;\n }\n\n // A drive the subject cannot read would keep a node for the deleted document.\n private async assertNoHiddenFiling(id: string, signal?: AbortSignal) {\n if (!this.subject) return;\n const parents = await this.inner.getIncomingRelationships(\n id,\n \"child\",\n undefined,\n undefined,\n signal,\n );\n // Unreadable nodes count as filing it: the delete cannot rule that out.\n const hidden = parents.results.find((parent) => {\n if (parent.header.documentType !== DRIVE_DOCUMENT_TYPE) return false;\n const nodes = (parent.state as DriveNodes).global?.nodes;\n return !Array.isArray(nodes) || nodes.some((n) => n.id === id);\n });\n if (hidden) {\n throw new ReactorToolError(\n \"FORBIDDEN\",\n `Document ${id} is filed in drive ${hidden.header.id}, which you cannot change; it was not deleted`,\n );\n }\n }\n\n get<T extends PHDocument>(\n id: string,\n view?: ViewFilter,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.get<T>(id, this.view(view), signal, consistencyToken);\n }\n\n resolveIdOrSlug(\n id: string,\n view?: ViewFilter,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.resolveIdOrSlug(\n id,\n this.view(view),\n signal,\n consistencyToken,\n );\n }\n\n find(\n search: SearchFilter,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.find(\n search,\n this.view(view),\n paging,\n signal,\n consistencyToken,\n );\n }\n\n getOperations(\n id: string,\n view?: ViewFilter,\n filter?: OperationFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.getOperations(\n id,\n this.view(view),\n filter,\n paging,\n signal,\n );\n }\n\n getOutgoingRelationships(\n id: string,\n type: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.getOutgoingRelationships(\n id,\n type,\n this.view(view),\n paging,\n signal,\n consistencyToken,\n );\n }\n\n getIncomingRelationships(\n id: string,\n type: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.getIncomingRelationships(\n id,\n type,\n this.view(view),\n paging,\n signal,\n consistencyToken,\n );\n }\n\n getOutgoingRelationshipEdges(\n id: string,\n type?: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.getOutgoingRelationshipEdges(\n id,\n type,\n this.view(view),\n paging,\n signal,\n consistencyToken,\n );\n }\n\n getIncomingRelationshipEdges(\n id: string,\n type?: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.getIncomingRelationshipEdges(\n id,\n type,\n this.view(view),\n paging,\n signal,\n consistencyToken,\n );\n }\n\n getDocumentModelModules(\n namespace?: string,\n paging?: PagingOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.getDocumentModelModules(namespace, paging, signal);\n }\n\n getDocumentModelModule(documentType: string) {\n return this.inner.getDocumentModelModule(documentType);\n }\n\n getDocumentModelModuleForDocument(document: PHDocument) {\n return this.inner.getDocumentModelModuleForDocument(document);\n }\n\n newDocument<T extends PHDocument = PHDocument>(\n documentType: string,\n options?: NewDocumentOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.newDocument<T>(documentType, options, signal);\n }\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { IReactorClient, ISyncManager } from \"@powerhousedao/reactor\";\nimport type { AuthSubject } from \"@powerhousedao/shared/document-model\";\nimport {\n type CodegenStatusRegistry,\n getCodegenStatusRegistry,\n} from \"@powerhousedao/shared/processors\";\nimport { reactorAdminTools, type RemoteDriveAllowlist } from \"./admin-tools.js\";\nimport {\n HostAccessClient,\n HostAccessGate,\n type McpAccess,\n} from \"./host-access.js\";\nimport { SubjectScopedClient } from \"./subject-client.js\";\nimport { codegenStatusTool, reactorTools, toMcpTool } from \"./tools/index.js\";\n\nexport interface CreateServerOptions {\n client: IReactorClient;\n syncManager?: ISyncManager;\n /** Who the tools read as; omitted, the client's signer. */\n subject?: AuthSubject;\n /** The host's ACL for the caller, in front of every tool; omitted, none. */\n access?: McpAccess;\n /** URLs `addRemoteDrive` may fetch; omitted, the tool is not mounted. */\n remoteDriveUrls?: RemoteDriveAllowlist;\n /** Vetra's codegen status; the process's registry by default. */\n codegenStatus?: CodegenStatusRegistry;\n}\n\nexport 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 — 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.\n\"addActions\" returns one result per action. When \"success\" is false, the results with an \"error\" say which actions were not applied and why.\nIn Vetra, a change to a document model, editor, app, processor, subgraph or package document makes Vetra generate code from it a few seconds later; \"getCodegenStatus\" says when that is done, and why it failed or was skipped.\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`;\n\nexport function createServer(options: CreateServerOptions): Promise<McpServer> {\n const { client, syncManager, subject, access, remoteDriveUrls } = options;\n const codegenStatus = options.codegenStatus ?? getCodegenStatusRegistry();\n const server = new McpServer(\n {\n name: \"reactor-mcp-server\",\n version: \"1.0.0\",\n description: ReactorMcpInstructions,\n },\n {\n capabilities: {\n tools: {},\n resources: {\n subscribe: true,\n listChanged: true,\n },\n prompts: {\n listChanged: true,\n },\n },\n },\n );\n\n server.registerResource(\n \"instructions\",\n \"reactor://instructions\",\n {\n title: \"Instructions\",\n description: \"General instructions on how to use the tools of this MCP\",\n mimeType: \"text/plain\",\n },\n (uri) => ({\n contents: [\n {\n uri: uri.href,\n text: ReactorMcpInstructions,\n },\n ],\n }),\n );\n\n const scoped = new SubjectScopedClient(client, subject);\n const gate = access && new HostAccessGate(access, client);\n const userContext = {\n client: gate ? new HostAccessClient(scoped, gate) : scoped,\n };\n const tools = [\n ...[\n ...reactorTools({ codegenStatus }),\n codegenStatusTool(codegenStatus),\n ].map((tool) => toMcpTool(tool, userContext)),\n ...reactorAdminTools({ syncManager, remoteDriveUrls, subject, gate }).map(\n (tool) => toMcpTool(tool, { client }),\n ),\n ];\n for (const { name, callback, ...config } of tools) {\n // The records carry zod shapes the SDK accepts; its overloads cannot infer them.\n server.registerTool(name, config as any, callback as any);\n }\n\n return Promise.resolve(server);\n}\n"],"mappings":";;;;;;AAEA,MAAa,SAAkB,YAAY,CAAC,aAAa,CAAC;;;;ACsC1D,IAAa,wBAAb,cAA2C,MAAM;CAC/C;CAEA,YAAY,QAAwB;EAClC,MAAM,OAAO,EAAE,EAAE,UAAU,WAAW;EACtC,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AAEA,MAAM,aAAa,SACjB,IAAI,iBAAiB,aAAa,0BAA0B,MAAM;;AAKpE,IAAa,iBAAb,MAA4B;CAEP;CACA;CAFnB,YACE,QACA,K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,QACA,QACA,gBACF;CACF;CAEA,cACE,IACA,MACA,QACA,QACA,QACA;EACA,OAAO,KAAK,MAAM,cAChB,IACA,KAAK,KAAK,IAAI,GACd,QACA,QACA,MACF;CACF;CAEA,yBACE,IACA,MACA,MACA,QACA,QACA,kBACA;EACA,OAAO,KAAK,MAAM,yBAChB,IACA,MACA,KAAK,KAAK,IAAI,GACd,QACA,QACA,gBACF;CACF;CAEA,yBACE,IACA,MACA,MACA,QACA,QACA,kBACA;EACA,OAAO,KAAK,MAAM,yBAChB,IACA,MACA,KAAK,KAAK,IAAI,GACd,QACA,QACA,gBACF;CACF;CAEA,6BACE,IACA,MACA,MACA,QACA,QACA,kBACA;EACA,OAAO,KAAK,MAAM,6BAChB,IACA,MACA,KAAK,KAAK,IAAI,GACd,QACA,QACA,gBACF;CACF;CAEA,6BACE,IACA,MACA,MACA,QACA,QACA,kBACA;EACA,OAAO,KAAK,MAAM,6BAChB,IACA,MACA,KAAK,KAAK,IAAI,GACd,QACA,QACA,gBACF;CACF;CAEA,wBACE,WACA,QACA,QACA;EACA,OAAO,KAAK,MAAM,wBAAwB,WAAW,QAAQ,MAAM;CACrE;CAEA,uBAAuB,cAAsB;EAC3C,OAAO,KAAK,MAAM,uBAAuB,YAAY;CACvD;CAEA,kCAAkC,UAAsB;EACtD,OAAO,KAAK,MAAM,kCAAkC,QAAQ;CAC9D;CAEA,YACE,cACA,SACA,QACA;EACA,OAAO,KAAK,MAAM,YAAe,cAAc,SAAS,MAAM;CAChE;AACF;;;AC3MA,MAAa,yBAAyB;;;;;;;;;;;;;;;;;AAkBtC,SAAgB,aAAa,SAAkD;CAC7E,MAAM,EAAE,QAAQ,aAAa,SAAS,QAAQ,oBAAoB;CAClE,MAAM,gBAAgB,QAAQ,iBAAiB,yBAAyB;CACxE,MAAM,SAAS,IAAI,UACjB;EACE,MAAM;EACN,SAAS;EACT,aAAa;CACf,GACA,EACE,cAAc;EACZ,OAAO,CAAC;EACR,WAAW;GACT,WAAW;GACX,aAAa;EACf;EACA,SAAS,EACP,aAAa,KACf;CACF,EACF,CACF;CAEA,OAAO,iBACL,gBACA,0BACA;EACE,OAAO;EACP,aAAa;EACb,UAAU;CACZ,IACC,SAAS,EACR,UAAU,CACR;EACE,KAAK,IAAI;EACT,MAAM;CACR,CACF,EACF,EACF;CAEA,MAAM,SAAS,IAAI,oBAAoB,QAAQ,OAAO;CACtD,MAAM,OAAO,UAAU,IAAI,eAAe,QAAQ,MAAM;CACxD,MAAM,cAAc,EAClB,QAAQ,OAAO,IAAI,iBAAiB,QAAQ,IAAI,IAAI,OACtD;CACA,MAAM,QAAQ,CACZ,GAAG,CACD,GAAG,aAAa,EAAE,cAAc,CAAC,GACjC,kBAAkB,aAAa,CACjC,CAAC,CAAC,KAAK,SAAS,UAAU,MAAM,WAAW,CAAC,GAC5C,GAAG,kBAAkB;EAAE;EAAa;EAAiB;EAAS;CAAK,CAAC,CAAC,CAAC,KACnE,SAAS,UAAU,MAAM,EAAE,OAAO,CAAC,CACtC,CACF;CACA,KAAK,MAAM,EAAE,MAAM,UAAU,GAAG,YAAY,OAE1C,OAAO,aAAa,MAAM,QAAe,QAAe;CAG1D,OAAO,QAAQ,QAAQ,MAAM;AAC/B"}
|
|
1
|
+
{"version":3,"file":"server-C20v0OSn.mjs","names":[],"sources":["../src/logger.ts","../src/host-access.ts","../src/subject-client.ts","../src/server.ts"],"sourcesContent":["import { childLogger, type ILogger } from \"document-model\";\n\nexport const logger: ILogger = childLogger([\"reactor-mcp\"]);\n","import type {\n ConsistencyToken,\n IReactorClient,\n NewDocumentOptions,\n OperationFilter,\n PagedResults,\n PagingOptions,\n SearchFilter,\n ViewFilter,\n} from \"@powerhousedao/reactor\";\nimport type { Action, PHDocument } from \"@powerhousedao/shared/document-model\";\nimport {\n DRIVE_DOCUMENT_TYPE,\n ReactorToolError,\n type ReactorToolClient,\n type ReactorToolWriteClient,\n} from \"./tools/index.js\";\n\n/** The host's access decisions for one caller, as its GraphQL API makes them; ids are canonical. */\nexport interface McpAccess {\n /** Policy-wide access (OPEN or a supreme admin): per-document checks are skipped. */\n readonly unrestricted: boolean;\n /** Whether the caller is authenticated; a refused create says which. */\n readonly authenticated: boolean;\n canRead(documentId: string): Promise<boolean>;\n canWrite(documentId: string): Promise<boolean>;\n canMutate(documentId: string, operationType: string): Promise<boolean>;\n canCreate(): boolean | Promise<boolean>;\n /** Called after the caller created a document, so the host records its owner. */\n created?(documentId: string): Promise<void>;\n}\n\n/** Resolves identifiers the way the host's GraphQL checks do. */\nexport type HostAccessIdentity = Pick<IReactorClient, \"resolveIdOrSlug\"> & {\n readonly write: Pick<IReactorClient[\"write\"], \"describe\">;\n};\n\ntype DeniedAction = { index: number; type: string; reason: string };\n\n/** A batch the host's ACL refused, by action index; nothing in it was written. */\nexport class HostAccessDeniedError extends Error {\n readonly denied: DeniedAction[];\n\n constructor(denied: DeniedAction[]) {\n super(denied[0]?.reason ?? \"Forbidden\");\n this.name = \"HostAccessDeniedError\";\n this.denied = denied;\n }\n}\n\nconst forbidden = (what: string) =>\n new ReactorToolError(\"FORBIDDEN\", `Forbidden: you may not ${what}`);\n\ntype DriveNodes = { global?: { nodes?: { id: string }[] } };\n\n/** The checks GraphQL's resolvers apply, for one caller. */\nexport class HostAccessGate {\n constructor(\n private readonly access: McpAccess,\n private readonly ids: HostAccessIdentity,\n ) {}\n\n get unrestricted(): boolean {\n return this.access.unrestricted;\n }\n\n // An unresolvable id is refused without saying whether it exists.\n private async canonical(\n identifier: string,\n side: \"read\" | \"write\",\n what: string,\n signal?: AbortSignal,\n ): Promise<string> {\n try {\n return side === \"read\"\n ? await this.ids.resolveIdOrSlug(identifier, undefined, signal)\n : (await this.ids.write.describe(identifier, undefined, signal))\n .documentId;\n } catch {\n throw forbidden(what);\n }\n }\n\n /** GraphQL's assertCanRead: the id to fetch, or FORBIDDEN. */\n async read(identifier: string, signal?: AbortSignal): Promise<string> {\n if (this.access.unrestricted) return identifier;\n const what = `read ${identifier}`;\n const id = await this.canonical(identifier, \"read\", what, signal);\n if (!(await this.access.canRead(id))) throw forbidden(what);\n return id;\n }\n\n /** GraphQL's assertCanWrite: the id to write, or FORBIDDEN. */\n async write(identifier: string, signal?: AbortSignal): Promise<string> {\n if (this.access.unrestricted) return identifier;\n const what = `write to ${identifier}`;\n const id = await this.canonical(identifier, \"write\", what, signal);\n if (!(await this.access.canWrite(id))) throw forbidden(what);\n return id;\n }\n\n /** GraphQL's assertCanExecuteOperations: canMutate per action type. */\n async mutate(\n identifier: string,\n actions: readonly Pick<Action, \"type\">[],\n signal?: AbortSignal,\n ): Promise<string> {\n if (this.access.unrestricted) return identifier;\n const id = await this.canonical(\n identifier,\n \"write\",\n `change ${identifier}`,\n signal,\n );\n const decisions = new Map<string, boolean>();\n for (const { type } of actions) {\n if (!decisions.has(type)) {\n decisions.set(type, await this.access.canMutate(id, type));\n }\n }\n const denied = actions.flatMap(({ type }, index): DeniedAction[] =>\n decisions.get(type)\n ? []\n : [{ index, type, reason: `Forbidden: you may not execute ${type}` }],\n );\n if (denied.length > 0) throw new HostAccessDeniedError(denied);\n return id;\n }\n\n /** GraphQL's create rule: write on the parent, else canCreate. */\n async create(parent?: string, signal?: AbortSignal): Promise<void> {\n if (parent) {\n await this.write(parent, signal);\n return;\n }\n if (this.access.unrestricted || (await this.access.canCreate())) return;\n throw new ReactorToolError(\n \"FORBIDDEN\",\n this.access.authenticated\n ? \"Forbidden: you may not create documents\"\n : \"Authentication required to create documents\",\n );\n }\n\n async created(documentId: string): Promise<void> {\n await this.access.created?.(documentId);\n }\n\n async readable<T>(items: readonly T[], idOf: (item: T) => string) {\n if (this.access.unrestricted) return [...items];\n const decisions = new Map<string, boolean>();\n const out: T[] = [];\n for (const item of items) {\n const id = idOf(item);\n let allowed = decisions.get(id);\n if (allowed === undefined) {\n allowed = await this.access.canRead(id);\n decisions.set(id, allowed);\n }\n if (allowed) out.push(item);\n }\n return out;\n }\n\n /** The readable part of a page; an emptied page moves on, so a listing does not stop early. */\n async readablePage<T>(\n page: PagedResults<T>,\n idOf: (item: T) => string,\n ): Promise<PagedResults<T>> {\n if (this.access.unrestricted) return page;\n const results = await this.readable(page.results, idOf);\n const next = page.next;\n if (results.length === 0 && next && page.results.length > 0) {\n return this.readablePage(await next(), idOf);\n }\n return {\n ...page,\n results,\n next: next && (async () => this.readablePage(await next(), idOf)),\n };\n }\n}\n\nconst documentId = (document: PHDocument) => document.header.id;\n\ntype EvaluateActions = IReactorClient[\"write\"][\"evaluateActions\"];\n\n/** The tool client behind the host's ACL as GraphQL applies it. */\nexport class HostAccessClient implements ReactorToolClient {\n readonly write: ReactorToolWriteClient & {\n evaluateActions: EvaluateActions;\n /** Checked before deleteDocument changes anything. */\n authorizeDelete(id: string, signal?: AbortSignal): Promise<void>;\n };\n\n constructor(\n private readonly inner: ReactorToolClient & {\n readonly write: { evaluateActions: EvaluateActions };\n },\n private readonly gate: HostAccessGate,\n ) {\n const write = inner.write;\n this.write = {\n create: async (document, parentIdentifier, signal) => {\n await gate.create(parentIdentifier, signal);\n const handle = await write.create(document, parentIdentifier, signal);\n await handle.readable;\n await gate.created(handle.documentId);\n return handle;\n },\n createEmpty: async (documentType, options, signal) => {\n await gate.create(options?.parentIdentifier, signal);\n const handle = await write.createEmpty(documentType, options, signal);\n await handle.readable;\n await gate.created(handle.documentId);\n return handle;\n },\n execute: async (id, branch, actions, signal) =>\n write.execute(\n await gate.mutate(id, actions, signal),\n branch,\n actions,\n signal,\n ),\n deleteDocument: async (id, propagate, signal) =>\n write.deleteDocument(await gate.write(id, signal), propagate, signal),\n drives: {\n // GraphQL's createDocument under a drive: write on the drive.\n addFile: async (driveId, document, parentFolder, signal) => {\n const drive = await gate.write(driveId, signal);\n const handle = await write.drives.addFile(\n drive,\n document,\n parentFolder,\n signal,\n );\n await handle.readable;\n await gate.created(document.header.id);\n return handle;\n },\n },\n evaluateActions: async (id, branch, candidates, subject, signal) =>\n write.evaluateActions(\n await gate.read(id, signal),\n branch,\n candidates,\n subject,\n signal,\n ),\n authorizeDelete: (id, signal) => this.authorizeDelete(id, signal),\n };\n }\n\n // GraphQL's deleteDocument check, plus DELETE_NODE on each drive filing it,\n // up front so a refusal leaves every drive as it was.\n private async authorizeDelete(id: string, signal?: AbortSignal) {\n if (this.gate.unrestricted) return;\n const canonical = await this.gate.write(id, signal);\n const parents = await this.inner.getIncomingRelationships(\n canonical,\n \"child\",\n undefined,\n undefined,\n signal,\n );\n for (const parent of parents.results) {\n if (parent.header.documentType !== DRIVE_DOCUMENT_TYPE) continue;\n const nodes = (parent.state as DriveNodes).global?.nodes;\n if (Array.isArray(nodes) && !nodes.some((n) => n.id === canonical)) {\n continue;\n }\n try {\n await this.gate.mutate(parent.header.id, [{ type: \"DELETE_NODE\" }]);\n } catch {\n throw new ReactorToolError(\n \"FORBIDDEN\",\n `Document ${canonical} is filed in drive ${parent.header.id}, which you cannot change; it was not deleted`,\n );\n }\n }\n }\n\n async get<T extends PHDocument>(\n id: string,\n view?: ViewFilter,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.get<T>(\n await this.gate.read(id, signal),\n view,\n signal,\n consistencyToken,\n );\n }\n\n async resolveIdOrSlug(\n id: string,\n view?: ViewFilter,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.resolveIdOrSlug(\n await this.gate.read(id, signal),\n view,\n signal,\n consistencyToken,\n );\n }\n\n async find(\n search: SearchFilter,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.gate.readablePage(\n await this.inner.find(search, view, paging, signal, consistencyToken),\n documentId,\n );\n }\n\n async getOperations(\n id: string,\n view?: ViewFilter,\n filter?: OperationFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.getOperations(\n await this.gate.read(id, signal),\n view,\n filter,\n paging,\n signal,\n );\n }\n\n async getOutgoingRelationships(\n id: string,\n type: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.gate.readablePage(\n await this.inner.getOutgoingRelationships(\n await this.gate.read(id, signal),\n type,\n view,\n paging,\n signal,\n consistencyToken,\n ),\n documentId,\n );\n }\n\n async getIncomingRelationships(\n id: string,\n type: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.gate.readablePage(\n await this.inner.getIncomingRelationships(\n await this.gate.read(id, signal),\n type,\n view,\n paging,\n signal,\n consistencyToken,\n ),\n documentId,\n );\n }\n\n async getOutgoingRelationshipEdges(\n id: string,\n type?: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.gate.readablePage(\n await this.inner.getOutgoingRelationshipEdges(\n await this.gate.read(id, signal),\n type,\n view,\n paging,\n signal,\n consistencyToken,\n ),\n (edge) => edge.targetId,\n );\n }\n\n async getIncomingRelationshipEdges(\n id: string,\n type?: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.gate.readablePage(\n await this.inner.getIncomingRelationshipEdges(\n await this.gate.read(id, signal),\n type,\n view,\n paging,\n signal,\n consistencyToken,\n ),\n (edge) => edge.sourceId,\n );\n }\n\n getDocumentModelModules(\n namespace?: string,\n paging?: PagingOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.getDocumentModelModules(namespace, paging, signal);\n }\n\n getDocumentModelModule(documentType: string) {\n return this.inner.getDocumentModelModule(documentType);\n }\n\n getDocumentModelModuleForDocument(document: PHDocument) {\n return this.inner.getDocumentModelModuleForDocument(document);\n }\n\n newDocument<T extends PHDocument = PHDocument>(\n documentType: string,\n options?: NewDocumentOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.newDocument<T>(documentType, options, signal);\n }\n}\n","import type {\n ConsistencyToken,\n IReactorClient,\n NewDocumentOptions,\n OperationFilter,\n PagingOptions,\n SearchFilter,\n ViewFilter,\n} from \"@powerhousedao/reactor\";\nimport type {\n AuthSubject,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport {\n DRIVE_DOCUMENT_TYPE,\n ReactorToolError,\n type ReactorToolClient,\n type ReactorToolWriteClient,\n} from \"./tools/index.js\";\n\ntype DriveNodes = { global?: { nodes?: { id: string }[] } };\n\n// The tool subset over a full client, reading as `subject`. Writes go through\n// the write half and are judged as the client's signer.\nexport class SubjectScopedClient implements ReactorToolClient {\n readonly write: ReactorToolWriteClient & {\n evaluateActions: IReactorClient[\"write\"][\"evaluateActions\"];\n };\n\n constructor(\n private readonly inner: IReactorClient,\n private readonly subject?: AuthSubject,\n ) {\n const write = inner.write;\n this.write = {\n create: (document, parentIdentifier, signal) =>\n write.create(document, parentIdentifier, signal),\n createEmpty: (documentType, options, signal) =>\n write.createEmpty(documentType, options, signal),\n execute: (id, branch, actions, signal) =>\n write.execute(id, branch, actions, signal),\n deleteDocument: async (id, propagate, signal) => {\n await this.assertNoHiddenFiling(id, signal);\n return write.deleteDocument(id, propagate, signal);\n },\n drives: {\n addFile: (driveId, document, parentFolder, signal) =>\n write.drives.addFile(driveId, document, parentFolder, signal),\n },\n evaluateActions: (id, branch, candidates, subject, signal) =>\n write.evaluateActions(id, branch, candidates, subject, signal),\n };\n }\n\n private view(view?: ViewFilter): ViewFilter | undefined {\n return this.subject ? { ...view, subject: this.subject } : view;\n }\n\n // A drive the subject cannot read would keep a node for the deleted document.\n private async assertNoHiddenFiling(id: string, signal?: AbortSignal) {\n if (!this.subject) return;\n const parents = await this.inner.getIncomingRelationships(\n id,\n \"child\",\n undefined,\n undefined,\n signal,\n );\n // Unreadable nodes count as filing it: the delete cannot rule that out.\n const hidden = parents.results.find((parent) => {\n if (parent.header.documentType !== DRIVE_DOCUMENT_TYPE) return false;\n const nodes = (parent.state as DriveNodes).global?.nodes;\n return !Array.isArray(nodes) || nodes.some((n) => n.id === id);\n });\n if (hidden) {\n throw new ReactorToolError(\n \"FORBIDDEN\",\n `Document ${id} is filed in drive ${hidden.header.id}, which you cannot change; it was not deleted`,\n );\n }\n }\n\n get<T extends PHDocument>(\n id: string,\n view?: ViewFilter,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.get<T>(id, this.view(view), signal, consistencyToken);\n }\n\n resolveIdOrSlug(\n id: string,\n view?: ViewFilter,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.resolveIdOrSlug(\n id,\n this.view(view),\n signal,\n consistencyToken,\n );\n }\n\n find(\n search: SearchFilter,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.find(\n search,\n this.view(view),\n paging,\n signal,\n consistencyToken,\n );\n }\n\n getOperations(\n id: string,\n view?: ViewFilter,\n filter?: OperationFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.getOperations(\n id,\n this.view(view),\n filter,\n paging,\n signal,\n );\n }\n\n getOutgoingRelationships(\n id: string,\n type: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.getOutgoingRelationships(\n id,\n type,\n this.view(view),\n paging,\n signal,\n consistencyToken,\n );\n }\n\n getIncomingRelationships(\n id: string,\n type: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.getIncomingRelationships(\n id,\n type,\n this.view(view),\n paging,\n signal,\n consistencyToken,\n );\n }\n\n getOutgoingRelationshipEdges(\n id: string,\n type?: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.getOutgoingRelationshipEdges(\n id,\n type,\n this.view(view),\n paging,\n signal,\n consistencyToken,\n );\n }\n\n getIncomingRelationshipEdges(\n id: string,\n type?: string,\n view?: ViewFilter,\n paging?: PagingOptions,\n signal?: AbortSignal,\n consistencyToken?: ConsistencyToken,\n ) {\n return this.inner.getIncomingRelationshipEdges(\n id,\n type,\n this.view(view),\n paging,\n signal,\n consistencyToken,\n );\n }\n\n getDocumentModelModules(\n namespace?: string,\n paging?: PagingOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.getDocumentModelModules(namespace, paging, signal);\n }\n\n getDocumentModelModule(documentType: string) {\n return this.inner.getDocumentModelModule(documentType);\n }\n\n getDocumentModelModuleForDocument(document: PHDocument) {\n return this.inner.getDocumentModelModuleForDocument(document);\n }\n\n newDocument<T extends PHDocument = PHDocument>(\n documentType: string,\n options?: NewDocumentOptions,\n signal?: AbortSignal,\n ) {\n return this.inner.newDocument<T>(documentType, options, signal);\n }\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { IReactorClient, ISyncManager } from \"@powerhousedao/reactor\";\nimport type { AuthSubject } from \"@powerhousedao/shared/document-model\";\nimport {\n type CodegenStatusRegistry,\n getCodegenStatusRegistry,\n} from \"@powerhousedao/shared/processors\";\nimport { reactorAdminTools, type RemoteDriveAllowlist } from \"./admin-tools.js\";\nimport {\n HostAccessClient,\n HostAccessGate,\n type McpAccess,\n} from \"./host-access.js\";\nimport { SubjectScopedClient } from \"./subject-client.js\";\nimport { codegenStatusTool, reactorTools, toMcpTool } from \"./tools/index.js\";\n\nexport interface CreateServerOptions {\n client: IReactorClient;\n syncManager?: ISyncManager;\n /** Who the tools read as; omitted, the client's signer. */\n subject?: AuthSubject;\n /** The host's ACL for the caller, in front of every tool; omitted, none. */\n access?: McpAccess;\n /** URLs `addRemoteDrive` may fetch; omitted, the tool is not mounted. */\n remoteDriveUrls?: RemoteDriveAllowlist;\n /** Vetra's codegen status; the process's registry by default. */\n codegenStatus?: CodegenStatusRegistry;\n}\n\nexport 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 — 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.\n\"addActions\" returns one result per action. When \"success\" is false, the results with an \"error\" say which actions were not applied and why.\nIn Vetra, a change to a document model, editor, app, processor, subgraph or package document makes Vetra generate code from it a few seconds later; \"getCodegenStatus\" says when that is done, and why it failed or was skipped.\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`;\n\nexport function createServer(options: CreateServerOptions): Promise<McpServer> {\n const { client, syncManager, subject, access, remoteDriveUrls } = options;\n const codegenStatus = options.codegenStatus ?? getCodegenStatusRegistry();\n const server = new McpServer(\n {\n name: \"reactor-mcp-server\",\n version: \"1.0.0\",\n description: ReactorMcpInstructions,\n },\n {\n capabilities: {\n tools: {},\n resources: {\n subscribe: true,\n listChanged: true,\n },\n prompts: {\n listChanged: true,\n },\n },\n },\n );\n\n server.registerResource(\n \"instructions\",\n \"reactor://instructions\",\n {\n title: \"Instructions\",\n description: \"General instructions on how to use the tools of this MCP\",\n mimeType: \"text/plain\",\n },\n (uri) => ({\n contents: [\n {\n uri: uri.href,\n text: ReactorMcpInstructions,\n },\n ],\n }),\n );\n\n const scoped = new SubjectScopedClient(client, subject);\n const gate = access && new HostAccessGate(access, client);\n const userContext = {\n client: gate ? new HostAccessClient(scoped, gate) : scoped,\n };\n const tools = [\n ...[\n ...reactorTools({ codegenStatus }),\n codegenStatusTool(codegenStatus),\n ].map((tool) => toMcpTool(tool, userContext)),\n ...reactorAdminTools({ syncManager, remoteDriveUrls, subject, gate }).map(\n (tool) => toMcpTool(tool, { client }),\n ),\n ];\n for (const { name, callback, ...config } of tools) {\n // The records carry zod shapes the SDK accepts; its overloads cannot infer them.\n server.registerTool(name, config as any, callback as any);\n }\n\n return Promise.resolve(server);\n}\n"],"mappings":";;;;;;AAEA,MAAa,SAAkB,YAAY,CAAC,aAAa,CAAC;;;;ACsC1D,IAAa,wBAAb,cAA2C,MAAM;CAC/C;CAEA,YAAY,QAAwB;EAClC,MAAM,OAAO,EAAE,EAAE,UAAU,WAAW;EACtC,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AA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I,GACd,QACA,gBACF;CACF;CAEA,KACE,QACA,MACA,QACA,QACA,kBACA;EACA,OAAO,KAAK,MAAM,KAChB,QACA,KAAK,KAAK,IAAI,GACd,QACA,QACA,gBACF;CACF;CAEA,cACE,IACA,MACA,QACA,QACA,QACA;EACA,OAAO,KAAK,MAAM,cAChB,IACA,KAAK,KAAK,IAAI,GACd,QACA,QACA,MACF;CACF;CAEA,yBACE,IACA,MACA,MACA,QACA,QACA,kBACA;EACA,OAAO,KAAK,MAAM,yBAChB,IACA,MACA,KAAK,KAAK,IAAI,GACd,QACA,QACA,gBACF;CACF;CAEA,yBACE,IACA,MACA,MACA,QACA,QACA,kBACA;EACA,OAAO,KAAK,MAAM,yBAChB,IACA,MACA,KAAK,KAAK,IAAI,GACd,QACA,QACA,gBACF;CACF;CAEA,6BACE,IACA,MACA,MACA,QACA,QACA,kBACA;EACA,OAAO,KAAK,MAAM,6BAChB,IACA,MACA,KAAK,KAAK,IAAI,GACd,QACA,QACA,gBACF;CACF;CAEA,6BACE,IACA,MACA,MACA,QACA,QACA,kBACA;EACA,OAAO,KAAK,MAAM,6BAChB,IACA,MACA,KAAK,KAAK,IAAI,GACd,QACA,QACA,gBACF;CACF;CAEA,wBACE,WACA,QACA,QACA;EACA,OAAO,KAAK,MAAM,wBAAwB,WAAW,QAAQ,MAAM;CACrE;CAEA,uBAAuB,cAAsB;EAC3C,OAAO,KAAK,MAAM,uBAAuB,YAAY;CACvD;CAEA,kCAAkC,UAAsB;EACtD,OAAO,KAAK,MAAM,kCAAkC,QAAQ;CAC9D;CAEA,YACE,cACA,SACA,QACA;EACA,OAAO,KAAK,MAAM,YAAe,cAAc,SAAS,MAAM;CAChE;AACF;;;AC3MA,MAAa,yBAAyB;;;;;;;;;;;;;;;;;AAkBtC,SAAgB,aAAa,SAAkD;CAC7E,MAAM,EAAE,QAAQ,aAAa,SAAS,QAAQ,oBAAoB;CAClE,MAAM,gBAAgB,QAAQ,iBAAiB,yBAAyB;CACxE,MAAM,SAAS,IAAI,UACjB;EACE,MAAM;EACN,SAAS;EACT,aAAa;CACf,GACA,EACE,cAAc;EACZ,OAAO,CAAC;EACR,WAAW;GACT,WAAW;GACX,aAAa;EACf;EACA,SAAS,EACP,aAAa,KACf;CACF,EACF,CACF;CAEA,OAAO,iBACL,gBACA,0BACA;EACE,OAAO;EACP,aAAa;EACb,UAAU;CACZ,IACC,SAAS,EACR,UAAU,CACR;EACE,KAAK,IAAI;EACT,MAAM;CACR,CACF,EACF,EACF;CAEA,MAAM,SAAS,IAAI,oBAAoB,QAAQ,OAAO;CACtD,MAAM,OAAO,UAAU,IAAI,eAAe,QAAQ,MAAM;CACxD,MAAM,cAAc,EAClB,QAAQ,OAAO,IAAI,iBAAiB,QAAQ,IAAI,IAAI,OACtD;CACA,MAAM,QAAQ,CACZ,GAAG,CACD,GAAG,aAAa,EAAE,cAAc,CAAC,GACjC,kBAAkB,aAAa,CACjC,CAAC,CAAC,KAAK,SAAS,UAAU,MAAM,WAAW,CAAC,GAC5C,GAAG,kBAAkB;EAAE;EAAa;EAAiB;EAAS;CAAK,CAAC,CAAC,CAAC,KACnE,SAAS,UAAU,MAAM,EAAE,OAAO,CAAC,CACtC,CACF;CACA,KAAK,MAAM,EAAE,MAAM,UAAU,GAAG,YAAY,OAE1C,OAAO,aAAa,MAAM,QAAe,QAAe;CAG1D,OAAO,QAAQ,QAAQ,MAAM;AAC/B"}
|
package/dist/tools/index.d.mts
CHANGED
|
@@ -713,6 +713,18 @@ export declare function documentModelInfo(module: DocumentModelModule): Document
|
|
|
713
713
|
export declare function latestSpecification(module: DocumentModelModule): DocumentSpecification | undefined;
|
|
714
714
|
/** The model's operations in its latest specification, without the base ones. */
|
|
715
715
|
export declare function modelOperations(module: DocumentModelModule): ModelOperation[];
|
|
716
|
+
/** @experimental */
|
|
717
|
+
export type ResolvedOperation = {
|
|
718
|
+
readonly operation: ModelOperation;
|
|
719
|
+
readonly base: boolean;
|
|
720
|
+
readonly creatorKey?: string;
|
|
721
|
+
};
|
|
722
|
+
/**
|
|
723
|
+
* @experimental The operation an action type names: a base action the base
|
|
724
|
+
* reducer reduces itself, else the model's own (by stored name, then by action
|
|
725
|
+
* type), else the base NOOP.
|
|
726
|
+
*/
|
|
727
|
+
export declare function resolveOperation(module: DocumentModelModule, type: string): ResolvedOperation | undefined;
|
|
716
728
|
/** Every action type the document accepts: the model's and the base ones. */
|
|
717
729
|
export declare function actionOperations(module: DocumentModelModule): ModelOperation[];
|
|
718
730
|
export declare const documentModelSummarySchema: z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/tools/client.ts","../../src/tools/errors.ts","../../src/tools/definition.ts","../../src/tools/validation.ts","../../src/tools/operations.ts","../../src/tools/codegen.ts","../../src/tools/compact-schema.ts","../../src/tools/documents.ts","../../src/tools/jsonpath.ts","../../src/tools/reactor.ts","../../src/tools/schema.ts","../../src/tools/suggest.ts"],"mappings":";;;;;;YAQY;YAaA;;YAOA,yBAAyB,KACnC,qBACA;WAES,QAAQ,KAAK;;YAIZ,oBAAoB,KAC9B,gBACA;WAES,OAAO;;YAGN,wBAAwB,KAClC,gBACA;;;qBC7CW;YAQD,+BAA+B;;YAG/B;EACV;EACA;EACA,MAAM,QACJ;EAGF;;qBAGW,yBAAyB;WAC3B,MAAM;WACN,WAAW;EAEpB,YACE,MAAM,sBACN,iBACA;IAAW,WAAW;IAAiB;;EAQzC;IACE,MAAM;IACN;IACA,WAAW;;;wBAUC,mBAAmB,iBAAiB,SAAS;;wBA2C7C,mBACd,gBACA,WAAU,uBACT;wBA6Ba,SAAS,kBAAkB;;;;YCtH/B;EACV;EACA;EACA;EACA;EACA;;YAGU,YAAY,IAAI;EAC1B,QAAQ;EACR,SAAS;;YAKC,eACV,UAAU,EAAE,YAAY,EAAE,WAC1B,UAAU,EAAE,YAAY,EAAE,WAC1B,IAAI,mBACJ;EAEA,MAAM;EACN;EACA;EACA,aAAa;EACb,cAAc;EACd,aAAa;EACb,UAAU,MAAM,EAAE,MAAM,IAAI,KAAK,YAAY,OAAO,QAAQ,EAAE,MAAM;;YAI1D,kBAAkB,IAAI;EAChC;EACA;EACA;EACA,aAAa,EAAE;EACf,cAAc,EAAE;EAChB,aAAa;EACb,UAAU,aAAa,KAAK,YAAY,OAAO;;wBAGjC,WACd,UAAU,EAAE,WACZ,UAAU,EAAE,WACZ,kBACA,IAAI,mBACJ,YAAY,eAAe,GAAG,GAAG,GAAG,KAAK,eAAe,GAAG,GAAG,GAAG;;wBAKnD,YAAY,cAAc;;wBAK1B,gBAAgB,OAAO;YAI3B,cAAc,UAAU;EAClC,MAAM;EACN;EACA;EACA,aAAa;EACb,cAAc;EACd,aAAa;EACb,WACE,MAAM,EAAE,MAAM,mBACd;IAAU,SAAS;QAChB,QAAQ;;;wBAMC,UAAU,UAAU,kBAAkB,IAAI,GACxD,YAAY,GACZ,KAAK,YAAY,KAChB,cAAc;;YAkCL,UAAU,UAAU;EAC9B;EACA;EACA,aAAa;EACb,cAAc;EACd,UACE,MAAM,EAAE,MAAM,mBACd;IAAY,cAAc;QACvB,QAAQ,EAAE,MAAM;;YAGX,aAAa,UAAU,+BAChC,KAAK,YAAY,UAAU,QAAQ;EAAK,MAAM;;;wBAIjC,aAAa,UAAU,kBAAkB,IAAI,GAC3D,sBAAsB,KACtB,KAAK,YAAY,KAChB,aAAa;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/tools/client.ts","../../src/tools/errors.ts","../../src/tools/definition.ts","../../src/tools/validation.ts","../../src/tools/operations.ts","../../src/tools/codegen.ts","../../src/tools/compact-schema.ts","../../src/tools/documents.ts","../../src/tools/jsonpath.ts","../../src/tools/reactor.ts","../../src/tools/schema.ts","../../src/tools/suggest.ts"],"mappings":";;;;;;YAQY;YAaA;;YAOA,yBAAyB,KACnC,qBACA;WAES,QAAQ,KAAK;;YAIZ,oBAAoB,KAC9B,gBACA;WAES,OAAO;;YAGN,wBAAwB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d,QAAQ,sBACP;qBAiBU,sBAAoB,EAAA;;;;;;;;;;GAI/B,EAAA,KAAA;YAEU,iBAAiB,EAAE,aAAa;;wBAG5B,qBACd,QAAQ,qBACR,wBACC;qBA6CU,kBAAgB,EAAA;;;;GAI3B,EAAA,KAAA;YAEU,aAAa,EAAE,aAAa;;wBAGxB,iBACd,QAAQ,qBACR,6BACC;;;;wBCtOa,aACd,eACA,+BACA;;wBAsBc,oBACd,iBACA,eACA,+BACA;EAAW;EAAqB;EAAsB"}
|
package/dist/tools/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { ANY_SCOPE, BASE_OPERATIONS, DEFAULT_BRANCH, DEFAULT_TRIM_LIMITS, DRIVE_DOCUMENT_TYPE, DRIVE_DOCUMENT_TYPES, JsonPathError, MAX_FILTERED_CHARS, REACTOR_TOOL_ERROR_CODES, ReactorToolError, actionFailuresError, actionInputSchema, actionOperations, addActionsTool, aliasParam, applyJsonPath, codegenHint, codegenStatusTool, compactDocumentModelSchema, compactDocumentModelSchemaSchema, createAddActionsTool, createDocument, createDocumentTool, defineTool, deleteDocument, deleteDocumentTool, documentModelInfo, documentModelInfoSchema, documentModelSummary, documentModelSummarySchema, documentName, documentSummary, documentSummarySchema, documentView, documentViewSchema, executeActions, executeBuiltActions, formatActionFailures, formatToolError, getDocument, getDocumentModel, getDocumentModelForDocument, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, isReactorToolError, isWriteTool, latestSpecification, modelOperationSchema, modelOperations, notFound, operationSchemaSlice, operationSliceSchema, parseJsonPath, queryJsonPath, reactorTools, stateSchemaSlice, stateSliceSchema, suggestNames, targetId, targetParam, toAiSdkTools, toMcpTool, toReactorToolError, trimValue, unknownValueMessage, validateActions };
|
|
1
|
+
import { $ as trimValue, A as documentModelInfoSchema, B as stateSliceSchema, C as actionInputSchema, D as BASE_OPERATIONS, E as ANY_SCOPE, F as modelOperations, G as DRIVE_DOCUMENT_TYPE, H as unknownValueMessage, I as operationSchemaSlice, J as documentName, K as DRIVE_DOCUMENT_TYPES, L as operationSliceSchema, M as documentModelSummarySchema, N as latestSpecification, O as actionOperations, P as modelOperationSchema, Q as documentViewSchema, R as resolveOperation, S as actionFailuresError, T as validateActions, U as DEFAULT_BRANCH, V as suggestNames, W as DEFAULT_TRIM_LIMITS, X as documentSummarySchema, Y as documentSummary, Z as documentView, _ as executeActions, _t as toReactorToolError, a as deleteDocumentTool, at as compactDocumentModelSchemaSchema, b as getDocumentModel, c as getDocumentTool, ct as defineTool, d as getDrivesTool, dt as toAiSdkTools, et as JsonPathError, f as reactorTools, ft as toMcpTool, g as deleteDocument, gt as notFound, h as createDocument, ht as isReactorToolError, i as createDocumentTool, it as compactDocumentModelSchema, j as documentModelSummary, k as documentModelInfo, l as getDocumentsTool, lt as formatToolError, m as targetParam, mt as ReactorToolError, n as aliasParam, nt as parseJsonPath, o as getDocumentModelSchemaTool, ot as codegenHint, p as targetId, pt as REACTOR_TOOL_ERROR_CODES, q as MAX_FILTERED_CHARS, r as createAddActionsTool, rt as queryJsonPath, s as getDocumentModelsTool, st as codegenStatusTool, t as addActionsTool, tt as applyJsonPath, u as getDriveTool, ut as isWriteTool, v as executeBuiltActions, w as formatActionFailures, x as getDocumentModelForDocument, y as getDocument, z as stateSchemaSlice } from "../tools-UCPB56U4.mjs";
|
|
2
|
+
export { ANY_SCOPE, BASE_OPERATIONS, DEFAULT_BRANCH, DEFAULT_TRIM_LIMITS, DRIVE_DOCUMENT_TYPE, DRIVE_DOCUMENT_TYPES, JsonPathError, MAX_FILTERED_CHARS, REACTOR_TOOL_ERROR_CODES, ReactorToolError, actionFailuresError, actionInputSchema, actionOperations, addActionsTool, aliasParam, applyJsonPath, codegenHint, codegenStatusTool, compactDocumentModelSchema, compactDocumentModelSchemaSchema, createAddActionsTool, createDocument, createDocumentTool, defineTool, deleteDocument, deleteDocumentTool, documentModelInfo, documentModelInfoSchema, documentModelSummary, documentModelSummarySchema, documentName, documentSummary, documentSummarySchema, documentView, documentViewSchema, executeActions, executeBuiltActions, formatActionFailures, formatToolError, getDocument, getDocumentModel, getDocumentModelForDocument, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, isReactorToolError, isWriteTool, latestSpecification, modelOperationSchema, modelOperations, notFound, operationSchemaSlice, operationSliceSchema, parseJsonPath, queryJsonPath, reactorTools, resolveOperation, stateSchemaSlice, stateSliceSchema, suggestNames, targetId, targetParam, toAiSdkTools, toMcpTool, toReactorToolError, trimValue, unknownValueMessage, validateActions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { childLogger, inspectDocumentModelDefinition } from "document-model";
|
|
1
|
+
import { childLogger, inspectDocumentModelDefinition, operationsByActionType } from "document-model";
|
|
2
2
|
import { deleteNode } from "@powerhousedao/shared/document-drive";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { DOCUMENT_SCOPE_ACTION_TYPES, baseActions, creationState, operationOutcome, stateReducerOf, undoCapabilitiesOf, undoNeedsTargets, undoRedoBatch } from "@powerhousedao/shared/document-model";
|
|
@@ -642,6 +642,36 @@ function documentView(document, options = {}) {
|
|
|
642
642
|
};
|
|
643
643
|
}
|
|
644
644
|
//#endregion
|
|
645
|
+
//#region src/tools/model-operations.ts
|
|
646
|
+
const logger = childLogger(["reactor-mcp", "model-operations"]);
|
|
647
|
+
const logged = /* @__PURE__ */ new Set();
|
|
648
|
+
function inspect(module) {
|
|
649
|
+
const inspection = inspectDocumentModelDefinition(module);
|
|
650
|
+
if ("diagnostics" in inspection) {
|
|
651
|
+
const documentType = module.documentModel.global.id;
|
|
652
|
+
const key = `${documentType}\n${inspection.reason}`;
|
|
653
|
+
if (!logged.has(key)) {
|
|
654
|
+
logged.add(key);
|
|
655
|
+
logger.warn("Serving @type from its stored model; its definition is @reason: @diagnostics", documentType, inspection.reason, inspection.diagnostics.map((d) => d.message).join("; "));
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return inspection;
|
|
659
|
+
}
|
|
660
|
+
function structuredDefinition(module) {
|
|
661
|
+
const inspection = inspect(module);
|
|
662
|
+
return inspection.kind === "structured" ? inspection.definition : null;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* The operations of a model authored in code, keyed by action type; empty for
|
|
666
|
+
* a model served from its stored specification. Callers consult it only for a
|
|
667
|
+
* type that names no stored operation, so every stored name keeps main's
|
|
668
|
+
* meaning.
|
|
669
|
+
*/
|
|
670
|
+
function operationsByActionType$1(module) {
|
|
671
|
+
inspect(module);
|
|
672
|
+
return operationsByActionType(module);
|
|
673
|
+
}
|
|
674
|
+
//#endregion
|
|
645
675
|
//#region src/tools/suggest.ts
|
|
646
676
|
function isSubsequence(needle, haystack) {
|
|
647
677
|
let i = 0;
|
|
@@ -698,48 +728,6 @@ function unknownValueMessage(subject, value, candidates, options = {}) {
|
|
|
698
728
|
return lines.join("\n");
|
|
699
729
|
}
|
|
700
730
|
//#endregion
|
|
701
|
-
//#region src/tools/model-operations.ts
|
|
702
|
-
const logger = childLogger(["reactor-mcp", "model-operations"]);
|
|
703
|
-
const logged = /* @__PURE__ */ new Set();
|
|
704
|
-
function inspect(module) {
|
|
705
|
-
const inspection = inspectDocumentModelDefinition(module);
|
|
706
|
-
if ("diagnostics" in inspection) {
|
|
707
|
-
const documentType = module.documentModel.global.id;
|
|
708
|
-
const key = `${documentType}\n${inspection.reason}`;
|
|
709
|
-
if (!logged.has(key)) {
|
|
710
|
-
logged.add(key);
|
|
711
|
-
logger.warn("Serving @type from its stored model; its definition is @reason: @diagnostics", documentType, inspection.reason, inspection.diagnostics.map((d) => d.message).join("; "));
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
return inspection;
|
|
715
|
-
}
|
|
716
|
-
function structuredDefinition(module) {
|
|
717
|
-
const inspection = inspect(module);
|
|
718
|
-
return inspection.kind === "structured" ? inspection.definition : null;
|
|
719
|
-
}
|
|
720
|
-
const indexes = /* @__PURE__ */ new WeakMap();
|
|
721
|
-
const NONE = /* @__PURE__ */ new Map();
|
|
722
|
-
/**
|
|
723
|
-
* The operations of a model authored in code, keyed by action type; empty for
|
|
724
|
-
* a model served from its stored specification. Callers consult it only for a
|
|
725
|
-
* type that names no stored operation, so every stored name keeps main's
|
|
726
|
-
* meaning.
|
|
727
|
-
*/
|
|
728
|
-
function operationsByActionType(module) {
|
|
729
|
-
const inspection = inspect(module);
|
|
730
|
-
if (inspection.kind !== "structured") return NONE;
|
|
731
|
-
const { specification } = inspection;
|
|
732
|
-
let byActionType = indexes.get(specification);
|
|
733
|
-
if (byActionType === void 0) {
|
|
734
|
-
byActionType = new Map(specification.modules.flatMap((m) => m.operations).map((operation) => [operation.actionType, {
|
|
735
|
-
storedName: operation.name ?? operation.actionType,
|
|
736
|
-
creatorKey: operation.creatorKey
|
|
737
|
-
}]));
|
|
738
|
-
indexes.set(specification, byActionType);
|
|
739
|
-
}
|
|
740
|
-
return byActionType;
|
|
741
|
-
}
|
|
742
|
-
//#endregion
|
|
743
731
|
//#region src/tools/schema.ts
|
|
744
732
|
/** Marks a base action that runs in whichever scope it is sent to; never itself a scope. */
|
|
745
733
|
const ANY_SCOPE = "any";
|
|
@@ -818,6 +806,36 @@ function modelOperations(module) {
|
|
|
818
806
|
...op.schema ? { schema: op.schema } : {}
|
|
819
807
|
})));
|
|
820
808
|
}
|
|
809
|
+
const MODEL_SHADOWS_BASE = /* @__PURE__ */ new Set(["NOOP"]);
|
|
810
|
+
/**
|
|
811
|
+
* @experimental The operation an action type names: a base action the base
|
|
812
|
+
* reducer reduces itself, else the model's own (by stored name, then by action
|
|
813
|
+
* type), else the base NOOP.
|
|
814
|
+
*/
|
|
815
|
+
function resolveOperation(module, type) {
|
|
816
|
+
const base = BASE_OPERATIONS.find((op) => op.name === type);
|
|
817
|
+
if (base && !MODEL_SHADOWS_BASE.has(type)) return {
|
|
818
|
+
operation: base,
|
|
819
|
+
base: true
|
|
820
|
+
};
|
|
821
|
+
const own = modelOperations(module);
|
|
822
|
+
const byName = own.find((op) => op.name === type);
|
|
823
|
+
if (byName) return {
|
|
824
|
+
operation: byName,
|
|
825
|
+
base: false
|
|
826
|
+
};
|
|
827
|
+
const structured = operationsByActionType$1(module).get(type);
|
|
828
|
+
const byActionType = structured && own.find((op) => op.name === structured.storedName);
|
|
829
|
+
if (structured && byActionType) return {
|
|
830
|
+
operation: byActionType,
|
|
831
|
+
base: false,
|
|
832
|
+
creatorKey: structured.creatorKey
|
|
833
|
+
};
|
|
834
|
+
return base && {
|
|
835
|
+
operation: base,
|
|
836
|
+
base: true
|
|
837
|
+
};
|
|
838
|
+
}
|
|
821
839
|
/** Every action type the document accepts: the model's and the base ones. */
|
|
822
840
|
function actionOperations(module) {
|
|
823
841
|
return [...modelOperations(module), ...BASE_OPERATIONS];
|
|
@@ -853,10 +871,8 @@ const operationSliceSchema = modelOperationSchema.extend({ errors: z.array(z.obj
|
|
|
853
871
|
})).optional() });
|
|
854
872
|
/** One operation's input schema; unknown names fail with did-you-mean. */
|
|
855
873
|
function operationSchemaSlice(module, operationName) {
|
|
856
|
-
const
|
|
857
|
-
|
|
858
|
-
const operation = operations.find((op) => op.name === operationName) ?? operations.find((op) => op.name === storedName);
|
|
859
|
-
if (!operation) throw new ReactorToolError("NOT_FOUND", unknownValueMessage("operation", operationName, operations.map((op) => op.name), {
|
|
874
|
+
const operation = resolveOperation(module, operationName)?.operation;
|
|
875
|
+
if (!operation) throw new ReactorToolError("NOT_FOUND", unknownValueMessage("operation", operationName, actionOperations(module).map((op) => op.name), {
|
|
860
876
|
context: `for ${module.documentModel.global.id}`,
|
|
861
877
|
knownLabel: "Valid action types"
|
|
862
878
|
}));
|
|
@@ -929,8 +945,6 @@ function issueLines(error) {
|
|
|
929
945
|
}
|
|
930
946
|
/** Builds the actions, collecting every failure instead of stopping at the first. */
|
|
931
947
|
function validateActions(module, inputs, options = {}) {
|
|
932
|
-
const operations = new Map(actionOperations(module).map((o) => [o.name, o]));
|
|
933
|
-
const byActionType = operationsByActionType(module);
|
|
934
948
|
const allowed = options.allowedActionTypes ? new Set(options.allowedActionTypes) : void 0;
|
|
935
949
|
const actions = [];
|
|
936
950
|
const failures = [];
|
|
@@ -943,14 +957,14 @@ function validateActions(module, inputs, options = {}) {
|
|
|
943
957
|
});
|
|
944
958
|
if (DOCUMENT_SCOPE_ACTION_TYPES.has(entry.type)) return fail("FORBIDDEN", ["document lifecycle actions are refused; use createDocument or deleteDocument"]);
|
|
945
959
|
if (allowed && !allowed.has(entry.type)) return fail("FORBIDDEN", [`not an allowed action type (allowed: ${[...allowed].join(", ")})`]);
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
960
|
+
const resolved = resolveOperation(module, entry.type);
|
|
961
|
+
if (!resolved) return fail("INVALID_ACTION", ["unknown action type"]);
|
|
962
|
+
const { operation } = resolved;
|
|
949
963
|
if (entry.scope === "any") return fail("INVALID_ACTION", [`"any" is not a scope; name one, e.g. "global"`]);
|
|
950
964
|
const anyScope = operation.scope === "any";
|
|
951
965
|
const scope = entry.scope ?? (anyScope ? "global" : operation.scope);
|
|
952
966
|
if (!anyScope && scope !== operation.scope) return fail("INVALID_ACTION", [`scope "${scope}" does not match the operation's scope "${operation.scope}"`]);
|
|
953
|
-
const creator = BASE_CREATORS[entry.type]
|
|
967
|
+
const creator = resolved.base ? BASE_CREATORS[entry.type] : module.actions[resolved.creatorKey ?? camelCase(entry.type)];
|
|
954
968
|
if (!creator) return fail("INVALID_ACTION", [`the model has no action creator for ${entry.type}`]);
|
|
955
969
|
try {
|
|
956
970
|
actions.push({
|
|
@@ -970,8 +984,7 @@ function validateActions(module, inputs, options = {}) {
|
|
|
970
984
|
function formatActionFailures(failures, module) {
|
|
971
985
|
const operations = module ? actionOperations(module) : [];
|
|
972
986
|
const names = operations.map((o) => o.name);
|
|
973
|
-
const
|
|
974
|
-
const nameOf = (type) => names.includes(type) ? type : byActionType?.get(type)?.storedName ?? type;
|
|
987
|
+
const nameOf = (type) => (module && resolveOperation(module, type)?.operation.name) ?? type;
|
|
975
988
|
const count = failures.length;
|
|
976
989
|
const lines = failures.map((f) => ` [${f.index}] ${f.type}: ${f.errors.join("; ")}`);
|
|
977
990
|
const sections = [];
|
|
@@ -1129,7 +1142,8 @@ function modelErrorFinder(module, actionType) {
|
|
|
1129
1142
|
code: code?.trim() || className
|
|
1130
1143
|
}];
|
|
1131
1144
|
});
|
|
1132
|
-
const
|
|
1145
|
+
const ownName = resolveOperation(module, actionType)?.operation.name;
|
|
1146
|
+
const candidates = [...declared(operations.find((o) => o.name === ownName)?.errors ?? []), ...declared(operations.flatMap((o) => o.errors))];
|
|
1133
1147
|
return (name, code, message) => candidates.find((e) => code !== void 0 && e.code === code) ?? candidates.find((e) => name !== void 0 && e.name === name) ?? candidates.find((e) => e.name === message);
|
|
1134
1148
|
}
|
|
1135
1149
|
function outcomeError(outcome, module, actionType) {
|
|
@@ -1695,6 +1709,6 @@ function reactorTools(options = {}) {
|
|
|
1695
1709
|
];
|
|
1696
1710
|
}
|
|
1697
1711
|
//#endregion
|
|
1698
|
-
export {
|
|
1712
|
+
export { trimValue as $, documentModelInfoSchema as A, stateSliceSchema as B, actionInputSchema as C, BASE_OPERATIONS as D, ANY_SCOPE as E, modelOperations as F, DRIVE_DOCUMENT_TYPE as G, unknownValueMessage as H, operationSchemaSlice as I, documentName as J, DRIVE_DOCUMENT_TYPES as K, operationSliceSchema as L, documentModelSummarySchema as M, latestSpecification as N, actionOperations as O, modelOperationSchema as P, documentViewSchema as Q, resolveOperation as R, actionFailuresError as S, validateActions as T, DEFAULT_BRANCH as U, suggestNames as V, DEFAULT_TRIM_LIMITS as W, documentSummarySchema as X, documentSummary as Y, documentView as Z, executeActions as _, toReactorToolError as _t, deleteDocumentTool as a, compactDocumentModelSchemaSchema as at, getDocumentModel as b, getDocumentTool as c, defineTool as ct, getDrivesTool as d, toAiSdkTools as dt, JsonPathError as et, reactorTools as f, toMcpTool as ft, deleteDocument as g, notFound as gt, createDocument as h, isReactorToolError as ht, createDocumentTool as i, compactDocumentModelSchema as it, documentModelSummary as j, documentModelInfo as k, getDocumentsTool as l, formatToolError as lt, targetParam as m, ReactorToolError as mt, aliasParam as n, parseJsonPath as nt, getDocumentModelSchemaTool as o, codegenHint as ot, targetId as p, REACTOR_TOOL_ERROR_CODES as pt, MAX_FILTERED_CHARS as q, createAddActionsTool as r, queryJsonPath as rt, getDocumentModelsTool as s, codegenStatusTool as st, addActionsTool as t, applyJsonPath as tt, getDriveTool as u, isWriteTool as ut, executeBuiltActions as v, formatActionFailures as w, getDocumentModelForDocument as x, getDocument as y, stateSchemaSlice as z };
|
|
1699
1713
|
|
|
1700
|
-
//# sourceMappingURL=tools-
|
|
1714
|
+
//# sourceMappingURL=tools-UCPB56U4.mjs.map
|