@plitzi/sdk-mcp 0.33.0
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/CHANGELOG.md +15 -0
- package/README.md +175 -0
- package/dist/createServer.d.ts +11 -0
- package/dist/createServer.js +36 -0
- package/dist/createServer.test.d.ts +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +21 -0
- package/dist/modules/ai/AIEngine.d.ts +20 -0
- package/dist/modules/ai/AIEngine.js +120 -0
- package/dist/modules/ai/index.d.ts +4 -0
- package/dist/modules/ai/toolkit.d.ts +17 -0
- package/dist/modules/ai/toolkit.js +59 -0
- package/dist/modules/ai/toolkit.test.d.ts +1 -0
- package/dist/modules/mcp/apps/apps.test.d.ts +1 -0
- package/dist/modules/mcp/apps/example/index.d.ts +8 -0
- package/dist/modules/mcp/apps/example/view/index.tsx +70 -0
- package/dist/modules/mcp/apps/index.d.ts +11 -0
- package/dist/modules/mcp/apps/index.js +16 -0
- package/dist/modules/mcp/apps/render/index.d.ts +4 -0
- package/dist/modules/mcp/apps/render/index.js +17 -0
- package/dist/modules/mcp/apps/render/styles.d.ts +10 -0
- package/dist/modules/mcp/apps/render/styles.js +54 -0
- package/dist/modules/mcp/apps/render/styles.test.d.ts +1 -0
- package/dist/modules/mcp/apps/render/view/heldBatch.ts +107 -0
- package/dist/modules/mcp/apps/render/view/index.tsx +314 -0
- package/dist/modules/mcp/apps/render/view/streamProgress.ts +137 -0
- package/dist/modules/mcp/apps/shared/assets.d.ts +10 -0
- package/dist/modules/mcp/apps/shared/assets.js +10 -0
- package/dist/modules/mcp/apps/shared/bundle.d.ts +4 -0
- package/dist/modules/mcp/apps/shared/bundle.js +23 -0
- package/dist/modules/mcp/apps/shared/index.d.ts +3 -0
- package/dist/modules/mcp/apps/shared/page.d.ts +2 -0
- package/dist/modules/mcp/apps/shared/page.js +34 -0
- package/dist/modules/mcp/apps/shared/registerApp.d.ts +5 -0
- package/dist/modules/mcp/apps/shared/registerApp.js +43 -0
- package/dist/modules/mcp/apps/shared/resolve.d.ts +1 -0
- package/dist/modules/mcp/apps/shared/resolve.js +5 -0
- package/dist/modules/mcp/apps/shared/shell.ejs +59 -0
- package/dist/modules/mcp/apps/shared/zodEnglishOnly.d.ts +4 -0
- package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +23 -0
- package/dist/modules/mcp/catalogs/builtinCallbacks.d.ts +19 -0
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +139 -0
- package/dist/modules/mcp/catalogs/builtinComponents.d.ts +4 -0
- package/dist/modules/mcp/catalogs/builtinComponents.js +165 -0
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.d.ts +17 -0
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +50 -0
- package/dist/modules/mcp/catalogs/builtinTransformers.d.ts +28 -0
- package/dist/modules/mcp/catalogs/builtinTransformers.js +148 -0
- package/dist/modules/mcp/catalogs/builtinTransformers.test.d.ts +1 -0
- package/dist/modules/mcp/catalogs/builtinUtilities.d.ts +15 -0
- package/dist/modules/mcp/catalogs/builtinUtilities.js +90 -0
- package/dist/modules/mcp/catalogs/cssCatalog/border.d.ts +4 -0
- package/dist/modules/mcp/catalogs/cssCatalog/border.js +30 -0
- package/dist/modules/mcp/catalogs/cssCatalog/box.d.ts +4 -0
- package/dist/modules/mcp/catalogs/cssCatalog/box.js +31 -0
- package/dist/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts +1 -0
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.d.ts +34 -0
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +185 -0
- package/dist/modules/mcp/catalogs/cssCatalog/index.d.ts +18 -0
- package/dist/modules/mcp/catalogs/cssCatalog/index.js +131 -0
- package/dist/modules/mcp/catalogs/cssCatalog/layout.d.ts +9 -0
- package/dist/modules/mcp/catalogs/cssCatalog/layout.js +99 -0
- package/dist/modules/mcp/catalogs/cssCatalog/visual.d.ts +8 -0
- package/dist/modules/mcp/catalogs/cssCatalog/visual.js +147 -0
- package/dist/modules/mcp/catalogs/index.d.ts +9 -0
- package/dist/modules/mcp/catalogs/observed.d.ts +46 -0
- package/dist/modules/mcp/catalogs/observed.js +90 -0
- package/dist/modules/mcp/catalogs/paramSpec.d.ts +39 -0
- package/dist/modules/mcp/catalogs/paramSpec.js +69 -0
- package/dist/modules/mcp/catalogs/registry.d.ts +35 -0
- package/dist/modules/mcp/catalogs/registry.js +89 -0
- package/dist/modules/mcp/e2e/connector.test.d.ts +1 -0
- package/dist/modules/mcp/e2e/host.test.d.ts +1 -0
- package/dist/modules/mcp/e2e/index.d.ts +6 -0
- package/dist/modules/mcp/e2e/mcpEndpoint.d.ts +27 -0
- package/dist/modules/mcp/e2e/oauthConnector.test.d.ts +1 -0
- package/dist/modules/mcp/e2e/postMessageChannel.d.ts +22 -0
- package/dist/modules/mcp/e2e/renderingHost.d.ts +39 -0
- package/dist/modules/mcp/handler.d.ts +22 -0
- package/dist/modules/mcp/handler.js +83 -0
- package/dist/modules/mcp/helpers/agentPrompt.d.ts +4 -0
- package/dist/modules/mcp/helpers/agentPrompt.js +104 -0
- package/dist/modules/mcp/helpers/computeVersion.d.ts +1 -0
- package/dist/modules/mcp/helpers/computeVersion.js +16 -0
- package/dist/modules/mcp/helpers/guide.d.ts +4 -0
- package/dist/modules/mcp/helpers/guide.js +608 -0
- package/dist/modules/mcp/helpers/index.d.ts +8 -0
- package/dist/modules/mcp/helpers/interactions.d.ts +30 -0
- package/dist/modules/mcp/helpers/interactions.js +123 -0
- package/dist/modules/mcp/helpers/log.d.ts +8 -0
- package/dist/modules/mcp/helpers/log.js +64 -0
- package/dist/modules/mcp/helpers/log.test.d.ts +1 -0
- package/dist/modules/mcp/helpers/opResult.d.ts +13 -0
- package/dist/modules/mcp/helpers/opResult.js +18 -0
- package/dist/modules/mcp/helpers/space.d.ts +126 -0
- package/dist/modules/mcp/helpers/space.js +314 -0
- package/dist/modules/mcp/helpers/uris.d.ts +33 -0
- package/dist/modules/mcp/helpers/uris.js +50 -0
- package/dist/modules/mcp/index.d.ts +13 -0
- package/dist/modules/mcp/mcp.bench.d.ts +1 -0
- package/dist/modules/mcp/previewClient.d.ts +13 -0
- package/dist/modules/mcp/previewClient.js +31 -0
- package/dist/modules/mcp/proxy/config.d.ts +20 -0
- package/dist/modules/mcp/proxy/config.js +62 -0
- package/dist/modules/mcp/proxy/endpoint.test.d.ts +1 -0
- package/dist/modules/mcp/proxy/fetch.d.ts +18 -0
- package/dist/modules/mcp/proxy/fetch.js +91 -0
- package/dist/modules/mcp/proxy/grant.d.ts +25 -0
- package/dist/modules/mcp/proxy/grant.js +67 -0
- package/dist/modules/mcp/proxy/guard.d.ts +6 -0
- package/dist/modules/mcp/proxy/guard.js +38 -0
- package/dist/modules/mcp/proxy/handler.d.ts +8 -0
- package/dist/modules/mcp/proxy/handler.js +99 -0
- package/dist/modules/mcp/proxy/index.d.ts +8 -0
- package/dist/modules/mcp/proxy/payload.d.ts +8 -0
- package/dist/modules/mcp/proxy/payload.js +29 -0
- package/dist/modules/mcp/proxy/proxy.test.d.ts +1 -0
- package/dist/modules/mcp/proxy/rewrite.d.ts +18 -0
- package/dist/modules/mcp/proxy/rewrite.js +138 -0
- package/dist/modules/mcp/proxy/sign.d.ts +6 -0
- package/dist/modules/mcp/proxy/sign.js +15 -0
- package/dist/modules/mcp/proxy/types.d.ts +45 -0
- package/dist/modules/mcp/proxy/types.js +9 -0
- package/dist/modules/mcp/proxy/wiring.test.d.ts +1 -0
- package/dist/modules/mcp/resources/canonical.d.ts +6 -0
- package/dist/modules/mcp/resources/canonical.js +30 -0
- package/dist/modules/mcp/resources/connectors.d.ts +22 -0
- package/dist/modules/mcp/resources/connectors.js +46 -0
- package/dist/modules/mcp/resources/core.d.ts +5 -0
- package/dist/modules/mcp/resources/core.js +18 -0
- package/dist/modules/mcp/resources/envelope.d.ts +10 -0
- package/dist/modules/mcp/resources/envelope.js +14 -0
- package/dist/modules/mcp/resources/index.d.ts +9 -0
- package/dist/modules/mcp/resources/primer.d.ts +7 -0
- package/dist/modules/mcp/resources/primer.js +33 -0
- package/dist/modules/mcp/resources/register.d.ts +10 -0
- package/dist/modules/mcp/resources/register.js +205 -0
- package/dist/modules/mcp/resources/renderGuide.d.ts +10 -0
- package/dist/modules/mcp/resources/renderGuide.js +451 -0
- package/dist/modules/mcp/resources/router.d.ts +10 -0
- package/dist/modules/mcp/resources/router.js +39 -0
- package/dist/modules/mcp/resources/schema.d.ts +5 -0
- package/dist/modules/mcp/resources/schema.js +43 -0
- package/dist/modules/mcp/resources/style.d.ts +5 -0
- package/dist/modules/mcp/resources/style.js +34 -0
- package/dist/modules/mcp/screenshotClient.d.ts +13 -0
- package/dist/modules/mcp/screenshotClient.js +47 -0
- package/dist/modules/mcp/server.d.ts +31 -0
- package/dist/modules/mcp/server.js +127 -0
- package/dist/modules/mcp/tests/apply.test.d.ts +1 -0
- package/dist/modules/mcp/tests/bindings.test.d.ts +1 -0
- package/dist/modules/mcp/tests/connectors.test.d.ts +1 -0
- package/dist/modules/mcp/tests/css.test.d.ts +1 -0
- package/dist/modules/mcp/tests/helpers.d.ts +13 -0
- package/dist/modules/mcp/tests/interactions.test.d.ts +1 -0
- package/dist/modules/mcp/tests/pages.test.d.ts +1 -0
- package/dist/modules/mcp/tests/reads.test.d.ts +1 -0
- package/dist/modules/mcp/tests/schemaIds.test.d.ts +1 -0
- package/dist/modules/mcp/tests/search.test.d.ts +1 -0
- package/dist/modules/mcp/tests/skill.test.d.ts +1 -0
- package/dist/modules/mcp/tests/styles.test.d.ts +1 -0
- package/dist/modules/mcp/tests/tools.test.d.ts +1 -0
- package/dist/modules/mcp/tests/validation.test.d.ts +1 -0
- package/dist/modules/mcp/tools/apply/dispatch.d.ts +6 -0
- package/dist/modules/mcp/tools/apply/dispatch.js +128 -0
- package/dist/modules/mcp/tools/apply/index.d.ts +656 -0
- package/dist/modules/mcp/tools/apply/index.js +161 -0
- package/dist/modules/mcp/tools/apply/writeResult.d.ts +8 -0
- package/dist/modules/mcp/tools/apply/writeResult.js +37 -0
- package/dist/modules/mcp/tools/index.d.ts +18 -0
- package/dist/modules/mcp/tools/index.js +24 -0
- package/dist/modules/mcp/tools/operations/connectors/deleteConnector.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/connectors/deleteConnector.js +20 -0
- package/dist/modules/mcp/tools/operations/connectors/index.d.ts +188 -0
- package/dist/modules/mcp/tools/operations/connectors/index.js +12 -0
- package/dist/modules/mcp/tools/operations/connectors/manifest.d.ts +89 -0
- package/dist/modules/mcp/tools/operations/connectors/manifest.js +70 -0
- package/dist/modules/mcp/tools/operations/connectors/patchConnector.d.ts +94 -0
- package/dist/modules/mcp/tools/operations/connectors/patchConnector.js +58 -0
- package/dist/modules/mcp/tools/operations/connectors/upsertConnector.d.ts +98 -0
- package/dist/modules/mcp/tools/operations/connectors/upsertConnector.js +64 -0
- package/dist/modules/mcp/tools/operations/index.d.ts +2235 -0
- package/dist/modules/mcp/tools/operations/index.js +55 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +17 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +32 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +25 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +36 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +27 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +47 -0
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +10 -0
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +29 -0
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +16 -0
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +41 -0
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +27 -0
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +60 -0
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +55 -0
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +148 -0
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +16 -0
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +66 -0
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +32 -0
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +49 -0
- package/dist/modules/mcp/tools/operations/schema/index.d.ts +21 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +52 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +18 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +47 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +27 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +44 -0
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +236 -0
- package/dist/modules/mcp/tools/operations/schema/operations.js +41 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +25 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +14 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +77 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +36 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +44 -0
- package/dist/modules/mcp/tools/operations/schema/shared.d.ts +106 -0
- package/dist/modules/mcp/tools/operations/schema/shared.js +131 -0
- package/dist/modules/mcp/tools/operations/schema/translator.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/schema/translator.js +216 -0
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +18 -0
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +16 -0
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +42 -0
- package/dist/modules/mcp/tools/operations/schema/write.d.ts +42 -0
- package/dist/modules/mcp/tools/operations/schema/write.js +112 -0
- package/dist/modules/mcp/tools/operations/schemaIds.d.ts +6 -0
- package/dist/modules/mcp/tools/operations/schemaIds.js +58 -0
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +21 -0
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +28 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +24 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +41 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +40 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +21 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +28 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +24 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +21 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +28 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +24 -0
- package/dist/modules/mcp/tools/operations/style/index.d.ts +15 -0
- package/dist/modules/mcp/tools/operations/style/operations.d.ts +264 -0
- package/dist/modules/mcp/tools/operations/style/operations.js +29 -0
- package/dist/modules/mcp/tools/operations/style/shared.d.ts +116 -0
- package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
- package/dist/modules/mcp/tools/operations/style/translator.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/style/translator.js +101 -0
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +15 -0
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +21 -0
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +20 -0
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +22 -0
- package/dist/modules/mcp/tools/operations/style/write.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/style/write.js +108 -0
- package/dist/modules/mcp/tools/preview.d.ts +472 -0
- package/dist/modules/mcp/tools/preview.js +37 -0
- package/dist/modules/mcp/tools/read.d.ts +9 -0
- package/dist/modules/mcp/tools/read.js +51 -0
- package/dist/modules/mcp/tools/render.d.ts +506 -0
- package/dist/modules/mcp/tools/render.js +184 -0
- package/dist/modules/mcp/tools/render.test.d.ts +1 -0
- package/dist/modules/mcp/tools/screenshot.d.ts +656 -0
- package/dist/modules/mcp/tools/screenshot.js +83 -0
- package/dist/modules/mcp/tools/search.d.ts +15 -0
- package/dist/modules/mcp/tools/search.js +115 -0
- package/dist/modules/mcp/tools/shared/expandOperations.d.ts +13 -0
- package/dist/modules/mcp/tools/shared/expandOperations.js +44 -0
- package/dist/modules/mcp/tools/shared/tool.d.ts +72 -0
- package/dist/modules/mcp/tools/shared/tool.js +33 -0
- package/dist/modules/mcp/tools/shared/validator/audit.d.ts +4 -0
- package/dist/modules/mcp/tools/shared/validator/audit.js +124 -0
- package/dist/modules/mcp/tools/shared/validator/batch.d.ts +5 -0
- package/dist/modules/mcp/tools/shared/validator/batch.js +39 -0
- package/dist/modules/mcp/tools/shared/validator/bindings.d.ts +6 -0
- package/dist/modules/mcp/tools/shared/validator/bindings.js +70 -0
- package/dist/modules/mcp/tools/shared/validator/connectors.d.ts +19 -0
- package/dist/modules/mcp/tools/shared/validator/connectors.js +76 -0
- package/dist/modules/mcp/tools/shared/validator/context.d.ts +38 -0
- package/dist/modules/mcp/tools/shared/validator/context.js +35 -0
- package/dist/modules/mcp/tools/shared/validator/css.d.ts +4 -0
- package/dist/modules/mcp/tools/shared/validator/css.js +39 -0
- package/dist/modules/mcp/tools/shared/validator/elements.d.ts +7 -0
- package/dist/modules/mcp/tools/shared/validator/elements.js +68 -0
- package/dist/modules/mcp/tools/shared/validator/index.d.ts +8 -0
- package/dist/modules/mcp/tools/shared/validator/index.js +268 -0
- package/dist/modules/mcp/tools/shared/validator/interactions.d.ts +3 -0
- package/dist/modules/mcp/tools/shared/validator/interactions.js +103 -0
- package/dist/modules/mcp/tools/shared/validator/refs.d.ts +4 -0
- package/dist/modules/mcp/tools/shared/validator/refs.js +28 -0
- package/dist/modules/mcp/tools/validate.d.ts +653 -0
- package/dist/modules/mcp/tools/validate.js +47 -0
- package/dist/modules/mcp/types/aiSchema.d.ts +226 -0
- package/dist/modules/mcp/types/appTypes.d.ts +26 -0
- package/dist/modules/mcp/types/index.d.ts +5 -0
- package/dist/modules/mcp/types/previewTypes.d.ts +25 -0
- package/dist/modules/mcp/types/screenshotTypes.d.ts +29 -0
- package/dist/modules/mcp/types/toolTypes.d.ts +145 -0
- package/dist/modules/oauth/authorize.d.ts +7 -0
- package/dist/modules/oauth/authorize.js +177 -0
- package/dist/modules/oauth/challenge.d.ts +11 -0
- package/dist/modules/oauth/challenge.js +33 -0
- package/dist/modules/oauth/consentPage.d.ts +7 -0
- package/dist/modules/oauth/consentPage.js +118 -0
- package/dist/modules/oauth/metadata.d.ts +40 -0
- package/dist/modules/oauth/metadata.js +69 -0
- package/dist/modules/oauth/oauth.test.d.ts +1 -0
- package/dist/modules/oauth/params.d.ts +5 -0
- package/dist/modules/oauth/params.js +5 -0
- package/dist/modules/oauth/pkce.d.ts +6 -0
- package/dist/modules/oauth/pkce.js +15 -0
- package/dist/modules/oauth/records.d.ts +71 -0
- package/dist/modules/oauth/records.js +46 -0
- package/dist/modules/oauth/register.d.ts +5 -0
- package/dist/modules/oauth/register.js +55 -0
- package/dist/modules/oauth/respond.d.ts +13 -0
- package/dist/modules/oauth/respond.js +44 -0
- package/dist/modules/oauth/token.d.ts +5 -0
- package/dist/modules/oauth/token.js +100 -0
- package/dist/options.d.ts +73 -0
- package/dist/packageBoundary.test.d.ts +1 -0
- package/dist/pipeline.d.ts +12 -0
- package/dist/pipeline.js +29 -0
- package/dist/pipeline.test.d.ts +1 -0
- package/dist/preview/createPreview.d.ts +10 -0
- package/dist/preview/createPreview.js +83 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.js +7 -0
- package/dist/stages/mcp.d.ts +4 -0
- package/dist/stages/mcp.js +30 -0
- package/dist/stages/oauth.d.ts +19 -0
- package/dist/stages/oauth.js +114 -0
- package/dist/stages/preview.d.ts +2 -0
- package/dist/stages/preview.js +37 -0
- package/dist/stages/proxy.d.ts +3 -0
- package/dist/stages/proxy.js +14 -0
- package/dist/tests/httpRequest.d.ts +14 -0
- package/package.json +77 -0
- package/skills/plitzi-render/SKILL.md +174 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { operation } from "./operations/index.js";
|
|
2
|
+
import { defineTool, imageResult } from "./shared/tool.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/modules/mcp/tools/screenshot.ts
|
|
5
|
+
var VIEWPORTS = {
|
|
6
|
+
desktop: {
|
|
7
|
+
label: "desktop",
|
|
8
|
+
width: 1440,
|
|
9
|
+
height: 900
|
|
10
|
+
},
|
|
11
|
+
mobile: {
|
|
12
|
+
label: "mobile",
|
|
13
|
+
width: 390,
|
|
14
|
+
height: 844
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var resolveViewports = (choice) => {
|
|
18
|
+
if (choice === "both") return [VIEWPORTS.desktop, VIEWPORTS.mobile];
|
|
19
|
+
if (choice === "mobile") return [VIEWPORTS.mobile];
|
|
20
|
+
return [VIEWPORTS.desktop];
|
|
21
|
+
};
|
|
22
|
+
var screenshotShape = {
|
|
23
|
+
pageRef: z.string().optional().describe("Page ref or id to capture; defaults to the space default page"),
|
|
24
|
+
operations: z.array(operation).max(100).optional().describe("Unsaved edits to apply before rendering, so you can screenshot a proposed change WITHOUT persisting it (same op vocabulary as plitzi_apply). Omit to capture the current saved state."),
|
|
25
|
+
viewport: z.enum([
|
|
26
|
+
"desktop",
|
|
27
|
+
"mobile",
|
|
28
|
+
"both"
|
|
29
|
+
]).optional().describe("Which viewport(s) to capture. \"both\" catches responsive issues (e.g. overflow at one width). Default desktop.")
|
|
30
|
+
};
|
|
31
|
+
var screenshotTool = defineTool({
|
|
32
|
+
name: "plitzi_screenshot",
|
|
33
|
+
title: "Screenshot",
|
|
34
|
+
description: "Render a page to a real PNG image so you can SEE the visual result of your edits — overflow, misalignment and broken layout that data alone never reveals. Pass unsaved `operations` to screenshot a proposed change before committing, and viewport \"both\" to compare desktop and mobile. Returns the image(s).",
|
|
35
|
+
inputShape: screenshotShape,
|
|
36
|
+
access: "read",
|
|
37
|
+
requires: "screenshot",
|
|
38
|
+
run: async (input, ctx) => {
|
|
39
|
+
if (!ctx.preview || ctx.spaceId === void 0) return {
|
|
40
|
+
error: "PREVIEW_UNAVAILABLE",
|
|
41
|
+
message: "Visual preview is not enabled on this server.",
|
|
42
|
+
hint: "Preview needs the SSR render service; it is unavailable in MCP-only mode."
|
|
43
|
+
};
|
|
44
|
+
const pv = await ctx.preview.render({
|
|
45
|
+
spaceId: ctx.spaceId,
|
|
46
|
+
env: ctx.env,
|
|
47
|
+
pageRef: input.pageRef,
|
|
48
|
+
operations: input.operations
|
|
49
|
+
});
|
|
50
|
+
if (!pv.ok) return pv;
|
|
51
|
+
const viewports = resolveViewports(input.viewport);
|
|
52
|
+
if (!ctx.screenshot) return {
|
|
53
|
+
warning: "SCREENSHOT_DISABLED",
|
|
54
|
+
message: "The screenshot service is not configured; returning the HTML preview instead.",
|
|
55
|
+
pageRef: input.pageRef ?? "default",
|
|
56
|
+
pagePath: pv.pagePath,
|
|
57
|
+
stateVersion: pv.stateVersion,
|
|
58
|
+
html: pv.html
|
|
59
|
+
};
|
|
60
|
+
const shot = await ctx.screenshot.capture({
|
|
61
|
+
pagePath: pv.pagePath,
|
|
62
|
+
token: pv.token,
|
|
63
|
+
viewports
|
|
64
|
+
});
|
|
65
|
+
if (!shot.ok) return {
|
|
66
|
+
warning: "SCREENSHOT_UNAVAILABLE",
|
|
67
|
+
message: `The screenshot service failed (${shot.message}); returning the HTML preview instead.`,
|
|
68
|
+
hint: "The dedicated browser service is down or unreachable. Inspect the HTML, or retry later.",
|
|
69
|
+
pageRef: input.pageRef ?? "default",
|
|
70
|
+
pagePath: pv.pagePath,
|
|
71
|
+
stateVersion: pv.stateVersion,
|
|
72
|
+
html: pv.html
|
|
73
|
+
};
|
|
74
|
+
return imageResult(shot.images, {
|
|
75
|
+
pageRef: input.pageRef ?? "default",
|
|
76
|
+
pagePath: pv.pagePath,
|
|
77
|
+
stateVersion: pv.stateVersion,
|
|
78
|
+
viewports: viewports.map((v) => v.label)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
//#endregion
|
|
83
|
+
export { screenshotShape, screenshotTool };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Space } from '../helpers';
|
|
3
|
+
import { Env, SearchInput, SearchResponse } from '../types';
|
|
4
|
+
export declare const searchShape: {
|
|
5
|
+
query: z.ZodString;
|
|
6
|
+
filters: z.ZodOptional<z.ZodObject<{
|
|
7
|
+
type: z.ZodOptional<z.ZodString>;
|
|
8
|
+
pageRef: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>>;
|
|
10
|
+
include: z.ZodOptional<z.ZodLiteral<"detail">>;
|
|
11
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
};
|
|
14
|
+
export declare const search: (input: SearchInput, space: Space, env: Env) => SearchResponse;
|
|
15
|
+
export declare const searchTool: import('.').ToolDef;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { computeVersion } from "../helpers/computeVersion.js";
|
|
2
|
+
import { elementRefOf, getPageElements, isPageElement, nameOf, pageRefOf, pageRefOfElement } from "../helpers/space.js";
|
|
3
|
+
import { elementUri, pageUri } from "../helpers/uris.js";
|
|
4
|
+
import { definitionRefs, definitionToAI } from "./operations/style/translator.js";
|
|
5
|
+
import { elementView, pageSkeletonToAI } from "./operations/schema/translator.js";
|
|
6
|
+
import { defineTool } from "./shared/tool.js";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
//#region src/modules/mcp/tools/search.ts
|
|
9
|
+
var searchShape = {
|
|
10
|
+
query: z.string().describe("Case-insensitive match on label, type and attribute values"),
|
|
11
|
+
filters: z.object({
|
|
12
|
+
type: z.string().optional(),
|
|
13
|
+
pageRef: z.string().optional()
|
|
14
|
+
}).optional(),
|
|
15
|
+
include: z.literal("detail").optional().describe("Set to \"detail\" to inline each hit's full props/style so an edit needs no follow-up read"),
|
|
16
|
+
limit: z.number().int().min(1).max(100).optional().describe("Max element hits to return (default 50). Response echoes total and, if more remain, nextOffset."),
|
|
17
|
+
offset: z.number().int().min(0).optional().describe("Element hits to skip (default 0). Page by re-calling with offset = nextOffset until it is absent.")
|
|
18
|
+
};
|
|
19
|
+
var breadcrumb = (schema, el) => {
|
|
20
|
+
const chain = [];
|
|
21
|
+
let current = el;
|
|
22
|
+
const guard = /* @__PURE__ */ new Set();
|
|
23
|
+
while (current && !guard.has(current.id)) {
|
|
24
|
+
guard.add(current.id);
|
|
25
|
+
chain.push(nameOf(current));
|
|
26
|
+
current = current.definition.parentId ? schema.flat[current.definition.parentId] : void 0;
|
|
27
|
+
}
|
|
28
|
+
return chain.reverse();
|
|
29
|
+
};
|
|
30
|
+
var search = (input, space, env) => {
|
|
31
|
+
const query = input.query.toLowerCase();
|
|
32
|
+
const matched = [];
|
|
33
|
+
for (const el of Object.values(space.schema.flat)) {
|
|
34
|
+
if (isPageElement(space.schema, el)) continue;
|
|
35
|
+
if (input.filters?.type && el.definition.type !== input.filters.type) continue;
|
|
36
|
+
const pageRef = pageRefOfElement(space.schema, el);
|
|
37
|
+
if (input.filters?.pageRef && pageRef !== input.filters.pageRef) continue;
|
|
38
|
+
const matches = [];
|
|
39
|
+
if (el.definition.label.toLowerCase().includes(query)) matches.push(`label: ${el.definition.label}`);
|
|
40
|
+
if (el.definition.type.toLowerCase().includes(query)) matches.push(`type: ${el.definition.type}`);
|
|
41
|
+
for (const [key, value] of Object.entries(el.attributes)) if (String(value).toLowerCase().includes(query)) matches.push(`${key}: ${String(value).slice(0, 100)}`);
|
|
42
|
+
if (matches.length === 0) continue;
|
|
43
|
+
matched.push({
|
|
44
|
+
el,
|
|
45
|
+
pageRef,
|
|
46
|
+
ref: elementRefOf(el),
|
|
47
|
+
matches
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const offset = input.offset ?? 0;
|
|
51
|
+
const limit = input.limit ?? 50;
|
|
52
|
+
const total = matched.length;
|
|
53
|
+
const nextOffset = offset + limit < total ? offset + limit : void 0;
|
|
54
|
+
const results = matched.slice(offset, offset + limit).map((hit) => {
|
|
55
|
+
const { detail, version } = elementView(space.schema, hit.el, space.style);
|
|
56
|
+
return {
|
|
57
|
+
pageRef: hit.pageRef,
|
|
58
|
+
ref: hit.ref,
|
|
59
|
+
uri: elementUri(env, hit.ref),
|
|
60
|
+
pageUri: pageUri(env, hit.pageRef),
|
|
61
|
+
stateVersion: version,
|
|
62
|
+
parentRef: detail.parentRef,
|
|
63
|
+
path: breadcrumb(space.schema, hit.el),
|
|
64
|
+
label: hit.el.definition.label,
|
|
65
|
+
type: hit.el.definition.type,
|
|
66
|
+
matches: hit.matches,
|
|
67
|
+
detail: input.include === "detail" ? detail : void 0
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
const definitions = [];
|
|
71
|
+
for (const ref of definitionRefs(space.style)) {
|
|
72
|
+
if (ref.toLowerCase().includes(query)) {
|
|
73
|
+
const def = definitionToAI(space.style, ref);
|
|
74
|
+
if (def) definitions.push(def);
|
|
75
|
+
}
|
|
76
|
+
if (definitions.length >= 50) break;
|
|
77
|
+
}
|
|
78
|
+
const pages = [];
|
|
79
|
+
for (const page of getPageElements(space.schema)) {
|
|
80
|
+
const label = nameOf(page);
|
|
81
|
+
const slug = typeof page.attributes.slug === "string" ? page.attributes.slug : "";
|
|
82
|
+
const matches = [];
|
|
83
|
+
if (label.toLowerCase().includes(query)) matches.push(`label: ${label}`);
|
|
84
|
+
if (slug && slug.toLowerCase().includes(query)) matches.push(`slug: ${slug}`);
|
|
85
|
+
if (matches.length === 0) continue;
|
|
86
|
+
const ref = pageRefOf(page);
|
|
87
|
+
pages.push({
|
|
88
|
+
ref,
|
|
89
|
+
uri: pageUri(env, ref),
|
|
90
|
+
stateVersion: computeVersion(pageSkeletonToAI(space.schema, page, space.style)),
|
|
91
|
+
label,
|
|
92
|
+
slug,
|
|
93
|
+
matches
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
results,
|
|
98
|
+
total,
|
|
99
|
+
offset,
|
|
100
|
+
limit,
|
|
101
|
+
nextOffset,
|
|
102
|
+
definitions: definitions.length > 0 ? definitions : void 0,
|
|
103
|
+
pages: pages.length > 0 ? pages : void 0
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
var searchTool = defineTool({
|
|
107
|
+
name: "plitzi_search",
|
|
108
|
+
title: "Search",
|
|
109
|
+
description: "FIND elements when you know what you want but not its ref/uri (e.g. \"the hero button\"). Matches label, type or attribute value across all pages. Each hit returns the element uri, its stateVersion (edit with optimistic concurrency, no read needed) and its tree path. Pass include: \"detail\" to inline the full props/style of each hit plus resolvedStyle (the CSS of its classes). Also returns any style definitions matching the query (with full CSS) under `definitions`, and matching pages under `pages`. Element hits are paginated: it returns at most `limit` (default 50) starting at `offset`, plus `total` and — while more remain — `nextOffset` to fetch the next page.",
|
|
110
|
+
inputShape: searchShape,
|
|
111
|
+
access: "read",
|
|
112
|
+
run: (input, ctx) => search(input, ctx.space, ctx.env)
|
|
113
|
+
});
|
|
114
|
+
//#endregion
|
|
115
|
+
export { search, searchShape, searchTool };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ValidationError } from '../../types';
|
|
2
|
+
import { Operation } from '../operations';
|
|
3
|
+
/** Rewrites the sugar ops into the vocabulary the rest of the pipeline knows, BEFORE validation — today that is
|
|
4
|
+
* `repeatElement`, which stands for the `upsertElement` its template + rows expand to. Everything downstream
|
|
5
|
+
* (validator, dispatch, audit, versions) therefore stays unaware of it, and a row that renders a bad element is
|
|
6
|
+
* reported by the ordinary element checks.
|
|
7
|
+
*
|
|
8
|
+
* One op in, one op out: the indices the agent sent are the indices every error path names, so `operations[3]`
|
|
9
|
+
* still means the fourth operation it wrote. */
|
|
10
|
+
export declare const expandOperations: (ops: Operation[]) => {
|
|
11
|
+
operations: Operation[];
|
|
12
|
+
errors: ValidationError[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { expandRepeat } from "../operations/schema/elements/repeatElement.js";
|
|
2
|
+
//#region src/modules/mcp/tools/shared/expandOperations.ts
|
|
3
|
+
/** Rewrites the sugar ops into the vocabulary the rest of the pipeline knows, BEFORE validation — today that is
|
|
4
|
+
* `repeatElement`, which stands for the `upsertElement` its template + rows expand to. Everything downstream
|
|
5
|
+
* (validator, dispatch, audit, versions) therefore stays unaware of it, and a row that renders a bad element is
|
|
6
|
+
* reported by the ordinary element checks.
|
|
7
|
+
*
|
|
8
|
+
* One op in, one op out: the indices the agent sent are the indices every error path names, so `operations[3]`
|
|
9
|
+
* still means the fourth operation it wrote. */
|
|
10
|
+
var expandOperations = (ops) => {
|
|
11
|
+
if (!ops.some((op) => op.type === "repeatElement")) return {
|
|
12
|
+
operations: ops,
|
|
13
|
+
errors: []
|
|
14
|
+
};
|
|
15
|
+
const operations = [];
|
|
16
|
+
const errors = [];
|
|
17
|
+
for (const [index, op] of ops.entries()) {
|
|
18
|
+
if (op.type !== "repeatElement") {
|
|
19
|
+
operations.push(op);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const expanded = expandRepeat(op);
|
|
23
|
+
if (!expanded.element) {
|
|
24
|
+
errors.push(...expanded.errors.map((error) => ({
|
|
25
|
+
...error,
|
|
26
|
+
path: `operations[${index}].${error.path}`
|
|
27
|
+
})));
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
operations.push({
|
|
31
|
+
type: "upsertElement",
|
|
32
|
+
pageRef: op.pageRef,
|
|
33
|
+
element: expanded.element,
|
|
34
|
+
...op.parentRef === void 0 ? {} : { parentRef: op.parentRef },
|
|
35
|
+
...op.position === void 0 ? {} : { position: op.position }
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
operations,
|
|
40
|
+
errors
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { expandOperations };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z, ZodObject, ZodRawShape } from 'zod';
|
|
2
|
+
import { Space } from '../../helpers';
|
|
3
|
+
import { ResourceProxy } from '../../proxy';
|
|
4
|
+
import { PreviewClient, ScreenshotClient, ScreenshotImage, Env, Persisters } from '../../types';
|
|
5
|
+
import { McpUiToolMeta } from '@modelcontextprotocol/ext-apps';
|
|
6
|
+
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
/** Everything a tool needs at call time: the loaded space, the target environment, and the persisters (only the
|
|
8
|
+
* write tools use them). Built by whoever hosts the tools — the standalone MCP server or the in-process AI
|
|
9
|
+
* engine — so a tool's behavior never touches spaceId resolution or adapters directly. `spaceId`, `preview` and
|
|
10
|
+
* `screenshot` are present only when the host wired them (the visual-preview tools need them). */
|
|
11
|
+
export interface ToolContext {
|
|
12
|
+
space: Space;
|
|
13
|
+
env: Env;
|
|
14
|
+
persisters: Persisters;
|
|
15
|
+
spaceId?: number;
|
|
16
|
+
preview?: PreviewClient;
|
|
17
|
+
screenshot?: ScreenshotClient;
|
|
18
|
+
/** Where a rendered widget loads its external resources from, when the host wired one (see `mcpAi.proxy`). Only
|
|
19
|
+
* plitzi_render uses it: a widget renders inside the host's sandbox, where an undeclared origin cannot be
|
|
20
|
+
* reached at all. */
|
|
21
|
+
proxy?: ResourceProxy;
|
|
22
|
+
}
|
|
23
|
+
/** A capability a tool depends on; the host skips registering a tool whose capability it did not wire (so
|
|
24
|
+
* plitzi_screenshot simply does not appear when no browser service is configured). */
|
|
25
|
+
export type ToolRequires = 'screenshot';
|
|
26
|
+
/** Build the MCP CallToolResult for an image-returning tool: a text meta block followed by one image block per
|
|
27
|
+
* PNG, so a vision-capable agent (or MCP client) sees the render directly. */
|
|
28
|
+
export declare const imageResult: (images: ScreenshotImage[], meta: unknown) => CallToolResult;
|
|
29
|
+
/** What a tool author writes: identity, the input schema that is the contract sent to the agent, and a typed
|
|
30
|
+
* `run` (its args are inferred from `inputShape`, so no cast). `access` marks whether it persists — a 'write'
|
|
31
|
+
* tool previews (dryRun) in plan mode and can persist in build mode; a 'read' tool never writes. */
|
|
32
|
+
export interface ToolSpec<Shape extends ZodRawShape> {
|
|
33
|
+
name: string;
|
|
34
|
+
title: string;
|
|
35
|
+
description: string;
|
|
36
|
+
inputShape: Shape;
|
|
37
|
+
access: 'read' | 'write';
|
|
38
|
+
/** A host capability this tool needs; hosts that did not wire it skip registering the tool. */
|
|
39
|
+
requires?: ToolRequires;
|
|
40
|
+
/** The tool operates on no space (plitzi_render authors a throwaway one), so the host must NOT resolve a spaceId
|
|
41
|
+
* or load a space for it — that keeps it callable with no auth, on the public surface. */
|
|
42
|
+
spaceless?: boolean;
|
|
43
|
+
/** MCP Apps: link this tool to an interactive UI resource (a `ui://` HTML page the host renders in a sandboxed
|
|
44
|
+
* iframe, receiving the tool result). Registered as the tool's `_meta.ui` — see registerAppTool. */
|
|
45
|
+
ui?: McpUiToolMeta;
|
|
46
|
+
run: (input: z.infer<ZodObject<Shape>>, ctx: ToolContext) => unknown;
|
|
47
|
+
/** What the tool still does on a connection that carries NO space (a guest / widgets-only grant): it keeps only
|
|
48
|
+
* the part that needs none — plitzi_read serves the public documents and says so for the rest. A tool that
|
|
49
|
+
* defines this stays advertised there; one that does not is not registered at all, so the agent never calls
|
|
50
|
+
* something that cannot work. */
|
|
51
|
+
runPublic?: (input: z.infer<ZodObject<Shape>>, env: Env) => unknown;
|
|
52
|
+
}
|
|
53
|
+
/** What the registry holds and the hosts register from: the same metadata plus a type-erased `execute` that
|
|
54
|
+
* validates raw args against the shape and delegates to the typed `run`. Produced by `defineTool`. */
|
|
55
|
+
export interface ToolDef {
|
|
56
|
+
name: string;
|
|
57
|
+
title: string;
|
|
58
|
+
description: string;
|
|
59
|
+
inputShape: ZodRawShape;
|
|
60
|
+
access: 'read' | 'write';
|
|
61
|
+
requires?: ToolRequires;
|
|
62
|
+
spaceless?: boolean;
|
|
63
|
+
ui?: McpUiToolMeta;
|
|
64
|
+
execute: (args: unknown, ctx: ToolContext) => unknown;
|
|
65
|
+
/** Present when the tool degrades to a space-less connection (see ToolSpec.runPublic); its absence is what tells
|
|
66
|
+
* the host not to advertise the tool there. */
|
|
67
|
+
executePublic?: (args: unknown, env: Env) => unknown;
|
|
68
|
+
}
|
|
69
|
+
/** Author a tool: give it its metadata, its input shape and a typed `run`. The returned descriptor parses the
|
|
70
|
+
* raw args against the shape before handing them to `run`, so `run` is fully typed and no cast is needed.
|
|
71
|
+
* Adding a tool is: call defineTool in its own file and append it to the `tools` registry. */
|
|
72
|
+
export declare const defineTool: <Shape extends ZodRawShape>(spec: ToolSpec<Shape>) => ToolDef;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/modules/mcp/tools/shared/tool.ts
|
|
3
|
+
/** Build the MCP CallToolResult for an image-returning tool: a text meta block followed by one image block per
|
|
4
|
+
* PNG, so a vision-capable agent (or MCP client) sees the render directly. */
|
|
5
|
+
var imageResult = (images, meta) => ({ content: [{
|
|
6
|
+
type: "text",
|
|
7
|
+
text: JSON.stringify(meta)
|
|
8
|
+
}, ...images.map((img) => ({
|
|
9
|
+
type: "image",
|
|
10
|
+
data: img.data,
|
|
11
|
+
mimeType: img.mimeType
|
|
12
|
+
}))] });
|
|
13
|
+
/** Author a tool: give it its metadata, its input shape and a typed `run`. The returned descriptor parses the
|
|
14
|
+
* raw args against the shape before handing them to `run`, so `run` is fully typed and no cast is needed.
|
|
15
|
+
* Adding a tool is: call defineTool in its own file and append it to the `tools` registry. */
|
|
16
|
+
var defineTool = (spec) => {
|
|
17
|
+
const { runPublic } = spec;
|
|
18
|
+
const parse = (args) => z.object(spec.inputShape).parse(args);
|
|
19
|
+
return {
|
|
20
|
+
name: spec.name,
|
|
21
|
+
title: spec.title,
|
|
22
|
+
description: spec.description,
|
|
23
|
+
inputShape: spec.inputShape,
|
|
24
|
+
access: spec.access,
|
|
25
|
+
requires: spec.requires,
|
|
26
|
+
spaceless: spec.spaceless,
|
|
27
|
+
ui: spec.ui,
|
|
28
|
+
execute: (args, ctx) => spec.run(parse(args), ctx),
|
|
29
|
+
...runPublic ? { executePublic: (args, env) => runPublic(parse(args), env) } : {}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { defineTool, imageResult };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { elementRefOf, findElementByRef } from "../../../helpers/space.js";
|
|
2
|
+
import { definitionToAI, globalStyleToAI, idStyleToAI } from "../../operations/style/translator.js";
|
|
3
|
+
import { checkBindingSourceScope, checkBindingTarget, checkBindingTransformers } from "./bindings.js";
|
|
4
|
+
import { checkSlotCss } from "./css.js";
|
|
5
|
+
import { checkVariantApplication } from "./elements.js";
|
|
6
|
+
import { checkInteractionNode } from "./interactions.js";
|
|
7
|
+
import { buildValidationCtx } from "./index.js";
|
|
8
|
+
//#region src/modules/mcp/tools/shared/validator/audit.ts
|
|
9
|
+
var harvest = (ctx, into, label, run) => {
|
|
10
|
+
const sub = {
|
|
11
|
+
...ctx,
|
|
12
|
+
errors: [],
|
|
13
|
+
warnings: [],
|
|
14
|
+
warned: /* @__PURE__ */ new Set()
|
|
15
|
+
};
|
|
16
|
+
run(sub);
|
|
17
|
+
for (const e of sub.errors) into.errors.push({
|
|
18
|
+
path: e.path,
|
|
19
|
+
message: `Pre-existing malformation in ${label}: ${e.message}`,
|
|
20
|
+
hint: `${e.hint ? `${e.hint} ` : ""}This issue already exists in the space (NOT caused by your change), but the save is blocked until you fix it too, in this same batch.`,
|
|
21
|
+
...e.validValues ? { validValues: e.validValues } : {}
|
|
22
|
+
});
|
|
23
|
+
for (const w of sub.warnings) {
|
|
24
|
+
const message = `Pre-existing issue in ${label} (not caused by your change, but worth fixing too): ${w}`;
|
|
25
|
+
if (!into.warnings.includes(message)) into.warnings.push(message);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var toNode = (id, node) => ({
|
|
29
|
+
id,
|
|
30
|
+
title: node.title,
|
|
31
|
+
nodeType: node.type,
|
|
32
|
+
action: node.action,
|
|
33
|
+
params: node.params,
|
|
34
|
+
enabled: node.enabled,
|
|
35
|
+
when: node.when,
|
|
36
|
+
elementId: node.elementId ?? void 0,
|
|
37
|
+
preview: node.preview
|
|
38
|
+
});
|
|
39
|
+
var auditElement = (space, sub, el) => {
|
|
40
|
+
const hostRef = elementRefOf(el);
|
|
41
|
+
const base = `element "${hostRef}"`;
|
|
42
|
+
for (const [category, list] of Object.entries(el.definition.bindings ?? {})) for (const binding of list) {
|
|
43
|
+
const path = `${base}.bindings.${category}[to=${binding.to}]`;
|
|
44
|
+
checkBindingTransformers(binding.transformers, `${path}.transformers`, sub);
|
|
45
|
+
checkBindingSourceScope(space, sub, hostRef, binding.source, `${path}.source`);
|
|
46
|
+
checkBindingTarget(hostRef, category, binding.to, path, sub);
|
|
47
|
+
}
|
|
48
|
+
for (const [id, node] of Object.entries(el.definition.interactions ?? {})) checkInteractionNode(toNode(id, node), `${base}.interactions.${id}`, sub, hostRef);
|
|
49
|
+
checkVariantApplication(el.definition.initialState, `${base}.initialState`, sub);
|
|
50
|
+
};
|
|
51
|
+
var auditDefinitionCss = (sub, label, def) => {
|
|
52
|
+
const { ref: _ref, slots, ...slot } = def;
|
|
53
|
+
checkSlotCss(slot, label, sub);
|
|
54
|
+
for (const [name, slotDef] of Object.entries(slots ?? {})) checkSlotCss(slotDef, `${label}.slots.${name}`, sub);
|
|
55
|
+
};
|
|
56
|
+
var collectTouched = (ops) => {
|
|
57
|
+
const touched = {
|
|
58
|
+
elementRefs: /* @__PURE__ */ new Set(),
|
|
59
|
+
definitions: /* @__PURE__ */ new Set(),
|
|
60
|
+
globalStyles: /* @__PURE__ */ new Set(),
|
|
61
|
+
idStyles: /* @__PURE__ */ new Set()
|
|
62
|
+
};
|
|
63
|
+
for (const op of ops) switch (op.type) {
|
|
64
|
+
case "upsertElement":
|
|
65
|
+
touched.elementRefs.add(op.element.ref);
|
|
66
|
+
break;
|
|
67
|
+
case "patchElement":
|
|
68
|
+
case "moveElement":
|
|
69
|
+
case "upsertBinding":
|
|
70
|
+
case "patchBinding":
|
|
71
|
+
case "deleteBinding":
|
|
72
|
+
case "upsertInteractionFlow":
|
|
73
|
+
case "patchInteractionNode":
|
|
74
|
+
case "deleteInteraction":
|
|
75
|
+
touched.elementRefs.add(op.ref);
|
|
76
|
+
break;
|
|
77
|
+
case "upsertDefinition":
|
|
78
|
+
case "patchDefinition":
|
|
79
|
+
touched.definitions.add(op.ref);
|
|
80
|
+
break;
|
|
81
|
+
case "upsertDefinitions":
|
|
82
|
+
for (const ref of Object.keys(op.definitions)) touched.definitions.add(ref);
|
|
83
|
+
break;
|
|
84
|
+
case "upsertGlobalStyle":
|
|
85
|
+
case "patchGlobalStyle":
|
|
86
|
+
touched.globalStyles.add(op.componentType);
|
|
87
|
+
break;
|
|
88
|
+
case "upsertIdStyle":
|
|
89
|
+
case "patchIdStyle": touched.idStyles.add(op.targetId);
|
|
90
|
+
}
|
|
91
|
+
return touched;
|
|
92
|
+
};
|
|
93
|
+
var auditResources = (space, ops) => {
|
|
94
|
+
const ctx = buildValidationCtx(space, ops);
|
|
95
|
+
const result = {
|
|
96
|
+
valid: true,
|
|
97
|
+
errors: [],
|
|
98
|
+
warnings: []
|
|
99
|
+
};
|
|
100
|
+
const touched = collectTouched(ops);
|
|
101
|
+
const seenElements = /* @__PURE__ */ new Set();
|
|
102
|
+
for (const ref of touched.elementRefs) {
|
|
103
|
+
const el = findElementByRef(space.schema, ref);
|
|
104
|
+
if (!el || seenElements.has(el.id)) continue;
|
|
105
|
+
seenElements.add(el.id);
|
|
106
|
+
harvest(ctx, result, `element "${elementRefOf(el)}"`, (sub) => auditElement(space, sub, el));
|
|
107
|
+
}
|
|
108
|
+
for (const ref of touched.definitions) {
|
|
109
|
+
const def = definitionToAI(space.style, ref);
|
|
110
|
+
if (def) harvest(ctx, result, `definition "${ref}"`, (sub) => auditDefinitionCss(sub, `definition "${ref}"`, def));
|
|
111
|
+
}
|
|
112
|
+
for (const componentType of touched.globalStyles) {
|
|
113
|
+
const def = globalStyleToAI(space.style, componentType);
|
|
114
|
+
if (def) harvest(ctx, result, `global style "${componentType}"`, (sub) => auditDefinitionCss(sub, `global style "${componentType}"`, def));
|
|
115
|
+
}
|
|
116
|
+
for (const targetId of touched.idStyles) {
|
|
117
|
+
const def = idStyleToAI(space.style, targetId);
|
|
118
|
+
if (def) harvest(ctx, result, `id style "#${targetId}"`, (sub) => auditDefinitionCss(sub, `id style "#${targetId}"`, def));
|
|
119
|
+
}
|
|
120
|
+
result.valid = result.errors.length === 0;
|
|
121
|
+
return result;
|
|
122
|
+
};
|
|
123
|
+
//#endregion
|
|
124
|
+
export { auditResources };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Operation } from '../../operations';
|
|
2
|
+
export declare const batchDeclaredVars: (ops: Operation[]) => string[];
|
|
3
|
+
export declare const batchDeclaredPages: (ops: Operation[]) => Set<string>;
|
|
4
|
+
export declare const batchDeclaredFolders: (ops: Operation[]) => Set<string>;
|
|
5
|
+
export declare const batchDeclaredVariants: (ops: Operation[]) => Map<string, Set<string>>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { slugRouteParams } from "../../../helpers/space.js";
|
|
2
|
+
//#region src/modules/mcp/tools/shared/validator/batch.ts
|
|
3
|
+
var batchDeclaredVars = (ops) => {
|
|
4
|
+
const names = [];
|
|
5
|
+
for (const op of ops) if (op.type === "upsertVariable") names.push(op.name);
|
|
6
|
+
else if (op.type === "upsertPage" && typeof op.slug === "string") names.push(...slugRouteParams(op.slug));
|
|
7
|
+
return names;
|
|
8
|
+
};
|
|
9
|
+
var batchDeclaredPages = (ops) => {
|
|
10
|
+
const refs = /* @__PURE__ */ new Set();
|
|
11
|
+
for (const op of ops) if (op.type === "upsertPage") refs.add(op.ref);
|
|
12
|
+
return refs;
|
|
13
|
+
};
|
|
14
|
+
var batchDeclaredFolders = (ops) => {
|
|
15
|
+
const refs = /* @__PURE__ */ new Set();
|
|
16
|
+
for (const op of ops) if (op.type === "upsertFolder") refs.add(op.ref);
|
|
17
|
+
return refs;
|
|
18
|
+
};
|
|
19
|
+
var variantNamesOf = (source) => {
|
|
20
|
+
const names = new Set(Object.keys(source.variants ?? {}));
|
|
21
|
+
for (const slot of Object.values(source.slots ?? {})) for (const name of Object.keys(slot.variants ?? {})) names.add(name);
|
|
22
|
+
return names;
|
|
23
|
+
};
|
|
24
|
+
var batchDeclaredVariants = (ops) => {
|
|
25
|
+
const map = /* @__PURE__ */ new Map();
|
|
26
|
+
const record = (ref, names) => {
|
|
27
|
+
if (names.size > 0) map.set(ref, /* @__PURE__ */ new Set([...map.get(ref) ?? [], ...names]));
|
|
28
|
+
};
|
|
29
|
+
for (const op of ops) {
|
|
30
|
+
if (op.type === "upsertDefinitions") {
|
|
31
|
+
for (const [ref, definition] of Object.entries(op.definitions)) record(ref, variantNamesOf(definition));
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (op.type === "upsertDefinition" || op.type === "patchDefinition") record(op.ref, variantNamesOf(op));
|
|
35
|
+
}
|
|
36
|
+
return map;
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { batchDeclaredFolders, batchDeclaredPages, batchDeclaredVariants, batchDeclaredVars };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ValidationCtx } from './context';
|
|
2
|
+
import { Space } from '../../../helpers';
|
|
3
|
+
import { BindingTransformer } from '@plitzi/sdk-shared';
|
|
4
|
+
export declare const checkBindingTarget: (ref: string, category: string | undefined, to: string, path: string, ctx: ValidationCtx) => void;
|
|
5
|
+
export declare const checkBindingSourceScope: (space: Space, ctx: ValidationCtx, elementRef: string, source: string, path: string) => void;
|
|
6
|
+
export declare const checkBindingTransformers: (transformers: BindingTransformer[] | undefined, path: string, ctx: ValidationCtx) => void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { getTransformer, suggestTransformer } from "../../../catalogs/builtinTransformers.js";
|
|
2
|
+
import { descendantIds, elementRefOf, findElementByRef } from "../../../helpers/space.js";
|
|
3
|
+
import { warnOnce } from "./context.js";
|
|
4
|
+
import getSourceName from "@plitzi/sdk-shared/dataSource/helpers/getSourceName";
|
|
5
|
+
//#region src/modules/mcp/tools/shared/validator/bindings.ts
|
|
6
|
+
var providerOfSource = (space, source) => {
|
|
7
|
+
const head = source.split(".")[0];
|
|
8
|
+
const sep = head.indexOf("_");
|
|
9
|
+
if (sep < 0) return;
|
|
10
|
+
const idRef = head.slice(sep + 1);
|
|
11
|
+
const el = findElementByRef(space.schema, idRef);
|
|
12
|
+
if (!el || getSourceName(el.definition.type, el) !== head) return;
|
|
13
|
+
return {
|
|
14
|
+
ref: elementRefOf(el),
|
|
15
|
+
id: el.id
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
var checkBindingTarget = (ref, category, to, path, ctx) => {
|
|
19
|
+
if (category !== "attributes" && category !== "initialState") return;
|
|
20
|
+
const type = ctx.elementType(ref);
|
|
21
|
+
const targets = type ? ctx.typeMeta.get(type)?.bindingTargets?.[category] : void 0;
|
|
22
|
+
if (!targets || targets.size === 0 || targets.has(to)) return;
|
|
23
|
+
warnOnce(ctx, `Binding target "${to}" at ${path} is not among the "${category}" targets the type "${type}" declares (${[...targets].sort().join(", ")}). Verify against plitzi://data-sources; it may still be valid.`);
|
|
24
|
+
};
|
|
25
|
+
var checkBindingSourceScope = (space, ctx, elementRef, source, path) => {
|
|
26
|
+
const provider = providerOfSource(space, source);
|
|
27
|
+
if (!provider) return;
|
|
28
|
+
const bound = findElementByRef(space.schema, elementRef);
|
|
29
|
+
if (!bound) return;
|
|
30
|
+
if (bound.id !== provider.id && descendantIds(space.schema, provider.id).includes(bound.id)) return;
|
|
31
|
+
ctx.errors.push({
|
|
32
|
+
path,
|
|
33
|
+
message: `Binding source "${source}" is provided by element "${provider.ref}", but "${elementRef}" is not inside its subtree`,
|
|
34
|
+
hint: `An element source is scoped to its DESCENDANTS only, so this binding resolves to nothing at runtime (the source is not available outside "${provider.ref}"). Move "${elementRef}" under "${provider.ref}", or bind to a source that is in scope (e.g. a global module source like state/space/navigation).`
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var checkBindingTransformers = (transformers, path, ctx) => {
|
|
38
|
+
transformers?.forEach((transformer, i) => {
|
|
39
|
+
if (transformer.enabled === false) return;
|
|
40
|
+
const base = `${path}[${i}]`;
|
|
41
|
+
const spec = getTransformer(transformer.action);
|
|
42
|
+
if (!spec) {
|
|
43
|
+
const suggestion = suggestTransformer(transformer.action);
|
|
44
|
+
ctx.errors.push({
|
|
45
|
+
path: `${base}.action`,
|
|
46
|
+
message: `Unknown transformer action "${transformer.action}"`,
|
|
47
|
+
hint: `The runtime skips an unknown transformer and passes the value through unchanged.${suggestion ? ` Did you mean "${suggestion}"?` : ""} See the transformers list in plitzi://data-sources.`
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const params = transformer.params;
|
|
52
|
+
const unknown = Object.keys(params).filter((key) => !(key in spec.params));
|
|
53
|
+
if (spec.strictParams && unknown.length > 0) warnOnce(ctx, `Transformer "${transformer.action}" at ${base} got unknown param(s) ${unknown.map((k) => `"${k}"`).join(", ")} — the runtime ignores them. Valid params: ${Object.keys(spec.params).join(", ") || "(none)"}.`);
|
|
54
|
+
for (const [key, param] of Object.entries(spec.params)) {
|
|
55
|
+
if (param.required && !(key in params)) ctx.errors.push({
|
|
56
|
+
path: `${base}.params.${key}`,
|
|
57
|
+
message: `Transformer "${transformer.action}" is missing required param "${key}"`,
|
|
58
|
+
hint: param.description
|
|
59
|
+
});
|
|
60
|
+
if (param.type === "select" && param.options && key in params && !param.options.includes(params[key])) ctx.errors.push({
|
|
61
|
+
path: `${base}.params.${key}`,
|
|
62
|
+
message: `Transformer "${transformer.action}" param "${key}" is "${params[key]}", not one of its options`,
|
|
63
|
+
hint: `Use one of: ${param.options.join(", ")}.`,
|
|
64
|
+
validValues: param.options
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { checkBindingSourceScope, checkBindingTarget, checkBindingTransformers };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ValidationCtx } from './context';
|
|
2
|
+
import { Space } from '../../../helpers';
|
|
3
|
+
import { Operation } from '../../operations';
|
|
4
|
+
/** Connectors this batch creates, so an element wired to one earlier in the same batch is not reported missing. */
|
|
5
|
+
export declare const batchDeclaredConnectors: (ops: Operation[]) => Set<string>;
|
|
6
|
+
export declare const checkConnectorOp: (space: Space, op: Operation, base: string, ctx: ValidationCtx) => void;
|
|
7
|
+
/** A provider element's props. Read as an open bag of unknowns — they are agent-authored, so `connector`,
|
|
8
|
+
* `endpoint` and `filters` are claims to verify, not fields to trust. */
|
|
9
|
+
type ProviderProps = Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* A provider element checked against the connector it names.
|
|
12
|
+
*
|
|
13
|
+
* These are warnings, not errors, and deliberately: the connector store is a different document from the schema,
|
|
14
|
+
* so an element may legitimately be authored before (or after) the connector it points at — and a batch that
|
|
15
|
+
* refuses the page because the connector is not there yet would make the two impossible to write in either order.
|
|
16
|
+
* What the agent must not do is walk away believing a page is wired when it resolves to nothing.
|
|
17
|
+
*/
|
|
18
|
+
export declare const checkProviderElement: (space: Space, ctx: ValidationCtx, ref: string, runtime: string | undefined, props: ProviderProps | undefined, batchConnectors: Set<string>, base: string) => void;
|
|
19
|
+
export {};
|