@powerhousedao/vetra 6.2.2-dev.7 → 6.2.2-dev.8
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/codegen/index.js +3 -3
- package/dist/codegen/spec.js +1 -1
- package/dist/{editor-De5XaIXa.js → editor-B5Vlvtap.js} +2 -2
- package/dist/{editor-De5XaIXa.js.map → editor-B5Vlvtap.js.map} +1 -1
- package/dist/{editor-bA5TTxfU.js → editor-B61yLjcN.js} +2 -2
- package/dist/{editor-bA5TTxfU.js.map → editor-B61yLjcN.js.map} +1 -1
- package/dist/{editor-fNaLqnMc.js → editor-CJw40LpC.js} +2 -2
- package/dist/{editor-fNaLqnMc.js.map → editor-CJw40LpC.js.map} +1 -1
- package/dist/{editor-saGUzfCl.js → editor-DhxLTv2_.js} +2 -2
- package/dist/{editor-saGUzfCl.js.map → editor-DhxLTv2_.js.map} +1 -1
- package/dist/{editor-CtN1Sy88.js → editor-LMWvf0-d.js} +2 -2
- package/dist/{editor-CtN1Sy88.js.map → editor-LMWvf0-d.js.map} +1 -1
- package/dist/editors/hooks/index.js +1 -1
- package/dist/editors/index.js +1 -1
- package/dist/{factory-Cn0UwIFB.js → factory-Dnymdhbp.js} +2 -2
- package/dist/{factory-Cn0UwIFB.js.map → factory-Dnymdhbp.js.map} +1 -1
- package/dist/{factory-B6hBnFAf.js → factory-DtBWM7Ap.js} +3 -3
- package/dist/{factory-B6hBnFAf.js.map → factory-DtBWM7Ap.js.map} +1 -1
- package/dist/{hooks-D_8Uwk1s.js → hooks-T8Fh8Ytk.js} +1 -1
- package/dist/{hooks-D_8Uwk1s.js.map → hooks-T8Fh8Ytk.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/{logger-DLnGUZk9.js → logger-Bst62sUy.js} +1 -1
- package/dist/{logger-DLnGUZk9.js.map → logger-Bst62sUy.js.map} +1 -1
- package/dist/{module-BhsG8kkn.js → module-C_lcZZZ9.js} +6 -6
- package/dist/{module-BhsG8kkn.js.map → module-C_lcZZZ9.js.map} +1 -1
- package/dist/{processor-D2z8Eq93.js → processor-CgScwnMI.js} +3 -3
- package/dist/{processor-D2z8Eq93.js.map → processor-CgScwnMI.js.map} +1 -1
- package/dist/processors/codegen/index.js +2 -2
- package/dist/processors/index.js +1 -1
- package/dist/processors/vetra-read-model/index.js +1 -1
- package/dist/{spec-api-CT1DqmgF.js → spec-api-CrmCurlh.js} +1 -1
- package/dist/{spec-api-CT1DqmgF.js.map → spec-api-CrmCurlh.js.map} +1 -1
- package/dist/switchboard-D5upogwE.js +8 -0
- package/dist/{switchboard-CvWiUgBP.js.map → switchboard-D5upogwE.js.map} +1 -1
- package/package.json +8 -8
- package/dist/switchboard-CvWiUgBP.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec-api-CT1DqmgF.js","names":["documentEditorReducer","documentEditorUtils","documentEditorActions","documentEditorSpec","processorModuleReducer","processorModuleUtils","processorModuleActions","processorModuleSpec","subgraphModuleReducer","subgraphModuleUtils","subgraphModuleActions","subgraphModuleSpec","appModuleReducer","appModuleUtils","appModuleActions","appModuleSpec"],"sources":["../document-models/app-module/app-module.json","../document-models/document-editor/document-editor.json","../document-models/processor-module/processor-module.json","../document-models/subgraph-module/subgraph-module.json","../codegen/specs.ts","../codegen/spec-api.ts"],"sourcesContent":["","","","","import type {\n Action,\n DocumentModelGlobalState,\n PHDocument,\n Reducer,\n} from \"@powerhousedao/shared/document-model\";\nimport { kebabCase } from \"change-case\";\nimport { documentModelDocumentModelModule } from \"document-model\";\nimport { baseSaveToFile } from \"document-model/node\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\n/* Import from gen/ + actions.ts directly (not the top-level barrel) so we\n * don't pull in `hooks.ts`, which depends on `@powerhousedao/reactor-browser`\n * (a browser-only module that breaks Node-side spec tooling). */\nimport appModuleSpec from \"../document-models/app-module/app-module.json\" with { type: \"json\" };\nimport { actions as appModuleActions } from \"../document-models/app-module/v1/actions.js\";\nimport {\n appModuleDocumentType,\n createAppModuleDocument,\n reducer as appModuleReducer,\n utils as appModuleUtils,\n} from \"../document-models/app-module/v1/gen/index.js\";\nimport documentEditorSpec from \"../document-models/document-editor/document-editor.json\" with { type: \"json\" };\nimport { actions as documentEditorActions } from \"../document-models/document-editor/v1/actions.js\";\nimport {\n createDocumentEditorDocument,\n documentEditorDocumentType,\n reducer as documentEditorReducer,\n utils as documentEditorUtils,\n} from \"../document-models/document-editor/v1/gen/index.js\";\nimport processorModuleSpec from \"../document-models/processor-module/processor-module.json\" with { type: \"json\" };\nimport { actions as processorModuleActions } from \"../document-models/processor-module/v1/actions.js\";\nimport {\n createProcessorModuleDocument,\n processorModuleDocumentType,\n reducer as processorModuleReducer,\n utils as processorModuleUtils,\n} from \"../document-models/processor-module/v1/gen/index.js\";\nimport subgraphModuleSpec from \"../document-models/subgraph-module/subgraph-module.json\" with { type: \"json\" };\nimport { actions as subgraphModuleActions } from \"../document-models/subgraph-module/v1/actions.js\";\nimport {\n createSubgraphModuleDocument,\n subgraphModuleDocumentType,\n reducer as subgraphModuleReducer,\n utils as subgraphModuleUtils,\n} from \"../document-models/subgraph-module/v1/gen/index.js\";\n\nexport const SPECS_DIRNAME = \"specs\";\n\nconst documentModelDocumentType = \"powerhouse/document-model\";\n\ntype ActionsModule = Record<string, (input?: any) => Action>;\n\ntype SpecEntry = {\n documentType: string;\n subdir: string;\n reducer: Reducer<any>;\n utils: { fileExtension: string };\n actions: ActionsModule;\n createDocument: (state?: any) => PHDocument;\n jsonSpec: DocumentModelGlobalState;\n};\n\nconst SPECS: Record<string, SpecEntry> = {\n [documentModelDocumentType]: {\n documentType: documentModelDocumentType,\n subdir: \"document-models\",\n reducer: documentModelDocumentModelModule.reducer,\n utils: documentModelDocumentModelModule.utils,\n actions: documentModelDocumentModelModule.actions as ActionsModule,\n createDocument: documentModelDocumentModelModule.utils.createDocument,\n jsonSpec: documentModelDocumentModelModule.documentModel\n .global as DocumentModelGlobalState,\n },\n [documentEditorDocumentType]: {\n documentType: documentEditorDocumentType,\n subdir: \"editors\",\n reducer: documentEditorReducer as Reducer<any>,\n utils: documentEditorUtils,\n actions: documentEditorActions as unknown as ActionsModule,\n createDocument: createDocumentEditorDocument as (state?: any) => PHDocument,\n jsonSpec: documentEditorSpec as unknown as DocumentModelGlobalState,\n },\n [processorModuleDocumentType]: {\n documentType: processorModuleDocumentType,\n subdir: \"processors\",\n reducer: processorModuleReducer as Reducer<any>,\n utils: processorModuleUtils,\n actions: processorModuleActions as unknown as ActionsModule,\n createDocument: createProcessorModuleDocument as (\n state?: any,\n ) => PHDocument,\n jsonSpec: processorModuleSpec as unknown as DocumentModelGlobalState,\n },\n [subgraphModuleDocumentType]: {\n documentType: subgraphModuleDocumentType,\n subdir: \"subgraphs\",\n reducer: subgraphModuleReducer as Reducer<any>,\n utils: subgraphModuleUtils,\n actions: subgraphModuleActions as unknown as ActionsModule,\n createDocument: createSubgraphModuleDocument as (state?: any) => PHDocument,\n jsonSpec: subgraphModuleSpec as unknown as DocumentModelGlobalState,\n },\n [appModuleDocumentType]: {\n documentType: appModuleDocumentType,\n subdir: \"apps\",\n reducer: appModuleReducer as Reducer<any>,\n utils: appModuleUtils,\n actions: appModuleActions as unknown as ActionsModule,\n createDocument: createAppModuleDocument as (state?: any) => PHDocument,\n jsonSpec: appModuleSpec as unknown as DocumentModelGlobalState,\n },\n};\n\nexport function getSpecEntry(documentType: string): SpecEntry {\n const entry = SPECS[documentType];\n if (!entry) {\n throw new Error(`No spec handler registered for \"${documentType}\"`);\n }\n return entry;\n}\n\nexport function listSpecDocumentTypes(): string[] {\n return Object.keys(SPECS);\n}\n\n/** Returns the directory that holds specs for a given document type. */\nexport function specDir(projectDir: string, documentType: string): string {\n return join(projectDir, SPECS_DIRNAME, getSpecEntry(documentType).subdir);\n}\n\n/**\n * Deterministic path for a doc-type + display name.\n * Format: `<projectDir>/<specsDir>/<subdir>/<kebab-name>.<ext>.phd`.\n */\nexport function specPath(\n projectDir: string,\n documentType: string,\n name: string,\n): string {\n const entry = getSpecEntry(documentType);\n const baseName = kebabCase(name);\n const ext = stripLeadingDot(entry.utils.fileExtension);\n return join(specDir(projectDir, documentType), `${baseName}.${ext}.phd`);\n}\n\n/* baseSaveToFile expects the extension WITHOUT a leading dot (\"phdm\"), while the\n * document-model utils export it WITH one (\".phdm\"). Normalize so we can pass\n * either through. */\nexport function stripLeadingDot(ext: string): string {\n return ext.startsWith(\".\") ? ext.slice(1) : ext;\n}\n\n/** Saves a document into `<projectDir>/specs/<subdir>/<kebab-name>.<ext>.phd`. */\nexport async function saveSpec(\n doc: PHDocument,\n projectDir: string,\n): Promise<string> {\n const entry = getSpecEntry(doc.header.documentType);\n const dir = specDir(projectDir, doc.header.documentType);\n await mkdir(dir, { recursive: true });\n const name = kebabCase(doc.header.name || \"untitled\");\n return baseSaveToFile(\n doc,\n dir,\n stripLeadingDot(entry.utils.fileExtension),\n name,\n );\n}\n","/**\n * File-backed mirror of reactor-mcp's tool surface. Same function names and\n * input shapes — same agent code works whether it's targeting a live reactor\n * or a `specs/` folder on disk. The \"drive id\" is the project directory;\n * \"document id\" is the file path of the spec.\n *\n * See `packages/reactor-mcp/src/tools/reactor.ts` for the canonical schema.\n */\nimport type {\n Action,\n DocumentModelGlobalState,\n OperationSpecification,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport { camelCase } from \"change-case\";\nimport { baseLoadFromFile } from \"document-model/node\";\nimport { readdir, rm, stat } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport {\n getSpecEntry,\n listSpecDocumentTypes,\n saveSpec,\n specDir,\n SPECS_DIRNAME,\n} from \"./specs.js\";\n\nexport type DocumentModelInfo = {\n name: string;\n type: string;\n description: string;\n extension: string;\n authorName: string;\n authorWebsite: string;\n};\n\n/** Mirrors reactor-mcp `getDocumentModels`. */\nexport function getDocumentModels(): DocumentModelInfo[] {\n return listSpecDocumentTypes().map((documentType) => {\n const { jsonSpec } = getSpecEntry(documentType);\n return {\n name: jsonSpec.name,\n type: jsonSpec.id,\n description: jsonSpec.description ?? \"\",\n extension: jsonSpec.extension ?? \"\",\n authorName: jsonSpec.author?.name ?? \"\",\n authorWebsite: jsonSpec.author?.website ?? \"\",\n };\n });\n}\n\n/** Mirrors reactor-mcp `getDocumentModelSchema`. Returns the full\n * `DocumentModelGlobalState` (schema + operations + errors), same payload\n * shape reactor-mcp serves. */\nexport function getDocumentModelSchema(\n documentType: string,\n): DocumentModelGlobalState {\n return getSpecEntry(documentType).jsonSpec;\n}\n\n/** Mirrors reactor-mcp `getDocument`. Path = file location on disk. */\nexport async function getDocument(path: string): Promise<PHDocument> {\n // We don't know the documentType ahead of time, so try each registered\n // reducer until one loads cleanly. baseLoadFromFile validates against the\n // reducer; the wrong reducer rejects. Try the path's parent directory first\n // as a fast hint (matches our `specs/<subdir>/` convention).\n const subdir = pathSubdir(path);\n const hint = subdir\n ? listSpecDocumentTypes().find((t) => getSpecEntry(t).subdir === subdir)\n : undefined;\n const order = hint\n ? [hint, ...listSpecDocumentTypes().filter((t) => t !== hint)]\n : listSpecDocumentTypes();\n\n let lastError: unknown;\n for (const documentType of order) {\n const { reducer } = getSpecEntry(documentType);\n try {\n return await baseLoadFromFile(path, reducer);\n } catch (err) {\n lastError = err;\n }\n }\n throw new Error(\n `Failed to load spec at \"${path}\": no registered reducer accepted it. Last error: ${String(lastError)}`,\n );\n}\n\n/** Mirrors reactor-mcp `getDocuments`. `parentId` is the project directory\n * containing `specs/`. */\nexport async function getDocuments(\n projectDir: string,\n opts: { documentType?: string } = {},\n): Promise<PHDocument[]> {\n const documentTypes = opts.documentType\n ? [opts.documentType]\n : listSpecDocumentTypes();\n\n const results: PHDocument[] = [];\n for (const documentType of documentTypes) {\n const dir = specDir(projectDir, documentType);\n const exists = await stat(dir).then(\n (s) => s.isDirectory(),\n () => false,\n );\n if (!exists) continue;\n const entries = await readdir(dir);\n for (const entry of entries) {\n if (!entry.endsWith(\".phd\")) continue;\n results.push(await getDocument(join(dir, entry)));\n }\n }\n return results;\n}\n\n/** Mirrors reactor-mcp `createDocument`. Returns an in-memory document; the\n * caller persists with `saveSpec`. */\nexport function createDocument(\n documentType: string,\n opts: {\n name?: string;\n initialState?: { global?: unknown; local?: unknown };\n } = {},\n): PHDocument {\n const entry = getSpecEntry(documentType);\n const doc = entry.createDocument(opts.initialState);\n if (opts.name) doc.header.name = opts.name;\n return doc;\n}\n\nexport type ActionInput = {\n type: string;\n input?: unknown;\n scope?: string;\n};\n\n/** Mirrors reactor-mcp `addActions`. Validates every action up front against\n * the document model's latest specification, then applies them in order via\n * the reducer. If any action is invalid, throws an aggregated error and\n * leaves `doc` untouched. */\nexport function addActions(\n doc: PHDocument,\n actions: ActionInput[],\n): PHDocument {\n const entry = getSpecEntry(doc.header.documentType);\n const built = validateAndBuildActions(entry, actions);\n let current = doc;\n for (let i = 0; i < built.length; i++) {\n const action = built[i];\n current = entry.reducer(current, action);\n /* The base reducer wraps custom reducers in try/catch and records any\n * throw as `operation.error` instead of propagating. For an atomic\n * batch apply that's the wrong shape — surface the error so callers\n * (and `saveSpec`) bail out before persisting a half-applied doc. */\n const scope = action.scope ?? \"global\";\n const ops = current.operations[scope];\n const last = ops?.[ops.length - 1];\n if (last?.error) {\n const failures: ActionValidationError[] = [\n {\n index: i,\n type: actions[i].type ?? \"<missing>\",\n errors: [`Reducer error: ${last.error}`],\n },\n ];\n throw formatValidationError(failures);\n }\n }\n return current;\n}\n\nexport type ActionValidationError = {\n /** Position in the input array. */\n index: number;\n /** The action's `type` field (or `<missing>` when not a string). */\n type: string;\n /** Human-readable reasons the action was rejected. */\n errors: string[];\n};\n\n/** Validate a list of actions without applying them. Returns one entry per\n * invalid action with all of its problems aggregated. Used by `addActions`\n * and exposed for callers that want a dry-run check. */\nexport function validateActions(\n documentType: string,\n actions: ActionInput[],\n): ActionValidationError[] {\n const entry = getSpecEntry(documentType);\n const failures: ActionValidationError[] = [];\n for (let i = 0; i < actions.length; i++) {\n const errors = collectActionErrors(entry, actions[i]);\n if (errors.length > 0) {\n failures.push({ index: i, type: actions[i].type ?? \"<missing>\", errors });\n }\n }\n return failures;\n}\n\n/** Run validateActions across the batch and, on success, materialize the\n * built Action objects. On any failure throws with every action's errors\n * aggregated — the caller never sees a partial apply. */\nfunction validateAndBuildActions(\n entry: ReturnType<typeof getSpecEntry>,\n actions: ActionInput[],\n): Action[] {\n const built: Action[] = [];\n const failures: ActionValidationError[] = [];\n for (let i = 0; i < actions.length; i++) {\n const item = actions[i];\n const errors = collectActionErrors(entry, item);\n if (errors.length > 0) {\n failures.push({ index: i, type: item.type ?? \"<missing>\", errors });\n continue;\n }\n built.push(buildAction(entry.actions, item));\n }\n if (failures.length > 0) throw formatValidationError(failures);\n return built;\n}\n\n/* Mirrors reactor-mcp's `validateDocumentModelAction`: confirms the operation\n * is declared in the latest spec, looks up the action creator, runs the\n * creator's own input validation, and checks scope. */\nfunction collectActionErrors(\n entry: ReturnType<typeof getSpecEntry>,\n item: ActionInput,\n): string[] {\n const errors: string[] = [];\n if (typeof item.type !== \"string\" || item.type.length === 0) {\n errors.push(\"Missing `type` field\");\n return errors;\n }\n const specs = entry.jsonSpec.specifications;\n if (!specs || specs.length === 0) {\n errors.push(\"Document model has no specifications\");\n return errors;\n }\n const latest = specs[specs.length - 1];\n let operation: OperationSpecification | undefined;\n for (const module of latest.modules ?? []) {\n const found = (module.operations ?? []).find((op) => op.name === item.type);\n if (found) {\n operation = found;\n break;\n }\n }\n if (!operation) {\n errors.push(\n `Operation \"${item.type}\" is not defined in any module of the document model`,\n );\n }\n const creatorName = camelCase(item.type);\n const creator = entry.actions[creatorName];\n if (!creator) {\n errors.push(`No action creator found.`);\n } else {\n try {\n creator(item.input);\n } catch (err) {\n errors.push(\n `Input validation error: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n if (operation?.scope && item.scope && item.scope !== operation.scope) {\n errors.push(\n `Scope \"${item.scope}\" does not match operation scope \"${operation.scope}\"`,\n );\n }\n return errors;\n}\n\nfunction formatValidationError(failures: ActionValidationError[]): Error {\n const lines = failures.map(\n (f) => ` [${f.index}] ${f.type}: ${f.errors.join(\"; \")}`,\n );\n const header =\n failures.length === 1\n ? \"1 action failed validation:\"\n : `${failures.length} actions failed validation:`;\n const err = new Error([header, ...lines].join(\"\\n\")) as Error & {\n failures: ActionValidationError[];\n };\n err.failures = failures;\n return err;\n}\n\nfunction buildAction(\n actionsModule: Record<string, (input?: any) => Action>,\n item: ActionInput,\n): Action {\n const creatorName = camelCase(item.type);\n const creator = actionsModule[creatorName];\n if (!creator) {\n throw new Error(\n `No action creator found for \"${item.type}\" (looked up as \"${creatorName}\")`,\n );\n }\n const action = creator(item.input);\n // Caller may override the scope (creator picks a default).\n if (item.scope) action.scope = item.scope;\n return action;\n}\n\n/** Mirrors reactor-mcp `deleteDocument`. Removes the spec file from disk. */\nexport async function deleteDocument(\n path: string,\n): Promise<{ success: boolean }> {\n try {\n await rm(path);\n return { success: true };\n } catch {\n return { success: false };\n }\n}\n\n/* Convenience: persist after applying actions. Matches the typical agent\n * loop `getDocument → addActions → saveSpec` from the plan. */\nexport async function addActionsAndSave(\n path: string,\n projectDir: string,\n actions: ActionInput[],\n): Promise<{ doc: PHDocument; savedPath: string }> {\n const doc = await getDocument(path);\n const next = addActions(doc, actions);\n const savedPath = await saveSpec(next, projectDir);\n return { doc: next, savedPath };\n}\n\nfunction pathSubdir(filePath: string): string | undefined {\n const parts = filePath.split(/[/\\\\]/);\n const i = parts.lastIndexOf(SPECS_DIRNAME);\n if (i < 0 || i + 1 >= parts.length) return undefined;\n return parts[i + 1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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K;EAAM,WADF,MAAM,SAAS,MAAM,WAAW;EACnB;;AAGjC,SAAS,WAAW,UAAsC;CACxD,MAAM,QAAQ,SAAS,MAAM,QAAQ;CACrC,MAAM,IAAI,MAAM,YAAY,cAAc;AAC1C,KAAI,IAAI,KAAK,IAAI,KAAK,MAAM,OAAQ,QAAO,KAAA;AAC3C,QAAO,MAAM,IAAI"}
|
|
1
|
+
{"version":3,"file":"spec-api-CrmCurlh.js","names":["documentEditorReducer","documentEditorUtils","documentEditorActions","documentEditorSpec","processorModuleReducer","processorModuleUtils","processorModuleActions","processorModuleSpec","subgraphModuleReducer","subgraphModuleUtils","subgraphModuleActions","subgraphModuleSpec","appModuleReducer","appModuleUtils","appModuleActions","appModuleSpec"],"sources":["../document-models/app-module/app-module.json","../document-models/document-editor/document-editor.json","../document-models/processor-module/processor-module.json","../document-models/subgraph-module/subgraph-module.json","../codegen/specs.ts","../codegen/spec-api.ts"],"sourcesContent":["","","","","import type {\n Action,\n DocumentModelGlobalState,\n PHDocument,\n Reducer,\n} from \"@powerhousedao/shared/document-model\";\nimport { kebabCase } from \"change-case\";\nimport { documentModelDocumentModelModule } from \"document-model\";\nimport { baseSaveToFile } from \"document-model/node\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\n/* Import from gen/ + actions.ts directly (not the top-level barrel) so we\n * don't pull in `hooks.ts`, which depends on `@powerhousedao/reactor-browser`\n * (a browser-only module that breaks Node-side spec tooling). */\nimport appModuleSpec from \"../document-models/app-module/app-module.json\" with { type: \"json\" };\nimport { actions as appModuleActions } from \"../document-models/app-module/v1/actions.js\";\nimport {\n appModuleDocumentType,\n createAppModuleDocument,\n reducer as appModuleReducer,\n utils as appModuleUtils,\n} from \"../document-models/app-module/v1/gen/index.js\";\nimport documentEditorSpec from \"../document-models/document-editor/document-editor.json\" with { type: \"json\" };\nimport { actions as documentEditorActions } from \"../document-models/document-editor/v1/actions.js\";\nimport {\n createDocumentEditorDocument,\n documentEditorDocumentType,\n reducer as documentEditorReducer,\n utils as documentEditorUtils,\n} from \"../document-models/document-editor/v1/gen/index.js\";\nimport processorModuleSpec from \"../document-models/processor-module/processor-module.json\" with { type: \"json\" };\nimport { actions as processorModuleActions } from \"../document-models/processor-module/v1/actions.js\";\nimport {\n createProcessorModuleDocument,\n processorModuleDocumentType,\n reducer as processorModuleReducer,\n utils as processorModuleUtils,\n} from \"../document-models/processor-module/v1/gen/index.js\";\nimport subgraphModuleSpec from \"../document-models/subgraph-module/subgraph-module.json\" with { type: \"json\" };\nimport { actions as subgraphModuleActions } from \"../document-models/subgraph-module/v1/actions.js\";\nimport {\n createSubgraphModuleDocument,\n subgraphModuleDocumentType,\n reducer as subgraphModuleReducer,\n utils as subgraphModuleUtils,\n} from \"../document-models/subgraph-module/v1/gen/index.js\";\n\nexport const SPECS_DIRNAME = \"specs\";\n\nconst documentModelDocumentType = \"powerhouse/document-model\";\n\ntype ActionsModule = Record<string, (input?: any) => Action>;\n\ntype SpecEntry = {\n documentType: string;\n subdir: string;\n reducer: Reducer<any>;\n utils: { fileExtension: string };\n actions: ActionsModule;\n createDocument: (state?: any) => PHDocument;\n jsonSpec: DocumentModelGlobalState;\n};\n\nconst SPECS: Record<string, SpecEntry> = {\n [documentModelDocumentType]: {\n documentType: documentModelDocumentType,\n subdir: \"document-models\",\n reducer: documentModelDocumentModelModule.reducer,\n utils: documentModelDocumentModelModule.utils,\n actions: documentModelDocumentModelModule.actions as ActionsModule,\n createDocument: documentModelDocumentModelModule.utils.createDocument,\n jsonSpec: documentModelDocumentModelModule.documentModel\n .global as DocumentModelGlobalState,\n },\n [documentEditorDocumentType]: {\n documentType: documentEditorDocumentType,\n subdir: \"editors\",\n reducer: documentEditorReducer as Reducer<any>,\n utils: documentEditorUtils,\n actions: documentEditorActions as unknown as ActionsModule,\n createDocument: createDocumentEditorDocument as (state?: any) => PHDocument,\n jsonSpec: documentEditorSpec as unknown as DocumentModelGlobalState,\n },\n [processorModuleDocumentType]: {\n documentType: processorModuleDocumentType,\n subdir: \"processors\",\n reducer: processorModuleReducer as Reducer<any>,\n utils: processorModuleUtils,\n actions: processorModuleActions as unknown as ActionsModule,\n createDocument: createProcessorModuleDocument as (\n state?: any,\n ) => PHDocument,\n jsonSpec: processorModuleSpec as unknown as DocumentModelGlobalState,\n },\n [subgraphModuleDocumentType]: {\n documentType: subgraphModuleDocumentType,\n subdir: \"subgraphs\",\n reducer: subgraphModuleReducer as Reducer<any>,\n utils: subgraphModuleUtils,\n actions: subgraphModuleActions as unknown as ActionsModule,\n createDocument: createSubgraphModuleDocument as (state?: any) => PHDocument,\n jsonSpec: subgraphModuleSpec as unknown as DocumentModelGlobalState,\n },\n [appModuleDocumentType]: {\n documentType: appModuleDocumentType,\n subdir: \"apps\",\n reducer: appModuleReducer as Reducer<any>,\n utils: appModuleUtils,\n actions: appModuleActions as unknown as ActionsModule,\n createDocument: createAppModuleDocument as (state?: any) => PHDocument,\n jsonSpec: appModuleSpec as unknown as DocumentModelGlobalState,\n },\n};\n\nexport function getSpecEntry(documentType: string): SpecEntry {\n const entry = SPECS[documentType];\n if (!entry) {\n throw new Error(`No spec handler registered for \"${documentType}\"`);\n }\n return entry;\n}\n\nexport function listSpecDocumentTypes(): string[] {\n return Object.keys(SPECS);\n}\n\n/** Returns the directory that holds specs for a given document type. */\nexport function specDir(projectDir: string, documentType: string): string {\n return join(projectDir, SPECS_DIRNAME, getSpecEntry(documentType).subdir);\n}\n\n/**\n * Deterministic path for a doc-type + display name.\n * Format: `<projectDir>/<specsDir>/<subdir>/<kebab-name>.<ext>.phd`.\n */\nexport function specPath(\n projectDir: string,\n documentType: string,\n name: string,\n): string {\n const entry = getSpecEntry(documentType);\n const baseName = kebabCase(name);\n const ext = stripLeadingDot(entry.utils.fileExtension);\n return join(specDir(projectDir, documentType), `${baseName}.${ext}.phd`);\n}\n\n/* baseSaveToFile expects the extension WITHOUT a leading dot (\"phdm\"), while the\n * document-model utils export it WITH one (\".phdm\"). Normalize so we can pass\n * either through. */\nexport function stripLeadingDot(ext: string): string {\n return ext.startsWith(\".\") ? ext.slice(1) : ext;\n}\n\n/** Saves a document into `<projectDir>/specs/<subdir>/<kebab-name>.<ext>.phd`. */\nexport async function saveSpec(\n doc: PHDocument,\n projectDir: string,\n): Promise<string> {\n const entry = getSpecEntry(doc.header.documentType);\n const dir = specDir(projectDir, doc.header.documentType);\n await mkdir(dir, { recursive: true });\n const name = kebabCase(doc.header.name || \"untitled\");\n return baseSaveToFile(\n doc,\n dir,\n stripLeadingDot(entry.utils.fileExtension),\n name,\n );\n}\n","/**\n * File-backed mirror of reactor-mcp's tool surface. Same function names and\n * input shapes — same agent code works whether it's targeting a live reactor\n * or a `specs/` folder on disk. The \"drive id\" is the project directory;\n * \"document id\" is the file path of the spec.\n *\n * See `packages/reactor-mcp/src/tools/reactor.ts` for the canonical schema.\n */\nimport type {\n Action,\n DocumentModelGlobalState,\n OperationSpecification,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport { camelCase } from \"change-case\";\nimport { baseLoadFromFile } from \"document-model/node\";\nimport { readdir, rm, stat } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport {\n getSpecEntry,\n listSpecDocumentTypes,\n saveSpec,\n specDir,\n SPECS_DIRNAME,\n} from \"./specs.js\";\n\nexport type DocumentModelInfo = {\n name: string;\n type: string;\n description: string;\n extension: string;\n authorName: string;\n authorWebsite: string;\n};\n\n/** Mirrors reactor-mcp `getDocumentModels`. */\nexport function getDocumentModels(): DocumentModelInfo[] {\n return listSpecDocumentTypes().map((documentType) => {\n const { jsonSpec } = getSpecEntry(documentType);\n return {\n name: jsonSpec.name,\n type: jsonSpec.id,\n description: jsonSpec.description ?? \"\",\n extension: jsonSpec.extension ?? \"\",\n authorName: jsonSpec.author?.name ?? \"\",\n authorWebsite: jsonSpec.author?.website ?? \"\",\n };\n });\n}\n\n/** Mirrors reactor-mcp `getDocumentModelSchema`. Returns the full\n * `DocumentModelGlobalState` (schema + operations + errors), same payload\n * shape reactor-mcp serves. */\nexport function getDocumentModelSchema(\n documentType: string,\n): DocumentModelGlobalState {\n return getSpecEntry(documentType).jsonSpec;\n}\n\n/** Mirrors reactor-mcp `getDocument`. Path = file location on disk. */\nexport async function getDocument(path: string): Promise<PHDocument> {\n // We don't know the documentType ahead of time, so try each registered\n // reducer until one loads cleanly. baseLoadFromFile validates against the\n // reducer; the wrong reducer rejects. Try the path's parent directory first\n // as a fast hint (matches our `specs/<subdir>/` convention).\n const subdir = pathSubdir(path);\n const hint = subdir\n ? listSpecDocumentTypes().find((t) => getSpecEntry(t).subdir === subdir)\n : undefined;\n const order = hint\n ? [hint, ...listSpecDocumentTypes().filter((t) => t !== hint)]\n : listSpecDocumentTypes();\n\n let lastError: unknown;\n for (const documentType of order) {\n const { reducer } = getSpecEntry(documentType);\n try {\n return await baseLoadFromFile(path, reducer);\n } catch (err) {\n lastError = err;\n }\n }\n throw new Error(\n `Failed to load spec at \"${path}\": no registered reducer accepted it. Last error: ${String(lastError)}`,\n );\n}\n\n/** Mirrors reactor-mcp `getDocuments`. `parentId` is the project directory\n * containing `specs/`. */\nexport async function getDocuments(\n projectDir: string,\n opts: { documentType?: string } = {},\n): Promise<PHDocument[]> {\n const documentTypes = opts.documentType\n ? [opts.documentType]\n : listSpecDocumentTypes();\n\n const results: PHDocument[] = [];\n for (const documentType of documentTypes) {\n const dir = specDir(projectDir, documentType);\n const exists = await stat(dir).then(\n (s) => s.isDirectory(),\n () => false,\n );\n if (!exists) continue;\n const entries = await readdir(dir);\n for (const entry of entries) {\n if (!entry.endsWith(\".phd\")) continue;\n results.push(await getDocument(join(dir, entry)));\n }\n }\n return results;\n}\n\n/** Mirrors reactor-mcp `createDocument`. Returns an in-memory document; the\n * caller persists with `saveSpec`. */\nexport function createDocument(\n documentType: string,\n opts: {\n name?: string;\n initialState?: { global?: unknown; local?: unknown };\n } = {},\n): PHDocument {\n const entry = getSpecEntry(documentType);\n const doc = entry.createDocument(opts.initialState);\n if (opts.name) doc.header.name = opts.name;\n return doc;\n}\n\nexport type ActionInput = {\n type: string;\n input?: unknown;\n scope?: string;\n};\n\n/** Mirrors reactor-mcp `addActions`. Validates every action up front against\n * the document model's latest specification, then applies them in order via\n * the reducer. If any action is invalid, throws an aggregated error and\n * leaves `doc` untouched. */\nexport function addActions(\n doc: PHDocument,\n actions: ActionInput[],\n): PHDocument {\n const entry = getSpecEntry(doc.header.documentType);\n const built = validateAndBuildActions(entry, actions);\n let current = doc;\n for (let i = 0; i < built.length; i++) {\n const action = built[i];\n current = entry.reducer(current, action);\n /* The base reducer wraps custom reducers in try/catch and records any\n * throw as `operation.error` instead of propagating. For an atomic\n * batch apply that's the wrong shape — surface the error so callers\n * (and `saveSpec`) bail out before persisting a half-applied doc. */\n const scope = action.scope ?? \"global\";\n const ops = current.operations[scope];\n const last = ops?.[ops.length - 1];\n if (last?.error) {\n const failures: ActionValidationError[] = [\n {\n index: i,\n type: actions[i].type ?? \"<missing>\",\n errors: [`Reducer error: ${last.error}`],\n },\n ];\n throw formatValidationError(failures);\n }\n }\n return current;\n}\n\nexport type ActionValidationError = {\n /** Position in the input array. */\n index: number;\n /** The action's `type` field (or `<missing>` when not a string). */\n type: string;\n /** Human-readable reasons the action was rejected. */\n errors: string[];\n};\n\n/** Validate a list of actions without applying them. Returns one entry per\n * invalid action with all of its problems aggregated. Used by `addActions`\n * and exposed for callers that want a dry-run check. */\nexport function validateActions(\n documentType: string,\n actions: ActionInput[],\n): ActionValidationError[] {\n const entry = getSpecEntry(documentType);\n const failures: ActionValidationError[] = [];\n for (let i = 0; i < actions.length; i++) {\n const errors = collectActionErrors(entry, actions[i]);\n if (errors.length > 0) {\n failures.push({ index: i, type: actions[i].type ?? \"<missing>\", errors });\n }\n }\n return failures;\n}\n\n/** Run validateActions across the batch and, on success, materialize the\n * built Action objects. On any failure throws with every action's errors\n * aggregated — the caller never sees a partial apply. */\nfunction validateAndBuildActions(\n entry: ReturnType<typeof getSpecEntry>,\n actions: ActionInput[],\n): Action[] {\n const built: Action[] = [];\n const failures: ActionValidationError[] = [];\n for (let i = 0; i < actions.length; i++) {\n const item = actions[i];\n const errors = collectActionErrors(entry, item);\n if (errors.length > 0) {\n failures.push({ index: i, type: item.type ?? \"<missing>\", errors });\n continue;\n }\n built.push(buildAction(entry.actions, item));\n }\n if (failures.length > 0) throw formatValidationError(failures);\n return built;\n}\n\n/* Mirrors reactor-mcp's `validateDocumentModelAction`: confirms the operation\n * is declared in the latest spec, looks up the action creator, runs the\n * creator's own input validation, and checks scope. */\nfunction collectActionErrors(\n entry: ReturnType<typeof getSpecEntry>,\n item: ActionInput,\n): string[] {\n const errors: string[] = [];\n if (typeof item.type !== \"string\" || item.type.length === 0) {\n errors.push(\"Missing `type` field\");\n return errors;\n }\n const specs = entry.jsonSpec.specifications;\n if (!specs || specs.length === 0) {\n errors.push(\"Document model has no specifications\");\n return errors;\n }\n const latest = specs[specs.length - 1];\n let operation: OperationSpecification | undefined;\n for (const module of latest.modules ?? []) {\n const found = (module.operations ?? []).find((op) => op.name === item.type);\n if (found) {\n operation = found;\n break;\n }\n }\n if (!operation) {\n errors.push(\n `Operation \"${item.type}\" is not defined in any module of the document model`,\n );\n }\n const creatorName = camelCase(item.type);\n const creator = entry.actions[creatorName];\n if (!creator) {\n errors.push(`No action creator found.`);\n } else {\n try {\n creator(item.input);\n } catch (err) {\n errors.push(\n `Input validation error: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n if (operation?.scope && item.scope && item.scope !== operation.scope) {\n errors.push(\n `Scope \"${item.scope}\" does not match operation scope \"${operation.scope}\"`,\n );\n }\n return errors;\n}\n\nfunction formatValidationError(failures: ActionValidationError[]): Error {\n const lines = failures.map(\n (f) => ` [${f.index}] ${f.type}: ${f.errors.join(\"; \")}`,\n );\n const header =\n failures.length === 1\n ? \"1 action failed validation:\"\n : `${failures.length} actions failed validation:`;\n const err = new Error([header, ...lines].join(\"\\n\")) as Error & {\n failures: ActionValidationError[];\n };\n err.failures = failures;\n return err;\n}\n\nfunction buildAction(\n actionsModule: Record<string, (input?: any) => Action>,\n item: ActionInput,\n): Action {\n const creatorName = camelCase(item.type);\n const creator = actionsModule[creatorName];\n if (!creator) {\n throw new Error(\n `No action creator found for \"${item.type}\" (looked up as \"${creatorName}\")`,\n );\n }\n const action = creator(item.input);\n // Caller may override the scope (creator picks a default).\n if (item.scope) action.scope = item.scope;\n return action;\n}\n\n/** Mirrors reactor-mcp `deleteDocument`. Removes the spec file from disk. */\nexport async function deleteDocument(\n path: string,\n): Promise<{ success: boolean }> {\n try {\n await rm(path);\n return { success: true };\n } catch {\n return { success: false };\n }\n}\n\n/* Convenience: persist after applying actions. Matches the typical agent\n * loop `getDocument → addActions → saveSpec` from the plan. */\nexport async function addActionsAndSave(\n path: string,\n projectDir: string,\n actions: ActionInput[],\n): Promise<{ doc: PHDocument; savedPath: string }> {\n const doc = await getDocument(path);\n const next = addActions(doc, actions);\n const savedPath = await saveSpec(next, projectDir);\n return { doc: next, savedPath };\n}\n\nfunction pathSubdir(filePath: string): string | undefined {\n const parts = filePath.split(/[/\\\\]/);\n const i = parts.lastIndexOf(SPECS_DIRNAME);\n if (i < 0 || i + 1 >= parts.length) return undefined;\n return parts[i + 1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIgDA,MAAa,gBAAgB;AAE7B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8 @@
|
|
|
1
|
+
import { t as codegenFactoryBuilder } from "./factory-DtBWM7Ap.js";
|
|
2
|
+
import { t as vetraReadModelFactoryBuilder } from "./factory-Dnymdhbp.js";
|
|
3
|
+
//#region processors/switchboard.ts
|
|
4
|
+
const processorFactoryBuilders = [vetraReadModelFactoryBuilder, codegenFactoryBuilder];
|
|
5
|
+
//#endregion
|
|
6
|
+
export { processorFactoryBuilders };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=switchboard-D5upogwE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchboard-
|
|
1
|
+
{"version":3,"file":"switchboard-D5upogwE.js","names":[],"sources":["../processors/switchboard.ts"],"sourcesContent":["/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { ProcessorFactoryBuilder } from \"@powerhousedao/reactor-browser\";\nimport { codegenFactoryBuilder } from \"./codegen/factory.js\";\nimport { vetraReadModelFactoryBuilder } from \"./vetra-read-model/factory.js\";\n\nexport const processorFactoryBuilders: ProcessorFactoryBuilder[] = [\n vetraReadModelFactoryBuilder,\n codegenFactoryBuilder,\n];\n"],"mappings":";;;AAQA,MAAa,2BAAsD,CACjE,8BACA,sBACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/vetra",
|
|
3
|
-
"version": "6.2.2-dev.
|
|
3
|
+
"version": "6.2.2-dev.8",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"react": "19.2.6",
|
|
66
66
|
"zod": "4.3.6",
|
|
67
67
|
"tailwind-merge": "3.4.0",
|
|
68
|
-
"@powerhousedao/
|
|
69
|
-
"@powerhousedao/
|
|
70
|
-
"@powerhousedao/
|
|
71
|
-
"@powerhousedao/
|
|
72
|
-
"@powerhousedao/shared": "6.2.2-dev.
|
|
73
|
-
"document-model": "6.2.2-dev.
|
|
68
|
+
"@powerhousedao/config": "6.2.2-dev.8",
|
|
69
|
+
"@powerhousedao/design-system": "6.2.2-dev.8",
|
|
70
|
+
"@powerhousedao/codegen": "6.2.2-dev.8",
|
|
71
|
+
"@powerhousedao/reactor-browser": "6.2.2-dev.8",
|
|
72
|
+
"@powerhousedao/shared": "6.2.2-dev.8",
|
|
73
|
+
"document-model": "6.2.2-dev.8"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@tailwindcss/cli": "4.2.2",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"vite": "8.0.10",
|
|
90
90
|
"vite-tsconfig-paths": "6.1.1",
|
|
91
91
|
"vitest": "4.1.1",
|
|
92
|
-
"@powerhousedao/builder-tools": "6.2.2-dev.
|
|
92
|
+
"@powerhousedao/builder-tools": "6.2.2-dev.8"
|
|
93
93
|
},
|
|
94
94
|
"description": "Vetra — the agent-first builder platform for the Powerhouse ecosystem. Spec-driven and AI-native development of open-source, decentralized back-ends.",
|
|
95
95
|
"keywords": [
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { t as codegenFactoryBuilder } from "./factory-B6hBnFAf.js";
|
|
2
|
-
import { t as vetraReadModelFactoryBuilder } from "./factory-Cn0UwIFB.js";
|
|
3
|
-
//#region processors/switchboard.ts
|
|
4
|
-
const processorFactoryBuilders = [vetraReadModelFactoryBuilder, codegenFactoryBuilder];
|
|
5
|
-
//#endregion
|
|
6
|
-
export { processorFactoryBuilders };
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=switchboard-CvWiUgBP.js.map
|