@plitzi/sdk-server 0.32.25 → 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 +12 -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,120 +0,0 @@
|
|
|
1
|
-
import { firstText, toolResponseErr } from "./toolkit.js";
|
|
2
|
-
//#region src/modules/ai/AIEngine.ts
|
|
3
|
-
var AIEngine = class {
|
|
4
|
-
mode;
|
|
5
|
-
callbacks;
|
|
6
|
-
toolsAvailables = /* @__PURE__ */ new Map();
|
|
7
|
-
toolsAvailablesMap = /* @__PURE__ */ new Map();
|
|
8
|
-
ctx;
|
|
9
|
-
constructor(mode, callbacks, ctx) {
|
|
10
|
-
this.mode = mode;
|
|
11
|
-
this.callbacks = callbacks;
|
|
12
|
-
this.ctx = {
|
|
13
|
-
...ctx,
|
|
14
|
-
mode: mode || "plan"
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
readResource = (name, uri) => {
|
|
18
|
-
this.callbacks.onResourceRead?.(name, uri);
|
|
19
|
-
};
|
|
20
|
-
setToolsAvailables = (tools) => {
|
|
21
|
-
this.toolsAvailables = new Map(tools.map((t) => [t.name, t]));
|
|
22
|
-
this.toolsAvailablesMap = new Map(tools.map((t) => [t.name, t.definition.allowedModes]));
|
|
23
|
-
};
|
|
24
|
-
can = (name) => {
|
|
25
|
-
if (!this.mode || !this.toolsAvailablesMap.has(name)) return false;
|
|
26
|
-
const allowedModes = this.toolsAvailablesMap.get(name);
|
|
27
|
-
return !allowedModes || allowedModes.includes(this.mode);
|
|
28
|
-
};
|
|
29
|
-
before = async (name, args) => {
|
|
30
|
-
this.callbacks.onBeforeTool?.(name, args);
|
|
31
|
-
if (!this.toolsAvailables.has(name)) {
|
|
32
|
-
this.callbacks.onLog?.("error", `tool rejected: '${name}' has no definition — possible security violation`);
|
|
33
|
-
await this.after(name, args, toolResponseErr(`Tool '${name}' is not defined and cannot be executed`));
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
if (!this.can(name)) {
|
|
37
|
-
this.callbacks.onLog?.("info", `tool blocked: '${name}' is not permitted in ${this.mode} mode`);
|
|
38
|
-
await this.after(name, args, toolResponseErr(`Tool '${name}' is not permitted in ${this.mode} mode`));
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
};
|
|
43
|
-
after = (name, args, result) => {
|
|
44
|
-
let resultParsed;
|
|
45
|
-
if (result.data !== void 0) resultParsed = result.data;
|
|
46
|
-
else try {
|
|
47
|
-
resultParsed = JSON.parse(firstText(result.content) ?? "");
|
|
48
|
-
} catch {}
|
|
49
|
-
if (result.isError) this.callbacks.onToolError?.({
|
|
50
|
-
name,
|
|
51
|
-
args,
|
|
52
|
-
result: resultParsed ?? { error: firstText(result.content) ?? "Tool failed" }
|
|
53
|
-
});
|
|
54
|
-
else this.callbacks.onToolSuccess?.({
|
|
55
|
-
name,
|
|
56
|
-
args,
|
|
57
|
-
result: resultParsed
|
|
58
|
-
});
|
|
59
|
-
return Promise.resolve();
|
|
60
|
-
};
|
|
61
|
-
validateToolInput = (name, args) => {
|
|
62
|
-
const tool = this.toolsAvailables.get(name);
|
|
63
|
-
if (!tool || !tool.mcpDefinition.inputSchema) return {
|
|
64
|
-
success: true,
|
|
65
|
-
data: args
|
|
66
|
-
};
|
|
67
|
-
const parsed = tool.mcpDefinition.inputSchema.safeParse(args);
|
|
68
|
-
if (!parsed.success) return {
|
|
69
|
-
success: false,
|
|
70
|
-
error: parsed.error.message
|
|
71
|
-
};
|
|
72
|
-
return {
|
|
73
|
-
success: true,
|
|
74
|
-
data: parsed.data
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
validateToolOutput = (name, result) => {
|
|
78
|
-
const tool = this.toolsAvailables.get(name);
|
|
79
|
-
if (!tool || !tool.mcpDefinition.outputSchema || result.isError) return;
|
|
80
|
-
if (result.data === void 0) return;
|
|
81
|
-
const parsed = tool.mcpDefinition.outputSchema.safeParse(result.data);
|
|
82
|
-
if (!parsed.success) return parsed.error.message;
|
|
83
|
-
};
|
|
84
|
-
runPipeline = async (name, args, handler) => {
|
|
85
|
-
const parsedArgs = this.validateToolInput(name, args);
|
|
86
|
-
if (!parsedArgs.success) {
|
|
87
|
-
this.callbacks.onLog?.("error", `tool validation error: ${name} error=${parsedArgs.error}`);
|
|
88
|
-
const err = toolResponseErr(parsedArgs.error);
|
|
89
|
-
await this.after(name, args, err);
|
|
90
|
-
return err;
|
|
91
|
-
}
|
|
92
|
-
const t0 = Date.now();
|
|
93
|
-
const result = await handler(parsedArgs.data, this.ctx);
|
|
94
|
-
this.callbacks.onLog?.("debug", `tool done: ${name} ms=${Date.now() - t0} result=${JSON.stringify(result).slice(0, 200)}`);
|
|
95
|
-
const outputError = this.validateToolOutput(name, result);
|
|
96
|
-
if (outputError) this.callbacks.onLog?.("info", `tool output schema drift: ${name} — ${outputError}`);
|
|
97
|
-
const tool = this.toolsAvailables.get(name);
|
|
98
|
-
if (!result.isError && tool?.mcpDefinition.outputSchema && result.data !== void 0 && result.data !== null) result.structuredContent = typeof result.data === "object" && !Array.isArray(result.data) ? result.data : { data: result.data };
|
|
99
|
-
if (result.isError) this.callbacks.onLog?.("error", `tool failed: ${name} error=${firstText(result.content) ?? "unknown"}`);
|
|
100
|
-
await this.after(name, args, result);
|
|
101
|
-
return result;
|
|
102
|
-
};
|
|
103
|
-
execute = (name, handlerFn) => async (args) => {
|
|
104
|
-
if (!await this.before(name, args)) return toolResponseErr(`Tool '${name}' execution was blocked`);
|
|
105
|
-
const handler = handlerFn ?? this.toolsAvailables.get(name)?.handler;
|
|
106
|
-
if (!handler) {
|
|
107
|
-
this.callbacks.onLog?.("error", `no handler registered for tool: ${name}`);
|
|
108
|
-
const err = toolResponseErr(`Tool '${name}' has no handler`);
|
|
109
|
-
await this.after(name, args, err);
|
|
110
|
-
return err;
|
|
111
|
-
}
|
|
112
|
-
this.callbacks.onLog?.("debug", `tool exec: ${name} args=${JSON.stringify(args).slice(0, 200)}`);
|
|
113
|
-
return this.runPipeline(name, args, handler);
|
|
114
|
-
};
|
|
115
|
-
executePrompt = (_name, handlerFn) => async (args) => {
|
|
116
|
-
return handlerFn(args, this.ctx);
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
//#endregion
|
|
120
|
-
export { AIEngine as default };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
//#region src/modules/ai/toolkit.ts
|
|
3
|
-
/** Convert a Zod schema to the JSON Schema an AI provider (Anthropic / OpenAI) expects in a tool definition.
|
|
4
|
-
* Delegates to Zod v4's built-in converter — one implementation, so descriptions, literal discriminators,
|
|
5
|
-
* enums, nested objects and recursive (z.lazy) shapes all survive and the provider sees the same contract an
|
|
6
|
-
* MCP client does. `io: 'input'` describes what the agent must SEND; `unrepresentable: 'any'` degrades an
|
|
7
|
-
* exotic type to an empty schema instead of throwing, so one unusual tool never breaks the whole tool list. */
|
|
8
|
-
var zodToJsonSchema = (schema) => {
|
|
9
|
-
const json = z.toJSONSchema(schema, {
|
|
10
|
-
target: "draft-7",
|
|
11
|
-
io: "input",
|
|
12
|
-
unrepresentable: "any"
|
|
13
|
-
});
|
|
14
|
-
delete json.$schema;
|
|
15
|
-
return json;
|
|
16
|
-
};
|
|
17
|
-
var firstText = (content) => content.find((block) => block.type === "text")?.text;
|
|
18
|
-
var getAllowedModes = (operationType) => {
|
|
19
|
-
return operationType === "write" ? ["build"] : ["plan", "build"];
|
|
20
|
-
};
|
|
21
|
-
var toolResponseOk = (data, agentMessage) => {
|
|
22
|
-
return {
|
|
23
|
-
content: [{
|
|
24
|
-
type: "text",
|
|
25
|
-
text: agentMessage ?? JSON.stringify(data ?? null, null, 2)
|
|
26
|
-
}],
|
|
27
|
-
data
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
var toolResponseErr = (error) => ({
|
|
31
|
-
content: [{
|
|
32
|
-
type: "text",
|
|
33
|
-
text: error instanceof Error ? error.message : error
|
|
34
|
-
}],
|
|
35
|
-
isError: true
|
|
36
|
-
});
|
|
37
|
-
var isCallToolResult = (result) => typeof result === "object" && result !== null && Array.isArray(result.content);
|
|
38
|
-
var toolResponseFromResult = (result) => {
|
|
39
|
-
const content = [];
|
|
40
|
-
for (const block of result.content) if (block.type === "text") content.push({
|
|
41
|
-
type: "text",
|
|
42
|
-
text: block.text
|
|
43
|
-
});
|
|
44
|
-
else if (block.type === "image") content.push({
|
|
45
|
-
type: "image",
|
|
46
|
-
data: block.data,
|
|
47
|
-
mimeType: block.mimeType
|
|
48
|
-
});
|
|
49
|
-
return {
|
|
50
|
-
content,
|
|
51
|
-
data: result.structuredContent,
|
|
52
|
-
isError: result.isError ? true : void 0
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
var isToolActive = (tool) => Boolean(tool.handler);
|
|
56
|
-
var resolveToolHandler = (tool) => tool.handler;
|
|
57
|
-
var bindTools = (tools) => tools.filter(isToolActive);
|
|
58
|
-
//#endregion
|
|
59
|
-
export { bindTools, firstText, getAllowedModes, isCallToolResult, isToolActive, resolveToolHandler, toolResponseErr, toolResponseFromResult, toolResponseOk, zodToJsonSchema };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react-refresh/only-export-components -- one bundled entry: components cannot move out. */
|
|
2
|
-
import { useApp, useHostStyles } from '@modelcontextprotocol/ext-apps/react';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { createRoot } from 'react-dom/client';
|
|
5
|
-
|
|
6
|
-
import type { McpUiHostContext } from '@modelcontextprotocol/ext-apps';
|
|
7
|
-
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
-
|
|
9
|
-
/** The smallest MCP App view there is — copy this folder to start a new one. It shows the whole contract:
|
|
10
|
-
* connect, receive the tool call and its result, call a tool back, and inherit the host's look. Everything it
|
|
11
|
-
* imports is bundled into the page, so a view that stays this small stays a few KB. */
|
|
12
|
-
|
|
13
|
-
// Host CSS variables: the chat's own palette and fonts, applied by useHostStyles below.
|
|
14
|
-
const panel = {
|
|
15
|
-
padding: 16,
|
|
16
|
-
font: 'var(--font-sans, system-ui, sans-serif)',
|
|
17
|
-
color: 'var(--color-text-primary, #0f172a)',
|
|
18
|
-
background: 'var(--color-background-secondary, #f8fafc)',
|
|
19
|
-
borderRadius: 'var(--border-radius-md, 8px)'
|
|
20
|
-
} as const;
|
|
21
|
-
|
|
22
|
-
const textOf = (result: CallToolResult): string => result.content.find(entry => entry.type === 'text')?.text ?? '';
|
|
23
|
-
|
|
24
|
-
const ExampleApp = () => {
|
|
25
|
-
const [result, setResult] = useState<CallToolResult | null>(null);
|
|
26
|
-
const [context, setContext] = useState<McpUiHostContext | undefined>(undefined);
|
|
27
|
-
|
|
28
|
-
// useApp creates the App, runs onAppCreated so every handler is in place BEFORE the handshake, and connects.
|
|
29
|
-
const { app, error } = useApp({
|
|
30
|
-
appInfo: { name: 'Plitzi Example', version: '1.0.0' },
|
|
31
|
-
capabilities: {},
|
|
32
|
-
onAppCreated: instance => {
|
|
33
|
-
// The result of the tool that opened this view. `ontoolinput` gives its arguments instead.
|
|
34
|
-
instance.ontoolresult = setResult;
|
|
35
|
-
instance.onhostcontextchanged = params => setContext(previous => ({ ...previous, ...params }));
|
|
36
|
-
instance.onteardown = () => ({});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
useHostStyles(app, context);
|
|
41
|
-
|
|
42
|
-
if (error) {
|
|
43
|
-
return <div style={panel}>Could not connect to the host: {error.message}</div>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (!app) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const insets = context?.safeAreaInsets;
|
|
51
|
-
const message = result ? textOf(result) : 'Waiting for the tool result…';
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<div style={{ ...panel, margin: `${insets?.top ?? 0}px ${insets?.right ?? 0}px` }}>
|
|
55
|
-
<p>{message}</p>
|
|
56
|
-
{/* An app can call the server's tools on its own — each call is a round-trip, so plan for latency. */}
|
|
57
|
-
<button
|
|
58
|
-
type="button"
|
|
59
|
-
onClick={() => void app.callServerTool({ name: 'plitzi_search', arguments: {} }).then(setResult)}
|
|
60
|
-
>
|
|
61
|
-
Call plitzi_search
|
|
62
|
-
</button>
|
|
63
|
-
</div>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const root = document.getElementById('app');
|
|
68
|
-
if (root) {
|
|
69
|
-
createRoot(root).render(<ExampleApp />);
|
|
70
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { registerApp } from "./shared/registerApp.js";
|
|
2
|
-
import { iconFontCss } from "./render/styles.js";
|
|
3
|
-
import { RENDER_APP_URI, renderApp } from "./render/index.js";
|
|
4
|
-
//#region src/modules/mcp/apps/index.ts
|
|
5
|
-
/** What a view gets when the deployment says nothing: streaming on, because a host that streams no arguments
|
|
6
|
-
* paints exactly what it painted before. */
|
|
7
|
-
var DEFAULT_VIEW_SETTINGS = { streaming: true };
|
|
8
|
-
/** Every MCP App this server serves. A new one is a folder beside `render/` (its definition + its view) and one
|
|
9
|
-
* line here — the tool that opens it points at its `uri` through `ui: { resourceUri }`. Start from `example/`,
|
|
10
|
-
* which is that same shape stripped to the minimum. */
|
|
11
|
-
var apps = [renderApp];
|
|
12
|
-
var registerApps = (server, settings = DEFAULT_VIEW_SETTINGS) => {
|
|
13
|
-
for (const app of apps) registerApp(server, app, settings);
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
16
|
-
export { DEFAULT_VIEW_SETTINGS, RENDER_APP_URI, apps, iconFontCss, registerApps };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { VIEW_DIR } from "../shared/assets.js";
|
|
2
|
-
import { iconFontCss, widgetCss } from "./styles.js";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
//#region src/modules/mcp/apps/render/index.ts
|
|
6
|
-
var RENDER_APP_URI = "ui://plitzi/render.html";
|
|
7
|
-
var HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
var renderApp = {
|
|
9
|
-
uri: RENDER_APP_URI,
|
|
10
|
-
name: "plitzi-render-app",
|
|
11
|
-
title: "Plitzi widget",
|
|
12
|
-
description: "Interactive view that renders a plitzi_render widget with the Plitzi SDK.",
|
|
13
|
-
entry: path.join(HERE, VIEW_DIR, "index.tsx"),
|
|
14
|
-
styles: () => [widgetCss()]
|
|
15
|
-
};
|
|
16
|
-
//#endregion
|
|
17
|
-
export { RENDER_APP_URI, iconFontCss, renderApp };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { require } from "../shared/resolve.js";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { readFileSync } from "node:fs";
|
|
4
|
-
//#region src/modules/mcp/apps/render/styles.ts
|
|
5
|
-
/** The SDK stylesheet, split in two.
|
|
6
|
-
*
|
|
7
|
-
* Everything the page shell inlines is paid for by EVERY widget: the host loads the ui:// page into a fresh
|
|
8
|
-
* sandboxed iframe and parses it whole before anything paints, which is the "Rendering…" the user waits through.
|
|
9
|
-
* Three of those @font-face blocks are Font Awesome shipped as base64 woff2 — ~330 KB, close to a fifth of the
|
|
10
|
-
* page — and only a widget that authored a `fontAwesome` element has any use for them.
|
|
11
|
-
*
|
|
12
|
-
* So the shell takes the base, and the fonts travel in the tool result of the renders that actually draw an icon
|
|
13
|
-
* (see tools/render.ts). A widget without icons never downloads a glyph; one with icons looks exactly the same as
|
|
14
|
-
* before. */
|
|
15
|
-
/** Where the closing brace of the block opened at `open` is, so a nested one cannot end it early. Returns the
|
|
16
|
-
* string's length when the CSS is truncated mid-block, which drops that tail rather than mixing it into the base. */
|
|
17
|
-
var blockEnd = (css, open) => {
|
|
18
|
-
let depth = 0;
|
|
19
|
-
for (let at = open; at < css.length; at++) if (css[at] === "{") depth++;
|
|
20
|
-
else if (css[at] === "}") {
|
|
21
|
-
depth--;
|
|
22
|
-
if (depth === 0) return at + 1;
|
|
23
|
-
}
|
|
24
|
-
return css.length;
|
|
25
|
-
};
|
|
26
|
-
/** Lifts every @font-face block out of a stylesheet. Brace counting rather than a CSS parser: a @font-face body is
|
|
27
|
-
* plain declarations, and base64 payloads and url() values carry no braces of their own. */
|
|
28
|
-
var splitFontFaces = (css) => {
|
|
29
|
-
const base = [];
|
|
30
|
-
const fonts = [];
|
|
31
|
-
let cursor = 0;
|
|
32
|
-
for (let at = css.indexOf("@font-face", cursor); at !== -1; at = css.indexOf("@font-face", cursor)) {
|
|
33
|
-
const open = css.indexOf("{", at);
|
|
34
|
-
if (open === -1) break;
|
|
35
|
-
const end = blockEnd(css, open);
|
|
36
|
-
base.push(css.slice(cursor, at));
|
|
37
|
-
fonts.push(css.slice(at, end));
|
|
38
|
-
cursor = end;
|
|
39
|
-
}
|
|
40
|
-
base.push(css.slice(cursor));
|
|
41
|
-
return {
|
|
42
|
-
base: base.join(""),
|
|
43
|
-
fonts: fonts.join("")
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
var stylesheet = () => readFileSync(path.join(path.dirname(require.resolve("@plitzi/plitzi-sdk")), "plitzi-sdk.css"), "utf-8");
|
|
47
|
-
var split;
|
|
48
|
-
var sdkStyles = () => split ??= splitFontFaces(stylesheet());
|
|
49
|
-
/** What the page shell inlines: the SDK stylesheet without the icon fonts. */
|
|
50
|
-
var widgetCss = () => sdkStyles().base;
|
|
51
|
-
/** The icon fonts, for the renders that draw one. */
|
|
52
|
-
var iconFontCss = () => sdkStyles().fonts;
|
|
53
|
-
//#endregion
|
|
54
|
-
export { iconFontCss, splitFontFaces, widgetCss };
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/** Where the batch a widget was built from survives between calls — on the HOST, so the server can keep nothing.
|
|
2
|
-
*
|
|
3
|
-
* It cannot live in the view's memory: the Apps spec binds a view to ONE tool call (`ui/notifications/tool-input`
|
|
4
|
-
* is sent "at most once", and the host renders a fresh iframe when a UI tool is called), so the patch call the
|
|
5
|
-
* model makes arrives in a brand-new instance whose memory is empty. localStorage keyed by an id the server hands
|
|
6
|
-
* back is the spec's own state-persistence pattern (`_meta.viewUUID` in the Apps docs); here the key is the
|
|
7
|
-
* renderId, which the model also carries, so a patch names the widget it means instead of assuming "the last one".
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const PREFIX = 'plitzi.render.';
|
|
11
|
-
const MAX_ENTRIES = 5;
|
|
12
|
-
// A renderId only lives in one conversation's context, so a batch outlives its usefulness the moment that
|
|
13
|
-
// conversation is over — and a conversation the user abandoned would otherwise leave its widget in the host's
|
|
14
|
-
// storage for good. Generous enough that no live conversation loses its widget, short enough to be housekeeping.
|
|
15
|
-
const MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
16
|
-
|
|
17
|
-
type Stored = { savedAt: number; operations: unknown[] };
|
|
18
|
-
|
|
19
|
-
// A sandboxed iframe without allow-same-origin throws on the ACCESS to localStorage, not on the call — so even
|
|
20
|
-
// reading the property has to be guarded. A host that denies storage simply gets no patching.
|
|
21
|
-
const localStore = (): Storage | undefined => {
|
|
22
|
-
try {
|
|
23
|
-
return window.localStorage;
|
|
24
|
-
} catch {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const parse = (raw: string | null): Stored | undefined => {
|
|
30
|
-
if (raw === null) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const value = JSON.parse(raw) as Stored;
|
|
36
|
-
|
|
37
|
-
return Array.isArray(value.operations) ? value : undefined;
|
|
38
|
-
} catch {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const ownKeys = (store: Storage): string[] => {
|
|
44
|
-
const keys: string[] = [];
|
|
45
|
-
for (let index = 0; index < store.length; index += 1) {
|
|
46
|
-
const key = store.key(index);
|
|
47
|
-
if (key !== null && key.startsWith(PREFIX)) {
|
|
48
|
-
keys.push(key);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return keys;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const dropStale = (store: Storage, keep: string): void => {
|
|
56
|
-
const others = ownKeys(store)
|
|
57
|
-
.filter(key => key !== keep)
|
|
58
|
-
.map(key => ({ key, savedAt: parse(store.getItem(key))?.savedAt ?? 0 }))
|
|
59
|
-
.sort((a, b) => b.savedAt - a.savedAt);
|
|
60
|
-
const expired = Date.now() - MAX_AGE_MS;
|
|
61
|
-
|
|
62
|
-
for (const [index, entry] of others.entries()) {
|
|
63
|
-
if (index >= MAX_ENTRIES - 1 || entry.savedAt < expired) {
|
|
64
|
-
store.removeItem(entry.key);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const readHeldBatch = (renderId: string, store = localStore()): unknown[] | undefined => {
|
|
70
|
-
if (!store) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const stored = parse(store.getItem(`${PREFIX}${renderId}`));
|
|
75
|
-
if (!stored || stored.savedAt < Date.now() - MAX_AGE_MS) {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return stored.operations;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const writeHeldBatch = (renderId: string, operations: unknown[], store = localStore()): void => {
|
|
83
|
-
if (!store) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const key = `${PREFIX}${renderId}`;
|
|
88
|
-
const payload = JSON.stringify({ savedAt: Date.now(), operations } satisfies Stored);
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
dropStale(store, key);
|
|
92
|
-
store.setItem(key, payload);
|
|
93
|
-
} catch {
|
|
94
|
-
// Out of quota: the widget just rendered is the only one still worth patching, so the rest go.
|
|
95
|
-
for (const other of ownKeys(store)) {
|
|
96
|
-
if (other !== key) {
|
|
97
|
-
store.removeItem(other);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
store.setItem(key, payload);
|
|
103
|
-
} catch {
|
|
104
|
-
// Storage is full or refused: patching degrades to "re-send the full batch", never to a wrong widget.
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|