@plitzi/sdk-server 0.32.24 → 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 +22 -0
- package/README.md +326 -162
- package/dist/adapters/authAdapters.d.ts +21 -0
- package/dist/adapters/authAdapters.js +12 -0
- package/dist/adapters/jsonAdapters.d.ts +15 -0
- package/dist/adapters/jsonAdapters.js +9 -4
- package/dist/core/auth/api.d.ts +148 -0
- package/dist/core/auth/api.js +286 -0
- package/dist/core/auth/authorize.d.ts +96 -0
- package/dist/core/auth/authorize.js +92 -0
- package/dist/core/auth/createAuth.d.ts +165 -0
- package/dist/core/auth/createAuth.js +105 -0
- package/dist/core/auth/credentials.d.ts +29 -0
- package/dist/core/auth/credentials.js +48 -0
- package/dist/core/auth/domains.d.ts +41 -0
- package/dist/core/auth/domains.js +78 -0
- package/dist/core/auth/identity.d.ts +108 -0
- package/dist/core/auth/identity.js +164 -0
- package/dist/core/auth/oauth/client.d.ts +5 -0
- package/dist/core/auth/oauth/client.js +47 -0
- package/dist/core/auth/oauth/index.d.ts +78 -0
- package/dist/core/auth/oauth/index.js +113 -0
- package/dist/core/auth/oauth/providers/github.d.ts +2 -0
- package/dist/core/auth/oauth/providers/github.js +48 -0
- package/dist/core/auth/oauth/providers/google.d.ts +2 -0
- package/dist/core/auth/oauth/providers/google.js +30 -0
- package/dist/core/auth/oauth/state.d.ts +23 -0
- package/dist/core/auth/oauth/state.js +55 -0
- package/dist/core/auth/oauth/types.d.ts +51 -0
- package/dist/core/auth/oauth/types.js +13 -0
- package/dist/core/auth/routes.d.ts +50 -0
- package/dist/core/auth/routes.js +129 -0
- package/dist/core/auth/session.d.ts +128 -0
- package/dist/core/auth/session.js +165 -0
- package/dist/core/auth/spaceTokens.d.ts +137 -0
- package/dist/core/auth/spaceTokens.js +212 -0
- package/dist/core/auth/tokens.d.ts +151 -0
- package/dist/core/auth/tokens.js +221 -0
- package/dist/core/createServer.d.ts +29 -0
- package/dist/core/createServer.js +28 -14
- package/dist/core/handlers/authMiddleware.d.ts +27 -0
- package/dist/core/handlers/authMiddleware.js +38 -0
- package/dist/core/handlers/authRouteHandlers.d.ts +46 -0
- package/dist/core/handlers/authRouteHandlers.js +75 -0
- package/dist/core/handlers/types.d.ts +37 -0
- package/dist/{src/core → core}/http/dispatcher.d.ts +2 -2
- package/dist/core/http/dispatcher.js +8 -6
- package/dist/core/http/navigation.d.ts +11 -0
- package/dist/core/http/navigation.js +16 -0
- package/dist/core/http/securityHeaders.js +6 -4
- package/dist/core/http/stages/authApi.d.ts +17 -0
- package/dist/core/http/stages/authApi.js +66 -0
- package/dist/core/http/stages/authRoutes.js +40 -11
- package/dist/core/http/stages/exchangeRoute.d.ts +15 -0
- package/dist/core/http/stages/exchangeRoute.js +67 -0
- package/dist/core/http/stages/health.d.ts +11 -0
- package/dist/core/http/stages/health.js +25 -3
- package/dist/core/http/stages/middlewares.d.ts +2 -0
- package/dist/core/http/stages/static.d.ts +13 -0
- package/dist/core/http/stages/static.js +21 -6
- package/dist/core/http/types.d.ts +35 -0
- package/dist/{modules/mcp/constants.js → core/previewToken.js} +1 -1
- package/dist/core/sdkAssets.d.ts +16 -0
- package/dist/core/sdkAssets.js +46 -0
- package/dist/core/server/baseServer.js +40 -5
- package/dist/core/server/pageServer.d.ts +7 -0
- package/dist/core/server/pageServer.js +13 -17
- package/dist/core/services/action.d.ts +9 -0
- package/dist/core/services/action.js +21 -0
- package/dist/core/services/registry.d.ts +3 -0
- package/dist/core/services/registry.js +9 -19
- package/dist/{src/core → core}/services/resolve.d.ts +1 -0
- package/dist/core/services/resolve.js +6 -4
- package/dist/core/services/rsc.js +3 -2
- package/dist/core/staticFiles.js +1 -1
- package/dist/{src/core → core}/transports.d.ts +3 -0
- package/dist/core/transports.js +7 -6
- package/dist/handlers.d.ts +58 -0
- package/dist/handlers.js +3 -0
- package/dist/{src/helpers → helpers}/buildResponseHelpers.d.ts +2 -1
- package/dist/helpers/buildResponseHelpers.js +13 -4
- package/dist/helpers/buildServerInfo.d.ts +3 -0
- package/dist/helpers/buildServerInfo.js +25 -3
- package/dist/{src/helpers → helpers}/cache/keys.d.ts +5 -1
- package/dist/helpers/cache/keys.js +1 -1
- package/dist/helpers/compress.d.ts +18 -0
- package/dist/helpers/compress.js +47 -11
- package/dist/helpers/offlineDataLoader.d.ts +11 -0
- package/dist/helpers/offlineDataLoader.js +15 -0
- package/dist/helpers/resolveDebugMode.d.ts +10 -0
- package/dist/helpers/resolveDebugMode.js +13 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +9 -20
- package/dist/kernel.d.ts +41 -0
- package/dist/kernel.js +22 -0
- package/dist/middlewares/spaceDeployment.d.ts +2 -0
- package/dist/middlewares/spaceDeployment.js +2 -1
- package/dist/modules/actions/handler.d.ts +11 -0
- package/dist/modules/actions/handler.js +77 -0
- package/dist/modules/connectors/engine.d.ts +42 -0
- package/dist/modules/connectors/engine.js +221 -0
- package/dist/modules/connectors/getByPath.d.ts +8 -0
- package/dist/modules/connectors/getByPath.js +21 -0
- package/dist/modules/connectors/index.d.ts +7 -0
- package/dist/modules/connectors/projection.d.ts +18 -0
- package/dist/modules/connectors/projection.js +108 -0
- package/dist/modules/connectors/resolver.d.ts +18 -0
- package/dist/modules/connectors/resolver.js +68 -0
- package/dist/modules/connectors/types.d.ts +19 -0
- package/dist/{src/modules → modules}/rsc/handler.d.ts +2 -2
- package/dist/modules/rsc/handler.js +54 -2
- package/dist/modules/rsc/resolveRscData.d.ts +35 -0
- package/dist/modules/rsc/resolveRscData.js +74 -0
- package/dist/{src/modules → modules}/ssr/Component.d.ts +4 -1
- package/dist/modules/ssr/Component.js +10 -3
- package/dist/modules/ssr/buildBody.d.ts +9 -0
- package/dist/modules/ssr/handler.d.ts +4 -0
- package/dist/modules/ssr/handler.js +18 -1
- package/dist/{src/modules → modules}/ssr/loadPluginComponents.d.ts +5 -2
- package/dist/modules/ssr/loadPluginComponents.js +20 -2
- package/dist/{src/modules → modules}/ssr/prepareRender.d.ts +2 -2
- package/dist/modules/ssr/prepareRender.js +24 -7
- package/dist/modules/ssr/preview.d.ts +10 -0
- package/dist/modules/ssr/preview.js +5 -78
- package/dist/modules/ssr/registerExternalPlugins.js +1 -1
- package/dist/modules/ssr/streamBody.d.ts +5 -0
- package/dist/modules/ssr/streamBody.js +1 -1
- package/dist/modules/ssr/template.d.ts +2 -0
- package/dist/modules/ssr/template.js +1 -1
- package/dist/plugins/compile.js +1 -1
- package/dist/plugins/manager.js +12 -8
- package/dist/ssr.d.ts +15 -0
- package/dist/ssr.js +4 -0
- package/package.json +29 -25
- package/dist/.gitkeep +0 -0
- package/dist/core/server/mcpServer.js +0 -29
- package/dist/core/services/mcp.js +0 -27
- package/dist/core/services/oauth.js +0 -116
- package/dist/core/services/preview.js +0 -37
- package/dist/core/services/proxy.js +0 -12
- package/dist/mcp.d.ts +0 -2
- package/dist/mcp.js +0 -7
- package/dist/modules/ai/AIEngine.js +0 -120
- package/dist/modules/ai/toolkit.js +0 -59
- package/dist/modules/mcp/apps/example/view/index.tsx +0 -70
- package/dist/modules/mcp/apps/index.js +0 -16
- package/dist/modules/mcp/apps/render/index.js +0 -17
- package/dist/modules/mcp/apps/render/styles.js +0 -54
- package/dist/modules/mcp/apps/render/view/heldBatch.ts +0 -107
- package/dist/modules/mcp/apps/render/view/index.tsx +0 -314
- package/dist/modules/mcp/apps/render/view/streamProgress.ts +0 -137
- package/dist/modules/mcp/apps/shared/assets.js +0 -10
- package/dist/modules/mcp/apps/shared/bundle.js +0 -23
- package/dist/modules/mcp/apps/shared/page.js +0 -34
- package/dist/modules/mcp/apps/shared/registerApp.js +0 -43
- package/dist/modules/mcp/apps/shared/resolve.js +0 -5
- package/dist/modules/mcp/apps/shared/shell.ejs +0 -59
- package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +0 -23
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -204
- package/dist/modules/mcp/catalogs/builtinComponents.js +0 -170
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
- package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
- package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
- package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
- package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
- package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
- package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -98
- package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -144
- package/dist/modules/mcp/catalogs/observed.js +0 -90
- package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
- package/dist/modules/mcp/catalogs/registry.js +0 -89
- package/dist/modules/mcp/handler.js +0 -83
- package/dist/modules/mcp/helpers/agentPrompt.js +0 -104
- package/dist/modules/mcp/helpers/computeVersion.js +0 -16
- package/dist/modules/mcp/helpers/guide.js +0 -467
- package/dist/modules/mcp/helpers/interactions.js +0 -123
- package/dist/modules/mcp/helpers/log.js +0 -64
- package/dist/modules/mcp/helpers/opResult.js +0 -18
- package/dist/modules/mcp/helpers/space.js +0 -300
- package/dist/modules/mcp/helpers/uris.js +0 -44
- package/dist/modules/mcp/previewClient.js +0 -31
- package/dist/modules/mcp/proxy/config.js +0 -46
- package/dist/modules/mcp/proxy/fetch.js +0 -91
- package/dist/modules/mcp/proxy/grant.js +0 -65
- package/dist/modules/mcp/proxy/guard.js +0 -38
- package/dist/modules/mcp/proxy/handler.js +0 -68
- package/dist/modules/mcp/proxy/rewrite.js +0 -72
- package/dist/modules/mcp/proxy/sign.js +0 -15
- package/dist/modules/mcp/proxy/types.js +0 -9
- package/dist/modules/mcp/resources/canonical.js +0 -30
- package/dist/modules/mcp/resources/core.js +0 -18
- package/dist/modules/mcp/resources/envelope.js +0 -14
- package/dist/modules/mcp/resources/primer.js +0 -31
- package/dist/modules/mcp/resources/register.js +0 -190
- package/dist/modules/mcp/resources/renderGuide.js +0 -451
- package/dist/modules/mcp/resources/router.js +0 -37
- package/dist/modules/mcp/resources/schema.js +0 -43
- package/dist/modules/mcp/resources/style.js +0 -34
- package/dist/modules/mcp/screenshotClient.js +0 -47
- package/dist/modules/mcp/server.js +0 -113
- package/dist/modules/mcp/tools/apply/dispatch.js +0 -105
- package/dist/modules/mcp/tools/apply/index.js +0 -150
- package/dist/modules/mcp/tools/apply/writeResult.js +0 -37
- package/dist/modules/mcp/tools/index.js +0 -24
- package/dist/modules/mcp/tools/operations/index.js +0 -45
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +0 -32
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +0 -36
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +0 -47
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +0 -29
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +0 -41
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +0 -58
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +0 -148
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +0 -65
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +0 -30
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +0 -49
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +0 -52
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +0 -47
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +0 -44
- package/dist/modules/mcp/tools/operations/schema/operations.js +0 -41
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +0 -25
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +0 -75
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +0 -45
- package/dist/modules/mcp/tools/operations/schema/shared.js +0 -122
- package/dist/modules/mcp/tools/operations/schema/translator.js +0 -215
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +0 -18
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +0 -42
- package/dist/modules/mcp/tools/operations/schema/write.js +0 -109
- package/dist/modules/mcp/tools/operations/schemaIds.js +0 -54
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +0 -21
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +0 -28
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +0 -24
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +0 -40
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +0 -21
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +0 -28
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +0 -24
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +0 -21
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +0 -28
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +0 -24
- package/dist/modules/mcp/tools/operations/style/operations.js +0 -29
- package/dist/modules/mcp/tools/operations/style/shared.js +0 -59
- package/dist/modules/mcp/tools/operations/style/translator.js +0 -101
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +0 -21
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +0 -22
- package/dist/modules/mcp/tools/operations/style/write.js +0 -108
- package/dist/modules/mcp/tools/preview.js +0 -37
- package/dist/modules/mcp/tools/read.js +0 -51
- package/dist/modules/mcp/tools/render.js +0 -184
- package/dist/modules/mcp/tools/screenshot.js +0 -83
- package/dist/modules/mcp/tools/search.js +0 -115
- package/dist/modules/mcp/tools/shared/expandOperations.js +0 -44
- package/dist/modules/mcp/tools/shared/tool.js +0 -33
- package/dist/modules/mcp/tools/shared/validator/audit.js +0 -124
- package/dist/modules/mcp/tools/shared/validator/batch.js +0 -39
- package/dist/modules/mcp/tools/shared/validator/bindings.js +0 -70
- package/dist/modules/mcp/tools/shared/validator/context.js +0 -35
- package/dist/modules/mcp/tools/shared/validator/css.js +0 -39
- package/dist/modules/mcp/tools/shared/validator/elements.js +0 -68
- package/dist/modules/mcp/tools/shared/validator/index.js +0 -246
- package/dist/modules/mcp/tools/shared/validator/interactions.js +0 -103
- package/dist/modules/mcp/tools/shared/validator/refs.js +0 -28
- package/dist/modules/mcp/tools/validate.js +0 -47
- package/dist/modules/oauth/authorize.js +0 -177
- package/dist/modules/oauth/challenge.js +0 -33
- package/dist/modules/oauth/consentPage.js +0 -118
- package/dist/modules/oauth/metadata.js +0 -69
- package/dist/modules/oauth/params.js +0 -5
- package/dist/modules/oauth/pkce.js +0 -15
- package/dist/modules/oauth/records.js +0 -46
- package/dist/modules/oauth/register.js +0 -55
- package/dist/modules/oauth/respond.js +0 -44
- package/dist/modules/oauth/token.js +0 -100
- package/dist/public/.gitkeep +0 -0
- package/dist/src/adapters/jsonAdapters.d.ts +0 -7
- package/dist/src/core/createServer.d.ts +0 -14
- package/dist/src/core/http/stages/health.d.ts +0 -2
- package/dist/src/core/http/stages/middlewares.d.ts +0 -2
- package/dist/src/core/http/stages/static.d.ts +0 -5
- package/dist/src/core/http/types.d.ts +0 -22
- package/dist/src/core/server/mcpServer.d.ts +0 -2
- package/dist/src/core/server/pageServer.d.ts +0 -10
- package/dist/src/core/services/mcp.d.ts +0 -3
- package/dist/src/core/services/oauth.d.ts +0 -18
- package/dist/src/core/services/preview.d.ts +0 -2
- package/dist/src/core/services/proxy.d.ts +0 -2
- package/dist/src/core/services/registry.d.ts +0 -4
- package/dist/src/helpers/buildServerInfo.d.ts +0 -2
- package/dist/src/helpers/compress.d.ts +0 -3
- package/dist/src/index.d.ts +0 -15
- package/dist/src/mcp.d.ts +0 -14
- package/dist/src/middlewares/spaceDeployment.d.ts +0 -2
- package/dist/src/modules/ai/AIEngine.d.ts +0 -20
- package/dist/src/modules/ai/index.d.ts +0 -4
- package/dist/src/modules/ai/toolkit.d.ts +0 -17
- package/dist/src/modules/mcp/apps/example/index.d.ts +0 -8
- package/dist/src/modules/mcp/apps/index.d.ts +0 -11
- package/dist/src/modules/mcp/apps/render/index.d.ts +0 -4
- package/dist/src/modules/mcp/apps/render/styles.d.ts +0 -10
- package/dist/src/modules/mcp/apps/shared/assets.d.ts +0 -10
- package/dist/src/modules/mcp/apps/shared/bundle.d.ts +0 -4
- package/dist/src/modules/mcp/apps/shared/index.d.ts +0 -3
- package/dist/src/modules/mcp/apps/shared/page.d.ts +0 -2
- package/dist/src/modules/mcp/apps/shared/registerApp.d.ts +0 -5
- package/dist/src/modules/mcp/apps/shared/resolve.d.ts +0 -1
- package/dist/src/modules/mcp/apps/shared/zodEnglishOnly.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -23
- package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -20
- package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
- package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +0 -18
- package/dist/src/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
- package/dist/src/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -19
- package/dist/src/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
- package/dist/src/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
- package/dist/src/modules/mcp/catalogs/index.d.ts +0 -9
- package/dist/src/modules/mcp/catalogs/observed.d.ts +0 -48
- package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +0 -42
- package/dist/src/modules/mcp/catalogs/registry.d.ts +0 -35
- package/dist/src/modules/mcp/e2e/index.d.ts +0 -6
- package/dist/src/modules/mcp/e2e/mcpEndpoint.d.ts +0 -27
- package/dist/src/modules/mcp/e2e/postMessageChannel.d.ts +0 -22
- package/dist/src/modules/mcp/e2e/renderingHost.d.ts +0 -34
- package/dist/src/modules/mcp/handler.d.ts +0 -22
- package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +0 -4
- package/dist/src/modules/mcp/helpers/computeVersion.d.ts +0 -1
- package/dist/src/modules/mcp/helpers/guide.d.ts +0 -4
- package/dist/src/modules/mcp/helpers/index.d.ts +0 -8
- package/dist/src/modules/mcp/helpers/interactions.d.ts +0 -30
- package/dist/src/modules/mcp/helpers/log.d.ts +0 -8
- package/dist/src/modules/mcp/helpers/opResult.d.ts +0 -13
- package/dist/src/modules/mcp/helpers/space.d.ts +0 -115
- package/dist/src/modules/mcp/helpers/uris.d.ts +0 -28
- package/dist/src/modules/mcp/index.d.ts +0 -13
- package/dist/src/modules/mcp/previewClient.d.ts +0 -13
- package/dist/src/modules/mcp/proxy/config.d.ts +0 -17
- package/dist/src/modules/mcp/proxy/fetch.d.ts +0 -18
- package/dist/src/modules/mcp/proxy/grant.d.ts +0 -23
- package/dist/src/modules/mcp/proxy/guard.d.ts +0 -6
- package/dist/src/modules/mcp/proxy/handler.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/index.d.ts +0 -7
- package/dist/src/modules/mcp/proxy/rewrite.d.ts +0 -13
- package/dist/src/modules/mcp/proxy/sign.d.ts +0 -6
- package/dist/src/modules/mcp/proxy/types.d.ts +0 -45
- package/dist/src/modules/mcp/resources/canonical.d.ts +0 -6
- package/dist/src/modules/mcp/resources/core.d.ts +0 -5
- package/dist/src/modules/mcp/resources/envelope.d.ts +0 -10
- package/dist/src/modules/mcp/resources/index.d.ts +0 -8
- package/dist/src/modules/mcp/resources/primer.d.ts +0 -7
- package/dist/src/modules/mcp/resources/register.d.ts +0 -10
- package/dist/src/modules/mcp/resources/renderGuide.d.ts +0 -10
- package/dist/src/modules/mcp/resources/router.d.ts +0 -10
- package/dist/src/modules/mcp/resources/schema.d.ts +0 -5
- package/dist/src/modules/mcp/resources/style.d.ts +0 -5
- package/dist/src/modules/mcp/screenshotClient.d.ts +0 -13
- package/dist/src/modules/mcp/server.d.ts +0 -31
- package/dist/src/modules/mcp/tests/helpers.d.ts +0 -13
- package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +0 -6
- package/dist/src/modules/mcp/tools/apply/index.d.ts +0 -470
- package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +0 -8
- package/dist/src/modules/mcp/tools/index.d.ts +0 -18
- package/dist/src/modules/mcp/tools/operations/index.d.ts +0 -928
- package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +0 -17
- package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +0 -25
- package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +0 -27
- package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +0 -10
- package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +0 -22
- package/dist/src/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +0 -55
- package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +0 -21
- package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +0 -18
- package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +0 -27
- package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +0 -229
- package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +0 -14
- package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +0 -34
- package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +0 -92
- package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +0 -42
- package/dist/src/modules/mcp/tools/operations/schemaIds.d.ts +0 -6
- package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +0 -41
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/index.d.ts +0 -15
- package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +0 -264
- package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +0 -116
- package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +0 -15
- package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +0 -20
- package/dist/src/modules/mcp/tools/operations/style/write.d.ts +0 -12
- package/dist/src/modules/mcp/tools/preview.d.ts +0 -465
- package/dist/src/modules/mcp/tools/read.d.ts +0 -9
- package/dist/src/modules/mcp/tools/render.d.ts +0 -499
- package/dist/src/modules/mcp/tools/render.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/screenshot.d.ts +0 -470
- package/dist/src/modules/mcp/tools/search.d.ts +0 -15
- package/dist/src/modules/mcp/tools/shared/expandOperations.d.ts +0 -13
- package/dist/src/modules/mcp/tools/shared/tool.d.ts +0 -72
- package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +0 -4
- package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +0 -5
- package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +0 -6
- package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +0 -38
- package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +0 -4
- package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +0 -7
- package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +0 -3
- package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +0 -4
- package/dist/src/modules/mcp/tools/validate.d.ts +0 -467
- package/dist/src/modules/mcp/types/aiSchema.d.ts +0 -218
- package/dist/src/modules/mcp/types/appTypes.d.ts +0 -26
- package/dist/src/modules/mcp/types/index.d.ts +0 -5
- package/dist/src/modules/mcp/types/previewTypes.d.ts +0 -25
- package/dist/src/modules/mcp/types/screenshotTypes.d.ts +0 -29
- package/dist/src/modules/mcp/types/toolTypes.d.ts +0 -138
- package/dist/src/modules/oauth/authorize.d.ts +0 -7
- package/dist/src/modules/oauth/challenge.d.ts +0 -11
- package/dist/src/modules/oauth/consentPage.d.ts +0 -7
- package/dist/src/modules/oauth/metadata.d.ts +0 -40
- package/dist/src/modules/oauth/params.d.ts +0 -5
- package/dist/src/modules/oauth/pkce.d.ts +0 -6
- package/dist/src/modules/oauth/records.d.ts +0 -71
- package/dist/src/modules/oauth/register.d.ts +0 -5
- package/dist/src/modules/oauth/respond.d.ts +0 -13
- package/dist/src/modules/oauth/token.d.ts +0 -5
- package/dist/src/modules/ssr/buildBody.d.ts +0 -9
- package/dist/src/modules/ssr/handler.d.ts +0 -4
- package/dist/src/modules/ssr/preview.d.ts +0 -16
- package/dist/src/modules/ssr/streamBody.d.ts +0 -5
- package/dist/src/modules/ssr/template.d.ts +0 -6
- package/dist/src/standalone/alias-loader.d.mts +0 -2
- package/dist/src/standalone/plugins/ClientInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/ServerInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/SharedInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/styles.d.ts +0 -5
- package/dist/src/standalone/register-alias.d.mts +0 -1
- package/dist/src/standalone/server.d.ts +0 -1
- package/dist/src/standalone/stubs/react-syntax-highlighter.d.mts +0 -31
- package/skills/plitzi-render/SKILL.md +0 -174
- /package/dist/{src/core/http/dispatcher.test.d.ts → core/auth/api.test.d.ts} +0 -0
- /package/dist/{src/core/server/mcpServer.test.d.ts → core/auth/authorize.test.d.ts} +0 -0
- /package/dist/{src/modules/ai/toolkit.test.d.ts → core/auth/createAuth.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/apps/apps.test.d.ts → core/auth/domains.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/apps/render/styles.test.d.ts → core/auth/identity.test.d.ts} +0 -0
- /package/dist/{src/modules → core/auth}/oauth/oauth.test.d.ts +0 -0
- /package/dist/{src/modules/mcp/catalogs/builtinTransformers.test.d.ts → core/auth/routes.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts → core/auth/session.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/connector.test.d.ts → core/auth/spaceTokens.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/host.test.d.ts → core/auth/tokens.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/oauthConnector.test.d.ts → core/createServer.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/helpers/log.test.d.ts → core/handlers/handlers.test.d.ts} +0 -0
- /package/dist/{src/core → core}/health.d.ts +0 -0
- /package/dist/{src/modules/mcp/mcp.bench.d.ts → core/http/dispatcher.test.d.ts} +0 -0
- /package/dist/{src/core → core}/http/securityHeaders.d.ts +0 -0
- /package/dist/{src/core → core}/http/stages/authRoutes.d.ts +0 -0
- /package/dist/{src/core → core}/http/stages/pluginAssets.d.ts +0 -0
- /package/dist/{src/core → core}/mimeTypes.d.ts +0 -0
- /package/dist/{src/modules/mcp/constants.d.ts → core/previewToken.d.ts} +0 -0
- /package/dist/{src/core → core}/requestParser.d.ts +0 -0
- /package/dist/{src/core → core}/server/baseServer.d.ts +0 -0
- /package/dist/{src/modules/mcp/proxy/endpoint.test.d.ts → core/server/baseServer.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/proxy/proxy.test.d.ts → core/services/resolve.test.d.ts} +0 -0
- /package/dist/{src/core → core}/services/rsc.d.ts +0 -0
- /package/dist/{src/core → core}/services/ssr.d.ts +0 -0
- /package/dist/{src/core → core}/staticFiles.d.ts +0 -0
- /package/dist/{src/modules/mcp/proxy/wiring.test.d.ts → helpers/buildResponseHelpers.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/cache/TtlCache.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/cacheManager.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/defaults.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/index.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/apply.test.d.ts → helpers/cache/keys.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/cache/serverCaches.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/bindings.test.d.ts → helpers/compress.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/escapeJson.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/metrics.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/normalizePlugins.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/css.test.d.ts → helpers/offlineDataLoader.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/readCookie.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/interactions.test.d.ts → helpers/resolveDebugMode.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/runMiddlewares.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/serverLog.d.ts +0 -0
- /package/dist/{src/middlewares → middlewares}/auth.d.ts +0 -0
- /package/dist/{src/middlewares → middlewares}/basicAuth.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/pages.test.d.ts → middlewares/spaceDeployment.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/reads.test.d.ts → modules/actions/handler.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/schemaIds.test.d.ts → modules/connectors/engine.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/search.test.d.ts → modules/connectors/projection.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/skill.test.d.ts → modules/connectors/resolver.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/styles.test.d.ts → modules/rsc/resolveRscData.test.d.ts} +0 -0
- /package/dist/{src/modules → modules}/ssr/applySSRResult.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/tools.test.d.ts → modules/ssr/loadPluginComponents.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/validation.test.d.ts → modules/ssr/metering.test.d.ts} +0 -0
- /package/dist/{src/modules → modules}/ssr/registerExternalPlugins.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/compile.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/copy.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/detect.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/manager.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/validate.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/validate.test.d.ts +0 -0
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { iconFontCss } from "../apps/render/styles.js";
|
|
2
|
-
import { RENDER_APP_URI } from "../apps/render/index.js";
|
|
3
|
-
import { emptySpace } from "../helpers/space.js";
|
|
4
|
-
import { proxifyResources } from "../proxy/rewrite.js";
|
|
5
|
-
import { operations } from "./operations/index.js";
|
|
6
|
-
import { applyOperations } from "./apply/dispatch.js";
|
|
7
|
-
import { expandOperations } from "./shared/expandOperations.js";
|
|
8
|
-
import { defineTool } from "./shared/tool.js";
|
|
9
|
-
import { validateOperations } from "./shared/validator/index.js";
|
|
10
|
-
import { auditResources } from "./shared/validator/audit.js";
|
|
11
|
-
import { randomUUID } from "node:crypto";
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
import { validateSchema } from "@plitzi/sdk-schema/helpers/schemaValidator";
|
|
14
|
-
import { generateCache } from "@plitzi/sdk-style/StyleHelper";
|
|
15
|
-
//#region src/modules/mcp/tools/render.ts
|
|
16
|
-
var HOST_PAGE_REF = "render";
|
|
17
|
-
var seedSpace = () => {
|
|
18
|
-
const space = emptySpace();
|
|
19
|
-
space.schema.definition.name = "Widget";
|
|
20
|
-
space.schema.flat[HOST_PAGE_REF] = {
|
|
21
|
-
id: HOST_PAGE_REF,
|
|
22
|
-
idRef: HOST_PAGE_REF,
|
|
23
|
-
attributes: {
|
|
24
|
-
slug: "",
|
|
25
|
-
name: "Render",
|
|
26
|
-
default: true
|
|
27
|
-
},
|
|
28
|
-
definition: {
|
|
29
|
-
rootId: HOST_PAGE_REF,
|
|
30
|
-
label: "Page",
|
|
31
|
-
type: "page",
|
|
32
|
-
items: [],
|
|
33
|
-
styleSelectors: { base: "" }
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
space.schema.pages = [HOST_PAGE_REF];
|
|
37
|
-
return space;
|
|
38
|
-
};
|
|
39
|
-
var noWarnings = (warnings) => warnings.length > 0 ? warnings : void 0;
|
|
40
|
-
var renderShape = {
|
|
41
|
-
operations,
|
|
42
|
-
patch: z.boolean().optional().describe("Set true to CHANGE a widget you already rendered instead of rebuilding it: send its `renderId` and ONLY the operations that differ (patchDefinition, patchElement, deleteElement, a new repeatElement…). The widget merges them into the batch it was built from and reports back what it applied. The refs it already has (card-1, blk-2-3) are the ones to address. If that widget cannot be recovered — a surface that renders none, a host that keeps no storage — the answer says so and you re-send the whole batch."),
|
|
43
|
-
renderId: z.string().optional().describe("Handle returned by a previous render. Required with patch:true; it names the widget being changed.")
|
|
44
|
-
};
|
|
45
|
-
var render = (input, options = {}) => {
|
|
46
|
-
const space = seedSpace();
|
|
47
|
-
const expansion = expandOperations(input.operations);
|
|
48
|
-
if (expansion.errors.length > 0) return {
|
|
49
|
-
rendered: false,
|
|
50
|
-
errors: expansion.errors
|
|
51
|
-
};
|
|
52
|
-
const ops = expansion.operations;
|
|
53
|
-
const validation = validateOperations(space, ops, "widget");
|
|
54
|
-
if (!validation.valid) return {
|
|
55
|
-
rendered: false,
|
|
56
|
-
errors: validation.errors,
|
|
57
|
-
warnings: noWarnings(validation.warnings)
|
|
58
|
-
};
|
|
59
|
-
const outcome = applyOperations(space, "main", ops);
|
|
60
|
-
if (outcome.errors.length > 0) return {
|
|
61
|
-
rendered: false,
|
|
62
|
-
errors: outcome.errors,
|
|
63
|
-
warnings: noWarnings(validation.warnings)
|
|
64
|
-
};
|
|
65
|
-
const integrity = validateSchema(space.schema);
|
|
66
|
-
if (!integrity.valid) return {
|
|
67
|
-
rendered: false,
|
|
68
|
-
errors: integrity.errors.map((error) => ({
|
|
69
|
-
path: error.elementId ? `schema.${error.elementId}` : "schema",
|
|
70
|
-
message: error.message,
|
|
71
|
-
hint: "The authored widget is structurally inconsistent (broken parent/child link or a cycle)."
|
|
72
|
-
})),
|
|
73
|
-
warnings: noWarnings(validation.warnings)
|
|
74
|
-
};
|
|
75
|
-
const audit = auditResources(space, ops);
|
|
76
|
-
const warnings = [...validation.warnings, ...audit.warnings];
|
|
77
|
-
if (audit.errors.length > 0) return {
|
|
78
|
-
rendered: false,
|
|
79
|
-
errors: audit.errors,
|
|
80
|
-
warnings: noWarnings(warnings)
|
|
81
|
-
};
|
|
82
|
-
if (options.proxy) warnings.push(...proxifyResources(space, options.proxy));
|
|
83
|
-
space.style.cache = generateCache(space.style);
|
|
84
|
-
return {
|
|
85
|
-
rendered: true,
|
|
86
|
-
operations: ops,
|
|
87
|
-
rootRef: HOST_PAGE_REF,
|
|
88
|
-
elementCount: Object.keys(space.schema.flat).length - 1,
|
|
89
|
-
offlineData: {
|
|
90
|
-
schema: space.schema,
|
|
91
|
-
style: space.style
|
|
92
|
-
},
|
|
93
|
-
warnings: noWarnings(warnings)
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
/** A patch is not rendered here — it CANNOT be: this server keeps nothing between calls (no session, no store,
|
|
97
|
-
* any replica answers any request), so the previous widget only exists on the host side. The delta therefore
|
|
98
|
-
* travels as a courier result: the model pays for the delta alone, the view recovers the batch that widget was
|
|
99
|
-
* built from (by renderId — see apps/render/heldBatch.ts), merges, and re-calls this same tool with the whole
|
|
100
|
-
* thing over the host bridge, never through the model's context, then reports back with ui/update-model-context.
|
|
101
|
-
*
|
|
102
|
-
* The renderId is the explicit handle the MCP RC asks for in place of implicit session state: the model carries
|
|
103
|
-
* it, so a patch names the widget it means and any replica can serve it.
|
|
104
|
-
*
|
|
105
|
-
* Validation is not skipped, only deferred: the re-call carries the full batch, so refs, integrity and the audit
|
|
106
|
-
* all run exactly as they do on a first render, and their errors reach the model through that report. */
|
|
107
|
-
var toPatchResult = (ops, renderId) => {
|
|
108
|
-
if (ops.length === 0) return { content: [{
|
|
109
|
-
type: "text",
|
|
110
|
-
text: JSON.stringify({
|
|
111
|
-
patch: false,
|
|
112
|
-
error: "A patch carries no operations",
|
|
113
|
-
hint: "Send the operations that differ from the widget on screen, or drop `patch` to render a new one."
|
|
114
|
-
})
|
|
115
|
-
}] };
|
|
116
|
-
if (renderId === void 0) return { content: [{
|
|
117
|
-
type: "text",
|
|
118
|
-
text: JSON.stringify({
|
|
119
|
-
patch: false,
|
|
120
|
-
error: "A patch needs the renderId of the widget it changes",
|
|
121
|
-
hint: "Pass the renderId the render answered with, or drop `patch` to render a new widget."
|
|
122
|
-
})
|
|
123
|
-
}] };
|
|
124
|
-
return {
|
|
125
|
-
content: [{
|
|
126
|
-
type: "text",
|
|
127
|
-
text: JSON.stringify({
|
|
128
|
-
patch: true,
|
|
129
|
-
renderId,
|
|
130
|
-
operations: ops.length,
|
|
131
|
-
note: "Handed to the widget; it will report what it applied. If nothing reports back, it could not be recovered — re-send the full batch without patch."
|
|
132
|
-
})
|
|
133
|
-
}],
|
|
134
|
-
structuredContent: {
|
|
135
|
-
patch: true,
|
|
136
|
-
renderId,
|
|
137
|
-
operations: ops
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
var newRenderId = () => `r${randomUUID().slice(0, 8)}`;
|
|
142
|
-
var ICON_TYPE = "fontAwesome";
|
|
143
|
-
var drawsIcons = (offlineData) => Object.values(offlineData.schema.flat).some((element) => element.definition.type === ICON_TYPE);
|
|
144
|
-
var toRenderResult = (res, renderId) => {
|
|
145
|
-
if (!res.rendered) return { content: [{
|
|
146
|
-
type: "text",
|
|
147
|
-
text: JSON.stringify({
|
|
148
|
-
rendered: false,
|
|
149
|
-
errors: res.errors,
|
|
150
|
-
warnings: res.warnings
|
|
151
|
-
})
|
|
152
|
-
}] };
|
|
153
|
-
const summary = {
|
|
154
|
-
rendered: true,
|
|
155
|
-
renderId,
|
|
156
|
-
rootRef: res.rootRef,
|
|
157
|
-
elementCount: res.elementCount,
|
|
158
|
-
warnings: res.warnings
|
|
159
|
-
};
|
|
160
|
-
return {
|
|
161
|
-
content: [{
|
|
162
|
-
type: "text",
|
|
163
|
-
text: JSON.stringify(summary)
|
|
164
|
-
}],
|
|
165
|
-
structuredContent: {
|
|
166
|
-
...summary,
|
|
167
|
-
offlineData: res.offlineData,
|
|
168
|
-
operations: res.operations,
|
|
169
|
-
...drawsIcons(res.offlineData) ? { iconCss: iconFontCss() } : {}
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
var renderTool = defineTool({
|
|
174
|
-
name: "plitzi_render",
|
|
175
|
-
title: "Render widget",
|
|
176
|
-
description: "Show the user a real, rendered UI widget instead of describing one — cards, hero sections, pricing tables, forms, menus, checklists, profiles, galleries. It runs the Plitzi SDK fully offline: no backend, account, or setup. Reach for it whenever a visual layout beats prose: the user asks you to design/build/show something, OR your answer is naturally visual (a recipe → a card, a comparison → a table, steps → a checklist). Prefer showing over telling.\n\nAuthor the widget as an ordered list of `operations` that build an element tree under the pre-seeded root page \"render\". Three rules:\n1. STRUCTURE — one upsertElement builds the whole tree: set pageRef:\"render\" and give element a nested `children` array. Each element is { ref (unique), type, subType?, props?, style?, children? }; children render in order. (To attach to something you already made, use a top-level parentRef:\"<existing ref>\" instead.)\n1b. REPEATS — the moment two siblings share a shape and differ only in data (list, steps, cards, table, timeline), do NOT copy-paste them: use repeatElement { pageRef, ref (wrapper), style, template, items }. The template is written once with {{item.field}} placeholders and rendered per row; refs come out numbered (\"step-1\", \"step-2\"…). A list INSIDE each row (days with their own steps) is the same op: give the wrapping node repeat:{ items:\"{{item.<list>}}\", template:… } and put the sub-rows in the row data.\n2. STYLE — declare ALL the classes in ONE upsertDefinitions { definitions: { \"<class>\": { desktop:{ …CSS in kebab-case… } }, … } }, then attach via the element style:{ base:[\"<class ref>\"] }. Lay containers out with flex/grid. Keep the call small: one class per look, not per property.\n2a. GRAPHICS — a logo, a sparkline, a badge, a decorative shape: draw it as an INLINE <svg> in a blockHtml element (props.content), keeping a viewBox with width/height \"100%\" so its class sizes it, and fill/stroke \"currentColor\" so it follows the host theme. Budget it: a handful of paths, drawn once and reused, never a data: URI and never a full illustration — a photo-real scene costs more than the whole widget, so use an https image, a flat colour or a gradient for that. Markup only: scripts and on* handlers are rejected.\n2b. LAYOUT — it renders in a side panel, so width is free and HEIGHT is scarce. Plain containers stack children vertically, which is the tall half-empty default to avoid: put peers (metrics, plans, options, image + text) in a wrapping row — display:flex, flex-direction:row, flex-wrap:wrap, children flex-grow:\"1\" + flex-basis:\"0%\" + min-width — or a grid with grid-template-columns:\"repeat(auto-fit, minmax(160px, 1fr))\". Keep padding 12-16px and gap 8-12px, and let the outer container fill the panel. Stack only what reads in order (heading over paragraph, forms, steps, prose). Nothing carries a minimum size, so an element with no content and no size takes none — give a spacer or a rail its own height/width — while heading/paragraph do keep the margins the browser gives them (zero them, space with the parent gap).\n2c. THEME — it is embedded in the host UI, which MAY BE DARK, so never hardcode a light palette. Take colours from the host variables with a light-dark() fallback — background-color:\"var(--color-background-secondary, light-dark(#ffffff, #1f2430))\", color:\"var(--color-text-primary, light-dark(#0f172a, #e8eaed))\", border-color:\"var(--color-border-primary, light-dark(#e2e8f0, #333a48))\" — and always set `color` wherever you set `background-color` (a brand accent states its own text colour too).\n3. CONTENT — visible copy goes in props.content (text, heading, paragraph, button); heading level is the element subType (\"h1\"..\"h6\"); image/video take props.src. Write real https URLs: everything the widget loads from outside (images, media, fonts, an apiContainer endpoint) is fetched for it by the render server, so redirects and hotlink rules are handled and there is nothing to configure. It must still point at the actual file — use a URL you have seen work, and when you have none, draw the block with a gradient or an inline SVG instead of guessing one. An unknown prop comes back as a warning naming the right one.\n\nCommon types: container, heading, paragraph, text, button, link, image, video, list, listItem, markdown (plitzi://render/types lists every built-in type with descriptions). Widgets can also be data-driven and interactive — an apiContainer fetches at runtime, upsertBinding wires data into elements, and upsertInteractionFlow makes them react to clicks (see the guide).\nREAD the resource plitzi://render/guide first — it has the element/prop table, the style model and a full worked example, and following it is the difference between a widget that renders and repeated failed calls.\nITERATING — to change a widget you already rendered, do NOT rebuild it: call again with patch:true, the `renderId` that render answered with, and ONLY the operations that differ (patchDefinition, patchElement, deleteElement…). The widget merges them and reports back what it applied; address rows by the refs you already know. Patch ONLY to modify that widget: a different subject or a different kind of widget is a fresh render, without patch — a patch is merged into the previous batch, so patching a new idea leaves you with both.\nReturns a compact summary including the renderId (the widget itself is shown to the user); on failure it returns teachable errors (path + hint) — read them and retry.",
|
|
177
|
-
inputShape: renderShape,
|
|
178
|
-
access: "read",
|
|
179
|
-
spaceless: true,
|
|
180
|
-
ui: { resourceUri: RENDER_APP_URI },
|
|
181
|
-
run: (input, ctx) => input.patch === true ? toPatchResult(input.operations, input.renderId) : toRenderResult(render(input, { proxy: ctx.proxy }), input.renderId ?? newRenderId())
|
|
182
|
-
});
|
|
183
|
-
//#endregion
|
|
184
|
-
export { render, renderShape, renderTool };
|
|
@@ -1,83 +0,0 @@
|
|
|
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 };
|
|
@@ -1,115 +0,0 @@
|
|
|
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 };
|
|
@@ -1,44 +0,0 @@
|
|
|
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 };
|
|
@@ -1,33 +0,0 @@
|
|
|
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 };
|
|
@@ -1,124 +0,0 @@
|
|
|
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 };
|
|
@@ -1,39 +0,0 @@
|
|
|
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 };
|