@plitzi/sdk-server 0.32.25 → 0.33.1
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 +21 -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 -63
- package/dist/modules/mcp/proxy/fetch.js +0 -91
- package/dist/modules/mcp/proxy/grant.js +0 -67
- package/dist/modules/mcp/proxy/guard.js +0 -38
- package/dist/modules/mcp/proxy/handler.js +0 -99
- package/dist/modules/mcp/proxy/payload.js +0 -29
- package/dist/modules/mcp/proxy/rewrite.js +0 -138
- 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 -19
- package/dist/src/modules/mcp/proxy/fetch.d.ts +0 -18
- package/dist/src/modules/mcp/proxy/grant.d.ts +0 -25
- 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 -8
- package/dist/src/modules/mcp/proxy/payload.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/rewrite.d.ts +0 -18
- 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,67 +0,0 @@
|
|
|
1
|
-
import { sign, verify } from "./sign.js";
|
|
2
|
-
//#region src/modules/mcp/proxy/grant.ts
|
|
3
|
-
/** The single query parameter a proxied URL carries: `<signature>.<kind>.<expiry>.<connection>.<target>`. One
|
|
4
|
-
* parameter rather than several so the URL holds no `&` — these end up inside HTML attributes and markdown
|
|
5
|
-
* links, where an unescaped ampersand is the kind of detail that silently truncates a URL. */
|
|
6
|
-
var PARAM = "i";
|
|
7
|
-
var CODE = {
|
|
8
|
-
asset: "a",
|
|
9
|
-
data: "d"
|
|
10
|
-
};
|
|
11
|
-
var KIND = {
|
|
12
|
-
a: "asset",
|
|
13
|
-
d: "data"
|
|
14
|
-
};
|
|
15
|
-
var isTemplated = (target) => target.includes("{{");
|
|
16
|
-
var originOf = (target) => {
|
|
17
|
-
try {
|
|
18
|
-
return new URL(target).origin;
|
|
19
|
-
} catch {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
var encodeTarget = (target) => encodeURIComponent(target).replace(/%7B/g, "{").replace(/%7D/g, "}");
|
|
24
|
-
var payloadOf = (kind, expiry, identity, target) => `${CODE[kind]}.${expiry.toString(36)}.${identity}.${target}`;
|
|
25
|
-
/** Mint the URL a widget will load this target from: this server's endpoint, carrying the target, the kind it was
|
|
26
|
-
* granted for, when the grant stops working and which connection minted it — all covered by one signature. */
|
|
27
|
-
var grantUrl = (target, proxy, kind = "asset") => {
|
|
28
|
-
const expiry = Math.floor(Date.now() / 1e3) + proxy.ttl;
|
|
29
|
-
const scope = (isTemplated(target) ? originOf(target) : target) ?? target;
|
|
30
|
-
const signature = sign(payloadOf(kind, expiry, proxy.identity, scope), proxy.secret);
|
|
31
|
-
const payload = `${CODE[kind]}.${expiry.toString(36)}.${proxy.identity}.${encodeTarget(target)}`;
|
|
32
|
-
return `${proxy.endpoint}?${PARAM}=${signature}.${payload}`;
|
|
33
|
-
};
|
|
34
|
-
/** What this endpoint was asked to fetch, or undefined when the parameter is missing, malformed, expired or not
|
|
35
|
-
* signed here — which is what keeps it from being an open proxy for anyone who finds it: it serves the URLs this
|
|
36
|
-
* server rewrote, for as long as it said, and nothing else.
|
|
37
|
-
*
|
|
38
|
-
* Takes the parameter as the query parser hands it over — decoded exactly once, which is the form that was
|
|
39
|
-
* signed. Decoding it again would corrupt every target that legitimately carries a percent-escape (an API URL
|
|
40
|
-
* with a nested URL in its query) and reject it as unsigned. */
|
|
41
|
-
var readGrant = (param, secret) => {
|
|
42
|
-
const parts = param?.split(".") ?? [];
|
|
43
|
-
if (parts.length < 5) return;
|
|
44
|
-
const [signature = "", code = "", expiry = "", identity = ""] = parts;
|
|
45
|
-
const kind = KIND[code];
|
|
46
|
-
const target = parts.slice(4).join(".");
|
|
47
|
-
const expiresAt = parseInt(expiry, 36);
|
|
48
|
-
if (!kind || !Number.isFinite(expiresAt) || expiresAt * 1e3 < Date.now()) return;
|
|
49
|
-
const payload = payloadOf(kind, expiresAt, identity, target);
|
|
50
|
-
if (verify(payload, signature, secret)) return {
|
|
51
|
-
kind,
|
|
52
|
-
target,
|
|
53
|
-
identity
|
|
54
|
-
};
|
|
55
|
-
const origin = originOf(target);
|
|
56
|
-
return origin && verify(payloadOf(kind, expiresAt, identity, origin), signature, secret) ? {
|
|
57
|
-
kind,
|
|
58
|
-
target,
|
|
59
|
-
identity
|
|
60
|
-
} : void 0;
|
|
61
|
-
};
|
|
62
|
-
/** Is this URL one the widget can already reach? Absolute http(s) URLs are the ones a sandbox CSP blocks;
|
|
63
|
-
* `data:`/`blob:` carry their own bytes, and a relative URL has no origin to reach in the first place. */
|
|
64
|
-
var isRemote = (url) => /^https?:\/\//i.test(url);
|
|
65
|
-
var isGranted = (url, proxy) => url.startsWith(`${proxy.endpoint}?`);
|
|
66
|
-
//#endregion
|
|
67
|
-
export { grantUrl, isGranted, isRemote, readGrant };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { lookup } from "node:dns/promises";
|
|
2
|
-
import { isIP } from "node:net";
|
|
3
|
-
//#region src/modules/mcp/proxy/guard.ts
|
|
4
|
-
var isPrivateIpv4 = (address) => {
|
|
5
|
-
const parts = address.split(".").map(Number);
|
|
6
|
-
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) return true;
|
|
7
|
-
const [a = 0, b = 0] = parts;
|
|
8
|
-
return a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 0 || a === 192 && b === 168 || a === 198 && (b === 18 || b === 19) || a >= 224;
|
|
9
|
-
};
|
|
10
|
-
var isPrivateIpv6 = (address) => {
|
|
11
|
-
const normalized = address.toLowerCase().split("%")[0] ?? "";
|
|
12
|
-
if (normalized.startsWith("::ffff:") && normalized.includes(".")) return isPrivateIpv4(normalized.slice(7));
|
|
13
|
-
return normalized === "::" || normalized === "::1" || normalized.startsWith("fc") || normalized.startsWith("fd") || normalized.startsWith("fe8") || normalized.startsWith("fe9") || normalized.startsWith("fea") || normalized.startsWith("feb");
|
|
14
|
-
};
|
|
15
|
-
var isPrivateAddress = (address) => isIP(address) === 6 ? isPrivateIpv6(address) : isPrivateIpv4(address);
|
|
16
|
-
var PRIVATE_SUFFIXES = [
|
|
17
|
-
".local",
|
|
18
|
-
".internal",
|
|
19
|
-
".localhost",
|
|
20
|
-
".home.arpa"
|
|
21
|
-
];
|
|
22
|
-
/** Does this hostname resolve somewhere on the public internet? The endpoint fetches URLs an agent authored, so
|
|
23
|
-
* without this it would be a way to read whatever the pod itself can reach — the cluster's services, the cloud
|
|
24
|
-
* metadata endpoint, a database on the node. Both the literal address and every address the name resolves to are
|
|
25
|
-
* checked; a name that does not resolve is refused rather than handed to fetch. */
|
|
26
|
-
var isPublicHost = async (hostname) => {
|
|
27
|
-
const host = hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
28
|
-
if (!host || host === "localhost" || PRIVATE_SUFFIXES.some((suffix) => host.endsWith(suffix))) return false;
|
|
29
|
-
if (isIP(host)) return !isPrivateAddress(host);
|
|
30
|
-
try {
|
|
31
|
-
const addresses = await lookup(host, { all: true });
|
|
32
|
-
return addresses.length > 0 && addresses.every((entry) => !isPrivateAddress(entry.address));
|
|
33
|
-
} catch {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
//#endregion
|
|
38
|
-
export { isPrivateAddress, isPublicHost };
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { grantingProxy } from "./config.js";
|
|
2
|
-
import { readGrant } from "./grant.js";
|
|
3
|
-
import { fetchResource } from "./fetch.js";
|
|
4
|
-
import { rewritablePayload, rewritePayload } from "./payload.js";
|
|
5
|
-
//#region src/modules/mcp/proxy/handler.ts
|
|
6
|
-
var CACHE_CONTROL = {
|
|
7
|
-
asset: "public, max-age=86400, immutable",
|
|
8
|
-
data: "no-store"
|
|
9
|
-
};
|
|
10
|
-
/** Read a response whole, or undefined once it is past the limit. Only a rewritable answer is read this way: it has
|
|
11
|
-
* to be complete before a URL inside it can be swapped, and an API answer is small — which is exactly why the
|
|
12
|
-
* streaming path below stays the rule for everything else. */
|
|
13
|
-
var readAll = async (body, maxBytes) => {
|
|
14
|
-
const reader = body.getReader();
|
|
15
|
-
const chunks = [];
|
|
16
|
-
let written = 0;
|
|
17
|
-
for (;;) {
|
|
18
|
-
const { done, value } = await reader.read();
|
|
19
|
-
if (done) break;
|
|
20
|
-
written += value.byteLength;
|
|
21
|
-
if (written > maxBytes) {
|
|
22
|
-
await reader.cancel();
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
chunks.push(Buffer.from(value));
|
|
26
|
-
}
|
|
27
|
-
return Buffer.concat(chunks);
|
|
28
|
-
};
|
|
29
|
-
var fail = (res, status, reason) => {
|
|
30
|
-
res.setStatus(status);
|
|
31
|
-
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
32
|
-
res.setHeader("Cache-Control", "no-store");
|
|
33
|
-
res.send(reason);
|
|
34
|
-
};
|
|
35
|
-
/** Serve one external resource on behalf of a widget: check the grant this server signed, fetch the target, and
|
|
36
|
-
* stream it back under this origin — the one the CSP declares. Read-only, credential-free and CORS-open, because
|
|
37
|
-
* it answers the host's sandboxed iframe: a browser that has no origin of its own and can present nothing. The
|
|
38
|
-
* grant is what stands in for a caller identity — it is unforgeable, it names one target (or one host, for a
|
|
39
|
-
* templated API URL), it names the kind, it expires, and it carries the connection that minted it. */
|
|
40
|
-
var handleProxyRequest = async (req, res, settings) => {
|
|
41
|
-
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
42
|
-
res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
|
|
43
|
-
if (req.method === "OPTIONS") {
|
|
44
|
-
res.setHeader("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS");
|
|
45
|
-
res.setHeader("Access-Control-Allow-Headers", "*");
|
|
46
|
-
res.setStatus(204);
|
|
47
|
-
res.end();
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
51
|
-
fail(res, 405, "Only GET is served here.");
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const grant = readGrant(req.query["i"], settings.secret);
|
|
55
|
-
if (!grant) {
|
|
56
|
-
fail(res, 403, "This URL is missing a grant, or the one it carries was not issued here or has expired.");
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const result = await fetchResource(grant.target, grant.kind, settings.maxBytes);
|
|
60
|
-
if (!result.ok) {
|
|
61
|
-
fail(res, result.status, result.reason);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
res.setStatus(200);
|
|
65
|
-
res.setHeader("Content-Type", result.contentType);
|
|
66
|
-
res.setHeader("Cache-Control", CACHE_CONTROL[grant.kind]);
|
|
67
|
-
if (req.method === "HEAD" || !result.body) {
|
|
68
|
-
res.end();
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const payloadProxy = grant.kind === "data" && rewritablePayload(result.contentType) ? grantingProxy(settings, req, grant.identity) : void 0;
|
|
72
|
-
if (payloadProxy) {
|
|
73
|
-
const body = await readAll(result.body, settings.maxBytes);
|
|
74
|
-
if (!body) {
|
|
75
|
-
fail(res, 413, "That response is too large to load in a widget.");
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
res.send(rewritePayload(body.toString("utf8"), payloadProxy));
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const reader = result.body.getReader();
|
|
82
|
-
let written = 0;
|
|
83
|
-
try {
|
|
84
|
-
for (;;) {
|
|
85
|
-
const { done, value } = await reader.read();
|
|
86
|
-
if (done) break;
|
|
87
|
-
written += value.byteLength;
|
|
88
|
-
if (written > settings.maxBytes) {
|
|
89
|
-
await reader.cancel();
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
res.write(Buffer.from(value));
|
|
93
|
-
}
|
|
94
|
-
} finally {
|
|
95
|
-
res.end();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
//#endregion
|
|
99
|
-
export { handleProxyRequest };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { grantUrl, isGranted, isRemote } from "./grant.js";
|
|
2
|
-
import { looksLikeAsset } from "./rewrite.js";
|
|
3
|
-
//#region src/modules/mcp/proxy/payload.ts
|
|
4
|
-
var JSON_TYPES = ["application/json", "application/ld+json"];
|
|
5
|
-
var ASSET_FIELD = /(image|img|thumb|photo|picture|avatar|icon|logo|cover|banner|poster|artwork|media|src)/i;
|
|
6
|
-
/** Is this what the endpoint fetched a body it can rewrite? Only JSON: it is what an apiContainer binds against,
|
|
7
|
-
* and re-serializing anything else would risk changing a document to fix a URL that may not even be loaded. */
|
|
8
|
-
var rewritablePayload = (contentType) => JSON_TYPES.some((type) => contentType.startsWith(type));
|
|
9
|
-
var rewriteNode = (node, field, proxy) => {
|
|
10
|
-
if (typeof node === "string") return isRemote(node) && !isGranted(node, proxy) && (looksLikeAsset(node) || ASSET_FIELD.test(field)) ? grantUrl(node, proxy) : node;
|
|
11
|
-
if (Array.isArray(node)) return node.map((item) => rewriteNode(item, field, proxy));
|
|
12
|
-
if (node !== null && typeof node === "object") {
|
|
13
|
-
const entries = Object.entries(node);
|
|
14
|
-
return Object.fromEntries(entries.map(([key, value]) => [key, rewriteNode(value, key, proxy)]));
|
|
15
|
-
}
|
|
16
|
-
return node;
|
|
17
|
-
};
|
|
18
|
-
/** Rewrite the asset URLs an API answer carries so the widget loads them through this endpoint too. Returns the
|
|
19
|
-
* body untouched when it is not the JSON it claimed to be — the widget asked for that response, and serving it
|
|
20
|
-
* as it came is better than failing the fetch over a rewrite. */
|
|
21
|
-
var rewritePayload = (body, proxy) => {
|
|
22
|
-
try {
|
|
23
|
-
return JSON.stringify(rewriteNode(JSON.parse(body), "", proxy));
|
|
24
|
-
} catch {
|
|
25
|
-
return body;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
export { rewritablePayload, rewritePayload };
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { grantUrl, isGranted, isRemote } from "./grant.js";
|
|
2
|
-
//#region src/modules/mcp/proxy/rewrite.ts
|
|
3
|
-
var URL_ATTRIBUTES = ["src", "poster"];
|
|
4
|
-
var MARKUP_ATTRIBUTES = ["content", "html"];
|
|
5
|
-
var FETCHING_TYPE = "apiContainer";
|
|
6
|
-
var SET_STATE_ACTION = "setState";
|
|
7
|
-
var NAVIGATION_ACTION = "navigate";
|
|
8
|
-
var FETCHING_UTILITY = "webHook";
|
|
9
|
-
var ASSET_EXTENSION = /\.(?:apng|avif|bmp|gif|ico|jpe?g|png|svg|webp|aac|flac|m4a|mp3|oga|ogg|opus|wav|mp4|m4v|mov|ogv|webm|otf|ttf|woff2?)$/i;
|
|
10
|
-
var CSS_URL = /url\(\s*(["']?)(https?:\/\/[^"')\s]+)\1\s*\)/gi;
|
|
11
|
-
var HTML_SRC = /(<[^>]+?\ssrc\s*=\s*)(["'])(https?:\/\/[^"']+)\2/gi;
|
|
12
|
-
var MARKDOWN_IMAGE = /(!\[[^\]]*\]\(\s*)(https?:\/\/[^\s)]+)/gi;
|
|
13
|
-
var unescapeHtml = (url) => url.replace(/&/g, "&");
|
|
14
|
-
var toProxy = (url, proxy) => isGranted(url, proxy) ? url : grantUrl(unescapeHtml(url), proxy);
|
|
15
|
-
/** Does this URL name a file the widget loads, judged by its path alone? Used where nothing else says what a URL is
|
|
16
|
-
* for — an interaction param, a field of an API answer — so the extension is the evidence and its absence is a
|
|
17
|
-
* reason to leave the URL alone. */
|
|
18
|
-
var looksLikeAsset = (url) => {
|
|
19
|
-
try {
|
|
20
|
-
return ASSET_EXTENSION.test(new URL(url).pathname);
|
|
21
|
-
} catch {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
/** Rewrite every remote URL embedded in a string: `url(…)` in CSS, `src="…"` in markup, `` in markdown. */
|
|
26
|
-
var rewriteText = (text, proxy) => text.replace(CSS_URL, (_match, quote, url) => `url(${quote}${toProxy(url, proxy)}${quote})`).replace(HTML_SRC, (_match, prefix, quote, url) => `${prefix}${quote}${toProxy(url, proxy)}${quote}`).replace(MARKDOWN_IMAGE, (_match, prefix, url) => `${prefix}${toProxy(url, proxy)}`);
|
|
27
|
-
var rewriteStyleObject = (styleObject, proxy) => {
|
|
28
|
-
for (const [property, value] of Object.entries(styleObject)) if (typeof value === "string" && value.includes("url(")) styleObject[property] = rewriteText(value, proxy);
|
|
29
|
-
};
|
|
30
|
-
var rewriteStyleBlock = (block, proxy) => {
|
|
31
|
-
if (block.default) rewriteStyleObject(block.default, proxy);
|
|
32
|
-
for (const state of Object.values(block.states ?? {})) rewriteStyleObject(state, proxy);
|
|
33
|
-
};
|
|
34
|
-
/** Why a request was left as authored, or undefined when it can be granted. Each case is one this hop cannot
|
|
35
|
-
* reproduce faithfully, and getting it wrong silently would be worse than the request being blocked: a write sent
|
|
36
|
-
* through a GET, or an API answering 401 because its credential was dropped on the way. Reads both vocabularies —
|
|
37
|
-
* an apiContainer's attributes and a webHook's params name the same things differently. */
|
|
38
|
-
var unproxyableFetch = (source) => {
|
|
39
|
-
const { method, headers, accessToken, authorizationToken } = source;
|
|
40
|
-
if (typeof method === "string" && method.toLowerCase() !== "get") return `it is a ${method.toUpperCase()} request`;
|
|
41
|
-
if (typeof accessToken === "string" && accessToken !== "") return "it sends its own credentials";
|
|
42
|
-
if (typeof authorizationToken === "string" && authorizationToken !== "") return "it sends its own credentials";
|
|
43
|
-
return headers && Object.keys(headers).length > 0 ? "it sends its own headers" : void 0;
|
|
44
|
-
};
|
|
45
|
-
var rewriteSetState = (params, proxy) => {
|
|
46
|
-
const { key, value } = params;
|
|
47
|
-
if (typeof key !== "string" || typeof value !== "string") return false;
|
|
48
|
-
if (URL_ATTRIBUTES.includes(key) && isRemote(value)) {
|
|
49
|
-
params.value = toProxy(value, proxy);
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
if (MARKUP_ATTRIBUTES.includes(key) && value.includes("http")) {
|
|
53
|
-
params.value = rewriteText(value, proxy);
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
return false;
|
|
57
|
-
};
|
|
58
|
-
var rewriteParams = (params, proxy) => {
|
|
59
|
-
for (const [name, value] of Object.entries(params)) {
|
|
60
|
-
if (typeof value !== "string") continue;
|
|
61
|
-
if (URL_ATTRIBUTES.includes(name) && isRemote(value)) params[name] = toProxy(value, proxy);
|
|
62
|
-
else if (MARKUP_ATTRIBUTES.includes(name) && value.includes("http")) params[name] = rewriteText(value, proxy);
|
|
63
|
-
else if (isRemote(value) && looksLikeAsset(value)) params[name] = toProxy(value, proxy);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
var rewriteWebHook = (node, proxy, warnings) => {
|
|
67
|
-
const params = node.params;
|
|
68
|
-
const url = params.url;
|
|
69
|
-
if (typeof url !== "string" || !isRemote(url) || isGranted(url, proxy)) return;
|
|
70
|
-
const blocked = unproxyableFetch(params);
|
|
71
|
-
if (blocked) {
|
|
72
|
-
warnings.push(`The ${FETCHING_UTILITY} step "${node.title}" calls its endpoint directly because ${blocked}, so that request is subject to the network policy of the surface it renders in, and to the CORS headers of the API, and may not run. A plain GET with no credentials is fetched by the widget server instead, which always works.`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
params.url = grantUrl(url, proxy, "data");
|
|
76
|
-
};
|
|
77
|
-
var rewriteInteractions = (interactions, proxy, warnings) => {
|
|
78
|
-
for (const node of Object.values(interactions ?? {})) {
|
|
79
|
-
if (node.type === "globalCallback" && node.action === NAVIGATION_ACTION) continue;
|
|
80
|
-
if (node.type === "utility" && node.action === FETCHING_UTILITY) {
|
|
81
|
-
rewriteWebHook(node, proxy, warnings);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
const params = node.params;
|
|
85
|
-
if (node.action === SET_STATE_ACTION && rewriteSetState(params, proxy)) continue;
|
|
86
|
-
rewriteParams(params, proxy);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
var rewriteBindings = (bindings, proxy) => {
|
|
90
|
-
for (const category of Object.values(bindings ?? {})) for (const binding of category) for (const transformer of binding.transformers ?? []) rewriteParams(transformer.params, proxy);
|
|
91
|
-
};
|
|
92
|
-
var rewriteSchema = (schema, proxy, warnings) => {
|
|
93
|
-
for (const element of Object.values(schema.flat)) {
|
|
94
|
-
rewriteInteractions(element.definition.interactions, proxy, warnings);
|
|
95
|
-
rewriteBindings(element.definition.bindings, proxy);
|
|
96
|
-
const attributes = element.attributes;
|
|
97
|
-
for (const name of URL_ATTRIBUTES) {
|
|
98
|
-
const value = attributes[name];
|
|
99
|
-
if (typeof value === "string" && isRemote(value) && !isGranted(value, proxy)) attributes[name] = grantUrl(value, proxy);
|
|
100
|
-
}
|
|
101
|
-
for (const name of MARKUP_ATTRIBUTES) {
|
|
102
|
-
const value = attributes[name];
|
|
103
|
-
if (typeof value === "string" && value.includes("http")) attributes[name] = rewriteText(value, proxy);
|
|
104
|
-
}
|
|
105
|
-
const query = attributes.query;
|
|
106
|
-
if (element.definition.type !== FETCHING_TYPE || typeof query !== "string" || !isRemote(query)) continue;
|
|
107
|
-
const blocked = unproxyableFetch(attributes);
|
|
108
|
-
if (blocked) {
|
|
109
|
-
warnings.push(`The ${FETCHING_TYPE} "${element.idRef ?? element.id}" calls its endpoint directly because ${blocked}, so that request is subject to the network policy of the surface it renders in, and to the CORS headers of the API, and may not run. A plain GET with no headers is fetched by the widget server instead, which always works.`);
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if (!isGranted(query, proxy)) attributes.query = grantUrl(query, proxy, "data");
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
var rewriteStyle = (style, proxy) => {
|
|
116
|
-
for (const items of Object.values(style.platform)) for (const item of Object.values(items)) {
|
|
117
|
-
for (const selector of Object.values(item.attributes)) {
|
|
118
|
-
rewriteStyleBlock(selector, proxy);
|
|
119
|
-
for (const variant of Object.values(selector.variants ?? {})) rewriteStyleBlock(variant, proxy);
|
|
120
|
-
}
|
|
121
|
-
if (item.cache.includes("url(")) item.cache = rewriteText(item.cache, proxy);
|
|
122
|
-
}
|
|
123
|
-
if (style.cache.includes("url(")) style.cache = rewriteText(style.cache, proxy);
|
|
124
|
-
};
|
|
125
|
-
/** Point everything an authored widget loads from outside — images, media, fonts, the data an apiContainer fetches
|
|
126
|
-
* and the URLs its interactions swap in later — at this server's endpoint, in place. The AGENT never sees this: it
|
|
127
|
-
* authors the real URL and this runs
|
|
128
|
-
* afterwards, on the throwaway space a render builds (so nothing shared is mutated) and before the global style
|
|
129
|
-
* cache is compiled (so the concatenated CSS comes out already rewritten). Returns what could not be rewritten,
|
|
130
|
-
* which is the only part the model hears about. */
|
|
131
|
-
var proxifyResources = (space, proxy) => {
|
|
132
|
-
const warnings = [];
|
|
133
|
-
rewriteSchema(space.schema, proxy, warnings);
|
|
134
|
-
rewriteStyle(space.style, proxy);
|
|
135
|
-
return warnings;
|
|
136
|
-
};
|
|
137
|
-
//#endregion
|
|
138
|
-
export { looksLikeAsset, proxifyResources, rewriteText };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
-
//#region src/modules/mcp/proxy/sign.ts
|
|
3
|
-
var SIGNATURE_LENGTH = 22;
|
|
4
|
-
var sign = (payload, secret) => createHmac("sha256", secret).update(payload).digest("base64url").slice(0, SIGNATURE_LENGTH);
|
|
5
|
-
var verify = (payload, signature, secret) => {
|
|
6
|
-
const expected = Buffer.from(sign(payload, secret));
|
|
7
|
-
const given = Buffer.from(signature);
|
|
8
|
-
return expected.length === given.length && timingSafeEqual(expected, given);
|
|
9
|
-
};
|
|
10
|
-
/** A short, stable fingerprint of the MCP credential a request carried — the connection a grant belongs to.
|
|
11
|
-
* Derived through the same secret, so it identifies without echoing any part of the token; a request with no
|
|
12
|
-
* credential (the public widgets surface) gets the shared anonymous identity. */
|
|
13
|
-
var connectionId = (authorization, secret) => authorization ? sign(`id:${authorization}`, secret).slice(0, 10) : "anon";
|
|
14
|
-
//#endregion
|
|
15
|
-
export { connectionId, sign, verify };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
//#region src/modules/mcp/proxy/types.ts
|
|
2
|
-
/** The tools a proxy may be handed to. `plitzi_render` alone by default, and that default is a guard, not a
|
|
3
|
-
* convenience: a render is a THROWAWAY widget, so rewriting its URLs changes nothing that outlives the call —
|
|
4
|
-
* while plitzi_apply writes to the user's real space, where a rewritten URL would be PERSISTED and the space
|
|
5
|
-
* would come to depend on this server's endpoint for content it owns. Nothing else should be added here without
|
|
6
|
-
* that being the intention. */
|
|
7
|
-
var DEFAULT_PROXY_TOOLS = ["plitzi_render"];
|
|
8
|
-
//#endregion
|
|
9
|
-
export { DEFAULT_PROXY_TOOLS };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { afterPrefix, aliasedRoots, itemTemplates, primerUri } from "../helpers/uris.js";
|
|
2
|
-
//#region src/modules/mcp/resources/canonical.ts
|
|
3
|
-
var canonicalUri = (env, uri) => {
|
|
4
|
-
const rest = afterPrefix(uri, `plitzi://schema/${env}/`);
|
|
5
|
-
if (rest === void 0) return uri;
|
|
6
|
-
for (const root of aliasedRoots) {
|
|
7
|
-
if (rest === root) return `plitzi://${root}/${env}`;
|
|
8
|
-
if (rest.startsWith(`${root}/`)) return `plitzi://${root}/${env}/${rest.slice(root.length + 1)}`;
|
|
9
|
-
}
|
|
10
|
-
return uri;
|
|
11
|
-
};
|
|
12
|
-
/** Teachable message for a URI that read as null. Distinguishes a well-formed URI whose ref does not resolve (the
|
|
13
|
-
* resource may be stale/deleted) from a URI whose shape matches no template at all (malformed — echo the valid
|
|
14
|
-
* templates so the agent stops hand-building URIs). See RFC 0004 I2. */
|
|
15
|
-
var resourceErrorMessage = (env, uri) => {
|
|
16
|
-
const canonical = canonicalUri(env, uri);
|
|
17
|
-
if (itemTemplates(env).some((tpl) => canonical.startsWith(tpl.slice(0, tpl.lastIndexOf("/") + 1)))) return JSON.stringify({
|
|
18
|
-
error: "NOT_FOUND",
|
|
19
|
-
message: `No resource at '${uri}'. Its shape is valid but the ref does not resolve.`,
|
|
20
|
-
hint: "It may have been deleted or your URI is stale. Re-list the parent resource (pages/definitions) to refresh."
|
|
21
|
-
});
|
|
22
|
-
return JSON.stringify({
|
|
23
|
-
error: "MALFORMED_URI",
|
|
24
|
-
message: `'${uri}' matches no resource template.`,
|
|
25
|
-
hint: "Do not hand-build element URIs — take the ready-made uri from plitzi_search or a write response.",
|
|
26
|
-
validTemplates: [primerUri(env), ...itemTemplates(env)]
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
|
-
export { canonicalUri, resourceErrorMessage };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { cssProperties, cssShorthands } from "../catalogs/cssCatalog/index.js";
|
|
2
|
-
import { buildTypeRegistry } from "../catalogs/registry.js";
|
|
3
|
-
import "../helpers/uris.js";
|
|
4
|
-
import { guideText } from "../helpers/guide.js";
|
|
5
|
-
import { envelope } from "./envelope.js";
|
|
6
|
-
//#region src/modules/mcp/resources/core.ts
|
|
7
|
-
/** Space-independent singletons: the usage guide, the observed type registry and the CSS property catalog.
|
|
8
|
-
* Returns undefined when the URI is not one of these, so the router falls through to the next resolver. */
|
|
9
|
-
var readCoreResource = (space, uri) => {
|
|
10
|
-
if (uri === "plitzi://guide") return envelope(guideText);
|
|
11
|
-
if (uri === "plitzi://types") return envelope(buildTypeRegistry(space.schema, space.catalog));
|
|
12
|
-
if (uri === "plitzi://css-properties") return envelope({
|
|
13
|
-
properties: cssProperties,
|
|
14
|
-
shorthands: cssShorthands
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
//#endregion
|
|
18
|
-
export { readCoreResource };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { computeVersion } from "../helpers/computeVersion.js";
|
|
2
|
-
//#region src/modules/mcp/resources/envelope.ts
|
|
3
|
-
/** Wrap any read projection with the version its optimistic-concurrency checks key on. */
|
|
4
|
-
var envelope = (data) => ({
|
|
5
|
-
stateVersion: computeVersion(data),
|
|
6
|
-
data
|
|
7
|
-
});
|
|
8
|
-
var jsonContents = (uri, data) => ({ contents: [{
|
|
9
|
-
uri,
|
|
10
|
-
mimeType: "application/json",
|
|
11
|
-
text: JSON.stringify(data)
|
|
12
|
-
}] });
|
|
13
|
-
//#endregion
|
|
14
|
-
export { envelope, jsonContents };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { cssProperties, cssShorthands } from "../catalogs/cssCatalog/index.js";
|
|
2
|
-
import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
|
|
3
|
-
import { buildTypeRegistry } from "../catalogs/registry.js";
|
|
4
|
-
import { guideQuickstart } from "../helpers/guide.js";
|
|
5
|
-
import { envelope } from "./envelope.js";
|
|
6
|
-
import { definitionRefs, styleVariablesToAI } from "../tools/operations/style/translator.js";
|
|
7
|
-
import { foldersToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI } from "../tools/operations/schema/translator.js";
|
|
8
|
-
//#region src/modules/mcp/resources/primer.ts
|
|
9
|
-
/** The cold-start bundle: everything the guide says to read before the first write, in one round-trip.
|
|
10
|
-
* Summaries only — never full page/element trees (those are opened on demand), so it stays cheap even on a
|
|
11
|
-
* large space. Carries the condensed `guideQuickstart` (not the full guideText, which the agent reads on demand at
|
|
12
|
-
* plitzi://guide) to keep the bundle small. Returns undefined when the URI is not the primer. */
|
|
13
|
-
var readPrimerResource = (space, env, uri) => {
|
|
14
|
-
if (uri !== `plitzi://primer/${env}`) return;
|
|
15
|
-
return envelope({
|
|
16
|
-
guide: guideQuickstart,
|
|
17
|
-
types: buildTypeRegistry(space.schema, space.catalog),
|
|
18
|
-
cssProperties,
|
|
19
|
-
cssShorthands,
|
|
20
|
-
pages: pageSummariesToAI(space.schema),
|
|
21
|
-
folders: foldersToAI(space.schema),
|
|
22
|
-
definitions: definitionRefs(space.style),
|
|
23
|
-
styleVariables: styleVariablesToAI(space.style),
|
|
24
|
-
schemaVariables: schemaVariablesToAI(space.schema, false),
|
|
25
|
-
settings: settingsToAI(space.schema),
|
|
26
|
-
interactions: buildInteractionCatalog(space.schema),
|
|
27
|
-
dataSources: buildDataSourceCatalog(space.schema)
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
//#endregion
|
|
31
|
-
export { readPrimerResource };
|