@powerhousedao/reactor-mcp 6.2.3-dev.78 → 6.2.3-dev.79

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactor-Cku02YAV.mjs","names":[],"sources":["../src/tools/compact-schema.ts","../src/tools/utils.ts","../src/tools/reactor.ts"],"sourcesContent":["import type { DocumentModelGlobalState } from \"@powerhousedao/shared/document-model\";\n\nexport type CompactDocumentModelSchema = {\n id: string;\n name: string;\n version: number;\n /** One entry per operation: what `addActions` takes as `type`, `scope` and `input`. */\n actions: {\n type: string;\n scope: string;\n /** The input's GraphQL definition, or `null` for an action without input. */\n input: string | null;\n }[];\n /** Definitions of the enums and types the inputs reference from the state schemas. */\n types?: Record<string, string>;\n};\n\nconst BUILTIN_SCALARS = new Set([\"String\", \"Int\", \"Float\", \"Boolean\", \"ID\"]);\n\nfunction stripComments(source: string) {\n return source\n .replace(/\"\"\"[\\s\\S]*?\"\"\"/g, \"\")\n .replace(/\"[^\"\\n]*\"/g, \"\")\n .replace(/#[^\\n]*/g, \"\");\n}\n\nfunction collapse(definition: string) {\n return stripComments(definition).replace(/\\s+/g, \" \").trim();\n}\n\n/** Named enum, input, type and union definitions in a GraphQL source. */\nfunction definitionsOf(source: string) {\n const definitions = new Map<string, string>();\n const pattern =\n /\\b(?:enum|input|type)\\s+(\\w+)[^{]*\\{[^}]*\\}|\\bunion\\s+(\\w+)\\s*=\\s*\\|?\\s*\\w+(?:\\s*\\|\\s*\\w+)*/g;\n for (const [definition, name, unionName] of stripComments(source).matchAll(\n pattern,\n )) {\n // An unmatched group is undefined at runtime, whatever its type says.\n definitions.set(name || unionName, collapse(definition));\n }\n return definitions;\n}\n\nfunction referencedNames(definition: string) {\n const names = new Set<string>();\n for (const match of definition.matchAll(/:\\s*\\[?\\s*(\\w+)/g)) {\n names.add(match[1]);\n }\n for (const match of definition.matchAll(/=\\s*([\\w\\s|]+)/g)) {\n for (const name of match[1].split(\"|\")) names.add(name.trim());\n }\n return names;\n}\n\n/** The parts of a document model's latest specification that writing actions needs. */\nexport function compactDocumentModelSchema(\n model: DocumentModelGlobalState,\n): CompactDocumentModelSchema {\n const spec = model.specifications.at(-1);\n const operations = spec?.modules.flatMap((module) => module.operations) ?? [];\n const stateDefinitions = definitionsOf(\n Object.values(spec?.state ?? {})\n .map((state) => state.schema)\n .join(\"\\n\"),\n );\n\n const types: Record<string, string> = {};\n const visit = (definition: string, local: Map<string, string>) => {\n for (const name of referencedNames(definition)) {\n if (BUILTIN_SCALARS.has(name) || local.has(name) || name in types) {\n continue;\n }\n const referenced = stateDefinitions.get(name);\n if (!referenced) continue;\n types[name] = referenced;\n visit(referenced, local);\n }\n };\n\n const actions = operations.flatMap((operation) => {\n if (!operation.name) return [];\n const input = operation.schema ? collapse(operation.schema) : null;\n if (operation.schema)\n visit(operation.schema, definitionsOf(operation.schema));\n return [{ type: operation.name, scope: operation.scope, input }];\n });\n\n return {\n id: model.id,\n name: model.name,\n version: spec?.version ?? 1,\n actions,\n ...(Object.keys(types).length ? { types } : {}),\n };\n}\n","import type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { camelCase } from \"change-case\";\nimport type {\n Action,\n DocumentModelModule,\n Operation,\n} from \"@powerhousedao/shared/document-model\";\nimport { baseActions } from \"@powerhousedao/shared/document-model\";\nimport type { z } from \"zod\";\nimport type { ResolveZodSchema, ToolSchema } from \"./types.js\";\n\nexport class InvalidToolOutputError extends Error {\n constructor(zodError: z.ZodError) {\n super(\"Invalid tool output\\n\" + zodError.message);\n this.name = \"InvalidToolOutputError\";\n this.cause = zodError;\n }\n}\n\n/**\n * Creates a tool with a callback function that handles the tool execution,\n * ensuring the output is valid and errors are handled and returned correctly.\n * @param tool The tool schema to wrap.\n * @param toolCallback The callback function to execute when the tool is called.\n * @returns A CallToolResult with structuredContent if OutputSchema is defined or content if undefined. If the\n * callback throws an error, the result will have isError set to true and the error message in the content.\n */\nexport function toolWithCallback<T extends ToolSchema>(\n tool: T,\n toolCallback: (\n args: ResolveZodSchema<T[\"inputSchema\"]>,\n ) =>\n | ResolveZodSchema<T[\"outputSchema\"]>\n | Promise<ResolveZodSchema<T[\"outputSchema\"]>>,\n) {\n const wrappedCallback = async (\n args: ResolveZodSchema<T[\"inputSchema\"]>,\n ): Promise<CallToolResult> => {\n try {\n const result = await toolCallback(args);\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(result),\n },\n ],\n structuredContent: result,\n } as const satisfies CallToolResult;\n } catch (error) {\n const errorString =\n error instanceof Error ? error.message : String(error);\n return {\n isError: true,\n content: [\n {\n type: \"text\",\n text: `Error: ${errorString}`,\n },\n ],\n } as const satisfies CallToolResult;\n }\n };\n return {\n ...tool,\n callback: wrappedCallback,\n };\n}\n\nexport function validateDocumentModelAction(\n documentModelModule: DocumentModelModule,\n action: Action,\n): { isValid: boolean; errors: string[] } {\n const errors: string[] = [];\n\n const globalState = documentModelModule.documentModel.global;\n\n // Get the latest specification\n if (!globalState.specifications || globalState.specifications.length === 0) {\n errors.push(\"Document model has no specifications\");\n return { isValid: false, errors };\n }\n\n const latestSpec =\n globalState.specifications[globalState.specifications.length - 1];\n\n // Search through modules to find the operation that matches the action type (in SCREAMING_SNAKE_CASE)\n let operation: (Operation & { scope: string }) | null = null;\n\n for (const module of latestSpec.modules) {\n const unsafeOperationOrActionOrSomething = module.operations.find(\n (op) => op.name === action.type,\n ) as unknown as Operation & { scope: string };\n if (unsafeOperationOrActionOrSomething) {\n operation = unsafeOperationOrActionOrSomething;\n break;\n }\n }\n\n if (!operation) {\n errors.push(\n `Operation \"${action.type}\" is not defined in any module of the document model`,\n );\n return { isValid: false, errors };\n }\n\n // Convert action type from SCREAMING_SNAKE_CASE to camelCase to match action creators\n const camelCaseActionType = camelCase(action.type);\n\n // Check if action creator exists in documentModelModule.actions\n const actionCreator = documentModelModule.actions[camelCaseActionType];\n\n if (!actionCreator) {\n errors.push(\n `Action creator \"${camelCaseActionType}\" for action type \"${action.type}\" is not defined in documentModelDocumentModelModule.actions`,\n );\n return { isValid: false, errors };\n }\n\n // Validate the operation using the action creator. TODO: Use document model exported validators directly\n let inputError: Error | null = null;\n try {\n actionCreator(action.input);\n } catch (e) {\n inputError = e instanceof Error ? e : new Error(JSON.stringify(e));\n }\n\n if (inputError) {\n errors.push(`Input validation error: ${inputError.message}`);\n }\n\n // Validate scope if operation defines one\n if (operation.scope && action.scope !== operation.scope) {\n errors.push(\n `Action scope \"${action.scope}\" does not match operation scope \"${operation.scope}\"`,\n );\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n };\n}\n\n/** The scope each base action must carry; `null` means any scope of the document. */\nconst BASE_ACTION_SCOPES: Record<string, string | null> = {\n SET_NAME: \"global\",\n SET_PREFERRED_EDITOR: \"header\",\n UNDO: null,\n REDO: null,\n NOOP: null,\n};\n\nfunction countInput(input: unknown): number | undefined {\n if (typeof input === \"number\") return input;\n if (\n typeof input === \"object\" &&\n input !== null &&\n \"count\" in input &&\n typeof input.count === \"number\"\n ) {\n return input.count;\n }\n return undefined;\n}\n\n/**\n * Builds a document-model base action (SET_NAME, SET_PREFERRED_EDITOR, UNDO,\n * REDO, NOOP) with its action creator. Returns `null` for any other type.\n */\nexport function createBaseAction(\n type: string,\n input: unknown,\n scope: string,\n): { action: Action | null; errors: string[] } | null {\n if (!Object.hasOwn(BASE_ACTION_SCOPES, type)) return null;\n\n const expectedScope = BASE_ACTION_SCOPES[type];\n if (expectedScope !== null && scope !== expectedScope) {\n return {\n action: null,\n errors: [\n `Action scope \"${scope}\" does not match operation scope \"${expectedScope}\"`,\n ],\n };\n }\n\n try {\n switch (type) {\n case \"SET_NAME\":\n return {\n action: baseActions.setName(input as string | { name: string }),\n errors: [],\n };\n case \"SET_PREFERRED_EDITOR\":\n return {\n action: baseActions.setPreferredEditor(\n input as string | null | { preferredEditor: string | null },\n ),\n errors: [],\n };\n case \"UNDO\":\n return {\n action: baseActions.undo(countInput(input), scope),\n errors: [],\n };\n case \"REDO\":\n return {\n action: baseActions.redo(countInput(input), scope),\n errors: [],\n };\n default:\n return { action: baseActions.noop(scope), errors: [] };\n }\n } catch (e) {\n const message = e instanceof Error ? e.message : JSON.stringify(e);\n return { action: null, errors: [`Input validation error: ${message}`] };\n }\n}\n","import type {\n IReactorClient,\n ISyncManager,\n JobFailedError,\n PagingOptions,\n WriteHandle,\n WriteReceipt,\n} from \"@powerhousedao/reactor\";\nimport { DriveCollectionId } from \"@powerhousedao/reactor\";\nimport type { DocumentDriveDocument } from \"@powerhousedao/shared/document-drive\";\nimport {\n setAvailableOffline,\n setDriveIcon,\n setDriveName,\n setSharingType,\n} from \"@powerhousedao/shared/document-drive\";\nimport type {\n Action,\n AuthSubject,\n DocumentModelModule,\n OperationOutcome,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport {\n createAction,\n operationOutcome,\n} from \"@powerhousedao/shared/document-model\";\nimport {\n type CodegenStatusRegistry,\n getCodegenStatusRegistry,\n} from \"@powerhousedao/shared/processors\";\nimport { pascalCase } from \"change-case\";\nimport { z } from \"zod\";\nimport { compactDocumentModelSchema } from \"./compact-schema.js\";\nimport type { ToolSchema, ToolWithCallback } from \"./types.js\";\nimport {\n createBaseAction,\n toolWithCallback,\n validateDocumentModelAction,\n} from \"./utils.js\";\n\nconst DRIVE_DOCUMENT_TYPE = \"powerhouse/document-drive\";\n\n/** The parameter every tool names its target document or drive by. */\nconst TARGET = \"documentId\";\n\nconst targetParam = (what: string) =>\n z.string().optional().describe(`ID or slug of the ${what}. Required.`);\nconst aliasParam = z.string().optional().describe(`Alias of \\`${TARGET}\\``);\n\n/** The target named by `documentId` or one of its aliases; they must agree. */\nfunction targetId(\n tool: string,\n params: Record<string, unknown>,\n aliases: string[],\n): string {\n const given = new Set(\n [TARGET, ...aliases]\n .map((name) => params[name])\n .filter((id): id is string => typeof id === \"string\" && id !== \"\"),\n );\n if (given.size > 1) {\n throw new Error(\n `${tool} got different IDs in \\`${TARGET}\\` and its aliases (${aliases.map((a) => `\\`${a}\\``).join(\", \")}); pass only \\`${TARGET}\\``,\n );\n }\n const [id] = given;\n if (!id) {\n throw new Error(`${tool} needs the target's ID in \\`${TARGET}\\``);\n }\n return id;\n}\n\n/** The value `addDrive` got for a field in any of its shapes; they must agree. */\nfunction driveField<T>(\n field: string,\n values: (T | null | undefined)[],\n): T | undefined {\n const given = new Set(\n values.filter((value): value is T => value != null && value !== \"\"),\n );\n if (given.size > 1) {\n throw new Error(\n `addDrive got different values for \\`${field}\\`; pass it once, at the top level`,\n );\n }\n const [value] = given;\n return value;\n}\n\n/** What became of one submitted action: its operation's index and outcome. */\ntype StoredOutcome = { index: number } & OperationOutcome;\n\ntype ActionError = {\n kind: \"reducer-error\" | \"denied\" | \"not-applied\";\n message: string;\n name?: string;\n code?: string;\n};\n\nfunction outcomeError(\n outcome: StoredOutcome | undefined,\n modelErrors: (\n name?: string,\n code?: string,\n message?: string,\n ) => ModelError | undefined,\n): ActionError | undefined {\n if (!outcome) {\n return {\n kind: \"not-applied\",\n message: \"The reactor stored no operation for this action\",\n };\n }\n switch (outcome.kind) {\n case \"applied\":\n return undefined;\n case \"reducer-error\": {\n const known = modelErrors(outcome.name, outcome.code, outcome.message);\n const name = known?.name ?? outcome.name;\n const code = known?.code ?? outcome.code;\n return {\n kind: outcome.kind,\n message: outcome.message,\n ...(name !== undefined && { name }),\n ...(code !== undefined && { code }),\n };\n }\n case \"denied\":\n return { kind: outcome.kind, message: outcome.reason };\n }\n}\n\n/** An error a document model declares, as codegen names its class and code. */\ntype ModelError = { name: string; code: string };\n\n/** Finds the declared error a reducer error was, by its code, class name or default message. */\nfunction modelErrorFinder(\n module: DocumentModelModule,\n actionType: string,\n): (name?: string, code?: string, message?: string) => ModelError | undefined {\n const specification = module.documentModel.global.specifications.at(-1);\n const operations = (specification?.modules ?? []).flatMap(\n (m) => m.operations,\n );\n const declared = (errors: { name: string | null; code: string | null }[]) =>\n errors.flatMap(({ name, code }) => {\n if (!name) return [];\n const className = pascalCase(name);\n return [{ name: className, code: code?.trim() || className }];\n });\n // The action's own operation first, as two operations may share a name.\n const candidates = [\n ...declared(operations.find((o) => o.name === actionType)?.errors ?? []),\n ...declared(operations.flatMap((o) => o.errors)),\n ];\n // By code, then class name (code generated before the model set one), then\n // the default message, which is the class name.\n return (name, code, message) =>\n candidates.find((e) => code !== undefined && e.code === code) ??\n candidates.find((e) => name !== undefined && e.name === name) ??\n candidates.find((e) => e.name === message);\n}\n\n/** Waits until a write can be read back. */\nasync function written(handle: Promise<WriteHandle>): Promise<WriteReceipt> {\n return (await handle).readable;\n}\n\n/** A job the auth policy refused at admission; such a job writes nothing. */\nfunction isDeniedJob(error: unknown): error is JobFailedError {\n return (\n error instanceof Error &&\n error.name === \"JobFailedError\" &&\n (error as JobFailedError).job.error?.name === \"AuthorizationDeniedError\"\n );\n}\n\nexport type ReactorMcpProviderOptions = {\n client: IReactorClient;\n syncManager?: ISyncManager;\n /**\n * Who the tools read as. A server shared by many callers must set it, an\n * anonymous one to an empty subject. Omitted, reads fall back to the\n * client's signer, which only a single-user local reactor should rely on.\n */\n subject?: AuthSubject;\n /** Vetra's codegen status; the process's registry by default. */\n codegenStatus?: CodegenStatusRegistry;\n};\n\nexport const createDocumentTool = {\n name: \"createDocument\",\n description: `Create a new document.\n Unless the user specifies otherwise, and a drive named \"vetra\" is available, add the document to that drive by providing the drive's ID in the \"driveId\" parameter.\n When \"driveId\" is provided, the document is created and added to the drive atomically — no separate \"addActions\" call with \"ADD_FILE\" is needed.`,\n inputSchema: {\n documentType: z.string().describe(\"Type of the document to create\"),\n name: z\n .string()\n .optional()\n .describe(\n \"Optional name for the document. Used as both the document name and the drive node name when driveId is provided.\",\n ),\n driveId: z\n .string()\n .optional()\n .describe(\n \"Optional drive ID or slug. When provided, the document is created and added to the drive atomically.\",\n ),\n parentFolder: z\n .string()\n .optional()\n .describe(\n \"Optional folder ID within the drive to place the document in. Only used when driveId is provided.\",\n ),\n },\n outputSchema: {\n documentId: z.string().describe(\"ID of the created document\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentTool = {\n name: \"getDocument\",\n description: \"Retrieve a document or drive by its ID, passed as `documentId`\",\n inputSchema: {\n documentId: targetParam(\"document to retrieve\"),\n id: aliasParam,\n },\n outputSchema: {\n document: z.unknown().describe(\"The retrieved Document\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentsTool = {\n name: \"getDocuments\",\n description: \"List documents in a drive, passed as `documentId`\",\n inputSchema: {\n documentId: targetParam(\"drive whose documents to list\"),\n driveId: aliasParam,\n parentId: aliasParam,\n },\n outputSchema: {\n documentIds: z.array(z.string()).describe(\"Array of document IDs\"),\n },\n} as const satisfies ToolSchema;\n\nexport const deleteDocumentTool = {\n name: \"deleteDocument\",\n description: \"Delete a document, passed as `documentId`\",\n inputSchema: {\n documentId: targetParam(\"document to delete\"),\n id: aliasParam,\n },\n outputSchema: {\n success: z.boolean().describe(\"Whether the deletion was successful\"),\n },\n} as const satisfies ToolSchema;\n\nconst actionErrorSchema = z\n .object({\n kind: z\n .enum([\"reducer-error\", \"denied\", \"not-applied\"])\n .describe(\n \"reducer-error: the reducer threw; denied: an auth policy refused it; not-applied: it was not written, e.g. because another action of the batch was denied\",\n ),\n message: z.string().describe(\"Why the action was not applied\"),\n name: z\n .string()\n .optional()\n .describe(\n \"For a reducer-error: the error class the reducer threw, e.g. BookNotStartedError\",\n ),\n code: z\n .string()\n .optional()\n .describe(\n \"For a reducer-error: the error's code in the document model, e.g. BOOK_NOT_STARTED\",\n ),\n })\n .describe(\"Present when the action was not applied\");\n\nexport const addActionsTool = {\n name: \"addActions\",\n description:\n \"Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps. Besides the document model's operations, accepts the base actions SET_NAME (scope global, input: the name), SET_PREFERRED_EDITOR (scope header, input: { preferredEditor }), UNDO and REDO (input: { count }) and NOOP. Returns one result per action, in input order; `success` is false when any result carries an `error`. An action its reducer rejected is stored as an operation that changes nothing, and the rest of the batch still applies. When a policy denies an action, the whole batch is refused: the denied action's error has kind `denied` and the others `not-applied`.\",\n inputSchema: {\n documentId: targetParam(\"document or drive to change\"),\n id: aliasParam,\n actions: z\n .array(\n z\n .object({\n type: z.string().describe(\"The name of the action\"),\n input: z.unknown().describe(\"The payload of the action\"),\n scope: z.string().describe(\"The scope of the action\"),\n context: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\"Optional action context\"), // TODO: Define context schema\n })\n .strict(),\n )\n .describe(\"Action to add to the document\"),\n },\n outputSchema: {\n success: z.boolean().describe(\"False when any action was not applied\"),\n results: z\n .array(\n z.object({\n index: z.number().describe(\"Position of the action in `actions`\"),\n type: z.string().describe(\"The action's type\"),\n scope: z.string().describe(\"The action's scope\"),\n operationIndex: z\n .number()\n .optional()\n .describe(\"Index of the operation the action was stored as\"),\n error: actionErrorSchema.optional(),\n }),\n )\n .describe(\"One result per action, in the order they were given\"),\n codegen: z\n .string()\n .optional()\n .describe(\n \"Present when Vetra generates code from this document: how to follow that generation\",\n ),\n },\n} as const satisfies ToolSchema;\n\n// export const addOperationTool = {\n// name: \"addOperation\",\n// description: \"Add an operation to a document\",\n// inputSchema: {\n// documentId: z.string().describe(\"ID of the document\"),\n// operation: z\n// .object({\n// type: z.string().describe(\"The name of the action\"),\n// input: z.unknown().describe(\"The payload of the action\"),\n// scope: z.string().describe(\"The scope of the action\"),\n// index: z.number().describe(\"Position of the operation in the history\"),\n// timestampUtcMs: z\n// .string()\n// .describe(\"Timestamp of when the operation was added\"),\n// hash: z.string().describe(\"Hash of the resulting document data\"),\n// skip: z.number().describe(\"The number of operations skipped\"),\n// error: z\n// .string()\n// .optional()\n// .describe(\"Error message for a failed action\"),\n// id: z.string().optional().describe(\"Unique operation id\"),\n// context: z.object({}).optional().describe(\"Optional action context\"), // TODO: Define context schema\n// })\n// .strict()\n// .describe(\"Operation to add to the document\"),\n// },\n// outputSchema: {\n// result: z\n// .object({\n// status: z\n// .enum([\"SUCCESS\", \"CONFLICT\", \"MISSING\", \"ERROR\"])\n// .describe(\"Operation status\"),\n// error: z\n// .string()\n// .optional()\n// .describe(\"Error details if operation failed\"), // TODO: Define error schema\n// operations: z\n// .array(z.object({}))\n// .describe(\"Array of operations created\"), // TODO: Define operation schema\n// document: z.object({}).optional().describe(\"Updated document\"), // TODO: Define document schema\n// signals: z.array(z.object({})).describe(\"Array of signals generated\"), // TODO: Define signal schema\n// })\n// .describe(\"Operation result\"),\n// },\n// } as const satisfies ToolSchema;\n\nconst codegenStatusSchema = z.object({\n documentId: z.string(),\n documentType: z.string(),\n name: z.string().optional().describe(\"The module's name\"),\n state: z\n .enum([\n \"queued\",\n \"running\",\n \"waiting-for-install\",\n \"done\",\n \"failed\",\n \"skipped\",\n ])\n .describe(\n \"queued: waiting for the changes to settle or for another job; running: writing code; waiting-for-install: a dependency install runs first; done: the code is written; failed: generation threw, see message; skipped: nothing was generated, see message\",\n ),\n message: z\n .string()\n .optional()\n .describe(\"Why it failed or was skipped, or what it waits for\"),\n files: z\n .array(z.string())\n .optional()\n .describe(\"Project files the job wrote, relative to the project\"),\n updatedAt: z.string().describe(\"ISO timestamp of the last change\"),\n});\n\nexport const getCodegenStatusTool = {\n name: \"getCodegenStatus\",\n description:\n \"Vetra's code generation for its documents (document models, editors, apps, processors, subgraphs and the package): each one's state, why it failed or was skipped, and the files it wrote. Vetra regenerates a document's code a few seconds after it changes; call this after addActions on such a document, with `waitSeconds` to wait until it settles, before reading or editing the generated code. `loadFailures` lists the project modules Vetra could not load, e.g. generated code that throws on import.\",\n inputSchema: {\n documentId: z\n .string()\n .optional()\n .describe(\"ID of a Vetra document; omitted, every document's status\"),\n waitSeconds: z\n .number()\n .min(0)\n .max(60)\n .optional()\n .describe(\n \"Wait up to this many seconds for the job, or every job without `documentId`, to be done, failed or skipped. Defaults to 0.\",\n ),\n },\n outputSchema: {\n active: z\n .boolean()\n .describe(\"False when no Vetra codegen runs on this reactor\"),\n settled: z\n .boolean()\n .describe(\"True when every listed job is done, failed or skipped\"),\n documents: z\n .array(codegenStatusSchema)\n .describe(\"One status per document, most recently updated first\"),\n loadFailures: z\n .array(\n z.object({\n package: z.string(),\n kind: z\n .string()\n .describe('What failed to load, e.g. \"document models\"'),\n message: z.string(),\n updatedAt: z.string(),\n }),\n )\n .describe(\"Project modules that failed to load\"),\n message: z.string().optional(),\n },\n} as const satisfies ToolSchema;\n\n// Drive Operation Tools\n\nexport const getDrivesTool = {\n name: \"getDrives\",\n description: \"List all drives\",\n inputSchema: {},\n outputSchema: {\n driveIds: z.array(z.string()).describe(\"Array of drive IDs\"),\n },\n} as const satisfies ToolSchema;\n\nconst driveName = z.string().optional().describe(\"Name of the drive\");\nconst driveIcon = z\n .string()\n .nullable()\n .optional()\n .describe(\"Optional icon for the drive\");\nconst drivePreferredEditor = z\n .string()\n .optional()\n .describe(\n \"Optional app/editor module id recorded as the drive's preferred editor\",\n );\n\nexport const addDriveTool = {\n name: \"addDrive\",\n description:\n \"Create a new drive. Pass `name` and, optionally, `icon` and `preferredEditor` at the top level. The older `driveInput` object is still accepted.\",\n inputSchema: {\n name: z.string().optional().describe(\"Name of the drive. Required.\"),\n icon: driveIcon,\n preferredEditor: drivePreferredEditor,\n driveInput: z\n .object({\n name: driveName,\n icon: driveIcon,\n global: z\n .object({\n name: z.string().describe(\"Name of the drive\"),\n icon: driveIcon,\n })\n .optional()\n .describe(\"Global drive properties\"),\n preferredEditor: drivePreferredEditor,\n local: z\n .object({\n availableOffline: z\n .boolean()\n .optional()\n .describe(\"Whether drive is available offline\"),\n sharingType: z\n .string()\n .nullable()\n .optional()\n .describe(\"Sharing type\"),\n })\n .optional()\n .describe(\"Optional local state properties\"),\n })\n .optional()\n .describe(\n \"Older form of the drive configuration; prefer the top-level fields\",\n ),\n },\n outputSchema: {\n driveId: z.string().describe(\"ID of the created drive\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDriveTool = {\n name: \"getDrive\",\n description: \"Get a specific drive, passed as `documentId`\",\n inputSchema: {\n documentId: targetParam(\"drive to retrieve\"),\n driveId: aliasParam,\n id: aliasParam,\n options: z\n .object({\n revisions: z\n .record(z.string(), z.number())\n .optional()\n .describe(\"Optional revision filter\"),\n checkHashes: z.boolean().optional().describe(\"Whether to check hashes\"),\n // TODO: Add other ReducerOptions if needed\n })\n .optional()\n .describe(\"Optional get document options\"),\n },\n outputSchema: {\n drive: z.unknown().describe(\"Drive document\"), // TODO: Define DocumentDriveDocument schema\n },\n} as const satisfies ToolSchema;\n\nexport const deleteDriveTool = {\n name: \"deleteDrive\",\n description: \"Delete a drive, passed as `documentId`\",\n inputSchema: {\n documentId: targetParam(\"drive to delete\"),\n driveId: aliasParam,\n id: aliasParam,\n },\n outputSchema: {\n success: z.boolean().describe(\"Whether the deletion was successful\"),\n },\n} as const satisfies ToolSchema;\n\nexport const addRemoteDriveTool = {\n name: \"addRemoteDrive\",\n description: \"Connect to a remote drive\",\n inputSchema: {\n url: z.string().describe(\"URL of the remote drive\"),\n options: z\n .object({\n availableOffline: z\n .boolean()\n .describe(\"Whether drive is available offline\"),\n sharingType: z.string().nullable().optional().describe(\"Sharing type\"),\n pullFilter: z\n .object({\n branch: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Branch filter\"),\n documentId: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Document ID filter\"),\n documentType: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Document type filter\"),\n scope: z\n .array(z.string())\n .nullable()\n .optional()\n .describe(\"Scope filter\"),\n })\n .optional()\n .describe(\"Optional pull filter\"),\n pullInterval: z\n .number()\n .optional()\n .describe(\"Pull interval in milliseconds\"),\n })\n .describe(\"Remote drive options\"),\n },\n outputSchema: {\n driveId: z.string().describe(\"ID of the added remote drive\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentModelSchemaTool = {\n name: \"getDocumentModelSchema\",\n description:\n \"Get the schema of a document model. Pass `compact: true` before addActions: it returns only each action's type, scope and GraphQL input definition, and the enums and types those inputs use. Omit it for the full model, with state schemas, descriptions, errors and examples.\",\n inputSchema: {\n type: z.string().describe(\"Type of the document model\"),\n compact: z\n .boolean()\n .optional()\n .describe(\n \"Return only the actions' types, scopes and input definitions. Defaults to false.\",\n ),\n },\n outputSchema: {\n schema: z.unknown().describe(\"Schema of the document model\"),\n },\n} as const satisfies ToolSchema;\n\nexport const getDocumentModelsTool = {\n name: \"getDocumentModels\",\n description: \"Get the list of document models\",\n inputSchema: {},\n outputSchema: {\n documentModels: z\n .array(\n z.object({\n name: z.string().describe(\"Name of the document model\"),\n type: z.string().describe(\"Type of the document model\"),\n description: z.string().describe(\"Description of the document model\"),\n extension: z.string().describe(\"Extension of the document model\"),\n authorName: z.string().describe(\"Author name of the document model\"),\n authorWebsite: z\n .string()\n .describe(\"Author website of the document model\"),\n }),\n )\n .describe(\"List of available document models\"),\n },\n} as const satisfies ToolSchema;\n\ntype ToolRecord<T extends readonly ToolSchema[]> = {\n [K in T[number][\"name\"]]: ToolWithCallback<Extract<T[number], { name: K }>>;\n};\n\n// All tools array for type inference\nconst _allTools = [\n getDocumentTool,\n createDocumentTool,\n getDocumentsTool,\n deleteDocumentTool,\n addActionsTool,\n // addOperationTool,\n getDrivesTool,\n addDriveTool,\n getDriveTool,\n deleteDriveTool,\n addRemoteDriveTool,\n getDocumentModelSchemaTool,\n getDocumentModelsTool,\n getCodegenStatusTool,\n] as const;\n\n// Inferred interface from tools\nexport type ReactorMcpTools = ToolRecord<typeof _allTools>;\n\nexport function createReactorMcpProvider(options: ReactorMcpProviderOptions) {\n const { client, syncManager, subject } = options;\n const view = subject ? { subject } : undefined;\n const codegen = options.codegenStatus ?? getCodegenStatusRegistry();\n\n /** Marks a Vetra document's codegen queued once a global change is written. */\n function codegenHint(\n document: PHDocument,\n results: { scope: string; operationIndex?: number }[],\n ): string | undefined {\n const { id, documentType } = document.header;\n if (!codegen.active || !codegen.watches(documentType)) return undefined;\n const written = results.some(\n (result) =>\n result.scope === \"global\" && result.operationIndex !== undefined,\n );\n if (written) {\n codegen.set({\n documentId: id,\n documentType,\n state: \"queued\",\n message: \"Waiting for Vetra's codegen processor to pick up the change\",\n });\n }\n return `Vetra generates code from this document a few seconds after a change. Call getCodegenStatus with documentId \"${id}\" and waitSeconds to see when it is done, and why it failed or was skipped.`;\n }\n\n function getDocumentModelModule(documentType: string) {\n return client.getDocumentModelModule(documentType);\n }\n\n /** Names the denied actions of a refused batch; the others were not written either. */\n async function denialErrors(\n documentId: string,\n actions: Action[],\n message: string,\n ): Promise<ActionError[]> {\n const notApplied: ActionError = {\n kind: \"not-applied\",\n message: `The batch was refused, so nothing in it was written: ${message}`,\n };\n try {\n const { evaluations } = await client.evaluateActions(\n documentId,\n \"main\",\n actions.map(({ scope, type, input }) => ({ scope, type, input })),\n );\n return evaluations.map((evaluation) =>\n evaluation.decision === \"deny\"\n ? { kind: \"denied\", message: evaluation.reason }\n : notApplied,\n );\n } catch {\n return actions.map(() => notApplied);\n }\n }\n\n /** For clients whose jobs carry no result: reads the operations the write appended. */\n async function readOutcomes(\n documentId: string,\n before: PHDocument,\n actions: Action[],\n ): Promise<Map<string, StoredOutcome>> {\n const ids = new Set(actions.map((action) => action.id));\n const outcomes = new Map<string, StoredOutcome>();\n for (const scope of new Set(actions.map((action) => action.scope))) {\n let paging: PagingOptions | undefined;\n do {\n const page = await client.getOperations(\n documentId,\n { ...view, branch: \"main\", scopes: [scope] },\n { sinceRevision: before.header.revision[scope] ?? 0 },\n paging,\n );\n for (const operation of page.results) {\n if (ids.has(operation.action.id)) {\n outcomes.set(operation.action.id, {\n index: operation.index,\n ...operationOutcome(operation),\n });\n }\n }\n paging =\n page.nextCursor && page.results.length\n ? { cursor: page.nextCursor, limit: page.options.limit }\n : undefined;\n } while (paging);\n }\n return outcomes;\n }\n\n const tools = {\n getDocument: toolWithCallback(getDocumentTool, async (params) => {\n const id = targetId(\"getDocument\", params, [\"id\"]);\n const document = await client.get<PHDocument>(id, view);\n return { document: { header: document.header, state: document.state } };\n }),\n\n createDocument: toolWithCallback(createDocumentTool, async (params) => {\n if (params.driveId) {\n const document = await client.newDocument(params.documentType, {\n parentIdentifier: params.driveId,\n name: params.name || undefined,\n });\n const created = await client.drives.addFile(\n params.driveId,\n document,\n params.parentFolder,\n );\n return { documentId: created.header.id };\n }\n\n const created = await written(\n client.write.createEmpty(params.documentType, {}),\n );\n return { documentId: created.documentId };\n }),\n\n getDocuments: toolWithCallback(getDocumentsTool, async (params) => {\n const driveId = targetId(\"getDocuments\", params, [\"driveId\", \"parentId\"]);\n const result = await client.getOutgoingRelationships(\n driveId,\n \"child\",\n view,\n );\n const documentIds = result.results.map((doc) => doc.header.id);\n return { documentIds };\n }),\n\n deleteDocument: toolWithCallback(deleteDocumentTool, async (params) => {\n const documentId = targetId(\"deleteDocument\", params, [\"id\"]);\n try {\n // Routes the delete through the drive; nothing read here is returned.\n const incoming = await client.getIncomingRelationships(\n documentId,\n \"child\",\n );\n const driveParent = incoming.results.find(\n (p) => p.header.documentType === DRIVE_DOCUMENT_TYPE,\n );\n if (driveParent) {\n await client.drives.removeNode(driveParent.header.id, documentId);\n } else {\n await written(client.write.deleteDocument(documentId));\n }\n return { success: true };\n } catch {\n return { success: false };\n }\n }),\n\n addActions: toolWithCallback(addActionsTool, async (params) => {\n const documentId = targetId(\"addActions\", params, [\"id\"]);\n const document = await client.get<PHDocument>(documentId, view);\n const documentModel = await getDocumentModelModule(\n document.header.documentType,\n );\n if (!documentModel) {\n throw new Error(\n `Document model for document type '${document.header.documentType}' not found`,\n );\n }\n const actions: Action[] = params.actions.map((paramAction) => {\n const baseAction = createBaseAction(\n paramAction.type,\n paramAction.input,\n paramAction.scope,\n );\n if (baseAction) {\n if (!baseAction.action) {\n throw new Error(\n `Invalid action ${JSON.stringify(paramAction)}: ${baseAction.errors.join(\", \")}`,\n );\n }\n return baseAction.action;\n }\n const action: Action = createAction(\n paramAction.type,\n paramAction.input ?? {},\n undefined,\n undefined,\n paramAction.scope,\n );\n const actionValidation = validateDocumentModelAction(\n documentModel,\n action,\n );\n if (!actionValidation.isValid) {\n throw new Error(\n `Invalid action ${JSON.stringify(action)}: ${actionValidation.errors.join(\", \")}`,\n );\n }\n return action;\n });\n\n const handle = await client.write.execute(documentId, \"main\", actions);\n let results: {\n index: number;\n type: string;\n scope: string;\n operationIndex?: number;\n error?: ActionError;\n }[];\n try {\n const receipt = await handle.readable;\n const outcomes = receipt.job.result\n ? new Map(receipt.job.result.actions.map((a) => [a.actionId, a]))\n : await readOutcomes(receipt.documentId, document, actions);\n results = actions.map((action, index) => {\n const outcome = outcomes.get(action.id);\n const error = outcomeError(\n outcome,\n modelErrorFinder(documentModel, action.type),\n );\n return {\n index,\n type: action.type,\n scope: action.scope,\n ...(outcome && { operationIndex: outcome.index }),\n ...(error && { error }),\n };\n });\n } catch (error) {\n if (!isDeniedJob(error)) throw error;\n const errors = await denialErrors(documentId, actions, error.message);\n results = actions.map((action, index) => ({\n index,\n type: action.type,\n scope: action.scope,\n error: errors[index],\n }));\n }\n const hint = codegenHint(document, results);\n return {\n success: results.every((result) => !result.error),\n results,\n ...(hint && { codegen: hint }),\n };\n }),\n\n // Drive operation implementations\n getDrives: toolWithCallback(getDrivesTool, async () => {\n // Find all documents of type \"powerhouse/document-drive\"\n const result = await client.find({ type: DRIVE_DOCUMENT_TYPE }, view);\n const driveIds = result.results.map((doc: PHDocument) => doc.header.id);\n return { driveIds };\n }),\n\n addDrive: toolWithCallback(addDriveTool, async (params) => {\n const { driveInput } = params;\n const name = driveField(\"name\", [\n params.name,\n driveInput?.name,\n driveInput?.global?.name,\n ]);\n if (!name) {\n throw new Error(\"addDrive needs the drive's `name`\");\n }\n const icon = driveField(\"icon\", [\n params.icon,\n driveInput?.icon,\n driveInput?.global?.icon,\n ]);\n const preferredEditor = driveField(\"preferredEditor\", [\n params.preferredEditor,\n driveInput?.preferredEditor,\n ]);\n\n const { documentId: driveId } = await written(\n client.write.createEmpty(DRIVE_DOCUMENT_TYPE, {}),\n );\n\n // Before the rename, so reactors without the document-view name fix keep it.\n if (preferredEditor) {\n await written(\n client.write.setPreferredEditor(driveId, preferredEditor),\n );\n }\n await written(client.write.rename(driveId, name));\n\n const actions: Action[] = [setDriveName({ name })];\n if (icon) {\n actions.push(setDriveIcon({ icon }));\n }\n if (driveInput?.local?.sharingType) {\n actions.push(setSharingType({ type: driveInput.local.sharingType }));\n }\n if (driveInput?.local?.availableOffline !== undefined) {\n actions.push(\n setAvailableOffline({\n availableOffline: driveInput.local.availableOffline,\n }),\n );\n }\n await written(client.write.execute(driveId, \"main\", actions));\n\n return { driveId };\n }),\n\n getDrive: toolWithCallback(getDriveTool, async (params) => {\n const driveId = targetId(\"getDrive\", params, [\"driveId\", \"id\"]);\n const drive = await client.get<DocumentDriveDocument>(driveId, view);\n return { drive: { header: drive.header, state: drive.state } };\n }),\n\n deleteDrive: toolWithCallback(deleteDriveTool, async (params) => {\n const driveId = targetId(\"deleteDrive\", params, [\"driveId\", \"id\"]);\n try {\n // Use CASCADE to delete the drive and all its contents\n await written(client.write.deleteDocument(driveId));\n return { success: true };\n } catch {\n return { success: false };\n }\n }),\n\n addRemoteDrive: toolWithCallback(addRemoteDriveTool, async (params) => {\n if (!syncManager) {\n throw new Error(\n \"Remote drive management is not available. \" +\n \"SyncManager was not configured for this MCP server.\",\n );\n }\n\n // Fetch drive info from the REST endpoint to get both id and graphqlEndpoint\n const response = await fetch(params.url);\n if (!response.ok) {\n throw new Error(`Failed to resolve drive info from ${params.url}`);\n }\n const driveInfo = (await response.json()) as {\n id: string;\n graphqlEndpoint: string;\n };\n\n const resolvedDriveId = driveInfo.id;\n const collectionId = DriveCollectionId.forDrive(resolvedDriveId);\n\n // Check if remote already exists\n const existingRemote = syncManager\n .list()\n .find((remote) => remote.meta.collectionId.equals(collectionId));\n if (existingRemote) {\n return { driveId: resolvedDriveId };\n }\n\n // Add the remote via SyncManager\n const remoteName = `mcp-remote-${crypto.randomUUID()}`;\n await syncManager.add(remoteName, collectionId, {\n type: \"gql\",\n parameters: {\n url: driveInfo.graphqlEndpoint,\n },\n });\n\n return { driveId: resolvedDriveId };\n }),\n\n getDocumentModels: toolWithCallback(getDocumentModelsTool, async () => {\n const result = await client.getDocumentModelModules();\n return {\n documentModels: result.results.map((model: DocumentModelModule) => {\n const schemaGlobal = model.documentModel.global;\n return {\n name: schemaGlobal.name,\n type: schemaGlobal.id,\n description: schemaGlobal.description,\n extension: schemaGlobal.extension,\n authorName: schemaGlobal.author.name,\n authorWebsite: schemaGlobal.author.website ?? \"\",\n };\n }),\n };\n }),\n\n getCodegenStatus: toolWithCallback(getCodegenStatusTool, async (params) => {\n if (!codegen.active) {\n return {\n active: false,\n settled: true,\n documents: [],\n loadFailures: codegen.loadFailures(),\n message:\n \"No Vetra codegen runs on this reactor; `ph vetra` runs it for the project's Vetra drive\",\n };\n }\n let documentId = params.documentId;\n if (documentId !== undefined && !codegen.get(documentId)) {\n // A slug names the document as well as its ID.\n try {\n documentId = (await client.get<PHDocument>(documentId, view)).header\n .id;\n } catch {\n // Reported below as a document without a status.\n }\n }\n const waitMs = (params.waitSeconds ?? 0) * 1000;\n const settled =\n waitMs > 0\n ? await codegen.waitUntilSettled(documentId, waitMs)\n : codegen.settled(documentId);\n const documents =\n documentId === undefined\n ? codegen.list()\n : [codegen.get(documentId)].filter((status) => status !== undefined);\n return {\n active: true,\n settled,\n documents,\n loadFailures: codegen.loadFailures(),\n ...(documentId !== undefined &&\n documents.length === 0 && {\n message: `No codegen recorded for ${params.documentId}. Vetra generates code for documents of type ${codegen.documentTypes.join(\", \")} in its drive, once they change.`,\n }),\n };\n }),\n\n getDocumentModelSchema: toolWithCallback(\n getDocumentModelSchemaTool,\n async (params) => {\n const documentModel = await getDocumentModelModule(params.type);\n const schema = documentModel?.documentModel.global;\n if (!schema) {\n throw new Error(`Document model '${params.type}' not found`);\n }\n return {\n schema: params.compact ? compactDocumentModelSchema(schema) : schema,\n };\n },\n ),\n } as const;\n\n const resources = {};\n\n const prompts = {};\n\n return Promise.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CAAC,QAAQ,IAAI,UAAU,GAErD,IAAI;IACF,cAAc,MAAM,OAAO,IAAgB,YAAY,IAAI,EAAA,CAAG,OAC3D;GACL,QAAQ,CAER;GAEF,MAAM,UAAU,OAAO,eAAe,KAAK;GAC3C,MAAM,UACJ,SAAS,IACL,MAAM,QAAQ,iBAAiB,YAAY,MAAM,IACjD,QAAQ,QAAQ,UAAU;GAChC,MAAM,YACJ,eAAe,KAAA,IACX,QAAQ,KAAK,IACb,CAAC,QAAQ,IAAI,UAAU,CAAC,CAAC,CAAC,QAAQ,WAAW,WAAW,KAAA,CAAS;GACvE,OAAO;IACL,QAAQ;IACR;IACA;IACA,cAAc,QAAQ,aAAa;IACnC,GAAI,eAAe,KAAA,KACjB,UAAU,WAAW,KAAK,EACxB,SAAS,2BAA2B,OAAO,WAAW,+CAA+C,QAAQ,cAAc,KAAK,IAAI,EAAE,kCACxI;GACJ;EACF,CAAC;EAED,wBAAwB,iBACtB,4BACA,OAAO,WAAW;GAEhB,MAAM,UAAS,MADa,uBAAuB,OAAO,IAAI,EAAA,EAChC,cAAc;GAC5C,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,mBAAmB,OAAO,KAAK,YAAY;GAE7D,OAAO,EACL,QAAQ,OAAO,UAAU,2BAA2B,MAAM,IAAI,OAChE;EACF,CACF;CACF;CAMA,OAAO,QAAQ,QAAQ;EACrB;EACA,WAAA,CAAQ;EACR,SAAA,CAAM;CACR,CAAU;AACZ"}
@@ -1,4 +1,4 @@
1
- import { a as createReactorMcpProvider } from "./reactor-BqyjCnB2.mjs";
1
+ import { a as createReactorMcpProvider } from "./reactor-Cku02YAV.mjs";
2
2
  import { childLogger } from "document-model";
3
3
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
  //#region src/logger.ts
@@ -14,6 +14,8 @@ There are 5 main concepts to know of:
14
14
  - 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.
15
15
 
16
16
  When planning to add multiple actions to a document, try to reduce the number of "addActions" calls to a minimum by adding multiple actions at once.
17
+ "addActions" returns one result per action. When "success" is false, the results with an "error" say which actions were not applied and why.
18
+ In 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.
17
19
  Unless the user specifies otherwise, and a drive with slug "vetra" is available, create new documents inside it by passing its ID as the "driveId" parameter to "createDocument".
18
20
 
19
21
  Examples:
@@ -21,7 +23,7 @@ Examples:
21
23
  <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>
22
24
  `;
23
25
  async function createServer(options) {
24
- const { client, syncManager, subject } = options;
26
+ const { client, syncManager, subject, codegenStatus } = options;
25
27
  const server = new McpServer({
26
28
  name: "reactor-mcp-server",
27
29
  version: "1.0.0",
@@ -45,7 +47,8 @@ async function createServer(options) {
45
47
  const reactorProvider = await createReactorMcpProvider({
46
48
  client,
47
49
  syncManager,
48
- subject
50
+ subject,
51
+ codegenStatus
49
52
  });
50
53
  Object.entries(reactorProvider.tools).forEach(([toolName, { callback, ...schema }]) => {
51
54
  server.registerTool(toolName, schema, callback);
@@ -55,4 +58,4 @@ async function createServer(options) {
55
58
  //#endregion
56
59
  export { logger as n, createServer as t };
57
60
 
58
- //# sourceMappingURL=server-DF99fpy8.mjs.map
61
+ //# sourceMappingURL=server-CPSr7how.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-CPSr7how.mjs","names":[],"sources":["../src/logger.ts","../src/server.ts"],"sourcesContent":["import { childLogger, type ILogger } from \"document-model\";\n\nexport const logger: ILogger = childLogger([\"reactor-mcp\"]);\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 type { CodegenStatusRegistry } from \"@powerhousedao/shared/processors\";\nimport { createReactorMcpProvider } from \"./tools/reactor.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 /** 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 async function createServer(\n options: CreateServerOptions,\n): Promise<McpServer> {\n const { client, syncManager, subject, codegenStatus } = options;\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 reactorProvider = await createReactorMcpProvider({\n client,\n syncManager,\n subject,\n codegenStatus,\n });\n\n // const { callback, ...toolSchema } = reactorProvider.tools.getDocumentModels;\n // server.registerTool(\"getDocumentModels\", toolSchema, callback);\n Object.entries(reactorProvider.tools).forEach(\n ([toolName, { callback, ...schema }]) => {\n server.registerTool(toolName, schema as any, callback as any);\n },\n );\n\n return server;\n}\n"],"mappings":";;;;AAEA,MAAa,SAAkB,YAAY,CAAC,aAAa,CAAC;;;ACa1D,MAAa,yBAAyB;;;;;;;;;;;;;;;;;AAkBtC,eAAsB,aACpB,SACoB;CACpB,MAAM,EAAE,QAAQ,aAAa,SAAS,kBAAkB;CACxD,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,kBAAkB,MAAM,yBAAyB;EACrD;EACA;EACA;EACA;CACF,CAAC;CAID,OAAO,QAAQ,gBAAgB,KAAK,CAAC,CAAC,SACnC,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc;EACvC,OAAO,aAAa,UAAU,QAAe,QAAe;CAC9D,CACF;CAEA,OAAO;AACT"}
@@ -1,3 +1,3 @@
1
- import { _ as getDocumentsTool, a as ReactorMcpProviderOptions, c as addDriveTool, d as createReactorMcpProvider, f as deleteDocumentTool, g as getDocumentTool, h as getDocumentModelsTool, i as validateDocumentModelAction, l as addRemoteDriveTool, m as getDocumentModelSchemaTool, n as createBaseAction, o as ReactorMcpTools, p as deleteDriveTool, r as toolWithCallback, s as addActionsTool, t as InvalidToolOutputError, u as createDocumentTool, v as getDriveTool, y as getDrivesTool } from "../index-BX9XmJWL.mjs";
2
- export { InvalidToolOutputError, ReactorMcpProviderOptions, ReactorMcpTools, addActionsTool, addDriveTool, addRemoteDriveTool, createBaseAction, createDocumentTool, createReactorMcpProvider, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, toolWithCallback, validateDocumentModelAction };
1
+ import { D as compactDocumentModelSchema, E as CompactDocumentModelSchema, _ as getDocumentTool, a as ReactorMcpProviderOptions, b as getDrivesTool, c as addDriveTool, d as createReactorMcpProvider, f as deleteDocumentTool, g as getDocumentModelsTool, h as getDocumentModelSchemaTool, i as validateDocumentModelAction, l as addRemoteDriveTool, m as getCodegenStatusTool, n as createBaseAction, o as ReactorMcpTools, p as deleteDriveTool, r as toolWithCallback, s as addActionsTool, t as InvalidToolOutputError, u as createDocumentTool, v as getDocumentsTool, y as getDriveTool } from "../index-D9YfSE7M.mjs";
2
+ export { CompactDocumentModelSchema, InvalidToolOutputError, ReactorMcpProviderOptions, ReactorMcpTools, addActionsTool, addDriveTool, addRemoteDriveTool, compactDocumentModelSchema, createBaseAction, createDocumentTool, createReactorMcpProvider, deleteDocumentTool, deleteDriveTool, getCodegenStatusTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, toolWithCallback, validateDocumentModelAction };
3
3
  export {};
@@ -1,2 +1,2 @@
1
- import { _ as validateDocumentModelAction, a as createReactorMcpProvider, c as getDocumentModelSchemaTool, d as getDocumentsTool, f as getDriveTool, g as toolWithCallback, h as createBaseAction, i as createDocumentTool, l as getDocumentModelsTool, m as InvalidToolOutputError, n as addDriveTool, o as deleteDocumentTool, p as getDrivesTool, r as addRemoteDriveTool, s as deleteDriveTool, t as addActionsTool, u as getDocumentTool } from "../reactor-BqyjCnB2.mjs";
2
- export { InvalidToolOutputError, addActionsTool, addDriveTool, addRemoteDriveTool, createBaseAction, createDocumentTool, createReactorMcpProvider, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, toolWithCallback, validateDocumentModelAction };
1
+ import { _ as toolWithCallback, a as createReactorMcpProvider, c as getCodegenStatusTool, d as getDocumentTool, f as getDocumentsTool, g as createBaseAction, h as InvalidToolOutputError, i as createDocumentTool, l as getDocumentModelSchemaTool, m as getDrivesTool, n as addDriveTool, o as deleteDocumentTool, p as getDriveTool, r as addRemoteDriveTool, s as deleteDriveTool, t as addActionsTool, u as getDocumentModelsTool, v as validateDocumentModelAction, y as compactDocumentModelSchema } from "../reactor-Cku02YAV.mjs";
2
+ export { InvalidToolOutputError, addActionsTool, addDriveTool, addRemoteDriveTool, compactDocumentModelSchema, createBaseAction, createDocumentTool, createReactorMcpProvider, deleteDocumentTool, deleteDriveTool, getCodegenStatusTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, toolWithCallback, validateDocumentModelAction };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/reactor-mcp",
3
- "version": "6.2.3-dev.78",
3
+ "version": "6.2.3-dev.79",
4
4
  "description": "MCP server for the Powerhouse reactor — exposes document model operations and drive management to AI coding assistants via the Model Context Protocol.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -50,12 +50,12 @@
50
50
  "@modelcontextprotocol/sdk": "1.29.0",
51
51
  "@openfeature/env-var-provider": "0.3.1",
52
52
  "@openfeature/server-sdk": "1.19.0",
53
- "@powerhousedao/reactor": "6.2.3-dev.78",
54
- "@powerhousedao/reactor-drive": "6.2.3-dev.78",
55
- "@powerhousedao/reactor-group": "6.2.3-dev.78",
56
- "@powerhousedao/shared": "6.2.3-dev.78",
53
+ "@powerhousedao/reactor": "6.2.3-dev.79",
54
+ "@powerhousedao/reactor-drive": "6.2.3-dev.79",
55
+ "@powerhousedao/reactor-group": "6.2.3-dev.79",
56
+ "@powerhousedao/shared": "6.2.3-dev.79",
57
57
  "change-case": "5.4.4",
58
- "document-model": "6.2.3-dev.78",
58
+ "document-model": "6.2.3-dev.79",
59
59
  "vite": "8.3.4",
60
60
  "zod": "^4.5.4"
61
61
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-BX9XmJWL.d.mts","names":[],"sources":["../src/tools/types.ts","../src/tools/reactor.ts","../src/tools/utils.ts"],"mappings":";;;;;;KAQY,wBAAwB,UAAU,cAAc;EAC1D,mBAAmB;IAEjB,aAAa,UAAU,cAAc,iBACrC;KAEQ,iBAAiB,UAAU,aAAa,cAAc;EAChE,UAAU,wBAAwB;;KAGxB,WACV,kBAAkB,cAAc,aAChC,mBAAmB,cAAc;EAEjC;EACA;EACA;EACA,cAAc;EACd,eAAe;EACf,cAAc;;KAGJ,iBAAiB,KAAK,UAAU,EAAE,cAC1C,EAAE,MAAM,EAAE,UAAU,MACpB;UAEa,aACf,UAAU,mBAAmB,kBAC7B,UAAU,WAAW,UACrB,UAAU,SAAS;EAEnB,OAAO,OAAO,WAAW,iBAAiB;EAC1C,WAAW,OAAO,WAAW;EAC7B,SAAS,OAAO,WAAW;;;;KCZjB;EACV,QAAQ;EACR,cAAc;;;;;;EAMd,UAAU;;cAGC;WACL;WACO;;;;aAIX,cAAY,EAAA;aACZ,MAAI,EAAA,YAAA,EAAA;aAMJ,SAAO,EAAA,YAAA,EAAA;aAMP,cAAY,EAAA,YAAA,EAAA;;;aAQZ,YAAU,EAAA;;;cAID;WACL;WAEJ;;aAEA,IAAE,EAAA,YAAA,EAAA;aACF,YAAU,EAAA,YAAA,EAAA;;;aAGV,UAAQ,EAAA;;;cAIC;WACL;WACO;;aAEX,UAAQ,EAAA;;;aAGR,aAAW,EAAA,SAAA,EAAA;;;cAIF;WACL;WACO;;aAEX,YAAU,EAAA;;;aAGV,SAAO,EAAA;;;cAIE;WACL;WAEJ;;aAEA,YAAU,EAAA;aACV,SAAO,EAAA,SAAA,EAAA;;;;;;;;aAiBP,SAAO,EAAA;;;cAoDE;WACL;WACO;;;aAGX,UAAQ,EAAA,SAAA,EAAA;;;cAIC;WACL;WACO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